From c63539ffe4c0e327337a1a51f638d9c8c958cb26 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 7 Nov 2022 12:54:13 +0100 Subject: [PATCH] sphinx: copy files from texi2rst-generated repository ChangeLog: * doc/Makefile: New file. * doc/_static/custom.css: New file. * doc/baseconf.py: New file. * doc/bsd.rst: New file. * doc/contrib.rst: New file. * doc/contribute.rst: New file. * doc/cppdiropts.rst: New file. * doc/cppenv.rst: New file. * doc/cppopts.rst: New file. * doc/cppwarnopts.rst: New file. * doc/favicon.ico: New file. * doc/funding.rst: New file. * doc/gcc_sphinx.py: New file. * doc/gnu.rst: New file. * doc/gnu_free_documentation_license.rst: New file. * doc/gpl-3.0.rst: New file. * doc/indices-and-tables.rst: New file. * doc/lgpl-2.1.rst: New file. * doc/logo.pdf: New file. * doc/logo.svg: New file. * doc/md.rst: New file. * doc/requirements.txt: New file. gcc/d/ChangeLog: * doc/conf.py: New file. * doc/copyright.rst: New file. * doc/general-public-license-3.rst: New file. * doc/gnu-free-documentation-license.rst: New file. * doc/index.rst: New file. * doc/indices-and-tables.rst: New file. * doc/invoking-gdc.rst: New file. * doc/invoking-gdc/code-generation.rst: New file. * doc/invoking-gdc/developer-options.rst: New file. * doc/invoking-gdc/input-and-output-files.rst: New file. * doc/invoking-gdc/options-for-directory-search.rst: New file. * doc/invoking-gdc/options-for-linking.rst: New file. * doc/invoking-gdc/runtime-options.rst: New file. * doc/invoking-gdc/warnings.rst: New file. gcc/ChangeLog: * doc/cpp/character-sets.rst: New file. * doc/cpp/conditional-syntax.rst: New file. * doc/cpp/conditional-uses.rst: New file. * doc/cpp/conditionals.rst: New file. * doc/cpp/conf.py: New file. * doc/cpp/copyright.rst: New file. * doc/cpp/deleted-code.rst: New file. * doc/cpp/diagnostics.rst: New file. * doc/cpp/environment-variables.rst: New file. * doc/cpp/gnu-free-documentation-license.rst: New file. * doc/cpp/header-files.rst: New file. * doc/cpp/header-files/alternatives-to-wrapper-ifndef.rst: New file. * doc/cpp/header-files/computed-includes.rst: New file. * doc/cpp/header-files/include-operation.rst: New file. * doc/cpp/header-files/include-syntax.rst: New file. * doc/cpp/header-files/once-only-headers.rst: New file. * doc/cpp/header-files/search-path.rst: New file. * doc/cpp/header-files/system-headers.rst: New file. * doc/cpp/header-files/wrapper-headers.rst: New file. * doc/cpp/implementation-defined-behavior.rst: New file. * doc/cpp/implementation-details.rst: New file. * doc/cpp/implementation-limits.rst: New file. * doc/cpp/index.rst: New file. * doc/cpp/indices-and-tables.rst: New file. * doc/cpp/initial-processing.rst: New file. * doc/cpp/invocation.rst: New file. * doc/cpp/line-control.rst: New file. * doc/cpp/macros.rst: New file. * doc/cpp/macros/concatenation.rst: New file. * doc/cpp/macros/directives-within-macro-arguments.rst: New file. * doc/cpp/macros/function-like-macros.rst: New file. * doc/cpp/macros/macro-arguments.rst: New file. * doc/cpp/macros/macro-pitfalls.rst: New file. * doc/cpp/macros/object-like-macros.rst: New file. * doc/cpp/macros/predefined-macros.rst: New file. * doc/cpp/macros/stringizing.rst: New file. * doc/cpp/macros/undefining-and-redefining-macros.rst: New file. * doc/cpp/macros/variadic-macros.rst: New file. * doc/cpp/obsolete-features.rst: New file. * doc/cpp/other-directives.rst: New file. * doc/cpp/overview.rst: New file. * doc/cpp/pragmas.rst: New file. * doc/cpp/preprocessor-output.rst: New file. * doc/cpp/the-preprocessing-language.rst: New file. * doc/cpp/tokenization.rst: New file. * doc/cpp/traditional-lexical-analysis.rst: New file. * doc/cpp/traditional-macros.rst: New file. * doc/cpp/traditional-miscellany.rst: New file. * doc/cpp/traditional-mode.rst: New file. * doc/cpp/traditional-warnings.rst: New file. * doc/cppinternals/conf.py: New file. * doc/cppinternals/copyright.rst: New file. * doc/cppinternals/cppinternals.rst: New file. * doc/cppinternals/cpplib.rst: New file. * doc/cppinternals/files.rst: New file. * doc/cppinternals/index.rst: New file. * doc/cppinternals/indices-and-tables.rst: New file. * doc/cppinternals/internal-representation-of-macros.rst: New file. * doc/cppinternals/just-which-line-number-anyway.rst: New file. * doc/cppinternals/lexing-a-line.rst: New file. * doc/cppinternals/lexing-a-token.rst: New file. * doc/cppinternals/looking-for-a-function-like-macros-opening-parenthesis.rst: New file. * doc/cppinternals/macro-expansion-overview.rst: New file. * doc/cppinternals/marking-tokens-ineligible-for-future-expansion.rst: New file. * doc/cppinternals/multiple-include-optimization.rst: New file. * doc/cppinternals/overview.rst: New file. * doc/cppinternals/representation-of-line-numbers.rst: New file. * doc/cppinternals/scanning-the-replacement-list-for-macros-to-expand.rst: New file. * doc/gcc/binary-compatibility.rst: New file. * doc/gcc/c++-implementation-defined-behavior.rst: New file. * doc/gcc/c-implementation-defined-behavior.rst: New file. * doc/gcc/c-implementation-defined-behavior/architecture.rst: New file. * doc/gcc/c-implementation-defined-behavior/arrays-and-pointers.rst: New file. * doc/gcc/c-implementation-defined-behavior/characters.rst: New file. * doc/gcc/c-implementation-defined-behavior/declarators.rst: New file. * doc/gcc/c-implementation-defined-behavior/environment.rst: New file. * doc/gcc/c-implementation-defined-behavior/floating-point.rst: New file. * doc/gcc/c-implementation-defined-behavior/hints.rst: New file. * doc/gcc/c-implementation-defined-behavior/identifiers.rst: New file. * doc/gcc/c-implementation-defined-behavior/integers.rst: New file. * doc/gcc/c-implementation-defined-behavior/library-functions.rst: New file. * doc/gcc/c-implementation-defined-behavior/locale-specific-behavior.rst: New file. * doc/gcc/c-implementation-defined-behavior/preprocessing-directives.rst: New file. * doc/gcc/c-implementation-defined-behavior/qualifiers.rst: New file. * doc/gcc/c-implementation-defined-behavior/statements.rst: New file. * doc/gcc/c-implementation-defined-behavior/structures-unions-enumerations-and-bit-fields.rst: New file. * doc/gcc/c-implementation-defined-behavior/translation.rst: New file. * doc/gcc/conditionally-supported-behavior.rst: New file. * doc/gcc/conf.py: New file. * doc/gcc/contributing-to-gcc-development.rst: New file. * doc/gcc/contributors-to-gcc.rst: New file. * doc/gcc/copyright.rst: New file. * doc/gcc/exception-handling.rst: New file. * doc/gcc/extensions-to-the-c++-language.rst: New file. * doc/gcc/extensions-to-the-c++-language/backwards-compatibility.rst: New file. * doc/gcc/extensions-to-the-c++-language/c++-concepts.rst: New file. * doc/gcc/extensions-to-the-c++-language/c++-interface-and-implementation-pragmas.rst: New file. * doc/gcc/extensions-to-the-c++-language/c++-specific-variable-function-and-type-attributes.rst: New file. * doc/gcc/extensions-to-the-c++-language/deprecated-features.rst: New file. * doc/gcc/extensions-to-the-c++-language/extracting-the-function-pointer-from-a-bound-pointer-to-member-function.rst: New file. * doc/gcc/extensions-to-the-c++-language/function-multiversioning.rst: New file. * doc/gcc/extensions-to-the-c++-language/restricting-pointer-aliasing.rst: New file. * doc/gcc/extensions-to-the-c++-language/type-traits.rst: New file. * doc/gcc/extensions-to-the-c++-language/vague-linkage.rst: New file. * doc/gcc/extensions-to-the-c++-language/when-is-a-volatile-c++-object-accessed.rst: New file. * doc/gcc/extensions-to-the-c++-language/wheres-the-template.rst: New file. * doc/gcc/extensions-to-the-c-language-family.rst: New file. * doc/gcc/extensions-to-the-c-language-family/128-bit-integers.rst: New file. * doc/gcc/extensions-to-the-c-language-family/additional-floating-types.rst: New file. * doc/gcc/extensions-to-the-c-language-family/alternate-keywords.rst: New file. * doc/gcc/extensions-to-the-c-language-family/an-inline-function-is-as-fast-as-a-macro.rst: New file. * doc/gcc/extensions-to-the-c-language-family/arithmetic-on-void-and-function-pointers.rst: New file. * doc/gcc/extensions-to-the-c-language-family/arrays-of-length-zero.rst: New file. * doc/gcc/extensions-to-the-c-language-family/arrays-of-variable-length.rst: New file. * doc/gcc/extensions-to-the-c-language-family/attribute-syntax.rst: New file. * doc/gcc/extensions-to-the-c-language-family/binary-constants-using-the-0b-prefix.rst: New file. * doc/gcc/extensions-to-the-c-language-family/built-in-functions-for-memory-model-aware-atomic-operations.rst: New file. * doc/gcc/extensions-to-the-c-language-family/built-in-functions-to-perform-arithmetic-with-overflow-checking.rst: New file. * doc/gcc/extensions-to-the-c-language-family/c++-style-comments.rst: New file. * doc/gcc/extensions-to-the-c-language-family/case-ranges.rst: New file. * doc/gcc/extensions-to-the-c-language-family/cast-to-a-union-type.rst: New file. * doc/gcc/extensions-to-the-c-language-family/complex-numbers.rst: New file. * doc/gcc/extensions-to-the-c-language-family/compound-literals.rst: New file. * doc/gcc/extensions-to-the-c-language-family/conditionals-with-omitted-operands.rst: New file. * doc/gcc/extensions-to-the-c-language-family/constructing-function-calls.rst: New file. * doc/gcc/extensions-to-the-c-language-family/decimal-floating-types.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/aarch64-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/amd-gcn-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/arc-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/arm-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/avr-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/blackfin-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/bpf-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/c-sky-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/common-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/epiphany-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/h8-300-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/ia-64-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m32c-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m32r-d-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m68k-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mcore-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mep-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/microblaze-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/microsoft-windows-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mips-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/msp430-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nds32-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nios-ii-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nvidia-ptx-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/powerpc-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/risc-v-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/rl78-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/rx-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/s-390-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/sh-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/symbian-os-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/v850-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/visium-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/x86-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/xstormy16-function-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/designated-initializers.rst: New file. * doc/gcc/extensions-to-the-c-language-family/determining-the-alignment-of-functions-types-or-variables.rst: New file. * doc/gcc/extensions-to-the-c-language-family/dollar-signs-in-identifier-names.rst: New file. * doc/gcc/extensions-to-the-c-language-family/double-word-integers.rst: New file. * doc/gcc/extensions-to-the-c-language-family/enumerator-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/fixed-point-types.rst: New file. * doc/gcc/extensions-to-the-c-language-family/format-checks-specific-to-particular-target-machines.rst: New file. * doc/gcc/extensions-to-the-c-language-family/function-names-as-strings.rst: New file. * doc/gcc/extensions-to-the-c-language-family/getting-the-return-or-frame-address-of-a-function.rst: New file. * doc/gcc/extensions-to-the-c-language-family/half-precision-floating-point.rst: New file. * doc/gcc/extensions-to-the-c-language-family/hex-floats.rst: New file. * doc/gcc/extensions-to-the-c-language-family/how-to-use-inline-assembly-language-in-c-code.rst: New file. * doc/gcc/extensions-to-the-c-language-family/incomplete-enum-types.rst: New file. * doc/gcc/extensions-to-the-c-language-family/label-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/labels-as-values.rst: New file. * doc/gcc/extensions-to-the-c-language-family/legacy-sync-built-in-functions-for-atomic-memory-access.rst: New file. * doc/gcc/extensions-to-the-c-language-family/locally-declared-labels.rst: New file. * doc/gcc/extensions-to-the-c-language-family/macros-with-a-variable-number-of-arguments.rst: New file. * doc/gcc/extensions-to-the-c-language-family/mixed-declarations-labels-and-code.rst: New file. * doc/gcc/extensions-to-the-c-language-family/named-address-spaces.rst: New file. * doc/gcc/extensions-to-the-c-language-family/nested-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/non-constant-initializers.rst: New file. * doc/gcc/extensions-to-the-c-language-family/non-lvalue-arrays-may-have-subscripts.rst: New file. * doc/gcc/extensions-to-the-c-language-family/nonlocal-gotos.rst: New file. * doc/gcc/extensions-to-the-c-language-family/object-size-checking-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/other-built-in-functions-provided-by-gcc.rst: New file. * doc/gcc/extensions-to-the-c-language-family/pointer-arguments-in-variadic-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/pointers-to-arrays-with-qualifiers-work-as-expected.rst: New file. * doc/gcc/extensions-to-the-c-language-family/pragmas-accepted-by-gcc.rst: New file. * doc/gcc/extensions-to-the-c-language-family/prototypes-and-old-style-function-definitions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/referring-to-a-type-with-typeof.rst: New file. * doc/gcc/extensions-to-the-c-language-family/slightly-looser-rules-for-escaped-newlines.rst: New file. * doc/gcc/extensions-to-the-c-language-family/specifying-attributes-of-types.rst: New file. * doc/gcc/extensions-to-the-c-language-family/specifying-attributes-of-variables.rst: New file. * doc/gcc/extensions-to-the-c-language-family/statement-attributes.rst: New file. * doc/gcc/extensions-to-the-c-language-family/statements-and-declarations-in-expressions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/structures-with-no-members.rst: New file. * doc/gcc/extensions-to-the-c-language-family/support-for-offsetof.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/aarch64-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/alpha-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/altera-nios-ii-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/arc-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/arc-simd-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-armv8-m-security-extensions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-c-language-extensions-acle.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-floating-point-status-and-control-intrinsics.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-iwmmxt-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/avr-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/basic-powerpc-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/blackfin-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/bpf-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/fr-v-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-dsp-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-loongson-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-paired-single-support.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-simd-architecture-msa-support.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/msp430-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/nds32-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/other-mips-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/picochip-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-altivec-vsx-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-atomic-memory-operation-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-hardware-transactional-memory-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-matrix-multiply-assist-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/pru-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/risc-v-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/rx-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/s-390-system-z-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/sh-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/sparc-vis-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/ti-c6x-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-control-flow-protection-intrinsics.rst: New file. * doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-transactional-memory-intrinsics.rst: New file. * doc/gcc/extensions-to-the-c-language-family/the-character-esc-in-constants.rst: New file. * doc/gcc/extensions-to-the-c-language-family/thread-local-storage.rst: New file. * doc/gcc/extensions-to-the-c-language-family/unnamed-structure-and-union-fields.rst: New file. * doc/gcc/extensions-to-the-c-language-family/using-vector-instructions-through-built-in-functions.rst: New file. * doc/gcc/extensions-to-the-c-language-family/when-is-a-volatile-object-accessed.rst: New file. * doc/gcc/extensions-to-the-c-language-family/x86-specific-memory-model-extensions-for-transactional-memory.rst: New file. * doc/gcc/funding.rst: New file. * doc/gcc/gcc-command-options.rst: New file. * doc/gcc/gcc-command-options/c++-modules.rst: New file. * doc/gcc/gcc-command-options/compiling-c++-programs.rst: New file. * doc/gcc/gcc-command-options/description.rst: New file. * doc/gcc/gcc-command-options/environment-variables-affecting-gcc.rst: New file. * doc/gcc/gcc-command-options/gcc-developer-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/aarch64-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/adapteva-epiphany-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/amd-gcn-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/arc-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/arm-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/avr-mmcu.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/avr-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/blackfin-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/c-sky-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/c6x-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/cris-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/darwin-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/dec-alpha-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/ebpf-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/fr30-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/frv-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/ft32-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/gnu-linux-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/h8-300-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/hppa-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/ia-64-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/ibm-rs-6000-and-powerpc-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/lm32-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/loongarch-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/m32c-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/m32r-d-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/m680x0-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/mcore-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/mep-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/microblaze-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/mips-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/mmix-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/mn10300-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/moxie-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/msp430-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/nds32-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/nios-ii-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/nvidia-ptx-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/openrisc-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/options-for-system-v.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/pdp-11-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/picochip-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/powerpc-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/pru-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/risc-v-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/rl78-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/rx-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/s-390-and-zseries-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/score-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/sh-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/solaris-2-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/sparc-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/v850-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/vax-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/visium-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/vms-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/vxworks-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/x86-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/x86-windows-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/xstormy16-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/xtensa-options.rst: New file. * doc/gcc/gcc-command-options/machine-dependent-options/zseries-options.rst: New file. * doc/gcc/gcc-command-options/option-summary.rst: New file. * doc/gcc/gcc-command-options/options-controlling-c++-dialect.rst: New file. * doc/gcc/gcc-command-options/options-controlling-c-dialect.rst: New file. * doc/gcc/gcc-command-options/options-controlling-objective-c-and-objective-c++-dialects.rst: New file. * doc/gcc/gcc-command-options/options-controlling-the-kind-of-output.rst: New file. * doc/gcc/gcc-command-options/options-controlling-the-preprocessor.rst: New file. * doc/gcc/gcc-command-options/options-for-code-generation-conventions.rst: New file. * doc/gcc/gcc-command-options/options-for-debugging-your-program.rst: New file. * doc/gcc/gcc-command-options/options-for-directory-search.rst: New file. * doc/gcc/gcc-command-options/options-for-linking.rst: New file. * doc/gcc/gcc-command-options/options-that-control-optimization.rst: New file. * doc/gcc/gcc-command-options/options-that-control-static-analysis.rst: New file. * doc/gcc/gcc-command-options/options-to-control-diagnostic-messages-formatting.rst: New file. * doc/gcc/gcc-command-options/options-to-request-or-suppress-warnings.rst: New file. * doc/gcc/gcc-command-options/passing-options-to-the-assembler.rst: New file. * doc/gcc/gcc-command-options/program-instrumentation-options.rst: New file. * doc/gcc/gcc-command-options/specifying-subprocesses-and-the-switches-to-pass-to-them.rst: New file. * doc/gcc/gcc-command-options/using-precompiled-headers.rst: New file. * doc/gcc/gcc.rst: New file. * doc/gcc/gcov-dump.rst: New file. * doc/gcc/gcov-tool.rst: New file. * doc/gcc/gcov.rst: New file. * doc/gcc/gcov/brief-description-of-gcov-data-files.rst: New file. * doc/gcc/gcov/data-file-relocation-to-support-cross-profiling.rst: New file. * doc/gcc/gcov/introduction-to-gcov.rst: New file. * doc/gcc/gcov/invoking-gcov.rst: New file. * doc/gcc/gcov/profiling-and-test-coverage-in-freestanding-environments.rst: New file. * doc/gcc/gcov/using-gcov-with-gcc-optimization.rst: New file. * doc/gcc/general-public-license-3.rst: New file. * doc/gcc/gnu-free-documentation-license.rst: New file. * doc/gcc/gnu-objective-c-features.rst: New file. * doc/gcc/gnu-objective-c-features/compatibilityalias.rst: New file. * doc/gcc/gnu-objective-c-features/constant-string-objects.rst: New file. * doc/gcc/gnu-objective-c-features/exceptions.rst: New file. * doc/gcc/gnu-objective-c-features/fast-enumeration.rst: New file. * doc/gcc/gnu-objective-c-features/garbage-collection.rst: New file. * doc/gcc/gnu-objective-c-features/gnu-objective-c-runtime-api.rst: New file. * doc/gcc/gnu-objective-c-features/load-executing-code-before-main.rst: New file. * doc/gcc/gnu-objective-c-features/messaging-with-the-gnu-objective-c-runtime.rst: New file. * doc/gcc/gnu-objective-c-features/synchronization.rst: New file. * doc/gcc/gnu-objective-c-features/type-encoding.rst: New file. * doc/gcc/gnu.rst: New file. * doc/gcc/have-you-found-a-bug.rst: New file. * doc/gcc/how-and-where-to-report-bugs.rst: New file. * doc/gcc/how-to-get-help-with-gcc.rst: New file. * doc/gcc/index.rst: New file. * doc/gcc/indices-and-tables.rst: New file. * doc/gcc/known-causes-of-trouble-with-gcc.rst: New file. * doc/gcc/known-causes-of-trouble-with-gcc/actual-bugs-we-havent-fixed-yet.rst: New file. * doc/gcc/known-causes-of-trouble-with-gcc/certain-changes-we-dont-want-to-make.rst: New file. * doc/gcc/known-causes-of-trouble-with-gcc/common-misunderstandings-with-gnu-c.rst: New file. * doc/gcc/known-causes-of-trouble-with-gcc/disappointments-and-misunderstandings.rst: New file. * doc/gcc/known-causes-of-trouble-with-gcc/fixed-header-files.rst: New file. * doc/gcc/known-causes-of-trouble-with-gcc/incompatibilities-of-gcc.rst: New file. * doc/gcc/known-causes-of-trouble-with-gcc/interoperation.rst: New file. * doc/gcc/known-causes-of-trouble-with-gcc/standard-libraries.rst: New file. * doc/gcc/known-causes-of-trouble-with-gcc/warning-messages-and-error-messages.rst: New file. * doc/gcc/language-standards-supported-by-gcc.rst: New file. * doc/gcc/language-standards-supported-by-gcc/c++-language.rst: New file. * doc/gcc/language-standards-supported-by-gcc/c-language.rst: New file. * doc/gcc/language-standards-supported-by-gcc/d-language.rst: New file. * doc/gcc/language-standards-supported-by-gcc/go-language.rst: New file. * doc/gcc/language-standards-supported-by-gcc/objective-c-and-objective-c++-languages.rst: New file. * doc/gcc/language-standards-supported-by-gcc/references-for-other-languages.rst: New file. * doc/gcc/lto-dump.rst: New file. * doc/gcc/programming-languages-supported-by-gcc.rst: New file. * doc/gcc/reporting-bugs.rst: New file. * doc/gccint/analysis-and-optimization-of-gimple-tuples.rst: New file. * doc/gccint/analysis-and-optimization-of-gimple-tuples/alias-analysis.rst: New file. * doc/gccint/analysis-and-optimization-of-gimple-tuples/annotations.rst: New file. * doc/gccint/analysis-and-optimization-of-gimple-tuples/memory-model.rst: New file. * doc/gccint/analysis-and-optimization-of-gimple-tuples/ssa-operands.rst: New file. * doc/gccint/analysis-and-optimization-of-gimple-tuples/static-single-assignment.rst: New file. * doc/gccint/analysis-and-representation-of-loops.rst: New file. * doc/gccint/analysis-and-representation-of-loops/data-dependency-analysis.rst: New file. * doc/gccint/analysis-and-representation-of-loops/iv-analysis-on-rtl.rst: New file. * doc/gccint/analysis-and-representation-of-loops/loop-closed-ssa-form.rst: New file. * doc/gccint/analysis-and-representation-of-loops/loop-manipulation.rst: New file. * doc/gccint/analysis-and-representation-of-loops/loop-querying.rst: New file. * doc/gccint/analysis-and-representation-of-loops/loop-representation.rst: New file. * doc/gccint/analysis-and-representation-of-loops/number-of-iterations-analysis.rst: New file. * doc/gccint/analysis-and-representation-of-loops/scalar-evolutions.rst: New file. * doc/gccint/analyzer-internals.rst: New file. * doc/gccint/collect2.rst: New file. * doc/gccint/conf.py: New file. * doc/gccint/contributing-to-gcc-development.rst: New file. * doc/gccint/contributors-to-gcc.rst: New file. * doc/gccint/control-flow-graph.rst: New file. * doc/gccint/control-flow-graph/basic-blocks.rst: New file. * doc/gccint/control-flow-graph/edges.rst: New file. * doc/gccint/control-flow-graph/liveness-information.rst: New file. * doc/gccint/control-flow-graph/maintaining-the-cfg.rst: New file. * doc/gccint/control-flow-graph/profile-information.rst: New file. * doc/gccint/copyright.rst: New file. * doc/gccint/debugging-the-analyzer.rst: New file. * doc/gccint/funding.rst: New file. * doc/gccint/gcc-and-portability.rst: New file. * doc/gccint/general-public-license-3.rst: New file. * doc/gccint/generic.rst: New file. * doc/gccint/generic/attributes-in-trees.rst: New file. * doc/gccint/generic/c-and-c++-trees.rst: New file. * doc/gccint/generic/declarations.rst: New file. * doc/gccint/generic/deficiencies.rst: New file. * doc/gccint/generic/expressions.rst: New file. * doc/gccint/generic/functions.rst: New file. * doc/gccint/generic/language-dependent-trees.rst: New file. * doc/gccint/generic/overview.rst: New file. * doc/gccint/generic/statements.rst: New file. * doc/gccint/generic/types.rst: New file. * doc/gccint/gimple-api.rst: New file. * doc/gccint/gimple.rst: New file. * doc/gccint/gimple/adding-a-new-gimple-statement-code.rst: New file. * doc/gccint/gimple/class-hierarchy-of-gimple-statements.rst: New file. * doc/gccint/gimple/exception-handling.rst: New file. * doc/gccint/gimple/gimple-instruction-set.rst: New file. * doc/gccint/gimple/gimple-sequences.rst: New file. * doc/gccint/gimple/manipulating-gimple-statements.rst: New file. * doc/gccint/gimple/operands.rst: New file. * doc/gccint/gimple/sequence-iterators.rst: New file. * doc/gccint/gimple/statement-and-operand-traversals.rst: New file. * doc/gccint/gimple/temporaries.rst: New file. * doc/gccint/gimple/tuple-representation.rst: New file. * doc/gccint/gimple/tuple-specific-accessors.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleasm.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleassign.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimplebind.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimplecall.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimplecatch.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimplecond.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpledebug.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleehfilter.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimplegoto.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimplelabel.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimplenop.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleompatomicload.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleompatomicstore.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleompcontinue.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleompcritical.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleompfor.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleompmaster.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleompordered.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleompparallel.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleompreturn.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleompsection.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleompsections.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleompsingle.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimplephi.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleresx.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimplereturn.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpleswitch.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimpletry.rst: New file. * doc/gccint/gimple/tuple-specific-accessors/gimplewithcleanupexpr.rst: New file. * doc/gccint/gnu-free-documentation-license.rst: New file. * doc/gccint/guidelines-for-diagnostics.rst: New file. * doc/gccint/guidelines-for-options.rst: New file. * doc/gccint/host-common.rst: New file. * doc/gccint/host-configuration.rst: New file. * doc/gccint/host-filesystem.rst: New file. * doc/gccint/host-makefile-fragments.rst: New file. * doc/gccint/host-misc.rst: New file. * doc/gccint/index.rst: New file. * doc/gccint/indices-and-tables.rst: New file. * doc/gccint/interfacing-to-gcc-output.rst: New file. * doc/gccint/introduction.rst: New file. * doc/gccint/language-front-ends-in-gcc.rst: New file. * doc/gccint/link-time-optimization.rst: New file. * doc/gccint/link-time-optimization/design-overview.rst: New file. * doc/gccint/link-time-optimization/internal-flags-controlling-lto1.rst: New file. * doc/gccint/link-time-optimization/lto-file-sections.rst: New file. * doc/gccint/link-time-optimization/using-summary-information-in-ipa-passes.rst: New file. * doc/gccint/link-time-optimization/whole-program-assumptions-linker-plugin-and-symbol-visibilities.rst: New file. * doc/gccint/machine-descriptions.rst: New file. * doc/gccint/machine-descriptions/c-statements-for-assembler-output.rst: New file. * doc/gccint/machine-descriptions/canonicalization-of-instructions.rst: New file. * doc/gccint/machine-descriptions/conditional-execution.rst: New file. * doc/gccint/machine-descriptions/constant-definitions.rst: New file. * doc/gccint/machine-descriptions/defining-how-to-split-instructions.rst: New file. * doc/gccint/machine-descriptions/defining-jump-instruction-patterns.rst: New file. * doc/gccint/machine-descriptions/defining-looping-instruction-patterns.rst: New file. * doc/gccint/machine-descriptions/defining-rtl-sequences-for-code-generation.rst: New file. * doc/gccint/machine-descriptions/everything-about-instruction-patterns.rst: New file. * doc/gccint/machine-descriptions/example-of-defineinsn.rst: New file. * doc/gccint/machine-descriptions/including-patterns-in-machine-descriptions.rst: New file. * doc/gccint/machine-descriptions/instruction-attributes.rst: New file. * doc/gccint/machine-descriptions/interdependence-of-patterns.rst: New file. * doc/gccint/machine-descriptions/iterators.rst: New file. * doc/gccint/machine-descriptions/machine-specific-peephole-optimizers.rst: New file. * doc/gccint/machine-descriptions/operand-constraints.rst: New file. * doc/gccint/machine-descriptions/output-templates-and-operand-substitution.rst: New file. * doc/gccint/machine-descriptions/overview-of-how-the-machine-description-is-used.rst: New file. * doc/gccint/machine-descriptions/predicates.rst: New file. * doc/gccint/machine-descriptions/rtl-template.rst: New file. * doc/gccint/machine-descriptions/rtl-templates-transformations.rst: New file. * doc/gccint/machine-descriptions/standard-pattern-names-for-generation.rst: New file. * doc/gccint/machine-descriptions/when-the-order-of-patterns-matters.rst: New file. * doc/gccint/makefile-fragments.rst: New file. * doc/gccint/match-and-simplify.rst: New file. * doc/gccint/memory-management-and-type-information.rst: New file. * doc/gccint/memory-management-and-type-information/how-to-invoke-the-garbage-collector.rst: New file. * doc/gccint/memory-management-and-type-information/marking-roots-for-the-garbage-collector.rst: New file. * doc/gccint/memory-management-and-type-information/source-files-containing-type-information.rst: New file. * doc/gccint/memory-management-and-type-information/support-for-inheritance.rst: New file. * doc/gccint/memory-management-and-type-information/support-for-user-provided-gc-marking-routines.rst: New file. * doc/gccint/memory-management-and-type-information/the-inside-of-a-gty.rst: New file. * doc/gccint/memory-management-and-type-information/troubleshooting-the-garbage-collector.rst: New file. * doc/gccint/option-file-format.rst: New file. * doc/gccint/option-properties.rst: New file. * doc/gccint/option-specification-files.rst: New file. * doc/gccint/passes-and-files-of-the-compiler.rst: New file. * doc/gccint/passes-and-files-of-the-compiler/gimplification-pass.rst: New file. * doc/gccint/passes-and-files-of-the-compiler/inter-procedural-optimization-passes.rst: New file. * doc/gccint/passes-and-files-of-the-compiler/optimization-info.rst: New file. * doc/gccint/passes-and-files-of-the-compiler/parsing-pass.rst: New file. * doc/gccint/passes-and-files-of-the-compiler/pass-manager.rst: New file. * doc/gccint/passes-and-files-of-the-compiler/rtl-passes.rst: New file. * doc/gccint/passes-and-files-of-the-compiler/tree-ssa-passes.rst: New file. * doc/gccint/plugins.rst: New file. * doc/gccint/plugins/building-gcc-plugins.rst: New file. * doc/gccint/plugins/controlling-which-passes-are-being-run.rst: New file. * doc/gccint/plugins/giving-information-about-a-plugin.rst: New file. * doc/gccint/plugins/interacting-with-the-gcc-garbage-collector.rst: New file. * doc/gccint/plugins/interacting-with-the-pass-manager.rst: New file. * doc/gccint/plugins/keeping-track-of-available-passes.rst: New file. * doc/gccint/plugins/loading-plugins.rst: New file. * doc/gccint/plugins/plugin-api.rst: New file. * doc/gccint/plugins/recording-information-about-pass-execution.rst: New file. * doc/gccint/plugins/registering-custom-attributes-or-pragmas.rst: New file. * doc/gccint/rtl-representation.rst: New file. * doc/gccint/rtl-representation/access-to-operands.rst: New file. * doc/gccint/rtl-representation/access-to-special-operands.rst: New file. * doc/gccint/rtl-representation/assembler-instructions-as-expressions.rst: New file. * doc/gccint/rtl-representation/bit-fields.rst: New file. * doc/gccint/rtl-representation/comparison-operations.rst: New file. * doc/gccint/rtl-representation/constant-expression-types.rst: New file. * doc/gccint/rtl-representation/conversions.rst: New file. * doc/gccint/rtl-representation/declarations.rst: New file. * doc/gccint/rtl-representation/embedded-side-effects-on-addresses.rst: New file. * doc/gccint/rtl-representation/flags-in-an-rtl-expression.rst: New file. * doc/gccint/rtl-representation/insns.rst: New file. * doc/gccint/rtl-representation/machine-modes.rst: New file. * doc/gccint/rtl-representation/on-the-side-ssa-form-for-rtl.rst: New file. * doc/gccint/rtl-representation/reading-rtl.rst: New file. * doc/gccint/rtl-representation/registers-and-memory.rst: New file. * doc/gccint/rtl-representation/rtl-classes-and-formats.rst: New file. * doc/gccint/rtl-representation/rtl-expressions-for-arithmetic.rst: New file. * doc/gccint/rtl-representation/rtl-object-types.rst: New file. * doc/gccint/rtl-representation/rtl-representation-of-function-call-insns.rst: New file. * doc/gccint/rtl-representation/side-effect-expressions.rst: New file. * doc/gccint/rtl-representation/structure-sharing-assumptions.rst: New file. * doc/gccint/rtl-representation/variable-location-debug-information-in-rtl.rst: New file. * doc/gccint/rtl-representation/vector-operations.rst: New file. * doc/gccint/sizes-and-offsets-as-runtime-invariants.rst: New file. * doc/gccint/sizes-and-offsets-as-runtime-invariants/alignment-of-polyints.rst: New file. * doc/gccint/sizes-and-offsets-as-runtime-invariants/arithmetic-on-polyints.rst: New file. * doc/gccint/sizes-and-offsets-as-runtime-invariants/comparisons-involving-polyint.rst: New file. * doc/gccint/sizes-and-offsets-as-runtime-invariants/computing-bounds-on-polyints.rst: New file. * doc/gccint/sizes-and-offsets-as-runtime-invariants/consequences-of-using-polyint.rst: New file. * doc/gccint/sizes-and-offsets-as-runtime-invariants/converting-polyints.rst: New file. * doc/gccint/sizes-and-offsets-as-runtime-invariants/guidelines-for-using-polyint.rst: New file. * doc/gccint/sizes-and-offsets-as-runtime-invariants/miscellaneous-polyint-routines.rst: New file. * doc/gccint/sizes-and-offsets-as-runtime-invariants/overview-of-polyint.rst: New file. * doc/gccint/source-tree-structure-and-build-system.rst: New file. * doc/gccint/source-tree-structure-and-build-system/configure-terms-and-history.rst: New file. * doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory.rst: New file. * doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/anatomy-of-a-language-front-end.rst: New file. * doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/anatomy-of-a-target-back-end.rst: New file. * doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/build-system-in-the-gcc-directory.rst: New file. * doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/building-documentation.rst: New file. * doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/configuration-in-the-gcc-directory.rst: New file. * doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/headers-installed-by-gcc.rst: New file. * doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/library-source-files-and-headers-under-the-gcc-directory.rst: New file. * doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/makefile-targets.rst: New file. * doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/subdirectories-of-gcc.rst: New file. * doc/gccint/source-tree-structure-and-build-system/top-level-source-directory.rst: New file. * doc/gccint/standard-header-file-directories.rst: New file. * doc/gccint/static-analyzer.rst: New file. * doc/gccint/target-macros.rst: New file. * doc/gccint/target-macros/adding-support-for-named-address-spaces.rst: New file. * doc/gccint/target-macros/addressing-modes.rst: New file. * doc/gccint/target-macros/adjusting-the-instruction-scheduler.rst: New file. * doc/gccint/target-macros/anchored-addresses.rst: New file. * doc/gccint/target-macros/c++-abi-parameters.rst: New file. * doc/gccint/target-macros/condition-code-status.rst: New file. * doc/gccint/target-macros/controlling-debugging-information-format.rst: New file. * doc/gccint/target-macros/controlling-the-compilation-driver-gcc.rst: New file. * doc/gccint/target-macros/cross-compilation-and-floating-point.rst: New file. * doc/gccint/target-macros/d-abi-parameters.rst: New file. * doc/gccint/target-macros/defining-coprocessor-specifics-for-mips-targets.rst: New file. * doc/gccint/target-macros/defining-data-structures-for-per-function-information.rst: New file. * doc/gccint/target-macros/defining-target-specific-uses-of-attribute.rst: New file. * doc/gccint/target-macros/defining-the-output-assembler-language.rst: New file. * doc/gccint/target-macros/defining-the-output-assembler-language/assembler-commands-for-alignment.rst: New file. * doc/gccint/target-macros/defining-the-output-assembler-language/assembler-commands-for-exception-regions.rst: New file. * doc/gccint/target-macros/defining-the-output-assembler-language/how-initialization-functions-are-handled.rst: New file. * doc/gccint/target-macros/defining-the-output-assembler-language/macros-controlling-initialization-routines.rst: New file. * doc/gccint/target-macros/defining-the-output-assembler-language/output-and-generation-of-labels.rst: New file. * doc/gccint/target-macros/defining-the-output-assembler-language/output-of-assembler-instructions.rst: New file. * doc/gccint/target-macros/defining-the-output-assembler-language/output-of-data.rst: New file. * doc/gccint/target-macros/defining-the-output-assembler-language/output-of-dispatch-tables.rst: New file. * doc/gccint/target-macros/defining-the-output-assembler-language/output-of-uninitialized-variables.rst: New file. * doc/gccint/target-macros/defining-the-output-assembler-language/the-overall-framework-of-an-assembler-file.rst: New file. * doc/gccint/target-macros/describing-relative-costs-of-operations.rst: New file. * doc/gccint/target-macros/dividing-the-output-into-sections-texts-data.rst: New file. * doc/gccint/target-macros/emulating-tls.rst: New file. * doc/gccint/target-macros/implementing-the-varargs-macros.rst: New file. * doc/gccint/target-macros/implicit-calls-to-library-routines.rst: New file. * doc/gccint/target-macros/layout-of-source-language-data-types.rst: New file. * doc/gccint/target-macros/miscellaneous-parameters.rst: New file. * doc/gccint/target-macros/mode-switching-instructions.rst: New file. * doc/gccint/target-macros/parameters-for-precompiled-header-validity-checking.rst: New file. * doc/gccint/target-macros/position-independent-code.rst: New file. * doc/gccint/target-macros/register-classes.rst: New file. * doc/gccint/target-macros/register-usage.rst: New file. * doc/gccint/target-macros/run-time-target-specification.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/basic-stack-layout.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/caller-saves-register-allocation.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/eliminating-frame-pointer-and-arg-pointer.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/exception-handling-support.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/function-entry-and-exit.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/generating-code-for-profiling.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/how-large-values-are-returned.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/how-scalar-function-values-are-returned.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/miscellaneous-register-hooks.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/passing-arguments-in-registers.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/passing-function-arguments-on-the-stack.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/permitting-tail-calls.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/registers-that-address-the-stack-frame.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/shrink-wrapping-separate-components.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/specifying-how-stack-checking-is-done.rst: New file. * doc/gccint/target-macros/stack-layout-and-calling-conventions/stack-smashing-protection.rst: New file. * doc/gccint/target-macros/storage-layout.rst: New file. * doc/gccint/target-macros/support-for-nested-functions.rst: New file. * doc/gccint/target-macros/the-global-targetm-variable.rst: New file. * doc/gccint/target-makefile-fragments.rst: New file. * doc/gccint/testsuites.rst: New test. * doc/gccint/testsuites/ada-language-testsuites.rst: New test. * doc/gccint/testsuites/c-language-testsuites.rst: New test. * doc/gccint/testsuites/directives-used-within-dejagnu-tests.rst: New test. * doc/gccint/testsuites/directives-used-within-dejagnu-tests/commands-for-use-in-dg-final.rst: New test. * doc/gccint/testsuites/directives-used-within-dejagnu-tests/features-for-dg-add-options.rst: New test. * doc/gccint/testsuites/directives-used-within-dejagnu-tests/keywords-describing-target-attributes.rst: New test. * doc/gccint/testsuites/directives-used-within-dejagnu-tests/selecting-targets-to-which-a-test-applies.rst: New test. * doc/gccint/testsuites/directives-used-within-dejagnu-tests/syntax-and-descriptions-of-test-directives.rst: New test. * doc/gccint/testsuites/directives-used-within-dejagnu-tests/variants-of-dg-require-support.rst: New test. * doc/gccint/testsuites/idioms-used-in-testsuite-code.rst: New test. * doc/gccint/testsuites/support-for-testing-binary-compatibility.rst: New test. * doc/gccint/testsuites/support-for-testing-gcov.rst: New test. * doc/gccint/testsuites/support-for-testing-gimple-passes.rst: New test. * doc/gccint/testsuites/support-for-testing-link-time-optimizations.rst: New test. * doc/gccint/testsuites/support-for-testing-profile-directed-optimizations.rst: New test. * doc/gccint/testsuites/support-for-testing-rtl-passes.rst: New test. * doc/gccint/testsuites/support-for-torture-testing-using-multiple-options.rst: New test. * doc/gccint/the-gcc-low-level-runtime-library.rst: New file. * doc/gccint/the-gcc-low-level-runtime-library/language-independent-routines-for-exception-handling.rst: New file. * doc/gccint/the-gcc-low-level-runtime-library/miscellaneous-runtime-library-routines.rst: New file. * doc/gccint/the-gcc-low-level-runtime-library/routines-for-decimal-floating-point-emulation.rst: New file. * doc/gccint/the-gcc-low-level-runtime-library/routines-for-fixed-point-fractional-emulation.rst: New file. * doc/gccint/the-gcc-low-level-runtime-library/routines-for-floating-point-emulation.rst: New file. * doc/gccint/the-gcc-low-level-runtime-library/routines-for-integer-arithmetic.rst: New file. * doc/gccint/the-language.rst: New file. * doc/gccint/user-experience-guidelines.rst: New file. * doc/install/binaries.rst: New file. * doc/install/building.rst: New file. * doc/install/building/building-a-cross-compiler.rst: New file. * doc/install/building/building-a-native-compiler.rst: New file. * doc/install/building/building-in-parallel.rst: New file. * doc/install/building/building-the-ada-compiler.rst: New file. * doc/install/building/building-the-d-compiler.rst: New file. * doc/install/building/building-with-profile-feedback.rst: New file. * doc/install/conf.py: New file. * doc/install/configuration.rst: New file. * doc/install/copyright.rst: New file. * doc/install/downloading-gcc.rst: New file. * doc/install/final-installation.rst: New file. * doc/install/gnu-free-documentation-license.rst: New file. * doc/install/host-target-specific-installation-notes-for-gcc.rst: New file. * doc/install/how-can-you-run-the-testsuite-on-selected-tests.rst: New test. * doc/install/how-to-interpret-test-results.rst: New file. * doc/install/index.rst: New file. * doc/install/indices-and-tables.rst: New file. * doc/install/installing-gcc.rst: New file. * doc/install/passing-options-and-running-multiple-testsuites.rst: New test. * doc/install/prerequisites.rst: New file. * doc/install/submitting-test-results.rst: New file. * doc/install/testing.rst: New file. gcc/fortran/ChangeLog: * doc/gfc-internals/code-that-interacts-with-the-user.rst: New file. * doc/gfc-internals/command-line-options.rst: New file. * doc/gfc-internals/conf.py: New file. * doc/gfc-internals/copyright.rst: New file. * doc/gfc-internals/error-handling.rst: New file. * doc/gfc-internals/frontend-data-structures.rst: New file. * doc/gfc-internals/generating-the-intermediate-language-for-later-stages.rst: New file. * doc/gfc-internals/generating-the-intermediate-language-for-later-stages/accessing-declarations.rst: New file. * doc/gfc-internals/generating-the-intermediate-language-for-later-stages/basic-data-structures.rst: New file. * doc/gfc-internals/generating-the-intermediate-language-for-later-stages/converting-expressions-to-tree.rst: New file. * doc/gfc-internals/generating-the-intermediate-language-for-later-stages/translating-statements.rst: New file. * doc/gfc-internals/gfccode.rst: New file. * doc/gfc-internals/gfcexpr.rst: New file. * doc/gfc-internals/gnu-free-documentation-license.rst: New file. * doc/gfc-internals/index.rst: New file. * doc/gfc-internals/indices-and-tables.rst: New file. * doc/gfc-internals/internals-of-fortran-2003-oop-features.rst: New file. * doc/gfc-internals/introduction.rst: New file. * doc/gfc-internals/symbol-versioning.rst: New file. * doc/gfc-internals/the-libgfortran-runtime-library.rst: New file. * doc/gfc-internals/type-bound-operators.rst: New file. * doc/gfc-internals/type-bound-procedures.rst: New file. * doc/gfortran/about-gnu-fortran.rst: New file. * doc/gfortran/coarray-programming.rst: New file. * doc/gfortran/compiler-characteristics.rst: New file. * doc/gfortran/compiler-characteristics/asynchronous-i-o.rst: New file. * doc/gfortran/compiler-characteristics/data-consistency-and-durability.rst: New file. * doc/gfortran/compiler-characteristics/evaluation-of-logical-expressions.rst: New file. * doc/gfortran/compiler-characteristics/file-format-of-unformatted-sequential-files.rst: New file. * doc/gfortran/compiler-characteristics/file-operations-on-symbolic-links.rst: New file. * doc/gfortran/compiler-characteristics/files-opened-without-an-explicit-action=-specifier.rst: New file. * doc/gfortran/compiler-characteristics/internal-representation-of-logical-variables.rst: New file. * doc/gfortran/compiler-characteristics/kind-type-parameters.rst: New file. * doc/gfortran/compiler-characteristics/max-and-min-intrinsics-with-real-nan-arguments.rst: New file. * doc/gfortran/compiler-characteristics/thread-safety-of-the-runtime-library.rst: New file. * doc/gfortran/conf.py: New file. * doc/gfortran/contributing.rst: New file. * doc/gfortran/contributors-to-gnu-fortran.rst: New file. * doc/gfortran/copyright.rst: New file. * doc/gfortran/extensions-implemented-in-gnu-fortran.rst: New file. * doc/gfortran/extensions-not-implemented-in-gnu-fortran.rst: New file. * doc/gfortran/extensions.rst: New file. * doc/gfortran/function-abi-documentation.rst: New file. * doc/gfortran/funding.rst: New file. * doc/gfortran/general-public-license-3.rst: New file. * doc/gfortran/gnu-fortran-and-gcc.rst: New file. * doc/gfortran/gnu-fortran-command-options.rst: New file. * doc/gfortran/gnu-fortran-command-options/description.rst: New file. * doc/gfortran/gnu-fortran-command-options/enable-and-customize-preprocessing.rst: New file. * doc/gfortran/gnu-fortran-command-options/environment-variables-affecting-gfortran.rst: New file. * doc/gfortran/gnu-fortran-command-options/influencing-runtime-behavior.rst: New file. * doc/gfortran/gnu-fortran-command-options/influencing-the-linking-step.rst: New file. * doc/gfortran/gnu-fortran-command-options/option-summary.rst: New file. * doc/gfortran/gnu-fortran-command-options/options-controlling-fortran-dialect.rst: New file. * doc/gfortran/gnu-fortran-command-options/options-for-code-generation-conventions.rst: New file. * doc/gfortran/gnu-fortran-command-options/options-for-debugging-your-program-or-gnu-fortran.rst: New file. * doc/gfortran/gnu-fortran-command-options/options-for-directory-search.rst: New file. * doc/gfortran/gnu-fortran-command-options/options-for-interoperability-with-other-languages.rst: New file. * doc/gfortran/gnu-fortran-command-options/options-to-request-or-suppress-errors-and-warnings.rst: New file. * doc/gfortran/gnu-fortran-compiler-directives.rst: New file. * doc/gfortran/gnu-free-documentation-license.rst: New file. * doc/gfortran/index.rst: New file. * doc/gfortran/indices-and-tables.rst: New file. * doc/gfortran/interoperability-with-c.rst: New file. * doc/gfortran/intrinsic-modules.rst: New file. * doc/gfortran/intrinsic-modules/ieee-modules-ieeeexceptions-ieeearithmetic-and-ieeefeatures.rst: New file. * doc/gfortran/intrinsic-modules/isocbinding.rst: New file. * doc/gfortran/intrinsic-modules/isofortranenv.rst: New file. * doc/gfortran/intrinsic-modules/openacc-module-openacc.rst: New file. * doc/gfortran/intrinsic-modules/openmp-modules-omplib-and-omplibkinds.rst: New file. * doc/gfortran/intrinsic-procedures.rst: New file. * doc/gfortran/intrinsic-procedures/abort.rst: New file. * doc/gfortran/intrinsic-procedures/abs.rst: New file. * doc/gfortran/intrinsic-procedures/access.rst: New file. * doc/gfortran/intrinsic-procedures/achar.rst: New file. * doc/gfortran/intrinsic-procedures/acos.rst: New file. * doc/gfortran/intrinsic-procedures/acosd.rst: New file. * doc/gfortran/intrinsic-procedures/acosh.rst: New file. * doc/gfortran/intrinsic-procedures/adjustl.rst: New file. * doc/gfortran/intrinsic-procedures/adjustr.rst: New file. * doc/gfortran/intrinsic-procedures/aimag.rst: New file. * doc/gfortran/intrinsic-procedures/aint.rst: New file. * doc/gfortran/intrinsic-procedures/alarm.rst: New file. * doc/gfortran/intrinsic-procedures/all.rst: New file. * doc/gfortran/intrinsic-procedures/allocated.rst: New file. * doc/gfortran/intrinsic-procedures/and.rst: New file. * doc/gfortran/intrinsic-procedures/anint.rst: New file. * doc/gfortran/intrinsic-procedures/any.rst: New file. * doc/gfortran/intrinsic-procedures/asin.rst: New file. * doc/gfortran/intrinsic-procedures/asind.rst: New file. * doc/gfortran/intrinsic-procedures/asinh.rst: New file. * doc/gfortran/intrinsic-procedures/associated.rst: New file. * doc/gfortran/intrinsic-procedures/atan.rst: New file. * doc/gfortran/intrinsic-procedures/atan2.rst: New file. * doc/gfortran/intrinsic-procedures/atan2d.rst: New file. * doc/gfortran/intrinsic-procedures/atand.rst: New file. * doc/gfortran/intrinsic-procedures/atanh.rst: New file. * doc/gfortran/intrinsic-procedures/atomicadd.rst: New file. * doc/gfortran/intrinsic-procedures/atomicand.rst: New file. * doc/gfortran/intrinsic-procedures/atomiccas.rst: New file. * doc/gfortran/intrinsic-procedures/atomicdefine.rst: New file. * doc/gfortran/intrinsic-procedures/atomicfetchadd.rst: New file. * doc/gfortran/intrinsic-procedures/atomicfetchand.rst: New file. * doc/gfortran/intrinsic-procedures/atomicfetchor.rst: New file. * doc/gfortran/intrinsic-procedures/atomicfetchxor.rst: New file. * doc/gfortran/intrinsic-procedures/atomicor.rst: New file. * doc/gfortran/intrinsic-procedures/atomicref.rst: New file. * doc/gfortran/intrinsic-procedures/atomicxor.rst: New file. * doc/gfortran/intrinsic-procedures/backtrace.rst: New file. * doc/gfortran/intrinsic-procedures/besselj0.rst: New file. * doc/gfortran/intrinsic-procedures/besselj1.rst: New file. * doc/gfortran/intrinsic-procedures/besseljn.rst: New file. * doc/gfortran/intrinsic-procedures/bessely0.rst: New file. * doc/gfortran/intrinsic-procedures/bessely1.rst: New file. * doc/gfortran/intrinsic-procedures/besselyn.rst: New file. * doc/gfortran/intrinsic-procedures/bge.rst: New file. * doc/gfortran/intrinsic-procedures/bgt.rst: New file. * doc/gfortran/intrinsic-procedures/bitsize.rst: New file. * doc/gfortran/intrinsic-procedures/ble.rst: New file. * doc/gfortran/intrinsic-procedures/blt.rst: New file. * doc/gfortran/intrinsic-procedures/btest.rst: New file. * doc/gfortran/intrinsic-procedures/cassociated.rst: New file. * doc/gfortran/intrinsic-procedures/ceiling.rst: New file. * doc/gfortran/intrinsic-procedures/cfpointer.rst: New file. * doc/gfortran/intrinsic-procedures/cfprocpointer.rst: New file. * doc/gfortran/intrinsic-procedures/cfunloc.rst: New file. * doc/gfortran/intrinsic-procedures/char.rst: New file. * doc/gfortran/intrinsic-procedures/chdir.rst: New file. * doc/gfortran/intrinsic-procedures/chmod.rst: New file. * doc/gfortran/intrinsic-procedures/cloc.rst: New file. * doc/gfortran/intrinsic-procedures/cmplx.rst: New file. * doc/gfortran/intrinsic-procedures/cobroadcast.rst: New file. * doc/gfortran/intrinsic-procedures/comax.rst: New file. * doc/gfortran/intrinsic-procedures/comin.rst: New file. * doc/gfortran/intrinsic-procedures/commandargumentcount.rst: New file. * doc/gfortran/intrinsic-procedures/compileroptions.rst: New file. * doc/gfortran/intrinsic-procedures/compilerversion.rst: New file. * doc/gfortran/intrinsic-procedures/complex.rst: New file. * doc/gfortran/intrinsic-procedures/conjg.rst: New file. * doc/gfortran/intrinsic-procedures/coreduce.rst: New file. * doc/gfortran/intrinsic-procedures/cos.rst: New file. * doc/gfortran/intrinsic-procedures/cosd.rst: New file. * doc/gfortran/intrinsic-procedures/cosh.rst: New file. * doc/gfortran/intrinsic-procedures/cosum.rst: New file. * doc/gfortran/intrinsic-procedures/cotan.rst: New file. * doc/gfortran/intrinsic-procedures/cotand.rst: New file. * doc/gfortran/intrinsic-procedures/count.rst: New file. * doc/gfortran/intrinsic-procedures/cputime.rst: New file. * doc/gfortran/intrinsic-procedures/cshift.rst: New file. * doc/gfortran/intrinsic-procedures/csizeof.rst: New file. * doc/gfortran/intrinsic-procedures/ctime.rst: New file. * doc/gfortran/intrinsic-procedures/dateandtime.rst: New file. * doc/gfortran/intrinsic-procedures/dble.rst: New file. * doc/gfortran/intrinsic-procedures/dcmplx.rst: New file. * doc/gfortran/intrinsic-procedures/digits.rst: New file. * doc/gfortran/intrinsic-procedures/dim.rst: New file. * doc/gfortran/intrinsic-procedures/dotproduct.rst: New file. * doc/gfortran/intrinsic-procedures/dprod.rst: New file. * doc/gfortran/intrinsic-procedures/dreal.rst: New file. * doc/gfortran/intrinsic-procedures/dshiftl.rst: New file. * doc/gfortran/intrinsic-procedures/dshiftr.rst: New file. * doc/gfortran/intrinsic-procedures/dtime.rst: New file. * doc/gfortran/intrinsic-procedures/eoshift.rst: New file. * doc/gfortran/intrinsic-procedures/epsilon.rst: New file. * doc/gfortran/intrinsic-procedures/erf.rst: New file. * doc/gfortran/intrinsic-procedures/erfc.rst: New file. * doc/gfortran/intrinsic-procedures/erfcscaled.rst: New file. * doc/gfortran/intrinsic-procedures/etime.rst: New file. * doc/gfortran/intrinsic-procedures/eventquery.rst: New file. * doc/gfortran/intrinsic-procedures/executecommandline.rst: New file. * doc/gfortran/intrinsic-procedures/exit.rst: New file. * doc/gfortran/intrinsic-procedures/exp.rst: New file. * doc/gfortran/intrinsic-procedures/exponent.rst: New file. * doc/gfortran/intrinsic-procedures/extendstypeof.rst: New file. * doc/gfortran/intrinsic-procedures/fdate.rst: New file. * doc/gfortran/intrinsic-procedures/fget.rst: New file. * doc/gfortran/intrinsic-procedures/fgetc.rst: New file. * doc/gfortran/intrinsic-procedures/findloc.rst: New file. * doc/gfortran/intrinsic-procedures/floor.rst: New file. * doc/gfortran/intrinsic-procedures/flush.rst: New file. * doc/gfortran/intrinsic-procedures/fnum.rst: New file. * doc/gfortran/intrinsic-procedures/fput.rst: New file. * doc/gfortran/intrinsic-procedures/fputc.rst: New file. * doc/gfortran/intrinsic-procedures/fraction.rst: New file. * doc/gfortran/intrinsic-procedures/free.rst: New file. * doc/gfortran/intrinsic-procedures/fseek.rst: New file. * doc/gfortran/intrinsic-procedures/fstat.rst: New file. * doc/gfortran/intrinsic-procedures/ftell.rst: New file. * doc/gfortran/intrinsic-procedures/gamma.rst: New file. * doc/gfortran/intrinsic-procedures/gerror.rst: New file. * doc/gfortran/intrinsic-procedures/getarg.rst: New file. * doc/gfortran/intrinsic-procedures/getcommand.rst: New file. * doc/gfortran/intrinsic-procedures/getcommandargument.rst: New file. * doc/gfortran/intrinsic-procedures/getcwd.rst: New file. * doc/gfortran/intrinsic-procedures/getenv.rst: New file. * doc/gfortran/intrinsic-procedures/getenvironmentvariable.rst: New file. * doc/gfortran/intrinsic-procedures/getgid.rst: New file. * doc/gfortran/intrinsic-procedures/getlog.rst: New file. * doc/gfortran/intrinsic-procedures/getpid.rst: New file. * doc/gfortran/intrinsic-procedures/getuid.rst: New file. * doc/gfortran/intrinsic-procedures/gmtime.rst: New file. * doc/gfortran/intrinsic-procedures/hostnm.rst: New file. * doc/gfortran/intrinsic-procedures/huge.rst: New file. * doc/gfortran/intrinsic-procedures/hypot.rst: New file. * doc/gfortran/intrinsic-procedures/iachar.rst: New file. * doc/gfortran/intrinsic-procedures/iall.rst: New file. * doc/gfortran/intrinsic-procedures/iand.rst: New file. * doc/gfortran/intrinsic-procedures/iany.rst: New file. * doc/gfortran/intrinsic-procedures/iargc.rst: New file. * doc/gfortran/intrinsic-procedures/ibclr.rst: New file. * doc/gfortran/intrinsic-procedures/ibits.rst: New file. * doc/gfortran/intrinsic-procedures/ibset.rst: New file. * doc/gfortran/intrinsic-procedures/ichar.rst: New file. * doc/gfortran/intrinsic-procedures/idate.rst: New file. * doc/gfortran/intrinsic-procedures/ieor.rst: New file. * doc/gfortran/intrinsic-procedures/ierrno.rst: New file. * doc/gfortran/intrinsic-procedures/imageindex.rst: New file. * doc/gfortran/intrinsic-procedures/index.rst: New file. * doc/gfortran/intrinsic-procedures/int.rst: New file. * doc/gfortran/intrinsic-procedures/int2.rst: New file. * doc/gfortran/intrinsic-procedures/int8.rst: New file. * doc/gfortran/intrinsic-procedures/introduction-to-intrinsic-procedures.rst: New file. * doc/gfortran/intrinsic-procedures/ior.rst: New file. * doc/gfortran/intrinsic-procedures/iparity.rst: New file. * doc/gfortran/intrinsic-procedures/irand.rst: New file. * doc/gfortran/intrinsic-procedures/isatty.rst: New file. * doc/gfortran/intrinsic-procedures/iscontiguous.rst: New file. * doc/gfortran/intrinsic-procedures/ishft.rst: New file. * doc/gfortran/intrinsic-procedures/ishftc.rst: New file. * doc/gfortran/intrinsic-procedures/isiostatend.rst: New file. * doc/gfortran/intrinsic-procedures/isiostateor.rst: New file. * doc/gfortran/intrinsic-procedures/isnan.rst: New file. * doc/gfortran/intrinsic-procedures/itime.rst: New file. * doc/gfortran/intrinsic-procedures/kill.rst: New file. * doc/gfortran/intrinsic-procedures/kind.rst: New file. * doc/gfortran/intrinsic-procedures/lbound.rst: New file. * doc/gfortran/intrinsic-procedures/lcobound.rst: New file. * doc/gfortran/intrinsic-procedures/leadz.rst: New file. * doc/gfortran/intrinsic-procedures/len.rst: New file. * doc/gfortran/intrinsic-procedures/lentrim.rst: New file. * doc/gfortran/intrinsic-procedures/lge.rst: New file. * doc/gfortran/intrinsic-procedures/lgt.rst: New file. * doc/gfortran/intrinsic-procedures/link.rst: New file. * doc/gfortran/intrinsic-procedures/lle.rst: New file. * doc/gfortran/intrinsic-procedures/llt.rst: New file. * doc/gfortran/intrinsic-procedures/lnblnk.rst: New file. * doc/gfortran/intrinsic-procedures/loc.rst: New file. * doc/gfortran/intrinsic-procedures/log.rst: New file. * doc/gfortran/intrinsic-procedures/log10.rst: New file. * doc/gfortran/intrinsic-procedures/loggamma.rst: New file. * doc/gfortran/intrinsic-procedures/logical.rst: New file. * doc/gfortran/intrinsic-procedures/lshift.rst: New file. * doc/gfortran/intrinsic-procedures/lstat.rst: New file. * doc/gfortran/intrinsic-procedures/ltime.rst: New file. * doc/gfortran/intrinsic-procedures/malloc.rst: New file. * doc/gfortran/intrinsic-procedures/maskl.rst: New file. * doc/gfortran/intrinsic-procedures/maskr.rst: New file. * doc/gfortran/intrinsic-procedures/matmul.rst: New file. * doc/gfortran/intrinsic-procedures/max.rst: New file. * doc/gfortran/intrinsic-procedures/maxexponent.rst: New file. * doc/gfortran/intrinsic-procedures/maxloc.rst: New file. * doc/gfortran/intrinsic-procedures/maxval.rst: New file. * doc/gfortran/intrinsic-procedures/mclock.rst: New file. * doc/gfortran/intrinsic-procedures/mclock8.rst: New file. * doc/gfortran/intrinsic-procedures/merge.rst: New file. * doc/gfortran/intrinsic-procedures/mergebits.rst: New file. * doc/gfortran/intrinsic-procedures/min.rst: New file. * doc/gfortran/intrinsic-procedures/minexponent.rst: New file. * doc/gfortran/intrinsic-procedures/minloc.rst: New file. * doc/gfortran/intrinsic-procedures/minval.rst: New file. * doc/gfortran/intrinsic-procedures/mod.rst: New file. * doc/gfortran/intrinsic-procedures/modulo.rst: New file. * doc/gfortran/intrinsic-procedures/movealloc.rst: New file. * doc/gfortran/intrinsic-procedures/mvbits.rst: New file. * doc/gfortran/intrinsic-procedures/nearest.rst: New file. * doc/gfortran/intrinsic-procedures/newline.rst: New file. * doc/gfortran/intrinsic-procedures/nint.rst: New file. * doc/gfortran/intrinsic-procedures/norm2.rst: New file. * doc/gfortran/intrinsic-procedures/not.rst: New file. * doc/gfortran/intrinsic-procedures/null.rst: New file. * doc/gfortran/intrinsic-procedures/numimages.rst: New file. * doc/gfortran/intrinsic-procedures/or.rst: New file. * doc/gfortran/intrinsic-procedures/pack.rst: New file. * doc/gfortran/intrinsic-procedures/parity.rst: New file. * doc/gfortran/intrinsic-procedures/perror.rst: New file. * doc/gfortran/intrinsic-procedures/popcnt.rst: New file. * doc/gfortran/intrinsic-procedures/poppar.rst: New file. * doc/gfortran/intrinsic-procedures/precision.rst: New file. * doc/gfortran/intrinsic-procedures/present.rst: New file. * doc/gfortran/intrinsic-procedures/product.rst: New file. * doc/gfortran/intrinsic-procedures/radix.rst: New file. * doc/gfortran/intrinsic-procedures/ran.rst: New file. * doc/gfortran/intrinsic-procedures/rand.rst: New file. * doc/gfortran/intrinsic-procedures/randominit.rst: New file. * doc/gfortran/intrinsic-procedures/randomnumber.rst: New file. * doc/gfortran/intrinsic-procedures/randomseed.rst: New file. * doc/gfortran/intrinsic-procedures/range.rst: New file. * doc/gfortran/intrinsic-procedures/rank.rst: New file. * doc/gfortran/intrinsic-procedures/real.rst: New file. * doc/gfortran/intrinsic-procedures/rename.rst: New file. * doc/gfortran/intrinsic-procedures/repeat.rst: New file. * doc/gfortran/intrinsic-procedures/reshape.rst: New file. * doc/gfortran/intrinsic-procedures/rrspacing.rst: New file. * doc/gfortran/intrinsic-procedures/rshift.rst: New file. * doc/gfortran/intrinsic-procedures/sametypeas.rst: New file. * doc/gfortran/intrinsic-procedures/scale.rst: New file. * doc/gfortran/intrinsic-procedures/scan.rst: New file. * doc/gfortran/intrinsic-procedures/secnds.rst: New file. * doc/gfortran/intrinsic-procedures/second.rst: New file. * doc/gfortran/intrinsic-procedures/selectedcharkind.rst: New file. * doc/gfortran/intrinsic-procedures/selectedintkind.rst: New file. * doc/gfortran/intrinsic-procedures/selectedrealkind.rst: New file. * doc/gfortran/intrinsic-procedures/setexponent.rst: New file. * doc/gfortran/intrinsic-procedures/shape.rst: New file. * doc/gfortran/intrinsic-procedures/shifta.rst: New file. * doc/gfortran/intrinsic-procedures/shiftl.rst: New file. * doc/gfortran/intrinsic-procedures/shiftr.rst: New file. * doc/gfortran/intrinsic-procedures/sign.rst: New file. * doc/gfortran/intrinsic-procedures/signal.rst: New file. * doc/gfortran/intrinsic-procedures/sin.rst: New file. * doc/gfortran/intrinsic-procedures/sind.rst: New file. * doc/gfortran/intrinsic-procedures/sinh.rst: New file. * doc/gfortran/intrinsic-procedures/size.rst: New file. * doc/gfortran/intrinsic-procedures/sizeof.rst: New file. * doc/gfortran/intrinsic-procedures/sleep.rst: New file. * doc/gfortran/intrinsic-procedures/spacing.rst: New file. * doc/gfortran/intrinsic-procedures/spread.rst: New file. * doc/gfortran/intrinsic-procedures/sqrt.rst: New file. * doc/gfortran/intrinsic-procedures/srand.rst: New file. * doc/gfortran/intrinsic-procedures/stat.rst: New file. * doc/gfortran/intrinsic-procedures/storagesize.rst: New file. * doc/gfortran/intrinsic-procedures/sum.rst: New file. * doc/gfortran/intrinsic-procedures/symlnk.rst: New file. * doc/gfortran/intrinsic-procedures/system.rst: New file. * doc/gfortran/intrinsic-procedures/systemclock.rst: New file. * doc/gfortran/intrinsic-procedures/tan.rst: New file. * doc/gfortran/intrinsic-procedures/tand.rst: New file. * doc/gfortran/intrinsic-procedures/tanh.rst: New file. * doc/gfortran/intrinsic-procedures/thisimage.rst: New file. * doc/gfortran/intrinsic-procedures/time.rst: New file. * doc/gfortran/intrinsic-procedures/time8.rst: New file. * doc/gfortran/intrinsic-procedures/tiny.rst: New file. * doc/gfortran/intrinsic-procedures/trailz.rst: New file. * doc/gfortran/intrinsic-procedures/transfer.rst: New file. * doc/gfortran/intrinsic-procedures/transpose.rst: New file. * doc/gfortran/intrinsic-procedures/trim.rst: New file. * doc/gfortran/intrinsic-procedures/ttynam.rst: New file. * doc/gfortran/intrinsic-procedures/ubound.rst: New file. * doc/gfortran/intrinsic-procedures/ucobound.rst: New file. * doc/gfortran/intrinsic-procedures/umask.rst: New file. * doc/gfortran/intrinsic-procedures/unlink.rst: New file. * doc/gfortran/intrinsic-procedures/unpack.rst: New file. * doc/gfortran/intrinsic-procedures/verify.rst: New file. * doc/gfortran/intrinsic-procedures/xor.rst: New file. * doc/gfortran/introduction.rst: New file. * doc/gfortran/mixed-language-programming.rst: New file. * doc/gfortran/naming-and-argument-passing-conventions.rst: New file. * doc/gfortran/non-fortran-main-program.rst: New file. * doc/gfortran/projects.rst: New file. * doc/gfortran/runtime.rst: New file. * doc/gfortran/runtime/gfortranconvertunit.rst: New file. * doc/gfortran/runtime/gfortranerrorbacktrace.rst: New file. * doc/gfortran/runtime/gfortranformattedbuffersize.rst: New file. * doc/gfortran/runtime/gfortranlistseparator.rst: New file. * doc/gfortran/runtime/gfortranoptionalplus.rst: New file. * doc/gfortran/runtime/gfortranshowlocus.rst: New file. * doc/gfortran/runtime/gfortranstderrunit.rst: New file. * doc/gfortran/runtime/gfortranstdinunit.rst: New file. * doc/gfortran/runtime/gfortranstdoutunit.rst: New file. * doc/gfortran/runtime/gfortranunbufferedall.rst: New file. * doc/gfortran/runtime/gfortranunbufferedpreconnected.rst: New file. * doc/gfortran/runtime/gfortranunformattedbuffersize.rst: New file. * doc/gfortran/runtime/tmpdir.rst: New file. * doc/gfortran/standards.rst: New file. * doc/gfortran/type-and-enum-abi-documentation.rst: New file. gcc/go/ChangeLog: * doc/c-interoperability.rst: New file. * doc/c-type-interoperability.rst: New file. * doc/compiler-directives.rst: New file. * doc/conf.py: New file. * doc/copyright.rst: New file. * doc/function-names.rst: New file. * doc/general-public-license-3.rst: New file. * doc/gnu-free-documentation-license.rst: New file. * doc/import-and-export.rst: New file. * doc/index.rst: New file. * doc/indices-and-tables.rst: New file. * doc/introduction.rst: New file. * doc/invoking-gccgo.rst: New file. libgomp/ChangeLog: * doc/amd-radeon-gcn.rst: New file. * doc/conf.py: New file. * doc/copyright.rst: New file. * doc/cuda-streams-usage.rst: New file. * doc/enabling-openacc.rst: New file. * doc/enabling-openmp.rst: New file. * doc/first-invocation-nvidia-cublas-library-api.rst: New file. * doc/first-invocation-openacc-library-api.rst: New file. * doc/funding.rst: New file. * doc/general-public-license-3.rst: New file. * doc/gnu-free-documentation-license.rst: New file. * doc/implementation-status-and-implementation-defined-behavior.rst: New file. * doc/index.rst: New file. * doc/indices-and-tables.rst: New file. * doc/introduction.rst: New file. * doc/memory-allocation-with-libmemkind.rst: New file. * doc/nvptx.rst: New file. * doc/offload-target-specifics.rst: New file. * doc/openacc-environment-variables.rst: New file. * doc/openacc-environment-variables/accdevicenum.rst: New file. * doc/openacc-environment-variables/accdevicetype.rst: New file. * doc/openacc-environment-variables/accproflib.rst: New file. * doc/openacc-environment-variables/gccaccnotify.rst: New file. * doc/openacc-introduction.rst: New file. * doc/openacc-library-and-environment-variables.rst: New file. * doc/openacc-library-interoperability.rst: New file. * doc/openacc-profiling-interface.rst: New file. * doc/openacc-runtime-library-routines.rst: New file. * doc/openacc-runtime-library-routines/accasynctest.rst: New file. * doc/openacc-runtime-library-routines/accasynctestall.rst: New file. * doc/openacc-runtime-library-routines/accattach.rst: New file. * doc/openacc-runtime-library-routines/acccopyin.rst: New file. * doc/openacc-runtime-library-routines/acccopyout.rst: New file. * doc/openacc-runtime-library-routines/acccreate.rst: New file. * doc/openacc-runtime-library-routines/accdelete.rst: New file. * doc/openacc-runtime-library-routines/accdetach.rst: New file. * doc/openacc-runtime-library-routines/accdeviceptr.rst: New file. * doc/openacc-runtime-library-routines/accfree.rst: New file. * doc/openacc-runtime-library-routines/accgetcudastream.rst: New file. * doc/openacc-runtime-library-routines/accgetcurrentcudacontext.rst: New file. * doc/openacc-runtime-library-routines/accgetcurrentcudadevice.rst: New file. * doc/openacc-runtime-library-routines/accgetdevicenum.rst: New file. * doc/openacc-runtime-library-routines/accgetdevicetype.rst: New file. * doc/openacc-runtime-library-routines/accgetnumdevices.rst: New file. * doc/openacc-runtime-library-routines/accgetproperty.rst: New file. * doc/openacc-runtime-library-routines/acchostptr.rst: New file. * doc/openacc-runtime-library-routines/accinit.rst: New file. * doc/openacc-runtime-library-routines/accispresent.rst: New file. * doc/openacc-runtime-library-routines/accmalloc.rst: New file. * doc/openacc-runtime-library-routines/accmapdata.rst: New file. * doc/openacc-runtime-library-routines/accmemcpyfromdevice.rst: New file. * doc/openacc-runtime-library-routines/accmemcpytodevice.rst: New file. * doc/openacc-runtime-library-routines/accondevice.rst: New file. * doc/openacc-runtime-library-routines/accpresentorcopyin.rst: New file. * doc/openacc-runtime-library-routines/accpresentorcreate.rst: New file. * doc/openacc-runtime-library-routines/accproflookup.rst: New file. * doc/openacc-runtime-library-routines/accprofregister.rst: New file. * doc/openacc-runtime-library-routines/accprofunregister.rst: New file. * doc/openacc-runtime-library-routines/accregisterlibrary.rst: New file. * doc/openacc-runtime-library-routines/accsetcudastream.rst: New file. * doc/openacc-runtime-library-routines/accsetdevicenum.rst: New file. * doc/openacc-runtime-library-routines/accsetdevicetype.rst: New file. * doc/openacc-runtime-library-routines/accshutdown.rst: New file. * doc/openacc-runtime-library-routines/accunmapdata.rst: New file. * doc/openacc-runtime-library-routines/accupdatedevice.rst: New file. * doc/openacc-runtime-library-routines/accupdateself.rst: New file. * doc/openacc-runtime-library-routines/accwait.rst: New file. * doc/openacc-runtime-library-routines/accwaitall.rst: New file. * doc/openacc-runtime-library-routines/accwaitallasync.rst: New file. * doc/openacc-runtime-library-routines/accwaitasync.rst: New file. * doc/openmp-context-selectors.rst: New file. * doc/openmp-environment-variables.rst: New file. * doc/openmp-environment-variables/gompcpuaffinity.rst: New file. * doc/openmp-environment-variables/gompdebug.rst: New file. * doc/openmp-environment-variables/gomprtemsthreadpools.rst: New file. * doc/openmp-environment-variables/gompspincount.rst: New file. * doc/openmp-environment-variables/gompstacksize.rst: New file. * doc/openmp-environment-variables/ompcancellation.rst: New file. * doc/openmp-environment-variables/ompdefaultdevice.rst: New file. * doc/openmp-environment-variables/ompdisplayenv.rst: New file. * doc/openmp-environment-variables/ompdynamic.rst: New file. * doc/openmp-environment-variables/ompmaxactivelevels.rst: New file. * doc/openmp-environment-variables/ompmaxtaskpriority.rst: New file. * doc/openmp-environment-variables/ompnested.rst: New file. * doc/openmp-environment-variables/ompnumteams.rst: New file. * doc/openmp-environment-variables/ompnumthreads.rst: New file. * doc/openmp-environment-variables/ompplaces.rst: New file. * doc/openmp-environment-variables/ompprocbind.rst: New file. * doc/openmp-environment-variables/ompschedule.rst: New file. * doc/openmp-environment-variables/ompstacksize.rst: New file. * doc/openmp-environment-variables/omptargetoffload.rst: New file. * doc/openmp-environment-variables/ompteamsthreadlimit.rst: New file. * doc/openmp-environment-variables/ompthreadlimit.rst: New file. * doc/openmp-environment-variables/ompwaitpolicy.rst: New file. * doc/openmp-implementation-specifics.rst: New file. * doc/openmp-implementation-status.rst: New file. * doc/openmp-implementation-status/openmp-45.rst: New file. * doc/openmp-implementation-status/openmp-50.rst: New file. * doc/openmp-implementation-status/openmp-51.rst: New file. * doc/openmp-implementation-status/openmp-52.rst: New file. * doc/openmp-runtime-library-routines.rst: New file. * doc/openmp-runtime-library-routines/ompdestroylock.rst: New file. * doc/openmp-runtime-library-routines/ompdestroynestlock.rst: New file. * doc/openmp-runtime-library-routines/ompfulfillevent.rst: New file. * doc/openmp-runtime-library-routines/ompgetactivelevel.rst: New file. * doc/openmp-runtime-library-routines/ompgetancestorthreadnum.rst: New file. * doc/openmp-runtime-library-routines/ompgetcancellation.rst: New file. * doc/openmp-runtime-library-routines/ompgetdefaultdevice.rst: New file. * doc/openmp-runtime-library-routines/ompgetdevicenum.rst: New file. * doc/openmp-runtime-library-routines/ompgetdynamic.rst: New file. * doc/openmp-runtime-library-routines/ompgetinitialdevice.rst: New file. * doc/openmp-runtime-library-routines/ompgetlevel.rst: New file. * doc/openmp-runtime-library-routines/ompgetmaxactivelevels.rst: New file. * doc/openmp-runtime-library-routines/ompgetmaxtaskpriority.rst: New file. * doc/openmp-runtime-library-routines/ompgetmaxteams.rst: New file. * doc/openmp-runtime-library-routines/ompgetmaxthreads.rst: New file. * doc/openmp-runtime-library-routines/ompgetnested.rst: New file. * doc/openmp-runtime-library-routines/ompgetnumdevices.rst: New file. * doc/openmp-runtime-library-routines/ompgetnumprocs.rst: New file. * doc/openmp-runtime-library-routines/ompgetnumteams.rst: New file. * doc/openmp-runtime-library-routines/ompgetnumthreads.rst: New file. * doc/openmp-runtime-library-routines/ompgetprocbind.rst: New file. * doc/openmp-runtime-library-routines/ompgetschedule.rst: New file. * doc/openmp-runtime-library-routines/ompgetsupportedactivelevels.rst: New file. * doc/openmp-runtime-library-routines/ompgetteamnum.rst: New file. * doc/openmp-runtime-library-routines/ompgetteamsize.rst: New file. * doc/openmp-runtime-library-routines/ompgetteamsthreadlimit.rst: New file. * doc/openmp-runtime-library-routines/ompgetthreadlimit.rst: New file. * doc/openmp-runtime-library-routines/ompgetthreadnum.rst: New file. * doc/openmp-runtime-library-routines/ompgetwtick.rst: New file. * doc/openmp-runtime-library-routines/ompgetwtime.rst: New file. * doc/openmp-runtime-library-routines/ompinfinal.rst: New file. * doc/openmp-runtime-library-routines/ompinitlock.rst: New file. * doc/openmp-runtime-library-routines/ompinitnestlock.rst: New file. * doc/openmp-runtime-library-routines/ompinparallel.rst: New file. * doc/openmp-runtime-library-routines/ompisinitialdevice.rst: New file. * doc/openmp-runtime-library-routines/ompsetdefaultdevice.rst: New file. * doc/openmp-runtime-library-routines/ompsetdynamic.rst: New file. * doc/openmp-runtime-library-routines/ompsetlock.rst: New file. * doc/openmp-runtime-library-routines/ompsetmaxactivelevels.rst: New file. * doc/openmp-runtime-library-routines/ompsetnested.rst: New file. * doc/openmp-runtime-library-routines/ompsetnestlock.rst: New file. * doc/openmp-runtime-library-routines/ompsetnumteams.rst: New file. * doc/openmp-runtime-library-routines/ompsetnumthreads.rst: New file. * doc/openmp-runtime-library-routines/ompsetschedule.rst: New file. * doc/openmp-runtime-library-routines/ompsetteamsthreadlimit.rst: New file. * doc/openmp-runtime-library-routines/omptestlock.rst: New file. * doc/openmp-runtime-library-routines/omptestnestlock.rst: New file. * doc/openmp-runtime-library-routines/ompunsetlock.rst: New file. * doc/openmp-runtime-library-routines/ompunsetnestlock.rst: New file. * doc/reporting-bugs.rst: New file. * doc/the-libgomp-abi.rst: New file. * doc/the-libgomp-abi/implementing-atomic-construct.rst: New file. * doc/the-libgomp-abi/implementing-barrier-construct.rst: New file. * doc/the-libgomp-abi/implementing-critical-construct.rst: New file. * doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst: New file. * doc/the-libgomp-abi/implementing-flush-construct.rst: New file. * doc/the-libgomp-abi/implementing-for-construct.rst: New file. * doc/the-libgomp-abi/implementing-master-construct.rst: New file. * doc/the-libgomp-abi/implementing-openaccs-parallel-construct.rst: New file. * doc/the-libgomp-abi/implementing-ordered-construct.rst: New file. * doc/the-libgomp-abi/implementing-parallel-construct.rst: New file. * doc/the-libgomp-abi/implementing-private-clause.rst: New file. * doc/the-libgomp-abi/implementing-reduction-clause.rst: New file. * doc/the-libgomp-abi/implementing-sections-construct.rst: New file. * doc/the-libgomp-abi/implementing-single-construct.rst: New file. * doc/the-libgomp-abi/implementing-threadprivate-construct.rst: New file. libiberty/ChangeLog: * doc/bsd.rst: New file. * doc/conf.py: New file. * doc/copyright.rst: New file. * doc/extensions.rst: New file. * doc/function-variable-and-macro-listing.rst: New file. * doc/index.rst: New file. * doc/indices-and-tables.rst: New file. * doc/introduction.rst: New file. * doc/lesser-general-public-license-2.1.rst: New file. * doc/overview.rst: New file. * doc/replacement-functions.rst: New file. * doc/supplemental-functions.rst: New file. * doc/using.rst: New file. libitm/ChangeLog: * doc/c-c++-language-constructs-for-tm.rst: New file. * doc/conf.py: New file. * doc/copyright.rst: New file. * doc/enabling-libitm.rst: New file. * doc/gnu-free-documentation-license.rst: New file. * doc/index.rst: New file. * doc/indices-and-tables.rst: New file. * doc/internals.rst: New file. * doc/locking-conventions.rst: New file. * doc/nesting-flat-vs-closed.rst: New file. * doc/the-libitm-abi.rst: New file. * doc/the-libitm-abi/function-list.rst: New file. * doc/the-libitm-abi/future-enhancements-to-the-abi.rst: New file. * doc/the-libitm-abi/library-design-principles.rst: New file. * doc/the-libitm-abi/memory-model.rst: New file. * doc/the-libitm-abi/non-objectives.rst: New file. * doc/the-libitm-abi/objectives.rst: New file. * doc/the-libitm-abi/sample-code.rst: New file. * doc/the-libitm-abi/types-and-macros-list.rst: New file. * doc/tm-methods-and-method-groups.rst: New file. libquadmath/ChangeLog: * doc/conf.py: New file. * doc/copyright.rst: New file. * doc/gnu-free-documentation-license.rst: New file. * doc/i-o-library-routines.rst: New file. * doc/index.rst: New file. * doc/indices-and-tables.rst: New file. * doc/introduction.rst: New file. * doc/math-library-routines.rst: New file. * doc/quadmathsnprintf.rst: New file. * doc/reporting-bugs.rst: New file. * doc/strtoflt128.rst: New file. * doc/typedef-and-constants.rst: New file. --- doc/Makefile | 97 + doc/_static/custom.css | 11 + doc/baseconf.py | 230 + doc/bsd.rst | 39 + doc/contrib.rst | 1273 +++++ doc/contribute.rst | 21 + doc/cppdiropts.rst | 217 + doc/cppenv.rst | 97 + doc/cppopts.rst | 556 ++ doc/cppwarnopts.rst | 4 + doc/favicon.ico | Bin 0 -> 766 bytes doc/funding.rst | 47 + doc/gcc_sphinx.py | 44 + doc/gnu.rst | 19 + doc/gnu_free_documentation_license.rst | 476 ++ doc/gpl-3.0.rst | 707 +++ doc/indices-and-tables.rst | 13 + doc/lgpl-2.1.rst | 514 ++ doc/logo.pdf | Bin 0 -> 8978 bytes doc/logo.svg | 108 + doc/md.rst | 3142 +++++++++++ doc/requirements.txt | 3 + gcc/d/doc/conf.py | 30 + gcc/d/doc/copyright.rst | 13 + gcc/d/doc/general-public-license-3.rst | 6 + gcc/d/doc/gnu-free-documentation-license.rst | 6 + gcc/d/doc/index.rst | 22 + gcc/d/doc/indices-and-tables.rst | 1 + gcc/d/doc/invoking-gdc.rst | 48 + gcc/d/doc/invoking-gdc/code-generation.rst | 170 + gcc/d/doc/invoking-gdc/developer-options.rst | 31 + .../invoking-gdc/input-and-output-files.rst | 45 + .../options-for-directory-search.rst | 92 + .../doc/invoking-gdc/options-for-linking.rst | 59 + gcc/d/doc/invoking-gdc/runtime-options.rst | 314 ++ gcc/d/doc/invoking-gdc/warnings.rst | 148 + gcc/doc/cpp/character-sets.rst | 56 + gcc/doc/cpp/conditional-syntax.rst | 411 ++ gcc/doc/cpp/conditional-uses.rst | 32 + gcc/doc/cpp/conditionals.rst | 44 + gcc/doc/cpp/conf.py | 30 + gcc/doc/cpp/copyright.rst | 24 + gcc/doc/cpp/deleted-code.rst | 34 + gcc/doc/cpp/diagnostics.rst | 51 + gcc/doc/cpp/environment-variables.rst | 23 + .../cpp/gnu-free-documentation-license.rst | 6 + gcc/doc/cpp/header-files.rst | 56 + .../alternatives-to-wrapper-ifndef.rst | 40 + .../cpp/header-files/computed-includes.rst | 86 + .../cpp/header-files/include-operation.rst | 67 + gcc/doc/cpp/header-files/include-syntax.rst | 42 + .../cpp/header-files/once-only-headers.rst | 52 + gcc/doc/cpp/header-files/search-path.rst | 53 + gcc/doc/cpp/header-files/system-headers.rst | 41 + gcc/doc/cpp/header-files/wrapper-headers.rst | 58 + .../cpp/implementation-defined-behavior.rst | 97 + gcc/doc/cpp/implementation-details.rst | 23 + gcc/doc/cpp/implementation-limits.rst | 68 + gcc/doc/cpp/index.rst | 35 + gcc/doc/cpp/indices-and-tables.rst | 1 + gcc/doc/cpp/initial-processing.rst | 164 + gcc/doc/cpp/invocation.rst | 81 + gcc/doc/cpp/line-control.rst | 55 + gcc/doc/cpp/macros.rst | 37 + gcc/doc/cpp/macros/concatenation.rst | 85 + .../directives-within-macro-arguments.rst | 39 + gcc/doc/cpp/macros/function-like-macros.rst | 55 + gcc/doc/cpp/macros/macro-arguments.rst | 112 + gcc/doc/cpp/macros/macro-pitfalls.rst | 449 ++ gcc/doc/cpp/macros/object-like-macros.rst | 126 + gcc/doc/cpp/macros/predefined-macros.rst | 874 +++ gcc/doc/cpp/macros/stringizing.rst | 86 + .../undefining-and-redefining-macros.rst | 67 + gcc/doc/cpp/macros/variadic-macros.rst | 141 + gcc/doc/cpp/obsolete-features.rst | 98 + gcc/doc/cpp/other-directives.rst | 30 + gcc/doc/cpp/overview.rst | 67 + gcc/doc/cpp/pragmas.rst | 121 + gcc/doc/cpp/preprocessor-output.rst | 86 + gcc/doc/cpp/the-preprocessing-language.rst | 69 + gcc/doc/cpp/tokenization.rst | 168 + gcc/doc/cpp/traditional-lexical-analysis.rst | 74 + gcc/doc/cpp/traditional-macros.rst | 99 + gcc/doc/cpp/traditional-miscellany.rst | 30 + gcc/doc/cpp/traditional-mode.rst | 35 + gcc/doc/cpp/traditional-warnings.rst | 49 + gcc/doc/cppinternals/conf.py | 24 + gcc/doc/cppinternals/copyright.rst | 19 + gcc/doc/cppinternals/cppinternals.rst | 284 + gcc/doc/cppinternals/cpplib.rst | 29 + gcc/doc/cppinternals/files.rst | 70 + gcc/doc/cppinternals/index.rst | 21 + gcc/doc/cppinternals/indices-and-tables.rst | 1 + .../internal-representation-of-macros.rst | 27 + .../just-which-line-number-anyway.rst | 62 + gcc/doc/cppinternals/lexing-a-line.rst | 91 + gcc/doc/cppinternals/lexing-a-token.rst | 177 + ...nction-like-macros-opening-parenthesis.rst | 24 + .../cppinternals/macro-expansion-overview.rst | 51 + ...tokens-ineligible-for-future-expansion.rst | 24 + .../multiple-include-optimization.rst | 117 + gcc/doc/cppinternals/overview.rst | 24 + .../representation-of-line-numbers.rst | 32 + ...-replacement-list-for-macros-to-expand.rst | 57 + gcc/doc/gcc/binary-compatibility.rst | 151 + .../c++-implementation-defined-behavior.rst | 33 + .../gcc/c-implementation-defined-behavior.rst | 46 + .../architecture.rst | 47 + .../arrays-and-pointers.rst | 46 + .../characters.rst | 93 + .../declarators.rst | 14 + .../environment.rst | 18 + .../floating-point.rst | 88 + .../hints.rst | 35 + .../identifiers.rst | 28 + .../integers.rst | 66 + .../library-functions.rst | 19 + .../locale-specific-behavior.rst | 12 + .../preprocessing-directives.rst | 54 + .../qualifiers.rst | 53 + .../statements.rst | 14 + ...res-unions-enumerations-and-bit-fields.rst | 78 + .../translation.rst | 20 + .../gcc/conditionally-supported-behavior.rst | 20 + gcc/doc/gcc/conf.py | 37 + .../gcc/contributing-to-gcc-development.rst | 6 + gcc/doc/gcc/contributors-to-gcc.rst | 6 + gcc/doc/gcc/copyright.rst | 25 + gcc/doc/gcc/exception-handling.rst | 15 + .../gcc/extensions-to-the-c++-language.rst | 34 + .../backwards-compatibility.rst | 27 + .../c++-concepts.rst | 44 + ...+-interface-and-implementation-pragmas.rst | 97 + ...-variable-function-and-type-attributes.rst | 95 + .../deprecated-features.rst | 43 + ...rom-a-bound-pointer-to-member-function.rst | 48 + .../function-multiversioning.rst | 65 + .../restricting-pointer-aliasing.rst | 52 + .../type-traits.rst | 165 + .../vague-linkage.rst | 80 + ...when-is-a-volatile-c++-object-accessed.rst | 58 + .../wheres-the-template.rst | 131 + .../extensions-to-the-c-language-family.rst | 92 + .../128-bit-integers.rst | 18 + .../additional-floating-types.rst | 83 + .../alternate-keywords.rst | 46 + ...-inline-function-is-as-fast-as-a-macro.rst | 126 + ...ithmetic-on-void-and-function-pointers.rst | 23 + .../arrays-of-length-zero.rst | 111 + .../arrays-of-variable-length.rst | 99 + .../attribute-syntax.rst | 259 + .../binary-constants-using-the-0b-prefix.rst | 29 + ...r-memory-model-aware-atomic-operations.rst | 290 + ...form-arithmetic-with-overflow-checking.rst | 102 + .../c++-style-comments.rst | 18 + .../case-ranges.rst | 43 + .../cast-to-a-union-type.rst | 69 + .../complex-numbers.rst | 122 + .../compound-literals.rst | 104 + .../conditionals-with-omitted-operands.rst | 39 + .../constructing-function-calls.rst | 125 + .../decimal-floating-types.rst | 47 + .../declaring-attributes-of-functions.rst | 109 + .../aarch64-function-attributes.rst | 192 + .../amd-gcn-function-attributes.rst | 93 + .../arc-function-attributes.rst | 88 + .../arm-function-attributes.rst | 168 + .../avr-function-attributes.rst | 120 + .../blackfin-function-attributes.rst | 91 + .../bpf-function-attributes.rst | 24 + .../c-sky-function-attributes.rst | 37 + .../common-function-attributes.rst | 1891 +++++++ .../epiphany-function-attributes.rst | 82 + .../h8-300-function-attributes.rst | 39 + .../ia-64-function-attributes.rst | 36 + .../m32c-function-attributes.rst | 75 + .../m32r-d-function-attributes.rst | 42 + .../m68k-function-attributes.rst | 30 + .../mcore-function-attributes.rst | 24 + .../mep-function-attributes.rst | 53 + .../microblaze-function-attributes.rst | 46 + .../microsoft-windows-function-attributes.rst | 104 + .../mips-function-attributes.rst | 134 + .../msp430-function-attributes.rst | 103 + .../nds32-function-attributes.rst | 96 + .../nios-ii-function-attributes.rst | 42 + .../nvidia-ptx-function-attributes.rst | 22 + .../powerpc-function-attributes.rst | 225 + .../risc-v-function-attributes.rst | 43 + .../rl78-function-attributes.rst | 37 + .../rx-function-attributes.rst | 75 + .../s-390-function-attributes.rst | 52 + .../sh-function-attributes.rst | 101 + .../symbian-os-function-attributes.rst | 12 + .../v850-function-attributes.rst | 20 + .../visium-function-attributes.rst | 22 + .../x86-function-attributes.rst | 1020 ++++ .../xstormy16-function-attributes.rst | 20 + .../designated-initializers.rst | 147 + ...gnment-of-functions-types-or-variables.rst | 44 + .../dollar-signs-in-identifier-names.rst | 16 + .../double-word-integers.rst | 35 + .../enumerator-attributes.rst | 53 + .../fixed-point-types.rst | 128 + ...specific-to-particular-target-machines.rst | 47 + .../function-names-as-strings.rst | 71 + ...-return-or-frame-address-of-a-function.rst | 97 + .../half-precision-floating-point.rst | 76 + .../hex-floats.rst | 30 + ...use-inline-assembly-language-in-c-code.rst | 1979 +++++++ .../incomplete-enum-types.rst | 23 + .../label-attributes.rst | 65 + .../labels-as-values.rst | 86 + ...-in-functions-for-atomic-memory-access.rst | 171 + .../locally-declared-labels.rst | 82 + ...os-with-a-variable-number-of-arguments.rst | 68 + .../mixed-declarations-labels-and-code.rst | 27 + .../named-address-spaces.rst | 240 + .../nested-functions.rst | 132 + .../non-constant-initializers.rst | 23 + .../non-lvalue-arrays-may-have-subscripts.rst | 30 + .../nonlocal-gotos.rst | 62 + ...bject-size-checking-built-in-functions.rst | 145 + ...her-built-in-functions-provided-by-gcc.rst | 1245 +++++ ...ointer-arguments-in-variadic-functions.rst | 22 + ...rrays-with-qualifiers-work-as-expected.rst | 27 + .../pragmas-accepted-by-gcc.rst | 729 +++ ...pes-and-old-style-function-definitions.rst | 63 + .../referring-to-a-type-with-typeof.rst | 137 + ...htly-looser-rules-for-escaped-newlines.rst | 23 + .../specifying-attributes-of-types.rst | 713 +++ .../specifying-attributes-of-variables.rst | 1187 ++++ .../statement-attributes.rst | 71 + ...ements-and-declarations-in-expressions.rst | 164 + .../structures-with-no-members.rst | 22 + .../support-for-offsetof.rst | 34 + .../target-builtins.rst | 53 + .../aarch64-built-in-functions.rst | 24 + .../alpha-built-in-functions.rst | 88 + .../altera-nios-ii-built-in-functions.rst | 118 + .../arc-built-in-functions.rst | 233 + .../arc-simd-built-in-functions.rst | 245 + .../arm-armv8-m-security-extensions.rst | 35 + .../arm-c-language-extensions-acle.rst | 30 + ...ng-point-status-and-control-intrinsics.rst | 17 + .../arm-iwmmxt-built-in-functions.rst | 159 + .../avr-built-in-functions.rst | 114 + .../basic-powerpc-built-in-functions.rst | 724 +++ .../blackfin-built-in-functions.rst | 20 + .../bpf-built-in-functions.rst | 100 + .../fr-v-built-in-functions.rst | 474 ++ .../mips-dsp-built-in-functions.rst | 312 ++ .../mips-loongson-built-in-functions.rst | 447 ++ .../mips-paired-single-support.rst | 45 + .../mips-simd-architecture-msa-support.rst | 812 +++ .../msp430-built-in-functions.rst | 36 + .../nds32-built-in-functions.rst | 44 + .../other-mips-built-in-functions.rst | 27 + .../picochip-built-in-functions.rst | 45 + ...powerpc-altivec-vsx-built-in-functions.rst | 2181 ++++++++ ...erpc-atomic-memory-operation-functions.rst | 68 + ...ransactional-memory-built-in-functions.rst | 226 + ...rix-multiply-assist-built-in-functions.rst | 104 + .../pru-built-in-functions.rst | 34 + .../risc-v-built-in-functions.rst | 16 + .../target-builtins/rx-built-in-functions.rst | 122 + .../s-390-system-z-built-in-functions.rst | 121 + .../target-builtins/sh-built-in-functions.rst | 50 + .../sparc-vis-built-in-functions.rst | 226 + .../ti-c6x-built-in-functions.rst | 43 + .../x86-built-in-functions.rst | 1698 ++++++ ...x86-control-flow-protection-intrinsics.rst | 50 + .../x86-transactional-memory-intrinsics.rst | 102 + .../the-character-esc-in-constants.rst | 12 + .../thread-local-storage.rst | 219 + .../unnamed-structure-and-union-fields.rst | 86 + ...nstructions-through-built-in-functions.rst | 285 + .../when-is-a-volatile-object-accessed.rst | 86 + ...el-extensions-for-transactional-memory.rst | 38 + gcc/doc/gcc/funding.rst | 6 + gcc/doc/gcc/gcc-command-options.rst | 67 + .../gcc/gcc-command-options/c++-modules.rst | 352 ++ .../compiling-c++-programs.rst | 42 + .../gcc/gcc-command-options/description.rst | 73 + .../environment-variables-affecting-gcc.rst | 163 + .../gcc-developer-options.rst | 1174 ++++ .../machine-dependent-options.rst | 92 + .../aarch64-options.rst | 550 ++ .../adapteva-epiphany-options.rst | 163 + .../amd-gcn-options.rst | 58 + .../machine-dependent-options/arc-options.rst | 759 +++ .../machine-dependent-options/arm-options.rst | 1037 ++++ .../machine-dependent-options/avr-mmcu.rst | 97 + .../machine-dependent-options/avr-options.rst | 543 ++ .../blackfin-options.rst | 227 + .../c-sky-options.rst | 193 + .../machine-dependent-options/c6x-options.rst | 55 + .../cris-options.rst | 102 + .../darwin-options.rst | 224 + .../dec-alpha-options.rst | 274 + .../ebpf-options.rst | 94 + .../fr30-options.rst | 27 + .../machine-dependent-options/frv-options.rst | 279 + .../ft32-options.rst | 44 + .../gnu-linux-options.rst | 56 + .../h8-300-options.rst | 64 + .../hppa-options.rst | 245 + .../ia-64-options.rst | 261 + .../ibm-rs-6000-and-powerpc-options.rst | 1017 ++++ .../lm32-options.rst | 35 + .../loongarch-options.rst | 191 + .../m32c-options.rst | 38 + .../m32r-d-options.rst | 137 + .../m680x0-options.rst | 407 ++ .../mcore-options.rst | 66 + .../machine-dependent-options/mep-options.rst | 167 + .../microblaze-options.rst | 121 + .../mips-options.rst | 986 ++++ .../mmix-options.rst | 75 + .../mn10300-options.rst | 93 + .../moxie-options.rst | 31 + .../msp430-options.rst | 189 + .../nds32-options.rst | 116 + .../nios-ii-options.rst | 363 ++ .../nvidia-ptx-options.rst | 98 + .../openrisc-options.rst | 95 + .../options-for-system-v.rst | 43 + .../pdp-11-options.rst | 73 + .../picochip-options.rst | 55 + .../powerpc-options.rst | 15 + .../machine-dependent-options/pru-options.rst | 63 + .../risc-v-options.rst | 216 + .../rl78-options.rst | 91 + .../machine-dependent-options/rx-options.rst | 209 + .../s-390-and-zseries-options.rst | 244 + .../score-options.rst | 51 + .../machine-dependent-options/sh-options.rst | 444 ++ .../solaris-2-options.rst | 42 + .../sparc-options.rst | 388 ++ .../v850-options.rst | 207 + .../machine-dependent-options/vax-options.rst | 35 + .../visium-options.rst | 73 + .../machine-dependent-options/vms-options.rst | 38 + .../vxworks-options.rst | 45 + .../machine-dependent-options/x86-options.rst | 1620 ++++++ .../x86-windows-options.rst | 95 + .../xstormy16-options.rst | 19 + .../xtensa-options.rst | 138 + .../zseries-options.rst | 15 + .../gcc-command-options/option-summary.rst | 1527 ++++++ .../options-controlling-c++-dialect.rst | 2133 ++++++++ .../options-controlling-c-dialect.rst | 544 ++ ...objective-c-and-objective-c++-dialects.rst | 316 ++ ...options-controlling-the-kind-of-output.rst | 732 +++ .../options-controlling-the-preprocessor.rst | 79 + ...ptions-for-code-generation-conventions.rst | 713 +++ .../options-for-debugging-your-program.rst | 471 ++ .../options-for-directory-search.rst | 102 + .../options-for-linking.rst | 407 ++ .../options-that-control-optimization.rst | 4857 ++++++++++++++++ .../options-that-control-static-analysis.rst | 1067 ++++ ...control-diagnostic-messages-formatting.rst | 899 +++ ...ptions-to-request-or-suppress-warnings.rst | 4866 +++++++++++++++++ .../passing-options-to-the-assembler.rst | 27 + .../program-instrumentation-options.rst | 1111 ++++ ...esses-and-the-switches-to-pass-to-them.rst | 687 +++ .../using-precompiled-headers.rst | 132 + gcc/doc/gcc/gcc.rst | 47 + gcc/doc/gcc/gcov-dump.rst | 70 + gcc/doc/gcc/gcov-tool.rst | 209 + gcc/doc/gcc/gcov.rst | 53 + .../brief-description-of-gcov-data-files.rst | 33 + ...-relocation-to-support-cross-profiling.rst | 43 + gcc/doc/gcc/gcov/introduction-to-gcov.rst | 62 + gcc/doc/gcc/gcov/invoking-gcov.rst | 656 +++ ...-coverage-in-freestanding-environments.rst | 391 ++ .../gcov/using-gcov-with-gcc-optimization.rst | 86 + gcc/doc/gcc/general-public-license-3.rst | 6 + .../gcc/gnu-free-documentation-license.rst | 6 + gcc/doc/gcc/gnu-objective-c-features.rst | 27 + .../compatibilityalias.rst | 26 + .../constant-string-objects.rst | 64 + .../gnu-objective-c-features/exceptions.rst | 79 + .../fast-enumeration.rst | 221 + .../garbage-collection.rst | 81 + .../gnu-objective-c-runtime-api.rst | 98 + .../load-executing-code-before-main.rst | 141 + ...aging-with-the-gnu-objective-c-runtime.rst | 145 + .../synchronization.rst | 36 + .../type-encoding.rst | 280 + gcc/doc/gcc/gnu.rst | 1 + gcc/doc/gcc/have-you-found-a-bug.rst | 62 + gcc/doc/gcc/how-and-where-to-report-bugs.rst | 13 + gcc/doc/gcc/how-to-get-help-with-gcc.rst | 26 + gcc/doc/gcc/index.rst | 40 + gcc/doc/gcc/indices-and-tables.rst | 1 + .../gcc/known-causes-of-trouble-with-gcc.rst | 32 + .../actual-bugs-we-havent-fixed-yet.rst | 14 + .../certain-changes-we-dont-want-to-make.rst | 236 + .../common-misunderstandings-with-gnu-c.rst | 296 + .../disappointments-and-misunderstandings.rst | 102 + .../fixed-header-files.rst | 39 + .../incompatibilities-of-gcc.rst | 233 + .../interoperation.rst | 153 + .../standard-libraries.rst | 33 + .../warning-messages-and-error-messages.rst | 46 + .../language-standards-supported-by-gcc.rst | 23 + .../c++-language.rst | 71 + .../c-language.rst | 139 + .../d-language.rst | 11 + .../go-language.rst | 10 + ...bjective-c-and-objective-c++-languages.rst | 62 + .../references-for-other-languages.rst | 13 + gcc/doc/gcc/lto-dump.rst | 117 + ...programming-languages-supported-by-gcc.rst | 54 + gcc/doc/gcc/reporting-bugs.rst | 23 + ...ysis-and-optimization-of-gimple-tuples.rst | 44 + .../alias-analysis.rst | 104 + .../annotations.rst | 17 + .../memory-model.rst | 34 + .../ssa-operands.rst | 388 ++ .../static-single-assignment.rst | 259 + .../analysis-and-representation-of-loops.rst | 27 + .../data-dependency-analysis.rst | 135 + .../iv-analysis-on-rtl.rst | 55 + .../loop-closed-ssa-form.rst | 47 + .../loop-manipulation.rst | 58 + .../loop-querying.rst | 81 + .../loop-representation.rst | 137 + .../number-of-iterations-analysis.rst | 85 + .../scalar-evolutions.rst | 71 + gcc/doc/gccint/analyzer-internals.rst | 419 ++ gcc/doc/gccint/collect2.rst | 77 + gcc/doc/gccint/conf.py | 24 + .../contributing-to-gcc-development.rst | 6 + gcc/doc/gccint/contributors-to-gcc.rst | 6 + gcc/doc/gccint/control-flow-graph.rst | 43 + .../control-flow-graph/basic-blocks.rst | 141 + gcc/doc/gccint/control-flow-graph/edges.rst | 241 + .../liveness-information.rst | 48 + .../maintaining-the-cfg.rst | 145 + .../profile-information.rst | 112 + gcc/doc/gccint/copyright.rst | 25 + gcc/doc/gccint/debugging-the-analyzer.rst | 141 + gcc/doc/gccint/funding.rst | 6 + gcc/doc/gccint/gcc-and-portability.rst | 41 + gcc/doc/gccint/general-public-license-3.rst | 6 + gcc/doc/gccint/generic.rst | 47 + .../gccint/generic/attributes-in-trees.rst | 35 + gcc/doc/gccint/generic/c-and-c++-trees.rst | 886 +++ gcc/doc/gccint/generic/declarations.rst | 346 ++ gcc/doc/gccint/generic/deficiencies.rst | 14 + gcc/doc/gccint/generic/expressions.rst | 910 +++ gcc/doc/gccint/generic/functions.rst | 212 + .../generic/language-dependent-trees.rst | 25 + gcc/doc/gccint/generic/overview.rst | 213 + gcc/doc/gccint/generic/statements.rst | 516 ++ gcc/doc/gccint/generic/types.rst | 299 + gcc/doc/gccint/gimple-api.rst | 47 + gcc/doc/gccint/gimple.rst | 88 + .../adding-a-new-gimple-statement-code.rst | 36 + .../class-hierarchy-of-gimple-statements.rst | 150 + gcc/doc/gccint/gimple/exception-handling.rst | 46 + .../gccint/gimple/gimple-instruction-set.rst | 106 + gcc/doc/gccint/gimple/gimple-sequences.rst | 94 + .../gimple/manipulating-gimple-statements.rst | 176 + gcc/doc/gccint/gimple/operands.rst | 319 ++ gcc/doc/gccint/gimple/sequence-iterators.rst | 223 + .../statement-and-operand-traversals.rst | 62 + gcc/doc/gccint/gimple/temporaries.rst | 43 + .../gccint/gimple/tuple-representation.rst | 242 + .../gimple/tuple-specific-accessors.rst | 44 + .../tuple-specific-accessors/gimpleasm.rst | 66 + .../tuple-specific-accessors/gimpleassign.rst | 126 + .../tuple-specific-accessors/gimplebind.rst | 56 + .../tuple-specific-accessors/gimplecall.rst | 116 + .../tuple-specific-accessors/gimplecatch.rst | 37 + .../tuple-specific-accessors/gimplecond.rst | 80 + .../tuple-specific-accessors/gimpledebug.rst | 106 + .../gimpleehfilter.rst | 45 + .../tuple-specific-accessors/gimplegoto.rst | 21 + .../tuple-specific-accessors/gimplelabel.rst | 23 + .../tuple-specific-accessors/gimplenop.rst | 17 + .../gimpleompatomicload.rst | 31 + .../gimpleompatomicstore.rst | 22 + .../gimpleompcontinue.rst | 43 + .../gimpleompcritical.rst | 28 + .../tuple-specific-accessors/gimpleompfor.rst | 97 + .../gimpleompmaster.rst | 14 + .../gimpleompordered.rst | 16 + .../gimpleompparallel.rst | 76 + .../gimpleompreturn.rst | 23 + .../gimpleompsection.rst | 24 + .../gimpleompsections.rst | 48 + .../gimpleompsingle.rst | 28 + .../tuple-specific-accessors/gimplephi.rst | 41 + .../tuple-specific-accessors/gimpleresx.rst | 24 + .../tuple-specific-accessors/gimplereturn.rst | 21 + .../tuple-specific-accessors/gimpleswitch.rst | 52 + .../tuple-specific-accessors/gimpletry.rst | 51 + .../gimplewithcleanupexpr.rst | 30 + .../gccint/gnu-free-documentation-license.rst | 6 + gcc/doc/gccint/guidelines-for-diagnostics.rst | 598 ++ gcc/doc/gccint/guidelines-for-options.rst | 13 + gcc/doc/gccint/host-common.rst | 57 + gcc/doc/gccint/host-configuration.rst | 32 + gcc/doc/gccint/host-filesystem.rst | 103 + gcc/doc/gccint/host-makefile-fragments.rst | 14 + gcc/doc/gccint/host-misc.rst | 70 + gcc/doc/gccint/index.rst | 51 + gcc/doc/gccint/indices-and-tables.rst | 1 + gcc/doc/gccint/interfacing-to-gcc-output.rst | 71 + gcc/doc/gccint/introduction.rst | 26 + gcc/doc/gccint/language-front-ends-in-gcc.rst | 39 + gcc/doc/gccint/link-time-optimization.rst | 33 + .../design-overview.rst | 123 + .../internal-flags-controlling-lto1.rst | 42 + .../lto-file-sections.rst | 110 + ...sing-summary-information-in-ipa-passes.rst | 206 + ...-linker-plugin-and-symbol-visibilities.rst | 91 + gcc/doc/gccint/machine-descriptions.rst | 49 + .../c-statements-for-assembler-output.rst | 122 + .../canonicalization-of-instructions.rst | 152 + .../conditional-execution.rst | 98 + .../constant-definitions.rst | 185 + .../defining-how-to-split-instructions.rst | 374 ++ .../defining-jump-instruction-patterns.rst | 37 + .../defining-looping-instruction-patterns.rst | 134 + ...ning-rtl-sequences-for-code-generation.rst | 206 + .../everything-about-instruction-patterns.rst | 106 + .../example-of-defineinsn.rst | 54 + ...uding-patterns-in-machine-descriptions.rst | 70 + .../instruction-attributes.rst | 1248 +++++ .../interdependence-of-patterns.rst | 43 + .../gccint/machine-descriptions/iterators.rst | 543 ++ .../machine-specific-peephole-optimizers.rst | 330 ++ .../operand-constraints.rst | 426 ++ ...put-templates-and-operand-substitution.rst | 99 + ...of-how-the-machine-description-is-used.rst | 47 + .../machine-descriptions/predicates.rst | 343 ++ .../machine-descriptions/rtl-template.rst | 255 + .../rtl-templates-transformations.rst | 225 + .../standard-pattern-names-for-generation.rst | 3413 ++++++++++++ .../when-the-order-of-patterns-matters.rst | 29 + gcc/doc/gccint/makefile-fragments.rst | 37 + gcc/doc/gccint/match-and-simplify.rst | 34 + ...memory-management-and-type-information.rst | 103 + .../how-to-invoke-the-garbage-collector.rst | 36 + ...arking-roots-for-the-garbage-collector.rst | 28 + ...urce-files-containing-type-information.rst | 60 + .../support-for-inheritance.rst | 59 + ...-for-user-provided-gc-marking-routines.rst | 121 + .../the-inside-of-a-gty.rst | 324 ++ .../troubleshooting-the-garbage-collector.rst | 27 + gcc/doc/gccint/option-file-format.rst | 175 + gcc/doc/gccint/option-properties.rst | 376 ++ gcc/doc/gccint/option-specification-files.rst | 21 + .../passes-and-files-of-the-compiler.rst | 27 + .../gimplification-pass.rst | 44 + .../inter-procedural-optimization-passes.rst | 269 + .../optimization-info.rst | 262 + .../parsing-pass.rst | 80 + .../pass-manager.rst | 42 + .../rtl-passes.rst | 275 + .../tree-ssa-passes.rst | 477 ++ gcc/doc/gccint/plugins.rst | 35 + .../gccint/plugins/building-gcc-plugins.rst | 97 + ...controlling-which-passes-are-being-run.rst | 16 + .../giving-information-about-a-plugin.rst | 24 + ...racting-with-the-gcc-garbage-collector.rst | 37 + .../interacting-with-the-pass-manager.rst | 57 + .../keeping-track-of-available-passes.rst | 17 + gcc/doc/gccint/plugins/loading-plugins.rst | 31 + gcc/doc/gccint/plugins/plugin-api.rst | 213 + ...rding-information-about-pass-execution.rst | 20 + ...gistering-custom-attributes-or-pragmas.rst | 73 + gcc/doc/gccint/rtl-representation.rst | 48 + .../rtl-representation/access-to-operands.rst | 73 + .../access-to-special-operands.rst | 188 + .../assembler-instructions-as-expressions.rst | 45 + .../gccint/rtl-representation/bit-fields.rst | 48 + .../comparison-operations.rst | 112 + .../constant-expression-types.rst | 313 ++ .../gccint/rtl-representation/conversions.rst | 152 + .../rtl-representation/declarations.rst | 27 + .../embedded-side-effects-on-addresses.rst | 100 + .../flags-in-an-rtl-expression.rst | 447 ++ gcc/doc/gccint/rtl-representation/insns.rst | 624 +++ .../rtl-representation/machine-modes.rst | 635 +++ .../on-the-side-ssa-form-for-rtl.rst | 748 +++ .../gccint/rtl-representation/reading-rtl.rst | 28 + .../registers-and-memory.rst | 451 ++ .../rtl-classes-and-formats.rst | 192 + .../rtl-expressions-for-arithmetic.rst | 310 ++ .../rtl-representation/rtl-object-types.rst | 84 + ...-representation-of-function-call-insns.rst | 72 + .../side-effect-expressions.rst | 374 ++ .../structure-sharing-assumptions.rst | 99 + ...able-location-debug-information-in-rtl.rst | 64 + .../rtl-representation/vector-operations.rst | 60 + ...izes-and-offsets-as-runtime-invariants.rst | 51 + .../alignment-of-polyints.rst | 84 + .../arithmetic-on-polyints.rst | 178 + .../comparisons-involving-polyint.rst | 324 ++ .../computing-bounds-on-polyints.rst | 34 + .../consequences-of-using-polyint.rst | 55 + .../converting-polyints.rst | 91 + .../guidelines-for-using-polyint.rst | 119 + .../miscellaneous-polyint-routines.rst | 16 + .../overview-of-polyint.rst | 78 + ...source-tree-structure-and-build-system.rst | 21 + .../configure-terms-and-history.rst | 64 + .../the-gcc-subdirectory.rst | 28 + .../anatomy-of-a-language-front-end.rst | 281 + .../anatomy-of-a-target-back-end.rst | 116 + .../build-system-in-the-gcc-directory.rst | 14 + .../building-documentation.rst | 247 + .../configuration-in-the-gcc-directory.rst | 127 + .../headers-installed-by-gcc.rst | 50 + ...es-and-headers-under-the-gcc-directory.rst | 15 + .../the-gcc-subdirectory/makefile-targets.rst | 195 + .../subdirectories-of-gcc.rst | 55 + .../top-level-source-directory.rst | 135 + .../standard-header-file-directories.rst | 35 + gcc/doc/gccint/static-analyzer.rst | 19 + gcc/doc/gccint/target-macros.rst | 60 + ...dding-support-for-named-address-spaces.rst | 163 + .../gccint/target-macros/addressing-modes.rst | 824 +++ .../adjusting-the-instruction-scheduler.rst | 660 +++ .../target-macros/anchored-addresses.rst | 92 + .../target-macros/c++-abi-parameters.rst | 164 + .../target-macros/condition-code-status.rst | 210 + ...ntrolling-debugging-information-format.rst | 306 ++ ...controlling-the-compilation-driver-gcc.rst | 482 ++ .../cross-compilation-and-floating-point.rst | 73 + .../gccint/target-macros/d-abi-parameters.rst | 111 + ...coprocessor-specifics-for-mips-targets.rst | 35 + ...tructures-for-per-function-information.rst | 62 + ...ning-target-specific-uses-of-attribute.rst | 319 ++ ...defining-the-output-assembler-language.rst | 27 + .../assembler-commands-for-alignment.rst | 95 + ...sembler-commands-for-exception-regions.rst | 188 + ...w-initialization-functions-are-handled.rst | 122 + ...os-controlling-initialization-routines.rst | 182 + .../output-and-generation-of-labels.rst | 586 ++ .../output-of-assembler-instructions.rst | 252 + .../output-of-data.rst | 191 + .../output-of-dispatch-tables.rst | 171 + .../output-of-uninitialized-variables.rst | 105 + ...overall-framework-of-an-assembler-file.rst | 287 + ...escribing-relative-costs-of-operations.rst | 528 ++ ...ng-the-output-into-sections-texts-data.rst | 445 ++ .../gccint/target-macros/emulating-tls.rst | 125 + .../implementing-the-varargs-macros.rst | 192 + .../implicit-calls-to-library-routines.rst | 141 + .../layout-of-source-language-data-types.rst | 355 ++ .../miscellaneous-parameters.rst | 1718 ++++++ .../mode-switching-instructions.rst | 121 + ...r-precompiled-header-validity-checking.rst | 63 + .../position-independent-code.rst | 53 + .../gccint/target-macros/register-classes.rst | 801 +++ .../gccint/target-macros/register-usage.rst | 563 ++ .../run-time-target-specification.rst | 273 + .../stack-layout-and-calling-conventions.rst | 35 + .../basic-stack-layout.rst | 304 + .../caller-saves-register-allocation.rst | 21 + ...minating-frame-pointer-and-arg-pointer.rst | 102 + .../exception-handling-support.rst | 137 + .../function-entry-and-exit.rst | 265 + .../generating-code-for-profiling.rst | 61 + .../how-large-values-are-returned.rst | 132 + ...ow-scalar-function-values-are-returned.rst | 166 + .../miscellaneous-register-hooks.rst | 26 + .../passing-arguments-in-registers.rst | 633 +++ ...assing-function-arguments-on-the-stack.rst | 193 + .../permitting-tail-calls.rst | 60 + ...registers-that-address-the-stack-frame.rst | 198 + .../shrink-wrapping-separate-components.rst | 93 + .../specifying-how-stack-checking-is-done.rst | 118 + .../stack-smashing-protection.rst | 75 + .../gccint/target-macros/storage-layout.rst | 729 +++ .../support-for-nested-functions.rst | 222 + .../the-global-targetm-variable.rst | 65 + gcc/doc/gccint/target-makefile-fragments.rst | 245 + gcc/doc/gccint/testsuites.rst | 31 + .../testsuites/ada-language-testsuites.rst | 38 + .../testsuites/c-language-testsuites.rst | 113 + .../directives-used-within-dejagnu-tests.rst | 19 + .../commands-for-use-in-dg-final.rst | 291 + .../features-for-dg-add-options.rst | 122 + .../keywords-describing-target-attributes.rst | 1524 ++++++ ...ecting-targets-to-which-a-test-applies.rst | 106 + ...ax-and-descriptions-of-test-directives.rst | 311 ++ .../variants-of-dg-require-support.rst | 83 + .../idioms-used-in-testsuite-code.rst | 84 + ...pport-for-testing-binary-compatibility.rst | 109 + .../testsuites/support-for-testing-gcov.rst | 72 + .../support-for-testing-gimple-passes.rst | 55 + ...rt-for-testing-link-time-optimizations.rst | 46 + ...testing-profile-directed-optimizations.rst | 51 + .../support-for-testing-rtl-passes.rst | 48 + ...torture-testing-using-multiple-options.rst | 52 + .../the-gcc-low-level-runtime-library.rst | 50 + ...endent-routines-for-exception-handling.rst | 42 + ...miscellaneous-runtime-library-routines.rst | 59 + ...s-for-decimal-floating-point-emulation.rst | 312 ++ ...s-for-fixed-point-fractional-emulation.rst | 1432 +++++ .../routines-for-floating-point-emulation.rst | 283 + .../routines-for-integer-arithmetic.rst | 183 + gcc/doc/gccint/the-language.rst | 384 ++ gcc/doc/gccint/user-experience-guidelines.rst | 30 + gcc/doc/install/binaries.rst | 54 + gcc/doc/install/building.rst | 67 + .../building/building-a-cross-compiler.rst | 74 + .../building/building-a-native-compiler.rst | 191 + .../install/building/building-in-parallel.rst | 15 + .../building/building-the-ada-compiler.rst | 9 + .../building/building-the-d-compiler.rst | 9 + .../building-with-profile-feedback.rst | 34 + gcc/doc/install/conf.py | 24 + gcc/doc/install/configuration.rst | 2098 +++++++ gcc/doc/install/copyright.rst | 24 + gcc/doc/install/downloading-gcc.rst | 42 + gcc/doc/install/final-installation.rst | 128 + .../gnu-free-documentation-license.rst | 6 + ...et-specific-installation-notes-for-gcc.rst | 1336 +++++ ...ou-run-the-testsuite-on-selected-tests.rst | 46 + .../install/how-to-interpret-test-results.rst | 32 + gcc/doc/install/index.rst | 27 + gcc/doc/install/indices-and-tables.rst | 1 + gcc/doc/install/installing-gcc.rst | 39 + ...ptions-and-running-multiple-testsuites.rst | 74 + gcc/doc/install/prerequisites.rst | 319 ++ gcc/doc/install/submitting-test-results.rst | 22 + gcc/doc/install/testing.rst | 69 + .../code-that-interacts-with-the-user.rst | 15 + .../gfc-internals/command-line-options.rst | 30 + gcc/fortran/doc/gfc-internals/conf.py | 24 + gcc/fortran/doc/gfc-internals/copyright.rst | 25 + .../doc/gfc-internals/error-handling.rst | 75 + .../frontend-data-structures.rst | 23 + ...intermediate-language-for-later-stages.rst | 24 + .../accessing-declarations.rst | 16 + .../basic-data-structures.rst | 67 + .../converting-expressions-to-tree.rst | 48 + .../translating-statements.rst | 14 + gcc/fortran/doc/gfc-internals/gfccode.rst | 146 + gcc/fortran/doc/gfc-internals/gfcexpr.rst | 156 + .../gnu-free-documentation-license.rst | 6 + gcc/fortran/doc/gfc-internals/index.rst | 24 + .../doc/gfc-internals/indices-and-tables.rst | 1 + ...internals-of-fortran-2003-oop-features.rst | 15 + .../doc/gfc-internals/introduction.rst | 32 + .../doc/gfc-internals/symbol-versioning.rst | 63 + .../the-libgfortran-runtime-library.rst | 14 + .../gfc-internals/type-bound-operators.rst | 33 + .../gfc-internals/type-bound-procedures.rst | 101 + .../doc/gfortran/about-gnu-fortran.rst | 115 + .../doc/gfortran/coarray-programming.rst | 17 + .../doc/gfortran/compiler-characteristics.rst | 27 + .../asynchronous-i-o.rst | 21 + .../data-consistency-and-durability.rst | 80 + .../evaluation-of-logical-expressions.rst | 18 + ...format-of-unformatted-sequential-files.rst | 63 + .../file-operations-on-symbolic-links.rst | 28 + ...-without-an-explicit-action=-specifier.rst | 23 + ...al-representation-of-logical-variables.rst | 24 + .../kind-type-parameters.rst | 54 + ...min-intrinsics-with-real-nan-arguments.rst | 21 + .../thread-safety-of-the-runtime-library.rst | 53 + gcc/fortran/doc/gfortran/conf.py | 30 + gcc/fortran/doc/gfortran/contributing.rst | 28 + .../gfortran/contributors-to-gnu-fortran.rst | 109 + gcc/fortran/doc/gfortran/copyright.rst | 25 + .../extensions-implemented-in-gnu-fortran.rst | 1535 ++++++ ...ensions-not-implemented-in-gnu-fortran.rst | 186 + gcc/fortran/doc/gfortran/extensions.rst | 24 + .../gfortran/function-abi-documentation.rst | 1526 ++++++ gcc/fortran/doc/gfortran/funding.rst | 6 + .../doc/gfortran/general-public-license-3.rst | 6 + .../doc/gfortran/gnu-fortran-and-gcc.rst | 48 + .../gfortran/gnu-fortran-command-options.rst | 33 + .../description.rst | 39 + .../enable-and-customize-preprocessing.rst | 298 + ...vironment-variables-affecting-gfortran.rst | 24 + .../influencing-runtime-behavior.rst | 67 + .../influencing-the-linking-step.rst | 37 + .../option-summary.rst | 104 + .../options-controlling-fortran-dialect.rst | 411 ++ ...ptions-for-code-generation-conventions.rst | 583 ++ ...-debugging-your-program-or-gnu-fortran.rst | 134 + .../options-for-directory-search.rst | 54 + ...-interoperability-with-other-languages.rst | 63 + ...equest-or-suppress-errors-and-warnings.rst | 411 ++ .../gnu-fortran-compiler-directives.rst | 174 + .../gnu-free-documentation-license.rst | 6 + gcc/fortran/doc/gfortran/index.rst | 56 + .../doc/gfortran/indices-and-tables.rst | 1 + .../doc/gfortran/interoperability-with-c.rst | 413 ++ .../doc/gfortran/intrinsic-modules.rst | 20 + ...ptions-ieeearithmetic-and-ieeefeatures.rst | 29 + .../intrinsic-modules/isocbinding.rst | 227 + .../intrinsic-modules/isofortranenv.rst | 116 + .../openacc-module-openacc.rst | 27 + .../openmp-modules-omplib-and-omplibkinds.rst | 161 + .../doc/gfortran/intrinsic-procedures.rst | 299 + .../gfortran/intrinsic-procedures/abort.rst | 44 + .../doc/gfortran/intrinsic-procedures/abs.rst | 117 + .../gfortran/intrinsic-procedures/access.rst | 61 + .../gfortran/intrinsic-procedures/achar.rst | 56 + .../gfortran/intrinsic-procedures/acos.rst | 73 + .../gfortran/intrinsic-procedures/acosd.rst | 74 + .../gfortran/intrinsic-procedures/acosh.rst | 70 + .../gfortran/intrinsic-procedures/adjustl.rst | 48 + .../gfortran/intrinsic-procedures/adjustr.rst | 48 + .../gfortran/intrinsic-procedures/aimag.rst | 81 + .../gfortran/intrinsic-procedures/aint.rst | 78 + .../gfortran/intrinsic-procedures/alarm.rst | 59 + .../doc/gfortran/intrinsic-procedures/all.rst | 61 + .../intrinsic-procedures/allocated.rst | 49 + .../doc/gfortran/intrinsic-procedures/and.rst | 60 + .../gfortran/intrinsic-procedures/anint.rst | 76 + .../doc/gfortran/intrinsic-procedures/any.rst | 61 + .../gfortran/intrinsic-procedures/asin.rst | 73 + .../gfortran/intrinsic-procedures/asind.rst | 74 + .../gfortran/intrinsic-procedures/asinh.rst | 70 + .../intrinsic-procedures/associated.rst | 74 + .../gfortran/intrinsic-procedures/atan.rst | 80 + .../gfortran/intrinsic-procedures/atan2.rst | 85 + .../gfortran/intrinsic-procedures/atan2d.rst | 85 + .../gfortran/intrinsic-procedures/atand.rst | 80 + .../gfortran/intrinsic-procedures/atanh.rst | 70 + .../intrinsic-procedures/atomicadd.rst | 60 + .../intrinsic-procedures/atomicand.rst | 60 + .../intrinsic-procedures/atomiccas.rst | 67 + .../intrinsic-procedures/atomicdefine.rst | 62 + .../intrinsic-procedures/atomicfetchadd.rst | 65 + .../intrinsic-procedures/atomicfetchand.rst | 64 + .../intrinsic-procedures/atomicfetchor.rst | 64 + .../intrinsic-procedures/atomicfetchxor.rst | 64 + .../intrinsic-procedures/atomicor.rst | 60 + .../intrinsic-procedures/atomicref.rst | 68 + .../intrinsic-procedures/atomicxor.rst | 60 + .../intrinsic-procedures/backtrace.rst | 34 + .../intrinsic-procedures/besselj0.rst | 64 + .../intrinsic-procedures/besselj1.rst | 64 + .../intrinsic-procedures/besseljn.rst | 85 + .../intrinsic-procedures/bessely0.rst | 62 + .../intrinsic-procedures/bessely1.rst | 62 + .../intrinsic-procedures/besselyn.rst | 85 + .../doc/gfortran/intrinsic-procedures/bge.rst | 42 + .../doc/gfortran/intrinsic-procedures/bgt.rst | 41 + .../gfortran/intrinsic-procedures/bitsize.rst | 44 + .../doc/gfortran/intrinsic-procedures/ble.rst | 42 + .../doc/gfortran/intrinsic-procedures/blt.rst | 41 + .../gfortran/intrinsic-procedures/btest.rst | 89 + .../intrinsic-procedures/cassociated.rst | 54 + .../gfortran/intrinsic-procedures/ceiling.rst | 51 + .../intrinsic-procedures/cfpointer.rst | 63 + .../intrinsic-procedures/cfprocpointer.rst | 64 + .../gfortran/intrinsic-procedures/cfunloc.rst | 64 + .../gfortran/intrinsic-procedures/char.rst | 71 + .../gfortran/intrinsic-procedures/chdir.rst | 51 + .../gfortran/intrinsic-procedures/chmod.rst | 70 + .../gfortran/intrinsic-procedures/cloc.rst | 51 + .../gfortran/intrinsic-procedures/cmplx.rst | 61 + .../intrinsic-procedures/cobroadcast.rst | 65 + .../gfortran/intrinsic-procedures/comax.rst | 66 + .../gfortran/intrinsic-procedures/comin.rst | 66 + .../commandargumentcount.rst | 43 + .../intrinsic-procedures/compileroptions.rst | 48 + .../intrinsic-procedures/compilerversion.rst | 47 + .../gfortran/intrinsic-procedures/complex.rst | 50 + .../gfortran/intrinsic-procedures/conjg.rst | 63 + .../intrinsic-procedures/coreduce.rst | 94 + .../doc/gfortran/intrinsic-procedures/cos.rst | 91 + .../gfortran/intrinsic-procedures/cosd.rst | 91 + .../gfortran/intrinsic-procedures/cosh.rst | 73 + .../gfortran/intrinsic-procedures/cosum.rst | 67 + .../gfortran/intrinsic-procedures/cotan.rst | 71 + .../gfortran/intrinsic-procedures/cotand.rst | 74 + .../gfortran/intrinsic-procedures/count.rst | 72 + .../gfortran/intrinsic-procedures/cputime.rst | 49 + .../gfortran/intrinsic-procedures/cshift.rst | 61 + .../gfortran/intrinsic-procedures/csizeof.rst | 55 + .../gfortran/intrinsic-procedures/ctime.rst | 62 + .../intrinsic-procedures/dateandtime.rst | 70 + .../gfortran/intrinsic-procedures/dble.rst | 46 + .../gfortran/intrinsic-procedures/dcmplx.rst | 54 + .../gfortran/intrinsic-procedures/digits.rst | 46 + .../doc/gfortran/intrinsic-procedures/dim.rst | 78 + .../intrinsic-procedures/dotproduct.rst | 57 + .../gfortran/intrinsic-procedures/dprod.rst | 62 + .../gfortran/intrinsic-procedures/dreal.rst | 43 + .../gfortran/intrinsic-procedures/dshiftl.rst | 52 + .../gfortran/intrinsic-procedures/dshiftr.rst | 52 + .../gfortran/intrinsic-procedures/dtime.rst | 64 + .../gfortran/intrinsic-procedures/eoshift.rst | 67 + .../gfortran/intrinsic-procedures/epsilon.rst | 43 + .../doc/gfortran/intrinsic-procedures/erf.rst | 57 + .../gfortran/intrinsic-procedures/erfc.rst | 57 + .../intrinsic-procedures/erfcscaled.rst | 41 + .../gfortran/intrinsic-procedures/etime.rst | 62 + .../intrinsic-procedures/eventquery.rst | 57 + .../executecommandline.rst | 70 + .../gfortran/intrinsic-procedures/exit.rst | 47 + .../doc/gfortran/intrinsic-procedures/exp.rst | 83 + .../intrinsic-procedures/exponent.rst | 44 + .../intrinsic-procedures/extendstypeof.rst | 41 + .../gfortran/intrinsic-procedures/fdate.rst | 57 + .../gfortran/intrinsic-procedures/fget.rst | 60 + .../gfortran/intrinsic-procedures/fgetc.rst | 62 + .../gfortran/intrinsic-procedures/findloc.rst | 78 + .../gfortran/intrinsic-procedures/floor.rst | 51 + .../gfortran/intrinsic-procedures/flush.rst | 72 + .../gfortran/intrinsic-procedures/fnum.rst | 44 + .../gfortran/intrinsic-procedures/fput.rst | 54 + .../gfortran/intrinsic-procedures/fputc.rst | 60 + .../intrinsic-procedures/fraction.rst | 44 + .../gfortran/intrinsic-procedures/free.rst | 43 + .../gfortran/intrinsic-procedures/fseek.rst | 72 + .../gfortran/intrinsic-procedures/fstat.rst | 47 + .../gfortran/intrinsic-procedures/ftell.rst | 50 + .../gfortran/intrinsic-procedures/gamma.rst | 67 + .../gfortran/intrinsic-procedures/gerror.rst | 43 + .../gfortran/intrinsic-procedures/getarg.rst | 64 + .../intrinsic-procedures/getcommand.rst | 58 + .../getcommandargument.rst | 76 + .../gfortran/intrinsic-procedures/getcwd.rst | 46 + .../gfortran/intrinsic-procedures/getenv.rst | 49 + .../getenvironmentvariable.rst | 68 + .../gfortran/intrinsic-procedures/getgid.rst | 37 + .../gfortran/intrinsic-procedures/getlog.rst | 47 + .../gfortran/intrinsic-procedures/getpid.rst | 43 + .../gfortran/intrinsic-procedures/getuid.rst | 37 + .../gfortran/intrinsic-procedures/gmtime.rst | 47 + .../gfortran/intrinsic-procedures/hostnm.rst | 38 + .../gfortran/intrinsic-procedures/huge.rst | 41 + .../gfortran/intrinsic-procedures/hypot.rst | 45 + .../gfortran/intrinsic-procedures/iachar.rst | 55 + .../gfortran/intrinsic-procedures/iall.rst | 61 + .../gfortran/intrinsic-procedures/iand.rst | 99 + .../gfortran/intrinsic-procedures/iany.rst | 61 + .../gfortran/intrinsic-procedures/iargc.rst | 44 + .../gfortran/intrinsic-procedures/ibclr.rst | 87 + .../gfortran/intrinsic-procedures/ibits.rst | 93 + .../gfortran/intrinsic-procedures/ibset.rst | 85 + .../gfortran/intrinsic-procedures/ichar.rst | 93 + .../gfortran/intrinsic-procedures/idate.rst | 50 + .../gfortran/intrinsic-procedures/ieor.rst | 91 + .../gfortran/intrinsic-procedures/ierrno.rst | 37 + .../intrinsic-procedures/imageindex.rst | 48 + .../gfortran/intrinsic-procedures/index.rst | 72 + .../doc/gfortran/intrinsic-procedures/int.rst | 76 + .../gfortran/intrinsic-procedures/int2.rst | 39 + .../gfortran/intrinsic-procedures/int8.rst | 39 + .../introduction-to-intrinsic-procedures.rst | 43 + .../doc/gfortran/intrinsic-procedures/ior.rst | 91 + .../gfortran/intrinsic-procedures/iparity.rst | 62 + .../gfortran/intrinsic-procedures/irand.rst | 48 + .../gfortran/intrinsic-procedures/isatty.rst | 46 + .../intrinsic-procedures/iscontiguous.rst | 52 + .../gfortran/intrinsic-procedures/ishft.rst | 85 + .../gfortran/intrinsic-procedures/ishftc.rst | 91 + .../intrinsic-procedures/isiostatend.rst | 48 + .../intrinsic-procedures/isiostateor.rst | 48 + .../gfortran/intrinsic-procedures/isnan.rst | 45 + .../gfortran/intrinsic-procedures/itime.rst | 50 + .../gfortran/intrinsic-procedures/kill.rst | 51 + .../gfortran/intrinsic-procedures/kind.rst | 46 + .../gfortran/intrinsic-procedures/lbound.rst | 51 + .../intrinsic-procedures/lcobound.rst | 48 + .../gfortran/intrinsic-procedures/leadz.rst | 47 + .../doc/gfortran/intrinsic-procedures/len.rst | 62 + .../gfortran/intrinsic-procedures/lentrim.rst | 43 + .../doc/gfortran/intrinsic-procedures/lge.rst | 63 + .../doc/gfortran/intrinsic-procedures/lgt.rst | 63 + .../gfortran/intrinsic-procedures/link.rst | 45 + .../doc/gfortran/intrinsic-procedures/lle.rst | 63 + .../doc/gfortran/intrinsic-procedures/llt.rst | 63 + .../gfortran/intrinsic-procedures/lnblnk.rst | 39 + .../doc/gfortran/intrinsic-procedures/loc.rst | 44 + .../doc/gfortran/intrinsic-procedures/log.rst | 93 + .../gfortran/intrinsic-procedures/log10.rst | 69 + .../intrinsic-procedures/loggamma.rst | 76 + .../gfortran/intrinsic-procedures/logical.rst | 43 + .../gfortran/intrinsic-procedures/lshift.rst | 48 + .../gfortran/intrinsic-procedures/lstat.rst | 49 + .../gfortran/intrinsic-procedures/ltime.rst | 46 + .../gfortran/intrinsic-procedures/malloc.rst | 66 + .../gfortran/intrinsic-procedures/maskl.rst | 42 + .../gfortran/intrinsic-procedures/maskr.rst | 42 + .../gfortran/intrinsic-procedures/matmul.rst | 44 + .../doc/gfortran/intrinsic-procedures/max.rst | 86 + .../intrinsic-procedures/maxexponent.rst | 45 + .../gfortran/intrinsic-procedures/maxloc.rst | 76 + .../gfortran/intrinsic-procedures/maxval.rst | 58 + .../gfortran/intrinsic-procedures/mclock.rst | 39 + .../gfortran/intrinsic-procedures/mclock8.rst | 39 + .../gfortran/intrinsic-procedures/merge.rst | 41 + .../intrinsic-procedures/mergebits.rst | 44 + .../doc/gfortran/intrinsic-procedures/min.rst | 86 + .../intrinsic-procedures/minexponent.rst | 37 + .../gfortran/intrinsic-procedures/minloc.rst | 76 + .../gfortran/intrinsic-procedures/minval.rst | 58 + .../doc/gfortran/intrinsic-procedures/mod.rst | 118 + .../gfortran/intrinsic-procedures/modulo.rst | 55 + .../intrinsic-procedures/movealloc.rst | 51 + .../gfortran/intrinsic-procedures/mvbits.rst | 95 + .../gfortran/intrinsic-procedures/nearest.rst | 51 + .../gfortran/intrinsic-procedures/newline.rst | 42 + .../gfortran/intrinsic-procedures/nint.rst | 75 + .../gfortran/intrinsic-procedures/norm2.rst | 46 + .../doc/gfortran/intrinsic-procedures/not.rst | 85 + .../gfortran/intrinsic-procedures/null.rst | 41 + .../intrinsic-procedures/numimages.rst | 61 + .../doc/gfortran/intrinsic-procedures/or.rst | 60 + .../gfortran/intrinsic-procedures/pack.rst | 72 + .../gfortran/intrinsic-procedures/parity.rst | 46 + .../gfortran/intrinsic-procedures/perror.rst | 35 + .../gfortran/intrinsic-procedures/popcnt.rst | 48 + .../gfortran/intrinsic-procedures/poppar.rst | 50 + .../intrinsic-procedures/precision.rst | 50 + .../gfortran/intrinsic-procedures/present.rst | 47 + .../gfortran/intrinsic-procedures/product.rst | 56 + .../gfortran/intrinsic-procedures/radix.rst | 44 + .../doc/gfortran/intrinsic-procedures/ran.rst | 27 + .../gfortran/intrinsic-procedures/rand.rst | 51 + .../intrinsic-procedures/randominit.rst | 62 + .../intrinsic-procedures/randomnumber.rst | 42 + .../intrinsic-procedures/randomseed.rst | 62 + .../gfortran/intrinsic-procedures/range.rst | 42 + .../gfortran/intrinsic-procedures/rank.rst | 43 + .../gfortran/intrinsic-procedures/real.rst | 104 + .../gfortran/intrinsic-procedures/rename.rst | 44 + .../gfortran/intrinsic-procedures/repeat.rst | 43 + .../gfortran/intrinsic-procedures/reshape.rst | 62 + .../intrinsic-procedures/rrspacing.rst | 38 + .../gfortran/intrinsic-procedures/rshift.rst | 50 + .../intrinsic-procedures/sametypeas.rst | 41 + .../gfortran/intrinsic-procedures/scale.rst | 45 + .../gfortran/intrinsic-procedures/scan.rst | 57 + .../gfortran/intrinsic-procedures/secnds.rst | 52 + .../gfortran/intrinsic-procedures/second.rst | 40 + .../intrinsic-procedures/selectedcharkind.rst | 56 + .../intrinsic-procedures/selectedintkind.rst | 48 + .../intrinsic-procedures/selectedrealkind.rst | 67 + .../intrinsic-procedures/setexponent.rst | 48 + .../gfortran/intrinsic-procedures/shape.rst | 55 + .../gfortran/intrinsic-procedures/shifta.rst | 46 + .../gfortran/intrinsic-procedures/shiftl.rst | 44 + .../gfortran/intrinsic-procedures/shiftr.rst | 44 + .../gfortran/intrinsic-procedures/sign.rst | 78 + .../gfortran/intrinsic-procedures/signal.rst | 59 + .../doc/gfortran/intrinsic-procedures/sin.rst | 89 + .../gfortran/intrinsic-procedures/sind.rst | 89 + .../gfortran/intrinsic-procedures/sinh.rst | 66 + .../gfortran/intrinsic-procedures/size.rst | 55 + .../gfortran/intrinsic-procedures/sizeof.rst | 58 + .../gfortran/intrinsic-procedures/sleep.rst | 36 + .../gfortran/intrinsic-procedures/spacing.rst | 47 + .../gfortran/intrinsic-procedures/spread.rst | 54 + .../gfortran/intrinsic-procedures/sqrt.rst | 86 + .../gfortran/intrinsic-procedures/srand.rst | 53 + .../gfortran/intrinsic-procedures/stat.rst | 72 + .../intrinsic-procedures/storagesize.rst | 42 + .../doc/gfortran/intrinsic-procedures/sum.rst | 56 + .../gfortran/intrinsic-procedures/symlnk.rst | 46 + .../gfortran/intrinsic-procedures/system.rst | 41 + .../intrinsic-procedures/systemclock.rst | 57 + .../doc/gfortran/intrinsic-procedures/tan.rst | 70 + .../gfortran/intrinsic-procedures/tand.rst | 70 + .../gfortran/intrinsic-procedures/tanh.rst | 72 + .../intrinsic-procedures/thisimage.rst | 75 + .../gfortran/intrinsic-procedures/time.rst | 39 + .../gfortran/intrinsic-procedures/time8.rst | 39 + .../gfortran/intrinsic-procedures/tiny.rst | 36 + .../gfortran/intrinsic-procedures/trailz.rst | 46 + .../intrinsic-procedures/transfer.rst | 55 + .../intrinsic-procedures/transpose.rst | 34 + .../gfortran/intrinsic-procedures/trim.rst | 45 + .../gfortran/intrinsic-procedures/ttynam.rst | 47 + .../gfortran/intrinsic-procedures/ubound.rst | 52 + .../intrinsic-procedures/ucobound.rst | 48 + .../gfortran/intrinsic-procedures/umask.rst | 36 + .../gfortran/intrinsic-procedures/unlink.rst | 41 + .../gfortran/intrinsic-procedures/unpack.rst | 57 + .../gfortran/intrinsic-procedures/verify.rst | 59 + .../doc/gfortran/intrinsic-procedures/xor.rst | 60 + gcc/fortran/doc/gfortran/introduction.rst | 18 + .../gfortran/mixed-language-programming.rst | 37 + ...aming-and-argument-passing-conventions.rst | 178 + .../doc/gfortran/non-fortran-main-program.rst | 251 + gcc/fortran/doc/gfortran/projects.rst | 29 + gcc/fortran/doc/gfortran/runtime.rst | 33 + .../gfortran/runtime/gfortranconvertunit.rst | 97 + .../runtime/gfortranerrorbacktrace.rst | 16 + .../runtime/gfortranformattedbuffersize.rst | 13 + .../runtime/gfortranlistseparator.rst | 21 + .../gfortran/runtime/gfortranoptionalplus.rst | 15 + .../gfortran/runtime/gfortranshowlocus.rst | 14 + .../gfortran/runtime/gfortranstderrunit.rst | 13 + .../gfortran/runtime/gfortranstdinunit.rst | 13 + .../gfortran/runtime/gfortranstdoutunit.rst | 13 + .../runtime/gfortranunbufferedall.rst | 15 + .../gfortranunbufferedpreconnected.rst | 15 + .../runtime/gfortranunformattedbuffersize.rst | 13 + gcc/fortran/doc/gfortran/runtime/tmpdir.rst | 22 + gcc/fortran/doc/gfortran/standards.rst | 130 + .../type-and-enum-abi-documentation.rst | 189 + gcc/go/doc/c-interoperability.rst | 23 + gcc/go/doc/c-type-interoperability.rst | 77 + gcc/go/doc/compiler-directives.rst | 47 + gcc/go/doc/conf.py | 30 + gcc/go/doc/copyright.rst | 24 + gcc/go/doc/function-names.rst | 61 + gcc/go/doc/general-public-license-3.rst | 6 + gcc/go/doc/gnu-free-documentation-license.rst | 6 + gcc/go/doc/import-and-export.rst | 50 + gcc/go/doc/index.rst | 23 + gcc/go/doc/indices-and-tables.rst | 1 + gcc/go/doc/introduction.rst | 8 + gcc/go/doc/invoking-gccgo.rst | 214 + libgomp/doc/amd-radeon-gcn.rst | 57 + libgomp/doc/conf.py | 24 + libgomp/doc/copyright.rst | 25 + libgomp/doc/cuda-streams-usage.rst | 50 + libgomp/doc/enabling-openacc.rst | 24 + libgomp/doc/enabling-openmp.rst | 22 + ...t-invocation-nvidia-cublas-library-api.rst | 52 + .../first-invocation-openacc-library-api.rst | 74 + libgomp/doc/funding.rst | 6 + libgomp/doc/general-public-license-3.rst | 6 + .../doc/gnu-free-documentation-license.rst | 6 + ...us-and-implementation-defined-behavior.rst | 281 + libgomp/doc/index.rst | 35 + libgomp/doc/indices-and-tables.rst | 1 + libgomp/doc/introduction.rst | 25 + .../doc/memory-allocation-with-libmemkind.rst | 23 + libgomp/doc/nvptx.rst | 60 + libgomp/doc/offload-target-specifics.rst | 17 + libgomp/doc/openacc-environment-variables.rst | 23 + .../accdevicenum.rst | 13 + .../accdevicetype.rst | 13 + .../accproflib.rst | 16 + .../gccaccnotify.rst | 12 + libgomp/doc/openacc-introduction.rst | 21 + ...nacc-library-and-environment-variables.rst | 30 + .../doc/openacc-library-interoperability.rst | 17 + libgomp/doc/openacc-profiling-interface.rst | 14 + .../doc/openacc-runtime-library-routines.rst | 74 + .../accasynctest.rst | 36 + .../accasynctestall.rst | 34 + .../accattach.rst | 25 + .../acccopyin.rst | 58 + .../acccopyout.rst | 85 + .../acccreate.rst | 58 + .../accdelete.rst | 85 + .../accdetach.rst | 29 + .../accdeviceptr.rst | 23 + .../accfree.rst | 22 + .../accgetcudastream.rst | 23 + .../accgetcurrentcudacontext.rst | 23 + .../accgetcurrentcudadevice.rst | 23 + .../accgetdevicenum.rst | 34 + .../accgetdevicetype.rst | 36 + .../accgetnumdevices.rst | 31 + .../accgetproperty.rst | 60 + .../acchostptr.rst | 23 + .../accinit.rst | 31 + .../accispresent.rst | 50 + .../accmalloc.rst | 23 + .../accmapdata.rst | 24 + .../accmemcpyfromdevice.rst | 24 + .../accmemcpytodevice.rst | 24 + .../accondevice.rst | 37 + .../accpresentorcopyin.rst | 58 + .../accpresentorcreate.rst | 58 + .../accproflookup.rst | 25 + .../accprofregister.rst | 25 + .../accprofunregister.rst | 25 + .../accregisterlibrary.rst | 25 + .../accsetcudastream.rst | 28 + .../accsetdevicenum.rst | 34 + .../accsetdevicetype.rst | 31 + .../accshutdown.rst | 31 + .../accunmapdata.rst | 23 + .../accupdatedevice.rst | 58 + .../accupdateself.rst | 58 + .../accwait.rst | 37 + .../accwaitall.rst | 32 + .../accwaitallasync.rst | 32 + .../accwaitasync.rst | 31 + libgomp/doc/openmp-context-selectors.rst | 28 + libgomp/doc/openmp-environment-variables.rst | 39 + .../gompcpuaffinity.rst | 37 + .../gompdebug.rst | 18 + .../gomprtemsthreadpools.rst | 46 + .../gompspincount.rst | 30 + .../gompstacksize.rst | 25 + .../ompcancellation.rst | 21 + .../ompdefaultdevice.rst | 24 + .../ompdisplayenv.rst | 21 + .../ompdynamic.rst | 23 + .../ompmaxactivelevels.rst | 26 + .../ompmaxtaskpriority.rst | 25 + .../ompnested.rst | 28 + .../ompnumteams.rst | 23 + .../ompnumthreads.rst | 24 + .../ompplaces.rst | 54 + .../ompprocbind.rst | 34 + .../ompschedule.rst | 24 + .../ompstacksize.rst | 24 + .../omptargetoffload.rst | 27 + .../ompteamsthreadlimit.rst | 24 + .../ompthreadlimit.rst | 22 + .../ompwaitpolicy.rst | 24 + .../doc/openmp-implementation-specifics.rst | 15 + libgomp/doc/openmp-implementation-status.rst | 21 + .../openmp-45.rst | 11 + .../openmp-50.rst | 212 + .../openmp-51.rst | 177 + .../openmp-52.rst | 132 + .../doc/openmp-runtime-library-routines.rst | 87 + .../ompdestroylock.rst | 33 + .../ompdestroynestlock.rst | 33 + .../ompfulfillevent.rst | 36 + .../ompgetactivelevel.rst | 31 + .../ompgetancestorthreadnum.rst | 35 + .../ompgetcancellation.rst | 33 + .../ompgetdefaultdevice.rst | 30 + .../ompgetdevicenum.rst | 33 + .../ompgetdynamic.rst | 37 + .../ompgetinitialdevice.rst | 32 + .../ompgetlevel.rst | 31 + .../ompgetmaxactivelevels.rst | 30 + .../ompgetmaxtaskpriority.rst | 29 + .../ompgetmaxteams.rst | 31 + .../ompgetmaxthreads.rst | 31 + .../ompgetnested.rst | 48 + .../ompgetnumdevices.rst | 27 + .../ompgetnumprocs.rst | 27 + .../ompgetnumteams.rst | 27 + .../ompgetnumthreads.rst | 38 + .../ompgetprocbind.rst | 34 + .../ompgetschedule.rst | 37 + .../ompgetsupportedactivelevels.rst | 31 + .../ompgetteamnum.rst | 27 + .../ompgetteamsize.rst | 36 + .../ompgetteamsthreadlimit.rst | 31 + .../ompgetthreadlimit.rst | 30 + .../ompgetthreadnum.rst | 34 + .../ompgetwtick.rst | 31 + .../ompgetwtime.rst | 33 + .../ompinfinal.rst | 29 + .../ompinitlock.rst | 33 + .../ompinitnestlock.rst | 33 + .../ompinparallel.rst | 29 + .../ompisinitialdevice.rst | 29 + .../ompsetdefaultdevice.rst | 33 + .../ompsetdynamic.rst | 35 + .../ompsetlock.rst | 35 + .../ompsetmaxactivelevels.rst | 35 + .../ompsetnested.rst | 40 + .../ompsetnestlock.rst | 35 + .../ompsetnumteams.rst | 34 + .../ompsetnumthreads.rst | 34 + .../ompsetschedule.rst | 40 + .../ompsetteamsthreadlimit.rst | 35 + .../omptestlock.rst | 36 + .../omptestnestlock.rst | 36 + .../ompunsetlock.rst | 36 + .../ompunsetnestlock.rst | 36 + libgomp/doc/reporting-bugs.rst | 14 + libgomp/doc/the-libgomp-abi.rst | 31 + .../implementing-atomic-construct.rst | 21 + .../implementing-barrier-construct.rst | 13 + .../implementing-critical-construct.rst | 30 + ...private-copyin-and-copyprivate-clauses.rst | 45 + .../implementing-flush-construct.rst | 11 + .../implementing-for-construct.rst | 73 + .../implementing-master-construct.rst | 18 + ...plementing-openaccs-parallel-construct.rst | 13 + .../implementing-ordered-construct.rst | 14 + .../implementing-parallel-construct.rst | 55 + .../implementing-private-clause.rst | 17 + .../implementing-reduction-clause.rst | 15 + .../implementing-sections-construct.rst | 42 + .../implementing-single-construct.rst | 48 + .../implementing-threadprivate-construct.rst | 18 + libiberty/doc/bsd.rst | 6 + libiberty/doc/conf.py | 25 + libiberty/doc/copyright.rst | 13 + libiberty/doc/extensions.rst | 767 +++ .../function-variable-and-macro-listing.rst | 1857 +++++++ libiberty/doc/index.rst | 23 + libiberty/doc/indices-and-tables.rst | 1 + libiberty/doc/introduction.rst | 8 + .../doc/lesser-general-public-license-2.1.rst | 6 + libiberty/doc/overview.rst | 20 + libiberty/doc/replacement-functions.rst | 62 + libiberty/doc/supplemental-functions.rst | 31 + libiberty/doc/using.rst | 40 + .../doc/c-c++-language-constructs-for-tm.rst | 39 + libitm/doc/conf.py | 24 + libitm/doc/copyright.rst | 13 + libitm/doc/enabling-libitm.rst | 13 + libitm/doc/gnu-free-documentation-license.rst | 6 + libitm/doc/index.rst | 27 + libitm/doc/indices-and-tables.rst | 1 + libitm/doc/internals.rst | 16 + libitm/doc/locking-conventions.rst | 261 + libitm/doc/nesting-flat-vs-closed.rst | 28 + libitm/doc/the-libitm-abi.rst | 27 + libitm/doc/the-libitm-abi/function-list.rst | 272 + .../future-enhancements-to-the-abi.rst | 7 + .../library-design-principles.rst | 61 + libitm/doc/the-libitm-abi/memory-model.rst | 18 + libitm/doc/the-libitm-abi/non-objectives.rst | 7 + libitm/doc/the-libitm-abi/objectives.rst | 7 + libitm/doc/the-libitm-abi/sample-code.rst | 10 + .../the-libitm-abi/types-and-macros-list.rst | 10 + libitm/doc/tm-methods-and-method-groups.rst | 47 + libquadmath/doc/conf.py | 24 + libquadmath/doc/copyright.rst | 18 + .../doc/gnu-free-documentation-license.rst | 6 + libquadmath/doc/i-o-library-routines.rst | 15 + libquadmath/doc/index.rst | 23 + libquadmath/doc/indices-and-tables.rst | 1 + libquadmath/doc/introduction.rst | 7 + libquadmath/doc/math-library-routines.rst | 104 + libquadmath/doc/quadmathsnprintf.rst | 74 + libquadmath/doc/reporting-bugs.rst | 12 + libquadmath/doc/strtoflt128.rst | 40 + libquadmath/doc/typedef-and-constants.rst | 43 + 1335 files changed, 176984 insertions(+) create mode 100644 doc/Makefile create mode 100644 doc/_static/custom.css create mode 100644 doc/baseconf.py create mode 100644 doc/bsd.rst create mode 100644 doc/contrib.rst create mode 100644 doc/contribute.rst create mode 100644 doc/cppdiropts.rst create mode 100644 doc/cppenv.rst create mode 100644 doc/cppopts.rst create mode 100644 doc/cppwarnopts.rst create mode 100644 doc/favicon.ico create mode 100644 doc/funding.rst create mode 100644 doc/gcc_sphinx.py create mode 100644 doc/gnu.rst create mode 100644 doc/gnu_free_documentation_license.rst create mode 100644 doc/gpl-3.0.rst create mode 100644 doc/indices-and-tables.rst create mode 100644 doc/lgpl-2.1.rst create mode 100644 doc/logo.pdf create mode 100644 doc/logo.svg create mode 100644 doc/md.rst create mode 100644 doc/requirements.txt create mode 100644 gcc/d/doc/conf.py create mode 100644 gcc/d/doc/copyright.rst create mode 100644 gcc/d/doc/general-public-license-3.rst create mode 100644 gcc/d/doc/gnu-free-documentation-license.rst create mode 100644 gcc/d/doc/index.rst create mode 100644 gcc/d/doc/indices-and-tables.rst create mode 100644 gcc/d/doc/invoking-gdc.rst create mode 100644 gcc/d/doc/invoking-gdc/code-generation.rst create mode 100644 gcc/d/doc/invoking-gdc/developer-options.rst create mode 100644 gcc/d/doc/invoking-gdc/input-and-output-files.rst create mode 100644 gcc/d/doc/invoking-gdc/options-for-directory-search.rst create mode 100644 gcc/d/doc/invoking-gdc/options-for-linking.rst create mode 100644 gcc/d/doc/invoking-gdc/runtime-options.rst create mode 100644 gcc/d/doc/invoking-gdc/warnings.rst create mode 100644 gcc/doc/cpp/character-sets.rst create mode 100644 gcc/doc/cpp/conditional-syntax.rst create mode 100644 gcc/doc/cpp/conditional-uses.rst create mode 100644 gcc/doc/cpp/conditionals.rst create mode 100644 gcc/doc/cpp/conf.py create mode 100644 gcc/doc/cpp/copyright.rst create mode 100644 gcc/doc/cpp/deleted-code.rst create mode 100644 gcc/doc/cpp/diagnostics.rst create mode 100644 gcc/doc/cpp/environment-variables.rst create mode 100644 gcc/doc/cpp/gnu-free-documentation-license.rst create mode 100644 gcc/doc/cpp/header-files.rst create mode 100644 gcc/doc/cpp/header-files/alternatives-to-wrapper-ifndef.rst create mode 100644 gcc/doc/cpp/header-files/computed-includes.rst create mode 100644 gcc/doc/cpp/header-files/include-operation.rst create mode 100644 gcc/doc/cpp/header-files/include-syntax.rst create mode 100644 gcc/doc/cpp/header-files/once-only-headers.rst create mode 100644 gcc/doc/cpp/header-files/search-path.rst create mode 100644 gcc/doc/cpp/header-files/system-headers.rst create mode 100644 gcc/doc/cpp/header-files/wrapper-headers.rst create mode 100644 gcc/doc/cpp/implementation-defined-behavior.rst create mode 100644 gcc/doc/cpp/implementation-details.rst create mode 100644 gcc/doc/cpp/implementation-limits.rst create mode 100644 gcc/doc/cpp/index.rst create mode 100644 gcc/doc/cpp/indices-and-tables.rst create mode 100644 gcc/doc/cpp/initial-processing.rst create mode 100644 gcc/doc/cpp/invocation.rst create mode 100644 gcc/doc/cpp/line-control.rst create mode 100644 gcc/doc/cpp/macros.rst create mode 100644 gcc/doc/cpp/macros/concatenation.rst create mode 100644 gcc/doc/cpp/macros/directives-within-macro-arguments.rst create mode 100644 gcc/doc/cpp/macros/function-like-macros.rst create mode 100644 gcc/doc/cpp/macros/macro-arguments.rst create mode 100644 gcc/doc/cpp/macros/macro-pitfalls.rst create mode 100644 gcc/doc/cpp/macros/object-like-macros.rst create mode 100644 gcc/doc/cpp/macros/predefined-macros.rst create mode 100644 gcc/doc/cpp/macros/stringizing.rst create mode 100644 gcc/doc/cpp/macros/undefining-and-redefining-macros.rst create mode 100644 gcc/doc/cpp/macros/variadic-macros.rst create mode 100644 gcc/doc/cpp/obsolete-features.rst create mode 100644 gcc/doc/cpp/other-directives.rst create mode 100644 gcc/doc/cpp/overview.rst create mode 100644 gcc/doc/cpp/pragmas.rst create mode 100644 gcc/doc/cpp/preprocessor-output.rst create mode 100644 gcc/doc/cpp/the-preprocessing-language.rst create mode 100644 gcc/doc/cpp/tokenization.rst create mode 100644 gcc/doc/cpp/traditional-lexical-analysis.rst create mode 100644 gcc/doc/cpp/traditional-macros.rst create mode 100644 gcc/doc/cpp/traditional-miscellany.rst create mode 100644 gcc/doc/cpp/traditional-mode.rst create mode 100644 gcc/doc/cpp/traditional-warnings.rst create mode 100644 gcc/doc/cppinternals/conf.py create mode 100644 gcc/doc/cppinternals/copyright.rst create mode 100644 gcc/doc/cppinternals/cppinternals.rst create mode 100644 gcc/doc/cppinternals/cpplib.rst create mode 100644 gcc/doc/cppinternals/files.rst create mode 100644 gcc/doc/cppinternals/index.rst create mode 100644 gcc/doc/cppinternals/indices-and-tables.rst create mode 100644 gcc/doc/cppinternals/internal-representation-of-macros.rst create mode 100644 gcc/doc/cppinternals/just-which-line-number-anyway.rst create mode 100644 gcc/doc/cppinternals/lexing-a-line.rst create mode 100644 gcc/doc/cppinternals/lexing-a-token.rst create mode 100644 gcc/doc/cppinternals/looking-for-a-function-like-macros-opening-parenthesis.rst create mode 100644 gcc/doc/cppinternals/macro-expansion-overview.rst create mode 100644 gcc/doc/cppinternals/marking-tokens-ineligible-for-future-expansion.rst create mode 100644 gcc/doc/cppinternals/multiple-include-optimization.rst create mode 100644 gcc/doc/cppinternals/overview.rst create mode 100644 gcc/doc/cppinternals/representation-of-line-numbers.rst create mode 100644 gcc/doc/cppinternals/scanning-the-replacement-list-for-macros-to-expand.rst create mode 100644 gcc/doc/gcc/binary-compatibility.rst create mode 100644 gcc/doc/gcc/c++-implementation-defined-behavior.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/architecture.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/arrays-and-pointers.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/characters.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/declarators.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/environment.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/floating-point.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/hints.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/identifiers.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/integers.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/library-functions.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/locale-specific-behavior.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/preprocessing-directives.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/qualifiers.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/statements.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/structures-unions-enumerations-and-bit-fields.rst create mode 100644 gcc/doc/gcc/c-implementation-defined-behavior/translation.rst create mode 100644 gcc/doc/gcc/conditionally-supported-behavior.rst create mode 100644 gcc/doc/gcc/conf.py create mode 100644 gcc/doc/gcc/contributing-to-gcc-development.rst create mode 100644 gcc/doc/gcc/contributors-to-gcc.rst create mode 100644 gcc/doc/gcc/copyright.rst create mode 100644 gcc/doc/gcc/exception-handling.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language/backwards-compatibility.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language/c++-concepts.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language/c++-interface-and-implementation-pragmas.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language/c++-specific-variable-function-and-type-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language/deprecated-features.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language/extracting-the-function-pointer-from-a-bound-pointer-to-member-function.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language/function-multiversioning.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language/restricting-pointer-aliasing.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language/type-traits.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language/vague-linkage.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language/when-is-a-volatile-c++-object-accessed.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c++-language/wheres-the-template.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/128-bit-integers.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/additional-floating-types.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/alternate-keywords.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/an-inline-function-is-as-fast-as-a-macro.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/arithmetic-on-void-and-function-pointers.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/arrays-of-length-zero.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/arrays-of-variable-length.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/attribute-syntax.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/binary-constants-using-the-0b-prefix.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/built-in-functions-for-memory-model-aware-atomic-operations.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/built-in-functions-to-perform-arithmetic-with-overflow-checking.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/c++-style-comments.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/case-ranges.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/cast-to-a-union-type.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/complex-numbers.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/compound-literals.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/conditionals-with-omitted-operands.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/constructing-function-calls.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/decimal-floating-types.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/aarch64-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/amd-gcn-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/arc-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/arm-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/avr-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/blackfin-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/bpf-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/c-sky-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/common-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/epiphany-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/h8-300-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/ia-64-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m32c-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m32r-d-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m68k-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mcore-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mep-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/microblaze-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/microsoft-windows-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mips-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/msp430-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nds32-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nios-ii-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nvidia-ptx-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/powerpc-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/risc-v-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/rl78-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/rx-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/s-390-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/sh-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/symbian-os-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/v850-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/visium-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/x86-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/xstormy16-function-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/designated-initializers.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/determining-the-alignment-of-functions-types-or-variables.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/dollar-signs-in-identifier-names.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/double-word-integers.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/enumerator-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/fixed-point-types.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/format-checks-specific-to-particular-target-machines.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/function-names-as-strings.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/getting-the-return-or-frame-address-of-a-function.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/half-precision-floating-point.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/hex-floats.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/how-to-use-inline-assembly-language-in-c-code.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/incomplete-enum-types.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/label-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/labels-as-values.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/legacy-sync-built-in-functions-for-atomic-memory-access.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/locally-declared-labels.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/macros-with-a-variable-number-of-arguments.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/mixed-declarations-labels-and-code.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/named-address-spaces.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/nested-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/non-constant-initializers.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/non-lvalue-arrays-may-have-subscripts.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/nonlocal-gotos.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/object-size-checking-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/other-built-in-functions-provided-by-gcc.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/pointer-arguments-in-variadic-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/pointers-to-arrays-with-qualifiers-work-as-expected.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/pragmas-accepted-by-gcc.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/prototypes-and-old-style-function-definitions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/referring-to-a-type-with-typeof.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/slightly-looser-rules-for-escaped-newlines.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/specifying-attributes-of-types.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/specifying-attributes-of-variables.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/statement-attributes.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/statements-and-declarations-in-expressions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/structures-with-no-members.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/support-for-offsetof.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/aarch64-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/alpha-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/altera-nios-ii-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arc-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arc-simd-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-armv8-m-security-extensions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-c-language-extensions-acle.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-floating-point-status-and-control-intrinsics.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-iwmmxt-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/avr-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/basic-powerpc-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/blackfin-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/bpf-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/fr-v-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-dsp-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-loongson-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-paired-single-support.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-simd-architecture-msa-support.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/msp430-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/nds32-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/other-mips-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/picochip-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-altivec-vsx-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-atomic-memory-operation-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-hardware-transactional-memory-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-matrix-multiply-assist-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/pru-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/risc-v-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/rx-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/s-390-system-z-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/sh-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/sparc-vis-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/ti-c6x-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-control-flow-protection-intrinsics.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-transactional-memory-intrinsics.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/the-character-esc-in-constants.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/thread-local-storage.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/unnamed-structure-and-union-fields.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/using-vector-instructions-through-built-in-functions.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/when-is-a-volatile-object-accessed.rst create mode 100644 gcc/doc/gcc/extensions-to-the-c-language-family/x86-specific-memory-model-extensions-for-transactional-memory.rst create mode 100644 gcc/doc/gcc/funding.rst create mode 100644 gcc/doc/gcc/gcc-command-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/c++-modules.rst create mode 100644 gcc/doc/gcc/gcc-command-options/compiling-c++-programs.rst create mode 100644 gcc/doc/gcc/gcc-command-options/description.rst create mode 100644 gcc/doc/gcc/gcc-command-options/environment-variables-affecting-gcc.rst create mode 100644 gcc/doc/gcc/gcc-command-options/gcc-developer-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/aarch64-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/adapteva-epiphany-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/amd-gcn-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/arc-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/arm-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/avr-mmcu.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/avr-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/blackfin-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/c-sky-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/c6x-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/cris-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/darwin-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/dec-alpha-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/ebpf-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/fr30-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/frv-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/ft32-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/gnu-linux-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/h8-300-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/hppa-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/ia-64-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/ibm-rs-6000-and-powerpc-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/lm32-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/loongarch-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/m32c-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/m32r-d-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/m680x0-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/mcore-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/mep-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/microblaze-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/mips-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/mmix-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/mn10300-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/moxie-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/msp430-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/nds32-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/nios-ii-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/nvidia-ptx-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/openrisc-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/options-for-system-v.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/pdp-11-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/picochip-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/powerpc-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/pru-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/risc-v-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/rl78-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/rx-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/s-390-and-zseries-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/score-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/sh-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/solaris-2-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/sparc-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/v850-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/vax-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/visium-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/vms-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/vxworks-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/x86-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/x86-windows-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/xstormy16-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/xtensa-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/machine-dependent-options/zseries-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/option-summary.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-controlling-c++-dialect.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-controlling-c-dialect.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-controlling-objective-c-and-objective-c++-dialects.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-controlling-the-kind-of-output.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-controlling-the-preprocessor.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-for-code-generation-conventions.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-for-debugging-your-program.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-for-directory-search.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-for-linking.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-that-control-optimization.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-that-control-static-analysis.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-to-control-diagnostic-messages-formatting.rst create mode 100644 gcc/doc/gcc/gcc-command-options/options-to-request-or-suppress-warnings.rst create mode 100644 gcc/doc/gcc/gcc-command-options/passing-options-to-the-assembler.rst create mode 100644 gcc/doc/gcc/gcc-command-options/program-instrumentation-options.rst create mode 100644 gcc/doc/gcc/gcc-command-options/specifying-subprocesses-and-the-switches-to-pass-to-them.rst create mode 100644 gcc/doc/gcc/gcc-command-options/using-precompiled-headers.rst create mode 100644 gcc/doc/gcc/gcc.rst create mode 100644 gcc/doc/gcc/gcov-dump.rst create mode 100644 gcc/doc/gcc/gcov-tool.rst create mode 100644 gcc/doc/gcc/gcov.rst create mode 100644 gcc/doc/gcc/gcov/brief-description-of-gcov-data-files.rst create mode 100644 gcc/doc/gcc/gcov/data-file-relocation-to-support-cross-profiling.rst create mode 100644 gcc/doc/gcc/gcov/introduction-to-gcov.rst create mode 100644 gcc/doc/gcc/gcov/invoking-gcov.rst create mode 100644 gcc/doc/gcc/gcov/profiling-and-test-coverage-in-freestanding-environments.rst create mode 100644 gcc/doc/gcc/gcov/using-gcov-with-gcc-optimization.rst create mode 100644 gcc/doc/gcc/general-public-license-3.rst create mode 100644 gcc/doc/gcc/gnu-free-documentation-license.rst create mode 100644 gcc/doc/gcc/gnu-objective-c-features.rst create mode 100644 gcc/doc/gcc/gnu-objective-c-features/compatibilityalias.rst create mode 100644 gcc/doc/gcc/gnu-objective-c-features/constant-string-objects.rst create mode 100644 gcc/doc/gcc/gnu-objective-c-features/exceptions.rst create mode 100644 gcc/doc/gcc/gnu-objective-c-features/fast-enumeration.rst create mode 100644 gcc/doc/gcc/gnu-objective-c-features/garbage-collection.rst create mode 100644 gcc/doc/gcc/gnu-objective-c-features/gnu-objective-c-runtime-api.rst create mode 100644 gcc/doc/gcc/gnu-objective-c-features/load-executing-code-before-main.rst create mode 100644 gcc/doc/gcc/gnu-objective-c-features/messaging-with-the-gnu-objective-c-runtime.rst create mode 100644 gcc/doc/gcc/gnu-objective-c-features/synchronization.rst create mode 100644 gcc/doc/gcc/gnu-objective-c-features/type-encoding.rst create mode 100644 gcc/doc/gcc/gnu.rst create mode 100644 gcc/doc/gcc/have-you-found-a-bug.rst create mode 100644 gcc/doc/gcc/how-and-where-to-report-bugs.rst create mode 100644 gcc/doc/gcc/how-to-get-help-with-gcc.rst create mode 100644 gcc/doc/gcc/index.rst create mode 100644 gcc/doc/gcc/indices-and-tables.rst create mode 100644 gcc/doc/gcc/known-causes-of-trouble-with-gcc.rst create mode 100644 gcc/doc/gcc/known-causes-of-trouble-with-gcc/actual-bugs-we-havent-fixed-yet.rst create mode 100644 gcc/doc/gcc/known-causes-of-trouble-with-gcc/certain-changes-we-dont-want-to-make.rst create mode 100644 gcc/doc/gcc/known-causes-of-trouble-with-gcc/common-misunderstandings-with-gnu-c.rst create mode 100644 gcc/doc/gcc/known-causes-of-trouble-with-gcc/disappointments-and-misunderstandings.rst create mode 100644 gcc/doc/gcc/known-causes-of-trouble-with-gcc/fixed-header-files.rst create mode 100644 gcc/doc/gcc/known-causes-of-trouble-with-gcc/incompatibilities-of-gcc.rst create mode 100644 gcc/doc/gcc/known-causes-of-trouble-with-gcc/interoperation.rst create mode 100644 gcc/doc/gcc/known-causes-of-trouble-with-gcc/standard-libraries.rst create mode 100644 gcc/doc/gcc/known-causes-of-trouble-with-gcc/warning-messages-and-error-messages.rst create mode 100644 gcc/doc/gcc/language-standards-supported-by-gcc.rst create mode 100644 gcc/doc/gcc/language-standards-supported-by-gcc/c++-language.rst create mode 100644 gcc/doc/gcc/language-standards-supported-by-gcc/c-language.rst create mode 100644 gcc/doc/gcc/language-standards-supported-by-gcc/d-language.rst create mode 100644 gcc/doc/gcc/language-standards-supported-by-gcc/go-language.rst create mode 100644 gcc/doc/gcc/language-standards-supported-by-gcc/objective-c-and-objective-c++-languages.rst create mode 100644 gcc/doc/gcc/language-standards-supported-by-gcc/references-for-other-languages.rst create mode 100644 gcc/doc/gcc/lto-dump.rst create mode 100644 gcc/doc/gcc/programming-languages-supported-by-gcc.rst create mode 100644 gcc/doc/gcc/reporting-bugs.rst create mode 100644 gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples.rst create mode 100644 gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/alias-analysis.rst create mode 100644 gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/annotations.rst create mode 100644 gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/memory-model.rst create mode 100644 gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/ssa-operands.rst create mode 100644 gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/static-single-assignment.rst create mode 100644 gcc/doc/gccint/analysis-and-representation-of-loops.rst create mode 100644 gcc/doc/gccint/analysis-and-representation-of-loops/data-dependency-analysis.rst create mode 100644 gcc/doc/gccint/analysis-and-representation-of-loops/iv-analysis-on-rtl.rst create mode 100644 gcc/doc/gccint/analysis-and-representation-of-loops/loop-closed-ssa-form.rst create mode 100644 gcc/doc/gccint/analysis-and-representation-of-loops/loop-manipulation.rst create mode 100644 gcc/doc/gccint/analysis-and-representation-of-loops/loop-querying.rst create mode 100644 gcc/doc/gccint/analysis-and-representation-of-loops/loop-representation.rst create mode 100644 gcc/doc/gccint/analysis-and-representation-of-loops/number-of-iterations-analysis.rst create mode 100644 gcc/doc/gccint/analysis-and-representation-of-loops/scalar-evolutions.rst create mode 100644 gcc/doc/gccint/analyzer-internals.rst create mode 100644 gcc/doc/gccint/collect2.rst create mode 100644 gcc/doc/gccint/conf.py create mode 100644 gcc/doc/gccint/contributing-to-gcc-development.rst create mode 100644 gcc/doc/gccint/contributors-to-gcc.rst create mode 100644 gcc/doc/gccint/control-flow-graph.rst create mode 100644 gcc/doc/gccint/control-flow-graph/basic-blocks.rst create mode 100644 gcc/doc/gccint/control-flow-graph/edges.rst create mode 100644 gcc/doc/gccint/control-flow-graph/liveness-information.rst create mode 100644 gcc/doc/gccint/control-flow-graph/maintaining-the-cfg.rst create mode 100644 gcc/doc/gccint/control-flow-graph/profile-information.rst create mode 100644 gcc/doc/gccint/copyright.rst create mode 100644 gcc/doc/gccint/debugging-the-analyzer.rst create mode 100644 gcc/doc/gccint/funding.rst create mode 100644 gcc/doc/gccint/gcc-and-portability.rst create mode 100644 gcc/doc/gccint/general-public-license-3.rst create mode 100644 gcc/doc/gccint/generic.rst create mode 100644 gcc/doc/gccint/generic/attributes-in-trees.rst create mode 100644 gcc/doc/gccint/generic/c-and-c++-trees.rst create mode 100644 gcc/doc/gccint/generic/declarations.rst create mode 100644 gcc/doc/gccint/generic/deficiencies.rst create mode 100644 gcc/doc/gccint/generic/expressions.rst create mode 100644 gcc/doc/gccint/generic/functions.rst create mode 100644 gcc/doc/gccint/generic/language-dependent-trees.rst create mode 100644 gcc/doc/gccint/generic/overview.rst create mode 100644 gcc/doc/gccint/generic/statements.rst create mode 100644 gcc/doc/gccint/generic/types.rst create mode 100644 gcc/doc/gccint/gimple-api.rst create mode 100644 gcc/doc/gccint/gimple.rst create mode 100644 gcc/doc/gccint/gimple/adding-a-new-gimple-statement-code.rst create mode 100644 gcc/doc/gccint/gimple/class-hierarchy-of-gimple-statements.rst create mode 100644 gcc/doc/gccint/gimple/exception-handling.rst create mode 100644 gcc/doc/gccint/gimple/gimple-instruction-set.rst create mode 100644 gcc/doc/gccint/gimple/gimple-sequences.rst create mode 100644 gcc/doc/gccint/gimple/manipulating-gimple-statements.rst create mode 100644 gcc/doc/gccint/gimple/operands.rst create mode 100644 gcc/doc/gccint/gimple/sequence-iterators.rst create mode 100644 gcc/doc/gccint/gimple/statement-and-operand-traversals.rst create mode 100644 gcc/doc/gccint/gimple/temporaries.rst create mode 100644 gcc/doc/gccint/gimple/tuple-representation.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleasm.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleassign.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimplebind.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimplecall.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimplecatch.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimplecond.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpledebug.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleehfilter.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimplegoto.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimplelabel.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimplenop.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompatomicload.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompatomicstore.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompcontinue.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompcritical.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompfor.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompmaster.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompordered.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompparallel.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompreturn.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompsection.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompsections.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompsingle.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimplephi.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleresx.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimplereturn.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleswitch.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimpletry.rst create mode 100644 gcc/doc/gccint/gimple/tuple-specific-accessors/gimplewithcleanupexpr.rst create mode 100644 gcc/doc/gccint/gnu-free-documentation-license.rst create mode 100644 gcc/doc/gccint/guidelines-for-diagnostics.rst create mode 100644 gcc/doc/gccint/guidelines-for-options.rst create mode 100644 gcc/doc/gccint/host-common.rst create mode 100644 gcc/doc/gccint/host-configuration.rst create mode 100644 gcc/doc/gccint/host-filesystem.rst create mode 100644 gcc/doc/gccint/host-makefile-fragments.rst create mode 100644 gcc/doc/gccint/host-misc.rst create mode 100644 gcc/doc/gccint/index.rst create mode 100644 gcc/doc/gccint/indices-and-tables.rst create mode 100644 gcc/doc/gccint/interfacing-to-gcc-output.rst create mode 100644 gcc/doc/gccint/introduction.rst create mode 100644 gcc/doc/gccint/language-front-ends-in-gcc.rst create mode 100644 gcc/doc/gccint/link-time-optimization.rst create mode 100644 gcc/doc/gccint/link-time-optimization/design-overview.rst create mode 100644 gcc/doc/gccint/link-time-optimization/internal-flags-controlling-lto1.rst create mode 100644 gcc/doc/gccint/link-time-optimization/lto-file-sections.rst create mode 100644 gcc/doc/gccint/link-time-optimization/using-summary-information-in-ipa-passes.rst create mode 100644 gcc/doc/gccint/link-time-optimization/whole-program-assumptions-linker-plugin-and-symbol-visibilities.rst create mode 100644 gcc/doc/gccint/machine-descriptions.rst create mode 100644 gcc/doc/gccint/machine-descriptions/c-statements-for-assembler-output.rst create mode 100644 gcc/doc/gccint/machine-descriptions/canonicalization-of-instructions.rst create mode 100644 gcc/doc/gccint/machine-descriptions/conditional-execution.rst create mode 100644 gcc/doc/gccint/machine-descriptions/constant-definitions.rst create mode 100644 gcc/doc/gccint/machine-descriptions/defining-how-to-split-instructions.rst create mode 100644 gcc/doc/gccint/machine-descriptions/defining-jump-instruction-patterns.rst create mode 100644 gcc/doc/gccint/machine-descriptions/defining-looping-instruction-patterns.rst create mode 100644 gcc/doc/gccint/machine-descriptions/defining-rtl-sequences-for-code-generation.rst create mode 100644 gcc/doc/gccint/machine-descriptions/everything-about-instruction-patterns.rst create mode 100644 gcc/doc/gccint/machine-descriptions/example-of-defineinsn.rst create mode 100644 gcc/doc/gccint/machine-descriptions/including-patterns-in-machine-descriptions.rst create mode 100644 gcc/doc/gccint/machine-descriptions/instruction-attributes.rst create mode 100644 gcc/doc/gccint/machine-descriptions/interdependence-of-patterns.rst create mode 100644 gcc/doc/gccint/machine-descriptions/iterators.rst create mode 100644 gcc/doc/gccint/machine-descriptions/machine-specific-peephole-optimizers.rst create mode 100644 gcc/doc/gccint/machine-descriptions/operand-constraints.rst create mode 100644 gcc/doc/gccint/machine-descriptions/output-templates-and-operand-substitution.rst create mode 100644 gcc/doc/gccint/machine-descriptions/overview-of-how-the-machine-description-is-used.rst create mode 100644 gcc/doc/gccint/machine-descriptions/predicates.rst create mode 100644 gcc/doc/gccint/machine-descriptions/rtl-template.rst create mode 100644 gcc/doc/gccint/machine-descriptions/rtl-templates-transformations.rst create mode 100644 gcc/doc/gccint/machine-descriptions/standard-pattern-names-for-generation.rst create mode 100644 gcc/doc/gccint/machine-descriptions/when-the-order-of-patterns-matters.rst create mode 100644 gcc/doc/gccint/makefile-fragments.rst create mode 100644 gcc/doc/gccint/match-and-simplify.rst create mode 100644 gcc/doc/gccint/memory-management-and-type-information.rst create mode 100644 gcc/doc/gccint/memory-management-and-type-information/how-to-invoke-the-garbage-collector.rst create mode 100644 gcc/doc/gccint/memory-management-and-type-information/marking-roots-for-the-garbage-collector.rst create mode 100644 gcc/doc/gccint/memory-management-and-type-information/source-files-containing-type-information.rst create mode 100644 gcc/doc/gccint/memory-management-and-type-information/support-for-inheritance.rst create mode 100644 gcc/doc/gccint/memory-management-and-type-information/support-for-user-provided-gc-marking-routines.rst create mode 100644 gcc/doc/gccint/memory-management-and-type-information/the-inside-of-a-gty.rst create mode 100644 gcc/doc/gccint/memory-management-and-type-information/troubleshooting-the-garbage-collector.rst create mode 100644 gcc/doc/gccint/option-file-format.rst create mode 100644 gcc/doc/gccint/option-properties.rst create mode 100644 gcc/doc/gccint/option-specification-files.rst create mode 100644 gcc/doc/gccint/passes-and-files-of-the-compiler.rst create mode 100644 gcc/doc/gccint/passes-and-files-of-the-compiler/gimplification-pass.rst create mode 100644 gcc/doc/gccint/passes-and-files-of-the-compiler/inter-procedural-optimization-passes.rst create mode 100644 gcc/doc/gccint/passes-and-files-of-the-compiler/optimization-info.rst create mode 100644 gcc/doc/gccint/passes-and-files-of-the-compiler/parsing-pass.rst create mode 100644 gcc/doc/gccint/passes-and-files-of-the-compiler/pass-manager.rst create mode 100644 gcc/doc/gccint/passes-and-files-of-the-compiler/rtl-passes.rst create mode 100644 gcc/doc/gccint/passes-and-files-of-the-compiler/tree-ssa-passes.rst create mode 100644 gcc/doc/gccint/plugins.rst create mode 100644 gcc/doc/gccint/plugins/building-gcc-plugins.rst create mode 100644 gcc/doc/gccint/plugins/controlling-which-passes-are-being-run.rst create mode 100644 gcc/doc/gccint/plugins/giving-information-about-a-plugin.rst create mode 100644 gcc/doc/gccint/plugins/interacting-with-the-gcc-garbage-collector.rst create mode 100644 gcc/doc/gccint/plugins/interacting-with-the-pass-manager.rst create mode 100644 gcc/doc/gccint/plugins/keeping-track-of-available-passes.rst create mode 100644 gcc/doc/gccint/plugins/loading-plugins.rst create mode 100644 gcc/doc/gccint/plugins/plugin-api.rst create mode 100644 gcc/doc/gccint/plugins/recording-information-about-pass-execution.rst create mode 100644 gcc/doc/gccint/plugins/registering-custom-attributes-or-pragmas.rst create mode 100644 gcc/doc/gccint/rtl-representation.rst create mode 100644 gcc/doc/gccint/rtl-representation/access-to-operands.rst create mode 100644 gcc/doc/gccint/rtl-representation/access-to-special-operands.rst create mode 100644 gcc/doc/gccint/rtl-representation/assembler-instructions-as-expressions.rst create mode 100644 gcc/doc/gccint/rtl-representation/bit-fields.rst create mode 100644 gcc/doc/gccint/rtl-representation/comparison-operations.rst create mode 100644 gcc/doc/gccint/rtl-representation/constant-expression-types.rst create mode 100644 gcc/doc/gccint/rtl-representation/conversions.rst create mode 100644 gcc/doc/gccint/rtl-representation/declarations.rst create mode 100644 gcc/doc/gccint/rtl-representation/embedded-side-effects-on-addresses.rst create mode 100644 gcc/doc/gccint/rtl-representation/flags-in-an-rtl-expression.rst create mode 100644 gcc/doc/gccint/rtl-representation/insns.rst create mode 100644 gcc/doc/gccint/rtl-representation/machine-modes.rst create mode 100644 gcc/doc/gccint/rtl-representation/on-the-side-ssa-form-for-rtl.rst create mode 100644 gcc/doc/gccint/rtl-representation/reading-rtl.rst create mode 100644 gcc/doc/gccint/rtl-representation/registers-and-memory.rst create mode 100644 gcc/doc/gccint/rtl-representation/rtl-classes-and-formats.rst create mode 100644 gcc/doc/gccint/rtl-representation/rtl-expressions-for-arithmetic.rst create mode 100644 gcc/doc/gccint/rtl-representation/rtl-object-types.rst create mode 100644 gcc/doc/gccint/rtl-representation/rtl-representation-of-function-call-insns.rst create mode 100644 gcc/doc/gccint/rtl-representation/side-effect-expressions.rst create mode 100644 gcc/doc/gccint/rtl-representation/structure-sharing-assumptions.rst create mode 100644 gcc/doc/gccint/rtl-representation/variable-location-debug-information-in-rtl.rst create mode 100644 gcc/doc/gccint/rtl-representation/vector-operations.rst create mode 100644 gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants.rst create mode 100644 gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/alignment-of-polyints.rst create mode 100644 gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/arithmetic-on-polyints.rst create mode 100644 gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/comparisons-involving-polyint.rst create mode 100644 gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/computing-bounds-on-polyints.rst create mode 100644 gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/consequences-of-using-polyint.rst create mode 100644 gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/converting-polyints.rst create mode 100644 gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/guidelines-for-using-polyint.rst create mode 100644 gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/miscellaneous-polyint-routines.rst create mode 100644 gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/overview-of-polyint.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system/configure-terms-and-history.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/anatomy-of-a-language-front-end.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/anatomy-of-a-target-back-end.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/build-system-in-the-gcc-directory.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/building-documentation.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/configuration-in-the-gcc-directory.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/headers-installed-by-gcc.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/library-source-files-and-headers-under-the-gcc-directory.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/makefile-targets.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/subdirectories-of-gcc.rst create mode 100644 gcc/doc/gccint/source-tree-structure-and-build-system/top-level-source-directory.rst create mode 100644 gcc/doc/gccint/standard-header-file-directories.rst create mode 100644 gcc/doc/gccint/static-analyzer.rst create mode 100644 gcc/doc/gccint/target-macros.rst create mode 100644 gcc/doc/gccint/target-macros/adding-support-for-named-address-spaces.rst create mode 100644 gcc/doc/gccint/target-macros/addressing-modes.rst create mode 100644 gcc/doc/gccint/target-macros/adjusting-the-instruction-scheduler.rst create mode 100644 gcc/doc/gccint/target-macros/anchored-addresses.rst create mode 100644 gcc/doc/gccint/target-macros/c++-abi-parameters.rst create mode 100644 gcc/doc/gccint/target-macros/condition-code-status.rst create mode 100644 gcc/doc/gccint/target-macros/controlling-debugging-information-format.rst create mode 100644 gcc/doc/gccint/target-macros/controlling-the-compilation-driver-gcc.rst create mode 100644 gcc/doc/gccint/target-macros/cross-compilation-and-floating-point.rst create mode 100644 gcc/doc/gccint/target-macros/d-abi-parameters.rst create mode 100644 gcc/doc/gccint/target-macros/defining-coprocessor-specifics-for-mips-targets.rst create mode 100644 gcc/doc/gccint/target-macros/defining-data-structures-for-per-function-information.rst create mode 100644 gcc/doc/gccint/target-macros/defining-target-specific-uses-of-attribute.rst create mode 100644 gcc/doc/gccint/target-macros/defining-the-output-assembler-language.rst create mode 100644 gcc/doc/gccint/target-macros/defining-the-output-assembler-language/assembler-commands-for-alignment.rst create mode 100644 gcc/doc/gccint/target-macros/defining-the-output-assembler-language/assembler-commands-for-exception-regions.rst create mode 100644 gcc/doc/gccint/target-macros/defining-the-output-assembler-language/how-initialization-functions-are-handled.rst create mode 100644 gcc/doc/gccint/target-macros/defining-the-output-assembler-language/macros-controlling-initialization-routines.rst create mode 100644 gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-and-generation-of-labels.rst create mode 100644 gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-assembler-instructions.rst create mode 100644 gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-data.rst create mode 100644 gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-dispatch-tables.rst create mode 100644 gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-uninitialized-variables.rst create mode 100644 gcc/doc/gccint/target-macros/defining-the-output-assembler-language/the-overall-framework-of-an-assembler-file.rst create mode 100644 gcc/doc/gccint/target-macros/describing-relative-costs-of-operations.rst create mode 100644 gcc/doc/gccint/target-macros/dividing-the-output-into-sections-texts-data.rst create mode 100644 gcc/doc/gccint/target-macros/emulating-tls.rst create mode 100644 gcc/doc/gccint/target-macros/implementing-the-varargs-macros.rst create mode 100644 gcc/doc/gccint/target-macros/implicit-calls-to-library-routines.rst create mode 100644 gcc/doc/gccint/target-macros/layout-of-source-language-data-types.rst create mode 100644 gcc/doc/gccint/target-macros/miscellaneous-parameters.rst create mode 100644 gcc/doc/gccint/target-macros/mode-switching-instructions.rst create mode 100644 gcc/doc/gccint/target-macros/parameters-for-precompiled-header-validity-checking.rst create mode 100644 gcc/doc/gccint/target-macros/position-independent-code.rst create mode 100644 gcc/doc/gccint/target-macros/register-classes.rst create mode 100644 gcc/doc/gccint/target-macros/register-usage.rst create mode 100644 gcc/doc/gccint/target-macros/run-time-target-specification.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/basic-stack-layout.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/caller-saves-register-allocation.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/eliminating-frame-pointer-and-arg-pointer.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/exception-handling-support.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/function-entry-and-exit.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/generating-code-for-profiling.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/how-large-values-are-returned.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/how-scalar-function-values-are-returned.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/miscellaneous-register-hooks.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/passing-arguments-in-registers.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/passing-function-arguments-on-the-stack.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/permitting-tail-calls.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/registers-that-address-the-stack-frame.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/shrink-wrapping-separate-components.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/specifying-how-stack-checking-is-done.rst create mode 100644 gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/stack-smashing-protection.rst create mode 100644 gcc/doc/gccint/target-macros/storage-layout.rst create mode 100644 gcc/doc/gccint/target-macros/support-for-nested-functions.rst create mode 100644 gcc/doc/gccint/target-macros/the-global-targetm-variable.rst create mode 100644 gcc/doc/gccint/target-makefile-fragments.rst create mode 100644 gcc/doc/gccint/testsuites.rst create mode 100644 gcc/doc/gccint/testsuites/ada-language-testsuites.rst create mode 100644 gcc/doc/gccint/testsuites/c-language-testsuites.rst create mode 100644 gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests.rst create mode 100644 gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/commands-for-use-in-dg-final.rst create mode 100644 gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/features-for-dg-add-options.rst create mode 100644 gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/keywords-describing-target-attributes.rst create mode 100644 gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/selecting-targets-to-which-a-test-applies.rst create mode 100644 gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/syntax-and-descriptions-of-test-directives.rst create mode 100644 gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/variants-of-dg-require-support.rst create mode 100644 gcc/doc/gccint/testsuites/idioms-used-in-testsuite-code.rst create mode 100644 gcc/doc/gccint/testsuites/support-for-testing-binary-compatibility.rst create mode 100644 gcc/doc/gccint/testsuites/support-for-testing-gcov.rst create mode 100644 gcc/doc/gccint/testsuites/support-for-testing-gimple-passes.rst create mode 100644 gcc/doc/gccint/testsuites/support-for-testing-link-time-optimizations.rst create mode 100644 gcc/doc/gccint/testsuites/support-for-testing-profile-directed-optimizations.rst create mode 100644 gcc/doc/gccint/testsuites/support-for-testing-rtl-passes.rst create mode 100644 gcc/doc/gccint/testsuites/support-for-torture-testing-using-multiple-options.rst create mode 100644 gcc/doc/gccint/the-gcc-low-level-runtime-library.rst create mode 100644 gcc/doc/gccint/the-gcc-low-level-runtime-library/language-independent-routines-for-exception-handling.rst create mode 100644 gcc/doc/gccint/the-gcc-low-level-runtime-library/miscellaneous-runtime-library-routines.rst create mode 100644 gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-decimal-floating-point-emulation.rst create mode 100644 gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-fixed-point-fractional-emulation.rst create mode 100644 gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-floating-point-emulation.rst create mode 100644 gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-integer-arithmetic.rst create mode 100644 gcc/doc/gccint/the-language.rst create mode 100644 gcc/doc/gccint/user-experience-guidelines.rst create mode 100644 gcc/doc/install/binaries.rst create mode 100644 gcc/doc/install/building.rst create mode 100644 gcc/doc/install/building/building-a-cross-compiler.rst create mode 100644 gcc/doc/install/building/building-a-native-compiler.rst create mode 100644 gcc/doc/install/building/building-in-parallel.rst create mode 100644 gcc/doc/install/building/building-the-ada-compiler.rst create mode 100644 gcc/doc/install/building/building-the-d-compiler.rst create mode 100644 gcc/doc/install/building/building-with-profile-feedback.rst create mode 100644 gcc/doc/install/conf.py create mode 100644 gcc/doc/install/configuration.rst create mode 100644 gcc/doc/install/copyright.rst create mode 100644 gcc/doc/install/downloading-gcc.rst create mode 100644 gcc/doc/install/final-installation.rst create mode 100644 gcc/doc/install/gnu-free-documentation-license.rst create mode 100644 gcc/doc/install/host-target-specific-installation-notes-for-gcc.rst create mode 100644 gcc/doc/install/how-can-you-run-the-testsuite-on-selected-tests.rst create mode 100644 gcc/doc/install/how-to-interpret-test-results.rst create mode 100644 gcc/doc/install/index.rst create mode 100644 gcc/doc/install/indices-and-tables.rst create mode 100644 gcc/doc/install/installing-gcc.rst create mode 100644 gcc/doc/install/passing-options-and-running-multiple-testsuites.rst create mode 100644 gcc/doc/install/prerequisites.rst create mode 100644 gcc/doc/install/submitting-test-results.rst create mode 100644 gcc/doc/install/testing.rst create mode 100644 gcc/fortran/doc/gfc-internals/code-that-interacts-with-the-user.rst create mode 100644 gcc/fortran/doc/gfc-internals/command-line-options.rst create mode 100644 gcc/fortran/doc/gfc-internals/conf.py create mode 100644 gcc/fortran/doc/gfc-internals/copyright.rst create mode 100644 gcc/fortran/doc/gfc-internals/error-handling.rst create mode 100644 gcc/fortran/doc/gfc-internals/frontend-data-structures.rst create mode 100644 gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages.rst create mode 100644 gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/accessing-declarations.rst create mode 100644 gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/basic-data-structures.rst create mode 100644 gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/converting-expressions-to-tree.rst create mode 100644 gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/translating-statements.rst create mode 100644 gcc/fortran/doc/gfc-internals/gfccode.rst create mode 100644 gcc/fortran/doc/gfc-internals/gfcexpr.rst create mode 100644 gcc/fortran/doc/gfc-internals/gnu-free-documentation-license.rst create mode 100644 gcc/fortran/doc/gfc-internals/index.rst create mode 100644 gcc/fortran/doc/gfc-internals/indices-and-tables.rst create mode 100644 gcc/fortran/doc/gfc-internals/internals-of-fortran-2003-oop-features.rst create mode 100644 gcc/fortran/doc/gfc-internals/introduction.rst create mode 100644 gcc/fortran/doc/gfc-internals/symbol-versioning.rst create mode 100644 gcc/fortran/doc/gfc-internals/the-libgfortran-runtime-library.rst create mode 100644 gcc/fortran/doc/gfc-internals/type-bound-operators.rst create mode 100644 gcc/fortran/doc/gfc-internals/type-bound-procedures.rst create mode 100644 gcc/fortran/doc/gfortran/about-gnu-fortran.rst create mode 100644 gcc/fortran/doc/gfortran/coarray-programming.rst create mode 100644 gcc/fortran/doc/gfortran/compiler-characteristics.rst create mode 100644 gcc/fortran/doc/gfortran/compiler-characteristics/asynchronous-i-o.rst create mode 100644 gcc/fortran/doc/gfortran/compiler-characteristics/data-consistency-and-durability.rst create mode 100644 gcc/fortran/doc/gfortran/compiler-characteristics/evaluation-of-logical-expressions.rst create mode 100644 gcc/fortran/doc/gfortran/compiler-characteristics/file-format-of-unformatted-sequential-files.rst create mode 100644 gcc/fortran/doc/gfortran/compiler-characteristics/file-operations-on-symbolic-links.rst create mode 100644 gcc/fortran/doc/gfortran/compiler-characteristics/files-opened-without-an-explicit-action=-specifier.rst create mode 100644 gcc/fortran/doc/gfortran/compiler-characteristics/internal-representation-of-logical-variables.rst create mode 100644 gcc/fortran/doc/gfortran/compiler-characteristics/kind-type-parameters.rst create mode 100644 gcc/fortran/doc/gfortran/compiler-characteristics/max-and-min-intrinsics-with-real-nan-arguments.rst create mode 100644 gcc/fortran/doc/gfortran/compiler-characteristics/thread-safety-of-the-runtime-library.rst create mode 100644 gcc/fortran/doc/gfortran/conf.py create mode 100644 gcc/fortran/doc/gfortran/contributing.rst create mode 100644 gcc/fortran/doc/gfortran/contributors-to-gnu-fortran.rst create mode 100644 gcc/fortran/doc/gfortran/copyright.rst create mode 100644 gcc/fortran/doc/gfortran/extensions-implemented-in-gnu-fortran.rst create mode 100644 gcc/fortran/doc/gfortran/extensions-not-implemented-in-gnu-fortran.rst create mode 100644 gcc/fortran/doc/gfortran/extensions.rst create mode 100644 gcc/fortran/doc/gfortran/function-abi-documentation.rst create mode 100644 gcc/fortran/doc/gfortran/funding.rst create mode 100644 gcc/fortran/doc/gfortran/general-public-license-3.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-and-gcc.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options/description.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options/enable-and-customize-preprocessing.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options/environment-variables-affecting-gfortran.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options/influencing-runtime-behavior.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options/influencing-the-linking-step.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options/option-summary.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-controlling-fortran-dialect.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-code-generation-conventions.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-debugging-your-program-or-gnu-fortran.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-directory-search.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-interoperability-with-other-languages.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-to-request-or-suppress-errors-and-warnings.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-fortran-compiler-directives.rst create mode 100644 gcc/fortran/doc/gfortran/gnu-free-documentation-license.rst create mode 100644 gcc/fortran/doc/gfortran/index.rst create mode 100644 gcc/fortran/doc/gfortran/indices-and-tables.rst create mode 100644 gcc/fortran/doc/gfortran/interoperability-with-c.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-modules.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-modules/ieee-modules-ieeeexceptions-ieeearithmetic-and-ieeefeatures.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-modules/isocbinding.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-modules/isofortranenv.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-modules/openacc-module-openacc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-modules/openmp-modules-omplib-and-omplibkinds.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/abort.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/abs.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/access.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/achar.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/acos.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/acosd.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/acosh.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/adjustl.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/adjustr.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/aimag.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/aint.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/alarm.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/all.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/allocated.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/and.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/anint.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/any.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/asin.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/asind.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/asinh.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/associated.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atan.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atan2.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atan2d.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atand.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atanh.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atomicadd.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atomicand.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atomiccas.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atomicdefine.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchadd.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchand.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchor.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchxor.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atomicor.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atomicref.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/atomicxor.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/backtrace.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/besselj0.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/besselj1.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/besseljn.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/bessely0.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/bessely1.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/besselyn.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/bge.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/bgt.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/bitsize.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ble.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/blt.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/btest.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cassociated.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ceiling.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cfpointer.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cfprocpointer.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cfunloc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/char.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/chdir.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/chmod.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cloc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cmplx.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cobroadcast.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/comax.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/comin.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/commandargumentcount.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/compileroptions.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/compilerversion.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/complex.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/conjg.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/coreduce.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cos.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cosd.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cosh.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cosum.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cotan.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cotand.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/count.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cputime.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/cshift.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/csizeof.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ctime.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/dateandtime.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/dble.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/dcmplx.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/digits.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/dim.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/dotproduct.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/dprod.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/dreal.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/dshiftl.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/dshiftr.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/dtime.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/eoshift.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/epsilon.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/erf.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/erfc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/erfcscaled.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/etime.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/eventquery.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/executecommandline.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/exit.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/exp.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/exponent.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/extendstypeof.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/fdate.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/fget.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/fgetc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/findloc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/floor.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/flush.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/fnum.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/fput.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/fputc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/fraction.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/free.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/fseek.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/fstat.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ftell.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/gamma.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/gerror.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/getarg.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/getcommand.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/getcommandargument.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/getcwd.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/getenv.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/getenvironmentvariable.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/getgid.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/getlog.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/getpid.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/getuid.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/gmtime.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/hostnm.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/huge.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/hypot.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/iachar.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/iall.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/iand.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/iany.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/iargc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ibclr.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ibits.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ibset.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ichar.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/idate.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ieor.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ierrno.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/imageindex.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/index.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/int.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/int2.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/int8.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/introduction-to-intrinsic-procedures.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ior.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/iparity.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/irand.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/isatty.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/iscontiguous.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ishft.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ishftc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/isiostatend.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/isiostateor.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/isnan.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/itime.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/kill.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/kind.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/lbound.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/lcobound.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/leadz.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/len.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/lentrim.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/lge.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/lgt.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/link.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/lle.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/llt.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/lnblnk.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/loc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/log.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/log10.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/loggamma.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/logical.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/lshift.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/lstat.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ltime.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/malloc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/maskl.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/maskr.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/matmul.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/max.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/maxexponent.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/maxloc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/maxval.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/mclock.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/mclock8.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/merge.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/mergebits.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/min.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/minexponent.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/minloc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/minval.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/mod.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/modulo.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/movealloc.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/mvbits.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/nearest.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/newline.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/nint.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/norm2.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/not.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/null.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/numimages.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/or.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/pack.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/parity.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/perror.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/popcnt.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/poppar.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/precision.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/present.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/product.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/radix.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ran.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/rand.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/randominit.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/randomnumber.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/randomseed.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/range.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/rank.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/real.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/rename.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/repeat.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/reshape.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/rrspacing.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/rshift.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/sametypeas.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/scale.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/scan.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/secnds.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/second.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/selectedcharkind.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/selectedintkind.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/selectedrealkind.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/setexponent.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/shape.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/shifta.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/shiftl.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/shiftr.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/sign.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/signal.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/sin.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/sind.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/sinh.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/size.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/sizeof.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/sleep.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/spacing.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/spread.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/sqrt.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/srand.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/stat.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/storagesize.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/sum.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/symlnk.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/system.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/systemclock.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/tan.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/tand.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/tanh.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/thisimage.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/time.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/time8.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/tiny.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/trailz.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/transfer.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/transpose.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/trim.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ttynam.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ubound.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/ucobound.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/umask.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/unlink.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/unpack.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/verify.rst create mode 100644 gcc/fortran/doc/gfortran/intrinsic-procedures/xor.rst create mode 100644 gcc/fortran/doc/gfortran/introduction.rst create mode 100644 gcc/fortran/doc/gfortran/mixed-language-programming.rst create mode 100644 gcc/fortran/doc/gfortran/naming-and-argument-passing-conventions.rst create mode 100644 gcc/fortran/doc/gfortran/non-fortran-main-program.rst create mode 100644 gcc/fortran/doc/gfortran/projects.rst create mode 100644 gcc/fortran/doc/gfortran/runtime.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/gfortranconvertunit.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/gfortranerrorbacktrace.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/gfortranformattedbuffersize.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/gfortranlistseparator.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/gfortranoptionalplus.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/gfortranshowlocus.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/gfortranstderrunit.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/gfortranstdinunit.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/gfortranstdoutunit.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/gfortranunbufferedall.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/gfortranunbufferedpreconnected.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/gfortranunformattedbuffersize.rst create mode 100644 gcc/fortran/doc/gfortran/runtime/tmpdir.rst create mode 100644 gcc/fortran/doc/gfortran/standards.rst create mode 100644 gcc/fortran/doc/gfortran/type-and-enum-abi-documentation.rst create mode 100644 gcc/go/doc/c-interoperability.rst create mode 100644 gcc/go/doc/c-type-interoperability.rst create mode 100644 gcc/go/doc/compiler-directives.rst create mode 100644 gcc/go/doc/conf.py create mode 100644 gcc/go/doc/copyright.rst create mode 100644 gcc/go/doc/function-names.rst create mode 100644 gcc/go/doc/general-public-license-3.rst create mode 100644 gcc/go/doc/gnu-free-documentation-license.rst create mode 100644 gcc/go/doc/import-and-export.rst create mode 100644 gcc/go/doc/index.rst create mode 100644 gcc/go/doc/indices-and-tables.rst create mode 100644 gcc/go/doc/introduction.rst create mode 100644 gcc/go/doc/invoking-gccgo.rst create mode 100644 libgomp/doc/amd-radeon-gcn.rst create mode 100644 libgomp/doc/conf.py create mode 100644 libgomp/doc/copyright.rst create mode 100644 libgomp/doc/cuda-streams-usage.rst create mode 100644 libgomp/doc/enabling-openacc.rst create mode 100644 libgomp/doc/enabling-openmp.rst create mode 100644 libgomp/doc/first-invocation-nvidia-cublas-library-api.rst create mode 100644 libgomp/doc/first-invocation-openacc-library-api.rst create mode 100644 libgomp/doc/funding.rst create mode 100644 libgomp/doc/general-public-license-3.rst create mode 100644 libgomp/doc/gnu-free-documentation-license.rst create mode 100644 libgomp/doc/implementation-status-and-implementation-defined-behavior.rst create mode 100644 libgomp/doc/index.rst create mode 100644 libgomp/doc/indices-and-tables.rst create mode 100644 libgomp/doc/introduction.rst create mode 100644 libgomp/doc/memory-allocation-with-libmemkind.rst create mode 100644 libgomp/doc/nvptx.rst create mode 100644 libgomp/doc/offload-target-specifics.rst create mode 100644 libgomp/doc/openacc-environment-variables.rst create mode 100644 libgomp/doc/openacc-environment-variables/accdevicenum.rst create mode 100644 libgomp/doc/openacc-environment-variables/accdevicetype.rst create mode 100644 libgomp/doc/openacc-environment-variables/accproflib.rst create mode 100644 libgomp/doc/openacc-environment-variables/gccaccnotify.rst create mode 100644 libgomp/doc/openacc-introduction.rst create mode 100644 libgomp/doc/openacc-library-and-environment-variables.rst create mode 100644 libgomp/doc/openacc-library-interoperability.rst create mode 100644 libgomp/doc/openacc-profiling-interface.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accasynctest.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accasynctestall.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accattach.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/acccopyin.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/acccopyout.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/acccreate.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accdelete.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accdetach.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accdeviceptr.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accfree.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accgetcudastream.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accgetcurrentcudacontext.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accgetcurrentcudadevice.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accgetdevicenum.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accgetdevicetype.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accgetnumdevices.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accgetproperty.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/acchostptr.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accinit.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accispresent.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accmalloc.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accmapdata.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accmemcpyfromdevice.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accmemcpytodevice.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accondevice.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accpresentorcopyin.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accpresentorcreate.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accproflookup.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accprofregister.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accprofunregister.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accregisterlibrary.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accsetcudastream.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accsetdevicenum.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accsetdevicetype.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accshutdown.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accunmapdata.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accupdatedevice.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accupdateself.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accwait.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accwaitall.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accwaitallasync.rst create mode 100644 libgomp/doc/openacc-runtime-library-routines/accwaitasync.rst create mode 100644 libgomp/doc/openmp-context-selectors.rst create mode 100644 libgomp/doc/openmp-environment-variables.rst create mode 100644 libgomp/doc/openmp-environment-variables/gompcpuaffinity.rst create mode 100644 libgomp/doc/openmp-environment-variables/gompdebug.rst create mode 100644 libgomp/doc/openmp-environment-variables/gomprtemsthreadpools.rst create mode 100644 libgomp/doc/openmp-environment-variables/gompspincount.rst create mode 100644 libgomp/doc/openmp-environment-variables/gompstacksize.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompcancellation.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompdefaultdevice.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompdisplayenv.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompdynamic.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompmaxactivelevels.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompmaxtaskpriority.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompnested.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompnumteams.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompnumthreads.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompplaces.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompprocbind.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompschedule.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompstacksize.rst create mode 100644 libgomp/doc/openmp-environment-variables/omptargetoffload.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompteamsthreadlimit.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompthreadlimit.rst create mode 100644 libgomp/doc/openmp-environment-variables/ompwaitpolicy.rst create mode 100644 libgomp/doc/openmp-implementation-specifics.rst create mode 100644 libgomp/doc/openmp-implementation-status.rst create mode 100644 libgomp/doc/openmp-implementation-status/openmp-45.rst create mode 100644 libgomp/doc/openmp-implementation-status/openmp-50.rst create mode 100644 libgomp/doc/openmp-implementation-status/openmp-51.rst create mode 100644 libgomp/doc/openmp-implementation-status/openmp-52.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompdestroylock.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompdestroynestlock.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompfulfillevent.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetactivelevel.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetancestorthreadnum.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetcancellation.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetdefaultdevice.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetdevicenum.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetdynamic.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetinitialdevice.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetlevel.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetmaxactivelevels.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetmaxtaskpriority.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetmaxteams.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetmaxthreads.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetnested.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetnumdevices.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetnumprocs.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetnumteams.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetnumthreads.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetprocbind.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetschedule.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetsupportedactivelevels.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetteamnum.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetteamsize.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetteamsthreadlimit.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetthreadlimit.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetthreadnum.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetwtick.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompgetwtime.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompinfinal.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompinitlock.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompinitnestlock.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompinparallel.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompisinitialdevice.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompsetdefaultdevice.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompsetdynamic.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompsetlock.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompsetmaxactivelevels.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompsetnested.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompsetnestlock.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompsetnumteams.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompsetnumthreads.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompsetschedule.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompsetteamsthreadlimit.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/omptestlock.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/omptestnestlock.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompunsetlock.rst create mode 100644 libgomp/doc/openmp-runtime-library-routines/ompunsetnestlock.rst create mode 100644 libgomp/doc/reporting-bugs.rst create mode 100644 libgomp/doc/the-libgomp-abi.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-atomic-construct.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-barrier-construct.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-critical-construct.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-flush-construct.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-for-construct.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-master-construct.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-openaccs-parallel-construct.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-ordered-construct.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-parallel-construct.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-private-clause.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-reduction-clause.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-sections-construct.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-single-construct.rst create mode 100644 libgomp/doc/the-libgomp-abi/implementing-threadprivate-construct.rst create mode 100644 libiberty/doc/bsd.rst create mode 100644 libiberty/doc/conf.py create mode 100644 libiberty/doc/copyright.rst create mode 100644 libiberty/doc/extensions.rst create mode 100644 libiberty/doc/function-variable-and-macro-listing.rst create mode 100644 libiberty/doc/index.rst create mode 100644 libiberty/doc/indices-and-tables.rst create mode 100644 libiberty/doc/introduction.rst create mode 100644 libiberty/doc/lesser-general-public-license-2.1.rst create mode 100644 libiberty/doc/overview.rst create mode 100644 libiberty/doc/replacement-functions.rst create mode 100644 libiberty/doc/supplemental-functions.rst create mode 100644 libiberty/doc/using.rst create mode 100644 libitm/doc/c-c++-language-constructs-for-tm.rst create mode 100644 libitm/doc/conf.py create mode 100644 libitm/doc/copyright.rst create mode 100644 libitm/doc/enabling-libitm.rst create mode 100644 libitm/doc/gnu-free-documentation-license.rst create mode 100644 libitm/doc/index.rst create mode 100644 libitm/doc/indices-and-tables.rst create mode 100644 libitm/doc/internals.rst create mode 100644 libitm/doc/locking-conventions.rst create mode 100644 libitm/doc/nesting-flat-vs-closed.rst create mode 100644 libitm/doc/the-libitm-abi.rst create mode 100644 libitm/doc/the-libitm-abi/function-list.rst create mode 100644 libitm/doc/the-libitm-abi/future-enhancements-to-the-abi.rst create mode 100644 libitm/doc/the-libitm-abi/library-design-principles.rst create mode 100644 libitm/doc/the-libitm-abi/memory-model.rst create mode 100644 libitm/doc/the-libitm-abi/non-objectives.rst create mode 100644 libitm/doc/the-libitm-abi/objectives.rst create mode 100644 libitm/doc/the-libitm-abi/sample-code.rst create mode 100644 libitm/doc/the-libitm-abi/types-and-macros-list.rst create mode 100644 libitm/doc/tm-methods-and-method-groups.rst create mode 100644 libquadmath/doc/conf.py create mode 100644 libquadmath/doc/copyright.rst create mode 100644 libquadmath/doc/gnu-free-documentation-license.rst create mode 100644 libquadmath/doc/i-o-library-routines.rst create mode 100644 libquadmath/doc/index.rst create mode 100644 libquadmath/doc/indices-and-tables.rst create mode 100644 libquadmath/doc/introduction.rst create mode 100644 libquadmath/doc/math-library-routines.rst create mode 100644 libquadmath/doc/quadmathsnprintf.rst create mode 100644 libquadmath/doc/reporting-bugs.rst create mode 100644 libquadmath/doc/strtoflt128.rst create mode 100644 libquadmath/doc/typedef-and-constants.rst diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 00000000000..9e305a8e7da --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,97 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS ?= -j auto -q +SPHINXBUILD ?= sphinx-build +PAPER ?= +SOURCEDIR = . +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_elements.papersize=a4paper +PAPEROPT_letter = -D latex_elements.papersize=letterpaper +# $(O) is meant as a shortcut for $(SPHINXOPTS) +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(O) $(SOURCEDIR) +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(O) $(SOURCEDIR) + +.PHONY: help +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and an HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " applehelp to make an Apple Help Book" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files (you can set PAPER=a4 or PAPER=letter)" + @echo " latexpdf to make LaTeX files and then PDFs out of them" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " lualatexpdf to make LaTeX files and run them through lualatex" + @echo " xelatexpdf to make LaTeX files and run them through xelatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + @echo " coverage to run coverage check of the documentation (if enabled)" + @echo " dummy to check syntax errors of document sources" + +.PHONY: clean +clean: + rm -rf $(BUILDDIR) + +.PHONY: latexpdf +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) LATEXMKOPTS="-interaction=nonstopmode -f" -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: latexpdfja +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: lualatexpdf +lualatexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through lualatex..." + $(MAKE) PDFLATEX=lualatex -C $(BUILDDIR)/latex all-pdf + @echo "lualatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: xelatexpdf +xelatexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through xelatex..." + $(MAKE) PDFLATEX=xelatex -C $(BUILDDIR)/latex all-pdf + @echo "xelatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: info +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +.PHONY: gettext +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + +# Catch-all target: route all unknown targets to Sphinx +.PHONY: Makefile +%: Makefile + $(SPHINXBUILD) -b "$@" $(ALLSPHINXOPTS) "$(BUILDDIR)/$@" + diff --git a/doc/_static/custom.css b/doc/_static/custom.css new file mode 100644 index 00000000000..1282a993e2a --- /dev/null +++ b/doc/_static/custom.css @@ -0,0 +1,11 @@ +.sidebar-brand-text { + font-size: 13pt; +} + +.literal { + white-space: nowrap !important; +} + +.wy-nav-content { + max-width: initial; +} diff --git a/doc/baseconf.py b/doc/baseconf.py new file mode 100644 index 00000000000..2eea8298dae --- /dev/null +++ b/doc/baseconf.py @@ -0,0 +1,230 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +import os +import subprocess +import sys +# sys.path.insert(0, os.path.abspath('.')) + +# gccint needs a deeper stack limit +sys.setrecursionlimit(2000) + +# -- Project information ----------------------------------------------------- + +# The full version, including alpha/beta/rc tags + +# FIXME +folder = os.path.dirname(os.path.realpath(__file__)) +gcc_srcdir = os.path.join(folder, './objdir') + + +def __read_file(name): + path = os.path.join(gcc_srcdir, name) + if os.path.exists(path): + return open(path).read().strip() + else: + return '' + + +def __get_git_revision(): + try: + r = subprocess.check_output('git rev-parse --short HEAD', shell=True, encoding='utf8', + stderr=subprocess.DEVNULL) + return r.strip() + except subprocess.CalledProcessError: + return None + + +def __get_builder_name(): + if '-b' in sys.argv: + return sys.argv[sys.argv.index('-b') + 1] + else: + return None + + +gcc_BASEVER = __read_file('BASE-VER') +gcc_DEVPHASE = __read_file('DEV-PHASE') +gcc_DATESTAMP = __read_file('DATESTAMP') +gcc_REVISION = __read_file('REVISION') + +VERSION_PACKAGE = os.getenv('VERSION_PACKAGE', '(GCC)') +BUGURL = os.getenv('BUGURL', 'https://gcc.gnu.org/bugs/') +MONOCHROMATIC = os.getenv('MONOCHROMATIC') + +# The short X.Y version. +version = gcc_BASEVER + +# The full version, including alpha/beta/rc tags. +release = ('%s (%s %s%s)' + % (gcc_BASEVER, gcc_DEVPHASE, gcc_DATESTAMP, + (' %s' % gcc_REVISION) if gcc_REVISION else '')) + +rst_prolog = r''' +.. |gol| raw:: latex + + \\ +.. |nbsp| unicode:: 0xA0 + :trim: +''' + +needs_sphinx = '5.3' + +rst_epilog = ''' +.. |gcc_version| replace:: %s +.. |package_version| replace:: %s +.. |bugurl| replace:: %s +.. |needs_sphinx| replace:: %s +''' % (gcc_BASEVER, VERSION_PACKAGE, BUGURL, needs_sphinx) + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'gcc_sphinx', + 'sphinx.ext.intersphinx', + 'sphinx.ext.extlinks', + 'sphinx.ext.todo', +] + +if __get_builder_name() == 'html': + extensions.append('sphinx_copybutton') + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = ['_build'] + +# Do not highlight by default +highlight_language = 'none' + +# Select C++ as a primary domain +primary_domain = 'cpp' + +cpp_id_attributes = ['HOST_WIDE_INT', '__memx'] + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'furo' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + 'navigation_with_keys': True, +} + +html_logo = '../logo.svg' + +html_favicon = '../favicon.ico' + +html_last_updated_fmt = '' + +html_context = { + 'commit': __get_git_revision() +} + +html_static_path = [ + '../_static' +] + +html_css_files = [ + 'custom.css' +] + +# By default, do not generate any manual pages +man_pages = [] + +# FIXME: handle WARNINGs: unknown option issues and cross refs +suppress_warnings = [ + 'ref.option', +] + +# Use xelatex by default +latex_engine = 'xelatex' + +latex_logo = '../logo.pdf' + +latex_elements = { + 'pointsize': '11pt', + 'fontpkg': r''' +\setmonofont[Scale=0.8]{DejaVu Sans Mono} +''', + 'preamble': r''' +\fvset{formatcom=\let\textbf\relax} +\protected\def\sphinxcrossref#1{#1} +''', +} + +if MONOCHROMATIC: + latex_elements['sphinxsetup'] = r''' +TitleColor={black}, +InnerLinkColor={rgb}{0.0, 0.2, 0.6}, +OuterLinkColor={rgb}{0.0, 0.2, 0.6}, +''' + +latex_table_style = ['colorrows'] + +texinfo_cross_references = False + +texinfo_elements = {'preamble': """ +@definfoenclose strong,*,* +@definfoenclose emph,',' +""" +} + +# Use default as RTD theme uses default as well +pygments_style = 'bw' if MONOCHROMATIC else 'default' + +option_emphasise_placeholders = True + +# Ignore GitHub domain for link checking: +# https://github.com/sphinx-doc/sphinx/issues/9016 +linkcheck_ignore = [ + 'https://github.com/.*#.*' +] + +USER_LEVEL_DOCS = ('install', 'gcc', 'gfortran', 'cpp', 'gnat_rm', 'gnat_ugn', + 'gccgo', 'libgomp', 'libquadmath', 'libgccjit') +INTERNAL_DOCS = ('gccint', 'cppinternals', 'gfc-internals', 'gnat-style') + +# Cross manual reference mapping +intersphinx_mapping = {} +for manual in USER_LEVEL_DOCS + INTERNAL_DOCS: + intersphinx_mapping[manual] = (f'https://splichal.eu/scripts/sphinx/{manual}/_build/html/', None) + +# Custom references +extlinks = { + 'P': ('https://wg21.link/p%s', 'P%s'), + 'PR': ('https://gcc.gnu.org/PR%s', 'PR%s'), + 'openmp': ('https://openmp.org/specifications/#%s', 'OpenMP specification v%s'), + 'openacc': ('https://openacc.org/specification#%s', 'OpenACC specification v%s'), +} + +extlinks_detect_hardcoded_links = True + +# Set common settings where we need NAME of the documentation +def set_common(name, module): + module['tags'].add(name) + if gcc_DEVPHASE == 'experimental': + module['todo_include_todos'] = True + module['tags'].add('development') + + html_theme_options['source_edit_link'] = f'https://splichal.eu/scripts/sphinx/{name}' \ + '/_build/html/_sources/{filename}.txt' diff --git a/doc/bsd.rst b/doc/bsd.rst new file mode 100644 index 00000000000..6d53fa6271c --- /dev/null +++ b/doc/bsd.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +BSD +=== + +Copyright (C) 1990 Regents of the University of California. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +#. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +#. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +#. [rescinded 22 July 1999] + +#. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. \ No newline at end of file diff --git a/doc/contrib.rst b/doc/contrib.rst new file mode 100644 index 00000000000..273d61717b1 --- /dev/null +++ b/doc/contrib.rst @@ -0,0 +1,1273 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: contributors + +.. _contributors: + +Contributors to GCC +=================== + +The GCC project would like to thank its many contributors. Without them the +project would not have been nearly as successful as it has been. Any omissions +in this list are accidental. Feel free to contact +law@redhat.com or gerald@pfeifer.com if you have been left +out or some of your contributions are not listed. Please keep this list in +alphabetical order. + +* Analog Devices helped implement the support for complex data types + and iterators. + +* John David Anglin for threading-related fixes and improvements to + libstdc++-v3, and the HP-UX port. + +* James van Artsdalen wrote the code that makes efficient use of + the Intel 80387 register stack. + +* Abramo and Roberto Bagnara for the SysV68 Motorola 3300 Delta Series + port. + +* Alasdair Baird for various bug fixes. + +* Giovanni Bajo for analyzing lots of complicated C++ problem reports. + +* Peter Barada for his work to improve code generation for new + ColdFire cores. + +* Gerald Baumgartner added the signature extension to the C++ front end. + +* Godmar Back for his Java improvements and encouragement. + +* Scott Bambrough for help porting the Java compiler. + +* Wolfgang Bangerth for processing tons of bug reports. + +* Jon Beniston for his Microsoft Windows port of Java and port to Lattice Mico32. + +* Daniel Berlin for better DWARF 2 support, faster/better optimizations, + improved alias analysis, plus migrating GCC to Bugzilla. + +* Geoff Berry for his Java object serialization work and various patches. + +* David Binderman tests weekly snapshots of GCC trunk against Fedora Rawhide + for several architectures. + +* Laurynas Biveinis for memory management work and DJGPP port fixes. + +* Uros Bizjak for the implementation of x87 math built-in functions and + for various middle end and i386 back end improvements and bug fixes. + +* Eric Blake for helping to make GCJ and libgcj conform to the + specifications. + +* Janne Blomqvist for contributions to GNU Fortran. + +* Hans-J. Boehm for his garbage collector, IA-64 libffi port, and other + Java work. + +* Segher Boessenkool for helping maintain the PowerPC port and the + instruction combiner plus various contributions to the middle end. + +* Neil Booth for work on cpplib, lang hooks, debug hooks and other + miscellaneous clean-ups. + +* Steven Bosscher for integrating the GNU Fortran front end into GCC and for + contributing to the tree-ssa branch. + +* Eric Botcazou for fixing middle- and backend bugs left and right. + +* Per Bothner for his direction via the steering committee and various + improvements to the infrastructure for supporting new languages. Chill + front end implementation. Initial implementations of + cpplib, fix-header, config.guess, libio, and past C++ library (libg++) + maintainer. Dreaming up, designing and implementing much of GCJ. + +* Devon Bowen helped port GCC to the Tahoe. + +* Don Bowman for mips-vxworks contributions. + +* James Bowman for the FT32 port. + +* Dave Brolley for work on cpplib and Chill. + +* Paul Brook for work on the ARM architecture and maintaining GNU Fortran. + +* Robert Brown implemented the support for Encore 32000 systems. + +* Christian Bruel for improvements to local store elimination. + +* Herman A.J. ten Brugge for various fixes. + +* Joerg Brunsmann for Java compiler hacking and help with the GCJ FAQ. + +* Joe Buck for his direction via the steering committee from its creation + to 2013. + +* Iain Buclaw for the D frontend. + +* Craig Burley for leadership of the G77 Fortran effort. + +* Tobias Burnus for contributions to GNU Fortran. + +* Stephan Buys for contributing Doxygen notes for libstdc++. + +* Paolo Carlini for libstdc++ work: lots of efficiency improvements to + the C++ strings, streambufs and formatted I/O, hard detective work on + the frustrating localization issues, and keeping up with the problem reports. + +* John Carr for his alias work, SPARC hacking, infrastructure improvements, + previous contributions to the steering committee, loop optimizations, etc. + +* Stephane Carrez for 68HC11 and 68HC12 ports. + +* Steve Chamberlain for support for the Renesas SH and H8 processors + and the PicoJava processor, and for GCJ config fixes. + +* Glenn Chambers for help with the GCJ FAQ. + +* John-Marc Chandonia for various libgcj patches. + +* Denis Chertykov for contributing and maintaining the AVR port, the first GCC port + for an 8-bit architecture. + +* Kito Cheng for his work on the RISC-V port, including bringing up the test + suite and maintenance. + +* Scott Christley for his Objective-C contributions. + +* Eric Christopher for his Java porting help and clean-ups. + +* Branko Cibej for more warning contributions. + +* The `GNU Classpath project `_ + for all of their merged runtime code. + +* Nick Clifton for arm, mcore, fr30, v850, m32r, msp430 rx work, + :option:`--help`, and other random hacking. + +* Michael Cook for libstdc++ cleanup patches to reduce warnings. + +* R. Kelley Cook for making GCC buildable from a read-only directory as + well as other miscellaneous build process and documentation clean-ups. + +* Ralf Corsepius for SH testing and minor bug fixing. + +* François-Xavier Coudert for contributions to GNU Fortran. + +* Stan Cox for care and feeding of the x86 port and lots of behind + the scenes hacking. + +* Alex Crain provided changes for the 3b1. + +* Ian Dall for major improvements to the NS32k port. + +* Paul Dale for his work to add uClinux platform support to the + m68k backend. + +* Palmer Dabbelt for his work maintaining the RISC-V port. + +* Dario Dariol contributed the four varieties of sample programs + that print a copy of their source. + +* Russell Davidson for fstream and stringstream fixes in libstdc++. + +* Bud Davis for work on the G77 and GNU Fortran compilers. + +* Mo DeJong for GCJ and libgcj bug fixes. + +* Jerry DeLisle for contributions to GNU Fortran. + +* DJ Delorie for the DJGPP port, build and libiberty maintenance, + various bug fixes, and the M32C, MeP, MSP430, and RL78 ports. + +* Arnaud Desitter for helping to debug GNU Fortran. + +* Gabriel Dos Reis for contributions to G++, contributions and + maintenance of GCC diagnostics infrastructure, libstdc++-v3, + including ``valarray<>``, ``complex<>``, maintaining the numerics library + (including that pesky ```` :-) and keeping up-to-date anything + to do with numbers. + +* Ulrich Drepper for his work on glibc, testing of GCC using glibc, ISO C99 + support, CFG dumping support, etc., plus support of the C++ runtime + libraries including for all kinds of C interface issues, contributing and + maintaining ``complex<>``, sanity checking and disbursement, configuration + architecture, libio maintenance, and early math work. + +* François Dumont for his work on libstdc++-v3, especially maintaining and + improving ``debug-mode`` and associative and unordered containers. + +* Zdenek Dvorak for a new loop unroller and various fixes. + +* Michael Eager for his work on the Xilinx MicroBlaze port. + +* Richard Earnshaw for his ongoing work with the ARM. + +* David Edelsohn for his direction via the steering committee, ongoing work + with the RS6000/PowerPC port, help cleaning up Haifa loop changes, + doing the entire AIX port of libstdc++ with his bare hands, and for + ensuring GCC properly keeps working on AIX. + +* Kevin Ediger for the floating point formatting of num_put::do_put in + libstdc++. + +* Phil Edwards for libstdc++ work including configuration hackery, + documentation maintainer, chief breaker of the web pages, the occasional + iostream bug fix, and work on shared library symbol versioning. + +* Paul Eggert for random hacking all over GCC. + +* Mark Elbrecht for various DJGPP improvements, and for libstdc++ + configuration support for locales and fstream-related fixes. + +* Vadim Egorov for libstdc++ fixes in strings, streambufs, and iostreams. + +* Christian Ehrhardt for dealing with bug reports. + +* Ben Elliston for his work to move the Objective-C runtime into its + own subdirectory and for his work on autoconf. + +* Revital Eres for work on the PowerPC 750CL port. + +* Marc Espie for OpenBSD support. + +* Doug Evans for much of the global optimization framework, arc, m32r, + and SPARC work. + +* Christopher Faylor for his work on the Cygwin port and for caring and + feeding the gcc.gnu.org box and saving its users tons of spam. + +* Fred Fish for BeOS support and Ada fixes. + +* Ivan Fontes Garcia for the Portuguese translation of the GCJ FAQ. + +* Peter Gerwinski for various bug fixes and the Pascal front end. + +* Kaveh R. Ghazi for his direction via the steering committee, amazing + work to make :samp:`-W -Wall -W* -Werror` useful, and + testing GCC on a plethora of platforms. Kaveh extends his gratitude to + the CAIP Center at Rutgers University for providing him with computing + resources to work on Free Software from the late 1980s to 2010. + +* John Gilmore for a donation to the FSF earmarked improving GNU Java. + +* Judy Goldberg for c++ contributions. + +* Torbjorn Granlund for various fixes and the c-torture testsuite, + multiply- and divide-by-constant optimization, improved long long + support, improved leaf function register allocation, and his direction + via the steering committee. + +* Jonny Grant for improvements to ``collect2's`` :option:`--help` documentation. + +* Anthony Green for his :option:`-Os` contributions, the moxie port, and + Java front end work. + +* Stu Grossman for gdb hacking, allowing GCJ developers to debug Java code. + +* Michael K. Gschwind contributed the port to the PDP-11. + +* Richard Biener for his ongoing middle-end contributions and bug fixes + and for release management. + +* Ron Guilmette implemented the :command:`protoize` and :command:`unprotoize` + tools, the support for DWARF 1 symbolic debugging information, and much of + the support for System V Release 4. He has also worked heavily on the + Intel 386 and 860 support. + +* Sumanth Gundapaneni for contributing the CR16 port. + +* Mostafa Hagog for Swing Modulo Scheduling (SMS) and post reload GCSE. + +* Bruno Haible for improvements in the runtime overhead for EH, new + warnings and assorted bug fixes. + +* Andrew Haley for his amazing Java compiler and library efforts. + +* Chris Hanson assisted in making GCC work on HP-UX for the 9000 series 300. + +* Michael Hayes for various thankless work he's done trying to get + the c30/c40 ports functional. Lots of loop and unroll improvements and + fixes. + +* Dara Hazeghi for wading through myriads of target-specific bug reports. + +* Kate Hedstrom for staking the G77 folks with an initial testsuite. + +* Richard Henderson for his ongoing SPARC, alpha, ia32, and ia64 work, loop + opts, and generally fixing lots of old problems we've ignored for + years, flow rewrite and lots of further stuff, including reviewing + tons of patches. + +* Aldy Hernandez for working on the PowerPC port, SIMD support, and + various fixes. + +* Nobuyuki Hikichi of Software Research Associates, Tokyo, contributed + the support for the Sony NEWS machine. + +* Kazu Hirata for caring and feeding the Renesas H8/300 port and various fixes. + +* Katherine Holcomb for work on GNU Fortran. + +* Manfred Hollstein for his ongoing work to keep the m88k alive, lots + of testing and bug fixing, particularly of GCC configury code. + +* Steve Holmgren for MachTen patches. + +* Mat Hostetter for work on the TILE-Gx and TILEPro ports. + +* Jan Hubicka for his x86 port improvements. + +* Falk Hueffner for working on C and optimization bug reports. + +* Bernardo Innocenti for his m68k work, including merging of + ColdFire improvements and uClinux support. + +* Christian Iseli for various bug fixes. + +* Kamil Iskra for general m68k hacking. + +* Lee Iverson for random fixes and MIPS testing. + +* Balaji V. Iyer for Cilk+ development and merging. + +* Andreas Jaeger for testing and benchmarking of GCC and various bug fixes. + +* Martin Jambor for his work on inter-procedural optimizations, the + switch conversion pass, and scalar replacement of aggregates. + +* Jakub Jelinek for his SPARC work and sibling call optimizations as well + as lots of bug fixes and test cases, and for improving the Java build + system. + +* Janis Johnson for ia64 testing and fixes, her quality improvement + sidetracks, and web page maintenance. + +* Kean Johnston for SCO OpenServer support and various fixes. + +* Tim Josling for the sample language treelang based originally on Richard + Kenner's 'toy' language. + +* Nicolai Josuttis for additional libstdc++ documentation. + +* Klaus Kaempf for his ongoing work to make alpha-vms a viable target. + +* Steven G. Kargl for work on GNU Fortran. + +* David Kashtan of SRI adapted GCC to VMS. + +* Ryszard Kabatek for many, many libstdc++ bug fixes and optimizations of + strings, especially member functions, and for auto_ptr fixes. + +* Geoffrey Keating for his ongoing work to make the PPC work for GNU/Linux + and his automatic regression tester. + +* Brendan Kehoe for his ongoing work with G++ and for a lot of early work + in just about every part of libstdc++. + +* Oliver M. Kellogg of Deutsche Aerospace contributed the port to the + MIL-STD-1750A. + +* Richard Kenner of the New York University Ultracomputer Research + Laboratory wrote the machine descriptions for the AMD 29000, the DEC + Alpha, the IBM RT PC, and the IBM RS/6000 as well as the support for + instruction attributes. He also made changes to better support RISC + processors including changes to common subexpression elimination, + strength reduction, function calling sequence handling, and condition + code support, in addition to generalizing the code for frame pointer + elimination and delay slot scheduling. Richard Kenner was also the + head maintainer of GCC for several years. + +* Mumit Khan for various contributions to the Cygwin and Mingw32 ports and + maintaining binary releases for Microsoft Windows hosts, and for massive libstdc++ + porting work to Cygwin/Mingw32. + +* Robin Kirkham for cpu32 support. + +* Mark Klein for PA improvements. + +* Thomas Koenig for various bug fixes. + +* Bruce Korb for the new and improved fixincludes code. + +* Benjamin Kosnik for his G++ work and for leading the libstdc++-v3 effort. + +* Maxim Kuvyrkov for contributions to the instruction scheduler, the Android + and m68k/Coldfire ports, and optimizations. + +* Charles LaBrec contributed the support for the Integrated Solutions + 68020 system. + +* Asher Langton and Mike Kumbera for contributing Cray pointer support + to GNU Fortran, and for other GNU Fortran improvements. + +* Jeff Law for his direction via the steering committee, coordinating the + entire egcs project and GCC 2.95, rolling out snapshots and releases, + handling merges from GCC2, reviewing tons of patches that might have + fallen through the cracks else, and random but extensive hacking. + +* Walter Lee for work on the TILE-Gx and TILEPro ports. + +* Marc Lehmann for his direction via the steering committee and helping + with analysis and improvements of x86 performance. + +* Victor Leikehman for work on GNU Fortran. + +* Ted Lemon wrote parts of the RTL reader and printer. + +* Kriang Lerdsuwanakij for C++ improvements including template as template + parameter support, and many C++ fixes. + +* Warren Levy for tremendous work on libgcj (Java Runtime Library) and + random work on the Java front end. + +* Alain Lichnewsky ported GCC to the MIPS CPU. + +* Oskar Liljeblad for hacking on AWT and his many Java bug reports and + patches. + +* Robert Lipe for OpenServer support, new testsuites, testing, etc. + +* Chen Liqin for various S+core related fixes/improvement, and for + maintaining the S+core port. + +* Martin Liska for his work on identical code folding, the sanitizers, + HSA, general bug fixing and for running automated regression testing of GCC + and reporting numerous bugs. + +* Weiwen Liu for testing and various bug fixes. + +* Manuel López-Ibáñez for improving :option:`-Wconversion` and + many other diagnostics fixes and improvements. + +* Dave Love for his ongoing work with the Fortran front end and + runtime libraries. + +* Martin von Löwis for internal consistency checking infrastructure, + various C++ improvements including namespace support, and tons of + assistance with libstdc++/compiler merges. + +* H.J. Lu for his previous contributions to the steering committee, many x86 + bug reports, prototype patches, and keeping the GNU/Linux ports working. + +* Greg McGary for random fixes and (someday) bounded pointers. + +* Andrew MacLeod for his ongoing work in building a real EH system, + various code generation improvements, work on the global optimizer, etc. + +* Vladimir Makarov for hacking some ugly i960 problems, PowerPC hacking + improvements to compile-time performance, overall knowledge and + direction in the area of instruction scheduling, design and + implementation of the automaton based instruction scheduler and + design and implementation of the integrated and local register allocators. + +* David Malcolm for his work on improving GCC diagnostics, JIT, self-tests + and unit testing. + +* Bob Manson for his behind the scenes work on dejagnu. + +* John Marino for contributing the DragonFly BSD port. + +* Philip Martin for lots of libstdc++ string and vector iterator fixes and + improvements, and string clean up and testsuites. + +* Michael Matz for his work on dominance tree discovery, the x86-64 port, + link-time optimization framework and general optimization improvements. + +* All of the Mauve project contributors for Java test code. + +* Bryce McKinlay for numerous GCJ and libgcj fixes and improvements. + +* Adam Megacz for his work on the Microsoft Windows port of GCJ. + +* Michael Meissner for LRS framework, ia32, m32r, v850, m88k, MIPS, + powerpc, haifa, ECOFF debug support, and other assorted hacking. + +* Jason Merrill for his direction via the steering committee and leading + the G++ effort. + +* Martin Michlmayr for testing GCC on several architectures using the + entire Debian archive. + +* David Miller for his direction via the steering committee, lots of + SPARC work, improvements in jump.cc and interfacing with the Linux kernel + developers. + +* Gary Miller ported GCC to Charles River Data Systems machines. + +* Alfred Minarik for libstdc++ string and ios bug fixes, and turning the + entire libstdc++ testsuite namespace-compatible. + +* Mark Mitchell for his direction via the steering committee, mountains of + C++ work, load/store hoisting out of loops, alias analysis improvements, + ISO C ``restrict`` support, and serving as release manager from 2000 + to 2011. + +* Alan Modra for various GNU/Linux bits and testing. + +* Toon Moene for his direction via the steering committee, Fortran + maintenance, and his ongoing work to make us make Fortran run fast. + +* Jason Molenda for major help in the care and feeding of all the services + on the gcc.gnu.org (formerly egcs.cygnus.com) machine---mail, web + services, ftp services, etc etc. Doing all this work on scrap paper and + the backs of envelopes would have been... difficult. + +* Catherine Moore for fixing various ugly problems we have sent her + way, including the haifa bug which was killing the Alpha & PowerPC + Linux kernels. + +* Mike Moreton for his various Java patches. + +* David Mosberger-Tang for various Alpha improvements, and for the initial + IA-64 port. + +* Stephen Moshier contributed the floating point emulator that assists in + cross-compilation and permits support for floating point numbers wider + than 64 bits and for ISO C99 support. + +* Bill Moyer for his behind the scenes work on various issues. + +* Philippe De Muyter for his work on the m68k port. + +* Joseph S. Myers for his work on the PDP-11 port, format checking and ISO + C99 support, and continuous emphasis on (and contributions to) documentation. + +* Nathan Myers for his work on libstdc++-v3: architecture and authorship + through the first three snapshots, including implementation of locale + infrastructure, string, shadow C headers, and the initial project + documentation (DESIGN, CHECKLIST, and so forth). Later, more work on + MT-safe string and shadow headers. + +* Felix Natter for documentation on porting libstdc++. + +* Nathanael Nerode for cleaning up the configuration/build process. + +* NeXT, Inc. donated the front end that supports the Objective-C + language. + +* Hans-Peter Nilsson for the CRIS and MMIX ports, improvements to the search + engine setup, various documentation fixes and other small fixes. + +* Geoff Noer for his work on getting cygwin native builds working. + +* Vegard Nossum for running automated regression testing of GCC and reporting + numerous bugs. + +* Diego Novillo for his work on Tree SSA, OpenMP, SPEC performance + tracking web pages, GIMPLE tuples, and assorted fixes. + +* David O'Brien for the FreeBSD/alpha, FreeBSD/AMD x86-64, FreeBSD/ARM, + FreeBSD/PowerPC, and FreeBSD/SPARC64 ports and related infrastructure + improvements. + +* Alexandre Oliva for various build infrastructure improvements, scripts and + amazing testing work, including keeping libtool issues sane and happy. + +* Stefan Olsson for work on mt_alloc. + +* Melissa O'Neill for various NeXT fixes. + +* Rainer Orth for random MIPS work, including improvements to GCC's o32 + ABI support, improvements to dejagnu's MIPS support, Java configuration + clean-ups and porting work, and maintaining the IRIX, Solaris 2, and + Tru64 UNIX ports. + +* Steven Pemberton for his contribution of :samp:`enquire` which allowed GCC to + determine various properties of the floating point unit and generate + :samp:`float.h` in older versions of GCC. + +* Hartmut Penner for work on the s390 port. + +* Paul Petersen wrote the machine description for the Alliant FX/8. + +* Alexandre Petit-Bianco for implementing much of the Java compiler and + continued Java maintainership. + +* Matthias Pfaller for major improvements to the NS32k port. + +* Gerald Pfeifer for his direction via the steering committee, pointing + out lots of problems we need to solve, maintenance of the web pages, and + taking care of documentation maintenance in general. + +* Marek Polacek for his work on the C front end, the sanitizers and general + bug fixing. + +* Andrew Pinski for processing bug reports by the dozen. + +* Ovidiu Predescu for his work on the Objective-C front end and runtime + libraries. + +* Jerry Quinn for major performance improvements in C++ formatted I/O. + +* Ken Raeburn for various improvements to checker, MIPS ports and various + cleanups in the compiler. + +* Rolf W. Rasmussen for hacking on AWT. + +* David Reese of Sun Microsystems contributed to the Solaris on PowerPC + port. + +* John Regehr for running automated regression testing of GCC and reporting + numerous bugs. + +* Volker Reichelt for running automated regression testing of GCC and reporting + numerous bugs and for keeping up with the problem reports. + +* Joern Rennecke for maintaining the sh port, loop, regmove & reload + hacking and developing and maintaining the Epiphany port. + +* Loren J. Rittle for improvements to libstdc++-v3 including the FreeBSD + port, threading fixes, thread-related configury changes, critical + threading documentation, and solutions to really tricky I/O problems, + as well as keeping GCC properly working on FreeBSD and continuous testing. + +* Craig Rodrigues for processing tons of bug reports. + +* Ola Rönnerup for work on mt_alloc. + +* Gavin Romig-Koch for lots of behind the scenes MIPS work. + +* David Ronis inspired and encouraged Craig to rewrite the G77 + documentation in texinfo format by contributing a first pass at a + translation of the old :samp:`g77-0.5.16/f/DOC` file. + +* Ken Rose for fixes to GCC's delay slot filling code. + +* Ira Rosen for her contributions to the auto-vectorizer. + +* Paul Rubin wrote most of the preprocessor. + +* Pétur Runólfsson for major performance improvements in C++ formatted I/O and + large file support in C++ filebuf. + +* Chip Salzenberg for libstdc++ patches and improvements to locales, traits, + Makefiles, libio, libtool hackery, and 'long long' support. + +* Juha Sarlin for improvements to the H8 code generator. + +* Greg Satz assisted in making GCC work on HP-UX for the 9000 series 300. + +* Roger Sayle for improvements to constant folding and GCC's RTL optimizers + as well as for fixing numerous bugs. + +* Bradley Schatz for his work on the GCJ FAQ. + +* Peter Schauer wrote the code to allow debugging to work on the Alpha. + +* William Schelter did most of the work on the Intel 80386 support. + +* Tobias Schlüter for work on GNU Fortran. + +* Bernd Schmidt for various code generation improvements and major + work in the reload pass, serving as release manager for + GCC 2.95.3, and work on the Blackfin and C6X ports. + +* Peter Schmid for constant testing of libstdc++---especially application + testing, going above and beyond what was requested for the release + criteria---and libstdc++ header file tweaks. + +* Jason Schroeder for jcf-dump patches. + +* Andreas Schwab for his work on the m68k port. + +* Lars Segerlund for work on GNU Fortran. + +* Dodji Seketeli for numerous C++ bug fixes and debug info improvements. + +* Tim Shen for major work on ````. + +* Joel Sherrill for his direction via the steering committee, RTEMS + contributions and RTEMS testing. + +* Nathan Sidwell for many C++ fixes/improvements. + +* Jeffrey Siegal for helping RMS with the original design of GCC, some + code which handles the parse tree and RTL data structures, constant + folding and help with the original VAX & m68k ports. + +* Kenny Simpson for prompting libstdc++ fixes due to defect reports from + the LWG (thereby keeping GCC in line with updates from the ISO). + +* Franz Sirl for his ongoing work with making the PPC port stable + for GNU/Linux. + +* Andrey Slepuhin for assorted AIX hacking. + +* Trevor Smigiel for contributing the SPU port. + +* Christopher Smith did the port for Convex machines. + +* Danny Smith for his major efforts on the Mingw (and Cygwin) ports. + Retired from GCC maintainership August 2010, having mentored two + new maintainers into the role. + +* Randy Smith finished the Sun FPA support. + +* Ed Smith-Rowland for his continuous work on libstdc++-v3, special functions, + ````, and various improvements to C++11 features. + +* Scott Snyder for queue, iterator, istream, and string fixes and libstdc++ + testsuite entries. Also for providing the patch to G77 to add + rudimentary support for ``INTEGER*1``, ``INTEGER*2``, and + ``LOGICAL*1``. + +* Zdenek Sojka for running automated regression testing of GCC and reporting + numerous bugs. + +* Arseny Solokha for running automated regression testing of GCC and reporting + numerous bugs. + +* Jayant Sonar for contributing the CR16 port. + +* Brad Spencer for contributions to the GLIBCPP_FORCE_NEW technique. + +* Richard Stallman, for writing the original GCC and launching the GNU project. + +* Jan Stein of the Chalmers Computer Society provided support for + Genix, as well as part of the 32000 machine description. + +* Gerhard Steinmetz for running automated regression testing of GCC and reporting + numerous bugs. + +* Nigel Stephens for various mips16 related fixes/improvements. + +* Jonathan Stone wrote the machine description for the Pyramid computer. + +* Graham Stott for various infrastructure improvements. + +* John Stracke for his Java HTTP protocol fixes. + +* Mike Stump for his Elxsi port, G++ contributions over the years and more + recently his vxworks contributions + +* Jeff Sturm for Java porting help, bug fixes, and encouragement. + +* Zhendong Su for running automated regression testing of GCC and reporting + numerous bugs. + +* Chengnian Sun for running automated regression testing of GCC and reporting + numerous bugs. + +* Shigeya Suzuki for this fixes for the bsdi platforms. + +* Ian Lance Taylor for the Go frontend, the initial mips16 and mips64 + support, general configury hacking, fixincludes, etc. + +* Holger Teutsch provided the support for the Clipper CPU. + +* Gary Thomas for his ongoing work to make the PPC work for GNU/Linux. + +* Paul Thomas for contributions to GNU Fortran. + +* Philipp Thomas for random bug fixes throughout the compiler + +* Jason Thorpe for thread support in libstdc++ on NetBSD. + +* Kresten Krab Thorup wrote the run time support for the Objective-C + language and the fantastic Java bytecode interpreter. + +* Michael Tiemann for random bug fixes, the first instruction scheduler, + initial C++ support, function integration, NS32k, SPARC and M88k + machine description work, delay slot scheduling. + +* Andreas Tobler for his work porting libgcj to Darwin. + +* Teemu Torma for thread safe exception handling support. + +* Leonard Tower wrote parts of the parser, RTL generator, and RTL + definitions, and of the VAX machine description. + +* Daniel Towner and Hariharan Sandanagobalane contributed and + maintain the picoChip port. + +* Tom Tromey for internationalization support and for his many Java + contributions and libgcj maintainership. + +* Lassi Tuura for improvements to config.guess to determine HP processor + types. + +* Petter Urkedal for libstdc++ CXXFLAGS, math, and algorithms fixes. + +* Andy Vaught for the design and initial implementation of the GNU Fortran + front end. + +* Brent Verner for work with the libstdc++ cshadow files and their + associated configure steps. + +* Todd Vierling for contributions for NetBSD ports. + +* Andrew Waterman for contributing the RISC-V port, as well as maintaining it. + +* Jonathan Wakely for contributing libstdc++ Doxygen notes and XHTML + guidance and maintaining libstdc++. + +* Dean Wakerley for converting the install documentation from HTML to texinfo + in time for GCC 3.0. + +* Krister Walfridsson for random bug fixes. + +* Feng Wang for contributions to GNU Fortran. + +* Stephen M. Webb for time and effort on making libstdc++ shadow files + work with the tricky Solaris 8+ headers, and for pushing the build-time + header tree. Also, for starting and driving the ```` effort. + +* John Wehle for various improvements for the x86 code generator, + related infrastructure improvements to help x86 code generation, + value range propagation and other work, WE32k port. + +* Ulrich Weigand for work on the s390 port. + +* Janus Weil for contributions to GNU Fortran. + +* Zack Weinberg for major work on cpplib and various other bug fixes. + +* Matt Welsh for help with Linux Threads support in GCJ. + +* Urban Widmark for help fixing java.io. + +* Mark Wielaard for new Java library code and his work integrating with + Classpath. + +* Dale Wiles helped port GCC to the Tahoe. + +* Bob Wilson from Tensilica, Inc. for the Xtensa port. + +* Jim Wilson for his direction via the steering committee, tackling hard + problems in various places that nobody else wanted to work on, strength + reduction and other loop optimizations. + +* Paul Woegerer and Tal Agmon for the CRX port. + +* Carlo Wood for various fixes. + +* Tom Wood for work on the m88k port. + +* Chung-Ju Wu for his work on the Andes NDS32 port. + +* Canqun Yang for work on GNU Fortran. + +* Masanobu Yuhara of Fujitsu Laboratories implemented the machine + description for the Tron architecture (specifically, the Gmicro). + +* Kevin Zachmann helped port GCC to the Tahoe. + +* Ayal Zaks for Swing Modulo Scheduling (SMS). + +* Qirun Zhang for running automated regression testing of GCC and reporting + numerous bugs. + +* Xiaoqiang Zhang for work on GNU Fortran. + +* Gilles Zunino for help porting Java to Irix. + +The following people are recognized for their contributions to GNAT, +the Ada front end of GCC: + +* Bernard Banner + +* Romain Berrendonner + +* Geert Bosch + +* Emmanuel Briot + +* Joel Brobecker + +* Ben Brosgol + +* Vincent Celier + +* Arnaud Charlet + +* Chien Chieng + +* Cyrille Comar + +* Cyrille Crozes + +* Robert Dewar + +* Gary Dismukes + +* Robert Duff + +* Ed Falis + +* Ramon Fernandez + +* Sam Figueroa + +* Vasiliy Fofanov + +* Michael Friess + +* Franco Gasperoni + +* Ted Giering + +* Matthew Gingell + +* Laurent Guerby + +* Jerome Guitton + +* Olivier Hainque + +* Jerome Hugues + +* Hristian Kirtchev + +* Jerome Lambourg + +* Bruno Leclerc + +* Albert Lee + +* Sean McNeil + +* Javier Miranda + +* Laurent Nana + +* Pascal Obry + +* Dong-Ik Oh + +* Laurent Pautet + +* Brett Porter + +* Thomas Quinot + +* Nicolas Roche + +* Pat Rogers + +* Jose Ruiz + +* Douglas Rupp + +* Sergey Rybin + +* Gail Schenker + +* Ed Schonberg + +* Nicolas Setton + +* Samuel Tardieu + +The following people are recognized for their contributions of new +features, bug reports, testing and integration of classpath/libgcj for +GCC version 4.1: + +* Lillian Angel for ``JTree`` implementation and lots Free Swing + additions and bug fixes. + +* Wolfgang Baer for ``GapContent`` bug fixes. + +* Anthony Balkissoon for ``JList``, Free Swing 1.5 updates and mouse event + fixes, lots of Free Swing work including ``JTable`` editing. + +* Stuart Ballard for RMI constant fixes. + +* Goffredo Baroncelli for ``HTTPURLConnection`` fixes. + +* Gary Benson for ``MessageFormat`` fixes. + +* Daniel Bonniot for ``Serialization`` fixes. + +* Chris Burdess for lots of gnu.xml and http protocol fixes, ``StAX`` + and ``DOM xml:id`` support. + +* Ka-Hing Cheung for ``TreePath`` and ``TreeSelection`` fixes. + +* Archie Cobbs for build fixes, VM interface updates, + ``URLClassLoader`` updates. + +* Kelley Cook for build fixes. + +* Martin Cordova for Suggestions for better ``SocketTimeoutException``. + +* David Daney for ``BitSet`` bug fixes, ``HttpURLConnection`` + rewrite and improvements. + +* Thomas Fitzsimmons for lots of upgrades to the gtk+ AWT and Cairo 2D + support. Lots of imageio framework additions, lots of AWT and Free + Swing bug fixes. + +* Jeroen Frijters for ``ClassLoader`` and nio cleanups, serialization fixes, + better ``Proxy`` support, bug fixes and IKVM integration. + +* Santiago Gala for ``AccessControlContext`` fixes. + +* Nicolas Geoffray for ``VMClassLoader`` and ``AccessController`` + improvements. + +* David Gilbert for ``basic`` and ``metal`` icon and plaf support + and lots of documenting, Lots of Free Swing and metal theme + additions. ``MetalIconFactory`` implementation. + +* Anthony Green for ``MIDI`` framework, ``ALSA`` and ``DSSI`` + providers. + +* Andrew Haley for ``Serialization`` and ``URLClassLoader`` fixes, + gcj build speedups. + +* Kim Ho for ``JFileChooser`` implementation. + +* Andrew John Hughes for ``Locale`` and net fixes, URI RFC2986 + updates, ``Serialization`` fixes, ``Properties`` XML support and + generic branch work, VMIntegration guide update. + +* Bastiaan Huisman for ``TimeZone`` bug fixing. + +* Andreas Jaeger for mprec updates. + +* Paul Jenner for better :option:`-Werror` support. + +* Ito Kazumitsu for ``NetworkInterface`` implementation and updates. + +* Roman Kennke for ``BoxLayout``, ``GrayFilter`` and + ``SplitPane``, plus bug fixes all over. Lots of Free Swing work + including styled text. + +* Simon Kitching for ``String`` cleanups and optimization suggestions. + +* Michael Koch for configuration fixes, ``Locale`` updates, bug and + build fixes. + +* Guilhem Lavaux for configuration, thread and channel fixes and Kaffe + integration. JCL native ``Pointer`` updates. Logger bug fixes. + +* David Lichteblau for JCL support library global/local reference + cleanups. + +* Aaron Luchko for JDWP updates and documentation fixes. + +* Ziga Mahkovec for ``Graphics2D`` upgraded to Cairo 0.5 and new regex + features. + +* Sven de Marothy for BMP imageio support, CSS and ``TextLayout`` + fixes. ``GtkImage`` rewrite, 2D, awt, free swing and date/time fixes and + implementing the Qt4 peers. + +* Casey Marshall for crypto algorithm fixes, ``FileChannel`` lock, + ``SystemLogger`` and ``FileHandler`` rotate implementations, NIO + ``FileChannel.map`` support, security and policy updates. + +* Bryce McKinlay for RMI work. + +* Audrius Meskauskas for lots of Free Corba, RMI and HTML work plus + testing and documenting. + +* Kalle Olavi Niemitalo for build fixes. + +* Rainer Orth for build fixes. + +* Andrew Overholt for ``File`` locking fixes. + +* Ingo Proetel for ``Image``, ``Logger`` and ``URLClassLoader`` + updates. + +* Olga Rodimina for ``MenuSelectionManager`` implementation. + +* Jan Roehrich for ``BasicTreeUI`` and ``JTree`` fixes. + +* Julian Scheid for documentation updates and gjdoc support. + +* Christian Schlichtherle for zip fixes and cleanups. + +* Robert Schuster for documentation updates and beans fixes, + ``TreeNode`` enumerations and ``ActionCommand`` and various + fixes, XML and URL, AWT and Free Swing bug fixes. + +* Keith Seitz for lots of JDWP work. + +* Christian Thalinger for 64-bit cleanups, Configuration and VM + interface fixes and ``CACAO`` integration, ``fdlibm`` updates. + +* Gael Thomas for ``VMClassLoader`` boot packages support suggestions. + +* Andreas Tobler for Darwin and Solaris testing and fixing, ``Qt4`` + support for Darwin/OS X, ``Graphics2D`` support, ``gtk+`` + updates. + +* Dalibor Topic for better ``DEBUG`` support, build cleanups and + Kaffe integration. ``Qt4`` build infrastructure, ``SHA1PRNG`` + and ``GdkPixbugDecoder`` updates. + +* Tom Tromey for Eclipse integration, generics work, lots of bug fixes + and gcj integration including coordinating The Big Merge. + +* Mark Wielaard for bug fixes, packaging and release management, + ``Clipboard`` implementation, system call interrupts and network + timeouts and ``GdkPixpufDecoder`` fixes. + +In addition to the above, all of which also contributed time and energy in +testing GCC, we would like to thank the following for their contributions +to testing: + +* Michael Abd-El-Malek + +* Thomas Arend + +* Bonzo Armstrong + +* Steven Ashe + +* Chris Baldwin + +* David Billinghurst + +* Jim Blandy + +* Stephane Bortzmeyer + +* Horst von Brand + +* Frank Braun + +* Rodney Brown + +* Sidney Cadot + +* Bradford Castalia + +* Robert Clark + +* Jonathan Corbet + +* Ralph Doncaster + +* Richard Emberson + +* Levente Farkas + +* Graham Fawcett + +* Mark Fernyhough + +* Robert A. French + +* Jörgen Freyh + +* Mark K. Gardner + +* Charles-Antoine Gauthier + +* Yung Shing Gene + +* David Gilbert + +* Simon Gornall + +* Fred Gray + +* John Griffin + +* Patrik Hagglund + +* Phil Hargett + +* Amancio Hasty + +* Takafumi Hayashi + +* Bryan W. Headley + +* Kevin B. Hendricks + +* Joep Jansen + +* Christian Joensson + +* Michel Kern + +* David Kidd + +* Tobias Kuipers + +* Anand Krishnaswamy + +* A.O.V. Le Blanc + +* llewelly + +* Damon Love + +* Brad Lucier + +* Matthias Klose + +* Martin Knoblauch + +* Rick Lutowski + +* Jesse Macnish + +* Stefan Morrell + +* Anon A. Mous + +* Matthias Mueller + +* Pekka Nikander + +* Rick Niles + +* Jon Olson + +* Magnus Persson + +* Chris Pollard + +* Richard Polton + +* Derk Reefman + +* David Rees + +* Paul Reilly + +* Tom Reilly + +* Torsten Rueger + +* Danny Sadinoff + +* Marc Schifer + +* Erik Schnetter + +* Wayne K. Schroll + +* David Schuler + +* Vin Shelton + +* Tim Souder + +* Adam Sulmicki + +* Bill Thorson + +* George Talbot + +* Pedro A. M. Vazquez + +* Gregory Warnes + +* Ian Watson + +* David E. Young + +* And many others + +And finally we'd like to thank everyone who uses the compiler, provides +feedback and generally reminds us why we're doing this work in the first +place. \ No newline at end of file diff --git a/doc/contribute.rst b/doc/contribute.rst new file mode 100644 index 00000000000..643562efc63 --- /dev/null +++ b/doc/contribute.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _contributing: + +Contributing to GCC Development +------------------------------- + +If you would like to help pretest GCC releases to assure they work well, +current development sources are available via Git (see +https://gcc.gnu.org/git.html). Source and binary snapshots are +also available for FTP; see https://gcc.gnu.org/snapshots.html. + +If you would like to work on improvements to GCC, please read the +advice at these URLs: https://gcc.gnu.org/contribute.html, https://gcc.gnu.org/contributewhy.html. + +for information on how to make useful contributions and avoid +duplication of effort. Suggested projects are listed at +https://gcc.gnu.org/projects/. \ No newline at end of file diff --git a/doc/cppdiropts.rst b/doc/cppdiropts.rst new file mode 100644 index 00000000000..91568fe5612 --- /dev/null +++ b/doc/cppdiropts.rst @@ -0,0 +1,217 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. option:: -I {dir}, -iquote {dir}, -isystem {dir}, -idirafter {dir} + + Add the directory :samp:`{dir}` to the list of directories to be searched + for header files during preprocessing. + + .. only:: cpp + + See :ref:`search-path`. + + If :samp:`{dir}` begins with :samp:`=` or ``$SYSROOT``, then the :samp:`=` + or ``$SYSROOT`` is replaced by the sysroot prefix; see + :option:`--sysroot` and :option:`-isysroot`. + + Directories specified with :option:`-iquote` apply only to the quote + form of the directive, ``#include "file"``. + Directories specified with :option:`-I`, :option:`-isystem`, + or :option:`-idirafter` apply to lookup for both the + ``#include "file"`` and + ``#include `` directives. + + You can specify any number or combination of these options on the + command line to search for header files in several directories. + The lookup order is as follows: + + * For the quote form of the include directive, the directory of the current + file is searched first. + + * For the quote form of the include directive, the directories specified + by :option:`-iquote` options are searched in left-to-right order, + as they appear on the command line. + + * Directories specified with :option:`-I` options are scanned in + left-to-right order. + + * Directories specified with :option:`-isystem` options are scanned in + left-to-right order. + + * Standard system directories are scanned. + + * Directories specified with :option:`-idirafter` options are scanned in + left-to-right order. + + You can use :option:`-I` to override a system header + file, substituting your own version, since these directories are + searched before the standard system header file directories. + However, you should + not use this option to add directories that contain vendor-supplied + system header files; use :option:`-isystem` for that. + + The :option:`-isystem` and :option:`-idirafter` options also mark the directory + as a system directory, so that it gets the same special treatment that + is applied to the standard system directories. + + .. only:: cpp + + See :ref:`system-headers`. + + + If a standard system include directory, or a directory specified with + :option:`-isystem`, is also specified with :option:`-I`, the :option:`-I` + option is ignored. The directory is still searched but as a + system directory at its normal position in the system include chain. + This is to ensure that GCC's procedure to fix buggy system headers and + the ordering for the ``#include_next`` directive are not inadvertently + changed. + If you really need to change the search order for system directories, + use the :option:`-nostdinc` and/or :option:`-isystem` options. + + .. only:: cpp + + See :ref:`system-headers`. + + +.. option:: -I- + + Split the include path. + This option has been deprecated. Please use :option:`-iquote` instead for + :option:`-I` directories before the :option:`-I-` and remove the :option:`-I-` + option. + + Any directories specified with :option:`-I` + options before :option:`-I-` are searched only for headers requested with + ``#include "file"`` ; they are not searched for + ``#include ``. If additional directories are + specified with :option:`-I` options after the :option:`-I-`, those + directories are searched for all :samp:`#include` directives. + + In addition, :option:`-I-` inhibits the use of the directory of the current + file directory as the first search directory for ``#include + "file"``. There is no way to override this effect of :option:`-I-`. + + .. only:: cpp + + See :ref:`search-path`. + + +.. option:: -iprefix {prefix} + + Specify :samp:`{prefix}` as the prefix for subsequent :option:`-iwithprefix` + options. If the prefix represents a directory, you should include the + final :samp:`/`. + +.. option:: -iwithprefix {dir}, -iwithprefixbefore {dir} + + Append :samp:`{dir}` to the prefix specified previously with + :option:`-iprefix`, and add the resulting directory to the include search + path. :option:`-iwithprefixbefore` puts it in the same place :option:`-I` + would; :option:`-iwithprefix` puts it where :option:`-idirafter` would. + +.. option:: -isysroot {dir} + + This option is like the :option:`--sysroot` option, but applies only to + header files (except for Darwin targets, where it applies to both header + files and libraries). See the :option:`--sysroot` option for more + information. + +.. option:: -imultilib {dir} + + Use :samp:`{dir}` as a subdirectory of the directory containing + target-specific C++ headers. + +.. option:: -nostdinc + + Do not search the standard system directories for header files. + Only the directories explicitly specified with :option:`-I`, + :option:`-iquote`, :option:`-isystem`, and/or :option:`-idirafter` + options (and the directory of the current file, if appropriate) + are searched. + +.. option:: -nostdinc++ + + Do not search for header files in the C++-specific standard directories, + but do still search the other standard directories. (This option is + used when building the C++ library.) + +.. option:: -Wcomment, -Wcomments + + Warn whenever a comment-start sequence :samp:`/*` appears in a :samp:`/*` + comment, or whenever a backslash-newline appears in a :samp:`//` comment. + This warning is enabled by :option:`-Wall`. + +.. option:: -Wtrigraphs + +.. _wtrigraphs: + + Warn if any trigraphs are encountered that might change the meaning of + the program. Trigraphs within comments are not warned about, + except those that would form escaped newlines. + + This option is implied by :option:`-Wall`. If :option:`-Wall` is not + given, this option is still enabled unless trigraphs are enabled. To + get trigraph conversion without warnings, but get the other + :option:`-Wall` warnings, use :samp:`-trigraphs -Wall -Wno-trigraphs`. + +.. option:: -Wundef + + Warn if an undefined identifier is evaluated in an ``#if`` directive. + Such identifiers are replaced with zero. + +.. option:: -Wno-undef + + Default setting; overrides :option:`-Wundef`. + +.. option:: -Wexpansion-to-defined + + Warn whenever :samp:`defined` is encountered in the expansion of a macro + (including the case where the macro is expanded by an :samp:`#if` directive). + Such usage is not portable. + This warning is also enabled by :option:`-Wpedantic` and :option:`-Wextra`. + +.. option:: -Wunused-macros + + Warn about macros defined in the main file that are unused. A macro + is :dfn:`used` if it is expanded or tested for existence at least once. + The preprocessor also warns if the macro has not been used at the + time it is redefined or undefined. + + Built-in macros, macros defined on the command line, and macros + defined in include files are not warned about. + + .. note:: + + If a macro is actually used, but only used in skipped + conditional blocks, then the preprocessor reports it as unused. To avoid the + warning in such a case, you might improve the scope of the macro's + definition by, for example, moving it into the first skipped block. + Alternatively, you could provide a dummy use with something like: + + .. code-block:: c++ + + #if defined the_macro_causing_the_warning + #endif + +.. option:: -Wno-endif-labels + + Do not warn whenever an ``#else`` or an ``#endif`` are followed by text. + This sometimes happens in older programs with code of the form + + .. code-block:: c++ + + #if FOO + ... + #else FOO + ... + #endif FOO + + The second and third ``FOO`` should be in comments. + This warning is on by default. + +.. option:: -Wendif-labels + + Default setting; overrides :option:`-Wno-endif-labels`. \ No newline at end of file diff --git a/doc/cppenv.rst b/doc/cppenv.rst new file mode 100644 index 00000000000..f27338cfa2f --- /dev/null +++ b/doc/cppenv.rst @@ -0,0 +1,97 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. envvar:: CPATH, C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, OBJC_INCLUDE_PATH + + .. Commented out until ObjC++ is part of GCC: + @itemx OBJCPLUS_INCLUDE_PATH + + Each variable's value is a list of directories separated by a special + character, much like :envvar:`PATH`, in which to look for header files. + The special character, ``PATH_SEPARATOR``, is target-dependent and + determined at GCC build time. For Microsoft Windows-based targets it is a + semicolon, and for almost all other targets it is a colon. + + :envvar:`CPATH` specifies a list of directories to be searched as if + specified with :option:`-I`, but after any paths given with :option:`-I` + options on the command line. This environment variable is used + regardless of which language is being preprocessed. + + The remaining environment variables apply only when preprocessing the + particular language indicated. Each specifies a list of directories + to be searched as if specified with :option:`-isystem`, but after any + paths given with :option:`-isystem` options on the command line. + + In all these variables, an empty element instructs the compiler to + search its current working directory. Empty elements can appear at the + beginning or end of a path. For instance, if the value of + :envvar:`CPATH` is ``:/special/include``, that has the same + effect as :samp:`-I. -I/special/include`. + + .. only:: cpp + + See also :ref:`search-path`. + +.. index:: dependencies for make as output + +.. envvar:: DEPENDENCIES_OUTPUT + + If this variable is set, its value specifies how to output + dependencies for Make based on the non-system header files processed + by the compiler. System header files are ignored in the dependency + output. + + The value of :envvar:`DEPENDENCIES_OUTPUT` can be just a file name, in + which case the Make rules are written to that file, guessing the target + name from the source file name. Or the value can have the form + :samp:`{file}{target}`, in which case the rules are written to + file :samp:`{file}` using :samp:`{target}` as the target name. + + In other words, this environment variable is equivalent to combining + the options :option:`-MM` and :option:`-MF` + + .. only:: cpp + + (see :ref:`invocation`), + + .. only:: not cpp + + (see :ref:`preprocessor-options`), + + with an optional :option:`-MT` switch too. + +.. index:: dependencies for make as output + +.. envvar:: SUNPRO_DEPENDENCIES + + This variable is the same as :envvar:`DEPENDENCIES_OUTPUT` (see above), + except that system header files are not ignored, so it implies + :option:`-M` rather than :option:`-MM`. However, the dependence on the + main input file is omitted. + + .. only:: cpp + + See :ref:`invocation`. + + .. only:: not cpp + + See :ref:`preprocessor-options`. + +.. envvar:: SOURCE_DATE_EPOCH + + If this variable is set, its value specifies a UNIX timestamp to be + used in replacement of the current date and time in the ``__DATE__`` + and ``__TIME__`` macros, so that the embedded timestamps become + reproducible. + + The value of :envvar:`SOURCE_DATE_EPOCH` must be a UNIX timestamp, + defined as the number of seconds (excluding leap seconds) since + 01 Jan 1970 00:00:00 represented in ASCII; identical to the output of + ``date +%s`` on GNU/Linux and other systems that support the + ``%s`` extension in the ``date`` command. + + The value should be a known timestamp such as the last modification + time of the source or package and it should be set by the build + process. \ No newline at end of file diff --git a/doc/cppopts.rst b/doc/cppopts.rst new file mode 100644 index 00000000000..60d663e35d8 --- /dev/null +++ b/doc/cppopts.rst @@ -0,0 +1,556 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. option:: -D {name} + + Predefine :samp:`{name}` as a macro, with definition ``1``. + +.. option:: -D name=definition + + The contents of :samp:`{definition}` are tokenized and processed as if + they appeared during translation phase three in a :samp:`#define` + directive. In particular, the definition is truncated by + embedded newline characters. + + If you are invoking the preprocessor from a shell or shell-like + program you may need to use the shell's quoting syntax to protect + characters such as spaces that have a meaning in the shell syntax. + + If you wish to define a function-like macro on the command line, write + its argument list with surrounding parentheses before the equals sign + (if any). Parentheses are meaningful to most shells, so you should + quote the option. With :command:`sh` and :command:`csh`, + :option:`-D'name(args...)=definition'` works. + + :option:`-D` and :option:`-U` options are processed in the order they + are given on the command line. All :option:`-imacros file` and + :option:`-include file` options are processed after all + :option:`-D` and :option:`-U` options. + +.. option:: -U {name} + + Cancel any previous definition of :samp:`{name}`, either built in or + provided with a :option:`-D` option. + +.. option:: -include {file} + + Process :samp:`{file}` as if ``#include "file"`` appeared as the first + line of the primary source file. However, the first directory searched + for :samp:`{file}` is the preprocessor's working directory *instead of* + the directory containing the main source file. If not found there, it + is searched for in the remainder of the ``#include "..."`` search + chain as normal. + + If multiple :option:`-include` options are given, the files are included + in the order they appear on the command line. + +.. option:: -imacros {file} + + Exactly like :option:`-include`, except that any output produced by + scanning :samp:`{file}` is thrown away. Macros it defines remain defined. + This allows you to acquire all the macros from a header without also + processing its declarations. + + All files specified by :option:`-imacros` are processed before all files + specified by :option:`-include`. + +.. option:: -undef + + Do not predefine any system-specific or GCC-specific macros. The + standard predefined macros remain defined. + + .. only:: cpp + + See :ref:`standard-predefined-macros`. + +.. option:: -pthread + + Define additional macros required for using the POSIX threads library. + You should use this option consistently for both compilation and linking. + This option is supported on GNU/Linux targets, most other Unix derivatives, + and also on x86 Cygwin and MinGW targets. + +.. index:: make, dependencies, make + +.. option:: -M + + Instead of outputting the result of preprocessing, output a rule + suitable for :command:`make` describing the dependencies of the main + source file. The preprocessor outputs one :command:`make` rule containing + the object file name for that source file, a colon, and the names of all + the included files, including those coming from :option:`-include` or + :option:`-imacros` command-line options. + + Unless specified explicitly (with :option:`-MT` or :option:`-MQ`), the + object file name consists of the name of the source file with any + suffix replaced with object file suffix and with any leading directory + parts removed. If there are many included files then the rule is + split into several lines using :samp:`\\` -newline. The rule has no + commands. + + This option does not suppress the preprocessor's debug output, such as + :option:`-dM`. To avoid mixing such debug output with the dependency + rules you should explicitly specify the dependency output file with + :option:`-MF`, or use an environment variable like + :envvar:`DEPENDENCIES_OUTPUT` (see :ref:`environment-variables`). Debug output + is still sent to the regular output stream as normal. + + Passing :option:`-M` to the driver implies :option:`-E`, and suppresses + warnings with an implicit :option:`-w`. + +.. option:: -MM + + Like :option:`-M` but do not mention header files that are found in + system header directories, nor header files that are included, + directly or indirectly, from such a header. + + This implies that the choice of angle brackets or double quotes in an + :samp:`#include` directive does not in itself determine whether that + header appears in :option:`-MM` dependency output. + +.. option:: -MF {file} + + When used with :option:`-M` or :option:`-MM`, specifies a + file to write the dependencies to. If no :option:`-MF` switch is given + the preprocessor sends the rules to the same place it would send + preprocessed output. + + When used with the driver options :option:`-MD` or :option:`-MMD`, + :option:`-MF` overrides the default dependency output file. + + If :samp:`{file}` is :samp:`-`, then the dependencies are written to :samp:`stdout`. + +.. option:: -MG + + In conjunction with an option such as :option:`-M` requesting + dependency generation, :option:`-MG` assumes missing header files are + generated files and adds them to the dependency list without raising + an error. The dependency filename is taken directly from the + ``#include`` directive without prepending any path. :option:`-MG` + also suppresses preprocessed output, as a missing header file renders + this useless. + + This feature is used in automatic updating of makefiles. + +.. option:: -Mno-modules + + Disable dependency generation for compiled module interfaces. + +.. option:: -MP + + This option instructs CPP to add a phony target for each dependency + other than the main file, causing each to depend on nothing. These + dummy rules work around errors :command:`make` gives if you remove header + files without updating the :samp:`Makefile` to match. + + This is typical output: + + .. code-block:: c++ + + test.o: test.c test.h + + test.h: + +.. option:: -MT {target} + + Change the target of the rule emitted by dependency generation. By + default CPP takes the name of the main input file, deletes any + directory components and any file suffix such as :samp:`.c`, and + appends the platform's usual object suffix. The result is the target. + + An :option:`-MT` option sets the target to be exactly the string you + specify. If you want multiple targets, you can specify them as a single + argument to :option:`-MT`, or use multiple :option:`-MT` options. + + For example, ``-MT '$(objpfx)foo.o'`` might give + + .. code-block:: c++ + + $(objpfx)foo.o: foo.c + +.. option:: -MQ {target} + + Same as :option:`-MT`, but it quotes any characters which are special to + Make. ``-MQ '$(objpfx)foo.o'`` gives + + .. code-block:: c++ + + $$(objpfx)foo.o: foo.c + + The default target is automatically quoted, as if it were given with + :option:`-MQ`. + +.. option:: -MD + + :option:`-MD` is equivalent to :option:`-M -MF file`, except that + :option:`-E` is not implied. The driver determines :samp:`{file}` based on + whether an :option:`-o` option is given. If it is, the driver uses its + argument but with a suffix of :samp:`.d`, otherwise it takes the name + of the input file, removes any directory components and suffix, and + applies a :samp:`.d` suffix. + + If :option:`-MD` is used in conjunction with :option:`-E`, any + :option:`-o` switch is understood to specify the dependency output file + (see :option:`-MF`), but if used without :option:`-E`, each :option:`-o` + is understood to specify a target object file. + + Since :option:`-E` is not implied, :option:`-MD` can be used to generate + a dependency output file as a side effect of the compilation process. + +.. option:: -MMD + + Like :option:`-MD` except mention only user header files, not system + header files. + +.. option:: -fpreprocessed + + Indicate to the preprocessor that the input file has already been + preprocessed. This suppresses things like macro expansion, trigraph + conversion, escaped newline splicing, and processing of most directives. + The preprocessor still recognizes and removes comments, so that you can + pass a file preprocessed with :option:`-C` to the compiler without + problems. In this mode the integrated preprocessor is little more than + a tokenizer for the front ends. + + :option:`-fpreprocessed` is implicit if the input file has one of the + extensions :samp:`.i`, :samp:`.ii` or :samp:`.mi`. These are the + extensions that GCC uses for preprocessed files created by + :option:`-save-temps`. + +.. option:: -fdirectives-only + + When preprocessing, handle directives, but do not expand macros. + + The option's behavior depends on the :option:`-E` and :option:`-fpreprocessed` + options. + + With :option:`-E`, preprocessing is limited to the handling of directives + such as ``#define``, ``#ifdef``, and ``#error``. Other + preprocessor operations, such as macro expansion and trigraph + conversion are not performed. In addition, the :option:`-dD` option is + implicitly enabled. + + With :option:`-fpreprocessed`, predefinition of command line and most + builtin macros is disabled. Macros such as ``__LINE__``, which are + contextually dependent, are handled normally. This enables compilation of + files previously preprocessed with ``-E -fdirectives-only``. + + With both :option:`-E` and :option:`-fpreprocessed`, the rules for + :option:`-fpreprocessed` take precedence. This enables full preprocessing of + files previously preprocessed with ``-E -fdirectives-only``. + +.. option:: -fdollars-in-identifiers + + Accept :samp:`$` in identifiers. + + .. only:: cpp + + See :ref:`identifier-characters`. + +.. option:: -fextended-identifiers + + Accept universal character names and extended characters in + identifiers. This option is enabled by default for C99 (and later C + standard versions) and C++. + +.. option:: -fno-canonical-system-headers + + When preprocessing, do not shorten system header paths with canonicalization. + +.. option:: -fmax-include-depth={depth} + + Set the maximum depth of the nested #include. The default is 200. + +.. option:: -ftabstop={width} + + Set the distance between tab stops. This helps the preprocessor report + correct column numbers in warnings or errors, even if tabs appear on the + line. If the value is less than 1 or greater than 100, the option is + ignored. The default is 8. + +.. option:: -ftrack-macro-expansion[={level}] + + Track locations of tokens across macro expansions. This allows the + compiler to emit diagnostic about the current macro expansion stack + when a compilation error occurs in a macro expansion. Using this + option makes the preprocessor and the compiler consume more + memory. The :samp:`{level}` parameter can be used to choose the level of + precision of token location tracking thus decreasing the memory + consumption if necessary. Value :samp:`0` of :samp:`{level}` de-activates + this option. Value :samp:`1` tracks tokens locations in a + degraded mode for the sake of minimal memory overhead. In this mode + all tokens resulting from the expansion of an argument of a + function-like macro have the same location. Value :samp:`2` tracks + tokens locations completely. This value is the most memory hungry. + When this option is given no argument, the default parameter value is + :samp:`2`. + + Note that ``-ftrack-macro-expansion=2`` is activated by default. + +.. option:: -fmacro-prefix-map={old}={new} + + When preprocessing files residing in directory :samp:`{old}`, + expand the ``__FILE__`` and ``__BASE_FILE__`` macros as if the + files resided in directory :samp:`{new}` instead. This can be used + to change an absolute path to a relative path by using :samp:`.` for + :samp:`{new}` which can result in more reproducible builds that are + location independent. This option also affects + ``__builtin_FILE()`` during compilation. See also + :option:`-ffile-prefix-map`. + +.. index:: character set, execution + +.. option:: -fexec-charset={charset} + + Set the execution character set, used for string and character + constants. The default is UTF-8. :samp:`{charset}` can be any encoding + supported by the system's ``iconv`` library routine. + +.. index:: character set, wide execution + +.. option:: -fwide-exec-charset={charset} + + Set the wide execution character set, used for wide string and + character constants. The default is one of UTF-32BE, UTF-32LE, UTF-16BE, + or UTF-16LE, whichever corresponds to the width of ``wchar_t`` and the + big-endian or little-endian byte order being used for code generation. As + with :option:`-fexec-charset`, :samp:`{charset}` can be any encoding supported + by the system's ``iconv`` library routine; however, you will have + problems with encodings that do not fit exactly in ``wchar_t``. + +.. index:: character set, input + +.. option:: -finput-charset={charset} + + Set the input character set, used for translation from the character + set of the input file to the source character set used by GCC. If the + locale does not specify, or GCC cannot get this information from the + locale, the default is UTF-8. This can be overridden by either the locale + or this command-line option. Currently the command-line option takes + precedence if there's a conflict. :samp:`{charset}` can be any encoding + supported by the system's ``iconv`` library routine. + +.. only:: not cpp + + .. option:: -fpch-deps + + When using precompiled headers (see :ref:`precompiled-headers`), this flag + causes the dependency-output flags to also list the files from the + precompiled header's dependencies. If not specified, only the + precompiled header are listed and not the files that were used to + create it, because those files are not consulted when a precompiled + header is used. + + .. option:: -fpch-preprocess + + This option allows use of a precompiled header (see :ref:`precompiled-headers`) together with :option:`-E`. It inserts a special ``#pragma``, + ``#pragma GCC pch_preprocess "filename"`` in the output to mark + the place where the precompiled header was found, and its :samp:`{filename}`. + When :option:`-fpreprocessed` is in use, GCC recognizes this ``#pragma`` + and loads the PCH. + + This option is off by default, because the resulting preprocessed output + is only really suitable as input to GCC. It is switched on by + :option:`-save-temps`. + + You should not write this ``#pragma`` in your own code, but it is + safe to edit the filename if the PCH file is available in a different + location. The filename may be absolute or it may be relative to GCC's + current directory. + +.. option:: -fworking-directory + + Enable generation of linemarkers in the preprocessor output that + let the compiler know the current working directory at the time of + preprocessing. When this option is enabled, the preprocessor + emits, after the initial linemarker, a second linemarker with the + current working directory followed by two slashes. GCC uses this + directory, when it's present in the preprocessed input, as the + directory emitted as the current working directory in some debugging + information formats. This option is implicitly enabled if debugging + information is enabled, but this can be inhibited with the negated + form :option:`-fno-working-directory`. If the :option:`-P` flag is + present in the command line, this option has no effect, since no + ``#line`` directives are emitted whatsoever. + +.. option:: -fno-working-directory + + Default setting; overrides :option:`-fworking-directory`. + +.. option:: -A {predicate}={answer} + + Make an assertion with the predicate :samp:`{predicate}` and answer + :samp:`{answer}`. This form is preferred to the older form :option:`-A + predicate(answer)`, which is still supported, because + it does not use shell special characters. + + .. only:: cpp + + See :ref:`obsolete-features`. + +.. option:: -A -predicate=answer + + Cancel an assertion with the predicate :samp:`{predicate}` and answer + :samp:`{answer}`. + +.. option:: -C + + Do not discard comments. All comments are passed through to the output + file, except for comments in processed directives, which are deleted + along with the directive. + + You should be prepared for side effects when using :option:`-C` ; it + causes the preprocessor to treat comments as tokens in their own right. + For example, comments appearing at the start of what would be a + directive line have the effect of turning that line into an ordinary + source line, since the first token on the line is no longer a :samp:`#`. + +.. option:: -CC + + Do not discard comments, including during macro expansion. This is + like :option:`-C`, except that comments contained within macros are + also passed through to the output file where the macro is expanded. + + In addition to the side effects of the :option:`-C` option, the + :option:`-CC` option causes all C++-style comments inside a macro + to be converted to C-style comments. This is to prevent later use + of that macro from inadvertently commenting out the remainder of + the source line. + + The :option:`-CC` option is generally used to support lint comments. + +.. option:: -P + + Inhibit generation of linemarkers in the output from the preprocessor. + This might be useful when running the preprocessor on something that is + not C code, and will be sent to a program which might be confused by the + linemarkers. + + .. only:: cpp + + See :ref:`preprocessor-output`. + + .. index:: traditional C language, C language, traditional + +.. option:: -traditional, -traditional-cpp + + Try to imitate the behavior of pre-standard C preprocessors, as + opposed to ISO C preprocessors. + + .. only:: cpp + + See :ref:`traditional-mode`. + + .. only:: not cpp + + See the GNU CPP manual for details. + + Note that GCC does not otherwise attempt to emulate a pre-standard + C compiler, and these options are only supported with the :option:`-E` + switch, or when invoking CPP explicitly. + +.. option:: -trigraphs + + Support ISO C trigraphs. + These are three-character sequences, all starting with :samp:`??`, that + are defined by ISO C to stand for single characters. For example, + :samp:`??/` stands for :samp:`\\`, so :samp:`??/n` is a character + constant for a newline. + + .. only:: cpp + + See :ref:`initial-processing`. + + .. only:: not cpp + + The nine trigraphs and their replacements are + + .. code-block:: + + Trigraph: ??( ??) ??< ??> ??= ??/ ??' ??! ??- + Replacement: [ ] { } # \ ^ | ~ + + By default, GCC ignores trigraphs, but in + standard-conforming modes it converts them. See the :option:`-std` and + :option:`-ansi` options. + +.. option:: -remap + + Enable special code to work around file systems which only permit very + short file names, such as MS-DOS. + +.. option:: -H + + Print the name of each header file used, in addition to other normal + activities. Each name is indented to show how deep in the + :samp:`#include` stack it is. Precompiled header files are also + printed, even if they are found to be invalid; an invalid precompiled + header file is printed with :samp:`...x` and a valid one with :samp:`...!` . + +.. option:: -dletters + + Says to make debugging dumps during compilation as specified by + :samp:`{letters}`. The flags documented here are those relevant to the + preprocessor. Other :samp:`{letters}` are interpreted + by the compiler proper, or reserved for future versions of GCC, and so + are silently ignored. If you specify :samp:`{letters}` whose behavior + conflicts, the result is undefined. + + .. only:: not cpp + + See :ref:`developer-options`, for more information. + + .. option:: -dM + + Instead of the normal output, generate a list of :samp:`#define` + directives for all the macros defined during the execution of the + preprocessor, including predefined macros. This gives you a way of + finding out what is predefined in your version of the preprocessor. + Assuming you have no file :samp:`foo.h`, the command + + .. code-block:: c++ + + touch foo.h; cpp -dM foo.h + + shows all the predefined macros. + + .. only:: cpp + + If you use :option:`-dM` without the :option:`-E` option, :option:`-dM` is + interpreted as a synonym for :option:`-fdump-rtl-mach`. + See :ref:`developer-options`. + + .. option:: -dD + + Like :option:`-dM` except in two respects: it does *not* include the + predefined macros, and it outputs *both* the :samp:`#define` + directives and the result of preprocessing. Both kinds of output go to + the standard output file. + + .. option:: -dN + + Like :option:`-dD`, but emit only the macro names, not their expansions. + + .. option:: -dI + + Output :samp:`#include` directives in addition to the result of + preprocessing. + + .. option:: -dU + + Like :option:`-dD` except that only macros that are expanded, or whose + definedness is tested in preprocessor directives, are output; the + output is delayed until the use or test of the macro; and + :samp:`#undef` directives are also output for macros tested but + undefined at the time. + +.. option:: -fdebug-cpp + + This option is only useful for debugging GCC. When used from CPP or with + :option:`-E`, it dumps debugging information about location maps. Every + token in the output is preceded by the dump of the map its location + belongs to. + + When used from GCC without :option:`-E`, this option has no effect. \ No newline at end of file diff --git a/doc/cppwarnopts.rst b/doc/cppwarnopts.rst new file mode 100644 index 00000000000..8e9e9e7276f --- /dev/null +++ b/doc/cppwarnopts.rst @@ -0,0 +1,4 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. \ No newline at end of file diff --git a/doc/favicon.ico b/doc/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..42e8969edc8c3345e10706d5e1c4f57ed92469e1 GIT binary patch literal 766 zc-muNU<5)11py$*!tjELfkBLcfk6X^6@b_Qh(Y4GKt!M$!}^6i46mO*VxS9P6a)eR d1|=|1pdKG+G(~*k?PFj-)lVvaaN9S;001VUA|?O; literal 0 Hc-jL100001 diff --git a/doc/funding.rst b/doc/funding.rst new file mode 100644 index 00000000000..ee4daca6fd7 --- /dev/null +++ b/doc/funding.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Funding Free Software +===================== + +If you want to have more free software a few years from now, it makes +sense for you to help encourage people to contribute funds for its +development. The most effective approach known is to encourage +commercial redistributors to donate. + +Users of free software systems can boost the pace of development by +encouraging for-a-fee distributors to donate part of their selling price +to free software developers-the Free Software Foundation, and others. + +The way to convince distributors to do this is to demand it and expect +it from them. So when you compare distributors, judge them partly by +how much they give to free software development. Show distributors +they must compete to be the one who gives the most. + +To make this approach work, you must insist on numbers that you can +compare, such as, 'We will donate ten dollars to the Frobnitz project +for each disk sold.' Don't be satisfied with a vague promise, such as +'A portion of the profits are donated,' since it doesn't give a basis +for comparison. + +Even a precise fraction 'of the profits from this disk' is not very +meaningful, since creative accounting and unrelated business decisions +can greatly alter what fraction of the sales price counts as profit. +If the price you pay is $50, ten percent of the profit is probably +less than a dollar; it might be a few cents, or nothing at all. + +Some redistributors do development work themselves. This is useful too; +but to keep everyone honest, you need to inquire how much they do, and +what kind. Some kinds of development make much more long-term +difference than others. For example, maintaining a separate version of +a program contributes very little; maintaining the standard version of a +program for the whole community contributes much. Easy new ports +contribute little, since someone else would surely do them; difficult +ports such as adding a new CPU to the GNU Compiler Collection contribute more; +major new features or packages contribute the most. + +By establishing the idea that supporting further development is 'the +proper thing to do' when distributing free software for a fee, we can +assure a steady flow of resources into making more free software. \ No newline at end of file diff --git a/doc/gcc_sphinx.py b/doc/gcc_sphinx.py new file mode 100644 index 00000000000..2ef15aef944 --- /dev/null +++ b/doc/gcc_sphinx.py @@ -0,0 +1,44 @@ +# GCC Sphinx customization + +__version__ = '1.0' + + +def setup(app): + app.add_object_type('gcc-attr', 'gcc-attr', objname='GCC attribute', + indextemplate='pair: %s; attribute') + app.add_object_type('fn-attr', 'fn-attr', objname='function attribute', + indextemplate='pair: %s; function attribute') + app.add_object_type('var-attr', 'var-attr', objname='variable attribute', + indextemplate='pair: %s; variable attribute') + app.add_object_type('type-attr', 'type-attr', objname='type attribute', + indextemplate='pair: %s; variable attribute') + app.add_object_type('enum-attr', 'enum-attr', objname='Enumerator attribute', + indextemplate='pair: %s; enumerator attribute') + app.add_object_type('label-attr', 'label-attr', objname='Label attribute', + indextemplate='pair: %s; label attribute') + app.add_object_type('gcc-param', 'gcc-param', objname='GCC parameter', + indextemplate='pair: %s; parameter') + + targets = (('AArch64 ', 'aarch64'), ('AMD GCN ', 'amd-gcn'), ('ARC ', 'arc'), ('ARM ', 'arm'), ('AVR ', 'avr'), + ('Blackfin ', 'blackfin'), ('BPF ', 'bpf'), ('C-SKY ', 'c-sky'), + ('Epiphany ', 'epiphany'), ('H8/300 ', 'h8-300'), ('IA-64 ', 'ia-64'), ('LoongArch', 'loongarch'), ('M32C ', 'm32c'), + ('M32R/D ', 'm32r-d'), ('m68k ', 'm68k'), ('MCORE ', 'mcore'), ('MeP ', 'mep'), + ('MicroBlaze ', 'microblaze'), ('Microsoft Windows ', 'microsoft-windows'), ('MIPS ', 'mips'), + ('MSP430 ', 'msp430'), ('NDS32 ', 'nds32'), ('Nios II ', 'nios-ii'), ('Nvidia PTX ', 'nvidia-ptx'), + ('PowerPC ', 'powerpc'), ('RISC-V ', 'risc-v'), ('RL78 ', 'rl78'), ('RX ', 'rx'), ('S/390 ', 's-390'), + ('SH ', 'sh'), ('Symbian OS ', 'symbian-os'), ('V850 ', 'v850'), ('Visium ', 'visium'), ('x86 ', 'x86'), + ('Xstormy16 ', 'xstormy16')) + + for target_name, target in targets: + app.add_object_type(f'{target}-fn-attr', f'{target}-fn-attr', objname=f'{target_name} function attribute', + indextemplate=f'pair: %s; {target_name} function attribute') + app.add_object_type(f'{target}-var-attr', f'{target}-var-attr', objname=f'{target_name} variable attribute', + indextemplate=f'pair: %s; {target_name} variable attribute') + app.add_object_type(f'{target}-type-attr', f'{target}-type-attr', objname=f'{target_name} type attribute', + indextemplate=f'pair: %s; {target_name} type attribute') + + return dict( + version=__version__, + parallel_read_safe=True, + parallel_write_safe=True + ) diff --git a/doc/gnu.rst b/doc/gnu.rst new file mode 100644 index 00000000000..930659b250b --- /dev/null +++ b/doc/gnu.rst @@ -0,0 +1,19 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gnu-project: + +The GNU Project and GNU/Linux +============================= + +The GNU Project was launched in 1984 to develop a complete Unix-like +operating system which is free software: the GNU system. (GNU is a +recursive acronym for 'GNU's Not Unix'; it is pronounced +'guh-NEW'.) Variants of the GNU operating system, which use the +kernel Linux, are now widely used; though these systems are often +referred to as 'Linux', they are more accurately called GNU/Linux +systems. + +For more information, see: https://www.gnu.org/ and https://www.gnu.org/gnu/linux-and-gnu.html. \ No newline at end of file diff --git a/doc/gnu_free_documentation_license.rst b/doc/gnu_free_documentation_license.rst new file mode 100644 index 00000000000..5a7d110efde --- /dev/null +++ b/doc/gnu_free_documentation_license.rst @@ -0,0 +1,476 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gnu_fdl: + +****************************** +GNU Free Documentation License +****************************** + +Version 1.3, 3 November 2008 + +Copyright 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc +https://fsf.org/ + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + +Preamble +~~~~~~~~ + +The purpose of this License is to make a manual, textbook, or other +functional and useful document "free" in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of "copyleft", which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + +1. APPLICABILITY AND DEFINITIONS +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The **Document**, below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as "**you**". You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A "**Modified Version**" of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A "**Secondary Section**" is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall subject +(or to related matters) and contains nothing that could fall directly +within that overall subject. (Thus, if the Document is in part a +textbook of mathematics, a Secondary Section may not explain any +mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The "**Invariant Sections**" are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The "**Cover Texts**" are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A "**Transparent**" copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not "Transparent" is called **Opaque**. + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML, PostScript or PDF designed for human modification. Examples of +transparent image formats include PNG, XCF and JPG. Opaque formats +include proprietary formats that can be read and edited only by +proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the +machine-generated HTML, PostScript or PDF produced by some word +processors for output purposes only. + +The "**Title Page**" means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, "Title Page" means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +The "**publisher**" means any person or entity that distributes +copies of the Document to the public. + +A section "**Entitled XYZ**" means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as "**Acknowledgements**", +"**Dedications**", "**Endorsements**", or "**History**".) +To "**Preserve the Title**" +of such a section when you modify the Document means that it remains a +section "Entitled XYZ" according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + +2. VERBATIM COPYING +~~~~~~~~~~~~~~~~~~~ + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + +3. COPYING IN QUANTITY +~~~~~~~~~~~~~~~~~~~~~~ + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + +4. MODIFICATIONS +~~~~~~~~~~~~~~~~ + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +A. Use in the Title Page (and on the covers, if any) a title distinct + from that of the Document, and from those of previous versions + (which should, if there were any, be listed in the History section + of the Document). You may use the same title as a previous version + if the original publisher of that version gives permission. + +B. List on the Title Page, as authors, one or more persons or entities + responsible for authorship of the modifications in the Modified + Version, together with at least five of the principal authors of the + Document (all of its principal authors, if it has fewer than five), + unless they release you from this requirement. + +C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + +D. Preserve all the copyright notices of the Document. + +E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + +F. Include, immediately after the copyright notices, a license notice + giving the public permission to use the Modified Version under the + terms of this License, in the form shown in the Addendum below. + +G. Preserve in that license notice the full lists of Invariant Sections + and required Cover Texts given in the Document's license notice. +H. Include an unaltered copy of this License. + +I. Preserve the section Entitled "History", Preserve its Title, and add + to it an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title Page. If + there is no section Entitled "History" in the Document, create one + stating the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the Modified + Version as stated in the previous sentence. + +J. Preserve the network location, if any, given in the Document for + public access to a Transparent copy of the Document, and likewise + the network locations given in the Document for previous versions + it was based on. These may be placed in the "History" section. + You may omit a network location for a work that was published at + least four years before the Document itself, or if the original + publisher of the version it refers to gives permission. + +K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the section all + the substance and tone of each of the contributor acknowledgements + and/or dedications given therein. + +L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section titles. + +M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + +N. Do not retitle any existing section to be Entitled "Endorsements" + or to conflict in title with any Invariant Section. + +O. Preserve any Warranty Disclaimers. + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled "Endorsements", provided it contains +nothing but endorsements of your Modified Version by various +parties---for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + +5. COMBINING DOCUMENTS +~~~~~~~~~~~~~~~~~~~~~~ + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled "History" +in the various original documents, forming one section Entitled +"History"; likewise combine any sections Entitled "Acknowledgements", +and any sections Entitled "Dedications". You must delete all sections +Entitled "Endorsements". + +6. COLLECTIONS OF DOCUMENTS +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + +7. AGGREGATION WITH INDEPENDENT WORKS +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an "aggregate" if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + +8. TRANSLATION +~~~~~~~~~~~~~~ + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled "Acknowledgements", +"Dedications", or "History", the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + +9. TERMINATION +~~~~~~~~~~~~~~ + +You may not copy, modify, sublicense, or distribute the Document +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense, or distribute it is void, and +will automatically terminate your rights under this License. + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, receipt of a copy of some or all of the same material does +not give you any rights to use it. + +10. FUTURE REVISIONS OF THIS LICENSE +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. See +https://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. If the Document +specifies that a proxy can decide which future versions of this +License can be used, that proxy's public statement of acceptance of a +version permanently authorizes you to choose that version for the +Document. + +11. RELICENSING +~~~~~~~~~~~~~~~ + +"Massive Multiauthor Collaboration Site" (or "MMC Site") means any +World Wide Web server that publishes copyrightable works and also +provides prominent facilities for anybody to edit those works. A +public wiki that anybody can edit is an example of such a server. A +"Massive Multiauthor Collaboration" (or "MMC") contained in the +site means any set of copyrightable works thus published on the MMC +site. + +"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 +license published by Creative Commons Corporation, a not-for-profit +corporation with a principal place of business in San Francisco, +California, as well as future copyleft versions of that license +published by that same organization. + +"Incorporate" means to publish or republish a Document, in whole or +in part, as part of another Document. + +An MMC is "eligible for relicensing" if it is licensed under this +License, and if all works that were first published under this License +somewhere other than this MMC, and subsequently incorporated in whole +or in part into the MMC, (1) had no cover texts or invariant sections, +and (2) were thus incorporated prior to November 1, 2008. + +The operator of an MMC Site may republish an MMC contained in the site +under CC-BY-SA on the same site at any time before August 1, 2009, +provided the MMC is eligible for relicensing. + +ADDENDUM: How to use this License for your documents +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + + Copyright © YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled "GNU + Free Documentation License". + + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the "with ... Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with the + Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. \ No newline at end of file diff --git a/doc/gpl-3.0.rst b/doc/gpl-3.0.rst new file mode 100644 index 00000000000..07ffd72b375 --- /dev/null +++ b/doc/gpl-3.0.rst @@ -0,0 +1,707 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +GNU GENERAL PUBLIC LICENSE +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. https://fsf.org/ + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + +Preamble +######## + +The GNU General Public License is a free, copyleft license for software +and other kinds of works. + +The licenses for most software and other practical works are designed to +take away your freedom to share and change the works. By contrast, the +GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not price. +Our General Public Licenses are designed to make sure that you have the +freedom to distribute copies of free software (and charge for them if +you wish), that you receive source code or can get it if you want it, +that you can change the software or use pieces of it in new free +programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these +rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis +or for a fee, you must pass on to the recipients the same freedoms that +you received. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + +Developers that use the GNU GPL protect your rights with two steps: (1) +assert copyright on the software, and (2) offer you this License giving +you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + +Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of protecting +users' freedom to change the software. The systematic pattern of such +abuse occurs in the area of products for individuals to use, which is +precisely where it is most unacceptable. Therefore, we have designed +this version of the GPL to prohibit the practice for those products. If +such problems arise substantially in other domains, we stand ready to +extend this provision to those domains in future versions of the GPL, as +needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and +modification follow. + +TERMS AND CONDITIONS +#################### + +0. Definitions. +^^^^^^^^^^^^^^^ + +"This License" refers to version 3 of the GNU General Public License. + +"Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + +"The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + +To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + +A "covered work" means either the unmodified Program or a work based on +the Program. + +To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + +To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays "Appropriate Legal Notices" to +the extent that it includes a convenient and prominently visible feature +that (1) displays an appropriate copyright notice, and (2) tells the +user that there is no warranty for the work (except to the extent that +warranties are provided), that licensees may convey the work under this +License, and how to view a copy of this License. If the interface +presents a list of user commands or options, such as a menu, a prominent +item in the list meets this criterion. + +1. Source Code. +^^^^^^^^^^^^^^^ + +The "source code" for a work means the preferred form of the work for +making modifications to it. "Object code" means any non-source form of a +work. + +A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that is +widely used among developers working in that language. + +The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that Major +Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A "Major +Component", in this context, means a major essential component (kernel, +window system, and so on) of the specific operating system (if any) on +which the executable work runs, or a compiler used to produce the work, +or an object code interpreter used to run it. + +The "Corresponding Source" for a work in object code form means all the +source code needed to generate, install, and (for an executable work) +run the object code and to modify the work, including scripts to control +those activities. However, it does not include the work's System +Libraries, or general-purpose tools or generally available free programs +which are used unmodified in performing those activities but which are +not part of the work. For example, Corresponding Source includes +interface definition files associated with source files for the work, +and the source code for shared libraries and dynamically linked +subprograms that the work is specifically designed to require, such as +by intimate data communication or control flow between those subprograms +and other parts of the work. + +The Corresponding Source need not include anything that users can +regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same +work. + +2. Basic Permissions. +^^^^^^^^^^^^^^^^^^^^^ + +All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, +without conditions so long as your license otherwise remains in force. +You may convey covered works to others for the sole purpose of having +them make modifications exclusively for you, or provide you with +facilities for running those works, provided that you comply with the +terms of this License in conveying all material for which you do not +control copyright. Those thus making or running the covered works for +you must do so exclusively on your behalf, under your direction and +control, on terms that prohibit them from making any copies of your +copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the +conditions stated below. Sublicensing is not allowed; section 10 makes +it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article 11 +of the WIPO copyright treaty adopted on 20 December 1996, or similar +laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to the +covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + +4. Conveying Verbatim Copies. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; keep +intact all notices stating that this License and any non-permissive +terms added in accord with section 7 apply to the code; keep intact all +notices of the absence of any warranty; and give all recipients a copy +of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and +you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the terms +of section 4, provided that you also meet all of these conditions: + +a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + +b) The work must carry prominent notices stating that it is released + under this License and any conditions added under section 7. This + requirement modifies the requirement in section 4 to "keep intact + all notices". + +c) You must license the entire work, as a whole, under this License + to anyone who comes into possession of a copy. This License will + therefore apply, along with any applicable section 7 additional + terms, to the whole of the work, and all its parts, regardless of + how they are packaged. This License gives no permission to license + the work in any other way, but it does not invalidate such + permission if you have separately received it. + +d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + +A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, and +which are not combined with it such as to form a larger program, in or +on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not used +to limit the access or legal rights of the compilation's users beyond +what the individual works permit. Inclusion of a covered work in an +aggregate does not cause this License to apply to the other parts of the +aggregate. + +6. Conveying Non-Source Forms. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You may convey a covered work in object code form under the terms of +sections 4 and 5, provided that you also convey the machine-readable +Corresponding Source under the terms of this License, in one of these +ways: + +a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + +b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the Corresponding + Source from a network server at no charge. + +c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + +d) Convey the object code by offering access from a designated place + (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + +e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be included +in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for +incorporation into a dwelling. In determining whether a product is a +consumer product, doubtful cases shall be resolved in favor of coverage. +For a particular product received by a particular user, "normally used" +refers to a typical or common use of that class of product, regardless +of the status of the particular user or of the way in which the +particular user actually uses, or expects or is expected to use, the +product. A product is a consumer product regardless of whether the +product has substantial commercial, industrial or non-consumer uses, +unless such uses represent the only significant mode of use of the +product. + +"Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product +from a modified version of its Corresponding Source. The information +must suffice to ensure that the continued functioning of the modified +object code is in no case prevented or interfered with solely because +modification has been made. + +If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied by +the Installation Information. But this requirement does not apply if +neither you nor any third party retains the ability to install modified +object code on the User Product (for example, the work has been +installed in ROM). + +The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in +accord with this section must be in a format that is publicly documented +(and with an implementation available to the public in source code +form), and must require no special password or key for unpacking, +reading or copying. + +7. Additional Terms. +^^^^^^^^^^^^^^^^^^^^ + +"Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by this +License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove +any additional permissions from that copy, or from any part of it. +(Additional permissions may be written to require their own removal in +certain cases when you modify the work.) You may place additional +permissions on material, added by you to a covered work, for which you +have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders +of that material) supplement the terms of this License with terms: + +a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + +b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + +c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + +d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + +e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + +f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions + of it) with contractual assumptions of liability to the recipient, + for any liability that these contractual assumptions directly + impose on those licensors and authors. + +All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains a +further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms of +that license document, provided that the further restriction does not +survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must +place, in the relevant source files, a statement of the additional terms +that apply to those files, or a notice indicating where to find the +applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; the above +requirements apply either way. + +8. Termination. +^^^^^^^^^^^^^^^ + +You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally terminates +your license, and (b) permanently, if the copyright holder fails to +notify you of the violation by some reasonable means prior to 60 days +after the cessation. + +Moreover, your license from a particular copyright holder is reinstated +permanently if the copyright holder notifies you of the violation by +some reasonable means, this is the first time you have received notice +of violation of this License (for any work) from that copyright holder, +and you cure the violation prior to 30 days after your receipt of the +notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + +9. Acceptance Not Required for Having Copies. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You are not required to accept this License in order to receive or run a +copy of the Program. Ancillary propagation of a covered work occurring +solely as a consequence of using peer-to-peer transmission to receive a +copy likewise does not require acceptance. However, nothing other than +this License grants you permission to propagate or modify any covered +work. These actions infringe copyright if you do not accept this +License. Therefore, by modifying or propagating a covered work, you +indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered work +results from an entity transaction, each party to that transaction who +receives a copy of the work also receives whatever licenses to the work +the party's predecessor in interest had or could give under the previous +paragraph, plus a right to possession of the Corresponding Source of the +work from the predecessor in interest, if the predecessor has it or can +get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may not +impose a license fee, royalty, or other charge for exercise of rights +granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that any +patent claim is infringed by making, using, selling, offering for sale, +or importing the Program or any portion of it. + +11. Patents. +^^^^^^^^^^^^ + +A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The work +thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims owned or +controlled by the contributor, whether already acquired or hereafter +acquired, that would be infringed by some manner, permitted by this +License, of making, using, or selling its contributor version, but do +not include claims that would be infringed only as a consequence of +further modification of the contributor version. For purposes of this +definition, "control" includes the right to grant patent sublicenses in +a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to make, +use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and +the Corresponding Source of the work is not available for anyone to +copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify or +convey a specific copy of the covered work, then the patent license you +grant is automatically extended to all recipients of the covered work +and works based on it. + +A patent license is "discriminatory" if it does not include within the +scope of its coverage, prohibits the exercise of, or is conditioned on +the non-exercise of one or more of the rights that are specifically +granted under this License. You may not convey a covered work if you are +a party to an arrangement with a third party that is in the business of +distributing software, under which you make payment to the third party +based on the extent of your activity of conveying the work, and under +which the third party grants, to any of the parties who would receive +the covered work from you, a discriminatory patent license (a) in +connection with copies of the covered work conveyed by you (or copies +made from those copies), or (b) primarily for and in connection with +specific products or compilations that contain the covered work, unless +you entered into that arrangement, or that patent license was granted, +prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any +implied license or other defenses to infringement that may otherwise be +available to you under applicable patent law. + +12. No Surrender of Others' Freedom. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not convey it at all. For example, if you agree to terms that +obligate you to collect a royalty for further conveying from those to +whom you convey the Program, the only way you could satisfy both those +terms and this License would be to refrain entirely from conveying the +Program. + +13. Use with the GNU Affero General Public License. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Notwithstanding any other provision of this License, you have permission +to link or combine any covered work with a work licensed under version 3 +of the GNU Affero General Public License into a single combined work, +and to convey the resulting work. The terms of this License will +continue to apply to the part which is the covered work, but the special +requirements of the GNU Affero General Public License, section 13, +concerning interaction through a network will apply to the combination +as such. + +14. Revised Versions of this License. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies that a certain numbered version of the GNU General Public +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that numbered version or of +any later version published by the Free Software Foundation. If the +Program does not specify a version number of the GNU General Public +License, you may choose any version ever published by the Free Software +Foundation. + +If the Program specifies that a proxy can decide which future versions +of the GNU General Public License can be used, that proxy's public +statement of acceptance of a version permanently authorizes you to +choose that version for the Program. + +Later license versions may give you additional or different permissions. +However, no additional obligations are imposed on any author or +copyright holder as a result of your choosing to follow a later version. + +15. Disclaimer of Warranty. +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF +THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR +CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT +NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES +SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE +WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN +ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If the disclaimer of warranty and limitation of liability provided above +cannot be given local legal effect according to their terms, reviewing +courts shall apply local law that most closely approximates an absolute +waiver of all civil liability in connection with the Program, unless a +warranty or assumption of liability accompanies a copy of the Program in +return for a fee. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs +############################################# + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + +To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively state +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + +:: + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice +like this when it starts in an interactive mode: + +:: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands \`show w' and \`show c' should show the +appropriate parts of the General Public License. Of course, your +program's commands might be different; for a GUI interface, you would +use an "about box". + +You should also get your employer (if you work as a programmer) or +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. For more information on this, and how to apply and follow the +GNU GPL, see https://www.gnu.org/licenses/. + +The GNU General Public License does not permit incorporating your +program into proprietary programs. If your program is a subroutine +library, you may consider it more useful to permit linking proprietary +applications with the library. If this is what you want to do, use the +GNU Lesser General Public License instead of this License. But first, +please read https://www.gnu.org/licenses/why-not-lgpl.html. \ No newline at end of file diff --git a/doc/indices-and-tables.rst b/doc/indices-and-tables.rst new file mode 100644 index 00000000000..92bf73bcb0a --- /dev/null +++ b/doc/indices-and-tables.rst @@ -0,0 +1,13 @@ +.. only:: html + + Indexes and tables + ================== + + :ref:`genindex` + + .. only:: development + + TODO + ---- + + .. todolist:: \ No newline at end of file diff --git a/doc/lgpl-2.1.rst b/doc/lgpl-2.1.rst new file mode 100644 index 00000000000..845de30d8d4 --- /dev/null +++ b/doc/lgpl-2.1.rst @@ -0,0 +1,514 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +GNU LESSER GENERAL PUBLIC LICENSE +--------------------------------- + +.. index:: LGPL, Lesser General Public License + +Version 2.1, February 1999 + +Copyright (C) 1991-2022 Free Software Foundation, Inc. +51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts +as the successor of the GNU Library Public License, version 2, hence the +version number 2.1.] + +Preamble +^^^^^^^^ + +The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software---to make sure the software is free for all its users. + +This license, the Lesser General Public License, applies to some +specially designated software---typically libraries---of the Free +Software Foundation and other authors who decide to use it. You can use +it too, but we suggest you first think carefully about whether this +license or the ordinary General Public License is the better strategy to +use in any particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of it +in new free programs; and that you are informed that you can do these +things. + +To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + +Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + +Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + +When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + +We call this license the :dfn:`Lesser` General Public License because it +does *Less* to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + +For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + +In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + +Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + +The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +'work based on the library' and a 'work that uses the library'. The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + +#. This License Agreement applies to any software library or other program + which contains a notice placed by the copyright holder or other + authorized party saying it may be distributed under the terms of this + Lesser General Public License (also called 'this License'). Each + licensee is addressed as 'you'. + + A 'library' means a collection of software functions and/or data + prepared so as to be conveniently linked with application programs + (which use some of those functions and data) to form executables. + + The 'Library', below, refers to any such software library or work + which has been distributed under these terms. A 'work based on the + Library' means either the Library or any derivative work under + copyright law: that is to say, a work containing the Library or a + portion of it, either verbatim or with modifications and/or translated + straightforwardly into another language. (Hereinafter, translation is + included without limitation in the term 'modification'.) + + 'Source code' for a work means the preferred form of the work for + making modifications to it. For a library, complete source code means + all the source code for all modules it contains, plus any associated + interface definition files, plus the scripts used to control compilation + and installation of the library. + + Activities other than copying, distribution and modification are not + covered by this License; they are outside its scope. The act of + running a program using the Library is not restricted, and output from + such a program is covered only if its contents constitute a work based + on the Library (independent of the use of the Library in a tool for + writing it). Whether that is true depends on what the Library does + and what the program that uses the Library does. + +#. You may copy and distribute verbatim copies of the Library's + complete source code as you receive it, in any medium, provided that + you conspicuously and appropriately publish on each copy an + appropriate copyright notice and disclaimer of warranty; keep intact + all the notices that refer to this License and to the absence of any + warranty; and distribute a copy of this License along with the + Library. + + You may charge a fee for the physical act of transferring a copy, + and you may at your option offer warranty protection in exchange for a + fee. + +#. You may modify your copy or copies of the Library or any portion + of it, thus forming a work based on the Library, and copy and + distribute such modifications or work under the terms of Section 1 + above, provided that you also meet all of these conditions: + + a* The modified work must itself be a software library. + + * You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + * You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + * If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Library, + and can be reasonably considered independent and separate works in + themselves, then this License, and its terms, do not apply to those + sections when you distribute them as separate works. But when you + distribute the same sections as part of a whole which is a work based + on the Library, the distribution of the whole must be on the terms of + this License, whose permissions for other licensees extend to the + entire whole, and thus to each and every part regardless of who wrote + it. + + Thus, it is not the intent of this section to claim rights or contest + your rights to work written entirely by you; rather, the intent is to + exercise the right to control the distribution of derivative or + collective works based on the Library. + + In addition, mere aggregation of another work not based on the Library + with the Library (or with a work based on the Library) on a volume of + a storage or distribution medium does not bring the other work under + the scope of this License. + +#. You may opt to apply the terms of the ordinary GNU General Public + License instead of this License to a given copy of the Library. To do + this, you must alter all the notices that refer to this License, so + that they refer to the ordinary GNU General Public License, version 2, + instead of to this License. (If a newer version than version 2 of the + ordinary GNU General Public License has appeared, then you can specify + that version instead if you wish.) Do not make any other change in + these notices. + + Once this change is made in a given copy, it is irreversible for + that copy, so the ordinary GNU General Public License applies to all + subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of + the Library into a program that is not a library. + +#. You may copy and distribute the Library (or a portion or + derivative of it, under Section 2) in object code or executable form + under the terms of Sections 1 and 2 above provided that you accompany + it with the complete corresponding machine-readable source code, which + must be distributed under the terms of Sections 1 and 2 above on a + medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy + from a designated place, then offering equivalent access to copy the + source code from the same place satisfies the requirement to + distribute the source code, even though third parties are not + compelled to copy the source along with the object code. + +#. A program that contains no derivative of any portion of the + Library, but is designed to work with the Library by being compiled or + linked with it, is called a 'work that uses the Library'. Such a + work, in isolation, is not a derivative work of the Library, and + therefore falls outside the scope of this License. + + However, linking a 'work that uses the Library' with the Library + creates an executable that is a derivative of the Library (because it + contains portions of the Library), rather than a 'work that uses the + library'. The executable is therefore covered by this License. + Section 6 states terms for distribution of such executables. + + When a 'work that uses the Library' uses material from a header file + that is part of the Library, the object code for the work may be a + derivative work of the Library even though the source code is not. + Whether this is true is especially significant if the work can be + linked without the Library, or if the work is itself a library. The + threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data + structure layouts and accessors, and small macros and small inline + functions (ten lines or less in length), then the use of the object + file is unrestricted, regardless of whether it is legally a derivative + work. (Executables containing this object code plus portions of the + Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may + distribute the object code for the work under the terms of Section 6. + Any executables containing that work also fall under Section 6, + whether or not they are linked directly with the Library itself. + +#. As an exception to the Sections above, you may also combine or + link a 'work that uses the Library' with the Library to produce a + work containing portions of the Library, and distribute that work + under terms of your choice, provided that the terms permit + modification of the work for the customer's own use and reverse + engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the + Library is used in it and that the Library and its use are covered by + this License. You must supply a copy of this License. If the work + during execution displays copyright notices, you must include the + copyright notice for the Library among them, as well as a reference + directing the user to the copy of this License. Also, you must do one + of these things: + + a* Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable 'work that + uses the Library', as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + * Use a suitable shared library mechanism for linking with the Library. A + suitable mechanism is one that (1) uses at run time a copy of the + library already present on the user's computer system, rather than + copying library functions into the executable, and (2) will operate + properly with a modified version of the library, if the user installs + one, as long as the modified version is interface-compatible with the + version that the work was made with. + + * Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + * If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + * Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the 'work that uses the + Library' must include any data and utility programs needed for + reproducing the executable from it. However, as a special exception, + the materials to be distributed need not include anything that is + normally distributed (in either source or binary form) with the major + components (compiler, kernel, and so on) of the operating system on + which the executable runs, unless that component itself accompanies the + executable. + + It may happen that this requirement contradicts the license + restrictions of other proprietary libraries that do not normally + accompany the operating system. Such a contradiction means you cannot + use both them and the Library together in an executable that you + distribute. + +#. You may place library facilities that are a work based on the + Library side-by-side in a single library together with other library + facilities not covered by this License, and distribute such a combined + library, provided that the separate distribution of the work based on + the Library and of the other library facilities is otherwise + permitted, and provided that you do these two things: + + a* Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + * Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + +#. You may not copy, modify, sublicense, link with, or distribute + the Library except as expressly provided under this License. Any + attempt otherwise to copy, modify, sublicense, link with, or + distribute the Library is void, and will automatically terminate your + rights under this License. However, parties who have received copies, + or rights, from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + +#. You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify or + distribute the Library or its derivative works. These actions are + prohibited by law if you do not accept this License. Therefore, by + modifying or distributing the Library (or any work based on the + Library), you indicate your acceptance of this License to do so, and + all its terms and conditions for copying, distributing or modifying + the Library or works based on it. + +#. Each time you redistribute the Library (or any work based on the + Library), the recipient automatically receives a license from the + original licensor to copy, distribute, link with or modify the Library + subject to these terms and conditions. You may not impose any further + restrictions on the recipients' exercise of the rights granted herein. + You are not responsible for enforcing compliance by third parties with + this License. + +#. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent issues), + conditions are imposed on you (whether by court order, agreement or + otherwise) that contradict the conditions of this License, they do not + excuse you from the conditions of this License. If you cannot + distribute so as to satisfy simultaneously your obligations under this + License and any other pertinent obligations, then as a consequence you + may not distribute the Library at all. For example, if a patent + license would not permit royalty-free redistribution of the Library by + all those who receive copies directly or indirectly through you, then + the only way you could satisfy both it and this License would be to + refrain entirely from distribution of the Library. + + If any portion of this section is held invalid or unenforceable under any + particular circumstance, the balance of the section is intended to apply, + and the section as a whole is intended to apply in other circumstances. + + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of any + such claims; this section has the sole purpose of protecting the + integrity of the free software distribution system which is + implemented by public license practices. Many people have made + generous contributions to the wide range of software distributed + through that system in reliance on consistent application of that + system; it is up to the author/donor to decide if he or she is willing + to distribute software through any other system and a licensee cannot + impose that choice. + + This section is intended to make thoroughly clear what is believed to + be a consequence of the rest of this License. + +#. If the distribution and/or use of the Library is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Library under this License may add + an explicit geographical distribution limitation excluding those countries, + so that distribution is permitted only in or among countries not thus + excluded. In such case, this License incorporates the limitation as if + written in the body of this License. + +#. The Free Software Foundation may publish revised and/or new + versions of the Lesser General Public License from time to time. + Such new versions will be similar in spirit to the present version, + but may differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the Library + specifies a version number of this License which applies to it and + 'any later version', you have the option of following the terms and + conditions either of that version or of any later version published by + the Free Software Foundation. If the Library does not specify a + license version number, you may choose any version ever published by + the Free Software Foundation. + +#. If you wish to incorporate parts of the Library into other free + programs whose distribution conditions are incompatible with these, + write to the author to ask for permission. For software which is + copyrighted by the Free Software Foundation, write to the Free + Software Foundation; we sometimes make exceptions for this. Our + decision will be guided by the two goals of preserving the free status + of all derivatives of our free software and of promoting the sharing + and reuse of software generally. + + NO WARRANTY + +#. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO + WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. + EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR + OTHER PARTIES PROVIDE THE LIBRARY 'AS IS' WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE + LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME + THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +#. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN + WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY + AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU + FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR + CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE + LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING + RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A + FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF + SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + DAMAGES. + +How to Apply These Terms to Your New Libraries +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + +To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +'copyright' line and a pointer to where the full notice is found. + +.. code-block:: + + one line to give the library's name and an idea of what it does. + Copyright (C) year name of author + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at + your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a 'copyright disclaimer' for the library, if +necessary. Here is a sample; alter the names: + +.. code-block:: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the library + `Frob' (a library for tweaking knobs) written by James Random Hacker. + + signature of Ty Coon, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! \ No newline at end of file diff --git a/doc/logo.pdf b/doc/logo.pdf new file mode 100644 index 0000000000000000000000000000000000000000..4ba78b166b48cac48f56298288b55b9a92bf276b GIT binary patch literal 8978 zc-n=TWmH_*5~$H2!8Lf}4&5~F(h%I;8|WZG8wu_%!Ce9b*Weo5H9?aQ+$}f+Lf|oT zXXf7Z=B@R5b?rLmtJ<}9)v15Qs1A|i1aa|UGBzF8{KDh~00B-Gc9^1~0B&WNqqUn2 zfbR)uVgdjFZaG_fHyHd$+e6)85SXQt6%12c9Mjbe4ud*idgg@Xh}3clIfh-_5ff9K zdhBx+t75%y2C8DC$&rDPH}lMgdhh)%jEd||d>rE`;(pA|lt(}kW47oHi!SN|9zb6M z?%Z>47SGcApVem0>`gwD##c^yJzS~nO8j1Qf7lO*S9){*t2<{qwKi*5@bQ)Fqut}f z^cl^g?Hl9W0Gg}&mJ4p{nc@dCA9%;z>tgScxue}%_k~nb*GX{dZPxo-iK&J0!}`pe z*-DtorC#;^#G>bwo!6I)IGv9AE_h~Ex3{%P(_1|U zkC?RYQ-(8#?X3)%%AP(=>0by-ewTfBHmS8=jC*wx*YKqap50vGLfhEzr9&lc9_M<& zQMY-?$miF>-kxA` zvJyw}X09EPqv*h!ey4()ETUoQ+EWWdjM;Qcy;p}#$_Xra$3Y_Dk4#@xcT(-qn&FMT z9toN*3On#A*ok!gD1+dP?NZ%uT|$)#a+B)>L;GLNbQE+zoGBukZ(PUakv04x=(9Q^ z@tGQ!)%V7WuYb;JeBhaaF{>+YT!S-%KD1gaMl4eSj- zIN}Px6f4bSNbWOgK6)C@s-8LxbL$%F>gR}gRYBvqJmkWkc_1-y%qGxS8+aIAPgohT z_Q0bnB8%o zL^nk!ODvc=aPPlK>$+ktMf|dkiM5K|USHi>eOqABmRXbUx~9%GAJ{omzG#17m7m=~ z+iy36)z9W=7;d7lsEja79XmN$++WcbZ+{S~L6-u%R`*O89bHzXG;0P=vF_8o478sa zl+Ogsf-@%PjWv^RlI~r>ern;2{7^~6Q{T>yy!%`~toK=WekJ%kyQw7ydxqMVnfwyQ z&9+#vx4iK_8FMr5lu-~CZ+&f!0_8ZDMB*Od_`;m}472C7~ z68&rI%~!0>HeE6~a-_VM&Br7w%agbnKO}}nO;Gcdjla1O)(pF01^@ocj+B&4%%%4RLhLD=N@fIab7VqPbdIH(mltrT?tI-Z{V^j@c}+e`@jO~~ zEX0<}f9`md=W&u*%tq}F4Y``9isnCEg$X*{oQ6MtbNlGbI@AHT*x+aKq~nrJnmLj|0v;I_!u zud$G!N&2ld4kIRsweP^N$v{j>j?U0^kUs=;uRIt65=hTGeLQS3rc{zkvrFq!9p)2jlUCCX=v z<$FU~`8y5I_Vsl-osmPHxgGXb4zIAJ>D5HRnV+2FGHe(kX^sp@rg1%h@7U#SIL%nlUDi;iox zKYrD(A8v6j%qWr2LuqD+`2xIuK{Gv|l67vE4`CKoqY+VkW~wKtt)q?cJ&ml!)x9Tz5;cHAxM}&#{tzNuQ+$m<1c=-6Inmh>%O`F7UMvI zSX_w_(~dzXW~yjEfx#+@bX!{m75E^{9QX{0uaU_uKY6B@wlpTqb)g4OeLgbgwTnKS zc&}zd&{6BNV{1^5bC4*vu(Whf1=lv0O5JOZpGF0AG=wZSIuRYx9m&ii`4`)xbJZ;@ z<87h@J<;`)Lz+y{*mamhgrY4X_F^dg`ms3d6BA7BbLC{-3HS^}MimRT?9~3x6P4*V z5x$eFA`vDv2&NoferA-oq49b4k($rv{*?#?=2em`V^ir!{F!{Y%1vh{a_Kt`N}E-= zmZH^;O#=h1*F$wduh!;$I`PT~4#dL3GUBbZ*06Ap)|-j($Tp2$t}J?+^-lAF7L`BM zR^|GtJS@HWyrn|OFVf)|C@QLim*l3F_u+dGT9Z*vLZOKK4XAw`S2DzfJc`lHYtTql zMgb=!Bo>ay7Ga*ums!`m{vofgFZx~R$4ES4y-$=A6K@9ywzgMf^xej>5e>?%i`7~^ zwu`4*kuGykKTjR^LeKh9W66xlTy28UBYb7QM#&z8f<2VFh?o+vYbzrzDz|t&8l;Mh zwQ2ZM8qvn81v9I9So#if*8M*<~;tJU&;?A#4M|8`Vhs83gW5<7s#$ z;Xo0Agh}w*NE@3?Rus{6{c{`Nwo*aiHrO$!ZJ113Yt?{J?N+%@WlFCA683I?gCAX@ zonJb5)g48P2~(y)F_rfUM{5R!v#Sw zjydD0wx(f`Vv{!tHSSipQUZ3PF-IZMje9{&kseb=KPO#*;=GkKT7WOg7+p16L5yDUT1H%EQ~$0te~OTfL4@zmn`a~wj8>L`ka zdoAW)GBLdRF7eg*$sI%X5%-n1-Ss&sW6LVvkY4u$+H|+n_<3AlP9#(@`6%p&Z?|}G zyyP<(>`vHBJX}@`BJE0<;9@=J3MME{elZZgt6lIpL6+}5yN&1;B{d2>8ZfM_hq1{i zUTpoYoHW+_T>A|dzIKxk!cLTN=xLL{G-heT2NvGwgl+o@0))QLqLNU9KpKHI;Ru6t z^cfi;P9NIFAxNt^zd!@)t~|9pAkd^w9ELzcGUs275TO@eqO(2#jbHbe3?(aNC74+i zBF63$+DLPXUs1>!v?R016b}86BponsrVxG;;&T*xoWv{TOfUtY zfuTM@B;PYDE8|awF$N}R-|bs_va$sXHJ>uEdrn&k*~3j>)%_t|a(C-)Z)eF{Iv1<5 z0>3QcO%kAiL5s;jvnAS56CEMti zkVfdLER-V=KD3d2(W_F?P4rr6%>*LV{9D*=5R4U0o_GIA$<4-#1qE95MTC^|@xl`)MDvS|i} zLDxp%g{ISuDaIM+2vuVzwd%DfC=mG}PWpxIMpAIGm(`|yZX{+nQ+xHy%kRC1=NU-5 zy95ov6-LIkKY!cM6yTF^g)ulYluVqm1N1yV7R2}}+XoMfZm8CMs3onTZ7NmfU(Y4z z;GscVcpBtAIB{RdG0egottY;lj6U0@oEplVqBV;aLLU7(D+?#;mT6DzOhI7aJ{svX zqx1WYeq{M_jzOPUCz(y>hH^)um`RHD)DBmqa#toLC!9XI`pnt;gMw!22u8dCs-n-k zYe*j$NW+Gzh&qf2(r!XJr-v})2Uz?AONi- zsys(4RE5Ym+1OlHty|*P7yOG-AxX)nA%jgbe%VcyTb@mg7*D3A|pc3 zcb#v&1qPiKlIxi-+A4Q7V)ThLQ)5rl>kg7=PJov5eOvg*GuY=Xvf3a)`BD4Ilck~pFW>McDJ=e{}-IU_AhW|Hk2rL)nz z)%-b$PONc2)cd{^jthC&cpEDepl6r)c($czHkQhuHMb0Yxvi-0=X2i?S1CXJtJ={3 z|Bm*A6BFCB?@F%kxn{h4q(W#a5z}h;&xG-)Tud*!0xm+AAMR`Y`w1Tlhz zP_4es0l@^t?kpuy`#I8#-=2=!&IkNLeMN@M`kkIyvfZ|N<_GOq$Qr56Hp}Ah zX)O1xU3C z29dAvxi>~k96|TeF zmB(9iW<@Efv#PyNQA*S=ojb!B=b}MjUs#^=Mfdraj{w5Hb7UWP0kAP|D5tlllHGEU z4yxIc4rWxL6hrJUrEz72=+yT@G9p`Set|*+h$$S|s`-0U<2 zFLNerK;|XRrO=lv?4yL~?^*$*Ns`FRLA8amkWXy$8su|Sho4s!1JL}4JTVrTl)h!l z-0E^Wxj1`ITFZ-6?zJ3X0Py!u8M?gC22ZErA%$p4aG^z&@LS~LspgEuB&ghuS}Eq0T?V2su6_jj>b28}d#|wN1d1x<)+yDB zVtq0us^d!2$U(@^1s26h1*+MGaqNU&g8(F#g@;PauYC6zy`n1X0eVh*;6Rv8Q{|@- z8N+c~u_5i3AE>v!%#5(rY*(`w{5Z*Gqk@X{qGma$H#}&rm4)ROpX?YFpVGZF#& zbxzwnHTwM^ave*h^QXW4^nG;lMjp>&r%LmRmY?m|Qg+wC>hrhqs9B30+Oh{o+5RfB z3j-`GB{I1fcOeMKM@527GFqv4N$ebhZ8IVB&w|hqr5tnywQT4;P^04Hkn0guwswQR zZU|bsWLM10%GfJv2V!i>M?iPmiN2ViyTp^4HKc2mL7{~FHPkm>4D!P(e6K1%vfb$P z@yuYqC4|d%o9ztf_J$}u-hA>(6P}~KM%jl&ZyM96EaT96@E8&9Spz`~%lE*>nb->`dzSSBo0!Nm;{j)u=8h~ArTT&raKY5~H zWFpVKnF~XGKwB+1j=3)LV>=3h2;sQuyu{{lNDV)(`J3CcA`qUt(gjC}7&TM#OWSOv zz(l8t!?$$olS@Bt4@V`bE#?v4+KHkoyO}2LH07OnoL&8FWe~FG+~t56HRxzKwaXGO zv#q2M2P@`?Bveg2x+1l06tRsoRmm+#wy=^ABdzNOONjt#l7kap{-ScH3&UPtZ~8hs*@ zXG6U2@~X?lNo2b0qzumq??NrzIAh^qe{U*HOW@a&SRIXWb-$I|a5SapNrS1AJL%$C ztBC*c*v~~|0~QlH8#@;p1D%4&MRx9tT%z0J=A%F%jY));zq@bnS8D$o!#9yrU zYgLAe`e_8+H%0>|TIGiAk~#W{j)Igh-K8)lx7NJFBeF5SBbUunALFL)KGT%vXoACv zsw!EHoqmIb&+GhYxJtaAwQnLdY7WjLPAa~_PlI$OcP?B{Kve24 zPJCPIOm1V@tc>#kP;UasN7OE7Pp=nv1_zIkzF!hw$&C=QPDT<@5i-zU7aq?_Y}Mds z9CL-8rVTT7O`Vt;(F!qmy9)I2nQb5ej3wQ6;q|18hG!L+(nmOZ8nU!PM7vh}MLDE9 zK5o!L>GFkT8lDqcUWy?c0jWoju6hqA<<51asjP-qVRQ{qEnD=e6nQ<`Gd;%7KQ7~a z(*#&q>uXoEcDQ(QS8uqyJVg@DAr_yw`9h9>DAD5HvL2CA8GG*{Av-S!hw}>N(LRmX zt(zR!tP@#ntJ-r;&)UETQ`uQK90xY;x>X=sw?Z=Z6_^_5WAK4Q@506WaA6-DPUKC- zB9cHtygr%!ujirWxng8^$#tD%lB0;3o$Y>a7K zdWpPd#kb&)_7VyCLAZ7KD)&|XDLrZ6G}GBW&YJoNrkx@1d4{uX9=5TgDT8qT%?}|3 zh}q6n{+jg_E~RI=*IK`Weq}~pYVG(q#cCrYt08K^4dZ$Dipu98mk&)D{XRL`q_Gq~ zCMUi36kaZLS?JMI<9IoUeB<`3Ic1vm>~ZloOVuT>=F)ebmwp#T>>#EgxO~aQ*jVA)cwJP$GU2Ek$mBP9L92y(7az~gwOb~dwsT{*5)go%W*jgt^L1yKoiGrdvr2N6 zeR#h~8`XGE1n%nGl;|!G-(kFVKCyeWrj2(Z=}AAsAp^|JkCRWlDE%}LE2iE5ZmW1L>gz(?q>n*cy0(@hoK0)h?}dWJXBxxcHaYKWj-WR`a{bil z`sR0|5KT|gIwE-du8H{S-`(72Tm0NS@s}NBR(>{h+#=2_vn2aXH~z;mhlI6ZG_{qt z8J=pWc(He$YCmoCvUInFs~Yd6gYToaEM`gOG(m?Vgt}!1VB%DlQ|*OQ#UQNW^ugA& z6INxO>C{yi&0F}6zGrRG;kW2Y$zuc1|3?Yea(6xeTZ+=m+IGdJ$r^K=ob_NEU#on@ zSMAN$gt&96Qk%WP`uez-K1T5wZSZ$$!UeVs|5tlnFCLcJrF?pC8MMf$6{2GUR zvd+C~AAA)ygH#SDTR9*nEEPaX8aW{wL+(Me+;A|&IAa!_k@3hnB@#;Sq(fGIXx<=3 zHhc_MnpCTk>t->E`!3q$zzzMDp}GCu#&ZvkaqoBJ)(ce9SnZSw zc|(;@jde@ZAF-f!AH0PhjS=I-ev7OW&0gk&yh)=oENx^hTGt*CRq|cdjr@MANJ=36>O>k)a#`## z5597}8kA0=x$#i)fp^X%w2bqWLJxbKA`$Mp*ruYgfkRBU|uZ@iz6^MA)M zKQ~O@PZxI$_lJm{YSlMYB~g5PrXhV&=9*iLs~2;pQn#lmc154%vpY68#v zB(whBuBp)Dox%e)qC03yP%PTA^|J2fG=4$P4PC)|F@^1JaqS_FlY7=WFfzLVW+8;9 zpAd)j0nx$JQv(e(qQnB%&WuS$!(Q*6eoRIy;T>gz8G+{&_U8c;8O%?5iq6TBQf17F zgg(z4gWYsk-eA{JurNfB#(~Pcy%5_HP%c=-yAovZOIwEfH_v{F^%E30YA$qvQu-o7 zLi4B8)yOYmT#n?7?lyj{{ z+pfPkBuFB?Vimj+Hg3Bbbn=x}V1BC>2_So@<~uF$FIf+eDDeEo9gH$q`LG|YS8|qj zj(I18nl9X?bjFhB-rx@yU(&s`$SE;P(ELtz94+Z^R`vdxbJ>QwdvI&5NRfA)R;-Q9 zIZ2{N@}iV7K0ddinCQ~D*X%7IHl{RskPd8Zl1}a{B-=}4_Chn2dy22YJy$YH1O;ZO zd-)FGm3fu8Daj5=*fgHoeY?;bccm69Hwb6{<6fY6GMn(Sbzk+&mBsWYudtJ`l`aIL zJtwt%nuCal?u)ej4Xj3l2)M(UuOW3zz3Y_|&CM6~$NHq*=>2`Fk*K)SUYA+qk4l8% zT}=qDv!2UIW~WaIaaTE)6Fzq0&iB=Ebuvtt@nPWIJB_@*H4cckocdh{A$8o4O?S+o z7H)8%QoA{=fiVB%oF_CMiX|nnT9T|07f&@NJm->;fc7%J2c7a1O;p8*|!RU6dgwAOrKcIc<+R_7=UExjdIb($8ly zNeZag6j-Ld9@o}`&i~?-Q%x@gpc@kt=HeS^f>`zLywTLSW(B| zNLZ|b9Vu5-Vr816Tn?hC>mPt+EB z0?IPGy@|KRCE6y=hV!|cXc(IUof6`<@%iov$l~`Z$tm-74eu?Hz99R(*1ELjyCWW; zr_;-wsCjd4=eb;DvNHMGPe=8=pILcipakV38gBKwVN95#)n8Nar>8&W=X`(7(E$K} zfDjn;HwOPRUjK8TF6-&`Qp*kM1_S&D{K23=z#qeR87Tk=z-UX^+tb#+C-*8aD_f|vlPAFF2>}5@Kp=qsNlgAU z$~ZZ?J-NFAc>nQ#33qaL{+~Gd~O0Jy>3VSm5LJb6K2 z9=4V+&6m=DW$_2sgttw|1&e!KX)nFTDd-D@JI5R|J>dEk3|0` z0RR64P=`BNxm&{E02WKAE!+tJ;sWt=0Rb#FZf?%5!ra_{QfoNW*~Zq=mCFfk&C2?p zs865L%?S<=m6Mf|0|I%U>cubnB+@{j0QgD&A)u#c;FIP90(qV^`01TT_W#mPoJa7< z=Sc*3{}SMTVt}QdY;yk*{{LV6KWtBa0#5*NUeqk~u=!aP785D3J> z4-x?JfqB@0AZ8$t^?ynu@UPm+K;5ABPS$@l%~PHK>Y4xU@r1)(VFCeyn81I20De9` zFdyI*;4dZ!20s=3PmAL}3)HN0L+ic$SA8Ohxva1GxTjd literal 0 Hc-jL100001 diff --git a/doc/logo.svg b/doc/logo.svg new file mode 100644 index 00000000000..0b8ed020c89 --- /dev/null +++ b/doc/logo.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + diff --git a/doc/md.rst b/doc/md.rst new file mode 100644 index 00000000000..55e0711113e --- /dev/null +++ b/doc/md.rst @@ -0,0 +1,3142 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: simple constraints + +.. _simple-constraints: + +Simple Constraints +^^^^^^^^^^^^^^^^^^ + +The simplest kind of constraint is a string full of letters, each of +which describes one kind of operand that is permitted. Here are +the letters that are allowed: + +whitespace + Whitespace characters are ignored and can be inserted at any position + except the first. This enables each alternative for different operands to + be visually aligned in the machine description even if they have different + number of constraints and modifiers. + + .. index:: m in constraint, memory references in constraints + +m + A memory operand is allowed, with any kind of address that the machine + supports in general. + Note that the letter used for the general memory constraint can be + re-defined by a back end using the ``TARGET_MEM_CONSTRAINT`` macro. + + .. index:: offsettable address, o in constraint + +o + A memory operand is allowed, but only if the address is + :dfn:`offsettable`. This means that adding a small integer (actually, + the width in bytes of the operand, as determined by its machine mode) + may be added to the address and the result is also a valid memory + address. + + .. index:: autoincrement/decrement addressing + + For example, an address which is constant is offsettable; so is an + address that is the sum of a register and a constant (as long as a + slightly larger constant is also within the range of address-offsets + supported by the machine); but an autoincrement or autodecrement + address is not offsettable. More complicated indirect/indexed + addresses may or may not be offsettable depending on the other + addressing modes that the machine supports. + + Note that in an output operand which can be matched by another + operand, the constraint letter :samp:`o` is valid only when accompanied + by both :samp:`<` (if the target machine has predecrement addressing) + and :samp:`>` (if the target machine has preincrement addressing). + + .. index:: V in constraint + +V + A memory operand that is not offsettable. In other words, anything that + would fit the :samp:`m` constraint but not the :samp:`o` constraint. + + .. index:: < in constraint + +< + A memory operand with autodecrement addressing (either predecrement or + postdecrement) is allowed. In inline ``asm`` this constraint is only + allowed if the operand is used exactly once in an instruction that can + handle the side effects. Not using an operand with :samp:`<` in constraint + string in the inline ``asm`` pattern at all or using it in multiple + instructions isn't valid, because the side effects wouldn't be performed + or would be performed more than once. Furthermore, on some targets + the operand with :samp:`<` in constraint string must be accompanied by + special instruction suffixes like ``%U0`` instruction suffix on PowerPC + or ``%P0`` on IA-64. + + .. index:: > in constraint + +> + A memory operand with autoincrement addressing (either preincrement or + postincrement) is allowed. In inline ``asm`` the same restrictions + as for :samp:`<` apply. + + .. index:: r in constraint, registers in constraints + +r + A register operand is allowed provided that it is in a general + register. + + .. index:: constants in constraints, i in constraint + +i + An immediate integer operand (one with constant value) is allowed. + This includes symbolic constants whose values will be known only at + assembly time or later. + + .. index:: n in constraint + +n + An immediate integer operand with a known numeric value is allowed. + Many systems cannot support assembly-time constants for operands less + than a word wide. Constraints for these operands should use :samp:`n` + rather than :samp:`i`. + + .. index:: I in constraint + +:samp:`{I}, {J}, {K}, ... {P}` + Other letters in the range :samp:`I` through :samp:`P` may be defined in + a machine-dependent fashion to permit immediate integer operands with + explicit integer values in specified ranges. For example, on the + 68000, :samp:`I` is defined to stand for the range of values 1 to 8. + This is the range permitted as a shift count in the shift + instructions. + + .. index:: E in constraint + +E + An immediate floating operand (expression code ``const_double``) is + allowed, but only if the target floating point format is the same as + that of the host machine (on which the compiler is running). + + .. index:: F in constraint + +F + An immediate floating operand (expression code ``const_double`` or + ``const_vector``) is allowed. + + .. index:: G in constraint, H in constraint + +:samp:`{G}, {H}` + :samp:`G` and :samp:`H` may be defined in a machine-dependent fashion to + permit immediate floating operands in particular ranges of values. + + .. index:: s in constraint + +s + An immediate integer operand whose value is not an explicit integer is + allowed. + + This might appear strange; if an insn allows a constant operand with a + value not known at compile time, it certainly must allow any known + value. So why use :samp:`s` instead of :samp:`i`? Sometimes it allows + better code to be generated. + + For example, on the 68000 in a fullword instruction it is possible to + use an immediate operand; but if the immediate value is between -128 + and 127, better code results from loading the value into a register and + using the register. This is because the load into the register can be + done with a :samp:`moveq` instruction. We arrange for this to happen + by defining the letter :samp:`K` to mean 'any integer outside the + range -128 to 127', and then specifying :samp:`Ks` in the operand + constraints. + + .. index:: g in constraint + +g + Any register, memory or immediate integer operand is allowed, except for + registers that are not general registers. + + .. index:: X in constraint + +X + + .. only:: gccint + + Any operand whatsoever is allowed, even if it does not satisfy + ``general_operand``. This is normally used in the constraint of + a ``match_scratch`` when certain alternatives will not actually + require a scratch register. + + .. only:: not gccint + + Any operand whatsoever is allowed. + + .. index:: 0 in constraint, digits in constraint + +:samp:`{0}, {1}, {2}, ... {9}` + An operand that matches the specified operand number is allowed. If a + digit is used together with letters within the same alternative, the + digit should come last. + + This number is allowed to be more than a single digit. If multiple + digits are encountered consecutively, they are interpreted as a single + decimal integer. There is scant chance for ambiguity, since to-date + it has never been desirable that :samp:`10` be interpreted as matching + either operand 1 *or* operand 0. Should this be desired, one + can use multiple alternatives instead. + + .. index:: matching constraint, constraint, matching + + This is called a :dfn:`matching constraint` and what it really means is + that the assembler has only a single operand that fills two roles + + .. only:: gccint + + considered separate in the RTL insn. For example, an add insn has two + input operands and one output operand in the RTL, but on most CISC + + .. only:: not gccint + + which ``asm`` distinguishes. For example, an add instruction uses + two input operands and an output operand, but on most CISC + + machines an add instruction really has only two operands, one of them an + input-output operand: + + .. code-block:: + + addl #35,r12 + + Matching constraints are used in these circumstances. + More precisely, the two operands that match must include one input-only + operand and one output-only operand. Moreover, the digit must be a + smaller number than the number of the operand that uses it in the + constraint. + + .. only:: gccint + + For operands to match in a particular case usually means that they + are identical-looking RTL expressions. But in a few special cases + specific kinds of dissimilarity are allowed. For example, ``*x`` + as an input operand will match ``*x++`` as an output operand. + For proper results in such cases, the output template should always + use the output-operand's number when printing the operand. + + .. index:: load address instruction, push address instruction, address constraints, p in constraint + +p + An operand that is a valid memory address is allowed. This is + for 'load address' and 'push address' instructions. + + .. index:: address_operand + + :samp:`p` in the constraint must be accompanied by ``address_operand`` + as the predicate in the ``match_operand``. This predicate interprets + the mode specified in the ``match_operand`` as the mode of the memory + reference for which the address would be valid. + + .. index:: other register constraints, extensible constraints + +other-letters + Other letters can be defined in machine-dependent fashion to stand for + particular classes of registers or other arbitrary operand types. + :samp:`d`, :samp:`a` and :samp:`f` are defined on the 68000/68020 to stand + for data, address and floating point registers. + +.. only:: gccint + + In order to have valid assembler code, each operand must satisfy + its constraint. But a failure to do so does not prevent the pattern + from applying to an insn. Instead, it directs the compiler to modify + the code so that the constraint will be satisfied. Usually this is + done by copying an operand into a register. + + Contrast, therefore, the two instruction patterns that follow: + + .. code-block:: c++ + + (define_insn "" + [(set (match_operand:SI 0 "general_operand" "=r") + (plus:SI (match_dup 0) + (match_operand:SI 1 "general_operand" "r")))] + "" + "...") + + which has two operands, one of which must appear in two places, and + + .. code-block:: c++ + + (define_insn "" + [(set (match_operand:SI 0 "general_operand" "=r") + (plus:SI (match_operand:SI 1 "general_operand" "0") + (match_operand:SI 2 "general_operand" "r")))] + "" + "...") + + which has three operands, two of which are required by a constraint to be + identical. If we are considering an insn of the form + + .. code-block:: c++ + + (insn n prev next + (set (reg:SI 3) + (plus:SI (reg:SI 6) (reg:SI 109))) + ...) + + the first pattern would not apply at all, because this insn does not + contain two identical subexpressions in the right place. The pattern would + say, 'That does not look like an add instruction; try other patterns'. + The second pattern would say, 'Yes, that's an add instruction, but there + is something wrong with it'. It would direct the reload pass of the + compiler to generate additional insns to make the constraint true. The + results might look like this: + + .. code-block:: c++ + + (insn n2 prev n + (set (reg:SI 3) (reg:SI 6)) + ...) + + (insn n n2 next + (set (reg:SI 3) + (plus:SI (reg:SI 3) (reg:SI 109))) + ...) + + It is up to you to make sure that each operand, in each pattern, has + constraints that can handle any RTL expression that could be present for + that operand. (When multiple alternatives are in use, each pattern must, + for each possible combination of operand expressions, have at least one + alternative which can handle that combination of operands.) The + constraints don't need to *allow* any possible operand---when this is + the case, they do not constrain---but they must at least point the way to + reloading any possible operand so that it will fit. + + * If the constraint accepts whatever operands the predicate permits, + there is no problem: reloading is never necessary for this operand. + + For example, an operand whose constraints permit everything except + registers is safe provided its predicate rejects registers. + + An operand whose predicate accepts only constant values is safe + provided its constraints include the letter :samp:`i`. If any possible + constant value is accepted, then nothing less than :samp:`i` will do; + if the predicate is more selective, then the constraints may also be + more selective. + + * Any operand expression can be reloaded by copying it into a register. + So if an operand's constraints allow some kind of register, it is + certain to be safe. It need not permit all classes of registers; the + compiler knows how to copy a register into another register of the + proper class in order to make an instruction valid. + + .. index:: nonoffsettable memory reference, memory reference, nonoffsettable + + * A nonoffsettable memory reference can be reloaded by copying the + address into a register. So if the constraint uses the letter + :samp:`o`, all memory references are taken care of. + + * A constant operand can be reloaded by allocating space in memory to + hold it as preinitialized data. Then the memory reference can be used + in place of the constant. So if the constraint uses the letters + :samp:`o` or :samp:`m`, constant operands are not a problem. + + * If the constraint permits a constant and a pseudo register used in an insn + was not allocated to a hard register and is equivalent to a constant, + the register will be replaced with the constant. If the predicate does + not permit a constant and the insn is re-recognized for some reason, the + compiler will crash. Thus the predicate must always recognize any + objects allowed by the constraint. + + If the operand's predicate can recognize registers, but the constraint does + not permit them, it can make the compiler crash. When this operand happens + to be a register, the reload pass will be stymied, because it does not know + how to copy a register temporarily into memory. + + If the predicate accepts a unary operator, the constraint applies to the + operand. For example, the MIPS processor at ISA level 3 supports an + instruction which adds two registers in ``SImode`` to produce a + ``DImode`` result, but only if the registers are correctly sign + extended. This predicate for the input operands accepts a + ``sign_extend`` of an ``SImode`` register. Write the constraint + to indicate the type of register that is required for the operand of the + ``sign_extend``. + +.. only:: not gccint + + So the first alternative for the 68000's logical-or could be written as + ``"+m" (output) : "ir" (input)``. The second could be ``"+r" + (output): "irm" (input)``. However, the fact that two memory locations + cannot be used in a single instruction prevents simply using ``"+rm" + (output) : "irm" (input)``. Using multi-alternatives, this might be + written as ``"+m,r" (output) : "ir,irm" (input)``. This describes + all the available alternatives to the compiler, allowing it to choose + the most efficient one for the current conditions. + + There is no way within the template to determine which alternative was + chosen. However you may be able to wrap your ``asm`` statements with + builtins such as ``__builtin_constant_p`` to achieve the desired results. + +.. index:: multiple alternative constraints + +.. _multi-alternative: + +Multiple Alternative Constraints +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Sometimes a single instruction has multiple alternative sets of possible +operands. For example, on the 68000, a logical-or instruction can combine +register or an immediate value into memory, or it can combine any kind of +operand into a register; but it cannot combine one memory location into +another. + +These constraints are represented as multiple alternatives. An alternative +can be described by a series of letters for each operand. The overall +constraint for an operand is made from the letters for this operand +from the first alternative, a comma, the letters for this operand from +the second alternative, a comma, and so on until the last alternative. +All operands for a single instruction must have the same number of +alternatives. + +.. only:: gccint + + Here is how it is done for fullword logical-or on the 68000: + + .. code-block:: c++ + + (define_insn "iorsi3" + [(set (match_operand:SI 0 "general_operand" "=m,d") + (ior:SI (match_operand:SI 1 "general_operand" "%0,0") + (match_operand:SI 2 "general_operand" "dKs,dmKs")))] + ...) + + The first alternative has :samp:`m` (memory) for operand 0, :samp:`0` for + operand 1 (meaning it must match operand 0), and :samp:`dKs` for operand + 2. The second alternative has :samp:`d` (data register) for operand 0, + :samp:`0` for operand 1, and :samp:`dmKs` for operand 2. The :samp:`=` and + :samp:`%` in the constraints apply to all the alternatives; their + meaning is explained in the next section (see :ref:`class-preferences`). + + If all the operands fit any one alternative, the instruction is valid. + Otherwise, for each alternative, the compiler counts how many instructions + must be added to copy the operands so that that alternative applies. + The alternative requiring the least copying is chosen. If two alternatives + need the same amount of copying, the one that comes first is chosen. + These choices can be altered with the :samp:`?` and :samp:`!` characters: + + .. index:: ? in constraint, question mark + + ``?`` + Disparage slightly the alternative that the :samp:`?` appears in, + as a choice when no alternative applies exactly. The compiler regards + this alternative as one unit more costly for each :samp:`?` that appears + in it. + + .. index:: ! in constraint, exclamation point + + ``!`` + Disparage severely the alternative that the :samp:`!` appears in. + This alternative can still be used if it fits without reloading, + but if reloading is needed, some other alternative will be used. + + .. index:: ^ in constraint, caret + + ``^`` + This constraint is analogous to :samp:`?` but it disparages slightly + the alternative only if the operand with the :samp:`^` needs a reload. + + .. index:: $ in constraint, dollar sign + + ``$`` + This constraint is analogous to :samp:`!` but it disparages severely + the alternative only if the operand with the :samp:`$` needs a reload. + + When an insn pattern has multiple alternatives in its constraints, often + the appearance of the assembler code is determined mostly by which + alternative was matched. When this is so, the C code for writing the + assembler code can use the variable ``which_alternative``, which is + the ordinal number of the alternative that was actually satisfied (0 for + the first, 1 for the second alternative, etc.). See :ref:`output-statement`. + +.. _class-preferences: + +Register Class Preferences +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. only:: gccint + + .. index:: class preference constraints, register class preference constraints, voting between constraint alternatives + + The operand constraints have another function: they enable the compiler + to decide which kind of hardware register a pseudo register is best + allocated to. The compiler examines the constraints that apply to the + insns that use the pseudo register, looking for the machine-dependent + letters such as :samp:`d` and :samp:`a` that specify classes of registers. + The pseudo register is put in whichever class gets the most 'votes'. + The constraint letters :samp:`g` and :samp:`r` also vote: they vote in + favor of a general register. The machine description says which registers + are considered general. + + Of course, on some machines all registers are equivalent, and no register + classes are defined. Then none of this complexity is relevant. + +.. index:: modifiers in constraints, constraint modifier characters + +.. _modifiers: + +Constraint Modifier Characters +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +Here are constraint modifier characters. + +.. index:: = in constraint + +:samp:`=` + Means that this operand is written to by this instruction: + the previous value is discarded and replaced by new data. + + .. index:: + in constraint + +:samp:`+` + Means that this operand is both read and written by the instruction. + + When the compiler fixes up the operands to satisfy the constraints, + it needs to know which operands are read by the instruction and + which are written by it. :samp:`=` identifies an operand which is only + written; :samp:`+` identifies an operand that is both read and written; all + other operands are assumed to only be read. + + If you specify :samp:`=` or :samp:`+` in a constraint, you put it in the + first character of the constraint string. + + .. index:: & in constraint, earlyclobber operand + +:samp:`&` + Means (in a particular alternative) that this operand is an + :dfn:`earlyclobber` operand, which is written before the instruction is + finished using the input operands. Therefore, this operand may not lie + in a register that is read by the instruction or as part of any memory + address. + + :samp:`&` applies only to the alternative in which it is written. In + constraints with multiple alternatives, sometimes one alternative + requires :samp:`&` while others do not. See, for example, the + :samp:`movdf` insn of the 68000. + + An operand which is read by the instruction can be tied to an earlyclobber + operand if its only use as an input occurs before the early result is + written. Adding alternatives of this form often allows GCC to produce + better code when only some of the read operands can be affected by the + earlyclobber. See, for example, the :samp:`mulsi3` insn of the ARM. + + Furthermore, if the :dfn:`earlyclobber` operand is also a read/write + operand, then that operand is written only after it's used. + + :samp:`&` does not obviate the need to write :samp:`=` or :samp:`+`. As + :dfn:`earlyclobber` operands are always written, a read-only + :dfn:`earlyclobber` operand is ill-formed and will be rejected by the + compiler. + + .. index:: % in constraint + +:samp:`%` + Declares the instruction to be commutative for this operand and the + following operand. This means that the compiler may interchange the + two operands if that is the cheapest way to make all operands fit the + constraints. :samp:`%` applies to all alternatives and must appear as + the first character in the constraint. Only read-only operands can use + :samp:`%`. + + .. only:: gccint + + This is often used in patterns for addition instructions + that really have only two operands: the result must go in one of the + arguments. Here for example, is how the 68000 halfword-add + instruction is defined: + + .. code-block:: c++ + + (define_insn "addhi3" + [(set (match_operand:HI 0 "general_operand" "=m,r") + (plus:HI (match_operand:HI 1 "general_operand" "%0,0") + (match_operand:HI 2 "general_operand" "di,g")))] + ...) + + GCC can only handle one commutative pair in an asm; if you use more, + the compiler may fail. Note that you need not use the modifier if + the two alternatives are strictly identical; this would only waste + time in the reload pass. + + .. only:: gccint + + The modifier is not operational after + register allocation, so the result of ``define_peephole2`` + and ``define_split`` s performed after reload cannot rely on + :samp:`%` to make the intended insn match. + + .. index:: # in constraint + + :samp:`#` + Says that all following characters, up to the next comma, are to be + ignored as a constraint. They are significant only for choosing + register preferences. + + .. index:: * in constraint + + :samp:`*` + Says that the following character should be ignored when choosing + register preferences. :samp:`*` has no effect on the meaning of the + constraint as a constraint, and no effect on reloading. For LRA + :samp:`*` additionally disparages slightly the alternative if the + following character matches the operand. + + Here is an example: the 68000 has an instruction to sign-extend a + halfword in a data register, and can also sign-extend a value by + copying it into an address register. While either kind of register is + acceptable, the constraints on an address-register destination are + less strict, so it is best if register allocation makes an address + register its goal. Therefore, :samp:`*` is used so that the :samp:`d` + constraint letter (for data register) is ignored when computing + register preferences. + + .. code-block:: c++ + + (define_insn "extendhisi2" + [(set (match_operand:SI 0 "general_operand" "=*d,a") + (sign_extend:SI + (match_operand:HI 1 "general_operand" "0,g")))] + ...) + +.. index:: machine specific constraints, constraints, machine specific + +.. _machine-constraints: + +Constraints for Particular Machines +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Whenever possible, you should use the general-purpose constraint letters +in ``asm`` arguments, since they will convey meaning more readily to +people reading your code. Failing that, use the constraint letters +that usually have very similar meanings across architectures. The most +commonly used constraints are :samp:`m` and :samp:`r` (for memory and +general-purpose registers respectively; see :ref:`simple-constraints`), and +:samp:`I`, usually the letter indicating the most common +immediate-constant format. + +Each architecture defines additional constraints. These constraints +are used by the compiler itself for instruction generation, as well as +for ``asm`` statements; therefore, some of the constraints are not +particularly useful for ``asm``. Here is a summary of some of the +machine-dependent constraints available on some particular machines; +it includes both constraints that are useful for ``asm`` and +constraints that aren't. The compiler source file mentioned in the +table heading for each architecture is the definitive reference for +the meanings of that architecture's constraints. + +.. Please keep this table alphabetized by target! + +AArch64 family---:samp:`{config/aarch64/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``k`` + The stack pointer register (``SP``) + +``w`` + Floating point register, Advanced SIMD vector register or SVE vector register + +``x`` + Like ``w``, but restricted to registers 0 to 15 inclusive. + +``y`` + Like ``w``, but restricted to registers 0 to 7 inclusive. + +``Upl`` + One of the low eight SVE predicate registers (``P0`` to ``P7``) + +``Upa`` + Any of the SVE predicate registers (``P0`` to ``P15``) + +``I`` + Integer constant that is valid as an immediate operand in an ``ADD`` + instruction + +``J`` + Integer constant that is valid as an immediate operand in a ``SUB`` + instruction (once negated) + +``K`` + Integer constant that can be used with a 32-bit logical instruction + +``L`` + Integer constant that can be used with a 64-bit logical instruction + +``M`` + Integer constant that is valid as an immediate operand in a 32-bit ``MOV`` + pseudo instruction. The ``MOV`` may be assembled to one of several different + machine instructions depending on the value + +``N`` + Integer constant that is valid as an immediate operand in a 64-bit ``MOV`` + pseudo instruction + +``S`` + An absolute symbolic address or a label reference + +``Y`` + Floating point constant zero + +``Z`` + Integer constant zero + +``Ush`` + The high part (bits 12 and upwards) of the pc-relative address of a symbol + within 4GB of the instruction + +``Q`` + A memory address which uses a single base register with no offset + +``Ump`` + A memory address suitable for a load/store pair instruction in SI, DI, SF and + DF modes + +AMD GCN ---:samp:`{config/gcn/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``I`` + Immediate integer in the range -16 to 64 + +``J`` + Immediate 16-bit signed integer + +``Kf`` + Immediate constant -1 + +``L`` + Immediate 15-bit unsigned integer + +``A`` + Immediate constant that can be inlined in an instruction encoding: integer + -16..64, or float 0.0, +/-0.5, +/-1.0, +/-2.0, + +/-4.0, 1.0/(2.0\*PI) + +``B`` + Immediate 32-bit signed integer that can be attached to an instruction encoding + +``C`` + Immediate 32-bit integer in range -16..4294967295 (i.e. 32-bit unsigned + integer or :samp:`A` constraint) + +``DA`` + Immediate 64-bit constant that can be split into two :samp:`A` constants + +``DB`` + Immediate 64-bit constant that can be split into two :samp:`B` constants + +``U`` + Any ``unspec`` + +``Y`` + Any ``symbol_ref`` or ``label_ref`` + +``v`` + VGPR register + +``Sg`` + SGPR register + +``SD`` + SGPR registers valid for instruction destinations, including VCC, M0 and EXEC + +``SS`` + SGPR registers valid for instruction sources, including VCC, M0, EXEC and SCC + +``Sm`` + SGPR registers valid as a source for scalar memory instructions (excludes M0 + and EXEC) + +``Sv`` + SGPR registers valid as a source or destination for vector instructions + (excludes EXEC) + +``ca`` + All condition registers: SCC, VCCZ, EXECZ + +``cs`` + Scalar condition register: SCC + +``cV`` + Vector condition register: VCC, VCC_LO, VCC_HI + +``e`` + EXEC register (EXEC_LO and EXEC_HI) + +``RB`` + Memory operand with address space suitable for ``buffer_*`` instructions + +``RF`` + Memory operand with address space suitable for ``flat_*`` instructions + +``RS`` + Memory operand with address space suitable for ``s_*`` instructions + +``RL`` + Memory operand with address space suitable for ``ds_*`` LDS instructions + +``RG`` + Memory operand with address space suitable for ``ds_*`` GDS instructions + +``RD`` + Memory operand with address space suitable for any ``ds_*`` instructions + +``RM`` + Memory operand with address space suitable for ``global_*`` instructions + +ARC ---:samp:`{config/arc/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``q`` + Registers usable in ARCompact 16-bit instructions: ``r0`` - ``r3``, + ``r12`` - ``r15``. This constraint can only match when the :option:`-mq` + option is in effect. + +``e`` + Registers usable as base-regs of memory addresses in ARCompact 16-bit memory + instructions: ``r0`` - ``r3``, ``r12`` - ``r15``, ``sp``. + This constraint can only match when the :option:`-mq` + option is in effect. + +``D`` + ARC FPX (dpfp) 64-bit registers. ``D0``, ``D1``. + +``I`` + A signed 12-bit integer constant. + +``Cal`` + constant for arithmetic/logical operations. This might be any constant + that can be put into a long immediate by the assmbler or linker without + involving a PIC relocation. + +``K`` + A 3-bit unsigned integer constant. + +``L`` + A 6-bit unsigned integer constant. + +``CnL`` + One's complement of a 6-bit unsigned integer constant. + +``CmL`` + Two's complement of a 6-bit unsigned integer constant. + +``M`` + A 5-bit unsigned integer constant. + +``O`` + A 7-bit unsigned integer constant. + +``P`` + A 8-bit unsigned integer constant. + +``H`` + Any const_double value. + +ARM family---:samp:`{config/arm/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``h`` + In Thumb state, the core registers ``r8`` - ``r15``. + +``k`` + The stack pointer register. + +``l`` + In Thumb State the core registers ``r0`` - ``r7``. In ARM state this + is an alias for the ``r`` constraint. + +``t`` + VFP floating-point registers ``s0`` - ``s31``. Used for 32 bit values. + +``w`` + VFP floating-point registers ``d0`` - ``d31`` and the appropriate + subset ``d0`` - ``d15`` based on command line options. + Used for 64 bit values only. Not valid for Thumb1. + +``y`` + The iWMMX co-processor registers. + +``z`` + The iWMMX GR registers. + +``G`` + The floating-point constant 0.0 + +``I`` + Integer that is valid as an immediate operand in a data processing + instruction. That is, an integer in the range 0 to 255 rotated by a + multiple of 2 + +``J`` + Integer in the range -4095 to 4095 + +``K`` + Integer that satisfies constraint :samp:`I` when inverted (ones complement) + +``L`` + Integer that satisfies constraint :samp:`I` when negated (twos complement) + +``M`` + Integer in the range 0 to 32 + +``Q`` + A memory reference where the exact address is in a single register + (':samp:`m`' is preferable for ``asm`` statements) + +``R`` + An item in the constant pool + +``S`` + A symbol in the text segment of the current file + +``Uv`` + A memory reference suitable for VFP load/store insns (reg+constant offset) + +``Uy`` + A memory reference suitable for iWMMXt load/store instructions. + +``Uq`` + A memory reference suitable for the ARMv4 ldrsb instruction. + +AVR family---:samp:`{config/avr/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``l`` + Registers from r0 to r15 + +``a`` + Registers from r16 to r23 + +``d`` + Registers from r16 to r31 + +``w`` + Registers from r24 to r31. These registers can be used in :samp:`adiw` command + +``e`` + Pointer register (r26--r31) + +``b`` + Base pointer register (r28--r31) + +``q`` + Stack pointer register (SPH:SPL) + +``t`` + Temporary register r0 + +``x`` + Register pair X (r27:r26) + +``y`` + Register pair Y (r29:r28) + +``z`` + Register pair Z (r31:r30) + +``I`` + Constant greater than -1, less than 64 + +``J`` + Constant greater than -64, less than 1 + +``K`` + Constant integer 2 + +``L`` + Constant integer 0 + +``M`` + Constant that fits in 8 bits + +``N`` + Constant integer -1 + +``O`` + Constant integer 8, 16, or 24 + +``P`` + Constant integer 1 + +``G`` + A floating point constant 0.0 + +``Q`` + A memory address based on Y or Z pointer with displacement. + +Blackfin family---:samp:`{config/bfin/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``a`` + P register + +``d`` + D register + +``z`` + A call clobbered P register. + +:samp:`q{n}` + A single register. If :samp:`{n}` is in the range 0 to 7, the corresponding D + register. If it is ``A``, then the register P0. + +``D`` + Even-numbered D register + +``W`` + Odd-numbered D register + +``e`` + Accumulator register. + +``A`` + Even-numbered accumulator register. + +``B`` + Odd-numbered accumulator register. + +``b`` + I register + +``v`` + B register + +``f`` + M register + +``c`` + Registers used for circular buffering, i.e. I, B, or L registers. + +``C`` + The CC register. + +``t`` + LT0 or LT1. + +``k`` + LC0 or LC1. + +``u`` + LB0 or LB1. + +``x`` + Any D, P, B, M, I or L register. + +``y`` + Additional registers typically used only in prologues and epilogues: RETS, + RETN, RETI, RETX, RETE, ASTAT, SEQSTAT and USP. + +``w`` + Any register except accumulators or CC. + +``Ksh`` + Signed 16 bit integer (in the range -32768 to 32767) + +``Kuh`` + Unsigned 16 bit integer (in the range 0 to 65535) + +``Ks7`` + Signed 7 bit integer (in the range -64 to 63) + +``Ku7`` + Unsigned 7 bit integer (in the range 0 to 127) + +``Ku5`` + Unsigned 5 bit integer (in the range 0 to 31) + +``Ks4`` + Signed 4 bit integer (in the range -8 to 7) + +``Ks3`` + Signed 3 bit integer (in the range -3 to 4) + +``Ku3`` + Unsigned 3 bit integer (in the range 0 to 7) + +:samp:`P{n}` + Constant :samp:`{n}`, where :samp:`{n}` is a single-digit constant in the range 0 to 4. + +``PA`` + An integer equal to one of the MACFLAG_XXX constants that is suitable for + use with either accumulator. + +``PB`` + An integer equal to one of the MACFLAG_XXX constants that is suitable for + use only with accumulator A1. + +``M1`` + Constant 255. + +``M2`` + Constant 65535. + +``J`` + An integer constant with exactly a single bit set. + +``L`` + An integer constant with all bits set except exactly one. + +``H``, ``Q`` + + Any SYMBOL_REF. + +C-SKY---:samp:`{config/csky/constraints.md}` + +``a`` + The mini registers r0 - r7. + +``b`` + The low registers r0 - r15. + +``c`` + C register. + +``y`` + HI and LO registers. + +``l`` + LO register. + +``h`` + HI register. + +``v`` + Vector registers. + +``z`` + Stack pointer register (SP). + +``Q`` + A memory address which uses a base register with a short offset + or with a index register with its scale. + +``W`` + A memory address which uses a base register with a index register + with its scale. + +.. only:: gccint + + The C-SKY back end supports a large set of additional constraints + that are only useful for instruction selection or splitting rather + than inline asm, such as constraints representing constant integer + ranges accepted by particular instruction encodings. + Refer to the source code for details. + +Epiphany---:samp:`{config/epiphany/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``U16`` + An unsigned 16-bit constant. + +``K`` + An unsigned 5-bit constant. + +``L`` + A signed 11-bit constant. + +``Cm1`` + A signed 11-bit constant added to -1. + Can only match when the :option:`-m1reg-reg` option is active. + +``Cl1`` + Left-shift of -1, i.e., a bit mask with a block of leading ones, the rest + being a block of trailing zeroes. + Can only match when the :option:`-m1reg-reg` option is active. + +``Cr1`` + Right-shift of -1, i.e., a bit mask with a trailing block of ones, the + rest being zeroes. Or to put it another way, one less than a power of two. + Can only match when the :option:`-m1reg-reg` option is active. + +``Cal`` + Constant for arithmetic/logical operations. + This is like ``i``, except that for position independent code, + no symbols / expressions needing relocations are allowed. + +``Csy`` + Symbolic constant for call/jump instruction. + +``Rcs`` + The register class usable in short insns. This is a register class + constraint, and can thus drive register allocation. + This constraint won't match unless :option:`-mprefer-short-insn-regs` is + in effect. + +``Rsc`` + The register class of registers that can be used to hold a + sibcall call address. I.e., a caller-saved register. + +``Rct`` + Core control register class. + +``Rgs`` + The register group usable in short insns. + This constraint does not use a register class, so that it only + passively matches suitable registers, and doesn't drive register allocation. + +.. only:: gccint + + ``Car`` + Constant suitable for the addsi3_r pattern. This is a valid offset + For byte, halfword, or word addressing. + +``Rra`` + Matches the return address if it can be replaced with the link register. + +``Rcc`` + Matches the integer condition code register. + +``Sra`` + Matches the return address if it is in a stack slot. + +``Cfm`` + Matches control register values to switch fp mode, which are encapsulated in + ``UNSPEC_FP_MODE``. + +FRV---:samp:`{config/frv/frv.h}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``a`` + Register in the class ``ACC_REGS`` (``acc0`` to ``acc7``). + +``b`` + Register in the class ``EVEN_ACC_REGS`` (``acc0`` to ``acc7``). + +``c`` + Register in the class ``CC_REGS`` (``fcc0`` to ``fcc3`` and + ``icc0`` to ``icc3``). + +``d`` + Register in the class ``GPR_REGS`` (``gr0`` to ``gr63``). + +``e`` + Register in the class ``EVEN_REGS`` (``gr0`` to ``gr63``). + Odd registers are excluded not in the class but through the use of a machine + mode larger than 4 bytes. + +``f`` + Register in the class ``FPR_REGS`` (``fr0`` to ``fr63``). + +``h`` + Register in the class ``FEVEN_REGS`` (``fr0`` to ``fr63``). + Odd registers are excluded not in the class but through the use of a machine + mode larger than 4 bytes. + +``l`` + Register in the class ``LR_REG`` (the ``lr`` register). + +``q`` + Register in the class ``QUAD_REGS`` (``gr2`` to ``gr63``). + Register numbers not divisible by 4 are excluded not in the class but through + the use of a machine mode larger than 8 bytes. + +``t`` + Register in the class ``ICC_REGS`` (``icc0`` to ``icc3``). + +``u`` + Register in the class ``FCC_REGS`` (``fcc0`` to ``fcc3``). + +``v`` + Register in the class ``ICR_REGS`` (``cc4`` to ``cc7``). + +``w`` + Register in the class ``FCR_REGS`` (``cc0`` to ``cc3``). + +``x`` + Register in the class ``QUAD_FPR_REGS`` (``fr0`` to ``fr63``). + Register numbers not divisible by 4 are excluded not in the class but through + the use of a machine mode larger than 8 bytes. + +``z`` + Register in the class ``SPR_REGS`` (``lcr`` and ``lr``). + +``A`` + Register in the class ``QUAD_ACC_REGS`` (``acc0`` to ``acc7``). + +``B`` + Register in the class ``ACCG_REGS`` (``accg0`` to ``accg7``). + +``C`` + Register in the class ``CR_REGS`` (``cc0`` to ``cc7``). + +``G`` + Floating point constant zero + +``I`` + 6-bit signed integer constant + +``J`` + 10-bit signed integer constant + +``L`` + 16-bit signed integer constant + +``M`` + 16-bit unsigned integer constant + +``N`` + 12-bit signed integer constant that is negative---i.e. in the + range of -2048 to -1 + +``O`` + Constant zero + +``P`` + 12-bit signed integer constant that is greater than zero---i.e. in the + range of 1 to 2047. + +FT32---:samp:`{config/ft32/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``A`` + An absolute address + +``B`` + An offset address + +``W`` + A register indirect memory operand + +``e`` + An offset address. + +``f`` + An offset address. + +``O`` + The constant zero or one + +``I`` + A 16-bit signed constant (-32768 ... 32767) + +``w`` + A bitfield mask suitable for bext or bins + +``x`` + An inverted bitfield mask suitable for bext or bins + +``L`` + A 16-bit unsigned constant, multiple of 4 (0 ... 65532) + +``S`` + A 20-bit signed constant (-524288 ... 524287) + +``b`` + A constant for a bitfield width (1 ... 16) + +``KA`` + A 10-bit signed constant (-512 ... 511) + +Hewlett-Packard PA-RISC---:samp:`{config/pa/pa.h}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``a`` + General register 1 + +``f`` + Floating point register + +``q`` + Shift amount register + +``x`` + Floating point register (deprecated) + +``y`` + Upper floating point register (32-bit), floating point register (64-bit) + +``Z`` + Any register + +``I`` + Signed 11-bit integer constant + +``J`` + Signed 14-bit integer constant + +``K`` + Integer constant that can be deposited with a ``zdepi`` instruction + +``L`` + Signed 5-bit integer constant + +``M`` + Integer constant 0 + +``N`` + Integer constant that can be loaded with a ``ldil`` instruction + +``O`` + Integer constant whose value plus one is a power of 2 + +``P`` + Integer constant that can be used for ``and`` operations in ``depi`` + and ``extru`` instructions + +``S`` + Integer constant 31 + +``U`` + Integer constant 63 + +``G`` + Floating-point constant 0.0 + +``A`` + A ``lo_sum`` data-linkage-table memory operand + +``Q`` + A memory operand that can be used as the destination operand of an + integer store instruction + +``R`` + A scaled or unscaled indexed memory operand + +``T`` + A memory operand for floating-point loads and stores + +``W`` + A register indirect memory operand + +Intel IA-64---:samp:`{config/ia64/ia64.h}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``a`` + General register ``r0`` to ``r3`` for ``addl`` instruction + +``b`` + Branch register + +``c`` + Predicate register (:samp:`c` as in 'conditional') + +``d`` + Application register residing in M-unit + +``e`` + Application register residing in I-unit + +``f`` + Floating-point register + +``m`` + Memory operand. If used together with :samp:`<` or :samp:`>`, + the operand can have postincrement and postdecrement which + require printing with :samp:`%Pn` on IA-64. + +``G`` + Floating-point constant 0.0 or 1.0 + +``I`` + 14-bit signed integer constant + +``J`` + 22-bit signed integer constant + +``K`` + 8-bit signed integer constant for logical instructions + +``L`` + 8-bit adjusted signed integer constant for compare pseudo-ops + +``M`` + 6-bit unsigned integer constant for shift counts + +``N`` + 9-bit signed integer constant for load and store postincrements + +``O`` + The constant zero + +``P`` + 0 or -1 for ``dep`` instruction + +``Q`` + Non-volatile memory for floating-point loads and stores + +``R`` + Integer constant in the range 1 to 4 for ``shladd`` instruction + +``S`` + Memory operand except postincrement and postdecrement. This is + now roughly the same as :samp:`m` when not used together with :samp:`<` + or :samp:`>`. + +M32C---:samp:`{config/m32c/m32c.cc}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``Rsp`` ``Rfb`` ``Rsb`` + :samp:`$sp`, :samp:`$fb`, :samp:`$sb`. + +``Rcr`` + Any control register, when they're 16 bits wide (nothing if control + registers are 24 bits wide) + +``Rcl`` + Any control register, when they're 24 bits wide. + +``R0w`` ``R1w`` ``R2w`` ``R3w`` + $r0, $r1, $r2, $r3. + +``R02`` + $r0 or $r2, or $r2r0 for 32 bit values. + +``R13`` + $r1 or $r3, or $r3r1 for 32 bit values. + +``Rdi`` + A register that can hold a 64 bit value. + +``Rhl`` + $r0 or $r1 (registers with addressable high/low bytes) + +``R23`` + $r2 or $r3 + +``Raa`` + Address registers + +``Raw`` + Address registers when they're 16 bits wide. + +``Ral`` + Address registers when they're 24 bits wide. + +``Rqi`` + Registers that can hold QI values. + +``Rad`` + Registers that can be used with displacements ($a0, $a1, $sb). + +``Rsi`` + Registers that can hold 32 bit values. + +``Rhi`` + Registers that can hold 16 bit values. + +``Rhc`` + Registers chat can hold 16 bit values, including all control + registers. + +``Rra`` + $r0 through R1, plus $a0 and $a1. + +``Rfl`` + The flags register. + +``Rmm`` + The memory-based pseudo-registers $mem0 through $mem15. + +``Rpi`` + Registers that can hold pointers (16 bit registers for r8c, m16c; 24 + bit registers for m32cm, m32c). + +``Rpa`` + Matches multiple registers in a PARALLEL to form a larger register. + Used to match function return values. + +``Is3`` + -8 ... 7 + +``IS1`` + -128 ... 127 + +``IS2`` + -32768 ... 32767 + +``IU2`` + 0 ... 65535 + +``In4`` + -8 ... -1 or 1 ... 8 + +``In5`` + -16 ... -1 or 1 ... 16 + +``In6`` + -32 ... -1 or 1 ... 32 + +``IM2`` + -65536 ... -1 + +``Ilb`` + An 8 bit value with exactly one bit set. + +``Ilw`` + A 16 bit value with exactly one bit set. + +``Sd`` + The common src/dest memory addressing modes. + +``Sa`` + Memory addressed using $a0 or $a1. + +``Si`` + Memory addressed with immediate addresses. + +``Ss`` + Memory addressed using the stack pointer ($sp). + +``Sf`` + Memory addressed using the frame base register ($fb). + +``Ss`` + Memory addressed using the small base register ($sb). + +``S1`` + $r1h + +LoongArch---:samp:`{config/loongarch/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``f`` + A floating-point register (if available). + +``k`` + A memory operand whose address is formed by a base register and + (optionally scaled) index register. + +``l`` + A signed 16-bit constant. + +``m`` + A memory operand whose address is formed by a base register and offset + that is suitable for use in instructions with the same addressing mode + as ``st.w`` and ``ld.w``. + +``I`` + A signed 12-bit constant (for arithmetic instructions). + +``K`` + An unsigned 12-bit constant (for logic instructions). + +``ZB`` + An address that is held in a general-purpose register. + The offset is zero. + +``ZC`` + A memory operand whose address is formed by a base register and offset + that is suitable for use in instructions with the same addressing mode + as ``ll.w`` and ``sc.w``. + +MicroBlaze---:samp:`{config/microblaze/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``d`` + A general register (``r0`` to ``r31``). + +``z`` + A status register (``rmsr``, ``$fcc1`` to ``$fcc7``). + +MIPS---:samp:`{config/mips/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``d`` + A general-purpose register. This is equivalent to ``r`` unless + generating MIPS16 code, in which case the MIPS16 register set is used. + +``f`` + A floating-point register (if available). + +``h`` + Formerly the ``hi`` register. This constraint is no longer supported. + +``l`` + The ``lo`` register. Use this register to store values that are + no bigger than a word. + +``x`` + The concatenated ``hi`` and ``lo`` registers. Use this register + to store doubleword values. + +``c`` + A register suitable for use in an indirect jump. This will always be + ``$25`` for :option:`-mabicalls`. + +``v`` + Register ``$3``. Do not use this constraint in new code; + it is retained only for compatibility with glibc. + +``y`` + Equivalent to ``r`` ; retained for backwards compatibility. + +``z`` + A floating-point condition code register. + +``I`` + A signed 16-bit constant (for arithmetic instructions). + +``J`` + Integer zero. + +``K`` + An unsigned 16-bit constant (for logic instructions). + +``L`` + A signed 32-bit constant in which the lower 16 bits are zero. + Such constants can be loaded using ``lui``. + +``M`` + A constant that cannot be loaded using ``lui``, ``addiu`` + or ``ori``. + +``N`` + A constant in the range -65535 to -1 (inclusive). + +``O`` + A signed 15-bit constant. + +``P`` + A constant in the range 1 to 65535 (inclusive). + +``G`` + Floating-point zero. + +``R`` + An address that can be used in a non-macro load or store. + +``ZC`` + A memory operand whose address is formed by a base register and offset + that is suitable for use in instructions with the same addressing mode + as ``ll`` and ``sc``. + +``ZD`` + An address suitable for a ``prefetch`` instruction, or for any other + instruction with the same addressing mode as ``prefetch``. + +Motorola 680x0---:samp:`{config/m68k/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``a`` + Address register + +``d`` + Data register + +``f`` + 68881 floating-point register, if available + +``I`` + Integer in the range 1 to 8 + +``J`` + 16-bit signed number + +``K`` + Signed number whose magnitude is greater than 0x80 + +``L`` + Integer in the range -8 to -1 + +``M`` + Signed number whose magnitude is greater than 0x100 + +``N`` + Range 24 to 31, rotatert:SI 8 to 1 expressed as rotate + +``O`` + 16 (for rotate using swap) + +``P`` + Range 8 to 15, rotatert:HI 8 to 1 expressed as rotate + +``R`` + Numbers that mov3q can handle + +``G`` + Floating point constant that is not a 68881 constant + +``S`` + Operands that satisfy 'm' when -mpcrel is in effect + +``T`` + Operands that satisfy 's' when -mpcrel is not in effect + +``Q`` + Address register indirect addressing mode + +``U`` + Register offset addressing + +``W`` + const_call_operand + +``Cs`` + symbol_ref or const + +``Ci`` + const_int + +``C0`` + const_int 0 + +``Cj`` + Range of signed numbers that don't fit in 16 bits + +``Cmvq`` + Integers valid for mvq + +``Capsw`` + Integers valid for a moveq followed by a swap + +``Cmvz`` + Integers valid for mvz + +``Cmvs`` + Integers valid for mvs + +``Ap`` + push_operand + +``Ac`` + Non-register operands allowed in clr + +Moxie---:samp:`{config/moxie/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``A`` + An absolute address + +``B`` + An offset address + +``W`` + A register indirect memory operand + +``I`` + A constant in the range of 0 to 255. + +``N`` + A constant in the range of 0 to -255. + +MSP430---:samp:`{config/msp430/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``R12`` + Register R12. + +``R13`` + Register R13. + +``K`` + Integer constant 1. + +``L`` + Integer constant -1^20..1^19. + +``M`` + Integer constant 1-4. + +``Ya`` + Memory references which do not require an extended MOVX instruction. + +``Yl`` + Memory reference, labels only. + +``Ys`` + Memory reference, stack only. + +NDS32---:samp:`{config/nds32/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``w`` + LOW register class $r0 to $r7 constraint for V3/V3M ISA. + +``l`` + LOW register class $r0 to $r7. + +``d`` + MIDDLE register class $r0 to $r11, $r16 to $r19. + +``h`` + HIGH register class $r12 to $r14, $r20 to $r31. + +``t`` + Temporary assist register $ta (i.e. $r15). + +``k`` + Stack register $sp. + +``Iu03`` + Unsigned immediate 3-bit value. + +``In03`` + Negative immediate 3-bit value in the range of -7--0. + +``Iu04`` + Unsigned immediate 4-bit value. + +``Is05`` + Signed immediate 5-bit value. + +``Iu05`` + Unsigned immediate 5-bit value. + +``In05`` + Negative immediate 5-bit value in the range of -31--0. + +``Ip05`` + Unsigned immediate 5-bit value for movpi45 instruction with range 16--47. + +``Iu06`` + Unsigned immediate 6-bit value constraint for addri36.sp instruction. + +``Iu08`` + Unsigned immediate 8-bit value. + +``Iu09`` + Unsigned immediate 9-bit value. + +``Is10`` + Signed immediate 10-bit value. + +``Is11`` + Signed immediate 11-bit value. + +``Is15`` + Signed immediate 15-bit value. + +``Iu15`` + Unsigned immediate 15-bit value. + +``Ic15`` + A constant which is not in the range of imm15u but ok for bclr instruction. + +``Ie15`` + A constant which is not in the range of imm15u but ok for bset instruction. + +``It15`` + A constant which is not in the range of imm15u but ok for btgl instruction. + +``Ii15`` + A constant whose compliment value is in the range of imm15u + and ok for bitci instruction. + +``Is16`` + Signed immediate 16-bit value. + +``Is17`` + Signed immediate 17-bit value. + +``Is19`` + Signed immediate 19-bit value. + +``Is20`` + Signed immediate 20-bit value. + +``Ihig`` + The immediate value that can be simply set high 20-bit. + +``Izeb`` + The immediate value 0xff. + +``Izeh`` + The immediate value 0xffff. + +``Ixls`` + The immediate value 0x01. + +``Ix11`` + The immediate value 0x7ff. + +``Ibms`` + The immediate value with power of 2. + +``Ifex`` + The immediate value with power of 2 minus 1. + +``U33`` + Memory constraint for 333 format. + +``U45`` + Memory constraint for 45 format. + +``U37`` + Memory constraint for 37 format. + +Nios II family---:samp:`{config/nios2/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``I`` + Integer that is valid as an immediate operand in an + instruction taking a signed 16-bit number. Range + -32768 to 32767. + +``J`` + Integer that is valid as an immediate operand in an + instruction taking an unsigned 16-bit number. Range + 0 to 65535. + +``K`` + Integer that is valid as an immediate operand in an + instruction taking only the upper 16-bits of a + 32-bit number. Range 32-bit numbers with the lower + 16-bits being 0. + +``L`` + Integer that is valid as an immediate operand for a + shift instruction. Range 0 to 31. + +``M`` + Integer that is valid as an immediate operand for + only the value 0. Can be used in conjunction with + the format modifier ``z`` to use ``r0`` + instead of ``0`` in the assembly output. + +``N`` + Integer that is valid as an immediate operand for + a custom instruction opcode. Range 0 to 255. + +``P`` + An immediate operand for R2 andchi/andci instructions. + +``S`` + Matches immediates which are addresses in the small + data section and therefore can be added to ``gp`` + as a 16-bit immediate to re-create their 32-bit value. + +``U`` + Matches constants suitable as an operand for the rdprs and + cache instructions. + +``v`` + A memory operand suitable for Nios II R2 load/store + exclusive instructions. + +``w`` + A memory operand suitable for load/store IO and cache + instructions. + +.. only:: gccint + + ``T`` + A ``const`` wrapped ``UNSPEC`` expression, + representing a supported PIC or TLS relocation. + +OpenRISC---:samp:`{config/or1k/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``I`` + Integer that is valid as an immediate operand in an + instruction taking a signed 16-bit number. Range + -32768 to 32767. + +``K`` + Integer that is valid as an immediate operand in an + instruction taking an unsigned 16-bit number. Range + 0 to 65535. + +``M`` + Signed 16-bit constant shifted left 16 bits. (Used with ``l.movhi``) + +``O`` + Zero + +.. only:: gccint + + ``c`` + Register usable for sibcalls. + +PDP-11---:samp:`{config/pdp11/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``a`` + Floating point registers AC0 through AC3. These can be loaded from/to + memory with a single instruction. + +``d`` + Odd numbered general registers (R1, R3, R5). These are used for + 16-bit multiply operations. + +``D`` + A memory reference that is encoded within the opcode, but not + auto-increment or auto-decrement. + +``f`` + Any of the floating point registers (AC0 through AC5). + +``G`` + Floating point constant 0. + +``h`` + Floating point registers AC4 and AC5. These cannot be loaded from/to + memory with a single instruction. + +``I`` + An integer constant that fits in 16 bits. + +``J`` + An integer constant whose low order 16 bits are zero. + +``K`` + An integer constant that does not meet the constraints for codes + :samp:`I` or :samp:`J`. + +``L`` + The integer constant 1. + +``M`` + The integer constant -1. + +``N`` + The integer constant 0. + +``O`` + Integer constants 0 through 3; shifts by these + amounts are handled as multiple single-bit shifts rather than a single + variable-length shift. + +``Q`` + A memory reference which requires an additional word (address or + offset) after the opcode. + +``R`` + A memory reference that is encoded within the opcode. + +PowerPC and IBM RS6000---:samp:`{config/rs6000/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``r`` + A general purpose register (GPR), ``r0``... ``r31``. + +``b`` + A base register. Like ``r``, but ``r0`` is not allowed, so + ``r1``... ``r31``. + +``f`` + A floating point register (FPR), ``f0``... ``f31``. + +``d`` + A floating point register. This is the same as ``f`` nowadays; + historically ``f`` was for single-precision and ``d`` was for + double-precision floating point. + +``v`` + An Altivec vector register (VR), ``v0``... ``v31``. + +``wa`` + A VSX register (VSR), ``vs0``... ``vs63``. This is either an + FPR (``vs0``... ``vs31`` are ``f0``... ``f31``) or a VR + (``vs32``... ``vs63`` are ``v0``... ``v31``). + + When using ``wa``, you should use the ``%x`` output modifier, so that + the correct register number is printed. For example: + + .. code-block:: c++ + + asm ("xvadddp %x0,%x1,%x2" + : "=wa" (v1) + : "wa" (v2), "wa" (v3)); + + You should not use ``%x`` for ``v`` operands: + + .. code-block:: c++ + + asm ("xsaddqp %0,%1,%2" + : "=v" (v1) + : "v" (v2), "v" (v3)); + +.. only:: gccint + + ``h`` + A special register (``vrsave``, ``ctr``, or ``lr``). + +``c`` + The count register, ``ctr``. + +``l`` + The link register, ``lr``. + +``x`` + Condition register field 0, ``cr0``. + +``y`` + Any condition register field, ``cr0``... ``cr7``. + +.. only:: gccint + + ``z`` + The carry bit, ``XER[CA]``. + + ``we`` + Like ``wa``, if :option:`-mpower9-vector` and :option:`-m64` are used; + otherwise, ``NO_REGS``. + + ``wn`` + No register (``NO_REGS``). + + ``wr`` + Like ``r``, if :option:`-mpowerpc64` is used; otherwise, ``NO_REGS``. + + ``wx`` + Like ``d``, if :option:`-mpowerpc-gfxopt` is used; otherwise, ``NO_REGS``. + + ``wA`` + Like ``b``, if :option:`-mpowerpc64` is used; otherwise, ``NO_REGS``. + + ``wB`` + Signed 5-bit constant integer that can be loaded into an Altivec register. + + ``wE`` + Vector constant that can be loaded with the XXSPLTIB instruction. + + ``wF`` + Memory operand suitable for power8 GPR load fusion. + + ``wL`` + Int constant that is the element number mfvsrld accesses in a vector. + + ``wM`` + Match vector constant with all 1's if the XXLORC instruction is available. + + ``wO`` + Memory operand suitable for the ISA 3.0 vector d-form instructions. + + ``wQ`` + Memory operand suitable for the load/store quad instructions. + + ``wS`` + Vector constant that can be loaded with XXSPLTIB & sign extension. + + ``wY`` + A memory operand for a DS-form instruction. + + ``wZ`` + An indexed or indirect memory operand, ignoring the bottom 4 bits. + +``I`` + A signed 16-bit constant. + +``J`` + An unsigned 16-bit constant shifted left 16 bits (use ``L`` instead + for ``SImode`` constants). + +``K`` + An unsigned 16-bit constant. + +``L`` + A signed 16-bit constant shifted left 16 bits. + +.. only:: gccint + + ``M`` + An integer constant greater than 31. + + ``N`` + An exact power of 2. + + ``O`` + The integer constant zero. + + ``P`` + A constant whose negation is a signed 16-bit constant. + +``eI`` + A signed 34-bit integer constant if prefixed instructions are supported. + +``eQ`` + An IEEE 128-bit constant that can be loaded into a VSX register with + the ``lxvkq`` instruction. + +.. only:: gccint + + ``G`` + A floating point constant that can be loaded into a register with one + instruction per word. + + ``H`` + A floating point constant that can be loaded into a register using + three instructions. + +``m`` + A memory operand. + Normally, ``m`` does not allow addresses that update the base register. + If the ``<`` or ``>`` constraint is also used, they are allowed and + therefore on PowerPC targets in that case it is only safe + to use ``m<>`` in an ``asm`` statement if that ``asm`` statement + accesses the operand exactly once. The ``asm`` statement must also + use ``%U`` as a placeholder for the 'update' flag in the + corresponding load or store instruction. For example: + + .. code-block:: c++ + + asm ("st%U0 %1,%0" : "=m<>" (mem) : "r" (val)); + + is correct but: + + .. code-block:: c++ + + asm ("st %1,%0" : "=m<>" (mem) : "r" (val)); + + is not. + +.. only:: gccint + + ``es`` + A 'stable' memory operand; that is, one which does not include any + automodification of the base register. This used to be useful when + ``m`` allowed automodification of the base register, but as those + are now only allowed when ``<`` or ``>`` is used, ``es`` is + basically the same as ``m`` without ``<`` and ``>``. + +``Q`` + A memory operand addressed by just a base register. + +.. only:: gccint + + ``Y`` + A memory operand for a DQ-form instruction. + +``Z`` + A memory operand accessed with indexed or indirect addressing. + +.. only:: gccint + + ``R`` + An AIX TOC entry. + +``a`` + An indexed or indirect address. + +.. only:: gccint + + ``U`` + A V.4 small data reference. + + ``W`` + A vector constant that does not require memory. + + ``j`` + The zero vector constant. + +PRU---:samp:`{config/pru/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``I`` + An unsigned 8-bit integer constant. + +``J`` + An unsigned 16-bit integer constant. + +``L`` + An unsigned 5-bit integer constant (for shift counts). + +``T`` + A text segment (program memory) constant label. + +``Z`` + Integer constant zero. + +RL78---:samp:`{config/rl78/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``Int3`` + An integer constant in the range 1 ... 7. + +``Int8`` + An integer constant in the range 0 ... 255. + +``J`` + An integer constant in the range -255 ... 0 + +``K`` + The integer constant 1. + +``L`` + The integer constant -1. + +``M`` + The integer constant 0. + +``N`` + The integer constant 2. + +``O`` + The integer constant -2. + +``P`` + An integer constant in the range 1 ... 15. + +``Qbi`` + The built-in compare types--eq, ne, gtu, ltu, geu, and leu. + +``Qsc`` + The synthetic compare types--gt, lt, ge, and le. + +``Wab`` + A memory reference with an absolute address. + +``Wbc`` + A memory reference using ``BC`` as a base register, with an optional offset. + +``Wca`` + A memory reference using ``AX``, ``BC``, ``DE``, or ``HL`` for the address, for calls. + +``Wcv`` + A memory reference using any 16-bit register pair for the address, for calls. + +``Wd2`` + A memory reference using ``DE`` as a base register, with an optional offset. + +``Wde`` + A memory reference using ``DE`` as a base register, without any offset. + +``Wfr`` + Any memory reference to an address in the far address space. + +``Wh1`` + A memory reference using ``HL`` as a base register, with an optional one-byte offset. + +``Whb`` + A memory reference using ``HL`` as a base register, with ``B`` or ``C`` as the index register. + +``Whl`` + A memory reference using ``HL`` as a base register, without any offset. + +``Ws1`` + A memory reference using ``SP`` as a base register, with an optional one-byte offset. + +``Y`` + Any memory reference to an address in the near address space. + +``A`` + The ``AX`` register. + +``B`` + The ``BC`` register. + +``D`` + The ``DE`` register. + +``R`` + ``A`` through ``L`` registers. + +``S`` + The ``SP`` register. + +``T`` + The ``HL`` register. + +``Z08W`` + The 16-bit ``R8`` register. + +``Z10W`` + The 16-bit ``R10`` register. + +``Zint`` + The registers reserved for interrupts (``R24`` to ``R31``). + +``a`` + The ``A`` register. + +``b`` + The ``B`` register. + +``c`` + The ``C`` register. + +``d`` + The ``D`` register. + +``e`` + The ``E`` register. + +``h`` + The ``H`` register. + +``l`` + The ``L`` register. + +``v`` + The virtual registers. + +``w`` + The ``PSW`` register. + +``x`` + The ``X`` register. + +RISC-V---:samp:`{config/riscv/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``f`` + A floating-point register (if available). + +``I`` + An I-type 12-bit signed immediate. + +``J`` + Integer zero. + +``K`` + A 5-bit unsigned immediate for CSR access instructions. + +``A`` + An address that is held in a general-purpose register. + +``S`` + A constraint that matches an absolute symbolic address. + +RX---:samp:`{config/rx/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``Q`` + An address which does not involve register indirect addressing or + pre/post increment/decrement addressing. + +``Symbol`` + A symbol reference. + +``Int08`` + A constant in the range -256 to 255, inclusive. + +``Sint08`` + A constant in the range -128 to 127, inclusive. + +``Sint16`` + A constant in the range -32768 to 32767, inclusive. + +``Sint24`` + A constant in the range -8388608 to 8388607, inclusive. + +``Uint04`` + A constant in the range 0 to 15, inclusive. + +S/390 and zSeries---:samp:`{config/s390/s390.h}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``a`` + Address register (general purpose register except r0) + +``c`` + Condition code register + +``d`` + Data register (arbitrary general purpose register) + +``f`` + Floating-point register + +``I`` + Unsigned 8-bit constant (0--255) + +``J`` + Unsigned 12-bit constant (0--4095) + +``K`` + Signed 16-bit constant (-32768--32767) + +``L`` + Value appropriate as displacement. + + ``(0..4095)`` + for short displacement + + ``(-524288..524287)`` + for long displacement + +``M`` + Constant integer with a value of 0x7fffffff. + +``N`` + Multiple letter constraint followed by 4 parameter letters. + + ``0..9:`` + number of the part counting from most to least significant + + ``H,Q:`` + mode of the part + + ``D,S,H:`` + mode of the containing operand + + ``0,F:`` + value of the other parts (F---all bits set) + + The constraint matches if the specified part of a constant + has a value different from its other parts. + +``Q`` + Memory reference without index register and with short displacement. + +``R`` + Memory reference with index register and short displacement. + +``S`` + Memory reference without index register but with long displacement. + +``T`` + Memory reference with index register and long displacement. + +``U`` + Pointer with short displacement. + +``W`` + Pointer with long displacement. + +``Y`` + Shift count operand. + +SPARC---:samp:`{config/sparc/sparc.h}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``f`` + Floating-point register on the SPARC-V8 architecture and + lower floating-point register on the SPARC-V9 architecture. + +``e`` + Floating-point register. It is equivalent to :samp:`f` on the + SPARC-V8 architecture and contains both lower and upper + floating-point registers on the SPARC-V9 architecture. + +``c`` + Floating-point condition code register. + +``d`` + Lower floating-point register. It is only valid on the SPARC-V9 + architecture when the Visual Instruction Set is available. + +``b`` + Floating-point register. It is only valid on the SPARC-V9 architecture + when the Visual Instruction Set is available. + +``h`` + 64-bit global or out register for the SPARC-V8+ architecture. + +``C`` + The constant all-ones, for floating-point. + +``A`` + Signed 5-bit constant + +``D`` + A vector constant + +``I`` + Signed 13-bit constant + +``J`` + Zero + +``K`` + 32-bit constant with the low 12 bits clear (a constant that can be + loaded with the ``sethi`` instruction) + +``L`` + A constant in the range supported by ``movcc`` instructions (11-bit + signed immediate) + +``M`` + A constant in the range supported by ``movrcc`` instructions (10-bit + signed immediate) + +``N`` + Same as :samp:`K`, except that it verifies that bits that are not in the + lower 32-bit range are all zero. Must be used instead of :samp:`K` for + modes wider than ``SImode`` + +``O`` + The constant 4096 + +``G`` + Floating-point zero + +``H`` + Signed 13-bit constant, sign-extended to 32 or 64 bits + +``P`` + The constant -1 + +``Q`` + Floating-point constant whose integral representation can + be moved into an integer register using a single sethi + instruction + +``R`` + Floating-point constant whose integral representation can + be moved into an integer register using a single mov + instruction + +``S`` + Floating-point constant whose integral representation can + be moved into an integer register using a high/lo_sum + instruction sequence + +``T`` + Memory address aligned to an 8-byte boundary + +``U`` + Even register + +``W`` + Memory address for :samp:`e` constraint registers + +``w`` + Memory address with only a base register + +``Y`` + Vector zero + +TI C6X family---:samp:`{config/c6x/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``a`` + Register file A (A0--A31). + +``b`` + Register file B (B0--B31). + +``A`` + Predicate registers in register file A (A0--A2 on C64X and + higher, A1 and A2 otherwise). + +``B`` + Predicate registers in register file B (B0--B2). + +``C`` + A call-used register in register file B (B0--B9, B16--B31). + +``Da`` + Register file A, excluding predicate registers (A3--A31, + plus A0 if not C64X or higher). + +``Db`` + Register file B, excluding predicate registers (B3--B31). + +``Iu4`` + Integer constant in the range 0 ... 15. + +``Iu5`` + Integer constant in the range 0 ... 31. + +``In5`` + Integer constant in the range -31 ... 0. + +``Is5`` + Integer constant in the range -16 ... 15. + +``I5x`` + Integer constant that can be the operand of an ADDA or a SUBA insn. + +``IuB`` + Integer constant in the range 0 ... 65535. + +``IsB`` + Integer constant in the range -32768 ... 32767. + +``IsC`` + Integer constant in the range -2^{20} ... 2^{20} - 1. + +``Jc`` + Integer constant that is a valid mask for the clr instruction. + +``Js`` + Integer constant that is a valid mask for the set instruction. + +``Q`` + Memory location with A base register. + +``R`` + Memory location with B base register. + +.. only:: gccint + + ``S0`` + On C64x+ targets, a GP-relative small data reference. + + ``S1`` + Any kind of ``SYMBOL_REF``, for use in a call address. + + ``Si`` + Any kind of immediate operand, unless it matches the S0 constraint. + + ``T`` + Memory location with B base register, but not using a long offset. + + ``W`` + A memory operand with an address that cannot be used in an unaligned access. + +``Z`` + Register B14 (aka DP). + +Visium---:samp:`{config/visium/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``b`` + EAM register ``mdb`` + +``c`` + EAM register ``mdc`` + +``f`` + Floating point register + +.. only:: gccint + + ``k`` + Register for sibcall optimization + +``l`` + General register, but not ``r29``, ``r30`` and ``r31`` + +``t`` + Register ``r1`` + +``u`` + Register ``r2`` + +``v`` + Register ``r3`` + +``G`` + Floating-point constant 0.0 + +``J`` + Integer constant in the range 0 .. 65535 (16-bit immediate) + +``K`` + Integer constant in the range 1 .. 31 (5-bit immediate) + +``L`` + Integer constant in the range -65535 .. -1 (16-bit negative immediate) + +``M`` + Integer constant -1 + +``O`` + Integer constant 0 + +``P`` + Integer constant 32 + +x86 family---:samp:`{config/i386/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``R`` + Legacy register---the eight integer registers available on all + i386 processors (``a``, ``b``, ``c``, ``d``, + ``si``, ``di``, ``bp``, ``sp``). + +``q`` + Any register accessible as ``rl``. In 32-bit mode, ``a``, + ``b``, ``c``, and ``d`` ; in 64-bit mode, any integer register. + +``Q`` + Any register accessible as ``rh`` : ``a``, ``b``, + ``c``, and ``d``. + +.. only:: gccint + + ``l`` + Any register that can be used as the index in a base+index memory + access: that is, any general register except the stack pointer. + +``a`` + The ``a`` register. + +``b`` + The ``b`` register. + +``c`` + The ``c`` register. + +``d`` + The ``d`` register. + +``S`` + The ``si`` register. + +``D`` + The ``di`` register. + +``A`` + The ``a`` and ``d`` registers. This class is used for instructions + that return double word results in the ``ax:dx`` register pair. Single + word values will be allocated either in ``ax`` or ``dx``. + For example on i386 the following implements ``rdtsc`` : + + .. code-block:: c++ + + unsigned long long rdtsc (void) + { + unsigned long long tick; + __asm__ __volatile__("rdtsc":"=A"(tick)); + return tick; + } + + This is not correct on x86-64 as it would allocate tick in either ``ax`` + or ``dx``. You have to use the following variant instead: + + .. code-block:: c++ + + unsigned long long rdtsc (void) + { + unsigned int tickl, tickh; + __asm__ __volatile__("rdtsc":"=a"(tickl),"=d"(tickh)); + return ((unsigned long long)tickh << 32)|tickl; + } + +``U`` + The call-clobbered integer registers. + +``f`` + Any 80387 floating-point (stack) register. + +``t`` + Top of 80387 floating-point stack (``%st(0)``). + +``u`` + Second from top of 80387 floating-point stack (``%st(1)``). + +.. only:: gccint + + ``Yk`` + Any mask register that can be used as a predicate, i.e. ``k1-k7``. + + ``k`` + Any mask register. + +``y`` + Any MMX register. + +``x`` + Any SSE register. + +``v`` + Any EVEX encodable SSE register (``%xmm0-%xmm31``). + +.. only:: gccint + + ``w`` + Any bound register. + +``Yz`` + First SSE register (``%xmm0``). + +.. only:: gccint + + ``Yi`` + Any SSE register, when SSE2 and inter-unit moves are enabled. + + ``Yj`` + Any SSE register, when SSE2 and inter-unit moves from vector registers are enabled. + + ``Ym`` + Any MMX register, when inter-unit moves are enabled. + + ``Yn`` + Any MMX register, when inter-unit moves from vector registers are enabled. + + ``Yp`` + Any integer register when ``TARGET_PARTIAL_REG_STALL`` is disabled. + + ``Ya`` + Any integer register when zero extensions with ``AND`` are disabled. + + ``Yb`` + Any register that can be used as the GOT base when calling + + ``___tls_get_addr`` : that is, any general register except ``a`` + and ``sp`` registers, for :option:`-fno-plt` if linker supports it. + Otherwise, ``b`` register. + + ``Yf`` + Any x87 register when 80387 floating-point arithmetic is enabled. + + ``Yr`` + Lower SSE register when avoiding REX prefix and all SSE registers otherwise. + + ``Yv`` + For AVX512VL, any EVEX-encodable SSE register (``%xmm0-%xmm31``), + otherwise any SSE register. + + ``Yh`` + Any EVEX-encodable SSE register, that has number factor of four. + + ``Bf`` + Flags register operand. + + ``Bg`` + GOT memory operand. + + ``Bm`` + Vector memory operand. + + ``Bc`` + Constant memory operand. + +``Bn`` + Memory operand without REX prefix. + +``Bs`` + Sibcall memory operand. + +``Bw`` + Call memory operand. + +``Bz`` + Constant call address operand. + +``BC`` + SSE constant -1 operand. + +``I`` + Integer constant in the range 0 ... 31, for 32-bit shifts. + +``J`` + Integer constant in the range 0 ... 63, for 64-bit shifts. + +``K`` + Signed 8-bit integer constant. + +``L`` + ``0xFF`` or ``0xFFFF``, for andsi as a zero-extending move. + +``M`` + 0, 1, 2, or 3 (shifts for the ``lea`` instruction). + +``N`` + Unsigned 8-bit integer constant (for ``in`` and ``out`` + instructions). + +.. only:: gccint + + ``O`` + Integer constant in the range 0 ... 127, for 128-bit shifts. + +``G`` + Standard 80387 floating point constant. + +``C`` + SSE constant zero operand. + +``e`` + 32-bit signed integer constant, or a symbolic reference known + to fit that range (for immediate operands in sign-extending x86-64 + instructions). + +``We`` + 32-bit signed integer constant, or a symbolic reference known + to fit that range (for sign-extending conversion operations that + require non- ``VOIDmode`` immediate operands). + +``Wz`` + 32-bit unsigned integer constant, or a symbolic reference known + to fit that range (for zero-extending conversion operations that + require non- ``VOIDmode`` immediate operands). + +``Wd`` + 128-bit integer constant where both the high and low 64-bit word + satisfy the ``e`` constraint. + +``Z`` + 32-bit unsigned integer constant, or a symbolic reference known + to fit that range (for immediate operands in zero-extending x86-64 + instructions). + +``Tv`` + VSIB address operand. + +``Ts`` + Address operand without segment register. + +Xstormy16---:samp:`{config/stormy16/stormy16.h}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``a`` + Register r0. + +``b`` + Register r1. + +``c`` + Register r2. + +``d`` + Register r8. + +``e`` + Registers r0 through r7. + +``t`` + Registers r0 and r1. + +``y`` + The carry register. + +``z`` + Registers r8 and r9. + +``I`` + A constant between 0 and 3 inclusive. + +``J`` + A constant that has exactly one bit set. + +``K`` + A constant that has exactly one bit clear. + +``L`` + A constant between 0 and 255 inclusive. + +``M`` + A constant between -255 and 0 inclusive. + +``N`` + A constant between -3 and 0 inclusive. + +``O`` + A constant between 1 and 4 inclusive. + +``P`` + A constant between -4 and -1 inclusive. + +``Q`` + A memory reference that is a stack push. + +``R`` + A memory reference that is a stack pop. + +``S`` + A memory reference that refers to a constant address of known value. + +``T`` + The register indicated by Rx (not implemented yet). + +``U`` + A constant that is not between 2 and 15 inclusive. + +``Z`` + The constant 0. + +Xtensa---:samp:`{config/xtensa/constraints.md}` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``a`` + General-purpose 32-bit register + +``b`` + One-bit boolean register + +``A`` + MAC16 40-bit accumulator register + +``I`` + Signed 12-bit integer constant, for use in MOVI instructions + +``J`` + Signed 8-bit integer constant, for use in ADDI instructions + +``K`` + Integer constant valid for BccI instructions + +``L`` + Unsigned constant valid for BccUI instructions \ No newline at end of file diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 00000000000..f5558030ca8 --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1,3 @@ +Sphinx>=5.3 +furo +sphinx_copybutton diff --git a/gcc/d/doc/conf.py b/gcc/d/doc/conf.py new file mode 100644 index 00000000000..c33f28a2f7f --- /dev/null +++ b/gcc/d/doc/conf.py @@ -0,0 +1,30 @@ +# Configuration file for the Sphinx documentation builder. + +import sys +sys.path.append('../../..//doc') + +from baseconf import * + +name = 'gdc' +project = 'The GNU D Compiler' +copyright = '2006-2022 Free Software Foundation, Inc.' +authors = 'David Friedman, Iain Buclaw' + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +latex_documents = [ + ('index', f'{name}.tex', project, authors, 'manual'), +] + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('invoking-gdc', name, project, [authors], 1), +] + +texinfo_documents = [ + ('index', name, project, authors, None, None, None, True) +] + +set_common(name, globals()) \ No newline at end of file diff --git a/gcc/d/doc/copyright.rst b/gcc/d/doc/copyright.rst new file mode 100644 index 00000000000..5afce611a7a --- /dev/null +++ b/gcc/d/doc/copyright.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Copyright +^^^^^^^^^ + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +A copy of the license is in the :ref:`gnu_fdl`. \ No newline at end of file diff --git a/gcc/d/doc/general-public-license-3.rst b/gcc/d/doc/general-public-license-3.rst new file mode 100644 index 00000000000..becda773ca0 --- /dev/null +++ b/gcc/d/doc/general-public-license-3.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/gpl-3.0.rst \ No newline at end of file diff --git a/gcc/d/doc/gnu-free-documentation-license.rst b/gcc/d/doc/gnu-free-documentation-license.rst new file mode 100644 index 00000000000..1de809b3636 --- /dev/null +++ b/gcc/d/doc/gnu-free-documentation-license.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/gnu_free_documentation_license.rst \ No newline at end of file diff --git a/gcc/d/doc/index.rst b/gcc/d/doc/index.rst new file mode 100644 index 00000000000..700a4a8d885 --- /dev/null +++ b/gcc/d/doc/index.rst @@ -0,0 +1,22 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +The GNU D Compiler +================== + +This manual describes how to use :command:`gdc`, the GNU compiler for +the D programming language. This manual is specifically about +:command:`gdc`. For more information about the D programming +language in general, including language specifications and standard +package documentation, see https://dlang.org/. + +.. toctree:: + + copyright + invoking-gdc + general-public-license-3 + gnu-free-documentation-license + + indices-and-tables \ No newline at end of file diff --git a/gcc/d/doc/indices-and-tables.rst b/gcc/d/doc/indices-and-tables.rst new file mode 100644 index 00000000000..6c215a391d9 --- /dev/null +++ b/gcc/d/doc/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/gcc/d/doc/invoking-gdc.rst b/gcc/d/doc/invoking-gdc.rst new file mode 100644 index 00000000000..be477b82f07 --- /dev/null +++ b/gcc/d/doc/invoking-gdc.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _invoking-gdc: + +Invoking gdc +------------ + +.. only:: man + + Synopsis + ^^^^^^^^ + + gdc [ :option:`-c` | :option:`-S` ] [ :option:`-g` ] [ :option:`-pg` ] + [ :option:`-O`:samp:`{level}` ] [ :option:`-W`:samp:`{warn}`...] + [ :option:`-I`:samp:`{dir}`...] [ :option:`-L`:samp:`{dir}`...] + [ :option:`-f`:samp:`{option}`...] [ :option:`-m`:samp:`{machine-option}`...] + [ :option:`-o` :samp:`{outfile}` ] [@ :samp:`{file}` ] :samp:`{infile}`... + + Only the most useful options are listed here; see below for the + remainder. + +Description +^^^^^^^^^^^ + +The :command:`gdc` command is the GNU compiler for the D language and +supports many of the same options as :command:`gcc`. See :ref:`gcc:option-summary`. +This manual only documents the options specific to :command:`gdc`. + +Options +^^^^^^^ + +.. toctree:: + :maxdepth: 2 + + invoking-gdc/input-and-output-files + invoking-gdc/runtime-options + invoking-gdc/options-for-directory-search + invoking-gdc/code-generation + invoking-gdc/warnings + invoking-gdc/options-for-linking + invoking-gdc/developer-options + +.. only:: man + + .. include:: copyright.rst \ No newline at end of file diff --git a/gcc/d/doc/invoking-gdc/code-generation.rst b/gcc/d/doc/invoking-gdc/code-generation.rst new file mode 100644 index 00000000000..178b6f98fe2 --- /dev/null +++ b/gcc/d/doc/invoking-gdc/code-generation.rst @@ -0,0 +1,170 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: options, code generation + +.. _code-generation: + +Code Generation +*************** + +In addition to the many :command:`gcc` options controlling code generation, +:command:`gdc` has several options specific to itself. + +.. option:: -H + + .. index:: -H + + Generates D interface files for all modules being compiled. The compiler + determines the output file based on the name of the input file, removes + any directory components and suffix, and applies the :samp:`.di` suffix. + +.. option:: -Hd dir + + .. index:: -Hd + + Same as :option:`-H`, but writes interface files to directory :samp:`{dir}`. + This option can be used with :option:`-Hf file` to independently set the + output file and directory path. + +.. option:: -Hf file + + .. index:: -Hf + + Same as :option:`-H` but writes interface files to :samp:`{file}`. This option can + be used with :option:`-Hd dir` to independently set the output file and + directory path. + +.. option:: -M + + .. index:: -M + + Output the module dependencies of all source files being compiled in a + format suitable for :command:`make`. The compiler outputs one + :command:`make` rule containing the object file name for that source file, + a colon, and the names of all imported files. + +.. option:: -MM + + .. index:: -MM + + Like :option:`-M` but does not mention imported modules from the D standard + library package directories. + +.. option:: -MF file + + .. index:: -MF + + When used with :option:`-M` or :option:`-MM`, specifies a :samp:`{file}` to write + the dependencies to. When used with the driver options :option:`-MD` or + :option:`-MMD`, :option:`-MF` overrides the default dependency output file. + +.. option:: -MG + + .. index:: -MG + + This option is for compatibility with :command:`gcc`, and is ignored by the + compiler. + +.. option:: -MP + + .. index:: -MP + + Outputs a phony target for each dependency other than the modules being + compiled, causing each to depend on nothing. + +.. option:: -MT target + + .. index:: -MT + + Change the :samp:`{target}` of the rule emitted by dependency generation + to be exactly the string you specify. If you want multiple targets, + you can specify them as a single argument to :option:`-MT`, or use + multiple :option:`-MT` options. + +.. option:: -MQ target + + .. index:: -MQ + + Same as :option:`-MT`, but it quotes any characters which are special to + :command:`make`. + +.. option:: -MD + + .. index:: -MD + + This option is equivalent to :option:`-M -MF file`. The driver + determines :samp:`{file}` by removing any directory components and suffix + from the input file, and then adding a :samp:`.deps` suffix. + +.. option:: -MMD + + .. index:: -MMD + + Like :option:`-MD` but does not mention imported modules from the D standard + library package directories. + +.. option:: -X + + .. index:: -X + + Output information describing the contents of all source files being + compiled in JSON format to a file. The driver determines :samp:`{file}` by + removing any directory components and suffix from the input file, and then + adding a :samp:`.json` suffix. + +.. option:: -Xf file + + .. index:: -Xf + + Same as :option:`-X`, but writes all JSON contents to the specified + :samp:`{file}`. + +.. option:: -fdoc + + .. index:: -fdoc + + Generates ``Ddoc`` documentation and writes it to a file. The compiler + determines :samp:`{file}` by removing any directory components and suffix + from the input file, and then adding a :samp:`.html` suffix. + +.. option:: -fdoc-dir=dir + + .. index:: -fdoc-dir + + Same as :option:`-fdoc`, but writes documentation to directory :samp:`{dir}`. + This option can be used with :option:`-fdoc-file=file` to + independently set the output file and directory path. + +.. option:: -fdoc-file=file + + .. index:: -fdoc-file + + Same as :option:`-fdoc`, but writes documentation to :samp:`{file}`. This + option can be used with :option:`-fdoc-dir=dir` to independently + set the output file and directory path. + +.. option:: -fdoc-inc=file + + .. index:: -fdoc-inc + + Specify :samp:`{file}` as a :samp:`{Ddoc}` macro file to be read. Multiple + :option:`-fdoc-inc` options can be used, and files are read and processed + in the same order. + +.. option:: -fdump-c++-spec={file} + + For D source files, generate corresponding C++ declarations in :samp:`{file}`. + +.. option:: -fdump-c++-spec-verbose + + In conjunction with :option:`-fdump-c++-spec=` above, add comments for ignored + declarations in the generated C++ header. + +.. option:: -fsave-mixins={file} + + Generates code expanded from D ``mixin`` statements and writes the + processed sources to :samp:`{file}`. This is useful to debug errors in compilation + and provides source for debuggers to show when requested. \ No newline at end of file diff --git a/gcc/d/doc/invoking-gdc/developer-options.rst b/gcc/d/doc/invoking-gdc/developer-options.rst new file mode 100644 index 00000000000..564ed36d6c0 --- /dev/null +++ b/gcc/d/doc/invoking-gdc/developer-options.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: developer options, debug dump options, dump options + +.. _developer-options: + +Developer Options +***************** + +This section describes command-line options that are primarily of +interest to developers or language tooling. + +.. option:: -fdump-d-original + + .. index:: -fdump-d-original + + Output the internal front-end AST after the ``semantic3`` stage. + This option is only useful for debugging the GNU D compiler itself. + +.. option:: -v + + .. index:: -v + + Dump information about the compiler language processing stages as the source + program is being compiled. This includes listing all modules that are + processed through the ``parse``, ``semantic``, ``semantic2``, and + ``semantic3`` stages; all ``import`` modules and their file paths; + and all ``function`` bodies that are being compiled. \ No newline at end of file diff --git a/gcc/d/doc/invoking-gdc/input-and-output-files.rst b/gcc/d/doc/invoking-gdc/input-and-output-files.rst new file mode 100644 index 00000000000..a4bce6b9aba --- /dev/null +++ b/gcc/d/doc/invoking-gdc/input-and-output-files.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: suffixes for D source, D source file suffixes + +.. _input-and-output-files: + +Input and Output files +********************** + +For any given input file, the file name suffix determines what kind of +compilation is done. The following kinds of input file names are supported: + +:samp:`{file}.d` + D source files. + +:samp:`{file}.dd` + Ddoc source files. + +:samp:`{file}.di` + D interface files. + +You can specify more than one input file on the :command:`gdc` command line, +each being compiled separately in the compilation process. If you specify a +``-o file`` option, all the input files are compiled together, +producing a single output file, named :samp:`{file}`. This is allowed even +when using ``-S`` or ``-c``. + +.. index:: D interface files. + +A D interface file contains only what an import of the module needs, +rather than the whole implementation of that module. They can be created +by :command:`gdc` from a D source file by using the ``-H`` option. +When the compiler resolves an import declaration, it searches for matching +:samp:`.di` files first, then for :samp:`.d`. + +.. index:: Ddoc source files. + +A Ddoc source file contains code in the D macro processor language. It is +primarily designed for use in producing user documentation from embedded +comments, with a slight affinity towards HTML generation. If a :samp:`.d` +source file starts with the string ``Ddoc`` then it is treated as general +purpose documentation, not as a D source file. \ No newline at end of file diff --git a/gcc/d/doc/invoking-gdc/options-for-directory-search.rst b/gcc/d/doc/invoking-gdc/options-for-directory-search.rst new file mode 100644 index 00000000000..934b22df5b0 --- /dev/null +++ b/gcc/d/doc/invoking-gdc/options-for-directory-search.rst @@ -0,0 +1,92 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: directory options, options, directory search, search path + +.. _directory-options: + +Options for Directory Search +**************************** + +These options specify directories to search for files, libraries, and +other parts of the compiler: + +.. option:: -Idir + + .. index:: -I + + Specify a directory to use when searching for imported modules at + compile time. Multiple :option:`-I` options can be used, and the + paths are searched in the same order. + +.. option:: -Jdir + + .. index:: -J + + Specify a directory to use when searching for files in string imports + at compile time. This switch is required in order to use + ``import(file)`` expressions. Multiple :option:`-J` options can be + used, and the paths are searched in the same order. + +.. option:: -Ldir + + .. index:: -L + + When linking, specify a library search directory, as with :command:`gcc`. + +.. option:: -Bdir + + .. index:: -B + + This option specifies where to find the executables, libraries, + source files, and data files of the compiler itself, as with :command:`gcc`. + +.. option:: -fmodule-file=module=spec + + .. index:: -fmodule-file + + This option manipulates file paths of imported modules, such that if an + imported module matches all or the leftmost part of :samp:`{module}`, the file + path in :samp:`{spec}` is used as the location to search for D sources. + This is used when the source file path and names are not the same as the + package and module hierarchy. Consider the following examples: + + .. code-block:: c++ + + gdc test.d -fmodule-file=A.B=foo.d -fmodule-file=C=bar + + This will tell the compiler to search in all import paths for the source + file :samp:`{foo.d}` when importing :samp:`{A.B}`, and the directory :samp:`{bar/}` + when importing :samp:`{C}`, as annotated in the following D code: + + .. code-block:: c++ + + module test; + import A.B; // Matches A.B, searches for foo.d + import C.D.E; // Matches C, searches for bar/D/E.d + import A.B.C; // No match, searches for A/B/C.d + +.. option:: -imultilib dir + + .. index:: -imultilib + + Use :samp:`{dir}` as a subdirectory of the gcc directory containing + target-specific D sources and interfaces. + +.. option:: -iprefix prefix + + .. index:: -iprefix + + Specify :samp:`{prefix}` as the prefix for the gcc directory containing + target-specific D sources and interfaces. If the :samp:`{prefix}` represents + a directory, you should include the final ``'/'``. + +.. option:: -nostdinc + + .. index:: -nostdinc + + Do not search the standard system directories for D source and interface + files. Only the directories that have been specified with :option:`-I` options + (and the directory of the current file, if appropriate) are searched. \ No newline at end of file diff --git a/gcc/d/doc/invoking-gdc/options-for-linking.rst b/gcc/d/doc/invoking-gdc/options-for-linking.rst new file mode 100644 index 00000000000..dc64fcd206a --- /dev/null +++ b/gcc/d/doc/invoking-gdc/options-for-linking.rst @@ -0,0 +1,59 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: options, linking, linking, static + +.. _linking: + +Options for Linking +******************* + +These options come into play when the compiler links object files into an +executable output file. They are meaningless if the compiler is not doing +a link step. + +.. option:: -defaultlib=libname + + .. index:: -defaultlib= + + Specify the library to use instead of libphobos when linking. Options + specifying the linkage of libphobos, such as :option:`-static-libphobos` + or :option:`-shared-libphobos`, are ignored. + +.. option:: -debuglib=libname + + .. index:: -debuglib= + + Specify the debug library to use instead of libphobos when linking. + This option has no effect unless the :option:`-g` option was also given + on the command line. Options specifying the linkage of libphobos, such + as :option:`-static-libphobos` or :option:`-shared-libphobos`, are ignored. + +.. option:: -nophoboslib + + .. index:: -nophoboslib + + Do not use the Phobos or D runtime library when linking. Options specifying + the linkage of libphobos, such as :option:`-static-libphobos` or + :option:`-shared-libphobos`, are ignored. The standard system libraries are + used normally, unless :option:`-nostdlib` or :option:`-nodefaultlibs` is used. + +.. option:: -shared-libphobos + + .. index:: -shared-libphobos + + On systems that provide :samp:`libgphobos` and :samp:`libgdruntime` as a + shared and a static library, this option forces the use of the shared + version. If no shared version was built when the compiler was configured, + this option has no effect. + +.. option:: -static-libphobos + + .. index:: -static-libphobos + + On systems that provide :samp:`libgphobos` and :samp:`libgdruntime` as a + shared and a static library, this option forces the use of the static + version. If no static version was built when the compiler was configured, + this option has no effect. \ No newline at end of file diff --git a/gcc/d/doc/invoking-gdc/runtime-options.rst b/gcc/d/doc/invoking-gdc/runtime-options.rst new file mode 100644 index 00000000000..fda87c2b96e --- /dev/null +++ b/gcc/d/doc/invoking-gdc/runtime-options.rst @@ -0,0 +1,314 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: options, runtime + +.. _runtime-options: + +Runtime Options +*************** + +These options affect the runtime behavior of programs compiled with +:command:`gdc`. + +.. option:: -fall-instantiations + + .. index:: -fall-instantiations, -fno-all-instantiations + + Generate code for all template instantiations. The default template emission + strategy is to not generate code for declarations that were either + instantiated speculatively, such as from ``__traits(compiles, ...)``, or + that come from an imported module not being compiled. + +.. option:: -fno-assert + + .. index:: -fassert, -fno-assert + + Turn off code generation for ``assert`` contracts. + +.. option:: -fno-bounds-check + + .. index:: -fbounds-check, -fno-bounds-check + + Turns off array bounds checking for all functions, which can improve + performance for code that uses arrays extensively. Note that this + can result in unpredictable behavior if the code in question actually + does violate array bounds constraints. It is safe to use this option + if you are sure that your code never throws a ``RangeError``. + +.. option:: -fbounds-check=value + + .. index:: -fbounds-check= + + An alternative to :option:`-fbounds-check` that allows more control + as to where bounds checking is turned on or off. The following values + are supported: + + :samp:`on` + Turns on array bounds checking for all functions. + + :samp:`safeonly` + Turns on array bounds checking only for ``@safe`` functions. + + :samp:`off` + Turns off array bounds checking completely. + +.. option:: -fno-builtin + + .. index:: -fbuiltin, -fno-builtin + + Don't recognize built-in functions unless they begin with the prefix + :samp:`__builtin_`. By default, the compiler will recognize when a + function in the ``core.stdc`` package is a built-in function. + +.. option:: -fcheckaction + + This option controls what code is generated on an assertion, bounds check, or + final switch failure. The following values are supported: + + :samp:`context` + Throw an ``AssertError`` with extra context information. + + :samp:`halt` + Halt the program execution. + + :samp:`throw` + Throw an ``AssertError`` (the default). + +.. option:: -fdebug=value + + .. index:: -fno-debug + + Turn on compilation of conditional ``debug`` code into the program. + The :option:`-fdebug` option itself sets the debug level to ``1``, + while :option:`-fdebug=` enables ``debug`` code that are identified + by any of the following values: + + :samp:`level` + Sets the debug level to :samp:`{level}`, any ``debug`` code <= :samp:`{level}` + is compiled into the program. + + :samp:`ident` + Turns on compilation of any ``debug`` code identified by :samp:`{ident}`. + +.. option:: -fno-druntime + + .. index:: -fdruntime, -fno-druntime + + Implements https://dlang.org/spec/betterc.html. Assumes that + compilation targets an environment without a D runtime library. + + This is equivalent to compiling with the following options: + + .. code-block:: c++ + + gdc -nophoboslib -fno-exceptions -fno-moduleinfo -fno-rtti + +.. option:: -fextern-std=standard + + Sets the C++ name mangling compatibility to the version identified by + :samp:`{standard}`. The following values are supported: + + :samp:`c++98`, :samp:`c++03` + Sets ``__traits(getTargetInfo, "cppStd")`` to ``199711``. + + :samp:`c++11` + Sets ``__traits(getTargetInfo, "cppStd")`` to ``201103``. + + :samp:`c++14` + Sets ``__traits(getTargetInfo, "cppStd")`` to ``201402``. + + :samp:`c++17` + Sets ``__traits(getTargetInfo, "cppStd")`` to ``201703``. + This is the default. + + :samp:`c++20` + Sets ``__traits(getTargetInfo, "cppStd")`` to ``202002``. + +.. option:: -fno-invariants + + .. index:: -finvariants, -fno-invariants + + Turns off code generation for class ``invariant`` contracts. + +.. option:: -fmain + + Generates a default ``main()`` function when compiling. This is useful when + unittesting a library, as it enables running the unittests in a library without + having to manually define an entry-point function. This option does nothing + when ``main`` is already defined in user code. + +.. option:: -fno-moduleinfo + + Turns off generation of the ``ModuleInfo`` and related functions + that would become unreferenced without it, which may allow linking + to programs not written in D. Functions that are not be generated + include module constructors and destructors (``static this`` and + ``static ~this``), ``unittest`` code, and ``DSO`` registry + functions for dynamically linked code. + +.. option:: -fonly=filename + + .. index:: -fonly + + Tells the compiler to parse and run semantic analysis on all modules + on the command line, but only generate code for the module specified + by :samp:`{filename}`. + +.. option:: -fno-postconditions + + .. index:: -fpostconditions, -fno-postconditions + + Turns off code generation for postcondition ``out`` contracts. + +.. option:: -fno-preconditions + + .. index:: -fpreconditions, -fno-preconditions + + Turns off code generation for precondition ``in`` contracts. + +.. option:: -fpreview=id + + .. index:: -fpreview + + Turns on an upcoming D language change identified by :samp:`{id}`. The following + values are supported: + + :samp:`all` + Turns on all upcoming D language features. + + :samp:`dip1000` + Implements https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1000.md + (Scoped pointers). + + :samp:`dip1008` + Implements https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1008.md + (Allow exceptions in ``@nogc`` code). + + :samp:`dip1021` + Implements https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1021.md + (Mutable function arguments). + + :samp:`dip25` + Implements https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md + (Sealed references). + + :samp:`dtorfields` + Turns on generation for destructing fields of partially constructed objects. + + :samp:`fieldwise` + Turns on generation of struct equality to use field-wise comparisons. + + :samp:`fixaliasthis` + Implements new lookup rules that check the current scope for ``alias this`` + before searching in upper scopes. + + :samp:`fiximmutableconv` + Disallows unsound immutable conversions that were formerly incorrectly + permitted. + + :samp:`in` + Implements ``in`` parameters to mean ``scope const [ref]`` and accepts + rvalues. + + :samp:`inclusiveincontracts` + Implements ``in`` contracts of overridden methods to be a superset of parent + contract. + + :samp:`intpromote` + Implements C-style integral promotion for unary ``+``, ``-`` and ``~`` + expressions. + + :samp:`nosharedaccess` + Turns off and disallows all access to shared memory objects. + + :samp:`rvaluerefparam` + Implements rvalue arguments to ``ref`` parameters. + + :samp:`systemvariables` + Disables access to variables marked ``@system`` from ``@safe`` code. + +.. option:: -frelease + + .. index:: -fno-release + + Turns on compiling in release mode, which means not emitting runtime + checks for contracts and asserts. Array bounds checking is not done + for ``@system`` and ``@trusted`` functions, and assertion + failures are undefined behavior. + + This is equivalent to compiling with the following options: + + .. code-block:: c++ + + gdc -fno-assert -fbounds-check=safe -fno-invariants \ + -fno-postconditions -fno-preconditions -fno-switch-errors + +.. option:: -frevert= + + .. index:: -frevert + + Turns off a D language feature identified by :samp:`{id}`. The following values + are supported: + + :samp:`all` + Turns off all revertable D language features. + + :samp:`dip25` + Reverts https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md + (Sealed references). + + :samp:`dtorfields` + Turns off generation for destructing fields of partially constructed objects. + + :samp:`markdown` + Turns off Markdown replacements in Ddoc comments. + +.. option:: -fno-rtti + + .. index:: -frtti, -fno-rtti + + Turns off generation of run-time type information for all user defined types. + Any code that uses features of the language that require access to this + information will result in an error. + +.. option:: -fno-switch-errors + + .. index:: -fswitch-errors, -fno-switch-errors + + This option controls what code is generated when no case is matched + in a ``final switch`` statement. The default run time behavior + is to throw a ``SwitchError``. Turning off :option:`-fswitch-errors` + means that instead the execution of the program is immediately halted. + +.. option:: -funittest + + .. index:: -funittest, -fno-unittest + + Turns on compilation of ``unittest`` code, and turns on the + ``version(unittest)`` identifier. This implies :option:`-fassert`. + +.. option:: -fversion=value + + .. index:: -fversion + + Turns on compilation of conditional ``version`` code into the program + identified by any of the following values: + + :samp:`level` + Sets the version level to :samp:`{level}`, any ``version`` code >= :samp:`{level}` + is compiled into the program. + + :samp:`ident` + Turns on compilation of ``version`` code identified by :samp:`{ident}`. + +.. option:: -fno-weak-templates + + .. index:: -fweak-templates, -fno-weak-templates + + Turns off emission of declarations that can be defined in multiple objects as + weak symbols. The default is to emit all public symbols as weak, unless the + target lacks support for weak symbols. Disabling this option means that common + symbols are instead put in COMDAT or become private. \ No newline at end of file diff --git a/gcc/d/doc/invoking-gdc/warnings.rst b/gcc/d/doc/invoking-gdc/warnings.rst new file mode 100644 index 00000000000..c9ed52e7630 --- /dev/null +++ b/gcc/d/doc/invoking-gdc/warnings.rst @@ -0,0 +1,148 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: options to control warnings, warning messages, messages, warning, suppressing warnings + +.. _warnings: + +Warnings +******** + +Warnings are diagnostic messages that report constructions that +are not inherently erroneous but that are risky or suggest there +is likely to be a bug in the program. Unless :option:`-Werror` is +specified, they do not prevent compilation of the program. + +.. option:: -Wall + + .. index:: -Wall, -Wno-all + + Turns on all warnings messages. Warnings are not a defined part of + the D language, and all constructs for which this may generate a + warning message are valid code. + +.. option:: -Walloca + + .. index:: -Walloca + + This option warns on all uses of "alloca" in the source. + +.. option:: -Walloca-larger-than=n + + .. index:: -Walloca-larger-than, -Wno-alloca-larger-than + + Warn on unbounded uses of alloca, and on bounded uses of alloca + whose bound can be larger than :samp:`{n}` bytes. + :option:`-Wno-alloca-larger-than` disables + :option:`-Walloca-larger-than` warning and is equivalent to + :option:`-Walloca-larger-than=SIZE_MAX` or larger. + +.. option:: -Wcast-result + + .. index:: -Wcast-result, -Wno-cast-result + + Warn about casts that will produce a null or zero result. Currently + this is only done for casting between an imaginary and non-imaginary + data type, or casting between a D and C++ class. + +.. option:: -Wno-deprecated + + .. index:: -Wdeprecated, -Wno-deprecated + + Do not warn about usage of deprecated features and symbols with + ``deprecated`` attributes. + +.. option:: -Werror + + .. index:: -Werror, -Wno-error + + Turns all warnings into errors. + +.. option:: -Wspeculative + + .. index:: -Wspeculative, -Wno-speculative + + List all error messages from speculative compiles, such as + ``__traits(compiles, ...)``. This option does not report + messages as warnings, and these messages therefore never become + errors when the :option:`-Werror` option is also used. + +.. option:: -Wtemplates + + .. index:: -Wtemplates, -Wno-templates + + Warn when a template instantiation is encountered. Some coding + rules disallow templates, and this may be used to enforce that rule. + +.. option:: -Wunknown-pragmas + + .. index:: -Wunknown-pragmas, -Wno-unknown-pragmas + + Warn when a ``pragma()`` is encountered that is not understood by + :command:`gdc`. This differs from :option:`-fignore-unknown-pragmas` + where a pragma that is part of the D language, but not implemented by + the compiler, won't get reported. + +.. option:: -Wno-varargs + + .. index:: Wvarargs, Wno-varargs + + Do not warn upon questionable usage of the macros used to handle variable + arguments like ``va_start``. + +.. option:: -fignore-unknown-pragmas + + .. index:: -fignore-unknown-pragmas, -fno-ignore-unknown-pragmas + + Turns off errors for unsupported pragmas. + +.. option:: -fmax-errors=n + + .. index:: -fmax-errors + + Limits the maximum number of error messages to :samp:`{n}`, at which point + :command:`gdc` bails out rather than attempting to continue processing the + source code. If :samp:`{n}` is 0 (the default), there is no limit on the + number of error messages produced. + +.. option:: -fsyntax-only + + .. index:: -fsyntax-only, -fno-syntax-only + + Check the code for syntax errors, but do not actually compile it. This + can be used in conjunction with :option:`-fdoc` or :option:`-H` to generate + files for each module present on the command-line, but no other output + file. + +.. option:: -ftransition=id + + .. index:: -ftransition + + Report additional information about D language changes identified by + :samp:`{id}`. The following values are supported: + + :samp:`all` + List information on all D language transitions. + + :samp:`complex` + List all usages of complex or imaginary types. + + :samp:`field` + List all non-mutable fields which occupy an object instance. + + :samp:`in` + List all usages of ``in`` on parameter. + + :samp:`nogc` + List all hidden GC allocations. + + :samp:`templates` + List statistics on template instantiations. + + :samp:`tls` + List all variables going into thread local storage. + + :samp:`vmarkdown` + List instances of Markdown replacements in Ddoc. \ No newline at end of file diff --git a/gcc/doc/cpp/character-sets.rst b/gcc/doc/cpp/character-sets.rst new file mode 100644 index 00000000000..f4b6e05515c --- /dev/null +++ b/gcc/doc/cpp/character-sets.rst @@ -0,0 +1,56 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _character-sets: + +Character sets +************** + +Source code character set processing in C and related languages is +rather complicated. The C standard discusses two character sets, but +there are really at least four. + +The files input to CPP might be in any character set at all. CPP's +very first action, before it even looks for line boundaries, is to +convert the file into the character set it uses for internal +processing. That set is what the C standard calls the :dfn:`source` +character set. It must be isomorphic with ISO 10646, also known as +Unicode. CPP uses the UTF-8 encoding of Unicode. + +The character sets of the input files are specified using the +:option:`-finput-charset=` option. + +All preprocessing work (the subject of the rest of this manual) is +carried out in the source character set. If you request textual +output from the preprocessor with the :option:`-E` option, it will be +in UTF-8. + +After preprocessing is complete, string and character constants are +converted again, into the :dfn:`execution` character set. This +character set is under control of the user; the default is UTF-8, +matching the source character set. Wide string and character +constants have their own character set, which is not called out +specifically in the standard. Again, it is under control of the user. +The default is UTF-16 or UTF-32, whichever fits in the target's +``wchar_t`` type, in the target machine's byte +order [#f1]_. + +Octal and hexadecimal escape sequences do not undergo +conversion; ``'\x12'`` has the value 0x12 regardless of the currently +selected execution character set. All other escapes are replaced by +the character in the source character set that they represent, then +converted to the execution character set, just like unescaped +characters. + +In identifiers, characters outside the ASCII range can be specified +with the :samp:`\\u` and :samp:`\\U` escapes or used directly in the input +encoding. If strict ISO C90 conformance is specified with an option +such as :option:`-std=c90`, or :option:`-fno-extended-identifiers` is +used, then those constructs are not permitted in identifiers. + +.. [#f1] UTF-16 does not meet the requirements of the C + standard for a wide character set, but the choice of 16-bit + ``wchar_t`` is enshrined in some system ABIs so we cannot fix + this. \ No newline at end of file diff --git a/gcc/doc/cpp/conditional-syntax.rst b/gcc/doc/cpp/conditional-syntax.rst new file mode 100644 index 00000000000..1dec2ac6f4b --- /dev/null +++ b/gcc/doc/cpp/conditional-syntax.rst @@ -0,0 +1,411 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: #if + +.. _conditional-syntax: + +Conditional Syntax +****************** + +A conditional in the C preprocessor begins with a :dfn:`conditional +directive`: :samp:`#if`, :samp:`#ifdef` or :samp:`#ifndef`. + +.. toctree:: + :maxdepth: 2 + + +.. index:: #ifdef, #endif + +.. _ifdef: + +Ifdef +^^^^^ + +The simplest sort of conditional is + +.. code-block:: c++ + + #ifdef MACRO + + controlled text + + #endif /* MACRO */ + +.. index:: conditional group + +This block is called a :dfn:`conditional group`. :samp:`{controlled text}` +will be included in the output of the preprocessor if and only if +:samp:`{MACRO}` is defined. We say that the conditional :dfn:`succeeds` if +:samp:`{MACRO}` is defined, :dfn:`fails` if it is not. + +The :samp:`{controlled text}` inside of a conditional can include +preprocessing directives. They are executed only if the conditional +succeeds. You can nest conditional groups inside other conditional +groups, but they must be completely nested. In other words, +:samp:`#endif` always matches the nearest :samp:`#ifdef` (or +:samp:`#ifndef`, or :samp:`#if`). Also, you cannot start a conditional +group in one file and end it in another. + +Even if a conditional fails, the :samp:`{controlled text}` inside it is +still run through initial transformations and tokenization. Therefore, +it must all be lexically valid C. Normally the only way this matters is +that all comments and string literals inside a failing conditional group +must still be properly ended. + +The comment following the :samp:`#endif` is not required, but it is a +good practice if there is a lot of :samp:`{controlled text}`, because it +helps people match the :samp:`#endif` to the corresponding :samp:`#ifdef`. +Older programs sometimes put :samp:`{MACRO}` directly after the +:samp:`#endif` without enclosing it in a comment. This is invalid code +according to the C standard. CPP accepts it with a warning. It +never affects which :samp:`#ifndef` the :samp:`#endif` matches. + +.. index:: #ifndef + +Sometimes you wish to use some code if a macro is *not* defined. +You can do this by writing :samp:`#ifndef` instead of :samp:`#ifdef`. +One common use of :samp:`#ifndef` is to include code only the first +time a header file is included. See :ref:`once-only-headers`. + +Macro definitions can vary between compilations for several reasons. +Here are some samples. + +* Some macros are predefined on each kind of machine + (see :ref:`system-specific-predefined-macros`). This allows you to provide + code specially tuned for a particular machine. + +* System header files define more macros, associated with the features + they implement. You can test these macros with conditionals to avoid + using a system feature on a machine where it is not implemented. + +* Macros can be defined or undefined with the :option:`-D` and :option:`-U` + command-line options when you compile the program. You can arrange to + compile the same source file into two different programs by choosing a + macro name to specify which program you want, writing conditionals to + test whether or how this macro is defined, and then controlling the + state of the macro with command-line options, perhaps set in the + Makefile. See :ref:`invocation`. + +* Your program might have a special header file (often called + :samp:`config.h`) that is adjusted when the program is compiled. It can + define or not define macros depending on the features of the system and + the desired capabilities of the program. The adjustment can be + automated by a tool such as :command:`autoconf`, or done by hand. + +.. _if: + +If +^^ + +The :samp:`#if` directive allows you to test the value of an arithmetic +expression, rather than the mere existence of one macro. Its syntax is + +.. code-block:: c++ + + #if expression + + controlled text + + #endif /* expression */ + +:samp:`{expression}` is a C expression of integer type, subject to stringent +restrictions. It may contain + +* Integer constants. + +* Character constants, which are interpreted as they would be in normal + code. + +* Arithmetic operators for addition, subtraction, multiplication, + division, bitwise operations, shifts, comparisons, and logical + operations (``&&`` and ``||``). The latter two obey the usual + short-circuiting rules of standard C. + +* Macros. All macros in the expression are expanded before actual + computation of the expression's value begins. + +* Uses of the ``defined`` operator, which lets you check whether macros + are defined in the middle of an :samp:`#if`. + +* Identifiers that are not macros, which are all considered to be the + number zero. This allows you to write ``#if MACRO`` instead of + ``#ifdef MACRO``, if you know that MACRO, when defined, will + always have a nonzero value. Function-like macros used without their + function call parentheses are also treated as zero. + + In some contexts this shortcut is undesirable. The :option:`-Wundef` + option causes GCC to warn whenever it encounters an identifier which is + not a macro in an :samp:`#if`. + +The preprocessor does not know anything about types in the language. +Therefore, ``sizeof`` operators are not recognized in :samp:`#if`, and +neither are ``enum`` constants. They will be taken as identifiers +which are not macros, and replaced by zero. In the case of +``sizeof``, this is likely to cause the expression to be invalid. + +The preprocessor calculates the value of :samp:`{expression}`. It carries +out all calculations in the widest integer type known to the compiler; +on most machines supported by GCC this is 64 bits. This is not the same +rule as the compiler uses to calculate the value of a constant +expression, and may give different results in some cases. If the value +comes out to be nonzero, the :samp:`#if` succeeds and the :samp:`{controlled +text}` is included; otherwise it is skipped. + +.. index:: defined + +.. _defined: + +Defined +^^^^^^^ + +The special operator ``defined`` is used in :samp:`#if` and +:samp:`#elif` expressions to test whether a certain name is defined as a +macro. ``defined name`` and ``defined (name)`` are +both expressions whose value is 1 if :samp:`{name}` is defined as a macro at +the current point in the program, and 0 otherwise. Thus, ``#if +defined MACRO`` is precisely equivalent to ``#ifdef MACRO``. + +``defined`` is useful when you wish to test more than one macro for +existence at once. For example, + +.. code-block:: c++ + + #if defined (__vax__) || defined (__ns16000__) + +would succeed if either of the names ``__vax__`` or +``__ns16000__`` is defined as a macro. + +Conditionals written like this: + +.. code-block:: c++ + + #if defined BUFSIZE && BUFSIZE >= 1024 + +can generally be simplified to just ``#if BUFSIZE >= 1024``, +since if ``BUFSIZE`` is not defined, it will be interpreted as having +the value zero. + +If the ``defined`` operator appears as a result of a macro expansion, +the C standard says the behavior is undefined. GNU cpp treats it as a +genuine ``defined`` operator and evaluates it normally. It will warn +wherever your code uses this feature if you use the command-line option +:option:`-Wpedantic`, since other compilers may handle it differently. The +warning is also enabled by :option:`-Wextra`, and can also be enabled +individually with :option:`-Wexpansion-to-defined`. + +.. index:: #else + +.. _else: + +Else +^^^^ + +The :samp:`#else` directive can be added to a conditional to provide +alternative text to be used if the condition fails. This is what it +looks like: + +.. code-block:: c++ + + #if expression + text-if-true + #else /* Not expression */ + text-if-false + #endif /* Not expression */ + +If :samp:`{expression}` is nonzero, the :samp:`{text-if-true}` is included and +the :samp:`{text-if-false}` is skipped. If :samp:`{expression}` is zero, the +opposite happens. + +You can use :samp:`#else` with :samp:`#ifdef` and :samp:`#ifndef`, too. + +.. index:: #elif + +.. _elif: + +Elif +^^^^ + +One common case of nested conditionals is used to check for more than two +possible alternatives. For example, you might have + +.. code-block:: c++ + + #if X == 1 + ... + #else /* X != 1 */ + #if X == 2 + ... + #else /* X != 2 */ + ... + #endif /* X != 2 */ + #endif /* X != 1 */ + +Another conditional directive, :samp:`#elif`, allows this to be +abbreviated as follows: + +.. code-block:: c++ + + #if X == 1 + ... + #elif X == 2 + ... + #else /* X != 2 and X != 1*/ + ... + #endif /* X != 2 and X != 1*/ + +:samp:`#elif` stands for 'else if'. Like :samp:`#else`, it goes in the +middle of a conditional group and subdivides it; it does not require a +matching :samp:`#endif` of its own. Like :samp:`#if`, the :samp:`#elif` +directive includes an expression to be tested. The text following the +:samp:`#elif` is processed only if the original :samp:`#if`-condition +failed and the :samp:`#elif` condition succeeds. + +More than one :samp:`#elif` can go in the same conditional group. Then +the text after each :samp:`#elif` is processed only if the :samp:`#elif` +condition succeeds after the original :samp:`#if` and all previous +:samp:`#elif` directives within it have failed. + +:samp:`#else` is allowed after any number of :samp:`#elif` directives, but +:samp:`#elif` may not follow :samp:`#else`. + +.. index:: __has_attribute + +__has_attribute +^^^^^^^^^^^^^^^ + +The special operator ``__has_attribute (operand)`` may be used +in :samp:`#if` and :samp:`#elif` expressions to test whether the attribute +referenced by its :samp:`{operand}` is recognized by GCC. Using the operator +in other contexts is not valid. In C code, if compiling for strict +conformance to standards before C2x, :samp:`{operand}` must be +a valid identifier. Otherwise, :samp:`{operand}` may be optionally +introduced by the ``attribute-scope::`` prefix. +The :samp:`{attribute-scope}` prefix identifies the 'namespace' within +which the attribute is recognized. The scope of GCC attributes is +:samp:`gnu` or :samp:`__gnu__`. The ``__has_attribute`` operator by +itself, without any :samp:`{operand}` or parentheses, acts as a predefined +macro so that support for it can be tested in portable code. Thus, +the recommended use of the operator is as follows: + +.. code-block:: c++ + + #if defined __has_attribute + # if __has_attribute (nonnull) + # define ATTR_NONNULL __attribute__ ((nonnull)) + # endif + #endif + +The first :samp:`#if` test succeeds only when the operator is supported +by the version of GCC (or another compiler) being used. Only when that +test succeeds is it valid to use ``__has_attribute`` as a preprocessor +operator. As a result, combining the two tests into a single expression as +shown below would only be valid with a compiler that supports the operator +but not with others that don't. + +.. code-block:: c++ + + #if defined __has_attribute && __has_attribute (nonnull) /* not portable */ + ... + #endif + +.. index:: __has_cpp_attribute + +__has_cpp_attribute +^^^^^^^^^^^^^^^^^^^ + +The special operator ``__has_cpp_attribute (operand)`` may be used +in :samp:`#if` and :samp:`#elif` expressions in C++ code to test whether +the attribute referenced by its :samp:`{operand}` is recognized by GCC. +``__has_cpp_attribute (operand)`` is equivalent to +``__has_attribute (operand)`` except that when :samp:`{operand}` +designates a supported standard attribute it evaluates to an integer +constant of the form ``YYYYMM`` indicating the year and month when +the attribute was first introduced into the C++ standard. For additional +information including the dates of the introduction of current standard +attributes, see `SD-6: SG10 Feature Test Recommendations `_. + +.. index:: __has_c_attribute + +__has_c_attribute +^^^^^^^^^^^^^^^^^ + +The special operator ``__has_c_attribute (operand)`` may be +used in :samp:`#if` and :samp:`#elif` expressions in C code to test +whether the attribute referenced by its :samp:`{operand}` is recognized by +GCC in attributes using the :samp:`[[]]` syntax. GNU attributes must +be specified with the scope :samp:`gnu` or :samp:`__gnu__` with +``__has_c_attribute``. When :samp:`{operand}` designates a supported +standard attribute it evaluates to an integer constant of the form +``YYYYMM`` indicating the year and month when the attribute was +first introduced into the C standard, or when the syntax of operands +to the attribute was extended in the C standard. + +.. index:: __has_builtin + +__has_builtin +^^^^^^^^^^^^^ + +The special operator ``__has_builtin (operand)`` may be used in +constant integer contexts and in preprocessor :samp:`#if` and :samp:`#elif` +expressions to test whether the symbol named by its :samp:`{operand}` is +recognized as a built-in function by GCC in the current language and +conformance mode. It evaluates to a constant integer with a nonzero +value if the argument refers to such a function, and to zero otherwise. +The operator may also be used in preprocessor :samp:`#if` and :samp:`#elif` +expressions. The ``__has_builtin`` operator by itself, without any +:samp:`{operand}` or parentheses, acts as a predefined macro so that support +for it can be tested in portable code. Thus, the recommended use of +the operator is as follows: + +.. code-block:: c++ + + #if defined __has_builtin + # if __has_builtin (__builtin_object_size) + # define builtin_object_size(ptr) __builtin_object_size (ptr, 2) + # endif + #endif + #ifndef builtin_object_size + # define builtin_object_size(ptr) ((size_t)-1) + #endif + +.. index:: __has_include + +__has_include +^^^^^^^^^^^^^ + +The special operator ``__has_include (operand)`` may be used in +:samp:`#if` and :samp:`#elif` expressions to test whether the header referenced +by its :samp:`{operand}` can be included using the :samp:`#include` directive. Using +the operator in other contexts is not valid. The :samp:`{operand}` takes +the same form as the file in the :samp:`#include` directive (see :ref:`include-syntax`) and evaluates to a nonzero value if the header can be included and +to zero otherwise. Note that that the ability to include a header doesn't +imply that the header doesn't contain invalid constructs or :samp:`#error` +directives that would cause the preprocessor to fail. + +The ``__has_include`` operator by itself, without any :samp:`{operand}` or +parentheses, acts as a predefined macro so that support for it can be tested +in portable code. Thus, the recommended use of the operator is as follows: + +.. code-block:: c++ + + #if defined __has_include + # if __has_include () + # include + # endif + #endif + +The first :samp:`#if` test succeeds only when the operator is supported +by the version of GCC (or another compiler) being used. Only when that +test succeeds is it valid to use ``__has_include`` as a preprocessor +operator. As a result, combining the two tests into a single expression +as shown below would only be valid with a compiler that supports the operator +but not with others that don't. + +.. code-block:: c++ + + #if defined __has_include && __has_include ("header.h") /* not portable */ + ... + #endif \ No newline at end of file diff --git a/gcc/doc/cpp/conditional-uses.rst b/gcc/doc/cpp/conditional-uses.rst new file mode 100644 index 00000000000..59555a5828d --- /dev/null +++ b/gcc/doc/cpp/conditional-uses.rst @@ -0,0 +1,32 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _conditional-uses: + +Conditional Uses +**************** + +There are three general reasons to use a conditional. + +* A program may need to use different code depending on the machine or + operating system it is to run on. In some cases the code for one + operating system may be erroneous on another operating system; for + example, it might refer to data types or constants that do not exist on + the other system. When this happens, it is not enough to avoid + executing the invalid code. Its mere presence will cause the compiler + to reject the program. With a preprocessing conditional, the offending + code can be effectively excised from the program when it is not valid. + +* You may want to be able to compile the same source file into two + different programs. One version might make frequent time-consuming + consistency checks on its intermediate data, or print the values of + those data for debugging, and the other not. + +* A conditional whose condition is always false is one way to exclude code + from the program but keep it as a sort of comment for future reference. + +Simple programs that do not need system-specific logic or complex +debugging hooks generally will not need to use preprocessing +conditionals. \ No newline at end of file diff --git a/gcc/doc/cpp/conditionals.rst b/gcc/doc/cpp/conditionals.rst new file mode 100644 index 00000000000..381a6124da4 --- /dev/null +++ b/gcc/doc/cpp/conditionals.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: conditionals + +.. _conditionals: + +Conditionals +------------ + +A :dfn:`conditional` is a directive that instructs the preprocessor to +select whether or not to include a chunk of code in the final token +stream passed to the compiler. Preprocessor conditionals can test +arithmetic expressions, or whether a name is defined as a macro, or both +simultaneously using the special ``defined`` operator. + +A conditional in the C preprocessor resembles in some ways an ``if`` +statement in C, but it is important to understand the difference between +them. The condition in an ``if`` statement is tested during the +execution of your program. Its purpose is to allow your program to +behave differently from run to run, depending on the data it is +operating on. The condition in a preprocessing conditional directive is +tested when your program is compiled. Its purpose is to allow different +code to be included in the program depending on the situation at the +time of compilation. + +However, the distinction is becoming less clear. Modern compilers often +do test ``if`` statements when a program is compiled, if their +conditions are known not to vary at run time, and eliminate code which +can never be executed. If you can count on your compiler to do this, +you may find that your program is more readable if you use ``if`` +statements with constant conditions (perhaps determined by macros). Of +course, you can only use this to exclude code, not type definitions or +other preprocessing directives, and you can only do it if the code +remains syntactically valid when it is not to be used. + +.. toctree:: + :maxdepth: 2 + + conditional-uses + conditional-syntax + deleted-code \ No newline at end of file diff --git a/gcc/doc/cpp/conf.py b/gcc/doc/cpp/conf.py new file mode 100644 index 00000000000..29d3aed4558 --- /dev/null +++ b/gcc/doc/cpp/conf.py @@ -0,0 +1,30 @@ +# Configuration file for the Sphinx documentation builder. + +import sys +sys.path.append('../../..//doc') + +from baseconf import * + +name = 'cpp' +project = 'The C Preprocessor' +copyright = '1987-2022 Free Software Foundation, Inc.' +authors = 'Richard M. Stallman, Zachary Weinberg' + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +latex_documents = [ + ('index', f'{name}.tex', project, authors, 'manual'), +] + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('invocation', name, project, [authors], 1), +] + +texinfo_documents = [ + ('index', name, project, authors, None, None, None, True) +] + +set_common(name, globals()) \ No newline at end of file diff --git a/gcc/doc/cpp/copyright.rst b/gcc/doc/cpp/copyright.rst new file mode 100644 index 00000000000..fa61190ddf7 --- /dev/null +++ b/gcc/doc/cpp/copyright.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Copyright +^^^^^^^^^ + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, the Front-Cover Texts being (a) (see below), and +with the Back-Cover Texts being (b) (see below). +A copy of the license is included in the :ref:`gnu_fdl`. + +(a) The FSF's Front-Cover Text is: + + A GNU Manual + +(b) The FSF's Back-Cover Text is: + + You have freedom to copy and modify this GNU Manual, like GNU + software. Copies published by the Free Software Foundation raise + funds for GNU development. \ No newline at end of file diff --git a/gcc/doc/cpp/deleted-code.rst b/gcc/doc/cpp/deleted-code.rst new file mode 100644 index 00000000000..758e0c1c0a3 --- /dev/null +++ b/gcc/doc/cpp/deleted-code.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: commenting out code + +.. _deleted-code: + +Deleted Code +************ + +If you replace or delete a part of the program but want to keep the old +code around for future reference, you often cannot simply comment it +out. Block comments do not nest, so the first comment inside the old +code will end the commenting-out. The probable result is a flood of +syntax errors. + +One way to avoid this problem is to use an always-false conditional +instead. For instance, put ``#if 0`` before the deleted code and +``#endif`` after it. This works even if the code being turned +off contains conditionals, but they must be entire conditionals +(balanced :samp:`#if` and :samp:`#endif`). + +Some people use ``#ifdef notdef`` instead. This is risky, because +``notdef`` might be accidentally defined as a macro, and then the +conditional would succeed. ``#if 0`` can be counted on to fail. + +Do not use ``#if 0`` for comments which are not C code. Use a real +comment, instead. The interior of ``#if 0`` must consist of complete +tokens; in particular, single-quote characters must balance. Comments +often contain unbalanced single-quote characters (known in English as +apostrophes). These confuse ``#if 0``. They don't confuse +:samp:`/*`. \ No newline at end of file diff --git a/gcc/doc/cpp/diagnostics.rst b/gcc/doc/cpp/diagnostics.rst new file mode 100644 index 00000000000..beaad7d8217 --- /dev/null +++ b/gcc/doc/cpp/diagnostics.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: diagnostic, reporting errors, reporting warnings, #error + +.. _diagnostics: + +Diagnostics +----------- + +The directive :samp:`#error` causes the preprocessor to report a fatal +error. The tokens forming the rest of the line following :samp:`#error` +are used as the error message. + +You would use :samp:`#error` inside of a conditional that detects a +combination of parameters which you know the program does not properly +support. For example, if you know that the program will not run +properly on a VAX, you might write + +.. code-block:: c++ + + #ifdef __vax__ + #error "Won't work on VAXen. See comments at get_last_object." + #endif + +If you have several configuration parameters that must be set up by +the installation in a consistent way, you can use conditionals to detect +an inconsistency and report it with :samp:`#error`. For example, + +.. code-block:: c++ + + #if !defined(FOO) && defined(BAR) + #error "BAR requires FOO." + #endif + +.. index:: #warning + +The directive :samp:`#warning` is like :samp:`#error`, but causes the +preprocessor to issue a warning and continue preprocessing. The tokens +following :samp:`#warning` are used as the warning message. + +You might use :samp:`#warning` in obsolete header files, with a message +directing the user to the header file which should be used instead. + +Neither :samp:`#error` nor :samp:`#warning` macro-expands its argument. +Internal whitespace sequences are each replaced with a single space. +The line must consist of complete tokens. It is wisest to make the +argument of these directives be a single string constant; this avoids +problems with apostrophes and the like. \ No newline at end of file diff --git a/gcc/doc/cpp/environment-variables.rst b/gcc/doc/cpp/environment-variables.rst new file mode 100644 index 00000000000..c0ab7992905 --- /dev/null +++ b/gcc/doc/cpp/environment-variables.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: environment variables + +.. _environment-variables: + +Environment Variables +--------------------- + +This section describes the environment variables that affect how CPP +operates. You can use them to specify directories or prefixes to use +when searching for include files, or to control dependency output. + +Note that you can also specify places to search using options such as +:option:`-I`, and control dependency output with options like +:option:`-M` (see :ref:`invocation`). These take precedence over +environment variables, which in turn take precedence over the +configuration of GCC. + +.. include:: ../../../doc/cppenv.rst \ No newline at end of file diff --git a/gcc/doc/cpp/gnu-free-documentation-license.rst b/gcc/doc/cpp/gnu-free-documentation-license.rst new file mode 100644 index 00000000000..1de809b3636 --- /dev/null +++ b/gcc/doc/cpp/gnu-free-documentation-license.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/gnu_free_documentation_license.rst \ No newline at end of file diff --git a/gcc/doc/cpp/header-files.rst b/gcc/doc/cpp/header-files.rst new file mode 100644 index 00000000000..13b9841c3c6 --- /dev/null +++ b/gcc/doc/cpp/header-files.rst @@ -0,0 +1,56 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: header file + +.. _header-files: + +Header Files +------------ + +A header file is a file containing C declarations and macro definitions +(see :ref:`macros`) to be shared between several source files. You request +the use of a header file in your program by :dfn:`including` it, with the +C preprocessing directive :samp:`#include`. + +Header files serve two purposes. + +.. index:: system header files + +* System header files declare the interfaces to parts of the operating + system. You include them in your program to supply the definitions and + declarations you need to invoke system calls and libraries. + +* Your own header files contain declarations for interfaces between the + source files of your program. Each time you have a group of related + declarations and macro definitions all or most of which are needed in + several different source files, it is a good idea to create a header + file for them. + +Including a header file produces the same results as copying the header +file into each source file that needs it. Such copying would be +time-consuming and error-prone. With a header file, the related +declarations appear in only one place. If they need to be changed, they +can be changed in one place, and programs that include the header file +will automatically use the new version when next recompiled. The header +file eliminates the labor of finding and changing all the copies as well +as the risk that a failure to find one copy will result in +inconsistencies within a program. + +In C, the usual convention is to give header files names that end with +:samp:`.h`. It is most portable to use only letters, digits, dashes, and +underscores in header file names, and at most one dot. + +.. toctree:: + :maxdepth: 2 + + header-files/include-syntax + header-files/include-operation + header-files/search-path + header-files/once-only-headers + header-files/alternatives-to-wrapper-ifndef + header-files/computed-includes + header-files/wrapper-headers + header-files/system-headers \ No newline at end of file diff --git a/gcc/doc/cpp/header-files/alternatives-to-wrapper-ifndef.rst b/gcc/doc/cpp/header-files/alternatives-to-wrapper-ifndef.rst new file mode 100644 index 00000000000..e38cffeaf38 --- /dev/null +++ b/gcc/doc/cpp/header-files/alternatives-to-wrapper-ifndef.rst @@ -0,0 +1,40 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _alternatives-to-wrapper-ifndef: + +Alternatives to Wrapper #ifndef +******************************* + +CPP supports two more ways of indicating that a header file should be +read only once. Neither one is as portable as a wrapper :samp:`#ifndef` +and we recommend you do not use them in new programs, with the caveat +that :samp:`#import` is standard practice in Objective-C. + +.. index:: #import + +CPP supports a variant of :samp:`#include` called :samp:`#import` which +includes a file, but does so at most once. If you use :samp:`#import` +instead of :samp:`#include`, then you don't need the conditionals +inside the header file to prevent multiple inclusion of the contents. +:samp:`#import` is standard in Objective-C, but is considered a +deprecated extension in C and C++. + +:samp:`#import` is not a well designed feature. It requires the users of +a header file to know that it should only be included once. It is much +better for the header file's implementor to write the file so that users +don't need to know this. Using a wrapper :samp:`#ifndef` accomplishes +this goal. + +In the present implementation, a single use of :samp:`#import` will +prevent the file from ever being read again, by either :samp:`#import` or +:samp:`#include`. You should not rely on this; do not use both +:samp:`#import` and :samp:`#include` to refer to the same header file. + +Another way to prevent a header file from being included more than once +is with the :samp:`#pragma once` directive (see :ref:`pragmas`). +:samp:`#pragma once` does not have the problems that :samp:`#import` does, +but it is not recognized by all preprocessors, so you cannot rely on it +in a portable program. \ No newline at end of file diff --git a/gcc/doc/cpp/header-files/computed-includes.rst b/gcc/doc/cpp/header-files/computed-includes.rst new file mode 100644 index 00000000000..49c16228032 --- /dev/null +++ b/gcc/doc/cpp/header-files/computed-includes.rst @@ -0,0 +1,86 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: computed includes, macros in include + +.. _computed-includes: + +Computed Includes +***************** + +Sometimes it is necessary to select one of several different header +files to be included into your program. They might specify +configuration parameters to be used on different sorts of operating +systems, for instance. You could do this with a series of conditionals, + +.. code-block:: c++ + + #if SYSTEM_1 + # include "system_1.h" + #elif SYSTEM_2 + # include "system_2.h" + #elif SYSTEM_3 + ... + #endif + +That rapidly becomes tedious. Instead, the preprocessor offers the +ability to use a macro for the header name. This is called a +:dfn:`computed include`. Instead of writing a header name as the direct +argument of :samp:`#include`, you simply put a macro name there instead: + +.. code-block:: c++ + + #define SYSTEM_H "system_1.h" + ... + #include SYSTEM_H + +``SYSTEM_H`` will be expanded, and the preprocessor will look for +:samp:`system_1.h` as if the :samp:`#include` had been written that way +originally. ``SYSTEM_H`` could be defined by your Makefile with a +:option:`-D` option. + +You must be careful when you define the macro. :samp:`#define` saves +tokens, not text. The preprocessor has no way of knowing that the macro +will be used as the argument of :samp:`#include`, so it generates +ordinary tokens, not a header name. This is unlikely to cause problems +if you use double-quote includes, which are close enough to string +constants. If you use angle brackets, however, you may have trouble. + +The syntax of a computed include is actually a bit more general than the +above. If the first non-whitespace character after :samp:`#include` is +not :samp:`"` or :samp:`<`, then the entire line is macro-expanded +like running text would be. + +If the line expands to a single string constant, the contents of that +string constant are the file to be included. CPP does not re-examine the +string for embedded quotes, but neither does it process backslash +escapes in the string. Therefore + +.. code-block:: c++ + + #define HEADER "a\"b" + #include HEADER + +looks for a file named :samp:`a\\"b`. CPP searches for the file according +to the rules for double-quoted includes. + +If the line expands to a token stream beginning with a :samp:`<` token +and including a :samp:`>` token, then the tokens between the :samp:`<` and +the first :samp:`>` are combined to form the filename to be included. +Any whitespace between tokens is reduced to a single space; then any +space after the initial :samp:`<` is retained, but a trailing space +before the closing :samp:`>` is ignored. CPP searches for the file +according to the rules for angle-bracket includes. + +In either case, if there are any tokens on the line after the file name, +an error occurs and the directive is not processed. It is also an error +if the result of expansion does not match either of the two expected +forms. + +These rules are implementation-defined behavior according to the C +standard. To minimize the risk of different compilers interpreting your +computed includes differently, we recommend you use only a single +object-like macro which expands to a string constant. This will also +minimize confusion for people reading your program. \ No newline at end of file diff --git a/gcc/doc/cpp/header-files/include-operation.rst b/gcc/doc/cpp/header-files/include-operation.rst new file mode 100644 index 00000000000..465905698e7 --- /dev/null +++ b/gcc/doc/cpp/header-files/include-operation.rst @@ -0,0 +1,67 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _include-operation: + +Include Operation +***************** + +The :samp:`#include` directive works by directing the C preprocessor to +scan the specified file as input before continuing with the rest of the +current file. The output from the preprocessor contains the output +already generated, followed by the output resulting from the included +file, followed by the output that comes from the text after the +:samp:`#include` directive. For example, if you have a header file +:samp:`header.h` as follows, + +.. code-block:: c++ + + char *test (void); + +and a main program called :samp:`program.c` that uses the header file, +like this, + +.. code-block:: c++ + + int x; + #include "header.h" + + int + main (void) + { + puts (test ()); + } + +the compiler will see the same token stream as it would if +:samp:`program.c` read + +.. code-block:: c++ + + int x; + char *test (void); + + int + main (void) + { + puts (test ()); + } + +Included files are not limited to declarations and macro definitions; +those are merely the typical uses. Any fragment of a C program can be +included from another file. The include file could even contain the +beginning of a statement that is concluded in the containing file, or +the end of a statement that was started in the including file. However, +an included file must consist of complete tokens. Comments and string +literals which have not been closed by the end of an included file are +invalid. For error recovery, they are considered to end at the end of +the file. + +To avoid confusion, it is best if header files contain only complete +syntactic units---function declarations or definitions, type +declarations, etc. + +The line following the :samp:`#include` directive is always treated as a +separate line by the C preprocessor, even if the included file lacks a +final newline. \ No newline at end of file diff --git a/gcc/doc/cpp/header-files/include-syntax.rst b/gcc/doc/cpp/header-files/include-syntax.rst new file mode 100644 index 00000000000..a378dfc5375 --- /dev/null +++ b/gcc/doc/cpp/header-files/include-syntax.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: #include + +.. _include-syntax: + +Include Syntax +************** + +Both user and system header files are included using the preprocessing +directive :samp:`#include`. It has two variants: + +:samp:`#include <{file}>` + This variant is used for system header files. It searches for a file + named :samp:`{file}` in a standard list of system directories. You can prepend + directories to this list with the :option:`-I` option (see :ref:`invocation`). + +:samp:`#include "{file}"` + This variant is used for header files of your own program. It + searches for a file named :samp:`{file}` first in the directory containing + the current file, then in the quote directories and then the same + directories used for ````. You can prepend directories + to the list of quote directories with the :option:`-iquote` option. + +The argument of :samp:`#include`, whether delimited with quote marks or +angle brackets, behaves like a string constant in that comments are not +recognized, and macro names are not expanded. Thus, ``#include +`` specifies inclusion of a system header file named :samp:`x/*y`. + +However, if backslashes occur within :samp:`{file}`, they are considered +ordinary text characters, not escape characters. None of the character +escape sequences appropriate to string constants in C are processed. +Thus, ``#include "x\n\\y"`` specifies a filename containing three +backslashes. (Some systems interpret :samp:`\\` as a pathname separator. +All of these also interpret :samp:`/` the same way. It is most portable +to use only :samp:`/`.) + +It is an error if there is anything (other than comments) on the line +after the file name. \ No newline at end of file diff --git a/gcc/doc/cpp/header-files/once-only-headers.rst b/gcc/doc/cpp/header-files/once-only-headers.rst new file mode 100644 index 00000000000..2ee77771620 --- /dev/null +++ b/gcc/doc/cpp/header-files/once-only-headers.rst @@ -0,0 +1,52 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: repeated inclusion, including just once, wrapper #ifndef + +.. _once-only-headers: + +Once-Only Headers +***************** + +If a header file happens to be included twice, the compiler will process +its contents twice. This is very likely to cause an error, e.g. when the +compiler sees the same structure definition twice. Even if it does not, +it will certainly waste time. + +The standard way to prevent this is to enclose the entire real contents +of the file in a conditional, like this: + +.. code-block:: c++ + + /* File foo. */ + #ifndef FILE_FOO_SEEN + #define FILE_FOO_SEEN + + the entire file + + #endif /* !FILE_FOO_SEEN */ + +This construct is commonly known as a :dfn:`wrapper #ifndef`. +When the header is included again, the conditional will be false, +because ``FILE_FOO_SEEN`` is defined. The preprocessor will skip +over the entire contents of the file, and the compiler will not see it +twice. + +CPP optimizes even further. It remembers when a header file has a +wrapper :samp:`#ifndef`. If a subsequent :samp:`#include` specifies that +header, and the macro in the :samp:`#ifndef` is still defined, it does +not bother to rescan the file at all. + +You can put comments outside the wrapper. They will not interfere with +this optimization. + +.. index:: controlling macro, guard macro + +The macro ``FILE_FOO_SEEN`` is called the :dfn:`controlling macro` or +:dfn:`guard macro`. In a user header file, the macro name should not +begin with :samp:`_`. In a system header file, it should begin with +:samp:`__` to avoid conflicts with user programs. In any kind of header +file, the macro name should contain the name of the file and some +additional text, to avoid conflicts with other header files. \ No newline at end of file diff --git a/gcc/doc/cpp/header-files/search-path.rst b/gcc/doc/cpp/header-files/search-path.rst new file mode 100644 index 00000000000..9f87878517f --- /dev/null +++ b/gcc/doc/cpp/header-files/search-path.rst @@ -0,0 +1,53 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _search-path: + +Search Path +*********** + +By default, the preprocessor looks for header files included by the quote +form of the directive ``#include "file"`` first relative to +the directory of the current file, and then in a preconfigured list +of standard system directories. +For example, if :samp:`/usr/include/sys/stat.h` contains +``#include "types.h"``, GCC looks for :samp:`types.h` first in +:samp:`/usr/include/sys`, then in its usual search path. + +For the angle-bracket form ``#include ``, the +preprocessor's default behavior is to look only in the standard system +directories. The exact search directory list depends on the target +system, how GCC is configured, and where it is installed. You can +find the default search directory list for your version of CPP by +invoking it with the :option:`-v` option. For example, + +.. code-block:: c++ + + cpp -v /dev/null -o /dev/null + +There are a number of command-line options you can use to add +additional directories to the search path. +The most commonly-used option is :option:`-Idir`, which causes +:samp:`{dir}` to be searched after the current directory (for the quote +form of the directive) and ahead of the standard system directories. +You can specify multiple :option:`-I` options on the command line, +in which case the directories are searched in left-to-right order. + +If you need separate control over the search paths for the quote and +angle-bracket forms of the :samp:`#include` directive, you can use the +:option:`-iquote` and/or :option:`-isystem` options instead of :option:`-I`. +See :ref:`invocation`, for a detailed description of these options, as +well as others that are less generally useful. + +If you specify other options on the command line, such as :option:`-I`, +that affect where the preprocessor searches for header files, the +directory list printed by the :option:`-v` option reflects the actual +search path used by the preprocessor. + +Note that you can also prevent the preprocessor from searching any of +the default system header directories with the :option:`-nostdinc` +option. This is useful when you are compiling an operating system +kernel or some other program that does not use the standard C library +facilities, or the standard C library itself. \ No newline at end of file diff --git a/gcc/doc/cpp/header-files/system-headers.rst b/gcc/doc/cpp/header-files/system-headers.rst new file mode 100644 index 00000000000..ef6474f9dea --- /dev/null +++ b/gcc/doc/cpp/header-files/system-headers.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: system header files + +.. _system-headers: + +System Headers +************** + +The header files declaring interfaces to the operating system and +runtime libraries often cannot be written in strictly conforming C. +Therefore, GCC gives code found in :dfn:`system headers` special +treatment. All warnings, other than those generated by :samp:`#warning` +(see :ref:`diagnostics`), are suppressed while GCC is processing a system +header. Macros defined in a system header are immune to a few warnings +wherever they are expanded. This immunity is granted on an ad-hoc +basis, when we find that a warning generates lots of false positives +because of code in macros defined in system headers. + +Normally, only the headers found in specific directories are considered +system headers. These directories are determined when GCC is compiled. +There are, however, two ways to make normal headers into system headers: + +* Header files found in directories added to the search path with the + :option:`-isystem` and :option:`-idirafter` command-line options are + treated as system headers for the purposes of diagnostics. + +* + .. index:: #pragma GCC system_header + + There is also a directive, ``#pragma GCC system_header``, which + tells GCC to consider the rest of the current include file a system + header, no matter where it was found. Code that comes before the + :samp:`#pragma` in the file is not affected. ``#pragma GCC + system_header`` has no effect in the primary source file. + +On some targets, such as RS/6000 AIX, GCC implicitly surrounds all +system headers with an :samp:`extern "C"` block when compiling as C++. \ No newline at end of file diff --git a/gcc/doc/cpp/header-files/wrapper-headers.rst b/gcc/doc/cpp/header-files/wrapper-headers.rst new file mode 100644 index 00000000000..848170e138e --- /dev/null +++ b/gcc/doc/cpp/header-files/wrapper-headers.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: wrapper headers, overriding a header file, #include_next + +.. _wrapper-headers: + +Wrapper Headers +*************** + +Sometimes it is necessary to adjust the contents of a system-provided +header file without editing it directly. GCC's :command:`fixincludes` +operation does this, for example. One way to do that would be to create +a new header file with the same name and insert it in the search path +before the original header. That works fine as long as you're willing +to replace the old header entirely. But what if you want to refer to +the old header from the new one? + +You cannot simply include the old header with :samp:`#include`. That +will start from the beginning, and find your new header again. If your +header is not protected from multiple inclusion (see :ref:`once-only-headers`), it will recurse infinitely and cause a fatal error. + +You could include the old header with an absolute pathname: + +.. code-block:: c++ + + #include "/usr/include/old-header.h" + +This works, but is not clean; should the system headers ever move, you +would have to edit the new headers to match. + +There is no way to solve this problem within the C standard, but you can +use the GNU extension :samp:`#include_next`. It means, 'Include the +*next* file with this name'. This directive works like +:samp:`#include` except in searching for the specified file: it starts +searching the list of header file directories *after* the directory +in which the current file was found. + +Suppose you specify :option:`-I /usr/local/include`, and the list of +directories to search also includes :samp:`/usr/include`; and suppose +both directories contain :samp:`signal.h`. Ordinary ``#include +`` finds the file under :samp:`/usr/local/include`. If that +file contains ``#include_next ``, it starts searching +after that directory, and finds the file in :samp:`/usr/include`. + +:samp:`#include_next` does not distinguish between ```` +and ``"file"`` inclusion, nor does it check that the file you +specify has the same name as the current file. It simply looks for the +file named, starting with the directory in the search path after the one +where the current file was found. + +The use of :samp:`#include_next` can lead to great confusion. We +recommend it be used only when there is no other alternative. In +particular, it should not be used in the headers belonging to a specific +program; it should be used only to make global corrections along the +lines of :command:`fixincludes`. \ No newline at end of file diff --git a/gcc/doc/cpp/implementation-defined-behavior.rst b/gcc/doc/cpp/implementation-defined-behavior.rst new file mode 100644 index 00000000000..8946520eefe --- /dev/null +++ b/gcc/doc/cpp/implementation-defined-behavior.rst @@ -0,0 +1,97 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementation-defined-behavior: + +.. _identifier-characters: + +Implementation-defined behavior +******************************* + +This is how CPP behaves in all the cases which the C standard +describes as :dfn:`implementation-defined`. This term means that the +implementation is free to do what it likes, but must document its choice +and stick to it. + +.. todo:: Check the C++ standard for more implementation-defined stuff. + +* The mapping of physical source file multi-byte characters to the + execution character set. + + The input character set can be specified using the + :option:`-finput-charset` option, while the execution character set may + be controlled using the :option:`-fexec-charset` and + :option:`-fwide-exec-charset` options. + +* Identifier characters. + + The C and C++ standards allow identifiers to be composed of :samp:`_` + and the alphanumeric characters. C++ also allows universal character + names. C99 and later C standards permit both universal character + names and implementation-defined characters. In both C and C++ modes, + GCC accepts in identifiers exactly those extended characters that + correspond to universal character names permitted by the chosen + standard. + + GCC allows the :samp:`$` character in identifiers as an extension for + most targets. This is true regardless of the std= switch, + since this extension cannot conflict with standards-conforming + programs. When preprocessing assembler, however, dollars are not + identifier characters by default. + + Currently the targets that by default do not permit :samp:`$` are AVR, + IP2K, MMIX, MIPS Irix 3, ARM aout, and PowerPC targets for the AIX + operating system. + + You can override the default with :option:`-fdollars-in-identifiers` or + :option:`-fno-dollars-in-identifiers`. See :option:`-fdollars-in-identifiers`. + +* Non-empty sequences of whitespace characters. + + In textual output, each whitespace sequence is collapsed to a single + space. For aesthetic reasons, the first token on each non-directive + line of output is preceded with sufficient spaces that it appears in the + same column as it did in the original source file. + +* The numeric value of character constants in preprocessor expressions. + + The preprocessor and compiler interpret character constants in the + same way; i.e. escape sequences such as :samp:`\\a` are given the + values they would have on the target machine. + + The compiler evaluates a multi-character character constant a character + at a time, shifting the previous value left by the number of bits per + target character, and then or-ing in the bit-pattern of the new + character truncated to the width of a target character. The final + bit-pattern is given type ``int``, and is therefore signed, + regardless of whether single characters are signed or not. + If there are more + characters in the constant than would fit in the target ``int`` the + compiler issues a warning, and the excess leading characters are + ignored. + + For example, ``'ab'`` for a target with an 8-bit ``char`` would be + interpreted as :samp:`(int) ((unsigned char) 'a' * 256 + (unsigned char) + 'b')`, and ``'\234a'`` as :samp:`(int) ((unsigned char) '\\234' * + 256 + (unsigned char) 'a')`. + +* Source file inclusion. + + For a discussion on how the preprocessor locates header files, + :ref:`include-operation`. + +* Interpretation of the filename resulting from a macro-expanded + :samp:`#include` directive. + + See :ref:`computed-includes`. + +* Treatment of a :samp:`#pragma` directive that after macro-expansion + results in a standard pragma. + + No macro expansion occurs on any :samp:`#pragma` directive line, so the + question does not arise. + + Note that GCC does not yet implement any of the standard + pragmas. \ No newline at end of file diff --git a/gcc/doc/cpp/implementation-details.rst b/gcc/doc/cpp/implementation-details.rst new file mode 100644 index 00000000000..326277b1fc9 --- /dev/null +++ b/gcc/doc/cpp/implementation-details.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementation-details: + +Implementation Details +---------------------- + +Here we document details of how the preprocessor's implementation +affects its user-visible behavior. You should try to avoid undue +reliance on behavior described here, as it is possible that it will +change subtly in future implementations. + +Also documented here are obsolete features still supported by CPP. + +.. toctree:: + :maxdepth: 2 + + implementation-defined-behavior + implementation-limits + obsolete-features \ No newline at end of file diff --git a/gcc/doc/cpp/implementation-limits.rst b/gcc/doc/cpp/implementation-limits.rst new file mode 100644 index 00000000000..18cfc6ab0a6 --- /dev/null +++ b/gcc/doc/cpp/implementation-limits.rst @@ -0,0 +1,68 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: implementation limits + +.. _implementation-limits: + +Implementation limits +********************* + +CPP has a small number of internal limits. This section lists the +limits which the C standard requires to be no lower than some minimum, +and all the others known. It is intended that there should be as few limits +as possible. If you encounter an undocumented or inconvenient limit, +please report that as a bug. See :ref:`gcc:bugs`. + +Where we say something is limited :dfn:`only by available memory`, that +means that internal data structures impose no intrinsic limit, and space +is allocated with ``malloc`` or equivalent. The actual limit will +therefore depend on many things, such as the size of other things +allocated by the compiler at the same time, the amount of memory +consumed by other processes on the same computer, etc. + +* Nesting levels of :samp:`#include` files. + + We impose an arbitrary limit of 200 levels, to avoid runaway recursion. + The standard requires at least 15 levels. + +* Nesting levels of conditional inclusion. + + The C standard mandates this be at least 63. CPP is limited only by + available memory. + +* Levels of parenthesized expressions within a full expression. + + The C standard requires this to be at least 63. In preprocessor + conditional expressions, it is limited only by available memory. + +* Significant initial characters in an identifier or macro name. + + The preprocessor treats all characters as significant. The C standard + requires only that the first 63 be significant. + +* Number of macros simultaneously defined in a single translation unit. + + The standard requires at least 4095 be possible. CPP is limited only + by available memory. + +* Number of parameters in a macro definition and arguments in a macro call. + + We allow ``USHRT_MAX``, which is no smaller than 65,535. The minimum + required by the standard is 127. + +* Number of characters on a logical source line. + + The C standard requires a minimum of 4096 be permitted. CPP places + no limits on this, but you may get incorrect column numbers reported in + diagnostics for lines longer than 65,535 characters. + +* Maximum size of a source file. + + The standard does not specify any lower limit on the maximum size of a + source file. GNU cpp maps files into memory, so it is limited by the + available address space. This is generally at least two gigabytes. + Depending on the operating system, the size of physical memory may or + may not be a limitation. \ No newline at end of file diff --git a/gcc/doc/cpp/index.rst b/gcc/doc/cpp/index.rst new file mode 100644 index 00000000000..e19dfba42a6 --- /dev/null +++ b/gcc/doc/cpp/index.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +The C Preprocessor +================== + +The C preprocessor implements the macro language used to transform C, +C++, and Objective-C programs before they are compiled. It can also be +useful on its own. + +.. only:: html + + Contents: + +.. toctree:: + + copyright + overview + header-files + macros + conditionals + diagnostics + line-control + pragmas + other-directives + preprocessor-output + traditional-mode + implementation-details + invocation + environment-variables + gnu-free-documentation-license + + indices-and-tables \ No newline at end of file diff --git a/gcc/doc/cpp/indices-and-tables.rst b/gcc/doc/cpp/indices-and-tables.rst new file mode 100644 index 00000000000..6c215a391d9 --- /dev/null +++ b/gcc/doc/cpp/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/gcc/doc/cpp/initial-processing.rst b/gcc/doc/cpp/initial-processing.rst new file mode 100644 index 00000000000..9ca96f21428 --- /dev/null +++ b/gcc/doc/cpp/initial-processing.rst @@ -0,0 +1,164 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _initial-processing: + +Initial processing +****************** + +The preprocessor performs a series of textual transformations on its +input. These happen before all other processing. Conceptually, they +happen in a rigid order, and the entire file is run through each +transformation before the next one begins. CPP actually does them +all at once, for performance reasons. These transformations correspond +roughly to the first three 'phases of translation' described in the C +standard. + +.. index:: line endings + +* The input file is read into memory and broken into lines. + + Different systems use different conventions to indicate the end of a + line. GCC accepts the ASCII control sequences LF, CR + LF and CR as end-of-line markers. These are the canonical + sequences used by Unix, DOS and VMS, and the classic Mac OS (before + OSX) respectively. You may therefore safely copy source code written + on any of those systems to a different one and use it without + conversion. (GCC may lose track of the current line number if a file + doesn't consistently use one convention, as sometimes happens when it + is edited on computers with different conventions that share a network + file system.) + + If the last line of any input file lacks an end-of-line marker, the end + of the file is considered to implicitly supply one. The C standard says + that this condition provokes undefined behavior, so GCC will emit a + warning message. + +.. index:: trigraphs + +.. _trigraphs: + +* If trigraphs are enabled, they are replaced by their + corresponding single characters. By default GCC ignores trigraphs, + but if you request a strictly conforming mode with the :option:`-std` + option, or you specify the :option:`-trigraphs` option, then it + converts them. + + These are nine three-character sequences, all starting with :samp:`??`, + that are defined by ISO C to stand for single characters. They permit + obsolete systems that lack some of C's punctuation to use C. For + example, :samp:`??/` stands for :samp:`\\`, so ``'??/n'`` is a character + constant for a newline. + + Trigraphs are not popular and many compilers implement them + incorrectly. Portable code should not rely on trigraphs being either + converted or ignored. With :option:`-Wtrigraphs` GCC will warn you + when a trigraph may change the meaning of your program if it were + converted. See :ref:`wtrigraphs`. + + In a string constant, you can prevent a sequence of question marks + from being confused with a trigraph by inserting a backslash between + the question marks, or by separating the string literal at the + trigraph and making use of string literal concatenation. ``"(??\?)"`` + is the string :samp:`(???)`, not :samp:`(?]`. Traditional C compilers + do not recognize these idioms. + + The nine trigraphs and their replacements are + + .. code-block:: + + Trigraph: ??( ??) ??< ??> ??= ??/ ??' ??! ??- + Replacement: [ ] { } # \ ^ | ~ + +.. index:: continued lines, backslash-newline + +* Continued lines are merged into one long line. + + A continued line is a line which ends with a backslash, :samp:`\\`. The + backslash is removed and the following line is joined with the current + one. No space is inserted, so you may split a line anywhere, even in + the middle of a word. (It is generally more readable to split lines + only at white space.) + + The trailing backslash on a continued line is commonly referred to as a + :dfn:`backslash-newline`. + + If there is white space between a backslash and the end of a line, that + is still a continued line. However, as this is usually the result of an + editing mistake, and many compilers will not accept it as a continued + line, GCC will warn you about it. + +.. index:: comments, line comments, block comments + +* All comments are replaced with single spaces. + + There are two kinds of comments. :dfn:`Block comments` begin with + :samp:`/*` and continue until the next :samp:`*/`. Block comments do not + nest: + + .. code-block:: c++ + + /* this is /* one comment */ text outside comment + + :dfn:`Line comments` begin with :samp:`//` and continue to the end of the + current line. Line comments do not nest either, but it does not matter, + because they would end in the same place anyway. + + .. code-block:: c++ + + // this is // one comment + text outside comment + +It is safe to put line comments inside block comments, or vice versa. + +.. code-block:: c++ + + /* block comment + // contains line comment + yet more comment + */ outside comment + + // line comment /* contains block comment */ + +But beware of commenting out one end of a block comment with a line +comment. + +.. code-block:: + + // l.c. /* block comment begins + oops! this isn't a comment anymore */ + +Comments are not recognized within string literals. +``"/* blah */"`` is the string constant :samp:`/\* blah \*/`, not +an empty string. + +Line comments are not in the 1989 edition of the C standard, but they +are recognized by GCC as an extension. In C++ and in the 1999 edition +of the C standard, they are an official part of the language. + +Since these transformations happen before all other processing, you can +split a line mechanically with backslash-newline anywhere. You can +comment out the end of a line. You can continue a line comment onto the +next line with backslash-newline. You can even split :samp:`/*`, +:samp:`*/`, and :samp:`//` onto multiple lines with backslash-newline. +For example: + +.. code-block:: + + /\ + * + */ # /* + */ defi\ + ne FO\ + O 10\ + 20 + +is equivalent to ``#define FOO 1020``. All these tricks are +extremely confusing and should not be used in code intended to be +readable. + +There is no way to prevent a backslash at the end of a line from being +interpreted as a backslash-newline. This cannot affect any correct +program, however. \ No newline at end of file diff --git a/gcc/doc/cpp/invocation.rst b/gcc/doc/cpp/invocation.rst new file mode 100644 index 00000000000..7b13980af5a --- /dev/null +++ b/gcc/doc/cpp/invocation.rst @@ -0,0 +1,81 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: invocation, command line + +.. _invocation: + +Invocation +---------- + +Most often when you use the C preprocessor you do not have to invoke it +explicitly: the C compiler does so automatically. However, the +preprocessor is sometimes useful on its own. You can invoke the +preprocessor either with the :command:`cpp` command, or via :command:`gcc -E`. +In GCC, the preprocessor is actually integrated with the compiler +rather than a separate program, and both of these commands invoke +GCC and tell it to stop after the preprocessing phase. + +The :command:`cpp` options listed here are also accepted by +:command:`gcc` and have the same meaning. Likewise the :command:`cpp` +command accepts all the usual :command:`gcc` driver options, although those +pertaining to compilation phases after preprocessing are ignored. + +Only options specific to preprocessing behavior are documented here. +Refer to the GCC manual for full documentation of other driver options. + +.. only:: man + + Synopsis + ^^^^^^^^ + + cpp [ :option:`-D`:samp:`{macro}` [= :samp:`{defn}` ]...] [ :option:`-U`:samp:`{macro}` ] + [ :option:`-I`:samp:`{dir}`...] [ :option:`-iquote`:samp:`{dir}`...] + [ :option:`-M` | :option:`-MM` ] [ :option:`-MG` ] [ :option:`-MF` :samp:`{filename}` ] + [ :option:`-MP` ] [ :option:`-MQ` :samp:`{target}`...] + [ :option:`-MT` :samp:`{target}`...] + :samp:`{infile}` [[ :option:`-o` ] :samp:`{outfile}` ] + + Only the most useful options are given above; see below for a more + complete list of preprocessor-specific options. + In addition, :command:`cpp` accepts most :command:`gcc` driver options, which + are not listed here. Refer to the GCC documentation for details. + +Options +^^^^^^^ + +The :command:`cpp` command expects two file names as arguments, :samp:`{infile}` and +:samp:`{outfile}`. The preprocessor reads :samp:`{infile}` together with any +other files it specifies with :samp:`#include`. All the output generated +by the combined input files is written in :samp:`{outfile}`. + +Either :samp:`{infile}` or :samp:`{outfile}` may be :option:`-`, which as +:samp:`{infile}` means to read from standard input and as :samp:`{outfile}` +means to write to standard output. If either file is omitted, it +means the same as if :option:`-` had been specified for that file. +You can also use the :option:`-o outfile` option to specify the +output file. + +Unless otherwise noted, or the option ends in :samp:`=`, all options +which take an argument may have that argument appear either immediately +after the option, or with a space between option and argument: +:option:`-Ifoo` and :option:`-I foo` have the same effect. + +.. index:: grouping options, options, grouping + +Many options have multi-letter names; therefore multiple single-letter +options may *not* be grouped: :option:`-dM` is very different from +:samp:`-d -M`. + +.. index:: options + +.. include:: ../../../doc/cppopts.rst + + +.. include:: ../../../doc/cppdiropts.rst + +.. only:: man + + .. include:: copyright.rst \ No newline at end of file diff --git a/gcc/doc/cpp/line-control.rst b/gcc/doc/cpp/line-control.rst new file mode 100644 index 00000000000..933d8a9cf1c --- /dev/null +++ b/gcc/doc/cpp/line-control.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: line control + +.. _line-control: + +Line Control +------------ + +The C preprocessor informs the C compiler of the location in your source +code where each token came from. Presently, this is just the file name +and line number. All the tokens resulting from macro expansion are +reported as having appeared on the line of the source file where the +outermost macro was used. We intend to be more accurate in the future. + +If you write a program which generates source code, such as the +:command:`bison` parser generator, you may want to adjust the preprocessor's +notion of the current file name and line number by hand. Parts of the +output from :command:`bison` are generated from scratch, other parts come +from a standard parser file. The rest are copied verbatim from +:command:`bison`'s input. You would like compiler error messages and +symbolic debuggers to be able to refer to ``bison`` 's input file. + +.. index:: #line + +:command:`bison` or any such program can arrange this by writing +:samp:`#line` directives into the output file. :samp:`#line` is a +directive that specifies the original line number and source file name +for subsequent input in the current preprocessor input file. +:samp:`#line` has three variants: + +:samp:`#line {linenum}` + :samp:`{linenum}` is a non-negative decimal integer constant. It specifies + the line number which should be reported for the following line of + input. Subsequent lines are counted from :samp:`{linenum}`. + +:samp:`#line {linenum}{filename}` + :samp:`{linenum}` is the same as for the first form, and has the same + effect. In addition, :samp:`{filename}` is a string constant. The + following line and all subsequent lines are reported to come from the + file it specifies, until something else happens to change that. + :samp:`{filename}` is interpreted according to the normal rules for a string + constant: backslash escapes are interpreted. This is different from + :samp:`#include`. + +:samp:`#line {anything else}` + :samp:`{anything else}` is checked for macro calls, which are expanded. + The result should match one of the above two forms. + +:samp:`#line` directives alter the results of the ``__FILE__`` and +``__LINE__`` predefined macros from that point on. See :ref:`standard-predefined-macros`. They do not have any effect on :samp:`#include`'s +idea of the directory containing the current file. \ No newline at end of file diff --git a/gcc/doc/cpp/macros.rst b/gcc/doc/cpp/macros.rst new file mode 100644 index 00000000000..7355e0719ef --- /dev/null +++ b/gcc/doc/cpp/macros.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _macros: + +Macros +------ + +A :dfn:`macro` is a fragment of code which has been given a name. +Whenever the name is used, it is replaced by the contents of the macro. +There are two kinds of macros. They differ mostly in what they look +like when they are used. :dfn:`Object-like` macros resemble data objects +when used, :dfn:`function-like` macros resemble function calls. + +You may define any valid identifier as a macro, even if it is a C +keyword. The preprocessor does not know anything about keywords. This +can be useful if you wish to hide a keyword such as ``const`` from an +older compiler that does not understand it. However, the preprocessor +operator ``defined`` (see :ref:`defined`) can never be defined as a +macro, and C++'s named operators (see :ref:`c++-named-operators`) cannot be +macros when you are compiling C++. + +.. toctree:: + :maxdepth: 2 + + macros/object-like-macros + macros/function-like-macros + macros/macro-arguments + macros/stringizing + macros/concatenation + macros/variadic-macros + macros/predefined-macros + macros/undefining-and-redefining-macros + macros/directives-within-macro-arguments + macros/macro-pitfalls \ No newline at end of file diff --git a/gcc/doc/cpp/macros/concatenation.rst b/gcc/doc/cpp/macros/concatenation.rst new file mode 100644 index 00000000000..2f5066ab65e --- /dev/null +++ b/gcc/doc/cpp/macros/concatenation.rst @@ -0,0 +1,85 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: concatenation, token pasting, token concatenation, ## operator + +.. _concatenation: + +Concatenation +************* + +It is often useful to merge two tokens into one while expanding macros. +This is called :dfn:`token pasting` or :dfn:`token concatenation`. The +:samp:`##` preprocessing operator performs token pasting. When a macro +is expanded, the two tokens on either side of each :samp:`##` operator +are combined into a single token, which then replaces the :samp:`##` and +the two original tokens in the macro expansion. Usually both will be +identifiers, or one will be an identifier and the other a preprocessing +number. When pasted, they make a longer identifier. This isn't the +only valid case. It is also possible to concatenate two numbers (or a +number and a name, such as ``1.5`` and ``e3``) into a number. +Also, multi-character operators such as ``+=`` can be formed by +token pasting. + +However, two tokens that don't together form a valid token cannot be +pasted together. For example, you cannot concatenate ``x`` with +``+`` in either order. If you try, the preprocessor issues a warning +and emits the two tokens. Whether it puts white space between the +tokens is undefined. It is common to find unnecessary uses of :samp:`##` +in complex macros. If you get this warning, it is likely that you can +simply remove the :samp:`##`. + +Both the tokens combined by :samp:`##` could come from the macro body, +but you could just as well write them as one token in the first place. +Token pasting is most useful when one or both of the tokens comes from a +macro argument. If either of the tokens next to an :samp:`##` is a +parameter name, it is replaced by its actual argument before :samp:`##` +executes. As with stringizing, the actual argument is not +macro-expanded first. If the argument is empty, that :samp:`##` has no +effect. + +Keep in mind that the C preprocessor converts comments to whitespace +before macros are even considered. Therefore, you cannot create a +comment by concatenating :samp:`/` and :samp:`*`. You can put as much +whitespace between :samp:`##` and its operands as you like, including +comments, and you can put comments in arguments that will be +concatenated. However, it is an error if :samp:`##` appears at either +end of a macro body. + +Consider a C program that interprets named commands. There probably +needs to be a table of commands, perhaps an array of structures declared +as follows: + +.. code-block:: c++ + + struct command + { + char *name; + void (*function) (void); + }; + + struct command commands[] = + { + { "quit", quit_command }, + { "help", help_command }, + ... + }; + +It would be cleaner not to have to give each command name twice, once in +the string constant and once in the function name. A macro which takes the +name of a command as an argument can make this unnecessary. The string +constant can be created with stringizing, and the function name by +concatenating the argument with :samp:`_command`. Here is how it is done: + +.. code-block:: c++ + + #define COMMAND(NAME) { #NAME, NAME ## _command } + + struct command commands[] = + { + COMMAND (quit), + COMMAND (help), + ... + }; \ No newline at end of file diff --git a/gcc/doc/cpp/macros/directives-within-macro-arguments.rst b/gcc/doc/cpp/macros/directives-within-macro-arguments.rst new file mode 100644 index 00000000000..2e7e82563e9 --- /dev/null +++ b/gcc/doc/cpp/macros/directives-within-macro-arguments.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: macro arguments and directives + +.. _directives-within-macro-arguments: + +Directives Within Macro Arguments +********************************* + +Occasionally it is convenient to use preprocessor directives within +the arguments of a macro. The C and C++ standards declare that +behavior in these cases is undefined. GNU CPP +processes arbitrary directives within macro arguments in +exactly the same way as it would have processed the directive were the +function-like macro invocation not present. + +If, within a macro invocation, that macro is redefined, then the new +definition takes effect in time for argument pre-expansion, but the +original definition is still used for argument replacement. Here is a +pathological example: + +.. code-block:: c++ + + #define f(x) x x + f (1 + #undef f + #define f 2 + f) + +which expands to + +.. code-block:: c++ + + 1 2 1 2 + +with the semantics described above. \ No newline at end of file diff --git a/gcc/doc/cpp/macros/function-like-macros.rst b/gcc/doc/cpp/macros/function-like-macros.rst new file mode 100644 index 00000000000..16ba2cf1a1a --- /dev/null +++ b/gcc/doc/cpp/macros/function-like-macros.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: function-like macros + +.. _function-like-macros: + +Function-like Macros +******************** + +You can also define macros whose use looks like a function call. These +are called :dfn:`function-like macros`. To define a function-like macro, +you use the same :samp:`#define` directive, but you put a pair of +parentheses immediately after the macro name. For example, + +.. code-block:: + + #define lang_init() c_init() + lang_init() + → c_init() + +A function-like macro is only expanded if its name appears with a pair +of parentheses after it. If you write just the name, it is left alone. +This can be useful when you have a function and a macro of the same +name, and you wish to use the function sometimes. + +.. code-block:: + + extern void foo(void); + #define foo() /* optimized inline version */ + ... + foo(); + funcptr = foo; + +Here the call to ``foo()`` will use the macro, but the function +pointer will get the address of the real function. If the macro were to +be expanded, it would cause a syntax error. + +If you put spaces between the macro name and the parentheses in the +macro definition, that does not define a function-like macro, it defines +an object-like macro whose expansion happens to begin with a pair of +parentheses. + +.. code-block:: + + #define lang_init () c_init() + lang_init() + → () c_init()() + +The first two pairs of parentheses in this expansion come from the +macro. The third is the pair that was originally after the macro +invocation. Since ``lang_init`` is an object-like macro, it does not +consume those parentheses. \ No newline at end of file diff --git a/gcc/doc/cpp/macros/macro-arguments.rst b/gcc/doc/cpp/macros/macro-arguments.rst new file mode 100644 index 00000000000..06911523e7f --- /dev/null +++ b/gcc/doc/cpp/macros/macro-arguments.rst @@ -0,0 +1,112 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: arguments, macros with arguments, arguments in macro definitions + +.. _macro-arguments: + +Macro Arguments +*************** + +Function-like macros can take :dfn:`arguments`, just like true functions. +To define a macro that uses arguments, you insert :dfn:`parameters` +between the pair of parentheses in the macro definition that make the +macro function-like. The parameters must be valid C identifiers, +separated by commas and optionally whitespace. + +To invoke a macro that takes arguments, you write the name of the macro +followed by a list of :dfn:`actual arguments` in parentheses, separated +by commas. The invocation of the macro need not be restricted to a +single logical line---it can cross as many lines in the source file as +you wish. The number of arguments you give must match the number of +parameters in the macro definition. When the macro is expanded, each +use of a parameter in its body is replaced by the tokens of the +corresponding argument. (You need not use all of the parameters in the +macro body.) + +As an example, here is a macro that computes the minimum of two numeric +values, as it is defined in many C programs, and some uses. + +.. code-block:: + + #define min(X, Y) ((X) < (Y) ? (X) : (Y)) + x = min(a, b); → x = ((a) < (b) ? (a) : (b)); + y = min(1, 2); → y = ((1) < (2) ? (1) : (2)); + z = min(a + 28, *p); → z = ((a + 28) < (*p) ? (a + 28) : (*p)); + +(In this small example you can already see several of the dangers of +macro arguments. See :ref:`macro-pitfalls`, for detailed explanations.) + +Leading and trailing whitespace in each argument is dropped, and all +whitespace between the tokens of an argument is reduced to a single +space. Parentheses within each argument must balance; a comma within +such parentheses does not end the argument. However, there is no +requirement for square brackets or braces to balance, and they do not +prevent a comma from separating arguments. Thus, + +.. code-block:: c++ + + macro (array[x = y, x + 1]) + +passes two arguments to ``macro`` : ``array[x = y`` and ``x + +1]``. If you want to supply ``array[x = y, x + 1]`` as an argument, +you can write it as ``array[(x = y, x + 1)]``, which is equivalent C +code. + +All arguments to a macro are completely macro-expanded before they are +substituted into the macro body. After substitution, the complete text +is scanned again for macros to expand, including the arguments. This rule +may seem strange, but it is carefully designed so you need not worry +about whether any function call is actually a macro invocation. You can +run into trouble if you try to be too clever, though. See :ref:`argument-prescan`, for detailed discussion. + +For example, ``min (min (a, b), c)`` is first expanded to + +.. code-block:: c++ + + min (((a) < (b) ? (a) : (b)), (c)) + +and then to + +.. code-block:: c++ + + ((((a) < (b) ? (a) : (b))) < (c) + ? (((a) < (b) ? (a) : (b))) + : (c)) + +(Line breaks shown here for clarity would not actually be generated.) + +.. index:: empty macro arguments + +You can leave macro arguments empty; this is not an error to the +preprocessor (but many macros will then expand to invalid code). +You cannot leave out arguments entirely; if a macro takes two arguments, +there must be exactly one comma at the top level of its argument list. +Here are some silly examples using ``min`` : + +.. code-block:: + + min(, b) → (( ) < (b) ? ( ) : (b)) + min(a, ) → ((a ) < ( ) ? (a ) : ( )) + min(,) → (( ) < ( ) ? ( ) : ( )) + min((,),) → (((,)) < ( ) ? ((,)) : ( )) + + min() error macro "min" requires 2 arguments, but only 1 given + min(,,) error macro "min" passed 3 arguments, but takes just 2 + +Whitespace is not a preprocessing token, so if a macro ``foo`` takes +one argument, ``foo ()`` and ``foo ( )`` both supply it an +empty argument. Previous GNU preprocessor implementations and +documentation were incorrect on this point, insisting that a +function-like macro that takes a single argument be passed a space if an +empty argument was required. + +Macro parameters appearing inside string literals are not replaced by +their corresponding actual arguments. + +.. code-block:: + + #define foo(x) x, "x" + foo(bar) → bar, "x" \ No newline at end of file diff --git a/gcc/doc/cpp/macros/macro-pitfalls.rst b/gcc/doc/cpp/macros/macro-pitfalls.rst new file mode 100644 index 00000000000..0be22954a76 --- /dev/null +++ b/gcc/doc/cpp/macros/macro-pitfalls.rst @@ -0,0 +1,449 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: problems with macros, pitfalls of macros + +.. _macro-pitfalls: + +Macro Pitfalls +************** + +In this section we describe some special rules that apply to macros and +macro expansion, and point out certain cases in which the rules have +counter-intuitive consequences that you must watch out for. + +.. toctree:: + :maxdepth: 2 + + +.. _misnesting: + +Misnesting +^^^^^^^^^^ + +When a macro is called with arguments, the arguments are substituted +into the macro body and the result is checked, together with the rest of +the input file, for more macro calls. It is possible to piece together +a macro call coming partially from the macro body and partially from the +arguments. For example, + +.. code-block:: + + #define twice(x) (2*(x)) + #define call_with_1(x) x(1) + call_with_1 (twice) + → twice(1) + → (2*(1)) + +Macro definitions do not have to have balanced parentheses. By writing +an unbalanced open parenthesis in a macro body, it is possible to create +a macro call that begins inside the macro body but ends outside of it. +For example, + +.. code-block:: + + #define strange(file) fprintf (file, "%s %d", + ... + strange(stderr) p, 35) + → fprintf (stderr, "%s %d", p, 35) + +The ability to piece together a macro call can be useful, but the use of +unbalanced open parentheses in a macro body is just confusing, and +should be avoided. + +.. index:: parentheses in macro bodies + +.. _operator-precedence-problems: + +Operator Precedence Problems +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You may have noticed that in most of the macro definition examples shown +above, each occurrence of a macro argument name had parentheses around +it. In addition, another pair of parentheses usually surround the +entire macro definition. Here is why it is best to write macros that +way. + +Suppose you define a macro as follows, + +.. code-block:: c++ + + #define ceil_div(x, y) (x + y - 1) / y + +whose purpose is to divide, rounding up. (One use for this operation is +to compute how many ``int`` objects are needed to hold a certain +number of ``char`` objects.) Then suppose it is used as follows: + +.. code-block:: + + a = ceil_div (b & c, sizeof (int)); + → a = (b & c + sizeof (int) - 1) / sizeof (int); + +This does not do what is intended. The operator-precedence rules of +C make it equivalent to this: + +.. code-block:: c++ + + a = (b & (c + sizeof (int) - 1)) / sizeof (int); + +What we want is this: + +.. code-block:: c++ + + a = ((b & c) + sizeof (int) - 1)) / sizeof (int); + +Defining the macro as + +.. code-block:: c++ + + #define ceil_div(x, y) ((x) + (y) - 1) / (y) + +provides the desired result. + +Unintended grouping can result in another way. Consider ``sizeof +ceil_div(1, 2)``. That has the appearance of a C expression that would +compute the size of the type of ``ceil_div (1, 2)``, but in fact it +means something very different. Here is what it expands to: + +.. code-block:: c++ + + sizeof ((1) + (2) - 1) / (2) + +This would take the size of an integer and divide it by two. The +precedence rules have put the division outside the ``sizeof`` when it +was intended to be inside. + +Parentheses around the entire macro definition prevent such problems. +Here, then, is the recommended way to define ``ceil_div`` : + +.. code-block:: c++ + + #define ceil_div(x, y) (((x) + (y) - 1) / (y)) + +.. index:: semicolons (after macro calls) + +.. _swallowing-the-semicolon: + +Swallowing the Semicolon +^^^^^^^^^^^^^^^^^^^^^^^^ + +Often it is desirable to define a macro that expands into a compound +statement. Consider, for example, the following macro, that advances a +pointer (the argument ``p`` says where to find it) across whitespace +characters: + +.. code-block:: c++ + + #define SKIP_SPACES(p, limit) \ + { char *lim = (limit); \ + while (p < lim) { \ + if (*p++ != ' ') { \ + p--; break; }}} + +Here backslash-newline is used to split the macro definition, which must +be a single logical line, so that it resembles the way such code would +be laid out if not part of a macro definition. + +A call to this macro might be ``SKIP_SPACES (p, lim)``. Strictly +speaking, the call expands to a compound statement, which is a complete +statement with no need for a semicolon to end it. However, since it +looks like a function call, it minimizes confusion if you can use it +like a function call, writing a semicolon afterward, as in +``SKIP_SPACES (p, lim);`` + +This can cause trouble before ``else`` statements, because the +semicolon is actually a null statement. Suppose you write + +.. code-block:: c++ + + if (*p != 0) + SKIP_SPACES (p, lim); + else ... + +The presence of two statements---the compound statement and a null +statement---in between the ``if`` condition and the ``else`` +makes invalid C code. + +The definition of the macro ``SKIP_SPACES`` can be altered to solve +this problem, using a ``do ... while`` statement. Here is how: + +.. code-block:: c++ + + #define SKIP_SPACES(p, limit) \ + do { char *lim = (limit); \ + while (p < lim) { \ + if (*p++ != ' ') { \ + p--; break; }}} \ + while (0) + +Now ``SKIP_SPACES (p, lim);`` expands into + +.. code-block:: c++ + + do {...} while (0); + +which is one statement. The loop executes exactly once; most compilers +generate no extra code for it. + +.. index:: side effects (in macro arguments), unsafe macros + +.. _duplication-of-side-effects: + +Duplication of Side Effects +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Many C programs define a macro ``min``, for 'minimum', like this: + +.. code-block:: c++ + + #define min(X, Y) ((X) < (Y) ? (X) : (Y)) + +When you use this macro with an argument containing a side effect, +as shown here, + +.. code-block:: c++ + + next = min (x + y, foo (z)); + +it expands as follows: + +.. code-block:: c++ + + next = ((x + y) < (foo (z)) ? (x + y) : (foo (z))); + +where ``x + y`` has been substituted for ``X`` and ``foo (z)`` +for ``Y``. + +The function ``foo`` is used only once in the statement as it appears +in the program, but the expression ``foo (z)`` has been substituted +twice into the macro expansion. As a result, ``foo`` might be called +two times when the statement is executed. If it has side effects or if +it takes a long time to compute, the results might not be what you +intended. We say that ``min`` is an :dfn:`unsafe` macro. + +The best solution to this problem is to define ``min`` in a way that +computes the value of ``foo (z)`` only once. The C language offers +no standard way to do this, but it can be done with GNU extensions as +follows: + +.. code-block:: c++ + + #define min(X, Y) \ + ({ typeof (X) x_ = (X); \ + typeof (Y) y_ = (Y); \ + (x_ < y_) ? x_ : y_; }) + +The :samp:`({ ... })` notation produces a compound statement that +acts as an expression. Its value is the value of its last statement. +This permits us to define local variables and assign each argument to +one. The local variables have underscores after their names to reduce +the risk of conflict with an identifier of wider scope (it is impossible +to avoid this entirely). Now each argument is evaluated exactly once. + +If you do not wish to use GNU C extensions, the only solution is to be +careful when *using* the macro ``min``. For example, you can +calculate the value of ``foo (z)``, save it in a variable, and use +that variable in ``min`` : + +.. code-block:: c++ + + #define min(X, Y) ((X) < (Y) ? (X) : (Y)) + ... + { + int tem = foo (z); + next = min (x + y, tem); + } + +(where we assume that ``foo`` returns type ``int``). + +.. index:: self-reference + +.. _self-referential-macros: + +Self-Referential Macros +^^^^^^^^^^^^^^^^^^^^^^^ + +A :dfn:`self-referential` macro is one whose name appears in its +definition. Recall that all macro definitions are rescanned for more +macros to replace. If the self-reference were considered a use of the +macro, it would produce an infinitely large expansion. To prevent this, +the self-reference is not considered a macro call. It is passed into +the preprocessor output unchanged. Consider an example: + +.. code-block:: c++ + + #define foo (4 + foo) + +where ``foo`` is also a variable in your program. + +Following the ordinary rules, each reference to ``foo`` will expand +into ``(4 + foo)`` ; then this will be rescanned and will expand into +``(4 + (4 + foo))`` ; and so on until the computer runs out of memory. + +The self-reference rule cuts this process short after one step, at +``(4 + foo)``. Therefore, this macro definition has the possibly +useful effect of causing the program to add 4 to the value of ``foo`` +wherever ``foo`` is referred to. + +In most cases, it is a bad idea to take advantage of this feature. A +person reading the program who sees that ``foo`` is a variable will +not expect that it is a macro as well. The reader will come across the +identifier ``foo`` in the program and think its value should be that +of the variable ``foo``, whereas in fact the value is four greater. + +One common, useful use of self-reference is to create a macro which +expands to itself. If you write + +.. code-block:: c++ + + #define EPERM EPERM + +then the macro ``EPERM`` expands to ``EPERM``. Effectively, it is +left alone by the preprocessor whenever it's used in running text. You +can tell that it's a macro with :samp:`#ifdef`. You might do this if you +want to define numeric constants with an ``enum``, but have +:samp:`#ifdef` be true for each constant. + +If a macro ``x`` expands to use a macro ``y``, and the expansion of +``y`` refers to the macro ``x``, that is an :dfn:`indirect +self-reference` of ``x``. ``x`` is not expanded in this case +either. Thus, if we have + +.. code-block:: c++ + + #define x (4 + y) + #define y (2 * x) + +then ``x`` and ``y`` expand as follows: + +.. code-block:: + + x → (4 + y) + → (4 + (2 * x)) + + y → (2 * x) + → (2 * (4 + y)) + +Each macro is expanded when it appears in the definition of the other +macro, but not when it indirectly appears in its own definition. + +.. index:: expansion of arguments, macro argument expansion, prescan of macro arguments + +.. _argument-prescan: + +Argument Prescan +^^^^^^^^^^^^^^^^ + +Macro arguments are completely macro-expanded before they are +substituted into a macro body, unless they are stringized or pasted +with other tokens. After substitution, the entire macro body, including +the substituted arguments, is scanned again for macros to be expanded. +The result is that the arguments are scanned *twice* to expand +macro calls in them. + +Most of the time, this has no effect. If the argument contained any +macro calls, they are expanded during the first scan. The result +therefore contains no macro calls, so the second scan does not change +it. If the argument were substituted as given, with no prescan, the +single remaining scan would find the same macro calls and produce the +same results. + +You might expect the double scan to change the results when a +self-referential macro is used in an argument of another macro +(see :ref:`self-referential-macros`): the self-referential macro would be +expanded once in the first scan, and a second time in the second scan. +However, this is not what happens. The self-references that do not +expand in the first scan are marked so that they will not expand in the +second scan either. + +You might wonder, 'Why mention the prescan, if it makes no difference? +And why not skip it and make the preprocessor faster?' The answer is +that the prescan does make a difference in three special cases: + +* Nested calls to a macro. + + We say that :dfn:`nested` calls to a macro occur when a macro's argument + contains a call to that very macro. For example, if ``f`` is a macro + that expects one argument, ``f (f (1))`` is a nested pair of calls to + ``f``. The desired expansion is made by expanding ``f (1)`` and + substituting that into the definition of ``f``. The prescan causes + the expected result to happen. Without the prescan, ``f (1)`` itself + would be substituted as an argument, and the inner use of ``f`` would + appear during the main scan as an indirect self-reference and would not + be expanded. + +* Macros that call other macros that stringize or concatenate. + + If an argument is stringized or concatenated, the prescan does not + occur. If you *want* to expand a macro, then stringize or + concatenate its expansion, you can do that by causing one macro to call + another macro that does the stringizing or concatenation. For + instance, if you have + + .. code-block:: c++ + + #define AFTERX(x) X_ ## x + #define XAFTERX(x) AFTERX(x) + #define TABLESIZE 1024 + #define BUFSIZE TABLESIZE + + then ``AFTERX(BUFSIZE)`` expands to ``X_BUFSIZE``, and + ``XAFTERX(BUFSIZE)`` expands to ``X_1024``. (Not to + ``X_TABLESIZE``. Prescan always does a complete expansion.) + +* Macros used in arguments, whose expansions contain unshielded commas. + + This can cause a macro expanded on the second scan to be called with the + wrong number of arguments. Here is an example: + + .. code-block:: c++ + + #define foo a,b + #define bar(x) lose(x) + #define lose(x) (1 + (x)) + + We would like ``bar(foo)`` to turn into ``(1 + (foo))``, which + would then turn into ``(1 + (a,b))``. Instead, ``bar(foo)`` + expands into ``lose(a,b)``, and you get an error because ``lose`` + requires a single argument. In this case, the problem is easily solved + by the same parentheses that ought to be used to prevent misnesting of + arithmetic operations: + + .. code-block:: + + #define foo (a,b) + or#define bar(x) lose((x)) + + The extra pair of parentheses prevents the comma in ``foo`` 's + definition from being interpreted as an argument separator. + +.. index:: newlines in macro arguments + +.. _newlines-in-arguments: + +Newlines in Arguments +^^^^^^^^^^^^^^^^^^^^^ + +The invocation of a function-like macro can extend over many logical +lines. However, in the present implementation, the entire expansion +comes out on one line. Thus line numbers emitted by the compiler or +debugger refer to the line the invocation started on, which might be +different to the line containing the argument causing the problem. + +Here is an example illustrating this: + +.. code-block:: c++ + + #define ignore_second_arg(a,b,c) a; c + + ignore_second_arg (foo (), + ignored (), + syntax error); + +The syntax error triggered by the tokens ``syntax error`` results in +an error message citing line three---the line of ignore_second_arg--- +even though the problematic code comes from line five. + +We consider this a bug, and intend to fix it in the near future. \ No newline at end of file diff --git a/gcc/doc/cpp/macros/object-like-macros.rst b/gcc/doc/cpp/macros/object-like-macros.rst new file mode 100644 index 00000000000..c5e6e4cd466 --- /dev/null +++ b/gcc/doc/cpp/macros/object-like-macros.rst @@ -0,0 +1,126 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: object-like macro, symbolic constants, manifest constants + +.. _object-like-macros: + +Object-like Macros +****************** + +An :dfn:`object-like macro` is a simple identifier which will be replaced +by a code fragment. It is called object-like because it looks like a +data object in code that uses it. They are most commonly used to give +symbolic names to numeric constants. + +.. index:: #define + +You create macros with the :samp:`#define` directive. :samp:`#define` is +followed by the name of the macro and then the token sequence it should +be an abbreviation for, which is variously referred to as the macro's +:dfn:`body`, :dfn:`expansion` or :dfn:`replacement list`. For example, + +.. code-block:: c++ + + #define BUFFER_SIZE 1024 + +defines a macro named ``BUFFER_SIZE`` as an abbreviation for the +token ``1024``. If somewhere after this :samp:`#define` directive +there comes a C statement of the form + +.. code-block:: c++ + + foo = (char *) malloc (BUFFER_SIZE); + +then the C preprocessor will recognize and :dfn:`expand` the macro +``BUFFER_SIZE``. The C compiler will see the same tokens as it would +if you had written + +.. code-block:: c++ + + foo = (char *) malloc (1024); + +By convention, macro names are written in uppercase. Programs are +easier to read when it is possible to tell at a glance which names are +macros. + +The macro's body ends at the end of the :samp:`#define` line. You may +continue the definition onto multiple lines, if necessary, using +backslash-newline. When the macro is expanded, however, it will all +come out on one line. For example, + +.. code-block:: + + #define NUMBERS 1, \ + 2, \ + 3 + int x[] = { NUMBERS }; + → int x[] = { 1, 2, 3 }; + +The most common visible consequence of this is surprising line numbers +in error messages. + +There is no restriction on what can go in a macro body provided it +decomposes into valid preprocessing tokens. Parentheses need not +balance, and the body need not resemble valid C code. (If it does not, +you may get error messages from the C compiler when you use the macro.) + +The C preprocessor scans your program sequentially. Macro definitions +take effect at the place you write them. Therefore, the following input +to the C preprocessor + +.. code-block:: c++ + + foo = X; + #define X 4 + bar = X; + +produces + +.. code-block:: c++ + + foo = X; + bar = 4; + +When the preprocessor expands a macro name, the macro's expansion +replaces the macro invocation, then the expansion is examined for more +macros to expand. For example, + +.. code-block:: + + #define TABLESIZE BUFSIZE + #define BUFSIZE 1024 + TABLESIZE + → BUFSIZE + → 1024 + +``TABLESIZE`` is expanded first to produce ``BUFSIZE``, then that +macro is expanded to produce the final result, ``1024``. + +Notice that ``BUFSIZE`` was not defined when ``TABLESIZE`` was +defined. The :samp:`#define` for ``TABLESIZE`` uses exactly the +expansion you specify---in this case, ``BUFSIZE`` ---and does not +check to see whether it too contains macro names. Only when you +*use* ``TABLESIZE`` is the result of its expansion scanned for +more macro names. + +This makes a difference if you change the definition of ``BUFSIZE`` +at some point in the source file. ``TABLESIZE``, defined as shown, +will always expand using the definition of ``BUFSIZE`` that is +currently in effect: + +.. code-block:: c++ + + #define BUFSIZE 1020 + #define TABLESIZE BUFSIZE + #undef BUFSIZE + #define BUFSIZE 37 + +Now ``TABLESIZE`` expands (in two stages) to ``37``. + +If the expansion of a macro contains its own name, either directly or +via intermediate macros, it is not expanded again when the expansion is +examined for more macros. This prevents infinite recursion. +See :ref:`self-referential-macros`, for the precise details. \ No newline at end of file diff --git a/gcc/doc/cpp/macros/predefined-macros.rst b/gcc/doc/cpp/macros/predefined-macros.rst new file mode 100644 index 00000000000..8af566e0dc3 --- /dev/null +++ b/gcc/doc/cpp/macros/predefined-macros.rst @@ -0,0 +1,874 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: predefined macros + +.. _predefined-macros: + +Predefined Macros +***************** + +Several object-like macros are predefined; you use them without +supplying their definitions. They fall into three classes: standard, +common, and system-specific. + +In C++, there is a fourth category, the named operators. They act like +predefined macros, but you cannot undefine them. + +.. toctree:: + :maxdepth: 2 + + +.. index:: standard predefined macros. + +.. _standard-predefined-macros: + +Standard Predefined Macros +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The standard predefined macros are specified by the relevant +language standards, so they are available with all compilers that +implement those standards. Older compilers may not provide all of +them. Their names all start with double underscores. + +.. c:macro:: __FILE__ + + This macro expands to the name of the current input file, in the form of + a C string constant. This is the path by which the preprocessor opened + the file, not the short name specified in :samp:`#include` or as the + input file name argument. For example, + ``"/usr/local/include/myheader.h"`` is a possible expansion of this + macro. + +.. c:macro:: __LINE__ + + This macro expands to the current input line number, in the form of a + decimal integer constant. While we call it a predefined macro, it's + a pretty strange macro, since its 'definition' changes with each + new line of source code. + + ``__FILE__`` and ``__LINE__`` are useful in generating an error + message to report an inconsistency detected by the program; the message + can state the source line at which the inconsistency was detected. For + example, + +.. code-block:: c++ + + fprintf (stderr, "Internal error: " + "negative string length " + "%d at %s, line %d.", + length, __FILE__, __LINE__); + +An :samp:`#include` directive changes the expansions of ``__FILE__`` +and ``__LINE__`` to correspond to the included file. At the end of +that file, when processing resumes on the input file that contained +the :samp:`#include` directive, the expansions of ``__FILE__`` and +``__LINE__`` revert to the values they had before the +:samp:`#include` (but ``__LINE__`` is then incremented by one as +processing moves to the line after the :samp:`#include`). + +A :samp:`#line` directive changes ``__LINE__``, and may change +``__FILE__`` as well. See :ref:`line-control`. + +C99 introduced ``__func__``, and GCC has provided ``__FUNCTION__`` +for a long time. Both of these are strings containing the name of the +current function (there are slight semantic differences; see the GCC +manual). Neither of them is a macro; the preprocessor does not know the +name of the current function. They tend to be useful in conjunction +with ``__FILE__`` and ``__LINE__``, though. + +.. c:macro:: __DATE__ + + This macro expands to a string constant that describes the date on which + the preprocessor is being run. The string constant contains eleven + characters and looks like ``"Feb 12 1996"``. If the day of the + month is less than 10, it is padded with a space on the left. + + If GCC cannot determine the current date, it will emit a warning message + (once per compilation) and ``__DATE__`` will expand to + ``"??? ?? ????"``. + +.. c:macro:: __TIME__ + + This macro expands to a string constant that describes the time at + which the preprocessor is being run. The string constant contains + eight characters and looks like ``"23:59:01"``. + + If GCC cannot determine the current time, it will emit a warning message + (once per compilation) and ``__TIME__`` will expand to + ``"??:??:??"``. + +.. c:macro:: __STDC__ + + In normal operation, this macro expands to the constant 1, to signify + that this compiler conforms to ISO Standard C. If GNU CPP is used with + a compiler other than GCC, this is not necessarily true; however, the + preprocessor always conforms to the standard unless the + :option:`-traditional-cpp` option is used. + + This macro is not defined if the :option:`-traditional-cpp` option is used. + + On some hosts, the system compiler uses a different convention, where + ``__STDC__`` is normally 0, but is 1 if the user specifies strict + conformance to the C Standard. CPP follows the host convention when + processing system header files, but when processing user files + ``__STDC__`` is always 1. This has been reported to cause problems; + for instance, some versions of Solaris provide X Windows headers that + expect ``__STDC__`` to be either undefined or 1. See :ref:`invocation`. + +.. c:macro:: __STDC_VERSION__ + + This macro expands to the C Standard's version number, a long integer + constant of the form ``yyyymmL`` where :samp:`{yyyy}` and + :samp:`{mm}` are the year and month of the Standard version. This signifies + which version of the C Standard the compiler conforms to. Like + ``__STDC__``, this is not necessarily accurate for the entire + implementation, unless GNU CPP is being used with GCC. + + The value ``199409L`` signifies the 1989 C standard as amended in + 1994, which is the current default; the value ``199901L`` signifies + the 1999 revision of the C standard; the value ``201112L`` + signifies the 2011 revision of the C standard; the value + ``201710L`` signifies the 2017 revision of the C standard (which is + otherwise identical to the 2011 version apart from correction of + defects). An unspecified value larger than ``201710L`` is used for + the experimental :option:`-std=c2x` and :option:`-std=gnu2x` modes. + + This macro is not defined if the :option:`-traditional-cpp` option is + used, nor when compiling C++ or Objective-C. + +.. c:macro:: __STDC_HOSTED__ + + This macro is defined, with value 1, if the compiler's target is a + :dfn:`hosted environment`. A hosted environment has the complete + facilities of the standard C library available. + +.. c:macro:: __cplusplus + + This macro is defined when the C++ compiler is in use. You can use + ``__cplusplus`` to test whether a header is compiled by a C compiler + or a C++ compiler. This macro is similar to ``__STDC_VERSION__``, in + that it expands to a version number. Depending on the language standard + selected, the value of the macro is + ``199711L`` for the 1998 C++ standard, + ``201103L`` for the 2011 C++ standard, + ``201402L`` for the 2014 C++ standard, + ``201703L`` for the 2017 C++ standard, + ``202002L`` for the 2020 C++ standard, + or an unspecified value strictly larger than ``202002L`` for the + experimental languages enabled by :option:`-std=c++23` and + :option:`-std=gnu++23`. + +.. c:macro:: __OBJC__ + + This macro is defined, with value 1, when the Objective-C compiler is in + use. You can use ``__OBJC__`` to test whether a header is compiled + by a C compiler or an Objective-C compiler. + +.. c:macro:: __ASSEMBLER__ + + This macro is defined with value 1 when preprocessing assembly + language. + +.. index:: common predefined macros + +.. _common-predefined-macros: + +Common Predefined Macros +^^^^^^^^^^^^^^^^^^^^^^^^ + +The common predefined macros are GNU C extensions. They are available +with the same meanings regardless of the machine or operating system on +which you are using GNU C or GNU Fortran. Their names all start with +double underscores. + +.. c:macro:: __COUNTER__ + + This macro expands to sequential integral values starting from 0. In + conjunction with the ``##`` operator, this provides a convenient means to + generate unique identifiers. Care must be taken to ensure that + ``__COUNTER__`` is not expanded prior to inclusion of precompiled headers + which use it. Otherwise, the precompiled headers will not be used. + +.. c:macro:: __GFORTRAN__ + + The GNU Fortran compiler defines this. + +.. c:macro:: __GNUC__ + __GNUC_MINOR__ + __GNUC_PATCHLEVEL__ + + These macros are defined by all GNU compilers that use the C + preprocessor: C, C++, Objective-C and Fortran. Their values are the major + version, minor version, and patch level of the compiler, as integer + constants. For example, GCC version :samp:`{x}`. :samp:`{y}`. :samp:`{z}` + defines ``__GNUC__`` to :samp:`{x}`, ``__GNUC_MINOR__`` to :samp:`{y}`, + and ``__GNUC_PATCHLEVEL__`` to :samp:`{z}`. These + macros are also defined if you invoke the preprocessor directly. + + If all you need to know is whether or not your program is being compiled + by GCC, or a non-GCC compiler that claims to accept the GNU C dialects, + you can simply test ``__GNUC__``. If you need to write code + which depends on a specific version, you must be more careful. Each + time the minor version is increased, the patch level is reset to zero; + each time the major version is increased, the + minor version and patch level are reset. If you wish to use the + predefined macros directly in the conditional, you will need to write it + like this: + + .. code-block:: c++ + + /* Test for GCC > 3.2.0 */ + #if __GNUC__ > 3 || \ + (__GNUC__ == 3 && (__GNUC_MINOR__ > 2 || \ + (__GNUC_MINOR__ == 2 && \ + __GNUC_PATCHLEVEL__ > 0)) + + Another approach is to use the predefined macros to + calculate a single number, then compare that against a threshold: + + .. code-block:: c++ + + #define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + ... + /* Test for GCC > 3.2.0 */ + #if GCC_VERSION > 30200 + + Many people find this form easier to understand. + +.. c:macro:: __GNUG__ + + The GNU C++ compiler defines this. Testing it is equivalent to + testing ``(__GNUC__ && __cplusplus)``. + +.. c:macro:: __STRICT_ANSI__ + + GCC defines this macro if and only if the :option:`-ansi` switch, or a + :option:`-std` switch specifying strict conformance to some version of ISO C + or ISO C++, was specified when GCC was invoked. It is defined to :samp:`1`. + This macro exists primarily to direct GNU libc's header files to use only + definitions found in standard C. + +.. c:macro:: __BASE_FILE__ + + This macro expands to the name of the main input file, in the form + of a C string constant. This is the source file that was specified + on the command line of the preprocessor or C compiler. + +.. c:macro:: __FILE_NAME__ + + This macro expands to the basename of the current input file, in the + form of a C string constant. This is the last path component by which + the preprocessor opened the file. For example, processing + ``"/usr/local/include/myheader.h"`` would set this + macro to ``"myheader.h"``. + +.. c:macro:: __INCLUDE_LEVEL__ + + This macro expands to a decimal integer constant that represents the + depth of nesting in include files. The value of this macro is + incremented on every :samp:`#include` directive and decremented at the + end of every included file. It starts out at 0, its value within the + base file specified on the command line. + +.. c:macro:: __ELF__ + + This macro is defined if the target uses the ELF object format. + +.. c:macro:: __VERSION__ + + This macro expands to a string constant which describes the version of + the compiler in use. You should not rely on its contents having any + particular form, but it can be counted on to contain at least the + release number. + +.. c:macro:: __OPTIMIZE__ + __OPTIMIZE_SIZE__ + __NO_INLINE__ + + These macros describe the compilation mode. ``__OPTIMIZE__`` is + defined in all optimizing compilations. ``__OPTIMIZE_SIZE__`` is + defined if the compiler is optimizing for size, not speed. + ``__NO_INLINE__`` is defined if no functions will be inlined into + their callers (when not optimizing, or when inlining has been + specifically disabled by :option:`-fno-inline`). + + These macros cause certain GNU header files to provide optimized + definitions, using macros or inline functions, of system library + functions. You should not use these macros in any way unless you make + sure that programs will execute with the same effect whether or not they + are defined. If they are defined, their value is 1. + +.. c:macro:: __GNUC_GNU_INLINE__ + + GCC defines this macro if functions declared ``inline`` will be + handled in GCC's traditional gnu90 mode. Object files will contain + externally visible definitions of all functions declared ``inline`` + without ``extern`` or ``static``. They will not contain any + definitions of any functions declared ``extern inline``. + +.. c:macro:: __GNUC_STDC_INLINE__ + + GCC defines this macro if functions declared ``inline`` will be + handled according to the ISO C99 or later standards. Object files will contain + externally visible definitions of all functions declared ``extern + inline``. They will not contain definitions of any functions declared + ``inline`` without ``extern``. + + If this macro is defined, GCC supports the ``gnu_inline`` function + attribute as a way to always get the gnu90 behavior. + +.. c:macro:: __CHAR_UNSIGNED__ + + GCC defines this macro if and only if the data type ``char`` is + unsigned on the target machine. It exists to cause the standard header + file :samp:`limits.h` to work correctly. You should not use this macro + yourself; instead, refer to the standard macros defined in :samp:`limits.h`. + +.. c:macro:: __WCHAR_UNSIGNED__ + + Like ``__CHAR_UNSIGNED__``, this macro is defined if and only if the + data type ``wchar_t`` is unsigned and the front-end is in C++ mode. + +.. c:macro:: __REGISTER_PREFIX__ + + This macro expands to a single token (not a string constant) which is + the prefix applied to CPU register names in assembly language for this + target. You can use it to write assembly that is usable in multiple + environments. For example, in the ``m68k-aout`` environment it + expands to nothing, but in the ``m68k-coff`` environment it expands + to a single :samp:`%`. + +.. c:macro:: __USER_LABEL_PREFIX__ + + This macro expands to a single token which is the prefix applied to + user labels (symbols visible to C code) in assembly. For example, in + the ``m68k-aout`` environment it expands to an :samp:`_`, but in the + ``m68k-coff`` environment it expands to nothing. + + This macro will have the correct definition even if + :option:`-f(no-)underscores` is in use, but it will not be correct if + target-specific options that adjust this prefix are used (e.g. the + OSF/rose :option:`-mno-underscores` option). + +.. c:macro:: __SIZE_TYPE__ + __PTRDIFF_TYPE__ + __WCHAR_TYPE__ + __WINT_TYPE__ + __INTMAX_TYPE__ + __UINTMAX_TYPE__ + __SIG_ATOMIC_TYPE__ + __INT8_TYPE__ + __INT16_TYPE__ + __INT32_TYPE__ + __INT64_TYPE__ + __UINT8_TYPE__ + __UINT16_TYPE__ + __UINT32_TYPE__ + __UINT64_TYPE__ + __INT_LEAST8_TYPE__ + __INT_LEAST16_TYPE__ + __INT_LEAST32_TYPE__ + __INT_LEAST64_TYPE__ + __UINT_LEAST8_TYPE__ + __UINT_LEAST16_TYPE__ + __UINT_LEAST32_TYPE__ + __UINT_LEAST64_TYPE__ + __INT_FAST8_TYPE__ + __INT_FAST16_TYPE__ + __INT_FAST32_TYPE__ + __INT_FAST64_TYPE__ + __UINT_FAST8_TYPE__ + __UINT_FAST16_TYPE__ + __UINT_FAST32_TYPE__ + __UINT_FAST64_TYPE__ + __INTPTR_TYPE__ + __UINTPTR_TYPE__ + + These macros are defined to the correct underlying types for the + ``size_t``, ``ptrdiff_t``, ``wchar_t``, ``wint_t``, + ``intmax_t``, ``uintmax_t``, ``sig_atomic_t``, ``int8_t``, + ``int16_t``, ``int32_t``, ``int64_t``, ``uint8_t``, + ``uint16_t``, ``uint32_t``, ``uint64_t``, + ``int_least8_t``, ``int_least16_t``, ``int_least32_t``, + ``int_least64_t``, ``uint_least8_t``, ``uint_least16_t``, + ``uint_least32_t``, ``uint_least64_t``, ``int_fast8_t``, + ``int_fast16_t``, ``int_fast32_t``, ``int_fast64_t``, + ``uint_fast8_t``, ``uint_fast16_t``, ``uint_fast32_t``, + ``uint_fast64_t``, ``intptr_t``, and ``uintptr_t`` typedefs, + respectively. They exist to make the standard header files + :samp:`stddef.h`, :samp:`stdint.h`, and :samp:`wchar.h` work correctly. + You should not use these macros directly; instead, include the + appropriate headers and use the typedefs. Some of these macros may + not be defined on particular systems if GCC does not provide a + :samp:`stdint.h` header on those systems. + +.. c:macro:: __CHAR_BIT__ + + Defined to the number of bits used in the representation of the + ``char`` data type. It exists to make the standard header given + numerical limits work correctly. You should not use + this macro directly; instead, include the appropriate headers. + +.. c:macro:: __SCHAR_MAX__ + __WCHAR_MAX__ + __SHRT_MAX__ + __INT_MAX__ + __LONG_MAX__ + __LONG_LONG_MAX__ + __WINT_MAX__ + __SIZE_MAX__ + __PTRDIFF_MAX__ + __INTMAX_MAX__ + __UINTMAX_MAX__ + __SIG_ATOMIC_MAX__ + __INT8_MAX__ + __INT16_MAX__ + __INT32_MAX__ + __INT64_MAX__ + __UINT8_MAX__ + __UINT16_MAX__ + __UINT32_MAX__ + __UINT64_MAX__ + __INT_LEAST8_MAX__ + __INT_LEAST16_MAX__ + __INT_LEAST32_MAX__ + __INT_LEAST64_MAX__ + __UINT_LEAST8_MAX__ + __UINT_LEAST16_MAX__ + __UINT_LEAST32_MAX__ + __UINT_LEAST64_MAX__ + __INT_FAST8_MAX__ + __INT_FAST16_MAX__ + __INT_FAST32_MAX__ + __INT_FAST64_MAX__ + __UINT_FAST8_MAX__ + __UINT_FAST16_MAX__ + __UINT_FAST32_MAX__ + __UINT_FAST64_MAX__ + __INTPTR_MAX__ + __UINTPTR_MAX__ + __WCHAR_MIN__ + __WINT_MIN__ + __SIG_ATOMIC_MIN__ + + Defined to the maximum value of the ``signed char``, ``wchar_t``, + ``signed short``, + ``signed int``, ``signed long``, ``signed long long``, + ``wint_t``, ``size_t``, ``ptrdiff_t``, + ``intmax_t``, ``uintmax_t``, ``sig_atomic_t``, ``int8_t``, + ``int16_t``, ``int32_t``, ``int64_t``, ``uint8_t``, + ``uint16_t``, ``uint32_t``, ``uint64_t``, + ``int_least8_t``, ``int_least16_t``, ``int_least32_t``, + ``int_least64_t``, ``uint_least8_t``, ``uint_least16_t``, + ``uint_least32_t``, ``uint_least64_t``, ``int_fast8_t``, + ``int_fast16_t``, ``int_fast32_t``, ``int_fast64_t``, + ``uint_fast8_t``, ``uint_fast16_t``, ``uint_fast32_t``, + ``uint_fast64_t``, ``intptr_t``, and ``uintptr_t`` types and + to the minimum value of the ``wchar_t``, ``wint_t``, and + ``sig_atomic_t`` types respectively. They exist to make the + standard header given numerical limits work correctly. You should not + use these macros directly; instead, include the appropriate headers. + Some of these macros may not be defined on particular systems if GCC + does not provide a :samp:`stdint.h` header on those systems. + +.. c:macro:: __INT8_C + __INT16_C + __INT32_C + __INT64_C + __UINT8_C + __UINT16_C + __UINT32_C + __UINT64_C + __INTMAX_C + __UINTMAX_C + + Defined to implementations of the standard :samp:`stdint.h` macros with + the same names without the leading ``__``. They exist the make the + implementation of that header work correctly. You should not use + these macros directly; instead, include the appropriate headers. Some + of these macros may not be defined on particular systems if GCC does + not provide a :samp:`stdint.h` header on those systems. + +.. c:macro:: __SCHAR_WIDTH__ + __SHRT_WIDTH__ + __INT_WIDTH__ + __LONG_WIDTH__ + __LONG_LONG_WIDTH__ + __PTRDIFF_WIDTH__ + __SIG_ATOMIC_WIDTH__ + __SIZE_WIDTH__ + __WCHAR_WIDTH__ + __WINT_WIDTH__ + __INT_LEAST8_WIDTH__ + __INT_LEAST16_WIDTH__ + __INT_LEAST32_WIDTH__ + __INT_LEAST64_WIDTH__ + __INT_FAST8_WIDTH__ + __INT_FAST16_WIDTH__ + __INT_FAST32_WIDTH__ + __INT_FAST64_WIDTH__ + __INTPTR_WIDTH__ + __INTMAX_WIDTH__ + + Defined to the bit widths of the corresponding types. They exist to + make the implementations of :samp:`limits.h` and :samp:`stdint.h` behave + correctly. You should not use these macros directly; instead, include + the appropriate headers. Some of these macros may not be defined on + particular systems if GCC does not provide a :samp:`stdint.h` header on + those systems. + +.. c:macro:: __SIZEOF_INT__ + __SIZEOF_LONG__ + __SIZEOF_LONG_LONG__ + __SIZEOF_SHORT__ + __SIZEOF_POINTER__ + __SIZEOF_FLOAT__ + __SIZEOF_DOUBLE__ + __SIZEOF_LONG_DOUBLE__ + __SIZEOF_SIZE_T__ + __SIZEOF_WCHAR_T__ + __SIZEOF_WINT_T__ + __SIZEOF_PTRDIFF_T__ + + Defined to the number of bytes of the C standard data types: ``int``, + ``long``, ``long long``, ``short``, ``void *``, ``float``, + ``double``, ``long double``, ``size_t``, ``wchar_t``, ``wint_t`` + and ``ptrdiff_t``. + +.. c:macro:: __BYTE_ORDER__ + __ORDER_LITTLE_ENDIAN__ + __ORDER_BIG_ENDIAN__ + __ORDER_PDP_ENDIAN__ + + ``__BYTE_ORDER__`` is defined to one of the values + ``__ORDER_LITTLE_ENDIAN__``, ``__ORDER_BIG_ENDIAN__``, or + ``__ORDER_PDP_ENDIAN__`` to reflect the layout of multi-byte and + multi-word quantities in memory. If ``__BYTE_ORDER__`` is equal to + ``__ORDER_LITTLE_ENDIAN__`` or ``__ORDER_BIG_ENDIAN__``, then + multi-byte and multi-word quantities are laid out identically: the + byte (word) at the lowest address is the least significant or most + significant byte (word) of the quantity, respectively. If + ``__BYTE_ORDER__`` is equal to ``__ORDER_PDP_ENDIAN__``, then + bytes in 16-bit words are laid out in a little-endian fashion, whereas + the 16-bit subwords of a 32-bit quantity are laid out in big-endian + fashion. + + You should use these macros for testing like this: + + .. code-block:: c++ + + /* Test for a little-endian machine */ + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + +.. c:macro:: __FLOAT_WORD_ORDER__ + + ``__FLOAT_WORD_ORDER__`` is defined to one of the values + ``__ORDER_LITTLE_ENDIAN__`` or ``__ORDER_BIG_ENDIAN__`` to reflect + the layout of the words of multi-word floating-point quantities. + +.. c:macro:: __DEPRECATED + + This macro is defined, with value 1, when compiling a C++ source file + with warnings about deprecated constructs enabled. These warnings are + enabled by default, but can be disabled with :option:`-Wno-deprecated`. + +.. c:macro:: __EXCEPTIONS + + This macro is defined, with value 1, when compiling a C++ source file + with exceptions enabled. If :option:`-fno-exceptions` is used when + compiling the file, then this macro is not defined. + +.. c:macro:: __GXX_RTTI + + This macro is defined, with value 1, when compiling a C++ source file + with runtime type identification enabled. If :option:`-fno-rtti` is + used when compiling the file, then this macro is not defined. + +.. c:macro:: __USING_SJLJ_EXCEPTIONS__ + + This macro is defined, with value 1, if the compiler uses the old + mechanism based on ``setjmp`` and ``longjmp`` for exception + handling. + +.. c:macro:: __GXX_EXPERIMENTAL_CXX0X__ + + This macro is defined when compiling a C++ source file with C++11 features + enabled, i.e., for all C++ language dialects except :option:`-std=c++98` + and :option:`-std=gnu++98`. This macro is obsolete, but can be used to + detect experimental C++0x features in very old versions of GCC. Since + GCC 4.7.0 the ``__cplusplus`` macro is defined correctly, so most + code should test ``__cplusplus >= 201103L`` instead of using this + macro. + +.. c:macro:: __GXX_WEAK__ + + This macro is defined when compiling a C++ source file. It has the + value 1 if the compiler will use weak symbols, COMDAT sections, or + other similar techniques to collapse symbols with 'vague linkage' + that are defined in multiple translation units. If the compiler will + not collapse such symbols, this macro is defined with value 0. In + general, user code should not need to make use of this macro; the + purpose of this macro is to ease implementation of the C++ runtime + library provided with G++. + +.. c:macro:: __NEXT_RUNTIME__ + + This macro is defined, with value 1, if (and only if) the NeXT runtime + (as in :option:`-fnext-runtime`) is in use for Objective-C. If the GNU + runtime is used, this macro is not defined, so that you can use this + macro to determine which runtime (NeXT or GNU) is being used. + +.. c:macro:: __LP64__ + _LP64 + + These macros are defined, with value 1, if (and only if) the compilation + is for a target where ``long int`` and pointer both use 64-bits and + ``int`` uses 32-bit. + +.. c:macro:: __SSP__ + + This macro is defined, with value 1, when :option:`-fstack-protector` is in + use. + +.. c:macro:: __SSP_ALL__ + + This macro is defined, with value 2, when :option:`-fstack-protector-all` is + in use. + +.. c:macro:: __SSP_STRONG__ + + This macro is defined, with value 3, when :option:`-fstack-protector-strong` is + in use. + +.. c:macro:: __SSP_EXPLICIT__ + + This macro is defined, with value 4, when :option:`-fstack-protector-explicit` is + in use. + +``__SANITIZE_ADDRESS__`` + This macro is defined, with value 1, when :option:`-fsanitize=address` + or :option:`-fsanitize=kernel-address` are in use. + +``__SANITIZE_THREAD__`` + This macro is defined, with value 1, when :option:`-fsanitize=thread` is in use. + +.. c:macro:: __TIMESTAMP__ + + This macro expands to a string constant that describes the date and time + of the last modification of the current source file. The string constant + contains abbreviated day of the week, month, day of the month, time in + hh:mm:ss form, year and looks like ``"Sun Sep 16 01:03:52 1973"``. + If the day of the month is less than 10, it is padded with a space on the left. + + If GCC cannot determine the current date, it will emit a warning message + (once per compilation) and ``__TIMESTAMP__`` will expand to + ``"??? ??? ?? ??:??:?? ????"``. + +.. c:macro:: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 + __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 + __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 + __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 + __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 + + These macros are defined when the target processor supports atomic compare + and swap operations on operands 1, 2, 4, 8 or 16 bytes in length, respectively. + +.. c:macro:: __HAVE_SPECULATION_SAFE_VALUE + + This macro is defined with the value 1 to show that this version of GCC + supports ``__builtin_speculation_safe_value``. + +.. c:macro:: __GCC_HAVE_DWARF2_CFI_ASM + + This macro is defined when the compiler is emitting DWARF CFI directives + to the assembler. When this is defined, it is possible to emit those same + directives in inline assembly. + +.. c:macro:: __FP_FAST_FMA + __FP_FAST_FMAF + __FP_FAST_FMAL + + These macros are defined with value 1 if the backend supports the + ``fma``, ``fmaf``, and ``fmal`` builtin functions, so that + the include file :samp:`math.h` can define the macros + ``FP_FAST_FMA``, ``FP_FAST_FMAF``, and ``FP_FAST_FMAL`` + for compatibility with the 1999 C standard. + +.. c:macro:: __FP_FAST_FMAF16 + __FP_FAST_FMAF32 + __FP_FAST_FMAF64 + __FP_FAST_FMAF128 + __FP_FAST_FMAF32X + __FP_FAST_FMAF64X + __FP_FAST_FMAF128X + + These macros are defined with the value 1 if the backend supports the + ``fma`` functions using the additional ``_Floatn`` and + ``_Floatnx`` types that are defined in ISO/IEC TS + 18661-3:2015. The include file :samp:`math.h` can define the + ``FP_FAST_FMAFn`` and ``FP_FAST_FMAFnx`` macros if + the user defined ``__STDC_WANT_IEC_60559_TYPES_EXT__`` before + including :samp:`math.h`. + +.. c:macro:: __GCC_IEC_559 + + This macro is defined to indicate the intended level of support for + IEEE 754 (IEC 60559) floating-point arithmetic. It expands to a + nonnegative integer value. If 0, it indicates that the combination of + the compiler configuration and the command-line options is not + intended to support IEEE 754 arithmetic for ``float`` and + ``double`` as defined in C99 and C11 Annex F (for example, that the + standard rounding modes and exceptions are not supported, or that + optimizations are enabled that conflict with IEEE 754 semantics). If + 1, it indicates that IEEE 754 arithmetic is intended to be supported; + this does not mean that all relevant language features are supported + by GCC. If 2 or more, it additionally indicates support for IEEE + 754-2008 (in particular, that the binary encodings for quiet and + signaling NaNs are as specified in IEEE 754-2008). + + This macro does not indicate the default state of command-line options + that control optimizations that C99 and C11 permit to be controlled by + standard pragmas, where those standards do not require a particular + default state. It does not indicate whether optimizations respect + signaling NaN semantics (the macro for that is + ``__SUPPORT_SNAN__``). It does not indicate support for decimal + floating point or the IEEE 754 binary16 and binary128 types. + +.. c:macro:: __GCC_IEC_559_COMPLEX + + This macro is defined to indicate the intended level of support for + IEEE 754 (IEC 60559) floating-point arithmetic for complex numbers, as + defined in C99 and C11 Annex G. It expands to a nonnegative integer + value. If 0, it indicates that the combination of the compiler + configuration and the command-line options is not intended to support + Annex G requirements (for example, because :option:`-fcx-limited-range` + was used). If 1 or more, it indicates that it is intended to support + those requirements; this does not mean that all relevant language + features are supported by GCC. + +.. c:macro:: __NO_MATH_ERRNO__ + + This macro is defined if :option:`-fno-math-errno` is used, or enabled + by another option such as :option:`-ffast-math` or by default. + +.. c:macro:: __RECIPROCAL_MATH__ + + This macro is defined if :option:`-freciprocal-math` is used, or enabled + by another option such as :option:`-ffast-math` or by default. + +.. c:macro:: __NO_SIGNED_ZEROS__ + + This macro is defined if :option:`-fno-signed-zeros` is used, or enabled + by another option such as :option:`-ffast-math` or by default. + +.. c:macro:: __NO_TRAPPING_MATH__ + + This macro is defined if :option:`-fno-trapping-math` is used. + +.. c:macro:: __ASSOCIATIVE_MATH__ + + This macro is defined if :option:`-fassociative-math` is used, or enabled + by another option such as :option:`-ffast-math` or by default. + +.. c:macro:: __ROUNDING_MATH__ + + This macro is defined if :option:`-frounding-math` is used. + +.. c:macro:: __GNUC_EXECUTION_CHARSET_NAME + __GNUC_WIDE_EXECUTION_CHARSET_NAME + + These macros are defined to expand to a narrow string literal of + the name of the narrow and wide compile-time execution character + set used. It directly reflects the name passed to the options + :option:`-fexec-charset` and :option:`-fwide-exec-charset`, or the defaults + documented for those options (that is, it can expand to something like + ``"UTF-8"``). See :ref:`invocation`. + +.. index:: system-specific predefined macros, predefined macros, system-specific, reserved namespace + +.. _system-specific-predefined-macros: + +System-specific Predefined Macros +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The C preprocessor normally predefines several macros that indicate what +type of system and machine is in use. They are obviously different on +each target supported by GCC. This manual, being for all systems and +machines, cannot tell you what their names are, but you can use +:command:`cpp -dM` to see them all. See :ref:`invocation`. All system-specific +predefined macros expand to a constant value, so you can test them with +either :samp:`#ifdef` or :samp:`#if`. + +The C standard requires that all system-specific macros be part of the +:dfn:`reserved namespace`. All names which begin with two underscores, +or an underscore and a capital letter, are reserved for the compiler and +library to use as they wish. However, historically system-specific +macros have had names with no special prefix; for instance, it is common +to find ``unix`` defined on Unix systems. For all such macros, GCC +provides a parallel macro with two underscores added at the beginning +and the end. If ``unix`` is defined, ``__unix__`` will be defined +too. There will never be more than two underscores; the parallel of +``_mips`` is ``__mips__``. + +When the :option:`-ansi` option, or any :option:`-std` option that +requests strict conformance, is given to the compiler, all the +system-specific predefined macros outside the reserved namespace are +suppressed. The parallel macros, inside the reserved namespace, remain +defined. + +We are slowly phasing out all predefined macros which are outside the +reserved namespace. You should never use them in new programs, and we +encourage you to correct older code to use the parallel macros whenever +you find it. We don't recommend you use the system-specific macros that +are in the reserved namespace, either. It is better in the long run to +check specifically for features you need, using a tool such as +:command:`autoconf`. + +.. index:: named operators, C++ named operators, iso646.h + +.. _c++-named-operators: + +C++ Named Operators +^^^^^^^^^^^^^^^^^^^ + +In C++, there are eleven keywords which are simply alternate spellings +of operators normally written with punctuation. These keywords are +treated as such even in the preprocessor. They function as operators in +:samp:`#if`, and they cannot be defined as macros or poisoned. In C, you +can request that those keywords take their C++ meaning by including +:samp:`iso646.h`. That header defines each one as a normal object-like +macro expanding to the appropriate punctuator. + +These are the named operators and their corresponding punctuators: + +.. list-table:: + + * - Named Operator + - Punctuator + * - ``and`` + - ``&&`` + * - ``and_eq`` + - ``&=`` + * - ``bitand`` + - ``&`` + * - ``bitor`` + - ``|`` + * - ``compl`` + - ``~`` + * - ``not`` + - ``!`` + * - ``not_eq`` + - ``!=`` + * - ``or`` + - ``||`` + * - ``or_eq`` + - ``|=`` + * - ``xor`` + - ``^`` + * - ``xor_eq`` + - ``^=`` \ No newline at end of file diff --git a/gcc/doc/cpp/macros/stringizing.rst b/gcc/doc/cpp/macros/stringizing.rst new file mode 100644 index 00000000000..9265601c134 --- /dev/null +++ b/gcc/doc/cpp/macros/stringizing.rst @@ -0,0 +1,86 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: stringizing, # operator + +.. _stringizing: + +Stringizing +*********** + +Sometimes you may want to convert a macro argument into a string +constant. Parameters are not replaced inside string constants, but you +can use the :samp:`#` preprocessing operator instead. When a macro +parameter is used with a leading :samp:`#`, the preprocessor replaces it +with the literal text of the actual argument, converted to a string +constant. Unlike normal parameter replacement, the argument is not +macro-expanded first. This is called :dfn:`stringizing`. + +There is no way to combine an argument with surrounding text and +stringize it all together. Instead, you can write a series of adjacent +string constants and stringized arguments. The preprocessor +replaces the stringized arguments with string constants. The C +compiler then combines all the adjacent string constants into one +long string. + +Here is an example of a macro definition that uses stringizing: + +.. code-block:: + + #define WARN_IF(EXP) \ + do { if (EXP) \ + fprintf (stderr, "Warning: " #EXP "\n"); } \ + while (0) + WARN_IF (x == 0); + → do { if (x == 0) + fprintf (stderr, "Warning: " "x == 0" "\n"); } while (0); + +The argument for ``EXP`` is substituted once, as-is, into the +``if`` statement, and once, stringized, into the argument to +``fprintf``. If ``x`` were a macro, it would be expanded in the +``if`` statement, but not in the string. + +The ``do`` and ``while (0)`` are a kludge to make it possible to +write ``WARN_IF (arg);``, which the resemblance of +``WARN_IF`` to a function would make C programmers want to do; see +:ref:`swallowing-the-semicolon`. + +Stringizing in C involves more than putting double-quote characters +around the fragment. The preprocessor backslash-escapes the quotes +surrounding embedded string constants, and all backslashes within string and +character constants, in order to get a valid C string constant with the +proper contents. Thus, stringizing ``p = "foo\n";`` results in +``"p = \"foo\\n\";"``. However, backslashes that are not inside string +or character constants are not duplicated: :samp:`\\n` by itself +stringizes to ``"\n"``. + +All leading and trailing whitespace in text being stringized is +ignored. Any sequence of whitespace in the middle of the text is +converted to a single space in the stringized result. Comments are +replaced by whitespace long before stringizing happens, so they +never appear in stringized text. + +There is no way to convert a macro argument into a character constant. + +If you want to stringize the result of expansion of a macro argument, +you have to use two levels of macros. + +.. code-block:: + + #define xstr(s) str(s) + #define str(s) #s + #define foo 4 + str (foo) + → "foo" + xstr (foo) + → xstr (4) + → str (4) + → "4" + +``s`` is stringized when it is used in ``str``, so it is not +macro-expanded first. But ``s`` is an ordinary argument to +``xstr``, so it is completely macro-expanded before ``xstr`` +itself is expanded (see :ref:`argument-prescan`). Therefore, by the time +``str`` gets to its argument, it has already been macro-expanded. \ No newline at end of file diff --git a/gcc/doc/cpp/macros/undefining-and-redefining-macros.rst b/gcc/doc/cpp/macros/undefining-and-redefining-macros.rst new file mode 100644 index 00000000000..137abe94984 --- /dev/null +++ b/gcc/doc/cpp/macros/undefining-and-redefining-macros.rst @@ -0,0 +1,67 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: undefining macros, redefining macros, #undef + +.. _undefining-and-redefining-macros: + +Undefining and Redefining Macros +******************************** + +If a macro ceases to be useful, it may be :dfn:`undefined` with the +:samp:`#undef` directive. :samp:`#undef` takes a single argument, the +name of the macro to undefine. You use the bare macro name, even if the +macro is function-like. It is an error if anything appears on the line +after the macro name. :samp:`#undef` has no effect if the name is not a +macro. + +.. code-block:: + + #define FOO 4 + x = FOO; → x = 4; + #undef FOO + x = FOO; → x = FOO; + +Once a macro has been undefined, that identifier may be :dfn:`redefined` +as a macro by a subsequent :samp:`#define` directive. The new definition +need not have any resemblance to the old definition. + +However, if an identifier which is currently a macro is redefined, then +the new definition must be :dfn:`effectively the same` as the old one. +Two macro definitions are effectively the same if: + +* Both are the same type of macro (object- or function-like). + +* All the tokens of the replacement list are the same. + +* If there are any parameters, they are the same. + +* Whitespace appears in the same places in both. It need not be + exactly the same amount of whitespace, though. Remember that comments + count as whitespace. + +These definitions are effectively the same: + +.. code-block:: c++ + + #define FOUR (2 + 2) + #define FOUR (2 + 2) + #define FOUR (2 /* two */ + 2) + +but these are not: + +.. code-block:: c++ + + #define FOUR (2 + 2) + #define FOUR ( 2+2 ) + #define FOUR (2 * 2) + #define FOUR(score,and,seven,years,ago) (2 + 2) + +If a macro is redefined with a definition that is not effectively the +same as the old one, the preprocessor issues a warning and changes the +macro to use the new definition. If the new definition is effectively +the same, the redefinition is silently ignored. This allows, for +instance, two different headers to define a common macro. The +preprocessor will only complain if the definitions do not match. \ No newline at end of file diff --git a/gcc/doc/cpp/macros/variadic-macros.rst b/gcc/doc/cpp/macros/variadic-macros.rst new file mode 100644 index 00000000000..21ce15da68a --- /dev/null +++ b/gcc/doc/cpp/macros/variadic-macros.rst @@ -0,0 +1,141 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: variable number of arguments, macros with variable arguments, variadic macros + +.. _variadic-macros: + +Variadic Macros +*************** + +A macro can be declared to accept a variable number of arguments much as +a function can. The syntax for defining the macro is similar to that of +a function. Here is an example: + +.. code-block:: c++ + + #define eprintf(...) fprintf (stderr, __VA_ARGS__) + +This kind of macro is called :dfn:`variadic`. When the macro is invoked, +all the tokens in its argument list after the last named argument (this +macro has none), including any commas, become the :dfn:`variable +argument`. This sequence of tokens replaces the identifier +``__VA_ARGS__`` in the macro body wherever it appears. Thus, we +have this expansion: + +.. code-block:: + + eprintf ("%s:%d: ", input_file, lineno) + → fprintf (stderr, "%s:%d: ", input_file, lineno) + +The variable argument is completely macro-expanded before it is inserted +into the macro expansion, just like an ordinary argument. You may use +the :samp:`#` and :samp:`##` operators to stringize the variable argument +or to paste its leading or trailing token with another token. (But see +below for an important special case for :samp:`##`.) + +If your macro is complicated, you may want a more descriptive name for +the variable argument than ``__VA_ARGS__``. CPP permits +this, as an extension. You may write an argument name immediately +before the :samp:`...`; that name is used for the variable argument. +The ``eprintf`` macro above could be written + +.. code-block:: c++ + + #define eprintf(args...) fprintf (stderr, args) + +using this extension. You cannot use ``__VA_ARGS__`` and this +extension in the same macro. + +You can have named arguments as well as variable arguments in a variadic +macro. We could define ``eprintf`` like this, instead: + +.. code-block:: c++ + + #define eprintf(format, ...) fprintf (stderr, format, __VA_ARGS__) + +This formulation looks more descriptive, but historically it was less +flexible: you had to supply at least one argument after the format +string. In standard C, you could not omit the comma separating the +named argument from the variable arguments. (Note that this +restriction has been lifted in C++20, and never existed in GNU C; see +below.) + +Furthermore, if you left the variable argument empty, you would have +gotten a syntax error, because there would have been an extra comma +after the format string. + +.. code-block:: + + eprintf("success!\n", ); + → fprintf(stderr, "success!\n", ); + +This has been fixed in C++20, and GNU CPP also has a pair of +extensions which deal with this problem. + +First, in GNU CPP, and in C++ beginning in C++20, you are allowed to +leave the variable argument out entirely: + +.. code-block:: + + eprintf ("success!\n") + → fprintf(stderr, "success!\n", ); + +Second, C++20 introduces the ``__VA_OPT__`` function macro. +This macro may only appear in the definition of a variadic macro. If +the variable argument has any tokens, then a ``__VA_OPT__`` +invocation expands to its argument; but if the variable argument does +not have any tokens, the ``__VA_OPT__`` expands to nothing: + +.. code-block:: c++ + + #define eprintf(format, ...) \ + fprintf (stderr, format __VA_OPT__(,) __VA_ARGS__) + +``__VA_OPT__`` is also available in GNU C and GNU C++. + +Historically, GNU CPP has also had another extension to handle the +trailing comma: the :samp:`##` token paste operator has a special +meaning when placed between a comma and a variable argument. Despite +the introduction of ``__VA_OPT__``, this extension remains +supported in GNU CPP, for backward compatibility. If you write + +.. code-block:: c++ + + #define eprintf(format, ...) fprintf (stderr, format, ##__VA_ARGS__) + +and the variable argument is left out when the ``eprintf`` macro is +used, then the comma before the :samp:`##` will be deleted. This does +*not* happen if you pass an empty argument, nor does it happen if +the token preceding :samp:`##` is anything other than a comma. + +.. code-block:: + + eprintf ("success!\n") + → fprintf(stderr, "success!\n"); + +The above explanation is ambiguous about the case where the only macro +parameter is a variable arguments parameter, as it is meaningless to +try to distinguish whether no argument at all is an empty argument or +a missing argument. +CPP retains the comma when conforming to a specific C +standard. Otherwise the comma is dropped as an extension to the standard. + +The C standard +mandates that the only place the identifier ``__VA_ARGS__`` +can appear is in the replacement list of a variadic macro. It may not +be used as a macro name, macro argument name, or within a different type +of macro. It may also be forbidden in open text; the standard is +ambiguous. We recommend you avoid using it except for its defined +purpose. + +Likewise, C++ forbids ``__VA_OPT__`` anywhere outside the +replacement list of a variadic macro. + +Variadic macros became a standard part of the C language with C99. +GNU CPP previously supported them +with a named variable argument +(:samp:`args...`, not :samp:`...` and ``__VA_ARGS__``), which +is still supported for backward compatibility. \ No newline at end of file diff --git a/gcc/doc/cpp/obsolete-features.rst b/gcc/doc/cpp/obsolete-features.rst new file mode 100644 index 00000000000..229c0332c13 --- /dev/null +++ b/gcc/doc/cpp/obsolete-features.rst @@ -0,0 +1,98 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _obsolete-features: + +Obsolete Features +***************** + +CPP has some features which are present mainly for compatibility with +older programs. We discourage their use in new code. In some cases, +we plan to remove the feature in a future version of GCC. + +.. index:: assertions + +Assertions +^^^^^^^^^^ + +:dfn:`Assertions` are a deprecated alternative to macros in writing +conditionals to test what sort of computer or system the compiled +program will run on. Assertions are usually predefined, but you can +define them with preprocessing directives or command-line options. + +Assertions were intended to provide a more systematic way to describe +the compiler's target system and we added them for compatibility with +existing compilers. In practice they are just as unpredictable as the +system-specific predefined macros. In addition, they are not part of +any standard, and only a few compilers support them. +Therefore, the use of assertions is **less** portable than the use +of system-specific predefined macros. We recommend you do not use them at +all. + +.. index:: predicates + +An assertion looks like this: + +.. code-block:: c++ + + #predicate (answer) + +:samp:`{predicate}` must be a single identifier. :samp:`{answer}` can be any +sequence of tokens; all characters are significant except for leading +and trailing whitespace, and differences in internal whitespace +sequences are ignored. (This is similar to the rules governing macro +redefinition.) Thus, ``(x + y)`` is different from ``(x+y)`` but +equivalent to ``( x + y )``. Parentheses do not nest inside an +answer. + +.. index:: testing predicates + +To test an assertion, you write it in an :samp:`#if`. For example, this +conditional succeeds if either ``vax`` or ``ns16000`` has been +asserted as an answer for ``machine``. + +.. code-block:: c++ + + #if #machine (vax) || #machine (ns16000) + +You can test whether *any* answer is asserted for a predicate by +omitting the answer in the conditional: + +.. code-block:: c++ + + #if #machine + +.. index:: #assert + +Assertions are made with the :samp:`#assert` directive. Its sole +argument is the assertion to make, without the leading :samp:`#` that +identifies assertions in conditionals. + +.. code-block:: c++ + + #assert predicate (answer) + +You may make several assertions with the same predicate and different +answers. Subsequent assertions do not override previous ones for the +same predicate. All the answers for any given predicate are +simultaneously true. + +.. index:: assertions, canceling, #unassert + +Assertions can be canceled with the :samp:`#unassert` directive. It +has the same syntax as :samp:`#assert`. In that form it cancels only the +answer which was specified on the :samp:`#unassert` line; other answers +for that predicate remain true. You can cancel an entire predicate by +leaving out the answer: + +.. code-block:: c++ + + #unassert predicate + +In either form, if no such assertion has been made, :samp:`#unassert` has +no effect. + +You can also make or cancel assertions using command-line options. +See :ref:`invocation`. \ No newline at end of file diff --git a/gcc/doc/cpp/other-directives.rst b/gcc/doc/cpp/other-directives.rst new file mode 100644 index 00000000000..370523a487c --- /dev/null +++ b/gcc/doc/cpp/other-directives.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: #ident, #sccs + +.. _other-directives: + +Other Directives +---------------- + +The :samp:`#ident` directive takes one argument, a string constant. On +some systems, that string constant is copied into a special segment of +the object file. On other systems, the directive is ignored. The +:samp:`#sccs` directive is a synonym for :samp:`#ident`. + +These directives are not part of the C standard, but they are not +official GNU extensions either. What historical information we have +been able to find, suggests they originated with System V. + +.. index:: null directive + +The :dfn:`null directive` consists of a :samp:`#` followed by a newline, +with only whitespace (including comments) in between. A null directive +is understood as a preprocessing directive but has no effect on the +preprocessor output. The primary significance of the existence of the +null directive is that an input line consisting of just a :samp:`#` will +produce no output, rather than a line of output containing just a +:samp:`#`. Supposedly some old C programs contain such lines. \ No newline at end of file diff --git a/gcc/doc/cpp/overview.rst b/gcc/doc/cpp/overview.rst new file mode 100644 index 00000000000..f7054195ab8 --- /dev/null +++ b/gcc/doc/cpp/overview.rst @@ -0,0 +1,67 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _top: + +.. _overview: + +Overview +-------- + +The C preprocessor, often known as :dfn:`cpp`, is a :dfn:`macro processor` +that is used automatically by the C compiler to transform your program +before compilation. It is called a macro processor because it allows +you to define :dfn:`macros`, which are brief abbreviations for longer +constructs. + +The C preprocessor is intended to be used only with C, C++, and +Objective-C source code. In the past, it has been abused as a general +text processor. It will choke on input which does not obey C's lexical +rules. For example, apostrophes will be interpreted as the beginning of +character constants, and cause errors. Also, you cannot rely on it +preserving characteristics of the input which are not significant to +C-family languages. If a Makefile is preprocessed, all the hard tabs +will be removed, and the Makefile will not work. + +Having said that, you can often get away with using cpp on things which +are not C. Other Algol-ish programming languages are often safe +(Ada, etc.) So is assembly, with caution. :option:`-traditional-cpp` +mode preserves more white space, and is otherwise more permissive. Many +of the problems can be avoided by writing C or C++ style comments +instead of native language comments, and keeping macros simple. + +Wherever possible, you should use a preprocessor geared to the language +you are writing in. Modern versions of the GNU assembler have macro +facilities. Most high level programming languages have their own +conditional compilation and inclusion mechanism. If all else fails, +try a true general text processor, such as GNU M4. + +C preprocessors vary in some details. This manual discusses the GNU C +preprocessor, which provides a small superset of the features of ISO +Standard C. In its default mode, the GNU C preprocessor does not do a +few things required by the standard. These are features which are +rarely, if ever, used, and may cause surprising changes to the meaning +of a program which does not expect them. To get strict ISO Standard C, +you should use the :option:`-std=c90`, :option:`-std=c99`, +:option:`-std=c11` or :option:`-std=c17` options, depending +on which version of the standard you want. To get all the mandatory +diagnostics, you must also use :option:`-pedantic`. See :ref:`invocation`. + +This manual describes the behavior of the ISO preprocessor. To +minimize gratuitous differences, where the ISO preprocessor's +behavior does not conflict with traditional semantics, the +traditional preprocessor should behave the same way. The various +differences that do exist are detailed in the section :ref:`traditional-mode`. + +For clarity, unless noted otherwise, references to :samp:`CPP` in this +manual refer to GNU CPP. + +.. toctree:: + :maxdepth: 2 + + character-sets + initial-processing + tokenization + the-preprocessing-language \ No newline at end of file diff --git a/gcc/doc/cpp/pragmas.rst b/gcc/doc/cpp/pragmas.rst new file mode 100644 index 00000000000..062b9c4165b --- /dev/null +++ b/gcc/doc/cpp/pragmas.rst @@ -0,0 +1,121 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: pragma directive + +.. _pragmas: + +Pragmas +------- + +The :samp:`#pragma` directive is the method specified by the C standard +for providing additional information to the compiler, beyond what is +conveyed in the language itself. The forms of this directive +(commonly known as :dfn:`pragmas`) specified by C standard are prefixed with +``STDC``. A C compiler is free to attach any meaning it likes to other +pragmas. Most GNU-defined, supported pragmas have been given a +``GCC`` prefix. + +.. index:: _Pragma + +C99 introduced the ``_Pragma`` operator. This feature addresses a +major problem with :samp:`#pragma`: being a directive, it cannot be +produced as the result of macro expansion. ``_Pragma`` is an +operator, much like ``sizeof`` or ``defined``, and can be embedded +in a macro. + +Its syntax is ``_Pragma (string-literal)``, where +:samp:`{string-literal}` can be either a normal or wide-character string +literal. It is destringized, by replacing all :samp:`\\\\` with a single +:samp:`\\` and all :samp:`\\"` with a :samp:`"`. The result is then +processed as if it had appeared as the right hand side of a +:samp:`#pragma` directive. For example, + +.. code-block:: c++ + + _Pragma ("GCC dependency \"parse.y\"") + +has the same effect as ``#pragma GCC dependency "parse.y"``. The +same effect could be achieved using macros, for example + +.. code-block:: c++ + + #define DO_PRAGMA(x) _Pragma (#x) + DO_PRAGMA (GCC dependency "parse.y") + +The standard is unclear on where a ``_Pragma`` operator can appear. +The preprocessor does not accept it within a preprocessing conditional +directive like :samp:`#if`. To be safe, you are probably best keeping it +out of directives other than :samp:`#define`, and putting it on a line of +its own. + +This manual documents the pragmas which are meaningful to the +preprocessor itself. Other pragmas are meaningful to the C or C++ +compilers. They are documented in the GCC manual. + +GCC plugins may provide their own pragmas. + +``#pragma GCC dependency`` + ``#pragma GCC dependency`` allows you to check the relative dates of + the current file and another file. If the other file is more recent than + the current file, a warning is issued. This is useful if the current + file is derived from the other file, and should be regenerated. The + other file is searched for using the normal include search path. + Optional trailing text can be used to give more information in the + warning message. + + .. code-block:: c++ + + #pragma GCC dependency "parse.y" + #pragma GCC dependency "/usr/include/time.h" rerun fixincludes + +``#pragma GCC poison`` + Sometimes, there is an identifier that you want to remove completely + from your program, and make sure that it never creeps back in. To + enforce this, you can :dfn:`poison` the identifier with this pragma. + ``#pragma GCC poison`` is followed by a list of identifiers to + poison. If any of those identifiers appears anywhere in the source + after the directive, it is a hard error. For example, + + .. code-block:: c++ + + #pragma GCC poison printf sprintf fprintf + sprintf(some_string, "hello"); + + will produce an error. + + If a poisoned identifier appears as part of the expansion of a macro + which was defined before the identifier was poisoned, it will *not* + cause an error. This lets you poison an identifier without worrying + about system headers defining macros that use it. + + For example, + + .. code-block:: c++ + + #define strrchr rindex + #pragma GCC poison rindex + strrchr(some_string, 'h'); + + will not produce an error. + +``#pragma GCC system_header`` + This pragma takes no arguments. It causes the rest of the code in the + current file to be treated as if it came from a system header. + See :ref:`system-headers`. + +``#pragma GCC warning``, ``#pragma GCC error`` + ``#pragma GCC warning "message"`` causes the preprocessor to issue + a warning diagnostic with the text :samp:`message`. The message + contained in the pragma must be a single string literal. Similarly, + ``#pragma GCC error "message"`` issues an error message. Unlike + the :samp:`#warning` and :samp:`#error` directives, these pragmas can be + embedded in preprocessor macros using :samp:`_Pragma`. + +``#pragma once`` + If ``#pragma once`` is seen when scanning a header file, that + file will never be read again, no matter what. It is a less-portable + alternative to using :samp:`#ifndef` to guard the contents of header files + against multiple inclusions. \ No newline at end of file diff --git a/gcc/doc/cpp/preprocessor-output.rst b/gcc/doc/cpp/preprocessor-output.rst new file mode 100644 index 00000000000..1b9c1f1bde1 --- /dev/null +++ b/gcc/doc/cpp/preprocessor-output.rst @@ -0,0 +1,86 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _preprocessor-output: + +Preprocessor Output +------------------- + +When the C preprocessor is used with the C, C++, or Objective-C +compilers, it is integrated into the compiler and communicates a stream +of binary tokens directly to the compiler's parser. However, it can +also be used in the more conventional standalone mode, where it produces +textual output. + +.. todo:: Document the library interface. + +.. index:: output format + +The output from the C preprocessor looks much like the input, except +that all preprocessing directive lines have been replaced with blank +lines and all comments with spaces. Long runs of blank lines are +discarded. + +The ISO standard specifies that it is implementation defined whether a +preprocessor preserves whitespace between tokens, or replaces it with +e.g. a single space. In GNU CPP, whitespace between tokens is collapsed +to become a single space, with the exception that the first token on a +non-directive line is preceded with sufficient spaces that it appears in +the same column in the preprocessed output that it appeared in the +original source file. This is so the output is easy to read. +CPP does not insert any +whitespace where there was none in the original source, except where +necessary to prevent an accidental token paste. + +.. index:: linemarkers + +Source file name and line number information is conveyed by lines +of the form + +.. code-block:: c++ + + # linenum filename flags + +These are called :dfn:`linemarkers`. They are inserted as needed into +the output (but never within a string or character constant). They mean +that the following line originated in file :samp:`{filename}` at line +:samp:`{linenum}`. :samp:`{filename}` will never contain any non-printing +characters; they are replaced with octal escape sequences. + +After the file name comes zero or more flags, which are :samp:`1`, +:samp:`2`, :samp:`3`, or :samp:`4`. If there are multiple flags, spaces +separate them. Here is what the flags mean: + +:samp:`1` + This indicates the start of a new file. + +:samp:`2` + This indicates returning to a file (after having included another file). + +:samp:`3` + This indicates that the following text comes from a system header file, + so certain warnings should be suppressed. + +:samp:`4` + This indicates that the following text should be treated as being + wrapped in an implicit ``extern "C"`` block. + + .. maybe cross reference SYSTEM_IMPLICIT_EXTERN_C + +As an extension, the preprocessor accepts linemarkers in non-assembler +input files. They are treated like the corresponding :samp:`#line` +directive, (see :ref:`line-control`), except that trailing flags are +permitted, and are interpreted with the meanings described above. If +multiple flags are given, they must be in ascending order. + +Some directives may be duplicated in the output of the preprocessor. +These are :samp:`#ident` (always), :samp:`#pragma` (only if the +preprocessor does not handle the pragma itself), and :samp:`#define` and +:samp:`#undef` (with certain debugging options). If this happens, the +:samp:`#` of the directive will always be in the first column, and there +will be no space between the :samp:`#` and the directive name. If macro +expansion happens to generate tokens which might be mistaken for a +duplicated directive, a space will be inserted between the :samp:`#` and +the directive name. \ No newline at end of file diff --git a/gcc/doc/cpp/the-preprocessing-language.rst b/gcc/doc/cpp/the-preprocessing-language.rst new file mode 100644 index 00000000000..f95e92465b9 --- /dev/null +++ b/gcc/doc/cpp/the-preprocessing-language.rst @@ -0,0 +1,69 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: directives, preprocessing directives, directive line, directive name + +.. _the-preprocessing-language: + +The preprocessing language +************************** + +After tokenization, the stream of tokens may simply be passed straight +to the compiler's parser. However, if it contains any operations in the +:dfn:`preprocessing language`, it will be transformed first. This stage +corresponds roughly to the standard's 'translation phase 4' and is +what most people think of as the preprocessor's job. + +The preprocessing language consists of :dfn:`directives` to be executed +and :dfn:`macros` to be expanded. Its primary capabilities are: + +* Inclusion of header files. These are files of declarations that can be + substituted into your program. + +* Macro expansion. You can define :dfn:`macros`, which are abbreviations + for arbitrary fragments of C code. The preprocessor will replace the + macros with their definitions throughout the program. Some macros are + automatically defined for you. + +* Conditional compilation. You can include or exclude parts of the + program according to various conditions. + +* Line control. If you use a program to combine or rearrange source files + into an intermediate file which is then compiled, you can use line + control to inform the compiler where each source line originally came + from. + +* Diagnostics. You can detect problems at compile time and issue errors + or warnings. + +There are a few more, less useful, features. + +Except for expansion of predefined macros, all these operations are +triggered with :dfn:`preprocessing directives`. Preprocessing directives +are lines in your program that start with :samp:`#`. Whitespace is +allowed before and after the :samp:`#`. The :samp:`#` is followed by an +identifier, the :dfn:`directive name`. It specifies the operation to +perform. Directives are commonly referred to as :samp:`#{name}` +where :samp:`{name}` is the directive name. For example, :samp:`#define` is +the directive that defines a macro. + +The :samp:`#` which begins a directive cannot come from a macro +expansion. Also, the directive name is not macro expanded. Thus, if +``foo`` is defined as a macro expanding to ``define``, that does +not make :samp:`#foo` a valid preprocessing directive. + +The set of valid directive names is fixed. Programs cannot define new +preprocessing directives. + +Some directives require arguments; these make up the rest of the +directive line and must be separated from the directive name by +whitespace. For example, :samp:`#define` must be followed by a macro +name and the intended expansion of the macro. + +A preprocessing directive cannot cover more than one line. The line +may, however, be continued with backslash-newline, or by a block comment +which extends past the end of the line. In either case, when the +directive is processed, the continuations have already been merged with +the first line to make one long line. \ No newline at end of file diff --git a/gcc/doc/cpp/tokenization.rst b/gcc/doc/cpp/tokenization.rst new file mode 100644 index 00000000000..34f02c9c2f7 --- /dev/null +++ b/gcc/doc/cpp/tokenization.rst @@ -0,0 +1,168 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: tokens, preprocessing tokens + +.. _tokenization: + +Tokenization +************ + +After the textual transformations are finished, the input file is +converted into a sequence of :dfn:`preprocessing tokens`. These mostly +correspond to the syntactic tokens used by the C compiler, but there are +a few differences. White space separates tokens; it is not itself a +token of any kind. Tokens do not have to be separated by white space, +but it is often necessary to avoid ambiguities. + +When faced with a sequence of characters that has more than one possible +tokenization, the preprocessor is greedy. It always makes each token, +starting from the left, as big as possible before moving on to the next +token. For instance, ``a+++++b`` is interpreted as +``a ++ ++ + b``, not as ``a ++ + ++ b``, even though the +latter tokenization could be part of a valid C program and the former +could not. + +Once the input file is broken into tokens, the token boundaries never +change, except when the :samp:`##` preprocessing operator is used to paste +tokens together. See :ref:`concatenation`. For example, + +.. code-block:: + + #define foo() bar + foo()baz + → bar baz + not + → barbaz + +The compiler does not re-tokenize the preprocessor's output. Each +preprocessing token becomes one compiler token. + +.. index:: identifiers + +Preprocessing tokens fall into five broad classes: identifiers, +preprocessing numbers, string literals, punctuators, and other. An +:dfn:`identifier` is the same as an identifier in C: any sequence of +letters, digits, or underscores, which begins with a letter or +underscore. Keywords of C have no significance to the preprocessor; +they are ordinary identifiers. You can define a macro whose name is a +keyword, for instance. The only identifier which can be considered a +preprocessing keyword is ``defined``. See :ref:`defined`. + +This is mostly true of other languages which use the C preprocessor. +However, a few of the keywords of C++ are significant even in the +preprocessor. See :ref:`c++-named-operators`. + +In the 1999 C standard, identifiers may contain letters which are not +part of the 'basic source character set', at the implementation's +discretion (such as accented Latin letters, Greek letters, or Chinese +ideograms). This may be done with an extended character set, or the +:samp:`\\u` and :samp:`\\U` escape sequences. + +As an extension, GCC treats :samp:`$` as a letter. This is for +compatibility with some systems, such as VMS, where :samp:`$` is commonly +used in system-defined function and object names. :samp:`$` is not a +letter in strictly conforming mode, or if you specify the :option:`-$` +option. See :ref:`invocation`. + +.. index:: numbers, preprocessing numbers + +A :dfn:`preprocessing number` has a rather bizarre definition. The +category includes all the normal integer and floating point constants +one expects of C, but also a number of other things one might not +initially recognize as a number. Formally, preprocessing numbers begin +with an optional period, a required decimal digit, and then continue +with any sequence of letters, digits, underscores, periods, and +exponents. Exponents are the two-character sequences :samp:`e+`, +:samp:`e-`, :samp:`E+`, :samp:`E-`, :samp:`p+`, :samp:`p-`, :samp:`P+`, and +:samp:`P-`. (The exponents that begin with :samp:`p` or :samp:`P` are +used for hexadecimal floating-point constants.) + +The purpose of this unusual definition is to isolate the preprocessor +from the full complexity of numeric constants. It does not have to +distinguish between lexically valid and invalid floating-point numbers, +which is complicated. The definition also permits you to split an +identifier at any position and get exactly two tokens, which can then be +pasted back together with the :samp:`##` operator. + +It's possible for preprocessing numbers to cause programs to be +misinterpreted. For example, ``0xE+12`` is a preprocessing number +which does not translate to any valid numeric constant, therefore a +syntax error. It does not mean ``0xE + 12``, which is what you +might have intended. + +.. index:: string literals, string constants, character constants, header file names + +.. the @: prevents makeinfo from turning '' into ". + +:dfn:`String literals` are string constants, character constants, and +header file names (the argument of :samp:`#include`) [#f1]_. + +String constants and character +constants are straightforward: ``"..."`` or ``'...'``. In +either case embedded quotes should be escaped with a backslash: +``'\''`` is the character constant for :samp:`'`. There is no limit on +the length of a character constant, but the value of a character +constant that contains more than one character is +implementation-defined. See :ref:`implementation-details`. + +Header file names either look like string constants, ``"..."``, or are +written with angle brackets instead, ``<...>``. In either case, +backslash is an ordinary character. There is no way to escape the +closing quote or angle bracket. The preprocessor looks for the header +file in different places depending on which form you use. See :ref:`include-operation`. + +No string literal may extend past the end of a line. You may use continued +lines instead, or string constant concatenation. + +.. index:: punctuators, digraphs, alternative tokens + +:dfn:`Punctuators` are all the usual bits of punctuation which are +meaningful to C and C++. All but three of the punctuation characters in +ASCII are C punctuators. The exceptions are :samp:`@`, :samp:`$`, and +:samp:`\``. In addition, all the two- and three-character operators are +punctuators. There are also six :dfn:`digraphs`, which the C++ standard +calls :dfn:`alternative tokens`, which are merely alternate ways to spell +other punctuators. This is a second attempt to work around missing +punctuation in obsolete systems. It has no negative side effects, +unlike trigraphs, but does not cover as much ground. The digraphs and +their corresponding normal punctuators are: + +.. code-block:: + + Digraph: <% %> <: :> %: %:%: + Punctuator: { } [ ] # ## + +.. index:: other tokens + +Any other single byte is considered 'other' and passed on to the +preprocessor's output unchanged. The C compiler will almost certainly +reject source code containing 'other' tokens. In ASCII, the only +'other' characters are :samp:`@`, :samp:`$`, :samp:`\``, and control +characters other than NUL (all bits zero). (Note that :samp:`$` is +normally considered a letter.) All bytes with the high bit set +(numeric range 0x7F--0xFF) that were not succesfully interpreted as +part of an extended character in the input encoding are also 'other' +in the present implementation. + +NUL is a special case because of the high probability that its +appearance is accidental, and because it may be invisible to the user +(many terminals do not display NUL at all). Within comments, NULs are +silently ignored, just as any other character would be. In running +text, NUL is considered white space. For example, these two directives +have the same meaning. + +.. code-block:: c++ + + #define X^@1 + #define X 1 + +(where :samp:`^@` is ASCII NUL). Within string or character constants, +NULs are preserved. In the latter two cases the preprocessor emits a +warning message. + +.. [#f1] The C + standard uses the term :dfn:`string literal` to refer only to what we are + calling :dfn:`string constants`. \ No newline at end of file diff --git a/gcc/doc/cpp/traditional-lexical-analysis.rst b/gcc/doc/cpp/traditional-lexical-analysis.rst new file mode 100644 index 00000000000..77db3d95a54 --- /dev/null +++ b/gcc/doc/cpp/traditional-lexical-analysis.rst @@ -0,0 +1,74 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _traditional-lexical-analysis: + +Traditional lexical analysis +**************************** + +The traditional preprocessor does not decompose its input into tokens +the same way a standards-conforming preprocessor does. The input is +simply treated as a stream of text with minimal internal form. + +This implementation does not treat trigraphs (see :ref:`trigraphs`) +specially since they were an invention of the standards committee. It +handles arbitrarily-positioned escaped newlines properly and splices +the lines as you would expect; many traditional preprocessors did not +do this. + +The form of horizontal whitespace in the input file is preserved in +the output. In particular, hard tabs remain hard tabs. This can be +useful if, for example, you are preprocessing a Makefile. + +Traditional CPP only recognizes C-style block comments, and treats the +:samp:`/*` sequence as introducing a comment only if it lies outside +quoted text. Quoted text is introduced by the usual single and double +quotes, and also by an initial :samp:`<` in a ``#include`` +directive. + +Traditionally, comments are completely removed and are not replaced +with a space. Since a traditional compiler does its own tokenization +of the output of the preprocessor, this means that comments can +effectively be used as token paste operators. However, comments +behave like separators for text handled by the preprocessor itself, +since it doesn't re-lex its input. For example, in + +.. code-block:: c++ + + #if foo/**/bar + +:samp:`foo` and :samp:`bar` are distinct identifiers and expanded +separately if they happen to be macros. In other words, this +directive is equivalent to + +.. code-block:: c++ + + #if foo bar + +rather than + +.. code-block:: c++ + + #if foobar + +Generally speaking, in traditional mode an opening quote need not have +a matching closing quote. In particular, a macro may be defined with +replacement text that contains an unmatched quote. Of course, if you +attempt to compile preprocessed output containing an unmatched quote +you will get a syntax error. + +However, all preprocessing directives other than ``#define`` +require matching quotes. For example: + +.. code-block:: c++ + + #define m This macro's fine and has an unmatched quote + "/* This is not a comment. */ + /* This is a comment. The following #include directive + is ill-formed. */ + #include `` directory chain. + +Files included with the ```` syntax start the lookup directly +in the second half of this chain. However, files included with the +``"foo.h"`` syntax start at the beginning of the chain, but with one +extra directory prepended. This is the directory of the current file; +the one containing the ``#include`` directive. Prepending this +directory on a per-file basis is handled by the function +``search_from``. + +Note that a header included with a directory component, such as +``#include "mydir/foo.h"`` and opened as +:samp:`/usr/local/include/mydir/foo.h`, will have the complete path minus +the basename :samp:`foo.h` as the current directory. + +Enough information is stored in the splay tree that CPP can immediately +tell whether it can skip the header file because of the multiple include +optimization, whether the file didn't exist or couldn't be opened for +some reason, or whether the header was flagged not to be re-used, as it +is with the obsolete ``#import`` directive. + +For the benefit of MS-DOS filesystems with an 8.3 filename limitation, +CPP offers the ability to treat various include file names as aliases +for the real header files with shorter names. The map from one to the +other is found in a special file called :samp:`header.gcc`, stored in the +command line (or system) include directories to which the mapping +applies. This may be higher up the directory tree than the full path to +the file minus the base name. \ No newline at end of file diff --git a/gcc/doc/cppinternals/index.rst b/gcc/doc/cppinternals/index.rst new file mode 100644 index 00000000000..0d20aa7930c --- /dev/null +++ b/gcc/doc/cppinternals/index.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +The GNU C Preprocessor Internals +================================ + +.. only:: html + + Contents: + +.. toctree:: + + copyright + cpplib + cppinternals + multiple-include-optimization + files + + indices-and-tables \ No newline at end of file diff --git a/gcc/doc/cppinternals/indices-and-tables.rst b/gcc/doc/cppinternals/indices-and-tables.rst new file mode 100644 index 00000000000..6c215a391d9 --- /dev/null +++ b/gcc/doc/cppinternals/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/gcc/doc/cppinternals/internal-representation-of-macros.rst b/gcc/doc/cppinternals/internal-representation-of-macros.rst new file mode 100644 index 00000000000..640e76b6eb8 --- /dev/null +++ b/gcc/doc/cppinternals/internal-representation-of-macros.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: macro representation (internal) + +Internal representation of macros +********************************* + +The preprocessor stores macro expansions in tokenized form. This +saves repeated lexing passes during expansion, at the cost of a small +increase in memory consumption on average. The tokens are stored +contiguously in memory, so a pointer to the first one and a token +count is all you need to get the replacement list of a macro. + +If the macro is a function-like macro the preprocessor also stores its +parameters, in the form of an ordered list of pointers to the hash +table entry of each parameter's identifier. Further, in the macro's +stored expansion each occurrence of a parameter is replaced with a +special token of type ``CPP_MACRO_ARG``. Each such token holds the +index of the parameter it represents in the parameter list, which +allows rapid replacement of parameters with their arguments during +expansion. Despite this optimization it is still necessary to store +the original parameters to the macro, both for dumping with e.g., +:option:`-dD`, and to warn about non-trivial macro redefinitions when +the parameter names have changed. \ No newline at end of file diff --git a/gcc/doc/cppinternals/just-which-line-number-anyway.rst b/gcc/doc/cppinternals/just-which-line-number-anyway.rst new file mode 100644 index 00000000000..df0ea219629 --- /dev/null +++ b/gcc/doc/cppinternals/just-which-line-number-anyway.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Just which line number anyway? +****************************** + +There are three reasonable requirements a cpplib client might have for +the line number of a token passed to it: + +* The source line it was lexed on. + +* The line it is output on. This can be different to the line it was + lexed on if, for example, there are intervening escaped newlines or + C-style comments. For example: + + .. code-block:: + + foo /* A long + comment */ bar \ + baz + ⇒ + foo bar baz + +* If the token results from a macro expansion, the line of the macro name, + or possibly the line of the closing parenthesis in the case of + function-like macro expansion. + +The ``cpp_token`` structure contains ``line`` and ``col`` +members. The lexer fills these in with the line and column of the first +character of the token. Consequently, but maybe unexpectedly, a token +from the replacement list of a macro expansion carries the location of +the token within the ``#define`` directive, because cpplib expands a +macro by returning pointers to the tokens in its replacement list. The +current implementation of cpplib assigns tokens created from built-in +macros and the :samp:`#` and :samp:`##` operators the location of the most +recently lexed token. This is a because they are allocated from the +lexer's token runs, and because of the way the diagnostic routines infer +the appropriate location to report. + +The diagnostic routines in cpplib display the location of the most +recently *lexed* token, unless they are passed a specific line and +column to report. For diagnostics regarding tokens that arise from +macro expansions, it might also be helpful for the user to see the +original location in the macro definition that the token came from. +Since that is exactly the information each token carries, such an +enhancement could be made relatively easily in future. + +The stand-alone preprocessor faces a similar problem when determining +the correct line to output the token on: the position attached to a +token is fairly useless if the token came from a macro expansion. All +tokens on a logical line should be output on its first physical line, so +the token's reported location is also wrong if it is part of a physical +line other than the first. + +To solve these issues, cpplib provides a callback that is generated +whenever it lexes a preprocessing token that starts a new logical line +other than a directive. It passes this token (which may be a +``CPP_EOF`` token indicating the end of the translation unit) to the +callback routine, which can then use the line and column of this token +to produce correct output. \ No newline at end of file diff --git a/gcc/doc/cppinternals/lexing-a-line.rst b/gcc/doc/cppinternals/lexing-a-line.rst new file mode 100644 index 00000000000..35638b9279a --- /dev/null +++ b/gcc/doc/cppinternals/lexing-a-line.rst @@ -0,0 +1,91 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: token run + +.. _lexing-a-line: + +Lexing a line +************* + +When the preprocessor was changed to return pointers to tokens, one +feature I wanted was some sort of guarantee regarding how long a +returned pointer remains valid. This is important to the stand-alone +preprocessor, the future direction of the C family front ends, and even +to cpplib itself internally. + +Occasionally the preprocessor wants to be able to peek ahead in the +token stream. For example, after the name of a function-like macro, it +wants to check the next token to see if it is an opening parenthesis. +Another example is that, after reading the first few tokens of a +``#pragma`` directive and not recognizing it as a registered pragma, +it wants to backtrack and allow the user-defined handler for unknown +pragmas to access the full ``#pragma`` token stream. The stand-alone +preprocessor wants to be able to test the current token with the +previous one to see if a space needs to be inserted to preserve their +separate tokenization upon re-lexing (paste avoidance), so it needs to +be sure the pointer to the previous token is still valid. The +recursive-descent C++ parser wants to be able to perform tentative +parsing arbitrarily far ahead in the token stream, and then to be able +to jump back to a prior position in that stream if necessary. + +The rule I chose, which is fairly natural, is to arrange that the +preprocessor lex all tokens on a line consecutively into a token buffer, +which I call a :dfn:`token run`, and when meeting an unescaped new line +(newlines within comments do not count either), to start lexing back at +the beginning of the run. Note that we do *not* lex a line of +tokens at once; if we did that ``parse_identifier`` would not have +state flags available to warn about invalid identifiers (see :ref:`Invalid identifiers `). + +In other words, accessing tokens that appeared earlier in the current +line is valid, but since each logical line overwrites the tokens of the +previous line, tokens from prior lines are unavailable. In particular, +since a directive only occupies a single logical line, this means that +the directive handlers like the ``#pragma`` handler can jump around +in the directive's tokens if necessary. + +Two issues remain: what about tokens that arise from macro expansions, +and what happens when we have a long line that overflows the token run? + +Since we promise clients that we preserve the validity of pointers that +we have already returned for tokens that appeared earlier in the line, +we cannot reallocate the run. Instead, on overflow it is expanded by +chaining a new token run on to the end of the existing one. + +The tokens forming a macro's replacement list are collected by the +``#define`` handler, and placed in storage that is only freed by +``cpp_destroy``. So if a macro is expanded in the line of tokens, +the pointers to the tokens of its expansion that are returned will always +remain valid. However, macros are a little trickier than that, since +they give rise to three sources of fresh tokens. They are the built-in +macros like ``__LINE__``, and the :samp:`#` and :samp:`##` operators +for stringizing and token pasting. I handled this by allocating +space for these tokens from the lexer's token run chain. This means +they automatically receive the same lifetime guarantees as lexed tokens, +and we don't need to concern ourselves with freeing them. + +Lexing into a line of tokens solves some of the token memory management +issues, but not all. The opening parenthesis after a function-like +macro name might lie on a different line, and the front ends definitely +want the ability to look ahead past the end of the current line. So +cpplib only moves back to the start of the token run at the end of a +line if the variable ``keep_tokens`` is zero. Line-buffering is +quite natural for the preprocessor, and as a result the only time cpplib +needs to increment this variable is whilst looking for the opening +parenthesis to, and reading the arguments of, a function-like macro. In +the near future cpplib will export an interface to increment and +decrement this variable, so that clients can share full control over the +lifetime of token pointers too. + +The routine ``_cpp_lex_token`` handles moving to new token runs, +calling ``_cpp_lex_direct`` to lex new tokens, or returning +previously-lexed tokens if we stepped back in the token stream. It also +checks each token for the ``BOL`` flag, which might indicate a +directive that needs to be handled, or require a start-of-line call-back +to be made. ``_cpp_lex_token`` also handles skipping over tokens in +failed conditional blocks, and invalidates the control macro of the +multiple-include optimization if a token was successfully lexed outside +a directive. In other words, its callers do not need to concern +themselves with such issues. \ No newline at end of file diff --git a/gcc/doc/cppinternals/lexing-a-token.rst b/gcc/doc/cppinternals/lexing-a-token.rst new file mode 100644 index 00000000000..9eff9210cf6 --- /dev/null +++ b/gcc/doc/cppinternals/lexing-a-token.rst @@ -0,0 +1,177 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Lexing a token +************** + +Lexing of an individual token is handled by ``_cpp_lex_direct`` and +its subroutines. In its current form the code is quite complicated, +with read ahead characters and such-like, since it strives to not step +back in the character stream in preparation for handling non-ASCII file +encodings. The current plan is to convert any such files to UTF-8 +before processing them. This complexity is therefore unnecessary and +will be removed, so I'll not discuss it further here. + +The job of ``_cpp_lex_direct`` is simply to lex a token. It is not +responsible for issues like directive handling, returning lookahead +tokens directly, multiple-include optimization, or conditional block +skipping. It necessarily has a minor rôle to play in memory +management of lexed lines. I discuss these issues in a separate section +(see :ref:`lexing-a-line`). + +The lexer places the token it lexes into storage pointed to by the +variable ``cur_token``, and then increments it. This variable is +important for correct diagnostic positioning. Unless a specific line +and column are passed to the diagnostic routines, they will examine the +``line`` and ``col`` values of the token just before the location +that ``cur_token`` points to, and use that location to report the +diagnostic. + +The lexer does not consider whitespace to be a token in its own right. +If whitespace (other than a new line) precedes a token, it sets the +``PREV_WHITE`` bit in the token's flags. Each token has its +``line`` and ``col`` variables set to the line and column of the +first character of the token. This line number is the line number in +the translation unit, and can be converted to a source (file, line) pair +using the line map code. + +The first token on a logical, i.e. unescaped, line has the flag +``BOL`` set for beginning-of-line. This flag is intended for +internal use, both to distinguish a :samp:`#` that begins a directive +from one that doesn't, and to generate a call-back to clients that want +to be notified about the start of every non-directive line with tokens +on it. Clients cannot reliably determine this for themselves: the first +token might be a macro, and the tokens of a macro expansion do not have +the ``BOL`` flag set. The macro expansion may even be empty, and the +next token on the line certainly won't have the ``BOL`` flag set. + +New lines are treated specially; exactly how the lexer handles them is +context-dependent. The C standard mandates that directives are +terminated by the first unescaped newline character, even if it appears +in the middle of a macro expansion. Therefore, if the state variable +``in_directive`` is set, the lexer returns a ``CPP_EOF`` token, +which is normally used to indicate end-of-file, to indicate +end-of-directive. In a directive a ``CPP_EOF`` token never means +end-of-file. Conveniently, if the caller was ``collect_args``, it +already handles ``CPP_EOF`` as if it were end-of-file, and reports an +error about an unterminated macro argument list. + +The C standard also specifies that a new line in the middle of the +arguments to a macro is treated as whitespace. This white space is +important in case the macro argument is stringized. The state variable +``parsing_args`` is nonzero when the preprocessor is collecting the +arguments to a macro call. It is set to 1 when looking for the opening +parenthesis to a function-like macro, and 2 when collecting the actual +arguments up to the closing parenthesis, since these two cases need to +be distinguished sometimes. One such time is here: the lexer sets the +``PREV_WHITE`` flag of a token if it meets a new line when +``parsing_args`` is set to 2. It doesn't set it if it meets a new +line when ``parsing_args`` is 1, since then code like + +.. code-block:: c++ + + #define foo() bar + foo + baz + +would be output with an erroneous space before :samp:`baz`: + +.. code-block:: c++ + + foo + baz + +This is a good example of the subtlety of getting token spacing correct +in the preprocessor; there are plenty of tests in the testsuite for +corner cases like this. + +The lexer is written to treat each of :samp:`\\r`, :samp:`\\n`, :samp:`\\r\\n` +and :samp:`\\n\\r` as a single new line indicator. This allows it to +transparently preprocess MS-DOS, Macintosh and Unix files without their +needing to pass through a special filter beforehand. + +We also decided to treat a backslash, either ``\`` or the trigraph +``??/``, separated from one of the above newline indicators by +non-comment whitespace only, as intending to escape the newline. It +tends to be a typing mistake, and cannot reasonably be mistaken for +anything else in any of the C-family grammars. Since handling it this +way is not strictly conforming to the ISO standard, the library issues a +warning wherever it encounters it. + +Handling newlines like this is made simpler by doing it in one place +only. The function ``handle_newline`` takes care of all newline +characters, and ``skip_escaped_newlines`` takes care of arbitrarily +long sequences of escaped newlines, deferring to ``handle_newline`` +to handle the newlines themselves. + +The most painful aspect of lexing ISO-standard C and C++ is handling +trigraphs and backlash-escaped newlines. Trigraphs are processed before +any interpretation of the meaning of a character is made, and unfortunately +there is a trigraph representation for a backslash, so it is possible for +the trigraph ``??/`` to introduce an escaped newline. + +Escaped newlines are tedious because theoretically they can occur +anywhere---between the :samp:`+` and :samp:`=` of the :samp:`+=` token, +within the characters of an identifier, and even between the :samp:`*` +and :samp:`/` that terminates a comment. Moreover, you cannot be sure +there is just one---there might be an arbitrarily long sequence of them. + +So, for example, the routine that lexes a number, ``parse_number``, +cannot assume that it can scan forwards until the first non-number +character and be done with it, because this could be the :samp:`\\` +introducing an escaped newline, or the :samp:`?` introducing the trigraph +sequence that represents the :samp:`\\` of an escaped newline. If it +encounters a :samp:`?` or :samp:`\\`, it calls ``skip_escaped_newlines`` +to skip over any potential escaped newlines before checking whether the +number has been finished. + +Similarly code in the main body of ``_cpp_lex_direct`` cannot simply +check for a :samp:`=` after a :samp:`+` character to determine whether it +has a :samp:`+=` token; it needs to be prepared for an escaped newline of +some sort. Such cases use the function ``get_effective_char``, which +returns the first character after any intervening escaped newlines. + +The lexer needs to keep track of the correct column position, including +counting tabs as specified by the :option:`-ftabstop=` option. This +should be done even within C-style comments; they can appear in the +middle of a line, and we want to report diagnostics in the correct +position for text appearing after the end of the comment. + +.. _invalid-identifiers: + +Some identifiers, such as ``__VA_ARGS__`` and poisoned identifiers, +may be invalid and require a diagnostic. However, if they appear in a +macro expansion we don't want to complain with each use of the macro. +It is therefore best to catch them during the lexing stage, in +``parse_identifier``. In both cases, whether a diagnostic is needed +or not is dependent upon the lexer's state. For example, we don't want +to issue a diagnostic for re-poisoning a poisoned identifier, or for +using ``__VA_ARGS__`` in the expansion of a variable-argument macro. +Therefore ``parse_identifier`` makes use of state flags to determine +whether a diagnostic is appropriate. Since we change state on a +per-token basis, and don't lex whole lines at a time, this is not a +problem. + +Another place where state flags are used to change behavior is whilst +lexing header names. Normally, a :samp:`<` would be lexed as a single +token. After a ``#include`` directive, though, it should be lexed as +a single token as far as the nearest :samp:`>` character. Note that we +don't allow the terminators of header names to be escaped; the first +:samp:`"` or :samp:`>` terminates the header name. + +Interpretation of some character sequences depends upon whether we are +lexing C, C++ or Objective-C, and on the revision of the standard in +force. For example, :samp:`::` is a single token in C++, but in C it is +two separate :samp:`:` tokens and almost certainly a syntax error. Such +cases are handled by ``_cpp_lex_direct`` based upon command-line +flags stored in the ``cpp_options`` structure. + +Once a token has been lexed, it leads an independent existence. The +spelling of numbers, identifiers and strings is copied to permanent +storage from the original input buffer, so a token remains valid and +correct even if its source buffer is freed with ``_cpp_pop_buffer``. +The storage holding the spellings of such tokens remains until the +client program calls cpp_destroy, probably at the end of the translation +unit. \ No newline at end of file diff --git a/gcc/doc/cppinternals/looking-for-a-function-like-macros-opening-parenthesis.rst b/gcc/doc/cppinternals/looking-for-a-function-like-macros-opening-parenthesis.rst new file mode 100644 index 00000000000..272cb4b8245 --- /dev/null +++ b/gcc/doc/cppinternals/looking-for-a-function-like-macros-opening-parenthesis.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Looking for a function-like macro's opening parenthesis +******************************************************* + +Function-like macros only expand when immediately followed by a +parenthesis. To do this cpplib needs to temporarily disable macros +and read the next token. Unfortunately, because of spacing issues +(see :ref:`token-spacing`), there can be fake padding tokens in-between, +and if the next real token is not a parenthesis cpplib needs to be +able to back up that one token as well as retain the information in +any intervening padding tokens. + +Backing up more than one token when macros are involved is not +permitted by cpplib, because in general it might involve issues like +restoring popped contexts onto the context stack, which are too hard. +Instead, searching for the parenthesis is handled by a special +function, ``funlike_invocation_p``, which remembers padding +information as it reads tokens. If the next real token is not an +opening parenthesis, it backs up that one token, and then pushes an +extra context just containing the padding information if necessary. \ No newline at end of file diff --git a/gcc/doc/cppinternals/macro-expansion-overview.rst b/gcc/doc/cppinternals/macro-expansion-overview.rst new file mode 100644 index 00000000000..ba55a6c8676 --- /dev/null +++ b/gcc/doc/cppinternals/macro-expansion-overview.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Macro expansion overview +************************ + +The preprocessor maintains a :dfn:`context stack`, implemented as a +linked list of ``cpp_context`` structures, which together represent +the macro expansion state at any one time. The ``struct +cpp_reader`` member variable ``context`` points to the current top +of this stack. The top normally holds the unexpanded replacement list +of the innermost macro under expansion, except when cpplib is about to +pre-expand an argument, in which case it holds that argument's +unexpanded tokens. + +When there are no macros under expansion, cpplib is in :dfn:`base +context`. All contexts other than the base context contain a +contiguous list of tokens delimited by a starting and ending token. +When not in base context, cpplib obtains the next token from the list +of the top context. If there are no tokens left in the list, it pops +that context off the stack, and subsequent ones if necessary, until an +unexhausted context is found or it returns to base context. In base +context, cpplib reads tokens directly from the lexer. + +If it encounters an identifier that is both a macro and enabled for +expansion, cpplib prepares to push a new context for that macro on the +stack by calling the routine ``enter_macro_context``. When this +routine returns, the new context will contain the unexpanded tokens of +the replacement list of that macro. In the case of function-like +macros, ``enter_macro_context`` also replaces any parameters in the +replacement list, stored as ``CPP_MACRO_ARG`` tokens, with the +appropriate macro argument. If the standard requires that the +parameter be replaced with its expanded argument, the argument will +have been fully macro expanded first. + +``enter_macro_context`` also handles special macros like +``__LINE__``. Although these macros expand to a single token which +cannot contain any further macros, for reasons of token spacing +(see :ref:`token-spacing`) and simplicity of implementation, cpplib +handles these special macros by pushing a context containing just that +one token. + +The final thing that ``enter_macro_context`` does before returning +is to mark the macro disabled for expansion (except for special macros +like ``__TIME__``). The macro is re-enabled when its context is +later popped from the context stack, as described above. This strict +ordering ensures that a macro is disabled whilst its expansion is +being scanned, but that it is *not* disabled whilst any arguments +to it are being expanded. \ No newline at end of file diff --git a/gcc/doc/cppinternals/marking-tokens-ineligible-for-future-expansion.rst b/gcc/doc/cppinternals/marking-tokens-ineligible-for-future-expansion.rst new file mode 100644 index 00000000000..b34aa83594a --- /dev/null +++ b/gcc/doc/cppinternals/marking-tokens-ineligible-for-future-expansion.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Marking tokens ineligible for future expansion +********************************************** + +As discussed above, cpplib needs a way of marking tokens as +unexpandable. Since the tokens cpplib handles are read-only once they +have been lexed, it instead makes a copy of the token and adds the +flag ``NO_EXPAND`` to the copy. + +For efficiency and to simplify memory management by avoiding having to +remember to free these tokens, they are allocated as temporary tokens +from the lexer's current token run (see :ref:`lexing-a-line`) using the +function ``_cpp_temp_token``. The tokens are then re-used once the +current line of tokens has been read in. + +This might sound unsafe. However, tokens runs are not re-used at the +end of a line if it happens to be in the middle of a macro argument +list, and cpplib only wants to back-up more than one lexer token in +situations where no macro expansion is involved, so the optimization +is safe. \ No newline at end of file diff --git a/gcc/doc/cppinternals/multiple-include-optimization.rst b/gcc/doc/cppinternals/multiple-include-optimization.rst new file mode 100644 index 00000000000..e710eaa8dac --- /dev/null +++ b/gcc/doc/cppinternals/multiple-include-optimization.rst @@ -0,0 +1,117 @@ +The Multiple-Include Optimization +================================= + +.. index:: guard macros, controlling macros, multiple-include optimization + +Header files are often of the form + +.. code-block:: c++ + + #ifndef FOO + #define FOO + ... + #endif + +to prevent the compiler from processing them more than once. The +preprocessor notices such header files, so that if the header file +appears in a subsequent ``#include`` directive and ``FOO`` is +defined, then it is ignored and it doesn't preprocess or even re-open +the file a second time. This is referred to as the :dfn:`multiple +include optimization`. + +Under what circumstances is such an optimization valid? If the file +were included a second time, it can only be optimized away if that +inclusion would result in no tokens to return, and no relevant +directives to process. Therefore the current implementation imposes +requirements and makes some allowances as follows: + +* There must be no tokens outside the controlling ``#if`` - ``#endif`` + pair, but whitespace and comments are permitted. + +* There must be no directives outside the controlling directive pair, but + the :dfn:`null directive` (a line containing nothing other than a single + :samp:`#` and possibly whitespace) is permitted. + +* The opening directive must be of the form + + .. code-block:: c++ + + #ifndef FOO + + or + + .. code-block:: c++ + + #if !defined FOO [equivalently, #if !defined(FOO)] + +* In the second form above, the tokens forming the ``#if`` expression + must have come directly from the source file---no macro expansion must + have been involved. This is because macro definitions can change, and + tracking whether or not a relevant change has been made is not worth the + implementation cost. + +* There can be no ``#else`` or ``#elif`` directives at the outer + conditional block level, because they would probably contain something + of interest to a subsequent pass. + +First, when pushing a new file on the buffer stack, +``_stack_include_file`` sets the controlling macro ``mi_cmacro`` to +``NULL``, and sets ``mi_valid`` to ``true``. This indicates +that the preprocessor has not yet encountered anything that would +invalidate the multiple-include optimization. As described in the next +few paragraphs, these two variables having these values effectively +indicates top-of-file. + +When about to return a token that is not part of a directive, +``_cpp_lex_token`` sets ``mi_valid`` to ``false``. This +enforces the constraint that tokens outside the controlling conditional +block invalidate the optimization. + +The ``do_if``, when appropriate, and ``do_ifndef`` directive +handlers pass the controlling macro to the function +``push_conditional``. cpplib maintains a stack of nested conditional +blocks, and after processing every opening conditional this function +pushes an ``if_stack`` structure onto the stack. In this structure +it records the controlling macro for the block, provided there is one +and we're at top-of-file (as described above). If an ``#elif`` or +``#else`` directive is encountered, the controlling macro for that +block is cleared to ``NULL``. Otherwise, it survives until the +``#endif`` closing the block, upon which ``do_endif`` sets +``mi_valid`` to true and stores the controlling macro in +``mi_cmacro``. + +``_cpp_handle_directive`` clears ``mi_valid`` when processing any +directive other than an opening conditional and the null directive. +With this, and requiring top-of-file to record a controlling macro, and +no ``#else`` or ``#elif`` for it to survive and be copied to +``mi_cmacro`` by ``do_endif``, we have enforced the absence of +directives outside the main conditional block for the optimization to be +on. + +Note that whilst we are inside the conditional block, ``mi_valid`` is +likely to be reset to ``false``, but this does not matter since +the closing ``#endif`` restores it to ``true`` if appropriate. + +Finally, since ``_cpp_lex_direct`` pops the file off the buffer stack +at ``EOF`` without returning a token, if the ``#endif`` directive +was not followed by any tokens, ``mi_valid`` is ``true`` and +``_cpp_pop_file_buffer`` remembers the controlling macro associated +with the file. Subsequent calls to ``stack_include_file`` result in +no buffer being pushed if the controlling macro is defined, effecting +the optimization. + +A quick word on how we handle the + +.. code-block:: c++ + + #if !defined FOO + +case. ``_cpp_parse_expr`` and ``parse_defined`` take steps to see +whether the three stages :samp:`!`, :samp:`defined-expression` and +:samp:`end-of-directive` occur in order in a ``#if`` expression. If +so, they return the guard macro to ``do_if`` in the variable +``mi_ind_cmacro``, and otherwise set it to ``NULL``. +``enter_macro_context`` sets ``mi_valid`` to false, so if a macro +was expanded whilst parsing any part of the expression, then the +top-of-file test in ``push_conditional`` fails and the optimization +is turned off. \ No newline at end of file diff --git a/gcc/doc/cppinternals/overview.rst b/gcc/doc/cppinternals/overview.rst new file mode 100644 index 00000000000..4459c7fd7d0 --- /dev/null +++ b/gcc/doc/cppinternals/overview.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Overview +******** + +The lexer is contained in the file :samp:`lex.cc`. It is a hand-coded +lexer, and not implemented as a state machine. It can understand C, C++ +and Objective-C source code, and has been extended to allow reasonably +successful preprocessing of assembly language. The lexer does not make +an initial pass to strip out trigraphs and escaped newlines, but handles +them as they are encountered in a single pass of the input file. It +returns preprocessing tokens individually, not a line at a time. + +It is mostly transparent to users of the library, since the library's +interface for obtaining the next token, ``cpp_get_token``, takes care +of lexing new tokens, handling directives, and expanding macros as +necessary. However, the lexer does expose some functionality so that +clients of the library can easily spell a given token, such as +``cpp_spell_token`` and ``cpp_token_len``. These functions are +useful when generating diagnostics, and for emitting the preprocessed +output. \ No newline at end of file diff --git a/gcc/doc/cppinternals/representation-of-line-numbers.rst b/gcc/doc/cppinternals/representation-of-line-numbers.rst new file mode 100644 index 00000000000..4aa99349ce9 --- /dev/null +++ b/gcc/doc/cppinternals/representation-of-line-numbers.rst @@ -0,0 +1,32 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Representation of line numbers +****************************** + +As mentioned above, cpplib stores with each token the line number that +it was lexed on. In fact, this number is not the number of the line in +the source file, but instead bears more resemblance to the number of the +line in the translation unit. + +The preprocessor maintains a monotonic increasing line count, which is +incremented at every new line character (and also at the end of any +buffer that does not end in a new line). Since a line number of zero is +useful to indicate certain special states and conditions, this variable +starts counting from one. + +This variable therefore uniquely enumerates each line in the translation +unit. With some simple infrastructure, it is straight forward to map +from this to the original source file and line number pair, saving space +whenever line number information needs to be saved. The code the +implements this mapping lies in the files :samp:`line-map.cc` and +:samp:`line-map.h`. + +Command-line macros and assertions are implemented by pushing a buffer +containing the right hand side of an equivalent ``#define`` or +``#assert`` directive. Some built-in macros are handled similarly. +Since these are all processed before the first line of the main input +file, it will typically have an assigned line closer to twenty than to +one. \ No newline at end of file diff --git a/gcc/doc/cppinternals/scanning-the-replacement-list-for-macros-to-expand.rst b/gcc/doc/cppinternals/scanning-the-replacement-list-for-macros-to-expand.rst new file mode 100644 index 00000000000..c0b12615def --- /dev/null +++ b/gcc/doc/cppinternals/scanning-the-replacement-list-for-macros-to-expand.rst @@ -0,0 +1,57 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Scanning the replacement list for macros to expand +************************************************** + +The C standard states that, after any parameters have been replaced +with their possibly-expanded arguments, the replacement list is +scanned for nested macros. Further, any identifiers in the +replacement list that are not expanded during this scan are never +again eligible for expansion in the future, if the reason they were +not expanded is that the macro in question was disabled. + +Clearly this latter condition can only apply to tokens resulting from +argument pre-expansion. Other tokens never have an opportunity to be +re-tested for expansion. It is possible for identifiers that are +function-like macros to not expand initially but to expand during a +later scan. This occurs when the identifier is the last token of an +argument (and therefore originally followed by a comma or a closing +parenthesis in its macro's argument list), and when it replaces its +parameter in the macro's replacement list, the subsequent token +happens to be an opening parenthesis (itself possibly the first token +of an argument). + +It is important to note that when cpplib reads the last token of a +given context, that context still remains on the stack. Only when +looking for the *next* token do we pop it off the stack and drop +to a lower context. This makes backing up by one token easy, but more +importantly ensures that the macro corresponding to the current +context is still disabled when we are considering the last token of +its replacement list for expansion (or indeed expanding it). As an +example, which illustrates many of the points above, consider + +.. code-block:: c++ + + #define foo(x) bar x + foo(foo) (2) + +which fully expands to :samp:`bar foo (2)`. During pre-expansion +of the argument, :samp:`foo` does not expand even though the macro is +enabled, since it has no following parenthesis [pre-expansion of an +argument only uses tokens from that argument; it cannot take tokens +from whatever follows the macro invocation]. This still leaves the +argument token :samp:`foo` eligible for future expansion. Then, when +re-scanning after argument replacement, the token :samp:`foo` is +rejected for expansion, and marked ineligible for future expansion, +since the macro is now disabled. It is disabled because the +replacement list :samp:`bar foo` of the macro is still on the context +stack. + +If instead the algorithm looked for an opening parenthesis first and +then tested whether the macro were disabled it would be subtly wrong. +In the example above, the replacement list of :samp:`foo` would be +popped in the process of finding the parenthesis, re-enabling +:samp:`foo` and expanding it a second time. \ No newline at end of file diff --git a/gcc/doc/gcc/binary-compatibility.rst b/gcc/doc/gcc/binary-compatibility.rst new file mode 100644 index 00000000000..a55423c56f5 --- /dev/null +++ b/gcc/doc/gcc/binary-compatibility.rst @@ -0,0 +1,151 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: binary compatibility, ABI, application binary interface + +.. _compatibility: + +Binary Compatibility +-------------------- + +Binary compatibility encompasses several related concepts: + +:dfn:`application binary interface (ABI)` + The set of runtime conventions followed by all of the tools that deal + with binary representations of a program, including compilers, assemblers, + linkers, and language runtime support. + Some ABIs are formal with a written specification, possibly designed + by multiple interested parties. Others are simply the way things are + actually done by a particular set of tools. + +:dfn:`ABI conformance` + A compiler conforms to an ABI if it generates code that follows all of + the specifications enumerated by that ABI. + A library conforms to an ABI if it is implemented according to that ABI. + An application conforms to an ABI if it is built using tools that conform + to that ABI and does not contain source code that specifically changes + behavior specified by the ABI. + +:dfn:`calling conventions` + Calling conventions are a subset of an ABI that specify of how arguments + are passed and function results are returned. + +:dfn:`interoperability` + Different sets of tools are interoperable if they generate files that + can be used in the same program. The set of tools includes compilers, + assemblers, linkers, libraries, header files, startup files, and debuggers. + Binaries produced by different sets of tools are not interoperable unless + they implement the same ABI. This applies to different versions of the + same tools as well as tools from different vendors. + +:dfn:`intercallability` + Whether a function in a binary built by one set of tools can call a + function in a binary built by a different set of tools is a subset + of interoperability. + +:dfn:`implementation-defined features` + Language standards include lists of implementation-defined features whose + behavior can vary from one implementation to another. Some of these + features are normally covered by a platform's ABI and others are not. + The features that are not covered by an ABI generally affect how a + program behaves, but not intercallability. + +:dfn:`compatibility` + Conformance to the same ABI and the same behavior of implementation-defined + features are both relevant for compatibility. + +The application binary interface implemented by a C or C++ compiler +affects code generation and runtime support for: + +* size and alignment of data types + +* layout of structured types + +* calling conventions + +* register usage conventions + +* interfaces for runtime arithmetic support + +* object file formats + +In addition, the application binary interface implemented by a C++ compiler +affects code generation and runtime support for: + +* name mangling + +* exception handling + +* invoking constructors and destructors + +* layout, alignment, and padding of classes + +* layout and alignment of virtual tables + +Some GCC compilation options cause the compiler to generate code that +does not conform to the platform's default ABI. Other options cause +different program behavior for implementation-defined features that are +not covered by an ABI. These options are provided for consistency with +other compilers that do not follow the platform's default ABI or the +usual behavior of implementation-defined features for the platform. +Be very careful about using such options. + +Most platforms have a well-defined ABI that covers C code, but ABIs +that cover C++ functionality are not yet common. + +Starting with GCC 3.2, GCC binary conventions for C++ are based on a +written, vendor-neutral C++ ABI that was designed to be specific to +64-bit Itanium but also includes generic specifications that apply to +any platform. +This C++ ABI is also implemented by other compiler vendors on some +platforms, notably GNU/Linux and BSD systems. +We have tried hard to provide a stable ABI that will be compatible with +future GCC releases, but it is possible that we will encounter problems +that make this difficult. Such problems could include different +interpretations of the C++ ABI by different vendors, bugs in the ABI, or +bugs in the implementation of the ABI in different compilers. +GCC's :option:`-Wabi` switch warns when G++ generates code that is +probably not compatible with the C++ ABI. + +The C++ library used with a C++ compiler includes the Standard C++ +Library, with functionality defined in the C++ Standard, plus language +runtime support. The runtime support is included in a C++ ABI, but there +is no formal ABI for the Standard C++ Library. Two implementations +of that library are interoperable if one follows the de-facto ABI of the +other and if they are both built with the same compiler, or with compilers +that conform to the same ABI for C++ compiler and runtime support. + +When G++ and another C++ compiler conform to the same C++ ABI, but the +implementations of the Standard C++ Library that they normally use do not +follow the same ABI for the Standard C++ Library, object files built with +those compilers can be used in the same program only if they use the same +C++ library. This requires specifying the location of the C++ library +header files when invoking the compiler whose usual library is not being +used. The location of GCC's C++ header files depends on how the GCC +build was configured, but can be seen by using the G++ :option:`-v` option. +With default configuration options for G++ 3.3 the compile line for a +different C++ compiler needs to include + +.. code-block:: c++ + + -Igcc_install_directory/include/c++/3.3 + +Similarly, compiling code with G++ that must use a C++ library other +than the GNU C++ library requires specifying the location of the header +files for that other library. + +The most straightforward way to link a program to use a particular +C++ library is to use a C++ driver that specifies that C++ library by +default. The :command:`g++` driver, for example, tells the linker where +to find GCC's C++ library (:samp:`libstdc++`) plus the other libraries +and startup files it needs, in the proper order. + +If a program must use a different C++ library and it's not possible +to do the final link using a C++ driver that uses that library by default, +it is necessary to tell :command:`g++` the location and name of that +library. It might also be necessary to specify different startup files +and other runtime support libraries, and to suppress the use of GCC's +support libraries with one or more of the options :option:`-nostdlib`, +:option:`-nostartfiles`, and :option:`-nodefaultlibs`. \ No newline at end of file diff --git a/gcc/doc/gcc/c++-implementation-defined-behavior.rst b/gcc/doc/gcc/c++-implementation-defined-behavior.rst new file mode 100644 index 00000000000..9cc4bcdddc1 --- /dev/null +++ b/gcc/doc/gcc/c++-implementation-defined-behavior.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: implementation-defined behavior, C++ language + +.. _c++-implementation: + +C++ Implementation-Defined Behavior +----------------------------------- + +A conforming implementation of ISO C++ is required to document its +choice of behavior in each of the areas that are designated +'implementation defined'. The following lists all such areas, +along with the section numbers from the ISO/IEC 14882:1998 and ISO/IEC +14882:2003 standards. Some areas are only implementation-defined in +one version of the standard. + +Some choices depend on the externally determined ABI for the platform +(including standard character encodings) which GCC follows; these are +listed as 'determined by ABI' below. See :ref:`compatibility`, and https://gcc.gnu.org/readings.html. Some +choices are documented in the preprocessor manual. +See :ref:`cpp:implementation-defined-behavior`. Some choices are documented in +the corresponding document for the C language. See :ref:`c-implementation`. Some choices are made by the library and operating +system (or other environment when compiling for a freestanding +environment); refer to their documentation for details. + +.. toctree:: + :maxdepth: 2 + + conditionally-supported-behavior + exception-handling \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior.rst b/gcc/doc/gcc/c-implementation-defined-behavior.rst new file mode 100644 index 00000000000..eb796dcd3f4 --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: implementation-defined behavior, C language + +.. _c-implementation: + +C Implementation-Defined Behavior +--------------------------------- + +A conforming implementation of ISO C is required to document its +choice of behavior in each of the areas that are designated +'implementation defined'. The following lists all such areas, +along with the section numbers from the ISO/IEC 9899:1990, ISO/IEC +9899:1999 and ISO/IEC 9899:2011 standards. Some areas are only +implementation-defined in one version of the standard. + +Some choices depend on the externally determined ABI for the platform +(including standard character encodings) which GCC follows; these are +listed as 'determined by ABI' below. See :ref:`compatibility`, and https://gcc.gnu.org/readings.html. Some +choices are documented in the preprocessor manual. +See :ref:`cpp:implementation-defined-behavior`. Some choices are made by the +library and operating system (or other environment when compiling for +a freestanding environment); refer to their documentation for details. + +.. toctree:: + :maxdepth: 2 + + c-implementation-defined-behavior/translation + c-implementation-defined-behavior/environment + c-implementation-defined-behavior/identifiers + c-implementation-defined-behavior/characters + c-implementation-defined-behavior/integers + c-implementation-defined-behavior/floating-point + c-implementation-defined-behavior/arrays-and-pointers + c-implementation-defined-behavior/hints + c-implementation-defined-behavior/structures-unions-enumerations-and-bit-fields + c-implementation-defined-behavior/qualifiers + c-implementation-defined-behavior/declarators + c-implementation-defined-behavior/statements + c-implementation-defined-behavior/preprocessing-directives + c-implementation-defined-behavior/library-functions + c-implementation-defined-behavior/architecture + c-implementation-defined-behavior/locale-specific-behavior \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/architecture.rst b/gcc/doc/gcc/c-implementation-defined-behavior/architecture.rst new file mode 100644 index 00000000000..99639bc7a31 --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/architecture.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _architecture-implementation: + +Architecture +************ + +* The values or expressions assigned to the macros specified in the + headers ````, ````, and ```` + (C90, C99 and C11 5.2.4.2, C99 7.18.2, C99 7.18.3, C11 7.20.2, C11 7.20.3). + + Determined by ABI. + +* The result of attempting to indirectly access an object with + automatic or thread storage duration from a thread other than the one + with which it is associated (C11 6.2.4). + + Such accesses are supported, subject to the same requirements for + synchronization for concurrent accesses as for concurrent accesses to + any object. + +* The number, order, and encoding of bytes in any object + (when not explicitly specified in this International Standard) (C99 + and C11 6.2.6.1). + + Determined by ABI. + +* Whether any extended alignments are supported and the contexts + in which they are supported (C11 6.2.8). + + Extended alignments up to 2^{28} (bytes) are supported for + objects of automatic storage duration. Alignments supported for + objects of static and thread storage duration are determined by the + ABI. + +* Valid alignment values other than those returned by an _Alignof + expression for fundamental types, if any (C11 6.2.8). + + Valid alignments are powers of 2 up to and including 2^{28}. + +* The value of the result of the ``sizeof`` and ``_Alignof`` + operators (C90 6.3.3.4, C99 and C11 6.5.3.4). + + Determined by ABI. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/arrays-and-pointers.rst b/gcc/doc/gcc/c-implementation-defined-behavior/arrays-and-pointers.rst new file mode 100644 index 00000000000..3d8f1884ffe --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/arrays-and-pointers.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _arrays-and-pointers-implementation: + +Arrays and Pointers +******************* + +* The result of converting a pointer to an integer or + vice versa (C90 6.3.4, C99 and C11 6.3.2.3). + + A cast from pointer to integer discards most-significant bits if the + pointer representation is larger than the integer type, + sign-extends ([#f1]_) if the pointer representation is smaller than the integer type, otherwise + the bits are unchanged. + + .. ??? We've always claimed that pointers were unsigned entities. + + .. Shouldn't we therefore be doing zero-extension? If so, the bug + + .. is in convert_to_integer, where we call type_for_size and request + + .. a signed integral type. On the other hand, it might be most useful + + .. for the target if we extend according to POINTERS_EXTEND_UNSIGNED. + + A cast from integer to pointer discards most-significant bits if the + pointer representation is smaller than the integer type, extends according + to the signedness of the integer type if the pointer representation + is larger than the integer type, otherwise the bits are unchanged. + + When casting from pointer to integer and back again, the resulting + pointer must reference the same object as the original pointer, otherwise + the behavior is undefined. That is, one may not use integer arithmetic to + avoid the undefined behavior of pointer arithmetic as proscribed in + C99 and C11 6.5.6/8. + +* The size of the result of subtracting two pointers to elements + of the same array (C90 6.3.6, C99 and C11 6.5.6). + + The value is as specified in the standard and the type is determined + by the ABI. + +.. [#f1] Future versions of GCC may zero-extend, or use a target-defined ``ptr_extend`` pattern. Do not rely on sign extension. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/characters.rst b/gcc/doc/gcc/c-implementation-defined-behavior/characters.rst new file mode 100644 index 00000000000..7e896b091ba --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/characters.rst @@ -0,0 +1,93 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _characters-implementation: + +Characters +********** + +* The number of bits in a byte (C90 3.4, C99 and C11 3.6). + + Determined by ABI. + +* The values of the members of the execution character set (C90, + C99 and C11 5.2.1). + + Determined by ABI. + +* The unique value of the member of the execution character set produced + for each of the standard alphabetic escape sequences (C90, C99 and C11 + 5.2.2). + + Determined by ABI. + +* The value of a ``char`` object into which has been stored any + character other than a member of the basic execution character set + (C90 6.1.2.5, C99 and C11 6.2.5). + + Determined by ABI. + +* Which of ``signed char`` or ``unsigned char`` has the same + range, representation, and behavior as 'plain' ``char`` (C90 + 6.1.2.5, C90 6.2.1.1, C99 and C11 6.2.5, C99 and C11 6.3.1.1). + + .. index:: fsigned-char, funsigned-char + + Determined by ABI. The options :option:`-funsigned-char` and + :option:`-fsigned-char` change the default. See :ref:`c-dialect-options`. + +* The mapping of members of the source character set (in character + constants and string literals) to members of the execution character + set (C90 6.1.3.4, C99 and C11 6.4.4.4, C90, C99 and C11 5.1.1.2). + + Determined by ABI. + +* The value of an integer character constant containing more than one + character or containing a character or escape sequence that does not map + to a single-byte execution character (C90 6.1.3.4, C99 and C11 6.4.4.4). + + See :ref:`cpp:implementation-defined-behavior`. + +* The value of a wide character constant containing more than one + multibyte character or a single multibyte character that maps to + multiple members of the extended execution character set, or + containing a multibyte character or escape sequence not represented in + the extended execution character set (C90 6.1.3.4, C99 and C11 + 6.4.4.4). + + See :ref:`cpp:implementation-defined-behavior`. + +* The current locale used to convert a wide character constant consisting + of a single multibyte character that maps to a member of the extended + execution character set into a corresponding wide character code (C90 + 6.1.3.4, C99 and C11 6.4.4.4). + + See :ref:`cpp:implementation-defined-behavior`. + +* Whether differently-prefixed wide string literal tokens can be + concatenated and, if so, the treatment of the resulting multibyte + character sequence (C11 6.4.5). + + Such tokens may not be concatenated. + +* The current locale used to convert a wide string literal into + corresponding wide character codes (C90 6.1.4, C99 and C11 6.4.5). + + See :ref:`cpp:implementation-defined-behavior`. + +* The value of a string literal containing a multibyte character or escape + sequence not represented in the execution character set (C90 6.1.4, + C99 and C11 6.4.5). + + See :ref:`cpp:implementation-defined-behavior`. + +* The encoding of any of ``wchar_t``, ``char16_t``, and + ``char32_t`` where the corresponding standard encoding macro + (``__STDC_ISO_10646__``, ``__STDC_UTF_16__``, or + ``__STDC_UTF_32__``) is not defined (C11 6.10.8.2). + + See :ref:`cpp:implementation-defined-behavior`. ``char16_t`` and + ``char32_t`` literals are always encoded in UTF-16 and UTF-32 + respectively. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/declarators.rst b/gcc/doc/gcc/c-implementation-defined-behavior/declarators.rst new file mode 100644 index 00000000000..8ac479ee200 --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/declarators.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _declarators-implementation: + +Declarators +*********** + +* The maximum number of declarators that may modify an arithmetic, + structure or union type (C90 6.5.4). + + GCC is only limited by available memory. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/environment.rst b/gcc/doc/gcc/c-implementation-defined-behavior/environment.rst new file mode 100644 index 00000000000..db3e7652ea4 --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/environment.rst @@ -0,0 +1,18 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _environment-implementation: + +Environment +*********** + +The behavior of most of these points are dependent on the implementation +of the C library, and are not defined by GCC itself. + +* The mapping between physical source file multibyte characters + and the source character set in translation phase 1 (C90, C99 and C11 + 5.1.1.2). + + See :ref:`cpp:implementation-defined-behavior`. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/floating-point.rst b/gcc/doc/gcc/c-implementation-defined-behavior/floating-point.rst new file mode 100644 index 00000000000..f0d43d58f0b --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/floating-point.rst @@ -0,0 +1,88 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _floating-point-implementation: + +Floating Point +************** + +* The accuracy of the floating-point operations and of the library + functions in ```` and ```` that return floating-point + results (C90, C99 and C11 5.2.4.2.2). + + The accuracy is unknown. + +* The rounding behaviors characterized by non-standard values + of ``FLT_ROUNDS`` + (C90, C99 and C11 5.2.4.2.2). + + GCC does not use such values. + +* The evaluation methods characterized by non-standard negative + values of ``FLT_EVAL_METHOD`` (C99 and C11 5.2.4.2.2). + + GCC does not use such values. + +* The direction of rounding when an integer is converted to a + floating-point number that cannot exactly represent the original + value (C90 6.2.1.3, C99 and C11 6.3.1.4). + + C99 Annex F is followed. + +* The direction of rounding when a floating-point number is + converted to a narrower floating-point number (C90 6.2.1.4, C99 and C11 + 6.3.1.5). + + C99 Annex F is followed. + +* How the nearest representable value or the larger or smaller + representable value immediately adjacent to the nearest representable + value is chosen for certain floating constants (C90 6.1.3.1, C99 and C11 + 6.4.4.2). + + C99 Annex F is followed. + +* Whether and how floating expressions are contracted when not + disallowed by the ``FP_CONTRACT`` pragma (C99 and C11 6.5). + + Expressions are currently only contracted if :option:`-ffp-contract=fast`, + :option:`-funsafe-math-optimizations` or :option:`-ffast-math` are used. + This is subject to change. + +* The default state for the ``FENV_ACCESS`` pragma (C99 and C11 + 7.6.1). + + This pragma is not implemented, but the default is to 'off' unless + :option:`-frounding-math` is used and :option:`-fno-trapping-math` is not + in which case it is 'on'. + +* Additional floating-point exceptions, rounding modes, environments, + and classifications, and their macro names (C99 and C11 7.6, C99 and + C11 7.12). + + This is dependent on the implementation of the C library, and is not + defined by GCC itself. + +* The default state for the ``FP_CONTRACT`` pragma (C99 and C11 + 7.12.2). + + This pragma is not implemented. Expressions are currently only + contracted if :option:`-ffp-contract=fast`, + :option:`-funsafe-math-optimizations` or :option:`-ffast-math` are used. + This is subject to change. + +* Whether the 'inexact' floating-point exception can be raised + when the rounded result actually does equal the mathematical result + in an IEC 60559 conformant implementation (C99 F.9). + + This is dependent on the implementation of the C library, and is not + defined by GCC itself. + +* Whether the 'underflow' (and 'inexact') floating-point + exception can be raised when a result is tiny but not inexact in an + IEC 60559 conformant implementation (C99 F.9). + + This is dependent on the implementation of the C library, and is not + defined by GCC itself. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/hints.rst b/gcc/doc/gcc/c-implementation-defined-behavior/hints.rst new file mode 100644 index 00000000000..e3d1935bc33 --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/hints.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _hints-implementation: + +Hints +***** + +* The extent to which suggestions made by using the ``register`` + storage-class specifier are effective (C90 6.5.1, C99 and C11 6.7.1). + + The ``register`` specifier affects code generation only in these ways: + + * When used as part of the register variable extension, see + :ref:`explicit-register-variables`. + + * When :option:`-O0` is in use, the compiler allocates distinct stack + memory for all variables that do not have the ``register`` + storage-class specifier; if ``register`` is specified, the variable + may have a shorter lifespan than the code would indicate and may never + be placed in memory. + + * On some rare x86 targets, ``setjmp`` doesn't save the registers in + all circumstances. In those cases, GCC doesn't allocate any variables + in registers unless they are marked ``register``. + +* The extent to which suggestions made by using the inline function + specifier are effective (C99 and C11 6.7.4). + + GCC will not inline any functions if the :option:`-fno-inline` option is + used or if :option:`-O0` is used. Otherwise, GCC may still be unable to + inline a function for many reasons; the :option:`-Winline` option may be + used to determine if a function has not been inlined and why not. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/identifiers.rst b/gcc/doc/gcc/c-implementation-defined-behavior/identifiers.rst new file mode 100644 index 00000000000..da1b949ed72 --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/identifiers.rst @@ -0,0 +1,28 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _identifiers-implementation: + +Identifiers +*********** + +* Which additional multibyte characters may appear in identifiers + and their correspondence to universal character names (C99 and C11 6.4.2). + + See :ref:`cpp:implementation-defined-behavior`. + +* The number of significant initial characters in an identifier + (C90 6.1.2, C90, C99 and C11 5.2.4.1, C99 and C11 6.4.2). + + For internal names, all characters are significant. For external names, + the number of significant characters are defined by the linker; for + almost all targets, all characters are significant. + +* Whether case distinctions are significant in an identifier with + external linkage (C90 6.1.2). + + This is a property of the linker. C99 and C11 require that case distinctions + are always significant in identifiers with external linkage and + systems without this property are not supported by GCC. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/integers.rst b/gcc/doc/gcc/c-implementation-defined-behavior/integers.rst new file mode 100644 index 00000000000..627fe775aed --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/integers.rst @@ -0,0 +1,66 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _integers-implementation: + +Integers +******** + +* Any extended integer types that exist in the implementation (C99 + and C11 6.2.5). + + GCC does not support any extended integer types. + + .. The __mode__ attribute might create types of precisions not + + .. otherwise supported, but the syntax isn't right for use everywhere + + .. the standard type names might be used. Predefined typedefs should + + .. be used if any extended integer types are to be defined. The __int128_t and __uint128_t + + .. typedefs are not extended integer types + + .. as they are generally longer than the ABI-specified intmax_t. + +* Whether signed integer types are represented using sign and magnitude, + two's complement, or one's complement, and whether the extraordinary value + is a trap representation or an ordinary value (C99 and C11 6.2.6.2). + + GCC supports only two's complement integer types, and all bit patterns + are ordinary values. + +* The rank of any extended integer type relative to another extended + integer type with the same precision (C99 and C11 6.3.1.1). + + GCC does not support any extended integer types. + + .. If it did, there would only be one of each precision and signedness. + +* The result of, or the signal raised by, converting an integer to a + signed integer type when the value cannot be represented in an object of + that type (C90 6.2.1.2, C99 and C11 6.3.1.3). + + For conversion to a type of width N, the value is reduced + modulo 2^N to be within range of the type; no signal is raised. + +* The results of some bitwise operations on signed integers (C90 + 6.3, C99 and C11 6.5). + + Bitwise operators act on the representation of the value including + both the sign and value bits, where the sign bit is considered + immediately above the highest-value value bit. Signed :samp:`>>` acts + on negative numbers by sign extension. + + As an extension to the C language, GCC does not use the latitude given in + C99 and C11 only to treat certain aspects of signed :samp:`<<` as undefined. + However, :option:`-fsanitize=shift` (and :option:`-fsanitize=undefined`) will + diagnose such cases. They are also diagnosed where constant + expressions are required. + +* The sign of the remainder on integer division (C90 6.3.5). + + GCC always follows the C99 and C11 requirement that the result of division is + truncated towards zero. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/library-functions.rst b/gcc/doc/gcc/c-implementation-defined-behavior/library-functions.rst new file mode 100644 index 00000000000..62bc15da9cb --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/library-functions.rst @@ -0,0 +1,19 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _library-functions-implementation: + +Library Functions +***************** + +The behavior of most of these points are dependent on the implementation +of the C library, and are not defined by GCC itself. + +* The null pointer constant to which the macro ``NULL`` expands + (C90 7.1.6, C99 7.17, C11 7.19). + + In ````, ``NULL`` expands to ``((void *)0)``. GCC + does not provide the other headers which define ``NULL`` and some + library implementations may use other definitions in those headers. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/locale-specific-behavior.rst b/gcc/doc/gcc/c-implementation-defined-behavior/locale-specific-behavior.rst new file mode 100644 index 00000000000..86745aacfeb --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/locale-specific-behavior.rst @@ -0,0 +1,12 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _locale-specific-behavior-implementation: + +Locale-Specific Behavior +************************ + +The behavior of these points are dependent on the implementation +of the C library, and are not defined by GCC itself. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/preprocessing-directives.rst b/gcc/doc/gcc/c-implementation-defined-behavior/preprocessing-directives.rst new file mode 100644 index 00000000000..cca0e2745e1 --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/preprocessing-directives.rst @@ -0,0 +1,54 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _preprocessing-directives-implementation: + +Preprocessing Directives +************************ + +See :ref:`cpp:implementation-defined-behavior`, for details of these aspects of +implementation-defined behavior. + +* The locations within ``#pragma`` directives where header name + preprocessing tokens are recognized (C11 6.4, C11 6.4.7). + +* How sequences in both forms of header names are mapped to headers + or external source file names (C90 6.1.7, C99 and C11 6.4.7). + +* Whether the value of a character constant in a constant expression + that controls conditional inclusion matches the value of the same character + constant in the execution character set (C90 6.8.1, C99 and C11 6.10.1). + +* Whether the value of a single-character character constant in a + constant expression that controls conditional inclusion may have a + negative value (C90 6.8.1, C99 and C11 6.10.1). + +* The places that are searched for an included :samp:`<>` delimited + header, and how the places are specified or the header is + identified (C90 6.8.2, C99 and C11 6.10.2). + +* How the named source file is searched for in an included :samp:`""` + delimited header (C90 6.8.2, C99 and C11 6.10.2). + +* The method by which preprocessing tokens (possibly resulting from + macro expansion) in a ``#include`` directive are combined into a header + name (C90 6.8.2, C99 and C11 6.10.2). + +* The nesting limit for ``#include`` processing (C90 6.8.2, C99 + and C11 6.10.2). + +* Whether the :samp:`#` operator inserts a :samp:`\\` character before + the :samp:`\\` character that begins a universal character name in a + character constant or string literal (C99 and C11 6.10.3.2). + +* The behavior on each recognized non- ``STDC #pragma`` + directive (C90 6.8.6, C99 and C11 6.10.6). + + See :ref:`cpp:pragmas`, for details of + pragmas accepted by GCC on all targets. See :ref:`pragmas`, for details of target-specific pragmas. + +* The definitions for ``__DATE__`` and ``__TIME__`` when + respectively, the date and time of translation are not available (C90 + 6.8.8, C99 6.10.8, C11 6.10.8.1). \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/qualifiers.rst b/gcc/doc/gcc/c-implementation-defined-behavior/qualifiers.rst new file mode 100644 index 00000000000..3d9baf3e6f0 --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/qualifiers.rst @@ -0,0 +1,53 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _qualifiers-implementation: + +Qualifiers +********** + +* What constitutes an access to an object that has volatile-qualified + type (C90 6.5.3, C99 and C11 6.7.3). + + Such an object is normally accessed by pointers and used for accessing + hardware. In most expressions, it is intuitively obvious what is a read + and what is a write. For example + + .. code-block:: c++ + + volatile int *dst = somevalue; + volatile int *src = someothervalue; + *dst = *src; + + will cause a read of the volatile object pointed to by :samp:`{src}` and store the + value into the volatile object pointed to by :samp:`{dst}`. There is no + guarantee that these reads and writes are atomic, especially for objects + larger than ``int``. + + However, if the volatile storage is not being modified, and the value of + the volatile storage is not used, then the situation is less obvious. + For example + + .. code-block:: c++ + + volatile int *src = somevalue; + *src; + + According to the C standard, such an expression is an rvalue whose type + is the unqualified version of its original type, i.e. ``int``. Whether + GCC interprets this as a read of the volatile object being pointed to or + only as a request to evaluate the expression for its side effects depends + on this type. + + If it is a scalar type, or on most targets an aggregate type whose only + member object is of a scalar type, or a union type whose member objects + are of scalar types, the expression is interpreted by GCC as a read of + the volatile object; in the other cases, the expression is only evaluated + for its side effects. + + When an object of an aggregate type, with the same size and alignment as a + scalar type ``S``, is the subject of a volatile access by an assignment + expression or an atomic function, the access to it is performed as if the + object's declared type were ``volatile S``. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/statements.rst b/gcc/doc/gcc/c-implementation-defined-behavior/statements.rst new file mode 100644 index 00000000000..725d9c45619 --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/statements.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _statements-implementation: + +Statements +********** + +* The maximum number of ``case`` values in a ``switch`` + statement (C90 6.6.4.2). + + GCC is only limited by available memory. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/structures-unions-enumerations-and-bit-fields.rst b/gcc/doc/gcc/c-implementation-defined-behavior/structures-unions-enumerations-and-bit-fields.rst new file mode 100644 index 00000000000..949f4658163 --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/structures-unions-enumerations-and-bit-fields.rst @@ -0,0 +1,78 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _structures-unions-enumerations-and-bit-fields-implementation: + +Structures, Unions, Enumerations, and Bit-Fields +************************************************ + +* A member of a union object is accessed using a member of a + different type (C90 6.3.2.3). + + The relevant bytes of the representation of the object are treated as + an object of the type used for the access. See :ref:`type-punning`. This + may be a trap representation. + +* Whether a 'plain' ``int`` bit-field is treated as a + ``signed int`` bit-field or as an ``unsigned int`` bit-field + (C90 6.5.2, C90 6.5.2.1, C99 and C11 6.7.2, C99 and C11 6.7.2.1). + + .. index:: funsigned-bitfields + + By default it is treated as ``signed int`` but this may be changed + by the :option:`-funsigned-bitfields` option. + +* Allowable bit-field types other than ``_Bool``, ``signed int``, + and ``unsigned int`` (C99 and C11 6.7.2.1). + + Other integer types, such as ``long int``, and enumerated types are + permitted even in strictly conforming mode. + +* Whether atomic types are permitted for bit-fields (C11 6.7.2.1). + + Atomic types are not permitted for bit-fields. + +* Whether a bit-field can straddle a storage-unit boundary (C90 + 6.5.2.1, C99 and C11 6.7.2.1). + + Determined by ABI. + +* The order of allocation of bit-fields within a unit (C90 + 6.5.2.1, C99 and C11 6.7.2.1). + + Determined by ABI. + +* The alignment of non-bit-field members of structures (C90 + 6.5.2.1, C99 and C11 6.7.2.1). + + Determined by ABI. + +* The integer type compatible with each enumerated type (C90 + 6.5.2.2, C99 and C11 6.7.2.2). + + .. index:: fshort-enums + + Normally, the type is ``unsigned int`` if there are no negative + values in the enumeration, otherwise ``int``. If + :option:`-fshort-enums` is specified, then if there are negative values + it is the first of ``signed char``, ``short`` and ``int`` + that can represent all the values, otherwise it is the first of + ``unsigned char``, ``unsigned short`` and ``unsigned int`` + that can represent all the values. + + .. On a few unusual targets with 64-bit int, this doesn't agree with + + .. the code and one of the types accessed via mode attributes (which + + .. are not currently considered extended integer types) may be used. + + .. If these types are made extended integer types, it would still be + + .. the case that -fshort-enums stops the implementation from + + .. conforming to C90 on those targets. + + On some targets, :option:`-fshort-enums` is the default; this is + determined by the ABI. \ No newline at end of file diff --git a/gcc/doc/gcc/c-implementation-defined-behavior/translation.rst b/gcc/doc/gcc/c-implementation-defined-behavior/translation.rst new file mode 100644 index 00000000000..e9a6d8855d4 --- /dev/null +++ b/gcc/doc/gcc/c-implementation-defined-behavior/translation.rst @@ -0,0 +1,20 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _translation-implementation: + +Translation +*********** + +* How a diagnostic is identified (C90 3.7, C99 and C11 3.10, C90, + C99 and C11 5.1.1.3). + + Diagnostics consist of all the output sent to stderr by GCC. + +* Whether each nonempty sequence of white-space characters other than + new-line is retained or replaced by one space character in translation + phase 3 (C90, C99 and C11 5.1.1.2). + + See :ref:`cpp:implementation-defined-behavior`. \ No newline at end of file diff --git a/gcc/doc/gcc/conditionally-supported-behavior.rst b/gcc/doc/gcc/conditionally-supported-behavior.rst new file mode 100644 index 00000000000..432bb329c2d --- /dev/null +++ b/gcc/doc/gcc/conditionally-supported-behavior.rst @@ -0,0 +1,20 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _conditionally-supported-behavior: + +Conditionally-Supported Behavior +******************************** + +Each implementation shall include documentation that identifies +all conditionally-supported constructs that it does not support (C++0x +1.4). + +* Whether an argument of class type with a non-trivial copy + constructor or destructor can be passed to ... (C++0x 5.2.2). + + Such argument passing is supported, using the same + pass-by-invisible-reference approach used for normal function + arguments of such types. \ No newline at end of file diff --git a/gcc/doc/gcc/conf.py b/gcc/doc/gcc/conf.py new file mode 100644 index 00000000000..7987f4d885b --- /dev/null +++ b/gcc/doc/gcc/conf.py @@ -0,0 +1,37 @@ +# Configuration file for the Sphinx documentation builder. + +import sys +sys.path.append('../../..//doc') + +from baseconf import * + +name = 'gcc' +project = 'Using the GNU Compiler Collection' +copyright = '1988-2022 Free Software Foundation, Inc.' +authors = 'Richard M. Stallman and the GCC Developer Community' + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +latex_documents = [ + ('index', f'{name}.tex', project, authors, 'manual'), +] + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('gcc-command-options', 'gcc', 'GNU project C and C++ compiler', [authors], 1), + ('gcov', 'gcov', 'coverage testing tool', [authors], 1), + ('gcov-dump', 'gcov-dump', 'offline gcda and gcno profile dump tool', [authors], 1), + ('gcov-tool', 'gcov-tool', 'offline gcda profile processing tool', [authors], 1), + ('lto-dump', 'lto-dump', 'Tool for dumping LTO object files', [authors], 1), + ('general-public-license-3', 'gpl', 'GNU General Public License', [], 7), + ('gnu-free-documentation-license', 'gfdl', 'GNU Free Documentation License', [], 7), + ('funding', 'fsf-funding', 'Funding Free Software', [], 7) +] + +texinfo_documents = [ + ('index', name, project, authors, None, None, None, True) +] + +set_common(name, globals()) \ No newline at end of file diff --git a/gcc/doc/gcc/contributing-to-gcc-development.rst b/gcc/doc/gcc/contributing-to-gcc-development.rst new file mode 100644 index 00000000000..f0d4b9f7db0 --- /dev/null +++ b/gcc/doc/gcc/contributing-to-gcc-development.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/contribute.rst \ No newline at end of file diff --git a/gcc/doc/gcc/contributors-to-gcc.rst b/gcc/doc/gcc/contributors-to-gcc.rst new file mode 100644 index 00000000000..27d5de90c77 --- /dev/null +++ b/gcc/doc/gcc/contributors-to-gcc.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/contrib.rst \ No newline at end of file diff --git a/gcc/doc/gcc/copyright.rst b/gcc/doc/gcc/copyright.rst new file mode 100644 index 00000000000..c778eb178c7 --- /dev/null +++ b/gcc/doc/gcc/copyright.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Copyright +^^^^^^^^^ + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with the +Invariant Sections being **GNU General Public License** and +**Funding Free Software**, the Front-Cover texts being (a) (see below), and with +the Back-Cover Texts being (b) (see below). A copy of the license is +in the :ref:`gnu_fdl`. + +(a) The FSF's Front-Cover Text is: + + A GNU Manual + +(b) The FSF's Back-Cover Text is: + + You have freedom to copy and modify this GNU Manual, like GNU + software. Copies published by the Free Software Foundation raise + funds for GNU development. \ No newline at end of file diff --git a/gcc/doc/gcc/exception-handling.rst b/gcc/doc/gcc/exception-handling.rst new file mode 100644 index 00000000000..5a29f279818 --- /dev/null +++ b/gcc/doc/gcc/exception-handling.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _exception-handling: + +Exception Handling +****************** + +* In the situation where no matching handler is found, it is + implementation-defined whether or not the stack is unwound before + std::terminate() is called (C++98 15.5.1). + + The stack is not unwound before std::terminate is called. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language.rst b/gcc/doc/gcc/extensions-to-the-c++-language.rst new file mode 100644 index 00000000000..5ea082b1a03 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: extensions, C++ language, C++ language extensions + +.. _c++-extensions: + +Extensions to the C++ Language +------------------------------ + +The GNU compiler provides these extensions to the C++ language (and you +can also use most of the C language extensions in your C++ programs). If you +want to write code that checks whether these features are available, you can +test for the GNU compiler the same way as for C programs: check for a +predefined macro ``__GNUC__``. You can also use ``__GNUG__`` to +test specifically for GNU C++ (see :ref:`cpp:common-predefined-macros`). + +.. toctree:: + :maxdepth: 2 + + extensions-to-the-c++-language/vague-linkage + extensions-to-the-c++-language/function-multiversioning + extensions-to-the-c++-language/type-traits + extensions-to-the-c++-language/c++-concepts + extensions-to-the-c++-language/deprecated-features + extensions-to-the-c++-language/backwards-compatibility + extensions-to-the-c++-language/when-is-a-volatile-c++-object-accessed + extensions-to-the-c++-language/restricting-pointer-aliasing + extensions-to-the-c++-language/c++-interface-and-implementation-pragmas + extensions-to-the-c++-language/wheres-the-template + extensions-to-the-c++-language/extracting-the-function-pointer-from-a-bound-pointer-to-member-function + extensions-to-the-c++-language/c++-specific-variable-function-and-type-attributes \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language/backwards-compatibility.rst b/gcc/doc/gcc/extensions-to-the-c++-language/backwards-compatibility.rst new file mode 100644 index 00000000000..d1ac5b21343 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language/backwards-compatibility.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Backwards Compatibility, ARM [Annotated C++ Reference Manual] + +.. _backwards-compatibility: + +Backwards Compatibility +*********************** + +Now that there is a definitive ISO standard C++, G++ has a specification +to adhere to. The C++ language evolved over time, and features that +used to be acceptable in previous drafts of the standard, such as the ARM +[Annotated C++ Reference Manual], are no longer accepted. In order to allow +compilation of C++ written to such drafts, G++ contains some backwards +compatibilities. *All such backwards compatibility features are +liable to disappear in future versions of G++.* They should be considered +deprecated. See :ref:`deprecated-features`. + +``Implicit C language`` + Old C system header files did not contain an ``extern "C" {...}`` + scope to set the language. On such systems, all system header files are + implicitly scoped inside a C language scope. Such headers must + correctly prototype function argument types, there is no leeway for + ``()`` to indicate an unspecified set of arguments. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language/c++-concepts.rst b/gcc/doc/gcc/extensions-to-the-c++-language/c++-concepts.rst new file mode 100644 index 00000000000..bba336ece54 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language/c++-concepts.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _c++-concepts: + +C++ Concepts +************ + +C++ concepts provide much-improved support for generic programming. In +particular, they allow the specification of constraints on template arguments. +The constraints are used to extend the usual overloading and partial +specialization capabilities of the language, allowing generic data structures +and algorithms to be 'refined' based on their properties rather than their +type names. + +The following keywords are reserved for concepts. + +``assumes`` + States an expression as an assumption, and if possible, verifies that the + assumption is valid. For example, ``assume(n > 0)``. + +``axiom`` + Introduces an axiom definition. Axioms introduce requirements on values. + +``forall`` + Introduces a universally quantified object in an axiom. For example, + ``forall (int n) n + 0 == n``). + +``concept`` + Introduces a concept definition. Concepts are sets of syntactic and semantic + requirements on types and their values. + +``requires`` + Introduces constraints on template arguments or requirements for a member + function of a class template. + +The front end also exposes a number of internal mechanism that can be used +to simplify the writing of type traits. Note that some of these traits are +likely to be removed in the future. + +``__is_same (type1, type2)`` + A binary type trait: ``true`` whenever the type arguments are the same. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language/c++-interface-and-implementation-pragmas.rst b/gcc/doc/gcc/extensions-to-the-c++-language/c++-interface-and-implementation-pragmas.rst new file mode 100644 index 00000000000..fc7fafd90c8 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language/c++-interface-and-implementation-pragmas.rst @@ -0,0 +1,97 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: interface and implementation headers, C++, C++ interface and implementation headers, pragmas, interface and implementation + +.. _c++-interface: + +C++ Interface and Implementation Pragmas +**************************************** + +``#pragma interface`` and ``#pragma implementation`` provide the +user with a way of explicitly directing the compiler to emit entities +with vague linkage (and debugging information) in a particular +translation unit. + +.. note:: + + These ``#pragma`` s have been superceded as of GCC 2.7.2 + by COMDAT support and the 'key method' heuristic + mentioned in :ref:`vague-linkage`. Using them can actually cause your + program to grow due to unnecessary out-of-line copies of inline + functions. + +``#pragma interface`` :samp:`#pragma interface "{subdir}/{objects}.h"` + + .. index:: #pragma interface + + Use this directive in *header files* that define object classes, to save + space in most of the object files that use those classes. Normally, + local copies of certain information (backup copies of inline member + functions, debugging information, and the internal tables that implement + virtual functions) must be kept in each object file that includes class + definitions. You can use this pragma to avoid such duplication. When a + header file containing :samp:`#pragma interface` is included in a + compilation, this auxiliary information is not generated (unless + the main input source file itself uses :samp:`#pragma implementation`). + Instead, the object files contain references to be resolved at link + time. + + The second form of this directive is useful for the case where you have + multiple headers with the same name in different directories. If you + use this form, you must specify the same string to :samp:`#pragma + implementation`. + +``#pragma implementation`` :samp:`#pragma implementation "{objects}.h"` + + .. index:: #pragma implementation + + Use this pragma in a *main input file*, when you want full output from + included header files to be generated (and made globally visible). The + included header file, in turn, should use :samp:`#pragma interface`. + Backup copies of inline member functions, debugging information, and the + internal tables used to implement virtual functions are all generated in + implementation files. + + .. index:: implied #pragma implementation, #pragma implementation, implied, naming convention, implementation headers + + If you use :samp:`#pragma implementation` with no argument, it applies to + an include file with the same basenameA file's :dfn:`basename` + is the name stripped of all leading path information and of trailing + suffixes, such as :samp:`.h` or :samp:`.C` or :samp:`.cc`. + as your source + file. For example, in :samp:`allclass.cc`, giving just + :samp:`#pragma implementation` + by itself is equivalent to :samp:`#pragma implementation "allclass.h"`. + + Use the string argument if you want a single implementation file to + include code from multiple header files. (You must also use + :samp:`#include` to include the header file; :samp:`#pragma + implementation` only specifies how to use the file---it doesn't actually + include it.) + + There is no way to split up the contents of a single header file into + multiple implementation files. + +.. index:: inlining and C++ pragmas, C++ pragmas, effect on inlining, pragmas in C++, effect on inlining + +:samp:`#pragma implementation` and :samp:`#pragma interface` also have an +effect on function inlining. + +If you define a class in a header file marked with :samp:`#pragma +interface`, the effect on an inline function defined in that class is +similar to an explicit ``extern`` declaration---the compiler emits +no code at all to define an independent version of the function. Its +definition is used only for inlining with its callers. + +.. index:: fno-implement-inlines + +Conversely, when you include the same header file in a main source file +that declares it as :samp:`#pragma implementation`, the compiler emits +code for the function itself; this defines a version of the function +that can be found via pointers (or by callers compiled without +inlining). If all calls to the function can be inlined, you can avoid +emitting the function by compiling with :option:`-fno-implement-inlines`. +If any calls are not inlined, you will get linker errors. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language/c++-specific-variable-function-and-type-attributes.rst b/gcc/doc/gcc/extensions-to-the-c++-language/c++-specific-variable-function-and-type-attributes.rst new file mode 100644 index 00000000000..0eb484a428e --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language/c++-specific-variable-function-and-type-attributes.rst @@ -0,0 +1,95 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _c++-attributes: + +C++-Specific Variable, Function, and Type Attributes +**************************************************** + +Some attributes only make sense for C++ programs. + +.. index:: abi_tag function attribute, abi_tag variable attribute, abi_tag type attribute + +.. gcc-attr:: abi_tag ("tag", ...) + + The ``abi_tag`` attribute can be applied to a function, variable, or class + declaration. It modifies the mangled name of the entity to + incorporate the tag name, in order to distinguish the function or + class from an earlier version with a different ABI; perhaps the class + has changed size, or the function has a different return type that is + not encoded in the mangled name. + + The attribute can also be applied to an inline namespace, but does not + affect the mangled name of the namespace; in this case it is only used + for :option:`-Wabi-tag` warnings and automatic tagging of functions and + variables. Tagging inline namespaces is generally preferable to + tagging individual declarations, but the latter is sometimes + necessary, such as when only certain members of a class need to be + tagged. + + The argument can be a list of strings of arbitrary length. The + strings are sorted on output, so the order of the list is + unimportant. + + A redeclaration of an entity must not add new ABI tags, + since doing so would change the mangled name. + + The ABI tags apply to a name, so all instantiations and + specializations of a template have the same tags. The attribute will + be ignored if applied to an explicit specialization or instantiation. + + The :option:`-Wabi-tag` flag enables a warning about a class which does + not have all the ABI tags used by its subobjects and virtual functions; for users with code + that needs to coexist with an earlier ABI, using this option can help + to find all affected types that need to be tagged. + + When a type involving an ABI tag is used as the type of a variable or + return type of a function where that tag is not already present in the + signature of the function, the tag is automatically applied to the + variable or function. :option:`-Wabi-tag` also warns about this + situation; this warning can be avoided by explicitly tagging the + variable or function or moving it into a tagged inline namespace. + +.. index:: init_priority variable attribute + +.. gcc-attr:: init_priority (priority) + + In Standard C++, objects defined at namespace scope are guaranteed to be + initialized in an order in strict accordance with that of their definitions + *in a given translation unit*. No guarantee is made for initializations + across translation units. However, GNU C++ allows users to control the + order of initialization of objects defined at namespace scope with the + ``init_priority`` attribute by specifying a relative :samp:`{priority}`, + a constant integral expression currently bounded between 101 and 65535 + inclusive. Lower numbers indicate a higher priority. + + In the following example, ``A`` would normally be created before + ``B``, but the ``init_priority`` attribute reverses that order: + + .. code-block:: c++ + + Some_Class A __attribute__ ((init_priority (2000))); + Some_Class B __attribute__ ((init_priority (543))); + + Note that the particular values of :samp:`{priority}` do not matter; only their + relative ordering. + +.. index:: warn_unused type attribute + +.. gcc-attr:: warn_unused + + For C++ types with non-trivial constructors and/or destructors it is + impossible for the compiler to determine whether a variable of this + type is truly unused if it is not referenced. This type attribute + informs the compiler that variables of this type should be warned + about if they appear to be unused, just like variables of fundamental + types. + + This attribute is appropriate for types which just represent a value, + such as ``std::string`` ; it is not appropriate for types which + control a resource, such as ``std::lock_guard``. + + This attribute is also accepted in C, but it is unnecessary because C + does not have constructors or destructors. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language/deprecated-features.rst b/gcc/doc/gcc/extensions-to-the-c++-language/deprecated-features.rst new file mode 100644 index 00000000000..f55b5eb4439 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language/deprecated-features.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _deprecated-features: + +Deprecated Features +******************* + +In the past, the GNU C++ compiler was extended to experiment with new +features, at a time when the C++ language was still evolving. Now that +the C++ standard is complete, some of those features are superseded by +superior alternatives. Using the old features might cause a warning in +some cases that the feature will be dropped in the future. In other +cases, the feature might be gone already. + +G++ allows a virtual function returning :samp:`void *` to be overridden +by one returning a different pointer type. This extension to the +covariant return type rules is now deprecated and will be removed from a +future version. + +The use of default arguments in function pointers, function typedefs +and other places where they are not permitted by the standard is +deprecated and will be removed from a future version of G++. + +G++ allows floating-point literals to appear in integral constant expressions, +e.g. :samp:`enum E { e = int(2.2 * 3.7) }` +This extension is deprecated and will be removed from a future version. + +G++ allows static data members of const floating-point type to be declared +with an initializer in a class definition. The standard only allows +initializers for static members of const integral types and const +enumeration types so this extension has been deprecated and will be removed +from a future version. + +G++ allows attributes to follow a parenthesized direct initializer, +e.g. :samp:`int f (0) __attribute__ ((something));` This extension +has been ignored since G++ 3.3 and is deprecated. + +G++ allows anonymous structs and unions to have members that are not +public non-static data members (i.e. fields). These extensions are +deprecated. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language/extracting-the-function-pointer-from-a-bound-pointer-to-member-function.rst b/gcc/doc/gcc/extensions-to-the-c++-language/extracting-the-function-pointer-from-a-bound-pointer-to-member-function.rst new file mode 100644 index 00000000000..bae1efefcbd --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language/extracting-the-function-pointer-from-a-bound-pointer-to-member-function.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: pmf, pointer to member function, bound pointer to member function + +.. _bound-member-functions: + +Extracting the Function Pointer from a Bound Pointer to Member Function +*********************************************************************** + +In C++, pointer to member functions (PMFs) are implemented using a wide +pointer of sorts to handle all the possible call mechanisms; the PMF +needs to store information about how to adjust the :samp:`this` pointer, +and if the function pointed to is virtual, where to find the vtable, and +where in the vtable to look for the member function. If you are using +PMFs in an inner loop, you should really reconsider that decision. If +that is not an option, you can extract the pointer to the function that +would be called for a given object/PMF pair and call it directly inside +the inner loop, to save a bit of time. + +Note that you still pay the penalty for the call through a +function pointer; on most modern architectures, such a call defeats the +branch prediction features of the CPU. This is also true of normal +virtual function calls. + +The syntax for this extension is + +.. code-block:: c++ + + extern A a; + extern int (A::*fp)(); + typedef int (*fptr)(A *); + + fptr p = (fptr)(a.*fp); + +For PMF constants (i.e. expressions of the form :samp:`&Klasse::Member`), +no object is needed to obtain the address of the function. They can be +converted to function pointers directly: + +.. code-block:: c++ + + fptr p1 = (fptr)(&A::foo); + +.. index:: Wno-pmf-conversions + +You must specify :option:`-Wno-pmf-conversions` to use this extension. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language/function-multiversioning.rst b/gcc/doc/gcc/extensions-to-the-c++-language/function-multiversioning.rst new file mode 100644 index 00000000000..2524ff5353c --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language/function-multiversioning.rst @@ -0,0 +1,65 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: function versions + +.. _function-multiversioning: + +Function Multiversioning +************************ + +With the GNU C++ front end, for x86 targets, you may specify multiple +versions of a function, where each function is specialized for a +specific target feature. At runtime, the appropriate version of the +function is automatically executed depending on the characteristics of +the execution platform. Here is an example. + +.. code-block:: c++ + + __attribute__ ((target ("default"))) + int foo () + { + // The default version of foo. + return 0; + } + + __attribute__ ((target ("sse4.2"))) + int foo () + { + // foo version for SSE4.2 + return 1; + } + + __attribute__ ((target ("arch=atom"))) + int foo () + { + // foo version for the Intel ATOM processor + return 2; + } + + __attribute__ ((target ("arch=amdfam10"))) + int foo () + { + // foo version for the AMD Family 0x10 processors. + return 3; + } + + int main () + { + int (*p)() = &foo; + assert ((*p) () == foo ()); + return 0; + } + +In the above example, four versions of function foo are created. The +first version of foo with the target attribute "default" is the default +version. This version gets executed when no other target specific +version qualifies for execution on a particular platform. A new version +of foo is created by using the same function signature but with a +different target string. Function foo is called or a pointer to it is +taken just like a regular function. GCC takes care of doing the +dispatching to call the right version at runtime. Refer to the +`GCC wiki on +Function Multiversioning `_ for more details. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language/restricting-pointer-aliasing.rst b/gcc/doc/gcc/extensions-to-the-c++-language/restricting-pointer-aliasing.rst new file mode 100644 index 00000000000..971770c6463 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language/restricting-pointer-aliasing.rst @@ -0,0 +1,52 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: restricted pointers, restricted references, restricted this pointer + +.. _restricted-pointers: + +Restricting Pointer Aliasing +**************************** + +As with the C front end, G++ understands the C99 feature of restricted pointers, +specified with the ``__restrict__``, or ``__restrict`` type +qualifier. Because you cannot compile C++ by specifying the :option:`-std=c99` +language flag, ``restrict`` is not a keyword in C++. + +In addition to allowing restricted pointers, you can specify restricted +references, which indicate that the reference is not aliased in the local +context. + +.. code-block:: c++ + + void fn (int *__restrict__ rptr, int &__restrict__ rref) + { + /* ... */ + } + +In the body of ``fn``, :samp:`{rptr}` points to an unaliased integer and +:samp:`{rref}` refers to a (different) unaliased integer. + +You may also specify whether a member function's :samp:`{this}` pointer is +unaliased by using ``__restrict__`` as a member function qualifier. + +.. code-block:: c++ + + void T::fn () __restrict__ + { + /* ... */ + } + +Within the body of ``T::fn``, :samp:`{this}` has the effective +definition ``T *__restrict__ const this``. Notice that the +interpretation of a ``__restrict__`` member function qualifier is +different to that of ``const`` or ``volatile`` qualifier, in that it +is applied to the pointer rather than the object. This is consistent with +other compilers that implement restricted pointers. + +As with all outermost parameter qualifiers, ``__restrict__`` is +ignored in function definition matching. This means you only need to +specify ``__restrict__`` in a function definition, rather than +in a function prototype as well. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language/type-traits.rst b/gcc/doc/gcc/extensions-to-the-c++-language/type-traits.rst new file mode 100644 index 00000000000..3ce0a3779de --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language/type-traits.rst @@ -0,0 +1,165 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _type-traits: + +Type Traits +*********** + +The C++ front end implements syntactic extensions that allow +compile-time determination of +various characteristics of a type (or of a +pair of types). + +``__has_nothrow_assign (type)`` + If ``type`` is ``const`` -qualified or is a reference type then + the trait is ``false``. Otherwise if ``__has_trivial_assign (type)`` + is ``true`` then the trait is ``true``, else if ``type`` is + a cv-qualified class or union type with copy assignment operators that are + known not to throw an exception then the trait is ``true``, else it is + ``false``. + Requires: ``type`` shall be a complete type, (possibly cv-qualified) + ``void``, or an array of unknown bound. + +``__has_nothrow_copy (type)`` + If ``__has_trivial_copy (type)`` is ``true`` then the trait is + ``true``, else if ``type`` is a cv-qualified class or union type + with copy constructors that are known not to throw an exception then + the trait is ``true``, else it is ``false``. + Requires: ``type`` shall be a complete type, (possibly cv-qualified) + ``void``, or an array of unknown bound. + +``__has_nothrow_constructor (type)`` + If ``__has_trivial_constructor (type)`` is ``true`` then the trait + is ``true``, else if ``type`` is a cv class or union type (or array + thereof) with a default constructor that is known not to throw an + exception then the trait is ``true``, else it is ``false``. + Requires: ``type`` shall be a complete type, (possibly cv-qualified) + ``void``, or an array of unknown bound. + +``__has_trivial_assign (type)`` + If ``type`` is ``const`` - qualified or is a reference type then + the trait is ``false``. Otherwise if ``__is_trivial (type)`` is + ``true`` then the trait is ``true``, else if ``type`` is + a cv-qualified class or union type with a trivial copy assignment + ([class.copy]) then the trait is ``true``, else it is ``false``. + Requires: ``type`` shall be a complete type, (possibly cv-qualified) + ``void``, or an array of unknown bound. + +``__has_trivial_copy (type)`` + If ``__is_trivial (type)`` is ``true`` or ``type`` is a reference + type then the trait is ``true``, else if ``type`` is a cv class + or union type with a trivial copy constructor ([class.copy]) then the trait + is ``true``, else it is ``false``. Requires: ``type`` shall be + a complete type, (possibly cv-qualified) ``void``, or an array of unknown + bound. + +``__has_trivial_constructor (type)`` + If ``__is_trivial (type)`` is ``true`` then the trait is ``true``, + else if ``type`` is a cv-qualified class or union type (or array thereof) + with a trivial default constructor ([class.ctor]) then the trait is ``true``, + else it is ``false``. + Requires: ``type`` shall be a complete type, (possibly cv-qualified) + ``void``, or an array of unknown bound. + +``__has_trivial_destructor (type)`` + If ``__is_trivial (type)`` is ``true`` or ``type`` is a reference type + then the trait is ``true``, else if ``type`` is a cv class or union + type (or array thereof) with a trivial destructor ([class.dtor]) then + the trait is ``true``, else it is ``false``. + Requires: ``type`` shall be a complete type, (possibly cv-qualified) + ``void``, or an array of unknown bound. + +``__has_virtual_destructor (type)`` + If ``type`` is a class type with a virtual destructor + ([class.dtor]) then the trait is ``true``, else it is ``false``. + Requires: If ``type`` is a non-union class type, it shall be a complete type. + +``__is_abstract (type)`` + If ``type`` is an abstract class ([class.abstract]) then the trait + is ``true``, else it is ``false``. + Requires: If ``type`` is a non-union class type, it shall be a complete type. + +``__is_aggregate (type)`` + If ``type`` is an aggregate type ([dcl.init.aggr]) the trait is + ``true``, else it is ``false``. + Requires: If ``type`` is a class type, it shall be a complete type. + +``__is_base_of (base_type, derived_type)`` + If ``base_type`` is a base class of ``derived_type`` + ([class.derived]) then the trait is ``true``, otherwise it is ``false``. + Top-level cv-qualifications of ``base_type`` and + ``derived_type`` are ignored. For the purposes of this trait, a + class type is considered is own base. + Requires: if ``__is_class (base_type)`` and ``__is_class (derived_type)`` + are ``true`` and ``base_type`` and ``derived_type`` are not the same + type (disregarding cv-qualifiers), ``derived_type`` shall be a complete + type. A diagnostic is produced if this requirement is not met. + +``__is_class (type)`` + If ``type`` is a cv-qualified class type, and not a union type + ([basic.compound]) the trait is ``true``, else it is ``false``. + +``__is_empty (type)`` + If ``__is_class (type)`` is ``false`` then the trait is ``false``. + Otherwise ``type`` is considered empty if and only if: ``type`` + has no non-static data members, or all non-static data members, if + any, are bit-fields of length 0, and ``type`` has no virtual + members, and ``type`` has no virtual base classes, and ``type`` + has no base classes ``base_type`` for which + ``__is_empty (base_type)`` is ``false``. + Requires: If ``type`` is a non-union class type, it shall be a complete type. + +``__is_enum (type)`` + If ``type`` is a cv enumeration type ([basic.compound]) the trait is + ``true``, else it is ``false``. + +``__is_final (type)`` + If ``type`` is a class or union type marked ``final``, then the trait + is ``true``, else it is ``false``. + Requires: If ``type`` is a class type, it shall be a complete type. + +``__is_literal_type (type)`` + If ``type`` is a literal type ([basic.types]) the trait is + ``true``, else it is ``false``. + Requires: ``type`` shall be a complete type, (possibly cv-qualified) + ``void``, or an array of unknown bound. + +``__is_pod (type)`` + If ``type`` is a cv POD type ([basic.types]) then the trait is ``true``, + else it is ``false``. + Requires: ``type`` shall be a complete type, (possibly cv-qualified) + ``void``, or an array of unknown bound. + +``__is_polymorphic (type)`` + If ``type`` is a polymorphic class ([class.virtual]) then the trait + is ``true``, else it is ``false``. + Requires: If ``type`` is a non-union class type, it shall be a complete type. + +``__is_standard_layout (type)`` + If ``type`` is a standard-layout type ([basic.types]) the trait is + ``true``, else it is ``false``. + Requires: ``type`` shall be a complete type, an array of complete types, + or (possibly cv-qualified) ``void``. + +``__is_trivial (type)`` + If ``type`` is a trivial type ([basic.types]) the trait is + ``true``, else it is ``false``. + Requires: ``type`` shall be a complete type, an array of complete types, + or (possibly cv-qualified) ``void``. + +``__is_union (type)`` + If ``type`` is a cv union type ([basic.compound]) the trait is + ``true``, else it is ``false``. + +``__underlying_type (type)`` + The underlying type of ``type``. + Requires: ``type`` shall be an enumeration type ([dcl.enum]). + +``__integer_pack (length)`` + When used as the pattern of a pack expansion within a template + definition, expands to a template argument pack containing integers + from ``0`` to ``length-1``. This is provided for efficient + implementation of ``std::make_integer_sequence``. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language/vague-linkage.rst b/gcc/doc/gcc/extensions-to-the-c++-language/vague-linkage.rst new file mode 100644 index 00000000000..7477d4d4191 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language/vague-linkage.rst @@ -0,0 +1,80 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: vague linkage + +.. _vague-linkage: + +Vague Linkage +************* + +There are several constructs in C++ that require space in the object +file but are not clearly tied to a single translation unit. We say that +these constructs have 'vague linkage'. Typically such constructs are +emitted wherever they are needed, though sometimes we can be more +clever. + +Inline Functions + Inline functions are typically defined in a header file which can be + included in many different compilations. Hopefully they can usually be + inlined, but sometimes an out-of-line copy is necessary, if the address + of the function is taken or if inlining fails. In general, we emit an + out-of-line copy in all translation units where one is needed. As an + exception, we only emit inline virtual functions with the vtable, since + it always requires a copy. + + Local static variables and string constants used in an inline function + are also considered to have vague linkage, since they must be shared + between all inlined and out-of-line instances of the function. + +VTables + C++ virtual functions are implemented in most compilers using a lookup + table, known as a vtable. The vtable contains pointers to the virtual + functions provided by a class, and each object of the class contains a + pointer to its vtable (or vtables, in some multiple-inheritance + situations). If the class declares any non-inline, non-pure virtual + functions, the first one is chosen as the 'key method' for the class, + and the vtable is only emitted in the translation unit where the key + method is defined. + + .. note:: + + If the chosen key method is later defined as inline, the + vtable is still emitted in every translation unit that defines it. + Make sure that any inline virtuals are declared inline in the class + body, even if they are not defined there. + +:samp:`{type_info} objects` + C++ requires information about types to be written out in order to + implement :samp:`dynamic_cast`, :samp:`typeid` and exception handling. + For polymorphic classes (classes with virtual functions), the :samp:`type_info` + object is written out along with the vtable so that :samp:`dynamic_cast` + can determine the dynamic type of a class object at run time. For all + other types, we write out the :samp:`type_info` object when it is used: when + applying :samp:`typeid` to an expression, throwing an object, or + referring to a type in a catch clause or exception specification. + +Template Instantiations + Most everything in this section also applies to template instantiations, + but there are other options as well. + See :ref:`template-instantiation`. + +When used with GNU ld version 2.8 or later on an ELF system such as +GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of +these constructs will be discarded at link time. This is known as +COMDAT support. + +On targets that don't support COMDAT, but do support weak symbols, GCC +uses them. This way one copy overrides all the others, but +the unused copies still take up space in the executable. + +For targets that do not support either COMDAT or weak symbols, +most entities with vague linkage are emitted as local symbols to +avoid duplicate definition errors from the linker. This does not happen +for local statics in inlines, however, as having multiple copies +almost certainly breaks things. + +See :ref:`c++-interface`, for +another way to control placement of these constructs. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language/when-is-a-volatile-c++-object-accessed.rst b/gcc/doc/gcc/extensions-to-the-c++-language/when-is-a-volatile-c++-object-accessed.rst new file mode 100644 index 00000000000..f50f1ea62e4 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language/when-is-a-volatile-c++-object-accessed.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: accessing volatiles, volatile read, volatile write, volatile access + +.. _c++-volatiles: + +When is a Volatile C++ Object Accessed? +*************************************** + +The C++ standard differs from the C standard in its treatment of +volatile objects. It fails to specify what constitutes a volatile +access, except to say that C++ should behave in a similar manner to C +with respect to volatiles, where possible. However, the different +lvalueness of expressions between C and C++ complicate the behavior. +G++ behaves the same as GCC for volatile access, See :ref:`c-extensions`, for a description of GCC's behavior. + +The C and C++ language specifications differ when an object is +accessed in a void context: + +.. code-block:: c++ + + volatile int *src = somevalue; + *src; + +The C++ standard specifies that such expressions do not undergo lvalue +to rvalue conversion, and that the type of the dereferenced object may +be incomplete. The C++ standard does not specify explicitly that it +is lvalue to rvalue conversion that is responsible for causing an +access. There is reason to believe that it is, because otherwise +certain simple expressions become undefined. However, because it +would surprise most programmers, G++ treats dereferencing a pointer to +volatile object of complete type as GCC would do for an equivalent +type in C. When the object has incomplete type, G++ issues a +warning; if you wish to force an error, you must force a conversion to +rvalue with, for instance, a static cast. + +When using a reference to volatile, G++ does not treat equivalent +expressions as accesses to volatiles, but instead issues a warning that +no volatile is accessed. The rationale for this is that otherwise it +becomes difficult to determine where volatile access occur, and not +possible to ignore the return value from functions returning volatile +references. Again, if you wish to force a read, cast the reference to +an rvalue. + +G++ implements the same behavior as GCC does when assigning to a +volatile object---there is no reread of the assigned-to object, the +assigned rvalue is reused. Note that in C++ assignment expressions +are lvalues, and if used as an lvalue, the volatile object is +referred to. For instance, :samp:`{vref}` refers to :samp:`{vobj}`, as +expected, in the following example: + +.. code-block:: c++ + + volatile int vobj; + volatile int &vref = vobj = something; \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c++-language/wheres-the-template.rst b/gcc/doc/gcc/extensions-to-the-c++-language/wheres-the-template.rst new file mode 100644 index 00000000000..72293670571 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c++-language/wheres-the-template.rst @@ -0,0 +1,131 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: template instantiation + +.. _template-instantiation: + +Where's the Template? +********************* + +C++ templates were the first language feature to require more +intelligence from the environment than was traditionally found on a UNIX +system. Somehow the compiler and linker have to make sure that each +template instance occurs exactly once in the executable if it is needed, +and not at all otherwise. There are two basic approaches to this +problem, which are referred to as the Borland model and the Cfront model. + +Borland model + Borland C++ solved the template instantiation problem by adding the code + equivalent of common blocks to their linker; the compiler emits template + instances in each translation unit that uses them, and the linker + collapses them together. The advantage of this model is that the linker + only has to consider the object files themselves; there is no external + complexity to worry about. The disadvantage is that compilation time + is increased because the template code is being compiled repeatedly. + Code written for this model tends to include definitions of all + templates in the header file, since they must be seen to be + instantiated. + +Cfront model + The AT&T C++ translator, Cfront, solved the template instantiation + problem by creating the notion of a template repository, an + automatically maintained place where template instances are stored. A + more modern version of the repository works as follows: As individual + object files are built, the compiler places any template definitions and + instantiations encountered in the repository. At link time, the link + wrapper adds in the objects in the repository and compiles any needed + instances that were not previously emitted. The advantages of this + model are more optimal compilation speed and the ability to use the + system linker; to implement the Borland model a compiler vendor also + needs to replace the linker. The disadvantages are vastly increased + complexity, and thus potential for error; for some code this can be + just as transparent, but in practice it can been very difficult to build + multiple programs in one directory and one program in multiple + directories. Code written for this model tends to separate definitions + of non-inline member templates into a separate file, which should be + compiled separately. + +G++ implements the Borland model on targets where the linker supports it, +including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows. +Otherwise G++ implements neither automatic model. + +You have the following options for dealing with template instantiations: + +* Do nothing. Code written for the Borland model works fine, but + each translation unit contains instances of each of the templates it + uses. The duplicate instances will be discarded by the linker, but in + a large program, this can lead to an unacceptable amount of code + duplication in object files or shared libraries. + + Duplicate instances of a template can be avoided by defining an explicit + instantiation in one object file, and preventing the compiler from doing + implicit instantiations in any other object files by using an explicit + instantiation declaration, using the ``extern template`` syntax: + + .. code-block:: c++ + + extern template int max (int, int); + + This syntax is defined in the C++ 2011 standard, but has been supported by + G++ and other compilers since well before 2011. + + Explicit instantiations can be used for the largest or most frequently + duplicated instances, without having to know exactly which other instances + are used in the rest of the program. You can scatter the explicit + instantiations throughout your program, perhaps putting them in the + translation units where the instances are used or the translation units + that define the templates themselves; you can put all of the explicit + instantiations you need into one big file; or you can create small files + like + + .. code-block:: c++ + + #include "Foo.h" + #include "Foo.cc" + + template class Foo; + template ostream& operator << + (ostream&, const Foo&); + + for each of the instances you need, and create a template instantiation + library from those. + + This is the simplest option, but also offers flexibility and + fine-grained control when necessary. It is also the most portable + alternative and programs using this approach will work with most modern + compilers. + +* + .. index:: fno-implicit-templates + + Compile your code with :option:`-fno-implicit-templates` to disable the + implicit generation of template instances, and explicitly instantiate + all the ones you use. This approach requires more knowledge of exactly + which instances you need than do the others, but it's less + mysterious and allows greater control if you want to ensure that only + the intended instances are used. + + If you are using Cfront-model code, you can probably get away with not + using :option:`-fno-implicit-templates` when compiling files that don't + :samp:`#include` the member template definitions. + + If you use one big file to do the instantiations, you may want to + compile it without :option:`-fno-implicit-templates` so you get all of the + instances required by your explicit instantiations (but not by any + other files) without having to specify them as well. + + In addition to forward declaration of explicit instantiations + (with ``extern``), G++ has extended the template instantiation + syntax to support instantiation of the compiler support data for a + template class (i.e. the vtable) without instantiating any of its + members (with ``inline``), and instantiation of only the static data + members of a template class, without the support data or member + functions (with ``static``): + + .. code-block:: c++ + + inline template class Foo; + static template class Foo; \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family.rst b/gcc/doc/gcc/extensions-to-the-c-language-family.rst new file mode 100644 index 00000000000..e7a036003d2 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family.rst @@ -0,0 +1,92 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: extensions, C language, C language extensions, pedantic + +.. _c-extensions: + +Extensions to the C Language Family +----------------------------------- + +GNU C provides several language features not found in ISO standard C. +(The :option:`-pedantic` option directs GCC to print a warning message if +any of these features is used.) To test for the availability of these +features in conditional compilation, check for a predefined macro +``__GNUC__``, which is always defined under GCC. + +These extensions are available in C and Objective-C. Most of them are +also available in C++. See :ref:`c++-extensions`, for extensions that apply *only* to C++. + +Some features that are in ISO C99 but not C90 or C++ are also, as +extensions, accepted by GCC in C90 mode and in C++. + +.. toctree:: + :maxdepth: 2 + + extensions-to-the-c-language-family/statements-and-declarations-in-expressions + extensions-to-the-c-language-family/locally-declared-labels + extensions-to-the-c-language-family/labels-as-values + extensions-to-the-c-language-family/nested-functions + extensions-to-the-c-language-family/nonlocal-gotos + extensions-to-the-c-language-family/constructing-function-calls + extensions-to-the-c-language-family/referring-to-a-type-with-typeof + extensions-to-the-c-language-family/conditionals-with-omitted-operands + extensions-to-the-c-language-family/128-bit-integers + extensions-to-the-c-language-family/double-word-integers + extensions-to-the-c-language-family/complex-numbers + extensions-to-the-c-language-family/additional-floating-types + extensions-to-the-c-language-family/half-precision-floating-point + extensions-to-the-c-language-family/decimal-floating-types + extensions-to-the-c-language-family/hex-floats + extensions-to-the-c-language-family/fixed-point-types + extensions-to-the-c-language-family/named-address-spaces + extensions-to-the-c-language-family/arrays-of-length-zero + extensions-to-the-c-language-family/structures-with-no-members + extensions-to-the-c-language-family/arrays-of-variable-length + extensions-to-the-c-language-family/macros-with-a-variable-number-of-arguments + extensions-to-the-c-language-family/slightly-looser-rules-for-escaped-newlines + extensions-to-the-c-language-family/non-lvalue-arrays-may-have-subscripts + extensions-to-the-c-language-family/arithmetic-on-void-and-function-pointers + extensions-to-the-c-language-family/pointer-arguments-in-variadic-functions + extensions-to-the-c-language-family/pointers-to-arrays-with-qualifiers-work-as-expected + extensions-to-the-c-language-family/non-constant-initializers + extensions-to-the-c-language-family/compound-literals + extensions-to-the-c-language-family/designated-initializers + extensions-to-the-c-language-family/case-ranges + extensions-to-the-c-language-family/cast-to-a-union-type + extensions-to-the-c-language-family/mixed-declarations-labels-and-code + extensions-to-the-c-language-family/declaring-attributes-of-functions + extensions-to-the-c-language-family/specifying-attributes-of-variables + extensions-to-the-c-language-family/specifying-attributes-of-types + extensions-to-the-c-language-family/label-attributes + extensions-to-the-c-language-family/enumerator-attributes + extensions-to-the-c-language-family/statement-attributes + extensions-to-the-c-language-family/attribute-syntax + extensions-to-the-c-language-family/prototypes-and-old-style-function-definitions + extensions-to-the-c-language-family/c++-style-comments + extensions-to-the-c-language-family/dollar-signs-in-identifier-names + extensions-to-the-c-language-family/the-character-esc-in-constants + extensions-to-the-c-language-family/determining-the-alignment-of-functions-types-or-variables + extensions-to-the-c-language-family/an-inline-function-is-as-fast-as-a-macro + extensions-to-the-c-language-family/when-is-a-volatile-object-accessed + extensions-to-the-c-language-family/how-to-use-inline-assembly-language-in-c-code + extensions-to-the-c-language-family/alternate-keywords + extensions-to-the-c-language-family/incomplete-enum-types + extensions-to-the-c-language-family/function-names-as-strings + extensions-to-the-c-language-family/getting-the-return-or-frame-address-of-a-function + extensions-to-the-c-language-family/using-vector-instructions-through-built-in-functions + extensions-to-the-c-language-family/support-for-offsetof + extensions-to-the-c-language-family/legacy-sync-built-in-functions-for-atomic-memory-access + extensions-to-the-c-language-family/built-in-functions-for-memory-model-aware-atomic-operations + extensions-to-the-c-language-family/built-in-functions-to-perform-arithmetic-with-overflow-checking + extensions-to-the-c-language-family/x86-specific-memory-model-extensions-for-transactional-memory + extensions-to-the-c-language-family/object-size-checking-built-in-functions + extensions-to-the-c-language-family/other-built-in-functions-provided-by-gcc + extensions-to-the-c-language-family/target-builtins + extensions-to-the-c-language-family/format-checks-specific-to-particular-target-machines + extensions-to-the-c-language-family/pragmas-accepted-by-gcc + extensions-to-the-c-language-family/unnamed-structure-and-union-fields + extensions-to-the-c-language-family/thread-local-storage + extensions-to-the-c-language-family/binary-constants-using-the-0b-prefix \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/128-bit-integers.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/128-bit-integers.rst new file mode 100644 index 00000000000..07376ba20ac --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/128-bit-integers.rst @@ -0,0 +1,18 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: __int128 data types + +.. _int128: + +128-bit Integers +**************** + +As an extension the integer scalar type ``__int128`` is supported for +targets which have an integer mode wide enough to hold 128 bits. +Simply write ``__int128`` for a signed 128-bit integer, or +``unsigned __int128`` for an unsigned 128-bit integer. There is no +support in GCC for expressing an integer constant of type ``__int128`` +for targets with ``long long`` integer less than 128 bits wide. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/additional-floating-types.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/additional-floating-types.rst new file mode 100644 index 00000000000..0746867bd42 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/additional-floating-types.rst @@ -0,0 +1,83 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: additional floating types, _Floatn data types, _Floatnx data types, __float80 data type, __float128 data type, __ibm128 data type, w floating point suffix, q floating point suffix, W floating point suffix, Q floating point suffix + +.. _floating-types: + +Additional Floating Types +************************* + +ISO/IEC TS 18661-3:2015 defines C support for additional floating +types ``_Floatn`` and ``_Floatnx``, and GCC supports +these type names; the set of types supported depends on the target +architecture. These types are not supported when compiling C++. +Constants with these types use suffixes ``fn`` or +``Fn`` and ``fnx`` or ``Fnx``. These type +names can be used together with ``_Complex`` to declare complex +types. + +As an extension, GNU C and GNU C++ support additional floating +types, which are not supported by all targets. + +* ``__float128`` is available on i386, x86_64, IA-64, and + hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable + the vector scalar (VSX) instruction set. ``__float128`` supports + the 128-bit floating type. On i386, x86_64, PowerPC, and IA-64 + other than HP-UX, ``__float128`` is an alias for ``_Float128``. + On hppa and IA-64 HP-UX, ``__float128`` is an alias for ``long + double``. + +* ``__float80`` is available on the i386, x86_64, and IA-64 + targets, and supports the 80-bit (``XFmode``) floating type. It is + an alias for the type name ``_Float64x`` on these targets. + +* ``__ibm128`` is available on PowerPC targets, and provides + access to the IBM extended double format which is the current format + used for ``long double``. When ``long double`` transitions to + ``__float128`` on PowerPC in the future, ``__ibm128`` will remain + for use in conversions between the two types. + +Support for these additional types includes the arithmetic operators: +add, subtract, multiply, divide; unary arithmetic operators; +relational operators; equality operators; and conversions to and from +integer and other floating types. Use a suffix :samp:`w` or :samp:`W` +in a literal constant of type ``__float80`` or type +``__ibm128``. Use a suffix :samp:`q` or :samp:`Q` for ``__float128``. + +In order to use ``_Float128``, ``__float128``, and ``__ibm128`` +on PowerPC Linux systems, you must use the :option:`-mfloat128` option. It is +expected in future versions of GCC that ``_Float128`` and ``__float128`` +will be enabled automatically. + +The ``_Float128`` type is supported on all systems where +``__float128`` is supported or where ``long double`` has the +IEEE binary128 format. The ``_Float64x`` type is supported on all +systems where ``__float128`` is supported. The ``_Float32`` +type is supported on all systems supporting IEEE binary32; the +``_Float64`` and ``_Float32x`` types are supported on all systems +supporting IEEE binary64. The ``_Float16`` type is supported on AArch64 +systems by default, on ARM systems when the IEEE format for 16-bit +floating-point types is selected with :option:`-mfp16-format=ieee` and, +for both C and C++, on x86 systems with SSE2 enabled. GCC does not currently +support ``_Float128x`` on any systems. + +On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex +types using the corresponding internal complex type, ``XCmode`` for +``__float80`` type and ``TCmode`` for ``__float128`` type: + +.. code-block:: c++ + + typedef _Complex float __attribute__((mode(TC))) _Complex128; + typedef _Complex float __attribute__((mode(XC))) _Complex80; + +On the PowerPC Linux VSX targets, you can declare complex types using +the corresponding internal complex type, ``KCmode`` for +``__float128`` type and ``ICmode`` for ``__ibm128`` type: + +.. code-block:: c++ + + typedef _Complex float __attribute__((mode(KC))) _Complex_float128; + typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128; \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/alternate-keywords.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/alternate-keywords.rst new file mode 100644 index 00000000000..0abcf0fbc07 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/alternate-keywords.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: alternate keywords, keywords, alternate + +.. _alternate-keywords: + +Alternate Keywords +****************** + +:option:`-ansi` and the various :option:`-std` options disable certain +keywords. This causes trouble when you want to use GNU C extensions, or +a general-purpose header file that should be usable by all programs, +including ISO C programs. The keywords ``asm``, ``typeof`` and +``inline`` are not available in programs compiled with +:option:`-ansi` or :option:`-std` (although ``inline`` can be used in a +program compiled with :option:`-std=c99` or a later standard). The +ISO C99 keyword +``restrict`` is only available when :option:`-std=gnu99` (which will +eventually be the default) or :option:`-std=c99` (or the equivalent +:option:`-std=iso9899:1999`), or an option for a later standard +version, is used. + +The way to solve these problems is to put :samp:`__` at the beginning and +end of each problematical keyword. For example, use ``__asm__`` +instead of ``asm``, and ``__inline__`` instead of ``inline``. + +Other C compilers won't accept these alternative keywords; if you want to +compile with another compiler, you can define the alternate keywords as +macros to replace them with the customary keywords. It looks like this: + +.. code-block:: c++ + + #ifndef __GNUC__ + #define __asm__ asm + #endif + +.. index:: __extension__, pedantic + +:option:`-pedantic` and other options cause warnings for many GNU C extensions. +You can +prevent such warnings within one expression by writing +``__extension__`` before the expression. ``__extension__`` has no +effect aside from this. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/an-inline-function-is-as-fast-as-a-macro.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/an-inline-function-is-as-fast-as-a-macro.rst new file mode 100644 index 00000000000..ad82c416788 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/an-inline-function-is-as-fast-as-a-macro.rst @@ -0,0 +1,126 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: inline functions, integrating function code, open coding, macros, inline alternative + +.. _inline: + +An Inline Function is As Fast As a Macro +**************************************** + +By declaring a function inline, you can direct GCC to make +calls to that function faster. One way GCC can achieve this is to +integrate that function's code into the code for its callers. This +makes execution faster by eliminating the function-call overhead; in +addition, if any of the actual argument values are constant, their +known values may permit simplifications at compile time so that not +all of the inline function's code needs to be included. The effect on +code size is less predictable; object code may be larger or smaller +with function inlining, depending on the particular case. You can +also direct GCC to try to integrate all 'simple enough' functions +into their callers with the option :option:`-finline-functions`. + +GCC implements three different semantics of declaring a function +inline. One is available with :option:`-std=gnu89` or +:option:`-fgnu89-inline` or when :gcc-attr:`gnu_inline` attribute is present +on all inline declarations, another when +:option:`-std=c99`, +:option:`-std=gnu99` or an option for a later C version is used +(without :option:`-fgnu89-inline`), and the third +is used when compiling C++. + +To declare a function inline, use the ``inline`` keyword in its +declaration, like this: + +.. code-block:: c++ + + static inline int + inc (int *a) + { + return (*a)++; + } + +If you are writing a header file to be included in ISO C90 programs, write +``__inline__`` instead of ``inline``. See :ref:`alternate-keywords`. + +The three types of inlining behave similarly in two important cases: +when the ``inline`` keyword is used on a ``static`` function, +like the example above, and when a function is first declared without +using the ``inline`` keyword and then is defined with +``inline``, like this: + +.. code-block:: c++ + + extern int inc (int *a); + inline int + inc (int *a) + { + return (*a)++; + } + +In both of these common cases, the program behaves the same as if you +had not used the ``inline`` keyword, except for its speed. + +.. index:: inline functions, omission of, fkeep-inline-functions + +When a function is both inline and ``static``, if all calls to the +function are integrated into the caller, and the function's address is +never used, then the function's own assembler code is never referenced. +In this case, GCC does not actually output assembler code for the +function, unless you specify the option :option:`-fkeep-inline-functions`. +If there is a nonintegrated call, then the function is compiled to +assembler code as usual. The function must also be compiled as usual if +the program refers to its address, because that cannot be inlined. + +.. index:: Winline + +Note that certain usages in a function definition can make it unsuitable +for inline substitution. Among these usages are: variadic functions, +use of ``alloca``, use of computed goto (see :ref:`labels-as-values`), +use of nonlocal goto, use of nested functions, use of ``setjmp``, use +of ``__builtin_longjmp`` and use of ``__builtin_return`` or +``__builtin_apply_args``. Using :option:`-Winline` warns when a +function marked ``inline`` could not be substituted, and gives the +reason for the failure. + +.. index:: automatic inline for C++ member fns, inline automatic for C++ member fns, member fns, automatically inline, C++ member fns, automatically inline, fno-default-inline + +As required by ISO C++, GCC considers member functions defined within +the body of a class to be marked inline even if they are +not explicitly declared with the ``inline`` keyword. You can +override this with :option:`-fno-default-inline` ; see :ref:`c++-dialect-options`. + +GCC does not inline any functions when not optimizing unless you specify +the :samp:`always_inline` attribute for the function, like this: + +.. code-block:: c++ + + /* Prototype. */ + inline void foo (const char) __attribute__((always_inline)); + +The remainder of this section is specific to GNU C90 inlining. + +.. index:: non-static inline function + +When an inline function is not ``static``, then the compiler must assume +that there may be calls from other source files; since a global symbol can +be defined only once in any program, the function must not be defined in +the other source files, so the calls therein cannot be integrated. +Therefore, a non- ``static`` inline function is always compiled on its +own in the usual fashion. + +If you specify both ``inline`` and ``extern`` in the function +definition, then the definition is used only for inlining. In no case +is the function compiled on its own, not even if you refer to its +address explicitly. Such an address becomes an external reference, as +if you had only declared the function, and had not defined it. + +This combination of ``inline`` and ``extern`` has almost the +effect of a macro. The way to use it is to put a function definition in +a header file with these keywords, and put another copy of the +definition (lacking ``inline`` and ``extern``) in a library file. +The definition in the header file causes most calls to the function +to be inlined. If any uses of the function remain, they refer to +the single copy in the library. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/arithmetic-on-void-and-function-pointers.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/arithmetic-on-void-and-function-pointers.rst new file mode 100644 index 00000000000..dc966981259 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/arithmetic-on-void-and-function-pointers.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: void pointers, arithmetic, void, size of pointer to, function pointers, arithmetic, function, size of pointer to + +.. _pointer-arith: + +Arithmetic on void- and Function-Pointers +***************************************** + +In GNU C, addition and subtraction operations are supported on pointers to +``void`` and on pointers to functions. This is done by treating the +size of a ``void`` or of a function as 1. + +A consequence of this is that ``sizeof`` is also allowed on ``void`` +and on function types, and returns 1. + +.. index:: Wpointer-arith + +The option :option:`-Wpointer-arith` requests a warning if these extensions +are used. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/arrays-of-length-zero.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/arrays-of-length-zero.rst new file mode 100644 index 00000000000..70142065814 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/arrays-of-length-zero.rst @@ -0,0 +1,111 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: arrays of length zero, zero-length arrays, length-zero arrays, flexible array members + +.. _zero-length: + +Arrays of Length Zero +********************* + +Declaring zero-length arrays is allowed in GNU C as an extension. +A zero-length array can be useful as the last element of a structure +that is really a header for a variable-length object: + +.. code-block:: c++ + + struct line { + int length; + char contents[0]; + }; + + struct line *thisline = (struct line *) + malloc (sizeof (struct line) + this_length); + thisline->length = this_length; + +Although the size of a zero-length array is zero, an array member of +this kind may increase the size of the enclosing type as a result of tail +padding. The offset of a zero-length array member from the beginning +of the enclosing structure is the same as the offset of an array with +one or more elements of the same type. The alignment of a zero-length +array is the same as the alignment of its elements. + +Declaring zero-length arrays in other contexts, including as interior +members of structure objects or as non-member objects, is discouraged. +Accessing elements of zero-length arrays declared in such contexts is +undefined and may be diagnosed. + +In the absence of the zero-length array extension, in ISO C90 +the ``contents`` array in the example above would typically be declared +to have a single element. Unlike a zero-length array which only contributes +to the size of the enclosing structure for the purposes of alignment, +a one-element array always occupies at least as much space as a single +object of the type. Although using one-element arrays this way is +discouraged, GCC handles accesses to trailing one-element array members +analogously to zero-length arrays. + +The preferred mechanism to declare variable-length types like +``struct line`` above is the ISO C99 :dfn:`flexible array member`, +with slightly different syntax and semantics: + +* Flexible array members are written as ``contents[]`` without + the ``0``. + +* Flexible array members have incomplete type, and so the ``sizeof`` + operator may not be applied. As a quirk of the original implementation + of zero-length arrays, ``sizeof`` evaluates to zero. + +* Flexible array members may only appear as the last member of a + ``struct`` that is otherwise non-empty. + +* A structure containing a flexible array member, or a union containing + such a structure (possibly recursively), may not be a member of a + structure or an element of an array. (However, these uses are + permitted by GCC as extensions.) + +Non-empty initialization of zero-length +arrays is treated like any case where there are more initializer +elements than the array holds, in that a suitable warning about 'excess +elements in array' is given, and the excess elements (all of them, in +this case) are ignored. + +GCC allows static initialization of flexible array members. +This is equivalent to defining a new structure containing the original +structure followed by an array of sufficient size to contain the data. +E.g. in the following, ``f1`` is constructed as if it were declared +like ``f2``. + +.. code-block:: c++ + + struct f1 { + int x; int y[]; + } f1 = { 1, { 2, 3, 4 } }; + + struct f2 { + struct f1 f1; int data[3]; + } f2 = { { 1 }, { 2, 3, 4 } }; + +The convenience of this extension is that ``f1`` has the desired +type, eliminating the need to consistently refer to ``f2.f1``. + +This has symmetry with normal static arrays, in that an array of +unknown size is also written with ``[]``. + +Of course, this extension only makes sense if the extra data comes at +the end of a top-level object, as otherwise we would be overwriting +data at subsequent offsets. To avoid undue complication and confusion +with initialization of deeply nested arrays, we simply disallow any +non-empty initialization except when the structure is the top-level +object. For example: + +.. code-block:: c++ + + struct foo { int x; int y[]; }; + struct bar { struct foo z; }; + + struct foo a = { 1, { 2, 3, 4 } }; // Valid. + struct bar b = { { 1, { 2, 3, 4 } } }; // Invalid. + struct bar c = { { 1, { } } }; // Valid. + struct foo d[1] = { { 1, { 2, 3, 4 } } }; // Invalid. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/arrays-of-variable-length.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/arrays-of-variable-length.rst new file mode 100644 index 00000000000..c0d0c12d3bd --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/arrays-of-variable-length.rst @@ -0,0 +1,99 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: variable-length arrays, arrays of variable length, VLAs + +.. _variable-length: + +Arrays of Variable Length +************************* + +Variable-length automatic arrays are allowed in ISO C99, and as an +extension GCC accepts them in C90 mode and in C++. These arrays are +declared like any other automatic arrays, but with a length that is not +a constant expression. The storage is allocated at the point of +declaration and deallocated when the block scope containing the declaration +exits. For +example: + +.. code-block:: c++ + + FILE * + concat_fopen (char *s1, char *s2, char *mode) + { + char str[strlen (s1) + strlen (s2) + 1]; + strcpy (str, s1); + strcat (str, s2); + return fopen (str, mode); + } + +.. index:: scope of a variable length array, variable-length array scope, deallocating variable length arrays + +Jumping or breaking out of the scope of the array name deallocates the +storage. Jumping into the scope is not allowed; you get an error +message for it. + +.. index:: variable-length array in a structure + +As an extension, GCC accepts variable-length arrays as a member of +a structure or a union. For example: + +.. code-block:: c++ + + void + foo (int n) + { + struct S { int x[n]; }; + } + +.. index:: alloca vs variable-length arrays + +You can use the function ``alloca`` to get an effect much like +variable-length arrays. The function ``alloca`` is available in +many other C implementations (but not in all). On the other hand, +variable-length arrays are more elegant. + +There are other differences between these two methods. Space allocated +with ``alloca`` exists until the containing *function* returns. +The space for a variable-length array is deallocated as soon as the array +name's scope ends, unless you also use ``alloca`` in this scope. + +You can also use variable-length arrays as arguments to functions: + +.. code-block:: c++ + + struct entry + tester (int len, char data[len][len]) + { + /* ... */ + } + +The length of an array is computed once when the storage is allocated +and is remembered for the scope of the array in case you access it with +``sizeof``. + +If you want to pass the array first and the length afterward, you can +use a forward declaration in the parameter list---another GNU extension. + +.. code-block:: c++ + + struct entry + tester (int len; char data[len][len], int len) + { + /* ... */ + } + +.. index:: parameter forward declaration + +The :samp:`int len` before the semicolon is a :dfn:`parameter forward +declaration`, and it serves the purpose of making the name ``len`` +known when the declaration of ``data`` is parsed. + +You can write any number of such parameter forward declarations in the +parameter list. They can be separated by commas or semicolons, but the +last one must end with a semicolon, which is followed by the 'real' +parameter declarations. Each forward declaration must match a 'real' +declaration in parameter name and data type. ISO C99 does not support +parameter forward declarations. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/attribute-syntax.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/attribute-syntax.rst new file mode 100644 index 00000000000..f8b52e5dd0a --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/attribute-syntax.rst @@ -0,0 +1,259 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: attribute syntax + +.. _attribute-syntax: + +Attribute Syntax +**************** + +This section describes the syntax with which ``__attribute__`` may be +used, and the constructs to which attribute specifiers bind, for the C +language. Some details may vary for C++ and Objective-C. Because of +infelicities in the grammar for attributes, some forms described here +may not be successfully parsed in all cases. + +There are some problems with the semantics of attributes in C++. For +example, there are no manglings for attributes, although they may affect +code generation, so problems may arise when attributed types are used in +conjunction with templates or overloading. Similarly, ``typeid`` +does not distinguish between types with different attributes. Support +for attributes in C++ may be restricted in future to attributes on +declarations only, but not on nested declarators. + +See :ref:`function-attributes`, for details of the semantics of attributes +applying to functions. See :ref:`variable-attributes`, for details of the +semantics of attributes applying to variables. See :ref:`type-attributes`, +for details of the semantics of attributes applying to structure, union +and enumerated types. +See :ref:`label-attributes`, for details of the semantics of attributes +applying to labels. +See :ref:`enumerator-attributes`, for details of the semantics of attributes +applying to enumerators. +See :ref:`statement-attributes`, for details of the semantics of attributes +applying to statements. + +An :dfn:`attribute specifier` is of the form +``__attribute__ ((attribute-list))``. An :dfn:`attribute list` +is a possibly empty comma-separated sequence of :dfn:`attributes`, where +each attribute is one of the following: + +* Empty. Empty attributes are ignored. + +* An attribute name + (which may be an identifier such as :fn-attr:`unused`, or a reserved + word such as :fn-attr:`const`). + +* An attribute name followed by a parenthesized list of + parameters for the attribute. + These parameters take one of the following forms: + + * An identifier. For example, ``mode`` attributes use this form. + + * An identifier followed by a comma and a non-empty comma-separated list + of expressions. For example, ``format`` attributes use this form. + + * A possibly empty comma-separated list of expressions. For example, + ``format_arg`` attributes use this form with the list being a single + integer constant expression, and ``alias`` attributes use this form + with the list being a single string constant. + +An :dfn:`attribute specifier list` is a sequence of one or more attribute +specifiers, not separated by any other tokens. + +You may optionally specify attribute names with :samp:`__` +preceding and following the name. +This allows you to use them in header files without +being concerned about a possible macro of the same name. For example, +you may use the attribute name ``__noreturn__`` instead of :fn-attr:`noreturn`. + +Label Attributes +^^^^^^^^^^^^^^^^ + +In GNU C, an attribute specifier list may appear after the colon following a +label, other than a ``case`` or ``default`` label. GNU C++ only permits +attributes on labels if the attribute specifier is immediately +followed by a semicolon (i.e., the label applies to an empty +statement). If the semicolon is missing, C++ label attributes are +ambiguous, as it is permissible for a declaration, which could begin +with an attribute list, to be labelled in C++. Declarations cannot be +labelled in C90 or C99, so the ambiguity does not arise there. + +Enumerator Attributes +^^^^^^^^^^^^^^^^^^^^^ + +In GNU C, an attribute specifier list may appear as part of an enumerator. +The attribute goes after the enumeration constant, before ``=``, if +present. The optional attribute in the enumerator appertains to the +enumeration constant. It is not possible to place the attribute after +the constant expression, if present. + +Statement Attributes +^^^^^^^^^^^^^^^^^^^^ + +In GNU C, an attribute specifier list may appear as part of a null +statement. The attribute goes before the semicolon. + +Type Attributes +^^^^^^^^^^^^^^^ + +An attribute specifier list may appear as part of a ``struct``, +``union`` or ``enum`` specifier. It may go either immediately +after the ``struct``, ``union`` or ``enum`` keyword, or after +the closing brace. The former syntax is preferred. +Where attribute specifiers follow the closing brace, they are considered +to relate to the structure, union or enumerated type defined, not to any +enclosing declaration the type specifier appears in, and the type +defined is not complete until after the attribute specifiers. + +.. Otherwise, there would be the following problems: a shift/reduce + +.. conflict between attributes binding the struct/union/enum and + +.. binding to the list of specifiers/qualifiers; and "aligned" + +.. attributes could use sizeof for the structure, but the size could be + +.. changed later by "packed" attributes. + +All other attributes +^^^^^^^^^^^^^^^^^^^^ + +Otherwise, an attribute specifier appears as part of a declaration, +counting declarations of unnamed parameters and type names, and relates +to that declaration (which may be nested in another declaration, for +example in the case of a parameter declaration), or to a particular declarator +within a declaration. Where an +attribute specifier is applied to a parameter declared as a function or +an array, it should apply to the function or array rather than the +pointer to which the parameter is implicitly converted, but this is not +yet correctly implemented. + +Any list of specifiers and qualifiers at the start of a declaration may +contain attribute specifiers, whether or not such a list may in that +context contain storage class specifiers. (Some attributes, however, +are essentially in the nature of storage class specifiers, and only make +sense where storage class specifiers may be used; for example, +``section``.) There is one necessary limitation to this syntax: the +first old-style parameter declaration in a function definition cannot +begin with an attribute specifier, because such an attribute applies to +the function instead by syntax described below (which, however, is not +yet implemented in this case). In some other cases, attribute +specifiers are permitted by this grammar but not yet supported by the +compiler. All attribute specifiers in this place relate to the +declaration as a whole. In the obsolescent usage where a type of +``int`` is implied by the absence of type specifiers, such a list of +specifiers and qualifiers may be an attribute specifier list with no +other specifiers or qualifiers. + +At present, the first parameter in a function prototype must have some +type specifier that is not an attribute specifier; this resolves an +ambiguity in the interpretation of ``void f(int +(__attribute__((foo)) x))``, but is subject to change. At present, if +the parentheses of a function declarator contain only attributes then +those attributes are ignored, rather than yielding an error or warning +or implying a single parameter of type int, but this is subject to +change. + +An attribute specifier list may appear immediately before a declarator +(other than the first) in a comma-separated list of declarators in a +declaration of more than one identifier using a single list of +specifiers and qualifiers. Such attribute specifiers apply +only to the identifier before whose declarator they appear. For +example, in + +.. code-block:: c++ + + __attribute__((noreturn)) void d0 (void), + __attribute__((format(printf, 1, 2))) d1 (const char *, ...), + d2 (void); + +the :fn-attr:`noreturn` attribute applies to all the functions +declared; the ``format`` attribute only applies to ``d1``. + +An attribute specifier list may appear immediately before the comma, +``=`` or semicolon terminating the declaration of an identifier other +than a function definition. Such attribute specifiers apply +to the declared object or function. Where an +assembler name for an object or function is specified (see :ref:`asm-labels`), the attribute must follow the ``asm`` +specification. + +An attribute specifier list may, in future, be permitted to appear after +the declarator in a function definition (before any old-style parameter +declarations or the function body). + +Attribute specifiers may be mixed with type qualifiers appearing inside +the ``[]`` of a parameter array declarator, in the C99 construct by +which such qualifiers are applied to the pointer to which the array is +implicitly converted. Such attribute specifiers apply to the pointer, +not to the array, but at present this is not implemented and they are +ignored. + +An attribute specifier list may appear at the start of a nested +declarator. At present, there are some limitations in this usage: the +attributes correctly apply to the declarator, but for most individual +attributes the semantics this implies are not implemented. +When attribute specifiers follow the ``*`` of a pointer +declarator, they may be mixed with any type qualifiers present. +The following describes the formal semantics of this syntax. It makes the +most sense if you are familiar with the formal specification of +declarators in the ISO C standard. + +Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration ``T +D1``, where ``T`` contains declaration specifiers that specify a type +:samp:`{Type}` (such as ``int``) and ``D1`` is a declarator that +contains an identifier :samp:`{ident}`. The type specified for :samp:`{ident}` +for derived declarators whose type does not include an attribute +specifier is as in the ISO C standard. + +If ``D1`` has the form ``( attribute-specifier-list D )``, +and the declaration ``T D`` specifies the type +' :samp:`{derived-declarator-type-list}` :samp:`{Type}` ' for :samp:`{ident}`, then +``T D1`` specifies the type ' :samp:`{derived-declarator-type-list}` +:samp:`{attribute-specifier-list}` :samp:`{Type}` ' for :samp:`{ident}`. + +If ``D1`` has the form ``* +type-qualifier-and-attribute-specifier-list D``, and the +declaration ``T D`` specifies the type +' :samp:`{derived-declarator-type-list}` :samp:`{Type}` ' for :samp:`{ident}`, then +``T D1`` specifies the type ' :samp:`{derived-declarator-type-list}` +:samp:`{type-qualifier-and-attribute-specifier-list}` pointer to :samp:`{Type}` ' for +:samp:`{ident}`. + +For example, + +.. code-block:: c++ + + void (__attribute__((noreturn)) ****f) (void); + +specifies the type 'pointer to pointer to pointer to pointer to +non-returning function returning ``void`` '. As another example, + +.. code-block:: c++ + + char *__attribute__((aligned(8))) *f; + +specifies the type 'pointer to 8-byte-aligned pointer to ``char`` '. +Note again that this does not work with most attributes; for example, +the usage of :samp:`aligned` and :samp:`noreturn` attributes given above +is not yet supported. + +For compatibility with existing code written for compiler versions that +did not implement attributes on nested declarators, some laxity is +allowed in the placing of attributes. If an attribute that only applies +to types is applied to a declaration, it is treated as applying to +the type of that declaration. If an attribute that only applies to +declarations is applied to the type of a declaration, it is treated +as applying to that declaration; and, for compatibility with code +placing the attributes immediately before the identifier declared, such +an attribute applied to a function return type is treated as +applying to the function type, and such an attribute applied to an array +element type is treated as applying to the array type. If an +attribute that only applies to function types is applied to a +pointer-to-function type, it is treated as applying to the pointer +target type; if such an attribute is applied to a function return type +that is not a pointer-to-function type, it is treated as applying +to the function type. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/binary-constants-using-the-0b-prefix.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/binary-constants-using-the-0b-prefix.rst new file mode 100644 index 00000000000..640523abd6e --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/binary-constants-using-the-0b-prefix.rst @@ -0,0 +1,29 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Binary constants using the 0b prefix + +.. _binary-constants: + +Binary Constants using the 0b Prefix +************************************ + +Integer constants can be written as binary constants, consisting of a +sequence of :samp:`0` and :samp:`1` digits, prefixed by :samp:`0b` or +:samp:`0B`. This is particularly useful in environments that operate a +lot on the bit level (like microcontrollers). + +The following statements are identical: + +.. code-block:: c++ + + i = 42; + i = 0x2a; + i = 052; + i = 0b101010; + +The type of these constants follows the same rules as for octal or +hexadecimal integer constants, so suffixes like :samp:`L` or :samp:`UL` +can be applied. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/built-in-functions-for-memory-model-aware-atomic-operations.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/built-in-functions-for-memory-model-aware-atomic-operations.rst new file mode 100644 index 00000000000..fcabf48e213 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/built-in-functions-for-memory-model-aware-atomic-operations.rst @@ -0,0 +1,290 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _atomic-builtins: + +Built-in Functions for Memory Model Aware Atomic Operations +*********************************************************** + +The following built-in functions approximately match the requirements +for the C++11 memory model. They are all +identified by being prefixed with :samp:`__atomic` and most are +overloaded so that they work with multiple types. + +These functions are intended to replace the legacy :samp:`__sync` +builtins. The main difference is that the memory order that is requested +is a parameter to the functions. New code should always use the +:samp:`__atomic` builtins rather than the :samp:`__sync` builtins. + +Note that the :samp:`__atomic` builtins assume that programs will +conform to the C++11 memory model. In particular, they assume +that programs are free of data races. See the C++11 standard for +detailed requirements. + +The :samp:`__atomic` builtins can be used with any integral scalar or +pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral +types are also allowed if :samp:`__int128` (see :ref:`int128`) is +supported by the architecture. + +The four non-arithmetic functions (load, store, exchange, and +compare_exchange) all have a generic version as well. This generic +version works on any data type. It uses the lock-free built-in function +if the specific data type size makes that possible; otherwise, an +external call is left to be resolved at run time. This external call is +the same format with the addition of a :samp:`size_t` parameter inserted +as the first parameter indicating the size of the object being pointed to. +All objects must be the same size. + +There are 6 different memory orders that can be specified. These map +to the C++11 memory orders with the same names, see the C++11 standard +or the `GCC wiki +on atomic synchronization `_ for detailed definitions. Individual +targets may also support additional memory orders for use on specific +architectures. Refer to the target documentation for details of +these. + +An atomic operation can both constrain code motion and +be mapped to hardware instructions for synchronization between threads +(e.g., a fence). To which extent this happens is controlled by the +memory orders, which are listed here in approximately ascending order of +strength. The description of each memory order is only meant to roughly +illustrate the effects and is not a specification; see the C++11 +memory model for precise semantics. + +``__ATOMIC_RELAXED`` + Implies no inter-thread ordering constraints. + +``__ATOMIC_CONSUME`` + This is currently implemented using the stronger ``__ATOMIC_ACQUIRE`` + memory order because of a deficiency in C++11's semantics for + ``memory_order_consume``. + +``__ATOMIC_ACQUIRE`` + Creates an inter-thread happens-before constraint from the release (or + stronger) semantic store to this acquire load. Can prevent hoisting + of code to before the operation. + +``__ATOMIC_RELEASE`` + Creates an inter-thread happens-before constraint to acquire (or stronger) + semantic loads that read from this release store. Can prevent sinking + of code to after the operation. + +``__ATOMIC_ACQ_REL`` + Combines the effects of both ``__ATOMIC_ACQUIRE`` and + ``__ATOMIC_RELEASE``. + +``__ATOMIC_SEQ_CST`` + Enforces total ordering with all other ``__ATOMIC_SEQ_CST`` operations. + +Note that in the C++11 memory model, *fences* (e.g., +:samp:`__atomic_thread_fence`) take effect in combination with other +atomic operations on specific memory locations (e.g., atomic loads); +operations on specific memory locations do not necessarily affect other +operations in the same way. + +Target architectures are encouraged to provide their own patterns for +each of the atomic built-in functions. If no target is provided, the original +non-memory model set of :samp:`__sync` atomic built-in functions are +used, along with any required synchronization fences surrounding it in +order to achieve the proper behavior. Execution in this case is subject +to the same restrictions as those built-in functions. + +If there is no pattern or mechanism to provide a lock-free instruction +sequence, a call is made to an external routine with the same parameters +to be resolved at run time. + +When implementing patterns for these built-in functions, the memory order +parameter can be ignored as long as the pattern implements the most +restrictive ``__ATOMIC_SEQ_CST`` memory order. Any of the other memory +orders execute correctly with this memory order but they may not execute as +efficiently as they could with a more appropriate implementation of the +relaxed requirements. + +Note that the C++11 standard allows for the memory order parameter to be +determined at run time rather than at compile time. These built-in +functions map any run-time value to ``__ATOMIC_SEQ_CST`` rather +than invoke a runtime library call or inline a switch statement. This is +standard compliant, safe, and the simplest approach for now. + +The memory order parameter is a signed int, but only the lower 16 bits are +reserved for the memory order. The remainder of the signed int is reserved +for target use and should be 0. Use of the predefined atomic values +ensures proper usage. + +.. function:: type __atomic_load_n (type *ptr, int memorder) + + This built-in function implements an atomic load operation. It returns the + contents of ``*ptr``. + + The valid memory order variants are + ``__ATOMIC_RELAXED``, ``__ATOMIC_SEQ_CST``, ``__ATOMIC_ACQUIRE``, + and ``__ATOMIC_CONSUME``. + +.. function:: void __atomic_load (type *ptr, type *ret, int memorder) + + This is the generic version of an atomic load. It returns the + contents of ``*ptr`` in ``*ret``. + +.. function:: void __atomic_store_n (type *ptr, type val, int memorder) + + This built-in function implements an atomic store operation. It writes + ``val`` into ``*ptr``. + + The valid memory order variants are + ``__ATOMIC_RELAXED``, ``__ATOMIC_SEQ_CST``, and ``__ATOMIC_RELEASE``. + +.. function:: void __atomic_store (type *ptr, type *val, int memorder) + + This is the generic version of an atomic store. It stores the value + of ``*val`` into ``*ptr``. + +.. function:: type __atomic_exchange_n (type *ptr, type val, int memorder) + + This built-in function implements an atomic exchange operation. It writes + :samp:`{val}` into ``*ptr``, and returns the previous contents of + ``*ptr``. + + All memory order variants are valid. + +.. function:: void __atomic_exchange (type *ptr, type *val, type *ret, int memorder) + + This is the generic version of an atomic exchange. It stores the + contents of ``*val`` into ``*ptr``. The original value + of ``*ptr`` is copied into ``*ret``. + +.. function:: bool __atomic_compare_exchange_n (type *ptr, type *expected, type desired, bool weak, int success_memorder, int failure_memorder) + + This built-in function implements an atomic compare and exchange operation. + This compares the contents of ``*ptr`` with the contents of + ``*expected``. If equal, the operation is a *read-modify-write* + operation that writes :samp:`{desired}` into ``*ptr``. If they are not + equal, the operation is a *read* and the current contents of + ``*ptr`` are written into ``*expected``. :samp:`{weak}` is ``true`` + for weak compare_exchange, which may fail spuriously, and ``false`` for + the strong variation, which never fails spuriously. Many targets + only offer the strong variation and ignore the parameter. When in doubt, use + the strong variation. + + If :samp:`{desired}` is written into ``*ptr`` then ``true`` is returned + and memory is affected according to the + memory order specified by :samp:`{success_memorder}`. There are no + restrictions on what memory order can be used here. + + Otherwise, ``false`` is returned and memory is affected according + to :samp:`{failure_memorder}`. This memory order cannot be + ``__ATOMIC_RELEASE`` nor ``__ATOMIC_ACQ_REL``. It also cannot be a + stronger order than that specified by :samp:`{success_memorder}`. + +.. function:: bool __atomic_compare_exchange (type *ptr, type *expected, type *desired, bool weak, int success_memorder, int failure_memorder) + + This built-in function implements the generic version of + ``__atomic_compare_exchange``. The function is virtually identical to + ``__atomic_compare_exchange_n``, except the desired value is also a + pointer. + +.. function:: type __atomic_add_fetch (type *ptr, type val, int memorder) + type __atomic_sub_fetch (type *ptr, type val, int memorder) + type __atomic_and_fetch (type *ptr, type val, int memorder) + type __atomic_xor_fetch (type *ptr, type val, int memorder) + type __atomic_or_fetch (type *ptr, type val, int memorder) + type __atomic_nand_fetch (type *ptr, type val, int memorder) + + These built-in functions perform the operation suggested by the name, and + return the result of the operation. Operations on pointer arguments are + performed as if the operands were of the ``uintptr_t`` type. That is, + they are not scaled by the size of the type to which the pointer points. + + .. code-block:: c++ + + { *ptr op= val; return *ptr; } + { *ptr = ~(*ptr & val); return *ptr; } // nand + + The object pointed to by the first argument must be of integer or pointer + type. It must not be a boolean type. All memory orders are valid. + +.. function:: type __atomic_fetch_add (type *ptr, type val, int memorder) + type __atomic_fetch_sub (type *ptr, type val, int memorder) + type __atomic_fetch_and (type *ptr, type val, int memorder) + type __atomic_fetch_xor (type *ptr, type val, int memorder) + type __atomic_fetch_or (type *ptr, type val, int memorder) + type __atomic_fetch_nand (type *ptr, type val, int memorder) + + These built-in functions perform the operation suggested by the name, and + return the value that had previously been in ``*ptr``. Operations + on pointer arguments are performed as if the operands were of + the ``uintptr_t`` type. That is, they are not scaled by the size of + the type to which the pointer points. + + .. code-block:: c++ + + { tmp = *ptr; *ptr op= val; return tmp; } + { tmp = *ptr; *ptr = ~(*ptr & val); return tmp; } // nand + + The same constraints on arguments apply as for the corresponding + ``__atomic_op_fetch`` built-in functions. All memory orders are valid. + +.. function:: bool __atomic_test_and_set (void *ptr, int memorder) + + This built-in function performs an atomic test-and-set operation on + the byte at ``*ptr``. The byte is set to some implementation + defined nonzero 'set' value and the return value is ``true`` if and only + if the previous contents were 'set'. + It should be only used for operands of type ``bool`` or ``char``. For + other types only part of the value may be set. + + All memory orders are valid. + +.. function:: void __atomic_clear (bool *ptr, int memorder) + + This built-in function performs an atomic clear operation on + ``*ptr``. After the operation, ``*ptr`` contains 0. + It should be only used for operands of type ``bool`` or ``char`` and + in conjunction with ``__atomic_test_and_set``. + For other types it may only clear partially. If the type is not ``bool`` + prefer using ``__atomic_store``. + + The valid memory order variants are + ``__ATOMIC_RELAXED``, ``__ATOMIC_SEQ_CST``, and + ``__ATOMIC_RELEASE``. + +.. function:: void __atomic_thread_fence (int memorder) + + This built-in function acts as a synchronization fence between threads + based on the specified memory order. + + All memory orders are valid. + +.. function:: void __atomic_signal_fence (int memorder) + + This built-in function acts as a synchronization fence between a thread + and signal handlers based in the same thread. + + All memory orders are valid. + +.. function:: bool __atomic_always_lock_free (size_t size, void *ptr) + + This built-in function returns ``true`` if objects of :samp:`{size}` bytes always + generate lock-free atomic instructions for the target architecture. + :samp:`{size}` must resolve to a compile-time constant and the result also + resolves to a compile-time constant. + + :samp:`{ptr}` is an optional pointer to the object that may be used to determine + alignment. A value of 0 indicates typical alignment should be used. The + compiler may also ignore this parameter. + + .. code-block:: c++ + + if (__atomic_always_lock_free (sizeof (long long), 0)) + +.. function:: bool __atomic_is_lock_free (size_t size, void *ptr) + + This built-in function returns ``true`` if objects of :samp:`{size}` bytes always + generate lock-free atomic instructions for the target architecture. If + the built-in function is not known to be lock-free, a call is made to a + runtime routine named ``__atomic_is_lock_free``. + + :samp:`{ptr}` is an optional pointer to the object that may be used to determine + alignment. A value of 0 indicates typical alignment should be used. The + compiler may also ignore this parameter. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/built-in-functions-to-perform-arithmetic-with-overflow-checking.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/built-in-functions-to-perform-arithmetic-with-overflow-checking.rst new file mode 100644 index 00000000000..a7927b15195 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/built-in-functions-to-perform-arithmetic-with-overflow-checking.rst @@ -0,0 +1,102 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _integer-overflow-builtins: + +Built-in Functions to Perform Arithmetic with Overflow Checking +*************************************************************** + +The following built-in functions allow performing simple arithmetic operations +together with checking whether the operations overflowed. + +.. function:: bool __builtin_add_overflow (type1 a, type2 b, type3 *res) + bool __builtin_sadd_overflow (int a, int b, int *res) + bool __builtin_saddl_overflow (long int a, long int b, long int *res) + bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res) + bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res) + bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res) + bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res) + + These built-in functions promote the first two operands into infinite precision signed + type and perform addition on those promoted operands. The result is then + cast to the type the third pointer argument points to and stored there. + If the stored result is equal to the infinite precision result, the built-in + functions return ``false``, otherwise they return ``true``. As the addition is + performed in infinite signed precision, these built-in functions have fully defined + behavior for all argument values. + + The first built-in function allows arbitrary integral types for operands and + the result type must be pointer to some integral type other than enumerated or + boolean type, the rest of the built-in functions have explicit integer types. + + The compiler will attempt to use hardware instructions to implement + these built-in functions where possible, like conditional jump on overflow + after addition, conditional jump on carry etc. + +.. function:: bool __builtin_sub_overflow (type1 a, type2 b, type3 *res) + bool __builtin_ssub_overflow (int a, int b, int *res) + bool __builtin_ssubl_overflow (long int a, long int b, long int *res) + bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res) + bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res) + bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res) + bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res) + + These built-in functions are similar to the add overflow checking built-in + functions above, except they perform subtraction, subtract the second argument + from the first one, instead of addition. + +.. function:: bool __builtin_mul_overflow (type1 a, type2 b, type3 *res) + bool __builtin_smul_overflow (int a, int b, int *res) + bool __builtin_smull_overflow (long int a, long int b, long int *res) + bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res) + bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res) + bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res) + bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res) + + These built-in functions are similar to the add overflow checking built-in + functions above, except they perform multiplication, instead of addition. + +The following built-in functions allow checking if simple arithmetic operation +would overflow. + +.. function:: bool __builtin_add_overflow_p (type1 a, type2 b, type3 c) + bool __builtin_sub_overflow_p (type1 a, type2 b, type3 c) + bool __builtin_mul_overflow_p (type1 a, type2 b, type3 c) + + These built-in functions are similar to ``__builtin_add_overflow``, + ``__builtin_sub_overflow``, or ``__builtin_mul_overflow``, except that + they don't store the result of the arithmetic operation anywhere and the + last argument is not a pointer, but some expression with integral type other + than enumerated or boolean type. + + The built-in functions promote the first two operands into infinite precision signed type + and perform addition on those promoted operands. The result is then + cast to the type of the third argument. If the cast result is equal to the infinite + precision result, the built-in functions return ``false``, otherwise they return ``true``. + The value of the third argument is ignored, just the side effects in the third argument + are evaluated, and no integral argument promotions are performed on the last argument. + If the third argument is a bit-field, the type used for the result cast has the + precision and signedness of the given bit-field, rather than precision and signedness + of the underlying type. + + For example, the following macro can be used to portably check, at + compile-time, whether or not adding two constant integers will overflow, + and perform the addition only when it is known to be safe and not to trigger + a :option:`-Woverflow` warning. + + .. code-block:: c++ + + #define INT_ADD_OVERFLOW_P(a, b) \ + __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0) + + enum { + A = INT_MAX, B = 3, + C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B, + D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0) + }; + + The compiler will attempt to use hardware instructions to implement + these built-in functions where possible, like conditional jump on overflow + after addition, conditional jump on carry etc. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/c++-style-comments.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/c++-style-comments.rst new file mode 100644 index 00000000000..c1815e8c02a --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/c++-style-comments.rst @@ -0,0 +1,18 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: //, C++ comments, comments, C++ style + +.. _c++-comments: + +C++ Style Comments +****************** + +In GNU C, you may use C++ style comments, which start with :samp:`//` and +continue until the end of the line. Many other C implementations allow +such comments, and they are included in the 1999 C standard. However, +C++ style comments are not recognized if you specify an :option:`-std` +option specifying a version of ISO C before C99, or :option:`-ansi` +(equivalent to :option:`-std=c90`). \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/case-ranges.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/case-ranges.rst new file mode 100644 index 00000000000..ad5aa534a12 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/case-ranges.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: case ranges, ranges in case statements + +.. _case-ranges: + +Case Ranges +*********** + +You can specify a range of consecutive values in a single ``case`` label, +like this: + +.. code-block:: c++ + + case low ... high: + +This has the same effect as the proper number of individual ``case`` +labels, one for each integer value from :samp:`{low}` to :samp:`{high}`, inclusive. + +This feature is especially useful for ranges of ASCII character codes: + +.. code-block:: c++ + + case 'A' ... 'Z': + +.. caution:: + + Write spaces around the ``...``, for otherwise + it may be parsed wrong when you use it with integer values. For example, + write this: + +.. code-block:: c++ + + case 1 ... 5: + +rather than this: + +.. code-block:: c++ + + case 1...5: \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/cast-to-a-union-type.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/cast-to-a-union-type.rst new file mode 100644 index 00000000000..4a02d878da3 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/cast-to-a-union-type.rst @@ -0,0 +1,69 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: cast to a union, union, casting to a + +.. _cast-to-union: + +Cast to a Union Type +******************** + +A cast to a union type is a C extension not available in C++. It looks +just like ordinary casts with the constraint that the type specified is +a union type. You can specify the type either with the ``union`` +keyword or with a ``typedef`` name that refers to a union. The result +of a cast to a union is a temporary rvalue of the union type with a member +whose type matches that of the operand initialized to the value of +the operand. The effect of a cast to a union is similar to a compound +literal except that it yields an rvalue like standard casts do. +See :ref:`compound-literals`. + +Expressions that may be cast to the union type are those whose type matches +at least one of the members of the union. Thus, given the following union +and variables: + +.. code-block:: c++ + + union foo { int i; double d; }; + int x; + double y; + union foo z; + +both ``x`` and ``y`` can be cast to type ``union foo`` and +the following assignments + +.. code-block:: c++ + + z = (union foo) x; + z = (union foo) y; + +are shorthand equivalents of these + +.. code-block:: c++ + + z = (union foo) { .i = x }; + z = (union foo) { .d = y }; + +However, ``(union foo) FLT_MAX;`` is not a valid cast because the union +has no member of type ``float``. + +Using the cast as the right-hand side of an assignment to a variable of +union type is equivalent to storing in a member of the union with +the same type + +.. code-block:: c++ + + union foo u; + /* ... */ + u = (union foo) x == u.i = x + u = (union foo) y == u.d = y + +You can also use the union cast as a function argument: + +.. code-block:: c++ + + void hack (union foo); + /* ... */ + hack ((union foo) x); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/complex-numbers.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/complex-numbers.rst new file mode 100644 index 00000000000..c8819cc1d8d --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/complex-numbers.rst @@ -0,0 +1,122 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: complex numbers, _Complex keyword, __complex__ keyword + +.. _complex: + +Complex Numbers +*************** + +ISO C99 supports complex floating data types, and as an extension GCC +supports them in C90 mode and in C++. GCC also supports complex integer data +types which are not part of ISO C99. You can declare complex types +using the keyword ``_Complex``. As an extension, the older GNU +keyword ``__complex__`` is also supported. + +For example, :samp:`_Complex double x;` declares ``x`` as a +variable whose real part and imaginary part are both of type +``double``. :samp:`_Complex short int y;` declares ``y`` to +have real and imaginary parts of type ``short int`` ; this is not +likely to be useful, but it shows that the set of complex types is +complete. + +To write a constant with a complex data type, use the suffix :samp:`i` or +:samp:`j` (either one; they are equivalent). For example, ``2.5fi`` +has type ``_Complex float`` and ``3i`` has type +``_Complex int``. Such a constant always has a pure imaginary +value, but you can form any complex value you like by adding one to a +real constant. This is a GNU extension; if you have an ISO C99 +conforming C library (such as the GNU C Library), and want to construct complex +constants of floating type, you should include ```` and +use the macros ``I`` or ``_Complex_I`` instead. + +The ISO C++14 library also defines the :samp:`i` suffix, so C++14 code +that includes the :samp:`` header cannot use :samp:`i` for the +GNU extension. The :samp:`j` suffix still has the GNU meaning. + +GCC can handle both implicit and explicit casts between the ``_Complex`` +types and other ``_Complex`` types as casting both the real and imaginary +parts to the scalar type. +GCC can handle implicit and explicit casts from a scalar type to a ``_Complex`` +type and where the imaginary part will be considered zero. +The C front-end can handle implicit and explicit casts from a ``_Complex`` type +to a scalar type where the imaginary part will be ignored. In C++ code, this cast +is considered illformed and G++ will error out. + +GCC provides a built-in function ``__builtin_complex`` will can be used to +construct a complex value. + +.. index:: __real__ keyword, __imag__ keyword + +GCC has a few extensions which can be used to extract the real +and the imaginary part of the complex-valued expression. Note +these expressions are lvalues if the :samp:`{exp}` is an lvalue. +These expressions operands have the type of a complex type +which might get prompoted to a complex type from a scalar type. +E.g. ``__real__ (int)x`` is the same as casting to +``_Complex int`` before ``__real__`` is done. + +.. list-table:: + :header-rows: 1 + + * - Expression + - Description + + * - ``__real__ exp`` + - Extract the real part of :samp:`{exp}`. + * - ``__imag__ exp`` + - Extract the imaginary part of :samp:`{exp}`. + +For values of floating point, you should use the ISO C99 +functions, declared in ```` and also provided as +built-in functions by GCC. + +.. list-table:: + :header-rows: 1 + + * - Expression + - float + - double + - long double + + * - ``__real__ exp`` + - ``crealf`` + - ``creal`` + - ``creall`` + * - ``__imag__ exp`` + - ``cimagf`` + - ``cimag`` + - ``cimagl`` + +.. index:: complex conjugation + +The operator :samp:`~` performs complex conjugation when used on a value +with a complex type. This is a GNU extension; for values of +floating type, you should use the ISO C99 functions ``conjf``, +``conj`` and ``conjl``, declared in ```` and also +provided as built-in functions by GCC. Note unlike the ``__real__`` +and ``__imag__`` operators, this operator will not do an implicit cast +to the complex type because the :samp:`~` is already a normal operator. + +GCC can allocate complex automatic variables in a noncontiguous +fashion; it's even possible for the real part to be in a register while +the imaginary part is on the stack (or vice versa). Only the DWARF +debug info format can represent this, so use of DWARF is recommended. +If you are using the stabs debug info format, GCC describes a noncontiguous +complex variable as if it were two separate variables of noncomplex type. +If the variable's actual name is ``foo``, the two fictitious +variables are named ``foo$real`` and ``foo$imag``. You can +examine and set these two fictitious variables with your debugger. + +.. function:: type __builtin_complex (real, imag) + + The built-in function ``__builtin_complex`` is provided for use in + implementing the ISO C11 macros ``CMPLXF``, ``CMPLX`` and + ``CMPLXL``. :samp:`{real}` and :samp:`{imag}` must have the same type, a + real binary floating-point type, and the result has the corresponding + complex type with real and imaginary parts :samp:`{real}` and :samp:`{imag}`. + Unlike :samp:`{real} + I * {imag}`, this works even when + infinities, NaNs and negative zeros are involved. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/compound-literals.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/compound-literals.rst new file mode 100644 index 00000000000..4984ed4b5c8 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/compound-literals.rst @@ -0,0 +1,104 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: constructor expressions, initializations in expressions, structures, constructor expression, expressions, constructor, compound literals + +.. _compound-literals: + +Compound Literals +***************** + +.. The GNU C name for what C99 calls compound literals was "constructor expressions". + +A compound literal looks like a cast of a brace-enclosed aggregate +initializer list. Its value is an object of the type specified in +the cast, containing the elements specified in the initializer. +Unlike the result of a cast, a compound literal is an lvalue. ISO +C99 and later support compound literals. As an extension, GCC +supports compound literals also in C90 mode and in C++, although +as explained below, the C++ semantics are somewhat different. + +Usually, the specified type of a compound literal is a structure. Assume +that ``struct foo`` and ``structure`` are declared as shown: + +.. code-block:: c++ + + struct foo {int a; char b[2];} structure; + +Here is an example of constructing a ``struct foo`` with a compound literal: + +.. code-block:: c++ + + structure = ((struct foo) {x + y, 'a', 0}); + +This is equivalent to writing the following: + +.. code-block:: c++ + + { + struct foo temp = {x + y, 'a', 0}; + structure = temp; + } + +You can also construct an array, though this is dangerous in C++, as +explained below. If all the elements of the compound literal are +(made up of) simple constant expressions suitable for use in +initializers of objects of static storage duration, then the compound +literal can be coerced to a pointer to its first element and used in +such an initializer, as shown here: + +.. code-block:: c++ + + char **foo = (char *[]) { "x", "y", "z" }; + +Compound literals for scalar types and union types are also allowed. In +the following example the variable ``i`` is initialized to the value +``2``, the result of incrementing the unnamed object created by +the compound literal. + +.. code-block:: c++ + + int i = ++(int) { 1 }; + +As a GNU extension, GCC allows initialization of objects with static storage +duration by compound literals (which is not possible in ISO C99 because +the initializer is not a constant). +It is handled as if the object were initialized only with the brace-enclosed +list if the types of the compound literal and the object match. +The elements of the compound literal must be constant. +If the object being initialized has array type of unknown size, the size is +determined by the size of the compound literal. + +.. code-block:: c++ + + static struct foo x = (struct foo) {1, 'a', 'b'}; + static int y[] = (int []) {1, 2, 3}; + static int z[] = (int [3]) {1}; + +The above lines are equivalent to the following: + +.. code-block:: c++ + + static struct foo x = {1, 'a', 'b'}; + static int y[] = {1, 2, 3}; + static int z[] = {1, 0, 0}; + +In C, a compound literal designates an unnamed object with static or +automatic storage duration. In C++, a compound literal designates a +temporary object that only lives until the end of its full-expression. +As a result, well-defined C code that takes the address of a subobject +of a compound literal can be undefined in C++, so G++ rejects +the conversion of a temporary array to a pointer. For instance, if +the array compound literal example above appeared inside a function, +any subsequent use of ``foo`` in C++ would have undefined behavior +because the lifetime of the array ends after the declaration of ``foo``. + +As an optimization, G++ sometimes gives array compound literals longer +lifetimes: when the array either appears outside a function or has +a ``const`` -qualified type. If ``foo`` and its initializer had +elements of type ``char *const`` rather than ``char *``, or if +``foo`` were a global variable, the array would have static storage +duration. But it is probably safest just to avoid the use of array +compound literals in C++ code. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/conditionals-with-omitted-operands.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/conditionals-with-omitted-operands.rst new file mode 100644 index 00000000000..ddea0fc3073 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/conditionals-with-omitted-operands.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: conditional expressions, extensions, omitted middle-operands, middle-operands, omitted, extensions, ?:, ?: extensions + +.. _conditionals: + +Conditionals with Omitted Operands +********************************** + +The middle operand in a conditional expression may be omitted. Then +if the first operand is nonzero, its value is the value of the conditional +expression. + +Therefore, the expression + +.. code-block:: c++ + + x ? : y + +has the value of ``x`` if that is nonzero; otherwise, the value of +``y``. + +This example is perfectly equivalent to + +.. code-block:: c++ + + x ? x : y + +.. index:: side effect in ?:, ?: side effect + +In this simple case, the ability to omit the middle operand is not +especially useful. When it becomes useful is when the first operand does, +or may (if it is a macro argument), contain a side effect. Then repeating +the operand in the middle would perform the side effect twice. Omitting +the middle operand uses the value already computed without the undesirable +effects of recomputing it. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/constructing-function-calls.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/constructing-function-calls.rst new file mode 100644 index 00000000000..051f1c31b4e --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/constructing-function-calls.rst @@ -0,0 +1,125 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: constructing calls, forwarding calls + +.. _constructing-calls: + +Constructing Function Calls +*************************** + +Using the built-in functions described below, you can record +the arguments a function received, and call another function +with the same arguments, without knowing the number or types +of the arguments. + +You can also record the return value of that function call, +and later return that value, without knowing what data type +the function tried to return (as long as your caller expects +that data type). + +However, these built-in functions may interact badly with some +sophisticated features or other extensions of the language. It +is, therefore, not recommended to use them outside very simple +functions acting as mere forwarders for their arguments. + +.. function:: void * __builtin_apply_args () + + This built-in function returns a pointer to data + describing how to perform a call with the same arguments as are passed + to the current function. + + The function saves the arg pointer register, structure value address, + and all registers that might be used to pass arguments to a function + into a block of memory allocated on the stack. Then it returns the + address of that block. + +.. function:: void * __builtin_apply (void (*function)(), void *arguments, size_t size) + + This built-in function invokes :samp:`{function}` + with a copy of the parameters described by :samp:`{arguments}` + and :samp:`{size}`. + + The value of :samp:`{arguments}` should be the value returned by + ``__builtin_apply_args``. The argument :samp:`{size}` specifies the size + of the stack argument data, in bytes. + + This function returns a pointer to data describing + how to return whatever value is returned by :samp:`{function}`. The data + is saved in a block of memory allocated on the stack. + + It is not always simple to compute the proper value for :samp:`{size}`. The + value is used by ``__builtin_apply`` to compute the amount of data + that should be pushed on the stack and copied from the incoming argument + area. + +.. function:: void __builtin_return (void *result) + + This built-in function returns the value described by :samp:`{result}` from + the containing function. You should specify, for :samp:`{result}`, a value + returned by ``__builtin_apply``. + +.. function:: __builtin_va_arg_pack () + + This built-in function represents all anonymous arguments of an inline + function. It can be used only in inline functions that are always + inlined, never compiled as a separate function, such as those using + ``__attribute__ ((__always_inline__))`` or + ``__attribute__ ((__gnu_inline__))`` extern inline functions. + It must be only passed as last argument to some other function + with variable arguments. This is useful for writing small wrapper + inlines for variable argument functions, when using preprocessor + macros is undesirable. For example: + + .. code-block:: c++ + + extern int myprintf (FILE *f, const char *format, ...); + extern inline __attribute__ ((__gnu_inline__)) int + myprintf (FILE *f, const char *format, ...) + { + int r = fprintf (f, "myprintf: "); + if (r < 0) + return r; + int s = fprintf (f, format, __builtin_va_arg_pack ()); + if (s < 0) + return s; + return r + s; + } + +.. function:: size_t __builtin_va_arg_pack_len () + + This built-in function returns the number of anonymous arguments of + an inline function. It can be used only in inline functions that + are always inlined, never compiled as a separate function, such + as those using ``__attribute__ ((__always_inline__))`` or + ``__attribute__ ((__gnu_inline__))`` extern inline functions. + For example following does link- or run-time checking of open + arguments for optimized code: + + .. code-block:: c++ + + #ifdef __OPTIMIZE__ + extern inline __attribute__((__gnu_inline__)) int + myopen (const char *path, int oflag, ...) + { + if (__builtin_va_arg_pack_len () > 1) + warn_open_too_many_arguments (); + + if (__builtin_constant_p (oflag)) + { + if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1) + { + warn_open_missing_mode (); + return __open_2 (path, oflag); + } + return open (path, oflag, __builtin_va_arg_pack ()); + } + + if (__builtin_va_arg_pack_len () < 1) + return __open_2 (path, oflag); + + return open (path, oflag, __builtin_va_arg_pack ()); + } + #endif \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/decimal-floating-types.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/decimal-floating-types.rst new file mode 100644 index 00000000000..aa3902e6cd4 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/decimal-floating-types.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: decimal floating types, _Decimal32 data type, _Decimal64 data type, _Decimal128 data type, df integer suffix, dd integer suffix, dl integer suffix, DF integer suffix, DD integer suffix, DL integer suffix + +.. _decimal-float: + +Decimal Floating Types +********************** + +As an extension, GNU C supports decimal floating types as +defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal +floating types in GCC will evolve as the draft technical report changes. +Calling conventions for any target might also change. Not all targets +support decimal floating types. + +The decimal floating types are ``_Decimal32``, ``_Decimal64``, and +``_Decimal128``. They use a radix of ten, unlike the floating types +``float``, ``double``, and ``long double`` whose radix is not +specified by the C standard but is usually two. + +Support for decimal floating types includes the arithmetic operators +add, subtract, multiply, divide; unary arithmetic operators; +relational operators; equality operators; and conversions to and from +integer and other floating types. Use a suffix :samp:`df` or +:samp:`DF` in a literal constant of type ``_Decimal32``, :samp:`dd` +or :samp:`DD` for ``_Decimal64``, and :samp:`dl` or :samp:`DL` for +``_Decimal128``. + +GCC support of decimal float as specified by the draft technical report +is incomplete: + +* When the value of a decimal floating type cannot be represented in the + integer type to which it is being converted, the result is undefined + rather than the result value specified by the draft technical report. + +* GCC does not provide the C library functionality associated with + :samp:`math.h`, :samp:`fenv.h`, :samp:`stdio.h`, :samp:`stdlib.h`, and + :samp:`wchar.h`, which must come from a separate C library implementation. + Because of this the GNU C compiler does not define macro + ``__STDC_DEC_FP__`` to indicate that the implementation conforms to + the technical report. + +Types ``_Decimal32``, ``_Decimal64``, and ``_Decimal128`` +are supported by the DWARF debug information format. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions.rst new file mode 100644 index 00000000000..0d57b9b9e73 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions.rst @@ -0,0 +1,109 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: function attributes, declaring attributes of functions, volatile applied to function, const applied to function + +.. _function-attributes: + +Declaring Attributes of Functions +********************************* + +In GNU C and C++, you can use function attributes to specify certain +function properties that may help the compiler optimize calls or +check code more carefully for correctness. For example, you +can use attributes to specify that a function never returns +(:fn-attr:`noreturn`), returns a value depending only on the values of +its arguments (``const``), or has ``printf`` -style arguments +(``format``). + +You can also use attributes to control memory placement, code +generation options or call/return conventions within the function +being annotated. Many of these attributes are target-specific. For +example, many targets support attributes for defining interrupt +handler functions, which typically must follow special register usage +and return conventions. Such attributes are described in the subsection +for each target. However, a considerable number of attributes are +supported by most, if not all targets. Those are described in +the :ref:`common-function-attributes` section. + +Function attributes are introduced by the ``__attribute__`` keyword +in the declaration of a function, followed by an attribute specification +enclosed in double parentheses. You can specify multiple attributes in +a declaration by separating them by commas within the double parentheses +or by immediately following one attribute specification with another. +See :ref:`attribute-syntax`, for the exact rules on attribute syntax and +placement. Compatible attribute specifications on distinct declarations +of the same function are merged. An attribute specification that is not +compatible with attributes already applied to a declaration of the same +function is ignored with a warning. + +Some function attributes take one or more arguments that refer to +the function's parameters by their positions within the function parameter +list. Such attribute arguments are referred to as :dfn:`positional arguments`. +Unless specified otherwise, positional arguments that specify properties +of parameters with pointer types can also specify the same properties of +the implicit C++ ``this`` argument in non-static member functions, and +of parameters of reference to a pointer type. For ordinary functions, +position one refers to the first parameter on the list. In C++ non-static +member functions, position one refers to the implicit ``this`` pointer. +The same restrictions and effects apply to function attributes used with +ordinary functions or C++ member functions. + +GCC also supports attributes on +variable declarations (see :ref:`variable-attributes`), +labels (see :ref:`label-attributes`), +enumerators (see :ref:`enumerator-attributes`), +statements (see :ref:`statement-attributes`), +types (see :ref:`type-attributes`), +and on field declarations (for :fn-attr:`tainted_args`). + +There is some overlap between the purposes of attributes and pragmas +(see :ref:`pragmas`). It has been +found convenient to use ``__attribute__`` to achieve a natural +attachment of attributes to their corresponding declarations, whereas +``#pragma`` is of use for compatibility with other compilers +or constructs that do not naturally form part of the grammar. + +In addition to the attributes documented here, +GCC plugins may provide their own attributes. + +.. toctree:: + :maxdepth: 1 + + declaring-attributes-of-functions/common-function-attributes + declaring-attributes-of-functions/aarch64-function-attributes + declaring-attributes-of-functions/amd-gcn-function-attributes + declaring-attributes-of-functions/arc-function-attributes + declaring-attributes-of-functions/arm-function-attributes + declaring-attributes-of-functions/avr-function-attributes + declaring-attributes-of-functions/blackfin-function-attributes + declaring-attributes-of-functions/bpf-function-attributes + declaring-attributes-of-functions/c-sky-function-attributes + declaring-attributes-of-functions/epiphany-function-attributes + declaring-attributes-of-functions/h8-300-function-attributes + declaring-attributes-of-functions/ia-64-function-attributes + declaring-attributes-of-functions/m32c-function-attributes + declaring-attributes-of-functions/m32r-d-function-attributes + declaring-attributes-of-functions/m68k-function-attributes + declaring-attributes-of-functions/mcore-function-attributes + declaring-attributes-of-functions/mep-function-attributes + declaring-attributes-of-functions/microblaze-function-attributes + declaring-attributes-of-functions/microsoft-windows-function-attributes + declaring-attributes-of-functions/mips-function-attributes + declaring-attributes-of-functions/msp430-function-attributes + declaring-attributes-of-functions/nds32-function-attributes + declaring-attributes-of-functions/nios-ii-function-attributes + declaring-attributes-of-functions/nvidia-ptx-function-attributes + declaring-attributes-of-functions/powerpc-function-attributes + declaring-attributes-of-functions/risc-v-function-attributes + declaring-attributes-of-functions/rl78-function-attributes + declaring-attributes-of-functions/rx-function-attributes + declaring-attributes-of-functions/s-390-function-attributes + declaring-attributes-of-functions/sh-function-attributes + declaring-attributes-of-functions/symbian-os-function-attributes + declaring-attributes-of-functions/v850-function-attributes + declaring-attributes-of-functions/visium-function-attributes + declaring-attributes-of-functions/x86-function-attributes + declaring-attributes-of-functions/xstormy16-function-attributes \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/aarch64-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/aarch64-function-attributes.rst new file mode 100644 index 00000000000..3f238e60179 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/aarch64-function-attributes.rst @@ -0,0 +1,192 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _aarch64-function-attributes: + +AArch64 Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following target-specific function attributes are available for the +AArch64 target. For the most part, these options mirror the behavior of +similar command-line options (see :ref:`aarch64-options`), but on a +per-function basis. + +.. index:: general-regs-only function attribute, AArch64 + +.. aarch64-fn-attr:: general-regs-only + + Indicates that no floating-point or Advanced SIMD registers should be + used when generating code for this function. If the function explicitly + uses floating-point code, then the compiler gives an error. This is + the same behavior as that of the command-line option + :option:`-mgeneral-regs-only`. + +.. index:: fix-cortex-a53-835769 function attribute, AArch64 + +.. aarch64-fn-attr:: fix-cortex-a53-835769 + + Indicates that the workaround for the Cortex-A53 erratum 835769 should be + applied to this function. To explicitly disable the workaround for this + function specify the negated form: ``no-fix-cortex-a53-835769``. + This corresponds to the behavior of the command line options + :option:`-mfix-cortex-a53-835769` and :option:`-mno-fix-cortex-a53-835769`. + +.. index:: cmodel= function attribute, AArch64 + +.. aarch64-fn-attr:: cmodel= + + Indicates that code should be generated for a particular code model for + this function. The behavior and permissible arguments are the same as + for the command line option :option:`-mcmodel=`. + +.. index:: strict-align function attribute, AArch64 + +.. aarch64-fn-attr:: strict-align, no-strict-align + + :aarch64-fn-attr:`strict-align` indicates that the compiler should not assume that unaligned + memory references are handled by the system. To allow the compiler to assume + that aligned memory references are handled by the system, the inverse attribute + ``no-strict-align`` can be specified. The behavior is same as for the + command-line option :option:`-mstrict-align` and :option:`-mno-strict-align`. + +.. index:: omit-leaf-frame-pointer function attribute, AArch64 + +.. aarch64-fn-attr:: omit-leaf-frame-pointer + + Indicates that the frame pointer should be omitted for a leaf function call. + To keep the frame pointer, the inverse attribute + ``no-omit-leaf-frame-pointer`` can be specified. These attributes have + the same behavior as the command-line options :option:`-momit-leaf-frame-pointer` + and :option:`-mno-omit-leaf-frame-pointer`. + +.. index:: tls-dialect= function attribute, AArch64 + +.. aarch64-fn-attr:: tls-dialect= + + Specifies the TLS dialect to use for this function. The behavior and + permissible arguments are the same as for the command-line option + :option:`-mtls-dialect=`. + +.. index:: arch= function attribute, AArch64 + +.. aarch64-fn-attr:: arch= + + Specifies the architecture version and architectural extensions to use + for this function. The behavior and permissible arguments are the same as + for the :option:`-march=` command-line option. + +.. index:: tune= function attribute, AArch64 + +.. aarch64-fn-attr:: tune= + + Specifies the core for which to tune the performance of this function. + The behavior and permissible arguments are the same as for the :option:`-mtune=` + command-line option. + +.. index:: cpu= function attribute, AArch64 + +.. aarch64-fn-attr:: cpu= + + Specifies the core for which to tune the performance of this function and also + whose architectural features to use. The behavior and valid arguments are the + same as for the :option:`-mcpu=` command-line option. + +.. index:: sign-return-address function attribute, AArch64 + +.. aarch64-fn-attr:: sign-return-address + + Select the function scope on which return address signing will be applied. The + behavior and permissible arguments are the same as for the command-line option + :option:`-msign-return-address=`. The default value is ``none``. This + attribute is deprecated. The :gcc-attr:`branch-protection` attribute should + be used instead. + +.. index:: branch-protection function attribute, AArch64 + +.. aarch64-fn-attr:: branch-protection + + Select the function scope on which branch protection will be applied. The + behavior and permissible arguments are the same as for the command-line option + :option:`-mbranch-protection=`. The default value is ``none``. + +.. index:: outline-atomics function attribute, AArch64 + +.. aarch64-fn-attr:: outline-atomics + + Enable or disable calls to out-of-line helpers to implement atomic operations. + This corresponds to the behavior of the command line options + :option:`-moutline-atomics` and :option:`-mno-outline-atomics`. + +The above target attributes can be specified as follows: + +.. code-block:: c++ + + __attribute__((target("attr-string"))) + int + f (int a) + { + return a + 5; + } + +where ``attr-string`` is one of the attribute strings specified above. + +Additionally, the architectural extension string may be specified on its +own. This can be used to turn on and off particular architectural extensions +without having to specify a particular architecture version or core. Example: + +.. code-block:: c++ + + __attribute__((target("+crc+nocrypto"))) + int + foo (int a) + { + return a + 5; + } + +In this example ``target("+crc+nocrypto")`` enables the ``crc`` +extension and disables the ``crypto`` extension for the function ``foo`` +without modifying an existing :option:`-march=` or :option:`-mcpu` option. + +Multiple target function attributes can be specified by separating them with +a comma. For example: + +.. code-block:: c++ + + __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53"))) + int + foo (int a) + { + return a + 5; + } + +is valid and compiles function ``foo`` for ARMv8-A with ``crc`` +and ``crypto`` extensions and tunes it for ``cortex-a53``. + +Inlining rules +~~~~~~~~~~~~~~ + +Specifying target attributes on individual functions or performing link-time +optimization across translation units compiled with different target options +can affect function inlining rules: + +In particular, a caller function can inline a callee function only if the +architectural features available to the callee are a subset of the features +available to the caller. +For example: A function ``foo`` compiled with :option:`-march=armv8-a+crc`, +or tagged with the equivalent ``arch=armv8-a+crc`` attribute, +can inline a function ``bar`` compiled with :option:`-march=armv8-a+nocrc` +because the all the architectural features that function ``bar`` requires +are available to function ``foo``. Conversely, function ``bar`` cannot +inline function ``foo``. + +Additionally inlining a function compiled with :option:`-mstrict-align` into a +function compiled without ``-mstrict-align`` is not allowed. +However, inlining a function compiled without :option:`-mstrict-align` into a +function compiled with :option:`-mstrict-align` is allowed. + +Note that CPU tuning options and attributes such as the :option:`-mcpu=`, +:option:`-mtune=` do not inhibit inlining unless the CPU specified by the +:option:`-mcpu=` option or the :gcc-attr:`cpu=` attribute conflicts with the +architectural feature rules specified above. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/amd-gcn-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/amd-gcn-function-attributes.rst new file mode 100644 index 00000000000..15034deea28 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/amd-gcn-function-attributes.rst @@ -0,0 +1,93 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _amd-gcn-function-attributes: + +AMD GCN Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the AMD GCN back end: + +.. index:: amdgpu_hsa_kernel function attribute, AMD GCN + +.. amd-gcn-fn-attr:: amdgpu_hsa_kernel + + This attribute indicates that the corresponding function should be compiled as + a kernel function, that is an entry point that can be invoked from the host + via the HSA runtime library. By default functions are only callable only from + other GCN functions. + + This attribute is implicitly applied to any function named ``main``, using + default parameters. + + Kernel functions may return an integer value, which will be written to a + conventional place within the HSA "kernargs" region. + + The attribute parameters configure what values are passed into the kernel + function by the GPU drivers, via the initial register state. Some values are + used by the compiler, and therefore forced on. Enabling other options may + break assumptions in the compiler and/or run-time libraries. + + ``private_segment_buffer`` + Set ``enable_sgpr_private_segment_buffer`` flag. Always on (required to + locate the stack). + + ``dispatch_ptr`` + Set ``enable_sgpr_dispatch_ptr`` flag. Always on (required to locate the + launch dimensions). + + ``queue_ptr`` + Set ``enable_sgpr_queue_ptr`` flag. Always on (required to convert address + spaces). + + ``kernarg_segment_ptr`` + Set ``enable_sgpr_kernarg_segment_ptr`` flag. Always on (required to + locate the kernel arguments, "kernargs"). + + ``dispatch_id`` + Set ``enable_sgpr_dispatch_id`` flag. + + ``flat_scratch_init`` + Set ``enable_sgpr_flat_scratch_init`` flag. + + ``private_segment_size`` + Set ``enable_sgpr_private_segment_size`` flag. + + ``grid_workgroup_count_X`` + Set ``enable_sgpr_grid_workgroup_count_x`` flag. Always on (required to + use OpenACC/OpenMP). + + ``grid_workgroup_count_Y`` + Set ``enable_sgpr_grid_workgroup_count_y`` flag. + + ``grid_workgroup_count_Z`` + Set ``enable_sgpr_grid_workgroup_count_z`` flag. + + ``workgroup_id_X`` + Set ``enable_sgpr_workgroup_id_x`` flag. + + ``workgroup_id_Y`` + Set ``enable_sgpr_workgroup_id_y`` flag. + + ``workgroup_id_Z`` + Set ``enable_sgpr_workgroup_id_z`` flag. + + ``workgroup_info`` + Set ``enable_sgpr_workgroup_info`` flag. + + ``private_segment_wave_offset`` + Set ``enable_sgpr_private_segment_wave_byte_offset`` flag. Always on + (required to locate the stack). + + ``work_item_id_X`` + Set ``enable_vgpr_workitem_id`` parameter. Always on (can't be disabled). + + ``work_item_id_Y`` + Set ``enable_vgpr_workitem_id`` parameter. Always on (required to enable + vectorization.) + + ``work_item_id_Z`` + Set ``enable_vgpr_workitem_id`` parameter. Always on (required to use + OpenACC/OpenMP). \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/arc-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/arc-function-attributes.rst new file mode 100644 index 00000000000..3cc2700bffe --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/arc-function-attributes.rst @@ -0,0 +1,88 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _arc-function-attributes: + +ARC Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the ARC back end: + +.. index:: interrupt function attribute, ARC + +.. arc-fn-attr:: interrupt + + Use this attribute to indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when this attribute is present. + + On the ARC, you must specify the kind of interrupt to be handled + in a parameter to the interrupt attribute like this: + + .. code-block:: c++ + + void f () __attribute__ ((interrupt ("ilink1"))); + + Permissible values for this parameter are: ``ilink1`` and + ``ilink2`` for ARCv1 architecture, and ``ilink`` and + ``firq`` for ARCv2 architecture. + +.. index:: long_call function attribute, ARC, medium_call function attribute, ARC, short_call function attribute, ARC, indirect calls, ARC + +.. arc-fn-attr:: long_call, medium_call, short_call + + These attributes specify how a particular function is called. + These attributes override the + :option:`-mlong-calls` and :option:`-mmedium-calls` (see :ref:`arc-options`) + command-line switches and ``#pragma long_calls`` settings. + + For ARC, a function marked with the :arc-fn-attr:`long_call` attribute is + always called using register-indirect jump-and-link instructions, + thereby enabling the called function to be placed anywhere within the + 32-bit address space. A function marked with the ``medium_call`` + attribute will always be close enough to be called with an unconditional + branch-and-link instruction, which has a 25-bit offset from + the call site. A function marked with the ``short_call`` + attribute will always be close enough to be called with a conditional + branch-and-link instruction, which has a 21-bit offset from + the call site. + +.. index:: jli_always function attribute, ARC + +.. arc-fn-attr:: jli_always + + Forces a particular function to be called using ``jli`` + instruction. The ``jli`` instruction makes use of a table stored + into ``.jlitab`` section, which holds the location of the functions + which are addressed using this instruction. + +.. index:: jli_fixed function attribute, ARC + +.. arc-fn-attr:: jli_fixed + + Identical like the above one, but the location of the function in the + ``jli`` table is known and given as an attribute parameter. + +.. index:: secure_call function attribute, ARC + +.. arc-fn-attr:: secure_call + + This attribute allows one to mark secure-code functions that are + callable from normal mode. The location of the secure call function + into the ``sjli`` table needs to be passed as argument. + +.. index:: naked function attribute, ARC + +.. arc-fn-attr:: naked + + This attribute allows the compiler to construct the requisite function + declaration, while allowing the body of the function to be assembly + code. The specified function will not have prologue/epilogue + sequences generated by the compiler. Only basic ``asm`` statements + can safely be included in naked functions (see :ref:`basic-asm`). While + using extended ``asm`` or a mixture of basic ``asm`` and C code + may appear to work, they cannot be depended upon to work reliably and + are not supported. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/arm-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/arm-function-attributes.rst new file mode 100644 index 00000000000..1806421c90c --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/arm-function-attributes.rst @@ -0,0 +1,168 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _arm-function-attributes: + +ARM Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported for ARM targets: + +.. index:: general-regs-only function attribute, ARM + +.. arm-fn-attr:: general-regs-only + + Indicates that no floating-point or Advanced SIMD registers should be + used when generating code for this function. If the function explicitly + uses floating-point code, then the compiler gives an error. This is + the same behavior as that of the command-line option + :option:`-mgeneral-regs-only`. + +.. index:: interrupt function attribute, ARM + +.. arm-fn-attr:: interrupt + + Use this attribute to indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when this attribute is present. + + You can specify the kind of interrupt to be handled by + adding an optional parameter to the interrupt attribute like this: + + .. code-block:: c++ + + void f () __attribute__ ((interrupt ("IRQ"))); + + Permissible values for this parameter are: ``IRQ``, ``FIQ``, + ``SWI``, ``ABORT`` and ``UNDEF``. + + On ARMv7-M the interrupt type is ignored, and the attribute means the function + may be called with a word-aligned stack pointer. + +.. index:: isr function attribute, ARM + +.. arm-fn-attr:: isr + + Use this attribute on ARM to write Interrupt Service Routines. This is an + alias to the :arm-fn-attr:`interrupt` attribute above. + +.. index:: long_call function attribute, ARM, short_call function attribute, ARM, indirect calls, ARM + +.. arm-fn-attr:: long_call, short_call + + These attributes specify how a particular function is called. + These attributes override the + :option:`-mlong-calls` (see :ref:`arm-options`) + command-line switch and ``#pragma long_calls`` settings. For ARM, the + :arm-fn-attr:`long_call` attribute indicates that the function might be far + away from the call site and require a different (more expensive) + calling sequence. The ``short_call`` attribute always places + the offset to the function from the call site into the :samp:`BL` + instruction directly. + +.. index:: naked function attribute, ARM + +.. arm-fn-attr:: naked + + This attribute allows the compiler to construct the + requisite function declaration, while allowing the body of the + function to be assembly code. The specified function will not have + prologue/epilogue sequences generated by the compiler. Only basic + ``asm`` statements can safely be included in naked functions + (see :ref:`basic-asm`). While using extended ``asm`` or a mixture of + basic ``asm`` and C code may appear to work, they cannot be + depended upon to work reliably and are not supported. + +.. index:: pcs function attribute, ARM + +.. arm-fn-attr:: pcs + + The :arm-fn-attr:`pcs` attribute can be used to control the calling convention + used for a function on ARM. The attribute takes an argument that specifies + the calling convention to use. + + When compiling using the AAPCS ABI (or a variant of it) then valid + values for the argument are ``"aapcs"`` and ``"aapcs-vfp"``. In + order to use a variant other than ``"aapcs"`` then the compiler must + be permitted to use the appropriate co-processor registers (i.e., the + VFP registers must be available in order to use ``"aapcs-vfp"``). + For example, + + .. code-block:: c++ + + /* Argument passed in r0, and result returned in r0+r1. */ + double f2d (float) __attribute__((pcs("aapcs"))); + + Variadic functions always use the ``"aapcs"`` calling convention and + the compiler rejects attempts to specify an alternative. + +.. index:: target function attribute + +.. arm-fn-attr:: target (options) + + As discussed in :ref:`common-function-attributes`, this attribute + allows specification of target-specific compilation options. + + On ARM, the following options are allowed: + + :samp:`thumb` + + .. index:: target("thumb") function attribute, ARM + + Force code generation in the Thumb (T16/T32) ISA, depending on the + architecture level. + + :samp:`arm` + + .. index:: target("arm") function attribute, ARM + + Force code generation in the ARM (A32) ISA. + + Functions from different modes can be inlined in the caller's mode. + + :samp:`fpu=` + + .. index:: target("fpu=") function attribute, ARM + + Specifies the fpu for which to tune the performance of this function. + The behavior and permissible arguments are the same as for the :option:`-mfpu=` + command-line option. + + :samp:`arch=` + + .. index:: arch= function attribute, ARM + + Specifies the architecture version and architectural extensions to use + for this function. The behavior and permissible arguments are the same as + for the :option:`-march=` command-line option. + + The above target attributes can be specified as follows: + + .. code-block:: c++ + + __attribute__((target("arch=armv8-a+crc"))) + int + f (int a) + { + return a + 5; + } + + Additionally, the architectural extension string may be specified on its + own. This can be used to turn on and off particular architectural extensions + without having to specify a particular architecture version or core. Example: + + .. code-block:: c++ + + __attribute__((target("+crc+nocrypto"))) + int + foo (int a) + { + return a + 5; + } + + In this example ``target("+crc+nocrypto")`` enables the ``crc`` + extension and disables the ``crypto`` extension for the function ``foo`` + without modifying an existing :option:`-march=` or :option:`-mcpu` option. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/avr-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/avr-function-attributes.rst new file mode 100644 index 00000000000..4d51397582d --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/avr-function-attributes.rst @@ -0,0 +1,120 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _avr-function-attributes: + +AVR Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the AVR back end: + +.. index:: interrupt function attribute, AVR + +.. avr-fn-attr:: interrupt + + Use this attribute to indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when this attribute is present. + + On the AVR, the hardware globally disables interrupts when an + interrupt is executed. The first instruction of an interrupt handler + declared with this attribute is a ``SEI`` instruction to + re-enable interrupts. See also the :avr-fn-attr:`signal` function attribute + that does not insert a ``SEI`` instruction. If both :avr-fn-attr:`signal` and + :avr-fn-attr:`interrupt` are specified for the same function, :avr-fn-attr:`signal` + is silently ignored. + +.. index:: naked function attribute, AVR + +.. avr-fn-attr:: naked + + This attribute allows the compiler to construct the + requisite function declaration, while allowing the body of the + function to be assembly code. The specified function will not have + prologue/epilogue sequences generated by the compiler. Only basic + ``asm`` statements can safely be included in naked functions + (see :ref:`basic-asm`). While using extended ``asm`` or a mixture of + basic ``asm`` and C code may appear to work, they cannot be + depended upon to work reliably and are not supported. + +.. index:: no_gccisr function attribute, AVR + +.. avr-fn-attr:: no_gccisr + + Do not use ``__gcc_isr`` pseudo instructions in a function with + the :avr-fn-attr:`interrupt` or :avr-fn-attr:`signal` attribute aka. interrupt + service routine (ISR). + Use this attribute if the preamble of the ISR prologue should always read + + .. code-block:: c++ + + push __zero_reg__ + push __tmp_reg__ + in __tmp_reg__, __SREG__ + push __tmp_reg__ + clr __zero_reg__ + + and accordingly for the postamble of the epilogue --- no matter whether + the mentioned registers are actually used in the ISR or not. + Situations where you might want to use this attribute include: + + * Code that (effectively) clobbers bits of ``SREG`` other than the + ``I`` -flag by writing to the memory location of ``SREG``. + + * Code that uses inline assembler to jump to a different function which + expects (parts of) the prologue code as outlined above to be present. + + To disable ``__gcc_isr`` generation for the whole compilation unit, + there is option :option:`-mno-gas-isr-prologues`, see :ref:`avr-options`. + +.. index:: OS_main function attribute, AVR, OS_task function attribute, AVR + +.. avr-fn-attr:: OS_main, OS_task + + On AVR, functions with the :avr-fn-attr:`OS_main` or ``OS_task`` attribute + do not save/restore any call-saved register in their prologue/epilogue. + + The :avr-fn-attr:`OS_main` attribute can be used when there *is + guarantee* that interrupts are disabled at the time when the function + is entered. This saves resources when the stack pointer has to be + changed to set up a frame for local variables. + + The ``OS_task`` attribute can be used when there is *no + guarantee* that interrupts are disabled at that time when the function + is entered like for, e.g. task functions in a multi-threading operating + system. In that case, changing the stack pointer register is + guarded by save/clear/restore of the global interrupt enable flag. + + The differences to the :avr-fn-attr:`naked` function attribute are: + + * :avr-fn-attr:`naked` functions do not have a return instruction whereas + :avr-fn-attr:`OS_main` and ``OS_task`` functions have a ``RET`` or + ``RETI`` return instruction. + + * :avr-fn-attr:`naked` functions do not set up a frame for local variables + or a frame pointer whereas :avr-fn-attr:`OS_main` and ``OS_task`` do this + as needed. + +.. index:: signal function attribute, AVR + +.. avr-fn-attr:: signal + + Use this attribute on the AVR to indicate that the specified + function is an interrupt handler. The compiler generates function + entry and exit sequences suitable for use in an interrupt handler when this + attribute is present. + + See also the :avr-fn-attr:`interrupt` function attribute. + + The AVR hardware globally disables interrupts when an interrupt is executed. + Interrupt handler functions defined with the :avr-fn-attr:`signal` attribute + do not re-enable interrupts. It is save to enable interrupts in a + :avr-fn-attr:`signal` handler. This 'save' only applies to the code + generated by the compiler and not to the IRQ layout of the + application which is responsibility of the application. + + If both :avr-fn-attr:`signal` and :avr-fn-attr:`interrupt` are specified for the same + function, :avr-fn-attr:`signal` is silently ignored. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/blackfin-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/blackfin-function-attributes.rst new file mode 100644 index 00000000000..cba1fcb95b3 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/blackfin-function-attributes.rst @@ -0,0 +1,91 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _blackfin-function-attributes: + +Blackfin Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the Blackfin back end: + +.. index:: exception_handler function attribute, exception handler functions, Blackfin + +.. blackfin-fn-attr:: exception_handler + + Use this attribute on the Blackfin to indicate that the specified function + is an exception handler. The compiler generates function entry and + exit sequences suitable for use in an exception handler when this + attribute is present. + +.. index:: interrupt_handler function attribute, Blackfin + +.. blackfin-fn-attr:: interrupt_handler + + Use this attribute to + indicate that the specified function is an interrupt handler. The compiler + generates function entry and exit sequences suitable for use in an + interrupt handler when this attribute is present. + +.. index:: kspisusp function attribute, Blackfin, User stack pointer in interrupts on the Blackfin + +.. blackfin-fn-attr:: kspisusp + + When used together with :blackfin-fn-attr:`interrupt_handler`, :blackfin-fn-attr:`exception_handler` + or :blackfin-fn-attr:`nmi_handler`, code is generated to load the stack pointer + from the USP register in the function prologue. + +.. index:: l1_text function attribute, Blackfin + +.. blackfin-fn-attr:: l1_text + + This attribute specifies a function to be placed into L1 Instruction + SRAM. The function is put into a specific section named ``.l1.text``. + With :option:`-mfdpic`, function calls with a such function as the callee + or caller uses inlined PLT. + +.. index:: l2 function attribute, Blackfin + +.. blackfin-fn-attr:: l2 + + This attribute specifies a function to be placed into L2 + SRAM. The function is put into a specific section named + ``.l2.text``. With :option:`-mfdpic`, callers of such functions use + an inlined PLT. + +.. index:: indirect calls, Blackfin, longcall function attribute, Blackfin, shortcall function attribute, Blackfin + +.. blackfin-fn-attr:: longcall, shortcall + + The :blackfin-fn-attr:`longcall` attribute + indicates that the function might be far away from the call site and + require a different (more expensive) calling sequence. The + ``shortcall`` attribute indicates that the function is always close + enough for the shorter calling sequence to be used. These attributes + override the :option:`-mlongcall` switch. + +.. index:: nesting function attribute, Blackfin, Allow nesting in an interrupt handler on the Blackfin processor + +.. blackfin-fn-attr:: nesting + + Use this attribute together with :blackfin-fn-attr:`interrupt_handler`, + :blackfin-fn-attr:`exception_handler` or :blackfin-fn-attr:`nmi_handler` to indicate that the function + entry code should enable nested interrupts or exceptions. + +.. index:: nmi_handler function attribute, Blackfin, NMI handler functions on the Blackfin processor + +.. blackfin-fn-attr:: nmi_handler + + Use this attribute on the Blackfin to indicate that the specified function + is an NMI handler. The compiler generates function entry and + exit sequences suitable for use in an NMI handler when this + attribute is present. + +.. index:: saveall function attribute, Blackfin, save all registers on the Blackfin + +.. blackfin-fn-attr:: saveall + + Use this attribute to indicate that + all registers except the stack pointer should be saved in the prologue + regardless of whether they are used or not. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/bpf-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/bpf-function-attributes.rst new file mode 100644 index 00000000000..76af135b9e8 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/bpf-function-attributes.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _bpf-function-attributes: + +BPF Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the BPF back end: + +.. index:: kernel helper, function attribute, BPF + +.. bpf-fn-attr:: kernel_helper + + use this attribute to indicate the specified function declaration is a + kernel helper. The helper function is passed as an argument to the + attribute. Example: + + .. code-block:: c++ + + int bpf_probe_read (void *dst, int size, const void *unsafe_ptr) + __attribute__ ((kernel_helper (4))); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/c-sky-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/c-sky-function-attributes.rst new file mode 100644 index 00000000000..2600ab849a4 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/c-sky-function-attributes.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _c-sky-function-attributes: + +C-SKY Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the C-SKY back end: + +.. index:: interrupt function attribute, C-SKY, isr function attribute, C-SKY + +.. c-sky-fn-attr:: interrupt, isr + + Use these attributes to indicate that the specified function + is an interrupt handler. + The compiler generates function entry and exit sequences suitable for + use in an interrupt handler when either of these attributes are present. + + Use of these options requires the :option:`-mistack` command-line option + to enable support for the necessary interrupt stack instructions. They + are ignored with a warning otherwise. See :ref:`c-sky-options`. + +.. index:: naked function attribute, C-SKY + +.. c-sky-fn-attr:: naked + + This attribute allows the compiler to construct the + requisite function declaration, while allowing the body of the + function to be assembly code. The specified function will not have + prologue/epilogue sequences generated by the compiler. Only basic + ``asm`` statements can safely be included in naked functions + (see :ref:`basic-asm`). While using extended ``asm`` or a mixture of + basic ``asm`` and C code may appear to work, they cannot be + depended upon to work reliably and are not supported. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/common-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/common-function-attributes.rst new file mode 100644 index 00000000000..f24a8fd3f34 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/common-function-attributes.rst @@ -0,0 +1,1891 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _common-function-attributes: + +Common Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following attributes are supported on most targets. + +.. Keep this table alphabetized by attribute name. Treat _ as space. + +.. fn-attr:: access (access-mode, ref-index), access (access-mode, ref-index, size-index) + + The :fn-attr:`access` attribute enables the detection of invalid or unsafe + accesses by functions to which they apply or their callers, as well as + write-only accesses to objects that are never read from. Such accesses + may be diagnosed by warnings such as :option:`-Wstringop-overflow`, + :option:`-Wuninitialized`, :option:`-Wunused`, and others. + + The :fn-attr:`access` attribute specifies that a function to whose by-reference + arguments the attribute applies accesses the referenced object according to + :samp:`{access-mode}`. The :samp:`{access-mode}` argument is required and must be + one of four names: ``read_only``, ``read_write``, ``write_only``, + or ``none``. The remaining two are positional arguments. + + The required :samp:`{ref-index}` positional argument denotes a function + argument of pointer (or in C++, reference) type that is subject to + the access. The same pointer argument can be referenced by at most one + distinct :fn-attr:`access` attribute. + + The optional :samp:`{size-index}` positional argument denotes a function + argument of integer type that specifies the maximum size of the access. + The size is the number of elements of the type referenced by :samp:`{ref-index}`, + or the number of bytes when the pointer type is ``void*``. When no + :samp:`{size-index}` argument is specified, the pointer argument must be either + null or point to a space that is suitably aligned and large for at least one + object of the referenced type (this implies that a past-the-end pointer is + not a valid argument). The actual size of the access may be less but it + must not be more. + + The ``read_only`` access mode specifies that the pointer to which it + applies is used to read the referenced object but not write to it. Unless + the argument specifying the size of the access denoted by :samp:`{size-index}` + is zero, the referenced object must be initialized. The mode implies + a stronger guarantee than the ``const`` qualifier which, when cast away + from a pointer, does not prevent the pointed-to object from being modified. + Examples of the use of the ``read_only`` access mode is the argument to + the ``puts`` function, or the second and third arguments to + the ``memcpy`` function. + + .. code-block:: c++ + + __attribute__ ((access (read_only, 1))) int puts (const char*); + __attribute__ ((access (read_only, 2, 3))) void* memcpy (void*, const void*, size_t); + + The ``read_write`` access mode applies to arguments of pointer types + without the ``const`` qualifier. It specifies that the pointer to which + it applies is used to both read and write the referenced object. Unless + the argument specifying the size of the access denoted by :samp:`{size-index}` + is zero, the object referenced by the pointer must be initialized. An example + of the use of the ``read_write`` access mode is the first argument to + the ``strcat`` function. + + .. code-block:: c++ + + __attribute__ ((access (read_write, 1), access (read_only, 2))) char* strcat (char*, const char*); + + The ``write_only`` access mode applies to arguments of pointer types + without the ``const`` qualifier. It specifies that the pointer to which + it applies is used to write to the referenced object but not read from it. + The object referenced by the pointer need not be initialized. An example + of the use of the ``write_only`` access mode is the first argument to + the ``strcpy`` function, or the first two arguments to the ``fgets`` + function. + + .. code-block:: c++ + + __attribute__ ((access (write_only, 1), access (read_only, 2))) char* strcpy (char*, const char*); + __attribute__ ((access (write_only, 1, 2), access (read_write, 3))) int fgets (char*, int, FILE*); + + The access mode ``none`` specifies that the pointer to which it applies + is not used to access the referenced object at all. Unless the pointer is + null the pointed-to object must exist and have at least the size as denoted + by the :samp:`{size-index}` argument. When the optional :samp:`{size-index}` + argument is omitted for an argument of ``void*`` type the actual pointer + agument is ignored. The referenced object need not be initialized. + The mode is intended to be used as a means to help validate the expected + object size, for example in functions that call ``__builtin_object_size``. + See :ref:`object-size-checking`. + + Note that the ``access`` attribute merely specifies how an object + referenced by the pointer argument can be accessed; it does not imply that + an access **will** happen. Also, the ``access`` attribute does not + imply the attribute :fn-attr:`nonnull` ; it may be appropriate to add both attributes + at the declaration of a function that unconditionally manipulates a buffer via + a pointer argument. See the :fn-attr:`nonnull` attribute for more information and + caveats. + +.. index:: alias function attribute + +.. fn-attr:: alias ("target") + + The ``alias`` attribute causes the declaration to be emitted as an alias + for another symbol, which must have been previously declared with the same + type, and for variables, also the same size and alignment. Declaring an alias + with a different type than the target is undefined and may be diagnosed. As + an example, the following declarations: + + .. code-block:: c++ + + void __f () { /* Do something. */; } + void f () __attribute__ ((weak, alias ("__f"))); + + define :samp:`f` to be a weak alias for :samp:`__f`. In C++, the mangled name + for the target must be used. It is an error if :samp:`__f` is not defined in + the same translation unit. + + This attribute requires assembler and object file support, + and may not be available on all targets. + +.. index:: aligned function attribute + +.. fn-attr:: aligned, aligned (alignment) + + The :fn-attr:`aligned` attribute specifies a minimum alignment for + the first instruction of the function, measured in bytes. When specified, + :samp:`{alignment}` must be an integer constant power of 2. Specifying no + :samp:`{alignment}` argument implies the ideal alignment for the target. + The ``__alignof__`` operator can be used to determine what that is + (see :ref:`alignment`). The attribute has no effect when a definition for + the function is not provided in the same translation unit. + + The attribute cannot be used to decrease the alignment of a function + previously declared with a more restrictive alignment; only to increase + it. Attempts to do otherwise are diagnosed. Some targets specify + a minimum default alignment for functions that is greater than 1. On + such targets, specifying a less restrictive alignment is silently ignored. + Using the attribute overrides the effect of the :option:`-falign-functions` + (see :ref:`optimize-options`) option for this function. + + Note that the effectiveness of :fn-attr:`aligned` attributes may be + limited by inherent limitations in the system linker + and/or object file format. On some systems, the + linker is only able to arrange for functions to be aligned up to a + certain maximum alignment. (For some linkers, the maximum supported + alignment may be very very small.) See your linker documentation for + further information. + + The :fn-attr:`aligned` attribute can also be used for variables and fields + (see :ref:`variable-attributes`.) + +.. index:: alloc_align function attribute + +.. fn-attr:: alloc_align (position) + + The ``alloc_align`` attribute may be applied to a function that + returns a pointer and takes at least one argument of an integer or + enumerated type. + It indicates that the returned pointer is aligned on a boundary given + by the function argument at :samp:`{position}`. Meaningful alignments are + powers of 2 greater than one. GCC uses this information to improve + pointer alignment analysis. + + The function parameter denoting the allocated alignment is specified by + one constant integer argument whose number is the argument of the attribute. + Argument numbering starts at one. + + For instance, + + .. code-block:: c++ + + void* my_memalign (size_t, size_t) __attribute__ ((alloc_align (1))); + + declares that ``my_memalign`` returns memory with minimum alignment + given by parameter 1. + +.. index:: alloc_size function attribute + +.. fn-attr:: alloc_size (position), alloc_size (position-1, position-2) + + The ``alloc_size`` attribute may be applied to a function that + returns a pointer and takes at least one argument of an integer or + enumerated type. + It indicates that the returned pointer points to memory whose size is + given by the function argument at :samp:`{position-1}`, or by the product + of the arguments at :samp:`{position-1}` and :samp:`{position-2}`. Meaningful + sizes are positive values less than ``PTRDIFF_MAX``. GCC uses this + information to improve the results of ``__builtin_object_size``. + + The function parameter(s) denoting the allocated size are specified by + one or two integer arguments supplied to the attribute. The allocated size + is either the value of the single function argument specified or the product + of the two function arguments specified. Argument numbering starts at + one for ordinary functions, and at two for C++ non-static member functions. + + For instance, + + .. code-block:: c++ + + void* my_calloc (size_t, size_t) __attribute__ ((alloc_size (1, 2))); + void* my_realloc (void*, size_t) __attribute__ ((alloc_size (2))); + + declares that ``my_calloc`` returns memory of the size given by + the product of parameter 1 and 2 and that ``my_realloc`` returns memory + of the size given by parameter 2. + +.. index:: always_inline function attribute + +.. fn-attr:: always_inline + + Generally, functions are not inlined unless optimization is specified. + For functions declared inline, this attribute inlines the function + independent of any restrictions that otherwise apply to inlining. + Failure to inline such a function is diagnosed as an error. + Note that if such a function is called indirectly the compiler may + or may not inline it depending on optimization level and a failure + to inline an indirect call may or may not be diagnosed. + +.. index:: artificial function attribute + +.. fn-attr:: artificial + + This attribute is useful for small inline wrappers that if possible + should appear during debugging as a unit. Depending on the debug + info format it either means marking the function as artificial + or using the caller location for all instructions within the inlined + body. + +.. index:: assume_aligned function attribute + +.. fn-attr:: assume_aligned (alignment), assume_aligned (alignment, offset) + + The ``assume_aligned`` attribute may be applied to a function that + returns a pointer. It indicates that the returned pointer is aligned + on a boundary given by :samp:`{alignment}`. If the attribute has two + arguments, the second argument is misalignment :samp:`{offset}`. Meaningful + values of :samp:`{alignment}` are powers of 2 greater than one. Meaningful + values of :samp:`{offset}` are greater than zero and less than :samp:`{alignment}`. + + For instance + + .. code-block:: c++ + + void* my_alloc1 (size_t) __attribute__((assume_aligned (16))); + void* my_alloc2 (size_t) __attribute__((assume_aligned (32, 8))); + + declares that ``my_alloc1`` returns 16-byte aligned pointers and + that ``my_alloc2`` returns a pointer whose value modulo 32 is equal + to 8. + +.. index:: cold function attribute + +.. fn-attr:: cold + + The :fn-attr:`cold` attribute on functions is used to inform the compiler that + the function is unlikely to be executed. The function is optimized for + size rather than speed and on many targets it is placed into a special + subsection of the text section so all cold functions appear close together, + improving code locality of non-cold parts of program. The paths leading + to calls of cold functions within code are marked as unlikely by the branch + prediction mechanism. It is thus useful to mark functions used to handle + unlikely conditions, such as ``perror``, as cold to improve optimization + of hot functions that do call marked functions in rare occasions. + + When profile feedback is available, via :option:`-fprofile-use`, cold functions + are automatically detected and this attribute is ignored. + +.. index:: const function attribute, functions that have no side effects + +.. fn-attr:: const + + Calls to functions whose return value is not affected by changes to + the observable state of the program and that have no observable effects + on such state other than to return a value may lend themselves to + optimizations such as common subexpression elimination. Declaring such + functions with the :option:`const` attribute allows GCC to avoid emitting + some calls in repeated invocations of the function with the same argument + values. + + For example, + + .. code-block:: c++ + + int square (int) __attribute__ ((const)); + + tells GCC that subsequent calls to function ``square`` with the same + argument value can be replaced by the result of the first call regardless + of the statements in between. + + The :option:`const` attribute prohibits a function from reading objects + that affect its return value between successive invocations. However, + functions declared with the attribute can safely read objects that do + not change their return value, such as non-volatile constants. + + The :fn-attr:`const` attribute imposes greater restrictions on a function's + definition than the similar :fn-attr:`pure` attribute. Declaring the same + function with both the :fn-attr:`const` and the :fn-attr:`pure` attribute is + diagnosed. Because a const function cannot have any observable side + effects it does not make sense for it to return ``void``. Declaring + such a function is diagnosed. + + .. index:: pointer arguments + + Note that a function that has pointer arguments and examines the data + pointed to must *not* be declared :option:`const` if the pointed-to + data might change between successive invocations of the function. In + general, since a function cannot distinguish data that might change + from data that cannot, const functions should never take pointer or, + in C++, reference arguments. Likewise, a function that calls a non-const + function usually must not be const itself. + +.. index:: constructor function attribute, destructor function attribute + +.. fn-attr:: constructor, destructor, constructor (priority), destructor (priority) + + The :fn-attr:`constructor` attribute causes the function to be called + automatically before execution enters ``main ()``. Similarly, the + ``destructor`` attribute causes the function to be called + automatically after ``main ()`` completes or ``exit ()`` is + called. Functions with these attributes are useful for + initializing data that is used implicitly during the execution of + the program. + + On some targets the attributes also accept an integer argument to + specify a priority to control the order in which constructor and + destructor functions are run. A constructor + with a smaller priority number runs before a constructor with a larger + priority number; the opposite relationship holds for destructors. Note + that priorities 0-100 are reserved. So, if you have a constructor that + allocates a resource and a destructor that deallocates the same + resource, both functions typically have the same priority. The + priorities for constructor and destructor functions are the same as + those specified for namespace-scope C++ objects (see :ref:`c++-attributes`). + However, at present, the order in which constructors for C++ objects + with static storage duration and functions decorated with attribute + :fn-attr:`constructor` are invoked is unspecified. In mixed declarations, + attribute ``init_priority`` can be used to impose a specific ordering. + + Using the argument forms of the :fn-attr:`constructor` and ``destructor`` + attributes on targets where the feature is not supported is rejected with + an error. + +.. index:: copy function attribute + +.. fn-attr:: copy, copy (function) + + The :fn-attr:`copy` attribute applies the set of attributes with which + :samp:`{function}` has been declared to the declaration of the function + to which the attribute is applied. The attribute is designed for + libraries that define aliases or function resolvers that are expected + to specify the same set of attributes as their targets. The :fn-attr:`copy` + attribute can be used with functions, variables, or types. However, + the kind of symbol to which the attribute is applied (either function + or variable) must match the kind of symbol to which the argument refers. + The :fn-attr:`copy` attribute copies only syntactic and semantic attributes + but not attributes that affect a symbol's linkage or visibility such as + ``alias``, :fn-attr:`visibility`, or :fn-attr:`weak`. The :fn-attr:`deprecated` + and ``target_clones`` attribute are also not copied. + See :ref:`common-type-attributes`. + See :ref:`common-variable-attributes`. + + For example, the :samp:`{StrongAlias}` macro below makes use of the ``alias`` + and :fn-attr:`copy` attributes to define an alias named :samp:`{alloc}` for function + :samp:`{allocate}` declared with attributes :samp:`{alloc_size}`, :samp:`{malloc}`, and + :samp:`{nothrow}`. Thanks to the ``__typeof__`` operator the alias has + the same type as the target function. As a result of the :fn-attr:`copy` + attribute the alias also shares the same attributes as the target. + + .. code-block:: c++ + + #define StrongAlias(TargetFunc, AliasDecl) \ + extern __typeof__ (TargetFunc) AliasDecl \ + __attribute__ ((alias (#TargetFunc), copy (TargetFunc))); + + extern __attribute__ ((alloc_size (1), malloc, nothrow)) + void* allocate (size_t); + StrongAlias (allocate, alloc); + +.. index:: deprecated function attribute + +.. fn-attr:: deprecated, deprecated (msg) + + The :fn-attr:`deprecated` attribute results in a warning if the function + is used anywhere in the source file. This is useful when identifying + functions that are expected to be removed in a future version of a + program. The warning also includes the location of the declaration + of the deprecated function, to enable users to easily find further + information about why the function is deprecated, or what they should + do instead. Note that the warnings only occurs for uses: + + .. code-block:: c++ + + int old_fn () __attribute__ ((deprecated)); + int old_fn (); + int (*fn_ptr)() = old_fn; + + results in a warning on line 3 but not line 2. The optional :samp:`{msg}` + argument, which must be a string, is printed in the warning if + present. + + The :fn-attr:`deprecated` attribute can also be used for variables and + types (see :ref:`variable-attributes`, see :ref:`type-attributes`.) + + The message attached to the attribute is affected by the setting of + the :option:`-fmessage-length` option. + +.. index:: unavailable function attribute + +.. fn-attr:: unavailable, unavailable (msg) + + The :fn-attr:`unavailable` attribute results in an error if the function + is used anywhere in the source file. This is useful when identifying + functions that have been removed from a particular variation of an + interface. Other than emitting an error rather than a warning, the + :fn-attr:`unavailable` attribute behaves in the same manner as + :fn-attr:`deprecated`. + + The :fn-attr:`unavailable` attribute can also be used for variables and + types (see :ref:`variable-attributes`, see :ref:`type-attributes`.) + +.. index:: error function attribute, warning function attribute + +.. fn-attr:: error ("message"), warning ("message") + + If the ``error`` or ``warning`` attribute + is used on a function declaration and a call to such a function + is not eliminated through dead code elimination or other optimizations, + an error or warning (respectively) that includes :samp:`{message}` is diagnosed. + This is useful + for compile-time checking, especially together with ``__builtin_constant_p`` + and inline functions where checking the inline function arguments is not + possible through ``extern char [(condition) ? 1 : -1];`` tricks. + + While it is possible to leave the function undefined and thus invoke + a link failure (to define the function with + a message in ``.gnu.warning*`` section), + when using these attributes the problem is diagnosed + earlier and with exact location of the call even in presence of inline + functions or when not emitting debugging information. + +.. index:: externally_visible function attribute + +.. fn-attr:: externally_visible + + This attribute, attached to a global variable or function, nullifies + the effect of the :option:`-fwhole-program` command-line option, so the + object remains visible outside the current compilation unit. + + If :option:`-fwhole-program` is used together with :option:`-flto` and + :command:`gold` is used as the linker plugin, + :fn-attr:`externally_visible` attributes are automatically added to functions + (not variable yet due to a current :command:`gold` issue) + that are accessed outside of LTO objects according to resolution file + produced by :command:`gold`. + For other linkers that cannot generate resolution file, + explicit :fn-attr:`externally_visible` attributes are still necessary. + +.. index:: fd_arg function attribute + +.. fn-attr:: fd_arg, fd_arg (N) + + The :fn-attr:`fd_arg` attribute may be applied to a function that takes an open + file descriptor at referenced argument :samp:`{N}`. + + It indicates that the passed filedescriptor must not have been closed. + Therefore, when the analyzer is enabled with :option:`-fanalyzer`, the + analyzer may emit a :option:`-Wanalyzer-fd-use-after-close` diagnostic + if it detects a code path in which a function with this attribute is + called with a closed file descriptor. + + The attribute also indicates that the file descriptor must have been checked for + validity before usage. Therefore, analyzer may emit + :option:`-Wanalyzer-fd-use-without-check` diagnostic if it detects a code path in + which a function with this attribute is called with a file descriptor that has + not been checked for validity. + +.. index:: fd_arg_read function attribute + +.. fn-attr:: fd_arg_read, fd_arg_read (N) + + The :fn-attr:`fd_arg_read` is identical to :fn-attr:`fd_arg`, but with the additional + requirement that it might read from the file descriptor, and thus, the file + descriptor must not have been opened as write-only. + + The analyzer may emit a :option:`-Wanalyzer-access-mode-mismatch` + diagnostic if it detects a code path in which a function with this + attribute is called on a file descriptor opened with ``O_WRONLY``. + +.. index:: fd_arg_write function attribute + +.. fn-attr:: fd_arg_write, fd_arg_write (N) + + The :fn-attr:`fd_arg_write` is identical to :fn-attr:`fd_arg_read` except that the + analyzer may emit a :option:`-Wanalyzer-access-mode-mismatch` diagnostic if + it detects a code path in which a function with this attribute is called on a + file descriptor opened with ``O_RDONLY``. + +.. index:: flatten function attribute + +.. fn-attr:: flatten + + Generally, inlining into a function is limited. For a function marked with + this attribute, every call inside this function is inlined, if possible. + Functions declared with attribute :fn-attr:`noinline` and similar are not + inlined. Whether the function itself is considered for inlining depends + on its size and the current inlining parameters. + +.. index:: format function attribute, functions with printf, scanf, strftime or strfmon style arguments + +.. option:: format (archetype, string-index, first-to-check) + + The ``format`` attribute specifies that a function takes ``printf``, + ``scanf``, ``strftime`` or ``strfmon`` style arguments that + should be type-checked against a format string. For example, the + declaration: + + .. code-block:: c++ + + extern int + my_printf (void *my_object, const char *my_format, ...) + __attribute__ ((format (printf, 2, 3))); + + causes the compiler to check the arguments in calls to ``my_printf`` + for consistency with the ``printf`` style format string argument + ``my_format``. + + The parameter :samp:`{archetype}` determines how the format string is + interpreted, and should be ``printf``, ``scanf``, ``strftime``, + ``gnu_printf``, ``gnu_scanf``, ``gnu_strftime`` or + ``strfmon``. (You can also use ``__printf__``, + ``__scanf__``, ``__strftime__`` or ``__strfmon__``.) On + MinGW targets, ``ms_printf``, ``ms_scanf``, and + ``ms_strftime`` are also present. + :samp:`{archetype}` values such as ``printf`` refer to the formats accepted + by the system's C runtime library, + while values prefixed with :samp:`gnu_` always refer + to the formats accepted by the GNU C Library. On Microsoft Windows + targets, values prefixed with :samp:`ms_` refer to the formats accepted by the + :samp:`msvcrt.dll` library. + The parameter :samp:`{string-index}` + specifies which argument is the format string argument (starting + from 1), while :samp:`{first-to-check}` is the number of the first + argument to check against the format string. For functions + where the arguments are not available to be checked (such as + ``vprintf``), specify the third parameter as zero. In this case the + compiler only checks the format string for consistency. For + ``strftime`` formats, the third parameter is required to be zero. + Since non-static C++ methods have an implicit ``this`` argument, the + arguments of such methods should be counted from two, not one, when + giving values for :samp:`{string-index}` and :samp:`{first-to-check}`. + + In the example above, the format string (``my_format``) is the second + argument of the function ``my_print``, and the arguments to check + start with the third argument, so the correct parameters for the format + attribute are 2 and 3. + + The ``format`` attribute allows you to identify your own functions + that take format strings as arguments, so that GCC can check the + calls to these functions for errors. The compiler always (unless + :option:`-ffreestanding` or :option:`-fno-builtin` is used) checks formats + for the standard library functions ``printf``, ``fprintf``, + ``sprintf``, ``scanf``, ``fscanf``, ``sscanf``, ``strftime``, + ``vprintf``, ``vfprintf`` and ``vsprintf`` whenever such + warnings are requested (using :option:`-Wformat`), so there is no need to + modify the header file :samp:`stdio.h`. In C99 mode, the functions + ``snprintf``, ``vsnprintf``, ``vscanf``, ``vfscanf`` and + ``vsscanf`` are also checked. Except in strictly conforming C + standard modes, the X/Open function ``strfmon`` is also checked as + are ``printf_unlocked`` and ``fprintf_unlocked``. + See :ref:`c-dialect-options`. + + For Objective-C dialects, ``NSString`` (or ``__NSString__``) is + recognized in the same context. Declarations including these format attributes + are parsed for correct syntax, however the result of checking of such format + strings is not yet defined, and is not carried out by this version of the + compiler. + + The target may also provide additional types of format checks. + See :ref:`target-format-checks`. + +.. index:: format_arg function attribute + +.. option:: format_arg (string-index) + + The ``format_arg`` attribute specifies that a function takes one or + more format strings for a ``printf``, ``scanf``, ``strftime`` or + ``strfmon`` style function and modifies it (for example, to translate + it into another language), so the result can be passed to a + ``printf``, ``scanf``, ``strftime`` or ``strfmon`` style + function (with the remaining arguments to the format function the same + as they would have been for the unmodified string). Multiple + ``format_arg`` attributes may be applied to the same function, each + designating a distinct parameter as a format string. For example, the + declaration: + + .. code-block:: c++ + + extern char * + my_dgettext (char *my_domain, const char *my_format) + __attribute__ ((format_arg (2))); + + causes the compiler to check the arguments in calls to a ``printf``, + ``scanf``, ``strftime`` or ``strfmon`` type function, whose + format string argument is a call to the ``my_dgettext`` function, for + consistency with the format string argument ``my_format``. If the + ``format_arg`` attribute had not been specified, all the compiler + could tell in such calls to format functions would be that the format + string argument is not constant; this would generate a warning when + :option:`-Wformat-nonliteral` is used, but the calls could not be checked + without the attribute. + + In calls to a function declared with more than one ``format_arg`` + attribute, each with a distinct argument value, the corresponding + actual function arguments are checked against all format strings + designated by the attributes. This capability is designed to support + the GNU ``ngettext`` family of functions. + + The parameter :samp:`{string-index}` specifies which argument is the format + string argument (starting from one). Since non-static C++ methods have + an implicit ``this`` argument, the arguments of such methods should + be counted from two. + + The ``format_arg`` attribute allows you to identify your own + functions that modify format strings, so that GCC can check the + calls to ``printf``, ``scanf``, ``strftime`` or ``strfmon`` + type function whose operands are a call to one of your own function. + The compiler always treats ``gettext``, ``dgettext``, and + ``dcgettext`` in this manner except when strict ISO C support is + requested by :option:`-ansi` or an appropriate :option:`-std` option, or + :option:`-ffreestanding` or :option:`-fno-builtin` + is used. See :ref:`c-dialect-options`. + + For Objective-C dialects, the ``format-arg`` attribute may refer to an + ``NSString`` reference for compatibility with the ``format`` attribute + above. + + The target may also allow additional types in ``format-arg`` attributes. + See :ref:`target-format-checks`. + +.. index:: gnu_inline function attribute + +.. fn-attr:: gnu_inline + + This attribute should be used with a function that is also declared + with the ``inline`` keyword. It directs GCC to treat the function + as if it were defined in gnu90 mode even when compiling in C99 or + gnu99 mode. + + If the function is declared ``extern``, then this definition of the + function is used only for inlining. In no case is the function + compiled as a standalone function, not even if you take its address + explicitly. Such an address becomes an external reference, as if you + had only declared the function, and had not defined it. This has + almost the effect of a macro. The way to use this is to put a + function definition in a header file with this attribute, and put + another copy of the function, without ``extern``, in a library + file. The definition in the header file causes most calls to the + function to be inlined. If any uses of the function remain, they + refer to the single copy in the library. Note that the two + definitions of the functions need not be precisely the same, although + if they do not have the same effect your program may behave oddly. + + In C, if the function is neither ``extern`` nor ``static``, then + the function is compiled as a standalone function, as well as being + inlined where possible. + + This is how GCC traditionally handled functions declared + ``inline``. Since ISO C99 specifies a different semantics for + ``inline``, this function attribute is provided as a transition + measure and as a useful feature in its own right. This attribute is + available in GCC 4.1.3 and later. It is available if either of the + preprocessor macros ``__GNUC_GNU_INLINE__`` or + ``__GNUC_STDC_INLINE__`` are defined. See :ref:`inline`. + + In C++, this attribute does not depend on ``extern`` in any way, + but it still requires the ``inline`` keyword to enable its special + behavior. + +.. index:: hot function attribute + +.. fn-attr:: hot + + The :fn-attr:`hot` attribute on a function is used to inform the compiler that + the function is a hot spot of the compiled program. The function is + optimized more aggressively and on many targets it is placed into a special + subsection of the text section so all hot functions appear close together, + improving locality. + + When profile feedback is available, via :option:`-fprofile-use`, hot functions + are automatically detected and this attribute is ignored. + +.. index:: ifunc function attribute, indirect functions, functions that are dynamically resolved + +.. fn-attr:: ifunc ("resolver") + + The ``ifunc`` attribute is used to mark a function as an indirect + function using the STT_GNU_IFUNC symbol type extension to the ELF + standard. This allows the resolution of the symbol value to be + determined dynamically at load time, and an optimized version of the + routine to be selected for the particular processor or other system + characteristics determined then. To use this attribute, first define + the implementation functions available, and a resolver function that + returns a pointer to the selected implementation function. The + implementation functions' declarations must match the API of the + function being implemented. The resolver should be declared to + be a function taking no arguments and returning a pointer to + a function of the same type as the implementation. For example: + + .. code-block:: c++ + + void *my_memcpy (void *dst, const void *src, size_t len) + { + ... + return dst; + } + + static void * (*resolve_memcpy (void))(void *, const void *, size_t) + { + return my_memcpy; // we will just always select this routine + } + + The exported header file declaring the function the user calls would + contain: + + .. code-block:: c++ + + extern void *memcpy (void *, const void *, size_t); + + allowing the user to call ``memcpy`` as a regular function, unaware of + the actual implementation. Finally, the indirect function needs to be + defined in the same translation unit as the resolver function: + + .. code-block:: c++ + + void *memcpy (void *, const void *, size_t) + __attribute__ ((ifunc ("resolve_memcpy"))); + + In C++, the ``ifunc`` attribute takes a string that is the mangled name + of the resolver function. A C++ resolver for a non-static member function + of class ``C`` should be declared to return a pointer to a non-member + function taking pointer to ``C`` as the first argument, followed by + the same arguments as of the implementation function. G++ checks + the signatures of the two functions and issues + a :option:`-Wattribute-alias` warning for mismatches. To suppress a warning + for the necessary cast from a pointer to the implementation member function + to the type of the corresponding non-member function use + the :option:`-Wno-pmf-conversions` option. For example: + + .. code-block:: c++ + + class S + { + private: + int debug_impl (int); + int optimized_impl (int); + + typedef int Func (S*, int); + + static Func* resolver (); + public: + + int interface (int); + }; + + int S::debug_impl (int) { /* ... */ } + int S::optimized_impl (int) { /* ... */ } + + S::Func* S::resolver () + { + int (S::*pimpl) (int) + = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl; + + // Cast triggers -Wno-pmf-conversions. + return reinterpret_cast(pimpl); + } + + int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv"))); + + Indirect functions cannot be weak. Binutils version 2.20.1 or higher + and GNU C Library version 2.11.1 are required to use this feature. + +.. fn-attr:: interrupt, interrupt_handler + + Many GCC back ends support attributes to indicate that a function is + an interrupt handler, which tells the compiler to generate function + entry and exit sequences that differ from those from regular + functions. The exact syntax and behavior are target-specific; + refer to the following subsections for details. + +.. index:: leaf function attribute + +.. fn-attr:: leaf + + Calls to external functions with this attribute must return to the + current compilation unit only by return or by exception handling. In + particular, a leaf function is not allowed to invoke callback functions + passed to it from the current compilation unit, directly call functions + exported by the unit, or ``longjmp`` into the unit. Leaf functions + might still call functions from other compilation units and thus they + are not necessarily leaf in the sense that they contain no function + calls at all. + + The attribute is intended for library functions to improve dataflow + analysis. The compiler takes the hint that any data not escaping the + current compilation unit cannot be used or modified by the leaf + function. For example, the ``sin`` function is a leaf function, but + ``qsort`` is not. + + Note that leaf functions might indirectly run a signal handler defined + in the current compilation unit that uses static variables. Similarly, + when lazy symbol resolution is in effect, leaf functions might invoke + indirect functions whose resolver function or implementation function is + defined in the current compilation unit and uses static variables. There + is no standard-compliant way to write such a signal handler, resolver + function, or implementation function, and the best that you can do is to + remove the :fn-attr:`leaf` attribute or mark all such static variables + ``volatile``. Lastly, for ELF-based systems that support symbol + interposition, care should be taken that functions defined in the + current compilation unit do not unexpectedly interpose other symbols + based on the defined standards mode and defined feature test macros; + otherwise an inadvertent callback would be added. + + The attribute has no effect on functions defined within the current + compilation unit. This is to allow easy merging of multiple compilation + units into one, for example, by using the link-time optimization. For + this reason the attribute is not allowed on types to annotate indirect + calls. + +.. index:: malloc function attribute, functions that behave like malloc + +.. fn-attr:: malloc, malloc (deallocator), malloc (deallocator, ptr-index) + + Attribute ``malloc`` indicates that a function is ``malloc`` -like, + i.e., that the pointer :samp:`{P}` returned by the function cannot alias any + other pointer valid when the function returns, and moreover no + pointers to valid objects occur in any storage addressed by :samp:`{P}`. In + addition, the GCC predicts that a function with the attribute returns + non-null in most cases. + + Independently, the form of the attribute with one or two arguments + associates ``deallocator`` as a suitable deallocation function for + pointers returned from the ``malloc`` -like function. :samp:`{ptr-index}` + denotes the positional argument to which when the pointer is passed in + calls to ``deallocator`` has the effect of deallocating it. + + Using the attribute with no arguments is designed to improve optimization + by relying on the aliasing property it implies. Functions like ``malloc`` + and ``calloc`` have this property because they return a pointer to + uninitialized or zeroed-out, newly obtained storage. However, functions + like ``realloc`` do not have this property, as they may return pointers + to storage containing pointers to existing objects. Additionally, since + all such functions are assumed to return null only infrequently, callers + can be optimized based on that assumption. + + Associating a function with a :samp:`{deallocator}` helps detect calls to + mismatched allocation and deallocation functions and diagnose them under + the control of options such as :option:`-Wmismatched-dealloc`. It also + makes it possible to diagnose attempts to deallocate objects that were not + allocated dynamically, by :option:`-Wfree-nonheap-object`. To indicate + that an allocation function both satisifies the nonaliasing property and + has a deallocator associated with it, both the plain form of the attribute + and the one with the :samp:`{deallocator}` argument must be used. The same + function can be both an allocator and a deallocator. Since inlining one + of the associated functions but not the other could result in apparent + mismatches, this form of attribute ``malloc`` is not accepted on inline + functions. For the same reason, using the attribute prevents both + the allocation and deallocation functions from being expanded inline. + + For example, besides stating that the functions return pointers that do + not alias any others, the following declarations make ``fclose`` + a suitable deallocator for pointers returned from all functions except + ``popen``, and ``pclose`` as the only suitable deallocator for + pointers returned from ``popen``. The deallocator functions must + be declared before they can be referenced in the attribute. + + .. code-block:: c++ + + int fclose (FILE*); + int pclose (FILE*); + + __attribute__ ((malloc, malloc (fclose, 1))) + FILE* fdopen (int, const char*); + __attribute__ ((malloc, malloc (fclose, 1))) + FILE* fopen (const char*, const char*); + __attribute__ ((malloc, malloc (fclose, 1))) + FILE* fmemopen(void *, size_t, const char *); + __attribute__ ((malloc, malloc (pclose, 1))) + FILE* popen (const char*, const char*); + __attribute__ ((malloc, malloc (fclose, 1))) + FILE* tmpfile (void); + + The warnings guarded by :option:`-fanalyzer` respect allocation and + deallocation pairs marked with the ``malloc``. In particular: + + * The analyzer will emit a :option:`-Wanalyzer-mismatching-deallocation` + diagnostic if there is an execution path in which the result of an + allocation call is passed to a different deallocator. + + * The analyzer will emit a :option:`-Wanalyzer-double-free` + diagnostic if there is an execution path in which a value is passed + more than once to a deallocation call. + + * The analyzer will consider the possibility that an allocation function + could fail and return NULL. It will emit + :option:`-Wanalyzer-possible-null-dereference` and + :option:`-Wanalyzer-possible-null-argument` diagnostics if there are + execution paths in which an unchecked result of an allocation call is + dereferenced or passed to a function requiring a non-null argument. + If the allocator always returns non-null, use + ``__attribute__ ((returns_nonnull))`` to suppress these warnings. + For example: + + .. code-block:: c++ + + char *xstrdup (const char *) + __attribute__((malloc (free), returns_nonnull)); + + * The analyzer will emit a :option:`-Wanalyzer-use-after-free` + diagnostic if there is an execution path in which the memory passed + by pointer to a deallocation call is used after the deallocation. + + * The analyzer will emit a :option:`-Wanalyzer-malloc-leak` diagnostic if + there is an execution path in which the result of an allocation call + is leaked (without being passed to the deallocation function). + + * The analyzer will emit a :option:`-Wanalyzer-free-of-non-heap` diagnostic + if a deallocation function is used on a global or on-stack variable. + + The analyzer assumes that deallocators can gracefully handle the ``NULL`` + pointer. If this is not the case, the deallocator can be marked with + ``__attribute__((nonnull))`` so that :option:`-fanalyzer` can emit + a :option:`-Wanalyzer-possible-null-argument` diagnostic for code paths + in which the deallocator is called with NULL. + +.. index:: no_icf function attribute + +.. fn-attr:: no_icf + + This function attribute prevents a functions from being merged with another + semantically equivalent function. + +.. index:: no_instrument_function function attribute + +.. option:: no_instrument_function + + If any of :option:`-finstrument-functions`, :option:`-p`, or :option:`-pg` are + given, profiling function calls are + generated at entry and exit of most user-compiled functions. + Functions with this attribute are not so instrumented. + +.. index:: no_profile_instrument_function function attribute + +.. fn-attr:: no_profile_instrument_function + + The :fn-attr:`no_profile_instrument_function` attribute on functions is used + to inform the compiler that it should not process any profile feedback based + optimization code instrumentation. + +.. index:: no_reorder function attribute + +.. fn-attr:: no_reorder + + Do not reorder functions or variables marked :fn-attr:`no_reorder` + against each other or top level assembler statements the executable. + The actual order in the program will depend on the linker command + line. Static variables marked like this are also not removed. + This has a similar effect + as the :option:`-fno-toplevel-reorder` option, but only applies to the + marked symbols. + +.. index:: no_sanitize function attribute + +.. fn-attr:: no_sanitize ("sanitize_option") + + The ``no_sanitize`` attribute on functions is used + to inform the compiler that it should not do sanitization of any option + mentioned in :samp:`{sanitize_option}`. A list of values acceptable by + the :option:`-fsanitize` option can be provided. + + .. code-block:: c++ + + void __attribute__ ((no_sanitize ("alignment", "object-size"))) + f () { /* Do something. */; } + void __attribute__ ((no_sanitize ("alignment,object-size"))) + g () { /* Do something. */; } + +.. index:: no_sanitize_address function attribute + +.. fn-attr:: no_sanitize_address, no_address_safety_analysis + + The :fn-attr:`no_sanitize_address` attribute on functions is used + to inform the compiler that it should not instrument memory accesses + in the function when compiling with the :option:`-fsanitize=address` option. + The ``no_address_safety_analysis`` is a deprecated alias of the + :fn-attr:`no_sanitize_address` attribute, new code should use + :fn-attr:`no_sanitize_address`. + +.. index:: no_sanitize_thread function attribute + +.. fn-attr:: no_sanitize_thread + + The :fn-attr:`no_sanitize_thread` attribute on functions is used + to inform the compiler that it should not instrument memory accesses + in the function when compiling with the :option:`-fsanitize=thread` option. + +.. index:: no_sanitize_undefined function attribute + +.. fn-attr:: no_sanitize_undefined + + The :fn-attr:`no_sanitize_undefined` attribute on functions is used + to inform the compiler that it should not check for undefined behavior + in the function when compiling with the :option:`-fsanitize=undefined` option. + +.. index:: no_sanitize_coverage function attribute + +.. fn-attr:: no_sanitize_coverage + + The :fn-attr:`no_sanitize_coverage` attribute on functions is used + to inform the compiler that it should not do coverage-guided + fuzzing code instrumentation (:option:`-fsanitize-coverage`). + +.. index:: no_split_stack function attribute + +.. option:: no_split_stack + + If :option:`-fsplit-stack` is given, functions have a small + prologue which decides whether to split the stack. Functions with the + ``no_split_stack`` attribute do not have that prologue, and thus + may run with only a small amount of stack space available. + +.. index:: no_stack_limit function attribute + +.. fn-attr:: no_stack_limit + + This attribute locally overrides the :option:`-fstack-limit-register` + and :option:`-fstack-limit-symbol` command-line options; it has the effect + of disabling stack limit checking in the function it applies to. + +.. index:: noclone function attribute + +.. fn-attr:: noclone + + This function attribute prevents a function from being considered for + cloning---a mechanism that produces specialized copies of functions + and which is (currently) performed by interprocedural constant + propagation. + +.. index:: noinline function attribute + +.. fn-attr:: noinline + + This function attribute prevents a function from being considered for + inlining. + + .. Don't enumerate the optimizations by name here; we try to be + + .. future-compatible with this mechanism. + + If the function does not have side effects, there are optimizations + other than inlining that cause function calls to be optimized away, + although the function call is live. To keep such calls from being + optimized away, put + + .. code-block:: c++ + + asm (""); + + (see :ref:`extended-asm`) in the called function, to serve as a special + side effect. + +.. index:: noipa function attribute + +.. fn-attr:: noipa + + Disable interprocedural optimizations between the function with this + attribute and its callers, as if the body of the function is not available + when optimizing callers and the callers are unavailable when optimizing + the body. This attribute implies :fn-attr:`noinline`, :fn-attr:`noclone` and + :fn-attr:`no_icf` attributes. However, this attribute is not equivalent + to a combination of other attributes, because its purpose is to suppress + existing and future optimizations employing interprocedural analysis, + including those that do not have an attribute suitable for disabling + them individually. This attribute is supported mainly for the purpose + of testing the compiler. + +.. index:: nonnull function attribute, functions with non-null pointer arguments + +.. fn-attr:: nonnull, nonnull (arg-index, ...) + + The :fn-attr:`nonnull` attribute may be applied to a function that takes at + least one argument of a pointer type. It indicates that the referenced + arguments must be non-null pointers. For instance, the declaration: + + .. code-block:: c++ + + extern void * + my_memcpy (void *dest, const void *src, size_t len) + __attribute__((nonnull (1, 2))); + + informs the compiler that, in calls to ``my_memcpy``, arguments + :samp:`{dest}` and :samp:`{src}` must be non-null. + + The attribute has an effect both on functions calls and function definitions. + + For function calls: + + * If the compiler determines that a null pointer is + passed in an argument slot marked as non-null, and the + :option:`-Wnonnull` option is enabled, a warning is issued. + See :ref:`warning-options`. + + * The :option:`-fisolate-erroneous-paths-attribute` option can be + specified to have GCC transform calls with null arguments to non-null + functions into traps. See :ref:`optimize-options`. + + * The compiler may also perform optimizations based on the + knowledge that certain function arguments cannot be null. These + optimizations can be disabled by the + :option:`-fno-delete-null-pointer-checks` option. See :ref:`optimize-options`. + + For function definitions: + + * If the compiler determines that a function parameter that is + marked with nonnull is compared with null, and + :option:`-Wnonnull-compare` option is enabled, a warning is issued. + See :ref:`warning-options`. + + * The compiler may also perform optimizations based on the + knowledge that ``nonnul`` parameters cannot be null. This can + currently not be disabled other than by removing the nonnull + attribute. + + If no :samp:`{arg-index}` is given to the :fn-attr:`nonnull` attribute, + all pointer arguments are marked as non-null. To illustrate, the + following declaration is equivalent to the previous example: + + .. code-block:: c++ + + extern void * + my_memcpy (void *dest, const void *src, size_t len) + __attribute__((nonnull)); + +.. index:: noplt function attribute + +.. fn-attr:: noplt + + The :fn-attr:`noplt` attribute is the counterpart to option :option:`-fno-plt`. + Calls to functions marked with this attribute in position-independent code + do not use the PLT. + + .. code-block:: c++ + + /* Externally defined function foo. */ + int foo () __attribute__ ((noplt)); + + int + main (/* ... */) + { + /* ... */ + foo (); + /* ... */ + } + + The :fn-attr:`noplt` attribute on function ``foo`` + tells the compiler to assume that + the function ``foo`` is externally defined and that the call to + ``foo`` must avoid the PLT + in position-independent code. + + In position-dependent code, a few targets also convert calls to + functions that are marked to not use the PLT to use the GOT instead. + +.. index:: noreturn function attribute, functions that never return + +.. fn-attr:: noreturn + + A few standard library functions, such as ``abort`` and ``exit``, + cannot return. GCC knows this automatically. Some programs define + their own functions that never return. You can declare them + :fn-attr:`noreturn` to tell the compiler this fact. For example, + + .. code-block:: c++ + + void fatal () __attribute__ ((noreturn)); + + void + fatal (/* ... */) + { + /* ... */ /* Print error message. */ /* ... */ + exit (1); + } + + The :fn-attr:`noreturn` keyword tells the compiler to assume that + ``fatal`` cannot return. It can then optimize without regard to what + would happen if ``fatal`` ever did return. This makes slightly + better code. More importantly, it helps avoid spurious warnings of + uninitialized variables. + + The :fn-attr:`noreturn` keyword does not affect the exceptional path when that + applies: a :fn-attr:`noreturn` -marked function may still return to the caller + by throwing an exception or calling ``longjmp``. + + In order to preserve backtraces, GCC will never turn calls to + :fn-attr:`noreturn` functions into tail calls. + + Do not assume that registers saved by the calling function are + restored before calling the :fn-attr:`noreturn` function. + + It does not make sense for a :fn-attr:`noreturn` function to have a return + type other than ``void``. + +.. index:: nothrow function attribute + +.. fn-attr:: nothrow + + The :fn-attr:`nothrow` attribute is used to inform the compiler that a + function cannot throw an exception. For example, most functions in + the standard C library can be guaranteed not to throw an exception + with the notable exceptions of ``qsort`` and ``bsearch`` that + take function pointer arguments. + +.. index:: optimize function attribute + +.. fn-attr:: optimize (level, ...), optimize (string, ...) + +.. fn-attr:: optimize (string, ...) + + The ``optimize`` attribute is used to specify that a function is to + be compiled with different optimization options than specified on the + command line. The optimize attribute arguments of a function behave + behave as if appended to the command-line. + + Valid arguments are constant non-negative integers and + strings. Each numeric argument specifies an optimization :samp:`{level}`. + Each :samp:`{string}` argument consists of one or more comma-separated + substrings. Each substring that begins with the letter ``O`` refers + to an optimization option such as :option:`-O0` or :option:`-Os`. Other + substrings are taken as suffixes to the ``-f`` prefix jointly + forming the name of an optimization option. See :ref:`optimize-options`. + + :samp:`#pragma GCC optimize` can be used to set optimization options + for more than one function. See :ref:`function-specific-option-pragmas`, + for details about the pragma. + + Providing multiple strings as arguments separated by commas to specify + multiple options is equivalent to separating the option suffixes with + a comma (:samp:`,`) within a single string. Spaces are not permitted + within the strings. + + Not every optimization option that starts with the :samp:`{-f}` prefix + specified by the attribute necessarily has an effect on the function. + The ``optimize`` attribute should be used for debugging purposes only. + It is not suitable in production code. + +.. index:: patchable_function_entry function attribute, extra NOP instructions at the function entry point + +.. fn-attr:: patchable_function_entry + + In case the target's text segment can be made writable at run time by + any means, padding the function entry with a number of NOPs can be + used to provide a universal tool for instrumentation. + + The :fn-attr:`patchable_function_entry` function attribute can be used to + change the number of NOPs to any desired value. The two-value syntax + is the same as for the command-line switch + :option:`-fpatchable-function-entry=N,M`, generating :samp:`{N}` NOPs, with + the function entry point before the :samp:`{M}` th NOP instruction. + :samp:`{M}` defaults to 0 if omitted e.g. function entry point is before + the first NOP. + + If patchable function entries are enabled globally using the command-line + option :option:`-fpatchable-function-entry=N,M`, then you must disable + instrumentation on all functions that are part of the instrumentation + framework with the attribute ``patchable_function_entry (0)`` + to prevent recursion. + +.. index:: pure function attribute, functions that have no side effects + +.. fn-attr:: pure + + Calls to functions that have no observable effects on the state of + the program other than to return a value may lend themselves to optimizations + such as common subexpression elimination. Declaring such functions with + the :fn-attr:`pure` attribute allows GCC to avoid emitting some calls in repeated + invocations of the function with the same argument values. + + The :fn-attr:`pure` attribute prohibits a function from modifying the state + of the program that is observable by means other than inspecting + the function's return value. However, functions declared with the :fn-attr:`pure` + attribute can safely read any non-volatile objects, and modify the value of + objects in a way that does not affect their return value or the observable + state of the program. + + For example, + + .. code-block:: c++ + + int hash (char *) __attribute__ ((pure)); + + tells GCC that subsequent calls to the function ``hash`` with the same + string can be replaced by the result of the first call provided the state + of the program observable by ``hash``, including the contents of the array + itself, does not change in between. Even though ``hash`` takes a non-const + pointer argument it must not modify the array it points to, or any other object + whose value the rest of the program may depend on. However, the caller may + safely change the contents of the array between successive calls to + the function (doing so disables the optimization). The restriction also + applies to member objects referenced by the ``this`` pointer in C++ + non-static member functions. + + Some common examples of pure functions are ``strlen`` or ``memcmp``. + Interesting non-pure functions are functions with infinite loops or those + depending on volatile memory or other system resource, that may change between + consecutive calls (such as the standard C ``feof`` function in + a multithreading environment). + + The :fn-attr:`pure` attribute imposes similar but looser restrictions on + a function's definition than the :fn-attr:`const` attribute: :fn-attr:`pure` + allows the function to read any non-volatile memory, even if it changes + in between successive invocations of the function. Declaring the same + function with both the :fn-attr:`pure` and the :fn-attr:`const` attribute is + diagnosed. Because a pure function cannot have any observable side + effects it does not make sense for such a function to return ``void``. + Declaring such a function is diagnosed. + +.. index:: returns_nonnull function attribute + +.. fn-attr:: returns_nonnull + + The :fn-attr:`returns_nonnull` attribute specifies that the function + return value should be a non-null pointer. For instance, the declaration: + + .. code-block:: c++ + + extern void * + mymalloc (size_t len) __attribute__((returns_nonnull)); + + lets the compiler optimize callers based on the knowledge + that the return value will never be null. + +.. index:: returns_twice function attribute, functions that return more than once + +.. fn-attr:: returns_twice + + The :fn-attr:`returns_twice` attribute tells the compiler that a function may + return more than one time. The compiler ensures that all registers + are dead before calling such a function and emits a warning about + the variables that may be clobbered after the second return from the + function. Examples of such functions are ``setjmp`` and ``vfork``. + The ``longjmp`` -like counterpart of such function, if any, might need + to be marked with the :fn-attr:`noreturn` attribute. + +.. index:: section function attribute, functions in arbitrary sections + +.. fn-attr:: section ("section-name") + + Normally, the compiler places the code it generates in the ``text`` section. + Sometimes, however, you need additional sections, or you need certain + particular functions to appear in special sections. The ``section`` + attribute specifies that a function lives in a particular section. + For example, the declaration: + + .. code-block:: c++ + + extern void foobar (void) __attribute__ ((section ("bar"))); + + puts the function ``foobar`` in the ``bar`` section. + + Some file formats do not support arbitrary sections so the ``section`` + attribute is not available on all platforms. + If you need to map the entire contents of a module to a particular + section, consider using the facilities of the linker instead. + +.. index:: sentinel function attribute + +.. fn-attr:: sentinel, sentinel (position) + + This function attribute indicates that an argument in a call to the function + is expected to be an explicit ``NULL``. The attribute is only valid on + variadic functions. By default, the sentinel is expected to be the last + argument of the function call. If the optional :samp:`{position}` argument + is specified to the attribute, the sentinel must be located at + :samp:`{position}` counting backwards from the end of the argument list. + + .. code-block:: c++ + + __attribute__ ((sentinel)) + is equivalent to + __attribute__ ((sentinel(0))) + + The attribute is automatically set with a position of 0 for the built-in + functions ``execl`` and ``execlp``. The built-in function + ``execle`` has the attribute set with a position of 1. + + A valid ``NULL`` in this context is defined as zero with any object + pointer type. If your system defines the ``NULL`` macro with + an integer type then you need to add an explicit cast. During + installation GCC replaces the system ```` header with + a copy that redefines NULL appropriately. + + The warnings for missing or incorrect sentinels are enabled with + :option:`-Wformat`. + +.. index:: simd function attribute + +.. fn-attr:: simd, simd("mask") + + This attribute enables creation of one or more function versions that + can process multiple arguments using SIMD instructions from a + single invocation. Specifying this attribute allows compiler to + assume that such versions are available at link time (provided + in the same or another translation unit). Generated versions are + target-dependent and described in the corresponding Vector ABI document. For + x86_64 target this document can be found + `here `_. + + The optional argument :samp:`{mask}` may have the value + ``notinbranch`` or ``inbranch``, + and instructs the compiler to generate non-masked or masked + clones correspondingly. By default, all clones are generated. + + If the attribute is specified and ``#pragma omp declare simd`` is + present on a declaration and the :option:`-fopenmp` or :option:`-fopenmp-simd` + switch is specified, then the attribute is ignored. + +.. index:: stack_protect function attribute + +.. fn-attr:: stack_protect + + This attribute adds stack protection code to the function if + flags :option:`-fstack-protector`, :option:`-fstack-protector-strong` + or :option:`-fstack-protector-explicit` are set. + +.. index:: no_stack_protector function attribute + +.. fn-attr:: no_stack_protector + + This attribute prevents stack protection code for the function. + +.. index:: target function attribute + +.. fn-attr:: target (string, ...) + + Multiple target back ends implement the ``target`` attribute + to specify that a function is to + be compiled with different target options than specified on the + command line. The original target command-line options are ignored. + One or more strings can be provided as arguments. + Each string consists of one or more comma-separated suffixes to + the ``-m`` prefix jointly forming the name of a machine-dependent + option. See :ref:`submodel-options`. + + The ``target`` attribute can be used for instance to have a function + compiled with a different ISA (instruction set architecture) than the + default. :samp:`#pragma GCC target` can be used to specify target-specific + options for more than one function. See :ref:`function-specific-option-pragmas`, + for details about the pragma. + + For instance, on an x86, you could declare one function with the + ``target("sse4.1,arch=core2")`` attribute and another with + ``target("sse4a,arch=amdfam10")``. This is equivalent to + compiling the first function with :option:`-msse4.1` and + :option:`-march=core2` options, and the second function with + :option:`-msse4a` and :option:`-march=amdfam10` options. It is up to you + to make sure that a function is only invoked on a machine that + supports the particular ISA it is compiled for (for example by using + ``cpuid`` on x86 to determine what feature bits and architecture + family are used). + + .. code-block:: c++ + + int core2_func (void) __attribute__ ((__target__ ("arch=core2"))); + int sse3_func (void) __attribute__ ((__target__ ("sse3"))); + + Providing multiple strings as arguments separated by commas to specify + multiple options is equivalent to separating the option suffixes with + a comma (:samp:`,`) within a single string. Spaces are not permitted + within the strings. + + The options supported are specific to each target; refer to :ref:`x86-function-attributes`, :ref:`powerpc-function-attributes`, + :ref:`arm-function-attributes`, :ref:`aarch64-function-attributes`, + :ref:`nios-ii-function-attributes`, and :ref:`s-390-function-attributes` + for details. + +.. index:: symver function attribute + +.. fn-attr:: symver ("name2@nodename") + + On ELF targets this attribute creates a symbol version. The :samp:`{name2}` part + of the parameter is the actual name of the symbol by which it will be + externally referenced. The ``nodename`` portion should be the name of a + node specified in the version script supplied to the linker when building a + shared library. Versioned symbol must be defined and must be exported with + default visibility. + + .. code-block:: c++ + + __attribute__ ((__symver__ ("foo@VERS_1"))) int + foo_v1 (void) + { + } + + Will produce a ``.symver foo_v1, foo@VERS_1`` directive in the assembler + output. + + One can also define multiple version for a given symbol + (starting from binutils 2.35). + + .. code-block:: c++ + + __attribute__ ((__symver__ ("foo@VERS_2"), __symver__ ("foo@VERS_3"))) + int symver_foo_v1 (void) + { + } + + This example creates a symbol name ``symver_foo_v1`` + which will be version ``VERS_2`` and ``VERS_3`` of ``foo``. + + If you have an older release of binutils, then symbol alias needs to + be used: + + .. code-block:: c++ + + __attribute__ ((__symver__ ("foo@VERS_2"))) + int foo_v1 (void) + { + return 0; + } + + __attribute__ ((__symver__ ("foo@VERS_3"))) + __attribute__ ((alias ("foo_v1"))) + int symver_foo_v1 (void); + + Finally if the parameter is ``"name2@@nodename"`` then in + addition to creating a symbol version (as if + ``"name2@nodename"`` was used) the version will be also used + to resolve :samp:`{name2}` by the linker. + +.. index:: tainted_args function attribute + +.. fn-attr:: tainted_args + + The :fn-attr:`tainted_args` attribute is used to specify that a function is called + in a way that requires sanitization of its arguments, such as a system + call in an operating system kernel. Such a function can be considered part + of the 'attack surface' of the program. The attribute can be used both + on function declarations, and on field declarations containing function + pointers. In the latter case, any function used as an initializer of + such a callback field will be treated as being called with tainted + arguments. + + The analyzer will pay particular attention to such functions when both + :option:`-fanalyzer` and :option:`-fanalyzer-checker=taint` are supplied, + potentially issuing warnings guarded by + :option:`-Wanalyzer-tainted-allocation-size`, + :option:`-Wanalyzer-tainted-array-index`, + :option:`-Wanalyzer-tainted-divisor`, + :option:`-Wanalyzer-tainted-offset`, + and :option:`-Wanalyzer-tainted-size`. + +.. index:: target_clones function attribute + +.. fn-attr:: target_clones (options) + + The ``target_clones`` attribute is used to specify that a function + be cloned into multiple versions compiled with different target options + than specified on the command line. The supported options and restrictions + are the same as for ``target`` attribute. + + For instance, on an x86, you could compile a function with + ``target_clones("sse4.1,avx")``. GCC creates two function clones, + one compiled with :option:`-msse4.1` and another with :option:`-mavx`. + + On a PowerPC, you can compile a function with + ``target_clones("cpu=power9,default")``. GCC will create two + function clones, one compiled with :option:`-mcpu=power9` and another + with the default options. GCC must be configured to use GLIBC 2.23 or + newer in order to use the ``target_clones`` attribute. + + It also creates a resolver function (see + the ``ifunc`` attribute above) that dynamically selects a clone + suitable for current architecture. The resolver is created only if there + is a usage of a function with ``target_clones`` attribute. + + Note that any subsequent call of a function without ``target_clone`` + from a ``target_clone`` caller will not lead to copying + (target clone) of the called function. + If you want to enforce such behaviour, + we recommend declaring the calling function with the :fn-attr:`flatten` attribute? + +.. index:: unused function attribute + +.. fn-attr:: unused + + This attribute, attached to a function, means that the function is meant + to be possibly unused. GCC does not produce a warning for this + function. + +.. index:: used function attribute + +.. fn-attr:: used + + This attribute, attached to a function, means that code must be emitted + for the function even if it appears that the function is not referenced. + This is useful, for example, when the function is referenced only in + inline assembly. + + When applied to a member function of a C++ class template, the + attribute also means that the function is instantiated if the + class itself is instantiated. + +.. index:: retain function attribute + +.. fn-attr:: retain + + For ELF targets that support the GNU or FreeBSD OSABIs, this attribute + will save the function from linker garbage collection. To support + this behavior, functions that have not been placed in specific sections + (e.g. by the ``section`` attribute, or the ``-ffunction-sections`` + option), will be placed in new, unique sections. + + This additional functionality requires Binutils version 2.36 or later. + +.. index:: visibility function attribute + +.. fn-attr:: visibility ("visibility_type") + + This attribute affects the linkage of the declaration to which it is attached. + It can be applied to variables (see :ref:`common-variable-attributes`) and types + (see :ref:`common-type-attributes`) as well as functions. + + There are four supported :samp:`{visibility_type}` values: default, + hidden, protected or internal visibility. + + .. code-block:: c++ + + void __attribute__ ((visibility ("protected"))) + f () { /* Do something. */; } + int i __attribute__ ((visibility ("hidden"))); + + The possible values of :samp:`{visibility_type}` correspond to the + visibility settings in the ELF gABI. + + .. keep this list of visibilities in alphabetical order. + + ``default`` + Default visibility is the normal case for the object file format. + This value is available for the visibility attribute to override other + options that may change the assumed visibility of entities. + + On ELF, default visibility means that the declaration is visible to other + modules and, in shared libraries, means that the declared entity may be + overridden. + + On Darwin, default visibility means that the declaration is visible to + other modules. + + Default visibility corresponds to 'external linkage' in the language. + + ``hidden`` + Hidden visibility indicates that the entity declared has a new + form of linkage, which we call 'hidden linkage'. Two + declarations of an object with hidden linkage refer to the same object + if they are in the same shared object. + + ``internal`` + Internal visibility is like hidden visibility, but with additional + processor specific semantics. Unless otherwise specified by the + psABI, GCC defines internal visibility to mean that a function is + *never* called from another module. Compare this with hidden + functions which, while they cannot be referenced directly by other + modules, can be referenced indirectly via function pointers. By + indicating that a function cannot be called from outside the module, + GCC may for instance omit the load of a PIC register since it is known + that the calling function loaded the correct value. + + ``protected`` + Protected visibility is like default visibility except that it + indicates that references within the defining module bind to the + definition in that module. That is, the declared entity cannot be + overridden by another module. + + All visibilities are supported on many, but not all, ELF targets + (supported when the assembler supports the :samp:`.visibility` + pseudo-op). Default visibility is supported everywhere. Hidden + visibility is supported on Darwin targets. + + The visibility attribute should be applied only to declarations that + would otherwise have external linkage. The attribute should be applied + consistently, so that the same entity should not be declared with + different settings of the attribute. + + In C++, the visibility attribute applies to types as well as functions + and objects, because in C++ types have linkage. A class must not have + greater visibility than its non-static data member types and bases, + and class members default to the visibility of their class. Also, a + declaration without explicit visibility is limited to the visibility + of its type. + + In C++, you can mark member functions and static member variables of a + class with the visibility attribute. This is useful if you know a + particular method or static member variable should only be used from + one shared object; then you can mark it hidden while the rest of the + class has default visibility. Care must be taken to avoid breaking + the One Definition Rule; for example, it is usually not useful to mark + an inline method as hidden without marking the whole class as hidden. + + A C++ namespace declaration can also have the visibility attribute. + + .. code-block:: c++ + + namespace nspace1 __attribute__ ((visibility ("protected"))) + { /* Do something. */; } + + This attribute applies only to the particular namespace body, not to + other definitions of the same namespace; it is equivalent to using + :samp:`#pragma GCC visibility` before and after the namespace + definition (see :ref:`visibility-pragmas`). + + In C++, if a template argument has limited visibility, this + restriction is implicitly propagated to the template instantiation. + Otherwise, template instantiations and specializations default to the + visibility of their template. + + If both the template and enclosing class have explicit visibility, the + visibility from the template is used. + +.. index:: warn_unused_result function attribute + +.. fn-attr:: warn_unused_result + + The :fn-attr:`warn_unused_result` attribute causes a warning to be emitted + if a caller of the function with this attribute does not use its + return value. This is useful for functions where not checking + the result is either a security problem or always a bug, such as + ``realloc``. + + .. code-block:: c++ + + int fn () __attribute__ ((warn_unused_result)); + int foo () + { + if (fn () < 0) return -1; + fn (); + return 0; + } + + results in warning on line 5. + +.. index:: weak function attribute + +.. fn-attr:: weak + + The :fn-attr:`weak` attribute causes a declaration of an external symbol + to be emitted as a weak symbol rather than a global. This is primarily + useful in defining library functions that can be overridden in user code, + though it can also be used with non-function declarations. The overriding + symbol must have the same type as the weak symbol. In addition, if it + designates a variable it must also have the same size and alignment as + the weak symbol. Weak symbols are supported for ELF targets, and also + for a.out targets when using the GNU assembler and linker. + +.. index:: weakref function attribute + +.. fn-attr:: weakref, weakref ("target") + + The :fn-attr:`weakref` attribute marks a declaration as a weak reference. + Without arguments, it should be accompanied by an ``alias`` attribute + naming the target symbol. Alternatively, :samp:`{target}` may be given as + an argument to :fn-attr:`weakref` itself, naming the target definition of + the alias. The :samp:`{target}` must have the same type as the declaration. + In addition, if it designates a variable it must also have the same size + and alignment as the declaration. In either form of the declaration + :fn-attr:`weakref` implicitly marks the declared symbol as :fn-attr:`weak`. Without + a :samp:`{target}` given as an argument to :fn-attr:`weakref` or to ``alias``, + :fn-attr:`weakref` is equivalent to :fn-attr:`weak` (in that case the declaration + may be ``extern``). + + .. code-block:: c++ + + /* Given the declaration: */ + extern int y (void); + + /* the following... */ + static int x (void) __attribute__ ((weakref ("y"))); + + /* is equivalent to... */ + static int x (void) __attribute__ ((weakref, alias ("y"))); + + /* or, alternatively, to... */ + static int x (void) __attribute__ ((weakref)); + static int x (void) __attribute__ ((alias ("y"))); + + A weak reference is an alias that does not by itself require a + definition to be given for the target symbol. If the target symbol is + only referenced through weak references, then it becomes a :fn-attr:`weak` + undefined symbol. If it is directly referenced, however, then such + strong references prevail, and a definition is required for the + symbol, not necessarily in the same translation unit. + + The effect is equivalent to moving all references to the alias to a + separate translation unit, renaming the alias to the aliased symbol, + declaring it as weak, compiling the two separate translation units and + performing a link with relocatable output (i.e. ``ld -r``) on them. + + A declaration to which :fn-attr:`weakref` is attached and that is associated + with a named ``target`` must be ``static``. + +.. index:: zero_call_used_regs function attribute + +.. fn-attr:: zero_call_used_regs ("choice") + + The ``zero_call_used_regs`` attribute causes the compiler to zero + a subset of all call-used registers ([#f1]_) at function return. + This is used to increase program security by either mitigating + Return-Oriented Programming (ROP) attacks or preventing information leakage + through registers. + + In order to satisfy users with different security needs and control the + run-time overhead at the same time, the :samp:`{choice}` parameter provides a + flexible way to choose the subset of the call-used registers to be zeroed. + The three basic values of :samp:`{choice}` are: + + * :samp:`skip` doesn't zero any call-used registers. + + * :samp:`used` only zeros call-used registers that are used in the function. + A 'used' register is one whose content has been set or referenced in + the function. + + * :samp:`all` zeros all call-used registers. + + In addition to these three basic choices, it is possible to modify + :samp:`used` or :samp:`all` as follows: + + * Adding :samp:`-gpr` restricts the zeroing to general-purpose registers. + + * Adding :samp:`-arg` restricts the zeroing to registers that can sometimes + be used to pass function arguments. This includes all argument registers + defined by the platform's calling conversion, regardless of whether the + function uses those registers for function arguments or not. + + The modifiers can be used individually or together. If they are used + together, they must appear in the order above. + + The full list of :samp:`{choice}` s is therefore: + + ``skip`` + doesn't zero any call-used register. + + ``used`` + only zeros call-used registers that are used in the function. + + ``used-gpr`` + only zeros call-used general purpose registers that are used in the function. + + ``used-arg`` + only zeros call-used registers that are used in the function and pass arguments. + + ``used-gpr-arg`` + only zeros call-used general purpose registers that are used in the function + and pass arguments. + + ``all`` + zeros all call-used registers. + + ``all-gpr`` + zeros all call-used general purpose registers. + + ``all-arg`` + zeros all call-used registers that pass arguments. + + ``all-gpr-arg`` + zeros all call-used general purpose registers that pass + arguments. + + Of this list, :samp:`used-arg`, :samp:`used-gpr-arg`, :samp:`all-arg`, + and :samp:`all-gpr-arg` are mainly used for ROP mitigation. + + The default for the attribute is controlled by :option:`-fzero-call-used-regs`. + +.. This is the end of the target-independent attribute table + +.. [#f1] A 'call-used' register + is a register whose contents can be changed by a function call; + therefore, a caller cannot assume that the register has the same contents + on return from the function as it had before calling the function. Such + registers are also called 'call-clobbered', 'caller-saved', or + 'volatile'. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/epiphany-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/epiphany-function-attributes.rst new file mode 100644 index 00000000000..da7441d2257 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/epiphany-function-attributes.rst @@ -0,0 +1,82 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _epiphany-function-attributes: + +Epiphany Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the Epiphany back end: + +.. index:: disinterrupt function attribute, Epiphany + +.. epiphany-fn-attr:: disinterrupt + + This attribute causes the compiler to emit + instructions to disable interrupts for the duration of the given + function. + +.. index:: forwarder_section function attribute, Epiphany + +.. epiphany-fn-attr:: forwarder_section + + This attribute modifies the behavior of an interrupt handler. + The interrupt handler may be in external memory which cannot be + reached by a branch instruction, so generate a local memory trampoline + to transfer control. The single parameter identifies the section where + the trampoline is placed. + +.. index:: interrupt function attribute, Epiphany + +.. epiphany-fn-attr:: interrupt + + Use this attribute to indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when this attribute is present. It may also generate + a special section with code to initialize the interrupt vector table. + + On Epiphany targets one or more optional parameters can be added like this: + + .. code-block:: c++ + + void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler (); + + Permissible values for these parameters are: :epiphany-fn-attr:`reset`, + ``software_exception``, ``page_miss``, + ``timer0``, ``timer1``, ``message``, + ``dma0``, ``dma1``, ``wand`` and ``swi``. + Multiple parameters indicate that multiple entries in the interrupt + vector table should be initialized for this function, i.e. for each + parameter :samp:`{name}`, a jump to the function is emitted in + the section ivt_entry\_ :samp:`{name}`. The parameter(s) may be omitted + entirely, in which case no interrupt vector table entry is provided. + + Note that interrupts are enabled inside the function + unless the :epiphany-fn-attr:`disinterrupt` attribute is also specified. + + The following examples are all valid uses of these attributes on + Epiphany targets: + + .. code-block:: c++ + + void __attribute__ ((interrupt)) universal_handler (); + void __attribute__ ((interrupt ("dma1"))) dma1_handler (); + void __attribute__ ((interrupt ("dma0, dma1"))) + universal_dma_handler (); + void __attribute__ ((interrupt ("timer0"), disinterrupt)) + fast_timer_handler (); + void __attribute__ ((interrupt ("dma0, dma1"), + forwarder_section ("tramp"))) + external_dma_handler (); + +.. index:: long_call function attribute, Epiphany, short_call function attribute, Epiphany, indirect calls, Epiphany + +.. epiphany-fn-attr:: long_call, short_call + + These attributes specify how a particular function is called. + These attributes override the + :option:`-mlong-calls` (see :ref:`adapteva-epiphany-options`) + command-line switch and ``#pragma long_calls`` settings. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/h8-300-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/h8-300-function-attributes.rst new file mode 100644 index 00000000000..70a929f8ad4 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/h8-300-function-attributes.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _h8-300-function-attributes: + +H8/300 Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are available for H8/300 targets: + +.. index:: function_vector function attribute, H8/300 + +.. h8-300-fn-attr:: function_vector + + Use this attribute on the H8/300, H8/300H, and H8S to indicate + that the specified function should be called through the function vector. + Calling a function through the function vector reduces code size; however, + the function vector has a limited size (maximum 128 entries on the H8/300 + and 64 entries on the H8/300H and H8S) + and shares space with the interrupt vector. + +.. index:: interrupt_handler function attribute, H8/300 + +.. h8-300-fn-attr:: interrupt_handler + + Use this attribute on the H8/300, H8/300H, and H8S to + indicate that the specified function is an interrupt handler. The compiler + generates function entry and exit sequences suitable for use in an + interrupt handler when this attribute is present. + +.. index:: saveall function attribute, H8/300, save all registers on the H8/300, H8/300H, and H8S + +.. h8-300-fn-attr:: saveall + + Use this attribute on the H8/300, H8/300H, and H8S to indicate that + all registers except the stack pointer should be saved in the prologue + regardless of whether they are used or not. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/ia-64-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/ia-64-function-attributes.rst new file mode 100644 index 00000000000..5be539efa17 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/ia-64-function-attributes.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ia-64-function-attributes: + +IA-64 Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported on IA-64 targets: + +.. index:: syscall_linkage function attribute, IA-64 + +.. ia-64-fn-attr:: syscall_linkage + + This attribute is used to modify the IA-64 calling convention by marking + all input registers as live at all function exits. This makes it possible + to restart a system call after an interrupt without having to save/restore + the input registers. This also prevents kernel data from leaking into + application code. + +.. index:: version_id function attribute, IA-64 + +.. ia-64-fn-attr:: version_id + + This IA-64 HP-UX attribute, attached to a global variable or function, renames a + symbol to contain a version string, thus allowing for function level + versioning. HP-UX system header files may use function level versioning + for some system calls. + + .. code-block:: c++ + + extern int foo () __attribute__((version_id ("20040821"))); + + Calls to ``foo`` are mapped to calls to ``foo{20040821}``. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m32c-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m32c-function-attributes.rst new file mode 100644 index 00000000000..4c1f863b841 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m32c-function-attributes.rst @@ -0,0 +1,75 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _m32c-function-attributes: + +M32C Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the M32C back end: + +.. index:: bank_switch function attribute, M32C + +.. m32c-fn-attr:: bank_switch + + When added to an interrupt handler with the M32C port, causes the + prologue and epilogue to use bank switching to preserve the registers + rather than saving them on the stack. + +.. index:: fast_interrupt function attribute, M32C + +.. m32c-fn-attr:: fast_interrupt + + Use this attribute on the M32C port to indicate that the specified + function is a fast interrupt handler. This is just like the + :m32c-fn-attr:`interrupt` attribute, except that ``freit`` is used to return + instead of ``reit``. + +.. index:: function_vector function attribute, M16C/M32C + +.. m32c-fn-attr:: function_vector + + On M16C/M32C targets, the :m32c-fn-attr:`function_vector` attribute declares a + special page subroutine call function. Use of this attribute reduces + the code size by 2 bytes for each call generated to the + subroutine. The argument to the attribute is the vector number entry + from the special page vector table which contains the 16 low-order + bits of the subroutine's entry address. Each vector table has special + page number (18 to 255) that is used in ``jsrs`` instructions. + Jump addresses of the routines are generated by adding 0x0F0000 (in + case of M16C targets) or 0xFF0000 (in case of M32C targets), to the + 2-byte addresses set in the vector table. Therefore you need to ensure + that all the special page vector routines should get mapped within the + address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF + (for M32C). + + In the following example 2 bytes are saved for each call to + function ``foo``. + + .. code-block:: c++ + + void foo (void) __attribute__((function_vector(0x18))); + void foo (void) + { + } + + void bar (void) + { + foo(); + } + + If functions are defined in one file and are called in another file, + then be sure to write this declaration in both files. + + This attribute is ignored for R8C target. + +.. index:: interrupt function attribute, M32C + +.. m32c-fn-attr:: interrupt + + Use this attribute to indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when this attribute is present. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m32r-d-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m32r-d-function-attributes.rst new file mode 100644 index 00000000000..04bb01f1423 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m32r-d-function-attributes.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _m32r-d-function-attributes: + +M32R/D Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the M32R/D back end: + +.. index:: interrupt function attribute, M32R/D + +.. m32r-d-fn-attr:: interrupt + + Use this attribute to indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when this attribute is present. + +.. index:: model function attribute, M32R/D, function addressability on the M32R/D + +.. m32r-d-fn-attr:: model (model-name) + + On the M32R/D, use this attribute to set the addressability of an + object, and of the code generated for a function. The identifier + :samp:`{model-name}` is one of ``small``, ``medium``, or + ``large``, representing each of the code models. + + Small model objects live in the lower 16MB of memory (so that their + addresses can be loaded with the ``ld24`` instruction), and are + callable with the ``bl`` instruction. + + Medium model objects may live anywhere in the 32-bit address space (the + compiler generates ``seth/add3`` instructions to load their addresses), + and are callable with the ``bl`` instruction. + + Large model objects may live anywhere in the 32-bit address space (the + compiler generates ``seth/add3`` instructions to load their addresses), + and may not be reachable with the ``bl`` instruction (the compiler + generates the much slower ``seth/add3/jl`` instruction sequence). \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m68k-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m68k-function-attributes.rst new file mode 100644 index 00000000000..b2fa7191f77 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/m68k-function-attributes.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _m68k-function-attributes: + +m68k Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the m68k back end: + +.. index:: interrupt function attribute, m68k, interrupt_handler function attribute, m68k + +.. m68k-fn-attr:: interrupt, interrupt_handler + + Use this attribute to + indicate that the specified function is an interrupt handler. The compiler + generates function entry and exit sequences suitable for use in an + interrupt handler when this attribute is present. Either name may be used. + +.. index:: interrupt_thread function attribute, fido + +.. m68k-fn-attr:: interrupt_thread + + Use this attribute on fido, a subarchitecture of the m68k, to indicate + that the specified function is an interrupt handler that is designed + to run as a thread. The compiler omits generate prologue/epilogue + sequences and replaces the return instruction with a ``sleep`` + instruction. This attribute is available only on fido. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mcore-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mcore-function-attributes.rst new file mode 100644 index 00000000000..ef90eb37f94 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mcore-function-attributes.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _mcore-function-attributes: + +MCORE Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the MCORE back end: + +.. index:: naked function attribute, MCORE + +.. mcore-fn-attr:: naked + + This attribute allows the compiler to construct the + requisite function declaration, while allowing the body of the + function to be assembly code. The specified function will not have + prologue/epilogue sequences generated by the compiler. Only basic + ``asm`` statements can safely be included in naked functions + (see :ref:`basic-asm`). While using extended ``asm`` or a mixture of + basic ``asm`` and C code may appear to work, they cannot be + depended upon to work reliably and are not supported. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mep-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mep-function-attributes.rst new file mode 100644 index 00000000000..b039c43fb18 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mep-function-attributes.rst @@ -0,0 +1,53 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _mep-function-attributes: + +MeP Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the MeP back end: + +.. index:: disinterrupt function attribute, MeP + +.. mep-fn-attr:: disinterrupt + + On MeP targets, this attribute causes the compiler to emit + instructions to disable interrupts for the duration of the given + function. + +.. index:: interrupt function attribute, MeP + +.. mep-fn-attr:: interrupt + + Use this attribute to indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when this attribute is present. + +.. index:: near function attribute, MeP + +.. mep-fn-attr:: near + + This attribute causes the compiler to assume the called + function is close enough to use the normal calling convention, + overriding the :option:`-mtf ` command-line option. + +.. index:: far function attribute, MeP + +.. mep-fn-attr:: far + + On MeP targets this causes the compiler to use a calling convention + that assumes the called function is too far away for the built-in + addressing modes. + +.. index:: vliw function attribute, MeP + +.. mep-fn-attr:: vliw + + The :mep-fn-attr:`vliw` attribute tells the compiler to emit + instructions in VLIW mode instead of core mode. Note that this + attribute is not allowed unless a VLIW coprocessor has been configured + and enabled through command-line options. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/microblaze-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/microblaze-function-attributes.rst new file mode 100644 index 00000000000..130de9c5f85 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/microblaze-function-attributes.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _microblaze-function-attributes: + +MicroBlaze Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported on MicroBlaze targets: + +.. index:: save_volatiles function attribute, MicroBlaze + +.. microblaze-fn-attr:: save_volatiles + + Use this attribute to indicate that the function is + an interrupt handler. All volatile registers (in addition to non-volatile + registers) are saved in the function prologue. If the function is a leaf + function, only volatiles used by the function are saved. A normal function + return is generated instead of a return from interrupt. + +.. index:: break_handler function attribute, MicroBlaze, break handler functions + +.. microblaze-fn-attr:: break_handler + + Use this attribute to indicate that + the specified function is a break handler. The compiler generates function + entry and exit sequences suitable for use in an break handler when this + attribute is present. The return from :microblaze-fn-attr:`break_handler` is done through + the ``rtbd`` instead of ``rtsd``. + + .. code-block:: c++ + + void f () __attribute__ ((break_handler)); + +.. index:: interrupt_handler function attribute, MicroBlaze, fast_interrupt function attribute, MicroBlaze + +.. microblaze-fn-attr:: interrupt_handler, fast_interrupt + + These attributes indicate that the specified function is an interrupt + handler. Use the :microblaze-fn-attr:`fast_interrupt` attribute to indicate handlers + used in low-latency interrupt mode, and :microblaze-fn-attr:`interrupt_handler` for + interrupts that do not use low-latency handlers. In both cases, GCC + emits appropriate prologue code and generates a return from the handler + using ``rtid`` instead of ``rtsd``. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/microsoft-windows-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/microsoft-windows-function-attributes.rst new file mode 100644 index 00000000000..7cdc761cfd5 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/microsoft-windows-function-attributes.rst @@ -0,0 +1,104 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _microsoft-windows-function-attributes: + +Microsoft Windows Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following attributes are available on Microsoft Windows and Symbian OS +targets. + +.. index:: dllexport function attribute, __declspec(dllexport) + +.. microsoft-windows-fn-attr:: dllexport + + On Microsoft Windows targets and Symbian OS targets the + :microsoft-windows-fn-attr:`dllexport` attribute causes the compiler to provide a global + pointer to a pointer in a DLL, so that it can be referenced with the + :microsoft-windows-fn-attr:`dllimport` attribute. On Microsoft Windows targets, the pointer + name is formed by combining ``_imp__`` and the function or variable + name. + + You can use ``__declspec(dllexport)`` as a synonym for + ``__attribute__ ((dllexport))`` for compatibility with other + compilers. + + On systems that support the :microsoft-windows-fn-attr:`visibility` attribute, this + attribute also implies 'default' visibility. It is an error to + explicitly specify any other visibility. + + GCC's default behavior is to emit all inline functions with the + :microsoft-windows-fn-attr:`dllexport` attribute. Since this can cause object file-size bloat, + you can use :option:`-fno-keep-inline-dllexport`, which tells GCC to + ignore the attribute for inlined functions unless the + :option:`-fkeep-inline-functions` flag is used instead. + + The attribute is ignored for undefined symbols. + + When applied to C++ classes, the attribute marks defined non-inlined + member functions and static data members as exports. Static consts + initialized in-class are not marked unless they are also defined + out-of-class. + + For Microsoft Windows targets there are alternative methods for + including the symbol in the DLL's export table such as using a + :samp:`.def` file with an ``EXPORTS`` section or, with GNU ld, using + the :option:`--export-all` linker flag. + +.. index:: dllimport function attribute, __declspec(dllimport) + +.. microsoft-windows-fn-attr:: dllimport + + On Microsoft Windows and Symbian OS targets, the :microsoft-windows-fn-attr:`dllimport` + attribute causes the compiler to reference a function or variable via + a global pointer to a pointer that is set up by the DLL exporting the + symbol. The attribute implies ``extern``. On Microsoft Windows + targets, the pointer name is formed by combining ``_imp__`` and the + function or variable name. + + You can use ``__declspec(dllimport)`` as a synonym for + ``__attribute__ ((dllimport))`` for compatibility with other + compilers. + + On systems that support the :microsoft-windows-fn-attr:`visibility` attribute, this + attribute also implies 'default' visibility. It is an error to + explicitly specify any other visibility. + + Currently, the attribute is ignored for inlined functions. If the + attribute is applied to a symbol *definition*, an error is reported. + If a symbol previously declared :microsoft-windows-fn-attr:`dllimport` is later defined, the + attribute is ignored in subsequent references, and a warning is emitted. + The attribute is also overridden by a subsequent declaration as + :microsoft-windows-fn-attr:`dllexport`. + + When applied to C++ classes, the attribute marks non-inlined + member functions and static data members as imports. However, the + attribute is ignored for virtual methods to allow creation of vtables + using thunks. + + On the SH Symbian OS target the :microsoft-windows-fn-attr:`dllimport` attribute also has + another affect---it can cause the vtable and run-time type information + for a class to be exported. This happens when the class has a + dllimported constructor or a non-inline, non-pure virtual function + and, for either of those two conditions, the class also has an inline + constructor or destructor and has a key function that is defined in + the current translation unit. + + For Microsoft Windows targets the use of the :microsoft-windows-fn-attr:`dllimport` + attribute on functions is not necessary, but provides a small + performance benefit by eliminating a thunk in the DLL. The use of the + :microsoft-windows-fn-attr:`dllimport` attribute on imported variables can be avoided by passing the + :option:`--enable-auto-import` switch to the GNU linker. As with + functions, using the attribute for a variable eliminates a thunk in + the DLL. + + One drawback to using this attribute is that a pointer to a + *variable* marked as :microsoft-windows-fn-attr:`dllimport` cannot be used as a constant + address. However, a pointer to a *function* with the + :microsoft-windows-fn-attr:`dllimport` attribute can be used as a constant initializer; in + this case, the address of a stub function in the import lib is + referenced. On Microsoft Windows targets, the attribute can be disabled + for functions by setting the :option:`-mnop-fun-dllimport` flag. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mips-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mips-function-attributes.rst new file mode 100644 index 00000000000..93e8aae0974 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/mips-function-attributes.rst @@ -0,0 +1,134 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _mips-function-attributes: + +MIPS Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the MIPS back end: + +.. index:: interrupt function attribute, MIPS + +.. mips-fn-attr:: interrupt + + Use this attribute to indicate that the specified function is an interrupt + handler. The compiler generates function entry and exit sequences suitable + for use in an interrupt handler when this attribute is present. + An optional argument is supported for the interrupt attribute which allows + the interrupt mode to be described. By default GCC assumes the external + interrupt controller (EIC) mode is in use, this can be explicitly set using + ``eic``. When interrupts are non-masked then the requested Interrupt + Priority Level (IPL) is copied to the current IPL which has the effect of only + enabling higher priority interrupts. To use vectored interrupt mode use + the argument ``vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]``, this will change + the behavior of the non-masked interrupt support and GCC will arrange to mask + all interrupts from sw0 up to and including the specified interrupt vector. + + You can use the following attributes to modify the behavior + of an interrupt handler: + + ``use_shadow_register_set`` + + .. index:: use_shadow_register_set function attribute, MIPS + + Assume that the handler uses a shadow register set, instead of + the main general-purpose registers. An optional argument ``intstack`` is + supported to indicate that the shadow register set contains a valid stack + pointer. + + ``keep_interrupts_masked`` + + .. index:: keep_interrupts_masked function attribute, MIPS + + Keep interrupts masked for the whole function. Without this attribute, + GCC tries to reenable interrupts for as much of the function as it can. + + ``use_debug_exception_return`` + + .. index:: use_debug_exception_return function attribute, MIPS + + Return using the ``deret`` instruction. Interrupt handlers that don't + have this attribute return using ``eret`` instead. + + You can use any combination of these attributes, as shown below: + + .. code-block:: c++ + + void __attribute__ ((interrupt)) v0 (); + void __attribute__ ((interrupt, use_shadow_register_set)) v1 (); + void __attribute__ ((interrupt, keep_interrupts_masked)) v2 (); + void __attribute__ ((interrupt, use_debug_exception_return)) v3 (); + void __attribute__ ((interrupt, use_shadow_register_set, + keep_interrupts_masked)) v4 (); + void __attribute__ ((interrupt, use_shadow_register_set, + use_debug_exception_return)) v5 (); + void __attribute__ ((interrupt, keep_interrupts_masked, + use_debug_exception_return)) v6 (); + void __attribute__ ((interrupt, use_shadow_register_set, + keep_interrupts_masked, + use_debug_exception_return)) v7 (); + void __attribute__ ((interrupt("eic"))) v8 (); + void __attribute__ ((interrupt("vector=hw3"))) v9 (); + +.. index:: indirect calls, MIPS, long_call function attribute, MIPS, short_call function attribute, MIPS, near function attribute, MIPS, far function attribute, MIPS + +.. mips-fn-attr:: long_call, short_call, near, far + + These attributes specify how a particular function is called on MIPS. + The attributes override the :option:`-mlong-calls` (see :ref:`mips-options`) + command-line switch. The :mips-fn-attr:`long_call` and :mips-fn-attr:`far` attributes are + synonyms, and cause the compiler to always call + the function by first loading its address into a register, and then using + the contents of that register. The ``short_call`` and :mips-fn-attr:`near` + attributes are synonyms, and have the opposite + effect; they specify that non-PIC calls should be made using the more + efficient ``jal`` instruction. + +.. index:: mips16 function attribute, MIPS, nomips16 function attribute, MIPS + +.. mips-fn-attr:: mips16, nomips16 + + On MIPS targets, you can use the :mips-fn-attr:`mips16` and ``nomips16`` + function attributes to locally select or turn off MIPS16 code generation. + A function with the :mips-fn-attr:`mips16` attribute is emitted as MIPS16 code, + while MIPS16 code generation is disabled for functions with the + ``nomips16`` attribute. These attributes override the + :option:`-mips16` and :option:`-mno-mips16` options on the command line + (see :ref:`mips-options`). + + When compiling files containing mixed MIPS16 and non-MIPS16 code, the + preprocessor symbol ``__mips16`` reflects the setting on the command line, + not that within individual functions. Mixed MIPS16 and non-MIPS16 code + may interact badly with some GCC extensions such as ``__builtin_apply`` + (see :ref:`constructing-calls`). + +.. index:: micromips function attribute, nomicromips function attribute + +.. mips-fn-attr:: micromips, MIPS, nomicromips, MIPS + + On MIPS targets, you can use the ``micromips`` and ``nomicromips`` + function attributes to locally select or turn off microMIPS code generation. + A function with the ``micromips`` attribute is emitted as microMIPS code, + while microMIPS code generation is disabled for functions with the + ``nomicromips`` attribute. These attributes override the + :option:`-mmicromips` and :option:`-mno-micromips` options on the command line + (see :ref:`mips-options`). + + When compiling files containing mixed microMIPS and non-microMIPS code, the + preprocessor symbol ``__mips_micromips`` reflects the setting on the + command line, + not that within individual functions. Mixed microMIPS and non-microMIPS code + may interact badly with some GCC extensions such as ``__builtin_apply`` + (see :ref:`constructing-calls`). + +.. index:: nocompression function attribute, MIPS + +.. mips-fn-attr:: nocompression + + On MIPS targets, you can use the :mips-fn-attr:`nocompression` function attribute + to locally turn off MIPS16 and microMIPS code generation. This attribute + overrides the :option:`-mips16` and :option:`-mmicromips` options on the + command line (see :ref:`mips-options`). \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/msp430-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/msp430-function-attributes.rst new file mode 100644 index 00000000000..1b234c4ff4e --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/msp430-function-attributes.rst @@ -0,0 +1,103 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _msp430-function-attributes: + +MSP430 Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the MSP430 back end: + +.. index:: critical function attribute, MSP430 + +.. msp430-fn-attr:: critical + + Critical functions disable interrupts upon entry and restore the + previous interrupt state upon exit. Critical functions cannot also + have the :msp430-fn-attr:`naked`, :msp430-fn-attr:`reentrant` or :msp430-fn-attr:`interrupt` attributes. + + The MSP430 hardware ensures that interrupts are disabled on entry to + :msp430-fn-attr:`interrupt` functions, and restores the previous interrupt state + on exit. The :msp430-fn-attr:`critical` attribute is therefore redundant on + :msp430-fn-attr:`interrupt` functions. + +.. index:: interrupt function attribute, MSP430 + +.. msp430-fn-attr:: interrupt + + Use this attribute to indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when this attribute is present. + + You can provide an argument to the interrupt + attribute which specifies a name or number. If the argument is a + number it indicates the slot in the interrupt vector table (0 - 31) to + which this handler should be assigned. If the argument is a name it + is treated as a symbolic name for the vector slot. These names should + match up with appropriate entries in the linker script. By default + the names ``watchdog`` for vector 26, ``nmi`` for vector 30 and + :msp430-fn-attr:`reset` for vector 31 are recognized. + +.. index:: naked function attribute, MSP430 + +.. msp430-fn-attr:: naked + + This attribute allows the compiler to construct the + requisite function declaration, while allowing the body of the + function to be assembly code. The specified function will not have + prologue/epilogue sequences generated by the compiler. Only basic + ``asm`` statements can safely be included in naked functions + (see :ref:`basic-asm`). While using extended ``asm`` or a mixture of + basic ``asm`` and C code may appear to work, they cannot be + depended upon to work reliably and are not supported. + +.. index:: reentrant function attribute, MSP430 + +.. msp430-fn-attr:: reentrant + + Reentrant functions disable interrupts upon entry and enable them + upon exit. Reentrant functions cannot also have the :msp430-fn-attr:`naked` + or :msp430-fn-attr:`critical` attributes. They can have the :msp430-fn-attr:`interrupt` + attribute. + +.. index:: wakeup function attribute, MSP430 + +.. msp430-fn-attr:: wakeup + + This attribute only applies to interrupt functions. It is silently + ignored if applied to a non-interrupt function. A wakeup interrupt + function will rouse the processor from any low-power state that it + might be in when the function exits. + +.. index:: lower function attribute, MSP430, upper function attribute, MSP430, either function attribute, MSP430 + +.. msp430-fn-attr:: lower, upper, either + + On the MSP430 target these attributes can be used to specify whether + the function or variable should be placed into low memory, high + memory, or the placement should be left to the linker to decide. The + attributes are only significant if compiling for the MSP430X + architecture in the large memory model. + + The attributes work in conjunction with a linker script that has been + augmented to specify where to place sections with a ``.lower`` and + a ``.upper`` prefix. So, for example, as well as placing the + ``.data`` section, the script also specifies the placement of a + ``.lower.data`` and a ``.upper.data`` section. The intention + is that :msp430-fn-attr:`lower` sections are placed into a small but easier to + access memory region and the upper sections are placed into a larger, but + slower to access, region. + + The ``either`` attribute is special. It tells the linker to place + the object into the corresponding :msp430-fn-attr:`lower` section if there is + room for it. If there is insufficient room then the object is placed + into the corresponding :msp430-fn-attr:`upper` section instead. Note that the + placement algorithm is not very sophisticated. It does not attempt to + find an optimal packing of the :msp430-fn-attr:`lower` sections. It just makes + one pass over the objects and does the best that it can. Using the + :option:`-ffunction-sections` and :option:`-fdata-sections` command-line + options can help the packing, however, since they produce smaller, + easier to pack regions. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nds32-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nds32-function-attributes.rst new file mode 100644 index 00000000000..5e98215c8d1 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nds32-function-attributes.rst @@ -0,0 +1,96 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _nds32-function-attributes: + +NDS32 Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the NDS32 back end: + +.. index:: exception function attribute, exception handler functions, NDS32 + +.. nds32-fn-attr:: exception + + Use this attribute on the NDS32 target to indicate that the specified function + is an exception handler. The compiler will generate corresponding sections + for use in an exception handler. + +.. index:: interrupt function attribute, NDS32 + +.. nds32-fn-attr:: interrupt + + On NDS32 target, this attribute indicates that the specified function + is an interrupt handler. The compiler generates corresponding sections + for use in an interrupt handler. You can use the following attributes + to modify the behavior: + + ``nested`` + + .. index:: nested function attribute, NDS32 + + This interrupt service routine is interruptible. + + ``not_nested`` + + .. index:: not_nested function attribute, NDS32 + + This interrupt service routine is not interruptible. + + ``nested_ready`` + + .. index:: nested_ready function attribute, NDS32 + + This interrupt service routine is interruptible after ``PSW.GIE`` + (global interrupt enable) is set. This allows interrupt service routine to + finish some short critical code before enabling interrupts. + + ``save_all`` + + .. index:: save_all function attribute, NDS32 + + The system will help save all registers into stack before entering + interrupt handler. + + ``partial_save`` + + .. index:: partial_save function attribute, NDS32 + + The system will help save caller registers into stack before entering + interrupt handler. + +.. index:: naked function attribute, NDS32 + +.. nds32-fn-attr:: naked + + This attribute allows the compiler to construct the + requisite function declaration, while allowing the body of the + function to be assembly code. The specified function will not have + prologue/epilogue sequences generated by the compiler. Only basic + ``asm`` statements can safely be included in naked functions + (see :ref:`basic-asm`). While using extended ``asm`` or a mixture of + basic ``asm`` and C code may appear to work, they cannot be + depended upon to work reliably and are not supported. + +.. index:: reset function attribute, NDS32, reset handler functions + +.. nds32-fn-attr:: reset + + Use this attribute on the NDS32 target to indicate that the specified function + is a reset handler. The compiler will generate corresponding sections + for use in a reset handler. You can use the following attributes + to provide extra exception handling: + + ``nmi`` + + .. index:: nmi function attribute, NDS32 + + Provide a user-defined function to handle NMI exception. + + ``warm`` + + .. index:: warm function attribute, NDS32 + + Provide a user-defined function to handle warm reset exception. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nios-ii-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nios-ii-function-attributes.rst new file mode 100644 index 00000000000..6e4b8730210 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nios-ii-function-attributes.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _nios-ii-function-attributes: + +Nios II Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the Nios II back end: + +.. index:: target function attribute + +.. nios-ii-fn-attr:: target (options) + + As discussed in :ref:`common-function-attributes`, this attribute + allows specification of target-specific compilation options. + + When compiling for Nios II, the following options are allowed: + + :samp:`custom-{insn}={N}` :samp:`no-custom-{insn}` + + .. index:: target("custom-insn=N") function attribute, Nios II, target("no-custom-insn") function attribute, Nios II + + Each :samp:`custom-{insn}={N}` attribute locally enables use of a + custom instruction with encoding :samp:`{N}` when generating code that uses + :samp:`{insn}`. Similarly, :samp:`no-custom-{insn}` locally inhibits use of + the custom instruction :samp:`{insn}`. + These target attributes correspond to the + :option:`-mcustom-insn=N` and :option:`-mno-custom-insn` + command-line options, and support the same set of :samp:`{insn}` keywords. + See :ref:`nios-ii-options`, for more information. + + :samp:`custom-fpu-cfg={name}` + + .. index:: target("custom-fpu-cfg=name") function attribute, Nios II + + This attribute corresponds to the :option:`-mcustom-fpu-cfg=name` + command-line option, to select a predefined set of custom instructions + named :samp:`{name}`. + See :ref:`nios-ii-options`, for more information. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nvidia-ptx-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nvidia-ptx-function-attributes.rst new file mode 100644 index 00000000000..700a73774af --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/nvidia-ptx-function-attributes.rst @@ -0,0 +1,22 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _nvidia-ptx-function-attributes: + +Nvidia PTX Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the Nvidia PTX back end: + +.. index:: kernel attribute, Nvidia PTX + +.. nvidia-ptx-fn-attr:: kernel + + This attribute indicates that the corresponding function should be compiled + as a kernel function, which can be invoked from the host via the CUDA RT + library. + By default functions are only callable only from other PTX functions. + + Kernel functions must have ``void`` return type. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/powerpc-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/powerpc-function-attributes.rst new file mode 100644 index 00000000000..f7a65acd636 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/powerpc-function-attributes.rst @@ -0,0 +1,225 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _powerpc-function-attributes: + +PowerPC Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the PowerPC back end: + +.. index:: indirect calls, PowerPC, longcall function attribute, PowerPC, shortcall function attribute, PowerPC + +.. powerpc-fn-attr:: longcall, shortcall + + The :powerpc-fn-attr:`longcall` attribute + indicates that the function might be far away from the call site and + require a different (more expensive) calling sequence. The + ``shortcall`` attribute indicates that the function is always close + enough for the shorter calling sequence to be used. These attributes + override both the :option:`-mlongcall` switch and + the ``#pragma longcall`` setting. + + See :ref:`rs-6000-and-powerpc-options`, for more information on whether long + calls are necessary. + +.. index:: target function attribute + +.. powerpc-fn-attr:: target (options) + + As discussed in :ref:`common-function-attributes`, this attribute + allows specification of target-specific compilation options. + + On the PowerPC, the following options are allowed: + + :samp:`altivec` :samp:`no-altivec` + + .. index:: target("altivec") function attribute, PowerPC + + Generate code that uses (does not use) AltiVec instructions. In + 32-bit code, you cannot enable AltiVec instructions unless + :option:`-mabi=altivec` is used on the command line. + + :samp:`cmpb` :samp:`no-cmpb` + + .. index:: target("cmpb") function attribute, PowerPC + + Generate code that uses (does not use) the compare bytes instruction + implemented on the POWER6 processor and other processors that support + the PowerPC V2.05 architecture. + + :samp:`dlmzb` :samp:`no-dlmzb` + + .. index:: target("dlmzb") function attribute, PowerPC + + Generate code that uses (does not use) the string-search :samp:`dlmzb` + instruction on the IBM 405, 440, 464 and 476 processors. This instruction is + generated by default when targeting those processors. + + :samp:`fprnd` :samp:`no-fprnd` + + .. index:: target("fprnd") function attribute, PowerPC + + Generate code that uses (does not use) the FP round to integer + instructions implemented on the POWER5+ processor and other processors + that support the PowerPC V2.03 architecture. + + :samp:`hard-dfp` :samp:`no-hard-dfp` + + .. index:: target("hard-dfp") function attribute, PowerPC + + Generate code that uses (does not use) the decimal floating-point + instructions implemented on some POWER processors. + + :samp:`isel` :samp:`no-isel` + + .. index:: target("isel") function attribute, PowerPC + + Generate code that uses (does not use) ISEL instruction. + + :samp:`mfcrf` :samp:`no-mfcrf` + + .. index:: target("mfcrf") function attribute, PowerPC + + Generate code that uses (does not use) the move from condition + register field instruction implemented on the POWER4 processor and + other processors that support the PowerPC V2.01 architecture. + + :samp:`mulhw` :samp:`no-mulhw` + + .. index:: target("mulhw") function attribute, PowerPC + + Generate code that uses (does not use) the half-word multiply and + multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors. + These instructions are generated by default when targeting those + processors. + + :samp:`multiple` :samp:`no-multiple` + + .. index:: target("multiple") function attribute, PowerPC + + Generate code that uses (does not use) the load multiple word + instructions and the store multiple word instructions. + + :samp:`update` :samp:`no-update` + + .. index:: target("update") function attribute, PowerPC + + Generate code that uses (does not use) the load or store instructions + that update the base register to the address of the calculated memory + location. + + :samp:`popcntb` :samp:`no-popcntb` + + .. index:: target("popcntb") function attribute, PowerPC + + Generate code that uses (does not use) the popcount and double-precision + FP reciprocal estimate instruction implemented on the POWER5 + processor and other processors that support the PowerPC V2.02 + architecture. + + :samp:`popcntd` :samp:`no-popcntd` + + .. index:: target("popcntd") function attribute, PowerPC + + Generate code that uses (does not use) the popcount instruction + implemented on the POWER7 processor and other processors that support + the PowerPC V2.06 architecture. + + :samp:`powerpc-gfxopt` :samp:`no-powerpc-gfxopt` + + .. index:: target("powerpc-gfxopt") function attribute, PowerPC + + Generate code that uses (does not use) the optional PowerPC + architecture instructions in the Graphics group, including + floating-point select. + + :samp:`powerpc-gpopt` :samp:`no-powerpc-gpopt` + + .. index:: target("powerpc-gpopt") function attribute, PowerPC + + Generate code that uses (does not use) the optional PowerPC + architecture instructions in the General Purpose group, including + floating-point square root. + + :samp:`recip-precision` :samp:`no-recip-precision` + + .. index:: target("recip-precision") function attribute, PowerPC + + Assume (do not assume) that the reciprocal estimate instructions + provide higher-precision estimates than is mandated by the PowerPC + ABI. + + :samp:`string` :samp:`no-string` + + .. index:: target("string") function attribute, PowerPC + + Generate code that uses (does not use) the load string instructions + and the store string word instructions to save multiple registers and + do small block moves. + + :samp:`vsx` :samp:`no-vsx` + + .. index:: target("vsx") function attribute, PowerPC + + Generate code that uses (does not use) vector/scalar (VSX) + instructions, and also enable the use of built-in functions that allow + more direct access to the VSX instruction set. In 32-bit code, you + cannot enable VSX or AltiVec instructions unless + :option:`-mabi=altivec` is used on the command line. + + :samp:`friz` :samp:`no-friz` + + .. index:: target("friz") function attribute, PowerPC + + Generate (do not generate) the ``friz`` instruction when the + :option:`-funsafe-math-optimizations` option is used to optimize + rounding a floating-point value to 64-bit integer and back to floating + point. The ``friz`` instruction does not return the same value if + the floating-point number is too large to fit in an integer. + + :samp:`avoid-indexed-addresses` :samp:`no-avoid-indexed-addresses` + + .. index:: target("avoid-indexed-addresses") function attribute, PowerPC + + Generate code that tries to avoid (not avoid) the use of indexed load + or store instructions. + + :samp:`paired` :samp:`no-paired` + + .. index:: target("paired") function attribute, PowerPC + + Generate code that uses (does not use) the generation of PAIRED simd + instructions. + + :samp:`longcall` :samp:`no-longcall` + + .. index:: target("longcall") function attribute, PowerPC + + Generate code that assumes (does not assume) that all calls are far + away so that a longer more expensive calling sequence is required. + + :samp:`cpu={CPU}` + + .. index:: target("cpu=CPU") function attribute, PowerPC + + Specify the architecture to generate code for when compiling the + function. If you select the ``target("cpu=power7")`` attribute when + generating 32-bit code, VSX and AltiVec instructions are not generated + unless you use the :option:`-mabi=altivec` option on the command line. + + :samp:`tune={TUNE}` + + .. index:: target("tune=TUNE") function attribute, PowerPC + + Specify the architecture to tune for when compiling the function. If + you do not specify the ``target("tune=TUNE")`` attribute and + you do specify the ``target("cpu=CPU")`` attribute, + compilation tunes for the :samp:`{CPU}` architecture, and not the + default tuning specified on the command line. + + On the PowerPC, the inliner does not inline a + function that has different target options than the caller, unless the + callee has a subset of the target options of the caller. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/risc-v-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/risc-v-function-attributes.rst new file mode 100644 index 00000000000..6ef5036c53a --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/risc-v-function-attributes.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _risc-v-function-attributes: + +RISC-V Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the RISC-V back end: + +.. index:: naked function attribute, RISC-V + +.. risc-v-fn-attr:: naked + + This attribute allows the compiler to construct the + requisite function declaration, while allowing the body of the + function to be assembly code. The specified function will not have + prologue/epilogue sequences generated by the compiler. Only basic + ``asm`` statements can safely be included in naked functions + (see :ref:`basic-asm`). While using extended ``asm`` or a mixture of + basic ``asm`` and C code may appear to work, they cannot be + depended upon to work reliably and are not supported. + +.. index:: interrupt function attribute, RISC-V + +.. risc-v-fn-attr:: interrupt + + Use this attribute to indicate that the specified function is an interrupt + handler. The compiler generates function entry and exit sequences suitable + for use in an interrupt handler when this attribute is present. + + You can specify the kind of interrupt to be handled by adding an optional + parameter to the interrupt attribute like this: + + .. code-block:: c++ + + void f (void) __attribute__ ((interrupt ("user"))); + + Permissible values for this parameter are ``user``, ``supervisor``, + and ``machine``. If there is no parameter, then it defaults to + ``machine``. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/rl78-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/rl78-function-attributes.rst new file mode 100644 index 00000000000..d963f1b863e --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/rl78-function-attributes.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _rl78-function-attributes: + +RL78 Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the RL78 back end: + +.. index:: interrupt function attribute, RL78, brk_interrupt function attribute, RL78 + +.. rl78-fn-attr:: interrupt, brk_interrupt + + These attributes indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when this attribute is present. + + Use ``brk_interrupt`` instead of :rl78-fn-attr:`interrupt` for + handlers intended to be used with the ``BRK`` opcode (i.e. those + that must end with ``RETB`` instead of ``RETI``). + +.. index:: naked function attribute, RL78 + +.. rl78-fn-attr:: naked + + This attribute allows the compiler to construct the + requisite function declaration, while allowing the body of the + function to be assembly code. The specified function will not have + prologue/epilogue sequences generated by the compiler. Only basic + ``asm`` statements can safely be included in naked functions + (see :ref:`basic-asm`). While using extended ``asm`` or a mixture of + basic ``asm`` and C code may appear to work, they cannot be + depended upon to work reliably and are not supported. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/rx-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/rx-function-attributes.rst new file mode 100644 index 00000000000..99260f714b1 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/rx-function-attributes.rst @@ -0,0 +1,75 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _rx-function-attributes: + +RX Function Attributes +^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the RX back end: + +.. index:: fast_interrupt function attribute, RX + +.. rx-fn-attr:: fast_interrupt + + Use this attribute on the RX port to indicate that the specified + function is a fast interrupt handler. This is just like the + :rx-fn-attr:`interrupt` attribute, except that ``freit`` is used to return + instead of ``reit``. + +.. index:: interrupt function attribute, RX + +.. rx-fn-attr:: interrupt + + Use this attribute to indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when this attribute is present. + + On RX and RL78 targets, you may specify one or more vector numbers as arguments + to the attribute, as well as naming an alternate table name. + Parameters are handled sequentially, so one handler can be assigned to + multiple entries in multiple tables. One may also pass the magic + string ``"$default"`` which causes the function to be used for any + unfilled slots in the current table. + + This example shows a simple assignment of a function to one vector in + the default table (note that preprocessor macros may be used for + chip-specific symbolic vector names): + + .. code-block:: c++ + + void __attribute__ ((interrupt (5))) txd1_handler (); + + This example assigns a function to two slots in the default table + (using preprocessor macros defined elsewhere) and makes it the default + for the ``dct`` table: + + .. code-block:: c++ + + void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default"))) + txd1_handler (); + +.. index:: naked function attribute, RX + +.. rx-fn-attr:: naked + + This attribute allows the compiler to construct the + requisite function declaration, while allowing the body of the + function to be assembly code. The specified function will not have + prologue/epilogue sequences generated by the compiler. Only basic + ``asm`` statements can safely be included in naked functions + (see :ref:`basic-asm`). While using extended ``asm`` or a mixture of + basic ``asm`` and C code may appear to work, they cannot be + depended upon to work reliably and are not supported. + +.. index:: vector function attribute, RX + +.. rx-fn-attr:: vector + + This RX attribute is similar to the :rx-fn-attr:`interrupt` attribute, including its + parameters, but does not make the function an interrupt-handler type + function (i.e. it retains the normal C function calling ABI). See the + :rx-fn-attr:`interrupt` attribute for a description of its arguments. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/s-390-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/s-390-function-attributes.rst new file mode 100644 index 00000000000..dad2caefe8d --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/s-390-function-attributes.rst @@ -0,0 +1,52 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _s-390-function-attributes: + +S/390 Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported on the S/390: + +.. index:: hotpatch function attribute, S/390 + +.. s-390-fn-attr:: hotpatch (halfwords-before-function-label,halfwords-after-function-label) + + On S/390 System z targets, you can use this function attribute to + make GCC generate a 'hot-patching' function prologue. If the + :option:`-mhotpatch=` command-line option is used at the same time, + the ``hotpatch`` attribute takes precedence. The first of the + two arguments specifies the number of halfwords to be added before + the function label. A second argument can be used to specify the + number of halfwords to be added after the function label. For + both arguments the maximum allowed value is 1000000. + + If both arguments are zero, hotpatching is disabled. + +.. index:: target function attribute + +.. s-390-fn-attr:: target (options) + + As discussed in :ref:`common-function-attributes`, this attribute + allows specification of target-specific compilation options. + + On S/390, the following options are supported: + + :samp:`arch=` :samp:`tune=` :samp:`stack-guard=` :samp:`stack-size=` :samp:`branch-cost=` + :samp:`warn-framesize=` :samp:`backchain` :samp:`no-backchain` :samp:`hard-dfp` + :samp:`no-hard-dfp` :samp:`hard-float` :samp:`soft-float` :samp:`htm` :samp:`no-htm` + :samp:`vx` :samp:`no-vx` :samp:`packed-stack` :samp:`no-packed-stack` :samp:`small-exec` + :samp:`no-small-exec` :samp:`mvcle` :samp:`no-mvcle` :samp:`warn-dynamicstack` + :samp:`no-warn-dynamicstack` + + The options work exactly like the S/390 specific command line + options (without the prefix :samp:`-m`) except that they do not + change any feature macros. For example, + + .. code-block:: c++ + + target("no-vx") + + does not undefine the ``__VEC__`` macro. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/sh-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/sh-function-attributes.rst new file mode 100644 index 00000000000..f60d38763ad --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/sh-function-attributes.rst @@ -0,0 +1,101 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _sh-function-attributes: + +SH Function Attributes +^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported on the SH family of processors: + +.. index:: function_vector function attribute, SH, calling functions through the function vector on SH2A + +.. sh-fn-attr:: function_vector + + On SH2A targets, this attribute declares a function to be called using the + TBR relative addressing mode. The argument to this attribute is the entry + number of the same function in a vector table containing all the TBR + relative addressable functions. For correct operation the TBR must be setup + accordingly to point to the start of the vector table before any functions with + this attribute are invoked. Usually a good place to do the initialization is + the startup routine. The TBR relative vector table can have at max 256 function + entries. The jumps to these functions are generated using a SH2A specific, + non delayed branch instruction JSR/N @(disp8,TBR). You must use GAS and GLD + from GNU binutils version 2.7 or later for this attribute to work correctly. + + In an application, for a function being called once, this attribute + saves at least 8 bytes of code; and if other successive calls are being + made to the same function, it saves 2 bytes of code per each of these + calls. + +.. index:: interrupt_handler function attribute, SH + +.. sh-fn-attr:: interrupt_handler + + Use this attribute to + indicate that the specified function is an interrupt handler. The compiler + generates function entry and exit sequences suitable for use in an + interrupt handler when this attribute is present. + +.. index:: nosave_low_regs function attribute, SH + +.. sh-fn-attr:: nosave_low_regs + + Use this attribute on SH targets to indicate that an :sh-fn-attr:`interrupt_handler` + function should not save and restore registers R0..R7. This can be used on SH3\* + and SH4\* targets that have a second R0..R7 register bank for non-reentrant + interrupt handlers. + +.. index:: renesas function attribute, SH + +.. sh-fn-attr:: renesas + + On SH targets this attribute specifies that the function or struct follows the + Renesas ABI. + +.. index:: resbank function attribute, SH + +.. sh-fn-attr:: resbank + + On the SH2A target, this attribute enables the high-speed register + saving and restoration using a register bank for :sh-fn-attr:`interrupt_handler` + routines. Saving to the bank is performed automatically after the CPU + accepts an interrupt that uses a register bank. + + The nineteen 32-bit registers comprising general register R0 to R14, + control register GBR, and system registers MACH, MACL, and PR and the + vector table address offset are saved into a register bank. Register + banks are stacked in first-in last-out (FILO) sequence. Restoration + from the bank is executed by issuing a RESBANK instruction. + +.. index:: sp_switch function attribute, SH + +.. sh-fn-attr:: sp_switch + + Use this attribute on the SH to indicate an :sh-fn-attr:`interrupt_handler` + function should switch to an alternate stack. It expects a string + argument that names a global variable holding the address of the + alternate stack. + + .. code-block:: c++ + + void *alt_stack; + void f () __attribute__ ((interrupt_handler, + sp_switch ("alt_stack"))); + +.. index:: trap_exit function attribute, SH + +.. sh-fn-attr:: trap_exit + + Use this attribute on the SH for an :sh-fn-attr:`interrupt_handler` to return using + ``trapa`` instead of ``rte``. This attribute expects an integer + argument specifying the trap number to be used. + +.. index:: trapa_handler function attribute, SH + +.. sh-fn-attr:: trapa_handler + + On SH targets this function attribute is similar to :sh-fn-attr:`interrupt_handler` + but it does not save and restore all registers. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/symbian-os-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/symbian-os-function-attributes.rst new file mode 100644 index 00000000000..2c57111a954 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/symbian-os-function-attributes.rst @@ -0,0 +1,12 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _symbian-os-function-attributes: + +Symbian OS Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +See :ref:`microsoft-windows-function-attributes`, for discussion of the +:symbian-os-fn-attr:`dllexport` and :symbian-os-fn-attr:`dllimport` attributes. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/v850-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/v850-function-attributes.rst new file mode 100644 index 00000000000..87f7dd240bf --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/v850-function-attributes.rst @@ -0,0 +1,20 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _v850-function-attributes: + +V850 Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^ + +The V850 back end supports these function attributes: + +.. index:: interrupt function attribute, V850, interrupt_handler function attribute, V850 + +.. v850-fn-attr:: interrupt, interrupt_handler + + Use these attributes to indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when either attribute is present. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/visium-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/visium-function-attributes.rst new file mode 100644 index 00000000000..1db8f75e765 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/visium-function-attributes.rst @@ -0,0 +1,22 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _visium-function-attributes: + +Visium Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the Visium back end: + +.. index:: interrupt function attribute, Visium + +.. visium-fn-attr:: interrupt, interrupt_handler + +.. visium-fn-attr:: interrupt + + Use this attribute to indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when this attribute is present. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/x86-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/x86-function-attributes.rst new file mode 100644 index 00000000000..b1a1861c6e0 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/x86-function-attributes.rst @@ -0,0 +1,1020 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _x86-function-attributes: + +x86 Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the x86 back end: + +.. index:: cdecl function attribute, x86-32, functions that pop the argument stack on x86-32 + +.. option:: cdecl + + On the x86-32 targets, the ``cdecl`` attribute causes the compiler to + assume that the calling function pops off the stack space used to + pass arguments. This is + useful to override the effects of the :option:`-mrtd` switch. + +.. index:: fastcall function attribute, x86-32, functions that pop the argument stack on x86-32 + +.. x86-fn-attr:: fastcall + + On x86-32 targets, the :x86-fn-attr:`fastcall` attribute causes the compiler to + pass the first argument (if of integral type) in the register ECX and + the second argument (if of integral type) in the register EDX. Subsequent + and other typed arguments are passed on the stack. The called function + pops the arguments off the stack. If the number of arguments is variable all + arguments are pushed on the stack. + +.. index:: thiscall function attribute, x86-32, functions that pop the argument stack on x86-32 + +.. x86-fn-attr:: thiscall + + On x86-32 targets, the :x86-fn-attr:`thiscall` attribute causes the compiler to + pass the first argument (if of integral type) in the register ECX. + Subsequent and other typed arguments are passed on the stack. The called + function pops the arguments off the stack. + If the number of arguments is variable all arguments are pushed on the + stack. + The :x86-fn-attr:`thiscall` attribute is intended for C++ non-static member functions. + As a GCC extension, this calling convention can be used for C functions + and for static member methods. + +.. index:: ms_abi function attribute, x86, sysv_abi function attribute, x86 + +.. x86-fn-attr:: ms_abi, sysv_abi + + On 32-bit and 64-bit x86 targets, you can use an ABI attribute + to indicate which calling convention should be used for a function. The + :x86-fn-attr:`ms_abi` attribute tells the compiler to use the Microsoft ABI, + while the ``sysv_abi`` attribute tells the compiler to use the System V + ELF ABI, which is used on GNU/Linux and other systems. The default is to use + the Microsoft ABI when targeting Windows. On all other systems, the default + is the System V ELF ABI. + + Note, the :x86-fn-attr:`ms_abi` attribute for Microsoft Windows 64-bit targets currently + requires the :option:`-maccumulate-outgoing-args` option. + +.. index:: callee_pop_aggregate_return function attribute, x86 + +.. x86-fn-attr:: callee_pop_aggregate_return (number) + + On x86-32 targets, you can use this attribute to control how + aggregates are returned in memory. If the caller is responsible for + popping the hidden pointer together with the rest of the arguments, specify + :samp:`{number}` equal to zero. If callee is responsible for popping the + hidden pointer, specify :samp:`{number}` equal to one. + + The default x86-32 ABI assumes that the callee pops the + stack for hidden pointer. However, on x86-32 Microsoft Windows targets, + the compiler assumes that the + caller pops the stack for hidden pointer. + +.. index:: ms_hook_prologue function attribute, x86 + +.. x86-fn-attr:: ms_hook_prologue + + On 32-bit and 64-bit x86 targets, you can use + this function attribute to make GCC generate the 'hot-patching' function + prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2 + and newer. + +.. index:: naked function attribute, x86 + +.. x86-fn-attr:: naked + + This attribute allows the compiler to construct the + requisite function declaration, while allowing the body of the + function to be assembly code. The specified function will not have + prologue/epilogue sequences generated by the compiler. Only basic + ``asm`` statements can safely be included in naked functions + (see :ref:`basic-asm`). While using extended ``asm`` or a mixture of + basic ``asm`` and C code may appear to work, they cannot be + depended upon to work reliably and are not supported. + +.. index:: regparm function attribute, x86, functions that are passed arguments in registers on x86-32 + +.. x86-fn-attr:: regparm (number) + + On x86-32 targets, the ``regparm`` attribute causes the compiler to + pass arguments number one to :samp:`{number}` if they are of integral type + in registers EAX, EDX, and ECX instead of on the stack. Functions that + take a variable number of arguments continue to be passed all of their + arguments on the stack. + + Beware that on some ELF systems this attribute is unsuitable for + global functions in shared libraries with lazy binding (which is the + default). Lazy binding sends the first call via resolving code in + the loader, which might assume EAX, EDX and ECX can be clobbered, as + per the standard calling conventions. Solaris 8 is affected by this. + Systems with the GNU C Library version 2.1 or higher + and FreeBSD are believed to be + safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be + disabled with the linker or the loader if desired, to avoid the + problem.) + +.. index:: sseregparm function attribute, x86 + +.. x86-fn-attr:: sseregparm + + On x86-32 targets with SSE support, the :x86-fn-attr:`sseregparm` attribute + causes the compiler to pass up to 3 floating-point arguments in + SSE registers instead of on the stack. Functions that take a + variable number of arguments continue to pass all of their + floating-point arguments on the stack. + +.. index:: force_align_arg_pointer function attribute, x86 + +.. x86-fn-attr:: force_align_arg_pointer + + On x86 targets, the :x86-fn-attr:`force_align_arg_pointer` attribute may be + applied to individual function definitions, generating an alternate + prologue and epilogue that realigns the run-time stack if necessary. + This supports mixing legacy codes that run with a 4-byte aligned stack + with modern codes that keep a 16-byte stack for SSE compatibility. + +.. index:: stdcall function attribute, x86-32, functions that pop the argument stack on x86-32 + +.. x86-fn-attr:: stdcall + + On x86-32 targets, the :x86-fn-attr:`stdcall` attribute causes the compiler to + assume that the called function pops off the stack space used to + pass arguments, unless it takes a variable number of arguments. + +.. index:: no_caller_saved_registers function attribute, x86 + +.. x86-fn-attr:: no_caller_saved_registers + + Use this attribute to indicate that the specified function has no + caller-saved registers. That is, all registers are callee-saved. For + example, this attribute can be used for a function called from an + interrupt handler. The compiler generates proper function entry and + exit sequences to save and restore any modified registers, except for + the EFLAGS register. Since GCC doesn't preserve SSE, MMX nor x87 + states, the GCC option :option:`-mgeneral-regs-only` should be used to + compile functions with :x86-fn-attr:`no_caller_saved_registers` attribute. + +.. index:: interrupt function attribute, x86 + +.. x86-fn-attr:: interrupt + + Use this attribute to indicate that the specified function is an + interrupt handler or an exception handler (depending on parameters passed + to the function, explained further). The compiler generates function + entry and exit sequences suitable for use in an interrupt handler when + this attribute is present. The ``IRET`` instruction, instead of the + ``RET`` instruction, is used to return from interrupt handlers. All + registers, except for the EFLAGS register which is restored by the + ``IRET`` instruction, are preserved by the compiler. Since GCC + doesn't preserve SSE, MMX nor x87 states, the GCC option + :option:`-mgeneral-regs-only` should be used to compile interrupt and + exception handlers. + + Any interruptible-without-stack-switch code must be compiled with + :option:`-mno-red-zone` since interrupt handlers can and will, because + of the hardware design, touch the red zone. + + An interrupt handler must be declared with a mandatory pointer + argument: + + .. code-block:: c++ + + struct interrupt_frame; + + __attribute__ ((interrupt)) + void + f (struct interrupt_frame *frame) + { + } + + and you must define ``struct interrupt_frame`` as described in the + processor's manual. + + Exception handlers differ from interrupt handlers because the system + pushes an error code on the stack. An exception handler declaration is + similar to that for an interrupt handler, but with a different mandatory + function signature. The compiler arranges to pop the error code off the + stack before the ``IRET`` instruction. + + .. code-block:: c++ + + #ifdef __x86_64__ + typedef unsigned long long int uword_t; + #else + typedef unsigned int uword_t; + #endif + + struct interrupt_frame; + + __attribute__ ((interrupt)) + void + f (struct interrupt_frame *frame, uword_t error_code) + { + ... + } + + Exception handlers should only be used for exceptions that push an error + code; you should use an interrupt handler in other cases. The system + will crash if the wrong kind of handler is used. + +.. index:: target function attribute + +.. x86-fn-attr:: target (options) + + As discussed in :ref:`common-function-attributes`, this attribute + allows specification of target-specific compilation options. + + On the x86, the following options are allowed: + + :samp:`3dnow` :samp:`no-3dnow` + + .. index:: target("3dnow") function attribute, x86 + + Enable/disable the generation of the 3DNow! instructions. + + :samp:`3dnowa` :samp:`no-3dnowa` + + .. index:: target("3dnowa") function attribute, x86 + + Enable/disable the generation of the enhanced 3DNow! instructions. + + :samp:`abm` :samp:`no-abm` + + .. index:: target("abm") function attribute, x86 + + Enable/disable the generation of the advanced bit instructions. + + :samp:`adx` :samp:`no-adx` + + .. index:: target("adx") function attribute, x86 + + Enable/disable the generation of the ADX instructions. + + :samp:`aes` :samp:`no-aes` + + .. index:: target("aes") function attribute, x86 + + Enable/disable the generation of the AES instructions. + + :samp:`avx` :samp:`no-avx` + + .. index:: target("avx") function attribute, x86 + + Enable/disable the generation of the AVX instructions. + + :samp:`avx2` :samp:`no-avx2` + + .. index:: target("avx2") function attribute, x86 + + Enable/disable the generation of the AVX2 instructions. + + :samp:`avx5124fmaps` :samp:`no-avx5124fmaps` + + .. index:: target("avx5124fmaps") function attribute, x86 + + Enable/disable the generation of the AVX5124FMAPS instructions. + + :samp:`avx5124vnniw` :samp:`no-avx5124vnniw` + + .. index:: target("avx5124vnniw") function attribute, x86 + + Enable/disable the generation of the AVX5124VNNIW instructions. + + :samp:`avx512bitalg` :samp:`no-avx512bitalg` + + .. index:: target("avx512bitalg") function attribute, x86 + + Enable/disable the generation of the AVX512BITALG instructions. + + :samp:`avx512bw` :samp:`no-avx512bw` + + .. index:: target("avx512bw") function attribute, x86 + + Enable/disable the generation of the AVX512BW instructions. + + :samp:`avx512cd` :samp:`no-avx512cd` + + .. index:: target("avx512cd") function attribute, x86 + + Enable/disable the generation of the AVX512CD instructions. + + :samp:`avx512dq` :samp:`no-avx512dq` + + .. index:: target("avx512dq") function attribute, x86 + + Enable/disable the generation of the AVX512DQ instructions. + + :samp:`avx512er` :samp:`no-avx512er` + + .. index:: target("avx512er") function attribute, x86 + + Enable/disable the generation of the AVX512ER instructions. + + :samp:`avx512f` :samp:`no-avx512f` + + .. index:: target("avx512f") function attribute, x86 + + Enable/disable the generation of the AVX512F instructions. + + :samp:`avx512ifma` :samp:`no-avx512ifma` + + .. index:: target("avx512ifma") function attribute, x86 + + Enable/disable the generation of the AVX512IFMA instructions. + + :samp:`avx512pf` :samp:`no-avx512pf` + + .. index:: target("avx512pf") function attribute, x86 + + Enable/disable the generation of the AVX512PF instructions. + + :samp:`avx512vbmi` :samp:`no-avx512vbmi` + + .. index:: target("avx512vbmi") function attribute, x86 + + Enable/disable the generation of the AVX512VBMI instructions. + + :samp:`avx512vbmi2` :samp:`no-avx512vbmi2` + + .. index:: target("avx512vbmi2") function attribute, x86 + + Enable/disable the generation of the AVX512VBMI2 instructions. + + :samp:`avx512vl` :samp:`no-avx512vl` + + .. index:: target("avx512vl") function attribute, x86 + + Enable/disable the generation of the AVX512VL instructions. + + :samp:`avx512vnni` :samp:`no-avx512vnni` + + .. index:: target("avx512vnni") function attribute, x86 + + Enable/disable the generation of the AVX512VNNI instructions. + + :samp:`avx512vpopcntdq` :samp:`no-avx512vpopcntdq` + + .. index:: target("avx512vpopcntdq") function attribute, x86 + + Enable/disable the generation of the AVX512VPOPCNTDQ instructions. + + :samp:`bmi` :samp:`no-bmi` + + .. index:: target("bmi") function attribute, x86 + + Enable/disable the generation of the BMI instructions. + + :samp:`bmi2` :samp:`no-bmi2` + + .. index:: target("bmi2") function attribute, x86 + + Enable/disable the generation of the BMI2 instructions. + + :samp:`cldemote` :samp:`no-cldemote` + + .. index:: target("cldemote") function attribute, x86 + + Enable/disable the generation of the CLDEMOTE instructions. + + :samp:`clflushopt` :samp:`no-clflushopt` + + .. index:: target("clflushopt") function attribute, x86 + + Enable/disable the generation of the CLFLUSHOPT instructions. + + :samp:`clwb` :samp:`no-clwb` + + .. index:: target("clwb") function attribute, x86 + + Enable/disable the generation of the CLWB instructions. + + :samp:`clzero` :samp:`no-clzero` + + .. index:: target("clzero") function attribute, x86 + + Enable/disable the generation of the CLZERO instructions. + + :samp:`crc32` :samp:`no-crc32` + + .. index:: target("crc32") function attribute, x86 + + Enable/disable the generation of the CRC32 instructions. + + :samp:`cx16` :samp:`no-cx16` + + .. index:: target("cx16") function attribute, x86 + + Enable/disable the generation of the CMPXCHG16B instructions. + + :samp:`default` + + .. index:: target("default") function attribute, x86 + + See :ref:`function-multiversioning`, where it is used to specify the + default function version. + + :samp:`f16c` :samp:`no-f16c` + + .. index:: target("f16c") function attribute, x86 + + Enable/disable the generation of the F16C instructions. + + :samp:`fma` :samp:`no-fma` + + .. index:: target("fma") function attribute, x86 + + Enable/disable the generation of the FMA instructions. + + :samp:`fma4` :samp:`no-fma4` + + .. index:: target("fma4") function attribute, x86 + + Enable/disable the generation of the FMA4 instructions. + + :samp:`fsgsbase` :samp:`no-fsgsbase` + + .. index:: target("fsgsbase") function attribute, x86 + + Enable/disable the generation of the FSGSBASE instructions. + + :samp:`fxsr` :samp:`no-fxsr` + + .. index:: target("fxsr") function attribute, x86 + + Enable/disable the generation of the FXSR instructions. + + :samp:`gfni` :samp:`no-gfni` + + .. index:: target("gfni") function attribute, x86 + + Enable/disable the generation of the GFNI instructions. + + :samp:`hle` :samp:`no-hle` + + .. index:: target("hle") function attribute, x86 + + Enable/disable the generation of the HLE instruction prefixes. + + :samp:`lwp` :samp:`no-lwp` + + .. index:: target("lwp") function attribute, x86 + + Enable/disable the generation of the LWP instructions. + + :samp:`lzcnt` :samp:`no-lzcnt` + + .. index:: target("lzcnt") function attribute, x86 + + Enable/disable the generation of the LZCNT instructions. + + :samp:`mmx` :samp:`no-mmx` + + .. index:: target("mmx") function attribute, x86 + + Enable/disable the generation of the MMX instructions. + + :samp:`movbe` :samp:`no-movbe` + + .. index:: target("movbe") function attribute, x86 + + Enable/disable the generation of the MOVBE instructions. + + :samp:`movdir64b` :samp:`no-movdir64b` + + .. index:: target("movdir64b") function attribute, x86 + + Enable/disable the generation of the MOVDIR64B instructions. + + :samp:`movdiri` :samp:`no-movdiri` + + .. index:: target("movdiri") function attribute, x86 + + Enable/disable the generation of the MOVDIRI instructions. + + :samp:`mwait` :samp:`no-mwait` + + .. index:: target("mwait") function attribute, x86 + + Enable/disable the generation of the MWAIT and MONITOR instructions. + + :samp:`mwaitx` :samp:`no-mwaitx` + + .. index:: target("mwaitx") function attribute, x86 + + Enable/disable the generation of the MWAITX instructions. + + :samp:`pclmul` :samp:`no-pclmul` + + .. index:: target("pclmul") function attribute, x86 + + Enable/disable the generation of the PCLMUL instructions. + + :samp:`pconfig` :samp:`no-pconfig` + + .. index:: target("pconfig") function attribute, x86 + + Enable/disable the generation of the PCONFIG instructions. + + :samp:`pku` :samp:`no-pku` + + .. index:: target("pku") function attribute, x86 + + Enable/disable the generation of the PKU instructions. + + :samp:`popcnt` :samp:`no-popcnt` + + .. index:: target("popcnt") function attribute, x86 + + Enable/disable the generation of the POPCNT instruction. + + :samp:`prefetchwt1` :samp:`no-prefetchwt1` + + .. index:: target("prefetchwt1") function attribute, x86 + + Enable/disable the generation of the PREFETCHWT1 instructions. + + :samp:`prfchw` :samp:`no-prfchw` + + .. index:: target("prfchw") function attribute, x86 + + Enable/disable the generation of the PREFETCHW instruction. + + :samp:`ptwrite` :samp:`no-ptwrite` + + .. index:: target("ptwrite") function attribute, x86 + + Enable/disable the generation of the PTWRITE instructions. + + :samp:`rdpid` :samp:`no-rdpid` + + .. index:: target("rdpid") function attribute, x86 + + Enable/disable the generation of the RDPID instructions. + + :samp:`rdrnd` :samp:`no-rdrnd` + + .. index:: target("rdrnd") function attribute, x86 + + Enable/disable the generation of the RDRND instructions. + + :samp:`rdseed` :samp:`no-rdseed` + + .. index:: target("rdseed") function attribute, x86 + + Enable/disable the generation of the RDSEED instructions. + + :samp:`rtm` :samp:`no-rtm` + + .. index:: target("rtm") function attribute, x86 + + Enable/disable the generation of the RTM instructions. + + :samp:`sahf` :samp:`no-sahf` + + .. index:: target("sahf") function attribute, x86 + + Enable/disable the generation of the SAHF instructions. + + :samp:`sgx` :samp:`no-sgx` + + .. index:: target("sgx") function attribute, x86 + + Enable/disable the generation of the SGX instructions. + + :samp:`sha` :samp:`no-sha` + + .. index:: target("sha") function attribute, x86 + + Enable/disable the generation of the SHA instructions. + + :samp:`shstk` :samp:`no-shstk` + + .. index:: target("shstk") function attribute, x86 + + Enable/disable the shadow stack built-in functions from CET. + + :samp:`sse` :samp:`no-sse` + + .. index:: target("sse") function attribute, x86 + + Enable/disable the generation of the SSE instructions. + + :samp:`sse2` :samp:`no-sse2` + + .. index:: target("sse2") function attribute, x86 + + Enable/disable the generation of the SSE2 instructions. + + :samp:`sse3` :samp:`no-sse3` + + .. index:: target("sse3") function attribute, x86 + + Enable/disable the generation of the SSE3 instructions. + + :samp:`sse4` :samp:`no-sse4` + + .. index:: target("sse4") function attribute, x86 + + Enable/disable the generation of the SSE4 instructions (both SSE4.1 + and SSE4.2). + + :samp:`sse4.1` :samp:`no-sse4.1` + + .. index:: target("sse4.1") function attribute, x86 + + Enable/disable the generation of the SSE4.1 instructions. + + :samp:`sse4.2` :samp:`no-sse4.2` + + .. index:: target("sse4.2") function attribute, x86 + + Enable/disable the generation of the SSE4.2 instructions. + + :samp:`sse4a` :samp:`no-sse4a` + + .. index:: target("sse4a") function attribute, x86 + + Enable/disable the generation of the SSE4A instructions. + + :samp:`ssse3` :samp:`no-ssse3` + + .. index:: target("ssse3") function attribute, x86 + + Enable/disable the generation of the SSSE3 instructions. + + :samp:`tbm` :samp:`no-tbm` + + .. index:: target("tbm") function attribute, x86 + + Enable/disable the generation of the TBM instructions. + + :samp:`vaes` :samp:`no-vaes` + + .. index:: target("vaes") function attribute, x86 + + Enable/disable the generation of the VAES instructions. + + :samp:`vpclmulqdq` :samp:`no-vpclmulqdq` + + .. index:: target("vpclmulqdq") function attribute, x86 + + Enable/disable the generation of the VPCLMULQDQ instructions. + + :samp:`waitpkg` :samp:`no-waitpkg` + + .. index:: target("waitpkg") function attribute, x86 + + Enable/disable the generation of the WAITPKG instructions. + + :samp:`wbnoinvd` :samp:`no-wbnoinvd` + + .. index:: target("wbnoinvd") function attribute, x86 + + Enable/disable the generation of the WBNOINVD instructions. + + :samp:`xop` :samp:`no-xop` + + .. index:: target("xop") function attribute, x86 + + Enable/disable the generation of the XOP instructions. + + :samp:`xsave` :samp:`no-xsave` + + .. index:: target("xsave") function attribute, x86 + + Enable/disable the generation of the XSAVE instructions. + + :samp:`xsavec` :samp:`no-xsavec` + + .. index:: target("xsavec") function attribute, x86 + + Enable/disable the generation of the XSAVEC instructions. + + :samp:`xsaveopt` :samp:`no-xsaveopt` + + .. index:: target("xsaveopt") function attribute, x86 + + Enable/disable the generation of the XSAVEOPT instructions. + + :samp:`xsaves` :samp:`no-xsaves` + + .. index:: target("xsaves") function attribute, x86 + + Enable/disable the generation of the XSAVES instructions. + + :samp:`amx-tile` :samp:`no-amx-tile` + + .. index:: target("amx-tile") function attribute, x86 + + Enable/disable the generation of the AMX-TILE instructions. + + :samp:`amx-int8` :samp:`no-amx-int8` + + .. index:: target("amx-int8") function attribute, x86 + + Enable/disable the generation of the AMX-INT8 instructions. + + :samp:`amx-bf16` :samp:`no-amx-bf16` + + .. index:: target("amx-bf16") function attribute, x86 + + Enable/disable the generation of the AMX-BF16 instructions. + + :samp:`uintr` :samp:`no-uintr` + + .. index:: target("uintr") function attribute, x86 + + Enable/disable the generation of the UINTR instructions. + + :samp:`hreset` :samp:`no-hreset` + + .. index:: target("hreset") function attribute, x86 + + Enable/disable the generation of the HRESET instruction. + + :samp:`kl` :samp:`no-kl` + + .. index:: target("kl") function attribute, x86 + + Enable/disable the generation of the KEYLOCKER instructions. + + :samp:`widekl` :samp:`no-widekl` + + .. index:: target("widekl") function attribute, x86 + + Enable/disable the generation of the WIDEKL instructions. + + :samp:`avxvnni` :samp:`no-avxvnni` + + .. index:: target("avxvnni") function attribute, x86 + + Enable/disable the generation of the AVXVNNI instructions. + + :samp:`avxifma` :samp:`no-avxifma` + + .. index:: target("avxifma") function attribute, x86 + + Enable/disable the generation of the AVXIFMA instructions. + + :samp:`avxvnniint8` :samp:`no-avxvnniint8` + + .. index:: target("avxvnniint8") function attribute, x86 + + Enable/disable the generation of the AVXVNNIINT8 instructions. + + :samp:`avxneconvert` :samp:`no-avxneconvert` + + .. index:: target("avxneconvert") function attribute, x86 + + Enable/disable the generation of the AVXNECONVERT instructions. + + :samp:`cmpccxadd` :samp:`no-cmpccxadd` + + .. index:: target("cmpccxadd") function attribute, x86 + + Enable/disable the generation of the CMPccXADD instructions. + + :samp:`amx-fp16` :samp:`no-amx-fp16` + + .. index:: target("amx-fp16") function attribute, x86 + + Enable/disable the generation of the AMX-FP16 instructions. + + :samp:`prefetchi` :samp:`no-prefetchi` + + .. index:: target("prefetchi") function attribute, x86 + + Enable/disable the generation of the PREFETCHI instructions. + + :samp:`raoint` :samp:`no-raoint` + + .. index:: target("raoint") function attribute, x86 + + Enable/disable the generation of the RAOINT instructions. + + :samp:`cld` :samp:`no-cld` + + .. index:: target("cld") function attribute, x86 + + Enable/disable the generation of the CLD before string moves. + + :samp:`fancy-math-387` :samp:`no-fancy-math-387` + + .. index:: target("fancy-math-387") function attribute, x86 + + Enable/disable the generation of the ``sin``, ``cos``, and + ``sqrt`` instructions on the 387 floating-point unit. + + :samp:`ieee-fp` :samp:`no-ieee-fp` + + .. index:: target("ieee-fp") function attribute, x86 + + Enable/disable the generation of floating point that depends on IEEE arithmetic. + + :samp:`inline-all-stringops` :samp:`no-inline-all-stringops` + + .. index:: target("inline-all-stringops") function attribute, x86 + + Enable/disable inlining of string operations. + + :samp:`inline-stringops-dynamically` :samp:`no-inline-stringops-dynamically` + + .. index:: target("inline-stringops-dynamically") function attribute, x86 + + Enable/disable the generation of the inline code to do small string + operations and calling the library routines for large operations. + + :samp:`align-stringops` :samp:`no-align-stringops` + + .. index:: target("align-stringops") function attribute, x86 + + Do/do not align destination of inlined string operations. + + :samp:`recip` :samp:`no-recip` + + .. index:: target("recip") function attribute, x86 + + Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS + instructions followed an additional Newton-Raphson step instead of + doing a floating-point division. + + :samp:`general-regs-only` + + .. index:: target("general-regs-only") function attribute, x86 + + Generate code which uses only the general registers. + + :samp:`arch={ARCH}` + + .. index:: target("arch=ARCH") function attribute, x86 + + Specify the architecture to generate code for in compiling the function. + + :samp:`tune={TUNE}` + + .. index:: target("tune=TUNE") function attribute, x86 + + Specify the architecture to tune for in compiling the function. + + :samp:`fpmath={FPMATH}` + + .. index:: target("fpmath=FPMATH") function attribute, x86 + + Specify which floating-point unit to use. You must specify the + ``target("fpmath=sse,387")`` option as + ``target("fpmath=sse+387")`` because the comma would separate + different options. + + :samp:`prefer-vector-width={OPT}` + + .. index:: prefer-vector-width function attribute, x86 + + On x86 targets, the ``prefer-vector-width`` attribute informs the + compiler to use :samp:`{OPT}` -bit vector width in instructions + instead of the default on the selected platform. + + Valid :samp:`{OPT}` values are: + + :samp:`none` + No extra limitations applied to GCC other than defined by the selected platform. + + :samp:`128` + Prefer 128-bit vector width for instructions. + + :samp:`256` + Prefer 256-bit vector width for instructions. + + :samp:`512` + Prefer 512-bit vector width for instructions. + + On the x86, the inliner does not inline a + function that has different target options than the caller, unless the + callee has a subset of the target options of the caller. For example + a function declared with ``target("sse3")`` can inline a function + with ``target("sse2")``, since ``-msse3`` implies ``-msse2``. + +.. index:: indirect_branch function attribute, x86 + +.. x86-fn-attr:: indirect_branch("choice") + + On x86 targets, the ``indirect_branch`` attribute causes the compiler + to convert indirect call and jump with :samp:`{choice}`. :samp:`keep` + keeps indirect call and jump unmodified. :samp:`thunk` converts indirect + call and jump to call and return thunk. :samp:`thunk-inline` converts + indirect call and jump to inlined call and return thunk. + :samp:`thunk-extern` converts indirect call and jump to external call + and return thunk provided in a separate object file. + +.. index:: function_return function attribute, x86 + +.. x86-fn-attr:: function_return("choice") + + On x86 targets, the ``function_return`` attribute causes the compiler + to convert function return with :samp:`{choice}`. :samp:`keep` keeps function + return unmodified. :samp:`thunk` converts function return to call and + return thunk. :samp:`thunk-inline` converts function return to inlined + call and return thunk. :samp:`thunk-extern` converts function return to + external call and return thunk provided in a separate object file. + +.. index:: nocf_check function attribute + +.. x86-fn-attr:: nocf_check + + The :x86-fn-attr:`nocf_check` attribute on a function is used to inform the + compiler that the function's prologue should not be instrumented when + compiled with the :option:`-fcf-protection=branch` option. The + compiler assumes that the function's address is a valid target for a + control-flow transfer. + + The :x86-fn-attr:`nocf_check` attribute on a type of pointer to function is + used to inform the compiler that a call through the pointer should + not be instrumented when compiled with the + :option:`-fcf-protection=branch` option. The compiler assumes + that the function's address from the pointer is a valid target for + a control-flow transfer. A direct function call through a function + name is assumed to be a safe call thus direct calls are not + instrumented by the compiler. + + The :x86-fn-attr:`nocf_check` attribute is applied to an object's type. + In case of assignment of a function address or a function pointer to + another pointer, the attribute is not carried over from the right-hand + object's type; the type of left-hand object stays unchanged. The + compiler checks for :x86-fn-attr:`nocf_check` attribute mismatch and reports + a warning in case of mismatch. + + .. code-block:: c++ + + { + int foo (void) __attribute__(nocf_check); + void (*foo1)(void) __attribute__(nocf_check); + void (*foo2)(void); + + /* foo's address is assumed to be valid. */ + int + foo (void) + + /* This call site is not checked for control-flow + validity. */ + (*foo1)(); + + /* A warning is issued about attribute mismatch. */ + foo1 = foo2; + + /* This call site is still not checked. */ + (*foo1)(); + + /* This call site is checked. */ + (*foo2)(); + + /* A warning is issued about attribute mismatch. */ + foo2 = foo1; + + /* This call site is still checked. */ + (*foo2)(); + + return 0; + } + +.. index:: cf_check function attribute, x86 + +.. x86-fn-attr:: cf_check + + The :x86-fn-attr:`cf_check` attribute on a function is used to inform the + compiler that ENDBR instruction should be placed at the function + entry when :option:`-fcf-protection=branch` is enabled. + +.. index:: indirect_return function attribute, x86 + +.. x86-fn-attr:: indirect_return + + The :x86-fn-attr:`indirect_return` attribute can be applied to a function, + as well as variable or type of function pointer to inform the + compiler that the function may return via indirect branch. + +.. index:: fentry_name function attribute, x86 + +.. x86-fn-attr:: fentry_name("name") + + On x86 targets, the ``fentry_name`` attribute sets the function to + call on function entry when function instrumentation is enabled + with :option:`-pg -mfentry`. When :samp:`{name}` is nop then a 5 byte + nop sequence is generated. + +.. index:: fentry_section function attribute, x86 + +.. x86-fn-attr:: fentry_section("name") + + On x86 targets, the ``fentry_section`` attribute sets the name + of the section to record function entry instrumentation calls in when + enabled with :option:`-pg -mrecord-mcount` + +.. index:: nodirect_extern_access function attribute + +.. option:: nodirect_extern_access + + This attribute, attached to a global variable or function, is the + counterpart to option :option:`-mno-direct-extern-access`. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/xstormy16-function-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/xstormy16-function-attributes.rst new file mode 100644 index 00000000000..0c798122651 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/declaring-attributes-of-functions/xstormy16-function-attributes.rst @@ -0,0 +1,20 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _xstormy16-function-attributes: + +Xstormy16 Function Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These function attributes are supported by the Xstormy16 back end: + +.. index:: interrupt function attribute, Xstormy16 + +.. xstormy16-fn-attr:: interrupt + + Use this attribute to indicate + that the specified function is an interrupt handler. The compiler generates + function entry and exit sequences suitable for use in an interrupt handler + when this attribute is present. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/designated-initializers.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/designated-initializers.rst new file mode 100644 index 00000000000..2b89d34e053 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/designated-initializers.rst @@ -0,0 +1,147 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: initializers with labeled elements, labeled elements in initializers, case labels in initializers, designated initializers + +.. _designated-inits: + +Designated Initializers +*********************** + +Standard C90 requires the elements of an initializer to appear in a fixed +order, the same as the order of the elements in the array or structure +being initialized. + +In ISO C99 you can give the elements in any order, specifying the array +indices or structure field names they apply to, and GNU C allows this as +an extension in C90 mode as well. This extension is not +implemented in GNU C++. + +To specify an array index, write +:samp:`[{index}] =` before the element value. For example, + +.. code-block:: c++ + + int a[6] = { [4] = 29, [2] = 15 }; + +is equivalent to + +.. code-block:: c++ + + int a[6] = { 0, 0, 15, 0, 29, 0 }; + +The index values must be constant expressions, even if the array being +initialized is automatic. + +An alternative syntax for this that has been obsolete since GCC 2.5 but +GCC still accepts is to write :samp:`[{index}]` before the element +value, with no :samp:`=`. + +To initialize a range of elements to the same value, write +:samp:`[{first} ... {last}] = {value}`. This is a GNU +extension. For example, + +.. code-block:: c++ + + int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 }; + +If the value in it has side effects, the side effects happen only once, +not for each initialized field by the range initializer. + +Note that the length of the array is the highest value specified +plus one. + +In a structure initializer, specify the name of a field to initialize +with :samp:`.{fieldname} =` before the element value. For example, +given the following structure, + +.. code-block:: c++ + + struct point { int x, y; }; + +the following initialization + +.. code-block:: c++ + + struct point p = { .y = yvalue, .x = xvalue }; + +is equivalent to + +.. code-block:: c++ + + struct point p = { xvalue, yvalue }; + +Another syntax that has the same meaning, obsolete since GCC 2.5, is +:samp:`{fieldname}:`, as shown here: + +.. code-block:: c++ + + struct point p = { y: yvalue, x: xvalue }; + +Omitted fields are implicitly initialized the same as for objects +that have static storage duration. + +.. index:: designators + +The :samp:`[{index}]` or :samp:`.{fieldname}` is known as a +:dfn:`designator`. You can also use a designator (or the obsolete colon +syntax) when initializing a union, to specify which element of the union +should be used. For example, + +.. code-block:: c++ + + union foo { int i; double d; }; + + union foo f = { .d = 4 }; + +converts 4 to a ``double`` to store it in the union using +the second element. By contrast, casting 4 to type ``union foo`` +stores it into the union as the integer ``i``, since it is +an integer. See :ref:`cast-to-union`. + +You can combine this technique of naming elements with ordinary C +initialization of successive elements. Each initializer element that +does not have a designator applies to the next consecutive element of the +array or structure. For example, + +.. code-block:: c++ + + int a[6] = { [1] = v1, v2, [4] = v4 }; + +is equivalent to + +.. code-block:: c++ + + int a[6] = { 0, v1, v2, 0, v4, 0 }; + +Labeling the elements of an array initializer is especially useful +when the indices are characters or belong to an ``enum`` type. +For example: + +.. code-block:: c++ + + int whitespace[256] + = { [' '] = 1, ['\t'] = 1, ['\h'] = 1, + ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 }; + +.. index:: designator lists + +You can also write a series of :samp:`.{fieldname}` and +:samp:`[{index}]` designators before an :samp:`=` to specify a +nested subobject to initialize; the list is taken relative to the +subobject corresponding to the closest surrounding brace pair. For +example, with the :samp:`struct point` declaration above: + +.. code-block:: c++ + + struct point ptarray[10] = { [2].y = yv2, [2].x = xv2, [0].x = xv0 }; + +If the same field is initialized multiple times, or overlapping +fields of a union are initialized, the value from the last +initialization is used. When a field of a union is itself a structure, +the entire structure from the last field initialized is used. If any previous +initializer has side effect, it is unspecified whether the side effect +happens or not. Currently, GCC discards the side-effecting +initializer expressions and issues a warning. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/determining-the-alignment-of-functions-types-or-variables.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/determining-the-alignment-of-functions-types-or-variables.rst new file mode 100644 index 00000000000..ff1c0111687 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/determining-the-alignment-of-functions-types-or-variables.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: alignment, type alignment, variable alignment + +.. _alignment: + +Determining the Alignment of Functions, Types or Variables +********************************************************** + +The keyword ``__alignof__`` determines the alignment requirement of +a function, object, or a type, or the minimum alignment usually required +by a type. Its syntax is just like ``sizeof`` and C11 ``_Alignof``. + +For example, if the target machine requires a ``double`` value to be +aligned on an 8-byte boundary, then ``__alignof__ (double)`` is 8. +This is true on many RISC machines. On more traditional machine +designs, ``__alignof__ (double)`` is 4 or even 2. + +Some machines never actually require alignment; they allow references to any +data type even at an odd address. For these machines, ``__alignof__`` +reports the smallest alignment that GCC gives the data type, usually as +mandated by the target ABI. + +If the operand of ``__alignof__`` is an lvalue rather than a type, +its value is the required alignment for its type, taking into account +any minimum alignment specified by attribute :var-attr:`aligned` +(see :ref:`common-variable-attributes`). For example, after this +declaration: + +.. code-block:: c++ + + struct foo { int x; char y; } foo1; + +the value of ``__alignof__ (foo1.y)`` is 1, even though its actual +alignment is probably 2 or 4, the same as ``__alignof__ (int)``. +It is an error to ask for the alignment of an incomplete type other +than ``void``. + +If the operand of the ``__alignof__`` expression is a function, +the expression evaluates to the alignment of the function which may +be specified by attribute :fn-attr:`aligned` (see :ref:`common-function-attributes`). \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/dollar-signs-in-identifier-names.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/dollar-signs-in-identifier-names.rst new file mode 100644 index 00000000000..c6d6e65e75d --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/dollar-signs-in-identifier-names.rst @@ -0,0 +1,16 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: $, dollar signs in identifier names, identifier names, dollar signs in + +.. _dollar-signs: + +Dollar Signs in Identifier Names +******************************** + +In GNU C, you may normally use dollar signs in identifier names. +This is because many traditional C implementations allow such identifiers. +However, dollar signs in identifiers are not supported on a few target +machines, typically because the target assembler does not allow them. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/double-word-integers.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/double-word-integers.rst new file mode 100644 index 00000000000..96d8bc3e2b8 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/double-word-integers.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: long long data types, double-word arithmetic, multiprecision arithmetic, LL integer suffix, ULL integer suffix + +.. _long-long: + +Double-Word Integers +******************** + +ISO C99 and ISO C++11 support data types for integers that are at least +64 bits wide, and as an extension GCC supports them in C90 and C++98 modes. +Simply write ``long long int`` for a signed integer, or +``unsigned long long int`` for an unsigned integer. To make an +integer constant of type ``long long int``, add the suffix :samp:`LL` +to the integer. To make an integer constant of type ``unsigned long +long int``, add the suffix :samp:`ULL` to the integer. + +You can use these types in arithmetic like any other integer types. +Addition, subtraction, and bitwise boolean operations on these types +are open-coded on all types of machines. Multiplication is open-coded +if the machine supports a fullword-to-doubleword widening multiply +instruction. Division and shifts are open-coded only on machines that +provide special support. The operations that are not open-coded use +special library routines that come with GCC. + +There may be pitfalls when you use ``long long`` types for function +arguments without function prototypes. If a function +expects type ``int`` for its argument, and you pass a value of type +``long long int``, confusion results because the caller and the +subroutine disagree about the number of bytes for the argument. +Likewise, if the function expects ``long long int`` and you pass +``int``. The best way to avoid such problems is to use prototypes. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/enumerator-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/enumerator-attributes.rst new file mode 100644 index 00000000000..620611bfdf5 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/enumerator-attributes.rst @@ -0,0 +1,53 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Enumerator Attributes + +.. _enumerator-attributes: + +Enumerator Attributes +********************* + +GCC allows attributes to be set on enumerators. See :ref:`attribute-syntax`, for +details of the exact syntax for using attributes. Other attributes are +available for functions (see :ref:`function-attributes`), variables +(see :ref:`variable-attributes`), labels (see :ref:`label-attributes`), statements +(see :ref:`statement-attributes`), and for types (see :ref:`type-attributes`). + +This example uses the :enum-attr:`deprecated` enumerator attribute to indicate the +``oldval`` enumerator is deprecated: + +.. code-block:: c++ + + enum E { + oldval __attribute__((deprecated)), + newval + }; + + int + fn (void) + { + return oldval; + } + +:enum-attr:`deprecated` + + .. index:: deprecated enumerator attribute + + The :enum-attr:`deprecated` attribute results in a warning if the enumerator + is used anywhere in the source file. This is useful when identifying + enumerators that are expected to be removed in a future version of a + program. The warning also includes the location of the declaration + of the deprecated enumerator, to enable users to easily find further + information about why the enumerator is deprecated, or what they should + do instead. Note that the warnings only occurs for uses. + +:enum-attr:`unavailable` + + .. index:: unavailable enumerator attribute + + The :enum-attr:`unavailable` attribute results in an error if the enumerator + is used anywhere in the source file. In other respects it behaves in the + same manner as the :enum-attr:`deprecated` attribute. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/fixed-point-types.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/fixed-point-types.rst new file mode 100644 index 00000000000..27f3d0e8789 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/fixed-point-types.rst @@ -0,0 +1,128 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: fixed-point types, _Fract data type, _Accum data type, _Sat data type, hr fixed-suffix, r fixed-suffix, lr fixed-suffix, llr fixed-suffix, uhr fixed-suffix, ur fixed-suffix, ulr fixed-suffix, ullr fixed-suffix, hk fixed-suffix, k fixed-suffix, lk fixed-suffix, llk fixed-suffix, uhk fixed-suffix, uk fixed-suffix, ulk fixed-suffix, ullk fixed-suffix, HR fixed-suffix, R fixed-suffix, LR fixed-suffix, LLR fixed-suffix, UHR fixed-suffix, UR fixed-suffix, ULR fixed-suffix, ULLR fixed-suffix, HK fixed-suffix, K fixed-suffix, LK fixed-suffix, LLK fixed-suffix, UHK fixed-suffix, UK fixed-suffix, ULK fixed-suffix, ULLK fixed-suffix + +.. _fixed-point: + +Fixed-Point Types +***************** + +As an extension, GNU C supports fixed-point types as +defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point +types in GCC will evolve as the draft technical report changes. +Calling conventions for any target might also change. Not all targets +support fixed-point types. + +The fixed-point types are +``short _Fract``, +``_Fract``, +``long _Fract``, +``long long _Fract``, +``unsigned short _Fract``, +``unsigned _Fract``, +``unsigned long _Fract``, +``unsigned long long _Fract``, +``_Sat short _Fract``, +``_Sat _Fract``, +``_Sat long _Fract``, +``_Sat long long _Fract``, +``_Sat unsigned short _Fract``, +``_Sat unsigned _Fract``, +``_Sat unsigned long _Fract``, +``_Sat unsigned long long _Fract``, +``short _Accum``, +``_Accum``, +``long _Accum``, +``long long _Accum``, +``unsigned short _Accum``, +``unsigned _Accum``, +``unsigned long _Accum``, +``unsigned long long _Accum``, +``_Sat short _Accum``, +``_Sat _Accum``, +``_Sat long _Accum``, +``_Sat long long _Accum``, +``_Sat unsigned short _Accum``, +``_Sat unsigned _Accum``, +``_Sat unsigned long _Accum``, +``_Sat unsigned long long _Accum``. + +Fixed-point data values contain fractional and optional integral parts. +The format of fixed-point data varies and depends on the target machine. + +Support for fixed-point types includes: + +* prefix and postfix increment and decrement operators (``++``, ``--``) + +* unary arithmetic operators (``+``, ``-``, ``!``) + +* binary arithmetic operators (``+``, ``-``, ``*``, ``/``) + +* binary shift operators (``<<``, ``>>``) + +* relational operators (``<``, ``<=``, ``>=``, ``>``) + +* equality operators (``==``, ``!=``) + +* assignment operators (``+=``, ``-=``, ``*=``, ``/=``, + ``<<=``, ``>>=``) + +* conversions to and from integer, floating-point, or fixed-point types + +Use a suffix in a fixed-point literal constant: + +* :samp:`hr` or :samp:`HR` for ``short _Fract`` and + ``_Sat short _Fract`` + +* :samp:`r` or :samp:`R` for ``_Fract`` and ``_Sat _Fract`` + +* :samp:`lr` or :samp:`LR` for ``long _Fract`` and + ``_Sat long _Fract`` + +* :samp:`llr` or :samp:`LLR` for ``long long _Fract`` and + ``_Sat long long _Fract`` + +* :samp:`uhr` or :samp:`UHR` for ``unsigned short _Fract`` and + ``_Sat unsigned short _Fract`` + +* :samp:`ur` or :samp:`UR` for ``unsigned _Fract`` and + ``_Sat unsigned _Fract`` + +* :samp:`ulr` or :samp:`ULR` for ``unsigned long _Fract`` and + ``_Sat unsigned long _Fract`` + +* :samp:`ullr` or :samp:`ULLR` for ``unsigned long long _Fract`` + and ``_Sat unsigned long long _Fract`` + +* :samp:`hk` or :samp:`HK` for ``short _Accum`` and + ``_Sat short _Accum`` + +* :samp:`k` or :samp:`K` for ``_Accum`` and ``_Sat _Accum`` + +* :samp:`lk` or :samp:`LK` for ``long _Accum`` and + ``_Sat long _Accum`` + +* :samp:`llk` or :samp:`LLK` for ``long long _Accum`` and + ``_Sat long long _Accum`` + +* :samp:`uhk` or :samp:`UHK` for ``unsigned short _Accum`` and + ``_Sat unsigned short _Accum`` + +* :samp:`uk` or :samp:`UK` for ``unsigned _Accum`` and + ``_Sat unsigned _Accum`` + +* :samp:`ulk` or :samp:`ULK` for ``unsigned long _Accum`` and + ``_Sat unsigned long _Accum`` + +* :samp:`ullk` or :samp:`ULLK` for ``unsigned long long _Accum`` + and ``_Sat unsigned long long _Accum`` + +GCC support of fixed-point types as specified by the draft technical report +is incomplete: + +* Pragmas to control overflow and rounding behaviors are not implemented. + +Fixed-point types are supported by the DWARF debug information format. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/format-checks-specific-to-particular-target-machines.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/format-checks-specific-to-particular-target-machines.rst new file mode 100644 index 00000000000..6ffc76e6802 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/format-checks-specific-to-particular-target-machines.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _target-format-checks: + +Format Checks Specific to Particular Target Machines +**************************************************** + +For some target machines, GCC supports additional options to the +format attribute +(see :ref:`function-attributes`). + +.. toctree:: + :maxdepth: 2 + + +.. _solaris-format-checks: + +Solaris Format Checks +^^^^^^^^^^^^^^^^^^^^^ + +Solaris targets support the ``cmn_err`` (or ``__cmn_err__``) format +check. ``cmn_err`` accepts a subset of the standard ``printf`` +conversions, and the two-argument ``%b`` conversion for displaying +bit-fields. See the Solaris man page for ``cmn_err`` for more information. + +.. _darwin-format-checks: + +Darwin Format Checks +^^^^^^^^^^^^^^^^^^^^ + +In addition to the full set of format archetypes (attribute format style +arguments such as ``printf``, ``scanf``, ``strftime``, and +``strfmon``), Darwin targets also support the ``CFString`` (or +``__CFString__``) archetype in the ``format`` attribute. +Declarations with this archetype are parsed for correct syntax +and argument types. However, parsing of the format string itself and +validating arguments against it in calls to such functions is currently +not performed. + +Additionally, ``CFStringRefs`` (defined by the ``CoreFoundation`` headers) may +also be used as format arguments. Note that the relevant headers are only likely to be +available on Darwin (OSX) installations. On such installations, the XCode and system +documentation provide descriptions of ``CFString``, ``CFStringRefs`` and +associated functions. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/function-names-as-strings.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/function-names-as-strings.rst new file mode 100644 index 00000000000..227154f6380 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/function-names-as-strings.rst @@ -0,0 +1,71 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: __func__ identifier, __FUNCTION__ identifier, __PRETTY_FUNCTION__ identifier + +.. _function-names: + +Function Names as Strings +************************* + +GCC provides three magic constants that hold the name of the current +function as a string. In C++11 and later modes, all three are treated +as constant expressions and can be used in ``constexpr`` constexts. +The first of these constants is ``__func__``, which is part of +the C99 standard: + +The identifier ``__func__`` is implicitly declared by the translator +as if, immediately following the opening brace of each function +definition, the declaration + +.. code-block:: c++ + + static const char __func__[] = "function-name"; + +appeared, where function-name is the name of the lexically-enclosing +function. This name is the unadorned name of the function. As an +extension, at file (or, in C++, namespace scope), ``__func__`` +evaluates to the empty string. + +``__FUNCTION__`` is another name for ``__func__``, provided for +backward compatibility with old versions of GCC. + +In C, ``__PRETTY_FUNCTION__`` is yet another name for +``__func__``, except that at file scope (or, in C++, namespace scope), +it evaluates to the string ``"top level"``. In addition, in C++, +``__PRETTY_FUNCTION__`` contains the signature of the function as +well as its bare name. For example, this program: + +.. code-block:: c++ + + extern "C" int printf (const char *, ...); + + class a { + public: + void sub (int i) + { + printf ("__FUNCTION__ = %s\n", __FUNCTION__); + printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__); + } + }; + + int + main (void) + { + a ax; + ax.sub (0); + return 0; + } + +gives this output: + +.. code-block:: c++ + + __FUNCTION__ = sub + __PRETTY_FUNCTION__ = void a::sub(int) + +These identifiers are variables, not preprocessor macros, and may not +be used to initialize ``char`` arrays or be concatenated with string +literals. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/getting-the-return-or-frame-address-of-a-function.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/getting-the-return-or-frame-address-of-a-function.rst new file mode 100644 index 00000000000..d3e3870b8da --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/getting-the-return-or-frame-address-of-a-function.rst @@ -0,0 +1,97 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _return-address: + +Getting the Return or Frame Address of a Function +************************************************* + +These functions may be used to get information about the callers of a +function. + +.. function:: void * __builtin_return_address (unsigned int level) + + This function returns the return address of the current function, or of + one of its callers. The :samp:`{level}` argument is number of frames to + scan up the call stack. A value of ``0`` yields the return address + of the current function, a value of ``1`` yields the return address + of the caller of the current function, and so forth. When inlining + the expected behavior is that the function returns the address of + the function that is returned to. To work around this behavior use + the :fn-attr:`noinline` function attribute. + + The :samp:`{level}` argument must be a constant integer. + + On some machines it may be impossible to determine the return address of + any function other than the current one; in such cases, or when the top + of the stack has been reached, this function returns an unspecified + value. In addition, ``__builtin_frame_address`` may be used + to determine if the top of the stack has been reached. + + Additional post-processing of the returned value may be needed, see + ``__builtin_extract_return_addr``. + + The stored representation of the return address in memory may be different + from the address returned by ``__builtin_return_address``. For example, + on AArch64 the stored address may be mangled with return address signing + whereas the address returned by ``__builtin_return_address`` is not. + + Calling this function with a nonzero argument can have unpredictable + effects, including crashing the calling program. As a result, calls + that are considered unsafe are diagnosed when the :option:`-Wframe-address` + option is in effect. Such calls should only be made in debugging + situations. + + On targets where code addresses are representable as ``void *``, + + .. code-block:: c++ + + void *addr = __builtin_extract_return_addr (__builtin_return_address (0)); + + gives the code address where the current function would return. For example, + such an address may be used with ``dladdr`` or other interfaces that work + with code addresses. + +.. function:: void * __builtin_extract_return_addr (void *addr) + + The address as returned by ``__builtin_return_address`` may have to be fed + through this function to get the actual encoded address. For example, on the + 31-bit S/390 platform the highest bit has to be masked out, or on SPARC + platforms an offset has to be added for the true next instruction to be + executed. + + If no fixup is needed, this function simply passes through :samp:`{addr}`. + +.. function:: void * __builtin_frob_return_addr (void *addr) + + This function does the reverse of ``__builtin_extract_return_addr``. + +.. function:: void * __builtin_frame_address (unsigned int level) + + This function is similar to ``__builtin_return_address``, but it + returns the address of the function frame rather than the return address + of the function. Calling ``__builtin_frame_address`` with a value of + ``0`` yields the frame address of the current function, a value of + ``1`` yields the frame address of the caller of the current function, + and so forth. + + The frame is the area on the stack that holds local variables and saved + registers. The frame address is normally the address of the first word + pushed on to the stack by the function. However, the exact definition + depends upon the processor and the calling convention. If the processor + has a dedicated frame pointer register, and the function has a frame, + then ``__builtin_frame_address`` returns the value of the frame + pointer register. + + On some machines it may be impossible to determine the frame address of + any function other than the current one; in such cases, or when the top + of the stack has been reached, this function returns ``0`` if + the first frame pointer is properly initialized by the startup code. + + Calling this function with a nonzero argument can have unpredictable + effects, including crashing the calling program. As a result, calls + that are considered unsafe are diagnosed when the :option:`-Wframe-address` + option is in effect. Such calls should only be made in debugging + situations. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/half-precision-floating-point.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/half-precision-floating-point.rst new file mode 100644 index 00000000000..3eff48063ba --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/half-precision-floating-point.rst @@ -0,0 +1,76 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: half-precision floating point, __fp16 data type, __Float16 data type + +.. _half-precision: + +Half-Precision Floating Point +***************************** + +On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating +point via the ``__fp16`` type defined in the ARM C Language Extensions. +On ARM systems, you must enable this type explicitly with the +:option:`-mfp16-format` command-line option in order to use it. +On x86 targets with SSE2 enabled, GCC supports half-precision (16-bit) +floating point via the ``_Float16`` type. For C++, x86 provides a builtin +type named ``_Float16`` which contains same data format as C. + +ARM targets support two incompatible representations for half-precision +floating-point values. You must choose one of the representations and +use it consistently in your program. + +Specifying :option:`-mfp16-format=ieee` selects the IEEE 754-2008 format. +This format can represent normalized values in the range of 2^{-14} to 65504. +There are 11 bits of significand precision, approximately 3 +decimal digits. + +Specifying :option:`-mfp16-format=alternative` selects the ARM +alternative format. This representation is similar to the IEEE +format, but does not support infinities or NaNs. Instead, the range +of exponents is extended, so that this format can represent normalized +values in the range of 2^{-14} to 131008. + +The GCC port for AArch64 only supports the IEEE 754-2008 format, and does +not require use of the :option:`-mfp16-format` command-line option. + +The ``__fp16`` type may only be used as an argument to intrinsics defined +in ````, or as a storage format. For purposes of +arithmetic and other operations, ``__fp16`` values in C or C++ +expressions are automatically promoted to ``float``. + +The ARM target provides hardware support for conversions between +``__fp16`` and ``float`` values +as an extension to VFP and NEON (Advanced SIMD), and from ARMv8-A provides +hardware support for conversions between ``__fp16`` and ``double`` +values. GCC generates code using these hardware instructions if you +compile with options to select an FPU that provides them; +for example, :option:`-mfpu=neon-fp16 -mfloat-abi=softfp`, +in addition to the :option:`-mfp16-format` option to select +a half-precision format. + +Language-level support for the ``__fp16`` data type is +independent of whether GCC generates code using hardware floating-point +instructions. In cases where hardware support is not specified, GCC +implements conversions between ``__fp16`` and other types as library +calls. + +It is recommended that portable code use the ``_Float16`` type defined +by ISO/IEC TS 18661-3:2015. See :ref:`floating-types`. + +On x86 targets with SSE2 enabled, without :option:`-mavx512fp16`, +all operations will be emulated by software emulation and the ``float`` +instructions. The default behavior for ``FLT_EVAL_METHOD`` is to keep the +intermediate result of the operation as 32-bit precision. This may lead to +inconsistent behavior between software emulation and AVX512-FP16 instructions. +Using :option:`-fexcess-precision=16` will force round back after each operation. + +Using :option:`-mavx512fp16` will generate AVX512-FP16 instructions instead of +software emulation. The default behavior of ``FLT_EVAL_METHOD`` is to round +after each operation. The same is true with :option:`-fexcess-precision=standard` +and :option:`-mfpmath=sse`. If there is no :option:`-mfpmath=sse`, +:option:`-fexcess-precision=standard` alone does the same thing as before, +It is useful for code that does not have ``_Float16`` and runs on the x87 +FPU. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/hex-floats.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/hex-floats.rst new file mode 100644 index 00000000000..25cd9645ed0 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/hex-floats.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: hex floats + +.. _hex-floats: + +Hex Floats +********** + +ISO C99 and ISO C++17 support floating-point numbers written not only in +the usual decimal notation, such as ``1.55e1``, but also numbers such as +``0x1.fp3`` written in hexadecimal format. As a GNU extension, GCC +supports this in C90 mode (except in some cases when strictly +conforming) and in C++98, C++11 and C++14 modes. In that format the +:samp:`0x` hex introducer and the :samp:`p` or :samp:`P` exponent field are +mandatory. The exponent is a decimal number that indicates the power of +2 by which the significant part is multiplied. Thus :samp:`0x1.f` is + +1 15/16, +:samp:`p3` multiplies it by 8, and the value of ``0x1.fp3`` +is the same as ``1.55e1``. + +Unlike for floating-point numbers in the decimal notation the exponent +is always required in the hexadecimal notation. Otherwise the compiler +would not be able to resolve the ambiguity of, e.g., ``0x1.f``. This +could mean ``1.0f`` or ``1.9375`` since :samp:`f` is also the +extension for floating-point constants of type ``float``. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/how-to-use-inline-assembly-language-in-c-code.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/how-to-use-inline-assembly-language-in-c-code.rst new file mode 100644 index 00000000000..bee40929305 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/how-to-use-inline-assembly-language-in-c-code.rst @@ -0,0 +1,1979 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: asm keyword, assembly language in C, inline assembly language, mixing assembly language and C + +.. _using-assembly-language-with-c: + +How to Use Inline Assembly Language in C Code +********************************************* + +The ``asm`` keyword allows you to embed assembler instructions +within C code. GCC provides two forms of inline ``asm`` +statements. A basic ``asm`` statement is one with no +operands (see :ref:`basic-asm`), while an extended ``asm`` +statement (see :ref:`extended-asm`) includes one or more operands. +The extended form is preferred for mixing C and assembly language +within a function, but to include assembly language at +top level you must use basic ``asm``. + +You can also use the ``asm`` keyword to override the assembler name +for a C symbol, or to place a C variable in a specific register. + +.. toctree:: + :maxdepth: 2 + + +.. index:: basic asm, assembly language in C, basic + +.. _basic-asm: + +Basic Asm --- Assembler Instructions Without Operands +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A basic ``asm`` statement has the following syntax: + +.. code-block:: + + asm asm-qualifiers ( AssemblerInstructions ) + +For the C language, the ``asm`` keyword is a GNU extension. +When writing C code that can be compiled with :option:`-ansi` and the +:option:`-std` options that select C dialects without GNU extensions, use +``__asm__`` instead of ``asm`` (see :ref:`alternate-keywords`). For +the C++ language, ``asm`` is a standard keyword, but ``__asm__`` +can be used for code compiled with :option:`-fno-asm`. + +Qualifiers +^^^^^^^^^^ + +``volatile`` + The optional ``volatile`` qualifier has no effect. + All basic ``asm`` blocks are implicitly volatile. + +``inline`` + If you use the ``inline`` qualifier, then for inlining purposes the size + of the ``asm`` statement is taken as the smallest size possible (see :ref:`size-of-an-asm`). + +Parameters +^^^^^^^^^^ + +:samp:`{AssemblerInstructions}` + This is a literal string that specifies the assembler code. The string can + contain any instructions recognized by the assembler, including directives. + GCC does not parse the assembler instructions themselves and + does not know what they mean or even whether they are valid assembler input. + + You may place multiple assembler instructions together in a single ``asm`` + string, separated by the characters normally used in assembly code for the + system. A combination that works in most places is a newline to break the + line, plus a tab character (written as :samp:`\\n\\t`). + Some assemblers allow semicolons as a line separator. However, + note that some assembler dialects use semicolons to start a comment. + +Remarks +^^^^^^^ + +Using extended ``asm`` (see :ref:`extended-asm`) typically produces +smaller, safer, and more efficient code, and in most cases it is a +better solution than basic ``asm``. However, there are two +situations where only basic ``asm`` can be used: + +* Extended ``asm`` statements have to be inside a C + function, so to write inline assembly language at file scope ('top-level'), + outside of C functions, you must use basic ``asm``. + You can use this technique to emit assembler directives, + define assembly language macros that can be invoked elsewhere in the file, + or write entire functions in assembly language. + Basic ``asm`` statements outside of functions may not use any + qualifiers. + +* Functions declared + with the :fn-attr:`naked` attribute also require basic ``asm`` + (see :ref:`function-attributes`). + +Safely accessing C data and calling functions from basic ``asm`` is more +complex than it may appear. To access C data, it is better to use extended +``asm``. + +Do not expect a sequence of ``asm`` statements to remain perfectly +consecutive after compilation. If certain instructions need to remain +consecutive in the output, put them in a single multi-instruction ``asm`` +statement. Note that GCC's optimizers can move ``asm`` statements +relative to other code, including across jumps. + +``asm`` statements may not perform jumps into other ``asm`` statements. +GCC does not know about these jumps, and therefore cannot take +account of them when deciding how to optimize. Jumps from ``asm`` to C +labels are only supported in extended ``asm``. + +Under certain circumstances, GCC may duplicate (or remove duplicates of) your +assembly code when optimizing. This can lead to unexpected duplicate +symbol errors during compilation if your assembly code defines symbols or +labels. + +.. warning:: + + The C standards do not specify semantics for ``asm``, + making it a potential source of incompatibilities between compilers. These + incompatibilities may not produce compiler warnings/errors. + +GCC does not parse basic ``asm`` 's :samp:`{AssemblerInstructions}`, which +means there is no way to communicate to the compiler what is happening +inside them. GCC has no visibility of symbols in the ``asm`` and may +discard them as unreferenced. It also does not know about side effects of +the assembler code, such as modifications to memory or registers. Unlike +some compilers, GCC assumes that no changes to general purpose registers +occur. This assumption may change in a future release. + +To avoid complications from future changes to the semantics and the +compatibility issues between compilers, consider replacing basic ``asm`` +with extended ``asm``. See +`How to convert +from basic asm to extended asm `_ for information about how to perform this +conversion. + +The compiler copies the assembler instructions in a basic ``asm`` +verbatim to the assembly language output file, without +processing dialects or any of the :samp:`%` operators that are available with +extended ``asm``. This results in minor differences between basic +``asm`` strings and extended ``asm`` templates. For example, to refer to +registers you might use :samp:`%eax` in basic ``asm`` and +:samp:`%%eax` in extended ``asm``. + +On targets such as x86 that support multiple assembler dialects, +all basic ``asm`` blocks use the assembler dialect specified by the +:option:`-masm` command-line option (see :ref:`x86-options`). +Basic ``asm`` provides no +mechanism to provide different assembler strings for different dialects. + +For basic ``asm`` with non-empty assembler string GCC assumes +the assembler block does not change any general purpose registers, +but it may read or write any globally accessible variable. + +Here is an example of basic ``asm`` for i386: + +.. code-block:: c++ + + /* Note that this code will not compile with -masm=intel */ + #define DebugBreak() asm("int $3") + +.. index:: extended asm, assembly language in C, extended + +.. _extended-asm: + +Extended Asm - Assembler Instructions with C Expression Operands +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +With extended ``asm`` you can read and write C variables from +assembler and perform jumps from assembler code to C labels. +Extended ``asm`` syntax uses colons (:samp:`:`) to delimit +the operand parameters after the assembler template: + +.. code-block:: + + asm asm-qualifiers ( AssemblerTemplate + : OutputOperands + [ : InputOperands + [ : Clobbers ] ]) + + asm asm-qualifiers ( AssemblerTemplate + : OutputOperands + : InputOperands + : Clobbers + : GotoLabels) + +where in the last form, :samp:`{asm-qualifiers}` contains ``goto`` (and in the +first form, not). + +The ``asm`` keyword is a GNU extension. +When writing code that can be compiled with :option:`-ansi` and the +various :option:`-std` options, use ``__asm__`` instead of +``asm`` (see :ref:`alternate-keywords`). + +Qualifiers +^^^^^^^^^^ + +``volatile`` + The typical use of extended ``asm`` statements is to manipulate input + values to produce output values. However, your ``asm`` statements may + also produce side effects. If so, you may need to use the ``volatile`` + qualifier to disable certain optimizations. See :ref:`volatile`. + +``inline`` + If you use the ``inline`` qualifier, then for inlining purposes the size + of the ``asm`` statement is taken as the smallest size possible + (see :ref:`size-of-an-asm`). + +``goto`` + This qualifier informs the compiler that the ``asm`` statement may + perform a jump to one of the labels listed in the :samp:`{GotoLabels}`. + See :ref:`gotolabels`. + +Parameters +^^^^^^^^^^ + +:samp:`{AssemblerTemplate}` + This is a literal string that is the template for the assembler code. It is a + combination of fixed text and tokens that refer to the input, output, + and goto parameters. See :ref:`assemblertemplate`. + +:samp:`{OutputOperands}` + A comma-separated list of the C variables modified by the instructions in the + :samp:`{AssemblerTemplate}`. An empty list is permitted. See :ref:`outputoperands`. + +:samp:`{InputOperands}` + A comma-separated list of C expressions read by the instructions in the + :samp:`{AssemblerTemplate}`. An empty list is permitted. See :ref:`inputoperands`. + +:samp:`{Clobbers}` + A comma-separated list of registers or other values changed by the + :samp:`{AssemblerTemplate}`, beyond those listed as outputs. + An empty list is permitted. See :ref:`clobbers-and-scratch-registers`. + +:samp:`{GotoLabels}` + When you are using the ``goto`` form of ``asm``, this section contains + the list of all C labels to which the code in the + :samp:`{AssemblerTemplate}` may jump. + See :ref:`gotolabels`. + + ``asm`` statements may not perform jumps into other ``asm`` statements, + only to the listed :samp:`{GotoLabels}`. + GCC's optimizers do not know about other jumps; therefore they cannot take + account of them when deciding how to optimize. + + The total number of input + output + goto operands is limited to 30. + +Remarks +^^^^^^^ + +The ``asm`` statement allows you to include assembly instructions directly +within C code. This may help you to maximize performance in time-sensitive +code or to access assembly instructions that are not readily available to C +programs. + +Note that extended ``asm`` statements must be inside a function. Only +basic ``asm`` may be outside functions (see :ref:`basic-asm`). +Functions declared with the :fn-attr:`naked` attribute also require basic +``asm`` (see :ref:`function-attributes`). + +While the uses of ``asm`` are many and varied, it may help to think of an +``asm`` statement as a series of low-level instructions that convert input +parameters to output parameters. So a simple (if not particularly useful) +example for i386 using ``asm`` might look like this: + +.. code-block:: c++ + + int src = 1; + int dst; + + asm ("mov %1, %0\n\t" + "add $1, %0" + : "=r" (dst) + : "r" (src)); + + printf("%d\n", dst); + +This code copies ``src`` to ``dst`` and add 1 to ``dst``. + +.. index:: volatile asm, asm volatile + +.. _volatile: + +Volatile +~~~~~~~~ + +GCC's optimizers sometimes discard ``asm`` statements if they determine +there is no need for the output variables. Also, the optimizers may move +code out of loops if they believe that the code will always return the same +result (i.e. none of its input values change between calls). Using the +``volatile`` qualifier disables these optimizations. ``asm`` statements +that have no output operands and ``asm goto`` statements, +are implicitly volatile. + +This i386 code demonstrates a case that does not use (or require) the +``volatile`` qualifier. If it is performing assertion checking, this code +uses ``asm`` to perform the validation. Otherwise, ``dwRes`` is +unreferenced by any code. As a result, the optimizers can discard the +``asm`` statement, which in turn removes the need for the entire +``DoCheck`` routine. By omitting the ``volatile`` qualifier when it +isn't needed you allow the optimizers to produce the most efficient code +possible. + +.. code-block:: c++ + + void DoCheck(uint32_t dwSomeValue) + { + uint32_t dwRes; + + // Assumes dwSomeValue is not zero. + asm ("bsfl %1,%0" + : "=r" (dwRes) + : "r" (dwSomeValue) + : "cc"); + + assert(dwRes > 3); + } + +The next example shows a case where the optimizers can recognize that the input +(``dwSomeValue``) never changes during the execution of the function and can +therefore move the ``asm`` outside the loop to produce more efficient code. +Again, using the ``volatile`` qualifier disables this type of optimization. + +.. code-block:: c++ + + void do_print(uint32_t dwSomeValue) + { + uint32_t dwRes; + + for (uint32_t x=0; x < 5; x++) + { + // Assumes dwSomeValue is not zero. + asm ("bsfl %1,%0" + : "=r" (dwRes) + : "r" (dwSomeValue) + : "cc"); + + printf("%u: %u %u\n", x, dwSomeValue, dwRes); + } + } + +The following example demonstrates a case where you need to use the +``volatile`` qualifier. +It uses the x86 ``rdtsc`` instruction, which reads +the computer's time-stamp counter. Without the ``volatile`` qualifier, +the optimizers might assume that the ``asm`` block will always return the +same value and therefore optimize away the second call. + +.. code-block:: c++ + + uint64_t msr; + + asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX. + "shl $32, %%rdx\n\t" // Shift the upper bits left. + "or %%rdx, %0" // 'Or' in the lower bits. + : "=a" (msr) + : + : "rdx"); + + printf("msr: %llx\n", msr); + + // Do other work... + + // Reprint the timestamp + asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX. + "shl $32, %%rdx\n\t" // Shift the upper bits left. + "or %%rdx, %0" // 'Or' in the lower bits. + : "=a" (msr) + : + : "rdx"); + + printf("msr: %llx\n", msr); + +GCC's optimizers do not treat this code like the non-volatile code in the +earlier examples. They do not move it out of loops or omit it on the +assumption that the result from a previous call is still valid. + +Note that the compiler can move even ``volatile asm`` instructions relative +to other code, including across jump instructions. For example, on many +targets there is a system register that controls the rounding mode of +floating-point operations. Setting it with a ``volatile asm`` statement, +as in the following PowerPC example, does not work reliably. + +.. code-block:: c++ + + asm volatile("mtfsf 255, %0" : : "f" (fpenv)); + sum = x + y; + +The compiler may move the addition back before the ``volatile asm`` +statement. To make it work as expected, add an artificial dependency to +the ``asm`` by referencing a variable in the subsequent code, for +example: + +.. code-block:: c++ + + asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv)); + sum = x + y; + +Under certain circumstances, GCC may duplicate (or remove duplicates of) your +assembly code when optimizing. This can lead to unexpected duplicate symbol +errors during compilation if your ``asm`` code defines symbols or labels. +Using :samp:`%=` +(see :ref:`assemblertemplate`) may help resolve this problem. + +.. index:: asm assembler template + +.. _assemblertemplate: + +Assembler Template +~~~~~~~~~~~~~~~~~~ + +An assembler template is a literal string containing assembler instructions. +The compiler replaces tokens in the template that refer +to inputs, outputs, and goto labels, +and then outputs the resulting string to the assembler. The +string can contain any instructions recognized by the assembler, including +directives. GCC does not parse the assembler instructions +themselves and does not know what they mean or even whether they are valid +assembler input. However, it does count the statements +(see :ref:`size-of-an-asm`). + +You may place multiple assembler instructions together in a single ``asm`` +string, separated by the characters normally used in assembly code for the +system. A combination that works in most places is a newline to break the +line, plus a tab character to move to the instruction field (written as +:samp:`\\n\\t`). +Some assemblers allow semicolons as a line separator. However, note +that some assembler dialects use semicolons to start a comment. + +Do not expect a sequence of ``asm`` statements to remain perfectly +consecutive after compilation, even when you are using the ``volatile`` +qualifier. If certain instructions need to remain consecutive in the output, +put them in a single multi-instruction ``asm`` statement. + +Accessing data from C programs without using input/output operands (such as +by using global symbols directly from the assembler template) may not work as +expected. Similarly, calling functions directly from an assembler template +requires a detailed understanding of the target assembler and ABI. + +Since GCC does not parse the assembler template, +it has no visibility of any +symbols it references. This may result in GCC discarding those symbols as +unreferenced unless they are also listed as input, output, or goto operands. + +Special format strings +^^^^^^^^^^^^^^^^^^^^^^ + +In addition to the tokens described by the input, output, and goto operands, +these tokens have special meanings in the assembler template: + +:samp:`%%` + Outputs a single :samp:`%` into the assembler code. + +:samp:`%=` + Outputs a number that is unique to each instance of the ``asm`` + statement in the entire compilation. This option is useful when creating local + labels and referring to them multiple times in a single template that + generates multiple assembler instructions. + +:samp:`%{` :samp:`%|` :samp:`%}` + Outputs :samp:`{`, :samp:`|`, and :samp:`}` characters (respectively) + into the assembler code. When unescaped, these characters have special + meaning to indicate multiple assembler dialects, as described below. + +Multiple assembler dialects in asm templates +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +On targets such as x86, GCC supports multiple assembler dialects. +The :option:`-masm` option controls which dialect GCC uses as its +default for inline assembler. The target-specific documentation for the +:option:`-masm` option contains the list of supported dialects, as well as the +default dialect if the option is not specified. This information may be +important to understand, since assembler code that works correctly when +compiled using one dialect will likely fail if compiled using another. +See :ref:`x86-options`. + +If your code needs to support multiple assembler dialects (for example, if +you are writing public headers that need to support a variety of compilation +options), use constructs of this form: + +.. code-block:: c++ + + { dialect0 | dialect1 | dialect2... } + +This construct outputs ``dialect0`` +when using dialect #0 to compile the code, +``dialect1`` for dialect #1, etc. If there are fewer alternatives within the +braces than the number of dialects the compiler supports, the construct +outputs nothing. + +For example, if an x86 compiler supports two dialects +(:samp:`att`, :samp:`intel`), an +assembler template such as this: + +.. code-block:: c++ + + "bt{l %[Offset],%[Base] | %[Base],%[Offset]}; jc %l2" + +is equivalent to one of + +.. code-block:: c++ + + "btl %[Offset],%[Base] ; jc %l2" /* att dialect */ + "bt %[Base],%[Offset]; jc %l2" /* intel dialect */ + +Using that same compiler, this code: + +.. code-block:: c++ + + "xchg{l}\t{%%}ebx, %1" + +corresponds to either + +.. code-block:: c++ + + "xchgl\t%%ebx, %1" /* att dialect */ + "xchg\tebx, %1" /* intel dialect */ + +There is no support for nesting dialect alternatives. + +.. index:: asm output operands + +.. _outputoperands: + +Output Operands +~~~~~~~~~~~~~~~ + +An ``asm`` statement has zero or more output operands indicating the names +of C variables modified by the assembler code. + +In this i386 example, ``old`` (referred to in the template string as +``%0``) and ``*Base`` (as ``%1``) are outputs and ``Offset`` +(``%2``) is an input: + +.. code-block:: c++ + + bool old; + + __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base. + "sbb %0,%0" // Use the CF to calculate old. + : "=r" (old), "+rm" (*Base) + : "Ir" (Offset) + : "cc"); + + return old; + +Operands are separated by commas. Each operand has this format: + +.. code-block:: c++ + + [ [asmSymbolicName] ] constraint (cvariablename) + +:samp:`{asmSymbolicName}` + Specifies a symbolic name for the operand. + Reference the name in the assembler template + by enclosing it in square brackets + (i.e. :samp:`%[Value]`). The scope of the name is the ``asm`` statement + that contains the definition. Any valid C variable name is acceptable, + including names already defined in the surrounding code. No two operands + within the same ``asm`` statement can use the same symbolic name. + + When not using an :samp:`{asmSymbolicName}`, use the (zero-based) position + of the operand + in the list of operands in the assembler template. For example if there are + three output operands, use :samp:`%0` in the template to refer to the first, + :samp:`%1` for the second, and :samp:`%2` for the third. + +:samp:`{constraint}` + A string constant specifying constraints on the placement of the operand; + See :ref:`constraints`, for details. + + Output constraints must begin with either :samp:`=` (a variable overwriting an + existing value) or :samp:`+` (when reading and writing). When using + :samp:`=`, do not assume the location contains the existing value + on entry to the ``asm``, except + when the operand is tied to an input; see :ref:`inputoperands`. + + After the prefix, there must be one or more additional constraints + (see :ref:`constraints`) that describe where the value resides. Common + constraints include :samp:`r` for register and :samp:`m` for memory. + When you list more than one possible location (for example, ``"=rm"``), + the compiler chooses the most efficient one based on the current context. + If you list as many alternates as the ``asm`` statement allows, you permit + the optimizers to produce the best possible code. + If you must use a specific register, but your Machine Constraints do not + provide sufficient control to select the specific register you want, + local register variables may provide a solution (see :ref:`local-register-variables`). + +:samp:`{cvariablename}` + Specifies a C lvalue expression to hold the output, typically a variable name. + The enclosing parentheses are a required part of the syntax. + +When the compiler selects the registers to use to +represent the output operands, it does not use any of the clobbered registers +(see :ref:`clobbers-and-scratch-registers`). + +Output operand expressions must be lvalues. The compiler cannot check whether +the operands have data types that are reasonable for the instruction being +executed. For output expressions that are not directly addressable (for +example a bit-field), the constraint must allow a register. In that case, GCC +uses the register as the output of the ``asm``, and then stores that +register into the output. + +Operands using the :samp:`+` constraint modifier count as two operands +(that is, both as input and output) towards the total maximum of 30 operands +per ``asm`` statement. + +Use the :samp:`&` constraint modifier (see :ref:`modifiers`) on all output +operands that must not overlap an input. Otherwise, +GCC may allocate the output operand in the same register as an unrelated +input operand, on the assumption that the assembler code consumes its +inputs before producing outputs. This assumption may be false if the assembler +code actually consists of more than one instruction. + +The same problem can occur if one output parameter (:samp:`{a}`) allows a register +constraint and another output parameter (:samp:`{b}`) allows a memory constraint. +The code generated by GCC to access the memory address in :samp:`{b}` can contain +registers which *might* be shared by :samp:`{a}`, and GCC considers those +registers to be inputs to the asm. As above, GCC assumes that such input +registers are consumed before any outputs are written. This assumption may +result in incorrect behavior if the ``asm`` statement writes to :samp:`{a}` +before using +:samp:`{b}`. Combining the :samp:`&` modifier with the register constraint on :samp:`{a}` +ensures that modifying :samp:`{a}` does not affect the address referenced by +:samp:`{b}`. Otherwise, the location of :samp:`{b}` +is undefined if :samp:`{a}` is modified before using :samp:`{b}`. + +``asm`` supports operand modifiers on operands (for example :samp:`%k2` +instead of simply :samp:`%2`). Typically these qualifiers are hardware +dependent. The list of supported modifiers for x86 is found at :ref:`x86operandmodifiers`. + +If the C code that follows the ``asm`` makes no use of any of the output +operands, use ``volatile`` for the ``asm`` statement to prevent the +optimizers from discarding the ``asm`` statement as unneeded +(see :ref:`volatile`). + +This code makes no use of the optional :samp:`{asmSymbolicName}`. Therefore it +references the first output operand as ``%0`` (were there a second, it +would be ``%1``, etc). The number of the first input operand is one greater +than that of the last output operand. In this i386 example, that makes +``Mask`` referenced as ``%1`` : + +.. code-block:: c++ + + uint32_t Mask = 1234; + uint32_t Index; + + asm ("bsfl %1, %0" + : "=r" (Index) + : "r" (Mask) + : "cc"); + +That code overwrites the variable ``Index`` (:samp:`=`), +placing the value in a register (:samp:`r`). +Using the generic :samp:`r` constraint instead of a constraint for a specific +register allows the compiler to pick the register to use, which can result +in more efficient code. This may not be possible if an assembler instruction +requires a specific register. + +The following i386 example uses the :samp:`{asmSymbolicName}` syntax. +It produces the +same result as the code above, but some may consider it more readable or more +maintainable since reordering index numbers is not necessary when adding or +removing operands. The names ``aIndex`` and ``aMask`` +are only used in this example to emphasize which +names get used where. +It is acceptable to reuse the names ``Index`` and ``Mask``. + +.. code-block:: c++ + + uint32_t Mask = 1234; + uint32_t Index; + + asm ("bsfl %[aMask], %[aIndex]" + : [aIndex] "=r" (Index) + : [aMask] "r" (Mask) + : "cc"); + +Here are some more examples of output operands. + +.. code-block:: c++ + + uint32_t c = 1; + uint32_t d; + uint32_t *e = &c; + + asm ("mov %[e], %[d]" + : [d] "=rm" (d) + : [e] "rm" (*e)); + +Here, ``d`` may either be in a register or in memory. Since the compiler +might already have the current value of the ``uint32_t`` location +pointed to by ``e`` +in a register, you can enable it to choose the best location +for ``d`` by specifying both constraints. + +.. index:: asm flag output operands + +.. _flagoutputoperands: + +Flag Output Operands +~~~~~~~~~~~~~~~~~~~~ + +Some targets have a special register that holds the 'flags' for the +result of an operation or comparison. Normally, the contents of that +register are either unmodifed by the asm, or the ``asm`` statement is +considered to clobber the contents. + +On some targets, a special form of output operand exists by which +conditions in the flags register may be outputs of the asm. The set of +conditions supported are target specific, but the general rule is that +the output variable must be a scalar integer, and the value is boolean. +When supported, the target defines the preprocessor symbol +``__GCC_ASM_FLAG_OUTPUTS__``. + +Because of the special nature of the flag output operands, the constraint +may not include alternatives. + +Most often, the target has only one flags register, and thus is an implied +operand of many instructions. In this case, the operand should not be +referenced within the assembler template via ``%0`` etc, as there's +no corresponding text in the assembly language. + +ARM AArch64 + The flag output constraints for the ARM family are of the form + :samp:`=@cc{cond}` where :samp:`{cond}` is one of the standard + conditions defined in the ARM ARM for ``ConditionHolds``. + + ``eq`` + Z flag set, or equal + + ``ne`` + Z flag clear or not equal + + ``cs`` ``hs`` + C flag set or unsigned greater than equal + + ``cc`` ``lo`` + C flag clear or unsigned less than + + ``mi`` + N flag set or 'minus' + + ``pl`` + N flag clear or 'plus' + + ``vs`` + V flag set or signed overflow + + ``vc`` + V flag clear + + ``hi`` + unsigned greater than + + ``ls`` + unsigned less than equal + + ``ge`` + signed greater than equal + + ``lt`` + signed less than + + ``gt`` + signed greater than + + ``le`` + signed less than equal + + The flag output constraints are not supported in thumb1 mode. + +x86 family + The flag output constraints for the x86 family are of the form + :samp:`=@cc{cond}` where :samp:`{cond}` is one of the standard + conditions defined in the ISA manual for ``jcc`` or + ``setcc``. + + ``a`` + 'above' or unsigned greater than + + ``ae`` + 'above or equal' or unsigned greater than or equal + + ``b`` + 'below' or unsigned less than + + ``be`` + 'below or equal' or unsigned less than or equal + + ``c`` + carry flag set + + ``e`` ``z`` + 'equal' or zero flag set + + ``g`` + signed greater than + + ``ge`` + signed greater than or equal + + ``l`` + signed less than + + ``le`` + signed less than or equal + + ``o`` + overflow flag set + + ``p`` + parity flag set + + ``s`` + sign flag set + + ``na`` ``nae`` ``nb`` ``nbe`` ``nc`` ``ne`` ``ng`` ``nge`` ``nl`` ``nle`` ``no`` ``np`` ``ns`` ``nz`` + 'not' :samp:`{flag}`, or inverted versions of those above + +.. index:: asm input operands, asm expressions + +.. _inputoperands: + +Input Operands +~~~~~~~~~~~~~~ + +Input operands make values from C variables and expressions available to the +assembly code. + +Operands are separated by commas. Each operand has this format: + +.. code-block:: c++ + + [ [asmSymbolicName] ] constraint (cexpression) + +:samp:`{asmSymbolicName}` + Specifies a symbolic name for the operand. + Reference the name in the assembler template + by enclosing it in square brackets + (i.e. :samp:`%[Value]`). The scope of the name is the ``asm`` statement + that contains the definition. Any valid C variable name is acceptable, + including names already defined in the surrounding code. No two operands + within the same ``asm`` statement can use the same symbolic name. + + When not using an :samp:`{asmSymbolicName}`, use the (zero-based) position + of the operand + in the list of operands in the assembler template. For example if there are + two output operands and three inputs, + use :samp:`%2` in the template to refer to the first input operand, + :samp:`%3` for the second, and :samp:`%4` for the third. + +:samp:`{constraint}` + A string constant specifying constraints on the placement of the operand; + See :ref:`constraints`, for details. + + Input constraint strings may not begin with either :samp:`=` or :samp:`+`. + When you list more than one possible location (for example, :samp:`"irm"`), + the compiler chooses the most efficient one based on the current context. + If you must use a specific register, but your Machine Constraints do not + provide sufficient control to select the specific register you want, + local register variables may provide a solution (see :ref:`local-register-variables`). + + Input constraints can also be digits (for example, ``"0"``). This indicates + that the specified input must be in the same place as the output constraint + at the (zero-based) index in the output constraint list. + When using :samp:`{asmSymbolicName}` syntax for the output operands, + you may use these names (enclosed in brackets :samp:`[]`) instead of digits. + +:samp:`{cexpression}` + This is the C variable or expression being passed to the ``asm`` statement + as input. The enclosing parentheses are a required part of the syntax. + +When the compiler selects the registers to use to represent the input +operands, it does not use any of the clobbered registers +(see :ref:`clobbers-and-scratch-registers`). + +If there are no output operands but there are input operands, place two +consecutive colons where the output operands would go: + +.. code-block:: c++ + + __asm__ ("some instructions" + : /* No outputs. */ + : "r" (Offset / 8)); + +.. warning:: + + Do *not* modify the contents of input-only operands + (except for inputs tied to outputs). The compiler assumes that on exit from + the ``asm`` statement these operands contain the same values as they + had before executing the statement. + +It is *not* possible to use clobbers +to inform the compiler that the values in these inputs are changing. One +common work-around is to tie the changing input variable to an output variable +that never gets used. Note, however, that if the code that follows the +``asm`` statement makes no use of any of the output operands, the GCC +optimizers may discard the ``asm`` statement as unneeded +(see :ref:`volatile`). + +``asm`` supports operand modifiers on operands (for example :samp:`%k2` +instead of simply :samp:`%2`). Typically these qualifiers are hardware +dependent. The list of supported modifiers for x86 is found at +:ref:`x86operandmodifiers`. + +In this example using the fictitious ``combine`` instruction, the +constraint ``"0"`` for input operand 1 says that it must occupy the same +location as output operand 0. Only input operands may use numbers in +constraints, and they must each refer to an output operand. Only a number (or +the symbolic assembler name) in the constraint can guarantee that one operand +is in the same place as another. The mere fact that ``foo`` is the value of +both operands is not enough to guarantee that they are in the same place in +the generated assembler code. + +.. code-block:: c++ + + asm ("combine %2, %0" + : "=r" (foo) + : "0" (foo), "g" (bar)); + +Here is an example using symbolic names. + +.. code-block:: c++ + + asm ("cmoveq %1, %2, %[result]" + : [result] "=r"(result) + : "r" (test), "r" (new), "[result]" (old)); + +.. index:: asm clobbers, asm scratch registers + +.. _clobbers-and-scratch-registers: + +Clobbers and Scratch Registers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +While the compiler is aware of changes to entries listed in the output +operands, the inline ``asm`` code may modify more than just the outputs. For +example, calculations may require additional registers, or the processor may +overwrite a register as a side effect of a particular assembler instruction. +In order to inform the compiler of these changes, list them in the clobber +list. Clobber list items are either register names or the special clobbers +(listed below). Each clobber list item is a string constant +enclosed in double quotes and separated by commas. + +Clobber descriptions may not in any way overlap with an input or output +operand. For example, you may not have an operand describing a register class +with one member when listing that register in the clobber list. Variables +declared to live in specific registers (see :ref:`explicit-register-variables`) and used +as ``asm`` input or output operands must have no part mentioned in the +clobber description. In particular, there is no way to specify that input +operands get modified without also specifying them as output operands. + +When the compiler selects which registers to use to represent input and output +operands, it does not use any of the clobbered registers. As a result, +clobbered registers are available for any use in the assembler code. + +Another restriction is that the clobber list should not contain the +stack pointer register. This is because the compiler requires the +value of the stack pointer to be the same after an ``asm`` +statement as it was on entry to the statement. However, previous +versions of GCC did not enforce this rule and allowed the stack +pointer to appear in the list, with unclear semantics. This behavior +is deprecated and listing the stack pointer may become an error in +future versions of GCC. + +Here is a realistic example for the VAX showing the use of clobbered +registers: + +.. code-block:: c++ + + asm volatile ("movc3 %0, %1, %2" + : /* No outputs. */ + : "g" (from), "g" (to), "g" (count) + : "r0", "r1", "r2", "r3", "r4", "r5", "memory"); + +Also, there are two special clobber arguments: + +``"cc"`` + The ``"cc"`` clobber indicates that the assembler code modifies the flags + register. On some machines, GCC represents the condition codes as a specific + hardware register; ``"cc"`` serves to name this register. + On other machines, condition code handling is different, + and specifying ``"cc"`` has no effect. But + it is valid no matter what the target. + +``"memory"`` + The ``"memory"`` clobber tells the compiler that the assembly code + performs memory + reads or writes to items other than those listed in the input and output + operands (for example, accessing the memory pointed to by one of the input + parameters). To ensure memory contains correct values, GCC may need to flush + specific register values to memory before executing the ``asm``. Further, + the compiler does not assume that any values read from memory before an + ``asm`` remain unchanged after that ``asm`` ; it reloads them as + needed. + Using the ``"memory"`` clobber effectively forms a read/write + memory barrier for the compiler. + + Note that this clobber does not prevent the *processor* from doing + speculative reads past the ``asm`` statement. To prevent that, you need + processor-specific fence instructions. + +Flushing registers to memory has performance implications and may be +an issue for time-sensitive code. You can provide better information +to GCC to avoid this, as shown in the following examples. At a +minimum, aliasing rules allow GCC to know what memory *doesn't* +need to be flushed. + +Here is a fictitious sum of squares instruction, that takes two +pointers to floating point values in memory and produces a floating +point register output. +Notice that ``x``, and ``y`` both appear twice in the ``asm`` +parameters, once to specify memory accessed, and once to specify a +base register used by the ``asm``. You won't normally be wasting a +register by doing this as GCC can use the same register for both +purposes. However, it would be foolish to use both ``%1`` and +``%3`` for ``x`` in this ``asm`` and expect them to be the +same. In fact, ``%3`` may well not be a register. It might be a +symbolic memory reference to the object pointed to by ``x``. + +.. code-block:: c++ + + asm ("sumsq %0, %1, %2" + : "+f" (result) + : "r" (x), "r" (y), "m" (*x), "m" (*y)); + +Here is a fictitious ``*z++ = *x++ * *y++`` instruction. +Notice that the ``x``, ``y`` and ``z`` pointer registers +must be specified as input/output because the ``asm`` modifies +them. + +.. code-block:: c++ + + asm ("vecmul %0, %1, %2" + : "+r" (z), "+r" (x), "+r" (y), "=m" (*z) + : "m" (*x), "m" (*y)); + +An x86 example where the string memory argument is of unknown length. + +.. code-block:: c++ + + asm("repne scasb" + : "=c" (count), "+D" (p) + : "m" (*(const char (*)[]) p), "0" (-1), "a" (0)); + +If you know the above will only be reading a ten byte array then you +could instead use a memory input like: +``"m" (*(const char (*)[10]) p)``. + +Here is an example of a PowerPC vector scale implemented in assembly, +complete with vector and condition code clobbers, and some initialized +offset registers that are unchanged by the ``asm``. + +.. code-block:: c++ + + void + dscal (size_t n, double *x, double alpha) + { + asm ("/* lots of asm here */" + : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x) + : "d" (alpha), "b" (32), "b" (48), "b" (64), + "b" (80), "b" (96), "b" (112) + : "cr0", + "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39", + "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"); + } + +Rather than allocating fixed registers via clobbers to provide scratch +registers for an ``asm`` statement, an alternative is to define a +variable and make it an early-clobber output as with ``a2`` and +``a3`` in the example below. This gives the compiler register +allocator more freedom. You can also define a variable and make it an +output tied to an input as with ``a0`` and ``a1``, tied +respectively to ``ap`` and ``lda``. Of course, with tied +outputs your ``asm`` can't use the input value after modifying the +output register since they are one and the same register. What's +more, if you omit the early-clobber on the output, it is possible that +GCC might allocate the same register to another of the inputs if GCC +could prove they had the same value on entry to the ``asm``. This +is why ``a1`` has an early-clobber. Its tied input, ``lda`` +might conceivably be known to have the value 16 and without an +early-clobber share the same register as ``%11``. On the other +hand, ``ap`` can't be the same as any of the other inputs, so an +early-clobber on ``a0`` is not needed. It is also not desirable in +this case. An early-clobber on ``a0`` would cause GCC to allocate +a separate register for the ``"m" (*(const double (*)[]) ap)`` +input. Note that tying an input to an output is the way to set up an +initialized temporary register modified by an ``asm`` statement. +An input not tied to an output is assumed by GCC to be unchanged, for +example ``"b" (16)`` below sets up ``%11`` to 16, and GCC might +use that register in following code if the value 16 happened to be +needed. You can even use a normal ``asm`` output for a scratch if +all inputs that might share the same register are consumed before the +scratch is used. The VSX registers clobbered by the ``asm`` +statement could have used this technique except for GCC's limit on the +number of ``asm`` parameters. + +.. code-block:: c++ + + static void + dgemv_kernel_4x4 (long n, const double *ap, long lda, + const double *x, double *y, double alpha) + { + double *a0; + double *a1; + double *a2; + double *a3; + + __asm__ + ( + /* lots of asm here */ + "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n" + "#a0=%3 a1=%4 a2=%5 a3=%6" + : + "+m" (*(double (*)[n]) y), + "+&r" (n), // 1 + "+b" (y), // 2 + "=b" (a0), // 3 + "=&b" (a1), // 4 + "=&b" (a2), // 5 + "=&b" (a3) // 6 + : + "m" (*(const double (*)[n]) x), + "m" (*(const double (*)[]) ap), + "d" (alpha), // 9 + "r" (x), // 10 + "b" (16), // 11 + "3" (ap), // 12 + "4" (lda) // 13 + : + "cr0", + "vs32","vs33","vs34","vs35","vs36","vs37", + "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47" + ); + } + +.. index:: asm goto labels + +.. _gotolabels: + +Goto Labels +~~~~~~~~~~~ + +``asm goto`` allows assembly code to jump to one or more C labels. The +:samp:`{GotoLabels}` section in an ``asm goto`` statement contains +a comma-separated +list of all C labels to which the assembler code may jump. GCC assumes that +``asm`` execution falls through to the next statement (if this is not the +case, consider using the ``__builtin_unreachable`` intrinsic after the +``asm`` statement). Optimization of ``asm goto`` may be improved by +using the :fn-attr:`hot` and :fn-attr:`cold` label attributes (see :ref:`label-attributes`). + +If the assembler code does modify anything, use the ``"memory"`` clobber +to force the +optimizers to flush all register values to memory and reload them if +necessary after the ``asm`` statement. + +Also note that an ``asm goto`` statement is always implicitly +considered volatile. + +Be careful when you set output operands inside ``asm goto`` only on +some possible control flow paths. If you don't set up the output on +given path and never use it on this path, it is okay. Otherwise, you +should use :samp:`+` constraint modifier meaning that the operand is +input and output one. With this modifier you will have the correct +values on all possible paths from the ``asm goto``. + +To reference a label in the assembler template, prefix it with +:samp:`%l` (lowercase :samp:`L`) followed by its (zero-based) position +in :samp:`{GotoLabels}` plus the number of input and output operands. +Output operand with constraint modifier :samp:`+` is counted as two +operands because it is considered as one output and one input operand. +For example, if the ``asm`` has three inputs, one output operand +with constraint modifier :samp:`+` and one output operand with +constraint modifier :samp:`=` and references two labels, refer to the +first label as :samp:`%l6` and the second as :samp:`%l7`). + +Alternately, you can reference labels using the actual C label name +enclosed in brackets. For example, to reference a label named +``carry``, you can use :samp:`%l[carry]`. The label must still be +listed in the :samp:`{GotoLabels}` section when using this approach. It +is better to use the named references for labels as in this case you +can avoid counting input and output operands and special treatment of +output operands with constraint modifier :samp:`+`. + +Here is an example of ``asm goto`` for i386: + +.. code-block:: c++ + + asm goto ( + "btl %1, %0\n\t" + "jc %l2" + : /* No outputs. */ + : "r" (p1), "r" (p2) + : "cc" + : carry); + + return 0; + + carry: + return 1; + +The following example shows an ``asm goto`` that uses a memory clobber. + +.. code-block:: c++ + + int frob(int x) + { + int y; + asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5" + : /* No outputs. */ + : "r"(x), "r"(&y) + : "r5", "memory" + : error); + return y; + error: + return -1; + } + +The following example shows an ``asm goto`` that uses an output. + +.. code-block:: c++ + + int foo(int count) + { + asm goto ("dec %0; jb %l[stop]" + : "+r" (count) + : + : + : stop); + return count; + stop: + return 0; + } + +The following artificial example shows an ``asm goto`` that sets +up an output only on one path inside the ``asm goto``. Usage of +constraint modifier ``=`` instead of ``+`` would be wrong as +``factor`` is used on all paths from the ``asm goto``. + +.. code-block:: c++ + + int foo(int inp) + { + int factor = 0; + asm goto ("cmp %1, 10; jb %l[lab]; mov 2, %0" + : "+r" (factor) + : "r" (inp) + : + : lab); + lab: + return inp * factor; /* return 2 * inp or 0 if inp < 10 */ + } + +.. _x86operandmodifiers: + +x86 Operand Modifiers +~~~~~~~~~~~~~~~~~~~~~ + +References to input, output, and goto operands in the assembler template +of extended ``asm`` statements can use +modifiers to affect the way the operands are formatted in +the code output to the assembler. For example, the +following code uses the :samp:`h` and :samp:`b` modifiers for x86: + +.. code-block:: c++ + + uint16_t num; + asm volatile ("xchg %h0, %b0" : "+a" (num) ); + +These modifiers generate this assembler code: + +.. code-block:: c++ + + xchg %ah, %al + +The rest of this discussion uses the following code for illustrative purposes. + +.. code-block:: c++ + + int main() + { + int iInt = 1; + + top: + + asm volatile goto ("some assembler instructions here" + : /* No outputs. */ + : "q" (iInt), "X" (sizeof(unsigned char) + 1), "i" (42) + : /* No clobbers. */ + : top); + } + +With no modifiers, this is what the output from the operands would be +for the :samp:`att` and :samp:`intel` dialects of assembler: + +.. list-table:: + :header-rows: 1 + + * - Operand + - :samp:`att` + - :samp:`intel` + + * - ``%0`` + - ``%eax`` + - ``eax`` + * - ``%1`` + - ``$2`` + - ``2`` + * - ``%3`` + - ``$.L3`` + - ``OFFSET FLAT:.L3`` + * - ``%4`` + - ``$8`` + - ``8`` + * - ``%5`` + - ``%xmm0`` + - ``xmm0`` + * - ``%7`` + - ``$0`` + - ``0`` + +The table below shows the list of supported modifiers and their effects. + +.. list-table:: + :header-rows: 1 + :widths: 10 50 10 10 10 + + * - Modifier + - Description + - Operand + - :samp:`att` + - :samp:`intel` + + * - ``A`` + - Print an absolute memory reference. + - ``%A0`` + - ``*%rax`` + - ``rax`` + * - ``b`` + - Print the QImode name of the register. + - ``%b0`` + - ``%al`` + - ``al`` + * - ``B`` + - print the opcode suffix of b. + - ``%B0`` + - ``b`` + - + * - ``c`` + - Require a constant operand and print the constant expression with no punctuation. + - ``%c1`` + - ``2`` + - ``2`` + * - ``d`` + - print duplicated register operand for AVX instruction. + - ``%d5`` + - ``%xmm0, %xmm0`` + - ``xmm0, xmm0`` + * - ``E`` + - Print the address in Double Integer (DImode) mode (8 bytes) when the target is 64-bit. Otherwise mode is unspecified (VOIDmode). + - ``%E1`` + - ``%(rax)`` + - ``[rax]`` + * - ``g`` + - Print the V16SFmode name of the register. + - ``%g0`` + - ``%zmm0`` + - ``zmm0`` + * - ``h`` + - Print the QImode name for a 'high' register. + - ``%h0`` + - ``%ah`` + - ``ah`` + * - ``H`` + - Add 8 bytes to an offsettable memory reference. Useful when accessing the high 8 bytes of SSE values. For a memref in (%rax), it generates + - ``%H0`` + - ``8(%rax)`` + - ``8[rax]`` + * - ``k`` + - Print the SImode name of the register. + - ``%k0`` + - ``%eax`` + - ``eax`` + * - ``l`` + - Print the label name with no punctuation. + - ``%l3`` + - ``.L3`` + - ``.L3`` + * - ``L`` + - print the opcode suffix of l. + - ``%L0`` + - ``l`` + - + * - ``N`` + - print maskz. + - ``%N7`` + - ``{z}`` + - ``{z}`` + * - ``p`` + - Print raw symbol name (without syntax-specific prefixes). + - ``%p2`` + - ``42`` + - ``42`` + * - ``P`` + - If used for a function, print the PLT suffix and generate PIC code. For example, emit ``foo@PLT`` instead of 'foo' for the function foo(). If used for a constant, drop all syntax-specific prefixes and issue the bare constant. See ``p`` above. + - + - + - + * - ``q`` + - Print the DImode name of the register. + - ``%q0`` + - ``%rax`` + - ``rax`` + * - ``Q`` + - print the opcode suffix of q. + - ``%Q0`` + - ``q`` + - + * - ``R`` + - print embedded rounding and sae. + - ``%R4`` + - ``{rn-sae},`` + - ``, {rn-sae}`` + * - ``r`` + - print only sae. + - ``%r4`` + - ``{sae},`` + - ``, {sae}`` + * - ``s`` + - print a shift double count, followed by the assemblers argument delimiterprint the opcode suffix of s. + - ``%s1`` + - ``$2,`` + - ``2,`` + * - ``S`` + - print the opcode suffix of s. + - ``%S0`` + - ``s`` + - + * - ``t`` + - print the V8SFmode name of the register. + - ``%t5`` + - ``%ymm0`` + - ``ymm0`` + * - ``T`` + - print the opcode suffix of t. + - ``%T0`` + - ``t`` + - + * - ``V`` + - print naked full integer register name without %. + - ``%V0`` + - ``eax`` + - ``eax`` + * - ``w`` + - Print the HImode name of the register. + - ``%w0`` + - ``%ax`` + - ``ax`` + * - ``W`` + - print the opcode suffix of w. + - ``%W0`` + - ``w`` + - + * - ``x`` + - print the V4SFmode name of the register. + - ``%x5`` + - ``%xmm0`` + - ``xmm0`` + * - ``y`` + - print "st(0)" instead of "st" as a register. + - ``%y6`` + - ``%st(0)`` + - ``st(0)`` + * - ``z`` + - Print the opcode suffix for the size of the current integer operand (one of ``b`` / ``w`` / ``l`` / ``q``). + - ``%z0`` + - ``l`` + - + * - ``Z`` + - Like ``z``, with special suffixes for x87 instructions. + - + - + - + +.. _x86floatingpointasmoperands: + +x86 Floating-Point asm Operands +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +On x86 targets, there are several rules on the usage of stack-like registers +in the operands of an ``asm``. These rules apply only to the operands +that are stack-like registers: + +* Given a set of input registers that die in an ``asm``, it is + necessary to know which are implicitly popped by the ``asm``, and + which must be explicitly popped by GCC. + + An input register that is implicitly popped by the ``asm`` must be + explicitly clobbered, unless it is constrained to match an + output operand. + +* For any input register that is implicitly popped by an ``asm``, it is + necessary to know how to adjust the stack to compensate for the pop. + If any non-popped input is closer to the top of the reg-stack than + the implicitly popped register, it would not be possible to know what the + stack looked like---it's not clear how the rest of the stack 'slides + up'. + + All implicitly popped input registers must be closer to the top of + the reg-stack than any input that is not implicitly popped. + + It is possible that if an input dies in an ``asm``, the compiler might + use the input register for an output reload. Consider this example: + + .. code-block:: c++ + + asm ("foo" : "=t" (a) : "f" (b)); + + This code says that input ``b`` is not popped by the ``asm``, and that + the ``asm`` pushes a result onto the reg-stack, i.e., the stack is one + deeper after the ``asm`` than it was before. But, it is possible that + reload may think that it can use the same register for both the input and + the output. + + To prevent this from happening, + if any input operand uses the :samp:`f` constraint, all output register + constraints must use the :samp:`&` early-clobber modifier. + + The example above is correctly written as: + + .. code-block:: c++ + + asm ("foo" : "=&t" (a) : "f" (b)); + +* Some operands need to be in particular places on the stack. All + output operands fall in this category---GCC has no other way to + know which registers the outputs appear in unless you indicate + this in the constraints. + + Output operands must specifically indicate which register an output + appears in after an ``asm``. :samp:`=f` is not allowed: the operand + constraints must select a class with a single register. + +* Output operands may not be 'inserted' between existing stack registers. + Since no 387 opcode uses a read/write operand, all output operands + are dead before the ``asm``, and are pushed by the ``asm``. + It makes no sense to push anywhere but the top of the reg-stack. + + Output operands must start at the top of the reg-stack: output + operands may not 'skip' a register. + +* Some ``asm`` statements may need extra stack space for internal + calculations. This can be guaranteed by clobbering stack registers + unrelated to the inputs and outputs. + +This ``asm`` +takes one input, which is internally popped, and produces two outputs. + +.. code-block:: c++ + + asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp)); + +This ``asm`` takes two inputs, which are popped by the ``fyl2xp1`` opcode, +and replaces them with one output. The ``st(1)`` clobber is necessary +for the compiler to know that ``fyl2xp1`` pops both inputs. + +.. code-block:: c++ + + asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)"); + +.. _msp430operandmodifiers: + +MSP430 Operand Modifiers +~~~~~~~~~~~~~~~~~~~~~~~~ + +The list below describes the supported modifiers and their effects for MSP430. + +.. list-table:: + :header-rows: 1 + :widths: 10 90 + + * - Modifier + - Description + + * - ``A`` + - Select low 16-bits of the constant/register/memory operand. + * - ``B`` + - Select high 16-bits of the constant/register/memory operand. + * - ``C`` + - Select bits 32-47 of the constant/register/memory operand. + * - ``D`` + - Select bits 48-63 of the constant/register/memory operand. + * - ``H`` + - Equivalent to ``B`` (for backwards compatibility). + * - ``I`` + - Print the inverse (logical ``NOT``) of the constant value. + * - ``J`` + - Print an integer without a ``#`` prefix. + * - ``L`` + - Equivalent to ``A`` (for backwards compatibility). + * - ``O`` + - Offset of the current frame from the top of the stack. + * - ``Q`` + - Use the ``A`` instruction postfix. + * - ``R`` + - Inverse of condition code, for unsigned comparisons. + * - ``W`` + - Subtract 16 from the constant value. + * - ``X`` + - Use the ``X`` instruction postfix. + * - ``Y`` + - Subtract 4 from the constant value. + * - ``Z`` + - Subtract 1 from the constant value. + * - ``b`` + - Append ``.B``, ``.W`` or ``.A`` to the instruction, depending on the mode. + * - ``d`` + - Offset 1 byte of a memory reference or constant value. + * - ``e`` + - Offset 3 bytes of a memory reference or constant value. + * - ``f`` + - Offset 5 bytes of a memory reference or constant value. + * - ``g`` + - Offset 7 bytes of a memory reference or constant value. + * - ``p`` + - Print the value of 2, raised to the power of the given constant. Used to select the specified bit position. + * - ``r`` + - Inverse of condition code, for signed comparisons. + * - ``x`` + - Equivialent to ``X``, but only for pointers. + +.. Most of this node appears by itself (in a different place) even + when the INTERNALS flag is clear. Passages that require the internals + manual's context are conditionalized to appear only in the internals manual. + +.. index:: operand constraints, asm, constraints, asm, asm constraints + +.. _constraints: + +Constraints for asm Operands +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Here are specific details on what constraint letters you can use with +``asm`` operands. +Constraints can say whether +an operand may be in a register, and which kinds of register; whether the +operand can be a memory reference, and which kinds of address; whether the +operand may be an immediate constant, and which possible values it may +have. Constraints can also require two operands to match. +Side-effects aren't allowed in operands of inline ``asm``, unless +:samp:`<` or :samp:`>` constraints are used, because there is no guarantee +that the side effects will happen exactly once in an instruction that can update +the addressing register. + +.. toctree:: + :maxdepth: 2 + + +.. include:: ../../../../doc/md.rst + + +.. Each of the following nodes are wrapped in separate + "@ifset INTERNALS" to work around memory limits for the default + configuration in older tetex distributions. Known to not work: + tetex-1.0.7, known to work: tetex-2.0.2. + +.. index:: assembler names for identifiers, names used in assembler code, identifiers, names in assembler code + +.. _asm-labels: + +Controlling Names Used in Assembler Code +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You can specify the name to be used in the assembler code for a C +function or variable by writing the ``asm`` (or ``__asm__``) +keyword after the declarator. +It is up to you to make sure that the assembler names you choose do not +conflict with any other assembler symbols, or reference registers. + +Assembler names for data +^^^^^^^^^^^^^^^^^^^^^^^^ + +This sample shows how to specify the assembler name for data: + +.. code-block:: c++ + + int foo asm ("myfoo") = 2; + +This specifies that the name to be used for the variable ``foo`` in +the assembler code should be :samp:`myfoo` rather than the usual +:samp:`_foo`. + +On systems where an underscore is normally prepended to the name of a C +variable, this feature allows you to define names for the +linker that do not start with an underscore. + +GCC does not support using this feature with a non-static local variable +since such variables do not have assembler names. If you are +trying to put the variable in a particular register, see +:ref:`explicit-register-variables`. + +Assembler names for functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To specify the assembler name for functions, write a declaration for the +function before its definition and put ``asm`` there, like this: + +.. code-block:: c++ + + int func (int x, int y) asm ("MYFUNC"); + + int func (int x, int y) + { + /* ... */ + +This specifies that the name to be used for the function ``func`` in +the assembler code should be ``MYFUNC``. + +.. _explicit-register-variables: + +Variables in Specified Registers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. index:: explicit register variables, variables in specified registers, specified registers + +.. _explicit-reg-vars: + +GNU C allows you to associate specific hardware registers with C +variables. In almost all cases, allowing the compiler to assign +registers produces the best code. However under certain unusual +circumstances, more precise control over the variable storage is +required. + +Both global and local variables can be associated with a register. The +consequences of performing this association are very different between +the two, as explained in the sections below. + +.. toctree:: + :maxdepth: 2 + + +.. _global-register-variables: + +Defining Global Register Variables +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. index:: global register variables, registers, global variables in, registers, global allocation + +.. _global-reg-vars: + +You can define a global register variable and associate it with a specified +register like this: + +.. code-block:: c++ + + register int *foo asm ("r12"); + +Here ``r12`` is the name of the register that should be used. Note that +this is the same syntax used for defining local register variables, but for +a global variable the declaration appears outside a function. The +``register`` keyword is required, and cannot be combined with +``static``. The register name must be a valid register name for the +target platform. + +Do not use type qualifiers such as ``const`` and ``volatile``, as +the outcome may be contrary to expectations. In particular, using the +``volatile`` qualifier does not fully prevent the compiler from +optimizing accesses to the register. + +Registers are a scarce resource on most systems and allowing the +compiler to manage their usage usually results in the best code. However, +under special circumstances it can make sense to reserve some globally. +For example this may be useful in programs such as programming language +interpreters that have a couple of global variables that are accessed +very often. + +After defining a global register variable, for the current compilation +unit: + +* If the register is a call-saved register, call ABI is affected: + the register will not be restored in function epilogue sequences after + the variable has been assigned. Therefore, functions cannot safely + return to callers that assume standard ABI. + +* Conversely, if the register is a call-clobbered register, making + calls to functions that use standard ABI may lose contents of the variable. + Such calls may be created by the compiler even if none are evident in + the original program, for example when libgcc functions are used to + make up for unavailable instructions. + +* Accesses to the variable may be optimized as usual and the register + remains available for allocation and use in any computations, provided that + observable values of the variable are not affected. + +* If the variable is referenced in inline assembly, the type of access + must be provided to the compiler via constraints (see :ref:`constraints`). + Accesses from basic asms are not supported. + +Note that these points *only* apply to code that is compiled with the +definition. The behavior of code that is merely linked in (for example +code from libraries) is not affected. + +If you want to recompile source files that do not actually use your global +register variable so they do not use the specified register for any other +purpose, you need not actually add the global register declaration to +their source code. It suffices to specify the compiler option +:option:`-ffixed-reg` (see :ref:`code-gen-options`) to reserve the +register. + +Declaring the variable +^^^^^^^^^^^^^^^^^^^^^^ + +Global register variables cannot have initial values, because an +executable file has no means to supply initial contents for a register. + +When selecting a register, choose one that is normally saved and +restored by function calls on your machine. This ensures that code +which is unaware of this reservation (such as library routines) will +restore it before returning. + +On machines with register windows, be sure to choose a global +register that is not affected magically by the function call mechanism. + +.. index:: qsort, and global register variables + +Using the variable +^^^^^^^^^^^^^^^^^^ + +When calling routines that are not aware of the reservation, be +cautious if those routines call back into code which uses them. As an +example, if you call the system library version of ``qsort``, it may +clobber your registers during execution, but (if you have selected +appropriate registers) it will restore them before returning. However +it will *not* restore them before calling ``qsort`` 's comparison +function. As a result, global values will not reliably be available to +the comparison function unless the ``qsort`` function itself is rebuilt. + +Similarly, it is not safe to access the global register variables from signal +handlers or from more than one thread of control. Unless you recompile +them specially for the task at hand, the system library routines may +temporarily use the register for other things. Furthermore, since the register +is not reserved exclusively for the variable, accessing it from handlers of +asynchronous signals may observe unrelated temporary values residing in the +register. + +.. index:: register variable after longjmp, global register after longjmp, value after longjmp, longjmp, setjmp + +On most machines, ``longjmp`` restores to each global register +variable the value it had at the time of the ``setjmp``. On some +machines, however, ``longjmp`` does not change the value of global +register variables. To be portable, the function that called ``setjmp`` +should make other arrangements to save the values of the global register +variables, and to restore them in a ``longjmp``. This way, the same +thing happens regardless of what ``longjmp`` does. + +.. _local-register-variables: + +Specifying Registers for Local Variables +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. index:: local variables, specifying registers, specifying registers for local variables, registers for local variables + +.. _local-reg-vars: + +You can define a local register variable and associate it with a specified +register like this: + +.. code-block:: c++ + + register int *foo asm ("r12"); + +Here ``r12`` is the name of the register that should be used. Note +that this is the same syntax used for defining global register variables, +but for a local variable the declaration appears within a function. The +``register`` keyword is required, and cannot be combined with +``static``. The register name must be a valid register name for the +target platform. + +Do not use type qualifiers such as ``const`` and ``volatile``, as +the outcome may be contrary to expectations. In particular, when the +``const`` qualifier is used, the compiler may substitute the +variable with its initializer in ``asm`` statements, which may cause +the corresponding operand to appear in a different register. + +As with global register variables, it is recommended that you choose +a register that is normally saved and restored by function calls on your +machine, so that calls to library routines will not clobber it. + +The only supported use for this feature is to specify registers +for input and output operands when calling Extended ``asm`` +(see :ref:`extended-asm`). This may be necessary if the constraints for a +particular machine don't provide sufficient control to select the desired +register. To force an operand into a register, create a local variable +and specify the register name after the variable's declaration. Then use +the local variable for the ``asm`` operand and specify any constraint +letter that matches the register: + +.. code-block:: c++ + + register int *p1 asm ("r0") = ...; + register int *p2 asm ("r1") = ...; + register int *result asm ("r0"); + asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2)); + +.. warning:: + + In the above example, be aware that a register (for example + ``r0``) can be call-clobbered by subsequent code, including function + calls and library calls for arithmetic operators on other variables (for + example the initialization of ``p2``). In this case, use temporary + variables for expressions between the register assignments: + +.. code-block:: c++ + + int t1 = ...; + register int *p1 asm ("r0") = ...; + register int *p2 asm ("r1") = t1; + register int *result asm ("r0"); + asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2)); + +Defining a register variable does not reserve the register. Other than +when invoking the Extended ``asm``, the contents of the specified +register are not guaranteed. For this reason, the following uses +are explicitly *not* supported. If they appear to work, it is only +happenstance, and may stop working as intended due to (seemingly) +unrelated changes in surrounding code, or even minor changes in the +optimization of a future version of gcc: + +* Passing parameters to or from Basic ``asm`` + +* Passing parameters to or from Extended ``asm`` without using input + or output operands. + +* Passing parameters to or from routines written in assembler (or + other languages) using non-standard calling conventions. + +Some developers use Local Register Variables in an attempt to improve +gcc's allocation of registers, especially in large functions. In this +case the register name is essentially a hint to the register allocator. +While in some instances this can generate better code, improvements are +subject to the whims of the allocator/optimizers. Since there are no +guarantees that your improvements won't be lost, this usage of Local +Register Variables is discouraged. + +On the MIPS platform, there is related use for local register variables +with slightly different characteristics (see :ref:`gccint:mips-coprocessors`). + +.. _size-of-an-asm: + +Size of an asm +^^^^^^^^^^^^^^ + +Some targets require that GCC track the size of each instruction used +in order to generate correct code. Because the final length of the +code produced by an ``asm`` statement is only known by the +assembler, GCC must make an estimate as to how big it will be. It +does this by counting the number of instructions in the pattern of the +``asm`` and multiplying that by the length of the longest +instruction supported by that processor. (When working out the number +of instructions, it assumes that any occurrence of a newline or of +whatever statement separator character is supported by the assembler --- +typically :samp:`;` --- indicates the end of an instruction.) + +Normally, GCC's estimate is adequate to ensure that correct +code is generated, but it is possible to confuse the compiler if you use +pseudo instructions or assembler macros that expand into multiple real +instructions, or if you use assembler directives that expand to more +space in the object file than is needed for a single instruction. +If this happens then the assembler may produce a diagnostic saying that +a label is unreachable. + +.. index:: asm inline + +This size is also used for inlining decisions. If you use ``asm inline`` +instead of just ``asm``, then for inlining purposes the size of the asm +is taken as the minimum size, ignoring how many instructions GCC thinks it is. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/incomplete-enum-types.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/incomplete-enum-types.rst new file mode 100644 index 00000000000..ffb06c9d4b4 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/incomplete-enum-types.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _incomplete-enums: + +Incomplete enum Types +********************* + +You can define an ``enum`` tag without specifying its possible values. +This results in an incomplete type, much like what you get if you write +``struct foo`` without describing the elements. A later declaration +that does specify the possible values completes the type. + +You cannot allocate variables or storage using the type while it is +incomplete. However, you can work with pointers to that type. + +This extension may not be very useful, but it makes the handling of +``enum`` more consistent with the way ``struct`` and ``union`` +are handled. + +This extension is not supported by GNU C++. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/label-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/label-attributes.rst new file mode 100644 index 00000000000..f872130a80d --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/label-attributes.rst @@ -0,0 +1,65 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Label Attributes + +.. _label-attributes: + +Label Attributes +**************** + +GCC allows attributes to be set on C labels. See :ref:`attribute-syntax`, for +details of the exact syntax for using attributes. Other attributes are +available for functions (see :ref:`function-attributes`), variables +(see :ref:`variable-attributes`), enumerators (see :ref:`enumerator-attributes`), +statements (see :ref:`statement-attributes`), and for types +(see :ref:`type-attributes`). A label attribute followed +by a declaration appertains to the label and not the declaration. + +This example uses the :label-attr:`cold` label attribute to indicate the +``ErrorHandling`` branch is unlikely to be taken and that the +``ErrorHandling`` label is unused: + +.. code-block:: c++ + + asm goto ("some asm" : : : : NoError); + + /* This branch (the fall-through from the asm) is less commonly used */ + ErrorHandling: + __attribute__((cold, unused)); /* Semi-colon is required here */ + printf("error\n"); + return 0; + + NoError: + printf("no error\n"); + return 1; + +:label-attr:`unused` + + .. index:: unused label attribute + + This feature is intended for program-generated code that may contain + unused labels, but which is compiled with :option:`-Wall`. It is + not normally appropriate to use in it human-written code, though it + could be useful in cases where the code that jumps to the label is + contained within an ``#ifdef`` conditional. + +:label-attr:`hot` + + .. index:: hot label attribute + + The :label-attr:`hot` attribute on a label is used to inform the compiler that + the path following the label is more likely than paths that are not so + annotated. This attribute is used in cases where ``__builtin_expect`` + cannot be used, for instance with computed goto or ``asm goto``. + +:label-attr:`cold` + + .. index:: cold label attribute + + The :label-attr:`cold` attribute on labels is used to inform the compiler that + the path following the label is unlikely to be executed. This attribute + is used in cases where ``__builtin_expect`` cannot be used, for instance + with computed goto or ``asm goto``. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/labels-as-values.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/labels-as-values.rst new file mode 100644 index 00000000000..7c6408a7031 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/labels-as-values.rst @@ -0,0 +1,86 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: labels as values, computed gotos, goto with computed label, address of a label + +.. _labels-as-values: + +Labels as Values +**************** + +You can get the address of a label defined in the current function +(or a containing function) with the unary operator :samp:`&&`. The +value has type ``void *``. This value is a constant and can be used +wherever a constant of that type is valid. For example: + +.. code-block:: c++ + + void *ptr; + /* ... */ + ptr = &&foo; + +To use these values, you need to be able to jump to one. This is done +with the computed goto statement [#f1]_, ``goto *exp;``. For example, + +.. code-block:: c++ + + goto *ptr; + +Any expression of type ``void *`` is allowed. + +One way of using these constants is in initializing a static array that +serves as a jump table: + +.. code-block:: c++ + + static void *array[] = { &&foo, &&bar, &&hack }; + +Then you can select a label with indexing, like this: + +.. code-block:: c++ + + goto *array[i]; + +Note that this does not check whether the subscript is in bounds---array +indexing in C never does that. + +Such an array of label values serves a purpose much like that of the +``switch`` statement. The ``switch`` statement is cleaner, so +use that rather than an array unless the problem does not fit a +``switch`` statement very well. + +Another use of label values is in an interpreter for threaded code. +The labels within the interpreter function can be stored in the +threaded code for super-fast dispatching. + +You may not use this mechanism to jump to code in a different function. +If you do that, totally unpredictable things happen. The best way to +avoid this is to store the label address only in automatic variables and +never pass it as an argument. + +An alternate way to write the above example is + +.. code-block:: c++ + + static const int array[] = { &&foo - &&foo, &&bar - &&foo, + &&hack - &&foo }; + goto *(&&foo + array[i]); + +This is more friendly to code living in shared libraries, as it reduces +the number of dynamic relocations that are needed, and by consequence, +allows the data to be read-only. +This alternative with label differences is not supported for the AVR target, +please use the first approach for AVR programs. + +The ``&&foo`` expressions for the same label might have different +values if the containing function is inlined or cloned. If a program +relies on them being always the same, +``__attribute__((__noinline__,__noclone__))`` should be used to +prevent inlining and cloning. If ``&&foo`` is used in a static +variable initializer, inlining and cloning is forbidden. + +.. [#f1] The analogous feature in Fortran is called an assigned goto, but that name seems inappropriate in + C, where one can do more than simply store label addresses in label + variables. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/legacy-sync-built-in-functions-for-atomic-memory-access.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/legacy-sync-built-in-functions-for-atomic-memory-access.rst new file mode 100644 index 00000000000..de3e80cb6bf --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/legacy-sync-built-in-functions-for-atomic-memory-access.rst @@ -0,0 +1,171 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _sync-builtins: + +Legacy __sync Built-in Functions for Atomic Memory Access +********************************************************* + +The following built-in functions +are intended to be compatible with those described +in the Intel Itanium Processor-specific Application Binary Interface, +section 7.4. As such, they depart from normal GCC practice by not using +the :samp:`__builtin_` prefix and also by being overloaded so that they +work on multiple types. + +The definition given in the Intel documentation allows only for the use of +the types ``int``, ``long``, ``long long`` or their unsigned +counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in +size other than the C type ``_Bool`` or the C++ type ``bool``. +Operations on pointer arguments are performed as if the operands were +of the ``uintptr_t`` type. That is, they are not scaled by the size +of the type to which the pointer points. + +These functions are implemented in terms of the :samp:`__atomic` +builtins (see :ref:`atomic-builtins`). They should not be used for new +code which should use the :samp:`__atomic` builtins instead. + +Not all operations are supported by all target processors. If a particular +operation cannot be implemented on the target processor, a warning is +generated and a call to an external function is generated. The external +function carries the same name as the built-in version, +with an additional suffix +:samp:`_{n}` where :samp:`{n}` is the size of the data type. + +.. ??? Should we have a mechanism to suppress this warning? This is almost + useful for implementing the operation under the control of an external + mutex. + +In most cases, these built-in functions are considered a :dfn:`full barrier`. +That is, +no memory operand is moved across the operation, either forward or +backward. Further, instructions are issued as necessary to prevent the +processor from speculating loads across the operation and from queuing stores +after the operation. + +All of the routines are described in the Intel documentation to take +'an optional list of variables protected by the memory barrier'. It's +not clear what is meant by that; it could mean that *only* the +listed variables are protected, or it could mean a list of additional +variables to be protected. The list is ignored by GCC which treats it as +empty. GCC interprets an empty list as meaning that all globally +accessible variables should be protected. + +:: + + type __sync_fetch_and_add (type *ptr, type value, ...) + type __sync_fetch_and_sub (type *ptr, type value, ...) + type __sync_fetch_and_or (type *ptr, type value, ...) + type __sync_fetch_and_and (type *ptr, type value, ...) + type __sync_fetch_and_xor (type *ptr, type value, ...) + type __sync_fetch_and_nand (type *ptr, type value, ...) + +.. index:: __sync_fetch_and_add +.. index:: __sync_fetch_and_sub +.. index:: __sync_fetch_and_or +.. index:: __sync_fetch_and_and +.. index:: __sync_fetch_and_xor +.. index:: __sync_fetch_and_nand + +These built-in functions perform the operation suggested by the name, and +returns the value that had previously been in memory. That is, operations +on integer operands have the following semantics. Operations on pointer +arguments are performed as if the operands were of the ``uintptr_t`` +type. That is, they are not scaled by the size of the type to which +the pointer points. + +.. code-block:: c++ + + { tmp = *ptr; *ptr op= value; return tmp; } + { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } // nand + +The object pointed to by the first argument must be of integer or pointer +type. It must not be a boolean type. + +.. note:: + GCC 4.4 and later implement ``__sync_fetch_and_nand`` + as ``*ptr = ~(tmp & value)`` instead of ``*ptr = ~tmp & value``. + +:: + + type __sync_add_and_fetch (type *ptr, type value, ...) + type __sync_sub_and_fetch (type *ptr, type value, ...) + type __sync_or_and_fetch (type *ptr, type value, ...) + type __sync_and_and_fetch (type *ptr, type value, ...) + type __sync_xor_and_fetch (type *ptr, type value, ...) + type __sync_nand_and_fetch (type *ptr, type value, ...) + +.. index:: __sync_add_and_fetch +.. index:: __sync_sub_and_fetch +.. index:: __sync_or_and_fetch +.. index:: __sync_and_and_fetch +.. index:: __sync_xor_and_fetch +.. index:: __sync_nand_and_fetch + +These built-in functions perform the operation suggested by the name, and +return the new value. That is, operations on integer operands have +the following semantics. Operations on pointer operands are performed as +if the operand's type were ``uintptr_t``. + +.. code-block:: c++ + + { *ptr op= value; return *ptr; } + { *ptr = ~(*ptr & value); return *ptr; } // nand + +The same constraints on arguments apply as for the corresponding +``__sync_op_and_fetch`` built-in functions. + +.. note:: + GCC 4.4 and later implement ``__sync_nand_and_fetch`` + as ``*ptr = ~(*ptr & value)`` instead of + ``*ptr = ~*ptr & value``. + +.. function:: bool __sync_bool_compare_and_swap (type *ptr, type oldval, type newval, ...) +.. function:: type __sync_val_compare_and_swap (type *ptr, type oldval, type newval, ...) + + These built-in functions perform an atomic compare and swap. + That is, if the current + value of ``*ptr`` is :samp:`{oldval}`, then write :samp:`{newval}` into + ``*ptr``. + + The 'bool' version returns ``true`` if the comparison is successful and + :samp:`{newval}` is written. The 'val' version returns the contents + of ``*ptr`` before the operation. + +.. function:: __sync_synchronize (...) + + This built-in function issues a full memory barrier. + +.. function:: type __sync_lock_test_and_set (type *ptr, type value, ...) + + This built-in function, as described by Intel, is not a traditional test-and-set + operation, but rather an atomic exchange operation. It writes :samp:`{value}` + into ``*ptr``, and returns the previous contents of + ``*ptr``. + + Many targets have only minimal support for such locks, and do not support + a full exchange operation. In this case, a target may support reduced + functionality here by which the *only* valid value to store is the + immediate constant 1. The exact value actually stored in ``*ptr`` + is implementation defined. + + This built-in function is not a full barrier, + but rather an :dfn:`acquire barrier`. + This means that references after the operation cannot move to (or be + speculated to) before the operation, but previous memory stores may not + be globally visible yet, and previous memory loads may not yet be + satisfied. + +.. function:: void __sync_lock_release (type *ptr, ...) + + This built-in function releases the lock acquired by + ``__sync_lock_test_and_set``. + Normally this means writing the constant 0 to ``*ptr``. + + This built-in function is not a full barrier, + but rather a :dfn:`release barrier`. + This means that all previous memory stores are globally visible, and all + previous memory loads have been satisfied, but following memory reads + are not prevented from being speculated to before the barrier. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/locally-declared-labels.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/locally-declared-labels.rst new file mode 100644 index 00000000000..b79e7453ea4 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/locally-declared-labels.rst @@ -0,0 +1,82 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: local labels, macros, local labels + +.. _local-labels: + +Locally Declared Labels +*********************** + +GCC allows you to declare :dfn:`local labels` in any nested block +scope. A local label is just like an ordinary label, but you can +only reference it (with a ``goto`` statement, or by taking its +address) within the block in which it is declared. + +A local label declaration looks like this: + +.. code-block:: c++ + + __label__ label; + +or + +.. code-block:: c++ + + __label__ label1, label2, /* ... */; + +Local label declarations must come at the beginning of the block, +before any ordinary declarations or statements. + +The label declaration defines the label *name*, but does not define +the label itself. You must do this in the usual way, with +``label:``, within the statements of the statement expression. + +The local label feature is useful for complex macros. If a macro +contains nested loops, a ``goto`` can be useful for breaking out of +them. However, an ordinary label whose scope is the whole function +cannot be used: if the macro can be expanded several times in one +function, the label is multiply defined in that function. A +local label avoids this problem. For example: + +.. code-block:: c++ + + #define SEARCH(value, array, target) \ + do { \ + __label__ found; \ + typeof (target) _SEARCH_target = (target); \ + typeof (*(array)) *_SEARCH_array = (array); \ + int i, j; \ + int value; \ + for (i = 0; i < max; i++) \ + for (j = 0; j < max; j++) \ + if (_SEARCH_array[i][j] == _SEARCH_target) \ + { (value) = i; goto found; } \ + (value) = -1; \ + found:; \ + } while (0) + +This could also be written using a statement expression: + +.. code-block:: c++ + + #define SEARCH(array, target) \ + ({ \ + __label__ found; \ + typeof (target) _SEARCH_target = (target); \ + typeof (*(array)) *_SEARCH_array = (array); \ + int i, j; \ + int value; \ + for (i = 0; i < max; i++) \ + for (j = 0; j < max; j++) \ + if (_SEARCH_array[i][j] == _SEARCH_target) \ + { value = i; goto found; } \ + value = -1; \ + found: \ + value; \ + }) + +Local label declarations also make the labels they declare visible to +nested functions, if there are any. See :ref:`nested-functions`, for details. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/macros-with-a-variable-number-of-arguments.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/macros-with-a-variable-number-of-arguments.rst new file mode 100644 index 00000000000..8c22eb542ba --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/macros-with-a-variable-number-of-arguments.rst @@ -0,0 +1,68 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: variable number of arguments, macro with variable arguments, rest argument (in macro), variadic macros + +.. _variadic-macros: + +Macros with a Variable Number of Arguments. +******************************************* + +In the ISO C standard of 1999, a macro can be declared to accept a +variable number of arguments much as a function can. The syntax for +defining the macro is similar to that of a function. Here is an +example: + +.. code-block:: c++ + + #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__) + +Here :samp:`...` is a :dfn:`variable argument`. In the invocation of +such a macro, it represents the zero or more tokens until the closing +parenthesis that ends the invocation, including any commas. This set of +tokens replaces the identifier ``__VA_ARGS__`` in the macro body +wherever it appears. See the CPP manual for more information. + +GCC has long supported variadic macros, and used a different syntax that +allowed you to give a name to the variable arguments just like any other +argument. Here is an example: + +.. code-block:: c++ + + #define debug(format, args...) fprintf (stderr, format, args) + +This is in all ways equivalent to the ISO C example above, but arguably +more readable and descriptive. + +GNU CPP has two further variadic macro extensions, and permits them to +be used with either of the above forms of macro definition. + +In standard C, you are not allowed to leave the variable argument out +entirely; but you are allowed to pass an empty argument. For example, +this invocation is invalid in ISO C, because there is no comma after +the string: + +.. code-block:: c++ + + debug ("A message") + +GNU CPP permits you to completely omit the variable arguments in this +way. In the above examples, the compiler would complain, though since +the expansion of the macro still has the extra comma after the format +string. + +To help solve this problem, CPP behaves specially for variable arguments +used with the token paste operator, :samp:`##`. If instead you write + +.. code-block:: c++ + + #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__) + +and if the variable arguments are omitted or empty, the :samp:`##` +operator causes the preprocessor to remove the comma before it. If you +do provide some variable arguments in your macro invocation, GNU CPP +does not complain about the paste operation and instead places the +variable arguments after the comma. Just like any other pasted macro +argument, these arguments are not macro expanded. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/mixed-declarations-labels-and-code.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/mixed-declarations-labels-and-code.rst new file mode 100644 index 00000000000..090ead8b431 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/mixed-declarations-labels-and-code.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: mixed declarations and code, declarations, mixed with code, code, mixed with declarations + +.. _mixed-labels-and-declarations: + +Mixed Declarations, Labels and Code +*********************************** + +ISO C99 and ISO C++ allow declarations and code to be freely mixed +within compound statements. ISO C2X allows labels to be +placed before declarations and at the end of a compound statement. +As an extension, GNU C also allows all this in C90 mode. For example, +you could do: + +.. code-block:: c++ + + int i; + /* ... */ + i++; + int j = i + 2; + +Each identifier is visible from where it is declared until the end of +the enclosing block. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/named-address-spaces.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/named-address-spaces.rst new file mode 100644 index 00000000000..842042810fc --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/named-address-spaces.rst @@ -0,0 +1,240 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Named Address Spaces + +.. _named-address-spaces: + +Named Address Spaces +******************** + +As an extension, GNU C supports named address spaces as +defined in the N1275 draft of ISO/IEC DTR 18037. Support for named +address spaces in GCC will evolve as the draft technical report +changes. Calling conventions for any target might also change. At +present, only the AVR, M32C, PRU, RL78, and x86 targets support +address spaces other than the generic address space. + +Address space identifiers may be used exactly like any other C type +qualifier (e.g., ``const`` or ``volatile``). See the N1275 +document for more details. + +.. _avr-named-address-spaces: + +AVR Named Address Spaces +^^^^^^^^^^^^^^^^^^^^^^^^ + +On the AVR target, there are several address spaces that can be used +in order to put read-only data into the flash memory and access that +data by means of the special instructions ``LPM`` or ``ELPM`` +needed to read from flash. + +Devices belonging to ``avrtiny`` and ``avrxmega3`` can access +flash memory by means of ``LD*`` instructions because the flash +memory is mapped into the RAM address space. There is *no need* +for language extensions like ``__flash`` or attribute +:ref:`avr-variable-attributes`. +The default linker description files for these devices cater for that +feature and ``.rodata`` stays in flash: The compiler just generates +``LD*`` instructions, and the linker script adds core specific +offsets to all ``.rodata`` symbols: ``0x4000`` in the case of +``avrtiny`` and ``0x8000`` in the case of ``avrxmega3``. +See :ref:`avr-options` for a list of respective devices. + +For devices not in ``avrtiny`` or ``avrxmega3``, +any data including read-only data is located in RAM (the generic +address space) because flash memory is not visible in the RAM address +space. In order to locate read-only data in flash memory *and* +to generate the right instructions to access this data without +using (inline) assembler code, special address spaces are needed. + +``__flash`` + + .. index:: __flash AVR Named Address Spaces + + The ``__flash`` qualifier locates data in the + ``.progmem.data`` section. Data is read using the ``LPM`` + instruction. Pointers to this address space are 16 bits wide. + +``__flash1`` ``__flash2`` ``__flash3`` ``__flash4`` ``__flash5`` + + .. index:: __flash1 AVR Named Address Spaces, __flash2 AVR Named Address Spaces, __flash3 AVR Named Address Spaces, __flash4 AVR Named Address Spaces, __flash5 AVR Named Address Spaces + + These are 16-bit address spaces locating data in section + ``.progmemN.data`` where :samp:`{N}` refers to + address space ``__flashN``. + The compiler sets the ``RAMPZ`` segment register appropriately + before reading data by means of the ``ELPM`` instruction. + +``__memx`` + + .. index:: __memx AVR Named Address Spaces + + This is a 24-bit address space that linearizes flash and RAM: + If the high bit of the address is set, data is read from + RAM using the lower two bytes as RAM address. + If the high bit of the address is clear, data is read from flash + with ``RAMPZ`` set according to the high byte of the address. + See :ref:`avr-built-in-functions`. + + Objects in this address space are located in ``.progmemx.data``. + + Example + +.. code-block:: c++ + + char my_read (const __flash char ** p) + { + /* p is a pointer to RAM that points to a pointer to flash. + The first indirection of p reads that flash pointer + from RAM and the second indirection reads a char from this + flash address. */ + + return **p; + } + + /* Locate array[] in flash memory */ + const __flash int array[] = { 3, 5, 7, 11, 13, 17, 19 }; + + int i = 1; + + int main (void) + { + /* Return 17 by reading from flash memory */ + return array[array[i]]; + } + +For each named address space supported by avr-gcc there is an equally +named but uppercase built-in macro defined. +The purpose is to facilitate testing if respective address space +support is available or not: + +.. code-block:: c++ + + #ifdef __FLASH + const __flash int var = 1; + + int read_var (void) + { + return var; + } + #else + #include /* From AVR-LibC */ + + const int var PROGMEM = 1; + + int read_var (void) + { + return (int) pgm_read_word (&var); + } + #endif /* __FLASH */ + +Notice that attribute :ref:`avr-variable-attributes` +locates data in flash but +accesses to these data read from generic address space, i.e. +from RAM, +so that you need special accessors like ``pgm_read_byte`` +from `AVR-LibC `_ +together with attribute :avr-var-attr:`progmem`. + +Limitations and caveats + +* Reading across the 64 |nbsp| KiB section boundary of + the ``__flash`` or ``__flashN`` address spaces + shows undefined behavior. The only address space that + supports reading across the 64 |nbsp| KiB flash segment boundaries is + ``__memx``. + +* If you use one of the ``__flashN`` address spaces + you must arrange your linker script to locate the + ``.progmemN.data`` sections according to your needs. + +* Any data or pointers to the non-generic address spaces must + be qualified as ``const``, i.e. as read-only data. + This still applies if the data in one of these address + spaces like software version number or calibration lookup table are intended to + be changed after load time by, say, a boot loader. In this case + the right qualification is ``const`` ``volatile`` so that the compiler + must not optimize away known values or insert them + as immediates into operands of instructions. + +* The following code initializes a variable ``pfoo`` + located in static storage with a 24-bit address: + + .. code-block:: c++ + + extern const __memx char foo; + const __memx void *pfoo = &foo; + +* On the reduced Tiny devices like ATtiny40, no address spaces are supported. + Just use vanilla C / C++ code without overhead as outlined above. + Attribute :avr-var-attr:`progmem` is supported but works differently, + see :ref:`avr-variable-attributes`. + +.. index:: __far M32C Named Address Spaces + +M32C Named Address Spaces +^^^^^^^^^^^^^^^^^^^^^^^^^ + +On the M32C target, with the R8C and M16C CPU variants, variables +qualified with ``__far`` are accessed using 32-bit addresses in +order to access memory beyond the first 64 |nbsp| Ki bytes. If +``__far`` is used with the M32CM or M32C CPU variants, it has no +effect. + +.. index:: __regio_symbol PRU Named Address Spaces + +PRU Named Address Spaces +^^^^^^^^^^^^^^^^^^^^^^^^ + +On the PRU target, variables qualified with ``__regio_symbol`` are +aliases used to access the special I/O CPU registers. They must be +declared as ``extern`` because such variables will not be allocated in +any data memory. They must also be marked as ``volatile``, and can +only be 32-bit integer types. The only names those variables can have +are ``__R30`` and ``__R31``, representing respectively the +``R30`` and ``R31`` special I/O CPU registers. Hence the following +example is the only valid usage of ``__regio_symbol`` : + +.. code-block:: c++ + + extern volatile __regio_symbol uint32_t __R30; + extern volatile __regio_symbol uint32_t __R31; + +.. index:: __far RL78 Named Address Spaces + +RL78 Named Address Spaces +^^^^^^^^^^^^^^^^^^^^^^^^^ + +On the RL78 target, variables qualified with ``__far`` are accessed +with 32-bit pointers (20-bit addresses) rather than the default 16-bit +addresses. Non-far variables are assumed to appear in the topmost +64 |nbsp| KiB of the address space. + +.. index:: x86 named address spaces + +x86 Named Address Spaces +^^^^^^^^^^^^^^^^^^^^^^^^ + +On the x86 target, variables may be declared as being relative +to the ``%fs`` or ``%gs`` segments. + +``__seg_fs`` ``__seg_gs`` + + .. index:: __seg_fs x86 named address space, __seg_gs x86 named address space + + The object is accessed with the respective segment override prefix. + + The respective segment base must be set via some method specific to + the operating system. Rather than require an expensive system call + to retrieve the segment base, these address spaces are not considered + to be subspaces of the generic (flat) address space. This means that + explicit casts are required to convert pointers between these address + spaces and the generic address space. In practice the application + should cast to ``uintptr_t`` and apply the segment base offset + that it installed previously. + + The preprocessor symbols ``__SEG_FS`` and ``__SEG_GS`` are + defined when these address spaces are supported. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/nested-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/nested-functions.rst new file mode 100644 index 00000000000..68bcb95eaee --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/nested-functions.rst @@ -0,0 +1,132 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: nested functions, downward funargs, thunks + +.. _nested-functions: + +Nested Functions +**************** + +A :dfn:`nested function` is a function defined inside another function. +Nested functions are supported as an extension in GNU C, but are not +supported by GNU C++. + +The nested function's name is local to the block where it is defined. +For example, here we define a nested function named ``square``, and +call it twice: + +.. code-block:: c++ + + foo (double a, double b) + { + double square (double z) { return z * z; } + + return square (a) + square (b); + } + +The nested function can access all the variables of the containing +function that are visible at the point of its definition. This is +called :dfn:`lexical scoping`. For example, here we show a nested +function which uses an inherited variable named ``offset`` : + +.. code-block:: c++ + + bar (int *array, int offset, int size) + { + int access (int *array, int index) + { return array[index + offset]; } + int i; + /* ... */ + for (i = 0; i < size; i++) + /* ... */ access (array, i) /* ... */ + } + +Nested function definitions are permitted within functions in the places +where variable definitions are allowed; that is, in any block, mixed +with the other declarations and statements in the block. + +It is possible to call the nested function from outside the scope of its +name by storing its address or passing the address to another function: + +.. code-block:: c++ + + hack (int *array, int size) + { + void store (int index, int value) + { array[index] = value; } + + intermediate (store, size); + } + +Here, the function ``intermediate`` receives the address of +``store`` as an argument. If ``intermediate`` calls ``store``, +the arguments given to ``store`` are used to store into ``array``. +But this technique works only so long as the containing function +(``hack``, in this example) does not exit. + +If you try to call the nested function through its address after the +containing function exits, all hell breaks loose. If you try +to call it after a containing scope level exits, and if it refers +to some of the variables that are no longer in scope, you may be lucky, +but it's not wise to take the risk. If, however, the nested function +does not refer to anything that has gone out of scope, you should be +safe. + +GCC implements taking the address of a nested function using a technique +called :dfn:`trampolines`. This technique was described in +Lexical Closures for C++ (Thomas M. Breuel, USENIX +C++ Conference Proceedings, October 17-21, 1988). + +A nested function can jump to a label inherited from a containing +function, provided the label is explicitly declared in the containing +function (see :ref:`local-labels`). Such a jump returns instantly to the +containing function, exiting the nested function that did the +``goto`` and any intermediate functions as well. Here is an example: + +.. code-block:: c++ + + bar (int *array, int offset, int size) + { + __label__ failure; + int access (int *array, int index) + { + if (index > size) + goto failure; + return array[index + offset]; + } + int i; + /* ... */ + for (i = 0; i < size; i++) + /* ... */ access (array, i) /* ... */ + /* ... */ + return 0; + + /* Control comes here from access + if it detects an error. */ + failure: + return -1; + } + +A nested function always has no linkage. Declaring one with +``extern`` or ``static`` is erroneous. If you need to declare the nested function +before its definition, use ``auto`` (which is otherwise meaningless +for function declarations). + +.. code-block:: c++ + + bar (int *array, int offset, int size) + { + __label__ failure; + auto int access (int *, int); + /* ... */ + int access (int *array, int index) + { + if (index > size) + goto failure; + return array[index + offset]; + } + /* ... */ + } \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/non-constant-initializers.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/non-constant-initializers.rst new file mode 100644 index 00000000000..e93c850a383 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/non-constant-initializers.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: initializers, non-constant, non-constant initializers + +.. _initializers: + +Non-Constant Initializers +************************* + +As in standard C++ and ISO C99, the elements of an aggregate initializer for an +automatic variable are not required to be constant expressions in GNU C. +Here is an example of an initializer with run-time varying elements: + +.. code-block:: c++ + + foo (float f, float g) + { + float beat_freqs[2] = { f-g, f+g }; + /* ... */ + } \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/non-lvalue-arrays-may-have-subscripts.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/non-lvalue-arrays-may-have-subscripts.rst new file mode 100644 index 00000000000..1d0d1546505 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/non-lvalue-arrays-may-have-subscripts.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: subscripting, arrays, non-lvalue, subscripting and function values + +.. _subscripting: + +Non-Lvalue Arrays May Have Subscripts +************************************* + +In ISO C99, arrays that are not lvalues still decay to pointers, and +may be subscripted, although they may not be modified or used after +the next sequence point and the unary :samp:`&` operator may not be +applied to them. As an extension, GNU C allows such arrays to be +subscripted in C90 mode, though otherwise they do not decay to +pointers outside C99 mode. For example, +this is valid in GNU C though not valid in C90: + +.. code-block:: c++ + + struct foo {int a[4];}; + + struct foo f(); + + bar (int index) + { + return f().a[index]; + } \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/nonlocal-gotos.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/nonlocal-gotos.rst new file mode 100644 index 00000000000..1aab77a6719 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/nonlocal-gotos.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: nonlocal gotos + +.. _nonlocal-gotos: + +Nonlocal Gotos +************** + +GCC provides the built-in functions ``__builtin_setjmp`` and +``__builtin_longjmp`` which are similar to, but not interchangeable +with, the C library functions ``setjmp`` and ``longjmp``. +The built-in versions are used internally by GCC's libraries +to implement exception handling on some targets. You should use the +standard C library functions declared in ```` in user code +instead of the builtins. + +The built-in versions of these functions use GCC's normal +mechanisms to save and restore registers using the stack on function +entry and exit. The jump buffer argument :samp:`{buf}` holds only the +information needed to restore the stack frame, rather than the entire +set of saved register values. + +An important caveat is that GCC arranges to save and restore only +those registers known to the specific architecture variant being +compiled for. This can make ``__builtin_setjmp`` and +``__builtin_longjmp`` more efficient than their library +counterparts in some cases, but it can also cause incorrect and +mysterious behavior when mixing with code that uses the full register +set. + +You should declare the jump buffer argument :samp:`{buf}` to the +built-in functions as: + +.. code-block:: c++ + + #include + intptr_t buf[5]; + +.. function:: int __builtin_setjmp (intptr_t *buf) + + This function saves the current stack context in :samp:`{buf}`. + ``__builtin_setjmp`` returns 0 when returning directly, + and 1 when returning from ``__builtin_longjmp`` using the same + :samp:`{buf}`. + +.. function:: void __builtin_longjmp (intptr_t *buf, int val) + + This function restores the stack context in :samp:`{buf}`, + saved by a previous call to ``__builtin_setjmp``. After + ``__builtin_longjmp`` is finished, the program resumes execution as + if the matching ``__builtin_setjmp`` returns the value :samp:`{val}`, + which must be 1. + + Because ``__builtin_longjmp`` depends on the function return + mechanism to restore the stack context, it cannot be called + from the same function calling ``__builtin_setjmp`` to + initialize :samp:`{buf}`. It can only be called from a function called + (directly or indirectly) from the function calling ``__builtin_setjmp``. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/object-size-checking-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/object-size-checking-built-in-functions.rst new file mode 100644 index 00000000000..640498a2485 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/object-size-checking-built-in-functions.rst @@ -0,0 +1,145 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: __builtin_object_size, __builtin_dynamic_object_size, __builtin___memcpy_chk, __builtin___mempcpy_chk, __builtin___memmove_chk, __builtin___memset_chk, __builtin___strcpy_chk, __builtin___stpcpy_chk, __builtin___strncpy_chk, __builtin___strcat_chk, __builtin___strncat_chk, __builtin___sprintf_chk, __builtin___snprintf_chk, __builtin___vsprintf_chk, __builtin___vsnprintf_chk, __builtin___printf_chk, __builtin___vprintf_chk, __builtin___fprintf_chk, __builtin___vfprintf_chk + +.. _object-size-checking: + +Object Size Checking Built-in Functions +*************************************** + +GCC implements a limited buffer overflow protection mechanism that can +prevent some buffer overflow attacks by determining the sizes of objects +into which data is about to be written and preventing the writes when +the size isn't sufficient. The built-in functions described below yield +the best results when used together and when optimization is enabled. +For example, to detect object sizes across function boundaries or to +follow pointer assignments through non-trivial control flow they rely +on various optimization passes enabled with :option:`-O2`. However, to +a limited extent, they can be used without optimization as well. + +.. function:: size_t __builtin_object_size (const void * ptr, int type) + + is a built-in construct that returns a constant number of bytes from + :samp:`{ptr}` to the end of the object :samp:`{ptr}` pointer points to + (if known at compile time). To determine the sizes of dynamically allocated + objects the function relies on the allocation functions called to obtain + the storage to be declared with the ``alloc_size`` attribute (see :ref:`common-function-attributes`). ``__builtin_object_size`` never evaluates + its arguments for side effects. If there are any side effects in them, it + returns ``(size_t) -1`` for :samp:`{type}` 0 or 1 and ``(size_t) 0`` + for :samp:`{type}` 2 or 3. If there are multiple objects :samp:`{ptr}` can + point to and all of them are known at compile time, the returned number + is the maximum of remaining byte counts in those objects if :samp:`{type}` & 2 is + 0 and minimum if nonzero. If it is not possible to determine which objects + :samp:`{ptr}` points to at compile time, ``__builtin_object_size`` should + return ``(size_t) -1`` for :samp:`{type}` 0 or 1 and ``(size_t) 0`` + for :samp:`{type}` 2 or 3. + + :samp:`{type}` is an integer constant from 0 to 3. If the least significant + bit is clear, objects are whole variables, if it is set, a closest + surrounding subobject is considered the object a pointer points to. + The second bit determines if maximum or minimum of remaining bytes + is computed. + + .. code-block:: c++ + + struct V { char buf1[10]; int b; char buf2[10]; } var; + char *p = &var.buf1[1], *q = &var.b; + + /* Here the object p points to is var. */ + assert (__builtin_object_size (p, 0) == sizeof (var) - 1); + /* The subobject p points to is var.buf1. */ + assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1); + /* The object q points to is var. */ + assert (__builtin_object_size (q, 0) + == (char *) (&var + 1) - (char *) &var.b); + /* The subobject q points to is var.b. */ + assert (__builtin_object_size (q, 1) == sizeof (var.b)); + +.. function:: size_t __builtin_dynamic_object_size (const void * ptr, int type) + + is similar to ``__builtin_object_size`` in that it returns a number of bytes + from :samp:`{ptr}` to the end of the object :samp:`{ptr}` pointer points to, except + that the size returned may not be a constant. This results in successful + evaluation of object size estimates in a wider range of use cases and can be + more precise than ``__builtin_object_size``, but it incurs a performance + penalty since it may add a runtime overhead on size computation. Semantics of + :samp:`{type}` as well as return values in case it is not possible to determine + which objects :samp:`{ptr}` points to at compile time are the same as in the case + of ``__builtin_object_size``. + +There are built-in functions added for many common string operation +functions, e.g., for ``memcpy`` ``__builtin___memcpy_chk`` +built-in is provided. This built-in has an additional last argument, +which is the number of bytes remaining in the object the :samp:`{dest}` +argument points to or ``(size_t) -1`` if the size is not known. + +The built-in functions are optimized into the normal string functions +like ``memcpy`` if the last argument is ``(size_t) -1`` or if +it is known at compile time that the destination object will not +be overflowed. If the compiler can determine at compile time that the +object will always be overflowed, it issues a warning. + +The intended use can be e.g. + +.. code-block:: c++ + + #undef memcpy + #define bos0(dest) __builtin_object_size (dest, 0) + #define memcpy(dest, src, n) \ + __builtin___memcpy_chk (dest, src, n, bos0 (dest)) + + char *volatile p; + char buf[10]; + /* It is unknown what object p points to, so this is optimized + into plain memcpy - no checking is possible. */ + memcpy (p, "abcde", n); + /* Destination is known and length too. It is known at compile + time there will be no overflow. */ + memcpy (&buf[5], "abcde", 5); + /* Destination is known, but the length is not known at compile time. + This will result in __memcpy_chk call that can check for overflow + at run time. */ + memcpy (&buf[5], "abcde", n); + /* Destination is known and it is known at compile time there will + be overflow. There will be a warning and __memcpy_chk call that + will abort the program at run time. */ + memcpy (&buf[6], "abcde", 5); + +Such built-in functions are provided for ``memcpy``, ``mempcpy``, +``memmove``, ``memset``, ``strcpy``, ``stpcpy``, ``strncpy``, +``strcat`` and ``strncat``. + +There are also checking built-in functions for formatted output functions. + +.. code-block:: c++ + + int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...); + int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os, + const char *fmt, ...); + int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt, + va_list ap); + int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os, + const char *fmt, va_list ap); + +The added :samp:`{flag}` argument is passed unchanged to ``__sprintf_chk`` +etc. functions and can contain implementation specific flags on what +additional security measures the checking function might take, such as +handling ``%n`` differently. + +The :samp:`{os}` argument is the object size :samp:`{s}` points to, like in the +other built-in functions. There is a small difference in the behavior +though, if :samp:`{os}` is ``(size_t) -1``, the built-in functions are +optimized into the non-checking functions only if :samp:`{flag}` is 0, otherwise +the checking function is called with :samp:`{os}` argument set to +``(size_t) -1``. + +In addition to this, there are checking built-in functions +``__builtin___printf_chk``, ``__builtin___vprintf_chk``, +``__builtin___fprintf_chk`` and ``__builtin___vfprintf_chk``. +These have just one additional argument, :samp:`{flag}`, right before +format string :samp:`{fmt}`. If the compiler is able to optimize them to +``fputc`` etc. functions, it does, otherwise the checking function +is called and the :samp:`{flag}` argument passed to it. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/other-built-in-functions-provided-by-gcc.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/other-built-in-functions-provided-by-gcc.rst new file mode 100644 index 00000000000..8f272a01d8e --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/other-built-in-functions-provided-by-gcc.rst @@ -0,0 +1,1245 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: built-in functions, __builtin_alloca, __builtin_alloca_with_align, __builtin_alloca_with_align_and_max, __builtin_call_with_static_chain, __builtin_extend_pointer, __builtin_fpclassify, __builtin_has_attribute, __builtin_isfinite, __builtin_isnormal, __builtin_isgreater, __builtin_isgreaterequal, __builtin_isinf_sign, __builtin_isless, __builtin_islessequal, __builtin_islessgreater, __builtin_isunordered, __builtin_object_size, __builtin_powi, __builtin_powif, __builtin_powil, __builtin_speculation_safe_value, _Exit, _exit, abort, abs, acos, acosf, acosh, acoshf, acoshl, acosl, alloca, asin, asinf, asinh, asinhf, asinhl, asinl, atan, atan2, atan2f, atan2l, atanf, atanh, atanhf, atanhl, atanl, bcmp, bzero, cabs, cabsf, cabsl, cacos, cacosf, cacosh, cacoshf, cacoshl, cacosl, calloc, carg, cargf, cargl, casin, casinf, casinh, casinhf, casinhl, casinl, catan, catanf, catanh, catanhf, catanhl, catanl, cbrt, cbrtf, cbrtl, ccos, ccosf, ccosh, ccoshf, ccoshl, ccosl, ceil, ceilf, ceill, cexp, cexpf, cexpl, cimag, cimagf, cimagl, clog, clogf, clogl, clog10, clog10f, clog10l, conj, conjf, conjl, copysign, copysignf, copysignl, cos, cosf, cosh, coshf, coshl, cosl, cpow, cpowf, cpowl, cproj, cprojf, cprojl, creal, crealf, creall, csin, csinf, csinh, csinhf, csinhl, csinl, csqrt, csqrtf, csqrtl, ctan, ctanf, ctanh, ctanhf, ctanhl, ctanl, dcgettext, dgettext, drem, dremf, dreml, erf, erfc, erfcf, erfcl, erff, erfl, exit, exp, exp10, exp10f, exp10l, exp2, exp2f, exp2l, expf, expl, expm1, expm1f, expm1l, fabs, fabsf, fabsl, fdim, fdimf, fdiml, ffs, floor, floorf, floorl, fma, fmaf, fmal, fmax, fmaxf, fmaxl, fmin, fminf, fminl, fmod, fmodf, fmodl, fprintf, fprintf_unlocked, fputs, fputs_unlocked, free, frexp, frexpf, frexpl, fscanf, gamma, gammaf, gammal, gamma_r, gammaf_r, gammal_r, gettext, hypot, hypotf, hypotl, ilogb, ilogbf, ilogbl, imaxabs, index, isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, iswalnum, iswalpha, iswblank, iswcntrl, iswdigit, iswgraph, iswlower, iswprint, iswpunct, iswspace, iswupper, iswxdigit, isxdigit, j0, j0f, j0l, j1, j1f, j1l, jn, jnf, jnl, labs, ldexp, ldexpf, ldexpl, lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, llabs, llrint, llrintf, llrintl, llround, llroundf, llroundl, log, log10, log10f, log10l, log1p, log1pf, log1pl, log2, log2f, log2l, logb, logbf, logbl, logf, logl, lrint, lrintf, lrintl, lround, lroundf, lroundl, malloc, memchr, memcmp, memcpy, mempcpy, memset, modf, modff, modfl, nearbyint, nearbyintf, nearbyintl, nextafter, nextafterf, nextafterl, nexttoward, nexttowardf, nexttowardl, pow, pow10, pow10f, pow10l, powf, powl, printf, printf_unlocked, putchar, puts, realloc, remainder, remainderf, remainderl, remquo, remquof, remquol, rindex, rint, rintf, rintl, round, roundf, roundl, scalb, scalbf, scalbl, scalbln, scalblnf, scalblnf, scalbn, scalbnf, scanfnl, signbit, signbitf, signbitl, signbitd32, signbitd64, signbitd128, significand, significandf, significandl, sin, sincos, sincosf, sincosl, sinf, sinh, sinhf, sinhl, sinl, snprintf, sprintf, sqrt, sqrtf, sqrtl, sscanf, stpcpy, stpncpy, strcasecmp, strcat, strchr, strcmp, strcpy, strcspn, strdup, strfmon, strftime, strlen, strncasecmp, strncat, strncmp, strncpy, strndup, strnlen, strpbrk, strrchr, strspn, strstr, tan, tanf, tanh, tanhf, tanhl, tanl, tgamma, tgammaf, tgammal, toascii, tolower, toupper, towlower, towupper, trunc, truncf, truncl, vfprintf, vfscanf, vprintf, vscanf, vsnprintf, vsprintf, vsscanf, y0, y0f, y0l, y1, y1f, y1l, yn, ynf, ynl + +.. _other-builtins: + +Other Built-in Functions Provided by GCC +**************************************** + +GCC provides a large number of built-in functions other than the ones +mentioned above. Some of these are for internal use in the processing +of exceptions or variable-length argument lists and are not +documented here because they may change from time to time; we do not +recommend general use of these functions. + +The remaining functions are provided for optimization purposes. + +With the exception of built-ins that have library equivalents such as +the standard C library functions discussed below, or that expand to +library calls, GCC built-in functions are always expanded inline and +thus do not have corresponding entry points and their address cannot +be obtained. Attempting to use them in an expression other than +a function call results in a compile-time error. + +.. index:: fno-builtin + +GCC includes built-in versions of many of the functions in the standard +C library. These functions come in two forms: one whose names start with +the ``__builtin_`` prefix, and the other without. Both forms have the +same type (including prototype), the same address (when their address is +taken), and the same meaning as the C library functions even if you specify +the :option:`-fno-builtin` option see :ref:`c-dialect-options`). Many of these +functions are only optimized in certain cases; if they are not optimized in +a particular case, a call to the library function is emitted. + +.. index:: ansi, std + +Outside strict ISO C mode (:option:`-ansi`, :option:`-std=c90`, +:option:`-std=c99` or :option:`-std=c11`), the functions +``_exit``, ``alloca``, ``bcmp``, ``bzero``, +``dcgettext``, ``dgettext``, ``dremf``, ``dreml``, +``drem``, ``exp10f``, ``exp10l``, ``exp10``, ``ffsll``, +``ffsl``, ``ffs``, ``fprintf_unlocked``, +``fputs_unlocked``, ``gammaf``, ``gammal``, ``gamma``, +``gammaf_r``, ``gammal_r``, ``gamma_r``, ``gettext``, +``index``, ``isascii``, ``j0f``, ``j0l``, ``j0``, +``j1f``, ``j1l``, ``j1``, ``jnf``, ``jnl``, ``jn``, +``lgammaf_r``, ``lgammal_r``, ``lgamma_r``, ``mempcpy``, +``pow10f``, ``pow10l``, ``pow10``, ``printf_unlocked``, +``rindex``, ``roundeven``, ``roundevenf``, ``roundevenl``, +``scalbf``, ``scalbl``, ``scalb``, +``signbit``, ``signbitf``, ``signbitl``, ``signbitd32``, +``signbitd64``, ``signbitd128``, ``significandf``, +``significandl``, ``significand``, ``sincosf``, +``sincosl``, ``sincos``, ``stpcpy``, ``stpncpy``, +``strcasecmp``, ``strdup``, ``strfmon``, ``strncasecmp``, +``strndup``, ``strnlen``, ``toascii``, ``y0f``, ``y0l``, +``y0``, ``y1f``, ``y1l``, ``y1``, ``ynf``, ``ynl`` and +``yn`` +may be handled as built-in functions. +All these functions have corresponding versions +prefixed with ``__builtin_``, which may be used even in strict C90 +mode. + +The ISO C99 functions +``_Exit``, ``acoshf``, ``acoshl``, ``acosh``, ``asinhf``, +``asinhl``, ``asinh``, ``atanhf``, ``atanhl``, ``atanh``, +``cabsf``, ``cabsl``, ``cabs``, ``cacosf``, ``cacoshf``, +``cacoshl``, ``cacosh``, ``cacosl``, ``cacos``, +``cargf``, ``cargl``, ``carg``, ``casinf``, ``casinhf``, +``casinhl``, ``casinh``, ``casinl``, ``casin``, +``catanf``, ``catanhf``, ``catanhl``, ``catanh``, +``catanl``, ``catan``, ``cbrtf``, ``cbrtl``, ``cbrt``, +``ccosf``, ``ccoshf``, ``ccoshl``, ``ccosh``, ``ccosl``, +``ccos``, ``cexpf``, ``cexpl``, ``cexp``, ``cimagf``, +``cimagl``, ``cimag``, ``clogf``, ``clogl``, ``clog``, +``conjf``, ``conjl``, ``conj``, ``copysignf``, ``copysignl``, +``copysign``, ``cpowf``, ``cpowl``, ``cpow``, ``cprojf``, +``cprojl``, ``cproj``, ``crealf``, ``creall``, ``creal``, +``csinf``, ``csinhf``, ``csinhl``, ``csinh``, ``csinl``, +``csin``, ``csqrtf``, ``csqrtl``, ``csqrt``, ``ctanf``, +``ctanhf``, ``ctanhl``, ``ctanh``, ``ctanl``, ``ctan``, +``erfcf``, ``erfcl``, ``erfc``, ``erff``, ``erfl``, +``erf``, ``exp2f``, ``exp2l``, ``exp2``, ``expm1f``, +``expm1l``, ``expm1``, ``fdimf``, ``fdiml``, ``fdim``, +``fmaf``, ``fmal``, ``fmaxf``, ``fmaxl``, ``fmax``, +``fma``, ``fminf``, ``fminl``, ``fmin``, ``hypotf``, +``hypotl``, ``hypot``, ``ilogbf``, ``ilogbl``, ``ilogb``, +``imaxabs``, ``isblank``, ``iswblank``, ``lgammaf``, +``lgammal``, ``lgamma``, ``llabs``, ``llrintf``, ``llrintl``, +``llrint``, ``llroundf``, ``llroundl``, ``llround``, +``log1pf``, ``log1pl``, ``log1p``, ``log2f``, ``log2l``, +``log2``, ``logbf``, ``logbl``, ``logb``, ``lrintf``, +``lrintl``, ``lrint``, ``lroundf``, ``lroundl``, +``lround``, ``nearbyintf``, ``nearbyintl``, ``nearbyint``, +``nextafterf``, ``nextafterl``, ``nextafter``, +``nexttowardf``, ``nexttowardl``, ``nexttoward``, +``remainderf``, ``remainderl``, ``remainder``, ``remquof``, +``remquol``, ``remquo``, ``rintf``, ``rintl``, ``rint``, +``roundf``, ``roundl``, ``round``, ``scalblnf``, +``scalblnl``, ``scalbln``, ``scalbnf``, ``scalbnl``, +``scalbn``, ``snprintf``, ``tgammaf``, ``tgammal``, +``tgamma``, ``truncf``, ``truncl``, ``trunc``, +``vfscanf``, ``vscanf``, ``vsnprintf`` and ``vsscanf`` +are handled as built-in functions +except in strict ISO C90 mode (:option:`-ansi` or :option:`-std=c90`). + +There are also built-in versions of the ISO C99 functions +``acosf``, ``acosl``, ``asinf``, ``asinl``, ``atan2f``, +``atan2l``, ``atanf``, ``atanl``, ``ceilf``, ``ceill``, +``cosf``, ``coshf``, ``coshl``, ``cosl``, ``expf``, +``expl``, ``fabsf``, ``fabsl``, ``floorf``, ``floorl``, +``fmodf``, ``fmodl``, ``frexpf``, ``frexpl``, ``ldexpf``, +``ldexpl``, ``log10f``, ``log10l``, ``logf``, ``logl``, +``modfl``, ``modff``, ``powf``, ``powl``, ``sinf``, +``sinhf``, ``sinhl``, ``sinl``, ``sqrtf``, ``sqrtl``, +``tanf``, ``tanhf``, ``tanhl`` and ``tanl`` +that are recognized in any mode since ISO C90 reserves these names for +the purpose to which ISO C99 puts them. All these functions have +corresponding versions prefixed with ``__builtin_``. + +There are also built-in functions ``__builtin_fabsfn``, +``__builtin_fabsfnx``, ``__builtin_copysignfn`` and +``__builtin_copysignfnx``, corresponding to the TS 18661-3 +functions ``fabsfn``, ``fabsfnx``, +``copysignfn`` and ``copysignfnx``, for supported +types ``_Floatn`` and ``_Floatnx``. + +There are also GNU extension functions ``clog10``, ``clog10f`` and +``clog10l`` which names are reserved by ISO C99 for future use. +All these functions have versions prefixed with ``__builtin_``. + +The ISO C94 functions +``iswalnum``, ``iswalpha``, ``iswcntrl``, ``iswdigit``, +``iswgraph``, ``iswlower``, ``iswprint``, ``iswpunct``, +``iswspace``, ``iswupper``, ``iswxdigit``, ``towlower`` and +``towupper`` +are handled as built-in functions +except in strict ISO C90 mode (:option:`-ansi` or :option:`-std=c90`). + +The ISO C90 functions +``abort``, ``abs``, ``acos``, ``asin``, ``atan2``, +``atan``, ``calloc``, ``ceil``, ``cosh``, ``cos``, +``exit``, ``exp``, ``fabs``, ``floor``, ``fmod``, +``fprintf``, ``fputs``, ``free``, ``frexp``, ``fscanf``, +``isalnum``, ``isalpha``, ``iscntrl``, ``isdigit``, +``isgraph``, ``islower``, ``isprint``, ``ispunct``, +``isspace``, ``isupper``, ``isxdigit``, ``tolower``, +``toupper``, ``labs``, ``ldexp``, ``log10``, ``log``, +``malloc``, ``memchr``, ``memcmp``, ``memcpy``, +``memset``, ``modf``, ``pow``, ``printf``, ``putchar``, +``puts``, ``realloc``, ``scanf``, ``sinh``, ``sin``, +``snprintf``, ``sprintf``, ``sqrt``, ``sscanf``, ``strcat``, +``strchr``, ``strcmp``, ``strcpy``, ``strcspn``, +``strlen``, ``strncat``, ``strncmp``, ``strncpy``, +``strpbrk``, ``strrchr``, ``strspn``, ``strstr``, +``tanh``, ``tan``, ``vfprintf``, ``vprintf`` and ``vsprintf`` +are all recognized as built-in functions unless +:option:`-fno-builtin` is specified (or :option:`-fno-builtin-function` +is specified for an individual function). All of these functions have +corresponding versions prefixed with ``__builtin_``. + +GCC provides built-in versions of the ISO C99 floating-point comparison +macros that avoid raising exceptions for unordered operands. They have +the same names as the standard macros ( ``isgreater``, +``isgreaterequal``, ``isless``, ``islessequal``, +``islessgreater``, and ``isunordered``) , with ``__builtin_`` +prefixed. We intend for a library implementor to be able to simply +``#define`` each standard macro to its built-in equivalent. +In the same fashion, GCC provides ``fpclassify``, ``isfinite``, +``isinf_sign``, ``isnormal`` and ``signbit`` built-ins used with +``__builtin_`` prefixed. The ``isinf`` and ``isnan`` +built-in functions appear both with and without the ``__builtin_`` prefix. +With ``-ffinite-math-only`` option the ``isinf`` and ``isnan`` +built-in functions will always return 0. + +GCC provides built-in versions of the ISO C99 floating-point rounding and +exceptions handling functions ``fegetround``, ``feclearexcept`` and +``feraiseexcept``. They may not be available for all targets, and because +they need close interaction with libc internal values, they may not be available +for all target libcs, but in all cases they will gracefully fallback to libc +calls. These built-in functions appear both with and without the +``__builtin_`` prefix. + +.. function:: void *__builtin_alloca (size_t size) + + The ``__builtin_alloca`` function must be called at block scope. + The function allocates an object :samp:`{size}` bytes large on the stack + of the calling function. The object is aligned on the default stack + alignment boundary for the target determined by the + ``__BIGGEST_ALIGNMENT__`` macro. The ``__builtin_alloca`` + function returns a pointer to the first byte of the allocated object. + The lifetime of the allocated object ends just before the calling + function returns to its caller. This is so even when + ``__builtin_alloca`` is called within a nested block. + + For example, the following function allocates eight objects of ``n`` + bytes each on the stack, storing a pointer to each in consecutive elements + of the array ``a``. It then passes the array to function ``g`` + which can safely use the storage pointed to by each of the array elements. + + .. code-block:: c++ + + void f (unsigned n) + { + void *a [8]; + for (int i = 0; i != 8; ++i) + a [i] = __builtin_alloca (n); + + g (a, n); // safe + } + + Since the ``__builtin_alloca`` function doesn't validate its argument + it is the responsibility of its caller to make sure the argument doesn't + cause it to exceed the stack size limit. + The ``__builtin_alloca`` function is provided to make it possible to + allocate on the stack arrays of bytes with an upper bound that may be + computed at run time. Since C99 Variable Length Arrays offer + similar functionality under a portable, more convenient, and safer + interface they are recommended instead, in both C99 and C++ programs + where GCC provides them as an extension. + See :ref:`variable-length`, for details. + +.. function:: void *__builtin_alloca_with_align (size_t size, size_t alignment) + + The ``__builtin_alloca_with_align`` function must be called at block + scope. The function allocates an object :samp:`{size}` bytes large on + the stack of the calling function. The allocated object is aligned on + the boundary specified by the argument :samp:`{alignment}` whose unit is given + in bits (not bytes). The :samp:`{size}` argument must be positive and not + exceed the stack size limit. The :samp:`{alignment}` argument must be a constant + integer expression that evaluates to a power of 2 greater than or equal to + ``CHAR_BIT`` and less than some unspecified maximum. Invocations + with other values are rejected with an error indicating the valid bounds. + The function returns a pointer to the first byte of the allocated object. + The lifetime of the allocated object ends at the end of the block in which + the function was called. The allocated storage is released no later than + just before the calling function returns to its caller, but may be released + at the end of the block in which the function was called. + + For example, in the following function the call to ``g`` is unsafe + because when ``overalign`` is non-zero, the space allocated by + ``__builtin_alloca_with_align`` may have been released at the end + of the ``if`` statement in which it was called. + + .. code-block:: c++ + + void f (unsigned n, bool overalign) + { + void *p; + if (overalign) + p = __builtin_alloca_with_align (n, 64 /* bits */); + else + p = __builtin_alloc (n); + + g (p, n); // unsafe + } + + Since the ``__builtin_alloca_with_align`` function doesn't validate its + :samp:`{size}` argument it is the responsibility of its caller to make sure + the argument doesn't cause it to exceed the stack size limit. + The ``__builtin_alloca_with_align`` function is provided to make + it possible to allocate on the stack overaligned arrays of bytes with + an upper bound that may be computed at run time. Since C99 + Variable Length Arrays offer the same functionality under + a portable, more convenient, and safer interface they are recommended + instead, in both C99 and C++ programs where GCC provides them as + an extension. See :ref:`variable-length`, for details. + +.. function:: void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size) + + Similar to ``__builtin_alloca_with_align`` but takes an extra argument + specifying an upper bound for :samp:`{size}` in case its value cannot be computed + at compile time, for use by :option:`-fstack-usage`, :option:`-Wstack-usage` + and :option:`-Walloca-larger-than`. :samp:`{max_size}` must be a constant integer + expression, it has no effect on code generation and no attempt is made to + check its compatibility with :samp:`{size}`. + +.. function:: bool __builtin_has_attribute (type_or_expression, attribute) + + The ``__builtin_has_attribute`` function evaluates to an integer constant + expression equal to ``true`` if the symbol or type referenced by + the :samp:`{type_or_expression}` argument has been declared with + the :samp:`{attribute}` referenced by the second argument. For + an :samp:`{type_or_expression}` argument that does not reference a symbol, + since attributes do not apply to expressions the built-in consider + the type of the argument. Neither argument is evaluated. + The :samp:`{type_or_expression}` argument is subject to the same + restrictions as the argument to ``typeof`` (see :ref:`typeof`). The + :samp:`{attribute}` argument is an attribute name optionally followed by + a comma-separated list of arguments enclosed in parentheses. Both forms + of attribute names---with and without double leading and trailing + underscores---are recognized. See :ref:`attribute-syntax`, for details. + When no attribute arguments are specified for an attribute that expects + one or more arguments the function returns ``true`` if + :samp:`{type_or_expression}` has been declared with the attribute regardless + of the attribute argument values. Arguments provided for an attribute + that expects some are validated and matched up to the provided number. + The function returns ``true`` if all provided arguments match. For + example, the first call to the function below evaluates to ``true`` + because ``x`` is declared with the :type-attr:`aligned` attribute but + the second call evaluates to ``false`` because ``x`` is declared + ``aligned (8)`` and not ``aligned (4)``. + + .. code-block:: c++ + + __attribute__ ((aligned (8))) int x; + _Static_assert (__builtin_has_attribute (x, aligned), "aligned"); + _Static_assert (!__builtin_has_attribute (x, aligned (4)), "aligned (4)"); + + Due to a limitation the ``__builtin_has_attribute`` function returns + ``false`` for the ``mode`` attribute even if the type or variable + referenced by the :samp:`{type_or_expression}` argument was declared with one. + The function is also not supported with labels, and in C with enumerators. + + Note that unlike the ``__has_attribute`` preprocessor operator which + is suitable for use in ``#if`` preprocessing directives + ``__builtin_has_attribute`` is an intrinsic function that is not + recognized in such contexts. + +.. function:: type __builtin_speculation_safe_value (type val, type failval) + + This built-in function can be used to help mitigate against unsafe + speculative execution. :samp:`{type}` may be any integral type or any + pointer type. + + * If the CPU is not speculatively executing the code, then :samp:`{val}` + is returned. + + * If the CPU is executing speculatively then either: + + * The function may cause execution to pause until it is known that the + code is no-longer being executed speculatively (in which case + :samp:`{val}` can be returned, as above); or + + * The function may use target-dependent speculation tracking state to cause + :samp:`{failval}` to be returned when it is known that speculative + execution has incorrectly predicted a conditional branch operation. + + The second argument, :samp:`{failval}`, is optional and defaults to zero + if omitted. + + GCC defines the preprocessor macro + ``__HAVE_BUILTIN_SPECULATION_SAFE_VALUE`` for targets that have been + updated to support this builtin. + + The built-in function can be used where a variable appears to be used in a + safe way, but the CPU, due to speculative execution may temporarily ignore + the bounds checks. Consider, for example, the following function: + + .. code-block:: c++ + + int array[500]; + int f (unsigned untrusted_index) + { + if (untrusted_index < 500) + return array[untrusted_index]; + return 0; + } + + If the function is called repeatedly with ``untrusted_index`` less + than the limit of 500, then a branch predictor will learn that the + block of code that returns a value stored in ``array`` will be + executed. If the function is subsequently called with an + out-of-range value it will still try to execute that block of code + first until the CPU determines that the prediction was incorrect + (the CPU will unwind any incorrect operations at that point). + However, depending on how the result of the function is used, it might be + possible to leave traces in the cache that can reveal what was stored + at the out-of-bounds location. The built-in function can be used to + provide some protection against leaking data in this way by changing + the code to: + + .. code-block:: c++ + + int array[500]; + int f (unsigned untrusted_index) + { + if (untrusted_index < 500) + return array[__builtin_speculation_safe_value (untrusted_index)]; + return 0; + } + + The built-in function will either cause execution to stall until the + conditional branch has been fully resolved, or it may permit + speculative execution to continue, but using 0 instead of + ``untrusted_value`` if that exceeds the limit. + + If accessing any memory location is potentially unsafe when speculative + execution is incorrect, then the code can be rewritten as + + .. code-block:: c++ + + int array[500]; + int f (unsigned untrusted_index) + { + if (untrusted_index < 500) + return *__builtin_speculation_safe_value (&array[untrusted_index], NULL); + return 0; + } + + which will cause a ``NULL`` pointer to be used for the unsafe case. + +.. function:: int __builtin_types_compatible_p (type1, type2) + + You can use the built-in function ``__builtin_types_compatible_p`` to + determine whether two types are the same. + + This built-in function returns 1 if the unqualified versions of the + types :samp:`{type1}` and :samp:`{type2}` (which are types, not expressions) are + compatible, 0 otherwise. The result of this built-in function can be + used in integer constant expressions. + + This built-in function ignores top level qualifiers (e.g., ``const``, + ``volatile``). For example, ``int`` is equivalent to ``const + int``. + + The type ``int[]`` and ``int[5]`` are compatible. On the other + hand, ``int`` and ``char *`` are not compatible, even if the size + of their types, on the particular architecture are the same. Also, the + amount of pointer indirection is taken into account when determining + similarity. Consequently, ``short *`` is not similar to + ``short **``. Furthermore, two types that are typedefed are + considered compatible if their underlying types are compatible. + + An ``enum`` type is not considered to be compatible with another + ``enum`` type even if both are compatible with the same integer + type; this is what the C standard specifies. + For example, ``enum {foo, bar}`` is not similar to + ``enum {hot, dog}``. + + You typically use this function in code whose execution varies + depending on the arguments' types. For example: + + .. code-block:: c++ + + #define foo(x) \ + ({ \ + typeof (x) tmp = (x); \ + if (__builtin_types_compatible_p (typeof (x), long double)) \ + tmp = foo_long_double (tmp); \ + else if (__builtin_types_compatible_p (typeof (x), double)) \ + tmp = foo_double (tmp); \ + else if (__builtin_types_compatible_p (typeof (x), float)) \ + tmp = foo_float (tmp); \ + else \ + abort (); \ + tmp; \ + }) + + .. note:: + + This construct is only available for C. + +.. function:: type __builtin_call_with_static_chain (call_exp, pointer_exp) + + The :samp:`{call_exp}` expression must be a function call, and the + :samp:`{pointer_exp}` expression must be a pointer. The :samp:`{pointer_exp}` + is passed to the function call in the target's static chain location. + The result of builtin is the result of the function call. + + .. note:: + + This builtin is only available for C. + + This builtin can be used to call Go closures from C. + +.. function:: type __builtin_choose_expr (const_exp, exp1, exp2) + + You can use the built-in function ``__builtin_choose_expr`` to + evaluate code depending on the value of a constant expression. This + built-in function returns :samp:`{exp1}` if :samp:`{const_exp}`, which is an + integer constant expression, is nonzero. Otherwise it returns :samp:`{exp2}`. + + This built-in function is analogous to the :samp:`? :` operator in C, + except that the expression returned has its type unaltered by promotion + rules. Also, the built-in function does not evaluate the expression + that is not chosen. For example, if :samp:`{const_exp}` evaluates to ``true``, + :samp:`{exp2}` is not evaluated even if it has side effects. + + This built-in function can return an lvalue if the chosen argument is an + lvalue. + + If :samp:`{exp1}` is returned, the return type is the same as :samp:`{exp1}` 's + type. Similarly, if :samp:`{exp2}` is returned, its return type is the same + as :samp:`{exp2}`. + + Example: + + .. code-block:: c++ + + #define foo(x) \ + __builtin_choose_expr ( \ + __builtin_types_compatible_p (typeof (x), double), \ + foo_double (x), \ + __builtin_choose_expr ( \ + __builtin_types_compatible_p (typeof (x), float), \ + foo_float (x), \ + /* The void expression results in a compile-time error \ + when assigning the result to something. */ \ + (void)0)) + + .. note:: + + This construct is only available for C. Furthermore, the + unused expression (:samp:`{exp1}` or :samp:`{exp2}` depending on the value of + :samp:`{const_exp}`) may still generate syntax errors. This may change in + future revisions. + +.. function:: type __builtin_tgmath (functions, arguments) + + The built-in function ``__builtin_tgmath``, available only for C + and Objective-C, calls a function determined according to the rules of + ```` macros. It is intended to be used in + implementations of that header, so that expansions of macros from that + header only expand each of their arguments once, to avoid problems + when calls to such macros are nested inside the arguments of other + calls to such macros; in addition, it results in better diagnostics + for invalid calls to ```` macros than implementations + using other GNU C language features. For example, the ``pow`` + type-generic macro might be defined as: + + .. code-block:: c++ + + #define pow(a, b) __builtin_tgmath (powf, pow, powl, \ + cpowf, cpow, cpowl, a, b) + + The arguments to ``__builtin_tgmath`` are at least two pointers to + functions, followed by the arguments to the type-generic macro (which + will be passed as arguments to the selected function). All the + pointers to functions must be pointers to prototyped functions, none + of which may have variable arguments, and all of which must have the + same number of parameters; the number of parameters of the first + function determines how many arguments to ``__builtin_tgmath`` are + interpreted as function pointers, and how many as the arguments to the + called function. + + The types of the specified functions must all be different, but + related to each other in the same way as a set of functions that may + be selected between by a macro in ````. This means that + the functions are parameterized by a floating-point type :samp:`{t}`, + different for each such function. The function return types may all + be the same type, or they may be :samp:`{t}` for each function, or they + may be the real type corresponding to :samp:`{t}` for each function (if + some of the types :samp:`{t}` are complex). Likewise, for each parameter + position, the type of the parameter in that position may always be the + same type, or may be :samp:`{t}` for each function (this case must apply + for at least one parameter position), or may be the real type + corresponding to :samp:`{t}` for each function. + + The standard rules for ```` macros are used to find a + common type :samp:`{u}` from the types of the arguments for parameters + whose types vary between the functions; complex integer types (a GNU + extension) are treated like ``_Complex double`` for this purpose + (or ``_Complex _Float64`` if all the function return types are the + same ``_Floatn`` or ``_Floatnx`` type). + If the function return types vary, or are all the same integer type, + the function called is the one for which :samp:`{t}` is :samp:`{u}`, and it is + an error if there is no such function. If the function return types + are all the same floating-point type, the type-generic macro is taken + to be one of those from TS 18661 that rounds the result to a narrower + type; if there is a function for which :samp:`{t}` is :samp:`{u}`, it is + called, and otherwise the first function, if any, for which :samp:`{t}` + has at least the range and precision of :samp:`{u}` is called, and it is + an error if there is no such function. + +.. function:: int __builtin_constant_p (exp) + + You can use the built-in function ``__builtin_constant_p`` to + determine if a value is known to be constant at compile time and hence + that GCC can perform constant-folding on expressions involving that + value. The argument of the function is the value to test. The function + returns the integer 1 if the argument is known to be a compile-time + constant and 0 if it is not known to be a compile-time constant. A + return of 0 does not indicate that the value is *not* a constant, + but merely that GCC cannot prove it is a constant with the specified + value of the :option:`-O` option. + + You typically use this function in an embedded application where + memory is a critical resource. If you have some complex calculation, + you may want it to be folded if it involves constants, but need to call + a function if it does not. For example: + + .. code-block:: c++ + + #define Scale_Value(X) \ + (__builtin_constant_p (X) \ + ? ((X) * SCALE + OFFSET) : Scale (X)) + + You may use this built-in function in either a macro or an inline + function. However, if you use it in an inlined function and pass an + argument of the function as the argument to the built-in, GCC + never returns 1 when you call the inline function with a string constant + or compound literal (see :ref:`compound-literals`) and does not return 1 + when you pass a constant numeric value to the inline function unless you + specify the :option:`-O` option. + + You may also use ``__builtin_constant_p`` in initializers for static + data. For instance, you can write + + .. code-block:: c++ + + static const int table[] = { + __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1, + /* ... */ + }; + + This is an acceptable initializer even if :samp:`{EXPRESSION}` is not a + constant expression, including the case where + ``__builtin_constant_p`` returns 1 because :samp:`{EXPRESSION}` can be + folded to a constant but :samp:`{EXPRESSION}` contains operands that are + not otherwise permitted in a static initializer (for example, + ``0 && foo ()``). GCC must be more conservative about evaluating the + built-in in this case, because it has no opportunity to perform + optimization. + +.. function:: bool __builtin_is_constant_evaluated (void) + + The ``__builtin_is_constant_evaluated`` function is available only + in C++. The built-in is intended to be used by implementations of + the ``std::is_constant_evaluated`` C++ function. Programs should make + use of the latter function rather than invoking the built-in directly. + + The main use case of the built-in is to determine whether a ``constexpr`` + function is being called in a ``constexpr`` context. A call to + the function evaluates to a core constant expression with the value + ``true`` if and only if it occurs within the evaluation of an expression + or conversion that is manifestly constant-evaluated as defined in the C++ + standard. Manifestly constant-evaluated contexts include constant-expressions, + the conditions of ``constexpr if`` statements, constraint-expressions, and + initializers of variables usable in constant expressions. For more details + refer to the latest revision of the C++ standard. + +.. function:: void __builtin_clear_padding (ptr) + + The built-in function ``__builtin_clear_padding`` function clears + padding bits inside of the object representation of object pointed by + :samp:`{ptr}`, which has to be a pointer. The value representation of the + object is not affected. The type of the object is assumed to be the type + the pointer points to. Inside of a union, the only cleared bits are + bits that are padding bits for all the union members. + + This built-in-function is useful if the padding bits of an object might + have intederminate values and the object representation needs to be + bitwise compared to some other object, for example for atomic operations. + + For C++, :samp:`{ptr}` argument type should be pointer to trivially-copyable + type, unless the argument is address of a variable or parameter, because + otherwise it isn't known if the type isn't just a base class whose padding + bits are reused or laid out differently in a derived class. + +.. function:: type __builtin_bit_cast (type, arg) + + The ``__builtin_bit_cast`` function is available only + in C++. The built-in is intended to be used by implementations of + the ``std::bit_cast`` C++ template function. Programs should make + use of the latter function rather than invoking the built-in directly. + + This built-in function allows reinterpreting the bits of the :samp:`{arg}` + argument as if it had type :samp:`{type}`. :samp:`{type}` and the type of the + :samp:`{arg}` argument need to be trivially copyable types with the same size. + When manifestly constant-evaluated, it performs extra diagnostics required + for ``std::bit_cast`` and returns a constant expression if :samp:`{arg}` + is a constant expression. For more details + refer to the latest revision of the C++ standard. + +.. function:: long __builtin_expect (long exp, long c) + + .. index:: fprofile-arcs + + You may use ``__builtin_expect`` to provide the compiler with + branch prediction information. In general, you should prefer to + use actual profile feedback for this (:option:`-fprofile-arcs`), as + programmers are notoriously bad at predicting how their programs + actually perform. However, there are applications in which this + data is hard to collect. + + The return value is the value of :samp:`{exp}`, which should be an integral + expression. The semantics of the built-in are that it is expected that + :samp:`{exp}` == :samp:`{c}`. For example: + + .. code-block:: c++ + + if (__builtin_expect (x, 0)) + foo (); + + indicates that we do not expect to call ``foo``, since + we expect ``x`` to be zero. Since you are limited to integral + expressions for :samp:`{exp}`, you should use constructions such as + + .. code-block:: c++ + + if (__builtin_expect (ptr != NULL, 1)) + foo (*ptr); + + when testing pointer or floating-point values. + + For the purposes of branch prediction optimizations, the probability that + a ``__builtin_expect`` expression is ``true`` is controlled by GCC's + ``builtin-expect-probability`` parameter, which defaults to 90%. + + You can also use ``__builtin_expect_with_probability`` to explicitly + assign a probability value to individual expressions. If the built-in + is used in a loop construct, the provided probability will influence + the expected number of iterations made by loop optimizations. + +.. function:: long __builtin_expect_with_probability (long exp, long c, double probability) + + This function has the same semantics as ``__builtin_expect``, + but the caller provides the expected probability that :samp:`{exp}` == :samp:`{c}`. + The last argument, :samp:`{probability}`, is a floating-point value in the + range 0.0 to 1.0, inclusive. The :samp:`{probability}` argument must be + constant floating-point expression. + +.. function:: void __builtin_trap (void) + + This function causes the program to exit abnormally. GCC implements + this function by using a target-dependent mechanism (such as + intentionally executing an illegal instruction) or by calling + ``abort``. The mechanism used may vary from release to release so + you should not rely on any particular implementation. + +.. function:: void __builtin_unreachable (void) + + If control flow reaches the point of the ``__builtin_unreachable``, + the program is undefined. It is useful in situations where the + compiler cannot deduce the unreachability of the code. + + One such case is immediately following an ``asm`` statement that + either never terminates, or one that transfers control elsewhere + and never returns. In this example, without the + ``__builtin_unreachable``, GCC issues a warning that control + reaches the end of a non-void function. It also generates code + to return after the ``asm``. + + .. code-block:: c++ + + int f (int c, int v) + { + if (c) + { + return v; + } + else + { + asm("jmp error_handler"); + __builtin_unreachable (); + } + } + + Because the ``asm`` statement unconditionally transfers control out + of the function, control never reaches the end of the function + body. The ``__builtin_unreachable`` is in fact unreachable and + communicates this fact to the compiler. + + Another use for ``__builtin_unreachable`` is following a call a + function that never returns but that is not declared + ``__attribute__((noreturn))``, as in this example: + + .. code-block:: c++ + + void function_that_never_returns (void); + + int g (int c) + { + if (c) + { + return 1; + } + else + { + function_that_never_returns (); + __builtin_unreachable (); + } + } + +.. function:: type __builtin_assoc_barrier (type expr) + + This built-in inhibits re-association of the floating-point expression + :samp:`{expr}` with expressions consuming the return value of the built-in. The + expression :samp:`{expr}` itself can be reordered, and the whole expression + :samp:`{expr}` can be reordered with operands after the barrier. The barrier is + only relevant when ``-fassociative-math`` is active, since otherwise + floating-point is not treated as associative. + + .. code-block:: c++ + + float x0 = a + b - b; + float x1 = __builtin_assoc_barrier(a + b) - b; + + means that, with ``-fassociative-math``, ``x0`` can be optimized to + ``x0 = a`` but ``x1`` cannot. + +.. function:: void * __builtin_assume_aligned (const void *exp, size_t align, ...) + + This function returns its first argument, and allows the compiler + to assume that the returned pointer is at least :samp:`{align}` bytes + aligned. This built-in can have either two or three arguments, + if it has three, the third argument should have integer type, and + if it is nonzero means misalignment offset. For example: + + .. code-block:: c++ + + void *x = __builtin_assume_aligned (arg, 16); + + means that the compiler can assume ``x``, set to ``arg``, is at least + 16-byte aligned, while: + + .. code-block:: c++ + + void *x = __builtin_assume_aligned (arg, 32, 8); + + means that the compiler can assume for ``x``, set to ``arg``, that + ``(char *) x - 8`` is 32-byte aligned. + +.. function:: int __builtin_LINE () + + This function is the equivalent of the preprocessor ``__LINE__`` + macro and returns a constant integer expression that evaluates to + the line number of the invocation of the built-in. When used as a C++ + default argument for a function :samp:`{F}`, it returns the line number + of the call to :samp:`{F}`. + +.. function:: const char * __builtin_FUNCTION () + + This function is the equivalent of the ``__FUNCTION__`` symbol + and returns an address constant pointing to the name of the function + from which the built-in was invoked, or the empty string if + the invocation is not at function scope. When used as a C++ default + argument for a function :samp:`{F}`, it returns the name of :samp:`{F}` 's + caller or the empty string if the call was not made at function + scope. + +.. function:: const char * __builtin_FILE () + + This function is the equivalent of the preprocessor ``__FILE__`` + macro and returns an address constant pointing to the file name + containing the invocation of the built-in, or the empty string if + the invocation is not at function scope. When used as a C++ default + argument for a function :samp:`{F}`, it returns the file name of the call + to :samp:`{F}` or the empty string if the call was not made at function + scope. + + For example, in the following, each call to function ``foo`` will + print a line similar to ``"file.c:123: foo: message"`` with the name + of the file and the line number of the ``printf`` call, the name of + the function ``foo``, followed by the word ``message``. + + .. code-block:: c++ + + const char* + function (const char *func = __builtin_FUNCTION ()) + { + return func; + } + + void foo (void) + { + printf ("%s:%i: %s: message\n", file (), line (), function ()); + } + +.. function:: void __builtin___clear_cache (void *begin, void *end) + + This function is used to flush the processor's instruction cache for + the region of memory between :samp:`{begin}` inclusive and :samp:`{end}` + exclusive. Some targets require that the instruction cache be + flushed, after modifying memory containing code, in order to obtain + deterministic behavior. + + If the target does not require instruction cache flushes, + ``__builtin___clear_cache`` has no effect. Otherwise either + instructions are emitted in-line to clear the instruction cache or a + call to the ``__clear_cache`` function in libgcc is made. + +.. function:: void __builtin_prefetch (const void *addr, ...) + + This function is used to minimize cache-miss latency by moving data into + a cache before it is accessed. + You can insert calls to ``__builtin_prefetch`` into code for which + you know addresses of data in memory that is likely to be accessed soon. + If the target supports them, data prefetch instructions are generated. + If the prefetch is done early enough before the access then the data will + be in the cache by the time it is accessed. + + The value of :samp:`{addr}` is the address of the memory to prefetch. + There are two optional arguments, :samp:`{rw}` and :samp:`{locality}`. + The value of :samp:`{rw}` is a compile-time constant one or zero; one + means that the prefetch is preparing for a write to the memory address + and zero, the default, means that the prefetch is preparing for a read. + The value :samp:`{locality}` must be a compile-time constant integer between + zero and three. A value of zero means that the data has no temporal + locality, so it need not be left in the cache after the access. A value + of three means that the data has a high degree of temporal locality and + should be left in all levels of cache possible. Values of one and two + mean, respectively, a low or moderate degree of temporal locality. The + default is three. + + .. code-block:: c++ + + for (i = 0; i < n; i++) + { + a[i] = a[i] + b[i]; + __builtin_prefetch (&a[i+j], 1, 1); + __builtin_prefetch (&b[i+j], 0, 1); + /* ... */ + } + + Data prefetch does not generate faults if :samp:`{addr}` is invalid, but + the address expression itself must be valid. For example, a prefetch + of ``p->next`` does not fault if ``p->next`` is not a valid + address, but evaluation faults if ``p`` is not a valid address. + + If the target does not support data prefetch, the address expression + is evaluated if it includes side effects but no other code is generated + and GCC does not issue a warning. + +.. function:: size_t __builtin_object_size (const void * ptr, int type) + + Returns the size of an object pointed to by :samp:`{ptr}`. See :ref:`object-size-checking`, for a detailed description of the function. + +.. function:: double __builtin_huge_val (void) + + Returns a positive infinity, if supported by the floating-point format, + else ``DBL_MAX``. This function is suitable for implementing the + ISO C macro ``HUGE_VAL``. + +.. function:: float __builtin_huge_valf (void) + + Similar to ``__builtin_huge_val``, except the return type is ``float``. + +.. function:: long double __builtin_huge_vall (void) + + Similar to ``__builtin_huge_val``, except the return + type is ``long double``. + +.. function:: _Floatn __builtin_huge_valfn (void) + + Similar to ``__builtin_huge_val``, except the return type is + ``_Floatn``. + +.. function:: _Floatnx __builtin_huge_valfnx (void) + + Similar to ``__builtin_huge_val``, except the return type is + ``_Floatnx``. + +.. function:: int __builtin_fpclassify (int, int, int, int, int, ...) + + This built-in implements the C99 fpclassify functionality. The first + five int arguments should be the target library's notion of the + possible FP classes and are used for return values. They must be + constant values and they must appear in this order: ``FP_NAN``, + ``FP_INFINITE``, ``FP_NORMAL``, ``FP_SUBNORMAL`` and + ``FP_ZERO``. The ellipsis is for exactly one floating-point value + to classify. GCC treats the last argument as type-generic, which + means it does not do default promotion from float to double. + +.. function:: double __builtin_inf (void) + + Similar to ``__builtin_huge_val``, except a warning is generated + if the target floating-point format does not support infinities. + +.. function:: _Decimal32 __builtin_infd32 (void) + + Similar to ``__builtin_inf``, except the return type is ``_Decimal32``. + +.. function:: _Decimal64 __builtin_infd64 (void) + + Similar to ``__builtin_inf``, except the return type is ``_Decimal64``. + +.. function:: _Decimal128 __builtin_infd128 (void) + + Similar to ``__builtin_inf``, except the return type is ``_Decimal128``. + +.. function:: float __builtin_inff (void) + + Similar to ``__builtin_inf``, except the return type is ``float``. + This function is suitable for implementing the ISO C99 macro ``INFINITY``. + +.. function:: long double __builtin_infl (void) + + Similar to ``__builtin_inf``, except the return + type is ``long double``. + +.. function:: _Floatn __builtin_inffn (void) + + Similar to ``__builtin_inf``, except the return + type is ``_Floatn``. + +.. function:: _Floatn __builtin_inffnx (void) + + Similar to ``__builtin_inf``, except the return + type is ``_Floatnx``. + +.. function:: int __builtin_isinf_sign (...) + + Similar to ``isinf``, except the return value is -1 for + an argument of ``-Inf`` and 1 for an argument of ``+Inf``. + Note while the parameter list is an + ellipsis, this function only accepts exactly one floating-point + argument. GCC treats this parameter as type-generic, which means it + does not do default promotion from float to double. + +.. function:: double __builtin_nan (const char *str) + + This is an implementation of the ISO C99 function ``nan``. + + Since ISO C99 defines this function in terms of ``strtod``, which we + do not implement, a description of the parsing is in order. The string + is parsed as by ``strtol`` ; that is, the base is recognized by + leading :samp:`0` or :samp:`0x` prefixes. The number parsed is placed + in the significand such that the least significant bit of the number + is at the least significant bit of the significand. The number is + truncated to fit the significand field provided. The significand is + forced to be a quiet NaN. + + This function, if given a string literal all of which would have been + consumed by ``strtol``, is evaluated early enough that it is considered a + compile-time constant. + +.. function:: _Decimal32 __builtin_nand32 (const char *str) + + Similar to ``__builtin_nan``, except the return type is ``_Decimal32``. + +.. function:: _Decimal64 __builtin_nand64 (const char *str) + + Similar to ``__builtin_nan``, except the return type is ``_Decimal64``. + +.. function:: _Decimal128 __builtin_nand128 (const char *str) + + Similar to ``__builtin_nan``, except the return type is ``_Decimal128``. + +.. function:: float __builtin_nanf (const char *str) + + Similar to ``__builtin_nan``, except the return type is ``float``. + +.. function:: long double __builtin_nanl (const char *str) + + Similar to ``__builtin_nan``, except the return type is ``long double``. + +.. function:: _Floatn __builtin_nanfn (const char *str) + + Similar to ``__builtin_nan``, except the return type is + ``_Floatn``. + +.. function:: _Floatnx __builtin_nanfnx (const char *str) + + Similar to ``__builtin_nan``, except the return type is + ``_Floatnx``. + +.. function:: double __builtin_nans (const char *str) + + Similar to ``__builtin_nan``, except the significand is forced + to be a signaling NaN. The ``nans`` function is proposed by + `WG14 N965 `_. + +.. function:: _Decimal32 __builtin_nansd32 (const char *str) + + Similar to ``__builtin_nans``, except the return type is ``_Decimal32``. + +.. function:: _Decimal64 __builtin_nansd64 (const char *str) + + Similar to ``__builtin_nans``, except the return type is ``_Decimal64``. + +.. function:: _Decimal128 __builtin_nansd128 (const char *str) + + Similar to ``__builtin_nans``, except the return type is ``_Decimal128``. + +.. function:: float __builtin_nansf (const char *str) + + Similar to ``__builtin_nans``, except the return type is ``float``. + +.. function:: long double __builtin_nansl (const char *str) + + Similar to ``__builtin_nans``, except the return type is ``long double``. + +.. function:: _Floatn __builtin_nansfn (const char *str) + + Similar to ``__builtin_nans``, except the return type is + ``_Floatn``. + +.. function:: _Floatnx __builtin_nansfnx (const char *str) + + Similar to ``__builtin_nans``, except the return type is + ``_Floatnx``. + +.. function:: int __builtin_issignaling (...) + + Return non-zero if the argument is a signaling NaN and zero otherwise. + Note while the parameter list is an + ellipsis, this function only accepts exactly one floating-point + argument. GCC treats this parameter as type-generic, which means it + does not do default promotion from float to double. + This built-in function can work even without the non-default + ``-fsignaling-nans`` option, although if a signaling NaN is computed, + stored or passed as argument to some function other than this built-in + in the current translation unit, it is safer to use ``-fsignaling-nans``. + With ``-ffinite-math-only`` option this built-in function will always + return 0. + +.. function:: int __builtin_ffs (int x) + + Returns one plus the index of the least significant 1-bit of :samp:`{x}`, or + if :samp:`{x}` is zero, returns zero. + +.. function:: int __builtin_clz (unsigned int x) + + Returns the number of leading 0-bits in :samp:`{x}`, starting at the most + significant bit position. If :samp:`{x}` is 0, the result is undefined. + +.. function:: int __builtin_ctz (unsigned int x) + + Returns the number of trailing 0-bits in :samp:`{x}`, starting at the least + significant bit position. If :samp:`{x}` is 0, the result is undefined. + +.. function:: int __builtin_clrsb (int x) + + Returns the number of leading redundant sign bits in :samp:`{x}`, i.e. the + number of bits following the most significant bit that are identical + to it. There are no special cases for 0 or other values. + +.. function:: int __builtin_popcount (unsigned int x) + + Returns the number of 1-bits in :samp:`{x}`. + +.. function:: int __builtin_parity (unsigned int x) + + Returns the parity of :samp:`{x}`, i.e. the number of 1-bits in :samp:`{x}` + modulo 2. + +.. function:: int __builtin_ffsl (long) + + Similar to ``__builtin_ffs``, except the argument type is + ``long``. + +.. function:: int __builtin_clzl (unsigned long) + + Similar to ``__builtin_clz``, except the argument type is + ``unsigned long``. + +.. function:: int __builtin_ctzl (unsigned long) + + Similar to ``__builtin_ctz``, except the argument type is + ``unsigned long``. + +.. function:: int __builtin_clrsbl (long) + + Similar to ``__builtin_clrsb``, except the argument type is + ``long``. + +.. function:: int __builtin_popcountl (unsigned long) + + Similar to ``__builtin_popcount``, except the argument type is + ``unsigned long``. + +.. function:: int __builtin_parityl (unsigned long) + + Similar to ``__builtin_parity``, except the argument type is + ``unsigned long``. + +.. function:: int __builtin_ffsll (long long) + + Similar to ``__builtin_ffs``, except the argument type is + ``long long``. + +.. function:: int __builtin_clzll (unsigned long long) + + Similar to ``__builtin_clz``, except the argument type is + ``unsigned long long``. + +.. function:: int __builtin_ctzll (unsigned long long) + + Similar to ``__builtin_ctz``, except the argument type is + ``unsigned long long``. + +.. function:: int __builtin_clrsbll (long long) + + Similar to ``__builtin_clrsb``, except the argument type is + ``long long``. + +.. function:: int __builtin_popcountll (unsigned long long) + + Similar to ``__builtin_popcount``, except the argument type is + ``unsigned long long``. + +.. function:: int __builtin_parityll (unsigned long long) + + Similar to ``__builtin_parity``, except the argument type is + ``unsigned long long``. + +.. function:: double __builtin_powi (double, int) + + Returns the first argument raised to the power of the second. Unlike the + ``pow`` function no guarantees about precision and rounding are made. + +.. function:: float __builtin_powif (float, int) + + Similar to ``__builtin_powi``, except the argument and return types + are ``float``. + +.. function:: long double __builtin_powil (long double, int) + + Similar to ``__builtin_powi``, except the argument and return types + are ``long double``. + +.. function:: uint16_t __builtin_bswap16 (uint16_t x) + + Returns :samp:`{x}` with the order of the bytes reversed; for example, + ``0xaabb`` becomes ``0xbbaa``. Byte here always means + exactly 8 bits. + +.. function:: uint32_t __builtin_bswap32 (uint32_t x) + + Similar to ``__builtin_bswap16``, except the argument and return types + are 32-bit. + +.. function:: uint64_t __builtin_bswap64 (uint64_t x) + + Similar to ``__builtin_bswap32``, except the argument and return types + are 64-bit. + +.. function:: uint128_t __builtin_bswap128 (uint128_t x) + + Similar to ``__builtin_bswap64``, except the argument and return types + are 128-bit. Only supported on targets when 128-bit types are supported. + +.. function:: Pmode __builtin_extend_pointer (void * x) + + On targets where the user visible pointer size is smaller than the size + of an actual hardware address this function returns the extended user + pointer. Targets where this is true included ILP32 mode on x86_64 or + Aarch64. This function is mainly useful when writing inline assembly + code. + +.. function:: int __builtin_goacc_parlevel_id (int x) + + Returns the openacc gang, worker or vector id depending on whether :samp:`{x}` is + 0, 1 or 2. + +.. function:: int __builtin_goacc_parlevel_size (int x) + + Returns the openacc gang, worker or vector size depending on whether :samp:`{x}` is + 0, 1 or 2. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/pointer-arguments-in-variadic-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/pointer-arguments-in-variadic-functions.rst new file mode 100644 index 00000000000..772ab0f3334 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/pointer-arguments-in-variadic-functions.rst @@ -0,0 +1,22 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: pointer arguments in variadic functions, variadic functions, pointer arguments + +.. _variadic-pointer-args: + +Pointer Arguments in Variadic Functions +*************************************** + +Standard C requires that pointer types used with ``va_arg`` in +functions with variable argument lists either must be compatible with +that of the actual argument, or that one type must be a pointer to +``void`` and the other a pointer to a character type. GNU C +implements the POSIX XSI extension that additionally permits the use +of ``va_arg`` with a pointer type to receive arguments of any other +pointer type. + +In particular, in GNU C :samp:`va_arg (ap, void *)` can safely be used +to consume an argument of any pointer type. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/pointers-to-arrays-with-qualifiers-work-as-expected.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/pointers-to-arrays-with-qualifiers-work-as-expected.rst new file mode 100644 index 00000000000..59764f925ce --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/pointers-to-arrays-with-qualifiers-work-as-expected.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: pointers to arrays, const qualifier + +.. _pointers-to-arrays: + +Pointers to Arrays with Qualifiers Work as Expected +*************************************************** + +In GNU C, pointers to arrays with qualifiers work similar to pointers +to other qualified types. For example, a value of type ``int (*)[5]`` +can be used to initialize a variable of type ``const int (*)[5]``. +These types are incompatible in ISO C because the ``const`` qualifier +is formally attached to the element type of the array and not the +array itself. + +.. code-block:: c++ + + extern void + transpose (int N, int M, double out[M][N], const double in[N][M]); + double x[3][2]; + double y[2][3]; + ... + transpose(3, 2, y, x); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/pragmas-accepted-by-gcc.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/pragmas-accepted-by-gcc.rst new file mode 100644 index 00000000000..70430c7b718 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/pragmas-accepted-by-gcc.rst @@ -0,0 +1,729 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: pragmas, #pragma + +.. _pragmas: + +Pragmas Accepted by GCC +*********************** + +GCC supports several types of pragmas, primarily in order to compile +code originally written for other compilers. Note that in general +we do not recommend the use of pragmas; See :ref:`function-attributes`, +for further explanation. + +The GNU C preprocessor recognizes several pragmas in addition to the +compiler pragmas documented here. Refer to the CPP manual for more +information. + +.. toctree:: + :maxdepth: 2 + + +.. _aarch64-pragmas: + +AArch64 Pragmas +^^^^^^^^^^^^^^^ + +The pragmas defined by the AArch64 target correspond to the AArch64 +target function attributes. They can be specified as below: + +.. code-block:: c++ + + #pragma GCC target("string") + +where ``string`` can be any string accepted as an AArch64 target +attribute. See :ref:`aarch64-function-attributes`, for more details +on the permissible values of ``string``. + +.. _arm-pragmas: + +ARM Pragmas +^^^^^^^^^^^ + +The ARM target defines pragmas for controlling the default addition of +:arm-fn-attr:`long_call` and ``short_call`` attributes to functions. +See :ref:`function-attributes`, for information about the effects of these +attributes. + +``long_calls`` + + .. index:: pragma, long_calls + + Set all subsequent functions to have the :arm-fn-attr:`long_call` attribute. + +``no_long_calls`` + + .. index:: pragma, no_long_calls + + Set all subsequent functions to have the ``short_call`` attribute. + +``long_calls_off`` + + .. index:: pragma, long_calls_off + + Do not affect the :arm-fn-attr:`long_call` or ``short_call`` attributes of + subsequent functions. + +.. _m32c-pragmas: + +M32C Pragmas +^^^^^^^^^^^^ + +:samp:`GCC memregs {number}` + + .. index:: pragma, memregs + + Overrides the command-line option ``-memregs=`` for the current + file. Use with care! This pragma must be before any function in the + file, and mixing different memregs values in different objects may + make them incompatible. This pragma is useful when a + performance-critical function uses a memreg for temporary values, + as it may allow you to reduce the number of memregs used. + +:samp:`ADDRESS {name}{address}` + + .. index:: pragma, address + + For any declared symbols matching :samp:`{name}`, this does three things + to that symbol: it forces the symbol to be located at the given + address (a number), it forces the symbol to be volatile, and it + changes the symbol's scope to be static. This pragma exists for + compatibility with other compilers, but note that the common + ``1234H`` numeric syntax is not supported (use ``0x1234`` + instead). Example: + + .. code-block:: c++ + + #pragma ADDRESS port3 0x103 + char port3; + +.. _mep-pragmas: + +MeP Pragmas +^^^^^^^^^^^ + +``custom io_volatile (on|off)`` + + .. index:: pragma, custom io_volatile + + Overrides the command-line option ``-mio-volatile`` for the current + file. Note that for compatibility with future GCC releases, this + option should only be used once before any :mep-var-attr:`io` variables in each + file. + +:samp:`GCC coprocessor available {registers}` + + .. index:: pragma, coprocessor available + + Specifies which coprocessor registers are available to the register + allocator. :samp:`{registers}` may be a single register, register range + separated by ellipses, or comma-separated list of those. Example: + + .. code-block:: c++ + + #pragma GCC coprocessor available $c0...$c10, $c28 + +:samp:`GCC coprocessor call_saved {registers}` + + .. index:: pragma, coprocessor call_saved + + Specifies which coprocessor registers are to be saved and restored by + any function using them. :samp:`{registers}` may be a single register, + register range separated by ellipses, or comma-separated list of + those. Example: + + .. code-block:: c++ + + #pragma GCC coprocessor call_saved $c4...$c6, $c31 + +:samp:`GCC coprocessor subclass '(A|B|C|D)' = {registers}` + + .. index:: pragma, coprocessor subclass + + Creates and defines a register class. These register classes can be + used by inline ``asm`` constructs. :samp:`{registers}` may be a single + register, register range separated by ellipses, or comma-separated + list of those. Example: + + .. code-block:: c++ + + #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6 + + asm ("cpfoo %0" : "=B" (x)); + +:samp:`GCC disinterrupt {name} , {name} ...` + + .. index:: pragma, disinterrupt + + For the named functions, the compiler adds code to disable interrupts + for the duration of those functions. If any functions so named + are not encountered in the source, a warning is emitted that the pragma is + not used. Examples: + + .. code-block:: c++ + + #pragma disinterrupt foo + #pragma disinterrupt bar, grill + int foo () { ... } + +:samp:`GCC call {name} , {name} ...` + + .. index:: pragma, call + + For the named functions, the compiler always uses a register-indirect + call model when calling the named functions. Examples: + + .. code-block:: c++ + + extern int foo (); + #pragma call foo + +.. _pru-pragmas: + +PRU Pragmas +^^^^^^^^^^^ + +:samp:`ctable_entry {index}{constant_address}` + + .. index:: pragma, ctable_entry + + Specifies that the PRU CTABLE entry given by :samp:`{index}` has the value + :samp:`{constant_address}`. This enables GCC to emit LBCO/SBCO instructions + when the load/store address is known and can be addressed with some CTABLE + entry. For example: + + .. code-block:: c++ + + /* will compile to "sbco Rx, 2, 0x10, 4" */ + #pragma ctable_entry 2 0x4802a000 + *(unsigned int *)0x4802a010 = val; + +.. _rs-6000-and-powerpc-pragmas: + +RS/6000 and PowerPC Pragmas +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The RS/6000 and PowerPC targets define one pragma for controlling +whether or not the :powerpc-fn-attr:`longcall` attribute is added to function +declarations by default. This pragma overrides the :option:`-mlongcall` +option, but not the :powerpc-fn-attr:`longcall` and ``shortcall`` attributes. +See :ref:`rs-6000-and-powerpc-options`, for more information about when long +calls are and are not necessary. + +``longcall (1)`` + + .. index:: pragma, longcall + + Apply the :powerpc-fn-attr:`longcall` attribute to all subsequent function + declarations. + +``longcall (0)`` + Do not apply the :powerpc-fn-attr:`longcall` attribute to subsequent function + declarations. + +.. Describe h8300 pragmas here. + Describe sh pragmas here. + Describe v850 pragmas here. + +.. _s-390-pragmas: + +S/390 Pragmas +^^^^^^^^^^^^^ + +The pragmas defined by the S/390 target correspond to the S/390 +target function attributes and some the additional options: + +:samp:`zvector` +:samp:`no-zvector` + +Note that options of the pragma, unlike options of the target +attribute, do change the value of preprocessor macros like +``__VEC__``. They can be specified as below: + +.. code-block:: c++ + + #pragma GCC target("string[,string]...") + #pragma GCC target("string"[,"string"]...) + +.. _darwin-pragmas: + +Darwin Pragmas +^^^^^^^^^^^^^^ + +The following pragmas are available for all architectures running the +Darwin operating system. These are useful for compatibility with other +Mac OS compilers. + +:samp:`mark {tokens}...` + + .. index:: pragma, mark + + This pragma is accepted, but has no effect. + +:samp:`options align={alignment}` + + .. index:: pragma, options align + + This pragma sets the alignment of fields in structures. The values of + :samp:`{alignment}` may be ``mac68k``, to emulate m68k alignment, or + ``power``, to emulate PowerPC alignment. Uses of this pragma nest + properly; to restore the previous setting, use ``reset`` for the + :samp:`{alignment}`. + +:samp:`segment {tokens}...` + + .. index:: pragma, segment + + This pragma is accepted, but has no effect. + +:samp:`unused ({var} [, {var}]...)` + + .. index:: pragma, unused + + This pragma declares variables to be possibly unused. GCC does not + produce warnings for the listed variables. The effect is similar to + that of the :var-attr:`unused` attribute, except that this pragma may appear + anywhere within the variables' scopes. + +.. _solaris-pragmas: + +Solaris Pragmas +^^^^^^^^^^^^^^^ + +The Solaris target supports ``#pragma redefine_extname`` +(see :ref:`symbol-renaming-pragmas`). It also supports additional +``#pragma`` directives for compatibility with the system compiler. + +:samp:`align {alignment} ({variable} [, {variable}]...)` + + .. index:: pragma, align + + Increase the minimum alignment of each :samp:`{variable}` to :samp:`{alignment}`. + This is the same as GCC's :var-attr:`aligned` attribute see :ref:`variable-attributes`). Macro expansion occurs on the arguments to this pragma + when compiling C and Objective-C. It does not currently occur when + compiling C++, but this is a bug which may be fixed in a future + release. + +:samp:`fini ({function} [, {function}]...)` + + .. index:: pragma, fini + + This pragma causes each listed :samp:`{function}` to be called after + main, or during shared module unloading, by adding a call to the + ``.fini`` section. + +:samp:`init ({function} [, {function}]...)` + + .. index:: pragma, init + + This pragma causes each listed :samp:`{function}` to be called during + initialization (before ``main``) or during shared module loading, by + adding a call to the ``.init`` section. + +.. _symbol-renaming-pragmas: + +Symbol-Renaming Pragmas +^^^^^^^^^^^^^^^^^^^^^^^ + +GCC supports a ``#pragma`` directive that changes the name used in +assembly for a given declaration. While this pragma is supported on all +platforms, it is intended primarily to provide compatibility with the +Solaris system headers. This effect can also be achieved using the asm +labels extension (see :ref:`asm-labels`). + +:samp:`redefine_extname {oldname}{newname}` + + .. index:: pragma, redefine_extname + + This pragma gives the C function :samp:`{oldname}` the assembly symbol + :samp:`{newname}`. The preprocessor macro ``__PRAGMA_REDEFINE_EXTNAME`` + is defined if this pragma is available (currently on all platforms). + +This pragma and the ``asm`` labels extension interact in a complicated +manner. Here are some corner cases you may want to be aware of: + +* This pragma silently applies only to declarations with external + linkage. The ``asm`` label feature does not have this restriction. + +* In C++, this pragma silently applies only to declarations with + 'C' linkage. Again, ``asm`` labels do not have this restriction. + +* If either of the ways of changing the assembly name of a + declaration are applied to a declaration whose assembly name has + already been determined (either by a previous use of one of these + features, or because the compiler needed the assembly name in order to + generate code), and the new name is different, a warning issues and + the name does not change. + +* The :samp:`{oldname}` used by ``#pragma redefine_extname`` is + always the C-language name. + +.. _structure-layout-pragmas: + +Structure-Layout Pragmas +^^^^^^^^^^^^^^^^^^^^^^^^ + +For compatibility with Microsoft Windows compilers, GCC supports a +set of ``#pragma`` directives that change the maximum alignment of +members of structures (other than zero-width bit-fields), unions, and +classes subsequently defined. The :samp:`{n}` value below always is required +to be a small power of two and specifies the new alignment in bytes. + +* ``#pragma pack(n)`` simply sets the new alignment. + +* ``#pragma pack()`` sets the alignment to the one that was in + effect when compilation started (see also command-line option + :option:`-fpack-struct[=n]` see :ref:`code-gen-options`). + +* ``#pragma pack(push[,n])`` pushes the current alignment + setting on an internal stack and then optionally sets the new alignment. + +* ``#pragma pack(pop)`` restores the alignment setting to the one + saved at the top of the internal stack (and removes that stack entry). + Note that ``#pragma pack([n])`` does not influence this internal + stack; thus it is possible to have ``#pragma pack(push)`` followed by + multiple ``#pragma pack(n)`` instances and finalized by a single + ``#pragma pack(pop)``. + +Some targets, e.g. x86 and PowerPC, support the ``#pragma ms_struct`` +directive which lays out structures and unions subsequently defined as the +documented ``__attribute__ ((ms_struct))``. + +* ``#pragma ms_struct on`` turns on the Microsoft layout. + +* ``#pragma ms_struct off`` turns off the Microsoft layout. + +* ``#pragma ms_struct reset`` goes back to the default layout. + +Most targets also support the ``#pragma scalar_storage_order`` directive +which lays out structures and unions subsequently defined as the documented +``__attribute__ ((scalar_storage_order))``. + +* ``#pragma scalar_storage_order big-endian`` sets the storage order + of the scalar fields to big-endian. + +* ``#pragma scalar_storage_order little-endian`` sets the storage order + of the scalar fields to little-endian. + +* ``#pragma scalar_storage_order default`` goes back to the endianness + that was in effect when compilation started (see also command-line option + :option:`-fsso-struct=endianness` see :ref:`c-dialect-options`). + +.. _weak-pragmas: + +Weak Pragmas +^^^^^^^^^^^^ + +For compatibility with SVR4, GCC supports a set of ``#pragma`` +directives for declaring symbols to be weak, and defining weak +aliases. + +:samp:`#pragma weak {symbol}` + This pragma declares :samp:`{symbol}` to be weak, as if the declaration + had the attribute of the same name. The pragma may appear before + or after the declaration of :samp:`{symbol}`. It is not an error for + :samp:`{symbol}` to never be defined at all. + +:samp:`#pragma weak {symbol1} = {symbol2}` + This pragma declares :samp:`{symbol1}` to be a weak alias of :samp:`{symbol2}`. + It is an error if :samp:`{symbol2}` is not defined in the current + translation unit. + +.. _diagnostic-pragmas: + +Diagnostic Pragmas +^^^^^^^^^^^^^^^^^^ + +GCC allows the user to selectively enable or disable certain types of +diagnostics, and change the kind of the diagnostic. For example, a +project's policy might require that all sources compile with +:option:`-Werror` but certain files might have exceptions allowing +specific types of warnings. Or, a project might selectively enable +diagnostics and treat them as errors depending on which preprocessor +macros are defined. + +:samp:`#pragma GCC diagnostic {kind}{option}` + Modifies the disposition of a diagnostic. Note that not all + diagnostics are modifiable; at the moment only warnings (normally + controlled by :samp:`-W...`) can be controlled, and not all of them. + Use :option:`-fdiagnostics-show-option` to determine which diagnostics + are controllable and which option controls them. + + :samp:`{kind}` is :samp:`error` to treat this diagnostic as an error, + :samp:`warning` to treat it like a warning (even if :option:`-Werror` is + in effect), or :samp:`ignored` if the diagnostic is to be ignored. + :samp:`{option}` is a double quoted string that matches the command-line + option. + + .. code-block:: c++ + + #pragma GCC diagnostic warning "-Wformat" + #pragma GCC diagnostic error "-Wformat" + #pragma GCC diagnostic ignored "-Wformat" + + Note that these pragmas override any command-line options. GCC keeps + track of the location of each pragma, and issues diagnostics according + to the state as of that point in the source file. Thus, pragmas occurring + after a line do not affect diagnostics caused by that line. + +``#pragma GCC diagnostic push``, ``#pragma GCC diagnostic pop`` + Causes GCC to remember the state of the diagnostics as of each + ``push``, and restore to that point at each ``pop``. If a + ``pop`` has no matching ``push``, the command-line options are + restored. + + .. code-block:: c++ + + #pragma GCC diagnostic error "-Wuninitialized" + foo(a); /* error is given for this one */ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wuninitialized" + foo(b); /* no diagnostic for this one */ + #pragma GCC diagnostic pop + foo(c); /* error is given for this one */ + #pragma GCC diagnostic pop + foo(d); /* depends on command-line options */ + +``#pragma GCC diagnostic ignored_attributes`` + Similarly to :option:`-Wno-attributes=`, this pragma allows users to suppress + warnings about unknown scoped attributes (in C++11 and C2X). For example, + ``#pragma GCC diagnostic ignored_attributes "vendor::attr"`` disables + warning about the following declaration: + + .. code-block:: c++ + + [[vendor::attr]] void f(); + + whereas ``#pragma GCC diagnostic ignored_attributes "vendor::"`` prevents + warning about both of these declarations: + + .. code-block:: c++ + + [[vendor::safe]] void f(); + [[vendor::unsafe]] void f2(); + +GCC also offers a simple mechanism for printing messages during compilation. + +:samp:`#pragma message {string}` + + .. index:: pragma, diagnostic + + Prints :samp:`{string}` as a compiler message on compilation. The message + is informational only, and is neither a compilation warning nor an + error. Newlines can be included in the string by using the :samp:`\\n` + escape sequence. + + .. code-block:: c++ + + #pragma message "Compiling " __FILE__ "..." + + :samp:`{string}` may be parenthesized, and is printed with location + information. For example, + + .. code-block:: fortran + + #define DO_PRAGMA(x) _Pragma (#x) + #define TODO(x) DO_PRAGMA(message ("TODO - " #x)) + + TODO(Remember to fix this) + + prints :samp:`/tmp/file.c:4: note: #pragma message: + TODO - Remember to fix this`. + +:samp:`#pragma GCC error {message}` + + .. index:: pragma, diagnostic + + Generates an error message. This pragma *is* considered to + indicate an error in the compilation, and it will be treated as such. + + Newlines can be included in the string by using the :samp:`\\n` + escape sequence. They will be displayed as newlines even if the + :option:`-fmessage-length` option is set to zero. + + The error is only generated if the pragma is present in the code after + pre-processing has been completed. It does not matter however if the + code containing the pragma is unreachable: + + .. code-block:: c++ + + #if 0 + #pragma GCC error "this error is not seen" + #endif + void foo (void) + { + return; + #pragma GCC error "this error is seen" + } + +:samp:`#pragma GCC warning {message}` + + .. index:: pragma, diagnostic + + This is just like :samp:`pragma GCC error` except that a warning + message is issued instead of an error message. Unless + :option:`-Werror` is in effect, in which case this pragma will generate + an error as well. + +.. _visibility-pragmas: + +Visibility Pragmas +^^^^^^^^^^^^^^^^^^ + +:samp:`#pragma GCC visibility push({visibility})`, ``#pragma GCC visibility pop`` + + .. index:: pragma, visibility + + This pragma allows the user to set the visibility for multiple + declarations without having to give each a visibility attribute + (see :ref:`function-attributes`). + + In C++, :samp:`#pragma GCC visibility` affects only namespace-scope + declarations. Class members and template specializations are not + affected; if you want to override the visibility for a particular + member or instantiation, you must use an attribute. + +.. _push-pop-macro-pragmas: + +Push/Pop Macro Pragmas +^^^^^^^^^^^^^^^^^^^^^^ + +For compatibility with Microsoft Windows compilers, GCC supports +:samp:`#pragma push_macro({"macro_name"})` +and :samp:`#pragma pop_macro({"macro_name"})`. + +:samp:`#pragma push_macro({"macro_name"})` + + .. index:: pragma, push_macro + + This pragma saves the value of the macro named as :samp:`{macro_name}` to + the top of the stack for this macro. + +:samp:`#pragma pop_macro({"macro_name"})` + + .. index:: pragma, pop_macro + + This pragma sets the value of the macro named as :samp:`{macro_name}` to + the value on top of the stack for this macro. If the stack for + :samp:`{macro_name}` is empty, the value of the macro remains unchanged. + + For example: + +.. code-block:: c++ + + #define X 1 + #pragma push_macro("X") + #undef X + #define X -1 + #pragma pop_macro("X") + int x [X]; + +In this example, the definition of X as 1 is saved by ``#pragma +push_macro`` and restored by ``#pragma pop_macro``. + +.. _function-specific-option-pragmas: + +Function Specific Option Pragmas +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +:samp:`#pragma GCC target ({string}, ...)` + + .. index:: pragma GCC target + + This pragma allows you to set target-specific options for functions + defined later in the source file. One or more strings can be + specified. Each function that is defined after this point is treated + as if it had been declared with one ``target(``:samp:`{string}` ``)`` + attribute for each :samp:`{string}` argument. The parentheses around + the strings in the pragma are optional. See :ref:`function-attributes`, + for more information about the ``target`` attribute and the attribute + syntax. + + The ``#pragma GCC target`` pragma is presently implemented for + x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only. + +:samp:`#pragma GCC optimize ({string}, ...)` + + .. index:: pragma GCC optimize + + This pragma allows you to set global optimization options for functions + defined later in the source file. One or more strings can be + specified. Each function that is defined after this point is treated + as if it had been declared with one ``optimize(``:samp:`{string}` ``)`` + attribute for each :samp:`{string}` argument. The parentheses around + the strings in the pragma are optional. See :ref:`function-attributes`, + for more information about the ``optimize`` attribute and the attribute + syntax. + +``#pragma GCC push_options`` ``#pragma GCC pop_options`` + + .. index:: pragma GCC push_options, pragma GCC pop_options + + These pragmas maintain a stack of the current target and optimization + options. It is intended for include files where you temporarily want + to switch to using a different :samp:`#pragma GCC target` or + :samp:`#pragma GCC optimize` and then to pop back to the previous + options. + +``#pragma GCC reset_options`` + + .. index:: pragma GCC reset_options + + This pragma clears the current ``#pragma GCC target`` and + ``#pragma GCC optimize`` to use the default switches as specified + on the command line. + +.. _loop-specific-pragmas: + +Loop-Specific Pragmas +^^^^^^^^^^^^^^^^^^^^^ + +``#pragma GCC ivdep`` + + .. index:: pragma GCC ivdep + + With this pragma, the programmer asserts that there are no loop-carried + dependencies which would prevent consecutive iterations of + the following loop from executing concurrently with SIMD + (single instruction multiple data) instructions. + + For example, the compiler can only unconditionally vectorize the following + loop with the pragma: + + .. code-block:: c++ + + void foo (int n, int *a, int *b, int *c) + { + int i, j; + #pragma GCC ivdep + for (i = 0; i < n; ++i) + a[i] = b[i] + c[i]; + } + + In this example, using the ``restrict`` qualifier had the same + effect. In the following example, that would not be possible. Assume + k < -m or k >= m. Only with the pragma, the compiler knows + that it can unconditionally vectorize the following loop: + + .. code-block:: c++ + + void ignore_vec_dep (int *a, int k, int c, int m) + { + #pragma GCC ivdep + for (int i = 0; i < m; i++) + a[i] = a[i + k] * c; + } + +:samp:`#pragma GCC unroll {n}` + + .. index:: pragma GCC unroll n + + You can use this pragma to control how many times a loop should be unrolled. + It must be placed immediately before a ``for``, ``while`` or ``do`` + loop or a ``#pragma GCC ivdep``, and applies only to the loop that follows. + :samp:`{n}` is an integer constant expression specifying the unrolling factor. + The values of 0 and 1 block any unrolling of the loop. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/prototypes-and-old-style-function-definitions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/prototypes-and-old-style-function-definitions.rst new file mode 100644 index 00000000000..fcaa0546108 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/prototypes-and-old-style-function-definitions.rst @@ -0,0 +1,63 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: function prototype declarations, old-style function definitions, promotion of formal parameters + +.. _function-prototypes: + +Prototypes and Old-Style Function Definitions +********************************************* + +GNU C extends ISO C to allow a function prototype to override a later +old-style non-prototype definition. Consider the following example: + +.. code-block:: c++ + + /* Use prototypes unless the compiler is old-fashioned. */ + #ifdef __STDC__ + #define P(x) x + #else + #define P(x) () + #endif + + /* Prototype function declaration. */ + int isroot P((uid_t)); + + /* Old-style function definition. */ + int + isroot (x) /* ??? lossage here ??? */ + uid_t x; + { + return x == 0; + } + +Suppose the type ``uid_t`` happens to be ``short``. ISO C does +not allow this example, because subword arguments in old-style +non-prototype definitions are promoted. Therefore in this example the +function definition's argument is really an ``int``, which does not +match the prototype argument type of ``short``. + +This restriction of ISO C makes it hard to write code that is portable +to traditional C compilers, because the programmer does not know +whether the ``uid_t`` type is ``short``, ``int``, or +``long``. Therefore, in cases like these GNU C allows a prototype +to override a later old-style definition. More precisely, in GNU C, a +function prototype argument type overrides the argument type specified +by a later old-style definition if the former type is the same as the +latter type before promotion. Thus in GNU C the above example is +equivalent to the following: + +.. code-block:: c++ + + int isroot (uid_t); + + int + isroot (uid_t x) + { + return x == 0; + } + +GNU C++ does not support old-style function definitions, so this +extension is irrelevant. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/referring-to-a-type-with-typeof.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/referring-to-a-type-with-typeof.rst new file mode 100644 index 00000000000..f84b1e0f703 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/referring-to-a-type-with-typeof.rst @@ -0,0 +1,137 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: typeof, sizeof, macros, types of arguments + +.. _typeof: + +Referring to a Type with typeof +******************************* + +Another way to refer to the type of an expression is with ``typeof``. +The syntax of using of this keyword looks like ``sizeof``, but the +construct acts semantically like a type name defined with ``typedef``. + +There are two ways of writing the argument to ``typeof`` : with an +expression or with a type. Here is an example with an expression: + +.. code-block:: c++ + + typeof (x[0](1)) + +This assumes that ``x`` is an array of pointers to functions; +the type described is that of the values of the functions. + +Here is an example with a typename as the argument: + +.. code-block:: c++ + + typeof (int *) + +Here the type described is that of pointers to ``int``. + +If you are writing a header file that must work when included in ISO C +programs, write ``__typeof__`` instead of ``typeof``. +See :ref:`alternate-keywords`. + +A ``typeof`` construct can be used anywhere a typedef name can be +used. For example, you can use it in a declaration, in a cast, or inside +of ``sizeof`` or ``typeof``. + +The operand of ``typeof`` is evaluated for its side effects if and +only if it is an expression of variably modified type or the name of +such a type. + +``typeof`` is often useful in conjunction with +statement expressions (see :ref:`statement-exprs`). +Here is how the two together can +be used to define a safe 'maximum' macro which operates on any +arithmetic type and evaluates each of its arguments exactly once: + +.. code-block:: c++ + + #define max(a,b) \ + ({ typeof (a) _a = (a); \ + typeof (b) _b = (b); \ + _a > _b ? _a : _b; }) + +.. index:: underscores in variables in macros, _ in variables in macros, local variables in macros, variables, local, in macros, macros, local variables in + +The reason for using names that start with underscores for the local +variables is to avoid conflicts with variable names that occur within the +expressions that are substituted for ``a`` and ``b``. Eventually we +hope to design a new form of declaration syntax that allows you to declare +variables whose scopes start only after their initializers; this will be a +more reliable way to prevent such conflicts. + +Some more examples of the use of ``typeof`` : + +* This declares ``y`` with the type of what ``x`` points to. + + .. code-block:: c++ + + typeof (*x) y; + +* This declares ``y`` as an array of such values. + + .. code-block:: c++ + + typeof (*x) y[4]; + +* This declares ``y`` as an array of pointers to characters: + + .. code-block:: c++ + + typeof (typeof (char *)[4]) y; + + It is equivalent to the following traditional C declaration: + + .. code-block:: c++ + + char *y[4]; + + To see the meaning of the declaration using ``typeof``, and why it + might be a useful way to write, rewrite it with these macros: + + .. code-block:: c++ + + #define pointer(T) typeof(T *) + #define array(T, N) typeof(T [N]) + + Now the declaration can be rewritten this way: + + .. code-block:: c++ + + array (pointer (char), 4) y; + + Thus, ``array (pointer (char), 4)`` is the type of arrays of 4 + pointers to ``char``. + +In GNU C, but not GNU C++, you may also declare the type of a variable +as ``__auto_type``. In that case, the declaration must declare +only one variable, whose declarator must just be an identifier, the +declaration must be initialized, and the type of the variable is +determined by the initializer; the name of the variable is not in +scope until after the initializer. (In C++, you should use C++11 +``auto`` for this purpose.) Using ``__auto_type``, the +'maximum' macro above could be written as: + +.. code-block:: c++ + + #define max(a,b) \ + ({ __auto_type _a = (a); \ + __auto_type _b = (b); \ + _a > _b ? _a : _b; }) + +Using ``__auto_type`` instead of ``typeof`` has two advantages: + +* Each argument to the macro appears only once in the expansion of + the macro. This prevents the size of the macro expansion growing + exponentially when calls to such macros are nested inside arguments of + such macros. + +* If the argument to the macro has variably modified type, it is + evaluated only once when using ``__auto_type``, but twice if + ``typeof`` is used. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/slightly-looser-rules-for-escaped-newlines.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/slightly-looser-rules-for-escaped-newlines.rst new file mode 100644 index 00000000000..8dc368434be --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/slightly-looser-rules-for-escaped-newlines.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: escaped newlines, newlines (escaped) + +.. _escaped-newlines: + +Slightly Looser Rules for Escaped Newlines +****************************************** + +The preprocessor treatment of escaped newlines is more relaxed +than that specified by the C90 standard, which requires the newline +to immediately follow a backslash. +GCC's implementation allows whitespace in the form +of spaces, horizontal and vertical tabs, and form feeds between the +backslash and the subsequent newline. The preprocessor issues a +warning, but treats it as a valid escaped newline and combines the two +lines to form a single logical line. This works within comments and +tokens, as well as between tokens. Comments are *not* treated as +whitespace for the purposes of this relaxation, since they have not +yet been replaced with spaces. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/specifying-attributes-of-types.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/specifying-attributes-of-types.rst new file mode 100644 index 00000000000..1703a0269dc --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/specifying-attributes-of-types.rst @@ -0,0 +1,713 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: attribute of types, type attributes + +.. _type-attributes: + +Specifying Attributes of Types +****************************** + +The keyword ``__attribute__`` allows you to specify various special +properties of types. Some type attributes apply only to structure and +union types, and in C++, also class types, while others can apply to +any type defined via a ``typedef`` declaration. Unless otherwise +specified, the same restrictions and effects apply to attributes regardless +of whether a type is a trivial structure or a C++ class with user-defined +constructors, destructors, or a copy assignment. + +Other attributes are defined for functions (see :ref:`function-attributes`), +labels (see :ref:`label-attributes`), enumerators (see :ref:`enumerator-attributes`), statements (see :ref:`statement-attributes`), and for variables +(see :ref:`variable-attributes`). + +The ``__attribute__`` keyword is followed by an attribute specification +enclosed in double parentheses. + +You may specify type attributes in an enum, struct or union type +declaration or definition by placing them immediately after the +``struct``, ``union`` or ``enum`` keyword. You can also place +them just past the closing curly brace of the definition, but this is less +preferred because logically the type should be fully defined at +the closing brace. + +You can also include type attributes in a ``typedef`` declaration. +See :ref:`attribute-syntax`, for details of the exact syntax for using +attributes. + +.. _common-type-attributes: + +Common Type Attributes +^^^^^^^^^^^^^^^^^^^^^^ + +The following type attributes are supported on most targets. + +.. index:: aligned type attribute + +.. type-attr:: aligned, aligned (alignment) + + The :type-attr:`aligned` attribute specifies a minimum alignment (in bytes) for + variables of the specified type. When specified, :samp:`{alignment}` must be + a power of 2. Specifying no :samp:`{alignment}` argument implies the maximum + alignment for the target, which is often, but by no means always, 8 or 16 + bytes. For example, the declarations: + + .. code-block:: c++ + + struct __attribute__ ((aligned (8))) S { short f[3]; }; + typedef int more_aligned_int __attribute__ ((aligned (8))); + + force the compiler to ensure (as far as it can) that each variable whose + type is ``struct S`` or ``more_aligned_int`` is allocated and + aligned *at least* on a 8-byte boundary. On a SPARC, having all + variables of type ``struct S`` aligned to 8-byte boundaries allows + the compiler to use the ``ldd`` and ``std`` (doubleword load and + store) instructions when copying one variable of type ``struct S`` to + another, thus improving run-time efficiency. + + Note that the alignment of any given ``struct`` or ``union`` type + is required by the ISO C standard to be at least a perfect multiple of + the lowest common multiple of the alignments of all of the members of + the ``struct`` or ``union`` in question. This means that you *can* + effectively adjust the alignment of a ``struct`` or ``union`` + type by attaching an :type-attr:`aligned` attribute to any one of the members + of such a type, but the notation illustrated in the example above is a + more obvious, intuitive, and readable way to request the compiler to + adjust the alignment of an entire ``struct`` or ``union`` type. + + As in the preceding example, you can explicitly specify the alignment + (in bytes) that you wish the compiler to use for a given ``struct`` + or ``union`` type. Alternatively, you can leave out the alignment factor + and just ask the compiler to align a type to the maximum + useful alignment for the target machine you are compiling for. For + example, you could write: + + .. code-block:: c++ + + struct __attribute__ ((aligned)) S { short f[3]; }; + + Whenever you leave out the alignment factor in an :type-attr:`aligned` + attribute specification, the compiler automatically sets the alignment + for the type to the largest alignment that is ever used for any data + type on the target machine you are compiling for. Doing this can often + make copy operations more efficient, because the compiler can use + whatever instructions copy the biggest chunks of memory when performing + copies to or from the variables that have types that you have aligned + this way. + + In the example above, if the size of each ``short`` is 2 bytes, then + the size of the entire ``struct S`` type is 6 bytes. The smallest + power of two that is greater than or equal to that is 8, so the + compiler sets the alignment for the entire ``struct S`` type to 8 + bytes. + + Note that although you can ask the compiler to select a time-efficient + alignment for a given type and then declare only individual stand-alone + objects of that type, the compiler's ability to select a time-efficient + alignment is primarily useful only when you plan to create arrays of + variables having the relevant (efficiently aligned) type. If you + declare or use arrays of variables of an efficiently-aligned type, then + it is likely that your program also does pointer arithmetic (or + subscripting, which amounts to the same thing) on pointers to the + relevant type, and the code that the compiler generates for these + pointer arithmetic operations is often more efficient for + efficiently-aligned types than for other types. + + Note that the effectiveness of :type-attr:`aligned` attributes may be limited + by inherent limitations in your linker. On many systems, the linker is + only able to arrange for variables to be aligned up to a certain maximum + alignment. (For some linkers, the maximum supported alignment may + be very very small.) If your linker is only able to align variables + up to a maximum of 8-byte alignment, then specifying ``aligned (16)`` + in an ``__attribute__`` still only provides you with 8-byte + alignment. See your linker documentation for further information. + + When used on a struct, or struct member, the :type-attr:`aligned` attribute can + only increase the alignment; in order to decrease it, the :type-attr:`packed` + attribute must be specified as well. When used as part of a typedef, the + :type-attr:`aligned` attribute can both increase and decrease alignment, and + specifying the :type-attr:`packed` attribute generates a warning. + + .. index:: warn_if_not_aligned type attribute + +.. type-attr:: warn_if_not_aligned (alignment) + + This attribute specifies a threshold for the structure field, measured + in bytes. If the structure field is aligned below the threshold, a + warning will be issued. For example, the declaration: + + .. code-block:: c++ + + typedef unsigned long long __u64 + __attribute__((aligned (4), warn_if_not_aligned (8))); + + struct foo + { + int i1; + int i2; + __u64 x; + }; + + causes the compiler to issue an warning on ``struct foo``, like + :samp:`warning: alignment 4 of 'struct foo' is less than 8`. + It is used to define ``struct foo`` in such a way that + ``struct foo`` has the same layout and the structure field ``x`` + has the same alignment when ``__u64`` is aligned at either 4 or + 8 bytes. Align ``struct foo`` to 8 bytes: + + .. code-block:: c++ + + struct __attribute__ ((aligned (8))) foo + { + int i1; + int i2; + __u64 x; + }; + + silences the warning. The compiler also issues a warning, like + :samp:`warning: 'x' offset 12 in 'struct foo' isn't aligned to 8`, + when the structure field has the misaligned offset: + + .. code-block:: c++ + + struct __attribute__ ((aligned (8))) foo + { + int i1; + int i2; + int i3; + __u64 x; + }; + + This warning can be disabled by :option:`-Wno-if-not-aligned`. + +.. index:: alloc_size type attribute + +.. type-attr:: alloc_size (position), alloc_size (position-1, position-2) + + The ``alloc_size`` type attribute may be applied to the definition + of a type of a function that returns a pointer and takes at least one + argument of an integer type. It indicates that the returned pointer + points to an object whose size is given by the function argument at + :samp:`{position-1}`, or by the product of the arguments at :samp:`{position-1}` + and :samp:`{position-2}`. Meaningful sizes are positive values less than + ``PTRDIFF_MAX``. Other sizes are disagnosed when detected. GCC uses + this information to improve the results of ``__builtin_object_size``. + + For instance, the following declarations + + .. code-block:: c++ + + typedef __attribute__ ((alloc_size (1, 2))) void* + calloc_type (size_t, size_t); + typedef __attribute__ ((alloc_size (1))) void* + malloc_type (size_t); + + specify that ``calloc_type`` is a type of a function that, like + the standard C function ``calloc``, returns an object whose size + is given by the product of arguments 1 and 2, and that + ``malloc_type``, like the standard C function ``malloc``, + returns an object whose size is given by argument 1 to the function. + +.. index:: copy type attribute + +.. type-attr:: copy, copy (expression) + + The :type-attr:`copy` attribute applies the set of attributes with which + the type of the :samp:`{expression}` has been declared to the declaration + of the type to which the attribute is applied. The attribute is + designed for libraries that define aliases that are expected to + specify the same set of attributes as the aliased symbols. + The :type-attr:`copy` attribute can be used with types, variables, or + functions. However, the kind of symbol to which the attribute is + applied (either varible or function) must match the kind of symbol + to which the argument refers. + The :type-attr:`copy` attribute copies only syntactic and semantic attributes + but not attributes that affect a symbol's linkage or visibility such as + ``alias``, :type-attr:`visibility`, or :type-attr:`weak`. The :type-attr:`deprecated` + attribute is also not copied. See :ref:`common-function-attributes`. + See :ref:`common-variable-attributes`. + + For example, suppose ``struct A`` below is defined in some third + party library header to have the alignment requirement ``N`` and + to force a warning whenever a variable of the type is not so aligned + due to attribute :type-attr:`packed`. Specifying the :type-attr:`copy` attribute + on the definition on the unrelated ``struct B`` has the effect of + copying all relevant attributes from the type referenced by the pointer + expression to ``struct B``. + + .. code-block:: c++ + + struct __attribute__ ((aligned (N), warn_if_not_aligned (N))) + A { /* ... */ }; + struct __attribute__ ((copy ( (struct A *)0)) B { /* ... */ }; + +.. index:: deprecated type attribute + +.. type-attr:: deprecated, deprecated (msg) + + The :type-attr:`deprecated` attribute results in a warning if the type + is used anywhere in the source file. This is useful when identifying + types that are expected to be removed in a future version of a program. + If possible, the warning also includes the location of the declaration + of the deprecated type, to enable users to easily find further + information about why the type is deprecated, or what they should do + instead. Note that the warnings only occur for uses and then only + if the type is being applied to an identifier that itself is not being + declared as deprecated. + + .. code-block:: c++ + + typedef int T1 __attribute__ ((deprecated)); + T1 x; + typedef T1 T2; + T2 y; + typedef T1 T3 __attribute__ ((deprecated)); + T3 z __attribute__ ((deprecated)); + + results in a warning on line 2 and 3 but not lines 4, 5, or 6. No + warning is issued for line 4 because T2 is not explicitly + deprecated. Line 5 has no warning because T3 is explicitly + deprecated. Similarly for line 6. The optional :samp:`{msg}` + argument, which must be a string, is printed in the warning if + present. Control characters in the string will be replaced with + escape sequences, and if the :option:`-fmessage-length` option is set + to 0 (its default value) then any newline characters will be ignored. + + The :type-attr:`deprecated` attribute can also be used for functions and + variables (see :ref:`function-attributes`, see :ref:`variable-attributes`.) + + The message attached to the attribute is affected by the setting of + the :option:`-fmessage-length` option. + +.. index:: unavailable type attribute + +.. type-attr:: unavailable, unavailable (msg) + + The :type-attr:`unavailable` attribute behaves in the same manner as the + :type-attr:`deprecated` one, but emits an error rather than a warning. It is + used to indicate that a (perhaps previously :type-attr:`deprecated`) type is + no longer usable. + + The :type-attr:`unavailable` attribute can also be used for functions and + variables (see :ref:`function-attributes`, see :ref:`variable-attributes`.) + +.. index:: designated_init type attribute + +.. type-attr:: designated_init + + This attribute may only be applied to structure types. It indicates + that any initialization of an object of this type must use designated + initializers rather than positional initializers. The intent of this + attribute is to allow the programmer to indicate that a structure's + layout may change, and that therefore relying on positional + initialization will result in future breakage. + + GCC emits warnings based on this attribute by default; use + :option:`-Wno-designated-init` to suppress them. + +.. index:: may_alias type attribute + +.. type-attr:: may_alias + + Accesses through pointers to types with this attribute are not subject + to type-based alias analysis, but are instead assumed to be able to alias + any other type of objects. + In the context of section 6.5 paragraph 7 of the C99 standard, + an lvalue expression + dereferencing such a pointer is treated like having a character type. + See :option:`-fstrict-aliasing` for more information on aliasing issues. + This extension exists to support some vector APIs, in which pointers to + one vector type are permitted to alias pointers to a different vector type. + + Note that an object of a type with this attribute does not have any + special semantics. + + Example of use: + + .. code-block:: c++ + + typedef short __attribute__ ((__may_alias__)) short_a; + + int + main (void) + { + int a = 0x12345678; + short_a *b = (short_a *) &a; + + b[1] = 0; + + if (a == 0x12345678) + abort(); + + exit(0); + } + + If you replaced ``short_a`` with ``short`` in the variable + declaration, the above program would abort when compiled with + :option:`-fstrict-aliasing`, which is on by default at :option:`-O2` or + above. + +.. index:: mode type attribute + +.. type-attr:: mode (mode) + + This attribute specifies the data type for the declaration---whichever + type corresponds to the mode :samp:`{mode}`. This in effect lets you + request an integer or floating-point type according to its width. + + See :ref:`gccint:machine-modes`, + for a list of the possible keywords for :samp:`{mode}`. + You may also specify a mode of ``byte`` or ``__byte__`` to + indicate the mode corresponding to a one-byte integer, ``word`` or + ``__word__`` for the mode of a one-word integer, and ``pointer`` + or ``__pointer__`` for the mode used to represent pointers. + +.. index:: packed type attribute + +.. option:: packed + + This attribute, attached to a ``struct``, ``union``, or C++ ``class`` + type definition, specifies that each of its members (other than zero-width + bit-fields) is placed to minimize the memory required. This is equivalent + to specifying the :type-attr:`packed` attribute on each of the members. + + When attached to an ``enum`` definition, the :type-attr:`packed` attribute + indicates that the smallest integral type should be used. + Specifying the :option:`-fshort-enums` flag on the command line + is equivalent to specifying the :type-attr:`packed` + attribute on all ``enum`` definitions. + + In the following example ``struct my_packed_struct`` 's members are + packed closely together, but the internal layout of its ``s`` member + is not packed---to do that, ``struct my_unpacked_struct`` needs to + be packed too. + + .. code-block:: c++ + + struct my_unpacked_struct + { + char c; + int i; + }; + + struct __attribute__ ((__packed__)) my_packed_struct + { + char c; + int i; + struct my_unpacked_struct s; + }; + + You may only specify the :type-attr:`packed` attribute on the definition + of an ``enum``, ``struct``, ``union``, or ``class``, + not on a ``typedef`` that does not also define the enumerated type, + structure, union, or class. + +.. index:: scalar_storage_order type attribute + +.. type-attr:: scalar_storage_order ("endianness") + + When attached to a ``union`` or a ``struct``, this attribute sets + the storage order, aka endianness, of the scalar fields of the type, as + well as the array fields whose component is scalar. The supported + endiannesses are ``big-endian`` and ``little-endian``. The attribute + has no effects on fields which are themselves a ``union``, a ``struct`` + or an array whose component is a ``union`` or a ``struct``, and it is + possible for these fields to have a different scalar storage order than the + enclosing type. + + Note that neither pointer nor vector fields are considered scalar fields in + this context, so the attribute has no effects on these fields. + + This attribute is supported only for targets that use a uniform default + scalar storage order (fortunately, most of them), i.e. targets that store + the scalars either all in big-endian or all in little-endian. + + Additional restrictions are enforced for types with the reverse scalar + storage order with regard to the scalar storage order of the target: + + * Taking the address of a scalar field of a ``union`` or a + ``struct`` with reverse scalar storage order is not permitted and yields + an error. + + * Taking the address of an array field, whose component is scalar, of + a ``union`` or a ``struct`` with reverse scalar storage order is + permitted but yields a warning, unless :option:`-Wno-scalar-storage-order` + is specified. + + * Taking the address of a ``union`` or a ``struct`` with reverse + scalar storage order is permitted. + + These restrictions exist because the storage order attribute is lost when + the address of a scalar or the address of an array with scalar component is + taken, so storing indirectly through this address generally does not work. + The second case is nevertheless allowed to be able to perform a block copy + from or to the array. + + Moreover, the use of type punning or aliasing to toggle the storage order + is not supported; that is to say, if a given scalar object can be accessed + through distinct types that assign a different storage order to it, then the + behavior is undefined. + +.. index:: transparent_union type attribute + +.. type-attr:: transparent_union + + This attribute, attached to a ``union`` type definition, indicates + that any function parameter having that union type causes calls to that + function to be treated in a special way. + + First, the argument corresponding to a transparent union type can be of + any type in the union; no cast is required. Also, if the union contains + a pointer type, the corresponding argument can be a null pointer + constant or a void pointer expression; and if the union contains a void + pointer type, the corresponding argument can be any pointer expression. + If the union member type is a pointer, qualifiers like ``const`` on + the referenced type must be respected, just as with normal pointer + conversions. + + Second, the argument is passed to the function using the calling + conventions of the first member of the transparent union, not the calling + conventions of the union itself. All members of the union must have the + same machine representation; this is necessary for this argument passing + to work properly. + + Transparent unions are designed for library functions that have multiple + interfaces for compatibility reasons. For example, suppose the + ``wait`` function must accept either a value of type ``int *`` to + comply with POSIX, or a value of type ``union wait *`` to comply with + the 4.1BSD interface. If ``wait`` 's parameter were ``void *``, + ``wait`` would accept both kinds of arguments, but it would also + accept any other pointer type and this would make argument type checking + less useful. Instead, ```` might define the interface + as follows: + + .. code-block:: c++ + + typedef union __attribute__ ((__transparent_union__)) + { + int *__ip; + union wait *__up; + } wait_status_ptr_t; + + pid_t wait (wait_status_ptr_t); + + This interface allows either ``int *`` or ``union wait *`` + arguments to be passed, using the ``int *`` calling convention. + The program can call ``wait`` with arguments of either type: + + .. code-block:: c++ + + int w1 () { int w; return wait (&w); } + int w2 () { union wait w; return wait (&w); } + + With this interface, ``wait`` 's implementation might look like this: + + .. code-block:: c++ + + pid_t wait (wait_status_ptr_t p) + { + return waitpid (-1, p.__ip, 0); + } + +.. index:: unused type attribute + +.. type-attr:: unused + + When attached to a type (including a ``union`` or a ``struct``), + this attribute means that variables of that type are meant to appear + possibly unused. GCC does not produce a warning for any variables of + that type, even if the variable appears to do nothing. This is often + the case with lock or thread classes, which are usually defined and then + not referenced, but contain constructors and destructors that have + nontrivial bookkeeping functions. + +.. index:: vector_size type attribute + +.. type-attr:: vector_size (bytes) + + This attribute specifies the vector size for the type, measured in bytes. + The type to which it applies is known as the :dfn:`base type`. The :samp:`{bytes}` + argument must be a positive power-of-two multiple of the base type size. For + example, the following declarations: + + .. code-block:: c++ + + typedef __attribute__ ((vector_size (32))) int int_vec32_t ; + typedef __attribute__ ((vector_size (32))) int* int_vec32_ptr_t; + typedef __attribute__ ((vector_size (32))) int int_vec32_arr3_t[3]; + + define ``int_vec32_t`` to be a 32-byte vector type composed of ``int`` + sized units. With ``int`` having a size of 4 bytes, the type defines + a vector of eight units, four bytes each. The mode of variables of type + ``int_vec32_t`` is ``V8SI``. ``int_vec32_ptr_t`` is then defined + to be a pointer to such a vector type, and ``int_vec32_arr3_t`` to be + an array of three such vectors. See :ref:`vector-extensions`, for details of + manipulating objects of vector types. + + This attribute is only applicable to integral and floating scalar types. + In function declarations the attribute applies to the function return + type. + + For example, the following: + + .. code-block:: c++ + + __attribute__ ((vector_size (16))) float get_flt_vec16 (void); + + declares ``get_flt_vec16`` to be a function returning a 16-byte vector + with the base type ``float``. + +.. index:: visibility type attribute + +.. type-attr:: visibility + + In C++, attribute visibility (see :ref:`function-attributes`) can also be + applied to class, struct, union and enum types. Unlike other type + attributes, the attribute must appear between the initial keyword and + the name of the type; it cannot appear after the body of the type. + + Note that the type visibility is applied to vague linkage entities + associated with the class (vtable, typeinfo node, etc.). In + particular, if a class is thrown as an exception in one shared object + and caught in another, the class must have default visibility. + Otherwise the two shared objects are unable to use the same + typeinfo node and exception handling will break. + +.. type-attr:: objc_root_class + + .. note:: + + Objective-C and Objective-C++ only + + .. index:: objc_root_class type attribute + + This attribute marks a class as being a root class, and thus allows + the compiler to elide any warnings about a missing superclass and to + make additional checks for mandatory methods as needed. + +To specify multiple attributes, separate them by commas within the +double parentheses: for example, :samp:`__attribute__ ((aligned (16), +packed))`. + +.. index:: uncached type attribute, ARC + +.. _arc-type-attributes: + +ARC Type Attributes +^^^^^^^^^^^^^^^^^^^ + +Declaring objects with ``uncached`` allows you to exclude +data-cache participation in load and store operations on those objects +without involving the additional semantic implications of +``volatile``. The ``.di`` instruction suffix is used for all +loads and stores of data declared ``uncached``. + +.. index:: notshared type attribute, ARM + +.. _arm-type-attributes: + +ARM Type Attributes +^^^^^^^^^^^^^^^^^^^ + +On those ARM targets that support :type-attr:`dllimport` (such as Symbian +OS), you can use the ``notshared`` attribute to indicate that the +virtual table and other similar data for a class should not be +exported from a DLL. For example: + +.. code-block:: c++ + + class __declspec(notshared) C { + public: + __declspec(dllimport) C(); + virtual void f(); + } + + __declspec(dllexport) + C::C() {} + +In this code, ``C::C`` is exported from the current DLL, but the +virtual table for ``C`` is not exported. (You can use +``__attribute__`` instead of ``__declspec`` if you prefer, but +most Symbian OS code uses ``__declspec``.) + +.. index:: preserve_access_index type attribute, BPF + +.. _bpf-type-attributes: + +BPF Type Attributes +^^^^^^^^^^^^^^^^^^^ + +BPF Compile Once - Run Everywhere (CO-RE) support. When attached to a +``struct`` or ``union`` type definition, indicates that CO-RE +relocation information should be generated for any access to a variable +of that type. The behavior is equivalent to the programmer manually +wrapping every such access with ``__builtin_preserve_access_index``. + +.. index:: based type attribute, MeP, tiny type attribute, MeP, near type attribute, MeP, far type attribute, MeP + +.. _mep-type-attributes: + +MeP Type Attributes +^^^^^^^^^^^^^^^^^^^ + +Many of the MeP variable attributes may be applied to types as well. +Specifically, the :type-attr:`based`, :type-attr:`tiny`, :type-attr:`near`, and +:type-attr:`far` attributes may be applied to either. The :type-attr:`io` and +:type-attr:`cb` attributes may not be applied to types. + +.. _powerpc-type-attributes: + +PowerPC Type Attributes +^^^^^^^^^^^^^^^^^^^^^^^ + +Three attributes currently are defined for PowerPC configurations: +``altivec``, :type-attr:`ms_struct` and ``gcc_struct``. + +.. index:: ms_struct type attribute, PowerPC, gcc_struct type attribute, PowerPC + +For full documentation of the :type-attr:`ms_struct` and ``gcc_struct`` +attributes please see the documentation in :ref:`x86-type-attributes`. + +.. index:: altivec type attribute, PowerPC + +The ``altivec`` attribute allows one to declare AltiVec vector data +types supported by the AltiVec Programming Interface Manual. The +attribute requires an argument to specify one of three vector types: +``vector__``, ``pixel__`` (always followed by unsigned short), +and ``bool__`` (always followed by unsigned). + +.. code-block:: c++ + + __attribute__((altivec(vector__))) + __attribute__((altivec(pixel__))) unsigned short + __attribute__((altivec(bool__))) unsigned + +These attributes mainly are intended to support the ``__vector``, +``__pixel``, and ``__bool`` AltiVec keywords. + +.. _x86-type-attributes: + +x86 Type Attributes +^^^^^^^^^^^^^^^^^^^ + +Two attributes are currently defined for x86 configurations: +:x86-type-attr:`ms_struct` and ``gcc_struct``. + +.. index:: ms_struct type attribute, x86, gcc_struct type attribute, x86 + +.. x86-type-attr:: ms_struct, gcc_struct + + If :type-attr:`packed` is used on a structure, or if bit-fields are used + it may be that the Microsoft ABI packs them differently + than GCC normally packs them. Particularly when moving packed + data between functions compiled with GCC and the native Microsoft compiler + (either via function call or as data in a file), it may be necessary to access + either format. + + The :type-attr:`ms_struct` and ``gcc_struct`` attributes correspond + to the :option:`-mms-bitfields` and :option:`-mno-ms-bitfields` + command-line options, respectively; + see :ref:`x86-options`, for details of how structure layout is affected. + See :ref:`x86-variable-attributes`, for information about the corresponding + attributes on variables. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/specifying-attributes-of-variables.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/specifying-attributes-of-variables.rst new file mode 100644 index 00000000000..9207fafb918 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/specifying-attributes-of-variables.rst @@ -0,0 +1,1187 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: attribute of variables, variable attributes + +.. _variable-attributes: + +Specifying Attributes of Variables +********************************** + +The keyword ``__attribute__`` allows you to specify special properties +of variables, function parameters, or structure, union, and, in C++, class +members. This ``__attribute__`` keyword is followed by an attribute +specification enclosed in double parentheses. Some attributes are currently +defined generically for variables. Other attributes are defined for +variables on particular target systems. Other attributes are available +for functions (see :ref:`function-attributes`), labels (see :ref:`label-attributes`), +enumerators (see :ref:`enumerator-attributes`), statements +(see :ref:`statement-attributes`), and for types (see :ref:`type-attributes`). +Other front ends might define more attributes +(see :ref:`c++-extensions`). + +See :ref:`attribute-syntax`, for details of the exact syntax for using +attributes. + +.. toctree:: + :maxdepth: 2 + +.. _common-variable-attributes: + +Common Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following attributes are supported on most targets. + +.. index:: alias variable attribute + +.. var-attr:: alias ("target") + + The ``alias`` variable attribute causes the declaration to be emitted + as an alias for another symbol known as an :dfn:`alias target`. Except + for top-level qualifiers the alias target must have the same type as + the alias. For instance, the following + + .. code-block:: c++ + + int var_target; + extern int __attribute__ ((alias ("var_target"))) var_alias; + + defines ``var_alias`` to be an alias for the ``var_target`` variable. + + It is an error if the alias target is not defined in the same translation + unit as the alias. + + Note that in the absence of the attribute GCC assumes that distinct + declarations with external linkage denote distinct objects. Using both + the alias and the alias target to access the same object is undefined + in a translation unit without a declaration of the alias with the attribute. + + This attribute requires assembler and object file support, and may not be + available on all targets. + + .. index:: aligned variable attribute + +.. var-attr:: aligned, aligned (alignment) + + The :var-attr:`aligned` attribute specifies a minimum alignment for the variable + or structure field, measured in bytes. When specified, :samp:`{alignment}` must + be an integer constant power of 2. Specifying no :samp:`{alignment}` argument + implies the maximum alignment for the target, which is often, but by no + means always, 8 or 16 bytes. + + For example, the declaration: + + .. code-block:: c++ + + int x __attribute__ ((aligned (16))) = 0; + + causes the compiler to allocate the global variable ``x`` on a + 16-byte boundary. On a 68040, this could be used in conjunction with + an ``asm`` expression to access the ``move16`` instruction which + requires 16-byte aligned operands. + + You can also specify the alignment of structure fields. For example, to + create a double-word aligned ``int`` pair, you could write: + + .. code-block:: c++ + + struct foo { int x[2] __attribute__ ((aligned (8))); }; + + This is an alternative to creating a union with a ``double`` member, + which forces the union to be double-word aligned. + + As in the preceding examples, you can explicitly specify the alignment + (in bytes) that you wish the compiler to use for a given variable or + structure field. Alternatively, you can leave out the alignment factor + and just ask the compiler to align a variable or field to the + default alignment for the target architecture you are compiling for. + The default alignment is sufficient for all scalar types, but may not be + enough for all vector types on a target that supports vector operations. + The default alignment is fixed for a particular target ABI. + + GCC also provides a target specific macro ``__BIGGEST_ALIGNMENT__``, + which is the largest alignment ever used for any data type on the + target machine you are compiling for. For example, you could write: + + .. code-block:: c++ + + short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__))); + + The compiler automatically sets the alignment for the declared + variable or field to ``__BIGGEST_ALIGNMENT__``. Doing this can + often make copy operations more efficient, because the compiler can + use whatever instructions copy the biggest chunks of memory when + performing copies to or from the variables or fields that you have + aligned this way. Note that the value of ``__BIGGEST_ALIGNMENT__`` + may change depending on command-line options. + + When used on a struct, or struct member, the :var-attr:`aligned` attribute can + only increase the alignment; in order to decrease it, the :var-attr:`packed` + attribute must be specified as well. When used as part of a typedef, the + :var-attr:`aligned` attribute can both increase and decrease alignment, and + specifying the :var-attr:`packed` attribute generates a warning. + + Note that the effectiveness of :var-attr:`aligned` attributes for static + variables may be limited by inherent limitations in the system linker + and/or object file format. On some systems, the linker is + only able to arrange for variables to be aligned up to a certain maximum + alignment. (For some linkers, the maximum supported alignment may + be very very small.) If your linker is only able to align variables + up to a maximum of 8-byte alignment, then specifying ``aligned(16)`` + in an ``__attribute__`` still only provides you with 8-byte + alignment. See your linker documentation for further information. + + Stack variables are not affected by linker restrictions; GCC can properly + align them on any target. + + The :var-attr:`aligned` attribute can also be used for functions + (see :ref:`common-function-attributes`.) + + .. index:: warn_if_not_aligned variable attribute + +.. var-attr:: warn_if_not_aligned (alignment) + + This attribute specifies a threshold for the structure field, measured + in bytes. If the structure field is aligned below the threshold, a + warning will be issued. For example, the declaration: + + .. code-block:: c++ + + struct foo + { + int i1; + int i2; + unsigned long long x __attribute__ ((warn_if_not_aligned (16))); + }; + + causes the compiler to issue an warning on ``struct foo``, like + :samp:`warning: alignment 8 of 'struct foo' is less than 16`. + The compiler also issues a warning, like :samp:`warning: 'x' offset + 8 in 'struct foo' isn't aligned to 16`, when the structure field has + the misaligned offset: + + .. code-block:: c++ + + struct __attribute__ ((aligned (16))) foo + { + int i1; + int i2; + unsigned long long x __attribute__ ((warn_if_not_aligned (16))); + }; + + This warning can be disabled by :option:`-Wno-if-not-aligned`. + The ``warn_if_not_aligned`` attribute can also be used for types + (see :ref:`common-type-attributes`.) + + .. index:: strict_flex_array variable attribute + +.. gcc-attr:: strict_flex_array (level) + + The ``strict_flex_array`` attribute should be attached to the trailing + array field of a structure. It controls when to treat the trailing array + field of a structure as a flexible array member for the purposes of accessing + the elements of such an array. + :samp:`{level}` must be an integer betwen 0 to 3. + + :samp:`{level}` =0 is the least strict level, all trailing arrays of structures + are treated as flexible array members. :samp:`{level}` =3 is the strictest level, + only when the trailing array is declared as a flexible array member per C99 + standard onwards (:samp:`[]`), it is treated as a flexible array member. + + There are two more levels in between 0 and 3, which are provided to support + older codes that use GCC zero-length array extension (:samp:`[0]`) or one-element + array as flexible array members (:samp:`[1]`): + When :samp:`{level}` is 1, the trailing array is treated as a flexible array member + when it is declared as either :samp:`[]`, :samp:`[0]`, or :samp:`[1]`; + When :samp:`{level}` is 2, the trailing array is treated as a flexible array member + when it is declared as either :samp:`[]`, or :samp:`[0]`. + + This attribute can be used with or without the :option:`-fstrict-flex-arrays`. + When both the attribute and the option present at the same time, the level of + the strictness for the specific trailing array field is determined by the + attribute. + +.. index:: alloc_size variable attribute + +.. var-attr:: alloc_size (position), alloc_size (position-1, position-2) + + The ``alloc_size`` variable attribute may be applied to the declaration + of a pointer to a function that returns a pointer and takes at least one + argument of an integer type. It indicates that the returned pointer points + to an object whose size is given by the function argument at :samp:`{position}`, + or by the product of the arguments at :samp:`{position-1}` and :samp:`{position-2}`. + Meaningful sizes are positive values less than ``PTRDIFF_MAX``. Other + sizes are diagnosed when detected. GCC uses this information to improve + the results of ``__builtin_object_size``. + + For instance, the following declarations + + .. code-block:: c++ + + typedef __attribute__ ((alloc_size (1, 2))) void* + (*calloc_ptr) (size_t, size_t); + typedef __attribute__ ((alloc_size (1))) void* + (*malloc_ptr) (size_t); + + specify that ``calloc_ptr`` is a pointer of a function that, like + the standard C function ``calloc``, returns an object whose size + is given by the product of arguments 1 and 2, and similarly, that + ``malloc_ptr``, like the standard C function ``malloc``, + returns an object whose size is given by argument 1 to the function. + +.. index:: cleanup variable attribute + +.. var-attr:: cleanup (cleanup_function) + + The ``cleanup`` attribute runs a function when the variable goes + out of scope. This attribute can only be applied to auto function + scope variables; it may not be applied to parameters or variables + with static storage duration. The function must take one parameter, + a pointer to a type compatible with the variable. The return value + of the function (if any) is ignored. + + If :option:`-fexceptions` is enabled, then :samp:`{cleanup_function}` + is run during the stack unwinding that happens during the + processing of the exception. Note that the ``cleanup`` attribute + does not allow the exception to be caught, only to perform an action. + It is undefined what happens if :samp:`{cleanup_function}` does not + return normally. + +.. index:: common variable attribute, nocommon variable attribute + +.. option:: common, nocommon + + The ``common`` attribute requests GCC to place a variable in + 'common' storage. The ``nocommon`` attribute requests the + opposite---to allocate space for it directly. + + These attributes override the default chosen by the + :option:`-fno-common` and :option:`-fcommon` flags respectively. + +.. index:: copy variable attribute + +.. var-attr:: copy, copy (variable) + + The :var-attr:`copy` attribute applies the set of attributes with which + :samp:`{variable}` has been declared to the declaration of the variable + to which the attribute is applied. The attribute is designed for + libraries that define aliases that are expected to specify the same + set of attributes as the aliased symbols. The :var-attr:`copy` attribute + can be used with variables, functions or types. However, the kind + of symbol to which the attribute is applied (either varible or + function) must match the kind of symbol to which the argument refers. + The :var-attr:`copy` attribute copies only syntactic and semantic attributes + but not attributes that affect a symbol's linkage or visibility such as + ``alias``, :var-attr:`visibility`, or :var-attr:`weak`. The :var-attr:`deprecated` + attribute is also not copied. See :ref:`common-function-attributes`. + See :ref:`common-type-attributes`. + +.. index:: deprecated variable attribute + +.. var-attr:: deprecated, deprecated (msg) + + The :var-attr:`deprecated` attribute results in a warning if the variable + is used anywhere in the source file. This is useful when identifying + variables that are expected to be removed in a future version of a + program. The warning also includes the location of the declaration + of the deprecated variable, to enable users to easily find further + information about why the variable is deprecated, or what they should + do instead. Note that the warning only occurs for uses: + + .. code-block:: c++ + + extern int old_var __attribute__ ((deprecated)); + extern int old_var; + int new_fn () { return old_var; } + + results in a warning on line 3 but not line 2. The optional :samp:`{msg}` + argument, which must be a string, is printed in the warning if + present. + + The :var-attr:`deprecated` attribute can also be used for functions and + types (see :ref:`common-function-attributes`, + see :ref:`common-type-attributes`). + + The message attached to the attribute is affected by the setting of + the :option:`-fmessage-length` option. + +.. index:: unavailable variable attribute + +.. var-attr:: unavailable, unavailable (msg) + + The :var-attr:`unavailable` attribute indicates that the variable so marked + is not available, if it is used anywhere in the source file. It behaves + in the same manner as the :var-attr:`deprecated` attribute except that the + compiler will emit an error rather than a warning. + + It is expected that items marked as :var-attr:`deprecated` will eventually be + withdrawn from interfaces, and then become unavailable. This attribute + allows for marking them appropriately. + + The :var-attr:`unavailable` attribute can also be used for functions and + types (see :ref:`common-function-attributes`, + see :ref:`common-type-attributes`). + +.. index:: mode variable attribute + +.. var-attr:: mode (mode) + + This attribute specifies the data type for the declaration---whichever + type corresponds to the mode :samp:`{mode}`. This in effect lets you + request an integer or floating-point type according to its width. + + See :ref:`gccint:machine-modes`, + for a list of the possible keywords for :samp:`{mode}`. + You may also specify a mode of ``byte`` or ``__byte__`` to + indicate the mode corresponding to a one-byte integer, ``word`` or + ``__word__`` for the mode of a one-word integer, and ``pointer`` + or ``__pointer__`` for the mode used to represent pointers. + +.. index:: nonstring variable attribute + +.. var-attr:: nonstring + + The :var-attr:`nonstring` variable attribute specifies that an object or member + declaration with type array of ``char``, ``signed char``, or + ``unsigned char``, or pointer to such a type is intended to store + character arrays that do not necessarily contain a terminating ``NUL``. + This is useful in detecting uses of such arrays or pointers with functions + that expect ``NUL`` -terminated strings, and to avoid warnings when such + an array or pointer is used as an argument to a bounded string manipulation + function such as ``strncpy``. For example, without the attribute, GCC + will issue a warning for the ``strncpy`` call below because it may + truncate the copy without appending the terminating ``NUL`` character. + Using the attribute makes it possible to suppress the warning. However, + when the array is declared with the attribute the call to ``strlen`` is + diagnosed because when the array doesn't contain a ``NUL`` -terminated + string the call is undefined. To copy, compare, of search non-string + character arrays use the ``memcpy``, ``memcmp``, ``memchr``, + and other functions that operate on arrays of bytes. In addition, + calling ``strnlen`` and ``strndup`` with such arrays is safe + provided a suitable bound is specified, and not diagnosed. + + .. code-block:: c++ + + struct Data + { + char name [32] __attribute__ ((nonstring)); + }; + + int f (struct Data *pd, const char *s) + { + strncpy (pd->name, s, sizeof pd->name); + ... + return strlen (pd->name); // unsafe, gets a warning + } + +.. index:: packed variable attribute + +.. var-attr:: packed + + The :var-attr:`packed` attribute specifies that a structure member should have + the smallest possible alignment---one bit for a bit-field and one byte + otherwise, unless a larger value is specified with the :var-attr:`aligned` + attribute. The attribute does not apply to non-member objects. + + For example in the structure below, the member array ``x`` is packed + so that it immediately follows ``a`` with no intervening padding: + + .. code-block:: c++ + + struct foo + { + char a; + int x[2] __attribute__ ((packed)); + }; + + .. note:: + + The 4.1, 4.2 and 4.3 series of GCC ignore the + :var-attr:`packed` attribute on bit-fields of type ``char``. This has + been fixed in GCC 4.4 but the change can lead to differences in the + structure layout. See the documentation of + :option:`-Wpacked-bitfield-compat` for more information. + +.. index:: section variable attribute + +.. var-attr:: section ("section-name") + + Normally, the compiler places the objects it generates in sections like + ``data`` and ``bss``. Sometimes, however, you need additional sections, + or you need certain particular variables to appear in special sections, + for example to map to special hardware. The ``section`` + attribute specifies that a variable (or function) lives in a particular + section. For example, this small program uses several specific section names: + + .. code-block:: c++ + + struct duart a __attribute__ ((section ("DUART_A"))) = { 0 }; + struct duart b __attribute__ ((section ("DUART_B"))) = { 0 }; + char stack[10000] __attribute__ ((section ("STACK"))) = { 0 }; + int init_data __attribute__ ((section ("INITDATA"))); + + main() + { + /* Initialize stack pointer */ + init_sp (stack + sizeof (stack)); + + /* Initialize initialized data */ + memcpy (&init_data, &data, &edata - &data); + + /* Turn on the serial ports */ + init_duart (&a); + init_duart (&b); + } + + Use the ``section`` attribute with + *global* variables and not *local* variables, + as shown in the example. + + You may use the ``section`` attribute with initialized or + uninitialized global variables but the linker requires + each object be defined once, with the exception that uninitialized + variables tentatively go in the ``common`` (or ``bss``) section + and can be multiply 'defined'. Using the ``section`` attribute + changes what section the variable goes into and may cause the + linker to issue an error if an uninitialized variable has multiple + definitions. You can force a variable to be initialized with the + :option:`-fno-common` flag or the ``nocommon`` attribute. + + Some file formats do not support arbitrary sections so the ``section`` + attribute is not available on all platforms. + If you need to map the entire contents of a module to a particular + section, consider using the facilities of the linker instead. + +.. index:: tls_model variable attribute + +.. var-attr:: tls_model ("tls_model") + + The ``tls_model`` attribute sets thread-local storage model + (see :ref:`thread-local`) of a particular ``__thread`` variable, + overriding :option:`-ftls-model=` command-line switch on a per-variable + basis. + The :samp:`{tls_model}` argument should be one of ``global-dynamic``, + ``local-dynamic``, ``initial-exec`` or ``local-exec``. + + Not all targets support this attribute. + +.. index:: unused variable attribute + +.. var-attr:: unused + + This attribute, attached to a variable or structure field, means that + the variable or field is meant to be possibly unused. GCC does not + produce a warning for this variable or field. + +.. index:: used variable attribute + +.. var-attr:: used + + This attribute, attached to a variable with static storage, means that + the variable must be emitted even if it appears that the variable is not + referenced. + + When applied to a static data member of a C++ class template, the + attribute also means that the member is instantiated if the + class itself is instantiated. + +.. index:: retain variable attribute + +.. var-attr:: retain + + For ELF targets that support the GNU or FreeBSD OSABIs, this attribute + will save the variable from linker garbage collection. To support + this behavior, variables that have not been placed in specific sections + (e.g. by the ``section`` attribute, or the ``-fdata-sections`` option), + will be placed in new, unique sections. + + This additional functionality requires Binutils version 2.36 or later. + +.. index:: uninitialized variable attribute + +.. var-attr:: uninitialized + + This attribute, attached to a variable with automatic storage, means that + the variable should not be automatically initialized by the compiler when + the option ``-ftrivial-auto-var-init`` presents. + + With the option ``-ftrivial-auto-var-init``, all the automatic variables + that do not have explicit initializers will be initialized by the compiler. + These additional compiler initializations might incur run-time overhead, + sometimes dramatically. This attribute can be used to mark some variables + to be excluded from such automatical initialization in order to reduce runtime + overhead. + + This attribute has no effect when the option ``-ftrivial-auto-var-init`` + does not present. + +.. index:: vector_size variable attribute + +.. var-attr:: vector_size (bytes) + + This attribute specifies the vector size for the type of the declared + variable, measured in bytes. The type to which it applies is known as + the :dfn:`base type`. The :samp:`{bytes}` argument must be a positive + power-of-two multiple of the base type size. For example, the declaration: + + .. code-block:: c++ + + int foo __attribute__ ((vector_size (16))); + + causes the compiler to set the mode for ``foo``, to be 16 bytes, + divided into ``int`` sized units. Assuming a 32-bit ``int``, + ``foo`` 's type is a vector of four units of four bytes each, and + the corresponding mode of ``foo`` is ``V4SI``. + See :ref:`vector-extensions`, for details of manipulating vector variables. + + This attribute is only applicable to integral and floating scalars, + although arrays, pointers, and function return values are allowed in + conjunction with this construct. + + Aggregates with this attribute are invalid, even if they are of the same + size as a corresponding scalar. For example, the declaration: + + .. code-block:: c++ + + struct S { int a; }; + struct S __attribute__ ((vector_size (16))) foo; + + is invalid even if the size of the structure is the same as the size of + the ``int``. + +.. index:: visibility variable attribute + +.. var-attr:: visibility ("visibility_type") + + This attribute affects the linkage of the declaration to which it is attached. + The :var-attr:`visibility` attribute is described in + :ref:`common-function-attributes`. + +.. index:: weak variable attribute + +.. var-attr:: weak + + The :var-attr:`weak` attribute is described in + :ref:`common-function-attributes`. + +.. index:: noinit variable attribute + +.. var-attr:: noinit + + Any data with the :var-attr:`noinit` attribute will not be initialized by + the C runtime startup code, or the program loader. Not initializing + data in this way can reduce program startup times. + + This attribute is specific to ELF targets and relies on the linker + script to place sections with the ``.noinit`` prefix in the right + location. + +.. index:: persistent variable attribute + +.. var-attr:: persistent + + Any data with the :var-attr:`persistent` attribute will not be initialized by + the C runtime startup code, but will be initialized by the program + loader. This enables the value of the variable to :samp:`persist` + between processor resets. + + This attribute is specific to ELF targets and relies on the linker + script to place the sections with the ``.persistent`` prefix in the + right location. Specifically, some type of non-volatile, writeable + memory is required. + +.. index:: objc_nullability variable attribute + +.. var-attr:: objc_nullability (nullability kind) + + .. note:: + + Objective-C and Objective-C++ only + + This attribute applies to pointer variables only. It allows marking the + pointer with one of four possible values describing the conditions under + which the pointer might have a ``nil`` value. In most cases, the + attribute is intended to be an internal representation for property and + method nullability (specified by language keywords); it is not recommended + to use it directly. + + When :samp:`{nullability kind}` is ``"unspecified"`` or ``0``, nothing is + known about the conditions in which the pointer might be ``nil``. Making + this state specific serves to avoid false positives in diagnostics. + + When :samp:`{nullability kind}` is ``"nonnull"`` or ``1``, the pointer has + no meaning if it is ``nil`` and thus the compiler is free to emit + diagnostics if it can be determined that the value will be ``nil``. + + When :samp:`{nullability kind}` is ``"nullable"`` or ``2``, the pointer might + be ``nil`` and carry meaning as such. + + When :samp:`{nullability kind}` is ``"resettable"`` or ``3`` (used only in + the context of property attribute lists) this describes the case in which a + property setter may take the value ``nil`` (which perhaps causes the + property to be reset in some manner to a default) but for which the property + getter will never validly return ``nil``. + +.. _arc-variable-attributes: + +ARC Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^ + +.. index:: aux variable attribute, ARC + +.. arc-var-attr:: aux + + The :var-attr:`aux` attribute is used to directly access the ARC's + auxiliary register space from C. The auxilirary register number is + given via attribute argument. + +.. _avr-variable-attributes: + +AVR Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^ + +.. index:: progmem variable attribute, AVR + +.. avr-var-attr:: progmem + + The :var-attr:`progmem` attribute is used on the AVR to place read-only + data in the non-volatile program memory (flash). The :var-attr:`progmem` + attribute accomplishes this by putting respective variables into a + section whose name starts with ``.progmem``. + + This attribute works similar to the ``section`` attribute + but adds additional checking. + + * Ordinary AVR cores with 32 general purpose registers: + :var-attr:`progmem` affects the location + of the data but not how this data is accessed. + In order to read data located with the :var-attr:`progmem` attribute + (inline) assembler must be used. + + .. code-block:: c++ + + /* Use custom macros from http://nongnu.org/avr-libc/user-manual/AVR-LibC */ + #include + + /* Locate var in flash memory */ + const int var[2] PROGMEM = { 1, 2 }; + + int read_var (int i) + { + /* Access var[] by accessor macro from avr/pgmspace.h */ + return (int) pgm_read_word (& var[i]); + } + + AVR is a Harvard architecture processor and data and read-only data + normally resides in the data memory (RAM). + + See also the :ref:`avr-named-address-spaces` section for + an alternate way to locate and access data in flash memory. + + * AVR cores with flash memory visible in the RAM address range: + On such devices, there is no need for attribute :var-attr:`progmem` or + :ref:`avr-named-address-spaces` qualifier at all. + Just use standard C / C++. The compiler will generate ``LD*`` + instructions. As flash memory is visible in the RAM address range, + and the default linker script does *not* locate ``.rodata`` in + RAM, no special features are needed in order not to waste RAM for + read-only data or to read from flash. You might even get slightly better + performance by + avoiding :var-attr:`progmem` and ``__flash``. This applies to devices from + families ``avrtiny`` and ``avrxmega3``, see :ref:`avr-options` for + an overview. + + * Reduced AVR Tiny cores like ATtiny40: + The compiler adds ``0x4000`` + to the addresses of objects and declarations in :var-attr:`progmem` and locates + the objects in flash memory, namely in section ``.progmem.data``. + The offset is needed because the flash memory is visible in the RAM + address space starting at address ``0x4000``. + + Data in :var-attr:`progmem` can be accessed by means of ordinary C |nbsp| code, + no special functions or macros are needed. + + .. code-block:: c++ + + /* var is located in flash memory */ + extern const int var[2] __attribute__((progmem)); + + int read_var (int i) + { + return var[i]; + } + + Please notice that on these devices, there is no need for :var-attr:`progmem` + at all. + +.. index:: io variable attribute, AVR + +.. avr-var-attr:: io, io (addr) + + Variables with the :var-attr:`io` attribute are used to address + memory-mapped peripherals in the io address range. + If an address is specified, the variable + is assigned that address, and the value is interpreted as an + address in the data address space. + Example: + + .. code-block:: c++ + + volatile int porta __attribute__((io (0x22))); + + The address specified in the address in the data address range. + + Otherwise, the variable it is not assigned an address, but the + compiler will still use in/out instructions where applicable, + assuming some other module assigns an address in the io address range. + Example: + + .. code-block:: c++ + + extern volatile int porta __attribute__((io)); + +.. index:: io_low variable attribute, AVR + +.. avr-var-attr:: io_low, io_low (addr) + + This is like the :var-attr:`io` attribute, but additionally it informs the + compiler that the object lies in the lower half of the I/O area, + allowing the use of ``cbi``, ``sbi``, ``sbic`` and ``sbis`` + instructions. + +.. index:: address variable attribute, AVR + +.. avr-var-attr:: address, address (addr) + + Variables with the :var-attr:`address` attribute are used to address + memory-mapped peripherals that may lie outside the io address range. + + .. code-block:: c++ + + volatile int porta __attribute__((address (0x600))); + +.. index:: absdata variable attribute, AVR + +.. avr-var-attr:: absdata + + Variables in static storage and with the :var-attr:`absdata` attribute can + be accessed by the ``LDS`` and ``STS`` instructions which take + absolute addresses. + + * This attribute is only supported for the reduced AVR Tiny core + like ATtiny40. + + * You must make sure that respective data is located in the + address range ``0x40``... ``0xbf`` accessible by + ``LDS`` and ``STS``. One way to achieve this as an + appropriate linker description file. + + * If the location does not fit the address range of ``LDS`` + and ``STS``, there is currently (Binutils 2.26) just an unspecific + warning like + + ``module.cc:(.text+0x1c): warning: internal error: out of range error`` + + See also the :option:`-mabsdata` :ref:`avr-options`. + +.. _blackfin-variable-attributes: + +Blackfin Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Three attributes are currently defined for the Blackfin. + +.. index:: l1_data variable attribute, Blackfin, l1_data_A variable attribute, Blackfin, l1_data_B variable attribute, Blackfin + +.. blackfin-var-attr:: l1_data, l1_data_A, l1_data_B + + Use these attributes on the Blackfin to place the variable into L1 Data SRAM. + Variables with :var-attr:`l1_data` attribute are put into the specific section + named ``.l1.data``. Those with ``l1_data_A`` attribute are put into + the specific section named ``.l1.data.A``. Those with ``l1_data_B`` + attribute are put into the specific section named ``.l1.data.B``. + +.. index:: l2 variable attribute, Blackfin + +.. blackfin-var-attr:: l2 + + Use this attribute on the Blackfin to place the variable into L2 SRAM. + Variables with :var-attr:`l2` attribute are put into the specific section + named ``.l2.data``. + +.. _h8-300-variable-attributes: + +H8/300 Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These variable attributes are available for H8/300 targets: + +.. index:: eightbit_data variable attribute, H8/300, eight-bit data on the H8/300, H8/300H, and H8S + +.. h8-300-var-attr:: eightbit_data + + Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified + variable should be placed into the eight-bit data section. + The compiler generates more efficient code for certain operations + on data in the eight-bit data area. Note the eight-bit data area is limited to + 256 bytes of data. + + You must use GAS and GLD from GNU binutils version 2.7 or later for + this attribute to work correctly. + +.. index:: tiny_data variable attribute, H8/300, tiny data section on the H8/300H and H8S + +.. h8-300-var-attr:: tiny_data + + Use this attribute on the H8/300H and H8S to indicate that the specified + variable should be placed into the tiny data section. + The compiler generates more efficient code for loads and stores + on data in the tiny data section. Note the tiny data area is limited to + slightly under 32KB of data. + +.. _ia-64-variable-attributes: + +IA-64 Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^ + +The IA-64 back end supports the following variable attribute: + +.. index:: model variable attribute, IA-64 + +.. ia-64-var-attr:: model (model-name) + + On IA-64, use this attribute to set the addressability of an object. + At present, the only supported identifier for :samp:`{model-name}` is + ``small``, indicating addressability via 'small' (22-bit) + addresses (so that their addresses can be loaded with the ``addl`` + instruction). Caveat: such addressing is by definition not position + independent and hence this attribute must not be used for objects + defined by shared libraries. + +.. _loongarch-variable-attributes: + +LoongArch Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +One attribute is currently defined for the LoongArch. + +.. index:: model variable attribute, LoongArch + +.. loongarch-var-attr:: model("name") + + Use this attribute on the LoongArch to use a different code model for + addressing this variable, than the code model specified by the global + :option:`-mcmodel` option. This attribute is mostly useful if a + ``section`` attribute and/or a linker script will locate this object + specially. Currently the only supported values of :samp:`{name}` are + ``normal`` and ``extreme``. + +.. _m32r-d-variable-attributes: + +M32R/D Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +One attribute is currently defined for the M32R/D. + +.. index:: model-name variable attribute, M32R/D, variable addressability on the M32R/D + +.. m32r-d-var-attr:: model (model-name) + + Use this attribute on the M32R/D to set the addressability of an object. + The identifier :samp:`{model-name}` is one of ``small``, ``medium``, + or ``large``, representing each of the code models. + + Small model objects live in the lower 16MB of memory (so that their + addresses can be loaded with the ``ld24`` instruction). + + Medium and large model objects may live anywhere in the 32-bit address space + (the compiler generates ``seth/add3`` instructions to load their + addresses). + +.. _mep-variable-attributes: + +MeP Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^ + +The MeP target has a number of addressing modes and busses. The +:var-attr:`near` space spans the standard memory space's first 16 megabytes +(24 bits). The :var-attr:`far` space spans the entire 32-bit memory space. +The :var-attr:`based` space is a 128-byte region in the memory space that +is addressed relative to the ``$tp`` register. The :var-attr:`tiny` +space is a 65536-byte region relative to the ``$gp`` register. In +addition to these memory regions, the MeP target has a separate 16-bit +control bus which is specified with :var-attr:`cb` attributes. + +.. index:: based variable attribute, MeP + +.. mep-var-attr:: based + + Any variable with the :var-attr:`based` attribute is assigned to the + ``.based`` section, and is accessed with relative to the + ``$tp`` register. + +.. index:: tiny variable attribute, MeP + +.. mep-var-attr:: tiny + + Likewise, the :var-attr:`tiny` attribute assigned variables to the + ``.tiny`` section, relative to the ``$gp`` register. + +.. index:: near variable attribute, MeP + +.. var-attr:: near + + Variables with the :var-attr:`near` attribute are assumed to have addresses + that fit in a 24-bit addressing mode. This is the default for large + variables (``-mtiny=4`` is the default) but this attribute can + override ``-mtiny=`` for small variables, or override ``-ml``. + +.. index:: far variable attribute, MeP + +.. mep-var-attr:: far + + Variables with the :var-attr:`far` attribute are addressed using a full + 32-bit address. Since this covers the entire memory space, this + allows modules to make no assumptions about where variables might be + stored. + +.. mep-var-attr:: io, io (addr) + + Variables with the :var-attr:`io` attribute are used to address + memory-mapped peripherals. If an address is specified, the variable + is assigned that address, else it is not assigned an address (it is + assumed some other module assigns an address). Example: + + .. code-block:: c++ + + int timer_count __attribute__((io(0x123))); + +.. index:: cb variable attribute, MeP + +.. mep-var-attr:: cb, cb (addr) + + Variables with the :var-attr:`cb` attribute are used to access the control + bus, using special instructions. ``addr`` indicates the control bus + address. Example: + + .. code-block:: c++ + + int cpu_clock __attribute__((cb(0x123))); + +.. _microsoft-windows-variable-attributes: + +Microsoft Windows Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You can use these attributes on Microsoft Windows targets. +:ref:`x86-variable-attributes` for additional Windows compatibility +attributes available on all x86 targets. + +.. index:: dllimport variable attribute, dllexport variable attribute + +.. microsoft-windows-var-attr:: dllimport, dllexport + + The :var-attr:`dllimport` and :var-attr:`dllexport` attributes are described in + :ref:`microsoft-windows-function-attributes`. + +.. index:: selectany variable attribute + +.. microsoft-windows-var-attr:: selectany + + The :microsoft-windows-var-attr:`selectany` attribute causes an initialized global variable to + have link-once semantics. When multiple definitions of the variable are + encountered by the linker, the first is selected and the remainder are + discarded. Following usage by the Microsoft compiler, the linker is told + *not* to warn about size or content differences of the multiple + definitions. + + Although the primary usage of this attribute is for POD types, the + attribute can also be applied to global C++ objects that are initialized + by a constructor. In this case, the static initialization and destruction + code for the object is emitted in each translation defining the object, + but the calls to the constructor and destructor are protected by a + link-once guard variable. + + The :microsoft-windows-var-attr:`selectany` attribute is only available on Microsoft Windows + targets. You can use ``__declspec (selectany)`` as a synonym for + ``__attribute__ ((selectany))`` for compatibility with other + compilers. + +.. index:: shared variable attribute + +.. microsoft-windows-var-attr:: shared + + On Microsoft Windows, in addition to putting variable definitions in a named + section, the section can also be shared among all running copies of an + executable or DLL. For example, this small program defines shared data + by putting it in a named section :microsoft-windows-var-attr:`shared` and marking the section + shareable: + + .. code-block:: c++ + + int foo __attribute__((section ("shared"), shared)) = 0; + + int + main() + { + /* Read and write foo. All running + copies see the same value. */ + return 0; + } + + You may only use the :var-attr:`shared` attribute along with ``section`` + attribute with a fully-initialized global definition because of the way + linkers work. See ``section`` attribute for more information. + + The :microsoft-windows-var-attr:`shared` attribute is only available on Microsoft Windows. + +.. _msp430-variable-attributes: + +MSP430 Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. index:: upper variable attribute, MSP430, either variable attribute, MSP430 + +.. msp430-var-attr:: upper, either + + These attributes are the same as the MSP430 function attributes of the + same name (see :ref:`msp430-function-attributes`). + +.. index:: lower variable attribute, MSP430 + +.. msp430-var-attr:: lower + + This option behaves mostly the same as the MSP430 function attribute of the + same name (see :ref:`msp430-function-attributes`), but it has some additional + functionality. + + If :option:`-mdata-region=` { ``upper,either,none`` } has been passed, or + the ``section`` attribute is applied to a variable, the compiler will + generate 430X instructions to handle it. This is because the compiler has + to assume that the variable could get placed in the upper memory region + (above address 0xFFFF). Marking the variable with the :var-attr:`lower` attribute + informs the compiler that the variable will be placed in lower memory so it + is safe to use 430 instructions to handle it. + + In the case of the ``section`` attribute, the section name given + will be used, and the ``.lower`` prefix will not be added. + +.. _nvidia-ptx-variable-attributes: + +Nvidia PTX Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These variable attributes are supported by the Nvidia PTX back end: + +.. index:: shared attribute, Nvidia PTX + +.. nvidia-ptx-var-attr:: shared + + Use this attribute to place a variable in the ``.shared`` memory space. + This memory space is private to each cooperative thread array; only threads + within one thread block refer to the same instance of the variable. + The runtime does not initialize variables in this memory space. + +.. _powerpc-variable-attributes: + +PowerPC Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Three attributes currently are defined for PowerPC configurations: +``altivec``, :var-attr:`ms_struct` and ``gcc_struct``. + +.. index:: ms_struct variable attribute, PowerPC, gcc_struct variable attribute, PowerPC + +For full documentation of the struct attributes please see the +documentation in :ref:`x86-variable-attributes`. + +.. index:: altivec variable attribute, PowerPC + +For documentation of ``altivec`` attribute please see the +documentation in :ref:`powerpc-type-attributes`. + +.. index:: saddr variable attribute, RL78 + +.. _rl78-variable-attributes: + +RL78 Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^ + +The RL78 back end supports the ``saddr`` variable attribute. This +specifies placement of the corresponding variable in the SADDR area, +which can be accessed more efficiently than the default memory region. + +.. _v850-variable-attributes: + +V850 Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^ + +These variable attributes are supported by the V850 back end: + +.. index:: sda variable attribute, V850 + +.. v850-var-attr:: sda + + Use this attribute to explicitly place a variable in the small data area, + which can hold up to 64 kilobytes. + +.. index:: tda variable attribute, V850 + +.. v850-var-attr:: tda + + Use this attribute to explicitly place a variable in the tiny data area, + which can hold up to 256 bytes in total. + +.. index:: zda variable attribute, V850 + +.. v850-var-attr:: zda + + Use this attribute to explicitly place a variable in the first 32 kilobytes + of memory. + +.. _x86-variable-attributes: + +x86 Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^ + +Two attributes are currently defined for x86 configurations: +:x86-var-attr:`ms_struct` and ``gcc_struct``. + +.. index:: ms_struct variable attribute, x86, gcc_struct variable attribute, x86 + +.. x86-var-attr:: ms_struct, gcc_struct + + If :var-attr:`packed` is used on a structure, or if bit-fields are used, + it may be that the Microsoft ABI lays out the structure differently + than the way GCC normally does. Particularly when moving packed + data between functions compiled with GCC and the native Microsoft compiler + (either via function call or as data in a file), it may be necessary to access + either format. + + The :var-attr:`ms_struct` and ``gcc_struct`` attributes correspond + to the :option:`-mms-bitfields` and :option:`-mno-ms-bitfields` + command-line options, respectively; + see :ref:`x86-options`, for details of how structure layout is affected. + See :ref:`x86-type-attributes`, for information about the corresponding + attributes on types. + +.. _xstormy16-variable-attributes: + +Xstormy16 Variable Attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +One attribute is currently defined for xstormy16 configurations: +:xstormy16-var-attr:`below100`. + +.. index:: below100 variable attribute, Xstormy16 + +.. xstormy16-var-attr:: below100 + + If a variable has the :xstormy16-var-attr:`below100` attribute (``BELOW100`` is + allowed also), GCC places the variable in the first 0x100 bytes of + memory and use special opcodes to access it. Such variables are + placed in either the ``.bss_below100`` section or the + ``.data_below100`` section. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/statement-attributes.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/statement-attributes.rst new file mode 100644 index 00000000000..683347a2165 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/statement-attributes.rst @@ -0,0 +1,71 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Statement Attributes + +.. _statement-attributes: + +Statement Attributes +******************** + +GCC allows attributes to be set on null statements. See :ref:`attribute-syntax`, +for details of the exact syntax for using attributes. Other attributes are +available for functions (see :ref:`function-attributes`), variables +(see :ref:`variable-attributes`), labels (see :ref:`label-attributes`), enumerators +(see :ref:`enumerator-attributes`), and for types (see :ref:`type-attributes`). + +``fallthrough`` + + .. index:: fallthrough statement attribute + + The ``fallthrough`` attribute with a null statement serves as a + fallthrough statement. It hints to the compiler that a statement + that falls through to another case label, or user-defined label + in a switch statement is intentional and thus the + :option:`-Wimplicit-fallthrough` warning must not trigger. The + fallthrough attribute may appear at most once in each attribute + list, and may not be mixed with other attributes. It can only + be used in a switch statement (the compiler will issue an error + otherwise), after a preceding statement and before a logically + succeeding case label, or user-defined label. + + This example uses the ``fallthrough`` statement attribute to indicate that + the :option:`-Wimplicit-fallthrough` warning should not be emitted: + + .. code-block:: c++ + + switch (cond) + { + case 1: + bar (1); + __attribute__((fallthrough)); + case 2: + ... + } + +``assume`` + + .. index:: assume statement attribute + + The ``assume`` attribute with a null statement serves as portable + assumption. It should have a single argument, a conditional expression, + which is not evaluated. If the argument would evaluate to true + at the point where it appears, it has no effect, otherwise there + is undefined behavior. This is a GNU variant of the ISO C++23 + standard ``assume`` attribute, but it can be used in any version of + both C and C++. + + .. code-block:: c++ + + int + foo (int x, int y) + { + __attribute__((assume(x == 42))); + __attribute__((assume(++y == 43))); + return x + y; + } + + ``y`` is not actually incremented and the compiler can but does not + have to optimize it to just ``return 42 + 42;``. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/statements-and-declarations-in-expressions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/statements-and-declarations-in-expressions.rst new file mode 100644 index 00000000000..c67be39a7b8 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/statements-and-declarations-in-expressions.rst @@ -0,0 +1,164 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: statements inside expressions, declarations inside expressions, expressions containing statements, macros, statements in expressions + +.. _statement-exprs: + +Statements and Declarations in Expressions +****************************************** + +.. the above section title wrapped and causes an underfull hbox.. i + changed it from "within" to "in". -mew 4feb93 + +A compound statement enclosed in parentheses may appear as an expression +in GNU C. This allows you to use loops, switches, and local variables +within an expression. + +Recall that a compound statement is a sequence of statements surrounded +by braces; in this construct, parentheses go around the braces. For +example: + +.. code-block:: c++ + + ({ int y = foo (); int z; + if (y > 0) z = y; + else z = - y; + z; }) + +is a valid (though slightly more complex than necessary) expression +for the absolute value of ``foo ()``. + +The last thing in the compound statement should be an expression +followed by a semicolon; the value of this subexpression serves as the +value of the entire construct. (If you use some other kind of statement +last within the braces, the construct has type ``void``, and thus +effectively no value.) + +This feature is especially useful in making macro definitions 'safe' (so +that they evaluate each operand exactly once). For example, the +'maximum' function is commonly defined as a macro in standard C as +follows: + +.. code-block:: c++ + + #define max(a,b) ((a) > (b) ? (a) : (b)) + +.. index:: side effects, macro argument + +But this definition computes either :samp:`{a}` or :samp:`{b}` twice, with bad +results if the operand has side effects. In GNU C, if you know the +type of the operands (here taken as ``int``), you can avoid this +problem by defining the macro as follows: + +.. code-block:: c++ + + #define maxint(a,b) \ + ({int _a = (a), _b = (b); _a > _b ? _a : _b; }) + +Note that introducing variable declarations (as we do in ``maxint``) can +cause variable shadowing, so while this example using the ``max`` macro +produces correct results: + +.. code-block:: c++ + + int _a = 1, _b = 2, c; + c = max (_a, _b); + +this example using maxint will not: + +.. code-block:: c++ + + int _a = 1, _b = 2, c; + c = maxint (_a, _b); + +This problem may for instance occur when we use this pattern recursively, like +so: + +.. code-block:: c++ + + #define maxint3(a, b, c) \ + ({int _a = (a), _b = (b), _c = (c); maxint (maxint (_a, _b), _c); }) + +Embedded statements are not allowed in constant expressions, such as +the value of an enumeration constant, the width of a bit-field, or +the initial value of a static variable. + +If you don't know the type of the operand, you can still do this, but you +must use ``typeof`` or ``__auto_type`` (see :ref:`typeof`). + +In G++, the result value of a statement expression undergoes array and +function pointer decay, and is returned by value to the enclosing +expression. For instance, if ``A`` is a class, then + +.. code-block:: c++ + + A a; + + ({a;}).Foo () + +constructs a temporary ``A`` object to hold the result of the +statement expression, and that is used to invoke ``Foo``. +Therefore the ``this`` pointer observed by ``Foo`` is not the +address of ``a``. + +In a statement expression, any temporaries created within a statement +are destroyed at that statement's end. This makes statement +expressions inside macros slightly different from function calls. In +the latter case temporaries introduced during argument evaluation are +destroyed at the end of the statement that includes the function +call. In the statement expression case they are destroyed during +the statement expression. For instance, + +.. code-block:: c++ + + #define macro(a) ({__typeof__(a) b = (a); b + 3; }) + template T function(T a) { T b = a; return b + 3; } + + void foo () + { + macro (X ()); + function (X ()); + } + +has different places where temporaries are destroyed. For the +``macro`` case, the temporary ``X`` is destroyed just after +the initialization of ``b``. In the ``function`` case that +temporary is destroyed when the function returns. + +These considerations mean that it is probably a bad idea to use +statement expressions of this form in header files that are designed to +work with C++. (Note that some versions of the GNU C Library contained +header files using statement expressions that lead to precisely this +bug.) + +Jumping into a statement expression with ``goto`` or using a +``switch`` statement outside the statement expression with a +``case`` or ``default`` label inside the statement expression is +not permitted. Jumping into a statement expression with a computed +``goto`` (see :ref:`labels-as-values`) has undefined behavior. +Jumping out of a statement expression is permitted, but if the +statement expression is part of a larger expression then it is +unspecified which other subexpressions of that expression have been +evaluated except where the language definition requires certain +subexpressions to be evaluated before or after the statement +expression. A ``break`` or ``continue`` statement inside of +a statement expression used in ``while``, ``do`` or ``for`` +loop or ``switch`` statement condition +or ``for`` statement init or increment expressions jumps to an +outer loop or ``switch`` statement if any (otherwise it is an error), +rather than to the loop or ``switch`` statement in whose condition +or init or increment expression it appears. +In any case, as with a function call, the evaluation of a +statement expression is not interleaved with the evaluation of other +parts of the containing expression. For example, + +.. code-block:: c++ + + foo (), (({ bar1 (); goto a; 0; }) + bar2 ()), baz(); + +calls ``foo`` and ``bar1`` and does not call ``baz`` but +may or may not call ``bar2``. If ``bar2`` is called, it is +called after ``foo`` and before ``bar1``. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/structures-with-no-members.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/structures-with-no-members.rst new file mode 100644 index 00000000000..7bd0b9fd6dc --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/structures-with-no-members.rst @@ -0,0 +1,22 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: empty structures, zero-size structures + +.. _empty-structures: + +Structures with No Members +************************** + +GCC permits a C structure to have no members: + +.. code-block:: c++ + + struct empty { + }; + +The structure has size zero. In C++, empty structures are part +of the language. G++ treats empty structures as if they had a single +member of type ``char``. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/support-for-offsetof.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/support-for-offsetof.rst new file mode 100644 index 00000000000..1c2a9199783 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/support-for-offsetof.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: __builtin_offsetof + +.. _offsetof: + +Support for offsetof +******************** + +GCC implements for both C and C++ a syntactic extension to implement +the ``offsetof`` macro. + +.. code-block:: c++ + + primary: + "__builtin_offsetof" "(" typename "," offsetof_member_designator ")" + + offsetof_member_designator: + identifier + | offsetof_member_designator "." identifier + | offsetof_member_designator "[" expr "]" + +This extension is sufficient such that + +.. code-block:: c++ + + #define offsetof(type, member) __builtin_offsetof (type, member) + +is a suitable definition of the ``offsetof`` macro. In C++, :samp:`{type}` +may be dependent. In either case, :samp:`{member}` may consist of a single +identifier, or a sequence of member accesses and array references. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins.rst new file mode 100644 index 00000000000..d2fce79a84c --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins.rst @@ -0,0 +1,53 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _target-builtins: + +Built-in Functions Specific to Particular Target Machines +********************************************************* + +On some target machines, GCC supports many built-in functions specific +to those machines. Generally these generate calls to specific machine +instructions, but allow the compiler to schedule those calls. + +.. toctree:: + :maxdepth: 1 + + target-builtins/aarch64-built-in-functions + target-builtins/alpha-built-in-functions + target-builtins/altera-nios-ii-built-in-functions + target-builtins/arc-built-in-functions + target-builtins/arc-simd-built-in-functions + target-builtins/arm-iwmmxt-built-in-functions + target-builtins/arm-c-language-extensions-acle + target-builtins/arm-floating-point-status-and-control-intrinsics + target-builtins/arm-armv8-m-security-extensions.rst + target-builtins/avr-built-in-functions + target-builtins/blackfin-built-in-functions + target-builtins/bpf-built-in-functions + target-builtins/fr-v-built-in-functions + target-builtins/mips-dsp-built-in-functions + target-builtins/mips-paired-single-support + target-builtins/mips-loongson-built-in-functions + target-builtins/mips-simd-architecture-msa-support + target-builtins/other-mips-built-in-functions + target-builtins/msp430-built-in-functions + target-builtins/nds32-built-in-functions + target-builtins/picochip-built-in-functions + target-builtins/basic-powerpc-built-in-functions + target-builtins/powerpc-altivec-vsx-built-in-functions + target-builtins/powerpc-hardware-transactional-memory-built-in-functions + target-builtins/powerpc-atomic-memory-operation-functions + target-builtins/powerpc-matrix-multiply-assist-built-in-functions + target-builtins/pru-built-in-functions + target-builtins/risc-v-built-in-functions + target-builtins/rx-built-in-functions + target-builtins/s-390-system-z-built-in-functions + target-builtins/sh-built-in-functions + target-builtins/sparc-vis-built-in-functions + target-builtins/ti-c6x-built-in-functions + target-builtins/x86-built-in-functions + target-builtins/x86-transactional-memory-intrinsics + target-builtins/x86-control-flow-protection-intrinsics \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/aarch64-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/aarch64-built-in-functions.rst new file mode 100644 index 00000000000..22d0426ebb3 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/aarch64-built-in-functions.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _aarch64-built-in-functions: + +AArch64 Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These built-in functions are available for the AArch64 family of +processors. + +.. code-block:: c++ + + unsigned int __builtin_aarch64_get_fpcr (); + void __builtin_aarch64_set_fpcr (unsigned int); + unsigned int __builtin_aarch64_get_fpsr (); + void __builtin_aarch64_set_fpsr (unsigned int); + + unsigned long long __builtin_aarch64_get_fpcr64 (); + void __builtin_aarch64_set_fpcr64 (unsigned long long); + unsigned long long __builtin_aarch64_get_fpsr64 (); + void __builtin_aarch64_set_fpsr64 (unsigned long long); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/alpha-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/alpha-built-in-functions.rst new file mode 100644 index 00000000000..b119719196c --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/alpha-built-in-functions.rst @@ -0,0 +1,88 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _alpha-built-in-functions: + +Alpha Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^ + +These built-in functions are available for the Alpha family of +processors, depending on the command-line switches used. + +The following built-in functions are always available. They +all generate the machine instruction that is part of the name. + +.. code-block:: c++ + + long __builtin_alpha_implver (void); + long __builtin_alpha_rpcc (void); + long __builtin_alpha_amask (long); + long __builtin_alpha_cmpbge (long, long); + long __builtin_alpha_extbl (long, long); + long __builtin_alpha_extwl (long, long); + long __builtin_alpha_extll (long, long); + long __builtin_alpha_extql (long, long); + long __builtin_alpha_extwh (long, long); + long __builtin_alpha_extlh (long, long); + long __builtin_alpha_extqh (long, long); + long __builtin_alpha_insbl (long, long); + long __builtin_alpha_inswl (long, long); + long __builtin_alpha_insll (long, long); + long __builtin_alpha_insql (long, long); + long __builtin_alpha_inswh (long, long); + long __builtin_alpha_inslh (long, long); + long __builtin_alpha_insqh (long, long); + long __builtin_alpha_mskbl (long, long); + long __builtin_alpha_mskwl (long, long); + long __builtin_alpha_mskll (long, long); + long __builtin_alpha_mskql (long, long); + long __builtin_alpha_mskwh (long, long); + long __builtin_alpha_msklh (long, long); + long __builtin_alpha_mskqh (long, long); + long __builtin_alpha_umulh (long, long); + long __builtin_alpha_zap (long, long); + long __builtin_alpha_zapnot (long, long); + +The following built-in functions are always with :option:`-mmax` +or :option:`-mcpu=cpu` where :samp:`{cpu}` is ``pca56`` or +later. They all generate the machine instruction that is part +of the name. + +.. code-block:: c++ + + long __builtin_alpha_pklb (long); + long __builtin_alpha_pkwb (long); + long __builtin_alpha_unpkbl (long); + long __builtin_alpha_unpkbw (long); + long __builtin_alpha_minub8 (long, long); + long __builtin_alpha_minsb8 (long, long); + long __builtin_alpha_minuw4 (long, long); + long __builtin_alpha_minsw4 (long, long); + long __builtin_alpha_maxub8 (long, long); + long __builtin_alpha_maxsb8 (long, long); + long __builtin_alpha_maxuw4 (long, long); + long __builtin_alpha_maxsw4 (long, long); + long __builtin_alpha_perr (long, long); + +The following built-in functions are always with :option:`-mcix` +or :option:`-mcpu=cpu` where :samp:`{cpu}` is ``ev67`` or +later. They all generate the machine instruction that is part +of the name. + +.. code-block:: c++ + + long __builtin_alpha_cttz (long); + long __builtin_alpha_ctlz (long); + long __builtin_alpha_ctpop (long); + +The following built-in functions are available on systems that use the OSF/1 +PALcode. Normally they invoke the ``rduniq`` and ``wruniq`` +PAL calls, but when invoked with :option:`-mtls-kernel`, they invoke +``rdval`` and ``wrval``. + +.. code-block:: c++ + + void *__builtin_thread_pointer (void); + void __builtin_set_thread_pointer (void *); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/altera-nios-ii-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/altera-nios-ii-built-in-functions.rst new file mode 100644 index 00000000000..aac982d3b13 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/altera-nios-ii-built-in-functions.rst @@ -0,0 +1,118 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _altera-nios-ii-built-in-functions: + +Altera Nios II Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These built-in functions are available for the Altera Nios II +family of processors. + +The following built-in functions are always available. They +all generate the machine instruction that is part of the name. + +.. code-block:: c++ + + int __builtin_ldbio (volatile const void *); + int __builtin_ldbuio (volatile const void *); + int __builtin_ldhio (volatile const void *); + int __builtin_ldhuio (volatile const void *); + int __builtin_ldwio (volatile const void *); + void __builtin_stbio (volatile void *, int); + void __builtin_sthio (volatile void *, int); + void __builtin_stwio (volatile void *, int); + void __builtin_sync (void); + int __builtin_rdctl (int); + int __builtin_rdprs (int, int); + void __builtin_wrctl (int, int); + void __builtin_flushd (volatile void *); + void __builtin_flushda (volatile void *); + int __builtin_wrpie (int); + void __builtin_eni (int); + int __builtin_ldex (volatile const void *); + int __builtin_stex (volatile void *, int); + int __builtin_ldsex (volatile const void *); + int __builtin_stsex (volatile void *, int); + +The following built-in functions are always available. They +all generate a Nios II Custom Instruction. The name of the +function represents the types that the function takes and +returns. The letter before the ``n`` is the return type +or void if absent. The ``n`` represents the first parameter +to all the custom instructions, the custom instruction number. +The two letters after the ``n`` represent the up to two +parameters to the function. + +The letters represent the following data types: + +```` + ``void`` for return type and no parameter for parameter types. + +``i`` + ``int`` for return type and parameter type + +``f`` + ``float`` for return type and parameter type + +``p`` + ``void *`` for return type and parameter type + + And the function names are: + +.. code-block:: c++ + + void __builtin_custom_n (void); + void __builtin_custom_ni (int); + void __builtin_custom_nf (float); + void __builtin_custom_np (void *); + void __builtin_custom_nii (int, int); + void __builtin_custom_nif (int, float); + void __builtin_custom_nip (int, void *); + void __builtin_custom_nfi (float, int); + void __builtin_custom_nff (float, float); + void __builtin_custom_nfp (float, void *); + void __builtin_custom_npi (void *, int); + void __builtin_custom_npf (void *, float); + void __builtin_custom_npp (void *, void *); + int __builtin_custom_in (void); + int __builtin_custom_ini (int); + int __builtin_custom_inf (float); + int __builtin_custom_inp (void *); + int __builtin_custom_inii (int, int); + int __builtin_custom_inif (int, float); + int __builtin_custom_inip (int, void *); + int __builtin_custom_infi (float, int); + int __builtin_custom_inff (float, float); + int __builtin_custom_infp (float, void *); + int __builtin_custom_inpi (void *, int); + int __builtin_custom_inpf (void *, float); + int __builtin_custom_inpp (void *, void *); + float __builtin_custom_fn (void); + float __builtin_custom_fni (int); + float __builtin_custom_fnf (float); + float __builtin_custom_fnp (void *); + float __builtin_custom_fnii (int, int); + float __builtin_custom_fnif (int, float); + float __builtin_custom_fnip (int, void *); + float __builtin_custom_fnfi (float, int); + float __builtin_custom_fnff (float, float); + float __builtin_custom_fnfp (float, void *); + float __builtin_custom_fnpi (void *, int); + float __builtin_custom_fnpf (void *, float); + float __builtin_custom_fnpp (void *, void *); + void * __builtin_custom_pn (void); + void * __builtin_custom_pni (int); + void * __builtin_custom_pnf (float); + void * __builtin_custom_pnp (void *); + void * __builtin_custom_pnii (int, int); + void * __builtin_custom_pnif (int, float); + void * __builtin_custom_pnip (int, void *); + void * __builtin_custom_pnfi (float, int); + void * __builtin_custom_pnff (float, float); + void * __builtin_custom_pnfp (float, void *); + void * __builtin_custom_pnpi (void *, int); + void * __builtin_custom_pnpf (void *, float); + void * __builtin_custom_pnpp (void *, void *); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arc-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arc-built-in-functions.rst new file mode 100644 index 00000000000..0df309e9186 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arc-built-in-functions.rst @@ -0,0 +1,233 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _arc-built-in-functions: + +ARC Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^ + +The following built-in functions are provided for ARC targets. The +built-ins generate the corresponding assembly instructions. In the +examples given below, the generated code often requires an operand or +result to be in a register. Where necessary further code will be +generated to ensure this is true, but for brevity this is not +described in each case. + +.. note:: + Using a built-in to generate an instruction not supported + by a target may cause problems. At present the compiler is not + guaranteed to detect such misuse, and as a result an internal compiler + error may be generated. + +.. function:: int __builtin_arc_aligned (void *val, int alignval) + + Return 1 if :samp:`{val}` is known to have the byte alignment given + by :samp:`{alignval}`, otherwise return 0. + Note that this is different from + + .. code-block:: c++ + + __alignof__(*(char *)val) >= alignval + + because __alignof__ sees only the type of the dereference, whereas + __builtin_arc_align uses alignment information from the pointer + as well as from the pointed-to type. + The information available will depend on optimization level. + +.. function:: void __builtin_arc_brk (void) + + Generates + + .. code-block:: c++ + + brk + +.. function:: unsigned int __builtin_arc_core_read (unsigned int regno) + + The operand is the number of a register to be read. Generates: + + .. code-block:: c++ + + mov dest, rregno + + where the value in :samp:`{dest}` will be the result returned from the + built-in. + +.. function:: void __builtin_arc_core_write (unsigned int regno, unsigned int val) + + The first operand is the number of a register to be written, the + second operand is a compile time constant to write into that + register. Generates: + + .. code-block:: c++ + + mov rregno, val + +.. function:: int __builtin_arc_divaw (int a, int b) + + Only available if either :option:`-mcpu=ARC700` or :option:`-meA` is set. + Generates: + + .. code-block:: c++ + + divaw dest, a, b + + where the value in :samp:`{dest}` will be the result returned from the + built-in. + +.. function:: void __builtin_arc_flag (unsigned int a) + + Generates + + .. code-block:: c++ + + flag a + +.. function:: unsigned int __builtin_arc_lr (unsigned int auxr) + + The operand, :samp:`{auxv}`, is the address of an auxiliary register and + must be a compile time constant. Generates: + + .. code-block:: c++ + + lr dest, [auxr] + + Where the value in :samp:`{dest}` will be the result returned from the + built-in. + +.. function:: void __builtin_arc_mul64 (int a, int b) + + Only available with :option:`-mmul64`. Generates: + + .. code-block:: c++ + + mul64 a, b + +.. function:: void __builtin_arc_mulu64 (unsigned int a, unsigned int b) + + Only available with :option:`-mmul64`. Generates: + + .. code-block:: c++ + + mulu64 a, b + +.. function:: void __builtin_arc_nop (void) + + Generates: + + .. code-block:: c++ + + nop + +.. function:: int __builtin_arc_norm (int src) + + Only valid if the :samp:`norm` instruction is available through the + :option:`-mnorm` option or by default with :option:`-mcpu=ARC700`. + Generates: + + .. code-block:: c++ + + norm dest, src + + Where the value in :samp:`{dest}` will be the result returned from the + built-in. + +.. function:: short int __builtin_arc_normw (short int src) + + Only valid if the :samp:`normw` instruction is available through the + :option:`-mnorm` option or by default with :option:`-mcpu=ARC700`. + Generates: + + .. code-block:: c++ + + normw dest, src + + Where the value in :samp:`{dest}` will be the result returned from the + built-in. + +.. function:: void __builtin_arc_rtie (void) + + Generates: + + .. code-block:: c++ + + rtie + +.. function:: void __builtin_arc_sleep (int a) + + Generates: + + .. code-block:: c++ + + sleep a + +.. function:: void __builtin_arc_sr (unsigned int val, unsigned int auxr) + + The first argument, :samp:`{val}`, is a compile time constant to be + written to the register, the second argument, :samp:`{auxr}`, is the + address of an auxiliary register. Generates: + + .. code-block:: c++ + + sr val, [auxr] + +.. function:: int __builtin_arc_swap (int src) + + Only valid with :option:`-mswap`. Generates: + + .. code-block:: c++ + + swap dest, src + + Where the value in :samp:`{dest}` will be the result returned from the + built-in. + +.. function:: void __builtin_arc_swi (void) + + Generates: + + .. code-block:: c++ + + swi + +.. function:: void __builtin_arc_sync (void) + + Only available with :option:`-mcpu=ARC700`. Generates: + + .. code-block:: c++ + + sync + +.. function:: void __builtin_arc_trap_s (unsigned int c) + + Only available with :option:`-mcpu=ARC700`. Generates: + + .. code-block:: c++ + + trap_s c + +.. function:: void __builtin_arc_unimp_s (void) + + Only available with :option:`-mcpu=ARC700`. Generates: + + .. code-block:: c++ + + unimp_s + +The instructions generated by the following builtins are not +considered as candidates for scheduling. They are not moved around by +the compiler during scheduling, and thus can be expected to appear +where they are put in the C code: + +.. code-block:: c++ + + __builtin_arc_brk() + __builtin_arc_core_read() + __builtin_arc_core_write() + __builtin_arc_flag() + __builtin_arc_lr() + __builtin_arc_sleep() + __builtin_arc_sr() + __builtin_arc_swi() \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arc-simd-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arc-simd-built-in-functions.rst new file mode 100644 index 00000000000..1d3dd7ea7da --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arc-simd-built-in-functions.rst @@ -0,0 +1,245 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _arc-simd-built-in-functions: + +ARC SIMD Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +SIMD builtins provided by the compiler can be used to generate the +vector instructions. This section describes the available builtins +and their usage in programs. With the :option:`-msimd` option, the +compiler provides 128-bit vector types, which can be specified using +the ``vector_size`` attribute. The header file :samp:`arc-simd.h` +can be included to use the following predefined types: + +.. code-block:: c++ + + typedef int __v4si __attribute__((vector_size(16))); + typedef short __v8hi __attribute__((vector_size(16))); + +These types can be used to define 128-bit variables. The built-in +functions listed in the following section can be used on these +variables to generate the vector operations. + +For all builtins, ``__builtin_arc_someinsn``, the header file +:samp:`arc-simd.h` also provides equivalent macros called +``_someinsn`` that can be used for programming ease and +improved readability. The following macros for DMA control are also +provided: + +.. code-block:: c++ + + #define _setup_dma_in_channel_reg _vdiwr + #define _setup_dma_out_channel_reg _vdowr + +The following is a complete list of all the SIMD built-ins provided +for ARC, grouped by calling signature. + +The following take two ``__v8hi`` arguments and return a +``__v8hi`` result: + +.. code-block:: c++ + + __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi); + __v8hi __builtin_arc_vaddw (__v8hi, __v8hi); + __v8hi __builtin_arc_vand (__v8hi, __v8hi); + __v8hi __builtin_arc_vandaw (__v8hi, __v8hi); + __v8hi __builtin_arc_vavb (__v8hi, __v8hi); + __v8hi __builtin_arc_vavrb (__v8hi, __v8hi); + __v8hi __builtin_arc_vbic (__v8hi, __v8hi); + __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi); + __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi); + __v8hi __builtin_arc_vdifw (__v8hi, __v8hi); + __v8hi __builtin_arc_veqw (__v8hi, __v8hi); + __v8hi __builtin_arc_vh264f (__v8hi, __v8hi); + __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi); + __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi); + __v8hi __builtin_arc_vlew (__v8hi, __v8hi); + __v8hi __builtin_arc_vltw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi); + __v8hi __builtin_arc_vminaw (__v8hi, __v8hi); + __v8hi __builtin_arc_vminw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi); + __v8hi __builtin_arc_vmrb (__v8hi, __v8hi); + __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi); + __v8hi __builtin_arc_vmulw (__v8hi, __v8hi); + __v8hi __builtin_arc_vnew (__v8hi, __v8hi); + __v8hi __builtin_arc_vor (__v8hi, __v8hi); + __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi); + __v8hi __builtin_arc_vsubw (__v8hi, __v8hi); + __v8hi __builtin_arc_vsummw (__v8hi, __v8hi); + __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi); + __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi); + __v8hi __builtin_arc_vxor (__v8hi, __v8hi); + __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi); + +The following take one ``__v8hi`` and one ``int`` argument and return a +``__v8hi`` result: + +.. code-block:: c++ + + __v8hi __builtin_arc_vbaddw (__v8hi, int); + __v8hi __builtin_arc_vbmaxw (__v8hi, int); + __v8hi __builtin_arc_vbminw (__v8hi, int); + __v8hi __builtin_arc_vbmulaw (__v8hi, int); + __v8hi __builtin_arc_vbmulfw (__v8hi, int); + __v8hi __builtin_arc_vbmulw (__v8hi, int); + __v8hi __builtin_arc_vbrsubw (__v8hi, int); + __v8hi __builtin_arc_vbsubw (__v8hi, int); + +The following take one ``__v8hi`` argument and one ``int`` argument which +must be a 3-bit compile time constant indicating a register number +I0-I7. They return a ``__v8hi`` result. + +.. code-block:: c++ + + __v8hi __builtin_arc_vasrw (__v8hi, const int); + __v8hi __builtin_arc_vsr8 (__v8hi, const int); + __v8hi __builtin_arc_vsr8aw (__v8hi, const int); + +The following take one ``__v8hi`` argument and one ``int`` +argument which must be a 6-bit compile time constant. They return a +``__v8hi`` result. + +.. code-block:: c++ + + __v8hi __builtin_arc_vasrpwbi (__v8hi, const int); + __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int); + __v8hi __builtin_arc_vasrrwi (__v8hi, const int); + __v8hi __builtin_arc_vasrsrwi (__v8hi, const int); + __v8hi __builtin_arc_vasrwi (__v8hi, const int); + __v8hi __builtin_arc_vsr8awi (__v8hi, const int); + __v8hi __builtin_arc_vsr8i (__v8hi, const int); + +The following take one ``__v8hi`` argument and one ``int`` argument which +must be a 8-bit compile time constant. They return a ``__v8hi`` +result. + +.. code-block:: c++ + + __v8hi __builtin_arc_vd6tapf (__v8hi, const int); + __v8hi __builtin_arc_vmvaw (__v8hi, const int); + __v8hi __builtin_arc_vmvw (__v8hi, const int); + __v8hi __builtin_arc_vmvzw (__v8hi, const int); + +The following take two ``int`` arguments, the second of which which +must be a 8-bit compile time constant. They return a ``__v8hi`` +result: + +.. code-block:: c++ + + __v8hi __builtin_arc_vmovaw (int, const int); + __v8hi __builtin_arc_vmovw (int, const int); + __v8hi __builtin_arc_vmovzw (int, const int); + +The following take a single ``__v8hi`` argument and return a +``__v8hi`` result: + +.. code-block:: c++ + + __v8hi __builtin_arc_vabsaw (__v8hi); + __v8hi __builtin_arc_vabsw (__v8hi); + __v8hi __builtin_arc_vaddsuw (__v8hi); + __v8hi __builtin_arc_vexch1 (__v8hi); + __v8hi __builtin_arc_vexch2 (__v8hi); + __v8hi __builtin_arc_vexch4 (__v8hi); + __v8hi __builtin_arc_vsignw (__v8hi); + __v8hi __builtin_arc_vupbaw (__v8hi); + __v8hi __builtin_arc_vupbw (__v8hi); + __v8hi __builtin_arc_vupsbaw (__v8hi); + __v8hi __builtin_arc_vupsbw (__v8hi); + +The following take two ``int`` arguments and return no result: + +.. code-block:: c++ + + void __builtin_arc_vdirun (int, int); + void __builtin_arc_vdorun (int, int); + +The following take two ``int`` arguments and return no result. The +first argument must a 3-bit compile time constant indicating one of +the DR0-DR7 DMA setup channels: + +.. code-block:: c++ + + void __builtin_arc_vdiwr (const int, int); + void __builtin_arc_vdowr (const int, int); + +The following take an ``int`` argument and return no result: + +.. code-block:: c++ + + void __builtin_arc_vendrec (int); + void __builtin_arc_vrec (int); + void __builtin_arc_vrecrun (int); + void __builtin_arc_vrun (int); + +The following take a ``__v8hi`` argument and two ``int`` +arguments and return a ``__v8hi`` result. The second argument must +be a 3-bit compile time constants, indicating one the registers I0-I7, +and the third argument must be an 8-bit compile time constant. + +.. note:: + + Although the equivalent hardware instructions do not take + an SIMD register as an operand, these builtins overwrite the relevant + bits of the ``__v8hi`` register provided as the first argument with + the value loaded from the ``[Ib, u8]`` location in the SDM. + +.. code-block:: c++ + + __v8hi __builtin_arc_vld32 (__v8hi, const int, const int); + __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int); + __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int); + __v8hi __builtin_arc_vld64 (__v8hi, const int, const int); + +The following take two ``int`` arguments and return a ``__v8hi`` +result. The first argument must be a 3-bit compile time constants, +indicating one the registers I0-I7, and the second argument must be an +8-bit compile time constant. + +.. code-block:: c++ + + __v8hi __builtin_arc_vld128 (const int, const int); + __v8hi __builtin_arc_vld64w (const int, const int); + +The following take a ``__v8hi`` argument and two ``int`` +arguments and return no result. The second argument must be a 3-bit +compile time constants, indicating one the registers I0-I7, and the +third argument must be an 8-bit compile time constant. + +.. code-block:: c++ + + void __builtin_arc_vst128 (__v8hi, const int, const int); + void __builtin_arc_vst64 (__v8hi, const int, const int); + +The following take a ``__v8hi`` argument and three ``int`` +arguments and return no result. The second argument must be a 3-bit +compile-time constant, identifying the 16-bit sub-register to be +stored, the third argument must be a 3-bit compile time constants, +indicating one the registers I0-I7, and the fourth argument must be an +8-bit compile time constant. + +.. code-block:: c++ + + void __builtin_arc_vst16_n (__v8hi, const int, const int, const int); + void __builtin_arc_vst32_n (__v8hi, const int, const int, const int); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-armv8-m-security-extensions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-armv8-m-security-extensions.rst new file mode 100644 index 00000000000..feb9fd3fac7 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-armv8-m-security-extensions.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _arm-armv8-m-security-extensions: + +ARM ARMv8-M Security Extensions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M +Security Extensions: Requirements on Development Tools Engineering +Specification, which can be found at +https://developer.arm.com/documentation/ecm0359818/latest/. + +As part of the Security Extensions GCC implements two new function attributes: +``cmse_nonsecure_entry`` and ``cmse_nonsecure_call``. + +As part of the Security Extensions GCC implements the intrinsics below. FPTR +is used here to mean any function pointer type. + +.. code-block:: c++ + + cmse_address_info_t cmse_TT (void *); + cmse_address_info_t cmse_TT_fptr (FPTR); + cmse_address_info_t cmse_TTT (void *); + cmse_address_info_t cmse_TTT_fptr (FPTR); + cmse_address_info_t cmse_TTA (void *); + cmse_address_info_t cmse_TTA_fptr (FPTR); + cmse_address_info_t cmse_TTAT (void *); + cmse_address_info_t cmse_TTAT_fptr (FPTR); + void * cmse_check_address_range (void *, size_t, int); + typeof(p) cmse_nsfptr_create (FPTR p); + intptr_t cmse_is_nsfptr (FPTR); + int cmse_nonsecure_caller (void); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-c-language-extensions-acle.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-c-language-extensions-acle.rst new file mode 100644 index 00000000000..1fa4a5f5f96 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-c-language-extensions-acle.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _arm-c-language-extensions-(acle): + +ARM C Language Extensions (ACLE) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC implements extensions for C as described in the ARM C Language +Extensions (ACLE) specification, which can be found at +https://developer.arm.com/documentation/ihi0053/latest/. + +As a part of ACLE, GCC implements extensions for Advanced SIMD as described in +the ARM C Language Extensions Specification. The complete list of Advanced SIMD +intrinsics can be found at +https://developer.arm.com/documentation/ihi0073/latest/. +The built-in intrinsics for the Advanced SIMD extension are available when +NEON is enabled. + +Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both +back ends support CRC32 intrinsics and the ARM back end supports the +Coprocessor intrinsics, all from :samp:`arm_acle.h`. The ARM back end's 16-bit +floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1. +AArch64's back end does not have support for 16-bit floating point Advanced SIMD +intrinsics yet. + +See :ref:`arm-options` and :ref:`aarch64-options` for more information on the +availability of extensions. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-floating-point-status-and-control-intrinsics.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-floating-point-status-and-control-intrinsics.rst new file mode 100644 index 00000000000..e67a0401a78 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-floating-point-status-and-control-intrinsics.rst @@ -0,0 +1,17 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _arm-floating-point-status-and-control-intrinsics: + +ARM Floating Point Status and Control Intrinsics +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These built-in functions are available for the ARM family of +processors with floating-point unit. + +.. code-block:: c++ + + unsigned int __builtin_arm_get_fpscr (); + void __builtin_arm_set_fpscr (unsigned int); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-iwmmxt-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-iwmmxt-built-in-functions.rst new file mode 100644 index 00000000000..a86039e344c --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/arm-iwmmxt-built-in-functions.rst @@ -0,0 +1,159 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _arm-iwmmxt-built-in-functions: + +ARM iWMMXt Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These built-in functions are available for the ARM family of +processors when the :option:`-mcpu=iwmmxt` switch is used: + +.. code-block:: c++ + + typedef int v2si __attribute__ ((vector_size (8))); + typedef short v4hi __attribute__ ((vector_size (8))); + typedef char v8qi __attribute__ ((vector_size (8))); + + int __builtin_arm_getwcgr0 (void); + void __builtin_arm_setwcgr0 (int); + int __builtin_arm_getwcgr1 (void); + void __builtin_arm_setwcgr1 (int); + int __builtin_arm_getwcgr2 (void); + void __builtin_arm_setwcgr2 (int); + int __builtin_arm_getwcgr3 (void); + void __builtin_arm_setwcgr3 (int); + int __builtin_arm_textrmsb (v8qi, int); + int __builtin_arm_textrmsh (v4hi, int); + int __builtin_arm_textrmsw (v2si, int); + int __builtin_arm_textrmub (v8qi, int); + int __builtin_arm_textrmuh (v4hi, int); + int __builtin_arm_textrmuw (v2si, int); + v8qi __builtin_arm_tinsrb (v8qi, int, int); + v4hi __builtin_arm_tinsrh (v4hi, int, int); + v2si __builtin_arm_tinsrw (v2si, int, int); + long long __builtin_arm_tmia (long long, int, int); + long long __builtin_arm_tmiabb (long long, int, int); + long long __builtin_arm_tmiabt (long long, int, int); + long long __builtin_arm_tmiaph (long long, int, int); + long long __builtin_arm_tmiatb (long long, int, int); + long long __builtin_arm_tmiatt (long long, int, int); + int __builtin_arm_tmovmskb (v8qi); + int __builtin_arm_tmovmskh (v4hi); + int __builtin_arm_tmovmskw (v2si); + long long __builtin_arm_waccb (v8qi); + long long __builtin_arm_wacch (v4hi); + long long __builtin_arm_waccw (v2si); + v8qi __builtin_arm_waddb (v8qi, v8qi); + v8qi __builtin_arm_waddbss (v8qi, v8qi); + v8qi __builtin_arm_waddbus (v8qi, v8qi); + v4hi __builtin_arm_waddh (v4hi, v4hi); + v4hi __builtin_arm_waddhss (v4hi, v4hi); + v4hi __builtin_arm_waddhus (v4hi, v4hi); + v2si __builtin_arm_waddw (v2si, v2si); + v2si __builtin_arm_waddwss (v2si, v2si); + v2si __builtin_arm_waddwus (v2si, v2si); + v8qi __builtin_arm_walign (v8qi, v8qi, int); + long long __builtin_arm_wand(long long, long long); + long long __builtin_arm_wandn (long long, long long); + v8qi __builtin_arm_wavg2b (v8qi, v8qi); + v8qi __builtin_arm_wavg2br (v8qi, v8qi); + v4hi __builtin_arm_wavg2h (v4hi, v4hi); + v4hi __builtin_arm_wavg2hr (v4hi, v4hi); + v8qi __builtin_arm_wcmpeqb (v8qi, v8qi); + v4hi __builtin_arm_wcmpeqh (v4hi, v4hi); + v2si __builtin_arm_wcmpeqw (v2si, v2si); + v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi); + v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi); + v2si __builtin_arm_wcmpgtsw (v2si, v2si); + v8qi __builtin_arm_wcmpgtub (v8qi, v8qi); + v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi); + v2si __builtin_arm_wcmpgtuw (v2si, v2si); + long long __builtin_arm_wmacs (long long, v4hi, v4hi); + long long __builtin_arm_wmacsz (v4hi, v4hi); + long long __builtin_arm_wmacu (long long, v4hi, v4hi); + long long __builtin_arm_wmacuz (v4hi, v4hi); + v4hi __builtin_arm_wmadds (v4hi, v4hi); + v4hi __builtin_arm_wmaddu (v4hi, v4hi); + v8qi __builtin_arm_wmaxsb (v8qi, v8qi); + v4hi __builtin_arm_wmaxsh (v4hi, v4hi); + v2si __builtin_arm_wmaxsw (v2si, v2si); + v8qi __builtin_arm_wmaxub (v8qi, v8qi); + v4hi __builtin_arm_wmaxuh (v4hi, v4hi); + v2si __builtin_arm_wmaxuw (v2si, v2si); + v8qi __builtin_arm_wminsb (v8qi, v8qi); + v4hi __builtin_arm_wminsh (v4hi, v4hi); + v2si __builtin_arm_wminsw (v2si, v2si); + v8qi __builtin_arm_wminub (v8qi, v8qi); + v4hi __builtin_arm_wminuh (v4hi, v4hi); + v2si __builtin_arm_wminuw (v2si, v2si); + v4hi __builtin_arm_wmulsm (v4hi, v4hi); + v4hi __builtin_arm_wmulul (v4hi, v4hi); + v4hi __builtin_arm_wmulum (v4hi, v4hi); + long long __builtin_arm_wor (long long, long long); + v2si __builtin_arm_wpackdss (long long, long long); + v2si __builtin_arm_wpackdus (long long, long long); + v8qi __builtin_arm_wpackhss (v4hi, v4hi); + v8qi __builtin_arm_wpackhus (v4hi, v4hi); + v4hi __builtin_arm_wpackwss (v2si, v2si); + v4hi __builtin_arm_wpackwus (v2si, v2si); + long long __builtin_arm_wrord (long long, long long); + long long __builtin_arm_wrordi (long long, int); + v4hi __builtin_arm_wrorh (v4hi, long long); + v4hi __builtin_arm_wrorhi (v4hi, int); + v2si __builtin_arm_wrorw (v2si, long long); + v2si __builtin_arm_wrorwi (v2si, int); + v2si __builtin_arm_wsadb (v2si, v8qi, v8qi); + v2si __builtin_arm_wsadbz (v8qi, v8qi); + v2si __builtin_arm_wsadh (v2si, v4hi, v4hi); + v2si __builtin_arm_wsadhz (v4hi, v4hi); + v4hi __builtin_arm_wshufh (v4hi, int); + long long __builtin_arm_wslld (long long, long long); + long long __builtin_arm_wslldi (long long, int); + v4hi __builtin_arm_wsllh (v4hi, long long); + v4hi __builtin_arm_wsllhi (v4hi, int); + v2si __builtin_arm_wsllw (v2si, long long); + v2si __builtin_arm_wsllwi (v2si, int); + long long __builtin_arm_wsrad (long long, long long); + long long __builtin_arm_wsradi (long long, int); + v4hi __builtin_arm_wsrah (v4hi, long long); + v4hi __builtin_arm_wsrahi (v4hi, int); + v2si __builtin_arm_wsraw (v2si, long long); + v2si __builtin_arm_wsrawi (v2si, int); + long long __builtin_arm_wsrld (long long, long long); + long long __builtin_arm_wsrldi (long long, int); + v4hi __builtin_arm_wsrlh (v4hi, long long); + v4hi __builtin_arm_wsrlhi (v4hi, int); + v2si __builtin_arm_wsrlw (v2si, long long); + v2si __builtin_arm_wsrlwi (v2si, int); + v8qi __builtin_arm_wsubb (v8qi, v8qi); + v8qi __builtin_arm_wsubbss (v8qi, v8qi); + v8qi __builtin_arm_wsubbus (v8qi, v8qi); + v4hi __builtin_arm_wsubh (v4hi, v4hi); + v4hi __builtin_arm_wsubhss (v4hi, v4hi); + v4hi __builtin_arm_wsubhus (v4hi, v4hi); + v2si __builtin_arm_wsubw (v2si, v2si); + v2si __builtin_arm_wsubwss (v2si, v2si); + v2si __builtin_arm_wsubwus (v2si, v2si); + v4hi __builtin_arm_wunpckehsb (v8qi); + v2si __builtin_arm_wunpckehsh (v4hi); + long long __builtin_arm_wunpckehsw (v2si); + v4hi __builtin_arm_wunpckehub (v8qi); + v2si __builtin_arm_wunpckehuh (v4hi); + long long __builtin_arm_wunpckehuw (v2si); + v4hi __builtin_arm_wunpckelsb (v8qi); + v2si __builtin_arm_wunpckelsh (v4hi); + long long __builtin_arm_wunpckelsw (v2si); + v4hi __builtin_arm_wunpckelub (v8qi); + v2si __builtin_arm_wunpckeluh (v4hi); + long long __builtin_arm_wunpckeluw (v2si); + v8qi __builtin_arm_wunpckihb (v8qi, v8qi); + v4hi __builtin_arm_wunpckihh (v4hi, v4hi); + v2si __builtin_arm_wunpckihw (v2si, v2si); + v8qi __builtin_arm_wunpckilb (v8qi, v8qi); + v4hi __builtin_arm_wunpckilh (v4hi, v4hi); + v2si __builtin_arm_wunpckilw (v2si, v2si); + long long __builtin_arm_wxor (long long, long long); + long long __builtin_arm_wzero (); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/avr-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/avr-built-in-functions.rst new file mode 100644 index 00000000000..80235028c07 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/avr-built-in-functions.rst @@ -0,0 +1,114 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _avr-built-in-functions: + +AVR Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^ + +For each built-in function for AVR, there is an equally named, +uppercase built-in macro defined. That way users can easily query if +or if not a specific built-in is implemented or not. For example, if +``__builtin_avr_nop`` is available the macro +``__BUILTIN_AVR_NOP`` is defined to ``1`` and undefined otherwise. + +.. code-block:: c++ + + void __builtin_avr_nop (void); + void __builtin_avr_sei (void); + void __builtin_avr_cli (void); + void __builtin_avr_sleep (void); + void __builtin_avr_wdr (void); + unsigned char __builtin_avr_swap (unsigned char); + unsigned int __builtin_avr_fmul (unsigned char, unsigned char); + int __builtin_avr_fmuls (char, char); + int __builtin_avr_fmulsu (char, unsigned char); + +These built-in functions map to the respective machine +instruction, i.e. ``nop``, ``sei``, ``cli``, ``sleep``, +``wdr``, ``swap``, ``fmul``, ``fmuls`` +resp. ``fmulsu``. The three ``fmul*`` built-ins are implemented +as library call if no hardware multiplier is available. + +.. function:: void __builtin_avr_delay_cycles (unsigned long ticks) + + Delay execution for :samp:`{ticks}` cycles. Note that this + built-in does not take into account the effect of interrupts that + might increase delay time. :samp:`{ticks}` must be a compile-time + integer constant; delays with a variable number of cycles are not supported. + +.. function:: char __builtin_avr_flash_segment (const __memx void*) + + This built-in takes a byte address to the 24-bit + :ref:`avr-named-address-spaces` ``__memx`` and returns + the number of the flash segment (the 64 KiB chunk) where the address + points to. Counting starts at ``0``. + If the address does not point to flash memory, return ``-1``. + +.. function:: uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val) + + Insert bits from :samp:`{bits}` into :samp:`{val}` and return the resulting + value. The nibbles of :samp:`{map}` determine how the insertion is + performed: Let :samp:`{X}` be the :samp:`{n}` -th nibble of :samp:`{map}` + + * If :samp:`{X}` is ``0xf``, + then the :samp:`{n}` -th bit of :samp:`{val}` is returned unaltered. + + * If X is in the range 0...7, + then the :samp:`{n}` -th result bit is set to the :samp:`{X}` -th bit of :samp:`{bits}` + + * If X is in the range 8... ``0xe``, + then the :samp:`{n}` -th result bit is undefined. + + One typical use case for this built-in is adjusting input and + output values to non-contiguous port layouts. Some examples: + + .. code-block:: c++ + + // same as val, bits is unused + __builtin_avr_insert_bits (0xffffffff, bits, val); + + .. code-block:: c++ + + // same as bits, val is unused + __builtin_avr_insert_bits (0x76543210, bits, val); + + .. code-block:: c++ + + // same as rotating bits by 4 + __builtin_avr_insert_bits (0x32107654, bits, 0); + + .. code-block:: c++ + + // high nibble of result is the high nibble of val + // low nibble of result is the low nibble of bits + __builtin_avr_insert_bits (0xffff3210, bits, val); + + .. code-block:: c++ + + // reverse the bit order of bits + __builtin_avr_insert_bits (0x01234567, bits, 0); + +.. function:: void __builtin_avr_nops (unsigned count) + + Insert :samp:`{count}` ``NOP`` instructions. + The number of instructions must be a compile-time integer constant. + +There are many more AVR-specific built-in functions that are used to +implement the ISO/IEC TR 18037 'Embedded C' fixed-point functions of +section 7.18a.6. You don't need to use these built-ins directly. +Instead, use the declarations as supplied by the ``stdfix.h`` header +with GNU-C99: + +.. code-block:: c++ + + #include + + // Re-interpret the bit representation of unsigned 16-bit + // integer uval as Q-format 0.16 value. + unsigned fract get_bits (uint_ur_t uval) + { + return urbits (uval); + } \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/basic-powerpc-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/basic-powerpc-built-in-functions.rst new file mode 100644 index 00000000000..0e9550cd32c --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/basic-powerpc-built-in-functions.rst @@ -0,0 +1,724 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _basic-powerpc-built-in-functions: + +Basic PowerPC Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. toctree:: + :maxdepth: 2 + + +This section describes PowerPC built-in functions that do not require +the inclusion of any special header files to declare prototypes or +provide macro definitions. The sections that follow describe +additional PowerPC built-in functions. + +.. _basic-powerpc-built-in-functions-available-on-all-configurations: + +Basic PowerPC Built-in Functions Available on all Configurations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. function:: void __builtin_cpu_init (void) + + This function is a ``nop`` on the PowerPC platform and is included solely + to maintain API compatibility with the x86 builtins. + +.. function:: int __builtin_cpu_is (const char *cpuname) + + This function returns a value of ``1`` if the run-time CPU is of type + :samp:`{cpuname}` and returns ``0`` otherwise + + The ``__builtin_cpu_is`` function requires GLIBC 2.23 or newer + which exports the hardware capability bits. GCC defines the macro + ``__BUILTIN_CPU_SUPPORTS__`` if the ``__builtin_cpu_supports`` + built-in function is fully supported. + + If GCC was configured to use a GLIBC before 2.23, the built-in + function ``__builtin_cpu_is`` always returns a 0 and the compiler + issues a warning. + + The following CPU names can be detected: + + :samp:`power10` + IBM POWER10 Server CPU. + + :samp:`power9` + IBM POWER9 Server CPU. + + :samp:`power8` + IBM POWER8 Server CPU. + + :samp:`power7` + IBM POWER7 Server CPU. + + :samp:`power6x` + IBM POWER6 Server CPU (RAW mode). + + :samp:`power6` + IBM POWER6 Server CPU (Architected mode). + + :samp:`power5+` + IBM POWER5+ Server CPU. + + :samp:`power5` + IBM POWER5 Server CPU. + + :samp:`ppc970` + IBM 970 Server CPU (ie, Apple G5). + + :samp:`power4` + IBM POWER4 Server CPU. + + :samp:`ppca2` + IBM A2 64-bit Embedded CPU + + :samp:`ppc476` + IBM PowerPC 476FP 32-bit Embedded CPU. + + :samp:`ppc464` + IBM PowerPC 464 32-bit Embedded CPU. + + :samp:`ppc440` + PowerPC 440 32-bit Embedded CPU. + + :samp:`ppc405` + PowerPC 405 32-bit Embedded CPU. + + :samp:`ppc-cell-be` + IBM PowerPC Cell Broadband Engine Architecture CPU. + + Here is an example: + + .. code-block:: c++ + + #ifdef __BUILTIN_CPU_SUPPORTS__ + if (__builtin_cpu_is ("power8")) + { + do_power8 (); // POWER8 specific implementation. + } + else + #endif + { + do_generic (); // Generic implementation. + } + +.. function:: int __builtin_cpu_supports (const char *feature) + + This function returns a value of ``1`` if the run-time CPU supports the HWCAP + feature :samp:`{feature}` and returns ``0`` otherwise. + + The ``__builtin_cpu_supports`` function requires GLIBC 2.23 or + newer which exports the hardware capability bits. GCC defines the + macro ``__BUILTIN_CPU_SUPPORTS__`` if the + ``__builtin_cpu_supports`` built-in function is fully supported. + + If GCC was configured to use a GLIBC before 2.23, the built-in + function ``__builtin_cpu_supports`` always returns a 0 and the + compiler issues a warning. + + The following features can be + detected: + + :samp:`4xxmac` + 4xx CPU has a Multiply Accumulator. + + :samp:`altivec` + CPU has a SIMD/Vector Unit. + + :samp:`arch_2_05` + CPU supports ISA 2.05 (eg, POWER6) + + :samp:`arch_2_06` + CPU supports ISA 2.06 (eg, POWER7) + + :samp:`arch_2_07` + CPU supports ISA 2.07 (eg, POWER8) + + :samp:`arch_3_00` + CPU supports ISA 3.0 (eg, POWER9) + + :samp:`arch_3_1` + CPU supports ISA 3.1 (eg, POWER10) + + :samp:`archpmu` + CPU supports the set of compatible performance monitoring events. + + :samp:`booke` + CPU supports the Embedded ISA category. + + :samp:`cellbe` + CPU has a CELL broadband engine. + + :samp:`darn` + CPU supports the ``darn`` (deliver a random number) instruction. + + :samp:`dfp` + CPU has a decimal floating point unit. + + :samp:`dscr` + CPU supports the data stream control register. + + :samp:`ebb` + CPU supports event base branching. + + :samp:`efpdouble` + CPU has a SPE double precision floating point unit. + + :samp:`efpsingle` + CPU has a SPE single precision floating point unit. + + :samp:`fpu` + CPU has a floating point unit. + + :samp:`htm` + CPU has hardware transaction memory instructions. + + :samp:`htm-nosc` + Kernel aborts hardware transactions when a syscall is made. + + :samp:`htm-no-suspend` + CPU supports hardware transaction memory but does not support the + ``tsuspend.`` instruction. + + :samp:`ic_snoop` + CPU supports icache snooping capabilities. + + :samp:`ieee128` + CPU supports 128-bit IEEE binary floating point instructions. + + :samp:`isel` + CPU supports the integer select instruction. + + :samp:`mma` + CPU supports the matrix-multiply assist instructions. + + :samp:`mmu` + CPU has a memory management unit. + + :samp:`notb` + CPU does not have a timebase (eg, 601 and 403gx). + + :samp:`pa6t` + CPU supports the PA Semi 6T CORE ISA. + + :samp:`power4` + CPU supports ISA 2.00 (eg, POWER4) + + :samp:`power5` + CPU supports ISA 2.02 (eg, POWER5) + + :samp:`power5+` + CPU supports ISA 2.03 (eg, POWER5+) + + :samp:`power6x` + CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr. + + :samp:`ppc32` + CPU supports 32-bit mode execution. + + :samp:`ppc601` + CPU supports the old POWER ISA (eg, 601) + + :samp:`ppc64` + CPU supports 64-bit mode execution. + + :samp:`ppcle` + CPU supports a little-endian mode that uses address swizzling. + + :samp:`scv` + Kernel supports system call vectored. + + :samp:`smt` + CPU support simultaneous multi-threading. + + :samp:`spe` + CPU has a signal processing extension unit. + + :samp:`tar` + CPU supports the target address register. + + :samp:`true_le` + CPU supports true little-endian mode. + + :samp:`ucache` + CPU has unified I/D cache. + + :samp:`vcrypto` + CPU supports the vector cryptography instructions. + + :samp:`vsx` + CPU supports the vector-scalar extension. + + Here is an example: + + .. code-block:: c++ + + #ifdef __BUILTIN_CPU_SUPPORTS__ + if (__builtin_cpu_supports ("fpu")) + { + asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2)); + } + else + #endif + { + dst = __fadd (src1, src2); // Software FP addition function. + } + +The following built-in functions are also available on all PowerPC +processors: + +.. code-block:: c++ + + uint64_t __builtin_ppc_get_timebase (); + unsigned long __builtin_ppc_mftb (); + double __builtin_unpack_ibm128 (__ibm128, int); + __ibm128 __builtin_pack_ibm128 (double, double); + double __builtin_mffs (void); + void __builtin_mtfsf (const int, double); + void __builtin_mtfsb0 (const int); + void __builtin_mtfsb1 (const int); + void __builtin_set_fpscr_rn (int); + +The ``__builtin_ppc_get_timebase`` and ``__builtin_ppc_mftb`` +functions generate instructions to read the Time Base Register. The +``__builtin_ppc_get_timebase`` function may generate multiple +instructions and always returns the 64 bits of the Time Base Register. +The ``__builtin_ppc_mftb`` function always generates one instruction and +returns the Time Base Register value as an unsigned long, throwing away +the most significant word on 32-bit environments. The ``__builtin_mffs`` +return the value of the FPSCR register. Note, ISA 3.0 supports the +``__builtin_mffsl()`` which permits software to read the control and +non-sticky status bits in the FSPCR without the higher latency associated with +accessing the sticky status bits. The ``__builtin_mtfsf`` takes a constant +8-bit integer field mask and a double precision floating point argument +and generates the ``mtfsf`` (extended mnemonic) instruction to write new +values to selected fields of the FPSCR. The +``__builtin_mtfsb0`` and ``__builtin_mtfsb1`` take the bit to change +as an argument. The valid bit range is between 0 and 31. The builtins map to +the ``mtfsb0`` and ``mtfsb1`` instructions which take the argument and +add 32. Hence these instructions only modify the FPSCR[32:63] bits by +changing the specified bit to a zero or one respectively. The +``__builtin_set_fpscr_rn`` builtin allows changing both of the floating +point rounding mode bits. The argument is a 2-bit value. The argument can +either be a ``const int`` or stored in a variable. The builtin uses +the ISA 3.0 +instruction ``mffscrn`` if available, otherwise it reads the FPSCR, masks +the current rounding mode bits out and OR's in the new value. + +.. _basic-powerpc-built-in-functions-available-on-isa-2.05: + +Basic PowerPC Built-in Functions Available on ISA 2.05 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The basic built-in functions described in this section are +available on the PowerPC family of processors starting with ISA 2.05 +or later. Unless specific options are explicitly disabled on the +command line, specifying option :option:`-mcpu=power6` has the effect of +enabling the :option:`-mpowerpc64`, :option:`-mpowerpc-gpopt`, +:option:`-mpowerpc-gfxopt`, :option:`-mmfcrf`, :option:`-mpopcntb`, +:option:`-mfprnd`, :option:`-mcmpb`, :option:`-mhard-dfp`, and +:option:`-mrecip-precision` options. Specify the +:option:`-maltivec` option explicitly in +combination with the above options if desired. + +The following functions require option :option:`-mcmpb`. + +.. code-block:: c++ + + unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int); + unsigned int __builtin_cmpb (unsigned int, unsigned int); + +The ``__builtin_cmpb`` function +performs a byte-wise compare on the contents of its two arguments, +returning the result of the byte-wise comparison as the returned +value. For each byte comparison, the corresponding byte of the return +value holds 0xff if the input bytes are equal and 0 if the input bytes +are not equal. If either of the arguments to this built-in function +is wider than 32 bits, the function call expands into the form that +expects ``unsigned long long int`` arguments +which is only available on 64-bit targets. + +The following built-in functions are available +when hardware decimal floating point +(:option:`-mhard-dfp`) is available: + +.. code-block:: c++ + + void __builtin_set_fpscr_drn(int); + _Decimal64 __builtin_ddedpd (int, _Decimal64); + _Decimal128 __builtin_ddedpdq (int, _Decimal128); + _Decimal64 __builtin_denbcd (int, _Decimal64); + _Decimal128 __builtin_denbcdq (int, _Decimal128); + _Decimal64 __builtin_diex (long long, _Decimal64); + _Decimal128 _builtin_diexq (long long, _Decimal128); + _Decimal64 __builtin_dscli (_Decimal64, int); + _Decimal128 __builtin_dscliq (_Decimal128, int); + _Decimal64 __builtin_dscri (_Decimal64, int); + _Decimal128 __builtin_dscriq (_Decimal128, int); + long long __builtin_dxex (_Decimal64); + long long __builtin_dxexq (_Decimal128); + _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long); + unsigned long long __builtin_unpack_dec128 (_Decimal128, int); + +The __builtin_set_fpscr_drn builtin allows changing the three decimal +floating point rounding mode bits. The argument is a 3-bit value. The +argument can either be a const int or the value can be stored in +a variable. +The builtin uses the ISA 3.0 instruction mffscdrn if available. +Otherwise the builtin reads the FPSCR, masks the current decimal rounding +mode bits out and OR's in the new value. + +The following functions require :option:`-mhard-float`, +:option:`-mpowerpc-gfxopt`, and :option:`-mpopcntb` options. + +.. code-block:: c++ + + double __builtin_recipdiv (double, double); + float __builtin_recipdivf (float, float); + double __builtin_rsqrt (double); + float __builtin_rsqrtf (float); + +The ``vec_rsqrt``, ``__builtin_rsqrt``, and +``__builtin_rsqrtf`` functions generate multiple instructions to +implement the reciprocal sqrt functionality using reciprocal sqrt +estimate instructions. + +The ``__builtin_recipdiv``, and ``__builtin_recipdivf`` +functions generate multiple instructions to implement division using +the reciprocal estimate instructions. + +The following functions require :option:`-mhard-float` and +:option:`-mmultiple` options. + +The ``__builtin_unpack_longdouble`` function takes a +``long double`` argument and a compile time constant of 0 or 1. If +the constant is 0, the first ``double`` within the +``long double`` is returned, otherwise the second ``double`` +is returned. The ``__builtin_unpack_longdouble`` function is only +available if ``long double`` uses the IBM extended double +representation. + +The ``__builtin_pack_longdouble`` function takes two ``double`` +arguments and returns a ``long double`` value that combines the two +arguments. The ``__builtin_pack_longdouble`` function is only +available if ``long double`` uses the IBM extended double +representation. + +The ``__builtin_unpack_ibm128`` function takes a ``__ibm128`` +argument and a compile time constant of 0 or 1. If the constant is 0, +the first ``double`` within the ``__ibm128`` is returned, +otherwise the second ``double`` is returned. + +The ``__builtin_pack_ibm128`` function takes two ``double`` +arguments and returns a ``__ibm128`` value that combines the two +arguments. + +Additional built-in functions are available for the 64-bit PowerPC +family of processors, for efficient use of 128-bit floating point +(``__float128``) values. + +.. _basic-powerpc-built-in-functions-available-on-isa-2.06: + +Basic PowerPC Built-in Functions Available on ISA 2.06 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The basic built-in functions described in this section are +available on the PowerPC family of processors starting with ISA 2.05 +or later. Unless specific options are explicitly disabled on the +command line, specifying option :option:`-mcpu=power7` has the effect of +enabling all the same options as for :option:`-mcpu=power6` in +addition to the :option:`-maltivec`, :option:`-mpopcntd`, and +:option:`-mvsx` options. + +The following basic built-in functions require :option:`-mpopcntd` : + +.. code-block:: c++ + + unsigned int __builtin_addg6s (unsigned int, unsigned int); + long long __builtin_bpermd (long long, long long); + unsigned int __builtin_cbcdtd (unsigned int); + unsigned int __builtin_cdtbcd (unsigned int); + long long __builtin_divde (long long, long long); + unsigned long long __builtin_divdeu (unsigned long long, unsigned long long); + int __builtin_divwe (int, int); + unsigned int __builtin_divweu (unsigned int, unsigned int); + vector __int128 __builtin_pack_vector_int128 (long long, long long); + void __builtin_rs6000_speculation_barrier (void); + long long __builtin_unpack_vector_int128 (vector __int128, signed char); + +Of these, the ``__builtin_divde`` and ``__builtin_divdeu`` functions +require a 64-bit environment. + +The following basic built-in functions, which are also supported on +x86 targets, require :option:`-mfloat128`. + +.. code-block:: c++ + + __float128 __builtin_fabsq (__float128); + __float128 __builtin_copysignq (__float128, __float128); + __float128 __builtin_infq (void); + __float128 __builtin_huge_valq (void); + __float128 __builtin_nanq (void); + __float128 __builtin_nansq (void); + + __float128 __builtin_sqrtf128 (__float128); + __float128 __builtin_fmaf128 (__float128, __float128, __float128); + +.. _basic-powerpc-built-in-functions-available-on-isa-2.07: + +Basic PowerPC Built-in Functions Available on ISA 2.07 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The basic built-in functions described in this section are +available on the PowerPC family of processors starting with ISA 2.07 +or later. Unless specific options are explicitly disabled on the +command line, specifying option :option:`-mcpu=power8` has the effect of +enabling all the same options as for :option:`-mcpu=power7` in +addition to the :option:`-mpower8-fusion`, :option:`-mpower8-vector`, +:option:`-mcrypto`, :option:`-mhtm`, :option:`-mquad-memory`, and +:option:`-mquad-memory-atomic` options. + +This section intentionally empty. + +.. _basic-powerpc-built-in-functions-available-on-isa-3.0: + +Basic PowerPC Built-in Functions Available on ISA 3.0 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The basic built-in functions described in this section are +available on the PowerPC family of processors starting with ISA 3.0 +or later. Unless specific options are explicitly disabled on the +command line, specifying option :option:`-mcpu=power9` has the effect of +enabling all the same options as for :option:`-mcpu=power8` in +addition to the :option:`-misel` option. + +The following built-in functions are available on Linux 64-bit systems +that use the ISA 3.0 instruction set (:option:`-mcpu=power9`): + +.. function:: __float128 __builtin_addf128_round_to_odd (__float128, __float128) + + Perform a 128-bit IEEE floating point add using round to odd as the + rounding mode. + + .. index:: __builtin_addf128_round_to_odd + +.. function:: __float128 __builtin_subf128_round_to_odd (__float128, __float128) + + Perform a 128-bit IEEE floating point subtract using round to odd as + the rounding mode. + + .. index:: __builtin_subf128_round_to_odd + +.. function:: __float128 __builtin_mulf128_round_to_odd (__float128, __float128) + + Perform a 128-bit IEEE floating point multiply using round to odd as + the rounding mode. + + .. index:: __builtin_mulf128_round_to_odd + +.. function:: __float128 __builtin_divf128_round_to_odd (__float128, __float128) + + Perform a 128-bit IEEE floating point divide using round to odd as + the rounding mode. + + .. index:: __builtin_divf128_round_to_odd + +.. function:: __float128 __builtin_sqrtf128_round_to_odd (__float128) + + Perform a 128-bit IEEE floating point square root using round to odd + as the rounding mode. + + .. index:: __builtin_sqrtf128_round_to_odd + +.. function:: __float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128) + + Perform a 128-bit IEEE floating point fused multiply and add operation + using round to odd as the rounding mode. + + .. index:: __builtin_fmaf128_round_to_odd + +.. function:: double __builtin_truncf128_round_to_odd (__float128) + + Convert a 128-bit IEEE floating point value to ``double`` using + round to odd as the rounding mode. + + .. index:: __builtin_truncf128_round_to_odd + +The following additional built-in functions are also available for the +PowerPC family of processors, starting with ISA 3.0 or later: + +.. code-block:: c++ + + long long __builtin_darn (void); + long long __builtin_darn_raw (void); + int __builtin_darn_32 (void); + +The ``__builtin_darn`` and ``__builtin_darn_raw`` +functions require a +64-bit environment supporting ISA 3.0 or later. +The ``__builtin_darn`` function provides a 64-bit conditioned +random number. The ``__builtin_darn_raw`` function provides a +64-bit raw random number. The ``__builtin_darn_32`` function +provides a 32-bit conditioned random number. + +The following additional built-in functions are also available for the +PowerPC family of processors, starting with ISA 3.0 or later: + +.. code-block:: c++ + + int __builtin_byte_in_set (unsigned char u, unsigned long long set); + int __builtin_byte_in_range (unsigned char u, unsigned int range); + int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges); + + int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value); + int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value); + int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value); + int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value); + + int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value); + int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value); + int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value); + int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value); + + int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value); + int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value); + int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value); + int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value); + + int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value); + int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value); + int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value); + int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value); + + double __builtin_mffsl(void); + +The ``__builtin_byte_in_set`` function requires a +64-bit environment supporting ISA 3.0 or later. This function returns +a non-zero value if and only if its ``u`` argument exactly equals one of +the eight bytes contained within its 64-bit ``set`` argument. + +The ``__builtin_byte_in_range`` and +``__builtin_byte_in_either_range`` require an environment +supporting ISA 3.0 or later. For these two functions, the +``range`` argument is encoded as 4 bytes, organized as +``hi_1:lo_1:hi_2:lo_2``. +The ``__builtin_byte_in_range`` function returns a +non-zero value if and only if its ``u`` argument is within the +range bounded between ``lo_2`` and ``hi_2`` inclusive. +The ``__builtin_byte_in_either_range`` function returns non-zero if +and only if its ``u`` argument is within either the range bounded +between ``lo_1`` and ``hi_1`` inclusive or the range bounded +between ``lo_2`` and ``hi_2`` inclusive. + +The ``__builtin_dfp_dtstsfi_lt`` function returns a non-zero value +if and only if the number of signficant digits of its ``value`` argument +is less than its ``comparison`` argument. The +``__builtin_dfp_dtstsfi_lt_dd`` and +``__builtin_dfp_dtstsfi_lt_td`` functions behave similarly, but +require that the type of the ``value`` argument be +``__Decimal64`` and ``__Decimal128`` respectively. + +The ``__builtin_dfp_dtstsfi_gt`` function returns a non-zero value +if and only if the number of signficant digits of its ``value`` argument +is greater than its ``comparison`` argument. The +``__builtin_dfp_dtstsfi_gt_dd`` and +``__builtin_dfp_dtstsfi_gt_td`` functions behave similarly, but +require that the type of the ``value`` argument be +``__Decimal64`` and ``__Decimal128`` respectively. + +The ``__builtin_dfp_dtstsfi_eq`` function returns a non-zero value +if and only if the number of signficant digits of its ``value`` argument +equals its ``comparison`` argument. The +``__builtin_dfp_dtstsfi_eq_dd`` and +``__builtin_dfp_dtstsfi_eq_td`` functions behave similarly, but +require that the type of the ``value`` argument be +``__Decimal64`` and ``__Decimal128`` respectively. + +The ``__builtin_dfp_dtstsfi_ov`` function returns a non-zero value +if and only if its ``value`` argument has an undefined number of +significant digits, such as when ``value`` is an encoding of ``NaN``. +The ``__builtin_dfp_dtstsfi_ov_dd`` and +``__builtin_dfp_dtstsfi_ov_td`` functions behave similarly, but +require that the type of the ``value`` argument be +``__Decimal64`` and ``__Decimal128`` respectively. + +The ``__builtin_mffsl`` uses the ISA 3.0 ``mffsl`` instruction to read +the FPSCR. The instruction is a lower latency version of the ``mffs`` +instruction. If the ``mffsl`` instruction is not available, then the +builtin uses the older ``mffs`` instruction to read the FPSCR. + +.. _basic-powerpc-built-in-functions-available-on-isa-3.1: + +Basic PowerPC Built-in Functions Available on ISA 3.1 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The basic built-in functions described in this section are +available on the PowerPC family of processors starting with ISA 3.1. +Unless specific options are explicitly disabled on the +command line, specifying option :option:`-mcpu=power10` has the effect of +enabling all the same options as for :option:`-mcpu=power9`. + +The following built-in functions are available on Linux 64-bit systems +that use a future architecture instruction set (:option:`-mcpu=power10`): + +.. function:: unsigned long long __builtin_cfuged (unsigned long long, unsigned long long int) + + Perform a 64-bit centrifuge operation, as if implemented by the + ``cfuged`` instruction. + +.. function:: unsigned long long __builtin_cntlzdm (unsigned long long int, unsigned long long int) + + Perform a 64-bit count leading zeros operation under mask, as if + implemented by the ``cntlzdm`` instruction. + +.. function:: unsigned long long __builtin_cnttzdm (unsigned long long, unsigned long long) + + Perform a 64-bit count trailing zeros operation under mask, as if + implemented by the ``cnttzdm`` instruction. + +.. function:: unsigned long long __builtin_pdepd (unsigned long long int, unsigned long long int) + + Perform a 64-bit parallel bits deposit operation, as if implemented by the + ``pdepd`` instruction. + +.. function:: unsigned long long __builtin_pextd (unsigned long long, unsigned long long) + + Perform a 64-bit parallel bits extract operation, as if implemented by the + ``pextd`` instruction. + +.. code-block:: c++ + + vector signed __int128 vsx_xl_sext (signed long long, signed char *) + vector signed __int128 vsx_xl_sext (signed long long, signed short *) + vector signed __int128 vsx_xl_sext (signed long long, signed int *) + vector signed __int128 vsx_xl_sext (signed long long, signed long long *) + vector unsigned __int128 vsx_xl_zext (signed long long, unsigned char *) + vector unsigned __int128 vsx_xl_zext (signed long long, unsigned short *) + vector unsigned __int128 vsx_xl_zext (signed long long, unsigned int *) + vector unsigned __int128 vsx_xl_zext (signed long long, unsigned long long *) + +Load (and sign extend) to an __int128 vector, as if implemented by the ISA 3.1 +``lxvrbx``, ``lxvrhx``, ``lxvrwx``, and ``lxvrdx`` instructions. + +.. index:: vsx_xl_sext, vsx_xl_zext + +.. code-block:: c++ + + void vec_xst_trunc (vector signed __int128, signed long long, signed char *) + void vec_xst_trunc (vector signed __int128, signed long long, signed short *) + void vec_xst_trunc (vector signed __int128, signed long long, signed int *) + void vec_xst_trunc (vector signed __int128, signed long long, signed long long *) + void vec_xst_trunc (vector unsigned __int128, signed long long, unsigned char *) + void vec_xst_trunc (vector unsigned __int128, signed long long, unsigned short *) + void vec_xst_trunc (vector unsigned __int128, signed long long, unsigned int *) + void vec_xst_trunc (vector unsigned __int128, signed long long, unsigned long long *) + +Truncate and store the rightmost element of a vector, as if implemented by the +ISA 3.1 ``stxvrbx``, ``stxvrhx``, ``stxvrwx``, and ``stxvrdx`` +instructions. + +.. index:: vec_xst_trunc \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/blackfin-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/blackfin-built-in-functions.rst new file mode 100644 index 00000000000..44189a3ef6c --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/blackfin-built-in-functions.rst @@ -0,0 +1,20 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _blackfin-built-in-functions: + +Blackfin Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Currently, there are two Blackfin-specific built-in functions. These are +used for generating ``CSYNC`` and ``SSYNC`` machine insns without +using inline assembly; by using these built-in functions the compiler can +automatically add workarounds for hardware errata involving these +instructions. These functions are named as follows: + +.. code-block:: c++ + + void __builtin_bfin_csync (void); + void __builtin_bfin_ssync (void); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/bpf-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/bpf-built-in-functions.rst new file mode 100644 index 00000000000..c4718523c03 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/bpf-built-in-functions.rst @@ -0,0 +1,100 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _bpf-built-in-functions: + +BPF Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^ + +The following built-in functions are available for eBPF targets. + +.. function:: unsigned long long __builtin_bpf_load_byte (unsigned long long offset) + + Load a byte from the ``struct sk_buff`` packet data pointed by the register ``%r6`` and return it. + +.. function:: unsigned long long __builtin_bpf_load_half (unsigned long long offset) + + Load 16-bits from the ``struct sk_buff`` packet data pointed by the register ``%r6`` and return it. + +.. function:: unsigned long long __builtin_bpf_load_word (unsigned long long offset) + + Load 32-bits from the ``struct sk_buff`` packet data pointed by the register ``%r6`` and return it. + +.. function:: void * __builtin_preserve_access_index (expr) + + BPF Compile Once-Run Everywhere (CO-RE) support. Instruct GCC to generate CO-RE relocation records for any accesses to aggregate data structures (struct, union, array types) in :samp:`{expr}`. This builtin is otherwise transparent, the return value is whatever :samp:`{expr}` evaluates to. It is also overloaded: :samp:`{expr}` may be of any type (not necessarily a pointer), the return type is the same. Has no effect if ``-mco-re`` is not in effect (either specified or implied). + +.. function:: unsigned int __builtin_preserve_field_info (expr, unsigned int kind) + + BPF Compile Once-Run Everywhere (CO-RE) support. This builtin is used to + extract information to aid in struct/union relocations. :samp:`{expr}` is + an access to a field of a struct or union. Depending on :samp:`{kind}`, different + information is returned to the program. A CO-RE relocation for the access in + :samp:`{expr}` with kind :samp:`{kind}` is recorded if ``-mco-re`` is in effect. + + The following values are supported for :samp:`{kind}` : + + :samp:`{FIELD_BYTE_OFFSET = 0}` + The returned value is the offset, in bytes, of the field from the + beginning of the containing structure. For bitfields, the byte offset + of the containing word. + + :samp:`{FIELD_BYTE_SIZE = 1}` + The returned value is the size, in bytes, of the field. For bitfields, + the size in bytes of the containing word. + + :samp:`{FIELD_EXISTENCE = 2}` + The returned value is 1 if the field exists, 0 otherwise. Always 1 at + compile time. + + :samp:`{FIELD_SIGNEDNESS = 3}` + The returned value is 1 if the field is signed, 0 otherwise. + + :samp:`{FIELD_LSHIFT_U64 = 4}` :samp:`{FIELD_RSHIFT_U64 = 5}` + The returned value is the number of bits of left- or right-shifting + respectively needed in order to recover the original value of the field, + after it has been loaded by a read of FIELD_BYTE_SIZE bytes into an + unsigned 64-bit value. Primarily useful for reading bitfield values + from structures which may change between kernel versions. + + Note that the return value is a constant which is known at + compile-time. If the field has a variable offset then + FIELD_BYTE_OFFSET, FIELD_LSHIFT_U64 and FIELD_RSHIFT_U64 are not + supported. Similarly, if the field has a variable size then + FIELD_BYTE_SIZE, FIELD_LSHIFT_U64 and FIELD_RSHIFT_U64 are not + supported. + + For example, __builtin_preserve_field_info can be used to reliably + extract bitfield values from a structure which may change between + kernel versions: + + .. code-block:: c++ + + struct S + { + short a; + int x:7; + int y:5; + }; + + int + read_y (struct S *arg) + { + unsigned long long val; + unsigned int offset = __builtin_preserve_field_info (arg->y, FIELD_BYTE_OFFSET); + unsigned int size = __builtin_presrve_field_info (arg->y, FIELD_BYTE_SIZE); + + /* Read size bytes from arg + offset into val. */ + bpf_probe_read (&val, size, arg + offset); + + val <<= __builtin_preserve_field_info (arg->y, FIELD_LSHIFT_U64); + + if (__builtin_preserve_field_info (arg->y, FIELD_SIGNEDNESS)) + val = ((long long) val >> __builtin_preserve_field_info (arg->y, FIELD_RSHIFT_U64)); + else + val >>= __builtin_preserve_field_info (arg->y, FIELD_RSHIFT_U64); + + return val; + } \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/fr-v-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/fr-v-built-in-functions.rst new file mode 100644 index 00000000000..b317839342d --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/fr-v-built-in-functions.rst @@ -0,0 +1,474 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _fr-v-built-in-functions: + +FR-V Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^ + +GCC provides many FR-V-specific built-in functions. In general, +these functions are intended to be compatible with those described +by FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu +Semiconductor. The two exceptions are ``__MDUNPACKH`` and +``__MBTOHE``, the GCC forms of which pass 128-bit values by +pointer rather than by value. + +Most of the functions are named after specific FR-V instructions. +Such functions are said to be 'directly mapped' and are summarized +here in tabular form. + +.. toctree:: + :maxdepth: 2 + + +.. _argument-types: + +Argument Types +~~~~~~~~~~~~~~ + +The arguments to the built-in functions can be divided into three groups: +register numbers, compile-time constants and run-time values. In order +to make this classification clear at a glance, the arguments and return +values are given the following pseudo types: + +.. list-table:: + :header-rows: 1 + + * - Pseudo type + - Real C type + - Constant? + - Description + + * - ``uh`` + - ``unsigned short`` + - No + - an unsigned halfword + * - ``uw1`` + - ``unsigned int`` + - No + - an unsigned word + * - ``sw1`` + - ``int`` + - No + - a signed word + * - ``uw2`` + - ``unsigned long long`` + - No + - an unsigned doubleword + * - ``sw2`` + - ``long long`` + - No + - a signed doubleword + * - ``const`` + - ``int`` + - Yes + - an integer constant + * - ``acc`` + - ``int`` + - Yes + - an ACC register number + * - ``iacc`` + - ``int`` + - Yes + - an IACC register number + +These pseudo types are not defined by GCC, they are simply a notational +convenience used in this manual. + +Arguments of type ``uh``, ``uw1``, ``sw1``, ``uw2`` +and ``sw2`` are evaluated at run time. They correspond to +register operands in the underlying FR-V instructions. + +``const`` arguments represent immediate operands in the underlying +FR-V instructions. They must be compile-time constants. + +``acc`` arguments are evaluated at compile time and specify the number +of an accumulator register. For example, an ``acc`` argument of 2 +selects the ACC2 register. + +``iacc`` arguments are similar to ``acc`` arguments but specify the +number of an IACC register. See see :ref:`other-builtins` +for more details. + +.. _directly-mapped-integer-functions: + +Directly-Mapped Integer Functions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The functions listed below map directly to FR-V I-type instructions. + +.. list-table:: + :header-rows: 1 + + * - Function prototype + - Example usage + - Assembly output + + * - ``sw1 __ADDSS (sw1, sw1)`` + - ``c = __ADDSS (a, b)`` + - ``ADDSS a,b,c`` + * - ``sw1 __SCAN (sw1, sw1)`` + - ``c = __SCAN (a, b)`` + - ``SCAN a,b,c`` + * - ``sw1 __SCUTSS (sw1)`` + - ``b = __SCUTSS (a)`` + - ``SCUTSS a,b`` + * - ``sw1 __SLASS (sw1, sw1)`` + - ``c = __SLASS (a, b)`` + - ``SLASS a,b,c`` + * - ``void __SMASS (sw1, sw1)`` + - ``__SMASS (a, b)`` + - ``SMASS a,b`` + * - ``void __SMSSS (sw1, sw1)`` + - ``__SMSSS (a, b)`` + - ``SMSSS a,b`` + * - ``void __SMU (sw1, sw1)`` + - ``__SMU (a, b)`` + - ``SMU a,b`` + * - ``sw2 __SMUL (sw1, sw1)`` + - ``c = __SMUL (a, b)`` + - ``SMUL a,b,c`` + * - ``sw1 __SUBSS (sw1, sw1)`` + - ``c = __SUBSS (a, b)`` + - ``SUBSS a,b,c`` + * - ``uw2 __UMUL (uw1, uw1)`` + - ``c = __UMUL (a, b)`` + - ``UMUL a,b,c`` + +.. _directly-mapped-media-functions: + +Directly-Mapped Media Functions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The functions listed below map directly to FR-V M-type instructions. + +.. list-table:: + :header-rows: 1 + + * - Function prototype + - Example usage + - Assembly output + + * - ``uw1 __MABSHS (sw1)`` + - ``b = __MABSHS (a)`` + - ``MABSHS a,b`` + * - ``void __MADDACCS (acc, acc)`` + - ``__MADDACCS (b, a)`` + - ``MADDACCS a,b`` + * - ``sw1 __MADDHSS (sw1, sw1)`` + - ``c = __MADDHSS (a, b)`` + - ``MADDHSS a,b,c`` + * - ``uw1 __MADDHUS (uw1, uw1)`` + - ``c = __MADDHUS (a, b)`` + - ``MADDHUS a,b,c`` + * - ``uw1 __MAND (uw1, uw1)`` + - ``c = __MAND (a, b)`` + - ``MAND a,b,c`` + * - ``void __MASACCS (acc, acc)`` + - ``__MASACCS (b, a)`` + - ``MASACCS a,b`` + * - ``uw1 __MAVEH (uw1, uw1)`` + - ``c = __MAVEH (a, b)`` + - ``MAVEH a,b,c`` + * - ``uw2 __MBTOH (uw1)`` + - ``b = __MBTOH (a)`` + - ``MBTOH a,b`` + * - ``void __MBTOHE (uw1 *, uw1)`` + - ``__MBTOHE (&b, a)`` + - ``MBTOHE a,b`` + * - ``void __MCLRACC (acc)`` + - ``__MCLRACC (a)`` + - ``MCLRACC a`` + * - ``void __MCLRACCA (void)`` + - ``__MCLRACCA ()`` + - ``MCLRACCA`` + * - ``uw1 __Mcop1 (uw1, uw1)`` + - ``c = __Mcop1 (a, b)`` + - ``Mcop1 a,b,c`` + * - ``uw1 __Mcop2 (uw1, uw1)`` + - ``c = __Mcop2 (a, b)`` + - ``Mcop2 a,b,c`` + * - ``uw1 __MCPLHI (uw2, const)`` + - ``c = __MCPLHI (a, b)`` + - ``MCPLHI a,#b,c`` + * - ``uw1 __MCPLI (uw2, const)`` + - ``c = __MCPLI (a, b)`` + - ``MCPLI a,#b,c`` + * - ``void __MCPXIS (acc, sw1, sw1)`` + - ``__MCPXIS (c, a, b)`` + - ``MCPXIS a,b,c`` + * - ``void __MCPXIU (acc, uw1, uw1)`` + - ``__MCPXIU (c, a, b)`` + - ``MCPXIU a,b,c`` + * - ``void __MCPXRS (acc, sw1, sw1)`` + - ``__MCPXRS (c, a, b)`` + - ``MCPXRS a,b,c`` + * - ``void __MCPXRU (acc, uw1, uw1)`` + - ``__MCPXRU (c, a, b)`` + - ``MCPXRU a,b,c`` + * - ``uw1 __MCUT (acc, uw1)`` + - ``c = __MCUT (a, b)`` + - ``MCUT a,b,c`` + * - ``uw1 __MCUTSS (acc, sw1)`` + - ``c = __MCUTSS (a, b)`` + - ``MCUTSS a,b,c`` + * - ``void __MDADDACCS (acc, acc)`` + - ``__MDADDACCS (b, a)`` + - ``MDADDACCS a,b`` + * - ``void __MDASACCS (acc, acc)`` + - ``__MDASACCS (b, a)`` + - ``MDASACCS a,b`` + * - ``uw2 __MDCUTSSI (acc, const)`` + - ``c = __MDCUTSSI (a, b)`` + - ``MDCUTSSI a,#b,c`` + * - ``uw2 __MDPACKH (uw2, uw2)`` + - ``c = __MDPACKH (a, b)`` + - ``MDPACKH a,b,c`` + * - ``uw2 __MDROTLI (uw2, const)`` + - ``c = __MDROTLI (a, b)`` + - ``MDROTLI a,#b,c`` + * - ``void __MDSUBACCS (acc, acc)`` + - ``__MDSUBACCS (b, a)`` + - ``MDSUBACCS a,b`` + * - ``void __MDUNPACKH (uw1 *, uw2)`` + - ``__MDUNPACKH (&b, a)`` + - ``MDUNPACKH a,b`` + * - ``uw2 __MEXPDHD (uw1, const)`` + - ``c = __MEXPDHD (a, b)`` + - ``MEXPDHD a,#b,c`` + * - ``uw1 __MEXPDHW (uw1, const)`` + - ``c = __MEXPDHW (a, b)`` + - ``MEXPDHW a,#b,c`` + * - ``uw1 __MHDSETH (uw1, const)`` + - ``c = __MHDSETH (a, b)`` + - ``MHDSETH a,#b,c`` + * - ``sw1 __MHDSETS (const)`` + - ``b = __MHDSETS (a)`` + - ``MHDSETS #a,b`` + * - ``uw1 __MHSETHIH (uw1, const)`` + - ``b = __MHSETHIH (b, a)`` + - ``MHSETHIH #a,b`` + * - ``sw1 __MHSETHIS (sw1, const)`` + - ``b = __MHSETHIS (b, a)`` + - ``MHSETHIS #a,b`` + * - ``uw1 __MHSETLOH (uw1, const)`` + - ``b = __MHSETLOH (b, a)`` + - ``MHSETLOH #a,b`` + * - ``sw1 __MHSETLOS (sw1, const)`` + - ``b = __MHSETLOS (b, a)`` + - ``MHSETLOS #a,b`` + * - ``uw1 __MHTOB (uw2)`` + - ``b = __MHTOB (a)`` + - ``MHTOB a,b`` + * - ``void __MMACHS (acc, sw1, sw1)`` + - ``__MMACHS (c, a, b)`` + - ``MMACHS a,b,c`` + * - ``void __MMACHU (acc, uw1, uw1)`` + - ``__MMACHU (c, a, b)`` + - ``MMACHU a,b,c`` + * - ``void __MMRDHS (acc, sw1, sw1)`` + - ``__MMRDHS (c, a, b)`` + - ``MMRDHS a,b,c`` + * - ``void __MMRDHU (acc, uw1, uw1)`` + - ``__MMRDHU (c, a, b)`` + - ``MMRDHU a,b,c`` + * - ``void __MMULHS (acc, sw1, sw1)`` + - ``__MMULHS (c, a, b)`` + - ``MMULHS a,b,c`` + * - ``void __MMULHU (acc, uw1, uw1)`` + - ``__MMULHU (c, a, b)`` + - ``MMULHU a,b,c`` + * - ``void __MMULXHS (acc, sw1, sw1)`` + - ``__MMULXHS (c, a, b)`` + - ``MMULXHS a,b,c`` + * - ``void __MMULXHU (acc, uw1, uw1)`` + - ``__MMULXHU (c, a, b)`` + - ``MMULXHU a,b,c`` + * - ``uw1 __MNOT (uw1)`` + - ``b = __MNOT (a)`` + - ``MNOT a,b`` + * - ``uw1 __MOR (uw1, uw1)`` + - ``c = __MOR (a, b)`` + - ``MOR a,b,c`` + * - ``uw1 __MPACKH (uh, uh)`` + - ``c = __MPACKH (a, b)`` + - ``MPACKH a,b,c`` + * - ``sw2 __MQADDHSS (sw2, sw2)`` + - ``c = __MQADDHSS (a, b)`` + - ``MQADDHSS a,b,c`` + * - ``uw2 __MQADDHUS (uw2, uw2)`` + - ``c = __MQADDHUS (a, b)`` + - ``MQADDHUS a,b,c`` + * - ``void __MQCPXIS (acc, sw2, sw2)`` + - ``__MQCPXIS (c, a, b)`` + - ``MQCPXIS a,b,c`` + * - ``void __MQCPXIU (acc, uw2, uw2)`` + - ``__MQCPXIU (c, a, b)`` + - ``MQCPXIU a,b,c`` + * - ``void __MQCPXRS (acc, sw2, sw2)`` + - ``__MQCPXRS (c, a, b)`` + - ``MQCPXRS a,b,c`` + * - ``void __MQCPXRU (acc, uw2, uw2)`` + - ``__MQCPXRU (c, a, b)`` + - ``MQCPXRU a,b,c`` + * - ``sw2 __MQLCLRHS (sw2, sw2)`` + - ``c = __MQLCLRHS (a, b)`` + - ``MQLCLRHS a,b,c`` + * - ``sw2 __MQLMTHS (sw2, sw2)`` + - ``c = __MQLMTHS (a, b)`` + - ``MQLMTHS a,b,c`` + * - ``void __MQMACHS (acc, sw2, sw2)`` + - ``__MQMACHS (c, a, b)`` + - ``MQMACHS a,b,c`` + * - ``void __MQMACHU (acc, uw2, uw2)`` + - ``__MQMACHU (c, a, b)`` + - ``MQMACHU a,b,c`` + * - ``void __MQMACXHS (acc, sw2, sw2)`` + - ``__MQMACXHS (c, a, b)`` + - ``MQMACXHS a,b,c`` + * - ``void __MQMULHS (acc, sw2, sw2)`` + - ``__MQMULHS (c, a, b)`` + - ``MQMULHS a,b,c`` + * - ``void __MQMULHU (acc, uw2, uw2)`` + - ``__MQMULHU (c, a, b)`` + - ``MQMULHU a,b,c`` + * - ``void __MQMULXHS (acc, sw2, sw2)`` + - ``__MQMULXHS (c, a, b)`` + - ``MQMULXHS a,b,c`` + * - ``void __MQMULXHU (acc, uw2, uw2)`` + - ``__MQMULXHU (c, a, b)`` + - ``MQMULXHU a,b,c`` + * - ``sw2 __MQSATHS (sw2, sw2)`` + - ``c = __MQSATHS (a, b)`` + - ``MQSATHS a,b,c`` + * - ``uw2 __MQSLLHI (uw2, int)`` + - ``c = __MQSLLHI (a, b)`` + - ``MQSLLHI a,b,c`` + * - ``sw2 __MQSRAHI (sw2, int)`` + - ``c = __MQSRAHI (a, b)`` + - ``MQSRAHI a,b,c`` + * - ``sw2 __MQSUBHSS (sw2, sw2)`` + - ``c = __MQSUBHSS (a, b)`` + - ``MQSUBHSS a,b,c`` + * - ``uw2 __MQSUBHUS (uw2, uw2)`` + - ``c = __MQSUBHUS (a, b)`` + - ``MQSUBHUS a,b,c`` + * - ``void __MQXMACHS (acc, sw2, sw2)`` + - ``__MQXMACHS (c, a, b)`` + - ``MQXMACHS a,b,c`` + * - ``void __MQXMACXHS (acc, sw2, sw2)`` + - ``__MQXMACXHS (c, a, b)`` + - ``MQXMACXHS a,b,c`` + * - ``uw1 __MRDACC (acc)`` + - ``b = __MRDACC (a)`` + - ``MRDACC a,b`` + * - ``uw1 __MRDACCG (acc)`` + - ``b = __MRDACCG (a)`` + - ``MRDACCG a,b`` + * - ``uw1 __MROTLI (uw1, const)`` + - ``c = __MROTLI (a, b)`` + - ``MROTLI a,#b,c`` + * - ``uw1 __MROTRI (uw1, const)`` + - ``c = __MROTRI (a, b)`` + - ``MROTRI a,#b,c`` + * - ``sw1 __MSATHS (sw1, sw1)`` + - ``c = __MSATHS (a, b)`` + - ``MSATHS a,b,c`` + * - ``uw1 __MSATHU (uw1, uw1)`` + - ``c = __MSATHU (a, b)`` + - ``MSATHU a,b,c`` + * - ``uw1 __MSLLHI (uw1, const)`` + - ``c = __MSLLHI (a, b)`` + - ``MSLLHI a,#b,c`` + * - ``sw1 __MSRAHI (sw1, const)`` + - ``c = __MSRAHI (a, b)`` + - ``MSRAHI a,#b,c`` + * - ``uw1 __MSRLHI (uw1, const)`` + - ``c = __MSRLHI (a, b)`` + - ``MSRLHI a,#b,c`` + * - ``void __MSUBACCS (acc, acc)`` + - ``__MSUBACCS (b, a)`` + - ``MSUBACCS a,b`` + * - ``sw1 __MSUBHSS (sw1, sw1)`` + - ``c = __MSUBHSS (a, b)`` + - ``MSUBHSS a,b,c`` + * - ``uw1 __MSUBHUS (uw1, uw1)`` + - ``c = __MSUBHUS (a, b)`` + - ``MSUBHUS a,b,c`` + * - ``void __MTRAP (void)`` + - ``__MTRAP ()`` + - ``MTRAP`` + * - ``uw2 __MUNPACKH (uw1)`` + - ``b = __MUNPACKH (a)`` + - ``MUNPACKH a,b`` + * - ``uw1 __MWCUT (uw2, uw1)`` + - ``c = __MWCUT (a, b)`` + - ``MWCUT a,b,c`` + * - ``void __MWTACC (acc, uw1)`` + - ``__MWTACC (b, a)`` + - ``MWTACC a,b`` + * - ``void __MWTACCG (acc, uw1)`` + - ``__MWTACCG (b, a)`` + - ``MWTACCG a,b`` + * - ``uw1 __MXOR (uw1, uw1)`` + - ``c = __MXOR (a, b)`` + - ``MXOR a,b,c`` + +.. _raw-read-write-functions: + +Raw Read/Write Functions +~~~~~~~~~~~~~~~~~~~~~~~~ + +This sections describes built-in functions related to read and write +instructions to access memory. These functions generate +``membar`` instructions to flush the I/O load and stores where +appropriate, as described in Fujitsu's manual described above. + +.. code-block:: c++ + + unsigned char __builtin_read8 (void *data); + unsigned short __builtin_read16 (void *data); + unsigned long __builtin_read32 (void *data); + unsigned long long __builtin_read64 (void *data); + void __builtin_write8 (void *data, unsigned char datum); + void __builtin_write16 (void *data, unsigned short datum); + void __builtin_write32 (void *data, unsigned long datum); + void __builtin_write64 (void *data, unsigned long long datum); + +Other Built-in Functions +~~~~~~~~~~~~~~~~~~~~~~~~ + +This section describes built-in functions that are not named after +a specific FR-V instruction. + +.. function:: sw2 __IACCreadll (iacc reg) + + Return the full 64-bit value of IACC0. The :samp:`{reg}` argument is reserved + for future expansion and must be 0. + +.. function:: sw1 __IACCreadl (iacc reg) + + Return the value of IACC0H if :samp:`{reg}` is 0 and IACC0L if :samp:`{reg}` is 1. + Other values of :samp:`{reg}` are rejected as invalid. + +.. function:: void __IACCsetll (iacc reg, sw2 x) + + Set the full 64-bit value of IACC0 to :samp:`{x}`. The :samp:`{reg}` argument + is reserved for future expansion and must be 0. + +.. function:: void __IACCsetl (iacc reg, sw1 x) + + Set IACC0H to :samp:`{x}` if :samp:`{reg}` is 0 and IACC0L to :samp:`{x}` if :samp:`{reg}` + is 1. Other values of :samp:`{reg}` are rejected as invalid. + +.. function:: void __data_prefetch0 (const void *x) + + Use the ``dcpl`` instruction to load the contents of address :samp:`{x}` + into the data cache. + +.. function:: void __data_prefetch (const void *x) + + Use the ``nldub`` instruction to load the contents of address :samp:`{x}` + into the data cache. The instruction is issued in slot I1. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-dsp-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-dsp-built-in-functions.rst new file mode 100644 index 00000000000..83fbb38f14c --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-dsp-built-in-functions.rst @@ -0,0 +1,312 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _mips-dsp-built-in-functions: + +MIPS DSP Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The MIPS DSP Application-Specific Extension (ASE) includes new +instructions that are designed to improve the performance of DSP and +media applications. It provides instructions that operate on packed +8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data. + +GCC supports MIPS DSP operations using both the generic +vector extensions (see :ref:`vector-extensions`) and a collection of +MIPS-specific built-in functions. Both kinds of support are +enabled by the :option:`-mdsp` command-line option. + +Revision 2 of the ASE was introduced in the second half of 2006. +This revision adds extra instructions to the original ASE, but is +otherwise backwards-compatible with it. You can select revision 2 +using the command-line option :option:`-mdspr2` ; this option implies +:option:`-mdsp`. + +The SCOUNT and POS bits of the DSP control register are global. The +WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and +POS bits. During optimization, the compiler does not delete these +instructions and it does not delete calls to functions containing +these instructions. + +At present, GCC only provides support for operations on 32-bit +vectors. The vector type associated with 8-bit integer data is +usually called ``v4i8``, the vector type associated with Q7 +is usually called ``v4q7``, the vector type associated with 16-bit +integer data is usually called ``v2i16``, and the vector type +associated with Q15 is usually called ``v2q15``. They can be +defined in C as follows: + +.. code-block:: c++ + + typedef signed char v4i8 __attribute__ ((vector_size(4))); + typedef signed char v4q7 __attribute__ ((vector_size(4))); + typedef short v2i16 __attribute__ ((vector_size(4))); + typedef short v2q15 __attribute__ ((vector_size(4))); + +``v4i8``, ``v4q7``, ``v2i16`` and ``v2q15`` values are +initialized in the same way as aggregates. For example: + +.. code-block:: c++ + + v4i8 a = {1, 2, 3, 4}; + v4i8 b; + b = (v4i8) {5, 6, 7, 8}; + + v2q15 c = {0x0fcb, 0x3a75}; + v2q15 d; + d = (v2q15) {0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15}; + +.. note:: + + The CPU's endianness determines the order in which values + are packed. On little-endian targets, the first value is the least + significant and the last value is the most significant. The opposite + order applies to big-endian targets. For example, the code above + sets the lowest byte of ``a`` to ``1`` on little-endian targets + and ``4`` on big-endian targets. + +.. note:: + + Q7, Q15 and Q31 values must be initialized with their integer + representation. As shown in this example, the integer representation + of a Q7 value can be obtained by multiplying the fractional value by + ``0x1.0p7``. The equivalent for Q15 values is to multiply by + ``0x1.0p15``. The equivalent for Q31 values is to multiply by + ``0x1.0p31``. + +The table below lists the ``v4i8`` and ``v2q15`` operations for which +hardware support exists. ``a`` and ``b`` are ``v4i8`` values, +and ``c`` and ``d`` are ``v2q15`` values. + +.. list-table:: + :header-rows: 1 + + * - C code + - MIPS instruction + + * - ``a + b`` + - ``addu.qb`` + * - ``c + d`` + - ``addq.ph`` + * - ``a - b`` + - ``subu.qb`` + * - ``c - d`` + - ``subq.ph`` + +The table below lists the ``v2i16`` operation for which +hardware support exists for the DSP ASE REV 2. ``e`` and ``f`` are +``v2i16`` values. + +.. list-table:: + :header-rows: 1 + + * - C code + - MIPS instruction + + * - ``e * f`` + - ``mul.ph`` + +It is easier to describe the DSP built-in functions if we first define +the following types: + +.. code-block:: c++ + + typedef int q31; + typedef int i32; + typedef unsigned int ui32; + typedef long long a64; + +``q31`` and ``i32`` are actually the same as ``int``, but we +use ``q31`` to indicate a Q31 fractional value and ``i32`` to +indicate a 32-bit integer value. Similarly, ``a64`` is the same as +``long long``, but we use ``a64`` to indicate values that are +placed in one of the four DSP accumulators (``$ac0``, +``$ac1``, ``$ac2`` or ``$ac3``). + +Also, some built-in functions prefer or require immediate numbers as +parameters, because the corresponding DSP instructions accept both immediate +numbers and register operands, or accept immediate numbers only. The +immediate parameters are listed as follows. + +.. code-block:: c++ + + imm0_3: 0 to 3. + imm0_7: 0 to 7. + imm0_15: 0 to 15. + imm0_31: 0 to 31. + imm0_63: 0 to 63. + imm0_255: 0 to 255. + imm_n32_31: -32 to 31. + imm_n512_511: -512 to 511. + +The following built-in functions map directly to a particular MIPS DSP +instruction. Please refer to the architecture specification +for details on what each instruction does. + +.. code-block:: c++ + + v2q15 __builtin_mips_addq_ph (v2q15, v2q15); + v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15); + q31 __builtin_mips_addq_s_w (q31, q31); + v4i8 __builtin_mips_addu_qb (v4i8, v4i8); + v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8); + v2q15 __builtin_mips_subq_ph (v2q15, v2q15); + v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15); + q31 __builtin_mips_subq_s_w (q31, q31); + v4i8 __builtin_mips_subu_qb (v4i8, v4i8); + v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8); + i32 __builtin_mips_addsc (i32, i32); + i32 __builtin_mips_addwc (i32, i32); + i32 __builtin_mips_modsub (i32, i32); + i32 __builtin_mips_raddu_w_qb (v4i8); + v2q15 __builtin_mips_absq_s_ph (v2q15); + q31 __builtin_mips_absq_s_w (q31); + v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15); + v2q15 __builtin_mips_precrq_ph_w (q31, q31); + v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31); + v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15); + q31 __builtin_mips_preceq_w_phl (v2q15); + q31 __builtin_mips_preceq_w_phr (v2q15); + v2q15 __builtin_mips_precequ_ph_qbl (v4i8); + v2q15 __builtin_mips_precequ_ph_qbr (v4i8); + v2q15 __builtin_mips_precequ_ph_qbla (v4i8); + v2q15 __builtin_mips_precequ_ph_qbra (v4i8); + v2q15 __builtin_mips_preceu_ph_qbl (v4i8); + v2q15 __builtin_mips_preceu_ph_qbr (v4i8); + v2q15 __builtin_mips_preceu_ph_qbla (v4i8); + v2q15 __builtin_mips_preceu_ph_qbra (v4i8); + v4i8 __builtin_mips_shll_qb (v4i8, imm0_7); + v4i8 __builtin_mips_shll_qb (v4i8, i32); + v2q15 __builtin_mips_shll_ph (v2q15, imm0_15); + v2q15 __builtin_mips_shll_ph (v2q15, i32); + v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15); + v2q15 __builtin_mips_shll_s_ph (v2q15, i32); + q31 __builtin_mips_shll_s_w (q31, imm0_31); + q31 __builtin_mips_shll_s_w (q31, i32); + v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7); + v4i8 __builtin_mips_shrl_qb (v4i8, i32); + v2q15 __builtin_mips_shra_ph (v2q15, imm0_15); + v2q15 __builtin_mips_shra_ph (v2q15, i32); + v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15); + v2q15 __builtin_mips_shra_r_ph (v2q15, i32); + q31 __builtin_mips_shra_r_w (q31, imm0_31); + q31 __builtin_mips_shra_r_w (q31, i32); + v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15); + v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15); + v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15); + q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15); + q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15); + a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8); + a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8); + a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8); + a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8); + a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15); + a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31); + a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15); + a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31); + a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15); + a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15); + a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15); + a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15); + a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15); + i32 __builtin_mips_bitrev (i32); + i32 __builtin_mips_insv (i32, i32); + v4i8 __builtin_mips_repl_qb (imm0_255); + v4i8 __builtin_mips_repl_qb (i32); + v2q15 __builtin_mips_repl_ph (imm_n512_511); + v2q15 __builtin_mips_repl_ph (i32); + void __builtin_mips_cmpu_eq_qb (v4i8, v4i8); + void __builtin_mips_cmpu_lt_qb (v4i8, v4i8); + void __builtin_mips_cmpu_le_qb (v4i8, v4i8); + i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8); + i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8); + i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8); + void __builtin_mips_cmp_eq_ph (v2q15, v2q15); + void __builtin_mips_cmp_lt_ph (v2q15, v2q15); + void __builtin_mips_cmp_le_ph (v2q15, v2q15); + v4i8 __builtin_mips_pick_qb (v4i8, v4i8); + v2q15 __builtin_mips_pick_ph (v2q15, v2q15); + v2q15 __builtin_mips_packrl_ph (v2q15, v2q15); + i32 __builtin_mips_extr_w (a64, imm0_31); + i32 __builtin_mips_extr_w (a64, i32); + i32 __builtin_mips_extr_r_w (a64, imm0_31); + i32 __builtin_mips_extr_s_h (a64, i32); + i32 __builtin_mips_extr_rs_w (a64, imm0_31); + i32 __builtin_mips_extr_rs_w (a64, i32); + i32 __builtin_mips_extr_s_h (a64, imm0_31); + i32 __builtin_mips_extr_r_w (a64, i32); + i32 __builtin_mips_extp (a64, imm0_31); + i32 __builtin_mips_extp (a64, i32); + i32 __builtin_mips_extpdp (a64, imm0_31); + i32 __builtin_mips_extpdp (a64, i32); + a64 __builtin_mips_shilo (a64, imm_n32_31); + a64 __builtin_mips_shilo (a64, i32); + a64 __builtin_mips_mthlip (a64, i32); + void __builtin_mips_wrdsp (i32, imm0_63); + i32 __builtin_mips_rddsp (imm0_63); + i32 __builtin_mips_lbux (void *, i32); + i32 __builtin_mips_lhx (void *, i32); + i32 __builtin_mips_lwx (void *, i32); + a64 __builtin_mips_ldx (void *, i32); /* MIPS64 only */ + i32 __builtin_mips_bposge32 (void); + a64 __builtin_mips_madd (a64, i32, i32); + a64 __builtin_mips_maddu (a64, ui32, ui32); + a64 __builtin_mips_msub (a64, i32, i32); + a64 __builtin_mips_msubu (a64, ui32, ui32); + a64 __builtin_mips_mult (i32, i32); + a64 __builtin_mips_multu (ui32, ui32); + +The following built-in functions map directly to a particular MIPS DSP REV 2 +instruction. Please refer to the architecture specification +for details on what each instruction does. + +.. code-block:: c++ + + v4q7 __builtin_mips_absq_s_qb (v4q7); + v2i16 __builtin_mips_addu_ph (v2i16, v2i16); + v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16); + v4i8 __builtin_mips_adduh_qb (v4i8, v4i8); + v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8); + i32 __builtin_mips_append (i32, i32, imm0_31); + i32 __builtin_mips_balign (i32, i32, imm0_3); + i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8); + i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8); + i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8); + a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16); + a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16); + v2i16 __builtin_mips_mul_ph (v2i16, v2i16); + v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16); + q31 __builtin_mips_mulq_rs_w (q31, q31); + v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15); + q31 __builtin_mips_mulq_s_w (q31, q31); + a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16); + v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16); + v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31); + v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31); + i32 __builtin_mips_prepend (i32, i32, imm0_31); + v4i8 __builtin_mips_shra_qb (v4i8, imm0_7); + v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7); + v4i8 __builtin_mips_shra_qb (v4i8, i32); + v4i8 __builtin_mips_shra_r_qb (v4i8, i32); + v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15); + v2i16 __builtin_mips_shrl_ph (v2i16, i32); + v2i16 __builtin_mips_subu_ph (v2i16, v2i16); + v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16); + v4i8 __builtin_mips_subuh_qb (v4i8, v4i8); + v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8); + v2q15 __builtin_mips_addqh_ph (v2q15, v2q15); + v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15); + q31 __builtin_mips_addqh_w (q31, q31); + q31 __builtin_mips_addqh_r_w (q31, q31); + v2q15 __builtin_mips_subqh_ph (v2q15, v2q15); + v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15); + q31 __builtin_mips_subqh_w (q31, q31); + q31 __builtin_mips_subqh_r_w (q31, q31); + a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16); + a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16); + a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15); + a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15); + a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15); + a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-loongson-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-loongson-built-in-functions.rst new file mode 100644 index 00000000000..dae2f963275 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-loongson-built-in-functions.rst @@ -0,0 +1,447 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _mips-loongson-built-in-functions: + +MIPS Loongson Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC provides intrinsics to access the SIMD instructions provided by the +ST Microelectronics Loongson-2E and -2F processors. These intrinsics, +available after inclusion of the ``loongson.h`` header file, +operate on the following 64-bit vector types: + +* ``uint8x8_t``, a vector of eight unsigned 8-bit integers; + +* ``uint16x4_t``, a vector of four unsigned 16-bit integers; + +* ``uint32x2_t``, a vector of two unsigned 32-bit integers; + +* ``int8x8_t``, a vector of eight signed 8-bit integers; + +* ``int16x4_t``, a vector of four signed 16-bit integers; + +* ``int32x2_t``, a vector of two signed 32-bit integers. + +The intrinsics provided are listed below; each is named after the +machine instruction to which it corresponds, with suffixes added as +appropriate to distinguish intrinsics that expand to the same machine +instruction yet have different argument types. Refer to the architecture +documentation for a description of the functionality of each +instruction. + +.. code-block:: c++ + + int16x4_t packsswh (int32x2_t s, int32x2_t t); + int8x8_t packsshb (int16x4_t s, int16x4_t t); + uint8x8_t packushb (uint16x4_t s, uint16x4_t t); + uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t); + uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t); + uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t); + int32x2_t paddw_s (int32x2_t s, int32x2_t t); + int16x4_t paddh_s (int16x4_t s, int16x4_t t); + int8x8_t paddb_s (int8x8_t s, int8x8_t t); + uint64_t paddd_u (uint64_t s, uint64_t t); + int64_t paddd_s (int64_t s, int64_t t); + int16x4_t paddsh (int16x4_t s, int16x4_t t); + int8x8_t paddsb (int8x8_t s, int8x8_t t); + uint16x4_t paddush (uint16x4_t s, uint16x4_t t); + uint8x8_t paddusb (uint8x8_t s, uint8x8_t t); + uint64_t pandn_ud (uint64_t s, uint64_t t); + uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t); + uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t); + uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t); + int64_t pandn_sd (int64_t s, int64_t t); + int32x2_t pandn_sw (int32x2_t s, int32x2_t t); + int16x4_t pandn_sh (int16x4_t s, int16x4_t t); + int8x8_t pandn_sb (int8x8_t s, int8x8_t t); + uint16x4_t pavgh (uint16x4_t s, uint16x4_t t); + uint8x8_t pavgb (uint8x8_t s, uint8x8_t t); + uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t); + uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t); + uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t); + int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t); + int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t); + int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t); + uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t); + uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t); + uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t); + int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t); + int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t); + int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t); + uint16x4_t pextrh_u (uint16x4_t s, int field); + int16x4_t pextrh_s (int16x4_t s, int field); + uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t); + uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t); + uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t); + uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t); + int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t); + int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t); + int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t); + int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t); + int32x2_t pmaddhw (int16x4_t s, int16x4_t t); + int16x4_t pmaxsh (int16x4_t s, int16x4_t t); + uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t); + int16x4_t pminsh (int16x4_t s, int16x4_t t); + uint8x8_t pminub (uint8x8_t s, uint8x8_t t); + uint8x8_t pmovmskb_u (uint8x8_t s); + int8x8_t pmovmskb_s (int8x8_t s); + uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t); + int16x4_t pmulhh (int16x4_t s, int16x4_t t); + int16x4_t pmullh (int16x4_t s, int16x4_t t); + int64_t pmuluw (uint32x2_t s, uint32x2_t t); + uint8x8_t pasubub (uint8x8_t s, uint8x8_t t); + uint16x4_t biadd (uint8x8_t s); + uint16x4_t psadbh (uint8x8_t s, uint8x8_t t); + uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order); + int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order); + uint16x4_t psllh_u (uint16x4_t s, uint8_t amount); + int16x4_t psllh_s (int16x4_t s, uint8_t amount); + uint32x2_t psllw_u (uint32x2_t s, uint8_t amount); + int32x2_t psllw_s (int32x2_t s, uint8_t amount); + uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount); + int16x4_t psrlh_s (int16x4_t s, uint8_t amount); + uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount); + int32x2_t psrlw_s (int32x2_t s, uint8_t amount); + uint16x4_t psrah_u (uint16x4_t s, uint8_t amount); + int16x4_t psrah_s (int16x4_t s, uint8_t amount); + uint32x2_t psraw_u (uint32x2_t s, uint8_t amount); + int32x2_t psraw_s (int32x2_t s, uint8_t amount); + uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t); + uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t); + uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t); + int32x2_t psubw_s (int32x2_t s, int32x2_t t); + int16x4_t psubh_s (int16x4_t s, int16x4_t t); + int8x8_t psubb_s (int8x8_t s, int8x8_t t); + uint64_t psubd_u (uint64_t s, uint64_t t); + int64_t psubd_s (int64_t s, int64_t t); + int16x4_t psubsh (int16x4_t s, int16x4_t t); + int8x8_t psubsb (int8x8_t s, int8x8_t t); + uint16x4_t psubush (uint16x4_t s, uint16x4_t t); + uint8x8_t psubusb (uint8x8_t s, uint8x8_t t); + uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t); + uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t); + uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t); + int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t); + int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t); + int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t); + uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t); + uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t); + uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t); + int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t); + int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t); + int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t); + +.. toctree:: + :maxdepth: 2 + + +.. _paired-single-arithmetic: + +Paired-Single Arithmetic +~~~~~~~~~~~~~~~~~~~~~~~~ + +The table below lists the ``v2sf`` operations for which hardware +support exists. ``a``, ``b`` and ``c`` are ``v2sf`` +values and ``x`` is an integral value. + +.. list-table:: + :header-rows: 1 + + * - C code + - MIPS instruction + + * - ``a + b`` + - ``add.ps`` + * - ``a - b`` + - ``sub.ps`` + * - ``-a`` + - ``neg.ps`` + * - ``a * b`` + - ``mul.ps`` + * - ``a * b + c`` + - ``madd.ps`` + * - ``a * b - c`` + - ``msub.ps`` + * - ``-(a * b + c)`` + - ``nmadd.ps`` + * - ``-(a * b - c)`` + - ``nmsub.ps`` + * - ``x ? a : b`` + - ``movn.ps`` / ``movz.ps`` + +Note that the multiply-accumulate instructions can be disabled +using the command-line option ``-mno-fused-madd``. + +.. _paired-single-built-in-functions: + +Paired-Single Built-in Functions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following paired-single functions map directly to a particular +MIPS instruction. Please refer to the architecture specification +for details on what each instruction does. + +.. function:: v2sf __builtin_mips_pll_ps (v2sf, v2sf) + + Pair lower lower (``pll.ps``). + +.. function:: v2sf __builtin_mips_pul_ps (v2sf, v2sf) + + Pair upper lower (``pul.ps``). + +.. function:: v2sf __builtin_mips_plu_ps (v2sf, v2sf) + + Pair lower upper (``plu.ps``). + +.. function:: v2sf __builtin_mips_puu_ps (v2sf, v2sf) + + Pair upper upper (``puu.ps``). + +.. function:: v2sf __builtin_mips_cvt_ps_s (float, float) + + Convert pair to paired single (``cvt.ps.s``). + +.. function:: float __builtin_mips_cvt_s_pl (v2sf) + + Convert pair lower to single (``cvt.s.pl``). + +.. function:: float __builtin_mips_cvt_s_pu (v2sf) + + Convert pair upper to single (``cvt.s.pu``). + +.. function:: v2sf __builtin_mips_abs_ps (v2sf) + + Absolute value (``abs.ps``). + +.. function:: v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int) + + Align variable (``alnv.ps``). + + .. note:: + + The value of the third parameter must be 0 or 4 + modulo 8, otherwise the result is unpredictable. Please read the + instruction description for details. + +The following multi-instruction functions are also available. +In each case, :samp:`{cond}` can be any of the 16 floating-point conditions: +``f``, ``un``, ``eq``, ``ueq``, ``olt``, ``ult``, +``ole``, ``ule``, ``sf``, ``ngle``, ``seq``, ``ngl``, +``lt``, ``nge``, ``le`` or ``ngt``. + +.. function:: v2sf __builtin_mips_movt_c_cond_ps (v2sf a, v2sf b, v2sf c, v2sf d) +.. function:: v2sf __builtin_mips_movf_c_cond_ps (v2sf a, v2sf b, v2sf c, v2sf d) + + Conditional move based on floating-point comparison (``c.cond.ps``, + ``movt.ps`` / ``movf.ps``). + + The ``movt`` functions return the value :samp:`{x}` computed by: + + .. code-block:: c++ + + c.cond.ps cc,a,b + mov.ps x,c + movt.ps x,d,cc + + The ``movf`` functions are similar but use ``movf.ps`` instead + of ``movt.ps``. + +.. function:: int __builtin_mips_upper_c_cond_ps (v2sf a, v2sf b) +.. function:: int __builtin_mips_lower_c_cond_ps (v2sf a, v2sf b) + + Comparison of two paired-single values (``c.cond.ps``, + ``bc1t`` / ``bc1f``). + + These functions compare :samp:`{a}` and :samp:`{b}` using ``c.cond.ps`` + and return either the upper or lower half of the result. For example: + + .. code-block:: c++ + + v2sf a, b; + if (__builtin_mips_upper_c_eq_ps (a, b)) + upper_halves_are_equal (); + else + upper_halves_are_unequal (); + + if (__builtin_mips_lower_c_eq_ps (a, b)) + lower_halves_are_equal (); + else + lower_halves_are_unequal (); + +.. _mips-3d-built-in-functions: + +MIPS-3D Built-in Functions +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The MIPS-3D Application-Specific Extension (ASE) includes additional +paired-single instructions that are designed to improve the performance +of 3D graphics operations. Support for these instructions is controlled +by the :option:`-mips3d` command-line option. + +The functions listed below map directly to a particular MIPS-3D +instruction. Please refer to the architecture specification for +more details on what each instruction does. + +.. function:: v2sf __builtin_mips_addr_ps (v2sf, v2sf) + + Reduction add (``addr.ps``). + +.. function:: v2sf __builtin_mips_mulr_ps (v2sf, v2sf) + + Reduction multiply (``mulr.ps``). + +.. function:: v2sf __builtin_mips_cvt_pw_ps (v2sf) + + Convert paired single to paired word (``cvt.pw.ps``). + +.. function:: v2sf __builtin_mips_cvt_ps_pw (v2sf) + + Convert paired word to paired single (``cvt.ps.pw``). + +.. function:: float __builtin_mips_recip1_s (float) +.. function:: double __builtin_mips_recip1_d (double) +.. function:: v2sf __builtin_mips_recip1_ps (v2sf) + + Reduced-precision reciprocal (sequence step 1) (``recip1.fmt``). + +.. function:: float __builtin_mips_recip2_s (float, float) +.. function:: double __builtin_mips_recip2_d (double, double) +.. function:: v2sf __builtin_mips_recip2_ps (v2sf, v2sf) + + Reduced-precision reciprocal (sequence step 2) (``recip2.fmt``). + +.. function:: float __builtin_mips_rsqrt1_s (float) +.. function:: double __builtin_mips_rsqrt1_d (double) +.. function:: v2sf __builtin_mips_rsqrt1_ps (v2sf) + + Reduced-precision reciprocal square root (sequence step 1) + (``rsqrt1.fmt``). + +.. function:: float __builtin_mips_rsqrt2_s (float, float) +.. function:: double __builtin_mips_rsqrt2_d (double, double) +.. function:: v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf) + + Reduced-precision reciprocal square root (sequence step 2) + (``rsqrt2.fmt``). + +The following multi-instruction functions are also available. +In each case, :samp:`{cond}` can be any of the 16 floating-point conditions: + +``f``, ``un``, ``eq``, ``ueq``, ``olt``, ``ult``, +``ole``, ``ule``, ``sf``, ``ngle``, ``seq``, +``ngl``, ``lt``, ``nge``, ``le`` or ``ngt``. + +.. function:: int __builtin_mips_cabs_cond_s (float a, float b) +.. function:: int __builtin_mips_cabs_cond_d (double a, double b) + + Absolute comparison of two scalar values (``cabs.cond.fmt``, + ``bc1t`` / ``bc1f``). + + These functions compare :samp:`{a}` and :samp:`{b}` using ``cabs.cond.s`` + or ``cabs.cond.d`` and return the result as a boolean value. + For example: + + .. code-block:: c++ + + float a, b; + if (__builtin_mips_cabs_eq_s (a, b)) + true (); + else + false (); + +.. function:: int __builtin_mips_upper_cabs_cond_ps (v2sf a, v2sf b) +.. function:: int __builtin_mips_lower_cabs_cond_ps (v2sf a, v2sf b) + + Absolute comparison of two paired-single values (``cabs.cond.ps``, + ``bc1t`` / ``bc1f``). + + These functions compare :samp:`{a}` and :samp:`{b}` using ``cabs.cond.ps`` + and return either the upper or lower half of the result. For example: + + .. code-block:: c++ + + v2sf a, b; + if (__builtin_mips_upper_cabs_eq_ps (a, b)) + upper_halves_are_equal (); + else + upper_halves_are_unequal (); + + if (__builtin_mips_lower_cabs_eq_ps (a, b)) + lower_halves_are_equal (); + else + lower_halves_are_unequal (); + +.. function:: v2sf __builtin_mips_movt_cabs_cond_ps (v2sf a, v2sf b, v2sf c, v2sf d) +.. function:: v2sf __builtin_mips_movf_cabs_cond_ps (v2sf a, v2sf b, v2sf c, v2sf d) + + Conditional move based on absolute comparison (``cabs.cond.ps``, + ``movt.ps`` / ``movf.ps``). + + The ``movt`` functions return the value :samp:`{x}` computed by: + + .. code-block:: c++ + + cabs.cond.ps cc,a,b + mov.ps x,c + movt.ps x,d,cc + + The ``movf`` functions are similar but use ``movf.ps`` instead + of ``movt.ps``. + +.. function:: int __builtin_mips_any_c_cond_ps (v2sf a, v2sf b) +.. function:: int __builtin_mips_all_c_cond_ps (v2sf a, v2sf b) +.. function:: int __builtin_mips_any_cabs_cond_ps (v2sf a, v2sf b) +.. function:: int __builtin_mips_all_cabs_cond_ps (v2sf a, v2sf b) + + Comparison of two paired-single values + (``c.cond.ps`` / ``cabs.cond.ps``, + ``bc1any2t`` / ``bc1any2f``). + + These functions compare :samp:`{a}` and :samp:`{b}` using ``c.cond.ps`` + or ``cabs.cond.ps``. The ``any`` forms return ``true`` if either + result is ``true`` and the ``all`` forms return ``true`` if both results are ``true``. + For example: + + .. code-block:: c++ + + v2sf a, b; + if (__builtin_mips_any_c_eq_ps (a, b)) + one_is_true (); + else + both_are_false (); + + if (__builtin_mips_all_c_eq_ps (a, b)) + both_are_true (); + else + one_is_false (); + +.. function:: int __builtin_mips_any_c_cond_4s (v2sf a, v2sf b, v2sf c, v2sf d) +.. function:: int __builtin_mips_all_c_cond_4s (v2sf a, v2sf b, v2sf c, v2sf d) +.. function:: int __builtin_mips_any_cabs_cond_4s (v2sf a, v2sf b, v2sf c, v2sf d) +.. function:: int __builtin_mips_all_cabs_cond_4s (v2sf a, v2sf b, v2sf c, v2sf d) + + Comparison of four paired-single values + (``c.cond.ps`` / ``cabs.cond.ps``, + ``bc1any4t`` / ``bc1any4f``). + + These functions use ``c.cond.ps`` or ``cabs.cond.ps`` + to compare :samp:`{a}` with :samp:`{b}` and to compare :samp:`{c}` with :samp:`{d}`. + The ``any`` forms return ``true`` if any of the four results are ``true`` + and the ``all`` forms return ``true`` if all four results are ``true``. + For example: + + .. code-block:: c++ + + v2sf a, b, c, d; + if (__builtin_mips_any_c_eq_4s (a, b, c, d)) + some_are_true (); + else + all_are_false (); + + if (__builtin_mips_all_c_eq_4s (a, b, c, d)) + all_are_true (); + else + some_are_false (); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-paired-single-support.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-paired-single-support.rst new file mode 100644 index 00000000000..aeb86cfe606 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-paired-single-support.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _mips-paired-single-support: + +MIPS Paired-Single Support +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The MIPS64 architecture includes a number of instructions that +operate on pairs of single-precision floating-point values. +Each pair is packed into a 64-bit floating-point register, +with one element being designated the 'upper half' and +the other being designated the 'lower half'. + +GCC supports paired-single operations using both the generic +vector extensions (see :ref:`vector-extensions`) and a collection of +MIPS-specific built-in functions. Both kinds of support are +enabled by the :option:`-mpaired-single` command-line option. + +The vector type associated with paired-single values is usually +called ``v2sf``. It can be defined in C as follows: + +.. code-block:: c++ + + typedef float v2sf __attribute__ ((vector_size (8))); + +``v2sf`` values are initialized in the same way as aggregates. +For example: + +.. code-block:: c++ + + v2sf a = {1.5, 9.1}; + v2sf b; + float e, f; + b = (v2sf) {e, f}; + +.. note:: + The CPU's endianness determines which value is stored in + the upper half of a register and which value is stored in the lower half. + On little-endian targets, the first value is the lower one and the second + value is the upper one. The opposite order applies to big-endian targets. + For example, the code above sets the lower half of ``a`` to + ``1.5`` on little-endian targets and ``9.1`` on big-endian targets. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-simd-architecture-msa-support.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-simd-architecture-msa-support.rst new file mode 100644 index 00000000000..ba42478e84b --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/mips-simd-architecture-msa-support.rst @@ -0,0 +1,812 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _mips-simd-architecture-(msa)-support: + +MIPS SIMD Architecture (MSA) Support +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC provides intrinsics to access the SIMD instructions provided by the +MSA MIPS SIMD Architecture. The interface is made available by including +```` and using :option:`-mmsa -mhard-float -mfp64 -mnan=2008`. +For each ``__builtin_msa_*``, there is a shortened name of the intrinsic, +``__msa_*``. + +MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and +64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point +data elements. The following vectors typedefs are included in ``msa.h`` : + +* ``v16i8``, a vector of sixteen signed 8-bit integers; + +* ``v16u8``, a vector of sixteen unsigned 8-bit integers; + +* ``v8i16``, a vector of eight signed 16-bit integers; + +* ``v8u16``, a vector of eight unsigned 16-bit integers; + +* ``v4i32``, a vector of four signed 32-bit integers; + +* ``v4u32``, a vector of four unsigned 32-bit integers; + +* ``v2i64``, a vector of two signed 64-bit integers; + +* ``v2u64``, a vector of two unsigned 64-bit integers; + +* ``v4f32``, a vector of four 32-bit floats; + +* ``v2f64``, a vector of two 64-bit doubles. + +Instructions and corresponding built-ins may have additional restrictions and/or +input/output values manipulated: + +* ``imm0_1``, an integer literal in range 0 to 1; + +* ``imm0_3``, an integer literal in range 0 to 3; + +* ``imm0_7``, an integer literal in range 0 to 7; + +* ``imm0_15``, an integer literal in range 0 to 15; + +* ``imm0_31``, an integer literal in range 0 to 31; + +* ``imm0_63``, an integer literal in range 0 to 63; + +* ``imm0_255``, an integer literal in range 0 to 255; + +* ``imm_n16_15``, an integer literal in range -16 to 15; + +* ``imm_n512_511``, an integer literal in range -512 to 511; + +* ``imm_n1024_1022``, an integer literal in range -512 to 511 left + shifted by 1 bit, i.e., -1024, -1022, ..., 1020, 1022; + +* ``imm_n2048_2044``, an integer literal in range -512 to 511 left + shifted by 2 bits, i.e., -2048, -2044, ..., 2040, 2044; + +* ``imm_n4096_4088``, an integer literal in range -512 to 511 left + shifted by 3 bits, i.e., -4096, -4088, ..., 4080, 4088; + +* ``imm1_4``, an integer literal in range 1 to 4; + +* ``i32, i64, u32, u64, f32, f64``, defined as follows: + +.. code-block:: c++ + + { + typedef int i32; + #if __LONG_MAX__ == __LONG_LONG_MAX__ + typedef long i64; + #else + typedef long long i64; + #endif + + typedef unsigned int u32; + #if __LONG_MAX__ == __LONG_LONG_MAX__ + typedef unsigned long u64; + #else + typedef unsigned long long u64; + #endif + + typedef double f64; + typedef float f32; + } + +.. _mips-simd-architecture-built-in-functions: + +MIPS SIMD Architecture Built-in Functions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The intrinsics provided are listed below; each is named after the +machine instruction. + +.. code-block:: c++ + + v16i8 __builtin_msa_add_a_b (v16i8, v16i8); + v8i16 __builtin_msa_add_a_h (v8i16, v8i16); + v4i32 __builtin_msa_add_a_w (v4i32, v4i32); + v2i64 __builtin_msa_add_a_d (v2i64, v2i64); + + v16i8 __builtin_msa_adds_a_b (v16i8, v16i8); + v8i16 __builtin_msa_adds_a_h (v8i16, v8i16); + v4i32 __builtin_msa_adds_a_w (v4i32, v4i32); + v2i64 __builtin_msa_adds_a_d (v2i64, v2i64); + + v16i8 __builtin_msa_adds_s_b (v16i8, v16i8); + v8i16 __builtin_msa_adds_s_h (v8i16, v8i16); + v4i32 __builtin_msa_adds_s_w (v4i32, v4i32); + v2i64 __builtin_msa_adds_s_d (v2i64, v2i64); + + v16u8 __builtin_msa_adds_u_b (v16u8, v16u8); + v8u16 __builtin_msa_adds_u_h (v8u16, v8u16); + v4u32 __builtin_msa_adds_u_w (v4u32, v4u32); + v2u64 __builtin_msa_adds_u_d (v2u64, v2u64); + + v16i8 __builtin_msa_addv_b (v16i8, v16i8); + v8i16 __builtin_msa_addv_h (v8i16, v8i16); + v4i32 __builtin_msa_addv_w (v4i32, v4i32); + v2i64 __builtin_msa_addv_d (v2i64, v2i64); + + v16i8 __builtin_msa_addvi_b (v16i8, imm0_31); + v8i16 __builtin_msa_addvi_h (v8i16, imm0_31); + v4i32 __builtin_msa_addvi_w (v4i32, imm0_31); + v2i64 __builtin_msa_addvi_d (v2i64, imm0_31); + + v16u8 __builtin_msa_and_v (v16u8, v16u8); + + v16u8 __builtin_msa_andi_b (v16u8, imm0_255); + + v16i8 __builtin_msa_asub_s_b (v16i8, v16i8); + v8i16 __builtin_msa_asub_s_h (v8i16, v8i16); + v4i32 __builtin_msa_asub_s_w (v4i32, v4i32); + v2i64 __builtin_msa_asub_s_d (v2i64, v2i64); + + v16u8 __builtin_msa_asub_u_b (v16u8, v16u8); + v8u16 __builtin_msa_asub_u_h (v8u16, v8u16); + v4u32 __builtin_msa_asub_u_w (v4u32, v4u32); + v2u64 __builtin_msa_asub_u_d (v2u64, v2u64); + + v16i8 __builtin_msa_ave_s_b (v16i8, v16i8); + v8i16 __builtin_msa_ave_s_h (v8i16, v8i16); + v4i32 __builtin_msa_ave_s_w (v4i32, v4i32); + v2i64 __builtin_msa_ave_s_d (v2i64, v2i64); + + v16u8 __builtin_msa_ave_u_b (v16u8, v16u8); + v8u16 __builtin_msa_ave_u_h (v8u16, v8u16); + v4u32 __builtin_msa_ave_u_w (v4u32, v4u32); + v2u64 __builtin_msa_ave_u_d (v2u64, v2u64); + + v16i8 __builtin_msa_aver_s_b (v16i8, v16i8); + v8i16 __builtin_msa_aver_s_h (v8i16, v8i16); + v4i32 __builtin_msa_aver_s_w (v4i32, v4i32); + v2i64 __builtin_msa_aver_s_d (v2i64, v2i64); + + v16u8 __builtin_msa_aver_u_b (v16u8, v16u8); + v8u16 __builtin_msa_aver_u_h (v8u16, v8u16); + v4u32 __builtin_msa_aver_u_w (v4u32, v4u32); + v2u64 __builtin_msa_aver_u_d (v2u64, v2u64); + + v16u8 __builtin_msa_bclr_b (v16u8, v16u8); + v8u16 __builtin_msa_bclr_h (v8u16, v8u16); + v4u32 __builtin_msa_bclr_w (v4u32, v4u32); + v2u64 __builtin_msa_bclr_d (v2u64, v2u64); + + v16u8 __builtin_msa_bclri_b (v16u8, imm0_7); + v8u16 __builtin_msa_bclri_h (v8u16, imm0_15); + v4u32 __builtin_msa_bclri_w (v4u32, imm0_31); + v2u64 __builtin_msa_bclri_d (v2u64, imm0_63); + + v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8); + v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16); + v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32); + v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64); + + v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7); + v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15); + v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31); + v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63); + + v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8); + v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16); + v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32); + v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64); + + v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7); + v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15); + v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31); + v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63); + + v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8); + + v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255); + + v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8); + + v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255); + + v16u8 __builtin_msa_bneg_b (v16u8, v16u8); + v8u16 __builtin_msa_bneg_h (v8u16, v8u16); + v4u32 __builtin_msa_bneg_w (v4u32, v4u32); + v2u64 __builtin_msa_bneg_d (v2u64, v2u64); + + v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7); + v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15); + v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31); + v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63); + + i32 __builtin_msa_bnz_b (v16u8); + i32 __builtin_msa_bnz_h (v8u16); + i32 __builtin_msa_bnz_w (v4u32); + i32 __builtin_msa_bnz_d (v2u64); + + i32 __builtin_msa_bnz_v (v16u8); + + v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8); + + v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255); + + v16u8 __builtin_msa_bset_b (v16u8, v16u8); + v8u16 __builtin_msa_bset_h (v8u16, v8u16); + v4u32 __builtin_msa_bset_w (v4u32, v4u32); + v2u64 __builtin_msa_bset_d (v2u64, v2u64); + + v16u8 __builtin_msa_bseti_b (v16u8, imm0_7); + v8u16 __builtin_msa_bseti_h (v8u16, imm0_15); + v4u32 __builtin_msa_bseti_w (v4u32, imm0_31); + v2u64 __builtin_msa_bseti_d (v2u64, imm0_63); + + i32 __builtin_msa_bz_b (v16u8); + i32 __builtin_msa_bz_h (v8u16); + i32 __builtin_msa_bz_w (v4u32); + i32 __builtin_msa_bz_d (v2u64); + + i32 __builtin_msa_bz_v (v16u8); + + v16i8 __builtin_msa_ceq_b (v16i8, v16i8); + v8i16 __builtin_msa_ceq_h (v8i16, v8i16); + v4i32 __builtin_msa_ceq_w (v4i32, v4i32); + v2i64 __builtin_msa_ceq_d (v2i64, v2i64); + + v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15); + v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15); + v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15); + v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15); + + i32 __builtin_msa_cfcmsa (imm0_31); + + v16i8 __builtin_msa_cle_s_b (v16i8, v16i8); + v8i16 __builtin_msa_cle_s_h (v8i16, v8i16); + v4i32 __builtin_msa_cle_s_w (v4i32, v4i32); + v2i64 __builtin_msa_cle_s_d (v2i64, v2i64); + + v16i8 __builtin_msa_cle_u_b (v16u8, v16u8); + v8i16 __builtin_msa_cle_u_h (v8u16, v8u16); + v4i32 __builtin_msa_cle_u_w (v4u32, v4u32); + v2i64 __builtin_msa_cle_u_d (v2u64, v2u64); + + v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15); + v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15); + v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15); + v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15); + + v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31); + v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31); + v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31); + v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31); + + v16i8 __builtin_msa_clt_s_b (v16i8, v16i8); + v8i16 __builtin_msa_clt_s_h (v8i16, v8i16); + v4i32 __builtin_msa_clt_s_w (v4i32, v4i32); + v2i64 __builtin_msa_clt_s_d (v2i64, v2i64); + + v16i8 __builtin_msa_clt_u_b (v16u8, v16u8); + v8i16 __builtin_msa_clt_u_h (v8u16, v8u16); + v4i32 __builtin_msa_clt_u_w (v4u32, v4u32); + v2i64 __builtin_msa_clt_u_d (v2u64, v2u64); + + v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15); + v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15); + v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15); + v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15); + + v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31); + v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31); + v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31); + v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31); + + i32 __builtin_msa_copy_s_b (v16i8, imm0_15); + i32 __builtin_msa_copy_s_h (v8i16, imm0_7); + i32 __builtin_msa_copy_s_w (v4i32, imm0_3); + i64 __builtin_msa_copy_s_d (v2i64, imm0_1); + + u32 __builtin_msa_copy_u_b (v16i8, imm0_15); + u32 __builtin_msa_copy_u_h (v8i16, imm0_7); + u32 __builtin_msa_copy_u_w (v4i32, imm0_3); + u64 __builtin_msa_copy_u_d (v2i64, imm0_1); + + void __builtin_msa_ctcmsa (imm0_31, i32); + + v16i8 __builtin_msa_div_s_b (v16i8, v16i8); + v8i16 __builtin_msa_div_s_h (v8i16, v8i16); + v4i32 __builtin_msa_div_s_w (v4i32, v4i32); + v2i64 __builtin_msa_div_s_d (v2i64, v2i64); + + v16u8 __builtin_msa_div_u_b (v16u8, v16u8); + v8u16 __builtin_msa_div_u_h (v8u16, v8u16); + v4u32 __builtin_msa_div_u_w (v4u32, v4u32); + v2u64 __builtin_msa_div_u_d (v2u64, v2u64); + + v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8); + v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16); + v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32); + + v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8); + v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16); + v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32); + + v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8); + v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16); + v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32); + + v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8); + v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16); + v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32); + + v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8); + v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16); + v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32); + + v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8); + v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16); + v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32); + + v4f32 __builtin_msa_fadd_w (v4f32, v4f32); + v2f64 __builtin_msa_fadd_d (v2f64, v2f64); + + v4i32 __builtin_msa_fcaf_w (v4f32, v4f32); + v2i64 __builtin_msa_fcaf_d (v2f64, v2f64); + + v4i32 __builtin_msa_fceq_w (v4f32, v4f32); + v2i64 __builtin_msa_fceq_d (v2f64, v2f64); + + v4i32 __builtin_msa_fclass_w (v4f32); + v2i64 __builtin_msa_fclass_d (v2f64); + + v4i32 __builtin_msa_fcle_w (v4f32, v4f32); + v2i64 __builtin_msa_fcle_d (v2f64, v2f64); + + v4i32 __builtin_msa_fclt_w (v4f32, v4f32); + v2i64 __builtin_msa_fclt_d (v2f64, v2f64); + + v4i32 __builtin_msa_fcne_w (v4f32, v4f32); + v2i64 __builtin_msa_fcne_d (v2f64, v2f64); + + v4i32 __builtin_msa_fcor_w (v4f32, v4f32); + v2i64 __builtin_msa_fcor_d (v2f64, v2f64); + + v4i32 __builtin_msa_fcueq_w (v4f32, v4f32); + v2i64 __builtin_msa_fcueq_d (v2f64, v2f64); + + v4i32 __builtin_msa_fcule_w (v4f32, v4f32); + v2i64 __builtin_msa_fcule_d (v2f64, v2f64); + + v4i32 __builtin_msa_fcult_w (v4f32, v4f32); + v2i64 __builtin_msa_fcult_d (v2f64, v2f64); + + v4i32 __builtin_msa_fcun_w (v4f32, v4f32); + v2i64 __builtin_msa_fcun_d (v2f64, v2f64); + + v4i32 __builtin_msa_fcune_w (v4f32, v4f32); + v2i64 __builtin_msa_fcune_d (v2f64, v2f64); + + v4f32 __builtin_msa_fdiv_w (v4f32, v4f32); + v2f64 __builtin_msa_fdiv_d (v2f64, v2f64); + + v8i16 __builtin_msa_fexdo_h (v4f32, v4f32); + v4f32 __builtin_msa_fexdo_w (v2f64, v2f64); + + v4f32 __builtin_msa_fexp2_w (v4f32, v4i32); + v2f64 __builtin_msa_fexp2_d (v2f64, v2i64); + + v4f32 __builtin_msa_fexupl_w (v8i16); + v2f64 __builtin_msa_fexupl_d (v4f32); + + v4f32 __builtin_msa_fexupr_w (v8i16); + v2f64 __builtin_msa_fexupr_d (v4f32); + + v4f32 __builtin_msa_ffint_s_w (v4i32); + v2f64 __builtin_msa_ffint_s_d (v2i64); + + v4f32 __builtin_msa_ffint_u_w (v4u32); + v2f64 __builtin_msa_ffint_u_d (v2u64); + + v4f32 __builtin_msa_ffql_w (v8i16); + v2f64 __builtin_msa_ffql_d (v4i32); + + v4f32 __builtin_msa_ffqr_w (v8i16); + v2f64 __builtin_msa_ffqr_d (v4i32); + + v16i8 __builtin_msa_fill_b (i32); + v8i16 __builtin_msa_fill_h (i32); + v4i32 __builtin_msa_fill_w (i32); + v2i64 __builtin_msa_fill_d (i64); + + v4f32 __builtin_msa_flog2_w (v4f32); + v2f64 __builtin_msa_flog2_d (v2f64); + + v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32); + v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64); + + v4f32 __builtin_msa_fmax_w (v4f32, v4f32); + v2f64 __builtin_msa_fmax_d (v2f64, v2f64); + + v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32); + v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64); + + v4f32 __builtin_msa_fmin_w (v4f32, v4f32); + v2f64 __builtin_msa_fmin_d (v2f64, v2f64); + + v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32); + v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64); + + v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32); + v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64); + + v4f32 __builtin_msa_fmul_w (v4f32, v4f32); + v2f64 __builtin_msa_fmul_d (v2f64, v2f64); + + v4f32 __builtin_msa_frint_w (v4f32); + v2f64 __builtin_msa_frint_d (v2f64); + + v4f32 __builtin_msa_frcp_w (v4f32); + v2f64 __builtin_msa_frcp_d (v2f64); + + v4f32 __builtin_msa_frsqrt_w (v4f32); + v2f64 __builtin_msa_frsqrt_d (v2f64); + + v4i32 __builtin_msa_fsaf_w (v4f32, v4f32); + v2i64 __builtin_msa_fsaf_d (v2f64, v2f64); + + v4i32 __builtin_msa_fseq_w (v4f32, v4f32); + v2i64 __builtin_msa_fseq_d (v2f64, v2f64); + + v4i32 __builtin_msa_fsle_w (v4f32, v4f32); + v2i64 __builtin_msa_fsle_d (v2f64, v2f64); + + v4i32 __builtin_msa_fslt_w (v4f32, v4f32); + v2i64 __builtin_msa_fslt_d (v2f64, v2f64); + + v4i32 __builtin_msa_fsne_w (v4f32, v4f32); + v2i64 __builtin_msa_fsne_d (v2f64, v2f64); + + v4i32 __builtin_msa_fsor_w (v4f32, v4f32); + v2i64 __builtin_msa_fsor_d (v2f64, v2f64); + + v4f32 __builtin_msa_fsqrt_w (v4f32); + v2f64 __builtin_msa_fsqrt_d (v2f64); + + v4f32 __builtin_msa_fsub_w (v4f32, v4f32); + v2f64 __builtin_msa_fsub_d (v2f64, v2f64); + + v4i32 __builtin_msa_fsueq_w (v4f32, v4f32); + v2i64 __builtin_msa_fsueq_d (v2f64, v2f64); + + v4i32 __builtin_msa_fsule_w (v4f32, v4f32); + v2i64 __builtin_msa_fsule_d (v2f64, v2f64); + + v4i32 __builtin_msa_fsult_w (v4f32, v4f32); + v2i64 __builtin_msa_fsult_d (v2f64, v2f64); + + v4i32 __builtin_msa_fsun_w (v4f32, v4f32); + v2i64 __builtin_msa_fsun_d (v2f64, v2f64); + + v4i32 __builtin_msa_fsune_w (v4f32, v4f32); + v2i64 __builtin_msa_fsune_d (v2f64, v2f64); + + v4i32 __builtin_msa_ftint_s_w (v4f32); + v2i64 __builtin_msa_ftint_s_d (v2f64); + + v4u32 __builtin_msa_ftint_u_w (v4f32); + v2u64 __builtin_msa_ftint_u_d (v2f64); + + v8i16 __builtin_msa_ftq_h (v4f32, v4f32); + v4i32 __builtin_msa_ftq_w (v2f64, v2f64); + + v4i32 __builtin_msa_ftrunc_s_w (v4f32); + v2i64 __builtin_msa_ftrunc_s_d (v2f64); + + v4u32 __builtin_msa_ftrunc_u_w (v4f32); + v2u64 __builtin_msa_ftrunc_u_d (v2f64); + + v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8); + v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16); + v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32); + + v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8); + v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16); + v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32); + + v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8); + v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16); + v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32); + + v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8); + v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16); + v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32); + + v16i8 __builtin_msa_ilvev_b (v16i8, v16i8); + v8i16 __builtin_msa_ilvev_h (v8i16, v8i16); + v4i32 __builtin_msa_ilvev_w (v4i32, v4i32); + v2i64 __builtin_msa_ilvev_d (v2i64, v2i64); + + v16i8 __builtin_msa_ilvl_b (v16i8, v16i8); + v8i16 __builtin_msa_ilvl_h (v8i16, v8i16); + v4i32 __builtin_msa_ilvl_w (v4i32, v4i32); + v2i64 __builtin_msa_ilvl_d (v2i64, v2i64); + + v16i8 __builtin_msa_ilvod_b (v16i8, v16i8); + v8i16 __builtin_msa_ilvod_h (v8i16, v8i16); + v4i32 __builtin_msa_ilvod_w (v4i32, v4i32); + v2i64 __builtin_msa_ilvod_d (v2i64, v2i64); + + v16i8 __builtin_msa_ilvr_b (v16i8, v16i8); + v8i16 __builtin_msa_ilvr_h (v8i16, v8i16); + v4i32 __builtin_msa_ilvr_w (v4i32, v4i32); + v2i64 __builtin_msa_ilvr_d (v2i64, v2i64); + + v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32); + v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32); + v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32); + v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64); + + v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8); + v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16); + v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32); + v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64); + + v16i8 __builtin_msa_ld_b (const void *, imm_n512_511); + v8i16 __builtin_msa_ld_h (const void *, imm_n1024_1022); + v4i32 __builtin_msa_ld_w (const void *, imm_n2048_2044); + v2i64 __builtin_msa_ld_d (const void *, imm_n4096_4088); + + v16i8 __builtin_msa_ldi_b (imm_n512_511); + v8i16 __builtin_msa_ldi_h (imm_n512_511); + v4i32 __builtin_msa_ldi_w (imm_n512_511); + v2i64 __builtin_msa_ldi_d (imm_n512_511); + + v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16); + v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32); + + v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16); + v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32); + + v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8); + v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16); + v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32); + v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64); + + v16i8 __builtin_msa_max_a_b (v16i8, v16i8); + v8i16 __builtin_msa_max_a_h (v8i16, v8i16); + v4i32 __builtin_msa_max_a_w (v4i32, v4i32); + v2i64 __builtin_msa_max_a_d (v2i64, v2i64); + + v16i8 __builtin_msa_max_s_b (v16i8, v16i8); + v8i16 __builtin_msa_max_s_h (v8i16, v8i16); + v4i32 __builtin_msa_max_s_w (v4i32, v4i32); + v2i64 __builtin_msa_max_s_d (v2i64, v2i64); + + v16u8 __builtin_msa_max_u_b (v16u8, v16u8); + v8u16 __builtin_msa_max_u_h (v8u16, v8u16); + v4u32 __builtin_msa_max_u_w (v4u32, v4u32); + v2u64 __builtin_msa_max_u_d (v2u64, v2u64); + + v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15); + v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15); + v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15); + v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15); + + v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31); + v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31); + v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31); + v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31); + + v16i8 __builtin_msa_min_a_b (v16i8, v16i8); + v8i16 __builtin_msa_min_a_h (v8i16, v8i16); + v4i32 __builtin_msa_min_a_w (v4i32, v4i32); + v2i64 __builtin_msa_min_a_d (v2i64, v2i64); + + v16i8 __builtin_msa_min_s_b (v16i8, v16i8); + v8i16 __builtin_msa_min_s_h (v8i16, v8i16); + v4i32 __builtin_msa_min_s_w (v4i32, v4i32); + v2i64 __builtin_msa_min_s_d (v2i64, v2i64); + + v16u8 __builtin_msa_min_u_b (v16u8, v16u8); + v8u16 __builtin_msa_min_u_h (v8u16, v8u16); + v4u32 __builtin_msa_min_u_w (v4u32, v4u32); + v2u64 __builtin_msa_min_u_d (v2u64, v2u64); + + v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15); + v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15); + v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15); + v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15); + + v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31); + v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31); + v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31); + v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31); + + v16i8 __builtin_msa_mod_s_b (v16i8, v16i8); + v8i16 __builtin_msa_mod_s_h (v8i16, v8i16); + v4i32 __builtin_msa_mod_s_w (v4i32, v4i32); + v2i64 __builtin_msa_mod_s_d (v2i64, v2i64); + + v16u8 __builtin_msa_mod_u_b (v16u8, v16u8); + v8u16 __builtin_msa_mod_u_h (v8u16, v8u16); + v4u32 __builtin_msa_mod_u_w (v4u32, v4u32); + v2u64 __builtin_msa_mod_u_d (v2u64, v2u64); + + v16i8 __builtin_msa_move_v (v16i8); + + v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16); + v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32); + + v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16); + v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32); + + v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8); + v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16); + v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32); + v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64); + + v8i16 __builtin_msa_mul_q_h (v8i16, v8i16); + v4i32 __builtin_msa_mul_q_w (v4i32, v4i32); + + v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16); + v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32); + + v16i8 __builtin_msa_mulv_b (v16i8, v16i8); + v8i16 __builtin_msa_mulv_h (v8i16, v8i16); + v4i32 __builtin_msa_mulv_w (v4i32, v4i32); + v2i64 __builtin_msa_mulv_d (v2i64, v2i64); + + v16i8 __builtin_msa_nloc_b (v16i8); + v8i16 __builtin_msa_nloc_h (v8i16); + v4i32 __builtin_msa_nloc_w (v4i32); + v2i64 __builtin_msa_nloc_d (v2i64); + + v16i8 __builtin_msa_nlzc_b (v16i8); + v8i16 __builtin_msa_nlzc_h (v8i16); + v4i32 __builtin_msa_nlzc_w (v4i32); + v2i64 __builtin_msa_nlzc_d (v2i64); + + v16u8 __builtin_msa_nor_v (v16u8, v16u8); + + v16u8 __builtin_msa_nori_b (v16u8, imm0_255); + + v16u8 __builtin_msa_or_v (v16u8, v16u8); + + v16u8 __builtin_msa_ori_b (v16u8, imm0_255); + + v16i8 __builtin_msa_pckev_b (v16i8, v16i8); + v8i16 __builtin_msa_pckev_h (v8i16, v8i16); + v4i32 __builtin_msa_pckev_w (v4i32, v4i32); + v2i64 __builtin_msa_pckev_d (v2i64, v2i64); + + v16i8 __builtin_msa_pckod_b (v16i8, v16i8); + v8i16 __builtin_msa_pckod_h (v8i16, v8i16); + v4i32 __builtin_msa_pckod_w (v4i32, v4i32); + v2i64 __builtin_msa_pckod_d (v2i64, v2i64); + + v16i8 __builtin_msa_pcnt_b (v16i8); + v8i16 __builtin_msa_pcnt_h (v8i16); + v4i32 __builtin_msa_pcnt_w (v4i32); + v2i64 __builtin_msa_pcnt_d (v2i64); + + v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7); + v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15); + v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31); + v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63); + + v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7); + v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15); + v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31); + v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63); + + v16i8 __builtin_msa_shf_b (v16i8, imm0_255); + v8i16 __builtin_msa_shf_h (v8i16, imm0_255); + v4i32 __builtin_msa_shf_w (v4i32, imm0_255); + + v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32); + v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32); + v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32); + v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32); + + v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15); + v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7); + v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3); + v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1); + + v16i8 __builtin_msa_sll_b (v16i8, v16i8); + v8i16 __builtin_msa_sll_h (v8i16, v8i16); + v4i32 __builtin_msa_sll_w (v4i32, v4i32); + v2i64 __builtin_msa_sll_d (v2i64, v2i64); + + v16i8 __builtin_msa_slli_b (v16i8, imm0_7); + v8i16 __builtin_msa_slli_h (v8i16, imm0_15); + v4i32 __builtin_msa_slli_w (v4i32, imm0_31); + v2i64 __builtin_msa_slli_d (v2i64, imm0_63); + + v16i8 __builtin_msa_splat_b (v16i8, i32); + v8i16 __builtin_msa_splat_h (v8i16, i32); + v4i32 __builtin_msa_splat_w (v4i32, i32); + v2i64 __builtin_msa_splat_d (v2i64, i32); + + v16i8 __builtin_msa_splati_b (v16i8, imm0_15); + v8i16 __builtin_msa_splati_h (v8i16, imm0_7); + v4i32 __builtin_msa_splati_w (v4i32, imm0_3); + v2i64 __builtin_msa_splati_d (v2i64, imm0_1); + + v16i8 __builtin_msa_sra_b (v16i8, v16i8); + v8i16 __builtin_msa_sra_h (v8i16, v8i16); + v4i32 __builtin_msa_sra_w (v4i32, v4i32); + v2i64 __builtin_msa_sra_d (v2i64, v2i64); + + v16i8 __builtin_msa_srai_b (v16i8, imm0_7); + v8i16 __builtin_msa_srai_h (v8i16, imm0_15); + v4i32 __builtin_msa_srai_w (v4i32, imm0_31); + v2i64 __builtin_msa_srai_d (v2i64, imm0_63); + + v16i8 __builtin_msa_srar_b (v16i8, v16i8); + v8i16 __builtin_msa_srar_h (v8i16, v8i16); + v4i32 __builtin_msa_srar_w (v4i32, v4i32); + v2i64 __builtin_msa_srar_d (v2i64, v2i64); + + v16i8 __builtin_msa_srari_b (v16i8, imm0_7); + v8i16 __builtin_msa_srari_h (v8i16, imm0_15); + v4i32 __builtin_msa_srari_w (v4i32, imm0_31); + v2i64 __builtin_msa_srari_d (v2i64, imm0_63); + + v16i8 __builtin_msa_srl_b (v16i8, v16i8); + v8i16 __builtin_msa_srl_h (v8i16, v8i16); + v4i32 __builtin_msa_srl_w (v4i32, v4i32); + v2i64 __builtin_msa_srl_d (v2i64, v2i64); + + v16i8 __builtin_msa_srli_b (v16i8, imm0_7); + v8i16 __builtin_msa_srli_h (v8i16, imm0_15); + v4i32 __builtin_msa_srli_w (v4i32, imm0_31); + v2i64 __builtin_msa_srli_d (v2i64, imm0_63); + + v16i8 __builtin_msa_srlr_b (v16i8, v16i8); + v8i16 __builtin_msa_srlr_h (v8i16, v8i16); + v4i32 __builtin_msa_srlr_w (v4i32, v4i32); + v2i64 __builtin_msa_srlr_d (v2i64, v2i64); + + v16i8 __builtin_msa_srlri_b (v16i8, imm0_7); + v8i16 __builtin_msa_srlri_h (v8i16, imm0_15); + v4i32 __builtin_msa_srlri_w (v4i32, imm0_31); + v2i64 __builtin_msa_srlri_d (v2i64, imm0_63); + + void __builtin_msa_st_b (v16i8, void *, imm_n512_511); + void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022); + void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044); + void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088); + + v16i8 __builtin_msa_subs_s_b (v16i8, v16i8); + v8i16 __builtin_msa_subs_s_h (v8i16, v8i16); + v4i32 __builtin_msa_subs_s_w (v4i32, v4i32); + v2i64 __builtin_msa_subs_s_d (v2i64, v2i64); + + v16u8 __builtin_msa_subs_u_b (v16u8, v16u8); + v8u16 __builtin_msa_subs_u_h (v8u16, v8u16); + v4u32 __builtin_msa_subs_u_w (v4u32, v4u32); + v2u64 __builtin_msa_subs_u_d (v2u64, v2u64); + + v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8); + v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16); + v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32); + v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64); + + v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8); + v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16); + v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32); + v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64); + + v16i8 __builtin_msa_subv_b (v16i8, v16i8); + v8i16 __builtin_msa_subv_h (v8i16, v8i16); + v4i32 __builtin_msa_subv_w (v4i32, v4i32); + v2i64 __builtin_msa_subv_d (v2i64, v2i64); + + v16i8 __builtin_msa_subvi_b (v16i8, imm0_31); + v8i16 __builtin_msa_subvi_h (v8i16, imm0_31); + v4i32 __builtin_msa_subvi_w (v4i32, imm0_31); + v2i64 __builtin_msa_subvi_d (v2i64, imm0_31); + + v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8); + v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16); + v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32); + v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64); + + v16u8 __builtin_msa_xor_v (v16u8, v16u8); + + v16u8 __builtin_msa_xori_b (v16u8, imm0_255); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/msp430-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/msp430-built-in-functions.rst new file mode 100644 index 00000000000..04560f1d60c --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/msp430-built-in-functions.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _msp430-built-in-functions: + +MSP430 Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC provides a couple of special builtin functions to aid in the +writing of interrupt handlers in C. + +.. function:: __bic_SR_register_on_exit (int mask) + + This clears the indicated bits in the saved copy of the status register + currently residing on the stack. This only works inside interrupt + handlers and the changes to the status register will only take affect + once the handler returns. + +.. function:: __bis_SR_register_on_exit (int mask) + + This sets the indicated bits in the saved copy of the status register + currently residing on the stack. This only works inside interrupt + handlers and the changes to the status register will only take affect + once the handler returns. + +.. function:: __delay_cycles (long long cycles) + + This inserts an instruction sequence that takes exactly :samp:`{cycles}` + cycles (between 0 and about 17E9) to complete. The inserted sequence + may use jumps, loops, or no-ops, and does not interfere with any other + instructions. Note that :samp:`{cycles}` must be a compile-time constant + integer - that is, you must pass a number, not a variable that may be + optimized to a constant later. The number of cycles delayed by this + builtin is exact. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/nds32-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/nds32-built-in-functions.rst new file mode 100644 index 00000000000..28365f92924 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/nds32-built-in-functions.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _nds32-built-in-functions: + +NDS32 Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^ + +These built-in functions are available for the NDS32 target: + +.. function:: void __builtin_nds32_isync (int *addr) + + Insert an ISYNC instruction into the instruction stream where + :samp:`{addr}` is an instruction address for serialization. + +.. function:: void __builtin_nds32_isb (void) + + Insert an ISB instruction into the instruction stream. + +.. function:: int __builtin_nds32_mfsr (int sr) + + Return the content of a system register which is mapped by :samp:`{sr}`. + +.. function:: int __builtin_nds32_mfusr (int usr) + + Return the content of a user space register which is mapped by :samp:`{usr}`. + +.. function:: void __builtin_nds32_mtsr (int value, int sr) + + Move the :samp:`{value}` to a system register which is mapped by :samp:`{sr}`. + +.. function:: void __builtin_nds32_mtusr (int value, int usr) + + Move the :samp:`{value}` to a user space register which is mapped by :samp:`{usr}`. + +.. function:: void __builtin_nds32_setgie_en (void) + + Enable global interrupt. + +.. function:: void __builtin_nds32_setgie_dis (void) + + Disable global interrupt. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/other-mips-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/other-mips-built-in-functions.rst new file mode 100644 index 00000000000..15703487680 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/other-mips-built-in-functions.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _other-mips-built-in-functions: + +Other MIPS Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC provides other MIPS-specific built-in functions: + +.. function:: void __builtin_mips_cache (int op, const volatile void *addr) + + Insert a :samp:`cache` instruction with operands :samp:`{op}` and :samp:`{addr}`. + GCC defines the preprocessor macro ``___GCC_HAVE_BUILTIN_MIPS_CACHE`` + when this function is available. + +.. function:: unsigned int __builtin_mips_get_fcsr (void) +.. function:: void __builtin_mips_set_fcsr (unsigned int value) + + Get and set the contents of the floating-point control and status register + (FPU control register 31). These functions are only available in hard-float + code but can be called in both MIPS16 and non-MIPS16 contexts. + + ``__builtin_mips_set_fcsr`` can be used to change any bit of the + register except the condition codes, which GCC assumes are preserved. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/picochip-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/picochip-built-in-functions.rst new file mode 100644 index 00000000000..03c99412e36 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/picochip-built-in-functions.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _picochip-built-in-functions: + +picoChip Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC provides an interface to selected machine instructions from the +picoChip instruction set. + +.. function:: int __builtin_sbc (int value) + + Sign bit count. Return the number of consecutive bits in :samp:`{value}` + that have the same value as the sign bit. The result is the number of + leading sign bits minus one, giving the number of redundant sign bits in + :samp:`{value}`. + +.. function:: int __builtin_byteswap (int value) + + Byte swap. Return the result of swapping the upper and lower bytes of + :samp:`{value}`. + +.. function:: int __builtin_brev (int value) + + Bit reversal. Return the result of reversing the bits in + :samp:`{value}`. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1, + and so on. + +.. function:: int __builtin_adds (int x, int y) + + Saturating addition. Return the result of adding :samp:`{x}` and :samp:`{y}`, + storing the value 32767 if the result overflows. + +.. function:: int __builtin_subs (int x, int y) + + Saturating subtraction. Return the result of subtracting :samp:`{y}` from + :samp:`{x}`, storing the value -32768 if the result overflows. + +.. function:: void __builtin_halt (void) + + Halt. The processor stops execution. This built-in is useful for + implementing assertions. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-altivec-vsx-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-altivec-vsx-built-in-functions.rst new file mode 100644 index 00000000000..3c08b2ec4ef --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-altivec-vsx-built-in-functions.rst @@ -0,0 +1,2181 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _powerpc-altivec-vsx-built-in-functions: + +PowerPC AltiVec/VSX Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC provides an interface for the PowerPC family of processors to access +the AltiVec operations described in Motorola's AltiVec Programming +Interface Manual. The interface is made available by including +```` and using :option:`-maltivec` and +:option:`-mabi=altivec`. The interface supports the following vector +types. + +.. code-block:: c++ + + vector unsigned char + vector signed char + vector bool char + + vector unsigned short + vector signed short + vector bool short + vector pixel + + vector unsigned int + vector signed int + vector bool int + vector float + +GCC's implementation of the high-level language interface available from +C and C++ code differs from Motorola's documentation in several ways. + +* A vector constant is a list of constant expressions within curly braces. + +* A vector initializer requires no cast if the vector constant is of the + same type as the variable it is initializing. + +* If ``signed`` or ``unsigned`` is omitted, the signedness of the + vector type is the default signedness of the base type. The default + varies depending on the operating system, so a portable program should + always specify the signedness. + +* Compiling with :option:`-maltivec` adds keywords ``__vector``, + ``vector``, ``__pixel``, ``pixel``, ``__bool`` and + ``bool``. When compiling ISO C, the context-sensitive substitution + of the keywords ``vector``, ``pixel`` and ``bool`` is + disabled. To use them, you must include ```` instead. + +* GCC allows using a ``typedef`` name as the type specifier for a + vector type, but only under the following circumstances: + + * When using ``__vector`` instead of ``vector`` ; for example, + + .. code-block:: c++ + + typedef signed short int16; + __vector int16 data; + + * When using ``vector`` in keyword-and-predefine mode; for example, + + .. code-block:: c++ + + typedef signed short int16; + vector int16 data; + + Note that keyword-and-predefine mode is enabled by disabling GNU + extensions (e.g., by using ``-std=c11``) and including + ````. + +* For C, overloaded functions are implemented with macros so the following + does not work: + + .. code-block:: c++ + + vec_add ((vector signed int){1, 2, 3, 4}, foo); + + Since ``vec_add`` is a macro, the vector constant in the example + is treated as four separate arguments. Wrap the entire argument in + parentheses for this to work. + +.. note:: + + Only the ```` interface is supported. + Internally, GCC uses built-in functions to achieve the functionality in + the aforementioned header file, but they are not supported and are + subject to change without notice. + +GCC complies with the Power Vector Intrinsic Programming Reference (PVIPR), +which may be found at +https://openpowerfoundation.org/?resource_lib=power-vector-intrinsic-programming-reference. +Chapter 4 of this document fully documents the vector API interfaces +that must be +provided by compliant compilers. Programmers should preferentially use +the interfaces described therein. However, historically GCC has provided +additional interfaces for access to vector instructions. These are +briefly described below. Where the PVIPR provides a portable interface, +other functions in GCC that provide the same capabilities should be +considered deprecated. + +The PVIPR documents the following overloaded functions: + +.. list-table:: + + * - ``vec_abs`` + - ``vec_absd`` + - ``vec_abss`` + * - ``vec_add`` + - ``vec_addc`` + - ``vec_adde`` + * - ``vec_addec`` + - ``vec_adds`` + - ``vec_all_eq`` + * - ``vec_all_ge`` + - ``vec_all_gt`` + - ``vec_all_in`` + * - ``vec_all_le`` + - ``vec_all_lt`` + - ``vec_all_nan`` + * - ``vec_all_ne`` + - ``vec_all_nge`` + - ``vec_all_ngt`` + * - ``vec_all_nle`` + - ``vec_all_nlt`` + - ``vec_all_numeric`` + * - ``vec_and`` + - ``vec_andc`` + - ``vec_any_eq`` + * - ``vec_any_ge`` + - ``vec_any_gt`` + - ``vec_any_le`` + * - ``vec_any_lt`` + - ``vec_any_nan`` + - ``vec_any_ne`` + * - ``vec_any_nge`` + - ``vec_any_ngt`` + - ``vec_any_nle`` + * - ``vec_any_nlt`` + - ``vec_any_numeric`` + - ``vec_any_out`` + * - ``vec_avg`` + - ``vec_bperm`` + - ``vec_ceil`` + * - ``vec_cipher_be`` + - ``vec_cipherlast_be`` + - ``vec_cmpb`` + * - ``vec_cmpeq`` + - ``vec_cmpge`` + - ``vec_cmpgt`` + * - ``vec_cmple`` + - ``vec_cmplt`` + - ``vec_cmpne`` + * - ``vec_cmpnez`` + - ``vec_cntlz`` + - ``vec_cntlz_lsbb`` + * - ``vec_cnttz`` + - ``vec_cnttz_lsbb`` + - ``vec_cpsgn`` + * - ``vec_ctf`` + - ``vec_cts`` + - ``vec_ctu`` + * - ``vec_div`` + - ``vec_double`` + - ``vec_doublee`` + * - ``vec_doubleh`` + - ``vec_doublel`` + - ``vec_doubleo`` + * - ``vec_eqv`` + - ``vec_expte`` + - ``vec_extract`` + * - ``vec_extract_exp`` + - ``vec_extract_fp32_from_shorth`` + - ``vec_extract_fp32_from_shortl`` + * - ``vec_extract_sig`` + - ``vec_extract_4b`` + - ``vec_first_match_index`` + * - ``vec_first_match_or_eos_index`` + - ``vec_first_mismatch_index`` + - ``vec_first_mismatch_or_eos_index`` + * - ``vec_float`` + - ``vec_float2`` + - ``vec_floate`` + * - ``vec_floato`` + - ``vec_floor`` + - ``vec_gb`` + * - ``vec_insert`` + - ``vec_insert_exp`` + - ``vec_insert4b`` + * - ``vec_ld`` + - ``vec_lde`` + - ``vec_ldl`` + * - ``vec_loge`` + - ``vec_madd`` + - ``vec_madds`` + * - ``vec_max`` + - ``vec_mergee`` + - ``vec_mergeh`` + * - ``vec_mergel`` + - ``vec_mergeo`` + - ``vec_mfvscr`` + * - ``vec_min`` + - ``vec_mradds`` + - ``vec_msub`` + * - ``vec_msum`` + - ``vec_msums`` + - ``vec_mtvscr`` + * - ``vec_mul`` + - ``vec_mule`` + - ``vec_mulo`` + * - ``vec_nabs`` + - ``vec_nand`` + - ``vec_ncipher_be`` + * - ``vec_ncipherlast_be`` + - ``vec_nearbyint`` + - ``vec_neg`` + * - ``vec_nmadd`` + - ``vec_nmsub`` + - ``vec_nor`` + * - ``vec_or`` + - ``vec_orc`` + - ``vec_pack`` + * - ``vec_pack_to_short_fp32`` + - ``vec_packpx`` + - ``vec_packs`` + * - ``vec_packsu`` + - ``vec_parity_lsbb`` + - ``vec_perm`` + * - ``vec_permxor`` + - ``vec_pmsum_be`` + - ``vec_popcnt`` + * - ``vec_re`` + - ``vec_recipdiv`` + - ``vec_revb`` + * - ``vec_reve`` + - ``vec_rint`` + - ``vec_rl`` + * - ``vec_rlmi`` + - ``vec_rlnm`` + - ``vec_round`` + * - ``vec_rsqrt`` + - ``vec_rsqrte`` + - ``vec_sbox_be`` + * - ``vec_sel`` + - ``vec_shasigma_be`` + - ``vec_signed`` + * - ``vec_signed2`` + - ``vec_signede`` + - ``vec_signedo`` + * - ``vec_sl`` + - ``vec_sld`` + - ``vec_sldw`` + * - ``vec_sll`` + - ``vec_slo`` + - ``vec_slv`` + * - ``vec_splat`` + - ``vec_splat_s8`` + - ``vec_splat_s16`` + * - ``vec_splat_s32`` + - ``vec_splat_u8`` + - ``vec_splat_u16`` + * - ``vec_splat_u32`` + - ``vec_splats`` + - ``vec_sqrt`` + * - ``vec_sr`` + - ``vec_sra`` + - ``vec_srl`` + * - ``vec_sro`` + - ``vec_srv`` + - ``vec_st`` + * - ``vec_ste`` + - ``vec_stl`` + - ``vec_sub`` + * - ``vec_subc`` + - ``vec_sube`` + - ``vec_subec`` + * - ``vec_subs`` + - ``vec_sum2s`` + - ``vec_sum4s`` + * - ``vec_sums`` + - ``vec_test_data_class`` + - ``vec_trunc`` + * - ``vec_unpackh`` + - ``vec_unpackl`` + - ``vec_unsigned`` + * - ``vec_unsigned2`` + - ``vec_unsignede`` + - ``vec_unsignedo`` + * - ``vec_xl`` + - ``vec_xl_be`` + - ``vec_xl_len`` + * - ``vec_xl_len_r`` + - ``vec_xor`` + - ``vec_xst`` + * - ``vec_xst_be`` + - ``vec_xst_len`` + - ``vec_xst_len_r`` + +.. toctree:: + :maxdepth: 2 + + +.. _powerpc-altivec-built-in-functions-on-isa-2.05: + +PowerPC AltiVec Built-in Functions on ISA 2.05 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following interfaces are supported for the generic and specific +AltiVec operations and the AltiVec predicates. In cases where there +is a direct mapping between generic and specific operations, only the +generic names are shown here, although the specific operations can also +be used. + +Arguments that are documented as ``const int`` require literal +integral values within the range required for that operation. + +Only functions excluded from the PVIPR are listed here. + +.. code-block:: c++ + + void vec_dss (const int); + + void vec_dssall (void); + + void vec_dst (const vector unsigned char *, int, const int); + void vec_dst (const vector signed char *, int, const int); + void vec_dst (const vector bool char *, int, const int); + void vec_dst (const vector unsigned short *, int, const int); + void vec_dst (const vector signed short *, int, const int); + void vec_dst (const vector bool short *, int, const int); + void vec_dst (const vector pixel *, int, const int); + void vec_dst (const vector unsigned int *, int, const int); + void vec_dst (const vector signed int *, int, const int); + void vec_dst (const vector bool int *, int, const int); + void vec_dst (const vector float *, int, const int); + void vec_dst (const unsigned char *, int, const int); + void vec_dst (const signed char *, int, const int); + void vec_dst (const unsigned short *, int, const int); + void vec_dst (const short *, int, const int); + void vec_dst (const unsigned int *, int, const int); + void vec_dst (const int *, int, const int); + void vec_dst (const float *, int, const int); + + void vec_dstst (const vector unsigned char *, int, const int); + void vec_dstst (const vector signed char *, int, const int); + void vec_dstst (const vector bool char *, int, const int); + void vec_dstst (const vector unsigned short *, int, const int); + void vec_dstst (const vector signed short *, int, const int); + void vec_dstst (const vector bool short *, int, const int); + void vec_dstst (const vector pixel *, int, const int); + void vec_dstst (const vector unsigned int *, int, const int); + void vec_dstst (const vector signed int *, int, const int); + void vec_dstst (const vector bool int *, int, const int); + void vec_dstst (const vector float *, int, const int); + void vec_dstst (const unsigned char *, int, const int); + void vec_dstst (const signed char *, int, const int); + void vec_dstst (const unsigned short *, int, const int); + void vec_dstst (const short *, int, const int); + void vec_dstst (const unsigned int *, int, const int); + void vec_dstst (const int *, int, const int); + void vec_dstst (const unsigned long *, int, const int); + void vec_dstst (const long *, int, const int); + void vec_dstst (const float *, int, const int); + + void vec_dststt (const vector unsigned char *, int, const int); + void vec_dststt (const vector signed char *, int, const int); + void vec_dststt (const vector bool char *, int, const int); + void vec_dststt (const vector unsigned short *, int, const int); + void vec_dststt (const vector signed short *, int, const int); + void vec_dststt (const vector bool short *, int, const int); + void vec_dststt (const vector pixel *, int, const int); + void vec_dststt (const vector unsigned int *, int, const int); + void vec_dststt (const vector signed int *, int, const int); + void vec_dststt (const vector bool int *, int, const int); + void vec_dststt (const vector float *, int, const int); + void vec_dststt (const unsigned char *, int, const int); + void vec_dststt (const signed char *, int, const int); + void vec_dststt (const unsigned short *, int, const int); + void vec_dststt (const short *, int, const int); + void vec_dststt (const unsigned int *, int, const int); + void vec_dststt (const int *, int, const int); + void vec_dststt (const float *, int, const int); + + void vec_dstt (const vector unsigned char *, int, const int); + void vec_dstt (const vector signed char *, int, const int); + void vec_dstt (const vector bool char *, int, const int); + void vec_dstt (const vector unsigned short *, int, const int); + void vec_dstt (const vector signed short *, int, const int); + void vec_dstt (const vector bool short *, int, const int); + void vec_dstt (const vector pixel *, int, const int); + void vec_dstt (const vector unsigned int *, int, const int); + void vec_dstt (const vector signed int *, int, const int); + void vec_dstt (const vector bool int *, int, const int); + void vec_dstt (const vector float *, int, const int); + void vec_dstt (const unsigned char *, int, const int); + void vec_dstt (const signed char *, int, const int); + void vec_dstt (const unsigned short *, int, const int); + void vec_dstt (const short *, int, const int); + void vec_dstt (const unsigned int *, int, const int); + void vec_dstt (const int *, int, const int); + void vec_dstt (const float *, int, const int); + + vector signed char vec_lvebx (int, char *); + vector unsigned char vec_lvebx (int, unsigned char *); + + vector signed short vec_lvehx (int, short *); + vector unsigned short vec_lvehx (int, unsigned short *); + + vector float vec_lvewx (int, float *); + vector signed int vec_lvewx (int, int *); + vector unsigned int vec_lvewx (int, unsigned int *); + + vector unsigned char vec_lvsl (int, const unsigned char *); + vector unsigned char vec_lvsl (int, const signed char *); + vector unsigned char vec_lvsl (int, const unsigned short *); + vector unsigned char vec_lvsl (int, const short *); + vector unsigned char vec_lvsl (int, const unsigned int *); + vector unsigned char vec_lvsl (int, const int *); + vector unsigned char vec_lvsl (int, const float *); + + vector unsigned char vec_lvsr (int, const unsigned char *); + vector unsigned char vec_lvsr (int, const signed char *); + vector unsigned char vec_lvsr (int, const unsigned short *); + vector unsigned char vec_lvsr (int, const short *); + vector unsigned char vec_lvsr (int, const unsigned int *); + vector unsigned char vec_lvsr (int, const int *); + vector unsigned char vec_lvsr (int, const float *); + + void vec_stvebx (vector signed char, int, signed char *); + void vec_stvebx (vector unsigned char, int, unsigned char *); + void vec_stvebx (vector bool char, int, signed char *); + void vec_stvebx (vector bool char, int, unsigned char *); + + void vec_stvehx (vector signed short, int, short *); + void vec_stvehx (vector unsigned short, int, unsigned short *); + void vec_stvehx (vector bool short, int, short *); + void vec_stvehx (vector bool short, int, unsigned short *); + + void vec_stvewx (vector float, int, float *); + void vec_stvewx (vector signed int, int, int *); + void vec_stvewx (vector unsigned int, int, unsigned int *); + void vec_stvewx (vector bool int, int, int *); + void vec_stvewx (vector bool int, int, unsigned int *); + + vector float vec_vaddfp (vector float, vector float); + + vector signed char vec_vaddsbs (vector bool char, vector signed char); + vector signed char vec_vaddsbs (vector signed char, vector bool char); + vector signed char vec_vaddsbs (vector signed char, vector signed char); + + vector signed short vec_vaddshs (vector bool short, vector signed short); + vector signed short vec_vaddshs (vector signed short, vector bool short); + vector signed short vec_vaddshs (vector signed short, vector signed short); + + vector signed int vec_vaddsws (vector bool int, vector signed int); + vector signed int vec_vaddsws (vector signed int, vector bool int); + vector signed int vec_vaddsws (vector signed int, vector signed int); + + vector signed char vec_vaddubm (vector bool char, vector signed char); + vector signed char vec_vaddubm (vector signed char, vector bool char); + vector signed char vec_vaddubm (vector signed char, vector signed char); + vector unsigned char vec_vaddubm (vector bool char, vector unsigned char); + vector unsigned char vec_vaddubm (vector unsigned char, vector bool char); + vector unsigned char vec_vaddubm (vector unsigned char, vector unsigned char); + + vector unsigned char vec_vaddubs (vector bool char, vector unsigned char); + vector unsigned char vec_vaddubs (vector unsigned char, vector bool char); + vector unsigned char vec_vaddubs (vector unsigned char, vector unsigned char); + + vector signed short vec_vadduhm (vector bool short, vector signed short); + vector signed short vec_vadduhm (vector signed short, vector bool short); + vector signed short vec_vadduhm (vector signed short, vector signed short); + vector unsigned short vec_vadduhm (vector bool short, vector unsigned short); + vector unsigned short vec_vadduhm (vector unsigned short, vector bool short); + vector unsigned short vec_vadduhm (vector unsigned short, vector unsigned short); + + vector unsigned short vec_vadduhs (vector bool short, vector unsigned short); + vector unsigned short vec_vadduhs (vector unsigned short, vector bool short); + vector unsigned short vec_vadduhs (vector unsigned short, vector unsigned short); + + vector signed int vec_vadduwm (vector bool int, vector signed int); + vector signed int vec_vadduwm (vector signed int, vector bool int); + vector signed int vec_vadduwm (vector signed int, vector signed int); + vector unsigned int vec_vadduwm (vector bool int, vector unsigned int); + vector unsigned int vec_vadduwm (vector unsigned int, vector bool int); + vector unsigned int vec_vadduwm (vector unsigned int, vector unsigned int); + + vector unsigned int vec_vadduws (vector bool int, vector unsigned int); + vector unsigned int vec_vadduws (vector unsigned int, vector bool int); + vector unsigned int vec_vadduws (vector unsigned int, vector unsigned int); + + vector signed char vec_vavgsb (vector signed char, vector signed char); + + vector signed short vec_vavgsh (vector signed short, vector signed short); + + vector signed int vec_vavgsw (vector signed int, vector signed int); + + vector unsigned char vec_vavgub (vector unsigned char, vector unsigned char); + + vector unsigned short vec_vavguh (vector unsigned short, vector unsigned short); + + vector unsigned int vec_vavguw (vector unsigned int, vector unsigned int); + + vector float vec_vcfsx (vector signed int, const int); + + vector float vec_vcfux (vector unsigned int, const int); + + vector bool int vec_vcmpeqfp (vector float, vector float); + + vector bool char vec_vcmpequb (vector signed char, vector signed char); + vector bool char vec_vcmpequb (vector unsigned char, vector unsigned char); + + vector bool short vec_vcmpequh (vector signed short, vector signed short); + vector bool short vec_vcmpequh (vector unsigned short, vector unsigned short); + + vector bool int vec_vcmpequw (vector signed int, vector signed int); + vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int); + + vector bool int vec_vcmpgtfp (vector float, vector float); + + vector bool char vec_vcmpgtsb (vector signed char, vector signed char); + + vector bool short vec_vcmpgtsh (vector signed short, vector signed short); + + vector bool int vec_vcmpgtsw (vector signed int, vector signed int); + + vector bool char vec_vcmpgtub (vector unsigned char, vector unsigned char); + + vector bool short vec_vcmpgtuh (vector unsigned short, vector unsigned short); + + vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int); + + vector float vec_vmaxfp (vector float, vector float); + + vector signed char vec_vmaxsb (vector bool char, vector signed char); + vector signed char vec_vmaxsb (vector signed char, vector bool char); + vector signed char vec_vmaxsb (vector signed char, vector signed char); + + vector signed short vec_vmaxsh (vector bool short, vector signed short); + vector signed short vec_vmaxsh (vector signed short, vector bool short); + vector signed short vec_vmaxsh (vector signed short, vector signed short); + + vector signed int vec_vmaxsw (vector bool int, vector signed int); + vector signed int vec_vmaxsw (vector signed int, vector bool int); + vector signed int vec_vmaxsw (vector signed int, vector signed int); + + vector unsigned char vec_vmaxub (vector bool char, vector unsigned char); + vector unsigned char vec_vmaxub (vector unsigned char, vector bool char); + vector unsigned char vec_vmaxub (vector unsigned char, vector unsigned char); + + vector unsigned short vec_vmaxuh (vector bool short, vector unsigned short); + vector unsigned short vec_vmaxuh (vector unsigned short, vector bool short); + vector unsigned short vec_vmaxuh (vector unsigned short, vector unsigned short); + + vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int); + vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int); + vector unsigned int vec_vmaxuw (vector unsigned int, vector unsigned int); + + vector float vec_vminfp (vector float, vector float); + + vector signed char vec_vminsb (vector bool char, vector signed char); + vector signed char vec_vminsb (vector signed char, vector bool char); + vector signed char vec_vminsb (vector signed char, vector signed char); + + vector signed short vec_vminsh (vector bool short, vector signed short); + vector signed short vec_vminsh (vector signed short, vector bool short); + vector signed short vec_vminsh (vector signed short, vector signed short); + + vector signed int vec_vminsw (vector bool int, vector signed int); + vector signed int vec_vminsw (vector signed int, vector bool int); + vector signed int vec_vminsw (vector signed int, vector signed int); + + vector unsigned char vec_vminub (vector bool char, vector unsigned char); + vector unsigned char vec_vminub (vector unsigned char, vector bool char); + vector unsigned char vec_vminub (vector unsigned char, vector unsigned char); + + vector unsigned short vec_vminuh (vector bool short, vector unsigned short); + vector unsigned short vec_vminuh (vector unsigned short, vector bool short); + vector unsigned short vec_vminuh (vector unsigned short, vector unsigned short); + + vector unsigned int vec_vminuw (vector bool int, vector unsigned int); + vector unsigned int vec_vminuw (vector unsigned int, vector bool int); + vector unsigned int vec_vminuw (vector unsigned int, vector unsigned int); + + vector bool char vec_vmrghb (vector bool char, vector bool char); + vector signed char vec_vmrghb (vector signed char, vector signed char); + vector unsigned char vec_vmrghb (vector unsigned char, vector unsigned char); + + vector bool short vec_vmrghh (vector bool short, vector bool short); + vector signed short vec_vmrghh (vector signed short, vector signed short); + vector unsigned short vec_vmrghh (vector unsigned short, vector unsigned short); + vector pixel vec_vmrghh (vector pixel, vector pixel); + + vector float vec_vmrghw (vector float, vector float); + vector bool int vec_vmrghw (vector bool int, vector bool int); + vector signed int vec_vmrghw (vector signed int, vector signed int); + vector unsigned int vec_vmrghw (vector unsigned int, vector unsigned int); + + vector bool char vec_vmrglb (vector bool char, vector bool char); + vector signed char vec_vmrglb (vector signed char, vector signed char); + vector unsigned char vec_vmrglb (vector unsigned char, vector unsigned char); + + vector bool short vec_vmrglh (vector bool short, vector bool short); + vector signed short vec_vmrglh (vector signed short, vector signed short); + vector unsigned short vec_vmrglh (vector unsigned short, vector unsigned short); + vector pixel vec_vmrglh (vector pixel, vector pixel); + + vector float vec_vmrglw (vector float, vector float); + vector signed int vec_vmrglw (vector signed int, vector signed int); + vector unsigned int vec_vmrglw (vector unsigned int, vector unsigned int); + vector bool int vec_vmrglw (vector bool int, vector bool int); + + vector signed int vec_vmsummbm (vector signed char, vector unsigned char, + vector signed int); + + vector signed int vec_vmsumshm (vector signed short, vector signed short, + vector signed int); + + vector signed int vec_vmsumshs (vector signed short, vector signed short, + vector signed int); + + vector unsigned int vec_vmsumubm (vector unsigned char, vector unsigned char, + vector unsigned int); + + vector unsigned int vec_vmsumuhm (vector unsigned short, vector unsigned short, + vector unsigned int); + + vector unsigned int vec_vmsumuhs (vector unsigned short, vector unsigned short, + vector unsigned int); + + vector signed short vec_vmulesb (vector signed char, vector signed char); + + vector signed int vec_vmulesh (vector signed short, vector signed short); + + vector unsigned short vec_vmuleub (vector unsigned char, vector unsigned char); + + vector unsigned int vec_vmuleuh (vector unsigned short, vector unsigned short); + + vector signed short vec_vmulosb (vector signed char, vector signed char); + + vector signed int vec_vmulosh (vector signed short, vector signed short); + + vector unsigned short vec_vmuloub (vector unsigned char, vector unsigned char); + + vector unsigned int vec_vmulouh (vector unsigned short, vector unsigned short); + + vector signed char vec_vpkshss (vector signed short, vector signed short); + + vector unsigned char vec_vpkshus (vector signed short, vector signed short); + + vector signed short vec_vpkswss (vector signed int, vector signed int); + + vector unsigned short vec_vpkswus (vector signed int, vector signed int); + + vector bool char vec_vpkuhum (vector bool short, vector bool short); + vector signed char vec_vpkuhum (vector signed short, vector signed short); + vector unsigned char vec_vpkuhum (vector unsigned short, vector unsigned short); + + vector unsigned char vec_vpkuhus (vector unsigned short, vector unsigned short); + + vector bool short vec_vpkuwum (vector bool int, vector bool int); + vector signed short vec_vpkuwum (vector signed int, vector signed int); + vector unsigned short vec_vpkuwum (vector unsigned int, vector unsigned int); + + vector unsigned short vec_vpkuwus (vector unsigned int, vector unsigned int); + + vector signed char vec_vrlb (vector signed char, vector unsigned char); + vector unsigned char vec_vrlb (vector unsigned char, vector unsigned char); + + vector signed short vec_vrlh (vector signed short, vector unsigned short); + vector unsigned short vec_vrlh (vector unsigned short, vector unsigned short); + + vector signed int vec_vrlw (vector signed int, vector unsigned int); + vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int); + + vector signed char vec_vslb (vector signed char, vector unsigned char); + vector unsigned char vec_vslb (vector unsigned char, vector unsigned char); + + vector signed short vec_vslh (vector signed short, vector unsigned short); + vector unsigned short vec_vslh (vector unsigned short, vector unsigned short); + + vector signed int vec_vslw (vector signed int, vector unsigned int); + vector unsigned int vec_vslw (vector unsigned int, vector unsigned int); + + vector signed char vec_vspltb (vector signed char, const int); + vector unsigned char vec_vspltb (vector unsigned char, const int); + vector bool char vec_vspltb (vector bool char, const int); + + vector bool short vec_vsplth (vector bool short, const int); + vector signed short vec_vsplth (vector signed short, const int); + vector unsigned short vec_vsplth (vector unsigned short, const int); + vector pixel vec_vsplth (vector pixel, const int); + + vector float vec_vspltw (vector float, const int); + vector signed int vec_vspltw (vector signed int, const int); + vector unsigned int vec_vspltw (vector unsigned int, const int); + vector bool int vec_vspltw (vector bool int, const int); + + vector signed char vec_vsrab (vector signed char, vector unsigned char); + vector unsigned char vec_vsrab (vector unsigned char, vector unsigned char); + + vector signed short vec_vsrah (vector signed short, vector unsigned short); + vector unsigned short vec_vsrah (vector unsigned short, vector unsigned short); + + vector signed int vec_vsraw (vector signed int, vector unsigned int); + vector unsigned int vec_vsraw (vector unsigned int, vector unsigned int); + + vector signed char vec_vsrb (vector signed char, vector unsigned char); + vector unsigned char vec_vsrb (vector unsigned char, vector unsigned char); + + vector signed short vec_vsrh (vector signed short, vector unsigned short); + vector unsigned short vec_vsrh (vector unsigned short, vector unsigned short); + + vector signed int vec_vsrw (vector signed int, vector unsigned int); + vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int); + + vector float vec_vsubfp (vector float, vector float); + + vector signed char vec_vsubsbs (vector bool char, vector signed char); + vector signed char vec_vsubsbs (vector signed char, vector bool char); + vector signed char vec_vsubsbs (vector signed char, vector signed char); + + vector signed short vec_vsubshs (vector bool short, vector signed short); + vector signed short vec_vsubshs (vector signed short, vector bool short); + vector signed short vec_vsubshs (vector signed short, vector signed short); + + vector signed int vec_vsubsws (vector bool int, vector signed int); + vector signed int vec_vsubsws (vector signed int, vector bool int); + vector signed int vec_vsubsws (vector signed int, vector signed int); + + vector signed char vec_vsububm (vector bool char, vector signed char); + vector signed char vec_vsububm (vector signed char, vector bool char); + vector signed char vec_vsububm (vector signed char, vector signed char); + vector unsigned char vec_vsububm (vector bool char, vector unsigned char); + vector unsigned char vec_vsububm (vector unsigned char, vector bool char); + vector unsigned char vec_vsububm (vector unsigned char, vector unsigned char); + + vector unsigned char vec_vsububs (vector bool char, vector unsigned char); + vector unsigned char vec_vsububs (vector unsigned char, vector bool char); + vector unsigned char vec_vsububs (vector unsigned char, vector unsigned char); + + vector signed short vec_vsubuhm (vector bool short, vector signed short); + vector signed short vec_vsubuhm (vector signed short, vector bool short); + vector signed short vec_vsubuhm (vector signed short, vector signed short); + vector unsigned short vec_vsubuhm (vector bool short, vector unsigned short); + vector unsigned short vec_vsubuhm (vector unsigned short, vector bool short); + vector unsigned short vec_vsubuhm (vector unsigned short, vector unsigned short); + + vector unsigned short vec_vsubuhs (vector bool short, vector unsigned short); + vector unsigned short vec_vsubuhs (vector unsigned short, vector bool short); + vector unsigned short vec_vsubuhs (vector unsigned short, vector unsigned short); + + vector signed int vec_vsubuwm (vector bool int, vector signed int); + vector signed int vec_vsubuwm (vector signed int, vector bool int); + vector signed int vec_vsubuwm (vector signed int, vector signed int); + vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int); + vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int); + vector unsigned int vec_vsubuwm (vector unsigned int, vector unsigned int); + + vector unsigned int vec_vsubuws (vector bool int, vector unsigned int); + vector unsigned int vec_vsubuws (vector unsigned int, vector bool int); + vector unsigned int vec_vsubuws (vector unsigned int, vector unsigned int); + + vector signed int vec_vsum4sbs (vector signed char, vector signed int); + + vector signed int vec_vsum4shs (vector signed short, vector signed int); + + vector unsigned int vec_vsum4ubs (vector unsigned char, vector unsigned int); + + vector unsigned int vec_vupkhpx (vector pixel); + + vector bool short vec_vupkhsb (vector bool char); + vector signed short vec_vupkhsb (vector signed char); + + vector bool int vec_vupkhsh (vector bool short); + vector signed int vec_vupkhsh (vector signed short); + + vector unsigned int vec_vupklpx (vector pixel); + + vector bool short vec_vupklsb (vector bool char); + vector signed short vec_vupklsb (vector signed char); + + vector bool int vec_vupklsh (vector bool short); + vector signed int vec_vupklsh (vector signed short); + +.. _powerpc-altivec-built-in-functions-available-on-isa-2.06: + +PowerPC AltiVec Built-in Functions Available on ISA 2.06 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The AltiVec built-in functions described in this section are +available on the PowerPC family of processors starting with ISA 2.06 +or later. These are normally enabled by adding :option:`-mvsx` to the +command line. + +When :option:`-mvsx` is used, the following additional vector types are +implemented. + +.. code-block:: c++ + + vector unsigned __int128 + vector signed __int128 + vector unsigned long long int + vector signed long long int + vector double + +The long long types are only implemented for 64-bit code generation. + +Only functions excluded from the PVIPR are listed here. + +.. code-block:: c++ + + void vec_dst (const unsigned long *, int, const int); + void vec_dst (const long *, int, const int); + + void vec_dststt (const unsigned long *, int, const int); + void vec_dststt (const long *, int, const int); + + void vec_dstt (const unsigned long *, int, const int); + void vec_dstt (const long *, int, const int); + + vector unsigned char vec_lvsl (int, const unsigned long *); + vector unsigned char vec_lvsl (int, const long *); + + vector unsigned char vec_lvsr (int, const unsigned long *); + vector unsigned char vec_lvsr (int, const long *); + + vector unsigned char vec_lvsl (int, const double *); + vector unsigned char vec_lvsr (int, const double *); + + vector double vec_vsx_ld (int, const vector double *); + vector double vec_vsx_ld (int, const double *); + vector float vec_vsx_ld (int, const vector float *); + vector float vec_vsx_ld (int, const float *); + vector bool int vec_vsx_ld (int, const vector bool int *); + vector signed int vec_vsx_ld (int, const vector signed int *); + vector signed int vec_vsx_ld (int, const int *); + vector signed int vec_vsx_ld (int, const long *); + vector unsigned int vec_vsx_ld (int, const vector unsigned int *); + vector unsigned int vec_vsx_ld (int, const unsigned int *); + vector unsigned int vec_vsx_ld (int, const unsigned long *); + vector bool short vec_vsx_ld (int, const vector bool short *); + vector pixel vec_vsx_ld (int, const vector pixel *); + vector signed short vec_vsx_ld (int, const vector signed short *); + vector signed short vec_vsx_ld (int, const short *); + vector unsigned short vec_vsx_ld (int, const vector unsigned short *); + vector unsigned short vec_vsx_ld (int, const unsigned short *); + vector bool char vec_vsx_ld (int, const vector bool char *); + vector signed char vec_vsx_ld (int, const vector signed char *); + vector signed char vec_vsx_ld (int, const signed char *); + vector unsigned char vec_vsx_ld (int, const vector unsigned char *); + vector unsigned char vec_vsx_ld (int, const unsigned char *); + + void vec_vsx_st (vector double, int, vector double *); + void vec_vsx_st (vector double, int, double *); + void vec_vsx_st (vector float, int, vector float *); + void vec_vsx_st (vector float, int, float *); + void vec_vsx_st (vector signed int, int, vector signed int *); + void vec_vsx_st (vector signed int, int, int *); + void vec_vsx_st (vector unsigned int, int, vector unsigned int *); + void vec_vsx_st (vector unsigned int, int, unsigned int *); + void vec_vsx_st (vector bool int, int, vector bool int *); + void vec_vsx_st (vector bool int, int, unsigned int *); + void vec_vsx_st (vector bool int, int, int *); + void vec_vsx_st (vector signed short, int, vector signed short *); + void vec_vsx_st (vector signed short, int, short *); + void vec_vsx_st (vector unsigned short, int, vector unsigned short *); + void vec_vsx_st (vector unsigned short, int, unsigned short *); + void vec_vsx_st (vector bool short, int, vector bool short *); + void vec_vsx_st (vector bool short, int, unsigned short *); + void vec_vsx_st (vector pixel, int, vector pixel *); + void vec_vsx_st (vector pixel, int, unsigned short *); + void vec_vsx_st (vector pixel, int, short *); + void vec_vsx_st (vector bool short, int, short *); + void vec_vsx_st (vector signed char, int, vector signed char *); + void vec_vsx_st (vector signed char, int, signed char *); + void vec_vsx_st (vector unsigned char, int, vector unsigned char *); + void vec_vsx_st (vector unsigned char, int, unsigned char *); + void vec_vsx_st (vector bool char, int, vector bool char *); + void vec_vsx_st (vector bool char, int, unsigned char *); + void vec_vsx_st (vector bool char, int, signed char *); + + vector double vec_xxpermdi (vector double, vector double, const int); + vector float vec_xxpermdi (vector float, vector float, const int); + vector long long vec_xxpermdi (vector long long, vector long long, const int); + vector unsigned long long vec_xxpermdi (vector unsigned long long, + vector unsigned long long, const int); + vector int vec_xxpermdi (vector int, vector int, const int); + vector unsigned int vec_xxpermdi (vector unsigned int, + vector unsigned int, const int); + vector short vec_xxpermdi (vector short, vector short, const int); + vector unsigned short vec_xxpermdi (vector unsigned short, + vector unsigned short, const int); + vector signed char vec_xxpermdi (vector signed char, vector signed char, + const int); + vector unsigned char vec_xxpermdi (vector unsigned char, + vector unsigned char, const int); + + vector double vec_xxsldi (vector double, vector double, int); + vector float vec_xxsldi (vector float, vector float, int); + vector long long vec_xxsldi (vector long long, vector long long, int); + vector unsigned long long vec_xxsldi (vector unsigned long long, + vector unsigned long long, int); + vector int vec_xxsldi (vector int, vector int, int); + vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int); + vector short vec_xxsldi (vector short, vector short, int); + vector unsigned short vec_xxsldi (vector unsigned short, + vector unsigned short, int); + vector signed char vec_xxsldi (vector signed char, vector signed char, int); + vector unsigned char vec_xxsldi (vector unsigned char, + vector unsigned char, int); + +Note that the :samp:`vec_ld` and :samp:`vec_st` built-in functions always +generate the AltiVec :samp:`LVX` and :samp:`STVX` instructions even +if the VSX instruction set is available. The :samp:`vec_vsx_ld` and +:samp:`vec_vsx_st` built-in functions always generate the VSX :samp:`LXVD2X`, +:samp:`LXVW4X`, :samp:`STXVD2X`, and :samp:`STXVW4X` instructions. + +.. _powerpc-altivec-built-in-functions-available-on-isa-2.07: + +PowerPC AltiVec Built-in Functions Available on ISA 2.07 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If the ISA 2.07 additions to the vector/scalar (power8-vector) +instruction set are available, the following additional functions are +available for both 32-bit and 64-bit targets. For 64-bit targets, you +can use :samp:`{vector long}` instead of :samp:`{vector long long}`, +:samp:`{vector bool long}` instead of :samp:`{vector bool long long}`, and +:samp:`{vector unsigned long}` instead of :samp:`{vector unsigned long long}`. + +Only functions excluded from the PVIPR are listed here. + +.. code-block:: c++ + + vector long long vec_vaddudm (vector long long, vector long long); + vector long long vec_vaddudm (vector bool long long, vector long long); + vector long long vec_vaddudm (vector long long, vector bool long long); + vector unsigned long long vec_vaddudm (vector unsigned long long, + vector unsigned long long); + vector unsigned long long vec_vaddudm (vector bool unsigned long long, + vector unsigned long long); + vector unsigned long long vec_vaddudm (vector unsigned long long, + vector bool unsigned long long); + + vector long long vec_vclz (vector long long); + vector unsigned long long vec_vclz (vector unsigned long long); + vector int vec_vclz (vector int); + vector unsigned int vec_vclz (vector int); + vector short vec_vclz (vector short); + vector unsigned short vec_vclz (vector unsigned short); + vector signed char vec_vclz (vector signed char); + vector unsigned char vec_vclz (vector unsigned char); + + vector signed char vec_vclzb (vector signed char); + vector unsigned char vec_vclzb (vector unsigned char); + + vector long long vec_vclzd (vector long long); + vector unsigned long long vec_vclzd (vector unsigned long long); + + vector short vec_vclzh (vector short); + vector unsigned short vec_vclzh (vector unsigned short); + + vector int vec_vclzw (vector int); + vector unsigned int vec_vclzw (vector int); + + vector signed char vec_vgbbd (vector signed char); + vector unsigned char vec_vgbbd (vector unsigned char); + + vector long long vec_vmaxsd (vector long long, vector long long); + + vector unsigned long long vec_vmaxud (vector unsigned long long, + unsigned vector long long); + + vector long long vec_vminsd (vector long long, vector long long); + + vector unsigned long long vec_vminud (vector long long, vector long long); + + vector int vec_vpksdss (vector long long, vector long long); + vector unsigned int vec_vpksdss (vector long long, vector long long); + + vector unsigned int vec_vpkudus (vector unsigned long long, + vector unsigned long long); + + vector int vec_vpkudum (vector long long, vector long long); + vector unsigned int vec_vpkudum (vector unsigned long long, + vector unsigned long long); + vector bool int vec_vpkudum (vector bool long long, vector bool long long); + + vector long long vec_vpopcnt (vector long long); + vector unsigned long long vec_vpopcnt (vector unsigned long long); + vector int vec_vpopcnt (vector int); + vector unsigned int vec_vpopcnt (vector int); + vector short vec_vpopcnt (vector short); + vector unsigned short vec_vpopcnt (vector unsigned short); + vector signed char vec_vpopcnt (vector signed char); + vector unsigned char vec_vpopcnt (vector unsigned char); + + vector signed char vec_vpopcntb (vector signed char); + vector unsigned char vec_vpopcntb (vector unsigned char); + + vector long long vec_vpopcntd (vector long long); + vector unsigned long long vec_vpopcntd (vector unsigned long long); + + vector short vec_vpopcnth (vector short); + vector unsigned short vec_vpopcnth (vector unsigned short); + + vector int vec_vpopcntw (vector int); + vector unsigned int vec_vpopcntw (vector int); + + vector long long vec_vrld (vector long long, vector unsigned long long); + vector unsigned long long vec_vrld (vector unsigned long long, + vector unsigned long long); + + vector long long vec_vsld (vector long long, vector unsigned long long); + vector long long vec_vsld (vector unsigned long long, + vector unsigned long long); + + vector long long vec_vsrad (vector long long, vector unsigned long long); + vector unsigned long long vec_vsrad (vector unsigned long long, + vector unsigned long long); + + vector long long vec_vsrd (vector long long, vector unsigned long long); + vector unsigned long long char vec_vsrd (vector unsigned long long, + vector unsigned long long); + + vector long long vec_vsubudm (vector long long, vector long long); + vector long long vec_vsubudm (vector bool long long, vector long long); + vector long long vec_vsubudm (vector long long, vector bool long long); + vector unsigned long long vec_vsubudm (vector unsigned long long, + vector unsigned long long); + vector unsigned long long vec_vsubudm (vector bool long long, + vector unsigned long long); + vector unsigned long long vec_vsubudm (vector unsigned long long, + vector bool long long); + + vector long long vec_vupkhsw (vector int); + vector unsigned long long vec_vupkhsw (vector unsigned int); + + vector long long vec_vupklsw (vector int); + vector unsigned long long vec_vupklsw (vector int); + +If the ISA 2.07 additions to the vector/scalar (power8-vector) +instruction set are available, the following additional functions are +available for 64-bit targets. New vector types +(:samp:`{vector __int128}` and :samp:`{vector __uint128}`) are available +to hold the :samp:`{__int128}` and :samp:`{__uint128}` types to use these +builtins. + +The normal vector extract, and set operations work on +:samp:`{vector __int128}` and :samp:`{vector __uint128}` types, +but the index value must be 0. + +Only functions excluded from the PVIPR are listed here. + +.. code-block:: c++ + + vector __int128 vec_vaddcuq (vector __int128, vector __int128); + vector __uint128 vec_vaddcuq (vector __uint128, vector __uint128); + + vector __int128 vec_vadduqm (vector __int128, vector __int128); + vector __uint128 vec_vadduqm (vector __uint128, vector __uint128); + + vector __int128 vec_vaddecuq (vector __int128, vector __int128, + vector __int128); + vector __uint128 vec_vaddecuq (vector __uint128, vector __uint128, + vector __uint128); + + vector __int128 vec_vaddeuqm (vector __int128, vector __int128, + vector __int128); + vector __uint128 vec_vaddeuqm (vector __uint128, vector __uint128, + vector __uint128); + + vector __int128 vec_vsubecuq (vector __int128, vector __int128, + vector __int128); + vector __uint128 vec_vsubecuq (vector __uint128, vector __uint128, + vector __uint128); + + vector __int128 vec_vsubeuqm (vector __int128, vector __int128, + vector __int128); + vector __uint128 vec_vsubeuqm (vector __uint128, vector __uint128, + vector __uint128); + + vector __int128 vec_vsubcuq (vector __int128, vector __int128); + vector __uint128 vec_vsubcuq (vector __uint128, vector __uint128); + + __int128 vec_vsubuqm (__int128, __int128); + __uint128 vec_vsubuqm (__uint128, __uint128); + + vector __int128 __builtin_bcdadd (vector __int128, vector __int128, const int); + vector unsigned char __builtin_bcdadd (vector unsigned char, vector unsigned char, + const int); + int __builtin_bcdadd_lt (vector __int128, vector __int128, const int); + int __builtin_bcdadd_lt (vector unsigned char, vector unsigned char, const int); + int __builtin_bcdadd_eq (vector __int128, vector __int128, const int); + int __builtin_bcdadd_eq (vector unsigned char, vector unsigned char, const int); + int __builtin_bcdadd_gt (vector __int128, vector __int128, const int); + int __builtin_bcdadd_gt (vector unsigned char, vector unsigned char, const int); + int __builtin_bcdadd_ov (vector __int128, vector __int128, const int); + int __builtin_bcdadd_ov (vector unsigned char, vector unsigned char, const int); + + vector __int128 __builtin_bcdsub (vector __int128, vector __int128, const int); + vector unsigned char __builtin_bcdsub (vector unsigned char, vector unsigned char, + const int); + int __builtin_bcdsub_lt (vector __int128, vector __int128, const int); + int __builtin_bcdsub_lt (vector unsigned char, vector unsigned char, const int); + int __builtin_bcdsub_eq (vector __int128, vector __int128, const int); + int __builtin_bcdsub_eq (vector unsigned char, vector unsigned char, const int); + int __builtin_bcdsub_gt (vector __int128, vector __int128, const int); + int __builtin_bcdsub_gt (vector unsigned char, vector unsigned char, const int); + int __builtin_bcdsub_ov (vector __int128, vector __int128, const int); + int __builtin_bcdsub_ov (vector unsigned char, vector unsigned char, const int); + +.. _powerpc-altivec-built-in-functions-available-on-isa-3.0: + +PowerPC AltiVec Built-in Functions Available on ISA 3.0 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following additional built-in functions are also available for the +PowerPC family of processors, starting with ISA 3.0 +(:option:`-mcpu=power9`) or later. + +Only instructions excluded from the PVIPR are listed here. + +.. code-block:: c++ + + unsigned int scalar_extract_exp (double source); + unsigned long long int scalar_extract_exp (__ieee128 source); + + unsigned long long int scalar_extract_sig (double source); + unsigned __int128 scalar_extract_sig (__ieee128 source); + + double scalar_insert_exp (unsigned long long int significand, + unsigned long long int exponent); + double scalar_insert_exp (double significand, unsigned long long int exponent); + + ieee_128 scalar_insert_exp (unsigned __int128 significand, + unsigned long long int exponent); + ieee_128 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent); + + int scalar_cmp_exp_gt (double arg1, double arg2); + int scalar_cmp_exp_lt (double arg1, double arg2); + int scalar_cmp_exp_eq (double arg1, double arg2); + int scalar_cmp_exp_unordered (double arg1, double arg2); + + bool scalar_test_data_class (float source, const int condition); + bool scalar_test_data_class (double source, const int condition); + bool scalar_test_data_class (__ieee128 source, const int condition); + + bool scalar_test_neg (float source); + bool scalar_test_neg (double source); + bool scalar_test_neg (__ieee128 source); + +The ``scalar_extract_exp`` and ``scalar_extract_sig`` +functions require a 64-bit environment supporting ISA 3.0 or later. +The ``scalar_extract_exp`` and ``scalar_extract_sig`` built-in +functions return the significand and the biased exponent value +respectively of their ``source`` arguments. +When supplied with a 64-bit ``source`` argument, the +result returned by ``scalar_extract_sig`` has +the ``0x0010000000000000`` bit set if the +function's ``source`` argument is in normalized form. +Otherwise, this bit is set to 0. +When supplied with a 128-bit ``source`` argument, the +``0x00010000000000000000000000000000`` bit of the result is +treated similarly. +Note that the sign of the significand is not represented in the result +returned from the ``scalar_extract_sig`` function. Use the +``scalar_test_neg`` function to test the sign of its ``double`` +argument. + +The ``scalar_insert_exp`` +functions require a 64-bit environment supporting ISA 3.0 or later. +When supplied with a 64-bit first argument, the +``scalar_insert_exp`` built-in function returns a double-precision +floating point value that is constructed by assembling the values of its +``significand`` and ``exponent`` arguments. The sign of the +result is copied from the most significant bit of the +``significand`` argument. The significand and exponent components +of the result are composed of the least significant 11 bits of the +``exponent`` argument and the least significant 52 bits of the +``significand`` argument respectively. + +When supplied with a 128-bit first argument, the +``scalar_insert_exp`` built-in function returns a quad-precision +ieee floating point value. The sign bit of the result is copied from +the most significant bit of the ``significand`` argument. +The significand and exponent components of the result are composed of +the least significant 15 bits of the ``exponent`` argument and the +least significant 112 bits of the ``significand`` argument respectively. + +The ``scalar_cmp_exp_gt``, ``scalar_cmp_exp_lt``, +``scalar_cmp_exp_eq``, and ``scalar_cmp_exp_unordered`` built-in +functions return a non-zero value if ``arg1`` is greater than, less +than, equal to, or not comparable to ``arg2`` respectively. The +arguments are not comparable if one or the other equals NaN (not a +number). + +The ``scalar_test_data_class`` built-in function returns 1 +if any of the condition tests enabled by the value of the +``condition`` variable are true, and 0 otherwise. The +``condition`` argument must be a compile-time constant integer with +value not exceeding 127. The +``condition`` argument is encoded as a bitmask with each bit +enabling the testing of a different condition, as characterized by the +following: + +.. code-block:: c++ + + 0x40 Test for NaN + 0x20 Test for +Infinity + 0x10 Test for -Infinity + 0x08 Test for +Zero + 0x04 Test for -Zero + 0x02 Test for +Denormal + 0x01 Test for -Denormal + +The ``scalar_test_neg`` built-in function returns 1 if its +``source`` argument holds a negative value, 0 otherwise. + +The following built-in functions are also available for the PowerPC family +of processors, starting with ISA 3.0 or later +(:option:`-mcpu=power9`). These string functions are described +separately in order to group the descriptions closer to the function +prototypes. + +Only functions excluded from the PVIPR are listed here. + +.. code-block:: c++ + + int vec_all_nez (vector signed char, vector signed char); + int vec_all_nez (vector unsigned char, vector unsigned char); + int vec_all_nez (vector signed short, vector signed short); + int vec_all_nez (vector unsigned short, vector unsigned short); + int vec_all_nez (vector signed int, vector signed int); + int vec_all_nez (vector unsigned int, vector unsigned int); + + int vec_any_eqz (vector signed char, vector signed char); + int vec_any_eqz (vector unsigned char, vector unsigned char); + int vec_any_eqz (vector signed short, vector signed short); + int vec_any_eqz (vector unsigned short, vector unsigned short); + int vec_any_eqz (vector signed int, vector signed int); + int vec_any_eqz (vector unsigned int, vector unsigned int); + + signed char vec_xlx (unsigned int index, vector signed char data); + unsigned char vec_xlx (unsigned int index, vector unsigned char data); + signed short vec_xlx (unsigned int index, vector signed short data); + unsigned short vec_xlx (unsigned int index, vector unsigned short data); + signed int vec_xlx (unsigned int index, vector signed int data); + unsigned int vec_xlx (unsigned int index, vector unsigned int data); + float vec_xlx (unsigned int index, vector float data); + + signed char vec_xrx (unsigned int index, vector signed char data); + unsigned char vec_xrx (unsigned int index, vector unsigned char data); + signed short vec_xrx (unsigned int index, vector signed short data); + unsigned short vec_xrx (unsigned int index, vector unsigned short data); + signed int vec_xrx (unsigned int index, vector signed int data); + unsigned int vec_xrx (unsigned int index, vector unsigned int data); + float vec_xrx (unsigned int index, vector float data); + +The ``vec_all_nez``, ``vec_any_eqz``, and ``vec_cmpnez`` +perform pairwise comparisons between the elements at the same +positions within their two vector arguments. +The ``vec_all_nez`` function returns a +non-zero value if and only if all pairwise comparisons are not +equal and no element of either vector argument contains a zero. +The ``vec_any_eqz`` function returns a +non-zero value if and only if at least one pairwise comparison is equal +or if at least one element of either vector argument contains a zero. +The ``vec_cmpnez`` function returns a vector of the same type as +its two arguments, within which each element consists of all ones to +denote that either the corresponding elements of the incoming arguments are +not equal or that at least one of the corresponding elements contains +zero. Otherwise, the element of the returned vector contains all zeros. + +The ``vec_xlx`` and ``vec_xrx`` functions extract the single +element selected by the ``index`` argument from the vector +represented by the ``data`` argument. The ``index`` argument +always specifies a byte offset, regardless of the size of the vector +element. With ``vec_xlx``, ``index`` is the offset of the first +byte of the element to be extracted. With ``vec_xrx``, ``index`` +represents the last byte of the element to be extracted, measured +from the right end of the vector. In other words, the last byte of +the element to be extracted is found at position ``(15 - index)``. +There is no requirement that ``index`` be a multiple of the vector +element size. However, if the size of the vector element added to +``index`` is greater than 15, the content of the returned value is +undefined. + +The following functions are also available if the ISA 3.0 instruction +set additions (:option:`-mcpu=power9`) are available. + +Only functions excluded from the PVIPR are listed here. + +.. code-block:: c++ + + vector long long vec_vctz (vector long long); + vector unsigned long long vec_vctz (vector unsigned long long); + vector int vec_vctz (vector int); + vector unsigned int vec_vctz (vector int); + vector short vec_vctz (vector short); + vector unsigned short vec_vctz (vector unsigned short); + vector signed char vec_vctz (vector signed char); + vector unsigned char vec_vctz (vector unsigned char); + + vector signed char vec_vctzb (vector signed char); + vector unsigned char vec_vctzb (vector unsigned char); + + vector long long vec_vctzd (vector long long); + vector unsigned long long vec_vctzd (vector unsigned long long); + + vector short vec_vctzh (vector short); + vector unsigned short vec_vctzh (vector unsigned short); + + vector int vec_vctzw (vector int); + vector unsigned int vec_vctzw (vector int); + + vector int vec_vprtyb (vector int); + vector unsigned int vec_vprtyb (vector unsigned int); + vector long long vec_vprtyb (vector long long); + vector unsigned long long vec_vprtyb (vector unsigned long long); + + vector int vec_vprtybw (vector int); + vector unsigned int vec_vprtybw (vector unsigned int); + + vector long long vec_vprtybd (vector long long); + vector unsigned long long vec_vprtybd (vector unsigned long long); + +On 64-bit targets, if the ISA 3.0 additions (:option:`-mcpu=power9`) +are available: + +.. code-block:: c++ + + vector long vec_vprtyb (vector long); + vector unsigned long vec_vprtyb (vector unsigned long); + vector __int128 vec_vprtyb (vector __int128); + vector __uint128 vec_vprtyb (vector __uint128); + + vector long vec_vprtybd (vector long); + vector unsigned long vec_vprtybd (vector unsigned long); + + vector __int128 vec_vprtybq (vector __int128); + vector __uint128 vec_vprtybd (vector __uint128); + +The following built-in functions are available for the PowerPC family +of processors, starting with ISA 3.0 or later (:option:`-mcpu=power9`). + +Only functions excluded from the PVIPR are listed here. + +.. code-block:: c++ + + __vector unsigned char + vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2); + __vector unsigned short + vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2); + __vector unsigned int + vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2); + +The ``vec_absd``, ``vec_absdb``, ``vec_absdh``, and +``vec_absdw`` built-in functions each computes the absolute +differences of the pairs of vector elements supplied in its two vector +arguments, placing the absolute differences into the corresponding +elements of the vector result. + +The following built-in functions are available for the PowerPC family +of processors, starting with ISA 3.0 or later (:option:`-mcpu=power9`): + +.. code-block:: c++ + + vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int); + vector unsigned long long vec_vrlnm (vector unsigned long long, + vector unsigned long long); + +The result of ``vec_vrlnm`` is obtained by rotating each element +of the first argument vector left and ANDing it with a mask. The +second argument vector contains the mask beginning in bits 11:15, +the mask end in bits 19:23, and the shift count in bits 27:31, +of each element. + +If the cryptographic instructions are enabled (:option:`-mcrypto` or +:option:`-mcpu=power8`), the following builtins are enabled. + +Only functions excluded from the PVIPR are listed here. + +.. code-block:: c++ + + vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long); + + vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long, + vector unsigned long long); + + vector unsigned long long __builtin_crypto_vcipherlast + (vector unsigned long long, + vector unsigned long long); + + vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long, + vector unsigned long long); + + vector unsigned long long __builtin_crypto_vncipherlast (vector unsigned long long, + vector unsigned long long); + + vector unsigned char __builtin_crypto_vpermxor (vector unsigned char, + vector unsigned char, + vector unsigned char); + + vector unsigned short __builtin_crypto_vpermxor (vector unsigned short, + vector unsigned short, + vector unsigned short); + + vector unsigned int __builtin_crypto_vpermxor (vector unsigned int, + vector unsigned int, + vector unsigned int); + + vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long, + vector unsigned long long, + vector unsigned long long); + + vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char, + vector unsigned char); + + vector unsigned short __builtin_crypto_vpmsumh (vector unsigned short, + vector unsigned short); + + vector unsigned int __builtin_crypto_vpmsumw (vector unsigned int, + vector unsigned int); + + vector unsigned long long __builtin_crypto_vpmsumd (vector unsigned long long, + vector unsigned long long); + + vector unsigned long long __builtin_crypto_vshasigmad (vector unsigned long long, + int, int); + + vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int, int, int); + +The second argument to :samp:`{__builtin_crypto_vshasigmad}` and +:samp:`{__builtin_crypto_vshasigmaw}` must be a constant +integer that is 0 or 1. The third argument to these built-in functions +must be a constant integer in the range of 0 to 15. + +The following sign extension builtins are provided: + +.. code-block:: c++ + + vector signed int vec_signexti (vector signed char a); + vector signed long long vec_signextll (vector signed char a); + vector signed int vec_signexti (vector signed short a); + vector signed long long vec_signextll (vector signed short a); + vector signed long long vec_signextll (vector signed int a); + vector signed long long vec_signextq (vector signed long long a); + +Each element of the result is produced by sign-extending the element of the +input vector that would fall in the least significant portion of the result +element. For example, a sign-extension of a vector signed char to a vector +signed long long will sign extend the rightmost byte of each doubleword. + +.. _powerpc-altivec-built-in-functions-available-on-isa-3.1: + +PowerPC AltiVec Built-in Functions Available on ISA 3.1 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following additional built-in functions are also available for the +PowerPC family of processors, starting with ISA 3.1 (:option:`-mcpu=power10`): + +.. code-block:: c++ + + vector unsigned long long int + vec_cfuge (vector unsigned long long int, vector unsigned long long int); + +Perform a vector centrifuge operation, as if implemented by the +``vcfuged`` instruction. + +.. index:: vec_cfuge + +.. code-block:: c++ + + vector unsigned long long int + vec_cntlzm (vector unsigned long long int, vector unsigned long long int); + +Perform a vector count leading zeros under bit mask operation, as if +implemented by the ``vclzdm`` instruction. + +.. index:: vec_cntlzm + +.. code-block:: c++ + + vector unsigned long long int + vec_cnttzm (vector unsigned long long int, vector unsigned long long int); + +Perform a vector count trailing zeros under bit mask operation, as if +implemented by the ``vctzdm`` instruction. + +.. index:: vec_cnttzm + +.. code-block:: c++ + + vector signed char + vec_clrl (vector signed char a, unsigned int n); + vector unsigned char + vec_clrl (vector unsigned char a, unsigned int n); + +Clear the left-most ``(16 - n)`` bytes of vector argument ``a``, as if +implemented by the ``vclrlb`` instruction on a big-endian target +and by the ``vclrrb`` instruction on a little-endian target. A +value of ``n`` that is greater than 16 is treated as if it equaled 16. + +.. index:: vec_clrl + +.. code-block:: c++ + + vector signed char + vec_clrr (vector signed char a, unsigned int n); + vector unsigned char + vec_clrr (vector unsigned char a, unsigned int n); + +Clear the right-most ``(16 - n)`` bytes of vector argument ``a``, as if +implemented by the ``vclrrb`` instruction on a big-endian target +and by the ``vclrlb`` instruction on a little-endian target. A +value of ``n`` that is greater than 16 is treated as if it equaled 16. + +.. index:: vec_clrr + +.. code-block:: c++ + + vector unsigned long long int + vec_gnb (vector unsigned __int128, const unsigned char); + +Perform a 128-bit vector gather operation, as if implemented by the +``vgnb`` instruction. The second argument must be a literal +integer value between 2 and 7 inclusive. + +.. index:: vec_gnb + +Vector Extract + +.. code-block:: c++ + + vector unsigned long long int + vec_extractl (vector unsigned char, vector unsigned char, unsigned int); + vector unsigned long long int + vec_extractl (vector unsigned short, vector unsigned short, unsigned int); + vector unsigned long long int + vec_extractl (vector unsigned int, vector unsigned int, unsigned int); + vector unsigned long long int + vec_extractl (vector unsigned long long, vector unsigned long long, unsigned int); + +Extract an element from two concatenated vectors starting at the given byte index +in natural-endian order, and place it zero-extended in doubleword 1 of the result +according to natural element order. If the byte index is out of range for the +data type, the intrinsic will be rejected. +For little-endian, this output will match the placement by the hardware +instruction, i.e., dword[0] in RTL notation. For big-endian, an additional +instruction is needed to move it from the "left" doubleword to the "right" one. +For little-endian, semantics matching the ``vextdubvrx``, +``vextduhvrx``, ``vextduwvrx`` instruction will be generated, while for +big-endian, semantics matching the ``vextdubvlx``, ``vextduhvlx``, +``vextduwvlx`` instructions +will be generated. Note that some fairly anomalous results can be generated if +the byte index is not aligned on an element boundary for the element being +extracted. This is a limitation of the bi-endian vector programming model is +consistent with the limitation on ``vec_perm``. + +.. index:: vec_extractl + +.. code-block:: c++ + + vector unsigned long long intvec_extracth (vector unsigned char, vector unsigned char, unsigned int); + vector unsigned long long intvec_extracth (vector unsigned short, vector unsigned short,unsigned int); + vector unsigned long long intvec_extracth (vector unsigned int, vector unsigned int, unsigned int); + vector unsigned long long intvec_extracth (vector unsigned long long, vector unsigned long long,unsigned int); + +Extract an element from two concatenated vectors starting at the given byte +index. The index is based on big endian order for a little endian system. +Similarly, the index is based on little endian order for a big endian system. +The extraced elements are zero-extended and put in doubleword 1 +according to natural element order. If the byte index is out of range for the +data type, the intrinsic will be rejected. For little-endian, this output +will match the placement by the hardware instruction (vextdubvrx, vextduhvrx, +vextduwvrx, vextddvrx) i.e., dword[0] in RTL +notation. For big-endian, an additional instruction is needed to move it +from the "left" doubleword to the "right" one. For little-endian, semantics +matching the ``vextdubvlx``, ``vextduhvlx``, ``vextduwvlx`` +instructions will be generated, while for big-endian, semantics matching the +``vextdubvrx``, ``vextduhvrx``, ``vextduwvrx`` instructions will +be generated. Note that some fairly anomalous +results can be generated if the byte index is not aligned on the +element boundary for the element being extracted. This is a +limitation of the bi-endian vector programming model consistent with the +limitation on ``vec_perm``. + +.. index:: vec_extracth + +.. code-block:: c++ + + vector unsigned long long int + vec_pdep (vector unsigned long long int, vector unsigned long long int); + +Perform a vector parallel bits deposit operation, as if implemented by +the ``vpdepd`` instruction. + +.. index:: vec_pdep + +Vector Insert + +.. code-block:: c++ + + vector unsigned charvec_insertl (unsigned char, vector unsigned char, unsigned int); + vector unsigned shortvec_insertl (unsigned short, vector unsigned short, unsigned int); + vector unsigned intvec_insertl (unsigned int, vector unsigned int, unsigned int); + vector unsigned long longvec_insertl (unsigned long long, vector unsigned long long,unsigned int); + vector unsigned charvec_insertl (vector unsigned char, vector unsigned char, unsigned int; + vector unsigned shortvec_insertl (vector unsigned short, vector unsigned short,unsigned int); + vector unsigned intvec_insertl (vector unsigned int, vector unsigned int, unsigned int); + +Let src be the first argument, when the first argument is a scalar, or the +rightmost element of the left doubleword of the first argument, when the first +argument is a vector. Insert the source into the destination at the position +given by the third argument, using natural element order in the second +argument. The rest of the second argument is unchanged. If the byte +index is greater than 14 for halfwords, greater than 12 for words, or +greater than 8 for doublewords the result is undefined. For little-endian, +the generated code will be semantically equivalent to ``vins[bhwd]rx`` +instructions. Similarly for big-endian it will be semantically equivalent +to ``vins[bhwd]lx``. Note that some fairly anomalous results can be +generated if the byte index is not aligned on an element boundary for the +type of element being inserted. + +.. index:: vec_insertl + +.. code-block:: c++ + + vector unsigned charvec_inserth (unsigned char, vector unsigned char, unsigned int); + vector unsigned shortvec_inserth (unsigned short, vector unsigned short, unsigned int); + vector unsigned intvec_inserth (unsigned int, vector unsigned int, unsigned int); + vector unsigned long longvec_inserth (unsigned long long, vector unsigned long long,unsigned int); + vector unsigned charvec_inserth (vector unsigned char, vector unsigned char, unsigned int); + vector unsigned shortvec_inserth (vector unsigned short, vector unsigned short,unsigned int); + vector unsigned intvec_inserth (vector unsigned int, vector unsigned int, unsigned int); + +Let src be the first argument, when the first argument is a scalar, or the +rightmost element of the first argument, when the first argument is a vector. +Insert src into the second argument at the position identified by the third +argument, using opposite element order in the second argument, and leaving the +rest of the second argument unchanged. If the byte index is greater than 14 +for halfwords, 12 for words, or 8 for doublewords, the intrinsic will be +rejected. Note that the underlying hardware instruction uses the same register +for the second argument and the result. +For little-endian, the code generation will be semantically equivalent to +``vins[bhwd]lx``, while for big-endian it will be semantically equivalent to +``vins[bhwd]rx``. +Note that some fairly anomalous results can be generated if the byte index is +not aligned on an element boundary for the sort of element being inserted. + +.. index:: vec_inserth + +Vector Replace Element + +.. code-block:: c++ + + vector signed int vec_replace_elt (vector signed int, signed int,const int); + vector unsigned int vec_replace_elt (vector unsigned int,unsigned int, const int); + vector float vec_replace_elt (vector float, float, const int); + vector signed long long vec_replace_elt (vector signed long long,signed long long, const int); + vector unsigned long long vec_replace_elt (vector unsigned long long,unsigned long long, const int); + vector double rec_replace_elt (vector double, double, const int); + +The third argument (constrained to [0,3]) identifies the natural-endian +element number of the first argument that will be replaced by the second +argument to produce the result. The other elements of the first argument will +remain unchanged in the result. + +If it's desirable to insert a word at an unaligned position, use +vec_replace_unaligned instead. + +.. index:: vec_replace_element + +Vector Replace Unaligned + +.. code-block:: c++ + + vector unsigned char vec_replace_unaligned (vector unsigned char,signed int, const int); + vector unsigned char vec_replace_unaligned (vector unsigned char,unsigned int, const int); + vector unsigned char vec_replace_unaligned (vector unsigned char,float, const int); + vector unsigned char vec_replace_unaligned (vector unsigned char,signed long long, const int); + vector unsigned char vec_replace_unaligned (vector unsigned char,unsigned long long, const int); + vector unsigned char vec_replace_unaligned (vector unsigned char,double, const int); + +The second argument replaces a portion of the first argument to produce the +result, with the rest of the first argument unchanged in the result. The +third argument identifies the byte index (using left-to-right, or big-endian +order) where the high-order byte of the second argument will be placed, with +the remaining bytes of the second argument placed naturally "to the right" +of the high-order byte. + +The programmer is responsible for understanding the endianness issues involved +with the first argument and the result. + +.. index:: vec_replace_unaligned + +Vector Shift Left Double Bit Immediate + +.. code-block:: c++ + + vector signed char vec_sldb (vector signed char, vector signed char,const unsigned int); + vector unsigned char vec_sldb (vector unsigned char,vector unsigned char, const unsigned int); + vector signed short vec_sldb (vector signed short, vector signed short,const unsigned int); + vector unsigned short vec_sldb (vector unsigned short,vector unsigned short, const unsigned int); + vector signed int vec_sldb (vector signed int, vector signed int,const unsigned int); + vector unsigned int vec_sldb (vector unsigned int, vector unsigned int,const unsigned int); + vector signed long long vec_sldb (vector signed long long,vector signed long long, const unsigned int); + vector unsigned long long vec_sldb (vector unsigned long long,vector unsigned long long, const unsigned int); + +Shift the combined input vectors left by the amount specified by the low-order +three bits of the third argument, and return the leftmost remaining 128 bits. +Code using this instruction must be endian-aware. + +.. index:: vec_sldb + +Vector Shift Right Double Bit Immediate + +.. code-block:: c++ + + vector signed char vec_srdb (vector signed char, vector signed char,const unsigned int); + vector unsigned char vec_srdb (vector unsigned char, vector unsigned char,const unsigned int); + vector signed short vec_srdb (vector signed short, vector signed short,const unsigned int); + vector unsigned short vec_srdb (vector unsigned short, vector unsigned short,const unsigned int); + vector signed int vec_srdb (vector signed int, vector signed int,const unsigned int); + vector unsigned int vec_srdb (vector unsigned int, vector unsigned int,const unsigned int); + vector signed long long vec_srdb (vector signed long long,vector signed long long, const unsigned int); + vector unsigned long long vec_srdb (vector unsigned long long,vector unsigned long long, const unsigned int); + +Shift the combined input vectors right by the amount specified by the low-order +three bits of the third argument, and return the remaining 128 bits. Code +using this built-in must be endian-aware. + +.. index:: vec_srdb + +Vector Splat + +.. code-block:: c++ + + vector signed int vec_splati (const signed int); + vector float vec_splati (const float); + +Splat a 32-bit immediate into a vector of words. + +.. index:: vec_splati + +.. code-block:: c++ + + vector double vec_splatid (const float); + +Convert a single precision floating-point value to double-precision and splat +the result to a vector of double-precision floats. + +.. index:: vec_splatid + +.. code-block:: c++ + + vector signed int vec_splati_ins (vector signed int,const unsigned int, const signed int); + vector unsigned int vec_splati_ins (vector unsigned int,const unsigned int, const unsigned int); + vector float vec_splati_ins (vector float, const unsigned int,const float); + +Argument 2 must be either 0 or 1. Splat the value of argument 3 into the word +identified by argument 2 of each doubleword of argument 1 and return the +result. The other words of argument 1 are unchanged. + +.. index:: vec_splati_ins + +Vector Blend Variable + +.. code-block:: c++ + + vector signed char vec_blendv (vector signed char, vector signed char,vector unsigned char); + vector unsigned char vec_blendv (vector unsigned char,vector unsigned char, vector unsigned char); + vector signed short vec_blendv (vector signed short,vector signed short, vector unsigned short); + vector unsigned short vec_blendv (vector unsigned short,vector unsigned short, vector unsigned short); + vector signed int vec_blendv (vector signed int, vector signed int,vector unsigned int); + vector unsigned int vec_blendv (vector unsigned int,vector unsigned int, vector unsigned int); + vector signed long long vec_blendv (vector signed long long,vector signed long long, vector unsigned long long); + vector unsigned long long vec_blendv (vector unsigned long long,vector unsigned long long, vector unsigned long long); + vector float vec_blendv (vector float, vector float,vector unsigned int); + vector double vec_blendv (vector double, vector double,vector unsigned long long); + +Blend the first and second argument vectors according to the sign bits of the +corresponding elements of the third argument vector. This is similar to the +``vsel`` and ``xxsel`` instructions but for bigger elements. + +.. index:: vec_blendv + +Vector Permute Extended + +.. code-block:: c++ + + vector signed char vec_permx (vector signed char, vector signed char,vector unsigned char, const int); + vector unsigned char vec_permx (vector unsigned char,vector unsigned char, vector unsigned char, const int); + vector signed short vec_permx (vector signed short,vector signed short, vector unsigned char, const int); + vector unsigned short vec_permx (vector unsigned short,vector unsigned short, vector unsigned char, const int); + vector signed int vec_permx (vector signed int, vector signed int,vector unsigned char, const int); + vector unsigned int vec_permx (vector unsigned int,vector unsigned int, vector unsigned char, const int); + vector signed long long vec_permx (vector signed long long,vector signed long long, vector unsigned char, const int); + vector unsigned long long vec_permx (vector unsigned long long,vector unsigned long long, vector unsigned char, const int); + vector float (vector float, vector float, vector unsigned char,const int); + vector double (vector double, vector double, vector unsigned char,const int); + +Perform a partial permute of the first two arguments, which form a 32-byte +section of an emulated vector up to 256 bytes wide, using the partial permute +control vector in the third argument. The fourth argument (constrained to +values of 0-7) identifies which 32-byte section of the emulated vector is +contained in the first two arguments. + +.. index:: vec_permx + +.. code-block:: c++ + + vector unsigned long long int + vec_pext (vector unsigned long long int, vector unsigned long long int); + +Perform a vector parallel bit extract operation, as if implemented by +the ``vpextd`` instruction. + +.. index:: vec_pext + +.. code-block:: c++ + + vector unsigned char vec_stril (vector unsigned char); + vector signed char vec_stril (vector signed char); + vector unsigned short vec_stril (vector unsigned short); + vector signed short vec_stril (vector signed short); + +Isolate the left-most non-zero elements of the incoming vector argument, +replacing all elements to the right of the left-most zero element +found within the argument with zero. The typical implementation uses +the ``vstribl`` or ``vstrihl`` instruction on big-endian targets +and uses the ``vstribr`` or ``vstrihr`` instruction on +little-endian targets. + +.. index:: vec_stril + +.. code-block:: c++ + + int vec_stril_p (vector unsigned char); + int vec_stril_p (vector signed char); + int short vec_stril_p (vector unsigned short); + int vec_stril_p (vector signed short); + +Return a non-zero value if and only if the argument contains a zero +element. The typical implementation uses +the ``vstribl.`` or ``vstrihl.`` instruction on big-endian targets +and uses the ``vstribr.`` or ``vstrihr.`` instruction on +little-endian targets. Choose this built-in to check for presence of +zero element if the same argument is also passed to ``vec_stril``. + +.. index:: vec_stril_p + +.. code-block:: c++ + + vector unsigned char vec_strir (vector unsigned char); + vector signed char vec_strir (vector signed char); + vector unsigned short vec_strir (vector unsigned short); + vector signed short vec_strir (vector signed short); + +Isolate the right-most non-zero elements of the incoming vector argument, +replacing all elements to the left of the right-most zero element +found within the argument with zero. The typical implementation uses +the ``vstribr`` or ``vstrihr`` instruction on big-endian targets +and uses the ``vstribl`` or ``vstrihl`` instruction on +little-endian targets. + +.. index:: vec_strir + +.. code-block:: c++ + + int vec_strir_p (vector unsigned char); + int vec_strir_p (vector signed char); + int short vec_strir_p (vector unsigned short); + int vec_strir_p (vector signed short); + +Return a non-zero value if and only if the argument contains a zero +element. The typical implementation uses +the ``vstribr.`` or ``vstrihr.`` instruction on big-endian targets +and uses the ``vstribl.`` or ``vstrihl.`` instruction on +little-endian targets. Choose this built-in to check for presence of +zero element if the same argument is also passed to ``vec_strir``. + +.. index:: vec_strir_p + +.. code-block:: c++ + + vector unsigned charvec_ternarylogic (vector unsigned char, vector unsigned char, vector unsigned char, const unsigned int); + vector unsigned shortvec_ternarylogic (vector unsigned short, vector unsigned short, vector unsigned short, const unsigned int); + vector unsigned intvec_ternarylogic (vector unsigned int, vector unsigned int, vector unsigned int, const unsigned int); + vector unsigned long long intvec_ternarylogic (vector unsigned long long int, vector unsigned long long int, vector unsigned long long int, const unsigned int); + vector unsigned __int128vec_ternarylogic (vector unsigned __int128, vector unsigned __int128, vector unsigned __int128, const unsigned int); + +Perform a 128-bit vector evaluate operation, as if implemented by the +``xxeval`` instruction. The fourth argument must be a literal +integer value between 0 and 255 inclusive. + +.. index:: vec_ternarylogic + +.. code-block:: c++ + + vector unsigned char vec_genpcvm (vector unsigned char, const int); + vector unsigned short vec_genpcvm (vector unsigned short, const int); + vector unsigned int vec_genpcvm (vector unsigned int, const int); + vector unsigned int vec_genpcvm (vector unsigned long long int, const int); + +Vector Integer Multiply/Divide/Modulo + +.. code-block:: c++ + + vector signed int + vec_mulh (vector signed int a, vector signed int b); + vector unsigned int + vec_mulh (vector unsigned int a, vector unsigned int b); + +For each integer value ``i`` from 0 to 3, do the following. The integer +value in word element ``i`` of a is multiplied by the integer value in word +element ``i`` of b. The high-order 32 bits of the 64-bit product are placed +into word element ``i`` of the vector returned. + +.. code-block:: c++ + + vector signed long long + vec_mulh (vector signed long long a, vector signed long long b); + vector unsigned long long + vec_mulh (vector unsigned long long a, vector unsigned long long b); + +For each integer value ``i`` from 0 to 1, do the following. The integer +value in doubleword element ``i`` of a is multiplied by the integer value in +doubleword element ``i`` of b. The high-order 64 bits of the 128-bit product +are placed into doubleword element ``i`` of the vector returned. + +.. code-block:: c++ + + vector unsigned long long + vec_mul (vector unsigned long long a, vector unsigned long long b); + vector signed long long + vec_mul (vector signed long long a, vector signed long long b); + +For each integer value ``i`` from 0 to 1, do the following. The integer +value in doubleword element ``i`` of a is multiplied by the integer value in +doubleword element ``i`` of b. The low-order 64 bits of the 128-bit product +are placed into doubleword element ``i`` of the vector returned. + +.. code-block:: c++ + + vector signed int + vec_div (vector signed int a, vector signed int b); + vector unsigned int + vec_div (vector unsigned int a, vector unsigned int b); + +For each integer value ``i`` from 0 to 3, do the following. The integer in +word element ``i`` of a is divided by the integer in word element ``i`` +of b. The unique integer quotient is placed into the word element ``i`` of +the vector returned. If an attempt is made to perform any of the divisions + ÷ 0 then the quotient is undefined. + +.. code-block:: c++ + + vector signed long long + vec_div (vector signed long long a, vector signed long long b); + vector unsigned long long + vec_div (vector unsigned long long a, vector unsigned long long b); + +For each integer value ``i`` from 0 to 1, do the following. The integer in +doubleword element ``i`` of a is divided by the integer in doubleword +element ``i`` of b. The unique integer quotient is placed into the +doubleword element ``i`` of the vector returned. If an attempt is made to +perform any of the divisions 0x8000_0000_0000_0000 ÷ -1 or ÷ 0 then +the quotient is undefined. + +.. code-block:: c++ + + vector signed int + vec_dive (vector signed int a, vector signed int b); + vector unsigned int + vec_dive (vector unsigned int a, vector unsigned int b); + +For each integer value ``i`` from 0 to 3, do the following. The integer in +word element ``i`` of a is shifted left by 32 bits, then divided by the +integer in word element ``i`` of b. The unique integer quotient is placed +into the word element ``i`` of the vector returned. If the quotient cannot +be represented in 32 bits, or if an attempt is made to perform any of the +divisions ÷ 0 then the quotient is undefined. + +.. code-block:: c++ + + vector signed long long + vec_dive (vector signed long long a, vector signed long long b); + vector unsigned long long + vec_dive (vector unsigned long long a, vector unsigned long long b); + +For each integer value ``i`` from 0 to 1, do the following. The integer in +doubleword element ``i`` of a is shifted left by 64 bits, then divided by +the integer in doubleword element ``i`` of b. The unique integer quotient is +placed into the doubleword element ``i`` of the vector returned. If the +quotient cannot be represented in 64 bits, or if an attempt is made to perform + ÷ 0 then the quotient is undefined. + +.. code-block:: c++ + + vector signed int + vec_mod (vector signed int a, vector signed int b); + vector unsigned int + vec_mod (vector unsigned int a, vector unsigned int b); + +For each integer value ``i`` from 0 to 3, do the following. The integer in +word element ``i`` of a is divided by the integer in word element ``i`` +of b. The unique integer remainder is placed into the word element ``i`` of +the vector returned. If an attempt is made to perform any of the divisions +0x8000_0000 ÷ -1 or ÷ 0 then the remainder is undefined. + +.. code-block:: c++ + + vector signed long long + vec_mod (vector signed long long a, vector signed long long b); + vector unsigned long long + vec_mod (vector unsigned long long a, vector unsigned long long b); + +For each integer value ``i`` from 0 to 1, do the following. The integer in +doubleword element ``i`` of a is divided by the integer in doubleword +element ``i`` of b. The unique integer remainder is placed into the +doubleword element ``i`` of the vector returned. If an attempt is made to +perform ÷ 0 then the remainder is undefined. + +Generate PCV from specified Mask size, as if implemented by the +``xxgenpcvbm``, ``xxgenpcvhm``, ``xxgenpcvwm`` instructions, where +immediate value is either 0, 1, 2 or 3. + +.. index:: vec_genpcvm + +.. code-block:: c++ + + vector unsigned __int128 vec_rl (vector unsigned __int128 A, vector unsigned __int128 B); + vector signed __int128 vec_rl (vector signed __int128 A, vector unsigned __int128 B); + +Result value: Each element of R is obtained by rotating the corresponding element +of A left by the number of bits specified by the corresponding element of B. + +.. code-block:: c++ + + vector unsigned __int128 vec_rlmi (vector unsigned __int128, vector unsigned __int128, vector unsigned __int128); + vector signed __int128 vec_rlmi (vector signed __int128, vector signed __int128, vector unsigned __int128); + +Returns the result of rotating the first input and inserting it under mask +into the second input. The first bit in the mask, the last bit in the mask are +obtained from the two 7-bit fields bits [108:115] and bits [117:123] +respectively of the second input. The shift is obtained from the third input +in the 7-bit field [125:131] where all bits counted from zero at the left. + +.. code-block:: c++ + + vector unsigned __int128 vec_rlnm (vector unsigned __int128, vector unsigned __int128, vector unsigned __int128); + vector signed __int128 vec_rlnm (vector signed __int128, vector unsigned __int128, vector unsigned __int128); + +Returns the result of rotating the first input and ANDing it with a mask. The +first bit in the mask and the last bit in the mask are obtained from the two +7-bit fields bits [117:123] and bits [125:131] respectively of the second +input. The shift is obtained from the third input in the 7-bit field bits +[125:131] where all bits counted from zero at the left. + +.. code-block:: c++ + + vector unsigned __int128 vec_sl(vector unsigned __int128 A, vector unsigned __int128 B); + vector signed __int128 vec_sl(vector signed __int128 A, vector unsigned __int128 B); + +Result value: Each element of R is obtained by shifting the corresponding element of +A left by the number of bits specified by the corresponding element of B. + +.. code-block:: c++ + + vector unsigned __int128 vec_sr(vector unsigned __int128 A, vector unsigned __int128 B); + vector signed __int128 vec_sr(vector signed __int128 A, vector unsigned __int128 B); + +Result value: Each element of R is obtained by shifting the corresponding element of +A right by the number of bits specified by the corresponding element of B. + +.. code-block:: c++ + + vector unsigned __int128 vec_sra(vector unsigned __int128 A, vector unsigned __int128 B); + vector signed __int128 vec_sra(vector signed __int128 A, vector unsigned __int128 B); + +Result value: Each element of R is obtained by arithmetic shifting the corresponding +element of A right by the number of bits specified by the corresponding element of B. + +.. code-block:: c++ + + vector unsigned __int128 vec_mule (vector unsigned long long, vector unsigned long long); + vector signed __int128 vec_mule (vector signed long long, vector signed long long); + +Returns a vector containing a 128-bit integer result of multiplying the even +doubleword elements of the two inputs. + +.. code-block:: c++ + + vector unsigned __int128 vec_mulo (vector unsigned long long, vector unsigned long long); + vector signed __int128 vec_mulo (vector signed long long, vector signed long long); + +Returns a vector containing a 128-bit integer result of multiplying the odd +doubleword elements of the two inputs. + +.. code-block:: c++ + + vector unsigned __int128 vec_div (vector unsigned __int128, vector unsigned __int128); + vector signed __int128 vec_div (vector signed __int128, vector signed __int128); + +Returns the result of dividing the first operand by the second operand. An +attempt to divide any value by zero or to divide the most negative signed +128-bit integer by negative one results in an undefined value. + +.. code-block:: c++ + + vector unsigned __int128 vec_dive (vector unsigned __int128, vector unsigned __int128); + vector signed __int128 vec_dive (vector signed __int128, vector signed __int128); + +The result is produced by shifting the first input left by 128 bits and +dividing by the second. If an attempt is made to divide by zero or the result +is larger than 128 bits, the result is undefined. + +.. code-block:: c++ + + vector unsigned __int128 vec_mod (vector unsigned __int128, vector unsigned __int128); + vector signed __int128 vec_mod (vector signed __int128, vector signed __int128); + +The result is the modulo result of dividing the first input by the second +input. + +The following builtins perform 128-bit vector comparisons. The +``vec_all_xx``, ``vec_any_xx``, and ``vec_cmpxx``, where ``xx`` is +one of the operations ``eq, ne, gt, lt, ge, le`` perform pairwise +comparisons between the elements at the same positions within their two vector +arguments. The ``vec_all_xx`` function returns a non-zero value if and only +if all pairwise comparisons are true. The ``vec_any_xx`` function returns +a non-zero value if and only if at least one pairwise comparison is true. The +``vec_cmpxx`` function returns a vector of the same type as its two +arguments, within which each element consists of all ones to denote that +specified logical comparison of the corresponding elements was true. +Otherwise, the element of the returned vector contains all zeros. + +.. code-block:: c++ + + vector bool __int128 vec_cmpeq (vector signed __int128, vector signed __int128); + vector bool __int128 vec_cmpeq (vector unsigned __int128, vector unsigned __int128); + vector bool __int128 vec_cmpne (vector signed __int128, vector signed __int128); + vector bool __int128 vec_cmpne (vector unsigned __int128, vector unsigned __int128); + vector bool __int128 vec_cmpgt (vector signed __int128, vector signed __int128); + vector bool __int128 vec_cmpgt (vector unsigned __int128, vector unsigned __int128); + vector bool __int128 vec_cmplt (vector signed __int128, vector signed __int128); + vector bool __int128 vec_cmplt (vector unsigned __int128, vector unsigned __int128); + vector bool __int128 vec_cmpge (vector signed __int128, vector signed __int128); + vector bool __int128 vec_cmpge (vector unsigned __int128, vector unsigned __int128); + vector bool __int128 vec_cmple (vector signed __int128, vector signed __int128); + vector bool __int128 vec_cmple (vector unsigned __int128, vector unsigned __int128); + + int vec_all_eq (vector signed __int128, vector signed __int128); + int vec_all_eq (vector unsigned __int128, vector unsigned __int128); + int vec_all_ne (vector signed __int128, vector signed __int128); + int vec_all_ne (vector unsigned __int128, vector unsigned __int128); + int vec_all_gt (vector signed __int128, vector signed __int128); + int vec_all_gt (vector unsigned __int128, vector unsigned __int128); + int vec_all_lt (vector signed __int128, vector signed __int128); + int vec_all_lt (vector unsigned __int128, vector unsigned __int128); + int vec_all_ge (vector signed __int128, vector signed __int128); + int vec_all_ge (vector unsigned __int128, vector unsigned __int128); + int vec_all_le (vector signed __int128, vector signed __int128); + int vec_all_le (vector unsigned __int128, vector unsigned __int128); + + int vec_any_eq (vector signed __int128, vector signed __int128); + int vec_any_eq (vector unsigned __int128, vector unsigned __int128); + int vec_any_ne (vector signed __int128, vector signed __int128); + int vec_any_ne (vector unsigned __int128, vector unsigned __int128); + int vec_any_gt (vector signed __int128, vector signed __int128); + int vec_any_gt (vector unsigned __int128, vector unsigned __int128); + int vec_any_lt (vector signed __int128, vector signed __int128); + int vec_any_lt (vector unsigned __int128, vector unsigned __int128); + int vec_any_ge (vector signed __int128, vector signed __int128); + int vec_any_ge (vector unsigned __int128, vector unsigned __int128); + int vec_any_le (vector signed __int128, vector signed __int128); + int vec_any_le (vector unsigned __int128, vector unsigned __int128); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-atomic-memory-operation-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-atomic-memory-operation-functions.rst new file mode 100644 index 00000000000..331d5fc7bde --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-atomic-memory-operation-functions.rst @@ -0,0 +1,68 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _powerpc-atomic-memory-operation-functions: + +PowerPC Atomic Memory Operation Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +ISA 3.0 of the PowerPC added new atomic memory operation (amo) +instructions. GCC provides support for these instructions in 64-bit +environments. All of the functions are declared in the include file +``amo.h``. + +The functions supported are: + +.. code-block:: c++ + + #include + + uint32_t amo_lwat_add (uint32_t *, uint32_t); + uint32_t amo_lwat_xor (uint32_t *, uint32_t); + uint32_t amo_lwat_ior (uint32_t *, uint32_t); + uint32_t amo_lwat_and (uint32_t *, uint32_t); + uint32_t amo_lwat_umax (uint32_t *, uint32_t); + uint32_t amo_lwat_umin (uint32_t *, uint32_t); + uint32_t amo_lwat_swap (uint32_t *, uint32_t); + + int32_t amo_lwat_sadd (int32_t *, int32_t); + int32_t amo_lwat_smax (int32_t *, int32_t); + int32_t amo_lwat_smin (int32_t *, int32_t); + int32_t amo_lwat_sswap (int32_t *, int32_t); + + uint64_t amo_ldat_add (uint64_t *, uint64_t); + uint64_t amo_ldat_xor (uint64_t *, uint64_t); + uint64_t amo_ldat_ior (uint64_t *, uint64_t); + uint64_t amo_ldat_and (uint64_t *, uint64_t); + uint64_t amo_ldat_umax (uint64_t *, uint64_t); + uint64_t amo_ldat_umin (uint64_t *, uint64_t); + uint64_t amo_ldat_swap (uint64_t *, uint64_t); + + int64_t amo_ldat_sadd (int64_t *, int64_t); + int64_t amo_ldat_smax (int64_t *, int64_t); + int64_t amo_ldat_smin (int64_t *, int64_t); + int64_t amo_ldat_sswap (int64_t *, int64_t); + + void amo_stwat_add (uint32_t *, uint32_t); + void amo_stwat_xor (uint32_t *, uint32_t); + void amo_stwat_ior (uint32_t *, uint32_t); + void amo_stwat_and (uint32_t *, uint32_t); + void amo_stwat_umax (uint32_t *, uint32_t); + void amo_stwat_umin (uint32_t *, uint32_t); + + void amo_stwat_sadd (int32_t *, int32_t); + void amo_stwat_smax (int32_t *, int32_t); + void amo_stwat_smin (int32_t *, int32_t); + + void amo_stdat_add (uint64_t *, uint64_t); + void amo_stdat_xor (uint64_t *, uint64_t); + void amo_stdat_ior (uint64_t *, uint64_t); + void amo_stdat_and (uint64_t *, uint64_t); + void amo_stdat_umax (uint64_t *, uint64_t); + void amo_stdat_umin (uint64_t *, uint64_t); + + void amo_stdat_sadd (int64_t *, int64_t); + void amo_stdat_smax (int64_t *, int64_t); + void amo_stdat_smin (int64_t *, int64_t); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-hardware-transactional-memory-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-hardware-transactional-memory-built-in-functions.rst new file mode 100644 index 00000000000..4b104a24298 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-hardware-transactional-memory-built-in-functions.rst @@ -0,0 +1,226 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _powerpc-hardware-transactional-memory-built-in-functions: + +PowerPC Hardware Transactional Memory Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC provides two interfaces for accessing the Hardware Transactional +Memory (HTM) instructions available on some of the PowerPC family +of processors (eg, POWER8). The two interfaces come in a low level +interface, consisting of built-in functions specific to PowerPC and a +higher level interface consisting of inline functions that are common +between PowerPC and S/390. + +PowerPC HTM Low Level Built-in Functions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following low level built-in functions are available with +:option:`-mhtm` or :option:`-mcpu=CPU` where CPU is 'power8' or later. +They all generate the machine instruction that is part of the name. + +The HTM builtins (with the exception of ``__builtin_tbegin``) return +the full 4-bit condition register value set by their associated hardware +instruction. The header file ``htmintrin.h`` defines some macros that can +be used to decipher the return value. The ``__builtin_tbegin`` builtin +returns a simple ``true`` or ``false`` value depending on whether a transaction was +successfully started or not. The arguments of the builtins match exactly the +type and order of the associated hardware instruction's operands, except for +the ``__builtin_tcheck`` builtin, which does not take any input arguments. +Refer to the ISA manual for a description of each instruction's operands. + +.. code-block:: c++ + + unsigned int __builtin_tbegin (unsigned int); + unsigned int __builtin_tend (unsigned int); + + unsigned int __builtin_tabort (unsigned int); + unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int); + unsigned int __builtin_tabortdci (unsigned int, unsigned int, int); + unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int); + unsigned int __builtin_tabortwci (unsigned int, unsigned int, int); + + unsigned int __builtin_tcheck (void); + unsigned int __builtin_treclaim (unsigned int); + unsigned int __builtin_trechkpt (void); + unsigned int __builtin_tsr (unsigned int); + +In addition to the above HTM built-ins, we have added built-ins for +some common extended mnemonics of the HTM instructions: + +.. code-block:: c++ + + unsigned int __builtin_tendall (void); + unsigned int __builtin_tresume (void); + unsigned int __builtin_tsuspend (void); + +Note that the semantics of the above HTM builtins are required to mimic +the locking semantics used for critical sections. Builtins that are used +to create a new transaction or restart a suspended transaction must have +lock acquisition like semantics while those builtins that end or suspend a +transaction must have lock release like semantics. Specifically, this must +mimic lock semantics as specified by C++11, for example: Lock acquisition is +as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE) +that returns 0, and lock release is as-if an execution of +__atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an +implicit implementation-defined lock used for all transactions. The HTM +instructions associated with with the builtins inherently provide the +correct acquisition and release hardware barriers required. However, +the compiler must also be prohibited from moving loads and stores across +the builtins in a way that would violate their semantics. This has been +accomplished by adding memory barriers to the associated HTM instructions +(which is a conservative approach to provide acquire and release semantics). +Earlier versions of the compiler did not treat the HTM instructions as +memory barriers. A ``__TM_FENCE__`` macro has been added, which can +be used to determine whether the current compiler treats HTM instructions +as memory barriers or not. This allows the user to explicitly add memory +barriers to their code when using an older version of the compiler. + +The following set of built-in functions are available to gain access +to the HTM specific special purpose registers. + +.. code-block:: c++ + + unsigned long __builtin_get_texasr (void); + unsigned long __builtin_get_texasru (void); + unsigned long __builtin_get_tfhar (void); + unsigned long __builtin_get_tfiar (void); + + void __builtin_set_texasr (unsigned long); + void __builtin_set_texasru (unsigned long); + void __builtin_set_tfhar (unsigned long); + void __builtin_set_tfiar (unsigned long); + +Example usage of these low level built-in functions may look like: + +.. code-block:: c++ + + #include + + int num_retries = 10; + + while (1) + { + if (__builtin_tbegin (0)) + { + /* Transaction State Initiated. */ + if (is_locked (lock)) + __builtin_tabort (0); + ... transaction code... + __builtin_tend (0); + break; + } + else + { + /* Transaction State Failed. Use locks if the transaction + failure is "persistent" or we've tried too many times. */ + if (num_retries-- <= 0 + || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ())) + { + acquire_lock (lock); + ... non transactional fallback path... + release_lock (lock); + break; + } + } + } + +One final built-in function has been added that returns the value of +the 2-bit Transaction State field of the Machine Status Register (MSR) +as stored in ``CR0``. + +.. code-block:: c++ + + unsigned long __builtin_ttest (void) + +This built-in can be used to determine the current transaction state +using the following code example: + +.. code-block:: c++ + + #include + + unsigned char tx_state = _HTM_STATE (__builtin_ttest ()); + + if (tx_state == _HTM_TRANSACTIONAL) + { + /* Code to use in transactional state. */ + } + else if (tx_state == _HTM_NONTRANSACTIONAL) + { + /* Code to use in non-transactional state. */ + } + else if (tx_state == _HTM_SUSPENDED) + { + /* Code to use in transaction suspended state. */ + } + +PowerPC HTM High Level Inline Functions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following high level HTM interface is made available by including +```` and using :option:`-mhtm` or :option:`-mcpu=CPU` +where CPU is 'power8' or later. This interface is common between PowerPC +and S/390, allowing users to write one HTM source implementation that +can be compiled and executed on either system. + +.. code-block:: c++ + + long __TM_simple_begin (void); + long __TM_begin (void* const TM_buff); + long __TM_end (void); + void __TM_abort (void); + void __TM_named_abort (unsigned char const code); + void __TM_resume (void); + void __TM_suspend (void); + + long __TM_is_user_abort (void* const TM_buff); + long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code); + long __TM_is_illegal (void* const TM_buff); + long __TM_is_footprint_exceeded (void* const TM_buff); + long __TM_nesting_depth (void* const TM_buff); + long __TM_is_nested_too_deep(void* const TM_buff); + long __TM_is_conflict(void* const TM_buff); + long __TM_is_failure_persistent(void* const TM_buff); + long __TM_failure_address(void* const TM_buff); + long long __TM_failure_code(void* const TM_buff); + +Using these common set of HTM inline functions, we can create +a more portable version of the HTM example in the previous +section that will work on either PowerPC or S/390: + +.. code-block:: c++ + + #include + + int num_retries = 10; + TM_buff_type TM_buff; + + while (1) + { + if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED) + { + /* Transaction State Initiated. */ + if (is_locked (lock)) + __TM_abort (); + ... transaction code... + __TM_end (); + break; + } + else + { + /* Transaction State Failed. Use locks if the transaction + failure is "persistent" or we've tried too many times. */ + if (num_retries-- <= 0 + || __TM_is_failure_persistent (TM_buff)) + { + acquire_lock (lock); + ... non transactional fallback path... + release_lock (lock); + break; + } + } + } \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-matrix-multiply-assist-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-matrix-multiply-assist-built-in-functions.rst new file mode 100644 index 00000000000..dd9e984b391 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/powerpc-matrix-multiply-assist-built-in-functions.rst @@ -0,0 +1,104 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _powerpc-matrix-multiply-assist-built-in-functions: + +PowerPC Matrix-Multiply Assist Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +ISA 3.1 of the PowerPC added new Matrix-Multiply Assist (MMA) instructions. +GCC provides support for these instructions through the following built-in +functions which are enabled with the ``-mmma`` option. The vec_t type +below is defined to be a normal vector unsigned char type. The uint2, uint4 +and uint8 parameters are 2-bit, 4-bit and 8-bit unsigned integer constants +respectively. The compiler will verify that they are constants and that +their values are within range. + +The built-in functions supported are: + +.. code-block:: c++ + + void __builtin_mma_xvi4ger8 (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvi8ger4 (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvi16ger2 (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvi16ger2s (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvf16ger2 (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvbf16ger2 (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvf32ger (__vector_quad *, vec_t, vec_t); + + void __builtin_mma_xvi4ger8pp (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvi8ger4pp (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvi8ger4spp(__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvi16ger2pp (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvi16ger2spp (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvf16ger2pp (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvf16ger2pn (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvf16ger2np (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvf16ger2nn (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvbf16ger2pp (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvbf16ger2pn (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvbf16ger2np (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvbf16ger2nn (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvf32gerpp (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvf32gerpn (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvf32gernp (__vector_quad *, vec_t, vec_t); + void __builtin_mma_xvf32gernn (__vector_quad *, vec_t, vec_t); + + void __builtin_mma_pmxvi4ger8 (__vector_quad *, vec_t, vec_t, uint4, uint4, uint8); + void __builtin_mma_pmxvi4ger8pp (__vector_quad *, vec_t, vec_t, uint4, uint4, uint8); + + void __builtin_mma_pmxvi8ger4 (__vector_quad *, vec_t, vec_t, uint4, uint4, uint4); + void __builtin_mma_pmxvi8ger4pp (__vector_quad *, vec_t, vec_t, uint4, uint4, uint4); + void __builtin_mma_pmxvi8ger4spp(__vector_quad *, vec_t, vec_t, uint4, uint4, uint4); + + void __builtin_mma_pmxvi16ger2 (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + void __builtin_mma_pmxvi16ger2s (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + void __builtin_mma_pmxvf16ger2 (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + void __builtin_mma_pmxvbf16ger2 (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + + void __builtin_mma_pmxvi16ger2pp (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + void __builtin_mma_pmxvi16ger2spp (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + void __builtin_mma_pmxvf16ger2pp (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + void __builtin_mma_pmxvf16ger2pn (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + void __builtin_mma_pmxvf16ger2np (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + void __builtin_mma_pmxvf16ger2nn (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + void __builtin_mma_pmxvbf16ger2pp (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + void __builtin_mma_pmxvbf16ger2pn (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + void __builtin_mma_pmxvbf16ger2np (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + void __builtin_mma_pmxvbf16ger2nn (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2); + + void __builtin_mma_pmxvf32ger (__vector_quad *, vec_t, vec_t, uint4, uint4); + void __builtin_mma_pmxvf32gerpp (__vector_quad *, vec_t, vec_t, uint4, uint4); + void __builtin_mma_pmxvf32gerpn (__vector_quad *, vec_t, vec_t, uint4, uint4); + void __builtin_mma_pmxvf32gernp (__vector_quad *, vec_t, vec_t, uint4, uint4); + void __builtin_mma_pmxvf32gernn (__vector_quad *, vec_t, vec_t, uint4, uint4); + + void __builtin_mma_xvf64ger (__vector_quad *, __vector_pair, vec_t); + void __builtin_mma_xvf64gerpp (__vector_quad *, __vector_pair, vec_t); + void __builtin_mma_xvf64gerpn (__vector_quad *, __vector_pair, vec_t); + void __builtin_mma_xvf64gernp (__vector_quad *, __vector_pair, vec_t); + void __builtin_mma_xvf64gernn (__vector_quad *, __vector_pair, vec_t); + + void __builtin_mma_pmxvf64ger (__vector_quad *, __vector_pair, vec_t, uint4, uint2); + void __builtin_mma_pmxvf64gerpp (__vector_quad *, __vector_pair, vec_t, uint4, uint2); + void __builtin_mma_pmxvf64gerpn (__vector_quad *, __vector_pair, vec_t, uint4, uint2); + void __builtin_mma_pmxvf64gernp (__vector_quad *, __vector_pair, vec_t, uint4, uint2); + void __builtin_mma_pmxvf64gernn (__vector_quad *, __vector_pair, vec_t, uint4, uint2); + + void __builtin_mma_xxmtacc (__vector_quad *); + void __builtin_mma_xxmfacc (__vector_quad *); + void __builtin_mma_xxsetaccz (__vector_quad *); + + void __builtin_mma_build_acc (__vector_quad *, vec_t, vec_t, vec_t, vec_t); + void __builtin_mma_disassemble_acc (void *, __vector_quad *); + + void __builtin_vsx_build_pair (__vector_pair *, vec_t, vec_t); + void __builtin_vsx_disassemble_pair (void *, __vector_pair *); + + vec_t __builtin_vsx_xvcvspbf16 (vec_t); + vec_t __builtin_vsx_xvcvbf16spn (vec_t); + + __vector_pair __builtin_vsx_lxvp (size_t, __vector_pair *); + void __builtin_vsx_stxvp (__vector_pair, size_t, __vector_pair *); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/pru-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/pru-built-in-functions.rst new file mode 100644 index 00000000000..840ce92f96d --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/pru-built-in-functions.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _pru-built-in-functions: + +PRU Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^ + +GCC provides a couple of special builtin functions to aid in utilizing +special PRU instructions. + +The built-in functions supported are: + +.. function:: __delay_cycles (long long cycles) + + This inserts an instruction sequence that takes exactly :samp:`{cycles}` + cycles (between 0 and 0xffffffff) to complete. The inserted sequence + may use jumps, loops, or no-ops, and does not interfere with any other + instructions. Note that :samp:`{cycles}` must be a compile-time constant + integer - that is, you must pass a number, not a variable that may be + optimized to a constant later. The number of cycles delayed by this + builtin is exact. + +.. function:: __halt (void) + + This inserts a HALT instruction to stop processor execution. + +.. function:: unsigned int __lmbd (unsigned int wordval, unsigned int bitval) + + This inserts LMBD instruction to calculate the left-most bit with value + :samp:`{bitval}` in value :samp:`{wordval}`. Only the least significant bit + of :samp:`{bitval}` is taken into account. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/risc-v-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/risc-v-built-in-functions.rst new file mode 100644 index 00000000000..90ed798d0fe --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/risc-v-built-in-functions.rst @@ -0,0 +1,16 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _risc-v-built-in-functions: + +RISC-V Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^ + +These built-in functions are available for the RISC-V family of +processors. + +.. function:: void * __builtin_thread_pointer (void) + + Returns the value that is currently set in the :samp:`tp` register. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/rx-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/rx-built-in-functions.rst new file mode 100644 index 00000000000..632014f11ca --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/rx-built-in-functions.rst @@ -0,0 +1,122 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _rx-built-in-functions: + +RX Built-in Functions +^^^^^^^^^^^^^^^^^^^^^ + +GCC supports some of the RX instructions which cannot be expressed in +the C programming language via the use of built-in functions. The +following functions are supported: + +.. function:: void __builtin_rx_brk (void) + + Generates the ``brk`` machine instruction. + +.. function:: void __builtin_rx_clrpsw (int) + + Generates the ``clrpsw`` machine instruction to clear the specified + bit in the processor status word. + +.. function:: void __builtin_rx_int (int) + + Generates the ``int`` machine instruction to generate an interrupt + with the specified value. + +.. function:: void __builtin_rx_machi (int, int) + + Generates the ``machi`` machine instruction to add the result of + multiplying the top 16 bits of the two arguments into the + accumulator. + +.. function:: void __builtin_rx_maclo (int, int) + + Generates the ``maclo`` machine instruction to add the result of + multiplying the bottom 16 bits of the two arguments into the + accumulator. + +.. function:: void __builtin_rx_mulhi (int, int) + + Generates the ``mulhi`` machine instruction to place the result of + multiplying the top 16 bits of the two arguments into the + accumulator. + +.. function:: void __builtin_rx_mullo (int, int) + + Generates the ``mullo`` machine instruction to place the result of + multiplying the bottom 16 bits of the two arguments into the + accumulator. + +.. function:: int __builtin_rx_mvfachi (void) + + Generates the ``mvfachi`` machine instruction to read the top + 32 bits of the accumulator. + +.. function:: int __builtin_rx_mvfacmi (void) + + Generates the ``mvfacmi`` machine instruction to read the middle + 32 bits of the accumulator. + +.. function:: int __builtin_rx_mvfc (int) + + Generates the ``mvfc`` machine instruction which reads the control + register specified in its argument and returns its value. + +.. function:: void __builtin_rx_mvtachi (int) + + Generates the ``mvtachi`` machine instruction to set the top + 32 bits of the accumulator. + +.. function:: void __builtin_rx_mvtaclo (int) + + Generates the ``mvtaclo`` machine instruction to set the bottom + 32 bits of the accumulator. + +.. function:: void __builtin_rx_mvtc (int reg, int val) + + Generates the ``mvtc`` machine instruction which sets control + register number ``reg`` to ``val``. + +.. function:: void __builtin_rx_mvtipl (int) + + Generates the ``mvtipl`` machine instruction set the interrupt + priority level. + +.. function:: void __builtin_rx_racw (int) + + Generates the ``racw`` machine instruction to round the accumulator + according to the specified mode. + +.. function:: int __builtin_rx_revw (int) + + Generates the ``revw`` machine instruction which swaps the bytes in + the argument so that bits 0--7 now occupy bits 8--15 and vice versa, + and also bits 16--23 occupy bits 24--31 and vice versa. + +.. function:: void __builtin_rx_rmpa (void) + + Generates the ``rmpa`` machine instruction which initiates a + repeated multiply and accumulate sequence. + +.. function:: void __builtin_rx_round (float) + + Generates the ``round`` machine instruction which returns the + floating-point argument rounded according to the current rounding mode + set in the floating-point status word register. + +.. function:: int __builtin_rx_sat (int) + + Generates the ``sat`` machine instruction which returns the + saturated value of the argument. + +.. function:: void __builtin_rx_setpsw (int) + + Generates the ``setpsw`` machine instruction to set the specified + bit in the processor status word. + +.. function:: void __builtin_rx_wait (void) + + Generates the ``wait`` machine instruction. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/s-390-system-z-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/s-390-system-z-built-in-functions.rst new file mode 100644 index 00000000000..3311d0b59b9 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/s-390-system-z-built-in-functions.rst @@ -0,0 +1,121 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _s-390-system-z-built-in-functions: + +S/390 System z Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: int __builtin_tbegin (void*) + + Generates the ``tbegin`` machine instruction starting a + non-constrained hardware transaction. If the parameter is non-NULL the + memory area is used to store the transaction diagnostic buffer and + will be passed as first operand to ``tbegin``. This buffer can be + defined using the ``struct __htm_tdb`` C struct defined in + ``htmintrin.h`` and must reside on a double-word boundary. The + second tbegin operand is set to ``0xff0c``. This enables + save/restore of all GPRs and disables aborts for FPR and AR + manipulations inside the transaction body. The condition code set by + the tbegin instruction is returned as integer value. The tbegin + instruction by definition overwrites the content of all FPRs. The + compiler will generate code which saves and restores the FPRs. For + soft-float code it is recommended to used the ``*_nofloat`` + variant. In order to prevent a TDB from being written it is required + to pass a constant zero value as parameter. Passing a zero value + through a variable is not sufficient. Although modifications of + access registers inside the transaction will not trigger an + transaction abort it is not supported to actually modify them. Access + registers do not get saved when entering a transaction. They will have + undefined state when reaching the abort code. + +Macros for the possible return codes of tbegin are defined in the +``htmintrin.h`` header file: + +``_HTM_TBEGIN_STARTED`` + ``tbegin`` has been executed as part of normal processing. The + transaction body is supposed to be executed. + +``_HTM_TBEGIN_INDETERMINATE`` + The transaction was aborted due to an indeterminate condition which + might be persistent. + +``_HTM_TBEGIN_TRANSIENT`` + The transaction aborted due to a transient failure. The transaction + should be re-executed in that case. + +``_HTM_TBEGIN_PERSISTENT`` + The transaction aborted due to a persistent failure. Re-execution + under same circumstances will not be productive. + +.. c:macro:: _HTM_FIRST_USER_ABORT_CODE + + The ``_HTM_FIRST_USER_ABORT_CODE`` defined in ``htmintrin.h`` + specifies the first abort code which can be used for + ``__builtin_tabort``. Values below this threshold are reserved for + machine use. + +.. index:: struct __htm_tdb + +Data type struct __htm_tdbThe ``struct __htm_tdb`` defined in ``htmintrin.h`` describes +the structure of the transaction diagnostic block as specified in the +Principles of Operation manual chapter 5-91. + +.. function:: int __builtin_tbegin_nofloat (void*) + + Same as ``__builtin_tbegin`` but without FPR saves and restores. + Using this variant in code making use of FPRs will leave the FPRs in + undefined state when entering the transaction abort handler code. + +.. function:: int __builtin_tbegin_retry (void*, int) + + In addition to ``__builtin_tbegin`` a loop for transient failures + is generated. If tbegin returns a condition code of 2 the transaction + will be retried as often as specified in the second argument. The + perform processor assist instruction is used to tell the CPU about the + number of fails so far. + +.. function:: int __builtin_tbegin_retry_nofloat (void*, int) + + Same as ``__builtin_tbegin_retry`` but without FPR saves and + restores. Using this variant in code making use of FPRs will leave + the FPRs in undefined state when entering the transaction abort + handler code. + +.. function:: void __builtin_tbeginc (void) + + Generates the ``tbeginc`` machine instruction starting a constrained + hardware transaction. The second operand is set to ``0xff08``. + +.. function:: int __builtin_tend (void) + + Generates the ``tend`` machine instruction finishing a transaction + and making the changes visible to other threads. The condition code + generated by tend is returned as integer value. + +.. function:: void __builtin_tabort (int) + + Generates the ``tabort`` machine instruction with the specified + abort code. Abort codes from 0 through 255 are reserved and will + result in an error message. + +.. function:: void __builtin_tx_assist (int) + + Generates the ``ppa rX,rY,1`` machine instruction. Where the + integer parameter is loaded into rX and a value of zero is loaded into + rY. The integer parameter specifies the number of times the + transaction repeatedly aborted. + +.. function:: int __builtin_tx_nesting_depth (void) + + Generates the ``etnd`` machine instruction. The current nesting + depth is returned as integer value. For a nesting depth of 0 the code + is not executed as part of an transaction. + +.. function:: void __builtin_non_tx_store (uint64_t *, uint64_t) + + Generates the ``ntstg`` machine instruction. The second argument + is written to the first arguments location. The store operation will + not be rolled-back in case of an transaction abort. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/sh-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/sh-built-in-functions.rst new file mode 100644 index 00000000000..4240fb74945 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/sh-built-in-functions.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _sh-built-in-functions: + +SH Built-in Functions +^^^^^^^^^^^^^^^^^^^^^ + +The following built-in functions are supported on the SH1, SH2, SH3 and SH4 +families of processors: + +.. function:: void __builtin_set_thread_pointer (void *ptr) + + Sets the :samp:`GBR` register to the specified value :samp:`{ptr}`. This is usually + used by system code that manages threads and execution contexts. The compiler + normally does not generate code that modifies the contents of :samp:`GBR` and + thus the value is preserved across function calls. Changing the :samp:`GBR` + value in user code must be done with caution, since the compiler might use + :samp:`GBR` in order to access thread local variables. + +.. function:: void * __builtin_thread_pointer (void) + + Returns the value that is currently set in the :samp:`GBR` register. + Memory loads and stores that use the thread pointer as a base address are + turned into :samp:`GBR` based displacement loads and stores, if possible. + For example: + + .. code-block:: c++ + + struct my_tcb + { + int a, b, c, d, e; + }; + + int get_tcb_value (void) + { + // Generate mov.l @(8,gbr),r0 instruction + return ((my_tcb*)__builtin_thread_pointer ())->c; + } + +.. function:: unsigned int __builtin_sh_get_fpscr (void) + + Returns the value that is currently set in the :samp:`FPSCR` register. + +.. function:: void __builtin_sh_set_fpscr (unsigned int val) + + Sets the :samp:`FPSCR` register to the specified value :samp:`{val}`, while + preserving the current values of the FR, SZ and PR bits. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/sparc-vis-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/sparc-vis-built-in-functions.rst new file mode 100644 index 00000000000..23d076a7105 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/sparc-vis-built-in-functions.rst @@ -0,0 +1,226 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _sparc-vis-built-in-functions: + +SPARC VIS Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC supports SIMD operations on the SPARC using both the generic vector +extensions (see :ref:`vector-extensions`) as well as built-in functions for +the SPARC Visual Instruction Set (VIS). When you use the :option:`-mvis` +switch, the VIS extension is exposed as the following built-in functions: + +.. code-block:: c++ + + typedef int v1si __attribute__ ((vector_size (4))); + typedef int v2si __attribute__ ((vector_size (8))); + typedef short v4hi __attribute__ ((vector_size (8))); + typedef short v2hi __attribute__ ((vector_size (4))); + typedef unsigned char v8qi __attribute__ ((vector_size (8))); + typedef unsigned char v4qi __attribute__ ((vector_size (4))); + + void __builtin_vis_write_gsr (int64_t); + int64_t __builtin_vis_read_gsr (void); + + void * __builtin_vis_alignaddr (void *, long); + void * __builtin_vis_alignaddrl (void *, long); + int64_t __builtin_vis_faligndatadi (int64_t, int64_t); + v2si __builtin_vis_faligndatav2si (v2si, v2si); + v4hi __builtin_vis_faligndatav4hi (v4si, v4si); + v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi); + + v4hi __builtin_vis_fexpand (v4qi); + + v4hi __builtin_vis_fmul8x16 (v4qi, v4hi); + v4hi __builtin_vis_fmul8x16au (v4qi, v2hi); + v4hi __builtin_vis_fmul8x16al (v4qi, v2hi); + v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi); + v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi); + v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi); + v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi); + + v4qi __builtin_vis_fpack16 (v4hi); + v8qi __builtin_vis_fpack32 (v2si, v8qi); + v2hi __builtin_vis_fpackfix (v2si); + v8qi __builtin_vis_fpmerge (v4qi, v4qi); + + int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t); + + long __builtin_vis_edge8 (void *, void *); + long __builtin_vis_edge8l (void *, void *); + long __builtin_vis_edge16 (void *, void *); + long __builtin_vis_edge16l (void *, void *); + long __builtin_vis_edge32 (void *, void *); + long __builtin_vis_edge32l (void *, void *); + + long __builtin_vis_fcmple16 (v4hi, v4hi); + long __builtin_vis_fcmple32 (v2si, v2si); + long __builtin_vis_fcmpne16 (v4hi, v4hi); + long __builtin_vis_fcmpne32 (v2si, v2si); + long __builtin_vis_fcmpgt16 (v4hi, v4hi); + long __builtin_vis_fcmpgt32 (v2si, v2si); + long __builtin_vis_fcmpeq16 (v4hi, v4hi); + long __builtin_vis_fcmpeq32 (v2si, v2si); + + v4hi __builtin_vis_fpadd16 (v4hi, v4hi); + v2hi __builtin_vis_fpadd16s (v2hi, v2hi); + v2si __builtin_vis_fpadd32 (v2si, v2si); + v1si __builtin_vis_fpadd32s (v1si, v1si); + v4hi __builtin_vis_fpsub16 (v4hi, v4hi); + v2hi __builtin_vis_fpsub16s (v2hi, v2hi); + v2si __builtin_vis_fpsub32 (v2si, v2si); + v1si __builtin_vis_fpsub32s (v1si, v1si); + + long __builtin_vis_array8 (long, long); + long __builtin_vis_array16 (long, long); + long __builtin_vis_array32 (long, long); + +When you use the :option:`-mvis2` switch, the VIS version 2.0 built-in +functions also become available: + +.. code-block:: c++ + + long __builtin_vis_bmask (long, long); + int64_t __builtin_vis_bshuffledi (int64_t, int64_t); + v2si __builtin_vis_bshufflev2si (v2si, v2si); + v4hi __builtin_vis_bshufflev2si (v4hi, v4hi); + v8qi __builtin_vis_bshufflev2si (v8qi, v8qi); + + long __builtin_vis_edge8n (void *, void *); + long __builtin_vis_edge8ln (void *, void *); + long __builtin_vis_edge16n (void *, void *); + long __builtin_vis_edge16ln (void *, void *); + long __builtin_vis_edge32n (void *, void *); + long __builtin_vis_edge32ln (void *, void *); + +When you use the :option:`-mvis3` switch, the VIS version 3.0 built-in +functions also become available: + +.. code-block:: c++ + + void __builtin_vis_cmask8 (long); + void __builtin_vis_cmask16 (long); + void __builtin_vis_cmask32 (long); + + v4hi __builtin_vis_fchksm16 (v4hi, v4hi); + + v4hi __builtin_vis_fsll16 (v4hi, v4hi); + v4hi __builtin_vis_fslas16 (v4hi, v4hi); + v4hi __builtin_vis_fsrl16 (v4hi, v4hi); + v4hi __builtin_vis_fsra16 (v4hi, v4hi); + v2si __builtin_vis_fsll16 (v2si, v2si); + v2si __builtin_vis_fslas16 (v2si, v2si); + v2si __builtin_vis_fsrl16 (v2si, v2si); + v2si __builtin_vis_fsra16 (v2si, v2si); + + long __builtin_vis_pdistn (v8qi, v8qi); + + v4hi __builtin_vis_fmean16 (v4hi, v4hi); + + int64_t __builtin_vis_fpadd64 (int64_t, int64_t); + int64_t __builtin_vis_fpsub64 (int64_t, int64_t); + + v4hi __builtin_vis_fpadds16 (v4hi, v4hi); + v2hi __builtin_vis_fpadds16s (v2hi, v2hi); + v4hi __builtin_vis_fpsubs16 (v4hi, v4hi); + v2hi __builtin_vis_fpsubs16s (v2hi, v2hi); + v2si __builtin_vis_fpadds32 (v2si, v2si); + v1si __builtin_vis_fpadds32s (v1si, v1si); + v2si __builtin_vis_fpsubs32 (v2si, v2si); + v1si __builtin_vis_fpsubs32s (v1si, v1si); + + long __builtin_vis_fucmple8 (v8qi, v8qi); + long __builtin_vis_fucmpne8 (v8qi, v8qi); + long __builtin_vis_fucmpgt8 (v8qi, v8qi); + long __builtin_vis_fucmpeq8 (v8qi, v8qi); + + float __builtin_vis_fhadds (float, float); + double __builtin_vis_fhaddd (double, double); + float __builtin_vis_fhsubs (float, float); + double __builtin_vis_fhsubd (double, double); + float __builtin_vis_fnhadds (float, float); + double __builtin_vis_fnhaddd (double, double); + + int64_t __builtin_vis_umulxhi (int64_t, int64_t); + int64_t __builtin_vis_xmulx (int64_t, int64_t); + int64_t __builtin_vis_xmulxhi (int64_t, int64_t); + +When you use the :option:`-mvis4` switch, the VIS version 4.0 built-in +functions also become available: + +.. code-block:: c++ + + v8qi __builtin_vis_fpadd8 (v8qi, v8qi); + v8qi __builtin_vis_fpadds8 (v8qi, v8qi); + v8qi __builtin_vis_fpaddus8 (v8qi, v8qi); + v4hi __builtin_vis_fpaddus16 (v4hi, v4hi); + + v8qi __builtin_vis_fpsub8 (v8qi, v8qi); + v8qi __builtin_vis_fpsubs8 (v8qi, v8qi); + v8qi __builtin_vis_fpsubus8 (v8qi, v8qi); + v4hi __builtin_vis_fpsubus16 (v4hi, v4hi); + + long __builtin_vis_fpcmple8 (v8qi, v8qi); + long __builtin_vis_fpcmpgt8 (v8qi, v8qi); + long __builtin_vis_fpcmpule16 (v4hi, v4hi); + long __builtin_vis_fpcmpugt16 (v4hi, v4hi); + long __builtin_vis_fpcmpule32 (v2si, v2si); + long __builtin_vis_fpcmpugt32 (v2si, v2si); + + v8qi __builtin_vis_fpmax8 (v8qi, v8qi); + v4hi __builtin_vis_fpmax16 (v4hi, v4hi); + v2si __builtin_vis_fpmax32 (v2si, v2si); + + v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi); + v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi); + v2si __builtin_vis_fpmaxu32 (v2si, v2si); + + v8qi __builtin_vis_fpmin8 (v8qi, v8qi); + v4hi __builtin_vis_fpmin16 (v4hi, v4hi); + v2si __builtin_vis_fpmin32 (v2si, v2si); + + v8qi __builtin_vis_fpminu8 (v8qi, v8qi); + v4hi __builtin_vis_fpminu16 (v4hi, v4hi); + v2si __builtin_vis_fpminu32 (v2si, v2si); + +When you use the :option:`-mvis4b` switch, the VIS version 4.0B +built-in functions also become available: + +.. code-block:: c++ + + v8qi __builtin_vis_dictunpack8 (double, int); + v4hi __builtin_vis_dictunpack16 (double, int); + v2si __builtin_vis_dictunpack32 (double, int); + + long __builtin_vis_fpcmple8shl (v8qi, v8qi, int); + long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int); + long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int); + long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int); + + long __builtin_vis_fpcmple16shl (v4hi, v4hi, int); + long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int); + long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int); + long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int); + + long __builtin_vis_fpcmple32shl (v2si, v2si, int); + long __builtin_vis_fpcmpgt32shl (v2si, v2si, int); + long __builtin_vis_fpcmpeq32shl (v2si, v2si, int); + long __builtin_vis_fpcmpne32shl (v2si, v2si, int); + + long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int); + long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int); + long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int); + long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int); + long __builtin_vis_fpcmpule32shl (v2si, v2si, int); + long __builtin_vis_fpcmpugt32shl (v2si, v2si, int); + + long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int); + long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int); + long __builtin_vis_fpcmpde32shl (v2si, v2si, int); + + long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int); + long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int); + long __builtin_vis_fpcmpur32shl (v2si, v2si, int); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/ti-c6x-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/ti-c6x-built-in-functions.rst new file mode 100644 index 00000000000..b75dc8231c4 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/ti-c6x-built-in-functions.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ti-c6x-built-in-functions: + +TI C6X Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC provides intrinsics to access certain instructions of the TI C6X +processors. These intrinsics, listed below, are available after +inclusion of the ``c6x_intrinsics.h`` header file. They map directly +to C6X instructions. + +.. code-block:: c++ + + int _sadd (int, int); + int _ssub (int, int); + int _sadd2 (int, int); + int _ssub2 (int, int); + long long _mpy2 (int, int); + long long _smpy2 (int, int); + int _add4 (int, int); + int _sub4 (int, int); + int _saddu4 (int, int); + + int _smpy (int, int); + int _smpyh (int, int); + int _smpyhl (int, int); + int _smpylh (int, int); + + int _sshl (int, int); + int _subc (int, int); + + int _avg2 (int, int); + int _avgu4 (int, int); + + int _clrr (int, int); + int _extr (int, int); + int _extru (int, int); + int _abs (int); + int _abs2 (int); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-built-in-functions.rst new file mode 100644 index 00000000000..2c03e454cb7 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-built-in-functions.rst @@ -0,0 +1,1698 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _x86-built-in-functions: + +x86 Built-in Functions +^^^^^^^^^^^^^^^^^^^^^^ + +These built-in functions are available for the x86-32 and x86-64 family +of computers, depending on the command-line switches used. + +If you specify command-line switches such as :option:`-msse`, +the compiler could use the extended instruction sets even if the built-ins +are not used explicitly in the program. For this reason, applications +that perform run-time CPU detection must compile separate files for each +supported architecture, using the appropriate flags. In particular, +the file containing the CPU detection code should be compiled without +these options. + +The following machine modes are available for use with MMX built-in functions +(see :ref:`vector-extensions`): ``V2SI`` for a vector of two 32-bit integers, +``V4HI`` for a vector of four 16-bit integers, and ``V8QI`` for a +vector of eight 8-bit integers. Some of the built-in functions operate on +MMX registers as a whole 64-bit entity, these use ``V1DI`` as their mode. + +If 3DNow! extensions are enabled, ``V2SF`` is used as a mode for a vector +of two 32-bit floating-point values. + +If SSE extensions are enabled, ``V4SF`` is used for a vector of four 32-bit +floating-point values. Some instructions use a vector of four 32-bit +integers, these use ``V4SI``. Finally, some instructions operate on an +entire vector register, interpreting it as a 128-bit integer, these use mode +``TI``. + +The x86-32 and x86-64 family of processors use additional built-in +functions for efficient use of ``TF`` (``__float128``) 128-bit +floating point and ``TC`` 128-bit complex floating-point values. + +The following floating-point built-in functions are always available. All +of them implement the function that is part of the name. + +.. code-block:: c++ + + __float128 __builtin_fabsq (__float128) + __float128 __builtin_copysignq (__float128, __float128) + +The following built-in functions are always available. + +.. function:: __float128 __builtin_infq (void) + + Similar to ``__builtin_inf``, except the return type is ``__float128``. + + .. index:: __builtin_infq + +.. function:: __float128 __builtin_huge_valq (void) + + Similar to ``__builtin_huge_val``, except the return type is ``__float128``. + + .. index:: __builtin_huge_valq + +.. function:: __float128 __builtin_nanq (void) + + Similar to ``__builtin_nan``, except the return type is ``__float128``. + + .. index:: __builtin_nanq + +.. function:: __float128 __builtin_nansq (void) + + Similar to ``__builtin_nans``, except the return type is ``__float128``. + + .. index:: __builtin_nansq + + The following built-in function is always available. + +.. function:: void __builtin_ia32_pause (void) + + Generates the ``pause`` machine instruction with a compiler memory + barrier. + +The following built-in functions are always available and can be used to +check the target platform type. + +.. function:: void __builtin_cpu_init (void) + + This function runs the CPU detection code to check the type of CPU and the + features supported. This built-in function needs to be invoked along with the built-in functions + to check CPU type and features, ``__builtin_cpu_is`` and + ``__builtin_cpu_supports``, only when used in a function that is + executed before any constructors are called. The CPU detection code is + automatically executed in a very high priority constructor. + + For example, this function has to be used in ``ifunc`` resolvers that + check for CPU type using the built-in functions ``__builtin_cpu_is`` + and ``__builtin_cpu_supports``, or in constructors on targets that + don't support constructor priority. + + .. code-block:: c++ + + static void (*resolve_memcpy (void)) (void) + { + // ifunc resolvers fire before constructors, explicitly call the init + // function. + __builtin_cpu_init (); + if (__builtin_cpu_supports ("ssse3")) + return ssse3_memcpy; // super fast memcpy with ssse3 instructions. + else + return default_memcpy; + } + + void *memcpy (void *, const void *, size_t) + __attribute__ ((ifunc ("resolve_memcpy"))); + +.. function:: int __builtin_cpu_is (const char *cpuname) + + This function returns a positive integer if the run-time CPU + is of type :samp:`{cpuname}` + and returns ``0`` otherwise. The following CPU names can be detected: + + :samp:`amd` + AMD CPU. + + :samp:`intel` + Intel CPU. + + :samp:`atom` + Intel Atom CPU. + + :samp:`slm` + Intel Silvermont CPU. + + :samp:`core2` + Intel Core 2 CPU. + + :samp:`corei7` + Intel Core i7 CPU. + + :samp:`nehalem` + Intel Core i7 Nehalem CPU. + + :samp:`westmere` + Intel Core i7 Westmere CPU. + + :samp:`sandybridge` + Intel Core i7 Sandy Bridge CPU. + + :samp:`ivybridge` + Intel Core i7 Ivy Bridge CPU. + + :samp:`haswell` + Intel Core i7 Haswell CPU. + + :samp:`broadwell` + Intel Core i7 Broadwell CPU. + + :samp:`skylake` + Intel Core i7 Skylake CPU. + + :samp:`skylake-avx512` + Intel Core i7 Skylake AVX512 CPU. + + :samp:`cannonlake` + Intel Core i7 Cannon Lake CPU. + + :samp:`icelake-client` + Intel Core i7 Ice Lake Client CPU. + + :samp:`icelake-server` + Intel Core i7 Ice Lake Server CPU. + + :samp:`cascadelake` + Intel Core i7 Cascadelake CPU. + + :samp:`tigerlake` + Intel Core i7 Tigerlake CPU. + + :samp:`cooperlake` + Intel Core i7 Cooperlake CPU. + + :samp:`sapphirerapids` + Intel Core i7 sapphirerapids CPU. + + :samp:`alderlake` + Intel Core i7 Alderlake CPU. + + :samp:`rocketlake` + Intel Core i7 Rocketlake CPU. + + :samp:`graniterapids` + Intel Core i7 graniterapids CPU. + + :samp:`bonnell` + Intel Atom Bonnell CPU. + + :samp:`silvermont` + Intel Atom Silvermont CPU. + + :samp:`goldmont` + Intel Atom Goldmont CPU. + + :samp:`goldmont-plus` + Intel Atom Goldmont Plus CPU. + + :samp:`tremont` + Intel Atom Tremont CPU. + + :samp:`sierraforest` + Intel Atom Sierra Forest CPU. + + :samp:`grandridge` + Intel Atom Grand Ridge CPU. + + :samp:`knl` + Intel Knights Landing CPU. + + :samp:`knm` + Intel Knights Mill CPU. + + :samp:`lujiazui` + ZHAOXIN lujiazui CPU. + + :samp:`amdfam10h` + AMD Family 10h CPU. + + :samp:`barcelona` + AMD Family 10h Barcelona CPU. + + :samp:`shanghai` + AMD Family 10h Shanghai CPU. + + :samp:`istanbul` + AMD Family 10h Istanbul CPU. + + :samp:`btver1` + AMD Family 14h CPU. + + :samp:`amdfam15h` + AMD Family 15h CPU. + + :samp:`bdver1` + AMD Family 15h Bulldozer version 1. + + :samp:`bdver2` + AMD Family 15h Bulldozer version 2. + + :samp:`bdver3` + AMD Family 15h Bulldozer version 3. + + :samp:`bdver4` + AMD Family 15h Bulldozer version 4. + + :samp:`btver2` + AMD Family 16h CPU. + + :samp:`amdfam17h` + AMD Family 17h CPU. + + :samp:`znver1` + AMD Family 17h Zen version 1. + + :samp:`znver2` + AMD Family 17h Zen version 2. + + :samp:`amdfam19h` + AMD Family 19h CPU. + + :samp:`znver3` + AMD Family 19h Zen version 3. + + :samp:`znver4` + AMD Family 19h Zen version 4. + + :samp:`x86-64` + Baseline x86-64 microarchitecture level (as defined in x86-64 psABI). + + :samp:`x86-64-v2` + x86-64-v2 microarchitecture level. + + :samp:`x86-64-v3` + x86-64-v3 microarchitecture level. + + :samp:`x86-64-v4` + x86-64-v4 microarchitecture level. + + Here is an example: + + .. code-block:: c++ + + if (__builtin_cpu_is ("corei7")) + { + do_corei7 (); // Core i7 specific implementation. + } + else + { + do_generic (); // Generic implementation. + } + +.. function:: int __builtin_cpu_supports (const char *feature) + + This function returns a positive integer if the run-time CPU + supports :samp:`{feature}` + and returns ``0`` otherwise. The following features can be detected: + + :samp:`cmov` + CMOV instruction. + + :samp:`mmx` + MMX instructions. + + :samp:`popcnt` + POPCNT instruction. + + :samp:`sse` + SSE instructions. + + :samp:`sse2` + SSE2 instructions. + + :samp:`sse3` + SSE3 instructions. + + :samp:`ssse3` + SSSE3 instructions. + + :samp:`sse4.1` + SSE4.1 instructions. + + :samp:`sse4.2` + SSE4.2 instructions. + + :samp:`avx` + AVX instructions. + + :samp:`avx2` + AVX2 instructions. + + :samp:`sse4a` + SSE4A instructions. + + :samp:`fma4` + FMA4 instructions. + + :samp:`xop` + XOP instructions. + + :samp:`fma` + FMA instructions. + + :samp:`avx512f` + AVX512F instructions. + + :samp:`bmi` + BMI instructions. + + :samp:`bmi2` + BMI2 instructions. + + :samp:`aes` + AES instructions. + + :samp:`pclmul` + PCLMUL instructions. + + :samp:`avx512vl` + AVX512VL instructions. + + :samp:`avx512bw` + AVX512BW instructions. + + :samp:`avx512dq` + AVX512DQ instructions. + + :samp:`avx512cd` + AVX512CD instructions. + + :samp:`avx512er` + AVX512ER instructions. + + :samp:`avx512pf` + AVX512PF instructions. + + :samp:`avx512vbmi` + AVX512VBMI instructions. + + :samp:`avx512ifma` + AVX512IFMA instructions. + + :samp:`avx5124vnniw` + AVX5124VNNIW instructions. + + :samp:`avx5124fmaps` + AVX5124FMAPS instructions. + + :samp:`avx512vpopcntdq` + AVX512VPOPCNTDQ instructions. + + :samp:`avx512vbmi2` + AVX512VBMI2 instructions. + + :samp:`gfni` + GFNI instructions. + + :samp:`vpclmulqdq` + VPCLMULQDQ instructions. + + :samp:`avx512vnni` + AVX512VNNI instructions. + + :samp:`avx512bitalg` + AVX512BITALG instructions. + + Here is an example: + + .. code-block:: c++ + + if (__builtin_cpu_supports ("popcnt")) + { + asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc"); + } + else + { + count = generic_countbits (n); //generic implementation. + } + +The following built-in functions are made available by :option:`-mmmx`. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + v8qi __builtin_ia32_paddb (v8qi, v8qi); + v4hi __builtin_ia32_paddw (v4hi, v4hi); + v2si __builtin_ia32_paddd (v2si, v2si); + v8qi __builtin_ia32_psubb (v8qi, v8qi); + v4hi __builtin_ia32_psubw (v4hi, v4hi); + v2si __builtin_ia32_psubd (v2si, v2si); + v8qi __builtin_ia32_paddsb (v8qi, v8qi); + v4hi __builtin_ia32_paddsw (v4hi, v4hi); + v8qi __builtin_ia32_psubsb (v8qi, v8qi); + v4hi __builtin_ia32_psubsw (v4hi, v4hi); + v8qi __builtin_ia32_paddusb (v8qi, v8qi); + v4hi __builtin_ia32_paddusw (v4hi, v4hi); + v8qi __builtin_ia32_psubusb (v8qi, v8qi); + v4hi __builtin_ia32_psubusw (v4hi, v4hi); + v4hi __builtin_ia32_pmullw (v4hi, v4hi); + v4hi __builtin_ia32_pmulhw (v4hi, v4hi); + di __builtin_ia32_pand (di, di); + di __builtin_ia32_pandn (di,di); + di __builtin_ia32_por (di, di); + di __builtin_ia32_pxor (di, di); + v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi); + v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi); + v2si __builtin_ia32_pcmpeqd (v2si, v2si); + v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi); + v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi); + v2si __builtin_ia32_pcmpgtd (v2si, v2si); + v8qi __builtin_ia32_punpckhbw (v8qi, v8qi); + v4hi __builtin_ia32_punpckhwd (v4hi, v4hi); + v2si __builtin_ia32_punpckhdq (v2si, v2si); + v8qi __builtin_ia32_punpcklbw (v8qi, v8qi); + v4hi __builtin_ia32_punpcklwd (v4hi, v4hi); + v2si __builtin_ia32_punpckldq (v2si, v2si); + v8qi __builtin_ia32_packsswb (v4hi, v4hi); + v4hi __builtin_ia32_packssdw (v2si, v2si); + v8qi __builtin_ia32_packuswb (v4hi, v4hi); + + v4hi __builtin_ia32_psllw (v4hi, v4hi); + v2si __builtin_ia32_pslld (v2si, v2si); + v1di __builtin_ia32_psllq (v1di, v1di); + v4hi __builtin_ia32_psrlw (v4hi, v4hi); + v2si __builtin_ia32_psrld (v2si, v2si); + v1di __builtin_ia32_psrlq (v1di, v1di); + v4hi __builtin_ia32_psraw (v4hi, v4hi); + v2si __builtin_ia32_psrad (v2si, v2si); + v4hi __builtin_ia32_psllwi (v4hi, int); + v2si __builtin_ia32_pslldi (v2si, int); + v1di __builtin_ia32_psllqi (v1di, int); + v4hi __builtin_ia32_psrlwi (v4hi, int); + v2si __builtin_ia32_psrldi (v2si, int); + v1di __builtin_ia32_psrlqi (v1di, int); + v4hi __builtin_ia32_psrawi (v4hi, int); + v2si __builtin_ia32_psradi (v2si, int); + +The following built-in functions are made available either with +:option:`-msse`, or with :option:`-m3dnowa`. All of them generate +the machine instruction that is part of the name. + +.. code-block:: c++ + + v4hi __builtin_ia32_pmulhuw (v4hi, v4hi); + v8qi __builtin_ia32_pavgb (v8qi, v8qi); + v4hi __builtin_ia32_pavgw (v4hi, v4hi); + v1di __builtin_ia32_psadbw (v8qi, v8qi); + v8qi __builtin_ia32_pmaxub (v8qi, v8qi); + v4hi __builtin_ia32_pmaxsw (v4hi, v4hi); + v8qi __builtin_ia32_pminub (v8qi, v8qi); + v4hi __builtin_ia32_pminsw (v4hi, v4hi); + int __builtin_ia32_pmovmskb (v8qi); + void __builtin_ia32_maskmovq (v8qi, v8qi, char *); + void __builtin_ia32_movntq (di *, di); + void __builtin_ia32_sfence (void); + +The following built-in functions are available when :option:`-msse` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + int __builtin_ia32_comieq (v4sf, v4sf); + int __builtin_ia32_comineq (v4sf, v4sf); + int __builtin_ia32_comilt (v4sf, v4sf); + int __builtin_ia32_comile (v4sf, v4sf); + int __builtin_ia32_comigt (v4sf, v4sf); + int __builtin_ia32_comige (v4sf, v4sf); + int __builtin_ia32_ucomieq (v4sf, v4sf); + int __builtin_ia32_ucomineq (v4sf, v4sf); + int __builtin_ia32_ucomilt (v4sf, v4sf); + int __builtin_ia32_ucomile (v4sf, v4sf); + int __builtin_ia32_ucomigt (v4sf, v4sf); + int __builtin_ia32_ucomige (v4sf, v4sf); + v4sf __builtin_ia32_addps (v4sf, v4sf); + v4sf __builtin_ia32_subps (v4sf, v4sf); + v4sf __builtin_ia32_mulps (v4sf, v4sf); + v4sf __builtin_ia32_divps (v4sf, v4sf); + v4sf __builtin_ia32_addss (v4sf, v4sf); + v4sf __builtin_ia32_subss (v4sf, v4sf); + v4sf __builtin_ia32_mulss (v4sf, v4sf); + v4sf __builtin_ia32_divss (v4sf, v4sf); + v4sf __builtin_ia32_cmpeqps (v4sf, v4sf); + v4sf __builtin_ia32_cmpltps (v4sf, v4sf); + v4sf __builtin_ia32_cmpleps (v4sf, v4sf); + v4sf __builtin_ia32_cmpgtps (v4sf, v4sf); + v4sf __builtin_ia32_cmpgeps (v4sf, v4sf); + v4sf __builtin_ia32_cmpunordps (v4sf, v4sf); + v4sf __builtin_ia32_cmpneqps (v4sf, v4sf); + v4sf __builtin_ia32_cmpnltps (v4sf, v4sf); + v4sf __builtin_ia32_cmpnleps (v4sf, v4sf); + v4sf __builtin_ia32_cmpngtps (v4sf, v4sf); + v4sf __builtin_ia32_cmpngeps (v4sf, v4sf); + v4sf __builtin_ia32_cmpordps (v4sf, v4sf); + v4sf __builtin_ia32_cmpeqss (v4sf, v4sf); + v4sf __builtin_ia32_cmpltss (v4sf, v4sf); + v4sf __builtin_ia32_cmpless (v4sf, v4sf); + v4sf __builtin_ia32_cmpunordss (v4sf, v4sf); + v4sf __builtin_ia32_cmpneqss (v4sf, v4sf); + v4sf __builtin_ia32_cmpnltss (v4sf, v4sf); + v4sf __builtin_ia32_cmpnless (v4sf, v4sf); + v4sf __builtin_ia32_cmpordss (v4sf, v4sf); + v4sf __builtin_ia32_maxps (v4sf, v4sf); + v4sf __builtin_ia32_maxss (v4sf, v4sf); + v4sf __builtin_ia32_minps (v4sf, v4sf); + v4sf __builtin_ia32_minss (v4sf, v4sf); + v4sf __builtin_ia32_andps (v4sf, v4sf); + v4sf __builtin_ia32_andnps (v4sf, v4sf); + v4sf __builtin_ia32_orps (v4sf, v4sf); + v4sf __builtin_ia32_xorps (v4sf, v4sf); + v4sf __builtin_ia32_movss (v4sf, v4sf); + v4sf __builtin_ia32_movhlps (v4sf, v4sf); + v4sf __builtin_ia32_movlhps (v4sf, v4sf); + v4sf __builtin_ia32_unpckhps (v4sf, v4sf); + v4sf __builtin_ia32_unpcklps (v4sf, v4sf); + v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si); + v4sf __builtin_ia32_cvtsi2ss (v4sf, int); + v2si __builtin_ia32_cvtps2pi (v4sf); + int __builtin_ia32_cvtss2si (v4sf); + v2si __builtin_ia32_cvttps2pi (v4sf); + int __builtin_ia32_cvttss2si (v4sf); + v4sf __builtin_ia32_rcpps (v4sf); + v4sf __builtin_ia32_rsqrtps (v4sf); + v4sf __builtin_ia32_sqrtps (v4sf); + v4sf __builtin_ia32_rcpss (v4sf); + v4sf __builtin_ia32_rsqrtss (v4sf); + v4sf __builtin_ia32_sqrtss (v4sf); + v4sf __builtin_ia32_shufps (v4sf, v4sf, int); + void __builtin_ia32_movntps (float *, v4sf); + int __builtin_ia32_movmskps (v4sf); + +The following built-in functions are available when :option:`-msse` is used. + +.. function:: v4sf __builtin_ia32_loadups (float *) + + Generates the ``movups`` machine instruction as a load from memory. + +.. function:: void __builtin_ia32_storeups (float *, v4sf) + + Generates the ``movups`` machine instruction as a store to memory. + +.. function:: v4sf __builtin_ia32_loadss (float *) + + Generates the ``movss`` machine instruction as a load from memory. + +.. function:: v4sf __builtin_ia32_loadhps (v4sf, const v2sf *) + + Generates the ``movhps`` machine instruction as a load from memory. + +.. function:: v4sf __builtin_ia32_loadlps (v4sf, const v2sf *) + + Generates the ``movlps`` machine instruction as a load from memory + +.. function:: void __builtin_ia32_storehps (v2sf *, v4sf) + + Generates the ``movhps`` machine instruction as a store to memory. + +.. function:: void __builtin_ia32_storelps (v2sf *, v4sf) + + Generates the ``movlps`` machine instruction as a store to memory. + + The following built-in functions are available when :option:`-msse2` is used. + +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + int __builtin_ia32_comisdeq (v2df, v2df); + int __builtin_ia32_comisdlt (v2df, v2df); + int __builtin_ia32_comisdle (v2df, v2df); + int __builtin_ia32_comisdgt (v2df, v2df); + int __builtin_ia32_comisdge (v2df, v2df); + int __builtin_ia32_comisdneq (v2df, v2df); + int __builtin_ia32_ucomisdeq (v2df, v2df); + int __builtin_ia32_ucomisdlt (v2df, v2df); + int __builtin_ia32_ucomisdle (v2df, v2df); + int __builtin_ia32_ucomisdgt (v2df, v2df); + int __builtin_ia32_ucomisdge (v2df, v2df); + int __builtin_ia32_ucomisdneq (v2df, v2df); + v2df __builtin_ia32_cmpeqpd (v2df, v2df); + v2df __builtin_ia32_cmpltpd (v2df, v2df); + v2df __builtin_ia32_cmplepd (v2df, v2df); + v2df __builtin_ia32_cmpgtpd (v2df, v2df); + v2df __builtin_ia32_cmpgepd (v2df, v2df); + v2df __builtin_ia32_cmpunordpd (v2df, v2df); + v2df __builtin_ia32_cmpneqpd (v2df, v2df); + v2df __builtin_ia32_cmpnltpd (v2df, v2df); + v2df __builtin_ia32_cmpnlepd (v2df, v2df); + v2df __builtin_ia32_cmpngtpd (v2df, v2df); + v2df __builtin_ia32_cmpngepd (v2df, v2df); + v2df __builtin_ia32_cmpordpd (v2df, v2df); + v2df __builtin_ia32_cmpeqsd (v2df, v2df); + v2df __builtin_ia32_cmpltsd (v2df, v2df); + v2df __builtin_ia32_cmplesd (v2df, v2df); + v2df __builtin_ia32_cmpunordsd (v2df, v2df); + v2df __builtin_ia32_cmpneqsd (v2df, v2df); + v2df __builtin_ia32_cmpnltsd (v2df, v2df); + v2df __builtin_ia32_cmpnlesd (v2df, v2df); + v2df __builtin_ia32_cmpordsd (v2df, v2df); + v2di __builtin_ia32_paddq (v2di, v2di); + v2di __builtin_ia32_psubq (v2di, v2di); + v2df __builtin_ia32_addpd (v2df, v2df); + v2df __builtin_ia32_subpd (v2df, v2df); + v2df __builtin_ia32_mulpd (v2df, v2df); + v2df __builtin_ia32_divpd (v2df, v2df); + v2df __builtin_ia32_addsd (v2df, v2df); + v2df __builtin_ia32_subsd (v2df, v2df); + v2df __builtin_ia32_mulsd (v2df, v2df); + v2df __builtin_ia32_divsd (v2df, v2df); + v2df __builtin_ia32_minpd (v2df, v2df); + v2df __builtin_ia32_maxpd (v2df, v2df); + v2df __builtin_ia32_minsd (v2df, v2df); + v2df __builtin_ia32_maxsd (v2df, v2df); + v2df __builtin_ia32_andpd (v2df, v2df); + v2df __builtin_ia32_andnpd (v2df, v2df); + v2df __builtin_ia32_orpd (v2df, v2df); + v2df __builtin_ia32_xorpd (v2df, v2df); + v2df __builtin_ia32_movsd (v2df, v2df); + v2df __builtin_ia32_unpckhpd (v2df, v2df); + v2df __builtin_ia32_unpcklpd (v2df, v2df); + v16qi __builtin_ia32_paddb128 (v16qi, v16qi); + v8hi __builtin_ia32_paddw128 (v8hi, v8hi); + v4si __builtin_ia32_paddd128 (v4si, v4si); + v2di __builtin_ia32_paddq128 (v2di, v2di); + v16qi __builtin_ia32_psubb128 (v16qi, v16qi); + v8hi __builtin_ia32_psubw128 (v8hi, v8hi); + v4si __builtin_ia32_psubd128 (v4si, v4si); + v2di __builtin_ia32_psubq128 (v2di, v2di); + v8hi __builtin_ia32_pmullw128 (v8hi, v8hi); + v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi); + v2di __builtin_ia32_pand128 (v2di, v2di); + v2di __builtin_ia32_pandn128 (v2di, v2di); + v2di __builtin_ia32_por128 (v2di, v2di); + v2di __builtin_ia32_pxor128 (v2di, v2di); + v16qi __builtin_ia32_pavgb128 (v16qi, v16qi); + v8hi __builtin_ia32_pavgw128 (v8hi, v8hi); + v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi); + v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi); + v4si __builtin_ia32_pcmpeqd128 (v4si, v4si); + v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi); + v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi); + v4si __builtin_ia32_pcmpgtd128 (v4si, v4si); + v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi); + v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi); + v16qi __builtin_ia32_pminub128 (v16qi, v16qi); + v8hi __builtin_ia32_pminsw128 (v8hi, v8hi); + v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi); + v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi); + v4si __builtin_ia32_punpckhdq128 (v4si, v4si); + v2di __builtin_ia32_punpckhqdq128 (v2di, v2di); + v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi); + v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi); + v4si __builtin_ia32_punpckldq128 (v4si, v4si); + v2di __builtin_ia32_punpcklqdq128 (v2di, v2di); + v16qi __builtin_ia32_packsswb128 (v8hi, v8hi); + v8hi __builtin_ia32_packssdw128 (v4si, v4si); + v16qi __builtin_ia32_packuswb128 (v8hi, v8hi); + v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi); + void __builtin_ia32_maskmovdqu (v16qi, v16qi); + v2df __builtin_ia32_loadupd (double *); + void __builtin_ia32_storeupd (double *, v2df); + v2df __builtin_ia32_loadhpd (v2df, double const *); + v2df __builtin_ia32_loadlpd (v2df, double const *); + int __builtin_ia32_movmskpd (v2df); + int __builtin_ia32_pmovmskb128 (v16qi); + void __builtin_ia32_movnti (int *, int); + void __builtin_ia32_movnti64 (long long int *, long long int); + void __builtin_ia32_movntpd (double *, v2df); + void __builtin_ia32_movntdq (v2df *, v2df); + v4si __builtin_ia32_pshufd (v4si, int); + v8hi __builtin_ia32_pshuflw (v8hi, int); + v8hi __builtin_ia32_pshufhw (v8hi, int); + v2di __builtin_ia32_psadbw128 (v16qi, v16qi); + v2df __builtin_ia32_sqrtpd (v2df); + v2df __builtin_ia32_sqrtsd (v2df); + v2df __builtin_ia32_shufpd (v2df, v2df, int); + v2df __builtin_ia32_cvtdq2pd (v4si); + v4sf __builtin_ia32_cvtdq2ps (v4si); + v4si __builtin_ia32_cvtpd2dq (v2df); + v2si __builtin_ia32_cvtpd2pi (v2df); + v4sf __builtin_ia32_cvtpd2ps (v2df); + v4si __builtin_ia32_cvttpd2dq (v2df); + v2si __builtin_ia32_cvttpd2pi (v2df); + v2df __builtin_ia32_cvtpi2pd (v2si); + int __builtin_ia32_cvtsd2si (v2df); + int __builtin_ia32_cvttsd2si (v2df); + long long __builtin_ia32_cvtsd2si64 (v2df); + long long __builtin_ia32_cvttsd2si64 (v2df); + v4si __builtin_ia32_cvtps2dq (v4sf); + v2df __builtin_ia32_cvtps2pd (v4sf); + v4si __builtin_ia32_cvttps2dq (v4sf); + v2df __builtin_ia32_cvtsi2sd (v2df, int); + v2df __builtin_ia32_cvtsi642sd (v2df, long long); + v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df); + v2df __builtin_ia32_cvtss2sd (v2df, v4sf); + void __builtin_ia32_clflush (const void *); + void __builtin_ia32_lfence (void); + void __builtin_ia32_mfence (void); + v16qi __builtin_ia32_loaddqu (const char *); + void __builtin_ia32_storedqu (char *, v16qi); + v1di __builtin_ia32_pmuludq (v2si, v2si); + v2di __builtin_ia32_pmuludq128 (v4si, v4si); + v8hi __builtin_ia32_psllw128 (v8hi, v8hi); + v4si __builtin_ia32_pslld128 (v4si, v4si); + v2di __builtin_ia32_psllq128 (v2di, v2di); + v8hi __builtin_ia32_psrlw128 (v8hi, v8hi); + v4si __builtin_ia32_psrld128 (v4si, v4si); + v2di __builtin_ia32_psrlq128 (v2di, v2di); + v8hi __builtin_ia32_psraw128 (v8hi, v8hi); + v4si __builtin_ia32_psrad128 (v4si, v4si); + v2di __builtin_ia32_pslldqi128 (v2di, int); + v8hi __builtin_ia32_psllwi128 (v8hi, int); + v4si __builtin_ia32_pslldi128 (v4si, int); + v2di __builtin_ia32_psllqi128 (v2di, int); + v2di __builtin_ia32_psrldqi128 (v2di, int); + v8hi __builtin_ia32_psrlwi128 (v8hi, int); + v4si __builtin_ia32_psrldi128 (v4si, int); + v2di __builtin_ia32_psrlqi128 (v2di, int); + v8hi __builtin_ia32_psrawi128 (v8hi, int); + v4si __builtin_ia32_psradi128 (v4si, int); + v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi); + v2di __builtin_ia32_movq128 (v2di); + +The following built-in functions are available when :option:`-msse3` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + v2df __builtin_ia32_addsubpd (v2df, v2df); + v4sf __builtin_ia32_addsubps (v4sf, v4sf); + v2df __builtin_ia32_haddpd (v2df, v2df); + v4sf __builtin_ia32_haddps (v4sf, v4sf); + v2df __builtin_ia32_hsubpd (v2df, v2df); + v4sf __builtin_ia32_hsubps (v4sf, v4sf); + v16qi __builtin_ia32_lddqu (char const *); + void __builtin_ia32_monitor (void *, unsigned int, unsigned int); + v4sf __builtin_ia32_movshdup (v4sf); + v4sf __builtin_ia32_movsldup (v4sf); + void __builtin_ia32_mwait (unsigned int, unsigned int); + +The following built-in functions are available when :option:`-mssse3` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + v2si __builtin_ia32_phaddd (v2si, v2si); + v4hi __builtin_ia32_phaddw (v4hi, v4hi); + v4hi __builtin_ia32_phaddsw (v4hi, v4hi); + v2si __builtin_ia32_phsubd (v2si, v2si); + v4hi __builtin_ia32_phsubw (v4hi, v4hi); + v4hi __builtin_ia32_phsubsw (v4hi, v4hi); + v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi); + v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi); + v8qi __builtin_ia32_pshufb (v8qi, v8qi); + v8qi __builtin_ia32_psignb (v8qi, v8qi); + v2si __builtin_ia32_psignd (v2si, v2si); + v4hi __builtin_ia32_psignw (v4hi, v4hi); + v1di __builtin_ia32_palignr (v1di, v1di, int); + v8qi __builtin_ia32_pabsb (v8qi); + v2si __builtin_ia32_pabsd (v2si); + v4hi __builtin_ia32_pabsw (v4hi); + +The following built-in functions are available when :option:`-mssse3` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + v4si __builtin_ia32_phaddd128 (v4si, v4si); + v8hi __builtin_ia32_phaddw128 (v8hi, v8hi); + v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi); + v4si __builtin_ia32_phsubd128 (v4si, v4si); + v8hi __builtin_ia32_phsubw128 (v8hi, v8hi); + v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi); + v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi); + v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi); + v16qi __builtin_ia32_pshufb128 (v16qi, v16qi); + v16qi __builtin_ia32_psignb128 (v16qi, v16qi); + v4si __builtin_ia32_psignd128 (v4si, v4si); + v8hi __builtin_ia32_psignw128 (v8hi, v8hi); + v2di __builtin_ia32_palignr128 (v2di, v2di, int); + v16qi __builtin_ia32_pabsb128 (v16qi); + v4si __builtin_ia32_pabsd128 (v4si); + v8hi __builtin_ia32_pabsw128 (v8hi); + +The following built-in functions are available when :option:`-msse4.1` is +used. All of them generate the machine instruction that is part of the +name. + +.. code-block:: c++ + + v2df __builtin_ia32_blendpd (v2df, v2df, const int); + v4sf __builtin_ia32_blendps (v4sf, v4sf, const int); + v2df __builtin_ia32_blendvpd (v2df, v2df, v2df); + v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf); + v2df __builtin_ia32_dppd (v2df, v2df, const int); + v4sf __builtin_ia32_dpps (v4sf, v4sf, const int); + v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int); + v2di __builtin_ia32_movntdqa (v2di *); + v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int); + v8hi __builtin_ia32_packusdw128 (v4si, v4si); + v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi); + v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int); + v2di __builtin_ia32_pcmpeqq (v2di, v2di); + v8hi __builtin_ia32_phminposuw128 (v8hi); + v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi); + v4si __builtin_ia32_pmaxsd128 (v4si, v4si); + v4si __builtin_ia32_pmaxud128 (v4si, v4si); + v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi); + v16qi __builtin_ia32_pminsb128 (v16qi, v16qi); + v4si __builtin_ia32_pminsd128 (v4si, v4si); + v4si __builtin_ia32_pminud128 (v4si, v4si); + v8hi __builtin_ia32_pminuw128 (v8hi, v8hi); + v4si __builtin_ia32_pmovsxbd128 (v16qi); + v2di __builtin_ia32_pmovsxbq128 (v16qi); + v8hi __builtin_ia32_pmovsxbw128 (v16qi); + v2di __builtin_ia32_pmovsxdq128 (v4si); + v4si __builtin_ia32_pmovsxwd128 (v8hi); + v2di __builtin_ia32_pmovsxwq128 (v8hi); + v4si __builtin_ia32_pmovzxbd128 (v16qi); + v2di __builtin_ia32_pmovzxbq128 (v16qi); + v8hi __builtin_ia32_pmovzxbw128 (v16qi); + v2di __builtin_ia32_pmovzxdq128 (v4si); + v4si __builtin_ia32_pmovzxwd128 (v8hi); + v2di __builtin_ia32_pmovzxwq128 (v8hi); + v2di __builtin_ia32_pmuldq128 (v4si, v4si); + v4si __builtin_ia32_pmulld128 (v4si, v4si); + int __builtin_ia32_ptestc128 (v2di, v2di); + int __builtin_ia32_ptestnzc128 (v2di, v2di); + int __builtin_ia32_ptestz128 (v2di, v2di); + v2df __builtin_ia32_roundpd (v2df, const int); + v4sf __builtin_ia32_roundps (v4sf, const int); + v2df __builtin_ia32_roundsd (v2df, v2df, const int); + v4sf __builtin_ia32_roundss (v4sf, v4sf, const int); + +The following built-in functions are available when :option:`-msse4.1` is +used. + +.. function:: v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int) + + Generates the ``insertps`` machine instruction. + +.. function:: int __builtin_ia32_vec_ext_v16qi (v16qi, const int) + + Generates the ``pextrb`` machine instruction. + +.. function:: v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int) + + Generates the ``pinsrb`` machine instruction. + +.. function:: v4si __builtin_ia32_vec_set_v4si (v4si, int, const int) + + Generates the ``pinsrd`` machine instruction. + +.. function:: v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int) + + Generates the ``pinsrq`` machine instruction in 64bit mode. + +The following built-in functions are changed to generate new SSE4.1 +instructions when :option:`-msse4.1` is used. + +.. function:: float __builtin_ia32_vec_ext_v4sf (v4sf, const int) + + Generates the ``extractps`` machine instruction. + +.. function:: int __builtin_ia32_vec_ext_v4si (v4si, const int) + + Generates the ``pextrd`` machine instruction. + +.. function:: long long __builtin_ia32_vec_ext_v2di (v2di, const int) + + Generates the ``pextrq`` machine instruction in 64bit mode. + +The following built-in functions are available when :option:`-msse4.2` is +used. All of them generate the machine instruction that is part of the +name. + +.. code-block:: c++ + + v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int); + int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int); + int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int); + int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int); + int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int); + int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int); + int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int); + v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int); + int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int); + int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int); + int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int); + int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int); + int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int); + int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int); + v2di __builtin_ia32_pcmpgtq (v2di, v2di); + +The following built-in functions are available when :option:`-msse4.2` is +used. + +.. function:: unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char) + + Generates the ``crc32b`` machine instruction. + +.. function:: unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short) + + Generates the ``crc32w`` machine instruction. + +.. function:: unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int) + + Generates the ``crc32l`` machine instruction. + +.. function:: unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long) + + Generates the ``crc32q`` machine instruction. + +The following built-in functions are changed to generate new SSE4.2 +instructions when :option:`-msse4.2` is used. + +.. function:: int __builtin_popcount (unsigned int) + + Generates the ``popcntl`` machine instruction. + +.. function:: int __builtin_popcountl (unsigned long) + + Generates the ``popcntl`` or ``popcntq`` machine instruction, + depending on the size of ``unsigned long``. + +.. function:: int __builtin_popcountll (unsigned long long) + + Generates the ``popcntq`` machine instruction. + +The following built-in functions are available when :option:`-mavx` is +used. All of them generate the machine instruction that is part of the +name. + +.. code-block:: c++ + + v4df __builtin_ia32_addpd256 (v4df,v4df); + v8sf __builtin_ia32_addps256 (v8sf,v8sf); + v4df __builtin_ia32_addsubpd256 (v4df,v4df); + v8sf __builtin_ia32_addsubps256 (v8sf,v8sf); + v4df __builtin_ia32_andnpd256 (v4df,v4df); + v8sf __builtin_ia32_andnps256 (v8sf,v8sf); + v4df __builtin_ia32_andpd256 (v4df,v4df); + v8sf __builtin_ia32_andps256 (v8sf,v8sf); + v4df __builtin_ia32_blendpd256 (v4df,v4df,int); + v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int); + v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df); + v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf); + v2df __builtin_ia32_cmppd (v2df,v2df,int); + v4df __builtin_ia32_cmppd256 (v4df,v4df,int); + v4sf __builtin_ia32_cmpps (v4sf,v4sf,int); + v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int); + v2df __builtin_ia32_cmpsd (v2df,v2df,int); + v4sf __builtin_ia32_cmpss (v4sf,v4sf,int); + v4df __builtin_ia32_cvtdq2pd256 (v4si); + v8sf __builtin_ia32_cvtdq2ps256 (v8si); + v4si __builtin_ia32_cvtpd2dq256 (v4df); + v4sf __builtin_ia32_cvtpd2ps256 (v4df); + v8si __builtin_ia32_cvtps2dq256 (v8sf); + v4df __builtin_ia32_cvtps2pd256 (v4sf); + v4si __builtin_ia32_cvttpd2dq256 (v4df); + v8si __builtin_ia32_cvttps2dq256 (v8sf); + v4df __builtin_ia32_divpd256 (v4df,v4df); + v8sf __builtin_ia32_divps256 (v8sf,v8sf); + v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int); + v4df __builtin_ia32_haddpd256 (v4df,v4df); + v8sf __builtin_ia32_haddps256 (v8sf,v8sf); + v4df __builtin_ia32_hsubpd256 (v4df,v4df); + v8sf __builtin_ia32_hsubps256 (v8sf,v8sf); + v32qi __builtin_ia32_lddqu256 (pcchar); + v32qi __builtin_ia32_loaddqu256 (pcchar); + v4df __builtin_ia32_loadupd256 (pcdouble); + v8sf __builtin_ia32_loadups256 (pcfloat); + v2df __builtin_ia32_maskloadpd (pcv2df,v2df); + v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df); + v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf); + v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf); + void __builtin_ia32_maskstorepd (pv2df,v2df,v2df); + void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df); + void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf); + void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf); + v4df __builtin_ia32_maxpd256 (v4df,v4df); + v8sf __builtin_ia32_maxps256 (v8sf,v8sf); + v4df __builtin_ia32_minpd256 (v4df,v4df); + v8sf __builtin_ia32_minps256 (v8sf,v8sf); + v4df __builtin_ia32_movddup256 (v4df); + int __builtin_ia32_movmskpd256 (v4df); + int __builtin_ia32_movmskps256 (v8sf); + v8sf __builtin_ia32_movshdup256 (v8sf); + v8sf __builtin_ia32_movsldup256 (v8sf); + v4df __builtin_ia32_mulpd256 (v4df,v4df); + v8sf __builtin_ia32_mulps256 (v8sf,v8sf); + v4df __builtin_ia32_orpd256 (v4df,v4df); + v8sf __builtin_ia32_orps256 (v8sf,v8sf); + v2df __builtin_ia32_pd_pd256 (v4df); + v4df __builtin_ia32_pd256_pd (v2df); + v4sf __builtin_ia32_ps_ps256 (v8sf); + v8sf __builtin_ia32_ps256_ps (v4sf); + int __builtin_ia32_ptestc256 (v4di,v4di,ptest); + int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest); + int __builtin_ia32_ptestz256 (v4di,v4di,ptest); + v8sf __builtin_ia32_rcpps256 (v8sf); + v4df __builtin_ia32_roundpd256 (v4df,int); + v8sf __builtin_ia32_roundps256 (v8sf,int); + v8sf __builtin_ia32_rsqrtps_nr256 (v8sf); + v8sf __builtin_ia32_rsqrtps256 (v8sf); + v4df __builtin_ia32_shufpd256 (v4df,v4df,int); + v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int); + v4si __builtin_ia32_si_si256 (v8si); + v8si __builtin_ia32_si256_si (v4si); + v4df __builtin_ia32_sqrtpd256 (v4df); + v8sf __builtin_ia32_sqrtps_nr256 (v8sf); + v8sf __builtin_ia32_sqrtps256 (v8sf); + void __builtin_ia32_storedqu256 (pchar,v32qi); + void __builtin_ia32_storeupd256 (pdouble,v4df); + void __builtin_ia32_storeups256 (pfloat,v8sf); + v4df __builtin_ia32_subpd256 (v4df,v4df); + v8sf __builtin_ia32_subps256 (v8sf,v8sf); + v4df __builtin_ia32_unpckhpd256 (v4df,v4df); + v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf); + v4df __builtin_ia32_unpcklpd256 (v4df,v4df); + v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf); + v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df); + v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf); + v4df __builtin_ia32_vbroadcastsd256 (pcdouble); + v4sf __builtin_ia32_vbroadcastss (pcfloat); + v8sf __builtin_ia32_vbroadcastss256 (pcfloat); + v2df __builtin_ia32_vextractf128_pd256 (v4df,int); + v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int); + v4si __builtin_ia32_vextractf128_si256 (v8si,int); + v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int); + v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int); + v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int); + v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int); + v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int); + v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int); + v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int); + v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int); + v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int); + v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int); + v2df __builtin_ia32_vpermilpd (v2df,int); + v4df __builtin_ia32_vpermilpd256 (v4df,int); + v4sf __builtin_ia32_vpermilps (v4sf,int); + v8sf __builtin_ia32_vpermilps256 (v8sf,int); + v2df __builtin_ia32_vpermilvarpd (v2df,v2di); + v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di); + v4sf __builtin_ia32_vpermilvarps (v4sf,v4si); + v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si); + int __builtin_ia32_vtestcpd (v2df,v2df,ptest); + int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest); + int __builtin_ia32_vtestcps (v4sf,v4sf,ptest); + int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest); + int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest); + int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest); + int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest); + int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest); + int __builtin_ia32_vtestzpd (v2df,v2df,ptest); + int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest); + int __builtin_ia32_vtestzps (v4sf,v4sf,ptest); + int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest); + void __builtin_ia32_vzeroall (void); + void __builtin_ia32_vzeroupper (void); + v4df __builtin_ia32_xorpd256 (v4df,v4df); + v8sf __builtin_ia32_xorps256 (v8sf,v8sf); + +The following built-in functions are available when :option:`-mavx2` is +used. All of them generate the machine instruction that is part of the +name. + +.. code-block:: c++ + + v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int); + v32qi __builtin_ia32_pabsb256 (v32qi); + v16hi __builtin_ia32_pabsw256 (v16hi); + v8si __builtin_ia32_pabsd256 (v8si); + v16hi __builtin_ia32_packssdw256 (v8si,v8si); + v32qi __builtin_ia32_packsswb256 (v16hi,v16hi); + v16hi __builtin_ia32_packusdw256 (v8si,v8si); + v32qi __builtin_ia32_packuswb256 (v16hi,v16hi); + v32qi __builtin_ia32_paddb256 (v32qi,v32qi); + v16hi __builtin_ia32_paddw256 (v16hi,v16hi); + v8si __builtin_ia32_paddd256 (v8si,v8si); + v4di __builtin_ia32_paddq256 (v4di,v4di); + v32qi __builtin_ia32_paddsb256 (v32qi,v32qi); + v16hi __builtin_ia32_paddsw256 (v16hi,v16hi); + v32qi __builtin_ia32_paddusb256 (v32qi,v32qi); + v16hi __builtin_ia32_paddusw256 (v16hi,v16hi); + v4di __builtin_ia32_palignr256 (v4di,v4di,int); + v4di __builtin_ia32_andsi256 (v4di,v4di); + v4di __builtin_ia32_andnotsi256 (v4di,v4di); + v32qi __builtin_ia32_pavgb256 (v32qi,v32qi); + v16hi __builtin_ia32_pavgw256 (v16hi,v16hi); + v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi); + v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int); + v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi); + v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi); + v8si __builtin_ia32_pcmpeqd256 (c8si,v8si); + v4di __builtin_ia32_pcmpeqq256 (v4di,v4di); + v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi); + v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi); + v8si __builtin_ia32_pcmpgtd256 (v8si,v8si); + v4di __builtin_ia32_pcmpgtq256 (v4di,v4di); + v16hi __builtin_ia32_phaddw256 (v16hi,v16hi); + v8si __builtin_ia32_phaddd256 (v8si,v8si); + v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi); + v16hi __builtin_ia32_phsubw256 (v16hi,v16hi); + v8si __builtin_ia32_phsubd256 (v8si,v8si); + v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi); + v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi); + v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi); + v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi); + v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi); + v8si __builtin_ia32_pmaxsd256 (v8si,v8si); + v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi); + v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi); + v8si __builtin_ia32_pmaxud256 (v8si,v8si); + v32qi __builtin_ia32_pminsb256 (v32qi,v32qi); + v16hi __builtin_ia32_pminsw256 (v16hi,v16hi); + v8si __builtin_ia32_pminsd256 (v8si,v8si); + v32qi __builtin_ia32_pminub256 (v32qi,v32qi); + v16hi __builtin_ia32_pminuw256 (v16hi,v16hi); + v8si __builtin_ia32_pminud256 (v8si,v8si); + int __builtin_ia32_pmovmskb256 (v32qi); + v16hi __builtin_ia32_pmovsxbw256 (v16qi); + v8si __builtin_ia32_pmovsxbd256 (v16qi); + v4di __builtin_ia32_pmovsxbq256 (v16qi); + v8si __builtin_ia32_pmovsxwd256 (v8hi); + v4di __builtin_ia32_pmovsxwq256 (v8hi); + v4di __builtin_ia32_pmovsxdq256 (v4si); + v16hi __builtin_ia32_pmovzxbw256 (v16qi); + v8si __builtin_ia32_pmovzxbd256 (v16qi); + v4di __builtin_ia32_pmovzxbq256 (v16qi); + v8si __builtin_ia32_pmovzxwd256 (v8hi); + v4di __builtin_ia32_pmovzxwq256 (v8hi); + v4di __builtin_ia32_pmovzxdq256 (v4si); + v4di __builtin_ia32_pmuldq256 (v8si,v8si); + v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi); + v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi); + v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi); + v16hi __builtin_ia32_pmullw256 (v16hi,v16hi); + v8si __builtin_ia32_pmulld256 (v8si,v8si); + v4di __builtin_ia32_pmuludq256 (v8si,v8si); + v4di __builtin_ia32_por256 (v4di,v4di); + v16hi __builtin_ia32_psadbw256 (v32qi,v32qi); + v32qi __builtin_ia32_pshufb256 (v32qi,v32qi); + v8si __builtin_ia32_pshufd256 (v8si,int); + v16hi __builtin_ia32_pshufhw256 (v16hi,int); + v16hi __builtin_ia32_pshuflw256 (v16hi,int); + v32qi __builtin_ia32_psignb256 (v32qi,v32qi); + v16hi __builtin_ia32_psignw256 (v16hi,v16hi); + v8si __builtin_ia32_psignd256 (v8si,v8si); + v4di __builtin_ia32_pslldqi256 (v4di,int); + v16hi __builtin_ia32_psllwi256 (16hi,int); + v16hi __builtin_ia32_psllw256(v16hi,v8hi); + v8si __builtin_ia32_pslldi256 (v8si,int); + v8si __builtin_ia32_pslld256(v8si,v4si); + v4di __builtin_ia32_psllqi256 (v4di,int); + v4di __builtin_ia32_psllq256(v4di,v2di); + v16hi __builtin_ia32_psrawi256 (v16hi,int); + v16hi __builtin_ia32_psraw256 (v16hi,v8hi); + v8si __builtin_ia32_psradi256 (v8si,int); + v8si __builtin_ia32_psrad256 (v8si,v4si); + v4di __builtin_ia32_psrldqi256 (v4di, int); + v16hi __builtin_ia32_psrlwi256 (v16hi,int); + v16hi __builtin_ia32_psrlw256 (v16hi,v8hi); + v8si __builtin_ia32_psrldi256 (v8si,int); + v8si __builtin_ia32_psrld256 (v8si,v4si); + v4di __builtin_ia32_psrlqi256 (v4di,int); + v4di __builtin_ia32_psrlq256(v4di,v2di); + v32qi __builtin_ia32_psubb256 (v32qi,v32qi); + v32hi __builtin_ia32_psubw256 (v16hi,v16hi); + v8si __builtin_ia32_psubd256 (v8si,v8si); + v4di __builtin_ia32_psubq256 (v4di,v4di); + v32qi __builtin_ia32_psubsb256 (v32qi,v32qi); + v16hi __builtin_ia32_psubsw256 (v16hi,v16hi); + v32qi __builtin_ia32_psubusb256 (v32qi,v32qi); + v16hi __builtin_ia32_psubusw256 (v16hi,v16hi); + v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi); + v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi); + v8si __builtin_ia32_punpckhdq256 (v8si,v8si); + v4di __builtin_ia32_punpckhqdq256 (v4di,v4di); + v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi); + v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi); + v8si __builtin_ia32_punpckldq256 (v8si,v8si); + v4di __builtin_ia32_punpcklqdq256 (v4di,v4di); + v4di __builtin_ia32_pxor256 (v4di,v4di); + v4di __builtin_ia32_movntdqa256 (pv4di); + v4sf __builtin_ia32_vbroadcastss_ps (v4sf); + v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf); + v4df __builtin_ia32_vbroadcastsd_pd256 (v2df); + v4di __builtin_ia32_vbroadcastsi256 (v2di); + v4si __builtin_ia32_pblendd128 (v4si,v4si); + v8si __builtin_ia32_pblendd256 (v8si,v8si); + v32qi __builtin_ia32_pbroadcastb256 (v16qi); + v16hi __builtin_ia32_pbroadcastw256 (v8hi); + v8si __builtin_ia32_pbroadcastd256 (v4si); + v4di __builtin_ia32_pbroadcastq256 (v2di); + v16qi __builtin_ia32_pbroadcastb128 (v16qi); + v8hi __builtin_ia32_pbroadcastw128 (v8hi); + v4si __builtin_ia32_pbroadcastd128 (v4si); + v2di __builtin_ia32_pbroadcastq128 (v2di); + v8si __builtin_ia32_permvarsi256 (v8si,v8si); + v4df __builtin_ia32_permdf256 (v4df,int); + v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf); + v4di __builtin_ia32_permdi256 (v4di,int); + v4di __builtin_ia32_permti256 (v4di,v4di,int); + v4di __builtin_ia32_extract128i256 (v4di,int); + v4di __builtin_ia32_insert128i256 (v4di,v2di,int); + v8si __builtin_ia32_maskloadd256 (pcv8si,v8si); + v4di __builtin_ia32_maskloadq256 (pcv4di,v4di); + v4si __builtin_ia32_maskloadd (pcv4si,v4si); + v2di __builtin_ia32_maskloadq (pcv2di,v2di); + void __builtin_ia32_maskstored256 (pv8si,v8si,v8si); + void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di); + void __builtin_ia32_maskstored (pv4si,v4si,v4si); + void __builtin_ia32_maskstoreq (pv2di,v2di,v2di); + v8si __builtin_ia32_psllv8si (v8si,v8si); + v4si __builtin_ia32_psllv4si (v4si,v4si); + v4di __builtin_ia32_psllv4di (v4di,v4di); + v2di __builtin_ia32_psllv2di (v2di,v2di); + v8si __builtin_ia32_psrav8si (v8si,v8si); + v4si __builtin_ia32_psrav4si (v4si,v4si); + v8si __builtin_ia32_psrlv8si (v8si,v8si); + v4si __builtin_ia32_psrlv4si (v4si,v4si); + v4di __builtin_ia32_psrlv4di (v4di,v4di); + v2di __builtin_ia32_psrlv2di (v2di,v2di); + v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int); + v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int); + v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int); + v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int); + v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int); + v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int); + v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int); + v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int); + v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int); + v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int); + v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int); + v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int); + v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int); + v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int); + v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int); + v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int); + +The following built-in functions are available when :option:`-maes` is +used. All of them generate the machine instruction that is part of the +name. + +.. code-block:: c++ + + v2di __builtin_ia32_aesenc128 (v2di, v2di); + v2di __builtin_ia32_aesenclast128 (v2di, v2di); + v2di __builtin_ia32_aesdec128 (v2di, v2di); + v2di __builtin_ia32_aesdeclast128 (v2di, v2di); + v2di __builtin_ia32_aeskeygenassist128 (v2di, const int); + v2di __builtin_ia32_aesimc128 (v2di); + +The following built-in function is available when :option:`-mpclmul` is +used. + +.. function:: v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int) + + Generates the ``pclmulqdq`` machine instruction. + +The following built-in function is available when :option:`-mfsgsbase` is +used. All of them generate the machine instruction that is part of the +name. + +.. code-block:: c++ + + unsigned int __builtin_ia32_rdfsbase32 (void); + unsigned long long __builtin_ia32_rdfsbase64 (void); + unsigned int __builtin_ia32_rdgsbase32 (void); + unsigned long long __builtin_ia32_rdgsbase64 (void); + void _writefsbase_u32 (unsigned int); + void _writefsbase_u64 (unsigned long long); + void _writegsbase_u32 (unsigned int); + void _writegsbase_u64 (unsigned long long); + +The following built-in function is available when :option:`-mrdrnd` is +used. All of them generate the machine instruction that is part of the +name. + +.. code-block:: c++ + + unsigned int __builtin_ia32_rdrand16_step (unsigned short *); + unsigned int __builtin_ia32_rdrand32_step (unsigned int *); + unsigned int __builtin_ia32_rdrand64_step (unsigned long long *); + +The following built-in function is available when :option:`-mptwrite` is +used. All of them generate the machine instruction that is part of the +name. + +.. code-block:: c++ + + void __builtin_ia32_ptwrite32 (unsigned); + void __builtin_ia32_ptwrite64 (unsigned long long); + +The following built-in functions are available when :option:`-msse4a` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + void __builtin_ia32_movntsd (double *, v2df); + void __builtin_ia32_movntss (float *, v4sf); + v2di __builtin_ia32_extrq (v2di, v16qi); + v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int); + v2di __builtin_ia32_insertq (v2di, v2di); + v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int); + +The following built-in functions are available when :option:`-mxop` is used. + +.. code-block:: c++ + + v2df __builtin_ia32_vfrczpd (v2df); + v4sf __builtin_ia32_vfrczps (v4sf); + v2df __builtin_ia32_vfrczsd (v2df); + v4sf __builtin_ia32_vfrczss (v4sf); + v4df __builtin_ia32_vfrczpd256 (v4df); + v8sf __builtin_ia32_vfrczps256 (v8sf); + v2di __builtin_ia32_vpcmov (v2di, v2di, v2di); + v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di); + v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si); + v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi); + v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi); + v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df); + v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf); + v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di); + v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si); + v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi); + v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi); + v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df); + v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf); + v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi); + v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi); + v4si __builtin_ia32_vpcomeqd (v4si, v4si); + v2di __builtin_ia32_vpcomeqq (v2di, v2di); + v16qi __builtin_ia32_vpcomequb (v16qi, v16qi); + v4si __builtin_ia32_vpcomequd (v4si, v4si); + v2di __builtin_ia32_vpcomequq (v2di, v2di); + v8hi __builtin_ia32_vpcomequw (v8hi, v8hi); + v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi); + v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi); + v4si __builtin_ia32_vpcomfalsed (v4si, v4si); + v2di __builtin_ia32_vpcomfalseq (v2di, v2di); + v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi); + v4si __builtin_ia32_vpcomfalseud (v4si, v4si); + v2di __builtin_ia32_vpcomfalseuq (v2di, v2di); + v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi); + v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi); + v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi); + v4si __builtin_ia32_vpcomged (v4si, v4si); + v2di __builtin_ia32_vpcomgeq (v2di, v2di); + v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi); + v4si __builtin_ia32_vpcomgeud (v4si, v4si); + v2di __builtin_ia32_vpcomgeuq (v2di, v2di); + v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi); + v8hi __builtin_ia32_vpcomgew (v8hi, v8hi); + v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi); + v4si __builtin_ia32_vpcomgtd (v4si, v4si); + v2di __builtin_ia32_vpcomgtq (v2di, v2di); + v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi); + v4si __builtin_ia32_vpcomgtud (v4si, v4si); + v2di __builtin_ia32_vpcomgtuq (v2di, v2di); + v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi); + v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi); + v16qi __builtin_ia32_vpcomleb (v16qi, v16qi); + v4si __builtin_ia32_vpcomled (v4si, v4si); + v2di __builtin_ia32_vpcomleq (v2di, v2di); + v16qi __builtin_ia32_vpcomleub (v16qi, v16qi); + v4si __builtin_ia32_vpcomleud (v4si, v4si); + v2di __builtin_ia32_vpcomleuq (v2di, v2di); + v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi); + v8hi __builtin_ia32_vpcomlew (v8hi, v8hi); + v16qi __builtin_ia32_vpcomltb (v16qi, v16qi); + v4si __builtin_ia32_vpcomltd (v4si, v4si); + v2di __builtin_ia32_vpcomltq (v2di, v2di); + v16qi __builtin_ia32_vpcomltub (v16qi, v16qi); + v4si __builtin_ia32_vpcomltud (v4si, v4si); + v2di __builtin_ia32_vpcomltuq (v2di, v2di); + v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi); + v8hi __builtin_ia32_vpcomltw (v8hi, v8hi); + v16qi __builtin_ia32_vpcomneb (v16qi, v16qi); + v4si __builtin_ia32_vpcomned (v4si, v4si); + v2di __builtin_ia32_vpcomneq (v2di, v2di); + v16qi __builtin_ia32_vpcomneub (v16qi, v16qi); + v4si __builtin_ia32_vpcomneud (v4si, v4si); + v2di __builtin_ia32_vpcomneuq (v2di, v2di); + v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi); + v8hi __builtin_ia32_vpcomnew (v8hi, v8hi); + v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi); + v4si __builtin_ia32_vpcomtrued (v4si, v4si); + v2di __builtin_ia32_vpcomtrueq (v2di, v2di); + v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi); + v4si __builtin_ia32_vpcomtrueud (v4si, v4si); + v2di __builtin_ia32_vpcomtrueuq (v2di, v2di); + v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi); + v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi); + v4si __builtin_ia32_vphaddbd (v16qi); + v2di __builtin_ia32_vphaddbq (v16qi); + v8hi __builtin_ia32_vphaddbw (v16qi); + v2di __builtin_ia32_vphadddq (v4si); + v4si __builtin_ia32_vphaddubd (v16qi); + v2di __builtin_ia32_vphaddubq (v16qi); + v8hi __builtin_ia32_vphaddubw (v16qi); + v2di __builtin_ia32_vphaddudq (v4si); + v4si __builtin_ia32_vphadduwd (v8hi); + v2di __builtin_ia32_vphadduwq (v8hi); + v4si __builtin_ia32_vphaddwd (v8hi); + v2di __builtin_ia32_vphaddwq (v8hi); + v8hi __builtin_ia32_vphsubbw (v16qi); + v2di __builtin_ia32_vphsubdq (v4si); + v4si __builtin_ia32_vphsubwd (v8hi); + v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si); + v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di); + v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di); + v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si); + v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di); + v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di); + v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si); + v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi); + v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si); + v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi); + v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si); + v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si); + v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi); + v16qi __builtin_ia32_vprotb (v16qi, v16qi); + v4si __builtin_ia32_vprotd (v4si, v4si); + v2di __builtin_ia32_vprotq (v2di, v2di); + v8hi __builtin_ia32_vprotw (v8hi, v8hi); + v16qi __builtin_ia32_vpshab (v16qi, v16qi); + v4si __builtin_ia32_vpshad (v4si, v4si); + v2di __builtin_ia32_vpshaq (v2di, v2di); + v8hi __builtin_ia32_vpshaw (v8hi, v8hi); + v16qi __builtin_ia32_vpshlb (v16qi, v16qi); + v4si __builtin_ia32_vpshld (v4si, v4si); + v2di __builtin_ia32_vpshlq (v2di, v2di); + v8hi __builtin_ia32_vpshlw (v8hi, v8hi); + +The following built-in functions are available when :option:`-mfma4` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df); + v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf); + v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df); + v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf); + v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df); + v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf); + v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df); + v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf); + v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df); + v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf); + v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df); + v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf); + v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df); + v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf); + v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df); + v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf); + v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df); + v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf); + v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df); + v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf); + v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df); + v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf); + v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df); + v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf); + v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df); + v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf); + v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df); + v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf); + v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df); + v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf); + v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df); + v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf); + +The following built-in functions are available when :option:`-mlwp` is used. + +.. code-block:: c++ + + void __builtin_ia32_llwpcb16 (void *); + void __builtin_ia32_llwpcb32 (void *); + void __builtin_ia32_llwpcb64 (void *); + void * __builtin_ia32_llwpcb16 (void); + void * __builtin_ia32_llwpcb32 (void); + void * __builtin_ia32_llwpcb64 (void); + void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short); + void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int); + void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int); + unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short); + unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int); + unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int); + +The following built-in functions are available when :option:`-mbmi` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int); + unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long); + +The following built-in functions are available when :option:`-mbmi2` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + unsigned int _bzhi_u32 (unsigned int, unsigned int); + unsigned int _pdep_u32 (unsigned int, unsigned int); + unsigned int _pext_u32 (unsigned int, unsigned int); + unsigned long long _bzhi_u64 (unsigned long long, unsigned long long); + unsigned long long _pdep_u64 (unsigned long long, unsigned long long); + unsigned long long _pext_u64 (unsigned long long, unsigned long long); + +The following built-in functions are available when :option:`-mlzcnt` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + unsigned short __builtin_ia32_lzcnt_u16(unsigned short); + unsigned int __builtin_ia32_lzcnt_u32(unsigned int); + unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long); + +The following built-in functions are available when :option:`-mfxsr` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + void __builtin_ia32_fxsave (void *); + void __builtin_ia32_fxrstor (void *); + void __builtin_ia32_fxsave64 (void *); + void __builtin_ia32_fxrstor64 (void *); + +The following built-in functions are available when :option:`-mxsave` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + void __builtin_ia32_xsave (void *, long long); + void __builtin_ia32_xrstor (void *, long long); + void __builtin_ia32_xsave64 (void *, long long); + void __builtin_ia32_xrstor64 (void *, long long); + +The following built-in functions are available when :option:`-mxsaveopt` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + void __builtin_ia32_xsaveopt (void *, long long); + void __builtin_ia32_xsaveopt64 (void *, long long); + +The following built-in functions are available when :option:`-mtbm` is used. +Both of them generate the immediate form of the bextr machine instruction. + +.. code-block:: c++ + + unsigned int __builtin_ia32_bextri_u32 (unsigned int, + const unsigned int); + unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, + const unsigned long long); + +The following built-in functions are available when :option:`-m3dnow` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + void __builtin_ia32_femms (void); + v8qi __builtin_ia32_pavgusb (v8qi, v8qi); + v2si __builtin_ia32_pf2id (v2sf); + v2sf __builtin_ia32_pfacc (v2sf, v2sf); + v2sf __builtin_ia32_pfadd (v2sf, v2sf); + v2si __builtin_ia32_pfcmpeq (v2sf, v2sf); + v2si __builtin_ia32_pfcmpge (v2sf, v2sf); + v2si __builtin_ia32_pfcmpgt (v2sf, v2sf); + v2sf __builtin_ia32_pfmax (v2sf, v2sf); + v2sf __builtin_ia32_pfmin (v2sf, v2sf); + v2sf __builtin_ia32_pfmul (v2sf, v2sf); + v2sf __builtin_ia32_pfrcp (v2sf); + v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf); + v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf); + v2sf __builtin_ia32_pfrsqrt (v2sf); + v2sf __builtin_ia32_pfsub (v2sf, v2sf); + v2sf __builtin_ia32_pfsubr (v2sf, v2sf); + v2sf __builtin_ia32_pi2fd (v2si); + v4hi __builtin_ia32_pmulhrw (v4hi, v4hi); + +The following built-in functions are available when :option:`-m3dnowa` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + v2si __builtin_ia32_pf2iw (v2sf); + v2sf __builtin_ia32_pfnacc (v2sf, v2sf); + v2sf __builtin_ia32_pfpnacc (v2sf, v2sf); + v2sf __builtin_ia32_pi2fw (v2si); + v2sf __builtin_ia32_pswapdsf (v2sf); + v2si __builtin_ia32_pswapdsi (v2si); + +The following built-in functions are available when :option:`-mrtm` is used +They are used for restricted transactional memory. These are the internal +low level functions. Normally the functions in +:ref:`x86-transactional-memory-intrinsics` should be used instead. + +.. code-block:: c++ + + int __builtin_ia32_xbegin (); + void __builtin_ia32_xend (); + void __builtin_ia32_xabort (status); + int __builtin_ia32_xtest (); + +The following built-in functions are available when :option:`-mmwaitx` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + void __builtin_ia32_monitorx (void *, unsigned int, unsigned int); + void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int); + +The following built-in functions are available when :option:`-mclzero` is used. +All of them generate the machine instruction that is part of the name. + +.. code-block:: c++ + + void __builtin_i32_clzero (void *); + +The following built-in functions are available when :option:`-mpku` is used. +They generate reads and writes to PKRU. + +.. code-block:: c++ + + void __builtin_ia32_wrpkru (unsigned int); + unsigned int __builtin_ia32_rdpkru (); + +The following built-in functions are available when +:option:`-mshstk` option is used. They support shadow stack +machine instructions from Intel Control-flow Enforcement Technology (CET). +Each built-in function generates the machine instruction that is part +of the function's name. These are the internal low-level functions. +Normally the functions in :ref:`x86-control-flow-protection-intrinsics` +should be used instead. + +.. code-block:: c++ + + unsigned int __builtin_ia32_rdsspd (void); + unsigned long long __builtin_ia32_rdsspq (void); + void __builtin_ia32_incsspd (unsigned int); + void __builtin_ia32_incsspq (unsigned long long); + void __builtin_ia32_saveprevssp(void); + void __builtin_ia32_rstorssp(void *); + void __builtin_ia32_wrssd(unsigned int, void *); + void __builtin_ia32_wrssq(unsigned long long, void *); + void __builtin_ia32_wrussd(unsigned int, void *); + void __builtin_ia32_wrussq(unsigned long long, void *); + void __builtin_ia32_setssbsy(void); + void __builtin_ia32_clrssbsy(void *); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-control-flow-protection-intrinsics.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-control-flow-protection-intrinsics.rst new file mode 100644 index 00000000000..c5638838f0b --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-control-flow-protection-intrinsics.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _x86-control-flow-protection-intrinsics: + +x86 Control-Flow Protection Intrinsics +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: ret_type _get_ssp (void) + + Get the current value of shadow stack pointer if shadow stack support + from Intel CET is enabled in the hardware or ``0`` otherwise. + The ``ret_type`` is ``unsigned long long`` for 64-bit targets + and ``unsigned int`` for 32-bit targets. + +.. function:: void _inc_ssp (unsigned int) + + Increment the current shadow stack pointer by the size specified by the + function argument. The argument is masked to a byte value for security + reasons, so to increment by more than 255 bytes you must call the function + multiple times. + +The shadow stack unwind code looks like: + +.. code-block:: c++ + + #include + + /* Unwind the shadow stack for EH. */ + #define _Unwind_Frames_Extra(x) \ + do \ + { \ + _Unwind_Word ssp = _get_ssp (); \ + if (ssp != 0) \ + { \ + _Unwind_Word tmp = (x); \ + while (tmp > 255) \ + { \ + _inc_ssp (tmp); \ + tmp -= 255; \ + } \ + _inc_ssp (tmp); \ + } \ + } \ + while (0) + +This code runs unconditionally on all 64-bit processors. For 32-bit +processors the code runs on those that support multi-byte NOP instructions. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-transactional-memory-intrinsics.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-transactional-memory-intrinsics.rst new file mode 100644 index 00000000000..7526ae27cd8 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/x86-transactional-memory-intrinsics.rst @@ -0,0 +1,102 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _x86-transactional-memory-intrinsics: + +x86 Transactional Memory Intrinsics +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These hardware transactional memory intrinsics for x86 allow you to use +memory transactions with RTM (Restricted Transactional Memory). +This support is enabled with the :option:`-mrtm` option. +For using HLE (Hardware Lock Elision) see +:ref:`x86-specific-memory-model-extensions-for-transactional-memory` instead. + +A memory transaction commits all changes to memory in an atomic way, +as visible to other threads. If the transaction fails it is rolled back +and all side effects discarded. + +Generally there is no guarantee that a memory transaction ever succeeds +and suitable fallback code always needs to be supplied. + +.. function:: unsigned _xbegin () + + Start a RTM (Restricted Transactional Memory) transaction. + Returns ``_XBEGIN_STARTED`` when the transaction + started successfully (note this is not 0, so the constant has to be + explicitly tested). + + If the transaction aborts, all side effects + are undone and an abort code encoded as a bit mask is returned. + The following macros are defined: + + ``_XABORT_EXPLICIT`` + Transaction was explicitly aborted with ``_xabort``. The parameter passed + to ``_xabort`` is available with ``_XABORT_CODE(status)``. + + ``_XABORT_RETRY`` + Transaction retry is possible. + + ``_XABORT_CONFLICT`` + Transaction abort due to a memory conflict with another thread. + + ``_XABORT_CAPACITY`` + Transaction abort due to the transaction using too much memory. + + ``_XABORT_DEBUG`` + Transaction abort due to a debug trap. + + ``_XABORT_NESTED`` + Transaction abort in an inner nested transaction. + + There is no guarantee + any transaction ever succeeds, so there always needs to be a valid + fallback path. + +.. function:: void _xend () + + Commit the current transaction. When no transaction is active this faults. + All memory side effects of the transaction become visible + to other threads in an atomic manner. + +.. function:: int _xtest () + + Return a nonzero value if a transaction is currently active, otherwise 0. + +.. function:: void _xabort (status) + + Abort the current transaction. When no transaction is active this is a no-op. + The :samp:`{status}` is an 8-bit constant; its value is encoded in the return + value from ``_xbegin``. + +Here is an example showing handling for ``_XABORT_RETRY`` +and a fallback path for other failures: + +.. code-block:: c++ + + #include + + int n_tries, max_tries; + unsigned status = _XABORT_EXPLICIT; + ... + + for (n_tries = 0; n_tries < max_tries; n_tries++) + { + status = _xbegin (); + if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY)) + break; + } + if (status == _XBEGIN_STARTED) + { + ... transaction code... + _xend (); + } + else + { + ... non-transactional fallback path... + } + +Note that, in most cases, the transactional and non-transactional code +must synchronize together to ensure consistency. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/the-character-esc-in-constants.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/the-character-esc-in-constants.rst new file mode 100644 index 00000000000..b379ec6976e --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/the-character-esc-in-constants.rst @@ -0,0 +1,12 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _character-escapes: + +The Character ESC in Constants +****************************** + +You can use the sequence :samp:`\\e` in a string or character constant to +stand for the ASCII character ESC. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/thread-local-storage.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/thread-local-storage.rst new file mode 100644 index 00000000000..ae51f8f7666 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/thread-local-storage.rst @@ -0,0 +1,219 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Thread-Local Storage, TLS, __thread + +.. _thread-local: + +Thread-Local Storage +******************** + +Thread-local storage (TLS) is a mechanism by which variables +are allocated such that there is one instance of the variable per extant +thread. The runtime model GCC uses to implement this originates +in the IA-64 processor-specific ABI, but has since been migrated +to other processors as well. It requires significant support from +the linker (:command:`ld`), dynamic linker (:command:`ld.so`), and +system libraries (:samp:`libc.so` and :samp:`libpthread.so`), so it +is not available everywhere. + +At the user level, the extension is visible with a new storage +class keyword: ``__thread``. For example: + +.. code-block:: c++ + + __thread int i; + extern __thread struct state s; + static __thread char *p; + +The ``__thread`` specifier may be used alone, with the ``extern`` +or ``static`` specifiers, but with no other storage class specifier. +When used with ``extern`` or ``static``, ``__thread`` must appear +immediately after the other storage class specifier. + +The ``__thread`` specifier may be applied to any global, file-scoped +static, function-scoped static, or static data member of a class. It may +not be applied to block-scoped automatic or non-static data member. + +When the address-of operator is applied to a thread-local variable, it is +evaluated at run time and returns the address of the current thread's +instance of that variable. An address so obtained may be used by any +thread. When a thread terminates, any pointers to thread-local variables +in that thread become invalid. + +No static initialization may refer to the address of a thread-local variable. + +In C++, if an initializer is present for a thread-local variable, it must +be a :samp:`{constant-expression}`, as defined in 5.19.2 of the ANSI/ISO C++ +standard. + +See `ELF Handling For Thread-Local Storage `_ for a detailed explanation of +the four thread-local storage addressing models, and how the runtime +is expected to function. + +.. toctree:: + :maxdepth: 2 + + +.. _c99-thread-local-edits: + +ISO/IEC 9899:1999 Edits for Thread-Local Storage +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following are a set of changes to ISO/IEC 9899:1999 (aka C99) +that document the exact semantics of the language extension. + +* 5.1.2 Execution environments + + Add new text after paragraph 1 + + Within either execution environment, a :dfn:`thread` is a flow of + control within a program. It is implementation defined whether + or not there may be more than one thread associated with a program. + It is implementation defined how threads beyond the first are + created, the name and type of the function called at thread + startup, and how threads may be terminated. However, objects + with thread storage duration shall be initialized before thread + startup. + +* 6.2.4 Storage durations of objects + + Add new text before paragraph 3 + + An object whose identifier is declared with the storage-class + specifier ``__thread`` has :dfn:`thread storage duration`. + Its lifetime is the entire execution of the thread, and its + stored value is initialized only once, prior to thread startup. + +* 6.4.1 Keywords + + Add ``__thread``. + +* 6.7.1 Storage-class specifiers + + Add ``__thread`` to the list of storage class specifiers in + paragraph 1. + + Change paragraph 2 to + + With the exception of ``__thread``, at most one storage-class + specifier may be given [...]. The ``__thread`` specifier may + be used alone, or immediately following ``extern`` or + ``static``. + + Add new text after paragraph 6 + + The declaration of an identifier for a variable that has + block scope that specifies ``__thread`` shall also + specify either ``extern`` or ``static``. + + The ``__thread`` specifier shall be used only with + variables. + +.. _c++98-thread-local-edits: + +ISO/IEC 14882:1998 Edits for Thread-Local Storage +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following are a set of changes to ISO/IEC 14882:1998 (aka C++98) +that document the exact semantics of the language extension. + +* [intro.execution] + + New text after paragraph 4 + + A :dfn:`thread` is a flow of control within the abstract machine. + It is implementation defined whether or not there may be more than + one thread. + + New text after paragraph 7 + + It is unspecified whether additional action must be taken to + ensure when and whether side effects are visible to other threads. + +* [lex.key] + + Add ``__thread``. + +* [basic.start.main] + + Add after paragraph 5 + + The thread that begins execution at the ``main`` function is called + the :dfn:`main thread`. It is implementation defined how functions + beginning threads other than the main thread are designated or typed. + A function so designated, as well as the ``main`` function, is called + a :dfn:`thread startup function`. It is implementation defined what + happens if a thread startup function returns. It is implementation + defined what happens to other threads when any thread calls ``exit``. + +* [basic.start.init] + + Add after paragraph 4 + + The storage for an object of thread storage duration shall be + statically initialized before the first statement of the thread startup + function. An object of thread storage duration shall not require + dynamic initialization. + +* [basic.start.term] + + Add after paragraph 3 + + The type of an object with thread storage duration shall not have a + non-trivial destructor, nor shall it be an array type whose elements + (directly or indirectly) have non-trivial destructors. + +* [basic.stc] + + Add 'thread storage duration' to the list in paragraph 1. + + Change paragraph 2 + + Thread, static, and automatic storage durations are associated with + objects introduced by declarations [...]. + + Add ``__thread`` to the list of specifiers in paragraph 3. + +* [basic.stc.thread] + + New section before [basic.stc.static] + + The keyword ``__thread`` applied to a non-local object gives the + object thread storage duration. + + A local variable or class data member declared both ``static`` + and ``__thread`` gives the variable or member thread storage + duration. + +* [basic.stc.static] + + Change paragraph 1 + + All objects that have neither thread storage duration, dynamic + storage duration nor are local [...]. + +* [dcl.stc] + + Add ``__thread`` to the list in paragraph 1. + + Change paragraph 1 + + With the exception of ``__thread``, at most one + :samp:`{storage-class-specifier}` shall appear in a given + :samp:`{decl-specifier-seq}`. The ``__thread`` specifier may + be used alone, or immediately following the ``extern`` or + ``static`` specifiers. [...] + + Add after paragraph 5 + + The ``__thread`` specifier can be applied only to the names of objects + and to anonymous unions. + +* [class.mem] + + Add after paragraph 6 + + Non- ``static`` members shall not be ``__thread``. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/unnamed-structure-and-union-fields.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/unnamed-structure-and-union-fields.rst new file mode 100644 index 00000000000..213a16c4ccc --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/unnamed-structure-and-union-fields.rst @@ -0,0 +1,86 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: struct, union + +.. _unnamed-fields: + +Unnamed Structure and Union Fields +********************************** + +As permitted by ISO C11 and for compatibility with other compilers, +GCC allows you to define +a structure or union that contains, as fields, structures and unions +without names. For example: + +.. code-block:: c++ + + struct { + int a; + union { + int b; + float c; + }; + int d; + } foo; + +In this example, you are able to access members of the unnamed +union with code like :samp:`foo.b`. Note that only unnamed structs and +unions are allowed, you may not have, for example, an unnamed +``int``. + +You must never create such structures that cause ambiguous field definitions. +For example, in this structure: + +.. code-block:: c++ + + struct { + int a; + struct { + int a; + }; + } foo; + +it is ambiguous which ``a`` is being referred to with :samp:`foo.a`. +The compiler gives errors for such constructs. + +.. index:: fms-extensions + +Unless :option:`-fms-extensions` is used, the unnamed field must be a +structure or union definition without a tag (for example, :samp:`struct +{ int a; };`). If :option:`-fms-extensions` is used, the field may +also be a definition with a tag such as :samp:`struct foo { int a; +};`, a reference to a previously defined structure or union such as +:samp:`struct foo;`, or a reference to a ``typedef`` name for a +previously defined structure or union type. + +.. index:: fplan9-extensions + +The option :option:`-fplan9-extensions` enables +:option:`-fms-extensions` as well as two other extensions. First, a +pointer to a structure is automatically converted to a pointer to an +anonymous field for assignments and function calls. For example: + +.. code-block:: c++ + + struct s1 { int a; }; + struct s2 { struct s1; }; + extern void f1 (struct s1 *); + void f2 (struct s2 *p) { f1 (p); } + +In the call to ``f1`` inside ``f2``, the pointer ``p`` is +converted into a pointer to the anonymous field. + +Second, when the type of an anonymous field is a ``typedef`` for a +``struct`` or ``union``, code may refer to the field using the +name of the ``typedef``. + +.. code-block:: c++ + + typedef struct { int a; } s1; + struct s2 { s1; }; + s1 f1 (struct s2 *p) { return p->s1; } + +These usages are only permitted when they are not ambiguous. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/using-vector-instructions-through-built-in-functions.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/using-vector-instructions-through-built-in-functions.rst new file mode 100644 index 00000000000..808ac582e92 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/using-vector-instructions-through-built-in-functions.rst @@ -0,0 +1,285 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _vector-extensions: + +Using Vector Instructions through Built-in Functions +**************************************************** + +On some targets, the instruction set contains SIMD vector instructions which +operate on multiple values contained in one large register at the same time. +For example, on the x86 the MMX, 3DNow! and SSE extensions can be used +this way. + +The first step in using these extensions is to provide the necessary data +types. This should be done using an appropriate ``typedef`` : + +.. code-block:: c++ + + typedef int v4si __attribute__ ((vector_size (16))); + +The ``int`` type specifies the :dfn:`base type`, while the attribute specifies +the vector size for the variable, measured in bytes. For example, the +declaration above causes the compiler to set the mode for the ``v4si`` +type to be 16 bytes wide and divided into ``int`` sized units. For +a 32-bit ``int`` this means a vector of 4 units of 4 bytes, and the +corresponding mode of ``foo`` is V4SI. + +The ``vector_size`` attribute is only applicable to integral and +floating scalars, although arrays, pointers, and function return values +are allowed in conjunction with this construct. Only sizes that are +positive power-of-two multiples of the base type size are currently allowed. + +All the basic integer types can be used as base types, both as signed +and as unsigned: ``char``, ``short``, ``int``, ``long``, +``long long``. In addition, ``float`` and ``double`` can be +used to build floating-point vector types. + +Specifying a combination that is not valid for the current architecture +causes GCC to synthesize the instructions using a narrower mode. +For example, if you specify a variable of type ``V4SI`` and your +architecture does not allow for this specific SIMD type, GCC +produces code that uses 4 ``SIs``. + +The types defined in this manner can be used with a subset of normal C +operations. Currently, GCC allows using the following operators +on these types: ``+, -, *, /, unary minus, ^, |, &, ~, %``. + +The operations behave like C++ ``valarrays``. Addition is defined as +the addition of the corresponding elements of the operands. For +example, in the code below, each of the 4 elements in :samp:`{a}` is +added to the corresponding 4 elements in :samp:`{b}` and the resulting +vector is stored in :samp:`{c}`. + +.. code-block:: c++ + + typedef int v4si __attribute__ ((vector_size (16))); + + v4si a, b, c; + + c = a + b; + +Subtraction, multiplication, division, and the logical operations +operate in a similar manner. Likewise, the result of using the unary +minus or complement operators on a vector type is a vector whose +elements are the negative or complemented values of the corresponding +elements in the operand. + +It is possible to use shifting operators ``<<``, ``>>`` on +integer-type vectors. The operation is defined as following: ``{a0, +a1, ..., an} >> {b0, b1, ..., bn} == {a0 >> b0, a1 >> b1, +..., an >> bn}``. Vector operands must have the same number of +elements. + +For convenience, it is allowed to use a binary vector operation +where one operand is a scalar. In that case the compiler transforms +the scalar operand into a vector where each element is the scalar from +the operation. The transformation happens only if the scalar could be +safely converted to the vector-element type. +Consider the following code. + +.. code-block:: c++ + + typedef int v4si __attribute__ ((vector_size (16))); + + v4si a, b, c; + long l; + + a = b + 1; /* a = b + {1,1,1,1}; */ + a = 2 * b; /* a = {2,2,2,2} * b; */ + + a = l + a; /* Error, cannot convert long to int. */ + +Vectors can be subscripted as if the vector were an array with +the same number of elements and base type. Out of bound accesses +invoke undefined behavior at run time. Warnings for out of bound +accesses for vector subscription can be enabled with +:option:`-Warray-bounds`. + +Vector comparison is supported with standard comparison +operators: ``==, !=, <, <=, >, >=``. Comparison operands can be +vector expressions of integer-type or real-type. Comparison between +integer-type vectors and real-type vectors are not supported. The +result of the comparison is a vector of the same width and number of +elements as the comparison operands with a signed integral element +type. + +Vectors are compared element-wise producing 0 when comparison is false +and -1 (constant of the appropriate type where all bits are set) +otherwise. Consider the following example. + +.. code-block:: c++ + + typedef int v4si __attribute__ ((vector_size (16))); + + v4si a = {1,2,3,4}; + v4si b = {3,2,1,4}; + v4si c; + + c = a > b; /* The result would be {0, 0,-1, 0} */ + c = a == b; /* The result would be {0,-1, 0,-1} */ + +In C++, the ternary operator ``?:`` is available. ``a?b:c``, where +``b`` and ``c`` are vectors of the same type and ``a`` is an +integer vector with the same number of elements of the same size as ``b`` +and ``c``, computes all three arguments and creates a vector +``{a[0]?b[0]:c[0], a[1]?b[1]:c[1], ...}``. Note that unlike in +OpenCL, ``a`` is thus interpreted as ``a != 0`` and not ``a < 0``. +As in the case of binary operations, this syntax is also accepted when +one of ``b`` or ``c`` is a scalar that is then transformed into a +vector. If both ``b`` and ``c`` are scalars and the type of +``true?b:c`` has the same size as the element type of ``a``, then +``b`` and ``c`` are converted to a vector type whose elements have +this type and with the same number of elements as ``a``. + +In C++, the logic operators ``!, &&, ||`` are available for vectors. +``!v`` is equivalent to ``v == 0``, ``a && b`` is equivalent to +``a!=0 & b!=0`` and ``a || b`` is equivalent to ``a!=0 | b!=0``. +For mixed operations between a scalar ``s`` and a vector ``v``, +``s && v`` is equivalent to ``s?v!=0:0`` (the evaluation is +short-circuit) and ``v && s`` is equivalent to ``v!=0 & (s?-1:0)``. + +.. index:: __builtin_shuffle + +Vector shuffling is available using functions +``__builtin_shuffle (vec, mask)`` and +``__builtin_shuffle (vec0, vec1, mask)``. +Both functions construct a permutation of elements from one or two +vectors and return a vector of the same type as the input vector(s). +The :samp:`{mask}` is an integral vector with the same width (:samp:`{W}`) +and element count (:samp:`{N}`) as the output vector. + +The elements of the input vectors are numbered in memory ordering of +:samp:`{vec0}` beginning at 0 and :samp:`{vec1}` beginning at :samp:`{N}`. The +elements of :samp:`{mask}` are considered modulo :samp:`{N}` in the single-operand +case and modulo 2\* :samp:`{N}` in the two-operand case. + +Consider the following example, + +.. code-block:: c++ + + typedef int v4si __attribute__ ((vector_size (16))); + + v4si a = {1,2,3,4}; + v4si b = {5,6,7,8}; + v4si mask1 = {0,1,1,3}; + v4si mask2 = {0,4,2,5}; + v4si res; + + res = __builtin_shuffle (a, mask1); /* res is {1,2,2,4} */ + res = __builtin_shuffle (a, b, mask2); /* res is {1,5,3,6} */ + +Note that ``__builtin_shuffle`` is intentionally semantically +compatible with the OpenCL ``shuffle`` and ``shuffle2`` functions. + +You can declare variables and use them in function calls and returns, as +well as in assignments and some casts. You can specify a vector type as +a return type for a function. Vector types can also be used as function +arguments. It is possible to cast from one vector type to another, +provided they are of the same size (in fact, you can also cast vectors +to and from other datatypes of the same size). + +You cannot operate between vectors of different lengths or different +signedness without a cast. + +.. index:: __builtin_shufflevector + +Vector shuffling is available using the +``__builtin_shufflevector (vec1, vec2, index...)`` +function. :samp:`{vec1}` and :samp:`{vec2}` must be expressions with +vector type with a compatible element type. The result of +``__builtin_shufflevector`` is a vector with the same element type +as :samp:`{vec1}` and :samp:`{vec2}` but that has an element count equal to +the number of indices specified. + +The :samp:`{index}` arguments are a list of integers that specify the +elements indices of the first two vectors that should be extracted and +returned in a new vector. These element indices are numbered sequentially +starting with the first vector, continuing into the second vector. +An index of -1 can be used to indicate that the corresponding element in +the returned vector is a don't care and can be freely chosen to optimized +the generated code sequence performing the shuffle operation. + +Consider the following example, + +.. code-block:: c++ + + typedef int v4si __attribute__ ((vector_size (16))); + typedef int v8si __attribute__ ((vector_size (32))); + + v8si a = {1,-2,3,-4,5,-6,7,-8}; + v4si b = __builtin_shufflevector (a, a, 0, 2, 4, 6); /* b is {1,3,5,7} */ + v4si c = {-2,-4,-6,-8}; + v8si d = __builtin_shufflevector (c, b, 4, 0, 5, 1, 6, 2, 7, 3); /* d is a */ + +.. index:: __builtin_convertvector + +Vector conversion is available using the +``__builtin_convertvector (vec, vectype)`` +function. :samp:`{vec}` must be an expression with integral or floating +vector type and :samp:`{vectype}` an integral or floating vector type with the +same number of elements. The result has :samp:`{vectype}` type and value of +a C cast of every element of :samp:`{vec}` to the element type of :samp:`{vectype}`. + +Consider the following example, + +.. code-block:: c++ + + typedef int v4si __attribute__ ((vector_size (16))); + typedef float v4sf __attribute__ ((vector_size (16))); + typedef double v4df __attribute__ ((vector_size (32))); + typedef unsigned long long v4di __attribute__ ((vector_size (32))); + + v4si a = {1,-2,3,-4}; + v4sf b = {1.5f,-2.5f,3.f,7.f}; + v4di c = {1ULL,5ULL,0ULL,10ULL}; + v4sf d = __builtin_convertvector (a, v4sf); /* d is {1.f,-2.f,3.f,-4.f} */ + /* Equivalent of: + v4sf d = { (float)a[0], (float)a[1], (float)a[2], (float)a[3] }; */ + v4df e = __builtin_convertvector (a, v4df); /* e is {1.,-2.,3.,-4.} */ + v4df f = __builtin_convertvector (b, v4df); /* f is {1.5,-2.5,3.,7.} */ + v4si g = __builtin_convertvector (f, v4si); /* g is {1,-2,3,7} */ + v4si h = __builtin_convertvector (c, v4si); /* h is {1,5,0,10} */ + +.. index:: vector types, using with x86 intrinsics + +Sometimes it is desirable to write code using a mix of generic vector +operations (for clarity) and machine-specific vector intrinsics (to +access vector instructions that are not exposed via generic built-ins). +On x86, intrinsic functions for integer vectors typically use the same +vector type ``__m128i`` irrespective of how they interpret the vector, +making it necessary to cast their arguments and return values from/to +other vector types. In C, you can make use of a ``union`` type: + +.. In C++ such type punning via a union is not allowed by the language + +.. code-block:: c++ + + #include + + typedef unsigned char u8x16 __attribute__ ((vector_size (16))); + typedef unsigned int u32x4 __attribute__ ((vector_size (16))); + + typedef union { + __m128i mm; + u8x16 u8; + u32x4 u32; + } v128; + +for variables that can be used with both built-in operators and x86 +intrinsics: + +.. code-block:: c++ + + v128 x, y = { 0 }; + memcpy (&x, ptr, sizeof x); + y.u8 += 0x80; + x.mm = _mm_adds_epu8 (x.mm, y.mm); + x.u32 &= 0xffffff; + + /* Instead of a variable, a compound literal may be used to pass the + return value of an intrinsic call to a function expecting the union: */ + v128 foo (v128); + x = foo ((v128) {_mm_adds_epu8 (x.mm, y.mm)}); \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/when-is-a-volatile-object-accessed.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/when-is-a-volatile-object-accessed.rst new file mode 100644 index 00000000000..d3e6f6ae082 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/when-is-a-volatile-object-accessed.rst @@ -0,0 +1,86 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: accessing volatiles, volatile read, volatile write, volatile access + +.. _volatiles: + +When is a Volatile Object Accessed? +*********************************** + +C has the concept of volatile objects. These are normally accessed by +pointers and used for accessing hardware or inter-thread +communication. The standard encourages compilers to refrain from +optimizations concerning accesses to volatile objects, but leaves it +implementation defined as to what constitutes a volatile access. The +minimum requirement is that at a sequence point all previous accesses +to volatile objects have stabilized and no subsequent accesses have +occurred. Thus an implementation is free to reorder and combine +volatile accesses that occur between sequence points, but cannot do +so for accesses across a sequence point. The use of volatile does +not allow you to violate the restriction on updating objects multiple +times between two sequence points. + +Accesses to non-volatile objects are not ordered with respect to +volatile accesses. You cannot use a volatile object as a memory +barrier to order a sequence of writes to non-volatile memory. For +instance: + +.. code-block:: c++ + + int *ptr = something; + volatile int vobj; + *ptr = something; + vobj = 1; + +Unless :samp:`{*ptr}` and :samp:`{vobj}` can be aliased, it is not guaranteed +that the write to :samp:`{*ptr}` occurs by the time the update +of :samp:`{vobj}` happens. If you need this guarantee, you must use +a stronger memory barrier such as: + +.. code-block:: c++ + + int *ptr = something; + volatile int vobj; + *ptr = something; + asm volatile ("" : : : "memory"); + vobj = 1; + +A scalar volatile object is read when it is accessed in a void context: + +.. code-block:: c++ + + volatile int *src = somevalue; + *src; + +Such expressions are rvalues, and GCC implements this as a +read of the volatile object being pointed to. + +Assignments are also expressions and have an rvalue. However when +assigning to a scalar volatile, the volatile object is not reread, +regardless of whether the assignment expression's rvalue is used or +not. If the assignment's rvalue is used, the value is that assigned +to the volatile object. For instance, there is no read of :samp:`{vobj}` +in all the following cases: + +.. code-block:: c++ + + int obj; + volatile int vobj; + vobj = something; + obj = vobj = something; + obj ? vobj = onething : vobj = anotherthing; + obj = (something, vobj = anotherthing); + +If you need to read the volatile object after an assignment has +occurred, you must use a separate expression with an intervening +sequence point. + +As bit-fields are not individually addressable, volatile bit-fields may +be implicitly read when written to, or when adjacent bit-fields are +accessed. Bit-field operations may be optimized such that adjacent +bit-fields are only partially accessed, if they straddle a storage unit +boundary. For these reasons it is unwise to use volatile bit-fields to +access hardware. \ No newline at end of file diff --git a/gcc/doc/gcc/extensions-to-the-c-language-family/x86-specific-memory-model-extensions-for-transactional-memory.rst b/gcc/doc/gcc/extensions-to-the-c-language-family/x86-specific-memory-model-extensions-for-transactional-memory.rst new file mode 100644 index 00000000000..045d2f94841 --- /dev/null +++ b/gcc/doc/gcc/extensions-to-the-c-language-family/x86-specific-memory-model-extensions-for-transactional-memory.rst @@ -0,0 +1,38 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _x86-specific-memory-model-extensions-for-transactional-memory: + +x86-Specific Memory Model Extensions for Transactional Memory +************************************************************* + +The x86 architecture supports additional memory ordering flags +to mark critical sections for hardware lock elision. +These must be specified in addition to an existing memory order to +atomic intrinsics. + +``__ATOMIC_HLE_ACQUIRE`` + Start lock elision on a lock variable. + Memory order must be ``__ATOMIC_ACQUIRE`` or stronger. + +``__ATOMIC_HLE_RELEASE`` + End lock elision on a lock variable. + Memory order must be ``__ATOMIC_RELEASE`` or stronger. + +When a lock acquire fails, it is required for good performance to abort +the transaction quickly. This can be done with a ``_mm_pause``. + +.. code-block:: c++ + + #include // For _mm_pause + + int lockvar; + + /* Acquire lock with lock elision */ + while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE)) + _mm_pause(); /* Abort failed transaction */ + ... + /* Free lock with lock elision */ + __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE); \ No newline at end of file diff --git a/gcc/doc/gcc/funding.rst b/gcc/doc/gcc/funding.rst new file mode 100644 index 00000000000..04e2a26b6c9 --- /dev/null +++ b/gcc/doc/gcc/funding.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/funding.rst \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options.rst b/gcc/doc/gcc/gcc-command-options.rst new file mode 100644 index 00000000000..fa1e37e9a83 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options.rst @@ -0,0 +1,67 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GCC command options, command options, options, GCC command + +.. _invoking-gcc: + +GCC Command Options +-------------------- + +.. only:: man + + Synopsis + ^^^^^^^^ + + gcc [ :option:`-c` | :option:`-S` | :option:`-E` ] [ :option:`-std`:samp:`={standard}` ] + [ :option:`-g` ] [ :option:`-pg` ] [ :option:`-O`:samp:`{level}` ] + [ :option:`-W`:samp:`{warn}`...] [ :option:`-Wpedantic` ] + [ :option:`-I`:samp:`{dir}`...] [ :option:`-L`:samp:`{dir}`...] + [ :option:`-D`:samp:`{macro}` [= :samp:`{defn}` ]...] [ :option:`-U`:samp:`{macro}` ] + [ :option:`-f`:samp:`{option}`...] [ :option:`-m`:samp:`{machine-option}`...] + [ :option:`-o` :samp:`{outfile}` ] [@ :samp:`{file}` ] :samp:`{infile}`... + + Only the most useful options are listed here; see below for the + remainder. :command:`g++` accepts mostly the same options as :command:`gcc`. + + For instructions on reporting bugs, see + |bugurl|. + + See the Info entry for :command:`gcc`, or + https://gcc.gnu.org/onlinedocs/gcc/Contributors.html, + for contributors to GCC. + + +.. toctree:: + :maxdepth: 2 + + gcc-command-options/description + gcc-command-options/option-summary + gcc-command-options/options-controlling-the-kind-of-output + gcc-command-options/compiling-c++-programs + gcc-command-options/options-controlling-c-dialect + gcc-command-options/options-controlling-c++-dialect + gcc-command-options/options-controlling-objective-c-and-objective-c++-dialects + gcc-command-options/options-to-control-diagnostic-messages-formatting + gcc-command-options/options-to-request-or-suppress-warnings + gcc-command-options/options-that-control-static-analysis + gcc-command-options/options-for-debugging-your-program + gcc-command-options/options-that-control-optimization + gcc-command-options/program-instrumentation-options + gcc-command-options/options-controlling-the-preprocessor + gcc-command-options/passing-options-to-the-assembler + gcc-command-options/options-for-linking + gcc-command-options/options-for-directory-search + gcc-command-options/options-for-code-generation-conventions + gcc-command-options/gcc-developer-options + gcc-command-options/machine-dependent-options + gcc-command-options/specifying-subprocesses-and-the-switches-to-pass-to-them + gcc-command-options/environment-variables-affecting-gcc + gcc-command-options/using-precompiled-headers + gcc-command-options/c++-modules + +.. only:: man + + .. include:: copyright.rst \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/c++-modules.rst b/gcc/doc/gcc/gcc-command-options/c++-modules.rst new file mode 100644 index 00000000000..283671bf0a7 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/c++-modules.rst @@ -0,0 +1,352 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: speed of compilation + +.. _c++-modules: + +C++ Modules +*********** + +Modules are a C++20 language feature. As the name suggests, they +provides a modular compilation system, intending to provide both +faster builds and better library isolation. The :P:`1103 `, +provides the easiest to read set +of changes to the standard, although it does not capture later +changes. + +*G++'s modules support is not complete.* Other than bugs, the +known missing pieces are: + +*Private Module Fragment* + The Private Module Fragment is recognized, but an error is emitted. + +*Partition definition visibility rules* + Entities may be defined in implementation partitions, and those + definitions are not available outside of the module. This is not + implemented, and the definitions are available to extra-module use. + +*Textual merging of reachable GM entities* + Entities may be multiply defined across different header-units. + These must be de-duplicated, and this is implemented across imports, + or when an import redefines a textually-defined entity. However the + reverse is not implemented---textually redefining an entity that has + been defined in an imported header-unit. A redefinition error is + emitted. + +*Translation-Unit local referencing rules* + Papers :P:`1815` and :P:`2003` + add limitations on which entities an + exported region may reference (for instance, the entities an exported + template definition may reference). These are not fully implemented. + +*Standard Library Header Units* + The Standard Library is not provided as importable header units. If + you want to import such units, you must explicitly build them first. + If you do not do this with care, you may have multiple declarations, + which the module machinery must merge---compiler resource usage can be + affected by how you partition header files into header units. + +Modular compilation is *not* enabled with just the +:option:`-std=c++20` option. You must explicitly enable it with the +:option:`-fmodules-ts` option. It is independent of the language +version selected, although in pre-C++20 versions, it is of course an +extension. + +No new source file suffixes are required or supported. If you wish to +use a non-standard suffix (see :ref:`overall-options`), you also need +to provide a :option:`-x c++` option too.Some users like to +distinguish module interface files with a new suffix, such as naming +the source ``module.cppm``, which involves +teaching all tools about the new suffix. A different scheme, such as +naming ``module-m.cpp`` would be less invasive. + +Compiling a module interface unit produces an additional output (to +the assembly or object file), called a Compiled Module Interface +(CMI). This encodes the exported declarations of the module. +Importing a module reads in the CMI. The import graph is a Directed +Acyclic Graph (DAG). You must build imports before the importer. + +Header files may themselves be compiled to header units, which are a +transitional ability aiming at faster compilation. The +:option:`-fmodule-header` option is used to enable this, and implies +the :option:`-fmodules-ts` option. These CMIs are named by the fully +resolved underlying header file, and thus may be a complete pathname +containing subdirectories. If the header file is found at an absolute +pathname, the CMI location is still relative to a CMI root directory. + +As header files often have no suffix, you commonly have to specify a +:option:`-x` option to tell the compiler the source is a header file. +You may use :option:`-x c++-header`, :option:`-x c++-user-header` or +:option:`-x c++-system-header`. When used in conjunction with +:option:`-fmodules-ts`, these all imply an appropriate +:option:`-fmodule-header` option. The latter two variants use the +user or system include path to search for the file specified. This +allows you to, for instance, compile standard library header files as +header units, without needing to know exactly where they are +installed. Specifying the language as one of these variants also +inhibits output of the object file, as header files have no associated +object file. + +The :option:`-fmodule-only` option disables generation of the +associated object file for compiling a module interface. Only the CMI +is generated. This option is implied when using the +:option:`-fmodule-header` option. + +The :option:`-flang-info-include-translate` and +:option:`-flang-info-include-translate-not` options notes whether +include translation occurs or not. With no argument, the first will +note all include translation. The second will note all +non-translations of include files not known to intentionally be +textual. With an argument, queries about include translation of a +header files with that particular trailing pathname are noted. You +may repeat this form to cover several different header files. This +option may be helpful in determining whether include translation is +happening---if it is working correctly, it behaves as if it isn't +there at all. + +The :option:`-flang-info-module-cmi` option can be used to determine +where the compiler is reading a CMI from. Without the option, the +compiler is silent when such a read is successful. This option has an +optional argument, which will restrict the notification to just the +set of named modules or header units specified. + +The :option:`-Winvalid-imported-macros` option causes all imported macros +to be resolved at the end of compilation. Without this, imported +macros are only resolved when expanded or (re)defined. This option +detects conflicting import definitions for all macros. + +For details of the :option:`-fmodule-mapper` family of options, +see :ref:`c++-module-mapper`. + +.. toctree:: + :maxdepth: 2 + + +.. index:: C++ Module Mapper + +.. _c++-module-mapper: + +Module Mapper +^^^^^^^^^^^^^ + +A module mapper provides a server or file that the compiler queries to +determine the mapping between module names and CMI files. It is also +used to build CMIs on demand. *Mapper functionality is in its +infancy and is intended for experimentation with build system +interactions.* + +You can specify a mapper with the :option:`-fmodule-mapper=val` +option or :envvar:`CXX_MODULE_MAPPER` environment variable. The value may +have one of the following forms: + +:samp:`{[}{hostname}{]}:{port}{[}?{ident}{]}` + An optional hostname and a numeric port number to connect to. If the + hostname is omitted, the loopback address is used. If the hostname + corresponds to multiple IPV6 addresses, these are tried in turn, until + one is successful. If your host lacks IPv6, this form is + non-functional. If you must use IPv4 use + :option:`-fmodule-mapper='|ncat ipv4hostport'`. + +:samp:`={socket}{[}?{ident}{]}` + A local domain socket. If your host lacks local domain sockets, this + form is non-functional. + +:samp:`|{program}{[}?{ident}{]}{[}{args...}{]}` + A program to spawn, and communicate with on its stdin/stdout streams. + Your :samp:`{PATH}` environment variable is searched for the program. + Arguments are separated by space characters, (it is not possible for + one of the arguments delivered to the program to contain a space). An + exception is if :samp:`{program}` begins with @. In that case + :samp:`{program}` (sans @) is looked for in the compiler's internal + binary directory. Thus the sample mapper-server can be specified + with ``@g++-mapper-server``. + + :samp:`<>{[}?{ident}{]}`:samp:`<>{inout}{[}?{ident}{]}` +:samp:`<{in}>{out}{[}?{ident}{]}` + Named pipes or file descriptors to communicate over. The first form, + <>, communicates over stdin and stdout. The other forms + allow you to specify a file descriptor or name a pipe. A numeric value + is interpreted as a file descriptor, otherwise named pipe is opened. + The second form specifies a bidirectional pipe and the last form + allows specifying two independent pipes. Using file descriptors + directly in this manner is fragile in general, as it can require the + cooperation of intermediate processes. In particular using stdin & + stdout is fraught with danger as other compiler options might also + cause the compiler to read stdin or write stdout, and it can have + unfortunate interactions with signal delivery from the terminal. + +:samp:`{file}{[}?{ident}{]}` + A mapping file consisting of space-separated module-name, filename + pairs, one per line. Only the mappings for the direct imports and any + module export name need be provided. If other mappings are provided, + they override those stored in any imported CMI files. A repository + root may be specified in the mapping file by using :samp:`$root` as the + module name in the first active line. Use of this option will disable + any default module->CMI name mapping. + +As shown, an optional :samp:`{ident}` may suffix the first word of the +option, indicated by a :samp:`?` prefix. The value is used in the +initial handshake with the module server, or to specify a prefix on +mapping file lines. In the server case, the main source file name is +used if no :samp:`{ident}` is specified. In the file case, all non-blank +lines are significant, unless a value is specified, in which case only +lines beginning with :samp:`{ident}` are significant. The :samp:`{ident}` +must be separated by whitespace from the module name. Be aware that +:samp:`<`, :samp:`>`, :samp:`?`, and :samp:`|` characters are often +significant to the shell, and therefore may need quoting. + +The mapper is connected to or loaded lazily, when the first module +mapping is required. The networking protocols are only supported on +hosts that provide networking. If no mapper is specified a default is +provided. + +A project-specific mapper is expected to be provided by the build +system that invokes the compiler. It is not expected that a +general-purpose server is provided for all compilations. As such, the +server will know the build configuration, the compiler it invoked, and +the environment (such as working directory) in which that is +operating. As it may parallelize builds, several compilations may +connect to the same socket. + +The default mapper generates CMI files in a :samp:`gcm.cache` +directory. CMI files have a :samp:`.gcm` suffix. The module unit name +is used directly to provide the basename. Header units construct a +relative path using the underlying header file name. If the path is +already relative, a :samp:`,` directory is prepended. Internal +:samp:`..` components are translated to :samp:`,,`. No attempt is made +to canonicalize these filenames beyond that done by the preprocessor's +include search algorithm, as in general it is ambiguous when symbolic +links are present. + +The mapper protocol was published as :P:`A Module Mapper <1184>`. +The implementation is provided by +:command:`libcody`, https://github.com/urnathan/libcody, +which specifies the canonical protocol definition. A proof of concept +server implementation embedded in :command:`make` was described in +:P:`Make Me A Module <1602>`. + +.. index:: C++ Module Preprocessing + +.. _c++-module-preprocessing: + +Module Preprocessing +^^^^^^^^^^^^^^^^^^^^ + +Modules affect preprocessing because of header units and include +translation. Some uses of the preprocessor as a separate step either +do not produce a correct output, or require CMIs to be available. + +Header units import macros. These macros can affect later conditional +inclusion, which therefore can cascade to differing import sets. When +preprocessing, it is necessary to load the CMI. If a header unit is +unavailable, the preprocessor issues a warning and continue (when +not just preprocessing, an error is emitted). Detecting such imports +requires preprocessor tokenization of the input stream to phase 4 +(macro expansion). + +Include translation converts ``#include``, ``#include_next`` and +``#import`` directives to internal ``import`` declarations. +Whether a particular directive is translated is controlled by the +module mapper. Header unit names are canonicalized during +preprocessing. + +Dependency information can be emitted for macro import, extending the +functionality of :option:`-MD` and :option:`-MMD` options. Detection of +import declarations also requires phase 4 preprocessing, and thus +requires full preprocessing (or compilation). + +The :option:`-M`, :option:`-MM` and :option:`-E -fdirectives-only` options halt +preprocessing before phase 4. + +The :option:`-save-temps` option uses :option:`-fdirectives-only` for +preprocessing, and preserve the macro definitions in the preprocessed +output. Usually you also want to use this option when explicitly +preprocessing a header-unit, or consuming such preprocessed output: + +.. code-block:: c++ + + g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii + g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii + +.. index:: C++ Compiled Module Interface + +.. _c++-compiled-module-interface: + +Compiled Module Interface +^^^^^^^^^^^^^^^^^^^^^^^^^ + +CMIs are an additional artifact when compiling named module +interfaces, partitions or header units. These are read when +importing. CMI contents are implementation-specific, and in GCC's +case tied to the compiler version. Consider them a rebuildable cache +artifact, not a distributable object. + +When creating an output CMI, any missing directory components are +created in a manner that is safe for concurrent builds creating +multiple, different, CMIs within a common subdirectory tree. + +CMI contents are written to a temporary file, which is then atomically +renamed. Observers either see old contents (if there is an +existing file), or complete new contents. They do not observe the +CMI during its creation. This is unlike object file writing, which +may be observed by an external process. + +CMIs are read in lazily, if the host OS provides ``mmap`` +functionality. Generally blocks are read when name lookup or template +instantiation occurs. To inhibit this, the :option:`-fno-module-lazy` +option may be used. + +The :option:`--param lazy-modules=n` parameter controls the limit +on the number of concurrently open module files during lazy loading. +Should more modules be imported, an LRU algorithm is used to determine +which files to close---until that file is needed again. This limit +may be exceeded with deep module dependency hierarchies. With large +code bases there may be more imports than the process limit of file +descriptors. By default, the limit is a few less than the per-process +file descriptor hard limit, if that is determinable.Where +applicable the soft limit is incremented as needed towards the hard limit. + +GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism. +You may use :command:`readelf` to inspect them, although section +contents are largely undecipherable. There is a section named +``.gnu.c++.README``, which contains human-readable text. Other +than the first line, each line consists of ``tag: value`` +tuples. + +.. code-block:: shell-session + + $ readelf -p.gnu.c++.README gcm.cache/foo.gcm + + String dump of section '.gnu.c++.README': + [ 0] GNU C++ primary module interface + [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454] + [ 6f] version: 2020/11/16-04:54 + [ 89] module: foo + [ 95] source: c_b.ii + [ a4] dialect: C++20/coroutines + [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc + [ ee] repository: gcm.cache + [ 104] buildtime: 2020/11/16 15:03:21 UTC + [ 127] localtime: 2020/11/16 07:03:21 PST + [ 14a] export: foo:part1 foo-part1.gcm + +Amongst other things, this lists the source that was built, C++ +dialect used and imports of the module.The precise contents +of this output may change. + +The timestamp is the same value as that +provided by the ``__DATE__`` & ``__TIME__`` macros, and may be +explicitly specified with the environment variable +``SOURCE_DATE_EPOCH``. For further details +see :ref:`environment-variables`. + +A set of related CMIs may be copied, provided the relative pathnames +are preserved. + +The ``.gnu.c++.README`` contents do not affect CMI integrity, and +it may be removed or altered. The section numbering of the sections +whose names do not begin with ``.gnu.c++.``, or are not the string +section is significant and must not be altered. diff --git a/gcc/doc/gcc/gcc-command-options/compiling-c++-programs.rst b/gcc/doc/gcc/gcc-command-options/compiling-c++-programs.rst new file mode 100644 index 00000000000..8dffe3756b2 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/compiling-c++-programs.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: suffixes for C++ source, C++ source file suffixes + +.. _invoking-g++: + +Compiling C++ Programs +********************** + +C++ source files conventionally use one of the suffixes :samp:`.C`, +:samp:`.cc`, :samp:`.cpp`, :samp:`.CPP`, :samp:`.c++`, :samp:`.cp`, or +:samp:`.cxx`; C++ header files often use :samp:`.hh`, :samp:`.hpp`, +:samp:`.H`, or (for shared template code) :samp:`.tcc`; and +preprocessed C++ files use the suffix :samp:`.ii`. GCC recognizes +files with these names and compiles them as C++ programs even if you +call the compiler the same way as for compiling C programs (usually +with the name :command:`gcc`). + +.. index:: g++, c++ + +However, the use of :command:`gcc` does not add the C++ library. +:command:`g++` is a program that calls GCC and automatically specifies linking +against the C++ library. It treats :samp:`.c`, +:samp:`.h` and :samp:`.i` files as C++ source files instead of C source +files unless :option:`-x` is used. This program is also useful when +precompiling a C header file with a :samp:`.h` extension for use in C++ +compilations. On many systems, :command:`g++` is also installed with +the name :command:`c++`. + +.. index:: invoking g++ + +When you compile C++ programs, you may specify many of the same +command-line options that you use for compiling programs in any +language; or command-line options meaningful for C and related +languages; or options that are meaningful only for C++ programs. +See :ref:`c-dialect-options`, for +explanations of options for languages related to C. +See :ref:`c++-dialect-options`, for +explanations of options that are meaningful only for C++ programs. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/description.rst b/gcc/doc/gcc/gcc-command-options/description.rst new file mode 100644 index 00000000000..33f1cc01e5f --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/description.rst @@ -0,0 +1,73 @@ +Description +*********** + +When you invoke GCC, it normally does preprocessing, compilation, +assembly and linking. The 'overall options' allow you to stop this +process at an intermediate stage. For example, the :option:`-c` option +says not to run the linker. Then the output consists of object files +output by the assembler. +See :ref:`overall-options`. + +Other options are passed on to one or more stages of processing. Some options +control the preprocessor and others the compiler itself. Yet other +options control the assembler and linker; most of these are not +documented here, since you rarely need to use any of them. + +.. index:: C compilation options + +Most of the command-line options that you can use with GCC are useful +for C programs; when an option is only useful with another language +(usually C++), the explanation says so explicitly. If the description +for a particular option does not mention a source language, you can use +that option with all supported languages. + +.. index:: cross compiling, specifying machine version, specifying compiler version and target machine, compiler version, specifying, target machine, specifying + +The usual way to run GCC is to run the executable called :samp:`gcc`, or +:samp:`{machine}-gcc` when cross-compiling, or +:samp:`{machine}-gcc-{version}` to run a specific version of GCC. +When you compile C++ programs, you should invoke GCC as :samp:`g++` +instead. See :ref:`invoking-g++`, +for information about the differences in behavior between :samp:`gcc` +and :samp:`g++` when compiling C++ programs. + +.. index:: grouping options, options, grouping + +The :command:`gcc` program accepts options and file names as operands. Many +options have multi-letter names; therefore multiple single-letter options +may *not* be grouped: :option:`-dv` is very different from :samp:`-d +-v`. + +.. index:: order of options, options, order + +You can mix options and other arguments. For the most part, the order +you use doesn't matter. Order does matter when you use several +options of the same kind; for example, if you specify :option:`-L` more +than once, the directories are searched in the order specified. Also, +the placement of the :option:`-l` option is significant. + +Many options have long names starting with :samp:`-f` or with +:samp:`-W`---for example, +:option:`-fmove-loop-invariants`, :option:`-Wformat` and so on. Most of +these have both positive and negative forms; the negative form of +:samp:`-ffoo` is :samp:`-fno-foo`. This manual documents +only one of these two forms, whichever one is not the default. + +Some options take one or more arguments typically separated either +by a space or by the equals sign (:samp:`=`) from the option name. +Unless documented otherwise, an argument can be either numeric or +a string. Numeric arguments must typically be small unsigned decimal +or hexadecimal integers. Hexadecimal arguments must begin with +the :samp:`0x` prefix. Arguments to options that specify a size +threshold of some sort may be arbitrarily large decimal or hexadecimal +integers followed by a byte size suffix designating a multiple of bytes +such as ``kB`` and ``KiB`` for kilobyte and kibibyte, respectively, +``MB`` and ``MiB`` for megabyte and mebibyte, ``GB`` and +``GiB`` for gigabyte and gigibyte, and so on. Such arguments are +designated by :samp:`{byte-size}` in the following text. Refer to the NIST, +IEC, and other relevant national and international standards for the full +listing and explanation of the binary and decimal byte size prefixes. + +.. only:: html + + See :ref:`genindex`, for an index to GCC's options. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/environment-variables-affecting-gcc.rst b/gcc/doc/gcc/gcc-command-options/environment-variables-affecting-gcc.rst new file mode 100644 index 00000000000..4b81a5d699b --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/environment-variables-affecting-gcc.rst @@ -0,0 +1,163 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: environment variables + +.. _environment-variables: + +Environment Variables Affecting GCC +*********************************** + +Environment +^^^^^^^^^^^ + +This section describes several environment variables that affect how GCC +operates. Some of them work by specifying directories or prefixes to use +when searching for various kinds of files. Some are used to specify other +aspects of the compilation environment. + +Note that you can also specify places to search using options such as +:option:`-B`, :option:`-I` and :option:`-L` (see :ref:`directory-options`). These +take precedence over places specified using environment variables, which +in turn take precedence over those specified by the configuration of GCC. +See :ref:`gccint:driver`. + +.. envvar:: LANG, LC_COLLATE, LC_MONETARY, LC_NUMERIC, LC_TIME + + .. index:: locale + + These environment variables control the way that GCC uses + localization information which allows GCC to work with different + national conventions. GCC inspects the locale categories + :envvar:`LC_CTYPE` and :envvar:`LC_MESSAGES` if it has been configured to do + so. These locale categories can be set to any value supported by your + installation. A typical value is :samp:`en_GB.UTF-8` for English in the United + Kingdom encoded in UTF-8. + + The :envvar:`LC_CTYPE` environment variable specifies character + classification. GCC uses it to determine the character boundaries in + a string; this is needed for some multibyte encodings that contain quote + and escape characters that are otherwise interpreted as a string + end or escape. + + The :envvar:`LC_MESSAGES` environment variable specifies the language to + use in diagnostic messages. + + If the :envvar:`LC_ALL` environment variable is set, it overrides the value + of :envvar:`LC_CTYPE` and :envvar:`LC_MESSAGES`; otherwise, :envvar:`LC_CTYPE` + and :envvar:`LC_MESSAGES` default to the value of the :envvar:`LANG` + environment variable. If none of these variables are set, GCC + defaults to traditional C English behavior. + +.. envvar:: TMPDIR + + If :envvar:`TMPDIR` is set, it specifies the directory to use for temporary + files. GCC uses temporary files to hold the output of one stage of + compilation which is to be used as input to the next stage: for example, + the output of the preprocessor, which is the input to the compiler + proper. + +.. envvar:: GCC_COMPARE_DEBUG + + Setting :envvar:`GCC_COMPARE_DEBUG` is nearly equivalent to passing + :option:`-fcompare-debug` to the compiler driver. See the documentation + of this option for more details. + +.. envvar:: GCC_EXEC_PREFIX + + If :envvar:`GCC_EXEC_PREFIX` is set, it specifies a prefix to use in the + names of the subprograms executed by the compiler. No slash is added + when this prefix is combined with the name of a subprogram, but you can + specify a prefix that ends with a slash if you wish. + + If :envvar:`GCC_EXEC_PREFIX` is not set, GCC attempts to figure out + an appropriate prefix to use based on the pathname it is invoked with. + + If GCC cannot find the subprogram using the specified prefix, it + tries looking in the usual places for the subprogram. + + The default value of :envvar:`GCC_EXEC_PREFIX` is + :samp:`{prefix}/lib/gcc/` where :samp:`{prefix}` is the prefix to + the installed compiler. In many cases :samp:`{prefix}` is the value + of ``prefix`` when you ran the :samp:`configure` script. + + Other prefixes specified with :option:`-B` take precedence over this prefix. + + This prefix is also used for finding files such as :samp:`crt0.o` that are + used for linking. + + In addition, the prefix is used in an unusual way in finding the + directories to search for header files. For each of the standard + directories whose name normally begins with :samp:`/usr/local/lib/gcc` + (more precisely, with the value of :envvar:`GCC_INCLUDE_DIR`), GCC tries + replacing that beginning with the specified prefix to produce an + alternate directory name. Thus, with :option:`-Bfoo/`, GCC searches + :samp:`foo/bar` just before it searches the standard directory + :samp:`/usr/local/lib/bar`. + If a standard directory begins with the configured + :samp:`{prefix}` then the value of :samp:`{prefix}` is replaced by + :envvar:`GCC_EXEC_PREFIX` when looking for header files. + +.. envvar:: COMPILER_PATH + + The value of :envvar:`COMPILER_PATH` is a colon-separated list of + directories, much like :envvar:`PATH`. GCC tries the directories thus + specified when searching for subprograms, if it cannot find the + subprograms using :envvar:`GCC_EXEC_PREFIX`. + +.. envvar:: LIBRARY_PATH + + The value of :envvar:`LIBRARY_PATH` is a colon-separated list of + directories, much like :envvar:`PATH`. When configured as a native compiler, + GCC tries the directories thus specified when searching for special + linker files, if it cannot find them using :envvar:`GCC_EXEC_PREFIX`. Linking + using GCC also uses these directories when searching for ordinary + libraries for the :option:`-l` option (but directories specified with + :option:`-L` come first). + +.. index:: locale definition + +.. envvar:: LANG + + This variable is used to pass locale information to the compiler. One way in + which this information is used is to determine the character set to be used + when character literals, string literals and comments are parsed in C and C++. + When the compiler is configured to allow multibyte characters, + the following values for :envvar:`LANG` are recognized: + + :samp:`C-JIS` + Recognize JIS characters. + + :samp:`C-SJIS` + Recognize SJIS characters. + + :samp:`C-EUCJP` + Recognize EUCJP characters. + + If :envvar:`LANG` is not defined, or if it has some other value, then the + compiler uses ``mblen`` and ``mbtowc`` as defined by the default locale to + recognize and translate multibyte characters. + +.. envvar:: GCC_EXTRA_DIAGNOSTIC_OUTPUT + + If :envvar:`GCC_EXTRA_DIAGNOSTIC_OUTPUT` is set to one of the following values, + then additional text will be emitted to stderr when fix-it hints are + emitted. :option:`-fdiagnostics-parseable-fixits` and + :option:`-fno-diagnostics-parseable-fixits` take precedence over this + environment variable. + + :samp:`fixits-v1` + Emit parseable fix-it hints, equivalent to + :option:`-fdiagnostics-parseable-fixits`. In particular, columns are + expressed as a count of bytes, starting at byte 1 for the initial column. + + :samp:`fixits-v2` + As ``fixits-v1``, but columns are expressed as display columns, + as per :option:`-fdiagnostics-column-unit=display`. + +Some additional environment variables affect the behavior of the +preprocessor. + +.. include:: ../../../../doc/cppenv.rst \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/gcc-developer-options.rst b/gcc/doc/gcc/gcc-command-options/gcc-developer-options.rst new file mode 100644 index 00000000000..dbfc233366d --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/gcc-developer-options.rst @@ -0,0 +1,1174 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: developer options, debugging GCC, debug dump options, dump options, compilation statistics + +.. _developer-options: + +GCC Developer Options +********************* + +This section describes command-line options that are primarily of +interest to GCC developers, including options to support compiler +testing and investigation of compiler bugs and compile-time +performance problems. This includes options that produce debug dumps +at various points in the compilation; that print statistics such as +memory use and execution time; and that print information about GCC's +configuration, such as where it searches for libraries. You should +rarely need to use any of these options for ordinary compilation and +linking tasks. + +Many developer options that cause GCC to dump output to a file take an +optional :samp:`={filename}` suffix. You can specify :samp:`stdout` +or :samp:`-` to dump to standard output, and :samp:`stderr` for standard +error. + +If :samp:`={filename}` is omitted, a default dump file name is +constructed by concatenating the base dump file name, a pass number, +phase letter, and pass name. The base dump file name is the name of +output file produced by the compiler if explicitly specified and not +an executable; otherwise it is the source file name. +The pass number is determined by the order passes are registered with +the compiler's pass manager. +This is generally the same as the order of execution, but passes +registered by plugins, target-specific passes, or passes that are +otherwise registered late are numbered higher than the pass named +:samp:`final`, even if they are executed earlier. The phase letter is +one of :samp:`i` (inter-procedural analysis), :samp:`l` +(language-specific), :samp:`r` (RTL), or :samp:`t` (tree). +The files are created in the directory of the output file. + +.. option:: -fcallgraph-info, -fcallgraph-info={MARKERS} + + Makes the compiler output callgraph information for the program, on a + per-object-file basis. The information is generated in the common VCG + format. It can be decorated with additional, per-node and/or per-edge + information, if a list of comma-separated markers is additionally + specified. When the ``su`` marker is specified, the callgraph is + decorated with stack usage information; it is equivalent to + :option:`-fstack-usage`. When the ``da`` marker is specified, the + callgraph is decorated with information about dynamically allocated + objects. + + When compiling with :option:`-flto`, no callgraph information is output + along with the object file. At LTO link time, :option:`-fcallgraph-info` + may generate multiple callgraph information files next to intermediate + LTO output files. + +.. index:: fdump-rtl-pass + +.. option:: -dletters, -fdump-rtl-pass, -fdump-rtl-pass={filename} + + Says to make debugging dumps during compilation at times specified by + :samp:`{letters}`. This is used for debugging the RTL-based passes of the + compiler. + + Some :option:`-dletters` switches have different meaning when + :option:`-E` is used for preprocessing. See :ref:`preprocessor-options`, + for information about preprocessor-specific dump options. + + Debug dumps can be enabled with a :option:`-fdump-rtl` switch or some + :option:`-d` option :samp:`{letters}`. Here are the possible + letters for use in :samp:`{pass}` and :samp:`{letters}`, and their meanings: + + .. option:: -fdump-rtl-alignments + + Dump after branch alignments have been computed. + + .. option:: -fdump-rtl-asmcons + + Dump after fixing rtl statements that have unsatisfied in/out constraints. + + .. option:: -fdump-rtl-auto_inc_dec + + Dump after auto-inc-dec discovery. This pass is only run on + architectures that have auto inc or auto dec instructions. + + .. option:: -fdump-rtl-barriers + + Dump after cleaning up the barrier instructions. + + .. option:: -fdump-rtl-bbpart + + Dump after partitioning hot and cold basic blocks. + + .. option:: -fdump-rtl-bbro + + Dump after block reordering. + + .. option:: -fdump-rtl-btl1, -fdump-rtl-btl2 + + :option:`-fdump-rtl-btl1` and :option:`-fdump-rtl-btl2` enable dumping + after the two branch + target load optimization passes. + + .. option:: -fdump-rtl-bypass + + Dump after jump bypassing and control flow optimizations. + + .. option:: -fdump-rtl-combine + + Dump after the RTL instruction combination pass. + + .. option:: -fdump-rtl-compgotos + + Dump after duplicating the computed gotos. + + .. option:: -fdump-rtl-ce1, -fdump-rtl-ce2, -fdump-rtl-ce3 + + :option:`-fdump-rtl-ce1`, :option:`-fdump-rtl-ce2`, and + :option:`-fdump-rtl-ce3` enable dumping after the three + if conversion passes. + + .. option:: -fdump-rtl-cprop_hardreg + + Dump after hard register copy propagation. + + .. option:: -fdump-rtl-csa + + Dump after combining stack adjustments. + + .. option:: -fdump-rtl-cse1, -fdump-rtl-cse2 + + :option:`-fdump-rtl-cse1` and :option:`-fdump-rtl-cse2` enable dumping after + the two common subexpression elimination passes. + + .. option:: -fdump-rtl-dce + + Dump after the standalone dead code elimination passes. + + .. option:: -fdump-rtl-dbr + + Dump after delayed branch scheduling. + + .. option:: -fdump-rtl-dce1, -fdump-rtl-dce2 + + :option:`-fdump-rtl-dce1` and :option:`-fdump-rtl-dce2` enable dumping after + the two dead store elimination passes. + + .. option:: -fdump-rtl-eh + + Dump after finalization of EH handling code. + + .. option:: -fdump-rtl-eh_ranges + + Dump after conversion of EH handling range regions. + + .. option:: -fdump-rtl-expand + + Dump after RTL generation. + + .. option:: -fdump-rtl-fwprop1, -fdump-rtl-fwprop2 + + :option:`-fdump-rtl-fwprop1` and :option:`-fdump-rtl-fwprop2` enable + dumping after the two forward propagation passes. + + .. option:: -fdump-rtl-gcse1, -fdump-rtl-gcse2 + + :option:`-fdump-rtl-gcse1` and :option:`-fdump-rtl-gcse2` enable dumping + after global common subexpression elimination. + + .. option:: -fdump-rtl-init-regs + + Dump after the initialization of the registers. + + .. option:: -fdump-rtl-initvals + + Dump after the computation of the initial value sets. + + .. option:: -fdump-rtl-into_cfglayout + + Dump after converting to cfglayout mode. + + .. option:: -fdump-rtl-ira + + Dump after iterated register allocation. + + .. option:: -fdump-rtl-jump + + Dump after the second jump optimization. + + .. option:: -fdump-rtl-loop2 + + :option:`-fdump-rtl-loop2` enables dumping after the rtl + loop optimization passes. + + .. option:: -fdump-rtl-mach + + Dump after performing the machine dependent reorganization pass, if that + pass exists. + + .. option:: -fdump-rtl-mode_sw + + Dump after removing redundant mode switches. + + .. option:: -fdump-rtl-rnreg + + Dump after register renumbering. + + .. option:: -fdump-rtl-outof_cfglayout + + Dump after converting from cfglayout mode. + + .. option:: -fdump-rtl-peephole2 + + Dump after the peephole pass. + + .. option:: -fdump-rtl-postreload + + Dump after post-reload optimizations. + + .. option:: -fdump-rtl-pro_and_epilogue + + Dump after generating the function prologues and epilogues. + + .. option:: -fdump-rtl-sched1, -fdump-rtl-sched2 + + :option:`-fdump-rtl-sched1` and :option:`-fdump-rtl-sched2` enable dumping + after the basic block scheduling passes. + + .. option:: -fdump-rtl-ree + + Dump after sign/zero extension elimination. + + .. option:: -fdump-rtl-seqabstr + + Dump after common sequence discovery. + + .. option:: -fdump-rtl-shorten + + Dump after shortening branches. + + .. option:: -fdump-rtl-sibling + + Dump after sibling call optimizations. + + .. option:: -fdump-rtl-split1, -fdump-rtl-split2, -fdump-rtl-split3, -fdump-rtl-split4, -fdump-rtl-split5 + + These options enable dumping after five rounds of + instruction splitting. + + .. option:: -fdump-rtl-sms + + Dump after modulo scheduling. This pass is only run on some + architectures. + + .. option:: -fdump-rtl-stack + + Dump after conversion from GCC's 'flat register file' registers to the + x87's stack-like registers. This pass is only run on x86 variants. + + .. option:: -fdump-rtl-subreg1, -fdump-rtl-subreg2 + + :option:`-fdump-rtl-subreg1` and :option:`-fdump-rtl-subreg2` enable dumping after + the two subreg expansion passes. + + .. option:: -fdump-rtl-unshare + + Dump after all rtl has been unshared. + + .. option:: -fdump-rtl-vartrack + + Dump after variable tracking. + + .. option:: -fdump-rtl-vregs + + Dump after converting virtual registers to hard registers. + + .. option:: -fdump-rtl-web + + Dump after live range splitting. + + .. option:: -fdump-rtl-regclass, -fdump-rtl-subregs_of_mode_init, -fdump-rtl-subregs_of_mode_finish, -fdump-rtl-dfinit, -fdump-rtl-dfinish + + These dumps are defined but always produce empty files. + + .. option:: -da, -fdump-rtl-all + + Produce all the dumps listed above. + + .. option:: -dA + + Annotate the assembler output with miscellaneous debugging information. + + .. option:: -dD + + Dump all macro definitions, at the end of preprocessing, in addition to + normal output. + + .. option:: -dH + + Produce a core dump whenever an error occurs. + + .. option:: -dp + + Annotate the assembler output with a comment indicating which + pattern and alternative is used. The length and cost of each instruction are + also printed. + + .. option:: -dP + + Dump the RTL in the assembler output as a comment before each instruction. + Also turns on :option:`-dp` annotation. + + .. option:: -dx + + Just generate RTL for a function instead of compiling it. Usually used + with :option:`-fdump-rtl-expand`. + +.. option:: -fdump-debug + + Dump debugging information generated during the debug + generation phase. + +.. option:: -fdump-earlydebug + + Dump debugging information generated during the early debug + generation phase. + +.. option:: -fdump-noaddr + + When doing debugging dumps, suppress address output. This makes it more + feasible to use diff on debugging dumps for compiler invocations with + different compiler binaries and/or different + text / bss / data / heap / stack / dso start locations. + +.. option:: -freport-bug + + Collect and dump debug information into a temporary file if an + internal compiler error (ICE) occurs. + +.. option:: -fdump-unnumbered + + When doing debugging dumps, suppress instruction numbers and address output. + This makes it more feasible to use diff on debugging dumps for compiler + invocations with different options, in particular with and without + :option:`-g`. + +.. option:: -fdump-unnumbered-links + + When doing debugging dumps (see :option:`-d` option above), suppress + instruction numbers for the links to the previous and next instructions + in a sequence. + +.. option:: -fdump-ipa-switch, -fdump-ipa-switch-options + + Control the dumping at various stages of inter-procedural analysis + language tree to a file. The file name is generated by appending a + switch specific suffix to the source file name, and the file is created + in the same directory as the output file. The following dumps are + possible: + + :samp:`all` + Enables all inter-procedural analysis dumps. + + :samp:`cgraph` + Dumps information about call-graph optimization, unused function removal, + and inlining decisions. + + :samp:`inline` + Dump after function inlining. + + Additionally, the options :option:`-optimized`, :option:`-missed`, + :option:`-note`, and :option:`-all` can be provided, with the same meaning + as for :option:`-fopt-info`, defaulting to :option:`-optimized`. + + For example, :option:`-fdump-ipa-inline-optimized-missed` will emit + information on callsites that were inlined, along with callsites + that were not inlined. + + By default, the dump will contain messages about successful + optimizations (equivalent to :option:`-optimized`) together with + low-level details about the analysis. + +.. option:: -fdump-lang + + Dump language-specific information. The file name is made by appending + :samp:`.lang` to the source file name. + +.. option:: -fdump-lang-all, -fdump-lang-switch, -fdump-lang-switch-options, -fdump-lang-switch-options={filename} + + Control the dumping of language-specific information. The :samp:`{options}` + and :samp:`{filename}` portions behave as described in the + :option:`-fdump-tree` option. The following :samp:`{switch}` values are + accepted: + + :samp:`all` + Enable all language-specific dumps. + + :samp:`class` + Dump class hierarchy information. Virtual table information is emitted + unless ' slim ' is specified. This option is applicable to C++ only. + + :samp:`module` + Dump module information. Options lineno (locations), + graph (reachability), blocks (clusters), + uid (serialization), alias (mergeable), + asmname (Elrond), eh (mapper) & vops + (macros) may provide additional information. This option is + applicable to C++ only. + + :samp:`raw` + Dump the raw internal tree data. This option is applicable to C++ only. + +.. option:: -fdump-passes + + Print on :samp:`stderr` the list of optimization passes that are turned + on and off by the current command-line options. + +.. option:: -fdump-statistics-option + + Enable and control dumping of pass statistics in a separate file. The + file name is generated by appending a suffix ending in + :samp:`.statistics` to the source file name, and the file is created in + the same directory as the output file. If the :samp:`-{option}` + form is used, :samp:`-stats` causes counters to be summed over the + whole compilation unit while :samp:`-details` dumps every event as + the passes generate them. The default with no option is to sum + counters for each function compiled. + +.. option:: -fdump-tree-all, -fdump-tree-switch, -fdump-tree-switch-options, -fdump-tree-switch-options={filename} + + Control the dumping at various stages of processing the intermediate + language tree to a file. If the :samp:`-{options}` + form is used, :samp:`{options}` is a list of :samp:`-` separated options + which control the details of the dump. Not all options are applicable + to all dumps; those that are not meaningful are ignored. The + following options are available + + :samp:`address` + Print the address of each node. Usually this is not meaningful as it + changes according to the environment and source file. Its primary use + is for tying up a dump file with a debug environment. + + :samp:`asmname` + If ``DECL_ASSEMBLER_NAME`` has been set for a given decl, use that + in the dump instead of ``DECL_NAME``. Its primary use is ease of + use working backward from mangled names in the assembly file. + + :samp:`slim` + When dumping front-end intermediate representations, inhibit dumping + of members of a scope or body of a function merely because that scope + has been reached. Only dump such items when they are directly reachable + by some other path. + + When dumping pretty-printed trees, this option inhibits dumping the + bodies of control structures. + + When dumping RTL, print the RTL in slim (condensed) form instead of + the default LISP-like representation. + + :samp:`raw` + Print a raw representation of the tree. By default, trees are + pretty-printed into a C-like representation. + + :samp:`details` + Enable more detailed dumps (not honored by every dump option). Also + include information from the optimization passes. + + :samp:`stats` + Enable dumping various statistics about the pass (not honored by every dump + option). + + :samp:`blocks` + Enable showing basic block boundaries (disabled in raw dumps). + + :samp:`graph` + For each of the other indicated dump files (:option:`-fdump-rtl-pass`), + dump a representation of the control flow graph suitable for viewing with + GraphViz to :samp:`{file}.{passid}.{pass}.dot`. Each function in + the file is pretty-printed as a subgraph, so that GraphViz can render them + all in a single plot. + + This option currently only works for RTL dumps, and the RTL is always + dumped in slim form. + + :samp:`vops` + Enable showing virtual operands for every statement. + + :samp:`lineno` + Enable showing line numbers for statements. + + :samp:`uid` + Enable showing the unique ID (``DECL_UID``) for each variable. + + :samp:`verbose` + Enable showing the tree dump for each statement. + + :samp:`eh` + Enable showing the EH region number holding each statement. + + :samp:`scev` + Enable showing scalar evolution analysis details. + + :samp:`optimized` + Enable showing optimization information (only available in certain + passes). + + :samp:`missed` + Enable showing missed optimization information (only available in certain + passes). + + :samp:`note` + Enable other detailed optimization information (only available in + certain passes). + + :samp:`all` + Turn on all options, except raw, slim, verbose + and lineno. + + :samp:`optall` + Turn on all optimization options, i.e., optimized, + missed, and note. + + To determine what tree dumps are available or find the dump for a pass + of interest follow the steps below. + + * Invoke GCC with :option:`-fdump-passes` and in the :samp:`stderr` output + look for a code that corresponds to the pass you are interested in. + For example, the codes ``tree-evrp``, ``tree-vrp1``, and + ``tree-vrp2`` correspond to the three Value Range Propagation passes. + The number at the end distinguishes distinct invocations of the same pass. + + * To enable the creation of the dump file, append the pass code to + the :option:`-fdump-` option prefix and invoke GCC with it. For example, + to enable the dump from the Early Value Range Propagation pass, invoke + GCC with the :option:`-fdump-tree-evrp` option. Optionally, you may + specify the name of the dump file. If you don't specify one, GCC + creates as described below. + + * Find the pass dump in a file whose name is composed of three components + separated by a period: the name of the source file GCC was invoked to + compile, a numeric suffix indicating the pass number followed by the + letter :samp:`t` for tree passes (and the letter :samp:`r` for RTL passes), + and finally the pass code. For example, the Early VRP pass dump might + be in a file named :samp:`myfile.c.038t.evrp` in the current working + directory. Note that the numeric codes are not stable and may change + from one version of GCC to another. + +.. option:: -fopt-info, -fopt-info-options, -fopt-info-options={filename} + + Controls optimization dumps from various optimization passes. If the + :samp:`-{options}` form is used, :samp:`{options}` is a list of + :samp:`-` separated option keywords to select the dump details and + optimizations. + + The :samp:`{options}` can be divided into three groups: + + * options describing what kinds of messages should be emitted, + + * options describing the verbosity of the dump, and + + * options describing which optimizations should be included. + + The options from each group can be freely mixed as they are + non-overlapping. However, in case of any conflicts, + the later options override the earlier options on the command + line. + + The following options control which kinds of messages should be emitted: + + :samp:`optimized` + Print information when an optimization is successfully applied. It is + up to a pass to decide which information is relevant. For example, the + vectorizer passes print the source location of loops which are + successfully vectorized. + + :samp:`missed` + Print information about missed optimizations. Individual passes + control which information to include in the output. + + :samp:`note` + Print verbose information about optimizations, such as certain + transformations, more detailed messages about decisions etc. + + :samp:`all` + Print detailed optimization information. This includes + :samp:`optimized`, :samp:`missed`, and :samp:`note`. + + The following option controls the dump verbosity: + + :samp:`internals` + By default, only 'high-level' messages are emitted. This option enables + additional, more detailed, messages, which are likely to only be of interest + to GCC developers. + + One or more of the following option keywords can be used to describe a + group of optimizations: + + :samp:`ipa` + Enable dumps from all interprocedural optimizations. + + :samp:`loop` + Enable dumps from all loop optimizations. + + :samp:`inline` + Enable dumps from all inlining optimizations. + + :samp:`omp` + Enable dumps from all OMP (Offloading and Multi Processing) optimizations. + + :samp:`vec` + Enable dumps from all vectorization optimizations. + + :samp:`optall` + Enable dumps from all optimizations. This is a superset of + the optimization groups listed above. + + If :samp:`{options}` is + omitted, it defaults to :samp:`optimized-optall`, which means to dump messages + about successful optimizations from all the passes, omitting messages + that are treated as 'internals'. + + If the :samp:`{filename}` is provided, then the dumps from all the + applicable optimizations are concatenated into the :samp:`{filename}`. + Otherwise the dump is output onto :samp:`stderr`. Though multiple + :option:`-fopt-info` options are accepted, only one of them can include + a :samp:`{filename}`. If other filenames are provided then all but the + first such option are ignored. + + Note that the output :samp:`{filename}` is overwritten + in case of multiple translation units. If a combined output from + multiple translation units is desired, :samp:`stderr` should be used + instead. + + In the following example, the optimization info is output to + :samp:`stderr`: + + .. code-block:: shell + + gcc -O3 -fopt-info + + This example: + + .. code-block:: shell + + gcc -O3 -fopt-info-missed=missed.all + + outputs missed optimization report from all the passes into + :samp:`missed.all`, and this one: + + .. code-block:: shell + + gcc -O2 -ftree-vectorize -fopt-info-vec-missed + + prints information about missed optimization opportunities from + vectorization passes on :samp:`stderr`. + Note that :option:`-fopt-info-vec-missed` is equivalent to + :option:`-fopt-info-missed-vec`. The order of the optimization group + names and message types listed after :option:`-fopt-info` does not matter. + + As another example, + + .. code-block:: shell + + gcc -O3 -fopt-info-inline-optimized-missed=inline.txt + + outputs information about missed optimizations as well as + optimized locations from all the inlining passes into + :samp:`inline.txt`. + + Finally, consider: + + .. code-block:: shell + + gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt + + Here the two output filenames :samp:`vec.miss` and :samp:`loop.opt` are + in conflict since only one output file is allowed. In this case, only + the first option takes effect and the subsequent options are + ignored. Thus only :samp:`vec.miss` is produced which contains + dumps from the vectorizer about missed opportunities. + +.. option:: -fsave-optimization-record + + Write a SRCFILE.opt-record.json.gz file detailing what optimizations + were performed, for those optimizations that support :option:`-fopt-info`. + + This option is experimental and the format of the data within the + compressed JSON file is subject to change. + + It is roughly equivalent to a machine-readable version of + :option:`-fopt-info-all`, as a collection of messages with source file, + line number and column number, with the following additional data for + each message: + + * the execution count of the code being optimized, along with metadata about + whether this was from actual profile data, or just an estimate, allowing + consumers to prioritize messages by code hotness, + + * the function name of the code being optimized, where applicable, + + * the 'inlining chain' for the code being optimized, so that when + a function is inlined into several different places (which might + themselves be inlined), the reader can distinguish between the copies, + + * objects identifying those parts of the message that refer to expressions, + statements or symbol-table nodes, which of these categories they are, and, + when available, their source code location, + + * the GCC pass that emitted the message, and + + * the location in GCC's own code from which the message was emitted + + Additionally, some messages are logically nested within other + messages, reflecting implementation details of the optimization + passes. + +.. option:: -fsched-verbose={n} + + On targets that use instruction scheduling, this option controls the + amount of debugging output the scheduler prints to the dump files. + + For :samp:`{n}` greater than zero, :option:`-fsched-verbose` outputs the + same information as :option:`-fdump-rtl-sched1` and :option:`-fdump-rtl-sched2`. + For :samp:`{n}` greater than one, it also output basic block probabilities, + detailed ready list information and unit/insn info. For :samp:`{n}` greater + than two, it includes RTL at abort point, control-flow and regions info. + And for :samp:`{n}` over four, :option:`-fsched-verbose` also includes + dependence info. + +.. option:: -fenable-kind-pass, -fdisable-kind-pass={range-list} + + This is a set of options that are used to explicitly disable/enable + optimization passes. These options are intended for use for debugging GCC. + Compiler users should use regular options for enabling/disabling + passes instead. + + :samp:`-fdisable-ipa-{pass}` + Disable IPA pass :samp:`{pass}`. :samp:`{pass}` is the pass name. If the same pass is + statically invoked in the compiler multiple times, the pass name should be + appended with a sequential number starting from 1. + + :samp:`-fdisable-rtl-{pass}` :samp:`-fdisable-rtl-{pass}={range-list}` + Disable RTL pass :samp:`{pass}`. :samp:`{pass}` is the pass name. If the same pass is + statically invoked in the compiler multiple times, the pass name should be + appended with a sequential number starting from 1. :samp:`{range-list}` is a + comma-separated list of function ranges or assembler names. Each range is a number + pair separated by a colon. The range is inclusive in both ends. If the range + is trivial, the number pair can be simplified as a single number. If the + function's call graph node's :samp:`{uid}` falls within one of the specified ranges, + the :samp:`{pass}` is disabled for that function. The :samp:`{uid}` is shown in the + function header of a dump file, and the pass names can be dumped by using + option :option:`-fdump-passes`. + + :samp:`-fdisable-tree-{pass}` :samp:`-fdisable-tree-{pass}={range-list}` + Disable tree pass :samp:`{pass}`. See :option:`-fdisable-rtl` for the description of + option arguments. + + :samp:`-fenable-ipa-{pass}` + Enable IPA pass :samp:`{pass}`. :samp:`{pass}` is the pass name. If the same pass is + statically invoked in the compiler multiple times, the pass name should be + appended with a sequential number starting from 1. + + :samp:`-fenable-rtl-{pass}` :samp:`-fenable-rtl-{pass}={range-list}` + Enable RTL pass :samp:`{pass}`. See :option:`-fdisable-rtl` for option argument + description and examples. + + :samp:`-fenable-tree-{pass}` :samp:`-fenable-tree-{pass}={range-list}` + Enable tree pass :samp:`{pass}`. See :option:`-fdisable-rtl` for the description + of option arguments. + + Here are some examples showing uses of these options. + + .. code-block:: c++ + + # disable ccp1 for all functions + -fdisable-tree-ccp1 + # disable complete unroll for function whose cgraph node uid is 1 + -fenable-tree-cunroll=1 + # disable gcse2 for functions at the following ranges [1,1], + # [300,400], and [400,1000] + # disable gcse2 for functions foo and foo2 + -fdisable-rtl-gcse2=foo,foo2 + # disable early inlining + -fdisable-tree-einline + # disable ipa inlining + -fdisable-ipa-inline + # enable tree full unroll + -fenable-tree-unroll + +.. option:: -fchecking, -fchecking={n} + + Enable internal consistency checking. The default depends on + the compiler configuration. :option:`-fchecking=2` enables further + internal consistency checking that might affect code generation. + +.. option:: -fno-checking + + Default setting; overrides :option:`-fchecking`. + +.. option:: -frandom-seed={string} + + This option provides a seed that GCC uses in place of + random numbers in generating certain symbol names + that have to be different in every compiled file. It is also used to + place unique stamps in coverage data files and the object files that + produce them. You can use the :option:`-frandom-seed` option to produce + reproducibly identical object files. + + The :samp:`{string}` can either be a number (decimal, octal or hex) or an + arbitrary string (in which case it's converted to a number by + computing CRC32). + + The :samp:`{string}` should be different for every file you compile. + +.. option:: -save-temps + + Store the usual 'temporary' intermediate files permanently; name them + as auxiliary output files, as specified described under + :option:`-dumpbase` and :option:`-dumpdir`. + + When used in combination with the :option:`-x` command-line option, + :option:`-save-temps` is sensible enough to avoid overwriting an + input source file with the same extension as an intermediate file. + The corresponding intermediate file may be obtained by renaming the + source file before using :option:`-save-temps`. + +.. option:: -save-temps=cwd + + Equivalent to :option:`-save-temps -dumpdir ./`. + +.. option:: -save-temps=obj + + Equivalent to :option:`-save-temps -dumpdir outdir/`, where + :samp:`outdir/` is the directory of the output file specified after the + :option:`-o` option, including any directory separators. If the + :option:`-o` option is not used, the :option:`-save-temps=obj` switch + behaves like :option:`-save-temps=cwd`. + +.. option:: -time[={file}] + + Report the CPU time taken by each subprocess in the compilation + sequence. For C source files, this is the compiler proper and assembler + (plus the linker if linking is done). + + Without the specification of an output file, the output looks like this: + + .. code-block:: c++ + + # cc1 0.12 0.01 + # as 0.00 0.01 + + The first number on each line is the 'user time', that is time spent + executing the program itself. The second number is 'system time', + time spent executing operating system routines on behalf of the program. + Both numbers are in seconds. + + With the specification of an output file, the output is appended to the + named file, and it looks like this: + + .. code-block:: c++ + + 0.12 0.01 cc1 options + 0.00 0.01 as options + + The 'user time' and the 'system time' are moved before the program + name, and the options passed to the program are displayed, so that one + can later tell what file was being compiled, and with which options. + +.. option:: -fdump-final-insns[={file}] + + Dump the final internal representation (RTL) to :samp:`{file}`. If the + optional argument is omitted (or if :samp:`{file}` is ``.``), the name + of the dump file is determined by appending ``.gkd`` to the + dump base name, see :option:`-dumpbase`. + +.. option:: -fcompare-debug[={opts}] + + If no error occurs during compilation, run the compiler a second time, + adding :samp:`{opts}` and :option:`-fcompare-debug-second` to the arguments + passed to the second compilation. Dump the final internal + representation in both compilations, and print an error if they differ. + + If the equal sign is omitted, the default :option:`-gtoggle` is used. + + The environment variable :envvar:`GCC_COMPARE_DEBUG`, if defined, non-empty + and nonzero, implicitly enables :option:`-fcompare-debug`. If + :envvar:`GCC_COMPARE_DEBUG` is defined to a string starting with a dash, + then it is used for :samp:`{opts}`, otherwise the default :option:`-gtoggle` + is used. + + :option:`-fcompare-debug=`, with the equal sign but without :samp:`{opts}`, + is equivalent to :option:`-fno-compare-debug`, which disables the dumping + of the final representation and the second compilation, preventing even + :envvar:`GCC_COMPARE_DEBUG` from taking effect. + + To verify full coverage during :option:`-fcompare-debug` testing, set + :envvar:`GCC_COMPARE_DEBUG` to say :option:`-fcompare-debug-not-overridden`, + which GCC rejects as an invalid option in any actual compilation + (rather than preprocessing, assembly or linking). To get just a + warning, setting :envvar:`GCC_COMPARE_DEBUG` to :samp:`-w%n-fcompare-debug + not overridden` will do. + +.. option:: -fcompare-debug-second + + This option is implicitly passed to the compiler for the second + compilation requested by :option:`-fcompare-debug`, along with options to + silence warnings, and omitting other options that would cause the compiler + to produce output to files or to standard output as a side effect. Dump + files and preserved temporary files are renamed so as to contain the + ``.gk`` additional extension during the second compilation, to avoid + overwriting those generated by the first. + + When this option is passed to the compiler driver, it causes the + *first* compilation to be skipped, which makes it useful for little + other than debugging the compiler proper. + +.. option:: -gtoggle + + Turn off generation of debug info, if leaving out this option + generates it, or turn it on at level 2 otherwise. The position of this + argument in the command line does not matter; it takes effect after all + other options are processed, and it does so only once, no matter how + many times it is given. This is mainly intended to be used with + :option:`-fcompare-debug`. + +.. option:: -fvar-tracking-assignments-toggle + + Toggle :option:`-fvar-tracking-assignments`, in the same way that + :option:`-gtoggle` toggles :option:`-g`. + +.. option:: -fno-var-tracking-assignments-toggle + + Default setting; overrides :option:`-fvar-tracking-assignments-toggle`. + +.. option:: -Q + + Makes the compiler print out each function name as it is compiled, and + print some statistics about each pass when it finishes. + +.. option:: -ftime-report + + Makes the compiler print some statistics about the time consumed by each + pass when it finishes. + +.. option:: -ftime-report-details + + Record the time consumed by infrastructure parts separately for each pass. + +.. option:: -fira-verbose={n} + + Control the verbosity of the dump file for the integrated register allocator. + The default value is 5. If the value :samp:`{n}` is greater or equal to 10, + the dump output is sent to stderr using the same format as :samp:`{n}` minus 10. + +.. option:: -flto-report + + Prints a report with internal details on the workings of the link-time + optimizer. The contents of this report vary from version to version. + It is meant to be useful to GCC developers when processing object + files in LTO mode (via :option:`-flto`). + + Disabled by default. + +.. option:: -flto-report-wpa + + Like :option:`-flto-report`, but only print for the WPA phase of link-time + optimization. + +.. option:: -fmem-report + + Makes the compiler print some statistics about permanent memory + allocation when it finishes. + +.. option:: -fmem-report-wpa + + Makes the compiler print some statistics about permanent memory + allocation for the WPA phase only. + +.. option:: -fpre-ipa-mem-report + +.. option:: -fpost-ipa-mem-report + + Makes the compiler print some statistics about permanent memory + allocation before or after interprocedural optimization. + +.. option:: -fmultiflags + + This option enables multilib-aware ``TFLAGS`` to be used to build + target libraries with options different from those the compiler is + configured to use by default, through the use of specs (See :ref:`spec-files`) set up by compiler internals, by the target, or by builders at + configure time. + + Like ``TFLAGS``, this allows the target libraries to be built for + portable baseline environments, while the compiler defaults to more + demanding ones. That's useful because users can easily override the + defaults the compiler is configured to use to build their own programs, + if the defaults are not ideal for their target environment, whereas + rebuilding the runtime libraries is usually not as easy or desirable. + + Unlike ``TFLAGS``, the use of specs enables different flags to be + selected for different multilibs. The way to accomplish that is to + build with :samp:`make TFLAGS=-fmultiflags`, after configuring + :samp:`--with-specs=%{fmultiflags:...}`. + + This option is discarded by the driver once it's done processing driver + self spec. + + It is also useful to check that ``TFLAGS`` are being used to build + all target libraries, by configuring a non-bootstrap compiler + :samp:`--with-specs='%{!fmultiflags:%emissing TFLAGS}'` and building + the compiler and target libraries. + +.. option:: -fprofile-report + + Makes the compiler print some statistics about consistency of the + (estimated) profile and effect of individual passes. + +.. option:: -fstack-usage + + Makes the compiler output stack usage information for the program, on a + per-function basis. The filename for the dump is made by appending + :samp:`.su` to the :samp:`{auxname}`. :samp:`{auxname}` is generated from the name of + the output file, if explicitly specified and it is not an executable, + otherwise it is the basename of the source file. An entry is made up + of three fields: + + * The name of the function. + + * A number of bytes. + + * One or more qualifiers: ``static``, ``dynamic``, ``bounded``. + + The qualifier ``static`` means that the function manipulates the stack + statically: a fixed number of bytes are allocated for the frame on function + entry and released on function exit; no stack adjustments are otherwise made + in the function. The second field is this fixed number of bytes. + + The qualifier ``dynamic`` means that the function manipulates the stack + dynamically: in addition to the static allocation described above, stack + adjustments are made in the body of the function, for example to push/pop + arguments around function calls. If the qualifier ``bounded`` is also + present, the amount of these adjustments is bounded at compile time and + the second field is an upper bound of the total amount of stack used by + the function. If it is not present, the amount of these adjustments is + not bounded at compile time and the second field only represents the + bounded part. + +.. option:: -fstats + + Emit statistics about front-end processing at the end of the compilation. + This option is supported only by the C++ front end, and + the information is generally only useful to the G++ development team. + +.. option:: -fdbg-cnt-list + + Print the name and the counter upper bound for all debug counters. + +.. option:: -fdbg-cnt={counter-value-list} + + Set the internal debug counter lower and upper bound. :samp:`{counter-value-list}` + is a comma-separated list of :samp:`{name}:{lower_bound1}-{upper_bound1}` + :samp:`[:{lower_bound2}-{upper_bound2}...]` tuples which sets + the name of the counter and list of closed intervals. + The :samp:`{lower_bound}` is optional and is zero + initialized if not set. + For example, with :option:`-fdbg-cnt=dce:2-4:10-11,tail_call:10`, + ``dbg_cnt(dce)`` returns true only for second, third, fourth, tenth and + eleventh invocation. + For ``dbg_cnt(tail_call)`` true is returned for first 10 invocations. + +.. option:: -print-file-name={library} + + Print the full absolute name of the library file :samp:`{library}` that + would be used when linking---and don't do anything else. With this + option, GCC does not compile or link anything; it just prints the + file name. + +.. option:: -print-multi-directory + + Print the directory name corresponding to the multilib selected by any + other switches present in the command line. This directory is supposed + to exist in :envvar:`GCC_EXEC_PREFIX`. + +.. option:: -print-multi-lib + + Print the mapping from multilib directory names to compiler switches + that enable them. The directory name is separated from the switches by + :samp:`;`, and each switch starts with an :samp:`@` instead of the + :samp:`-`, without spaces between multiple switches. This is supposed to + ease shell processing. + +.. option:: -print-multi-os-directory + + Print the path to OS libraries for the selected + multilib, relative to some :samp:`lib` subdirectory. If OS libraries are + present in the :samp:`lib` subdirectory and no multilibs are used, this is + usually just :samp:`.`, if OS libraries are present in :samp:`lib{suffix}` + sibling directories this prints e.g. :samp:`../lib64`, :samp:`../lib` or + :samp:`../lib32`, or if OS libraries are present in :samp:`lib/{subdir}` + subdirectories it prints e.g. :samp:`amd64`, :samp:`sparcv9` or :samp:`ev6`. + +.. option:: -print-multiarch + + Print the path to OS libraries for the selected multiarch, + relative to some :samp:`lib` subdirectory. + +.. option:: -print-prog-name={program} + + Like :option:`-print-file-name`, but searches for a program such as :command:`cpp`. + +.. option:: -print-libgcc-file-name + + Same as :option:`-print-file-name=libgcc.a`. + + This is useful when you use :option:`-nostdlib` or :option:`-nodefaultlibs` + but you do want to link with :samp:`libgcc.a`. You can do: + + .. code-block:: shell + + gcc -nostdlib files... `gcc -print-libgcc-file-name` + +.. option:: -print-search-dirs + + Print the name of the configured installation directory and a list of + program and library directories :command:`gcc` searches---and don't do anything else. + + This is useful when :command:`gcc` prints the error message + :samp:`installation problem, cannot exec cpp0: No such file or directory`. + To resolve this you either need to put :samp:`cpp0` and the other compiler + components where :command:`gcc` expects to find them, or you can set the environment + variable :envvar:`GCC_EXEC_PREFIX` to the directory where you installed them. + Don't forget the trailing :samp:`/`. + See :ref:`environment-variables`. + +.. option:: -print-sysroot + + Print the target sysroot directory that is used during + compilation. This is the target sysroot specified either at configure + time or using the :option:`--sysroot` option, possibly with an extra + suffix that depends on compilation options. If no target sysroot is + specified, the option prints nothing. + +.. option:: -print-sysroot-headers-suffix + + Print the suffix added to the target sysroot when searching for + headers, or give an error if the compiler is not configured with such + a suffix---and don't do anything else. + +.. option:: -dumpmachine + + Print the compiler's target machine (for example, + :samp:`i686-pc-linux-gnu`)---and don't do anything else. + +.. option:: -dumpversion + + Print the compiler version (for example, ``3.0``, ``6.3.0`` or ``7``)---and don't do + anything else. This is the compiler version used in filesystem paths and + specs. Depending on how the compiler has been configured it can be just + a single number (major version), two numbers separated by a dot (major and + minor version) or three numbers separated by dots (major, minor and patchlevel + version). + +.. option:: -dumpfullversion + + Print the full compiler version---and don't do anything else. The output is + always three numbers separated by dots, major, minor and patchlevel version. + +.. option:: -dumpspecs + + Print the compiler's built-in specs---and don't do anything else. (This + is used when GCC itself is being built.) See :ref:`spec-files`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options.rst new file mode 100644 index 00000000000..79dc9ddd77f --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options.rst @@ -0,0 +1,92 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: submodel options, specifying hardware config, hardware models and configurations, specifying, target-dependent options, machine-dependent options + +.. _submodel-options: + +Machine-Dependent Options +************************* + +Each target machine supported by GCC can have its own options---for +example, to allow you to compile for a particular processor variant or +ABI, or to control optimizations specific to that machine. By +convention, the names of machine-specific options start with +:samp:`-m`. + +Some configurations of the compiler also support additional target-specific +options, usually for compatibility with other compilers on the same +platform. + +.. This list is ordered alphanumerically by subsection name. + It should be the same order and spelling as these options are listed + in Machine Dependent Options + +.. toctree:: + :maxdepth: 1 + + machine-dependent-options/aarch64-options + machine-dependent-options/adapteva-epiphany-options + machine-dependent-options/amd-gcn-options + machine-dependent-options/arc-options + machine-dependent-options/arm-options + machine-dependent-options/avr-options + machine-dependent-options/blackfin-options + machine-dependent-options/c6x-options + machine-dependent-options/cris-options + machine-dependent-options/c-sky-options + machine-dependent-options/darwin-options + machine-dependent-options/dec-alpha-options + machine-dependent-options/ebpf-options + machine-dependent-options/fr30-options + machine-dependent-options/ft32-options + machine-dependent-options/frv-options + machine-dependent-options/gnu-linux-options + machine-dependent-options/h8-300-options + machine-dependent-options/hppa-options + machine-dependent-options/ia-64-options + machine-dependent-options/lm32-options + machine-dependent-options/loongarch-options + machine-dependent-options/m32c-options + machine-dependent-options/m32r-d-options + machine-dependent-options/m680x0-options + machine-dependent-options/mcore-options + machine-dependent-options/mep-options + machine-dependent-options/microblaze-options + machine-dependent-options/mips-options + machine-dependent-options/mmix-options + machine-dependent-options/mn10300-options + machine-dependent-options/moxie-options + machine-dependent-options/msp430-options + machine-dependent-options/nds32-options + machine-dependent-options/nios-ii-options + machine-dependent-options/nvidia-ptx-options + machine-dependent-options/openrisc-options + machine-dependent-options/pdp-11-options + machine-dependent-options/picochip-options + machine-dependent-options/powerpc-options + machine-dependent-options/pru-options + machine-dependent-options/risc-v-options + machine-dependent-options/rl78-options + machine-dependent-options/ibm-rs-6000-and-powerpc-options + machine-dependent-options/rx-options + machine-dependent-options/s-390-and-zseries-options + machine-dependent-options/score-options + machine-dependent-options/sh-options + machine-dependent-options/solaris-2-options + machine-dependent-options/sparc-options + machine-dependent-options/options-for-system-v + machine-dependent-options/v850-options + machine-dependent-options/vax-options + machine-dependent-options/visium-options + machine-dependent-options/vms-options + machine-dependent-options/vxworks-options + machine-dependent-options/x86-options + machine-dependent-options/x86-windows-options + machine-dependent-options/xstormy16-options + machine-dependent-options/xtensa-options + machine-dependent-options/zseries-options + +.. program:: None \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/aarch64-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/aarch64-options.rst new file mode 100644 index 00000000000..345b54e28a2 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/aarch64-options.rst @@ -0,0 +1,550 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: AArch64 + +.. index:: AArch64 Options + +.. _aarch64-options: + +AArch64 Options +^^^^^^^^^^^^^^^ + +These options are defined for AArch64 implementations: + +.. option:: -mabi={name} + + Generate code for the specified data model. Permissible values + are :samp:`ilp32` for SysV-like data model where int, long int and pointers + are 32 bits, and :samp:`lp64` for SysV-like data model where int is 32 bits, + but long int and pointers are 64 bits. + + The default depends on the specific target configuration. Note that + the LP64 and ILP32 ABIs are not link-compatible; you must compile your + entire program with the same ABI, and link with a compatible set of libraries. + +.. option:: -mbig-endian + + Generate big-endian code. This is the default when GCC is configured for an + :samp:`aarch64_be-*-*` target. + +.. option:: -mgeneral-regs-only + + Generate code which uses only the general-purpose registers. This will prevent + the compiler from using floating-point and Advanced SIMD registers but will not + impose any restrictions on the assembler. + +.. option:: -mlittle-endian + + Generate little-endian code. This is the default when GCC is configured for an + :samp:`aarch64-*-*` but not an :samp:`aarch64_be-*-*` target. + +.. option:: -mcmodel=tiny + + Generate code for the tiny code model. The program and its statically defined + symbols must be within 1MB of each other. Programs can be statically or + dynamically linked. + +.. option:: -mcmodel=small + + Generate code for the small code model. The program and its statically defined + symbols must be within 4GB of each other. Programs can be statically or + dynamically linked. This is the default code model. + +.. option:: -mcmodel=large + + Generate code for the large code model. This makes no assumptions about + addresses and sizes of sections. Programs can be statically linked only. The + :option:`-mcmodel=large` option is incompatible with :option:`-mabi=ilp32`, + :option:`-fpic` and :option:`-fPIC`. + +.. option:: -mstrict-align, -mno-strict-align + + Avoid or allow generating memory accesses that may not be aligned on a natural + object boundary as described in the architecture specification. + +.. option:: -momit-leaf-frame-pointer, -mno-omit-leaf-frame-pointer + + Omit or keep the frame pointer in leaf functions. The former behavior is the + default. + +.. option:: -mstack-protector-guard={guard} + + Generate stack protection code using canary at :samp:`{guard}`. Supported + locations are :samp:`global` for a global canary or :samp:`sysreg` for a + canary in an appropriate system register. + + With the latter choice the options + :option:`-mstack-protector-guard-reg=reg` and + :option:`-mstack-protector-guard-offset=offset` furthermore specify + which system register to use as base register for reading the canary, + and from what offset from that base register. There is no default + register or offset as this is entirely for use within the Linux + kernel. + +.. option:: -mtls-dialect=desc + + Use TLS descriptors as the thread-local storage mechanism for dynamic accesses + of TLS variables. This is the default. + +.. option:: -mtls-dialect=traditional + + Use traditional TLS as the thread-local storage mechanism for dynamic accesses + of TLS variables. + +.. option:: -mtls-size={size} + + Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48. + This option requires binutils 2.26 or newer. + +.. option:: -mfix-cortex-a53-835769, -mno-fix-cortex-a53-835769 + + Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769. + This involves inserting a NOP instruction between memory instructions and + 64-bit integer multiply-accumulate instructions. + +.. option:: -mfix-cortex-a53-843419, -mno-fix-cortex-a53-843419 + + Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419. + This erratum workaround is made at link time and this will only pass the + corresponding flag to the linker. + +.. option:: -mlow-precision-recip-sqrt, -mno-low-precision-recip-sqrt + + Enable or disable the reciprocal square root approximation. + This option only has an effect if :option:`-ffast-math` or + :option:`-funsafe-math-optimizations` is used as well. Enabling this reduces + precision of reciprocal square root results to about 16 bits for + single precision and to 32 bits for double precision. + +.. option:: -mlow-precision-sqrt, -mno-low-precision-sqrt + + Enable or disable the square root approximation. + This option only has an effect if :option:`-ffast-math` or + :option:`-funsafe-math-optimizations` is used as well. Enabling this reduces + precision of square root results to about 16 bits for + single precision and to 32 bits for double precision. + If enabled, it implies :option:`-mlow-precision-recip-sqrt`. + +.. option:: -mlow-precision-div, -mno-low-precision-div + + Enable or disable the division approximation. + This option only has an effect if :option:`-ffast-math` or + :option:`-funsafe-math-optimizations` is used as well. Enabling this reduces + precision of division results to about 16 bits for + single precision and to 32 bits for double precision. + +.. option:: -mtrack-speculation, -mno-track-speculation + + Enable or disable generation of additional code to track speculative + execution through conditional branches. The tracking state can then + be used by the compiler when expanding calls to + ``__builtin_speculation_safe_copy`` to permit a more efficient code + sequence to be generated. + +.. option:: -moutline-atomics, -mno-outline-atomics + + Enable or disable calls to out-of-line helpers to implement atomic operations. + These helpers will, at runtime, determine if the LSE instructions from + ARMv8.1-A can be used; if not, they will use the load/store-exclusive + instructions that are present in the base ARMv8.0 ISA. + + This option is only applicable when compiling for the base ARMv8.0 + instruction set. If using a later revision, e.g. :option:`-march=armv8.1-a` + or :option:`-march=armv8-a+lse`, the ARMv8.1-Atomics instructions will be + used directly. The same applies when using :option:`-mcpu=` when the + selected cpu supports the :samp:`lse` feature. + This option is on by default. + +.. option:: -march={name} + + Specify the name of the target architecture and, optionally, one or + more feature modifiers. This option has the form + :option:`-march=arch{+[no]feature}*`. + + The table below summarizes the permissible values for :samp:`{arch}` + and the features that they enable by default: + + .. list-table:: + :header-rows: 1 + + * - :samp:`{arch}` value + - Architecture + - Includes by default + + * - :samp:`armv8-a` + - Armv8-A + - :samp:`+fp`, :samp:`+simd` + * - :samp:`armv8.1-a` + - Armv8.1-A + - :samp:`armv8-a`, :samp:`+crc`, :samp:`+lse`, :samp:`+rdma` + * - :samp:`armv8.2-a` + - Armv8.2-A + - :samp:`armv8.1-a` + * - :samp:`armv8.3-a` + - Armv8.3-A + - :samp:`armv8.2-a`, :samp:`+pauth` + * - :samp:`armv8.4-a` + - Armv8.4-A + - :samp:`armv8.3-a`, :samp:`+flagm`, :samp:`+fp16fml`, :samp:`+dotprod` + * - :samp:`armv8.5-a` + - Armv8.5-A + - :samp:`armv8.4-a`, :samp:`+sb`, :samp:`+ssbs`, :samp:`+predres` + * - :samp:`armv8.6-a` + - Armv8.6-A + - :samp:`armv8.5-a`, :samp:`+bf16`, :samp:`+i8mm` + * - :samp:`armv8.7-a` + - Armv8.7-A + - :samp:`armv8.6-a`, :samp:`+ls64` + * - :samp:`armv8.8-a` + - Armv8.8-a + - :samp:`armv8.7-a`, :samp:`+mops` + * - :samp:`armv9-a` + - Armv9-A + - :samp:`armv8.5-a`, :samp:`+sve`, :samp:`+sve2` + * - :samp:`armv9.1-a` + - Armv9.1-A + - :samp:`armv9-a`, :samp:`+bf16`, :samp:`+i8mm` + * - :samp:`armv9.2-a` + - Armv9.2-A + - :samp:`armv9.1-a`, :samp:`+ls64` + * - :samp:`armv9.3-a` + - Armv9.3-A + - :samp:`armv9.2-a`, :samp:`+mops` + * - :samp:`armv8-r` + - Armv8-R + - :samp:`armv8-r` + + The value :samp:`native` is available on native AArch64 GNU/Linux and + causes the compiler to pick the architecture of the host system. This + option has no effect if the compiler is unable to recognize the + architecture of the host system, + + The permissible values for :samp:`{feature}` are listed in the sub-section + on :ref:`aarch64-feature-modifiers`. + Where conflicting feature modifiers are + specified, the right-most feature is used. + + GCC uses :samp:`{name}` to determine what kind of instructions it can emit + when generating assembly code. If :option:`-march` is specified + without either of :option:`-mtune` or :option:`-mcpu` also being + specified, the code is tuned to perform well across a range of target + processors implementing the target architecture. + +.. option:: -mtune={name} + + Specify the name of the target processor for which GCC should tune the + performance of the code. Permissible values for this option are: + :samp:`generic`, :samp:`cortex-a35`, :samp:`cortex-a53`, :samp:`cortex-a55`, + :samp:`cortex-a57`, :samp:`cortex-a72`, :samp:`cortex-a73`, :samp:`cortex-a75`, + :samp:`cortex-a76`, :samp:`cortex-a76ae`, :samp:`cortex-a77`, + :samp:`cortex-a65`, :samp:`cortex-a65ae`, :samp:`cortex-a34`, + :samp:`cortex-a78`, :samp:`cortex-a78ae`, :samp:`cortex-a78c`, + :samp:`ares`, :samp:`exynos-m1`, :samp:`emag`, :samp:`falkor`, + :samp:`neoverse-512tvb`, :samp:`neoverse-e1`, :samp:`neoverse-n1`, + :samp:`neoverse-n2`, :samp:`neoverse-v1`, :samp:`neoverse-v2`, :samp:`qdf24xx`, + :samp:`saphira`, :samp:`phecda`, :samp:`xgene1`, :samp:`vulcan`, + :samp:`octeontx`, :samp:`octeontx81`, :samp:`octeontx83`, + :samp:`octeontx2`, :samp:`octeontx2t98`, :samp:`octeontx2t96` + :samp:`octeontx2t93`, :samp:`octeontx2f95`, :samp:`octeontx2f95n`, + :samp:`octeontx2f95mm`, + :samp:`a64fx`, + :samp:`thunderx`, :samp:`thunderxt88`, + :samp:`thunderxt88p1`, :samp:`thunderxt81`, :samp:`tsv110`, + :samp:`thunderxt83`, :samp:`thunderx2t99`, :samp:`thunderx3t110`, :samp:`zeus`, + :samp:`cortex-a57.cortex-a53`, :samp:`cortex-a72.cortex-a53`, + :samp:`cortex-a73.cortex-a35`, :samp:`cortex-a73.cortex-a53`, + :samp:`cortex-a75.cortex-a55`, :samp:`cortex-a76.cortex-a55`, + :samp:`cortex-r82`, :samp:`cortex-x1`, :samp:`cortex-x2`, + :samp:`cortex-a510`, :samp:`cortex-a710`, :samp:`ampere1`, :samp:`native`. + + The values :samp:`cortex-a57.cortex-a53`, :samp:`cortex-a72.cortex-a53`, + :samp:`cortex-a73.cortex-a35`, :samp:`cortex-a73.cortex-a53`, + :samp:`cortex-a75.cortex-a55`, :samp:`cortex-a76.cortex-a55` specify that GCC + should tune for a big.LITTLE system. + + The value :samp:`neoverse-512tvb` specifies that GCC should tune + for Neoverse cores that (a) implement SVE and (b) have a total vector + bandwidth of 512 bits per cycle. In other words, the option tells GCC to + tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic + instructions a cycle and that can execute an equivalent number of SVE + arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE). + This is more general than tuning for a specific core like Neoverse V1 + but is more specific than the default tuning described below. + + Additionally on native AArch64 GNU/Linux systems the value + :samp:`native` tunes performance to the host system. This option has no effect + if the compiler is unable to recognize the processor of the host system. + + Where none of :option:`-mtune=`, :option:`-mcpu=` or :option:`-march=` + are specified, the code is tuned to perform well across a range + of target processors. + + This option cannot be suffixed by feature modifiers. + +.. option:: -mcpu={name} + + Specify the name of the target processor, optionally suffixed by one + or more feature modifiers. This option has the form + :option:`-mcpu=cpu{+[no]feature}*`, where + the permissible values for :samp:`{cpu}` are the same as those available + for :option:`-mtune`. The permissible values for :samp:`{feature}` are + documented in the sub-section on :ref:`aarch64-feature-modifiers`. + Where conflicting feature modifiers are + specified, the right-most feature is used. + + GCC uses :samp:`{name}` to determine what kind of instructions it can emit when + generating assembly code (as if by :option:`-march`) and to determine + the target processor for which to tune for performance (as if + by :option:`-mtune`). Where this option is used in conjunction + with :option:`-march` or :option:`-mtune`, those options take precedence + over the appropriate part of this option. + + :option:`-mcpu=neoverse-512tvb` is special in that it does not refer + to a specific core, but instead refers to all Neoverse cores that + (a) implement SVE and (b) have a total vector bandwidth of 512 bits + a cycle. Unless overridden by :option:`-march`, + :option:`-mcpu=neoverse-512tvb` generates code that can run on a + Neoverse V1 core, since Neoverse V1 is the first Neoverse core with + these properties. Unless overridden by :option:`-mtune`, + :option:`-mcpu=neoverse-512tvb` tunes code in the same way as for + :option:`-mtune=neoverse-512tvb`. + +.. option:: -moverride={string} + + Override tuning decisions made by the back-end in response to a + :option:`-mtune=` switch. The syntax, semantics, and accepted values + for :samp:`{string}` in this option are not guaranteed to be consistent + across releases. + + This option is only intended to be useful when developing GCC. + +.. option:: -mverbose-cost-dump + + Enable verbose cost model dumping in the debug dump files. This option is + provided for use in debugging the compiler. + +.. option:: -mpc-relative-literal-loads, -mno-pc-relative-literal-loads + + Enable or disable PC-relative literal loads. With this option literal pools are + accessed using a single instruction and emitted after each function. This + limits the maximum size of functions to 1MB. This is enabled by default for + :option:`-mcmodel=tiny`. + +.. option:: -msign-return-address={scope} + + Select the function scope on which return address signing will be applied. + Permissible values are :samp:`none`, which disables return address signing, + :samp:`non-leaf`, which enables pointer signing for functions which are not leaf + functions, and :samp:`all`, which enables pointer signing for all functions. The + default value is :samp:`none`. This option has been deprecated by + -mbranch-protection. + +.. option:: -mbranch-protection={none}|{standard}|{pac-ret}[+{leaf}+{b-key}]|{bti} + + Select the branch protection features to use. + :samp:`none` is the default and turns off all types of branch protection. + :samp:`standard` turns on all types of branch protection features. If a feature + has additional tuning options, then :samp:`standard` sets it to its standard + level. + :samp:`pac-ret[+{leaf}]` turns on return address signing to its standard + level: signing functions that save the return address to memory (non-leaf + functions will practically always do this) using the a-key. The optional + argument :samp:`leaf` can be used to extend the signing to include leaf + functions. The optional argument :samp:`b-key` can be used to sign the functions + with the B-key instead of the A-key. + :samp:`bti` turns on branch target identification mechanism. + +.. option:: -mharden-sls={opts} + + Enable compiler hardening against straight line speculation (SLS). + :samp:`{opts}` is a comma-separated list of the following options: + + :samp:`retbr` :samp:`blr` + + In addition, :option:`-mharden-sls`:samp:`=all` enables all SLS hardening while + :option:`-mharden-sls`:samp:`=none` disables all SLS hardening. + +.. option:: -msve-vector-bits={bits} + + Specify the number of bits in an SVE vector register. This option only has + an effect when SVE is enabled. + + GCC supports two forms of SVE code generation: 'vector-length + agnostic' output that works with any size of vector register and + 'vector-length specific' output that allows GCC to make assumptions + about the vector length when it is useful for optimization reasons. + The possible values of :samp:`bits` are: :samp:`scalable`, :samp:`128`, + :samp:`256`, :samp:`512`, :samp:`1024` and :samp:`2048`. + Specifying :samp:`scalable` selects vector-length agnostic + output. At present :samp:`-msve-vector-bits=128` also generates vector-length + agnostic output for big-endian targets. All other values generate + vector-length specific code. The behavior of these values may change + in future releases and no value except :samp:`scalable` should be + relied on for producing code that is portable across different + hardware SVE vector lengths. + + The default is :samp:`-msve-vector-bits=scalable`, which produces + vector-length agnostic code. + + +.. _aarch64-feature-modifiers: + +-march and -mcpu Feature Modifiers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. index:: -march feature modifiers, -mcpu feature modifiers + +Feature modifiers used with :option:`-march` and :option:`-mcpu` can be any of +the following and their inverses no :samp:`{feature}` : + +:samp:`crc` + Enable CRC extension. This is on by default for + :option:`-march=armv8.1-a`. + +:samp:`crypto` + Enable Crypto extension. This also enables Advanced SIMD and floating-point + instructions. + +:samp:`fp` + Enable floating-point instructions. This is on by default for all possible + values for options :option:`-march` and :option:`-mcpu`. + +:samp:`simd` + Enable Advanced SIMD instructions. This also enables floating-point + instructions. This is on by default for all possible values for options + :option:`-march` and :option:`-mcpu`. + +:samp:`sve` + Enable Scalable Vector Extension instructions. This also enables Advanced + SIMD and floating-point instructions. + +:samp:`lse` + Enable Large System Extension instructions. This is on by default for + :option:`-march=armv8.1-a`. + +:samp:`rdma` + Enable Round Double Multiply Accumulate instructions. This is on by default + for :option:`-march=armv8.1-a`. + +:samp:`fp16` + Enable FP16 extension. This also enables floating-point instructions. + +:samp:`fp16fml` + Enable FP16 fmla extension. This also enables FP16 extensions and + floating-point instructions. This option is enabled by default for :option:`-march=armv8.4-a`. Use of this option with architectures prior to Armv8.2-A is not supported. + +:samp:`rcpc` + Enable the RcPc extension. This does not change code generation from GCC, + but is passed on to the assembler, enabling inline asm statements to use + instructions from the RcPc extension. + +:samp:`dotprod` + Enable the Dot Product extension. This also enables Advanced SIMD instructions. + +:samp:`aes` + Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced + SIMD instructions. + +:samp:`sha2` + Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions. + +:samp:`sha3` + Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD + instructions. Use of this option with architectures prior to Armv8.2-A is not supported. + +:samp:`sm4` + Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions. + Use of this option with architectures prior to Armv8.2-A is not supported. + +:samp:`profile` + Enable the Statistical Profiling extension. This option is only to enable the + extension at the assembler level and does not affect code generation. + +:samp:`rng` + Enable the Armv8.5-a Random Number instructions. This option is only to + enable the extension at the assembler level and does not affect code + generation. + +:samp:`memtag` + Enable the Armv8.5-a Memory Tagging Extensions. + Use of this option with architectures prior to Armv8.5-A is not supported. + +:samp:`sb` + Enable the Armv8-a Speculation Barrier instruction. This option is only to + enable the extension at the assembler level and does not affect code + generation. This option is enabled by default for :option:`-march=armv8.5-a`. + +:samp:`ssbs` + Enable the Armv8-a Speculative Store Bypass Safe instruction. This option + is only to enable the extension at the assembler level and does not affect code + generation. This option is enabled by default for :option:`-march=armv8.5-a`. + +:samp:`predres` + Enable the Armv8-a Execution and Data Prediction Restriction instructions. + This option is only to enable the extension at the assembler level and does + not affect code generation. This option is enabled by default for + :option:`-march=armv8.5-a`. + +:samp:`sve2` + Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE + instructions. + +:samp:`sve2-bitperm` + Enable SVE2 bitperm instructions. This also enables SVE2 instructions. + +:samp:`sve2-sm4` + Enable SVE2 sm4 instructions. This also enables SVE2 instructions. + +:samp:`sve2-aes` + Enable SVE2 aes instructions. This also enables SVE2 instructions. + +:samp:`sve2-sha3` + Enable SVE2 sha3 instructions. This also enables SVE2 instructions. + +:samp:`tme` + Enable the Transactional Memory Extension. + +:samp:`i8mm` + Enable 8-bit Integer Matrix Multiply instructions. This also enables + Advanced SIMD and floating-point instructions. This option is enabled by + default for :option:`-march=armv8.6-a`. Use of this option with architectures + prior to Armv8.2-A is not supported. + +:samp:`f32mm` + Enable 32-bit Floating point Matrix Multiply instructions. This also enables + SVE instructions. Use of this option with architectures prior to Armv8.2-A is + not supported. + +:samp:`f64mm` + Enable 64-bit Floating point Matrix Multiply instructions. This also enables + SVE instructions. Use of this option with architectures prior to Armv8.2-A is + not supported. + +:samp:`bf16` + Enable brain half-precision floating-point instructions. This also enables + Advanced SIMD and floating-point instructions. This option is enabled by + default for :option:`-march=armv8.6-a`. Use of this option with architectures + prior to Armv8.2-A is not supported. + +:samp:`ls64` + Enable the 64-byte atomic load and store instructions for accelerators. + This option is enabled by default for :option:`-march=armv8.7-a`. + +:samp:`mops` + Enable the instructions to accelerate memory operations like ``memcpy``, + ``memmove``, ``memset``. This option is enabled by default for + :option:`-march=armv8.8-a` + +:samp:`flagm` + Enable the Flag Manipulation instructions Extension. + +:samp:`pauth` + Enable the Pointer Authentication Extension. + +Feature ``crypto`` implies ``aes``, ``sha2``, and ``simd``, +which implies ``fp``. +Conversely, ``nofp`` implies ``nosimd``, which implies +``nocrypto``, ``noaes`` and ``nosha2``. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/adapteva-epiphany-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/adapteva-epiphany-options.rst new file mode 100644 index 00000000000..abbcc6881b1 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/adapteva-epiphany-options.rst @@ -0,0 +1,163 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: Adapteva Epiphany + +.. _adapteva-epiphany-options: + +Adapteva Epiphany Options +^^^^^^^^^^^^^^^^^^^^^^^^^ + +These :samp:`-m` options are defined for Adapteva Epiphany: + +.. option:: -mhalf-reg-file + + Don't allocate any register in the range ``r32``... ``r63``. + That allows code to run on hardware variants that lack these registers. + +.. option:: -mprefer-short-insn-regs + + Preferentially allocate registers that allow short instruction generation. + This can result in increased instruction count, so this may either reduce or + increase overall code size. + +.. option:: -mbranch-cost={num} + + Set the cost of branches to roughly :samp:`{num}` 'simple' instructions. + This cost is only a heuristic and is not guaranteed to produce + consistent results across releases. + +.. option:: -mcmove + + Enable the generation of conditional moves. + +.. option:: -mnops={num} + + Emit :samp:`{num}` NOPs before every other generated instruction. + +.. option:: -mno-soft-cmpsf + + For single-precision floating-point comparisons, emit an ``fsub`` instruction + and test the flags. This is faster than a software comparison, but can + get incorrect results in the presence of NaNs, or when two different small + numbers are compared such that their difference is calculated as zero. + The default is :option:`-msoft-cmpsf`, which uses slower, but IEEE-compliant, + software comparisons. + +.. option:: -msoft-cmpsf + + Default setting; overrides :option:`-mno-soft-cmpsf`. + +.. option:: -mstack-offset={num} + + Set the offset between the top of the stack and the stack pointer. + E.g., a value of 8 means that the eight bytes in the range ``sp+0...sp+7`` + can be used by leaf functions without stack allocation. + Values other than :samp:`8` or :samp:`16` are untested and unlikely to work. + Note also that this option changes the ABI; compiling a program with a + different stack offset than the libraries have been compiled with + generally does not work. + This option can be useful if you want to evaluate if a different stack + offset would give you better code, but to actually use a different stack + offset to build working programs, it is recommended to configure the + toolchain with the appropriate :option:`--with-stack-offset=num` option. + +.. option:: -mno-round-nearest + + Make the scheduler assume that the rounding mode has been set to + truncating. The default is :option:`-mround-nearest`. + +.. option:: -mround-nearest + + Default setting; overrides :option:`-mno-round-nearest`. + +.. option:: -mlong-calls + + If not otherwise specified by an attribute, assume all calls might be beyond + the offset range of the ``b`` / ``bl`` instructions, and therefore load the + function address into a register before performing a (otherwise direct) call. + This is the default. + +.. option:: -mshort-calls + + If not otherwise specified by an attribute, assume all direct calls are + in the range of the ``b`` / ``bl`` instructions, so use these instructions + for direct calls. The default is :option:`-mlong-calls`. + +.. option:: -msmall16 + + Assume addresses can be loaded as 16-bit unsigned values. This does not + apply to function addresses for which :option:`-mlong-calls` semantics + are in effect. + +.. option:: -mfp-mode={mode} + + Set the prevailing mode of the floating-point unit. + This determines the floating-point mode that is provided and expected + at function call and return time. Making this mode match the mode you + predominantly need at function start can make your programs smaller and + faster by avoiding unnecessary mode switches. + + :samp:`{mode}` can be set to one the following values: + + :samp:`caller` + Any mode at function entry is valid, and retained or restored when + the function returns, and when it calls other functions. + This mode is useful for compiling libraries or other compilation units + you might want to incorporate into different programs with different + prevailing FPU modes, and the convenience of being able to use a single + object file outweighs the size and speed overhead for any extra + mode switching that might be needed, compared with what would be needed + with a more specific choice of prevailing FPU mode. + + :samp:`truncate` + This is the mode used for floating-point calculations with + truncating (i.e. round towards zero) rounding mode. That includes + conversion from floating point to integer. + + :samp:`round-nearest` + This is the mode used for floating-point calculations with + round-to-nearest-or-even rounding mode. + + :samp:`int` + This is the mode used to perform integer calculations in the FPU, e.g. + integer multiply, or integer multiply-and-accumulate. + + The default is :option:`-mfp-mode=caller` + +.. option:: -mno-split-lohi, -mno-postinc, -mno-postmodify + + Code generation tweaks that disable, respectively, splitting of 32-bit + loads, generation of post-increment addresses, and generation of + post-modify addresses. The defaults are msplit-lohi, + :option:`-mpost-inc`, and :option:`-mpost-modify`. + +.. option:: -mnovect-double + + Change the preferred SIMD mode to SImode. The default is + :option:`-mvect-double`, which uses DImode as preferred SIMD mode. + +.. option:: -max-vect-align={num} + + The maximum alignment for SIMD vector mode types. + :samp:`{num}` may be 4 or 8. The default is 8. + Note that this is an ABI change, even though many library function + interfaces are unaffected if they don't use SIMD vector modes + in places that affect size and/or alignment of relevant types. + +.. option:: -msplit-vecmove-early + + Split vector moves into single word moves before reload. In theory this + can give better register allocation, but so far the reverse seems to be + generally the case. + +.. option:: -m1reg-reg + + Specify a register to hold the constant -1, which makes loading small negative + constants and certain bitmasks faster. + Allowable values for :samp:`{reg}` are :samp:`r43` and :samp:`r63`, + which specify use of that register as a fixed register, + and :samp:`none`, which means that no register is used for this + purpose. The default is :option:`-m1reg-none`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/amd-gcn-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/amd-gcn-options.rst new file mode 100644 index 00000000000..75fe0e3a2ea --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/amd-gcn-options.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: AMD GCN + +.. index:: AMD GCN Options + +.. _amd-gcn-options: + +AMD GCN Options +^^^^^^^^^^^^^^^ + +These options are defined specifically for the AMD GCN port. + +.. option:: -march={gpu} + + Set architecture type or tuning for :samp:`{gpu}`. Supported values for :samp:`{gpu}` + are + + :samp:`fiji` + Compile for GCN3 Fiji devices (gfx803). + + :samp:`gfx900` + Compile for GCN5 Vega 10 devices (gfx900). + + :samp:`gfx906` + Compile for GCN5 Vega 20 devices (gfx906). + + :samp:`gfx908` + Compile for CDNA1 Instinct MI100 series devices (gfx908). + + :samp:`gfx90a` + Compile for CDNA2 Instinct MI200 series devices (gfx90a). + +.. option:: -msram-ecc=on + + Compile binaries suitable for devices with the SRAM-ECC feature enabled, + disabled, or either mode. This feature can be enabled per-process on some + devices. The compiled code must match the device mode. The default is + :samp:`any`, for devices that support it. + +.. option:: -mstack-size={bytes} + + Specify how many :samp:`{bytes}` of stack space will be requested for each GPU + thread (wave-front). Beware that there may be many threads and limited memory + available. The size of the stack allocation may also have an impact on + run-time performance. The default is 32KB when using OpenACC or OpenMP, and + 1MB otherwise. + +.. option:: -mxnack + + Compile binaries suitable for devices with the XNACK feature enabled. Some + devices always require XNACK and some allow the user to configure XNACK. The + compiled code must match the device mode. The default is :samp:`-mno-xnack`. + At present this option is a placeholder for support that is not yet + implemented. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/arc-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/arc-options.rst new file mode 100644 index 00000000000..758331aa333 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/arc-options.rst @@ -0,0 +1,759 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: ARC + +.. index:: ARC options + +.. _arc-options: + +ARC Options +^^^^^^^^^^^ + +The following options control the architecture variant for which code +is being compiled: + +.. architecture variants + +.. option:: -mbarrel-shifter + + Generate instructions supported by barrel shifter. This is the default + unless :option:`-mcpu=ARC601` or :samp:`-mcpu=ARCEM` is in effect. + +.. option:: -mjli-always + + Force to call a function using jli_s instruction. This option is + valid only for ARCv2 architecture. + +.. option:: -mcpu={cpu} + + Set architecture type, register usage, and instruction scheduling + parameters for :samp:`{cpu}`. There are also shortcut alias options + available for backward compatibility and convenience. Supported + values for :samp:`{cpu}` are + + .. index:: mA6, mARC600 + + :samp:`arc600` + Compile for ARC600. Aliases: :option:`-mA6`, :option:`-mARC600`. + + :samp:`arc601` + Compile for ARC601. Alias: :option:`-mARC601`. + + :samp:`arc700` + Compile for ARC700. Aliases: :option:`-mA7`, :option:`-mARC700`. + This is the default when configured with :option:`--with-cpu=arc700`. + + :samp:`arcem` + Compile for ARC EM. + + :samp:`archs` + Compile for ARC HS. + + :samp:`em` + Compile for ARC EM CPU with no hardware extensions. + + :samp:`em4` + Compile for ARC EM4 CPU. + + :samp:`em4_dmips` + Compile for ARC EM4 DMIPS CPU. + + :samp:`em4_fpus` + Compile for ARC EM4 DMIPS CPU with the single-precision floating-point + extension. + + :samp:`em4_fpuda` + Compile for ARC EM4 DMIPS CPU with single-precision floating-point and + double assist instructions. + + :samp:`hs` + Compile for ARC HS CPU with no hardware extensions except the atomic + instructions. + + :samp:`hs34` + Compile for ARC HS34 CPU. + + :samp:`hs38` + Compile for ARC HS38 CPU. + + :samp:`hs38_linux` + Compile for ARC HS38 CPU with all hardware extensions on. + + :samp:`hs4x` + Compile for ARC HS4x CPU. + + :samp:`hs4xd` + Compile for ARC HS4xD CPU. + + :samp:`hs4x_rel31` + Compile for ARC HS4x CPU release 3.10a. + + :samp:`arc600_norm` + Compile for ARC 600 CPU with ``norm`` instructions enabled. + + :samp:`arc600_mul32x16` + Compile for ARC 600 CPU with ``norm`` and 32x16-bit multiply + instructions enabled. + + :samp:`arc600_mul64` + Compile for ARC 600 CPU with ``norm`` and ``mul64`` -family + instructions enabled. + + :samp:`arc601_norm` + Compile for ARC 601 CPU with ``norm`` instructions enabled. + + :samp:`arc601_mul32x16` + Compile for ARC 601 CPU with ``norm`` and 32x16-bit multiply + instructions enabled. + + :samp:`arc601_mul64` + Compile for ARC 601 CPU with ``norm`` and ``mul64`` -family + instructions enabled. + + :samp:`nps400` + Compile for ARC 700 on NPS400 chip. + + :samp:`em_mini` + Compile for ARC EM minimalist configuration featuring reduced register + set. + +.. option:: -mdpfp, -mdpfp-compact + + Generate double-precision FPX instructions, tuned for the compact + implementation. + +.. option:: -mdpfp-fast + + Generate double-precision FPX instructions, tuned for the fast + implementation. + +.. option:: -mno-dpfp-lrsr + + Disable ``lr`` and ``sr`` instructions from using FPX extension + aux registers. + +.. option:: -mea + + Generate extended arithmetic instructions. Currently only + ``divaw``, ``adds``, ``subs``, and ``sat16`` are + supported. Only valid for :option:`-mcpu=ARC700`. + +.. option:: -mno-mpy + + Do not generate ``mpy`` -family instructions for ARC700. This option is + deprecated. + +.. option:: -mmpy + + Default setting; overrides :option:`-mno-mpy`. + +.. option:: -mmul32x16 + + Generate 32x16-bit multiply and multiply-accumulate instructions. + +.. option:: -mmul64 + + Generate ``mul64`` and ``mulu64`` instructions. + Only valid for :option:`-mcpu=ARC600`. + +.. option:: -mnorm + + Generate ``norm`` instructions. This is the default if :option:`-mcpu=ARC700` + is in effect. + +.. option:: -mspfp, -mspfp-compact + + Generate single-precision FPX instructions, tuned for the compact + implementation. + +.. option:: -mspfp-fast + + Generate single-precision FPX instructions, tuned for the fast + implementation. + +.. option:: -msimd + + Enable generation of ARC SIMD instructions via target-specific + builtins. Only valid for :option:`-mcpu=ARC700`. + +.. option:: -msoft-float + + This option ignored; it is provided for compatibility purposes only. + Software floating-point code is emitted by default, and this default + can overridden by FPX options; :option:`-mspfp`, :option:`-mspfp-compact`, or + :option:`-mspfp-fast` for single precision, and :option:`-mdpfp`, + :option:`-mdpfp-compact`, or :option:`-mdpfp-fast` for double precision. + +.. option:: -mswap + + Generate ``swap`` instructions. + +.. option:: -matomic + + This enables use of the locked load/store conditional extension to implement + atomic memory built-in functions. Not available for ARC 6xx or ARC + EM cores. + +.. option:: -mdiv-rem + + Enable ``div`` and ``rem`` instructions for ARCv2 cores. + +.. option:: -mcode-density + + Enable code density instructions for ARC EM. + This option is on by default for ARC HS. + +.. option:: -mll64 + + Enable double load/store operations for ARC HS cores. + +.. option:: -mtp-regno={regno} + + Specify thread pointer register number. + +.. option:: -mmpy-option={multo} + + Compile ARCv2 code with a multiplier design option. You can specify + the option using either a string or numeric value for :samp:`{multo}`. + :samp:`wlh1` is the default value. The recognized values are: + + :samp:`0` :samp:`none` + No multiplier available. + + :samp:`1` :samp:`w` + 16x16 multiplier, fully pipelined. + The following instructions are enabled: ``mpyw`` and ``mpyuw``. + + :samp:`2` :samp:`wlh1` + 32x32 multiplier, fully + pipelined (1 stage). The following instructions are additionally + enabled: ``mpy``, ``mpyu``, ``mpym``, ``mpymu``, and ``mpy_s``. + + :samp:`3` :samp:`wlh2` + 32x32 multiplier, fully pipelined + (2 stages). The following instructions are additionally enabled: ``mpy``, + ``mpyu``, ``mpym``, ``mpymu``, and ``mpy_s``. + + :samp:`4` :samp:`wlh3` + Two 16x16 multipliers, blocking, + sequential. The following instructions are additionally enabled: ``mpy``, + ``mpyu``, ``mpym``, ``mpymu``, and ``mpy_s``. + + :samp:`5` :samp:`wlh4` + One 16x16 multiplier, blocking, + sequential. The following instructions are additionally enabled: ``mpy``, + ``mpyu``, ``mpym``, ``mpymu``, and ``mpy_s``. + + :samp:`6` :samp:`wlh5` + One 32x4 multiplier, blocking, + sequential. The following instructions are additionally enabled: ``mpy``, + ``mpyu``, ``mpym``, ``mpymu``, and ``mpy_s``. + + :samp:`7` :samp:`plus_dmpy` + ARC HS SIMD support. + + :samp:`8` :samp:`plus_macd` + ARC HS SIMD support. + + :samp:`9` :samp:`plus_qmacw` + ARC HS SIMD support. + + This option is only available for ARCv2 cores. + +.. option:: -mfpu={fpu} + + Enables support for specific floating-point hardware extensions for ARCv2 + cores. Supported values for :samp:`{fpu}` are: + + :samp:`fpus` + Enables support for single-precision floating-point hardware + extensions. + + :samp:`fpud` + Enables support for double-precision floating-point hardware + extensions. The single-precision floating-point extension is also + enabled. Not available for ARC EM. + + :samp:`fpuda` + Enables support for double-precision floating-point hardware + extensions using double-precision assist instructions. The single-precision + floating-point extension is also enabled. This option is + only available for ARC EM. + + :samp:`fpuda_div` + Enables support for double-precision floating-point hardware + extensions using double-precision assist instructions. + The single-precision floating-point, square-root, and divide + extensions are also enabled. This option is + only available for ARC EM. + + :samp:`fpuda_fma` + Enables support for double-precision floating-point hardware + extensions using double-precision assist instructions. + The single-precision floating-point and fused multiply and add + hardware extensions are also enabled. This option is + only available for ARC EM. + + :samp:`fpuda_all` + Enables support for double-precision floating-point hardware + extensions using double-precision assist instructions. + All single-precision floating-point hardware extensions are also + enabled. This option is only available for ARC EM. + + :samp:`fpus_div` + Enables support for single-precision floating-point, square-root and divide + hardware extensions. + + :samp:`fpud_div` + Enables support for double-precision floating-point, square-root and divide + hardware extensions. This option + includes option :samp:`fpus_div`. Not available for ARC EM. + + :samp:`fpus_fma` + Enables support for single-precision floating-point and + fused multiply and add hardware extensions. + + :samp:`fpud_fma` + Enables support for double-precision floating-point and + fused multiply and add hardware extensions. This option + includes option :samp:`fpus_fma`. Not available for ARC EM. + + :samp:`fpus_all` + Enables support for all single-precision floating-point hardware + extensions. + + :samp:`fpud_all` + Enables support for all single- and double-precision floating-point + hardware extensions. Not available for ARC EM. + +.. option:: -mirq-ctrl-saved={register-range},{blink},{lp_count} + + Specifies general-purposes registers that the processor automatically + saves/restores on interrupt entry and exit. :samp:`{register-range}` is + specified as two registers separated by a dash. The register range + always starts with ``r0``, the upper limit is ``fp`` register. + :samp:`{blink}` and :samp:`{lp_count}` are optional. This option is only + valid for ARC EM and ARC HS cores. + +.. option:: -mrgf-banked-regs={number} + + Specifies the number of registers replicated in second register bank + on entry to fast interrupt. Fast interrupts are interrupts with the + highest priority level P0. These interrupts save only PC and STATUS32 + registers to avoid memory transactions during interrupt entry and exit + sequences. Use this option when you are using fast interrupts in an + ARC V2 family processor. Permitted values are 4, 8, 16, and 32. + +.. option:: -mlpc-width={width} + + Specify the width of the ``lp_count`` register. Valid values for + :samp:`{width}` are 8, 16, 20, 24, 28 and 32 bits. The default width is + fixed to 32 bits. If the width is less than 32, the compiler does not + attempt to transform loops in your program to use the zero-delay loop + mechanism unless it is known that the ``lp_count`` register can + hold the required loop-counter value. Depending on the width + specified, the compiler and run-time library might continue to use the + loop mechanism for various needs. This option defines macro + ``__ARC_LPC_WIDTH__`` with the value of :samp:`{width}`. + +.. option:: -mrf16 + + This option instructs the compiler to generate code for a 16-entry + register file. This option defines the ``__ARC_RF16__`` + preprocessor macro. + +.. option:: -mbranch-index + + Enable use of ``bi`` or ``bih`` instructions to implement jump + tables. + +The following options are passed through to the assembler, and also +define preprocessor macro symbols. + +.. Flags used by the assembler, but for which we define preprocessor + macro symbols as well. + +.. option:: -mdsp-packa + + Passed down to the assembler to enable the DSP Pack A extensions. + Also sets the preprocessor symbol ``__Xdsp_packa``. This option is + deprecated. + +.. option:: -mdvbf + + Passed down to the assembler to enable the dual Viterbi butterfly + extension. Also sets the preprocessor symbol ``__Xdvbf``. This + option is deprecated. + + .. ARC700 4.10 extension instruction + +.. option:: -mlock + + Passed down to the assembler to enable the locked load/store + conditional extension. Also sets the preprocessor symbol + ``__Xlock``. + +.. option:: -mmac-d16 + + Passed down to the assembler. Also sets the preprocessor symbol + ``__Xxmac_d16``. This option is deprecated. + +.. option:: -mmac-24 + + Passed down to the assembler. Also sets the preprocessor symbol + ``__Xxmac_24``. This option is deprecated. + + .. ARC700 4.10 extension instruction + +.. option:: -mrtsc + + Passed down to the assembler to enable the 64-bit time-stamp counter + extension instruction. Also sets the preprocessor symbol + ``__Xrtsc``. This option is deprecated. + + .. ARC700 4.10 extension instruction + +.. option:: -mswape + + Passed down to the assembler to enable the swap byte ordering + extension instruction. Also sets the preprocessor symbol + ``__Xswape``. + +.. option:: -mtelephony + + Passed down to the assembler to enable dual- and single-operand + instructions for telephony. Also sets the preprocessor symbol + ``__Xtelephony``. This option is deprecated. + +.. option:: -mxy + + Passed down to the assembler to enable the XY memory extension. Also + sets the preprocessor symbol ``__Xxy``. + +The following options control how the assembly code is annotated: + +.. Assembly annotation options + +.. option:: -misize + + Annotate assembler instructions with estimated addresses. + +.. option:: -mannotate-align + + Explain what alignment considerations lead to the decision to make an + instruction short or long. + +The following options are passed through to the linker: + +.. options passed through to the linker + +.. option:: -marclinux + + Passed through to the linker, to specify use of the ``arclinux`` emulation. + This option is enabled by default in tool chains built for + ``arc-linux-uclibc`` and ``arceb-linux-uclibc`` targets + when profiling is not requested. + +.. option:: -marclinux_prof + + Passed through to the linker, to specify use of the + ``arclinux_prof`` emulation. This option is enabled by default in + tool chains built for ``arc-linux-uclibc`` and + ``arceb-linux-uclibc`` targets when profiling is requested. + +The following options control the semantics of generated code: + +.. semantically relevant code generation options + +.. option:: -mlong-calls + + Generate calls as register indirect calls, thus providing access + to the full 32-bit address range. + +.. option:: -mmedium-calls + + Don't use less than 25-bit addressing range for calls, which is the + offset available for an unconditional branch-and-link + instruction. Conditional execution of function calls is suppressed, to + allow use of the 25-bit range, rather than the 21-bit range with + conditional branch-and-link. This is the default for tool chains built + for ``arc-linux-uclibc`` and ``arceb-linux-uclibc`` targets. + +.. option:: -G {num} + + Put definitions of externally-visible data in a small data section if + that data is no bigger than :samp:`{num}` bytes. The default value of + :samp:`{num}` is 4 for any ARC configuration, or 8 when we have double + load/store operations. + +.. option:: -mno-sdata + + Do not generate sdata references. This is the default for tool chains + built for ``arc-linux-uclibc`` and ``arceb-linux-uclibc`` + targets. + +.. option:: -msdata + + Default setting; overrides :option:`-mno-sdata`. + +.. option:: -mvolatile-cache + + Use ordinarily cached memory accesses for volatile references. This is the + default. + +.. option:: -mno-volatile-cache + + Enable cache bypass for volatile references. + +.. option:: -mvolatile-cache + + Default setting; overrides :option:`-mno-volatile-cache`. + +The following options fine tune code generation: + +.. code generation tuning options + +.. option:: -malign-call + + Does nothing. Preserved for backward compatibility. + +.. option:: -mauto-modify-reg + + Enable the use of pre/post modify with register displacement. + +.. option:: -mbbit-peephole + + Enable bbit peephole2. + +.. option:: -mno-brcc + + This option disables a target-specific pass in :samp:`arc_reorg` to + generate compare-and-branch (``brcc``) instructions. + It has no effect on + generation of these instructions driven by the combiner pass. + +.. option:: -mcase-vector-pcrel + + Use PC-relative switch case tables to enable case table shortening. + This is the default for :option:`-Os`. + +.. option:: -mcompact-casesi + + Enable compact ``casesi`` pattern. This is the default for :option:`-Os`, + and only available for ARCv1 cores. This option is deprecated. + +.. option:: -mno-cond-exec + + Disable the ARCompact-specific pass to generate conditional + execution instructions. + + Due to delay slot scheduling and interactions between operand numbers, + literal sizes, instruction lengths, and the support for conditional execution, + the target-independent pass to generate conditional execution is often lacking, + so the ARC port has kept a special pass around that tries to find more + conditional execution generation opportunities after register allocation, + branch shortening, and delay slot scheduling have been done. This pass + generally, but not always, improves performance and code size, at the cost of + extra compilation time, which is why there is an option to switch it off. + If you have a problem with call instructions exceeding their allowable + offset range because they are conditionalized, you should consider using + :option:`-mmedium-calls` instead. + +.. option:: -mearly-cbranchsi + + Enable pre-reload use of the ``cbranchsi`` pattern. + +.. option:: -mexpand-adddi + + Expand ``adddi3`` and ``subdi3`` at RTL generation time into + ``add.f``, ``adc`` etc. This option is deprecated. + +.. option:: -mindexed-loads + + Enable the use of indexed loads. This can be problematic because some + optimizers then assume that indexed stores exist, which is not + the case. + +.. option:: -mlra + + Enable Local Register Allocation. This is still experimental for ARC, + so by default the compiler uses standard reload + (i.e. :option:`-mno-lra`). + +.. option:: -mlra-priority-none + + Don't indicate any priority for target registers. + +.. option:: -mlra-priority-compact + + Indicate target register priority for ``r0`` .. ``r3`` / ``r12`` .. ``r15``. + +.. option:: -mlra-priority-noncompact + + Reduce target register priority for ``r0`` .. ``r3`` / ``r12`` .. ``r15``. + +.. option:: -mmillicode + + When optimizing for size (using :option:`-Os`), prologues and epilogues + that have to save or restore a large number of registers are often + shortened by using call to a special function in libgcc; this is + referred to as a *millicode* call. As these calls can pose + performance issues, and/or cause linking issues when linking in a + nonstandard way, this option is provided to turn on or off millicode + call generation. + +.. option:: -mcode-density-frame + + This option enable the compiler to emit ``enter`` and ``leave`` + instructions. These instructions are only valid for CPUs with + code-density feature. + +.. option:: -mmixed-code + + Does nothing. Preserved for backward compatibility. + +.. option:: -mq-class + + Ths option is deprecated. Enable :samp:`q` instruction alternatives. + This is the default for :option:`-Os`. + +.. option:: -mRcq + + Does nothing. Preserved for backward compatibility. + +.. option:: -mRcw + + Does nothing. Preserved for backward compatibility. + +.. option:: -msize-level={level} + + Fine-tune size optimization with regards to instruction lengths and alignment. + The recognized values for :samp:`{level}` are: + + :samp:`0` + No size optimization. This level is deprecated and treated like :samp:`1`. + + :samp:`1` + Short instructions are used opportunistically. + + :samp:`2` + In addition, alignment of loops and of code after barriers are dropped. + + :samp:`3` + In addition, optional data alignment is dropped, and the option Os is enabled. + + This defaults to :samp:`3` when :option:`-Os` is in effect. Otherwise, + the behavior when this is not set is equivalent to level :samp:`1`. + +.. option:: -mtune={cpu} + + Set instruction scheduling parameters for :samp:`{cpu}`, overriding any implied + by :option:`-mcpu=`. + + Supported values for :samp:`{cpu}` are + + :samp:`ARC600` + Tune for ARC600 CPU. + + :samp:`ARC601` + Tune for ARC601 CPU. + + :samp:`ARC700` + Tune for ARC700 CPU with standard multiplier block. + + :samp:`ARC700-xmac` + Tune for ARC700 CPU with XMAC block. + + :samp:`ARC725D` + Tune for ARC725D CPU. + + :samp:`ARC750D` + Tune for ARC750D CPU. + + :samp:`core3` + Tune for ARCv2 core3 type CPU. This option enable usage of + ``dbnz`` instruction. + + :samp:`release31a` + Tune for ARC4x release 3.10a. + +.. option:: -mmultcost={num} + + Cost to assume for a multiply instruction, with :samp:`4` being equal to a + normal instruction. + +.. option:: -munalign-prob-threshold={probability} + + Does nothing. Preserved for backward compatibility. + +The following options are maintained for backward compatibility, but +are now deprecated and will be removed in a future release: + +.. Deprecated options + +.. option:: -margonaut + + Obsolete FPX. + +.. option:: -mbig-endian, -EB + + Compile code for big-endian targets. Use of these options is now + deprecated. Big-endian code is supported by configuring GCC to build + ``arceb-elf32`` and ``arceb-linux-uclibc`` targets, + for which big endian is the default. + +.. option:: -mlittle-endian, -EL + + Compile code for little-endian targets. Use of these options is now + deprecated. Little-endian code is supported by configuring GCC to build + ``arc-elf32`` and ``arc-linux-uclibc`` targets, + for which little endian is the default. + +.. option:: -mbarrel_shifter + + Replaced by :option:`-mbarrel-shifter`. + +.. option:: -mdpfp_compact + + Replaced by :option:`-mdpfp-compact`. + +.. option:: -mdpfp_fast + + Replaced by :option:`-mdpfp-fast`. + +.. option:: -mdsp_packa + + Replaced by :option:`-mdsp-packa`. + +.. option:: -mEA + + Replaced by :option:`-mea`. + +.. option:: -mmac_24 + + Replaced by :option:`-mmac-24`. + +.. option:: -mmac_d16 + + Replaced by :option:`-mmac-d16`. + +.. option:: -mspfp_compact + + Replaced by :option:`-mspfp-compact`. + +.. option:: -mspfp_fast + + Replaced by :option:`-mspfp-fast`. + +.. option:: -mtune={cpu} + + Values :samp:`arc600`, :samp:`arc601`, :samp:`arc700` and + :samp:`arc700-xmac` for :samp:`{cpu}` are replaced by :samp:`ARC600`, + :samp:`ARC601`, :samp:`ARC700` and :samp:`ARC700-xmac` respectively. + +.. option:: -multcost={num} + + Replaced by :option:`-mmultcost`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/arm-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/arm-options.rst new file mode 100644 index 00000000000..398b0da0133 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/arm-options.rst @@ -0,0 +1,1037 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: ARM + +.. index:: ARM options + +.. _arm-options: + +ARM Options +^^^^^^^^^^^ + +These :samp:`-m` options are defined for the ARM port: + +.. option:: -mabi={name} + + Generate code for the specified ABI. Permissible values are: :samp:`apcs-gnu`, + :samp:`atpcs`, :samp:`aapcs`, :samp:`aapcs-linux` and :samp:`iwmmxt`. + +.. option:: -mapcs-frame + + Generate a stack frame that is compliant with the ARM Procedure Call + Standard for all functions, even if this is not strictly necessary for + correct execution of the code. Specifying :option:`-fomit-frame-pointer` + with this option causes the stack frames not to be generated for + leaf functions. The default is :option:`-mno-apcs-frame`. + This option is deprecated. + +.. option:: -mapcs + + This is a synonym for :option:`-mapcs-frame` and is deprecated. + +.. option:: -mapcs-stack-check + + Generate code to check the amount of stack space available upon entry to + every function (that actually uses some stack space). If there is + insufficient space available then either the function + ``__rt_stkovf_split_small`` or ``__rt_stkovf_split_big`` is + called, depending upon the amount of stack space required. The runtime + system is required to provide these functions. The default is + :option:`-mno-apcs-stack-check`, since this produces smaller code. + +.. option:: -mapcs-reentrant + + Generate reentrant, position-independent code. The default is + :option:`-mno-apcs-reentrant`. + +.. option:: -mthumb-interwork + + Generate code that supports calling between the ARM and Thumb + instruction sets. Without this option, on pre-v5 architectures, the + two instruction sets cannot be reliably used inside one program. The + default is :option:`-mno-thumb-interwork`, since slightly larger code + is generated when :option:`-mthumb-interwork` is specified. In AAPCS + configurations this option is meaningless. + +.. option:: -mno-sched-prolog + + Prevent the reordering of instructions in the function prologue, or the + merging of those instruction with the instructions in the function's + body. This means that all functions start with a recognizable set + of instructions (or in fact one of a choice from a small set of + different function prologues), and this information can be used to + locate the start of functions inside an executable piece of code. The + default is :option:`-msched-prolog`. + +.. option:: -msched-prolog + + Default setting; overrides :option:`-mno-sched-prolog`. + +.. option:: -mfloat-abi={name} + + Specifies which floating-point ABI to use. Permissible values + are: :samp:`soft`, :samp:`softfp` and :samp:`hard`. + + Specifying :samp:`soft` causes GCC to generate output containing + library calls for floating-point operations. + :samp:`softfp` allows the generation of code using hardware floating-point + instructions, but still uses the soft-float calling conventions. + :samp:`hard` allows generation of floating-point instructions + and uses FPU-specific calling conventions. + + The default depends on the specific target configuration. Note that + the hard-float and soft-float ABIs are not link-compatible; you must + compile your entire program with the same ABI, and link with a + compatible set of libraries. + +.. option:: -mgeneral-regs-only + + Generate code which uses only the general-purpose registers. This will prevent + the compiler from using floating-point and Advanced SIMD registers but will not + impose any restrictions on the assembler. + +.. option:: -mlittle-endian + + Generate code for a processor running in little-endian mode. This is + the default for all standard configurations. + +.. option:: -mbig-endian + + Generate code for a processor running in big-endian mode; the default is + to compile code for a little-endian processor. + +.. option:: -mbe8, -mbe32 + + When linking a big-endian image select between BE8 and BE32 formats. + The option has no effect for little-endian images and is ignored. The + default is dependent on the selected target architecture. For ARMv6 + and later architectures the default is BE8, for older architectures + the default is BE32. BE32 format has been deprecated by ARM. + +.. option:: -march={name}[+extension...] + + This specifies the name of the target ARM architecture. GCC uses this + name to determine what kind of instructions it can emit when generating + assembly code. This option can be used in conjunction with or instead + of the :option:`-mcpu=` option. + + Permissible names are: + :samp:`armv4t`, + :samp:`armv5t`, :samp:`armv5te`, + :samp:`armv6`, :samp:`armv6j`, :samp:`armv6k`, :samp:`armv6kz`, :samp:`armv6t2`, + :samp:`armv6z`, :samp:`armv6zk`, + :samp:`armv7`, :samp:`armv7-a`, :samp:`armv7ve`, + :samp:`armv8-a`, :samp:`armv8.1-a`, :samp:`armv8.2-a`, :samp:`armv8.3-a`, + :samp:`armv8.4-a`, + :samp:`armv8.5-a`, + :samp:`armv8.6-a`, + :samp:`armv9-a`, + :samp:`armv7-r`, + :samp:`armv8-r`, + :samp:`armv6-m`, :samp:`armv6s-m`, + :samp:`armv7-m`, :samp:`armv7e-m`, + :samp:`armv8-m.base`, :samp:`armv8-m.main`, + :samp:`armv8.1-m.main`, + :samp:`armv9-a`, + :samp:`iwmmxt` and :samp:`iwmmxt2`. + + Additionally, the following architectures, which lack support for the + Thumb execution state, are recognized but support is deprecated: :samp:`armv4`. + + Many of the architectures support extensions. These can be added by + appending :samp:`+{extension}` to the architecture name. Extension + options are processed in order and capabilities accumulate. An extension + will also enable any necessary base extensions + upon which it depends. For example, the :samp:`+crypto` extension + will always enable the :samp:`+simd` extension. The exception to the + additive construction is for extensions that are prefixed with + :samp:`+no...`: these extensions disable the specified option and + any other extensions that may depend on the presence of that + extension. + + For example, :samp:`-march=armv7-a+simd+nofp+vfpv4` is equivalent to + writing :samp:`-march=armv7-a+vfpv4` since the :samp:`+simd` option is + entirely disabled by the :samp:`+nofp` option that follows it. + + Most extension names are generically named, but have an effect that is + dependent upon the architecture to which it is applied. For example, + the :samp:`+simd` option can be applied to both :samp:`armv7-a` and + :samp:`armv8-a` architectures, but will enable the original ARMv7-A + Advanced SIMD (Neon) extensions for :samp:`armv7-a` and the ARMv8-A + variant for :samp:`armv8-a`. + + The table below lists the supported extensions for each architecture. + Architectures not mentioned do not support any extensions. + + :samp:`armv5te` :samp:`armv6` :samp:`armv6j` :samp:`armv6k` :samp:`armv6kz` :samp:`armv6t2` :samp:`armv6z` :samp:`armv6zk` + :samp:`+fp` + The VFPv2 floating-point instructions. The extension :samp:`+vfpv2` can be + used as an alias for this extension. + + :samp:`+nofp` + Disable the floating-point instructions. + + :samp:`armv7` + The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures. + + :samp:`+fp` + The VFPv3 floating-point instructions, with 16 double-precision + registers. The extension :samp:`+vfpv3-d16` can be used as an alias + for this extension. Note that floating-point is not supported by the + base ARMv7-M architecture, but is compatible with both the ARMv7-A and + ARMv7-R architectures. + + :samp:`+nofp` + Disable the floating-point instructions. + + :samp:`armv7-a` + :samp:`+mp` + The multiprocessing extension. + + :samp:`+sec` + The security extension. + + :samp:`+fp` + The VFPv3 floating-point instructions, with 16 double-precision + registers. The extension :samp:`+vfpv3-d16` can be used as an alias + for this extension. + + :samp:`+simd` + The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. + The extensions :samp:`+neon` and :samp:`+neon-vfpv3` can be used as aliases + for this extension. + + :samp:`+vfpv3` + The VFPv3 floating-point instructions, with 32 double-precision + registers. + + :samp:`+vfpv3-d16-fp16` + The VFPv3 floating-point instructions, with 16 double-precision + registers and the half-precision floating-point conversion operations. + + :samp:`+vfpv3-fp16` + The VFPv3 floating-point instructions, with 32 double-precision + registers and the half-precision floating-point conversion operations. + + :samp:`+vfpv4-d16` + The VFPv4 floating-point instructions, with 16 double-precision + registers. + + :samp:`+vfpv4` + The VFPv4 floating-point instructions, with 32 double-precision + registers. + + :samp:`+neon-fp16` + The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with + the half-precision floating-point conversion operations. + + :samp:`+neon-vfpv4` + The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. + + :samp:`+nosimd` + Disable the Advanced SIMD instructions (does not disable floating point). + + :samp:`+nofp` + Disable the floating-point and Advanced SIMD instructions. + + :samp:`armv7ve` + The extended version of the ARMv7-A architecture with support for + virtualization. + + :samp:`+fp` + The VFPv4 floating-point instructions, with 16 double-precision registers. + The extension :samp:`+vfpv4-d16` can be used as an alias for this extension. + + :samp:`+simd` + The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The + extension :samp:`+neon-vfpv4` can be used as an alias for this extension. + + :samp:`+vfpv3-d16` + The VFPv3 floating-point instructions, with 16 double-precision + registers. + + :samp:`+vfpv3` + The VFPv3 floating-point instructions, with 32 double-precision + registers. + + :samp:`+vfpv3-d16-fp16` + The VFPv3 floating-point instructions, with 16 double-precision + registers and the half-precision floating-point conversion operations. + + :samp:`+vfpv3-fp16` + The VFPv3 floating-point instructions, with 32 double-precision + registers and the half-precision floating-point conversion operations. + + :samp:`+vfpv4-d16` + The VFPv4 floating-point instructions, with 16 double-precision + registers. + + :samp:`+vfpv4` + The VFPv4 floating-point instructions, with 32 double-precision + registers. + + :samp:`+neon` + The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. + The extension :samp:`+neon-vfpv3` can be used as an alias for this extension. + + :samp:`+neon-fp16` + The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with + the half-precision floating-point conversion operations. + + :samp:`+nosimd` + Disable the Advanced SIMD instructions (does not disable floating point). + + :samp:`+nofp` + Disable the floating-point and Advanced SIMD instructions. + + :samp:`armv8-a` + :samp:`+crc` + The Cyclic Redundancy Check (CRC) instructions. + + :samp:`+simd` + The ARMv8-A Advanced SIMD and floating-point instructions. + + :samp:`+crypto` + The cryptographic instructions. + + :samp:`+nocrypto` + Disable the cryptographic instructions. + + :samp:`+nofp` + Disable the floating-point, Advanced SIMD and cryptographic instructions. + + :samp:`+sb` + Speculation Barrier Instruction. + + :samp:`+predres` + Execution and Data Prediction Restriction Instructions. + + :samp:`armv8.1-a` + :samp:`+simd` + The ARMv8.1-A Advanced SIMD and floating-point instructions. + + :samp:`+crypto` + The cryptographic instructions. This also enables the Advanced SIMD and + floating-point instructions. + + :samp:`+nocrypto` + Disable the cryptographic instructions. + + :samp:`+nofp` + Disable the floating-point, Advanced SIMD and cryptographic instructions. + + :samp:`+sb` + Speculation Barrier Instruction. + + :samp:`+predres` + Execution and Data Prediction Restriction Instructions. + + :samp:`armv8.2-a` :samp:`armv8.3-a` + :samp:`+fp16` + The half-precision floating-point data processing instructions. + This also enables the Advanced SIMD and floating-point instructions. + + :samp:`+fp16fml` + The half-precision floating-point fmla extension. This also enables + the half-precision floating-point extension and Advanced SIMD and + floating-point instructions. + + :samp:`+simd` + The ARMv8.1-A Advanced SIMD and floating-point instructions. + + :samp:`+crypto` + The cryptographic instructions. This also enables the Advanced SIMD and + floating-point instructions. + + :samp:`+dotprod` + Enable the Dot Product extension. This also enables Advanced SIMD instructions. + + :samp:`+nocrypto` + Disable the cryptographic extension. + + :samp:`+nofp` + Disable the floating-point, Advanced SIMD and cryptographic instructions. + + :samp:`+sb` + Speculation Barrier Instruction. + + :samp:`+predres` + Execution and Data Prediction Restriction Instructions. + + :samp:`+i8mm` + 8-bit Integer Matrix Multiply instructions. + This also enables Advanced SIMD and floating-point instructions. + + :samp:`+bf16` + Brain half-precision floating-point instructions. + This also enables Advanced SIMD and floating-point instructions. + + :samp:`armv8.4-a` + :samp:`+fp16` + The half-precision floating-point data processing instructions. + This also enables the Advanced SIMD and floating-point instructions as well + as the Dot Product extension and the half-precision floating-point fmla + extension. + + :samp:`+simd` + The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the + Dot Product extension. + + :samp:`+crypto` + The cryptographic instructions. This also enables the Advanced SIMD and + floating-point instructions as well as the Dot Product extension. + + :samp:`+nocrypto` + Disable the cryptographic extension. + + :samp:`+nofp` + Disable the floating-point, Advanced SIMD and cryptographic instructions. + + :samp:`+sb` + Speculation Barrier Instruction. + + :samp:`+predres` + Execution and Data Prediction Restriction Instructions. + + :samp:`+i8mm` + 8-bit Integer Matrix Multiply instructions. + This also enables Advanced SIMD and floating-point instructions. + + :samp:`+bf16` + Brain half-precision floating-point instructions. + This also enables Advanced SIMD and floating-point instructions. + + :samp:`armv8.5-a` + :samp:`+fp16` + The half-precision floating-point data processing instructions. + This also enables the Advanced SIMD and floating-point instructions as well + as the Dot Product extension and the half-precision floating-point fmla + extension. + + :samp:`+simd` + The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the + Dot Product extension. + + :samp:`+crypto` + The cryptographic instructions. This also enables the Advanced SIMD and + floating-point instructions as well as the Dot Product extension. + + :samp:`+nocrypto` + Disable the cryptographic extension. + + :samp:`+nofp` + Disable the floating-point, Advanced SIMD and cryptographic instructions. + + :samp:`+i8mm` + 8-bit Integer Matrix Multiply instructions. + This also enables Advanced SIMD and floating-point instructions. + + :samp:`+bf16` + Brain half-precision floating-point instructions. + This also enables Advanced SIMD and floating-point instructions. + + :samp:`armv8.6-a` + :samp:`+fp16` + The half-precision floating-point data processing instructions. + This also enables the Advanced SIMD and floating-point instructions as well + as the Dot Product extension and the half-precision floating-point fmla + extension. + + :samp:`+simd` + The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the + Dot Product extension. + + :samp:`+crypto` + The cryptographic instructions. This also enables the Advanced SIMD and + floating-point instructions as well as the Dot Product extension. + + :samp:`+nocrypto` + Disable the cryptographic extension. + + :samp:`+nofp` + Disable the floating-point, Advanced SIMD and cryptographic instructions. + + :samp:`+i8mm` + 8-bit Integer Matrix Multiply instructions. + This also enables Advanced SIMD and floating-point instructions. + + :samp:`+bf16` + Brain half-precision floating-point instructions. + This also enables Advanced SIMD and floating-point instructions. + + :samp:`armv7-r` + :samp:`+fp.sp` + The single-precision VFPv3 floating-point instructions. The extension + :samp:`+vfpv3xd` can be used as an alias for this extension. + + :samp:`+fp` + The VFPv3 floating-point instructions with 16 double-precision registers. + The extension +vfpv3-d16 can be used as an alias for this extension. + + :samp:`+vfpv3xd-d16-fp16` + The single-precision VFPv3 floating-point instructions with 16 double-precision + registers and the half-precision floating-point conversion operations. + + :samp:`+vfpv3-d16-fp16` + The VFPv3 floating-point instructions with 16 double-precision + registers and the half-precision floating-point conversion operations. + + :samp:`+nofp` + Disable the floating-point extension. + + :samp:`+idiv` + The ARM-state integer division instructions. + + :samp:`+noidiv` + Disable the ARM-state integer division extension. + + :samp:`armv7e-m` + :samp:`+fp` + The single-precision VFPv4 floating-point instructions. + + :samp:`+fpv5` + The single-precision FPv5 floating-point instructions. + + :samp:`+fp.dp` + The single- and double-precision FPv5 floating-point instructions. + + :samp:`+nofp` + Disable the floating-point extensions. + + :samp:`armv8.1-m.main` + :samp:`+dsp` + The DSP instructions. + + :samp:`+mve` + The M-Profile Vector Extension (MVE) integer instructions. + + :samp:`+mve.fp` + The M-Profile Vector Extension (MVE) integer and single precision + floating-point instructions. + + :samp:`+fp` + The single-precision floating-point instructions. + + :samp:`+fp.dp` + The single- and double-precision floating-point instructions. + + :samp:`+nofp` + Disable the floating-point extension. + + :samp:`+cdecp0, +cdecp1, ... , +cdecp7` + Enable the Custom Datapath Extension (CDE) on selected coprocessors according + to the numbers given in the options in the range 0 to 7. + + :samp:`armv8-m.main` + :samp:`+dsp` + The DSP instructions. + + :samp:`+nodsp` + Disable the DSP extension. + + :samp:`+fp` + The single-precision floating-point instructions. + + :samp:`+fp.dp` + The single- and double-precision floating-point instructions. + + :samp:`+nofp` + Disable the floating-point extension. + + :samp:`+cdecp0, +cdecp1, ... , +cdecp7` + Enable the Custom Datapath Extension (CDE) on selected coprocessors according + to the numbers given in the options in the range 0 to 7. + + :samp:`armv8-r` + :samp:`+crc` + The Cyclic Redundancy Check (CRC) instructions. + + :samp:`+fp.sp` + The single-precision FPv5 floating-point instructions. + + :samp:`+simd` + The ARMv8-A Advanced SIMD and floating-point instructions. + + :samp:`+crypto` + The cryptographic instructions. + + :samp:`+nocrypto` + Disable the cryptographic instructions. + + :samp:`+nofp` + Disable the floating-point, Advanced SIMD and cryptographic instructions. + + :option:`-march=native` causes the compiler to auto-detect the architecture + of the build computer. At present, this feature is only supported on + GNU/Linux, and not all architectures are recognized. If the auto-detect + is unsuccessful the option has no effect. + +.. option:: -mtune={name} + + This option specifies the name of the target ARM processor for + which GCC should tune the performance of the code. + For some ARM implementations better performance can be obtained by using + this option. + Permissible names are: :samp:`arm7tdmi`, :samp:`arm7tdmi-s`, :samp:`arm710t`, + :samp:`arm720t`, :samp:`arm740t`, :samp:`strongarm`, :samp:`strongarm110`, + :samp:`strongarm1100`, :samp:`strongarm1110`, :samp:`arm8`, :samp:`arm810`, + :samp:`arm9`, :samp:`arm9e`, :samp:`arm920`, :samp:`arm920t`, :samp:`arm922t`, + :samp:`arm946e-s`, :samp:`arm966e-s`, :samp:`arm968e-s`, :samp:`arm926ej-s`, + :samp:`arm940t`, :samp:`arm9tdmi`, :samp:`arm10tdmi`, :samp:`arm1020t`, + :samp:`arm1026ej-s`, :samp:`arm10e`, :samp:`arm1020e`, :samp:`arm1022e`, + :samp:`arm1136j-s`, :samp:`arm1136jf-s`, :samp:`mpcore`, :samp:`mpcorenovfp`, + :samp:`arm1156t2-s`, :samp:`arm1156t2f-s`, :samp:`arm1176jz-s`, :samp:`arm1176jzf-s`, + :samp:`generic-armv7-a`, :samp:`cortex-a5`, :samp:`cortex-a7`, :samp:`cortex-a8`, + :samp:`cortex-a9`, :samp:`cortex-a12`, :samp:`cortex-a15`, :samp:`cortex-a17`, + :samp:`cortex-a32`, :samp:`cortex-a35`, :samp:`cortex-a53`, :samp:`cortex-a55`, + :samp:`cortex-a57`, :samp:`cortex-a72`, :samp:`cortex-a73`, :samp:`cortex-a75`, + :samp:`cortex-a76`, :samp:`cortex-a76ae`, :samp:`cortex-a77`, + :samp:`cortex-a78`, :samp:`cortex-a78ae`, :samp:`cortex-a78c`, :samp:`cortex-a710`, + :samp:`ares`, :samp:`cortex-r4`, :samp:`cortex-r4f`, :samp:`cortex-r5`, + :samp:`cortex-r7`, :samp:`cortex-r8`, :samp:`cortex-r52`, :samp:`cortex-r52plus`, + :samp:`cortex-m0`, :samp:`cortex-m0plus`, :samp:`cortex-m1`, :samp:`cortex-m3`, + :samp:`cortex-m4`, :samp:`cortex-m7`, :samp:`cortex-m23`, :samp:`cortex-m33`, + :samp:`cortex-m35p`, :samp:`cortex-m55`, :samp:`cortex-x1`, + :samp:`cortex-m1.small-multiply`, :samp:`cortex-m0.small-multiply`, + :samp:`cortex-m0plus.small-multiply`, :samp:`exynos-m1`, :samp:`marvell-pj4`, + :samp:`neoverse-n1`, :samp:`neoverse-n2`, :samp:`neoverse-v1`, :samp:`xscale`, + :samp:`iwmmxt`, :samp:`iwmmxt2`, :samp:`ep9312`, :samp:`fa526`, :samp:`fa626`, + :samp:`fa606te`, :samp:`fa626te`, :samp:`fmp626`, :samp:`fa726te`, :samp:`star-mc1`, + :samp:`xgene1`. + + Additionally, this option can specify that GCC should tune the performance + of the code for a big.LITTLE system. Permissible names are: + :samp:`cortex-a15.cortex-a7`, :samp:`cortex-a17.cortex-a7`, + :samp:`cortex-a57.cortex-a53`, :samp:`cortex-a72.cortex-a53`, + :samp:`cortex-a72.cortex-a35`, :samp:`cortex-a73.cortex-a53`, + :samp:`cortex-a75.cortex-a55`, :samp:`cortex-a76.cortex-a55`. + + :option:`-mtune=generic-arch` specifies that GCC should tune the + performance for a blend of processors within architecture :samp:`{arch}`. + The aim is to generate code that run well on the current most popular + processors, balancing between optimizations that benefit some CPUs in the + range, and avoiding performance pitfalls of other CPUs. The effects of + this option may change in future GCC versions as CPU models come and go. + + :option:`-mtune` permits the same extension options as :option:`-mcpu`, but + the extension options do not affect the tuning of the generated code. + + :option:`-mtune=native` causes the compiler to auto-detect the CPU + of the build computer. At present, this feature is only supported on + GNU/Linux, and not all architectures are recognized. If the auto-detect is + unsuccessful the option has no effect. + +.. option:: -mcpu={name}[+extension...] + + This specifies the name of the target ARM processor. GCC uses this name + to derive the name of the target ARM architecture (as if specified + by :option:`-march`) and the ARM processor type for which to tune for + performance (as if specified by :option:`-mtune`). Where this option + is used in conjunction with :option:`-march` or :option:`-mtune`, + those options take precedence over the appropriate part of this option. + + Many of the supported CPUs implement optional architectural + extensions. Where this is so the architectural extensions are + normally enabled by default. If implementations that lack the + extension exist, then the extension syntax can be used to disable + those extensions that have been omitted. For floating-point and + Advanced SIMD (Neon) instructions, the settings of the options + :option:`-mfloat-abi` and :option:`-mfpu` must also be considered: + floating-point and Advanced SIMD instructions will only be used if + :option:`-mfloat-abi` is not set to :samp:`soft`; and any setting of + :option:`-mfpu` other than :samp:`auto` will override the available + floating-point and SIMD extension instructions. + + For example, :samp:`cortex-a9` can be found in three major + configurations: integer only, with just a floating-point unit or with + floating-point and Advanced SIMD. The default is to enable all the + instructions, but the extensions :samp:`+nosimd` and :samp:`+nofp` can + be used to disable just the SIMD or both the SIMD and floating-point + instructions respectively. + + Permissible names for this option are the same as those for + :option:`-mtune`. + + The following extension options are common to the listed CPUs: + + :samp:`+nodsp` + Disable the DSP instructions on :samp:`cortex-m33`, :samp:`cortex-m35p` + and :samp:`cortex-m55`. Also disable the M-Profile Vector Extension (MVE) + integer and single precision floating-point instructions on :samp:`cortex-m55`. + + :samp:`+nomve` + Disable the M-Profile Vector Extension (MVE) integer and single precision + floating-point instructions on :samp:`cortex-m55`. + + :samp:`+nomve.fp` + Disable the M-Profile Vector Extension (MVE) single precision floating-point + instructions on :samp:`cortex-m55`. + + :samp:`+nofp` + Disables the floating-point instructions on :samp:`arm9e`, + :samp:`arm946e-s`, :samp:`arm966e-s`, :samp:`arm968e-s`, :samp:`arm10e`, + :samp:`arm1020e`, :samp:`arm1022e`, :samp:`arm926ej-s`, + :samp:`arm1026ej-s`, :samp:`cortex-r5`, :samp:`cortex-r7`, :samp:`cortex-r8`, + :samp:`cortex-m4`, :samp:`cortex-m7`, :samp:`cortex-m33`, :samp:`cortex-m35p` + and :samp:`cortex-m55`. + Disables the floating-point and SIMD instructions on + :samp:`generic-armv7-a`, :samp:`cortex-a5`, :samp:`cortex-a7`, + :samp:`cortex-a8`, :samp:`cortex-a9`, :samp:`cortex-a12`, + :samp:`cortex-a15`, :samp:`cortex-a17`, :samp:`cortex-a15.cortex-a7`, + :samp:`cortex-a17.cortex-a7`, :samp:`cortex-a32`, :samp:`cortex-a35`, + :samp:`cortex-a53` and :samp:`cortex-a55`. + + :samp:`+nofp.dp` + Disables the double-precision component of the floating-point instructions + on :samp:`cortex-r5`, :samp:`cortex-r7`, :samp:`cortex-r8`, :samp:`cortex-r52`, + :samp:`cortex-r52plus` and :samp:`cortex-m7`. + + :samp:`+nosimd` + Disables the SIMD (but not floating-point) instructions on + :samp:`generic-armv7-a`, :samp:`cortex-a5`, :samp:`cortex-a7` + and :samp:`cortex-a9`. + + :samp:`+crypto` + Enables the cryptographic instructions on :samp:`cortex-a32`, + :samp:`cortex-a35`, :samp:`cortex-a53`, :samp:`cortex-a55`, :samp:`cortex-a57`, + :samp:`cortex-a72`, :samp:`cortex-a73`, :samp:`cortex-a75`, :samp:`exynos-m1`, + :samp:`xgene1`, :samp:`cortex-a57.cortex-a53`, :samp:`cortex-a72.cortex-a53`, + :samp:`cortex-a73.cortex-a35`, :samp:`cortex-a73.cortex-a53` and + :samp:`cortex-a75.cortex-a55`. + + Additionally the :samp:`generic-armv7-a` pseudo target defaults to + VFPv3 with 16 double-precision registers. It supports the following + extension options: :samp:`mp`, :samp:`sec`, :samp:`vfpv3-d16`, + :samp:`vfpv3`, :samp:`vfpv3-d16-fp16`, :samp:`vfpv3-fp16`, + :samp:`vfpv4-d16`, :samp:`vfpv4`, :samp:`neon`, :samp:`neon-vfpv3`, + :samp:`neon-fp16`, :samp:`neon-vfpv4`. The meanings are the same as for + the extensions to :option:`-march=armv7-a`. + + :option:`-mcpu=generic-arch` is also permissible, and is + equivalent to :option:`-march=arch -mtune=generic-arch`. + See :option:`-mtune` for more information. + + :option:`-mcpu=native` causes the compiler to auto-detect the CPU + of the build computer. At present, this feature is only supported on + GNU/Linux, and not all architectures are recognized. If the auto-detect + is unsuccessful the option has no effect. + +.. option:: -mfpu={name} + + This specifies what floating-point hardware (or hardware emulation) is + available on the target. Permissible names are: :samp:`auto`, :samp:`vfpv2`, + :samp:`vfpv3`, + :samp:`vfpv3-fp16`, :samp:`vfpv3-d16`, :samp:`vfpv3-d16-fp16`, :samp:`vfpv3xd`, + :samp:`vfpv3xd-fp16`, :samp:`neon-vfpv3`, :samp:`neon-fp16`, :samp:`vfpv4`, + :samp:`vfpv4-d16`, :samp:`fpv4-sp-d16`, :samp:`neon-vfpv4`, + :samp:`fpv5-d16`, :samp:`fpv5-sp-d16`, + :samp:`fp-armv8`, :samp:`neon-fp-armv8` and :samp:`crypto-neon-fp-armv8`. + Note that :samp:`neon` is an alias for :samp:`neon-vfpv3` and :samp:`vfp` + is an alias for :samp:`vfpv2`. + + The setting :samp:`auto` is the default and is special. It causes the + compiler to select the floating-point and Advanced SIMD instructions + based on the settings of :option:`-mcpu` and :option:`-march`. + + If the selected floating-point hardware includes the NEON extension + (e.g. :option:`-mfpu=neon`), note that floating-point + operations are not generated by GCC's auto-vectorization pass unless + :option:`-funsafe-math-optimizations` is also specified. This is + because NEON hardware does not fully implement the IEEE 754 standard for + floating-point arithmetic (in particular denormal values are treated as + zero), so the use of NEON instructions may lead to a loss of precision. + + You can also set the fpu name at function level by using the ``target("fpu=")`` function attributes (see :ref:`arm-function-attributes`) or pragmas (see :ref:`function-specific-option-pragmas`). + +.. option:: -mfp16-format={name} + + Specify the format of the ``__fp16`` half-precision floating-point type. + Permissible names are :samp:`none`, :samp:`ieee`, and :samp:`alternative`; + the default is :samp:`none`, in which case the ``__fp16`` type is not + defined. See :ref:`half-precision`, for more information. + +.. option:: -mstructure-size-boundary={n} + + The sizes of all structures and unions are rounded up to a multiple + of the number of bits set by this option. Permissible values are 8, 32 + and 64. The default value varies for different toolchains. For the COFF + targeted toolchain the default value is 8. A value of 64 is only allowed + if the underlying ABI supports it. + + Specifying a larger number can produce faster, more efficient code, but + can also increase the size of the program. Different values are potentially + incompatible. Code compiled with one value cannot necessarily expect to + work with code or libraries compiled with another value, if they exchange + information using structures or unions. + + This option is deprecated. + +.. option:: -mabort-on-noreturn + + Generate a call to the function ``abort`` at the end of a + :fn-attr:`noreturn` function. It is executed if the function tries to + return. + +.. option:: -mlong-calls, -mno-long-calls + + Tells the compiler to perform function calls by first loading the + address of the function into a register and then performing a subroutine + call on this register. This switch is needed if the target function + lies outside of the 64-megabyte addressing range of the offset-based + version of subroutine call instruction. + + Even if this switch is enabled, not all function calls are turned + into long calls. The heuristic is that static functions, functions + that have the ``short_call`` attribute, functions that are inside + the scope of a ``#pragma no_long_calls`` directive, and functions whose + definitions have already been compiled within the current compilation + unit are not turned into long calls. The exceptions to this rule are + that weak function definitions, functions with the :arm-fn-attr:`long_call` + attribute or the ``section`` attribute, and functions that are within + the scope of a ``#pragma long_calls`` directive are always + turned into long calls. + + This feature is not enabled by default. Specifying + :option:`-mno-long-calls` restores the default behavior, as does + placing the function calls within the scope of a ``#pragma + long_calls_off`` directive. Note these switches have no effect on how + the compiler generates code to handle function calls via function + pointers. + +.. option:: -msingle-pic-base + + Treat the register used for PIC addressing as read-only, rather than + loading it in the prologue for each function. The runtime system is + responsible for initializing this register with an appropriate value + before execution begins. + +.. option:: -mpic-register={reg} + + Specify the register to be used for PIC addressing. + For standard PIC base case, the default is any suitable register + determined by compiler. For single PIC base case, the default is + :samp:`R9` if target is EABI based or stack-checking is enabled, + otherwise the default is :samp:`R10`. + +.. option:: -mpic-data-is-text-relative + + Assume that the displacement between the text and data segments is fixed + at static link time. This permits using PC-relative addressing + operations to access data known to be in the data segment. For + non-VxWorks RTP targets, this option is enabled by default. When + disabled on such targets, it will enable :option:`-msingle-pic-base` by + default. + +.. option:: -mpoke-function-name + + Write the name of each function into the text section, directly + preceding the function prologue. The generated code is similar to this: + + .. code-block:: + + t0 + .ascii "arm_poke_function_name", 0 + .align + t1 + .word 0xff000000 + (t1 - t0) + arm_poke_function_name + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + + When performing a stack backtrace, code can inspect the value of + ``pc`` stored at ``fp + 0``. If the trace function then looks at + location ``pc - 12`` and the top 8 bits are set, then we know that + there is a function name embedded immediately preceding this location + and has length ``((pc[-3]) & 0xff000000)``. + +.. option:: -mthumb, -marm + + Select between generating code that executes in ARM and Thumb + states. The default for most configurations is to generate code + that executes in ARM state, but the default can be changed by + configuring GCC with the :option:`--with-mode=state` + configure option. + + You can also override the ARM and Thumb mode for each function + by using the ``target("thumb")`` and ``target("arm")`` function attributes + (see :ref:`arm-function-attributes`) or pragmas (see :ref:`function-specific-option-pragmas`). + +.. option:: -mflip-thumb + + Switch ARM/Thumb modes on alternating functions. + This option is provided for regression testing of mixed Thumb/ARM code + generation, and is not intended for ordinary use in compiling code. + +.. option:: -mtpcs-frame + + Generate a stack frame that is compliant with the Thumb Procedure Call + Standard for all non-leaf functions. (A leaf function is one that does + not call any other functions.) The default is :option:`-mno-tpcs-frame`. + +.. option:: -mtpcs-leaf-frame + + Generate a stack frame that is compliant with the Thumb Procedure Call + Standard for all leaf functions. (A leaf function is one that does + not call any other functions.) The default is :option:`-mno-apcs-leaf-frame`. + +.. option:: -mcallee-super-interworking + + Gives all externally visible functions in the file being compiled an ARM + instruction set header which switches to Thumb mode before executing the + rest of the function. This allows these functions to be called from + non-interworking code. This option is not valid in AAPCS configurations + because interworking is enabled by default. + +.. option:: -mcaller-super-interworking + + Allows calls via function pointers (including virtual functions) to + execute correctly regardless of whether the target code has been + compiled for interworking or not. There is a small overhead in the cost + of executing a function pointer if this option is enabled. This option + is not valid in AAPCS configurations because interworking is enabled + by default. + +.. option:: -mtp={name} + + Specify the access model for the thread local storage pointer. The valid + models are :samp:`soft`, which generates calls to ``__aeabi_read_tp``, + :samp:`cp15`, which fetches the thread pointer from ``cp15`` directly + (supported in the arm6k architecture), and :samp:`auto`, which uses the + best available method for the selected processor. The default setting is + :samp:`auto`. + +.. option:: -mtls-dialect={dialect} + + Specify the dialect to use for accessing thread local storage. Two + :samp:`{dialect}` s are supported---:samp:`gnu` and :samp:`gnu2`. The + :samp:`gnu` dialect selects the original GNU scheme for supporting + local and global dynamic TLS models. The :samp:`gnu2` dialect + selects the GNU descriptor scheme, which provides better performance + for shared libraries. The GNU descriptor scheme is compatible with + the original scheme, but does require new assembler, linker and + library support. Initial and local exec TLS models are unaffected by + this option and always use the original scheme. + +.. option:: -mword-relocations + + Only generate absolute relocations on word-sized values (i.e. R_ARM_ABS32). + This is enabled by default on targets (uClinux, SymbianOS) where the runtime + loader imposes this restriction, and when :option:`-fpic` or :option:`-fPIC` + is specified. This option conflicts with :option:`-mslow-flash-data`. + +.. option:: -mfix-cortex-m3-ldrd + + Some Cortex-M3 cores can cause data corruption when ``ldrd`` instructions + with overlapping destination and base registers are used. This option avoids + generating these instructions. This option is enabled by default when + :option:`-mcpu=cortex-m3` is specified. + +.. option:: -mfix-cortex-a57-aes-1742098, -mno-fix-cortex-a57-aes-1742098, -mfix-cortex-a72-aes-1655431, -mno-fix-cortex-a72-aes-1655431 + + Enable (disable) mitigation for an erratum on Cortex-A57 and + Cortex-A72 that affects the AES cryptographic instructions. This + option is enabled by default when either :option:`-mcpu=cortex-a57` or + :option:`-mcpu=cortex-a72` is specified. + +.. option:: -munaligned-access, -mno-unaligned-access + + Enables (or disables) reading and writing of 16- and 32- bit values + from addresses that are not 16- or 32- bit aligned. By default + unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for + ARMv8-M Baseline architectures, and enabled for all other + architectures. If unaligned access is not enabled then words in packed + data structures are accessed a byte at a time. + + The ARM attribute ``Tag_CPU_unaligned_access`` is set in the + generated object file to either true or false, depending upon the + setting of this option. If unaligned access is enabled then the + preprocessor symbol ``__ARM_FEATURE_UNALIGNED`` is also + defined. + +.. option:: -mneon-for-64bits + + This option is deprecated and has no effect. + +.. option:: -mslow-flash-data + + Assume loading data from flash is slower than fetching instruction. + Therefore literal load is minimized for better performance. + This option is only supported when compiling for ARMv7 M-profile and + off by default. It conflicts with :option:`-mword-relocations`. + +.. option:: -masm-syntax-unified + + Assume inline assembler is using unified asm syntax. The default is + currently off which implies divided syntax. This option has no impact + on Thumb2. However, this may change in future releases of GCC. + Divided syntax should be considered deprecated. + +.. option:: -mrestrict-it + + Restricts generation of IT blocks to conform to the rules of ARMv8-A. + IT blocks can only contain a single 16-bit instruction from a select + set of instructions. This option is on by default for ARMv8-A Thumb mode. + +.. option:: -mprint-tune-info + + Print CPU tuning information as comment in assembler file. This is + an option used only for regression testing of the compiler and not + intended for ordinary use in compiling code. This option is disabled + by default. + +.. option:: -mverbose-cost-dump + + Enable verbose cost model dumping in the debug dump files. This option is + provided for use in debugging the compiler. + +.. option:: -mpure-code + + Do not allow constant data to be placed in code sections. + Additionally, when compiling for ELF object format give all text sections the + ELF processor-specific section attribute ``SHF_ARM_PURECODE``. This option + is only available when generating non-pic code for M-profile targets. + +.. option:: -mcmse + + Generate secure code as per the "ARMv8-M Security Extensions: Requirements on + Development Tools Engineering Specification", which can be found on + https://developer.arm.com/documentation/ecm0359818/latest/. + +.. option:: -mfix-cmse-cve-2021-35465 + + Mitigate against a potential security issue with the ``VLLDM`` instruction + in some M-profile devices when using CMSE (CVE-2021-365465). This option is + enabled by default when the option :option:`-mcpu=` is used with + ``cortex-m33``, ``cortex-m35p``, ``cortex-m55`` or ``star-mc1``. + The option :option:`-mno-fix-cmse-cve-2021-35465` can be used to disable + the mitigation. + +.. option:: -mstack-protector-guard={guard} + + Generate stack protection code using canary at :samp:`{guard}`. Supported + locations are :samp:`global` for a global canary or :samp:`tls` for a + canary accessible via the TLS register. The option + :option:`-mstack-protector-guard-offset=` is for use with + :option:`-fstack-protector-guard=tls` and not for use in user-land code. + +.. option:: -mfdpic, -mno-fdpic + + Select the FDPIC ABI, which uses 64-bit function descriptors to + represent pointers to functions. When the compiler is configured for + ``arm-*-uclinuxfdpiceabi`` targets, this option is on by default + and implies :option:`-fPIE` if none of the PIC/PIE-related options is + provided. On other targets, it only enables the FDPIC-specific code + generation features, and the user should explicitly provide the + PIC/PIE-related options as needed. + + Note that static linking is not supported because it would still + involve the dynamic linker when the program self-relocates. If such + behavior is acceptable, use -static and -Wl,-dynamic-linker options. + + The opposite :option:`-mno-fdpic` option is useful (and required) to + build the Linux kernel using the same (``arm-*-uclinuxfdpiceabi``) + toolchain as the one used to build the userland programs. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/avr-mmcu.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/avr-mmcu.rst new file mode 100644 index 00000000000..df82d0cf906 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/avr-mmcu.rst @@ -0,0 +1,97 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + + This file is generated automatically using + gcc/config/avr/gen-avr-mmcu-texi.cc from: + gcc/config/avr/avr-arch.h + gcc/config/avr/avr-devices.cc + gcc/config/avr/avr-mcus.def + + Please do not edit manually. + +``avr2`` + "Classic" devices with up to 8 |nbsp| KiB of program memory. + + :samp:`{mcu}=` ``attiny22``, ``attiny26``, ``at90s2313``, ``at90s2323``, ``at90s2333``, ``at90s2343``, ``at90s4414``, ``at90s4433``, ``at90s4434``, ``at90c8534``, ``at90s8515``, ``at90s8535``. + +``avr25`` + "Classic" devices with up to 8 |nbsp| KiB of program memory and with the ``MOVW`` instruction. + + :samp:`{mcu}=` ``attiny13``, ``attiny13a``, ``attiny24``, ``attiny24a``, ``attiny25``, ``attiny261``, ``attiny261a``, ``attiny2313``, ``attiny2313a``, ``attiny43u``, ``attiny44``, ``attiny44a``, ``attiny45``, ``attiny48``, ``attiny441``, ``attiny461``, ``attiny461a``, ``attiny4313``, ``attiny84``, ``attiny84a``, ``attiny85``, ``attiny87``, ``attiny88``, ``attiny828``, ``attiny841``, ``attiny861``, ``attiny861a``, ``ata5272``, ``ata6616c``, ``at86rf401``. + +``avr3`` + "Classic" devices with 16 |nbsp| KiB up to 64 |nbsp| KiB of program memory. + + :samp:`{mcu}=` ``at76c711``, ``at43usb355``. + +``avr31`` + "Classic" devices with 128 |nbsp| KiB of program memory. + + :samp:`{mcu}=` ``atmega103``, ``at43usb320``. + +``avr35`` + "Classic" devices with 16 |nbsp| KiB up to 64 |nbsp| KiB of program memory and with the ``MOVW`` instruction. + + :samp:`{mcu}=` ``attiny167``, ``attiny1634``, ``atmega8u2``, ``atmega16u2``, ``atmega32u2``, ``ata5505``, ``ata6617c``, ``ata664251``, ``at90usb82``, ``at90usb162``. + +``avr4`` + "Enhanced" devices with up to 8 |nbsp| KiB of program memory. + + :samp:`{mcu}=` ``atmega48``, ``atmega48a``, ``atmega48p``, ``atmega48pa``, ``atmega48pb``, ``atmega8``, ``atmega8a``, ``atmega8hva``, ``atmega88``, ``atmega88a``, ``atmega88p``, ``atmega88pa``, ``atmega88pb``, ``atmega8515``, ``atmega8535``, ``ata6285``, ``ata6286``, ``ata6289``, ``ata6612c``, ``at90pwm1``, ``at90pwm2``, ``at90pwm2b``, ``at90pwm3``, ``at90pwm3b``, ``at90pwm81``. + +``avr5`` + "Enhanced" devices with 16 |nbsp| KiB up to 64 |nbsp| KiB of program memory. + + :samp:`{mcu}=` ``atmega16``, ``atmega16a``, ``atmega16hva``, ``atmega16hva2``, ``atmega16hvb``, ``atmega16hvbrevb``, ``atmega16m1``, ``atmega16u4``, ``atmega161``, ``atmega162``, ``atmega163``, ``atmega164a``, ``atmega164p``, ``atmega164pa``, ``atmega165``, ``atmega165a``, ``atmega165p``, ``atmega165pa``, ``atmega168``, ``atmega168a``, ``atmega168p``, ``atmega168pa``, ``atmega168pb``, ``atmega169``, ``atmega169a``, ``atmega169p``, ``atmega169pa``, ``atmega32``, ``atmega32a``, ``atmega32c1``, ``atmega32hvb``, ``atmega32hvbrevb``, ``atmega32m1``, ``atmega32u4``, ``atmega32u6``, ``atmega323``, ``atmega324a``, ``atmega324p``, ``atmega324pa``, ``atmega324pb``, ``atmega325``, ``atmega325a``, ``atmega325p``, ``atmega325pa``, ``atmega328``, ``atmega328p``, ``atmega328pb``, ``atmega329``, ``atmega329a``, ``atmega329p``, ``atmega329pa``, ``atmega3250``, ``atmega3250a``, ``atmega3250p``, ``atmega3250pa``, ``atmega3290``, ``atmega3290a``, ``atmega3290p``, ``atmega3290pa``, ``atmega406``, ``atmega64``, ``atmega64a``, ``atmega64c1``, ``atmega64hve``, ``atmega64hve2``, ``atmega64m1``, ``atmega64rfr2``, ``atmega640``, ``atmega644``, ``atmega644a``, ``atmega644p``, ``atmega644pa``, ``atmega644rfr2``, ``atmega645``, ``atmega645a``, ``atmega645p``, ``atmega649``, ``atmega649a``, ``atmega649p``, ``atmega6450``, ``atmega6450a``, ``atmega6450p``, ``atmega6490``, ``atmega6490a``, ``atmega6490p``, ``ata5795``, ``ata5790``, ``ata5790n``, ``ata5791``, ``ata6613c``, ``ata6614q``, ``ata5782``, ``ata5831``, ``ata8210``, ``ata8510``, ``ata5702m322``, ``at90pwm161``, ``at90pwm216``, ``at90pwm316``, ``at90can32``, ``at90can64``, ``at90scr100``, ``at90usb646``, ``at90usb647``, ``at94k``, ``m3000``. + +``avr51`` + "Enhanced" devices with 128 |nbsp| KiB of program memory. + + :samp:`{mcu}=` ``atmega128``, ``atmega128a``, ``atmega128rfa1``, ``atmega128rfr2``, ``atmega1280``, ``atmega1281``, ``atmega1284``, ``atmega1284p``, ``atmega1284rfr2``, ``at90can128``, ``at90usb1286``, ``at90usb1287``. + +``avr6`` + "Enhanced" devices with 3-byte PC, i.e.: with more than 128 |nbsp| KiB of program memory. + + :samp:`{mcu}=` ``atmega256rfr2``, ``atmega2560``, ``atmega2561``, ``atmega2564rfr2``. + +``avrxmega2`` + "XMEGA" devices with more than 8 |nbsp| KiB and up to 64 |nbsp| KiB of program memory. + + :samp:`{mcu}=` ``atxmega8e5``, ``atxmega16a4``, ``atxmega16a4u``, ``atxmega16c4``, ``atxmega16d4``, ``atxmega16e5``, ``atxmega32a4``, ``atxmega32a4u``, ``atxmega32c3``, ``atxmega32c4``, ``atxmega32d3``, ``atxmega32d4``, ``atxmega32e5``, ``avr64da28``, ``avr64da32``, ``avr64da48``, ``avr64da64``, ``avr64db28``, ``avr64db32``, ``avr64db48``, ``avr64db64``. + +``avrxmega3`` + "XMEGA" devices with up to 64 |nbsp| KiB of combined program memory and RAM, and with program memory visible in the RAM address space. + + :samp:`{mcu}=` ``attiny202``, ``attiny204``, ``attiny212``, ``attiny214``, ``attiny402``, ``attiny404``, ``attiny406``, ``attiny412``, ``attiny414``, ``attiny416``, ``attiny417``, ``attiny804``, ``attiny806``, ``attiny807``, ``attiny814``, ``attiny816``, ``attiny817``, ``attiny1604``, ``attiny1606``, ``attiny1607``, ``attiny1614``, ``attiny1616``, ``attiny1617``, ``attiny3214``, ``attiny3216``, ``attiny3217``, ``atmega808``, ``atmega809``, ``atmega1608``, ``atmega1609``, ``atmega3208``, ``atmega3209``, ``atmega4808``, ``atmega4809``, ``avr32da28``, ``avr32da32``, ``avr32da48``, ``avr32db28``, ``avr32db32``, ``avr32db48``. + +``avrxmega4`` + "XMEGA" devices with more than 64 |nbsp| KiB and up to 128 |nbsp| KiB of program memory. + + :samp:`{mcu}=` ``atxmega64a3``, ``atxmega64a3u``, ``atxmega64a4u``, ``atxmega64b1``, ``atxmega64b3``, ``atxmega64c3``, ``atxmega64d3``, ``atxmega64d4``, ``avr128da28``, ``avr128da32``, ``avr128da48``, ``avr128da64``, ``avr128db28``, ``avr128db32``, ``avr128db48``, ``avr128db64``. + +``avrxmega5`` + "XMEGA" devices with more than 64 |nbsp| KiB and up to 128 |nbsp| KiB of program memory and more than 64 |nbsp| KiB of RAM. + + :samp:`{mcu}=` ``atxmega64a1``, ``atxmega64a1u``. + +``avrxmega6`` + "XMEGA" devices with more than 128 |nbsp| KiB of program memory. + + :samp:`{mcu}=` ``atxmega128a3``, ``atxmega128a3u``, ``atxmega128b1``, ``atxmega128b3``, ``atxmega128c3``, ``atxmega128d3``, ``atxmega128d4``, ``atxmega192a3``, ``atxmega192a3u``, ``atxmega192c3``, ``atxmega192d3``, ``atxmega256a3``, ``atxmega256a3b``, ``atxmega256a3bu``, ``atxmega256a3u``, ``atxmega256c3``, ``atxmega256d3``, ``atxmega384c3``, ``atxmega384d3``. + +``avrxmega7`` + "XMEGA" devices with more than 128 |nbsp| KiB of program memory and more than 64 |nbsp| KiB of RAM. + + :samp:`{mcu}=` ``atxmega128a1``, ``atxmega128a1u``, ``atxmega128a4u``. + +``avrtiny`` + "TINY" Tiny core devices with 512 |nbsp| B up to 4 |nbsp| KiB of program memory. + + :samp:`{mcu}=` ``attiny4``, ``attiny5``, ``attiny9``, ``attiny10``, ``attiny20``, ``attiny40``. + +``avr1`` + This ISA is implemented by the minimal AVR core and supported for assembler only. + + :samp:`{mcu}=` ``attiny11``, ``attiny12``, ``attiny15``, ``attiny28``, ``at90s1200``. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/avr-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/avr-options.rst new file mode 100644 index 00000000000..634032cfc29 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/avr-options.rst @@ -0,0 +1,543 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: AVR + +.. index:: AVR Options + +.. _avr-options: + +AVR Options +^^^^^^^^^^^ + +These options are defined for AVR implementations: + +.. option:: -mmcu={mcu} + + Specify Atmel AVR instruction set architectures (ISA) or MCU type. + + The default for this option is |nbsp| :samp:`avr2`. + +GCC supports the following AVR devices and ISAs: + +.. include:: avr-mmcu.rst + +.. option:: -mabsdata + + Assume that all data in static storage can be accessed by LDS / STS + instructions. This option has only an effect on reduced Tiny devices like + ATtiny40. See also the :avr-var-attr:`absdata`. + +.. option:: -maccumulate-args + + Accumulate outgoing function arguments and acquire/release the needed + stack space for outgoing function arguments once in function + prologue/epilogue. Without this option, outgoing arguments are pushed + before calling a function and popped afterwards. + + Popping the arguments after the function call can be expensive on + AVR so that accumulating the stack space might lead to smaller + executables because arguments need not be removed from the + stack after such a function call. + + This option can lead to reduced code size for functions that perform + several calls to functions that get their arguments on the stack like + calls to printf-like functions. + +.. option:: -mbranch-cost={cost} + + Set the branch costs for conditional branch instructions to + :samp:`{cost}`. Reasonable values for :samp:`{cost}` are small, non-negative + integers. The default branch cost is 0. + +.. option:: -mcall-prologues + + Functions prologues/epilogues are expanded as calls to appropriate + subroutines. Code size is smaller. + +.. option:: -mdouble={bits} + + Set the size (in bits) of the ``double`` or ``long double`` type, + respectively. Possible values for :samp:`{bits}` are 32 and 64. + Whether or not a specific value for :samp:`{bits}` is allowed depends on + the ``--with-double=`` and ``--with-long-double=`` + `configure options `_, + and the same applies for the default values of the options. + +.. option:: -mgas-isr-prologues + + Interrupt service routines (ISRs) may use the ``__gcc_isr`` pseudo + instruction supported by GNU Binutils. + If this option is on, the feature can still be disabled for individual + ISRs by means of the :ref:`avr-function-attributes` + function attribute. This feature is activated per default + if optimization is on (but not with :option:`-Og`, see :ref:`optimize-options`), + and if GNU Binutils support `PR21683 `_. + +.. option:: -mint8 + + Assume ``int`` to be 8-bit integer. This affects the sizes of all types: a + ``char`` is 1 byte, an ``int`` is 1 byte, a ``long`` is 2 bytes, + and ``long long`` is 4 bytes. Please note that this option does not + conform to the C standards, but it results in smaller code + size. + +.. option:: -mmain-is-OS_task + + Do not save registers in ``main``. The effect is the same like + attaching attribute :ref:`avr-function-attributes` + to ``main``. It is activated per default if optimization is on. + +.. option:: -mn-flash={num} + + Assume that the flash memory has a size of + :samp:`{num}` times 64 |nbsp| KiB. + +.. option:: -mno-interrupts + + Generated code is not compatible with hardware interrupts. + Code size is smaller. + +.. option:: -mrelax + + Try to replace ``CALL`` resp. ``JMP`` instruction by the shorter + ``RCALL`` resp. ``RJMP`` instruction if applicable. + Setting :option:`-mrelax` just adds the :option:`--mlink-relax` option to + the assembler's command line and the :option:`--relax` option to the + linker's command line. + + Jump relaxing is performed by the linker because jump offsets are not + known before code is located. Therefore, the assembler code generated by the + compiler is the same, but the instructions in the executable may + differ from instructions in the assembler code. + + Relaxing must be turned on if linker stubs are needed, see the + section on ``EIND`` and linker stubs below. + +.. option:: -mrmw + + Assume that the device supports the Read-Modify-Write + instructions ``XCH``, ``LAC``, ``LAS`` and ``LAT``. + +.. option:: -mshort-calls + + Assume that ``RJMP`` and ``RCALL`` can target the whole + program memory. + + This option is used internally for multilib selection. It is + not an optimization option, and you don't need to set it by hand. + +.. option:: -msp8 + + Treat the stack pointer register as an 8-bit register, + i.e. assume the high byte of the stack pointer is zero. + In general, you don't need to set this option by hand. + + This option is used internally by the compiler to select and + build multilibs for architectures ``avr2`` and ``avr25``. + These architectures mix devices with and without ``SPH``. + For any setting other than :option:`-mmcu=avr2` or :option:`-mmcu=avr25` + the compiler driver adds or removes this option from the compiler + proper's command line, because the compiler then knows if the device + or architecture has an 8-bit stack pointer and thus no ``SPH`` + register or not. + +.. option:: -mstrict-X + + Use address register ``X`` in a way proposed by the hardware. This means + that ``X`` is only used in indirect, post-increment or + pre-decrement addressing. + + Without this option, the ``X`` register may be used in the same way + as ``Y`` or ``Z`` which then is emulated by additional + instructions. + For example, loading a value with ``X+const`` addressing with a + small non-negative ``const < 64`` to a register :samp:`{Rn}` is + performed as + + .. code-block:: + + adiw r26, const ; X += const + ld Rn, X ; Rn = *X + sbiw r26, const ; X -= const + +.. option:: -mtiny-stack + + Only change the lower 8 |nbsp| bits of the stack pointer. + +.. option:: -mfract-convert-truncate + + Allow to use truncation instead of rounding towards zero for fractional fixed-point types. + +.. option:: -nodevicelib + + Don't link against AVR-LibC's device specific library ``lib.a``. + +.. option:: -nodevicespecs + + Don't add :option:`-specs=device-specs/specs-mcu` to the compiler driver's + command line. The user takes responsibility for supplying the sub-processes + like compiler proper, assembler and linker with appropriate command line + options. This means that the user has to supply her private device specs + file by means of :option:`-specs=path-to-specs-file`. There is no + more need for option :option:`-mmcu=mcu`. + + This option can also serve as a replacement for the older way of + specifying custom device-specs files that needed :option:`-B some-path` to point to a directory + which contains a folder named ``device-specs`` which contains a specs file named + ``specs-mcu``, where :samp:`{mcu}` was specified by :option:`-mmcu=mcu`. + +.. option:: -Waddr-space-convert + + Warn about conversions between address spaces in the case where the + resulting address space is not contained in the incoming address space. + +.. option:: -Wno-addr-space-convert + + Default setting; overrides :option:`-Waddr-space-convert`. + +.. option:: -Wmisspelled-isr + + Warn if the ISR is misspelled, i.e. without __vector prefix. + Enabled by default. + +.. option:: -Wno-misspelled-isr + + Default setting; overrides :option:`-Wmisspelled-isr`. + +.. index:: EIND + +EIND and Devices with More Than 128 Ki Bytes of Flash +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Pointers in the implementation are 16 |nbsp| bits wide. +The address of a function or label is represented as word address so +that indirect jumps and calls can target any code address in the +range of 64 |nbsp| Ki words. + +In order to facilitate indirect jump on devices with more than 128 |nbsp| Ki +bytes of program memory space, there is a special function register called +``EIND`` that serves as most significant part of the target address +when ``EICALL`` or ``EIJMP`` instructions are used. + +Indirect jumps and calls on these devices are handled as follows by +the compiler and are subject to some limitations: + +* The compiler never sets ``EIND``. + +* The compiler uses ``EIND`` implicitly in ``EICALL`` / ``EIJMP`` + instructions or might read ``EIND`` directly in order to emulate an + indirect call/jump by means of a ``RET`` instruction. + +* The compiler assumes that ``EIND`` never changes during the startup + code or during the application. In particular, ``EIND`` is not + saved/restored in function or interrupt service routine + prologue/epilogue. + +* For indirect calls to functions and computed goto, the linker + generates *stubs*. Stubs are jump pads sometimes also called + *trampolines*. Thus, the indirect call/jump jumps to such a stub. + The stub contains a direct jump to the desired address. + +* Linker relaxation must be turned on so that the linker generates + the stubs correctly in all situations. See the compiler option + :option:`-mrelax` and the linker option :option:`--relax`. + There are corner cases where the linker is supposed to generate stubs + but aborts without relaxation and without a helpful error message. + +* The default linker script is arranged for code with ``EIND = 0``. + If code is supposed to work for a setup with ``EIND != 0``, a custom + linker script has to be used in order to place the sections whose + name start with ``.trampolines`` into the segment where ``EIND`` + points to. + +* The startup code from libgcc never sets ``EIND``. + Notice that startup code is a blend of code from libgcc and AVR-LibC. + For the impact of AVR-LibC on ``EIND``, see the + `AVR-LibC user manual `_. + +* It is legitimate for user-specific startup code to set up ``EIND`` + early, for example by means of initialization code located in + section ``.init3``. Such code runs prior to general startup code + that initializes RAM and calls constructors, but after the bit + of startup code from AVR-LibC that sets ``EIND`` to the segment + where the vector table is located. + + .. code-block:: c + + #include + + static void + __attribute__((section(".init3"),naked,used,no_instrument_function)) + init3_set_eind (void) + { + __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t" + "out %i0,r24" :: "n" (&EIND) : "r24","memory"); + } + + The ``__trampolines_start`` symbol is defined in the linker script. + +* Stubs are generated automatically by the linker if + the following two conditions are met: + + * The address of a label is taken by means of the ``gs`` modifier + (short for *generate stubs*) like so: + + .. code-block:: + + LDI r24, lo8(gs(func)) + LDI r25, hi8(gs(func)) + + * The final location of that label is in a code segment + *outside* the segment where the stubs are located. + +* The compiler emits such ``gs`` modifiers for code labels in the + following situations: + + * Taking address of a function or code label. + + * Computed goto. + + * If prologue-save function is used, see :option:`-mcall-prologues` + command-line option. + + * Switch/case dispatch tables. If you do not want such dispatch + tables you can specify the :option:`-fno-jump-tables` command-line option. + + * C and C++ constructors/destructors called during startup/shutdown. + + * If the tools hit a ``gs()`` modifier explained above. + +* Jumping to non-symbolic addresses like so is *not* supported: + + .. code-block:: c++ + + int main (void) + { + /* Call function at word address 0x2 */ + return ((int(*)(void)) 0x2)(); + } + + Instead, a stub has to be set up, i.e. the function has to be called + through a symbol (``func_4`` in the example): + + .. code-block:: c++ + + int main (void) + { + extern int func_4 (void); + + /* Call function at byte address 0x4 */ + return func_4(); + } + + and the application be linked with :option:`-Wl,--defsym,func_4=0x4`. + Alternatively, ``func_4`` can be defined in the linker script. + +.. index:: RAMPD, RAMPX, RAMPY, RAMPZ + +Handling of the RAMPD, RAMPX, RAMPY and RAMPZ Special Function Registers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some AVR devices support memories larger than the 64 |nbsp| KiB range +that can be accessed with 16-bit pointers. To access memory locations +outside this 64 |nbsp| KiB range, the content of a ``RAMP`` +register is used as high part of the address: +The ``X``, ``Y``, ``Z`` address register is concatenated +with the ``RAMPX``, ``RAMPY``, ``RAMPZ`` special function +register, respectively, to get a wide address. Similarly, +``RAMPD`` is used together with direct addressing. + +* The startup code initializes the ``RAMP`` special function + registers with zero. + +* If a :ref:`avr-named-address-spaces` other than + generic or ``__flash`` is used, then ``RAMPZ`` is set + as needed before the operation. + +* If the device supports RAM larger than 64 |nbsp| KiB and the compiler + needs to change ``RAMPZ`` to accomplish an operation, ``RAMPZ`` + is reset to zero after the operation. + +* If the device comes with a specific ``RAMP`` register, the ISR + prologue/epilogue saves/restores that SFR and initializes it with + zero in case the ISR code might (implicitly) use it. + +* RAM larger than 64 |nbsp| KiB is not supported by GCC for AVR targets. + If you use inline assembler to read from locations outside the + 16-bit address range and change one of the ``RAMP`` registers, + you must reset it to zero after the access. + +AVR Built-in Macros +~~~~~~~~~~~~~~~~~~~ + +GCC defines several built-in macros so that the user code can test +for the presence or absence of features. Almost any of the following +built-in macros are deduced from device capabilities and thus +triggered by the :option:`-mmcu=` command-line option. + +For even more AVR-specific built-in macros see +:ref:`avr-named-address-spaces` and :ref:`avr-built-in-functions`. + +``__AVR_ARCH__`` + Build-in macro that resolves to a decimal number that identifies the + architecture and depends on the :option:`-mmcu=mcu` option. + Possible values are: + + ``2``, ``25``, ``3``, ``31``, ``35``, + ``4``, ``5``, ``51``, ``6`` + + for :samp:`{mcu}` = ``avr2``, ``avr25``, ``avr3``, ``avr31``, + ``avr35``, ``avr4``, ``avr5``, ``avr51``, ``avr6``, + + respectively and + + ``100``, + ``102``, ``103``, ``104``, + ``105``, ``106``, ``107`` + + for :samp:`{mcu}` = ``avrtiny``, + ``avrxmega2``, ``avrxmega3``, ``avrxmega4``, + ``avrxmega5``, ``avrxmega6``, ``avrxmega7``, respectively. + If :samp:`{mcu}` specifies a device, this built-in macro is set + accordingly. For example, with :option:`-mmcu=atmega8` the macro is + defined to ``4``. + +:samp:`__AVR_{Device}__` + Setting :option:`-mmcu=device` defines this built-in macro which reflects + the device's name. For example, :option:`-mmcu=atmega8` defines the + built-in macro ``__AVR_ATmega8__``, :option:`-mmcu=attiny261a` defines + ``__AVR_ATtiny261A__``, etc. + + The built-in macros' names follow + the scheme ``__AVR_Device__`` where :samp:`{Device}` is + the device name as from the AVR user manual. The difference between + :samp:`{Device}` in the built-in macro and :samp:`{device}` in + :option:`-mmcu=device` is that the latter is always lowercase. + + If :samp:`{device}` is not a device but only a core architecture like + :samp:`avr51`, this macro is not defined. + +``__AVR_DEVICE_NAME__`` + Setting :option:`-mmcu=device` defines this built-in macro to + the device's name. For example, with :option:`-mmcu=atmega8` the macro + is defined to ``atmega8``. + + If :samp:`{device}` is not a device but only a core architecture like + :samp:`avr51`, this macro is not defined. + +``__AVR_XMEGA__`` + The device / architecture belongs to the XMEGA family of devices. + +``__AVR_HAVE_ELPM__`` + The device has the ``ELPM`` instruction. + +``__AVR_HAVE_ELPMX__`` + The device has the ``ELPM Rn,Z`` and ``ELPM + Rn,Z+`` instructions. + +``__AVR_HAVE_MOVW__`` + The device has the ``MOVW`` instruction to perform 16-bit + register-register moves. + +``__AVR_HAVE_LPMX__`` + The device has the ``LPM Rn,Z`` and + ``LPM Rn,Z+`` instructions. + +``__AVR_HAVE_MUL__`` + The device has a hardware multiplier. + +``__AVR_HAVE_JMP_CALL__`` + The device has the ``JMP`` and ``CALL`` instructions. + This is the case for devices with more than 8 |nbsp| KiB of program + memory. + +``__AVR_HAVE_EIJMP_EICALL__`` ``__AVR_3_BYTE_PC__`` + The device has the ``EIJMP`` and ``EICALL`` instructions. + This is the case for devices with more than 128 |nbsp| KiB of program memory. + This also means that the program counter + (PC) is 3 |nbsp| bytes wide. + +``__AVR_2_BYTE_PC__`` + The program counter (PC) is 2 |nbsp| bytes wide. This is the case for devices + with up to 128 |nbsp| KiB of program memory. + +``__AVR_HAVE_8BIT_SP__`` ``__AVR_HAVE_16BIT_SP__`` + The stack pointer (SP) register is treated as 8-bit respectively + 16-bit register by the compiler. + The definition of these macros is affected by :option:`-mtiny-stack`. + +``__AVR_HAVE_SPH__`` ``__AVR_SP8__`` + The device has the SPH (high part of stack pointer) special function + register or has an 8-bit stack pointer, respectively. + The definition of these macros is affected by :option:`-mmcu=` and + in the cases of :option:`-mmcu=avr2` and :option:`-mmcu=avr25` also + by :option:`-msp8`. + +``__AVR_HAVE_RAMPD__`` ``__AVR_HAVE_RAMPX__`` ``__AVR_HAVE_RAMPY__`` ``__AVR_HAVE_RAMPZ__`` + The device has the ``RAMPD``, ``RAMPX``, ``RAMPY``, + ``RAMPZ`` special function register, respectively. + +``__NO_INTERRUPTS__`` + This macro reflects the :option:`-mno-interrupts` command-line option. + +``__AVR_ERRATA_SKIP__`` ``__AVR_ERRATA_SKIP_JMP_CALL__`` + Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit + instructions because of a hardware erratum. Skip instructions are + ``SBRS``, ``SBRC``, ``SBIS``, ``SBIC`` and ``CPSE``. + The second macro is only defined if ``__AVR_HAVE_JMP_CALL__`` is also + set. + +``__AVR_ISA_RMW__`` + The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT). + +:samp:`__AVR_SFR_OFFSET__={offset}` + Instructions that can address I/O special function registers directly + like ``IN``, ``OUT``, ``SBI``, etc. may use a different + address as if addressed by an instruction to access RAM like ``LD`` + or ``STS``. This offset depends on the device architecture and has + to be subtracted from the RAM address in order to get the + respective I/O |nbsp| address. + +``__AVR_SHORT_CALLS__`` + The :option:`-mshort-calls` command line option is set. + +:samp:`__AVR_PM_BASE_ADDRESS__={addr}` + Some devices support reading from flash memory by means of ``LD*`` + instructions. The flash memory is seen in the data address space + at an offset of ``__AVR_PM_BASE_ADDRESS__``. If this macro + is not defined, this feature is not available. If defined, + the address space is linear and there is no need to put + ``.rodata`` into RAM. This is handled by the default linker + description file, and is currently available for + ``avrtiny`` and ``avrxmega3``. Even more convenient, + there is no need to use address spaces like ``__flash`` or + features like attribute :avr-var-attr:`progmem` and ``pgm_read_*``. + +``__WITH_AVRLIBC__`` + The compiler is configured to be used together with AVR-Libc. + See the :option:`--with-avrlibc` configure option. + +``__HAVE_DOUBLE_MULTILIB__`` + Defined if :option:`-mdouble=` acts as a multilib option. + +``__HAVE_DOUBLE32__`` ``__HAVE_DOUBLE64__`` + Defined if the compiler supports 32-bit double resp. 64-bit double. + The actual layout is specified by option :option:`-mdouble=`. + +``__DEFAULT_DOUBLE__`` + The size in bits of ``double`` if :option:`-mdouble=` is not set. + To test the layout of ``double`` in a program, use the built-in + macro ``__SIZEOF_DOUBLE__``. + +``__HAVE_LONG_DOUBLE32__`` ``__HAVE_LONG_DOUBLE64__`` ``__HAVE_LONG_DOUBLE_MULTILIB__`` ``__DEFAULT_LONG_DOUBLE__`` + Same as above, but for ``long double`` instead of ``double``. + +``__WITH_DOUBLE_COMPARISON__`` + Reflects the :option:`install:--with-double-comparison` + and is defined to ``2`` or ``3``. + +``__WITH_LIBF7_LIBGCC__`` ``__WITH_LIBF7_MATH__`` ``__WITH_LIBF7_MATH_SYMBOLS__`` + Reflects the :option:`install:--with-libf7`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/blackfin-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/blackfin-options.rst new file mode 100644 index 00000000000..7e7fbda8d6d --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/blackfin-options.rst @@ -0,0 +1,227 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: Blackfin + +.. index:: Blackfin Options + +.. _blackfin-options: + +Blackfin Options +^^^^^^^^^^^^^^^^ + +.. option:: -mcpu={cpu}[-{sirevision}] + + Specifies the name of the target Blackfin processor. Currently, :samp:`{cpu}` + can be one of :samp:`bf512`, :samp:`bf514`, :samp:`bf516`, :samp:`bf518`, + :samp:`bf522`, :samp:`bf523`, :samp:`bf524`, :samp:`bf525`, :samp:`bf526`, + :samp:`bf527`, :samp:`bf531`, :samp:`bf532`, :samp:`bf533`, + :samp:`bf534`, :samp:`bf536`, :samp:`bf537`, :samp:`bf538`, :samp:`bf539`, + :samp:`bf542`, :samp:`bf544`, :samp:`bf547`, :samp:`bf548`, :samp:`bf549`, + :samp:`bf542m`, :samp:`bf544m`, :samp:`bf547m`, :samp:`bf548m`, :samp:`bf549m`, + :samp:`bf561`, :samp:`bf592`. + + The optional :samp:`{sirevision}` specifies the silicon revision of the target + Blackfin processor. Any workarounds available for the targeted silicon revision + are enabled. If :samp:`{sirevision}` is :samp:`none`, no workarounds are enabled. + If :samp:`{sirevision}` is :samp:`any`, all workarounds for the targeted processor + are enabled. The ``__SILICON_REVISION__`` macro is defined to two + hexadecimal digits representing the major and minor numbers in the silicon + revision. If :samp:`{sirevision}` is :samp:`none`, the ``__SILICON_REVISION__`` + is not defined. If :samp:`{sirevision}` is :samp:`any`, the + ``__SILICON_REVISION__`` is defined to be ``0xffff``. + If this optional :samp:`{sirevision}` is not used, GCC assumes the latest known + silicon revision of the targeted Blackfin processor. + + GCC defines a preprocessor macro for the specified :samp:`{cpu}`. + For the :samp:`bfin-elf` toolchain, this option causes the hardware BSP + provided by libgloss to be linked in if :option:`-msim` is not given. + + Without this option, :samp:`bf532` is used as the processor by default. + + Note that support for :samp:`bf561` is incomplete. For :samp:`bf561`, + only the preprocessor macro is defined. + +.. option:: -msim + + Specifies that the program will be run on the simulator. This causes + the simulator BSP provided by libgloss to be linked in. This option + has effect only for :samp:`bfin-elf` toolchain. + Certain other options, such as :option:`-mid-shared-library` and + :option:`-mfdpic`, imply :option:`-msim`. + +.. option:: -momit-leaf-frame-pointer + + Don't keep the frame pointer in a register for leaf functions. This + avoids the instructions to save, set up and restore frame pointers and + makes an extra register available in leaf functions. + +.. option:: -mspecld-anomaly + + When enabled, the compiler ensures that the generated code does not + contain speculative loads after jump instructions. If this option is used, + ``__WORKAROUND_SPECULATIVE_LOADS`` is defined. + +.. option:: -mno-specld-anomaly + + Don't generate extra code to prevent speculative loads from occurring. + +.. option:: -mspecld-anomaly + + Default setting; overrides :option:`-mno-specld-anomaly`. + +.. option:: -mcsync-anomaly + + When enabled, the compiler ensures that the generated code does not + contain CSYNC or SSYNC instructions too soon after conditional branches. + If this option is used, ``__WORKAROUND_SPECULATIVE_SYNCS`` is defined. + +.. option:: -mno-csync-anomaly + + Don't generate extra code to prevent CSYNC or SSYNC instructions from + occurring too soon after a conditional branch. + +.. option:: -mcsync-anomaly + + Default setting; overrides :option:`-mno-csync-anomaly`. + +.. option:: -mlow64k + + When enabled, the compiler is free to take advantage of the knowledge that + the entire program fits into the low 64k of memory. + +.. option:: -mno-low64k + + Assume that the program is arbitrarily large. This is the default. + +.. option:: -mstack-check-l1 + + Do stack checking using information placed into L1 scratchpad memory by the + uClinux kernel. + +.. option:: -mid-shared-library + + Generate code that supports shared libraries via the library ID method. + This allows for execute in place and shared libraries in an environment + without virtual memory management. This option implies :option:`-fPIC`. + With a :samp:`bfin-elf` target, this option implies :option:`-msim`. + +.. option:: -mno-id-shared-library + + Generate code that doesn't assume ID-based shared libraries are being used. + This is the default. + +.. option:: -mid-shared-library + + Default setting; overrides :option:`-mno-id-shared-library`. + +.. option:: -mleaf-id-shared-library + + Generate code that supports shared libraries via the library ID method, + but assumes that this library or executable won't link against any other + ID shared libraries. That allows the compiler to use faster code for jumps + and calls. + +.. option:: -mno-leaf-id-shared-library + + Do not assume that the code being compiled won't link against any ID shared + libraries. Slower code is generated for jump and call insns. + +.. option:: -mleaf-id-shared-library + + Default setting; overrides :option:`-mno-leaf-id-shared-library`. + +.. option:: -mshared-library-id=n + + Specifies the identification number of the ID-based shared library being + compiled. Specifying a value of 0 generates more compact code; specifying + other values forces the allocation of that number to the current + library but is no more space- or time-efficient than omitting this option. + +.. option:: -msep-data + + Generate code that allows the data segment to be located in a different + area of memory from the text segment. This allows for execute in place in + an environment without virtual memory management by eliminating relocations + against the text section. + +.. option:: -mno-sep-data + + Generate code that assumes that the data segment follows the text segment. + This is the default. + +.. option:: -msep-data + + Default setting; overrides :option:`-mno-sep-data`. + +.. option:: -mlong-calls, -mno-long-calls + + Tells the compiler to perform function calls by first loading the + address of the function into a register and then performing a subroutine + call on this register. This switch is needed if the target function + lies outside of the 24-bit addressing range of the offset-based + version of subroutine call instruction. + + This feature is not enabled by default. Specifying + :option:`-mno-long-calls` restores the default behavior. Note these + switches have no effect on how the compiler generates code to handle + function calls via function pointers. + +.. option:: -mfast-fp + + Link with the fast floating-point library. This library relaxes some of + the IEEE floating-point standard's rules for checking inputs against + Not-a-Number (NAN), in the interest of performance. + +.. option:: -minline-plt + + Enable inlining of PLT entries in function calls to functions that are + not known to bind locally. It has no effect without :option:`-mfdpic`. + +.. option:: -mmulticore + + Build a standalone application for multicore Blackfin processors. + This option causes proper start files and link scripts supporting + multicore to be used, and defines the macro ``__BFIN_MULTICORE``. + It can only be used with :option:`-mcpu=bf561[-sirevision]`. + + This option can be used with :option:`-mcorea` or :option:`-mcoreb`, which + selects the one-application-per-core programming model. Without + :option:`-mcorea` or :option:`-mcoreb`, the single-application/dual-core + programming model is used. In this model, the main function of Core B + should be named as ``coreb_main``. + + If this option is not used, the single-core application programming + model is used. + +.. option:: -mcorea + + Build a standalone application for Core A of BF561 when using + the one-application-per-core programming model. Proper start files + and link scripts are used to support Core A, and the macro + ``__BFIN_COREA`` is defined. + This option can only be used in conjunction with :option:`-mmulticore`. + +.. option:: -mcoreb + + Build a standalone application for Core B of BF561 when using + the one-application-per-core programming model. Proper start files + and link scripts are used to support Core B, and the macro + ``__BFIN_COREB`` is defined. When this option is used, ``coreb_main`` + should be used instead of ``main``. + This option can only be used in conjunction with :option:`-mmulticore`. + +.. option:: -msdram + + Build a standalone application for SDRAM. Proper start files and + link scripts are used to put the application into SDRAM, and the macro + ``__BFIN_SDRAM`` is defined. + The loader should initialize SDRAM before loading the application. + +.. option:: -micplb + + Assume that ICPLBs are enabled at run time. This has an effect on certain + anomaly workarounds. For Linux targets, the default is to assume ICPLBs + are enabled; for standalone applications the default is off. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/c-sky-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/c-sky-options.rst new file mode 100644 index 00000000000..77ebf1452be --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/c-sky-options.rst @@ -0,0 +1,193 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: C-SKY + +.. index:: C-SKY Options + +.. _c-sky-options: + +C-SKY Options +^^^^^^^^^^^^^ + +GCC supports these options when compiling for C-SKY V2 processors. + +.. option:: -march={arch} + + Specify the C-SKY target architecture. Valid values for :samp:`{arch}` are: + :samp:`ck801`, :samp:`ck802`, :samp:`ck803`, :samp:`ck807`, and :samp:`ck810`. + The default is :samp:`ck810`. + +.. option:: -mcpu={cpu} + + Specify the C-SKY target processor. Valid values for :samp:`{cpu}` are: + :samp:`ck801`, :samp:`ck801t`, + :samp:`ck802`, :samp:`ck802t`, :samp:`ck802j`, + :samp:`ck803`, :samp:`ck803h`, :samp:`ck803t`, :samp:`ck803ht`, + :samp:`ck803f`, :samp:`ck803fh`, :samp:`ck803e`, :samp:`ck803eh`, + :samp:`ck803et`, :samp:`ck803eht`, :samp:`ck803ef`, :samp:`ck803efh`, + :samp:`ck803ft`, :samp:`ck803eft`, :samp:`ck803efht`, :samp:`ck803r1`, + :samp:`ck803hr1`, :samp:`ck803tr1`, :samp:`ck803htr1`, :samp:`ck803fr1`, + :samp:`ck803fhr1`, :samp:`ck803er1`, :samp:`ck803ehr1`, :samp:`ck803etr1`, + :samp:`ck803ehtr1`, :samp:`ck803efr1`, :samp:`ck803efhr1`, :samp:`ck803ftr1`, + :samp:`ck803eftr1`, :samp:`ck803efhtr1`, + :samp:`ck803s`, :samp:`ck803st`, :samp:`ck803se`, :samp:`ck803sf`, + :samp:`ck803sef`, :samp:`ck803seft`, + :samp:`ck807e`, :samp:`ck807ef`, :samp:`ck807`, :samp:`ck807f`, + :samp:`ck810e`, :samp:`ck810et`, :samp:`ck810ef`, :samp:`ck810eft`, + :samp:`ck810`, :samp:`ck810v`, :samp:`ck810f`, :samp:`ck810t`, :samp:`ck810fv`, + :samp:`ck810tv`, :samp:`ck810ft`, and :samp:`ck810ftv`. + +.. option:: -mbig-endian, -EB, -mlittle-endian, -EL + + Select big- or little-endian code. The default is little-endian. + +.. option:: -mfloat-abi={name} + + Specifies which floating-point ABI to use. Permissible values + are: :samp:`soft`, :samp:`softfp` and :samp:`hard`. + + Specifying :samp:`soft` causes GCC to generate output containing + library calls for floating-point operations. + :samp:`softfp` allows the generation of code using hardware floating-point + instructions, but still uses the soft-float calling conventions. + :samp:`hard` allows generation of floating-point instructions + and uses FPU-specific calling conventions. + + The default depends on the specific target configuration. Note that + the hard-float and soft-float ABIs are not link-compatible; you must + compile your entire program with the same ABI, and link with a + compatible set of libraries. + +.. option:: -mhard-float, -msoft-float + + Select hardware or software floating-point implementations. + The default is soft float. + +.. option:: -mdouble-float, -mno-double-float + + When :option:`-mhard-float` is in effect, enable generation of + double-precision float instructions. This is the default except + when compiling for CK803. + +.. option:: -mfdivdu, -mno-fdivdu + + When :option:`-mhard-float` is in effect, enable generation of + ``frecipd``, ``fsqrtd``, and ``fdivd`` instructions. + This is the default except when compiling for CK803. + +.. option:: -mfpu={fpu} + + Select the floating-point processor. This option can only be used with + :option:`-mhard-float`. + Values for :samp:`{fpu}` are + :samp:`fpv2_sf` (equivalent to :samp:`-mno-double-float -mno-fdivdu`), + :samp:`fpv2` (:samp:`-mdouble-float -mno-divdu`), and + :samp:`fpv2_divd` (:samp:`-mdouble-float -mdivdu`). + +.. option:: -melrw, -mno-elrw + + Enable the extended ``lrw`` instruction. This option defaults to on + for CK801 and off otherwise. + +.. option:: -mistack, -mno-istack + + Enable interrupt stack instructions; the default is off. + + The :option:`-mistack` option is required to handle the + :c-sky-fn-attr:`interrupt` and :c-sky-fn-attr:`isr` function attributes + (see :ref:`c-sky-function-attributes`). + +.. option:: -mmp + + Enable multiprocessor instructions; the default is off. + +.. option:: -mcp + + Enable coprocessor instructions; the default is off. + +.. option:: -mcache + + Enable coprocessor instructions; the default is off. + +.. option:: -msecurity + + Enable C-SKY security instructions; the default is off. + +.. option:: -mtrust + + Enable C-SKY trust instructions; the default is off. + +.. option:: -mdsp, -medsp, -mvdsp + + Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively. + All of these options default to off. + +.. option:: -mdiv, -mno-div + + Generate divide instructions. Default is off. + +.. option:: -msmart, -mno-smart + + Generate code for Smart Mode, using only registers numbered 0-7 to allow + use of 16-bit instructions. This option is ignored for CK801 where this + is the required behavior, and it defaults to on for CK802. + For other targets, the default is off. + +.. option:: -mhigh-registers, -mno-high-registers + + Generate code using the high registers numbered 16-31. This option + is not supported on CK801, CK802, or CK803, and is enabled by default + for other processors. + +.. option:: -manchor, -mno-anchor + + Generate code using global anchor symbol addresses. + +.. option:: -mpushpop, -mno-pushpop + + Generate code using ``push`` and ``pop`` instructions. This option + defaults to on. + +.. option:: -mmultiple-stld, -mstm, -mno-multiple-stld, -mno-stm + + Generate code using ``stm`` and ``ldm`` instructions. This option + isn't supported on CK801 but is enabled by default on other processors. + +.. option:: -mconstpool, -mno-constpool + + Create constant pools in the compiler instead of deferring it to the + assembler. This option is the default and required for correct code + generation on CK801 and CK802, and is optional on other processors. + +.. option:: -mstack-size, -mno-stack-size + + Emit ``.stack_size`` directives for each function in the assembly + output. This option defaults to off. + +.. option:: -mstack-size + + Default setting; overrides :option:`-mno-stack-size`. + +.. option:: -mccrt, -mno-ccrt + + Generate code for the C-SKY compiler runtime instead of libgcc. This + option defaults to off. + +.. option:: -mbranch-cost={n} + + Set the branch costs to roughly ``n`` instructions. The default is 1. + +.. option:: -msched-prolog, -mno-sched-prolog + + Permit scheduling of function prologue and epilogue sequences. Using + this option can result in code that is not compliant with the C-SKY V2 ABI + prologue requirements and that cannot be debugged or backtraced. + It is disabled by default. + +.. option:: -msim + + Links the library libsemi.a which is in compatible with simulator. Applicable + to ELF compiler only. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/c6x-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/c6x-options.rst new file mode 100644 index 00000000000..452e8ebaf49 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/c6x-options.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: C6X + +.. index:: C6X Options + +.. _c6x-options: + +C6X Options +^^^^^^^^^^^ + +.. option:: -march={name} + + This specifies the name of the target architecture. GCC uses this + name to determine what kind of instructions it can emit when generating + assembly code. Permissible names are: :samp:`c62x`, + :samp:`c64x`, :samp:`c64x+`, :samp:`c67x`, :samp:`c67x+`, :samp:`c674x`. + +.. option:: -mbig-endian + + Generate code for a big-endian target. + +.. option:: -mlittle-endian + + Generate code for a little-endian target. This is the default. + +.. option:: -msim + + Choose startup files and linker script suitable for the simulator. + +.. option:: -msdata=default + + Put small global and static data in the ``.neardata`` section, + which is pointed to by register ``B14``. Put small uninitialized + global and static data in the ``.bss`` section, which is adjacent + to the ``.neardata`` section. Put small read-only data into the + ``.rodata`` section. The corresponding sections used for large + pieces of data are ``.fardata``, ``.far`` and ``.const``. + +.. option:: -msdata=all + + Put all data, not just small objects, into the sections reserved for + small data, and use addressing relative to the ``B14`` register to + access them. + +.. option:: -msdata=none + + Make no use of the sections reserved for small data, and use absolute + addresses to access all data. Put all initialized global and static + data in the ``.fardata`` section, and all uninitialized data in the + ``.far`` section. Put all constant data into the ``.const`` + section. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/cris-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/cris-options.rst new file mode 100644 index 00000000000..c0b392ccb3c --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/cris-options.rst @@ -0,0 +1,102 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: CRIS + +.. index:: CRIS Options + +.. _cris-options: + +CRIS Options +^^^^^^^^^^^^ + +These options are defined specifically for the CRIS ports. + +.. option:: -march={architecture-type} + + Generate code for the specified architecture. The choices for + :samp:`{architecture-type}` are :samp:`v3`, :samp:`v8` and :samp:`v10` for + respectively ETRAX4, ETRAX100, and ETRAX100LX. + Default is :samp:`v0`. + +.. option:: -mtune={architecture-type} + + Tune to :samp:`{architecture-type}` everything applicable about the generated + code, except for the ABI and the set of available instructions. The + choices for :samp:`{architecture-type}` are the same as for + :option:`-march=architecture-type`. + +.. option:: -mmax-stack-frame={n} + + Warn when the stack frame of a function exceeds :samp:`{n}` bytes. + +.. option:: -metrax4, -metrax100 + + The options :option:`-metrax4` and :option:`-metrax100` are synonyms for + :option:`-march=v3` and :option:`-march=v8` respectively. + +.. option:: -mmul-bug-workaround, -mno-mul-bug-workaround + + Work around a bug in the ``muls`` and ``mulu`` instructions for CPU + models where it applies. This option is disabled by default. + +.. option:: -mpdebug + + Enable CRIS-specific verbose debug-related information in the assembly + code. This option also has the effect of turning off the :samp:`#NO_APP` + formatted-code indicator to the assembler at the beginning of the + assembly file. + +.. option:: -mcc-init + + Do not use condition-code results from previous instruction; always emit + compare and test instructions before use of condition codes. + +.. option:: -mno-side-effects + + Do not emit instructions with side effects in addressing modes other than + post-increment. + +.. option:: -mside-effects + + Default setting; overrides :option:`-mno-side-effects`. + +.. option:: -mstack-align, -mno-stack-align, -mdata-align, -mno-data-align, -mconst-align, -mno-const-align + + These options (:samp:`no-` options) arrange (eliminate arrangements) for the + stack frame, individual data and constants to be aligned for the maximum + single data access size for the chosen CPU model. The default is to + arrange for 32-bit alignment. ABI details such as structure layout are + not affected by these options. + +.. option:: -m32-bit, -m16-bit, -m8-bit + + Similar to the stack- data- and const-align options above, these options + arrange for stack frame, writable data and constants to all be 32-bit, + 16-bit or 8-bit aligned. The default is 32-bit alignment. + +.. option:: -mno-prologue-epilogue, -mprologue-epilogue + + With :option:`-mno-prologue-epilogue`, the normal function prologue and + epilogue which set up the stack frame are omitted and no return + instructions or return sequences are generated in the code. Use this + option only together with visual inspection of the compiled code: no + warnings or errors are generated when call-saved registers must be saved, + or storage for local variables needs to be allocated. + +.. option:: -melf + + Legacy no-op option. + +.. option:: -sim + + This option arranges + to link with input-output functions from a simulator library. Code, + initialized data and zero-initialized data are allocated consecutively. + +.. option:: -sim2 + + Like :option:`-sim`, but pass linker options to locate initialized data at + 0x40000000 and zero-initialized data at 0x80000000. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/darwin-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/darwin-options.rst new file mode 100644 index 00000000000..8f799f39a81 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/darwin-options.rst @@ -0,0 +1,224 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: Darwin + +.. index:: Darwin options + +.. _darwin-options: + +Darwin Options +^^^^^^^^^^^^^^ + +These options are defined for all architectures running the Darwin operating +system. + +FSF GCC on Darwin does not create 'fat' object files; it creates +an object file for the single architecture that GCC was built to +target. Apple's GCC on Darwin does create 'fat' files if multiple +:option:`-arch` options are used; it does so by running the compiler or +linker multiple times and joining the results together with +:samp:`lipo`. + +The subtype of the file created (like :samp:`ppc7400` or :samp:`ppc970` or +:samp:`i686`) is determined by the flags that specify the ISA +that GCC is targeting, like :option:`-mcpu` or :option:`-march`. The +:option:`-force_cpusubtype_ALL` option can be used to override this. + +The Darwin tools vary in their behavior when presented with an ISA +mismatch. The assembler, :samp:`as`, only permits instructions to +be used that are valid for the subtype of the file it is generating, +so you cannot put 64-bit instructions in a :samp:`ppc750` object file. +The linker for shared libraries, :samp:`/usr/bin/libtool`, fails +and prints an error if asked to create a shared library with a less +restrictive subtype than its input files (for instance, trying to put +a :samp:`ppc970` object file in a :samp:`ppc7400` library). The linker +for executables, :command:`ld`, quietly gives the executable the most +restrictive subtype of any of its input files. + +.. option:: -Fdir + + Add the framework directory :samp:`{dir}` to the head of the list of + directories to be searched for header files. These directories are + interleaved with those specified by :option:`-I` options and are + scanned in a left-to-right order. + + A framework directory is a directory with frameworks in it. A + framework is a directory with a :samp:`Headers` and/or + :samp:`PrivateHeaders` directory contained directly in it that ends + in :samp:`.framework`. The name of a framework is the name of this + directory excluding the :samp:`.framework`. Headers associated with + the framework are found in one of those two directories, with + :samp:`Headers` being searched first. A subframework is a framework + directory that is in a framework's :samp:`Frameworks` directory. + Includes of subframework headers can only appear in a header of a + framework that contains the subframework, or in a sibling subframework + header. Two subframeworks are siblings if they occur in the same + framework. A subframework should not have the same name as a + framework; a warning is issued if this is violated. Currently a + subframework cannot have subframeworks; in the future, the mechanism + may be extended to support this. The standard frameworks can be found + in :samp:`/System/Library/Frameworks` and + :samp:`/Library/Frameworks`. An example include looks like + ``#include ``, where :samp:`Framework` denotes + the name of the framework and :samp:`header.h` is found in the + :samp:`PrivateHeaders` or :samp:`Headers` directory. + +.. option:: -iframeworkdir + + Like :option:`-F` except the directory is a treated as a system + directory. The main difference between this :option:`-iframework` and + :option:`-F` is that with :option:`-iframework` the compiler does not + warn about constructs contained within header files found via + :samp:`{dir}`. This option is valid only for the C family of languages. + +.. option:: -gused + + Emit debugging information for symbols that are used. For stabs + debugging format, this enables :option:`-feliminate-unused-debug-symbols`. + This is by default ON. + +.. option:: -gfull + + Emit debugging information for all symbols and types. + +.. option:: -mmacosx-version-min=version + + The earliest version of MacOS X that this executable will run on + is :samp:`{version}`. Typical values of :samp:`{version}` include ``10.1``, + ``10.2``, and ``10.3.9``. + + If the compiler was built to use the system's headers by default, + then the default for this option is the system version on which the + compiler is running, otherwise the default is to make choices that + are compatible with as many systems and code bases as possible. + +.. option:: -mkernel + + Enable kernel development mode. The :option:`-mkernel` option sets + :option:`-static`, :option:`-fno-common`, :option:`-fno-use-cxa-atexit`, + :option:`-fno-exceptions`, :option:`-fno-non-call-exceptions`, + :option:`-fapple-kext`, :option:`-fno-weak` and :option:`-fno-rtti` where + applicable. This mode also sets :option:`-mno-altivec`, + :option:`-msoft-float`, :option:`-fno-builtin` and + :option:`-mlong-branch` for PowerPC targets. + +.. option:: -mone-byte-bool + + Override the defaults for ``bool`` so that ``sizeof(bool)==1``. + By default ``sizeof(bool)`` is ``4`` when compiling for + Darwin/PowerPC and ``1`` when compiling for Darwin/x86, so this + option has no effect on x86. + + .. warning:: + + The :option:`-mone-byte-bool` switch causes GCC + to generate code that is not binary compatible with code generated + without that switch. Using this switch may require recompiling all + other modules in a program, including system libraries. Use this + switch to conform to a non-default data model. + +.. option:: -mfix-and-continue, -ffix-and-continue, -findirect-data + + Generate code suitable for fast turnaround development, such as to + allow GDB to dynamically load :samp:`.o` files into already-running + programs. :option:`-findirect-data` and :option:`-ffix-and-continue` + are provided for backwards compatibility. + +.. option:: -all_load + + Loads all members of static archive libraries. + See man ld(1) for more information. + +.. option:: -arch_errors_fatal + + Cause the errors having to do with files that have the wrong architecture + to be fatal. + +.. option:: -bind_at_load + + Causes the output file to be marked such that the dynamic linker will + bind all undefined references when the file is loaded or launched. + +.. option:: -bundle + + Produce a Mach-o bundle format file. + See man ld(1) for more information. + +.. option:: -bundle_loader {executable} + + This option specifies the :samp:`{executable}` that will load the build + output file being linked. See man ld(1) for more information. + +.. option:: -dynamiclib + + When passed this option, GCC produces a dynamic library instead of + an executable when linking, using the Darwin :samp:`libtool` command. + +.. option:: -force_cpusubtype_ALL + + This causes GCC's output file to have the :samp:`ALL` subtype, instead of + one controlled by the :option:`-mcpu` or :option:`-march` option. + +.. option:: -allowable_client {client_name} +.. option:: -compatibility_version +.. option:: -current_version +.. option:: -dead_strip +.. option:: -dependency-file +.. option:: -dylib_file +.. option:: -dylinker_install_name +.. option:: -dynamic +.. option:: -exported_symbols_list +.. option:: -filelist +.. option:: -flat_namespace +.. option:: -force_flat_namespace +.. option:: -headerpad_max_install_names +.. option:: -image_base +.. option:: -init +.. option:: -install_name +.. option:: -keep_private_externs +.. option:: -multi_module +.. option:: -multiply_defined +.. option:: -multiply_defined_unused +.. option:: -noall_load +.. option:: -no_dead_strip_inits_and_terms +.. option:: -nofixprebinding +.. option:: -nomultidefs +.. option:: -noprebind +.. option:: -noseglinkedit +.. option:: -pagezero_size +.. option:: -prebind +.. option:: -prebind_all_twolevel_modules +.. option:: -private_bundle +.. option:: -read_only_relocs +.. option:: -sectalign +.. option:: -sectobjectsymbols +.. option:: -whyload +.. option:: -seg1addr +.. option:: -sectcreate +.. option:: -sectobjectsymbols +.. option:: -sectorder +.. option:: -segaddr +.. option:: -segs_read_only_addr +.. option:: -segs_read_write_addr +.. option:: -seg_addr_table +.. option:: -seg_addr_table_filename +.. option:: -seglinkedit +.. option:: -segprot +.. option:: -segs_read_only_addr +.. option:: -segs_read_write_addr +.. option:: -single_module +.. option:: -static +.. option:: -sub_library +.. option:: -sub_umbrella +.. option:: -twolevel_namespace +.. option:: -umbrella +.. option:: -undefined +.. option:: -unexported_symbols_list +.. option:: -weak_reference_mismatches +.. option:: -whatsloaded + + These options are passed to the Darwin linker. The Darwin linker man page + describes them in detail. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/dec-alpha-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/dec-alpha-options.rst new file mode 100644 index 00000000000..f9571c4aec9 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/dec-alpha-options.rst @@ -0,0 +1,274 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: DEC Alpha + +.. _dec-alpha-options: + +DEC Alpha Options +^^^^^^^^^^^^^^^^^ + +These :samp:`-m` options are defined for the DEC Alpha implementations: + +.. option:: -mno-soft-float, -msoft-float + + Use (do not use) the hardware floating-point instructions for + floating-point operations. When :option:`-msoft-float` is specified, + functions in :samp:`libgcc.a` are used to perform floating-point + operations. Unless they are replaced by routines that emulate the + floating-point operations, or compiled in such a way as to call such + emulations routines, these routines issue floating-point + operations. If you are compiling for an Alpha without floating-point + operations, you must ensure that the library is built so as not to call + them. + + Note that Alpha implementations without floating-point operations are + required to have floating-point registers. + +.. option:: -mfp-reg, -mno-fp-regs + + Generate code that uses (does not use) the floating-point register set. + :option:`-mno-fp-regs` implies :option:`-msoft-float`. If the floating-point + register set is not used, floating-point operands are passed in integer + registers as if they were integers and floating-point results are passed + in ``$0`` instead of ``$f0``. This is a non-standard calling sequence, + so any function with a floating-point argument or return value called by code + compiled with :option:`-mno-fp-regs` must also be compiled with that + option. + + A typical use of this option is building a kernel that does not use, + and hence need not save and restore, any floating-point registers. + +.. option:: -mieee + + The Alpha architecture implements floating-point hardware optimized for + maximum performance. It is mostly compliant with the IEEE floating-point + standard. However, for full compliance, software assistance is + required. This option generates code fully IEEE-compliant code + *except* that the :samp:`{inexact-flag}` is not maintained (see below). + If this option is turned on, the preprocessor macro ``_IEEE_FP`` is + defined during compilation. The resulting code is less efficient but is + able to correctly support denormalized numbers and exceptional IEEE + values such as not-a-number and plus/minus infinity. Other Alpha + compilers call this option :option:`-ieee_with_no_inexact`. + +.. option:: -mieee-with-inexact + + This is like :option:`-mieee` except the generated code also maintains + the IEEE :samp:`{inexact-flag}`. Turning on this option causes the + generated code to implement fully-compliant IEEE math. In addition to + ``_IEEE_FP``, ``_IEEE_FP_EXACT`` is defined as a preprocessor + macro. On some Alpha implementations the resulting code may execute + significantly slower than the code generated by default. Since there is + very little code that depends on the :samp:`{inexact-flag}`, you should + normally not specify this option. Other Alpha compilers call this + option :option:`-ieee_with_inexact`. + +.. option:: -mfp-trap-mode={trap-mode} + + This option controls what floating-point related traps are enabled. + Other Alpha compilers call this option :option:`-fptm trap-mode`. + The trap mode can be set to one of four values: + + :samp:`n` + This is the default (normal) setting. The only traps that are enabled + are the ones that cannot be disabled in software (e.g., division by zero + trap). + + :samp:`u` + In addition to the traps enabled by :samp:`n`, underflow traps are enabled + as well. + + :samp:`su` + Like :samp:`u`, but the instructions are marked to be safe for software + completion (see Alpha architecture manual for details). + + :samp:`sui` + Like :samp:`su`, but inexact traps are enabled as well. + +.. option:: -mfp-rounding-mode={rounding-mode} + + Selects the IEEE rounding mode. Other Alpha compilers call this option + :option:`-fprm rounding-mode`. The :samp:`{rounding-mode}` can be one + of: + + :samp:`n` + Normal IEEE rounding mode. Floating-point numbers are rounded towards + the nearest machine number or towards the even machine number in case + of a tie. + + :samp:`m` + Round towards minus infinity. + + :samp:`c` + Chopped rounding mode. Floating-point numbers are rounded towards zero. + + :samp:`d` + Dynamic rounding mode. A field in the floating-point control register + (:samp:`{fpcr}`, see Alpha architecture reference manual) controls the + rounding mode in effect. The C library initializes this register for + rounding towards plus infinity. Thus, unless your program modifies the + :samp:`{fpcr}`, :samp:`d` corresponds to round towards plus infinity. + +.. option:: -mtrap-precision={trap-precision} + + In the Alpha architecture, floating-point traps are imprecise. This + means without software assistance it is impossible to recover from a + floating trap and program execution normally needs to be terminated. + GCC can generate code that can assist operating system trap handlers + in determining the exact location that caused a floating-point trap. + Depending on the requirements of an application, different levels of + precisions can be selected: + + :samp:`p` + Program precision. This option is the default and means a trap handler + can only identify which program caused a floating-point exception. + + :samp:`f` + Function precision. The trap handler can determine the function that + caused a floating-point exception. + + :samp:`i` + Instruction precision. The trap handler can determine the exact + instruction that caused a floating-point exception. + + Other Alpha compilers provide the equivalent options called + :option:`-scope_safe` and :option:`-resumption_safe`. + +.. option:: -mieee-conformant + + This option marks the generated code as IEEE conformant. You must not + use this option unless you also specify :option:`-mtrap-precision=i` and either + :option:`-mfp-trap-mode=su` or :option:`-mfp-trap-mode=sui`. Its only effect + is to emit the line :samp:`.eflag 48` in the function prologue of the + generated assembly file. + +.. option:: -mbuild-constants + + Normally GCC examines a 32- or 64-bit integer constant to + see if it can construct it from smaller constants in two or three + instructions. If it cannot, it outputs the constant as a literal and + generates code to load it from the data segment at run time. + + Use this option to require GCC to construct *all* integer constants + using code, even if it takes more instructions (the maximum is six). + + You typically use this option to build a shared library dynamic + loader. Itself a shared library, it must relocate itself in memory + before it can find the variables and constants in its own data segment. + +.. option:: -mbwx, -mno-bwx, -mcix, -mno-cix, -mfix, -mno-fix, -mmax, -mno-max + + Indicate whether GCC should generate code to use the optional BWX, + CIX, FIX and MAX instruction sets. The default is to use the instruction + sets supported by the CPU type specified via :option:`-mcpu=` option or that + of the CPU on which GCC was built if none is specified. + +.. option:: -mfloat-vax, -mfloat-ieee + + Generate code that uses (does not use) VAX F and G floating-point + arithmetic instead of IEEE single and double precision. + +.. option:: -mexplicit-relocs, -mno-explicit-relocs + + Older Alpha assemblers provided no way to generate symbol relocations + except via assembler macros. Use of these macros does not allow + optimal instruction scheduling. GNU binutils as of version 2.12 + supports a new syntax that allows the compiler to explicitly mark + which relocations should apply to which instructions. This option + is mostly useful for debugging, as GCC detects the capabilities of + the assembler when it is built and sets the default accordingly. + +.. option:: -msmall-data, -mlarge-data + + When :option:`-mexplicit-relocs` is in effect, static data is + accessed via :dfn:`gp-relative` relocations. When :option:`-msmall-data` + is used, objects 8 bytes long or smaller are placed in a :dfn:`small data area` + (the ``.sdata`` and ``.sbss`` sections) and are accessed via + 16-bit relocations off of the ``$gp`` register. This limits the + size of the small data area to 64KB, but allows the variables to be + directly accessed via a single instruction. + + The default is :option:`-mlarge-data`. With this option the data area + is limited to just below 2GB. Programs that require more than 2GB of + data must use ``malloc`` or ``mmap`` to allocate the data in the + heap instead of in the program's data segment. + + When generating code for shared libraries, :option:`-fpic` implies + :option:`-msmall-data` and :option:`-fPIC` implies :option:`-mlarge-data`. + +.. option:: -msmall-text, -mlarge-text + + When :option:`-msmall-text` is used, the compiler assumes that the + code of the entire program (or shared library) fits in 4MB, and is + thus reachable with a branch instruction. When :option:`-msmall-data` + is used, the compiler can assume that all local symbols share the + same ``$gp`` value, and thus reduce the number of instructions + required for a function call from 4 to 1. + + The default is :option:`-mlarge-text`. + +.. option:: -mcpu={cpu_type} + + Set the instruction set and instruction scheduling parameters for + machine type :samp:`{cpu_type}`. You can specify either the :samp:`EV` + style name or the corresponding chip number. GCC supports scheduling + parameters for the EV4, EV5 and EV6 family of processors and + chooses the default values for the instruction set from the processor + you specify. If you do not specify a processor type, GCC defaults + to the processor on which the compiler was built. + + Supported values for :samp:`{cpu_type}` are + + :samp:`ev4` :samp:`ev45` :samp:`21064` + Schedules as an EV4 and has no instruction set extensions. + + :samp:`ev5` :samp:`21164` + Schedules as an EV5 and has no instruction set extensions. + + :samp:`ev56` :samp:`21164a` + Schedules as an EV5 and supports the BWX extension. + + :samp:`pca56` :samp:`21164pc` :samp:`21164PC` + Schedules as an EV5 and supports the BWX and MAX extensions. + + :samp:`ev6` :samp:`21264` + Schedules as an EV6 and supports the BWX, FIX, and MAX extensions. + + :samp:`ev67` :samp:`21264a` + Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions. + + Native toolchains also support the value :samp:`native`, + which selects the best architecture option for the host processor. + :option:`-mcpu=native` has no effect if GCC does not recognize + the processor. + +.. option:: -mtune={cpu_type} + + Set only the instruction scheduling parameters for machine type + :samp:`{cpu_type}`. The instruction set is not changed. + + Native toolchains also support the value :samp:`native`, + which selects the best architecture option for the host processor. + :option:`-mtune=native` has no effect if GCC does not recognize + the processor. + +.. option:: -mmemory-latency={time} + + Sets the latency the scheduler should assume for typical memory + references as seen by the application. This number is highly + dependent on the memory access patterns used by the application + and the size of the external cache on the machine. + + Valid options for :samp:`{time}` are + + :samp:`number` + A decimal number representing clock cycles. + + :samp:`L1` :samp:`L2` :samp:`L3` :samp:`main` + The compiler contains estimates of the number of clock cycles for + 'typical' EV4 & EV5 hardware for the Level 1, 2 & 3 caches + (also called Dcache, Scache, and Bcache), as well as to main memory. + Note that L3 is only valid for EV5. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/ebpf-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/ebpf-options.rst new file mode 100644 index 00000000000..724beef4d2b --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/ebpf-options.rst @@ -0,0 +1,94 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: eBPF + +.. index:: eBPF Options + +.. _ebpf-options: + +eBPF Options +^^^^^^^^^^^^ + +.. index:: eBPF Options + +.. option:: -mframe-limit=bytes + + This specifies the hard limit for frame sizes, in bytes. Currently, + the value that can be specified should be less than or equal to + :samp:`32767`. Defaults to whatever limit is imposed by the version of + the Linux kernel targeted. + +.. option:: -mkernel={version} + + This specifies the minimum version of the kernel that will run the + compiled program. GCC uses this version to determine which + instructions to use, what kernel helpers to allow, etc. Currently, + :samp:`{version}` can be one of :samp:`4.0`, :samp:`4.1`, :samp:`4.2`, + :samp:`4.3`, :samp:`4.4`, :samp:`4.5`, :samp:`4.6`, :samp:`4.7`, + :samp:`4.8`, :samp:`4.9`, :samp:`4.10`, :samp:`4.11`, :samp:`4.12`, + :samp:`4.13`, :samp:`4.14`, :samp:`4.15`, :samp:`4.16`, :samp:`4.17`, + :samp:`4.18`, :samp:`4.19`, :samp:`4.20`, :samp:`5.0`, :samp:`5.1`, + :samp:`5.2`, :samp:`latest` and :samp:`native`. + +.. option:: -mbig-endian + + Generate code for a big-endian target. + +.. option:: -mlittle-endian + + Generate code for a little-endian target. This is the default. + +.. option:: -mjmpext + + Enable generation of extra conditional-branch instructions. + Enabled for CPU v2 and above. + +.. option:: -mjmp32 + + Enable 32-bit jump instructions. Enabled for CPU v3 and above. + +.. option:: -malu32 + + Enable 32-bit ALU instructions. Enabled for CPU v3 and above. + +.. option:: -mcpu={version} + + This specifies which version of the eBPF ISA to target. Newer versions + may not be supported by all kernels. The default is :samp:`v3`. + + Supported values for :samp:`{version}` are: + + :samp:`v1` + The first stable eBPF ISA with no special features or extensions. + + :samp:`v2` + Supports the jump extensions, as in :option:`-mjmpext`. + + :samp:`v3` + All features of v2, plus: + + * 32-bit jump operations, as in :option:`-mjmp32` + + * 32-bit ALU operations, as in :option:`-malu32` + +.. option:: -mco-re + + Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and + is implied by :option:`-gbtf`. + +.. option:: -mno-co-re + + Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE + support is enabled by default when generating BTF debug information for + the BPF target. + +.. option:: -mxbpf + + Generate code for an expanded version of BPF, which relaxes some of + the restrictions imposed by the BPF architecture: + + * Save and restore callee-saved registers at function entry and + exit, respectively. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/fr30-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/fr30-options.rst new file mode 100644 index 00000000000..cd03df9fbb3 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/fr30-options.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: FR30 + +.. index:: FR30 Options + +.. _fr30-options: + +FR30 Options +^^^^^^^^^^^^ + +These options are defined specifically for the FR30 port. + +.. option:: -msmall-model + + Use the small address space model. This can produce smaller code, but + it does assume that all symbolic values and addresses fit into a + 20-bit range. + +.. option:: -mno-lsim + + Assume that runtime support has been provided and so there is no need + to include the simulator library (:samp:`libsim.a`) on the linker + command line. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/frv-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/frv-options.rst new file mode 100644 index 00000000000..bb7ce7ccb40 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/frv-options.rst @@ -0,0 +1,279 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: FRV + +.. index:: FRV Options + +.. _frv-options: + +FRV Options +^^^^^^^^^^^ + +.. option:: -mgpr-32 + + Only use the first 32 general-purpose registers. + +.. option:: -mgpr-64 + + Use all 64 general-purpose registers. + +.. option:: -mfpr-32 + + Use only the first 32 floating-point registers. + +.. option:: -mfpr-64 + + Use all 64 floating-point registers. + +.. option:: -mhard-float + + Use hardware instructions for floating-point operations. + +.. option:: -msoft-float + + Use library routines for floating-point operations. + +.. option:: -malloc-cc + + Dynamically allocate condition code registers. + +.. option:: -mfixed-cc + + Do not try to dynamically allocate condition code registers, only + use ``icc0`` and ``fcc0``. + +.. option:: -mdword + + Change ABI to use double word insns. + +.. option:: -mno-dword + + Do not use double word instructions. + +.. option:: -mdword + + Default setting; overrides :option:`-mno-dword`. + +.. option:: -mdouble + + Use floating-point double instructions. + +.. option:: -mno-double + + Do not use floating-point double instructions. + +.. option:: -mmedia + + Use media instructions. + +.. option:: -mno-media + + Do not use media instructions. + +.. option:: -mmuladd + + Use multiply and add/subtract instructions. + +.. option:: -mno-muladd + + Do not use multiply and add/subtract instructions. + +.. option:: -mfdpic + + Select the FDPIC ABI, which uses function descriptors to represent + pointers to functions. Without any PIC/PIE-related options, it + implies :option:`-fPIE`. With :option:`-fpic` or :option:`-fpie`, it + assumes GOT entries and small data are within a 12-bit range from the + GOT base address; with :option:`-fPIC` or :option:`-fPIE`, GOT offsets + are computed with 32 bits. + With a :samp:`bfin-elf` target, this option implies :option:`-msim`. + +.. option:: -minline-plt + + Enable inlining of PLT entries in function calls to functions that are + not known to bind locally. It has no effect without :option:`-mfdpic`. + It's enabled by default if optimizing for speed and compiling for + shared libraries (i.e., :option:`-fPIC` or :option:`-fpic`), or when an + optimization option such as :option:`-O3` or above is present in the + command line. + +.. option:: -mTLS + + Assume a large TLS segment when generating thread-local code. + +.. option:: -mtls + + Do not assume a large TLS segment when generating thread-local code. + +.. option:: -mgprel-ro + + Enable the use of ``GPREL`` relocations in the FDPIC ABI for data + that is known to be in read-only sections. It's enabled by default, + except for :option:`-fpic` or :option:`-fpie` : even though it may help + make the global offset table smaller, it trades 1 instruction for 4. + With :option:`-fPIC` or :option:`-fPIE`, it trades 3 instructions for 4, + one of which may be shared by multiple symbols, and it avoids the need + for a GOT entry for the referenced symbol, so it's more likely to be a + win. If it is not, :option:`-mno-gprel-ro` can be used to disable it. + +.. option:: -multilib-library-pic + + Link with the (library, not FD) pic libraries. It's implied by + :option:`-mlibrary-pic`, as well as by :option:`-fPIC` and + :option:`-fpic` without :option:`-mfdpic`. You should never have to use + it explicitly. + +.. option:: -mlinked-fp + + Follow the EABI requirement of always creating a frame pointer whenever + a stack frame is allocated. This option is enabled by default and can + be disabled with :option:`-mno-linked-fp`. + +.. option:: -mlong-calls + + Use indirect addressing to call functions outside the current + compilation unit. This allows the functions to be placed anywhere + within the 32-bit address space. + +.. option:: -malign-labels + + Try to align labels to an 8-byte boundary by inserting NOPs into the + previous packet. This option only has an effect when VLIW packing + is enabled. It doesn't create new packets; it merely adds NOPs to + existing ones. + +.. option:: -mlibrary-pic + + Generate position-independent EABI code. + +.. option:: -macc-4 + + Use only the first four media accumulator registers. + +.. option:: -macc-8 + + Use all eight media accumulator registers. + +.. option:: -mpack + + Pack VLIW instructions. + +.. option:: -mno-pack + + Do not pack VLIW instructions. + +.. option:: -mno-eflags + + Do not mark ABI switches in e_flags. + +.. option:: -mcond-move + + Enable the use of conditional-move instructions (default). + + This switch is mainly for debugging the compiler and will likely be removed + in a future version. + +.. option:: -mno-cond-move + + Disable the use of conditional-move instructions. + + This switch is mainly for debugging the compiler and will likely be removed + in a future version. + +.. option:: -mscc + + Enable the use of conditional set instructions (default). + + This switch is mainly for debugging the compiler and will likely be removed + in a future version. + +.. option:: -mno-scc + + Disable the use of conditional set instructions. + + This switch is mainly for debugging the compiler and will likely be removed + in a future version. + +.. option:: -mcond-exec + + Enable the use of conditional execution (default). + + This switch is mainly for debugging the compiler and will likely be removed + in a future version. + +.. option:: -mno-cond-exec + + Disable the use of conditional execution. + + This switch is mainly for debugging the compiler and will likely be removed + in a future version. + +.. option:: -mvliw-branch + + Run a pass to pack branches into VLIW instructions (default). + + This switch is mainly for debugging the compiler and will likely be removed + in a future version. + +.. option:: -mno-vliw-branch + + Do not run a pass to pack branches into VLIW instructions. + + This switch is mainly for debugging the compiler and will likely be removed + in a future version. + +.. option:: -mmulti-cond-exec + + Enable optimization of ``&&`` and ``||`` in conditional execution + (default). + + This switch is mainly for debugging the compiler and will likely be removed + in a future version. + +.. option:: -mno-multi-cond-exec + + Disable optimization of ``&&`` and ``||`` in conditional execution. + + This switch is mainly for debugging the compiler and will likely be removed + in a future version. + +.. option:: -mnested-cond-exec + + Enable nested conditional execution optimizations (default). + + This switch is mainly for debugging the compiler and will likely be removed + in a future version. + +.. option:: -mno-nested-cond-exec + + Disable nested conditional execution optimizations. + + This switch is mainly for debugging the compiler and will likely be removed + in a future version. + +.. option:: -moptimize-membar + + This switch removes redundant ``membar`` instructions from the + compiler-generated code. It is enabled by default. + +.. option:: -mno-optimize-membar + + This switch disables the automatic removal of redundant ``membar`` + instructions from the generated code. + +.. option:: -moptimize-membar + + Default setting; overrides :option:`-mno-optimize-membar`. + +.. option:: -mtomcat-stats + + Cause gas to print out tomcat statistics. + +.. option:: -mcpu={cpu} + + Select the processor type for which to generate code. Possible values are + :samp:`frv`, :samp:`fr550`, :samp:`tomcat`, :samp:`fr500`, :samp:`fr450`, + :samp:`fr405`, :samp:`fr400`, :samp:`fr300` and :samp:`simple`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/ft32-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/ft32-options.rst new file mode 100644 index 00000000000..7f865697890 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/ft32-options.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: FT32 + +.. index:: FT32 Options + +.. _ft32-options: + +FT32 Options +^^^^^^^^^^^^ + +These options are defined specifically for the FT32 port. + +.. option:: -msim + + Specifies that the program will be run on the simulator. This causes + an alternate runtime startup and library to be linked. + You must not use this option when generating programs that will run on + real hardware; you must provide your own runtime library for whatever + I/O functions are needed. + +.. option:: -mlra + + Enable Local Register Allocation. This is still experimental for FT32, + so by default the compiler uses standard reload. + +.. option:: -mnodiv + + Do not use div and mod instructions. + +.. option:: -mft32b + + Enable use of the extended instructions of the FT32B processor. + +.. option:: -mcompress + + Compress all code using the Ft32B code compression scheme. + +.. option:: -mnopm + + Do not generate code that reads program memory. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/gnu-linux-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/gnu-linux-options.rst new file mode 100644 index 00000000000..6ba0182513f --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/gnu-linux-options.rst @@ -0,0 +1,56 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: GNU/Linux + +.. _gnu-linux-options: + +GNU/Linux Options +^^^^^^^^^^^^^^^^^ + +These :samp:`-m` options are defined for GNU/Linux targets: + +.. option:: -mglibc + + Use the GNU C library. This is the default except + on :samp:`*-*-linux-*uclibc*`, :samp:`*-*-linux-*musl*` and + :samp:`*-*-linux-*android*` targets. + +.. option:: -muclibc + + Use uClibc C library. This is the default on + :samp:`*-*-linux-*uclibc*` targets. + +.. option:: -mmusl + + Use the musl C library. This is the default on + :samp:`*-*-linux-*musl*` targets. + +.. option:: -mbionic + + Use Bionic C library. This is the default on + :samp:`*-*-linux-*android*` targets. + +.. option:: -mandroid + + Compile code compatible with Android platform. This is the default on + :samp:`*-*-linux-*android*` targets. + + When compiling, this option enables :option:`-mbionic`, :option:`-fPIC`, + :option:`-fno-exceptions` and :option:`-fno-rtti` by default. When linking, + this option makes the GCC driver pass Android-specific options to the linker. + Finally, this option causes the preprocessor macro ``__ANDROID__`` + to be defined. + +.. option:: -tno-android-cc + + Disable compilation effects of :option:`-mandroid`, i.e., do not enable + :option:`-mbionic`, :option:`-fPIC`, :option:`-fno-exceptions` and + :option:`-fno-rtti` by default. + +.. option:: -tno-android-ld + + Disable linking effects of :option:`-mandroid`, i.e., pass standard Linux + linking options to the linker. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/h8-300-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/h8-300-options.rst new file mode 100644 index 00000000000..c9219ffb7d4 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/h8-300-options.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: H8/300 + +.. _h8-300-options: + +H8/300 Options +^^^^^^^^^^^^^^ + +These :samp:`-m` options are defined for the H8/300 implementations: + +.. option:: -mrelax + + Shorten some address references at link time, when possible; uses the + linker option :option:`-relax`. See `Using ld `_ + for a fuller description. + +.. option:: -mh + + Generate code for the H8/300H. + +.. option:: -ms + + Generate code for the H8S. + +.. option:: -mn + + Generate code for the H8S and H8/300H in the normal mode. This switch + must be used either with :option:`-mh` or :option:`-ms`. + +.. option:: -ms2600 + + Generate code for the H8S/2600. This switch must be used with :option:`-ms`. + +.. option:: -mexr + + Extended registers are stored on stack before execution of function + with monitor attribute. Default option is :option:`-mexr`. + This option is valid only for H8S targets. + +.. option:: -mno-exr + + Extended registers are not stored on stack before execution of function + with monitor attribute. Default option is :option:`-mno-exr`. + This option is valid only for H8S targets. + +.. option:: -mexr + + Default setting; overrides :option:`-mno-exr`. + +.. option:: -mint32 + + Make ``int`` data 32 bits by default. + +.. option:: -malign-300 + + On the H8/300H and H8S, use the same alignment rules as for the H8/300. + The default for the H8/300H and H8S is to align longs and floats on + 4-byte boundaries. + :option:`-malign-300` causes them to be aligned on 2-byte boundaries. + This option has no effect on the H8/300. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/hppa-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/hppa-options.rst new file mode 100644 index 00000000000..3f1196554c3 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/hppa-options.rst @@ -0,0 +1,245 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: HPPA + +.. index:: HPPA Options + +.. _hppa-options: + +HPPA Options +^^^^^^^^^^^^ + +These :samp:`-m` options are defined for the HPPA family of computers: + +.. option:: -march={architecture-type} + + Generate code for the specified architecture. The choices for + :samp:`{architecture-type}` are :samp:`1.0` for PA 1.0, :samp:`1.1` for PA + 1.1, and :samp:`2.0` for PA 2.0 processors. Refer to + :samp:`/usr/lib/sched.models` on an HP-UX system to determine the proper + architecture option for your machine. Code compiled for lower numbered + architectures runs on higher numbered architectures, but not the + other way around. + +.. option:: -mpa-risc-1-0, -mpa-risc-1-1, -mpa-risc-2-0 + + Synonyms for :option:`-march=1.0`, :option:`-march=1.1`, and :option:`-march=2.0` respectively. + +.. option:: -mcaller-copies + + The caller copies function arguments passed by hidden reference. This + option should be used with care as it is not compatible with the default + 32-bit runtime. However, only aggregates larger than eight bytes are + passed by hidden reference and the option provides better compatibility + with OpenMP. + +.. option:: -mjump-in-delay + + This option is ignored and provided for compatibility purposes only. + +.. option:: -mdisable-fpregs + + Prevent floating-point registers from being used in any manner. This is + necessary for compiling kernels that perform lazy context switching of + floating-point registers. If you use this option and attempt to perform + floating-point operations, the compiler aborts. + +.. option:: -mdisable-indexing + + Prevent the compiler from using indexing address modes. This avoids some + rather obscure problems when compiling MIG generated code under MACH. + +.. option:: -mno-space-regs + + Generate code that assumes the target has no space registers. This allows + GCC to generate faster indirect calls and use unscaled index address modes. + + Such code is suitable for level 0 PA systems and kernels. + +.. option:: -mspace-regs + + Default setting; overrides :option:`-mno-space-regs`. + +.. option:: -mfast-indirect-calls + + Generate code that assumes calls never cross space boundaries. This + allows GCC to emit code that performs faster indirect calls. + + This option does not work in the presence of shared libraries or nested + functions. + +.. option:: -mfixed-range={register-range} + + Generate code treating the given register range as fixed registers. + A fixed register is one that the register allocator cannot use. This is + useful when compiling kernel code. A register range is specified as + two registers separated by a dash. Multiple register ranges can be + specified separated by a comma. + +.. option:: -mlong-load-store + + Generate 3-instruction load and store sequences as sometimes required by + the HP-UX 10 linker. This is equivalent to the :samp:`+k` option to + the HP compilers. + +.. option:: -mportable-runtime + + Use the portable calling conventions proposed by HP for ELF systems. + +.. option:: -mgas + + Enable the use of assembler directives only GAS understands. + +.. option:: -mschedule={cpu-type} + + Schedule code according to the constraints for the machine type + :samp:`{cpu-type}`. The choices for :samp:`{cpu-type}` are :samp:`700` + :samp:`7100`, :samp:`7100LC`, :samp:`7200`, :samp:`7300` and :samp:`8000`. Refer + to :samp:`/usr/lib/sched.models` on an HP-UX system to determine the + proper scheduling option for your machine. The default scheduling is + :samp:`8000`. + +.. option:: -mlinker-opt + + Enable the optimization pass in the HP-UX linker. Note this makes symbolic + debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9 + linkers in which they give bogus error messages when linking some programs. + +.. option:: -msoft-float + + Generate output containing library calls for floating point. + + .. warning:: + + The requisite libraries are not available for all HPPA + targets. Normally the facilities of the machine's usual C compiler are + used, but this cannot be done directly in cross-compilation. You must make + your own arrangements to provide suitable library functions for + cross-compilation. + + :option:`-msoft-float` changes the calling convention in the output file; + therefore, it is only useful if you compile *all* of a program with + this option. In particular, you need to compile :samp:`libgcc.a`, the + library that comes with GCC, with :option:`-msoft-float` in order for + this to work. + +.. option:: -msio + + Generate the predefine, ``_SIO``, for server IO. The default is + :option:`-mwsio`. This generates the predefines, ``__hp9000s700``, + ``__hp9000s700__`` and ``_WSIO``, for workstation IO. These + options are available under HP-UX and HI-UX. + +.. option:: -mgnu-ld + + Use options specific to GNU :command:`ld`. + This passes :option:`-shared` to :command:`ld` when + building a shared library. It is the default when GCC is configured, + explicitly or implicitly, with the GNU linker. This option does not + affect which :command:`ld` is called; it only changes what parameters + are passed to that :command:`ld`. + The :command:`ld` that is called is determined by the + :option:`--with-ld` configure option, GCC's program search path, and + finally by the user's :envvar:`PATH`. The linker used by GCC can be printed + using :samp:`which `gcc -print-prog-name=ld``. This option is only available + on the 64-bit HP-UX GCC, i.e. configured with :samp:`hppa*64*-*-hpux*`. + +.. option:: -mhp-ld + + Use options specific to HP :command:`ld`. + This passes :option:`-b` to :command:`ld` when building + a shared library and passes +Accept TypeMismatch to :command:`ld` on all + links. It is the default when GCC is configured, explicitly or + implicitly, with the HP linker. This option does not affect + which :command:`ld` is called; it only changes what parameters are passed to that + :command:`ld`. + The :command:`ld` that is called is determined by the :option:`--with-ld` + configure option, GCC's program search path, and finally by the user's + :envvar:`PATH`. The linker used by GCC can be printed using :samp:`which + `gcc -print-prog-name=ld``. This option is only available on the 64-bit + HP-UX GCC, i.e. configured with :samp:`hppa*64*-*-hpux*`. + +.. option:: -mlong-calls + + Generate code that uses long call sequences. This ensures that a call + is always able to reach linker generated stubs. The default is to generate + long calls only when the distance from the call site to the beginning + of the function or translation unit, as the case may be, exceeds a + predefined limit set by the branch type being used. The limits for + normal calls are 7,600,000 and 240,000 bytes, respectively for the + PA 2.0 and PA 1.X architectures. Sibcalls are always limited at + 240,000 bytes. + + Distances are measured from the beginning of functions when using the + :option:`-ffunction-sections` option, or when using the :option:`-mgas` + and :option:`-mno-portable-runtime` options together under HP-UX with + the SOM linker. + + It is normally not desirable to use this option as it degrades + performance. However, it may be useful in large applications, + particularly when partial linking is used to build the application. + + The types of long calls used depends on the capabilities of the + assembler and linker, and the type of code being generated. The + impact on systems that support long absolute calls, and long pic + symbol-difference or pc-relative calls should be relatively small. + However, an indirect call is used on 32-bit ELF systems in pic code + and it is quite long. + +.. option:: -mno-long-calls + + Default setting; overrides :option:`-mlong-calls`. + +.. option:: -munix={unix-std} + + Generate compiler predefines and select a startfile for the specified + UNIX standard. The choices for :samp:`{unix-std}` are :samp:`93`, :samp:`95` + and :samp:`98`. :samp:`93` is supported on all HP-UX versions. :samp:`95` + is available on HP-UX 10.10 and later. :samp:`98` is available on HP-UX + 11.11 and later. The default values are :samp:`93` for HP-UX 10.00, + :samp:`95` for HP-UX 10.10 though to 11.00, and :samp:`98` for HP-UX 11.11 + and later. + + :option:`-munix=93` provides the same predefines as GCC 3.3 and 3.4. + :option:`-munix=95` provides additional predefines for ``XOPEN_UNIX`` + and ``_XOPEN_SOURCE_EXTENDED``, and the startfile :samp:`unix95.o`. + :option:`-munix=98` provides additional predefines for ``_XOPEN_UNIX``, + ``_XOPEN_SOURCE_EXTENDED``, ``_INCLUDE__STDC_A1_SOURCE`` and + ``_INCLUDE_XOPEN_SOURCE_500``, and the startfile :samp:`unix98.o`. + + It is *important* to note that this option changes the interfaces + for various library routines. It also affects the operational behavior + of the C library. Thus, *extreme* care is needed in using this + option. + + Library code that is intended to operate with more than one UNIX + standard must test, set and restore the variable ``__xpg4_extended_mask`` + as appropriate. Most GNU software doesn't provide this capability. + +.. option:: -nolibdld + + Suppress the generation of link options to search libdld.sl when the + :option:`-static` option is specified on HP-UX 10 and later. + +.. option:: -static + + The HP-UX implementation of setlocale in libc has a dependency on + libdld.sl. There isn't an archive version of libdld.sl. Thus, + when the :option:`-static` option is specified, special link options + are needed to resolve this dependency. + + On HP-UX 10 and later, the GCC driver adds the necessary options to + link with libdld.sl when the :option:`-static` option is specified. + This causes the resulting binary to be dynamic. On the 64-bit port, + the linkers generate dynamic binaries by default in any case. The + :option:`-nolibdld` option can be used to prevent the GCC driver from + adding these link options. + +.. option:: -threads + + Add support for multithreading with the :dfn:`dce thread` library + under HP-UX. This option sets flags for both the preprocessor and + linker. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/ia-64-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/ia-64-options.rst new file mode 100644 index 00000000000..15299b9bdfd --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/ia-64-options.rst @@ -0,0 +1,261 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: IA-64 + +.. index:: IA-64 Options + +.. _ia-64-options: + +IA-64 Options +^^^^^^^^^^^^^ + +These are the :samp:`-m` options defined for the Intel IA-64 architecture. + +.. option:: -mbig-endian + + Generate code for a big-endian target. This is the default for HP-UX. + +.. option:: -mlittle-endian + + Generate code for a little-endian target. This is the default for AIX5 + and GNU/Linux. + +.. option:: -mgnu-as, -mno-gnu-as + + Generate (or don't) code for the GNU assembler. This is the default. + + .. Also, this is the default if the configure option @option{-with-gnu-as} + + .. is used. + +.. option:: -mgnu-ld, -mno-gnu-ld + + Generate (or don't) code for the GNU linker. This is the default. + + .. Also, this is the default if the configure option @option{-with-gnu-ld} + + .. is used. + +.. option:: -mno-pic + + Generate code that does not use a global pointer register. The result + is not position independent code, and violates the IA-64 ABI. + +.. option:: -mvolatile-asm-stop, -mno-volatile-asm-stop + + Generate (or don't) a stop bit immediately before and after volatile asm + statements. + +.. option:: -mregister-names, -mno-register-names + + Generate (or don't) :samp:`in`, :samp:`loc`, and :samp:`out` register names for + the stacked registers. This may make assembler output more readable. + +.. option:: -mno-sdata, -msdata + + Disable (or enable) optimizations that use the small data section. This may + be useful for working around optimizer bugs. + +.. option:: -mconstant-gp + + Generate code that uses a single constant global pointer value. This is + useful when compiling kernel code. + +.. option:: -mauto-pic + + Generate code that is self-relocatable. This implies :option:`-mconstant-gp`. + This is useful when compiling firmware code. + +.. option:: -minline-float-divide-min-latency + + Generate code for inline divides of floating-point values + using the minimum latency algorithm. + +.. option:: -minline-float-divide-max-throughput + + Generate code for inline divides of floating-point values + using the maximum throughput algorithm. + +.. option:: -mno-inline-float-divide + + Do not generate inline code for divides of floating-point values. + +.. option:: -minline-int-divide-min-latency + + Generate code for inline divides of integer values + using the minimum latency algorithm. + +.. option:: -minline-int-divide-max-throughput + + Generate code for inline divides of integer values + using the maximum throughput algorithm. + +.. option:: -mno-inline-int-divide + + Do not generate inline code for divides of integer values. + +.. option:: -minline-int-divide + + Default setting; overrides :option:`-mno-inline-int-divide`. + +.. option:: -minline-sqrt-min-latency + + Generate code for inline square roots + using the minimum latency algorithm. + +.. option:: -minline-sqrt-max-throughput + + Generate code for inline square roots + using the maximum throughput algorithm. + +.. option:: -mno-inline-sqrt + + Do not generate inline code for ``sqrt``. + +.. option:: -mfused-madd, -mno-fused-madd + + Do (don't) generate code that uses the fused multiply/add or multiply/subtract + instructions. The default is to use these instructions. + +.. option:: -mno-dwarf2-asm, -mdwarf2-asm + + Don't (or do) generate assembler code for the DWARF line number debugging + info. This may be useful when not using the GNU assembler. + +.. option:: -mearly-stop-bits, -mno-early-stop-bits + + Allow stop bits to be placed earlier than immediately preceding the + instruction that triggered the stop bit. This can improve instruction + scheduling, but does not always do so. + +.. option:: -mfixed-range={register-range} + + Generate code treating the given register range as fixed registers. + A fixed register is one that the register allocator cannot use. This is + useful when compiling kernel code. A register range is specified as + two registers separated by a dash. Multiple register ranges can be + specified separated by a comma. + +.. option:: -mtls-size={tls-size} + + Specify bit size of immediate TLS offsets. Valid values are 14, 22, and + 64. + +.. option:: -mtune={cpu-type} + + Tune the instruction scheduling for a particular CPU, Valid values are + :samp:`itanium`, :samp:`itanium1`, :samp:`merced`, :samp:`itanium2`, + and :samp:`mckinley`. + +.. option:: -milp32, -mlp64 + + Generate code for a 32-bit or 64-bit environment. + The 32-bit environment sets int, long and pointer to 32 bits. + The 64-bit environment sets int to 32 bits and long and pointer + to 64 bits. These are HP-UX specific flags. + +.. option:: -mno-sched-br-data-spec, -msched-br-data-spec + + (Dis/En)able data speculative scheduling before reload. + This results in generation of ``ld.a`` instructions and + the corresponding check instructions (``ld.c`` / ``chk.a``). + The default setting is disabled. + +.. option:: -msched-ar-data-spec, -mno-sched-ar-data-spec + + (En/Dis)able data speculative scheduling after reload. + This results in generation of ``ld.a`` instructions and + the corresponding check instructions (``ld.c`` / ``chk.a``). + The default setting is enabled. + +.. option:: -mno-sched-control-spec, -msched-control-spec + + (Dis/En)able control speculative scheduling. This feature is + available only during region scheduling (i.e. before reload). + This results in generation of the ``ld.s`` instructions and + the corresponding check instructions ``chk.s``. + The default setting is disabled. + +.. option:: -msched-br-in-data-spec, -mno-sched-br-in-data-spec + + (En/Dis)able speculative scheduling of the instructions that + are dependent on the data speculative loads before reload. + This is effective only with :option:`-msched-br-data-spec` enabled. + The default setting is enabled. + +.. option:: -msched-ar-in-data-spec, -mno-sched-ar-in-data-spec + + (En/Dis)able speculative scheduling of the instructions that + are dependent on the data speculative loads after reload. + This is effective only with :option:`-msched-ar-data-spec` enabled. + The default setting is enabled. + +.. option:: -msched-in-control-spec, -mno-sched-in-control-spec + + (En/Dis)able speculative scheduling of the instructions that + are dependent on the control speculative loads. + This is effective only with :option:`-msched-control-spec` enabled. + The default setting is enabled. + +.. option:: -mno-sched-prefer-non-data-spec-insns, -msched-prefer-non-data-spec-insns + + If enabled, data-speculative instructions are chosen for schedule + only if there are no other choices at the moment. This makes + the use of the data speculation much more conservative. + The default setting is disabled. + +.. option:: -mno-sched-prefer-non-control-spec-insns, -msched-prefer-non-control-spec-insns + + If enabled, control-speculative instructions are chosen for schedule + only if there are no other choices at the moment. This makes + the use of the control speculation much more conservative. + The default setting is disabled. + +.. option:: -mno-sched-count-spec-in-critical-path, -msched-count-spec-in-critical-path + + If enabled, speculative dependencies are considered during + computation of the instructions priorities. This makes the use of the + speculation a bit more conservative. + The default setting is disabled. + +.. option:: -msched-spec-ldc + + Use a simple data speculation check. This option is on by default. + +.. option:: -msched-control-spec-ldc + + Use a simple check for control speculation. This option is on by default. + +.. option:: -msched-stop-bits-after-every-cycle + + Place a stop bit after every cycle when scheduling. This option is on + by default. + +.. option:: -msched-fp-mem-deps-zero-cost + + Assume that floating-point stores and loads are not likely to cause a conflict + when placed into the same instruction group. This option is disabled by + default. + +.. option:: -msel-sched-dont-check-control-spec + + Generate checks for control speculation in selective scheduling. + This flag is disabled by default. + +.. option:: -msched-max-memory-insns={max-insns} + + Limit on the number of memory insns per instruction group, giving lower + priority to subsequent memory insns attempting to schedule in the same + instruction group. Frequently useful to prevent cache bank conflicts. + The default value is 1. + +.. option:: -msched-max-memory-insns-hard-limit + + Makes the limit specified by msched-max-memory-insns a hard limit, + disallowing more than that number in an instruction group. + Otherwise, the limit is 'soft', meaning that non-memory operations + are preferred when the limit is reached, but memory operations may still + be scheduled. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/ibm-rs-6000-and-powerpc-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/ibm-rs-6000-and-powerpc-options.rst new file mode 100644 index 00000000000..10b4e64a374 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/ibm-rs-6000-and-powerpc-options.rst @@ -0,0 +1,1017 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: IBM RS/6000 and PowerPC + +.. index:: RS/6000 and PowerPC Options, IBM RS/6000 and PowerPC Options + +.. _rs-6000-and-powerpc-options: + +IBM RS/6000 and PowerPC Options +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These :samp:`-m` options are defined for the IBM RS/6000 and PowerPC: + +.. option:: -mpowerpc-gpopt, -mno-powerpc-gpopt, -mpowerpc-gfxopt, -mno-powerpc-gfxopt, -mpowerpc64, -mno-powerpc64, -mmfcrf, -mno-mfcrf, -mpopcntb, -mno-popcntb, -mpopcntd, -mno-popcntd, -mfprnd, -mno-fprnd, -mcmpb, -mno-cmpb, -mhard-dfp, -mno-hard-dfp + + You use these options to specify which instructions are available on the + processor you are using. The default value of these options is + determined when configuring GCC. Specifying the + :option:`-mcpu=cpu_type` overrides the specification of these + options. We recommend you use the :option:`-mcpu=cpu_type` option + rather than the options listed above. + + Specifying :option:`-mpowerpc-gpopt` allows + GCC to use the optional PowerPC architecture instructions in the + General Purpose group, including floating-point square root. Specifying + :option:`-mpowerpc-gfxopt` allows GCC to + use the optional PowerPC architecture instructions in the Graphics + group, including floating-point select. + + The :option:`-mmfcrf` option allows GCC to generate the move from + condition register field instruction implemented on the POWER4 + processor and other processors that support the PowerPC V2.01 + architecture. + The :option:`-mpopcntb` option allows GCC to generate the popcount and + double-precision FP reciprocal estimate instruction implemented on the + POWER5 processor and other processors that support the PowerPC V2.02 + architecture. + The :option:`-mpopcntd` option allows GCC to generate the popcount + instruction implemented on the POWER7 processor and other processors + that support the PowerPC V2.06 architecture. + The :option:`-mfprnd` option allows GCC to generate the FP round to + integer instructions implemented on the POWER5+ processor and other + processors that support the PowerPC V2.03 architecture. + The :option:`-mcmpb` option allows GCC to generate the compare bytes + instruction implemented on the POWER6 processor and other processors + that support the PowerPC V2.05 architecture. + The :option:`-mhard-dfp` option allows GCC to generate the decimal + floating-point instructions implemented on some POWER processors. + + The :option:`-mpowerpc64` option allows GCC to generate the additional + 64-bit instructions that are found in the full PowerPC64 architecture + and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to + :option:`-mno-powerpc64`. + +.. option:: -mcpu={cpu_type} + + Set architecture type, register usage, and + instruction scheduling parameters for machine type :samp:`{cpu_type}`. + Supported values for :samp:`{cpu_type}` are :samp:`401`, :samp:`403`, + :samp:`405`, :samp:`405fp`, :samp:`440`, :samp:`440fp`, :samp:`464`, :samp:`464fp`, + :samp:`476`, :samp:`476fp`, :samp:`505`, :samp:`601`, :samp:`602`, :samp:`603`, + :samp:`603e`, :samp:`604`, :samp:`604e`, :samp:`620`, :samp:`630`, :samp:`740`, + :samp:`7400`, :samp:`7450`, :samp:`750`, :samp:`801`, :samp:`821`, :samp:`823`, + :samp:`860`, :samp:`970`, :samp:`8540`, :samp:`a2`, :samp:`e300c2`, + :samp:`e300c3`, :samp:`e500mc`, :samp:`e500mc64`, :samp:`e5500`, + :samp:`e6500`, :samp:`ec603e`, :samp:`G3`, :samp:`G4`, :samp:`G5`, + :samp:`titan`, :samp:`power3`, :samp:`power4`, :samp:`power5`, :samp:`power5+`, + :samp:`power6`, :samp:`power6x`, :samp:`power7`, :samp:`power8`, + :samp:`power9`, :samp:`power10`, :samp:`powerpc`, :samp:`powerpc64`, + :samp:`powerpc64le`, :samp:`rs64`, and :samp:`native`. + + :option:`-mcpu=powerpc`, :option:`-mcpu=powerpc64`, and + :option:`-mcpu=powerpc64le` specify pure 32-bit PowerPC (either + endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC + architecture machine types, with an appropriate, generic processor + model assumed for scheduling purposes. + + Specifying :samp:`native` as cpu type detects and selects the + architecture option that corresponds to the host processor of the + system performing the compilation. + :option:`-mcpu=native` has no effect if GCC does not recognize the + processor. + + The other options specify a specific processor. Code generated under + those options runs best on that processor, and may not run at all on + others. + + The :option:`-mcpu` options automatically enable or disable the + following options: + + :option:`-maltivec` :option:`-mfprnd` :option:`-mhard-float` :option:`-mmfcrf` :option:`-mmultiple` |gol| + :option:`-mpopcntb` :option:`-mpopcntd` :option:`-mpowerpc64` |gol| + :option:`-mpowerpc-gpopt` :option:`-mpowerpc-gfxopt` |gol| + :option:`-mmulhw` :option:`-mdlmzb` :option:`-mmfpgpr` :option:`-mvsx` |gol| + :option:`-mcrypto` :option:`-mhtm` :option:`-mpower8-fusion` :option:`-mpower8-vector` |gol| + :option:`-mquad-memory` :option:`-mquad-memory-atomic` :option:`-mfloat128` |gol| + :option:`-mfloat128-hardware` :option:`-mprefixed` :option:`-mpcrel` :option:`-mmma` |gol| + :option:`-mrop-protect` + + The particular options set for any particular CPU varies between + compiler versions, depending on what setting seems to produce optimal + code for that CPU; it doesn't necessarily reflect the actual hardware's + capabilities. If you wish to set an individual option to a particular + value, you may specify it after the :option:`-mcpu` option, like + :option:`-mcpu=970 -mno-altivec`. + + On AIX, the :option:`-maltivec` and :option:`-mpowerpc64` options are + not enabled or disabled by the :option:`-mcpu` option at present because + AIX does not have full support for these options. You may still + enable or disable them individually if you're sure it'll work in your + environment. + +.. option:: -mtune={cpu_type} + + Set the instruction scheduling parameters for machine type + :samp:`{cpu_type}`, but do not set the architecture type or register usage, + as :option:`-mcpu=cpu_type` does. The same + values for :samp:`{cpu_type}` are used for :option:`-mtune` as for + :option:`-mcpu`. If both are specified, the code generated uses the + architecture and registers set by :option:`-mcpu`, but the + scheduling parameters set by :option:`-mtune`. + +.. option:: -mcmodel=small + + Generate PowerPC64 code for the small model: The TOC is limited to + 64k. + +.. option:: -mcmodel=medium + + Generate PowerPC64 code for the medium model: The TOC and other static + data may be up to a total of 4G in size. This is the default for 64-bit + Linux. + +.. option:: -mcmodel=large + + Generate PowerPC64 code for the large model: The TOC may be up to 4G + in size. Other data and code is only limited by the 64-bit address + space. + +.. option:: -maltivec, -mno-altivec + + Generate code that uses (does not use) AltiVec instructions, and also + enable the use of built-in functions that allow more direct access to + the AltiVec instruction set. You may also need to set + :option:`-mabi=altivec` to adjust the current ABI with AltiVec ABI + enhancements. + + When :option:`-maltivec` is used, the element order for AltiVec intrinsics + such as ``vec_splat``, ``vec_extract``, and ``vec_insert`` + match array element order corresponding to the endianness of the + target. That is, element zero identifies the leftmost element in a + vector register when targeting a big-endian platform, and identifies + the rightmost element in a vector register when targeting a + little-endian platform. + +.. option:: -mvrsave, -mno-vrsave + + Generate VRSAVE instructions when generating AltiVec code. + +.. option:: -msecure-plt + + Generate code that allows :command:`ld` and :command:`ld.so` + to build executables and shared + libraries with non-executable ``.plt`` and ``.got`` sections. + This is a PowerPC + 32-bit SYSV ABI option. + +.. option:: -mbss-plt + + Generate code that uses a BSS ``.plt`` section that :command:`ld.so` + fills in, and + requires ``.plt`` and ``.got`` + sections that are both writable and executable. + This is a PowerPC 32-bit SYSV ABI option. + +.. option:: -misel, -mno-isel + + This switch enables or disables the generation of ISEL instructions. + +.. option:: -mvsx, -mno-vsx + + Generate code that uses (does not use) vector/scalar (VSX) + instructions, and also enable the use of built-in functions that allow + more direct access to the VSX instruction set. + +.. option:: -mcrypto, -mno-crypto + + Enable the use (disable) of the built-in functions that allow direct + access to the cryptographic instructions that were added in version + 2.07 of the PowerPC ISA. + +.. option:: -mhtm, -mno-htm + + Enable (disable) the use of the built-in functions that allow direct + access to the Hardware Transactional Memory (HTM) instructions that + were added in version 2.07 of the PowerPC ISA. + +.. option:: -mpower8-fusion, -mno-power8-fusion + + Generate code that keeps (does not keeps) some integer operations + adjacent so that the instructions can be fused together on power8 and + later processors. + +.. option:: -mpower8-vector, -mno-power8-vector + + Generate code that uses (does not use) the vector and scalar + instructions that were added in version 2.07 of the PowerPC ISA. Also + enable the use of built-in functions that allow more direct access to + the vector instructions. + +.. option:: -mquad-memory, -mno-quad-memory + + Generate code that uses (does not use) the non-atomic quad word memory + instructions. The :option:`-mquad-memory` option requires use of + 64-bit mode. + +.. option:: -mquad-memory-atomic, -mno-quad-memory-atomic + + Generate code that uses (does not use) the atomic quad word memory + instructions. The :option:`-mquad-memory-atomic` option requires use of + 64-bit mode. + +.. option:: -mfloat128, -mno-float128 + + Enable/disable the :samp:`{__float128}` keyword for IEEE 128-bit floating point + and use either software emulation for IEEE 128-bit floating point or + hardware instructions. + + The VSX instruction set (:option:`-mvsx`) must be enabled to use the IEEE + 128-bit floating point support. The IEEE 128-bit floating point is only + supported on Linux. + + The default for :option:`-mfloat128` is enabled on PowerPC Linux + systems using the VSX instruction set, and disabled on other systems. + + If you use the ISA 3.0 instruction set (:option:`-mpower9-vector` or + :option:`-mcpu=power9`) on a 64-bit system, the IEEE 128-bit floating + point support will also enable the generation of ISA 3.0 IEEE 128-bit + floating point instructions. Otherwise, if you do not specify to + generate ISA 3.0 instructions or you are targeting a 32-bit big endian + system, IEEE 128-bit floating point will be done with software + emulation. + +.. option:: -mfloat128-hardware, -mno-float128-hardware + + Enable/disable using ISA 3.0 hardware instructions to support the + :samp:`{__float128}` data type. + + The default for :option:`-mfloat128-hardware` is enabled on PowerPC + Linux systems using the ISA 3.0 instruction set, and disabled on other + systems. + +.. option:: -m32, -m64 + + Generate code for 32-bit or 64-bit environments of Darwin and SVR4 + targets (including GNU/Linux). The 32-bit environment sets int, long + and pointer to 32 bits and generates code that runs on any PowerPC + variant. The 64-bit environment sets int to 32 bits and long and + pointer to 64 bits, and generates code for PowerPC64, as for + :option:`-mpowerpc64`. + +.. option:: -mfull-toc, -mno-fp-in-toc, -mno-sum-in-toc, -mminimal-toc + + Modify generation of the TOC (Table Of Contents), which is created for + every executable file. The :option:`-mfull-toc` option is selected by + default. In that case, GCC allocates at least one TOC entry for + each unique non-automatic variable reference in your program. GCC + also places floating-point constants in the TOC. However, only + 16,384 entries are available in the TOC. + + If you receive a linker error message that saying you have overflowed + the available TOC space, you can reduce the amount of TOC space used + with the :option:`-mno-fp-in-toc` and :option:`-mno-sum-in-toc` options. + :option:`-mno-fp-in-toc` prevents GCC from putting floating-point + constants in the TOC and :option:`-mno-sum-in-toc` forces GCC to + generate code to calculate the sum of an address and a constant at + run time instead of putting that sum into the TOC. You may specify one + or both of these options. Each causes GCC to produce very slightly + slower and larger code at the expense of conserving TOC space. + + If you still run out of space in the TOC even when you specify both of + these options, specify :option:`-mminimal-toc` instead. This option causes + GCC to make only one TOC entry for every file. When you specify this + option, GCC produces code that is slower and larger but which + uses extremely little TOC space. You may wish to use this option + only on files that contain less frequently-executed code. + +.. option:: -maix64, -maix32 + + Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit + ``long`` type, and the infrastructure needed to support them. + Specifying :option:`-maix64` implies :option:`-mpowerpc64`, + while :option:`-maix32` disables the 64-bit ABI and + implies :option:`-mno-powerpc64`. GCC defaults to :option:`-maix32`. + +.. option:: -mxl-compat, -mno-xl-compat + + Produce code that conforms more closely to IBM XL compiler semantics + when using AIX-compatible ABI. Pass floating-point arguments to + prototyped functions beyond the register save area (RSA) on the stack + in addition to argument FPRs. Do not assume that most significant + double in 128-bit long double value is properly rounded when comparing + values and converting to double. Use XL symbol names for long double + support routines. + + The AIX calling convention was extended but not initially documented to + handle an obscure K&R C case of calling a function that takes the + address of its arguments with fewer arguments than declared. IBM XL + compilers access floating-point arguments that do not fit in the + RSA from the stack when a subroutine is compiled without + optimization. Because always storing floating-point arguments on the + stack is inefficient and rarely needed, this option is not enabled by + default and only is necessary when calling subroutines compiled by IBM + XL compilers without optimization. + +.. option:: -mpe + + Support :dfn:`IBM RS/6000 SP` :dfn:`Parallel Environment` (PE). Link an + application written to use message passing with special startup code to + enable the application to run. The system must have PE installed in the + standard location (:samp:`/usr/lpp/ppe.poe/`), or the :samp:`specs` file + must be overridden with the :option:`-specs=` option to specify the + appropriate directory location. The Parallel Environment does not + support threads, so the :option:`-mpe` option and the :option:`-pthread` + option are incompatible. + +.. option:: -malign-natural, -malign-power + + On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option + :option:`-malign-natural` overrides the ABI-defined alignment of larger + types, such as floating-point doubles, on their natural size-based boundary. + The option :option:`-malign-power` instructs GCC to follow the ABI-specified + alignment rules. GCC defaults to the standard alignment defined in the ABI. + + On 64-bit Darwin, natural alignment is the default, and :option:`-malign-power` + is not supported. + +.. option:: -msoft-float, -mhard-float + + Generate code that does not use (uses) the floating-point register set. + Software floating-point emulation is provided if you use the + :option:`-msoft-float` option, and pass the option to GCC when linking. + +.. option:: -mmultiple, -mno-multiple + + Generate code that uses (does not use) the load multiple word + instructions and the store multiple word instructions. These + instructions are generated by default on POWER systems, and not + generated on PowerPC systems. Do not use :option:`-mmultiple` on little-endian + PowerPC systems, since those instructions do not work when the + processor is in little-endian mode. The exceptions are PPC740 and + PPC750 which permit these instructions in little-endian mode. + +.. option:: -mupdate, -mno-update + + Generate code that uses (does not use) the load or store instructions + that update the base register to the address of the calculated memory + location. These instructions are generated by default. If you use + :option:`-mno-update`, there is a small window between the time that the + stack pointer is updated and the address of the previous frame is + stored, which means code that walks the stack frame across interrupts or + signals may get corrupted data. + +.. option:: -mavoid-indexed-addresses, -mno-avoid-indexed-addresses + + Generate code that tries to avoid (not avoid) the use of indexed load + or store instructions. These instructions can incur a performance + penalty on Power6 processors in certain situations, such as when + stepping through large arrays that cross a 16M boundary. This option + is enabled by default when targeting Power6 and disabled otherwise. + +.. option:: -mfused-madd, -mno-fused-madd + + Generate code that uses (does not use) the floating-point multiply and + accumulate instructions. These instructions are generated by default + if hardware floating point is used. The machine-dependent + :option:`-mfused-madd` option is now mapped to the machine-independent + :option:`-ffp-contract=fast` option, and :option:`-mno-fused-madd` is + mapped to :option:`-ffp-contract=off`. + +.. option:: -mmulhw, -mno-mulhw + + Generate code that uses (does not use) the half-word multiply and + multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors. + These instructions are generated by default when targeting those + processors. + +.. option:: -mdlmzb, -mno-dlmzb + + Generate code that uses (does not use) the string-search :samp:`dlmzb` + instruction on the IBM 405, 440, 464 and 476 processors. This instruction is + generated by default when targeting those processors. + +.. option:: -mno-bit-align, -mbit-align + + On System V.4 and embedded PowerPC systems do not (do) force structures + and unions that contain bit-fields to be aligned to the base type of the + bit-field. + + For example, by default a structure containing nothing but 8 + ``unsigned`` bit-fields of length 1 is aligned to a 4-byte + boundary and has a size of 4 bytes. By using :option:`-mno-bit-align`, + the structure is aligned to a 1-byte boundary and is 1 byte in + size. + +.. option:: -mno-strict-align, -mstrict-align + + On System V.4 and embedded PowerPC systems do not (do) assume that + unaligned memory references are handled by the system. + +.. option:: -mrelocatable, -mno-relocatable + + Generate code that allows (does not allow) a static executable to be + relocated to a different address at run time. A simple embedded + PowerPC system loader should relocate the entire contents of + ``.got2`` and 4-byte locations listed in the ``.fixup`` section, + a table of 32-bit addresses generated by this option. For this to + work, all objects linked together must be compiled with + :option:`-mrelocatable` or :option:`-mrelocatable-lib`. + :option:`-mrelocatable` code aligns the stack to an 8-byte boundary. + +.. option:: -mrelocatable-lib, -mno-relocatable-lib + + Like :option:`-mrelocatable`, :option:`-mrelocatable-lib` generates a + ``.fixup`` section to allow static executables to be relocated at + run time, but :option:`-mrelocatable-lib` does not use the smaller stack + alignment of :option:`-mrelocatable`. Objects compiled with + :option:`-mrelocatable-lib` may be linked with objects compiled with + any combination of the :option:`-mrelocatable` options. + +.. option:: -mno-toc, -mtoc + + On System V.4 and embedded PowerPC systems do not (do) assume that + register 2 contains a pointer to a global area pointing to the addresses + used in the program. + +.. option:: -mlittle, -mlittle-endian + + On System V.4 and embedded PowerPC systems compile code for the + processor in little-endian mode. The :option:`-mlittle-endian` option is + the same as :option:`-mlittle`. + +.. option:: -mbig, -mbig-endian + + On System V.4 and embedded PowerPC systems compile code for the + processor in big-endian mode. The :option:`-mbig-endian` option is + the same as :option:`-mbig`. + +.. option:: -mdynamic-no-pic + + On Darwin and Mac OS X systems, compile code so that it is not + relocatable, but that its external references are relocatable. The + resulting code is suitable for applications, but not shared + libraries. + +.. option:: -msingle-pic-base + + Treat the register used for PIC addressing as read-only, rather than + loading it in the prologue for each function. The runtime system is + responsible for initializing this register with an appropriate value + before execution begins. + +.. option:: -mprioritize-restricted-insns={priority} + + This option controls the priority that is assigned to + dispatch-slot restricted instructions during the second scheduling + pass. The argument :samp:`{priority}` takes the value :samp:`0`, :samp:`1`, + or :samp:`2` to assign no, highest, or second-highest (respectively) + priority to dispatch-slot restricted + instructions. + +.. option:: -msched-costly-dep={dependence_type} + + This option controls which dependences are considered costly + by the target during instruction scheduling. The argument + :samp:`{dependence_type}` takes one of the following values: + + no + No dependence is costly. + + all + All dependences are costly. + + true_store_to_load + A true dependence from store to load is costly. + + store_to_load + Any dependence from store to load is costly. + + number + Any dependence for which the latency is greater than or equal to + :samp:`{number}` is costly. + +.. option:: -minsert-sched-nops={scheme} + + This option controls which NOP insertion scheme is used during + the second scheduling pass. The argument :samp:`{scheme}` takes one of the + following values: + + no + Don't insert NOPs. + + pad + Pad with NOPs any dispatch group that has vacant issue slots, + according to the scheduler's grouping. + + regroup_exact + Insert NOPs to force costly dependent insns into + separate groups. Insert exactly as many NOPs as needed to force an insn + to a new group, according to the estimated processor grouping. + + number + Insert NOPs to force costly dependent insns into + separate groups. Insert :samp:`{number}` NOPs to force an insn to a new group. + +.. option:: -mcall-sysv + + On System V.4 and embedded PowerPC systems compile code using calling + conventions that adhere to the March 1995 draft of the System V + Application Binary Interface, PowerPC processor supplement. This is the + default unless you configured GCC using :samp:`powerpc-*-eabiaix`. + +.. option:: -mcall-sysv-eabi, -mcall-eabi + + Specify both :option:`-mcall-sysv` and :option:`-meabi` options. + +.. option:: -mcall-sysv-noeabi + + Specify both :option:`-mcall-sysv` and :option:`-mno-eabi` options. + +.. option:: -mcall-aixdesc + + On System V.4 and embedded PowerPC systems compile code for the AIX + operating system. + +.. option:: -mcall-linux + + On System V.4 and embedded PowerPC systems compile code for the + Linux-based GNU system. + +.. option:: -mcall-freebsd + + On System V.4 and embedded PowerPC systems compile code for the + FreeBSD operating system. + +.. option:: -mcall-netbsd + + On System V.4 and embedded PowerPC systems compile code for the + NetBSD operating system. + +.. option:: -mcall-openbsd + + On System V.4 and embedded PowerPC systems compile code for the + OpenBSD operating system. + +.. option:: -mtraceback={traceback_type} + + Select the type of traceback table. Valid values for :samp:`{traceback_type}` + are :samp:`full`, :samp:`part`, and :samp:`no`. + +.. option:: -maix-struct-return + + Return all structures in memory (as specified by the AIX ABI). + +.. option:: -msvr4-struct-return + + Return structures smaller than 8 bytes in registers (as specified by the + SVR4 ABI). + +.. option:: -mabi={abi-type} + + Extend the current ABI with a particular extension, or remove such extension. + Valid values are: :samp:`altivec`, :samp:`no-altivec`, + :samp:`ibmlongdouble`, :samp:`ieeelongdouble`, + :samp:`elfv1`, :samp:`elfv2`, + and for AIX: :samp:`vec-extabi`, :samp:`vec-default`. + +.. option:: -mabi=ibmlongdouble + + Change the current ABI to use IBM extended-precision long double. + This is not likely to work if your system defaults to using IEEE + extended-precision long double. If you change the long double type + from IEEE extended-precision, the compiler will issue a warning unless + you use the :option:`-Wno-psabi` option. Requires :option:`-mlong-double-128` + to be enabled. + +.. option:: -mabi=ieeelongdouble + + Change the current ABI to use IEEE extended-precision long double. + This is not likely to work if your system defaults to using IBM + extended-precision long double. If you change the long double type + from IBM extended-precision, the compiler will issue a warning unless + you use the :option:`-Wno-psabi` option. Requires :option:`-mlong-double-128` + to be enabled. + +.. option:: -mabi=elfv1 + + Change the current ABI to use the ELFv1 ABI. + This is the default ABI for big-endian PowerPC 64-bit Linux. + Overriding the default ABI requires special system support and is + likely to fail in spectacular ways. + +.. option:: -mabi=elfv2 + + Change the current ABI to use the ELFv2 ABI. + This is the default ABI for little-endian PowerPC 64-bit Linux. + Overriding the default ABI requires special system support and is + likely to fail in spectacular ways. + +.. option:: -mgnu-attribute, -mno-gnu-attribute + + Emit .gnu_attribute assembly directives to set tag/value pairs in a + .gnu.attributes section that specify ABI variations in function + parameters or return values. + +.. option:: -mprototype, -mno-prototype + + On System V.4 and embedded PowerPC systems assume that all calls to + variable argument functions are properly prototyped. Otherwise, the + compiler must insert an instruction before every non-prototyped call to + set or clear bit 6 of the condition code register (``CR``) to + indicate whether floating-point values are passed in the floating-point + registers in case the function takes variable arguments. With + :option:`-mprototype`, only calls to prototyped variable argument functions + set or clear the bit. + +.. option:: -msim + + On embedded PowerPC systems, assume that the startup module is called + :samp:`sim-crt0.o` and that the standard C libraries are :samp:`libsim.a` and + :samp:`libc.a`. This is the default for :samp:`powerpc-*-eabisim` + configurations. + +.. option:: -mmvme + + On embedded PowerPC systems, assume that the startup module is called + :samp:`crt0.o` and the standard C libraries are :samp:`libmvme.a` and + :samp:`libc.a`. + +.. option:: -mads + + On embedded PowerPC systems, assume that the startup module is called + :samp:`crt0.o` and the standard C libraries are :samp:`libads.a` and + :samp:`libc.a`. + +.. option:: -myellowknife + + On embedded PowerPC systems, assume that the startup module is called + :samp:`crt0.o` and the standard C libraries are :samp:`libyk.a` and + :samp:`libc.a`. + +.. option:: -mvxworks + + On System V.4 and embedded PowerPC systems, specify that you are + compiling for a VxWorks system. + +.. option:: -memb + + On embedded PowerPC systems, set the ``PPC_EMB`` bit in the ELF flags + header to indicate that :samp:`eabi` extended relocations are used. + +.. option:: -meabi, -mno-eabi + + On System V.4 and embedded PowerPC systems do (do not) adhere to the + Embedded Applications Binary Interface (EABI), which is a set of + modifications to the System V.4 specifications. Selecting :option:`-meabi` + means that the stack is aligned to an 8-byte boundary, a function + ``__eabi`` is called from ``main`` to set up the EABI + environment, and the :option:`-msdata` option can use both ``r2`` and + ``r13`` to point to two separate small data areas. Selecting + :option:`-mno-eabi` means that the stack is aligned to a 16-byte boundary, + no EABI initialization function is called from ``main``, and the + :option:`-msdata` option only uses ``r13`` to point to a single + small data area. The :option:`-meabi` option is on by default if you + configured GCC using one of the :samp:`powerpc*-*-eabi*` options. + +.. option:: -msdata=eabi + + On System V.4 and embedded PowerPC systems, put small initialized + ``const`` global and static data in the ``.sdata2`` section, which + is pointed to by register ``r2``. Put small initialized + non- ``const`` global and static data in the ``.sdata`` section, + which is pointed to by register ``r13``. Put small uninitialized + global and static data in the ``.sbss`` section, which is adjacent to + the ``.sdata`` section. The :option:`-msdata=eabi` option is + incompatible with the :option:`-mrelocatable` option. The + :option:`-msdata=eabi` option also sets the :option:`-memb` option. + +.. option:: -msdata=sysv + + On System V.4 and embedded PowerPC systems, put small global and static + data in the ``.sdata`` section, which is pointed to by register + ``r13``. Put small uninitialized global and static data in the + ``.sbss`` section, which is adjacent to the ``.sdata`` section. + The :option:`-msdata=sysv` option is incompatible with the + :option:`-mrelocatable` option. + +.. option:: -msdata=default + + On System V.4 and embedded PowerPC systems, if :option:`-meabi` is used, + compile code the same as :option:`-msdata=eabi`, otherwise compile code the + same as :option:`-msdata=sysv`. + +.. option:: -msdata=data + + On System V.4 and embedded PowerPC systems, put small global + data in the ``.sdata`` section. Put small uninitialized global + data in the ``.sbss`` section. Do not use register ``r13`` + to address small data however. This is the default behavior unless + other :option:`-msdata` options are used. + +.. option:: -msdata=none + + On embedded PowerPC systems, put all initialized global and static data + in the ``.data`` section, and all uninitialized data in the + ``.bss`` section. + +.. option:: -mreadonly-in-sdata + + Put read-only objects in the ``.sdata`` section as well. This is the + default. + +.. option:: -mno-readonly-in-sdata + + Default setting; overrides :option:`-mreadonly-in-sdata`. + +.. option:: -mblock-move-inline-limit={num} + + Inline all block moves (such as calls to ``memcpy`` or structure + copies) less than or equal to :samp:`{num}` bytes. The minimum value for + :samp:`{num}` is 32 bytes on 32-bit targets and 64 bytes on 64-bit + targets. The default value is target-specific. + +.. option:: -mblock-compare-inline-limit={num} + + Generate non-looping inline code for all block compares (such as calls + to ``memcmp`` or structure compares) less than or equal to :samp:`{num}` + bytes. If :samp:`{num}` is 0, all inline expansion (non-loop and loop) of + block compare is disabled. The default value is target-specific. + +.. option:: -mblock-compare-inline-loop-limit={num} + + Generate an inline expansion using loop code for all block compares that + are less than or equal to :samp:`{num}` bytes, but greater than the limit + for non-loop inline block compare expansion. If the block length is not + constant, at most :samp:`{num}` bytes will be compared before ``memcmp`` + is called to compare the remainder of the block. The default value is + target-specific. + +.. option:: -mstring-compare-inline-limit={num} + + Compare at most :samp:`{num}` string bytes with inline code. + If the difference or end of string is not found at the + end of the inline compare a call to ``strcmp`` or ``strncmp`` will + take care of the rest of the comparison. The default is 64 bytes. + +.. index:: smaller data references (PowerPC), .sdata/.sdata2 references (PowerPC) + +.. option:: -G {num} + + On embedded PowerPC systems, put global and static items less than or + equal to :samp:`{num}` bytes into the small data or BSS sections instead of + the normal data or BSS section. By default, :samp:`{num}` is 8. The + :option:`-G num` switch is also passed to the linker. + All modules should be compiled with the same :option:`-G num` value. + +.. option:: -mregnames, -mno-regnames + + On System V.4 and embedded PowerPC systems do (do not) emit register + names in the assembly language output using symbolic forms. + +.. option:: -mlongcall, -mno-longcall + + By default assume that all calls are far away so that a longer and more + expensive calling sequence is required. This is required for calls + farther than 32 megabytes (33,554,432 bytes) from the current location. + A short call is generated if the compiler knows + the call cannot be that far away. This setting can be overridden by + the ``shortcall`` function attribute, or by ``#pragma + longcall(0)``. + + Some linkers are capable of detecting out-of-range calls and generating + glue code on the fly. On these systems, long calls are unnecessary and + generate slower code. As of this writing, the AIX linker can do this, + as can the GNU linker for PowerPC/64. It is planned to add this feature + to the GNU linker for 32-bit PowerPC systems as well. + + On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers, + GCC can generate long calls using an inline PLT call sequence (see + :option:`-mpltseq`). PowerPC with :option:`-mbss-plt` and PowerPC64 + ELFv1 (big-endian) do not support inline PLT calls. + + On Darwin/PPC systems, ``#pragma longcall`` generates ``jbsr + callee, L42``, plus a :dfn:`branch island` (glue code). The two target + addresses represent the callee and the branch island. The + Darwin/PPC linker prefers the first address and generates a ``bl + callee`` if the PPC ``bl`` instruction reaches the callee directly; + otherwise, the linker generates ``bl L42`` to call the branch + island. The branch island is appended to the body of the + calling function; it computes the full 32-bit address of the callee + and jumps to it. + + On Mach-O (Darwin) systems, this option directs the compiler emit to + the glue for every direct call, and the Darwin linker decides whether + to use or discard it. + + In the future, GCC may ignore all longcall specifications + when the linker is known to generate glue. + +.. option:: -mpltseq, -mno-pltseq + + Implement (do not implement) -fno-plt and long calls using an inline + PLT call sequence that supports lazy linking and long calls to + functions in dlopen'd shared libraries. Inline PLT calls are only + supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU + linkers, and are enabled by default if the support is detected when + configuring GCC, and, in the case of 32-bit PowerPC, if GCC is + configured with :option:`--enable-secureplt`. :option:`-mpltseq` code + and :option:`-mbss-plt` 32-bit PowerPC relocatable objects may not be + linked together. + +.. option:: -mtls-markers, -mno-tls-markers + + Mark (do not mark) calls to ``__tls_get_addr`` with a relocation + specifying the function argument. The relocation allows the linker to + reliably associate function call with argument setup instructions for + TLS optimization, which in turn allows GCC to better schedule the + sequence. + +.. option:: -mrecip, -mno-recip + + This option enables use of the reciprocal estimate and + reciprocal square root estimate instructions with additional + Newton-Raphson steps to increase precision instead of doing a divide or + square root and divide for floating-point arguments. You should use + the :option:`-ffast-math` option when using :option:`-mrecip` (or at + least :option:`-funsafe-math-optimizations`, + :option:`-ffinite-math-only`, :option:`-freciprocal-math` and + :option:`-fno-trapping-math`). Note that while the throughput of the + sequence is generally higher than the throughput of the non-reciprocal + instruction, the precision of the sequence can be decreased by up to 2 + ulp (i.e. the inverse of 1.0 equals 0.99999994) for reciprocal square + roots. + +.. option:: -mrecip={opt} + + This option controls which reciprocal estimate instructions + may be used. :samp:`{opt}` is a comma-separated list of options, which may + be preceded by a ``!`` to invert the option: + + :samp:`all` + Enable all estimate instructions. + + :samp:`default` + Enable the default instructions, equivalent to :option:`-mrecip`. + + :samp:`none` + Disable all estimate instructions, equivalent to :option:`-mno-recip`. + + :samp:`div` + Enable the reciprocal approximation instructions for both + single and double precision. + + :samp:`divf` + Enable the single-precision reciprocal approximation instructions. + + :samp:`divd` + Enable the double-precision reciprocal approximation instructions. + + :samp:`rsqrt` + Enable the reciprocal square root approximation instructions for both + single and double precision. + + :samp:`rsqrtf` + Enable the single-precision reciprocal square root approximation instructions. + + :samp:`rsqrtd` + Enable the double-precision reciprocal square root approximation instructions. + + So, for example, :option:`-mrecip=all,!rsqrtd` enables + all of the reciprocal estimate instructions, except for the + ``FRSQRTE``, ``XSRSQRTEDP``, and ``XVRSQRTEDP`` instructions + which handle the double-precision reciprocal square root calculations. + +.. option:: -mrecip-precision, -mno-recip-precision + + Assume (do not assume) that the reciprocal estimate instructions + provide higher-precision estimates than is mandated by the PowerPC + ABI. Selecting :option:`-mcpu=power6`, :option:`-mcpu=power7` or + :option:`-mcpu=power8` automatically selects :option:`-mrecip-precision`. + The double-precision square root estimate instructions are not generated by + default on low-precision machines, since they do not provide an + estimate that converges after three steps. + +.. option:: -mveclibabi={type} + + Specifies the ABI type to use for vectorizing intrinsics using an + external library. The only type supported at present is :samp:`mass`, + which specifies to use IBM's Mathematical Acceleration Subsystem + (MASS) libraries for vectorizing intrinsics using external libraries. + GCC currently emits calls to ``acosd2``, ``acosf4``, + ``acoshd2``, ``acoshf4``, ``asind2``, ``asinf4``, + ``asinhd2``, ``asinhf4``, ``atan2d2``, ``atan2f4``, + ``atand2``, ``atanf4``, ``atanhd2``, ``atanhf4``, + ``cbrtd2``, ``cbrtf4``, ``cosd2``, ``cosf4``, + ``coshd2``, ``coshf4``, ``erfcd2``, ``erfcf4``, + ``erfd2``, ``erff4``, ``exp2d2``, ``exp2f4``, + ``expd2``, ``expf4``, ``expm1d2``, ``expm1f4``, + ``hypotd2``, ``hypotf4``, ``lgammad2``, ``lgammaf4``, + ``log10d2``, ``log10f4``, ``log1pd2``, ``log1pf4``, + ``log2d2``, ``log2f4``, ``logd2``, ``logf4``, + ``powd2``, ``powf4``, ``sind2``, ``sinf4``, ``sinhd2``, + ``sinhf4``, ``sqrtd2``, ``sqrtf4``, ``tand2``, + ``tanf4``, ``tanhd2``, and ``tanhf4`` when generating code + for power7. Both :option:`-ftree-vectorize` and + :option:`-funsafe-math-optimizations` must also be enabled. The MASS + libraries must be specified at link time. + +.. option:: -mfriz, -mno-friz + + Generate (do not generate) the ``friz`` instruction when the + :option:`-funsafe-math-optimizations` option is used to optimize + rounding of floating-point values to 64-bit integer and back to floating + point. The ``friz`` instruction does not return the same value if + the floating-point number is too large to fit in an integer. + +.. option:: -mpointers-to-nested-functions, -mno-pointers-to-nested-functions + + Generate (do not generate) code to load up the static chain register + (``r11``) when calling through a pointer on AIX and 64-bit Linux + systems where a function pointer points to a 3-word descriptor giving + the function address, TOC value to be loaded in register ``r2``, and + static chain value to be loaded in register ``r11``. The + :option:`-mpointers-to-nested-functions` is on by default. You cannot + call through pointers to nested functions or pointers + to functions compiled in other languages that use the static chain if + you use :option:`-mno-pointers-to-nested-functions`. + +.. option:: -msave-toc-indirect, -mno-save-toc-indirect + + Generate (do not generate) code to save the TOC value in the reserved + stack location in the function prologue if the function calls through + a pointer on AIX and 64-bit Linux systems. If the TOC value is not + saved in the prologue, it is saved just before the call through the + pointer. The :option:`-mno-save-toc-indirect` option is the default. + +.. option:: -mcompat-align-parm, -mno-compat-align-parm + + Generate (do not generate) code to pass structure parameters with a + maximum alignment of 64 bits, for compatibility with older versions + of GCC. + + Older versions of GCC (prior to 4.9.0) incorrectly did not align a + structure parameter on a 128-bit boundary when that structure contained + a member requiring 128-bit alignment. This is corrected in more + recent versions of GCC. This option may be used to generate code + that is compatible with functions compiled with older versions of + GCC. + + The :option:`-mno-compat-align-parm` option is the default. + +.. option:: -mstack-protector-guard={guard} + + Generate stack protection code using canary at :samp:`{guard}`. Supported + locations are :samp:`global` for global canary or :samp:`tls` for per-thread + canary in the TLS block (the default with GNU libc version 2.4 or later). + + With the latter choice the options + :option:`-mstack-protector-guard-reg=reg` and + :option:`-mstack-protector-guard-offset=offset` furthermore specify + which register to use as base register for reading the canary, and from what + offset from that base register. The default for those is as specified in the + relevant ABI. :option:`-mstack-protector-guard-symbol=symbol` overrides + the offset with a symbol reference to a canary in the TLS block. + +.. option:: -mpcrel, -mno-pcrel + + Generate (do not generate) pc-relative addressing. The :option:`-mpcrel` + option requires that the medium code model (:option:`-mcmodel=medium`) + and prefixed addressing (:option:`-mprefixed`) options are enabled. + +.. option:: -mprefixed, -mno-prefixed + + Generate (do not generate) addressing modes using prefixed load and + store instructions. The :option:`-mprefixed` option requires that + the option :option:`-mcpu=power10` (or later) is enabled. + +.. option:: -mmma, -mno-mma + + Generate (do not generate) the MMA instructions. The :option:`-mma` + option requires that the option :option:`-mcpu=power10` (or later) + is enabled. + +.. option:: -mrop-protect, -mno-rop-protect + + Generate (do not generate) ROP protection instructions when the target + processor supports them. Currently this option disables the shrink-wrap + optimization (:option:`-fshrink-wrap`). + +.. option:: -mprivileged, -mno-privileged + + Generate (do not generate) code that will run in privileged state. + +.. option:: -mblock-ops-unaligned-vsx, -mno-block-ops-unaligned-vsx + + Generate (do not generate) unaligned vsx loads and stores for + inline expansion of ``memcpy`` and ``memmove``. + +.. gcc-param:: rs6000-vect-unroll-limit= + + The vectorizer will check with target information to determine whether it + would be beneficial to unroll the main vectorized loop and by how much. This + parameter sets the upper bound of how much the vectorizer will unroll the main + loop. The default value is four. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/lm32-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/lm32-options.rst new file mode 100644 index 00000000000..c8ced19de77 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/lm32-options.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: LM32 + +.. index:: LM32 options + +.. _lm32-options: + +LM32 Options +^^^^^^^^^^^^ + +These :option:`-m` options are defined for the LatticeMico32 architecture: + +.. option:: -mbarrel-shift-enabled + + Enable barrel-shift instructions. + +.. option:: -mdivide-enabled + + Enable divide and modulus instructions. + +.. option:: -mmultiply-enabled + + Enable multiply instructions. + +.. option:: -msign-extend-enabled + + Enable sign extend instructions. + +.. option:: -muser-enabled + + Enable user-defined instructions. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/loongarch-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/loongarch-options.rst new file mode 100644 index 00000000000..6bd45bbc01e --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/loongarch-options.rst @@ -0,0 +1,191 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: LoongArch + +.. _loongarch-options: + +.. index:: LoongArch Options + +LoongArch Options +^^^^^^^^^^^^^^^^^ + +These command-line options are defined for LoongArch targets: + +.. option:: -march={cpu-type} + + Generate instructions for the machine type :samp:`{cpu-type}`. In contrast to + :option:`-mtune=cpu-type`, which merely tunes the generated code + for the specified :samp:`{cpu-type}`, :option:`-march=cpu-type` allows GCC + to generate code that may not run at all on processors other than the one + indicated. Specifying :option:`-march=cpu-type` implies + :option:`-mtune=cpu-type`, except where noted otherwise. + + The choices for :samp:`{cpu-type}` are: + + :samp:`native` + This selects the CPU to generate code for at compilation time by determining + the processor type of the compiling machine. Using :option:`-march=native` + enables all instruction subsets supported by the local machine (hence + the result might not run on different machines). Using :option:`-mtune=native` + produces code optimized for the local machine under the constraints + of the selected instruction set. + + :samp:`loongarch64` + A generic CPU with 64-bit extensions. + + :samp:`la464` + LoongArch LA464 CPU with LBT, LSX, LASX, LVZ. + +.. option:: -mtune={cpu-type} + + Optimize the output for the given processor, specified by microarchitecture + name. + +.. option:: -mabi={base-abi-type} + + Generate code for the specified calling convention. + :samp:`{base-abi-type}` can be one of: + + :samp:`lp64d` + Uses 64-bit general purpose registers and 32/64-bit floating-point + registers for parameter passing. Data model is LP64, where :samp:`int` + is 32 bits, while :samp:`long int` and pointers are 64 bits. + + :samp:`lp64f` + Uses 64-bit general purpose registers and 32-bit floating-point + registers for parameter passing. Data model is LP64, where :samp:`int` + is 32 bits, while :samp:`long int` and pointers are 64 bits. + + :samp:`lp64s` + Uses 64-bit general purpose registers and no floating-point + registers for parameter passing. Data model is LP64, where :samp:`int` + is 32 bits, while :samp:`long int` and pointers are 64 bits. + +.. option:: -mfpu={fpu-type} + + Generate code for the specified FPU type, which can be one of: + + :samp:`64` + Allow the use of hardware floating-point instructions for 32-bit + and 64-bit operations. + + :samp:`32` + Allow the use of hardware floating-point instructions for 32-bit + operations. + + :samp:`none` + :samp:`0` + Prevent the use of hardware floating-point instructions. + +.. option:: -msoft-float + + Force :option:`-mfpu=none` and prevents the use of floating-point + registers for parameter passing. This option may change the target + ABI. + +.. option:: -msingle-float + + Force :option:`-mfpu=32` and allow the use of 32-bit floating-point + registers for parameter passing. This option may change the target + ABI. + +.. option:: -mdouble-float + + Force :option:`-mfpu=64` and allow the use of 32/64-bit floating-point + registers for parameter passing. This option may change the target + ABI. + +.. option:: -mbranch-cost={n} + + Set the cost of branches to roughly :samp:`{n}` instructions. + +.. option:: -mcheck-zero-division, -mno-check-zero-divison + + Trap (do not trap) on integer division by zero. The default is + :option:`-mcheck-zero-division` for :option:`-O0` or :option:`-Og`, and + :option:`-mno-check-zero-division` for other optimization levels. + +.. option:: -mcond-move-int, -mno-cond-move-int + + Conditional moves for integral data in general-purpose registers + are enabled (disabled). The default is :option:`-mcond-move-int`. + +.. option:: -mcond-move-float, -mno-cond-move-float + + Conditional moves for floating-point registers are enabled (disabled). + The default is :option:`-mcond-move-float`. + +.. option:: -mmemcpy, -mno-memcpy + + Force (do not force) the use of ``memcpy`` for non-trivial block moves. + The default is :option:`-mno-memcpy`, which allows GCC to inline most + constant-sized copies. Setting optimization level to :option:`-Os` also + forces the use of ``memcpy``, but :option:`-mno-memcpy` may override this + behavior if explicitly specified, regardless of the order these options on + the command line. + +.. option:: -mstrict-align, -mno-strict-align + + Avoid or allow generating memory accesses that may not be aligned on a natural + object boundary as described in the architecture specification. The default is + :option:`-mno-strict-align`. + +.. option:: -msmall-data-limit={number} + + Put global and static data smaller than :samp:`{number}` bytes into a special + section (on some targets). The default value is 0. + +.. option:: -mmax-inline-memcpy-size={n} + + Inline all block moves (such as calls to ``memcpy`` or structure copies) + less than or equal to :samp:`{n}` bytes. The default value of :samp:`{n}` is 1024. + +.. option:: -mcmodel={code-model} + + Set the code model to one of: + + :samp:`tiny-static (Not implemented yet)` + :samp:`tiny (Not implemented yet)` + + :samp:`normal` + The text segment must be within 128MB addressing space. The data segment must + be within 2GB addressing space. + + :samp:`medium` + The text segment and data segment must be within 2GB addressing space. + + :samp:`large (Not implemented yet)` + + :samp:`extreme` + This mode does not limit the size of the code segment and data segment. + The :option:`-mcmodel=extreme` option is incompatible with :option:`-fplt` and + :option:`-mno-explicit-relocs`. + + The default code model is ``normal``. + +.. option:: -mexplicit-relocs, -mno-explicit-relocs + + Use or do not use assembler relocation operators when dealing with symbolic + addresses. The alternative is to use assembler macros instead, which may + limit optimization. The default value for the option is determined during + GCC build-time by detecting corresponding assembler support: + ``-mexplicit-relocs`` if said support is present, + ``-mno-explicit-relocs`` otherwise. This option is mostly useful for + debugging, or interoperation with assemblers different from the build-time + one. + +.. option:: -mdirect-extern-access, -mno-direct-extern-access + + Do not use or use GOT to access external symbols. The default is + :option:`-mno-direct-extern-access` : GOT is used for external symbols with + default visibility, but not used for other external symbols. + + With :option:`-mdirect-extern-access`, GOT is not used and all external + symbols are PC-relatively addressed. It is **only** suitable for + environments where no dynamic link is performed, like firmwares, OS + kernels, executables linked with :option:`-static` or :option:`-static-pie`. + :option:`-mdirect-extern-access` is not compatible with :option:`-fPIC` or + :option:`-fpic`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/m32c-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/m32c-options.rst new file mode 100644 index 00000000000..d3aa8052aa7 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/m32c-options.rst @@ -0,0 +1,38 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: M32C + +.. index:: M32C options + +.. _m32c-options: + +M32C Options +^^^^^^^^^^^^ + +.. option:: -mcpu={name} + + Select the CPU for which code is generated. :samp:`{name}` may be one of + :samp:`r8c` for the R8C/Tiny series, :samp:`m16c` for the M16C (up to + /60) series, :samp:`m32cm` for the M16C/80 series, or :samp:`m32c` for + the M32C/80 series. + +.. option:: -msim + + Specifies that the program will be run on the simulator. This causes + an alternate runtime library to be linked in which supports, for + example, file I/O. You must not use this option when generating + programs that will run on real hardware; you must provide your own + runtime library for whatever I/O functions are needed. + +.. option:: -memregs={number} + + Specifies the number of memory-based pseudo-registers GCC uses + during code generation. These pseudo-registers are used like real + registers, so there is a tradeoff between GCC's ability to fit the + code into available registers, and the performance penalty of using + memory instead of registers. Note that all modules in a program must + be compiled with the same value for this option. Because of that, you + must not use this option with GCC's default runtime libraries. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/m32r-d-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/m32r-d-options.rst new file mode 100644 index 00000000000..483f0e28115 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/m32r-d-options.rst @@ -0,0 +1,137 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: M32R/D + +.. index:: M32R/D options + +.. _m32r-d-options: + +M32R/D Options +^^^^^^^^^^^^^^ + +These :option:`-m` options are defined for Renesas M32R/D architectures: + +.. option:: -m32r2 + + Generate code for the M32R/2. + +.. option:: -m32rx + + Generate code for the M32R/X. + +.. option:: -m32r + + Generate code for the M32R. This is the default. + +.. option:: -mmodel=small + + Assume all objects live in the lower 16MB of memory (so that their addresses + can be loaded with the ``ld24`` instruction), and assume all subroutines + are reachable with the ``bl`` instruction. + This is the default. + + The addressability of a particular object can be set with the + ``model`` attribute. + +.. option:: -mmodel=medium + + Assume objects may be anywhere in the 32-bit address space (the compiler + generates ``seth/add3`` instructions to load their addresses), and + assume all subroutines are reachable with the ``bl`` instruction. + +.. option:: -mmodel=large + + Assume objects may be anywhere in the 32-bit address space (the compiler + generates ``seth/add3`` instructions to load their addresses), and + assume subroutines may not be reachable with the ``bl`` instruction + (the compiler generates the much slower ``seth/add3/jl`` + instruction sequence). + +.. option:: -msdata=none + + Disable use of the small data area. Variables are put into + one of ``.data``, ``.bss``, or ``.rodata`` (unless the + ``section`` attribute has been specified). + This is the default. + + The small data area consists of sections ``.sdata`` and ``.sbss``. + Objects may be explicitly put in the small data area with the + ``section`` attribute using one of these sections. + +.. option:: -msdata=sdata + + Put small global and static data in the small data area, but do not + generate special code to reference them. + +.. option:: -msdata=use + + Put small global and static data in the small data area, and generate + special instructions to reference them. + +.. index:: smaller data references + +.. option:: -G {num} + + Put global and static objects less than or equal to :samp:`{num}` bytes + into the small data or BSS sections instead of the normal data or BSS + sections. The default value of :samp:`{num}` is 8. + The :option:`-msdata` option must be set to one of :samp:`sdata` or :samp:`use` + for this option to have any effect. + + All modules should be compiled with the same :option:`-G num` value. + Compiling with different values of :samp:`{num}` may or may not work; if it + doesn't the linker gives an error message---incorrect code is not + generated. + +.. option:: -mdebug + + Makes the M32R-specific code in the compiler display some statistics + that might help in debugging programs. + +.. option:: -malign-loops + + Align all loops to a 32-byte boundary. + +.. option:: -mno-align-loops + + Do not enforce a 32-byte alignment for loops. This is the default. + +.. index:: missue-rate=number + +.. option:: -missue-rate={number} + + Issue :samp:`{number}` instructions per cycle. :samp:`{number}` can only be 1 + or 2. + +.. index:: mbranch-cost=number + +.. option:: -mbranch-cost={number} + + :samp:`{number}` can only be 1 or 2. If it is 1 then branches are + preferred over conditional code, if it is 2, then the opposite applies. + +.. index:: mflush-trap=number + +.. option:: -mflush-trap={number} + + Specifies the trap number to use to flush the cache. The default is + 12. Valid numbers are between 0 and 15 inclusive. + +.. option:: -mno-flush-trap + + Specifies that the cache cannot be flushed by using a trap. + +.. index:: mflush-func=name + +.. option:: -mflush-func={name} + + Specifies the name of the operating system function to call to flush + the cache. The default is :samp:`_flush_cache`, but a function call + is only used if a trap is not available. + +.. option:: -mno-flush-func + + Indicates that there is no OS function for flushing the cache. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/m680x0-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/m680x0-options.rst new file mode 100644 index 00000000000..63fac925a74 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/m680x0-options.rst @@ -0,0 +1,407 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: M680x0 + +.. index:: M680x0 options + +.. _m680x0-options: + +M680x0 Options +^^^^^^^^^^^^^^ + +These are the :samp:`-m` options defined for M680x0 and ColdFire processors. +The default settings depend on which architecture was selected when +the compiler was configured; the defaults for the most common choices +are given below. + +.. option:: -march={arch} + + Generate code for a specific M680x0 or ColdFire instruction set + architecture. Permissible values of :samp:`{arch}` for M680x0 + architectures are: :samp:`68000`, :samp:`68010`, :samp:`68020`, + :samp:`68030`, :samp:`68040`, :samp:`68060` and :samp:`cpu32`. ColdFire + architectures are selected according to Freescale's ISA classification + and the permissible values are: :samp:`isaa`, :samp:`isaaplus`, + :samp:`isab` and :samp:`isac`. + + GCC defines a macro ``__mcfarch__`` whenever it is generating + code for a ColdFire target. The :samp:`{arch}` in this macro is one of the + :option:`-march` arguments given above. + + When used together, :option:`-march` and :option:`-mtune` select code + that runs on a family of similar processors but that is optimized + for a particular microarchitecture. + +.. option:: -mcpu={cpu} + + Generate code for a specific M680x0 or ColdFire processor. + The M680x0 :samp:`{cpu}` s are: :samp:`68000`, :samp:`68010`, :samp:`68020`, + :samp:`68030`, :samp:`68040`, :samp:`68060`, :samp:`68302`, :samp:`68332` + and :samp:`cpu32`. The ColdFire :samp:`{cpu}` s are given by the table + below, which also classifies the CPUs into families: + + .. list-table:: + :header-rows: 1 + + * - Family + - :samp:`-mcpu` arguments + + * - :samp:`51` + - :samp:`51` :samp:`51ac` :samp:`51ag` :samp:`51cn` :samp:`51em` :samp:`51je` :samp:`51jf` :samp:`51jg` :samp:`51jm` :samp:`51mm` :samp:`51qe` :samp:`51qm` + * - :samp:`5206` + - :samp:`5202` :samp:`5204` :samp:`5206` + * - :samp:`5206e` + - :samp:`5206e` + * - :samp:`5208` + - :samp:`5207` :samp:`5208` + * - :samp:`5211a` + - :samp:`5210a` :samp:`5211a` + * - :samp:`5213` + - :samp:`5211` :samp:`5212` :samp:`5213` + * - :samp:`5216` + - :samp:`5214` :samp:`5216` + * - :samp:`52235` + - :samp:`52230` :samp:`52231` :samp:`52232` :samp:`52233` :samp:`52234` :samp:`52235` + * - :samp:`5225` + - :samp:`5224` :samp:`5225` + * - :samp:`52259` + - :samp:`52252` :samp:`52254` :samp:`52255` :samp:`52256` :samp:`52258` :samp:`52259` + * - :samp:`5235` + - :samp:`5232` :samp:`5233` :samp:`5234` :samp:`5235` :samp:`523x` + * - :samp:`5249` + - :samp:`5249` + * - :samp:`5250` + - :samp:`5250` + * - :samp:`5271` + - :samp:`5270` :samp:`5271` + * - :samp:`5272` + - :samp:`5272` + * - :samp:`5275` + - :samp:`5274` :samp:`5275` + * - :samp:`5282` + - :samp:`5280` :samp:`5281` :samp:`5282` :samp:`528x` + * - :samp:`53017` + - :samp:`53011` :samp:`53012` :samp:`53013` :samp:`53014` :samp:`53015` :samp:`53016` :samp:`53017` + * - :samp:`5307` + - :samp:`5307` + * - :samp:`5329` + - :samp:`5327` :samp:`5328` :samp:`5329` :samp:`532x` + * - :samp:`5373` + - :samp:`5372` :samp:`5373` :samp:`537x` + * - :samp:`5407` + - :samp:`5407` + * - :samp:`5475` + - :samp:`5470` :samp:`5471` :samp:`5472` :samp:`5473` :samp:`5474` :samp:`5475` :samp:`547x` :samp:`5480` :samp:`5481` :samp:`5482` :samp:`5483` :samp:`5484` :samp:`5485` + + :option:`-mcpu=cpu` overrides :option:`-march=arch` if + :samp:`{arch}` is compatible with :samp:`{cpu}`. Other combinations of + :option:`-mcpu` and :option:`-march` are rejected. + + GCC defines the macro ``__mcf_cpu_cpu`` when ColdFire target + :samp:`{cpu}` is selected. It also defines ``__mcf_family_family``, + where the value of :samp:`{family}` is given by the table above. + +.. option:: -mtune={tune} + + Tune the code for a particular microarchitecture within the + constraints set by :option:`-march` and :option:`-mcpu`. + The M680x0 microarchitectures are: :samp:`68000`, :samp:`68010`, + :samp:`68020`, :samp:`68030`, :samp:`68040`, :samp:`68060` + and :samp:`cpu32`. The ColdFire microarchitectures + are: :samp:`cfv1`, :samp:`cfv2`, :samp:`cfv3`, :samp:`cfv4` and :samp:`cfv4e`. + + You can also use :option:`-mtune=68020-40` for code that needs + to run relatively well on 68020, 68030 and 68040 targets. + :option:`-mtune=68020-60` is similar but includes 68060 targets + as well. These two options select the same tuning decisions as + :option:`-m68020-40` and :option:`-m68020-60` respectively. + + GCC defines the macros ``__mcarch`` and ``__mcarch__`` + when tuning for 680x0 architecture :samp:`{arch}`. It also defines + ``mcarch`` unless either :option:`-ansi` or a non-GNU :option:`-std` + option is used. If GCC is tuning for a range of architectures, + as selected by :option:`-mtune=68020-40` or :option:`-mtune=68020-60`, + it defines the macros for every architecture in the range. + + GCC also defines the macro ``__muarch__`` when tuning for + ColdFire microarchitecture :samp:`{uarch}`, where :samp:`{uarch}` is one + of the arguments given above. + +.. option:: -m68000, -mc68000 + + Generate output for a 68000. This is the default + when the compiler is configured for 68000-based systems. + It is equivalent to :option:`-march=68000`. + + Use this option for microcontrollers with a 68000 or EC000 core, + including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356. + +.. option:: -m68010 + + Generate output for a 68010. This is the default + when the compiler is configured for 68010-based systems. + It is equivalent to :option:`-march=68010`. + +.. option:: -m68020, -mc68020 + + Generate output for a 68020. This is the default + when the compiler is configured for 68020-based systems. + It is equivalent to :option:`-march=68020`. + +.. option:: -m68030 + + Generate output for a 68030. This is the default when the compiler is + configured for 68030-based systems. It is equivalent to + :option:`-march=68030`. + +.. option:: -m68040 + + Generate output for a 68040. This is the default when the compiler is + configured for 68040-based systems. It is equivalent to + :option:`-march=68040`. + + This option inhibits the use of 68881/68882 instructions that have to be + emulated by software on the 68040. Use this option if your 68040 does not + have code to emulate those instructions. + +.. option:: -m68060 + + Generate output for a 68060. This is the default when the compiler is + configured for 68060-based systems. It is equivalent to + :option:`-march=68060`. + + This option inhibits the use of 68020 and 68881/68882 instructions that + have to be emulated by software on the 68060. Use this option if your 68060 + does not have code to emulate those instructions. + +.. option:: -mcpu32 + + Generate output for a CPU32. This is the default + when the compiler is configured for CPU32-based systems. + It is equivalent to :option:`-march=cpu32`. + + Use this option for microcontrollers with a + CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334, + 68336, 68340, 68341, 68349 and 68360. + +.. option:: -m5200 + + Generate output for a 520X ColdFire CPU. This is the default + when the compiler is configured for 520X-based systems. + It is equivalent to :option:`-mcpu=5206`, and is now deprecated + in favor of that option. + + Use this option for microcontroller with a 5200 core, including + the MCF5202, MCF5203, MCF5204 and MCF5206. + +.. option:: -m5206e + + Generate output for a 5206e ColdFire CPU. The option is now + deprecated in favor of the equivalent :option:`-mcpu=5206e`. + +.. option:: -m528x + + Generate output for a member of the ColdFire 528X family. + The option is now deprecated in favor of the equivalent + :option:`-mcpu=528x`. + +.. option:: -m5307 + + Generate output for a ColdFire 5307 CPU. The option is now deprecated + in favor of the equivalent :option:`-mcpu=5307`. + +.. option:: -m5407 + + Generate output for a ColdFire 5407 CPU. The option is now deprecated + in favor of the equivalent :option:`-mcpu=5407`. + +.. option:: -mcfv4e + + Generate output for a ColdFire V4e family CPU (e.g. 547x/548x). + This includes use of hardware floating-point instructions. + The option is equivalent to :option:`-mcpu=547x`, and is now + deprecated in favor of that option. + +.. option:: -m68020-40 + + Generate output for a 68040, without using any of the new instructions. + This results in code that can run relatively efficiently on either a + 68020/68881 or a 68030 or a 68040. The generated code does use the + 68881 instructions that are emulated on the 68040. + + The option is equivalent to :option:`-march=68020` :option:`-mtune=68020-40`. + +.. option:: -m68020-60 + + Generate output for a 68060, without using any of the new instructions. + This results in code that can run relatively efficiently on either a + 68020/68881 or a 68030 or a 68040. The generated code does use the + 68881 instructions that are emulated on the 68060. + + The option is equivalent to :option:`-march=68020` :option:`-mtune=68020-60`. + +.. option:: -mhard-float, -m68881 + + Generate floating-point instructions. This is the default for 68020 + and above, and for ColdFire devices that have an FPU. It defines the + macro ``__HAVE_68881__`` on M680x0 targets and ``__mcffpu__`` + on ColdFire targets. + +.. option:: -msoft-float + + Do not generate floating-point instructions; use library calls instead. + This is the default for 68000, 68010, and 68832 targets. It is also + the default for ColdFire devices that have no FPU. + +.. option:: -mdiv, -mno-div + + Generate (do not generate) ColdFire hardware divide and remainder + instructions. If :option:`-march` is used without :option:`-mcpu`, + the default is 'on' for ColdFire architectures and 'off' for M680x0 + architectures. Otherwise, the default is taken from the target CPU + (either the default CPU, or the one specified by :option:`-mcpu`). For + example, the default is 'off' for :option:`-mcpu=5206` and 'on' for + :option:`-mcpu=5206e`. + + GCC defines the macro ``__mcfhwdiv__`` when this option is enabled. + +.. option:: -mshort + + Consider type ``int`` to be 16 bits wide, like ``short int``. + Additionally, parameters passed on the stack are also aligned to a + 16-bit boundary even on targets whose API mandates promotion to 32-bit. + +.. option:: -mno-short + + Do not consider type ``int`` to be 16 bits wide. This is the default. + +.. option:: -mnobitfield, -mno-bitfield + + Do not use the bit-field instructions. The :option:`-m68000`, :option:`-mcpu32` + and :option:`-m5200` options imply :option:`-mnobitfield`. + +.. option:: -mbitfield + + Do use the bit-field instructions. The :option:`-m68020` option implies + :option:`-mbitfield`. This is the default if you use a configuration + designed for a 68020. + +.. option:: -mrtd + + Use a different function-calling convention, in which functions + that take a fixed number of arguments return with the ``rtd`` + instruction, which pops their arguments while returning. This + saves one instruction in the caller since there is no need to pop + the arguments there. + + This calling convention is incompatible with the one normally + used on Unix, so you cannot use it if you need to call libraries + compiled with the Unix compiler. + + Also, you must provide function prototypes for all functions that + take variable numbers of arguments (including ``printf``); + otherwise incorrect code is generated for calls to those + functions. + + In addition, seriously incorrect code results if you call a + function with too many arguments. (Normally, extra arguments are + harmlessly ignored.) + + The ``rtd`` instruction is supported by the 68010, 68020, 68030, + 68040, 68060 and CPU32 processors, but not by the 68000 or 5200. + + The default is :option:`-mno-rtd`. + +.. option:: -malign-int, -mno-align-int + + Control whether GCC aligns ``int``, ``long``, ``long long``, + ``float``, ``double``, and ``long double`` variables on a 32-bit + boundary (:option:`-malign-int`) or a 16-bit boundary (:option:`-mno-align-int`). + Aligning variables on 32-bit boundaries produces code that runs somewhat + faster on processors with 32-bit busses at the expense of more memory. + + .. warning:: + + If you use the :option:`-malign-int` switch, GCC + aligns structures containing the above types differently than + most published application binary interface specifications for the m68k. + + Use the pc-relative addressing mode of the 68000 directly, instead of + using a global offset table. At present, this option implies :option:`-fpic`, + allowing at most a 16-bit offset for pc-relative addressing. :option:`-fPIC` is + not presently supported with :option:`-mpcrel`, though this could be supported for + 68020 and higher processors. + +.. option:: -mno-strict-align, -mstrict-align + + Do not (do) assume that unaligned memory references are handled by + the system. + +.. option:: -msep-data + + Generate code that allows the data segment to be located in a different + area of memory from the text segment. This allows for execute-in-place in + an environment without virtual memory management. This option implies + :option:`-fPIC`. + +.. option:: -mno-sep-data + + Generate code that assumes that the data segment follows the text segment. + This is the default. + +.. option:: -mid-shared-library + + Generate code that supports shared libraries via the library ID method. + This allows for execute-in-place and shared libraries in an environment + without virtual memory management. This option implies :option:`-fPIC`. + +.. option:: -mno-id-shared-library + + Generate code that doesn't assume ID-based shared libraries are being used. + This is the default. + +.. option:: -mshared-library-id=n + + Specifies the identification number of the ID-based shared library being + compiled. Specifying a value of 0 generates more compact code; specifying + other values forces the allocation of that number to the current + library, but is no more space- or time-efficient than omitting this option. + +.. option:: -mxgot, -mno-xgot + + When generating position-independent code for ColdFire, generate code + that works if the GOT has more than 8192 entries. This code is + larger and slower than code generated without this option. On M680x0 + processors, this option is not needed; :option:`-fPIC` suffices. + + GCC normally uses a single instruction to load values from the GOT. + While this is relatively efficient, it only works if the GOT + is smaller than about 64k. Anything larger causes the linker + to report an error such as: + + .. index:: relocation truncated to fit (ColdFire) + + .. code-block:: c++ + + relocation truncated to fit: R_68K_GOT16O foobar + + If this happens, you should recompile your code with :option:`-mxgot`. + It should then work with very large GOTs. However, code generated with + :option:`-mxgot` is less efficient, since it takes 4 instructions to fetch + the value of a global symbol. + + Note that some linkers, including newer versions of the GNU linker, + can create multiple GOTs and sort GOT entries. If you have such a linker, + you should only need to use :option:`-mxgot` when compiling a single + object file that accesses more than 8192 GOT entries. Very few do. + + These options have no effect unless GCC is generating + position-independent code. + +.. option:: -mlong-jump-table-offsets + + Use 32-bit offsets in ``switch`` tables. The default is to use + 16-bit offsets. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mcore-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mcore-options.rst new file mode 100644 index 00000000000..1a9eca104c5 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mcore-options.rst @@ -0,0 +1,66 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: MCore + +.. index:: MCore options + +.. _mcore-options: + +MCore Options +^^^^^^^^^^^^^ + +These are the :samp:`-m` options defined for the Motorola M\*Core +processors. + +.. option:: -mhardlit, -mno-hardlit + + Inline constants into the code stream if it can be done in two + instructions or less. + +.. option:: -mdiv, -mno-div + + Use the divide instruction. (Enabled by default). + +.. option:: -mrelax-immediate, -mno-relax-immediate + + Allow arbitrary-sized immediates in bit operations. + +.. option:: -mwide-bitfields, -mno-wide-bitfields + + Always treat bit-fields as ``int`` -sized. + +.. option:: -m4byte-functions, -mno-4byte-functions + + Force all functions to be aligned to a 4-byte boundary. + +.. option:: -mcallgraph-data, -mno-callgraph-data + + Emit callgraph information. + +.. option:: -mslow-bytes, -mno-slow-bytes + + Prefer word access when reading byte quantities. + +.. option:: -mlittle-endian, -mbig-endian + + Generate code for a little-endian target. + +.. option:: -m210, -m340 + + Generate code for the 210 processor. + +.. option:: -mno-lsim + + Assume that runtime support has been provided and so omit the + simulator library (:samp:`libsim.a)` from the linker command line. + +.. option:: -mstack-increment={size} + + Set the maximum amount for a single stack increment operation. Large + values can increase the speed of programs that contain functions + that need a large amount of stack space, but they can also trigger a + segmentation fault if the stack is extended too much. The default + value is 0x1000. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mep-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mep-options.rst new file mode 100644 index 00000000000..28f4c420530 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mep-options.rst @@ -0,0 +1,167 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: MeP + +.. index:: MeP options + +.. _mep-options: + +MeP Options +^^^^^^^^^^^ + +.. option:: -mabsdiff + + Enables the ``abs`` instruction, which is the absolute difference + between two registers. + +.. option:: -mall-opts + + Enables all the optional instructions---average, multiply, divide, bit + operations, leading zero, absolute difference, min/max, clip, and + saturation. + +.. option:: -maverage + + Enables the ``ave`` instruction, which computes the average of two + registers. + +.. option:: -mbased={n} + + Variables of size :samp:`{n}` bytes or smaller are placed in the + ``.based`` section by default. Based variables use the ``$tp`` + register as a base register, and there is a 128-byte limit to the + ``.based`` section. + +.. option:: -mbitops + + Enables the bit operation instructions---bit test (``btstm``), set + (``bsetm``), clear (``bclrm``), invert (``bnotm``), and + test-and-set (``tas``). + +.. option:: -mc={name} + + Selects which section constant data is placed in. :samp:`{name}` may + be :samp:`tiny`, :samp:`near`, or :samp:`far`. + +.. option:: -mclip + + Enables the ``clip`` instruction. Note that :option:`-mclip` is not + useful unless you also provide :option:`-mminmax`. + +.. option:: -mconfig={name} + + Selects one of the built-in core configurations. Each MeP chip has + one or more modules in it; each module has a core CPU and a variety of + coprocessors, optional instructions, and peripherals. The + ``MeP-Integrator`` tool, not part of GCC, provides these + configurations through this option; using this option is the same as + using all the corresponding command-line options. The default + configuration is :samp:`default`. + +.. option:: -mcop + + Enables the coprocessor instructions. By default, this is a 32-bit + coprocessor. Note that the coprocessor is normally enabled via the + :option:`-mconfig=` option. + +.. option:: -mcop32 + + Enables the 32-bit coprocessor's instructions. + +.. option:: -mcop64 + + Enables the 64-bit coprocessor's instructions. + +.. option:: -mivc2 + + Enables IVC2 scheduling. IVC2 is a 64-bit VLIW coprocessor. + +.. option:: -mdc + + Causes constant variables to be placed in the ``.near`` section. + +.. option:: -mdiv + + Enables the ``div`` and ``divu`` instructions. + +.. option:: -meb + + Generate big-endian code. + +.. option:: -mel + + Generate little-endian code. + +.. option:: -mio-volatile + + Tells the compiler that any variable marked with the :mep-var-attr:`io` + attribute is to be considered volatile. + +.. option:: -ml + + Causes variables to be assigned to the ``.far`` section by default. + +.. option:: -mleadz + + Enables the ``leadz`` (leading zero) instruction. + +.. option:: -mm + + Causes variables to be assigned to the ``.near`` section by default. + +.. option:: -mminmax + + Enables the ``min`` and ``max`` instructions. + +.. option:: -mmult + + Enables the multiplication and multiply-accumulate instructions. + +.. option:: -mno-opts + + Disables all the optional instructions enabled by :option:`-mall-opts`. + +.. option:: -mrepeat + + Enables the ``repeat`` and ``erepeat`` instructions, used for + low-overhead looping. + +.. option:: -ms + + Causes all variables to default to the ``.tiny`` section. Note + that there is a 65536-byte limit to this section. Accesses to these + variables use the ``%gp`` base register. + +.. option:: -msatur + + Enables the saturation instructions. Note that the compiler does not + currently generate these itself, but this option is included for + compatibility with other tools, like ``as``. + +.. option:: -msdram + + Link the SDRAM-based runtime instead of the default ROM-based runtime. + +.. option:: -msim + + Link the simulator run-time libraries. + +.. option:: -msimnovec + + Link the simulator runtime libraries, excluding built-in support + for reset and exception vectors and tables. + +.. option:: -mtf + + Causes all functions to default to the ``.far`` section. Without + this option, functions default to the ``.near`` section. + +.. option:: -mtiny={n} + + Variables that are :samp:`{n}` bytes or smaller are allocated to the + ``.tiny`` section. These variables use the ``$gp`` base + register. The default for this option is 4, but note that there's a + 65536-byte limit to the ``.tiny`` section. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/microblaze-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/microblaze-options.rst new file mode 100644 index 00000000000..059af63edcb --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/microblaze-options.rst @@ -0,0 +1,121 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: MicroBlaze + +.. index:: MicroBlaze Options + +.. _microblaze-options: + +MicroBlaze Options +^^^^^^^^^^^^^^^^^^ + +.. option:: -msoft-float + + Use software emulation for floating point (default). + +.. option:: -mhard-float + + Use hardware floating-point instructions. + +.. option:: -mmemcpy + + Do not optimize block moves, use ``memcpy``. + +.. option:: -mno-clearbss + + This option is deprecated. Use :option:`-fno-zero-initialized-in-bss` instead. + +.. option:: -mcpu={cpu-type} + + Use features of, and schedule code for, the given CPU. + Supported values are in the format :samp:`v{X}.{YY}.{Z}`, + where :samp:`{X}` is a major version, :samp:`{YY}` is the minor version, and + :samp:`{Z}` is compatibility code. Example values are :samp:`v3.00.a`, + :samp:`v4.00.b`, :samp:`v5.00.a`, :samp:`v5.00.b`, :samp:`v6.00.a`. + +.. option:: -mxl-soft-mul + + Use software multiply emulation (default). + +.. option:: -mxl-soft-div + + Use software emulation for divides (default). + +.. option:: -mxl-barrel-shift + + Use the hardware barrel shifter. + +.. option:: -mxl-pattern-compare + + Use pattern compare instructions. + +.. option:: -msmall-divides + + Use table lookup optimization for small signed integer divisions. + +.. option:: -mxl-stack-check + + This option is deprecated. Use :option:`-fstack-check` instead. + +.. option:: -mxl-gp-opt + + Use GP-relative ``.sdata`` / ``.sbss`` sections. + +.. option:: -mxl-multiply-high + + Use multiply high instructions for high part of 32x32 multiply. + +.. option:: -mxl-float-convert + + Use hardware floating-point conversion instructions. + +.. option:: -mxl-float-sqrt + + Use hardware floating-point square root instruction. + +.. option:: -mbig-endian + + Generate code for a big-endian target. + +.. option:: -mlittle-endian + + Generate code for a little-endian target. + +.. option:: -mxl-reorder + + Use reorder instructions (swap and byte reversed load/store). + +.. option:: -mxl-mode-app-model + + Select application model :samp:`{app-model}`. Valid models are + + :samp:`executable` + normal executable (default), uses startup code :samp:`crt0.o`. + + :samp:`xmdstub` + for use with Xilinx Microprocessor Debugger (XMD) based + software intrusive debug agent called xmdstub. This uses startup file + :samp:`crt1.o` and sets the start address of the program to 0x800. + + :samp:`bootstrap` + for applications that are loaded using a bootloader. + This model uses startup file :samp:`crt2.o` which does not contain a processor + reset vector handler. This is suitable for transferring control on a + processor reset to the bootloader rather than the application. + + :samp:`novectors` + for applications that do not require any of the + MicroBlaze vectors. This option may be useful for applications running + within a monitoring application. This model uses :samp:`crt3.o` as a startup file. + + Option :option:`-xl-mode-app-model` is a deprecated alias for + :option:`-mxl-mode-app-model`. + +.. option:: -mpic-data-is-text-relative + + Assume that the displacement between the text and data segments is fixed + at static link time. This allows data to be referenced by offset from start of + text address instead of GOT since PC-relative addressing is not supported. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mips-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mips-options.rst new file mode 100644 index 00000000000..296c7780bd5 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mips-options.rst @@ -0,0 +1,986 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: MIPS + +.. index:: MIPS options + +.. _mips-options: + +MIPS Options +^^^^^^^^^^^^ + +.. option:: -EB + + Generate big-endian code. + +.. option:: -EL + + Generate little-endian code. This is the default for :samp:`mips*el-*-*` + configurations. + +.. option:: -march={arch} + + Generate code that runs on :samp:`{arch}`, which can be the name of a + generic MIPS ISA, or the name of a particular processor. + The ISA names are: + :samp:`mips1`, :samp:`mips2`, :samp:`mips3`, :samp:`mips4`, + :samp:`mips32`, :samp:`mips32r2`, :samp:`mips32r3`, :samp:`mips32r5`, + :samp:`mips32r6`, :samp:`mips64`, :samp:`mips64r2`, :samp:`mips64r3`, + :samp:`mips64r5` and :samp:`mips64r6`. + The processor names are: + :samp:`4kc`, :samp:`4km`, :samp:`4kp`, :samp:`4ksc`, + :samp:`4kec`, :samp:`4kem`, :samp:`4kep`, :samp:`4ksd`, + :samp:`5kc`, :samp:`5kf`, + :samp:`20kc`, + :samp:`24kc`, :samp:`24kf2_1`, :samp:`24kf1_1`, + :samp:`24kec`, :samp:`24kef2_1`, :samp:`24kef1_1`, + :samp:`34kc`, :samp:`34kf2_1`, :samp:`34kf1_1`, :samp:`34kn`, + :samp:`74kc`, :samp:`74kf2_1`, :samp:`74kf1_1`, :samp:`74kf3_2`, + :samp:`1004kc`, :samp:`1004kf2_1`, :samp:`1004kf1_1`, + :samp:`i6400`, :samp:`i6500`, + :samp:`interaptiv`, + :samp:`loongson2e`, :samp:`loongson2f`, :samp:`loongson3a`, :samp:`gs464`, + :samp:`gs464e`, :samp:`gs264e`, + :samp:`m4k`, + :samp:`m14k`, :samp:`m14kc`, :samp:`m14ke`, :samp:`m14kec`, + :samp:`m5100`, :samp:`m5101`, + :samp:`octeon`, :samp:`octeon+`, :samp:`octeon2`, :samp:`octeon3`, + :samp:`orion`, + :samp:`p5600`, :samp:`p6600`, + :samp:`r2000`, :samp:`r3000`, :samp:`r3900`, :samp:`r4000`, :samp:`r4400`, + :samp:`r4600`, :samp:`r4650`, :samp:`r4700`, :samp:`r5900`, + :samp:`r6000`, :samp:`r8000`, + :samp:`rm7000`, :samp:`rm9000`, + :samp:`r10000`, :samp:`r12000`, :samp:`r14000`, :samp:`r16000`, + :samp:`sb1`, + :samp:`sr71000`, + :samp:`vr4100`, :samp:`vr4111`, :samp:`vr4120`, :samp:`vr4130`, :samp:`vr4300`, + :samp:`vr5000`, :samp:`vr5400`, :samp:`vr5500`, + :samp:`xlr` and :samp:`xlp`. + The special value :samp:`from-abi` selects the + most compatible architecture for the selected ABI (that is, + :samp:`mips1` for 32-bit ABIs and :samp:`mips3` for 64-bit ABIs). + + The native Linux/GNU toolchain also supports the value :samp:`native`, + which selects the best architecture option for the host processor. + :option:`-march=native` has no effect if GCC does not recognize + the processor. + + In processor names, a final :samp:`000` can be abbreviated as :samp:`k` + (for example, :option:`-march=r2k`). Prefixes are optional, and + :samp:`vr` may be written :samp:`r`. + + Names of the form :samp:`{n}f2_1` refer to processors with + FPUs clocked at half the rate of the core, names of the form + :samp:`{n}f1_1` refer to processors with FPUs clocked at the same + rate as the core, and names of the form :samp:`{n}f3_2` refer to + processors with FPUs clocked a ratio of 3:2 with respect to the core. + For compatibility reasons, :samp:`{n}f` is accepted as a synonym + for :samp:`{n}f2_1` while :samp:`{n}x` and :samp:`{b}fx` are + accepted as synonyms for :samp:`{n}f1_1`. + + GCC defines two macros based on the value of this option. The first + is ``_MIPS_ARCH``, which gives the name of target architecture, as + a string. The second has the form ``_MIPS_ARCH_foo``, + where :samp:`{foo}` is the capitalized value of ``_MIPS_ARCH``. + For example, :option:`-march=r2000` sets ``_MIPS_ARCH`` + to ``"r2000"`` and defines the macro ``_MIPS_ARCH_R2000``. + + Note that the ``_MIPS_ARCH`` macro uses the processor names given + above. In other words, it has the full prefix and does not + abbreviate :samp:`000` as :samp:`k`. In the case of :samp:`from-abi`, + the macro names the resolved architecture (either ``"mips1"`` or + ``"mips3"``). It names the default architecture when no + :option:`-march` option is given. + +.. option:: -mtune={arch} + + Optimize for :samp:`{arch}`. Among other things, this option controls + the way instructions are scheduled, and the perceived cost of arithmetic + operations. The list of :samp:`{arch}` values is the same as for + :option:`-march`. + + When this option is not used, GCC optimizes for the processor + specified by :option:`-march`. By using :option:`-march` and + :option:`-mtune` together, it is possible to generate code that + runs on a family of processors, but optimize the code for one + particular member of that family. + + :option:`-mtune` defines the macros ``_MIPS_TUNE`` and + ``_MIPS_TUNE_foo``, which work in the same way as the + :option:`-march` ones described above. + +.. option:: -mips1 + + Equivalent to :option:`-march=mips1`. + +.. option:: -mips2 + + Equivalent to :option:`-march=mips2`. + +.. option:: -mips3 + + Equivalent to :option:`-march=mips3`. + +.. option:: -mips4 + + Equivalent to :option:`-march=mips4`. + +.. option:: -mips32 + + Equivalent to :option:`-march=mips32`. + +.. option:: -mips32r3 + + Equivalent to :option:`-march=mips32r3`. + +.. option:: -mips32r5 + + Equivalent to :option:`-march=mips32r5`. + +.. option:: -mips32r6 + + Equivalent to :option:`-march=mips32r6`. + +.. option:: -mips64 + + Equivalent to :option:`-march=mips64`. + +.. option:: -mips64r2 + + Equivalent to :option:`-march=mips64r2`. + +.. option:: -mips64r3 + + Equivalent to :option:`-march=mips64r3`. + +.. option:: -mips64r5 + + Equivalent to :option:`-march=mips64r5`. + +.. option:: -mips64r6 + + Equivalent to :option:`-march=mips64r6`. + +.. option:: -mips16, -mno-mips16 + + Generate (do not generate) MIPS16 code. If GCC is targeting a + MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE. + + MIPS16 code generation can also be controlled on a per-function basis + by means of :mips-fn-attr:`mips16` and ``nomips16`` attributes. + See :ref:`function-attributes`, for more information. + +.. option:: -mflip-mips16 + + Generate MIPS16 code on alternating functions. This option is provided + for regression testing of mixed MIPS16/non-MIPS16 code generation, and is + not intended for ordinary use in compiling user code. + +.. option:: -minterlink-compressed, -mno-interlink-compressed + + Require (do not require) that code using the standard (uncompressed) MIPS ISA + be link-compatible with MIPS16 and microMIPS code, and vice versa. + + For example, code using the standard ISA encoding cannot jump directly + to MIPS16 or microMIPS code; it must either use a call or an indirect jump. + :option:`-minterlink-compressed` therefore disables direct jumps unless GCC + knows that the target of the jump is not compressed. + +.. option:: -minterlink-mips16, -mno-interlink-mips16 + + Aliases of :option:`-minterlink-compressed` and + :option:`-mno-interlink-compressed`. These options predate the microMIPS ASE + and are retained for backwards compatibility. + +.. option:: -mabi=32 + + Generate code for the given ABI. + + Note that the EABI has a 32-bit and a 64-bit variant. GCC normally + generates 64-bit code when you select a 64-bit architecture, but you + can use :option:`-mgp32` to get 32-bit code instead. + + For information about the O64 ABI, see + https://gcc.gnu.org/projects/mipso64-abi.html. + + GCC supports a variant of the o32 ABI in which floating-point registers + are 64 rather than 32 bits wide. You can select this combination with + :option:`-mabi=32` :option:`-mfp64`. This ABI relies on the ``mthc1`` + and ``mfhc1`` instructions and is therefore only supported for + MIPS32R2, MIPS32R3 and MIPS32R5 processors. + + The register assignments for arguments and return values remain the + same, but each scalar value is passed in a single 64-bit register + rather than a pair of 32-bit registers. For example, scalar + floating-point values are returned in :samp:`$f0` only, not a + :samp:`$f0`/:samp:`$f1` pair. The set of call-saved registers also + remains the same in that the even-numbered double-precision registers + are saved. + + Two additional variants of the o32 ABI are supported to enable + a transition from 32-bit to 64-bit registers. These are FPXX + (:option:`-mfpxx`) and FP64A (:option:`-mfp64` :option:`-mno-odd-spreg`). + The FPXX extension mandates that all code must execute correctly + when run using 32-bit or 64-bit registers. The code can be interlinked + with either FP32 or FP64, but not both. + The FP64A extension is similar to the FP64 extension but forbids the + use of odd-numbered single-precision registers. This can be used + in conjunction with the ``FRE`` mode of FPUs in MIPS32R5 + processors and allows both FP32 and FP64A code to interlink and + run in the same process without changing FPU modes. + +.. option:: -mabicalls, -mno-abicalls + + Generate (do not generate) code that is suitable for SVR4-style + dynamic objects. :option:`-mabicalls` is the default for SVR4-based + systems. + +.. option:: -mshared, -mno-shared + + Generate (do not generate) code that is fully position-independent, + and that can therefore be linked into shared libraries. This option + only affects :option:`-mabicalls`. + + All :option:`-mabicalls` code has traditionally been position-independent, + regardless of options like :option:`-fPIC` and :option:`-fpic`. However, + as an extension, the GNU toolchain allows executables to use absolute + accesses for locally-binding symbols. It can also use shorter GP + initialization sequences and generate direct calls to locally-defined + functions. This mode is selected by :option:`-mno-shared`. + + :option:`-mno-shared` depends on binutils 2.16 or higher and generates + objects that can only be linked by the GNU linker. However, the option + does not affect the ABI of the final executable; it only affects the ABI + of relocatable objects. Using :option:`-mno-shared` generally makes + executables both smaller and quicker. + + :option:`-mshared` is the default. + +.. option:: -mplt, -mno-plt + + Assume (do not assume) that the static and dynamic linkers + support PLTs and copy relocations. This option only affects + :option:`-mno-shared -mabicalls`. For the n64 ABI, this option + has no effect without :option:`-msym32`. + + You can make :option:`-mplt` the default by configuring + GCC with :option:`--with-mips-plt`. The default is + :option:`-mno-plt` otherwise. + +.. option:: -mxgot, -mno-xgot + + Lift (do not lift) the usual restrictions on the size of the global + offset table. + + GCC normally uses a single instruction to load values from the GOT. + While this is relatively efficient, it only works if the GOT + is smaller than about 64k. Anything larger causes the linker + to report an error such as: + + .. index:: relocation truncated to fit (MIPS) + + .. code-block:: c++ + + relocation truncated to fit: R_MIPS_GOT16 foobar + + If this happens, you should recompile your code with :option:`-mxgot`. + This works with very large GOTs, although the code is also + less efficient, since it takes three instructions to fetch the + value of a global symbol. + + Note that some linkers can create multiple GOTs. If you have such a + linker, you should only need to use :option:`-mxgot` when a single object + file accesses more than 64k's worth of GOT entries. Very few do. + + These options have no effect unless GCC is generating position + independent code. + +.. option:: -mgp32 + + Assume that general-purpose registers are 32 bits wide. + +.. option:: -mgp64 + + Assume that general-purpose registers are 64 bits wide. + +.. option:: -mfp32 + + Assume that floating-point registers are 32 bits wide. + +.. option:: -mfp64 + + Assume that floating-point registers are 64 bits wide. + +.. option:: -mfpxx + + Do not assume the width of floating-point registers. + +.. option:: -mhard-float + + Use floating-point coprocessor instructions. + +.. option:: -msoft-float + + Do not use floating-point coprocessor instructions. Implement + floating-point calculations using library calls instead. + +.. option:: -mno-float + + Equivalent to :option:`-msoft-float`, but additionally asserts that the + program being compiled does not perform any floating-point operations. + This option is presently supported only by some bare-metal MIPS + configurations, where it may select a special set of libraries + that lack all floating-point support (including, for example, the + floating-point ``printf`` formats). + If code compiled with :option:`-mno-float` accidentally contains + floating-point operations, it is likely to suffer a link-time + or run-time failure. + +.. option:: -msingle-float + + Assume that the floating-point coprocessor only supports single-precision + operations. + +.. option:: -mdouble-float + + Assume that the floating-point coprocessor supports double-precision + operations. This is the default. + +.. option:: -modd-spreg, -mno-odd-spreg + + Enable the use of odd-numbered single-precision floating-point registers + for the o32 ABI. This is the default for processors that are known to + support these registers. When using the o32 FPXX ABI, :option:`-mno-odd-spreg` + is set by default. + +.. option:: -mabs=2008 + + These options control the treatment of the special not-a-number (NaN) + IEEE 754 floating-point data with the ``abs.fmt`` and + ``neg.fmt`` machine instructions. + + By default or when :option:`-mabs=legacy` is used the legacy + treatment is selected. In this case these instructions are considered + arithmetic and avoided where correct operation is required and the + input operand might be a NaN. A longer sequence of instructions that + manipulate the sign bit of floating-point datum manually is used + instead unless the :option:`-ffinite-math-only` option has also been + specified. + + The :option:`-mabs=2008` option selects the IEEE 754-2008 treatment. In + this case these instructions are considered non-arithmetic and therefore + operating correctly in all cases, including in particular where the + input operand is a NaN. These instructions are therefore always used + for the respective operations. + +.. option:: -mnan=2008 + + These options control the encoding of the special not-a-number (NaN) + IEEE 754 floating-point data. + + The :option:`-mnan=legacy` option selects the legacy encoding. In this + case quiet NaNs (qNaNs) are denoted by the first bit of their trailing + significand field being 0, whereas signaling NaNs (sNaNs) are denoted + by the first bit of their trailing significand field being 1. + + The :option:`-mnan=2008` option selects the IEEE 754-2008 encoding. In + this case qNaNs are denoted by the first bit of their trailing + significand field being 1, whereas sNaNs are denoted by the first bit of + their trailing significand field being 0. + + The default is :option:`-mnan=legacy` unless GCC has been configured with + :option:`--with-nan=2008`. + +.. option:: -mllsc, -mno-llsc + + Use (do not use) :samp:`ll`, :samp:`sc`, and :samp:`sync` instructions to + implement atomic memory built-in functions. When neither option is + specified, GCC uses the instructions if the target architecture + supports them. + + :option:`-mllsc` is useful if the runtime environment can emulate the + instructions and :option:`-mno-llsc` can be useful when compiling for + nonstandard ISAs. You can make either option the default by + configuring GCC with :option:`--with-llsc` and :option:`--without-llsc` + respectively. :option:`--with-llsc` is the default for some + configurations; see the installation documentation for details. + +.. option:: -mdsp, -mno-dsp + + Use (do not use) revision 1 of the MIPS DSP ASE. + See :ref:`mips-dsp-built-in-functions`. This option defines the + preprocessor macro ``__mips_dsp``. It also defines + ``__mips_dsp_rev`` to 1. + +.. option:: -mdspr2, -mno-dspr2 + + Use (do not use) revision 2 of the MIPS DSP ASE. + See :ref:`mips-dsp-built-in-functions`. This option defines the + preprocessor macros ``__mips_dsp`` and ``__mips_dspr2``. + It also defines ``__mips_dsp_rev`` to 2. + +.. option:: -msmartmips, -mno-smartmips + + Use (do not use) the MIPS SmartMIPS ASE. + +.. option:: -mpaired-single, -mno-paired-single + + Use (do not use) paired-single floating-point instructions. + See :ref:`mips-paired-single-support`. This option requires + hardware floating-point support to be enabled. + +.. option:: -mdmx, -mno-mdmx + + Use (do not use) MIPS Digital Media Extension instructions. + This option can only be used when generating 64-bit code and requires + hardware floating-point support to be enabled. + +.. option:: -mips3d, -mno-mips3d + + Use (do not use) the MIPS-3D ASE. See :ref:`mips-3d-built-in-functions`. + The option :option:`-mips3d` implies :option:`-mpaired-single`. + +.. option:: -mmicromips, -mno-micromips + + Generate (do not generate) microMIPS code. + + MicroMIPS code generation can also be controlled on a per-function basis + by means of ``micromips`` and ``nomicromips`` attributes. + See :ref:`function-attributes`, for more information. + +.. option:: -mmt, -mno-mt + + Use (do not use) MT Multithreading instructions. + +.. option:: -mmcu, -mno-mcu + + Use (do not use) the MIPS MCU ASE instructions. + +.. option:: -meva, -mno-eva + + Use (do not use) the MIPS Enhanced Virtual Addressing instructions. + +.. option:: -mvirt, -mno-virt + + Use (do not use) the MIPS Virtualization (VZ) instructions. + +.. option:: -mxpa, -mno-xpa + + Use (do not use) the MIPS eXtended Physical Address (XPA) instructions. + +.. option:: -mcrc, -mno-crc + + Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions. + +.. option:: -mginv, -mno-ginv + + Use (do not use) the MIPS Global INValidate (GINV) instructions. + +.. option:: -mloongson-mmi, -mno-loongson-mmi + + Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI). + +.. option:: -mloongson-ext, -mno-loongson-ext + + Use (do not use) the MIPS Loongson EXTensions (EXT) instructions. + +.. option:: -mloongson-ext2, -mno-loongson-ext2 + + Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions. + +.. option:: -mlong64 + + Force ``long`` types to be 64 bits wide. See :option:`-mlong32` for + an explanation of the default and the way that the pointer size is + determined. + +.. option:: -mlong32 + + Force ``long``, ``int``, and pointer types to be 32 bits wide. + + The default size of ``int`` s, ``long`` s and pointers depends on + the ABI. All the supported ABIs use 32-bit ``int`` s. The n64 ABI + uses 64-bit ``long`` s, as does the 64-bit EABI; the others use + 32-bit ``long`` s. Pointers are the same size as ``long`` s, + or the same size as integer registers, whichever is smaller. + +.. option:: -msym32, -mno-sym32 + + Assume (do not assume) that all symbols have 32-bit values, regardless + of the selected ABI. This option is useful in combination with + :option:`-mabi=64` and :option:`-mno-abicalls` because it allows GCC + to generate shorter and faster references to symbolic addresses. + +.. option:: -G {num} + + Put definitions of externally-visible data in a small data section + if that data is no bigger than :samp:`{num}` bytes. GCC can then generate + more efficient accesses to the data; see :option:`-mgpopt` for details. + + The default :option:`-G` option depends on the configuration. + +.. option:: -mlocal-sdata, -mno-local-sdata + + Extend (do not extend) the :option:`-G` behavior to local data too, + such as to static variables in C. :option:`-mlocal-sdata` is the + default for all configurations. + + If the linker complains that an application is using too much small data, + you might want to try rebuilding the less performance-critical parts with + :option:`-mno-local-sdata`. You might also want to build large + libraries with :option:`-mno-local-sdata`, so that the libraries leave + more room for the main program. + +.. option:: -mextern-sdata, -mno-extern-sdata + + Assume (do not assume) that externally-defined data is in + a small data section if the size of that data is within the :option:`-G` limit. + :option:`-mextern-sdata` is the default for all configurations. + + If you compile a module :samp:`{Mod}` with :option:`-mextern-sdata` :option:`-G num` + :option:`-mgpopt`, and :samp:`{Mod}` references a variable :samp:`{Var}` + that is no bigger than :samp:`{num}` bytes, you must make sure that :samp:`{Var}` + is placed in a small data section. If :samp:`{Var}` is defined by another + module, you must either compile that module with a high-enough + :option:`-G` setting or attach a ``section`` attribute to :samp:`{Var}` 's + definition. If :samp:`{Var}` is common, you must link the application + with a high-enough :option:`-G` setting. + + The easiest way of satisfying these restrictions is to compile + and link every module with the same :option:`-G` option. However, + you may wish to build a library that supports several different + small data limits. You can do this by compiling the library with + the highest supported :option:`-G` setting and additionally using + :option:`-mno-extern-sdata` to stop the library from making assumptions + about externally-defined data. + +.. option:: -mgpopt, -mno-gpopt + + Use (do not use) GP-relative accesses for symbols that are known to be + in a small data section; see :option:`-G`, :option:`-mlocal-sdata` and + :option:`-mextern-sdata`. :option:`-mgpopt` is the default for all + configurations. + + :option:`-mno-gpopt` is useful for cases where the ``$gp`` register + might not hold the value of ``_gp``. For example, if the code is + part of a library that might be used in a boot monitor, programs that + call boot monitor routines pass an unknown value in ``$gp``. + (In such situations, the boot monitor itself is usually compiled + with :option:`-G0`.) + + :option:`-mno-gpopt` implies :option:`-mno-local-sdata` and + :option:`-mno-extern-sdata`. + +.. option:: -membedded-data, -mno-embedded-data + + Allocate variables to the read-only data section first if possible, then + next in the small data section if possible, otherwise in data. This gives + slightly slower code than the default, but reduces the amount of RAM required + when executing, and thus may be preferred for some embedded systems. + +.. option:: -muninit-const-in-rodata, -mno-uninit-const-in-rodata + + Put uninitialized ``const`` variables in the read-only data section. + This option is only meaningful in conjunction with :option:`-membedded-data`. + +.. option:: -mcode-readable={setting} + + Specify whether GCC may generate code that reads from executable sections. + There are three possible settings: + + ``-mcode-readable=yes`` + Instructions may freely access executable sections. This is the + default setting. + + ``-mcode-readable=pcrel`` + MIPS16 PC-relative load instructions can access executable sections, + but other instructions must not do so. This option is useful on 4KSc + and 4KSd processors when the code TLBs have the Read Inhibit bit set. + It is also useful on processors that can be configured to have a dual + instruction/data SRAM interface and that, like the M4K, automatically + redirect PC-relative loads to the instruction RAM. + + ``-mcode-readable=no`` + Instructions must not access executable sections. This option can be + useful on targets that are configured to have a dual instruction/data + SRAM interface but that (unlike the M4K) do not automatically redirect + PC-relative loads to the instruction RAM. + +.. option:: -msplit-addresses, -mno-split-addresses + + Enable (disable) use of the ``%hi()`` and ``%lo()`` assembler + relocation operators. This option has been superseded by + :option:`-mexplicit-relocs` but is retained for backwards compatibility. + +.. option:: -mexplicit-relocs, -mno-explicit-relocs + + Use (do not use) assembler relocation operators when dealing with symbolic + addresses. The alternative, selected by :option:`-mno-explicit-relocs`, + is to use assembler macros instead. + + :option:`-mexplicit-relocs` is the default if GCC was configured + to use an assembler that supports relocation operators. + +.. option:: -mcheck-zero-division, -mno-check-zero-division + + Trap (do not trap) on integer division by zero. + + The default is :option:`-mcheck-zero-division`. + +.. option:: -mdivide-traps, -mdivide-breaks + + MIPS systems check for division by zero by generating either a + conditional trap or a break instruction. Using traps results in + smaller code, but is only supported on MIPS II and later. Also, some + versions of the Linux kernel have a bug that prevents trap from + generating the proper signal (``SIGFPE``). Use :option:`-mdivide-traps` to + allow conditional traps on architectures that support them and + :option:`-mdivide-breaks` to force the use of breaks. + + The default is usually :option:`-mdivide-traps`, but this can be + overridden at configure time using :option:`--with-divide=breaks`. + Divide-by-zero checks can be completely disabled using + :option:`-mno-check-zero-division`. + +.. option:: -mload-store-pairs, -mno-load-store-pairs + + Enable (disable) an optimization that pairs consecutive load or store + instructions to enable load/store bonding. This option is enabled by + default but only takes effect when the selected architecture is known + to support bonding. + +.. option:: -munaligned-access, -mno-unaligned-access + + Enable (disable) direct unaligned access for MIPS Release 6. + MIPSr6 requires load/store unaligned-access support, + by hardware or trap&emulate. + So :option:`-mno-unaligned-access` may be needed by kernel. + +.. option:: -mmemcpy, -mno-memcpy + + Force (do not force) the use of ``memcpy`` for non-trivial block + moves. The default is :option:`-mno-memcpy`, which allows GCC to inline + most constant-sized copies. + +.. option:: -mlong-calls, -mno-long-calls + + Disable (do not disable) use of the ``jal`` instruction. Calling + functions using ``jal`` is more efficient but requires the caller + and callee to be in the same 256 megabyte segment. + + This option has no effect on abicalls code. The default is + :option:`-mno-long-calls`. + +.. option:: -mmad, -mno-mad + + Enable (disable) use of the ``mad``, ``madu`` and ``mul`` + instructions, as provided by the R4650 ISA. + +.. option:: -mimadd, -mno-imadd + + Enable (disable) use of the ``madd`` and ``msub`` integer + instructions. The default is :option:`-mimadd` on architectures + that support ``madd`` and ``msub`` except for the 74k + architecture where it was found to generate slower code. + +.. option:: -mfused-madd, -mno-fused-madd + + Enable (disable) use of the floating-point multiply-accumulate + instructions, when they are available. The default is + :option:`-mfused-madd`. + + On the R8000 CPU when multiply-accumulate instructions are used, + the intermediate product is calculated to infinite precision + and is not subject to the FCSR Flush to Zero bit. This may be + undesirable in some circumstances. On other processors the result + is numerically identical to the equivalent computation using + separate multiply, add, subtract and negate instructions. + +.. option:: -nocpp + + Tell the MIPS assembler to not run its preprocessor over user + assembler files (with a :samp:`.s` suffix) when assembling them. + +.. option:: -mfix-24k, -mno-fix-24k + + Work around the 24K E48 (lost data on stores during refill) errata. + The workarounds are implemented by the assembler rather than by GCC. + +.. option:: -mfix-r4000, -mno-fix-r4000 + + Work around certain R4000 CPU errata: + + * A double-word or a variable shift may give an incorrect result if executed + immediately after starting an integer division. + + * A double-word or a variable shift may give an incorrect result if executed + while an integer multiplication is in progress. + + * An integer division may give an incorrect result if started in a delay slot + of a taken branch or a jump. + +.. option:: -mfix-r4400, -mno-fix-r4400 + + Work around certain R4400 CPU errata: + + * A double-word or a variable shift may give an incorrect result if executed + immediately after starting an integer division. + +.. option:: -mfix-r10000, -mno-fix-r10000 + + Work around certain R10000 errata: + + * ``ll`` / ``sc`` sequences may not behave atomically on revisions + prior to 3.0. They may deadlock on revisions 2.6 and earlier. + + This option can only be used if the target architecture supports + branch-likely instructions. :option:`-mfix-r10000` is the default when + :option:`-march=r10000` is used; :option:`-mno-fix-r10000` is the default + otherwise. + +.. option:: -mfix-r5900, -mno-fix-r5900 + + Do not attempt to schedule the preceding instruction into the delay slot + of a branch instruction placed at the end of a short loop of six + instructions or fewer and always schedule a ``nop`` instruction there + instead. The short loop bug under certain conditions causes loops to + execute only once or twice, due to a hardware bug in the R5900 chip. The + workaround is implemented by the assembler rather than by GCC. + +.. option:: -mfix-rm7000, -mno-fix-rm7000 + + Work around the RM7000 ``dmult`` / ``dmultu`` errata. The + workarounds are implemented by the assembler rather than by GCC. + +.. option:: -mfix-vr4120, -mno-fix-vr4120 + + Work around certain VR4120 errata: + + * ``dmultu`` does not always produce the correct result. + + * ``div`` and ``ddiv`` do not always produce the correct result if one + of the operands is negative. + + The workarounds for the division errata rely on special functions in + :samp:`libgcc.a`. At present, these functions are only provided by + the ``mips64vr*-elf`` configurations. + + Other VR4120 errata require a NOP to be inserted between certain pairs of + instructions. These errata are handled by the assembler, not by GCC itself. + +.. option:: -mfix-vr4130 + + Work around the VR4130 ``mflo`` / ``mfhi`` errata. The + workarounds are implemented by the assembler rather than by GCC, + although GCC avoids using ``mflo`` and ``mfhi`` if the + VR4130 ``macc``, ``macchi``, ``dmacc`` and ``dmacchi`` + instructions are available instead. + +.. option:: -mfix-sb1, -mno-fix-sb1 + + Work around certain SB-1 CPU core errata. + (This flag currently works around the SB-1 revision 2 + 'F1' and 'F2' floating-point errata.) + +.. option:: -mr10k-cache-barrier={setting} + + Specify whether GCC should insert cache barriers to avoid the + side effects of speculation on R10K processors. + + In common with many processors, the R10K tries to predict the outcome + of a conditional branch and speculatively executes instructions from + the 'taken' branch. It later aborts these instructions if the + predicted outcome is wrong. However, on the R10K, even aborted + instructions can have side effects. + + This problem only affects kernel stores and, depending on the system, + kernel loads. As an example, a speculatively-executed store may load + the target memory into cache and mark the cache line as dirty, even if + the store itself is later aborted. If a DMA operation writes to the + same area of memory before the 'dirty' line is flushed, the cached + data overwrites the DMA-ed data. See the R10K processor manual + for a full description, including other potential problems. + + One workaround is to insert cache barrier instructions before every memory + access that might be speculatively executed and that might have side + effects even if aborted. :option:`-mr10k-cache-barrier=setting` + controls GCC's implementation of this workaround. It assumes that + aborted accesses to any byte in the following regions does not have + side effects: + + * the memory occupied by the current function's stack frame; + + * the memory occupied by an incoming stack argument; + + * the memory occupied by an object with a link-time-constant address. + + It is the kernel's responsibility to ensure that speculative + accesses to these regions are indeed safe. + + If the input program contains a function declaration such as: + + .. code-block:: c++ + + void foo (void); + + then the implementation of ``foo`` must allow ``j foo`` and + ``jal foo`` to be executed speculatively. GCC honors this + restriction for functions it compiles itself. It expects non-GCC + functions (such as hand-written assembly code) to do the same. + + The option has three forms: + + ``-mr10k-cache-barrier=load-store`` + Insert a cache barrier before a load or store that might be + speculatively executed and that might have side effects even + if aborted. + + ``-mr10k-cache-barrier=store`` + Insert a cache barrier before a store that might be speculatively + executed and that might have side effects even if aborted. + + ``-mr10k-cache-barrier=none`` + Disable the insertion of cache barriers. This is the default setting. + +.. option:: -mflush-func={func} + + Specifies the function to call to flush the I and D caches, or to not + call any such function. If called, the function must take the same + arguments as the common ``_flush_func``, that is, the address of the + memory range for which the cache is being flushed, the size of the + memory range, and the number 3 (to flush both caches). The default + depends on the target GCC was configured for, but commonly is either + ``_flush_func`` or ``__cpu_flush``. + +.. option:: -mflush-func + + Default setting; overrides :option:`-mno-flush-func`. + +.. option:: mbranch-cost=num + + Set the cost of branches to roughly :samp:`{num}` 'simple' instructions. + This cost is only a heuristic and is not guaranteed to produce + consistent results across releases. A zero cost redundantly selects + the default, which is based on the :option:`-mtune` setting. + +.. option:: -mbranch-likely, -mno-branch-likely + + Enable or disable use of Branch Likely instructions, regardless of the + default for the selected architecture. By default, Branch Likely + instructions may be generated if they are supported by the selected + architecture. An exception is for the MIPS32 and MIPS64 architectures + and processors that implement those architectures; for those, Branch + Likely instructions are not be generated by default because the MIPS32 + and MIPS64 architectures specifically deprecate their use. + +.. option:: -mcompact-branches=never + + These options control which form of branches will be generated. The + default is :option:`-mcompact-branches=optimal`. + + The :option:`-mcompact-branches=never` option ensures that compact branch + instructions will never be generated. + + The :option:`-mcompact-branches=always` option ensures that a compact + branch instruction will be generated if available for MIPS Release 6 onwards. + If a compact branch instruction is not available (or pre-R6), + a delay slot form of the branch will be used instead. + + If it is used for MIPS16/microMIPS targets, it will be just ignored now. + The behaviour for MIPS16/microMIPS may change in future, + since they do have some compact branch instructions. + + The :option:`-mcompact-branches=optimal` option will cause a delay slot + branch to be used if one is available in the current ISA and the delay + slot is successfully filled. If the delay slot is not filled, a compact + branch will be chosen if one is available. + +.. option:: -mfp-exceptions, -mno-fp-exceptions + + Specifies whether FP exceptions are enabled. This affects how + FP instructions are scheduled for some processors. + The default is that FP exceptions are + enabled. + + For instance, on the SB-1, if FP exceptions are disabled, and we are emitting + 64-bit code, then we can use both FP pipes. Otherwise, we can only use one + FP pipe. + +.. option:: -mvr4130-align, -mno-vr4130-align + + The VR4130 pipeline is two-way superscalar, but can only issue two + instructions together if the first one is 8-byte aligned. When this + option is enabled, GCC aligns pairs of instructions that it + thinks should execute in parallel. + + This option only has an effect when optimizing for the VR4130. + It normally makes code faster, but at the expense of making it bigger. + It is enabled by default at optimization level :option:`-O3`. + +.. option:: -msynci, -mno-synci + + Enable (disable) generation of ``synci`` instructions on + architectures that support it. The ``synci`` instructions (if + enabled) are generated when ``__builtin___clear_cache`` is + compiled. + + This option defaults to :option:`-mno-synci`, but the default can be + overridden by configuring GCC with :option:`--with-synci`. + + When compiling code for single processor systems, it is generally safe + to use ``synci``. However, on many multi-core (SMP) systems, it + does not invalidate the instruction caches on all cores and may lead + to undefined behavior. + +.. option:: -mrelax-pic-calls, -mno-relax-pic-calls + + Try to turn PIC calls that are normally dispatched via register + ``$25`` into direct calls. This is only possible if the linker can + resolve the destination at link time and if the destination is within + range for a direct call. + + :option:`-mrelax-pic-calls` is the default if GCC was configured to use + an assembler and a linker that support the ``.reloc`` assembly + directive and :option:`-mexplicit-relocs` is in effect. With + :option:`-mno-explicit-relocs`, this optimization can be performed by the + assembler and the linker alone without help from the compiler. + +.. option:: -mmcount-ra-address, -mno-mcount-ra-address + + Emit (do not emit) code that allows ``_mcount`` to modify the + calling function's return address. When enabled, this option extends + the usual ``_mcount`` interface with a new :samp:`{ra-address}` + parameter, which has type ``intptr_t *`` and is passed in register + ``$12``. ``_mcount`` can then modify the return address by + doing both of the following: + + * Returning the new address in register ``$31``. + + * Storing the new address in ``*ra-address``, + if :samp:`{ra-address}` is nonnull. + + The default is :option:`-mno-mcount-ra-address`. + +.. option:: -mframe-header-opt, -mno-frame-header-opt + + Enable (disable) frame header optimization in the o32 ABI. When using the + o32 ABI, calling functions will allocate 16 bytes on the stack for the called + function to write out register arguments. When enabled, this optimization + will suppress the allocation of the frame header if it can be determined that + it is unused. + + This optimization is off by default at all optimization levels. + +.. option:: -mlxc1-sxc1, -mno-lxc1-sxc1 + + When applicable, enable (disable) the generation of ``lwxc1``, + ``swxc1``, ``ldxc1``, ``sdxc1`` instructions. Enabled by default. + +.. option:: -mmadd4, -mno-madd4 + + When applicable, enable (disable) the generation of 4-operand ``madd.s``, + ``madd.d`` and related instructions. Enabled by default. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mmix-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mmix-options.rst new file mode 100644 index 00000000000..91e5d1f140c --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mmix-options.rst @@ -0,0 +1,75 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: MMIX + +.. index:: MMIX Options + +.. _mmix-options: + +MMIX Options +^^^^^^^^^^^^ + +These options are defined for the MMIX: + +.. option:: -mlibfuncs, -mno-libfuncs + + Specify that intrinsic library functions are being compiled, passing all + values in registers, no matter the size. + +.. option:: -mepsilon, -mno-epsilon + + Generate floating-point comparison instructions that compare with respect + to the ``rE`` epsilon register. + +.. option:: -mabi=mmixware + + Generate code that passes function parameters and return values that (in + the called function) are seen as registers ``$0`` and up, as opposed to + the GNU ABI which uses global registers ``$231`` and up. + +.. option:: -mzero-extend, -mno-zero-extend + + When reading data from memory in sizes shorter than 64 bits, use (do not + use) zero-extending load instructions by default, rather than + sign-extending ones. + +.. option:: -mknuthdiv, -mno-knuthdiv + + Make the result of a division yielding a remainder have the same sign as + the divisor. With the default, :option:`-mno-knuthdiv`, the sign of the + remainder follows the sign of the dividend. Both methods are + arithmetically valid, the latter being almost exclusively used. + +.. option:: -mtoplevel-symbols, -mno-toplevel-symbols + + Prepend (do not prepend) a :samp:`:` to all global symbols, so the assembly + code can be used with the ``PREFIX`` assembly directive. + +.. option:: -melf + + Generate an executable in the ELF format, rather than the default + :samp:`mmo` format used by the :command:`mmix` simulator. + +.. option:: -mbranch-predict, -mno-branch-predict + + Use (do not use) the probable-branch instructions, when static branch + prediction indicates a probable branch. + +.. option:: -mbase-addresses, -mno-base-addresses + + Generate (do not generate) code that uses *base addresses*. Using a + base address automatically generates a request (handled by the assembler + and the linker) for a constant to be set up in a global register. The + register is used for one or more base address requests within the range 0 + to 255 from the value held in the register. The generally leads to short + and fast code, but the number of different data items that can be + addressed is limited. This means that a program that uses lots of static + data may require :option:`-mno-base-addresses`. + +.. option:: -msingle-exit, -mno-single-exit + + Force (do not force) generated code to have a single exit point in each + function. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mn10300-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mn10300-options.rst new file mode 100644 index 00000000000..ff73e98b395 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/mn10300-options.rst @@ -0,0 +1,93 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: MN10300 + +.. index:: MN10300 options + +.. _mn10300-options: + +MN10300 Options +^^^^^^^^^^^^^^^ + +These :option:`-m` options are defined for Matsushita MN10300 architectures: + +.. option:: -mmult-bug + + Generate code to avoid bugs in the multiply instructions for the MN10300 + processors. This is the default. + +.. option:: -mno-mult-bug + + Do not generate code to avoid bugs in the multiply instructions for the + MN10300 processors. + +.. option:: -mam33 + + Generate code using features specific to the AM33 processor. + +.. option:: -mno-am33 + + Do not generate code using features specific to the AM33 processor. This + is the default. + +.. option:: -mam33-2 + + Generate code using features specific to the AM33/2.0 processor. + +.. option:: -mam34 + + Generate code using features specific to the AM34 processor. + +.. option:: -mtune={cpu-type} + + Use the timing characteristics of the indicated CPU type when + scheduling instructions. This does not change the targeted processor + type. The CPU type must be one of :samp:`mn10300`, :samp:`am33`, + :samp:`am33-2` or :samp:`am34`. + +.. option:: -mreturn-pointer-on-d0 + + When generating a function that returns a pointer, return the pointer + in both ``a0`` and ``d0``. Otherwise, the pointer is returned + only in ``a0``, and attempts to call such functions without a prototype + result in errors. Note that this option is on by default; use + :option:`-mno-return-pointer-on-d0` to disable it. + +.. option:: -mno-crt0 + + Do not link in the C run-time initialization object file. + +.. option:: -mrelax + + Indicate to the linker that it should perform a relaxation optimization pass + to shorten branches, calls and absolute memory addresses. This option only + has an effect when used on the command line for the final link step. + + This option makes symbolic debugging impossible. + +.. option:: -mliw + + Allow the compiler to generate *Long Instruction Word* + instructions if the target is the :samp:`AM33` or later. This is the + default. This option defines the preprocessor macro ``__LIW__``. + +.. option:: -mno-liw + + Do not allow the compiler to generate *Long Instruction Word* + instructions. This option defines the preprocessor macro + ``__NO_LIW__``. + +.. option:: -msetlb + + Allow the compiler to generate the *SETLB* and *Lcc* + instructions if the target is the :samp:`AM33` or later. This is the + default. This option defines the preprocessor macro ``__SETLB__``. + +.. option:: -mno-setlb + + Do not allow the compiler to generate *SETLB* or *Lcc* + instructions. This option defines the preprocessor macro + ``__NO_SETLB__``. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/moxie-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/moxie-options.rst new file mode 100644 index 00000000000..d552dd3d06a --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/moxie-options.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: Moxie + +.. index:: Moxie Options + +.. _moxie-options: + +Moxie Options +^^^^^^^^^^^^^ + +.. option:: -meb + + Generate big-endian code. This is the default for :samp:`moxie-*-*` + configurations. + +.. option:: -mel + + Generate little-endian code. + +.. option:: -mmul.x + + Generate mul.x and umul.x instructions. This is the default for + :samp:`moxiebox-*-*` configurations. + +.. option:: -mno-crt0 + + Do not link in the C run-time initialization object file. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/msp430-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/msp430-options.rst new file mode 100644 index 00000000000..6367bb15d08 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/msp430-options.rst @@ -0,0 +1,189 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: MSP430 + +.. index:: MSP430 Options + +.. _msp430-options: + +MSP430 Options +^^^^^^^^^^^^^^ + +These options are defined for the MSP430: + +.. option:: -masm-hex + + Force assembly output to always use hex constants. Normally such + constants are signed decimals, but this option is available for + testsuite and/or aesthetic purposes. + +.. option:: -mmcu= + + Select the MCU to target. This is used to create a C preprocessor + symbol based upon the MCU name, converted to upper case and pre- and + post-fixed with :samp:`__`. This in turn is used by the + :samp:`msp430.h` header file to select an MCU-specific supplementary + header file. + + The option also sets the ISA to use. If the MCU name is one that is + known to only support the 430 ISA then that is selected, otherwise the + 430X ISA is selected. A generic MCU name of :samp:`msp430` can also be + used to select the 430 ISA. Similarly the generic :samp:`msp430x` MCU + name selects the 430X ISA. + + In addition an MCU-specific linker script is added to the linker + command line. The script's name is the name of the MCU with + :samp:`.ld` appended. Thus specifying :option:`-mmcu=xxx` on the :command:`gcc` + command line defines the C preprocessor symbol ``__XXX__`` and + cause the linker to search for a script called :samp:`xxx.ld`. + + The ISA and hardware multiply supported for the different MCUs is hard-coded + into GCC. However, an external :samp:`devices.csv` file can be used to + extend device support beyond those that have been hard-coded. + + GCC searches for the :samp:`devices.csv` file using the following methods in the + given precedence order, where the first method takes precendence over the + second which takes precedence over the third. + + Include path specified with -I and -L + + :samp:`devices.csv` will be searched for in each of the directories specified by + include paths and linker library search paths. + + Path specified by the environment variable MSP430_GCC_INCLUDE_DIR + + Define the value of the global environment variable + :samp:`MSP430_GCC_INCLUDE_DIR` + to the full path to the directory containing devices.csv, and GCC will search + this directory for devices.csv. If devices.csv is found, this directory will + also be registered as an include path, and linker library path. Header files + and linker scripts in this directory can therefore be used without manually + specifying ``-I`` and ``-L`` on the command line. + + The msp430-elf{,bare}/include/devices directory + + Finally, GCC will examine :samp:`msp430-elf{,bare}/include/devices` from the + toolchain root directory. This directory does not exist in a default + installation, but if the user has created it and copied :samp:`devices.csv` + there, then the MCU data will be read. As above, this directory will + also be registered as an include path, and linker library path. + + If none of the above search methods find :samp:`devices.csv`, then the + hard-coded MCU data is used. + +.. option:: -mwarn-mcu, -mno-warn-mcu + + This option enables or disables warnings about conflicts between the + MCU name specified by the :option:`-mmcu` option and the ISA set by the + :option:`-mcpu` option and/or the hardware multiply support set by the + :option:`-mhwmult` option. It also toggles warnings about unrecognized + MCU names. This option is on by default. + +.. option:: -mcpu= + + Specifies the ISA to use. Accepted values are :samp:`msp430`, + :samp:`msp430x` and :samp:`msp430xv2`. This option is deprecated. The + :option:`-mmcu=` option should be used to select the ISA. + +.. option:: -msim + + Link to the simulator runtime libraries and linker script. Overrides + any scripts that would be selected by the :option:`-mmcu=` option. + +.. option:: -mlarge + + Use large-model addressing (20-bit pointers, 20-bit ``size_t``). + +.. option:: -msmall + + Use small-model addressing (16-bit pointers, 16-bit ``size_t``). + +.. option:: -mrelax + + This option is passed to the assembler and linker, and allows the + linker to perform certain optimizations that cannot be done until + the final link. + +.. option:: mhwmult= + + Describes the type of hardware multiply supported by the target. + Accepted values are :samp:`none` for no hardware multiply, :samp:`16bit` + for the original 16-bit-only multiply supported by early MCUs. + :samp:`32bit` for the 16/32-bit multiply supported by later MCUs and + :samp:`f5series` for the 16/32-bit multiply supported by F5-series MCUs. + A value of :samp:`auto` can also be given. This tells GCC to deduce + the hardware multiply support based upon the MCU name provided by the + :option:`-mmcu` option. If no :option:`-mmcu` option is specified or if + the MCU name is not recognized then no hardware multiply support is + assumed. ``auto`` is the default setting. + + Hardware multiplies are normally performed by calling a library + routine. This saves space in the generated code. When compiling at + :option:`-O3` or higher however the hardware multiplier is invoked + inline. This makes for bigger, but faster code. + + The hardware multiply routines disable interrupts whilst running and + restore the previous interrupt state when they finish. This makes + them safe to use inside interrupt handlers as well as in normal code. + +.. option:: -minrt + + Enable the use of a minimum runtime environment - no static + initializers or constructors. This is intended for memory-constrained + devices. The compiler includes special symbols in some objects + that tell the linker and runtime which code fragments are required. + +.. option:: -mtiny-printf + + Enable reduced code size ``printf`` and ``puts`` library functions. + The :samp:`tiny` implementations of these functions are not reentrant, so + must be used with caution in multi-threaded applications. + + Support for streams has been removed and the string to be printed will + always be sent to stdout via the ``write`` syscall. The string is not + buffered before it is sent to write. + + This option requires Newlib Nano IO, so GCC must be configured with + :samp:`--enable-newlib-nano-formatted-io`. + +.. option:: -mmax-inline-shift= + + This option takes an integer between 0 and 64 inclusive, and sets + the maximum number of inline shift instructions which should be emitted to + perform a shift operation by a constant amount. When this value needs to be + exceeded, an mspabi helper function is used instead. The default value is 4. + + This only affects cases where a shift by multiple positions cannot be + completed with a single instruction (e.g. all shifts >1 on the 430 ISA). + + Shifts of a 32-bit value are at least twice as costly, so the value passed for + this option is divided by 2 and the resulting value used instead. + +.. option:: -mcode-region= + + These options tell the compiler where to place functions and data that + do not have one of the :msp430-fn-attr:`lower`, :msp430-fn-attr:`upper`, ``either`` or + ``section`` attributes. Possible values are :msp430-fn-attr:`lower`, + :msp430-fn-attr:`upper`, ``either`` or ``any``. The first three behave + like the corresponding attribute. The fourth possible value - + ``any`` - is the default. It leaves placement entirely up to the + linker script and how it assigns the standard sections + (``.text``, ``.data``, etc) to the memory regions. + +.. option:: -msilicon-errata= + + This option passes on a request to assembler to enable the fixes for + the named silicon errata. + +.. option:: -msilicon-errata-warn= + + This option passes on a request to the assembler to enable warning + messages when a silicon errata might need to be applied. + +.. option:: -mwarn-devices-csv, -mno-warn-devices-csv + + Warn if :samp:`devices.csv` is not found or there are problem parsing it + (default: on). \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/nds32-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/nds32-options.rst new file mode 100644 index 00000000000..ecfb5129ac4 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/nds32-options.rst @@ -0,0 +1,116 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: NDS32 + +.. index:: NDS32 Options + +.. _nds32-options: + +NDS32 Options +^^^^^^^^^^^^^ + +These options are defined for NDS32 implementations: + +.. option:: -mbig-endian + + Generate code in big-endian mode. + +.. option:: -mlittle-endian + + Generate code in little-endian mode. + +.. option:: -mreduced-regs + + Use reduced-set registers for register allocation. + +.. option:: -mfull-regs + + Use full-set registers for register allocation. + +.. option:: -mcmov + + Generate conditional move instructions. + +.. option:: -mno-cmov + + Do not generate conditional move instructions. + +.. option:: -mext-perf + + Generate performance extension instructions. + +.. option:: -mno-ext-perf + + Do not generate performance extension instructions. + +.. option:: -mext-perf2 + + Generate performance extension 2 instructions. + +.. option:: -mno-ext-perf2 + + Do not generate performance extension 2 instructions. + +.. option:: -mext-string + + Generate string extension instructions. + +.. option:: -mno-ext-string + + Do not generate string extension instructions. + +.. option:: -mv3push + + Generate v3 push25/pop25 instructions. + +.. option:: -mno-v3push + + Do not generate v3 push25/pop25 instructions. + +.. option:: -m16-bit + + Generate 16-bit instructions. + +.. option:: -mno-16-bit + + Do not generate 16-bit instructions. + +.. option:: -misr-vector-size={num} + + Specify the size of each interrupt vector, which must be 4 or 16. + +.. option:: -mcache-block-size={num} + + Specify the size of each cache block, + which must be a power of 2 between 4 and 512. + +.. option:: -march={arch} + + Specify the name of the target architecture. + +.. option:: -mcmodel={code-model} + + Set the code model to one of + + small + All the data and read-only data segments must be within 512KB addressing space. + The text segment must be within 16MB addressing space. + + medium + The data segment must be within 512KB while the read-only data segment can be + within 4GB addressing space. The text segment should be still within 16MB + addressing space. + + large + All the text and data segments can be within 4GB addressing space. + +.. option:: -mctor-dtor + + Enable constructor/destructor feature. + +.. option:: -mrelax + + Guide linker to relax instructions. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/nios-ii-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/nios-ii-options.rst new file mode 100644 index 00000000000..3be25c23b9b --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/nios-ii-options.rst @@ -0,0 +1,363 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: Nios II + +.. index:: Nios II options, Altera Nios II options + +.. _nios-ii-options: + +Nios II Options +^^^^^^^^^^^^^^^ + +These are the options defined for the Altera Nios II processor. + +.. index:: smaller data references + +.. option:: -G {num} + + Put global and static objects less than or equal to :samp:`{num}` bytes + into the small data or BSS sections instead of the normal data or BSS + sections. The default value of :samp:`{num}` is 8. + +.. option:: -mgpopt={option} + + Generate (do not generate) GP-relative accesses. The following + :samp:`{option}` names are recognized: + + :samp:`none` + Do not generate GP-relative accesses. + + :samp:`local` + Generate GP-relative accesses for small data objects that are not + external, weak, or uninitialized common symbols. + Also use GP-relative addressing for objects that + have been explicitly placed in a small data section via a ``section`` + attribute. + + :samp:`global` + As for :samp:`local`, but also generate GP-relative accesses for + small data objects that are external, weak, or common. If you use this option, + you must ensure that all parts of your program (including libraries) are + compiled with the same :option:`-G` setting. + + :samp:`data` + Generate GP-relative accesses for all data objects in the program. If you + use this option, the entire data and BSS segments + of your program must fit in 64K of memory and you must use an appropriate + linker script to allocate them within the addressable range of the + global pointer. + + :samp:`all` + Generate GP-relative addresses for function pointers as well as data + pointers. If you use this option, the entire text, data, and BSS segments + of your program must fit in 64K of memory and you must use an appropriate + linker script to allocate them within the addressable range of the + global pointer. + + :option:`-mgpopt` is equivalent to :option:`-mgpopt=local`, and + :option:`-mno-gpopt` is equivalent to :option:`-mgpopt=none`. + + The default is :option:`-mgpopt` except when :option:`-fpic` or + :option:`-fPIC` is specified to generate position-independent code. + Note that the Nios II ABI does not permit GP-relative accesses from + shared libraries. + + You may need to specify :option:`-mno-gpopt` explicitly when building + programs that include large amounts of small data, including large + GOT data sections. In this case, the 16-bit offset for GP-relative + addressing may not be large enough to allow access to the entire + small data section. + +.. option:: -mgprel-sec={regexp} + + This option specifies additional section names that can be accessed via + GP-relative addressing. It is most useful in conjunction with + ``section`` attributes on variable declarations + (see :ref:`common-variable-attributes`) and a custom linker script. + The :samp:`{regexp}` is a POSIX Extended Regular Expression. + + This option does not affect the behavior of the :option:`-G` option, and + the specified sections are in addition to the standard ``.sdata`` + and ``.sbss`` small-data sections that are recognized by :option:`-mgpopt`. + +.. option:: -mr0rel-sec={regexp} + + This option specifies names of sections that can be accessed via a + 16-bit offset from ``r0`` ; that is, in the low 32K or high 32K + of the 32-bit address space. It is most useful in conjunction with + ``section`` attributes on variable declarations + (see :ref:`common-variable-attributes`) and a custom linker script. + The :samp:`{regexp}` is a POSIX Extended Regular Expression. + + In contrast to the use of GP-relative addressing for small data, + zero-based addressing is never generated by default and there are no + conventional section names used in standard linker scripts for sections + in the low or high areas of memory. + +.. option:: -mel, -meb + + Generate little-endian (default) or big-endian (experimental) code, + respectively. + +.. option:: -march={arch} + + This specifies the name of the target Nios II architecture. GCC uses this + name to determine what kind of instructions it can emit when generating + assembly code. Permissible names are: :samp:`r1`, :samp:`r2`. + + The preprocessor macro ``__nios2_arch__`` is available to programs, + with value 1 or 2, indicating the targeted ISA level. + +.. option:: -mbypass-cache, -mno-bypass-cache + + Force all load and store instructions to always bypass cache by + using I/O variants of the instructions. The default is not to + bypass the cache. + +.. option:: -mno-cache-volatile, -mcache-volatile + + Volatile memory access bypass the cache using the I/O variants of + the load and store instructions. The default is not to bypass the cache. + +.. option:: -mno-fast-sw-div, -mfast-sw-div + + Do not use table-based fast divide for small numbers. The default + is to use the fast divide at :option:`-O3` and above. + +.. option:: -mno-hw-mul, -mhw-mul, -mno-hw-mulx, -mhw-mulx, -mno-hw-div, -mhw-div + + Enable or disable emitting ``mul``, ``mulx`` and ``div`` family of + instructions by the compiler. The default is to emit ``mul`` + and not emit ``div`` and ``mulx``. + +.. option:: -mbmx, -mno-bmx, -mcdx, -mno-cdx + + Enable or disable generation of Nios II R2 BMX (bit manipulation) and + CDX (code density) instructions. Enabling these instructions also + requires :option:`-march=r2`. Since these instructions are optional + extensions to the R2 architecture, the default is not to emit them. + +.. index:: mcustom-insn, mno-custom-insn + +.. option:: -mcustom-insn={N} + + Each :option:`-mcustom-insn=N` option enables use of a + custom instruction with encoding :samp:`{N}` when generating code that uses + :samp:`{insn}`. For example, :option:`-mcustom-fadds=253` generates custom + instruction 253 for single-precision floating-point add operations instead + of the default behavior of using a library call. + + The following values of :samp:`{insn}` are supported. Except as otherwise + noted, floating-point operations are expected to be implemented with + normal IEEE 754 semantics and correspond directly to the C operators or the + equivalent GCC built-in functions (see :ref:`other-builtins`). + + Single-precision floating point: + + :samp:`{fadds}, {fsubs}, {fdivs}, {fmuls}` + Binary arithmetic operations. + + fnegs + Unary negation. + + fabss + Unary absolute value. + + :samp:`{fcmpeqs}, {fcmpges}, {fcmpgts}, {fcmples}, {fcmplts}, {fcmpnes}` + Comparison operations. + + :samp:`{fmins}, {fmaxs}` + Floating-point minimum and maximum. These instructions are only + generated if :option:`-ffinite-math-only` is specified. + + fsqrts + Unary square root operation. + + :samp:`{fcoss}, {fsins}, {ftans}, {fatans}, {fexps}, {flogs}` + Floating-point trigonometric and exponential functions. These instructions + are only generated if :option:`-funsafe-math-optimizations` is also specified. + + Double-precision floating point: + + :samp:`{faddd}, {fsubd}, {fdivd}, {fmuld}` + Binary arithmetic operations. + + fnegd + Unary negation. + + fabsd + Unary absolute value. + + :samp:`{fcmpeqd}, {fcmpged}, {fcmpgtd}, {fcmpled}, {fcmpltd}, {fcmpned}` + Comparison operations. + + :samp:`{fmind}, {fmaxd}` + Double-precision minimum and maximum. These instructions are only + generated if :option:`-ffinite-math-only` is specified. + + fsqrtd + Unary square root operation. + + :samp:`{fcosd}, {fsind}, {ftand}, {fatand}, {fexpd}, {flogd}` + Double-precision trigonometric and exponential functions. These instructions + are only generated if :option:`-funsafe-math-optimizations` is also specified. + + Conversions: + + fextsd + Conversion from single precision to double precision. + + ftruncds + Conversion from double precision to single precision. + + :samp:`{fixsi}, {fixsu}, {fixdi}, {fixdu}` + Conversion from floating point to signed or unsigned integer types, with + truncation towards zero. + + round + Conversion from single-precision floating point to signed integer, + rounding to the nearest integer and ties away from zero. + This corresponds to the ``__builtin_lroundf`` function when + :option:`-fno-math-errno` is used. + + :samp:`{floatis}, {floatus}, {floatid}, {floatud}` + Conversion from signed or unsigned integer types to floating-point types. + + In addition, all of the following transfer instructions for internal + registers X and Y must be provided to use any of the double-precision + floating-point instructions. Custom instructions taking two + double-precision source operands expect the first operand in the + 64-bit register X. The other operand (or only operand of a unary + operation) is given to the custom arithmetic instruction with the + least significant half in source register :samp:`{src1}` and the most + significant half in :samp:`{src2}`. A custom instruction that returns a + double-precision result returns the most significant 32 bits in the + destination register and the other half in 32-bit register Y. + GCC automatically generates the necessary code sequences to write + register X and/or read register Y when double-precision floating-point + instructions are used. + + fwrx + Write :samp:`{src1}` into the least significant half of X and :samp:`{src2}` into + the most significant half of X. + + fwry + Write :samp:`{src1}` into Y. + + :samp:`{frdxhi}, {frdxlo}` + Read the most or least (respectively) significant half of X and store it in + :samp:`{dest}`. + + frdy + Read the value of Y and store it into :samp:`{dest}`. + + Note that you can gain more local control over generation of Nios II custom + instructions by using the ``target("custom-insn=N")`` + and ``target("no-custom-insn")`` function attributes + (see :ref:`function-attributes`) + or pragmas (see :ref:`function-specific-option-pragmas`). + +.. option:: -mcustom-fpu-cfg={name} + + This option enables a predefined, named set of custom instruction encodings + (see :option:`-mcustom-insn` above). + Currently, the following sets are defined: + + :option:`-mcustom-fpu-cfg=60-1` is equivalent to: + + :option:`-mcustom-fmuls=252` |gol| + :option:`-mcustom-fadds=253` |gol| + :option:`-mcustom-fsubs=254` |gol| + :option:`-fsingle-precision-constant` + + :option:`-mcustom-fpu-cfg=60-2` is equivalent to: + + :option:`-mcustom-fmuls=252` |gol| + :option:`-mcustom-fadds=253` |gol| + :option:`-mcustom-fsubs=254` |gol| + :option:`-mcustom-fdivs=255` |gol| + :option:`-fsingle-precision-constant` + + :option:`-mcustom-fpu-cfg=72-3` is equivalent to: + + :option:`-mcustom-floatus=243` |gol| + :option:`-mcustom-fixsi=244` |gol| + :option:`-mcustom-floatis=245` |gol| + :option:`-mcustom-fcmpgts=246` |gol| + :option:`-mcustom-fcmples=249` |gol| + :option:`-mcustom-fcmpeqs=250` |gol| + :option:`-mcustom-fcmpnes=251` |gol| + :option:`-mcustom-fmuls=252` |gol| + :option:`-mcustom-fadds=253` |gol| + :option:`-mcustom-fsubs=254` |gol| + :option:`-mcustom-fdivs=255` |gol| + :option:`-fsingle-precision-constant` + + :option:`-mcustom-fpu-cfg=fph2` is equivalent to: + + :option:`-mcustom-fabss=224` |gol| + :option:`-mcustom-fnegs=225` |gol| + :option:`-mcustom-fcmpnes=226` |gol| + :option:`-mcustom-fcmpeqs=227` |gol| + :option:`-mcustom-fcmpges=228` |gol| + :option:`-mcustom-fcmpgts=229` |gol| + :option:`-mcustom-fcmples=230` |gol| + :option:`-mcustom-fcmplts=231` |gol| + :option:`-mcustom-fmaxs=232` |gol| + :option:`-mcustom-fmins=233` |gol| + :option:`-mcustom-round=248` |gol| + :option:`-mcustom-fixsi=249` |gol| + :option:`-mcustom-floatis=250` |gol| + :option:`-mcustom-fsqrts=251` |gol| + :option:`-mcustom-fmuls=252` |gol| + :option:`-mcustom-fadds=253` |gol| + :option:`-mcustom-fsubs=254` |gol| + :option:`-mcustom-fdivs=255` + + Custom instruction assignments given by individual + :option:`-mcustom-insn=` options override those given by + :option:`-mcustom-fpu-cfg=`, regardless of the + order of the options on the command line. + + Note that you can gain more local control over selection of a FPU + configuration by using the ``target("custom-fpu-cfg=name")`` + function attribute (see :ref:`function-attributes`) + or pragma (see :ref:`function-specific-option-pragmas`). + + The name :samp:`{fph2}` is an abbreviation for *Nios II Floating Point + Hardware 2 Component*. Please note that the custom instructions enabled by + :option:`-mcustom-fmins=233` and :option:`-mcustom-fmaxs=234` are only generated + if :option:`-ffinite-math-only` is specified. The custom instruction enabled by + :option:`-mcustom-round=248` is only generated if :option:`-fno-math-errno` is + specified. In contrast to the other configurations, + :option:`-fsingle-precision-constant` is not set. + +These additional :samp:`-m` options are available for the Altera Nios II +ELF (bare-metal) target: + +.. option:: -mhal + + Link with HAL BSP. This suppresses linking with the GCC-provided C runtime + startup and termination code, and is typically used in conjunction with + :option:`-msys-crt0=` to specify the location of the alternate startup code + provided by the HAL BSP. + +.. option:: -msmallc + + Link with a limited version of the C library, :option:`-lsmallc`, rather than + Newlib. + +.. option:: -msys-crt0={startfile} + + :samp:`{startfile}` is the file name of the startfile (crt0) to use + when linking. This option is only useful in conjunction with :option:`-mhal`. + +.. option:: -msys-lib={systemlib} + + :samp:`{systemlib}` is the library name of the library that provides + low-level system calls required by the C library, + e.g. ``read`` and ``write``. + This option is typically used to link with a library provided by a HAL BSP. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/nvidia-ptx-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/nvidia-ptx-options.rst new file mode 100644 index 00000000000..05344d6b652 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/nvidia-ptx-options.rst @@ -0,0 +1,98 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: Nvidia PTX + +.. index:: Nvidia PTX options, nvptx options + +.. _nvidia-ptx-options: + +Nvidia PTX Options +^^^^^^^^^^^^^^^^^^ + +These options are defined for Nvidia PTX: + +.. option:: -m64 + + Ignored, but preserved for backward compatibility. Only 64-bit ABI is + supported. + +.. option:: -march={architecture-string} + + Generate code for the specified PTX ISA target architecture + (e.g. :samp:`sm_35`). Valid architecture strings are :samp:`sm_30`, + :samp:`sm_35`, :samp:`sm_53`, :samp:`sm_70`, :samp:`sm_75` and + :samp:`sm_80`. + The default depends on how the compiler has been configured, see + :option:`--with-arch`. + + This option sets the value of the preprocessor macro + ``__PTX_SM__`` ; for instance, for :samp:`sm_35`, it has the value + :samp:`350`. + +.. option:: -misa={architecture-string} + + Alias of :option:`-march=`. + +.. option:: -march-map={architecture-string} + + Select the closest available :option:`-march=` value that is not more + capable. For instance, for :option:`-march-map=sm_50` select + :option:`-march=sm_35`, and for :option:`-march-map=sm_53` select + :option:`-march=sm_53`. + +.. option:: -mptx={version-string} + + Generate code for the specified PTX ISA version (e.g. :samp:`7.0`). + Valid version strings include :samp:`3.1`, :samp:`6.0`, :samp:`6.3`, and + :samp:`7.0`. The default PTX ISA version is 6.0, unless a higher + version is required for specified PTX ISA target architecture via + option :option:`-march=`. + + This option sets the values of the preprocessor macros + ``__PTX_ISA_VERSION_MAJOR__`` and ``__PTX_ISA_VERSION_MINOR__`` ; + for instance, for :samp:`3.1` the macros have the values :samp:`3` and + :samp:`1`, respectively. + +.. option:: -mmainkernel + + Link in code for a __main kernel. This is for stand-alone instead of + offloading execution. + +.. option:: -moptimize + + Apply partitioned execution optimizations. This is the default when any + level of optimization is selected. + +.. option:: -msoft-stack + + Generate code that does not use ``.local`` memory + directly for stack storage. Instead, a per-warp stack pointer is + maintained explicitly. This enables variable-length stack allocation (with + variable-length arrays or ``alloca``), and when global memory is used for + underlying storage, makes it possible to access automatic variables from other + threads, or with atomic instructions. This code generation variant is used + for OpenMP offloading, but the option is exposed on its own for the purpose + of testing the compiler; to generate code suitable for linking into programs + using OpenMP offloading, use option :option:`-mgomp`. + +.. option:: -muniform-simt + + Switch to code generation variant that allows to execute all threads in each + warp, while maintaining memory state and side effects as if only one thread + in each warp was active outside of OpenMP SIMD regions. All atomic operations + and calls to runtime (malloc, free, vprintf) are conditionally executed (iff + current lane index equals the master lane index), and the register being + assigned is copied via a shuffle instruction from the master lane. Outside of + SIMD regions lane 0 is the master; inside, each thread sees itself as the + master. Shared memory array ``int __nvptx_uni[]`` stores all-zeros or + all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD + regions). Each thread can bitwise-and the bitmask at position ``tid.y`` + with current lane index to compute the master lane index. + +.. option:: -mgomp + + Generate code for use in OpenMP offloading: enables :option:`-msoft-stack` and + :option:`-muniform-simt` options, and selects corresponding multilib variant. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/openrisc-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/openrisc-options.rst new file mode 100644 index 00000000000..45d67ea160d --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/openrisc-options.rst @@ -0,0 +1,95 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: OpenRISC + +.. index:: OpenRISC Options + +.. _openrisc-options: + +OpenRISC Options +^^^^^^^^^^^^^^^^ + +These options are defined for OpenRISC: + +.. option:: -mboard={name} + + Configure a board specific runtime. This will be passed to the linker for + newlib board library linking. The default is ``or1ksim``. + +.. option:: -mnewlib + + This option is ignored; it is for compatibility purposes only. This used to + select linker and preprocessor options for use with newlib. + +.. option:: -msoft-div, -mhard-div + + Select software or hardware divide (``l.div``, ``l.divu``) instructions. + This default is hardware divide. + +.. option:: -msoft-mul, -mhard-mul + + Select software or hardware multiply (``l.mul``, ``l.muli``) instructions. + This default is hardware multiply. + +.. option:: -msoft-float, -mhard-float + + Select software or hardware for floating point operations. + The default is software. + +.. option:: -mdouble-float + + When :option:`-mhard-float` is selected, enables generation of double-precision + floating point instructions. By default functions from :samp:`libgcc` are used + to perform double-precision floating point operations. + +.. option:: -munordered-float + + When :option:`-mhard-float` is selected, enables generation of unordered + floating point compare and set flag (``lf.sfun*``) instructions. By default + functions from :samp:`libgcc` are used to perform unordered floating point + compare and set flag operations. + +.. option:: -mcmov + + Enable generation of conditional move (``l.cmov``) instructions. By + default the equivalent will be generated using set and branch. + +.. option:: -mror + + Enable generation of rotate right (``l.ror``) instructions. By default + functions from :samp:`libgcc` are used to perform rotate right operations. + +.. option:: -mrori + + Enable generation of rotate right with immediate (``l.rori``) instructions. + By default functions from :samp:`libgcc` are used to perform rotate right with + immediate operations. + +.. option:: -msext + + Enable generation of sign extension (``l.ext*``) instructions. By default + memory loads are used to perform sign extension. + +.. option:: -msfimm + + Enable generation of compare and set flag with immediate (``l.sf*i``) + instructions. By default extra instructions will be generated to store the + immediate to a register first. + +.. option:: -mshftimm + + Enable generation of shift with immediate (``l.srai``, ``l.srli``, + ``l.slli``) instructions. By default extra instructions will be generated + to store the immediate to a register first. + +.. option:: -mcmodel=small + + Generate OpenRISC code for the small model: The GOT is limited to 64k. This is + the default model. + +.. option:: -mcmodel=large + + Generate OpenRISC code for the large model: The GOT may grow up to 4G in size. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/options-for-system-v.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/options-for-system-v.rst new file mode 100644 index 00000000000..e4e67b536fd --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/options-for-system-v.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: System V + +.. _system-v-options: + +Options for System V +^^^^^^^^^^^^^^^^^^^^ + +These additional options are available on System V Release 4 for +compatibility with other compilers on those systems: + +.. option:: -G + + Create a shared object. + It is recommended that :option:`-symbolic` or :option:`-shared` be used instead. + +.. option:: -Qy + + Identify the versions of each tool used by the compiler, in a + ``.ident`` assembler directive in the output. + +.. option:: -Qn + + Refrain from adding ``.ident`` directives to the output file (this is + the default). + +.. option:: -YP,dirs + + Search the directories :samp:`{dirs}`, and no others, for libraries + specified with :option:`-l`. + +.. option:: -Ym,dir + + Look in the directory :samp:`{dir}` to find the M4 preprocessor. + The assembler uses this option. + + .. This is supposed to go with a -Yd for predefined M4 macro files, but + + .. the generic assembler that comes with Solaris takes just -Ym. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/pdp-11-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/pdp-11-options.rst new file mode 100644 index 00000000000..73a352f4653 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/pdp-11-options.rst @@ -0,0 +1,73 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: PDP-11 + +.. index:: PDP-11 Options + +.. _pdp-11-options: + +PDP-11 Options +^^^^^^^^^^^^^^ + +These options are defined for the PDP-11: + +.. option:: -mfpu + + Use hardware FPP floating point. This is the default. (FIS floating + point on the PDP-11/40 is not supported.) Implies :option:`-m45`. + +.. option:: -msoft-float + + Do not use hardware floating point. + +.. option:: -mac0 + + Return floating-point results in ac0 (fr0 in Unix assembler syntax). + +.. option:: -mno-ac0 + + Return floating-point results in memory. This is the default. + +.. option:: -m40 + + Generate code for a PDP-11/40. Implies -msoft-float -mno-split. + +.. option:: -m45 + + Generate code for a PDP-11/45. This is the default. + +.. option:: -m10 + + Generate code for a PDP-11/10. Implies -msoft-float -mno-split. + +.. option:: -mint16, -mno-int32 + + Use 16-bit ``int``. This is the default. + +.. option:: -mint32, -mno-int16 + + Use 32-bit ``int``. + +.. option:: -msplit + + Target has split instruction and data space. Implies -m45. + +.. option:: -munix-asm + + Use Unix assembler syntax. + +.. option:: -mdec-asm + + Use DEC assembler syntax. + +.. option:: -mgnu-asm + + Use GNU assembler syntax. This is the default. + +.. option:: -mlra + + Use the new LRA register allocator. By default, the old 'reload' + allocator is used. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/picochip-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/picochip-options.rst new file mode 100644 index 00000000000..ef0a65afe24 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/picochip-options.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: picoChip + +.. index:: picoChip options + +.. _picochip-options: + +picoChip Options +^^^^^^^^^^^^^^^^ + +These :samp:`-m` options are defined for picoChip implementations: + +.. option:: -mae={ae_type} + + Set the instruction set, register set, and instruction scheduling + parameters for array element type :samp:`{ae_type}`. Supported values + for :samp:`{ae_type}` are :samp:`ANY`, :samp:`MUL`, and :samp:`MAC`. + + :option:`-mae=ANY` selects a completely generic AE type. Code + generated with this option runs on any of the other AE types. The + code is not as efficient as it would be if compiled for a specific + AE type, and some types of operation (e.g., multiplication) do not + work properly on all types of AE. + + :option:`-mae=MUL` selects a MUL AE type. This is the most useful AE type + for compiled code, and is the default. + + :option:`-mae=MAC` selects a DSP-style MAC AE. Code compiled with this + option may suffer from poor performance of byte (char) manipulation, + since the DSP AE does not provide hardware support for byte load/stores. + +.. option:: -msymbol-as-address + + Enable the compiler to directly use a symbol name as an address in a + load/store instruction, without first loading it into a + register. Typically, the use of this option generates larger + programs, which run faster than when the option isn't used. However, the + results vary from program to program, so it is left as a user option, + rather than being permanently enabled. + +.. option:: -mno-inefficient-warnings + + Disables warnings about the generation of inefficient code. These + warnings can be generated, for example, when compiling code that + performs byte-level memory operations on the MAC AE type. The MAC AE has + no hardware support for byte-level memory operations, so all byte + load/stores must be synthesized from word load/store operations. This is + inefficient and a warning is generated to indicate + that you should rewrite the code to avoid byte operations, or to target + an AE type that has the necessary hardware support. This option disables + these warnings. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/powerpc-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/powerpc-options.rst new file mode 100644 index 00000000000..026e1127c70 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/powerpc-options.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: PowerPC + +.. index:: PowerPC options + +.. _powerpc-options: + +PowerPC Options +^^^^^^^^^^^^^^^ + +These are listed under See :ref:`rs-6000-and-powerpc-options`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/pru-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/pru-options.rst new file mode 100644 index 00000000000..70611cb4cc6 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/pru-options.rst @@ -0,0 +1,63 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: PRU + +.. index:: PRU Options + +.. _pru-options: + +PRU Options +^^^^^^^^^^^ + +These command-line options are defined for PRU target: + +.. option:: -minrt + + Link with a minimum runtime environment, with no support for static + initializers and constructors. Using this option can significantly reduce + the size of the final ELF binary. Beware that the compiler could still + generate code with static initializers and constructors. It is up to the + programmer to ensure that the source program will not use those features. + +.. option:: -mmcu={mcu} + + Specify the PRU MCU variant to use. Check Newlib for the exact list of + supported MCUs. + +.. option:: -mno-relax + + Make GCC pass the :option:`--no-relax` command-line option to the linker + instead of the :option:`--relax` option. + +.. option:: -mloop + + Allow (or do not allow) GCC to use the LOOP instruction. + +.. option:: -mabi={variant} + + Specify the ABI variant to output code for. :option:`-mabi=ti` selects the + unmodified TI ABI while :option:`-mabi=gnu` selects a GNU variant that copes + more naturally with certain GCC assumptions. These are the differences: + + :samp:`Function Pointer Size` + TI ABI specifies that function (code) pointers are 16-bit, whereas GNU + supports only 32-bit data and code pointers. + + :samp:`Optional Return Value Pointer` + Function return values larger than 64 bits are passed by using a hidden + pointer as the first argument of the function. TI ABI, though, mandates that + the pointer can be NULL in case the caller is not using the returned value. + GNU always passes and expects a valid return value pointer. + + The current :option:`-mabi=ti` implementation simply raises a compile error + when any of the above code constructs is detected. As a consequence + the standard C library cannot be built and it is omitted when linking with + :option:`-mabi=ti`. + + Relaxation is a GNU feature and for safety reasons is disabled when using + :option:`-mabi=ti`. The TI toolchain does not emit relocations for QBBx + instructions, so the GNU linker cannot adjust them when shortening adjacent + LDI32 pseudo instructions. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/risc-v-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/risc-v-options.rst new file mode 100644 index 00000000000..36de7047364 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/risc-v-options.rst @@ -0,0 +1,216 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: RISC-V + +.. index:: RISC-V Options + +.. _risc-v-options: + +RISC-V Options +^^^^^^^^^^^^^^ + +These command-line options are defined for RISC-V targets: + +.. option:: -mbranch-cost={n} + + Set the cost of branches to roughly :samp:`{n}` instructions. + +.. option:: -mplt, -mno-plt + + When generating PIC code, do or don't allow the use of PLTs. Ignored for + non-PIC. The default is :option:`-mplt`. + +.. option:: -mabi={ABI-string} + + Specify integer and floating-point calling convention. :samp:`{ABI-string}` + contains two parts: the size of integer types and the registers used for + floating-point types. For example :samp:`-march=rv64ifd -mabi=lp64d` means that + :samp:`long` and pointers are 64-bit (implicitly defining :samp:`int` to be + 32-bit), and that floating-point values up to 64 bits wide are passed in F + registers. Contrast this with :samp:`-march=rv64ifd -mabi=lp64f`, which still + allows the compiler to generate code that uses the F and D extensions but only + allows floating-point values up to 32 bits long to be passed in registers; or + :samp:`-march=rv64ifd -mabi=lp64`, in which no floating-point arguments will be + passed in registers. + + The default for this argument is system dependent, users who want a specific + calling convention should specify one explicitly. The valid calling + conventions are: :samp:`ilp32`, :samp:`ilp32f`, :samp:`ilp32d`, :samp:`lp64`, + :samp:`lp64f`, and :samp:`lp64d`. Some calling conventions are impossible to + implement on some ISAs: for example, :samp:`-march=rv32if -mabi=ilp32d` is + invalid because the ABI requires 64-bit values be passed in F registers, but F + registers are only 32 bits wide. There is also the :samp:`ilp32e` ABI that can + only be used with the :samp:`rv32e` architecture. This ABI is not well + specified at present, and is subject to change. + +.. option:: -mfdiv, -mno-fdiv + + Do or don't use hardware floating-point divide and square root instructions. + This requires the F or D extensions for floating-point registers. The default + is to use them if the specified architecture has these instructions. + +.. option:: -mdiv, -mno-div + + Do or don't use hardware instructions for integer division. This requires the + M extension. The default is to use them if the specified architecture has + these instructions. + +.. option:: -misa-spec={ISA-spec-string} + + Specify the version of the RISC-V Unprivileged (formerly User-Level) + ISA specification to produce code conforming to. The possibilities + for :samp:`{ISA-spec-string}` are: + + ``2.2`` + Produce code conforming to version 2.2. + + ``20190608`` + Produce code conforming to version 20190608. + + ``20191213`` + Produce code conforming to version 20191213. + + The default is :option:`-misa-spec=20191213` unless GCC has been configured + with :option:`--with-isa-spec=` specifying a different default version. + +.. option:: -march={ISA-string} + + Generate code for given RISC-V ISA (e.g. :samp:`rv64im`). ISA strings must be + lower-case. Examples include :samp:`rv64i`, :samp:`rv32g`, :samp:`rv32e`, and + :samp:`rv32imaf`. + + When :option:`-march=` is not specified, use the setting from :option:`-mcpu`. + + If both :option:`-march` and :option:`-mcpu=` are not specified, the default for + this argument is system dependent, users who want a specific architecture + extensions should specify one explicitly. + +.. option:: -mcpu={processor-string} + + Use architecture of and optimize the output for the given processor, specified + by particular CPU name. + Permissible values for this option are: :samp:`sifive-e20`, :samp:`sifive-e21`, + :samp:`sifive-e24`, :samp:`sifive-e31`, :samp:`sifive-e34`, :samp:`sifive-e76`, + :samp:`sifive-s21`, :samp:`sifive-s51`, :samp:`sifive-s54`, :samp:`sifive-s76`, + :samp:`sifive-u54`, and :samp:`sifive-u74`. + +.. option:: -mtune={processor-string} + + Optimize the output for the given processor, specified by microarchitecture or + particular CPU name. Permissible values for this option are: :samp:`rocket`, + :samp:`sifive-3-series`, :samp:`sifive-5-series`, :samp:`sifive-7-series`, + :samp:`thead-c906`, :samp:`size`, and all valid options for :option:`-mcpu=`. + + When :option:`-mtune=` is not specified, use the setting from :option:`-mcpu`, + the default is :samp:`rocket` if both are not specified. + + The :samp:`size` choice is not intended for use by end-users. This is used + when :option:`-Os` is specified. It overrides the instruction cost info + provided by :option:`-mtune=`, but does not override the pipeline info. This + helps reduce code size while still giving good performance. + +.. option:: -mpreferred-stack-boundary={num} + + Attempt to keep the stack boundary aligned to a 2 raised to :samp:`{num}` + byte boundary. If :option:`-mpreferred-stack-boundary` is not specified, + the default is 4 (16 bytes or 128-bits). + + .. warning:: + + If you use this switch, then you must build all modules with + the same value, including any libraries. This includes the system libraries + and startup modules. + +.. option:: -msmall-data-limit={n} + + Put global and static data smaller than :samp:`{n}` bytes into a special section + (on some targets). + +.. option:: -msave-restore, -mno-save-restore + + Do or don't use smaller but slower prologue and epilogue code that uses + library function calls. The default is to use fast inline prologues and + epilogues. + +.. option:: -mshorten-memrefs, -mno-shorten-memrefs + + Do or do not attempt to make more use of compressed load/store instructions by + replacing a load/store of 'base register + large offset' with a new load/store + of 'new base + small offset'. If the new base gets stored in a compressed + register, then the new load/store can be compressed. Currently targets 32-bit + integer load/stores only. + +.. option:: -mstrict-align, -mno-strict-align + + Do not or do generate unaligned memory accesses. The default is set depending + on whether the processor we are optimizing for supports fast unaligned access + or not. + +.. option:: -mcmodel=medlow + + Generate code for the medium-low code model. The program and its statically + defined symbols must lie within a single 2 GiB address range and must lie + between absolute addresses -2 GiB and +2 GiB. Programs can be + statically or dynamically linked. This is the default code model. + +.. option:: -mcmodel=medany + + Generate code for the medium-any code model. The program and its statically + defined symbols must be within any single 2 GiB address range. Programs can be + statically or dynamically linked. + +.. option:: -mexplicit-relocs, -mno-exlicit-relocs + + Use or do not use assembler relocation operators when dealing with symbolic + addresses. The alternative is to use assembler macros instead, which may + limit optimization. + +.. option:: -mrelax, -mno-relax + + Take advantage of linker relaxations to reduce the number of instructions + required to materialize symbol addresses. The default is to take advantage of + linker relaxations. + +.. option:: -mriscv-attribute, -mno-riscv-attribute + + Emit (do not emit) RISC-V attribute to record extra information into ELF + objects. This feature requires at least binutils 2.32. + +.. option:: -mcsr-check, -mno-csr-check + + Enables or disables the CSR checking. + +.. option:: -malign-data={type} + + Control how GCC aligns variables and constants of array, structure, or union + types. Supported values for :samp:`{type}` are :samp:`xlen` which uses x register + width as the alignment value, and :samp:`natural` which uses natural alignment. + :samp:`xlen` is the default. + +.. option:: -mbig-endian + + Generate big-endian code. This is the default when GCC is configured for a + :samp:`riscv64be-*-*` or :samp:`riscv32be-*-*` target. + +.. option:: -mlittle-endian + + Generate little-endian code. This is the default when GCC is configured for a + :samp:`riscv64-*-*` or :samp:`riscv32-*-*` but not a :samp:`riscv64be-*-*` or + :samp:`riscv32be-*-*` target. + +.. option:: -mstack-protector-guard={guard} + + Generate stack protection code using canary at :samp:`{guard}`. Supported + locations are :samp:`global` for a global canary or :samp:`tls` for per-thread + canary in the TLS block. + + With the latter choice the options + :option:`-mstack-protector-guard-reg=reg` and + :option:`-mstack-protector-guard-offset=offset` furthermore specify + which register to use as base register for reading the canary, + and from what offset from that base register. There is no default + register or offset as this is entirely for use within the Linux + kernel. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/rl78-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/rl78-options.rst new file mode 100644 index 00000000000..cbe5b29b9d7 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/rl78-options.rst @@ -0,0 +1,91 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: RL78 + +.. index:: RL78 Options + +.. _rl78-options: + +RL78 Options +^^^^^^^^^^^^ + +.. option:: -msim + + Links in additional target libraries to support operation within a + simulator. + +.. option:: -mmul=none + + Specifies the type of hardware multiplication and division support to + be used. The simplest is ``none``, which uses software for both + multiplication and division. This is the default. The ``g13`` + value is for the hardware multiply/divide peripheral found on the + RL78/G13 (S2 core) targets. The ``g14`` value selects the use of + the multiplication and division instructions supported by the RL78/G14 + (S3 core) parts. The value ``rl78`` is an alias for ``g14`` and + the value ``mg10`` is an alias for ``none``. + + In addition a C preprocessor macro is defined, based upon the setting + of this option. Possible values are: ``__RL78_MUL_NONE__``, + ``__RL78_MUL_G13__`` or ``__RL78_MUL_G14__``. + +.. option:: -mcpu=g10 + + Specifies the RL78 core to target. The default is the G14 core, also + known as an S3 core or just RL78. The G13 or S2 core does not have + multiply or divide instructions, instead it uses a hardware peripheral + for these operations. The G10 or S1 core does not have register + banks, so it uses a different calling convention. + + If this option is set it also selects the type of hardware multiply + support to use, unless this is overridden by an explicit + :option:`-mmul=none` option on the command line. Thus specifying + :option:`-mcpu=g13` enables the use of the G13 hardware multiply + peripheral and specifying :option:`-mcpu=g10` disables the use of + hardware multiplications altogether. + + Note, although the RL78/G14 core is the default target, specifying + :option:`-mcpu=g14` or :option:`-mcpu=rl78` on the command line does + change the behavior of the toolchain since it also enables G14 + hardware multiply support. If these options are not specified on the + command line then software multiplication routines will be used even + though the code targets the RL78 core. This is for backwards + compatibility with older toolchains which did not have hardware + multiply and divide support. + + In addition a C preprocessor macro is defined, based upon the setting + of this option. Possible values are: ``__RL78_G10__``, + ``__RL78_G13__`` or ``__RL78_G14__``. + +.. option:: -mg10, -mg13, -mg14, -mrl78 + + These are aliases for the corresponding :option:`-mcpu=` option. They + are provided for backwards compatibility. + +.. option:: -mallregs + + Allow the compiler to use all of the available registers. By default + registers ``r24..r31`` are reserved for use in interrupt handlers. + With this option enabled these registers can be used in ordinary + functions as well. + +.. option:: -m64bit-doubles, -m32bit-doubles + + Make the ``double`` data type be 64 bits (:option:`-m64bit-doubles`) + or 32 bits (:option:`-m32bit-doubles`) in size. The default is + :option:`-m32bit-doubles`. + +.. option:: -msave-mduc-in-interrupts, -mno-save-mduc-in-interrupts + + Specifies that interrupt handler functions should preserve the + MDUC registers. This is only necessary if normal code might use + the MDUC registers, for example because it performs multiplication + and division operations. The default is to ignore the MDUC registers + as this makes the interrupt handlers faster. The target option -mg13 + needs to be passed for this to work as this feature is only available + on the G13 target (S2 core). The MDUC registers will only be saved + if the interrupt handler performs a multiplication or division + operation or it calls another function. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/rx-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/rx-options.rst new file mode 100644 index 00000000000..f1af26319d1 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/rx-options.rst @@ -0,0 +1,209 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: RX + +.. index:: RX Options + +.. _rx-options: + +RX Options +^^^^^^^^^^ + +These command-line options are defined for RX targets: + +.. option:: -m64bit-doubles, -m32bit-doubles + + Make the ``double`` data type be 64 bits (:option:`-m64bit-doubles`) + or 32 bits (:option:`-m32bit-doubles`) in size. The default is + :option:`-m32bit-doubles`. + + .. note:: + + RX floating-point hardware only + works on 32-bit values, which is why the default is + :option:`-m32bit-doubles`. + +.. option:: -fpu, -nofpu + + Enables (:option:`-fpu`) or disables (:option:`-nofpu`) the use of RX + floating-point hardware. The default is enabled for the RX600 + series and disabled for the RX200 series. + + Floating-point instructions are only generated for 32-bit floating-point + values, however, so the FPU hardware is not used for doubles if the + :option:`-m64bit-doubles` option is used. + + .. note:: + + If the :option:`-fpu` option is enabled then + :option:`-funsafe-math-optimizations` is also enabled automatically. + This is because the RX FPU instructions are themselves unsafe. + +.. option:: -mcpu={name} + + Selects the type of RX CPU to be targeted. Currently three types are + supported, the generic :samp:`RX600` and :samp:`RX200` series hardware and + the specific :samp:`RX610` CPU. The default is :samp:`RX600`. + + The only difference between :samp:`RX600` and :samp:`RX610` is that the + :samp:`RX610` does not support the ``MVTIPL`` instruction. + + The :samp:`RX200` series does not have a hardware floating-point unit + and so :option:`-nofpu` is enabled by default when this type is + selected. + +.. option:: -mbig-endian-data, -mlittle-endian-data + + Store data (but not code) in the big-endian format. The default is + :option:`-mlittle-endian-data`, i.e. to store data in the little-endian + format. + +.. option:: -msmall-data-limit={N} + + Specifies the maximum size in bytes of global and static variables + which can be placed into the small data area. Using the small data + area can lead to smaller and faster code, but the size of area is + limited and it is up to the programmer to ensure that the area does + not overflow. Also when the small data area is used one of the RX's + registers (usually ``r13``) is reserved for use pointing to this + area, so it is no longer available for use by the compiler. This + could result in slower and/or larger code if variables are pushed onto + the stack instead of being held in this register. + + .. note:: + + Common variables (variables that have not been initialized) and + constants are not placed into the small data area as they are assigned + to other sections in the output executable. + + The default value is zero, which disables this feature. Note, this + feature is not enabled by default with higher optimization levels + (:option:`-O2` etc) because of the potentially detrimental effects of + reserving a register. It is up to the programmer to experiment and + discover whether this feature is of benefit to their program. See the + description of the :option:`-mpid` option for a description of how the + actual register to hold the small data area pointer is chosen. + +.. option:: -msim, -mno-sim + + Use the simulator runtime. The default is to use the libgloss + board-specific runtime. + +.. option:: -mas100-syntax, -mno-as100-syntax + + When generating assembler output use a syntax that is compatible with + Renesas's AS100 assembler. This syntax can also be handled by the GAS + assembler, but it has some restrictions so it is not generated by default. + +.. option:: -mmax-constant-size={N} + + Specifies the maximum size, in bytes, of a constant that can be used as + an operand in a RX instruction. Although the RX instruction set does + allow constants of up to 4 bytes in length to be used in instructions, + a longer value equates to a longer instruction. Thus in some + circumstances it can be beneficial to restrict the size of constants + that are used in instructions. Constants that are too big are instead + placed into a constant pool and referenced via register indirection. + + The value :samp:`{N}` can be between 0 and 4. A value of 0 (the default) + or 4 means that constants of any size are allowed. + +.. option:: -mrelax + + Enable linker relaxation. Linker relaxation is a process whereby the + linker attempts to reduce the size of a program by finding shorter + versions of various instructions. Disabled by default. + +.. option:: -mint-register={N} + + Specify the number of registers to reserve for fast interrupt handler + functions. The value :samp:`{N}` can be between 0 and 4. A value of 1 + means that register ``r13`` is reserved for the exclusive use + of fast interrupt handlers. A value of 2 reserves ``r13`` and + ``r12``. A value of 3 reserves ``r13``, ``r12`` and + ``r11``, and a value of 4 reserves ``r13`` through ``r10``. + A value of 0, the default, does not reserve any registers. + +.. option:: -msave-acc-in-interrupts + + Specifies that interrupt handler functions should preserve the + accumulator register. This is only necessary if normal code might use + the accumulator register, for example because it performs 64-bit + multiplications. The default is to ignore the accumulator as this + makes the interrupt handlers faster. + +.. option:: -mpid, -mno-pid + + Enables the generation of position independent data. When enabled any + access to constant data is done via an offset from a base address + held in a register. This allows the location of constant data to be + determined at run time without requiring the executable to be + relocated, which is a benefit to embedded applications with tight + memory constraints. Data that can be modified is not affected by this + option. + + Note, using this feature reserves a register, usually ``r13``, for + the constant data base address. This can result in slower and/or + larger code, especially in complicated functions. + + The actual register chosen to hold the constant data base address + depends upon whether the :option:`-msmall-data-limit` and/or the + :option:`-mint-register` command-line options are enabled. Starting + with register ``r13`` and proceeding downwards, registers are + allocated first to satisfy the requirements of :option:`-mint-register`, + then :option:`-mpid` and finally :option:`-msmall-data-limit`. Thus it + is possible for the small data area register to be ``r8`` if both + :option:`-mint-register=4` and :option:`-mpid` are specified on the + command line. + + By default this feature is not enabled. The default can be restored + via the :option:`-mno-pid` command-line option. + +.. option:: -mno-warn-multiple-fast-interrupts, -mwarn-multiple-fast-interrupts + + Prevents GCC from issuing a warning message if it finds more than one + fast interrupt handler when it is compiling a file. The default is to + issue a warning for each extra fast interrupt handler found, as the RX + only supports one such interrupt. + +.. option:: -mallow-string-insns, -mno-allow-string-insns + + Enables or disables the use of the string manipulation instructions + ``SMOVF``, ``SCMPU``, ``SMOVB``, ``SMOVU``, ``SUNTIL`` + ``SWHILE`` and also the ``RMPA`` instruction. These + instructions may prefetch data, which is not safe to do if accessing + an I/O register. (See section 12.2.7 of the RX62N Group User's Manual + for more information). + + The default is to allow these instructions, but it is not possible for + GCC to reliably detect all circumstances where a string instruction + might be used to access an I/O register, so their use cannot be + disabled automatically. Instead it is reliant upon the programmer to + use the :option:`-mno-allow-string-insns` option if their program + accesses I/O space. + + When the instructions are enabled GCC defines the C preprocessor + symbol ``__RX_ALLOW_STRING_INSNS__``, otherwise it defines the + symbol ``__RX_DISALLOW_STRING_INSNS__``. + +.. option:: -mjsr, -mno-jsr + + Use only (or not only) ``JSR`` instructions to access functions. + This option can be used when code size exceeds the range of ``BSR`` + instructions. Note that :option:`-mno-jsr` does not mean to not use + ``JSR`` but instead means that any type of branch may be used. + +.. note:: + + The generic GCC command-line option :option:`-ffixed-reg` + has special significance to the RX port when used with the + :rx-fn-attr:`interrupt` function attribute. This attribute indicates a + function intended to process fast interrupts. GCC ensures + that it only uses the registers ``r10``, ``r11``, ``r12`` + and/or ``r13`` and only provided that the normal use of the + corresponding registers have been restricted via the + :option:`-ffixed-reg` or :option:`-mint-register` command-line + options. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/s-390-and-zseries-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/s-390-and-zseries-options.rst new file mode 100644 index 00000000000..7cdde513897 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/s-390-and-zseries-options.rst @@ -0,0 +1,244 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: S/390 and zSeries + +.. index:: S/390 and zSeries Options + +.. _s-390-and-zseries-options: + +S/390 and zSeries Options +^^^^^^^^^^^^^^^^^^^^^^^^^ + +These are the :samp:`-m` options defined for the S/390 and zSeries architecture. + +.. option:: -mhard-float, -msoft-float + + Use (do not use) the hardware floating-point instructions and registers + for floating-point operations. When :option:`-msoft-float` is specified, + functions in :samp:`libgcc.a` are used to perform floating-point + operations. When :option:`-mhard-float` is specified, the compiler + generates IEEE floating-point instructions. This is the default. + +.. option:: -mhard-dfp, -mno-hard-dfp + + Use (do not use) the hardware decimal-floating-point instructions for + decimal-floating-point operations. When :option:`-mno-hard-dfp` is + specified, functions in :samp:`libgcc.a` are used to perform + decimal-floating-point operations. When :option:`-mhard-dfp` is + specified, the compiler generates decimal-floating-point hardware + instructions. This is the default for :option:`-march=z9-ec` or higher. + +.. option:: -mlong-double-64, -mlong-double-128 + + These switches control the size of ``long double`` type. A size + of 64 bits makes the ``long double`` type equivalent to the ``double`` + type. This is the default. + +.. option:: -mbackchain, -mno-backchain + + Store (do not store) the address of the caller's frame as backchain pointer + into the callee's stack frame. + A backchain may be needed to allow debugging using tools that do not understand + DWARF call frame information. + When :option:`-mno-packed-stack` is in effect, the backchain pointer is stored + at the bottom of the stack frame; when :option:`-mpacked-stack` is in effect, + the backchain is placed into the topmost word of the 96/160 byte register + save area. + + In general, code compiled with :option:`-mbackchain` is call-compatible with + code compiled with :option:`-mno-backchain` ; however, use of the backchain + for debugging purposes usually requires that the whole binary is built with + :option:`-mbackchain`. Note that the combination of :option:`-mbackchain`, + :option:`-mpacked-stack` and :option:`-mhard-float` is not supported. In order + to build a linux kernel use :option:`-msoft-float`. + + The default is to not maintain the backchain. + +.. option:: -mpacked-stack, -mno-packed-stack + + Use (do not use) the packed stack layout. When :option:`-mno-packed-stack` is + specified, the compiler uses the all fields of the 96/160 byte register save + area only for their default purpose; unused fields still take up stack space. + When :option:`-mpacked-stack` is specified, register save slots are densely + packed at the top of the register save area; unused space is reused for other + purposes, allowing for more efficient use of the available stack space. + However, when :option:`-mbackchain` is also in effect, the topmost word of + the save area is always used to store the backchain, and the return address + register is always saved two words below the backchain. + + As long as the stack frame backchain is not used, code generated with + :option:`-mpacked-stack` is call-compatible with code generated with + :option:`-mno-packed-stack`. Note that some non-FSF releases of GCC 2.95 for + S/390 or zSeries generated code that uses the stack frame backchain at run + time, not just for debugging purposes. Such code is not call-compatible + with code compiled with :option:`-mpacked-stack`. Also, note that the + combination of :option:`-mbackchain`, + :option:`-mpacked-stack` and :option:`-mhard-float` is not supported. In order + to build a linux kernel use :option:`-msoft-float`. + + The default is to not use the packed stack layout. + +.. option:: -msmall-exec, -mno-small-exec + + Generate (or do not generate) code using the ``bras`` instruction + to do subroutine calls. + This only works reliably if the total executable size does not + exceed 64k. The default is to use the ``basr`` instruction instead, + which does not have this limitation. + +.. option:: -m64, -m31 + + When :option:`-m31` is specified, generate code compliant to the + GNU/Linux for S/390 ABI. When :option:`-m64` is specified, generate + code compliant to the GNU/Linux for zSeries ABI. This allows GCC in + particular to generate 64-bit instructions. For the :samp:`s390` + targets, the default is :option:`-m31`, while the :samp:`s390x` + targets default to :option:`-m64`. + +.. option:: -mzarch, -mesa + + When :option:`-mzarch` is specified, generate code using the + instructions available on z/Architecture. + When :option:`-mesa` is specified, generate code using the + instructions available on ESA/390. Note that :option:`-mesa` is + not possible with :option:`-m64`. + When generating code compliant to the GNU/Linux for S/390 ABI, + the default is :option:`-mesa`. When generating code compliant + to the GNU/Linux for zSeries ABI, the default is :option:`-mzarch`. + +.. option:: -mhtm, -mno-htm + + The :option:`-mhtm` option enables a set of builtins making use of + instructions available with the transactional execution facility + introduced with the IBM zEnterprise EC12 machine generation + :ref:`s-390-system-z-built-in-functions`. + :option:`-mhtm` is enabled by default when using :option:`-march=zEC12`. + +.. option:: -mvx, -mno-vx + + When :option:`-mvx` is specified, generate code using the instructions + available with the vector extension facility introduced with the IBM + z13 machine generation. + This option changes the ABI for some vector type values with regard to + alignment and calling conventions. In case vector type values are + being used in an ABI-relevant context a GAS :samp:`.gnu_attribute` + command will be added to mark the resulting binary with the ABI used. + :option:`-mvx` is enabled by default when using :option:`-march=z13`. + +.. option:: -mzvector, -mno-zvector + + The :option:`-mzvector` option enables vector language extensions and + builtins using instructions available with the vector extension + facility introduced with the IBM z13 machine generation. + This option adds support for :samp:`vector` to be used as a keyword to + define vector type variables and arguments. :samp:`vector` is only + available when GNU extensions are enabled. It will not be expanded + when requesting strict standard compliance e.g. with :option:`-std=c99`. + In addition to the GCC low-level builtins :option:`-mzvector` enables + a set of builtins added for compatibility with AltiVec-style + implementations like Power and Cell. In order to make use of these + builtins the header file :samp:`vecintrin.h` needs to be included. + :option:`-mzvector` is disabled by default. + +.. option:: -mmvcle, -mno-mvcle + + Generate (or do not generate) code using the ``mvcle`` instruction + to perform block moves. When :option:`-mno-mvcle` is specified, + use a ``mvc`` loop instead. This is the default unless optimizing for + size. + +.. option:: -mdebug, -mno-debug + + Print (or do not print) additional debug information when compiling. + The default is to not print debug information. + +.. option:: -march={cpu-type} + + Generate code that runs on :samp:`{cpu-type}`, which is the name of a + system representing a certain processor type. Possible values for + :samp:`{cpu-type}` are :samp:`z900`/:samp:`arch5`, :samp:`z990`/:samp:`arch6`, + :samp:`z9-109`, :samp:`z9-ec`/:samp:`arch7`, :samp:`z10`/:samp:`arch8`, + :samp:`z196`/:samp:`arch9`, :samp:`zEC12`, :samp:`z13`/:samp:`arch11`, + :samp:`z14`/:samp:`arch12`, :samp:`z15`/:samp:`arch13`, + :samp:`z16`/:samp:`arch14`, and :samp:`native`. + + The default is :option:`-march=z900`. + + Specifying :samp:`native` as cpu type can be used to select the best + architecture option for the host processor. + :option:`-march=native` has no effect if GCC does not recognize the + processor. + +.. option:: -mtune={cpu-type} + + Tune to :samp:`{cpu-type}` everything applicable about the generated code, + except for the ABI and the set of available instructions. + The list of :samp:`{cpu-type}` values is the same as for :option:`-march`. + The default is the value used for :option:`-march`. + +.. option:: -mtpf-trace, -mno-tpf-trace + + Generate code that adds (does not add) in TPF OS specific branches to trace + routines in the operating system. This option is off by default, even + when compiling for the TPF OS. + +.. option:: -mtpf-trace-skip, -mno-tpf-trace-skip + + Generate code that changes (does not change) the default branch + targets enabled by :option:`-mtpf-trace` to point to specialized trace + routines providing the ability of selectively skipping function trace + entries for the TPF OS. This option is off by default, even when + compiling for the TPF OS and specifying :option:`-mtpf-trace`. + +.. option:: -mfused-madd, -mno-fused-madd + + Generate code that uses (does not use) the floating-point multiply and + accumulate instructions. These instructions are generated by default if + hardware floating point is used. + +.. option:: -mwarn-framesize={framesize} + + Emit a warning if the current function exceeds the given frame size. Because + this is a compile-time check it doesn't need to be a real problem when the program + runs. It is intended to identify functions that most probably cause + a stack overflow. It is useful to be used in an environment with limited stack + size e.g. the linux kernel. + +.. option:: -mwarn-dynamicstack + + Emit a warning if the function calls ``alloca`` or uses dynamically-sized + arrays. This is generally a bad idea with a limited stack size. + +.. option:: -mstack-guard={stack-guard} + + If these options are provided the S/390 back end emits additional instructions in + the function prologue that trigger a trap if the stack size is :samp:`{stack-guard}` + bytes above the :samp:`{stack-size}` (remember that the stack on S/390 grows downward). + If the :samp:`{stack-guard}` option is omitted the smallest power of 2 larger than + the frame size of the compiled function is chosen. + These options are intended to be used to help debugging stack overflow problems. + The additionally emitted code causes only little overhead and hence can also be + used in production-like systems without greater performance degradation. The given + values have to be exact powers of 2 and :samp:`{stack-size}` has to be greater than + :samp:`{stack-guard}` without exceeding 64k. + In order to be efficient the extra code makes the assumption that the stack starts + at an address aligned to the value given by :samp:`{stack-size}`. + The :samp:`{stack-guard}` option can only be used in conjunction with :samp:`{stack-size}`. + +.. option:: -mhotpatch={pre-halfwords},{post-halfwords} + + If the hotpatch option is enabled, a 'hot-patching' function + prologue is generated for all functions in the compilation unit. + The funtion label is prepended with the given number of two-byte + NOP instructions (:samp:`{pre-halfwords}`, maximum 1000000). After + the label, 2 \* :samp:`{post-halfwords}` bytes are appended, using the + largest NOP like instructions the architecture allows (maximum + 1000000). + + If both arguments are zero, hotpatching is disabled. + + This option can be overridden for individual functions with the + ``hotpatch`` attribute. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/score-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/score-options.rst new file mode 100644 index 00000000000..900da883b2e --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/score-options.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: Score + +.. index:: Score Options + +.. _score-options: + +Score Options +^^^^^^^^^^^^^ + +These options are defined for Score implementations: + +.. option:: -meb + + Compile code for big-endian mode. This is the default. + +.. option:: -mel + + Compile code for little-endian mode. + +.. option:: -mnhwloop + + Disable generation of ``bcnz`` instructions. + +.. option:: -muls + + Enable generation of unaligned load and store instructions. + +.. option:: -mmac + + Enable the use of multiply-accumulate instructions. Disabled by default. + +.. option:: -mscore5 + + Specify the SCORE5 as the target architecture. + +.. option:: -mscore5u + + Specify the SCORE5U of the target architecture. + +.. option:: -mscore7 + + Specify the SCORE7 as the target architecture. This is the default. + +.. option:: -mscore7d + + Specify the SCORE7D as the target architecture. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/sh-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/sh-options.rst new file mode 100644 index 00000000000..b1c1b9fe4c2 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/sh-options.rst @@ -0,0 +1,444 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: SH + +.. _sh-options: + +SH Options +^^^^^^^^^^ + +These :samp:`-m` options are defined for the SH implementations: + +.. option:: -m1 + + Generate code for the SH1. + +.. option:: -m2 + + Generate code for the SH2. + +.. option:: -m2e + + Generate code for the SH2e. + +.. option:: -m2a-nofpu + + Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way + that the floating-point unit is not used. + +.. option:: -m2a-single-only + + Generate code for the SH2a-FPU, in such a way that no double-precision + floating-point operations are used. + +.. option:: -m2a-single + + Generate code for the SH2a-FPU assuming the floating-point unit is in + single-precision mode by default. + +.. option:: -m2a + + Generate code for the SH2a-FPU assuming the floating-point unit is in + double-precision mode by default. + +.. option:: -m3 + + Generate code for the SH3. + +.. option:: -m3e + + Generate code for the SH3e. + +.. option:: -m4-nofpu + + Generate code for the SH4 without a floating-point unit. + +.. option:: -m4-single-only + + Generate code for the SH4 with a floating-point unit that only + supports single-precision arithmetic. + +.. option:: -m4-single + + Generate code for the SH4 assuming the floating-point unit is in + single-precision mode by default. + +.. option:: -m4 + + Generate code for the SH4. + +.. option:: -m4-100 + + Generate code for SH4-100. + +.. option:: -m4-100-nofpu + + Generate code for SH4-100 in such a way that the + floating-point unit is not used. + +.. option:: -m4-100-single + + Generate code for SH4-100 assuming the floating-point unit is in + single-precision mode by default. + +.. option:: -m4-100-single-only + + Generate code for SH4-100 in such a way that no double-precision + floating-point operations are used. + +.. option:: -m4-200 + + Generate code for SH4-200. + +.. option:: -m4-200-nofpu + + Generate code for SH4-200 without in such a way that the + floating-point unit is not used. + +.. option:: -m4-200-single + + Generate code for SH4-200 assuming the floating-point unit is in + single-precision mode by default. + +.. option:: -m4-200-single-only + + Generate code for SH4-200 in such a way that no double-precision + floating-point operations are used. + +.. option:: -m4-300 + + Generate code for SH4-300. + +.. option:: -m4-300-nofpu + + Generate code for SH4-300 without in such a way that the + floating-point unit is not used. + +.. option:: -m4-300-single + + Generate code for SH4-300 in such a way that no double-precision + floating-point operations are used. + +.. option:: -m4-300-single-only + + Generate code for SH4-300 in such a way that no double-precision + floating-point operations are used. + +.. option:: -m4-340 + + Generate code for SH4-340 (no MMU, no FPU). + +.. option:: -m4-500 + + Generate code for SH4-500 (no FPU). Passes :option:`-isa=sh4-nofpu` to the + assembler. + +.. option:: -m4a-nofpu + + Generate code for the SH4al-dsp, or for a SH4a in such a way that the + floating-point unit is not used. + +.. option:: -m4a-single-only + + Generate code for the SH4a, in such a way that no double-precision + floating-point operations are used. + +.. option:: -m4a-single + + Generate code for the SH4a assuming the floating-point unit is in + single-precision mode by default. + +.. option:: -m4a + + Generate code for the SH4a. + +.. option:: -m4al + + Same as :option:`-m4a-nofpu`, except that it implicitly passes + :option:`-dsp` to the assembler. GCC doesn't generate any DSP + instructions at the moment. + +.. option:: -mb + + Compile code for the processor in big-endian mode. + +.. option:: -ml + + Compile code for the processor in little-endian mode. + +.. option:: -mdalign + + Align doubles at 64-bit boundaries. Note that this changes the calling + conventions, and thus some functions from the standard C library do + not work unless you recompile it first with :option:`-mdalign`. + +.. option:: -mrelax + + Shorten some address references at link time, when possible; uses the + linker option :option:`-relax`. + +.. option:: -mbigtable + + Use 32-bit offsets in ``switch`` tables. The default is to use + 16-bit offsets. + +.. option:: -mbitops + + Enable the use of bit manipulation instructions on SH2A. + +.. option:: -mfmovd + + Enable the use of the instruction ``fmovd``. Check :option:`-mdalign` for + alignment constraints. + +.. option:: -mrenesas + + Comply with the calling conventions defined by Renesas. + +.. option:: -mno-renesas + + Comply with the calling conventions defined for GCC before the Renesas + conventions were available. This option is the default for all + targets of the SH toolchain. + +.. option:: -mnomacsave + + Mark the ``MAC`` register as call-clobbered, even if + :option:`-mrenesas` is given. + +.. option:: -mieee, -mno-ieee + + Control the IEEE compliance of floating-point comparisons, which affects the + handling of cases where the result of a comparison is unordered. By default + :option:`-mieee` is implicitly enabled. If :option:`-ffinite-math-only` is + enabled :option:`-mno-ieee` is implicitly set, which results in faster + floating-point greater-equal and less-equal comparisons. The implicit settings + can be overridden by specifying either :option:`-mieee` or :option:`-mno-ieee`. + +.. option:: -minline-ic_invalidate + + Inline code to invalidate instruction cache entries after setting up + nested function trampolines. + This option has no effect if :option:`-musermode` is in effect and the selected + code generation option (e.g. :option:`-m4`) does not allow the use of the ``icbi`` + instruction. + If the selected code generation option does not allow the use of the ``icbi`` + instruction, and :option:`-musermode` is not in effect, the inlined code + manipulates the instruction cache address array directly with an associative + write. This not only requires privileged mode at run time, but it also + fails if the cache line had been mapped via the TLB and has become unmapped. + +.. option:: -misize + + Dump instruction size and location in the assembly code. + +.. option:: -mpadstruct + + This option is deprecated. It pads structures to multiple of 4 bytes, + which is incompatible with the SH ABI. + +.. index:: matomic-model=model + +.. option:: -matomic-model={model} + + Sets the model of atomic operations and additional parameters as a comma + separated list. For details on the atomic built-in functions see + :ref:`atomic-builtins`. The following models and parameters are supported: + + :samp:`none` + Disable compiler generated atomic sequences and emit library calls for atomic + operations. This is the default if the target is not ``sh*-*-linux*``. + + :samp:`soft-gusa` + Generate GNU/Linux compatible gUSA software atomic sequences for the atomic + built-in functions. The generated atomic sequences require additional support + from the interrupt/exception handling code of the system and are only suitable + for SH3\* and SH4\* single-core systems. This option is enabled by default when + the target is ``sh*-*-linux*`` and SH3\* or SH4\*. When the target is SH4A, + this option also partially utilizes the hardware atomic instructions + ``movli.l`` and ``movco.l`` to create more efficient code, unless + :samp:`strict` is specified. + + :samp:`soft-tcb` + Generate software atomic sequences that use a variable in the thread control + block. This is a variation of the gUSA sequences which can also be used on + SH1\* and SH2\* targets. The generated atomic sequences require additional + support from the interrupt/exception handling code of the system and are only + suitable for single-core systems. When using this model, the :samp:`gbr-offset=` + parameter has to be specified as well. + + :samp:`soft-imask` + Generate software atomic sequences that temporarily disable interrupts by + setting ``SR.IMASK = 1111``. This model works only when the program runs + in privileged mode and is only suitable for single-core systems. Additional + support from the interrupt/exception handling code of the system is not + required. This model is enabled by default when the target is + ``sh*-*-linux*`` and SH1\* or SH2\*. + + :samp:`hard-llcs` + Generate hardware atomic sequences using the ``movli.l`` and ``movco.l`` + instructions only. This is only available on SH4A and is suitable for + multi-core systems. Since the hardware instructions support only 32 bit atomic + variables access to 8 or 16 bit variables is emulated with 32 bit accesses. + Code compiled with this option is also compatible with other software + atomic model interrupt/exception handling systems if executed on an SH4A + system. Additional support from the interrupt/exception handling code of the + system is not required for this model. + + :samp:`gbr-offset=` + This parameter specifies the offset in bytes of the variable in the thread + control block structure that should be used by the generated atomic sequences + when the :samp:`soft-tcb` model has been selected. For other models this + parameter is ignored. The specified value must be an integer multiple of four + and in the range 0-1020. + + :samp:`strict` + This parameter prevents mixed usage of multiple atomic models, even if they + are compatible, and makes the compiler generate atomic sequences of the + specified model only. + +.. option:: -mtas + + Generate the ``tas.b`` opcode for ``__atomic_test_and_set``. + Notice that depending on the particular hardware and software configuration + this can degrade overall performance due to the operand cache line flushes + that are implied by the ``tas.b`` instruction. On multi-core SH4A + processors the ``tas.b`` instruction must be used with caution since it + can result in data corruption for certain cache configurations. + +.. option:: -mprefergot + + When generating position-independent code, emit function calls using + the Global Offset Table instead of the Procedure Linkage Table. + +.. option:: -musermode, -mno-usermode + + Don't allow (allow) the compiler generating privileged mode code. Specifying + :option:`-musermode` also implies :option:`-mno-inline-ic_invalidate` if the + inlined code would not work in user mode. :option:`-musermode` is the default + when the target is ``sh*-*-linux*``. If the target is SH1\* or SH2\* + :option:`-musermode` has no effect, since there is no user mode. + +.. index:: multcost=number + +.. option:: -multcost={number} + + Set the cost to assume for a multiply insn. + +.. index:: mdiv=strategy + +.. option:: -mdiv={strategy} + + Set the division strategy to be used for integer division operations. + :samp:`{strategy}` can be one of: + + :samp:`call-div1` + Calls a library function that uses the single-step division instruction + ``div1`` to perform the operation. Division by zero calculates an + unspecified result and does not trap. This is the default except for SH4, + SH2A and SHcompact. + + :samp:`call-fp` + Calls a library function that performs the operation in double precision + floating point. Division by zero causes a floating-point exception. This is + the default for SHcompact with FPU. Specifying this for targets that do not + have a double precision FPU defaults to ``call-div1``. + + :samp:`call-table` + Calls a library function that uses a lookup table for small divisors and + the ``div1`` instruction with case distinction for larger divisors. Division + by zero calculates an unspecified result and does not trap. This is the default + for SH4. Specifying this for targets that do not have dynamic shift + instructions defaults to ``call-div1``. + + When a division strategy has not been specified the default strategy is + selected based on the current target. For SH2A the default strategy is to + use the ``divs`` and ``divu`` instructions instead of library function + calls. + +.. option:: -maccumulate-outgoing-args + + Reserve space once for outgoing arguments in the function prologue rather + than around each call. Generally beneficial for performance and size. Also + needed for unwinding to avoid changing the stack frame around conditional code. + +.. index:: mdivsi3_libfunc=name + +.. option:: -mdivsi3_libfunc={name} + + Set the name of the library function used for 32-bit signed division to + :samp:`{name}`. + This only affects the name used in the :samp:`call` division strategies, and + the compiler still expects the same sets of input/output/clobbered registers as + if this option were not present. + +.. option:: -mfixed-range={register-range} + + Generate code treating the given register range as fixed registers. + A fixed register is one that the register allocator cannot use. This is + useful when compiling kernel code. A register range is specified as + two registers separated by a dash. Multiple register ranges can be + specified separated by a comma. + +.. index:: mbranch-cost=num + +.. option:: -mbranch-cost={num} + + Assume :samp:`{num}` to be the cost for a branch instruction. Higher numbers + make the compiler try to generate more branch-free code if possible. + If not specified the value is selected depending on the processor type that + is being compiled for. + +.. option:: -mzdcbranch, -mno-zdcbranch + + Assume (do not assume) that zero displacement conditional branch instructions + ``bt`` and ``bf`` are fast. If :option:`-mzdcbranch` is specified, the + compiler prefers zero displacement branch code sequences. This is + enabled by default when generating code for SH4 and SH4A. It can be explicitly + disabled by specifying :option:`-mno-zdcbranch`. + +.. option:: -mcbranch-force-delay-slot + + Force the usage of delay slots for conditional branches, which stuffs the delay + slot with a ``nop`` if a suitable instruction cannot be found. By default + this option is disabled. It can be enabled to work around hardware bugs as + found in the original SH7055. + +.. option:: -mfused-madd, -mno-fused-madd + + Generate code that uses (does not use) the floating-point multiply and + accumulate instructions. These instructions are generated by default + if hardware floating point is used. The machine-dependent + :option:`-mfused-madd` option is now mapped to the machine-independent + :option:`-ffp-contract=fast` option, and :option:`-mno-fused-madd` is + mapped to :option:`-ffp-contract=off`. + +.. option:: -mfsca, -mno-fsca + + Allow or disallow the compiler to emit the ``fsca`` instruction for sine + and cosine approximations. The option :option:`-mfsca` must be used in + combination with :option:`-funsafe-math-optimizations`. It is enabled by default + when generating code for SH4A. Using :option:`-mno-fsca` disables sine and cosine + approximations even if :option:`-funsafe-math-optimizations` is in effect. + +.. option:: -mfsrra, -mno-fsrra + + Allow or disallow the compiler to emit the ``fsrra`` instruction for + reciprocal square root approximations. The option :option:`-mfsrra` must be used + in combination with :option:`-funsafe-math-optimizations` and + :option:`-ffinite-math-only`. It is enabled by default when generating code for + SH4A. Using :option:`-mno-fsrra` disables reciprocal square root approximations + even if :option:`-funsafe-math-optimizations` and :option:`-ffinite-math-only` are + in effect. + +.. option:: -mpretend-cmove + + Prefer zero-displacement conditional branches for conditional move instruction + patterns. This can result in faster code on the SH4 processor. + +.. option:: -mfdpic + + Generate code using the FDPIC ABI. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/solaris-2-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/solaris-2-options.rst new file mode 100644 index 00000000000..39ef4cd8f3b --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/solaris-2-options.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: Solaris 2 + +.. index:: Solaris 2 options + +.. _solaris-2-options: + +Solaris 2 Options +^^^^^^^^^^^^^^^^^ + +These :samp:`-m` options are supported on Solaris 2: + +.. option:: -mclear-hwcap + + :option:`-mclear-hwcap` tells the compiler to remove the hardware + capabilities generated by the Solaris assembler. This is only necessary + when object files use ISA extensions not supported by the current + machine, but check at runtime whether or not to use them. + +.. option:: -mimpure-text + + :option:`-mimpure-text`, used in addition to :option:`-shared`, tells + the compiler to not pass :option:`-z text` to the linker when linking a + shared object. Using this option, you can link position-dependent + code into a shared object. + + :option:`-mimpure-text` suppresses the 'relocations remain against + allocatable but non-writable sections' linker error message. + However, the necessary relocations trigger copy-on-write, and the + shared object is not actually shared across processes. Instead of + using :option:`-mimpure-text`, you should compile all source code with + :option:`-fpic` or :option:`-fPIC`. + +These switches are supported in addition to the above on Solaris 2: + +.. option:: -pthreads + + This is a synonym for :option:`-pthread`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/sparc-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/sparc-options.rst new file mode 100644 index 00000000000..9cffb712cfc --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/sparc-options.rst @@ -0,0 +1,388 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: SPARC + +.. index:: SPARC options + +.. _sparc-options: + +SPARC Options +^^^^^^^^^^^^^ + +These :samp:`-m` options are supported on the SPARC: + +.. option:: -mno-app-regs, -mapp-regs + + Specify :option:`-mapp-regs` to generate output using the global registers + 2 through 4, which the SPARC SVR4 ABI reserves for applications. Like the + global register 1, each global register 2 through 4 is then treated as an + allocable register that is clobbered by function calls. This is the default. + + To be fully SVR4 ABI-compliant at the cost of some performance loss, + specify :option:`-mno-app-regs`. You should compile libraries and system + software with this option. + +.. option:: -mflat, -mno-flat + + With :option:`-mflat`, the compiler does not generate save/restore instructions + and uses a 'flat' or single register window model. This model is compatible + with the regular register window model. The local registers and the input + registers (0--5) are still treated as 'call-saved' registers and are + saved on the stack as needed. + + With :option:`-mno-flat` (the default), the compiler generates save/restore + instructions (except for leaf functions). This is the normal operating mode. + +.. option:: -mfpu, -mhard-float + + Generate output containing floating-point instructions. This is the + default. + +.. option:: -mno-fpu, -msoft-float + + Generate output containing library calls for floating point. + + .. warning:: + + The requisite libraries are not available for all SPARC + targets. Normally the facilities of the machine's usual C compiler are + used, but this cannot be done directly in cross-compilation. You must make + your own arrangements to provide suitable library functions for + cross-compilation. The embedded targets :samp:`sparc-*-aout` and + :samp:`sparclite-*-*` do provide software floating-point support. + + :option:`-msoft-float` changes the calling convention in the output file; + therefore, it is only useful if you compile *all* of a program with + this option. In particular, you need to compile :samp:`libgcc.a`, the + library that comes with GCC, with :option:`-msoft-float` in order for + this to work. + +.. option:: -mhard-quad-float + + Generate output containing quad-word (long double) floating-point + instructions. + +.. option:: -msoft-quad-float + + Generate output containing library calls for quad-word (long double) + floating-point instructions. The functions called are those specified + in the SPARC ABI. This is the default. + + As of this writing, there are no SPARC implementations that have hardware + support for the quad-word floating-point instructions. They all invoke + a trap handler for one of these instructions, and then the trap handler + emulates the effect of the instruction. Because of the trap handler overhead, + this is much slower than calling the ABI library routines. Thus the + :option:`-msoft-quad-float` option is the default. + +.. option:: -mno-unaligned-doubles, -munaligned-doubles + + Assume that doubles have 8-byte alignment. This is the default. + + With :option:`-munaligned-doubles`, GCC assumes that doubles have 8-byte + alignment only if they are contained in another type, or if they have an + absolute address. Otherwise, it assumes they have 4-byte alignment. + Specifying this option avoids some rare compatibility problems with code + generated by other compilers. It is not the default because it results + in a performance loss, especially for floating-point code. + +.. option:: -muser-mode, -mno-user-mode + + Do not generate code that can only run in supervisor mode. This is relevant + only for the ``casa`` instruction emitted for the LEON3 processor. This + is the default. + +.. option:: -mfaster-structs, -mno-faster-structs + + With :option:`-mfaster-structs`, the compiler assumes that structures + should have 8-byte alignment. This enables the use of pairs of + ``ldd`` and ``std`` instructions for copies in structure + assignment, in place of twice as many ``ld`` and ``st`` pairs. + However, the use of this changed alignment directly violates the SPARC + ABI. Thus, it's intended only for use on targets where the developer + acknowledges that their resulting code is not directly in line with + the rules of the ABI. + +.. option:: -mstd-struct-return, -mno-std-struct-return + + With :option:`-mstd-struct-return`, the compiler generates checking code + in functions returning structures or unions to detect size mismatches + between the two sides of function calls, as per the 32-bit ABI. + + The default is :option:`-mno-std-struct-return`. This option has no effect + in 64-bit mode. + +.. option:: -mlra, -mno-lra + + Enable Local Register Allocation. This is the default for SPARC since GCC 7 + so :option:`-mno-lra` needs to be passed to get old Reload. + +.. option:: -mcpu={cpu_type} + + Set the instruction set, register set, and instruction scheduling parameters + for machine type :samp:`{cpu_type}`. Supported values for :samp:`{cpu_type}` are + :samp:`v7`, :samp:`cypress`, :samp:`v8`, :samp:`supersparc`, :samp:`hypersparc`, + :samp:`leon`, :samp:`leon3`, :samp:`leon3v7`, :samp:`leon5`, :samp:`sparclite`, + :samp:`f930`, :samp:`f934`, :samp:`sparclite86x`, :samp:`sparclet`, :samp:`tsc701`, + :samp:`v9`, :samp:`ultrasparc`, :samp:`ultrasparc3`, :samp:`niagara`, + :samp:`niagara2`, :samp:`niagara3`, :samp:`niagara4`, :samp:`niagara7` and + :samp:`m8`. + + Native Solaris and GNU/Linux toolchains also support the value :samp:`native`, + which selects the best architecture option for the host processor. + :option:`-mcpu=native` has no effect if GCC does not recognize + the processor. + + Default instruction scheduling parameters are used for values that select + an architecture and not an implementation. These are :samp:`v7`, :samp:`v8`, + :samp:`sparclite`, :samp:`sparclet`, :samp:`v9`. + + Here is a list of each supported architecture and their supported + implementations. + + v7 + cypress, leon3v7 + + v8 + supersparc, hypersparc, leon, leon3, leon5 + + sparclite + f930, f934, sparclite86x + + sparclet + tsc701 + + v9 + ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4, + niagara7, m8 + + By default (unless configured otherwise), GCC generates code for the V7 + variant of the SPARC architecture. With :option:`-mcpu=cypress`, the compiler + additionally optimizes it for the Cypress CY7C602 chip, as used in the + SPARCStation/SPARCServer 3xx series. This is also appropriate for the older + SPARCStation 1, 2, IPX etc. + + With :option:`-mcpu=v8`, GCC generates code for the V8 variant of the SPARC + architecture. The only difference from V7 code is that the compiler emits + the integer multiply and integer divide instructions which exist in SPARC-V8 + but not in SPARC-V7. With :option:`-mcpu=supersparc`, the compiler additionally + optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and + 2000 series. + + With :option:`-mcpu=sparclite`, GCC generates code for the SPARClite variant of + the SPARC architecture. This adds the integer multiply, integer divide step + and scan (``ffs``) instructions which exist in SPARClite but not in SPARC-V7. + With :option:`-mcpu=f930`, the compiler additionally optimizes it for the + Fujitsu MB86930 chip, which is the original SPARClite, with no FPU. With + :option:`-mcpu=f934`, the compiler additionally optimizes it for the Fujitsu + MB86934 chip, which is the more recent SPARClite with FPU. + + With :option:`-mcpu=sparclet`, GCC generates code for the SPARClet variant of + the SPARC architecture. This adds the integer multiply, multiply/accumulate, + integer divide step and scan (``ffs``) instructions which exist in SPARClet + but not in SPARC-V7. With :option:`-mcpu=tsc701`, the compiler additionally + optimizes it for the TEMIC SPARClet chip. + + With :option:`-mcpu=v9`, GCC generates code for the V9 variant of the SPARC + architecture. This adds 64-bit integer and floating-point move instructions, + 3 additional floating-point condition code registers and conditional move + instructions. With :option:`-mcpu=ultrasparc`, the compiler additionally + optimizes it for the Sun UltraSPARC I/II/IIi chips. With + :option:`-mcpu=ultrasparc3`, the compiler additionally optimizes it for the + Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With + :option:`-mcpu=niagara`, the compiler additionally optimizes it for + Sun UltraSPARC T1 chips. With :option:`-mcpu=niagara2`, the compiler + additionally optimizes it for Sun UltraSPARC T2 chips. With + :option:`-mcpu=niagara3`, the compiler additionally optimizes it for Sun + UltraSPARC T3 chips. With :option:`-mcpu=niagara4`, the compiler + additionally optimizes it for Sun UltraSPARC T4 chips. With + :option:`-mcpu=niagara7`, the compiler additionally optimizes it for + Oracle SPARC M7 chips. With :option:`-mcpu=m8`, the compiler + additionally optimizes it for Oracle M8 chips. + +.. option:: -mtune={cpu_type} + + Set the instruction scheduling parameters for machine type + :samp:`{cpu_type}`, but do not set the instruction set or register set that the + option :option:`-mcpu=cpu_type` does. + + The same values for :option:`-mcpu=cpu_type` can be used for + :option:`-mtune=cpu_type`, but the only useful values are those + that select a particular CPU implementation. Those are + :samp:`cypress`, :samp:`supersparc`, :samp:`hypersparc`, :samp:`leon`, + :samp:`leon3`, :samp:`leon3v7`, :samp:`leon5`, :samp:`f930`, :samp:`f934`, + :samp:`sparclite86x`, :samp:`tsc701`, :samp:`ultrasparc`, + :samp:`ultrasparc3`, :samp:`niagara`, :samp:`niagara2`, :samp:`niagara3`, + :samp:`niagara4`, :samp:`niagara7` and :samp:`m8`. With native Solaris + and GNU/Linux toolchains, :samp:`native` can also be used. + +.. option:: -mv8plus, -mno-v8plus + + With :option:`-mv8plus`, GCC generates code for the SPARC-V8+ ABI. The + difference from the V8 ABI is that the global and out registers are + considered 64 bits wide. This is enabled by default on Solaris in 32-bit + mode for all SPARC-V9 processors. + +.. option:: -mvis, -mno-vis + + With :option:`-mvis`, GCC generates code that takes advantage of the UltraSPARC + Visual Instruction Set extensions. The default is :option:`-mno-vis`. + +.. option:: -mvis2, -mno-vis2 + + With :option:`-mvis2`, GCC generates code that takes advantage of + version 2.0 of the UltraSPARC Visual Instruction Set extensions. The + default is :option:`-mvis2` when targeting a cpu that supports such + instructions, such as UltraSPARC-III and later. Setting :option:`-mvis2` + also sets :option:`-mvis`. + +.. option:: -mvis3, -mno-vis3 + + With :option:`-mvis3`, GCC generates code that takes advantage of + version 3.0 of the UltraSPARC Visual Instruction Set extensions. The + default is :option:`-mvis3` when targeting a cpu that supports such + instructions, such as niagara-3 and later. Setting :option:`-mvis3` + also sets :option:`-mvis2` and :option:`-mvis`. + +.. option:: -mvis4, -mno-vis4 + + With :option:`-mvis4`, GCC generates code that takes advantage of + version 4.0 of the UltraSPARC Visual Instruction Set extensions. The + default is :option:`-mvis4` when targeting a cpu that supports such + instructions, such as niagara-7 and later. Setting :option:`-mvis4` + also sets :option:`-mvis3`, :option:`-mvis2` and :option:`-mvis`. + +.. option:: -mvis4b, -mno-vis4b + + With :option:`-mvis4b`, GCC generates code that takes advantage of + version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus + the additional VIS instructions introduced in the Oracle SPARC + Architecture 2017. The default is :option:`-mvis4b` when targeting a + cpu that supports such instructions, such as m8 and later. Setting + :option:`-mvis4b` also sets :option:`-mvis4`, :option:`-mvis3`, + :option:`-mvis2` and :option:`-mvis`. + +.. option:: -mcbcond, -mno-cbcond + + With :option:`-mcbcond`, GCC generates code that takes advantage of the UltraSPARC + Compare-and-Branch-on-Condition instructions. The default is :option:`-mcbcond` + when targeting a CPU that supports such instructions, such as Niagara-4 and + later. + +.. option:: -mfmaf, -mno-fmaf + + With :option:`-mfmaf`, GCC generates code that takes advantage of the UltraSPARC + Fused Multiply-Add Floating-point instructions. The default is :option:`-mfmaf` + when targeting a CPU that supports such instructions, such as Niagara-3 and + later. + +.. option:: -mfsmuld, -mno-fsmuld + + With :option:`-mfsmuld`, GCC generates code that takes advantage of the + Floating-point Multiply Single to Double (FsMULd) instruction. The default is + :option:`-mfsmuld` when targeting a CPU supporting the architecture versions V8 + or V9 with FPU except :option:`-mcpu=leon`. + +.. option:: -mpopc, -mno-popc + + With :option:`-mpopc`, GCC generates code that takes advantage of the UltraSPARC + Population Count instruction. The default is :option:`-mpopc` + when targeting a CPU that supports such an instruction, such as Niagara-2 and + later. + +.. option:: -msubxc, -mno-subxc + + With :option:`-msubxc`, GCC generates code that takes advantage of the UltraSPARC + Subtract-Extended-with-Carry instruction. The default is :option:`-msubxc` + when targeting a CPU that supports such an instruction, such as Niagara-7 and + later. + +.. option:: -mfix-at697f + + Enable the documented workaround for the single erratum of the Atmel AT697F + processor (which corresponds to erratum #13 of the AT697E processor). + +.. option:: -mfix-ut699 + + Enable the documented workarounds for the floating-point errata and the data + cache nullify errata of the UT699 processor. + +.. option:: -mfix-ut700 + + Enable the documented workaround for the back-to-back store errata of + the UT699E/UT700 processor. + +.. option:: -mfix-gr712rc + + Enable the documented workaround for the back-to-back store errata of + the GR712RC processor. + +These :samp:`-m` options are supported in addition to the above +on SPARC-V9 processors in 64-bit environments: + +.. option:: -m32, -m64 + + Generate code for a 32-bit or 64-bit environment. + The 32-bit environment sets int, long and pointer to 32 bits. + The 64-bit environment sets int to 32 bits and long and pointer + to 64 bits. + +.. option:: -mcmodel={which} + + Set the code model to one of + + :samp:`medlow` + The Medium/Low code model: 64-bit addresses, programs + must be linked in the low 32 bits of memory. Programs can be statically + or dynamically linked. + + :samp:`medmid` + The Medium/Middle code model: 64-bit addresses, programs + must be linked in the low 44 bits of memory, the text and data segments must + be less than 2GB in size and the data segment must be located within 2GB of + the text segment. + + :samp:`medany` + The Medium/Anywhere code model: 64-bit addresses, programs + may be linked anywhere in memory, the text and data segments must be less + than 2GB in size and the data segment must be located within 2GB of the + text segment. + + :samp:`embmedany` + The Medium/Anywhere code model for embedded systems: + 64-bit addresses, the text and data segments must be less than 2GB in + size, both starting anywhere in memory (determined at link time). The + global register %g4 points to the base of the data segment. Programs + are statically linked and PIC is not supported. + +.. option:: -mmemory-model={mem-model} + + Set the memory model in force on the processor to one of + + :samp:`default` + The default memory model for the processor and operating system. + + :samp:`rmo` + Relaxed Memory Order + + :samp:`pso` + Partial Store Order + + :samp:`tso` + Total Store Order + + :samp:`sc` + Sequential Consistency + + These memory models are formally defined in Appendix D of the SPARC-V9 + architecture manual, as set in the processor's ``PSTATE.MM`` field. + +.. option:: -mstack-bias, -mno-stack-bias + + With :option:`-mstack-bias`, GCC assumes that the stack pointer, and + frame pointer if present, are offset by -2047 which must be added back + when making stack frame references. This is the default in 64-bit mode. + Otherwise, assume no such offset is present. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/v850-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/v850-options.rst new file mode 100644 index 00000000000..e6bf936ed24 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/v850-options.rst @@ -0,0 +1,207 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: V850 + +.. index:: V850 Options + +.. _v850-options: + +V850 Options +^^^^^^^^^^^^ + +These :samp:`-m` options are defined for V850 implementations: + +.. option:: -mlong-calls, -mno-long-calls + + Treat all calls as being far away (near). If calls are assumed to be + far away, the compiler always loads the function's address into a + register, and calls indirect through the pointer. + +.. option:: -mno-ep, -mep + + Do not optimize (do optimize) basic blocks that use the same index + pointer 4 or more times to copy pointer into the ``ep`` register, and + use the shorter ``sld`` and ``sst`` instructions. The :option:`-mep` + option is on by default if you optimize. + +.. option:: -mno-prolog-function, -mprolog-function + + Do not use (do use) external functions to save and restore registers + at the prologue and epilogue of a function. The external functions + are slower, but use less code space if more than one function saves + the same number of registers. The :option:`-mprolog-function` option + is on by default if you optimize. + +.. option:: -mspace + + Try to make the code as small as possible. At present, this just turns + on the :option:`-mep` and :option:`-mprolog-function` options. + +.. option:: -mtda={n} + + Put static or global variables whose size is :samp:`{n}` bytes or less into + the tiny data area that register ``ep`` points to. The tiny data + area can hold up to 256 bytes in total (128 bytes for byte references). + +.. option:: -msda={n} + + Put static or global variables whose size is :samp:`{n}` bytes or less into + the small data area that register ``gp`` points to. The small data + area can hold up to 64 kilobytes. + +.. option:: -mzda={n} + + Put static or global variables whose size is :samp:`{n}` bytes or less into + the first 32 kilobytes of memory. + +.. option:: -mv850 + + Specify that the target processor is the V850. + +.. option:: -mv850e3v5 + + Specify that the target processor is the V850E3V5. The preprocessor + constant ``__v850e3v5__`` is defined if this option is used. + +.. option:: -mv850e2v4 + + Specify that the target processor is the V850E3V5. This is an alias for + the :option:`-mv850e3v5` option. + +.. option:: -mv850e2v3 + + Specify that the target processor is the V850E2V3. The preprocessor + constant ``__v850e2v3__`` is defined if this option is used. + +.. option:: -mv850e2 + + Specify that the target processor is the V850E2. The preprocessor + constant ``__v850e2__`` is defined if this option is used. + +.. option:: -mv850e1 + + Specify that the target processor is the V850E1. The preprocessor + constants ``__v850e1__`` and ``__v850e__`` are defined if + this option is used. + +.. option:: -mv850es + + Specify that the target processor is the V850ES. This is an alias for + the :option:`-mv850e1` option. + +.. option:: -mv850e + + Specify that the target processor is the V850E. The preprocessor + constant ``__v850e__`` is defined if this option is used. + + If neither :option:`-mv850` nor :option:`-mv850e` nor :option:`-mv850e1` + nor :option:`-mv850e2` nor :option:`-mv850e2v3` nor :option:`-mv850e3v5` + are defined then a default target processor is chosen and the + relevant :samp:`__v850*__` preprocessor constant is defined. + + The preprocessor constants ``__v850`` and ``__v851__`` are always + defined, regardless of which processor variant is the target. + +.. option:: -mdisable-callt, -mno-disable-callt + + This option suppresses generation of the ``CALLT`` instruction for the + v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850 + architecture. + + This option is enabled by default when the RH850 ABI is + in use (see :option:`-mrh850-abi`), and disabled by default when the + GCC ABI is in use. If ``CALLT`` instructions are being generated + then the C preprocessor symbol ``__V850_CALLT__`` is defined. + +.. option:: -mrelax, -mno-relax + + Pass on (or do not pass on) the :option:`-mrelax` command-line option + to the assembler. + +.. option:: -mlong-jumps, -mno-long-jumps + + Disable (or re-enable) the generation of PC-relative jump instructions. + +.. option:: -msoft-float, -mhard-float + + Disable (or re-enable) the generation of hardware floating point + instructions. This option is only significant when the target + architecture is :samp:`V850E2V3` or higher. If hardware floating point + instructions are being generated then the C preprocessor symbol + ``__FPU_OK__`` is defined, otherwise the symbol + ``__NO_FPU__`` is defined. + +.. option:: -mloop + + Enables the use of the e3v5 LOOP instruction. The use of this + instruction is not enabled by default when the e3v5 architecture is + selected because its use is still experimental. + +.. option:: -mrh850-abi, -mghs + + Enables support for the RH850 version of the V850 ABI. This is the + default. With this version of the ABI the following rules apply: + + * Integer sized structures and unions are returned via a memory pointer + rather than a register. + + * Large structures and unions (more than 8 bytes in size) are passed by + value. + + * Functions are aligned to 16-bit boundaries. + + * The :option:`-m8byte-align` command-line option is supported. + + * The :option:`-mdisable-callt` command-line option is enabled by + default. The :option:`-mno-disable-callt` command-line option is not + supported. + + When this version of the ABI is enabled the C preprocessor symbol + ``__V850_RH850_ABI__`` is defined. + +.. option:: -mgcc-abi + + Enables support for the old GCC version of the V850 ABI. With this + version of the ABI the following rules apply: + + * Integer sized structures and unions are returned in register ``r10``. + + * Large structures and unions (more than 8 bytes in size) are passed by + reference. + + * Functions are aligned to 32-bit boundaries, unless optimizing for + size. + + * The :option:`-m8byte-align` command-line option is not supported. + + * The :option:`-mdisable-callt` command-line option is supported but not + enabled by default. + + When this version of the ABI is enabled the C preprocessor symbol + ``__V850_GCC_ABI__`` is defined. + +.. option:: -m8byte-align, -mno-8byte-align + + Enables support for ``double`` and ``long long`` types to be + aligned on 8-byte boundaries. The default is to restrict the + alignment of all objects to at most 4-bytes. When + :option:`-m8byte-align` is in effect the C preprocessor symbol + ``__V850_8BYTE_ALIGN__`` is defined. + +.. option:: -mbig-switch + + Generate code suitable for big switch tables. Use this option only if + the assembler/linker complain about out of range branches within a switch + table. + +.. option:: -mapp-regs + + This option causes r2 and r5 to be used in the code generated by + the compiler. This setting is the default. + +.. option:: -mno-app-regs + + This option causes r2 and r5 to be treated as fixed registers. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/vax-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/vax-options.rst new file mode 100644 index 00000000000..d6041686df9 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/vax-options.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: VAX + +.. index:: VAX options + +.. _vax-options: + +VAX Options +^^^^^^^^^^^ + +These :samp:`-m` options are defined for the VAX: + +.. option:: -munix + + Do not output certain jump instructions (``aobleq`` and so on) + that the Unix assembler for the VAX cannot handle across long + ranges. + +.. option:: -mgnu + + Do output those jump instructions, on the assumption that the + GNU assembler is being used. + +.. option:: -mg + + Output code for G-format floating-point numbers instead of D-format. + +.. option:: -mlra, -mno-lra + + Enable Local Register Allocation. This is still experimental for the VAX, + so by default the compiler uses standard reload. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/visium-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/visium-options.rst new file mode 100644 index 00000000000..17459253ea4 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/visium-options.rst @@ -0,0 +1,73 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: Visium + +.. index:: Visium options + +.. _visium-options: + +Visium Options +^^^^^^^^^^^^^^ + +.. option:: -mdebug + + A program which performs file I/O and is destined to run on an MCM target + should be linked with this option. It causes the libraries libc.a and + libdebug.a to be linked. The program should be run on the target under + the control of the GDB remote debugging stub. + +.. option:: -msim + + A program which performs file I/O and is destined to run on the simulator + should be linked with option. This causes libraries libc.a and libsim.a to + be linked. + +.. option:: -mfpu, -mhard-float + + Generate code containing floating-point instructions. This is the + default. + +.. option:: -mno-fpu, -msoft-float + + Generate code containing library calls for floating-point. + + :option:`-msoft-float` changes the calling convention in the output file; + therefore, it is only useful if you compile *all* of a program with + this option. In particular, you need to compile :samp:`libgcc.a`, the + library that comes with GCC, with :option:`-msoft-float` in order for + this to work. + +.. option:: -mcpu={cpu_type} + + Set the instruction set, register set, and instruction scheduling parameters + for machine type :samp:`{cpu_type}`. Supported values for :samp:`{cpu_type}` are + :samp:`mcm`, :samp:`gr5` and :samp:`gr6`. + + :samp:`mcm` is a synonym of :samp:`gr5` present for backward compatibility. + + By default (unless configured otherwise), GCC generates code for the GR5 + variant of the Visium architecture. + + With :option:`-mcpu=gr6`, GCC generates code for the GR6 variant of the Visium + architecture. The only difference from GR5 code is that the compiler will + generate block move instructions. + +.. option:: -mtune={cpu_type} + + Set the instruction scheduling parameters for machine type :samp:`{cpu_type}`, + but do not set the instruction set or register set that the option + :option:`-mcpu=cpu_type` would. + +.. option:: -msv-mode + + Generate code for the supervisor mode, where there are no restrictions on + the access to general registers. This is the default. + +.. option:: -muser-mode + + Generate code for the user mode, where the access to some general registers + is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this + mode; on the GR6, only registers r29 to r31 are affected. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/vms-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/vms-options.rst new file mode 100644 index 00000000000..d0d8120597c --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/vms-options.rst @@ -0,0 +1,38 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: VMS + +.. _vms-options: + +VMS Options +^^^^^^^^^^^ + +These :samp:`-m` options are defined for the VMS implementations: + +.. option:: -mvms-return-codes + + Return VMS condition codes from ``main``. The default is to return POSIX-style + condition (e.g. error) codes. + +.. index:: mdebug-main=prefix + +.. option:: -mdebug-main={prefix} + + Flag the first routine whose name starts with :samp:`{prefix}` as the main + routine for the debugger. + +.. option:: -mmalloc64 + + Default to 64-bit memory allocation routines. + +.. index:: mpointer-size=size + +.. option:: -mpointer-size={size} + + Set the default size of pointers. Possible options for :samp:`{size}` are + :samp:`32` or :samp:`short` for 32 bit pointers, :samp:`64` or :samp:`long` + for 64 bit pointers, and :samp:`no` for supporting only 32 bit pointers. + The later option disables ``pragma pointer_size``. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/vxworks-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/vxworks-options.rst new file mode 100644 index 00000000000..8c79f5c4798 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/vxworks-options.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: VxWorks + +.. index:: VxWorks Options + +.. _vxworks-options: + +VxWorks Options +^^^^^^^^^^^^^^^ + +The options in this section are defined for all VxWorks targets. +Options specific to the target hardware are listed with the other +options for that target. + +.. option:: -mrtp + + GCC can generate code for both VxWorks kernels and real time processes + (RTPs). This option switches from the former to the latter. It also + defines the preprocessor macro ``__RTP__``. + +.. option:: -non-static + + Link an RTP executable against shared libraries rather than static + libraries. The options :option:`-static` and :option:`-shared` can + also be used for RTPs (see :ref:`link-options`); :option:`-static` + is the default. + +.. option:: -Bstatic, -Bdynamic + + These options are passed down to the linker. They are defined for + compatibility with Diab. + +.. option:: -Xbind-lazy + + Enable lazy binding of function calls. This option is equivalent to + :option:`-Wl,-z,now` and is defined for compatibility with Diab. + +.. option:: -Xbind-now + + Disable lazy binding of function calls. This option is the default and + is defined for compatibility with Diab. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/x86-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/x86-options.rst new file mode 100644 index 00000000000..7e784eb9a07 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/x86-options.rst @@ -0,0 +1,1620 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: x86 + +.. index:: x86 Options + +.. _x86-options: + +x86 Options +^^^^^^^^^^^ + +These :samp:`-m` options are defined for the x86 family of computers. + +.. option:: -march={cpu-type} + + Generate instructions for the machine type :samp:`{cpu-type}`. In contrast to + :option:`-mtune=cpu-type`, which merely tunes the generated code + for the specified :samp:`{cpu-type}`, :option:`-march=cpu-type` allows GCC + to generate code that may not run at all on processors other than the one + indicated. Specifying :option:`-march=cpu-type` implies + :option:`-mtune=cpu-type`, except where noted otherwise. + + The choices for :samp:`{cpu-type}` are: + + :samp:`native` + This selects the CPU to generate code for at compilation time by determining + the processor type of the compiling machine. Using :option:`-march=native` + enables all instruction subsets supported by the local machine (hence + the result might not run on different machines). Using :option:`-mtune=native` + produces code optimized for the local machine under the constraints + of the selected instruction set. + + :samp:`x86-64` + A generic CPU with 64-bit extensions. + + :samp:`x86-64-v2` :samp:`x86-64-v3` :samp:`x86-64-v4` + These choices for :samp:`{cpu-type}` select the corresponding + micro-architecture level from the x86-64 psABI. On ABIs other than + the x86-64 psABI they select the same CPU features as the x86-64 psABI + documents for the particular micro-architecture level. + + Since these :samp:`{cpu-type}` values do not have a corresponding + :option:`-mtune` setting, using :option:`-march` with these values enables + generic tuning. Specific tuning can be enabled using the + :option:`-mtune=other-cpu-type` option with an appropriate + :samp:`{other-cpu-type}` value. + + :samp:`i386` + Original Intel i386 CPU. + + :samp:`i486` + Intel i486 CPU. (No scheduling is implemented for this chip.) + + :samp:`i586` :samp:`pentium` + Intel Pentium CPU with no MMX support. + + :samp:`lakemont` + Intel Lakemont MCU, based on Intel Pentium CPU. + + :samp:`pentium-mmx` + Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support. + + :samp:`pentiumpro` + Intel Pentium Pro CPU. + + :samp:`i686` + When used with :option:`-march`, the Pentium Pro + instruction set is used, so the code runs on all i686 family chips. + When used with :option:`-mtune`, it has the same meaning as :samp:`generic`. + + :samp:`pentium2` + Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction + set support. + + :samp:`pentium3` :samp:`pentium3m` + Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE + instruction set support. + + :samp:`pentium-m` + Intel Pentium M; low-power version of Intel Pentium III CPU + with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino + notebooks. + + :samp:`pentium4` :samp:`pentium4m` + Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support. + + :samp:`prescott` + Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR + instruction set support. + + :samp:`nocona` + Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE, + SSE2, SSE3 and FXSR instruction set support. + + :samp:`core2` + Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16, + SAHF and FXSR instruction set support. + + :samp:`nehalem` + Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support. + + :samp:`westmere` + Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support. + + :samp:`sandybridge` + Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set + support. + + :samp:`ivybridge` + Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND + and F16C instruction set support. + + :samp:`haswell` + Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, + F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support. + + :samp:`broadwell` + Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, + F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW + instruction set support. + + :samp:`skylake` + Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, + F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, + CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support. + + :samp:`bonnell` + Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3 + instruction set support. + + :samp:`silvermont` + Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND + instruction set support. + + :samp:`goldmont` + Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, + RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction + set support. + + :samp:`goldmont-plus` + Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, + SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, + SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, + RDPID and SGX instruction set support. + + :samp:`tremont` + Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, + RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID, + SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set + support. + + :samp:`sierraforest` + Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, + SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, + XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, + MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, + PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, + AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support. + + :samp:`grandridge` + Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, + SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, + XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, + MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, + PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, + AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD and RAOINT instruction set + support. + + :samp:`knl` + Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, + SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, + RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, + AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support. + + :samp:`knm` + Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, + SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, + RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, + AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW, + AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support. + + :samp:`skylake-avx512` + Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, + SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, + RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, + AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, + AVX512DQ and AVX512CD instruction set support. + + :samp:`cannonlake` + Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, + SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, + FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, + PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, + AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set + support. + + :samp:`icelake-client` + Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, + SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, + RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, + AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, + AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 + , VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. + + :samp:`icelake-server` + Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, + SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, + RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, + AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, + AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 + , VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB + instruction set support. + + :samp:`cascadelake` + Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, + F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, + CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, + AVX512CD and AVX512VNNI instruction set support. + + :samp:`cooperlake` + Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, + F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, + CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, + AVX512CD, AVX512VNNI and AVX512BF16 instruction set support. + + :samp:`tigerlake` + Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, + F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, + CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD + PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, + VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB, + AVX512VP2INTERSECT and KEYLOCKER instruction set support. + + :samp:`sapphirerapids` + Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, + SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, + RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, + AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, + AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, + VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, + MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, + UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16 and AVX512BF16 + instruction set support. + + :samp:`alderlake` + Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES, + XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B, + CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU, + VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set + support. + + :samp:`rocketlake` + Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3 + , SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, + F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, + CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD + PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, + VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. + + :samp:`graniterapids` + Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, + SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, + RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, + AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, + AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, + VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, + MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, + SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, + AVX512BF16, AMX-FP16 and PREFETCHI instruction set support. + + :samp:`k6` + AMD K6 CPU with MMX instruction set support. + + :samp:`k6-2` :samp:`k6-3` + Improved versions of AMD K6 CPU with MMX and 3DNow! instruction set support. + + :samp:`athlon` :samp:`athlon-tbird` + AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow! and SSE prefetch instructions + support. + + :samp:`athlon-4` :samp:`athlon-xp` :samp:`athlon-mp` + Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow! and full SSE + instruction set support. + + :samp:`k8` :samp:`opteron` :samp:`athlon64` :samp:`athlon-fx` + Processors based on the AMD K8 core with x86-64 instruction set support, + including the AMD Opteron, Athlon 64, and Athlon 64 FX processors. + (This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow! and 64-bit + instruction set extensions.) + + :samp:`k8-sse3` :samp:`opteron-sse3` :samp:`athlon64-sse3` + Improved versions of AMD K8 cores with SSE3 instruction set support. + + :samp:`amdfam10` :samp:`barcelona` + CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This + supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit + instruction set extensions.) + + :samp:`bdver1` + CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This + supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, + SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.) + + :samp:`bdver2` + AMD Family 15h core based CPUs with x86-64 instruction set support. (This + supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, + SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set + extensions.) + + :samp:`bdver3` + AMD Family 15h core based CPUs with x86-64 instruction set support. (This + supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES, + PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and + 64-bit instruction set extensions.) + + :samp:`bdver4` + AMD Family 15h core based CPUs with x86-64 instruction set support. (This + supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP, + AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, + SSE4.2, ABM and 64-bit instruction set extensions.) + + :samp:`znver1` + AMD Family 17h core based CPUs with x86-64 instruction set support. (This + supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX, + SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, + SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit + instruction set extensions.) + + :samp:`znver2` + AMD Family 17h core based CPUs with x86-64 instruction set support. (This + supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, + MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, + SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, + WBNOINVD, and 64-bit instruction set extensions.) + + :samp:`znver3` + AMD Family 19h core based CPUs with x86-64 instruction set support. (This + supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, + MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, + SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, + WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.) + + :samp:`znver4` + AMD Family 19h core based CPUs with x86-64 instruction set support. (This + supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, + MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, + SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, + WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD, + AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI, + AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.) + + :samp:`btver1` + CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This + supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit + instruction set extensions.) + + :samp:`btver2` + CPUs based on AMD Family 16h cores with x86-64 instruction set support. This + includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM, + SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions. + + :samp:`winchip-c6` + IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction + set support. + + :samp:`winchip2` + IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow! + instruction set support. + + :samp:`c3` + VIA C3 CPU with MMX and 3DNow! instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`c3-2` + VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`c7` + VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`samuel-2` + VIA Eden Samuel 2 CPU with MMX and 3DNow! instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`nehemiah` + VIA Eden Nehemiah CPU with MMX and SSE instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`esther` + VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`eden-x2` + VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`eden-x4` + VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, + AVX and AVX2 instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`nano` + Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 + instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`nano-1000` + VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 + instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`nano-2000` + VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 + instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`nano-3000` + VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 + instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`nano-x2` + VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 + instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`nano-x4` + VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 + instruction set support. + (No scheduling is implemented for this chip.) + + :samp:`lujiazui` + ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, + SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16, + ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support. + + :samp:`geode` + AMD Geode embedded processor with MMX and 3DNow! instruction set support. + +.. option:: -mtune={cpu-type} + + Tune to :samp:`{cpu-type}` everything applicable about the generated code, except + for the ABI and the set of available instructions. + While picking a specific :samp:`{cpu-type}` schedules things appropriately + for that particular chip, the compiler does not generate any code that + cannot run on the default machine type unless you use a + :option:`-march=cpu-type` option. + For example, if GCC is configured for i686-pc-linux-gnu + then :option:`-mtune=pentium4` generates code that is tuned for Pentium 4 + but still runs on i686 machines. + + The choices for :samp:`{cpu-type}` are the same as for :option:`-march`. + In addition, :option:`-mtune` supports 2 extra choices for :samp:`{cpu-type}` : + + :samp:`generic` + Produce code optimized for the most common IA32/AMD64/EM64T processors. + If you know the CPU on which your code will run, then you should use + the corresponding :option:`-mtune` or :option:`-march` option instead of + :option:`-mtune=generic`. But, if you do not know exactly what CPU users + of your application will have, then you should use this option. + + As new processors are deployed in the marketplace, the behavior of this + option will change. Therefore, if you upgrade to a newer version of + GCC, code generation controlled by this option will change to reflect + the processors + that are most common at the time that version of GCC is released. + + There is no :option:`-march=generic` option because :option:`-march` + indicates the instruction set the compiler can use, and there is no + generic instruction set applicable to all processors. In contrast, + :option:`-mtune` indicates the processor (or, in this case, collection of + processors) for which the code is optimized. + + :samp:`intel` + Produce code optimized for the most current Intel processors, which are + Haswell and Silvermont for this version of GCC. If you know the CPU + on which your code will run, then you should use the corresponding + :option:`-mtune` or :option:`-march` option instead of :option:`-mtune=intel`. + But, if you want your application performs better on both Haswell and + Silvermont, then you should use this option. + + As new Intel processors are deployed in the marketplace, the behavior of + this option will change. Therefore, if you upgrade to a newer version of + GCC, code generation controlled by this option will change to reflect + the most current Intel processors at the time that version of GCC is + released. + + There is no :option:`-march=intel` option because :option:`-march` indicates + the instruction set the compiler can use, and there is no common + instruction set applicable to all processors. In contrast, + :option:`-mtune` indicates the processor (or, in this case, collection of + processors) for which the code is optimized. + +.. option:: -mcpu={cpu-type} + + A deprecated synonym for :option:`-mtune`. + +.. option:: -mfpmath={unit} + + Generate floating-point arithmetic for selected unit :samp:`{unit}`. The choices + for :samp:`{unit}` are: + + :samp:`387` + Use the standard 387 floating-point coprocessor present on the majority of chips and + emulated otherwise. Code compiled with this option runs almost everywhere. + The temporary results are computed in 80-bit precision instead of the precision + specified by the type, resulting in slightly different results compared to most + of other chips. See :option:`-ffloat-store` for more detailed description. + + This is the default choice for non-Darwin x86-32 targets. + + :samp:`sse` + Use scalar floating-point instructions present in the SSE instruction set. + This instruction set is supported by Pentium III and newer chips, + and in the AMD line + by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE + instruction set supports only single-precision arithmetic, thus the double and + extended-precision arithmetic are still done using 387. A later version, present + only in Pentium 4 and AMD x86-64 chips, supports double-precision + arithmetic too. + + For the x86-32 compiler, you must use :option:`-march=cpu-type`, :option:`-msse` + or :option:`-msse2` switches to enable SSE extensions and make this option + effective. For the x86-64 compiler, these extensions are enabled by default. + + The resulting code should be considerably faster in the majority of cases and avoid + the numerical instability problems of 387 code, but may break some existing + code that expects temporaries to be 80 bits. + + This is the default choice for the x86-64 compiler, Darwin x86-32 targets, + and the default choice for x86-32 targets with the SSE2 instruction set + when :option:`-ffast-math` is enabled. + + :samp:`sse,387` :samp:`sse+387` :samp:`both` + Attempt to utilize both instruction sets at once. This effectively doubles the + amount of available registers, and on chips with separate execution units for + 387 and SSE the execution resources too. Use this option with care, as it is + still experimental, because the GCC register allocator does not model separate + functional units well, resulting in unstable performance. + +.. index:: masm=dialect + +.. option:: -masm={dialect} + + Output assembly instructions using selected :samp:`{dialect}`. Also affects + which dialect is used for basic ``asm`` (see :ref:`basic-asm`) and + extended ``asm`` (see :ref:`extended-asm`). Supported choices (in dialect + order) are :samp:`att` or :samp:`intel`. The default is :samp:`att`. Darwin does + not support :samp:`intel`. + +.. option:: -mieee-fp, -mno-ieee-fp + + Control whether or not the compiler uses IEEE floating-point + comparisons. These correctly handle the case where the result of a + comparison is unordered. + +.. option:: -m80387, -mhard-float + + Generate output containing 80387 instructions for floating point. + +.. option:: -mno-80387, -msoft-float + + Generate output containing library calls for floating point. + + .. warning:: + + The requisite libraries are not part of GCC. + Normally the facilities of the machine's usual C compiler are used, but + this cannot be done directly in cross-compilation. You must make your + own arrangements to provide suitable library functions for + cross-compilation. + + On machines where a function returns floating-point results in the 80387 + register stack, some floating-point opcodes may be emitted even if + :option:`-msoft-float` is used. + +.. option:: -mno-fp-ret-in-387 + + Do not use the FPU registers for return values of functions. + + The usual calling convention has functions return values of types + ``float`` and ``double`` in an FPU register, even if there + is no FPU. The idea is that the operating system should emulate + an FPU. + + The option :option:`-mno-fp-ret-in-387` causes such values to be returned + in ordinary CPU registers instead. + +.. option:: -mfp-ret-in-387 + + Default setting; overrides :option:`-mno-fp-ret-in-387`. + +.. option:: -mno-fancy-math-387 + + Some 387 emulators do not support the ``sin``, ``cos`` and + ``sqrt`` instructions for the 387. Specify this option to avoid + generating those instructions. + This option is overridden when :option:`-march` + indicates that the target CPU always has an FPU and so the + instruction does not need emulation. These + instructions are not generated unless you also use the + :option:`-funsafe-math-optimizations` switch. + +.. option:: -mfancy-math-387 + + Default setting; overrides :option:`-mno-fancy-math-387`. + +.. option:: -malign-double, -mno-align-double + + Control whether GCC aligns ``double``, ``long double``, and + ``long long`` variables on a two-word boundary or a one-word + boundary. Aligning ``double`` variables on a two-word boundary + produces code that runs somewhat faster on a Pentium at the + expense of more memory. + + On x86-64, :option:`-malign-double` is enabled by default. + + .. warning:: + + If you use the :option:`-malign-double` switch, + structures containing the above types are aligned differently than + the published application binary interface specifications for the x86-32 + and are not binary compatible with structures in code compiled + without that switch. + +.. option:: -m96bit-long-double, -m128bit-long-double + + These switches control the size of ``long double`` type. The x86-32 + application binary interface specifies the size to be 96 bits, + so :option:`-m96bit-long-double` is the default in 32-bit mode. + + Modern architectures (Pentium and newer) prefer ``long double`` + to be aligned to an 8- or 16-byte boundary. In arrays or structures + conforming to the ABI, this is not possible. So specifying + :option:`-m128bit-long-double` aligns ``long double`` + to a 16-byte boundary by padding the ``long double`` with an additional + 32-bit zero. + + In the x86-64 compiler, :option:`-m128bit-long-double` is the default choice as + its ABI specifies that ``long double`` is aligned on 16-byte boundary. + + Notice that neither of these options enable any extra precision over the x87 + standard of 80 bits for a ``long double``. + + .. warning:: + + If you override the default value for your target ABI, this + changes the size of + structures and arrays containing ``long double`` variables, + as well as modifying the function calling convention for functions taking + ``long double``. Hence they are not binary-compatible + with code compiled without that switch. + +.. option:: -mlong-double-64, -mlong-double-80, -mlong-double-128 + + These switches control the size of ``long double`` type. A size + of 64 bits makes the ``long double`` type equivalent to the ``double`` + type. This is the default for 32-bit Bionic C library. A size + of 128 bits makes the ``long double`` type equivalent to the + ``__float128`` type. This is the default for 64-bit Bionic C library. + + .. warning:: + + If you override the default value for your target ABI, this + changes the size of + structures and arrays containing ``long double`` variables, + as well as modifying the function calling convention for functions taking + ``long double``. Hence they are not binary-compatible + with code compiled without that switch. + +.. option:: -malign-data={type} + + Control how GCC aligns variables. Supported values for :samp:`{type}` are + :samp:`compat` uses increased alignment value compatible uses GCC 4.8 + and earlier, :samp:`abi` uses alignment value as specified by the + psABI, and :samp:`cacheline` uses increased alignment value to match + the cache line size. :samp:`compat` is the default. + +.. option:: -mlarge-data-threshold={threshold} + + When :option:`-mcmodel=medium` is specified, data objects larger than + :samp:`{threshold}` are placed in the large data section. This value must be the + same across all objects linked into the binary, and defaults to 65535. + +.. option:: -mrtd + + Use a different function-calling convention, in which functions that + take a fixed number of arguments return with the ``ret num`` + instruction, which pops their arguments while returning. This saves one + instruction in the caller since there is no need to pop the arguments + there. + + You can specify that an individual function is called with this calling + sequence with the function attribute :x86-fn-attr:`stdcall`. You can also + override the :option:`-mrtd` option by using the function attribute + ``cdecl``. See :ref:`function-attributes`. + + .. warning:: + + This calling convention is incompatible with the one + normally used on Unix, so you cannot use it if you need to call + libraries compiled with the Unix compiler. + + Also, you must provide function prototypes for all functions that + take variable numbers of arguments (including ``printf``); + otherwise incorrect code is generated for calls to those + functions. + + In addition, seriously incorrect code results if you call a + function with too many arguments. (Normally, extra arguments are + harmlessly ignored.) + +.. option:: -mregparm={num} + + Control how many registers are used to pass integer arguments. By + default, no registers are used to pass arguments, and at most 3 + registers can be used. You can control this behavior for a specific + function by using the function attribute ``regparm``. + See :ref:`function-attributes`. + + .. warning:: + + If you use this switch, and + :samp:`{num}` is nonzero, then you must build all modules with the same + value, including any libraries. This includes the system libraries and + startup modules. + +.. option:: -msseregparm + + Use SSE register passing conventions for float and double arguments + and return values. You can control this behavior for a specific + function by using the function attribute :x86-fn-attr:`sseregparm`. + See :ref:`function-attributes`. + + .. warning:: + + If you use this switch then you must build all + modules with the same value, including any libraries. This includes + the system libraries and startup modules. + +.. option:: -mvect8-ret-in-mem + + Return 8-byte vectors in memory instead of MMX registers. This is the + default on VxWorks to match the ABI of the Sun Studio compilers until + version 12. *Only* use this option if you need to remain + compatible with existing code produced by those previous compiler + versions or older versions of GCC. + +.. option:: -mpc32, -mpc64, -mpc80 + + Set 80387 floating-point precision to 32, 64 or 80 bits. When :option:`-mpc32` + is specified, the significands of results of floating-point operations are + rounded to 24 bits (single precision); :option:`-mpc64` rounds the + significands of results of floating-point operations to 53 bits (double + precision) and :option:`-mpc80` rounds the significands of results of + floating-point operations to 64 bits (extended double precision), which is + the default. When this option is used, floating-point operations in higher + precisions are not available to the programmer without setting the FPU + control word explicitly. + + Setting the rounding of floating-point operations to less than the default + 80 bits can speed some programs by 2% or more. Note that some mathematical + libraries assume that extended-precision (80-bit) floating-point operations + are enabled by default; routines in such libraries could suffer significant + loss of accuracy, typically through so-called 'catastrophic cancellation', + when this option is used to set the precision to less than extended precision. + +.. option:: -mstackrealign + + Realign the stack at entry. On the x86, the :option:`-mstackrealign` + option generates an alternate prologue and epilogue that realigns the + run-time stack if necessary. This supports mixing legacy codes that keep + 4-byte stack alignment with modern codes that keep 16-byte stack alignment for + SSE compatibility. See also the attribute :x86-fn-attr:`force_align_arg_pointer`, + applicable to individual functions. + +.. option:: -mpreferred-stack-boundary={num} + + Attempt to keep the stack boundary aligned to a 2 raised to :samp:`{num}` + byte boundary. If :option:`-mpreferred-stack-boundary` is not specified, + the default is 4 (16 bytes or 128 bits). + + .. warning:: + + When generating code for the x86-64 architecture with + SSE extensions disabled, :option:`-mpreferred-stack-boundary=3` can be + used to keep the stack boundary aligned to 8 byte boundary. Since + x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and + intended to be used in controlled environment where stack space is + important limitation. This option leads to wrong code when functions + compiled with 16 byte stack alignment (such as functions from a standard + library) are called with misaligned stack. In this case, SSE + instructions may lead to misaligned memory access traps. In addition, + variable arguments are handled incorrectly for 16 byte aligned + objects (including x87 long double and __int128), leading to wrong + results. You must build all modules with + :option:`-mpreferred-stack-boundary=3`, including any libraries. This + includes the system libraries and startup modules. + +.. option:: -mincoming-stack-boundary={num} + + Assume the incoming stack is aligned to a 2 raised to :samp:`{num}` byte + boundary. If :option:`-mincoming-stack-boundary` is not specified, + the one specified by :option:`-mpreferred-stack-boundary` is used. + + On Pentium and Pentium Pro, ``double`` and ``long double`` values + should be aligned to an 8-byte boundary (see :option:`-malign-double`) or + suffer significant run time performance penalties. On Pentium III, the + Streaming SIMD Extension (SSE) data type ``__m128`` may not work + properly if it is not 16-byte aligned. + + To ensure proper alignment of this values on the stack, the stack boundary + must be as aligned as that required by any value stored on the stack. + Further, every function must be generated such that it keeps the stack + aligned. Thus calling a function compiled with a higher preferred + stack boundary from a function compiled with a lower preferred stack + boundary most likely misaligns the stack. It is recommended that + libraries that use callbacks always use the default setting. + + This extra alignment does consume extra stack space, and generally + increases code size. Code that is sensitive to stack space usage, such + as embedded systems and operating system kernels, may want to reduce the + preferred alignment to :option:`-mpreferred-stack-boundary=2`. + +.. option:: -mmmx, -msse, -msse2, -msse3, -mssse3, -msse4, -msse4a, -msse4.1, -msse4.2, -mavx, -mavx2, -mavx512f, -mavx512pf, -mavx512er, -mavx512cd, -mavx512vl, -mavx512bw, -mavx512dq, -mavx512ifma, -mavx512vbmi, -msha, -maes, -mpclmul, -mclflushopt, -mclwb, -mfsgsbase, -mptwrite, -mrdrnd, -mf16c, -mfma, -mpconfig, -mwbnoinvd, -mfma4, -mprfchw, -mrdpid, -mprefetchwt1, -mrdseed, -msgx, -mxop, -mlwp, -m3dnow, -m3dnowa, -mpopcnt, -mabm, -madx, -mbmi, -mbmi2, -mlzcnt, -mfxsr, -mxsave, -mxsaveopt, -mxsavec, -mxsaves, -mrtm, -mhle, -mtbm, -mmwaitx, -mclzero, -mpku, -mavx512vbmi2, -mavx512bf16, -mavx512fp16, -mgfni, -mvaes, -mwaitpkg, -mvpclmulqdq, -mavx512bitalg, -mmovdiri, -mmovdir64b, -menqcmd, -muintr, -mtsxldtrk, -mavx512vpopcntdq, -mavx512vp2intersect, -mavx5124fmaps, -mavx512vnni, -mavxvnni, -mavx5124vnniw, -mcldemote, -mserialize, -mamx-tile, -mamx-int8, -mamx-bf16, -mhreset, -mkl, -mwidekl, -mavxifma, -mavxvnniint8, -mavxneconvert, -mcmpccxadd, -mamx-fp16, -mprefetchi, -mraoint + + These switches enable the use of instructions in the MMX, SSE, + SSE2, SSE3, SSSE3, SSE4, SSE4A, SSE4.1, SSE4.2, AVX, AVX2, AVX512F, AVX512PF, + AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA, + AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG, + WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP, + 3DNow!, enhanced 3DNow!, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE, + XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2, + GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16, + ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE, + UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512FP16, + AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT or + CLDEMOTE extended instruction sets. Each has a corresponding :option:`-mno-` + option to disable use of these instructions. + + These extensions are also available as built-in functions: see + :ref:`x86-built-in-functions`, for details of the functions enabled and + disabled by these switches. + + To generate SSE/SSE2 instructions automatically from floating-point + code (as opposed to 387 instructions), see :option:`-mfpmath=sse`. + + GCC depresses SSEx instructions when :option:`-mavx` is used. Instead, it + generates new AVX instructions or AVX equivalence for all SSEx instructions + when needed. + + These options enable GCC to use these extended instructions in + generated code, even without :option:`-mfpmath=sse`. Applications that + perform run-time CPU detection must compile separate files for each + supported architecture, using the appropriate flags. In particular, + the file containing the CPU detection code should be compiled without + these options. + +.. option:: -mdump-tune-features + + This option instructs GCC to dump the names of the x86 performance + tuning features and default settings. The names can be used in + :option:`-mtune-ctrl=feature-list`. + +.. index:: mtune-ctrl=feature-list + +.. option:: -mtune-ctrl={feature-list} + + This option is used to do fine grain control of x86 code generation features. + :samp:`{feature-list}` is a comma separated list of :samp:`{feature}` names. See also + :option:`-mdump-tune-features`. When specified, the :samp:`{feature}` is turned + on if it is not preceded with :samp:`^`, otherwise, it is turned off. + :option:`-mtune-ctrl=feature-list` is intended to be used by GCC + developers. Using it may lead to code paths not covered by testing and can + potentially result in compiler ICEs or runtime errors. + +.. option:: -mno-default + + This option instructs GCC to turn off all tunable features. See also + :option:`-mtune-ctrl=feature-list` and :option:`-mdump-tune-features`. + +.. option:: -mcld + + This option instructs GCC to emit a ``cld`` instruction in the prologue + of functions that use string instructions. String instructions depend on + the DF flag to select between autoincrement or autodecrement mode. While the + ABI specifies the DF flag to be cleared on function entry, some operating + systems violate this specification by not clearing the DF flag in their + exception dispatchers. The exception handler can be invoked with the DF flag + set, which leads to wrong direction mode when string instructions are used. + This option can be enabled by default on 32-bit x86 targets by configuring + GCC with the :option:`--enable-cld` configure option. Generation of ``cld`` + instructions can be suppressed with the :option:`-mno-cld` compiler option + in this case. + +.. option:: -mvzeroupper + + This option instructs GCC to emit a ``vzeroupper`` instruction + before a transfer of control flow out of the function to minimize + the AVX to SSE transition penalty as well as remove unnecessary ``zeroupper`` + intrinsics. + +.. option:: -mprefer-avx128 + + This option instructs GCC to use 128-bit AVX instructions instead of + 256-bit AVX instructions in the auto-vectorizer. + +.. option:: -mprefer-vector-width={opt} + + This option instructs GCC to use :samp:`{opt}` -bit vector width in instructions + instead of default on the selected platform. + +.. option:: -mmove-max={bits} + + This option instructs GCC to set the maximum number of bits can be + moved from memory to memory efficiently to :samp:`{bits}`. The valid + :samp:`{bits}` are 128, 256 and 512. + +.. option:: -mstore-max={bits} + + This option instructs GCC to set the maximum number of bits can be + stored to memory efficiently to :samp:`{bits}`. The valid :samp:`{bits}` are + 128, 256 and 512. + + :samp:`none` + No extra limitations applied to GCC other than defined by the selected platform. + + :samp:`128` + Prefer 128-bit vector width for instructions. + + :samp:`256` + Prefer 256-bit vector width for instructions. + + :samp:`512` + Prefer 512-bit vector width for instructions. + +.. option:: -mcx16 + + This option enables GCC to generate ``CMPXCHG16B`` instructions in 64-bit + code to implement compare-and-exchange operations on 16-byte aligned 128-bit + objects. This is useful for atomic updates of data structures exceeding one + machine word in size. The compiler uses this instruction to implement + :ref:`sync-builtins`. However, for :ref:`atomic-builtins` operating on + 128-bit integers, a library call is always used. + +.. option:: -msahf + + This option enables generation of ``SAHF`` instructions in 64-bit code. + Early Intel Pentium 4 CPUs with Intel 64 support, + prior to the introduction of Pentium 4 G1 step in December 2005, + lacked the ``LAHF`` and ``SAHF`` instructions + which are supported by AMD64. + These are load and store instructions, respectively, for certain status flags. + In 64-bit mode, the ``SAHF`` instruction is used to optimize ``fmod``, + ``drem``, and ``remainder`` built-in functions; + see :ref:`other-builtins` for details. + +.. option:: -mmovbe + + This option enables use of the ``movbe`` instruction to implement + ``__builtin_bswap32`` and ``__builtin_bswap64``. + +.. option:: -mshstk + + The :option:`-mshstk` option enables shadow stack built-in functions + from x86 Control-flow Enforcement Technology (CET). + +.. option:: -mcrc32 + + This option enables built-in functions ``__builtin_ia32_crc32qi``, + ``__builtin_ia32_crc32hi``, ``__builtin_ia32_crc32si`` and + ``__builtin_ia32_crc32di`` to generate the ``crc32`` machine instruction. + +.. option:: -mmwait + + This option enables built-in functions ``__builtin_ia32_monitor``, + and ``__builtin_ia32_mwait`` to generate the ``monitor`` and + ``mwait`` machine instructions. + +.. option:: -mrecip + + This option enables use of ``RCPSS`` and ``RSQRTSS`` instructions + (and their vectorized variants ``RCPPS`` and ``RSQRTPS``) + with an additional Newton-Raphson step + to increase precision instead of ``DIVSS`` and ``SQRTSS`` + (and their vectorized + variants) for single-precision floating-point arguments. These instructions + are generated only when :option:`-funsafe-math-optimizations` is enabled + together with :option:`-ffinite-math-only` and :option:`-fno-trapping-math`. + Note that while the throughput of the sequence is higher than the throughput + of the non-reciprocal instruction, the precision of the sequence can be + decreased by up to 2 ulp (i.e. the inverse of 1.0 equals 0.99999994). + + Note that GCC implements ``1.0f/sqrtf(x)`` in terms of ``RSQRTSS`` + (or ``RSQRTPS``) already with :option:`-ffast-math` (or the above option + combination), and doesn't need :option:`-mrecip`. + + Also note that GCC emits the above sequence with additional Newton-Raphson step + for vectorized single-float division and vectorized ``sqrtf(x)`` + already with :option:`-ffast-math` (or the above option combination), and + doesn't need :option:`-mrecip`. + +.. option:: -mrecip={opt} + + This option controls which reciprocal estimate instructions + may be used. :samp:`{opt}` is a comma-separated list of options, which may + be preceded by a :samp:`!` to invert the option: + + :samp:`all` + Enable all estimate instructions. + + :samp:`default` + Enable the default instructions, equivalent to :option:`-mrecip`. + + :samp:`none` + Disable all estimate instructions, equivalent to :option:`-mno-recip`. + + :samp:`div` + Enable the approximation for scalar division. + + :samp:`vec-div` + Enable the approximation for vectorized division. + + :samp:`sqrt` + Enable the approximation for scalar square root. + + :samp:`vec-sqrt` + Enable the approximation for vectorized square root. + + So, for example, :option:`-mrecip=all,!sqrt` enables + all of the reciprocal approximations, except for square root. + +.. option:: -mveclibabi={type} + + Specifies the ABI type to use for vectorizing intrinsics using an + external library. Supported values for :samp:`{type}` are :samp:`svml` + for the Intel short + vector math library and :samp:`acml` for the AMD math core library. + To use this option, both :option:`-ftree-vectorize` and + :option:`-funsafe-math-optimizations` have to be enabled, and an SVML or ACML + ABI-compatible library must be specified at link time. + + GCC currently emits calls to ``vmldExp2``, + ``vmldLn2``, ``vmldLog102``, ``vmldPow2``, + ``vmldTanh2``, ``vmldTan2``, ``vmldAtan2``, ``vmldAtanh2``, + ``vmldCbrt2``, ``vmldSinh2``, ``vmldSin2``, ``vmldAsinh2``, + ``vmldAsin2``, ``vmldCosh2``, ``vmldCos2``, ``vmldAcosh2``, + ``vmldAcos2``, ``vmlsExp4``, ``vmlsLn4``, + ``vmlsLog104``, ``vmlsPow4``, ``vmlsTanh4``, ``vmlsTan4``, + ``vmlsAtan4``, ``vmlsAtanh4``, ``vmlsCbrt4``, ``vmlsSinh4``, + ``vmlsSin4``, ``vmlsAsinh4``, ``vmlsAsin4``, ``vmlsCosh4``, + ``vmlsCos4``, ``vmlsAcosh4`` and ``vmlsAcos4`` for corresponding + function type when :option:`-mveclibabi=svml` is used, and ``__vrd2_sin``, + ``__vrd2_cos``, ``__vrd2_exp``, ``__vrd2_log``, ``__vrd2_log2``, + ``__vrd2_log10``, ``__vrs4_sinf``, ``__vrs4_cosf``, + ``__vrs4_expf``, ``__vrs4_logf``, ``__vrs4_log2f``, + ``__vrs4_log10f`` and ``__vrs4_powf`` for the corresponding function type + when :option:`-mveclibabi=acml` is used. + +.. option:: -mabi={name} + + Generate code for the specified calling convention. Permissible values + are :samp:`sysv` for the ABI used on GNU/Linux and other systems, and + :samp:`ms` for the Microsoft ABI. The default is to use the Microsoft + ABI when targeting Microsoft Windows and the SysV ABI on all other systems. + You can control this behavior for specific functions by + using the function attributes :x86-fn-attr:`ms_abi` and ``sysv_abi``. + See :ref:`function-attributes`. + +.. option:: -mforce-indirect-call + + Force all calls to functions to be indirect. This is useful + when using Intel Processor Trace where it generates more precise timing + information for function calls. + +.. option:: -mmanual-endbr + + Insert ENDBR instruction at function entry only via the :x86-fn-attr:`cf_check` + function attribute. This is useful when used with the option + :option:`-fcf-protection=branch` to control ENDBR insertion at the + function entry. + +.. option:: -mcet-switch + + By default, CET instrumentation is turned off on switch statements that + use a jump table and indirect branch track is disabled. Since jump + tables are stored in read-only memory, this does not result in a direct + loss of hardening. But if the jump table index is attacker-controlled, + the indirect jump may not be constrained by CET. This option turns on + CET instrumentation to enable indirect branch track for switch statements + with jump tables which leads to the jump targets reachable via any indirect + jumps. + +.. option:: -mcall-ms2sysv-xlogues + + Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a + System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By + default, the code for saving and restoring these registers is emitted inline, + resulting in fairly lengthy prologues and epilogues. Using + :option:`-mcall-ms2sysv-xlogues` emits prologues and epilogues that + use stubs in the static portion of libgcc to perform these saves and restores, + thus reducing function size at the cost of a few extra instructions. + +.. option:: -mno-call-ms2sysv-xlogues + + Default setting; overrides :option:`-mcall-ms2sysv-xlogues`. + +.. option:: -mtls-dialect={type} + + Generate code to access thread-local storage using the :samp:`gnu` or + :samp:`gnu2` conventions. :samp:`gnu` is the conservative default; + :samp:`gnu2` is more efficient, but it may add compile- and run-time + requirements that cannot be satisfied on all systems. + +.. option:: -mpush-args, -mno-push-args + + Use PUSH operations to store outgoing parameters. This method is shorter + and usually equally fast as method using SUB/MOV operations and is enabled + by default. In some cases disabling it may improve performance because of + improved scheduling and reduced dependencies. + +.. option:: -maccumulate-outgoing-args + + If enabled, the maximum amount of space required for outgoing arguments is + computed in the function prologue. This is faster on most modern CPUs + because of reduced dependencies, improved scheduling and reduced stack usage + when the preferred stack boundary is not equal to 2. The drawback is a notable + increase in code size. This switch implies :option:`-mno-push-args`. + +.. option:: -mthreads + + Support thread-safe exception handling on MinGW. Programs that rely + on thread-safe exception handling must compile and link all code with the + :option:`-mthreads` option. When compiling, :option:`-mthreads` defines + :option:`-D_MT` ; when linking, it links in a special thread helper library + :option:`-lmingwthrd` which cleans up per-thread exception-handling data. + +.. option:: -mms-bitfields, -mno-ms-bitfields + + Enable/disable bit-field layout compatible with the native Microsoft + Windows compiler. + + If :var-attr:`packed` is used on a structure, or if bit-fields are used, + it may be that the Microsoft ABI lays out the structure differently + than the way GCC normally does. Particularly when moving packed + data between functions compiled with GCC and the native Microsoft compiler + (either via function call or as data in a file), it may be necessary to access + either format. + + This option is enabled by default for Microsoft Windows + targets. This behavior can also be controlled locally by use of variable + or type attributes. For more information, see :ref:`x86-variable-attributes` + and :ref:`x86-type-attributes`. + + The Microsoft structure layout algorithm is fairly simple with the exception + of the bit-field packing. + The padding and alignment of members of structures and whether a bit-field + can straddle a storage-unit boundary are determine by these rules: + + * Structure members are stored sequentially in the order in which they are + declared: the first member has the lowest memory address and the last member + the highest. + + * Every data object has an alignment requirement. The alignment requirement + for all data except structures, unions, and arrays is either the size of the + object or the current packing size (specified with either the + :fn-attr:`aligned` attribute or the ``pack`` pragma), + whichever is less. For structures, unions, and arrays, + the alignment requirement is the largest alignment requirement of its members. + Every object is allocated an offset so that: + + .. code-block:: c++ + + offset % alignment_requirement == 0 + + * Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation + unit if the integral types are the same size and if the next bit-field fits + into the current allocation unit without crossing the boundary imposed by the + common alignment requirements of the bit-fields. + + MSVC interprets zero-length bit-fields in the following ways: + + * If a zero-length bit-field is inserted between two bit-fields that + are normally coalesced, the bit-fields are not coalesced. + + For example: + + .. code-block:: c++ + + struct + { + unsigned long bf_1 : 12; + unsigned long : 0; + unsigned long bf_2 : 12; + } t1; + + The size of ``t1`` is 8 bytes with the zero-length bit-field. If the + zero-length bit-field were removed, ``t1`` 's size would be 4 bytes. + + * If a zero-length bit-field is inserted after a bit-field, ``foo``, and the + alignment of the zero-length bit-field is greater than the member that follows it, + ``bar``, ``bar`` is aligned as the type of the zero-length bit-field. + + For example: + + .. code-block:: c++ + + struct + { + char foo : 4; + short : 0; + char bar; + } t2; + + struct + { + char foo : 4; + short : 0; + double bar; + } t3; + + For ``t2``, ``bar`` is placed at offset 2, rather than offset 1. + Accordingly, the size of ``t2`` is 4. For ``t3``, the zero-length + bit-field does not affect the alignment of ``bar`` or, as a result, the size + of the structure. + + Taking this into account, it is important to note the following: + + * If a zero-length bit-field follows a normal bit-field, the type of the + zero-length bit-field may affect the alignment of the structure as whole. For + example, ``t2`` has a size of 4 bytes, since the zero-length bit-field follows a + normal bit-field, and is of type short. + + * Even if a zero-length bit-field is not followed by a normal bit-field, it may + still affect the alignment of the structure: + + .. code-block:: c++ + + struct + { + char foo : 6; + long : 0; + } t4; + + Here, ``t4`` takes up 4 bytes. + + * Zero-length bit-fields following non-bit-field members are ignored: + + .. code-block:: c++ + + struct + { + char foo; + long : 0; + char bar; + } t5; + + Here, ``t5`` takes up 2 bytes. + +.. option:: -mno-align-stringops + + Do not align the destination of inlined string operations. This switch reduces + code size and improves performance in case the destination is already aligned, + but GCC doesn't know about it. + +.. option:: -malign-stringops + + Default setting; overrides :option:`-mno-align-stringops`. + +.. option:: -minline-all-stringops + + By default GCC inlines string operations only when the destination is + known to be aligned to least a 4-byte boundary. + This enables more inlining and increases code + size, but may improve performance of code that depends on fast + ``memcpy`` and ``memset`` for short lengths. + The option enables inline expansion of ``strlen`` for all + pointer alignments. + +.. option:: -minline-stringops-dynamically + + For string operations of unknown size, use run-time checks with + inline code for small blocks and a library call for large blocks. + +.. index:: mstringop-strategy=alg + +.. option:: -mstringop-strategy={alg} + + Override the internal decision heuristic for the particular algorithm to use + for inlining string operations. The allowed values for :samp:`{alg}` are: + + :samp:`rep_byte` :samp:`rep_4byte` :samp:`rep_8byte` + Expand using i386 ``rep`` prefix of the specified size. + + :samp:`byte_loop` :samp:`loop` :samp:`unrolled_loop` + Expand into an inline loop. + + :samp:`libcall` + Always use a library call. + +.. index:: mmemcpy-strategy=strategy + +.. option:: -mmemcpy-strategy={strategy} + + Override the internal decision heuristic to decide if ``__builtin_memcpy`` + should be inlined and what inline algorithm to use when the expected size + of the copy operation is known. :samp:`{strategy}` + is a comma-separated list of :samp:`{alg}` : :samp:`{max_size}` : :samp:`{dest_align}` triplets. + :samp:`{alg}` is specified in :option:`-mstringop-strategy`, :samp:`{max_size}` specifies + the max byte size with which inline algorithm :samp:`{alg}` is allowed. For the last + triplet, the :samp:`{max_size}` must be ``-1``. The :samp:`{max_size}` of the triplets + in the list must be specified in increasing order. The minimal byte size for + :samp:`{alg}` is ``0`` for the first triplet and ``max_size + 1`` of the + preceding range. + +.. index:: mmemset-strategy=strategy + +.. option:: -mmemset-strategy={strategy} + + The option is similar to :option:`-mmemcpy-strategy=` except that it is to control + ``__builtin_memset`` expansion. + +.. option:: -momit-leaf-frame-pointer + + Don't keep the frame pointer in a register for leaf functions. This + avoids the instructions to save, set up, and restore frame pointers and + makes an extra register available in leaf functions. The option + :option:`-fomit-leaf-frame-pointer` removes the frame pointer for leaf functions, + which might make debugging harder. + +.. option:: -mtls-direct-seg-refs, -mno-tls-direct-seg-refs + + Controls whether TLS variables may be accessed with offsets from the + TLS segment register (``%gs`` for 32-bit, ``%fs`` for 64-bit), + or whether the thread base pointer must be added. Whether or not this + is valid depends on the operating system, and whether it maps the + segment to cover the entire TLS area. + + For systems that use the GNU C Library, the default is on. + +.. option:: -msse2avx, -mno-sse2avx + + Specify that the assembler should encode SSE instructions with VEX + prefix. The option :option:`-mavx` turns this on by default. + +.. option:: -mfentry, -mno-fentry + + If profiling is active (:option:`-pg`), put the profiling + counter call before the prologue. + + .. note:: + + On x86 architectures the attribute :x86-fn-attr:`ms_hook_prologue` + isn't possible at the moment for :option:`-mfentry` and :option:`-pg`. + +.. option:: -mrecord-mcount, -mno-record-mcount + + If profiling is active (:option:`-pg`), generate a __mcount_loc section + that contains pointers to each profiling call. This is useful for + automatically patching and out calls. + +.. option:: -mnop-mcount, -mno-nop-mcount + + If profiling is active (:option:`-pg`), generate the calls to + the profiling functions as NOPs. This is useful when they + should be patched in later dynamically. This is likely only + useful together with :option:`-mrecord-mcount`. + +.. option:: -minstrument-return={type} + + Instrument function exit in -pg -mfentry instrumented functions with + call to specified function. This only instruments true returns ending + with ret, but not sibling calls ending with jump. Valid types + are :samp:`{none}` to not instrument, :samp:`{call}` to generate a call to __return__, + or :samp:`{nop5}` to generate a 5 byte nop. + +.. option:: -mrecord-return, -mno-record-return + + Generate a __return_loc section pointing to all return instrumentation code. + +.. option:: -mfentry-name={name} + + Set name of __fentry__ symbol called at function entry for -pg -mfentry functions. + +.. option:: -mfentry-section={name} + + Set name of section to record -mrecord-mcount calls (default __mcount_loc). + +.. option:: -mskip-rax-setup, -mno-skip-rax-setup + + When generating code for the x86-64 architecture with SSE extensions + disabled, :option:`-mskip-rax-setup` can be used to skip setting up RAX + register when there are no variable arguments passed in vector registers. + + .. warning:: + + Since RAX register is used to avoid unnecessarily + saving vector registers on stack when passing variable arguments, the + impacts of this option are callees may waste some stack space, + misbehave or jump to a random location. GCC 4.4 or newer don't have + those issues, regardless the RAX register value. + +.. option:: -m8bit-idiv, -mno-8bit-idiv + + On some processors, like Intel Atom, 8-bit unsigned integer divide is + much faster than 32-bit/64-bit integer divide. This option generates a + run-time check. If both dividend and divisor are within range of 0 + to 255, 8-bit unsigned integer divide is used instead of + 32-bit/64-bit integer divide. + +.. option:: -mavx256-split-unaligned-load, -mavx256-split-unaligned-store + + Split 32-byte AVX unaligned load and store. + +.. option:: -mstack-protector-guard={guard} + + Generate stack protection code using canary at :samp:`{guard}`. Supported + locations are :samp:`global` for global canary or :samp:`tls` for per-thread + canary in the TLS block (the default). This option has effect only when + :option:`-fstack-protector` or :option:`-fstack-protector-all` is specified. + + With the latter choice the options + :option:`-mstack-protector-guard-reg=reg` and + :option:`-mstack-protector-guard-offset=offset` furthermore specify + which segment register (``%fs`` or ``%gs``) to use as base register + for reading the canary, and from what offset from that base register. + The default for those is as specified in the relevant ABI. + +.. option:: -mgeneral-regs-only + + Generate code that uses only the general-purpose registers. This + prevents the compiler from using floating-point, vector, mask and bound + registers. + +.. option:: -mrelax-cmpxchg-loop + + Relax cmpxchg loop by emitting an early load and compare before cmpxchg, + execute pause if load value is not expected. This reduces excessive + cachline bouncing when and works for all atomic logic fetch builtins + that generates compare and swap loop. + +.. option:: -mprefer-remote-atomic + + Prefer use remote atomic insn for atomic operations. + +.. option:: -mindirect-branch={choice} + + Convert indirect call and jump with :samp:`{choice}`. The default is + :samp:`keep`, which keeps indirect call and jump unmodified. + :samp:`thunk` converts indirect call and jump to call and return thunk. + :samp:`thunk-inline` converts indirect call and jump to inlined call + and return thunk. :samp:`thunk-extern` converts indirect call and jump + to external call and return thunk provided in a separate object file. + You can control this behavior for a specific function by using the + function attribute ``indirect_branch``. See :ref:`function-attributes`. + + Note that :option:`-mcmodel=large` is incompatible with + :option:`-mindirect-branch=thunk` and + :option:`-mindirect-branch=thunk-extern` since the thunk function may + not be reachable in the large code model. + + Note that :option:`-mindirect-branch=thunk-extern` is compatible with + :option:`-fcf-protection=branch` since the external thunk can be made + to enable control-flow check. + +.. option:: -mfunction-return={choice} + + Convert function return with :samp:`{choice}`. The default is :samp:`keep`, + which keeps function return unmodified. :samp:`thunk` converts function + return to call and return thunk. :samp:`thunk-inline` converts function + return to inlined call and return thunk. :samp:`thunk-extern` converts + function return to external call and return thunk provided in a separate + object file. You can control this behavior for a specific function by + using the function attribute ``function_return``. + See :ref:`function-attributes`. + + Note that :option:`-mindirect-return=thunk-extern` is compatible with + :option:`-fcf-protection=branch` since the external thunk can be made + to enable control-flow check. + + Note that :option:`-mcmodel=large` is incompatible with + :option:`-mfunction-return=thunk` and + :option:`-mfunction-return=thunk-extern` since the thunk function may + not be reachable in the large code model. + +.. option:: -mindirect-branch-register + + Force indirect call and jump via register. + +.. option:: -mharden-sls={choice} + + Generate code to mitigate against straight line speculation (SLS) with + :samp:`{choice}`. The default is :samp:`none` which disables all SLS + hardening. :samp:`return` enables SLS hardening for function returns. + :samp:`indirect-jmp` enables SLS hardening for indirect jumps. + :samp:`all` enables all SLS hardening. + +.. option:: -mindirect-branch-cs-prefix + + Add CS prefix to call and jmp to indirect thunk with branch target in + r8-r15 registers so that the call and jmp instruction length is 6 bytes + to allow them to be replaced with :samp:`lfence; call *%r8-r15` or + :samp:`lfence; jmp *%r8-r15` at run-time. + +These :samp:`-m` switches are supported in addition to the above +on x86-64 processors in 64-bit environments. + +.. option:: -m32, -m64, -mx32, -m16, -miamcu + + Generate code for a 16-bit, 32-bit or 64-bit environment. + The :option:`-m32` option sets ``int``, ``long``, and pointer types + to 32 bits, and + generates code that runs on any i386 system. + + The :option:`-m64` option sets ``int`` to 32 bits and ``long`` and pointer + types to 64 bits, and generates code for the x86-64 architecture. + For Darwin only the :option:`-m64` option also turns off the :option:`-fno-pic` + and :option:`-mdynamic-no-pic` options. + + The :option:`-mx32` option sets ``int``, ``long``, and pointer types + to 32 bits, and + generates code for the x86-64 architecture. + + The :option:`-m16` option is the same as :option:`-m32`, except for that + it outputs the ``.code16gcc`` assembly directive at the beginning of + the assembly output so that the binary can run in 16-bit mode. + + The :option:`-miamcu` option generates code which conforms to Intel MCU + psABI. It requires the :option:`-m32` option to be turned on. + +.. option:: -mno-red-zone + + Do not use a so-called 'red zone' for x86-64 code. The red zone is mandated + by the x86-64 ABI; it is a 128-byte area beyond the location of the + stack pointer that is not modified by signal or interrupt handlers + and therefore can be used for temporary data without adjusting the stack + pointer. The flag :option:`-mno-red-zone` disables this red zone. + +.. option:: -mred-zone + + Default setting; overrides :option:`-mno-red-zone`. + +.. option:: -mcmodel=small + + Generate code for the small code model: the program and its symbols must + be linked in the lower 2 GB of the address space. Pointers are 64 bits. + Programs can be statically or dynamically linked. This is the default + code model. + +.. option:: -mcmodel=kernel + + Generate code for the kernel code model. The kernel runs in the + negative 2 GB of the address space. + This model has to be used for Linux kernel code. + +.. option:: -mcmodel=medium + + Generate code for the medium model: the program is linked in the lower 2 + GB of the address space. Small symbols are also placed there. Symbols + with sizes larger than :option:`-mlarge-data-threshold` are put into + large data or BSS sections and can be located above 2GB. Programs can + be statically or dynamically linked. + +.. option:: -mcmodel=large + + Generate code for the large model. This model makes no assumptions + about addresses and sizes of sections. + +.. option:: -maddress-mode=long + + Generate code for long address mode. This is only supported for 64-bit + and x32 environments. It is the default address mode for 64-bit + environments. + +.. option:: -maddress-mode=short + + Generate code for short address mode. This is only supported for 32-bit + and x32 environments. It is the default address mode for 32-bit and + x32 environments. + +.. option:: -mneeded, -mno-needed + + Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to + indicate the micro-architecture ISA level required to execute the binary. + +.. option:: -mno-direct-extern-access + + Without :option:`-fpic` nor :option:`-fPIC`, always use the GOT pointer + to access external symbols. With :option:`-fpic` or :option:`-fPIC`, + treat access to protected symbols as local symbols. The default is + :option:`-mdirect-extern-access`. + + .. warning:: + + Shared libraries compiled with + :option:`-mno-direct-extern-access` and executable compiled with + :option:`-mdirect-extern-access` may not be binary compatible if + protected symbols are used in shared libraries and executable. + +.. option:: -mdirect-extern-access + + Default setting; overrides :option:`-mno-direct-extern-access`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/x86-windows-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/x86-windows-options.rst new file mode 100644 index 00000000000..b7e75cfff37 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/x86-windows-options.rst @@ -0,0 +1,95 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: x86 Windows + +.. index:: x86 Windows Options, Windows Options for x86 + +.. _x86-windows-options: + +x86 Windows Options +^^^^^^^^^^^^^^^^^^^ + +These additional options are available for Microsoft Windows targets: + +.. option:: -mconsole + + This option + specifies that a console application is to be generated, by + instructing the linker to set the PE header subsystem type + required for console applications. + This option is available for Cygwin and MinGW targets and is + enabled by default on those targets. + +.. option:: -mdll + + This option is available for Cygwin and MinGW targets. It + specifies that a DLL---a dynamic link library---is to be + generated, enabling the selection of the required runtime + startup object and entry point. + +.. option:: -mnop-fun-dllimport + + This option is available for Cygwin and MinGW targets. It + specifies that the :microsoft-windows-fn-attr:`dllimport` attribute should be ignored. + +.. option:: -mthreads + + This option is available for MinGW targets. It specifies + that MinGW-specific thread support is to be used. + +.. option:: -municode + + This option is available for MinGW-w64 targets. It causes + the ``UNICODE`` preprocessor macro to be predefined, and + chooses Unicode-capable runtime startup code. + +.. option:: -mwin32 + + This option is available for Cygwin and MinGW targets. It + specifies that the typical Microsoft Windows predefined macros are to + be set in the pre-processor, but does not influence the choice + of runtime library/startup code. + +.. option:: -mwindows + + This option is available for Cygwin and MinGW targets. It + specifies that a GUI application is to be generated by + instructing the linker to set the PE header subsystem type + appropriately. + +.. option:: -fno-set-stack-executable + + This option is available for MinGW targets. It specifies that + the executable flag for the stack used by nested functions isn't + set. This is necessary for binaries running in kernel mode of + Microsoft Windows, as there the User32 API, which is used to set executable + privileges, isn't available. + +.. option:: -fset-stack-executable + + Default setting; overrides :option:`-fno-set-stack-executable`. + +.. option:: -fwritable-relocated-rdata + + This option is available for MinGW and Cygwin targets. It specifies + that relocated-data in read-only section is put into the ``.data`` + section. This is a necessary for older runtimes not supporting + modification of ``.rdata`` sections for pseudo-relocation. + +.. option:: -fno-writable-relocated-rdata + + Default setting; overrides :option:`-fwritable-relocated-rdata`. + +.. option:: -mpe-aligned-commons + + This option is available for Cygwin and MinGW targets. It + specifies that the GNU extension to the PE file format that + permits the correct alignment of COMMON variables should be + used when generating code. It is enabled by default if + GCC detects that the target assembler found during configuration + supports the feature. + +See also under :ref:`x86-options` for standard options. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/xstormy16-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/xstormy16-options.rst new file mode 100644 index 00000000000..8c191b972c8 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/xstormy16-options.rst @@ -0,0 +1,19 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: Xstormy16 + +.. index:: Xstormy16 Options + +.. _xstormy16-options: + +Xstormy16 Options +^^^^^^^^^^^^^^^^^ + +These options are defined for Xstormy16: + +.. option:: -msim + + Choose startup files and linker script suitable for the simulator. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/xtensa-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/xtensa-options.rst new file mode 100644 index 00000000000..fbffe960fba --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/xtensa-options.rst @@ -0,0 +1,138 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: Xtensa + +.. index:: Xtensa Options + +.. _xtensa-options: + +Xtensa Options +^^^^^^^^^^^^^^ + +These options are supported for Xtensa targets: + +.. option:: -mconst16, -mno-const16 + + Enable or disable use of ``CONST16`` instructions for loading + constant values. The ``CONST16`` instruction is currently not a + standard option from Tensilica. When enabled, ``CONST16`` + instructions are always used in place of the standard ``L32R`` + instructions. The use of ``CONST16`` is enabled by default only if + the ``L32R`` instruction is not available. + +.. option:: -mfused-madd, -mno-fused-madd + + Enable or disable use of fused multiply/add and multiply/subtract + instructions in the floating-point option. This has no effect if the + floating-point option is not also enabled. Disabling fused multiply/add + and multiply/subtract instructions forces the compiler to use separate + instructions for the multiply and add/subtract operations. This may be + desirable in some cases where strict IEEE 754-compliant results are + required: the fused multiply add/subtract instructions do not round the + intermediate result, thereby producing results with *more* bits of + precision than specified by the IEEE standard. Disabling fused multiply + add/subtract instructions also ensures that the program output is not + sensitive to the compiler's ability to combine multiply and add/subtract + operations. + +.. option:: -mserialize-volatile, -mno-serialize-volatile + + When this option is enabled, GCC inserts ``MEMW`` instructions before + ``volatile`` memory references to guarantee sequential consistency. + The default is :option:`-mserialize-volatile`. Use + :option:`-mno-serialize-volatile` to omit the ``MEMW`` instructions. + +.. option:: -mforce-no-pic + + For targets, like GNU/Linux, where all user-mode Xtensa code must be + position-independent code (PIC), this option disables PIC for compiling + kernel code. + +.. option:: -mtext-section-literals, -mno-text-section-literals + + These options control the treatment of literal pools. The default is + :option:`-mno-text-section-literals`, which places literals in a separate + section in the output file. This allows the literal pool to be placed + in a data RAM/ROM, and it also allows the linker to combine literal + pools from separate object files to remove redundant literals and + improve code size. With :option:`-mtext-section-literals`, the literals + are interspersed in the text section in order to keep them as close as + possible to their references. This may be necessary for large assembly + files. Literals for each function are placed right before that function. + +.. option:: -mauto-litpools, -mno-auto-litpools + + These options control the treatment of literal pools. The default is + :option:`-mno-auto-litpools`, which places literals in a separate + section in the output file unless :option:`-mtext-section-literals` is + used. With :option:`-mauto-litpools` the literals are interspersed in + the text section by the assembler. Compiler does not produce explicit + ``.literal`` directives and loads literals into registers with + ``MOVI`` instructions instead of ``L32R`` to let the assembler + do relaxation and place literals as necessary. This option allows + assembler to create several literal pools per function and assemble + very big functions, which may not be possible with + :option:`-mtext-section-literals`. + +.. option:: -mtarget-align, -mno-target-align + + When this option is enabled, GCC instructs the assembler to + automatically align instructions to reduce branch penalties at the + expense of some code density. The assembler attempts to widen density + instructions to align branch targets and the instructions following call + instructions. If there are not enough preceding safe density + instructions to align a target, no widening is performed. The + default is :option:`-mtarget-align`. These options do not affect the + treatment of auto-aligned instructions like ``LOOP``, which the + assembler always aligns, either by widening density instructions or + by inserting NOP instructions. + +.. option:: -mlongcalls, -mno-longcalls + + When this option is enabled, GCC instructs the assembler to translate + direct calls to indirect calls unless it can determine that the target + of a direct call is in the range allowed by the call instruction. This + translation typically occurs for calls to functions in other source + files. Specifically, the assembler translates a direct ``CALL`` + instruction into an ``L32R`` followed by a ``CALLX`` instruction. + The default is :option:`-mno-longcalls`. This option should be used in + programs where the call target can potentially be out of range. This + option is implemented in the assembler, not the compiler, so the + assembly code generated by GCC still shows direct call + instructions---look at the disassembled object code to see the actual + instructions. Note that the assembler uses an indirect call for + every cross-file call, not just those that really are out of range. + +.. option:: -mabi={name} + + Generate code for the specified ABI. Permissible values are: :samp:`call0`, + :samp:`windowed`. Default ABI is chosen by the Xtensa core configuration. + +.. option:: -mabi=call0 + + When this option is enabled function parameters are passed in registers + ``a2`` through ``a7``, registers ``a12`` through ``a15`` are + caller-saved, and register ``a15`` may be used as a frame pointer. + When this version of the ABI is enabled the C preprocessor symbol + ``__XTENSA_CALL0_ABI__`` is defined. + +.. option:: -mabi=windowed + + When this option is enabled function parameters are passed in registers + ``a10`` through ``a15``, and called function rotates register window + by 8 registers on entry so that its arguments are found in registers + ``a2`` through ``a7``. Register ``a7`` may be used as a frame + pointer. Register window is rotated 8 registers back upon return. + When this version of the ABI is enabled the C preprocessor symbol + ``__XTENSA_WINDOWED_ABI__`` is defined. + +.. option:: -mextra-l32r-costs={n} + + Specify an extra cost of instruction RAM/ROM access for ``L32R`` + instructions, in clock cycles. This affects, when optimizing for speed, + whether loading a constant from literal pool using ``L32R`` or + synthesizing the constant from a small one with a couple of arithmetic + instructions. The default value is 0. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/machine-dependent-options/zseries-options.rst b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/zseries-options.rst new file mode 100644 index 00000000000..eec47bfd1bc --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/machine-dependent-options/zseries-options.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: zSeries + +.. index:: zSeries options + +.. _zseries-options: + +zSeries Options +^^^^^^^^^^^^^^^ + +These are listed under See :ref:`s-390-and-zseries-options`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/option-summary.rst b/gcc/doc/gcc/gcc-command-options/option-summary.rst new file mode 100644 index 00000000000..e687b95b9ee --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/option-summary.rst @@ -0,0 +1,1527 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _option-summary: + +Option Summary +************** + +Here is a summary of all the options, grouped by type. Explanations are +in the following sections. + +*Overall Options* + + See :ref:`overall-options`. + + :option:`-c` :option:`-S` :option:`-E` :option:`-o` :samp:`{file}` |gol| + :option:`-dumpbase` :samp:`{dumpbase}` :option:`-dumpbase-ext` :samp:`{auxdropsuf}` |gol| + :option:`-dumpdir` :samp:`{dumppfx}` :option:`-x` :samp:`{language}` |gol| + :option:`-v` :option:`-###` :option:`--help`:samp:`[={class}[,...]]` :option:`--target-help` :option:`--version` |gol| + :option:`-pass-exit-codes` :option:`-pipe` :option:`-specs=file` :option:`-wrapper` |gol| + :samp:`@{file}` :option:`-ffile-prefix-map=old=new` |gol| + :option:`-fplugin=file` :option:`-fplugin-arg-name=arg` |gol| + :option:`-fdump-ada-spec[-slim]` :option:`-fada-spec-parent=unit` :option:`-fdump-go-spec=file` + +*C Language Options* + + See :ref:`c-dialect-options`. + + :option:`-ansi` :option:`-std=standard` :option:`-aux-info` :samp:`{filename}` |gol| + :option:`-fno-asm` |gol| + :option:`-fno-builtin` :option:`-fno-builtin-function` :option:`-fcond-mismatch` |gol| + :option:`-ffreestanding` :option:`-fgimple` :option:`-fgnu-tm` :option:`-fgnu89-inline` :option:`-fhosted` |gol| + :option:`-flax-vector-conversions` :option:`-fms-extensions` |gol| + :option:`-foffload=arg` :option:`-foffload-options=arg` |gol| + :option:`-fopenacc` :option:`-fopenacc-dim=geom` |gol| + :option:`-fopenmp` :option:`-fopenmp-simd` |gol| + :option:`-fpermitted-flt-eval-methods=standard` |gol| + :option:`-fplan9-extensions` :option:`-fsigned-bitfields` :option:`-funsigned-bitfields` |gol| + :option:`-fsigned-char` :option:`-funsigned-char` :option:`-fstrict-flex-arrays[=n]` |gol| + :option:`-fsso-struct=endianness` + +*C++ Language Options* + + See :ref:`c++-dialect-options`. + + :option:`-fabi-version=n` :option:`-fno-access-control` |gol| + :option:`-faligned-new=n` :option:`-fargs-in-order=n` :option:`-fchar8_t` :option:`-fcheck-new` |gol| + :option:`-fconstexpr-depth=n` :option:`-fconstexpr-cache-depth=n` |gol| + :option:`-fconstexpr-loop-limit=n` :option:`-fconstexpr-ops-limit=n` |gol| + :option:`-fno-elide-constructors` |gol| + :option:`-fno-enforce-eh-specs` |gol| + :option:`-fno-gnu-keywords` |gol| + :option:`-fno-implicit-templates` |gol| + :option:`-fno-implicit-inline-templates` |gol| + :option:`-fno-implement-inlines` |gol| + :option:`-fmodule-header=kind` :option:`-fmodule-only` :option:`-fmodules-ts` |gol| + :option:`-fmodule-implicit-inline` |gol| + :option:`-fno-module-lazy` |gol| + :option:`-fmodule-mapper=specification` |gol| + :option:`-fmodule-version-ignore` |gol| + :option:`-fms-extensions` |gol| + :option:`-fnew-inheriting-ctors` |gol| + :option:`-fnew-ttp-matching` |gol| + :option:`-fno-nonansi-builtins` :option:`-fnothrow-opt` :option:`-fno-operator-names` |gol| + :option:`-fno-optional-diags` :option:`-fpermissive` |gol| + :option:`-fno-pretty-templates` |gol| + :option:`-fno-rtti` :option:`-fsized-deallocation` |gol| + :option:`-ftemplate-backtrace-limit=n` |gol| + :option:`-ftemplate-depth=n` |gol| + :option:`-fno-threadsafe-statics` :option:`-fuse-cxa-atexit` |gol| + :option:`-fno-weak` :option:`-nostdinc++` |gol| + :option:`-fvisibility-inlines-hidden` |gol| + :option:`-fvisibility-ms-compat` |gol| + :option:`-fext-numeric-literals` |gol| + :option:`-flang-info-include-translate=header` |gol| + :option:`-flang-info-include-translate-not` |gol| + :option:`-flang-info-module-cmi=module` |gol| + :option:`-stdlib=libstdc++,libc++` |gol| + :option:`-Wabi-tag` :option:`-Wcatch-value` :option:`-Wcatch-value=n` |gol| + :option:`-Wno-class-conversion` :option:`-Wclass-memaccess` |gol| + :option:`-Wcomma-subscript` :option:`-Wconditionally-supported` |gol| + :option:`-Wno-conversion-null` :option:`-Wctad-maybe-unsupported` |gol| + :option:`-Wctor-dtor-privacy` :option:`-Wdangling-reference` |gol| + :option:`-Wno-delete-incomplete` |gol| + :option:`-Wdelete-non-virtual-dtor` :option:`-Wno-deprecated-array-compare` |gol| + :option:`-Wdeprecated-copy` :option:`-Wdeprecated-copy-dtor` |gol| + :option:`-Wno-deprecated-enum-enum-conversion` :option:`-Wno-deprecated-enum-float-conversion` |gol| + :option:`-Weffc++` :option:`-Wno-exceptions` :option:`-Wextra-semi` :option:`-Wno-inaccessible-base` |gol| + :option:`-Wno-inherited-variadic-ctor` :option:`-Wno-init-list-lifetime` |gol| + :option:`-Winvalid-imported-macros` |gol| + :option:`-Wno-invalid-offsetof` :option:`-Wno-literal-suffix` |gol| + :option:`-Wmismatched-new-delete` :option:`-Wmismatched-tags` |gol| + :option:`-Wmultiple-inheritance` :option:`-Wnamespaces` :option:`-Wnarrowing` |gol| + :option:`-Wnoexcept` :option:`-Wnoexcept-type` :option:`-Wnon-virtual-dtor` |gol| + :option:`-Wpessimizing-move` :option:`-Wno-placement-new` :option:`-Wplacement-new=n` |gol| + :option:`-Wrange-loop-construct` :option:`-Wredundant-move` :option:`-Wredundant-tags` |gol| + :option:`-Wreorder` :option:`-Wregister` |gol| + :option:`-Wstrict-null-sentinel` :option:`-Wno-subobject-linkage` :option:`-Wtemplates` |gol| + :option:`-Wno-non-template-friend` :option:`-Wold-style-cast` |gol| + :option:`-Woverloaded-virtual` :option:`-Wno-pmf-conversions` :option:`-Wself-move` :option:`-Wsign-promo` |gol| + :option:`-Wsized-deallocation` :option:`-Wsuggest-final-methods` |gol| + :option:`-Wsuggest-final-types` :option:`-Wsuggest-override` |gol| + :option:`-Wno-terminate` :option:`-Wuseless-cast` :option:`-Wno-vexing-parse` |gol| + :option:`-Wvirtual-inheritance` |gol| + :option:`-Wno-virtual-move-assign` :option:`-Wvolatile` :option:`-Wzero-as-null-pointer-constant` + +*Objective-C and Objective-C++ Language Options* + + See :ref:`objective-c-and-objective-c++-dialect-options`. + + :option:`-fconstant-string-class=class-name` |gol| + :option:`-fgnu-runtime` :option:`-fnext-runtime` |gol| + :option:`-fno-nil-receivers` |gol| + :option:`-fobjc-abi-version=n` |gol| + :option:`-fobjc-call-cxx-cdtors` |gol| + :option:`-fobjc-direct-dispatch` |gol| + :option:`-fobjc-exceptions` |gol| + :option:`-fobjc-gc` |gol| + :option:`-fobjc-nilcheck` |gol| + :option:`-fobjc-std=objc1` |gol| + :option:`-fno-local-ivars` |gol| + :option:`-fivar-visibility=[public|protected|private|package]` |gol| + :option:`-freplace-objc-classes` |gol| + :option:`-fzero-link` |gol| + :option:`-gen-decls` |gol| + :option:`-Wassign-intercept` :option:`-Wno-property-assign-default` |gol| + :option:`-Wno-protocol` :option:`-Wobjc-root-class` :option:`-Wselector` |gol| + :option:`-Wstrict-selector-match` |gol| + :option:`-Wundeclared-selector` + +*Diagnostic Message Formatting Options* + + See :ref:`diagnostic-message-formatting-options`. + + :option:`-fmessage-length=n` |gol| + :option:`-fdiagnostics-plain-output` |gol| + :option:`-fdiagnostics-show-location=[once|every-line]` |gol| + :option:`-fdiagnostics-color=[auto|never|always]` |gol| + :option:`-fdiagnostics-urls=[auto|never|always]` |gol| + :option:`-fdiagnostics-format=[text|sarif-stderr|sarif-file|json|json-stderr|json-file]` |gol| + :option:`-fno-diagnostics-show-option` :option:`-fno-diagnostics-show-caret` |gol| + :option:`-fno-diagnostics-show-labels` :option:`-fno-diagnostics-show-line-numbers` |gol| + :option:`-fno-diagnostics-show-cwe` |gol| + :option:`-fno-diagnostics-show-rule` |gol| + :option:`-fdiagnostics-minimum-margin-width=width` |gol| + :option:`-fdiagnostics-parseable-fixits` :option:`-fdiagnostics-generate-patch` |gol| + :option:`-fdiagnostics-show-template-tree` :option:`-fno-elide-type` |gol| + :option:`-fdiagnostics-path-format=[none|separate-events|inline-events]` |gol| + :option:`-fdiagnostics-show-path-depths` |gol| + :option:`-fno-show-column` |gol| + :option:`-fdiagnostics-column-unit=[display|byte]` |gol| + :option:`-fdiagnostics-column-origin=origin` |gol| + :option:`-fdiagnostics-escape-format=[unicode|bytes]` + +*Warning Options* + + See :ref:`warning-options`. + + :option:`-fsyntax-only` :option:`-fmax-errors=n` :option:`-Wpedantic` |gol| + :option:`-pedantic-errors` |gol| + :option:`-w` :option:`-Wextra` :option:`-Wall` :option:`-Wabi=n` |gol| + :option:`-Waddress` :option:`-Wno-address-of-packed-member` :option:`-Waggregate-return` |gol| + :option:`-Walloc-size-larger-than=byte-size` :option:`-Walloc-zero` |gol| + :option:`-Walloca` :option:`-Walloca-larger-than=byte-size` |gol| + :option:`-Wno-aggressive-loop-optimizations` |gol| + :option:`-Warith-conversion` |gol| + :option:`-Warray-bounds` :option:`-Warray-bounds=n` :option:`-Warray-compare` |gol| + :option:`-Wno-attributes` :option:`-Wattribute-alias=n` :option:`-Wno-attribute-alias` |gol| + :option:`-Wno-attribute-warning` |gol| + :option:`-Wbidi-chars=[none|unpaired|any|ucn]` |gol| + :option:`-Wbool-compare` :option:`-Wbool-operation` |gol| + :option:`-Wno-builtin-declaration-mismatch` |gol| + :option:`-Wno-builtin-macro-redefined` :option:`-Wc90-c99-compat` :option:`-Wc99-c11-compat` |gol| + :option:`-Wc11-c2x-compat` |gol| + :option:`-Wc++-compat` :option:`-Wc++11-compat` :option:`-Wc++14-compat` :option:`-Wc++17-compat` |gol| + :option:`-Wc++20-compat` |gol| + :option:`-Wno-c++11-extensions` :option:`-Wno-c++14-extensions` :option:`-Wno-c++17-extensions` |gol| + :option:`-Wno-c++20-extensions` :option:`-Wno-c++23-extensions` |gol| + :option:`-Wcast-align` :option:`-Wcast-align=strict` :option:`-Wcast-function-type` :option:`-Wcast-qual` |gol| + :option:`-Wchar-subscripts` |gol| + :option:`-Wclobbered` :option:`-Wcomment` |gol| + :option:`-Wconversion` :option:`-Wno-coverage-mismatch` :option:`-Wno-cpp` |gol| + :option:`-Wdangling-else` :option:`-Wdangling-pointer` :option:`-Wdangling-pointer=n` |gol| + :option:`-Wdate-time` |gol| + :option:`-Wno-deprecated` :option:`-Wno-deprecated-declarations` :option:`-Wno-designated-init` |gol| + :option:`-Wdisabled-optimization` |gol| + :option:`-Wno-discarded-array-qualifiers` :option:`-Wno-discarded-qualifiers` |gol| + :option:`-Wno-div-by-zero` :option:`-Wdouble-promotion` |gol| + :option:`-Wduplicated-branches` :option:`-Wduplicated-cond` |gol| + :option:`-Wempty-body` :option:`-Wno-endif-labels` :option:`-Wenum-compare` :option:`-Wenum-conversion` |gol| + :option:`-Wenum-int-mismatch` |gol| + :option:`-Werror` :option:`-Werror=*` :option:`-Wexpansion-to-defined` :option:`-Wfatal-errors` |gol| + :option:`-Wfloat-conversion` :option:`-Wfloat-equal` :option:`-Wformat` :option:`-Wformat=2` |gol| + :option:`-Wno-format-contains-nul` :option:`-Wno-format-extra-args` |gol| + :option:`-Wformat-nonliteral` :option:`-Wformat-overflow=n` |gol| + :option:`-Wformat-security` :option:`-Wformat-signedness` :option:`-Wformat-truncation=n` |gol| + :option:`-Wformat-y2k` :option:`-Wframe-address` |gol| + :option:`-Wframe-larger-than=byte-size` :option:`-Wno-free-nonheap-object` |gol| + :option:`-Wno-if-not-aligned` :option:`-Wno-ignored-attributes` |gol| + :option:`-Wignored-qualifiers` :option:`-Wno-incompatible-pointer-types` |gol| + :option:`-Wimplicit` :option:`-Wimplicit-fallthrough` :option:`-Wimplicit-fallthrough=n` |gol| + :option:`-Wno-implicit-function-declaration` :option:`-Wno-implicit-int` |gol| + :option:`-Winfinite-recursion` |gol| + :option:`-Winit-self` :option:`-Winline` :option:`-Wno-int-conversion` :option:`-Wint-in-bool-context` |gol| + :option:`-Wno-int-to-pointer-cast` :option:`-Wno-invalid-memory-model` |gol| + :option:`-Winvalid-pch` :option:`-Winvalid-utf8` :option:`-Wno-unicode` :option:`-Wjump-misses-init` |gol| + :option:`-Wlarger-than=byte-size` :option:`-Wlogical-not-parentheses` :option:`-Wlogical-op` |gol| + :option:`-Wlong-long` :option:`-Wno-lto-type-mismatch` :option:`-Wmain` :option:`-Wmaybe-uninitialized` |gol| + :option:`-Wmemset-elt-size` :option:`-Wmemset-transposed-args` |gol| + :option:`-Wmisleading-indentation` :option:`-Wmissing-attributes` :option:`-Wmissing-braces` |gol| + :option:`-Wmissing-field-initializers` :option:`-Wmissing-format-attribute` |gol| + :option:`-Wmissing-include-dirs` :option:`-Wmissing-noreturn` :option:`-Wno-missing-profile` |gol| + :option:`-Wno-multichar` :option:`-Wmultistatement-macros` :option:`-Wnonnull` :option:`-Wnonnull-compare` |gol| + :option:`-Wnormalized=[none|id|nfc|nfkc]` |gol| + :option:`-Wnull-dereference` :option:`-Wno-odr` |gol| + :option:`-Wopenacc-parallelism` |gol| + :option:`-Wopenmp-simd` |gol| + :option:`-Wno-overflow` :option:`-Woverlength-strings` :option:`-Wno-override-init-side-effects` |gol| + :option:`-Wpacked` :option:`-Wno-packed-bitfield-compat` :option:`-Wpacked-not-aligned` :option:`-Wpadded` |gol| + :option:`-Wparentheses` :option:`-Wno-pedantic-ms-format` |gol| + :option:`-Wpointer-arith` :option:`-Wno-pointer-compare` :option:`-Wno-pointer-to-int-cast` |gol| + :option:`-Wno-pragmas` :option:`-Wno-prio-ctor-dtor` :option:`-Wredundant-decls` |gol| + :option:`-Wrestrict` :option:`-Wno-return-local-addr` :option:`-Wreturn-type` |gol| + :option:`-Wno-scalar-storage-order` :option:`-Wsequence-point` |gol| + :option:`-Wshadow` :option:`-Wshadow=global` :option:`-Wshadow=local` :option:`-Wshadow=compatible-local` |gol| + :option:`-Wno-shadow-ivar` |gol| + :option:`-Wno-shift-count-negative` :option:`-Wno-shift-count-overflow` :option:`-Wshift-negative-value` |gol| + :option:`-Wno-shift-overflow` :option:`-Wshift-overflow=n` |gol| + :option:`-Wsign-compare` :option:`-Wsign-conversion` |gol| + :option:`-Wno-sizeof-array-argument` |gol| + :option:`-Wsizeof-array-div` |gol| + :option:`-Wsizeof-pointer-div` :option:`-Wsizeof-pointer-memaccess` |gol| + :option:`-Wstack-protector` :option:`-Wstack-usage=byte-size` :option:`-Wstrict-aliasing` |gol| + :option:`-Wstrict-aliasing=n` :option:`-Wstrict-overflow` :option:`-Wstrict-overflow=n` |gol| + :option:`-Wstring-compare` |gol| + :option:`-Wno-stringop-overflow` :option:`-Wno-stringop-overread` |gol| + :option:`-Wno-stringop-truncation` |gol| + :option:`-Wsuggest-attribute=[pure|const|noreturn|format|malloc]` |gol| + :option:`-Wswitch` :option:`-Wno-switch-bool` :option:`-Wswitch-default` :option:`-Wswitch-enum` |gol| + :option:`-Wno-switch-outside-range` :option:`-Wno-switch-unreachable` :option:`-Wsync-nand` |gol| + :option:`-Wsystem-headers` :option:`-Wtautological-compare` :option:`-Wtrampolines` :option:`-Wtrigraphs` |gol| + :option:`-Wtrivial-auto-var-init` :option:`-Wtsan` :option:`-Wtype-limits` :option:`-Wundef` |gol| + :option:`-Wuninitialized` :option:`-Wunknown-pragmas` |gol| + :option:`-Wunsuffixed-float-constants` :option:`-Wunused` |gol| + :option:`-Wunused-but-set-parameter` :option:`-Wunused-but-set-variable` |gol| + :option:`-Wunused-const-variable` :option:`-Wunused-const-variable=n` |gol| + :option:`-Wunused-function` :option:`-Wunused-label` :option:`-Wunused-local-typedefs` |gol| + :option:`-Wunused-macros` |gol| + :option:`-Wunused-parameter` :option:`-Wno-unused-result` |gol| + :option:`-Wunused-value` :option:`-Wunused-variable` |gol| + :option:`-Wno-varargs` :option:`-Wvariadic-macros` |gol| + :option:`-Wvector-operation-performance` |gol| + :option:`-Wvla` :option:`-Wvla-larger-than=byte-size` :option:`-Wno-vla-larger-than` |gol| + :option:`-Wvolatile-register-var` :option:`-Wwrite-strings` |gol| + :option:`-Wxor-used-as-pow` |gol| + :option:`-Wzero-length-bounds` + +*Static Analyzer Options* + + :option:`-fanalyzer` |gol| + :option:`-fanalyzer-call-summaries` |gol| + :option:`-fanalyzer-checker=name` |gol| + :option:`-fno-analyzer-feasibility` |gol| + :option:`-fanalyzer-fine-grained` |gol| + :option:`-fno-analyzer-state-merge` |gol| + :option:`-fno-analyzer-state-purge` |gol| + :option:`-fanalyzer-transitivity` |gol| + :option:`-fno-analyzer-undo-inlining` |gol| + :option:`-fanalyzer-verbose-edges` |gol| + :option:`-fanalyzer-verbose-state-changes` |gol| + :option:`-fanalyzer-verbosity=level` |gol| + :option:`-fdump-analyzer` |gol| + :option:`-fdump-analyzer-callgraph` |gol| + :option:`-fdump-analyzer-exploded-graph` |gol| + :option:`-fdump-analyzer-exploded-nodes` |gol| + :option:`-fdump-analyzer-exploded-nodes-2` |gol| + :option:`-fdump-analyzer-exploded-nodes-3` |gol| + :option:`-fdump-analyzer-exploded-paths` |gol| + :option:`-fdump-analyzer-feasibility` |gol| + :option:`-fdump-analyzer-json` |gol| + :option:`-fdump-analyzer-state-purge` |gol| + :option:`-fdump-analyzer-stderr` |gol| + :option:`-fdump-analyzer-supergraph` |gol| + :option:`-fdump-analyzer-untracked` |gol| + :option:`-Wno-analyzer-double-fclose` |gol| + :option:`-Wno-analyzer-double-free` |gol| + :option:`-Wno-analyzer-exposure-through-output-file` |gol| + :option:`-Wno-analyzer-exposure-through-uninit-copy` |gol| + :option:`-Wno-analyzer-fd-access-mode-mismatch` |gol| + :option:`-Wno-analyzer-fd-double-close` |gol| + :option:`-Wno-analyzer-fd-leak` |gol| + :option:`-Wno-analyzer-fd-use-after-close` |gol| + :option:`-Wno-analyzer-fd-use-without-check` |gol| + :option:`-Wno-analyzer-file-leak` |gol| + :option:`-Wno-analyzer-free-of-non-heap` |gol| + :option:`-Wno-analyzer-imprecise-fp-arithmetic` |gol| + :option:`-Wno-analyzer-jump-through-null` |gol| + :option:`-Wno-analyzer-malloc-leak` |gol| + :option:`-Wno-analyzer-mismatching-deallocation` |gol| + :option:`-Wno-analyzer-null-argument` |gol| + :option:`-Wno-analyzer-null-dereference` |gol| + :option:`-Wno-analyzer-out-of-bounds` |gol| + :option:`-Wno-analyzer-possible-null-argument` |gol| + :option:`-Wno-analyzer-possible-null-dereference` |gol| + :option:`-Wno-analyzer-putenv-of-auto-var` |gol| + :option:`-Wno-analyzer-shift-count-negative` |gol| + :option:`-Wno-analyzer-shift-count-overflow` |gol| + :option:`-Wno-analyzer-stale-setjmp-buffer` |gol| + :option:`-Wno-analyzer-tainted-allocation-size` |gol| + :option:`-Wno-analyzer-tainted-array-index` |gol| + :option:`-Wno-analyzer-tainted-divisor` |gol| + :option:`-Wno-analyzer-tainted-offset` |gol| + :option:`-Wno-analyzer-tainted-size` |gol| + :option:`-Wanalyzer-too-complex` |gol| + :option:`-Wno-analyzer-unsafe-call-within-signal-handler` |gol| + :option:`-Wno-analyzer-use-after-free` |gol| + :option:`-Wno-analyzer-use-of-pointer-in-stale-stack-frame` |gol| + :option:`-Wno-analyzer-use-of-uninitialized-value` |gol| + :option:`-Wno-analyzer-va-arg-type-mismatch` |gol| + :option:`-Wno-analyzer-va-list-exhausted` |gol| + :option:`-Wno-analyzer-va-list-leak` |gol| + :option:`-Wno-analyzer-va-list-use-after-va-end` |gol| + :option:`-Wno-analyzer-write-to-const` |gol| + :option:`-Wno-analyzer-write-to-string-literal` + +*C and Objective-C-only Warning Options* + + :option:`-Wbad-function-cast` :option:`-Wmissing-declarations` |gol| + :option:`-Wmissing-parameter-type` :option:`-Wmissing-prototypes` :option:`-Wnested-externs` |gol| + :option:`-Wold-style-declaration` :option:`-Wold-style-definition` |gol| + :option:`-Wstrict-prototypes` :option:`-Wtraditional` :option:`-Wtraditional-conversion` |gol| + :option:`-Wdeclaration-after-statement` :option:`-Wpointer-sign` + +*Debugging Options* + + See :ref:`debugging-options`. + + :option:`-g` :option:`-glevel` :option:`-gdwarf` :option:`-gdwarf-version` |gol| + :option:`-gbtf` :option:`-gctf` :option:`-gctflevel` |gol| + :option:`-ggdb` :option:`-grecord-gcc-switches` :option:`-gno-record-gcc-switches` |gol| + :option:`-gstrict-dwarf` :option:`-gno-strict-dwarf` |gol| + :option:`-gas-loc-support` :option:`-gno-as-loc-support` |gol| + :option:`-gas-locview-support` :option:`-gno-as-locview-support` |gol| + :option:`-gcolumn-info` :option:`-gno-column-info` :option:`-gdwarf32` :option:`-gdwarf64` |gol| + :option:`-gstatement-frontiers` :option:`-gno-statement-frontiers` |gol| + :option:`-gvariable-location-views` :option:`-gno-variable-location-views` |gol| + :option:`-ginternal-reset-location-views` :option:`-gno-internal-reset-location-views` |gol| + :option:`-ginline-points` :option:`-gno-inline-points` |gol| + :option:`-gvms` :option:`-gz=type` |gol| + :option:`-gsplit-dwarf` :option:`-gdescribe-dies` :option:`-gno-describe-dies` |gol| + :option:`-fdebug-prefix-map=old=new` :option:`-fdebug-types-section` |gol| + :option:`-fno-eliminate-unused-debug-types` |gol| + :option:`-femit-struct-debug-baseonly` :option:`-femit-struct-debug-reduced` |gol| + :option:`-femit-struct-debug-detailed[=spec-list]` |gol| + :option:`-fno-eliminate-unused-debug-symbols` :option:`-femit-class-debug-always` |gol| + :option:`-fno-merge-debug-strings` :option:`-fno-dwarf2-cfi-asm` |gol| + :option:`-fvar-tracking` :option:`-fvar-tracking-assignments` + +*Optimization Options* + + See :ref:`optimize-options`. + + :option:`-faggressive-loop-optimizations` |gol| + :option:`-falign-functions[=n[m:[n2[:m2]]]]` |gol| + :option:`-falign-jumps[=n[m:[n2[:m2]]]]` |gol| + :option:`-falign-labels[=n[m:[n2[:m2]]]]` |gol| + :option:`-falign-loops[=n[m:[n2[:m2]]]]` |gol| + :option:`-fno-allocation-dce` :option:`-fallow-store-data-races` |gol| + :option:`-fassociative-math` :option:`-fauto-profile` :option:`-fauto-profile[=path]` |gol| + :option:`-fauto-inc-dec` :option:`-fbranch-probabilities` |gol| + :option:`-fcaller-saves` |gol| + :option:`-fcombine-stack-adjustments` :option:`-fconserve-stack` |gol| + :option:`-fcompare-elim` :option:`-fcprop-registers` :option:`-fcrossjumping` |gol| + :option:`-fcse-follow-jumps` :option:`-fcse-skip-blocks` :option:`-fcx-fortran-rules` |gol| + :option:`-fcx-limited-range` |gol| + :option:`-fdata-sections` :option:`-fdce` :option:`-fdelayed-branch` |gol| + :option:`-fdelete-null-pointer-checks` :option:`-fdevirtualize` :option:`-fdevirtualize-speculatively` |gol| + :option:`-fdevirtualize-at-ltrans` :option:`-fdse` |gol| + :option:`-fearly-inlining` :option:`-fipa-sra` :option:`-fexpensive-optimizations` :option:`-ffat-lto-objects` |gol| + :option:`-ffast-math` :option:`-ffinite-math-only` :option:`-ffloat-store` :option:`-fexcess-precision=style` |gol| + :option:`-ffinite-loops` |gol| + :option:`-fforward-propagate` :option:`-ffp-contract=style` :option:`-ffunction-sections` |gol| + :option:`-fgcse` :option:`-fgcse-after-reload` :option:`-fgcse-las` :option:`-fgcse-lm` :option:`-fgraphite-identity` |gol| + :option:`-fgcse-sm` :option:`-fhoist-adjacent-loads` :option:`-fif-conversion` |gol| + :option:`-fif-conversion2` :option:`-findirect-inlining` |gol| + :option:`-finline-functions` :option:`-finline-functions-called-once` :option:`-finline-limit=n` |gol| + :option:`-finline-small-functions` :option:`-fipa-modref` :option:`-fipa-cp` :option:`-fipa-cp-clone` |gol| + :option:`-fipa-bit-cp` :option:`-fipa-vrp` :option:`-fipa-pta` :option:`-fipa-profile` :option:`-fipa-pure-const` |gol| + :option:`-fipa-reference` :option:`-fipa-reference-addressable` |gol| + :option:`-fipa-stack-alignment` :option:`-fipa-icf` :option:`-fira-algorithm=algorithm` |gol| + :option:`-flive-patching=level` |gol| + :option:`-fira-region=region` :option:`-fira-hoist-pressure` |gol| + :option:`-fira-loop-pressure` :option:`-fno-ira-share-save-slots` |gol| + :option:`-fno-ira-share-spill-slots` |gol| + :option:`-fisolate-erroneous-paths-dereference` :option:`-fisolate-erroneous-paths-attribute` |gol| + :option:`-fivopts` :option:`-fkeep-inline-functions` :option:`-fkeep-static-functions` |gol| + :option:`-fkeep-static-consts` :option:`-flimit-function-alignment` :option:`-flive-range-shrinkage` |gol| + :option:`-floop-block` :option:`-floop-interchange` :option:`-floop-strip-mine` |gol| + :option:`-floop-unroll-and-jam` :option:`-floop-nest-optimize` |gol| + :option:`-floop-parallelize-all` :option:`-flra-remat` :option:`-flto` :option:`-flto-compression-level` |gol| + :option:`-flto-partition=alg` :option:`-fmerge-all-constants` |gol| + :option:`-fmerge-constants` :option:`-fmodulo-sched` :option:`-fmodulo-sched-allow-regmoves` |gol| + :option:`-fmove-loop-invariants` :option:`-fmove-loop-stores` :option:`-fno-branch-count-reg` |gol| + :option:`-fno-defer-pop` :option:`-fno-fp-int-builtin-inexact` :option:`-fno-function-cse` |gol| + :option:`-fno-guess-branch-probability` :option:`-fno-inline` :option:`-fno-math-errno` :option:`-fno-peephole` |gol| + :option:`-fno-peephole2` :option:`-fno-printf-return-value` :option:`-fno-sched-interblock` |gol| + :option:`-fno-sched-spec` :option:`-fno-signed-zeros` |gol| + :option:`-fno-toplevel-reorder` :option:`-fno-trapping-math` :option:`-fno-zero-initialized-in-bss` |gol| + :option:`-fomit-frame-pointer` :option:`-foptimize-sibling-calls` |gol| + :option:`-fpartial-inlining` :option:`-fpeel-loops` :option:`-fpredictive-commoning` |gol| + :option:`-fprefetch-loop-arrays` |gol| + :option:`-fprofile-correction` |gol| + :option:`-fprofile-use` :option:`-fprofile-use=path` :option:`-fprofile-partial-training` |gol| + :option:`-fprofile-values` :option:`-fprofile-reorder-functions` |gol| + :option:`-freciprocal-math` :option:`-free` :option:`-frename-registers` :option:`-freorder-blocks` |gol| + :option:`-freorder-blocks-algorithm=algorithm` |gol| + :option:`-freorder-blocks-and-partition` :option:`-freorder-functions` |gol| + :option:`-frerun-cse-after-loop` :option:`-freschedule-modulo-scheduled-loops` |gol| + :option:`-frounding-math` :option:`-fsave-optimization-record` |gol| + :option:`-fsched2-use-superblocks` :option:`-fsched-pressure` |gol| + :option:`-fsched-spec-load` :option:`-fsched-spec-load-dangerous` |gol| + :option:`-fsched-stalled-insns-dep[=n]` :option:`-fsched-stalled-insns[=n]` |gol| + :option:`-fsched-group-heuristic` :option:`-fsched-critical-path-heuristic` |gol| + :option:`-fsched-spec-insn-heuristic` :option:`-fsched-rank-heuristic` |gol| + :option:`-fsched-last-insn-heuristic` :option:`-fsched-dep-count-heuristic` |gol| + :option:`-fschedule-fusion` |gol| + :option:`-fschedule-insns` :option:`-fschedule-insns2` :option:`-fsection-anchors` |gol| + :option:`-fselective-scheduling` :option:`-fselective-scheduling2` |gol| + :option:`-fsel-sched-pipelining` :option:`-fsel-sched-pipelining-outer-loops` |gol| + :option:`-fsemantic-interposition` :option:`-fshrink-wrap` :option:`-fshrink-wrap-separate` |gol| + :option:`-fsignaling-nans` |gol| + :option:`-fsingle-precision-constant` :option:`-fsplit-ivs-in-unroller` :option:`-fsplit-loops` |gol| + :option:`-fsplit-paths` |gol| + :option:`-fsplit-wide-types` :option:`-fsplit-wide-types-early` :option:`-fssa-backprop` :option:`-fssa-phiopt` |gol| + :option:`-fstdarg-opt` :option:`-fstore-merging` :option:`-fstrict-aliasing` :option:`-fipa-strict-aliasing` |gol| + :option:`-fthread-jumps` :option:`-ftracer` :option:`-ftree-bit-ccp` |gol| + :option:`-ftree-builtin-call-dce` :option:`-ftree-ccp` :option:`-ftree-ch` |gol| + :option:`-ftree-coalesce-vars` :option:`-ftree-copy-prop` :option:`-ftree-dce` :option:`-ftree-dominator-opts` |gol| + :option:`-ftree-dse` :option:`-ftree-forwprop` :option:`-ftree-fre` :option:`-fcode-hoisting` |gol| + :option:`-ftree-loop-if-convert` :option:`-ftree-loop-im` |gol| + :option:`-ftree-phiprop` :option:`-ftree-loop-distribution` :option:`-ftree-loop-distribute-patterns` |gol| + :option:`-ftree-loop-ivcanon` :option:`-ftree-loop-linear` :option:`-ftree-loop-optimize` |gol| + :option:`-ftree-loop-vectorize` |gol| + :option:`-ftree-parallelize-loops=n` :option:`-ftree-pre` :option:`-ftree-partial-pre` :option:`-ftree-pta` |gol| + :option:`-ftree-reassoc` :option:`-ftree-scev-cprop` :option:`-ftree-sink` :option:`-ftree-slsr` :option:`-ftree-sra` |gol| + :option:`-ftree-switch-conversion` :option:`-ftree-tail-merge` |gol| + :option:`-ftree-ter` :option:`-ftree-vectorize` :option:`-ftree-vrp` :option:`-ftrivial-auto-var-init` |gol| + :option:`-funconstrained-commons` :option:`-funit-at-a-time` :option:`-funroll-all-loops` |gol| + :option:`-funroll-loops` :option:`-funsafe-math-optimizations` :option:`-funswitch-loops` |gol| + :option:`-fipa-ra` :option:`-fvariable-expansion-in-unroller` :option:`-fvect-cost-model` :option:`-fvpt` |gol| + :option:`-fweb` :option:`-fwhole-program` :option:`-fwpa` :option:`-fuse-linker-plugin` :option:`-fzero-call-used-regs` |gol| + :option:`--param` :samp:`{name}={value}` |gol| + :option:`-O` :option:`-O0` :option:`-O1` :option:`-O2` :option:`-O3` :option:`-Os` :option:`-Ofast` :option:`-Og` :option:`-Oz` + +*Program Instrumentation Options* + + See :ref:`instrumentation-options`. + + :option:`-p` :option:`-pg` :option:`-fprofile-arcs` :option:`--coverage` :option:`-ftest-coverage` |gol| + :option:`-fprofile-abs-path` |gol| + :option:`-fprofile-dir=path` :option:`-fprofile-generate` :option:`-fprofile-generate=path` |gol| + :option:`-fprofile-info-section` :option:`-fprofile-info-section=name` |gol| + :option:`-fprofile-note=path` :option:`-fprofile-prefix-path=path` |gol| + :option:`-fprofile-update=method` :option:`-fprofile-filter-files=regex` |gol| + :option:`-fprofile-exclude-files=regex` |gol| + :option:`-fprofile-reproducible=[multithreaded|parallel-runs|serial]` |gol| + :option:`-fsanitize=style` :option:`-fsanitize-recover` :option:`-fsanitize-recover=style` |gol| + :option:`-fsanitize-trap` :option:`-fsanitize-trap=style` |gol| + :option:`-fasan-shadow-offset=number` :option:`-fsanitize-sections=s1,s2,...` |gol| + :option:`-fsanitize-undefined-trap-on-error` :option:`-fbounds-check` |gol| + :option:`-fcf-protection=[full|branch|return|none|check]` |gol| + :option:`-fharden-compares` :option:`-fharden-conditional-branches` |gol| + :option:`-fstack-protector` :option:`-fstack-protector-all` :option:`-fstack-protector-strong` |gol| + :option:`-fstack-protector-explicit` :option:`-fstack-check` |gol| + :option:`-fstack-limit-register=reg` :option:`-fstack-limit-symbol=sym` |gol| + :option:`-fno-stack-limit` :option:`-fsplit-stack` |gol| + :option:`-fvtable-verify=[std|preinit|none]` |gol| + :option:`-fvtv-counts` :option:`-fvtv-debug` |gol| + :option:`-finstrument-functions` :option:`-finstrument-functions-once` |gol| + :option:`-finstrument-functions-exclude-function-list=sym,sym,...` |gol| + :option:`-finstrument-functions-exclude-file-list=file,file,...` |gol| + :option:`-fprofile-prefix-map=old=new` + +*Preprocessor Options* + + See :ref:`preprocessor-options`. + + :option:`-Aquestion=answer` |gol| + :option:`-A-question[=answer]` |gol| + :option:`-C` :option:`-CC` :option:`-Dmacro[=defn]` |gol| + :option:`-dD` :option:`-dI` :option:`-dM` :option:`-dN` :option:`-dU` |gol| + :option:`-fdebug-cpp` :option:`-fdirectives-only` :option:`-fdollars-in-identifiers` |gol| + :option:`-fexec-charset=charset` :option:`-fextended-identifiers` |gol| + :option:`-finput-charset=charset` :option:`-flarge-source-files` |gol| + :option:`-fmacro-prefix-map=old=new` :option:`-fmax-include-depth=depth` |gol| + :option:`-fno-canonical-system-headers` :option:`-fpch-deps` :option:`-fpch-preprocess` |gol| + :option:`-fpreprocessed` :option:`-ftabstop=width` :option:`-ftrack-macro-expansion` |gol| + :option:`-fwide-exec-charset=charset` :option:`-fworking-directory` |gol| + :option:`-H` :option:`-imacros` :samp:`{file}` :option:`-include` :samp:`{file}` |gol| + :option:`-M` :option:`-MD` :option:`-MF` :option:`-MG` :option:`-MM` :option:`-MMD` :option:`-MP` :option:`-MQ` :option:`-MT` :option:`-Mno-modules` |gol| + :option:`-no-integrated-cpp` :option:`-P` :option:`-pthread` :option:`-remap` |gol| + :option:`-traditional` :option:`-traditional-cpp` :option:`-trigraphs` |gol| + :option:`-Umacro` :option:`-undef` |gol| + :option:`-Wp,option` :option:`-Xpreprocessor` :samp:`{option}` + +*Assembler Options* + + See :ref:`assembler-options`. + + :option:`-Wa,option` :option:`-Xassembler` :samp:`{option}` + +*Linker Options* + + See :ref:`link-options`. + + :samp:`{object-file-name}` :option:`-fuse-ld=linker` :option:`-llibrary` |gol| + :option:`-nostartfiles` :option:`-nodefaultlibs` :option:`-nolibc` :option:`-nostdlib` :option:`-nostdlib++` |gol| + :option:`-e` :samp:`{entry}` :option:`--entry=entry` |gol| + :option:`-pie` :option:`-pthread` :option:`-r` :option:`-rdynamic` |gol| + :option:`-s` :option:`-static` :option:`-static-pie` :option:`-static-libgcc` :option:`-static-libstdc++` |gol| + :option:`-static-libasan` :option:`-static-libtsan` :option:`-static-liblsan` :option:`-static-libubsan` |gol| + :option:`-shared` :option:`-shared-libgcc` :option:`-symbolic` |gol| + :option:`-T` :samp:`{script}` :option:`-Wl,option` :option:`-Xlinker` :samp:`{option}` |gol| + :option:`-u` :samp:`{symbol}` :option:`-z` :samp:`{keyword}` + +*Directory Options* + + See :ref:`directory-options`. + + :option:`-Bprefix` :option:`-Idir` :option:`-I-` |gol| + :option:`-idirafter` :samp:`{dir}` |gol| + :option:`-imacros` :samp:`{file}` :option:`-imultilib` :samp:`{dir}` |gol| + :option:`-iplugindir=dir` :option:`-iprefix` :samp:`{file}` |gol| + :option:`-iquote` :samp:`{dir}` :option:`-isysroot` :samp:`{dir}` :option:`-isystem` :samp:`{dir}` |gol| + :option:`-iwithprefix` :samp:`{dir}` :option:`-iwithprefixbefore` :samp:`{dir}` |gol| + :option:`-Ldir` :option:`-no-canonical-prefixes` :option:`--no-sysroot-suffix` |gol| + :option:`-nostdinc` :option:`-nostdinc++` :option:`--sysroot=dir` + +*Code Generation Options* + + See :ref:`code-gen-options`. + + :option:`-fcall-saved-reg` :option:`-fcall-used-reg` |gol| + :option:`-ffixed-reg` :option:`-fexceptions` |gol| + :option:`-fnon-call-exceptions` :option:`-fdelete-dead-exceptions` :option:`-funwind-tables` |gol| + :option:`-fasynchronous-unwind-tables` |gol| + :option:`-fno-gnu-unique` |gol| + :option:`-finhibit-size-directive` :option:`-fcommon` :option:`-fno-ident` |gol| + :option:`-fpcc-struct-return` :option:`-fpic` :option:`-fPIC` :option:`-fpie` :option:`-fPIE` :option:`-fno-plt` |gol| + :option:`-fno-jump-tables` :option:`-fno-bit-tests` |gol| + :option:`-frecord-gcc-switches` |gol| + :option:`-freg-struct-return` :option:`-fshort-enums` :option:`-fshort-wchar` |gol| + :option:`-fverbose-asm` :option:`-fpack-struct[=n]` |gol| + :option:`-fleading-underscore` :option:`-ftls-model=model` |gol| + :option:`-fstack-reuse=reuse_level` |gol| + :option:`-ftrampolines` :option:`-ftrapv` :option:`-fwrapv` |gol| + :option:`-fvisibility=[default|internal|hidden|protected]` |gol| + :option:`-fstrict-volatile-bitfields` :option:`-fsync-libcalls` + +*Developer Options* + + See :ref:`developer-options`. + + :option:`-dletters` :option:`-dumpspecs` :option:`-dumpmachine` :option:`-dumpversion` |gol| + :option:`-dumpfullversion` :option:`-fcallgraph-info[=su,da]` |gol| + :option:`-fchecking` :option:`-fchecking=n` |gol| + :option:`-fdbg-cnt-list` :option:`-fdbg-cnt=counter-value-list` |gol| + :option:`-fdisable-ipa-pass_name` |gol| + :option:`-fdisable-rtl-pass_name` |gol| + :option:`-fdisable-rtl-pass-name=range-list` |gol| + :option:`-fdisable-tree-pass_name` |gol| + :option:`-fdisable-tree-pass-name=range-list` |gol| + :option:`-fdump-debug` :option:`-fdump-earlydebug` |gol| + :option:`-fdump-noaddr` :option:`-fdump-unnumbered` :option:`-fdump-unnumbered-links` |gol| + :option:`-fdump-final-insns[=file]` |gol| + :option:`-fdump-ipa-all` :option:`-fdump-ipa-cgraph` :option:`-fdump-ipa-inline` |gol| + :option:`-fdump-lang-all` |gol| + :option:`-fdump-lang-switch` |gol| + :option:`-fdump-lang-switch`:samp:`-{options}` |gol| + :option:`-fdump-lang-switch`:samp:`-{options}={filename}` |gol| + :option:`-fdump-passes` |gol| + :option:`-fdump-rtl-pass` :option:`-fdump-rtl-pass=filename` |gol| + :option:`-fdump-statistics` |gol| + :option:`-fdump-tree-all` |gol| + :option:`-fdump-tree-switch` |gol| + :option:`-fdump-tree-switch`:samp:`-{options}` |gol| + :option:`-fdump-tree-switch`:samp:`-{options}={filename}` |gol| + :option:`-fcompare-debug[=opts]` :option:`-fcompare-debug-second` |gol| + :option:`-fenable-kind`:samp:`-{pass}` |gol| + :option:`-fenable-kind`:samp:`-{pass}={range-list}` |gol| + :option:`-fira-verbose=n` |gol| + :option:`-flto-report` :option:`-flto-report-wpa` :option:`-fmem-report-wpa` |gol| + :option:`-fmem-report` :option:`-fpre-ipa-mem-report` :option:`-fpost-ipa-mem-report` |gol| + :option:`-fopt-info` :option:`-fopt-info-options[=file]` |gol| + :option:`-fmultiflags` :option:`-fprofile-report` |gol| + :option:`-frandom-seed=string` :option:`-fsched-verbose=n` |gol| + :option:`-fsel-sched-verbose` :option:`-fsel-sched-dump-cfg` :option:`-fsel-sched-pipelining-verbose` |gol| + :option:`-fstats` :option:`-fstack-usage` :option:`-ftime-report` :option:`-ftime-report-details` |gol| + :option:`-fvar-tracking-assignments-toggle` :option:`-gtoggle` |gol| + :option:`-print-file-name=library` :option:`-print-libgcc-file-name` |gol| + :option:`-print-multi-directory` :option:`-print-multi-lib` :option:`-print-multi-os-directory` |gol| + :option:`-print-prog-name=program` :option:`-print-search-dirs` :option:`-Q` |gol| + :option:`-print-sysroot` :option:`-print-sysroot-headers-suffix` |gol| + :option:`-save-temps` :option:`-save-temps=cwd` :option:`-save-temps=obj` :option:`-time[=file]` + +*Machine-Dependent Options* + + See :ref:`submodel-options`. + + .. This list is ordered alphanumerically by subsection name. + Try and put the significant identifier (CPU or system) first, + so users have a clue at guessing where the ones they want will be. + + *AArch64 Options* + + .. program:: AArch64 + + :option:`-mabi=name` :option:`-mbig-endian` :option:`-mlittle-endian` |gol| + :option:`-mgeneral-regs-only` |gol| + :option:`-mcmodel=tiny` :option:`-mcmodel=small` :option:`-mcmodel=large` |gol| + :option:`-mstrict-align` :option:`-mno-strict-align` |gol| + :option:`-momit-leaf-frame-pointer` |gol| + :option:`-mtls-dialect=desc` :option:`-mtls-dialect=traditional` |gol| + :option:`-mtls-size=size` |gol| + :option:`-mfix-cortex-a53-835769` :option:`-mfix-cortex-a53-843419` |gol| + :option:`-mlow-precision-recip-sqrt` :option:`-mlow-precision-sqrt` :option:`-mlow-precision-div` |gol| + :option:`-mpc-relative-literal-loads` |gol| + :option:`-msign-return-address=scope` |gol| + :option:`-mbranch-protection=none|standard|pac-ret[+leaf+b-key|bti]` |gol| + :option:`-mharden-sls=opts` |gol| + :option:`-march=name` :option:`-mcpu=name` :option:`-mtune=name` |gol| + :option:`-moverride=string` :option:`-mverbose-cost-dump` |gol| + :option:`-mstack-protector-guard=guard` :option:`-mstack-protector-guard-reg=sysreg` |gol| + :option:`-mstack-protector-guard-offset=offset` :option:`-mtrack-speculation` |gol| + :option:`-moutline-atomics` + + *Adapteva Epiphany Options* + + .. program:: Adapteva Epiphany + + :option:`-mhalf-reg-file` :option:`-mprefer-short-insn-regs` |gol| + :option:`-mbranch-cost=num` :option:`-mcmove` :option:`-mnops=num` :option:`-msoft-cmpsf` |gol| + :option:`-msplit-lohi` :option:`-mpost-inc` :option:`-mpost-modify` :option:`-mstack-offset=num` |gol| + :option:`-mround-nearest` :option:`-mlong-calls` :option:`-mshort-calls` :option:`-msmall16` |gol| + :option:`-mfp-mode=mode` :option:`-mvect-double` :option:`-max-vect-align=num` |gol| + :option:`-msplit-vecmove-early` :option:`-m1reg-reg` + + *AMD GCN Options* + + .. program:: AMD GCN + + :option:`-march=gpu` :option:`-mtune=gpu` :option:`-mstack-size=bytes` + + *ARC Options* + + .. program:: ARC + + :option:`-mbarrel-shifter` :option:`-mjli-always` |gol| + :option:`-mcpu=cpu` :option:`-mA6` :option:`-mARC600` :option:`-mA7` :option:`-mARC700` |gol| + :option:`-mdpfp` :option:`-mdpfp-compact` :option:`-mdpfp-fast` :option:`-mno-dpfp-lrsr` |gol| + :option:`-mea` :option:`-mno-mpy` :option:`-mmul32x16` :option:`-mmul64` :option:`-matomic` |gol| + :option:`-mnorm` :option:`-mspfp` :option:`-mspfp-compact` :option:`-mspfp-fast` :option:`-msimd` :option:`-msoft-float` :option:`-mswap` |gol| + :option:`-mcrc` :option:`-mdsp-packa` :option:`-mdvbf` :option:`-mlock` :option:`-mmac-d16` :option:`-mmac-24` :option:`-mrtsc` :option:`-mswape` |gol| + :option:`-mtelephony` :option:`-mxy` :option:`-misize` :option:`-mannotate-align` :option:`-marclinux` :option:`-marclinux_prof` |gol| + :option:`-mlong-calls` :option:`-mmedium-calls` :option:`-msdata` :option:`-mirq-ctrl-saved` |gol| + :option:`-mrgf-banked-regs` :option:`-mlpc-width=width` :option:`-G num` |gol| + :option:`-mvolatile-cache` :option:`-mtp-regno=regno` |gol| + :option:`-malign-call` :option:`-mauto-modify-reg` :option:`-mbbit-peephole` :option:`-mno-brcc` |gol| + :option:`-mcase-vector-pcrel` :option:`-mcompact-casesi` :option:`-mno-cond-exec` :option:`-mearly-cbranchsi` |gol| + :option:`-mexpand-adddi` :option:`-mindexed-loads` :option:`-mlra` :option:`-mlra-priority-none` |gol| + :option:`-mlra-priority-compact` :option:`-mlra-priority-noncompact` :option:`-mmillicode` |gol| + :option:`-mmixed-code` :option:`-mq-class` :option:`-mRcq` :option:`-mRcw` :option:`-msize-level=level` |gol| + :option:`-mtune=cpu` :option:`-mmultcost=num` :option:`-mcode-density-frame` |gol| + :option:`-munalign-prob-threshold=probability` :option:`-mmpy-option=multo` |gol| + :option:`-mdiv-rem` :option:`-mcode-density` :option:`-mll64` :option:`-mfpu=fpu` :option:`-mrf16` :option:`-mbranch-index` + + *ARM Options* + + .. program:: ARM + + :option:`-mapcs-frame` :option:`-mno-apcs-frame` |gol| + :option:`-mabi=name` |gol| + :option:`-mapcs-stack-check` :option:`-mno-apcs-stack-check` |gol| + :option:`-mapcs-reentrant` :option:`-mno-apcs-reentrant` |gol| + :option:`-mgeneral-regs-only` |gol| + :option:`-msched-prolog` :option:`-mno-sched-prolog` |gol| + :option:`-mlittle-endian` :option:`-mbig-endian` |gol| + :option:`-mbe8` :option:`-mbe32` |gol| + :option:`-mfloat-abi=name` |gol| + :option:`-mfp16-format=name` |gol| + :option:`-mthumb-interwork` :option:`-mno-thumb-interwork` |gol| + :option:`-mcpu=name` :option:`-march=name` :option:`-mfpu=name` |gol| + :option:`-mtune=name` :option:`-mprint-tune-info` |gol| + :option:`-mstructure-size-boundary=n` |gol| + :option:`-mabort-on-noreturn` |gol| + :option:`-mlong-calls` :option:`-mno-long-calls` |gol| + :option:`-msingle-pic-base` :option:`-mno-single-pic-base` |gol| + :option:`-mpic-register=reg` |gol| + :option:`-mnop-fun-dllimport` |gol| + :option:`-mpoke-function-name` |gol| + :option:`-mthumb` :option:`-marm` :option:`-mflip-thumb` |gol| + :option:`-mtpcs-frame` :option:`-mtpcs-leaf-frame` |gol| + :option:`-mcaller-super-interworking` :option:`-mcallee-super-interworking` |gol| + :option:`-mtp=name` :option:`-mtls-dialect=dialect` |gol| + :option:`-mword-relocations` |gol| + :option:`-mfix-cortex-m3-ldrd` |gol| + :option:`-mfix-cortex-a57-aes-1742098` |gol| + :option:`-mfix-cortex-a72-aes-1655431` |gol| + :option:`-munaligned-access` |gol| + :option:`-mneon-for-64bits` |gol| + :option:`-mslow-flash-data` |gol| + :option:`-masm-syntax-unified` |gol| + :option:`-mrestrict-it` |gol| + :option:`-mverbose-cost-dump` |gol| + :option:`-mpure-code` |gol| + :option:`-mcmse` |gol| + :option:`-mfix-cmse-cve-2021-35465` |gol| + :option:`-mstack-protector-guard=guard` :option:`-mstack-protector-guard-offset=offset` |gol| + :option:`-mfdpic` + + *AVR Options* + + .. program:: AVR + + :option:`-mmcu=mcu` :option:`-mabsdata` :option:`-maccumulate-args` |gol| + :option:`-mbranch-cost=cost` |gol| + :option:`-mcall-prologues` :option:`-mgas-isr-prologues` :option:`-mint8` |gol| + :option:`-mdouble=bits` :option:`-mlong-double=bits` |gol| + :option:`-mn_flash=size` :option:`-mno-interrupts` |gol| + :option:`-mmain-is-OS_task` :option:`-mrelax` :option:`-mrmw` :option:`-mstrict-X` :option:`-mtiny-stack` |gol| + :option:`-mfract-convert-truncate` |gol| + :option:`-mshort-calls` :option:`-nodevicelib` :option:`-nodevicespecs` |gol| + :option:`-Waddr-space-convert` :option:`-Wmisspelled-isr` + + *Blackfin Options* + + .. program:: Blackfin + + :option:`-mcpu=cpu[-sirevision]` |gol| + :option:`-msim` :option:`-momit-leaf-frame-pointer` :option:`-mno-omit-leaf-frame-pointer` |gol| + :option:`-mspecld-anomaly` :option:`-mno-specld-anomaly` :option:`-mcsync-anomaly` :option:`-mno-csync-anomaly` |gol| + :option:`-mlow-64k` :option:`-mno-low64k` :option:`-mstack-check-l1` :option:`-mid-shared-library` |gol| + :option:`-mno-id-shared-library` :option:`-mshared-library-id=n` |gol| + :option:`-mleaf-id-shared-library` :option:`-mno-leaf-id-shared-library` |gol| + :option:`-msep-data` :option:`-mno-sep-data` :option:`-mlong-calls` :option:`-mno-long-calls` |gol| + :option:`-mfast-fp` :option:`-minline-plt` :option:`-mmulticore` :option:`-mcorea` :option:`-mcoreb` :option:`-msdram` |gol| + :option:`-micplb` + + *C6X Options* + + .. program:: C6X + + :option:`-mbig-endian` :option:`-mlittle-endian` :option:`-march=cpu` |gol| + :option:`-msim` :option:`-msdata=sdata-type` + + *CRIS Options* + + .. program:: CRIS + + :option:`-mcpu=cpu` :option:`-march=cpu` |gol| + :option:`-mtune=cpu` :option:`-mmax-stack-frame=n` |gol| + :option:`-metrax4` :option:`-metrax100` :option:`-mpdebug` :option:`-mcc-init` :option:`-mno-side-effects` |gol| + :option:`-mstack-align` :option:`-mdata-align` :option:`-mconst-align` |gol| + :option:`-m32-bit` :option:`-m16-bit` :option:`-m8-bit` :option:`-mno-prologue-epilogue` |gol| + :option:`-melf` :option:`-maout` :option:`-sim` :option:`-sim2` |gol| + :option:`-mmul-bug-workaround` :option:`-mno-mul-bug-workaround` + + *C-SKY Options* + + .. program:: C-SKY + + :option:`-march=arch` :option:`-mcpu=cpu` |gol| + :option:`-mbig-endian` :option:`-EB` :option:`-mlittle-endian` :option:`-EL` |gol| + :option:`-mhard-float` :option:`-msoft-float` :option:`-mfpu=fpu` :option:`-mdouble-float` :option:`-mfdivdu` |gol| + :option:`-mfloat-abi=name` |gol| + :option:`-melrw` :option:`-mistack` :option:`-mmp` :option:`-mcp` :option:`-mcache` :option:`-msecurity` :option:`-mtrust` |gol| + :option:`-mdsp` :option:`-medsp` :option:`-mvdsp` |gol| + :option:`-mdiv` :option:`-msmart` :option:`-mhigh-registers` :option:`-manchor` |gol| + :option:`-mpushpop` :option:`-mmultiple-stld` :option:`-mconstpool` :option:`-mstack-size` :option:`-mccrt` |gol| + :option:`-mbranch-cost=n` :option:`-mcse-cc` :option:`-msched-prolog` :option:`-msim` + + *Darwin Options* + + .. program:: Darwin + + :option:`-all_load` :option:`-allowable_client` :option:`-arch` :option:`-arch_errors_fatal` |gol| + :option:`-arch_only` :option:`-bind_at_load` :option:`-bundle` :option:`-bundle_loader` |gol| + :option:`-client_name` :option:`-compatibility_version` :option:`-current_version` |gol| + :option:`-dead_strip` |gol| + :option:`-dependency-file` :option:`-dylib_file` :option:`-dylinker_install_name` |gol| + :option:`-dynamic` :option:`-dynamiclib` :option:`-exported_symbols_list` |gol| + :option:`-filelist` :option:`-flat_namespace` :option:`-force_cpusubtype_ALL` |gol| + :option:`-force_flat_namespace` :option:`-headerpad_max_install_names` |gol| + :option:`-iframework` |gol| + :option:`-image_base` :option:`-init` :option:`-install_name` :option:`-keep_private_externs` |gol| + :option:`-multi_module` :option:`-multiply_defined` :option:`-multiply_defined_unused` |gol| + :option:`-noall_load` :option:`-no_dead_strip_inits_and_terms` |gol| + :option:`-nofixprebinding` :option:`-nomultidefs` :option:`-noprebind` :option:`-noseglinkedit` |gol| + :option:`-pagezero_size` :option:`-prebind` :option:`-prebind_all_twolevel_modules` |gol| + :option:`-private_bundle` :option:`-read_only_relocs` :option:`-sectalign` |gol| + :option:`-sectobjectsymbols` :option:`-whyload` :option:`-seg1addr` |gol| + :option:`-sectcreate` :option:`-sectobjectsymbols` :option:`-sectorder` |gol| + :option:`-segaddr` :option:`-segs_read_only_addr` :option:`-segs_read_write_addr` |gol| + :option:`-seg_addr_table` :option:`-seg_addr_table_filename` :option:`-seglinkedit` |gol| + :option:`-segprot` :option:`-segs_read_only_addr` :option:`-segs_read_write_addr` |gol| + :option:`-single_module` :option:`-static` :option:`-sub_library` :option:`-sub_umbrella` |gol| + :option:`-twolevel_namespace` :option:`-umbrella` :option:`-undefined` |gol| + :option:`-unexported_symbols_list` :option:`-weak_reference_mismatches` |gol| + :option:`-whatsloaded` :option:`-F` :option:`-gused` :option:`-gfull` :option:`-mmacosx-version-min=version` |gol| + :option:`-mkernel` :option:`-mone-byte-bool` + + *DEC Alpha Options* + + .. program:: DEC Alpha + + :option:`-mno-fp-regs` :option:`-msoft-float` |gol| + :option:`-mieee` :option:`-mieee-with-inexact` :option:`-mieee-conformant` |gol| + :option:`-mfp-trap-mode=mode` :option:`-mfp-rounding-mode=mode` |gol| + :option:`-mtrap-precision=mode` :option:`-mbuild-constants` |gol| + :option:`-mcpu=cpu-type` :option:`-mtune=cpu-type` |gol| + :option:`-mbwx` :option:`-mmax` :option:`-mfix` :option:`-mcix` |gol| + :option:`-mfloat-vax` :option:`-mfloat-ieee` |gol| + :option:`-mexplicit-relocs` :option:`-msmall-data` :option:`-mlarge-data` |gol| + :option:`-msmall-text` :option:`-mlarge-text` |gol| + :option:`-mmemory-latency=time` + + *eBPF Options* + + .. program:: eBPF + + :option:`-mbig-endian` :option:`-mlittle-endian` :option:`-mkernel=version` |gol| + :option:`-mframe-limit=bytes` :option:`-mxbpf` :option:`-mco-re` :option:`-mno-co-re` |gol| + :option:`-mjmpext` :option:`-mjmp32` :option:`-malu32` :option:`-mcpu=version` + + *FR30 Options* + + .. program:: FR30 + + :option:`-msmall-model` :option:`-mno-lsim` + + *FT32 Options* + + .. program:: FT32 + + :option:`-msim` :option:`-mlra` :option:`-mnodiv` :option:`-mft32b` :option:`-mcompress` :option:`-mnopm` + + *FRV Options* + + .. program:: FRV + + :option:`-mgpr-32` :option:`-mgpr-64` :option:`-mfpr-32` :option:`-mfpr-64` |gol| + :option:`-mhard-float` :option:`-msoft-float` |gol| + :option:`-malloc-cc` :option:`-mfixed-cc` :option:`-mdword` :option:`-mno-dword` |gol| + :option:`-mdouble` :option:`-mno-double` |gol| + :option:`-mmedia` :option:`-mno-media` :option:`-mmuladd` :option:`-mno-muladd` |gol| + :option:`-mfdpic` :option:`-minline-plt` :option:`-mgprel-ro` :option:`-multilib-library-pic` |gol| + :option:`-mlinked-fp` :option:`-mlong-calls` :option:`-malign-labels` |gol| + :option:`-mlibrary-pic` :option:`-macc-4` :option:`-macc-8` |gol| + :option:`-mpack` :option:`-mno-pack` :option:`-mno-eflags` :option:`-mcond-move` :option:`-mno-cond-move` |gol| + :option:`-moptimize-membar` :option:`-mno-optimize-membar` |gol| + :option:`-mscc` :option:`-mno-scc` :option:`-mcond-exec` :option:`-mno-cond-exec` |gol| + :option:`-mvliw-branch` :option:`-mno-vliw-branch` |gol| + :option:`-mmulti-cond-exec` :option:`-mno-multi-cond-exec` :option:`-mnested-cond-exec` |gol| + :option:`-mno-nested-cond-exec` :option:`-mtomcat-stats` |gol| + :option:`-mTLS` :option:`-mtls` |gol| + :option:`-mcpu=cpu` + + *GNU/Linux Options* + + .. program:: GNU/Linux + + :option:`-mglibc` :option:`-muclibc` :option:`-mmusl` :option:`-mbionic` :option:`-mandroid` |gol| + :option:`-tno-android-cc` :option:`-tno-android-ld` + + *H8/300 Options* + + .. program:: H8/300 + + :option:`-mrelax` :option:`-mh` :option:`-ms` :option:`-mn` :option:`-mexr` :option:`-mno-exr` :option:`-mint32` :option:`-malign-300` + + *HPPA Options* + + .. program:: HPPA + + :option:`-march=architecture-type` |gol| + :option:`-mcaller-copies` :option:`-mdisable-fpregs` :option:`-mdisable-indexing` |gol| + :option:`-mfast-indirect-calls` :option:`-mgas` :option:`-mgnu-ld` :option:`-mhp-ld` |gol| + :option:`-mfixed-range=register-range` |gol| + :option:`-mjump-in-delay` :option:`-mlinker-opt` :option:`-mlong-calls` |gol| + :option:`-mlong-load-store` :option:`-mno-disable-fpregs` |gol| + :option:`-mno-disable-indexing` :option:`-mno-fast-indirect-calls` :option:`-mno-gas` |gol| + :option:`-mno-jump-in-delay` :option:`-mno-long-load-store` |gol| + :option:`-mno-portable-runtime` :option:`-mno-soft-float` |gol| + :option:`-mno-space-regs` :option:`-msoft-float` :option:`-mpa-risc-1-0` |gol| + :option:`-mpa-risc-1-1` :option:`-mpa-risc-2-0` :option:`-mportable-runtime` |gol| + :option:`-mschedule=cpu-type` :option:`-mspace-regs` :option:`-msio` :option:`-mwsio` |gol| + :option:`-munix=unix-std` :option:`-nolibdld` :option:`-static` :option:`-threads` + + *IA-64 Options* + + .. program:: IA-64 + + :option:`-mbig-endian` :option:`-mlittle-endian` :option:`-mgnu-as` :option:`-mgnu-ld` :option:`-mno-pic` |gol| + :option:`-mvolatile-asm-stop` :option:`-mregister-names` :option:`-msdata` :option:`-mno-sdata` |gol| + :option:`-mconstant-gp` :option:`-mauto-pic` :option:`-mfused-madd` |gol| + :option:`-minline-float-divide-min-latency` |gol| + :option:`-minline-float-divide-max-throughput` |gol| + :option:`-mno-inline-float-divide` |gol| + :option:`-minline-int-divide-min-latency` |gol| + :option:`-minline-int-divide-max-throughput` |gol| + :option:`-mno-inline-int-divide` |gol| + :option:`-minline-sqrt-min-latency` :option:`-minline-sqrt-max-throughput` |gol| + :option:`-mno-inline-sqrt` |gol| + :option:`-mdwarf2-asm` :option:`-mearly-stop-bits` |gol| + :option:`-mfixed-range=register-range` :option:`-mtls-size=tls-size` |gol| + :option:`-mtune=cpu-type` :option:`-milp32` :option:`-mlp64` |gol| + :option:`-msched-br-data-spec` :option:`-msched-ar-data-spec` :option:`-msched-control-spec` |gol| + :option:`-msched-br-in-data-spec` :option:`-msched-ar-in-data-spec` :option:`-msched-in-control-spec` |gol| + :option:`-msched-spec-ldc` :option:`-msched-spec-control-ldc` |gol| + :option:`-msched-prefer-non-data-spec-insns` :option:`-msched-prefer-non-control-spec-insns` |gol| + :option:`-msched-stop-bits-after-every-cycle` :option:`-msched-count-spec-in-critical-path` |gol| + :option:`-msel-sched-dont-check-control-spec` :option:`-msched-fp-mem-deps-zero-cost` |gol| + :option:`-msched-max-memory-insns-hard-limit` :option:`-msched-max-memory-insns=max-insns` + + *LM32 Options* + + .. program:: LM32 + + :option:`-mbarrel-shift-enabled` :option:`-mdivide-enabled` :option:`-mmultiply-enabled` |gol| + :option:`-msign-extend-enabled` :option:`-muser-enabled` + + *LoongArch Options* + + .. program:: LoongArch + + :option:`-march=cpu-type` :option:`-mtune=cpu-type` :option:`-mabi=base-abi-type` + :option:`-mfpu=fpu-type` :option:`-msoft-float` :option:`-msingle-float` :option:`-mdouble-float` + :option:`-mbranch-cost=n` :option:`-mcheck-zero-division` :option:`-mno-check-zero-division` + :option:`-mcond-move-int` :option:`-mno-cond-move-int` + :option:`-mcond-move-float` :option:`-mno-cond-move-float` + :option:`-memcpy` :option:`-mno-memcpy` :option:`-mstrict-align` :option:`-mno-strict-align` + :option:`-mmax-inline-memcpy-size=n` + :option:`-mexplicit-relocs` :option:`-mno-explicit-relocs` + :option:`-mdirect-extern-access` :option:`-mno-direct-extern-access` + :option:`-mcmodel=code-model` + + *M32R/D Options* + + .. program:: M32R/D + + :option:`-m32r2` :option:`-m32rx` :option:`-m32r` |gol| + :option:`-mdebug` |gol| + :option:`-malign-loops` :option:`-mno-align-loops` |gol| + :option:`-missue-rate=number` |gol| + :option:`-mbranch-cost=number` |gol| + :option:`-mmodel=code-size-model-type` |gol| + :option:`-msdata=sdata-type` |gol| + :option:`-mno-flush-func` :option:`-mflush-func=name` |gol| + :option:`-mno-flush-trap` :option:`-mflush-trap=number` |gol| + :option:`-G` :samp:`{num}` + + *M32C Options* + + .. program:: M32C + + :option:`-mcpu=cpu` :option:`-msim` :option:`-memregs=number` + + *M680x0 Options* + + .. program:: M680x0 + + :option:`-march=arch` :option:`-mcpu=cpu` :option:`-mtune=tune` |gol| + :option:`-m68000` :option:`-m68020` :option:`-m68020-40` :option:`-m68020-60` :option:`-m68030` :option:`-m68040` |gol| + :option:`-m68060` :option:`-mcpu32` :option:`-m5200` :option:`-m5206e` :option:`-m528x` :option:`-m5307` :option:`-m5407` |gol| + :option:`-mcfv4e` :option:`-mbitfield` :option:`-mno-bitfield` :option:`-mc68000` :option:`-mc68020` |gol| + :option:`-mnobitfield` :option:`-mrtd` :option:`-mno-rtd` :option:`-mdiv` :option:`-mno-div` :option:`-mshort` |gol| + :option:`-mno-short` :option:`-mhard-float` :option:`-m68881` :option:`-msoft-float` :option:`-mpcrel` |gol| + :option:`-malign-int` :option:`-mstrict-align` :option:`-msep-data` :option:`-mno-sep-data` |gol| + :option:`-mshared-library-id=n` :option:`-mid-shared-library` :option:`-mno-id-shared-library` |gol| + :option:`-mxgot` :option:`-mno-xgot` :option:`-mlong-jump-table-offsets` + + *MCore Options* + + .. program:: MCore + + :option:`-mhardlit` :option:`-mno-hardlit` :option:`-mdiv` :option:`-mno-div` :option:`-mrelax-immediates` |gol| + :option:`-mno-relax-immediates` :option:`-mwide-bitfields` :option:`-mno-wide-bitfields` |gol| + :option:`-m4byte-functions` :option:`-mno-4byte-functions` :option:`-mcallgraph-data` |gol| + :option:`-mno-callgraph-data` :option:`-mslow-bytes` :option:`-mno-slow-bytes` :option:`-mno-lsim` |gol| + :option:`-mlittle-endian` :option:`-mbig-endian` :option:`-m210` :option:`-m340` :option:`-mstack-increment` + + *MeP Options* + + .. program:: MeP + + :option:`-mabsdiff` :option:`-mall-opts` :option:`-maverage` :option:`-mbased=n` :option:`-mbitops` |gol| + :option:`-mc=n` :option:`-mclip` :option:`-mconfig=name` :option:`-mcop` :option:`-mcop32` :option:`-mcop64` :option:`-mivc2` |gol| + :option:`-mdc` :option:`-mdiv` :option:`-meb` :option:`-mel` :option:`-mio-volatile` :option:`-ml` :option:`-mleadz` :option:`-mm` :option:`-mminmax` |gol| + :option:`-mmult` :option:`-mno-opts` :option:`-mrepeat` :option:`-ms` :option:`-msatur` :option:`-msdram` :option:`-msim` :option:`-msimnovec` :option:`-mtf` |gol| + :option:`-mtiny=n` + + *MicroBlaze Options* + + .. program:: MicroBlaze + + :option:`-msoft-float` :option:`-mhard-float` :option:`-msmall-divides` :option:`-mcpu=cpu` |gol| + :option:`-mmemcpy` :option:`-mxl-soft-mul` :option:`-mxl-soft-div` :option:`-mxl-barrel-shift` |gol| + :option:`-mxl-pattern-compare` :option:`-mxl-stack-check` :option:`-mxl-gp-opt` :option:`-mno-clearbss` |gol| + :option:`-mxl-multiply-high` :option:`-mxl-float-convert` :option:`-mxl-float-sqrt` |gol| + :option:`-mbig-endian` :option:`-mlittle-endian` :option:`-mxl-reorder` :option:`-mxl-mode-app-model` |gol| + :option:`-mpic-data-is-text-relative` + + *MIPS Options* + + .. program:: MIPS + + :option:`-EL` :option:`-EB` :option:`-march=arch` :option:`-mtune=arch` |gol| + :option:`-mips1` :option:`-mips2` :option:`-mips3` :option:`-mips4` :option:`-mips32` :option:`-mips32r2` :option:`-mips32r3` :option:`-mips32r5` |gol| + :option:`-mips32r6` :option:`-mips64` :option:`-mips64r2` :option:`-mips64r3` :option:`-mips64r5` :option:`-mips64r6` |gol| + :option:`-mips16` :option:`-mno-mips16` :option:`-mflip-mips16` |gol| + :option:`-minterlink-compressed` :option:`-mno-interlink-compressed` |gol| + :option:`-minterlink-mips16` :option:`-mno-interlink-mips16` |gol| + :option:`-mabi=abi` :option:`-mabicalls` :option:`-mno-abicalls` |gol| + :option:`-mshared` :option:`-mno-shared` :option:`-mplt` :option:`-mno-plt` :option:`-mxgot` :option:`-mno-xgot` |gol| + :option:`-mgp32` :option:`-mgp64` :option:`-mfp32` :option:`-mfpxx` :option:`-mfp64` :option:`-mhard-float` :option:`-msoft-float` |gol| + :option:`-mno-float` :option:`-msingle-float` :option:`-mdouble-float` |gol| + :option:`-modd-spreg` :option:`-mno-odd-spreg` |gol| + :option:`-mabs=mode` :option:`-mnan=encoding` |gol| + :option:`-mdsp` :option:`-mno-dsp` :option:`-mdspr2` :option:`-mno-dspr2` |gol| + :option:`-mmcu` :option:`-mmno-mcu` |gol| + :option:`-meva` :option:`-mno-eva` |gol| + :option:`-mvirt` :option:`-mno-virt` |gol| + :option:`-mxpa` :option:`-mno-xpa` |gol| + :option:`-mcrc` :option:`-mno-crc` |gol| + :option:`-mginv` :option:`-mno-ginv` |gol| + :option:`-mmicromips` :option:`-mno-micromips` |gol| + :option:`-mmsa` :option:`-mno-msa` |gol| + :option:`-mloongson-mmi` :option:`-mno-loongson-mmi` |gol| + :option:`-mloongson-ext` :option:`-mno-loongson-ext` |gol| + :option:`-mloongson-ext2` :option:`-mno-loongson-ext2` |gol| + :option:`-mfpu=fpu-type` |gol| + :option:`-msmartmips` :option:`-mno-smartmips` |gol| + :option:`-mpaired-single` :option:`-mno-paired-single` :option:`-mdmx` :option:`-mno-mdmx` |gol| + :option:`-mips3d` :option:`-mno-mips3d` :option:`-mmt` :option:`-mno-mt` :option:`-mllsc` :option:`-mno-llsc` |gol| + :option:`-mlong64` :option:`-mlong32` :option:`-msym32` :option:`-mno-sym32` |gol| + :option:`-Gnum` :option:`-mlocal-sdata` :option:`-mno-local-sdata` |gol| + :option:`-mextern-sdata` :option:`-mno-extern-sdata` :option:`-mgpopt` :option:`-mno-gopt` |gol| + :option:`-membedded-data` :option:`-mno-embedded-data` |gol| + :option:`-muninit-const-in-rodata` :option:`-mno-uninit-const-in-rodata` |gol| + :option:`-mcode-readable=setting` |gol| + :option:`-msplit-addresses` :option:`-mno-split-addresses` |gol| + :option:`-mexplicit-relocs` :option:`-mno-explicit-relocs` |gol| + :option:`-mcheck-zero-division` :option:`-mno-check-zero-division` |gol| + :option:`-mdivide-traps` :option:`-mdivide-breaks` |gol| + :option:`-mload-store-pairs` :option:`-mno-load-store-pairs` |gol| + :option:`-munaligned-access` :option:`-mno-unaligned-access` |gol| + :option:`-mmemcpy` :option:`-mno-memcpy` :option:`-mlong-calls` :option:`-mno-long-calls` |gol| + :option:`-mmad` :option:`-mno-mad` :option:`-mimadd` :option:`-mno-imadd` :option:`-mfused-madd` :option:`-mno-fused-madd` :option:`-nocpp` |gol| + :option:`-mfix-24k` :option:`-mno-fix-24k` |gol| + :option:`-mfix-r4000` :option:`-mno-fix-r4000` :option:`-mfix-r4400` :option:`-mno-fix-r4400` |gol| + :option:`-mfix-r5900` :option:`-mno-fix-r5900` |gol| + :option:`-mfix-r10000` :option:`-mno-fix-r10000` :option:`-mfix-rm7000` :option:`-mno-fix-rm7000` |gol| + :option:`-mfix-vr4120` :option:`-mno-fix-vr4120` |gol| + :option:`-mfix-vr4130` :option:`-mno-fix-vr4130` :option:`-mfix-sb1` :option:`-mno-fix-sb1` |gol| + :option:`-mflush-func=func` :option:`-mno-flush-func` |gol| + :option:`-mbranch-cost=num` :option:`-mbranch-likely` :option:`-mno-branch-likely` |gol| + :option:`-mcompact-branches=policy` |gol| + :option:`-mfp-exceptions` :option:`-mno-fp-exceptions` |gol| + :option:`-mvr4130-align` :option:`-mno-vr4130-align` :option:`-msynci` :option:`-mno-synci` |gol| + :option:`-mlxc1-sxc1` :option:`-mno-lxc1-sxc1` :option:`-mmadd4` :option:`-mno-madd4` |gol| + :option:`-mrelax-pic-calls` :option:`-mno-relax-pic-calls` :option:`-mmcount-ra-address` |gol| + :option:`-mframe-header-opt` :option:`-mno-frame-header-opt` + + *MMIX Options* + + .. program:: MMIX + + :option:`-mlibfuncs` :option:`-mno-libfuncs` :option:`-mepsilon` :option:`-mno-epsilon` :option:`-mabi=gnu` |gol| + :option:`-mabi=mmixware` :option:`-mzero-extend` :option:`-mknuthdiv` :option:`-mtoplevel-symbols` |gol| + :option:`-melf` :option:`-mbranch-predict` :option:`-mno-branch-predict` :option:`-mbase-addresses` |gol| + :option:`-mno-base-addresses` :option:`-msingle-exit` :option:`-mno-single-exit` + + *MN10300 Options* + + .. program:: MN10300 + + :option:`-mmult-bug` :option:`-mno-mult-bug` |gol| + :option:`-mno-am33` :option:`-mam33` :option:`-mam33-2` :option:`-mam34` |gol| + :option:`-mtune=cpu-type` |gol| + :option:`-mreturn-pointer-on-d0` |gol| + :option:`-mno-crt0` :option:`-mrelax` :option:`-mliw` :option:`-msetlb` + + *Moxie Options* + + .. program:: Moxie + + :option:`-meb` :option:`-mel` :option:`-mmul.x` :option:`-mno-crt0` + + *MSP430 Options* + + .. program:: MSP430 + + :option:`-msim` :option:`-masm-hex` :option:`-mmcu=` :option:`-mcpu=` :option:`-mlarge` :option:`-msmall` :option:`-mrelax` |gol| + :option:`-mwarn-mcu` |gol| + :option:`-mcode-region=` :option:`-mdata-region=` |gol| + :option:`-msilicon-errata=` :option:`-msilicon-errata-warn=` |gol| + :option:`-mhwmult=` :option:`-minrt` :option:`-mtiny-printf` :option:`-mmax-inline-shift=` + + *NDS32 Options* + + .. program:: NDS32 + + :option:`-mbig-endian` :option:`-mlittle-endian` |gol| + :option:`-mreduced-regs` :option:`-mfull-regs` |gol| + :option:`-mcmov` :option:`-mno-cmov` |gol| + :option:`-mext-perf` :option:`-mno-ext-perf` |gol| + :option:`-mext-perf2` :option:`-mno-ext-perf2` |gol| + :option:`-mext-string` :option:`-mno-ext-string` |gol| + :option:`-mv3push` :option:`-mno-v3push` |gol| + :option:`-m16bit` :option:`-mno-16bit` |gol| + :option:`-misr-vector-size=num` |gol| + :option:`-mcache-block-size=num` |gol| + :option:`-march=arch` |gol| + :option:`-mcmodel=code-model` |gol| + :option:`-mctor-dtor` :option:`-mrelax` + + *Nios II Options* + + .. program:: Nios II + + :option:`-G` :samp:`{num}` :option:`-mgpopt=option` :option:`-mgpopt` :option:`-mno-gpopt` |gol| + :option:`-mgprel-sec=regexp` :option:`-mr0rel-sec=regexp` |gol| + :option:`-mel` :option:`-meb` |gol| + :option:`-mno-bypass-cache` :option:`-mbypass-cache` |gol| + :option:`-mno-cache-volatile` :option:`-mcache-volatile` |gol| + :option:`-mno-fast-sw-div` :option:`-mfast-sw-div` |gol| + :option:`-mhw-mul` :option:`-mno-hw-mul` :option:`-mhw-mulx` :option:`-mno-hw-mulx` :option:`-mno-hw-div` :option:`-mhw-div` |gol| + :option:`-mcustom-insn=N` :option:`-mno-custom-insn` |gol| + :option:`-mcustom-fpu-cfg=name` |gol| + :option:`-mhal` :option:`-msmallc` :option:`-msys-crt0=name` :option:`-msys-lib=name` |gol| + :option:`-march=arch` :option:`-mbmx` :option:`-mno-bmx` :option:`-mcdx` :option:`-mno-cdx` + + *Nvidia PTX Options* + + .. program:: Nvidia PTX + + :option:`-m64` :option:`-mmainkernel` :option:`-moptimize` + + *OpenRISC Options* + + .. program:: OpenRISC + + :option:`-mboard=name` :option:`-mnewlib` :option:`-mhard-mul` :option:`-mhard-div` |gol| + :option:`-msoft-mul` :option:`-msoft-div` |gol| + :option:`-msoft-float` :option:`-mhard-float` :option:`-mdouble-float` :option:`-munordered-float` |gol| + :option:`-mcmov` :option:`-mror` :option:`-mrori` :option:`-msext` :option:`-msfimm` :option:`-mshftimm` |gol| + :option:`-mcmodel=code-model` + + *PDP-11 Options* + + .. program:: PDP-11 + + :option:`-mfpu` :option:`-msoft-float` :option:`-mac0` :option:`-mno-ac0` :option:`-m40` :option:`-m45` :option:`-m10` |gol| + :option:`-mint32` :option:`-mno-int16` :option:`-mint16` :option:`-mno-int32` |gol| + :option:`-msplit` :option:`-munix-asm` :option:`-mdec-asm` :option:`-mgnu-asm` :option:`-mlra` + + *picoChip Options* + + .. program:: picoChip + + :option:`-mae=ae_type` :option:`-mvliw-lookahead=N` |gol| + :option:`-msymbol-as-address` :option:`-mno-inefficient-warnings` + + *PowerPC Options* + + See :ref:`rs-6000-and-powerpc-options`. + + *PRU Options* + + .. program:: PRU + + :option:`-mmcu=mcu` :option:`-minrt` :option:`-mno-relax` :option:`-mloop` |gol| + :option:`-mabi=variant` + + *RISC-V Options* + + .. program:: RISC-V + + :option:`-mbranch-cost=N-instruction` |gol| + :option:`-mplt` :option:`-mno-plt` |gol| + :option:`-mabi=ABI-string` |gol| + :option:`-mfdiv` :option:`-mno-fdiv` |gol| + :option:`-mdiv` :option:`-mno-div` |gol| + :option:`-misa-spec=ISA-spec-string` |gol| + :option:`-march=ISA-string` |gol| + :option:`-mtune=processor-string` |gol| + :option:`-mpreferred-stack-boundary=num` |gol| + :option:`-msmall-data-limit=N-bytes` |gol| + :option:`-msave-restore` :option:`-mno-save-restore` |gol| + :option:`-mshorten-memrefs` :option:`-mno-shorten-memrefs` |gol| + :option:`-mstrict-align` :option:`-mno-strict-align` |gol| + :option:`-mcmodel=medlow` :option:`-mcmodel=medany` |gol| + :option:`-mexplicit-relocs` :option:`-mno-explicit-relocs` |gol| + :option:`-mrelax` :option:`-mno-relax` |gol| + :option:`-mriscv-attribute` :option:`-mno-riscv-attribute` |gol| + :option:`-malign-data=type` |gol| + :option:`-mbig-endian` :option:`-mlittle-endian` |gol| + :option:`-mstack-protector-guard=guard` :option:`-mstack-protector-guard-reg=reg` |gol| + :option:`-mstack-protector-guard-offset=offset` + -mcsr-check -mno-csr-check + + .. program:: -mcsr-check -mno-csr-check + + *RL78 Options* + + .. program:: RL78 + + :option:`-msim` :option:`-mmul=none` :option:`-mmul=g13` :option:`-mmul=g14` :option:`-mallregs` |gol| + :option:`-mcpu=g10` :option:`-mcpu=g13` :option:`-mcpu=g14` :option:`-mg10` :option:`-mg13` :option:`-mg14` |gol| + :option:`-m64bit-doubles` :option:`-m32bit-doubles` :option:`-msave-mduc-in-interrupts` + + *RS/6000 and PowerPC Options* + + .. program:: IBM RS/6000 and PowerPC + + :option:`-mcpu=cpu-type` |gol| + :option:`-mtune=cpu-type` |gol| + :option:`-mcmodel=code-model` |gol| + :option:`-mpowerpc64` |gol| + :option:`-maltivec` :option:`-mno-altivec` |gol| + :option:`-mpowerpc-gpopt` :option:`-mno-powerpc-gpopt` |gol| + :option:`-mpowerpc-gfxopt` :option:`-mno-powerpc-gfxopt` |gol| + :option:`-mmfcrf` :option:`-mno-mfcrf` :option:`-mpopcntb` :option:`-mno-popcntb` :option:`-mpopcntd` :option:`-mno-popcntd` |gol| + :option:`-mfprnd` :option:`-mno-fprnd` |gol| + :option:`-mcmpb` :option:`-mno-cmpb` :option:`-mhard-dfp` :option:`-mno-hard-dfp` |gol| + :option:`-mfull-toc` :option:`-mminimal-toc` :option:`-mno-fp-in-toc` :option:`-mno-sum-in-toc` |gol| + :option:`-m64` :option:`-m32` :option:`-mxl-compat` :option:`-mno-xl-compat` :option:`-mpe` |gol| + :option:`-malign-power` :option:`-malign-natural` |gol| + :option:`-msoft-float` :option:`-mhard-float` :option:`-mmultiple` :option:`-mno-multiple` |gol| + :option:`-mupdate` :option:`-mno-update` |gol| + :option:`-mavoid-indexed-addresses` :option:`-mno-avoid-indexed-addresses` |gol| + :option:`-mfused-madd` :option:`-mno-fused-madd` :option:`-mbit-align` :option:`-mno-bit-align` |gol| + :option:`-mstrict-align` :option:`-mno-strict-align` :option:`-mrelocatable` |gol| + :option:`-mno-relocatable` :option:`-mrelocatable-lib` :option:`-mno-relocatable-lib` |gol| + :option:`-mtoc` :option:`-mno-toc` :option:`-mlittle` :option:`-mlittle-endian` :option:`-mbig` :option:`-mbig-endian` |gol| + :option:`-mdynamic-no-pic` :option:`-mswdiv` :option:`-msingle-pic-base` |gol| + :option:`-mprioritize-restricted-insns=priority` |gol| + :option:`-msched-costly-dep=dependence_type` |gol| + :option:`-minsert-sched-nops=scheme` |gol| + :option:`-mcall-aixdesc` :option:`-mcall-eabi` :option:`-mcall-freebsd` |gol| + :option:`-mcall-linux` :option:`-mcall-netbsd` :option:`-mcall-openbsd` |gol| + :option:`-mcall-sysv` :option:`-mcall-sysv-eabi` :option:`-mcall-sysv-noeabi` |gol| + :option:`-mtraceback=traceback_type` |gol| + :option:`-maix-struct-return` :option:`-msvr4-struct-return` |gol| + :option:`-mabi=abi-type` :option:`-msecure-plt` :option:`-mbss-plt` |gol| + :option:`-mlongcall` :option:`-mno-longcall` :option:`-mpltseq` :option:`-mno-pltseq` |gol| + :option:`-mblock-move-inline-limit=num` |gol| + :option:`-mblock-compare-inline-limit=num` |gol| + :option:`-mblock-compare-inline-loop-limit=num` |gol| + :option:`-mno-block-ops-unaligned-vsx` |gol| + :option:`-mstring-compare-inline-limit=num` |gol| + :option:`-misel` :option:`-mno-isel` |gol| + :option:`-mvrsave` :option:`-mno-vrsave` |gol| + :option:`-mmulhw` :option:`-mno-mulhw` |gol| + :option:`-mdlmzb` :option:`-mno-dlmzb` |gol| + :option:`-mprototype` :option:`-mno-prototype` |gol| + :option:`-msim` :option:`-mmvme` :option:`-mads` :option:`-myellowknife` :option:`-memb` :option:`-msdata` |gol| + :option:`-msdata=opt` :option:`-mreadonly-in-sdata` :option:`-mvxworks` :option:`-G` :samp:`{num}` |gol| + :option:`-mrecip` :option:`-mrecip=opt` :option:`-mno-recip` :option:`-mrecip-precision` |gol| + :option:`-mno-recip-precision` |gol| + :option:`-mveclibabi=type` :option:`-mfriz` :option:`-mno-friz` |gol| + :option:`-mpointers-to-nested-functions` :option:`-mno-pointers-to-nested-functions` |gol| + :option:`-msave-toc-indirect` :option:`-mno-save-toc-indirect` |gol| + :option:`-mpower8-fusion` :option:`-mno-mpower8-fusion` :option:`-mpower8-vector` :option:`-mno-power8-vector` |gol| + :option:`-mcrypto` :option:`-mno-crypto` :option:`-mhtm` :option:`-mno-htm` |gol| + :option:`-mquad-memory` :option:`-mno-quad-memory` |gol| + :option:`-mquad-memory-atomic` :option:`-mno-quad-memory-atomic` |gol| + :option:`-mcompat-align-parm` :option:`-mno-compat-align-parm` |gol| + :option:`-mfloat128` :option:`-mno-float128` :option:`-mfloat128-hardware` :option:`-mno-float128-hardware` |gol| + :option:`-mgnu-attribute` :option:`-mno-gnu-attribute` |gol| + :option:`-mstack-protector-guard=guard` :option:`-mstack-protector-guard-reg=reg` |gol| + :option:`-mstack-protector-guard-offset=offset` :option:`-mprefixed` :option:`-mno-prefixed` |gol| + :option:`-mpcrel` :option:`-mno-pcrel` :option:`-mmma` :option:`-mno-mmma` :option:`-mrop-protect` :option:`-mno-rop-protect` |gol| + :option:`-mprivileged` :option:`-mno-privileged` + + *RX Options* + + .. program:: RX + + :option:`-m64bit-doubles` :option:`-m32bit-doubles` :option:`-fpu` :option:`-nofpu` |gol| + :option:`-mcpu=` |gol| + :option:`-mbig-endian-data` :option:`-mlittle-endian-data` |gol| + :option:`-msmall-data` |gol| + :option:`-msim` :option:`-mno-sim` |gol| + :option:`-mas100-syntax` :option:`-mno-as100-syntax` |gol| + :option:`-mrelax` |gol| + :option:`-mmax-constant-size=` |gol| + :option:`-mint-register=` |gol| + :option:`-mpid` |gol| + :option:`-mallow-string-insns` :option:`-mno-allow-string-insns` |gol| + :option:`-mjsr` |gol| + :option:`-mno-warn-multiple-fast-interrupts` |gol| + :option:`-msave-acc-in-interrupts` + + *S/390 and zSeries Options* + + .. program:: S/390 and zSeries + + :option:`-mtune=cpu-type` :option:`-march=cpu-type` |gol| + :option:`-mhard-float` :option:`-msoft-float` :option:`-mhard-dfp` :option:`-mno-hard-dfp` |gol| + :option:`-mlong-double-64` :option:`-mlong-double-128` |gol| + :option:`-mbackchain` :option:`-mno-backchain` :option:`-mpacked-stack` :option:`-mno-packed-stack` |gol| + :option:`-msmall-exec` :option:`-mno-small-exec` :option:`-mmvcle` :option:`-mno-mvcle` |gol| + :option:`-m64` :option:`-m31` :option:`-mdebug` :option:`-mno-debug` :option:`-mesa` :option:`-mzarch` |gol| + :option:`-mhtm` :option:`-mvx` :option:`-mzvector` |gol| + :option:`-mtpf-trace` :option:`-mno-tpf-trace` :option:`-mtpf-trace-skip` :option:`-mno-tpf-trace-skip` |gol| + :option:`-mfused-madd` :option:`-mno-fused-madd` |gol| + :option:`-mwarn-framesize` :option:`-mwarn-dynamicstack` :option:`-mstack-size` :option:`-mstack-guard` |gol| + :option:`-mhotpatch=halfwords,halfwords` + + *Score Options* + + .. program:: Score + + :option:`-meb` :option:`-mel` |gol| + :option:`-mnhwloop` |gol| + :option:`-muls` |gol| + :option:`-mmac` |gol| + :option:`-mscore5` :option:`-mscore5u` :option:`-mscore7` :option:`-mscore7d` + + *SH Options* + + .. program:: SH + + :option:`-m1` :option:`-m2` :option:`-m2e` |gol| + :option:`-m2a-nofpu` :option:`-m2a-single-only` :option:`-m2a-single` :option:`-m2a` |gol| + :option:`-m3` :option:`-m3e` |gol| + :option:`-m4-nofpu` :option:`-m4-single-only` :option:`-m4-single` :option:`-m4` |gol| + :option:`-m4a-nofpu` :option:`-m4a-single-only` :option:`-m4a-single` :option:`-m4a` :option:`-m4al` |gol| + :option:`-mb` :option:`-ml` :option:`-mdalign` :option:`-mrelax` |gol| + :option:`-mbigtable` :option:`-mfmovd` :option:`-mrenesas` :option:`-mno-renesas` :option:`-mnomacsave` |gol| + :option:`-mieee` :option:`-mno-ieee` :option:`-mbitops` :option:`-misize` :option:`-minline-ic_invalidate` :option:`-mpadstruct` |gol| + :option:`-mprefergot` :option:`-musermode` :option:`-multcost=number` :option:`-mdiv=strategy` |gol| + :option:`-mdivsi3_libfunc=name` :option:`-mfixed-range=register-range` |gol| + :option:`-maccumulate-outgoing-args` |gol| + :option:`-matomic-model=atomic-model` |gol| + :option:`-mbranch-cost=num` :option:`-mzdcbranch` :option:`-mno-zdcbranch` |gol| + :option:`-mcbranch-force-delay-slot` |gol| + :option:`-mfused-madd` :option:`-mno-fused-madd` :option:`-mfsca` :option:`-mno-fsca` :option:`-mfsrra` :option:`-mno-fsrra` |gol| + :option:`-mpretend-cmove` :option:`-mtas` + + *Solaris 2 Options* + + .. program:: Solaris 2 + + :option:`-mclear-hwcap` :option:`-mno-clear-hwcap` :option:`-mimpure-text` :option:`-mno-impure-text` |gol| + :option:`-pthreads` + + *SPARC Options* + + .. program:: SPARC + + :option:`-mcpu=cpu-type` |gol| + :option:`-mtune=cpu-type` |gol| + :option:`-mcmodel=code-model` |gol| + :option:`-mmemory-model=mem-model` |gol| + :option:`-m32` :option:`-m64` :option:`-mapp-regs` :option:`-mno-app-regs` |gol| + :option:`-mfaster-structs` :option:`-mno-faster-structs` :option:`-mflat` :option:`-mno-flat` |gol| + :option:`-mfpu` :option:`-mno-fpu` :option:`-mhard-float` :option:`-msoft-float` |gol| + :option:`-mhard-quad-float` :option:`-msoft-quad-float` |gol| + :option:`-mstack-bias` :option:`-mno-stack-bias` |gol| + :option:`-mstd-struct-return` :option:`-mno-std-struct-return` |gol| + :option:`-munaligned-doubles` :option:`-mno-unaligned-doubles` |gol| + :option:`-muser-mode` :option:`-mno-user-mode` |gol| + :option:`-mv8plus` :option:`-mno-v8plus` :option:`-mvis` :option:`-mno-vis` |gol| + :option:`-mvis2` :option:`-mno-vis2` :option:`-mvis3` :option:`-mno-vis3` |gol| + :option:`-mvis4` :option:`-mno-vis4` :option:`-mvis4b` :option:`-mno-vis4b` |gol| + :option:`-mcbcond` :option:`-mno-cbcond` :option:`-mfmaf` :option:`-mno-fmaf` :option:`-mfsmuld` :option:`-mno-fsmuld` |gol| + :option:`-mpopc` :option:`-mno-popc` :option:`-msubxc` :option:`-mno-subxc` |gol| + :option:`-mfix-at697f` :option:`-mfix-ut699` :option:`-mfix-ut700` :option:`-mfix-gr712rc` |gol| + :option:`-mlra` :option:`-mno-lra` + + *System V Options* + + .. program:: System V + + :option:`-Qy` :option:`-Qn` :option:`-YP,paths` :option:`-Ym,dir` + + *V850 Options* + + .. program:: V850 + + :option:`-mlong-calls` :option:`-mno-long-calls` :option:`-mep` :option:`-mno-ep` |gol| + :option:`-mprolog-function` :option:`-mno-prolog-function` :option:`-mspace` |gol| + :option:`-mtda=n` :option:`-msda=n` :option:`-mzda=n` |gol| + :option:`-mapp-regs` :option:`-mno-app-regs` |gol| + :option:`-mdisable-callt` :option:`-mno-disable-callt` |gol| + :option:`-mv850e2v3` :option:`-mv850e2` :option:`-mv850e1` :option:`-mv850es` |gol| + :option:`-mv850e` :option:`-mv850` :option:`-mv850e3v5` |gol| + :option:`-mloop` |gol| + :option:`-mrelax` |gol| + :option:`-mlong-jumps` |gol| + :option:`-msoft-float` |gol| + :option:`-mhard-float` |gol| + :option:`-mgcc-abi` |gol| + :option:`-mrh850-abi` |gol| + :option:`-mbig-switch` + + *VAX Options* + + .. program:: VAX + + :option:`-mg` :option:`-mgnu` :option:`-munix` :option:`-mlra` + + *Visium Options* + + .. program:: Visium + + :option:`-mdebug` :option:`-msim` :option:`-mfpu` :option:`-mno-fpu` :option:`-mhard-float` :option:`-msoft-float` |gol| + :option:`-mcpu=cpu-type` :option:`-mtune=cpu-type` :option:`-msv-mode` :option:`-muser-mode` + + *VMS Options* + + .. program:: VMS + + :option:`-mvms-return-codes` :option:`-mdebug-main=prefix` :option:`-mmalloc64` |gol| + :option:`-mpointer-size=size` + + *VxWorks Options* + + .. program:: VxWorks + + :option:`-mrtp` :option:`-non-static` :option:`-Bstatic` :option:`-Bdynamic` |gol| + :option:`-Xbind-lazy` :option:`-Xbind-now` + + *x86 Options* + + .. program:: x86 + + :option:`-mtune=cpu-type` :option:`-march=cpu-type` |gol| + :option:`-mtune-ctrl=feature-list` :option:`-mdump-tune-features` :option:`-mno-default` |gol| + :option:`-mfpmath=unit` |gol| + :option:`-masm=dialect` :option:`-mno-fancy-math-387` |gol| + :option:`-mno-fp-ret-in-387` :option:`-m80387` :option:`-mhard-float` :option:`-msoft-float` |gol| + :option:`-mno-wide-multiply` :option:`-mrtd` :option:`-malign-double` |gol| + :option:`-mpreferred-stack-boundary=num` |gol| + :option:`-mincoming-stack-boundary=num` |gol| + :option:`-mcld` :option:`-mcx16` :option:`-msahf` :option:`-mmovbe` :option:`-mcrc32` :option:`-mmwait` |gol| + :option:`-mrecip` :option:`-mrecip=opt` |gol| + :option:`-mvzeroupper` :option:`-mprefer-avx128` :option:`-mprefer-vector-width=opt` |gol| + :option:`-mmove-max=bits` :option:`-mstore-max=bits` |gol| + :option:`-mmmx` :option:`-msse` :option:`-msse2` :option:`-msse3` :option:`-mssse3` :option:`-msse4.1` :option:`-msse4.2` :option:`-msse4` :option:`-mavx` |gol| + :option:`-mavx2` :option:`-mavx512f` :option:`-mavx512pf` :option:`-mavx512er` :option:`-mavx512cd` :option:`-mavx512vl` |gol| + :option:`-mavx512bw` :option:`-mavx512dq` :option:`-mavx512ifma` :option:`-mavx512vbmi` :option:`-msha` :option:`-maes` |gol| + :option:`-mpclmul` :option:`-mfsgsbase` :option:`-mrdrnd` :option:`-mf16c` :option:`-mfma` :option:`-mpconfig` :option:`-mwbnoinvd` |gol| + :option:`-mptwrite` :option:`-mprefetchwt1` :option:`-mclflushopt` :option:`-mclwb` :option:`-mxsavec` :option:`-mxsaves` |gol| + :option:`-msse4a` :option:`-m3dnow` :option:`-m3dnowa` :option:`-mpopcnt` :option:`-mabm` :option:`-mbmi` :option:`-mtbm` :option:`-mfma4` :option:`-mxop` |gol| + :option:`-madx` :option:`-mlzcnt` :option:`-mbmi2` :option:`-mfxsr` :option:`-mxsave` :option:`-mxsaveopt` :option:`-mrtm` :option:`-mhle` :option:`-mlwp` |gol| + :option:`-mmwaitx` :option:`-mclzero` :option:`-mpku` :option:`-mthreads` :option:`-mgfni` :option:`-mvaes` :option:`-mwaitpkg` |gol| + :option:`-mshstk` :option:`-mmanual-endbr` :option:`-mcet-switch` :option:`-mforce-indirect-call` |gol| + :option:`-mavx512vbmi2` :option:`-mavx512bf16` :option:`-menqcmd` |gol| + :option:`-mvpclmulqdq` :option:`-mavx512bitalg` :option:`-mmovdiri` :option:`-mmovdir64b` :option:`-mavx512vpopcntdq` |gol| + :option:`-mavx5124fmaps` :option:`-mavx512vnni` :option:`-mavx5124vnniw` :option:`-mprfchw` :option:`-mrdpid` |gol| + :option:`-mrdseed` :option:`-msgx` :option:`-mavx512vp2intersect` :option:`-mserialize` :option:`-mtsxldtrk` |gol| + :option:`-mamx-tile` :option:`-mamx-int8` :option:`-mamx-bf16` :option:`-muintr` :option:`-mhreset` :option:`-mavxvnni` |gol| + :option:`-mavx512fp16` :option:`-mavxifma` :option:`-mavxvnniint8` :option:`-mavxneconvert` :option:`-mcmpccxadd` :option:`-mamx-fp16` |gol| + :option:`-mprefetchi` :option:`-mraoint` :option:`-mprefer-remote-atomic` + :option:`-mcldemote` :option:`-mms-bitfields` :option:`-mno-align-stringops` :option:`-minline-all-stringops` |gol| + :option:`-minline-stringops-dynamically` :option:`-mstringop-strategy=alg` |gol| + :option:`-mkl` :option:`-mwidekl` |gol| + :option:`-mmemcpy-strategy=strategy` :option:`-mmemset-strategy=strategy` |gol| + :option:`-mpush-args` :option:`-maccumulate-outgoing-args` :option:`-m128bit-long-double` |gol| + :option:`-m96bit-long-double` :option:`-mlong-double-64` :option:`-mlong-double-80` :option:`-mlong-double-128` |gol| + :option:`-mregparm=num` :option:`-msseregparm` |gol| + :option:`-mveclibabi=type` :option:`-mvect8-ret-in-mem` |gol| + :option:`-mpc32` :option:`-mpc64` :option:`-mpc80` :option:`-mstackrealign` |gol| + :option:`-momit-leaf-frame-pointer` :option:`-mno-red-zone` :option:`-mno-tls-direct-seg-refs` |gol| + :option:`-mcmodel=code-model` :option:`-mabi=name` :option:`-maddress-mode=mode` |gol| + :option:`-m32` :option:`-m64` :option:`-mx32` :option:`-m16` :option:`-miamcu` :option:`-mlarge-data-threshold=num` |gol| + :option:`-msse2avx` :option:`-mfentry` :option:`-mrecord-mcount` :option:`-mnop-mcount` :option:`-m8bit-idiv` |gol| + :option:`-minstrument-return=type` :option:`-mfentry-name=name` :option:`-mfentry-section=name` |gol| + :option:`-mavx256-split-unaligned-load` :option:`-mavx256-split-unaligned-store` |gol| + :option:`-malign-data=type` :option:`-mstack-protector-guard=guard` |gol| + :option:`-mstack-protector-guard-reg=reg` |gol| + :option:`-mstack-protector-guard-offset=offset` |gol| + :option:`-mstack-protector-guard-symbol=symbol` |gol| + :option:`-mgeneral-regs-only` :option:`-mcall-ms2sysv-xlogues` :option:`-mrelax-cmpxchg-loop` |gol| + :option:`-mindirect-branch=choice` :option:`-mfunction-return=choice` |gol| + :option:`-mindirect-branch-register` :option:`-mharden-sls=choice` |gol| + :option:`-mindirect-branch-cs-prefix` :option:`-mneeded` :option:`-mno-direct-extern-access` + + *x86 Windows Options* + + .. program:: x86 Windows + + :option:`-mconsole` :option:`-mcygwin` :option:`-mno-cygwin` :option:`-mdll` |gol| + :option:`-mnop-fun-dllimport` :option:`-mthread` |gol| + :option:`-municode` :option:`-mwin32` :option:`-mwindows` :option:`-fno-set-stack-executable` + + *Xstormy16 Options* + + .. program:: Xstormy16 + + :option:`-msim` + + *Xtensa Options* + + .. program:: Xtensa + + :option:`-mconst16` :option:`-mno-const16` |gol| + :option:`-mfused-madd` :option:`-mno-fused-madd` |gol| + :option:`-mforce-no-pic` |gol| + :option:`-mserialize-volatile` :option:`-mno-serialize-volatile` |gol| + :option:`-mtext-section-literals` :option:`-mno-text-section-literals` |gol| + :option:`-mauto-litpools` :option:`-mno-auto-litpools` |gol| + :option:`-mtarget-align` :option:`-mno-target-align` |gol| + :option:`-mlongcalls` :option:`-mno-longcalls` |gol| + :option:`-mabi=abi-type` |gol| + :option:`-mextra-l32r-costs=cycles` + + *zSeries Options* + + See :ref:`s-390-and-zseries-options`. + + .. program:: None \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-controlling-c++-dialect.rst b/gcc/doc/gcc/gcc-command-options/options-controlling-c++-dialect.rst new file mode 100644 index 00000000000..d0786bcdcac --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-controlling-c++-dialect.rst @@ -0,0 +1,2133 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: compiler options, C++, C++ options, command-line, options, C++ + +.. _c++-dialect-options: + +Options Controlling C++ Dialect +******************************* + +This section describes the command-line options that are only meaningful +for C++ programs. You can also use most of the GNU compiler options +regardless of what language your program is in. For example, you +might compile a file :samp:`firstClass.C` like this: + +.. code-block:: shell + + g++ -g -fstrict-enums -O -c firstClass.C + +In this example, only :option:`-fstrict-enums` is an option meant +only for C++ programs; you can use the other options with any +language supported by GCC. + +Some options for compiling C programs, such as :option:`-std`, are also +relevant for C++ programs. +See :ref:`c-dialect-options`. + +Here is a list of options that are *only* for compiling C++ programs: + +.. option:: -fabi-version={n} + + Use version :samp:`{n}` of the C++ ABI. The default is version 0. + + Version 0 refers to the version conforming most closely to + the C++ ABI specification. Therefore, the ABI obtained using version 0 + will change in different versions of G++ as ABI bugs are fixed. + + Version 1 is the version of the C++ ABI that first appeared in G++ 3.2. + + Version 2 is the version of the C++ ABI that first appeared in G++ + 3.4, and was the default through G++ 4.9. + + Version 3 corrects an error in mangling a constant address as a + template argument. + + Version 4, which first appeared in G++ 4.5, implements a standard + mangling for vector types. + + Version 5, which first appeared in G++ 4.6, corrects the mangling of + attribute const/volatile on function pointer types, decltype of a + plain decl, and use of a function parameter in the declaration of + another parameter. + + Version 6, which first appeared in G++ 4.7, corrects the promotion + behavior of C++11 scoped enums and the mangling of template argument + packs, const/static_cast, prefix ++ and --, and a class scope function + used as a template argument. + + Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a + builtin type and corrects the mangling of lambdas in default argument + scope. + + Version 8, which first appeared in G++ 4.9, corrects the substitution + behavior of function types with function-cv-qualifiers. + + Version 9, which first appeared in G++ 5.2, corrects the alignment of + ``nullptr_t``. + + Version 10, which first appeared in G++ 6.1, adds mangling of + attributes that affect type identity, such as ia32 calling convention + attributes (e.g. :samp:`stdcall`). + + Version 11, which first appeared in G++ 7, corrects the mangling of + sizeof... expressions and operator names. For multiple entities with + the same name within a function, that are declared in different scopes, + the mangling now changes starting with the twelfth occurrence. It also + implies :option:`-fnew-inheriting-ctors`. + + Version 12, which first appeared in G++ 8, corrects the calling + conventions for empty classes on the x86_64 target and for classes + with only deleted copy/move constructors. It accidentally changes the + calling convention for classes with a deleted copy constructor and a + trivial move constructor. + + Version 13, which first appeared in G++ 8.2, fixes the accidental + change in version 12. + + Version 14, which first appeared in G++ 10, corrects the mangling of + the nullptr expression. + + Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI + tag regression. + + Version 16, which first appeared in G++ 11, changes the mangling of + ``__alignof__`` to be distinct from that of ``alignof``, and + dependent operator names. + + Version 17, which first appeared in G++ 12, fixes layout of classes + that inherit from aggregate classes with default member initializers + in C++14 and up. + + Version 18, which first appeard in G++ 13, fixes manglings of lambdas + that have additional context. + + See also :option:`-Wabi`. + +.. option:: -fabi-compat-version={n} + + On targets that support strong aliases, G++ + works around mangling changes by creating an alias with the correct + mangled name when defining a symbol with an incorrect mangled name. + This switch specifies which ABI version to use for the alias. + + With :option:`-fabi-version=0` (the default), this defaults to 13 (GCC 8.2 + compatibility). If another ABI version is explicitly selected, this + defaults to 0. For compatibility with GCC versions 3.2 through 4.9, + use :option:`-fabi-compat-version=2`. + + If this option is not provided but :option:`-Wabi=n` is, that + version is used for compatibility aliases. If this option is provided + along with :option:`-Wabi` (without the version), the version from this + option is used for the warning. + +.. option:: -fno-access-control + + Turn off all access checking. This switch is mainly useful for working + around bugs in the access control code. + +.. option:: -faccess-control + + Default setting; overrides :option:`-fno-access-control`. + +.. option:: -faligned-new + + Enable support for C++17 ``new`` of types that require more + alignment than ``void* ::operator new(std::size_t)`` provides. A + numeric argument such as ``-faligned-new=32`` can be used to + specify how much alignment (in bytes) is provided by that function, + but few users will need to override the default of + ``alignof(std::max_align_t)``. + + This flag is enabled by default for :option:`-std=c++17`. + +.. option:: -fchar8_t, -fno-char8_t + + Enable support for ``char8_t`` as adopted for C++20. This includes + the addition of a new ``char8_t`` fundamental type, changes to the + types of UTF-8 string and character literals, new signatures for + user-defined literals, associated standard library updates, and new + ``__cpp_char8_t`` and ``__cpp_lib_char8_t`` feature test macros. + + This option enables functions to be overloaded for ordinary and UTF-8 + strings: + + .. code-block:: c++ + + int f(const char *); // #1 + int f(const char8_t *); // #2 + int v1 = f("text"); // Calls #1 + int v2 = f(u8"text"); // Calls #2 + + and introduces new signatures for user-defined literals: + + .. code-block:: c++ + + int operator""_udl1(char8_t); + int v3 = u8'x'_udl1; + int operator""_udl2(const char8_t*, std::size_t); + int v4 = u8"text"_udl2; + template int operator""_udl3(); + int v5 = u8"text"_udl3; + + The change to the types of UTF-8 string and character literals introduces + incompatibilities with ISO C++11 and later standards. For example, the + following code is well-formed under ISO C++11, but is ill-formed when + :option:`-fchar8_t` is specified. + + .. code-block:: c++ + + char ca[] = u8"xx"; // error: char-array initialized from wide + // string + const char *cp = u8"xx";// error: invalid conversion from + // `const char8_t*' to `const char*' + int f(const char*); + auto v = f(u8"xx"); // error: invalid conversion from + // `const char8_t*' to `const char*' + std::string s{u8"xx"}; // error: no matching function for call to + // `std::basic_string::basic_string()' + using namespace std::literals; + s = u8"xx"s; // error: conversion from + // `basic_string' to non-scalar + // type `basic_string' requested + +.. option:: -fcheck-new + + Check that the pointer returned by ``operator new`` is non-null + before attempting to modify the storage allocated. This check is + normally unnecessary because the C++ standard specifies that + ``operator new`` only returns ``0`` if it is declared + ``throw()``, in which case the compiler always checks the + return value even without this option. In all other cases, when + ``operator new`` has a non-empty exception specification, memory + exhaustion is signalled by throwing ``std::bad_alloc``. See also + :samp:`new (nothrow)`. + +.. option:: -fconcepts, -fconcepts-ts + + Enable support for the C++ Concepts feature for constraining template + arguments. With :option:`-std=c++20` and above, Concepts are part of + the language standard, so :option:`-fconcepts` defaults to on. + + Some constructs that were allowed by the earlier C++ Extensions for + Concepts Technical Specification, ISO 19217 (2015), but didn't make it + into the standard, can additionally be enabled by + :option:`-fconcepts-ts`. + +.. option:: -fconstexpr-depth={n} + + Set the maximum nested evaluation depth for C++11 constexpr functions + to :samp:`{n}`. A limit is needed to detect endless recursion during + constant expression evaluation. The minimum specified by the standard + is 512. + +.. option:: -fconstexpr-cache-depth={n} + + Set the maximum level of nested evaluation depth for C++11 constexpr + functions that will be cached to :samp:`{n}`. This is a heuristic that + trades off compilation speed (when the cache avoids repeated + calculations) against memory consumption (when the cache grows very + large from highly recursive evaluations). The default is 8. Very few + users are likely to want to adjust it, but if your code does heavy + constexpr calculations you might want to experiment to find which + value works best for you. + +.. option:: -fconstexpr-fp-except + + Annex F of the C standard specifies that IEC559 floating point + exceptions encountered at compile time should not stop compilation. + C++ compilers have historically not followed this guidance, instead + treating floating point division by zero as non-constant even though + it has a well defined value. This flag tells the compiler to give + Annex F priority over other rules saying that a particular operation + is undefined. + + .. code-block:: c++ + + constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except + +.. option:: -fconstexpr-loop-limit={n} + + Set the maximum number of iterations for a loop in C++14 constexpr functions + to :samp:`{n}`. A limit is needed to detect infinite loops during + constant expression evaluation. The default is 262144 (1<<18). + +.. option:: -fconstexpr-ops-limit={n} + + Set the maximum number of operations during a single constexpr evaluation. + Even when number of iterations of a single loop is limited with the above limit, + if there are several nested loops and each of them has many iterations but still + smaller than the above limit, or if in a body of some loop or even outside + of a loop too many expressions need to be evaluated, the resulting constexpr + evaluation might take too long. + The default is 33554432 (1<<25). + +.. option:: -fcoroutines + + Enable support for the C++ coroutines extension (experimental). + +.. option:: -fno-elide-constructors + + The C++ standard allows an implementation to omit creating a temporary + that is only used to initialize another object of the same type. + Specifying this option disables that optimization, and forces G++ to + call the copy constructor in all cases. This option also causes G++ + to call trivial member functions which otherwise would be expanded inline. + + In C++17, the compiler is required to omit these temporaries, but this + option still affects trivial member functions. + +.. option:: -felide-constructors + + Default setting; overrides :option:`-fno-elide-constructors`. + +.. option:: -fno-enforce-eh-specs + + Don't generate code to check for violation of exception specifications + at run time. This option violates the C++ standard, but may be useful + for reducing code size in production builds, much like defining + ``NDEBUG``. This does not give user code permission to throw + exceptions in violation of the exception specifications; the compiler + still optimizes based on the specifications, so throwing an + unexpected exception results in undefined behavior at run time. + +.. option:: -fenforce-eh-specs + + Default setting; overrides :option:`-fno-enforce-eh-specs`. + +.. option:: -fextern-tls-init, -fno-extern-tls-init + + The C++11 and OpenMP standards allow ``thread_local`` and + ``threadprivate`` variables to have dynamic (runtime) + initialization. To support this, any use of such a variable goes + through a wrapper function that performs any necessary initialization. + When the use and definition of the variable are in the same + translation unit, this overhead can be optimized away, but when the + use is in a different translation unit there is significant overhead + even if the variable doesn't actually need dynamic initialization. If + the programmer can be sure that no use of the variable in a + non-defining TU needs to trigger dynamic initialization (either + because the variable is statically initialized, or a use of the + variable in the defining TU will be executed before any uses in + another TU), they can avoid this overhead with the + :option:`-fno-extern-tls-init` option. + + On targets that support symbol aliases, the default is + :option:`-fextern-tls-init`. On targets that do not support symbol + aliases, the default is :option:`-fno-extern-tls-init`. + +.. option:: -ffold-simple-inlines, -fno-fold-simple-inlines + + Permit the C++ frontend to fold calls to ``std::move``, ``std::forward``, + ``std::addressof`` and ``std::as_const``. In contrast to inlining, this + means no debug information will be generated for such calls. Since these + functions are rarely interesting to debug, this flag is enabled by default + unless :option:`-fno-inline` is active. + +.. option:: -fno-gnu-keywords + + Do not recognize ``typeof`` as a keyword, so that code can use this + word as an identifier. You can use the keyword ``__typeof__`` instead. + This option is implied by the strict ISO C++ dialects: :option:`-ansi`, + :option:`-std=c++98`, :option:`-std=c++11`, etc. + +.. option:: -fgnu-keywords + + Default setting; overrides :option:`-fno-gnu-keywords`. + +.. option:: -fimplicit-constexpr + + Make inline functions implicitly constexpr, if they satisfy the + requirements for a constexpr function. This option can be used in + C++14 mode or later. This can result in initialization changing from + dynamic to static and other optimizations. + +.. option:: -fno-implicit-templates + + Never emit code for non-inline templates that are instantiated + implicitly (i.e. by use); only emit code for explicit instantiations. + If you use this option, you must take care to structure your code to + include all the necessary explicit instantiations to avoid getting + undefined symbols at link time. + See :ref:`template-instantiation`, for more information. + +.. option:: -fimplicit-templates + + Default setting; overrides :option:`-fno-implicit-templates`. + +.. option:: -fno-implicit-inline-templates + + Don't emit code for implicit instantiations of inline templates, either. + The default is to handle inlines differently so that compiles with and + without optimization need the same set of explicit instantiations. + +.. option:: -fimplicit-inline-templates + + Default setting; overrides :option:`-fno-implicit-inline-templates`. + +.. option:: -fno-implement-inlines + + To save space, do not emit out-of-line copies of inline functions + controlled by ``#pragma implementation``. This causes linker + errors if these functions are not inlined everywhere they are called. + +.. option:: -fimplement-inlines + + Default setting; overrides :option:`-fno-implement-inlines`. + +.. option:: -fmodules-ts, -fno-modules-ts + + Enable support for C++20 modules (see :ref:`c++-modules`). The + :option:`-fno-modules-ts` is usually not needed, as that is the + default. Even though this is a C++20 feature, it is not currently + implicitly enabled by selecting that standard version. + +.. option:: -fmodule-header, -fmodule-header=user, -fmodule-header=system + + Compile a header file to create an importable header unit. + +.. option:: -fmodule-implicit-inline + + Member functions defined in their class definitions are not implicitly + inline for modular code. This is different to traditional C++ + behavior, for good reasons. However, it may result in a difficulty + during code porting. This option makes such function definitions + implicitly inline. It does however generate an ABI incompatibility, + so you must use it everywhere or nowhere. (Such definitions outside + of a named module remain implicitly inline, regardless.) + +.. option:: -fno-module-lazy + + Disable lazy module importing and module mapper creation. + +.. option:: -fmodule-lazy + + Default setting; overrides :option:`-fno-module-lazy`. + +.. index:: CXX_MODULE_MAPPER environment variable + +.. option:: -fmodule-mapper=[{hostname}]:{port}[?{ident}] + + An oracle to query for module name to filename mappings. If + unspecified the :envvar:`CXX_MODULE_MAPPER` environment variable is used, + and if that is unset, an in-process default is provided. + +.. option:: -fmodule-only + + Only emit the Compiled Module Interface, inhibiting any object file. + +.. option:: -fms-extensions + + Disable Wpedantic warnings about constructs used in MFC, such as implicit + int and getting a pointer to member function via non-standard syntax. + +.. option:: -fnew-inheriting-ctors + + Enable the P0136 adjustment to the semantics of C++11 constructor + inheritance. This is part of C++17 but also considered to be a Defect + Report against C++11 and C++14. This flag is enabled by default + unless :option:`-fabi-version=10` or lower is specified. + +.. option:: -fnew-ttp-matching + + Enable the P0522 resolution to Core issue 150, template template + parameters and default arguments: this allows a template with default + template arguments as an argument for a template template parameter + with fewer template parameters. This flag is enabled by default for + :option:`-std=c++17`. + +.. option:: -fno-nonansi-builtins + + Disable built-in declarations of functions that are not mandated by + ANSI/ISO C. These include ``ffs``, ``alloca``, ``_exit``, + ``index``, ``bzero``, ``conjf``, and other related functions. + +.. option:: -fnonansi-builtins + + Default setting; overrides :option:`-fno-nonansi-builtins`. + +.. option:: -fnothrow-opt + + Treat a ``throw()`` exception specification as if it were a + ``noexcept`` specification to reduce or eliminate the text size + overhead relative to a function with no exception specification. If + the function has local variables of types with non-trivial + destructors, the exception specification actually makes the + function smaller because the EH cleanups for those variables can be + optimized away. The semantic effect is that an exception thrown out of + a function with such an exception specification results in a call + to ``terminate`` rather than ``unexpected``. + +.. option:: -fno-operator-names + + Do not treat the operator name keywords ``and``, ``bitand``, + ``bitor``, ``compl``, ``not``, ``or`` and ``xor`` as + synonyms as keywords. + +.. option:: -foperator-names + + Default setting; overrides :option:`-fno-operator-names`. + +.. option:: -fno-optional-diags + + Disable diagnostics that the standard says a compiler does not need to + issue. Currently, the only such diagnostic issued by G++ is the one for + a name having multiple meanings within a class. + +.. option:: -foptional-diags + + Default setting; overrides :option:`-fno-optional-diags`. + +.. option:: -fpermissive + + Downgrade some diagnostics about nonconformant code from errors to + warnings. Thus, using :option:`-fpermissive` allows some + nonconforming code to compile. + +.. option:: -fno-pretty-templates + + When an error message refers to a specialization of a function + template, the compiler normally prints the signature of the + template followed by the template arguments and any typedefs or + typenames in the signature (e.g. ``void f(T) [with T = int]`` + rather than ``void f(int)``) so that it's clear which template is + involved. When an error message refers to a specialization of a class + template, the compiler omits any template arguments that match + the default template arguments for that template. If either of these + behaviors make it harder to understand the error message rather than + easier, you can use :option:`-fno-pretty-templates` to disable them. + +.. option:: -fpretty-templates + + Default setting; overrides :option:`-fno-pretty-templates`. + +.. option:: -fno-rtti + + Disable generation of information about every class with virtual + functions for use by the C++ run-time type identification features + (``dynamic_cast`` and ``typeid``). If you don't use those parts + of the language, you can save some space by using this flag. Note that + exception handling uses the same information, but G++ generates it as + needed. The ``dynamic_cast`` operator can still be used for casts that + do not require run-time type information, i.e. casts to ``void *`` or to + unambiguous base classes. + + Mixing code compiled with :option:`-frtti` with that compiled with + :option:`-fno-rtti` may not work. For example, programs may + fail to link if a class compiled with :option:`-fno-rtti` is used as a base + for a class compiled with :option:`-frtti`. + +.. option:: -frtti + + Default setting; overrides :option:`-fno-rtti`. + +.. option:: -fsized-deallocation + + Enable the built-in global declarations + + .. code-block:: c++ + + void operator delete (void *, std::size_t) noexcept; + void operator delete[] (void *, std::size_t) noexcept; + + as introduced in C++14. This is useful for user-defined replacement + deallocation functions that, for example, use the size of the object + to make deallocation faster. Enabled by default under + :option:`-std=c++14` and above. The flag :option:`-Wsized-deallocation` + warns about places that might want to add a definition. + +.. option:: -fstrict-enums + + Allow the compiler to optimize using the assumption that a value of + enumerated type can only be one of the values of the enumeration (as + defined in the C++ standard; basically, a value that can be + represented in the minimum number of bits needed to represent all the + enumerators). This assumption may not be valid if the program uses a + cast to convert an arbitrary integer value to the enumerated type. + +.. option:: -fstrong-eval-order + + Evaluate member access, array subscripting, and shift expressions in + left-to-right order, and evaluate assignment in right-to-left order, + as adopted for C++17. Enabled by default with :option:`-std=c++17`. + :option:`-fstrong-eval-order=some` enables just the ordering of member + access and shift expressions, and is the default without + :option:`-std=c++17`. + +.. option:: -ftemplate-backtrace-limit={n} + + Set the maximum number of template instantiation notes for a single + warning or error to :samp:`{n}`. The default value is 10. + +.. option:: -ftemplate-depth={n} + + Set the maximum instantiation depth for template classes to :samp:`{n}`. + A limit on the template instantiation depth is needed to detect + endless recursions during template class instantiation. ANSI/ISO C++ + conforming programs must not rely on a maximum depth greater than 17 + (changed to 1024 in C++11). The default value is 900, as the compiler + can run out of stack space before hitting 1024 in some situations. + +.. option:: -fno-threadsafe-statics + + Do not emit the extra code to use the routines specified in the C++ + ABI for thread-safe initialization of local statics. You can use this + option to reduce code size slightly in code that doesn't need to be + thread-safe. + +.. option:: -fthreadsafe-statics + + Default setting; overrides :option:`-fno-threadsafe-statics`. + +.. option:: -fuse-cxa-atexit + + Register destructors for objects with static storage duration with the + ``__cxa_atexit`` function rather than the ``atexit`` function. + This option is required for fully standards-compliant handling of static + destructors, but only works if your C library supports + ``__cxa_atexit``. + +.. option:: -fno-use-cxa-get-exception-ptr + + Don't use the ``__cxa_get_exception_ptr`` runtime routine. This + causes ``std::uncaught_exception`` to be incorrect, but is necessary + if the runtime routine is not available. + +.. option:: -fuse-cxa-get-exception-ptr + + Default setting; overrides :option:`-fno-use-cxa-get-exception-ptr`. + +.. option:: -fvisibility-inlines-hidden + + This switch declares that the user does not attempt to compare + pointers to inline functions or methods where the addresses of the two functions + are taken in different shared objects. + + The effect of this is that GCC may, effectively, mark inline methods with + ``__attribute__ ((visibility ("hidden")))`` so that they do not + appear in the export table of a DSO and do not require a PLT indirection + when used within the DSO. Enabling this option can have a dramatic effect + on load and link times of a DSO as it massively reduces the size of the + dynamic export table when the library makes heavy use of templates. + + The behavior of this switch is not quite the same as marking the + methods as hidden directly, because it does not affect static variables + local to the function or cause the compiler to deduce that + the function is defined in only one shared object. + + You may mark a method as having a visibility explicitly to negate the + effect of the switch for that method. For example, if you do want to + compare pointers to a particular inline method, you might mark it as + having default visibility. Marking the enclosing class with explicit + visibility has no effect. + + Explicitly instantiated inline methods are unaffected by this option + as their linkage might otherwise cross a shared library boundary. + See :ref:`template-instantiation`. + +.. option:: -fvisibility-ms-compat + + This flag attempts to use visibility settings to make GCC's C++ + linkage model compatible with that of Microsoft Visual Studio. + + The flag makes these changes to GCC's linkage model: + + * It sets the default visibility to ``hidden``, like + :option:`-fvisibility=hidden`. + + * Types, but not their members, are not hidden by default. + + * The One Definition Rule is relaxed for types without explicit + visibility specifications that are defined in more than one + shared object: those declarations are permitted if they are + permitted when this option is not used. + + In new code it is better to use :option:`-fvisibility=hidden` and + export those classes that are intended to be externally visible. + Unfortunately it is possible for code to rely, perhaps accidentally, + on the Visual Studio behavior. + + Among the consequences of these changes are that static data members + of the same type with the same name but defined in different shared + objects are different, so changing one does not change the other; + and that pointers to function members defined in different shared + objects may not compare equal. When this flag is given, it is a + violation of the ODR to define types with the same name differently. + +.. option:: -fno-weak + + Do not use weak symbol support, even if it is provided by the linker. + By default, G++ uses weak symbols if they are available. This + option exists only for testing, and should not be used by end-users; + it results in inferior code and has no benefits. This option may + be removed in a future release of G++. + +.. option:: -fweak + + Default setting; overrides :option:`-fno-weak`. + +.. option:: -fext-numeric-literals + + .. note:: + + C++ and Objective-C++ only + + Accept imaginary, fixed-point, or machine-defined + literal number suffixes as GNU extensions. + When this option is turned off these suffixes are treated + as C++11 user-defined literal numeric suffixes. + This is on by default for all pre-C++11 dialects and all GNU dialects: + :option:`-std=c++98`, :option:`-std=gnu++98`, :option:`-std=gnu++11`, + :option:`-std=gnu++14`. + This option is off by default + for ISO C++11 onwards (:option:`-std=c++11`, ...). + +.. option:: -fno-ext-numeric-literals + + Default setting; overrides :option:`-fext-numeric-literals`. + +.. option:: -nostdinc++ + + Do not search for header files in the standard directories specific to + C++, but do still search the other standard directories. (This option + is used when building the C++ library.) + +.. option:: -flang-info-include-translate, -flang-info-include-translate-not, -flang-info-include-translate={header} + + Inform of include translation events. The first will note accepted + include translations, the second will note declined include + translations. The :samp:`{header}` form will inform of include + translations relating to that specific header. If :samp:`{header}` is of + the form ``"user"`` or ```` it will be resolved to a + specific user or system header using the include path. + +.. option:: -flang-info-module-cmi, -flang-info-module-cmi={module} + + Inform of Compiled Module Interface pathnames. The first will note + all read CMI pathnames. The :samp:`{module}` form will not reading a + specific module's CMI. :samp:`{module}` may be a named module or a + header-unit (the latter indicated by either being a pathname containing + directory separators or enclosed in ``<>`` or ``""``). + +.. option:: -stdlib={libstdc++,libc++} + + When G++ is configured to support this option, it allows specification of + alternate C++ runtime libraries. Two options are available: :samp:`{libstdc++}` + (the default, native C++ runtime for G++) and :samp:`{libc++}` which is the + C++ runtime installed on some operating systems (e.g. Darwin versions from + Darwin11 onwards). The option switches G++ to use the headers from the + specified library and to emit ``-lstdc++`` or ``-lc++`` respectively, + when a C++ runtime is required for linking. + +In addition, these warning options have meanings only for C++ programs: + +.. option:: -Wabi-tag + + .. note:: + + C++ and Objective-C++ only + + Warn when a type with an ABI tag is used in a context that does not + have that ABI tag. See :ref:`c++-attributes` for more information + about ABI tags. + +.. option:: -Wcomma-subscript + + .. note:: + + C++ and Objective-C++ only + + Warn about uses of a comma expression within a subscripting expression. + This usage was deprecated in C++20 and is going to be removed in C++23. + However, a comma expression wrapped in ``( )`` is not deprecated. Example: + + .. code-block:: c++ + + void f(int *a, int b, int c) { + a[b,c]; // deprecated in C++20, invalid in C++23 + a[(b,c)]; // OK + } + + In C++23 it is valid to have comma separated expressions in a subscript + when an overloaded subscript operator is found and supports the right + number and types of arguments. G++ will accept the formerly valid syntax + for code that is not valid in C++23 but used to be valid but deprecated + in C++20 with a pedantic warning that can be disabled with + :option:`-Wno-comma-subscript`. + + Enabled by default with :option:`-std=c++20` unless :option:`-Wno-deprecated`, + and with :option:`-std=c++23` regardless of :option:`-Wno-deprecated`. + +.. option:: -Wno-comma-subscript + + Default setting; overrides :option:`-Wcomma-subscript`. + +.. option:: -Wctad-maybe-unsupported + + .. note:: + + C++ and Objective-C++ only + + Warn when performing class template argument deduction (CTAD) on a type with + no explicitly written deduction guides. This warning will point out cases + where CTAD succeeded only because the compiler synthesized the implicit + deduction guides, which might not be what the programmer intended. Certain + style guides allow CTAD only on types that specifically "opt-in"; i.e., on + types that are designed to support CTAD. This warning can be suppressed with + the following pattern: + + .. code-block:: c++ + + struct allow_ctad_t; // any name works + template struct S { + S(T) { } + }; + S(allow_ctad_t) -> S; // guide with incomplete parameter type will never be considered + +.. option:: -Wno-ctad-maybe-unsupported + + Default setting; overrides :option:`-Wctad-maybe-unsupported`. + +.. option:: -Wctor-dtor-privacy + + .. note:: + + C++ and Objective-C++ only + + Warn when a class seems unusable because all the constructors or + destructors in that class are private, and it has neither friends nor + public static member functions. Also warn if there are no non-private + methods, and there's at least one private member function that isn't + a constructor or destructor. + +.. option:: -Wno-ctor-dtor-privacy + + Default setting; overrides :option:`-Wctor-dtor-privacy`. + +.. option:: -Wdangling-reference + + .. note:: + + C++ and Objective-C++ only + + Warn when a reference is bound to a temporary whose lifetime has ended. + For example: + + .. code-block:: c++ + + int n = 1; + const int& r = std::max(n - 1, n + 1); // r is dangling + + In the example above, two temporaries are created, one for each + argument, and a reference to one of the temporaries is returned. + However, both temporaries are destroyed at the end of the full + expression, so the reference ``r`` is dangling. This warning + also detects dangling references in member initializer lists: + + .. code-block:: c++ + + const int& f(const int& i) { return i; } + struct S { + const int &r; // r is dangling + S() : r(f(10)) { } + }; + + Member functions are checked as well, but only their object argument: + + .. code-block:: c++ + + struct S { + const S& self () { return *this; } + }; + const S& s = S().self(); // s is dangling + + Certain functions are safe in this respect, for example ``std::use_facet`` : + they take and return a reference, but they don't return one of its arguments, + which can fool the warning. Such functions can be excluded from the warning + by wrapping them in a ``#pragma`` : + + .. code-block:: c++ + + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdangling-reference" + const T& foo (const T&) { ... } + #pragma GCC diagnostic pop + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-dangling-reference + + Default setting; overrides :option:`-Wdangling-reference`. + +.. option:: -Wdelete-non-virtual-dtor + + .. note:: + + C++ and Objective-C++ only + + Warn when ``delete`` is used to destroy an instance of a class that + has virtual functions and non-virtual destructor. It is unsafe to delete + an instance of a derived class through a pointer to a base class if the + base class does not have a virtual destructor. This warning is enabled + by :option:`-Wall`. + +.. option:: -Wno-delete-non-virtual-dtor + + Default setting; overrides :option:`-Wdelete-non-virtual-dtor`. + +.. option:: -Wdeprecated-copy + + .. note:: + + C++ and Objective-C++ only + + Warn that the implicit declaration of a copy constructor or copy + assignment operator is deprecated if the class has a user-provided + copy constructor or copy assignment operator, in C++11 and up. This + warning is enabled by :option:`-Wextra`. With + :option:`-Wdeprecated-copy-dtor`, also deprecate if the class has a + user-provided destructor. + +.. option:: -Wno-deprecated-copy + + Default setting; overrides :option:`-Wdeprecated-copy`. + +.. option:: -Wno-deprecated-enum-enum-conversion + + .. note:: + + C++ and Objective-C++ only + + Disable the warning about the case when the usual arithmetic conversions + are applied on operands where one is of enumeration type and the other is + of a different enumeration type. This conversion was deprecated in C++20. + For example: + + .. code-block:: c++ + + enum E1 { e }; + enum E2 { f }; + int k = f - e; + + :option:`-Wdeprecated-enum-enum-conversion` is enabled by default with + :option:`-std=c++20`. In pre-C++20 dialects, this warning can be enabled + by :option:`-Wenum-conversion`. + +.. option:: -Wdeprecated-enum-enum-conversion + + Default setting; overrides :option:`-Wno-deprecated-enum-enum-conversion`. + +.. option:: -Wno-deprecated-enum-float-conversion + + .. note:: + + C++ and Objective-C++ only + + Disable the warning about the case when the usual arithmetic conversions + are applied on operands where one is of enumeration type and the other is + of a floating-point type. This conversion was deprecated in C++20. For + example: + + .. code-block:: c++ + + enum E1 { e }; + enum E2 { f }; + bool b = e <= 3.7; + + :option:`-Wdeprecated-enum-float-conversion` is enabled by default with + :option:`-std=c++20`. In pre-C++20 dialects, this warning can be enabled + by :option:`-Wenum-conversion`. + +.. option:: -Wdeprecated-enum-float-conversion + + Default setting; overrides :option:`-Wno-deprecated-enum-float-conversion`. + +.. option:: -Wno-init-list-lifetime + + .. note:: + + C++ and Objective-C++ only + + Do not warn about uses of ``std::initializer_list`` that are likely + to result in dangling pointers. Since the underlying array for an + ``initializer_list`` is handled like a normal C++ temporary object, + it is easy to inadvertently keep a pointer to the array past the end + of the array's lifetime. For example: + + * If a function returns a temporary ``initializer_list``, or a local + ``initializer_list`` variable, the array's lifetime ends at the end + of the return statement, so the value returned has a dangling pointer. + + * If a new-expression creates an ``initializer_list``, the array only + lives until the end of the enclosing full-expression, so the + ``initializer_list`` in the heap has a dangling pointer. + + * When an ``initializer_list`` variable is assigned from a + brace-enclosed initializer list, the temporary array created for the + right side of the assignment only lives until the end of the + full-expression, so at the next statement the ``initializer_list`` + variable has a dangling pointer. + + .. code-block:: c++ + + // li's initial underlying array lives as long as li + std::initializer_list li = { 1,2,3 }; + // assignment changes li to point to a temporary array + li = { 4, 5 }; + // now the temporary is gone and li has a dangling pointer + int i = li.begin()[0] // undefined behavior + + * When a list constructor stores the ``begin`` pointer from the + ``initializer_list`` argument, this doesn't extend the lifetime of + the array, so if a class variable is constructed from a temporary + ``initializer_list``, the pointer is left dangling by the end of + the variable declaration statement. + +.. option:: -Winit-list-lifetime + + Default setting; overrides :option:`-Wno-init-list-lifetime`. + +.. option:: -Winvalid-imported-macros + + Verify all imported macro definitions are valid at the end of + compilation. This is not enabled by default, as it requires + additional processing to determine. It may be useful when preparing + sets of header-units to ensure consistent macros. + +.. option:: -Wno-invalid-imported-macros + + Default setting; overrides :option:`-Winvalid-imported-macros`. + +.. option:: -Wno-literal-suffix + + .. note:: + + C++ and Objective-C++ only + + Do not warn when a string or character literal is followed by a + ud-suffix which does not begin with an underscore. As a conforming + extension, GCC treats such suffixes as separate preprocessing tokens + in order to maintain backwards compatibility with code that uses + formatting macros from ````. For example: + + .. code-block:: c++ + + #define __STDC_FORMAT_MACROS + #include + #include + + int main() { + int64_t i64 = 123; + printf("My int64: %" PRId64"\n", i64); + } + + In this case, ``PRId64`` is treated as a separate preprocessing token. + + This option also controls warnings when a user-defined literal + operator is declared with a literal suffix identifier that doesn't + begin with an underscore. Literal suffix identifiers that don't begin + with an underscore are reserved for future standardization. + + These warnings are enabled by default. + +.. option:: -Wliteral-suffix + + Default setting; overrides :option:`-Wno-literal-suffix`. + +.. option:: -Wno-narrowing + + .. note:: + + C++ and Objective-C++ only + + For C++11 and later standards, narrowing conversions are diagnosed by default, + as required by the standard. A narrowing conversion from a constant produces + an error, and a narrowing conversion from a non-constant produces a warning, + but :option:`-Wno-narrowing` suppresses the diagnostic. + Note that this does not affect the meaning of well-formed code; + narrowing conversions are still considered ill-formed in SFINAE contexts. + + With :option:`-Wnarrowing` in C++98, warn when a narrowing + conversion prohibited by C++11 occurs within + ``{ }``, e.g. + + .. code-block:: c++ + + int i = { 2.2 }; // error: narrowing from double to int + + This flag is included in :option:`-Wall` and :option:`-Wc++11-compat`. + +.. option:: -Wnarrowing + + Default setting; overrides :option:`-Wno-narrowing`. + +.. option:: -Wnoexcept + + .. note:: + + C++ and Objective-C++ only + + Warn when a noexcept-expression evaluates to false because of a call + to a function that does not have a non-throwing exception + specification (i.e. ``throw()`` or ``noexcept``) but is known by + the compiler to never throw an exception. + +.. option:: -Wno-noexcept + + Default setting; overrides :option:`-Wnoexcept`. + +.. option:: -Wnoexcept-type + + .. note:: + + C++ and Objective-C++ only + + Warn if the C++17 feature making ``noexcept`` part of a function + type changes the mangled name of a symbol relative to C++14. Enabled + by :option:`-Wabi` and :option:`-Wc++17-compat`. + + As an example: + + .. code-block:: c++ + + template void f(T t) { t(); }; + void g() noexcept; + void h() { f(g); } + + In C++14, ``f`` calls ``f``, but in + C++17 it calls ``f``. + +.. option:: -Wno-noexcept-type + + Default setting; overrides :option:`-Wnoexcept-type`. + +.. option:: -Wclass-memaccess + + .. note:: + + C++ and Objective-C++ only + + Warn when the destination of a call to a raw memory function such as + ``memset`` or ``memcpy`` is an object of class type, and when writing + into such an object might bypass the class non-trivial or deleted constructor + or copy assignment, violate const-correctness or encapsulation, or corrupt + virtual table pointers. Modifying the representation of such objects may + violate invariants maintained by member functions of the class. For example, + the call to ``memset`` below is undefined because it modifies a non-trivial + class object and is, therefore, diagnosed. The safe way to either initialize + or clear the storage of objects of such types is by using the appropriate + constructor or assignment operator, if one is available. + + .. code-block:: c++ + + std::string str = "abc"; + memset (&str, 0, sizeof str); + + The :option:`-Wclass-memaccess` option is enabled by :option:`-Wall`. + Explicitly casting the pointer to the class object to ``void *`` or + to a type that can be safely accessed by the raw memory function suppresses + the warning. + +.. option:: -Wno-class-memaccess + + Default setting; overrides :option:`-Wclass-memaccess`. + +.. option:: -Wnon-virtual-dtor + + .. note:: + + C++ and Objective-C++ only + + Warn when a class has virtual functions and an accessible non-virtual + destructor itself or in an accessible polymorphic base class, in which + case it is possible but unsafe to delete an instance of a derived + class through a pointer to the class itself or base class. This + warning is automatically enabled if :option:`-Weffc++` is specified. + +.. option:: -Wno-non-virtual-dtor + + Default setting; overrides :option:`-Wnon-virtual-dtor`. + +.. option:: -Wregister + + .. note:: + + C++ and Objective-C++ only + + Warn on uses of the ``register`` storage class specifier, except + when it is part of the GNU :ref:`explicit-register-variables` extension. + The use of the ``register`` keyword as storage class specifier has + been deprecated in C++11 and removed in C++17. + Enabled by default with :option:`-std=c++17`. + +.. option:: -Wno-register + + Default setting; overrides :option:`-Wregister`. + +.. option:: -Wreorder + + .. note:: + + C++ and Objective-C++ only + + .. index:: reordering, warning, warning for reordering of member initializers + + Warn when the order of member initializers given in the code does not + match the order in which they must be executed. For instance: + + .. code-block:: c++ + + struct A { + int i; + int j; + A(): j (0), i (1) { } + }; + + The compiler rearranges the member initializers for ``i`` + and ``j`` to match the declaration order of the members, emitting + a warning to that effect. This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-reorder + + Default setting; overrides :option:`-Wreorder`. + +.. option:: -Wno-pessimizing-move + + .. note:: + + C++ and Objective-C++ only + + This warning warns when a call to ``std::move`` prevents copy + elision. A typical scenario when copy elision can occur is when returning in + a function with a class return type, when the expression being returned is the + name of a non-volatile automatic object, and is not a function parameter, and + has the same type as the function return type. + + .. code-block:: c++ + + struct T { + ... + }; + T fn() + { + T t; + ... + return std::move (t); + } + + But in this example, the ``std::move`` call prevents copy elision. + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wpessimizing-move + + Default setting; overrides :option:`-Wno-pessimizing-move`. + +.. option:: -Wno-redundant-move + + .. note:: + + C++ and Objective-C++ only + + This warning warns about redundant calls to ``std::move`` ; that is, when + a move operation would have been performed even without the ``std::move`` + call. This happens because the compiler is forced to treat the object as if + it were an rvalue in certain situations such as returning a local variable, + where copy elision isn't applicable. Consider: + + .. code-block:: c++ + + struct T { + ... + }; + T fn(T t) + { + ... + return std::move (t); + } + + Here, the ``std::move`` call is redundant. Because G++ implements Core + Issue 1579, another example is: + + .. code-block:: c++ + + struct T { // convertible to U + ... + }; + struct U { + ... + }; + U fn() + { + T t; + ... + return std::move (t); + } + + In this example, copy elision isn't applicable because the type of the + expression being returned and the function return type differ, yet G++ + treats the return value as if it were designated by an rvalue. + + This warning is enabled by :option:`-Wextra`. + +.. option:: -Wredundant-move + + Default setting; overrides :option:`-Wno-redundant-move`. + +.. option:: -Wrange-loop-construct + + .. note:: + + C++ and Objective-C++ only + + This warning warns when a C++ range-based for-loop is creating an unnecessary + copy. This can happen when the range declaration is not a reference, but + probably should be. For example: + + .. code-block:: c++ + + struct S { char arr[128]; }; + void fn () { + S arr[5]; + for (const auto x : arr) { ... } + } + + It does not warn when the type being copied is a trivially-copyable type whose + size is less than 64 bytes. + + This warning also warns when a loop variable in a range-based for-loop is + initialized with a value of a different type resulting in a copy. For example: + + .. code-block:: c++ + + void fn() { + int arr[10]; + for (const double &x : arr) { ... } + } + + In the example above, in every iteration of the loop a temporary value of + type ``double`` is created and destroyed, to which the reference + ``const double &`` is bound. + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-range-loop-construct + + Default setting; overrides :option:`-Wrange-loop-construct`. + +.. option:: -Wredundant-tags + + .. note:: + + C++ and Objective-C++ only + + Warn about redundant class-key and enum-key in references to class types + and enumerated types in contexts where the key can be eliminated without + causing an ambiguity. For example: + + .. code-block:: c++ + + struct foo; + struct foo *p; // warn that keyword struct can be eliminated + + On the other hand, in this example there is no warning: + + .. code-block:: c++ + + struct foo; + void foo (); // "hides" struct foo + void bar (struct foo&); // no warning, keyword struct is necessary + +.. option:: -Wno-redundant-tags + + Default setting; overrides :option:`-Wredundant-tags`. + +.. option:: -Wno-subobject-linkage + + .. note:: + + C++ and Objective-C++ only + + Do not warn + if a class type has a base or a field whose type uses the anonymous + namespace or depends on a type with no linkage. If a type A depends on + a type B with no or internal linkage, defining it in multiple + translation units would be an ODR violation because the meaning of B + is different in each translation unit. If A only appears in a single + translation unit, the best way to silence the warning is to give it + internal linkage by putting it in an anonymous namespace as well. The + compiler doesn't give this warning for types defined in the main .C + file, as those are unlikely to have multiple definitions. + :option:`-Wsubobject-linkage` is enabled by default. + +.. option:: -Wsubobject-linkage + + Default setting; overrides :option:`-Wno-subobject-linkage`. + +.. option:: -Weffc++ + + .. note:: + + C++ and Objective-C++ only + + Warn about violations of the following style guidelines from Scott Meyers' + Effective C++ series of books: + + * Define a copy constructor and an assignment operator for classes + with dynamically-allocated memory. + + * Prefer initialization to assignment in constructors. + + * Have ``operator=`` return a reference to ``*this``. + + * Don't try to return a reference when you must return an object. + + * Distinguish between prefix and postfix forms of increment and + decrement operators. + + * Never overload ``&&``, ``||``, or ``,``. + + This option also enables :option:`-Wnon-virtual-dtor`, which is also + one of the effective C++ recommendations. However, the check is + extended to warn about the lack of virtual destructor in accessible + non-polymorphic bases classes too. + + When selecting this option, be aware that the standard library + headers do not obey all of these guidelines; use :samp:`grep -v` + to filter out those warnings. + +.. option:: -Wno-effc++ + + Default setting; overrides :option:`-Weffc++`. + +.. option:: -Wno-exceptions + + .. note:: + + C++ and Objective-C++ only + + Disable the warning about the case when an exception handler is shadowed by + another handler, which can point out a wrong ordering of exception handlers. + +.. option:: -Wexceptions + + Default setting; overrides :option:`-Wno-exceptions`. + +.. option:: -Wstrict-null-sentinel + + .. note:: + + C++ and Objective-C++ only + + Warn about the use of an uncasted ``NULL`` as sentinel. When + compiling only with GCC this is a valid sentinel, as ``NULL`` is defined + to ``__null``. Although it is a null pointer constant rather than a + null pointer, it is guaranteed to be of the same size as a pointer. + But this use is not portable across different compilers. + +.. option:: -Wno-strict-null-sentinel + + Default setting; overrides :option:`-Wstrict-null-sentinel`. + +.. option:: -Wno-non-template-friend + + .. note:: + + C++ and Objective-C++ only + + Disable warnings when non-template friend functions are declared + within a template. In very old versions of GCC that predate implementation + of the ISO standard, declarations such as + :samp:`friend int foo(int)`, where the name of the friend is an unqualified-id, + could be interpreted as a particular specialization of a template + function; the warning exists to diagnose compatibility problems, + and is enabled by default. + +.. option:: -Wnon-template-friend + + Default setting; overrides :option:`-Wno-non-template-friend`. + +.. option:: -Wold-style-cast + + .. note:: + + C++ and Objective-C++ only + + Warn if an old-style (C-style) cast to a non-void type is used within + a C++ program. The new-style casts (``dynamic_cast``, + ``static_cast``, ``reinterpret_cast``, and ``const_cast``) are + less vulnerable to unintended effects and much easier to search for. + +.. option:: -Wno-old-style-cast + + Default setting; overrides :option:`-Wold-style-cast`. + +.. option:: -Woverloaded-virtual, -Woverloaded-virtual={n} + + .. note:: + + C++ and Objective-C++ only + + .. index:: overloaded virtual function, warning, warning for overloaded virtual function + + Warn when a function declaration hides virtual functions from a + base class. For example, in: + + .. code-block:: c++ + + struct A { + virtual void f(); + }; + + struct B: public A { + void f(int); // does not override + }; + + the ``A`` class version of ``f`` is hidden in ``B``, and code + like: + + .. code-block:: c++ + + B* b; + b->f(); + + fails to compile. + + The optional level suffix controls the behavior when all the + declarations in the derived class override virtual functions in the + base class, even if not all of the base functions are overridden: + + .. code-block:: c++ + + struct C { + virtual void f(); + virtual void f(int); + }; + + struct D: public C { + void f(int); // does override + } + + This pattern is less likely to be a mistake; if D is only used + virtually, the user might have decided that the base class semantics + for some of the overloads are fine. + + At level 1, this case does not warn; at level 2, it does. + :option:`-Woverloaded-virtual` by itself selects level 2. Level 1 is + included in :option:`-Wall`. + +.. option:: -Wno-overloaded-virtual + + Default setting; overrides :option:`-Woverloaded-virtual`. + +.. option:: -Wno-pmf-conversions + + .. note:: + + C++ and Objective-C++ only + + Disable the diagnostic for converting a bound pointer to member function + to a plain pointer. + +.. option:: -Wpmf-conversions + + Default setting; overrides :option:`-Wno-pmf-conversions`. + +.. option:: -Wsign-promo + + .. note:: + + C++ and Objective-C++ only + + Warn when overload resolution chooses a promotion from unsigned or + enumerated type to a signed type, over a conversion to an unsigned type of + the same size. Previous versions of G++ tried to preserve + unsignedness, but the standard mandates the current behavior. + +.. option:: -Wno-sign-promo + + Default setting; overrides :option:`-Wsign-promo`. + +.. option:: -Wtemplates + + .. note:: + + C++ and Objective-C++ only + + Warn when a primary template declaration is encountered. Some coding + rules disallow templates, and this may be used to enforce that rule. + The warning is inactive inside a system header file, such as the STL, so + one can still use the STL. One may also instantiate or specialize + templates. + +.. option:: -Wno-templates + + Default setting; overrides :option:`-Wtemplates`. + +.. option:: -Wmismatched-new-delete + + .. note:: + + C++ and Objective-C++ only + + Warn for mismatches between calls to ``operator new`` or ``operator + delete`` and the corresponding call to the allocation or deallocation function. + This includes invocations of C++ ``operator delete`` with pointers + returned from either mismatched forms of ``operator new``, or from other + functions that allocate objects for which the ``operator delete`` isn't + a suitable deallocator, as well as calls to other deallocation functions + with pointers returned from ``operator new`` for which the deallocation + function isn't suitable. + + For example, the ``delete`` expression in the function below is diagnosed + because it doesn't match the array form of the ``new`` expression + the pointer argument was returned from. Similarly, the call to ``free`` + is also diagnosed. + + .. code-block:: c++ + + void f () + { + int *a = new int[n]; + delete a; // warning: mismatch in array forms of expressions + + char *p = new char[n]; + free (p); // warning: mismatch between new and free + } + + The related option :option:`-Wmismatched-dealloc` diagnoses mismatches + involving allocation and deallocation functions other than ``operator + new`` and ``operator delete``. + + :option:`-Wmismatched-new-delete` is included in :option:`-Wall`. + +.. option:: -Wno-mismatched-new-delete + + Default setting; overrides :option:`-Wmismatched-new-delete`. + +.. option:: -Wmismatched-tags + + .. note:: + + C++ and Objective-C++ only + + Warn for declarations of structs, classes, and class templates and their + specializations with a class-key that does not match either the definition + or the first declaration if no definition is provided. + + For example, the declaration of ``struct Object`` in the argument list + of ``draw`` triggers the warning. To avoid it, either remove the redundant + class-key ``struct`` or replace it with ``class`` to match its definition. + + .. code-block:: c++ + + class Object { + public: + virtual ~Object () = 0; + }; + void draw (struct Object*); + + It is not wrong to declare a class with the class-key ``struct`` as + the example above shows. The :option:`-Wmismatched-tags` option is intended + to help achieve a consistent style of class declarations. In code that is + intended to be portable to Windows-based compilers the warning helps prevent + unresolved references due to the difference in the mangling of symbols + declared with different class-keys. The option can be used either on its + own or in conjunction with :option:`-Wredundant-tags`. + +.. option:: -Wno-mismatched-tags + + Default setting; overrides :option:`-Wmismatched-tags`. + +.. option:: -Wmultiple-inheritance + + .. note:: + + C++ and Objective-C++ only + + Warn when a class is defined with multiple direct base classes. Some + coding rules disallow multiple inheritance, and this may be used to + enforce that rule. The warning is inactive inside a system header file, + such as the STL, so one can still use the STL. One may also define + classes that indirectly use multiple inheritance. + +.. option:: -Wno-multiple-inheritance + + Default setting; overrides :option:`-Wmultiple-inheritance`. + +.. option:: -Wvirtual-inheritance + + Warn when a class is defined with a virtual direct base class. Some + coding rules disallow multiple inheritance, and this may be used to + enforce that rule. The warning is inactive inside a system header file, + such as the STL, so one can still use the STL. One may also define + classes that indirectly use virtual inheritance. + +.. option:: -Wno-virtual-inheritance + + Default setting; overrides :option:`-Wvirtual-inheritance`. + +.. option:: -Wno-virtual-move-assign + + Suppress warnings about inheriting from a virtual base with a + non-trivial C++11 move assignment operator. This is dangerous because + if the virtual base is reachable along more than one path, it is + moved multiple times, which can mean both objects end up in the + moved-from state. If the move assignment operator is written to avoid + moving from a moved-from object, this warning can be disabled. + +.. option:: -Wvirtual-move-assign + + Default setting; overrides :option:`-Wno-virtual-move-assign`. + +.. option:: -Wnamespaces + + Warn when a namespace definition is opened. Some coding rules disallow + namespaces, and this may be used to enforce that rule. The warning is + inactive inside a system header file, such as the STL, so one can still + use the STL. One may also use using directives and qualified names. + +.. option:: -Wno-namespaces + + Default setting; overrides :option:`-Wnamespaces`. + +.. option:: -Wno-terminate + + .. note:: + + C++ and Objective-C++ only + + Disable the warning about a throw-expression that will immediately + result in a call to ``terminate``. + +.. option:: -Wterminate + + Default setting; overrides :option:`-Wno-terminate`. + +.. option:: -Wno-vexing-parse + + .. note:: + + C++ and Objective-C++ only + + Warn about the most vexing parse syntactic ambiguity. This warns about + the cases when a declaration looks like a variable definition, but the + C++ language requires it to be interpreted as a function declaration. + For instance: + + .. code-block:: c++ + + void f(double a) { + int i(); // extern int i (void); + int n(int(a)); // extern int n (int); + } + + Another example: + + .. code-block:: c++ + + struct S { S(int); }; + void f(double a) { + S x(int(a)); // extern struct S x (int); + S y(int()); // extern struct S y (int (*) (void)); + S z(); // extern struct S z (void); + } + + The warning will suggest options how to deal with such an ambiguity; e.g., + it can suggest removing the parentheses or using braces instead. + + This warning is enabled by default. + +.. option:: -Wvexing-parse + + Default setting; overrides :option:`-Wno-vexing-parse`. + +.. option:: -Wno-class-conversion + + .. note:: + + C++ and Objective-C++ only + + Do not warn when a conversion function converts an + object to the same type, to a base class of that type, or to void; such + a conversion function will never be called. + +.. option:: -Wclass-conversion + + Default setting; overrides :option:`-Wno-class-conversion`. + +.. option:: -Wvolatile + + .. note:: + + C++ and Objective-C++ only + + Warn about deprecated uses of the ``volatile`` qualifier. This includes + postfix and prefix ``++`` and ``--`` expressions of + ``volatile`` -qualified types, using simple assignments where the left + operand is a ``volatile`` -qualified non-class type for their value, + compound assignments where the left operand is a ``volatile`` -qualified + non-class type, ``volatile`` -qualified function return type, + ``volatile`` -qualified parameter type, and structured bindings of a + ``volatile`` -qualified type. This usage was deprecated in C++20. + + Enabled by default with :option:`-std=c++20`. + +.. option:: -Wno-volatile + + Default setting; overrides :option:`-Wvolatile`. + +.. option:: -Wzero-as-null-pointer-constant + + .. note:: + + C++ and Objective-C++ only + + Warn when a literal :samp:`0` is used as null pointer constant. This can + be useful to facilitate the conversion to ``nullptr`` in C++11. + +.. option:: -Wno-zero-as-null-pointer-constant + + Default setting; overrides :option:`-Wzero-as-null-pointer-constant`. + +.. option:: -Waligned-new + + Warn about a new-expression of a type that requires greater alignment + than the ``alignof(std::max_align_t)`` but uses an allocation + function without an explicit alignment parameter. This option is + enabled by :option:`-Wall`. + + Normally this only warns about global allocation functions, but + :option:`-Waligned-new=all` also warns about class member allocation + functions. + +.. option:: -Wno-aligned-new + + Default setting; overrides :option:`-Waligned-new`. + +.. option:: -Wno-placement-new, -Wplacement-new={n} + + Warn about placement new expressions with undefined behavior, such as + constructing an object in a buffer that is smaller than the type of + the object. For example, the placement new expression below is diagnosed + because it attempts to construct an array of 64 integers in a buffer only + 64 bytes large. + + .. code-block:: c++ + + char buf [64]; + new (buf) int[64]; + + This warning is enabled by default. + + ``-Wplacement-new=1`` + This is the default warning level of :option:`-Wplacement-new`. At this + level the warning is not issued for some strictly undefined constructs that + GCC allows as extensions for compatibility with legacy code. For example, + the following ``new`` expression is not diagnosed at this level even + though it has undefined behavior according to the C++ standard because + it writes past the end of the one-element array. + + .. code-block:: c++ + + struct S { int n, a[1]; }; + S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]); + new (s->a)int [32](); + + ``-Wplacement-new=2`` + At this level, in addition to diagnosing all the same constructs as at level + 1, a diagnostic is also issued for placement new expressions that construct + an object in the last member of structure whose type is an array of a single + element and whose size is less than the size of the object being constructed. + While the previous example would be diagnosed, the following construct makes + use of the flexible member array extension to avoid the warning at level 2. + + .. code-block:: c++ + + struct S { int n, a[]; }; + S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]); + new (s->a)int [32](); + +.. option:: -Wplacement-new + + Default setting; overrides :option:`-Wno-placement-new`. + +.. option:: -Wcatch-value, -Wcatch-value={n} + + .. note:: + + C++ and Objective-C++ only + + Warn about catch handlers that do not catch via reference. + With :option:`-Wcatch-value=1` (or :option:`-Wcatch-value` for short) + warn about polymorphic class types that are caught by value. + With :option:`-Wcatch-value=2` warn about all class types that are caught + by value. With :option:`-Wcatch-value=3` warn about all types that are + not caught by reference. :option:`-Wcatch-value` is enabled by :option:`-Wall`. + +.. option:: -Wno-catch-value + + Default setting; overrides :option:`-Wcatch-value`. + +.. option:: -Wconditionally-supported + + .. note:: + + C++ and Objective-C++ only + + Warn for conditionally-supported (C++11 [intro.defs]) constructs. + +.. option:: -Wno-conditionally-supported + + Default setting; overrides :option:`-Wconditionally-supported`. + +.. option:: -Wno-delete-incomplete + + .. note:: + + C++ and Objective-C++ only + + Do not warn when deleting a pointer to incomplete type, which may cause + undefined behavior at runtime. This warning is enabled by default. + +.. option:: -Wdelete-incomplete + + Default setting; overrides :option:`-Wno-delete-incomplete`. + +.. option:: -Wextra-semi + + .. note:: + + C++, Objective-C++ only + + Warn about redundant semicolons after in-class function definitions. + +.. option:: -Wno-extra-semi + + Default setting; overrides :option:`-Wextra-semi`. + +.. option:: -Wno-inaccessible-base + + .. note:: + + C++, Objective-C++ only + + This option controls warnings + when a base class is inaccessible in a class derived from it due to + ambiguity. The warning is enabled by default. + Note that the warning for ambiguous virtual + bases is enabled by the :option:`-Wextra` option. + + .. code-block:: c++ + + struct A { int a; }; + + struct B : A { }; + + struct C : B, A { }; + +.. option:: -Winaccessible-base + + Default setting; overrides :option:`-Wno-inaccessible-base`. + +.. option:: -Wno-inherited-variadic-ctor + + Suppress warnings about use of C++11 inheriting constructors when the + base class inherited from has a C variadic constructor; the warning is + on by default because the ellipsis is not inherited. + +.. option:: -Winherited-variadic-ctor + + Default setting; overrides :option:`-Wno-inherited-variadic-ctor`. + +.. option:: -Wno-invalid-offsetof + + .. note:: + + C++ and Objective-C++ only + + Suppress warnings from applying the ``offsetof`` macro to a non-POD + type. According to the 2014 ISO C++ standard, applying ``offsetof`` + to a non-standard-layout type is undefined. In existing C++ implementations, + however, ``offsetof`` typically gives meaningful results. + This flag is for users who are aware that they are + writing nonportable code and who have deliberately chosen to ignore the + warning about it. + + The restrictions on ``offsetof`` may be relaxed in a future version + of the C++ standard. + +.. option:: -Winvalid-offsetof + + Default setting; overrides :option:`-Wno-invalid-offsetof`. + +.. option:: -Wsized-deallocation + + .. note:: + + C++ and Objective-C++ only + + Warn about a definition of an unsized deallocation function + + .. code-block:: c++ + + void operator delete (void *) noexcept; + void operator delete[] (void *) noexcept; + + without a definition of the corresponding sized deallocation function + + .. code-block:: c++ + + void operator delete (void *, std::size_t) noexcept; + void operator delete[] (void *, std::size_t) noexcept; + + or vice versa. Enabled by :option:`-Wextra` along with + :option:`-fsized-deallocation`. + +.. option:: -Wno-sized-deallocation + + Default setting; overrides :option:`-Wsized-deallocation`. + +.. option:: -Wsuggest-final-types + + Warn about types with virtual methods where code quality would be improved + if the type were declared with the C++11 ``final`` specifier, + or, if possible, + declared in an anonymous namespace. This allows GCC to more aggressively + devirtualize the polymorphic calls. This warning is more effective with + link-time optimization, + where the information about the class hierarchy graph is + more complete. + +.. option:: -Wno-suggest-final-types + + Default setting; overrides :option:`-Wsuggest-final-types`. + +.. option:: -Wsuggest-final-methods + + Warn about virtual methods where code quality would be improved if the method + were declared with the C++11 ``final`` specifier, + or, if possible, its type were + declared in an anonymous namespace or with the ``final`` specifier. + This warning is + more effective with link-time optimization, where the information about the + class hierarchy graph is more complete. It is recommended to first consider + suggestions of :option:`-Wsuggest-final-types` and then rebuild with new + annotations. + +.. option:: -Wno-suggest-final-methods + + Default setting; overrides :option:`-Wsuggest-final-methods`. + +.. option:: -Wsuggest-override + + Warn about overriding virtual functions that are not marked with the + ``override`` keyword. + +.. option:: -Wno-suggest-override + + Default setting; overrides :option:`-Wsuggest-override`. + +.. option:: -Wuse-after-free, -Wuse-after-free={n} + + Warn about uses of pointers to dynamically allocated objects that have + been rendered indeterminate by a call to a deallocation function. + The warning is enabled at all optimization levels but may yield different + results with optimization than without. + + ``-Wuse-after-free=1`` + At level 1 the warning attempts to diagnose only unconditional uses + of pointers made indeterminate by a deallocation call or a successful + call to ``realloc``, regardless of whether or not the call resulted + in an actual reallocatio of memory. This includes double- ``free`` + calls as well as uses in arithmetic and relational expressions. Although + undefined, uses of indeterminate pointers in equality (or inequality) + expressions are not diagnosed at this level. + + ``-Wuse-after-free=2`` + At level 2, in addition to unconditional uses, the warning also diagnoses + conditional uses of pointers made indeterminate by a deallocation call. + As at level 2, uses in equality (or inequality) expressions are not + diagnosed. For example, the second call to ``free`` in the following + function is diagnosed at this level: + + .. code-block:: c++ + + struct A { int refcount; void *data; }; + + void release (struct A *p) + { + int refcount = --p->refcount; + free (p); + if (refcount == 0) + free (p->data); // warning: p may be used after free + } + + ``-Wuse-after-free=3`` + At level 3, the warning also diagnoses uses of indeterminate pointers in + equality expressions. All uses of indeterminate pointers are undefined + but equality tests sometimes appear after calls to ``realloc`` as + an attempt to determine whether the call resulted in relocating the object + to a different address. They are diagnosed at a separate level to aid + legacy code gradually transition to safe alternatives. For example, + the equality test in the function below is diagnosed at this level: + + .. code-block:: c++ + + void adjust_pointers (int**, int); + + void grow (int **p, int n) + { + int **q = (int**)realloc (p, n *= 2); + if (q == p) + return; + adjust_pointers ((int**)q, n); + } + + To avoid the warning at this level, store offsets into allocated memory + instead of pointers. This approach obviates needing to adjust the stored + pointers after reallocation. + + :option:`-Wuse-after-free=2` is included in :option:`-Wall`. + +.. option:: -Wno-use-after-free + + Default setting; overrides :option:`-Wuse-after-free`. + +.. option:: -Wuseless-cast + + .. note:: + + C++ and Objective-C++ only + + Warn when an expression is cast to its own type. This warning does not + occur when a class object is converted to a non-reference type as that + is a way to create a temporary: + + .. code-block:: c++ + + struct S { }; + void g (S&&); + void f (S&& arg) + { + g (S(arg)); // make arg prvalue so that it can bind to S&& + } + +.. option:: -Wno-useless-cast + + Default setting; overrides :option:`-Wuseless-cast`. + +.. option:: -Wno-conversion-null + + .. note:: + + C++ and Objective-C++ only + + Do not warn for conversions between ``NULL`` and non-pointer + types. :option:`-Wconversion-null` is enabled by default. + +.. option:: -Wconversion-null + + Default setting; overrides :option:`-Wno-conversion-null`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-controlling-c-dialect.rst b/gcc/doc/gcc/gcc-command-options/options-controlling-c-dialect.rst new file mode 100644 index 00000000000..203982fc269 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-controlling-c-dialect.rst @@ -0,0 +1,544 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: dialect options, language dialect options, options, dialect + +.. _c-dialect-options: + +Options Controlling C Dialect +***************************** + +The following options control the dialect of C (or languages derived +from C, such as C++, Objective-C and Objective-C++) that the compiler +accepts: + +.. index:: ANSI support, ISO support + +.. option:: -ansi + + In C mode, this is equivalent to :option:`-std=c90`. In C++ mode, it is + equivalent to :option:`-std=c++98`. + + This turns off certain features of GCC that are incompatible with ISO + C90 (when compiling C code), or of standard C++ (when compiling C++ code), + such as the ``asm`` and ``typeof`` keywords, and + predefined macros such as ``unix`` and ``vax`` that identify the + type of system you are using. It also enables the undesirable and + rarely used ISO trigraph feature. For the C compiler, + it disables recognition of C++ style :samp:`//` comments as well as + the ``inline`` keyword. + + The alternate keywords ``__asm__``, ``__extension__``, + ``__inline__`` and ``__typeof__`` continue to work despite + :option:`-ansi`. You would not want to use them in an ISO C program, of + course, but it is useful to put them in header files that might be included + in compilations done with :option:`-ansi`. Alternate predefined macros + such as ``__unix__`` and ``__vax__`` are also available, with or + without :option:`-ansi`. + + The :option:`-ansi` option does not cause non-ISO programs to be + rejected gratuitously. For that, :option:`-Wpedantic` is required in + addition to :option:`-ansi`. See :ref:`warning-options`. + + The macro ``__STRICT_ANSI__`` is predefined when the :option:`-ansi` + option is used. Some header files may notice this macro and refrain + from declaring certain functions or defining certain macros that the + ISO standard doesn't call for; this is to avoid interfering with any + programs that might use these names for other things. + + Functions that are normally built in but do not have semantics + defined by ISO C (such as ``alloca`` and ``ffs``) are not built-in + functions when :option:`-ansi` is used. See :ref:`other-builtins`, for details of the functions + affected. + +.. option:: -std= + + Determine the language standard. See :ref:`standards`, for details of these standard versions. This option + is currently only supported when compiling C or C++. + + The compiler can accept several base standards, such as :samp:`c90` or + :samp:`c++98`, and GNU dialects of those standards, such as + :samp:`gnu90` or :samp:`gnu++98`. When a base standard is specified, the + compiler accepts all programs following that standard plus those + using GNU extensions that do not contradict it. For example, + :option:`-std=c90` turns off certain features of GCC that are + incompatible with ISO C90, such as the ``asm`` and ``typeof`` + keywords, but not other GNU extensions that do not have a meaning in + ISO C90, such as omitting the middle term of a ``?:`` + expression. On the other hand, when a GNU dialect of a standard is + specified, all features supported by the compiler are enabled, even when + those features change the meaning of the base standard. As a result, some + strict-conforming programs may be rejected. The particular standard + is used by :option:`-Wpedantic` to identify which features are GNU + extensions given that version of the standard. For example + :option:`-std=gnu90 -Wpedantic` warns about C++ style :samp:`//` + comments, while :option:`-std=gnu99 -Wpedantic` does not. + + A value for this option must be provided; possible values are + + :samp:`c90` :samp:`c89` :samp:`iso9899:1990` + Support all ISO C90 programs (certain GNU extensions that conflict + with ISO C90 are disabled). Same as :option:`-ansi` for C code. + + :samp:`iso9899:199409` + ISO C90 as modified in amendment 1. + + :samp:`c99` :samp:`c9x` :samp:`iso9899:1999` :samp:`iso9899:199x` + ISO C99. This standard is substantially completely supported, modulo + bugs and floating-point issues + (mainly but not entirely relating to optional C99 features from + Annexes F and G). See + https://gcc.gnu.org/c99status.html for more information. The + names :samp:`c9x` and :samp:`iso9899:199x` are deprecated. + + :samp:`c11` :samp:`c1x` :samp:`iso9899:2011` + ISO C11, the 2011 revision of the ISO C standard. This standard is + substantially completely supported, modulo bugs, floating-point issues + (mainly but not entirely relating to optional C11 features from + Annexes F and G) and the optional Annexes K (Bounds-checking + interfaces) and L (Analyzability). The name :samp:`c1x` is deprecated. + + :samp:`c17` :samp:`c18` :samp:`iso9899:2017` :samp:`iso9899:2018` + ISO C17, the 2017 revision of the ISO C standard + (published in 2018). This standard is + same as C11 except for corrections of defects (all of which are also + applied with :option:`-std=c11`) and a new value of + ``__STDC_VERSION__``, and so is supported to the same extent as C11. + + :samp:`c2x` + The next version of the ISO C standard, still under development. The + support for this version is experimental and incomplete. + + :samp:`gnu90` :samp:`gnu89` + GNU dialect of ISO C90 (including some C99 features). + + :samp:`gnu99` :samp:`gnu9x` + GNU dialect of ISO C99. The name :samp:`gnu9x` is deprecated. + + :samp:`gnu11` :samp:`gnu1x` + GNU dialect of ISO C11. + The name :samp:`gnu1x` is deprecated. + + :samp:`gnu17` :samp:`gnu18` + GNU dialect of ISO C17. This is the default for C code. + + :samp:`gnu2x` + The next version of the ISO C standard, still under development, plus + GNU extensions. The support for this version is experimental and + incomplete. + + :samp:`c++98` :samp:`c++03` + The 1998 ISO C++ standard plus the 2003 technical corrigendum and some + additional defect reports. Same as :option:`-ansi` for C++ code. + + :samp:`gnu++98` :samp:`gnu++03` + GNU dialect of :option:`-std=c++98`. + + :samp:`c++11` :samp:`c++0x` + The 2011 ISO C++ standard plus amendments. + The name :samp:`c++0x` is deprecated. + + :samp:`gnu++11` :samp:`gnu++0x` + GNU dialect of :option:`-std=c++11`. + The name :samp:`gnu++0x` is deprecated. + + :samp:`c++14` :samp:`c++1y` + The 2014 ISO C++ standard plus amendments. + The name :samp:`c++1y` is deprecated. + + :samp:`gnu++14` :samp:`gnu++1y` + GNU dialect of :option:`-std=c++14`. + The name :samp:`gnu++1y` is deprecated. + + :samp:`c++17` :samp:`c++1z` + The 2017 ISO C++ standard plus amendments. + The name :samp:`c++1z` is deprecated. + + :samp:`gnu++17` :samp:`gnu++1z` + GNU dialect of :option:`-std=c++17`. + This is the default for C++ code. + The name :samp:`gnu++1z` is deprecated. + + :samp:`c++20` :samp:`c++2a` + The 2020 ISO C++ standard plus amendments. + Support is experimental, and could change in incompatible ways in + future releases. + The name :samp:`c++2a` is deprecated. + + :samp:`gnu++20` :samp:`gnu++2a` + GNU dialect of :option:`-std=c++20`. + Support is experimental, and could change in incompatible ways in + future releases. + The name :samp:`gnu++2a` is deprecated. + + :samp:`c++2b` :samp:`c++23` + The next revision of the ISO C++ standard, planned for + 2023. Support is highly experimental, and will almost certainly + change in incompatible ways in future releases. + + :samp:`gnu++2b` :samp:`gnu++23` + GNU dialect of :option:`-std=c++2b`. Support is highly experimental, + and will almost certainly change in incompatible ways in future + releases. + +.. option:: -aux-info {filename} + + Output to the given filename prototyped declarations for all functions + declared and/or defined in a translation unit, including those in header + files. This option is silently ignored in any language other than C. + + Besides declarations, the file indicates, in comments, the origin of + each declaration (source file and line), whether the declaration was + implicit, prototyped or unprototyped (:samp:`I`, :samp:`N` for new or + :samp:`O` for old, respectively, in the first character after the line + number and the colon), and whether it came from a declaration or a + definition (:samp:`C` or :samp:`F`, respectively, in the following + character). In the case of function definitions, a K&R-style list of + arguments followed by their declarations is also provided, inside + comments, after the declaration. + +.. option:: -fno-asm + + Do not recognize ``asm``, ``inline`` or ``typeof`` as a + keyword, so that code can use these words as identifiers. You can use + the keywords ``__asm__``, ``__inline__`` and ``__typeof__`` + instead. In C, :option:`-ansi` implies :option:`-fno-asm`. + + In C++, ``inline`` is a standard keyword and is not affected by + this switch. You may want to use the :option:`-fno-gnu-keywords` flag + instead, which disables ``typeof`` but not ``asm`` and + ``inline``. In C99 mode (:option:`-std=c99` or :option:`-std=gnu99`), + this switch only affects the ``asm`` and ``typeof`` keywords, + since ``inline`` is a standard keyword in ISO C99. In C2X mode + (:option:`-std=c2x` or :option:`-std=gnu2x`), this switch only affects + the ``asm`` keyword, since ``typeof`` is a standard keyword in + ISO C2X. + +.. option:: -fasm + + Default setting; overrides :option:`-fno-asm`. + +.. index:: built-in functions + +.. option:: -fno-builtin, -fno-builtin-function + + Don't recognize built-in functions that do not begin with + :samp:`__builtin_` as prefix. See :ref:`other-builtins`, for details of the functions affected, + including those which are not built-in functions when :option:`-ansi` or + :option:`-std` options for strict ISO C conformance are used because they + do not have an ISO standard meaning. + + GCC normally generates special code to handle certain built-in functions + more efficiently; for instance, calls to ``alloca`` may become single + instructions which adjust the stack directly, and calls to ``memcpy`` + may become inline copy loops. The resulting code is often both smaller + and faster, but since the function calls no longer appear as such, you + cannot set a breakpoint on those calls, nor can you change the behavior + of the functions by linking with a different library. In addition, + when a function is recognized as a built-in function, GCC may use + information about that function to warn about problems with calls to + that function, or to generate more efficient code, even if the + resulting code still contains calls to that function. For example, + warnings are given with :option:`-Wformat` for bad calls to + ``printf`` when ``printf`` is built in and ``strlen`` is + known not to modify global memory. + + With the :option:`-fno-builtin-function` option + only the built-in function :samp:`{function}` is + disabled. :samp:`{function}` must not begin with :samp:`__builtin_`. If a + function is named that is not built-in in this version of GCC, this + option is ignored. There is no corresponding + :option:`-fbuiltin-function` option; if you wish to enable + built-in functions selectively when using :option:`-fno-builtin` or + :option:`-ffreestanding`, you may define macros such as: + + .. code-block:: c++ + + #define abs(n) __builtin_abs ((n)) + #define strcpy(d, s) __builtin_strcpy ((d), (s)) + +.. option:: -fbuiltin + + Default setting; overrides :option:`-fno-builtin`. + +.. option:: -fcond-mismatch + + Allow conditional expressions with mismatched types in the second and + third arguments. The value of such an expression is void. This option + is not supported for C++. + +.. index:: hosted environment + +.. option:: -ffreestanding + + Assert that compilation targets a freestanding environment. This + implies :option:`-fno-builtin`. A freestanding environment + is one in which the standard library may not exist, and program startup may + not necessarily be at ``main``. The most obvious example is an OS kernel. + This is equivalent to :option:`-fno-hosted`. + + See :ref:`standards`, for details of + freestanding and hosted environments. + +.. option:: -fgimple + + Enable parsing of function definitions marked with ``__GIMPLE``. + This is an experimental feature that allows unit testing of GIMPLE + passes. + +.. option:: -fgnu-tm + + When the option :option:`-fgnu-tm` is specified, the compiler + generates code for the Linux variant of Intel's current Transactional + Memory ABI specification document (Revision 1.1, May 6 2009). This is + an experimental feature whose interface may change in future versions + of GCC, as the official specification changes. Please note that not + all architectures are supported for this feature. + + For more information on GCC's support for transactional memory, + see :ref:`libitm:enabling-libitm`. + + Note that the transactional memory feature is not supported with + non-call exceptions (:option:`-fnon-call-exceptions`). + +.. option:: -fgnu89-inline + + The option :option:`-fgnu89-inline` tells GCC to use the traditional + GNU semantics for ``inline`` functions when in C99 mode. + See :ref:`inline`. + Using this option is roughly equivalent to adding the + :fn-attr:`gnu_inline` function attribute to all inline functions + (see :ref:`function-attributes`). + + The option :option:`-fno-gnu89-inline` explicitly tells GCC to use the + C99 semantics for ``inline`` when in C99 or gnu99 mode (i.e., it + specifies the default behavior). + This option is not supported in :option:`-std=c90` or + :option:`-std=gnu90` mode. + + The preprocessor macros ``__GNUC_GNU_INLINE__`` and + ``__GNUC_STDC_INLINE__`` may be used to check which semantics are + in effect for ``inline`` functions. See :ref:`cpp:common-predefined-macros`. + +.. index:: hosted environment + +.. option:: -fhosted + + Assert that compilation targets a hosted environment. This implies + :option:`-fbuiltin`. A hosted environment is one in which the + entire standard library is available, and in which ``main`` has a return + type of ``int``. Examples are nearly everything except a kernel. + This is equivalent to :option:`-fno-freestanding`. + +.. option:: -flax-vector-conversions + + Allow implicit conversions between vectors with differing numbers of + elements and/or incompatible element types. This option should not be + used for new code. + +.. option:: -fms-extensions + + Accept some non-standard constructs used in Microsoft header files. + + In C++ code, this allows member names in structures to be similar + to previous types declarations. + + .. code-block:: c++ + + typedef int UOW; + struct ABC { + UOW UOW; + }; + + Some cases of unnamed fields in structures and unions are only + accepted with this option. See :ref:`unnamed-fields`, for details. + + Note that this option is off for all targets except for x86 + targets using ms-abi. + +.. index:: Offloading targets, OpenACC offloading targets, OpenMP offloading targets + +.. option:: -foffload=disable + + Specify for which OpenMP and OpenACC offload targets code should be generated. + The default behavior, equivalent to :option:`-foffload=default`, is to generate + code for all supported offload targets. The :option:`-foffload=disable` form + generates code only for the host fallback, while + :option:`-foffload=target-list` generates code only for the specified + comma-separated list of offload targets. + + Offload targets are specified in GCC's internal target-triplet format. You can + run the compiler with :option:`-v` to show the list of configured offload targets + under ``OFFLOAD_TARGET_NAMES``. + +.. index:: Offloading options, OpenACC offloading options, OpenMP offloading options + +.. option:: -foffload-options={options} + + With :option:`-foffload-options=options`, GCC passes the specified + :samp:`{options}` to the compilers for all enabled offloading targets. You can + specify options that apply only to a specific target or targets by using + the :option:`-foffload-options=target-list=options` form. The + :samp:`{target-list}` is a comma-separated list in the same format as for the + :option:`-foffload=` option. + + Typical command lines are + + :option:`-foffload-options=-lgfortran` :option:`-foffload-options=-lm` + :option:`-foffload-options="-lgfortran-lm` :option:`-lm"` :option:`-foffload-options=nvptx-none=-latomic` + :option:`-foffload-options=amdgcn-amdhsa=-march=gfx906` :option:`-foffload-options=-lm` + +.. index:: OpenACC accelerator programming + +.. option:: -fopenacc + + Enable handling of OpenACC directives ``#pragma acc`` in C/C++ and + ``!$acc`` in Fortran. When :option:`-fopenacc` is specified, the + compiler generates accelerated code according to the OpenACC Application + Programming Interface v2.6 https://www.openacc.org. This option + implies :option:`-pthread`, and thus is only supported on targets that + have support for :option:`-pthread`. + +.. index:: OpenACC accelerator programming + +.. option:: -fopenacc-dim={geom} + + Specify default compute dimensions for parallel offload regions that do + not explicitly specify. The :samp:`{geom}` value is a triple of + ':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size + can be omitted, to use a target-specific default value. + +.. index:: OpenMP parallel + +.. option:: -fopenmp + + Enable handling of OpenMP directives ``#pragma omp`` in C/C++, + ``[[omp::directive(...)]]`` and ``[[omp::sequence(...)]]`` in C++ and + ``!$omp`` in Fortran. When :option:`-fopenmp` is specified, the + compiler generates parallel code according to the OpenMP Application + Program Interface v4.5 https://www.openmp.org. This option + implies :option:`-pthread`, and thus is only supported on targets that + have support for :option:`-pthread`. :option:`-fopenmp` implies + :option:`-fopenmp-simd`. + +.. index:: OpenMP SIMD, SIMD + +.. option:: -fopenmp-simd + + Enable handling of OpenMP's :gcc-attr:`simd`, ``declare simd``, + ``declare reduction``, ``assume``, ``ordered``, ``scan``, + ``loop`` directives and combined or composite directives with + :gcc-attr:`simd` as constituent with ``#pragma omp`` in C/C++, + ``[[omp::directive(...)]]`` and ``[[omp::sequence(...)]]`` in C++ + and ``!$omp`` in Fortran. Other OpenMP directives are ignored. + +.. option:: -fpermitted-flt-eval-methods={style} + + ISO/IEC TS 18661-3 defines new permissible values for + ``FLT_EVAL_METHOD`` that indicate that operations and constants with + a semantic type that is an interchange or extended format should be + evaluated to the precision and range of that type. These new values are + a superset of those permitted under C99/C11, which does not specify the + meaning of other positive values of ``FLT_EVAL_METHOD``. As such, code + conforming to C11 may not have been written expecting the possibility of + the new values. + + :option:`-fpermitted-flt-eval-methods` specifies whether the compiler + should allow only the values of ``FLT_EVAL_METHOD`` specified in C99/C11, + or the extended set of values specified in ISO/IEC TS 18661-3. + + :samp:`{style}` is either ``c11`` or ``ts-18661-3`` as appropriate. + + The default when in a standards compliant mode (:option:`-std=c11` or similar) + is :option:`-fpermitted-flt-eval-methods=c11`. The default when in a GNU + dialect (:option:`-std=gnu11` or similar) is + :option:`-fpermitted-flt-eval-methods=ts-18661-3`. + +.. option:: -fplan9-extensions + + Accept some non-standard constructs used in Plan 9 code. + + This enables :option:`-fms-extensions`, permits passing pointers to + structures with anonymous fields to functions that expect pointers to + elements of the type of the field, and permits referring to anonymous + fields declared using a typedef. See :ref:`unnamed-fields`, for details. This is only + supported for C, not C++. + +.. option:: -fsigned-bitfields, -funsigned-bitfields, -fno-signed-bitfields, -fno-unsigned-bitfields + + These options control whether a bit-field is signed or unsigned, when the + declaration does not use either ``signed`` or ``unsigned``. By + default, such a bit-field is signed, because this is consistent: the + basic integer types such as ``int`` are signed types. + +.. option:: -fsigned-char + + Let the type ``char`` be signed, like ``signed char``. + + Note that this is equivalent to :option:`-fno-unsigned-char`, which is + the negative form of :option:`-funsigned-char`. Likewise, the option + :option:`-fno-signed-char` is equivalent to :option:`-funsigned-char`. + +.. option:: -funsigned-char + + Let the type ``char`` be unsigned, like ``unsigned char``. + + Each kind of machine has a default for what ``char`` should + be. It is either like ``unsigned char`` by default or like + ``signed char`` by default. + + Ideally, a portable program should always use ``signed char`` or + ``unsigned char`` when it depends on the signedness of an object. + But many programs have been written to use plain ``char`` and + expect it to be signed, or expect it to be unsigned, depending on the + machines they were written for. This option, and its inverse, let you + make such a program work with the opposite default. + + The type ``char`` is always a distinct type from each of + ``signed char`` or ``unsigned char``, even though its behavior + is always just like one of those two. + +.. option:: -fstrict-flex-arrays + + Control when to treat the trailing array of a structure as a flexible array + member for the purpose of accessing the elements of such an array. + The positive form is equivalent to :option:`-fstrict-flex-arrays=3`, which is the + strictest. A trailing array is treated as a flexible array member only when it + is declared as a flexible array member per C99 standard onwards. + The negative form is equivalent to :option:`-fstrict-flex-arrays=0`, which is the + least strict. All trailing arrays of structures are treated as flexible array + members. + +.. option:: -fno-strict-flex-arrays + + Default setting; overrides :option:`-fstrict-flex-arrays`. + +.. index:: fstrict-flex-arrays=level + +.. option:: -fstrict-flex-arrays={level} + + Control when to treat the trailing array of a structure as a flexible array + member for the purpose of accessing the elements of such an array. The value + of :samp:`{level}` controls the level of strictness. + + The possible values of :samp:`{level}` are the same as for the + ``strict_flex_array`` attribute (see :ref:`variable-attributes`). + + You can control this behavior for a specific trailing array field of a + structure by using the variable attribute ``strict_flex_array`` attribute + (see :ref:`variable-attributes`). + +.. option:: -fsso-struct={endianness} + + Set the default scalar storage order of structures and unions to the + specified endianness. The accepted values are :samp:`big-endian`, + :samp:`little-endian` and :samp:`native` for the native endianness of + the target (the default). This option is not supported for C++. + + .. warning:: + + The :option:`-fsso-struct` switch causes GCC to generate + code that is not binary compatible with code generated without it if the + specified endianness is not the native endianness of the target. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-controlling-objective-c-and-objective-c++-dialects.rst b/gcc/doc/gcc/gcc-command-options/options-controlling-objective-c-and-objective-c++-dialects.rst new file mode 100644 index 00000000000..119e646b3d7 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-controlling-objective-c-and-objective-c++-dialects.rst @@ -0,0 +1,316 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: compiler options, Objective-C and Objective-C++, Objective-C and Objective-C++ options, command-line, options, Objective-C and Objective-C++ + +.. _objective-c-and-objective-c++-dialect-options: + +Options Controlling Objective-C and Objective-C++ Dialects +********************************************************** + +.. note:: + + This manual does not describe the Objective-C and Objective-C++ + languages themselves. See :ref:`standards`, for references. + +This section describes the command-line options that are only meaningful +for Objective-C and Objective-C++ programs. You can also use most of +the language-independent GNU compiler options. +For example, you might compile a file :samp:`some_class.m` like this: + +.. code-block:: shell + + gcc -g -fgnu-runtime -O -c some_class.m + +In this example, :option:`-fgnu-runtime` is an option meant only for +Objective-C and Objective-C++ programs; you can use the other options with +any language supported by GCC. + +Note that since Objective-C is an extension of the C language, Objective-C +compilations may also use options specific to the C front-end (e.g., +:option:`-Wtraditional`). Similarly, Objective-C++ compilations may use +C++-specific options (e.g., :option:`-Wabi`). + +Here is a list of options that are *only* for compiling Objective-C +and Objective-C++ programs: + +.. option:: -fconstant-string-class={class-name} + + Use :samp:`{class-name}` as the name of the class to instantiate for each + literal string specified with the syntax ``@"..."``. The default + class name is ``NXConstantString`` if the GNU runtime is being used, and + ``NSConstantString`` if the NeXT runtime is being used (see below). The + :option:`-fconstant-cfstrings` option, if also present, overrides the + :option:`-fconstant-string-class` setting and cause ``@"..."`` literals + to be laid out as constant CoreFoundation strings. + +.. option:: -fgnu-runtime + + Generate object code compatible with the standard GNU Objective-C + runtime. This is the default for most types of systems. + +.. option:: -fnext-runtime + + Generate output compatible with the NeXT runtime. This is the default + for NeXT-based systems, including Darwin and Mac OS X. The macro + ``__NEXT_RUNTIME__`` is predefined if (and only if) this option is + used. + +.. option:: -fno-nil-receivers + + Assume that all Objective-C message dispatches (``[receiver + message:arg]``) in this translation unit ensure that the receiver is + not ``nil``. This allows for more efficient entry points in the + runtime to be used. This option is only available in conjunction with + the NeXT runtime and ABI version 0 or 1. + +.. option:: -fnil-receivers + + Default setting; overrides :option:`-fno-nil-receivers`. + +.. option:: -fobjc-abi-version={n} + + Use version :samp:`{n}` of the Objective-C ABI for the selected runtime. + This option is currently supported only for the NeXT runtime. In that + case, Version 0 is the traditional (32-bit) ABI without support for + properties and other Objective-C 2.0 additions. Version 1 is the + traditional (32-bit) ABI with support for properties and other + Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If + nothing is specified, the default is Version 0 on 32-bit target + machines, and Version 2 on 64-bit target machines. + +.. option:: -fobjc-call-cxx-cdtors + + For each Objective-C class, check if any of its instance variables is a + C++ object with a non-trivial default constructor. If so, synthesize a + special ``- (id) .cxx_construct`` instance method which runs + non-trivial default constructors on any such instance variables, in order, + and then return ``self``. Similarly, check if any instance variable + is a C++ object with a non-trivial destructor, and if so, synthesize a + special ``- (void) .cxx_destruct`` method which runs + all such default destructors, in reverse order. + + The ``- (id) .cxx_construct`` and ``- (void) .cxx_destruct`` + methods thusly generated only operate on instance variables + declared in the current Objective-C class, and not those inherited + from superclasses. It is the responsibility of the Objective-C + runtime to invoke all such methods in an object's inheritance + hierarchy. The ``- (id) .cxx_construct`` methods are invoked + by the runtime immediately after a new object instance is allocated; + the ``- (void) .cxx_destruct`` methods are invoked immediately + before the runtime deallocates an object instance. + + As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has + support for invoking the ``- (id) .cxx_construct`` and + ``- (void) .cxx_destruct`` methods. + +.. option:: -fobjc-direct-dispatch + + Allow fast jumps to the message dispatcher. On Darwin this is + accomplished via the comm page. + +.. option:: -fobjc-exceptions + + Enable syntactic support for structured exception handling in + Objective-C, similar to what is offered by C++. This option + is required to use the Objective-C keywords ``@try``, + ``@throw``, ``@catch``, ``@finally`` and + ``@synchronized``. This option is available with both the GNU + runtime and the NeXT runtime (but not available in conjunction with + the NeXT runtime on Mac OS X 10.2 and earlier). + +.. option:: -fobjc-gc + + Enable garbage collection (GC) in Objective-C and Objective-C++ + programs. This option is only available with the NeXT runtime; the + GNU runtime has a different garbage collection implementation that + does not require special compiler flags. + +.. option:: -fobjc-nilcheck + + For the NeXT runtime with version 2 of the ABI, check for a nil + receiver in method invocations before doing the actual method call. + This is the default and can be disabled using + :option:`-fno-objc-nilcheck`. Class methods and super calls are never + checked for nil in this way no matter what this flag is set to. + Currently this flag does nothing when the GNU runtime, or an older + version of the NeXT runtime ABI, is used. + +.. option:: -fobjc-std=objc1 + + Conform to the language syntax of Objective-C 1.0, the language + recognized by GCC 4.0. This only affects the Objective-C additions to + the C/C++ language; it does not affect conformance to C/C++ standards, + which is controlled by the separate C/C++ dialect option flags. When + this option is used with the Objective-C or Objective-C++ compiler, + any Objective-C syntax that is not recognized by GCC 4.0 is rejected. + This is useful if you need to make sure that your Objective-C code can + be compiled with older versions of GCC. + +.. option:: -freplace-objc-classes + + Emit a special marker instructing :command:`ld(1)` not to statically link in + the resulting object file, and allow :command:`dyld(1)` to load it in at + run time instead. This is used in conjunction with the Fix-and-Continue + debugging mode, where the object file in question may be recompiled and + dynamically reloaded in the course of program execution, without the need + to restart the program itself. Currently, Fix-and-Continue functionality + is only available in conjunction with the NeXT runtime on Mac OS X 10.3 + and later. + +.. option:: -fzero-link + + When compiling for the NeXT runtime, the compiler ordinarily replaces calls + to ``objc_getClass("...")`` (when the name of the class is known at + compile time) with static class references that get initialized at load time, + which improves run-time performance. Specifying the :option:`-fzero-link` flag + suppresses this behavior and causes calls to ``objc_getClass("...")`` + to be retained. This is useful in Zero-Link debugging mode, since it allows + for individual class implementations to be modified during program execution. + The GNU runtime currently always retains calls to ``objc_get_class("...")`` + regardless of command-line options. + +.. option:: -fno-local-ivars + + By default instance variables in Objective-C can be accessed as if + they were local variables from within the methods of the class they're + declared in. This can lead to shadowing between instance variables + and other variables declared either locally inside a class method or + globally with the same name. Specifying the :option:`-fno-local-ivars` + flag disables this behavior thus avoiding variable shadowing issues. + +.. option:: -flocal-ivars + + Default setting; overrides :option:`-fno-local-ivars`. + +.. option:: -fivar-visibility=[public|protected|private|package] + + Set the default instance variable visibility to the specified option + so that instance variables declared outside the scope of any access + modifier directives default to the specified visibility. + +.. option:: -gen-decls + + Dump interface declarations for all classes seen in the source file to a + file named :samp:`{sourcename}.decl`. + +.. option:: -Wassign-intercept + + .. note:: + + Objective-C and Objective-C++ only + + Warn whenever an Objective-C assignment is being intercepted by the + garbage collector. + +.. option:: -Wno-assign-intercept + + Default setting; overrides :option:`-Wassign-intercept`. + +.. option:: -Wno-property-assign-default + + .. note:: + + Objective-C and Objective-C++ only + + Do not warn if a property for an Objective-C object has no assign + semantics specified. + +.. option:: -Wproperty-assign-default + + Default setting; overrides :option:`-Wno-property-assign-default`. + +.. option:: -Wno-protocol + + .. note:: + + Objective-C and Objective-C++ only + + If a class is declared to implement a protocol, a warning is issued for + every method in the protocol that is not implemented by the class. The + default behavior is to issue a warning for every method not explicitly + implemented in the class, even if a method implementation is inherited + from the superclass. If you use the :option:`-Wno-protocol` option, then + methods inherited from the superclass are considered to be implemented, + and no warning is issued for them. + +.. option:: -Wprotocol + + Default setting; overrides :option:`-Wno-protocol`. + +.. option:: -Wobjc-root-class + + .. note:: + + Objective-C and Objective-C++ only + + Warn if a class interface lacks a superclass. Most classes will inherit + from ``NSObject`` (or ``Object``) for example. When declaring + classes intended to be root classes, the warning can be suppressed by + marking their interfaces with ``__attribute__((objc_root_class))``. + +.. option:: -Wselector + + .. note:: + + Objective-C and Objective-C++ only + + Warn if multiple methods of different types for the same selector are + found during compilation. The check is performed on the list of methods + in the final stage of compilation. Additionally, a check is performed + for each selector appearing in a ``@selector(...)`` + expression, and a corresponding method for that selector has been found + during compilation. Because these checks scan the method table only at + the end of compilation, these warnings are not produced if the final + stage of compilation is not reached, for example because an error is + found during compilation, or because the :option:`-fsyntax-only` option is + being used. + +.. option:: -Wno-selector + + Default setting; overrides :option:`-Wselector`. + +.. option:: -Wstrict-selector-match + + .. note:: + + Objective-C and Objective-C++ only + + Warn if multiple methods with differing argument and/or return types are + found for a given selector when attempting to send a message using this + selector to a receiver of type ``id`` or ``Class``. When this flag + is off (which is the default behavior), the compiler omits such warnings + if any differences found are confined to types that share the same size + and alignment. + +.. option:: -Wno-strict-selector-match + + Default setting; overrides :option:`-Wstrict-selector-match`. + +.. option:: -Wundeclared-selector + + .. note:: + + Objective-C and Objective-C++ only + + Warn if a ``@selector(...)`` expression referring to an + undeclared selector is found. A selector is considered undeclared if no + method with that name has been declared before the + ``@selector(...)`` expression, either explicitly in an + ``@interface`` or ``@protocol`` declaration, or implicitly in + an ``@implementation`` section. This option always performs its + checks as soon as a ``@selector(...)`` expression is found, + while :option:`-Wselector` only performs its checks in the final stage of + compilation. This also enforces the coding style convention + that methods and selectors must be declared before being used. + +.. option:: -Wno-undeclared-selector + + Default setting; overrides :option:`-Wundeclared-selector`. + +.. option:: -print-objc-runtime-info + + Generate C header describing the largest structure that is passed by + value, if any. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-controlling-the-kind-of-output.rst b/gcc/doc/gcc/gcc-command-options/options-controlling-the-kind-of-output.rst new file mode 100644 index 00000000000..61420c1c395 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-controlling-the-kind-of-output.rst @@ -0,0 +1,732 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _overall-options: + +Options Controlling the Kind of Output +************************************** + +Compilation can involve up to four stages: preprocessing, compilation +proper, assembly and linking, always in that order. GCC is capable of +preprocessing and compiling several files either into several +assembler input files, or into one assembler input file; then each +assembler input file produces an object file, and linking combines all +the object files (those newly compiled, and those specified as input) +into an executable file. + +.. index:: file name suffix + +For any given input file, the file name suffix determines what kind of +compilation is done: + +:samp:`{file}.c` + C source code that must be preprocessed. + +:samp:`{file}.i` + C source code that should not be preprocessed. + +:samp:`{file}.ii` + C++ source code that should not be preprocessed. + +:samp:`{file}.m` + Objective-C source code. Note that you must link with the :samp:`libobjc` + library to make an Objective-C program work. + +:samp:`{file}.mi` + Objective-C source code that should not be preprocessed. + +:samp:`{file}.mm` :samp:`{file}.M` + Objective-C++ source code. Note that you must link with the :samp:`libobjc` + library to make an Objective-C++ program work. Note that :samp:`.M` refers + to a literal capital M. + +:samp:`{file}.mii` + Objective-C++ source code that should not be preprocessed. + +:samp:`{file}.h` + C, C++, Objective-C or Objective-C++ header file to be turned into a + precompiled header (default), or C, C++ header file to be turned into an + Ada spec (via the :option:`-fdump-ada-spec` switch). + +:samp:`{file}.cc` :samp:`{file}.cp` :samp:`{file}.cxx` :samp:`{file}.cpp` :samp:`{file}.CPP` :samp:`{file}.c++` :samp:`{file}.C` + C++ source code that must be preprocessed. Note that in :samp:`.cxx`, + the last two letters must both be literally :samp:`x`. Likewise, + :samp:`.C` refers to a literal capital C. + +:samp:`{file}.mm` :samp:`{file}.M` + Objective-C++ source code that must be preprocessed. + +:samp:`{file}.mii` + Objective-C++ source code that should not be preprocessed. + +:samp:`{file}.hh` :samp:`{file}.H` :samp:`{file}.hp` :samp:`{file}.hxx` :samp:`{file}.hpp` :samp:`{file}.HPP` :samp:`{file}.h++` :samp:`{file}.tcc` + C++ header file to be turned into a precompiled header or Ada spec. + +:samp:`{file}.f` :samp:`{file}.for` :samp:`{file}.ftn` + Fixed form Fortran source code that should not be preprocessed. + +:samp:`{file}.F` :samp:`{file}.FOR` :samp:`{file}.fpp` :samp:`{file}.FPP` :samp:`{file}.FTN` + Fixed form Fortran source code that must be preprocessed (with the traditional + preprocessor). + +:samp:`{file}.f90` :samp:`{file}.f95` :samp:`{file}.f03` :samp:`{file}.f08` + Free form Fortran source code that should not be preprocessed. + +:samp:`{file}.F90` :samp:`{file}.F95` :samp:`{file}.F03` :samp:`{file}.F08` + Free form Fortran source code that must be preprocessed (with the + traditional preprocessor). + +:samp:`{file}.go` + Go source code. + +:samp:`{file}.d` + D source code. + +:samp:`{file}.di` + D interface file. + +:samp:`{file}.dd` + D documentation code (Ddoc). + +:samp:`{file}.ads` + Ada source code file that contains a library unit declaration (a + declaration of a package, subprogram, or generic, or a generic + instantiation), or a library unit renaming declaration (a package, + generic, or subprogram renaming declaration). Such files are also + called :dfn:`specs`. + +:samp:`{file}.adb` + Ada source code file containing a library unit body (a subprogram or + package body). Such files are also called :dfn:`bodies`. + + .. GCC also knows about some suffixes for languages not yet included: + Ratfor: + @var{file}.r + +:samp:`{file}.s` + Assembler code. + +:samp:`{file}.S` :samp:`{file}.sx` + Assembler code that must be preprocessed. + +``other`` + An object file to be fed straight into linking. + Any file name with no recognized suffix is treated this way. + +.. index:: x + +You can specify the input language explicitly with the :option:`-x` option: + +:samp:`-x {language}` + Specify explicitly the :samp:`{language}` for the following input files + (rather than letting the compiler choose a default based on the file + name suffix). This option applies to all following input files until + the next :option:`-x` option. Possible values for :samp:`{language}` are: + + :samp:`c` :samp:`c-header` :samp:`cpp-output` + :samp:`c++` :samp:`c++-header` :samp:`c++-system-header` :samp:`c++-user-header` :samp:`c++-cpp-output` + :samp:`objective-c` :samp:`objective-c-header` :samp:`objective-c-cpp-output` + :samp:`objective-c++` :samp:`objective-c++-header` :samp:`objective-c++-cpp-output` + :samp:`assembler` :samp:`assembler-with-cpp` :samp:`ada` :samp:`d` + :samp:`f77` :samp:`f77-cpp-input` :samp:`f95` :samp:`f95-cpp-input` :samp:`go` + +``-x none`` + Turn off any specification of a language, so that subsequent files are + handled according to their file name suffixes (as they are if :option:`-x` + has not been used at all). + +If you only want some of the stages of compilation, you can use +:option:`-x` (or filename suffixes) to tell :command:`gcc` where to start, and +one of the options :option:`-c`, :option:`-S`, or :option:`-E` to say where +:command:`gcc` is to stop. Note that some combinations (for example, +:samp:`-x cpp-output -E`) instruct :command:`gcc` to do nothing at all. + +.. option:: -c + + Compile or assemble the source files, but do not link. The linking + stage simply is not done. The ultimate output is in the form of an + object file for each source file. + + By default, the object file name for a source file is made by replacing + the suffix :samp:`.c`, :samp:`.i`, :samp:`.s`, etc., with :samp:`.o`. + + Unrecognized input files, not requiring compilation or assembly, are + ignored. + +.. option:: -S + + Stop after the stage of compilation proper; do not assemble. The output + is in the form of an assembler code file for each non-assembler input + file specified. + + By default, the assembler file name for a source file is made by + replacing the suffix :samp:`.c`, :samp:`.i`, etc., with :samp:`.s`. + + Input files that don't require compilation are ignored. + +.. option:: -E + + Stop after the preprocessing stage; do not run the compiler proper. The + output is in the form of preprocessed source code, which is sent to the + standard output. + + Input files that don't require preprocessing are ignored. + + .. index:: output file option + +.. option:: -o {file} + + Place the primary output in file :samp:`{file}`. This applies to whatever + sort of output is being produced, whether it be an executable file, an + object file, an assembler file or preprocessed C code. + + If :option:`-o` is not specified, the default is to put an executable + file in :samp:`a.out`, the object file for + :samp:`{source}.{suffix}` in :samp:`{source}.o`, its + assembler file in :samp:`{source}.s`, a precompiled header file in + :samp:`{source}.{suffix}.gch`, and all preprocessed C source on + standard output. + + Though :option:`-o` names only the primary output, it also affects the + naming of auxiliary and dump outputs. See the examples below. Unless + overridden, both auxiliary outputs and dump outputs are placed in the + same directory as the primary output. In auxiliary outputs, the suffix + of the input file is replaced with that of the auxiliary output file + type; in dump outputs, the suffix of the dump file is appended to the + input file suffix. In compilation commands, the base name of both + auxiliary and dump outputs is that of the primary output; in compile and + link commands, the primary output name, minus the executable suffix, is + combined with the input file name. If both share the same base name, + disregarding the suffix, the result of the combination is that base + name, otherwise, they are concatenated, separated by a dash. + + .. code-block:: shell + + gcc -c foo.c ... + + will use :samp:`foo.o` as the primary output, and place aux outputs and + dumps next to it, e.g., aux file :samp:`foo.dwo` for + :option:`-gsplit-dwarf`, and dump file :samp:`foo.c.???r.final` for + :option:`-fdump-rtl-final`. + + If a non-linker output file is explicitly specified, aux and dump files + by default take the same base name: + + .. code-block:: shell + + gcc -c foo.c -o dir/foobar.o ... + + will name aux outputs :samp:`dir/foobar.*` and dump outputs + :samp:`dir/foobar.c.*`. + + A linker output will instead prefix aux and dump outputs: + + .. code-block:: shell + + gcc foo.c bar.c -o dir/foobar ... + + will generally name aux outputs :samp:`dir/foobar-foo.*` and + :samp:`dir/foobar-bar.*`, and dump outputs :samp:`dir/foobar-foo.c.*` and + :samp:`dir/foobar-bar.c.*`. + + The one exception to the above is when the executable shares the base + name with the single input: + + .. code-block:: shell + + gcc foo.c -o dir/foo ... + + in which case aux outputs are named :samp:`dir/foo.*` and dump outputs + named :samp:`dir/foo.c.*`. + + The location and the names of auxiliary and dump outputs can be adjusted + by the options :option:`-dumpbase`, :option:`-dumpbase-ext`, + :option:`-dumpdir`, :option:`-save-temps=cwd`, and + :option:`-save-temps=obj`. + +.. option:: -dumpbase {dumpbase} + + This option sets the base name for auxiliary and dump output files. It + does not affect the name of the primary output file. Intermediate + outputs, when preserved, are not regarded as primary outputs, but as + auxiliary outputs: + + .. code-block:: shell + + gcc -save-temps -S foo.c + + saves the (no longer) temporary preprocessed file in :samp:`foo.i`, and + then compiles to the (implied) output file :samp:`foo.s`, whereas: + + .. code-block:: shell + + gcc -save-temps -dumpbase save-foo -c foo.c + + preprocesses to in :samp:`save-foo.i`, compiles to :samp:`save-foo.s` (now + an intermediate, thus auxiliary output), and then assembles to the + (implied) output file :samp:`foo.o`. + + Absent this option, dump and aux files take their names from the input + file, or from the (non-linker) output file, if one is explicitly + specified: dump output files (e.g. those requested by :option:`-fdump-*` + options) with the input name suffix, and aux output files (those + requested by other non-dump options, e.g. ``-save-temps``, + ``-gsplit-dwarf``, ``-fcallgraph-info``) without it. + + Similar suffix differentiation of dump and aux outputs can be attained + for explicitly-given :option:`-dumpbase basename.suf` by also specifying + :option:`-dumpbase-ext .suf`. + + If :samp:`{dumpbase}` is explicitly specified with any directory component, + any :samp:`{dumppfx}` specification (e.g. :option:`-dumpdir` or + :option:`-save-temps=*`) is ignored, and instead of appending to it, + :samp:`{dumpbase}` fully overrides it: + + .. code-block:: shell + + gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \ + -dumpdir pfx- -save-temps=cwd ... + + creates auxiliary and dump outputs named :samp:`alt/foo.*`, disregarding + :samp:`dir/` in :option:`-o`, the :samp:`./` prefix implied by + :option:`-save-temps=cwd`, and :samp:`pfx-` in :option:`-dumpdir`. + + When :option:`-dumpbase` is specified in a command that compiles multiple + inputs, or that compiles and then links, it may be combined with + :samp:`{dumppfx}`, as specified under :option:`-dumpdir`. Then, each input + file is compiled using the combined :samp:`{dumppfx}`, and default values + for :samp:`{dumpbase}` and :samp:`{auxdropsuf}` are computed for each input + file: + + .. code-block:: shell + + gcc foo.c bar.c -c -dumpbase main ... + + creates :samp:`foo.o` and :samp:`bar.o` as primary outputs, and avoids + overwriting the auxiliary and dump outputs by using the :samp:`{dumpbase}` + as a prefix, creating auxiliary and dump outputs named :samp:`main-foo.*` + and :samp:`main-bar.*`. + + An empty string specified as :samp:`{dumpbase}` avoids the influence of the + output basename in the naming of auxiliary and dump outputs during + compilation, computing default values : + + .. code-block:: shell + + gcc -c foo.c -o dir/foobar.o -dumpbase '' ... + + will name aux outputs :samp:`dir/foo.*` and dump outputs + :samp:`dir/foo.c.*`. Note how their basenames are taken from the input + name, but the directory still defaults to that of the output. + + The empty-string dumpbase does not prevent the use of the output + basename for outputs during linking: + + .. code-block:: shell + + gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ... + + The compilation of the source files will name auxiliary outputs + :samp:`dir/foo.*` and :samp:`dir/bar.*`, and dump outputs + :samp:`dir/foo.c.*` and :samp:`dir/bar.c.*`. LTO recompilation during + linking will use :samp:`dir/foobar.` as the prefix for dumps and + auxiliary files. + +.. option:: -dumpbase-ext {auxdropsuf} + + When forming the name of an auxiliary (but not a dump) output file, drop + trailing :samp:`{auxdropsuf}` from :samp:`{dumpbase}` before appending any + suffixes. If not specified, this option defaults to the suffix of a + default :samp:`{dumpbase}`, i.e., the suffix of the input file when + :option:`-dumpbase` is not present in the command line, or :samp:`{dumpbase}` + is combined with :samp:`{dumppfx}`. + + .. code-block:: shell + + gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ... + + creates :samp:`dir/foo.o` as the main output, and generates auxiliary + outputs in :samp:`dir/x-foo.*`, taking the location of the primary + output, and dropping the :samp:`.c` suffix from the :samp:`{dumpbase}`. Dump + outputs retain the suffix: :samp:`dir/x-foo.c.*`. + + This option is disregarded if it does not match the suffix of a + specified :samp:`{dumpbase}`, except as an alternative to the executable + suffix when appending the linker output base name to :samp:`{dumppfx}`, as + specified below: + + .. code-block:: shell + + gcc foo.c bar.c -o main.out -dumpbase-ext .out ... + + creates :samp:`main.out` as the primary output, and avoids overwriting + the auxiliary and dump outputs by using the executable name minus + :samp:`{auxdropsuf}` as a prefix, creating auxiliary outputs named + :samp:`main-foo.*` and :samp:`main-bar.*` and dump outputs named + :samp:`main-foo.c.*` and :samp:`main-bar.c.*`. + +.. option:: -dumpdir {dumppfx} + + When forming the name of an auxiliary or dump output file, use + :samp:`{dumppfx}` as a prefix: + + .. code-block:: shell + + gcc -dumpdir pfx- -c foo.c ... + + creates :samp:`foo.o` as the primary output, and auxiliary outputs named + :samp:`pfx-foo.*`, combining the given :samp:`{dumppfx}` with the default + :samp:`{dumpbase}` derived from the default primary output, derived in turn + from the input name. Dump outputs also take the input name suffix: + :samp:`pfx-foo.c.*`. + + If :samp:`{dumppfx}` is to be used as a directory name, it must end with a + directory separator: + + .. code-block:: shell + + gcc -dumpdir dir/ -c foo.c -o obj/bar.o ... + + creates :samp:`obj/bar.o` as the primary output, and auxiliary outputs + named :samp:`dir/bar.*`, combining the given :samp:`{dumppfx}` with the + default :samp:`{dumpbase}` derived from the primary output name. Dump + outputs also take the input name suffix: :samp:`dir/bar.c.*`. + + It defaults to the location of the output file, unless the output + file is a special file like ``/dev/null``. Options + :option:`-save-temps=cwd` and :option:`-save-temps=obj` override this + default, just like an explicit :option:`-dumpdir` option. In case + multiple such options are given, the last one prevails: + + .. code-block:: shell + + gcc -dumpdir pfx- -c foo.c -save-temps=obj ... + + outputs :samp:`foo.o`, with auxiliary outputs named :samp:`foo.*` because + :option:`-save-temps=*` overrides the :samp:`{dumppfx}` given by the earlier + :option:`-dumpdir` option. It does not matter that =obj is the + default for :option:`-save-temps`, nor that the output directory is + implicitly the current directory. Dump outputs are named + :samp:`foo.c.*`. + + When compiling from multiple input files, if :option:`-dumpbase` is + specified, :samp:`{dumpbase}`, minus a :samp:`{auxdropsuf}` suffix, and a dash + are appended to (or override, if containing any directory components) an + explicit or defaulted :samp:`{dumppfx}`, so that each of the multiple + compilations gets differently-named aux and dump outputs. + + .. code-block:: shell + + gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ... + + outputs auxiliary dumps to :samp:`dir/pfx-main-foo.*` and + :samp:`dir/pfx-main-bar.*`, appending :samp:`{dumpbase}` - to :samp:`{dumppfx}`. + Dump outputs retain the input file suffix: :samp:`dir/pfx-main-foo.c.*` + and :samp:`dir/pfx-main-bar.c.*`, respectively. Contrast with the + single-input compilation: + + .. code-block:: shell + + gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ... + + that, applying :option:`-dumpbase` to a single source, does not compute + and append a separate :samp:`{dumpbase}` per input file. Its auxiliary and + dump outputs go in :samp:`dir/pfx-main.*`. + + When compiling and then linking from multiple input files, a defaulted + or explicitly specified :samp:`{dumppfx}` also undergoes the :samp:`{dumpbase}` - + transformation above (e.g. the compilation of :samp:`foo.c` and + :samp:`bar.c` above, but without :option:`-c`). If neither + :option:`-dumpdir` nor :option:`-dumpbase` are given, the linker output + base name, minus :samp:`{auxdropsuf}`, if specified, or the executable + suffix otherwise, plus a dash is appended to the default :samp:`{dumppfx}` + instead. Note, however, that unlike earlier cases of linking: + + .. code-block:: shell + + gcc foo.c bar.c -dumpdir dir/pfx- -o main ... + + does not append the output name :samp:`main` to :samp:`{dumppfx}`, because + :option:`-dumpdir` is explicitly specified. The goal is that the + explicitly-specified :samp:`{dumppfx}` may contain the specified output name + as part of the prefix, if desired; only an explicitly-specified + :option:`-dumpbase` would be combined with it, in order to avoid simply + discarding a meaningful option. + + When compiling and then linking from a single input file, the linker + output base name will only be appended to the default :samp:`{dumppfx}` as + above if it does not share the base name with the single input file + name. This has been covered in single-input linking cases above, but + not with an explicit :option:`-dumpdir` that inhibits the combination, + even if overridden by :option:`-save-temps=*` : + + .. code-block:: shell + + gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ... + + Auxiliary outputs are named :samp:`foo.*`, and dump outputs + :samp:`foo.c.*`, in the current working directory as ultimately requested + by :option:`-save-temps=cwd`. + + Summing it all up for an intuitive though slightly imprecise data flow: + the primary output name is broken into a directory part and a basename + part; :samp:`{dumppfx}` is set to the former, unless overridden by + :option:`-dumpdir` or :option:`-save-temps=*`, and :samp:`{dumpbase}` is set + to the latter, unless overriden by :option:`-dumpbase`. If there are + multiple inputs or linking, this :samp:`{dumpbase}` may be combined with + :samp:`{dumppfx}` and taken from each input file. Auxiliary output names + for each input are formed by combining :samp:`{dumppfx}`, :samp:`{dumpbase}` + minus suffix, and the auxiliary output suffix; dump output names are + only different in that the suffix from :samp:`{dumpbase}` is retained. + + When it comes to auxiliary and dump outputs created during LTO + recompilation, a combination of :samp:`{dumppfx}` and :samp:`{dumpbase}`, as + given or as derived from the linker output name but not from inputs, + even in cases in which this combination would not otherwise be used as + such, is passed down with a trailing period replacing the compiler-added + dash, if any, as a :option:`-dumpdir` option to :command:`lto-wrapper`; + being involved in linking, this program does not normally get any + :option:`-dumpbase` and :option:`-dumpbase-ext`, and it ignores them. + + When running sub-compilers, :command:`lto-wrapper` appends LTO stage + names to the received :samp:`{dumppfx}`, ensures it contains a directory + component so that it overrides any :option:`-dumpdir`, and passes that as + :option:`-dumpbase` to sub-compilers. + +.. option:: -v + + Print (on standard error output) the commands executed to run the stages + of compilation. Also print the version number of the compiler driver + program and of the preprocessor and the compiler proper. + +.. option:: -### + + Like :option:`-v` except the commands are not executed and arguments + are quoted unless they contain only alphanumeric characters or ``./-_``. + This is useful for shell scripts to capture the driver-generated command lines. + +.. option:: --help + + Print (on the standard output) a description of the command-line options + understood by :command:`gcc`. If the :option:`-v` option is also specified + then :option:`--help` is also passed on to the various processes + invoked by :command:`gcc`, so that they can display the command-line options + they accept. If the :option:`-Wextra` option has also been specified + (prior to the :option:`--help` option), then command-line options that + have no documentation associated with them are also displayed. + +.. option:: --target-help + + Print (on the standard output) a description of target-specific command-line + options for each tool. For some targets extra target-specific + information may also be printed. + +.. option:: --help={class}|[^]qualifier}[,...] + + Print (on the standard output) a description of the command-line + options understood by the compiler that fit into all specified classes + and qualifiers. These are the supported classes: + + optimizers + Display all of the optimization options supported by the + compiler. + + warnings + Display all of the options controlling warning messages + produced by the compiler. + + target + Display target-specific options. Unlike the + :option:`--target-help` option however, target-specific options of the + linker and assembler are not displayed. This is because those + tools do not currently support the extended :option:`--help=` syntax. + + params + Display the values recognized by the :option:`--param` + option. + + language + Display the options supported for :samp:`{language}`, where + :samp:`{language}` is the name of one of the languages supported in this + version of GCC. If an option is supported by all languages, one needs + to select :samp:`common` class. + + common + Display the options that are common to all languages. + + These are the supported qualifiers: + + undocumented + Display only those options that are undocumented. + + joined + Display options taking an argument that appears after an equal + sign in the same continuous piece of text, such as: + :samp:`--help=target`. + + separate + Display options taking an argument that appears as a separate word + following the original option, such as: :samp:`-o output-file`. + + Thus for example to display all the undocumented target-specific + switches supported by the compiler, use: + + :option:`--help=target,undocumented` + The sense of a qualifier can be inverted by prefixing it with the + :samp:`^` character, so for example to display all binary warning + options (i.e., ones that are either on or off and that do not take an + argument) that have a description, use: + + :option:`--help=warnings,^joined,^undocumented` + The argument to :option:`--help=` should not consist solely of inverted + qualifiers. + + Combining several classes is possible, although this usually + restricts the output so much that there is nothing to display. One + case where it does work, however, is when one of the classes is + :samp:`{target}`. For example, to display all the target-specific + optimization options, use: + + :option:`--help=target,optimizers` + The :option:`--help=` option can be repeated on the command line. Each + successive use displays its requested class of options, skipping + those that have already been displayed. If :option:`--help` is also + specified anywhere on the command line then this takes precedence + over any :option:`--help=` option. + + If the :option:`-Q` option appears on the command line before the + :option:`--help=` option, then the descriptive text displayed by + :option:`--help=` is changed. Instead of describing the displayed + options, an indication is given as to whether the option is enabled, + disabled or set to a specific value (assuming that the compiler + knows this at the point where the :option:`--help=` option is used). + + Here is a truncated example from the ARM port of :command:`gcc`: + + .. code-block:: shell-session + + % gcc -Q -mabi=2 --help=target -c + The following options are target specific: + -mabi= 2 + -mabort-on-noreturn [disabled] + -mapcs [disabled] + + The output is sensitive to the effects of previous command-line + options, so for example it is possible to find out which optimizations + are enabled at :option:`-O2` by using: + + :option:`-Q` :option:`-O2` :option:`--help=optimizers` + Alternatively you can discover which binary optimizations are enabled + by :option:`-O3` by using: + + .. code-block:: shell + + gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts + gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts + diff /tmp/O2-opts /tmp/O3-opts | grep enabled + +.. option:: --version + + Display the version number and copyrights of the invoked GCC. + +.. option:: -pass-exit-codes + + Normally the :command:`gcc` program exits with the code of 1 if any + phase of the compiler returns a non-success return code. If you specify + :option:`-pass-exit-codes`, the :command:`gcc` program instead returns with + the numerically highest error produced by any phase returning an error + indication. The C, C++, and Fortran front ends return 4 if an internal + compiler error is encountered. + +.. option:: -pipe + + Use pipes rather than temporary files for communication between the + various stages of compilation. This fails to work on some systems where + the assembler is unable to read from a pipe; but the GNU assembler has + no trouble. + +.. option:: -specs={file} + + Process :samp:`{file}` after the compiler reads in the standard :samp:`specs` + file, in order to override the defaults which the :command:`gcc` driver + program uses when determining what switches to pass to :command:`cc1`, + :command:`cc1plus`, :command:`as`, :command:`ld`, etc. More than one + :option:`-specs=file` can be specified on the command line, and they + are processed in order, from left to right. See :ref:`spec-files`, for + information about the format of the :samp:`{file}`. + +.. option:: -wrapper + + Invoke all subcommands under a wrapper program. The name of the + wrapper program and its parameters are passed as a comma separated + list. + + .. code-block:: shell + + gcc -c t.c -wrapper gdb,--args + + This invokes all subprograms of :command:`gcc` under + :samp:`gdb --args`, thus the invocation of :command:`cc1` is + :samp:`gdb --args cc1 ...`. + +.. option:: -ffile-prefix-map={old}={new} + + When compiling files residing in directory :samp:`{old}`, record + any references to them in the result of the compilation as if the + files resided in directory :samp:`{new}` instead. Specifying this + option is equivalent to specifying all the individual + :option:`-f*-prefix-map` options. This can be used to make reproducible + builds that are location independent. See also + :option:`-fmacro-prefix-map`, :option:`-fdebug-prefix-map` and + :option:`-fprofile-prefix-map`. + +.. option:: -fplugin={name}.so + + Load the plugin code in file :samp:`{name}`.so, assumed to be a + shared object to be dlopen'd by the compiler. The base name of + the shared object file is used to identify the plugin for the + purposes of argument parsing (See + :option:`-fplugin-arg-name-key=value` below). + Each plugin should define the callback functions specified in the + Plugins API. + +.. option:: -fplugin-arg-name-key={value} + + Define an argument called :samp:`{key}` with a value of :samp:`{value}` + for the plugin called :samp:`{name}`. + +.. option:: -fdump-ada-spec[-slim] + + For C and C++ source and include files, generate corresponding Ada specs. + See :ref:`gnat_ugn:generating-ada-bindings-for-c-and-c++-headers`, which provides detailed documentation on this feature. + +.. option:: -fada-spec-parent={unit} + + In conjunction with :option:`-fdump-ada-spec[-slim]` above, generate + Ada specs as child units of parent :samp:`{unit}`. + +.. option:: -fdump-go-spec={file} + + For input files in any language, generate corresponding Go + declarations in :samp:`{file}`. This generates Go ``const``, + ``type``, ``var``, and ``func`` declarations which may be a + useful way to start writing a Go interface to code written in some + other language. + + .. This file is designed to be included in manuals that use + expandargv. + +:samp:`@{file}` + Read command-line options from :samp:`{file}`. The options read are + inserted in place of the original :samp:`@{file}` option. If :samp:`{file}` + does not exist, or cannot be read, then the option will be treated + literally, and not removed. + + Options in :samp:`{file}` are separated by whitespace. A whitespace + character may be included in an option by surrounding the entire + option in either single or double quotes. Any character (including a + backslash) may be included by prefixing the character to be included + with a backslash. The :samp:`{file}` may itself contain additional + :samp:`@{file}` options; any such options will be processed recursively. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-controlling-the-preprocessor.rst b/gcc/doc/gcc/gcc-command-options/options-controlling-the-preprocessor.rst new file mode 100644 index 00000000000..4b646a07061 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-controlling-the-preprocessor.rst @@ -0,0 +1,79 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: preprocessor options, options, preprocessor + +.. _preprocessor-options: + +Options Controlling the Preprocessor +************************************ + +These options control the C preprocessor, which is run on each C source +file before actual compilation. + +If you use the :option:`-E` option, nothing is done except preprocessing. +Some of these options make sense only together with :option:`-E` because +they cause the preprocessor output to be unsuitable for actual +compilation. + +In addition to the options listed here, there are a number of options +to control search paths for include files documented in +:ref:`directory-options`. +Options to control preprocessor diagnostics are listed in +:ref:`warning-options`. + +.. include:: ../../../../doc/cppopts.rst + + +.. option:: -Wp,option + + You can use :option:`-Wp,option` to bypass the compiler driver + and pass :samp:`{option}` directly through to the preprocessor. If + :samp:`{option}` contains commas, it is split into multiple options at the + commas. However, many options are modified, translated or interpreted + by the compiler driver before being passed to the preprocessor, and + :option:`-Wp` forcibly bypasses this phase. The preprocessor's direct + interface is undocumented and subject to change, so whenever possible + you should avoid using :option:`-Wp` and let the driver handle the + options instead. + +.. option:: -Xpreprocessor {option} + + Pass :samp:`{option}` as an option to the preprocessor. You can use this to + supply system-specific preprocessor options that GCC does not + recognize. + + If you want to pass an option that takes an argument, you must use + :option:`-Xpreprocessor` twice, once for the option and once for the argument. + +.. option:: -no-integrated-cpp + + Perform preprocessing as a separate pass before compilation. + By default, GCC performs preprocessing as an integrated part of + input tokenization and parsing. + If this option is provided, the appropriate language front end + (:command:`cc1`, :command:`cc1plus`, or :command:`cc1obj` for C, C++, + and Objective-C, respectively) is instead invoked twice, + once for preprocessing only and once for actual compilation + of the preprocessed input. + This option may be useful in conjunction with the :option:`-B` or + :option:`-wrapper` options to specify an alternate preprocessor or + perform additional processing of the program source between + normal preprocessing and compilation. + +.. option:: -flarge-source-files + + Adjust GCC to expect large source files, at the expense of slower + compilation and higher memory usage. + + Specifically, GCC normally tracks both column numbers and line numbers + within source files and it normally prints both of these numbers in + diagnostics. However, once it has processed a certain number of source + lines, it stops tracking column numbers and only tracks line numbers. + This means that diagnostics for later lines do not include column numbers. + It also means that options like :option:`-Wmisleading-indentation` cease to work + at that point, although the compiler prints a note if this happens. + Passing :option:`-flarge-source-files` significantly increases the number + of source lines that GCC can process before it stops tracking columns. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-for-code-generation-conventions.rst b/gcc/doc/gcc/gcc-command-options/options-for-code-generation-conventions.rst new file mode 100644 index 00000000000..5bd55309f66 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-for-code-generation-conventions.rst @@ -0,0 +1,713 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: code generation conventions, options, code generation, run-time options + +.. _code-gen-options: + +Options for Code Generation Conventions +*************************************** + +These machine-independent options control the interface conventions +used in code generation. + +Most of them have both positive and negative forms; the negative form +of :samp:`-ffoo` is :samp:`-fno-foo`. In the table below, only +one of the forms is listed---the one that is not the default. You +can figure out the other form by either removing :samp:`no-` or adding +it. + +.. option:: -fstack-reuse={reuse-level} + + This option controls stack space reuse for user declared local/auto variables + and compiler generated temporaries. :samp:`{reuse_level}` can be :samp:`all`, + :samp:`named_vars`, or :samp:`none`. :samp:`all` enables stack reuse for all + local variables and temporaries, :samp:`named_vars` enables the reuse only for + user defined local variables with names, and :samp:`none` disables stack reuse + completely. The default value is :samp:`all`. The option is needed when the + program extends the lifetime of a scoped local variable or a compiler generated + temporary beyond the end point defined by the language. When a lifetime of + a variable ends, and if the variable lives in memory, the optimizing compiler + has the freedom to reuse its stack space with other temporaries or scoped + local variables whose live range does not overlap with it. Legacy code extending + local lifetime is likely to break with the stack reuse optimization. + + For example, + + .. code-block:: c++ + + int *p; + { + int local1; + + p = &local1; + local1 = 10; + .... + } + { + int local2; + local2 = 20; + ... + } + + if (*p == 10) // out of scope use of local1 + { + + } + + Another example: + + .. code-block:: c++ + + struct A + { + A(int k) : i(k), j(k) { } + int i; + int j; + }; + + A *ap; + + void foo(const A& ar) + { + ap = &ar; + } + + void bar() + { + foo(A(10)); // temp object's lifetime ends when foo returns + + { + A a(20); + .... + } + ap->i+= 10; // ap references out of scope temp whose space + // is reused with a. What is the value of ap->i? + } + + The lifetime of a compiler generated temporary is well defined by the C++ + standard. When a lifetime of a temporary ends, and if the temporary lives + in memory, the optimizing compiler has the freedom to reuse its stack + space with other temporaries or scoped local variables whose live range + does not overlap with it. However some of the legacy code relies on + the behavior of older compilers in which temporaries' stack space is + not reused, the aggressive stack reuse can lead to runtime errors. This + option is used to control the temporary stack reuse optimization. + +.. option:: -ftrapv + + This option generates traps for signed overflow on addition, subtraction, + multiplication operations. + The options :option:`-ftrapv` and :option:`-fwrapv` override each other, so using + :option:`-ftrapv` :option:`-fwrapv` on the command-line results in + :option:`-fwrapv` being effective. Note that only active options override, so + using :option:`-ftrapv` :option:`-fwrapv` :option:`-fno-wrapv` on the command-line + results in :option:`-ftrapv` being effective. + +.. option:: -fwrapv + + This option instructs the compiler to assume that signed arithmetic + overflow of addition, subtraction and multiplication wraps around + using twos-complement representation. This flag enables some optimizations + and disables others. + The options :option:`-ftrapv` and :option:`-fwrapv` override each other, so using + :option:`-ftrapv` :option:`-fwrapv` on the command-line results in + :option:`-fwrapv` being effective. Note that only active options override, so + using :option:`-ftrapv` :option:`-fwrapv` :option:`-fno-wrapv` on the command-line + results in :option:`-ftrapv` being effective. + +.. option:: -fwrapv-pointer + + This option instructs the compiler to assume that pointer arithmetic + overflow on addition and subtraction wraps around using twos-complement + representation. This flag disables some optimizations which assume + pointer overflow is invalid. + +.. option:: -fstrict-overflow + + This option implies :option:`-fno-wrapv` :option:`-fno-wrapv-pointer` and when + negated implies :option:`-fwrapv` :option:`-fwrapv-pointer`. + +.. option:: -fexceptions + + Enable exception handling. Generates extra code needed to propagate + exceptions. For some targets, this implies GCC generates frame + unwind information for all functions, which can produce significant data + size overhead, although it does not affect execution. If you do not + specify this option, GCC enables it by default for languages like + C++ that normally require exception handling, and disables it for + languages like C that do not normally require it. However, you may need + to enable this option when compiling C code that needs to interoperate + properly with exception handlers written in C++. You may also wish to + disable this option if you are compiling older C++ programs that don't + use exception handling. + +.. option:: -fnon-call-exceptions + + Generate code that allows trapping instructions to throw exceptions. + Note that this requires platform-specific runtime support that does + not exist everywhere. Moreover, it only allows *trapping* + instructions to throw exceptions, i.e. memory references or floating-point + instructions. It does not allow exceptions to be thrown from + arbitrary signal handlers such as ``SIGALRM``. This enables + :option:`-fexceptions`. + +.. option:: -fdelete-dead-exceptions + + Consider that instructions that may throw exceptions but don't otherwise + contribute to the execution of the program can be optimized away. + This does not affect calls to functions except those with the + :fn-attr:`pure` or :fn-attr:`const` attributes. + This option is enabled by default for the Ada and C++ compilers, as permitted by + the language specifications. + Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels. + +.. option:: -funwind-tables + + Similar to :option:`-fexceptions`, except that it just generates any needed + static data, but does not affect the generated code in any other way. + You normally do not need to enable this option; instead, a language processor + that needs this handling enables it on your behalf. + +.. option:: -fasynchronous-unwind-tables + + Generate unwind table in DWARF format, if supported by target machine. The + table is exact at each instruction boundary, so it can be used for stack + unwinding from asynchronous events (such as debugger or garbage collector). + +.. option:: -fno-gnu-unique + + On systems with recent GNU assembler and C library, the C++ compiler + uses the ``STB_GNU_UNIQUE`` binding to make sure that definitions + of template static data members and static local variables in inline + functions are unique even in the presence of ``RTLD_LOCAL`` ; this + is necessary to avoid problems with a library used by two different + ``RTLD_LOCAL`` plugins depending on a definition in one of them and + therefore disagreeing with the other one about the binding of the + symbol. But this causes ``dlclose`` to be ignored for affected + DSOs; if your program relies on reinitialization of a DSO via + ``dlclose`` and ``dlopen``, you can use + :option:`-fno-gnu-unique`. + +.. option:: -fgnu-unique + + Default setting; overrides :option:`-fno-gnu-unique`. + +.. option:: -fpcc-struct-return + + Return 'short' ``struct`` and ``union`` values in memory like + longer ones, rather than in registers. This convention is less + efficient, but it has the advantage of allowing intercallability between + GCC-compiled files and files compiled with other compilers, particularly + the Portable C Compiler (pcc). + + The precise convention for returning structures in memory depends + on the target configuration macros. + + Short structures and unions are those whose size and alignment match + that of some integer type. + + .. warning:: + + Code compiled with the :option:`-fpcc-struct-return` + switch is not binary compatible with code compiled with the + :option:`-freg-struct-return` switch. + Use it to conform to a non-default application binary interface. + +.. option:: -freg-struct-return + + Return ``struct`` and ``union`` values in registers when possible. + This is more efficient for small structures than + :option:`-fpcc-struct-return`. + + If you specify neither :option:`-fpcc-struct-return` nor + :option:`-freg-struct-return`, GCC defaults to whichever convention is + standard for the target. If there is no standard convention, GCC + defaults to :option:`-fpcc-struct-return`, except on targets where GCC is + the principal compiler. In those cases, we can choose the standard, and + we chose the more efficient register return alternative. + + .. warning:: + + Code compiled with the :option:`-freg-struct-return` + switch is not binary compatible with code compiled with the + :option:`-fpcc-struct-return` switch. + Use it to conform to a non-default application binary interface. + +.. option:: -fshort-enums + + Allocate to an ``enum`` type only as many bytes as it needs for the + declared range of possible values. Specifically, the ``enum`` type + is equivalent to the smallest integer type that has enough room. + + .. warning:: + + The :option:`-fshort-enums` switch causes GCC to generate + code that is not binary compatible with code generated without that switch. + Use it to conform to a non-default application binary interface. + +.. option:: -fshort-wchar + + Override the underlying type for ``wchar_t`` to be ``short + unsigned int`` instead of the default for the target. This option is + useful for building programs to run under WINE. + + .. warning:: + + The :option:`-fshort-wchar` switch causes GCC to generate + code that is not binary compatible with code generated without that switch. + Use it to conform to a non-default application binary interface. + +.. index:: tentative definitions + +.. option:: -fcommon + + In C code, this option controls the placement of global variables + defined without an initializer, known as :dfn:`tentative definitions` + in the C standard. Tentative definitions are distinct from declarations + of a variable with the ``extern`` keyword, which do not allocate storage. + + The default is :option:`-fno-common`, which specifies that the compiler places + uninitialized global variables in the BSS section of the object file. + This inhibits the merging of tentative definitions by the linker so you get a + multiple-definition error if the same variable is accidentally defined in more + than one compilation unit. + + The :option:`-fcommon` places uninitialized global variables in a common block. + This allows the linker to resolve all tentative definitions of the same variable + in different compilation units to the same object, or to a non-tentative + definition. This behavior is inconsistent with C++, and on many targets implies + a speed and code size penalty on global variable references. It is mainly + useful to enable legacy code to link without errors. + +.. option:: -fno-common + + Default setting; overrides :option:`-fcommon`. + +.. option:: -fno-ident + + Ignore the ``#ident`` directive. + +.. option:: -fident + + Default setting; overrides :option:`-fno-ident`. + +.. option:: -finhibit-size-directive + + Don't output a ``.size`` assembler directive, or anything else that + would cause trouble if the function is split in the middle, and the + two halves are placed at locations far apart in memory. This option is + used when compiling :samp:`crtstuff.c`; you should not need to use it + for anything else. + +.. option:: -fverbose-asm + + Put extra commentary information in the generated assembly code to + make it more readable. This option is generally only of use to those + who actually need to read the generated assembly code (perhaps while + debugging the compiler itself). + + :option:`-fno-verbose-asm`, the default, causes the + extra information to be omitted and is useful when comparing two assembler + files. + + The added comments include: + + * information on the compiler version and command-line options, + + * the source code lines associated with the assembly instructions, + in the form FILENAME:LINENUMBER:CONTENT OF LINE, + + * hints on which high-level expressions correspond to + the various assembly instruction operands. + + For example, given this C source file: + + .. code-block:: c++ + + int test (int n) + { + int i; + int total = 0; + + for (i = 0; i < n; i++) + total += i * i; + + return total; + } + + compiling to (x86_64) assembly via :option:`-S` and emitting the result + direct to stdout via :option:`-o` :option:`-` + + .. code-block:: shell + + gcc -S test.c -fverbose-asm -Os -o - + + gives output similar to this: + + .. code-block:: gas + + .file "test.c" + # GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu) + # [...snip...] + # options passed: + # [...snip...] + + .text + .globl test + .type test, @function + test: + .LFB0: + .cfi_startproc + # test.c:4: int total = 0; + xorl %eax, %eax # + # test.c:6: for (i = 0; i < n; i++) + xorl %edx, %edx # i + .L2: + # test.c:6: for (i = 0; i < n; i++) + cmpl %edi, %edx # n, i + jge .L5 #, + # test.c:7: total += i * i; + movl %edx, %ecx # i, tmp92 + imull %edx, %ecx # i, tmp92 + # test.c:6: for (i = 0; i < n; i++) + incl %edx # i + # test.c:7: total += i * i; + addl %ecx, %eax # tmp92, + jmp .L2 # + .L5: + # test.c:10: } + ret + .cfi_endproc + .LFE0: + .size test, .-test + .ident "GCC: (GNU) 7.0.0 20160809 (experimental)" + .section .note.GNU-stack,"",@progbits + + The comments are intended for humans rather than machines and hence the + precise format of the comments is subject to change. + +.. option:: -frecord-gcc-switches + + This switch causes the command line used to invoke the + compiler to be recorded into the object file that is being created. + This switch is only implemented on some targets and the exact format + of the recording is target and binary file format dependent, but it + usually takes the form of a section containing ASCII text. This + switch is related to the :option:`-fverbose-asm` switch, but that + switch only records information in the assembler output file as + comments, so it never reaches the object file. + See also :option:`-grecord-gcc-switches` for another + way of storing compiler options into the object file. + +.. index:: global offset table, PIC + +.. option:: -fpic + + Generate position-independent code (PIC) suitable for use in a shared + library, if supported for the target machine. Such code accesses all + constant addresses through a global offset table (GOT). The dynamic + loader resolves the GOT entries when the program starts (the dynamic + loader is not part of GCC; it is part of the operating system). If + the GOT size for the linked executable exceeds a machine-specific + maximum size, you get an error message from the linker indicating that + :option:`-fpic` does not work; in that case, recompile with :option:`-fPIC` + instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k + on the m68k and RS/6000. The x86 has no such limit.) + + Position-independent code requires special support, and therefore works + only on certain machines. For the x86, GCC supports PIC for System V + but not for the Sun 386i. Code generated for the IBM RS/6000 is always + position-independent. + + When this flag is set, the macros ``__pic__`` and ``__PIC__`` + are defined to 1. + +.. option:: -fPIC + + If supported for the target machine, emit position-independent code, + suitable for dynamic linking and avoiding any limit on the size of the + global offset table. This option makes a difference on AArch64, m68k, + PowerPC and SPARC. + + Position-independent code requires special support, and therefore works + only on certain machines. + + When this flag is set, the macros ``__pic__`` and ``__PIC__`` + are defined to 2. + +.. option:: -fpie, -fPIE + + These options are similar to :option:`-fpic` and :option:`-fPIC`, but the + generated position-independent code can be only linked into executables. + Usually these options are used to compile code that will be linked using + the :option:`-pie` GCC option. + + :option:`-fpie` and :option:`-fPIE` both define the macros + ``__pie__`` and ``__PIE__``. The macros have the value 1 + for :option:`-fpie` and 2 for :option:`-fPIE`. + +.. option:: -fno-plt + + Do not use the PLT for external function calls in position-independent code. + Instead, load the callee address at call sites from the GOT and branch to it. + This leads to more efficient code by eliminating PLT stubs and exposing + GOT loads to optimizations. On architectures such as 32-bit x86 where + PLT stubs expect the GOT pointer in a specific register, this gives more + register allocation freedom to the compiler. + Lazy binding requires use of the PLT; + with :option:`-fno-plt` all external symbols are resolved at load time. + + Alternatively, the function attribute :fn-attr:`noplt` can be used to avoid calls + through the PLT for specific external functions. + + In position-dependent code, a few targets also convert calls to + functions that are marked to not use the PLT to use the GOT instead. + +.. option:: -fplt + + Default setting; overrides :option:`-fno-plt`. + +.. option:: -fno-jump-tables + + Do not use jump tables for switch statements even where it would be + more efficient than other code generation strategies. This option is + of use in conjunction with :option:`-fpic` or :option:`-fPIC` for + building code that forms part of a dynamic linker and cannot + reference the address of a jump table. On some targets, jump tables + do not require a GOT and this option is not needed. + +.. option:: -fjump-tables + + Default setting; overrides :option:`-fno-jump-tables`. + +.. option:: -fno-bit-tests + + Do not use bit tests for switch statements even where it would be + more efficient than other code generation strategies. + +.. option:: -fbit-tests + + Default setting; overrides :option:`-fno-bit-tests`. + +.. option:: -ffixed-reg + + Treat the register named :samp:`{reg}` as a fixed register; generated code + should never refer to it (except perhaps as a stack pointer, frame + pointer or in some other fixed role). + + :samp:`{reg}` must be the name of a register. The register names accepted + are machine-specific and are defined in the ``REGISTER_NAMES`` + macro in the machine description macro file. + + This flag does not have a negative form, because it specifies a + three-way choice. + +.. option:: -fcall-used-reg + + Treat the register named :samp:`{reg}` as an allocable register that is + clobbered by function calls. It may be allocated for temporaries or + variables that do not live across a call. Functions compiled this way + do not save and restore the register :samp:`{reg}`. + + It is an error to use this flag with the frame pointer or stack pointer. + Use of this flag for other registers that have fixed pervasive roles in + the machine's execution model produces disastrous results. + + This flag does not have a negative form, because it specifies a + three-way choice. + +.. option:: -fcall-saved-reg + + Treat the register named :samp:`{reg}` as an allocable register saved by + functions. It may be allocated even for temporaries or variables that + live across a call. Functions compiled this way save and restore + the register :samp:`{reg}` if they use it. + + It is an error to use this flag with the frame pointer or stack pointer. + Use of this flag for other registers that have fixed pervasive roles in + the machine's execution model produces disastrous results. + + A different sort of disaster results from the use of this flag for + a register in which function values may be returned. + + This flag does not have a negative form, because it specifies a + three-way choice. + +.. option:: -fpack-struct[={n}] + + Without a value specified, pack all structure members together without + holes. When a value is specified (which must be a small power of two), pack + structure members according to this value, representing the maximum + alignment (that is, objects with default alignment requirements larger than + this are output potentially unaligned at the next fitting location. + + .. warning:: + + The :option:`-fpack-struct` switch causes GCC to generate + code that is not binary compatible with code generated without that switch. + Additionally, it makes the code suboptimal. + Use it to conform to a non-default application binary interface. + +.. option:: -fleading-underscore + + This option and its counterpart, :option:`-fno-leading-underscore`, forcibly + change the way C symbols are represented in the object file. One use + is to help link with legacy assembly code. + + .. warning:: + + The :option:`-fleading-underscore` switch causes GCC to + generate code that is not binary compatible with code generated without that + switch. Use it to conform to a non-default application binary interface. + Not all targets provide complete support for this switch. + +.. option:: -ftls-model={model} + + Alter the thread-local storage model to be used (see :ref:`thread-local`). + The :samp:`{model}` argument should be one of :samp:`global-dynamic`, + :samp:`local-dynamic`, :samp:`initial-exec` or :samp:`local-exec`. + Note that the choice is subject to optimization: the compiler may use + a more efficient model for symbols not visible outside of the translation + unit, or if :option:`-fpic` is not given on the command line. + + The default without :option:`-fpic` is :samp:`initial-exec`; with + :option:`-fpic` the default is :samp:`global-dynamic`. + +.. option:: -ftrampolines + + For targets that normally need trampolines for nested functions, always + generate them instead of using descriptors. Otherwise, for targets that + do not need them, like for example HP-PA or IA-64, do nothing. + + A trampoline is a small piece of code that is created at run time on the + stack when the address of a nested function is taken, and is used to call + the nested function indirectly. Therefore, it requires the stack to be + made executable in order for the program to work properly. + + :option:`-fno-trampolines` is enabled by default on a language by language + basis to let the compiler avoid generating them, if it computes that this + is safe, and replace them with descriptors. Descriptors are made up of data + only, but the generated code must be prepared to deal with them. As of this + writing, :option:`-fno-trampolines` is enabled by default only for Ada. + + Moreover, code compiled with :option:`-ftrampolines` and code compiled with + :option:`-fno-trampolines` are not binary compatible if nested functions are + present. This option must therefore be used on a program-wide basis and be + manipulated with extreme care. + + For languages other than Ada, the ``-ftrampolines`` and + ``-fno-trampolines`` options currently have no effect, and + trampolines are always generated on platforms that need them + for nested functions. + +.. option:: -fvisibility=[default|internal|hidden|protected] + + Set the default ELF image symbol visibility to the specified option---all + symbols are marked with this unless overridden within the code. + Using this feature can very substantially improve linking and + load times of shared object libraries, produce more optimized + code, provide near-perfect API export and prevent symbol clashes. + It is **strongly** recommended that you use this in any shared objects + you distribute. + + Despite the nomenclature, :samp:`default` always means public; i.e., + available to be linked against from outside the shared object. + :samp:`protected` and :samp:`internal` are pretty useless in real-world + usage so the only other commonly used option is :samp:`hidden`. + The default if :option:`-fvisibility` isn't specified is + :samp:`default`, i.e., make every symbol public. + + A good explanation of the benefits offered by ensuring ELF + symbols have the correct visibility is given by 'How To Write + Shared Libraries' by Ulrich Drepper (which can be found at + https://www.akkadia.org/drepper/) --- however a superior + solution made possible by this option to marking things hidden when + the default is public is to make the default hidden and mark things + public. This is the norm with DLLs on Windows and with :option:`-fvisibility=hidden` + and ``__attribute__ ((visibility("default")))`` instead of + ``__declspec(dllexport)`` you get almost identical semantics with + identical syntax. This is a great boon to those working with + cross-platform projects. + + For those adding visibility support to existing code, you may find + ``#pragma GCC visibility`` of use. This works by you enclosing + the declarations you wish to set visibility for with (for example) + ``#pragma GCC visibility push(hidden)`` and + ``#pragma GCC visibility pop``. + Bear in mind that symbol visibility should be viewed **as + part of the API interface contract** and thus all new code should + always specify visibility when it is not the default; i.e., declarations + only for use within the local DSO should **always** be marked explicitly + as hidden as so to avoid PLT indirection overheads---making this + abundantly clear also aids readability and self-documentation of the code. + Note that due to ISO C++ specification requirements, ``operator new`` and + ``operator delete`` must always be of default visibility. + + Be aware that headers from outside your project, in particular system + headers and headers from any other library you use, may not be + expecting to be compiled with visibility other than the default. You + may need to explicitly say ``#pragma GCC visibility push(default)`` + before including any such headers. + + ``extern`` declarations are not affected by :option:`-fvisibility`, so + a lot of code can be recompiled with :option:`-fvisibility=hidden` with + no modifications. However, this means that calls to ``extern`` + functions with no explicit visibility use the PLT, so it is more + effective to use ``__attribute ((visibility))`` and/or + ``#pragma GCC visibility`` to tell the compiler which ``extern`` + declarations should be treated as hidden. + + Note that :option:`-fvisibility` does affect C++ vague linkage + entities. This means that, for instance, an exception class that is + be thrown between DSOs must be explicitly marked with default + visibility so that the :samp:`type_info` nodes are unified between + the DSOs. + + An overview of these techniques, their benefits and how to use them + is at https://gcc.gnu.org/wiki/Visibility. + +.. option:: -fstrict-volatile-bitfields + + This option should be used if accesses to volatile bit-fields (or other + structure fields, although the compiler usually honors those types + anyway) should use a single access of the width of the + field's type, aligned to a natural alignment if possible. For + example, targets with memory-mapped peripheral registers might require + all such accesses to be 16 bits wide; with this flag you can + declare all peripheral bit-fields as ``unsigned short`` (assuming short + is 16 bits on these targets) to force GCC to use 16-bit accesses + instead of, perhaps, a more efficient 32-bit access. + + If this option is disabled, the compiler uses the most efficient + instruction. In the previous example, that might be a 32-bit load + instruction, even though that accesses bytes that do not contain + any portion of the bit-field, or memory-mapped registers unrelated to + the one being updated. + + In some cases, such as when the :var-attr:`packed` attribute is applied to a + structure field, it may not be possible to access the field with a single + read or write that is correctly aligned for the target machine. In this + case GCC falls back to generating multiple accesses rather than code that + will fault or truncate the result at run time. + + .. note:: + + Due to restrictions of the C/C++11 memory model, write accesses are + not allowed to touch non bit-field members. It is therefore recommended + to define all bits of the field's type as bit-field members. + + The default value of this option is determined by the application binary + interface for the target processor. + +.. option:: -fsync-libcalls + + This option controls whether any out-of-line instance of the ``__sync`` + family of functions may be used to implement the C++11 ``__atomic`` + family of functions. + + The default value of this option is enabled, thus the only useful form + of the option is :option:`-fno-sync-libcalls`. This option is used in + the implementation of the :samp:`libatomic` runtime library. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-for-debugging-your-program.rst b/gcc/doc/gcc/gcc-command-options/options-for-debugging-your-program.rst new file mode 100644 index 00000000000..16f830c8340 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-for-debugging-your-program.rst @@ -0,0 +1,471 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: options, debugging, debugging information options + +.. _debugging-options: + +Options for Debugging Your Program +********************************** + +To tell GCC to emit extra information for use by a debugger, in almost +all cases you need only to add :option:`-g` to your other options. Some debug +formats can co-exist (like DWARF with CTF) when each of them is enabled +explicitly by adding the respective command line option to your other options. + +GCC allows you to use :option:`-g` with +:option:`-O`. The shortcuts taken by optimized code may occasionally +be surprising: some variables you declared may not exist +at all; flow of control may briefly move where you did not expect it; +some statements may not be executed because they compute constant +results or their values are already at hand; some statements may +execute in different places because they have been moved out of loops. +Nevertheless it is possible to debug optimized output. This makes +it reasonable to use the optimizer for programs that might have bugs. + +If you are not using some other optimization option, consider +using :option:`-Og` (see :ref:`optimize-options`) with :option:`-g`. +With no :option:`-O` option at all, some compiler passes that collect +information useful for debugging do not run at all, so that +:option:`-Og` may result in a better debugging experience. + +.. option:: -g + + Produce debugging information in the operating system's native format + (stabs, COFF, XCOFF, or DWARF). GDB can work with this debugging + information. + + On most systems that use stabs format, :option:`-g` enables use of extra + debugging information that only GDB can use; this extra information + makes debugging work better in GDB but probably makes other debuggers + crash or refuse to read the program. If you want to control for certain whether + to generate the extra information, use :option:`-gvms` (see below). + +.. option:: -ggdb + + Produce debugging information for use by GDB. This means to use the + most expressive format available (DWARF, stabs, or the native format + if neither of those are supported), including GDB extensions if at all + possible. + +.. option:: -gdwarf, -gdwarf-version + + Produce debugging information in DWARF format (if that is supported). + The value of :samp:`{version}` may be either 2, 3, 4 or 5; the default + version for most targets is 5 (with the exception of VxWorks, TPF and + Darwin/Mac OS X, which default to version 2, and AIX, which defaults + to version 4). + + Note that with DWARF Version 2, some ports require and always + use some non-conflicting DWARF 3 extensions in the unwind tables. + + Version 4 may require GDB 7.0 and :option:`-fvar-tracking-assignments` + for maximum benefit. Version 5 requires GDB 8.0 or higher. + + GCC no longer supports DWARF Version 1, which is substantially + different than Version 2 and later. For historical reasons, some + other DWARF-related options such as + :option:`-fno-dwarf2-cfi-asm`) retain a reference to DWARF Version 2 + in their names, but apply to all currently-supported versions of DWARF. + +.. option:: -gbtf + + Request BTF debug information. BTF is the default debugging format for the + eBPF target. On other targets, like x86, BTF debug information can be + generated along with DWARF debug information when both of the debug formats are + enabled explicitly via their respective command line options. + +.. option:: -gctf, -gctflevel + + Request CTF debug information and use level to specify how much CTF debug + information should be produced. If :option:`-gctf` is specified + without a value for level, the default level of CTF debug information is 2. + + CTF debug information can be generated along with DWARF debug information when + both of the debug formats are enabled explicitly via their respective command + line options. + + Level 0 produces no CTF debug information at all. Thus, :option:`-gctf0` + negates :option:`-gctf`. + + Level 1 produces CTF information for tracebacks only. This includes callsite + information, but does not include type information. + + Level 2 produces type information for entities (functions, data objects etc.) + at file-scope or global-scope only. + +.. option:: -gvms + + Produce debugging information in Alpha/VMS debug format (if that is + supported). This is the format used by DEBUG on Alpha/VMS systems. + +:samp:`-g{level}` :samp:`-ggdb{level}` :samp:`-gvms{level}` + Request debugging information and also use :samp:`{level}` to specify how + much information. The default level is 2. + + Level 0 produces no debug information at all. Thus, :option:`-g0` negates + :option:`-g`. + + Level 1 produces minimal information, enough for making backtraces in + parts of the program that you don't plan to debug. This includes + descriptions of functions and external variables, and line number + tables, but no information about local variables. + + Level 3 includes extra information, such as all the macro definitions + present in the program. Some debuggers support macro expansion when + you use :option:`-g3`. + + If you use multiple :option:`-g` options, with or without level numbers, + the last such option is the one that is effective. + + :option:`-gdwarf` does not accept a concatenated debug level, to avoid + confusion with :option:`-gdwarf-level`. + Instead use an additional :option:`-glevel` option to change the + debug level for DWARF. + +.. option:: -fno-eliminate-unused-debug-symbols + + By default, no debug information is produced for symbols that are not actually + used. Use this option if you want debug information for all symbols. + +.. option:: -feliminate-unused-debug-symbols + + Default setting; overrides :option:`-fno-eliminate-unused-debug-symbols`. + +.. option:: -femit-class-debug-always + + Instead of emitting debugging information for a C++ class in only one + object file, emit it in all object files using the class. This option + should be used only with debuggers that are unable to handle the way GCC + normally emits debugging information for classes because using this + option increases the size of debugging information by as much as a + factor of two. + +.. option:: -fno-merge-debug-strings + + Direct the linker to not merge together strings in the debugging + information that are identical in different object files. Merging is + not supported by all assemblers or linkers. Merging decreases the size + of the debug information in the output file at the cost of increasing + link processing time. Merging is enabled by default. + +.. option:: -fmerge-debug-strings + + Default setting; overrides :option:`-fno-merge-debug-strings`. + +.. option:: -fdebug-prefix-map={old}={new} + + When compiling files residing in directory :samp:`{old}`, record + debugging information describing them as if the files resided in + directory :samp:`{new}` instead. This can be used to replace a + build-time path with an install-time path in the debug info. It can + also be used to change an absolute path to a relative path by using + :samp:`.` for :samp:`{new}`. This can give more reproducible builds, which + are location independent, but may require an extra command to tell GDB + where to find the source files. See also :option:`-ffile-prefix-map`. + +.. option:: -fvar-tracking + + Run variable tracking pass. It computes where variables are stored at each + position in code. Better debugging information is then generated + (if the debugging information format supports this information). + + It is enabled by default when compiling with optimization (:option:`-Os`, + :option:`-O`, :option:`-O2`, ...), debugging information (:option:`-g`) and + the debug info format supports it. + +.. option:: -fvar-tracking-assignments + + Annotate assignments to user variables early in the compilation and + attempt to carry the annotations over throughout the compilation all the + way to the end, in an attempt to improve debug information while + optimizing. Use of :option:`-gdwarf-4` is recommended along with it. + + It can be enabled even if var-tracking is disabled, in which case + annotations are created and maintained, but discarded at the end. + By default, this flag is enabled together with :option:`-fvar-tracking`, + except when selective scheduling is enabled. + +.. option:: -fno-var-tracking-assignments + + Default setting; overrides :option:`-fvar-tracking-assignments`. + +.. option:: -gsplit-dwarf + + If DWARF debugging information is enabled, separate as much debugging + information as possible into a separate output file with the extension + :samp:`.dwo`. This option allows the build system to avoid linking files with + debug information. To be useful, this option requires a debugger capable of + reading :samp:`.dwo` files. + +.. option:: -gdwarf32, -gdwarf64 + + If DWARF debugging information is enabled, the :option:`-gdwarf32` selects + the 32-bit DWARF format and the :option:`-gdwarf64` selects the 64-bit + DWARF format. The default is target specific, on most targets it is + :option:`-gdwarf32` though. The 32-bit DWARF format is smaller, but + can't support more than 2GiB of debug information in any of the DWARF + debug information sections. The 64-bit DWARF format allows larger debug + information and might not be well supported by all consumers yet. + +.. option:: -gdescribe-dies + + Add description attributes to some DWARF DIEs that have no name attribute, + such as artificial variables, external references and call site + parameter DIEs. + +.. option:: -gpubnames + + Generate DWARF ``.debug_pubnames`` and ``.debug_pubtypes`` sections. + +.. option:: -ggnu-pubnames + + Generate ``.debug_pubnames`` and ``.debug_pubtypes`` sections in a format + suitable for conversion into a GDBindex. This option is only useful + with a linker that can produce GDBindex version 7. + +.. option:: -fdebug-types-section + + When using DWARF Version 4 or higher, type DIEs can be put into + their own ``.debug_types`` section instead of making them part of the + ``.debug_info`` section. It is more efficient to put them in a separate + comdat section since the linker can then remove duplicates. + But not all DWARF consumers support ``.debug_types`` sections yet + and on some objects ``.debug_types`` produces larger instead of smaller + debugging information. + +.. option:: -fno-debug-types-section + + Default setting; overrides :option:`-fdebug-types-section`. + +.. option:: -grecord-gcc-switches, -gno-record-gcc-switches + + This switch causes the command-line options used to invoke the + compiler that may affect code generation to be appended to the + DW_AT_producer attribute in DWARF debugging information. The options + are concatenated with spaces separating them from each other and from + the compiler version. + It is enabled by default. + See also :option:`-frecord-gcc-switches` for another + way of storing compiler options into the object file. + +.. option:: -gstrict-dwarf + + Disallow using extensions of later DWARF standard version than selected + with :option:`-gdwarf-version`. On most targets using non-conflicting + DWARF extensions from later standard versions is allowed. + +.. option:: -gno-strict-dwarf + + Allow using extensions of later DWARF standard version than selected with + :option:`-gdwarf-version`. + +.. option:: -gas-loc-support + + Inform the compiler that the assembler supports ``.loc`` directives. + It may then use them for the assembler to generate DWARF2+ line number + tables. + + This is generally desirable, because assembler-generated line-number + tables are a lot more compact than those the compiler can generate + itself. + + This option will be enabled by default if, at GCC configure time, the + assembler was found to support such directives. + +.. option:: -gno-as-loc-support + + Force GCC to generate DWARF2+ line number tables internally, if DWARF2+ + line number tables are to be generated. + +.. option:: -gas-locview-support + + Inform the compiler that the assembler supports ``view`` assignment + and reset assertion checking in ``.loc`` directives. + + This option will be enabled by default if, at GCC configure time, the + assembler was found to support them. + +.. option:: -gno-as-locview-support + + Force GCC to assign view numbers internally, if + :option:`-gvariable-location-views` are explicitly requested. + +.. option:: -gcolumn-info, -gno-column-info + + Emit location column information into DWARF debugging information, rather + than just file and line. + This option is enabled by default. + +.. option:: -gstatement-frontiers, -gno-statement-frontiers + + This option causes GCC to create markers in the internal representation + at the beginning of statements, and to keep them roughly in place + throughout compilation, using them to guide the output of ``is_stmt`` + markers in the line number table. This is enabled by default when + compiling with optimization (:option:`-Os`, :option:`-O1`, :option:`-O2`, + ...), and outputting DWARF 2 debug information at the normal level. + +.. option:: -gvariable-location-views, -gvariable-location-views=incompat5, -gno-variable-location-views + + Augment variable location lists with progressive view numbers implied + from the line number table. This enables debug information consumers to + inspect state at certain points of the program, even if no instructions + associated with the corresponding source locations are present at that + point. If the assembler lacks support for view numbers in line number + tables, this will cause the compiler to emit the line number table, + which generally makes them somewhat less compact. The augmented line + number tables and location lists are fully backward-compatible, so they + can be consumed by debug information consumers that are not aware of + these augmentations, but they won't derive any benefit from them either. + + This is enabled by default when outputting DWARF 2 debug information at + the normal level, as long as there is assembler support, + :option:`-fvar-tracking-assignments` is enabled and + :option:`-gstrict-dwarf` is not. When assembler support is not + available, this may still be enabled, but it will force GCC to output + internal line number tables, and if + :option:`-ginternal-reset-location-views` is not enabled, that will most + certainly lead to silently mismatching location views. + + There is a proposed representation for view numbers that is not backward + compatible with the location list format introduced in DWARF 5, that can + be enabled with :option:`-gvariable-location-views=incompat5`. This + option may be removed in the future, is only provided as a reference + implementation of the proposed representation. Debug information + consumers are not expected to support this extended format, and they + would be rendered unable to decode location lists using it. + +.. option:: -ginternal-reset-location-views, -gno-internal-reset-location-views + + Attempt to determine location views that can be omitted from location + view lists. This requires the compiler to have very accurate insn + length estimates, which isn't always the case, and it may cause + incorrect view lists to be generated silently when using an assembler + that does not support location view lists. The GNU assembler will flag + any such error as a ``view number mismatch``. This is only enabled + on ports that define a reliable estimation function. + +.. option:: -ginline-points, -gno-inline-points + + Generate extended debug information for inlined functions. Location + view tracking markers are inserted at inlined entry points, so that + address and view numbers can be computed and output in debug + information. This can be enabled independently of location views, in + which case the view numbers won't be output, but it can only be enabled + along with statement frontiers, and it is only enabled by default if + location views are enabled. + +.. option:: -gz[={type}] + + Produce compressed debug sections in DWARF format, if that is supported. + If :samp:`{type}` is not given, the default type depends on the capabilities + of the assembler and linker used. :samp:`{type}` may be one of + :samp:`none` (don't compress debug sections), or :samp:`zlib` (use zlib + compression in ELF gABI format). If the linker doesn't support writing + compressed debug sections, the option is rejected. Otherwise, if the + assembler does not support them, :option:`-gz` is silently ignored when + producing object files. + +.. option:: -femit-struct-debug-baseonly + + Emit debug information for struct-like types + only when the base name of the compilation source file + matches the base name of file in which the struct is defined. + + This option substantially reduces the size of debugging information, + but at significant potential loss in type information to the debugger. + See :option:`-femit-struct-debug-reduced` for a less aggressive option. + See :option:`-femit-struct-debug-detailed` for more detailed control. + + This option works only with DWARF debug output. + +.. option:: -femit-struct-debug-reduced + + Emit debug information for struct-like types + only when the base name of the compilation source file + matches the base name of file in which the type is defined, + unless the struct is a template or defined in a system header. + + This option significantly reduces the size of debugging information, + with some potential loss in type information to the debugger. + See :option:`-femit-struct-debug-baseonly` for a more aggressive option. + See :option:`-femit-struct-debug-detailed` for more detailed control. + + This option works only with DWARF debug output. + +.. option:: -femit-struct-debug-detailed[={spec-list}] + + Specify the struct-like types + for which the compiler generates debug information. + The intent is to reduce duplicate struct debug information + between different object files within the same program. + + This option is a detailed version of + :option:`-femit-struct-debug-reduced` and :option:`-femit-struct-debug-baseonly`, + which serves for most needs. + + A specification has the syntax + + [:samp:`dir:` | :samp:`ind:`][:samp:`ord:` | :samp:`gen:`](:samp:`any` | :samp:`sys` | :samp:`base` | :samp:`none`) + + The optional first word limits the specification to + structs that are used directly (:samp:`dir:`) or used indirectly (:samp:`ind:`). + A struct type is used directly when it is the type of a variable, member. + Indirect uses arise through pointers to structs. + That is, when use of an incomplete struct is valid, the use is indirect. + An example is + :samp:`struct one direct; struct two * indirect;`. + + The optional second word limits the specification to + ordinary structs (:samp:`ord:`) or generic structs (:samp:`gen:`). + Generic structs are a bit complicated to explain. + For C++, these are non-explicit specializations of template classes, + or non-template classes within the above. + Other programming languages have generics, + but :option:`-femit-struct-debug-detailed` does not yet implement them. + + The third word specifies the source files for those + structs for which the compiler should emit debug information. + The values :samp:`none` and :samp:`any` have the normal meaning. + The value :samp:`base` means that + the base of name of the file in which the type declaration appears + must match the base of the name of the main compilation file. + In practice, this means that when compiling :samp:`foo.c`, debug information + is generated for types declared in that file and :samp:`foo.h`, + but not other header files. + The value :samp:`sys` means those types satisfying :samp:`base` + or declared in system or compiler headers. + + You may need to experiment to determine the best settings for your application. + + The default is :option:`-femit-struct-debug-detailed=all`. + + This option works only with DWARF debug output. + +.. option:: -fno-dwarf2-cfi-asm + + Emit DWARF unwind info as compiler generated ``.eh_frame`` section + instead of using GAS ``.cfi_*`` directives. + +.. option:: -fdwarf2-cfi-asm + + Default setting; overrides :option:`-fno-dwarf2-cfi-asm`. + +.. option:: -fno-eliminate-unused-debug-types + + Normally, when producing DWARF output, GCC avoids producing debug symbol + output for types that are nowhere used in the source file being compiled. + Sometimes it is useful to have GCC emit debugging + information for all types declared in a compilation + unit, regardless of whether or not they are actually used + in that compilation unit, for example + if, in the debugger, you want to cast a value to a type that is + not actually used in your program (but is declared). More often, + however, this results in a significant amount of wasted space. + +.. option:: -feliminate-unused-debug-types + + Default setting; overrides :option:`-fno-eliminate-unused-debug-types`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-for-directory-search.rst b/gcc/doc/gcc/gcc-command-options/options-for-directory-search.rst new file mode 100644 index 00000000000..1d6e0e4b87a --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-for-directory-search.rst @@ -0,0 +1,102 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: directory options, options, directory search, search path + +.. _directory-options: + +Options for Directory Search +**************************** + +These options specify directories to search for header files, for +libraries and for parts of the compiler: + +.. include:: ../../../../doc/cppdiropts.rst + +.. option:: -iplugindir={dir} + + Set the directory to search for plugins that are passed + by :option:`-fplugin=name` instead of + :option:`-fplugin=path/name.so`. This option is not meant + to be used by the user, but only passed by the driver. + +.. option:: -Ldir + + Add directory :samp:`{dir}` to the list of directories to be searched + for :option:`-l`. + +.. option:: -Bprefix + + This option specifies where to find the executables, libraries, + include files, and data files of the compiler itself. + + The compiler driver program runs one or more of the subprograms + :command:`cpp`, :command:`cc1`, :command:`as` and :command:`ld`. It tries + :samp:`{prefix}` as a prefix for each program it tries to run, both with and + without :samp:`{machine}/{version}/` for the corresponding target + machine and compiler version. + + For each subprogram to be run, the compiler driver first tries the + :option:`-B` prefix, if any. If that name is not found, or if :option:`-B` + is not specified, the driver tries two standard prefixes, + :samp:`/usr/lib/gcc/` and :samp:`/usr/local/lib/gcc/`. If neither of + those results in a file name that is found, the unmodified program + name is searched for using the directories specified in your + :envvar:`PATH` environment variable. + + The compiler checks to see if the path provided by :option:`-B` + refers to a directory, and if necessary it adds a directory + separator character at the end of the path. + + :option:`-B` prefixes that effectively specify directory names also apply + to libraries in the linker, because the compiler translates these + options into :option:`-L` options for the linker. They also apply to + include files in the preprocessor, because the compiler translates these + options into :option:`-isystem` options for the preprocessor. In this case, + the compiler appends :samp:`include` to the prefix. + + The runtime support file :samp:`libgcc.a` can also be searched for using + the :option:`-B` prefix, if needed. If it is not found there, the two + standard prefixes above are tried, and that is all. The file is left + out of the link if it is not found by those means. + + Another way to specify a prefix much like the :option:`-B` prefix is to use + the environment variable :envvar:`GCC_EXEC_PREFIX`. See :ref:`environment-variables`. + + As a special kludge, if the path provided by :option:`-B` is + :samp:`[dir/]stage{N}/`, where :samp:`{N}` is a number in the range 0 to + 9, then it is replaced by :samp:`[dir/]include`. This is to help + with boot-strapping the compiler. + +.. option:: -no-canonical-prefixes + + Do not expand any symbolic links, resolve references to :samp:`/../` + or :samp:`/./`, or make the path absolute when generating a relative + prefix. + +.. option:: --sysroot={dir} + + Use :samp:`{dir}` as the logical root directory for headers and libraries. + For example, if the compiler normally searches for headers in + :samp:`/usr/include` and libraries in :samp:`/usr/lib`, it instead + searches :samp:`{dir}/usr/include` and :samp:`{dir}/usr/lib`. + + If you use both this option and the :option:`-isysroot` option, then + the :option:`--sysroot` option applies to libraries, but the + :option:`-isysroot` option applies to header files. + + The GNU linker (beginning with version 2.16) has the necessary support + for this option. If your linker does not support this option, the + header file aspect of :option:`--sysroot` still works, but the + library aspect does not. + +.. option:: --no-sysroot-suffix + + For some targets, a suffix is added to the root directory specified + with :option:`--sysroot`, depending on the other options used, so that + headers may for example be found in + :samp:`{dir}/{suffix}/usr/include` instead of + :samp:`{dir}/usr/include`. This option disables the addition of + such a suffix. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-for-linking.rst b/gcc/doc/gcc/gcc-command-options/options-for-linking.rst new file mode 100644 index 00000000000..d988b2fccb5 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-for-linking.rst @@ -0,0 +1,407 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: link options, options, linking + +.. _link-options: + +Options for Linking +******************* + +These options come into play when the compiler links object files into +an executable output file. They are meaningless if the compiler is +not doing a link step. + +.. index:: file names + +``object-file-name`` + A file name that does not end in a special recognized suffix is + considered to name an object file or library. (Object files are + distinguished from libraries by the linker according to the file + contents.) If linking is done, these object files are used as input + to the linker. + +.. option:: -c, -S, -E + + If any of these options is used, then the linker is not run, and + object file names should not be used as arguments. See :ref:`overall-options`. + +.. option:: -flinker-output={type} + + This option controls code generation of the link-time optimizer. By + default the linker output is automatically determined by the linker + plugin. For debugging the compiler and if incremental linking with a + non-LTO object file is desired, it may be useful to control the type + manually. + + If :samp:`{type}` is :samp:`exec`, code generation produces a static + binary. In this case :option:`-fpic` and :option:`-fpie` are both + disabled. + + If :samp:`{type}` is :samp:`dyn`, code generation produces a shared + library. In this case :option:`-fpic` or :option:`-fPIC` is preserved, + but not enabled automatically. This allows to build shared libraries + without position-independent code on architectures where this is + possible, i.e. on x86. + + If :samp:`{type}` is :samp:`pie`, code generation produces an :option:`-fpie` + executable. This results in similar optimizations as :samp:`exec` + except that :option:`-fpie` is not disabled if specified at compilation + time. + + If :samp:`{type}` is :samp:`rel`, the compiler assumes that incremental linking is + done. The sections containing intermediate code for link-time optimization are + merged, pre-optimized, and output to the resulting object file. In addition, if + :option:`-ffat-lto-objects` is specified, binary code is produced for future + non-LTO linking. The object file produced by incremental linking is smaller + than a static library produced from the same object files. At link time the + result of incremental linking also loads faster than a static + library assuming that the majority of objects in the library are used. + + Finally :samp:`nolto-rel` configures the compiler for incremental linking where + code generation is forced, a final binary is produced, and the intermediate + code for later link-time optimization is stripped. When multiple object files + are linked together the resulting code is better optimized than with + link-time optimizations disabled (for example, cross-module inlining + happens), but most of benefits of whole program optimizations are lost. + + During the incremental link (by :option:`-r`) the linker plugin defaults to + rel. With current interfaces to GNU Binutils it is however not + possible to incrementally link LTO objects and non-LTO objects into a single + mixed object file. If any of object files in incremental link cannot + be used for link-time optimization, the linker plugin issues a warning and + uses :samp:`nolto-rel`. To maintain whole program optimization, it is + recommended to link such objects into static library instead. Alternatively it + is possible to use H.J. Lu's binutils with support for mixed objects. + +.. option:: -fuse-ld=bfd + + Use the :command:`bfd` linker instead of the default linker. + +.. option:: -fuse-ld=gold + + Use the :command:`gold` linker instead of the default linker. + +.. option:: -fuse-ld=lld + + Use the LLVM :command:`lld` linker instead of the default linker. + +.. option:: -fuse-ld=mold + + Use the Modern Linker (:command:`mold`) instead of the default linker. + + .. index:: Libraries + +.. option:: -llibrary, -l {library} + + Search the library named :samp:`{library}` when linking. (The second + alternative with the library as a separate argument is only for + POSIX compliance and is not recommended.) + + The :option:`-l` option is passed directly to the linker by GCC. Refer + to your linker documentation for exact details. The general + description below applies to the GNU linker. + + The linker searches a standard list of directories for the library. + The directories searched include several standard system directories + plus any that you specify with :option:`-L`. + + Static libraries are archives of object files, and have file names + like :samp:`lib{library}.a`. Some targets also support shared + libraries, which typically have names like :samp:`lib{library}.so`. + If both static and shared libraries are found, the linker gives + preference to linking with the shared library unless the + :option:`-static` option is used. + + It makes a difference where in the command you write this option; the + linker searches and processes libraries and object files in the order they + are specified. Thus, :samp:`foo.o -lz bar.o` searches library :samp:`z` + after file :samp:`foo.o` but before :samp:`bar.o`. If :samp:`bar.o` refers + to functions in :samp:`z`, those functions may not be loaded. + +.. option:: -lobjc + + You need this special case of the :option:`-l` option in order to + link an Objective-C or Objective-C++ program. + +.. option:: -nostartfiles + + Do not use the standard system startup files when linking. + The standard system libraries are used normally, unless :option:`-nostdlib`, + :option:`-nolibc`, or :option:`-nodefaultlibs` is used. + +.. option:: -nodefaultlibs + + Do not use the standard system libraries when linking. + Only the libraries you specify are passed to the linker, and options + specifying linkage of the system libraries, such as :option:`-static-libgcc` + or :option:`-shared-libgcc`, are ignored. + The standard startup files are used normally, unless :option:`-nostartfiles` + is used. + + The compiler may generate calls to ``memcmp``, + ``memset``, ``memcpy`` and ``memmove``. + These entries are usually resolved by entries in + libc. These entry points should be supplied through some other + mechanism when this option is specified. + +.. option:: -nolibc + + Do not use the C library or system libraries tightly coupled with it when + linking. Still link with the startup files, :samp:`libgcc` or toolchain + provided language support libraries such as :samp:`libgnat`, :samp:`libgfortran` + or :samp:`libstdc++` unless options preventing their inclusion are used as + well. This typically removes :option:`-lc` from the link command line, as well + as system libraries that normally go with it and become meaningless when + absence of a C library is assumed, for example :option:`-lpthread` or + :option:`-lm` in some configurations. This is intended for bare-board + targets when there is indeed no C library available. + +.. option:: -nostdlib + + Do not use the standard system startup files or libraries when linking. + No startup files and only the libraries you specify are passed to + the linker, and options specifying linkage of the system libraries, such as + :option:`-static-libgcc` or :option:`-shared-libgcc`, are ignored. + + The compiler may generate calls to ``memcmp``, ``memset``, + ``memcpy`` and ``memmove``. + These entries are usually resolved by entries in + libc. These entry points should be supplied through some other + mechanism when this option is specified. + + .. index:: -lgcc, use with -nostdlib, -nostdlib and unresolved references, unresolved references and -nostdlib, -lgcc, use with -nodefaultlibs, -nodefaultlibs and unresolved references, unresolved references and -nodefaultlibs + + One of the standard libraries bypassed by :option:`-nostdlib` and + :option:`-nodefaultlibs` is :samp:`libgcc.a`, a library of internal subroutines + which GCC uses to overcome shortcomings of particular machines, or special + needs for some languages. + (See :ref:`gccint:interface`, + for more discussion of :samp:`libgcc.a`.) + In most cases, you need :samp:`libgcc.a` even when you want to avoid + other standard libraries. In other words, when you specify :option:`-nostdlib` + or :option:`-nodefaultlibs` you should usually specify :option:`-lgcc` as well. + This ensures that you have no unresolved references to internal GCC + library subroutines. + (An example of such an internal subroutine is ``__main``, used to ensure C++ + constructors are called; see :ref:`gccint:collect2`.) + +.. option:: -nostdlib++ + + Do not implicitly link with standard C++ libraries. + +.. option:: -e {entry}, --entry={entry} + + Specify that the program entry point is :samp:`{entry}`. The argument is + interpreted by the linker; the GNU linker accepts either a symbol name + or an address. + +.. option:: -pie + + Produce a dynamically linked position independent executable on targets + that support it. For predictable results, you must also specify the same + set of options used for compilation (:option:`-fpie`, :option:`-fPIE`, + or model suboptions) when you specify this linker option. + +.. option:: -no-pie + + Don't produce a dynamically linked position independent executable. + +.. option:: -static-pie + + Produce a static position independent executable on targets that support + it. A static position independent executable is similar to a static + executable, but can be loaded at any address without a dynamic linker. + For predictable results, you must also specify the same set of options + used for compilation (:option:`-fpie`, :option:`-fPIE`, or model + suboptions) when you specify this linker option. + +.. option:: -pthread + + Link with the POSIX threads library. This option is supported on + GNU/Linux targets, most other Unix derivatives, and also on + x86 Cygwin and MinGW targets. On some targets this option also sets + flags for the preprocessor, so it should be used consistently for both + compilation and linking. + +.. option:: -r + + Produce a relocatable object as output. This is also known as partial + linking. + +.. option:: -rdynamic + + Pass the flag :option:`-export-dynamic` to the ELF linker, on targets + that support it. This instructs the linker to add all symbols, not + only used ones, to the dynamic symbol table. This option is needed + for some uses of ``dlopen`` or to allow obtaining backtraces + from within a program. + +.. option:: -s + + Remove all symbol table and relocation information from the executable. + +.. option:: -static + + On systems that support dynamic linking, this overrides :option:`-pie` + and prevents linking with the shared libraries. On other systems, this + option has no effect. + +.. option:: -shared + + Produce a shared object which can then be linked with other objects to + form an executable. Not all systems support this option. For predictable + results, you must also specify the same set of options used for compilation + (:option:`-fpic`, :option:`-fPIC`, or model suboptions) when + you specify this linker option. + + On some systems, :samp:`gcc -shared` + needs to build supplementary stub code for constructors to work. On + multi-libbed systems, :samp:`gcc -shared` must select the correct support + libraries to link against. Failing to supply the correct flags may lead + to subtle defects. Supplying them in cases where they are not necessary + is innocuous. + +.. option:: -shared-libgcc, -static-libgcc + + On systems that provide :samp:`libgcc` as a shared library, these options + force the use of either the shared or static version, respectively. + If no shared version of :samp:`libgcc` was built when the compiler was + configured, these options have no effect. + + There are several situations in which an application should use the + shared :samp:`libgcc` instead of the static version. The most common + of these is when the application wishes to throw and catch exceptions + across different shared libraries. In that case, each of the libraries + as well as the application itself should use the shared :samp:`libgcc`. + + Therefore, the G++ driver automatically adds :option:`-shared-libgcc` + whenever you build a shared library or a main executable, because C++ + programs typically use exceptions, so this is the right thing to do. + + If, instead, you use the GCC driver to create shared libraries, you may + find that they are not always linked with the shared :samp:`libgcc`. + If GCC finds, at its configuration time, that you have a non-GNU linker + or a GNU linker that does not support option :option:`--eh-frame-hdr`, + it links the shared version of :samp:`libgcc` into shared libraries + by default. Otherwise, it takes advantage of the linker and optimizes + away the linking with the shared version of :samp:`libgcc`, linking with + the static version of libgcc by default. This allows exceptions to + propagate through such shared libraries, without incurring relocation + costs at library load time. + + However, if a library or main executable is supposed to throw or catch + exceptions, you must link it using the G++ driver, or using the option + :option:`-shared-libgcc`, such that it is linked with the shared + :samp:`libgcc`. + +.. option:: -static-libasan + + When the :option:`-fsanitize=address` option is used to link a program, + the GCC driver automatically links against libasan. If + :samp:`libasan` is available as a shared library, and the :option:`-static` + option is not used, then this links against the shared version of + :samp:`libasan`. The :option:`-static-libasan` option directs the GCC + driver to link :samp:`libasan` statically, without necessarily linking + other libraries statically. + +.. option:: -static-libtsan + + When the :option:`-fsanitize=thread` option is used to link a program, + the GCC driver automatically links against libtsan. If + :samp:`libtsan` is available as a shared library, and the :option:`-static` + option is not used, then this links against the shared version of + :samp:`libtsan`. The :option:`-static-libtsan` option directs the GCC + driver to link :samp:`libtsan` statically, without necessarily linking + other libraries statically. + +.. option:: -static-liblsan + + When the :option:`-fsanitize=leak` option is used to link a program, + the GCC driver automatically links against liblsan. If + :samp:`liblsan` is available as a shared library, and the :option:`-static` + option is not used, then this links against the shared version of + :samp:`liblsan`. The :option:`-static-liblsan` option directs the GCC + driver to link :samp:`liblsan` statically, without necessarily linking + other libraries statically. + +.. option:: -static-libubsan + + When the :option:`-fsanitize=undefined` option is used to link a program, + the GCC driver automatically links against libubsan. If + :samp:`libubsan` is available as a shared library, and the :option:`-static` + option is not used, then this links against the shared version of + :samp:`libubsan`. The :option:`-static-libubsan` option directs the GCC + driver to link :samp:`libubsan` statically, without necessarily linking + other libraries statically. + +.. option:: -static-libstdc++ + + When the :command:`g++` program is used to link a C++ program, it + normally automatically links against libstdc++. If + :samp:`libstdc++` is available as a shared library, and the + :option:`-static` option is not used, then this links against the + shared version of :samp:`libstdc++`. That is normally fine. However, it + is sometimes useful to freeze the version of :samp:`libstdc++` used by + the program without going all the way to a fully static link. The + :option:`-static-libstdc++` option directs the :command:`g++` driver to + link :samp:`libstdc++` statically, without necessarily linking other + libraries statically. + +.. option:: -symbolic + + Bind references to global symbols when building a shared object. Warn + about any unresolved references (unless overridden by the link editor + option :option:`-Xlinker -z -Xlinker defs`). Only a few systems support + this option. + +.. index:: linker script + +.. option:: -T {script} + + Use :samp:`{script}` as the linker script. This option is supported by most + systems using the GNU linker. On some targets, such as bare-board + targets without an operating system, the :option:`-T` option may be required + when linking to avoid references to undefined symbols. + +.. option:: -Xlinker {option} + + Pass :samp:`{option}` as an option to the linker. You can use this to + supply system-specific linker options that GCC does not recognize. + + If you want to pass an option that takes a separate argument, you must use + :option:`-Xlinker` twice, once for the option and once for the argument. + For example, to pass :option:`-assert definitions`, you must write + :option:`-Xlinker -assert -Xlinker definitions`. It does not work to write + :option:`-Xlinker "-assert definitions"`, because this passes the entire + string as a single argument, which is not what the linker expects. + + When using the GNU linker, it is usually more convenient to pass + arguments to linker options using the :samp:`{option}={value}` + syntax than as separate arguments. For example, you can specify + :option:`-Xlinker -Map=output.map` rather than + :option:`-Xlinker -Map -Xlinker output.map`. Other linkers may not support + this syntax for command-line options. + +.. option:: -Wl,option + + Pass :samp:`{option}` as an option to the linker. If :samp:`{option}` contains + commas, it is split into multiple options at the commas. You can use this + syntax to pass an argument to the option. + For example, :option:`-Wl,-Map,output.map` passes :option:`-Map output.map` to the + linker. When using the GNU linker, you can also get the same effect with + :option:`-Wl,-Map=output.map`. + +.. option:: -u {symbol} + + Pretend the symbol :samp:`{symbol}` is undefined, to force linking of + library modules to define it. You can use :option:`-u` multiple times with + different symbols to force loading of additional library modules. + +.. option:: -z {keyword} + + :option:`-z` is passed directly on to the linker along with the keyword + :samp:`{keyword}`. See the section in the documentation of your linker for + permitted values and their meanings. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-that-control-optimization.rst b/gcc/doc/gcc/gcc-command-options/options-that-control-optimization.rst new file mode 100644 index 00000000000..102396fb6b7 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-that-control-optimization.rst @@ -0,0 +1,4857 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: optimize options, options, optimization + +.. _optimize-options: + +Options That Control Optimization +********************************* + +These options control various sorts of optimizations. + +Without any optimization option, the compiler's goal is to reduce the +cost of compilation and to make debugging produce the expected +results. Statements are independent: if you stop the program with a +breakpoint between statements, you can then assign a new value to any +variable or change the program counter to any other statement in the +function and get exactly the results you expect from the source +code. + +Turning on optimization flags makes the compiler attempt to improve +the performance and/or code size at the expense of compilation time +and possibly the ability to debug the program. + +The compiler performs optimization based on the knowledge it has of the +program. Compiling multiple files at once to a single output file mode allows +the compiler to use information gained from all of the files when compiling +each of them. + +Not all optimizations are controlled directly by a flag. Only +optimizations that have a flag are listed in this section. + +Most optimizations are completely disabled at :option:`-O0` or if an +:option:`-O` level is not set on the command line, even if individual +optimization flags are specified. Similarly, :option:`-Og` suppresses +many optimization passes. + +Depending on the target and how GCC was configured, a slightly different +set of optimizations may be enabled at each :option:`-O` level than +those listed here. You can invoke GCC with :option:`-Q --help=optimizers` +to find out the exact set of optimizations that are enabled at each level. +See :ref:`overall-options`, for examples. + +.. option:: -O, -O1 + + Optimize. Optimizing compilation takes somewhat more time, and a lot + more memory for a large function. + + With :option:`-O`, the compiler tries to reduce code size and execution + time, without performing any optimizations that take a great deal of + compilation time. + + .. Note that in addition to the default_options_table list in opts.cc, + several optimization flags default to true but control optimization + passes that are explicitly disabled at -O0. + + :option:`-O` turns on the following optimization flags: + + .. Please keep the following list alphabetized. + + :option:`-fauto-inc-dec` |gol| + :option:`-fbranch-count-reg` |gol| + :option:`-fcombine-stack-adjustments` |gol| + :option:`-fcompare-elim` |gol| + :option:`-fcprop-registers` |gol| + :option:`-fdce` |gol| + :option:`-fdefer-pop` |gol| + :option:`-fdelayed-branch` |gol| + :option:`-fdse` |gol| + :option:`-fforward-propagate` |gol| + :option:`-fguess-branch-probability` |gol| + :option:`-fif-conversion` |gol| + :option:`-fif-conversion2` |gol| + :option:`-finline-functions-called-once` |gol| + :option:`-fipa-modref` |gol| + :option:`-fipa-profile` |gol| + :option:`-fipa-pure-const` |gol| + :option:`-fipa-reference` |gol| + :option:`-fipa-reference-addressable` |gol| + :option:`-fmerge-constants` |gol| + :option:`-fmove-loop-invariants` |gol| + :option:`-fmove-loop-stores` |gol| + :option:`-fomit-frame-pointer` |gol| + :option:`-freorder-blocks` |gol| + :option:`-fshrink-wrap` |gol| + :option:`-fshrink-wrap-separate` |gol| + :option:`-fsplit-wide-types` |gol| + :option:`-fssa-backprop` |gol| + :option:`-fssa-phiopt` |gol| + :option:`-ftree-bit-ccp` |gol| + :option:`-ftree-ccp` |gol| + :option:`-ftree-ch` |gol| + :option:`-ftree-coalesce-vars` |gol| + :option:`-ftree-copy-prop` |gol| + :option:`-ftree-dce` |gol| + :option:`-ftree-dominator-opts` |gol| + :option:`-ftree-dse` |gol| + :option:`-ftree-forwprop` |gol| + :option:`-ftree-fre` |gol| + :option:`-ftree-phiprop` |gol| + :option:`-ftree-pta` |gol| + :option:`-ftree-scev-cprop` |gol| + :option:`-ftree-sink` |gol| + :option:`-ftree-slsr` |gol| + :option:`-ftree-sra` |gol| + :option:`-ftree-ter` |gol| + :option:`-funit-at-a-time` + +.. option:: -O2 + + Optimize even more. GCC performs nearly all supported optimizations + that do not involve a space-speed tradeoff. + As compared to :option:`-O`, this option increases both compilation time + and the performance of the generated code. + + :option:`-O2` turns on all optimization flags specified by :option:`-O1`. It + also turns on the following optimization flags: + + .. Please keep the following list alphabetized! + + :option:`-falign-functions` :option:`-falign-jumps` |gol| + :option:`-falign-labels` :option:`-falign-loops` |gol| + :option:`-fcaller-saves` |gol| + :option:`-fcode-hoisting` |gol| + :option:`-fcrossjumping` |gol| + :option:`-fcse-follow-jumps` :option:`-fcse-skip-blocks` |gol| + :option:`-fdelete-null-pointer-checks` |gol| + :option:`-fdevirtualize` :option:`-fdevirtualize-speculatively` |gol| + :option:`-fexpensive-optimizations` |gol| + :option:`-ffinite-loops` |gol| + :option:`-fgcse` :option:`-fgcse-lm` |gol| + :option:`-fhoist-adjacent-loads` |gol| + :option:`-finline-functions` |gol| + :option:`-finline-small-functions` |gol| + :option:`-findirect-inlining` |gol| + :option:`-fipa-bit-cp` :option:`-fipa-cp` :option:`-fipa-icf` |gol| + :option:`-fipa-ra` :option:`-fipa-sra` :option:`-fipa-vrp` |gol| + :option:`-fisolate-erroneous-paths-dereference` |gol| + :option:`-flra-remat` |gol| + :option:`-foptimize-sibling-calls` |gol| + :option:`-foptimize-strlen` |gol| + :option:`-fpartial-inlining` |gol| + :option:`-fpeephole2` |gol| + :option:`-freorder-blocks-algorithm=stc` |gol| + :option:`-freorder-blocks-and-partition` :option:`-freorder-functions` |gol| + :option:`-frerun-cse-after-loop` |gol| + :option:`-fschedule-insns` :option:`-fschedule-insns2` |gol| + :option:`-fsched-interblock` :option:`-fsched-spec` |gol| + :option:`-fstore-merging` |gol| + :option:`-fstrict-aliasing` |gol| + :option:`-fthread-jumps` |gol| + :option:`-ftree-builtin-call-dce` |gol| + :option:`-ftree-loop-vectorize` |gol| + :option:`-ftree-pre` |gol| + :option:`-ftree-slp-vectorize` |gol| + :option:`-ftree-switch-conversion` :option:`-ftree-tail-merge` |gol| + :option:`-ftree-vrp` |gol| + :option:`-fvect-cost-model=very-cheap` + + Please note the warning under :option:`-fgcse` about + invoking :option:`-O2` on programs that use computed gotos. + +.. option:: -O3 + + Optimize yet more. :option:`-O3` turns on all optimizations specified + by :option:`-O2` and also turns on the following optimization flags: + + .. Please keep the following list alphabetized! + + :option:`-fgcse-after-reload` |gol| + :option:`-fipa-cp-clone` |gol| + :option:`-floop-interchange` |gol| + :option:`-floop-unroll-and-jam` |gol| + :option:`-fpeel-loops` |gol| + :option:`-fpredictive-commoning` |gol| + :option:`-fsplit-loops` |gol| + :option:`-fsplit-paths` |gol| + :option:`-ftree-loop-distribution` |gol| + :option:`-ftree-partial-pre` |gol| + :option:`-funswitch-loops` |gol| + :option:`-fvect-cost-model=dynamic` |gol| + :option:`-fversion-loops-for-strides` + +.. option:: -O0 + + Reduce compilation time and make debugging produce the expected + results. This is the default. + +.. option:: -Os + + Optimize for size. :option:`-Os` enables all :option:`-O2` optimizations + except those that often increase code size: + + :option:`-falign-functions` :option:`-falign-jumps` |gol| + :option:`-falign-labels` :option:`-falign-loops` |gol| + :option:`-fprefetch-loop-arrays` :option:`-freorder-blocks-algorithm=stc` |gol| + It also enables :option:`-finline-functions`, causes the compiler to tune for + code size rather than execution speed, and performs further optimizations + designed to reduce code size. + +.. option:: -Ofast + + Disregard strict standards compliance. :option:`-Ofast` enables all + :option:`-O3` optimizations. It also enables optimizations that are not + valid for all standard-compliant programs. + It turns on :option:`-ffast-math`, :option:`-fallow-store-data-races` + and the Fortran-specific :option:`-fstack-arrays`, unless + :option:`-fmax-stack-var-size` is specified, and :option:`-fno-protect-parens`. + It turns off :option:`-fsemantic-interposition`. + +.. option:: -Og + + Optimize debugging experience. :option:`-Og` should be the optimization + level of choice for the standard edit-compile-debug cycle, offering + a reasonable level of optimization while maintaining fast compilation + and a good debugging experience. It is a better choice than :option:`-O0` + for producing debuggable code because some compiler passes + that collect debug information are disabled at :option:`-O0`. + + Like :option:`-O0`, :option:`-Og` completely disables a number of + optimization passes so that individual options controlling them have + no effect. Otherwise :option:`-Og` enables all :option:`-O1` + optimization flags except for those that may interfere with debugging: + + :option:`-fbranch-count-reg` :option:`-fdelayed-branch` |gol| + :option:`-fdse` :option:`-fif-conversion` :option:`-fif-conversion2` |gol| + :option:`-finline-functions-called-once` |gol| + :option:`-fmove-loop-invariants` :option:`-fmove-loop-stores` :option:`-fssa-phiopt` |gol| + :option:`-ftree-bit-ccp` :option:`-ftree-dse` :option:`-ftree-pta` :option:`-ftree-sra` + +.. option:: -Oz + + Optimize aggressively for size rather than speed. This may increase + the number of instructions executed if those instructions require + fewer bytes to encode. :option:`-Oz` behaves similarly to :option:`-Os` + including enabling most :option:`-O2` optimizations. + +If you use multiple :option:`-O` options, with or without level numbers, +the last such option is the one that is effective. + +Options of the form :samp:`-fflag` specify machine-independent +flags. Most flags have both positive and negative forms; the negative +form of :samp:`-ffoo` is :samp:`-fno-foo`. In the table +below, only one of the forms is listed---the one you typically +use. You can figure out the other form by either removing :samp:`no-` +or adding it. + +The following options control specific optimizations. They are either +activated by :option:`-O` options or are related to ones that are. You +can use the following flags in the rare cases when 'fine-tuning' of +optimizations to be performed is desired. + +.. option:: -fno-defer-pop + + For machines that must pop arguments after a function call, always pop + the arguments as soon as each function returns. + At levels :option:`-O1` and higher, :option:`-fdefer-pop` is the default; + this allows the compiler to let arguments accumulate on the stack for several + function calls and pop them all at once. + +.. option:: -fdefer-pop + + Default setting; overrides :option:`-fno-defer-pop`. + +.. option:: -fforward-propagate + + Perform a forward propagation pass on RTL. The pass tries to combine two + instructions and checks if the result can be simplified. If loop unrolling + is active, two passes are performed and the second is scheduled after + loop unrolling. + + This option is enabled by default at optimization levels :option:`-O1`, + :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -ffp-contract={style} + + :option:`-ffp-contract=off` disables floating-point expression contraction. + :option:`-ffp-contract=fast` enables floating-point expression contraction + such as forming of fused multiply-add operations if the target has + native support for them. + :option:`-ffp-contract=on` enables floating-point expression contraction + if allowed by the language standard. This is currently not implemented + and treated equal to :option:`-ffp-contract=off`. + + The default is :option:`-ffp-contract=fast`. + +.. option:: -fomit-frame-pointer + + Omit the frame pointer in functions that don't need one. This avoids the + instructions to save, set up and restore the frame pointer; on many targets + it also makes an extra register available. + + On some targets this flag has no effect because the standard calling sequence + always uses a frame pointer, so it cannot be omitted. + + Note that :option:`-fno-omit-frame-pointer` doesn't guarantee the frame pointer + is used in all functions. Several targets always omit the frame pointer in + leaf functions. + + Enabled by default at :option:`-O1` and higher. + +.. option:: -foptimize-sibling-calls + + Optimize sibling and tail recursive calls. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -foptimize-strlen + + Optimize various standard C string functions (e.g. ``strlen``, + ``strchr`` or ``strcpy``) and + their ``_FORTIFY_SOURCE`` counterparts into faster alternatives. + + Enabled at levels :option:`-O2`, :option:`-O3`. + +.. option:: -fno-inline + + Do not expand any functions inline apart from those marked with + the :fn-attr:`always_inline` attribute. This is the default when not + optimizing. + + Single functions can be exempted from inlining by marking them + with the :fn-attr:`noinline` attribute. + +.. option:: -finline + + Default setting; overrides :option:`-fno-inline`. + +.. option:: -finline-small-functions + + Integrate functions into their callers when their body is smaller than expected + function call code (so overall size of program gets smaller). The compiler + heuristically decides which functions are simple enough to be worth integrating + in this way. This inlining applies to all functions, even those not declared + inline. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -findirect-inlining + + Inline also indirect calls that are discovered to be known at compile + time thanks to previous inlining. This option has any effect only + when inlining itself is turned on by the :option:`-finline-functions` + or :option:`-finline-small-functions` options. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -finline-functions + + Consider all functions for inlining, even if they are not declared inline. + The compiler heuristically decides which functions are worth integrating + in this way. + + If all calls to a given function are integrated, and the function is + declared ``static``, then the function is normally not output as + assembler code in its own right. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. Also enabled + by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -finline-functions-called-once + + Consider all ``static`` functions called once for inlining into their + caller even if they are not marked ``inline``. If a call to a given + function is integrated, then the function is not output as assembler code + in its own right. + + Enabled at levels :option:`-O1`, :option:`-O2`, :option:`-O3` and :option:`-Os`, + but not :option:`-Og`. + +.. option:: -fearly-inlining + + Inline functions marked by :fn-attr:`always_inline` and functions whose body seems + smaller than the function call overhead early before doing + :option:`-fprofile-generate` instrumentation and real inlining pass. Doing so + makes profiling significantly cheaper and usually inlining faster on programs + having large chains of nested wrapper functions. + + Enabled by default. + +.. option:: -fipa-sra + + Perform interprocedural scalar replacement of aggregates, removal of + unused parameters and replacement of parameters passed by reference + by parameters passed by value. + + Enabled at levels :option:`-O2`, :option:`-O3` and :option:`-Os`. + +.. option:: -finline-limit={n} + + By default, GCC limits the size of functions that can be inlined. This flag + allows coarse control of this limit. :samp:`{n}` is the size of functions that + can be inlined in number of pseudo instructions. + + Inlining is actually controlled by a number of parameters, which may be + specified individually by using :option:`--param name=value`. + The :option:`-finline-limit=n` option sets some of these parameters + as follows: + + ``max-inline-insns-single`` + is set to :samp:`{n}/2`. + + ``max-inline-insns-auto`` + is set to :samp:`{n}/2`. + + See below for a documentation of the individual + parameters controlling inlining and for the defaults of these parameters. + + .. note:: + There may be no value to :option:`-finline-limit` that results + in default behavior. + + .. note:: + Pseudo instruction represents, in this particular context, an + abstract measurement of function's size. In no way does it represent a count + of assembly instructions and as such its exact meaning might change from one + release to an another. + +.. option:: -fno-keep-inline-dllexport + + This is a more fine-grained version of :option:`-fkeep-inline-functions`, + which applies only to functions that are declared using the :microsoft-windows-fn-attr:`dllexport` + attribute or declspec. See :ref:`function-attributes`. + +.. option:: -fkeep-inline-dllexport + + Default setting; overrides :option:`-fno-keep-inline-dllexport`. + +.. option:: -fkeep-inline-functions + + In C, emit ``static`` functions that are declared ``inline`` + into the object file, even if the function has been inlined into all + of its callers. This switch does not affect functions using the + ``extern inline`` extension in GNU C90. In C++, emit any and all + inline functions into the object file. + +.. option:: -fkeep-static-functions + + Emit ``static`` functions into the object file, even if the function + is never used. + +.. option:: -fkeep-static-consts + + Emit variables declared ``static const`` when optimization isn't turned + on, even if the variables aren't referenced. + + GCC enables this option by default. If you want to force the compiler to + check if a variable is referenced, regardless of whether or not + optimization is turned on, use the :option:`-fno-keep-static-consts` option. + +.. option:: -fmerge-constants + + Attempt to merge identical constants (string constants and floating-point + constants) across compilation units. + + This option is the default for optimized compilation if the assembler and + linker support it. Use :option:`-fno-merge-constants` to inhibit this + behavior. + + Enabled at levels :option:`-O1`, :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fmerge-all-constants + + Attempt to merge identical constants and identical variables. + + This option implies :option:`-fmerge-constants`. In addition to + :option:`-fmerge-constants` this considers e.g. even constant initialized + arrays or initialized constant variables with integral or floating-point + types. Languages like C or C++ require each variable, including multiple + instances of the same variable in recursive calls, to have distinct locations, + so using this option results in non-conforming + behavior. + +.. option:: -fmodulo-sched + + Perform swing modulo scheduling immediately before the first scheduling + pass. This pass looks at innermost loops and reorders their + instructions by overlapping different iterations. + +.. option:: -fmodulo-sched-allow-regmoves + + Perform more aggressive SMS-based modulo scheduling with register moves + allowed. By setting this flag certain anti-dependences edges are + deleted, which triggers the generation of reg-moves based on the + life-range analysis. This option is effective only with + :option:`-fmodulo-sched` enabled. + +.. option:: -fno-branch-count-reg + + Disable the optimization pass that scans for opportunities to use + 'decrement and branch' instructions on a count register instead of + instruction sequences that decrement a register, compare it against zero, and + then branch based upon the result. This option is only meaningful on + architectures that support such instructions, which include x86, PowerPC, + IA-64 and S/390. Note that the :option:`-fno-branch-count-reg` option + doesn't remove the decrement and branch instructions from the generated + instruction stream introduced by other optimization passes. + + The default is :option:`-fbranch-count-reg` at :option:`-O1` and higher, + except for :option:`-Og`. + +.. option:: -fbranch-count-reg + + Default setting; overrides :option:`-fno-branch-count-reg`. + +.. option:: -fno-function-cse + + Do not put function addresses in registers; make each instruction that + calls a constant function contain the function's address explicitly. + + This option results in less efficient code, but some strange hacks + that alter the assembler output may be confused by the optimizations + performed when this option is not used. + + The default is :option:`-ffunction-cse` + +.. option:: -ffunction-cse + + Default setting; overrides :option:`-fno-function-cse`. + +.. option:: -fno-zero-initialized-in-bss + + If the target supports a BSS section, GCC by default puts variables that + are initialized to zero into BSS. This can save space in the resulting + code. + + This option turns off this behavior because some programs explicitly + rely on variables going to the data section---e.g., so that the + resulting executable can find the beginning of that section and/or make + assumptions based on that. + + The default is :option:`-fzero-initialized-in-bss`. + +.. option:: -fzero-initialized-in-bss + + Default setting; overrides :option:`-fno-zero-initialized-in-bss`. + +.. option:: -fthread-jumps + + Perform optimizations that check to see if a jump branches to a + location where another comparison subsumed by the first is found. If + so, the first branch is redirected to either the destination of the + second branch or a point immediately following it, depending on whether + the condition is known to be true or false. + + Enabled at levels :option:`-O1`, :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fsplit-wide-types + + When using a type that occupies multiple registers, such as ``long + long`` on a 32-bit system, split the registers apart and allocate them + independently. This normally generates better code for those types, + but may make debugging more difficult. + + Enabled at levels :option:`-O1`, :option:`-O2`, :option:`-O3`, + :option:`-Os`. + +.. option:: -fsplit-wide-types-early + + Fully split wide types early, instead of very late. + This option has no effect unless :option:`-fsplit-wide-types` is turned on. + + This is the default on some targets. + +.. option:: -fcse-follow-jumps + + In common subexpression elimination (CSE), scan through jump instructions + when the target of the jump is not reached by any other path. For + example, when CSE encounters an ``if`` statement with an + ``else`` clause, CSE follows the jump when the condition + tested is false. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fcse-skip-blocks + + This is similar to :option:`-fcse-follow-jumps`, but causes CSE to + follow jumps that conditionally skip over blocks. When CSE + encounters a simple ``if`` statement with no else clause, + :option:`-fcse-skip-blocks` causes CSE to follow the jump around the + body of the ``if``. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -frerun-cse-after-loop + + Re-run common subexpression elimination after loop optimizations are + performed. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fgcse + + Perform a global common subexpression elimination pass. + This pass also performs global constant and copy propagation. + + .. note:: + + When compiling a program using computed gotos, a GCC + extension, you may get better run-time performance if you disable + the global common subexpression elimination pass by adding + :option:`-fno-gcse` to the command line. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fgcse-lm + + When :option:`-fgcse-lm` is enabled, global common subexpression elimination + attempts to move loads that are only killed by stores into themselves. This + allows a loop containing a load/store sequence to be changed to a load outside + the loop, and a copy/store within the loop. + + Enabled by default when :option:`-fgcse` is enabled. + +.. option:: -fgcse-sm + + When :option:`-fgcse-sm` is enabled, a store motion pass is run after + global common subexpression elimination. This pass attempts to move + stores out of loops. When used in conjunction with :option:`-fgcse-lm`, + loops containing a load/store sequence can be changed to a load before + the loop and a store after the loop. + + Not enabled at any optimization level. + +.. option:: -fgcse-las + + When :option:`-fgcse-las` is enabled, the global common subexpression + elimination pass eliminates redundant loads that come after stores to the + same memory location (both partial and full redundancies). + + Not enabled at any optimization level. + +.. option:: -fgcse-after-reload + + When :option:`-fgcse-after-reload` is enabled, a redundant load elimination + pass is performed after reload. The purpose of this pass is to clean up + redundant spilling. + + Enabled by :option:`-O3`, :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -faggressive-loop-optimizations + + This option tells the loop optimizer to use language constraints to + derive bounds for the number of iterations of a loop. This assumes that + loop code does not invoke undefined behavior by for example causing signed + integer overflows or out-of-bound array accesses. The bounds for the + number of iterations of a loop are used to guide loop unrolling and peeling + and loop exit test optimizations. + This option is enabled by default. + +.. option:: -funconstrained-commons + + This option tells the compiler that variables declared in common blocks + (e.g. Fortran) may later be overridden with longer trailing arrays. This + prevents certain optimizations that depend on knowing the array bounds. + +.. option:: -fcrossjumping + + Perform cross-jumping transformation. + This transformation unifies equivalent code and saves code size. The + resulting code may or may not perform better than without cross-jumping. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fauto-inc-dec + + Combine increments or decrements of addresses with memory accesses. + This pass is always skipped on architectures that do not have + instructions to support this. Enabled by default at :option:`-O1` and + higher on architectures that support this. + +.. option:: -fdce + + Perform dead code elimination (DCE) on RTL. + Enabled by default at :option:`-O1` and higher. + +.. option:: -fdse + + Perform dead store elimination (DSE) on RTL. + Enabled by default at :option:`-O1` and higher. + +.. option:: -fif-conversion + + Attempt to transform conditional jumps into branch-less equivalents. This + includes use of conditional moves, min, max, set flags and abs instructions, and + some tricks doable by standard arithmetics. The use of conditional execution + on chips where it is available is controlled by :option:`-fif-conversion2`. + + Enabled at levels :option:`-O1`, :option:`-O2`, :option:`-O3`, :option:`-Os`, but + not with :option:`-Og`. + +.. option:: -fif-conversion2 + + Use conditional execution (where available) to transform conditional jumps into + branch-less equivalents. + + Enabled at levels :option:`-O1`, :option:`-O2`, :option:`-O3`, :option:`-Os`, but + not with :option:`-Og`. + +.. option:: -fdeclone-ctor-dtor + + The C++ ABI requires multiple entry points for constructors and + destructors: one for a base subobject, one for a complete object, and + one for a virtual destructor that calls operator delete afterwards. + For a hierarchy with virtual bases, the base and complete variants are + clones, which means two copies of the function. With this option, the + base and complete variants are changed to be thunks that call a common + implementation. + + Enabled by :option:`-Os`. + +.. option:: -fdelete-null-pointer-checks + + Assume that programs cannot safely dereference null pointers, and that + no code or data element resides at address zero. + This option enables simple constant + folding optimizations at all optimization levels. In addition, other + optimization passes in GCC use this flag to control global dataflow + analyses that eliminate useless checks for null pointers; these assume + that a memory access to address zero always results in a trap, so + that if a pointer is checked after it has already been dereferenced, + it cannot be null. + + Note however that in some environments this assumption is not true. + Use :option:`-fno-delete-null-pointer-checks` to disable this optimization + for programs that depend on that behavior. + + This option is enabled by default on most targets. On Nios II ELF, it + defaults to off. On AVR and MSP430, this option is completely disabled. + + Passes that use the dataflow information + are enabled independently at different optimization levels. + +.. option:: -fdevirtualize + + Attempt to convert calls to virtual functions to direct calls. This + is done both within a procedure and interprocedurally as part of + indirect inlining (:option:`-findirect-inlining`) and interprocedural constant + propagation (:option:`-fipa-cp`). + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fdevirtualize-speculatively + + Attempt to convert calls to virtual functions to speculative direct calls. + Based on the analysis of the type inheritance graph, determine for a given call + the set of likely targets. If the set is small, preferably of size 1, change + the call into a conditional deciding between direct and indirect calls. The + speculative calls enable more optimizations, such as inlining. When they seem + useless after further optimization, they are converted back into original form. + +.. option:: -fdevirtualize-at-ltrans + + Stream extra information needed for aggressive devirtualization when running + the link-time optimizer in local transformation mode. + This option enables more devirtualization but + significantly increases the size of streamed data. For this reason it is + disabled by default. + +.. option:: -fexpensive-optimizations + + Perform a number of minor optimizations that are relatively expensive. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -free + + Attempt to remove redundant extension instructions. This is especially + helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit + registers after writing to their lower 32-bit half. + + Enabled for Alpha, AArch64 and x86 at levels :option:`-O2`, + :option:`-O3`, :option:`-Os`. + +.. option:: -fno-lifetime-dse + + In C++ the value of an object is only affected by changes within its + lifetime: when the constructor begins, the object has an indeterminate + value, and any changes during the lifetime of the object are dead when + the object is destroyed. Normally dead store elimination will take + advantage of this; if your code relies on the value of the object + storage persisting beyond the lifetime of the object, you can use this + flag to disable this optimization. To preserve stores before the + constructor starts (e.g. because your operator new clears the object + storage) but still treat the object as dead after the destructor, you + can use :option:`-flifetime-dse=1`. The default behavior can be + explicitly selected with :option:`-flifetime-dse=2`. + :option:`-flifetime-dse=0` is equivalent to :option:`-fno-lifetime-dse`. + +.. option:: -flifetime-dse + + Default setting; overrides :option:`-fno-lifetime-dse`. + +.. option:: -flive-range-shrinkage + + Attempt to decrease register pressure through register live range + shrinkage. This is helpful for fast processors with small or moderate + size register sets. + +.. option:: -fira-algorithm={algorithm} + + Use the specified coloring algorithm for the integrated register + allocator. The :samp:`{algorithm}` argument can be :samp:`priority`, which + specifies Chow's priority coloring, or :samp:`CB`, which specifies + Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented + for all architectures, but for those targets that do support it, it is + the default because it generates better code. + +.. option:: -fira-region={region} + + Use specified regions for the integrated register allocator. The + :samp:`{region}` argument should be one of the following: + + :samp:`all` + Use all loops as register allocation regions. + This can give the best results for machines with a small and/or + irregular register set. + + :samp:`mixed` + Use all loops except for loops with small register pressure + as the regions. This value usually gives + the best results in most cases and for most architectures, + and is enabled by default when compiling with optimization for speed + (:option:`-O`, :option:`-O2`, ...). + + :samp:`one` + Use all functions as a single region. + This typically results in the smallest code size, and is enabled by default for + :option:`-Os` or :option:`-O0`. + +.. option:: -fira-hoist-pressure + + Use IRA to evaluate register pressure in the code hoisting pass for + decisions to hoist expressions. This option usually results in smaller + code, but it can slow the compiler down. + + This option is enabled at level :option:`-Os` for all targets. + +.. option:: -fira-loop-pressure + + Use IRA to evaluate register pressure in loops for decisions to move + loop invariants. This option usually results in generation + of faster and smaller code on machines with large register files (>= 32 + registers), but it can slow the compiler down. + + This option is enabled at level :option:`-O3` for some targets. + +.. option:: -fno-ira-share-save-slots + + Disable sharing of stack slots used for saving call-used hard + registers living through a call. Each hard register gets a + separate stack slot, and as a result function stack frames are + larger. + +.. option:: -fira-share-save-slots + + Default setting; overrides :option:`-fno-ira-share-save-slots`. + +.. option:: -fno-ira-share-spill-slots + + Disable sharing of stack slots allocated for pseudo-registers. Each + pseudo-register that does not get a hard register gets a separate + stack slot, and as a result function stack frames are larger. + +.. option:: -fira-share-spill-slots + + Default setting; overrides :option:`-fno-ira-share-spill-slots`. + +.. option:: -flra-remat + + Enable CFG-sensitive rematerialization in LRA. Instead of loading + values of spilled pseudos, LRA tries to rematerialize (recalculate) + values if it is profitable. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fdelayed-branch + + If supported for the target machine, attempt to reorder instructions + to exploit instruction slots available after delayed branch + instructions. + + Enabled at levels :option:`-O1`, :option:`-O2`, :option:`-O3`, :option:`-Os`, + but not at :option:`-Og`. + +.. option:: -fschedule-insns + + If supported for the target machine, attempt to reorder instructions to + eliminate execution stalls due to required data being unavailable. This + helps machines that have slow floating point or memory load instructions + by allowing other instructions to be issued until the result of the load + or floating-point instruction is required. + + Enabled at levels :option:`-O2`, :option:`-O3`. + +.. option:: -fschedule-insns2 + + Similar to :option:`-fschedule-insns`, but requests an additional pass of + instruction scheduling after register allocation has been done. This is + especially useful on machines with a relatively small number of + registers and where memory load instructions take more than one cycle. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fno-sched-interblock + + Disable instruction scheduling across basic blocks, which + is normally enabled when scheduling before register allocation, i.e. + with :option:`-fschedule-insns` or at :option:`-O2` or higher. + +.. option:: -fsched-interblock + + Default setting; overrides :option:`-fno-sched-interblock`. + +.. option:: -fno-sched-spec + + Disable speculative motion of non-load instructions, which + is normally enabled when scheduling before register allocation, i.e. + with :option:`-fschedule-insns` or at :option:`-O2` or higher. + +.. option:: -fsched-spec + + Default setting; overrides :option:`-fno-sched-spec`. + +.. option:: -fsched-pressure + + Enable register pressure sensitive insn scheduling before register + allocation. This only makes sense when scheduling before register + allocation is enabled, i.e. with :option:`-fschedule-insns` or at + :option:`-O2` or higher. Usage of this option can improve the + generated code and decrease its size by preventing register pressure + increase above the number of available hard registers and subsequent + spills in register allocation. + +.. option:: -fsched-spec-load + + Allow speculative motion of some load instructions. This only makes + sense when scheduling before register allocation, i.e. with + :option:`-fschedule-insns` or at :option:`-O2` or higher. + +.. option:: -fsched-spec-load-dangerous + + Allow speculative motion of more load instructions. This only makes + sense when scheduling before register allocation, i.e. with + :option:`-fschedule-insns` or at :option:`-O2` or higher. + +.. option:: -fsched-stalled-insns, -fsched-stalled-insns={n} + + Define how many insns (if any) can be moved prematurely from the queue + of stalled insns into the ready list during the second scheduling pass. + :option:`-fno-sched-stalled-insns` means that no insns are moved + prematurely, :option:`-fsched-stalled-insns=0` means there is no limit + on how many queued insns can be moved prematurely. + :option:`-fsched-stalled-insns` without a value is equivalent to + :option:`-fsched-stalled-insns=1`. + +.. option:: -fsched-stalled-insns-dep, -fsched-stalled-insns-dep={n} + + Define how many insn groups (cycles) are examined for a dependency + on a stalled insn that is a candidate for premature removal from the queue + of stalled insns. This has an effect only during the second scheduling pass, + and only if :option:`-fsched-stalled-insns` is used. + :option:`-fno-sched-stalled-insns-dep` is equivalent to + :option:`-fsched-stalled-insns-dep=0`. + :option:`-fsched-stalled-insns-dep` without a value is equivalent to + :option:`-fsched-stalled-insns-dep=1`. + +.. option:: -fsched2-use-superblocks + + When scheduling after register allocation, use superblock scheduling. + This allows motion across basic block boundaries, + resulting in faster schedules. This option is experimental, as not all machine + descriptions used by GCC model the CPU closely enough to avoid unreliable + results from the algorithm. + + This only makes sense when scheduling after register allocation, i.e. with + :option:`-fschedule-insns2` or at :option:`-O2` or higher. + +.. option:: -fsched-group-heuristic + + Enable the group heuristic in the scheduler. This heuristic favors + the instruction that belongs to a schedule group. This is enabled + by default when scheduling is enabled, i.e. with :option:`-fschedule-insns` + or :option:`-fschedule-insns2` or at :option:`-O2` or higher. + +.. option:: -fsched-critical-path-heuristic + + Enable the critical-path heuristic in the scheduler. This heuristic favors + instructions on the critical path. This is enabled by default when + scheduling is enabled, i.e. with :option:`-fschedule-insns` + or :option:`-fschedule-insns2` or at :option:`-O2` or higher. + +.. option:: -fsched-spec-insn-heuristic + + Enable the speculative instruction heuristic in the scheduler. This + heuristic favors speculative instructions with greater dependency weakness. + This is enabled by default when scheduling is enabled, i.e. + with :option:`-fschedule-insns` or :option:`-fschedule-insns2` + or at :option:`-O2` or higher. + +.. option:: -fsched-rank-heuristic + + Enable the rank heuristic in the scheduler. This heuristic favors + the instruction belonging to a basic block with greater size or frequency. + This is enabled by default when scheduling is enabled, i.e. + with :option:`-fschedule-insns` or :option:`-fschedule-insns2` or + at :option:`-O2` or higher. + +.. option:: -fsched-last-insn-heuristic + + Enable the last-instruction heuristic in the scheduler. This heuristic + favors the instruction that is less dependent on the last instruction + scheduled. This is enabled by default when scheduling is enabled, + i.e. with :option:`-fschedule-insns` or :option:`-fschedule-insns2` or + at :option:`-O2` or higher. + +.. option:: -fsched-dep-count-heuristic + + Enable the dependent-count heuristic in the scheduler. This heuristic + favors the instruction that has more instructions depending on it. + This is enabled by default when scheduling is enabled, i.e. + with :option:`-fschedule-insns` or :option:`-fschedule-insns2` or + at :option:`-O2` or higher. + +.. option:: -freschedule-modulo-scheduled-loops + + Modulo scheduling is performed before traditional scheduling. If a loop + is modulo scheduled, later scheduling passes may change its schedule. + Use this option to control that behavior. + +.. option:: -fselective-scheduling + + Schedule instructions using selective scheduling algorithm. Selective + scheduling runs instead of the first scheduler pass. + +.. option:: -fselective-scheduling2 + + Schedule instructions using selective scheduling algorithm. Selective + scheduling runs instead of the second scheduler pass. + +.. option:: -fsel-sched-pipelining + + Enable software pipelining of innermost loops during selective scheduling. + This option has no effect unless one of :option:`-fselective-scheduling` or + :option:`-fselective-scheduling2` is turned on. + +.. option:: -fsel-sched-pipelining-outer-loops + + When pipelining loops during selective scheduling, also pipeline outer loops. + This option has no effect unless :option:`-fsel-sched-pipelining` is turned on. + +.. option:: -fsemantic-interposition + + Some object formats, like ELF, allow interposing of symbols by the + dynamic linker. + This means that for symbols exported from the DSO, the compiler cannot perform + interprocedural propagation, inlining and other optimizations in anticipation + that the function or variable in question may change. While this feature is + useful, for example, to rewrite memory allocation functions by a debugging + implementation, it is expensive in the terms of code quality. + With :option:`-fno-semantic-interposition` the compiler assumes that + if interposition happens for functions the overwriting function will have + precisely the same semantics (and side effects). + Similarly if interposition happens + for variables, the constructor of the variable will be the same. The flag + has no effect for functions explicitly declared inline + (where it is never allowed for interposition to change semantics) + and for symbols explicitly declared weak. + +.. option:: -fshrink-wrap + + Emit function prologues only before parts of the function that need it, + rather than at the top of the function. This flag is enabled by default at + :option:`-O` and higher. + +.. option:: -fshrink-wrap-separate + + Shrink-wrap separate parts of the prologue and epilogue separately, so that + those parts are only executed when needed. + This option is on by default, but has no effect unless :option:`-fshrink-wrap` + is also turned on and the target supports this. + +.. option:: -fcaller-saves + + Enable allocation of values to registers that are clobbered by + function calls, by emitting extra instructions to save and restore the + registers around such calls. Such allocation is done only when it + seems to result in better code. + + This option is always enabled by default on certain machines, usually + those which have no call-preserved registers to use instead. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fcombine-stack-adjustments + + Tracks stack adjustments (pushes and pops) and stack memory references + and then tries to find ways to combine them. + + Enabled by default at :option:`-O1` and higher. + +.. option:: -fipa-ra + + Use caller save registers for allocation if those registers are not used by + any called function. In that case it is not necessary to save and restore + them around calls. This is only possible if called functions are part of + same compilation unit as current function and they are compiled before it. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`, however the option + is disabled if generated code will be instrumented for profiling + (:option:`-p`, or :option:`-pg`) or if callee's register usage cannot be known + exactly (this happens on targets that do not expose prologues + and epilogues in RTL). + +.. option:: -fconserve-stack + + Attempt to minimize stack usage. The compiler attempts to use less + stack space, even if that makes the program slower. This option + implies setting the large-stack-frame parameter to 100 + and the large-stack-frame-growth parameter to 400. + +.. option:: -ftree-reassoc + + Perform reassociation on trees. This flag is enabled by default + at :option:`-O1` and higher. + +.. option:: -fcode-hoisting + + Perform code hoisting. Code hoisting tries to move the + evaluation of expressions executed on all paths to the function exit + as early as possible. This is especially useful as a code size + optimization, but it often helps for code speed as well. + This flag is enabled by default at :option:`-O2` and higher. + +.. option:: -ftree-pre + + Perform partial redundancy elimination (PRE) on trees. This flag is + enabled by default at :option:`-O2` and :option:`-O3`. + +.. option:: -ftree-partial-pre + + Make partial redundancy elimination (PRE) more aggressive. This flag is + enabled by default at :option:`-O3`. + +.. option:: -ftree-forwprop + + Perform forward propagation on trees. This flag is enabled by default + at :option:`-O1` and higher. + +.. option:: -ftree-fre + + Perform full redundancy elimination (FRE) on trees. The difference + between FRE and PRE is that FRE only considers expressions + that are computed on all paths leading to the redundant computation. + This analysis is faster than PRE, though it exposes fewer redundancies. + This flag is enabled by default at :option:`-O1` and higher. + +.. option:: -ftree-phiprop + + Perform hoisting of loads from conditional pointers on trees. This + pass is enabled by default at :option:`-O1` and higher. + +.. option:: -fhoist-adjacent-loads + + Speculatively hoist loads from both branches of an if-then-else if the + loads are from adjacent locations in the same structure and the target + architecture has a conditional move instruction. This flag is enabled + by default at :option:`-O2` and higher. + +.. option:: -ftree-copy-prop + + Perform copy propagation on trees. This pass eliminates unnecessary + copy operations. This flag is enabled by default at :option:`-O1` and + higher. + +.. option:: -fipa-pure-const + + Discover which functions are pure or constant. + Enabled by default at :option:`-O1` and higher. + +.. option:: -fipa-reference + + Discover which static variables do not escape the + compilation unit. + Enabled by default at :option:`-O1` and higher. + +.. option:: -fipa-reference-addressable + + Discover read-only, write-only and non-addressable static variables. + Enabled by default at :option:`-O1` and higher. + +.. option:: -fipa-stack-alignment + + Reduce stack alignment on call sites if possible. + Enabled by default. + +.. option:: -fipa-pta + + Perform interprocedural pointer analysis and interprocedural modification + and reference analysis. This option can cause excessive memory and + compile-time usage on large compilation units. It is not enabled by + default at any optimization level. + +.. option:: -fipa-profile + + Perform interprocedural profile propagation. The functions called only from + cold functions are marked as cold. Also functions executed once (such as + :fn-attr:`cold`, :fn-attr:`noreturn`, static constructors or destructors) are + identified. Cold functions and loop less parts of functions executed once are + then optimized for size. + Enabled by default at :option:`-O1` and higher. + +.. option:: -fipa-modref + + Perform interprocedural mod/ref analysis. This optimization analyzes the side + effects of functions (memory locations that are modified or referenced) and + enables better optimization across the function call boundary. This flag is + enabled by default at :option:`-O1` and higher. + +.. option:: -fipa-cp + + Perform interprocedural constant propagation. + This optimization analyzes the program to determine when values passed + to functions are constants and then optimizes accordingly. + This optimization can substantially increase performance + if the application has constants passed to functions. + This flag is enabled by default at :option:`-O2`, :option:`-Os` and :option:`-O3`. + It is also enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -fipa-cp-clone + + Perform function cloning to make interprocedural constant propagation stronger. + When enabled, interprocedural constant propagation performs function cloning + when externally visible function can be called with constant arguments. + Because this optimization can create multiple copies of functions, + it may significantly increase code size + (see :option:`--param ipa-cp-unit-growth=value`). + This flag is enabled by default at :option:`-O3`. + It is also enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -fipa-bit-cp + + When enabled, perform interprocedural bitwise constant + propagation. This flag is enabled by default at :option:`-O2` and + by :option:`-fprofile-use` and :option:`-fauto-profile`. + It requires that :option:`-fipa-cp` is enabled. + +.. option:: -fipa-vrp + + When enabled, perform interprocedural propagation of value + ranges. This flag is enabled by default at :option:`-O2`. It requires + that :option:`-fipa-cp` is enabled. + +.. option:: -fipa-icf + + Perform Identical Code Folding for functions and read-only variables. + The optimization reduces code size and may disturb unwind stacks by replacing + a function by equivalent one with a different name. The optimization works + more effectively with link-time optimization enabled. + + Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF + works on different levels and thus the optimizations are not same - there are + equivalences that are found only by GCC and equivalences found only by Gold. + + This flag is enabled by default at :option:`-O2` and :option:`-Os`. + +.. option:: -flive-patching={level} + + Control GCC's optimizations to produce output suitable for live-patching. + + If the compiler's optimization uses a function's body or information extracted + from its body to optimize/change another function, the latter is called an + impacted function of the former. If a function is patched, its impacted + functions should be patched too. + + The impacted functions are determined by the compiler's interprocedural + optimizations. For example, a caller is impacted when inlining a function + into its caller, + cloning a function and changing its caller to call this new clone, + or extracting a function's pureness/constness information to optimize + its direct or indirect callers, etc. + + Usually, the more IPA optimizations enabled, the larger the number of + impacted functions for each function. In order to control the number of + impacted functions and more easily compute the list of impacted function, + IPA optimizations can be partially enabled at two different levels. + + The :samp:`{level}` argument should be one of the following: + + :samp:`inline-clone` + Only enable inlining and cloning optimizations, which includes inlining, + cloning, interprocedural scalar replacement of aggregates and partial inlining. + As a result, when patching a function, all its callers and its clones' + callers are impacted, therefore need to be patched as well. + + :option:`-flive-patching=inline-clone` disables the following optimization flags: + + :option:`-fwhole-program` :option:`-fipa-pta` :option:`-fipa-reference` :option:`-fipa-ra` |gol| + :option:`-fipa-icf` :option:`-fipa-icf-functions` :option:`-fipa-icf-variables` |gol| + :option:`-fipa-bit-cp` :option:`-fipa-vrp` :option:`-fipa-pure-const` :option:`-fipa-reference-addressable` |gol| + :option:`-fipa-stack-alignment` :option:`-fipa-modref` + + :samp:`inline-only-static` + Only enable inlining of static functions. + As a result, when patching a static function, all its callers are impacted + and so need to be patched as well. + + In addition to all the flags that :option:`-flive-patching=inline-clone` + disables, + :option:`-flive-patching=inline-only-static` disables the following additional + optimization flags: + + :option:`-fipa-cp-clone` :option:`-fipa-sra` :option:`-fpartial-inlining` :option:`-fipa-cp` + + When :option:`-flive-patching` is specified without any value, the default value + is :samp:`{inline-clone}`. + + This flag is disabled by default. + + Note that :option:`-flive-patching` is not supported with link-time optimization + (:option:`-flto`). + +.. option:: -fisolate-erroneous-paths-dereference + + Detect paths that trigger erroneous or undefined behavior due to + dereferencing a null pointer. Isolate those paths from the main control + flow and turn the statement with erroneous or undefined behavior into a trap. + This flag is enabled by default at :option:`-O2` and higher and depends on + :option:`-fdelete-null-pointer-checks` also being enabled. + +.. option:: -fisolate-erroneous-paths-attribute + + Detect paths that trigger erroneous or undefined behavior due to a null value + being used in a way forbidden by a :fn-attr:`returns_nonnull` or :fn-attr:`nonnull` + attribute. Isolate those paths from the main control flow and turn the + statement with erroneous or undefined behavior into a trap. This is not + currently enabled, but may be enabled by :option:`-O2` in the future. + +.. option:: -ftree-sink + + Perform forward store motion on trees. This flag is + enabled by default at :option:`-O1` and higher. + +.. option:: -ftree-bit-ccp + + Perform sparse conditional bit constant propagation on trees and propagate + pointer alignment information. + This pass only operates on local scalar variables and is enabled by default + at :option:`-O1` and higher, except for :option:`-Og`. + It requires that :option:`-ftree-ccp` is enabled. + +.. option:: -ftree-ccp + + Perform sparse conditional constant propagation (CCP) on trees. This + pass only operates on local scalar variables and is enabled by default + at :option:`-O1` and higher. + +.. option:: -fssa-backprop + + Propagate information about uses of a value up the definition chain + in order to simplify the definitions. For example, this pass strips + sign operations if the sign of a value never matters. The flag is + enabled by default at :option:`-O1` and higher. + +.. option:: -fssa-phiopt + + Perform pattern matching on SSA PHI nodes to optimize conditional + code. This pass is enabled by default at :option:`-O1` and higher, + except for :option:`-Og`. + +.. option:: -ftree-switch-conversion + + Perform conversion of simple initializations in a switch to + initializations from a scalar array. This flag is enabled by default + at :option:`-O2` and higher. + +.. option:: -ftree-tail-merge + + Look for identical code sequences. When found, replace one with a jump to the + other. This optimization is known as tail merging or cross jumping. This flag + is enabled by default at :option:`-O2` and higher. The compilation time + in this pass can + be limited using max-tail-merge-comparisons parameter and + max-tail-merge-iterations parameter. + +.. option:: -ftree-dce + + Perform dead code elimination (DCE) on trees. This flag is enabled by + default at :option:`-O1` and higher. + +.. option:: -ftree-builtin-call-dce + + Perform conditional dead code elimination (DCE) for calls to built-in functions + that may set ``errno`` but are otherwise free of side effects. This flag is + enabled by default at :option:`-O2` and higher if :option:`-Os` is not also + specified. + +.. option:: -ffinite-loops + + Assume that a loop with an exit will eventually take the exit and not loop + indefinitely. This allows the compiler to remove loops that otherwise have + no side-effects, not considering eventual endless looping as such. + + This option is enabled by default at :option:`-O2` for C++ with -std=c++11 + or higher. + +.. option:: -fno-finite-loops + + Default setting; overrides :option:`-ffinite-loops`. + +.. option:: -ftree-dominator-opts + + Perform a variety of simple scalar cleanups (constant/copy + propagation, redundancy elimination, range propagation and expression + simplification) based on a dominator tree traversal. This also + performs jump threading (to reduce jumps to jumps). This flag is + enabled by default at :option:`-O1` and higher. + +.. option:: -ftree-dse + + Perform dead store elimination (DSE) on trees. A dead store is a store into + a memory location that is later overwritten by another store without + any intervening loads. In this case the earlier store can be deleted. This + flag is enabled by default at :option:`-O1` and higher. + +.. option:: -ftree-ch + + Perform loop header copying on trees. This is beneficial since it increases + effectiveness of code motion optimizations. It also saves one jump. This flag + is enabled by default at :option:`-O1` and higher. It is not enabled + for :option:`-Os`, since it usually increases code size. + +.. option:: -ftree-loop-optimize + + Perform loop optimizations on trees. This flag is enabled by default + at :option:`-O1` and higher. + +.. option:: -ftree-loop-linear, -floop-strip-mine, -floop-block + + Perform loop nest optimizations. Same as + :option:`-floop-nest-optimize`. To use this code transformation, GCC has + to be configured with :option:`--with-isl` to enable the Graphite loop + transformation infrastructure. + +.. option:: -fgraphite-identity + + Enable the identity transformation for graphite. For every SCoP we generate + the polyhedral representation and transform it back to gimple. Using + :option:`-fgraphite-identity` we can check the costs or benefits of the + GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations + are also performed by the code generator isl, like index splitting and + dead code elimination in loops. + +.. option:: -floop-nest-optimize + + Enable the isl based loop nest optimizer. This is a generic loop nest + optimizer based on the Pluto optimization algorithms. It calculates a loop + structure optimized for data-locality and parallelism. This option + is experimental. + +.. option:: -floop-parallelize-all + + Use the Graphite data dependence analysis to identify loops that can + be parallelized. Parallelize all the loops that can be analyzed to + not contain loop carried dependences without checking that it is + profitable to parallelize the loops. + +.. option:: -ftree-coalesce-vars + + While transforming the program out of the SSA representation, attempt to + reduce copying by coalescing versions of different user-defined + variables, instead of just compiler temporaries. This may severely + limit the ability to debug an optimized program compiled with + :option:`-fno-var-tracking-assignments`. In the negated form, this flag + prevents SSA coalescing of user variables. This option is enabled by + default if optimization is enabled, and it does very little otherwise. + +.. option:: -ftree-loop-if-convert + + Attempt to transform conditional jumps in the innermost loops to + branch-less equivalents. The intent is to remove control-flow from + the innermost loops in order to improve the ability of the + vectorization pass to handle these loops. This is enabled by default + if vectorization is enabled. + +.. option:: -ftree-loop-distribution + + Perform loop distribution. This flag can improve cache performance on + big loop bodies and allow further loop optimizations, like + parallelization or vectorization, to take place. For example, the loop + + .. code-block:: fortran + + DO I = 1, N + A(I) = B(I) + C + D(I) = E(I) * F + ENDDO + + is transformed to + + .. code-block:: fortran + + DO I = 1, N + A(I) = B(I) + C + ENDDO + DO I = 1, N + D(I) = E(I) * F + ENDDO + + This flag is enabled by default at :option:`-O3`. + It is also enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -ftree-loop-distribute-patterns + + Perform loop distribution of patterns that can be code generated with + calls to a library. This flag is enabled by default at :option:`-O2` and + higher, and by :option:`-fprofile-use` and :option:`-fauto-profile`. + + This pass distributes the initialization loops and generates a call to + memset zero. For example, the loop + + .. code-block:: fortran + + DO I = 1, N + A(I) = 0 + B(I) = A(I) + I + ENDDO + + is transformed to + + .. code-block:: fortran + + DO I = 1, N + A(I) = 0 + ENDDO + DO I = 1, N + B(I) = A(I) + I + ENDDO + + and the initialization loop is transformed into a call to memset zero. + This flag is enabled by default at :option:`-O3`. + It is also enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -floop-interchange + + Perform loop interchange outside of graphite. This flag can improve cache + performance on loop nest and allow further loop optimizations, like + vectorization, to take place. For example, the loop + + .. code-block:: c++ + + for (int i = 0; i < N; i++) + for (int j = 0; j < N; j++) + for (int k = 0; k < N; k++) + c[i][j] = c[i][j] + a[i][k]*b[k][j]; + + is transformed to + + .. code-block:: c++ + + for (int i = 0; i < N; i++) + for (int k = 0; k < N; k++) + for (int j = 0; j < N; j++) + c[i][j] = c[i][j] + a[i][k]*b[k][j]; + + This flag is enabled by default at :option:`-O3`. + It is also enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -floop-unroll-and-jam + + Apply unroll and jam transformations on feasible loops. In a loop + nest this unrolls the outer loop by some factor and fuses the resulting + multiple inner loops. This flag is enabled by default at :option:`-O3`. + It is also enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -ftree-loop-im + + Perform loop invariant motion on trees. This pass moves only invariants that + are hard to handle at RTL level (function calls, operations that expand to + nontrivial sequences of insns). With :option:`-funswitch-loops` it also moves + operands of conditions that are invariant out of the loop, so that we can use + just trivial invariantness analysis in loop unswitching. The pass also includes + store motion. + +.. option:: -ftree-loop-ivcanon + + Create a canonical counter for number of iterations in loops for which + determining number of iterations requires complicated analysis. Later + optimizations then may determine the number easily. Useful especially + in connection with unrolling. + +.. option:: -ftree-scev-cprop + + Perform final value replacement. If a variable is modified in a loop + in such a way that its value when exiting the loop can be determined using + only its initial value and the number of loop iterations, replace uses of + the final value by such a computation, provided it is sufficiently cheap. + This reduces data dependencies and may allow further simplifications. + Enabled by default at :option:`-O1` and higher. + +.. option:: -fivopts + + Perform induction variable optimizations (strength reduction, induction + variable merging and induction variable elimination) on trees. + +.. option:: -ftree-parallelize-loops=n + + Parallelize loops, i.e., split their iteration space to run in n threads. + This is only possible for loops whose iterations are independent + and can be arbitrarily reordered. The optimization is only + profitable on multiprocessor machines, for loops that are CPU-intensive, + rather than constrained e.g. by memory bandwidth. This option + implies :option:`-pthread`, and thus is only supported on targets + that have support for :option:`-pthread`. + +.. option:: -ftree-pta + + Perform function-local points-to analysis on trees. This flag is + enabled by default at :option:`-O1` and higher, except for :option:`-Og`. + +.. option:: -ftree-sra + + Perform scalar replacement of aggregates. This pass replaces structure + references with scalars to prevent committing structures to memory too + early. This flag is enabled by default at :option:`-O1` and higher, + except for :option:`-Og`. + +.. option:: -fstore-merging + + Perform merging of narrow stores to consecutive memory addresses. This pass + merges contiguous stores of immediate values narrower than a word into fewer + wider stores to reduce the number of instructions. This is enabled by default + at :option:`-O2` and higher as well as :option:`-Os`. + +.. option:: -ftree-ter + + Perform temporary expression replacement during the SSA->normal phase. Single + use/single def temporaries are replaced at their use location with their + defining expression. This results in non-GIMPLE code, but gives the expanders + much more complex trees to work on resulting in better RTL generation. This is + enabled by default at :option:`-O1` and higher. + +.. option:: -ftree-slsr + + Perform straight-line strength reduction on trees. This recognizes related + expressions involving multiplications and replaces them by less expensive + calculations when possible. This is enabled by default at :option:`-O1` and + higher. + +.. option:: -ftree-vectorize + + Perform vectorization on trees. This flag enables :option:`-ftree-loop-vectorize` + and :option:`-ftree-slp-vectorize` if not explicitly specified. + +.. option:: -ftree-loop-vectorize + + Perform loop vectorization on trees. This flag is enabled by default at + :option:`-O2` and by :option:`-ftree-vectorize`, :option:`-fprofile-use`, + and :option:`-fauto-profile`. + +.. option:: -ftree-slp-vectorize + + Perform basic block vectorization on trees. This flag is enabled by default at + :option:`-O2` and by :option:`-ftree-vectorize`, :option:`-fprofile-use`, + and :option:`-fauto-profile`. + +.. option:: -ftrivial-auto-var-init={choice} + + Initialize automatic variables with either a pattern or with zeroes to increase + the security and predictability of a program by preventing uninitialized memory + disclosure and use. + GCC still considers an automatic variable that doesn't have an explicit + initializer as uninitialized, :option:`-Wuninitialized` and + :option:`-Wanalyzer-use-of-uninitialized-value` will still report + warning messages on such automatic variables. + With this option, GCC will also initialize any padding of automatic variables + that have structure or union types to zeroes. + However, the current implementation cannot initialize automatic variables that + are declared between the controlling expression and the first case of a + ``switch`` statement. Using :option:`-Wtrivial-auto-var-init` to report all + such cases. + + The three values of :samp:`{choice}` are: + + * :samp:`uninitialized` doesn't initialize any automatic variables. + This is C and C++'s default. + + * :samp:`pattern` Initialize automatic variables with values which will likely + transform logic bugs into crashes down the line, are easily recognized in a + crash dump and without being values that programmers can rely on for useful + program semantics. + The current value is byte-repeatable pattern with byte "0xFE". + The values used for pattern initialization might be changed in the future. + + * :samp:`zero` Initialize automatic variables with zeroes. + + The default is :samp:`uninitialized`. + + You can control this behavior for a specific variable by using the variable + attribute :var-attr:`uninitialized` (see :ref:`variable-attributes`). + +.. option:: -fvect-cost-model={model} + + Alter the cost model used for vectorization. The :samp:`{model}` argument + should be one of :samp:`unlimited`, :samp:`dynamic`, :samp:`cheap` or + :samp:`very-cheap`. + With the :samp:`unlimited` model the vectorized code-path is assumed + to be profitable while with the :samp:`dynamic` model a runtime check + guards the vectorized code-path to enable it only for iteration + counts that will likely execute faster than when executing the original + scalar loop. The :samp:`cheap` model disables vectorization of + loops where doing so would be cost prohibitive for example due to + required runtime checks for data dependence or alignment but otherwise + is equal to the :samp:`dynamic` model. The :samp:`very-cheap` model only + allows vectorization if the vector code would entirely replace the + scalar code that is being vectorized. For example, if each iteration + of a vectorized loop would only be able to handle exactly four iterations + of the scalar loop, the :samp:`very-cheap` model would only allow + vectorization if the scalar iteration count is known to be a multiple + of four. + + The default cost model depends on other optimization flags and is + either :samp:`dynamic` or :samp:`cheap`. + +.. option:: -fsimd-cost-model={model} + + Alter the cost model used for vectorization of loops marked with the OpenMP + simd directive. The :samp:`{model}` argument should be one of + :samp:`unlimited`, :samp:`dynamic`, :samp:`cheap`. All values of :samp:`{model}` + have the same meaning as described in :option:`-fvect-cost-model` and by + default a cost model defined with :option:`-fvect-cost-model` is used. + +.. option:: -ftree-vrp + + Perform Value Range Propagation on trees. This is similar to the + constant propagation pass, but instead of values, ranges of values are + propagated. This allows the optimizers to remove unnecessary range + checks like array bound checks and null pointer checks. This is + enabled by default at :option:`-O2` and higher. Null pointer check + elimination is only done if :option:`-fdelete-null-pointer-checks` is + enabled. + +.. option:: -fsplit-paths + + Split paths leading to loop backedges. This can improve dead code + elimination and common subexpression elimination. This is enabled by + default at :option:`-O3` and above. + +.. option:: -fsplit-ivs-in-unroller + + Enables expression of values of induction variables in later iterations + of the unrolled loop using the value in the first iteration. This breaks + long dependency chains, thus improving efficiency of the scheduling passes. + + A combination of :option:`-fweb` and CSE is often sufficient to obtain the + same effect. However, that is not reliable in cases where the loop body + is more complicated than a single basic block. It also does not work at all + on some architectures due to restrictions in the CSE pass. + + This optimization is enabled by default. + +.. option:: -fvariable-expansion-in-unroller + + With this option, the compiler creates multiple copies of some + local variables when unrolling a loop, which can result in superior code. + + This optimization is enabled by default for PowerPC targets, but disabled + by default otherwise. + +.. option:: -fpartial-inlining + + Inline parts of functions. This option has any effect only + when inlining itself is turned on by the :option:`-finline-functions` + or :option:`-finline-small-functions` options. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fpredictive-commoning + + Perform predictive commoning optimization, i.e., reusing computations + (especially memory loads and stores) performed in previous + iterations of loops. + + This option is enabled at level :option:`-O3`. + It is also enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -fprefetch-loop-arrays + + If supported by the target machine, generate instructions to prefetch + memory to improve the performance of loops that access large arrays. + + This option may generate better or worse code; results are highly + dependent on the structure of loops within the source code. + + Disabled at level :option:`-Os`. + +.. option:: -fno-printf-return-value + + Do not substitute constants for known return value of formatted output + functions such as ``sprintf``, ``snprintf``, ``vsprintf``, and + ``vsnprintf`` (but not ``printf`` of ``fprintf``). This + transformation allows GCC to optimize or even eliminate branches based + on the known return value of these functions called with arguments that + are either constant, or whose values are known to be in a range that + makes determining the exact return value possible. For example, when + :option:`-fprintf-return-value` is in effect, both the branch and the + body of the ``if`` statement (but not the call to ``snprint``) + can be optimized away when ``i`` is a 32-bit or smaller integer + because the return value is guaranteed to be at most 8. + + .. code-block:: c++ + + char buf[9]; + if (snprintf (buf, "%08x", i) >= sizeof buf) + ... + + The :option:`-fprintf-return-value` option relies on other optimizations + and yields best results with :option:`-O2` and above. It works in tandem + with the :option:`-Wformat-overflow` and :option:`-Wformat-truncation` + options. The :option:`-fprintf-return-value` option is enabled by default. + +.. option:: -fprintf-return-value + + Default setting; overrides :option:`-fno-printf-return-value`. + +.. option:: -fno-peephole, -fno-peephole2, -fpeephole, -fpeephole2 + + Disable any machine-specific peephole optimizations. The difference + between :option:`-fno-peephole` and :option:`-fno-peephole2` is in how they + are implemented in the compiler; some targets use one, some use the + other, a few use both. + + :option:`-fpeephole` is enabled by default. + :option:`-fpeephole2` enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fno-guess-branch-probability + + Do not guess branch probabilities using heuristics. + + GCC uses heuristics to guess branch probabilities if they are + not provided by profiling feedback (:option:`-fprofile-arcs`). These + heuristics are based on the control flow graph. If some branch probabilities + are specified by ``__builtin_expect``, then the heuristics are + used to guess branch probabilities for the rest of the control flow graph, + taking the ``__builtin_expect`` info into account. The interactions + between the heuristics and ``__builtin_expect`` can be complex, and in + some cases, it may be useful to disable the heuristics so that the effects + of ``__builtin_expect`` are easier to understand. + + It is also possible to specify expected probability of the expression + with ``__builtin_expect_with_probability`` built-in function. + + The default is :option:`-fguess-branch-probability` at levels + :option:`-O`, :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fguess-branch-probability + + Default setting; overrides :option:`-fno-guess-branch-probability`. + +.. option:: -freorder-blocks + + Reorder basic blocks in the compiled function in order to reduce number of + taken branches and improve code locality. + + Enabled at levels :option:`-O1`, :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -freorder-blocks-algorithm={algorithm} + + Use the specified algorithm for basic block reordering. The + :samp:`{algorithm}` argument can be :samp:`simple`, which does not increase + code size (except sometimes due to secondary effects like alignment), + or :samp:`stc`, the 'software trace cache' algorithm, which tries to + put all often executed code together, minimizing the number of branches + executed by making extra copies of code. + + The default is :samp:`simple` at levels :option:`-O1`, :option:`-Os`, and + :samp:`stc` at levels :option:`-O2`, :option:`-O3`. + +.. option:: -freorder-blocks-and-partition + + In addition to reordering basic blocks in the compiled function, in order + to reduce number of taken branches, partitions hot and cold basic blocks + into separate sections of the assembly and :samp:`.o` files, to improve + paging and cache locality performance. + + This optimization is automatically turned off in the presence of + exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined + section attribute and on any architecture that does not support named + sections. When :option:`-fsplit-stack` is used this option is not + enabled by default (to avoid linker errors), but may be enabled + explicitly (if using a working linker). + + Enabled for x86 at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -freorder-functions + + Reorder functions in the object file in order to + improve code locality. This is implemented by using special + subsections ``.text.hot`` for most frequently executed functions and + ``.text.unlikely`` for unlikely executed functions. Reordering is done by + the linker so object file format must support named sections and linker must + place them in a reasonable way. + + This option isn't effective unless you either provide profile feedback + (see :option:`-fprofile-arcs` for details) or manually annotate functions with + :fn-attr:`hot` or :fn-attr:`cold` attributes (see :ref:`common-function-attributes`). + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. _type-punning: + +.. option:: -fstrict-aliasing + + Allow the compiler to assume the strictest aliasing rules applicable to + the language being compiled. For C (and C++), this activates + optimizations based on the type of expressions. In particular, an + object of one type is assumed never to reside at the same address as an + object of a different type, unless the types are almost the same. For + example, an ``unsigned int`` can alias an ``int``, but not a + ``void*`` or a ``double``. A character type may alias any other + type. + + Pay special attention to code like this: + + .. code-block:: c++ + + union a_union { + int i; + double d; + }; + + int f() { + union a_union t; + t.d = 3.0; + return t.i; + } + + The practice of reading from a different union member than the one most + recently written to (called 'type-punning') is common. Even with + :option:`-fstrict-aliasing`, type-punning is allowed, provided the memory + is accessed through the union type. So, the code above works as + expected. See :ref:`structures-unions-enumerations-and-bit-fields-implementation`. However, this code might not: + + .. code-block:: c++ + + int f() { + union a_union t; + int* ip; + t.d = 3.0; + ip = &t.i; + return *ip; + } + + Similarly, access by taking the address, casting the resulting pointer + and dereferencing the result has undefined behavior, even if the cast + uses a union type, e.g.: + + .. code-block:: c++ + + int f() { + double d = 3.0; + return ((union a_union *) &d)->i; + } + + The :option:`-fstrict-aliasing` option is enabled at levels + :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fipa-strict-aliasing + + Controls whether rules of :option:`-fstrict-aliasing` are applied across + function boundaries. Note that if multiple functions gets inlined into a + single function the memory accesses are no longer considered to be crossing a + function boundary. + + The :option:`-fipa-strict-aliasing` option is enabled by default and is + effective only in combination with :option:`-fstrict-aliasing`. + +.. option:: -falign-functions[={n}[:{m}[:{n2}[:{m2}]]]] + + Align the start of functions to the next power-of-two greater than or + equal to :samp:`{n}`, skipping up to :samp:`{m}` -1 bytes. This ensures that at + least the first :samp:`{m}` bytes of the function can be fetched by the CPU + without crossing an :samp:`{n}` -byte alignment boundary. + + If :samp:`{m}` is not specified, it defaults to :samp:`{n}`. + + Examples: :option:`-falign-functions=32` aligns functions to the next + 32-byte boundary, :option:`-falign-functions=24` aligns to the next + 32-byte boundary only if this can be done by skipping 23 bytes or less, + :option:`-falign-functions=32:7` aligns to the next + 32-byte boundary only if this can be done by skipping 6 bytes or less. + + The second pair of :samp:`{n2}:{m2}` values allows you to specify + a secondary alignment: :option:`-falign-functions=64:7:32:3` aligns to + the next 64-byte boundary if this can be done by skipping 6 bytes or less, + otherwise aligns to the next 32-byte boundary if this can be done + by skipping 2 bytes or less. + If :samp:`{m2}` is not specified, it defaults to :samp:`{n2}`. + + Some assemblers only support this flag when :samp:`{n}` is a power of two; + in that case, it is rounded up. + + :option:`-fno-align-functions` and :option:`-falign-functions=1` are + equivalent and mean that functions are not aligned. + + If :samp:`{n}` is not specified or is zero, use a machine-dependent default. + The maximum allowed :samp:`{n}` option value is 65536. + + Enabled at levels :option:`-O2`, :option:`-O3`. + +.. option:: -flimit-function-alignment + + If this option is enabled, the compiler tries to avoid unnecessarily + overaligning functions. It attempts to instruct the assembler to align + by the amount specified by :option:`-falign-functions`, but not to + skip more bytes than the size of the function. + +.. option:: -falign-labels[={n}[:{m}[:{n2}[:{m2}]]]] + + Align all branch targets to a power-of-two boundary. + + Parameters of this option are analogous to the :option:`-falign-functions` option. + :option:`-fno-align-labels` and :option:`-falign-labels=1` are + equivalent and mean that labels are not aligned. + + If :option:`-falign-loops` or :option:`-falign-jumps` are applicable and + are greater than this value, then their values are used instead. + + If :samp:`{n}` is not specified or is zero, use a machine-dependent default + which is very likely to be :samp:`1`, meaning no alignment. + The maximum allowed :samp:`{n}` option value is 65536. + + Enabled at levels :option:`-O2`, :option:`-O3`. + +.. option:: -falign-loops[={n}[:{m}[:{n2}[:{m2}]]]] + + Align loops to a power-of-two boundary. If the loops are executed + many times, this makes up for any execution of the dummy padding + instructions. + + If :option:`-falign-labels` is greater than this value, then its value + is used instead. + + Parameters of this option are analogous to the :option:`-falign-functions` option. + :option:`-fno-align-loops` and :option:`-falign-loops=1` are + equivalent and mean that loops are not aligned. + The maximum allowed :samp:`{n}` option value is 65536. + + If :samp:`{n}` is not specified or is zero, use a machine-dependent default. + + Enabled at levels :option:`-O2`, :option:`-O3`. + +.. option:: -falign-jumps[={n}[:{m}[:{n2}[:{m2}]]]] + + Align branch targets to a power-of-two boundary, for branch targets + where the targets can only be reached by jumping. In this case, + no dummy operations need be executed. + + If :option:`-falign-labels` is greater than this value, then its value + is used instead. + + Parameters of this option are analogous to the :option:`-falign-functions` option. + :option:`-fno-align-jumps` and :option:`-falign-jumps=1` are + equivalent and mean that loops are not aligned. + + If :samp:`{n}` is not specified or is zero, use a machine-dependent default. + The maximum allowed :samp:`{n}` option value is 65536. + + Enabled at levels :option:`-O2`, :option:`-O3`. + +.. option:: -fno-allocation-dce + + Do not remove unused C++ allocations in dead code elimination. + +.. option:: -fallow-store-data-races + + Allow the compiler to perform optimizations that may introduce new data races + on stores, without proving that the variable cannot be concurrently accessed + by other threads. Does not affect optimization of local data. It is safe to + use this option if it is known that global data will not be accessed by + multiple threads. + + Examples of optimizations enabled by :option:`-fallow-store-data-races` include + hoisting or if-conversions that may cause a value that was already in memory + to be re-written with that same value. Such re-writing is safe in a single + threaded context but may be unsafe in a multi-threaded context. Note that on + some processors, if-conversions may be required in order to enable + vectorization. + + Enabled at level :option:`-Ofast`. + +.. option:: -funit-at-a-time + + This option is left for compatibility reasons. :option:`-funit-at-a-time` + has no effect, while :option:`-fno-unit-at-a-time` implies + :option:`-fno-toplevel-reorder` and :option:`-fno-section-anchors`. + + Enabled by default. + +.. option:: -fno-toplevel-reorder + + Do not reorder top-level functions, variables, and ``asm`` + statements. Output them in the same order that they appear in the + input file. When this option is used, unreferenced static variables + are not removed. This option is intended to support existing code + that relies on a particular ordering. For new code, it is better to + use attributes when possible. + + :option:`-ftoplevel-reorder` is the default at :option:`-O1` and higher, and + also at :option:`-O0` if :option:`-fsection-anchors` is explicitly requested. + Additionally :option:`-fno-toplevel-reorder` implies + :option:`-fno-section-anchors`. + +.. option:: -ftoplevel-reorder + + Default setting; overrides :option:`-fno-toplevel-reorder`. + +.. option:: -funreachable-traps + + With this option, the compiler turns calls to + ``__builtin_unreachable`` into traps, instead of using them for + optimization. This also affects any such calls implicitly generated + by the compiler. + + This option has the same effect as :option:`-fsanitize=unreachable + -fsanitize-trap=unreachable`, but does not affect the values of those + options. If :option:`-fsanitize=unreachable` is enabled, that option + takes priority over this one. + + This option is enabled by default at :option:`-O0` and :option:`-Og`. + +.. option:: -fweb + + Constructs webs as commonly used for register allocation purposes and assign + each web individual pseudo register. This allows the register allocation pass + to operate on pseudos directly, but also strengthens several other optimization + passes, such as CSE, loop optimizer and trivial dead code remover. It can, + however, make debugging impossible, since variables no longer stay in a + 'home register'. + + Enabled by default with :option:`-funroll-loops`. + +.. option:: -fwhole-program + + Assume that the current compilation unit represents the whole program being + compiled. All public functions and variables with the exception of ``main`` + and those merged by attribute :fn-attr:`externally_visible` become static functions + and in effect are optimized more aggressively by interprocedural optimizers. + + This option should not be used in combination with :option:`-flto`. + Instead relying on a linker plugin should provide safer and more precise + information. + +.. option:: -flto[={n}] + + This option runs the standard link-time optimizer. When invoked + with source code, it generates GIMPLE (one of GCC's internal + representations) and writes it to special ELF sections in the object + file. When the object files are linked together, all the function + bodies are read from these ELF sections and instantiated as if they + had been part of the same translation unit. + + To use the link-time optimizer, :option:`-flto` and optimization + options should be specified at compile time and during the final link. + It is recommended that you compile all the files participating in the + same link with the same options and also specify those options at + link time. + For example: + + .. code-block:: shell + + gcc -c -O2 -flto foo.c + gcc -c -O2 -flto bar.c + gcc -o myprog -flto -O2 foo.o bar.o + + The first two invocations to GCC save a bytecode representation + of GIMPLE into special ELF sections inside :samp:`foo.o` and + :samp:`bar.o`. The final invocation reads the GIMPLE bytecode from + :samp:`foo.o` and :samp:`bar.o`, merges the two files into a single + internal image, and compiles the result as usual. Since both + :samp:`foo.o` and :samp:`bar.o` are merged into a single image, this + causes all the interprocedural analyses and optimizations in GCC to + work across the two files as if they were a single one. This means, + for example, that the inliner is able to inline functions in + :samp:`bar.o` into functions in :samp:`foo.o` and vice-versa. + + Another (simpler) way to enable link-time optimization is: + + .. code-block:: shell + + gcc -o myprog -flto -O2 foo.c bar.c + + The above generates bytecode for :samp:`foo.c` and :samp:`bar.c`, + merges them together into a single GIMPLE representation and optimizes + them as usual to produce :samp:`myprog`. + + The important thing to keep in mind is that to enable link-time + optimizations you need to use the GCC driver to perform the link step. + GCC automatically performs link-time optimization if any of the + objects involved were compiled with the :option:`-flto` command-line option. + You can always override + the automatic decision to do link-time optimization + by passing :option:`-fno-lto` to the link command. + + To make whole program optimization effective, it is necessary to make + certain whole program assumptions. The compiler needs to know + what functions and variables can be accessed by libraries and runtime + outside of the link-time optimized unit. When supported by the linker, + the linker plugin (see :option:`-fuse-linker-plugin`) passes information + to the compiler about used and externally visible symbols. When + the linker plugin is not available, :option:`-fwhole-program` should be + used to allow the compiler to make these assumptions, which leads + to more aggressive optimization decisions. + + When a file is compiled with :option:`-flto` without + :option:`-fuse-linker-plugin`, the generated object file is larger than + a regular object file because it contains GIMPLE bytecodes and the usual + final code (see :option:`-ffat-lto-objects`). This means that + object files with LTO information can be linked as normal object + files; if :option:`-fno-lto` is passed to the linker, no + interprocedural optimizations are applied. Note that when + :option:`-fno-fat-lto-objects` is enabled the compile stage is faster + but you cannot perform a regular, non-LTO link on them. + + When producing the final binary, GCC only + applies link-time optimizations to those files that contain bytecode. + Therefore, you can mix and match object files and libraries with + GIMPLE bytecodes and final object code. GCC automatically selects + which files to optimize in LTO mode and which files to link without + further processing. + + Generally, options specified at link time override those + specified at compile time, although in some cases GCC attempts to infer + link-time options from the settings used to compile the input files. + + If you do not specify an optimization level option :option:`-O` at + link time, then GCC uses the highest optimization level + used when compiling the object files. Note that it is generally + ineffective to specify an optimization level option only at link time and + not at compile time, for two reasons. First, compiling without + optimization suppresses compiler passes that gather information + needed for effective optimization at link time. Second, some early + optimization passes can be performed only at compile time and + not at link time. + + There are some code generation flags preserved by GCC when + generating bytecodes, as they need to be used during the final link. + Currently, the following options and their settings are taken from + the first object file that explicitly specifies them: + :option:`-fcommon`, :option:`-fexceptions`, :option:`-fnon-call-exceptions`, + :option:`-fgnu-tm` and all the :option:`-m` target flags. + + The following options :option:`-fPIC`, :option:`-fpic`, :option:`-fpie` and + :option:`-fPIE` are combined based on the following scheme: + + .. list-table:: + :header-rows: 1 + + * - argument 1 + - argument 2 + - output + + * - :option:`-fPIC` + - :option:`-fpic` + - :option:`-fpic` + * - :option:`-fPIC` + - :option:`-fno-pic` + - :option:`-fno-pic` + * - :option:`-fpic`/:option:`-fPIC` + - no option + - no option + * - :option:`-fPIC` + - :option:`-fPIE` + - :option:`-fPIE` + * - :option:`-fpic` + - :option:`-fPIE` + - :option:`-fpie` + * - :option:`-fPIC`/:option:`-fpic` + - :option:`-fpie` + - :option:`-fpie` + + Certain ABI-changing flags are required to match in all compilation units, + and trying to override this at link time with a conflicting value + is ignored. This includes options such as :option:`-freg-struct-return` + and :option:`-fpcc-struct-return`. + + Other options such as :option:`-ffp-contract`, :option:`-fno-strict-overflow`, + :option:`-fwrapv`, :option:`-fno-trapv` or :option:`-fno-strict-aliasing` + are passed through to the link stage and merged conservatively for + conflicting translation units. Specifically + :option:`-fno-strict-overflow`, :option:`-fwrapv` and :option:`-fno-trapv` take + precedence; and for example :option:`-ffp-contract=off` takes precedence + over :option:`-ffp-contract=fast`. You can override them at link time. + + Diagnostic options such as :option:`-Wstringop-overflow` are passed + through to the link stage and their setting matches that of the + compile-step at function granularity. Note that this matters only + for diagnostics emitted during optimization. Note that code + transforms such as inlining can lead to warnings being enabled + or disabled for regions if code not consistent with the setting + at compile time. + + When you need to pass options to the assembler via :option:`-Wa` or + :option:`-Xassembler` make sure to either compile such translation + units with :option:`-fno-lto` or consistently use the same assembler + options on all translation units. You can alternatively also + specify assembler options at LTO link time. + + To enable debug info generation you need to supply :option:`-g` at + compile time. If any of the input files at link time were built + with debug info generation enabled the link will enable debug info + generation as well. Any elaborate debug info settings + like the dwarf level :option:`-gdwarf-5` need to be explicitly repeated + at the linker command line and mixing different settings in different + translation units is discouraged. + + If LTO encounters objects with C linkage declared with incompatible + types in separate translation units to be linked together (undefined + behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be + issued. The behavior is still undefined at run time. Similar + diagnostics may be raised for other languages. + + Another feature of LTO is that it is possible to apply interprocedural + optimizations on files written in different languages: + + .. code-block:: shell + + gcc -c -flto foo.c + g++ -c -flto bar.cc + gfortran -c -flto baz.f90 + g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran + + Notice that the final link is done with :command:`g++` to get the C++ + runtime libraries and :option:`-lgfortran` is added to get the Fortran + runtime libraries. In general, when mixing languages in LTO mode, you + should use the same link command options as when mixing languages in a + regular (non-LTO) compilation. + + If object files containing GIMPLE bytecode are stored in a library archive, say + :samp:`libfoo.a`, it is possible to extract and use them in an LTO link if you + are using a linker with plugin support. To create static libraries suitable + for LTO, use :command:`gcc-ar` and :command:`gcc-ranlib` instead of :command:`ar` + and :command:`ranlib`; + to show the symbols of object files with GIMPLE bytecode, use + :command:`gcc-nm`. Those commands require that :command:`ar`, :command:`ranlib` + and :command:`nm` have been compiled with plugin support. At link time, use the + flag :option:`-fuse-linker-plugin` to ensure that the library participates in + the LTO optimization process: + + .. code-block:: shell + + gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo + + With the linker plugin enabled, the linker extracts the needed + GIMPLE files from :samp:`libfoo.a` and passes them on to the running GCC + to make them part of the aggregated GIMPLE image to be optimized. + + If you are not using a linker with plugin support and/or do not + enable the linker plugin, then the objects inside :samp:`libfoo.a` + are extracted and linked as usual, but they do not participate + in the LTO optimization process. In order to make a static library suitable + for both LTO optimization and usual linkage, compile its object files with + :option:`-flto` :option:`-ffat-lto-objects`. + + Link-time optimizations do not require the presence of the whole program to + operate. If the program does not require any symbols to be exported, it is + possible to combine :option:`-flto` and :option:`-fwhole-program` to allow + the interprocedural optimizers to use more aggressive assumptions which may + lead to improved optimization opportunities. + Use of :option:`-fwhole-program` is not needed when linker plugin is + active (see :option:`-fuse-linker-plugin`). + + The current implementation of LTO makes no + attempt to generate bytecode that is portable between different + types of hosts. The bytecode files are versioned and there is a + strict version check, so bytecode files generated in one version of + GCC do not work with an older or newer version of GCC. + + Link-time optimization does not work well with generation of debugging + information on systems other than those using a combination of ELF and + DWARF. + + If you specify the optional :samp:`{n}`, the optimization and code + generation done at link time is executed in parallel using :samp:`{n}` + parallel jobs by utilizing an installed :command:`make` program. The + environment variable :envvar:`MAKE` may be used to override the program + used. + + You can also specify :option:`-flto=jobserver` to use GNU make's + job server mode to determine the number of parallel jobs. This + is useful when the Makefile calling GCC is already executing in parallel. + You must prepend a :samp:`+` to the command recipe in the parent Makefile + for this to work. This option likely only works if :envvar:`MAKE` is + GNU make. Even without the option value, GCC tries to automatically + detect a running GNU make's job server. + + Use :option:`-flto=auto` to use GNU make's job server, if available, + or otherwise fall back to autodetection of the number of CPU threads + present in your system. + +.. option:: -flto-partition={alg} + + Specify the partitioning algorithm used by the link-time optimizer. + The value is either :samp:`1to1` to specify a partitioning mirroring + the original source files or :samp:`balanced` to specify partitioning + into equally sized chunks (whenever possible) or :samp:`max` to create + new partition for every symbol where possible. Specifying :samp:`none` + as an algorithm disables partitioning and streaming completely. + The default value is :samp:`balanced`. While :samp:`1to1` can be used + as an workaround for various code ordering issues, the :samp:`max` + partitioning is intended for internal testing only. + The value :samp:`one` specifies that exactly one partition should be + used while the value :samp:`none` bypasses partitioning and executes + the link-time optimization step directly from the WPA phase. + +.. option:: -flto-compression-level={n} + + This option specifies the level of compression used for intermediate + language written to LTO object files, and is only meaningful in + conjunction with LTO mode (:option:`-flto`). GCC currently supports two + LTO compression algorithms. For zstd, valid values are 0 (no compression) + to 19 (maximum compression), while zlib supports values from 0 to 9. + Values outside this range are clamped to either minimum or maximum + of the supported values. If the option is not given, + a default balanced compression setting is used. + +.. option:: -fuse-linker-plugin + + Enables the use of a linker plugin during link-time optimization. This + option relies on plugin support in the linker, which is available in gold + or in GNU ld 2.21 or newer. + + This option enables the extraction of object files with GIMPLE bytecode out + of library archives. This improves the quality of optimization by exposing + more code to the link-time optimizer. This information specifies what + symbols can be accessed externally (by non-LTO object or during dynamic + linking). Resulting code quality improvements on binaries (and shared + libraries that use hidden visibility) are similar to :option:`-fwhole-program`. + See :option:`-flto` for a description of the effect of this flag and how to + use it. + + This option is enabled by default when LTO support in GCC is enabled + and GCC was configured for use with + a linker supporting plugins (GNU ld 2.21 or newer or gold). + +.. option:: -ffat-lto-objects + + Fat LTO objects are object files that contain both the intermediate language + and the object code. This makes them usable for both LTO linking and normal + linking. This option is effective only when compiling with :option:`-flto` + and is ignored at link time. + + :option:`-fno-fat-lto-objects` improves compilation time over plain LTO, but + requires the complete toolchain to be aware of LTO. It requires a linker with + linker plugin support for basic functionality. Additionally, + :command:`nm`, :command:`ar` and :command:`ranlib` + need to support linker plugins to allow a full-featured build environment + (capable of building static libraries etc). GCC provides the :command:`gcc-ar`, + :command:`gcc-nm`, :command:`gcc-ranlib` wrappers to pass the right options + to these tools. With non fat LTO makefiles need to be modified to use them. + + Note that modern binutils provide plugin auto-load mechanism. + Installing the linker plugin into :samp:`$libdir/bfd-plugins` has the same + effect as usage of the command wrappers (:command:`gcc-ar`, :command:`gcc-nm` and + :command:`gcc-ranlib`). + + The default is :option:`-fno-fat-lto-objects` on targets with linker plugin + support. + +.. option:: -fcompare-elim + + After register allocation and post-register allocation instruction splitting, + identify arithmetic instructions that compute processor flags similar to a + comparison operation based on that arithmetic. If possible, eliminate the + explicit comparison operation. + + This pass only applies to certain targets that cannot explicitly represent + the comparison operation before register allocation is complete. + + Enabled at levels :option:`-O1`, :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fcprop-registers + + After register allocation and post-register allocation instruction splitting, + perform a copy-propagation pass to try to reduce scheduling dependencies + and occasionally eliminate the copy. + + Enabled at levels :option:`-O1`, :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -fprofile-correction + + Profiles collected using an instrumented binary for multi-threaded programs may + be inconsistent due to missed counter updates. When this option is specified, + GCC uses heuristics to correct or smooth out such inconsistencies. By + default, GCC emits an error message when an inconsistent profile is detected. + + This option is enabled by :option:`-fauto-profile`. + +.. option:: -fprofile-partial-training + + With ``-fprofile-use`` all portions of programs not executed during train + run are optimized agressively for size rather than speed. In some cases it is + not practical to train all possible hot paths in the program. (For + example, program may contain functions specific for a given hardware and + trianing may not cover all hardware configurations program is run on.) With + ``-fprofile-partial-training`` profile feedback will be ignored for all + functions not executed during the train run leading them to be optimized as if + they were compiled without profile feedback. This leads to better performance + when train run is not representative but also leads to significantly bigger + code. + +.. option:: -fprofile-use, -fprofile-use={path} + + Enable profile feedback-directed optimizations, + and the following optimizations, many of which + are generally profitable only with profile feedback available: + + :option:`-fbranch-probabilities` :option:`-fprofile-values` |gol| + :option:`-funroll-loops` :option:`-fpeel-loops` :option:`-ftracer` :option:`-fvpt` |gol| + :option:`-finline-functions` :option:`-fipa-cp` :option:`-fipa-cp-clone` :option:`-fipa-bit-cp` |gol| + :option:`-fpredictive-commoning` :option:`-fsplit-loops` :option:`-funswitch-loops` |gol| + :option:`-fgcse-after-reload` :option:`-ftree-loop-vectorize` :option:`-ftree-slp-vectorize` |gol| + :option:`-fvect-cost-model=dynamic` :option:`-ftree-loop-distribute-patterns` |gol| + :option:`-fprofile-reorder-functions` + + Before you can use this option, you must first generate profiling information. + See :ref:`instrumentation-options`, for information about the + :option:`-fprofile-generate` option. + + By default, GCC emits an error message if the feedback profiles do not + match the source code. This error can be turned into a warning by using + :option:`-Wno-error=coverage-mismatch`. Note this may result in poorly + optimized code. Additionally, by default, GCC also emits a warning message if + the feedback profiles do not exist (see :option:`-Wmissing-profile`). + + If :samp:`{path}` is specified, GCC looks at the :samp:`{path}` to find + the profile feedback data files. See :option:`-fprofile-dir`. + +.. option:: -fauto-profile, -fauto-profile={path} + + Enable sampling-based feedback-directed optimizations, + and the following optimizations, + many of which are generally profitable only with profile feedback available: + + :option:`-fbranch-probabilities` :option:`-fprofile-values` |gol| + :option:`-funroll-loops` :option:`-fpeel-loops` :option:`-ftracer` :option:`-fvpt` |gol| + :option:`-finline-functions` :option:`-fipa-cp` :option:`-fipa-cp-clone` :option:`-fipa-bit-cp` |gol| + :option:`-fpredictive-commoning` :option:`-fsplit-loops` :option:`-funswitch-loops` |gol| + :option:`-fgcse-after-reload` :option:`-ftree-loop-vectorize` :option:`-ftree-slp-vectorize` |gol| + :option:`-fvect-cost-model=dynamic` :option:`-ftree-loop-distribute-patterns` |gol| + :option:`-fprofile-correction` + + :samp:`{path}` is the name of a file containing AutoFDO profile information. + If omitted, it defaults to :samp:`fbdata.afdo` in the current directory. + + Producing an AutoFDO profile data file requires running your program + with the :command:`perf` utility on a supported GNU/Linux target system. + For more information, see https://perf.wiki.kernel.org/. + + E.g. + + .. code-block:: c++ + + perf record -e br_inst_retired:near_taken -b -o perf.data \ + -- your_program + + Then use the :command:`create_gcov` tool to convert the raw profile data + to a format that can be used by GCC. You must also supply the + unstripped binary for your program to this tool. + See https://github.com/google/autofdo. + + E.g. + + .. code-block:: c++ + + create_gcov --binary=your_program.unstripped --profile=perf.data \ + --gcov=profile.afdo + +The following options control compiler behavior regarding floating-point +arithmetic. These options trade off between speed and +correctness. All must be specifically enabled. + +.. option:: -ffloat-store + + Do not store floating-point variables in registers, and inhibit other + options that might change whether a floating-point value is taken from a + register or memory. + + .. index:: floating-point precision + + This option prevents undesirable excess precision on machines such as + the 68000 where the floating registers (of the 68881) keep more + precision than a ``double`` is supposed to have. Similarly for the + x86 architecture. For most programs, the excess precision does only + good, but a few programs rely on the precise definition of IEEE floating + point. Use :option:`-ffloat-store` for such programs, after modifying + them to store all pertinent intermediate computations into variables. + +.. option:: -fexcess-precision={style} + + This option allows further control over excess precision on machines + where floating-point operations occur in a format with more precision or + range than the IEEE standard and interchange floating-point types. By + default, :option:`-fexcess-precision=fast` is in effect; this means that + operations may be carried out in a wider precision than the types specified + in the source if that would result in faster code, and it is unpredictable + when rounding to the types specified in the source code takes place. + When compiling C or C++, if :option:`-fexcess-precision=standard` is specified + then excess precision follows the rules specified in ISO C99 or C++; in particular, + both casts and assignments cause values to be rounded to their + semantic types (whereas :option:`-ffloat-store` only affects + assignments). This option is enabled by default for C or C++ if a strict + conformance option such as :option:`-std=c99` or :option:`-std=c++17` is used. + :option:`-ffast-math` enables :option:`-fexcess-precision=fast` by default + regardless of whether a strict conformance option is used. + + :option:`-fexcess-precision=standard` is not implemented for languages + other than C or C++. On the x86, it has no effect if :option:`-mfpmath=sse` + or :option:`-mfpmath=sse+387` is specified; in the former case, IEEE + semantics apply without excess precision, and in the latter, rounding + is unpredictable. + +.. option:: -ffast-math + + Sets the options :option:`-fno-math-errno`, :option:`-funsafe-math-optimizations`, + :option:`-ffinite-math-only`, :option:`-fno-rounding-math`, + :option:`-fno-signaling-nans`, :option:`-fcx-limited-range` and + :option:`-fexcess-precision=fast`. + + This option causes the preprocessor macro ``__FAST_MATH__`` to be defined. + + This option is not turned on by any :option:`-O` option besides + :option:`-Ofast` since it can result in incorrect output for programs + that depend on an exact implementation of IEEE or ISO rules/specifications + for math functions. It may, however, yield faster code for programs + that do not require the guarantees of these specifications. + +.. option:: -fno-math-errno + + Do not set ``errno`` after calling math functions that are executed + with a single instruction, e.g., ``sqrt``. A program that relies on + IEEE exceptions for math error handling may want to use this flag + for speed while maintaining IEEE arithmetic compatibility. + + This option is not turned on by any :option:`-O` option since + it can result in incorrect output for programs that depend on + an exact implementation of IEEE or ISO rules/specifications for + math functions. It may, however, yield faster code for programs + that do not require the guarantees of these specifications. + + The default is :option:`-fmath-errno`. + + On Darwin systems, the math library never sets ``errno``. There is + therefore no reason for the compiler to consider the possibility that + it might, and :option:`-fno-math-errno` is the default. + +.. option:: -fmath-errno + + Default setting; overrides :option:`-fno-math-errno`. + +.. option:: -funsafe-math-optimizations + + Allow optimizations for floating-point arithmetic that (a) assume + that arguments and results are valid and (b) may violate IEEE or + ANSI standards. When used at link time, it may include libraries + or startup files that change the default FPU control word or other + similar optimizations. + + This option is not turned on by any :option:`-O` option since + it can result in incorrect output for programs that depend on + an exact implementation of IEEE or ISO rules/specifications for + math functions. It may, however, yield faster code for programs + that do not require the guarantees of these specifications. + Enables :option:`-fno-signed-zeros`, :option:`-fno-trapping-math`, + :option:`-fassociative-math` and :option:`-freciprocal-math`. + + The default is :option:`-fno-unsafe-math-optimizations`. + +.. option:: -fassociative-math + + Allow re-association of operands in series of floating-point operations. + This violates the ISO C and C++ language standard by possibly changing + computation result. NOTE: re-ordering may change the sign of zero as + well as ignore NaNs and inhibit or create underflow or overflow (and + thus cannot be used on code that relies on rounding behavior like + ``(x + 2**52) - 2**52``. May also reorder floating-point comparisons + and thus may not be used when ordered comparisons are required. + This option requires that both :option:`-fno-signed-zeros` and + :option:`-fno-trapping-math` be in effect. Moreover, it doesn't make + much sense with :option:`-frounding-math`. For Fortran the option + is automatically enabled when both :option:`-fno-signed-zeros` and + :option:`-fno-trapping-math` are in effect. + + The default is :option:`-fno-associative-math`. + +.. option:: -freciprocal-math + + Allow the reciprocal of a value to be used instead of dividing by + the value if this enables optimizations. For example ``x / y`` + can be replaced with ``x * (1/y)``, which is useful if ``(1/y)`` + is subject to common subexpression elimination. Note that this loses + precision and increases the number of flops operating on the value. + + The default is :option:`-fno-reciprocal-math`. + +.. option:: -ffinite-math-only + + Allow optimizations for floating-point arithmetic that assume + that arguments and results are not NaNs or +-Infs. + + This option is not turned on by any :option:`-O` option since + it can result in incorrect output for programs that depend on + an exact implementation of IEEE or ISO rules/specifications for + math functions. It may, however, yield faster code for programs + that do not require the guarantees of these specifications. + + The default is :option:`-fno-finite-math-only`. + +.. option:: -fno-signed-zeros + + Allow optimizations for floating-point arithmetic that ignore the + signedness of zero. IEEE arithmetic specifies the behavior of + distinct +0.0 and -0.0 values, which then prohibits simplification + of expressions such as x+0.0 or 0.0\*x (even with :option:`-ffinite-math-only`). + This option implies that the sign of a zero result isn't significant. + + The default is :option:`-fsigned-zeros`. + +.. option:: -fsigned-zeros + + Default setting; overrides :option:`-fno-signed-zeros`. + +.. option:: -fno-trapping-math + + Compile code assuming that floating-point operations cannot generate + user-visible traps. These traps include division by zero, overflow, + underflow, inexact result and invalid operation. This option requires + that :option:`-fno-signaling-nans` be in effect. Setting this option may + allow faster code if one relies on 'non-stop' IEEE arithmetic, for example. + + This option should never be turned on by any :option:`-O` option since + it can result in incorrect output for programs that depend on + an exact implementation of IEEE or ISO rules/specifications for + math functions. + + The default is :option:`-ftrapping-math`. + + Future versions of GCC may provide finer control of this setting + using C99's ``FENV_ACCESS`` pragma. This command-line option + will be used along with :option:`-frounding-math` to specify the + default state for ``FENV_ACCESS``. + +.. option:: -ftrapping-math + + Default setting; overrides :option:`-fno-trapping-math`. + +.. option:: -frounding-math + + Disable transformations and optimizations that assume default floating-point + rounding behavior. This is round-to-zero for all floating point + to integer conversions, and round-to-nearest for all other arithmetic + truncations. This option should be specified for programs that change + the FP rounding mode dynamically, or that may be executed with a + non-default rounding mode. This option disables constant folding of + floating-point expressions at compile time (which may be affected by + rounding mode) and arithmetic transformations that are unsafe in the + presence of sign-dependent rounding modes. + + The default is :option:`-fno-rounding-math`. + + This option is experimental and does not currently guarantee to + disable all GCC optimizations that are affected by rounding mode. + Future versions of GCC may provide finer control of this setting + using C99's ``FENV_ACCESS`` pragma. This command-line option + will be used along with :option:`-ftrapping-math` to specify the + default state for ``FENV_ACCESS``. + +.. option:: -fsignaling-nans + + Compile code assuming that IEEE signaling NaNs may generate user-visible + traps during floating-point operations. Setting this option disables + optimizations that may change the number of exceptions visible with + signaling NaNs. This option implies :option:`-ftrapping-math`. + + This option causes the preprocessor macro ``__SUPPORT_SNAN__`` to + be defined. + + The default is :option:`-fno-signaling-nans`. + + This option is experimental and does not currently guarantee to + disable all GCC optimizations that affect signaling NaN behavior. + +.. option:: -fno-fp-int-builtin-inexact + + Do not allow the built-in functions ``ceil``, ``floor``, + ``round`` and ``trunc``, and their ``float`` and ``long + double`` variants, to generate code that raises the 'inexact' + floating-point exception for noninteger arguments. ISO C99 and C11 + allow these functions to raise the 'inexact' exception, but ISO/IEC + TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into + ISO C2X, does not allow these functions to do so. + + The default is :option:`-ffp-int-builtin-inexact`, allowing the + exception to be raised, unless C2X or a later C standard is selected. + This option does nothing unless :option:`-ftrapping-math` is in effect. + + Even if :option:`-fno-fp-int-builtin-inexact` is used, if the functions + generate a call to a library function then the 'inexact' exception + may be raised if the library implementation does not follow TS 18661. + +.. option:: -ffp-int-builtin-inexact + + Default setting; overrides :option:`-fno-fp-int-builtin-inexact`. + +.. option:: -fsingle-precision-constant + + Treat floating-point constants as single precision instead of + implicitly converting them to double-precision constants. + +.. option:: -fcx-limited-range + + When enabled, this option states that a range reduction step is not + needed when performing complex division. Also, there is no checking + whether the result of a complex multiplication or division is + ``NaN I*NaN``, with an attempt to rescue the situation in that case. The + default is :option:`-fno-cx-limited-range`, but is enabled by + :option:`-ffast-math`. + + This option controls the default setting of the ISO C99 + ``CX_LIMITED_RANGE`` pragma. Nevertheless, the option applies to + all languages. + +.. option:: -fcx-fortran-rules + + Complex multiplication and division follow Fortran rules. Range + reduction is done as part of complex division, but there is no checking + whether the result of a complex multiplication or division is ``NaN + + I*NaN``, with an attempt to rescue the situation in that case. + + The default is :option:`-fno-cx-fortran-rules`. + +The following options control optimizations that may improve +performance, but are not enabled by any :option:`-O` options. This +section includes experimental options that may produce broken code. + +.. option:: -fbranch-probabilities + + After running a program compiled with :option:`-fprofile-arcs` + (see :ref:`instrumentation-options`), + you can compile it a second time using + :option:`-fbranch-probabilities`, to improve optimizations based on + the number of times each branch was taken. When a program + compiled with :option:`-fprofile-arcs` exits, it saves arc execution + counts to a file called :samp:`{sourcename}.gcda` for each source + file. The information in this data file is very dependent on the + structure of the generated code, so you must use the same source code + and the same optimization options for both compilations. + See details about the file naming in :option:`-fprofile-arcs`. + + With :option:`-fbranch-probabilities`, GCC puts a + :samp:`REG_BR_PROB` note on each :samp:`JUMP_INSN` and :samp:`CALL_INSN`. + These can be used to improve optimization. Currently, they are only + used in one place: in :samp:`reorg.cc`, instead of guessing which path a + branch is most likely to take, the :samp:`REG_BR_PROB` values are used to + exactly determine which path is taken more often. + + Enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -fprofile-values + + If combined with :option:`-fprofile-arcs`, it adds code so that some + data about values of expressions in the program is gathered. + + With :option:`-fbranch-probabilities`, it reads back the data gathered + from profiling values of expressions for usage in optimizations. + + Enabled by :option:`-fprofile-generate`, :option:`-fprofile-use`, and + :option:`-fauto-profile`. + +.. option:: -fprofile-reorder-functions + + Function reordering based on profile instrumentation collects + first time of execution of a function and orders these functions + in ascending order. + + Enabled with :option:`-fprofile-use`. + +.. option:: -fvpt + + If combined with :option:`-fprofile-arcs`, this option instructs the compiler + to add code to gather information about values of expressions. + + With :option:`-fbranch-probabilities`, it reads back the data gathered + and actually performs the optimizations based on them. + Currently the optimizations include specialization of division operations + using the knowledge about the value of the denominator. + + Enabled with :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -frename-registers + + Attempt to avoid false dependencies in scheduled code by making use + of registers left over after register allocation. This optimization + most benefits processors with lots of registers. Depending on the + debug information format adopted by the target, however, it can + make debugging impossible, since variables no longer stay in + a 'home register'. + + Enabled by default with :option:`-funroll-loops`. + +.. option:: -fschedule-fusion + + Performs a target dependent pass over the instruction stream to schedule + instructions of same type together because target machine can execute them + more efficiently if they are adjacent to each other in the instruction flow. + + Enabled at levels :option:`-O2`, :option:`-O3`, :option:`-Os`. + +.. option:: -ftracer + + Perform tail duplication to enlarge superblock size. This transformation + simplifies the control flow of the function allowing other optimizations to do + a better job. + + Enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -funroll-loops + + Unroll loops whose number of iterations can be determined at compile time or + upon entry to the loop. :option:`-funroll-loops` implies + :option:`-frerun-cse-after-loop`, :option:`-fweb` and :option:`-frename-registers`. + It also turns on complete loop peeling (i.e. complete removal of loops with + a small constant number of iterations). This option makes code larger, and may + or may not make it run faster. + + Enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -funroll-all-loops + + Unroll all loops, even if their number of iterations is uncertain when + the loop is entered. This usually makes programs run more slowly. + :option:`-funroll-all-loops` implies the same options as + :option:`-funroll-loops`. + +.. option:: -fpeel-loops + + Peels loops for which there is enough information that they do not + roll much (from profile feedback or static analysis). It also turns on + complete loop peeling (i.e. complete removal of loops with small constant + number of iterations). + + Enabled by :option:`-O3`, :option:`-fprofile-use`, and :option:`-fauto-profile`. + +.. option:: -fmove-loop-invariants + + Enables the loop invariant motion pass in the RTL loop optimizer. Enabled + at level :option:`-O1` and higher, except for :option:`-Og`. + +.. option:: -fmove-loop-stores + + Enables the loop store motion pass in the GIMPLE loop optimizer. This + moves invariant stores to after the end of the loop in exchange for + carrying the stored value in a register across the iteration. + Note for this option to have an effect :option:`-ftree-loop-im` has to + be enabled as well. Enabled at level :option:`-O1` and higher, except + for :option:`-Og`. + +.. option:: -fsplit-loops + + Split a loop into two if it contains a condition that's always true + for one side of the iteration space and false for the other. + + Enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -funswitch-loops + + Move branches with loop invariant conditions out of the loop, with duplicates + of the loop on both branches (modified according to result of the condition). + + Enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -fversion-loops-for-strides + + If a loop iterates over an array with a variable stride, create another + version of the loop that assumes the stride is always one. For example: + + .. code-block:: c++ + + for (int i = 0; i < n; ++i) + x[i * stride] = ...; + + becomes: + + .. code-block:: c++ + + if (stride == 1) + for (int i = 0; i < n; ++i) + x[i] = ...; + else + for (int i = 0; i < n; ++i) + x[i * stride] = ...; + + This is particularly useful for assumed-shape arrays in Fortran where + (for example) it allows better vectorization assuming contiguous accesses. + This flag is enabled by default at :option:`-O3`. + It is also enabled by :option:`-fprofile-use` and :option:`-fauto-profile`. + +.. option:: -ffunction-sections, -fdata-sections + + Place each function or data item into its own section in the output + file if the target supports arbitrary sections. The name of the + function or the name of the data item determines the section's name + in the output file. + + Use these options on systems where the linker can perform optimizations to + improve locality of reference in the instruction space. Most systems using the + ELF object format have linkers with such optimizations. On AIX, the linker + rearranges sections (CSECTs) based on the call graph. The performance impact + varies. + + Together with a linker garbage collection (linker :option:`--gc-sections` + option) these options may lead to smaller statically-linked executables (after + stripping). + + On ELF/DWARF systems these options do not degenerate the quality of the debug + information. There could be issues with other object files/debug info formats. + + Only use these options when there are significant benefits from doing so. When + you specify these options, the assembler and linker create larger object and + executable files and are also slower. These options affect code generation. + They prevent optimizations by the compiler and assembler using relative + locations inside a translation unit since the locations are unknown until + link time. An example of such an optimization is relaxing calls to short call + instructions. + +.. option:: -fstdarg-opt + + Optimize the prologue of variadic argument functions with respect to usage of + those arguments. + +.. option:: -fsection-anchors + + Try to reduce the number of symbolic address calculations by using + shared 'anchor' symbols to address nearby objects. This transformation + can help to reduce the number of GOT entries and GOT accesses on some + targets. + + For example, the implementation of the following function ``foo`` : + + .. code-block:: c++ + + static int a, b, c; + int foo (void) { return a + b + c; } + + usually calculates the addresses of all three variables, but if you + compile it with :option:`-fsection-anchors`, it accesses the variables + from a common anchor point instead. The effect is similar to the + following pseudocode (which isn't valid C): + + .. code-block:: c++ + + int foo (void) + { + register int *xr = &x; + return xr[&a - &x] + xr[&b - &x] + xr[&c - &x]; + } + + Not all targets support this option. + +.. option:: -fzero-call-used-regs={choice} + + Zero call-used registers at function return to increase program + security by either mitigating Return-Oriented Programming (ROP) + attacks or preventing information leakage through registers. + + The possible values of :samp:`{choice}` are the same as for the + ``zero_call_used_regs`` attribute (see :ref:`function-attributes`). + The default is :samp:`skip`. + + You can control this behavior for a specific function by using the function + attribute ``zero_call_used_regs`` (see :ref:`function-attributes`). + +.. option:: --param {name}={value} + + In some places, GCC uses various constants to control the amount of + optimization that is done. For example, GCC does not inline functions + that contain more than a certain number of instructions. You can + control some of these constants on the command line using the + :option:`--param` option. + + The names of specific parameters, and the meaning of the values, are + tied to the internals of the compiler, and are subject to change + without notice in future releases. + + In order to get minimal, maximal and default value of a parameter, + one can use :option:`--help=param -Q` options. + + In each case, the :samp:`{value}` is an integer. The following choices + of :samp:`{name}` are recognized for all targets: + + .. gcc-param:: predictable-branch-outcome + + When branch is predicted to be taken with probability lower than this threshold + (in percent), then it is considered well predictable. + + .. gcc-param:: max-rtl-if-conversion-insns + + RTL if-conversion tries to remove conditional branches around a block and + replace them with conditionally executed instructions. This parameter + gives the maximum number of instructions in a block which should be + considered for if-conversion. The compiler will + also use other heuristics to decide whether if-conversion is likely to be + profitable. + + .. gcc-param:: max-rtl-if-conversion-predictable-cost + + RTL if-conversion will try to remove conditional branches around a block + and replace them with conditionally executed instructions. These parameters + give the maximum permissible cost for the sequence that would be generated + by if-conversion depending on whether the branch is statically determined + to be predictable or not. The units for this parameter are the same as + those for the GCC internal seq_cost metric. The compiler will try to + provide a reasonable default for this parameter using the BRANCH_COST + target macro. + + .. gcc-param:: max-crossjump-edges + + The maximum number of incoming edges to consider for cross-jumping. + The algorithm used by :option:`-fcrossjumping` is O(N^2) in + the number of edges incoming to each block. Increasing values mean + more aggressive optimization, making the compilation time increase with + probably small improvement in executable size. + + .. gcc-param:: min-crossjump-insns + + The minimum number of instructions that must be matched at the end + of two blocks before cross-jumping is performed on them. This + value is ignored in the case where all instructions in the block being + cross-jumped from are matched. + + .. gcc-param:: max-grow-copy-bb-insns + + The maximum code size expansion factor when copying basic blocks + instead of jumping. The expansion is relative to a jump instruction. + + .. gcc-param:: max-goto-duplication-insns + + The maximum number of instructions to duplicate to a block that jumps + to a computed goto. To avoid O(N^2) behavior in a number of + passes, GCC factors computed gotos early in the compilation process, + and unfactors them as late as possible. Only computed jumps at the + end of a basic blocks with no more than max-goto-duplication-insns are + unfactored. + + .. gcc-param:: max-delay-slot-insn-search + + The maximum number of instructions to consider when looking for an + instruction to fill a delay slot. If more than this arbitrary number of + instructions are searched, the time savings from filling the delay slot + are minimal, so stop searching. Increasing values mean more + aggressive optimization, making the compilation time increase with probably + small improvement in execution time. + + .. gcc-param:: max-delay-slot-live-search + + When trying to fill delay slots, the maximum number of instructions to + consider when searching for a block with valid live register + information. Increasing this arbitrarily chosen value means more + aggressive optimization, increasing the compilation time. This parameter + should be removed when the delay slot code is rewritten to maintain the + control-flow graph. + + .. gcc-param:: max-gcse-memory + + The approximate maximum amount of memory in ``kB`` that can be allocated in + order to perform the global common subexpression elimination + optimization. If more memory than specified is required, the + optimization is not done. + + .. gcc-param:: max-gcse-insertion-ratio + + If the ratio of expression insertions to deletions is larger than this value + for any expression, then RTL PRE inserts or removes the expression and thus + leaves partially redundant computations in the instruction stream. + + .. gcc-param:: max-pending-list-length + + The maximum number of pending dependencies scheduling allows + before flushing the current state and starting over. Large functions + with few branches or calls can create excessively large lists which + needlessly consume memory and resources. + + .. gcc-param:: max-modulo-backtrack-attempts + + The maximum number of backtrack attempts the scheduler should make + when modulo scheduling a loop. Larger values can exponentially increase + compilation time. + + .. gcc-param:: max-inline-functions-called-once-loop-depth + + Maximal loop depth of a call considered by inline heuristics that tries to + inline all functions called once. + + .. gcc-param:: max-inline-functions-called-once-insns + + Maximal estimated size of functions produced while inlining functions called + once. + + .. gcc-param:: max-inline-insns-single + + Several parameters control the tree inliner used in GCC. This number sets the + maximum number of instructions (counted in GCC's internal representation) in a + single function that the tree inliner considers for inlining. This only + affects functions declared inline and methods implemented in a class + declaration (C++). + + .. gcc-param:: max-inline-insns-auto + + When you use :option:`-finline-functions` (included in :option:`-O3`), + a lot of functions that would otherwise not be considered for inlining + by the compiler are investigated. To those functions, a different + (more restrictive) limit compared to functions declared inline can + be applied (:option:`--param` :gcc-param:`max-inline-insns-auto`). + + .. gcc-param:: max-inline-insns-small + + This is bound applied to calls which are considered relevant with + :option:`-finline-small-functions`. + + .. gcc-param:: max-inline-insns-size + + This is bound applied to calls which are optimized for size. Small growth + may be desirable to anticipate optimization oppurtunities exposed by inlining. + + .. gcc-param:: uninlined-function-insns + + Number of instructions accounted by inliner for function overhead such as + function prologue and epilogue. + + .. gcc-param:: uninlined-function-time + + Extra time accounted by inliner for function overhead such as time needed to + execute function prologue and epilogue. + + .. gcc-param:: inline-heuristics-hint-percent + + The scale (in percents) applied to inline-insns-single, + inline-insns-single-O2, inline-insns-auto + when inline heuristics hints that inlining is + very profitable (will enable later optimizations). + + .. gcc-param:: uninlined-thunk-insns + uninlined-thunk-time + + Same as :option:`--param` :gcc-param:`uninlined-function-insns` and + :option:`--param` :gcc-param:`uninlined-function-time` but applied to function thunks. + + .. gcc-param:: inline-min-speedup + + When estimated performance improvement of caller + callee runtime exceeds this + threshold (in percent), the function can be inlined regardless of the limit on + :option:`--param` :gcc-param:`max-inline-insns-single` and :option:`--param` + :gcc-param:`max-inline-insns-auto`. + + .. gcc-param:: large-function-insns + + The limit specifying really large functions. For functions larger than this + limit after inlining, inlining is constrained by + :option:`--param` :gcc-param:`large-function-growth`. This parameter is useful primarily + to avoid extreme compilation time caused by non-linear algorithms used by the + back end. + + .. gcc-param:: large-function-growth + + Specifies maximal growth of large function caused by inlining in percents. + For example, parameter value 100 limits large function growth to 2.0 times + the original size. + + .. gcc-param:: large-unit-insns + + The limit specifying large translation unit. Growth caused by inlining of + units larger than this limit is limited by :option:`--param` :gcc-param:`inline-unit-growth`. + For small units this might be too tight. + For example, consider a unit consisting of function A + that is inline and B that just calls A three times. If B is small relative to + A, the growth of unit is 300\% and yet such inlining is very sane. For very + large units consisting of small inlineable functions, however, the overall unit + growth limit is needed to avoid exponential explosion of code size. Thus for + smaller units, the size is increased to :option:`--param` :gcc-param:`large-unit-insns` + before applying :option:`--param` :gcc-param:`inline-unit-growth`. + + .. gcc-param:: lazy-modules + + Maximum number of concurrently open C++ module files when lazy loading. + + .. gcc-param:: inline-unit-growth + + Specifies maximal overall growth of the compilation unit caused by inlining. + For example, parameter value 20 limits unit growth to 1.2 times the original + size. Cold functions (either marked cold via an attribute or by profile + feedback) are not accounted into the unit size. + + .. gcc-param:: ipa-cp-unit-growth + + Specifies maximal overall growth of the compilation unit caused by + interprocedural constant propagation. For example, parameter value 10 limits + unit growth to 1.1 times the original size. + + .. gcc-param:: ipa-cp-large-unit-insns + + The size of translation unit that IPA-CP pass considers large. + + .. gcc-param:: large-stack-frame + + The limit specifying large stack frames. While inlining the algorithm is trying + to not grow past this limit too much. + + .. gcc-param:: large-stack-frame-growth + + Specifies maximal growth of large stack frames caused by inlining in percents. + For example, parameter value 1000 limits large stack frame growth to 11 times + the original size. + + .. gcc-param:: max-inline-insns-recursive + max-inline-insns-recursive-auto + + Specifies the maximum number of instructions an out-of-line copy of a + self-recursive inline + function can grow into by performing recursive inlining. + + :option:`--param` :gcc-param:`max-inline-insns-recursive` applies to functions + declared inline. + For functions not declared inline, recursive inlining + happens only when :option:`-finline-functions` (included in :option:`-O3`) is + enabled; :option:`--param` :gcc-param:`max-inline-insns-recursive-auto` applies instead. + + .. gcc-param:: max-inline-recursive-depth + max-inline-recursive-depth-auto + + Specifies the maximum recursion depth used for recursive inlining. + + :option:`--param` :gcc-param:`max-inline-recursive-depth` applies to functions + declared inline. For functions not declared inline, recursive inlining + happens only when :option:`-finline-functions` (included in :option:`-O3`) is + enabled; :option:`--param` :gcc-param:`max-inline-recursive-depth-auto` applies instead. + + .. gcc-param:: min-inline-recursive-probability + + Recursive inlining is profitable only for function having deep recursion + in average and can hurt for function having little recursion depth by + increasing the prologue size or complexity of function body to other + optimizers. + + When profile feedback is available (see :option:`-fprofile-generate`) the actual + recursion depth can be guessed from the probability that function recurses + via a given call expression. This parameter limits inlining only to call + expressions whose probability exceeds the given threshold (in percents). + + .. gcc-param:: early-inlining-insns + + Specify growth that the early inliner can make. In effect it increases + the amount of inlining for code having a large abstraction penalty. + + .. gcc-param:: max-early-inliner-iterations + + Limit of iterations of the early inliner. This basically bounds + the number of nested indirect calls the early inliner can resolve. + Deeper chains are still handled by late inlining. + + .. gcc-param:: comdat-sharing-probability + + Probability (in percent) that C++ inline function with comdat visibility + are shared across multiple compilation units. + + .. gcc-param:: modref-max-bases + modref-max-refs + modref-max-accesses + + Specifies the maximal number of base pointers, references and accesses stored + for a single function by mod/ref analysis. + + .. gcc-param:: modref-max-tests + + Specifies the maxmal number of tests alias oracle can perform to disambiguate + memory locations using the mod/ref information. This parameter ought to be + bigger than :option:`--param` :gcc-param:`modref-max-bases` and :option:`--param + :gcc-param:`modref-max-refs`. + + .. gcc-param:: modref-max-depth + + Specifies the maximum depth of DFS walk used by modref escape analysis. + Setting to 0 disables the analysis completely. + + .. gcc-param:: modref-max-escape-points + + Specifies the maximum number of escape points tracked by modref per SSA-name. + + .. gcc-param:: modref-max-adjustments + + Specifies the maximum number the access range is enlarged during modref dataflow + analysis. + + .. gcc-param:: profile-func-internal-id + + A parameter to control whether to use function internal id in profile + database lookup. If the value is 0, the compiler uses an id that + is based on function assembler name and filename, which makes old profile + data more tolerant to source changes such as function reordering etc. + + .. gcc-param:: min-vect-loop-bound + + The minimum number of iterations under which loops are not vectorized + when :option:`-ftree-vectorize` is used. The number of iterations after + vectorization needs to be greater than the value specified by this option + to allow vectorization. + + .. gcc-param:: gcse-cost-distance-ratio + + Scaling factor in calculation of maximum distance an expression + can be moved by GCSE optimizations. This is currently supported only in the + code hoisting pass. The bigger the ratio, the more aggressive code hoisting + is with simple expressions, i.e., the expressions that have cost + less than gcse-unrestricted-cost. Specifying 0 disables + hoisting of simple expressions. + + .. gcc-param:: gcse-unrestricted-cost + + Cost, roughly measured as the cost of a single typical machine + instruction, at which GCSE optimizations do not constrain + the distance an expression can travel. This is currently + supported only in the code hoisting pass. The lesser the cost, + the more aggressive code hoisting is. Specifying 0 + allows all expressions to travel unrestricted distances. + + .. gcc-param:: max-hoist-depth + + The depth of search in the dominator tree for expressions to hoist. + This is used to avoid quadratic behavior in hoisting algorithm. + The value of 0 does not limit on the search, but may slow down compilation + of huge functions. + + .. gcc-param:: max-tail-merge-comparisons + + The maximum amount of similar bbs to compare a bb with. This is used to + avoid quadratic behavior in tree tail merging. + + .. gcc-param:: max-tail-merge-iterations + + The maximum amount of iterations of the pass over the function. This is used to + limit compilation time in tree tail merging. + + .. gcc-param:: store-merging-allow-unaligned + + Allow the store merging pass to introduce unaligned stores if it is legal to + do so. + + .. gcc-param:: max-stores-to-merge + + The maximum number of stores to attempt to merge into wider stores in the store + merging pass. + + .. gcc-param:: max-store-chains-to-track + + The maximum number of store chains to track at the same time in the attempt + to merge them into wider stores in the store merging pass. + + .. gcc-param:: max-stores-to-track + + The maximum number of stores to track at the same time in the attemt to + to merge them into wider stores in the store merging pass. + + .. gcc-param:: max-unrolled-insns + + The maximum number of instructions that a loop may have to be unrolled. + If a loop is unrolled, this parameter also determines how many times + the loop code is unrolled. + + .. gcc-param:: max-average-unrolled-insns + + The maximum number of instructions biased by probabilities of their execution + that a loop may have to be unrolled. If a loop is unrolled, + this parameter also determines how many times the loop code is unrolled. + + .. gcc-param:: max-unroll-times + + The maximum number of unrollings of a single loop. + + .. gcc-param:: max-peeled-insns + + The maximum number of instructions that a loop may have to be peeled. + If a loop is peeled, this parameter also determines how many times + the loop code is peeled. + + .. gcc-param:: max-peel-times + + The maximum number of peelings of a single loop. + + .. gcc-param:: max-peel-branches + + The maximum number of branches on the hot path through the peeled sequence. + + .. gcc-param:: max-completely-peeled-insns + + The maximum number of insns of a completely peeled loop. + + .. gcc-param:: max-completely-peel-times + + The maximum number of iterations of a loop to be suitable for complete peeling. + + .. gcc-param:: max-completely-peel-loop-nest-depth + + The maximum depth of a loop nest suitable for complete peeling. + + .. gcc-param:: max-unswitch-insns + + The maximum number of insns of an unswitched loop. + + .. gcc-param:: lim-expensive + + The minimum cost of an expensive expression in the loop invariant motion. + + .. gcc-param:: min-loop-cond-split-prob + + When FDO profile information is available, min-loop-cond-split-prob + specifies minimum threshold for probability of semi-invariant condition + statement to trigger loop split. + + .. gcc-param:: iv-consider-all-candidates-bound + + Bound on number of candidates for induction variables, below which + all candidates are considered for each use in induction variable + optimizations. If there are more candidates than this, + only the most relevant ones are considered to avoid quadratic time complexity. + + .. gcc-param:: iv-max-considered-uses + + The induction variable optimizations give up on loops that contain more + induction variable uses. + + .. gcc-param:: iv-always-prune-cand-set-bound + + If the number of candidates in the set is smaller than this value, + always try to remove unnecessary ivs from the set + when adding a new one. + + .. gcc-param:: avg-loop-niter + + Average number of iterations of a loop. + + .. gcc-param:: dse-max-object-size + + Maximum size (in bytes) of objects tracked bytewise by dead store elimination. + Larger values may result in larger compilation times. + + .. gcc-param:: dse-max-alias-queries-per-store + + Maximum number of queries into the alias oracle per store. + Larger values result in larger compilation times and may result in more + removed dead stores. + + .. gcc-param:: scev-max-expr-size + + Bound on size of expressions used in the scalar evolutions analyzer. + Large expressions slow the analyzer. + + .. gcc-param:: scev-max-expr-complexity + + Bound on the complexity of the expressions in the scalar evolutions analyzer. + Complex expressions slow the analyzer. + + .. gcc-param:: max-tree-if-conversion-phi-args + + Maximum number of arguments in a PHI supported by TREE if conversion + unless the loop is marked with simd pragma. + + .. gcc-param:: vect-max-layout-candidates + + The maximum number of possible vector layouts (such as permutations) + to consider when optimizing to-be-vectorized code. + + .. gcc-param:: vect-max-version-for-alignment-checks + + The maximum number of run-time checks that can be performed when + doing loop versioning for alignment in the vectorizer. + + .. gcc-param:: vect-max-version-for-alias-checks + + The maximum number of run-time checks that can be performed when + doing loop versioning for alias in the vectorizer. + + .. gcc-param:: vect-max-peeling-for-alignment + + The maximum number of loop peels to enhance access alignment + for vectorizer. Value -1 means no limit. + + .. gcc-param:: max-iterations-to-track + + The maximum number of iterations of a loop the brute-force algorithm + for analysis of the number of iterations of the loop tries to evaluate. + + .. gcc-param:: hot-bb-count-fraction + + The denominator n of fraction 1/n of the maximal execution count of a + basic block in the entire program that a basic block needs to at least + have in order to be considered hot. The default is 10000, which means + that a basic block is considered hot if its execution count is greater + than 1/10000 of the maximal execution count. 0 means that it is never + considered hot. Used in non-LTO mode. + + .. gcc-param:: hot-bb-count-ws-permille + + The number of most executed permilles, ranging from 0 to 1000, of the + profiled execution of the entire program to which the execution count + of a basic block must be part of in order to be considered hot. The + default is 990, which means that a basic block is considered hot if + its execution count contributes to the upper 990 permilles, or 99.0%, + of the profiled execution of the entire program. 0 means that it is + never considered hot. Used in LTO mode. + + .. gcc-param:: hot-bb-frequency-fraction + + The denominator n of fraction 1/n of the execution frequency of the + entry block of a function that a basic block of this function needs + to at least have in order to be considered hot. The default is 1000, + which means that a basic block is considered hot in a function if it + is executed more frequently than 1/1000 of the frequency of the entry + block of the function. 0 means that it is never considered hot. + + .. gcc-param:: unlikely-bb-count-fraction + + The denominator n of fraction 1/n of the number of profiled runs of + the entire program below which the execution count of a basic block + must be in order for the basic block to be considered unlikely executed. + The default is 20, which means that a basic block is considered unlikely + executed if it is executed in fewer than 1/20, or 5%, of the runs of + the program. 0 means that it is always considered unlikely executed. + + .. gcc-param:: max-predicted-iterations + + The maximum number of loop iterations we predict statically. This is useful + in cases where a function contains a single loop with known bound and + another loop with unknown bound. + The known number of iterations is predicted correctly, while + the unknown number of iterations average to roughly 10. This means that the + loop without bounds appears artificially cold relative to the other one. + + .. gcc-param:: builtin-expect-probability + + Control the probability of the expression having the specified value. This + parameter takes a percentage (i.e. 0 ... 100) as input. + + .. gcc-param:: builtin-string-cmp-inline-length + + The maximum length of a constant string for a builtin string cmp call + eligible for inlining. + + .. gcc-param:: align-threshold + + Select fraction of the maximal frequency of executions of a basic block in + a function to align the basic block. + + .. gcc-param:: align-loop-iterations + + A loop expected to iterate at least the selected number of iterations is + aligned. + + .. gcc-param:: tracer-dynamic-coverage + tracer-dynamic-coverage-feedback + + This value is used to limit superblock formation once the given percentage of + executed instructions is covered. This limits unnecessary code size + expansion. + + The tracer-dynamic-coverage-feedback parameter + is used only when profile + feedback is available. The real profiles (as opposed to statically estimated + ones) are much less balanced allowing the threshold to be larger value. + + .. gcc-param:: tracer-max-code-growth + + Stop tail duplication once code growth has reached given percentage. This is + a rather artificial limit, as most of the duplicates are eliminated later in + cross jumping, so it may be set to much higher values than is the desired code + growth. + + .. gcc-param:: tracer-min-branch-ratio + + Stop reverse growth when the reverse probability of best edge is less than this + threshold (in percent). + + .. gcc-param:: tracer-min-branch-probability + tracer-min-branch-probability-feedback + + Stop forward growth if the best edge has probability lower than this + threshold. + + Similarly to tracer-dynamic-coverage two parameters are + provided. tracer-min-branch-probability-feedback is used for + compilation with profile feedback and tracer-min-branch-probability + compilation without. The value for compilation with profile feedback + needs to be more conservative (higher) in order to make tracer + effective. + + .. gcc-param:: stack-clash-protection-guard-size + + Specify the size of the operating system provided stack guard as + 2 raised to :samp:`{num}` bytes. Higher values may reduce the + number of explicit probes, but a value larger than the operating system + provided guard will leave code vulnerable to stack clash style attacks. + + .. gcc-param:: stack-clash-protection-probe-interval + + Stack clash protection involves probing stack space as it is allocated. This + param controls the maximum distance between probes into the stack as 2 raised + to :samp:`{num}` bytes. Higher values may reduce the number of explicit probes, but a value + larger than the operating system provided guard will leave code vulnerable to + stack clash style attacks. + + .. gcc-param:: max-cse-path-length + + The maximum number of basic blocks on path that CSE considers. + + .. gcc-param:: max-cse-insns + + The maximum number of instructions CSE processes before flushing. + + .. gcc-param:: ggc-min-expand + + GCC uses a garbage collector to manage its own memory allocation. This + parameter specifies the minimum percentage by which the garbage + collector's heap should be allowed to expand between collections. + Tuning this may improve compilation speed; it has no effect on code + generation. + + The default is 30% + 70% \* (RAM/1GB) with an upper bound of 100% when + RAM >= 1GB. If ``getrlimit`` is available, the notion of 'RAM' is + the smallest of actual RAM and ``RLIMIT_DATA`` or ``RLIMIT_AS``. If + GCC is not able to calculate RAM on a particular platform, the lower + bound of 30% is used. Setting this parameter and + ggc-min-heapsize to zero causes a full collection to occur at + every opportunity. This is extremely slow, but can be useful for + debugging. + + .. gcc-param:: ggc-min-heapsize + + Minimum size of the garbage collector's heap before it begins bothering + to collect garbage. The first collection occurs after the heap expands + by ggc-min-expand % beyond ggc-min-heapsize. Again, + tuning this may improve compilation speed, and has no effect on code + generation. + + The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that + tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but + with a lower bound of 4096 (four megabytes) and an upper bound of + 131072 (128 megabytes). If GCC is not able to calculate RAM on a + particular platform, the lower bound is used. Setting this parameter + very large effectively disables garbage collection. Setting this + parameter and ggc-min-expand to zero causes a full collection + to occur at every opportunity. + + .. gcc-param:: max-reload-search-insns + + The maximum number of instruction reload should look backward for equivalent + register. Increasing values mean more aggressive optimization, making the + compilation time increase with probably slightly better performance. + + .. gcc-param:: max-cselib-memory-locations + + The maximum number of memory locations cselib should take into account. + Increasing values mean more aggressive optimization, making the compilation time + increase with probably slightly better performance. + + .. gcc-param:: max-sched-ready-insns + + The maximum number of instructions ready to be issued the scheduler should + consider at any given time during the first scheduling pass. Increasing + values mean more thorough searches, making the compilation time increase + with probably little benefit. + + .. gcc-param:: max-sched-region-blocks + + The maximum number of blocks in a region to be considered for + interblock scheduling. + + .. gcc-param:: max-pipeline-region-blocks + + The maximum number of blocks in a region to be considered for + pipelining in the selective scheduler. + + .. gcc-param:: max-sched-region-insns + + The maximum number of insns in a region to be considered for + interblock scheduling. + + .. gcc-param:: max-pipeline-region-insns + + The maximum number of insns in a region to be considered for + pipelining in the selective scheduler. + + .. gcc-param:: min-spec-prob + + The minimum probability (in percents) of reaching a source block + for interblock speculative scheduling. + + .. gcc-param:: max-sched-extend-regions-iters + + The maximum number of iterations through CFG to extend regions. + A value of 0 disables region extensions. + + .. gcc-param:: max-sched-insn-conflict-delay + + The maximum conflict delay for an insn to be considered for speculative motion. + + .. gcc-param:: sched-spec-prob-cutoff + + The minimal probability of speculation success (in percents), so that + speculative insns are scheduled. + + .. gcc-param:: sched-state-edge-prob-cutoff + + The minimum probability an edge must have for the scheduler to save its + state across it. + + .. gcc-param:: sched-mem-true-dep-cost + + Minimal distance (in CPU cycles) between store and load targeting same + memory locations. + + .. gcc-param:: selsched-max-lookahead + + The maximum size of the lookahead window of selective scheduling. It is a + depth of search for available instructions. + + .. gcc-param:: selsched-max-sched-times + + The maximum number of times that an instruction is scheduled during + selective scheduling. This is the limit on the number of iterations + through which the instruction may be pipelined. + + .. gcc-param:: selsched-insns-to-rename + + The maximum number of best instructions in the ready list that are considered + for renaming in the selective scheduler. + + .. gcc-param:: sms-min-sc + + The minimum value of stage count that swing modulo scheduler + generates. + + .. gcc-param:: max-last-value-rtl + + The maximum size measured as number of RTLs that can be recorded in an expression + in combiner for a pseudo register as last known value of that register. + + .. gcc-param:: max-combine-insns + + The maximum number of instructions the RTL combiner tries to combine. + + .. gcc-param:: integer-share-limit + + Small integer constants can use a shared data structure, reducing the + compiler's memory usage and increasing its speed. This sets the maximum + value of a shared integer constant. + + .. gcc-param:: ssp-buffer-size + + The minimum size of buffers (i.e. arrays) that receive stack smashing + protection when :option:`-fstack-protector` is used. + + .. gcc-param:: min-size-for-stack-sharing + + The minimum size of variables taking part in stack slot sharing when not + optimizing. + + .. gcc-param:: max-jump-thread-duplication-stmts + + Maximum number of statements allowed in a block that needs to be + duplicated when threading jumps. + + .. gcc-param:: max-jump-thread-paths + + The maximum number of paths to consider when searching for jump threading + opportunities. When arriving at a block, incoming edges are only considered + if the number of paths to be searched so far multiplied by the number of + incoming edges does not exhaust the specified maximum number of paths to + consider. + + .. gcc-param:: max-fields-for-field-sensitive + + Maximum number of fields in a structure treated in + a field sensitive manner during pointer analysis. + + .. gcc-param:: prefetch-latency + + Estimate on average number of instructions that are executed before + prefetch finishes. The distance prefetched ahead is proportional + to this constant. Increasing this number may also lead to less + streams being prefetched (see :gcc-param:`simultaneous-prefetches`). + + .. gcc-param:: simultaneous-prefetches + + Maximum number of prefetches that can run at the same time. + + .. gcc-param:: l1-cache-line-size + + The size of cache line in L1 data cache, in bytes. + + .. gcc-param:: l1-cache-size + + The size of L1 data cache, in kilobytes. + + .. gcc-param:: l2-cache-size + + The size of L2 data cache, in kilobytes. + + .. gcc-param:: prefetch-dynamic-strides + + Whether the loop array prefetch pass should issue software prefetch hints + for strides that are non-constant. In some cases this may be + beneficial, though the fact the stride is non-constant may make it + hard to predict when there is clear benefit to issuing these hints. + + Set to 1 if the prefetch hints should be issued for non-constant + strides. Set to 0 if prefetch hints should be issued only for strides that + are known to be constant and below prefetch-minimum-stride. + + .. gcc-param:: prefetch-minimum-stride + + Minimum constant stride, in bytes, to start using prefetch hints for. If + the stride is less than this threshold, prefetch hints will not be issued. + + This setting is useful for processors that have hardware prefetchers, in + which case there may be conflicts between the hardware prefetchers and + the software prefetchers. If the hardware prefetchers have a maximum + stride they can handle, it should be used here to improve the use of + software prefetchers. + + A value of -1 means we don't have a threshold and therefore + prefetch hints can be issued for any constant stride. + + This setting is only useful for strides that are known and constant. + + .. gcc-param:: destructive-interference-size + constructive-interference-size + + The values for the C++17 variables + ``std::hardware_destructive_interference_size`` and + ``std::hardware_constructive_interference_size``. The destructive + interference size is the minimum recommended offset between two + independent concurrently-accessed objects; the constructive + interference size is the maximum recommended size of contiguous memory + accessed together. Typically both will be the size of an L1 cache + line for the target, in bytes. For a generic target covering a range of L1 + cache line sizes, typically the constructive interference size will be + the small end of the range and the destructive size will be the large + end. + + The destructive interference size is intended to be used for layout, + and thus has ABI impact. The default value is not expected to be + stable, and on some targets varies with :option:`-mtune`, so use of + this variable in a context where ABI stability is important, such as + the public interface of a library, is strongly discouraged; if it is + used in that context, users can stabilize the value using this + option. + + The constructive interference size is less sensitive, as it is + typically only used in a :samp:`static_assert` to make sure that a type + fits within a cache line. + + See also :option:`-Winterference-size`. + + .. gcc-param:: loop-interchange-max-num-stmts + + The maximum number of stmts in a loop to be interchanged. + + .. gcc-param:: loop-interchange-stride-ratio + + The minimum ratio between stride of two loops for interchange to be profitable. + + .. gcc-param:: min-insn-to-prefetch-ratio + + The minimum ratio between the number of instructions and the + number of prefetches to enable prefetching in a loop. + + .. gcc-param:: prefetch-min-insn-to-mem-ratio + + The minimum ratio between the number of instructions and the + number of memory references to enable prefetching in a loop. + + .. gcc-param:: use-canonical-types + + Whether the compiler should use the 'canonical' type system. + Should always be 1, which uses a more efficient internal + mechanism for comparing types in C++ and Objective-C++. However, if + bugs in the canonical type system are causing compilation failures, + set this value to 0 to disable canonical types. + + .. gcc-param:: switch-conversion-max-branch-ratio + + Switch initialization conversion refuses to create arrays that are + bigger than switch-conversion-max-branch-ratio times the number of + branches in the switch. + + .. gcc-param:: max-partial-antic-length + + Maximum length of the partial antic set computed during the tree + partial redundancy elimination optimization (:option:`-ftree-pre`) when + optimizing at :option:`-O3` and above. For some sorts of source code + the enhanced partial redundancy elimination optimization can run away, + consuming all of the memory available on the host machine. This + parameter sets a limit on the length of the sets that are computed, + which prevents the runaway behavior. Setting a value of 0 for + this parameter allows an unlimited set length. + + .. gcc-param:: rpo-vn-max-loop-depth + + Maximum loop depth that is value-numbered optimistically. + When the limit hits the innermost + :samp:`{rpo-vn-max-loop-depth}` loops and the outermost loop in the + loop nest are value-numbered optimistically and the remaining ones not. + + .. gcc-param:: sccvn-max-alias-queries-per-access + + Maximum number of alias-oracle queries we perform when looking for + redundancies for loads and stores. If this limit is hit the search + is aborted and the load or store is not considered redundant. The + number of queries is algorithmically limited to the number of + stores on all paths from the load to the function entry. + + .. gcc-param:: ira-max-loops-num + + IRA uses regional register allocation by default. If a function + contains more loops than the number given by this parameter, only at most + the given number of the most frequently-executed loops form regions + for regional register allocation. + + .. gcc-param:: ira-max-conflict-table-size + + Although IRA uses a sophisticated algorithm to compress the conflict + table, the table can still require excessive amounts of memory for + huge functions. If the conflict table for a function could be more + than the size in MB given by this parameter, the register allocator + instead uses a faster, simpler, and lower-quality + algorithm that does not require building a pseudo-register conflict table. + + .. gcc-param:: ira-loop-reserved-regs + + IRA can be used to evaluate more accurate register pressure in loops + for decisions to move loop invariants (see :option:`-O3`). The number + of available registers reserved for some other purposes is given + by this parameter. Default of the parameter + is the best found from numerous experiments. + + .. gcc-param:: ira-consider-dup-in-all-alts + + Make IRA to consider matching constraint (duplicated operand number) + heavily in all available alternatives for preferred register class. + If it is set as zero, it means IRA only respects the matching + constraint when it's in the only available alternative with an + appropriate register class. Otherwise, it means IRA will check all + available alternatives for preferred register class even if it has + found some choice with an appropriate register class and respect the + found qualified matching constraint. + + .. gcc-param:: lra-inheritance-ebb-probability-cutoff + + LRA tries to reuse values reloaded in registers in subsequent insns. + This optimization is called inheritance. EBB is used as a region to + do this optimization. The parameter defines a minimal fall-through + edge probability in percentage used to add BB to inheritance EBB in + LRA. The default value was chosen + from numerous runs of SPEC2000 on x86-64. + + .. gcc-param:: loop-invariant-max-bbs-in-loop + + Loop invariant motion can be very expensive, both in compilation time and + in amount of needed compile-time memory, with very large loops. Loops + with more basic blocks than this parameter won't have loop invariant + motion optimization performed on them. + + .. gcc-param:: loop-max-datarefs-for-datadeps + + Building data dependencies is expensive for very large loops. This + parameter limits the number of data references in loops that are + considered for data dependence analysis. These large loops are no + handled by the optimizations using loop data dependencies. + + .. gcc-param:: max-vartrack-size + + Sets a maximum number of hash table slots to use during variable + tracking dataflow analysis of any function. If this limit is exceeded + with variable tracking at assignments enabled, analysis for that + function is retried without it, after removing all debug insns from + the function. If the limit is exceeded even without debug insns, var + tracking analysis is completely disabled for the function. Setting + the parameter to zero makes it unlimited. + + .. gcc-param:: max-vartrack-expr-depth + + Sets a maximum number of recursion levels when attempting to map + variable names or debug temporaries to value expressions. This trades + compilation time for more complete debug information. If this is set too + low, value expressions that are available and could be represented in + debug information may end up not being used; setting this higher may + enable the compiler to find more complex debug expressions, but compile + time and memory use may grow. + + .. gcc-param:: max-debug-marker-count + + Sets a threshold on the number of debug markers (e.g. begin stmt + markers) to avoid complexity explosion at inlining or expanding to RTL. + If a function has more such gimple stmts than the set limit, such stmts + will be dropped from the inlined copy of a function, and from its RTL + expansion. + + .. gcc-param:: min-nondebug-insn-uid + + Use uids starting at this parameter for nondebug insns. The range below + the parameter is reserved exclusively for debug insns created by + :option:`-fvar-tracking-assignments`, but debug insns may get + (non-overlapping) uids above it if the reserved range is exhausted. + + .. gcc-param:: ipa-sra-ptr-growth-factor + + IPA-SRA replaces a pointer to an aggregate with one or more new + parameters only when their cumulative size is less or equal to + ipa-sra-ptr-growth-factor times the size of the original + pointer parameter. + + .. gcc-param:: ipa-sra-max-replacements + + Maximum pieces of an aggregate that IPA-SRA tracks. As a + consequence, it is also the maximum number of replacements of a formal + parameter. + + .. gcc-param:: sra-max-scalarization-size-Ospeed + sra-max-scalarization-size-Osize + + The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to + replace scalar parts of aggregates with uses of independent scalar + variables. These parameters control the maximum size, in storage units, + of aggregate which is considered for replacement when compiling for + speed + (:gcc-param:`sra-max-scalarization-size-Ospeed``) or size + (:gcc-param:`sra-max-scalarization-size-Osize``) respectively. + + .. gcc-param:: sra-max-propagations + + The maximum number of artificial accesses that Scalar Replacement of + Aggregates (SRA) will track, per one local variable, in order to + facilitate copy propagation. + + .. gcc-param:: tm-max-aggregate-size + + When making copies of thread-local variables in a transaction, this + parameter specifies the size in bytes after which variables are + saved with the logging functions as opposed to save/restore code + sequence pairs. This option only applies when using + :option:`-fgnu-tm`. + + .. gcc-param:: graphite-max-nb-scop-params + + To avoid exponential effects in the Graphite loop transforms, the + number of parameters in a Static Control Part (SCoP) is bounded. + A value of zero can be used to lift + the bound. A variable whose value is unknown at compilation time and + defined outside a SCoP is a parameter of the SCoP. + + .. gcc-param:: loop-block-tile-size + + Loop blocking or strip mining transforms, enabled with + :option:`-floop-block` or :option:`-floop-strip-mine`, strip mine each + loop in the loop nest by a given number of iterations. The strip + length can be changed using the loop-block-tile-size + parameter. + + .. gcc-param:: ipa-jump-function-lookups + + Specifies number of statements visited during jump function offset discovery. + + .. gcc-param:: ipa-cp-value-list-size + + IPA-CP attempts to track all possible values and types passed to a function's + parameter in order to propagate them and perform devirtualization. + :gcc-param:`ipa-cp-value-list-size` is the maximum number of values and types it + stores per one formal parameter of a function. + + .. gcc-param:: ipa-cp-eval-threshold + + IPA-CP calculates its own score of cloning profitability heuristics + and performs those cloning opportunities with scores that exceed + :gcc-param:`ipa-cp-eval-threshold`. + + .. gcc-param:: ipa-cp-max-recursive-depth + + Maximum depth of recursive cloning for self-recursive function. + + .. gcc-param:: ipa-cp-min-recursive-probability + + Recursive cloning only when the probability of call being executed exceeds + the parameter. + + .. gcc-param:: ipa-cp-profile-count-base + + When using :option:`-fprofile-use` option, IPA-CP will consider the measured + execution count of a call graph edge at this percentage position in their + histogram as the basis for its heuristics calculation. + + .. gcc-param:: ipa-cp-recursive-freq-factor + + The number of times interprocedural copy propagation expects recursive + functions to call themselves. + + .. gcc-param:: ipa-cp-recursion-penalty + + Percentage penalty the recursive functions will receive when they + are evaluated for cloning. + + .. gcc-param:: ipa-cp-single-call-penalty + + Percentage penalty functions containing a single call to another + function will receive when they are evaluated for cloning. + + .. gcc-param:: ipa-max-agg-items + + IPA-CP is also capable to propagate a number of scalar values passed + in an aggregate. :gcc-param:`ipa-max-agg-items`` controls the maximum + number of such values per one parameter. + + .. gcc-param:: ipa-cp-loop-hint-bonus + + When IPA-CP determines that a cloning candidate would make the number + of iterations of a loop known, it adds a bonus of + ipa-cp-loop-hint-bonus to the profitability score of + the candidate. + + .. gcc-param:: ipa-max-loop-predicates + + The maximum number of different predicates IPA will use to describe when + loops in a function have known properties. + + .. gcc-param:: ipa-max-aa-steps + + During its analysis of function bodies, IPA-CP employs alias analysis + in order to track values pointed to by function parameters. In order + not spend too much time analyzing huge functions, it gives up and + consider all memory clobbered after examining + :gcc-param:`ipa-max-aa-steps` statements modifying memory. + + .. gcc-param:: ipa-max-switch-predicate-bounds + + Maximal number of boundary endpoints of case ranges of switch statement. + For switch exceeding this limit, IPA-CP will not construct cloning cost + predicate, which is used to estimate cloning benefit, for default case + of the switch statement. + + .. gcc-param:: ipa-max-param-expr-ops + + IPA-CP will analyze conditional statement that references some function + parameter to estimate benefit for cloning upon certain constant value. + But if number of operations in a parameter expression exceeds + :gcc-param:`ipa-max-param-expr-ops`, the expression is treated as complicated + one, and is not handled by IPA analysis. + + .. gcc-param:: lto-partitions + + Specify desired number of partitions produced during WHOPR compilation. + The number of partitions should exceed the number of CPUs used for compilation. + + .. gcc-param:: lto-min-partition + + Size of minimal partition for WHOPR (in estimated instructions). + This prevents expenses of splitting very small programs into too many + partitions. + + .. gcc-param:: lto-max-partition + + Size of max partition for WHOPR (in estimated instructions). + to provide an upper bound for individual size of partition. + Meant to be used only with balanced partitioning. + + .. gcc-param:: lto-max-streaming-parallelism + + Maximal number of parallel processes used for LTO streaming. + + .. gcc-param:: cxx-max-namespaces-for-diagnostic-help + + The maximum number of namespaces to consult for suggestions when C++ + name lookup fails for an identifier. + + .. gcc-param:: sink-frequency-threshold + + The maximum relative execution frequency (in percents) of the target block + relative to a statement's original block to allow statement sinking of a + statement. Larger numbers result in more aggressive statement sinking. + A small positive adjustment is applied for + statements with memory operands as those are even more profitable so sink. + + .. gcc-param:: max-stores-to-sink + + The maximum number of conditional store pairs that can be sunk. Set to 0 + if either vectorization (:option:`-ftree-vectorize`) or if-conversion + (:option:`-ftree-loop-if-convert`) is disabled. + + .. gcc-param:: case-values-threshold + + The smallest number of different values for which it is best to use a + jump-table instead of a tree of conditional branches. If the value is + 0, use the default for the machine. + + .. gcc-param:: jump-table-max-growth-ratio-for-size + + The maximum code size growth ratio when expanding + into a jump table (in percent). The parameter is used when + optimizing for size. + + .. gcc-param:: jump-table-max-growth-ratio-for-speed + + The maximum code size growth ratio when expanding + into a jump table (in percent). The parameter is used when + optimizing for speed. + + .. gcc-param:: tree-reassoc-width + + Set the maximum number of instructions executed in parallel in + reassociated tree. This parameter overrides target dependent + heuristics used by default if has non zero value. + + .. gcc-param:: sched-pressure-algorithm + + Choose between the two available implementations of + :option:`-fsched-pressure`. Algorithm 1 is the original implementation + and is the more likely to prevent instructions from being reordered. + Algorithm 2 was designed to be a compromise between the relatively + conservative approach taken by algorithm 1 and the rather aggressive + approach taken by the default scheduler. It relies more heavily on + having a regular register file and accurate register pressure classes. + See :samp:`haifa-sched.cc` in the GCC sources for more details. + + The default choice depends on the target. + + .. gcc-param:: max-slsr-cand-scan + + Set the maximum number of existing candidates that are considered when + seeking a basis for a new straight-line strength reduction candidate. + + .. gcc-param:: asan-globals + + Enable buffer overflow detection for global objects. This kind + of protection is enabled by default if you are using + :option:`-fsanitize=address` option. + To disable global objects protection use :option:`--param` :gcc-param:`asan-globals`:samp:`=0`. + + .. gcc-param:: asan-stack + + Enable buffer overflow detection for stack objects. This kind of + protection is enabled by default when using :option:`-fsanitize=address`. + To disable stack protection use :option:`--param` :gcc-param:`asan-stack`:samp:`=0` option. + + .. gcc-param:: asan-instrument-reads + + Enable buffer overflow detection for memory reads. This kind of + protection is enabled by default when using :option:`-fsanitize=address`. + To disable memory reads protection use + :option:`--param` :gcc-param:`asan-instrument-reads`:samp:`=0`. + + .. gcc-param:: asan-instrument-writes + + Enable buffer overflow detection for memory writes. This kind of + protection is enabled by default when using :option:`-fsanitize=address`. + To disable memory writes protection use + :option:`--param` :gcc-param:`asan-instrument-writes`:samp:`=0` option. + + .. gcc-param:: asan-memintrin + + Enable detection for built-in functions. This kind of protection + is enabled by default when using :option:`-fsanitize=address`. + To disable built-in functions protection use + :option:`--param` :gcc-param:`asan-memintrin`:samp:`=0`. + + .. gcc-param:: asan-use-after-return + + Enable detection of use-after-return. This kind of protection + is enabled by default when using the :option:`-fsanitize=address` option. + To disable it use :option:`--param` :gcc-param:`asan-use-after-return`:samp:`=0`. + + .. note:: + + By default the check is disabled at run time. To enable it, + add ``detect_stack_use_after_return=1`` to the environment variable + :envvar:`ASAN_OPTIONS`. + + .. gcc-param:: asan-instrumentation-with-call-threshold + + If number of memory accesses in function being instrumented + is greater or equal to this number, use callbacks instead of inline checks. + E.g. to disable inline code use + :option:`--param` :gcc-param:`asan-instrumentation-with-call-threshold`:samp:`=0`. + + .. gcc-param:: hwasan-instrument-stack + + Enable hwasan instrumentation of statically sized stack-allocated variables. + This kind of instrumentation is enabled by default when using + :option:`-fsanitize=hwaddress` and disabled by default when using + :option:`-fsanitize=kernel-hwaddress`. + To disable stack instrumentation use + :option:`--param` :gcc-param:`hwasan-instrument-stack`:samp:`=0`, and to enable it use + :option:`--param` :gcc-param:`hwasan-instrument-stack`:samp:`=1`. + + .. gcc-param:: hwasan-random-frame-tag + + When using stack instrumentation, decide tags for stack variables using a + deterministic sequence beginning at a random tag for each frame. With this + parameter unset tags are chosen using the same sequence but beginning from 1. + This is enabled by default for :option:`-fsanitize=hwaddress` and unavailable + for :option:`-fsanitize=kernel-hwaddress`. + To disable it use :option:`--param` :gcc-param:`hwasan-random-frame-tag`:samp:`=0`. + + .. gcc-param:: hwasan-instrument-allocas + + Enable hwasan instrumentation of dynamically sized stack-allocated variables. + This kind of instrumentation is enabled by default when using + :option:`-fsanitize=hwaddress` and disabled by default when using + :option:`-fsanitize=kernel-hwaddress`. + To disable instrumentation of such variables use + :option:`--param` :gcc-param:`hwasan-instrument-allocas`:samp:`=0`, and to enable it use + :option:`--param` :gcc-param:`hwasan-instrument-allocas`:samp:`=1`. + + .. gcc-param:: hwasan-instrument-reads + + Enable hwasan checks on memory reads. Instrumentation of reads is enabled by + default for both :option:`-fsanitize=hwaddress` and + :option:`-fsanitize=kernel-hwaddress`. + To disable checking memory reads use + :option:`--param` :gcc-param:`hwasan-instrument-reads`:samp:`=0`. + + .. gcc-param:: hwasan-instrument-writes + + Enable hwasan checks on memory writes. Instrumentation of writes is enabled by + default for both :option:`-fsanitize=hwaddress` and + :option:`-fsanitize=kernel-hwaddress`. + To disable checking memory writes use + :option:`--param` :gcc-param:`hwasan-instrument-writes`:samp:`=0`. + + .. gcc-param:: hwasan-instrument-mem-intrinsics + + Enable hwasan instrumentation of builtin functions. Instrumentation of these + builtin functions is enabled by default for both :option:`-fsanitize=hwaddress` + and :option:`-fsanitize=kernel-hwaddress`. + To disable instrumentation of builtin functions use + :option:`--param` :gcc-param:`hwasan-instrument-mem-intrinsics`:samp:`=0`. + + .. gcc-param:: use-after-scope-direct-emission-threshold + + If the size of a local variable in bytes is smaller or equal to this + number, directly poison (or unpoison) shadow memory instead of using + run-time callbacks. + + .. gcc-param:: tsan-distinguish-volatile + + Emit special instrumentation for accesses to volatiles. + + .. gcc-param:: tsan-instrument-func-entry-exit + + Emit instrumentation calls to :samp:`__tsan_func_entry()` and :samp:`__tsan_func_exit()`. + + .. gcc-param:: max-fsm-thread-path-insns + + Maximum number of instructions to copy when duplicating blocks on a + finite state automaton jump thread path. + + .. gcc-param:: threader-debug + + threader-debug=[none|all] + Enables verbose dumping of the threader solver. + + .. gcc-param:: parloops-chunk-size + + Chunk size of omp schedule for loops parallelized by parloops. + + .. gcc-param:: parloops-schedule + + Schedule type of omp schedule for loops parallelized by parloops (static, + dynamic, guided, auto, runtime). + + .. gcc-param:: parloops-min-per-thread + + The minimum number of iterations per thread of an innermost parallelized + loop for which the parallelized variant is preferred over the single threaded + one. Note that for a parallelized loop nest the + minimum number of iterations of the outermost loop per thread is two. + + .. gcc-param:: max-ssa-name-query-depth + + Maximum depth of recursion when querying properties of SSA names in things + like fold routines. One level of recursion corresponds to following a + use-def chain. + + .. gcc-param:: max-speculative-devirt-maydefs + + The maximum number of may-defs we analyze when looking for a must-def + specifying the dynamic type of an object that invokes a virtual call + we may be able to devirtualize speculatively. + + .. gcc-param:: max-vrp-switch-assertions + + The maximum number of assertions to add along the default edge of a switch + statement during VRP. + + .. gcc-param:: evrp-sparse-threshold + + Maximum number of basic blocks before EVRP uses a sparse cache. + + .. gcc-param:: vrp1-mode + + Specifies the mode VRP pass 1 should operate in. + + .. gcc-param:: vrp2-mode + + Specifies the mode VRP pass 2 should operate in. + + .. gcc-param:: ranger-debug + + Specifies the type of debug output to be issued for ranges. + + .. gcc-param:: evrp-switch-limit + + Specifies the maximum number of switch cases before EVRP ignores a switch. + + .. gcc-param:: unroll-jam-min-percent + + The minimum percentage of memory references that must be optimized + away for the unroll-and-jam transformation to be considered profitable. + + .. gcc-param:: unroll-jam-max-unroll + + The maximum number of times the outer loop should be unrolled by + the unroll-and-jam transformation. + + .. gcc-param:: max-rtl-if-conversion-unpredictable-cost + + Maximum permissible cost for the sequence that would be generated + by the RTL if-conversion pass for a branch that is considered unpredictable. + + .. gcc-param:: max-variable-expansions-in-unroller + + If :option:`-fvariable-expansion-in-unroller` is used, the maximum number + of times that an individual variable will be expanded during loop unrolling. + + .. gcc-param:: partial-inlining-entry-probability + + Maximum probability of the entry BB of split region + (in percent relative to entry BB of the function) + to make partial inlining happen. + + .. gcc-param:: max-tracked-strlens + + Maximum number of strings for which strlen optimization pass will + track string lengths. + + .. gcc-param:: gcse-after-reload-partial-fraction + + The threshold ratio for performing partial redundancy + elimination after reload. + + .. gcc-param:: gcse-after-reload-critical-fraction + + The threshold ratio of critical edges execution count that + permit performing redundancy elimination after reload. + + .. gcc-param:: max-loop-header-insns + + The maximum number of insns in loop header duplicated + by the copy loop headers pass. + + .. gcc-param:: vect-epilogues-nomask + + Enable loop epilogue vectorization using smaller vector size. + + .. gcc-param:: vect-partial-vector-usage + + Controls when the loop vectorizer considers using partial vector loads + and stores as an alternative to falling back to scalar code. 0 stops + the vectorizer from ever using partial vector loads and stores. 1 allows + partial vector loads and stores if vectorization removes the need for the + code to iterate. 2 allows partial vector loads and stores in all loops. + The parameter only has an effect on targets that support partial + vector loads and stores. + + .. gcc-param:: vect-inner-loop-cost-factor + + The maximum factor which the loop vectorizer applies to the cost of statements + in an inner loop relative to the loop being vectorized. The factor applied + is the maximum of the estimated number of iterations of the inner loop and + this parameter. The default value of this parameter is 50. + + .. gcc-param:: vect-induction-float + + Enable loop vectorization of floating point inductions. + + .. gcc-param:: avoid-fma-max-bits + + Maximum number of bits for which we avoid creating FMAs. + + .. gcc-param:: sms-loop-average-count-threshold + + A threshold on the average loop count considered by the swing modulo scheduler. + + .. gcc-param:: sms-dfa-history + + The number of cycles the swing modulo scheduler considers when checking + conflicts using DFA. + + .. gcc-param:: graphite-allow-codegen-errors + + Whether codegen errors should be ICEs when :option:`-fchecking`. + + .. gcc-param:: sms-max-ii-factor + + A factor for tuning the upper bound that swing modulo scheduler + uses for scheduling a loop. + + .. gcc-param:: lra-max-considered-reload-pseudos + + The max number of reload pseudos which are considered during + spilling a non-reload pseudo. + + .. gcc-param:: max-pow-sqrt-depth + + Maximum depth of sqrt chains to use when synthesizing exponentiation + by a real constant. + + .. gcc-param:: max-dse-active-local-stores + + Maximum number of active local stores in RTL dead store elimination. + + .. gcc-param:: asan-instrument-allocas + + Enable asan allocas/VLAs protection. + + .. gcc-param:: max-iterations-computation-cost + + Bound on the cost of an expression to compute the number of iterations. + + .. gcc-param:: max-isl-operations + + Maximum number of isl operations, 0 means unlimited. + + .. gcc-param:: graphite-max-arrays-per-scop + + Maximum number of arrays per scop. + + .. gcc-param:: max-vartrack-reverse-op-size + + Max. size of loc list for which reverse ops should be added. + + .. gcc-param:: fsm-scale-path-stmts + + Scale factor to apply to the number of statements in a threading path + when comparing to the number of (scaled) blocks. + + .. gcc-param:: uninit-control-dep-attempts + + Maximum number of nested calls to search for control dependencies + during uninitialized variable analysis. + + .. gcc-param:: fsm-scale-path-blocks + + Scale factor to apply to the number of blocks in a threading path + when comparing to the number of (scaled) statements. + + .. gcc-param:: sched-autopref-queue-depth + + Hardware autoprefetcher scheduler model control flag. + Number of lookahead cycles the model looks into; at ' + ' only enable instruction sorting heuristic. + + .. gcc-param:: loop-versioning-max-inner-insns + + The maximum number of instructions that an inner loop can have + before the loop versioning pass considers it too big to copy. + + .. gcc-param:: loop-versioning-max-outer-insns + + The maximum number of instructions that an outer loop can have + before the loop versioning pass considers it too big to copy, + discounting any instructions in inner loops that directly benefit + from versioning. + + .. gcc-param:: ssa-name-def-chain-limit + + The maximum number of SSA_NAME assignments to follow in determining + a property of a variable such as its value. This limits the number + of iterations or recursive calls GCC performs when optimizing certain + statements or when determining their validity prior to issuing + diagnostics. + + .. gcc-param:: store-merging-max-size + + Maximum size of a single store merging region in bytes. + + .. gcc-param:: hash-table-verification-limit + + The number of elements for which hash table verification is done + for each searched element. + + .. gcc-param:: max-find-base-term-values + + Maximum number of VALUEs handled during a single find_base_term call. + + .. gcc-param:: analyzer-max-enodes-per-program-point + + The maximum number of exploded nodes per program point within + the analyzer, before terminating analysis of that point. + + .. gcc-param:: analyzer-max-constraints + + The maximum number of constraints per state. + + .. gcc-param:: analyzer-min-snodes-for-call-summary + + The minimum number of supernodes within a function for the + analyzer to consider summarizing its effects at call sites. + + .. gcc-param:: analyzer-max-enodes-for-full-dump + + The maximum depth of exploded nodes that should appear in a dot dump + before switching to a less verbose format. + + .. gcc-param:: analyzer-max-recursion-depth + + The maximum number of times a callsite can appear in a call stack + within the analyzer, before terminating analysis of a call that would + recurse deeper. + + .. gcc-param:: analyzer-max-svalue-depth + + The maximum depth of a symbolic value, before approximating + the value as unknown. + + .. gcc-param:: analyzer-max-infeasible-edges + + The maximum number of infeasible edges to reject before declaring + a diagnostic as infeasible. + + .. gcc-param:: gimple-fe-computed-hot-bb-threshold + + The number of executions of a basic block which is considered hot. + The parameter is used only in GIMPLE FE. + + .. gcc-param:: analyzer-bb-explosion-factor + + The maximum number of 'after supernode' exploded nodes within the analyzer + per supernode, before terminating analysis. + + .. gcc-param:: ranger-logical-depth + + Maximum depth of logical expression evaluation ranger will look through + when evaluating outgoing edge ranges. + + .. gcc-param:: relation-block-limit + + Maximum number of relations the oracle will register in a basic block. + + .. gcc-param:: min-pagesize + + Minimum page size for warning purposes. + + .. gcc-param:: openacc-kernels + + Specify mode of OpenACC 'kernels' constructs handling. + With :option:`--param` :gcc-param:`openacc-kernels`:samp:`=decompose`, OpenACC 'kernels' + constructs are decomposed into parts, a sequence of compute + constructs, each then handled individually. + This is work in progress. + With :option:`--param` :gcc-param:`openacc-kernels`:samp:`=parloops`, OpenACC 'kernels' + constructs are handled by the :samp:`parloops` pass, en bloc. + This is the current default. + + .. gcc-param:: openacc-privatization + + Specify mode of OpenACC privatization diagnostics for + :option:`-fopt-info-omp-note` and applicable + :option:`-fdump-tree-*-details`. + With :option:`--param` :gcc-param:`openacc-privatization`:samp:`=quiet`, don't diagnose. + This is the current default. + With :option:`--param` :gcc-param:`openacc-privatization`:samp:`=noisy`, do diagnose. + + The following choices of :samp:`{name}` are available on AArch64 targets: + + .. gcc-param:: aarch64-sve-compare-costs + + When vectorizing for SVE, consider using 'unpacked' vectors for + smaller elements and use the cost model to pick the cheapest approach. + Also use the cost model to choose between SVE and Advanced SIMD vectorization. + + Using unpacked vectors includes storing smaller elements in larger + containers and accessing elements with extending loads and truncating + stores. + + .. gcc-param:: aarch64-float-recp-precision + + The number of Newton iterations for calculating the reciprocal for float type. + The precision of division is proportional to this param when division + approximation is enabled. The default value is 1. + + .. gcc-param:: aarch64-double-recp-precision + + The number of Newton iterations for calculating the reciprocal for double type. + The precision of division is propotional to this param when division + approximation is enabled. The default value is 2. + + .. gcc-param:: aarch64-autovec-preference + + Force an ISA selection strategy for auto-vectorization. Accepts values from + 0 to 4, inclusive. + + :samp:`0` + Use the default heuristics. + + :samp:`1` + Use only Advanced SIMD for auto-vectorization. + + :samp:`2` + Use only SVE for auto-vectorization. + + :samp:`3` + Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are + deemed equal. + + :samp:`4` + Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal. + + The default value is 0. + + .. gcc-param:: aarch64-loop-vect-issue-rate-niters + + The tuning for some AArch64 CPUs tries to take both latencies and issue + rates into account when deciding whether a loop should be vectorized + using SVE, vectorized using Advanced SIMD, or not vectorized at all. + If this parameter is set to :samp:`{n}`, GCC will not use this heuristic + for loops that are known to execute in fewer than :samp:`{n}` Advanced + SIMD iterations. + + .. gcc-param:: aarch64-vect-unroll-limit + + The vectorizer will use available tuning information to determine whether it + would be beneficial to unroll the main vectorized loop and by how much. This + parameter set's the upper bound of how much the vectorizer will unroll the main + loop. The default value is four. + + The following choices of :samp:`{name}` are available on i386 and x86_64 targets: + + .. gcc-param:: x86-stlf-window-ninsns + + Instructions number above which STFL stall penalty can be compensated. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-that-control-static-analysis.rst b/gcc/doc/gcc/gcc-command-options/options-that-control-static-analysis.rst new file mode 100644 index 00000000000..a4e87a1c9e9 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-that-control-static-analysis.rst @@ -0,0 +1,1067 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _static-analyzer-options: + +Options That Control Static Analysis +************************************ + +.. option:: -fanalyzer + + This option enables an static analysis of program flow which looks + for 'interesting' interprocedural paths through the + code, and issues warnings for problems found on them. + + This analysis is much more expensive than other GCC warnings. + + Enabling this option effectively enables the following warnings: + + :option:`-Wanalyzer-allocation-size` |gol| + :option:`-Wanalyzer-double-fclose` |gol| + :option:`-Wanalyzer-double-free` |gol| + :option:`-Wanalyzer-exposure-through-output-file` |gol| + :option:`-Wanalyzer-exposure-through-uninit-copy` |gol| + :option:`-Wanalyzer-fd-access-mode-mismatch` |gol| + :option:`-Wanalyzer-fd-double-close` |gol| + :option:`-Wanalyzer-fd-leak` |gol| + :option:`-Wanalyzer-fd-use-after-close` |gol| + :option:`-Wanalyzer-fd-use-without-check` |gol| + :option:`-Wanalyzer-file-leak` |gol| + :option:`-Wanalyzer-free-of-non-heap` |gol| + :option:`-Wanalyzer-imprecise-fp-arithmetic` |gol| + :option:`-Wanalyzer-jump-through-null` |gol| + :option:`-Wanalyzer-malloc-leak` |gol| + :option:`-Wanalyzer-mismatching-deallocation` |gol| + :option:`-Wanalyzer-null-argument` |gol| + :option:`-Wanalyzer-null-dereference` |gol| + :option:`-Wanalyzer-out-of-bounds` |gol| + :option:`-Wanalyzer-possible-null-argument` |gol| + :option:`-Wanalyzer-possible-null-dereference` |gol| + :option:`-Wanalyzer-putenv-of-auto-var` |gol| + :option:`-Wanalyzer-shift-count-negative` |gol| + :option:`-Wanalyzer-shift-count-overflow` |gol| + :option:`-Wanalyzer-stale-setjmp-buffer` |gol| + :option:`-Wanalyzer-unsafe-call-within-signal-handler` |gol| + :option:`-Wanalyzer-use-after-free` |gol| + :option:`-Wanalyzer-use-of-pointer-in-stale-stack-frame` |gol| + :option:`-Wanalyzer-use-of-uninitialized-value` |gol| + :option:`-Wanalyzer-va-arg-type-mismatch` |gol| + :option:`-Wanalyzer-va-list-exhausted` |gol| + :option:`-Wanalyzer-va-list-leak` |gol| + :option:`-Wanalyzer-va-list-use-after-va-end` |gol| + :option:`-Wanalyzer-write-to-const` |gol| + :option:`-Wanalyzer-write-to-string-literal` + +.. option:: -fno-analyzer + + Default setting; overrides :option:`-fanalyzer`. + +.. option:: -Wanalyzer-too-complex + + If :option:`-fanalyzer` is enabled, the analyzer uses various heuristics + to attempt to explore the control flow and data flow in the program, + but these can be defeated by sufficiently complicated code. + + By default, the analysis silently stops if the code is too + complicated for the analyzer to fully explore and it reaches an internal + limit. The :option:`-Wanalyzer-too-complex` option warns if this occurs. + +.. option:: -Wno-analyzer-too-complex + + Default setting; overrides :option:`-Wanalyzer-too-complex`. + +.. option:: -Wno-analyzer-allocation-size + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-allocation-size` + to disable it. + + This diagnostic warns for paths through the code in which a pointer to + a buffer is assigned to point at a buffer with a size that is not a + multiple of ``sizeof (*pointer)``. + + See `CWE-131: Incorrect Calculation of Buffer Size `_. + +.. option:: -Wanalyzer-allocation-size + + Default setting; overrides :option:`-Wno-analyzer-allocation-size`. + +.. option:: -Wno-analyzer-double-fclose + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-double-fclose` to disable it. + + This diagnostic warns for paths through the code in which a ``FILE *`` + can have ``fclose`` called on it more than once. + + See `CWE-1341: Multiple Releases of Same Resource or Handle `_. + +.. option:: -Wanalyzer-double-fclose + + Default setting; overrides :option:`-Wno-analyzer-double-fclose`. + +.. option:: -Wno-analyzer-double-free + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-double-free` to disable it. + + This diagnostic warns for paths through the code in which a pointer + can have a deallocator called on it more than once, either ``free``, + or a deallocator referenced by attribute ``malloc``. + + See `CWE-415: Double Free `_. + +.. option:: -Wanalyzer-double-free + + Default setting; overrides :option:`-Wno-analyzer-double-free`. + +.. option:: -Wno-analyzer-exposure-through-output-file + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-exposure-through-output-file` + to disable it. + + This diagnostic warns for paths through the code in which a + security-sensitive value is written to an output file + (such as writing a password to a log file). + + See `CWE-532: Information Exposure Through Log Files `_. + +.. option:: -Wanalyzer-exposure-through-output-file + + Default setting; overrides :option:`-Wno-analyzer-exposure-through-output-file`. + +.. option:: -Wanalyzer-exposure-through-uninit-copy + + This warning requires both :option:`-fanalyzer` and the use of a plugin + to specify a function that copies across a 'trust boundary'. Use + :option:`-Wno-analyzer-exposure-through-uninit-copy` to disable it. + + This diagnostic warns for 'infoleaks' - paths through the code in which + uninitialized values are copied across a security boundary + (such as code within an OS kernel that copies a partially-initialized + struct on the stack to user space). + + See `CWE-200: Exposure of Sensitive Information to an Unauthorized Actor `_. + +.. option:: -Wno-analyzer-exposure-through-uninit-copy + + Default setting; overrides :option:`-Wanalyzer-exposure-through-uninit-copy`. + +.. option:: -Wno-analyzer-fd-access-mode-mismatch + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-fd-access-mode-mismatch` + to disable it. + + This diagnostic warns for paths through code in which a + ``read`` on a write-only file descriptor is attempted, or vice versa. + + This diagnostic also warns for code paths in a which a function with attribute + ``fd_arg_read (N)`` is called with a file descriptor opened with + ``O_WRONLY`` at referenced argument ``N`` or a function with attribute + ``fd_arg_write (N)`` is called with a file descriptor opened with + ``O_RDONLY`` at referenced argument :samp:`{N}`. + +.. option:: -Wanalyzer-fd-access-mode-mismatch + + Default setting; overrides :option:`-Wno-analyzer-fd-access-mode-mismatch`. + +.. option:: -Wno-analyzer-fd-double-close + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-fd-double-close` + to disable it. + + This diagnostic warns for paths through code in which a + file descriptor can be closed more than once. + + See `CWE-1341: Multiple Releases of Same Resource or Handle `_. + +.. option:: -Wanalyzer-fd-double-close + + Default setting; overrides :option:`-Wno-analyzer-fd-double-close`. + +.. option:: -Wno-analyzer-fd-leak + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-fd-leak` + to disable it. + + This diagnostic warns for paths through code in which an + open file descriptor is leaked. + + See `CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime `_. + +.. option:: -Wanalyzer-fd-leak + + Default setting; overrides :option:`-Wno-analyzer-fd-leak`. + +.. option:: -Wno-analyzer-fd-use-after-close + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-fd-use-after-close` + to disable it. + + This diagnostic warns for paths through code in which a + read or write is called on a closed file descriptor. + + This diagnostic also warns for paths through code in which + a function with attribute ``fd_arg (N)`` or ``fd_arg_read (N)`` + or ``fd_arg_write (N)`` is called with a closed file descriptor at + referenced argument ``N``. + +.. option:: -Wanalyzer-fd-use-after-close + + Default setting; overrides :option:`-Wno-analyzer-fd-use-after-close`. + +.. option:: -Wno-analyzer-fd-use-without-check + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-fd-use-without-check` + to disable it. + + This diagnostic warns for paths through code in which a + file descriptor is used without being checked for validity. + + This diagnostic also warns for paths through code in which + a function with attribute ``fd_arg (N)`` or ``fd_arg_read (N)`` + or ``fd_arg_write (N)`` is called with a file descriptor, at referenced + argument ``N``, without being checked for validity. + +.. option:: -Wanalyzer-fd-use-without-check + + Default setting; overrides :option:`-Wno-analyzer-fd-use-without-check`. + +.. option:: -Wno-analyzer-file-leak + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-file-leak` + to disable it. + + This diagnostic warns for paths through the code in which a + ```` ``FILE *`` stream object is leaked. + + See `CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime `_. + +.. option:: -Wanalyzer-file-leak + + Default setting; overrides :option:`-Wno-analyzer-file-leak`. + +.. option:: -Wno-analyzer-free-of-non-heap + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-free-of-non-heap` + to disable it. + + This diagnostic warns for paths through the code in which ``free`` + is called on a non-heap pointer (e.g. an on-stack buffer, or a global). + + See `CWE-590: Free of Memory not on the Heap `_. + +.. option:: -Wanalyzer-free-of-non-heap + + Default setting; overrides :option:`-Wno-analyzer-free-of-non-heap`. + +.. option:: -Wno-analyzer-imprecise-fp-arithmetic + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-imprecise-fp-arithmetic` + to disable it. + + This diagnostic warns for paths through the code in which floating-point + arithmetic is used in locations where precise computation is needed. This + diagnostic only warns on use of floating-point operands inside the + calculation of an allocation size at the moment. + +.. option:: -Wanalyzer-imprecise-fp-arithmetic + + Default setting; overrides :option:`-Wno-analyzer-imprecise-fp-arithmetic`. + +.. option:: -Wno-analyzer-jump-through-null + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-jump-through-null` + to disable it. + + This diagnostic warns for paths through the code in which a ``NULL`` + function pointer is called. + +.. option:: -Wanalyzer-jump-through-null + + Default setting; overrides :option:`-Wno-analyzer-jump-through-null`. + +.. option:: -Wno-analyzer-malloc-leak + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-malloc-leak` + to disable it. + + This diagnostic warns for paths through the code in which a + pointer allocated via an allocator is leaked: either ``malloc``, + or a function marked with attribute ``malloc``. + + See `CWE-401: Missing Release of Memory after Effective Lifetime `_. + +.. option:: -Wanalyzer-malloc-leak + + Default setting; overrides :option:`-Wno-analyzer-malloc-leak`. + +.. option:: -Wno-analyzer-mismatching-deallocation + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-mismatching-deallocation` + to disable it. + + This diagnostic warns for paths through the code in which the + wrong deallocation function is called on a pointer value, based on + which function was used to allocate the pointer value. The diagnostic + will warn about mismatches between ``free``, scalar ``delete`` + and vector ``delete[]``, and those marked as allocator/deallocator + pairs using attribute ``malloc``. + + See `CWE-762: Mismatched Memory Management Routines `_. + +.. option:: -Wanalyzer-mismatching-deallocation + + Default setting; overrides :option:`-Wno-analyzer-mismatching-deallocation`. + +.. option:: -Wno-analyzer-out-of-bounds + + This warning requires :option:`-fanalyzer` to enable it; use + :option:`-Wno-analyzer-out-of-bounds` to disable it. + + This diagnostic warns for path through the code in which a buffer is + definitely read or written out-of-bounds. The diagnostic applies for + cases where the analyzer is able to determine a constant offset and for + accesses past the end of a buffer, also a constant capacity. Further, + the diagnostic does limited checking for accesses past the end when the + offset as well as the capacity is symbolic. + + See `CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer `_. + +.. option:: -Wanalyzer-out-of-bounds + + Default setting; overrides :option:`-Wno-analyzer-out-of-bounds`. + +.. option:: -Wno-analyzer-possible-null-argument + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-possible-null-argument` to disable it. + + This diagnostic warns for paths through the code in which a + possibly-NULL value is passed to a function argument marked + with ``__attribute__((nonnull))`` as requiring a non-NULL + value. + + See `CWE-690: Unchecked Return Value to NULL Pointer Dereference `_. + +.. option:: -Wanalyzer-possible-null-argument + + Default setting; overrides :option:`-Wno-analyzer-possible-null-argument`. + +.. option:: -Wno-analyzer-possible-null-dereference + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-possible-null-dereference` to disable it. + + This diagnostic warns for paths through the code in which a + possibly-NULL value is dereferenced. + + See `CWE-690: Unchecked Return Value to NULL Pointer Dereference `_. + +.. option:: -Wanalyzer-possible-null-dereference + + Default setting; overrides :option:`-Wno-analyzer-possible-null-dereference`. + +.. option:: -Wno-analyzer-null-argument + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-null-argument` to disable it. + + This diagnostic warns for paths through the code in which a + value known to be NULL is passed to a function argument marked + with ``__attribute__((nonnull))`` as requiring a non-NULL + value. + + See `CWE-476: NULL Pointer Dereference `_. + +.. option:: -Wanalyzer-null-argument + + Default setting; overrides :option:`-Wno-analyzer-null-argument`. + +.. option:: -Wno-analyzer-null-dereference + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-null-dereference` to disable it. + + This diagnostic warns for paths through the code in which a + value known to be NULL is dereferenced. + + See `CWE-476: NULL Pointer Dereference `_. + +.. option:: -Wanalyzer-null-dereference + + Default setting; overrides :option:`-Wno-analyzer-null-dereference`. + +.. option:: -Wno-analyzer-putenv-of-auto-var + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-putenv-of-auto-var` to disable it. + + This diagnostic warns for paths through the code in which a + call to ``putenv`` is passed a pointer to an automatic variable + or an on-stack buffer. + + See `POS34-C. Do not call putenv() with a pointer to an automatic variable as the argument `_. + +.. option:: -Wanalyzer-putenv-of-auto-var + + Default setting; overrides :option:`-Wno-analyzer-putenv-of-auto-var`. + +.. option:: -Wno-analyzer-shift-count-negative + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-shift-count-negative` to disable it. + + This diagnostic warns for paths through the code in which a + shift is attempted with a negative count. It is analogous to + the :option:`-Wshift-count-negative` diagnostic implemented in + the C/C++ front ends, but is implemented based on analyzing + interprocedural paths, rather than merely parsing the syntax tree. + However, the analyzer does not prioritize detection of such paths, so + false negatives are more likely relative to other warnings. + +.. option:: -Wanalyzer-shift-count-negative + + Default setting; overrides :option:`-Wno-analyzer-shift-count-negative`. + +.. option:: -Wno-analyzer-shift-count-overflow + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-shift-count-overflow` to disable it. + + This diagnostic warns for paths through the code in which a + shift is attempted with a count greater than or equal to the + precision of the operand's type. It is analogous to + the :option:`-Wshift-count-overflow` diagnostic implemented in + the C/C++ front ends, but is implemented based on analyzing + interprocedural paths, rather than merely parsing the syntax tree. + However, the analyzer does not prioritize detection of such paths, so + false negatives are more likely relative to other warnings. + +.. option:: -Wanalyzer-shift-count-overflow + + Default setting; overrides :option:`-Wno-analyzer-shift-count-overflow`. + +.. option:: -Wno-analyzer-stale-setjmp-buffer + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-stale-setjmp-buffer` to disable it. + + This diagnostic warns for paths through the code in which + ``longjmp`` is called to rewind to a ``jmp_buf`` relating + to a ``setjmp`` call in a function that has returned. + + When ``setjmp`` is called on a ``jmp_buf`` to record a rewind + location, it records the stack frame. The stack frame becomes invalid + when the function containing the ``setjmp`` call returns. Attempting + to rewind to it via ``longjmp`` would reference a stack frame that + no longer exists, and likely lead to a crash (or worse). + +.. option:: -Wanalyzer-stale-setjmp-buffer + + Default setting; overrides :option:`-Wno-analyzer-stale-setjmp-buffer`. + +.. option:: -Wno-analyzer-tainted-allocation-size + + This warning requires both :option:`-fanalyzer` and + :option:`-fanalyzer-checker=taint` to enable it; + use :option:`-Wno-analyzer-tainted-allocation-size` to disable it. + + This diagnostic warns for paths through the code in which a value + that could be under an attacker's control is used as the size + of an allocation without being sanitized, so that an attacker could + inject an excessively large allocation and potentially cause a denial + of service attack. + + See `CWE-789: Memory Allocation with Excessive Size Value `_. + +.. option:: -Wanalyzer-tainted-allocation-size + + Default setting; overrides :option:`-Wno-analyzer-tainted-allocation-size`. + +.. option:: -Wno-analyzer-tainted-array-index + + This warning requires both :option:`-fanalyzer` and + :option:`-fanalyzer-checker=taint` to enable it; + use :option:`-Wno-analyzer-tainted-array-index` to disable it. + + This diagnostic warns for paths through the code in which a value + that could be under an attacker's control is used as the index + of an array access without being sanitized, so that an attacker + could inject an out-of-bounds access. + + See `CWE-129: Improper Validation of Array Index `_. + +.. option:: -Wanalyzer-tainted-array-index + + Default setting; overrides :option:`-Wno-analyzer-tainted-array-index`. + +.. option:: -Wno-analyzer-tainted-divisor + + This warning requires both :option:`-fanalyzer` and + :option:`-fanalyzer-checker=taint` to enable it; + use :option:`-Wno-analyzer-tainted-divisor` to disable it. + + This diagnostic warns for paths through the code in which a value + that could be under an attacker's control is used as the divisor + in a division or modulus operation without being sanitized, so that + an attacker could inject a division-by-zero. + + See `CWE-369: Divide By Zero `_. + +.. option:: -Wanalyzer-tainted-divisor + + Default setting; overrides :option:`-Wno-analyzer-tainted-divisor`. + +.. option:: -Wno-analyzer-tainted-offset + + This warning requires both :option:`-fanalyzer` and + :option:`-fanalyzer-checker=taint` to enable it; + use :option:`-Wno-analyzer-tainted-offset` to disable it. + + This diagnostic warns for paths through the code in which a value + that could be under an attacker's control is used as a pointer offset + without being sanitized, so that an attacker could inject an out-of-bounds + access. + + See `CWE-823: Use of Out-of-range Pointer Offset `_. + +.. option:: -Wanalyzer-tainted-offset + + Default setting; overrides :option:`-Wno-analyzer-tainted-offset`. + +.. option:: -Wno-analyzer-tainted-size + + This warning requires both :option:`-fanalyzer` and + :option:`-fanalyzer-checker=taint` to enable it; + use :option:`-Wno-analyzer-tainted-size` to disable it. + + This diagnostic warns for paths through the code in which a value + that could be under an attacker's control is used as the size of + an operation such as ``memset`` without being sanitized, so that an + attacker could inject an out-of-bounds access. + + See `CWE-129: Improper Validation of Array Index `_. + +.. option:: -Wanalyzer-tainted-size + + Default setting; overrides :option:`-Wno-analyzer-tainted-size`. + +.. option:: -Wno-analyzer-unsafe-call-within-signal-handler + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-unsafe-call-within-signal-handler` to disable it. + + This diagnostic warns for paths through the code in which a + function known to be async-signal-unsafe (such as ``fprintf``) is + called from a signal handler. + + See `CWE-479: Signal Handler Use of a Non-reentrant Function `_. + +.. option:: -Wanalyzer-unsafe-call-within-signal-handler + + Default setting; overrides :option:`-Wno-analyzer-unsafe-call-within-signal-handler`. + +.. option:: -Wno-analyzer-use-after-free + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-use-after-free` to disable it. + + This diagnostic warns for paths through the code in which a + pointer is used after a deallocator is called on it: either ``free``, + or a deallocator referenced by attribute ``malloc``. + + See `CWE-416: Use After Free `_. + +.. option:: -Wanalyzer-use-after-free + + Default setting; overrides :option:`-Wno-analyzer-use-after-free`. + +.. option:: -Wno-analyzer-use-of-pointer-in-stale-stack-frame + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-use-of-pointer-in-stale-stack-frame` + to disable it. + + This diagnostic warns for paths through the code in which a pointer + is dereferenced that points to a variable in a stale stack frame. + +.. option:: -Wanalyzer-use-of-pointer-in-stale-stack-frame + + Default setting; overrides :option:`-Wno-analyzer-use-of-pointer-in-stale-stack-frame`. + +.. option:: -Wno-analyzer-va-arg-type-mismatch + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-va-arg-type-mismatch` + to disable it. + + This diagnostic warns for interprocedural paths through the code for which + the analyzer detects an attempt to use ``va_arg`` to extract a value + passed to a variadic call, but uses a type that does not match that of + the expression passed to the call. + + See `CWE-686: Function Call With Incorrect Argument Type `_. + +.. option:: -Wanalyzer-va-arg-type-mismatch + + Default setting; overrides :option:`-Wno-analyzer-va-arg-type-mismatch`. + +.. option:: -Wno-analyzer-va-list-exhausted + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-va-list-exhausted` + to disable it. + + This diagnostic warns for interprocedural paths through the code for which + the analyzer detects an attempt to use ``va_arg`` to access the next + value passed to a variadic call, but all of the values in the + ``va_list`` have already been consumed. + + See `CWE-685: Function Call With Incorrect Number of Arguments `_. + +.. option:: -Wanalyzer-va-list-exhausted + + Default setting; overrides :option:`-Wno-analyzer-va-list-exhausted`. + +.. option:: -Wno-analyzer-va-list-leak + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-va-list-leak` + to disable it. + + This diagnostic warns for interprocedural paths through the code for which + the analyzer detects that ``va_start`` or ``va_copy`` has been called + on a ``va_list`` without a corresponding call to ``va_end``. + +.. option:: -Wanalyzer-va-list-leak + + Default setting; overrides :option:`-Wno-analyzer-va-list-leak`. + +.. option:: -Wno-analyzer-va-list-use-after-va-end + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-va-list-use-after-va-end` + to disable it. + + This diagnostic warns for interprocedural paths through the code for which + the analyzer detects an attempt to use a ``va_list`` after + ``va_end`` has been called on it. + ``va_list``. + +.. option:: -Wanalyzer-va-list-use-after-va-end + + Default setting; overrides :option:`-Wno-analyzer-va-list-use-after-va-end`. + +.. option:: -Wno-analyzer-write-to-const + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-write-to-const` + to disable it. + + This diagnostic warns for paths through the code in which the analyzer + detects an attempt to write through a pointer to a ``const`` object. + However, the analyzer does not prioritize detection of such paths, so + false negatives are more likely relative to other warnings. + +.. option:: -Wanalyzer-write-to-const + + Default setting; overrides :option:`-Wno-analyzer-write-to-const`. + +.. option:: -Wno-analyzer-write-to-string-literal + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-write-to-string-literal` + to disable it. + + This diagnostic warns for paths through the code in which the analyzer + detects an attempt to write through a pointer to a string literal. + However, the analyzer does not prioritize detection of such paths, so + false negatives are more likely relative to other warnings. + +.. option:: -Wanalyzer-write-to-string-literal + + Default setting; overrides :option:`-Wno-analyzer-write-to-string-literal`. + +.. option:: -Wno-analyzer-use-of-uninitialized-value + + This warning requires :option:`-fanalyzer`, which enables it; use + :option:`-Wno-analyzer-use-of-uninitialized-value` to disable it. + + This diagnostic warns for paths through the code in which an uninitialized + value is used. + + See `CWE-457: Use of Uninitialized Variable `_. + +.. option:: -Wanalyzer-use-of-uninitialized-value + + Default setting; overrides :option:`-Wno-analyzer-use-of-uninitialized-value`. + +The analyzer has hardcoded knowledge about the behavior of the following +memory-management functions: + +* ``alloca`` +* The built-in functions ``__builtin_alloc``, + ``__builtin_alloc_with_align``, ``__builtin_calloc``, + ``__builtin_free``, ``__builtin_malloc``, ``__builtin_memcpy``, + ``__builtin_memcpy_chk``, ``__builtin_memset``, + ``__builtin_memset_chk``, ``__builtin_realloc``, + ``__builtin_stack_restore``, and ``__builtin_stack_save`` +* ``calloc`` +* ``free`` +* ``malloc`` +* ``memset`` +* ``operator delete`` +* ``operator delete []`` +* ``operator new`` +* ``operator new []`` +* ``realloc`` +* ``strdup`` +* ``strndup`` + +of the following functions for working with file descriptors: + +* ``open`` +* ``close`` +* ``creat`` +* ``dup``, ``dup2`` and ``dup3`` +* ``pipe`` and ``pipe2`` +* ``read`` +* ``write`` + +of the following functions for working with ```` streams: + +* The built-in functions ``__builtin_fprintf``, + ``__builtin_fprintf_unlocked``, ``__builtin_fputc``, + ``__builtin_fputc_unlocked``, ``__builtin_fputs``, + ``__builtin_fputs_unlocked``, ``__builtin_fwrite``, + ``__builtin_fwrite_unlocked``, ``__builtin_printf``, + ``__builtin_printf_unlocked``, ``__builtin_putc``, + ``__builtin_putchar``, ``__builtin_putchar_unlocked``, + ``__builtin_putc_unlocked``, ``__builtin_puts``, + ``__builtin_puts_unlocked``, ``__builtin_vfprintf``, and + ``__builtin_vprintf`` +* ``fopen`` +* ``fclose`` +* ``fgets`` +* ``fgets_unlocked`` +* ``fread`` +* ``getchar`` +* ``fprintf`` +* ``printf`` +* ``fwrite`` + +and of the following functions: + +* The built-in functions ``__builtin_expect``, + ``__builtin_expect_with_probability``, ``__builtin_strchr``, + ``__builtin_strcpy``, ``__builtin_strcpy_chk``, + ``__builtin_strlen``, ``__builtin_va_copy``, and + ``__builtin_va_start`` + +* The GNU extensions ``error`` and ``error_at_line`` + +* ``getpass`` +* ``longjmp`` +* ``putenv`` +* ``setjmp`` +* ``siglongjmp`` +* ``signal`` +* ``sigsetjmp`` +* ``strchr`` +* ``strlen`` + +In addition, various functions with an ``__analyzer_`` prefix have +special meaning to the analyzer, described in the GCC Internals manual. + +Pertinent parameters for controlling the exploration are: + +:option:`--param` :gcc-param:`analyzer-bb-explosion-factor`:samp:`={value}`, +:option:`--param` :gcc-param:`analyzer-max-enodes-per-program-point`:samp:`={value}`, +:option:`--param` :gcc-param:`analyzer-max-recursion-depth`:samp:`={value}` and +:option:`--param` :gcc-param:`analyzer-min-snodes-for-call-summary`:samp:`={value}`. + +The following options control the analyzer. + +.. option:: -fanalyzer-call-summaries + + Simplify interprocedural analysis by computing the effect of certain calls, + rather than exploring all paths through the function from callsite to each + possible return. + + If enabled, call summaries are only used for functions with more than one + call site, and that are sufficiently complicated (as per + :option:`--param` :gcc-param:`analyzer-min-snodes-for-call-summary`:samp:`={value}`). + +.. option:: -fno-analyzer-call-summaries + + Default setting; overrides :option:`-fanalyzer-call-summaries`. + +.. option:: -fanalyzer-checker={name} + + Restrict the analyzer to run just the named checker, and enable it. + + Some checkers are disabled by default (even with :option:`-fanalyzer`), + such as the ``taint`` checker that implements + :option:`-Wanalyzer-tainted-array-index`, and this option is required + to enable them. + + .. note:: + + Currently, :option:`-fanalyzer-checker=taint` disables the + following warnings from :option:`-fanalyzer` : + + :option:`-Wanalyzer-double-fclose` |gol| + :option:`-Wanalyzer-double-free` |gol| + :option:`-Wanalyzer-exposure-through-output-file` |gol| + :option:`-Wanalyzer-fd-access-mode-mismatch` |gol| + :option:`-Wanalyzer-fd-double-close` |gol| + :option:`-Wanalyzer-fd-leak` |gol| + :option:`-Wanalyzer-fd-use-after-close` |gol| + :option:`-Wanalyzer-fd-use-without-check` |gol| + :option:`-Wanalyzer-file-leak` |gol| + :option:`-Wanalyzer-free-of-non-heap` |gol| + :option:`-Wanalyzer-malloc-leak` |gol| + :option:`-Wanalyzer-mismatching-deallocation` |gol| + :option:`-Wanalyzer-null-argument` |gol| + :option:`-Wanalyzer-null-dereference` |gol| + :option:`-Wanalyzer-possible-null-argument` |gol| + :option:`-Wanalyzer-possible-null-dereference` |gol| + :option:`-Wanalyzer-unsafe-call-within-signal-handler` |gol| + :option:`-Wanalyzer-use-after-free` |gol| + :option:`-Wanalyzer-va-list-leak` |gol| + :option:`-Wanalyzer-va-list-use-after-va-end` + +.. option:: -fno-analyzer-feasibility + + This option is intended for analyzer developers. + + By default the analyzer verifies that there is a feasible control flow path + for each diagnostic it emits: that the conditions that hold are not mutually + exclusive. Diagnostics for which no feasible path can be found are rejected. + This filtering can be suppressed with :option:`-fno-analyzer-feasibility`, for + debugging issues in this code. + +.. option:: -fanalyzer-feasibility + + Default setting; overrides :option:`-fno-analyzer-feasibility`. + +.. option:: -fanalyzer-fine-grained + + This option is intended for analyzer developers. + + Internally the analyzer builds an 'exploded graph' that combines + control flow graphs with data flow information. + + By default, an edge in this graph can contain the effects of a run + of multiple statements within a basic block. With + :option:`-fanalyzer-fine-grained`, each statement gets its own edge. + +.. option:: -fno-analyzer-fine-grained + + Default setting; overrides :option:`-fanalyzer-fine-grained`. + +.. option:: -fanalyzer-show-duplicate-count + + This option is intended for analyzer developers: if multiple diagnostics + have been detected as being duplicates of each other, it emits a note when + reporting the best diagnostic, giving the number of additional diagnostics + that were suppressed by the deduplication logic. + +.. option:: -fno-analyzer-show-duplicate-count + + Default setting; overrides :option:`-fanalyzer-show-duplicate-count`. + +.. option:: -fno-analyzer-state-merge + + This option is intended for analyzer developers. + + By default the analyzer attempts to simplify analysis by merging + sufficiently similar states at each program point as it builds its + 'exploded graph'. With :option:`-fno-analyzer-state-merge` this + merging can be suppressed, for debugging state-handling issues. + +.. option:: -fanalyzer-state-merge + + Default setting; overrides :option:`-fno-analyzer-state-merge`. + +.. option:: -fno-analyzer-state-purge + + This option is intended for analyzer developers. + + By default the analyzer attempts to simplify analysis by purging + aspects of state at a program point that appear to no longer be relevant + e.g. the values of locals that aren't accessed later in the function + and which aren't relevant to leak analysis. + + With :option:`-fno-analyzer-state-purge` this purging of state can + be suppressed, for debugging state-handling issues. + +.. option:: -fanalyzer-state-purge + + Default setting; overrides :option:`-fno-analyzer-state-purge`. + +.. option:: -fanalyzer-transitivity + + This option enables transitivity of constraints within the analyzer. + +.. option:: -fno-analyzer-transitivity + + Default setting; overrides :option:`-fanalyzer-transitivity`. + +.. option:: -fno-analyzer-undo-inlining + + This option is intended for analyzer developers. + + :option:`-fanalyzer` runs relatively late compared to other code analysis + tools, and some optimizations have already been applied to the code. In + particular function inlining may have occurred, leading to the + interprocedural execution paths emitted by the analyzer containing + function frames that don't correspond to those in the original source + code. + + By default the analyzer attempts to reconstruct the original function + frames, and to emit events showing the inlined calls. + + With :option:`-fno-analyzer-undo-inlining` this attempt to reconstruct + the original frame information can be be disabled, which may be of help + when debugging issues in the analyzer. + +.. option:: -fanalyzer-undo-inlining + + Default setting; overrides :option:`-fno-analyzer-undo-inlining`. + +.. option:: -fanalyzer-verbose-edges + + This option is intended for analyzer developers. It enables more + verbose, lower-level detail in the descriptions of control flow + within diagnostic paths. + +.. option:: -fanalyzer-verbose-state-changes + + This option is intended for analyzer developers. It enables more + verbose, lower-level detail in the descriptions of events relating + to state machines within diagnostic paths. + +.. option:: -fanalyzer-verbosity={level} + + This option controls the complexity of the control flow paths that are + emitted for analyzer diagnostics. + + The :samp:`{level}` can be one of: + + :samp:`0` + At this level, interprocedural call and return events are displayed, + along with the most pertinent state-change events relating to + a diagnostic. For example, for a double- ``free`` diagnostic, + both calls to ``free`` will be shown. + + :samp:`1` + As per the previous level, but also show events for the entry + to each function. + + :samp:`2` + As per the previous level, but also show events relating to + control flow that are significant to triggering the issue + (e.g. 'true path taken' at a conditional). + + This level is the default. + + :samp:`3` + As per the previous level, but show all control flow events, not + just significant ones. + + :samp:`4` + This level is intended for analyzer developers; it adds various + other events intended for debugging the analyzer. + +.. option:: -fdump-analyzer + + Dump internal details about what the analyzer is doing to + :samp:`{file}.analyzer.txt`. + This option is overridden by :option:`-fdump-analyzer-stderr`. + +.. option:: -fdump-analyzer-stderr + + Dump internal details about what the analyzer is doing to stderr. + This option overrides :option:`-fdump-analyzer`. + +.. option:: -fdump-analyzer-callgraph + + Dump a representation of the call graph suitable for viewing with + GraphViz to :samp:`{file}.callgraph.dot`. + +.. option:: -fdump-analyzer-exploded-graph + + Dump a representation of the 'exploded graph' suitable for viewing with + GraphViz to :samp:`{file}.eg.dot`. + Nodes are color-coded based on state-machine states to emphasize + state changes. + +.. option:: -fdump-analyzer-exploded-nodes + + Emit diagnostics showing where nodes in the 'exploded graph' are + in relation to the program source. + +.. option:: -fdump-analyzer-exploded-nodes-2 + + Dump a textual representation of the 'exploded graph' to + :samp:`{file}.eg.txt`. + +.. option:: -fdump-analyzer-exploded-nodes-3 + + Dump a textual representation of the 'exploded graph' to + one dump file per node, to :samp:`{file}.eg-{id}.txt`. + This is typically a large number of dump files. + +.. option:: -fdump-analyzer-exploded-paths + + Dump a textual representation of the 'exploded path' for each + diagnostic to :samp:`{file}.{idx}.{kind}.epath.txt`. + +.. option:: -fdump-analyzer-feasibility + + Dump internal details about the analyzer's search for feasible paths. + The details are written in a form suitable for viewing with GraphViz + to filenames of the form :samp:`{file}.*.fg.dot`, + :samp:`{file}.*.tg.dot`, and :samp:`{file}.*.fpath.txt`. + +.. option:: -fdump-analyzer-json + + Dump a compressed JSON representation of analyzer internals to + :samp:`{file}.analyzer.json.gz`. The precise format is subject + to change. + +.. option:: -fdump-analyzer-state-purge + + As per :option:`-fdump-analyzer-supergraph`, dump a representation of the + 'supergraph' suitable for viewing with GraphViz, but annotate the + graph with information on what state will be purged at each node. + The graph is written to :samp:`{file}.state-purge.dot`. + +.. option:: -fdump-analyzer-supergraph + + Dump representations of the 'supergraph' suitable for viewing with + GraphViz to :samp:`{file}.supergraph.dot` and to + :samp:`{file}.supergraph-eg.dot`. These show all of the + control flow graphs in the program, with interprocedural edges for + calls and returns. The second dump contains annotations showing nodes + in the 'exploded graph' and diagnostics associated with them. + +.. option:: -fdump-analyzer-untracked + + Emit custom warnings with internal details intended for analyzer developers. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-to-control-diagnostic-messages-formatting.rst b/gcc/doc/gcc/gcc-command-options/options-to-control-diagnostic-messages-formatting.rst new file mode 100644 index 00000000000..ea38381acf8 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-to-control-diagnostic-messages-formatting.rst @@ -0,0 +1,899 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: options to control diagnostics formatting, diagnostic messages, message formatting + +.. _diagnostic-message-formatting-options: + +Options to Control Diagnostic Messages Formatting +************************************************* + +Traditionally, diagnostic messages have been formatted irrespective of +the output device's aspect (e.g. its width, ...). You can use the +options described below +to control the formatting algorithm for diagnostic messages, +e.g. how many characters per line, how often source location +information should be reported. Note that some language front ends may not +honor these options. + +.. option:: -fmessage-length={n} + + Try to format error messages so that they fit on lines of about + :samp:`{n}` characters. If :samp:`{n}` is zero, then no line-wrapping is + done; each error message appears on a single line. This is the + default for all front ends. + + Note - this option also affects the display of the :samp:`#error` and + :samp:`#warning` pre-processor directives, and the :samp:`deprecated` + function/type/variable attribute. It does not however affect the + :samp:`pragma GCC warning` and :samp:`pragma GCC error` pragmas. + +.. option:: -fdiagnostics-plain-output + + This option requests that diagnostic output look as plain as possible, which + may be useful when running :command:`dejagnu` or other utilities that need to + parse diagnostics output and prefer that it remain more stable over time. + :option:`-fdiagnostics-plain-output` is currently equivalent to the following + options: + + :option:`-fno-diagnostics-show-caret` |gol| + :option:`-fno-diagnostics-show-line-numbers` |gol| + :option:`-fdiagnostics-color=never` |gol| + :option:`-fdiagnostics-urls=never` |gol| + :option:`-fdiagnostics-path-format=separate-events` + In the future, if GCC changes the default appearance of its diagnostics, the + corresponding option to disable the new behavior will be added to this list. + +.. option:: -fdiagnostics-show-location=once + + Only meaningful in line-wrapping mode. Instructs the diagnostic messages + reporter to emit source location information *once*; that is, in + case the message is too long to fit on a single physical line and has to + be wrapped, the source location won't be emitted (as prefix) again, + over and over, in subsequent continuation lines. This is the default + behavior. + +.. option:: -fdiagnostics-show-location=every-line + + Only meaningful in line-wrapping mode. Instructs the diagnostic + messages reporter to emit the same source location information (as + prefix) for physical lines that result from the process of breaking + a message which is too long to fit on a single line. + +.. index:: highlight, color, GCC_COLORS environment variable + +.. option:: -fdiagnostics-color[={WHEN}] + + Use color in diagnostics. :samp:`{WHEN}` is :samp:`never`, :samp:`always`, + or :samp:`auto`. The default depends on how the compiler has been configured, + it can be any of the above :samp:`{WHEN}` options or also :samp:`never` + if :envvar:`GCC_COLORS` environment variable isn't present in the environment, + and :samp:`auto` otherwise. + :samp:`auto` makes GCC use color only when the standard error is a terminal, + and when not executing in an emacs shell. + The forms :option:`-fdiagnostics-color` and :option:`-fno-diagnostics-color` are + aliases for :option:`-fdiagnostics-color=always` and + :option:`-fdiagnostics-color=never`, respectively. + + The colors are defined by the environment variable :envvar:`GCC_COLORS`. + Its value is a colon-separated list of capabilities and Select Graphic + Rendition (SGR) substrings. SGR commands are interpreted by the + terminal or terminal emulator. (See the section in the documentation + of your text terminal for permitted values and their meanings as + character attributes.) These substring values are integers in decimal + representation and can be concatenated with semicolons. + Common values to concatenate include + :samp:`1` for bold, + :samp:`4` for underline, + :samp:`5` for blink, + :samp:`7` for inverse, + :samp:`39` for default foreground color, + :samp:`30` to :samp:`37` for foreground colors, + :samp:`90` to :samp:`97` for 16-color mode foreground colors, + :samp:`38;5;0` to :samp:`38;5;255` + for 88-color and 256-color modes foreground colors, + :samp:`49` for default background color, + :samp:`40` to :samp:`47` for background colors, + :samp:`100` to :samp:`107` for 16-color mode background colors, + and :samp:`48;5;0` to :samp:`48;5;255` + for 88-color and 256-color modes background colors. + + The default :envvar:`GCC_COLORS` is + + .. code-block:: + + error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\ + quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\ + diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\ + type-diff=01;32:fnname=01;32:targs=35 + + where :samp:`01;31` is bold red, :samp:`01;35` is bold magenta, + :samp:`01;36` is bold cyan, :samp:`32` is green, :samp:`34` is blue, + :samp:`01` is bold, and :samp:`31` is red. + Setting :envvar:`GCC_COLORS` to the empty string disables colors. + Supported capabilities are as follows. + + ``error=`` + + .. index:: error GCC_COLORS capability + + SGR substring for error: markers. + + ``warning=`` + + .. index:: warning GCC_COLORS capability + + SGR substring for warning: markers. + + ``note=`` + + .. index:: note GCC_COLORS capability + + SGR substring for note: markers. + + ``path=`` + + .. index:: path GCC_COLORS capability + + SGR substring for colorizing paths of control-flow events as printed + via :option:`-fdiagnostics-path-format=`, such as the identifiers of + individual events and lines indicating interprocedural calls and returns. + + ``range1=`` + + .. index:: range1 GCC_COLORS capability + + SGR substring for first additional range. + + ``range2=`` + + .. index:: range2 GCC_COLORS capability + + SGR substring for second additional range. + + ``locus=`` + + .. index:: locus GCC_COLORS capability + + SGR substring for location information, :samp:`file:line` or + :samp:`file:line:column` etc. + + ``quote=`` + + .. index:: quote GCC_COLORS capability + + SGR substring for information printed within quotes. + + ``fnname=`` + + .. index:: fnname GCC_COLORS capability + + SGR substring for names of C++ functions. + + ``targs=`` + + .. index:: targs GCC_COLORS capability + + SGR substring for C++ function template parameter bindings. + + ``fixit-insert=`` + + .. index:: fixit-insert GCC_COLORS capability + + SGR substring for fix-it hints suggesting text to + be inserted or replaced. + + ``fixit-delete=`` + + .. index:: fixit-delete GCC_COLORS capability + + SGR substring for fix-it hints suggesting text to + be deleted. + + ``diff-filename=`` + + .. index:: diff-filename GCC_COLORS capability + + SGR substring for filename headers within generated patches. + + ``diff-hunk=`` + + .. index:: diff-hunk GCC_COLORS capability + + SGR substring for the starts of hunks within generated patches. + + ``diff-delete=`` + + .. index:: diff-delete GCC_COLORS capability + + SGR substring for deleted lines within generated patches. + + ``diff-insert=`` + + .. index:: diff-insert GCC_COLORS capability + + SGR substring for inserted lines within generated patches. + + ``type-diff=`` + + .. index:: type-diff GCC_COLORS capability + + SGR substring for highlighting mismatching types within template + arguments in the C++ frontend. + +.. option:: -fdiagnostics-color + + Default setting; overrides :option:`-fno-diagnostics-color`. + +.. index:: urls, GCC_URLS environment variable, TERM_URLS environment variable + +.. option:: -fdiagnostics-urls[={WHEN}] + + Use escape sequences to embed URLs in diagnostics. For example, when + :option:`-fdiagnostics-show-option` emits text showing the command-line + option controlling a diagnostic, embed a URL for documentation of that + option. + + :samp:`{WHEN}` is :samp:`never`, :samp:`always`, or :samp:`auto`. + :samp:`auto` makes GCC use URL escape sequences only when the standard error + is a terminal, and when not executing in an emacs shell or any graphical + terminal which is known to be incompatible with this feature, see below. + + The default depends on how the compiler has been configured. + It can be any of the above :samp:`{WHEN}` options. + + GCC can also be configured (via the + :option:`--with-diagnostics-urls=auto-if-env` configure-time option) + so that the default is affected by environment variables. + Under such a configuration, GCC defaults to using :samp:`auto` + if either :envvar:`GCC_URLS` or :envvar:`TERM_URLS` environment variables are + present and non-empty in the environment of the compiler, or :samp:`never` + if neither are. + + However, even with :option:`-fdiagnostics-urls=always` the behavior is + dependent on those environment variables: + If :envvar:`GCC_URLS` is set to empty or :samp:`no`, do not embed URLs in + diagnostics. If set to :samp:`st`, URLs use ST escape sequences. + If set to :samp:`bel`, the default, URLs use BEL escape sequences. + Any other non-empty value enables the feature. + If :envvar:`GCC_URLS` is not set, use :envvar:`TERM_URLS` as a fallback. + Note: ST is an ANSI escape sequence, string terminator :samp:`ESC \\`, + BEL is an ASCII character, CTRL-G that usually sounds like a beep. + + At this time GCC tries to detect also a few terminals that are known to + not implement the URL feature, and have bugs or at least had bugs in + some versions that are still in use, where the URL escapes are likely + to misbehave, i.e. print garbage on the screen. + That list is currently xfce4-terminal, certain known to be buggy + gnome-terminal versions, the linux console, and mingw. + This check can be skipped with the :option:`-fdiagnostics-urls=always`. + +.. option:: -fno-diagnostics-show-option + + By default, each diagnostic emitted includes text indicating the + command-line option that directly controls the diagnostic (if such an + option is known to the diagnostic machinery). Specifying the + :option:`-fno-diagnostics-show-option` flag suppresses that behavior. + +.. option:: -fdiagnostics-show-option + + Default setting; overrides :option:`-fno-diagnostics-show-option`. + +.. option:: -fno-diagnostics-show-caret + + By default, each diagnostic emitted includes the original source line + and a caret :samp:`^` indicating the column. This option suppresses this + information. The source line is truncated to :samp:`{n}` characters, if + the :option:`-fmessage-length=n` option is given. When the output is done + to the terminal, the width is limited to the width given by the + :envvar:`COLUMNS` environment variable or, if not set, to the terminal width. + +.. option:: -fdiagnostics-show-caret + + Default setting; overrides :option:`-fno-diagnostics-show-caret`. + +.. option:: -fno-diagnostics-show-labels + + By default, when printing source code (via :option:`-fdiagnostics-show-caret`), + diagnostics can label ranges of source code with pertinent information, such + as the types of expressions: + + .. code-block:: + + printf ("foo %s bar", long_i + long_j); + ~^ ~~~~~~~~~~~~~~~ + | | + char * long int + + This option suppresses the printing of these labels (in the example above, + the vertical bars and the 'char \*' and 'long int' text). + +.. option:: -fdiagnostics-show-labels + + Default setting; overrides :option:`-fno-diagnostics-show-labels`. + +.. option:: -fno-diagnostics-show-cwe + + Diagnostic messages can optionally have an associated + `CWE `_ identifier. + GCC itself only provides such metadata for some of the :option:`-fanalyzer` + diagnostics. GCC plugins may also provide diagnostics with such metadata. + By default, if this information is present, it will be printed with + the diagnostic. This option suppresses the printing of this metadata. + +.. option:: -fdiagnostics-show-cwe + + Default setting; overrides :option:`-fno-diagnostics-show-cwe`. + +.. option:: -fno-diagnostics-show-rules + + Diagnostic messages can optionally have rules associated with them, such + as from a coding standard, or a specification. + GCC itself does not do this for any of its diagnostics, but plugins may do so. + By default, if this information is present, it will be printed with + the diagnostic. This option suppresses the printing of this metadata. + +.. option:: -fdiagnostics-show-rules + + Default setting; overrides :option:`-fno-diagnostics-show-rules`. + +.. option:: -fno-diagnostics-show-line-numbers + + By default, when printing source code (via :option:`-fdiagnostics-show-caret`), + a left margin is printed, showing line numbers. This option suppresses this + left margin. + +.. option:: -fdiagnostics-show-line-numbers + + Default setting; overrides :option:`-fno-diagnostics-show-line-numbers`. + +.. option:: -fdiagnostics-minimum-margin-width={width} + + This option controls the minimum width of the left margin printed by + :option:`-fdiagnostics-show-line-numbers`. It defaults to 6. + +.. option:: -fdiagnostics-parseable-fixits + + Emit fix-it hints in a machine-parseable format, suitable for consumption + by IDEs. For each fix-it, a line will be printed after the relevant + diagnostic, starting with the string 'fix-it:'. For example: + + .. code-block:: + + fix-it:"test.c":{45:3-45:21}:"gtk_widget_show_all" + + The location is expressed as a half-open range, expressed as a count of + bytes, starting at byte 1 for the initial column. In the above example, + bytes 3 through 20 of line 45 of 'test.c' are to be replaced with the + given string: + + .. code-block:: + + 00000000011111111112222222222 + 12345678901234567890123456789 + gtk_widget_showall (dlg); + ^^^^^^^^^^^^^^^^^^ + gtk_widget_show_all + + The filename and replacement string escape backslash as '\\", tab as '\t', + newline as '\n', double quotes as '\"', non-printable characters as octal + (e.g. vertical tab as '\013'). + + An empty replacement string indicates that the given range is to be removed. + An empty range (e.g. '45:3-45:3') indicates that the string is to + be inserted at the given position. + +.. option:: -fdiagnostics-generate-patch + + Print fix-it hints to stderr in unified diff format, after any diagnostics + are printed. For example: + + .. code-block:: diff + + --- test.c + +++ test.c + @ -42,5 +42,5 @ + + void show_cb(GtkDialog *dlg) + { + - gtk_widget_showall(dlg); + + gtk_widget_show_all(dlg); + } + + The diff may or may not be colorized, following the same rules + as for diagnostics (see :option:`-fdiagnostics-color`). + +.. option:: -fdiagnostics-show-template-tree + + In the C++ frontend, when printing diagnostics showing mismatching + template types, such as: + + .. code-block:: + + could not convert 'std::map >()' + from 'map<[...],vector>' to 'map<[...],vector> + + the :option:`-fdiagnostics-show-template-tree` flag enables printing a + tree-like structure showing the common and differing parts of the types, + such as: + + .. code-block:: + + map< + [...], + vector< + [double != float]>> + + The parts that differ are highlighted with color ('double' and + 'float' in this case). + +.. option:: -fno-elide-type + + By default when the C++ frontend prints diagnostics showing mismatching + template types, common parts of the types are printed as '[...]' to + simplify the error message. For example: + + .. code-block:: + + could not convert 'std::map >()' + from 'map<[...],vector>' to 'map<[...],vector> + + Specifying the :option:`-fno-elide-type` flag suppresses that behavior. + This flag also affects the output of the + :option:`-fdiagnostics-show-template-tree` flag. + +.. option:: -felide-type + + Default setting; overrides :option:`-fno-elide-type`. + +.. option:: -fdiagnostics-path-format={KIND} + + Specify how to print paths of control-flow events for diagnostics that + have such a path associated with them. + + :samp:`{KIND}` is :samp:`none`, :samp:`separate-events`, or :samp:`inline-events`, + the default. + + :samp:`none` means to not print diagnostic paths. + + :samp:`separate-events` means to print a separate 'note' diagnostic for + each event within the diagnostic. For example: + + .. code-block:: + + test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter + test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL + test.c:27:3: note: (2) when 'i < count' + test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 + + :samp:`inline-events` means to print the events 'inline' within the source + code. This view attempts to consolidate the events into runs of + sufficiently-close events, printing them as labelled ranges within the source. + + For example, the same events as above might be printed as: + + .. code-block:: + + 'test': events 1-3 + | + | 25 | list = PyList_New(0); + | | ^~~~~~~~~~~~~ + | | | + | | (1) when 'PyList_New' fails, returning NULL + | 26 | + | 27 | for (i = 0; i < count; i++) { + | | ~~~ + | | | + | | (2) when 'i < count' + | 28 | item = PyLong_FromLong(random()); + | 29 | PyList_Append(list, item); + | | ~~~~~~~~~~~~~~~~~~~~~~~~~ + | | | + | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 + | + + Interprocedural control flow is shown by grouping the events by stack frame, + and using indentation to show how stack frames are nested, pushed, and popped. + + For example: + + .. code-block:: + + 'test': events 1-2 + | + | 133 | { + | | ^ + | | | + | | (1) entering 'test' + | 134 | boxed_int *obj = make_boxed_int (i); + | | ~~~~~~~~~~~~~~~~~~ + | | | + | | (2) calling 'make_boxed_int' + | + +--> 'make_boxed_int': events 3-4 + | + | 120 | { + | | ^ + | | | + | | (3) entering 'make_boxed_int' + | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int)); + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | | | + | | (4) calling 'wrapped_malloc' + | + +--> 'wrapped_malloc': events 5-6 + | + | 7 | { + | | ^ + | | | + | | (5) entering 'wrapped_malloc' + | 8 | return malloc (size); + | | ~~~~~~~~~~~~~ + | | | + | | (6) calling 'malloc' + | + <-------------+ + | + 'test': event 7 + | + | 138 | free_boxed_int (obj); + | | ^~~~~~~~~~~~~~~~~~~~ + | | | + | | (7) calling 'free_boxed_int' + | + (etc) + +.. option:: -fdiagnostics-show-path-depths + + This option provides additional information when printing control-flow paths + associated with a diagnostic. + + If this is option is provided then the stack depth will be printed for + each run of events within :option:`-fdiagnostics-path-format=inline-events`. + If provided with :option:`-fdiagnostics-path-format=separate-events`, then + the stack depth and function declaration will be appended when printing + each event. + + This is intended for use by GCC developers and plugin developers when + debugging diagnostics that report interprocedural control flow. + +.. option:: -fno-show-column + + Do not print column numbers in diagnostics. This may be necessary if + diagnostics are being scanned by a program that does not understand the + column numbers, such as :command:`dejagnu`. + +.. option:: -fshow-column + + Default setting; overrides :option:`-fno-show-column`. + +.. option:: -fdiagnostics-column-unit={UNIT} + + Select the units for the column number. This affects traditional diagnostics + (in the absence of :option:`-fno-show-column`), as well as JSON format + diagnostics if requested. + + The default :samp:`{UNIT}`, :samp:`display`, considers the number of display + columns occupied by each character. This may be larger than the number + of bytes required to encode the character, in the case of tab + characters, or it may be smaller, in the case of multibyte characters. + For example, the character 'GREEK SMALL LETTER PI (U+03C0)' occupies one + display column, and its UTF-8 encoding requires two bytes; the character + 'SLIGHTLY SMILING FACE (U+1F642)' occupies two display columns, and + its UTF-8 encoding requires four bytes. + + Setting :samp:`{UNIT}` to :samp:`byte` changes the column number to the raw byte + count in all cases, as was traditionally output by GCC prior to version 11.1.0. + +.. option:: -fdiagnostics-column-origin={ORIGIN} + + Select the origin for column numbers, i.e. the column number assigned to the + first column. The default value of 1 corresponds to traditional GCC + behavior and to the GNU style guide. Some utilities may perform better with an + origin of 0; any non-negative value may be specified. + +.. option:: -fdiagnostics-escape-format={FORMAT} + + When GCC prints pertinent source lines for a diagnostic it normally attempts + to print the source bytes directly. However, some diagnostics relate to encoding + issues in the source file, such as malformed UTF-8, or issues with Unicode + normalization. These diagnostics are flagged so that GCC will escape bytes + that are not printable ASCII when printing their pertinent source lines. + + This option controls how such bytes should be escaped. + + The default :samp:`{FORMAT}`, :samp:`unicode` displays Unicode characters that + are not printable ASCII in the form :samp:``, and bytes that do not + correspond to a Unicode character validly-encoded in UTF-8-encoded will be + displayed as hexadecimal in the form :samp:``. + + For example, a source line containing the string :samp:`before` followed by the + Unicode character U+03C0 ('GREEK SMALL LETTER PI', with UTF-8 encoding + 0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by + the string :samp:`after` will be printed for such a diagnostic as: + + .. code-block:: c++ + + beforeafter + + Setting :samp:`{FORMAT}` to :samp:`bytes` will display all non-printable-ASCII bytes + in the form :samp:``, thus showing the underlying encoding of non-ASCII + Unicode characters. For the example above, the following will be printed: + + .. code-block:: c++ + + before<80>after + +.. option:: -fdiagnostics-format={FORMAT} + + Select a different format for printing diagnostics. + :samp:`{FORMAT}` is :samp:`text`, :samp:`sarif-stderr`, :samp:`sarif-file`, + :samp:`json`, :samp:`json-stderr`, or :samp:`json-file`. + + The default is :samp:`text`. + + The :samp:`sarif-stderr` and :samp:`sarif-file` formats both emit + diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file + named :samp:`{source}.sarif`, respectively. + + The :samp:`json` format is a synonym for :samp:`json-stderr`. + The :samp:`json-stderr` and :samp:`json-file` formats are identical, apart from + where the JSON is emitted to - with the former, the JSON is emitted to stderr, + whereas with :samp:`json-file` it is written to :samp:`{source}.gcc.json`. + + The emitted JSON consists of a top-level JSON array containing JSON objects + representing the diagnostics. The JSON is emitted as one line, without + formatting; the examples below have been formatted for clarity. + + Diagnostics can have child diagnostics. For example, this error and note: + + .. code-block:: + + misleading-indentation.c:15:3: warning: this 'if' clause does not + guard... [-Wmisleading-indentation] + 15 | if (flag) + | ^~ + misleading-indentation.c:17:5: note: ...this statement, but the latter + is misleadingly indented as if it were guarded by the 'if' + 17 | y = 2; + | ^ + + might be printed in JSON form (after formatting) like this: + + .. code-block:: json + + [ + { + "kind": "warning", + "locations": [ + { + "caret": { + "display-column": 3, + "byte-column": 3, + "column": 3, + "file": "misleading-indentation.c", + "line": 15 + }, + "finish": { + "display-column": 4, + "byte-column": 4, + "column": 4, + "file": "misleading-indentation.c", + "line": 15 + } + } + ], + "message": "this ‘if’ clause does not guard...", + "option": "-Wmisleading-indentation", + "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation", + "children": [ + { + "kind": "note", + "locations": [ + { + "caret": { + "display-column": 5, + "byte-column": 5, + "column": 5, + "file": "misleading-indentation.c", + "line": 17 + } + } + ], + "escape-source": false, + "message": "...this statement, but the latter is ..." + } + ] + "escape-source": false, + "column-origin": 1, + } + ] + + where the ``note`` is a child of the ``warning``. + + A diagnostic has a ``kind``. If this is ``warning``, then there is + an ``option`` key describing the command-line option controlling the + warning. + + A diagnostic can contain zero or more locations. Each location has an + optional ``label`` string and up to three positions within it: a + ``caret`` position and optional ``start`` and ``finish`` positions. + A position is described by a ``file`` name, a ``line`` number, and + three numbers indicating a column position: + + * ``display-column`` counts display columns, accounting for tabs and + multibyte characters. + + * ``byte-column`` counts raw bytes. + + * ``column`` is equal to one of + the previous two, as dictated by the :option:`-fdiagnostics-column-unit` + option. + + All three columns are relative to the origin specified by + :option:`-fdiagnostics-column-origin`, which is typically equal to 1 but may + be set, for instance, to 0 for compatibility with other utilities that + number columns from 0. The column origin is recorded in the JSON output in + the ``column-origin`` tag. In the remaining examples below, the extra + column number outputs have been omitted for brevity. + + For example, this error: + + .. code-block:: + + bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' {aka + 'struct s'} and 'T' {aka 'struct t'}) + 64 | return callee_4a () + callee_4b (); + | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ + | | | + | | T {aka struct t} + | S {aka struct s} + + has three locations. Its primary location is at the '+' token at column + 23. It has two secondary locations, describing the left and right-hand sides + of the expression, which have labels. It might be printed in JSON form as: + + .. code-block:: json + + { + "children": [], + "kind": "error", + "locations": [ + { + "caret": { + "column": 23, "file": "bad-binary-ops.c", "line": 64 + } + }, + { + "caret": { + "column": 10, "file": "bad-binary-ops.c", "line": 64 + }, + "finish": { + "column": 21, "file": "bad-binary-ops.c", "line": 64 + }, + "label": "S {aka struct s}" + }, + { + "caret": { + "column": 25, "file": "bad-binary-ops.c", "line": 64 + }, + "finish": { + "column": 36, "file": "bad-binary-ops.c", "line": 64 + }, + "label": "T {aka struct t}" + } + ], + "escape-source": false, + "message": "invalid operands to binary + ..." + } + + If a diagnostic contains fix-it hints, it has a ``fixits`` array, + consisting of half-open intervals, similar to the output of + :option:`-fdiagnostics-parseable-fixits`. For example, this diagnostic + with a replacement fix-it hint: + + .. code-block:: + + demo.c:8:15: error: 'struct s' has no member named 'colour'; did you + mean 'color'? + 8 | return ptr->colour; + | ^~~~~~ + | color + + might be printed in JSON form as: + + .. code-block:: json + + { + "children": [], + "fixits": [ + { + "next": { + "column": 21, + "file": "demo.c", + "line": 8 + }, + "start": { + "column": 15, + "file": "demo.c", + "line": 8 + }, + "string": "color" + } + ], + "kind": "error", + "locations": [ + { + "caret": { + "column": 15, + "file": "demo.c", + "line": 8 + }, + "finish": { + "column": 20, + "file": "demo.c", + "line": 8 + } + } + ], + "escape-source": false, + "message": "‘struct s’ has no member named ..." + } + + where the fix-it hint suggests replacing the text from ``start`` up + to but not including ``next`` with ``string`` 's value. Deletions + are expressed via an empty value for ``string``, insertions by + having ``start`` equal ``next``. + + If the diagnostic has a path of control-flow events associated with it, + it has a ``path`` array of objects representing the events. Each + event object has a ``description`` string, a ``location`` object, + along with a ``function`` string and a ``depth`` number for + representing interprocedural paths. The ``function`` represents the + current function at that event, and the ``depth`` represents the + stack depth relative to some baseline: the higher, the more frames are + within the stack. + + For example, the intraprocedural example shown for + :option:`-fdiagnostics-path-format=` might have this JSON for its path: + + .. code-block:: json + + "path": [ + { + "depth": 0, + "description": "when 'PyList_New' fails, returning NULL", + "function": "test", + "location": { + "column": 10, + "file": "test.c", + "line": 25 + } + }, + { + "depth": 0, + "description": "when 'i < count'", + "function": "test", + "location": { + "column": 3, + "file": "test.c", + "line": 27 + } + }, + { + "depth": 0, + "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1", + "function": "test", + "location": { + "column": 5, + "file": "test.c", + "line": 29 + } + } + ] + + Diagnostics have a boolean attribute ``escape-source``, hinting whether + non-ASCII bytes should be escaped when printing the pertinent lines of + source code (``true`` for diagnostics involving source encoding issues). \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/options-to-request-or-suppress-warnings.rst b/gcc/doc/gcc/gcc-command-options/options-to-request-or-suppress-warnings.rst new file mode 100644 index 00000000000..7ddb5daf490 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/options-to-request-or-suppress-warnings.rst @@ -0,0 +1,4866 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: options to control warnings, warning messages, messages, warning, suppressing warnings + +.. _warning-options: + +Options to Request or Suppress Warnings +*************************************** + +Warnings are diagnostic messages that report constructions that +are not inherently erroneous but that are risky or suggest there +may have been an error. + +The following language-independent options do not enable specific +warnings but control the kinds of diagnostics produced by GCC. + +.. index:: syntax checking + +.. option:: -fsyntax-only + + Check the code for syntax errors, but don't do anything beyond that. + +.. option:: -fmax-errors={n} + + Limits the maximum number of error messages to :samp:`{n}`, at which point + GCC bails out rather than attempting to continue processing the source + code. If :samp:`{n}` is 0 (the default), there is no limit on the number + of error messages produced. If :option:`-Wfatal-errors` is also + specified, then :option:`-Wfatal-errors` takes precedence over this + option. + +.. option:: -w + + Inhibit all warning messages. + +.. option:: -Werror + + Make all warnings into errors. + +.. option:: -Wno-error + + Default setting; overrides :option:`-Werror`. + +.. option:: -Werror= + + Make the specified warning into an error. The specifier for a warning + is appended; for example :option:`-Werror=switch` turns the warnings + controlled by :option:`-Wswitch` into errors. This switch takes a + negative form, to be used to negate :option:`-Werror` for specific + warnings; for example :option:`-Wno-error=switch` makes + :option:`-Wswitch` warnings not be errors, even when :option:`-Werror` + is in effect. + + The warning message for each controllable warning includes the + option that controls the warning. That option can then be used with + :option:`-Werror=` and :option:`-Wno-error=` as described above. + (Printing of the option in the warning message can be disabled using the + :option:`-fno-diagnostics-show-option` flag.) + + Note that specifying :option:`-Werror=foo` automatically implies + :option:`-Wfoo`. However, :option:`-Wno-error=foo` does not + imply anything. + +.. option:: -Wno-error= + + Default setting; overrides :option:`-Werror=`. + +.. option:: -Wfatal-errors + + This option causes the compiler to abort compilation on the first error + occurred rather than trying to keep going and printing further error + messages. + +.. option:: -Wno-fatal-errors + + Default setting; overrides :option:`-Wfatal-errors`. + +You can request many specific warnings with options beginning with +:samp:`-W`, for example :option:`-Wimplicit` to request warnings on +implicit declarations. Each of these specific warning options also +has a negative form beginning :samp:`-Wno-` to turn off warnings; for +example, :option:`-Wno-implicit`. This manual lists only one of the +two forms, whichever is not the default. For further +language-specific options also refer to :ref:`c++-dialect-options` and +:ref:`objective-c-and-objective-c++-dialect-options`. +Additional warnings can be produced by enabling the static analyzer; +See :ref:`static-analyzer-options`. + +Some options, such as :option:`-Wall` and :option:`-Wextra`, turn on other +options, such as :option:`-Wunused`, which may turn on further options, +such as :option:`-Wunused-value`. The combined effect of positive and +negative forms is that more specific options have priority over less +specific ones, independently of their position in the command-line. For +options of the same specificity, the last one takes effect. Options +enabled or disabled via pragmas (see :ref:`diagnostic-pragmas`) take effect +as if they appeared at the end of the command-line. + +When an unrecognized warning option is requested (e.g., +:option:`-Wunknown-warning`), GCC emits a diagnostic stating +that the option is not recognized. However, if the :option:`-Wno-` form +is used, the behavior is slightly different: no diagnostic is +produced for :option:`-Wno-unknown-warning` unless other diagnostics +are being produced. This allows the use of new :option:`-Wno-` options +with old compilers, but if something goes wrong, the compiler +warns that an unrecognized option is present. + +The effectiveness of some warnings depends on optimizations also being +enabled. For example :option:`-Wsuggest-final-types` is more effective +with link-time optimization and some instances of other warnings may +not be issued at all unless optimization is enabled. While optimization +in general improves the efficacy of control and data flow sensitive +warnings, in some cases it may also cause false positives. + +.. option:: -Wpedantic, -pedantic + + Issue all the warnings demanded by strict ISO C and ISO C++; + reject all programs that use forbidden extensions, and some other + programs that do not follow ISO C and ISO C++. For ISO C, follows the + version of the ISO C standard specified by any :option:`-std` option used. + + Valid ISO C and ISO C++ programs should compile properly with or without + this option (though a rare few require :option:`-ansi` or a + :option:`-std` option specifying the required version of ISO C). However, + without this option, certain GNU extensions and traditional C and C++ + features are supported as well. With this option, they are rejected. + + :option:`-Wpedantic` does not cause warning messages for use of the + alternate keywords whose names begin and end with :samp:`__`. This alternate + format can also be used to disable warnings for non-ISO :samp:`__intN` types, + i.e. :samp:`__intN__`. + Pedantic warnings are also disabled in the expression that follows + ``__extension__``. However, only system header files should use + these escape routes; application programs should avoid them. + See :ref:`alternate-keywords`. + + Some users try to use :option:`-Wpedantic` to check programs for strict ISO + C conformance. They soon find that it does not do quite what they want: + it finds some non-ISO practices, but not all---only those for which + ISO C *requires* a diagnostic, and some others for which + diagnostics have been added. + + A feature to report any failure to conform to ISO C might be useful in + some instances, but would require considerable additional work and would + be quite different from :option:`-Wpedantic`. We don't have plans to + support such a feature in the near future. + + Where the standard specified with :option:`-std` represents a GNU + extended dialect of C, such as :samp:`gnu90` or :samp:`gnu99`, there is a + corresponding :dfn:`base standard`, the version of ISO C on which the GNU + extended dialect is based. Warnings from :option:`-Wpedantic` are given + where they are required by the base standard. (It does not make sense + for such warnings to be given only for features not in the specified GNU + C dialect, since by definition the GNU dialects of C include all + features the compiler supports with the given option, and there would be + nothing to warn about.) + +.. option:: -Wno-pedantic + + Default setting; overrides :option:`-Wpedantic`. + +.. option:: -pedantic-errors + + Give an error whenever the :dfn:`base standard` (see :option:`-Wpedantic`) + requires a diagnostic, in some cases where there is undefined behavior + at compile-time and in some other cases that do not prevent compilation + of programs that are valid according to the standard. This is not + equivalent to :option:`-Werror=pedantic`, since there are errors enabled + by this option and not enabled by the latter and vice versa. + +.. option:: -Wall + + This enables all the warnings about constructions that some users + consider questionable, and that are easy to avoid (or modify to + prevent the warning), even in conjunction with macros. This also + enables some language-specific warnings described in :ref:`c++-dialect-options` and :ref:`objective-c-and-objective-c++-dialect-options`. + + :option:`-Wall` turns on the following warning flags: + + :option:`-Waddress` |gol| + :option:`-Warray-bounds=1` (only with :option:`-O2` ) |gol| + :option:`-Warray-compare` |gol| + :option:`-Warray-parameter=2` (C and Objective :option:`-C` only) |gol| + :option:`-Wbool-compare` |gol| + :option:`-Wbool-operation` |gol| + :option:`-Wc++11-compat` :option:`-Wc++14-compat` |gol| + :option:`-Wcatch-value` (C++ and Objective :option:`-C++` only) |gol| + :option:`-Wchar-subscripts` |gol| + :option:`-Wcomment` |gol| + :option:`-Wdangling-pointer=2` |gol| + :option:`-Wduplicate-decl-specifier` (C and Objective :option:`-C` only) |gol| + :option:`-Wenum-compare` (in C/ObjC; this is on by default in C++) |gol| + :option:`-Wenum-int-mismatch` (C and Objective :option:`-C` only) |gol| + :option:`-Wformat` |gol| + :option:`-Wformat-overflow` |gol| + :option:`-Wformat-truncation` |gol| + :option:`-Wint-in-bool-context` |gol| + :option:`-Wimplicit` (C and Objective :option:`-C` only) |gol| + :option:`-Wimplicit-int` (C and Objective :option:`-C` only) |gol| + :option:`-Wimplicit-function-declaration` (C and Objective :option:`-C` only) |gol| + :option:`-Winit-self` (only for C++) |gol| + :option:`-Wlogical-not-parentheses` |gol| + :option:`-Wmain` (only for C/ObjC and unless :option:`-ffreestanding` ) |gol| + :option:`-Wmaybe-uninitialized` |gol| + :option:`-Wmemset-elt-size` |gol| + :option:`-Wmemset-transposed-args` |gol| + :option:`-Wmisleading-indentation` (only for C/C++) |gol| + :option:`-Wmismatched-dealloc` |gol| + :option:`-Wmismatched-new-delete` (only for C/C++) |gol| + :option:`-Wmissing-attributes` |gol| + :option:`-Wmissing-braces` (only for C/ObjC) |gol| + :option:`-Wmultistatement-macros` |gol| + :option:`-Wnarrowing` (only for C++) |gol| + :option:`-Wnonnull` |gol| + :option:`-Wnonnull-compare` |gol| + :option:`-Wopenmp-simd` |gol| + :option:`-Wparentheses` |gol| + :option:`-Wpessimizing-move` (only for C++) |gol| + :option:`-Wpointer-sign` |gol| + :option:`-Wrange-loop-construct` (only for C++) |gol| + :option:`-Wreorder` |gol| + :option:`-Wrestrict` |gol| + :option:`-Wreturn-type` |gol| + :option:`-Wself-move` (only for C++) |gol| + :option:`-Wsequence-point` |gol| + :option:`-Wsign-compare` (only in C++) |gol| + :option:`-Wsizeof-array-div` |gol| + :option:`-Wsizeof-pointer-div` |gol| + :option:`-Wsizeof-pointer-memaccess` |gol| + :option:`-Wstrict-aliasing` |gol| + :option:`-Wstrict-overflow=1` |gol| + :option:`-Wswitch` |gol| + :option:`-Wtautological-compare` |gol| + :option:`-Wtrigraphs` |gol| + :option:`-Wuninitialized` |gol| + :option:`-Wunknown-pragmas` |gol| + :option:`-Wunused-function` |gol| + :option:`-Wunused-label` |gol| + :option:`-Wunused-value` |gol| + :option:`-Wunused-variable` |gol| + :option:`-Wuse-after-free=3` |gol| + :option:`-Wvla-parameter` (C and Objective :option:`-C` only) |gol| + :option:`-Wvolatile-register-var` |gol| + :option:`-Wzero-length-bounds` + + Note that some warning flags are not implied by :option:`-Wall`. Some of + them warn about constructions that users generally do not consider + questionable, but which occasionally you might wish to check for; + others warn about constructions that are necessary or hard to avoid in + some cases, and there is no simple way to modify the code to suppress + the warning. Some of them are enabled by :option:`-Wextra` but many of + them must be enabled individually. + +.. option:: -Wno-all + + Default setting; overrides :option:`-Wall`. + +.. option:: -Wextra + + This enables some extra warning flags that are not enabled by + :option:`-Wall`. (This option used to be called :option:`-W`. The older + name is still supported, but the newer name is more descriptive.) + + :option:`-Wclobbered` |gol| + :option:`-Wcast-function-type` |gol| + :option:`-Wdeprecated-copy` (C++ only) |gol| + :option:`-Wempty-body` |gol| + :option:`-Wenum-conversion` (C only) |gol| + :option:`-Wignored-qualifiers` |gol| + :option:`-Wimplicit-fallthrough=3` |gol| + :option:`-Wmissing-field-initializers` |gol| + :option:`-Wmissing-parameter-type` (C only) |gol| + :option:`-Wold-style-declaration` (C only) |gol| + :option:`-Woverride-init` |gol| + :option:`-Wsign-compare` (C only) |gol| + :option:`-Wstring-compare` |gol| + :option:`-Wredundant-move` (only for C++) |gol| + :option:`-Wtype-limits` |gol| + :option:`-Wuninitialized` |gol| + :option:`-Wshift-negative-value` (in C++11 to C++17 and in C99 and newer) |gol| + :option:`-Wunused-parameter` (only with :option:`-Wunused` or :option:`-Wall` ) |gol| + :option:`-Wunused-but-set-parameter` (only with :option:`-Wunused` or :option:`-Wall` ) + The option :option:`-Wextra` also prints warning messages for the + following cases: + + * A pointer is compared against integer zero with ``<``, ``<=``, + ``>``, or ``>=``. + + * (C++ only) An enumerator and a non-enumerator both appear in a + conditional expression. + + * (C++ only) Ambiguous virtual bases. + + * (C++ only) Subscripting an array that has been declared ``register``. + + * (C++ only) Taking the address of a variable that has been declared + ``register``. + + * (C++ only) A base class is not initialized in the copy constructor + of a derived class. + +.. option:: -Wno-extra + + Default setting; overrides :option:`-Wextra`. + +.. option:: -Wabi + + .. note:: + + C, Objective-C, C++ and Objective-C++ only + + Warn about code affected by ABI changes. This includes code that may + not be compatible with the vendor-neutral C++ ABI as well as the psABI + for the particular target. + + Since G++ now defaults to updating the ABI with each major release, + normally :option:`-Wabi` warns only about C++ ABI compatibility + problems if there is a check added later in a release series for an + ABI issue discovered since the initial release. :option:`-Wabi` warns + about more things if an older ABI version is selected (with + :option:`-fabi-version=n`). + + :option:`-Wabi` can also be used with an explicit version number to + warn about C++ ABI compatibility with a particular :option:`-fabi-version` + level, e.g. :option:`-Wabi=2` to warn about changes relative to + :option:`-fabi-version=2`. + + If an explicit version number is provided and + :option:`-fabi-compat-version` is not specified, the version number + from this option is used for compatibility aliases. If no explicit + version number is provided with this option, but + :option:`-fabi-compat-version` is specified, that version number is + used for C++ ABI warnings. + + Although an effort has been made to warn about + all such cases, there are probably some cases that are not warned about, + even though G++ is generating incompatible code. There may also be + cases where warnings are emitted even though the code that is generated + is compatible. + + You should rewrite your code to avoid these warnings if you are + concerned about the fact that code generated by G++ may not be binary + compatible with code generated by other compilers. + + Known incompatibilities in :option:`-fabi-version=2` (which was the + default from GCC 3.4 to 4.9) include: + + * A template with a non-type template parameter of reference type was + mangled incorrectly: + + .. code-block:: c++ + + extern int N; + template struct S {}; + void n (S) {2} + + This was fixed in :option:`-fabi-version=3`. + + * SIMD vector types declared using ``__attribute ((vector_size))`` were + mangled in a non-standard way that does not allow for overloading of + functions taking vectors of different sizes. + + The mangling was changed in :option:`-fabi-version=4`. + + * ``__attribute ((const))`` and :fn-attr:`noreturn` were mangled as type + qualifiers, and ``decltype`` of a plain declaration was folded away. + + These mangling issues were fixed in :option:`-fabi-version=5`. + + * Scoped enumerators passed as arguments to a variadic function are + promoted like unscoped enumerators, causing ``va_arg`` to complain. + On most targets this does not actually affect the parameter passing + ABI, as there is no way to pass an argument smaller than ``int``. + + Also, the ABI changed the mangling of template argument packs, + ``const_cast``, ``static_cast``, prefix increment/decrement, and + a class scope function used as a template argument. + + These issues were corrected in :option:`-fabi-version=6`. + + * Lambdas in default argument scope were mangled incorrectly, and the + ABI changed the mangling of ``nullptr_t``. + + These issues were corrected in :option:`-fabi-version=7`. + + * When mangling a function type with function-cv-qualifiers, the + un-qualified function type was incorrectly treated as a substitution + candidate. + + This was fixed in :option:`-fabi-version=8`, the default for GCC 5.1. + + * ``decltype(nullptr)`` incorrectly had an alignment of 1, leading to + unaligned accesses. Note that this did not affect the ABI of a + function with a ``nullptr_t`` parameter, as parameters have a + minimum alignment. + + This was fixed in :option:`-fabi-version=9`, the default for GCC 5.2. + + * Target-specific attributes that affect the identity of a type, such as + ia32 calling conventions on a function type (stdcall, regparm, etc.), + did not affect the mangled name, leading to name collisions when + function pointers were used as template arguments. + + This was fixed in :option:`-fabi-version=10`, the default for GCC 6.1. + + This option also enables warnings about psABI-related changes. + The known psABI changes at this point include: + + * For SysV/x86-64, unions with ``long double`` members are + passed in memory as specified in psABI. Prior to GCC 4.4, this was not + the case. For example: + + .. code-block:: c++ + + union U { + long double ld; + int i; + }; + + ``union U`` is now always passed in memory. + +.. option:: -Wno-abi + + Default setting; overrides :option:`-Wabi`. + +.. option:: -Wchar-subscripts + + Warn if an array subscript has type ``char``. This is a common cause + of error, as programmers often forget that this type is signed on some + machines. + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-char-subscripts + + Default setting; overrides :option:`-Wchar-subscripts`. + +.. option:: -Wno-coverage-mismatch + + Warn if feedback profiles do not match when using the + :option:`-fprofile-use` option. + If a source file is changed between compiling with :option:`-fprofile-generate` + and with :option:`-fprofile-use`, the files with the profile feedback can fail + to match the source file and GCC cannot use the profile feedback + information. By default, this warning is enabled and is treated as an + error. :option:`-Wno-coverage-mismatch` can be used to disable the + warning or :option:`-Wno-error=coverage-mismatch` can be used to + disable the error. Disabling the error for this warning can result in + poorly optimized code and is useful only in the + case of very minor changes such as bug fixes to an existing code-base. + Completely disabling the warning is not recommended. + +.. option:: -Wcoverage-mismatch + + Default setting; overrides :option:`-Wno-coverage-mismatch`. + +.. option:: -Wno-coverage-invalid-line-number + + Warn in case a function ends earlier than it begins due + to an invalid linenum macros. The warning is emitted only + with :option:`--coverage` enabled. + + By default, this warning is enabled and is treated as an + error. :option:`-Wno-coverage-invalid-line-number` can be used to disable the + warning or :option:`-Wno-error=coverage-invalid-line-number` can be used to + disable the error. + +.. option:: -Wcoverage-invalid-line-number + + Default setting; overrides :option:`-Wno-coverage-invalid-line-number`. + +.. option:: -Wno-cpp + + .. note:: + + C, Objective-C, C++, Objective-C++ and Fortran only + + Suppress warning messages emitted by ``#warning`` directives. + +.. option:: -Wcpp + + Default setting; overrides :option:`-Wno-cpp`. + +.. option:: -Wdouble-promotion + + .. note:: + + C, C++, Objective-C and Objective-C++ only + + Give a warning when a value of type ``float`` is implicitly + promoted to ``double``. CPUs with a 32-bit 'single-precision' + floating-point unit implement ``float`` in hardware, but emulate + ``double`` in software. On such a machine, doing computations + using ``double`` values is much more expensive because of the + overhead required for software emulation. + + It is easy to accidentally do computations with ``double`` because + floating-point literals are implicitly of type ``double``. For + example, in: + + .. code-block:: c++ + + float area(float radius) + { + return 3.14159 * radius * radius; + } + + the compiler performs the entire computation with ``double`` + because the floating-point literal is a ``double``. + +.. option:: -Wno-double-promotion + + Default setting; overrides :option:`-Wdouble-promotion`. + +.. option:: -Wduplicate-decl-specifier + + .. note:: + + C and Objective-C only + + Warn if a declaration has duplicate ``const``, ``volatile``, + ``restrict`` or ``_Atomic`` specifier. This warning is enabled by + :option:`-Wall`. + +.. option:: -Wno-duplicate-decl-specifier + + Default setting; overrides :option:`-Wduplicate-decl-specifier`. + +.. option:: -Wformat, -Wformat={n} + + Check calls to ``printf`` and ``scanf``, etc., to make sure that + the arguments supplied have types appropriate to the format string + specified, and that the conversions specified in the format string make + sense. This includes standard functions, and others specified by format + attributes (see :ref:`function-attributes`), in the ``printf``, + ``scanf``, ``strftime`` and ``strfmon`` (an X/Open extension, + not in the C standard) families (or other target-specific families). + Which functions are checked without format attributes having been + specified depends on the standard version selected, and such checks of + functions without the attribute specified are disabled by + :option:`-ffreestanding` or :option:`-fno-builtin`. + + The formats are checked against the format features supported by GNU + libc version 2.2. These include all ISO C90 and C99 features, as well + as features from the Single Unix Specification and some BSD and GNU + extensions. Other library implementations may not support all these + features; GCC does not support warning about features that go beyond a + particular library's limitations. However, if :option:`-Wpedantic` is used + with :option:`-Wformat`, warnings are given about format features not + in the selected standard version (but not for ``strfmon`` formats, + since those are not in any version of the C standard). See :ref:`c-dialect-options`. + + .. option:: -Wformat=1 + + Option :option:`-Wformat` is equivalent to :option:`-Wformat=1`, and + :option:`-Wno-format` is equivalent to :option:`-Wformat=0`. Since + :option:`-Wformat` also checks for null format arguments for several + functions, :option:`-Wformat` also implies :option:`-Wnonnull`. Some + aspects of this level of format checking can be disabled by the + options: :option:`-Wno-format-contains-nul`, + :option:`-Wno-format-extra-args`, and :option:`-Wno-format-zero-length`. + :option:`-Wformat` is enabled by :option:`-Wall`. + + .. option:: -Wformat=2 + + Enable :option:`-Wformat` plus additional format checks. Currently + equivalent to :option:`-Wformat` :option:`-Wformat-nonliteral` :option:`-Wformat-security` + :option:`-Wformat-y2k`. + +.. option:: -Wno-format + + Default setting; overrides :option:`-Wformat`. + +.. option:: -Wno-format-contains-nul + + If :option:`-Wformat` is specified, do not warn about format strings that + contain NUL bytes. + +.. option:: -Wformat-contains-nul + + Default setting; overrides :option:`-Wno-format-contains-nul`. + +.. option:: -Wno-format-extra-args + + If :option:`-Wformat` is specified, do not warn about excess arguments to a + ``printf`` or ``scanf`` format function. The C standard specifies + that such arguments are ignored. + + Where the unused arguments lie between used arguments that are + specified with :samp:`$` operand number specifications, normally + warnings are still given, since the implementation could not know what + type to pass to ``va_arg`` to skip the unused arguments. However, + in the case of ``scanf`` formats, this option suppresses the + warning if the unused arguments are all pointers, since the Single + Unix Specification says that such unused arguments are allowed. + +.. option:: -Wformat-extra-args + + Default setting; overrides :option:`-Wno-format-extra-args`. + +.. option:: -Wformat-overflow, -Wformat-overflow={level} + + Warn about calls to formatted input/output functions such as ``sprintf`` + and ``vsprintf`` that might overflow the destination buffer. When the + exact number of bytes written by a format directive cannot be determined + at compile-time it is estimated based on heuristics that depend on the + :samp:`{level}` argument and on optimization. While enabling optimization + will in most cases improve the accuracy of the warning, it may also + result in false positives. + + .. option:: -Wformat-overflow, -Wformat-overflow=1 + + Level :samp:`{1}` of :option:`-Wformat-overflow` enabled by :option:`-Wformat` + employs a conservative approach that warns only about calls that most + likely overflow the buffer. At this level, numeric arguments to format + directives with unknown values are assumed to have the value of one, and + strings of unknown length to be empty. Numeric arguments that are known + to be bounded to a subrange of their type, or string arguments whose output + is bounded either by their directive's precision or by a finite set of + string literals, are assumed to take on the value within the range that + results in the most bytes on output. For example, the call to ``sprintf`` + below is diagnosed because even with both :samp:`{a}` and :samp:`{b}` equal to zero, + the terminating NUL character (``'\0'``) appended by the function + to the destination buffer will be written past its end. Increasing + the size of the buffer by a single byte is sufficient to avoid the + warning, though it may not be sufficient to avoid the overflow. + + .. code-block:: c++ + + void f (int a, int b) + { + char buf [13]; + sprintf (buf, "a = %i, b = %i\n", a, b); + } + + .. option:: -Wno-format-overflow + + Default setting; overrides :option:`-Wformat-overflow`. + + ``-Wformat-overflow=2`` + Level :samp:`{2}` warns also about calls that might overflow the destination + buffer given an argument of sufficient length or magnitude. At level + :samp:`{2}`, unknown numeric arguments are assumed to have the minimum + representable value for signed types with a precision greater than 1, and + the maximum representable value otherwise. Unknown string arguments whose + length cannot be assumed to be bounded either by the directive's precision, + or by a finite set of string literals they may evaluate to, or the character + array they may point to, are assumed to be 1 character long. + + At level :samp:`{2}`, the call in the example above is again diagnosed, but + this time because with :samp:`{a}` equal to a 32-bit ``INT_MIN`` the first + ``%i`` directive will write some of its digits beyond the end of + the destination buffer. To make the call safe regardless of the values + of the two variables, the size of the destination buffer must be increased + to at least 34 bytes. GCC includes the minimum size of the buffer in + an informational note following the warning. + + An alternative to increasing the size of the destination buffer is to + constrain the range of formatted values. The maximum length of string + arguments can be bounded by specifying the precision in the format + directive. When numeric arguments of format directives can be assumed + to be bounded by less than the precision of their type, choosing + an appropriate length modifier to the format specifier will reduce + the required buffer size. For example, if :samp:`{a}` and :samp:`{b}` in the + example above can be assumed to be within the precision of + the ``short int`` type then using either the ``%hi`` format + directive or casting the argument to ``short`` reduces the maximum + required size of the buffer to 24 bytes. + + .. code-block:: c++ + + void f (int a, int b) + { + char buf [23]; + sprintf (buf, "a = %hi, b = %i\n", a, (short)b); + } + +.. option:: -Wno-format-overflow + + Default setting; overrides :option:`-Wformat-overflow`. + +.. option:: -Wno-format-zero-length + + If :option:`-Wformat` is specified, do not warn about zero-length formats. + The C standard specifies that zero-length formats are allowed. + +.. option:: -Wformat-zero-length + + Default setting; overrides :option:`-Wno-format-zero-length`. + +.. option:: -Wformat-nonliteral + + If :option:`-Wformat` is specified, also warn if the format string is not a + string literal and so cannot be checked, unless the format function + takes its format arguments as a ``va_list``. + +.. option:: -Wno-format-nonliteral + + Default setting; overrides :option:`-Wformat-nonliteral`. + +.. option:: -Wformat-security + + If :option:`-Wformat` is specified, also warn about uses of format + functions that represent possible security problems. At present, this + warns about calls to ``printf`` and ``scanf`` functions where the + format string is not a string literal and there are no format arguments, + as in ``printf (foo);``. This may be a security hole if the format + string came from untrusted input and contains :samp:`%n`. (This is + currently a subset of what :option:`-Wformat-nonliteral` warns about, but + in future warnings may be added to :option:`-Wformat-security` that are not + included in :option:`-Wformat-nonliteral`.) + +.. option:: -Wno-format-security + + Default setting; overrides :option:`-Wformat-security`. + +.. option:: -Wformat-signedness + + If :option:`-Wformat` is specified, also warn if the format string + requires an unsigned argument and the argument is signed and vice versa. + +.. option:: -Wno-format-signedness + + Default setting; overrides :option:`-Wformat-signedness`. + +.. option:: -Wformat-truncation, -Wformat-truncation={level} + + Warn about calls to formatted input/output functions such as ``snprintf`` + and ``vsnprintf`` that might result in output truncation. When the exact + number of bytes written by a format directive cannot be determined at + compile-time it is estimated based on heuristics that depend on + the :samp:`{level}` argument and on optimization. While enabling optimization + will in most cases improve the accuracy of the warning, it may also result + in false positives. Except as noted otherwise, the option uses the same + logic :option:`-Wformat-overflow`. + + .. option:: -Wformat-truncation, -Wformat-truncation=1 + + Level :samp:`{1}` of :option:`-Wformat-truncation` enabled by :option:`-Wformat` + employs a conservative approach that warns only about calls to bounded + functions whose return value is unused and that will most likely result + in output truncation. + + .. option:: -Wformat-truncation=2 + + Level :samp:`{2}` warns also about calls to bounded functions whose return + value is used and that might result in truncation given an argument of + sufficient length or magnitude. + +.. option:: -Wno-format-truncation + + Default setting; overrides :option:`-Wformat-truncation`. + +.. option:: -Wformat-y2k + + If :option:`-Wformat` is specified, also warn about ``strftime`` + formats that may yield only a two-digit year. + +.. option:: -Wno-format-y2k + + Default setting; overrides :option:`-Wformat-y2k`. + +.. option:: -Wnonnull + + Warn about passing a null pointer for arguments marked as + requiring a non-null value by the :fn-attr:`nonnull` function attribute. + + :option:`-Wnonnull` is included in :option:`-Wall` and :option:`-Wformat`. It + can be disabled with the :option:`-Wno-nonnull` option. + +.. option:: -Wno-nonnull + + Default setting; overrides :option:`-Wnonnull`. + +.. option:: -Wnonnull-compare + + Warn when comparing an argument marked with the :fn-attr:`nonnull` + function attribute against null inside the function. + + :option:`-Wnonnull-compare` is included in :option:`-Wall`. It + can be disabled with the :option:`-Wno-nonnull-compare` option. + +.. option:: -Wno-nonnull-compare + + Default setting; overrides :option:`-Wnonnull-compare`. + +.. option:: -Wnull-dereference + + Warn if the compiler detects paths that trigger erroneous or + undefined behavior due to dereferencing a null pointer. This option + is only active when :option:`-fdelete-null-pointer-checks` is active, + which is enabled by optimizations in most targets. The precision of + the warnings depends on the optimization options used. + +.. option:: -Wno-null-dereference + + Default setting; overrides :option:`-Wnull-dereference`. + +.. option:: -Winfinite-recursion + + Warn about infinitely recursive calls. The warning is effective at all + optimization levels but requires optimization in order to detect infinite + recursion in calls between two or more functions. + :option:`-Winfinite-recursion` is included in :option:`-Wall`. + +.. option:: -Wno-infinite-recursion + + Default setting; overrides :option:`-Winfinite-recursion`. + +.. option:: -Winit-self + + .. note:: + + C, C++, Objective-C and Objective-C++ only + + Warn about uninitialized variables that are initialized with themselves. + Note this option can only be used with the :option:`-Wuninitialized` option. + + For example, GCC warns about ``i`` being uninitialized in the + following snippet only when :option:`-Winit-self` has been specified: + + .. code-block:: c++ + + int f() + { + int i = i; + return i; + } + + This warning is enabled by :option:`-Wall` in C++. + +.. option:: -Wno-init-self + + Default setting; overrides :option:`-Winit-self`. + +.. option:: -Wno-implicit-int + + .. note:: + + C and Objective-C only + + This option controls warnings when a declaration does not specify a type. + This warning is enabled by default in C99 and later dialects of C, + and also by :option:`-Wall`. + +.. option:: -Wimplicit-int + + Default setting; overrides :option:`-Wno-implicit-int`. + +.. option:: -Wno-implicit-function-declaration + + .. note:: + + C and Objective-C only + + This option controls warnings when a function is used before being declared. + This warning is enabled by default in C99 and later dialects of C, + and also by :option:`-Wall`. + The warning is made into an error by :option:`-pedantic-errors`. + +.. option:: -Wimplicit-function-declaration + + Default setting; overrides :option:`-Wno-implicit-function-declaration`. + +.. option:: -Wimplicit + + .. note:: + + C and Objective-C only + + Same as :option:`-Wimplicit-int` and :option:`-Wimplicit-function-declaration`. + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-implicit + + Default setting; overrides :option:`-Wimplicit`. + +.. option:: -Wimplicit-fallthrough + + :option:`-Wimplicit-fallthrough` is the same as :option:`-Wimplicit-fallthrough=3` + and :option:`-Wno-implicit-fallthrough` is the same as + :option:`-Wimplicit-fallthrough=0`. + +.. option:: -Wno-implicit-fallthrough + + Default setting; overrides :option:`-Wimplicit-fallthrough`. + +.. option:: -Wimplicit-fallthrough={n} + + Warn when a switch case falls through. For example: + + .. code-block:: c++ + + switch (cond) + { + case 1: + a = 1; + break; + case 2: + a = 2; + case 3: + a = 3; + break; + } + + This warning does not warn when the last statement of a case cannot + fall through, e.g. when there is a return statement or a call to function + declared with the noreturn attribute. :option:`-Wimplicit-fallthrough=` + also takes into account control flow statements, such as ifs, and only + warns when appropriate. E.g. + + .. code-block:: c++ + + switch (cond) + { + case 1: + if (i > 3) { + bar (5); + break; + } else if (i < 1) { + bar (0); + } else + return; + default: + ... + } + + Since there are occasions where a switch case fall through is desirable, + GCC provides an attribute, ``__attribute__ ((fallthrough))``, that is + to be used along with a null statement to suppress this warning that + would normally occur: + + .. code-block:: c++ + + switch (cond) + { + case 1: + bar (0); + __attribute__ ((fallthrough)); + default: + ... + } + + C++17 provides a standard way to suppress the :option:`-Wimplicit-fallthrough` + warning using ``[[fallthrough]];`` instead of the GNU attribute. In C++11 + or C++14 users can use ``[[gnu::fallthrough]];``, which is a GNU extension. + Instead of these attributes, it is also possible to add a fallthrough comment + to silence the warning. The whole body of the C or C++ style comment should + match the given regular expressions listed below. The option argument :samp:`{n}` + specifies what kind of comments are accepted: + + * :option:`-Wimplicit-fallthrough=0` disables the warning altogether. + + * :option:`-Wimplicit-fallthrough=1` matches ``.*`` regular + expression, any comment is used as fallthrough comment. + + * :option:`-Wimplicit-fallthrough=2` case insensitively matches + ``.*falls?[ \t-]*thr(ough|u).*`` regular expression. + + * :option:`-Wimplicit-fallthrough=3` case sensitively matches one of the + following regular expressions: + + * ``-fallthrough`` + + * ``@fallthrough@`` + + * ``lint -fallthrough[ \t]*`` + + * ``[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )? + FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?`` + + * ``[ \t.!]*(Else,? |Intentional(ly)? )? + Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?`` + + * ``[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )? + fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?`` + + * :option:`-Wimplicit-fallthrough=4` case sensitively matches one of the + following regular expressions: + + * ``-fallthrough`` + + * ``@fallthrough@`` + + * ``lint -fallthrough[ \t]*`` + + * ``[ \t]*FALLTHR(OUGH|U)[ \t]*`` + + * :option:`-Wimplicit-fallthrough=5` doesn't recognize any comments as + fallthrough comments, only attributes disable the warning. + + The comment needs to be followed after optional whitespace and other comments + by ``case`` or ``default`` keywords or by a user label that precedes some + ``case`` or ``default`` label. + + .. code-block:: c++ + + switch (cond) + { + case 1: + bar (0); + /* FALLTHRU */ + default: + ... + } + + The :option:`-Wimplicit-fallthrough=3` warning is enabled by :option:`-Wextra`. + +.. option:: -Wno-if-not-aligned + + .. note:: + + C, C++, Objective-C and Objective-C++ only + + Control if warnings triggered by the ``warn_if_not_aligned`` attribute + should be issued. These warnings are enabled by default. + +.. option:: -Wif-not-aligned + + Default setting; overrides :option:`-Wno-if-not-aligned`. + +.. option:: -Wignored-qualifiers + + .. note:: + + C and C++ only + + Warn if the return type of a function has a type qualifier + such as ``const``. For ISO C such a type qualifier has no effect, + since the value returned by a function is not an lvalue. + For C++, the warning is only emitted for scalar types or ``void``. + ISO C prohibits qualified ``void`` return types on function + definitions, so such return types always receive a warning + even without this option. + + This warning is also enabled by :option:`-Wextra`. + +.. option:: -Wno-ignored-qualifiers + + Default setting; overrides :option:`-Wignored-qualifiers`. + +.. option:: -Wno-ignored-attributes + + .. note:: + + C and C++ only + + This option controls warnings when an attribute is ignored. + This is different from the + :option:`-Wattributes` option in that it warns whenever the compiler decides + to drop an attribute, not that the attribute is either unknown, used in a + wrong place, etc. This warning is enabled by default. + +.. option:: -Wignored-attributes + + Default setting; overrides :option:`-Wno-ignored-attributes`. + +.. option:: -Wmain + + Warn if the type of ``main`` is suspicious. ``main`` should be + a function with external linkage, returning int, taking either zero + arguments, two, or three arguments of appropriate types. This warning + is enabled by default in C++ and is enabled by either :option:`-Wall` + or :option:`-Wpedantic`. + +.. option:: -Wno-main + + Default setting; overrides :option:`-Wmain`. + +.. option:: -Wmisleading-indentation + + .. note:: + + C and C++ only + + Warn when the indentation of the code does not reflect the block structure. + Specifically, a warning is issued for ``if``, ``else``, ``while``, and + ``for`` clauses with a guarded statement that does not use braces, + followed by an unguarded statement with the same indentation. + + In the following example, the call to 'bar' is misleadingly indented as + if it were guarded by the 'if' conditional. + + .. code-block:: c++ + + if (some_condition ()) + foo (); + bar (); /* Gotcha: this is not guarded by the "if". */ + + In the case of mixed tabs and spaces, the warning uses the + :option:`-ftabstop=` option to determine if the statements line up + (defaulting to 8). + + The warning is not issued for code involving multiline preprocessor logic + such as the following example. + + .. code-block:: c++ + + if (flagA) + foo (0); + #if SOME_CONDITION_THAT_DOES_NOT_HOLD + if (flagB) + #endif + foo (1); + + The warning is not issued after a ``#line`` directive, since this + typically indicates autogenerated code, and no assumptions can be made + about the layout of the file that the directive references. + + This warning is enabled by :option:`-Wall` in C and C++. + +.. option:: -Wno-misleading-indentation + + Default setting; overrides :option:`-Wmisleading-indentation`. + +.. option:: -Wmissing-attributes + + Warn when a declaration of a function is missing one or more attributes + that a related function is declared with and whose absence may adversely + affect the correctness or efficiency of generated code. For example, + the warning is issued for declarations of aliases that use attributes + to specify less restrictive requirements than those of their targets. + This typically represents a potential optimization opportunity. + By contrast, the :option:`-Wattribute-alias=2` option controls warnings + issued when the alias is more restrictive than the target, which could + lead to incorrect code generation. + Attributes considered include ``alloc_align``, ``alloc_size``, + :fn-attr:`cold`, :fn-attr:`const`, :fn-attr:`hot`, :fn-attr:`leaf`, :fn-attr:`malloc`, + :fn-attr:`nonnull`, :fn-attr:`noreturn`, :fn-attr:`nothrow`, :fn-attr:`pure`, + :fn-attr:`returns_nonnull`, and :fn-attr:`returns_twice`. + + In C++, the warning is issued when an explicit specialization of a primary + template declared with attribute ``alloc_align``, ``alloc_size``, + ``assume_aligned``, ``format``, ``format_arg``, ``malloc``, + or :fn-attr:`nonnull` is declared without it. Attributes :fn-attr:`deprecated`, + ``error``, and ``warning`` suppress the warning. + (see :ref:`function-attributes`). + + You can use the ``copy`` attribute to apply the same + set of attributes to a declaration as that on another declaration without + explicitly enumerating the attributes. This attribute can be applied + to declarations of functions (see :ref:`common-function-attributes`), + variables (see :ref:`common-variable-attributes`), or types + (see :ref:`common-type-attributes`). + + :option:`-Wmissing-attributes` is enabled by :option:`-Wall`. + + For example, since the declaration of the primary function template + below makes use of both attribute ``malloc`` and ``alloc_size`` + the declaration of the explicit specialization of the template is + diagnosed because it is missing one of the attributes. + + .. code-block:: c++ + + template + T* __attribute__ ((malloc, alloc_size (1))) + allocate (size_t); + + template <> + void* __attribute__ ((malloc)) // missing alloc_size + allocate (size_t); + +.. option:: -Wno-missing-attributes + + Default setting; overrides :option:`-Wmissing-attributes`. + +.. option:: -Wmissing-braces + + Warn if an aggregate or union initializer is not fully bracketed. In + the following example, the initializer for ``a`` is not fully + bracketed, but that for ``b`` is fully bracketed. + + .. code-block:: c++ + + int a[2][2] = { 0, 1, 2, 3 }; + int b[2][2] = { { 0, 1 }, { 2, 3 } }; + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-missing-braces + + Default setting; overrides :option:`-Wmissing-braces`. + +.. option:: -Wmissing-include-dirs + + .. note:: + + C, C++, Objective-C, Objective-C++ and Fortran only + + Warn if a user-supplied include directory does not exist. This opions is disabled + by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially + enabled by default by warning for -I and -J, only. + +.. option:: -Wno-missing-include-dirs + + Default setting; overrides :option:`-Wmissing-include-dirs`. + +.. option:: -Wno-missing-profile + + This option controls warnings if feedback profiles are missing when using the + :option:`-fprofile-use` option. + This option diagnoses those cases where a new function or a new file is added + between compiling with :option:`-fprofile-generate` and with + :option:`-fprofile-use`, without regenerating the profiles. + In these cases, the profile feedback data files do not contain any + profile feedback information for + the newly added function or file respectively. Also, in the case when profile + count data (.gcda) files are removed, GCC cannot use any profile feedback + information. In all these cases, warnings are issued to inform you that a + profile generation step is due. + Ignoring the warning can result in poorly optimized code. + :option:`-Wno-missing-profile` can be used to + disable the warning, but this is not recommended and should be done only + when non-existent profile data is justified. + +.. option:: -Wmissing-profile + + Default setting; overrides :option:`-Wno-missing-profile`. + +.. option:: -Wmismatched-dealloc + + Warn for calls to deallocation functions with pointer arguments returned + from from allocations functions for which the former isn't a suitable + deallocator. A pair of functions can be associated as matching allocators + and deallocators by use of attribute ``malloc``. Unless disabled by + the :option:`-fno-builtin` option the standard functions ``calloc``, + ``malloc``, ``realloc``, and ``free``, as well as the corresponding + forms of C++ ``operator new`` and ``operator delete`` are implicitly + associated as matching allocators and deallocators. In the following + example ``mydealloc`` is the deallocator for pointers returned from + ``myalloc``. + + .. code-block:: c++ + + void mydealloc (void*); + + __attribute__ ((malloc (mydealloc, 1))) void* + myalloc (size_t); + + void f (void) + { + void *p = myalloc (32); + // ...use p... + free (p); // warning: not a matching deallocator for myalloc + mydealloc (p); // ok + } + + In C++, the related option :option:`-Wmismatched-new-delete` diagnoses + mismatches involving either ``operator new`` or ``operator delete``. + + Option :option:`-Wmismatched-dealloc` is included in :option:`-Wall`. + +.. option:: -Wno-mismatched-dealloc + + Default setting; overrides :option:`-Wmismatched-dealloc`. + +.. option:: -Wmultistatement-macros + + Warn about unsafe multiple statement macros that appear to be guarded + by a clause such as ``if``, ``else``, ``for``, ``switch``, or + ``while``, in which only the first statement is actually guarded after + the macro is expanded. + + For example: + + .. code-block:: c++ + + #define DOIT x++; y++ + if (c) + DOIT; + + will increment ``y`` unconditionally, not just when ``c`` holds. + The can usually be fixed by wrapping the macro in a do-while loop: + + .. code-block:: c++ + + #define DOIT do { x++; y++; } while (0) + if (c) + DOIT; + + This warning is enabled by :option:`-Wall` in C and C++. + +.. option:: -Wno-multistatement-macros + + Default setting; overrides :option:`-Wmultistatement-macros`. + +.. option:: -Wparentheses + + Warn if parentheses are omitted in certain contexts, such + as when there is an assignment in a context where a truth value + is expected, or when operators are nested whose precedence people + often get confused about. + + Also warn if a comparison like ``x<=y<=z`` appears; this is + equivalent to ``(x<=y ? 1 : 0) <= z``, which is a different + interpretation from that of ordinary mathematical notation. + + Also warn for dangerous uses of the GNU extension to + ``?:`` with omitted middle operand. When the condition + in the ``?`` : operator is a boolean expression, the omitted value is + always 1. Often programmers expect it to be a value computed + inside the conditional expression instead. + + For C++ this also warns for some cases of unnecessary parentheses in + declarations, which can indicate an attempt at a function call instead + of a declaration: + + .. code-block:: c++ + + { + // Declares a local variable called mymutex. + std::unique_lock (mymutex); + // User meant std::unique_lock lock (mymutex); + } + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-parentheses + + Default setting; overrides :option:`-Wparentheses`. + +.. option:: -Wno-self-move + + .. note:: + + C++ and Objective-C++ only + + This warning warns when a value is moved to itself with ``std::move``. + Such a ``std::move`` typically has no effect. + + .. code-block:: c++ + + struct T { + ... + }; + void fn() + { + T t; + ... + t = std::move (t); + } + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wself-move + + Default setting; overrides :option:`-Wno-self-move`. + +.. option:: -Wsequence-point + + Warn about code that may have undefined semantics because of violations + of sequence point rules in the C and C++ standards. + + The C and C++ standards define the order in which expressions in a C/C++ + program are evaluated in terms of :dfn:`sequence points`, which represent + a partial ordering between the execution of parts of the program: those + executed before the sequence point, and those executed after it. These + occur after the evaluation of a full expression (one which is not part + of a larger expression), after the evaluation of the first operand of a + ``&&``, ``||``, ``? :`` or ``,`` (comma) operator, before a + function is called (but after the evaluation of its arguments and the + expression denoting the called function), and in certain other places. + Other than as expressed by the sequence point rules, the order of + evaluation of subexpressions of an expression is not specified. All + these rules describe only a partial order rather than a total order, + since, for example, if two functions are called within one expression + with no sequence point between them, the order in which the functions + are called is not specified. However, the standards committee have + ruled that function calls do not overlap. + + It is not specified when between sequence points modifications to the + values of objects take effect. Programs whose behavior depends on this + have undefined behavior; the C and C++ standards specify that 'Between + the previous and next sequence point an object shall have its stored + value modified at most once by the evaluation of an expression. + Furthermore, the prior value shall be read only to determine the value + to be stored.'. If a program breaks these rules, the results on any + particular implementation are entirely unpredictable. + + Examples of code with undefined behavior are ``a = a++;``, ``a[n] + = b[n++]`` and ``a[i++] = i;``. Some more complicated cases are not + diagnosed by this option, and it may give an occasional false positive + result, but in general it has been found fairly effective at detecting + this sort of problem in programs. + + The C++17 standard will define the order of evaluation of operands in + more cases: in particular it requires that the right-hand side of an + assignment be evaluated before the left-hand side, so the above + examples are no longer undefined. But this option will still warn + about them, to help people avoid writing code that is undefined in C + and earlier revisions of C++. + + The standard is worded confusingly, therefore there is some debate + over the precise meaning of the sequence point rules in subtle cases. + Links to discussions of the problem, including proposed formal + definitions, may be found on the GCC readings page, at + https://gcc.gnu.org/readings.html. + + This warning is enabled by :option:`-Wall` for C and C++. + +.. option:: -Wno-sequence-point + + Default setting; overrides :option:`-Wsequence-point`. + +.. option:: -Wno-return-local-addr + + Do not warn about returning a pointer (or in C++, a reference) to a + variable that goes out of scope after the function returns. + +.. option:: -Wreturn-local-addr + + Default setting; overrides :option:`-Wno-return-local-addr`. + +.. option:: -Wreturn-type + + Warn whenever a function is defined with a return type that defaults + to ``int``. Also warn about any ``return`` statement with no + return value in a function whose return type is not ``void`` + (falling off the end of the function body is considered returning + without a value). + + For C only, warn about a ``return`` statement with an expression in a + function whose return type is ``void``, unless the expression type is + also ``void``. As a GNU extension, the latter case is accepted + without a warning unless :option:`-Wpedantic` is used. Attempting + to use the return value of a non- ``void`` function other than ``main`` + that flows off the end by reaching the closing curly brace that terminates + the function is undefined. + + Unlike in C, in C++, flowing off the end of a non- ``void`` function other + than ``main`` results in undefined behavior even when the value of + the function is not used. + + This warning is enabled by default in C++ and by :option:`-Wall` otherwise. + +.. option:: -Wno-return-type + + Default setting; overrides :option:`-Wreturn-type`. + +.. option:: -Wno-shift-count-negative + + Controls warnings if a shift count is negative. + This warning is enabled by default. + +.. option:: -Wshift-count-negative + + Default setting; overrides :option:`-Wno-shift-count-negative`. + +.. option:: -Wno-shift-count-overflow + + Controls warnings if a shift count is greater than or equal to the bit width + of the type. This warning is enabled by default. + +.. option:: -Wshift-count-overflow + + Default setting; overrides :option:`-Wno-shift-count-overflow`. + +.. option:: -Wshift-negative-value + + Warn if left shifting a negative value. This warning is enabled by + :option:`-Wextra` in C99 (and newer) and C++11 to C++17 modes. + +.. option:: -Wno-shift-negative-value + + Default setting; overrides :option:`-Wshift-negative-value`. + +.. option:: -Wno-shift-overflow, -Wshift-overflow={n} + + These options control warnings about left shift overflows. + + ``-Wshift-overflow=1`` + This is the warning level of :option:`-Wshift-overflow` and is enabled + by default in C99 and C++11 modes (and newer). This warning level does + not warn about left-shifting 1 into the sign bit. (However, in C, such + an overflow is still rejected in contexts where an integer constant expression + is required.) No warning is emitted in C++20 mode (and newer), as signed left + shifts always wrap. + + ``-Wshift-overflow=2`` + This warning level also warns about left-shifting 1 into the sign bit, + unless C++14 mode (or newer) is active. + +.. option:: -Wshift-overflow + + Default setting; overrides :option:`-Wno-shift-overflow`. + +.. option:: -Wswitch + + Warn whenever a ``switch`` statement has an index of enumerated type + and lacks a ``case`` for one or more of the named codes of that + enumeration. (The presence of a ``default`` label prevents this + warning.) ``case`` labels outside the enumeration range also + provoke warnings when this option is used (even if there is a + ``default`` label). + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-switch + + Default setting; overrides :option:`-Wswitch`. + +.. option:: -Wswitch-default + + Warn whenever a ``switch`` statement does not have a ``default`` + case. + +.. option:: -Wno-switch-default + + Default setting; overrides :option:`-Wswitch-default`. + +.. option:: -Wswitch-enum + + Warn whenever a ``switch`` statement has an index of enumerated type + and lacks a ``case`` for one or more of the named codes of that + enumeration. ``case`` labels outside the enumeration range also + provoke warnings when this option is used. The only difference + between :option:`-Wswitch` and this option is that this option gives a + warning about an omitted enumeration code even if there is a + ``default`` label. + +.. option:: -Wno-switch-enum + + Default setting; overrides :option:`-Wswitch-enum`. + +.. option:: -Wno-switch-bool + + Do not warn when a ``switch`` statement has an index of boolean type + and the case values are outside the range of a boolean type. + It is possible to suppress this warning by casting the controlling + expression to a type other than ``bool``. For example: + + .. code-block:: c++ + + switch ((int) (a == 4)) + { + ... + } + + This warning is enabled by default for C and C++ programs. + +.. option:: -Wswitch-bool + + Default setting; overrides :option:`-Wno-switch-bool`. + +.. option:: -Wno-switch-outside-range + + This option controls warnings when a ``switch`` case has a value + that is outside of its + respective type range. This warning is enabled by default for + C and C++ programs. + +.. option:: -Wswitch-outside-range + + Default setting; overrides :option:`-Wno-switch-outside-range`. + +.. option:: -Wno-switch-unreachable + + Do not warn when a ``switch`` statement contains statements between the + controlling expression and the first case label, which will never be + executed. For example: + + .. code-block:: c++ + + switch (cond) + { + i = 15; + ... + case 5: + ... + } + + :option:`-Wswitch-unreachable` does not warn if the statement between the + controlling expression and the first case label is just a declaration: + + .. code-block:: c++ + + switch (cond) + { + int i; + ... + case 5: + i = 5; + ... + } + + This warning is enabled by default for C and C++ programs. + +.. option:: -Wswitch-unreachable + + Default setting; overrides :option:`-Wno-switch-unreachable`. + +.. option:: -Wsync-nand + + .. note:: + + C and C++ only + + Warn when ``__sync_fetch_and_nand`` and ``__sync_nand_and_fetch`` + built-in functions are used. These functions changed semantics in GCC 4.4. + +.. option:: -Wno-sync-nand + + Default setting; overrides :option:`-Wsync-nand`. + +.. option:: -Wtrivial-auto-var-init + + Warn when ``-ftrivial-auto-var-init`` cannot initialize the automatic + variable. A common situation is an automatic variable that is declared + between the controlling expression and the first case label of a ``switch`` + statement. + +.. option:: -Wno-trivial-auto-var-init + + Default setting; overrides :option:`-Wtrivial-auto-var-init`. + +.. option:: -Wunused-but-set-parameter + + Warn whenever a function parameter is assigned to, but otherwise unused + (aside from its declaration). + + To suppress this warning use the :var-attr:`unused` attribute + (see :ref:`variable-attributes`). + + This warning is also enabled by :option:`-Wunused` together with + :option:`-Wextra`. + +.. option:: -Wno-unused-but-set-parameter + + Default setting; overrides :option:`-Wunused-but-set-parameter`. + +.. option:: -Wunused-but-set-variable + + Warn whenever a local variable is assigned to, but otherwise unused + (aside from its declaration). + This warning is enabled by :option:`-Wall`. + + To suppress this warning use the :var-attr:`unused` attribute + (see :ref:`variable-attributes`). + + This warning is also enabled by :option:`-Wunused`, which is enabled + by :option:`-Wall`. + +.. option:: -Wno-unused-but-set-variable + + Default setting; overrides :option:`-Wunused-but-set-variable`. + +.. option:: -Wunused-function + + Warn whenever a static function is declared but not defined or a + non-inline static function is unused. + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-unused-function + + Default setting; overrides :option:`-Wunused-function`. + +.. option:: -Wunused-label + + Warn whenever a label is declared but not used. + This warning is enabled by :option:`-Wall`. + + To suppress this warning use the :var-attr:`unused` attribute + (see :ref:`variable-attributes`). + +.. option:: -Wno-unused-label + + Default setting; overrides :option:`-Wunused-label`. + +.. option:: -Wunused-local-typedefs + + .. note:: + + C, Objective-C, C++ and Objective-C++ only + + Warn when a typedef locally defined in a function is not used. + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-unused-local-typedefs + + Default setting; overrides :option:`-Wunused-local-typedefs`. + +.. option:: -Wunused-parameter + + Warn whenever a function parameter is unused aside from its declaration. + + To suppress this warning use the :var-attr:`unused` attribute + (see :ref:`variable-attributes`). + +.. option:: -Wno-unused-parameter + + Default setting; overrides :option:`-Wunused-parameter`. + +.. option:: -Wno-unused-result + + Do not warn if a caller of a function marked with attribute + :fn-attr:`warn_unused_result` (see :ref:`function-attributes`) does not use + its return value. The default is :option:`-Wunused-result`. + +.. option:: -Wunused-result + + Default setting; overrides :option:`-Wno-unused-result`. + +.. option:: -Wunused-variable + + Warn whenever a local or static variable is unused aside from its + declaration. This option implies :option:`-Wunused-const-variable=1` for C, + but not for C++. This warning is enabled by :option:`-Wall`. + + To suppress this warning use the :var-attr:`unused` attribute + (see :ref:`variable-attributes`). + +.. option:: -Wno-unused-variable + + Default setting; overrides :option:`-Wunused-variable`. + +.. option:: -Wunused-const-variable, -Wunused-const-variable={n} + + Warn whenever a constant static variable is unused aside from its declaration. + :option:`-Wunused-const-variable=1` is enabled by :option:`-Wunused-variable` + for C, but not for C++. In C this declares variable storage, but in C++ this + is not an error since const variables take the place of ``#define`` s. + + To suppress this warning use the :var-attr:`unused` attribute + (see :ref:`variable-attributes`). + + ``-Wunused-const-variable=1`` + This is the warning level that is enabled by :option:`-Wunused-variable` for + C. It warns only about unused static const variables defined in the main + compilation unit, but not about static const variables declared in any + header included. + + ``-Wunused-const-variable=2`` + This warning level also warns for unused constant static variables in + headers (excluding system headers). This is the warning level of + :option:`-Wunused-const-variable` and must be explicitly requested since + in C++ this isn't an error and in C it might be harder to clean up all + headers included. + +.. option:: -Wno-unused-const-variable + + Default setting; overrides :option:`-Wunused-const-variable`. + +.. option:: -Wunused-value + + Warn whenever a statement computes a result that is explicitly not + used. To suppress this warning cast the unused expression to + ``void``. This includes an expression-statement or the left-hand + side of a comma expression that contains no side effects. For example, + an expression such as ``x[i,j]`` causes a warning, while + ``x[(void)i,j]`` does not. + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-unused-value + + Default setting; overrides :option:`-Wunused-value`. + +.. option:: -Wunused + + All the above :option:`-Wunused` options combined. + + In order to get a warning about an unused function parameter, you must + either specify :option:`-Wextra -Wunused` (note that :option:`-Wall` implies + :option:`-Wunused`), or separately specify :option:`-Wunused-parameter`. + +.. option:: -Wno-unused + + Default setting; overrides :option:`-Wunused`. + +.. option:: -Wuninitialized + + Warn if an object with automatic or allocated storage duration is used + without having been initialized. In C++, also warn if a non-static + reference or non-static ``const`` member appears in a class without + constructors. + + In addition, passing a pointer (or in C++, a reference) to an uninitialized + object to a ``const`` -qualified argument of a built-in function known to + read the object is also diagnosed by this warning. + (:option:`-Wmaybe-uninitialized` is issued for ordinary functions.) + + If you want to warn about code that uses the uninitialized value of the + variable in its own initializer, use the :option:`-Winit-self` option. + + These warnings occur for individual uninitialized elements of + structure, union or array variables as well as for variables that are + uninitialized as a whole. They do not occur for variables or elements + declared ``volatile``. Because these warnings depend on + optimization, the exact variables or elements for which there are + warnings depend on the precise optimization options and version of GCC + used. + + Note that there may be no warning about a variable that is used only + to compute a value that itself is never used, because such + computations may be deleted by data flow analysis before the warnings + are printed. + + In C++, this warning also warns about using uninitialized objects in + member-initializer-lists. For example, GCC warns about ``b`` being + uninitialized in the following snippet: + + .. code-block:: c++ + + struct A { + int a; + int b; + A() : a(b) { } + }; + +.. option:: -Wno-uninitialized + + Default setting; overrides :option:`-Wuninitialized`. + +.. option:: -Wno-invalid-memory-model + + This option controls warnings + for invocations of :ref:`atomic-builtins`, :ref:`sync-builtins`, + and the C11 atomic generic functions with a memory consistency argument + that is either invalid for the operation or outside the range of values + of the ``memory_order`` enumeration. For example, since the + ``__atomic_store`` and ``__atomic_store_n`` built-ins are only + defined for the relaxed, release, and sequentially consistent memory + orders the following code is diagnosed: + + .. code-block:: c++ + + void store (int *i) + { + __atomic_store_n (i, 0, memory_order_consume); + } + + :option:`-Winvalid-memory-model` is enabled by default. + +.. option:: -Winvalid-memory-model + + Default setting; overrides :option:`-Wno-invalid-memory-model`. + +.. option:: -Wmaybe-uninitialized + + For an object with automatic or allocated storage duration, if there exists + a path from the function entry to a use of the object that is initialized, + but there exist some other paths for which the object is not initialized, + the compiler emits a warning if it cannot prove the uninitialized paths + are not executed at run time. + + In addition, passing a pointer (or in C++, a reference) to an uninitialized + object to a ``const`` -qualified function argument is also diagnosed by + this warning. (:option:`-Wuninitialized` is issued for built-in functions + known to read the object.) Annotating the function with attribute + ``access (none)`` indicates that the argument isn't used to access + the object and avoids the warning (see :ref:`common-function-attributes`). + + These warnings are only possible in optimizing compilation, because otherwise + GCC does not keep track of the state of variables. + + These warnings are made optional because GCC may not be able to determine when + the code is correct in spite of appearing to have an error. Here is one + example of how this can happen: + + .. code-block:: c++ + + { + int x; + switch (y) + { + case 1: x = 1; + break; + case 2: x = 4; + break; + case 3: x = 5; + } + foo (x); + } + + If the value of ``y`` is always 1, 2 or 3, then ``x`` is + always initialized, but GCC doesn't know this. To suppress the + warning, you need to provide a default case with assert(0) or + similar code. + + .. index:: longjmp warnings + + This option also warns when a non-volatile automatic variable might be + changed by a call to ``longjmp``. + The compiler sees only the calls to ``setjmp``. It cannot know + where ``longjmp`` will be called; in fact, a signal handler could + call it at any point in the code. As a result, you may get a warning + even when there is in fact no problem because ``longjmp`` cannot + in fact be called at the place that would cause a problem. + + Some spurious warnings can be avoided if you declare all the functions + you use that never return as :fn-attr:`noreturn`. See :ref:`function-attributes`. + + This warning is enabled by :option:`-Wall` or :option:`-Wextra`. + +.. option:: -Wno-maybe-uninitialized + + Default setting; overrides :option:`-Wmaybe-uninitialized`. + +.. index:: warning for unknown pragmas, unknown pragmas, warning, pragmas, warning of unknown + +.. option:: -Wunknown-pragmas + + Warn when a ``#pragma`` directive is encountered that is not understood by + GCC. If this command-line option is used, warnings are even issued + for unknown pragmas in system header files. This is not the case if + the warnings are only enabled by the :option:`-Wall` command-line option. + +.. option:: -Wno-unknown-pragmas + + Default setting; overrides :option:`-Wunknown-pragmas`. + +.. option:: -Wno-pragmas + + Do not warn about misuses of pragmas, such as incorrect parameters, + invalid syntax, or conflicts between pragmas. See also + :option:`-Wunknown-pragmas`. + +.. option:: -Wpragmas + + Default setting; overrides :option:`-Wno-pragmas`. + +.. option:: -Wno-prio-ctor-dtor + + Do not warn if a priority from 0 to 100 is used for constructor or destructor. + The use of constructor and destructor attributes allow you to assign a + priority to the constructor/destructor to control its order of execution + before ``main`` is called or after it returns. The priority values must be + greater than 100 as the compiler reserves priority values between 0--100 for + the implementation. + +.. option:: -Wprio-ctor-dtor + + Default setting; overrides :option:`-Wno-prio-ctor-dtor`. + +.. option:: -Wstrict-aliasing + + This option is only active when :option:`-fstrict-aliasing` is active. + It warns about code that might break the strict aliasing rules that the + compiler is using for optimization. The warning does not catch all + cases, but does attempt to catch the more common pitfalls. It is + included in :option:`-Wall`. + It is equivalent to :option:`-Wstrict-aliasing=3` + +.. option:: -Wno-strict-aliasing + + Default setting; overrides :option:`-Wstrict-aliasing`. + +.. option:: -Wstrict-aliasing=n + + This option is only active when :option:`-fstrict-aliasing` is active. + It warns about code that might break the strict aliasing rules that the + compiler is using for optimization. + Higher levels correspond to higher accuracy (fewer false positives). + Higher levels also correspond to more effort, similar to the way :option:`-O` + works. + :option:`-Wstrict-aliasing` is equivalent to :option:`-Wstrict-aliasing=3`. + + Level 1: Most aggressive, quick, least accurate. + Possibly useful when higher levels + do not warn but :option:`-fstrict-aliasing` still breaks the code, as it has very few + false negatives. However, it has many false positives. + Warns for all pointer conversions between possibly incompatible types, + even if never dereferenced. Runs in the front end only. + + Level 2: Aggressive, quick, not too precise. + May still have many false positives (not as many as level 1 though), + and few false negatives (but possibly more than level 1). + Unlike level 1, it only warns when an address is taken. Warns about + incomplete types. Runs in the front end only. + + Level 3 (default for :option:`-Wstrict-aliasing`): + Should have very few false positives and few false + negatives. Slightly slower than levels 1 or 2 when optimization is enabled. + Takes care of the common pun+dereference pattern in the front end: + ``*(int*)&some_float``. + If optimization is enabled, it also runs in the back end, where it deals + with multiple statement cases using flow-sensitive points-to information. + Only warns when the converted pointer is dereferenced. + Does not warn about incomplete types. + +.. option:: -Wstrict-overflow, -Wstrict-overflow={n} + + This option is only active when signed overflow is undefined. + It warns about cases where the compiler optimizes based on the + assumption that signed overflow does not occur. Note that it does not + warn about all cases where the code might overflow: it only warns + about cases where the compiler implements some optimization. Thus + this warning depends on the optimization level. + + An optimization that assumes that signed overflow does not occur is + perfectly safe if the values of the variables involved are such that + overflow never does, in fact, occur. Therefore this warning can + easily give a false positive: a warning about code that is not + actually a problem. To help focus on important issues, several + warning levels are defined. No warnings are issued for the use of + undefined signed overflow when estimating how many iterations a loop + requires, in particular when determining whether a loop will be + executed at all. + + ``-Wstrict-overflow=1`` + Warn about cases that are both questionable and easy to avoid. For + example the compiler simplifies + ``x + 1 > x`` to ``1``. This level of + :option:`-Wstrict-overflow` is enabled by :option:`-Wall` ; higher levels + are not, and must be explicitly requested. + + ``-Wstrict-overflow=2`` + Also warn about other cases where a comparison is simplified to a + constant. For example: ``abs (x) >= 0``. This can only be + simplified when signed integer overflow is undefined, because + ``abs (INT_MIN)`` overflows to ``INT_MIN``, which is less than + zero. :option:`-Wstrict-overflow` (with no level) is the same as + :option:`-Wstrict-overflow=2`. + + ``-Wstrict-overflow=3`` + Also warn about other cases where a comparison is simplified. For + example: ``x + 1 > 1`` is simplified to ``x > 0``. + + ``-Wstrict-overflow=4`` + Also warn about other simplifications not covered by the above cases. + For example: ``(x * 10) / 5`` is simplified to ``x * 2``. + + ``-Wstrict-overflow=5`` + Also warn about cases where the compiler reduces the magnitude of a + constant involved in a comparison. For example: ``x + 2 > y`` is + simplified to ``x + 1 >= y``. This is reported only at the + highest warning level because this simplification applies to many + comparisons, so this warning level gives a very large number of + false positives. + +.. option:: -Wno-strict-overflow + + Default setting; overrides :option:`-Wstrict-overflow`. + +.. option:: -Wstring-compare + + Warn for calls to ``strcmp`` and ``strncmp`` whose result is + determined to be either zero or non-zero in tests for such equality + owing to the length of one argument being greater than the size of + the array the other argument is stored in (or the bound in the case + of ``strncmp``). Such calls could be mistakes. For example, + the call to ``strcmp`` below is diagnosed because its result is + necessarily non-zero irrespective of the contents of the array ``a``. + + .. code-block:: c++ + + extern char a[4]; + void f (char *d) + { + strcpy (d, "string"); + ... + if (0 == strcmp (a, d)) // cannot be true + puts ("a and d are the same"); + } + + :option:`-Wstring-compare` is enabled by :option:`-Wextra`. + +.. option:: -Wno-string-compare + + Default setting; overrides :option:`-Wstring-compare`. + +.. option:: -Wstringop-overflow, -Wstringop-overflow={type} + + Warn for calls to string manipulation functions such as ``memcpy`` and + ``strcpy`` that are determined to overflow the destination buffer. The + optional argument is one greater than the type of Object Size Checking to + perform to determine the size of the destination. See :ref:`object-size-checking`. + The argument is meaningful only for functions that operate on character arrays + but not for raw memory functions like ``memcpy`` which always make use + of Object Size type-0. The option also warns for calls that specify a size + in excess of the largest possible object or at most ``SIZE_MAX / 2`` bytes. + The option produces the best results with optimization enabled but can detect + a small subset of simple buffer overflows even without optimization in + calls to the GCC built-in functions like ``__builtin_memcpy`` that + correspond to the standard functions. In any case, the option warns about + just a subset of buffer overflows detected by the corresponding overflow + checking built-ins. For example, the option issues a warning for + the ``strcpy`` call below because it copies at least 5 characters + (the string ``"blue"`` including the terminating NUL) into the buffer + of size 4. + + .. code-block:: c++ + + enum Color { blue, purple, yellow }; + const char* f (enum Color clr) + { + static char buf [4]; + const char *str; + switch (clr) + { + case blue: str = "blue"; break; + case purple: str = "purple"; break; + case yellow: str = "yellow"; break; + } + + return strcpy (buf, str); // warning here + } + + Option :option:`-Wstringop-overflow=2` is enabled by default. + + ``-Wstringop-overflow=1`` + The :option:`-Wstringop-overflow=1` option uses type-zero Object Size Checking + to determine the sizes of destination objects. At this setting the option + does not warn for writes past the end of subobjects of larger objects accessed + by pointers unless the size of the largest surrounding object is known. When + the destination may be one of several objects it is assumed to be the largest + one of them. On Linux systems, when optimization is enabled at this setting + the option warns for the same code as when the ``_FORTIFY_SOURCE`` macro + is defined to a non-zero value. + + ``-Wstringop-overflow=2`` + The :option:`-Wstringop-overflow=2` option uses type-one Object Size Checking + to determine the sizes of destination objects. At this setting the option + warns about overflows when writing to members of the largest complete + objects whose exact size is known. However, it does not warn for excessive + writes to the same members of unknown objects referenced by pointers since + they may point to arrays containing unknown numbers of elements. This is + the default setting of the option. + + ``-Wstringop-overflow=3`` + The :option:`-Wstringop-overflow=3` option uses type-two Object Size Checking + to determine the sizes of destination objects. At this setting the option + warns about overflowing the smallest object or data member. This is the + most restrictive setting of the option that may result in warnings for safe + code. + + ``-Wstringop-overflow=4`` + The :option:`-Wstringop-overflow=4` option uses type-three Object Size Checking + to determine the sizes of destination objects. At this setting the option + warns about overflowing any data members, and when the destination is + one of several objects it uses the size of the largest of them to decide + whether to issue a warning. Similarly to :option:`-Wstringop-overflow=3` this + setting of the option may result in warnings for benign code. + +.. option:: -Wno-stringop-overflow + + Default setting; overrides :option:`-Wstringop-overflow`. + +.. option:: -Wno-stringop-overread + + Warn for calls to string manipulation functions such as ``memchr``, or + ``strcpy`` that are determined to read past the end of the source + sequence. + + Option :option:`-Wstringop-overread` is enabled by default. + +.. option:: -Wstringop-overread + + Default setting; overrides :option:`-Wno-stringop-overread`. + +.. option:: -Wno-stringop-truncation + + Do not warn for calls to bounded string manipulation functions + such as ``strncat``, + ``strncpy``, and ``stpncpy`` that may either truncate the copied string + or leave the destination unchanged. + + In the following example, the call to ``strncat`` specifies a bound that + is less than the length of the source string. As a result, the copy of + the source will be truncated and so the call is diagnosed. To avoid the + warning use ``bufsize - strlen (buf) - 1)`` as the bound. + + .. code-block:: c++ + + void append (char *buf, size_t bufsize) + { + strncat (buf, ".txt", 3); + } + + As another example, the following call to ``strncpy`` results in copying + to ``d`` just the characters preceding the terminating NUL, without + appending the NUL to the end. Assuming the result of ``strncpy`` is + necessarily a NUL-terminated string is a common mistake, and so the call + is diagnosed. To avoid the warning when the result is not expected to be + NUL-terminated, call ``memcpy`` instead. + + .. code-block:: c++ + + void copy (char *d, const char *s) + { + strncpy (d, s, strlen (s)); + } + + In the following example, the call to ``strncpy`` specifies the size + of the destination buffer as the bound. If the length of the source + string is equal to or greater than this size the result of the copy will + not be NUL-terminated. Therefore, the call is also diagnosed. To avoid + the warning, specify ``sizeof buf - 1`` as the bound and set the last + element of the buffer to ``NUL``. + + .. code-block:: c++ + + void copy (const char *s) + { + char buf[80]; + strncpy (buf, s, sizeof buf); + ... + } + + In situations where a character array is intended to store a sequence + of bytes with no terminating ``NUL`` such an array may be annotated + with attribute :var-attr:`nonstring` to avoid this warning. Such arrays, + however, are not suitable arguments to functions that expect + ``NUL`` -terminated strings. To help detect accidental misuses of + such arrays GCC issues warnings unless it can prove that the use is + safe. See :ref:`common-variable-attributes`. + +.. option:: -Wstringop-truncation + + Default setting; overrides :option:`-Wno-stringop-truncation`. + +.. option:: -Wsuggest-attribute=[pure|const|noreturn|format|cold|malloc] + + Warn for cases where adding an attribute may be beneficial. The + attributes currently supported are listed below. + + .. option:: -Wsuggest-attribute=pure, -Wno-suggest-attribute=pure, -Wno-suggest-attribute=const, -Wno-suggest-attribute=noreturn, -Wno-missing-noreturn, -Wno-suggest-attribute=malloc + + Warn about functions that might be candidates for attributes + :fn-attr:`pure`, :fn-attr:`const` or :fn-attr:`noreturn` or ``malloc``. The compiler + only warns for functions visible in other compilation units or (in the case of + :fn-attr:`pure` and :fn-attr:`const`) if it cannot prove that the function returns + normally. A function returns normally if it doesn't contain an infinite loop or + return abnormally by throwing, calling ``abort`` or trapping. This analysis + requires option :option:`-fipa-pure-const`, which is enabled by default at + :option:`-O` and higher. Higher optimization levels improve the accuracy + of the analysis. + + .. option:: -Wsuggest-attribute=format, -Wno-suggest-attribute=format, -Wno-missing-format-attribute + + Warn about function pointers that might be candidates for ``format`` + attributes. Note these are only possible candidates, not absolute ones. + GCC guesses that function pointers with ``format`` attributes that + are used in assignment, initialization, parameter passing or return + statements should have a corresponding ``format`` attribute in the + resulting type. I.e. the left-hand side of the assignment or + initialization, the type of the parameter variable, or the return type + of the containing function respectively should also have a ``format`` + attribute to avoid the warning. + + GCC also warns about function definitions that might be + candidates for ``format`` attributes. Again, these are only + possible candidates. GCC guesses that ``format`` attributes + might be appropriate for any function that calls a function like + ``vprintf`` or ``vscanf``, but this might not always be the + case, and some functions for which ``format`` attributes are + appropriate may not be detected. + + .. option:: -Wsuggest-attribute=cold + + Warn about functions that might be candidates for :fn-attr:`cold` attribute. This + is based on static detection and generally only warns about functions which + always leads to a call to another :fn-attr:`cold` function such as wrappers of + C++ ``throw`` or fatal error reporting functions leading to ``abort``. + + .. option:: -Wno-suggest-attribute=cold + + Default setting; overrides :option:`-Wsuggest-attribute=cold`. + +.. option:: -Walloc-zero + + Warn about calls to allocation functions decorated with attribute + ``alloc_size`` that specify zero bytes, including those to the built-in + forms of the functions ``aligned_alloc``, ``alloca``, ``calloc``, + ``malloc``, and ``realloc``. Because the behavior of these functions + when called with a zero size differs among implementations (and in the case + of ``realloc`` has been deprecated) relying on it may result in subtle + portability bugs and should be avoided. + +.. option:: -Wno-alloc-zero + + Default setting; overrides :option:`-Walloc-zero`. + +.. option:: -Walloc-size-larger-than={byte-size} + + Warn about calls to functions decorated with attribute ``alloc_size`` + that attempt to allocate objects larger than the specified number of bytes, + or where the result of the size computation in an integer type with infinite + precision would exceed the value of :samp:`PTRDIFF_MAX` on the target. + :option:`-Walloc-size-larger-than=PTRDIFF_MAX` is enabled by default. + Warnings controlled by the option can be disabled either by specifying + :samp:`{byte-size}` of :samp:`SIZE_MAX` or more or by + :option:`-Wno-alloc-size-larger-than`. + See :ref:`function-attributes`. + +.. option:: -Wno-alloc-size-larger-than + + Disable :option:`-Walloc-size-larger-than=` warnings. The option is + equivalent to :option:`-Walloc-size-larger-than=SIZE_MAX` or + larger. + +.. option:: -Walloca + + This option warns on all uses of ``alloca`` in the source. + +.. option:: -Wno-alloca + + Default setting; overrides :option:`-Walloca`. + +.. option:: -Walloca-larger-than={byte-size} + + This option warns on calls to ``alloca`` with an integer argument whose + value is either zero, or that is not bounded by a controlling predicate + that limits its value to at most :samp:`{byte-size}`. It also warns for calls + to ``alloca`` where the bound value is unknown. Arguments of non-integer + types are considered unbounded even if they appear to be constrained to + the expected range. + + For example, a bounded case of ``alloca`` could be: + + .. code-block:: c++ + + void func (size_t n) + { + void *p; + if (n <= 1000) + p = alloca (n); + else + p = malloc (n); + f (p); + } + + In the above example, passing ``-Walloca-larger-than=1000`` would not + issue a warning because the call to ``alloca`` is known to be at most + 1000 bytes. However, if ``-Walloca-larger-than=500`` were passed, + the compiler would emit a warning. + + Unbounded uses, on the other hand, are uses of ``alloca`` with no + controlling predicate constraining its integer argument. For example: + + .. code-block:: c++ + + void func () + { + void *p = alloca (n); + f (p); + } + + If ``-Walloca-larger-than=500`` were passed, the above would trigger + a warning, but this time because of the lack of bounds checking. + + Note, that even seemingly correct code involving signed integers could + cause a warning: + + .. code-block:: c++ + + void func (signed int n) + { + if (n < 500) + { + p = alloca (n); + f (p); + } + } + + In the above example, :samp:`{n}` could be negative, causing a larger than + expected argument to be implicitly cast into the ``alloca`` call. + + This option also warns when ``alloca`` is used in a loop. + + :option:`-Walloca-larger-than=PTRDIFF_MAX` is enabled by default + but is usually only effective when :option:`-ftree-vrp` is active (default + for :option:`-O2` and above). + + See also :option:`-Wvla-larger-than=byte-size`. + +.. option:: -Wno-alloca-larger-than + + Disable :option:`-Walloca-larger-than=` warnings. The option is + equivalent to :option:`-Walloca-larger-than=SIZE_MAX` or larger. + +.. option:: -Warith-conversion + + Do warn about implicit conversions from arithmetic operations even + when conversion of the operands to the same type cannot change their + values. This affects warnings from :option:`-Wconversion`, + :option:`-Wfloat-conversion`, and :option:`-Wsign-conversion`. + + .. code-block:: c++ + + void f (char c, int i) + { + c = c + i; // warns with -Wconversion + c = c + 1; // only warns with -Warith-conversion + } + +.. option:: -Wno-arith-conversion + + Default setting; overrides :option:`-Warith-conversion`. + +.. option:: -Warray-bounds, -Warray-bounds={n} + + Warn about out of bounds subscripts or offsets into arrays. This warning + is enabled by :option:`-Wall`. It is more effective when :option:`-ftree-vrp` + is active (the default for :option:`-O2` and above) but a subset of instances + are issued even without optimization. + + ``-Warray-bounds=1`` + This is the default warning level of :option:`-Warray-bounds` and is enabled + by :option:`-Wall` ; higher levels are not, and must be explicitly requested. + + ``-Warray-bounds=2`` + This warning level also warns about out of bounds accesses to trailing + struct members of one-element array types (see :ref:`zero-length`) and about + the intermediate results of pointer arithmetic that may yield out of bounds + values. This warning level may give a larger number of false positives and + is deactivated by default. + +.. option:: -Wno-array-bounds + + Default setting; overrides :option:`-Warray-bounds`. + +.. option:: -Warray-compare + + Warn about equality and relational comparisons between two operands of array + type. This comparison was deprecated in C++20. For example: + + .. code-block:: c++ + + int arr1[5]; + int arr2[5]; + bool same = arr1 == arr2; + + :option:`-Warray-compare` is enabled by :option:`-Wall`. + +.. option:: -Wno-array-compare + + Default setting; overrides :option:`-Warray-compare`. + +.. option:: -Warray-parameter, -Warray-parameter={n} + + Warn about redeclarations of functions involving arguments of array or + pointer types of inconsistent kinds or forms, and enable the detection + of out-of-bounds accesses to such parameters by warnings such as + :option:`-Warray-bounds`. + + If the first function declaration uses the array form the bound specified + in the array is assumed to be the minimum number of elements expected to + be provided in calls to the function and the maximum number of elements + accessed by it. Failing to provide arguments of sufficient size or accessing + more than the maximum number of elements may be diagnosed by warnings such + as :option:`-Warray-bounds`. At level 1 the warning diagnoses inconsistencies + involving array parameters declared using the ``T[static N]`` form. + + For example, the warning triggers for the following redeclarations because + the first one allows an array of any size to be passed to ``f`` while + the second one with the keyword ``static`` specifies that the array + argument must have at least four elements. + + .. code-block:: c++ + + void f (int[static 4]); + void f (int[]); // warning (inconsistent array form) + + void g (void) + { + int *p = (int *)malloc (4); + f (p); // warning (array too small) + ... + } + + At level 2 the warning also triggers for redeclarations involving any other + inconsistency in array or pointer argument forms denoting array sizes. + Pointers and arrays of unspecified bound are considered equivalent and do + not trigger a warning. + + .. code-block:: c++ + + void g (int*); + void g (int[]); // no warning + void g (int[8]); // warning (inconsistent array bound) + + :option:`-Warray-parameter=2` is included in :option:`-Wall`. The + :option:`-Wvla-parameter` option triggers warnings for similar inconsistencies + involving Variable Length Array arguments. + +.. option:: -Wno-array-parameter + + Default setting; overrides :option:`-Warray-parameter`. + +.. option:: -Wattribute-alias={n} + + Warn about declarations using the ``alias`` and similar attributes whose + target is incompatible with the type of the alias. + See :ref:`function-attributes`. + + ``-Wattribute-alias=1`` + The default warning level of the :option:`-Wattribute-alias` option diagnoses + incompatibilities between the type of the alias declaration and that of its + target. Such incompatibilities are typically indicative of bugs. + + ``-Wattribute-alias=2`` + At this level :option:`-Wattribute-alias` also diagnoses cases where + the attributes of the alias declaration are more restrictive than the + attributes applied to its target. These mismatches can potentially + result in incorrect code generation. In other cases they may be + benign and could be resolved simply by adding the missing attribute to + the target. For comparison, see the :option:`-Wmissing-attributes` + option, which controls diagnostics when the alias declaration is less + restrictive than the target, rather than more restrictive. + + Attributes considered include ``alloc_align``, ``alloc_size``, + :fn-attr:`cold`, :fn-attr:`const`, :fn-attr:`hot`, :fn-attr:`leaf`, :fn-attr:`malloc`, + :fn-attr:`nonnull`, :fn-attr:`noreturn`, :fn-attr:`nothrow`, :fn-attr:`pure`, + :fn-attr:`returns_nonnull`, and :fn-attr:`returns_twice`. + + :option:`-Wattribute-alias` is equivalent to :option:`-Wattribute-alias=1`. + This is the default. You can disable these warnings with either + :option:`-Wno-attribute-alias` or :option:`-Wattribute-alias=0`. + +.. option:: -Wattribute-alias + + Default setting; overrides :option:`-Wno-attribute-alias`. + +.. option:: -Wbidi-chars=[none|unpaired|any|ucn] + + Warn about possibly misleading UTF-8 bidirectional control characters in + comments, string literals, character constants, and identifiers. Such + characters can change left-to-right writing direction into right-to-left + (and vice versa), which can cause confusion between the logical order and + visual order. This may be dangerous; for instance, it may seem that a piece + of code is not commented out, whereas it in fact is. + + There are three levels of warning supported by GCC. The default is + :option:`-Wbidi-chars=unpaired`, which warns about improperly terminated + bidi contexts. :option:`-Wbidi-chars=none` turns the warning off. + :option:`-Wbidi-chars=any` warns about any use of bidirectional control + characters. + + By default, this warning does not warn about UCNs. It is, however, possible + to turn on such checking by using :option:`-Wbidi-chars=unpaired,ucn` or + :option:`-Wbidi-chars=any,ucn`. Using :option:`-Wbidi-chars=ucn` is valid, + and is equivalent to :option:`-Wbidi-chars=unpaired,ucn`, if no previous + :option:`-Wbidi-chars=any` was specified. + +.. option:: -Wbool-compare + + Warn about boolean expression compared with an integer value different from + ``true`` / ``false``. For instance, the following comparison is + always false: + + .. code-block:: c++ + + int n = 5; + ... + if ((n > 1) == 2) { ... } + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-bool-compare + + Default setting; overrides :option:`-Wbool-compare`. + +.. option:: -Wbool-operation + + Warn about suspicious operations on expressions of a boolean type. For + instance, bitwise negation of a boolean is very likely a bug in the program. + For C, this warning also warns about incrementing or decrementing a boolean, + which rarely makes sense. (In C++, decrementing a boolean is always invalid. + Incrementing a boolean is invalid in C++17, and deprecated otherwise.) + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-bool-operation + + Default setting; overrides :option:`-Wbool-operation`. + +.. option:: -Wduplicated-branches + + Warn when an if-else has identical branches. This warning detects cases like + + .. code-block:: c++ + + if (p != NULL) + return 0; + else + return 0; + + It doesn't warn when both branches contain just a null statement. This warning + also warn for conditional operators: + + .. code-block:: c++ + + int i = x ? *p : *p; + +.. option:: -Wno-duplicated-branches + + Default setting; overrides :option:`-Wduplicated-branches`. + +.. option:: -Wduplicated-cond + + Warn about duplicated conditions in an if-else-if chain. For instance, + warn for the following code: + + .. code-block:: c++ + + if (p->q != NULL) { ... } + else if (p->q != NULL) { ... } + +.. option:: -Wno-duplicated-cond + + Default setting; overrides :option:`-Wduplicated-cond`. + +.. option:: -Wframe-address + + Warn when the :samp:`__builtin_frame_address` or :samp:`__builtin_return_address` + is called with an argument greater than 0. Such calls may return indeterminate + values or crash the program. The warning is included in :option:`-Wall`. + +.. option:: -Wno-frame-address + + Default setting; overrides :option:`-Wframe-address`. + +.. option:: -Wno-discarded-qualifiers + + .. note:: + + C and Objective-C only + + Do not warn if type qualifiers on pointers are being discarded. + Typically, the compiler warns if a ``const char *`` variable is + passed to a function that takes a ``char *`` parameter. This option + can be used to suppress such a warning. + +.. option:: -Wdiscarded-qualifiers + + Default setting; overrides :option:`-Wno-discarded-qualifiers`. + +.. option:: -Wno-discarded-array-qualifiers + + .. note:: + + C and Objective-C only + + Do not warn if type qualifiers on arrays which are pointer targets + are being discarded. Typically, the compiler warns if a + ``const int (*)[]`` variable is passed to a function that + takes a ``int (*)[]`` parameter. This option can be used to + suppress such a warning. + +.. option:: -Wdiscarded-array-qualifiers + + Default setting; overrides :option:`-Wno-discarded-array-qualifiers`. + +.. option:: -Wno-incompatible-pointer-types + + .. note:: + + C and Objective-C only + + Do not warn when there is a conversion between pointers that have incompatible + types. This warning is for cases not covered by :option:`-Wno-pointer-sign`, + which warns for pointer argument passing or assignment with different + signedness. + +.. option:: -Wincompatible-pointer-types + + Default setting; overrides :option:`-Wno-incompatible-pointer-types`. + +.. option:: -Wno-int-conversion + + .. note:: + + C and Objective-C only + + Do not warn about incompatible integer to pointer and pointer to integer + conversions. This warning is about implicit conversions; for explicit + conversions the warnings :option:`-Wno-int-to-pointer-cast` and + :option:`-Wno-pointer-to-int-cast` may be used. + +.. option:: -Wint-conversion + + Default setting; overrides :option:`-Wno-int-conversion`. + +.. option:: -Wzero-length-bounds + + Warn about accesses to elements of zero-length array members that might + overlap other members of the same object. Declaring interior zero-length + arrays is discouraged because accesses to them are undefined. See + See :ref:`zero-length`. + + For example, the first two stores in function ``bad`` are diagnosed + because the array elements overlap the subsequent members ``b`` and + ``c``. The third store is diagnosed by :option:`-Warray-bounds` + because it is beyond the bounds of the enclosing object. + + .. code-block:: c++ + + struct X { int a[0]; int b, c; }; + struct X x; + + void bad (void) + { + x.a[0] = 0; // -Wzero-length-bounds + x.a[1] = 1; // -Wzero-length-bounds + x.a[2] = 2; // -Warray-bounds + } + + Option :option:`-Wzero-length-bounds` is enabled by :option:`-Warray-bounds`. + +.. option:: -Wno-div-by-zero + + Do not warn about compile-time integer division by zero. Floating-point + division by zero is not warned about, as it can be a legitimate way of + obtaining infinities and NaNs. + +.. option:: -Wdiv-by-zero + + Default setting; overrides :option:`-Wno-div-by-zero`. + +.. index:: warnings from system headers, system headers, warnings from + +.. option:: -Wsystem-headers + + Print warning messages for constructs found in system header files. + Warnings from system headers are normally suppressed, on the assumption + that they usually do not indicate real problems and would only make the + compiler output harder to read. Using this command-line option tells + GCC to emit warnings from system headers as if they occurred in user + code. However, note that using :option:`-Wall` in conjunction with this + option does *not* warn about unknown pragmas in system + headers --- for that, :option:`-Wunknown-pragmas` must also be used. + +.. option:: -Wno-system-headers + + Default setting; overrides :option:`-Wsystem-headers`. + +.. option:: -Wtautological-compare + + Warn if a self-comparison always evaluates to true or false. This + warning detects various mistakes such as: + + .. code-block:: c++ + + int i = 1; + ... + if (i > i) { ... } + + This warning also warns about bitwise comparisons that always evaluate + to true or false, for instance: + + .. code-block:: c++ + + if ((a & 16) == 10) { ... } + + will always be false. + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-tautological-compare + + Default setting; overrides :option:`-Wtautological-compare`. + +.. option:: -Wtrampolines + + Warn about trampolines generated for pointers to nested functions. + A trampoline is a small piece of data or code that is created at run + time on the stack when the address of a nested function is taken, and is + used to call the nested function indirectly. For some targets, it is + made up of data only and thus requires no special treatment. But, for + most targets, it is made up of code and thus requires the stack to be + made executable in order for the program to work properly. + +.. option:: -Wno-trampolines + + Default setting; overrides :option:`-Wtrampolines`. + +.. option:: -Wfloat-equal + + Warn if floating-point values are used in equality comparisons. + + The idea behind this is that sometimes it is convenient (for the + programmer) to consider floating-point values as approximations to + infinitely precise real numbers. If you are doing this, then you need + to compute (by analyzing the code, or in some other way) the maximum or + likely maximum error that the computation introduces, and allow for it + when performing comparisons (and when producing output, but that's a + different problem). In particular, instead of testing for equality, you + should check to see whether the two values have ranges that overlap; and + this is done with the relational operators, so equality comparisons are + probably mistaken. + +.. option:: -Wno-float-equal + + Default setting; overrides :option:`-Wfloat-equal`. + +.. option:: -Wtraditional + + .. note:: + + C and Objective-C only + + Warn about certain constructs that behave differently in traditional and + ISO C. Also warn about ISO C constructs that have no traditional C + equivalent, and/or problematic constructs that should be avoided. + + * Macro parameters that appear within string literals in the macro body. + In traditional C macro replacement takes place within string literals, + but in ISO C it does not. + + * In traditional C, some preprocessor directives did not exist. + Traditional preprocessors only considered a line to be a directive + if the :samp:`#` appeared in column 1 on the line. Therefore + :option:`-Wtraditional` warns about directives that traditional C + understands but ignores because the :samp:`#` does not appear as the + first character on the line. It also suggests you hide directives like + ``#pragma`` not understood by traditional C by indenting them. Some + traditional implementations do not recognize ``#elif``, so this option + suggests avoiding it altogether. + + * A function-like macro that appears without arguments. + + * The unary plus operator. + + * The :samp:`U` integer constant suffix, or the :samp:`F` or :samp:`L` floating-point + constant suffixes. (Traditional C does support the :samp:`L` suffix on integer + constants.) Note, these suffixes appear in macros defined in the system + headers of most modern systems, e.g. the :samp:`_MIN`/:samp:`_MAX` macros in ````. + Use of these macros in user code might normally lead to spurious + warnings, however GCC's integrated preprocessor has enough context to + avoid warning in these cases. + + * A function declared external in one block and then used after the end of + the block. + + * A ``switch`` statement has an operand of type ``long``. + + * A non- ``static`` function declaration follows a ``static`` one. + This construct is not accepted by some traditional C compilers. + + * The ISO type of an integer constant has a different width or + signedness from its traditional type. This warning is only issued if + the base of the constant is ten. I.e. hexadecimal or octal values, which + typically represent bit patterns, are not warned about. + + * Usage of ISO string concatenation is detected. + + * Initialization of automatic aggregates. + + * Identifier conflicts with labels. Traditional C lacks a separate + namespace for labels. + + * Initialization of unions. If the initializer is zero, the warning is + omitted. This is done under the assumption that the zero initializer in + user code appears conditioned on e.g. ``__STDC__`` to avoid missing + initializer warnings and relies on default initialization to zero in the + traditional C case. + + * Conversions by prototypes between fixed/floating-point values and vice + versa. The absence of these prototypes when compiling with traditional + C causes serious problems. This is a subset of the possible + conversion warnings; for the full set use :option:`-Wtraditional-conversion`. + + * Use of ISO C style function definitions. This warning intentionally is + *not* issued for prototype declarations or variadic functions + because these ISO C features appear in your code when using + libiberty's traditional C compatibility macros, ``PARAMS`` and + ``VPARAMS``. This warning is also bypassed for nested functions + because that feature is already a GCC extension and thus not relevant to + traditional C compatibility. + +.. option:: -Wno-traditional + + Default setting; overrides :option:`-Wtraditional`. + +.. option:: -Wtraditional-conversion + + .. note:: + + C and Objective-C only + + Warn if a prototype causes a type conversion that is different from what + would happen to the same argument in the absence of a prototype. This + includes conversions of fixed point to floating and vice versa, and + conversions changing the width or signedness of a fixed-point argument + except when the same as the default promotion. + +.. option:: -Wno-traditional-conversion + + Default setting; overrides :option:`-Wtraditional-conversion`. + +.. option:: -Wdeclaration-after-statement + + .. note:: + + C and Objective-C only + + Warn when a declaration is found after a statement in a block. This + construct, known from C++, was introduced with ISO C99 and is by default + allowed in GCC. It is not supported by ISO C90. See :ref:`mixed-labels-and-declarations`. + +.. option:: -Wno-declaration-after-statement + + Default setting; overrides :option:`-Wdeclaration-after-statement`. + +.. option:: -Wshadow + + Warn whenever a local variable or type declaration shadows another + variable, parameter, type, class member (in C++), or instance variable + (in Objective-C) or whenever a built-in function is shadowed. Note + that in C++, the compiler warns if a local variable shadows an + explicit typedef, but not if it shadows a struct/class/enum. + If this warning is enabled, it includes also all instances of + local shadowing. This means that :option:`-Wno-shadow=local` + and :option:`-Wno-shadow=compatible-local` are ignored when + :option:`-Wshadow` is used. + Same as :option:`-Wshadow=global`. + +.. option:: -Wno-shadow + + Default setting; overrides :option:`-Wshadow`. + +.. option:: -Wno-shadow-ivar + + .. note:: + + Objective-C only + + Do not warn whenever a local variable shadows an instance variable in an + Objective-C method. + +.. option:: -Wshadow-ivar + + Default setting; overrides :option:`-Wno-shadow-ivar`. + +.. option:: -Wshadow=global + + Warn for any shadowing. + Same as :option:`-Wshadow`. + +.. option:: -Wshadow=local + + Warn when a local variable shadows another local variable or parameter. + +.. option:: -Wshadow=compatible-local + + Warn when a local variable shadows another local variable or parameter + whose type is compatible with that of the shadowing variable. In C++, + type compatibility here means the type of the shadowing variable can be + converted to that of the shadowed variable. The creation of this flag + (in addition to :option:`-Wshadow=local`) is based on the idea that when + a local variable shadows another one of incompatible type, it is most + likely intentional, not a bug or typo, as shown in the following example: + + .. code-block:: c++ + + for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i) + { + for (int i = 0; i < N; ++i) + { + ... + } + ... + } + + Since the two variable ``i`` in the example above have incompatible types, + enabling only :option:`-Wshadow=compatible-local` does not emit a warning. + Because their types are incompatible, if a programmer accidentally uses one + in place of the other, type checking is expected to catch that and emit an + error or warning. Use of this flag instead of :option:`-Wshadow=local` can + possibly reduce the number of warnings triggered by intentional shadowing. + Note that this also means that shadowing ``const char *i`` by + ``char *i`` does not emit a warning. + + This warning is also enabled by :option:`-Wshadow=local`. + +.. index:: Wlarger-than-byte-size + +.. option:: -Wlarger-than={byte-size} + + Warn whenever an object is defined whose size exceeds :samp:`{byte-size}`. + :option:`-Wlarger-than=PTRDIFF_MAX` is enabled by default. + Warnings controlled by the option can be disabled either by specifying + :samp:`{byte-size}` of :samp:`SIZE_MAX` or more or by :option:`-Wno-larger-than`. + + Also warn for calls to bounded functions such as ``memchr`` or + ``strnlen`` that specify a bound greater than the largest possible + object, which is :samp:`PTRDIFF_MAX` bytes by default. These warnings + can only be disabled by :option:`-Wno-larger-than`. + +.. option:: -Wno-larger-than + + Disable :option:`-Wlarger-than=` warnings. The option is equivalent + to :option:`-Wlarger-than=SIZE_MAX` or larger. + +.. option:: -Wframe-larger-than={byte-size} + + Warn if the size of a function frame exceeds :samp:`{byte-size}`. + The computation done to determine the stack frame size is approximate + and not conservative. + The actual requirements may be somewhat greater than :samp:`{byte-size}` + even if you do not get a warning. In addition, any space allocated + via ``alloca``, variable-length arrays, or related constructs + is not included by the compiler when determining + whether or not to issue a warning. + :option:`-Wframe-larger-than=PTRDIFF_MAX` is enabled by default. + Warnings controlled by the option can be disabled either by specifying + :samp:`{byte-size}` of :samp:`SIZE_MAX` or more or by + :option:`-Wno-frame-larger-than`. + +.. option:: -Wno-frame-larger-than + + Disable :option:`-Wframe-larger-than=` warnings. The option is equivalent + to :option:`-Wframe-larger-than=SIZE_MAX` or larger. + +.. option:: -Wfree-nonheap-object + + Warn when attempting to deallocate an object that was either not allocated + on the heap, or by using a pointer that was not returned from a prior call + to the corresponding allocation function. For example, because the call + to ``stpcpy`` returns a pointer to the terminating nul character and + not to the beginning of the object, the call to ``free`` below is + diagnosed. + + .. code-block:: c++ + + void f (char *p) + { + p = stpcpy (p, "abc"); + // ... + free (p); // warning + } + + :option:`-Wfree-nonheap-object` is included in :option:`-Wall`. + +.. option:: -Wno-free-nonheap-object + + Default setting; overrides :option:`-Wfree-nonheap-object`. + +.. option:: -Wstack-usage={byte-size} + + Warn if the stack usage of a function might exceed :samp:`{byte-size}`. + The computation done to determine the stack usage is conservative. + Any space allocated via ``alloca``, variable-length arrays, or related + constructs is included by the compiler when determining whether or not to + issue a warning. + + The message is in keeping with the output of :option:`-fstack-usage`. + + * If the stack usage is fully static but exceeds the specified amount, it's: + + .. code-block:: c++ + + warning: stack usage is 1120 bytes + + * If the stack usage is (partly) dynamic but bounded, it's: + + .. code-block:: c++ + + warning: stack usage might be 1648 bytes + + * If the stack usage is (partly) dynamic and not bounded, it's: + + .. code-block:: c++ + + warning: stack usage might be unbounded + + :option:`-Wstack-usage=PTRDIFF_MAX` is enabled by default. + Warnings controlled by the option can be disabled either by specifying + :samp:`{byte-size}` of :samp:`SIZE_MAX` or more or by + :option:`-Wno-stack-usage`. + +.. option:: -Wno-stack-usage + + Disable :option:`-Wstack-usage=` warnings. The option is equivalent + to :option:`-Wstack-usage=SIZE_MAX` or larger. + +.. option:: -Wunsafe-loop-optimizations + + Warn if the loop cannot be optimized because the compiler cannot + assume anything on the bounds of the loop indices. With + :option:`-funsafe-loop-optimizations` warn if the compiler makes + such assumptions. + +.. option:: -Wno-unsafe-loop-optimizations + + Default setting; overrides :option:`-Wunsafe-loop-optimizations`. + +.. option:: -Wno-pedantic-ms-format + + .. note:: + + MinGW targets only + + When used in combination with :option:`-Wformat` + and :option:`-pedantic` without GNU extensions, this option + disables the warnings about non-ISO ``printf`` / ``scanf`` format + width specifiers ``I32``, ``I64``, and ``I`` used on Windows targets, + which depend on the MS runtime. + +.. option:: -Wpedantic-ms-format + + Default setting; overrides :option:`-Wno-pedantic-ms-format`. + +.. option:: -Wpointer-arith + + Warn about anything that depends on the 'size of' a function type or + of ``void``. GNU C assigns these types a size of 1, for + convenience in calculations with ``void *`` pointers and pointers + to functions. In C++, warn also when an arithmetic operation involves + ``NULL``. This warning is also enabled by :option:`-Wpedantic`. + +.. option:: -Wno-pointer-arith + + Default setting; overrides :option:`-Wpointer-arith`. + +.. option:: -Wno-pointer-compare + + Do not warn if a pointer is compared with a zero character constant. + This usually + means that the pointer was meant to be dereferenced. For example: + + .. code-block:: c++ + + const char *p = foo (); + if (p == '\0') + return 42; + + Note that the code above is invalid in C++11. + + This warning is enabled by default. + +.. option:: -Wpointer-compare + + Default setting; overrides :option:`-Wno-pointer-compare`. + +.. option:: -Wtsan + + Warn about unsupported features in ThreadSanitizer. + + ThreadSanitizer does not support ``std::atomic_thread_fence`` and + can report false positives. + + This warning is enabled by default. + +.. option:: -Wno-tsan + + Default setting; overrides :option:`-Wtsan`. + +.. option:: -Wtype-limits + + Warn if a comparison is always true or always false due to the limited + range of the data type, but do not warn for constant expressions. For + example, warn if an unsigned variable is compared against zero with + ``<`` or ``>=``. This warning is also enabled by + :option:`-Wextra`. + +.. option:: -Wno-type-limits + + Default setting; overrides :option:`-Wtype-limits`. + +.. option:: -Wabsolute-value + + .. note:: + + C and Objective-C only + + Warn for calls to standard functions that compute the absolute value + of an argument when a more appropriate standard function is available. + For example, calling ``abs(3.14)`` triggers the warning because the + appropriate function to call to compute the absolute value of a double + argument is ``fabs``. The option also triggers warnings when the + argument in a call to such a function has an unsigned type. This + warning can be suppressed with an explicit type cast and it is also + enabled by :option:`-Wextra`. + +.. option:: -Wno-absolute-value + + Default setting; overrides :option:`-Wabsolute-value`. + +.. include:: ../../../../doc/cppwarnopts.rst + + +.. option:: -Wendif-labels + + Default setting; overrides :option:`-Wno-endif-labels`. + +.. option:: -Wbad-function-cast + + .. note:: + + C and Objective-C only + + Warn when a function call is cast to a non-matching type. + For example, warn if a call to a function returning an integer type + is cast to a pointer type. + +.. option:: -Wno-bad-function-cast + + Default setting; overrides :option:`-Wbad-function-cast`. + +.. option:: -Wc90-c99-compat + + .. note:: + + C and Objective-C only + + Warn about features not present in ISO C90, but present in ISO C99. + For instance, warn about use of variable length arrays, ``long long`` + type, ``bool`` type, compound literals, designated initializers, and so + on. This option is independent of the standards mode. Warnings are disabled + in the expression that follows ``__extension__``. + +.. option:: -Wno-c90-c99-compat + + Default setting; overrides :option:`-Wc90-c99-compat`. + +.. option:: -Wc99-c11-compat + + .. note:: + + C and Objective-C only + + Warn about features not present in ISO C99, but present in ISO C11. + For instance, warn about use of anonymous structures and unions, + ``_Atomic`` type qualifier, ``_Thread_local`` storage-class specifier, + ``_Alignas`` specifier, ``Alignof`` operator, ``_Generic`` keyword, + and so on. This option is independent of the standards mode. Warnings are + disabled in the expression that follows ``__extension__``. + +.. option:: -Wno-c99-c11-compat + + Default setting; overrides :option:`-Wc99-c11-compat`. + +.. option:: -Wc11-c2x-compat + + .. note:: + + C and Objective-C only + + Warn about features not present in ISO C11, but present in ISO C2X. + For instance, warn about omitting the string in ``_Static_assert``, + use of :samp:`[[]]` syntax for attributes, use of decimal + floating-point types, and so on. This option is independent of the + standards mode. Warnings are disabled in the expression that follows + ``__extension__``. + +.. option:: -Wno-c11-c2x-compat + + Default setting; overrides :option:`-Wc11-c2x-compat`. + +.. option:: -Wc++-compat + + .. note:: + + C and Objective-C only + + Warn about ISO C constructs that are outside of the common subset of + ISO C and ISO C++, e.g. request for implicit conversion from + ``void *`` to a pointer to non- ``void`` type. + +.. option:: -Wno-c++-compat + + Default setting; overrides :option:`-Wc++-compat`. + +.. option:: -Wc++11-compat + + .. note:: + + C++ and Objective-C++ only + + Warn about C++ constructs whose meaning differs between ISO C++ 1998 + and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords + in ISO C++ 2011. This warning turns on :option:`-Wnarrowing` and is + enabled by :option:`-Wall`. + +.. option:: -Wno-c++11-compat + + Default setting; overrides :option:`-Wc++11-compat`. + +.. option:: -Wc++14-compat + + .. note:: + + C++ and Objective-C++ only + + Warn about C++ constructs whose meaning differs between ISO C++ 2011 + and ISO C++ 2014. This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-c++14-compat + + Default setting; overrides :option:`-Wc++14-compat`. + +.. option:: -Wc++17-compat + + .. note:: + + C++ and Objective-C++ only + + Warn about C++ constructs whose meaning differs between ISO C++ 2014 + and ISO C++ 2017. This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-c++17-compat + + Default setting; overrides :option:`-Wc++17-compat`. + +.. option:: -Wc++20-compat + + .. note:: + + C++ and Objective-C++ only + + Warn about C++ constructs whose meaning differs between ISO C++ 2017 + and ISO C++ 2020. This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-c++20-compat + + Default setting; overrides :option:`-Wc++20-compat`. + +.. option:: -Wno-c++11-extensions + + .. note:: + + C++ and Objective-C++ only + + Do not warn about C++11 constructs in code being compiled using + an older C++ standard. Even without this option, some C++11 constructs + will only be diagnosed if :option:`-Wpedantic` is used. + +.. option:: -Wc++11-extensions + + Default setting; overrides :option:`-Wno-c++11-extensions`. + +.. option:: -Wno-c++14-extensions + + .. note:: + + C++ and Objective-C++ only + + Do not warn about C++14 constructs in code being compiled using + an older C++ standard. Even without this option, some C++14 constructs + will only be diagnosed if :option:`-Wpedantic` is used. + +.. option:: -Wc++14-extensions + + Default setting; overrides :option:`-Wno-c++14-extensions`. + +.. option:: -Wno-c++17-extensions + + .. note:: + + C++ and Objective-C++ only + + Do not warn about C++17 constructs in code being compiled using + an older C++ standard. Even without this option, some C++17 constructs + will only be diagnosed if :option:`-Wpedantic` is used. + +.. option:: -Wc++17-extensions + + Default setting; overrides :option:`-Wno-c++17-extensions`. + +.. option:: -Wno-c++20-extensions + + .. note:: + + C++ and Objective-C++ only + + Do not warn about C++20 constructs in code being compiled using + an older C++ standard. Even without this option, some C++20 constructs + will only be diagnosed if :option:`-Wpedantic` is used. + +.. option:: -Wc++20-extensions + + Default setting; overrides :option:`-Wno-c++20-extensions`. + +.. option:: -Wno-c++23-extensions + + .. note:: + + C++ and Objective-C++ only + + Do not warn about C++23 constructs in code being compiled using + an older C++ standard. Even without this option, some C++23 constructs + will only be diagnosed if :option:`-Wpedantic` is used. + +.. option:: -Wc++23-extensions + + Default setting; overrides :option:`-Wno-c++23-extensions`. + +.. option:: -Wcast-qual + + Warn whenever a pointer is cast so as to remove a type qualifier from + the target type. For example, warn if a ``const char *`` is cast + to an ordinary ``char *``. + + Also warn when making a cast that introduces a type qualifier in an + unsafe way. For example, casting ``char **`` to ``const char **`` + is unsafe, as in this example: + + .. code-block:: c++ + + /* p is char ** value. */ + const char **q = (const char **) p; + /* Assignment of readonly string to const char * is OK. */ + *q = "string"; + /* Now char** pointer points to read-only memory. */ + **p = 'b'; + +.. option:: -Wno-cast-qual + + Default setting; overrides :option:`-Wcast-qual`. + +.. option:: -Wcast-align + + Warn whenever a pointer is cast such that the required alignment of the + target is increased. For example, warn if a ``char *`` is cast to + an ``int *`` on machines where integers can only be accessed at + two- or four-byte boundaries. + +.. option:: -Wno-cast-align + + Default setting; overrides :option:`-Wcast-align`. + +.. option:: -Wcast-align=strict + + Warn whenever a pointer is cast such that the required alignment of the + target is increased. For example, warn if a ``char *`` is cast to + an ``int *`` regardless of the target machine. + +.. option:: -Wcast-function-type + + Warn when a function pointer is cast to an incompatible function pointer. + In a cast involving function types with a variable argument list only + the types of initial arguments that are provided are considered. + Any parameter of pointer-type matches any other pointer-type. Any benign + differences in integral types are ignored, like ``int`` vs. ``long`` + on ILP32 targets. Likewise type qualifiers are ignored. The function + type ``void (*) (void)`` is special and matches everything, which can + be used to suppress this warning. + In a cast involving pointer to member types this warning warns whenever + the type cast is changing the pointer to member type. + This warning is enabled by :option:`-Wextra`. + +.. option:: -Wno-cast-function-type + + Default setting; overrides :option:`-Wcast-function-type`. + +.. option:: -Wwrite-strings + + When compiling C, give string constants the type ``const + char[length]`` so that copying the address of one into a + non- ``const`` ``char *`` pointer produces a warning. These + warnings help you find at compile time code that can try to write + into a string constant, but only if you have been very careful about + using ``const`` in declarations and prototypes. Otherwise, it is + just a nuisance. This is why we did not make :option:`-Wall` request + these warnings. + + When compiling C++, warn about the deprecated conversion from string + literals to ``char *``. This warning is enabled by default for C++ + programs. + +.. option:: -Wno-write-strings + + Default setting; overrides :option:`-Wwrite-strings`. + +.. option:: -Wclobbered + + Warn for variables that might be changed by ``longjmp`` or + ``vfork``. This warning is also enabled by :option:`-Wextra`. + +.. option:: -Wno-clobbered + + Default setting; overrides :option:`-Wclobbered`. + +.. option:: -Wconversion + + Warn for implicit conversions that may alter a value. This includes + conversions between real and integer, like ``abs (x)`` when + ``x`` is ``double`` ; conversions between signed and unsigned, + like ``unsigned ui = -1`` ; and conversions to smaller types, like + ``sqrtf (M_PI)``. Do not warn for explicit casts like ``abs + ((int) x)`` and ``ui = (unsigned) -1``, or if the value is not + changed by the conversion like in ``abs (2.0)``. Warnings about + conversions between signed and unsigned integers can be disabled by + using :option:`-Wno-sign-conversion`. + + For C++, also warn for confusing overload resolution for user-defined + conversions; and conversions that never use a type conversion + operator: conversions to ``void``, the same type, a base class or a + reference to them. Warnings about conversions between signed and + unsigned integers are disabled by default in C++ unless + :option:`-Wsign-conversion` is explicitly enabled. + + Warnings about conversion from arithmetic on a small type back to that + type are only given with :option:`-Warith-conversion`. + +.. option:: -Wno-conversion + + Default setting; overrides :option:`-Wconversion`. + +.. option:: -Wdangling-else + + Warn about constructions where there may be confusion to which + ``if`` statement an ``else`` branch belongs. Here is an example of + such a case: + + .. code-block:: c++ + + { + if (a) + if (b) + foo (); + else + bar (); + } + + In C/C++, every ``else`` branch belongs to the innermost possible + ``if`` statement, which in this example is ``if (b)``. This is + often not what the programmer expected, as illustrated in the above + example by indentation the programmer chose. When there is the + potential for this confusion, GCC issues a warning when this flag + is specified. To eliminate the warning, add explicit braces around + the innermost ``if`` statement so there is no way the ``else`` + can belong to the enclosing ``if``. The resulting code + looks like this: + + .. code-block:: c++ + + { + if (a) + { + if (b) + foo (); + else + bar (); + } + } + + This warning is enabled by :option:`-Wparentheses`. + +.. option:: -Wno-dangling-else + + Default setting; overrides :option:`-Wdangling-else`. + +.. option:: -Wdangling-pointer, -Wdangling-pointer={n} + + Warn about uses of pointers (or C++ references) to objects with automatic + storage duration after their lifetime has ended. This includes local + variables declared in nested blocks, compound literals and other unnamed + temporary objects. In addition, warn about storing the address of such + objects in escaped pointers. The warning is enabled at all optimization + levels but may yield different results with optimization than without. + + ``-Wdangling-pointer=1`` + At level 1 the warning diagnoses only unconditional uses of dangling pointers. + For example + + .. code-block:: c++ + + int f (int c1, int c2, x) + { + char *p = strchr ((char[]){ c1, c2 }, c3); + return p ? *p : 'x'; // warning: dangling pointer to a compound literal + } + + In the following function the store of the address of the local variable + ``x`` in the escaped pointer ``*p`` also triggers the warning. + + .. code-block:: c++ + + void g (int **p) + { + int x = 7; + *p = &x; // warning: storing the address of a local variable in *p + } + + ``-Wdangling-pointer=2`` + At level 2, in addition to unconditional uses the warning also diagnoses + conditional uses of dangling pointers. + + For example, because the array :samp:`{a}` in the following function is out of + scope when the pointer :samp:`{s}` that was set to point is used, the warning + triggers at this level. + + .. code-block:: c++ + + void f (char *s) + { + if (!s) + { + char a[12] = "tmpname"; + s = a; + } + strcat (s, ".tmp"); // warning: dangling pointer to a may be used + ... + } + + :option:`-Wdangling-pointer=2` is included in :option:`-Wall`. + +.. option:: -Wno-dangling-pointer + + Default setting; overrides :option:`-Wdangling-pointer`. + +.. option:: -Wdate-time + + Warn when macros ``__TIME__``, ``__DATE__`` or ``__TIMESTAMP__`` + are encountered as they might prevent bit-wise-identical reproducible + compilations. + +.. option:: -Wno-date-time + + Default setting; overrides :option:`-Wdate-time`. + +.. option:: -Wempty-body + + Warn if an empty body occurs in an ``if``, ``else`` or ``do + while`` statement. This warning is also enabled by :option:`-Wextra`. + +.. option:: -Wno-empty-body + + Default setting; overrides :option:`-Wempty-body`. + +.. option:: -Wno-endif-labels + + Do not warn about stray tokens after ``#else`` and ``#endif``. + +.. option:: -Wendif-labels + + Default setting; overrides :option:`-Wno-endif-labels`. + +.. option:: -Wenum-compare + + Warn about a comparison between values of different enumerated types. + In C++ enumerated type mismatches in conditional expressions are also + diagnosed and the warning is enabled by default. In C this warning is + enabled by :option:`-Wall`. + +.. option:: -Wno-enum-compare + + Default setting; overrides :option:`-Wenum-compare`. + +.. option:: -Wenum-conversion + + Warn when a value of enumerated type is implicitly converted to a + different enumerated type. This warning is enabled by :option:`-Wextra` + in C. + +.. option:: -Wno-enum-conversion + + Default setting; overrides :option:`-Wenum-conversion`. + +.. option:: -Wenum-int-mismatch + + .. note:: + + C and Objective-C only + + Warn about mismatches between an enumerated type and an integer type in + declarations. For example: + + .. code-block:: c++ + + enum E { l = -1, z = 0, g = 1 }; + int foo(void); + enum E foo(void); + + In C, an enumerated type is compatible with ``char``, a signed + integer type, or an unsigned integer type. However, since the choice + of the underlying type of an enumerated type is implementation-defined, + such mismatches may cause portability issues. In C++, such mismatches + are an error. In C, this warning is enabled by :option:`-Wall` and + :option:`-Wc++-compat`. + +.. option:: -Wno-enum-int-mismatch + + Default setting; overrides :option:`-Wenum-int-mismatch`. + +.. option:: -Wjump-misses-init + + .. note:: + + C, Objective-C only + + Warn if a ``goto`` statement or a ``switch`` statement jumps + forward across the initialization of a variable, or jumps backward to a + label after the variable has been initialized. This only warns about + variables that are initialized when they are declared. This warning is + only supported for C and Objective-C; in C++ this sort of branch is an + error in any case. + + :option:`-Wjump-misses-init` is included in :option:`-Wc++-compat`. It + can be disabled with the :option:`-Wno-jump-misses-init` option. + +.. option:: -Wno-jump-misses-init + + Default setting; overrides :option:`-Wjump-misses-init`. + +.. index:: warning for comparison of signed and unsigned values, comparison of signed and unsigned values, warning, signed and unsigned values, comparison warning + +.. option:: -Wsign-compare + + Warn when a comparison between signed and unsigned values could produce + an incorrect result when the signed value is converted to unsigned. + In C++, this warning is also enabled by :option:`-Wall`. In C, it is + also enabled by :option:`-Wextra`. + +.. option:: -Wno-sign-compare + + Default setting; overrides :option:`-Wsign-compare`. + +.. option:: -Wsign-conversion + + Warn for implicit conversions that may change the sign of an integer + value, like assigning a signed integer expression to an unsigned + integer variable. An explicit cast silences the warning. In C, this + option is enabled also by :option:`-Wconversion`. + +.. option:: -Wno-sign-conversion + + Default setting; overrides :option:`-Wsign-conversion`. + +.. option:: -Wfloat-conversion + + Warn for implicit conversions that reduce the precision of a real value. + This includes conversions from real to integer, and from higher precision + real to lower precision real values. This option is also enabled by + :option:`-Wconversion`. + +.. option:: -Wno-float-conversion + + Default setting; overrides :option:`-Wfloat-conversion`. + +.. option:: -Wno-scalar-storage-order + + Do not warn on suspicious constructs involving reverse scalar storage order. + +.. option:: -Wscalar-storage-order + + Default setting; overrides :option:`-Wno-scalar-storage-order`. + +.. option:: -Wsizeof-array-div + + Warn about divisions of two sizeof operators when the first one is applied + to an array and the divisor does not equal the size of the array element. + In such a case, the computation will not yield the number of elements in the + array, which is likely what the user intended. This warning warns e.g. about + + .. code-block:: c++ + + int fn () + { + int arr[10]; + return sizeof (arr) / sizeof (short); + } + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-sizeof-array-div + + Default setting; overrides :option:`-Wsizeof-array-div`. + +.. option:: -Wsizeof-pointer-div + + Warn for suspicious divisions of two sizeof expressions that divide + the pointer size by the element size, which is the usual way to compute + the array size but won't work out correctly with pointers. This warning + warns e.g. about ``sizeof (ptr) / sizeof (ptr[0])`` if ``ptr`` is + not an array, but a pointer. This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-sizeof-pointer-div + + Default setting; overrides :option:`-Wsizeof-pointer-div`. + +.. option:: -Wsizeof-pointer-memaccess + + Warn for suspicious length parameters to certain string and memory built-in + functions if the argument uses ``sizeof``. This warning triggers for + example for ``memset (ptr, 0, sizeof (ptr));`` if ``ptr`` is not + an array, but a pointer, and suggests a possible fix, or about + ``memcpy (&foo, ptr, sizeof (&foo));``. :option:`-Wsizeof-pointer-memaccess` + also warns about calls to bounded string copy functions like ``strncat`` + or ``strncpy`` that specify as the bound a ``sizeof`` expression of + the source array. For example, in the following function the call to + ``strncat`` specifies the size of the source string as the bound. That + is almost certainly a mistake and so the call is diagnosed. + + .. code-block:: c++ + + void make_file (const char *name) + { + char path[PATH_MAX]; + strncpy (path, name, sizeof path - 1); + strncat (path, ".text", sizeof ".text"); + ... + } + + The :option:`-Wsizeof-pointer-memaccess` option is enabled by :option:`-Wall`. + +.. option:: -Wno-sizeof-pointer-memaccess + + Default setting; overrides :option:`-Wsizeof-pointer-memaccess`. + +.. option:: -Wno-sizeof-array-argument + + Do not warn when the ``sizeof`` operator is applied to a parameter that is + declared as an array in a function definition. This warning is enabled by + default for C and C++ programs. + +.. option:: -Wsizeof-array-argument + + Default setting; overrides :option:`-Wno-sizeof-array-argument`. + +.. option:: -Wmemset-elt-size + + Warn for suspicious calls to the ``memset`` built-in function, if the + first argument references an array, and the third argument is a number + equal to the number of elements, but not equal to the size of the array + in memory. This indicates that the user has omitted a multiplication by + the element size. This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-memset-elt-size + + Default setting; overrides :option:`-Wmemset-elt-size`. + +.. option:: -Wmemset-transposed-args + + Warn for suspicious calls to the ``memset`` built-in function where + the second argument is not zero and the third argument is zero. For + example, the call ``memset (buf, sizeof buf, 0)`` is diagnosed because + ``memset (buf, 0, sizeof buf)`` was meant instead. The diagnostic + is only emitted if the third argument is a literal zero. Otherwise, if + it is an expression that is folded to zero, or a cast of zero to some + type, it is far less likely that the arguments have been mistakenly + transposed and no warning is emitted. This warning is enabled + by :option:`-Wall`. + +.. option:: -Wno-memset-transposed-args + + Default setting; overrides :option:`-Wmemset-transposed-args`. + +.. option:: -Waddress + + Warn about suspicious uses of address expressions. These include comparing + the address of a function or a declared object to the null pointer constant + such as in + + .. code-block:: c++ + + void f (void); + void g (void) + { + if (!f) // warning: expression evaluates to false + abort (); + } + + comparisons of a pointer to a string literal, such as in + + .. code-block:: c++ + + void f (const char *x) + { + if (x == "abc") // warning: expression evaluates to false + puts ("equal"); + } + + and tests of the results of pointer addition or subtraction for equality + to null, such as in + + .. code-block:: c++ + + void f (const int *p, int i) + { + return p + i == NULL; + } + + Such uses typically indicate a programmer error: the address of most + functions and objects necessarily evaluates to true (the exception are + weak symbols), so their use in a conditional might indicate missing + parentheses in a function call or a missing dereference in an array + expression. The subset of the warning for object pointers can be + suppressed by casting the pointer operand to an integer type such + as ``intptr_t`` or ``uintptr_t``. + Comparisons against string literals result in unspecified behavior + and are not portable, and suggest the intent was to call ``strcmp``. + The warning is suppressed if the suspicious expression is the result + of macro expansion. + :option:`-Waddress` warning is enabled by :option:`-Wall`. + +.. option:: -Wno-address + + Default setting; overrides :option:`-Waddress`. + +.. option:: -Wno-address-of-packed-member + + Do not warn when the address of packed member of struct or union is taken, + which usually results in an unaligned pointer value. This is + enabled by default. + +.. option:: -Waddress-of-packed-member + + Default setting; overrides :option:`-Wno-address-of-packed-member`. + +.. option:: -Wlogical-op + + Warn about suspicious uses of logical operators in expressions. + This includes using logical operators in contexts where a + bit-wise operator is likely to be expected. Also warns when + the operands of a logical operator are the same: + + .. code-block:: c++ + + extern int a; + if (a < 0 && a < 0) { ... } + +.. option:: -Wno-logical-op + + Default setting; overrides :option:`-Wlogical-op`. + +.. option:: -Wlogical-not-parentheses + + Warn about logical not used on the left hand side operand of a comparison. + This option does not warn if the right operand is considered to be a boolean + expression. Its purpose is to detect suspicious code like the following: + + .. code-block:: c++ + + int a; + ... + if (!a > 1) { ... } + + It is possible to suppress the warning by wrapping the LHS into + parentheses: + + .. code-block:: c++ + + if ((!a) > 1) { ... } + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-logical-not-parentheses + + Default setting; overrides :option:`-Wlogical-not-parentheses`. + +.. option:: -Waggregate-return + + Warn if any functions that return structures or unions are defined or + called. (In languages where you can return an array, this also elicits + a warning.) + +.. option:: -Wno-aggregate-return + + Default setting; overrides :option:`-Waggregate-return`. + +.. option:: -Wno-aggressive-loop-optimizations + + Warn if in a loop with constant number of iterations the compiler detects + undefined behavior in some statement during one or more of the iterations. + +.. option:: -Waggressive-loop-optimizations + + Default setting; overrides :option:`-Wno-aggressive-loop-optimizations`. + +.. option:: -Wno-attributes + + Do not warn if an unexpected ``__attribute__`` is used, such as + unrecognized attributes, function attributes applied to variables, + etc. This does not stop errors for incorrect use of supported + attributes. + + Additionally, using :option:`-Wno-attributes=`, it is possible to suppress + warnings about unknown scoped attributes (in C++11 and C2X). For example, + :option:`-Wno-attributes=vendor::attr` disables warning about the following + declaration: + + .. code-block:: c++ + + [[vendor::attr]] void f(); + + It is also possible to disable warning about all attributes in a namespace + using :option:`-Wno-attributes=vendor::` which prevents warning about both + of these declarations: + + .. code-block:: c++ + + [[vendor::safe]] void f(); + [[vendor::unsafe]] void f2(); + + Note that :option:`-Wno-attributes=` does not imply :option:`-Wno-attributes`. + +.. option:: -Wattributes + + Default setting; overrides :option:`-Wno-attributes`. + +.. option:: -Wno-builtin-declaration-mismatch + + Warn if a built-in function is declared with an incompatible signature + or as a non-function, or when a built-in function declared with a type + that does not include a prototype is called with arguments whose promoted + types do not match those expected by the function. When :option:`-Wextra` + is specified, also warn when a built-in function that takes arguments is + declared without a prototype. The :option:`-Wbuiltin-declaration-mismatch` + warning is enabled by default. To avoid the warning include the appropriate + header to bring the prototypes of built-in functions into scope. + + For example, the call to ``memset`` below is diagnosed by the warning + because the function expects a value of type ``size_t`` as its argument + but the type of ``32`` is ``int``. With :option:`-Wextra`, + the declaration of the function is diagnosed as well. + + .. code-block:: c++ + + extern void* memset (); + void f (void *d) + { + memset (d, '\0', 32); + } + +.. option:: -Wbuiltin-declaration-mismatch + + Default setting; overrides :option:`-Wno-builtin-declaration-mismatch`. + +.. option:: -Wno-builtin-macro-redefined + + Do not warn if certain built-in macros are redefined. This suppresses + warnings for redefinition of ``__TIMESTAMP__``, ``__TIME__``, + ``__DATE__``, ``__FILE__``, and ``__BASE_FILE__``. + +.. option:: -Wbuiltin-macro-redefined + + Default setting; overrides :option:`-Wno-builtin-macro-redefined`. + +.. option:: -Wstrict-prototypes + + .. note:: + + C and Objective-C only + + Warn if a function is declared or defined without specifying the + argument types. (An old-style function definition is permitted without + a warning if preceded by a declaration that specifies the argument + types.) + +.. option:: -Wno-strict-prototypes + + Default setting; overrides :option:`-Wstrict-prototypes`. + +.. option:: -Wold-style-declaration + + .. note:: + + C and Objective-C only + + Warn for obsolescent usages, according to the C Standard, in a + declaration. For example, warn if storage-class specifiers like + ``static`` are not the first things in a declaration. This warning + is also enabled by :option:`-Wextra`. + +.. option:: -Wno-old-style-declaration + + Default setting; overrides :option:`-Wold-style-declaration`. + +.. option:: -Wold-style-definition + + .. note:: + + C and Objective-C only + + Warn if an old-style function definition is used. A warning is given + even if there is a previous prototype. A definition using :samp:`()` + is not considered an old-style definition in C2X mode, because it is + equivalent to :samp:`(void)` in that case, but is considered an + old-style definition for older standards. + +.. option:: -Wno-old-style-definition + + Default setting; overrides :option:`-Wold-style-definition`. + +.. option:: -Wmissing-parameter-type + + .. note:: + + C and Objective-C only + + A function parameter is declared without a type specifier in K&R-style + functions: + + .. code-block:: c++ + + void foo(bar) { } + + This warning is also enabled by :option:`-Wextra`. + +.. option:: -Wno-missing-parameter-type + + Default setting; overrides :option:`-Wmissing-parameter-type`. + +.. option:: -Wmissing-prototypes + + .. note:: + + C and Objective-C only + + Warn if a global function is defined without a previous prototype + declaration. This warning is issued even if the definition itself + provides a prototype. Use this option to detect global functions + that do not have a matching prototype declaration in a header file. + This option is not valid for C++ because all function declarations + provide prototypes and a non-matching declaration declares an + overload rather than conflict with an earlier declaration. + Use :option:`-Wmissing-declarations` to detect missing declarations in C++. + +.. option:: -Wno-missing-prototypes + + Default setting; overrides :option:`-Wmissing-prototypes`. + +.. option:: -Wmissing-declarations + + Warn if a global function is defined without a previous declaration. + Do so even if the definition itself provides a prototype. + Use this option to detect global functions that are not declared in + header files. In C, no warnings are issued for functions with previous + non-prototype declarations; use :option:`-Wmissing-prototypes` to detect + missing prototypes. In C++, no warnings are issued for function templates, + or for inline functions, or for functions in anonymous namespaces. + +.. option:: -Wno-missing-declarations + + Default setting; overrides :option:`-Wmissing-declarations`. + +.. option:: -Wmissing-field-initializers + + Warn if a structure's initializer has some fields missing. For + example, the following code causes such a warning, because + ``x.h`` is implicitly zero: + + .. code-block:: c++ + + struct s { int f, g, h; }; + struct s x = { 3, 4 }; + + This option does not warn about designated initializers, so the following + modification does not trigger a warning: + + .. code-block:: c++ + + struct s { int f, g, h; }; + struct s x = { .f = 3, .g = 4 }; + + In C this option does not warn about the universal zero initializer + :samp:`{ 0 }`: + + .. code-block:: c++ + + struct s { int f, g, h; }; + struct s x = { 0 }; + + Likewise, in C++ this option does not warn about the empty { } + initializer, for example: + + .. code-block:: c++ + + struct s { int f, g, h; }; + s x = { }; + + This warning is included in :option:`-Wextra`. To get other :option:`-Wextra` + warnings without this one, use :option:`-Wextra -Wno-missing-field-initializers`. + +.. option:: -Wno-missing-field-initializers + + Default setting; overrides :option:`-Wmissing-field-initializers`. + +.. option:: -Wno-missing-requires + + By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement: + + .. code-block:: c++ + + bool satisfied = requires { C }; + + Here :samp:`satisfied` will be true if :samp:`C` is a valid + expression, which it is for all T. Presumably the user meant to write + + .. code-block:: c++ + + bool satisfied = requires { requires C }; + + so :samp:`satisfied` is only true if concept :samp:`C` is satisfied for + type :samp:`T`. + + This warning can be disabled with :option:`-Wno-missing-requires`. + +.. option:: -Wmissing-requires + + Default setting; overrides :option:`-Wno-missing-requires`. + +.. option:: -Wno-missing-template-keyword + + The member access tokens ., -> and :: must be followed by the ``template`` + keyword if the parent object is dependent and the member being named is a + template. + + .. code-block:: c++ + + template + void DoStuff (X x) + { + x.template DoSomeOtherStuff(); // Good. + x.DoMoreStuff(); // Warning, x is dependent. + } + + In rare cases it is possible to get false positives. To silence this, wrap + the expression in parentheses. For example, the following is treated as a + template, even where m and N are integers: + + .. code-block:: c++ + + void NotATemplate (my_class t) + { + int N = 5; + + bool test = t.m < N > (0); // Treated as a template. + test = (t.m < N) > (0); // Same meaning, but not treated as a template. + } + + This warning can be disabled with :option:`-Wno-missing-template-keyword`. + +.. option:: -Wmissing-template-keyword + + Default setting; overrides :option:`-Wno-missing-template-keyword`. + +.. option:: -Wno-multichar + + Do not warn if a multicharacter constant (:samp:`'FOOF'`) is used. + Usually they indicate a typo in the user's code, as they have + implementation-defined values, and should not be used in portable code. + +.. option:: -Wmultichar + + Default setting; overrides :option:`-Wno-multichar`. + +.. index:: NFC, NFKC, character set, input normalization + +.. option:: -Wnormalized=[none|id|nfc|nfkc] + + In ISO C and ISO C++, two identifiers are different if they are + different sequences of characters. However, sometimes when characters + outside the basic ASCII character set are used, you can have two + different character sequences that look the same. To avoid confusion, + the ISO 10646 standard sets out some :dfn:`normalization rules` which + when applied ensure that two sequences that look the same are turned into + the same sequence. GCC can warn you if you are using identifiers that + have not been normalized; this option controls that warning. + + There are four levels of warning supported by GCC. The default is + :option:`-Wnormalized=nfc`, which warns about any identifier that is + not in the ISO 10646 'C' normalized form, :dfn:`NFC`. NFC is the + recommended form for most uses. It is equivalent to + :option:`-Wnormalized`. + + Unfortunately, there are some characters allowed in identifiers by + ISO C and ISO C++ that, when turned into NFC, are not allowed in + identifiers. That is, there's no way to use these symbols in portable + ISO C or C++ and have all your identifiers in NFC. + :option:`-Wnormalized=id` suppresses the warning for these characters. + It is hoped that future versions of the standards involved will correct + this, which is why this option is not the default. + + You can switch the warning off for all characters by writing + :option:`-Wnormalized=none` or :option:`-Wno-normalized`. You should + only do this if you are using some other normalization scheme (like + 'D'), because otherwise you can easily create bugs that are + literally impossible to see. + + Some characters in ISO 10646 have distinct meanings but look identical + in some fonts or display methodologies, especially once formatting has + been applied. For instance ``\u207F``, 'SUPERSCRIPT LATIN SMALL + LETTER N', displays just like a regular ``n`` that has been + placed in a superscript. ISO 10646 defines the :dfn:`NFKC` + normalization scheme to convert all these into a standard form as + well, and GCC warns if your code is not in NFKC if you use + :option:`-Wnormalized=nfkc`. This warning is comparable to warning + about every identifier that contains the letter O because it might be + confused with the digit 0, and so is not the default, but may be + useful as a local coding convention if the programming environment + cannot be fixed to display these characters distinctly. + +.. option:: -Wno-attribute-warning + + Do not warn about usage of functions (see :ref:`function-attributes`) + declared with ``warning`` attribute. By default, this warning is + enabled. :option:`-Wno-attribute-warning` can be used to disable the + warning or :option:`-Wno-error=attribute-warning` can be used to + disable the error when compiled with :option:`-Werror` flag. + +.. option:: -Wattribute-warning + + Default setting; overrides :option:`-Wno-attribute-warning`. + +.. option:: -Wno-deprecated + + Do not warn about usage of deprecated features. See :ref:`deprecated-features`. + +.. option:: -Wdeprecated + + Default setting; overrides :option:`-Wno-deprecated`. + +.. option:: -Wno-deprecated-declarations + + Do not warn about uses of functions (see :ref:`function-attributes`), + variables (see :ref:`variable-attributes`), and types (see :ref:`type-attributes`) marked as deprecated by using the ``deprecated`` + attribute. + +.. option:: -Wdeprecated-declarations + + Default setting; overrides :option:`-Wno-deprecated-declarations`. + +.. option:: -Wno-overflow + + Do not warn about compile-time overflow in constant expressions. + +.. option:: -Woverflow + + Default setting; overrides :option:`-Wno-overflow`. + +.. option:: -Wno-odr + + Warn about One Definition Rule violations during link-time optimization. + Enabled by default. + +.. option:: -Wodr + + Default setting; overrides :option:`-Wno-odr`. + +.. index:: OpenACC accelerator programming + +.. option:: -Wopenacc-parallelism + + Warn about potentially suboptimal choices related to OpenACC parallelism. + +.. option:: -Wno-openacc-parallelism + + Default setting; overrides :option:`-Wopenacc-parallelism`. + +.. option:: -Wopenmp-simd + + Warn if the vectorizer cost model overrides the OpenMP + simd directive set by user. The :option:`-fsimd-cost-model=unlimited` + option can be used to relax the cost model. + +.. option:: -Wno-openmp-simd + + Default setting; overrides :option:`-Wopenmp-simd`. + +.. option:: -Woverride-init + + .. note:: + + C and Objective-C only + + Warn if an initialized field without side effects is overridden when + using designated initializers (see :ref:`designated-inits`). + + This warning is included in :option:`-Wextra`. To get other + :option:`-Wextra` warnings without this one, use :option:`-Wextra + -Wno-override-init`. + +.. option:: -Wno-override-init + + Default setting; overrides :option:`-Woverride-init`. + +.. option:: -Wno-override-init-side-effects + + .. note:: + + C and Objective-C only + + Do not warn if an initialized field with side effects is overridden when + using designated initializers (see :ref:`designated-inits`). This warning is enabled by default. + +.. option:: -Woverride-init-side-effects + + Default setting; overrides :option:`-Wno-override-init-side-effects`. + +.. option:: -Wpacked + + Warn if a structure is given the packed attribute, but the packed + attribute has no effect on the layout or size of the structure. + Such structures may be mis-aligned for little benefit. For + instance, in this code, the variable ``f.x`` in ``struct bar`` + is misaligned even though ``struct bar`` does not itself + have the packed attribute: + + .. code-block:: c++ + + struct foo { + int x; + char a, b, c, d; + } __attribute__((packed)); + struct bar { + char z; + struct foo f; + }; + +.. option:: -Wno-packed + + Default setting; overrides :option:`-Wpacked`. + +.. option:: -Wnopacked-bitfield-compat + + The 4.1, 4.2 and 4.3 series of GCC ignore the :var-attr:`packed` attribute + on bit-fields of type ``char``. This was fixed in GCC 4.4 but + the change can lead to differences in the structure layout. GCC + informs you when the offset of such a field has changed in GCC 4.4. + For example there is no longer a 4-bit padding between field ``a`` + and ``b`` in this structure: + + .. code-block:: c++ + + struct foo + { + char a:4; + char b:8; + } __attribute__ ((packed)); + + This warning is enabled by default. Use + :option:`-Wno-packed-bitfield-compat` to disable this warning. + +.. option:: -Wpacked-not-aligned + + .. note:: + + C, C++, Objective-C and Objective-C++ only + + Warn if a structure field with explicitly specified alignment in a + packed struct or union is misaligned. For example, a warning will + be issued on ``struct S``, like, ``warning: alignment 1 of + 'struct S' is less than 8``, in this code: + + .. code-block:: c++ + + struct __attribute__ ((aligned (8))) S8 { char a[8]; }; + struct __attribute__ ((packed)) S { + struct S8 s8; + }; + + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-packed-not-aligned + + Default setting; overrides :option:`-Wpacked-not-aligned`. + +.. option:: -Wpadded + + Warn if padding is included in a structure, either to align an element + of the structure or to align the whole structure. Sometimes when this + happens it is possible to rearrange the fields of the structure to + reduce the padding and so make the structure smaller. + +.. option:: -Wno-padded + + Default setting; overrides :option:`-Wpadded`. + +.. option:: -Wredundant-decls + + Warn if anything is declared more than once in the same scope, even in + cases where multiple declaration is valid and changes nothing. + +.. option:: -Wno-redundant-decls + + Default setting; overrides :option:`-Wredundant-decls`. + +.. option:: -Wrestrict + + Warn when an object referenced by a ``restrict`` -qualified parameter + (or, in C++, a ``__restrict`` -qualified parameter) is aliased by another + argument, or when copies between such objects overlap. For example, + the call to the ``strcpy`` function below attempts to truncate the string + by replacing its initial characters with the last four. However, because + the call writes the terminating NUL into ``a[4]``, the copies overlap and + the call is diagnosed. + + .. code-block:: c++ + + void foo (void) + { + char a[] = "abcd1234"; + strcpy (a, a + 4); + ... + } + + The :option:`-Wrestrict` option detects some instances of simple overlap + even without optimization but works best at :option:`-O2` and above. It + is included in :option:`-Wall`. + +.. option:: -Wno-restrict + + Default setting; overrides :option:`-Wrestrict`. + +.. option:: -Wnested-externs + + .. note:: + + C and Objective-C only + + Warn if an ``extern`` declaration is encountered within a function. + +.. option:: -Wno-nested-externs + + Default setting; overrides :option:`-Wnested-externs`. + +.. option:: -Winline + + Warn if a function that is declared as inline cannot be inlined. + Even with this option, the compiler does not warn about failures to + inline functions declared in system headers. + + The compiler uses a variety of heuristics to determine whether or not + to inline a function. For example, the compiler takes into account + the size of the function being inlined and the amount of inlining + that has already been done in the current function. Therefore, + seemingly insignificant changes in the source program can cause the + warnings produced by :option:`-Winline` to appear or disappear. + +.. option:: -Wno-inline + + Default setting; overrides :option:`-Winline`. + +.. option:: -Winterference-size + + Warn about use of C++17 ``std::hardware_destructive_interference_size`` + without specifying its value with :option:`--param destructive-interference-size`. + Also warn about questionable values for that option. + + This variable is intended to be used for controlling class layout, to + avoid false sharing in concurrent code: + + .. code-block:: c++ + + struct independent_fields { + alignas(std::hardware_destructive_interference_size) std::atomic one; + alignas(std::hardware_destructive_interference_size) std::atomic two; + }; + + Here :samp:`one` and :samp:`two` are intended to be far enough apart + that stores to one won't require accesses to the other to reload the + cache line. + + By default, :option:`--param destructive-interference-size` and + :option:`--param constructive-interference-size` are set based on the + current :option:`-mtune` option, typically to the L1 cache line size + for the particular target CPU, sometimes to a range if tuning for a + generic target. So all translation units that depend on ABI + compatibility for the use of these variables must be compiled with + the same :option:`-mtune` (or :option:`-mcpu`). + + If ABI stability is important, such as if the use is in a header for a + library, you should probably not use the hardware interference size + variables at all. Alternatively, you can force a particular value + with :option:`--param`. + + If you are confident that your use of the variable does not affect ABI + outside a single build of your project, you can turn off the warning + with :option:`-Wno-interference-size`. + +.. option:: -Wint-in-bool-context + + Warn for suspicious use of integer values where boolean values are expected, + such as conditional expressions (?:) using non-boolean integer constants in + boolean context, like ``if (a <= b ? 2 : 3)``. Or left shifting of signed + integers in boolean context, like ``for (a = 0; 1 << a; a++);``. Likewise + for all kinds of multiplications regardless of the data type. + This warning is enabled by :option:`-Wall`. + +.. option:: -Wno-int-in-bool-context + + Default setting; overrides :option:`-Wint-in-bool-context`. + +.. option:: -Wno-int-to-pointer-cast + + Suppress warnings from casts to pointer type of an integer of a + different size. In C++, casting to a pointer type of smaller size is + an error. Wint-to-pointer-cast is enabled by default. + +.. option:: -Wint-to-pointer-cast + + Default setting; overrides :option:`-Wno-int-to-pointer-cast`. + +.. option:: -Wno-pointer-to-int-cast + + .. note:: + + C and Objective-C only + + Suppress warnings from casts from a pointer to an integer type of a + different size. + +.. option:: -Wpointer-to-int-cast + + Default setting; overrides :option:`-Wno-pointer-to-int-cast`. + +.. option:: -Winvalid-pch + + Warn if a precompiled header (see :ref:`precompiled-headers`) is found in + the search path but cannot be used. + +.. option:: -Wno-invalid-pch + + Default setting; overrides :option:`-Winvalid-pch`. + +.. option:: -Winvalid-utf8 + + Warn if an invalid UTF-8 character is found. + This warning is on by default for C++23 if :option:`-finput-charset=UTF-8` + is used and turned into error with :option:`-pedantic-errors`. + +.. option:: -Wno-invalid-utf8 + + Default setting; overrides :option:`-Winvalid-utf8`. + +.. option:: -Wno-unicode + + Don't diagnose invalid forms of delimited or named escape sequences which are + treated as separate tokens. Wunicode is enabled by default. + +.. option:: -Wunicode + + Default setting; overrides :option:`-Wno-unicode`. + +.. option:: -Wlong-long + + Warn if ``long long`` type is used. This is enabled by either + :option:`-Wpedantic` or :option:`-Wtraditional` in ISO C90 and C++98 + modes. To inhibit the warning messages, use :option:`-Wno-long-long`. + +.. option:: -Wno-long-long + + Default setting; overrides :option:`-Wlong-long`. + +.. option:: -Wvariadic-macros + + Warn if variadic macros are used in ISO C90 mode, or if the GNU + alternate syntax is used in ISO C99 mode. This is enabled by either + :option:`-Wpedantic` or :option:`-Wtraditional`. To inhibit the warning + messages, use :option:`-Wno-variadic-macros`. + +.. option:: -Wno-variadic-macros + + Default setting; overrides :option:`-Wvariadic-macros`. + +.. option:: -Wno-varargs + + Do not warn upon questionable usage of the macros used to handle variable + arguments like ``va_start``. These warnings are enabled by default. + +.. option:: -Wvarargs + + Default setting; overrides :option:`-Wno-varargs`. + +.. option:: -Wvector-operation-performance + + Warn if vector operation is not implemented via SIMD capabilities of the + architecture. Mainly useful for the performance tuning. + Vector operation can be implemented ``piecewise``, which means that the + scalar operation is performed on every vector element; + ``in parallel``, which means that the vector operation is implemented + using scalars of wider type, which normally is more performance efficient; + and ``as a single scalar``, which means that vector fits into a + scalar type. + +.. option:: -Wno-vector-operation-performance + + Default setting; overrides :option:`-Wvector-operation-performance`. + +.. option:: -Wvla + + Warn if a variable-length array is used in the code. + :option:`-Wno-vla` prevents the :option:`-Wpedantic` warning of + the variable-length array. + +.. option:: -Wno-vla + + Default setting; overrides :option:`-Wvla`. + +.. option:: -Wvla-larger-than={byte-size} + + If this option is used, the compiler warns for declarations of + variable-length arrays whose size is either unbounded, or bounded + by an argument that allows the array size to exceed :samp:`{byte-size}` + bytes. This is similar to how :option:`-Walloca-larger-than=byte-size` + works, but with variable-length arrays. + + Note that GCC may optimize small variable-length arrays of a known + value into plain arrays, so this warning may not get triggered for + such arrays. + + :option:`-Wvla-larger-than=PTRDIFF_MAX` is enabled by default but + is typically only effective when :option:`-ftree-vrp` is active (default + for :option:`-O2` and above). + + See also :option:`-Walloca-larger-than=byte-size`. + +.. option:: -Wno-vla-larger-than + + Disable :option:`-Wvla-larger-than=` warnings. The option is equivalent + to :option:`-Wvla-larger-than=SIZE_MAX` or larger. + +.. option:: -Wvla-parameter + + Warn about redeclarations of functions involving arguments of Variable + Length Array types of inconsistent kinds or forms, and enable the detection + of out-of-bounds accesses to such parameters by warnings such as + :option:`-Warray-bounds`. + + If the first function declaration uses the VLA form the bound specified + in the array is assumed to be the minimum number of elements expected to + be provided in calls to the function and the maximum number of elements + accessed by it. Failing to provide arguments of sufficient size or + accessing more than the maximum number of elements may be diagnosed. + + For example, the warning triggers for the following redeclarations because + the first one allows an array of any size to be passed to ``f`` while + the second one specifies that the array argument must have at least ``n`` + elements. In addition, calling ``f`` with the associated VLA bound + parameter in excess of the actual VLA bound triggers a warning as well. + + .. code-block:: c++ + + void f (int n, int[n]); + void f (int, int[]); // warning: argument 2 previously declared as a VLA + + void g (int n) + { + if (n > 4) + return; + int a[n]; + f (sizeof a, a); // warning: access to a by f may be out of bounds + ... + } + + :option:`-Wvla-parameter` is included in :option:`-Wall`. The + :option:`-Warray-parameter` option triggers warnings for similar problems + involving ordinary array arguments. + +.. option:: -Wno-vla-parameter + + Default setting; overrides :option:`-Wvla-parameter`. + +.. option:: -Wvolatile-register-var + + Warn if a register variable is declared volatile. The volatile + modifier does not inhibit all optimizations that may eliminate reads + and/or writes to register variables. This warning is enabled by + :option:`-Wall`. + +.. option:: -Wno-volatile-register-var + + Default setting; overrides :option:`-Wvolatile-register-var`. + +.. option:: -Wxor-used-as-pow + + .. note:: + + C, C++, Objective-C and Objective-C++ only + + Warn about uses of ``^``, the exclusive or operator, where it appears + the user meant exponentiation. Specifically, the warning occurs when the + left-hand side is the decimal constant 2 or 10 and the right-hand side + is also a decimal constant. + + In C and C++, ``^`` means exclusive or, whereas in some other languages + (e.g. TeX and some versions of BASIC) it means exponentiation. + + This warning is enabled by default. It can be silenced by converting one + of the operands to hexadecimal. + +.. option:: -Wno-xor-used-as-pow + + Default setting; overrides :option:`-Wxor-used-as-pow`. + +.. option:: -Wdisabled-optimization + + Warn if a requested optimization pass is disabled. This warning does + not generally indicate that there is anything wrong with your code; it + merely indicates that GCC's optimizers are unable to handle the code + effectively. Often, the problem is that your code is too big or too + complex; GCC refuses to optimize programs when the optimization + itself is likely to take inordinate amounts of time. + +.. option:: -Wno-disabled-optimization + + Default setting; overrides :option:`-Wdisabled-optimization`. + +.. option:: -Wpointer-sign + + .. note:: + + C and Objective-C only + + Warn for pointer argument passing or assignment with different signedness. + This option is only supported for C and Objective-C. It is implied by + :option:`-Wall` and by :option:`-Wpedantic`, which can be disabled with + :option:`-Wno-pointer-sign`. + +.. option:: -Wno-pointer-sign + + Default setting; overrides :option:`-Wpointer-sign`. + +.. option:: -Wstack-protector + + This option is only active when :option:`-fstack-protector` is active. It + warns about functions that are not protected against stack smashing. + +.. option:: -Wno-stack-protector + + Default setting; overrides :option:`-Wstack-protector`. + +.. option:: -Woverlength-strings + + Warn about string constants that are longer than the 'minimum + maximum' length specified in the C standard. Modern compilers + generally allow string constants that are much longer than the + standard's minimum limit, but very portable programs should avoid + using longer strings. + + The limit applies *after* string constant concatenation, and does + not count the trailing NUL. In C90, the limit was 509 characters; in + C99, it was raised to 4095. C++98 does not specify a normative + minimum maximum, so we do not diagnose overlength strings in C++. + + This option is implied by :option:`-Wpedantic`, and can be disabled with + :option:`-Wno-overlength-strings`. + +.. option:: -Wno-overlength-strings + + Default setting; overrides :option:`-Woverlength-strings`. + +.. option:: -Wunsuffixed-float-constants + + .. note:: + + C and Objective-C only + + Issue a warning for any floating constant that does not have + a suffix. When used together with :option:`-Wsystem-headers` it + warns about such constants in system header files. This can be useful + when preparing code to use with the ``FLOAT_CONST_DECIMAL64`` pragma + from the decimal floating-point extension to C99. + +.. option:: -Wno-unsuffixed-float-constants + + Default setting; overrides :option:`-Wunsuffixed-float-constants`. + +.. option:: -Wno-lto-type-mismatch + + During the link-time optimization, do not warn about type mismatches in + global declarations from different compilation units. + Requires :option:`-flto` to be enabled. Enabled by default. + +.. option:: -Wlto-type-mismatch + + Default setting; overrides :option:`-Wno-lto-type-mismatch`. + +.. option:: -Wno-designated-init + + .. note:: + + C and Objective-C only + + Suppress warnings when a positional initializer is used to initialize + a structure that has been marked with the :type-attr:`designated_init` + attribute. + +.. option:: -Wdesignated-init + + Default setting; overrides :option:`-Wno-designated-init`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/passing-options-to-the-assembler.rst b/gcc/doc/gcc/gcc-command-options/passing-options-to-the-assembler.rst new file mode 100644 index 00000000000..c39a61f0333 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/passing-options-to-the-assembler.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _assembler-options: + +Passing Options to the Assembler +******************************** + +.. prevent bad page break with this line + +You can pass options to the assembler. + +.. option:: -Wa,option + + Pass :samp:`{option}` as an option to the assembler. If :samp:`{option}` + contains commas, it is split into multiple options at the commas. + +.. option:: -Xassembler {option} + + Pass :samp:`{option}` as an option to the assembler. You can use this to + supply system-specific assembler options that GCC does not + recognize. + + If you want to pass an option that takes an argument, you must use + :option:`-Xassembler` twice, once for the option and once for the argument. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/program-instrumentation-options.rst b/gcc/doc/gcc/gcc-command-options/program-instrumentation-options.rst new file mode 100644 index 00000000000..0549b7dca97 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/program-instrumentation-options.rst @@ -0,0 +1,1111 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: instrumentation options, program instrumentation options, run-time error checking options, profiling options, options, program instrumentation, options, run-time error checking, options, profiling + +.. _instrumentation-options: + +Program Instrumentation Options +******************************* + +GCC supports a number of command-line options that control adding +run-time instrumentation to the code it normally generates. +For example, one purpose of instrumentation is collect profiling +statistics for use in finding program hot spots, code coverage +analysis, or profile-guided optimizations. +Another class of program instrumentation is adding run-time checking +to detect programming errors like invalid pointer +dereferences or out-of-bounds array accesses, as well as deliberately +hostile attacks such as stack smashing or C++ vtable hijacking. +There is also a general hook which can be used to implement other +forms of tracing or function-level instrumentation for debug or +program analysis purposes. + +.. index:: prof, gprof + +.. option:: -p, -pg + + Generate extra code to write profile information suitable for the + analysis program :command:`prof` (for :option:`-p`) or :command:`gprof` + (for :option:`-pg`). You must use this option when compiling + the source files you want data about, and you must also use it when + linking. + + You can use the function attribute ``no_instrument_function`` to + suppress profiling of individual functions when compiling with these options. + See :ref:`common-function-attributes`. + +.. option:: -fprofile-arcs + + Add code so that program flow :dfn:`arcs` are instrumented. During + execution the program records how many times each branch and call is + executed and how many times it is taken or returns. On targets that support + constructors with priority support, profiling properly handles constructors, + destructors and C++ constructors (and destructors) of classes which are used + as a type of a global variable. + + When the compiled + program exits it saves this data to a file called + :samp:`{auxname}.gcda` for each source file. The data may be used for + profile-directed optimizations (:option:`-fbranch-probabilities`), or for + test coverage analysis (:option:`-ftest-coverage`). Each object file's + :samp:`{auxname}` is generated from the name of the output file, if + explicitly specified and it is not the final executable, otherwise it is + the basename of the source file. In both cases any suffix is removed + (e.g. :samp:`foo.gcda` for input file :samp:`dir/foo.c`, or + :samp:`dir/foo.gcda` for output file specified as :option:`-o dir/foo.o`). + + Note that if a command line directly links source files, the corresponding + :samp:`{.gcda}` files will be prefixed with the unsuffixed name of the output file. + E.g. ``gcc a.c b.c -o binary`` would generate :samp:`binary-a.gcda` and + :samp:`binary-b.gcda` files. + + See :ref:`cross-profiling`. + + .. index:: gcov + +.. option:: --coverage + + This option is used to compile and link code instrumented for coverage + analysis. The option is a synonym for :option:`-fprofile-arcs` + :option:`-ftest-coverage` (when compiling) and :option:`-lgcov` (when + linking). See the documentation for those options for more details. + + * Compile the source files with :option:`-fprofile-arcs` plus optimization + and code generation options. For test coverage analysis, use the + additional :option:`-ftest-coverage` option. You do not need to profile + every source file in a program. + + * Compile the source files additionally with :option:`-fprofile-abs-path` + to create absolute path names in the :samp:`.gcno` files. This allows + :command:`gcov` to find the correct sources in projects where compilations + occur with different working directories. + + * Link your object files with :option:`-lgcov` or :option:`-fprofile-arcs` + (the latter implies the former). + + * Run the program on a representative workload to generate the arc profile + information. This may be repeated any number of times. You can run + concurrent instances of your program, and provided that the file system + supports locking, the data files will be correctly updated. Unless + a strict ISO C dialect option is in effect, ``fork`` calls are + detected and correctly handled without double counting. + + Moreover, an object file can be recompiled multiple times + and the corresponding :samp:`.gcda` file merges as long as + the source file and the compiler options are unchanged. + + * For profile-directed optimizations, compile the source files again with + the same optimization and code generation options plus + :option:`-fbranch-probabilities` (see :ref:`optimize-options`). + + * For test coverage analysis, use :command:`gcov` to produce human readable + information from the :samp:`.gcno` and :samp:`.gcda` files. Refer to the + :command:`gcov` documentation for further information. + + With :option:`-fprofile-arcs`, for each function of your program GCC + creates a program flow graph, then finds a spanning tree for the graph. + Only arcs that are not on the spanning tree have to be instrumented: the + compiler adds code to count the number of times that these arcs are + executed. When an arc is the only exit or only entrance to a block, the + instrumentation code can be added to the block; otherwise, a new basic + block must be created to hold the instrumentation code. + +.. option:: -ftest-coverage + + Produce a notes file that the :command:`gcov` code-coverage utility + (see :ref:`gcov`) can use to + show program coverage. Each source file's note file is called + :samp:`{auxname}.gcno`. Refer to the :option:`-fprofile-arcs` option + above for a description of :samp:`{auxname}` and instructions on how to + generate test coverage data. Coverage data matches the source files + more closely if you do not optimize. + +.. option:: -fprofile-abs-path + + Automatically convert relative source file names to absolute path names + in the :samp:`.gcno` files. This allows :command:`gcov` to find the correct + sources in projects where compilations occur with different working + directories. + +.. option:: -fprofile-dir={path} + + Set the directory to search for the profile data files in to :samp:`{path}`. + This option affects only the profile data generated by + :option:`-fprofile-generate`, :option:`-ftest-coverage`, :option:`-fprofile-arcs` + and used by :option:`-fprofile-use` and :option:`-fbranch-probabilities` + and its related options. Both absolute and relative paths can be used. + By default, GCC uses the current directory as :samp:`{path}`, thus the + profile data file appears in the same directory as the object file. + In order to prevent the file name clashing, if the object file name is + not an absolute path, we mangle the absolute path of the + :samp:`{sourcename}.gcda` file and use it as the file name of a + :samp:`.gcda` file. See details about the file naming in :option:`-fprofile-arcs`. + See similar option :option:`-fprofile-note`. + + When an executable is run in a massive parallel environment, it is recommended + to save profile to different folders. That can be done with variables + in :samp:`{path}` that are exported during run-time: + + ``%p`` + process ID. + + ``%q{VAR}`` + value of environment variable :samp:`{VAR}` + +.. option:: -fprofile-generate, -fprofile-generate={path} + + Enable options usually used for instrumenting application to produce + profile useful for later recompilation with profile feedback based + optimization. You must use :option:`-fprofile-generate` both when + compiling and when linking your program. + + The following options are enabled: + :option:`-fprofile-arcs`, :option:`-fprofile-values`, + :option:`-finline-functions`, and :option:`-fipa-bit-cp`. + + If :samp:`{path}` is specified, GCC looks at the :samp:`{path}` to find + the profile feedback data files. See :option:`-fprofile-dir`. + + To optimize the program based on the collected profile information, use + :option:`-fprofile-use`. See :ref:`optimize-options`, for more information. + +.. option:: -fprofile-info-section, -fprofile-info-section={name} + + Register the profile information in the specified section instead of using a + constructor/destructor. The section name is :samp:`{name}` if it is specified, + otherwise the section name defaults to ``.gcov_info``. A pointer to the + profile information generated by :option:`-fprofile-arcs` is placed in the + specified section for each translation unit. This option disables the profile + information registration through a constructor and it disables the profile + information processing through a destructor. This option is not intended to be + used in hosted environments such as GNU/Linux. It targets freestanding + environments (for example embedded systems) with limited resources which do not + support constructors/destructors or the C library file I/O. + + The linker could collect the input sections in a continuous memory block and + define start and end symbols. A GNU linker script example which defines a + linker output section follows: + + .. code-block:: c++ + + .gcov_info : + { + PROVIDE (__gcov_info_start = .); + KEEP (*(.gcov_info)) + PROVIDE (__gcov_info_end = .); + } + + The program could dump the profiling information registered in this linker set + for example like this: + + .. code-block:: c++ + + #include + #include + #include + + extern const struct gcov_info *const __gcov_info_start[]; + extern const struct gcov_info *const __gcov_info_end[]; + + static void + dump (const void *d, unsigned n, void *arg) + { + const unsigned char *c = d; + + for (unsigned i = 0; i < n; ++i) + printf ("%02x", c[i]); + } + + static void + filename (const char *f, void *arg) + { + __gcov_filename_to_gcfn (f, dump, arg ); + } + + static void * + allocate (unsigned length, void *arg) + { + return malloc (length); + } + + static void + dump_gcov_info (void) + { + const struct gcov_info *const *info = __gcov_info_start; + const struct gcov_info *const *end = __gcov_info_end; + + /* Obfuscate variable to prevent compiler optimizations. */ + __asm__ ("" : "+r" (info)); + + while (info != end) + { + void *arg = NULL; + __gcov_info_to_gcda (*info, filename, dump, allocate, arg); + putchar ('\n'); + ++info; + } + } + + int + main (void) + { + dump_gcov_info (); + return 0; + } + + The :command:`merge-stream` subcommand of :command:`gcov-tool` may be used to + deserialize the data stream generated by the ``__gcov_filename_to_gcfn`` and + ``__gcov_info_to_gcda`` functions and merge the profile information into + :samp:`.gcda` files on the host filesystem. + +.. option:: -fprofile-note={path} + + If :samp:`{path}` is specified, GCC saves :samp:`.gcno` file into :samp:`{path}` + location. If you combine the option with multiple source files, + the :samp:`.gcno` file will be overwritten. + +.. option:: -fprofile-prefix-path={path} + + This option can be used in combination with + :option:`-fprofile-generate=profile_dir` and + :option:`-fprofile-use=profile_dir` to inform GCC where is the base + directory of built source tree. By default :samp:`{profile_dir}` will contain + files with mangled absolute paths of all object files in the built project. + This is not desirable when directory used to build the instrumented binary + differs from the directory used to build the binary optimized with profile + feedback because the profile data will not be found during the optimized build. + In such setups :option:`-fprofile-prefix-path=path` with :samp:`{path}` + pointing to the base directory of the build can be used to strip the irrelevant + part of the path and keep all file names relative to the main build directory. + +.. option:: -fprofile-prefix-map={old}={new} + + When compiling files residing in directory :samp:`{old}`, record + profiling information (with :option:`--coverage`) + describing them as if the files resided in + directory :samp:`{new}` instead. + See also :option:`-ffile-prefix-map`. + +.. option:: -fprofile-update={method} + + Alter the update method for an application instrumented for profile + feedback based optimization. The :samp:`{method}` argument should be one of + :samp:`single`, :samp:`atomic` or :samp:`prefer-atomic`. + The first one is useful for single-threaded applications, + while the second one prevents profile corruption by emitting thread-safe code. + + .. warning:: + + When an application does not properly join all threads + (or creates an detached thread), a profile file can be still corrupted. + + Using :samp:`prefer-atomic` would be transformed either to :samp:`atomic`, + when supported by a target, or to :samp:`single` otherwise. The GCC driver + automatically selects :samp:`prefer-atomic` when :option:`-pthread` + is present in the command line. + +.. option:: -fprofile-filter-files={regex} + + Instrument only functions from files whose name matches + any of the regular expressions (separated by semi-colons). + + For example, :option:`-fprofile-filter-files=main\\.c;module.*\\.c` will instrument + only :samp:`main.c` and all C files starting with 'module'. + +.. option:: -fprofile-exclude-files={regex} + + Instrument only functions from files whose name does not match + any of the regular expressions (separated by semi-colons). + + For example, :option:`-fprofile-exclude-files=/usr/.*` will prevent instrumentation + of all files that are located in the :samp:`/usr/` folder. + +.. option:: -fprofile-reproducible=[multithreaded|parallel-runs|serial] + + Control level of reproducibility of profile gathered by + ``-fprofile-generate``. This makes it possible to rebuild program + with same outcome which is useful, for example, for distribution + packages. + + With :option:`-fprofile-reproducible=serial` the profile gathered by + :option:`-fprofile-generate` is reproducible provided the trained program + behaves the same at each invocation of the train run, it is not + multi-threaded and profile data streaming is always done in the same + order. Note that profile streaming happens at the end of program run but + also before ``fork`` function is invoked. + + Note that it is quite common that execution counts of some part of + programs depends, for example, on length of temporary file names or + memory space randomization (that may affect hash-table collision rate). + Such non-reproducible part of programs may be annotated by + ``no_instrument_function`` function attribute. :command:`gcov-dump` with + :option:`-l` can be used to dump gathered data and verify that they are + indeed reproducible. + + With :option:`-fprofile-reproducible=parallel-runs` collected profile + stays reproducible regardless the order of streaming of the data into + gcda files. This setting makes it possible to run multiple instances of + instrumented program in parallel (such as with ``make -j``). This + reduces quality of gathered data, in particular of indirect call + profiling. + +.. option:: -fsanitize=address + + Enable AddressSanitizer, a fast memory error detector. + Memory access instructions are instrumented to detect + out-of-bounds and use-after-free bugs. + The option enables :option:`-fsanitize-address-use-after-scope`. + See https://github.com/google/sanitizers/wiki/AddressSanitizer for + more details. The run-time behavior can be influenced using the + :envvar:`ASAN_OPTIONS` environment variable. When set to ``help=1``, + the available options are shown at startup of the instrumented program. See + https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags + for a list of supported options. + The option cannot be combined with :option:`-fsanitize=thread` or + :option:`-fsanitize=hwaddress`. Note that the only target + :option:`-fsanitize=hwaddress` is currently supported on is AArch64. + +.. option:: -fsanitize=kernel-address + + Enable AddressSanitizer for Linux kernel. + See https://github.com/google/kasan for more details. + +.. option:: -fsanitize=hwaddress + + Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to + ignore the top byte of a pointer to allow the detection of memory errors with + a low memory overhead. + Memory access instructions are instrumented to detect out-of-bounds and + use-after-free bugs. + The option enables :option:`-fsanitize-address-use-after-scope`. + See + https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html + for more details. The run-time behavior can be influenced using the + :envvar:`HWASAN_OPTIONS` environment variable. When set to ``help=1``, + the available options are shown at startup of the instrumented program. + The option cannot be combined with :option:`-fsanitize=thread` or + :option:`-fsanitize=address`, and is currently only available on AArch64. + +.. option:: -fsanitize=kernel-hwaddress + + Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel. + Similar to :option:`-fsanitize=kernel-address` but using an alternate + instrumentation method, and similar to :option:`-fsanitize=hwaddress` but with + instrumentation differences necessary for compiling the Linux kernel. + These differences are to avoid hwasan library initialization calls and to + account for the stack pointer having a different value in its top byte. + + .. note:: + + This option has different defaults to the :option:`-fsanitize=hwaddress`. + Instrumenting the stack and alloca calls are not on by default but are still + possible by specifying the command-line options + :option:`--param` :gcc-param:`hwasan-instrument-stack`:samp:`=1` and + :option:`--param` :gcc-param:`hwasan-instrument-allocas`:samp:`=1` respectively. Using a random frame + tag is not implemented for kernel instrumentation. + +.. option:: -fsanitize=pointer-compare + + Instrument comparison operation (<, <=, >, >=) with pointer operands. + The option must be combined with either :option:`-fsanitize=kernel-address` or + :option:`-fsanitize=address` + The option cannot be combined with :option:`-fsanitize=thread`. + Note: By default the check is disabled at run time. To enable it, + add ``detect_invalid_pointer_pairs=2`` to the environment variable + :envvar:`ASAN_OPTIONS`. Using ``detect_invalid_pointer_pairs=1`` detects + invalid operation only when both pointers are non-null. + +.. option:: -fsanitize=pointer-subtract + + Instrument subtraction with pointer operands. + The option must be combined with either :option:`-fsanitize=kernel-address` or + :option:`-fsanitize=address` + The option cannot be combined with :option:`-fsanitize=thread`. + Note: By default the check is disabled at run time. To enable it, + add ``detect_invalid_pointer_pairs=2`` to the environment variable + :envvar:`ASAN_OPTIONS`. Using ``detect_invalid_pointer_pairs=1`` detects + invalid operation only when both pointers are non-null. + +.. option:: -fsanitize=shadow-call-stack + + Enable ShadowCallStack, a security enhancement mechanism used to protect + programs against return address overwrites (e.g. stack buffer overflows.) + It works by saving a function's return address to a separately allocated + shadow call stack in the function prologue and restoring the return address + from the shadow call stack in the function epilogue. Instrumentation only + occurs in functions that need to save the return address to the stack. + + Currently it only supports the aarch64 platform. It is specifically + designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option. + For the user space programs, runtime support is not currently provided + in libc and libgcc. Users who want to use this feature in user space need + to provide their own support for the runtime. It should be noted that + this may cause the ABI rules to be broken. + + On aarch64, the instrumentation makes use of the platform register ``x18``. + This generally means that any code that may run on the same thread as code + compiled with ShadowCallStack must be compiled with the flag + :option:`-ffixed-x18`, otherwise functions compiled without + :option:`-ffixed-x18` might clobber ``x18`` and so corrupt the shadow + stack pointer. + + Also, because there is no userspace runtime support, code compiled with + ShadowCallStack cannot use exception handling. Use :option:`-fno-exceptions` + to turn off exceptions. + + See https://clang.llvm.org/docs/ShadowCallStack.html for more + details. + +.. option:: -fsanitize=thread + + Enable ThreadSanitizer, a fast data race detector. + Memory access instructions are instrumented to detect + data race bugs. See https://github.com/google/sanitizers/wiki#threadsanitizer for more + details. The run-time behavior can be influenced using the :envvar:`TSAN_OPTIONS` + environment variable; see + https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags for a list of + supported options. + The option cannot be combined with :option:`-fsanitize=address`, + :option:`-fsanitize=leak`. + + Note that sanitized atomic builtins cannot throw exceptions when + operating on invalid memory addresses with non-call exceptions + (:option:`-fnon-call-exceptions`). + +.. option:: -fsanitize=leak + + Enable LeakSanitizer, a memory leak detector. + This option only matters for linking of executables and + the executable is linked against a library that overrides ``malloc`` + and other allocator functions. See + https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer for more + details. The run-time behavior can be influenced using the + :envvar:`LSAN_OPTIONS` environment variable. + The option cannot be combined with :option:`-fsanitize=thread`. + +.. option:: -fsanitize=undefined + + Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector. + Various computations are instrumented to detect undefined behavior + at runtime. See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html for more details. The run-time behavior can be influenced using the + :envvar:`UBSAN_OPTIONS` environment variable. Current suboptions are: + + .. option:: -fsanitize=shift + + This option enables checking that the result of a shift operation is + not undefined. Note that what exactly is considered undefined differs + slightly between C and C++, as well as between ISO C90 and C99, etc. + This option has two suboptions, :option:`-fsanitize=shift-base` and + :option:`-fsanitize=shift-exponent`. + + .. option:: -fsanitize=shift-exponent + + This option enables checking that the second argument of a shift operation + is not negative and is smaller than the precision of the promoted first + argument. + + .. option:: -fsanitize=shift-base + + If the second argument of a shift operation is within range, check that the + result of a shift operation is not undefined. Note that what exactly is + considered undefined differs slightly between C and C++, as well as between + ISO C90 and C99, etc. + + .. option:: -fsanitize=integer-divide-by-zero + + Detect integer division by zero. + + .. option:: -fsanitize=unreachable + + With this option, the compiler turns the ``__builtin_unreachable`` + call into a diagnostics message call instead. When reaching the + ``__builtin_unreachable`` call, the behavior is undefined. + + .. option:: -fsanitize=vla-bound + + This option instructs the compiler to check that the size of a variable + length array is positive. + + .. option:: -fsanitize=null + + This option enables pointer checking. Particularly, the application + built with this option turned on will issue an error message when it + tries to dereference a NULL pointer, or if a reference (possibly an + rvalue reference) is bound to a NULL pointer, or if a method is invoked + on an object pointed by a NULL pointer. + + .. option:: -fsanitize=return + + This option enables return statement checking. Programs + built with this option turned on will issue an error message + when the end of a non-void function is reached without actually + returning a value. This option works in C++ only. + + .. option:: -fsanitize=signed-integer-overflow + + This option enables signed integer overflow checking. We check that + the result of ``+``, ``*``, and both unary and binary ``-`` + does not overflow in the signed arithmetics. This also detects + ``INT_MIN / -1`` signed division. Note, integer promotion + rules must be taken into account. That is, the following is not an + overflow: + + .. code-block:: c++ + + signed char a = SCHAR_MAX; + a++; + + .. option:: -fsanitize=bounds + + This option enables instrumentation of array bounds. Various out of bounds + accesses are detected. Flexible array members, flexible array member-like + arrays, and initializers of variables with static storage are not instrumented. + + .. option:: -fsanitize=bounds-strict + + This option enables strict instrumentation of array bounds. Most out of bounds + accesses are detected, including flexible array members and flexible array + member-like arrays. Initializers of variables with static storage are not + instrumented. + + .. option:: -fsanitize=alignment + + This option enables checking of alignment of pointers when they are + dereferenced, or when a reference is bound to insufficiently aligned target, + or when a method or constructor is invoked on insufficiently aligned object. + + .. option:: -fsanitize=object-size + + This option enables instrumentation of memory references using the + ``__builtin_object_size`` function. Various out of bounds pointer + accesses are detected. + + .. option:: -fsanitize=float-divide-by-zero + + Detect floating-point division by zero. Unlike other similar options, + :option:`-fsanitize=float-divide-by-zero` is not enabled by + :option:`-fsanitize=undefined`, since floating-point division by zero can + be a legitimate way of obtaining infinities and NaNs. + + .. option:: -fsanitize=float-cast-overflow + + This option enables floating-point type to integer conversion checking. + We check that the result of the conversion does not overflow. + Unlike other similar options, :option:`-fsanitize=float-cast-overflow` is + not enabled by :option:`-fsanitize=undefined`. + This option does not work well with ``FE_INVALID`` exceptions enabled. + + .. option:: -fsanitize=nonnull-attribute + + This option enables instrumentation of calls, checking whether null values + are not passed to arguments marked as requiring a non-null value by the + :fn-attr:`nonnull` function attribute. + + .. option:: -fsanitize=returns-nonnull-attribute + + This option enables instrumentation of return statements in functions + marked with :fn-attr:`returns_nonnull` function attribute, to detect returning + of null values from such functions. + + .. option:: -fsanitize=bool + + This option enables instrumentation of loads from bool. If a value other + than 0/1 is loaded, a run-time error is issued. + + .. option:: -fsanitize=enum + + This option enables instrumentation of loads from an enum type. If + a value outside the range of values for the enum type is loaded, + a run-time error is issued. + + .. option:: -fsanitize=vptr + + This option enables instrumentation of C++ member function calls, member + accesses and some conversions between pointers to base and derived classes, + to verify the referenced object has the correct dynamic type. + + .. option:: -fsanitize=pointer-overflow + + This option enables instrumentation of pointer arithmetics. If the pointer + arithmetics overflows, a run-time error is issued. + + .. option:: -fsanitize=builtin + + This option enables instrumentation of arguments to selected builtin + functions. If an invalid value is passed to such arguments, a run-time + error is issued. E.g.passing 0 as the argument to ``__builtin_ctz`` + or ``__builtin_clz`` invokes undefined behavior and is diagnosed + by this option. + + Note that sanitizers tend to increase the rate of false positive + warnings, most notably those around :option:`-Wmaybe-uninitialized`. + We recommend against combining :option:`-Werror` and [the use of] + sanitizers. + + While :option:`-ftrapv` causes traps for signed overflows to be emitted, + :option:`-fsanitize=undefined` gives a diagnostic message. + This currently works only for the C family of languages. + +.. option:: -fno-sanitize=all + + This option disables all previously enabled sanitizers. + :option:`-fsanitize=all` is not allowed, as some sanitizers cannot be used + together. + +.. option:: -fasan-shadow-offset={number} + + This option forces GCC to use custom shadow offset in AddressSanitizer checks. + It is useful for experimenting with different shadow memory layouts in + Kernel AddressSanitizer. + +.. option:: -fsanitize-sections={s1},{s2},... + + Sanitize global variables in selected user-defined sections. :samp:`{si}` may + contain wildcards. + +.. option:: -fsanitize-recover[={opts}] + + :option:`-fsanitize-recover=` controls error recovery mode for sanitizers + mentioned in comma-separated list of :samp:`{opts}`. Enabling this option + for a sanitizer component causes it to attempt to continue + running the program as if no error happened. This means multiple + runtime errors can be reported in a single program run, and the exit + code of the program may indicate success even when errors + have been reported. The :option:`-fno-sanitize-recover=` option + can be used to alter + this behavior: only the first detected error is reported + and program then exits with a non-zero exit code. + + Currently this feature only works for :option:`-fsanitize=undefined` (and its suboptions + except for :option:`-fsanitize=unreachable` and :option:`-fsanitize=return`), + :option:`-fsanitize=float-cast-overflow`, :option:`-fsanitize=float-divide-by-zero`, + :option:`-fsanitize=bounds-strict`, + :option:`-fsanitize=kernel-address` and :option:`-fsanitize=address`. + For these sanitizers error recovery is turned on by default, + except :option:`-fsanitize=address`, for which this feature is experimental. + :option:`-fsanitize-recover=all` and :option:`-fno-sanitize-recover=all` is also + accepted, the former enables recovery for all sanitizers that support it, + the latter disables recovery for all sanitizers that support it. + + Even if a recovery mode is turned on the compiler side, it needs to be also + enabled on the runtime library side, otherwise the failures are still fatal. + The runtime library defaults to ``halt_on_error=0`` for + ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for + AddressSanitizer is ``halt_on_error=1``. This can be overridden through + setting the ``halt_on_error`` flag in the corresponding environment variable. + + Syntax without an explicit :samp:`{opts}` parameter is deprecated. It is + equivalent to specifying an :samp:`{opts}` list of: + + .. code-block:: + + undefined,float-cast-overflow,float-divide-by-zero,bounds-strict + +.. option:: -fsanitize-address-use-after-scope + + Enable sanitization of local variables to detect use-after-scope bugs. + The option sets :option:`-fstack-reuse` to :samp:`none`. + +.. option:: -fsanitize-trap[={opts}] + + The :option:`-fsanitize-trap=` option instructs the compiler to + report for sanitizers mentioned in comma-separated list of :samp:`{opts}` + undefined behavior using ``__builtin_trap`` rather than a ``libubsan`` + library routine. If this option is enabled for certain sanitizer, + it takes precedence over the :option:`-fsanitizer-recover=` for that + sanitizer, ``__builtin_trap`` will be emitted and be fatal regardless + of whether recovery is enabled or disabled using :option:`-fsanitize-recover=`. + + The advantage of this is that the ``libubsan`` library is not needed + and is not linked in, so this is usable even in freestanding environments. + + Currently this feature works with :option:`-fsanitize=undefined` (and its suboptions + except for :option:`-fsanitize=vptr`), :option:`-fsanitize=float-cast-overflow`, + :option:`-fsanitize=float-divide-by-zero` and + :option:`-fsanitize=bounds-strict`. ``-fsanitize-trap=all`` can be also + specified, which enables it for ``undefined`` suboptions, + :option:`-fsanitize=float-cast-overflow`, + :option:`-fsanitize=float-divide-by-zero` and + :option:`-fsanitize=bounds-strict`. + If ``-fsanitize-trap=undefined`` or ``-fsanitize-trap=all`` is used + and ``-fsanitize=vptr`` is enabled on the command line, the + instrumentation is silently ignored as the instrumentation always needs + ``libubsan`` support, :option:`-fsanitize-trap=vptr` is not allowed. + +.. option:: -fsanitize-undefined-trap-on-error + + The :option:`-fsanitize-undefined-trap-on-error` option is deprecated + equivalent of :option:`-fsanitize-trap=all`. + +.. option:: -fsanitize-coverage=trace-pc + + Enable coverage-guided fuzzing code instrumentation. + Inserts a call to ``__sanitizer_cov_trace_pc`` into every basic block. + +.. option:: -fsanitize-coverage=trace-cmp + + Enable dataflow guided fuzzing code instrumentation. + Inserts a call to ``__sanitizer_cov_trace_cmp1``, + ``__sanitizer_cov_trace_cmp2``, ``__sanitizer_cov_trace_cmp4`` or + ``__sanitizer_cov_trace_cmp8`` for integral comparison with both operands + variable or ``__sanitizer_cov_trace_const_cmp1``, + ``__sanitizer_cov_trace_const_cmp2``, + ``__sanitizer_cov_trace_const_cmp4`` or + ``__sanitizer_cov_trace_const_cmp8`` for integral comparison with one + operand constant, ``__sanitizer_cov_trace_cmpf`` or + ``__sanitizer_cov_trace_cmpd`` for float or double comparisons and + ``__sanitizer_cov_trace_switch`` for switch statements. + +.. option:: -fcf-protection=[full|branch|return|none|check] + + Enable code instrumentation of control-flow transfers to increase + program security by checking that target addresses of control-flow + transfer instructions (such as indirect function call, function return, + indirect jump) are valid. This prevents diverting the flow of control + to an unexpected target. This is intended to protect against such + threats as Return-oriented Programming (ROP), and similarly + call/jmp-oriented programming (COP/JOP). + + The value ``branch`` tells the compiler to implement checking of + validity of control-flow transfer at the point of indirect branch + instructions, i.e. call/jmp instructions. The value ``return`` + implements checking of validity at the point of returning from a + function. The value ``full`` is an alias for specifying both + ``branch`` and ``return``. The value ``none`` turns off + instrumentation. + + The value ``check`` is used for the final link with link-time + optimization (LTO). An error is issued if LTO object files are + compiled with different :option:`-fcf-protection` values. The + value ``check`` is ignored at the compile time. + + The macro ``__CET__`` is defined when :option:`-fcf-protection` is + used. The first bit of ``__CET__`` is set to 1 for the value + ``branch`` and the second bit of ``__CET__`` is set to 1 for + the ``return``. + + You can also use the :fn-attr:`nocf_check` attribute to identify + which functions and calls should be skipped from instrumentation + (see :ref:`function-attributes`). + + Currently the x86 GNU/Linux target provides an implementation based + on Intel Control-flow Enforcement Technology (CET) which works for + i686 processor or newer. + +.. option:: -fharden-compares + + For every logical test that survives gimple optimizations and is + *not* the condition in a conditional branch (for example, + conditions tested for conditional moves, or to store in boolean + variables), emit extra code to compute and verify the reversed + condition, and to call ``__builtin_trap`` if the results do not + match. Use with :samp:`-fharden-conditional-branches` to cover all + conditionals. + +.. option:: -fharden-conditional-branches + + For every non-vectorized conditional branch that survives gimple + optimizations, emit extra code to compute and verify the reversed + condition, and to call ``__builtin_trap`` if the result is + unexpected. Use with :samp:`-fharden-compares` to cover all + conditionals. + +.. option:: -fstack-protector + + Emit extra code to check for buffer overflows, such as stack smashing + attacks. This is done by adding a guard variable to functions with + vulnerable objects. This includes functions that call ``alloca``, and + functions with buffers larger than or equal to 8 bytes. The guards are + initialized when a function is entered and then checked when the function + exits. If a guard check fails, an error message is printed and the program + exits. Only variables that are actually allocated on the stack are + considered, optimized away variables or variables allocated in registers + don't count. + +.. option:: -fstack-protector-all + + Like :option:`-fstack-protector` except that all functions are protected. + +.. option:: -fstack-protector-strong + + Like :option:`-fstack-protector` but includes additional functions to + be protected --- those that have local array definitions, or have + references to local frame addresses. Only variables that are actually + allocated on the stack are considered, optimized away variables or variables + allocated in registers don't count. + +.. option:: -fstack-protector-explicit + + Like :option:`-fstack-protector` but only protects those functions which + have the :fn-attr:`stack_protect` attribute. + +.. option:: -fstack-check + + Generate code to verify that you do not go beyond the boundary of the + stack. You should specify this flag if you are running in an + environment with multiple threads, but you only rarely need to specify it in + a single-threaded environment since stack overflow is automatically + detected on nearly all systems if there is only one stack. + + Note that this switch does not actually cause checking to be done; the + operating system or the language runtime must do that. The switch causes + generation of code to ensure that they see the stack being extended. + + You can additionally specify a string parameter: :samp:`no` means no + checking, :samp:`generic` means force the use of old-style checking, + :samp:`specific` means use the best checking method and is equivalent + to bare :option:`-fstack-check`. + + Old-style checking is a generic mechanism that requires no specific + target support in the compiler but comes with the following drawbacks: + + * Modified allocation strategy for large objects: they are always + allocated dynamically if their size exceeds a fixed threshold. Note this + may change the semantics of some code. + + * Fixed limit on the size of the static frame of functions: when it is + topped by a particular function, stack checking is not reliable and + a warning is issued by the compiler. + + * Inefficiency: because of both the modified allocation strategy and the + generic implementation, code performance is hampered. + + Note that old-style stack checking is also the fallback method for + :samp:`specific` if no target support has been added in the compiler. + + :samp:`-fstack-check=` is designed for Ada's needs to detect infinite recursion + and stack overflows. :samp:`specific` is an excellent choice when compiling + Ada code. It is not generally sufficient to protect against stack-clash + attacks. To protect against those you want :samp:`-fstack-clash-protection`. + +.. option:: -fstack-clash-protection + + Generate code to prevent stack clash style attacks. When this option is + enabled, the compiler will only allocate one page of stack space at a time + and each page is accessed immediately after allocation. Thus, it prevents + allocations from jumping over any stack guard page provided by the + operating system. + + Most targets do not fully support stack clash protection. However, on + those targets :option:`-fstack-clash-protection` will protect dynamic stack + allocations. :option:`-fstack-clash-protection` may also provide limited + protection for static stack allocations if the target supports + :option:`-fstack-check=specific`. + +.. option:: -fstack-limit-register={reg} + + Generate code to ensure that the stack does not grow beyond a certain value, + either the value of a register or the address of a symbol. If a larger + stack is required, a signal is raised at run time. For most targets, + the signal is raised before the stack overruns the boundary, so + it is possible to catch the signal without taking special precautions. + + For instance, if the stack starts at absolute address :samp:`0x80000000` + and grows downwards, you can use the flags + :option:`-fstack-limit-symbol=__stack_limit` and + :option:`-Wl,--defsym,__stack_limit=0x7ffe0000` to enforce a stack limit + of 128KB. Note that this may only work with the GNU linker. + + You can locally override stack limit checking by using the + :fn-attr:`no_stack_limit` function attribute (see :ref:`function-attributes`). + +.. option:: -fsplit-stack + + Generate code to automatically split the stack before it overflows. + The resulting program has a discontiguous stack which can only + overflow if the program is unable to allocate any more memory. This + is most useful when running threaded programs, as it is no longer + necessary to calculate a good stack size to use for each thread. This + is currently only implemented for the x86 targets running + GNU/Linux. + + When code compiled with :option:`-fsplit-stack` calls code compiled + without :option:`-fsplit-stack`, there may not be much stack space + available for the latter code to run. If compiling all code, + including library code, with :option:`-fsplit-stack` is not an option, + then the linker can fix up these calls so that the code compiled + without :option:`-fsplit-stack` always has a large stack. Support for + this is implemented in the gold linker in GNU binutils release 2.21 + and later. + +.. option:: -fvtable-verify=[std|preinit|none] + + This option is only available when compiling C++ code. + It turns on (or off, if using :option:`-fvtable-verify=none`) the security + feature that verifies at run time, for every virtual call, that + the vtable pointer through which the call is made is valid for the type of + the object, and has not been corrupted or overwritten. If an invalid vtable + pointer is detected at run time, an error is reported and execution of the + program is immediately halted. + + This option causes run-time data structures to be built at program startup, + which are used for verifying the vtable pointers. + The options :samp:`std` and :samp:`preinit` + control the timing of when these data structures are built. In both cases the + data structures are built before execution reaches ``main``. Using + :option:`-fvtable-verify=std` causes the data structures to be built after + shared libraries have been loaded and initialized. + :option:`-fvtable-verify=preinit` causes them to be built before shared + libraries have been loaded and initialized. + + If this option appears multiple times in the command line with different + values specified, :samp:`none` takes highest priority over both :samp:`std` and + :samp:`preinit`; :samp:`preinit` takes priority over :samp:`std`. + +.. option:: -fvtv-debug + + When used in conjunction with :option:`-fvtable-verify=std` or + :option:`-fvtable-verify=preinit`, causes debug versions of the + runtime functions for the vtable verification feature to be called. + This flag also causes the compiler to log information about which + vtable pointers it finds for each class. + This information is written to a file named :samp:`vtv_set_ptr_data.log` + in the directory named by the environment variable :envvar:`VTV_LOGS_DIR` + if that is defined or the current working directory otherwise. + + .. note:: + This feature *appends* data to the log file. If you want a fresh log + file, be sure to delete any existing one. + +.. option:: -fvtv-counts + + This is a debugging flag. When used in conjunction with + :option:`-fvtable-verify=std` or :option:`-fvtable-verify=preinit`, this + causes the compiler to keep track of the total number of virtual calls + it encounters and the number of verifications it inserts. It also + counts the number of calls to certain run-time library functions + that it inserts and logs this information for each compilation unit. + The compiler writes this information to a file named + :samp:`vtv_count_data.log` in the directory named by the environment + variable :envvar:`VTV_LOGS_DIR` if that is defined or the current working + directory otherwise. It also counts the size of the vtable pointer sets + for each class, and writes this information to :samp:`vtv_class_set_sizes.log` + in the same directory. + + .. note:: + This feature *appends* data to the log files. To get fresh log + files, be sure to delete any existing ones. + +.. option:: -finstrument-functions + + Generate instrumentation calls for entry and exit to functions. Just + after function entry and just before function exit, the following + profiling functions are called with the address of the current + function and its call site. (On some platforms, + ``__builtin_return_address`` does not work beyond the current + function, so the call site information may not be available to the + profiling functions otherwise.) + + .. code-block:: c++ + + void __cyg_profile_func_enter (void *this_fn, + void *call_site); + void __cyg_profile_func_exit (void *this_fn, + void *call_site); + + The first argument is the address of the start of the current function, + which may be looked up exactly in the symbol table. + + This instrumentation is also done for functions expanded inline in other + functions. The profiling calls indicate where, conceptually, the + inline function is entered and exited. This means that addressable + versions of such functions must be available. If all your uses of a + function are expanded inline, this may mean an additional expansion of + code size. If you use ``extern inline`` in your C code, an + addressable version of such functions must be provided. (This is + normally the case anyway, but if you get lucky and the optimizer always + expands the functions inline, you might have gotten away without + providing static copies.) + + A function may be given the attribute ``no_instrument_function``, in + which case this instrumentation is not done. This can be used, for + example, for the profiling functions listed above, high-priority + interrupt routines, and any functions from which the profiling functions + cannot safely be called (perhaps signal handlers, if the profiling + routines generate output or allocate memory). + See :ref:`common-function-attributes`. + +.. option:: -finstrument-functions-once + + This is similar to :option:`-finstrument-functions`, but the profiling + functions are called only once per instrumented function, i.e. the first + profiling function is called after the first entry into the instrumented + function and the second profiling function is called before the exit + corresponding to this first entry. + + The definition of ``once`` for the purpose of this option is a little + vague because the implementation is not protected against data races. + As a result, the implementation only guarantees that the profiling + functions are called at *least* once per process and at *most* + once per thread, but the calls are always paired, that is to say, if a + thread calls the first function, then it will call the second function, + unless it never reaches the exit of the instrumented function. + +.. option:: -finstrument-functions-exclude-file-list={file},{file},... + + Set the list of functions that are excluded from instrumentation (see + the description of :option:`-finstrument-functions`). If the file that + contains a function definition matches with one of :samp:`{file}`, then + that function is not instrumented. The match is done on substrings: + if the :samp:`{file}` parameter is a substring of the file name, it is + considered to be a match. + + For example: + + :option:`-finstrument-functions-exclude-file-list=/bits/stl,include/sys` + excludes any inline function defined in files whose pathnames + contain :samp:`/bits/stl` or :samp:`include/sys`. + + If, for some reason, you want to include letter :samp:`,` in one of + :samp:`{sym}`, write :samp:`\\,`. For example, + :option:`-finstrument-functions-exclude-file-list='\\,\\,tmp'` + (note the single quote surrounding the option). + +.. option:: -finstrument-functions-exclude-function-list={sym},{sym},... + + This is similar to :option:`-finstrument-functions-exclude-file-list`, + but this option sets the list of function names to be excluded from + instrumentation. The function name to be matched is its user-visible + name, such as ``vector blah(const vector &)``, not the + internal mangled name (e.g., ``_Z4blahRSt6vectorIiSaIiEE``). The + match is done on substrings: if the :samp:`{sym}` parameter is a substring + of the function name, it is considered to be a match. For C99 and C++ + extended identifiers, the function name must be given in UTF-8, not + using universal character names. + +.. option:: -fpatchable-function-entry={N}[,{M}] + + Generate :samp:`{N}` NOPs right at the beginning + of each function, with the function entry point before the :samp:`{M}` th NOP. + If :samp:`{M}` is omitted, it defaults to ``0`` so the + function entry points to the address just at the first NOP. + The NOP instructions reserve extra space which can be used to patch in + any desired instrumentation at run time, provided that the code segment + is writable. The amount of space is controllable indirectly via + the number of NOPs; the NOP instruction used corresponds to the instruction + emitted by the internal GCC back-end interface ``gen_nop``. This behavior + is target-specific and may also depend on the architecture variant and/or + other compilation options. + + For run-time identification, the starting addresses of these areas, + which correspond to their respective function entries minus :samp:`{M}`, + are additionally collected in the ``__patchable_function_entries`` + section of the resulting binary. + + Note that the value of ``__attribute__ ((patchable_function_entry + (N,M)))`` takes precedence over command-line option + :option:`-fpatchable-function-entry=N,M`. This can be used to increase + the area size or to remove it completely on a single function. + If ``N=0``, no pad location is recorded. + + The NOP instructions are inserted at---and maybe before, depending on + :samp:`{M}` ---the function entry address, even before the prologue. On + PowerPC with the ELFv2 ABI, for a function with dual entry points, + the local entry point is this function entry address. + + The maximum value of :samp:`{N}` and :samp:`{M}` is 65535. On PowerPC with the + ELFv2 ABI, for a function with dual entry points, the supported values + for :samp:`{M}` are 0, 2, 6 and 14. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/specifying-subprocesses-and-the-switches-to-pass-to-them.rst b/gcc/doc/gcc/gcc-command-options/specifying-subprocesses-and-the-switches-to-pass-to-them.rst new file mode 100644 index 00000000000..cc5e03c10ca --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/specifying-subprocesses-and-the-switches-to-pass-to-them.rst @@ -0,0 +1,687 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. only:: not man + + .. index:: Spec Files + + .. _spec-files: + + Specifying Subprocesses and the Switches to Pass to Them + ******************************************************** + + :command:`gcc` is a driver program. It performs its job by invoking a + sequence of other programs to do the work of compiling, assembling and + linking. GCC interprets its command-line parameters and uses these to + deduce which programs it should invoke, and which command-line options + it ought to place on their command lines. This behavior is controlled + by :dfn:`spec strings`. In most cases there is one spec string for each + program that GCC can invoke, but a few programs have multiple spec + strings to control their behavior. The spec strings built into GCC can + be overridden by using the :option:`-specs=` command-line switch to specify + a spec file. + + :dfn:`Spec files` are plain-text files that are used to construct spec + strings. They consist of a sequence of directives separated by blank + lines. The type of directive is determined by the first non-whitespace + character on the line, which can be one of the following: + + :samp:`%{command}` + Issues a :samp:`{command}` to the spec file processor. The commands that can + appear here are: + + :samp:`%include <{file}>` + + .. index:: %include + + Search for :samp:`{file}` and insert its text at the current point in the + specs file. + + :samp:`%include_noerr <{file}>` + + .. index:: %include_noerr + + Just like :samp:`%include`, but do not generate an error message if the include + file cannot be found. + + :samp:`%rename {old_name}{new_name}` + + .. index:: %rename + + Rename the spec string :samp:`{old_name}` to :samp:`{new_name}`. + + :samp:`*[{spec_name}]:` + This tells the compiler to create, override or delete the named spec + string. All lines after this directive up to the next directive or + blank line are considered to be the text for the spec string. If this + results in an empty string then the spec is deleted. (Or, if the + spec did not exist, then nothing happens.) Otherwise, if the spec + does not currently exist a new spec is created. If the spec does + exist then its contents are overridden by the text of this + directive, unless the first character of that text is the :samp:`+` + character, in which case the text is appended to the spec. + + :samp:`[{suffix}]:` + Creates a new :samp:`[{suffix}] spec` pair. All lines after this directive + and up to the next directive or blank line are considered to make up the + spec string for the indicated suffix. When the compiler encounters an + input file with the named suffix, it processes the spec string in + order to work out how to compile that file. For example: + + .. code-block:: + + .ZZ: + z-compile -input %i + + This says that any input file whose name ends in :samp:`.ZZ` should be + passed to the program :samp:`z-compile`, which should be invoked with the + command-line switch :option:`-input` and with the result of performing the + :samp:`%i` substitution. (See below.) + + As an alternative to providing a spec string, the text following a + suffix directive can be one of the following: + + :samp:`@{language}` + This says that the suffix is an alias for a known :samp:`{language}`. This is + similar to using the :option:`-x` command-line switch to GCC to specify a + language explicitly. For example: + + .. code-block:: + + .ZZ: + @c++ + + Says that .ZZ files are, in fact, C++ source files. + + :samp:`#{name}` + This causes an error messages saying: + + .. code-block:: + + name compiler not installed on this system. + + GCC already has an extensive list of suffixes built into it. + This directive adds an entry to the end of the list of suffixes, but + since the list is searched from the end backwards, it is effectively + possible to override earlier entries using this technique. + + GCC has the following spec strings built into it. Spec files can + override these strings or create their own. Note that individual + targets can also add their own spec strings to this list. + + .. code-block:: + + asm Options to pass to the assembler + asm_final Options to pass to the assembler post-processor + cpp Options to pass to the C preprocessor + cc1 Options to pass to the C compiler + cc1plus Options to pass to the C++ compiler + endfile Object files to include at the end of the link + link Options to pass to the linker + lib Libraries to include on the command line to the linker + libgcc Decides which GCC support library to pass to the linker + linker Sets the name of the linker + predefines Defines to be passed to the C preprocessor + signed_char Defines to pass to CPP to say whether char is signed + by default + startfile Object files to include at the start of the link + + Here is a small example of a spec file: + + .. code-block:: + + %rename lib old_lib + + *lib: + --start-group -lgcc -lc -leval1 --end-group %(old_lib) + + This example renames the spec called :samp:`lib` to :samp:`old_lib` and + then overrides the previous definition of :samp:`lib` with a new one. + The new definition adds in some extra command-line options before + including the text of the old definition. + + :dfn:`Spec strings` are a list of command-line options to be passed to their + corresponding program. In addition, the spec strings can contain + :samp:`%`-prefixed sequences to substitute variable text or to + conditionally insert text into the command line. Using these constructs + it is possible to generate quite complex command lines. + + Here is a table of all defined :samp:`%`-sequences for spec + strings. Note that spaces are not generated automatically around the + results of expanding these sequences. Therefore you can concatenate them + together or combine them with constant text in a single argument. + + ``%%`` + Substitute one :samp:`%` into the program name or argument. + + ``%"`` + Substitute an empty argument. + + ``%i`` + Substitute the name of the input file being processed. + + ``%b`` + Substitute the basename for outputs related with the input file being + processed. This is often the substring up to (and not including) the + last period and not including the directory but, unless %w is active, it + expands to the basename for auxiliary outputs, which may be influenced + by an explicit output name, and by various other options that control + how auxiliary outputs are named. + + ``%B`` + This is the same as :samp:`%b`, but include the file suffix (text after + the last period). Without %w, it expands to the basename for dump + outputs. + + ``%d`` + Marks the argument containing or following the :samp:`%d` as a + temporary file name, so that that file is deleted if GCC exits + successfully. Unlike :samp:`%g`, this contributes no text to the + argument. + + :samp:`%g{suffix}` + Substitute a file name that has suffix :samp:`{suffix}` and is chosen + once per compilation, and mark the argument in the same way as + :samp:`%d`. To reduce exposure to denial-of-service attacks, the file + name is now chosen in a way that is hard to predict even when previously + chosen file names are known. For example, :samp:`%g.s ... %g.o ... %g.s` + might turn into :samp:`ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s`. :samp:`{suffix}` matches + the regexp :samp:`[.A-Za-z]*` or the special string :samp:`%O`, which is + treated exactly as if :samp:`%O` had been preprocessed. Previously, :samp:`%g` + was simply substituted with a file name chosen once per compilation, + without regard to any appended suffix (which was therefore treated + just like ordinary text), making such attacks more likely to succeed. + + :samp:`%u{suffix}` + Like :samp:`%g`, but generates a new temporary file name + each time it appears instead of once per compilation. + + :samp:`%U{suffix}` + Substitutes the last file name generated with :samp:`%u{suffix}`, generating a + new one if there is no such last file name. In the absence of any + :samp:`%u{suffix}`, this is just like :samp:`%g{suffix}`, except they don't share + the same suffix *space*, so :samp:`%g.s ... %U.s ... %g.s ... %U.s` + involves the generation of two distinct file names, one + for each :samp:`%g.s` and another for each :samp:`%U.s`. Previously, :samp:`%U` was + simply substituted with a file name chosen for the previous :samp:`%u`, + without regard to any appended suffix. + + :samp:`%j{suffix}` + Substitutes the name of the ``HOST_BIT_BUCKET``, if any, and if it is + writable, and if :option:`-save-temps` is not used; + otherwise, substitute the name + of a temporary file, just like :samp:`%u`. This temporary file is not + meant for communication between processes, but rather as a junk + disposal mechanism. + + :samp:`%|{suffix}` :samp:`%m{suffix}` + Like :samp:`%g`, except if :option:`-pipe` is in effect. In that case + :samp:`%|` substitutes a single dash and :samp:`%m` substitutes nothing at + all. These are the two most common ways to instruct a program that it + should read from standard input or write to standard output. If you + need something more elaborate you can use an :samp:`%{{pipe:X}}` + construct: see for example :samp:`gcc/fortran/lang-specs.h`. + + :samp:`%.{SUFFIX}` + Substitutes :samp:`{.SUFFIX}` for the suffixes of a matched switch's args + when it is subsequently output with :samp:`%*`. :samp:`{SUFFIX}` is + terminated by the next space or %. + + ``%w`` + Marks the argument containing or following the :samp:`%w` as the + designated output file of this compilation. This puts the argument + into the sequence of arguments that :samp:`%o` substitutes. + + ``%V`` + Indicates that this compilation produces no output file. + + ``%o`` + Substitutes the names of all the output files, with spaces + automatically placed around them. You should write spaces + around the :samp:`%o` as well or the results are undefined. + :samp:`%o` is for use in the specs for running the linker. + Input files whose names have no recognized suffix are not compiled + at all, but they are included among the output files, so they are + linked. + + ``%O`` + Substitutes the suffix for object files. Note that this is + handled specially when it immediately follows :samp:`%g, %u, or %U`, + because of the need for those to form complete file names. The + handling is such that :samp:`%O` is treated exactly as if it had already + been substituted, except that :samp:`%g, %u, and %U` do not currently + support additional :samp:`{suffix}` characters following :samp:`%O` as they do + following, for example, :samp:`.o`. + + ``%I`` + Substitute any of :option:`-iprefix` (made from :envvar:`GCC_EXEC_PREFIX`), + :option:`-isysroot` (made from :envvar:`TARGET_SYSTEM_ROOT`), + :option:`-isystem` (made from :envvar:`COMPILER_PATH` and :option:`-B` options) + and :option:`-imultilib` as necessary. + + ``%s`` + Current argument is the name of a library or startup file of some sort. + Search for that file in a standard list of directories and substitute + the full name found. The current working directory is included in the + list of directories scanned. + + ``%T`` + Current argument is the name of a linker script. Search for that file + in the current list of directories to scan for libraries. If the file + is located insert a :option:`--script` option into the command line + followed by the full path name found. If the file is not found then + generate an error message. Note: the current working directory is not + searched. + + :samp:`%e{str}` + Print :samp:`{str}` as an error message. :samp:`{str}` is terminated by a newline. + Use this when inconsistent options are detected. + + :samp:`%n{str}` + Print :samp:`{str}` as a notice. :samp:`{str}` is terminated by a newline. + + :samp:`%({name})` + Substitute the contents of spec string :samp:`{name}` at this point. + + :samp:`%x{{option}}` + Accumulate an option for :samp:`%X`. + + ``%X`` + Output the accumulated linker options specified by a :samp:`%x` spec string. + + ``%Y`` + Output the accumulated assembler options specified by :option:`-Wa`. + + ``%Z`` + Output the accumulated preprocessor options specified by :option:`-Wp`. + + ``%M`` + Output ``multilib_os_dir``. + + ``%R`` + Output the concatenation of ``target_system_root`` and ``target_sysroot_suffix``. + + ``%a`` + Process the ``asm`` spec. This is used to compute the + switches to be passed to the assembler. + + ``%A`` + Process the ``asm_final`` spec. This is a spec string for + passing switches to an assembler post-processor, if such a program is + needed. + + ``%l`` + Process the ``link`` spec. This is the spec for computing the + command line passed to the linker. Typically it makes use of the + :samp:`%L %G %S %D and %E` sequences. + + ``%D`` + Dump out a :option:`-L` option for each directory that GCC believes might + contain startup files. If the target supports multilibs then the + current multilib directory is prepended to each of these paths. + + ``%L`` + Process the ``lib`` spec. This is a spec string for deciding which + libraries are included on the command line to the linker. + + ``%G`` + Process the ``libgcc`` spec. This is a spec string for deciding + which GCC support library is included on the command line to the linker. + + ``%S`` + Process the ``startfile`` spec. This is a spec for deciding which + object files are the first ones passed to the linker. Typically + this might be a file named :samp:`crt0.o`. + + ``%E`` + Process the ``endfile`` spec. This is a spec string that specifies + the last object files that are passed to the linker. + + ``%C`` + Process the ``cpp`` spec. This is used to construct the arguments + to be passed to the C preprocessor. + + ``%1`` + Process the ``cc1`` spec. This is used to construct the options to be + passed to the actual C compiler (:command:`cc1`). + + ``%2`` + Process the ``cc1plus`` spec. This is used to construct the options to be + passed to the actual C++ compiler (:command:`cc1plus`). + + ``%*`` + Substitute the variable part of a matched option. See below. + Note that each comma in the substituted string is replaced by + a single space. + + ``%S`` + Similar to :samp:`% [] + + It returns ``result`` if the comparison evaluates to true, and NULL if it doesn't. + The supported ``comparison-op`` values are: + + ``>=`` + True if ``switch`` is a later (or same) version than ``arg1`` + + ``!>`` + Opposite of ``>=`` + + ``<`` + True if ``switch`` is an earlier version than ``arg1`` + + ``!<`` + Opposite of ``<`` + + ``><`` + True if ``switch`` is ``arg1`` or later, and earlier than ``arg2`` + + ``<>`` + True if ``switch`` is earlier than ``arg1``, or is ``arg2`` or later + + If the ``switch`` is not present at all, the condition is false unless the first character + of the ``comparison-op`` is ``!``. + + .. code-block:: + + %:version-compare(>= 10.3 mmacosx-version-min= -lmx) + + The above example would add :option:`-lmx` if :option:`-mmacosx-version-min=10.3.9` was + passed. + + ``include`` + The ``include`` spec function behaves much like ``%include``, with the advantage + that it can be nested inside a spec and thus be conditionalized. It takes one argument, + the filename, and looks for it in the startfile path. It always returns NULL. + + .. code-block:: + + %{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)} + + ``pass-through-libs`` + The ``pass-through-libs`` spec function takes any number of arguments. It + finds any :option:`-l` options and any non-options ending in :samp:`.a` (which it + assumes are the names of linker input library archive files) and returns a + result containing all the found arguments each prepended by + :option:`-plugin-opt=-pass-through=` and joined by spaces. This list is + intended to be passed to the LTO linker plugin. + + .. code-block:: + + %:pass-through-libs(%G %L %G) + + ``print-asm-header`` + The ``print-asm-header`` function takes no arguments and simply + prints a banner like: + + .. code-block:: + + Assembler options + ================= + + Use "-Wa,OPTION" to pass "OPTION" to the assembler. + + It is used to separate compiler options from assembler options + in the :option:`--target-help` output. + + ``gt`` + The ``gt`` spec function takes two or more arguments. It returns ``""`` (the + empty string) if the second-to-last argument is greater than the last argument, and NULL + otherwise. The following example inserts the ``link_gomp`` spec if the last + :option:`-ftree-parallelize-loops=` option given on the command line is greater than 1: + + .. code-block:: + + %{%:gt(%{ftree-parallelize-loops=*:%*} 1):%:include(libgomp.spec)%(link_gomp)} + + ``debug-level-gt`` + The ``debug-level-gt`` spec function takes one argument and returns ``""`` (the + empty string) if ``debug_info_level`` is greater than the specified number, and NULL + otherwise. + + .. code-block:: + + %{%:debug-level-gt(0):%{gdwarf*:--gdwarf2}} + + ``%{S}`` + Substitutes the ``-S`` switch, if that switch is given to GCC. + If that switch is not specified, this substitutes nothing. Note that + the leading dash is omitted when specifying this option, and it is + automatically inserted if the substitution is performed. Thus the spec + string :samp:`%{foo}` matches the command-line option :option:`-foo` + and outputs the command-line option :option:`-foo`. + + ``%W{S}`` + Like ``%{S}`` but mark last argument supplied within as a file to be + deleted on failure. + + ``%@{S}`` + Like ``%{S}`` but puts the result into a ``FILE`` and substitutes + ``@FILE`` if an ``@file`` argument has been supplied. + + ``%{S*}`` + Substitutes all the switches specified to GCC whose names start + with ``-S``, but which also take an argument. This is used for + switches like :option:`-o`, :option:`-D`, :option:`-I`, etc. + GCC considers :option:`-o foo` as being + one switch whose name starts with :samp:`o`. %{o\*} substitutes this + text, including the space. Thus two arguments are generated. + + ``%{S*&T*}`` + Like ``%{S*}``, but preserve order of ``S`` and ``T`` options + (the order of ``S`` and ``T`` in the spec is not significant). + There can be any number of ampersand-separated variables; for each the + wild card is optional. Useful for CPP as ``%{D*&U*&A*}``. + + ``%{S:X}`` + Substitutes ``X``, if the :option:`-S` switch is given to GCC. + + ``%{!S:X}`` + Substitutes ``X``, if the :option:`-S` switch is *not* given to GCC. + + ``%{S*:X}`` + Substitutes ``X`` if one or more switches whose names start with + ``-S`` are specified to GCC. Normally ``X`` is substituted only + once, no matter how many such switches appeared. However, if ``%*`` + appears somewhere in ``X``, then ``X`` is substituted once + for each matching switch, with the ``%*`` replaced by the part of + that switch matching the ``*``. + + If ``%*`` appears as the last part of a spec sequence then a space + is added after the end of the last substitution. If there is more + text in the sequence, however, then a space is not generated. This + allows the ``%*`` substitution to be used as part of a larger + string. For example, a spec string like this: + + .. code-block:: + + %{mcu=*:--script=%*/memory.ld} + + when matching an option like :option:`-mcu=newchip` produces: + + :option:`--script=newchip/memory.ld` + + ``%{.S:X}`` + Substitutes ``X``, if processing a file with suffix ``S``. + + ``%{!.S:X}`` + Substitutes ``X``, if *not* processing a file with suffix ``S``. + + ``%{,S:X}`` + Substitutes ``X``, if processing a file for language ``S``. + + ``%{!,S:X}`` + Substitutes ``X``, if not processing a file for language ``S``. + + ``%{S|P:X}`` + Substitutes ``X`` if either ``-S`` or ``-P`` is given to + GCC. This may be combined with :samp:`!`, :samp:`.`, :samp:`,`, and + ``*`` sequences as well, although they have a stronger binding than + the :samp:`|`. If ``%*`` appears in ``X``, all of the + alternatives must be starred, and only the first matching alternative + is substituted. + + For example, a spec string like this: + + .. code-block:: + + %{.c:-foo} %{!.c:-bar} %{.c|d:-baz} %{!.c|d:-boggle} + + outputs the following command-line options from the following input + command-line options: + + .. code-block:: + + fred.c -foo -baz + jim.d -bar -boggle + -d fred.c -foo -baz -boggle + -d jim.d -bar -baz -boggle + + :samp:`%{%:{function}({args}):X}` + Call function named :samp:`{function}` with args :samp:`{args}`. If the + function returns non-NULL, then ``X`` is substituted, if it returns + NULL, it isn't substituted. + + ``%{S:X; T:Y; :D}`` + If ``S`` is given to GCC, substitutes ``X`` ; else if ``T`` is + given to GCC, substitutes ``Y`` ; else substitutes ``D``. There can + be as many clauses as you need. This may be combined with ``.``, + ``,``, ``!``, ``|``, and ``*`` as needed. + + The switch matching text ``S`` in a :samp:`%{S}`, :samp:`%{S:X}` + or similar construct can use a backslash to ignore the special meaning + of the character following it, thus allowing literal matching of a + character that is otherwise specially treated. For example, + :samp:`%{std=iso9899\\:1999:X}` substitutes ``X`` if the + :option:`-std=iso9899:1999` option is given. + + The conditional text ``X`` in a :samp:`%{S:X}` or similar + construct may contain other nested :samp:`%` constructs or spaces, or + even newlines. They are processed as usual, as described above. + Trailing white space in ``X`` is ignored. White space may also + appear anywhere on the left side of the colon in these constructs, + except between ``.`` or ``*`` and the corresponding word. + + The :option:`-O`, :option:`-f`, :option:`-m`, and :option:`-W` switches are + handled specifically in these constructs. If another value of + :option:`-O` or the negated form of a :option:`-f`, :option:`-m`, or + :option:`-W` switch is found later in the command line, the earlier + switch value is ignored, except with ``{S*}`` where ``S`` is + just one letter, which passes all matching options. + + The character :samp:`|` at the beginning of the predicate text is used to + indicate that a command should be piped to the following command, but + only if :option:`-pipe` is specified. + + It is built into GCC which switches take arguments and which do not. + (You might think it would be useful to generalize this to allow each + compiler's spec to say which switches take arguments. But this cannot + be done in a consistent fashion. GCC cannot even decide which input + files have been specified without knowing which switches take arguments, + and it must know which input files to compile in order to tell which + compilers to run). + + GCC also knows implicitly that arguments starting in :option:`-l` are to be + treated as compiler output files, and passed to the linker in their + proper position among the other output files. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc-command-options/using-precompiled-headers.rst b/gcc/doc/gcc/gcc-command-options/using-precompiled-headers.rst new file mode 100644 index 00000000000..94549c9dc45 --- /dev/null +++ b/gcc/doc/gcc/gcc-command-options/using-precompiled-headers.rst @@ -0,0 +1,132 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. only:: not man + + .. index:: precompiled headers, speed of compilation + + .. _precompiled-headers: + + Using Precompiled Headers + ************************* + + Often large projects have many header files that are included in every + source file. The time the compiler takes to process these header files + over and over again can account for nearly all of the time required to + build the project. To make builds faster, GCC allows you to + :dfn:`precompile` a header file. + + To create a precompiled header file, simply compile it as you would any + other file, if necessary using the :option:`-x` option to make the driver + treat it as a C or C++ header file. You may want to use a + tool like :command:`make` to keep the precompiled header up-to-date when + the headers it contains change. + + A precompiled header file is searched for when ``#include`` is + seen in the compilation. As it searches for the included file + (see :ref:`cpp:search-path`) the + compiler looks for a precompiled header in each directory just before it + looks for the include file in that directory. The name searched for is + the name specified in the ``#include`` with :samp:`.gch` appended. If + the precompiled header file cannot be used, it is ignored. + + For instance, if you have ``#include "all.h"``, and you have + :samp:`all.h.gch` in the same directory as :samp:`all.h`, then the + precompiled header file is used if possible, and the original + header is used otherwise. + + Alternatively, you might decide to put the precompiled header file in a + directory and use :option:`-I` to ensure that directory is searched + before (or instead of) the directory containing the original header. + Then, if you want to check that the precompiled header file is always + used, you can put a file of the same name as the original header in this + directory containing an ``#error`` command. + + This also works with :option:`-include`. So yet another way to use + precompiled headers, good for projects not designed with precompiled + header files in mind, is to simply take most of the header files used by + a project, include them from another header file, precompile that header + file, and :option:`-include` the precompiled header. If the header files + have guards against multiple inclusion, they are skipped because + they've already been included (in the precompiled header). + + If you need to precompile the same header file for different + languages, targets, or compiler options, you can instead make a + *directory* named like :samp:`all.h.gch`, and put each precompiled + header in the directory, perhaps using :option:`-o`. It doesn't matter + what you call the files in the directory; every precompiled header in + the directory is considered. The first precompiled header + encountered in the directory that is valid for this compilation is + used; they're searched in no particular order. + + There are many other possibilities, limited only by your imagination, + good sense, and the constraints of your build system. + + A precompiled header file can be used only when these conditions apply: + + * Only one precompiled header can be used in a particular compilation. + + * A precompiled header cannot be used once the first C token is seen. You + can have preprocessor directives before a precompiled header; you cannot + include a precompiled header from inside another header. + + * The precompiled header file must be produced for the same language as + the current compilation. You cannot use a C precompiled header for a C++ + compilation. + + * The precompiled header file must have been produced by the same compiler + binary as the current compilation is using. + + * Any macros defined before the precompiled header is included must + either be defined in the same way as when the precompiled header was + generated, or must not affect the precompiled header, which usually + means that they don't appear in the precompiled header at all. + + The :option:`-D` option is one way to define a macro before a + precompiled header is included; using a ``#define`` can also do it. + There are also some options that define macros implicitly, like + :option:`-O` and :option:`-Wdeprecated` ; the same rule applies to macros + defined this way. + + * If debugging information is output when using the precompiled + header, using :option:`-g` or similar, the same kind of debugging information + must have been output when building the precompiled header. However, + a precompiled header built using :option:`-g` can be used in a compilation + when no debugging information is being output. + + * The same :option:`-m` options must generally be used when building + and using the precompiled header. See :ref:`submodel-options`, + for any cases where this rule is relaxed. + + * Each of the following options must be the same when building and using + the precompiled header: :option:`-fexceptions` + + * Some other command-line options starting with :option:`-f`, + :option:`-p`, or :option:`-O` must be defined in the same way as when + the precompiled header was generated. At present, it's not clear + which options are safe to change and which are not; the safest choice + is to use exactly the same options when generating and using the + precompiled header. The following are known to be safe: + + :option:`-fmessage-length=` :option:`-fpreprocessed` :option:`-fsched-interblock` |gol| + :option:`-fsched-spec` :option:`-fsched-spec-load` :option:`-fsched-spec-load-dangerous` |gol| + :option:`-fsched-verbose=number` :option:`-fschedule-insns` :option:`-fvisibility=` |gol| + :option:`-pedantic-errors` + + * Address space layout randomization (ASLR) can lead to not binary identical + PCH files. If you rely on stable PCH file contents disable ASLR when generating + PCH files. + + For all of these except the last, the compiler automatically + ignores the precompiled header if the conditions aren't met. If you + find an option combination that doesn't work and doesn't cause the + precompiled header to be ignored, please consider filing a bug report, + see :ref:`bugs`. + + If you do use differing options when generating and using the + precompiled header, the actual behavior is a mixture of the + behavior for the options. For instance, if you use :option:`-g` to + generate the precompiled header but not when using it, you may or may + not get debugging information for routines in the precompiled header. \ No newline at end of file diff --git a/gcc/doc/gcc/gcc.rst b/gcc/doc/gcc/gcc.rst new file mode 100644 index 00000000000..f14f0746bad --- /dev/null +++ b/gcc/doc/gcc/gcc.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. %**start of header + +.. INTERNALS is used by md.texi to determine whether to include the + whole of that file, in the internals manual, or only the part + dealing with constraints, in the user manual. + +.. NOTE: checks/things to do: + c + -have bob do a search in all seven files for "mew" (ideally -mew, + but i may have forgotten the occasional "-"..). + Just checked... all have `-'! Bob 22Jul96 + Use this to search: grep -n '\-\-mew' *.texi + -item/itemx, text after all (sub/sub)section titles, etc.. + -consider putting the lists of options on pp 17-> etc in columns or + some such. + -overfulls. do a search for "mew" in the files, and you will see + overfulls that i noted but could not deal with. + -have to add text: beginning of chapter 8 + c + anything else? -mew 10feb93 + +.. Create a separate index for command line options. + +.. Merge the standard indexes into a single one. + +.. %**end of header + +.. index:: introduction + +.. _top: + +Introduction +============ + +This manual documents how to use the GNU compilers, +as well as their features and incompatibilities, and how to report +bugs. It corresponds to the compilers +|package_version| +version |gcc_version|. +The internals of the GNU compilers, including how to port them to new +targets and some information about how to write front ends for new +languages, are documented in a separate manual. See :ref:`gccint:top`. \ No newline at end of file diff --git a/gcc/doc/gcc/gcov-dump.rst b/gcc/doc/gcc/gcov-dump.rst new file mode 100644 index 00000000000..629efd255ea --- /dev/null +++ b/gcc/doc/gcc/gcov-dump.rst @@ -0,0 +1,70 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: gcov-dump + +.. _gcov-dump: + +gcov-dump---an Offline Gcda and Gcno Profile Dump Tool +------------------------------------------------------ + +.. only:: man + + Synopsis + ^^^^^^^^ + + gcov-dump + [ :option:`-v` | :option:`--version` ] + [ :option:`-h` | :option:`--help` ] + [ :option:`-l` | :option:`--long` ] + [ :option:`-p` | :option:`--positions` ] + [ :option:`-r` | :option:`--raw` ] + [ :option:`-s` | :option:`--stable` ] + [ :samp:`{gcovfiles}` ] + +.. only:: not man + + .. code-block:: + + gcov-dump [OPTION] ... gcovfiles + +Description +^^^^^^^^^^^ + +:command:`gcov-dump` is a tool you can use in conjunction with GCC to +dump content of gcda and gcno profile files offline. + +Options +^^^^^^^ + +.. option:: -h, --help + + Display help about using :command:`gcov-dump` (on the standard output), and + exit without doing any further processing. + +.. option:: -l, --long + + Dump content of records. + +.. option:: -p, --positions + + Dump positions of records. + +.. option:: -r, --raw + + Print content records in raw format. + +.. option:: -s, --stable + + Print content in stable format usable for comparison. + +.. option:: -v, --version + + Display the :command:`gcov-dump` version number (on the standard output), + and exit without doing any further processing. + +.. only:: man + + .. include:: copyright.rst \ No newline at end of file diff --git a/gcc/doc/gcc/gcov-tool.rst b/gcc/doc/gcc/gcov-tool.rst new file mode 100644 index 00000000000..6b415d5db88 --- /dev/null +++ b/gcc/doc/gcc/gcov-tool.rst @@ -0,0 +1,209 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: gcov-tool + +.. _gcov-tool: + +gcov-tool---an Offline Gcda Profile Processing Tool +--------------------------------------------------- + +.. only:: man + + Synopsis + ^^^^^^^^ + + gcov-tool [ :option:`-v` | :option:`--version` ] [ :option:`-h` | :option:`--help` ] + + gcov-tool merge [merge-options] :samp:`{directory1}` :samp:`{directory2}` + [ :option:`-o` | :option:`--output` :samp:`{directory}` ] + [ :option:`-v` | :option:`--verbose` ] + [ :option:`-w` | :option:`--weight` :samp:`{w1,w2}` ] + + gcov-tool merge-stream [merge-stream-options] [ :samp:`{file}` ] + [ :option:`-v` | :option:`--verbose` ] + [ :option:`-w` | :option:`--weight` :samp:`{w1,w2}` ] + + gcov-tool rewrite [rewrite-options] :samp:`{directory}` + [ :option:`-n` | :option:`--normalize` :samp:`{long_long_value}` ] + [ :option:`-o` | :option:`--output` :samp:`{directory}` ] + [ :option:`-s` | :option:`--scale` :samp:`{float_or_simple-frac_value}` ] + [ :option:`-v` | :option:`--verbose` ] + + gcov-tool overlap [overlap-options] :samp:`{directory1}` :samp:`{directory2}` + [ :option:`-f` | :option:`--function` ] + [ :option:`-F` | :option:`--fullname` ] + [ :option:`-h` | :option:`--hotonly` ] + [ :option:`-o` | :option:`--object` ] + [ :option:`-t` | :option:`--hot_threshold` ] :samp:`{float}` + [ :option:`-v` | :option:`--verbose` ] + +.. only:: not man + + .. code-block:: + + gcov-tool [global-options] SUB_COMMAND [sub_command-options] profile_dir + +Description +^^^^^^^^^^^ + +:command:`gcov-tool` is an offline tool to process gcc's gcda profile files. + +Current gcov-tool supports the following functionalities: + +* merge two sets of profiles with weights. + +* read a stream of profiles with associated filenames and merge it with a set of + profiles with weights. + +* read one set of profile and rewrite profile contents. One can scale or + normalize the count values. + +Examples of the use cases for this tool are: + +* Collect the profiles for different set of inputs, and use this tool to merge + them. One can specify the weight to factor in the relative importance of + each input. + +* Collect profiles from target systems without a filesystem (freestanding + environments). Merge the collected profiles with associated profiles + present on the host system. One can specify the weight to factor in the + relative importance of each input. + +* Rewrite the profile after removing a subset of the gcda files, while maintaining + the consistency of the summary and the histogram. + +* It can also be used to debug or libgcov code as the tools shares the majority + code as the runtime library. + +Note that for the merging operation, this profile generated offline may +contain slight different values from the online merged profile. Here are +a list of typical differences: + +* histogram difference: This offline tool recomputes the histogram after merging + the counters. The resulting histogram, therefore, is precise. The online + merging does not have this capability -- the histogram is merged from two + histograms and the result is an approximation. + +* summary checksum difference: Summary checksum uses a CRC32 operation. The value + depends on the link list order of gcov-info objects. This order is different in + gcov-tool from that in the online merge. It's expected to have different + summary checksums. It does not really matter as the compiler does not use this + checksum anywhere. + +* value profile counter values difference: Some counter values for value profile + are runtime dependent, like heap addresses. It's normal to see some difference + in these kind of counters. + +Options +^^^^^^^ + +.. option:: -h, --help + + Display help about using :command:`gcov-tool` (on the standard output), and + exit without doing any further processing. + +.. option:: -v, --version + + Display the :command:`gcov-tool` version number (on the standard output), + and exit without doing any further processing. + +.. option:: merge + + Merge two profile directories. + + .. option:: -o directory, --output directory + + Set the output profile directory. Default output directory name is + :samp:`{merged_profile}`. + + .. option:: -v, --verbose + + Set the verbose mode. + + .. option:: -w w1,w2, --weight w1,w2 + + Set the merge weights of the :samp:`{directory1}` and :samp:`{directory2}`, + respectively. The default weights are 1 for both. + +.. option:: merge-stream + + Collect profiles with associated filenames from a *gcfn* and *gcda* + data stream. Read the stream from the file specified by :samp:`{file}` or from + :samp:`stdin`. Merge the profiles with associated profiles in the host + filesystem. Apply the optional weights while merging profiles. + + For the generation of a *gcfn* and *gcda* data stream on the target + system, please have a look at the ``__gcov_filename_to_gcfn()`` and + ``__gcov_info_to_gcda()`` functions declared in ``#include ``. + + .. option:: -v, --verbose + + Set the verbose mode. + + .. option:: -w w1,w2, --weight w1,w2 + + Set the merge weights of the profiles from the *gcfn* and *gcda* data + stream and the associated profiles in the host filesystem, respectively. The + default weights are 1 for both. + +.. option:: rewrite + + Read the specified profile directory and rewrite to a new directory. + + .. option:: -n long_long_value, --normalize + + Normalize the profile. The specified value is the max counter value + in the new profile. + + .. option:: -o directory, --output directory + + Set the output profile directory. Default output name is :samp:`{rewrite_profile}`. + + .. option:: -s float_or_simple-frac_value, --scale float_or_simple-frac_value + + Scale the profile counters. The specified value can be in floating point value, + or simple fraction value form, such 1, 2, 2/3, and 5/3. + + .. option:: -v, --verbose + + Set the verbose mode. + +.. option:: overlap + + Compute the overlap score between the two specified profile directories. + The overlap score is computed based on the arc profiles. It is defined as + the sum of min (p1_counter[i] / p1_sum_all, p2_counter[i] / p2_sum_all), + for all arc counter i, where p1_counter[i] and p2_counter[i] are two + matched counters and p1_sum_all and p2_sum_all are the sum of counter + values in profile 1 and profile 2, respectively. + + .. option:: -f, --function + + Print function level overlap score. + + .. option:: -F, --fullname + + Print full gcda filename. + + .. option:: -h, --hotonly + + Only print info for hot objects/functions. + + .. option:: -o, --object + + Print object level overlap score. + + .. option:: -t float, --hot_threshold + + Set the threshold for hot counter value. + + .. option:: -v, --verbose + + Set the verbose mode. + +.. only:: man + + .. include:: copyright.rst \ No newline at end of file diff --git a/gcc/doc/gcc/gcov.rst b/gcc/doc/gcc/gcov.rst new file mode 100644 index 00000000000..c8418740184 --- /dev/null +++ b/gcc/doc/gcc/gcov.rst @@ -0,0 +1,53 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gcov: + +gcov---a Test Coverage Program +------------------------------ + +:command:`gcov` is a tool you can use in conjunction with GCC to +test code coverage in your programs. + +.. only:: man + + Synopsis + ^^^^^^^^ + + gcov [ :option:`-v` | :option:`--version` ] [ :option:`-h` | :option:`--help` ] + [ :option:`-a` | :option:`--all-blocks` ] + [ :option:`-b` | :option:`--branch-probabilities` ] + [ :option:`-c` | :option:`--branch-counts` ] + [ :option:`-d` | :option:`--display-progress` ] + [ :option:`-f` | :option:`--function-summaries` ] + [ :option:`-j` | :option:`--json-format` ] + [ :option:`-H` | :option:`--human-readable` ] + [ :option:`-k` | :option:`--use-colors` ] + [ :option:`-l` | :option:`--long-file-names` ] + [ :option:`-m` | :option:`--demangled-names` ] + [ :option:`-n` | :option:`--no-output` ] + [ :option:`-o` | :option:`--object-directory` :samp:`{directory|file}` ] + [ :option:`-p` | :option:`--preserve-paths` ] + [ :option:`-q` | :option:`--use-hotness-colors` ] + [ :option:`-r` | :option:`--relative-only` ] + [ :option:`-s` | :option:`--source-prefix` :samp:`{directory}` ] + [ :option:`-t` | :option:`--stdout` ] + [ :option:`-u` | :option:`--unconditional-branches` ] + [ :option:`-x` | :option:`--hash-filenames` ] + :samp:`{files}` + +.. toctree:: + :maxdepth: 2 + + gcov/introduction-to-gcov + gcov/invoking-gcov + gcov/using-gcov-with-gcc-optimization + gcov/brief-description-of-gcov-data-files + gcov/data-file-relocation-to-support-cross-profiling + gcov/profiling-and-test-coverage-in-freestanding-environments + +.. only:: man + + .. include:: copyright.rst \ No newline at end of file diff --git a/gcc/doc/gcc/gcov/brief-description-of-gcov-data-files.rst b/gcc/doc/gcc/gcov/brief-description-of-gcov-data-files.rst new file mode 100644 index 00000000000..11201a3d979 --- /dev/null +++ b/gcc/doc/gcc/gcov/brief-description-of-gcov-data-files.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gcov-data-files: + +Brief Description of gcov Data Files +************************************ + +:command:`gcov` uses two files for profiling. The names of these files +are derived from the original *object* file by substituting the +file suffix with either :samp:`.gcno`, or :samp:`.gcda`. The files +contain coverage and profile data stored in a platform-independent format. +The :samp:`.gcno` files are placed in the same directory as the object +file. By default, the :samp:`.gcda` files are also stored in the same +directory as the object file, but the GCC :option:`-fprofile-dir` option +may be used to store the :samp:`.gcda` files in a separate directory. + +The :samp:`.gcno` notes file is generated when the source file is compiled +with the GCC :option:`-ftest-coverage` option. It contains information to +reconstruct the basic block graphs and assign source line numbers to +blocks. + +The :samp:`.gcda` count data file is generated when a program containing +object files built with the GCC :option:`-fprofile-arcs` option is executed. +A separate :samp:`.gcda` file is created for each object file compiled with +this option. It contains arc transition counts, value profile counts, and +some summary information. + +It is not recommended to access the coverage files directly. +Consumers should use the intermediate format that is provided +by :command:`gcov` tool via :option:`--json-format` option. \ No newline at end of file diff --git a/gcc/doc/gcc/gcov/data-file-relocation-to-support-cross-profiling.rst b/gcc/doc/gcc/gcov/data-file-relocation-to-support-cross-profiling.rst new file mode 100644 index 00000000000..fc3585cb646 --- /dev/null +++ b/gcc/doc/gcc/gcov/data-file-relocation-to-support-cross-profiling.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _cross-profiling: + +Data File Relocation to Support Cross-Profiling +*********************************************** + +Running the program will cause profile output to be generated. For each +source file compiled with :option:`-fprofile-arcs`, an accompanying :samp:`.gcda` +file will be placed in the object file directory. That implicitly requires +running the program on the same system as it was built or having the same +absolute directory structure on the target system. The program will try +to create the needed directory structure, if it is not already present. + +To support cross-profiling, a program compiled with :option:`-fprofile-arcs` +can relocate the data files based on two environment variables: + +* GCOV_PREFIX contains the prefix to add to the absolute paths + in the object file. Prefix can be absolute, or relative. The + default is no prefix. + +* GCOV_PREFIX_STRIP indicates the how many initial directory names to strip off + the hardwired absolute paths. Default value is 0. + +.. note:: + + If GCOV_PREFIX_STRIP is set without GCOV_PREFIX is undefined, + then a relative path is made out of the hardwired absolute paths. + +For example, if the object file :samp:`/user/build/foo.o` was built with +:option:`-fprofile-arcs`, the final executable will try to create the data file +:samp:`/user/build/foo.gcda` when running on the target system. This will +fail if the corresponding directory does not exist and it is unable to create +it. This can be overcome by, for example, setting the environment as +:samp:`GCOV_PREFIX=/target/run` and :samp:`GCOV_PREFIX_STRIP=1`. Such a +setting will name the data file :samp:`/target/run/build/foo.gcda`. + +You must move the data files to the expected directory tree in order to +use them for profile directed optimizations (:option:`-fprofile-use`), or to +use the :command:`gcov` tool. \ No newline at end of file diff --git a/gcc/doc/gcc/gcov/introduction-to-gcov.rst b/gcc/doc/gcc/gcov/introduction-to-gcov.rst new file mode 100644 index 00000000000..5b9fda0a0f1 --- /dev/null +++ b/gcc/doc/gcc/gcov/introduction-to-gcov.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gcov-intro: + +Introduction to gcov +******************** + +:command:`gcov` is a test coverage program. Use it in concert with GCC +to analyze your programs to help create more efficient, faster running +code and to discover untested parts of your program. You can use +:command:`gcov` as a profiling tool to help discover where your +optimization efforts will best affect your code. You can also use +:command:`gcov` along with the other profiling tool, :command:`gprof`, to +assess which parts of your code use the greatest amount of computing +time. + +Profiling tools help you analyze your code's performance. Using a +profiler such as :command:`gcov` or :command:`gprof`, you can find out some +basic performance statistics, such as: + +* how often each line of code executes + +* what lines of code are actually executed + +* how much computing time each section of code uses + +Once you know these things about how your code works when compiled, you +can look at each module to see which modules should be optimized. +:command:`gcov` helps you determine where to work on optimization. + +Software developers also use coverage testing in concert with +testsuites, to make sure software is actually good enough for a release. +Testsuites can verify that a program works as expected; a coverage +program tests to see how much of the program is exercised by the +testsuite. Developers can then determine what kinds of test cases need +to be added to the testsuites to create both better testing and a better +final product. + +You should compile your code without optimization if you plan to use +:command:`gcov` because the optimization, by combining some lines of code +into one function, may not give you as much information as you need to +look for 'hot spots' where the code is using a great deal of computer +time. Likewise, because :command:`gcov` accumulates statistics by line (at +the lowest resolution), it works best with a programming style that +places only one statement on each line. If you use complicated macros +that expand to loops or to other control structures, the statistics are +less helpful---they only report on the line where the macro call +appears. If your complex macros behave like functions, you can replace +them with inline functions to solve this problem. + +:command:`gcov` creates a logfile called :samp:`{sourcefile}.gcov` which +indicates how many times each line of a source file :samp:`{sourcefile}.c` +has executed. You can use these logfiles along with :command:`gprof` to aid +in fine-tuning the performance of your programs. :command:`gprof` gives +timing information you can use along with the information you get from +:command:`gcov`. + +:command:`gcov` works only on code compiled with GCC. It is not +compatible with any other profiling or test coverage mechanism. \ No newline at end of file diff --git a/gcc/doc/gcc/gcov/invoking-gcov.rst b/gcc/doc/gcc/gcov/invoking-gcov.rst new file mode 100644 index 00000000000..8445ddb8db6 --- /dev/null +++ b/gcc/doc/gcc/gcov/invoking-gcov.rst @@ -0,0 +1,656 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: gcov + +.. _invoking-gcov: + +Invoking gcov +************* + +.. code-block:: + + gcov [options] files + +:command:`gcov` accepts the following options: + +Options +^^^^^^^ + +.. option:: -a, --all-blocks + + Write individual execution counts for every basic block. Normally gcov + outputs execution counts only for the main blocks of a line. With this + option you can determine if blocks within a single line are not being + executed. + +.. option:: -b, --branch-probabilities + + Write branch frequencies to the output file, and write branch summary + info to the standard output. This option allows you to see how often + each branch in your program was taken. Unconditional branches will not + be shown, unless the :option:`-u` option is given. + +.. option:: -c, --branch-counts + + Write branch frequencies as the number of branches taken, rather than + the percentage of branches taken. + +.. option:: -d, --display-progress + + Display the progress on the standard output. + +.. option:: -f, --function-summaries + + Output summaries for each function in addition to the file level summary. + +.. option:: -h, --help + + Display help about using :command:`gcov` (on the standard output), and + exit without doing any further processing. + +.. option:: -j, --json-format + + Output gcov file in an easy-to-parse JSON intermediate format + which does not require source code for generation. The JSON + file is compressed with gzip compression algorithm + and the files have :samp:`.gcov.json.gz` extension. + + Structure of the JSON is following: + + .. code-block:: json + + { + "current_working_directory": "foo/bar", + "data_file": "a.out", + "format_version": "1", + "gcc_version": "11.1.1 20210510" + "files": ["$file"] + } + + Fields of the root element have following semantics: + + * :samp:`{current_working_directory}` : working directory where + a compilation unit was compiled + + * :samp:`{data_file}` : name of the data file (GCDA) + + * :samp:`{format_version}` : semantic version of the format + + * :samp:`{gcc_version}` : version of the GCC compiler + + Each :samp:`{file}` has the following form: + + .. code-block:: json + + { + "file": "a.c", + "functions": ["$function"], + "lines": ["$line"] + } + + Fields of the :samp:`{file}` element have following semantics: + + * :samp:`{file_name}` : name of the source file + + Each :samp:`{function}` has the following form: + + .. code-block:: json + + { + "blocks": 2, + "blocks_executed": 2, + "demangled_name": "foo", + "end_column": 1, + "end_line": 4, + "execution_count": 1, + "name": "foo", + "start_column": 5, + "start_line": 1 + } + + Fields of the :samp:`{function}` element have following semantics: + + * :samp:`{blocks}` : number of blocks that are in the function + + * :samp:`{blocks_executed}` : number of executed blocks of the function + + * :samp:`{demangled_name}` : demangled name of the function + + * :samp:`{end_column}` : column in the source file where the function ends + + * :samp:`{end_line}` : line in the source file where the function ends + + * :samp:`{execution_count}` : number of executions of the function + + * :samp:`{name}` : name of the function + + * :samp:`{start_column}` : column in the source file where the function begins + + * :samp:`{start_line}` : line in the source file where the function begins + + Note that line numbers and column numbers number from 1. In the current + implementation, :samp:`{start_line}` and :samp:`{start_column}` do not include + any template parameters and the leading return type but that + this is likely to be fixed in the future. + + Each :samp:`{line}` has the following form: + + .. code-block:: json + + { + "branches": ["$branch"], + "count": 2, + "line_number": 15, + "unexecuted_block": false, + "function_name": "foo", + } + + Branches are present only with :samp:`{-b}` option. + Fields of the :samp:`{line}` element have following semantics: + + * :samp:`{count}` : number of executions of the line + + * :samp:`{line_number}` : line number + + * :samp:`{unexecuted_block}` : flag whether the line contains an unexecuted block + (not all statements on the line are executed) + + * :samp:`{function_name}` : a name of a function this :samp:`{line}` belongs to + (for a line with an inlined statements can be not set) + + Each :samp:`{branch}` has the following form: + + .. code-block:: json + + { + "count": 11, + "fallthrough": true, + "throw": false + } + + Fields of the :samp:`{branch}` element have following semantics: + + * :samp:`{count}` : number of executions of the branch + + * :samp:`{fallthrough}` : true when the branch is a fall through branch + + * :samp:`{throw}` : true when the branch is an exceptional branch + +.. option:: -H, --human-readable + + Write counts in human readable format (like 24.6k). + +.. option:: -k, --use-colors + + Use colors for lines of code that have zero coverage. We use red color for + non-exceptional lines and cyan for exceptional. Same colors are used for + basic blocks with :option:`-a` option. + +.. option:: -l, --long-file-names + + Create long file names for included source files. For example, if the + header file :samp:`x.h` contains code, and was included in the file + :samp:`a.c`, then running :command:`gcov` on the file :samp:`a.c` will + produce an output file called :samp:`a.c##x.h.gcov` instead of + :samp:`x.h.gcov`. This can be useful if :samp:`x.h` is included in + multiple source files and you want to see the individual + contributions. If you use the :samp:`-p` option, both the including + and included file names will be complete path names. + +.. option:: -m, --demangled-names + + Display demangled function names in output. The default is to show + mangled function names. + +.. option:: -n, --no-output + + Do not create the :command:`gcov` output file. + + +.. option:: -o directory|file, --object-directory directory, --object-file file + + Specify either the directory containing the gcov data files, or the + object path name. The :samp:`.gcno`, and + :samp:`.gcda` data files are searched for using this option. If a directory + is specified, the data files are in that directory and named after the + input file name, without its extension. If a file is specified here, + the data files are named after that file, without its extension. + +.. option:: -p, --preserve-paths + + Preserve complete path information in the names of generated + :samp:`.gcov` files. Without this option, just the filename component is + used. With this option, all directories are used, with :samp:`/` characters + translated to :samp:`#` characters, :samp:`.` directory components + removed and unremoveable :samp:`..` + components renamed to :samp:`^`. This is useful if sourcefiles are in several + different directories. + +.. option:: -q, --use-hotness-colors + + Emit perf-like colored output for hot lines. Legend of the color scale + is printed at the very beginning of the output file. + +.. option:: -r, --relative-only + + Only output information about source files with a relative pathname + (after source prefix elision). Absolute paths are usually system + header files and coverage of any inline functions therein is normally + uninteresting. + +.. option:: -s directory, --source-prefix directory + + A prefix for source file names to remove when generating the output + coverage files. This option is useful when building in a separate + directory, and the pathname to the source directory is not wanted when + determining the output file names. Note that this prefix detection is + applied before determining whether the source file is absolute. + +.. option:: -t, --stdout + + Output to standard output instead of output files. + +.. option:: -u, --unconditional-branches + + When branch probabilities are given, include those of unconditional branches. + Unconditional branches are normally not interesting. + +.. option:: -v, --version + + Display the :command:`gcov` version number (on the standard output), + and exit without doing any further processing. + +.. option:: -w, --verbose + + Print verbose informations related to basic blocks and arcs. + +.. option:: -x, --hash-filenames + + When using :samp:`{--preserve-paths}`, + gcov uses the full pathname of the source files to create + an output filename. This can lead to long filenames that can overflow + filesystem limits. This option creates names of the form + :samp:`{source-file}##{md5}.gcov`, + where the :samp:`{source-file}` component is the final filename part and + the :samp:`{md5}` component is calculated from the full mangled name that + would have been used otherwise. The option is an alternative + to the :samp:`{--preserve-paths}` on systems which have a filesystem limit. + +:command:`gcov` should be run with the current directory the same as that +when you invoked the compiler. Otherwise it will not be able to locate +the source files. :command:`gcov` produces files called +:samp:`{mangledname}.gcov` in the current directory. These contain +the coverage information of the source file they correspond to. +One :samp:`.gcov` file is produced for each source (or header) file +containing code, +which was compiled to produce the data files. The :samp:`{mangledname}` part +of the output file name is usually simply the source file name, but can +be something more complicated if the :samp:`-l` or :samp:`-p` options are +given. Refer to those options for details. + +If you invoke :command:`gcov` with multiple input files, the +contributions from each input file are summed. Typically you would +invoke it with the same list of files as the final link of your executable. + +The :samp:`.gcov` files contain the :samp:`:` separated fields along with +program source code. The format is + +.. code-block:: + + execution_count:line_number:source line text + +Additional block information may succeed each line, when requested by +command line option. The :samp:`{execution_count}` is :samp:`-` for lines +containing no code. Unexecuted lines are marked :samp:`#####` or +:samp:`=====`, depending on whether they are reachable by +non-exceptional paths or only exceptional paths such as C++ exception +handlers, respectively. Given the :samp:`-a` option, unexecuted blocks are +marked :samp:`$$$$$` or :samp:`%%%%%`, depending on whether a basic block +is reachable via non-exceptional or exceptional paths. +Executed basic blocks having a statement with zero :samp:`{execution_count}` +end with :samp:`*` character and are colored with magenta color with +the :option:`-k` option. This functionality is not supported in Ada. + +Note that GCC can completely remove the bodies of functions that are +not needed -- for instance if they are inlined everywhere. Such functions +are marked with :samp:`-`, which can be confusing. +Use the :option:`-fkeep-inline-functions` and :option:`-fkeep-static-functions` +options to retain these functions and +allow gcov to properly show their :samp:`{execution_count}`. + +Some lines of information at the start have :samp:`{line_number}` of zero. +These preamble lines are of the form + +:option:`-:0:tag` : :samp:`{value}` +The ordering and number of these preamble lines will be augmented as +:command:`gcov` development progresses --- do not rely on them remaining +unchanged. Use :samp:`{tag}` to locate a particular preamble line. + +The additional block information is of the form + +.. code-block:: + + tag information + +The :samp:`{information}` is human readable, but designed to be simple +enough for machine parsing too. + +When printing percentages, 0% and 100% are only printed when the values +are *exactly* 0% and 100% respectively. Other values which would +conventionally be rounded to 0% or 100% are instead printed as the +nearest non-boundary value. + +When using :command:`gcov`, you must first compile your program +with a special GCC option :samp:`--coverage`. +This tells the compiler to generate additional information needed by +gcov (basically a flow graph of the program) and also includes +additional code in the object files for generating the extra profiling +information needed by gcov. These additional files are placed in the +directory where the object file is located. + +Running the program will cause profile output to be generated. For each +source file compiled with :option:`-fprofile-arcs`, an accompanying +:samp:`.gcda` file will be placed in the object file directory. + +Running :command:`gcov` with your program's source file names as arguments +will now produce a listing of the code along with frequency of execution +for each line. For example, if your program is called :samp:`tmp.cpp`, this +is what you see when you use the basic :command:`gcov` facility: + +.. code-block:: shell-session + + $ g++ --coverage tmp.cpp -c + $ g++ --coverage tmp.o + $ a.out + $ gcov tmp.cpp -m + File 'tmp.cpp' + Lines executed:92.86% of 14 + Creating 'tmp.cpp.gcov' + +The file :samp:`tmp.cpp.gcov` contains output from :command:`gcov`. +Here is a sample: + +.. code-block:: + + -: 0:Source:tmp.cpp + -: 0:Working directory:/home/gcc/testcase + -: 0:Graph:tmp.gcno + -: 0:Data:tmp.gcda + -: 0:Runs:1 + -: 0:Programs:1 + -: 1:#include + -: 2: + -: 3:template + -: 4:class Foo + -: 5:{ + -: 6: public: + 1*: 7: Foo(): b (1000) {} + ------------------ + Foo::Foo(): + #####: 7: Foo(): b (1000) {} + ------------------ + Foo::Foo(): + 1: 7: Foo(): b (1000) {} + ------------------ + 2*: 8: void inc () { b++; } + ------------------ + Foo::inc(): + #####: 8: void inc () { b++; } + ------------------ + Foo::inc(): + 2: 8: void inc () { b++; } + ------------------ + -: 9: + -: 10: private: + -: 11: int b; + -: 12:}; + -: 13: + -: 14:template class Foo; + -: 15:template class Foo; + -: 16: + -: 17:int + 1: 18:main (void) + -: 19:{ + -: 20: int i, total; + 1: 21: Foo counter; + -: 22: + 1: 23: counter.inc(); + 1: 24: counter.inc(); + 1: 25: total = 0; + -: 26: + 11: 27: for (i = 0; i < 10; i++) + 10: 28: total += i; + -: 29: + 1*: 30: int v = total > 100 ? 1 : 2; + -: 31: + 1: 32: if (total != 45) + #####: 33: printf ("Failure\n"); + -: 34: else + 1: 35: printf ("Success\n"); + 1: 36: return 0; + -: 37:} + +Note that line 7 is shown in the report multiple times. First occurrence +presents total number of execution of the line and the next two belong +to instances of class Foo constructors. As you can also see, line 30 contains +some unexecuted basic blocks and thus execution count has asterisk symbol. + +When you use the :option:`-a` option, you will get individual block +counts, and the output looks like this: + +.. code-block:: + + -: 0:Source:tmp.cpp + -: 0:Working directory:/home/gcc/testcase + -: 0:Graph:tmp.gcno + -: 0:Data:tmp.gcda + -: 0:Runs:1 + -: 0:Programs:1 + -: 1:#include + -: 2: + -: 3:template + -: 4:class Foo + -: 5:{ + -: 6: public: + 1*: 7: Foo(): b (1000) {} + ------------------ + Foo::Foo(): + #####: 7: Foo(): b (1000) {} + ------------------ + Foo::Foo(): + 1: 7: Foo(): b (1000) {} + ------------------ + 2*: 8: void inc () { b++; } + ------------------ + Foo::inc(): + #####: 8: void inc () { b++; } + ------------------ + Foo::inc(): + 2: 8: void inc () { b++; } + ------------------ + -: 9: + -: 10: private: + -: 11: int b; + -: 12:}; + -: 13: + -: 14:template class Foo; + -: 15:template class Foo; + -: 16: + -: 17:int + 1: 18:main (void) + -: 19:{ + -: 20: int i, total; + 1: 21: Foo counter; + 1: 21-block 0 + -: 22: + 1: 23: counter.inc(); + 1: 23-block 0 + 1: 24: counter.inc(); + 1: 24-block 0 + 1: 25: total = 0; + -: 26: + 11: 27: for (i = 0; i < 10; i++) + 1: 27-block 0 + 11: 27-block 1 + 10: 28: total += i; + 10: 28-block 0 + -: 29: + 1*: 30: int v = total > 100 ? 1 : 2; + 1: 30-block 0 + %%%%%: 30-block 1 + 1: 30-block 2 + -: 31: + 1: 32: if (total != 45) + 1: 32-block 0 + #####: 33: printf ("Failure\n"); + %%%%%: 33-block 0 + -: 34: else + 1: 35: printf ("Success\n"); + 1: 35-block 0 + 1: 36: return 0; + 1: 36-block 0 + -: 37:} + +In this mode, each basic block is only shown on one line -- the last +line of the block. A multi-line block will only contribute to the +execution count of that last line, and other lines will not be shown +to contain code, unless previous blocks end on those lines. +The total execution count of a line is shown and subsequent lines show +the execution counts for individual blocks that end on that line. After each +block, the branch and call counts of the block will be shown, if the +:option:`-b` option is given. + +Because of the way GCC instruments calls, a call count can be shown +after a line with no individual blocks. +As you can see, line 33 contains a basic block that was not executed. + +When you use the :option:`-b` option, your output looks like this: + +.. code-block:: + + -: 0:Source:tmp.cpp + -: 0:Working directory:/home/gcc/testcase + -: 0:Graph:tmp.gcno + -: 0:Data:tmp.gcda + -: 0:Runs:1 + -: 0:Programs:1 + -: 1:#include + -: 2: + -: 3:template + -: 4:class Foo + -: 5:{ + -: 6: public: + 1*: 7: Foo(): b (1000) {} + ------------------ + Foo::Foo(): + function Foo::Foo() called 0 returned 0% blocks executed 0% + #####: 7: Foo(): b (1000) {} + ------------------ + Foo::Foo(): + function Foo::Foo() called 1 returned 100% blocks executed 100% + 1: 7: Foo(): b (1000) {} + ------------------ + 2*: 8: void inc () { b++; } + ------------------ + Foo::inc(): + function Foo::inc() called 0 returned 0% blocks executed 0% + #####: 8: void inc () { b++; } + ------------------ + Foo::inc(): + function Foo::inc() called 2 returned 100% blocks executed 100% + 2: 8: void inc () { b++; } + ------------------ + -: 9: + -: 10: private: + -: 11: int b; + -: 12:}; + -: 13: + -: 14:template class Foo; + -: 15:template class Foo; + -: 16: + -: 17:int + function main called 1 returned 100% blocks executed 81% + 1: 18:main (void) + -: 19:{ + -: 20: int i, total; + 1: 21: Foo counter; + call 0 returned 100% + branch 1 taken 100% (fallthrough) + branch 2 taken 0% (throw) + -: 22: + 1: 23: counter.inc(); + call 0 returned 100% + branch 1 taken 100% (fallthrough) + branch 2 taken 0% (throw) + 1: 24: counter.inc(); + call 0 returned 100% + branch 1 taken 100% (fallthrough) + branch 2 taken 0% (throw) + 1: 25: total = 0; + -: 26: + 11: 27: for (i = 0; i < 10; i++) + branch 0 taken 91% (fallthrough) + branch 1 taken 9% + 10: 28: total += i; + -: 29: + 1*: 30: int v = total > 100 ? 1 : 2; + branch 0 taken 0% (fallthrough) + branch 1 taken 100% + -: 31: + 1: 32: if (total != 45) + branch 0 taken 0% (fallthrough) + branch 1 taken 100% + #####: 33: printf ("Failure\n"); + call 0 never executed + branch 1 never executed + branch 2 never executed + -: 34: else + 1: 35: printf ("Success\n"); + call 0 returned 100% + branch 1 taken 100% (fallthrough) + branch 2 taken 0% (throw) + 1: 36: return 0; + -: 37:} + +For each function, a line is printed showing how many times the function +is called, how many times it returns and what percentage of the +function's blocks were executed. + +For each basic block, a line is printed after the last line of the basic +block describing the branch or call that ends the basic block. There can +be multiple branches and calls listed for a single source line if there +are multiple basic blocks that end on that line. In this case, the +branches and calls are each given a number. There is no simple way to map +these branches and calls back to source constructs. In general, though, +the lowest numbered branch or call will correspond to the leftmost construct +on the source line. + +For a branch, if it was executed at least once, then a percentage +indicating the number of times the branch was taken divided by the +number of times the branch was executed will be printed. Otherwise, the +message 'never executed' is printed. + +For a call, if it was executed at least once, then a percentage +indicating the number of times the call returned divided by the number +of times the call was executed will be printed. This will usually be +100%, but may be less for functions that call ``exit`` or ``longjmp``, +and thus may not return every time they are called. + +The execution counts are cumulative. If the example program were +executed again without removing the :samp:`.gcda` file, the count for the +number of times each line in the source was executed would be added to +the results of the previous run(s). This is potentially useful in +several ways. For example, it could be used to accumulate data over a +number of program runs as part of a test verification suite, or to +provide more accurate long-term information over a large number of +program runs. + +The data in the :samp:`.gcda` files is saved immediately before the program +exits. For each source file compiled with :option:`-fprofile-arcs`, the +profiling code first attempts to read in an existing :samp:`.gcda` file; if +the file doesn't match the executable (differing number of basic block +counts) it will ignore the contents of the file. It then adds in the +new execution counts and finally writes the data to the file. \ No newline at end of file diff --git a/gcc/doc/gcc/gcov/profiling-and-test-coverage-in-freestanding-environments.rst b/gcc/doc/gcc/gcov/profiling-and-test-coverage-in-freestanding-environments.rst new file mode 100644 index 00000000000..8efae010b84 --- /dev/null +++ b/gcc/doc/gcc/gcov/profiling-and-test-coverage-in-freestanding-environments.rst @@ -0,0 +1,391 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _freestanding-environments: + +Profiling and Test Coverage in Freestanding Environments +******************************************************** + +In case your application runs in a hosted environment such as GNU/Linux, then +this section is likely not relevant to you. This section is intended for +application developers targeting freestanding environments (for example +embedded systems) with limited resources. In particular, systems or test cases +which do not support constructors/destructors or the C library file I/O. In +this section, the :dfn:`target system` runs your application instrumented for +profiling or test coverage. You develop and analyze your application on the +:dfn:`host system`. We now provide an overview how profiling and test coverage +can be obtained in this scenario followed by a tutorial which can be exercised +on the host system. Finally, some system initialization caveats are listed. + +Overview +^^^^^^^^ + +For an application instrumented for profiling or test coverage, the compiler +generates some global data structures which are updated by instrumentation code +while the application runs. These data structures are called the :dfn:`gcov +information`. Normally, when the application exits, the gcov information is +stored to :samp:`.gcda` files. There is one file per translation unit +instrumented for profiling or test coverage. The function +``__gcov_exit()``, which stores the gcov information to a file, is called by +a global destructor function for each translation unit instrumented for +profiling or test coverage. It runs at process exit. In a global constructor +function, the ``__gcov_init()`` function is called to register the gcov +information of a translation unit in a global list. In some situations, this +procedure does not work. Firstly, if you want to profile the global +constructor or exit processing of an operating system, the compiler generated +functions may conflict with the test objectives. Secondly, you may want to +test early parts of the system initialization or abnormal program behaviour +which do not allow a global constructor or exit processing. Thirdly, you need +a filesystem to store the files. + +The :option:`-fprofile-info-section` GCC option enables you to use profiling and +test coverage in freestanding environments. This option disables the use of +global constructors and destructors for the gcov information. Instead, a +pointer to the gcov information is stored in a special linker input section for +each translation unit which is compiled with this option. By default, the +section name is ``.gcov_info``. The gcov information is statically +initialized. The pointers to the gcov information from all translation units +of an executable can be collected by the linker in a contiguous memory block. +For the GNU linker, the below linker script output section definition can be +used to achieve this: + +.. code-block:: c++ + + .gcov_info : + { + PROVIDE (__gcov_info_start = .); + KEEP (*(.gcov_info)) + PROVIDE (__gcov_info_end = .); + } + +The linker will provide two global symbols, ``__gcov_info_start`` and +``__gcov_info_end``, which define the start and end of the array of pointers +to gcov information blocks, respectively. The ``KEEP ()`` directive is +required to prevent a garbage collection of the pointers. They are not +directly referenced by anything in the executable. The section may be placed +in a read-only memory area. + +In order to transfer the profiling and test coverage data from the target to +the host system, the application has to provide a function to produce a +reliable in order byte stream from the target to the host. The byte stream may +be compressed and encoded using error detection and correction codes to meet +application-specific requirements. The GCC provided :samp:`libgcov` target +library provides two functions, ``__gcov_info_to_gcda()`` and +``__gcov_filename_to_gcfn()``, to generate a byte stream from a gcov +information bock. The functions are declared in ``#include ``. The +byte stream can be deserialized by the :command:`merge-stream` subcommand of the +:command:`gcov-tool` to create or update :samp:`.gcda` files in the host +filesystem for the instrumented application. + +Tutorial +^^^^^^^^ + +This tutorial should be exercised on the host system. We will build a program +instrumented for test coverage. The program runs an application and dumps the +gcov information to :samp:`stderr` encoded as a printable character stream. The +application simply decodes such character streams from :samp:`stdin` and writes +the decoded character stream to :samp:`stdout` (warning: this is binary data). +The decoded character stream is consumed by the :command:`merge-stream` +subcommand of the :command:`gcov-tool` to create or update the :samp:`.gcda` +files. + +To get started, create an empty directory. Change into the new directory. +Then you will create the following three files in this directory + +* :samp:`app.h` - a header file included by :samp:`app.c` and :samp:`main.c`, + +* :samp:`app.c` - a source file which contains an example application, and + +* :samp:`main.c` - a source file which contains the program main function and code + to dump the gcov information. + +Firstly, create the header file :samp:`app.h` with the following content: + +.. code-block:: c++ + + static const unsigned char a = 'a'; + + static inline unsigned char * + encode (unsigned char c, unsigned char buf[2]) + { + buf[0] = c % 16 + a; + buf[1] = (c / 16) % 16 + a; + return buf; + } + + extern void application (void); + +Secondly, create the source file :samp:`app.c` with the following content: + +.. code-block:: c++ + + #include "app.h" + + #include + + /* The application reads a character stream encoded by encode() from stdin, + decodes it, and writes the decoded characters to stdout. Characters other + than the 16 characters 'a' to 'p' are ignored. */ + + static int can_decode (unsigned char c) + { + return (unsigned char)(c - a) < 16; + } + + void + application (void) + { + int first = 1; + int i; + unsigned char c; + + while ((i = fgetc (stdin)) != EOF) + { + unsigned char x = (unsigned char)i; + + if (can_decode (x)) + { + if (first) + c = x - a; + else + fputc (c + 16 * (x - a), stdout); + first = !first; + } + else + first = 1; + } + } + +Thirdly, create the source file :samp:`main.c` with the following content: + +.. code-block:: c++ + + #include "app.h" + + #include + #include + #include + + /* The start and end symbols are provided by the linker script. We use the + array notation to avoid issues with a potential small-data area. */ + + extern const struct gcov_info *const __gcov_info_start[]; + extern const struct gcov_info *const __gcov_info_end[]; + + /* This function shall produce a reliable in order byte stream to transfer the + gcov information from the target to the host system. */ + + static void + dump (const void *d, unsigned n, void *arg) + { + (void)arg; + const unsigned char *c = d; + unsigned char buf[2]; + + for (unsigned i = 0; i < n; ++i) + fwrite (encode (c[i], buf), sizeof (buf), 1, stderr); + } + + /* The filename is serialized to a gcfn data stream by the + __gcov_filename_to_gcfn() function. The gcfn data is used by the + "merge-stream" subcommand of the "gcov-tool" to figure out the filename + associated with the gcov information. */ + + static void + filename (const char *f, void *arg) + { + __gcov_filename_to_gcfn (f, dump, arg); + } + + /* The __gcov_info_to_gcda() function may have to allocate memory under + certain conditions. Simply try it out if it is needed for your application + or not. */ + + static void * + allocate (unsigned length, void *arg) + { + (void)arg; + return malloc (length); + } + + /* Dump the gcov information of all translation units. */ + + static void + dump_gcov_info (void) + { + const struct gcov_info *const *info = __gcov_info_start; + const struct gcov_info *const *end = __gcov_info_end; + + /* Obfuscate variable to prevent compiler optimizations. */ + __asm__ ("" : "+r" (info)); + + while (info != end) + { + void *arg = NULL; + __gcov_info_to_gcda (*info, filename, dump, allocate, arg); + fputc ('\n', stderr); + ++info; + } + } + + /* The main() function just runs the application and then dumps the gcov + information to stderr. */ + + int + main (void) + { + application (); + dump_gcov_info (); + return 0; + } + +If we compile :samp:`app.c` with test coverage and no extra profiling options, +then a global constructor (``_sub_I_00100_0`` here, it may have a different +name in your environment) and destructor (``_sub_D_00100_1``) is used to +register and dump the gcov information, respectively. We also see undefined +references to ``__gcov_init`` and ``__gcov_exit`` : + +.. code-block:: shell-session + + $ gcc --coverage -c app.c + $ nm app.o + 0000000000000000 r a + 0000000000000030 T application + 0000000000000000 t can_decode + U fgetc + U fputc + 0000000000000000 b __gcov0.application + 0000000000000038 b __gcov0.can_decode + 0000000000000000 d __gcov_.application + 00000000000000c0 d __gcov_.can_decode + U __gcov_exit + U __gcov_init + U __gcov_merge_add + U stdin + U stdout + 0000000000000161 t _sub_D_00100_1 + 0000000000000151 t _sub_I_00100_0 + +Compile :samp:`app.c` and :samp:`main.c` with test coverage and +:option:`-fprofile-info-section`. Now, a read-only pointer size object is +present in the ``.gcov_info`` section and there are no undefined references +to ``__gcov_init`` and ``__gcov_exit`` : + +.. code-block:: shell-session + + $ gcc --coverage -fprofile-info-section -c main.c + $ gcc --coverage -fprofile-info-section -c app.c + $ objdump -h app.o + + app.o: file format elf64-x86-64 + + Sections: + Idx Name Size VMA LMA File off Algn + 0 .text 00000151 0000000000000000 0000000000000000 00000040 2**0 + CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE + 1 .data 00000100 0000000000000000 0000000000000000 000001a0 2**5 + CONTENTS, ALLOC, LOAD, RELOC, DATA + 2 .bss 00000040 0000000000000000 0000000000000000 000002a0 2**5 + ALLOC + 3 .rodata 0000003c 0000000000000000 0000000000000000 000002a0 2**3 + CONTENTS, ALLOC, LOAD, READONLY, DATA + 4 .gcov_info 00000008 0000000000000000 0000000000000000 000002e0 2**3 + CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA + 5 .comment 0000004e 0000000000000000 0000000000000000 000002e8 2**0 + CONTENTS, READONLY + 6 .note.GNU-stack 00000000 0000000000000000 0000000000000000 00000336 2**0 + CONTENTS, READONLY + 7 .eh_frame 00000058 0000000000000000 0000000000000000 00000338 2**3 + CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA + +We have to customize the program link procedure so that all the +``.gcov_info`` linker input sections are placed in a contiguous memory block +with a begin and end symbol. Firstly, get the default linker script using the +following commands (we assume a GNU linker): + +.. code-block:: shell-session + + $ ld --verbose | sed '1,/^===/d' | sed '/^===/d' > linkcmds + +Secondly, open the file :samp:`linkcmds` with a text editor and place the linker +output section definition from the overview after the ``.rodata`` section +definition. Link the program executable using the customized linker script: + +.. code-block:: shell-session + + $ gcc --coverage main.o app.o -T linkcmds -Wl,-Map,app.map + +In the linker map file :samp:`app.map`, we see that the linker placed the +read-only pointer size objects of our objects files :samp:`main.o` and +:samp:`app.o` into a contiguous memory block and provided the symbols +``__gcov_info_start`` and ``__gcov_info_end`` : + +.. code-block:: shell-session + + $ grep -C 1 "\.gcov_info" app.map + + .gcov_info 0x0000000000403ac0 0x10 + 0x0000000000403ac0 PROVIDE (__gcov_info_start = .) + *(.gcov_info) + .gcov_info 0x0000000000403ac0 0x8 main.o + .gcov_info 0x0000000000403ac8 0x8 app.o + 0x0000000000403ad0 PROVIDE (__gcov_info_end = .) + +Make sure no :samp:`.gcda` files are present. Run the program with nothing to +decode and dump :samp:`stderr` to the file :samp:`gcda-0.txt` (first run). Run +the program to decode :samp:`gcda-0.txt` and send it to the :command:`gcov-tool` +using the :command:`merge-stream` subcommand to create the :samp:`.gcda` files +(second run). Run :command:`gcov` to produce a report for :samp:`app.c`. We see +that the first run with nothing to decode results in a partially covered +application: + +.. code-block:: shell-session + + $ rm -f app.gcda main.gcda + $ echo "" | ./a.out 2>gcda-0.txt + $ ./a.out gcda-1.txt | gcov-tool merge-stream + $ gcov -bc app.c + File 'app.c' + Lines executed:69.23% of 13 + Branches executed:66.67% of 6 + Taken at least once:50.00% of 6 + Calls executed:66.67% of 3 + Creating 'app.c.gcov' + + Lines executed:69.23% of 13 + +Run the program to decode :samp:`gcda-1.txt` and send it to the +:command:`gcov-tool` using the :command:`merge-stream` subcommand to update the +:samp:`.gcda` files. Run :command:`gcov` to produce a report for :samp:`app.c`. +Since the second run decoded the gcov information of the first run, we have now +a fully covered application: + +.. code-block:: shell-session + + $ ./a.out gcda-2.txt | gcov-tool merge-stream + $ gcov -bc app.c + File 'app.c' + Lines executed:100.00% of 13 + Branches executed:100.00% of 6 + Taken at least once:100.00% of 6 + Calls executed:100.00% of 3 + Creating 'app.c.gcov' + + Lines executed:100.00% of 13 + +System Initialization Caveats +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The gcov information of a translation unit consists of several global data +structures. For example, the instrumented code may update program flow graph +edge counters in a zero-initialized data structure. It is safe to run +instrumented code before the zero-initialized data is cleared to zero. The +coverage information obtained before the zero-initialized data is cleared to +zero is unusable. Dumping the gcov information using +``__gcov_info_to_gcda()`` before the zero-initialized data is cleared to +zero or the initialized data is loaded, is undefined behaviour. Clearing the +zero-initialized data to zero through a function instrumented for profiling or +test coverage is undefined behaviour, since it may produce inconsistent program +flow graph edge counters for example. \ No newline at end of file diff --git a/gcc/doc/gcc/gcov/using-gcov-with-gcc-optimization.rst b/gcc/doc/gcc/gcov/using-gcov-with-gcc-optimization.rst new file mode 100644 index 00000000000..eaab0a8bc43 --- /dev/null +++ b/gcc/doc/gcc/gcov/using-gcov-with-gcc-optimization.rst @@ -0,0 +1,86 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gcov-and-optimization: + +Using gcov with GCC Optimization +******************************** + +If you plan to use :command:`gcov` to help optimize your code, you must +first compile your program with a special GCC option +:samp:`--coverage`. Aside from that, you can use any +other GCC options; but if you want to prove that every single line +in your program was executed, you should not compile with optimization +at the same time. On some machines the optimizer can eliminate some +simple code lines by combining them with other lines. For example, code +like this: + +.. code-block:: c++ + + if (a != b) + c = 1; + else + c = 0; + +can be compiled into one instruction on some machines. In this case, +there is no way for :command:`gcov` to calculate separate execution counts +for each line because there isn't separate code for each line. Hence +the :command:`gcov` output looks like this if you compiled the program with +optimization: + +.. code-block:: c++ + + 100: 12:if (a != b) + 100: 13: c = 1; + 100: 14:else + 100: 15: c = 0; + +The output shows that this block of code, combined by optimization, +executed 100 times. In one sense this result is correct, because there +was only one instruction representing all four of these lines. However, +the output does not indicate how many times the result was 0 and how +many times the result was 1. + +Inlineable functions can create unexpected line counts. Line counts are +shown for the source code of the inlineable function, but what is shown +depends on where the function is inlined, or if it is not inlined at all. + +If the function is not inlined, the compiler must emit an out of line +copy of the function, in any object file that needs it. If +:samp:`fileA.o` and :samp:`fileB.o` both contain out of line bodies of a +particular inlineable function, they will also both contain coverage +counts for that function. When :samp:`fileA.o` and :samp:`fileB.o` are +linked together, the linker will, on many systems, select one of those +out of line bodies for all calls to that function, and remove or ignore +the other. Unfortunately, it will not remove the coverage counters for +the unused function body. Hence when instrumented, all but one use of +that function will show zero counts. + +If the function is inlined in several places, the block structure in +each location might not be the same. For instance, a condition might +now be calculable at compile time in some instances. Because the +coverage of all the uses of the inline function will be shown for the +same source lines, the line counts themselves might seem inconsistent. + +Long-running applications can use the ``__gcov_reset`` and ``__gcov_dump`` +facilities to restrict profile collection to the program region of +interest. Calling ``__gcov_reset(void)`` will clear all run-time profile +counters to zero, and calling ``__gcov_dump(void)`` will cause the profile +information collected at that point to be dumped to :samp:`.gcda` output files. +Instrumented applications use a static destructor with priority 99 +to invoke the ``__gcov_dump`` function. Thus ``__gcov_dump`` +is executed after all user defined static destructors, +as well as handlers registered with ``atexit``. + +If an executable loads a dynamic shared object via dlopen functionality, +:option:`-Wl,--dynamic-list-data` is needed to dump all profile data. + +Profiling run-time library reports various errors related to profile +manipulation and profile saving. Errors are printed into standard error output +or :samp:`GCOV_ERROR_FILE` file, if environment variable is used. +In order to terminate immediately after an errors occurs +set :samp:`GCOV_EXIT_AT_ERROR` environment variable. +That can help users to find profile clashing which leads +to a misleading profile. \ No newline at end of file diff --git a/gcc/doc/gcc/general-public-license-3.rst b/gcc/doc/gcc/general-public-license-3.rst new file mode 100644 index 00000000000..becda773ca0 --- /dev/null +++ b/gcc/doc/gcc/general-public-license-3.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/gpl-3.0.rst \ No newline at end of file diff --git a/gcc/doc/gcc/gnu-free-documentation-license.rst b/gcc/doc/gcc/gnu-free-documentation-license.rst new file mode 100644 index 00000000000..1de809b3636 --- /dev/null +++ b/gcc/doc/gcc/gnu-free-documentation-license.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/gnu_free_documentation_license.rst \ No newline at end of file diff --git a/gcc/doc/gcc/gnu-objective-c-features.rst b/gcc/doc/gcc/gnu-objective-c-features.rst new file mode 100644 index 00000000000..bce77af685d --- /dev/null +++ b/gcc/doc/gcc/gnu-objective-c-features.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _objective-c: + +GNU Objective-C Features +------------------------ + +This document is meant to describe some of the GNU Objective-C +features. It is not intended to teach you Objective-C. There are +several resources on the Internet that present the language. + +.. toctree:: + :maxdepth: 2 + + gnu-objective-c-features/gnu-objective-c-runtime-api + gnu-objective-c-features/load-executing-code-before-main + gnu-objective-c-features/type-encoding + gnu-objective-c-features/garbage-collection + gnu-objective-c-features/constant-string-objects + gnu-objective-c-features/compatibilityalias + gnu-objective-c-features/exceptions + gnu-objective-c-features/synchronization + gnu-objective-c-features/fast-enumeration + gnu-objective-c-features/messaging-with-the-gnu-objective-c-runtime \ No newline at end of file diff --git a/gcc/doc/gcc/gnu-objective-c-features/compatibilityalias.rst b/gcc/doc/gcc/gnu-objective-c-features/compatibilityalias.rst new file mode 100644 index 00000000000..4255144c8a8 --- /dev/null +++ b/gcc/doc/gcc/gnu-objective-c-features/compatibilityalias.rst @@ -0,0 +1,26 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _compatibility_alias: + +compatibility_alias +******************* + +The keyword ``@compatibility_alias`` allows you to define a class name +as equivalent to another class name. For example: + +.. code-block:: objective-c + + @compatibility_alias WOApplication GSWApplication; + +tells the compiler that each time it encounters ``WOApplication`` as +a class name, it should replace it with ``GSWApplication`` (that is, +``WOApplication`` is just an alias for ``GSWApplication``). + +There are some constraints on how this can be used--- + +* ``WOApplication`` (the alias) must not be an existing class; + +* ``GSWApplication`` (the real class) must be an existing class. \ No newline at end of file diff --git a/gcc/doc/gcc/gnu-objective-c-features/constant-string-objects.rst b/gcc/doc/gcc/gnu-objective-c-features/constant-string-objects.rst new file mode 100644 index 00000000000..2e7b8ba8b6c --- /dev/null +++ b/gcc/doc/gcc/gnu-objective-c-features/constant-string-objects.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _constant-string-objects: + +Constant String Objects +*********************** + +GNU Objective-C provides constant string objects that are generated +directly by the compiler. You declare a constant string object by +prefixing a C constant string with the character :samp:`@`: + +.. code-block:: objective-c + + id myString = @"this is a constant string object"; + +The constant string objects are by default instances of the +``NXConstantString`` class which is provided by the GNU Objective-C +runtime. To get the definition of this class you must include the +:samp:`objc/NXConstStr.h` header file. + +User defined libraries may want to implement their own constant string +class. To be able to support them, the GNU Objective-C compiler provides +a new command line options :option:`-fconstant-string-class=class-name`. +The provided class should adhere to a strict structure, the same +as ``NXConstantString`` 's structure: + +.. code-block:: objective-c + + @interface MyConstantStringClass + { + Class isa; + char *c_string; + unsigned int len; + } + @end + +``NXConstantString`` inherits from ``Object`` ; user class +libraries may choose to inherit the customized constant string class +from a different class than ``Object``. There is no requirement in +the methods the constant string class has to implement, but the final +ivar layout of the class must be the compatible with the given +structure. + +When the compiler creates the statically allocated constant string +object, the ``c_string`` field will be filled by the compiler with +the string; the ``length`` field will be filled by the compiler with +the string length; the ``isa`` pointer will be filled with +``NULL`` by the compiler, and it will later be fixed up automatically +at runtime by the GNU Objective-C runtime library to point to the class +which was set by the :option:`-fconstant-string-class` option when the +object file is loaded (if you wonder how it works behind the scenes, the +name of the class to use, and the list of static objects to fixup, are +stored by the compiler in the object file in a place where the GNU +runtime library will find them at runtime). + +As a result, when a file is compiled with the +:option:`-fconstant-string-class` option, all the constant string objects +will be instances of the class specified as argument to this option. It +is possible to have multiple compilation units referring to different +constant string classes, neither the compiler nor the linker impose any +restrictions in doing this. \ No newline at end of file diff --git a/gcc/doc/gcc/gnu-objective-c-features/exceptions.rst b/gcc/doc/gcc/gnu-objective-c-features/exceptions.rst new file mode 100644 index 00000000000..f763e12b4a9 --- /dev/null +++ b/gcc/doc/gcc/gnu-objective-c-features/exceptions.rst @@ -0,0 +1,79 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _exceptions: + +Exceptions +********** + +GNU Objective-C provides exception support built into the language, as +in the following example: + +.. code-block:: objective-c + + @try { + ... + @throw expr; + ... + } + @catch (AnObjCClass *exc) { + ... + @throw expr; + ... + @throw; + ... + } + @catch (AnotherClass *exc) { + ... + } + @catch (id allOthers) { + ... + } + @finally { + ... + @throw expr; + ... + } + +The ``@throw`` statement may appear anywhere in an Objective-C or +Objective-C++ program; when used inside of a ``@catch`` block, the +``@throw`` may appear without an argument (as shown above), in +which case the object caught by the ``@catch`` will be rethrown. + +Note that only (pointers to) Objective-C objects may be thrown and +caught using this scheme. When an object is thrown, it will be caught +by the nearest ``@catch`` clause capable of handling objects of +that type, analogously to how ``catch`` blocks work in C++ and +Java. A ``@catch(id ...)`` clause (as shown above) may also +be provided to catch any and all Objective-C exceptions not caught by +previous ``@catch`` clauses (if any). + +The ``@finally`` clause, if present, will be executed upon exit +from the immediately preceding ``@try ... @catch`` section. +This will happen regardless of whether any exceptions are thrown, +caught or rethrown inside the ``@try ... @catch`` section, +analogously to the behavior of the ``finally`` clause in Java. + +There are several caveats to using the new exception mechanism: + +* The :option:`-fobjc-exceptions` command line option must be used when + compiling Objective-C files that use exceptions. + +* With the GNU runtime, exceptions are always implemented as 'native' + exceptions and it is recommended that the :option:`-fexceptions` and + :option:`-shared-libgcc` options are used when linking. + +* With the NeXT runtime, although currently designed to be binary + compatible with ``NS_HANDLER`` -style idioms provided by the + ``NSException`` class, the new exceptions can only be used on Mac + OS X 10.3 (Panther) and later systems, due to additional functionality + needed in the NeXT Objective-C runtime. + +* As mentioned above, the new exceptions do not support handling + types other than Objective-C objects. Furthermore, when used from + Objective-C++, the Objective-C exception model does not interoperate with C++ + exceptions at this time. This means you cannot ``@throw`` an exception + from Objective-C and ``catch`` it in C++, or vice versa + (i.e., ``throw ... @catch``). \ No newline at end of file diff --git a/gcc/doc/gcc/gnu-objective-c-features/fast-enumeration.rst b/gcc/doc/gcc/gnu-objective-c-features/fast-enumeration.rst new file mode 100644 index 00000000000..bc4a43298a4 --- /dev/null +++ b/gcc/doc/gcc/gnu-objective-c-features/fast-enumeration.rst @@ -0,0 +1,221 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _fast-enumeration: + +Fast Enumeration +**************** + +.. toctree:: + :maxdepth: 2 + + +.. ================================ + +.. _using-fast-enumeration: + +Using Fast Enumeration +^^^^^^^^^^^^^^^^^^^^^^ + +GNU Objective-C provides support for the fast enumeration syntax: + +.. code-block:: objective-c + + id array = ...; + id object; + + for (object in array) + { + /* Do something with 'object' */ + } + +``array`` needs to be an Objective-C object (usually a collection +object, for example an array, a dictionary or a set) which implements +the 'Fast Enumeration Protocol' (see below). If you are using a +Foundation library such as GNUstep Base or Apple Cocoa Foundation, all +collection objects in the library implement this protocol and can be +used in this way. + +The code above would iterate over all objects in ``array``. For +each of them, it assigns it to ``object``, then executes the +``Do something with 'object'`` statements. + +Here is a fully worked-out example using a Foundation library (which +provides the implementation of ``NSArray``, ``NSString`` and +``NSLog``): + +.. code-block:: objective-c + + NSArray *array = [NSArray arrayWithObjects: @"1", @"2", @"3", nil]; + NSString *object; + + for (object in array) + NSLog (@"Iterating over %@", object); + +.. ================================ + +.. _c99-like-fast-enumeration-syntax: + +C99-Like Fast Enumeration Syntax +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A c99-like declaration syntax is also allowed: + +.. code-block:: objective-c + + id array = ...; + + for (id object in array) + { + /* Do something with 'object' */ + } + +this is completely equivalent to: + +.. code-block:: objective-c + + id array = ...; + + { + id object; + for (object in array) + { + /* Do something with 'object' */ + } + } + +but can save some typing. + +Note that the option :option:`-std=c99` is not required to allow this +syntax in Objective-C. + +.. ================================ + +.. _fast-enumeration-details: + +Fast Enumeration Details +^^^^^^^^^^^^^^^^^^^^^^^^ + +Here is a more technical description with the gory details. Consider the code + +.. code-block:: objective-c + + for (object expression in collection expression) + { + statements + } + +here is what happens when you run it: + +* ``collection expression`` is evaluated exactly once and the + result is used as the collection object to iterate over. This means + it is safe to write code such as ``for (object in [NSDictionary + keyEnumerator]) ...``. + +* the iteration is implemented by the compiler by repeatedly getting + batches of objects from the collection object using the fast + enumeration protocol (see below), then iterating over all objects in + the batch. This is faster than a normal enumeration where objects are + retrieved one by one (hence the name 'fast enumeration'). + +* if there are no objects in the collection, then + ``object expression`` is set to ``nil`` and the loop + immediately terminates. + +* if there are objects in the collection, then for each object in the + collection (in the order they are returned) ``object expression`` + is set to the object, then ``statements`` are executed. + +* ``statements`` can contain ``break`` and ``continue`` + commands, which will abort the iteration or skip to the next loop + iteration as expected. + +* when the iteration ends because there are no more objects to iterate + over, ``object expression`` is set to ``nil``. This allows + you to determine whether the iteration finished because a ``break`` + command was used (in which case ``object expression`` will remain + set to the last object that was iterated over) or because it iterated + over all the objects (in which case ``object expression`` will be + set to ``nil``). + +* ``statements`` must not make any changes to the collection + object; if they do, it is a hard error and the fast enumeration + terminates by invoking ``objc_enumerationMutation``, a runtime + function that normally aborts the program but which can be customized + by Foundation libraries via ``objc_set_mutation_handler`` to do + something different, such as raising an exception. + +.. ================================ + +.. _fast-enumeration-protocol: + +Fast Enumeration Protocol +^^^^^^^^^^^^^^^^^^^^^^^^^ + +If you want your own collection object to be usable with fast +enumeration, you need to have it implement the method + +.. code-block:: + + - (unsigned long) countByEnumeratingWithState: (NSFastEnumerationState \*)state + objects: (id \*)objects + count: (unsigned long)len; + +where ``NSFastEnumerationState`` must be defined in your code as follows: + +.. code-block:: objective-c + + typedef struct + { + unsigned long state; + id *itemsPtr; + unsigned long *mutationsPtr; + unsigned long extra[5]; + } NSFastEnumerationState; + +If no ``NSFastEnumerationState`` is defined in your code, the +compiler will automatically replace ``NSFastEnumerationState *`` +with ``struct __objcFastEnumerationState *``, where that type is +silently defined by the compiler in an identical way. This can be +confusing and we recommend that you define +``NSFastEnumerationState`` (as shown above) instead. + +The method is called repeatedly during a fast enumeration to retrieve +batches of objects. Each invocation of the method should retrieve the +next batch of objects. + +The return value of the method is the number of objects in the current +batch; this should not exceed ``len``, which is the maximum size of +a batch as requested by the caller. The batch itself is returned in +the ``itemsPtr`` field of the ``NSFastEnumerationState`` struct. + +To help with returning the objects, the ``objects`` array is a C +array preallocated by the caller (on the stack) of size ``len``. +In many cases you can put the objects you want to return in that +``objects`` array, then do ``itemsPtr = objects``. But you +don't have to; if your collection already has the objects to return in +some form of C array, it could return them from there instead. + +The ``state`` and ``extra`` fields of the +``NSFastEnumerationState`` structure allows your collection object +to keep track of the state of the enumeration. In a simple array +implementation, ``state`` may keep track of the index of the last +object that was returned, and ``extra`` may be unused. + +The ``mutationsPtr`` field of the ``NSFastEnumerationState`` is +used to keep track of mutations. It should point to a number; before +working on each object, the fast enumeration loop will check that this +number has not changed. If it has, a mutation has happened and the +fast enumeration will abort. So, ``mutationsPtr`` could be set to +point to some sort of version number of your collection, which is +increased by one every time there is a change (for example when an +object is added or removed). Or, if you are content with less strict +mutation checks, it could point to the number of objects in your +collection or some other value that can be checked to perform an +approximate check that the collection has not been mutated. + +Finally, note how we declared the ``len`` argument and the return +value to be of type ``unsigned long``. They could also be declared +to be of type ``unsigned int`` and everything would still work. \ No newline at end of file diff --git a/gcc/doc/gcc/gnu-objective-c-features/garbage-collection.rst b/gcc/doc/gcc/gnu-objective-c-features/garbage-collection.rst new file mode 100644 index 00000000000..c78a66cb291 --- /dev/null +++ b/gcc/doc/gcc/gnu-objective-c-features/garbage-collection.rst @@ -0,0 +1,81 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _garbage-collection: + +Garbage Collection +****************** + +This section is specific for the GNU Objective-C runtime. If you are +using a different runtime, you can skip it. + +Support for garbage collection with the GNU runtime has been added by +using a powerful conservative garbage collector, known as the +Boehm-Demers-Weiser conservative garbage collector. + +To enable the support for it you have to configure the compiler using +an additional argument, :option:`--enable-objc-gc`. This will +build the boehm-gc library, and build an additional runtime library +which has several enhancements to support the garbage collector. The +new library has a new name, :samp:`libobjc_gc.a` to not conflict with +the non-garbage-collected library. + +When the garbage collector is used, the objects are allocated using the +so-called typed memory allocation mechanism available in the +Boehm-Demers-Weiser collector. This mode requires precise information on +where pointers are located inside objects. This information is computed +once per class, immediately after the class has been initialized. + +There is a new runtime function ``class_ivar_set_gcinvisible()`` +which can be used to declare a so-called :dfn:`weak pointer` +reference. Such a pointer is basically hidden for the garbage collector; +this can be useful in certain situations, especially when you want to +keep track of the allocated objects, yet allow them to be +collected. This kind of pointers can only be members of objects, you +cannot declare a global pointer as a weak reference. Every type which is +a pointer type can be declared a weak pointer, including ``id``, +``Class`` and ``SEL``. + +Here is an example of how to use this feature. Suppose you want to +implement a class whose instances hold a weak pointer reference; the +following class does this: + +.. code-block:: objective-c + + @interface WeakPointer : Object + { + const void* weakPointer; + } + + - initWithPointer:(const void*)p; + - (const void*)weakPointer; + @end + + @implementation WeakPointer + + + (void)initialize + { + if (self == objc_lookUpClass ("WeakPointer")) + class_ivar_set_gcinvisible (self, "weakPointer", YES); + } + + - initWithPointer:(const void*)p + { + weakPointer = p; + return self; + } + + - (const void*)weakPointer + { + return weakPointer; + } + + @end + +Weak pointers are supported through a new type character specifier +represented by the :samp:`!` character. The +``class_ivar_set_gcinvisible()`` function adds or removes this +specifier to the string type description of the instance variable named +as argument. \ No newline at end of file diff --git a/gcc/doc/gcc/gnu-objective-c-features/gnu-objective-c-runtime-api.rst b/gcc/doc/gcc/gnu-objective-c-features/gnu-objective-c-runtime-api.rst new file mode 100644 index 00000000000..6c5f0381c60 --- /dev/null +++ b/gcc/doc/gcc/gnu-objective-c-features/gnu-objective-c-runtime-api.rst @@ -0,0 +1,98 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gnu-objective-c-runtime-api: + +GNU Objective-C Runtime API +*************************** + +This section is specific for the GNU Objective-C runtime. If you are +using a different runtime, you can skip it. + +The GNU Objective-C runtime provides an API that allows you to +interact with the Objective-C runtime system, querying the live +runtime structures and even manipulating them. This allows you for +example to inspect and navigate classes, methods and protocols; to +define new classes or new methods, and even to modify existing classes +or protocols. + +If you are using a 'Foundation' library such as GNUstep-Base, this +library will provide you with a rich set of functionality to do most +of the inspection tasks, and you probably will only need direct access +to the GNU Objective-C runtime API to define new classes or methods. + +.. toctree:: + :maxdepth: 2 + + +.. ========================================================================= + +.. _modern-gnu-objective-c-runtime-api: + +Modern GNU Objective-C Runtime API +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The GNU Objective-C runtime provides an API which is similar to the +one provided by the 'Objective-C 2.0' Apple/NeXT Objective-C +runtime. The API is documented in the public header files of the GNU +Objective-C runtime: + +* :samp:`objc/objc.h`: this is the basic Objective-C header file, + defining the basic Objective-C types such as ``id``, ``Class`` + and ``BOOL``. You have to include this header to do almost + anything with Objective-C. + +* :samp:`objc/runtime.h`: this header declares most of the public runtime + API functions allowing you to inspect and manipulate the Objective-C + runtime data structures. These functions are fairly standardized + across Objective-C runtimes and are almost identical to the Apple/NeXT + Objective-C runtime ones. It does not declare functions in some + specialized areas (constructing and forwarding message invocations, + threading) which are in the other headers below. You have to include + :samp:`objc/objc.h` and :samp:`objc/runtime.h` to use any of the + functions, such as ``class_getName()``, declared in + :samp:`objc/runtime.h`. + +* :samp:`objc/message.h`: this header declares public functions used to + construct, deconstruct and forward message invocations. Because + messaging is done in quite a different way on different runtimes, + functions in this header are specific to the GNU Objective-C runtime + implementation. + +* :samp:`objc/objc-exception.h`: this header declares some public + functions related to Objective-C exceptions. For example functions in + this header allow you to throw an Objective-C exception from plain + C/C++ code. + +* :samp:`objc/objc-sync.h`: this header declares some public functions + related to the Objective-C ``@synchronized()`` syntax, allowing + you to emulate an Objective-C ``@synchronized()`` block in plain + C/C++ code. + +* :samp:`objc/thr.h`: this header declares a public runtime API threading + layer that is only provided by the GNU Objective-C runtime. It + declares functions such as ``objc_mutex_lock()``, which provide a + platform-independent set of threading functions. + +The header files contain detailed documentation for each function in +the GNU Objective-C runtime API. + +.. ========================================================================= + +.. _traditional-gnu-objective-c-runtime-api: + +Traditional GNU Objective-C Runtime API +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The GNU Objective-C runtime used to provide a different API, which we +call the 'traditional' GNU Objective-C runtime API. Functions +belonging to this API are easy to recognize because they use a +different naming convention, such as ``class_get_super_class()`` +(traditional API) instead of ``class_getSuperclass()`` (modern +API). Software using this API includes the file +:samp:`objc/objc-api.h` where it is declared. + +Starting with GCC 4.7.0, the traditional GNU runtime API is no longer +available. \ No newline at end of file diff --git a/gcc/doc/gcc/gnu-objective-c-features/load-executing-code-before-main.rst b/gcc/doc/gcc/gnu-objective-c-features/load-executing-code-before-main.rst new file mode 100644 index 00000000000..04a3e840a1b --- /dev/null +++ b/gcc/doc/gcc/gnu-objective-c-features/load-executing-code-before-main.rst @@ -0,0 +1,141 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _executing-code-before-main: + ++load: Executing Code before main +********************************* + +This section is specific for the GNU Objective-C runtime. If you are +using a different runtime, you can skip it. + +The GNU Objective-C runtime provides a way that allows you to execute +code before the execution of the program enters the ``main`` +function. The code is executed on a per-class and a per-category basis, +through a special class method ``+load``. + +This facility is very useful if you want to initialize global variables +which can be accessed by the program directly, without sending a message +to the class first. The usual way to initialize global variables, in the +``+initialize`` method, might not be useful because +``+initialize`` is only called when the first message is sent to a +class object, which in some cases could be too late. + +Suppose for example you have a ``FileStream`` class that declares +``Stdin``, ``Stdout`` and ``Stderr`` as global variables, like +below: + +.. code-block:: objective-c + + FileStream *Stdin = nil; + FileStream *Stdout = nil; + FileStream *Stderr = nil; + + @implementation FileStream + + + (void)initialize + { + Stdin = [[FileStream new] initWithFd:0]; + Stdout = [[FileStream new] initWithFd:1]; + Stderr = [[FileStream new] initWithFd:2]; + } + + /* Other methods here */ + @end + +In this example, the initialization of ``Stdin``, ``Stdout`` and +``Stderr`` in ``+initialize`` occurs too late. The programmer can +send a message to one of these objects before the variables are actually +initialized, thus sending messages to the ``nil`` object. The +``+initialize`` method which actually initializes the global +variables is not invoked until the first message is sent to the class +object. The solution would require these variables to be initialized +just before entering ``main``. + +The correct solution of the above problem is to use the ``+load`` +method instead of ``+initialize`` : + +.. code-block:: objective-c + + @implementation FileStream + + + (void)load + { + Stdin = [[FileStream new] initWithFd:0]; + Stdout = [[FileStream new] initWithFd:1]; + Stderr = [[FileStream new] initWithFd:2]; + } + + /* Other methods here */ + @end + +The ``+load`` is a method that is not overridden by categories. If a +class and a category of it both implement ``+load``, both methods are +invoked. This allows some additional initializations to be performed in +a category. + +This mechanism is not intended to be a replacement for ``+initialize``. +You should be aware of its limitations when you decide to use it +instead of ``+initialize``. + +.. toctree:: + :maxdepth: 2 + + +.. _what-you-can-and-what-you-cannot-do-in-+load: + +What You Can and Cannot Do in +load +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +``+load`` is to be used only as a last resort. Because it is +executed very early, most of the Objective-C runtime machinery will +not be ready when ``+load`` is executed; hence ``+load`` works +best for executing C code that is independent on the Objective-C +runtime. + +The ``+load`` implementation in the GNU runtime guarantees you the +following things: + +* you can write whatever C code you like; + +* you can allocate and send messages to objects whose class is implemented + in the same file; + +* the ``+load`` implementation of all super classes of a class are + executed before the ``+load`` of that class is executed; + +* the ``+load`` implementation of a class is executed before the + ``+load`` implementation of any category. + +In particular, the following things, even if they can work in a +particular case, are not guaranteed: + +* allocation of or sending messages to arbitrary objects; + +* allocation of or sending messages to objects whose classes have a + category implemented in the same file; + +* sending messages to Objective-C constant strings (``@"this is a + constant string"``); + +You should make no assumptions about receiving ``+load`` in sibling +classes when you write ``+load`` of a class. The order in which +sibling classes receive ``+load`` is not guaranteed. + +The order in which ``+load`` and ``+initialize`` are called could +be problematic if this matters. If you don't allocate objects inside +``+load``, it is guaranteed that ``+load`` is called before +``+initialize``. If you create an object inside ``+load`` the +``+initialize`` method of object's class is invoked even if +``+load`` was not invoked. Note if you explicitly call ``+load`` +on a class, ``+initialize`` will be called first. To avoid possible +problems try to implement only one of these methods. + +The ``+load`` method is also invoked when a bundle is dynamically +loaded into your running program. This happens automatically without any +intervening operation from you. When you write bundles and you need to +write ``+load`` you can safely create and send messages to objects whose +classes already exist in the running program. The same restrictions as +above apply to classes defined in bundle. \ No newline at end of file diff --git a/gcc/doc/gcc/gnu-objective-c-features/messaging-with-the-gnu-objective-c-runtime.rst b/gcc/doc/gcc/gnu-objective-c-features/messaging-with-the-gnu-objective-c-runtime.rst new file mode 100644 index 00000000000..4d2405a0554 --- /dev/null +++ b/gcc/doc/gcc/gnu-objective-c-features/messaging-with-the-gnu-objective-c-runtime.rst @@ -0,0 +1,145 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _messaging-with-the-gnu-objective-c-runtime: + +Messaging with the GNU Objective-C Runtime +****************************************** + +This section is specific for the GNU Objective-C runtime. If you are +using a different runtime, you can skip it. + +The implementation of messaging in the GNU Objective-C runtime is +designed to be portable, and so is based on standard C. + +Sending a message in the GNU Objective-C runtime is composed of two +separate steps. First, there is a call to the lookup function, +``objc_msg_lookup ()`` (or, in the case of messages to super, +``objc_msg_lookup_super ()``). This runtime function takes as +argument the receiver and the selector of the method to be called; it +returns the ``IMP``, that is a pointer to the function implementing +the method. The second step of method invocation consists of casting +this pointer function to the appropriate function pointer type, and +calling the function pointed to it with the right arguments. + +For example, when the compiler encounters a method invocation such as +``[object init]``, it compiles it into a call to +``objc_msg_lookup (object, @selector(init))`` followed by a cast +of the returned value to the appropriate function pointer type, and +then it calls it. + +.. toctree:: + :maxdepth: 2 + + +.. ========================================================================= + +.. _dynamically-registering-methods: + +Dynamically Registering Methods +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If ``objc_msg_lookup()`` does not find a suitable method +implementation, because the receiver does not implement the required +method, it tries to see if the class can dynamically register the +method. + +To do so, the runtime checks if the class of the receiver implements +the method + +.. code-block:: objective-c + + + (BOOL) resolveInstanceMethod: (SEL)selector; + +in the case of an instance method, or + +.. code-block:: objective-c + + + (BOOL) resolveClassMethod: (SEL)selector; + +in the case of a class method. If the class implements it, the +runtime invokes it, passing as argument the selector of the original +method, and if it returns ``YES``, the runtime tries the lookup +again, which could now succeed if a matching method was added +dynamically by ``+resolveInstanceMethod:`` or +``+resolveClassMethod:``. + +This allows classes to dynamically register methods (by adding them to +the class using ``class_addMethod``) when they are first called. +To do so, a class should implement ``+resolveInstanceMethod:`` (or, +depending on the case, ``+resolveClassMethod:``) and have it +recognize the selectors of methods that can be registered dynamically +at runtime, register them, and return ``YES``. It should return +``NO`` for methods that it does not dynamically registered at +runtime. + +If ``+resolveInstanceMethod:`` (or ``+resolveClassMethod:``) is +not implemented or returns ``NO``, the runtime then tries the +forwarding hook. + +Support for ``+resolveInstanceMethod:`` and +``resolveClassMethod:`` was added to the GNU Objective-C runtime in +GCC version 4.6. + +.. ========================================================================= + +.. _forwarding-hook: + +Forwarding Hook +^^^^^^^^^^^^^^^ + +The GNU Objective-C runtime provides a hook, called +``__objc_msg_forward2``, which is called by +``objc_msg_lookup()`` when it cannot find a method implementation in +the runtime tables and after calling ``+resolveInstanceMethod:`` +and ``+resolveClassMethod:`` has been attempted and did not succeed +in dynamically registering the method. + +To configure the hook, you set the global variable +``__objc_msg_forward2`` to a function with the same argument and +return types of ``objc_msg_lookup()``. When +``objc_msg_lookup()`` cannot find a method implementation, it +invokes the hook function you provided to get a method implementation +to return. So, in practice ``__objc_msg_forward2`` allows you to +extend ``objc_msg_lookup()`` by adding some custom code that is +called to do a further lookup when no standard method implementation +can be found using the normal lookup. + +This hook is generally reserved for 'Foundation' libraries such as +GNUstep Base, which use it to implement their high-level method +forwarding API, typically based around the ``forwardInvocation:`` +method. So, unless you are implementing your own 'Foundation' +library, you should not set this hook. + +In a typical forwarding implementation, the ``__objc_msg_forward2`` +hook function determines the argument and return type of the method +that is being looked up, and then creates a function that takes these +arguments and has that return type, and returns it to the caller. +Creating this function is non-trivial and is typically performed using +a dedicated library such as ``libffi``. + +The forwarding method implementation thus created is returned by +``objc_msg_lookup()`` and is executed as if it was a normal method +implementation. When the forwarding method implementation is called, +it is usually expected to pack all arguments into some sort of object +(typically, an ``NSInvocation`` in a 'Foundation' library), and +hand it over to the programmer (``forwardInvocation:``) who is then +allowed to manipulate the method invocation using a high-level API +provided by the 'Foundation' library. For example, the programmer +may want to examine the method invocation arguments and name and +potentially change them before forwarding the method invocation to one +or more local objects (``performInvocation:``) or even to remote +objects (by using Distributed Objects or some other mechanism). When +all this completes, the return value is passed back and must be +returned correctly to the original caller. + +Note that the GNU Objective-C runtime currently provides no support +for method forwarding or method invocations other than the +``__objc_msg_forward2`` hook. + +If the forwarding hook does not exist or returns ``NULL``, the +runtime currently attempts forwarding using an older, deprecated API, +and if that fails, it aborts the program. In future versions of the +GNU Objective-C runtime, the runtime will immediately abort. \ No newline at end of file diff --git a/gcc/doc/gcc/gnu-objective-c-features/synchronization.rst b/gcc/doc/gcc/gnu-objective-c-features/synchronization.rst new file mode 100644 index 00000000000..a24abd76abb --- /dev/null +++ b/gcc/doc/gcc/gnu-objective-c-features/synchronization.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _synchronization: + +Synchronization +*************** + +GNU Objective-C provides support for synchronized blocks: + +.. code-block:: objective-c + + @synchronized (ObjCClass *guard) { + ... + } + +Upon entering the ``@synchronized`` block, a thread of execution +shall first check whether a lock has been placed on the corresponding +``guard`` object by another thread. If it has, the current thread +shall wait until the other thread relinquishes its lock. Once +``guard`` becomes available, the current thread will place its own +lock on it, execute the code contained in the ``@synchronized`` +block, and finally relinquish the lock (thereby making ``guard`` +available to other threads). + +Unlike Java, Objective-C does not allow for entire methods to be +marked ``@synchronized``. Note that throwing exceptions out of +``@synchronized`` blocks is allowed, and will cause the guarding +object to be unlocked properly. + +Because of the interactions between synchronization and exception +handling, you can only use ``@synchronized`` when compiling with +exceptions enabled, that is with the command line option +:option:`-fobjc-exceptions`. \ No newline at end of file diff --git a/gcc/doc/gcc/gnu-objective-c-features/type-encoding.rst b/gcc/doc/gcc/gnu-objective-c-features/type-encoding.rst new file mode 100644 index 00000000000..531c7ac0a21 --- /dev/null +++ b/gcc/doc/gcc/gnu-objective-c-features/type-encoding.rst @@ -0,0 +1,280 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _type-encoding: + +Type Encoding +************* + +This is an advanced section. Type encodings are used extensively by +the compiler and by the runtime, but you generally do not need to know +about them to use Objective-C. + +The Objective-C compiler generates type encodings for all the types. +These type encodings are used at runtime to find out information about +selectors and methods and about objects and classes. + +The types are encoded in the following way: + +.. @sp 1 + +.. list-table:: + :widths: 25 75 + + * - ``_Bool`` + - ``B`` + * - ``char`` + - ``c`` + * - ``unsigned char`` + - ``C`` + * - ``short`` + - ``s`` + * - ``unsigned short`` + - ``S`` + * - ``int`` + - ``i`` + * - ``unsigned int`` + - ``I`` + * - ``long`` + - ``l`` + * - ``unsigned long`` + - ``L`` + * - ``long long`` + - ``q`` + * - ``unsigned long long`` + - ``Q`` + * - ``float`` + - ``f`` + * - ``double`` + - ``d`` + * - ``long double`` + - ``D`` + * - ``void`` + - ``v`` + * - ``id`` + - ``@`` + * - ``Class`` + - ``#`` + * - ``SEL`` + - ``:`` + * - ``char*`` + - ``*`` + * - ``enum`` + - an ``enum`` is encoded exactly as the integer type that the compiler uses for it, which depends on the enumeration values. Often the compiler users ``unsigned int``, which is then encoded as ``I``. + * - unknown type + - ``?`` + * - Complex types + - ``j`` followed by the inner type. For example ``_Complex double`` is encoded as "jd". + * - bit-fields + - ``b`` followed by the starting position of the bit-field, the type of the bit-field and the size of the bit-field (the bit-fields encoding was changed from the NeXT's compiler encoding, see below) + +.. @sp 1 + +The encoding of bit-fields has changed to allow bit-fields to be +properly handled by the runtime functions that compute sizes and +alignments of types that contain bit-fields. The previous encoding +contained only the size of the bit-field. Using only this information +it is not possible to reliably compute the size occupied by the +bit-field. This is very important in the presence of the Boehm's +garbage collector because the objects are allocated using the typed +memory facility available in this collector. The typed memory +allocation requires information about where the pointers are located +inside the object. + +The position in the bit-field is the position, counting in bits, of the +bit closest to the beginning of the structure. + +The non-atomic types are encoded as follows: + +.. @sp 1 + +.. list-table:: + :widths: 15 85 + + * - pointers + - :samp:`^` followed by the pointed type. + * - arrays + - :samp:`[` followed by the number of elements in the array followed by the type of the elements followed by :samp:`]` + * - structures + - :samp:`{` followed by the name of the structure (or :samp:`?` if the structure is unnamed), the :samp:`=` sign, the type of the members and by :samp:`}` + * - unions + - :samp:`(` followed by the name of the structure (or :samp:`?` if the union is unnamed), the :samp:`=` sign, the type of the members followed by :samp:`)` + * - vectors + - :samp:`![` followed by the vector_size (the number of bytes composing the vector) followed by a comma, followed by the alignment (in bytes) of the vector, followed by the type of the elements followed by :samp:`]` + +Here are some types and their encodings, as they are generated by the +compiler on an i386 machine: + ++-------------------------------------------+------------------------------------------------+ +|Objective-C type |Compiler encoding | ++===========================================+================================================+ +|.. code-block:: objective-c |``[10i]`` | +| | | +| int a[10]; | | ++-------------------------------------------+------------------------------------------------+ +|.. code-block:: objective-c |``{?=i[3f]b128i3b131i2c}`` | +| | | +| struct { | | +| int i; | | +| float f[3]; | | +| int a:3; | | +| int b:2; | | +| char c; | | +| } | | ++-------------------------------------------+------------------------------------------------+ +|.. code-block:: objective-c |``![16,16i]`` (alignment depends on the machine)| +| | | +| int a __attribute__ ((vector_size (16)));| | ++-------------------------------------------+------------------------------------------------+ + +In addition to the types the compiler also encodes the type +specifiers. The table below describes the encoding of the current +Objective-C type specifiers: + +.. list-table:: + :header-rows: 1 + + * - Specifier + - Encoding + + * - ``const`` + - ``r`` + * - ``in`` + - ``n`` + * - ``inout`` + - ``N`` + * - ``out`` + - ``o`` + * - ``bycopy`` + - ``O`` + * - ``byref`` + - ``R`` + * - ``oneway`` + - ``V`` + +The type specifiers are encoded just before the type. Unlike types +however, the type specifiers are only encoded when they appear in method +argument types. + +Note how ``const`` interacts with pointers: + ++---------------------------+-----------------+ +|Objective-C type |Compiler encoding| ++===========================+=================+ +|.. code-block:: objective-c|``ri`` | +| | | +| const int | | ++---------------------------+-----------------+ +|.. code-block:: objective-c|``^ri`` | +| | | +| const int* | | ++---------------------------+-----------------+ +|.. code-block:: objective-c|``r^i`` | +| | | +| int *const | | ++---------------------------+-----------------+ + +``const int*`` is a pointer to a ``const int``, and so is +encoded as ``^ri``. ``int* const``, instead, is a ``const`` +pointer to an ``int``, and so is encoded as ``r^i``. + +Finally, there is a complication when encoding ``const char *`` +versus ``char * const``. Because ``char *`` is encoded as +``*`` and not as ``^c``, there is no way to express the fact +that ``r`` applies to the pointer or to the pointee. + +Hence, it is assumed as a convention that ``r*`` means ``const +char *`` (since it is what is most often meant), and there is no way to +encode ``char *const``. ``char *const`` would simply be encoded +as ``*``, and the ``const`` is lost. + +.. toctree:: + :maxdepth: 2 + + +.. _legacy-type-encoding: + +Legacy Type Encoding +^^^^^^^^^^^^^^^^^^^^ + +Unfortunately, historically GCC used to have a number of bugs in its +encoding code. The NeXT runtime expects GCC to emit type encodings in +this historical format (compatible with GCC-3.3), so when using the +NeXT runtime, GCC will introduce on purpose a number of incorrect +encodings: + +* the read-only qualifier of the pointee gets emitted before the '^'. + The read-only qualifier of the pointer itself gets ignored, unless it + is a typedef. Also, the 'r' is only emitted for the outermost type. + +* 32-bit longs are encoded as 'l' or 'L', but not always. For typedefs, + the compiler uses 'i' or 'I' instead if encoding a struct field or a + pointer. + +* ``enum`` s are always encoded as 'i' (int) even if they are actually + unsigned or long. + +In addition to that, the NeXT runtime uses a different encoding for +bitfields. It encodes them as ``b`` followed by the size, without +a bit offset or the underlying field type. + +.. _@encode: + +@encode +^^^^^^^ + +GNU Objective-C supports the ``@encode`` syntax that allows you to +create a type encoding from a C/Objective-C type. For example, +``@encode(int)`` is compiled by the compiler into ``"i"``. + +``@encode`` does not support type qualifiers other than +``const``. For example, ``@encode(const char*)`` is valid and +is compiled into ``"r*"``, while ``@encode(bycopy char *)`` is +invalid and will cause a compilation error. + +.. _method-signatures: + +Method Signatures +^^^^^^^^^^^^^^^^^ + +This section documents the encoding of method types, which is rarely +needed to use Objective-C. You should skip it at a first reading; the +runtime provides functions that will work on methods and can walk +through the list of parameters and interpret them for you. These +functions are part of the public 'API' and are the preferred way to +interact with method signatures from user code. + +But if you need to debug a problem with method signatures and need to +know how they are implemented (i.e., the 'ABI'), read on. + +Methods have their 'signature' encoded and made available to the +runtime. The 'signature' encodes all the information required to +dynamically build invocations of the method at runtime: return type +and arguments. + +The 'signature' is a null-terminated string, composed of the following: + +* The return type, including type qualifiers. For example, a method + returning ``int`` would have ``i`` here. + +* The total size (in bytes) required to pass all the parameters. This + includes the two hidden parameters (the object ``self`` and the + method selector ``_cmd``). + +* Each argument, with the type encoding, followed by the offset (in + bytes) of the argument in the list of parameters. + +For example, a method with no arguments and returning ``int`` would +have the signature ``i8@0:4`` if the size of a pointer is 4. The +signature is interpreted as follows: the ``i`` is the return type +(an ``int``), the ``8`` is the total size of the parameters in +bytes (two pointers each of size 4), the ``@0`` is the first +parameter (an object at byte offset ``0``) and ``:4`` is the +second parameter (a ``SEL`` at byte offset ``4``). + +You can easily find more examples by running the 'strings' program +on an Objective-C object file compiled by GCC. You'll see a lot of +strings that look very much like ``i8@0:4``. They are signatures +of Objective-C methods. \ No newline at end of file diff --git a/gcc/doc/gcc/gnu.rst b/gcc/doc/gcc/gnu.rst new file mode 100644 index 00000000000..6b3fc40858f --- /dev/null +++ b/gcc/doc/gcc/gnu.rst @@ -0,0 +1 @@ +.. include:: ../../../doc/gnu.rst \ No newline at end of file diff --git a/gcc/doc/gcc/have-you-found-a-bug.rst b/gcc/doc/gcc/have-you-found-a-bug.rst new file mode 100644 index 00000000000..2c7b38f2107 --- /dev/null +++ b/gcc/doc/gcc/have-you-found-a-bug.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: bug criteria + +.. _bug-criteria: + +Have You Found a Bug? +********************* + +If you are not sure whether you have found a bug, here are some guidelines: + +.. index:: fatal signal, core dump + +* If the compiler gets a fatal signal, for any input whatever, that is a + compiler bug. Reliable compilers never crash. + + .. index:: invalid assembly code, assembly code, invalid + +* If the compiler produces invalid assembly code, for any input whatever + (except an ``asm`` statement), that is a compiler bug, unless the + compiler reports errors (not just warnings) which would ordinarily + prevent the assembler from being run. + + .. index:: undefined behavior, undefined function value, increment operators + +* If the compiler produces valid assembly code that does not correctly + execute the input source code, that is a compiler bug. + + However, you must double-check to make sure, because you may have a + program whose behavior is undefined, which happened by chance to give + the desired results with another C or C++ compiler. + + For example, in many nonoptimizing compilers, you can write :samp:`x;` + at the end of a function instead of :samp:`return x;`, with the same + results. But the value of the function is undefined if ``return`` + is omitted; it is not a bug when GCC produces different results. + + Problems often result from expressions with two increment operators, + as in ``f (*p++, *p++)``. Your previous compiler might have + interpreted that expression the way you intended; GCC might + interpret it another way. Neither compiler is wrong. The bug is + in your code. + + After you have localized the error to a single source line, it should + be easy to check for these things. If your program is correct and + well defined, you have found a compiler bug. + +* If the compiler produces an error message for valid input, that is a + compiler bug. + + .. index:: invalid input + +* If the compiler does not produce an error message for invalid input, + that is a compiler bug. However, you should note that your idea of + 'invalid input' might be someone else's idea of 'an extension' or + 'support for traditional practice'. + +* If you are an experienced user of one of the languages GCC supports, your + suggestions for improvement of GCC are welcome in any case. \ No newline at end of file diff --git a/gcc/doc/gcc/how-and-where-to-report-bugs.rst b/gcc/doc/gcc/how-and-where-to-report-bugs.rst new file mode 100644 index 00000000000..af19f920570 --- /dev/null +++ b/gcc/doc/gcc/how-and-where-to-report-bugs.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: compiler bugs, reporting + +.. _bug-reporting: + +How and Where to Report Bugs +**************************** + +Bugs should be reported to the bug database at |bugurl|. \ No newline at end of file diff --git a/gcc/doc/gcc/how-to-get-help-with-gcc.rst b/gcc/doc/gcc/how-to-get-help-with-gcc.rst new file mode 100644 index 00000000000..fc2af7af026 --- /dev/null +++ b/gcc/doc/gcc/how-to-get-help-with-gcc.rst @@ -0,0 +1,26 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _service: + +How To Get Help with GCC +------------------------ + +If you need help installing, using or changing GCC, there are two +ways to find it: + +* Send a message to a suitable network mailing list. First try + gcc-help@gcc.gnu.org (for help installing or using GCC), and if + that brings no response, try gcc@gcc.gnu.org. For help + changing GCC, ask gcc@gcc.gnu.org. If you think you have found + a bug in GCC, please report it following the instructions at + see :ref:`bug-reporting`. + +* Look in the service directory for someone who might help you for a fee. + The service directory is found at + https://www.fsf.org/resources/service. + +For further information, see +https://gcc.gnu.org/faq.html#support. \ No newline at end of file diff --git a/gcc/doc/gcc/index.rst b/gcc/doc/gcc/index.rst new file mode 100644 index 00000000000..5aea8986f42 --- /dev/null +++ b/gcc/doc/gcc/index.rst @@ -0,0 +1,40 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Using the GNU Compiler Collection (GCC) +======================================= + +.. only:: html + + Contents: + +.. toctree:: + + copyright + gcc + programming-languages-supported-by-gcc + language-standards-supported-by-gcc + gcc-command-options + c-implementation-defined-behavior + c++-implementation-defined-behavior + extensions-to-the-c-language-family + extensions-to-the-c++-language + gnu-objective-c-features + binary-compatibility + gcov + gcov-tool + gcov-dump + lto-dump + known-causes-of-trouble-with-gcc + reporting-bugs + how-to-get-help-with-gcc + contributing-to-gcc-development + funding + gnu + general-public-license-3 + gnu-free-documentation-license + contributors-to-gcc + + indices-and-tables \ No newline at end of file diff --git a/gcc/doc/gcc/indices-and-tables.rst b/gcc/doc/gcc/indices-and-tables.rst new file mode 100644 index 00000000000..6c215a391d9 --- /dev/null +++ b/gcc/doc/gcc/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/gcc/doc/gcc/known-causes-of-trouble-with-gcc.rst b/gcc/doc/gcc/known-causes-of-trouble-with-gcc.rst new file mode 100644 index 00000000000..8fe0467f796 --- /dev/null +++ b/gcc/doc/gcc/known-causes-of-trouble-with-gcc.rst @@ -0,0 +1,32 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: bugs, known, installation trouble, known causes of trouble + +.. _trouble: + +Known Causes of Trouble with GCC +-------------------------------- + +This section describes known problems that affect users of GCC. Most +of these are not GCC bugs per se---if they were, we would fix them. +But the result for a user may be like the result of a bug. + +Some of these problems are due to bugs in other software, some are +missing features that are too much work to add, and some are places +where people's opinions differ as to what is best. + +.. toctree:: + :maxdepth: 2 + + known-causes-of-trouble-with-gcc/actual-bugs-we-havent-fixed-yet + known-causes-of-trouble-with-gcc/interoperation + known-causes-of-trouble-with-gcc/incompatibilities-of-gcc + known-causes-of-trouble-with-gcc/fixed-header-files + known-causes-of-trouble-with-gcc/standard-libraries + known-causes-of-trouble-with-gcc/disappointments-and-misunderstandings + known-causes-of-trouble-with-gcc/common-misunderstandings-with-gnu-c + known-causes-of-trouble-with-gcc/certain-changes-we-dont-want-to-make + known-causes-of-trouble-with-gcc/warning-messages-and-error-messages \ No newline at end of file diff --git a/gcc/doc/gcc/known-causes-of-trouble-with-gcc/actual-bugs-we-havent-fixed-yet.rst b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/actual-bugs-we-havent-fixed-yet.rst new file mode 100644 index 00000000000..ecd5a01b8fd --- /dev/null +++ b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/actual-bugs-we-havent-fixed-yet.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _actual-bugs: + +Actual Bugs We Haven't Fixed Yet +******************************** + +* The ``fixincludes`` script interacts badly with automounters; if the + directory of system header files is automounted, it tends to be + unmounted while ``fixincludes`` is running. This would seem to be a + bug in the automounter. We don't know any good way to work around it. \ No newline at end of file diff --git a/gcc/doc/gcc/known-causes-of-trouble-with-gcc/certain-changes-we-dont-want-to-make.rst b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/certain-changes-we-dont-want-to-make.rst new file mode 100644 index 00000000000..ef49c5d1b45 --- /dev/null +++ b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/certain-changes-we-dont-want-to-make.rst @@ -0,0 +1,236 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _non-bugs: + +Certain Changes We Don't Want to Make +************************************* + +This section lists changes that people frequently request, but which +we do not make because we think GCC is better without them. + +* Checking the number and type of arguments to a function which has an + old-fashioned definition and no prototype. + + Such a feature would work only occasionally---only for calls that appear + in the same file as the called function, following the definition. The + only way to check all calls reliably is to add a prototype for the + function. But adding a prototype eliminates the motivation for this + feature. So the feature is not worthwhile. + +* Warning about using an expression whose type is signed as a shift count. + + Shift count operands are probably signed more often than unsigned. + Warning about this would cause far more annoyance than good. + +* Warning about assigning a signed value to an unsigned variable. + + Such assignments must be very common; warning about them would cause + more annoyance than good. + +* Warning when a non-void function value is ignored. + + C contains many standard functions that return a value that most + programs choose to ignore. One obvious example is ``printf``. + Warning about this practice only leads the defensive programmer to + clutter programs with dozens of casts to ``void``. Such casts are + required so frequently that they become visual noise. Writing those + casts becomes so automatic that they no longer convey useful + information about the intentions of the programmer. For functions + where the return value should never be ignored, use the + :fn-attr:`warn_unused_result` function attribute (see :ref:`function-attributes`). + +* + .. index:: fshort-enums + + Making :option:`-fshort-enums` the default. + + This would cause storage layout to be incompatible with most other C + compilers. And it doesn't seem very important, given that you can get + the same result in other ways. The case where it matters most is when + the enumeration-valued object is inside a structure, and in that case + you can specify a field width explicitly. + +* Making bit-fields unsigned by default on particular machines where 'the + ABI standard' says to do so. + + The ISO C standard leaves it up to the implementation whether a bit-field + declared plain ``int`` is signed or not. This in effect creates two + alternative dialects of C. + + .. index:: fsigned-bitfields, funsigned-bitfields + + The GNU C compiler supports both dialects; you can specify the signed + dialect with :option:`-fsigned-bitfields` and the unsigned dialect with + :option:`-funsigned-bitfields`. However, this leaves open the question of + which dialect to use by default. + + Currently, the preferred dialect makes plain bit-fields signed, because + this is simplest. Since ``int`` is the same as ``signed int`` in + every other context, it is cleanest for them to be the same in bit-fields + as well. + + Some computer manufacturers have published Application Binary Interface + standards which specify that plain bit-fields should be unsigned. It is + a mistake, however, to say anything about this issue in an ABI. This is + because the handling of plain bit-fields distinguishes two dialects of C. + Both dialects are meaningful on every type of machine. Whether a + particular object file was compiled using signed bit-fields or unsigned + is of no concern to other object files, even if they access the same + bit-fields in the same data structures. + + A given program is written in one or the other of these two dialects. + The program stands a chance to work on most any machine if it is + compiled with the proper dialect. It is unlikely to work at all if + compiled with the wrong dialect. + + Many users appreciate the GNU C compiler because it provides an + environment that is uniform across machines. These users would be + inconvenienced if the compiler treated plain bit-fields differently on + certain machines. + + Occasionally users write programs intended only for a particular machine + type. On these occasions, the users would benefit if the GNU C compiler + were to support by default the same dialect as the other compilers on + that machine. But such applications are rare. And users writing a + program to run on more than one type of machine cannot possibly benefit + from this kind of compatibility. + + This is why GCC does and will treat plain bit-fields in the same + fashion on all types of machines (by default). + + There are some arguments for making bit-fields unsigned by default on all + machines. If, for example, this becomes a universal de facto standard, + it would make sense for GCC to go along with it. This is something + to be considered in the future. + + (Of course, users strongly concerned about portability should indicate + explicitly in each bit-field whether it is signed or not. In this way, + they write programs which have the same meaning in both C dialects.) + +* + .. index:: ansi, std + + Undefining ``__STDC__`` when :option:`-ansi` is not used. + + Currently, GCC defines ``__STDC__`` unconditionally. This provides + good results in practice. + + Programmers normally use conditionals on ``__STDC__`` to ask whether + it is safe to use certain features of ISO C, such as function + prototypes or ISO token concatenation. Since plain :command:`gcc` supports + all the features of ISO C, the correct answer to these questions is + 'yes'. + + Some users try to use ``__STDC__`` to check for the availability of + certain library facilities. This is actually incorrect usage in an ISO + C program, because the ISO C standard says that a conforming + freestanding implementation should define ``__STDC__`` even though it + does not have the library facilities. :samp:`gcc -ansi -pedantic` is a + conforming freestanding implementation, and it is therefore required to + define ``__STDC__``, even though it does not come with an ISO C + library. + + Sometimes people say that defining ``__STDC__`` in a compiler that + does not completely conform to the ISO C standard somehow violates the + standard. This is illogical. The standard is a standard for compilers + that claim to support ISO C, such as :samp:`gcc -ansi`---not for other + compilers such as plain :command:`gcc`. Whatever the ISO C standard says + is relevant to the design of plain :command:`gcc` without :option:`-ansi` only + for pragmatic reasons, not as a requirement. + + GCC normally defines ``__STDC__`` to be 1, and in addition + defines ``__STRICT_ANSI__`` if you specify the :option:`-ansi` option, + or a :option:`-std` option for strict conformance to some version of ISO C. + On some hosts, system include files use a different convention, where + ``__STDC__`` is normally 0, but is 1 if the user specifies strict + conformance to the C Standard. GCC follows the host convention when + processing system include files, but when processing user files it follows + the usual GNU C convention. + +* Undefining ``__STDC__`` in C++. + + Programs written to compile with C++-to-C translators get the + value of ``__STDC__`` that goes with the C compiler that is + subsequently used. These programs must test ``__STDC__`` + to determine what kind of C preprocessor that compiler uses: + whether they should concatenate tokens in the ISO C fashion + or in the traditional fashion. + + These programs work properly with GNU C++ if ``__STDC__`` is defined. + They would not work otherwise. + + In addition, many header files are written to provide prototypes in ISO + C but not in traditional C. Many of these header files can work without + change in C++ provided ``__STDC__`` is defined. If ``__STDC__`` + is not defined, they will all fail, and will all need to be changed to + test explicitly for C++ as well. + +* Deleting 'empty' loops. + + Historically, GCC has not deleted 'empty' loops under the + assumption that the most likely reason you would put one in a program is + to have a delay, so deleting them will not make real programs run any + faster. + + However, the rationale here is that optimization of a nonempty loop + cannot produce an empty one. This held for carefully written C compiled + with less powerful optimizers but is not always the case for carefully + written C++ or with more powerful optimizers. + Thus GCC will remove operations from loops whenever it can determine + those operations are not externally visible (apart from the time taken + to execute them, of course). In case the loop can be proved to be finite, + GCC will also remove the loop itself. + + Be aware of this when performing timing tests, for instance the + following loop can be completely removed, provided + ``some_expression`` can provably not change any global state. + + .. code-block:: c++ + + { + int sum = 0; + int ix; + + for (ix = 0; ix != 10000; ix++) + sum += some_expression; + } + + Even though ``sum`` is accumulated in the loop, no use is made of + that summation, so the accumulation can be removed. + +* Making side effects happen in the same order as in some other compiler. + + .. index:: side effects, order of evaluation, order of evaluation, side effects + + It is never safe to depend on the order of evaluation of side effects. + For example, a function call like this may very well behave differently + from one compiler to another: + + .. code-block:: c++ + + void func (int, int); + + int i = 2; + func (i++, i++); + + There is no guarantee (in either the C or the C++ standard language + definitions) that the increments will be evaluated in any particular + order. Either increment might happen first. ``func`` might get the + arguments :samp:`2, 3`, or it might get :samp:`3, 2`, or even :samp:`2, 2`. + +* Making certain warnings into errors by default. + + Some ISO C testsuites report failure when the compiler does not produce + an error message for a certain program. + + .. index:: pedantic-errors + + ISO C requires a 'diagnostic' message for certain kinds of invalid + programs, but a warning is defined by GCC to count as a diagnostic. If + GCC produces a warning but not an error, that is correct ISO C support. + If testsuites call this 'failure', they should be run with the GCC + option :option:`-pedantic-errors`, which will turn these warnings into + errors. \ No newline at end of file diff --git a/gcc/doc/gcc/known-causes-of-trouble-with-gcc/common-misunderstandings-with-gnu-c.rst b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/common-misunderstandings-with-gnu-c.rst new file mode 100644 index 00000000000..037abcb8e6d --- /dev/null +++ b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/common-misunderstandings-with-gnu-c.rst @@ -0,0 +1,296 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: misunderstandings in C++, surprises in C++, C++ misunderstandings + +.. _c++-misunderstandings: + +Common Misunderstandings with GNU C++ +************************************* + +C++ is a complex language and an evolving one, and its standard +definition (the ISO C++ standard) was only recently completed. As a +result, your C++ compiler may occasionally surprise you, even when its +behavior is correct. This section discusses some areas that frequently +give rise to questions of this sort. + +.. toctree:: + :maxdepth: 2 + + +.. index:: C++ static data, declaring and defining, static data in C++, declaring and defining, declaring static data in C++, defining static data in C++ + +.. _static-definitions: + +Declare and Define Static Members +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When a class has static data members, it is not enough to *declare* +the static member; you must also *define* it. For example: + +.. code-block:: c++ + + class Foo + { + ... + void method(); + static int bar; + }; + +This declaration only establishes that the class ``Foo`` has an +``int`` named ``Foo::bar``, and a member function named +``Foo::method``. But you still need to define *both* +``method`` and ``bar`` elsewhere. According to the ISO +standard, you must supply an initializer in one (and only one) source +file, such as: + +.. code-block:: c++ + + int Foo::bar = 0; + +Other C++ compilers may not correctly implement the standard behavior. +As a result, when you switch to :command:`g++` from one of these compilers, +you may discover that a program that appeared to work correctly in fact +does not conform to the standard: :command:`g++` reports as undefined +symbols any static data members that lack definitions. + +.. index:: base class members, two-stage name lookup, dependent name lookup + +.. _name-lookup: + +Name Lookup, Templates, and Accessing Members of Base Classes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The C++ standard prescribes that all names that are not dependent on +template parameters are bound to their present definitions when parsing +a template function or class.The C++ standard just uses the +term 'dependent' for names that depend on the type or value of +template parameters. This shorter term will also be used in the rest of +this section. + +Only names that are dependent are looked up at the point +of instantiation. For example, consider + +.. code-block:: c++ + + void foo(double); + + struct A { + template + void f () { + foo (1); // 1 + int i = N; // 2 + T t; + t.bar(); // 3 + foo (t); // 4 + } + + static const int N; + }; + +Here, the names ``foo`` and ``N`` appear in a context that does +not depend on the type of ``T``. The compiler will thus require that +they are defined in the context of use in the template, not only before +the point of instantiation, and will here use ``::foo(double)`` and +``A::N``, respectively. In particular, it will convert the integer +value to a ``double`` when passing it to ``::foo(double)``. + +Conversely, ``bar`` and the call to ``foo`` in the fourth marked +line are used in contexts that do depend on the type of ``T``, so +they are only looked up at the point of instantiation, and you can +provide declarations for them after declaring the template, but before +instantiating it. In particular, if you instantiate ``A::f``, +the last line will call an overloaded ``::foo(int)`` if one was +provided, even if after the declaration of ``struct A``. + +This distinction between lookup of dependent and non-dependent names is +called two-stage (or dependent) name lookup. G++ implements it +since version 3.4. + +Two-stage name lookup sometimes leads to situations with behavior +different from non-template codes. The most common is probably this: + +.. code-block:: c++ + + template struct Base { + int i; + }; + + template struct Derived : public Base { + int get_i() { return i; } + }; + +In ``get_i()``, ``i`` is not used in a dependent context, so the +compiler will look for a name declared at the enclosing namespace scope +(which is the global scope here). It will not look into the base class, +since that is dependent and you may declare specializations of +``Base`` even after declaring ``Derived``, so the compiler cannot +really know what ``i`` would refer to. If there is no global +variable ``i``, then you will get an error message. + +In order to make it clear that you want the member of the base class, +you need to defer lookup until instantiation time, at which the base +class is known. For this, you need to access ``i`` in a dependent +context, by either using ``this->i`` (remember that ``this`` is of +type ``Derived*``, so is obviously dependent), or using +``Base::i``. Alternatively, ``Base::i`` might be brought +into scope by a ``using`` -declaration. + +Another, similar example involves calling member functions of a base +class: + +.. code-block:: c++ + + template struct Base { + int f(); + }; + + template struct Derived : Base { + int g() { return f(); }; + }; + +Again, the call to ``f()`` is not dependent on template arguments +(there are no arguments that depend on the type ``T``, and it is also +not otherwise specified that the call should be in a dependent context). +Thus a global declaration of such a function must be available, since +the one in the base class is not visible until instantiation time. The +compiler will consequently produce the following error message: + +.. code-block:: + + x.cc: In member function `int Derived::g()': + x.cc:6: error: there are no arguments to `f' that depend on a template + parameter, so a declaration of `f' must be available + x.cc:6: error: (if you use `-fpermissive', G++ will accept your code, but + allowing the use of an undeclared name is deprecated) + +To make the code valid either use ``this->f()``, or +``Base::f()``. Using the :option:`-fpermissive` flag will also let +the compiler accept the code, by marking all function calls for which no +declaration is visible at the time of definition of the template for +later lookup at instantiation time, as if it were a dependent call. +We do not recommend using :option:`-fpermissive` to work around invalid +code, and it will also only catch cases where functions in base classes +are called, not where variables in base classes are used (as in the +example above). + +Note that some compilers (including G++ versions prior to 3.4) get these +examples wrong and accept above code without an error. Those compilers +do not implement two-stage name lookup correctly. + +.. index:: temporaries, lifetime of, portions of temporary objects, pointers to + +.. _temporaries: + +Temporaries May Vanish Before You Expect +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +It is dangerous to use pointers or references to *portions* of a +temporary object. The compiler may very well delete the object before +you expect it to, leaving a pointer to garbage. The most common place +where this problem crops up is in classes like string classes, +especially ones that define a conversion function to type ``char *`` +or ``const char *`` ---which is one reason why the standard +``string`` class requires you to call the ``c_str`` member +function. However, any class that returns a pointer to some internal +structure is potentially subject to this problem. + +For example, a program may use a function ``strfunc`` that returns +``string`` objects, and another function ``charfunc`` that +operates on pointers to ``char`` : + +.. code-block:: c++ + + string strfunc (); + void charfunc (const char *); + + void + f () + { + const char *p = strfunc().c_str(); + ... + charfunc (p); + ... + charfunc (p); + } + +In this situation, it may seem reasonable to save a pointer to the C +string returned by the ``c_str`` member function and use that rather +than call ``c_str`` repeatedly. However, the temporary string +created by the call to ``strfunc`` is destroyed after ``p`` is +initialized, at which point ``p`` is left pointing to freed memory. + +Code like this may run successfully under some other compilers, +particularly obsolete cfront-based compilers that delete temporaries +along with normal local variables. However, the GNU C++ behavior is +standard-conforming, so if your program depends on late destruction of +temporaries it is not portable. + +The safe way to write such code is to give the temporary a name, which +forces it to remain until the end of the scope of the name. For +example: + +.. code-block:: c++ + + const string& tmp = strfunc (); + charfunc (tmp.c_str ()); + +.. _copy-assignment: + +Implicit Copy-Assignment for Virtual Bases +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When a base class is virtual, only one subobject of the base class +belongs to each full object. Also, the constructors and destructors are +invoked only once, and called from the most-derived class. However, such +objects behave unspecified when being assigned. For example: + +.. code-block:: c++ + + struct Base{ + char *name; + Base(const char *n) : name(strdup(n)){} + Base& operator= (const Base& other){ + free (name); + name = strdup (other.name); + return *this; + } + }; + + struct A:virtual Base{ + int val; + A():Base("A"){} + }; + + struct B:virtual Base{ + int bval; + B():Base("B"){} + }; + + struct Derived:public A, public B{ + Derived():Base("Derived"){} + }; + + void func(Derived &d1, Derived &d2) + { + d1 = d2; + } + +The C++ standard specifies that :samp:`Base::Base` is only called once +when constructing or copy-constructing a Derived object. It is +unspecified whether :samp:`Base::operator=` is called more than once when +the implicit copy-assignment for Derived objects is invoked (as it is +inside :samp:`func` in the example). + +G++ implements the 'intuitive' algorithm for copy-assignment: assign all +direct bases, then assign all members. In that algorithm, the virtual +base subobject can be encountered more than once. In the example, copying +proceeds in the following order: :samp:`name` (via ``strdup``), +:samp:`val`, :samp:`name` again, and :samp:`bval`. + +If application code relies on copy-assignment, a user-defined +copy-assignment operator removes any uncertainties. With such an +operator, the application can define whether and how the virtual base +subobject is assigned. \ No newline at end of file diff --git a/gcc/doc/gcc/known-causes-of-trouble-with-gcc/disappointments-and-misunderstandings.rst b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/disappointments-and-misunderstandings.rst new file mode 100644 index 00000000000..5eaf16b1aff --- /dev/null +++ b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/disappointments-and-misunderstandings.rst @@ -0,0 +1,102 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _disappointments: + +Disappointments and Misunderstandings +************************************* + +These problems are perhaps regrettable, but we don't know any practical +way around them. + +* Certain local variables aren't recognized by debuggers when you compile + with optimization. + + This occurs because sometimes GCC optimizes the variable out of + existence. There is no way to tell the debugger how to compute the + value such a variable 'would have had', and it is not clear that would + be desirable anyway. So GCC simply does not mention the eliminated + variable when it writes debugging information. + + You have to expect a certain amount of disagreement between the + executable and your source code, when you use optimization. + + .. index:: conflicting types, scope of declaration + +* Users often think it is a bug when GCC reports an error for code + like this: + + .. code-block:: c++ + + int foo (struct mumble *); + + struct mumble { ... }; + + int foo (struct mumble *x) + { ... } + + This code really is erroneous, because the scope of ``struct + mumble`` in the prototype is limited to the argument list containing it. + It does not refer to the ``struct mumble`` defined with file scope + immediately below---they are two unrelated types with similar names in + different scopes. + + But in the definition of ``foo``, the file-scope type is used + because that is available to be inherited. Thus, the definition and + the prototype do not match, and you get an error. + + This behavior may seem silly, but it's what the ISO standard specifies. + It is easy enough for you to make your code work by moving the + definition of ``struct mumble`` above the prototype. It's not worth + being incompatible with ISO C just to avoid an error for the example + shown above. + +* Accesses to bit-fields even in volatile objects works by accessing larger + objects, such as a byte or a word. You cannot rely on what size of + object is accessed in order to read or write the bit-field; it may even + vary for a given bit-field according to the precise usage. + + If you care about controlling the amount of memory that is accessed, use + volatile but do not use bit-fields. + +* GCC comes with shell scripts to fix certain known problems in system + header files. They install corrected copies of various header files in + a special directory where only GCC will normally look for them. The + scripts adapt to various systems by searching all the system header + files for the problem cases that we know about. + + If new system header files are installed, nothing automatically arranges + to update the corrected header files. They can be updated using the + :command:`mkheaders` script installed in + :samp:`{libexecdir}/gcc/{target}/{version}/install-tools/`. + +.. index:: floating point precision + +* On 68000 and x86 systems, for instance, you can get paradoxical results + if you test the precise values of floating point numbers. For example, + you can find that a floating point value which is not a NaN is not equal + to itself. This results from the fact that the floating point registers + hold a few more bits of precision than fit in a ``double`` in memory. + Compiled code moves values between memory and floating point registers + at its convenience, and moving them into memory truncates them. + + .. index:: ffloat-store + + You can partially avoid this problem by using the :option:`-ffloat-store` + option (see :ref:`optimize-options`). + +* On AIX and other platforms without weak symbol support, templates + need to be instantiated explicitly and symbols for static members + of templates will not be generated. + +* On AIX, GCC scans object files and library archives for static + constructors and destructors when linking an application before the + linker prunes unreferenced symbols. This is necessary to prevent the + AIX linker from mistakenly assuming that static constructor or + destructor are unused and removing them before the scanning can occur. + All static constructors and destructors found will be referenced even + though the modules in which they occur may not be used by the program. + This may lead to both increased executable size and unexpected symbol + references. \ No newline at end of file diff --git a/gcc/doc/gcc/known-causes-of-trouble-with-gcc/fixed-header-files.rst b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/fixed-header-files.rst new file mode 100644 index 00000000000..5ec03e1bbeb --- /dev/null +++ b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/fixed-header-files.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _fixed-headers: + +Fixed Header Files +****************** + +GCC needs to install corrected versions of some system header files. +This is because most target systems have some header files that won't +work with GCC unless they are changed. Some have bugs, some are +incompatible with ISO C, and some depend on special features of other +compilers. + +Installing GCC automatically creates and installs the fixed header +files, by running a program called ``fixincludes``. Normally, you +don't need to pay attention to this. But there are cases where it +doesn't do the right thing automatically. + +* If you update the system's header files, such as by installing a new + system version, the fixed header files of GCC are not automatically + updated. They can be updated using the :command:`mkheaders` script + installed in + :samp:`{libexecdir}/gcc/{target}/{version}/install-tools/`. + +* On some systems, header file directories contain + machine-specific symbolic links in certain places. This makes it + possible to share most of the header files among hosts running the + same version of the system on different machine models. + + The programs that fix the header files do not understand this special + way of using symbolic links; therefore, the directory of fixed header + files is good only for the machine model used to build it. + + It is possible to make separate sets of fixed header files for the + different machine models, and arrange a structure of symbolic links so + as to use the proper set, but you'll have to do this by hand. \ No newline at end of file diff --git a/gcc/doc/gcc/known-causes-of-trouble-with-gcc/incompatibilities-of-gcc.rst b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/incompatibilities-of-gcc.rst new file mode 100644 index 00000000000..c78b2c1979f --- /dev/null +++ b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/incompatibilities-of-gcc.rst @@ -0,0 +1,233 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: incompatibilities of GCC, traditional + +.. _incompatibilities: + +Incompatibilities of GCC +************************ + +There are several noteworthy incompatibilities between GNU C and K&R +(non-ISO) versions of C. + +.. index:: string constants, read-only strings, shared strings + +* GCC normally makes string constants read-only. If several + identical-looking string constants are used, GCC stores only one + copy of the string. + + .. index:: mktemp, and constant strings + + One consequence is that you cannot call ``mktemp`` with a string + constant argument. The function ``mktemp`` always alters the + string its argument points to. + + .. index:: sscanf, and constant strings, fscanf, and constant strings, scanf, and constant strings + + Another consequence is that ``sscanf`` does not work on some very + old systems when passed a string constant as its format control string + or input. This is because ``sscanf`` incorrectly tries to write + into the string constant. Likewise ``fscanf`` and ``scanf``. + + The solution to these problems is to change the program to use + ``char`` -array variables with initialization strings for these + purposes instead of string constants. + +* ``-2147483648`` is positive. + + This is because 2147483648 cannot fit in the type ``int``, so + (following the ISO C rules) its data type is ``unsigned long int``. + Negating this value yields 2147483648 again. + +* GCC does not substitute macro arguments when they appear inside of + string constants. For example, the following macro in GCC + + .. code-block:: c++ + + #define foo(a) "a" + + will produce output ``"a"`` regardless of what the argument :samp:`{a}` is. + + .. index:: setjmp incompatibilities, longjmp incompatibilities + +* When you use ``setjmp`` and ``longjmp``, the only automatic + variables guaranteed to remain valid are those declared + ``volatile``. This is a consequence of automatic register + allocation. Consider this function: + + .. code-block:: c++ + + jmp_buf j; + + foo () + { + int a, b; + + a = fun1 (); + if (setjmp (j)) + return a; + + a = fun2 (); + /* longjmp (j) may occur in fun3. */ + return a + fun3 (); + } + + Here ``a`` may or may not be restored to its first value when the + ``longjmp`` occurs. If ``a`` is allocated in a register, then + its first value is restored; otherwise, it keeps the last value stored + in it. + + .. index:: W + + If you use the :option:`-W` option with the :option:`-O` option, you will + get a warning when GCC thinks such a problem might be possible. + +* Programs that use preprocessing directives in the middle of macro + arguments do not work with GCC. For example, a program like this + will not work: + + .. code-block:: c++ + + foobar ( + #define luser + hack) + + ISO C does not permit such a construct. + +* K&R compilers allow comments to cross over an inclusion boundary + (i.e. started in an include file and ended in the including file). + + .. index:: external declaration scope, scope of external declarations, declaration scope + +* Declarations of external variables and functions within a block apply + only to the block containing the declaration. In other words, they + have the same scope as any other declaration in the same place. + + In some other C compilers, an ``extern`` declaration affects all the + rest of the file even if it happens within a block. + +* In traditional C, you can combine ``long``, etc., with a typedef name, + as shown here: + + .. code-block:: c++ + + typedef int foo; + typedef long foo bar; + + In ISO C, this is not allowed: ``long`` and other type modifiers + require an explicit ``int``. + + .. index:: typedef names as function parameters + +* PCC allows typedef names to be used as function parameters. + +* Traditional C allows the following erroneous pair of declarations to + appear together in a given scope: + + .. code-block:: c++ + + typedef int foo; + typedef foo foo; + +* GCC treats all characters of identifiers as significant. According to + K&R-1 (2.2), 'No more than the first eight characters are significant, + although more may be used.'. Also according to K&R-1 (2.2), 'An + identifier is a sequence of letters and digits; the first character must + be a letter. The underscore _ counts as a letter.', but GCC also + allows dollar signs in identifiers. + + .. index:: whitespace + +* PCC allows whitespace in the middle of compound assignment operators + such as :samp:`+=`. GCC, following the ISO standard, does not + allow this. + + .. index:: apostrophes, ' + +* GCC complains about unterminated character constants inside of + preprocessing conditionals that fail. Some programs have English + comments enclosed in conditionals that are guaranteed to fail; if these + comments contain apostrophes, GCC will probably report an error. For + example, this code would produce an error: + + .. code-block:: c++ + + #if 0 + You can't expect this to work. + #endif + + The best solution to such a problem is to put the text into an actual + C comment delimited by :samp:`/*...*/`. + +* Many user programs contain the declaration :samp:`long time ();`. In the + past, the system header files on many systems did not actually declare + ``time``, so it did not matter what type your program declared it to + return. But in systems with ISO C headers, ``time`` is declared to + return ``time_t``, and if that is not the same as ``long``, then + :samp:`long time ();` is erroneous. + + The solution is to change your program to use appropriate system headers + (```` on systems with ISO C headers) and not to declare + ``time`` if the system header files declare it, or failing that to + use ``time_t`` as the return type of ``time``. + + .. index:: float as function value type + +* When compiling functions that return ``float``, PCC converts it to + a double. GCC actually returns a ``float``. If you are concerned + with PCC compatibility, you should declare your functions to return + ``double`` ; you might as well say what you mean. + + .. index:: structures, unions + +* When compiling functions that return structures or unions, GCC + output code normally uses a method different from that used on most + versions of Unix. As a result, code compiled with GCC cannot call + a structure-returning function compiled with PCC, and vice versa. + + The method used by GCC is as follows: a structure or union which is + 1, 2, 4 or 8 bytes long is returned like a scalar. A structure or union + with any other size is stored into an address supplied by the caller + (usually in a special, fixed register, but on some machines it is passed + on the stack). The target hook ``TARGET_STRUCT_VALUE_RTX`` + tells GCC where to pass this address. + + By contrast, PCC on most target machines returns structures and unions + of any size by copying the data into an area of static storage, and then + returning the address of that storage as if it were a pointer value. + The caller must copy the data from that memory area to the place where + the value is wanted. GCC does not use this method because it is + slower and nonreentrant. + + On some newer machines, PCC uses a reentrant convention for all + structure and union returning. GCC on most of these machines uses a + compatible convention when returning structures and unions in memory, + but still returns small structures and unions in registers. + + .. index:: fpcc-struct-return + + You can tell GCC to use a compatible convention for all structure and + union returning with the option :option:`-fpcc-struct-return`. + + .. index:: preprocessing tokens, preprocessing numbers + +* GCC complains about program fragments such as :samp:`0x74ae-0x4000` + which appear to be two hexadecimal constants separated by the minus + operator. Actually, this string is a single :dfn:`preprocessing token`. + Each such token must correspond to one token in C. Since this does not, + GCC prints an error message. Although it may appear obvious that what + is meant is an operator and two values, the ISO C standard specifically + requires that this be treated as erroneous. + + A :dfn:`preprocessing token` is a :dfn:`preprocessing number` if it + begins with a digit and is followed by letters, underscores, digits, + periods and :samp:`e+`, :samp:`e-`, :samp:`E+`, :samp:`E-`, :samp:`p+`, + :samp:`p-`, :samp:`P+`, or :samp:`P-` character sequences. (In strict C90 + mode, the sequences :samp:`p+`, :samp:`p-`, :samp:`P+` and :samp:`P-` cannot + appear in preprocessing numbers.) + + To make the above program fragment valid, place whitespace in front of + the minus sign. This whitespace will end the preprocessing number. \ No newline at end of file diff --git a/gcc/doc/gcc/known-causes-of-trouble-with-gcc/interoperation.rst b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/interoperation.rst new file mode 100644 index 00000000000..01f32d02f65 --- /dev/null +++ b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/interoperation.rst @@ -0,0 +1,153 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _interoperation: + +Interoperation +************** + +This section lists various difficulties encountered in using GCC +together with other compilers or with the assemblers, linkers, +libraries and debuggers on certain systems. + +* On many platforms, GCC supports a different ABI for C++ than do other + compilers, so the object files compiled by GCC cannot be used with object + files generated by another C++ compiler. + + An area where the difference is most apparent is name mangling. The use + of different name mangling is intentional, to protect you from more subtle + problems. + Compilers differ as to many internal details of C++ implementation, + including: how class instances are laid out, how multiple inheritance is + implemented, and how virtual function calls are handled. If the name + encoding were made the same, your programs would link against libraries + provided from other compilers---but the programs would then crash when + run. Incompatible libraries are then detected at link time, rather than + at run time. + +* On some BSD systems, including some versions of Ultrix, use of profiling + causes static variable destructors (currently used only in C++) not to + be run. + +* On a SPARC, GCC aligns all values of type ``double`` on an 8-byte + boundary, and it expects every ``double`` to be so aligned. The Sun + compiler usually gives ``double`` values 8-byte alignment, with one + exception: function arguments of type ``double`` may not be aligned. + + As a result, if a function compiled with Sun CC takes the address of an + argument of type ``double`` and passes this pointer of type + ``double *`` to a function compiled with GCC, dereferencing the + pointer may cause a fatal signal. + + One way to solve this problem is to compile your entire program with GCC. + Another solution is to modify the function that is compiled with + Sun CC to copy the argument into a local variable; local variables + are always properly aligned. A third solution is to modify the function + that uses the pointer to dereference it via the following function + ``access_double`` instead of directly with :samp:`*`: + + .. code-block:: c++ + + inline double + access_double (double *unaligned_ptr) + { + union d2i { double d; int i[2]; }; + + union d2i *p = (union d2i *) unaligned_ptr; + union d2i u; + + u.i[0] = p->i[0]; + u.i[1] = p->i[1]; + + return u.d; + } + + Storing into the pointer can be done likewise with the same union. + +* On Solaris, the ``malloc`` function in the :samp:`libmalloc.a` library + may allocate memory that is only 4 byte aligned. Since GCC on the + SPARC assumes that doubles are 8 byte aligned, this may result in a + fatal signal if doubles are stored in memory allocated by the + :samp:`libmalloc.a` library. + + The solution is to not use the :samp:`libmalloc.a` library. Use instead + ``malloc`` and related functions from :samp:`libc.a`; they do not have + this problem. + +* On the HP PA machine, ADB sometimes fails to work on functions compiled + with GCC. Specifically, it fails to work on functions that use + ``alloca`` or variable-size arrays. This is because GCC doesn't + generate HP-UX unwind descriptors for such functions. It may even be + impossible to generate them. + +* Debugging (:option:`-g`) is not supported on the HP PA machine, unless you use + the preliminary GNU tools. + +* Taking the address of a label may generate errors from the HP-UX + PA assembler. GAS for the PA does not have this problem. + +* Using floating point parameters for indirect calls to static functions + will not work when using the HP assembler. There simply is no way for GCC + to specify what registers hold arguments for static functions when using + the HP assembler. GAS for the PA does not have this problem. + +* In extremely rare cases involving some very large functions you may + receive errors from the HP linker complaining about an out of bounds + unconditional branch offset. This used to occur more often in previous + versions of GCC, but is now exceptionally rare. If you should run + into it, you can work around by making your function smaller. + +* GCC compiled code sometimes emits warnings from the HP-UX assembler of + the form: + + .. code-block:: c++ + + (warning) Use of GR3 when + frame >= 8192 may cause conflict. + + These warnings are harmless and can be safely ignored. + +* In extremely rare cases involving some very large functions you may + receive errors from the AIX Assembler complaining about a displacement + that is too large. If you should run into it, you can work around by + making your function smaller. + +* The :samp:`libstdc++.a` library in GCC relies on the SVR4 dynamic + linker semantics which merges global symbols between libraries and + applications, especially necessary for C++ streams functionality. + This is not the default behavior of AIX shared libraries and dynamic + linking. :samp:`libstdc++.a` is built on AIX with 'runtime-linking' + enabled so that symbol merging can occur. To utilize this feature, + the application linked with :samp:`libstdc++.a` must include the + :option:`-Wl,-brtl` flag on the link line. G++ cannot impose this + because this option may interfere with the semantics of the user + program and users may not always use :samp:`g++` to link his or her + application. Applications are not required to use the + :option:`-Wl,-brtl` flag on the link line---the rest of the + :samp:`libstdc++.a` library which is not dependent on the symbol + merging semantics will continue to function correctly. + +* An application can interpose its own definition of functions for + functions invoked by :samp:`libstdc++.a` with 'runtime-linking' + enabled on AIX. To accomplish this the application must be linked + with 'runtime-linking' option and the functions explicitly must be + exported by the application (:option:`-Wl,-brtl,-bE:exportfile`). + +* AIX on the RS/6000 provides support (NLS) for environments outside of + the United States. Compilers and assemblers use NLS to support + locale-specific representations of various objects including + floating-point numbers (:samp:`.` vs :samp:`,` for separating decimal + fractions). There have been problems reported where the library linked + with GCC does not produce the same floating-point formats that the + assembler accepts. If you have this problem, set the :envvar:`LANG` + environment variable to :samp:`C` or :samp:`En_US`. + +* + .. index:: fdollars-in-identifiers + + Even if you specify :option:`-fdollars-in-identifiers`, + you cannot successfully use :samp:`$` in identifiers on the RS/6000 due + to a restriction in the IBM assembler. GAS supports these + identifiers. \ No newline at end of file diff --git a/gcc/doc/gcc/known-causes-of-trouble-with-gcc/standard-libraries.rst b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/standard-libraries.rst new file mode 100644 index 00000000000..86782a13432 --- /dev/null +++ b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/standard-libraries.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Wall + +.. _standard-libraries: + +Standard Libraries +****************** + +GCC by itself attempts to be a conforming freestanding implementation. +See :ref:`standards`, for details of +what this means. Beyond the library facilities required of such an +implementation, the rest of the C library is supplied by the vendor of +the operating system. If that C library doesn't conform to the C +standards, then your programs might get warnings (especially when using +:option:`-Wall`) that you don't expect. + +For example, the ``sprintf`` function on SunOS 4.1.3 returns +``char *`` while the C standard says that ``sprintf`` returns an +``int``. The ``fixincludes`` program could make the prototype for +this function match the Standard, but that would be wrong, since the +function will still return ``char *``. + +If you need a Standard compliant library, then you need to find one, as +GCC does not provide one. The GNU C library (called ``glibc``) +provides ISO C, POSIX, BSD, SystemV and X/Open compatibility for +GNU/Linux and HURD-based GNU systems; no recent version of it supports +other systems, though some very old versions did. Version 2.2 of the +GNU C library includes nearly complete C99 support. You could also ask +your operating system vendor if newer libraries are available. \ No newline at end of file diff --git a/gcc/doc/gcc/known-causes-of-trouble-with-gcc/warning-messages-and-error-messages.rst b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/warning-messages-and-error-messages.rst new file mode 100644 index 00000000000..83830495730 --- /dev/null +++ b/gcc/doc/gcc/known-causes-of-trouble-with-gcc/warning-messages-and-error-messages.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: error messages, warnings vs errors, messages, warning and error + +.. _warnings-and-errors: + +Warning Messages and Error Messages +*********************************** + +The GNU compiler can produce two kinds of diagnostics: errors and +warnings. Each kind has a different purpose: + +* :dfn:`Errors` report problems that make it impossible to compile your + program. GCC reports errors with the source file name and line + number where the problem is apparent. + +* :dfn:`Warnings` report other unusual conditions in your code that + *may* indicate a problem, although compilation can (and does) + proceed. Warning messages also report the source file name and line + number, but include the text :samp:`warning:` to distinguish them + from error messages. + +Warnings may indicate danger points where you should check to make sure +that your program really does what you intend; or the use of obsolete +features; or the use of nonstandard features of GNU C or C++. Many +warnings are issued only if you ask for them, with one of the :option:`-W` +options (for instance, :option:`-Wall` requests a variety of useful +warnings). + +.. index:: pedantic, pedantic-errors + +GCC always tries to compile your program if possible; it never +gratuitously rejects a program whose meaning is clear merely because +(for instance) it fails to conform to a standard. In some cases, +however, the C and C++ standards specify that certain extensions are +forbidden, and a diagnostic *must* be issued by a conforming +compiler. The :option:`-pedantic` option tells GCC to issue warnings in +such cases; :option:`-pedantic-errors` says to make them errors instead. +This does not mean that *all* non-ISO constructs get warnings +or errors. + +See :ref:`warning-options`, for +more detail on these and related command-line options. \ No newline at end of file diff --git a/gcc/doc/gcc/language-standards-supported-by-gcc.rst b/gcc/doc/gcc/language-standards-supported-by-gcc.rst new file mode 100644 index 00000000000..bf0413175db --- /dev/null +++ b/gcc/doc/gcc/language-standards-supported-by-gcc.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _standards: + +Language Standards Supported by GCC +----------------------------------- + +For each language compiled by GCC for which there is a standard, GCC +attempts to follow one or more versions of that standard, possibly +with some exceptions, and possibly with some extensions. + +.. toctree:: + :maxdepth: 2 + + language-standards-supported-by-gcc/c-language + language-standards-supported-by-gcc/c++-language + language-standards-supported-by-gcc/objective-c-and-objective-c++-languages + language-standards-supported-by-gcc/go-language + language-standards-supported-by-gcc/d-language + language-standards-supported-by-gcc/references-for-other-languages \ No newline at end of file diff --git a/gcc/doc/gcc/language-standards-supported-by-gcc/c++-language.rst b/gcc/doc/gcc/language-standards-supported-by-gcc/c++-language.rst new file mode 100644 index 00000000000..7d9c50a7caf --- /dev/null +++ b/gcc/doc/gcc/language-standards-supported-by-gcc/c++-language.rst @@ -0,0 +1,71 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +C++ Language +************ + +GCC supports the original ISO C++ standard published in 1998, +and the 2011, 2014, 2017 and mostly 2020 revisions. + +The original ISO C++ standard was published as the ISO standard (ISO/IEC +14882:1998) and amended by a Technical Corrigenda published in 2003 +(ISO/IEC 14882:2003). These standards are referred to as C++98 and +C++03, respectively. GCC implements the majority of C++98 (``export`` +is a notable exception) and most of the changes in C++03. To select +this standard in GCC, use one of the options :option:`-ansi`, +:option:`-std=c++98`, or :option:`-std=c++03` ; to obtain all the diagnostics +required by the standard, you should also specify :option:`-pedantic` (or +:option:`-pedantic-errors` if you want them to be errors rather than +warnings). + +A revised ISO C++ standard was published in 2011 as ISO/IEC +14882:2011, and is referred to as C++11; before its publication it was +commonly referred to as C++0x. C++11 contains several changes to the +C++ language, all of which have been implemented in GCC. For details +see https://gcc.gnu.org/projects/cxx-status.html#cxx11. +To select this standard in GCC, use the option :option:`-std=c++11`. + +Another revised ISO C++ standard was published in 2014 as ISO/IEC +14882:2014, and is referred to as C++14; before its publication it was +sometimes referred to as C++1y. C++14 contains several further +changes to the C++ language, all of which have been implemented in GCC. +For details see https://gcc.gnu.org/projects/cxx-status.html#cxx14. +To select this standard in GCC, use the option :option:`-std=c++14`. + +The C++ language was further revised in 2017 and ISO/IEC 14882:2017 was +published. This is referred to as C++17, and before publication was +often referred to as C++1z. GCC supports all the changes in that +specification. For further details see +https://gcc.gnu.org/projects/cxx-status.html#cxx17. Use the option +:option:`-std=c++17` to select this variant of C++. + +Another revised ISO C++ standard was published in 2020 as ISO/IEC +14882:2020, and is referred to as C++20; before its publication it was +sometimes referred to as C++2a. GCC supports most of the changes in the +new specification. For further details see +https://gcc.gnu.org/projects/cxx-status.html#cxx20. +To select this standard in GCC, use the option :option:`-std=c++20`. + +More information about the C++ standards is available on the ISO C++ +committee's web site at http://www.open-std.org/jtc1/sc22/wg21/. + +To obtain all the diagnostics required by any of the standard versions +described above you should specify :option:`-pedantic` +or :option:`-pedantic-errors`, otherwise GCC will allow some non-ISO C++ +features as extensions. See :ref:`warning-options`. + +By default, GCC also provides some additional extensions to the C++ language +that on rare occasions conflict with the C++ standard. See :ref:`c++-dialect-options`. Use of the +:option:`-std` options listed above disables these extensions where they +they conflict with the C++ standard version selected. You may also +select an extended version of the C++ language explicitly with +:option:`-std=gnu++98` (for C++98 with GNU extensions), or +:option:`-std=gnu++11` (for C++11 with GNU extensions), or +:option:`-std=gnu++14` (for C++14 with GNU extensions), or +:option:`-std=gnu++17` (for C++17 with GNU extensions), or +:option:`-std=gnu++20` (for C++20 with GNU extensions). + +The default, if +no C++ language dialect options are given, is :option:`-std=gnu++17`. \ No newline at end of file diff --git a/gcc/doc/gcc/language-standards-supported-by-gcc/c-language.rst b/gcc/doc/gcc/language-standards-supported-by-gcc/c-language.rst new file mode 100644 index 00000000000..b6bdc37b01e --- /dev/null +++ b/gcc/doc/gcc/language-standards-supported-by-gcc/c-language.rst @@ -0,0 +1,139 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: C standard, C standards, ANSI C standard, ANSI C, ANSI C89, C89, ANSI X3.159-1989, X3.159-1989, ISO C standard, ISO C, ISO C90, ISO/IEC 9899, ISO 9899, C90, ISO C94, C94, ISO C95, C95, ISO C99, C99, ISO C9X, C9X, ISO C11, C11, ISO C1X, C1X, ISO C17, C17, ISO C2X, C2X, Technical Corrigenda, TC1, Technical Corrigendum 1, TC2, Technical Corrigendum 2, TC3, Technical Corrigendum 3, AMD1, freestanding implementation, freestanding environment, hosted implementation, hosted environment, __STDC_HOSTED__, std, ansi, pedantic, pedantic-errors + +C Language +********** + +The original ANSI C standard (X3.159-1989) was ratified in 1989 and +published in 1990. This standard was ratified as an ISO standard +(ISO/IEC 9899:1990) later in 1990. There were no technical +differences between these publications, although the sections of the +ANSI standard were renumbered and became clauses in the ISO standard. +The ANSI +standard, but not the ISO standard, also came with a Rationale +document. +This standard, in both its forms, is commonly known as :dfn:`C89`, or +occasionally as :dfn:`C90`, from the dates of ratification. +To select this standard in GCC, use one of the options +:option:`-ansi`, :option:`-std=c90` or :option:`-std=iso9899:1990` ; to obtain +all the diagnostics required by the standard, you should also specify +:option:`-pedantic` (or :option:`-pedantic-errors` if you want them to be +errors rather than warnings). See :ref:`c-dialect-options`. + +Errors in the 1990 ISO C standard were corrected in two Technical +Corrigenda published in 1994 and 1996. GCC does not support the +uncorrected version. + +An amendment to the 1990 standard was published in 1995. This +amendment added digraphs and ``__STDC_VERSION__`` to the language, +but otherwise concerned the library. This amendment is commonly known +as :dfn:`AMD1`; the amended standard is sometimes known as :dfn:`C94` or +:dfn:`C95`. To select this standard in GCC, use the option +:option:`-std=iso9899:199409` (with, as for other standard versions, +:option:`-pedantic` to receive all required diagnostics). + +A new edition of the ISO C standard was published in 1999 as ISO/IEC +9899:1999, and is commonly known as :dfn:`C99`. (While in +development, drafts of this standard version were referred to as +:dfn:`C9X`.) GCC has substantially +complete support for this standard version; see +https://gcc.gnu.org/c99status.html for details. To select this +standard, use :option:`-std=c99` or :option:`-std=iso9899:1999`. + +Errors in the 1999 ISO C standard were corrected in three Technical +Corrigenda published in 2001, 2004 and 2007. GCC does not support the +uncorrected version. + +A fourth version of the C standard, known as :dfn:`C11`, was published +in 2011 as ISO/IEC 9899:2011. (While in development, drafts of this +standard version were referred to as :dfn:`C1X`.) +GCC has substantially complete support +for this standard, enabled with :option:`-std=c11` or +:option:`-std=iso9899:2011`. A version with corrections integrated was +prepared in 2017 and published in 2018 as ISO/IEC 9899:2018; it is +known as :dfn:`C17` and is supported with :option:`-std=c17` or +:option:`-std=iso9899:2017` ; the corrections are also applied with +:option:`-std=c11`, and the only difference between the options is the +value of ``__STDC_VERSION__``. + +A further version of the C standard, known as :dfn:`C2X`, is under +development; experimental and incomplete support for this is enabled +with :option:`-std=c2x`. + +By default, GCC provides some extensions to the C language that, on +rare occasions conflict with the C standard. See :ref:`c-extensions`. +Some features that are part of the C99 standard +are accepted as extensions in C90 mode, and some features that are part +of the C11 standard are accepted as extensions in C90 and C99 modes. +Use of the +:option:`-std` options listed above disables these extensions where +they conflict with the C standard version selected. You may also +select an extended version of the C language explicitly with +:option:`-std=gnu90` (for C90 with GNU extensions), :option:`-std=gnu99` +(for C99 with GNU extensions) or :option:`-std=gnu11` (for C11 with GNU +extensions). + +The default, if no C language dialect options are given, +is :option:`-std=gnu17`. + +The ISO C standard defines (in clause 4) two classes of conforming +implementation. A :dfn:`conforming hosted implementation` supports the +whole standard including all the library facilities; a :dfn:`conforming +freestanding implementation` is only required to provide certain +library facilities: those in ````, ````, +````, and ```` ; since AMD1, also those in +```` ; since C99, also those in ```` and +```` ; and since C11, also those in ```` +and ````. In addition, complex types, added in C99, are not +required for freestanding implementations. + +The standard also defines two environments for programs, a +:dfn:`freestanding environment`, required of all implementations and +which may not have library facilities beyond those required of +freestanding implementations, where the handling of program startup +and termination are implementation-defined; and a :dfn:`hosted +environment`, which is not required, in which all the library +facilities are provided and startup is through a function ``int +main (void)`` or ``int main (int, char *[])``. An OS kernel is an example +of a program running in a freestanding environment; +a program using the facilities of an +operating system is an example of a program running in a hosted environment. + +.. index:: ffreestanding + +GCC aims towards being usable as a conforming freestanding +implementation, or as the compiler for a conforming hosted +implementation. By default, it acts as the compiler for a hosted +implementation, defining ``__STDC_HOSTED__`` as ``1`` and +presuming that when the names of ISO C functions are used, they have +the semantics defined in the standard. To make it act as a conforming +freestanding implementation for a freestanding environment, use the +option :option:`-ffreestanding` ; it then defines +``__STDC_HOSTED__`` to ``0`` and does not make assumptions about the +meanings of function names from the standard library, with exceptions +noted below. To build an OS kernel, you may well still need to make +your own arrangements for linking and startup. +See :ref:`c-dialect-options`. + +GCC does not provide the library facilities required only of hosted +implementations, nor yet all the facilities required by C99 of +freestanding implementations on all platforms. +To use the facilities of a hosted +environment, you need to find them elsewhere (for example, in the +GNU C library). See :ref:`standard-libraries`. + +Most of the compiler support routines used by GCC are present in +:samp:`libgcc`, but there are a few exceptions. GCC requires the +freestanding environment provide ``memcpy``, ``memmove``, +``memset`` and ``memcmp``. +Finally, if ``__builtin_trap`` is used, and the target does +not implement the ``trap`` pattern, then GCC emits a call +to ``abort``. + +For references to Technical Corrigenda, Rationale documents and +information concerning the history of C that is available online, see +https://gcc.gnu.org/readings.html \ No newline at end of file diff --git a/gcc/doc/gcc/language-standards-supported-by-gcc/d-language.rst b/gcc/doc/gcc/language-standards-supported-by-gcc/d-language.rst new file mode 100644 index 00000000000..bc23da90beb --- /dev/null +++ b/gcc/doc/gcc/language-standards-supported-by-gcc/d-language.rst @@ -0,0 +1,11 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +D language +********** + +GCC supports the D 2.0 programming language. The D language itself is +currently defined by its reference implementation and supporting language +specification, described at https://dlang.org/spec/spec.html. \ No newline at end of file diff --git a/gcc/doc/gcc/language-standards-supported-by-gcc/go-language.rst b/gcc/doc/gcc/language-standards-supported-by-gcc/go-language.rst new file mode 100644 index 00000000000..d74d36fab19 --- /dev/null +++ b/gcc/doc/gcc/language-standards-supported-by-gcc/go-language.rst @@ -0,0 +1,10 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Go Language +*********** + +As of the GCC 4.7.1 release, GCC supports the Go 1 language standard, +described at https://golang.org/doc/go1. \ No newline at end of file diff --git a/gcc/doc/gcc/language-standards-supported-by-gcc/objective-c-and-objective-c++-languages.rst b/gcc/doc/gcc/language-standards-supported-by-gcc/objective-c-and-objective-c++-languages.rst new file mode 100644 index 00000000000..535080e64f2 --- /dev/null +++ b/gcc/doc/gcc/language-standards-supported-by-gcc/objective-c-and-objective-c++-languages.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Objective-C, Objective-C++ + +Objective-C and Objective-C++ Languages +*************************************** + +GCC supports 'traditional' Objective-C (also known as 'Objective-C +1.0') and contains support for the Objective-C exception and +synchronization syntax. It has also support for a number of +'Objective-C 2.0' language extensions, including properties, fast +enumeration (only for Objective-C), method attributes and the +@optional and @required keywords in protocols. GCC supports +Objective-C++ and features available in Objective-C are also available +in Objective-C++. + +GCC by default uses the GNU Objective-C runtime library, which is part +of GCC and is not the same as the Apple/NeXT Objective-C runtime +library used on Apple systems. There are a number of differences +documented in this manual. The options :option:`-fgnu-runtime` and +:option:`-fnext-runtime` allow you to switch between producing output +that works with the GNU Objective-C runtime library and output that +works with the Apple/NeXT Objective-C runtime library. + +There is no formal written standard for Objective-C or Objective-C++. +The authoritative manual on traditional Objective-C (1.0) is +'Object-Oriented Programming and the Objective-C Language': +http://www.gnustep.org/resources/documentation/ObjectivCBook.pdf +is the original NeXTstep document. + +The Objective-C exception and synchronization syntax (that is, the +keywords ``@try``, ``@throw``, ``@catch``, +``@finally`` and ``@synchronized``) is +supported by GCC and is enabled with the option +:option:`-fobjc-exceptions`. The syntax is briefly documented in this +manual and in the Objective-C 2.0 manuals from Apple. + +The Objective-C 2.0 language extensions and features are automatically +enabled; they include properties (via the ``@property``, +``@synthesize`` and +``@dynamic keywords``), fast enumeration (not available in +Objective-C++), attributes for methods (such as :fn-attr:`deprecated`, +:fn-attr:`noreturn`, :fn-attr:`sentinel`, ``format``), +the :fn-attr:`unused` attribute for method arguments, the +``@package`` keyword for instance variables and the ``@optional`` and +``@required`` keywords in protocols. You can disable all these +Objective-C 2.0 language extensions with the option +:option:`-fobjc-std=objc1`, which causes the compiler to recognize the +same Objective-C language syntax recognized by GCC 4.0, and to produce +an error if one of the new features is used. + +GCC has currently no support for non-fragile instance variables. + +The authoritative manual on Objective-C 2.0 is available from Apple: + +* https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html + +For more information concerning the history of Objective-C that is +available online, see https://gcc.gnu.org/readings.html \ No newline at end of file diff --git a/gcc/doc/gcc/language-standards-supported-by-gcc/references-for-other-languages.rst b/gcc/doc/gcc/language-standards-supported-by-gcc/references-for-other-languages.rst new file mode 100644 index 00000000000..001116ac260 --- /dev/null +++ b/gcc/doc/gcc/language-standards-supported-by-gcc/references-for-other-languages.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +References for Other Languages +****************************** + +See :ref:`gnat_rm:top`, for information on standard +conformance and compatibility of the Ada compiler. + +See :ref:`gfortran:standards`, for details +of standards supported by GNU Fortran. \ No newline at end of file diff --git a/gcc/doc/gcc/lto-dump.rst b/gcc/doc/gcc/lto-dump.rst new file mode 100644 index 00000000000..b1ca4a3707a --- /dev/null +++ b/gcc/doc/gcc/lto-dump.rst @@ -0,0 +1,117 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. program:: lto-dump + +.. _lto-dump: + +lto-dump---Tool for dumping LTO object files. +--------------------------------------------- + +.. only:: man + + Synopsis + ^^^^^^^^ + + lto-dump + [ :option:`-list` ] + [ :option:`-demangle` ] + [ :option:`-defined-only` ] + [ :option:`-print-value` ] + [ :option:`-name-sort` ] + [ :option:`-size-sort` ] + [ :option:`-reverse-sort` ] + [ :option:`-no-sort` ] + [ :option:`-symbol=` ] + [ :option:`-objects` ] + [ :option:`-type-stats` ] + [ :option:`-tree-stats` ] + [ :option:`-gimple-stats` ] + [ :option:`-dump-level=` ] + [ :option:`-dump-body=` ] + [ :option:`-help` ] :samp:`{lto-dump}` + +.. only:: not man + + .. code-block:: + + Usage: lto-dump [OPTION] ... objfiles + +Description +^^^^^^^^^^^ + +:command:`lto-dump` is a tool you can use in conjunction with GCC to +dump link time optimization object files. + +Options +^^^^^^^ + +.. option:: -list + + Dumps list of details of functions and variables. + +.. option:: -demangle + + Dump the demangled output. + +.. option:: -defined-only + + Dump only the defined symbols. + +.. option:: -print-value + + Dump initial values of the variables. + +.. option:: -name-sort + + Sort the symbols alphabetically. + +.. option:: -size-sort + + Sort the symbols according to size. + +.. option:: -reverse-sort + + Dump the symbols in reverse order. + +.. option:: -no-sort + + Dump the symbols in order of occurrence. + +.. option:: -symbol= + + Dump the details of specific symbol. + +.. option:: -objects + + Dump the details of LTO objects. + +.. option:: -type-stats + + Dump the statistics of tree types. + +.. option:: -tree-stats + + Dump the statistics of trees. + +.. option:: -gimple-stats + + Dump the statistics of gimple statements. + +.. option:: -dump-level= + + For deciding the optimization level of body. + +.. option:: -dump-body= + + Dump the specific gimple body. + +.. option:: -help + + Display the dump tool help. + +.. only:: man + + .. include:: copyright.rst \ No newline at end of file diff --git a/gcc/doc/gcc/programming-languages-supported-by-gcc.rst b/gcc/doc/gcc/programming-languages-supported-by-gcc.rst new file mode 100644 index 00000000000..0d4ce6f86f2 --- /dev/null +++ b/gcc/doc/gcc/programming-languages-supported-by-gcc.rst @@ -0,0 +1,54 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GCC, GNU Compiler Collection, GNU C Compiler, Ada, D, Fortran, Go, Objective-C, Objective-C++ + +.. _g++-and-gcc: + +Programming Languages Supported by GCC +-------------------------------------- + +GCC stands for 'GNU Compiler Collection'. GCC is an integrated +distribution of compilers for several major programming languages. These +languages currently include C, C++, Objective-C, Objective-C++, +Fortran, Ada, D, and Go. + +The abbreviation :dfn:`GCC` has multiple meanings in common use. The +current official meaning is 'GNU Compiler Collection', which refers +generically to the complete suite of tools. The name historically stood +for 'GNU C Compiler', and this usage is still common when the emphasis +is on compiling C programs. Finally, the name is also used when speaking +of the :dfn:`language-independent` component of GCC: code shared among the +compilers for all supported languages. + +The language-independent component of GCC includes the majority of the +optimizers, as well as the 'back ends' that generate machine code for +various processors. + +.. index:: COBOL, Mercury + +The part of a compiler that is specific to a particular language is +called the 'front end'. In addition to the front ends that are +integrated components of GCC, there are several other front ends that +are maintained separately. These support languages such as +Mercury, and COBOL. To use these, they must be built together with +GCC proper. + +.. index:: C++, G++, Ada, GNAT + +Most of the compilers for languages other than C have their own names. +The C++ compiler is G++, the Ada compiler is GNAT, and so on. When we +talk about compiling one of those languages, we might refer to that +compiler by its own name, or as GCC. Either is correct. + +.. index:: compiler compared to C++ preprocessor, intermediate C version, nonexistent, C intermediate output, nonexistent + +Historically, compilers for many languages, including C++ and Fortran, +have been implemented as 'preprocessors' which emit another high +level language such as C. None of the compilers included in GCC are +implemented this way; they all generate machine code directly. This +sort of preprocessor should not be confused with the :dfn:`C +preprocessor`, which is an integral feature of the C, C++, Objective-C +and Objective-C++ languages. \ No newline at end of file diff --git a/gcc/doc/gcc/reporting-bugs.rst b/gcc/doc/gcc/reporting-bugs.rst new file mode 100644 index 00000000000..ab3e067bcb2 --- /dev/null +++ b/gcc/doc/gcc/reporting-bugs.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: bugs, reporting bugs + +.. _bugs: + +Reporting Bugs +-------------- + +Your bug reports play an essential role in making GCC reliable. + +When you encounter a problem, the first thing to do is to see if it is +already known. See :ref:`trouble`. If it isn't known, then you should +report the problem. + +.. toctree:: + :maxdepth: 2 + + have-you-found-a-bug + how-and-where-to-report-bugs \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples.rst b/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples.rst new file mode 100644 index 00000000000..6fdfd54cfd2 --- /dev/null +++ b/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Tree SSA, Optimization infrastructure for GIMPLE + +.. _tree-ssa: + +Analysis and Optimization of GIMPLE tuples +------------------------------------------ + +GCC uses three main intermediate languages to represent the program +during compilation: GENERIC, GIMPLE and RTL. GENERIC is a +language-independent representation generated by each front end. It +is used to serve as an interface between the parser and optimizer. +GENERIC is a common representation that is able to represent programs +written in all the languages supported by GCC. + +GIMPLE and RTL are used to optimize the program. GIMPLE is used for +target and language independent optimizations (e.g., inlining, +constant propagation, tail call elimination, redundancy elimination, +etc). Much like GENERIC, GIMPLE is a language independent, tree based +representation. However, it differs from GENERIC in that the GIMPLE +grammar is more restrictive: expressions contain no more than 3 +operands (except function calls), it has no control flow structures +and expressions with side effects are only allowed on the right hand +side of assignments. See the chapter describing GENERIC and GIMPLE +for more details. + +This chapter describes the data structures and functions used in the +GIMPLE optimizers (also known as 'tree optimizers' or 'middle +end'). In particular, it focuses on all the macros, data structures, +functions and programming constructs needed to implement optimization +passes for GIMPLE. + +.. toctree:: + :maxdepth: 2 + + analysis-and-optimization-of-gimple-tuples/annotations + analysis-and-optimization-of-gimple-tuples/ssa-operands + analysis-and-optimization-of-gimple-tuples/alias-analysis + analysis-and-optimization-of-gimple-tuples/memory-model + analysis-and-optimization-of-gimple-tuples/static-single-assignment \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/alias-analysis.rst b/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/alias-analysis.rst new file mode 100644 index 00000000000..4e73721e5b8 --- /dev/null +++ b/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/alias-analysis.rst @@ -0,0 +1,104 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: alias, flow-sensitive alias analysis, flow-insensitive alias analysis + +.. _alias-analysis: + +Alias analysis +************** + +Alias analysis in GIMPLE SSA form consists of two pieces. First +the virtual SSA web ties conflicting memory accesses and provides +a SSA use-def chain and SSA immediate-use chains for walking +possibly dependent memory accesses. Second an alias-oracle can +be queried to disambiguate explicit and implicit memory references. + +* Memory SSA form. + + All statements that may use memory have exactly one accompanied use of + a virtual SSA name that represents the state of memory at the + given point in the IL. + + All statements that may define memory have exactly one accompanied + definition of a virtual SSA name using the previous state of memory + and defining the new state of memory after the given point in the IL. + + .. code-block:: c++ + + int i; + int foo (void) + { + # .MEM_3 = VDEF <.MEM_2(D)> + i = 1; + # VUSE <.MEM_3> + return i; + } + + The virtual SSA names in this case are ``.MEM_2(D)`` and + ``.MEM_3``. The store to the global variable ``i`` + defines ``.MEM_3`` invalidating ``.MEM_2(D)``. The + load from ``i`` uses that new state ``.MEM_3``. + + The virtual SSA web serves as constraints to SSA optimizers + preventing illegitimate code-motion and optimization. It + also provides a way to walk related memory statements. + +* Points-to and escape analysis. + + Points-to analysis builds a set of constraints from the GIMPLE + SSA IL representing all pointer operations and facts we do + or do not know about pointers. Solving this set of constraints + yields a conservatively correct solution for each pointer + variable in the program (though we are only interested in + SSA name pointers) as to what it may possibly point to. + + This points-to solution for a given SSA name pointer is stored + in the ``pt_solution`` sub-structure of the + ``SSA_NAME_PTR_INFO`` record. The following accessor + functions are available: + + * ``pt_solution_includes`` + + * ``pt_solutions_intersect`` + + Points-to analysis also computes the solution for two special + set of pointers, ``ESCAPED`` and ``CALLUSED``. Those + represent all memory that has escaped the scope of analysis + or that is used by pure or nested const calls. + +* Type-based alias analysis + + Type-based alias analysis is frontend dependent though generic + support is provided by the middle-end in ``alias.cc``. TBAA + code is used by both tree optimizers and RTL optimizers. + + Every language that wishes to perform language-specific alias analysis + should define a function that computes, given a ``tree`` + node, an alias set for the node. Nodes in different alias sets are not + allowed to alias. For an example, see the C front-end function + ``c_get_alias_set``. + +* Tree alias-oracle + + The tree alias-oracle provides means to disambiguate two memory + references and memory references against statements. The following + queries are available: + + * ``refs_may_alias_p`` + + * ``ref_maybe_used_by_stmt_p`` + + * ``stmt_may_clobber_ref_p`` + + In addition to those two kind of statement walkers are available + walking statements related to a reference ref. + ``walk_non_aliased_vuses`` walks over dominating memory defining + statements and calls back if the statement does not clobber ref + providing the non-aliased VUSE. The walk stops at + the first clobbering statement or if asked to. + ``walk_aliased_vdefs`` walks over dominating memory defining + statements and calls back on each statement clobbering ref + providing its aliasing VDEF. The walk stops if asked to. \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/annotations.rst b/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/annotations.rst new file mode 100644 index 00000000000..a8e0374eb0a --- /dev/null +++ b/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/annotations.rst @@ -0,0 +1,17 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: annotations + +.. _annotations: + +Annotations +*********** + +The optimizers need to associate attributes with variables during the +optimization process. For instance, we need to know whether a +variable has aliases. All these attributes are stored in data +structures called annotations which are then linked to the field +``ann`` in ``struct tree_common``. \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/memory-model.rst b/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/memory-model.rst new file mode 100644 index 00000000000..11a68f5f722 --- /dev/null +++ b/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/memory-model.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: memory model + +.. _memory-model: + +Memory model +************ + +The memory model used by the middle-end models that of the C/C++ +languages. The middle-end has the notion of an effective type +of a memory region which is used for type-based alias analysis. + +The following is a refinement of ISO C99 6.5/6, clarifying the block copy case +to follow common sense and extending the concept of a dynamic effective +type to objects with a declared type as required for C++. + +:: + + The effective type of an object for an access to its stored value is + the declared type of the object or the effective type determined by + a previous store to it. If a value is stored into an object through + an lvalue having a type that is not a character type, then the + type of the lvalue becomes the effective type of the object for that + access and for subsequent accesses that do not modify the stored value. + If a value is copied into an object using memcpy or memmove, + or is copied as an array of character type, then the effective type + of the modified object for that access and for subsequent accesses that + do not modify the value is undetermined. For all other accesses to an + object, the effective type of the object is simply the type of the + lvalue used for the access. \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/ssa-operands.rst b/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/ssa-operands.rst new file mode 100644 index 00000000000..e36bf94953e --- /dev/null +++ b/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/ssa-operands.rst @@ -0,0 +1,388 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: operands, virtual operands, real operands, update_stmt + +.. _ssa-operands: + +SSA Operands +************ + +Almost every GIMPLE statement will contain a reference to a variable +or memory location. Since statements come in different shapes and +sizes, their operands are going to be located at various spots inside +the statement's tree. To facilitate access to the statement's +operands, they are organized into lists associated inside each +statement's annotation. Each element in an operand list is a pointer +to a ``VAR_DECL``, ``PARM_DECL`` or ``SSA_NAME`` tree node. +This provides a very convenient way of examining and replacing +operands. + +Data flow analysis and optimization is done on all tree nodes +representing variables. Any node for which ``SSA_VAR_P`` returns +nonzero is considered when scanning statement operands. However, not +all ``SSA_VAR_P`` variables are processed in the same way. For the +purposes of optimization, we need to distinguish between references to +local scalar variables and references to globals, statics, structures, +arrays, aliased variables, etc. The reason is simple, the compiler +can gather complete data flow information for a local scalar. On the +other hand, a global variable may be modified by a function call, it +may not be possible to keep track of all the elements of an array or +the fields of a structure, etc. + +The operand scanner gathers two kinds of operands: :dfn:`real` and +:dfn:`virtual`. An operand for which ``is_gimple_reg`` returns true +is considered real, otherwise it is a virtual operand. We also +distinguish between uses and definitions. An operand is used if its +value is loaded by the statement (e.g., the operand at the RHS of an +assignment). If the statement assigns a new value to the operand, the +operand is considered a definition (e.g., the operand at the LHS of +an assignment). + +Virtual and real operands also have very different data flow +properties. Real operands are unambiguous references to the +full object that they represent. For instance, given + +.. code-block:: c++ + + { + int a, b; + a = b + } + +Since ``a`` and ``b`` are non-aliased locals, the statement +``a = b`` will have one real definition and one real use because +variable ``a`` is completely modified with the contents of +variable ``b``. Real definition are also known as :dfn:`killing +definitions`. Similarly, the use of ``b`` reads all its bits. + +In contrast, virtual operands are used with variables that can have +a partial or ambiguous reference. This includes structures, arrays, +globals, and aliased variables. In these cases, we have two types of +definitions. For globals, structures, and arrays, we can determine from +a statement whether a variable of these types has a killing definition. +If the variable does, then the statement is marked as having a +:dfn:`must definition` of that variable. However, if a statement is only +defining a part of the variable (i.e. a field in a structure), or if we +know that a statement might define the variable but we cannot say for sure, +then we mark that statement as having a :dfn:`may definition`. For +instance, given + +.. code-block:: c++ + + { + int a, b, *p; + + if (...) + p = &a; + else + p = &b; + *p = 5; + return *p; + } + +The assignment ``*p = 5`` may be a definition of ``a`` or +``b``. If we cannot determine statically where ``p`` is +pointing to at the time of the store operation, we create virtual +definitions to mark that statement as a potential definition site for +``a`` and ``b``. Memory loads are similarly marked with virtual +use operands. Virtual operands are shown in tree dumps right before +the statement that contains them. To request a tree dump with virtual +operands, use the :option:`-vops` option to :option:`-fdump-tree` : + +.. code-block:: c++ + + { + int a, b, *p; + + if (...) + p = &a; + else + p = &b; + # a = VDEF + # b = VDEF + *p = 5; + + # VUSE + # VUSE + return *p; + } + +Notice that ``VDEF`` operands have two copies of the referenced +variable. This indicates that this is not a killing definition of +that variable. In this case we refer to it as a :dfn:`may definition` +or :dfn:`aliased store`. The presence of the second copy of the +variable in the ``VDEF`` operand will become important when the +function is converted into SSA form. This will be used to link all +the non-killing definitions to prevent optimizations from making +incorrect assumptions about them. + +Operands are updated as soon as the statement is finished via a call +to ``update_stmt``. If statement elements are changed via +``SET_USE`` or ``SET_DEF``, then no further action is required +(i.e., those macros take care of updating the statement). If changes +are made by manipulating the statement's tree directly, then a call +must be made to ``update_stmt`` when complete. Calling one of the +``bsi_insert`` routines or ``bsi_replace`` performs an implicit +call to ``update_stmt``. + +.. index:: Operand Iterators, Operand Access Routines + +Operand Iterators And Access Routines +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Operands are collected by :samp:`tree-ssa-operands.cc`. They are stored +inside each statement's annotation and can be accessed through either the +operand iterators or an access routine. + +The following access routines are available for examining operands: + +* ``SINGLE_SSA_{USE,DEF,TREE}_OPERAND`` : These accessors will return + NULL unless there is exactly one operand matching the specified flags. If + there is exactly one operand, the operand is returned as either a ``tree``, + ``def_operand_p``, or ``use_operand_p``. + + .. code-block:: c++ + + tree t = SINGLE_SSA_TREE_OPERAND (stmt, flags); + use_operand_p u = SINGLE_SSA_USE_OPERAND (stmt, SSA_ALL_VIRTUAL_USES); + def_operand_p d = SINGLE_SSA_DEF_OPERAND (stmt, SSA_OP_ALL_DEFS); + +* ``ZERO_SSA_OPERANDS`` : This macro returns true if there are no + operands matching the specified flags. + + .. code-block:: c++ + + if (ZERO_SSA_OPERANDS (stmt, SSA_OP_ALL_VIRTUALS)) + return; + +* ``NUM_SSA_OPERANDS`` : This macro Returns the number of operands + matching 'flags'. This actually executes a loop to perform the count, so + only use this if it is really needed. + + .. code-block:: c++ + + int count = NUM_SSA_OPERANDS (stmt, flags) + +If you wish to iterate over some or all operands, use the +``FOR_EACH_SSA_{USE,DEF,TREE}_OPERAND`` iterator. For example, to print +all the operands for a statement: + +.. code-block:: c++ + + void + print_ops (tree stmt) + { + ssa_op_iter; + tree var; + + FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_ALL_OPERANDS) + print_generic_expr (stderr, var, TDF_SLIM); + } + +How to choose the appropriate iterator: + +* Determine whether you are need to see the operand pointers, or just the + trees, and choose the appropriate macro: + + .. code-block:: c++ + + Need Macro: + ---- ------- + use_operand_p FOR_EACH_SSA_USE_OPERAND + def_operand_p FOR_EACH_SSA_DEF_OPERAND + tree FOR_EACH_SSA_TREE_OPERAND + +* You need to declare a variable of the type you are interested + in, and an ssa_op_iter structure which serves as the loop controlling + variable. + +* Determine which operands you wish to use, and specify the flags of + those you are interested in. They are documented in + :samp:`tree-ssa-operands.h`: + + .. code-block:: c++ + + #define SSA_OP_USE 0x01 /* Real USE operands. */ + #define SSA_OP_DEF 0x02 /* Real DEF operands. */ + #define SSA_OP_VUSE 0x04 /* VUSE operands. */ + #define SSA_OP_VDEF 0x08 /* VDEF operands. */ + + /* These are commonly grouped operand flags. */ + #define SSA_OP_VIRTUAL_USES (SSA_OP_VUSE) + #define SSA_OP_VIRTUAL_DEFS (SSA_OP_VDEF) + #define SSA_OP_ALL_VIRTUALS (SSA_OP_VIRTUAL_USES | SSA_OP_VIRTUAL_DEFS) + #define SSA_OP_ALL_USES (SSA_OP_VIRTUAL_USES | SSA_OP_USE) + #define SSA_OP_ALL_DEFS (SSA_OP_VIRTUAL_DEFS | SSA_OP_DEF) + #define SSA_OP_ALL_OPERANDS (SSA_OP_ALL_USES | SSA_OP_ALL_DEFS) + +So if you want to look at the use pointers for all the ``USE`` and +``VUSE`` operands, you would do something like: + +.. code-block:: c++ + + use_operand_p use_p; + ssa_op_iter iter; + + FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, (SSA_OP_USE | SSA_OP_VUSE)) + { + process_use_ptr (use_p); + } + +The ``TREE`` macro is basically the same as the ``USE`` and +``DEF`` macros, only with the use or def dereferenced via +``USE_FROM_PTR (use_p)`` and ``DEF_FROM_PTR (def_p)``. Since we +aren't using operand pointers, use and defs flags can be mixed. + +.. code-block:: c++ + + tree var; + ssa_op_iter iter; + + FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_VUSE) + { + print_generic_expr (stderr, var, TDF_SLIM); + } + +``VDEF`` s are broken into two flags, one for the +``DEF`` portion (``SSA_OP_VDEF``) and one for the USE portion +(``SSA_OP_VUSE``). + +There are many examples in the code, in addition to the documentation +in :samp:`tree-ssa-operands.h` and :samp:`ssa-iterators.h`. + +There are also a couple of variants on the stmt iterators regarding PHI +nodes. + +``FOR_EACH_PHI_ARG`` Works exactly like +``FOR_EACH_SSA_USE_OPERAND``, except it works over ``PHI`` arguments +instead of statement operands. + +.. code-block:: c++ + + /* Look at every virtual PHI use. */ + FOR_EACH_PHI_ARG (use_p, phi_stmt, iter, SSA_OP_VIRTUAL_USES) + { + my_code; + } + + /* Look at every real PHI use. */ + FOR_EACH_PHI_ARG (use_p, phi_stmt, iter, SSA_OP_USES) + my_code; + + /* Look at every PHI use. */ + FOR_EACH_PHI_ARG (use_p, phi_stmt, iter, SSA_OP_ALL_USES) + my_code; + +``FOR_EACH_PHI_OR_STMT_{USE,DEF}`` works exactly like +``FOR_EACH_SSA_{USE,DEF}_OPERAND``, except it will function on +either a statement or a ``PHI`` node. These should be used when it is +appropriate but they are not quite as efficient as the individual +``FOR_EACH_PHI`` and ``FOR_EACH_SSA`` routines. + +.. code-block:: c++ + + FOR_EACH_PHI_OR_STMT_USE (use_operand_p, stmt, iter, flags) + { + my_code; + } + + FOR_EACH_PHI_OR_STMT_DEF (def_operand_p, phi, iter, flags) + { + my_code; + } + +.. index:: Immediate Uses + +Immediate Uses +^^^^^^^^^^^^^^ + +Immediate use information is now always available. Using the immediate use +iterators, you may examine every use of any ``SSA_NAME``. For instance, +to change each use of ``ssa_var`` to ``ssa_var2`` and call fold_stmt on +each stmt after that is done: + +.. code-block:: c++ + + use_operand_p imm_use_p; + imm_use_iterator iterator; + tree ssa_var, stmt; + + FOR_EACH_IMM_USE_STMT (stmt, iterator, ssa_var) + { + FOR_EACH_IMM_USE_ON_STMT (imm_use_p, iterator) + SET_USE (imm_use_p, ssa_var_2); + fold_stmt (stmt); + } + +There are 2 iterators which can be used. ``FOR_EACH_IMM_USE_FAST`` is +used when the immediate uses are not changed, i.e., you are looking at the +uses, but not setting them. + +If they do get changed, then care must be taken that things are not changed +under the iterators, so use the ``FOR_EACH_IMM_USE_STMT`` and +``FOR_EACH_IMM_USE_ON_STMT`` iterators. They attempt to preserve the +sanity of the use list by moving all the uses for a statement into +a controlled position, and then iterating over those uses. Then the +optimization can manipulate the stmt when all the uses have been +processed. This is a little slower than the FAST version since it adds a +placeholder element and must sort through the list a bit for each statement. +This placeholder element must be also be removed if the loop is +terminated early; a destructor takes care of that when leaving the +``FOR_EACH_IMM_USE_STMT`` scope. + +There are checks in ``verify_ssa`` which verify that the immediate use list +is up to date, as well as checking that an optimization didn't break from the +loop without using this macro. It is safe to simply 'break'; from a +``FOR_EACH_IMM_USE_FAST`` traverse. + +Some useful functions and macros: + +* ``has_zero_uses (ssa_var)`` : Returns true if there are no uses of + ``ssa_var``. + +* ``has_single_use (ssa_var)`` : Returns true if there is only a + single use of ``ssa_var``. + +* ``single_imm_use (ssa_var, use_operand_p *ptr, tree *stmt)`` : + Returns true if there is only a single use of ``ssa_var``, and also returns + the use pointer and statement it occurs in, in the second and third parameters. + +* ``num_imm_uses (ssa_var)`` : Returns the number of immediate uses of + ``ssa_var``. It is better not to use this if possible since it simply + utilizes a loop to count the uses. + +* ``PHI_ARG_INDEX_FROM_USE (use_p)`` : Given a use within a ``PHI`` + node, return the index number for the use. An assert is triggered if the use + isn't located in a ``PHI`` node. + +* ``USE_STMT (use_p)`` : Return the statement a use occurs in. + +Note that uses are not put into an immediate use list until their statement is +actually inserted into the instruction stream via a ``bsi_*`` routine. + +It is also still possible to utilize lazy updating of statements, but this +should be used only when absolutely required. Both alias analysis and the +dominator optimizations currently do this. + +When lazy updating is being used, the immediate use information is out of date +and cannot be used reliably. Lazy updating is achieved by simply marking +statements modified via calls to ``gimple_set_modified`` instead of +``update_stmt``. When lazy updating is no longer required, all the +modified statements must have ``update_stmt`` called in order to bring them +up to date. This must be done before the optimization is finished, or +``verify_ssa`` will trigger an abort. + +This is done with a simple loop over the instruction stream: + +.. code-block:: c++ + + block_stmt_iterator bsi; + basic_block bb; + FOR_EACH_BB (bb) + { + for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi)) + update_stmt_if_modified (bsi_stmt (bsi)); + } \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/static-single-assignment.rst b/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/static-single-assignment.rst new file mode 100644 index 00000000000..8b79dc0a714 --- /dev/null +++ b/gcc/doc/gccint/analysis-and-optimization-of-gimple-tuples/static-single-assignment.rst @@ -0,0 +1,259 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SSA, static single assignment + +.. _ssa: + +Static Single Assignment +************************ + +Most of the tree optimizers rely on the data flow information provided +by the Static Single Assignment (SSA) form. We implement the SSA form +as described in R. Cytron, J. Ferrante, B. Rosen, M. Wegman, and +K. Zadeck. Efficiently Computing Static Single Assignment Form and the +Control Dependence Graph. ACM Transactions on Programming Languages +and Systems, 13(4):451-490, October 1991. + +The SSA form is based on the premise that program variables are +assigned in exactly one location in the program. Multiple assignments +to the same variable create new versions of that variable. Naturally, +actual programs are seldom in SSA form initially because variables +tend to be assigned multiple times. The compiler modifies the program +representation so that every time a variable is assigned in the code, +a new version of the variable is created. Different versions of the +same variable are distinguished by subscripting the variable name with +its version number. Variables used in the right-hand side of +expressions are renamed so that their version number matches that of +the most recent assignment. + +We represent variable versions using ``SSA_NAME`` nodes. The +renaming process in :samp:`tree-ssa.cc` wraps every real and +virtual operand with an ``SSA_NAME`` node which contains +the version number and the statement that created the +``SSA_NAME``. Only definitions and virtual definitions may +create new ``SSA_NAME`` nodes. + +.. index:: PHI nodes + +Sometimes, flow of control makes it impossible to determine the +most recent version of a variable. In these cases, the compiler +inserts an artificial definition for that variable called +:dfn:`PHI function` or :dfn:`PHI node`. This new definition merges +all the incoming versions of the variable to create a new name +for it. For instance, + +.. code-block:: c++ + + if (...) + a_1 = 5; + else if (...) + a_2 = 2; + else + a_3 = 13; + + # a_4 = PHI + return a_4; + +Since it is not possible to determine which of the three branches +will be taken at runtime, we don't know which of ``a_1``, +``a_2`` or ``a_3`` to use at the return statement. So, the +SSA renamer creates a new version ``a_4`` which is assigned +the result of 'merging' ``a_1``, ``a_2`` and ``a_3``. +Hence, PHI nodes mean 'one of these operands. I don't know +which'. + +The following functions can be used to examine PHI nodes + +.. function:: gimple_phi_result (phi) + + Returns the ``SSA_NAME`` created by PHI node :samp:`{phi}` (i.e., :samp:`{phi}` 's LHS). + +.. function:: gimple_phi_num_args (phi) + + Returns the number of arguments in :samp:`{phi}`. This number is exactly + the number of incoming edges to the basic block holding :samp:`{phi}`. + +.. function:: gimple_phi_arg (phi, i) + + Returns :samp:`{i}` th argument of :samp:`{phi}`. + +.. function:: gimple_phi_arg_edge (phi, i) + + Returns the incoming edge for the :samp:`{i}` th argument of :samp:`{phi}`. + +.. function:: gimple_phi_arg_def (phi, i) + + Returns the ``SSA_NAME`` for the :samp:`{i}` th argument of :samp:`{phi}`. + +.. index:: update_ssa, preserving SSA form + +Preserving the SSA form +^^^^^^^^^^^^^^^^^^^^^^^ + +Some optimization passes make changes to the function that +invalidate the SSA property. This can happen when a pass has +added new symbols or changed the program so that variables that +were previously aliased aren't anymore. Whenever something like this +happens, the affected symbols must be renamed into SSA form again. +Transformations that emit new code or replicate existing statements +will also need to update the SSA form. + +Since GCC implements two different SSA forms for register and virtual +variables, keeping the SSA form up to date depends on whether you are +updating register or virtual names. In both cases, the general idea +behind incremental SSA updates is similar: when new SSA names are +created, they typically are meant to replace other existing names in +the program. + +For instance, given the following code: + +.. code-block:: c++ + + 1 L0: + 2 x_1 = PHI (0, x_5) + 3 if (x_1 < 10) + 4 if (x_1 > 7) + 5 y_2 = 0 + 6 else + 7 y_3 = x_1 + x_7 + 8 endif + 9 x_5 = x_1 + 1 + 10 goto L0; + 11 endif + +Suppose that we insert new names ``x_10`` and ``x_11`` (lines +``4`` and ``8``). + +.. code-block:: c++ + + 1 L0: + 2 x_1 = PHI (0, x_5) + 3 if (x_1 < 10) + 4 x_10 = ... + 5 if (x_1 > 7) + 6 y_2 = 0 + 7 else + 8 x_11 = ... + 9 y_3 = x_1 + x_7 + 10 endif + 11 x_5 = x_1 + 1 + 12 goto L0; + 13 endif + +We want to replace all the uses of ``x_1`` with the new definitions +of ``x_10`` and ``x_11``. Note that the only uses that should +be replaced are those at lines ``5``, ``9`` and ``11``. +Also, the use of ``x_7`` at line ``9`` should *not* be +replaced (this is why we cannot just mark symbol ``x`` for +renaming). + +Additionally, we may need to insert a PHI node at line ``11`` +because that is a merge point for ``x_10`` and ``x_11``. So the +use of ``x_1`` at line ``11`` will be replaced with the new PHI +node. The insertion of PHI nodes is optional. They are not strictly +necessary to preserve the SSA form, and depending on what the caller +inserted, they may not even be useful for the optimizers. + +Updating the SSA form is a two step process. First, the pass has to +identify which names need to be updated and/or which symbols need to +be renamed into SSA form for the first time. When new names are +introduced to replace existing names in the program, the mapping +between the old and the new names are registered by calling +``register_new_name_mapping`` (note that if your pass creates new +code by duplicating basic blocks, the call to ``tree_duplicate_bb`` +will set up the necessary mappings automatically). + +After the replacement mappings have been registered and new symbols +marked for renaming, a call to ``update_ssa`` makes the registered +changes. This can be done with an explicit call or by creating +``TODO`` flags in the ``tree_opt_pass`` structure for your pass. +There are several ``TODO`` flags that control the behavior of +``update_ssa`` : + +* ``TODO_update_ssa``. Update the SSA form inserting PHI nodes + for newly exposed symbols and virtual names marked for updating. + When updating real names, only insert PHI nodes for a real name + ``O_j`` in blocks reached by all the new and old definitions for + ``O_j``. If the iterated dominance frontier for ``O_j`` + is not pruned, we may end up inserting PHI nodes in blocks that + have one or more edges with no incoming definition for + ``O_j``. This would lead to uninitialized warnings for + ``O_j`` 's symbol. + +* ``TODO_update_ssa_no_phi``. Update the SSA form without + inserting any new PHI nodes at all. This is used by passes that + have either inserted all the PHI nodes themselves or passes that + need only to patch use-def and def-def chains for virtuals + (e.g., DCE). + +* ``TODO_update_ssa_full_phi``. Insert PHI nodes everywhere + they are needed. No pruning of the IDF is done. This is used + by passes that need the PHI nodes for ``O_j`` even if it + means that some arguments will come from the default definition + of ``O_j`` 's symbol (e.g., ``pass_linear_transform``). + + WARNING: If you need to use this flag, chances are that your + pass may be doing something wrong. Inserting PHI nodes for an + old name where not all edges carry a new replacement may lead to + silent codegen errors or spurious uninitialized warnings. + +* ``TODO_update_ssa_only_virtuals``. Passes that update the + SSA form on their own may want to delegate the updating of + virtual names to the generic updater. Since FUD chains are + easier to maintain, this simplifies the work they need to do. + NOTE: If this flag is used, any OLD->NEW mappings for real names + are explicitly destroyed and only the symbols marked for + renaming are processed. + +.. index:: examining SSA_NAMEs + +Examining SSA_NAME nodes +^^^^^^^^^^^^^^^^^^^^^^^^ + +The following macros can be used to examine ``SSA_NAME`` nodes + +.. c:macro:: SSA_NAME_DEF_STMT (var) + + Returns the statement :samp:`{s}` that creates the ``SSA_NAME`` + :samp:`{var}`. If :samp:`{s}` is an empty statement (i.e., ``IS_EMPTY_STMT + (s)`` returns ``true``), it means that the first reference to + this variable is a USE or a VUSE. + +.. c:macro:: SSA_NAME_VERSION (var) + + Returns the version number of the ``SSA_NAME`` object :samp:`{var}`. + +Walking the dominator tree +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void walk_dominator_tree (walk_data, bb) + + This function walks the dominator tree for the current CFG calling a + set of callback functions defined in :samp:`{struct dom_walk_data}` in + :samp:`domwalk.h`. The call back functions you need to define give you + hooks to execute custom code at various points during traversal: + + * Once to initialize any local data needed while processing + :samp:`{bb}` and its children. This local data is pushed into an + internal stack which is automatically pushed and popped as the + walker traverses the dominator tree. + + * Once before traversing all the statements in the :samp:`{bb}`. + + * Once for every statement inside :samp:`{bb}`. + + * Once after traversing all the statements and before recursing + into :samp:`{bb}` 's dominator children. + + * It then recurses into all the dominator children of :samp:`{bb}`. + + * After recursing into all the dominator children of :samp:`{bb}` it + can, optionally, traverse every statement in :samp:`{bb}` again + (i.e., repeating steps 2 and 3). + + * Once after walking the statements in :samp:`{bb}` and :samp:`{bb}` 's + dominator children. At this stage, the block local data stack + is popped. \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-representation-of-loops.rst b/gcc/doc/gccint/analysis-and-representation-of-loops.rst new file mode 100644 index 00000000000..a1fe2cd7a40 --- /dev/null +++ b/gcc/doc/gccint/analysis-and-representation-of-loops.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _loop-analysis-and-representation: + +Analysis and Representation of Loops +------------------------------------ + +GCC provides extensive infrastructure for work with natural loops, i.e., +strongly connected components of CFG with only one entry block. This +chapter describes representation of loops in GCC, both on GIMPLE and in +RTL, as well as the interfaces to loop-related analyses (induction +variable analysis and number of iterations analysis). + +.. toctree:: + :maxdepth: 2 + + analysis-and-representation-of-loops/loop-representation + analysis-and-representation-of-loops/loop-querying + analysis-and-representation-of-loops/loop-manipulation + analysis-and-representation-of-loops/loop-closed-ssa-form + analysis-and-representation-of-loops/scalar-evolutions + analysis-and-representation-of-loops/iv-analysis-on-rtl + analysis-and-representation-of-loops/number-of-iterations-analysis + analysis-and-representation-of-loops/data-dependency-analysis \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-representation-of-loops/data-dependency-analysis.rst b/gcc/doc/gccint/analysis-and-representation-of-loops/data-dependency-analysis.rst new file mode 100644 index 00000000000..3548e16a31c --- /dev/null +++ b/gcc/doc/gccint/analysis-and-representation-of-loops/data-dependency-analysis.rst @@ -0,0 +1,135 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Data Dependency Analysis + +.. _dependency-analysis: + +Data Dependency Analysis +************************ + +The code for the data dependence analysis can be found in +:samp:`tree-data-ref.cc` and its interface and data structures are +described in :samp:`tree-data-ref.h`. The function that computes the +data dependences for all the array and pointer references for a given +loop is ``compute_data_dependences_for_loop``. This function is +currently used by the linear loop transform and the vectorization +passes. Before calling this function, one has to allocate two vectors: +a first vector will contain the set of data references that are +contained in the analyzed loop body, and the second vector will contain +the dependence relations between the data references. Thus if the +vector of data references is of size ``n``, the vector containing the +dependence relations will contain ``n*n`` elements. However if the +analyzed loop contains side effects, such as calls that potentially can +interfere with the data references in the current analyzed loop, the +analysis stops while scanning the loop body for data references, and +inserts a single ``chrec_dont_know`` in the dependence relation +array. + +The data references are discovered in a particular order during the +scanning of the loop body: the loop body is analyzed in execution order, +and the data references of each statement are pushed at the end of the +data reference array. Two data references syntactically occur in the +program in the same order as in the array of data references. This +syntactic order is important in some classical data dependence tests, +and mapping this order to the elements of this array avoids costly +queries to the loop body representation. + +Three types of data references are currently handled: ARRAY_REF, +INDIRECT_REF and COMPONENT_REF. The data structure for the data reference +is ``data_reference``, where ``data_reference_p`` is a name of a +pointer to the data reference structure. The structure contains the +following elements: + +* ``base_object_info`` : Provides information about the base object + of the data reference and its access functions. These access functions + represent the evolution of the data reference in the loop relative to + its base, in keeping with the classical meaning of the data reference + access function for the support of arrays. For example, for a reference + ``a.b[i][j]``, the base object is ``a.b`` and the access functions, + one for each array subscript, are: + ``{i_init, + i_step}_1, {j_init, +, j_step}_2``. + +* ``first_location_in_loop`` : Provides information about the first + location accessed by the data reference in the loop and about the access + function used to represent evolution relative to this location. This data + is used to support pointers, and is not used for arrays (for which we + have base objects). Pointer accesses are represented as a one-dimensional + access that starts from the first location accessed in the loop. For + example: + + .. code-block:: c++ + + for1 i + for2 j + *((int *)p + i + j) = a[i][j]; + + The access function of the pointer access is ``{0, + 4B}_for2`` + relative to ``p + i``. The access functions of the array are + ``{i_init, + i_step}_for1`` and ``{j_init, +, j_step}_for2`` + relative to ``a``. + + Usually, the object the pointer refers to is either unknown, or we cannot + prove that the access is confined to the boundaries of a certain object. + + Two data references can be compared only if at least one of these two + representations has all its fields filled for both data references. + + The current strategy for data dependence tests is as follows: + If both ``a`` and ``b`` are represented as arrays, compare + ``a.base_object`` and ``b.base_object`` ; + if they are equal, apply dependence tests (use access functions based on + base_objects). + Else if both ``a`` and ``b`` are represented as pointers, compare + ``a.first_location`` and ``b.first_location`` ; + if they are equal, apply dependence tests (use access functions based on + first location). + However, if ``a`` and ``b`` are represented differently, only try + to prove that the bases are definitely different. + +* Aliasing information. + +* Alignment information. + +The structure describing the relation between two data references is +``data_dependence_relation`` and the shorter name for a pointer to +such a structure is ``ddr_p``. This structure contains: + +* a pointer to each data reference, + +* a tree node ``are_dependent`` that is set to ``chrec_known`` + if the analysis has proved that there is no dependence between these two + data references, ``chrec_dont_know`` if the analysis was not able to + determine any useful result and potentially there could exist a + dependence between these data references, and ``are_dependent`` is + set to ``NULL_TREE`` if there exist a dependence relation between the + data references, and the description of this dependence relation is + given in the ``subscripts``, ``dir_vects``, and ``dist_vects`` + arrays, + +* a boolean that determines whether the dependence relation can be + represented by a classical distance vector, + +* an array ``subscripts`` that contains a description of each + subscript of the data references. Given two array accesses a + subscript is the tuple composed of the access functions for a given + dimension. For example, given ``A[f1][f2][f3]`` and + ``B[g1][g2][g3]``, there are three subscripts: ``(f1, g1), (f2, + g2), (f3, g3)``. + +* two arrays ``dir_vects`` and ``dist_vects`` that contain + classical representations of the data dependences under the form of + direction and distance dependence vectors, + +* an array of loops ``loop_nest`` that contains the loops to + which the distance and direction vectors refer to. + +Several functions for pretty printing the information extracted by the +data dependence analysis are available: ``dump_ddrs`` prints with a +maximum verbosity the details of a data dependence relations array, +``dump_dist_dir_vectors`` prints only the classical distance and +direction vectors for a data dependence relations array, and +``dump_data_references`` prints the details of the data references +contained in a data reference array. \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-representation-of-loops/iv-analysis-on-rtl.rst b/gcc/doc/gccint/analysis-and-representation-of-loops/iv-analysis-on-rtl.rst new file mode 100644 index 00000000000..77facc00abd --- /dev/null +++ b/gcc/doc/gccint/analysis-and-representation-of-loops/iv-analysis-on-rtl.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: IV analysis on RTL + +.. _loop-iv: + +IV analysis on RTL +****************** + +The induction variable on RTL is simple and only allows analysis of +affine induction variables, and only in one loop at once. The interface +is declared in :samp:`cfgloop.h`. Before analyzing induction variables +in a loop L, ``iv_analysis_loop_init`` function must be called on L. +After the analysis (possibly calling ``iv_analysis_loop_init`` for +several loops) is finished, ``iv_analysis_done`` should be called. +The following functions can be used to access the results of the +analysis: + +* ``iv_analyze`` : Analyzes a single register used in the given + insn. If no use of the register in this insn is found, the following + insns are scanned, so that this function can be called on the insn + returned by get_condition. + +* ``iv_analyze_result`` : Analyzes result of the assignment in the + given insn. + +* ``iv_analyze_expr`` : Analyzes a more complicated expression. + All its operands are analyzed by ``iv_analyze``, and hence they must + be used in the specified insn or one of the following insns. + +The description of the induction variable is provided in ``struct +rtx_iv``. In order to handle subregs, the representation is a bit +complicated; if the value of the ``extend`` field is not +``UNKNOWN``, the value of the induction variable in the i-th +iteration is + +.. code-block:: c++ + + delta + mult * extend_{extend_mode} (subreg_{mode} (base + i * step)), + +with the following exception: if ``first_special`` is true, then the +value in the first iteration (when ``i`` is zero) is ``delta + +mult * base``. However, if ``extend`` is equal to ``UNKNOWN``, +then ``first_special`` must be false, ``delta`` 0, ``mult`` 1 +and the value in the i-th iteration is + +.. code-block:: c++ + + subreg_{mode} (base + i * step) + +The function ``get_iv_value`` can be used to perform these +calculations. \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-representation-of-loops/loop-closed-ssa-form.rst b/gcc/doc/gccint/analysis-and-representation-of-loops/loop-closed-ssa-form.rst new file mode 100644 index 00000000000..bbca8b669ec --- /dev/null +++ b/gcc/doc/gccint/analysis-and-representation-of-loops/loop-closed-ssa-form.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: LCSSA, Loop-closed SSA form + +.. _lcssa: + +Loop-closed SSA form +******************** + +Throughout the loop optimizations on tree level, one extra condition is +enforced on the SSA form: No SSA name is used outside of the loop in +that it is defined. The SSA form satisfying this condition is called +'loop-closed SSA form' -- LCSSA. To enforce LCSSA, PHI nodes must be +created at the exits of the loops for the SSA names that are used +outside of them. Only the real operands (not virtual SSA names) are +held in LCSSA, in order to save memory. + +There are various benefits of LCSSA: + +* Many optimizations (value range analysis, final value + replacement) are interested in the values that are defined in the loop + and used outside of it, i.e., exactly those for that we create new PHI + nodes. + +* In induction variable analysis, it is not necessary to specify the + loop in that the analysis should be performed -- the scalar evolution + analysis always returns the results with respect to the loop in that the + SSA name is defined. + +* It makes updating of SSA form during loop transformations simpler. + Without LCSSA, operations like loop unrolling may force creation of PHI + nodes arbitrarily far from the loop, while in LCSSA, the SSA form can be + updated locally. However, since we only keep real operands in LCSSA, we + cannot use this advantage (we could have local updating of real + operands, but it is not much more efficient than to use generic SSA form + updating for it as well; the amount of changes to SSA is the same). + +However, it also means LCSSA must be updated. This is usually +straightforward, unless you create a new value in loop and use it +outside, or unless you manipulate loop exit edges (functions are +provided to make these manipulations simple). +``rewrite_into_loop_closed_ssa`` is used to rewrite SSA form to +LCSSA, and ``verify_loop_closed_ssa`` to check that the invariant of +LCSSA is preserved. \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-representation-of-loops/loop-manipulation.rst b/gcc/doc/gccint/analysis-and-representation-of-loops/loop-manipulation.rst new file mode 100644 index 00000000000..7546e439f8c --- /dev/null +++ b/gcc/doc/gccint/analysis-and-representation-of-loops/loop-manipulation.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Loop manipulation + +.. _loop-manipulation: + +Loop manipulation +***************** + +The loops tree can be manipulated using the following functions: + +* ``flow_loop_tree_node_add`` : Adds a node to the tree. + +* ``flow_loop_tree_node_remove`` : Removes a node from the tree. + +* ``add_bb_to_loop`` : Adds a basic block to a loop. + +* ``remove_bb_from_loops`` : Removes a basic block from loops. + +Most low-level CFG functions update loops automatically. The following +functions handle some more complicated cases of CFG manipulations: + +* ``remove_path`` : Removes an edge and all blocks it dominates. + +* ``split_loop_exit_edge`` : Splits exit edge of the loop, + ensuring that PHI node arguments remain in the loop (this ensures that + loop-closed SSA form is preserved). Only useful on GIMPLE. + +Finally, there are some higher-level loop transformations implemented. +While some of them are written so that they should work on non-innermost +loops, they are mostly untested in that case, and at the moment, they +are only reliable for the innermost loops: + +* ``create_iv`` : Creates a new induction variable. Only works on + GIMPLE. ``standard_iv_increment_position`` can be used to find a + suitable place for the iv increment. + +* ``duplicate_loop_body_to_header_edge``, + ``tree_duplicate_loop_body_to_header_edge`` : These functions (on RTL and + on GIMPLE) duplicate the body of the loop prescribed number of times on + one of the edges entering loop header, thus performing either loop + unrolling or loop peeling. ``can_duplicate_loop_p`` + (``can_unroll_loop_p`` on GIMPLE) must be true for the duplicated + loop. + +* ``loop_version`` : This function creates a copy of a loop, and + a branch before them that selects one of them depending on the + prescribed condition. This is useful for optimizations that need to + verify some assumptions in runtime (one of the copies of the loop is + usually left unchanged, while the other one is transformed in some way). + +* ``tree_unroll_loop`` : Unrolls the loop, including peeling the + extra iterations to make the number of iterations divisible by unroll + factor, updating the exit condition, and removing the exits that now + cannot be taken. Works only on GIMPLE. \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-representation-of-loops/loop-querying.rst b/gcc/doc/gccint/analysis-and-representation-of-loops/loop-querying.rst new file mode 100644 index 00000000000..d37bcae3b24 --- /dev/null +++ b/gcc/doc/gccint/analysis-and-representation-of-loops/loop-querying.rst @@ -0,0 +1,81 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Loop querying + +.. _loop-querying: + +Loop querying +************* + +The functions to query the information about loops are declared in +:samp:`cfgloop.h`. Some of the information can be taken directly from +the structures. ``loop_father`` field of each basic block contains +the innermost loop to that the block belongs. The most useful fields of +loop structure (that are kept up-to-date at all times) are: + +* ``header``, ``latch`` : Header and latch basic blocks of the + loop. + +* ``num_nodes`` : Number of basic blocks in the loop (including + the basic blocks of the sub-loops). + +* ``outer``, ``inner``, ``next`` : The super-loop, the first + sub-loop, and the sibling of the loop in the loops tree. + +There are other fields in the loop structures, many of them used only by +some of the passes, or not updated during CFG changes; in general, they +should not be accessed directly. + +The most important functions to query loop structures are: + +* ``loop_depth`` : The depth of the loop in the loops tree, i.e., the + number of super-loops of the loop. + +* ``flow_loops_dump`` : Dumps the information about loops to a + file. + +* ``verify_loop_structure`` : Checks consistency of the loop + structures. + +* ``loop_latch_edge`` : Returns the latch edge of a loop. + +* ``loop_preheader_edge`` : If loops have preheaders, returns + the preheader edge of a loop. + +* ``flow_loop_nested_p`` : Tests whether loop is a sub-loop of + another loop. + +* ``flow_bb_inside_loop_p`` : Tests whether a basic block belongs + to a loop (including its sub-loops). + +* ``find_common_loop`` : Finds the common super-loop of two loops. + +* ``superloop_at_depth`` : Returns the super-loop of a loop with + the given depth. + +* ``tree_num_loop_insns``, ``num_loop_insns`` : Estimates the + number of insns in the loop, on GIMPLE and on RTL. + +* ``loop_exit_edge_p`` : Tests whether edge is an exit from a + loop. + +* ``mark_loop_exit_edges`` : Marks all exit edges of all loops + with ``EDGE_LOOP_EXIT`` flag. + +* ``get_loop_body``, ``get_loop_body_in_dom_order``, + ``get_loop_body_in_bfs_order`` : Enumerates the basic blocks in the + loop in depth-first search order in reversed CFG, ordered by dominance + relation, and breath-first search order, respectively. + +* ``single_exit`` : Returns the single exit edge of the loop, or + ``NULL`` if the loop has more than one exit. You can only use this + function if ``LOOPS_HAVE_RECORDED_EXITS`` is used. + +* ``get_loop_exit_edges`` : Enumerates the exit edges of a loop. + +* ``just_once_each_iteration_p`` : Returns true if the basic block + is executed exactly once during each iteration of a loop (that is, it + does not belong to a sub-loop, and it dominates the latch of the loop). \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-representation-of-loops/loop-representation.rst b/gcc/doc/gccint/analysis-and-representation-of-loops/loop-representation.rst new file mode 100644 index 00000000000..861f6ad3ebc --- /dev/null +++ b/gcc/doc/gccint/analysis-and-representation-of-loops/loop-representation.rst @@ -0,0 +1,137 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Loop representation, Loop analysis + +.. _loop-representation: + +Loop representation +******************* + +This chapter describes the representation of loops in GCC, and functions +that can be used to build, modify and analyze this representation. Most +of the interfaces and data structures are declared in :samp:`cfgloop.h`. +Loop structures are analyzed and this information disposed or updated +at the discretion of individual passes. Still most of the generic +CFG manipulation routines are aware of loop structures and try to +keep them up-to-date. By this means an increasing part of the +compilation pipeline is setup to maintain loop structure across +passes to allow attaching meta information to individual loops +for consumption by later passes. + +In general, a natural loop has one entry block (header) and possibly +several back edges (latches) leading to the header from the inside of +the loop. Loops with several latches may appear if several loops share +a single header, or if there is a branching in the middle of the loop. +The representation of loops in GCC however allows only loops with a +single latch. During loop analysis, headers of such loops are split and +forwarder blocks are created in order to disambiguate their structures. +Heuristic based on profile information and structure of the induction +variables in the loops is used to determine whether the latches +correspond to sub-loops or to control flow in a single loop. This means +that the analysis sometimes changes the CFG, and if you run it in the +middle of an optimization pass, you must be able to deal with the new +blocks. You may avoid CFG changes by passing +``LOOPS_MAY_HAVE_MULTIPLE_LATCHES`` flag to the loop discovery, +note however that most other loop manipulation functions will not work +correctly for loops with multiple latch edges (the functions that only +query membership of blocks to loops and subloop relationships, or +enumerate and test loop exits, can be expected to work). + +Body of the loop is the set of blocks that are dominated by its header, +and reachable from its latch against the direction of edges in CFG. The +loops are organized in a containment hierarchy (tree) such that all the +loops immediately contained inside loop L are the children of L in the +tree. This tree is represented by the ``struct loops`` structure. +The root of this tree is a fake loop that contains all blocks in the +function. Each of the loops is represented in a ``struct loop`` +structure. Each loop is assigned an index (``num`` field of the +``struct loop`` structure), and the pointer to the loop is stored in +the corresponding field of the ``larray`` vector in the loops +structure. The indices do not have to be continuous, there may be +empty (``NULL``) entries in the ``larray`` created by deleting +loops. Also, there is no guarantee on the relative order of a loop +and its subloops in the numbering. The index of a loop never changes. + +The entries of the ``larray`` field should not be accessed directly. +The function ``get_loop`` returns the loop description for a loop with +the given index. ``number_of_loops`` function returns number of loops +in the function. To traverse all loops, use a range-based for loop with +class ``loops_list`` instance. The ``flags`` argument passed to the +constructor function of class ``loops_list`` is used to determine the +direction of traversal and the set of loops visited. Each loop is +guaranteed to be visited exactly once, regardless of the changes to the +loop tree, and the loops may be removed during the traversal. The newly +created loops are never traversed, if they need to be visited, this must +be done separately after their creation. + +Each basic block contains the reference to the innermost loop it belongs +to (``loop_father``). For this reason, it is only possible to have +one ``struct loops`` structure initialized at the same time for each +CFG. The global variable ``current_loops`` contains the +``struct loops`` structure. Many of the loop manipulation functions +assume that dominance information is up-to-date. + +The loops are analyzed through ``loop_optimizer_init`` function. The +argument of this function is a set of flags represented in an integer +bitmask. These flags specify what other properties of the loop +structures should be calculated/enforced and preserved later: + +* ``LOOPS_MAY_HAVE_MULTIPLE_LATCHES`` : If this flag is set, no + changes to CFG will be performed in the loop analysis, in particular, + loops with multiple latch edges will not be disambiguated. If a loop + has multiple latches, its latch block is set to NULL. Most of + the loop manipulation functions will not work for loops in this shape. + No other flags that require CFG changes can be passed to + loop_optimizer_init. + +* ``LOOPS_HAVE_PREHEADERS`` : Forwarder blocks are created in such + a way that each loop has only one entry edge, and additionally, the + source block of this entry edge has only one successor. This creates a + natural place where the code can be moved out of the loop, and ensures + that the entry edge of the loop leads from its immediate super-loop. + +* ``LOOPS_HAVE_SIMPLE_LATCHES`` : Forwarder blocks are created to + force the latch block of each loop to have only one successor. This + ensures that the latch of the loop does not belong to any of its + sub-loops, and makes manipulation with the loops significantly easier. + Most of the loop manipulation functions assume that the loops are in + this shape. Note that with this flag, the 'normal' loop without any + control flow inside and with one exit consists of two basic blocks. + +* ``LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS`` : Basic blocks and + edges in the strongly connected components that are not natural loops + (have more than one entry block) are marked with + ``BB_IRREDUCIBLE_LOOP`` and ``EDGE_IRREDUCIBLE_LOOP`` flags. The + flag is not set for blocks and edges that belong to natural loops that + are in such an irreducible region (but it is set for the entry and exit + edges of such a loop, if they lead to/from this region). + +* ``LOOPS_HAVE_RECORDED_EXITS`` : The lists of exits are recorded + and updated for each loop. This makes some functions (e.g., + ``get_loop_exit_edges``) more efficient. Some functions (e.g., + ``single_exit``) can be used only if the lists of exits are + recorded. + +These properties may also be computed/enforced later, using functions +``create_preheaders``, ``force_single_succ_latches``, +``mark_irreducible_loops`` and ``record_loop_exits``. +The properties can be queried using ``loops_state_satisfies_p``. + +The memory occupied by the loops structures should be freed with +``loop_optimizer_finalize`` function. When loop structures are +setup to be preserved across passes this function reduces the +information to be kept up-to-date to a minimum (only +``LOOPS_MAY_HAVE_MULTIPLE_LATCHES`` set). + +The CFG manipulation functions in general do not update loop structures. +Specialized versions that additionally do so are provided for the most +common tasks. On GIMPLE, ``cleanup_tree_cfg_loop`` function can be +used to cleanup CFG while updating the loops structures if +``current_loops`` is set. + +At the moment loop structure is preserved from the start of GIMPLE +loop optimizations until the end of RTL loop optimizations. During +this time a loop can be tracked by its ``struct loop`` and number. \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-representation-of-loops/number-of-iterations-analysis.rst b/gcc/doc/gccint/analysis-and-representation-of-loops/number-of-iterations-analysis.rst new file mode 100644 index 00000000000..b806d480413 --- /dev/null +++ b/gcc/doc/gccint/analysis-and-representation-of-loops/number-of-iterations-analysis.rst @@ -0,0 +1,85 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Number of iterations analysis + +.. _number-of-iterations: + +Number of iterations analysis +***************************** + +Both on GIMPLE and on RTL, there are functions available to determine +the number of iterations of a loop, with a similar interface. The +number of iterations of a loop in GCC is defined as the number of +executions of the loop latch. In many cases, it is not possible to +determine the number of iterations unconditionally -- the determined +number is correct only if some assumptions are satisfied. The analysis +tries to verify these conditions using the information contained in the +program; if it fails, the conditions are returned together with the +result. The following information and conditions are provided by the +analysis: + +* ``assumptions`` : If this condition is false, the rest of + the information is invalid. + +* ``noloop_assumptions`` on RTL, ``may_be_zero`` on GIMPLE: If + this condition is true, the loop exits in the first iteration. + +* ``infinite`` : If this condition is true, the loop is infinite. + This condition is only available on RTL. On GIMPLE, conditions for + finiteness of the loop are included in ``assumptions``. + +* ``niter_expr`` on RTL, ``niter`` on GIMPLE: The expression + that gives number of iterations. The number of iterations is defined as + the number of executions of the loop latch. + +Both on GIMPLE and on RTL, it necessary for the induction variable +analysis framework to be initialized (SCEV on GIMPLE, loop-iv on RTL). +On GIMPLE, the results are stored to ``struct tree_niter_desc`` +structure. Number of iterations before the loop is exited through a +given exit can be determined using ``number_of_iterations_exit`` +function. On RTL, the results are returned in ``struct niter_desc`` +structure. The corresponding function is named +``check_simple_exit``. There are also functions that pass through +all the exits of a loop and try to find one with easy to determine +number of iterations -- ``find_loop_niter`` on GIMPLE and +``find_simple_exit`` on RTL. Finally, there are functions that +provide the same information, but additionally cache it, so that +repeated calls to number of iterations are not so costly -- +``number_of_latch_executions`` on GIMPLE and ``get_simple_loop_desc`` +on RTL. + +Note that some of these functions may behave slightly differently than +others -- some of them return only the expression for the number of +iterations, and fail if there are some assumptions. The function +``number_of_latch_executions`` works only for single-exit loops. +The function ``number_of_cond_exit_executions`` can be used to +determine number of executions of the exit condition of a single-exit +loop (i.e., the ``number_of_latch_executions`` increased by one). + +On GIMPLE, below constraint flags affect semantics of some APIs of number +of iterations analyzer: + +* ``LOOP_C_INFINITE`` : If this constraint flag is set, the loop + is known to be infinite. APIs like ``number_of_iterations_exit`` can + return false directly without doing any analysis. + +* ``LOOP_C_FINITE`` : If this constraint flag is set, the loop is + known to be finite, in other words, loop's number of iterations can be + computed with ``assumptions`` be true. + +Generally, the constraint flags are set/cleared by consumers which are +loop optimizers. It's also the consumers' responsibility to set/clear +constraints correctly. Failing to do that might result in hard to track +down bugs in scev/niter consumers. One typical use case is vectorizer: +it drives number of iterations analyzer by setting ``LOOP_C_FINITE`` +and vectorizes possibly infinite loop by versioning loop with analysis +result. In return, constraints set by consumers can also help number of +iterations analyzer in following optimizers. For example, ``niter`` +of a loop versioned under ``assumptions`` is valid unconditionally. + +Other constraints may be added in the future, for example, a constraint +indicating that loops' latch must roll thus ``may_be_zero`` would be +false unconditionally. \ No newline at end of file diff --git a/gcc/doc/gccint/analysis-and-representation-of-loops/scalar-evolutions.rst b/gcc/doc/gccint/analysis-and-representation-of-loops/scalar-evolutions.rst new file mode 100644 index 00000000000..1001511b4dd --- /dev/null +++ b/gcc/doc/gccint/analysis-and-representation-of-loops/scalar-evolutions.rst @@ -0,0 +1,71 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Scalar evolutions, IV analysis on GIMPLE + +.. _scalar-evolutions: + +Scalar evolutions +***************** + +Scalar evolutions (SCEV) are used to represent results of induction +variable analysis on GIMPLE. They enable us to represent variables with +complicated behavior in a simple and consistent way (we only use it to +express values of polynomial induction variables, but it is possible to +extend it). The interfaces to SCEV analysis are declared in +:samp:`tree-scalar-evolution.h`. To use scalar evolutions analysis, +``scev_initialize`` must be used. To stop using SCEV, +``scev_finalize`` should be used. SCEV analysis caches results in +order to save time and memory. This cache however is made invalid by +most of the loop transformations, including removal of code. If such a +transformation is performed, ``scev_reset`` must be called to clean +the caches. + +Given an SSA name, its behavior in loops can be analyzed using the +``analyze_scalar_evolution`` function. The returned SCEV however +does not have to be fully analyzed and it may contain references to +other SSA names defined in the loop. To resolve these (potentially +recursive) references, ``instantiate_parameters`` or +``resolve_mixers`` functions must be used. +``instantiate_parameters`` is useful when you use the results of SCEV +only for some analysis, and when you work with whole nest of loops at +once. It will try replacing all SSA names by their SCEV in all loops, +including the super-loops of the current loop, thus providing a complete +information about the behavior of the variable in the loop nest. +``resolve_mixers`` is useful if you work with only one loop at a +time, and if you possibly need to create code based on the value of the +induction variable. It will only resolve the SSA names defined in the +current loop, leaving the SSA names defined outside unchanged, even if +their evolution in the outer loops is known. + +The SCEV is a normal tree expression, except for the fact that it may +contain several special tree nodes. One of them is +``SCEV_NOT_KNOWN``, used for SSA names whose value cannot be +expressed. The other one is ``POLYNOMIAL_CHREC``. Polynomial chrec +has three arguments -- base, step and loop (both base and step may +contain further polynomial chrecs). Type of the expression and of base +and step must be the same. A variable has evolution +``POLYNOMIAL_CHREC(base, step, loop)`` if it is (in the specified +loop) equivalent to ``x_1`` in the following example + +.. code-block:: c++ + + while (...) + { + x_1 = phi (base, x_2); + x_2 = x_1 + step; + } + +Note that this includes the language restrictions on the operations. +For example, if we compile C code and ``x`` has signed type, then the +overflow in addition would cause undefined behavior, and we may assume +that this does not happen. Hence, the value with this SCEV cannot +overflow (which restricts the number of iterations of such a loop). + +In many cases, one wants to restrict the attention just to affine +induction variables. In this case, the extra expressive power of SCEV +is not useful, and may complicate the optimizations. In this case, +``simple_iv`` function may be used to analyze a value -- the result +is a loop-invariant base and step. \ No newline at end of file diff --git a/gcc/doc/gccint/analyzer-internals.rst b/gcc/doc/gccint/analyzer-internals.rst new file mode 100644 index 00000000000..2dc5462c879 --- /dev/null +++ b/gcc/doc/gccint/analyzer-internals.rst @@ -0,0 +1,419 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: analyzer, internals, static analyzer, internals + +.. _analyzer-internals: + +Analyzer Internals +****************** + +Overview +^^^^^^^^ + +The analyzer implementation works on the gimple-SSA representation. +(I chose this in the hopes of making it easy to work with LTO to +do whole-program analysis). + +The implementation is read-only: it doesn't attempt to change anything, +just emit warnings. + +The gimple representation can be seen using :option:`-fdump-ipa-analyzer`. + +TipIf the analyzer ICEs before this is written out, one workaround is to use +:option:`--param=analyzer-bb-explosion-factor=0` to force the analyzer +to bail out after analyzing the first basic block. + +First, we build a ``supergraph`` which combines the callgraph and all +of the CFGs into a single directed graph, with both interprocedural and +intraprocedural edges. The nodes and edges in the supergraph are called +'supernodes' and 'superedges', and often referred to in code as +``snodes`` and ``sedges``. Basic blocks in the CFGs are split at +interprocedural calls, so there can be more than one supernode per +basic block. Most statements will be in just one supernode, but a call +statement can appear in two supernodes: at the end of one for the call, +and again at the start of another for the return. + +The supergraph can be seen using :option:`-fdump-analyzer-supergraph`. + +We then build an ``analysis_plan`` which walks the callgraph to +determine which calls might be suitable for being summarized (rather +than fully explored) and thus in what order to explore the functions. + +Next is the heart of the analyzer: we use a worklist to explore state +within the supergraph, building an "exploded graph". +Nodes in the exploded graph correspond to pairs, as in +"Precise Interprocedural Dataflow Analysis via Graph Reachability" +(Thomas Reps, Susan Horwitz and Mooly Sagiv). + +We reuse nodes for pairs we've already seen, and avoid +tracking state too closely, so that (hopefully) we rapidly converge +on a final exploded graph, and terminate the analysis. We also bail +out if the number of exploded nodes gets +larger than a particular multiple of the total number of basic blocks +(to ensure termination in the face of pathological state-explosion +cases, or bugs). We also stop exploring a point once we hit a limit +of states for that point. + +We can identify problems directly when processing a +instance. For example, if we're finding the successors of + +.. code-block:: c++ + + + +then we can detect a double-free of "ptr". We can then emit a path +to reach the problem by finding the simplest route through the graph. + +Program points in the analysis are much more fine-grained than in the +CFG and supergraph, with points (and thus potentially exploded nodes) +for various events, including before individual statements. +By default the exploded graph merges multiple consecutive statements +in a supernode into one exploded edge to minimize the size of the +exploded graph. This can be suppressed via +:option:`-fanalyzer-fine-grained`. +The fine-grained approach seems to make things simpler and more debuggable +that other approaches I tried, in that each point is responsible for one +thing. + +Program points in the analysis also have a "call string" identifying the +stack of callsites below them, so that paths in the exploded graph +correspond to interprocedurally valid paths: we always return to the +correct call site, propagating state information accordingly. +We avoid infinite recursion by stopping the analysis if a callsite +appears more than ``analyzer-max-recursion-depth`` in a callstring +(defaulting to 2). + +Graphs +^^^^^^ + +Nodes and edges in the exploded graph are called 'exploded nodes' and +'exploded edges' and often referred to in the code as +``enodes`` and ``eedges`` (especially when distinguishing them +from the ``snodes`` and ``sedges`` in the supergraph). + +Each graph numbers its nodes, giving unique identifiers - supernodes +are referred to throughout dumps in the form :samp:`SN': {index}` and +exploded nodes in the form :samp:`EN: {index}` (e.g. :samp:`SN: 2` and +:samp:`EN:29`). + +The supergraph can be seen using :option:`-fdump-analyzer-supergraph-graph`. + +The exploded graph can be seen using :option:`-fdump-analyzer-exploded-graph` +and other dump options. Exploded nodes are color-coded in the .dot output +based on state-machine states to make it easier to see state changes at +a glance. + +State Tracking +^^^^^^^^^^^^^^ + +There's a tension between: + +* precision of analysis in the straight-line case, vs + +* exponential blow-up in the face of control flow. + +For example, in general, given this CFG: + +.. code-block:: + + A + / \ + B C + \ / + D + / \ + E F + \ / + G + +we want to avoid differences in state-tracking in B and C from +leading to blow-up. If we don't prevent state blowup, we end up +with exponential growth of the exploded graph like this: + +.. code-block:: + + 1:A + / \ + / \ + / \ + 2:B 3:C + | | + 4:D 5:D (2 exploded nodes for D) + / \ / \ + 6:E 7:F 8:E 9:F + | | | | + 10:G 11:G 12:G 13:G (4 exploded nodes for G) + +Similar issues arise with loops. + +To prevent this, we follow various approaches: + +* state pruning: which tries to discard state that won't be relevant + later on withing the function. + This can be disabled via :option:`-fno-analyzer-state-purge`. + +* state merging. We can try to find the commonality between two + program_state instances to make a third, simpler program_state. + We have two strategies here: + + * the worklist keeps new nodes for the same program_point together, + and tries to merge them before processing, and thus before they have + successors. Hence, in the above, the two nodes for D (4 and 5) reach + the front of the worklist together, and we create a node for D with + the merger of the incoming states. + + * try merging with the state of existing enodes for the program_point + (which may have already been explored). There will be duplication, + but only one set of duplication; subsequent duplicates are more likely + to hit the cache. In particular, (hopefully) all merger chains are + finite, and so we guarantee termination. + This is intended to help with loops: we ought to explore the first + iteration, and then have a "subsequent iterations" exploration, + which uses a state merged from that of the first, to be more abstract. + + We avoid merging pairs of states that have state-machine differences, + as these are the kinds of differences that are likely to be most + interesting. So, for example, given: + + .. code-block:: + + if (condition) + ptr = malloc (size); + else + ptr = local_buf; + + .... do things with 'ptr' + + if (condition) + free (ptr); + + ...etc + + then we end up with an exploded graph that looks like this: + + .. code-block:: + + if (condition) + / T \ F + --------- ---------- + / \ + ptr = malloc (size) ptr = local_buf + | | + copy of copy of + "do things with 'ptr'" "do things with 'ptr'" + with ptr: heap-allocated with ptr: stack-allocated + | | + if (condition) if (condition) + | known to be T | known to be F + free (ptr); | + \ / + ----------------------------- + | ('ptr' is pruned, so states can be merged) + etc + + where some duplication has occurred, but only for the places where the + the different paths are worth exploringly separately. + + Merging can be disabled via :option:`-fno-analyzer-state-merge`. + +Region Model +^^^^^^^^^^^^ + +Part of the state stored at a ``exploded_node`` is a ``region_model``. +This is an implementation of the region-based ternary model described in +`"A Memory Model for Static Analysis of C Programs" `_ +(Zhongxing Xu, Ted Kremenek, and Jian Zhang). + +A ``region_model`` encapsulates a representation of the state of +memory, with a ``store`` recording a binding between ``region`` +instances, to ``svalue`` instances. The bindings are organized into +clusters, where regions accessible via well-defined pointer arithmetic +are in the same cluster. The representation is graph-like because values +can be pointers to regions. It also stores a constraint_manager, +capturing relationships between the values. + +Because each node in the ``exploded_graph`` has a ``region_model``, +and each of the latter is graph-like, the ``exploded_graph`` is in some +ways a graph of graphs. + +Here's an example of printing a ``program_state``, showing the +``region_model`` within it, along with state for the ``malloc`` +state machine. + +.. code-block:: + + (gdb) call debug (*this) + rmodel: + stack depth: 1 + frame (index 0): frame: ‘test’@1 + clusters within frame: ‘test’@1 + cluster for: ptr_3: &HEAP_ALLOCATED_REGION(12) + m_called_unknown_fn: FALSE + constraint_manager: + equiv classes: + constraints: + malloc: + 0x2e89590: &HEAP_ALLOCATED_REGION(12): unchecked ('ptr_3') + +This is the state at the point of returning from ``calls_malloc`` back +to ``test`` in the following: + +.. code-block:: c++ + + void * + calls_malloc (void) + { + void *result = malloc (1024); + return result; + } + + void test (void) + { + void *ptr = calls_malloc (); + /* etc. */ + } + +Within the store, there is the cluster for ``ptr_3`` within the frame +for ``test``, where the whole cluster is bound to a pointer value, +pointing at ``HEAP_ALLOCATED_REGION(12)``. Additionally, this pointer +has the ``unchecked`` state for the ``malloc`` state machine +indicating it hasn't yet been checked against NULL since the allocation +call. + +Analyzer Paths +^^^^^^^^^^^^^^ + +We need to explain to the user what the problem is, and to persuade them +that there really is a problem. Hence having a ``diagnostic_path`` +isn't just an incidental detail of the analyzer; it's required. + +Paths ought to be: + +* interprocedurally-valid + +* feasible + +Without state-merging, all paths in the exploded graph are feasible +(in terms of constraints being satisfied). +With state-merging, paths in the exploded graph can be infeasible. + +We collate warnings and only emit them for the simplest path +e.g. for a bug in a utility function, with lots of routes to calling it, +we only emit the simplest path (which could be intraprocedural, if +it can be reproduced without a caller). + +We thus want to find the shortest feasible path through the exploded +graph from the origin to the exploded node at which the diagnostic was +saved. Unfortunately, if we simply find the shortest such path and +check if it's feasible we might falsely reject the diagnostic, as there +might be a longer path that is feasible. Examples include the cases +where the diagnostic requires us to go at least once around a loop for a +later condition to be satisfied, or where for a later condition to be +satisfied we need to enter a suite of code that the simpler path skips. + +We attempt to find the shortest feasible path to each diagnostic by +first constructing a 'trimmed graph' from the exploded graph, +containing only those nodes and edges from which there are paths to +the target node, and using Dijkstra's algorithm to order the trimmed +nodes by minimal distance to the target. + +We then use a worklist to iteratively build a 'feasible graph' +(actually a tree), capturing the pertinent state along each path, in +which every path to a 'feasible node' is feasible by construction, +restricting ourselves to the trimmed graph to ensure we stay on target, +and ordering the worklist so that the first feasible path we find to the +target node is the shortest possible path. Hence we start by trying the +shortest possible path, but if that fails, we explore progressively +longer paths, eventually trying iterations through loops. The +exploration is captured in the feasible_graph, which can be dumped as a +.dot file via :option:`-fdump-analyzer-feasibility` to visualize the +exploration. The indices of the feasible nodes show the order in which +they were created. We effectively explore the tree of feasible paths in +order of shortest path until we either find a feasible path to the +target node, or hit a limit and give up. + +This is something of a brute-force approach, but the trimmed graph +hopefully keeps the complexity manageable. + +This algorithm can be disabled (for debugging purposes) via +:option:`-fno-analyzer-feasibility`, which simply uses the shortest path, +and notes if it is infeasible. + +The above gives us a shortest feasible ``exploded_path`` through the +``exploded_graph`` (a list of ``exploded_edge *``). We use this +``exploded_path`` to build a ``diagnostic_path`` (a list of +**events** for the diagnostic subsystem) - specifically a +``checker_path``. + +Having built the ``checker_path``, we prune it to try to eliminate +events that aren't relevant, to minimize how much the user has to read. + +After pruning, we notify each event in the path of its ID and record the +IDs of interesting events, allowing for events to refer to other events +in their descriptions. The ``pending_diagnostic`` class has various +vfuncs to support emitting more precise descriptions, so that e.g. + +* a deref-of-unchecked-malloc diagnostic might use: + + .. code-block:: + + returning possibly-NULL pointer to 'make_obj' from 'allocator' + + for a ``return_event`` to make it clearer how the unchecked value moves + from callee back to caller + +* a double-free diagnostic might use: + + .. code-block:: + + second 'free' here; first 'free' was at (3) + + and a use-after-free might use + + .. code-block:: + + use after 'free' here; memory was freed at (2) + +At this point we can emit the diagnostic. + +Limitations +^^^^^^^^^^^ + +* Only for C so far + +* The implementation of call summaries is currently very simplistic. + +* Lack of function pointer analysis + +* The constraint-handling code assumes reflexivity in some places + (that values are equal to themselves), which is not the case for NaN. + As a simple workaround, constraints on floating-point values are + currently ignored. + +* There are various other limitations in the region model (grep for TODO/xfail + in the testsuite). + +* The constraint_manager's implementation of transitivity is currently too + expensive to enable by default and so must be manually enabled via + :option:`-fanalyzer-transitivity`). + +* The checkers are currently hardcoded and don't allow for user extensibility + (e.g. adding allocate/release pairs). + +* Although the analyzer's test suite has a proof-of-concept test case for + LTO, LTO support hasn't had extensive testing. There are various + lang-specific things in the analyzer that assume C rather than LTO. + For example, SSA names are printed to the user in 'raw' form, rather + than printing the underlying variable name. + +Some ideas for other checkers + +* File-descriptor-based APIs + +* Linux kernel internal APIs + +* Signal handling \ No newline at end of file diff --git a/gcc/doc/gccint/collect2.rst b/gcc/doc/gccint/collect2.rst new file mode 100644 index 00000000000..e49cbd9f42c --- /dev/null +++ b/gcc/doc/gccint/collect2.rst @@ -0,0 +1,77 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _collect2: + +collect2 +-------- + +GCC uses a utility called ``collect2`` on nearly all systems to arrange +to call various initialization functions at start time. + +The program ``collect2`` works by linking the program once and +looking through the linker output file for symbols with particular names +indicating they are constructor functions. If it finds any, it +creates a new temporary :samp:`.c` file containing a table of them, +compiles it, and links the program a second time including that file. + +.. index:: __main, constructors, automatic calls + +The actual calls to the constructors are carried out by a subroutine +called ``__main``, which is called (automatically) at the beginning +of the body of ``main`` (provided ``main`` was compiled with GNU +CC). Calling ``__main`` is necessary, even when compiling C code, to +allow linking C and C++ object code together. (If you use +:option:`-nostdlib`, you get an unresolved reference to ``__main``, +since it's defined in the standard GCC library. Include :option:`-lgcc` at +the end of your compiler command line to resolve this reference.) + +The program ``collect2`` is installed as ``ld`` in the directory +where the passes of the compiler are installed. When ``collect2`` +needs to find the *real* ``ld``, it tries the following file +names: + +* a hard coded linker file name, if GCC was configured with the + :option:`--with-ld` option. + +* :samp:`real-ld` in the directories listed in the compiler's search + directories. + +* :samp:`real-ld` in the directories listed in the environment variable + ``PATH``. + +* The file specified in the ``REAL_LD_FILE_NAME`` configuration macro, + if specified. + +* :samp:`ld` in the compiler's search directories, except that + ``collect2`` will not execute itself recursively. + +* :samp:`ld` in ``PATH``. + +'The compiler's search directories' means all the directories where +:command:`gcc` searches for passes of the compiler. This includes +directories that you specify with :option:`-B`. + +Cross-compilers search a little differently: + +* :samp:`real-ld` in the compiler's search directories. + +* :samp:`{target}-real-ld` in ``PATH``. + +* The file specified in the ``REAL_LD_FILE_NAME`` configuration macro, + if specified. + +* :samp:`ld` in the compiler's search directories. + +* :samp:`{target}-ld` in ``PATH``. + +``collect2`` explicitly avoids running ``ld`` using the file name +under which ``collect2`` itself was invoked. In fact, it remembers +up a list of such names---in case one copy of ``collect2`` finds +another copy (or version) of ``collect2`` installed as ``ld`` in a +second place in the search path. + +``collect2`` searches for the utilities ``nm`` and ``strip`` +using the same algorithm as above for ``ld``. \ No newline at end of file diff --git a/gcc/doc/gccint/conf.py b/gcc/doc/gccint/conf.py new file mode 100644 index 00000000000..466261dbeb1 --- /dev/null +++ b/gcc/doc/gccint/conf.py @@ -0,0 +1,24 @@ +# Configuration file for the Sphinx documentation builder. + +import sys +sys.path.append('../../..//doc') + +from baseconf import * + +name = 'gccint' +project = 'GNU Compiler Collection Internals' +copyright = '1988-2022 Free Software Foundation, Inc.' +authors = 'Richard M. Stallman and the GCC Developer Community' + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +latex_documents = [ + ('index', f'{name}.tex', project, authors, 'manual'), +] + +texinfo_documents = [ + ('index', name, project, authors, None, None, None, True) +] + +set_common(name, globals()) \ No newline at end of file diff --git a/gcc/doc/gccint/contributing-to-gcc-development.rst b/gcc/doc/gccint/contributing-to-gcc-development.rst new file mode 100644 index 00000000000..f0d4b9f7db0 --- /dev/null +++ b/gcc/doc/gccint/contributing-to-gcc-development.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/contribute.rst \ No newline at end of file diff --git a/gcc/doc/gccint/contributors-to-gcc.rst b/gcc/doc/gccint/contributors-to-gcc.rst new file mode 100644 index 00000000000..27d5de90c77 --- /dev/null +++ b/gcc/doc/gccint/contributors-to-gcc.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/contrib.rst \ No newline at end of file diff --git a/gcc/doc/gccint/control-flow-graph.rst b/gcc/doc/gccint/control-flow-graph.rst new file mode 100644 index 00000000000..92de2a55dcd --- /dev/null +++ b/gcc/doc/gccint/control-flow-graph.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: CFG, Control Flow Graph, basic-block.h + +.. _control-flow: + +Control Flow Graph +------------------ + +A control flow graph (CFG) is a data structure built on top of the +intermediate code representation (the RTL or ``GIMPLE`` instruction +stream) abstracting the control flow behavior of a function that is +being compiled. The CFG is a directed graph where the vertices +represent basic blocks and edges represent possible transfer of +control flow from one basic block to another. The data structures +used to represent the control flow graph are defined in +:samp:`basic-block.h`. + +In GCC, the representation of control flow is maintained throughout +the compilation process, from constructing the CFG early in +``pass_build_cfg`` to ``pass_free_cfg`` (see :samp:`passes.def`). +The CFG takes various different modes and may undergo extensive +manipulations, but the graph is always valid between its construction +and its release. This way, transfer of information such as data flow, +a measured profile, or the loop tree, can be propagated through the +passes pipeline, and even from ``GIMPLE`` to ``RTL``. + +Often the CFG may be better viewed as integral part of instruction +chain, than structure built on the top of it. Updating the compiler's +intermediate representation for instructions cannot be easily done +without proper maintenance of the CFG simultaneously. + +.. toctree:: + :maxdepth: 2 + + control-flow-graph/basic-blocks + control-flow-graph/edges + control-flow-graph/profile-information + control-flow-graph/maintaining-the-cfg + control-flow-graph/liveness-information \ No newline at end of file diff --git a/gcc/doc/gccint/control-flow-graph/basic-blocks.rst b/gcc/doc/gccint/control-flow-graph/basic-blocks.rst new file mode 100644 index 00000000000..a29867cdf40 --- /dev/null +++ b/gcc/doc/gccint/control-flow-graph/basic-blocks.rst @@ -0,0 +1,141 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: basic block, basic_block + +.. _basic-blocks: + +Basic Blocks +************ + +A basic block is a straight-line sequence of code with only one entry +point and only one exit. In GCC, basic blocks are represented using +the ``basic_block`` data type. + +.. index:: ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR + +Special basic blocks represent possible entry and exit points of a +function. These blocks are called ``ENTRY_BLOCK_PTR`` and +``EXIT_BLOCK_PTR``. These blocks do not contain any code. + +.. index:: BASIC_BLOCK + +The ``BASIC_BLOCK`` array contains all basic blocks in an +unspecified order. Each ``basic_block`` structure has a field +that holds a unique integer identifier ``index`` that is the +index of the block in the ``BASIC_BLOCK`` array. +The total number of basic blocks in the function is +``n_basic_blocks``. Both the basic block indices and +the total number of basic blocks may vary during the compilation +process, as passes reorder, create, duplicate, and destroy basic +blocks. The index for any block should never be greater than +``last_basic_block``. The indices 0 and 1 are special codes +reserved for ``ENTRY_BLOCK`` and ``EXIT_BLOCK``, the +indices of ``ENTRY_BLOCK_PTR`` and ``EXIT_BLOCK_PTR``. + +.. index:: next_bb, prev_bb, FOR_EACH_BB, FOR_ALL_BB + +Two pointer members of the ``basic_block`` structure are the +pointers ``next_bb`` and ``prev_bb``. These are used to keep +doubly linked chain of basic blocks in the same order as the +underlying instruction stream. The chain of basic blocks is updated +transparently by the provided API for manipulating the CFG. The macro +``FOR_EACH_BB`` can be used to visit all the basic blocks in +lexicographical order, except ``ENTRY_BLOCK`` and ``EXIT_BLOCK``. +The macro ``FOR_ALL_BB`` also visits all basic blocks in +lexicographical order, including ``ENTRY_BLOCK`` and ``EXIT_BLOCK``. + +.. index:: post_order_compute, inverted_post_order_compute, walk_dominator_tree + +The functions ``post_order_compute`` and ``inverted_post_order_compute`` +can be used to compute topological orders of the CFG. The orders are +stored as vectors of basic block indices. The ``BASIC_BLOCK`` array +can be used to iterate each basic block by index. +Dominator traversals are also possible using +``walk_dominator_tree``. Given two basic blocks A and B, block A +dominates block B if A is *always* executed before B. + +Each ``basic_block`` also contains pointers to the first +instruction (the :dfn:`head`) and the last instruction (the :dfn:`tail`) +or :dfn:`end` of the instruction stream contained in a basic block. In +fact, since the ``basic_block`` data type is used to represent +blocks in both major intermediate representations of GCC (``GIMPLE`` +and RTL), there are pointers to the head and end of a basic block for +both representations, stored in intermediate representation specific +data in the ``il`` field of ``struct basic_block_def``. + +.. index:: CODE_LABEL, NOTE_INSN_BASIC_BLOCK + +For RTL, these pointers are ``BB_HEAD`` and ``BB_END``. + +.. index:: insn notes, notes, NOTE_INSN_BASIC_BLOCK + +In the RTL representation of a function, the instruction stream +contains not only the 'real' instructions, but also :dfn:`notes` +or :dfn:`insn notes` (to distinguish them from :dfn:`reg notes`). +Any function that moves or duplicates the basic blocks needs +to take care of updating of these notes. Many of these notes expect +that the instruction stream consists of linear regions, so updating +can sometimes be tedious. All types of insn notes are defined +in :samp:`insn-notes.def`. + +In the RTL function representation, the instructions contained in a +basic block always follow a ``NOTE_INSN_BASIC_BLOCK``, but zero +or more ``CODE_LABEL`` nodes can precede the block note. +A basic block ends with a control flow instruction or with the last +instruction before the next ``CODE_LABEL`` or +``NOTE_INSN_BASIC_BLOCK``. +By definition, a ``CODE_LABEL`` cannot appear in the middle of +the instruction stream of a basic block. + +.. index:: can_fallthru, table jump + +In addition to notes, the jump table vectors are also represented as +'pseudo-instructions' inside the insn stream. These vectors never +appear in the basic block and should always be placed just after the +table jump instructions referencing them. After removing the +table-jump it is often difficult to eliminate the code computing the +address and referencing the vector, so cleaning up these vectors is +postponed until after liveness analysis. Thus the jump table vectors +may appear in the insn stream unreferenced and without any purpose. +Before any edge is made :dfn:`fall-thru`, the existence of such +construct in the way needs to be checked by calling +``can_fallthru`` function. + +.. index:: GIMPLE statement iterators + +For the ``GIMPLE`` representation, the PHI nodes and statements +contained in a basic block are in a ``gimple_seq`` pointed to by +the basic block intermediate language specific pointers. +Abstract containers and iterators are used to access the PHI nodes +and statements in a basic blocks. These iterators are called +:dfn:`GIMPLE statement iterators` (GSIs). Grep for ``^gsi`` +in the various :samp:`gimple-*` and :samp:`tree-*` files. +There is a ``gimple_stmt_iterator`` type for iterating over +all kinds of statement, and a ``gphi_iterator`` subclass for +iterating over PHI nodes. +The following snippet will pretty-print all PHI nodes the statements +of the current function in the GIMPLE representation. + +.. code-block:: c++ + + basic_block bb; + + FOR_EACH_BB (bb) + { + gphi_iterator pi; + gimple_stmt_iterator si; + + for (pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi)) + { + gphi *phi = pi.phi (); + print_gimple_stmt (dump_file, phi, 0, TDF_SLIM); + } + for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) + { + gimple stmt = gsi_stmt (si); + print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM); + } + } \ No newline at end of file diff --git a/gcc/doc/gccint/control-flow-graph/edges.rst b/gcc/doc/gccint/control-flow-graph/edges.rst new file mode 100644 index 00000000000..55d64012b72 --- /dev/null +++ b/gcc/doc/gccint/control-flow-graph/edges.rst @@ -0,0 +1,241 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: edge in the flow graph, edge + +.. _edges: + +Edges +***** + +Edges represent possible control flow transfers from the end of some +basic block A to the head of another basic block B. We say that A is +a predecessor of B, and B is a successor of A. Edges are represented +in GCC with the ``edge`` data type. Each ``edge`` acts as a +link between two basic blocks: The ``src`` member of an edge +points to the predecessor basic block of the ``dest`` basic block. +The members ``preds`` and ``succs`` of the ``basic_block`` data +type point to type-safe vectors of edges to the predecessors and +successors of the block. + +.. index:: edge iterators + +When walking the edges in an edge vector, :dfn:`edge iterators` should +be used. Edge iterators are constructed using the +``edge_iterator`` data structure and several methods are available +to operate on them: + +``ei_start`` + This function initializes an ``edge_iterator`` that points to the + first edge in a vector of edges. + +``ei_last`` + This function initializes an ``edge_iterator`` that points to the + last edge in a vector of edges. + +``ei_end_p`` + This predicate is ``true`` if an ``edge_iterator`` represents + the last edge in an edge vector. + +``ei_one_before_end_p`` + This predicate is ``true`` if an ``edge_iterator`` represents + the second last edge in an edge vector. + +``ei_next`` + This function takes a pointer to an ``edge_iterator`` and makes it + point to the next edge in the sequence. + +``ei_prev`` + This function takes a pointer to an ``edge_iterator`` and makes it + point to the previous edge in the sequence. + +``ei_edge`` + This function returns the ``edge`` currently pointed to by an + ``edge_iterator``. + +``ei_safe_edge`` + This function returns the ``edge`` currently pointed to by an + ``edge_iterator``, but returns ``NULL`` if the iterator is + pointing at the end of the sequence. This function has been provided + for existing code makes the assumption that a ``NULL`` edge + indicates the end of the sequence. + + The convenience macro ``FOR_EACH_EDGE`` can be used to visit all of + the edges in a sequence of predecessor or successor edges. It must + not be used when an element might be removed during the traversal, + otherwise elements will be missed. Here is an example of how to use + the macro: + +.. code-block:: c++ + + edge e; + edge_iterator ei; + + FOR_EACH_EDGE (e, ei, bb->succs) + { + if (e->flags & EDGE_FALLTHRU) + break; + } + +.. index:: fall-thru + +There are various reasons why control flow may transfer from one block +to another. One possibility is that some instruction, for example a +``CODE_LABEL``, in a linearized instruction stream just always +starts a new basic block. In this case a :dfn:`fall-thru` edge links +the basic block to the first following basic block. But there are +several other reasons why edges may be created. The ``flags`` +field of the ``edge`` data type is used to store information +about the type of edge we are dealing with. Each edge is of one of +the following types: + +**jump** + + No type flags are set for edges corresponding to jump instructions. + These edges are used for unconditional or conditional jumps and in + RTL also for table jumps. They are the easiest to manipulate as they + may be freely redirected when the flow graph is not in SSA form. + +**fall-thru** + + .. index:: EDGE_FALLTHRU, force_nonfallthru + + Fall-thru edges are present in case where the basic block may continue + execution to the following one without branching. These edges have + the ``EDGE_FALLTHRU`` flag set. Unlike other types of edges, these + edges must come into the basic block immediately following in the + instruction stream. The function ``force_nonfallthru`` is + available to insert an unconditional jump in the case that redirection + is needed. Note that this may require creation of a new basic block. + +**exception handling** + + .. index:: exception handling, EDGE_ABNORMAL, EDGE_EH + + Exception handling edges represent possible control transfers from a + trapping instruction to an exception handler. The definition of + 'trapping' varies. In C++, only function calls can throw, but for + Ada exceptions like division by zero or segmentation fault are + defined and thus each instruction possibly throwing this kind of + exception needs to be handled as control flow instruction. Exception + edges have the ``EDGE_ABNORMAL`` and ``EDGE_EH`` flags set. + + .. index:: purge_dead_edges + + When updating the instruction stream it is easy to change possibly + trapping instruction to non-trapping, by simply removing the exception + edge. The opposite conversion is difficult, but should not happen + anyway. The edges can be eliminated via ``purge_dead_edges`` call. + + .. index:: REG_EH_REGION, EDGE_ABNORMAL_CALL + + In the RTL representation, the destination of an exception edge is + specified by ``REG_EH_REGION`` note attached to the insn. + In case of a trapping call the ``EDGE_ABNORMAL_CALL`` flag is set + too. In the ``GIMPLE`` representation, this extra flag is not set. + + .. index:: may_trap_p, tree_could_trap_p + + In the RTL representation, the predicate ``may_trap_p`` may be used + to check whether instruction still may trap or not. For the tree + representation, the ``tree_could_trap_p`` predicate is available, + but this predicate only checks for possible memory traps, as in + dereferencing an invalid pointer location. + +**sibling calls** + + .. index:: sibling call, EDGE_ABNORMAL, EDGE_SIBCALL + + Sibling calls or tail calls terminate the function in a non-standard + way and thus an edge to the exit must be present. + ``EDGE_SIBCALL`` and ``EDGE_ABNORMAL`` are set in such case. + These edges only exist in the RTL representation. + +**computed jumps** + + .. index:: computed jump, EDGE_ABNORMAL + + Computed jumps contain edges to all labels in the function referenced + from the code. All those edges have ``EDGE_ABNORMAL`` flag set. + The edges used to represent computed jumps often cause compile time + performance problems, since functions consisting of many taken labels + and many computed jumps may have *very* dense flow graphs, so + these edges need to be handled with special care. During the earlier + stages of the compilation process, GCC tries to avoid such dense flow + graphs by factoring computed jumps. For example, given the following + series of jumps, + + .. code-block:: c++ + + goto *x; + [ ... ] + + goto *x; + [ ... ] + + goto *x; + [ ... ] + + factoring the computed jumps results in the following code sequence + which has a much simpler flow graph: + + .. code-block:: c++ + + goto y; + [ ... ] + + goto y; + [ ... ] + + goto y; + [ ... ] + + y: + goto *x; + + .. index:: pass_duplicate_computed_gotos + + However, the classic problem with this transformation is that it has a + runtime cost in there resulting code: An extra jump. Therefore, the + computed jumps are un-factored in the later passes of the compiler + (in the pass called ``pass_duplicate_computed_gotos``). + Be aware of that when you work on passes in that area. There have + been numerous examples already where the compile time for code with + unfactored computed jumps caused some serious headaches. + +**nonlocal goto handlers** + + .. index:: nonlocal goto handler, EDGE_ABNORMAL, EDGE_ABNORMAL_CALL + + GCC allows nested functions to return into caller using a ``goto`` + to a label passed to as an argument to the callee. The labels passed + to nested functions contain special code to cleanup after function + call. Such sections of code are referred to as 'nonlocal goto + receivers'. If a function contains such nonlocal goto receivers, an + edge from the call to the label is created with the + ``EDGE_ABNORMAL`` and ``EDGE_ABNORMAL_CALL`` flags set. + +**function entry points** + + .. index:: function entry point, alternate function entry point, LABEL_ALTERNATE_NAME + + By definition, execution of function starts at basic block 0, so there + is always an edge from the ``ENTRY_BLOCK_PTR`` to basic block 0. + There is no ``GIMPLE`` representation for alternate entry points at + this moment. In RTL, alternate entry points are specified by + ``CODE_LABEL`` with ``LABEL_ALTERNATE_NAME`` defined. This + feature is currently used for multiple entry point prologues and is + limited to post-reload passes only. This can be used by back-ends to + emit alternate prologues for functions called from different contexts. + In future full support for multiple entry functions defined by Fortran + 90 needs to be implemented. + +**function exits** + + In the pre-reload representation a function terminates after the last + instruction in the insn chain and no explicit return instructions are + used. This corresponds to the fall-thru edge into exit block. After + reload, optimal RTL epilogues are used that use explicit (conditional) + return instructions that are represented by edges with no flags set. \ No newline at end of file diff --git a/gcc/doc/gccint/control-flow-graph/liveness-information.rst b/gcc/doc/gccint/control-flow-graph/liveness-information.rst new file mode 100644 index 00000000000..5e75a305525 --- /dev/null +++ b/gcc/doc/gccint/control-flow-graph/liveness-information.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Liveness representation + +.. _liveness-information: + +Liveness information +******************** + +Liveness information is useful to determine whether some register is +'live' at given point of program, i.e. that it contains a value that +may be used at a later point in the program. This information is +used, for instance, during register allocation, as the pseudo +registers only need to be assigned to a unique hard register or to a +stack slot if they are live. The hard registers and stack slots may +be freely reused for other values when a register is dead. + +Liveness information is available in the back end starting with +``pass_df_initialize`` and ending with ``pass_df_finish``. Three +flavors of live analysis are available: With ``LR``, it is possible +to determine at any point ``P`` in the function if the register may be +used on some path from ``P`` to the end of the function. With +``UR``, it is possible to determine if there is a path from the +beginning of the function to ``P`` that defines the variable. +``LIVE`` is the intersection of the ``LR`` and ``UR`` and a +variable is live at ``P`` if there is both an assignment that reaches +it from the beginning of the function and a use that can be reached on +some path from ``P`` to the end of the function. + +In general ``LIVE`` is the most useful of the three. The macros +``DF_[LR,UR,LIVE]_[IN,OUT]`` can be used to access this information. +The macros take a basic block number and return a bitmap that is indexed +by the register number. This information is only guaranteed to be up to +date after calls are made to ``df_analyze``. See the file +``df-core.cc`` for details on using the dataflow. + +.. index:: REG_DEAD, REG_UNUSED + +The liveness information is stored partly in the RTL instruction stream +and partly in the flow graph. Local information is stored in the +instruction stream: Each instruction may contain ``REG_DEAD`` notes +representing that the value of a given register is no longer needed, or +``REG_UNUSED`` notes representing that the value computed by the +instruction is never used. The second is useful for instructions +computing multiple values at once. \ No newline at end of file diff --git a/gcc/doc/gccint/control-flow-graph/maintaining-the-cfg.rst b/gcc/doc/gccint/control-flow-graph/maintaining-the-cfg.rst new file mode 100644 index 00000000000..9b9b51b1fc9 --- /dev/null +++ b/gcc/doc/gccint/control-flow-graph/maintaining-the-cfg.rst @@ -0,0 +1,145 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: cfghooks.h + +.. _maintaining-the-cfg: + +Maintaining the CFG +******************* + +An important task of each compiler pass is to keep both the control +flow graph and all profile information up-to-date. Reconstruction of +the control flow graph after each pass is not an option, since it may be +very expensive and lost profile information cannot be reconstructed at +all. + +GCC has two major intermediate representations, and both use the +``basic_block`` and ``edge`` data types to represent control +flow. Both representations share as much of the CFG maintenance code +as possible. For each representation, a set of :dfn:`hooks` is defined +so that each representation can provide its own implementation of CFG +manipulation routines when necessary. These hooks are defined in +:samp:`cfghooks.h`. There are hooks for almost all common CFG +manipulations, including block splitting and merging, edge redirection +and creating and deleting basic blocks. These hooks should provide +everything you need to maintain and manipulate the CFG in both the RTL +and ``GIMPLE`` representation. + +At the moment, the basic block boundaries are maintained transparently +when modifying instructions, so there rarely is a need to move them +manually (such as in case someone wants to output instruction outside +basic block explicitly). + +.. index:: BLOCK_FOR_INSN, gimple_bb + +In the RTL representation, each instruction has a +``BLOCK_FOR_INSN`` value that represents pointer to the basic block +that contains the instruction. In the ``GIMPLE`` representation, the +function ``gimple_bb`` returns a pointer to the basic block +containing the queried statement. + +.. index:: GIMPLE statement iterators + +When changes need to be applied to a function in its ``GIMPLE`` +representation, :dfn:`GIMPLE statement iterators` should be used. These +iterators provide an integrated abstraction of the flow graph and the +instruction stream. Block statement iterators are constructed using +the ``gimple_stmt_iterator`` data structure and several modifiers are +available, including the following: + +``gsi_start`` + This function initializes a ``gimple_stmt_iterator`` that points to + the first non-empty statement in a basic block. + +``gsi_last`` + This function initializes a ``gimple_stmt_iterator`` that points to + the last statement in a basic block. + +``gsi_end_p`` + This predicate is ``true`` if a ``gimple_stmt_iterator`` + represents the end of a basic block. + +``gsi_next`` + This function takes a ``gimple_stmt_iterator`` and makes it point to + its successor. + +``gsi_prev`` + This function takes a ``gimple_stmt_iterator`` and makes it point to + its predecessor. + +``gsi_insert_after`` + This function inserts a statement after the ``gimple_stmt_iterator`` + passed in. The final parameter determines whether the statement + iterator is updated to point to the newly inserted statement, or left + pointing to the original statement. + +``gsi_insert_before`` + This function inserts a statement before the ``gimple_stmt_iterator`` + passed in. The final parameter determines whether the statement + iterator is updated to point to the newly inserted statement, or left + pointing to the original statement. + +``gsi_remove`` + This function removes the ``gimple_stmt_iterator`` passed in and + rechains the remaining statements in a basic block, if any. + +.. index:: BB_HEAD, BB_END + +In the RTL representation, the macros ``BB_HEAD`` and ``BB_END`` +may be used to get the head and end ``rtx`` of a basic block. No +abstract iterators are defined for traversing the insn chain, but you +can just use ``NEXT_INSN`` and ``PREV_INSN`` instead. See :ref:`insns`. + +.. index:: purge_dead_edges + +Usually a code manipulating pass simplifies the instruction stream and +the flow of control, possibly eliminating some edges. This may for +example happen when a conditional jump is replaced with an +unconditional jump. Updating of edges +is not transparent and each optimization pass is required to do so +manually. However only few cases occur in practice. The pass may +call ``purge_dead_edges`` on a given basic block to remove +superfluous edges, if any. + +.. index:: redirect_edge_and_branch, redirect_jump + +Another common scenario is redirection of branch instructions, but +this is best modeled as redirection of edges in the control flow graph +and thus use of ``redirect_edge_and_branch`` is preferred over more +low level functions, such as ``redirect_jump`` that operate on RTL +chain only. The CFG hooks defined in :samp:`cfghooks.h` should provide +the complete API required for manipulating and maintaining the CFG. + +.. index:: split_block + +It is also possible that a pass has to insert control flow instruction +into the middle of a basic block, thus creating an entry point in the +middle of the basic block, which is impossible by definition: The +block must be split to make sure it only has one entry point, i.e. the +head of the basic block. The CFG hook ``split_block`` may be used +when an instruction in the middle of a basic block has to become the +target of a jump or branch instruction. + +.. index:: insert_insn_on_edge, commit_edge_insertions, gsi_insert_on_edge, gsi_commit_edge_inserts, edge splitting + +For a global optimizer, a common operation is to split edges in the +flow graph and insert instructions on them. In the RTL +representation, this can be easily done using the +``insert_insn_on_edge`` function that emits an instruction +'on the edge', caching it for a later ``commit_edge_insertions`` +call that will take care of moving the inserted instructions off the +edge into the instruction stream contained in a basic block. This +includes the creation of new basic blocks where needed. In the +``GIMPLE`` representation, the equivalent functions are +``gsi_insert_on_edge`` which inserts a block statement +iterator on an edge, and ``gsi_commit_edge_inserts`` which flushes +the instruction to actual instruction stream. + +.. index:: verify_flow_info, CFG verification + +While debugging the optimization pass, the ``verify_flow_info`` +function may be useful to find bugs in the control flow graph updating +code. \ No newline at end of file diff --git a/gcc/doc/gccint/control-flow-graph/profile-information.rst b/gcc/doc/gccint/control-flow-graph/profile-information.rst new file mode 100644 index 00000000000..8238f7dcc76 --- /dev/null +++ b/gcc/doc/gccint/control-flow-graph/profile-information.rst @@ -0,0 +1,112 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: profile representation + +.. _profile-information: + +Profile information +******************* + +In many cases a compiler must make a choice whether to trade speed in +one part of code for speed in another, or to trade code size for code +speed. In such cases it is useful to know information about how often +some given block will be executed. That is the purpose for +maintaining profile within the flow graph. +GCC can handle profile information obtained through :dfn:`profile +feedback`, but it can also estimate branch probabilities based on +statics and heuristics. + +.. index:: profile feedback + +The feedback based profile is produced by compiling the program with +instrumentation, executing it on a train run and reading the numbers +of executions of basic blocks and edges back to the compiler while +re-compiling the program to produce the final executable. This method +provides very accurate information about where a program spends most +of its time on the train run. Whether it matches the average run of +course depends on the choice of train data set, but several studies +have shown that the behavior of a program usually changes just +marginally over different data sets. + +.. index:: Static profile estimation, branch prediction, predict.def + +When profile feedback is not available, the compiler may be asked to +attempt to predict the behavior of each branch in the program using a +set of heuristics (see :samp:`predict.def` for details) and compute +estimated frequencies of each basic block by propagating the +probabilities over the graph. + +.. index:: frequency, count, BB_FREQ_BASE + +Each ``basic_block`` contains two integer fields to represent +profile information: ``frequency`` and ``count``. The +``frequency`` is an estimation how often is basic block executed +within a function. It is represented as an integer scaled in the +range from 0 to ``BB_FREQ_BASE``. The most frequently executed +basic block in function is initially set to ``BB_FREQ_BASE`` and +the rest of frequencies are scaled accordingly. During optimization, +the frequency of the most frequent basic block can both decrease (for +instance by loop unrolling) or grow (for instance by cross-jumping +optimization), so scaling sometimes has to be performed multiple +times. + +.. index:: gcov_type + +The ``count`` contains hard-counted numbers of execution measured +during training runs and is nonzero only when profile feedback is +available. This value is represented as the host's widest integer +(typically a 64 bit integer) of the special type ``gcov_type``. + +Most optimization passes can use only the frequency information of a +basic block, but a few passes may want to know hard execution counts. +The frequencies should always match the counts after scaling, however +during updating of the profile information numerical error may +accumulate into quite large errors. + +.. index:: REG_BR_PROB_BASE, EDGE_FREQUENCY + +Each edge also contains a branch probability field: an integer in the +range from 0 to ``REG_BR_PROB_BASE``. It represents probability of +passing control from the end of the ``src`` basic block to the +``dest`` basic block, i.e. the probability that control will flow +along this edge. The ``EDGE_FREQUENCY`` macro is available to +compute how frequently a given edge is taken. There is a ``count`` +field for each edge as well, representing same information as for a +basic block. + +The basic block frequencies are not represented in the instruction +stream, but in the RTL representation the edge frequencies are +represented for conditional jumps (via the ``REG_BR_PROB`` +macro) since they are used when instructions are output to the +assembly file and the flow graph is no longer maintained. + +.. index:: reverse probability + +The probability that control flow arrives via a given edge to its +destination basic block is called :dfn:`reverse probability` and is not +directly represented, but it may be easily computed from frequencies +of basic blocks. + +.. index:: redirect_edge_and_branch + +Updating profile information is a delicate task that can unfortunately +not be easily integrated with the CFG manipulation API. Many of the +functions and hooks to modify the CFG, such as +``redirect_edge_and_branch``, do not have enough information to +easily update the profile, so updating it is in the majority of cases +left up to the caller. It is difficult to uncover bugs in the profile +updating code, because they manifest themselves only by producing +worse code, and checking profile consistency is not possible because +of numeric error accumulation. Hence special attention needs to be +given to this issue in each pass that modifies the CFG. + +.. index:: REG_BR_PROB_BASE, BB_FREQ_BASE, count + +It is important to point out that ``REG_BR_PROB_BASE`` and +``BB_FREQ_BASE`` are both set low enough to be possible to compute +second power of any frequency or probability in the flow graph, it is +not possible to even square the ``count`` field, as modern CPUs are +fast enough to execute $2^32$ operations quickly. \ No newline at end of file diff --git a/gcc/doc/gccint/copyright.rst b/gcc/doc/gccint/copyright.rst new file mode 100644 index 00000000000..c778eb178c7 --- /dev/null +++ b/gcc/doc/gccint/copyright.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Copyright +^^^^^^^^^ + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with the +Invariant Sections being **GNU General Public License** and +**Funding Free Software**, the Front-Cover texts being (a) (see below), and with +the Back-Cover Texts being (b) (see below). A copy of the license is +in the :ref:`gnu_fdl`. + +(a) The FSF's Front-Cover Text is: + + A GNU Manual + +(b) The FSF's Back-Cover Text is: + + You have freedom to copy and modify this GNU Manual, like GNU + software. Copies published by the Free Software Foundation raise + funds for GNU development. \ No newline at end of file diff --git a/gcc/doc/gccint/debugging-the-analyzer.rst b/gcc/doc/gccint/debugging-the-analyzer.rst new file mode 100644 index 00000000000..b2ae658fb73 --- /dev/null +++ b/gcc/doc/gccint/debugging-the-analyzer.rst @@ -0,0 +1,141 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: analyzer, debugging, static analyzer, debugging + +.. _debugging-the-analyzer: + +Debugging the Analyzer +********************** + +Special Functions for Debugging the Analyzer +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The analyzer recognizes various special functions by name, for use +in debugging the analyzer. Declarations can be seen in the testsuite +in :samp:`analyzer-decls.h`. None of these functions are actually +implemented. + +Add: + +.. code-block:: c++ + + __analyzer_break (); + +to the source being analyzed to trigger a breakpoint in the analyzer when +that source is reached. By putting a series of these in the source, it's +much easier to effectively step through the program state as it's analyzed. + +The analyzer handles: + +.. code-block:: c++ + + __analyzer_describe (0, expr); + +by emitting a warning describing the 2nd argument (which can be of any +type), at a verbosity level given by the 1st argument. This is for use when +debugging, and may be of use in DejaGnu tests. + +.. code-block:: c++ + + __analyzer_dump (); + +will dump the copious information about the analyzer's state each time it +reaches the call in its traversal of the source. + +.. code-block:: c++ + + extern void __analyzer_dump_capacity (const void *ptr); + +will emit a warning describing the capacity of the base region of +the region pointed to by the 1st argument. + +.. code-block:: c++ + + extern void __analyzer_dump_escaped (void); + +will emit a warning giving the number of decls that have escaped on this +analysis path, followed by a comma-separated list of their names, +in alphabetical order. + +.. code-block:: c++ + + __analyzer_dump_path (); + +will emit a placeholder 'note' diagnostic with a path to that call site, +if the analyzer finds a feasible path to it. + +The builtin ``__analyzer_dump_exploded_nodes`` will emit a warning +after analysis containing information on all of the exploded nodes at that +program point: + +.. code-block:: c++ + + __analyzer_dump_exploded_nodes (0); + +will output the number of 'processed' nodes, and the IDs of +both 'processed' and 'merger' nodes, such as: + +.. code-block:: c++ + + warning: 2 processed enodes: [EN: 56, EN: 58] merger(s): [EN: 54-55, EN: 57, EN: 59] + +With a non-zero argument + +.. code-block:: c++ + + __analyzer_dump_exploded_nodes (1); + +it will also dump all of the states within the 'processed' nodes. + +.. code-block:: c++ + + __analyzer_dump_region_model (); + +will dump the region_model's state to stderr. + +.. code-block:: c++ + + __analyzer_dump_state ("malloc", ptr); + +will emit a warning describing the state of the 2nd argument +(which can be of any type) with respect to the state machine with +a name matching the 1st argument (which must be a string literal). +This is for use when debugging, and may be of use in DejaGnu tests. + +.. code-block:: c++ + + __analyzer_eval (expr); + +will emit a warning with text "TRUE", FALSE" or "UNKNOWN" based on the +truthfulness of the argument. This is useful for writing DejaGnu tests. + +.. code-block:: c++ + + __analyzer_get_unknown_ptr (); + +will obtain an unknown ``void *``. + +Other Debugging Techniques +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The option :option:`-fdump-analyzer-json` will dump both the supergraph +and the exploded graph in compressed JSON form. + +One approach when tracking down where a particular bogus state is +introduced into the ``exploded_graph`` is to add custom code to +``program_state::validate``. + +The debug function ``region::is_named_decl_p`` can be used when debugging, +such as for assertions and conditional breakpoints. For example, when +tracking down a bug in handling a decl called ``yy_buffer_stack``, I +temporarily added a: + +.. code-block:: c++ + + gcc_assert (!m_base_region->is_named_decl_p ("yy_buffer_stack")); + +to ``binding_cluster::mark_as_escaped`` to trap a point where +``yy_buffer_stack`` was mistakenly being treated as having escaped. \ No newline at end of file diff --git a/gcc/doc/gccint/funding.rst b/gcc/doc/gccint/funding.rst new file mode 100644 index 00000000000..04e2a26b6c9 --- /dev/null +++ b/gcc/doc/gccint/funding.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/funding.rst \ No newline at end of file diff --git a/gcc/doc/gccint/gcc-and-portability.rst b/gcc/doc/gccint/gcc-and-portability.rst new file mode 100644 index 00000000000..02a7f8da89f --- /dev/null +++ b/gcc/doc/gccint/gcc-and-portability.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: portability, GCC and portability + +.. _portability: + +GCC and Portability +------------------- + +GCC itself aims to be portable to any machine where ``int`` is at least +a 32-bit type. It aims to target machines with a flat (non-segmented) byte +addressed data address space (the code address space can be separate). +Target ABIs may have 8, 16, 32 or 64-bit ``int`` type. ``char`` +can be wider than 8 bits. + +GCC gets most of the information about the target machine from a machine +description which gives an algebraic formula for each of the machine's +instructions. This is a very clean way to describe the target. But when +the compiler needs information that is difficult to express in this +fashion, ad-hoc parameters have been defined for machine descriptions. +The purpose of portability is to reduce the total work needed on the +compiler; it was not of interest for its own sake. + +.. index:: endianness, autoincrement addressing, availability, abort + +GCC does not contain machine dependent code, but it does contain code +that depends on machine parameters such as endianness (whether the most +significant byte has the highest or lowest address of the bytes in a word) +and the availability of autoincrement addressing. In the RTL-generation +pass, it is often necessary to have multiple strategies for generating code +for a particular kind of syntax tree, strategies that are usable for different +combinations of parameters. Often, not all possible cases have been +addressed, but only the common ones or only the ones that have been +encountered. As a result, a new target may require additional +strategies. You will know +if this happens because the compiler will call ``abort``. Fortunately, +the new strategies can be added in a machine-independent fashion, and will +affect only the target machines that need them. \ No newline at end of file diff --git a/gcc/doc/gccint/general-public-license-3.rst b/gcc/doc/gccint/general-public-license-3.rst new file mode 100644 index 00000000000..becda773ca0 --- /dev/null +++ b/gcc/doc/gccint/general-public-license-3.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/gpl-3.0.rst \ No newline at end of file diff --git a/gcc/doc/gccint/generic.rst b/gcc/doc/gccint/generic.rst new file mode 100644 index 00000000000..9b644c3f821 --- /dev/null +++ b/gcc/doc/gccint/generic.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GENERIC + +.. _generic: + +GENERIC +------- + +The purpose of GENERIC is simply to provide a +language-independent way of representing an entire function in +trees. To this end, it was necessary to add a few new tree codes +to the back end, but almost everything was already there. If you +can express it with the codes in ``gcc/tree.def``, it's +GENERIC. + +Early on, there was a great deal of debate about how to think +about statements in a tree IL. In GENERIC, a statement is +defined as any expression whose value, if any, is ignored. A +statement will always have ``TREE_SIDE_EFFECTS`` set (or it +will be discarded), but a non-statement expression may also have +side effects. A ``CALL_EXPR``, for instance. + +It would be possible for some local optimizations to work on the +GENERIC form of a function; indeed, the adapted tree inliner +works fine on GENERIC, but the current compiler performs inlining +after lowering to GIMPLE (a restricted form described in the next +section). Indeed, currently the frontends perform this lowering +before handing off to ``tree_rest_of_compilation``, but this +seems inelegant. + +.. toctree:: + :maxdepth: 2 + + generic/deficiencies + generic/overview + generic/types + generic/declarations + generic/attributes-in-trees + generic/expressions + generic/statements + generic/functions + generic/language-dependent-trees + generic/c-and-c++-trees \ No newline at end of file diff --git a/gcc/doc/gccint/generic/attributes-in-trees.rst b/gcc/doc/gccint/generic/attributes-in-trees.rst new file mode 100644 index 00000000000..b3a04e9ea9a --- /dev/null +++ b/gcc/doc/gccint/generic/attributes-in-trees.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: attributes + +.. _attributes: + +Attributes in trees +******************* + +Attributes, as specified using the ``__attribute__`` keyword, are +represented internally as a ``TREE_LIST``. The ``TREE_PURPOSE`` +is the name of the attribute, as an ``IDENTIFIER_NODE``. The +``TREE_VALUE`` is a ``TREE_LIST`` of the arguments of the +attribute, if any, or ``NULL_TREE`` if there are no arguments; the +arguments are stored as the ``TREE_VALUE`` of successive entries in +the list, and may be identifiers or expressions. The ``TREE_CHAIN`` +of the attribute is the next attribute in a list of attributes applying +to the same declaration or type, or ``NULL_TREE`` if there are no +further attributes in the list. + +Attributes may be attached to declarations and to types; these +attributes may be accessed with the following macros. All attributes +are stored in this way, and many also cause other changes to the +declaration or type or to other internal compiler data structures. + +.. function:: tree DECL_ATTRIBUTES (tree decl) + + This macro returns the attributes on the declaration :samp:`{decl}`. + +.. function:: tree TYPE_ATTRIBUTES (tree type) + + This macro returns the attributes on the type :samp:`{type}`. \ No newline at end of file diff --git a/gcc/doc/gccint/generic/c-and-c++-trees.rst b/gcc/doc/gccint/generic/c-and-c++-trees.rst new file mode 100644 index 00000000000..b3edfecef2b --- /dev/null +++ b/gcc/doc/gccint/generic/c-and-c++-trees.rst @@ -0,0 +1,886 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _c-and-c++-trees: + +C and C++ Trees +*************** + +This section documents the internal representation used by GCC to +represent C and C++ source programs. When presented with a C or C++ +source program, GCC parses the program, performs semantic analysis +(including the generation of error messages), and then produces the +internal representation described here. This representation contains a +complete representation for the entire translation unit provided as +input to the front end. This representation is then typically processed +by a code-generator in order to produce machine code, but could also be +used in the creation of source browsers, intelligent editors, automatic +documentation generators, interpreters, and any other programs needing +the ability to process C or C++ code. + +This section explains the internal representation. In particular, it +documents the internal representation for C and C++ source +constructs, and the macros, functions, and variables that can be used to +access these constructs. The C++ representation is largely a superset +of the representation used in the C front end. There is only one +construct used in C that does not appear in the C++ front end and that +is the GNU 'nested function' extension. Many of the macros documented +here do not apply in C because the corresponding language constructs do +not appear in C. + +The C and C++ front ends generate a mix of GENERIC trees and ones +specific to C and C++. These language-specific trees are higher-level +constructs than the ones in GENERIC to make the parser's job easier. +This section describes those trees that aren't part of GENERIC as well +as aspects of GENERIC trees that are treated in a language-specific +manner. + +If you are developing a 'back end', be it is a code-generator or some +other tool, that uses this representation, you may occasionally find +that you need to ask questions not easily answered by the functions and +macros available here. If that situation occurs, it is quite likely +that GCC already supports the functionality you desire, but that the +interface is simply not documented here. In that case, you should ask +the GCC maintainers (via mail to gcc@gcc.gnu.org) about +documenting the functionality you require. Similarly, if you find +yourself writing functions that do not deal directly with your back end, +but instead might be useful to other people using the GCC front end, you +should submit your patches for inclusion in GCC. + +.. toctree:: + :maxdepth: 2 + + +.. _types-for-c++: + +Types for C++ +^^^^^^^^^^^^^ + +.. index:: UNKNOWN_TYPE, TYPENAME_TYPE, TYPEOF_TYPE, cp_type_quals, TYPE_UNQUALIFIED, TYPE_QUAL_CONST, TYPE_QUAL_VOLATILE, TYPE_QUAL_RESTRICT, TYPE_MAIN_VARIANT, qualified type, TYPE_SIZE, TYPE_ALIGN, TYPE_PRECISION, TYPE_ARG_TYPES, TYPE_METHOD_BASETYPE, TYPE_PTRDATAMEM_P, TYPE_OFFSET_BASETYPE, TREE_TYPE, TYPE_CONTEXT, TYPE_NAME, TYPENAME_TYPE_FULLNAME, TYPE_FIELDS, TYPE_PTROBV_P + +In C++, an array type is not qualified; rather the type of the array +elements is qualified. This situation is reflected in the intermediate +representation. The macros described here will always examine the +qualification of the underlying element type when applied to an array +type. (If the element type is itself an array, then the recursion +continues until a non-array type is found, and the qualification of this +type is examined.) So, for example, ``CP_TYPE_CONST_P`` will hold of +the type ``const int ()[7]``, denoting an array of seven ``int`` s. + +The following functions and macros deal with cv-qualification of types: + +``cp_type_quals`` + This function returns the set of type qualifiers applied to this type. + This value is ``TYPE_UNQUALIFIED`` if no qualifiers have been + applied. The ``TYPE_QUAL_CONST`` bit is set if the type is + ``const`` -qualified. The ``TYPE_QUAL_VOLATILE`` bit is set if the + type is ``volatile`` -qualified. The ``TYPE_QUAL_RESTRICT`` bit is + set if the type is ``restrict`` -qualified. + +.. envvar:: CP_TYPE_CONST_P + + This macro holds if the type is ``const`` -qualified. + +.. envvar:: CP_TYPE_VOLATILE_P + + This macro holds if the type is ``volatile`` -qualified. + +.. envvar:: CP_TYPE_RESTRICT_P + + This macro holds if the type is ``restrict`` -qualified. + +.. envvar:: CP_TYPE_CONST_NON_VOLATILE_P + + This predicate holds for a type that is ``const`` -qualified, but + *not* ``volatile`` -qualified; other cv-qualifiers are ignored as + well: only the ``const`` -ness is tested. + +A few other macros and functions are usable with all types: + +.. envvar:: TYPE_SIZE + + The number of bits required to represent the type, represented as an + ``INTEGER_CST``. For an incomplete type, ``TYPE_SIZE`` will be + ``NULL_TREE``. + +.. envvar:: TYPE_ALIGN + + The alignment of the type, in bits, represented as an ``int``. + +.. envvar:: TYPE_NAME + + This macro returns a declaration (in the form of a ``TYPE_DECL``) for + the type. (Note this macro does *not* return an + ``IDENTIFIER_NODE``, as you might expect, given its name!) You can + look at the ``DECL_NAME`` of the ``TYPE_DECL`` to obtain the + actual name of the type. The ``TYPE_NAME`` will be ``NULL_TREE`` + for a type that is not a built-in type, the result of a typedef, or a + named class type. + +.. envvar:: CP_INTEGRAL_TYPE + + This predicate holds if the type is an integral type. Notice that in + C++, enumerations are *not* integral types. + +.. envvar:: ARITHMETIC_TYPE_P + + This predicate holds if the type is an integral type (in the C++ sense) + or a floating point type. + +.. envvar:: CLASS_TYPE_P + + This predicate holds for a class-type. + +.. envvar:: TYPE_BUILT_IN + + This predicate holds for a built-in type. + +.. envvar:: TYPE_PTRDATAMEM_P + + This predicate holds if the type is a pointer to data member. + +.. envvar:: TYPE_PTR_P + + This predicate holds if the type is a pointer type, and the pointee is + not a data member. + +.. envvar:: TYPE_PTRFN_P + + This predicate holds for a pointer to function type. + +.. envvar:: TYPE_PTROB_P + + This predicate holds for a pointer to object type. Note however that it + does not hold for the generic pointer to object type ``void *``. You + may use ``TYPE_PTROBV_P`` to test for a pointer to object type as + well as ``void *``. + +The table below describes types specific to C and C++ as well as +language-dependent info about GENERIC types. + +.. envvar:: POINTER_TYPE + + Used to represent pointer types, and pointer to data member types. If + ``TREE_TYPE`` + is a pointer to data member type, then ``TYPE_PTRDATAMEM_P`` will hold. + For a pointer to data member type of the form :samp:`T X::*`, + ``TYPE_PTRMEM_CLASS_TYPE`` will be the type ``X``, while + ``TYPE_PTRMEM_POINTED_TO_TYPE`` will be the type ``T``. + +.. envvar:: RECORD_TYPE + + Used to represent ``struct`` and ``class`` types in C and C++. If + ``TYPE_PTRMEMFUNC_P`` holds, then this type is a pointer-to-member + type. In that case, the ``TYPE_PTRMEMFUNC_FN_TYPE`` is a + ``POINTER_TYPE`` pointing to a ``METHOD_TYPE``. The + ``METHOD_TYPE`` is the type of a function pointed to by the + pointer-to-member function. If ``TYPE_PTRMEMFUNC_P`` does not hold, + this type is a class type. For more information, see :ref:`classes`. + +.. envvar:: UNKNOWN_TYPE + + This node is used to represent a type the knowledge of which is + insufficient for a sound processing. + +.. envvar:: TYPENAME_TYPE + + Used to represent a construct of the form ``typename T::A``. The + ``TYPE_CONTEXT`` is ``T`` ; the ``TYPE_NAME`` is an + ``IDENTIFIER_NODE`` for ``A``. If the type is specified via a + template-id, then ``TYPENAME_TYPE_FULLNAME`` yields a + ``TEMPLATE_ID_EXPR``. The ``TREE_TYPE`` is non- ``NULL`` if the + node is implicitly generated in support for the implicit typename + extension; in which case the ``TREE_TYPE`` is a type node for the + base-class. + +.. envvar:: TYPEOF_TYPE + + Used to represent the ``__typeof__`` extension. The + ``TYPE_FIELDS`` is the expression the type of which is being + represented. + +.. - + Namespaces + - + +.. index:: namespace, scope + +.. _namespaces: + +Namespaces +^^^^^^^^^^ + +.. index:: NAMESPACE_DECL + +The root of the entire intermediate representation is the variable +``global_namespace``. This is the namespace specified with ``::`` +in C++ source code. All other namespaces, types, variables, functions, +and so forth can be found starting with this namespace. + +However, except for the fact that it is distinguished as the root of the +representation, the global namespace is no different from any other +namespace. Thus, in what follows, we describe namespaces generally, +rather than the global namespace in particular. + +A namespace is represented by a ``NAMESPACE_DECL`` node. + +The following macros and functions can be used on a ``NAMESPACE_DECL`` : + +.. envvar:: DECL_NAME + + This macro is used to obtain the ``IDENTIFIER_NODE`` corresponding to + the unqualified name of the name of the namespace (see :ref:`identifiers`). + The name of the global namespace is :samp:`::`, even though in C++ the + global namespace is unnamed. However, you should use comparison with + ``global_namespace``, rather than ``DECL_NAME`` to determine + whether or not a namespace is the global one. An unnamed namespace + will have a ``DECL_NAME`` equal to ``anonymous_namespace_name``. + Within a single translation unit, all unnamed namespaces will have the + same name. + +.. envvar:: DECL_CONTEXT + + This macro returns the enclosing namespace. The ``DECL_CONTEXT`` for + the ``global_namespace`` is ``NULL_TREE``. + +.. envvar:: DECL_NAMESPACE_ALIAS + + If this declaration is for a namespace alias, then + ``DECL_NAMESPACE_ALIAS`` is the namespace for which this one is an + alias. + + Do not attempt to use ``cp_namespace_decls`` for a namespace which is + an alias. Instead, follow ``DECL_NAMESPACE_ALIAS`` links until you + reach an ordinary, non-alias, namespace, and call + ``cp_namespace_decls`` there. + +.. envvar:: DECL_NAMESPACE_STD_P + + This predicate holds if the namespace is the special ``::std`` + namespace. + +``cp_namespace_decls`` + This function will return the declarations contained in the namespace, + including types, overloaded functions, other namespaces, and so forth. + If there are no declarations, this function will return + ``NULL_TREE``. The declarations are connected through their + ``TREE_CHAIN`` fields. + + Although most entries on this list will be declarations, + ``TREE_LIST`` nodes may also appear. In this case, the + ``TREE_VALUE`` will be an ``OVERLOAD``. The value of the + ``TREE_PURPOSE`` is unspecified; back ends should ignore this value. + As with the other kinds of declarations returned by + ``cp_namespace_decls``, the ``TREE_CHAIN`` will point to the next + declaration in this list. + + For more information on the kinds of declarations that can occur on this + list, See :ref:`declarations`. Some declarations will not appear on this + list. In particular, no ``FIELD_DECL``, ``LABEL_DECL``, or + ``PARM_DECL`` nodes will appear here. + + This function cannot be used with namespaces that have + ``DECL_NAMESPACE_ALIAS`` set. + +.. - + Classes + - + +.. index:: class, scope + +.. _classes: + +Classes +^^^^^^^ + +.. index:: RECORD_TYPE, UNION_TYPE, CLASSTYPE_DECLARED_CLASS, TYPE_BINFO, BINFO_TYPE, TYPE_FIELDS, TYPE_VFIELD + +Besides namespaces, the other high-level scoping construct in C++ is the +class. (Throughout this manual the term :dfn:`class` is used to mean the +types referred to in the ANSI/ISO C++ Standard as classes; these include +types defined with the ``class``, ``struct``, and ``union`` +keywords.) + +A class type is represented by either a ``RECORD_TYPE`` or a +``UNION_TYPE``. A class declared with the ``union`` tag is +represented by a ``UNION_TYPE``, while classes declared with either +the ``struct`` or the ``class`` tag are represented by +``RECORD_TYPE`` s. You can use the ``CLASSTYPE_DECLARED_CLASS`` +macro to discern whether or not a particular type is a ``class`` as +opposed to a ``struct``. This macro will be true only for classes +declared with the ``class`` tag. + +Almost all members are available on the ``TYPE_FIELDS`` +list. Given one member, the next can be found by following the +``TREE_CHAIN``. You should not depend in any way on the order in +which fields appear on this list. All nodes on this list will be +:samp:`DECL` nodes. A ``FIELD_DECL`` is used to represent a non-static +data member, a ``VAR_DECL`` is used to represent a static data +member, and a ``TYPE_DECL`` is used to represent a type. Note that +the ``CONST_DECL`` for an enumeration constant will appear on this +list, if the enumeration type was declared in the class. (Of course, +the ``TYPE_DECL`` for the enumeration type will appear here as well.) +There are no entries for base classes on this list. In particular, +there is no ``FIELD_DECL`` for the 'base-class portion' of an +object. If a function member is overloaded, each of the overloaded +functions appears; no ``OVERLOAD`` nodes appear on the ``TYPE_FIELDS`` +list. Implicitly declared functions (including default constructors, +copy constructors, assignment operators, and destructors) will appear on +this list as well. + +The ``TYPE_VFIELD`` is a compiler-generated field used to point to +virtual function tables. It may or may not appear on the +``TYPE_FIELDS`` list. However, back ends should handle the +``TYPE_VFIELD`` just like all the entries on the ``TYPE_FIELDS`` +list. + +Every class has an associated :dfn:`binfo`, which can be obtained with +``TYPE_BINFO``. Binfos are used to represent base-classes. The +binfo given by ``TYPE_BINFO`` is the degenerate case, whereby every +class is considered to be its own base-class. The base binfos for a +particular binfo are held in a vector, whose length is obtained with +``BINFO_N_BASE_BINFOS``. The base binfos themselves are obtained +with ``BINFO_BASE_BINFO`` and ``BINFO_BASE_ITERATE``. To add a +new binfo, use ``BINFO_BASE_APPEND``. The vector of base binfos can +be obtained with ``BINFO_BASE_BINFOS``, but normally you do not need +to use that. The class type associated with a binfo is given by +``BINFO_TYPE``. It is not always the case that ``BINFO_TYPE +(TYPE_BINFO (x))``, because of typedefs and qualified types. Neither is +it the case that ``TYPE_BINFO (BINFO_TYPE (y))`` is the same binfo as +``y``. The reason is that if ``y`` is a binfo representing a +base-class ``B`` of a derived class ``D``, then ``BINFO_TYPE +(y)`` will be ``B``, and ``TYPE_BINFO (BINFO_TYPE (y))`` will be +``B`` as its own base-class, rather than as a base-class of ``D``. + +The access to a base type can be found with ``BINFO_BASE_ACCESS``. +This will produce ``access_public_node``, ``access_private_node`` +or ``access_protected_node``. If bases are always public, +``BINFO_BASE_ACCESSES`` may be ``NULL``. + +``BINFO_VIRTUAL_P`` is used to specify whether the binfo is inherited +virtually or not. The other flags, ``BINFO_FLAG_0`` to +``BINFO_FLAG_6``, can be used for language specific use. + +The following macros can be used on a tree node representing a class-type. + +.. envvar:: LOCAL_CLASS_P + + This predicate holds if the class is local class *i.e.* declared + inside a function body. + +.. envvar:: TYPE_POLYMORPHIC_P + + This predicate holds if the class has at least one virtual function + (declared or inherited). + +.. envvar:: TYPE_HAS_DEFAULT_CONSTRUCTOR + + This predicate holds whenever its argument represents a class-type with + default constructor. + +.. envvar:: CLASSTYPE_HAS_MUTABLE + + These predicates hold for a class-type having a mutable data member. + +.. envvar:: CLASSTYPE_NON_POD_P + + This predicate holds only for class-types that are not PODs. + +.. envvar:: TYPE_HAS_NEW_OPERATOR + + This predicate holds for a class-type that defines + ``operator new``. + +.. envvar:: TYPE_HAS_ARRAY_NEW_OPERATOR + + This predicate holds for a class-type for which + ``operator new[]`` is defined. + +.. envvar:: TYPE_OVERLOADS_CALL_EXPR + + This predicate holds for class-type for which the function call + ``operator()`` is overloaded. + +.. envvar:: TYPE_OVERLOADS_ARRAY_REF + + This predicate holds for a class-type that overloads + ``operator[]`` + +.. envvar:: TYPE_OVERLOADS_ARROW + + This predicate holds for a class-type for which ``operator->`` is + overloaded. + +.. index:: function + +.. _functions-for-c++: + +Functions for C++ +^^^^^^^^^^^^^^^^^ + +.. index:: FUNCTION_DECL, OVERLOAD, OVL_CURRENT, OVL_NEXT + +A function is represented by a ``FUNCTION_DECL`` node. A set of +overloaded functions is sometimes represented by an ``OVERLOAD`` node. + +An ``OVERLOAD`` node is not a declaration, so none of the +:samp:`DECL_` macros should be used on an ``OVERLOAD``. An +``OVERLOAD`` node is similar to a ``TREE_LIST``. Use +``OVL_CURRENT`` to get the function associated with an +``OVERLOAD`` node; use ``OVL_NEXT`` to get the next +``OVERLOAD`` node in the list of overloaded functions. The macros +``OVL_CURRENT`` and ``OVL_NEXT`` are actually polymorphic; you can +use them to work with ``FUNCTION_DECL`` nodes as well as with +overloads. In the case of a ``FUNCTION_DECL``, ``OVL_CURRENT`` +will always return the function itself, and ``OVL_NEXT`` will always +be ``NULL_TREE``. + +To determine the scope of a function, you can use the +``DECL_CONTEXT`` macro. This macro will return the class +(either a ``RECORD_TYPE`` or a ``UNION_TYPE``) or namespace (a +``NAMESPACE_DECL``) of which the function is a member. For a virtual +function, this macro returns the class in which the function was +actually defined, not the base class in which the virtual declaration +occurred. + +If a friend function is defined in a class scope, the +``DECL_FRIEND_CONTEXT`` macro can be used to determine the class in +which it was defined. For example, in + +.. code-block:: c++ + + class C { friend void f() {} }; + +the ``DECL_CONTEXT`` for ``f`` will be the +``global_namespace``, but the ``DECL_FRIEND_CONTEXT`` will be the +``RECORD_TYPE`` for ``C``. + +The following macros and functions can be used on a ``FUNCTION_DECL`` : + +.. envvar:: DECL_MAIN_P + + This predicate holds for a function that is the program entry point + ``::code``. + +.. envvar:: DECL_LOCAL_FUNCTION_P + + This predicate holds if the function was declared at block scope, even + though it has a global scope. + +.. envvar:: DECL_ANTICIPATED + + This predicate holds if the function is a built-in function but its + prototype is not yet explicitly declared. + +.. envvar:: DECL_EXTERN_C_FUNCTION_P + + This predicate holds if the function is declared as an + ' ``extern "C"`` ' function. + +.. envvar:: DECL_LINKONCE_P + + This macro holds if multiple copies of this function may be emitted in + various translation units. It is the responsibility of the linker to + merge the various copies. Template instantiations are the most common + example of functions for which ``DECL_LINKONCE_P`` holds; G++ + instantiates needed templates in all translation units which require them, + and then relies on the linker to remove duplicate instantiations. + + .. todo:: This macro is not yet implemented. + +.. envvar:: DECL_FUNCTION_MEMBER_P + + This macro holds if the function is a member of a class, rather than a + member of a namespace. + +.. envvar:: DECL_STATIC_FUNCTION_P + + This predicate holds if the function a static member function. + +.. envvar:: DECL_NONSTATIC_MEMBER_FUNCTION_P + + This macro holds for a non-static member function. + +.. envvar:: DECL_CONST_MEMFUNC_P + + This predicate holds for a ``const`` -member function. + +.. envvar:: DECL_VOLATILE_MEMFUNC_P + + This predicate holds for a ``volatile`` -member function. + +.. envvar:: DECL_CONSTRUCTOR_P + + This macro holds if the function is a constructor. + +.. envvar:: DECL_NONCONVERTING_P + + This predicate holds if the constructor is a non-converting constructor. + +.. envvar:: DECL_COMPLETE_CONSTRUCTOR_P + + This predicate holds for a function which is a constructor for an object + of a complete type. + +.. envvar:: DECL_BASE_CONSTRUCTOR_P + + This predicate holds for a function which is a constructor for a base + class sub-object. + +.. envvar:: DECL_COPY_CONSTRUCTOR_P + + This predicate holds for a function which is a copy-constructor. + +.. envvar:: DECL_DESTRUCTOR_P + + This macro holds if the function is a destructor. + +.. envvar:: DECL_COMPLETE_DESTRUCTOR_P + + This predicate holds if the function is the destructor for an object a + complete type. + +.. envvar:: DECL_OVERLOADED_OPERATOR_P + + This macro holds if the function is an overloaded operator. + +.. envvar:: DECL_CONV_FN_P + + This macro holds if the function is a type-conversion operator. + +.. envvar:: DECL_GLOBAL_CTOR_P + + This predicate holds if the function is a file-scope initialization + function. + +.. envvar:: DECL_GLOBAL_DTOR_P + + This predicate holds if the function is a file-scope finalization + function. + +.. envvar:: DECL_THUNK_P + + This predicate holds if the function is a thunk. + + These functions represent stub code that adjusts the ``this`` pointer + and then jumps to another function. When the jumped-to function + returns, control is transferred directly to the caller, without + returning to the thunk. The first parameter to the thunk is always the + ``this`` pointer; the thunk should add ``THUNK_DELTA`` to this + value. (The ``THUNK_DELTA`` is an ``int``, not an + ``INTEGER_CST``.) + + Then, if ``THUNK_VCALL_OFFSET`` (an ``INTEGER_CST``) is nonzero + the adjusted ``this`` pointer must be adjusted again. The complete + calculation is given by the following pseudo-code: + + .. code-block:: c++ + + this += THUNK_DELTA + if (THUNK_VCALL_OFFSET) + this += (*((ptrdiff_t **) this))[THUNK_VCALL_OFFSET] + + Finally, the thunk should jump to the location given + by ``DECL_INITIAL`` ; this will always be an expression for the + address of a function. + +.. envvar:: DECL_NON_THUNK_FUNCTION_P + + This predicate holds if the function is *not* a thunk function. + +.. envvar:: GLOBAL_INIT_PRIORITY + + If either ``DECL_GLOBAL_CTOR_P`` or ``DECL_GLOBAL_DTOR_P`` holds, + then this gives the initialization priority for the function. The + linker will arrange that all functions for which + ``DECL_GLOBAL_CTOR_P`` holds are run in increasing order of priority + before ``main`` is called. When the program exits, all functions for + which ``DECL_GLOBAL_DTOR_P`` holds are run in the reverse order. + +.. envvar:: TYPE_RAISES_EXCEPTIONS + + This macro returns the list of exceptions that a (member-)function can + raise. The returned list, if non ``NULL``, is comprised of nodes + whose ``TREE_VALUE`` represents a type. + +.. envvar:: TYPE_NOTHROW_P + + This predicate holds when the exception-specification of its arguments + is of the form ' ``()`` '. + +.. envvar:: DECL_ARRAY_DELETE_OPERATOR_P + + This predicate holds if the function an overloaded + ``operator delete[]``. + +.. - + Function Bodies + - + +.. index:: statements + +.. _statements-for-c-and-c++: + +Statements for C and C++ +^^^^^^^^^^^^^^^^^^^^^^^^ + +.. index:: BREAK_STMT, CLEANUP_STMT, CLEANUP_DECL, CLEANUP_EXPR, CONTINUE_STMT, DECL_STMT, DECL_STMT_DECL, DO_STMT, DO_BODY, DO_COND, EMPTY_CLASS_EXPR, EXPR_STMT, EXPR_STMT_EXPR, FOR_STMT, FOR_INIT_STMT, FOR_COND, FOR_EXPR, FOR_BODY, HANDLER, IF_STMT, IF_COND, THEN_CLAUSE, ELSE_CLAUSE, RETURN_STMT, RETURN_EXPR, SUBOBJECT, SUBOBJECT_CLEANUP, SWITCH_STMT, SWITCH_COND, SWITCH_BODY, TRY_BLOCK, TRY_STMTS, TRY_HANDLERS, HANDLER_PARMS, HANDLER_BODY, USING_STMT, WHILE_STMT, WHILE_BODY, WHILE_COND + +A function that has a definition in the current translation unit has +a non- ``NULL`` ``DECL_INITIAL``. However, back ends should not make +use of the particular value given by ``DECL_INITIAL``. + +The ``DECL_SAVED_TREE`` gives the complete body of the +function. + +There are tree nodes corresponding to all of the source-level +statement constructs, used within the C and C++ frontends. These are +enumerated here, together with a list of the various macros that can +be used to obtain information about them. There are a few macros that +can be used with all statements: + +.. envvar:: STMT_IS_FULL_EXPR_P + + In C++, statements normally constitute 'full expressions'; temporaries + created during a statement are destroyed when the statement is complete. + However, G++ sometimes represents expressions by statements; these + statements will not have ``STMT_IS_FULL_EXPR_P`` set. Temporaries + created during such statements should be destroyed when the innermost + enclosing statement with ``STMT_IS_FULL_EXPR_P`` set is exited. + +Here is the list of the various statement nodes, and the macros used to +access them. This documentation describes the use of these nodes in +non-template functions (including instantiations of template functions). +In template functions, the same nodes are used, but sometimes in +slightly different ways. + +Many of the statements have substatements. For example, a ``while`` +loop has a body, which is itself a statement. If the substatement +is ``NULL_TREE``, it is considered equivalent to a statement +consisting of a single ``;``, i.e., an expression statement in which +the expression has been omitted. A substatement may in fact be a list +of statements, connected via their ``TREE_CHAIN`` s. So, you should +always process the statement tree by looping over substatements, like +this: + +.. code-block:: c++ + + void process_stmt (stmt) + tree stmt; + { + while (stmt) + { + switch (TREE_CODE (stmt)) + { + case IF_STMT: + process_stmt (THEN_CLAUSE (stmt)); + /* More processing here. */ + break; + + ... + } + + stmt = TREE_CHAIN (stmt); + } + } + +In other words, while the ``then`` clause of an ``if`` statement +in C++ can be only one statement (although that one statement may be a +compound statement), the intermediate representation sometimes uses +several statements chained together. + +.. envvar:: BREAK_STMT + + Used to represent a ``break`` statement. There are no additional + fields. + +.. envvar:: CLEANUP_STMT + + Used to represent an action that should take place upon exit from the + enclosing scope. Typically, these actions are calls to destructors for + local objects, but back ends cannot rely on this fact. If these nodes + are in fact representing such destructors, ``CLEANUP_DECL`` will be + the ``VAR_DECL`` destroyed. Otherwise, ``CLEANUP_DECL`` will be + ``NULL_TREE``. In any case, the ``CLEANUP_EXPR`` is the + expression to execute. The cleanups executed on exit from a scope + should be run in the reverse order of the order in which the associated + ``CLEANUP_STMT`` s were encountered. + +.. envvar:: CONTINUE_STMT + + Used to represent a ``continue`` statement. There are no additional + fields. + +.. envvar:: CTOR_STMT + + Used to mark the beginning (if ``CTOR_BEGIN_P`` holds) or end (if + ``CTOR_END_P`` holds of the main body of a constructor. See also + ``SUBOBJECT`` for more information on how to use these nodes. + +.. envvar:: DO_STMT + + Used to represent a ``do`` loop. The body of the loop is given by + ``DO_BODY`` while the termination condition for the loop is given by + ``DO_COND``. The condition for a ``do`` -statement is always an + expression. + +.. envvar:: EMPTY_CLASS_EXPR + + Used to represent a temporary object of a class with no data whose + address is never taken. (All such objects are interchangeable.) The + ``TREE_TYPE`` represents the type of the object. + +.. envvar:: EXPR_STMT + + Used to represent an expression statement. Use ``EXPR_STMT_EXPR`` to + obtain the expression. + +.. envvar:: FOR_STMT + + Used to represent a ``for`` statement. The ``FOR_INIT_STMT`` is + the initialization statement for the loop. The ``FOR_COND`` is the + termination condition. The ``FOR_EXPR`` is the expression executed + right before the ``FOR_COND`` on each loop iteration; often, this + expression increments a counter. The body of the loop is given by + ``FOR_BODY``. ``FOR_SCOPE`` holds the scope of the ``for`` + statement (used in the C++ front end only). Note that + ``FOR_INIT_STMT`` and ``FOR_BODY`` return statements, while + ``FOR_COND`` and ``FOR_EXPR`` return expressions. + +.. envvar:: HANDLER + + Used to represent a C++ ``catch`` block. The ``HANDLER_TYPE`` + is the type of exception that will be caught by this handler; it is + equal (by pointer equality) to ``NULL`` if this handler is for all + types. ``HANDLER_PARMS`` is the ``DECL_STMT`` for the catch + parameter, and ``HANDLER_BODY`` is the code for the block itself. + +.. envvar:: IF_STMT + + Used to represent an ``if`` statement. The ``IF_COND`` is the + expression. + + If the condition is a ``TREE_LIST``, then the ``TREE_PURPOSE`` is + a statement (usually a ``DECL_STMT``). Each time the condition is + evaluated, the statement should be executed. Then, the + ``TREE_VALUE`` should be used as the conditional expression itself. + This representation is used to handle C++ code like this: + + .. code-block:: c++ + + if (int i = 7) ... + + where there is a new local variable (or variables) declared within the + condition. + + The ``THEN_CLAUSE`` represents the statement given by the ``then`` + condition, while the ``ELSE_CLAUSE`` represents the statement given + by the ``else`` condition. + + C++ distinguishes between this and ``COND_EXPR`` for handling templates. + +.. envvar:: SUBOBJECT + + In a constructor, these nodes are used to mark the point at which a + subobject of ``this`` is fully constructed. If, after this point, an + exception is thrown before a ``CTOR_STMT`` with ``CTOR_END_P`` set + is encountered, the ``SUBOBJECT_CLEANUP`` must be executed. The + cleanups must be executed in the reverse order in which they appear. + +.. envvar:: SWITCH_STMT + + Used to represent a ``switch`` statement. The ``SWITCH_STMT_COND`` + is the expression on which the switch is occurring. See the documentation + for an ``IF_STMT`` for more information on the representation used + for the condition. The ``SWITCH_STMT_BODY`` is the body of the switch + statement. The ``SWITCH_STMT_TYPE`` is the original type of switch + expression as given in the source, before any compiler conversions. + The ``SWITCH_STMT_SCOPE`` is the statement scope (used in the + C++ front end only). + + There are also two boolean flags used with ``SWITCH_STMT``. + ``SWITCH_STMT_ALL_CASES_P`` is true if the switch includes a default label + or the case label ranges cover all possible values of the condition + expression. ``SWITCH_STMT_NO_BREAK_P`` is true if there are no + ``break`` statements in the switch. + +.. envvar:: TRY_BLOCK + + Used to represent a ``try`` block. The body of the try block is + given by ``TRY_STMTS``. Each of the catch blocks is a ``HANDLER`` + node. The first handler is given by ``TRY_HANDLERS``. Subsequent + handlers are obtained by following the ``TREE_CHAIN`` link from one + handler to the next. The body of the handler is given by + ``HANDLER_BODY``. + + If ``CLEANUP_P`` holds of the ``TRY_BLOCK``, then the + ``TRY_HANDLERS`` will not be a ``HANDLER`` node. Instead, it will + be an expression that should be executed if an exception is thrown in + the try block. It must rethrow the exception after executing that code. + And, if an exception is thrown while the expression is executing, + ``terminate`` must be called. + +.. envvar:: USING_STMT + + Used to represent a ``using`` directive. The namespace is given by + ``USING_STMT_NAMESPACE``, which will be a NAMESPACE_DECL. This node + is needed inside template functions, to implement using directives + during instantiation. + +.. envvar:: WHILE_STMT + + Used to represent a ``while`` loop. The ``WHILE_COND`` is the + termination condition for the loop. See the documentation for an + ``IF_STMT`` for more information on the representation used for the + condition. + + The ``WHILE_BODY`` is the body of the loop. + +.. _c++-expressions: + +C++ Expressions +^^^^^^^^^^^^^^^ + +This section describes expressions specific to the C and C++ front +ends. + +.. envvar:: TYPEID_EXPR + + Used to represent a ``typeid`` expression. + +.. envvar:: NEW_EXPR + + Used to represent a call to ``new`` and ``new[]`` respectively. + +.. envvar:: DELETE_EXPR + + Used to represent a call to ``delete`` and ``delete[]`` respectively. + +.. envvar:: MEMBER_REF + + Represents a reference to a member of a class. + +.. envvar:: THROW_EXPR + + Represents an instance of ``throw`` in the program. Operand 0, + which is the expression to throw, may be ``NULL_TREE``. + +.. envvar:: AGGR_INIT_EXPR + + An ``AGGR_INIT_EXPR`` represents the initialization as the return + value of a function call, or as the result of a constructor. An + ``AGGR_INIT_EXPR`` will only appear as a full-expression, or as the + second operand of a ``TARGET_EXPR``. ``AGGR_INIT_EXPR`` s have + a representation similar to that of ``CALL_EXPR`` s. You can use + the ``AGGR_INIT_EXPR_FN`` and ``AGGR_INIT_EXPR_ARG`` macros to access + the function to call and the arguments to pass. + + If ``AGGR_INIT_VIA_CTOR_P`` holds of the ``AGGR_INIT_EXPR``, then + the initialization is via a constructor call. The address of the + ``AGGR_INIT_EXPR_SLOT`` operand, which is always a ``VAR_DECL``, + is taken, and this value replaces the first argument in the argument + list. + + In either case, the expression is void. \ No newline at end of file diff --git a/gcc/doc/gccint/generic/declarations.rst b/gcc/doc/gccint/generic/declarations.rst new file mode 100644 index 00000000000..71307ad2a75 --- /dev/null +++ b/gcc/doc/gccint/generic/declarations.rst @@ -0,0 +1,346 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: declaration, variable, type declaration + +.. _declarations: + +Declarations +************ + +.. index:: LABEL_DECL, CONST_DECL, TYPE_DECL, VAR_DECL, PARM_DECL, DEBUG_EXPR_DECL, FIELD_DECL, NAMESPACE_DECL, RESULT_DECL, TEMPLATE_DECL, THUNK_DECL, THUNK_DELTA, DECL_INITIAL, DECL_SIZE, DECL_ALIGN, DECL_EXTERNAL + +This section covers the various kinds of declarations that appear in the +internal representation, except for declarations of functions +(represented by ``FUNCTION_DECL`` nodes), which are described in +:ref:`functions`. + +.. toctree:: + :maxdepth: 2 + + +.. _working-with-declarations: + +Working with declarations +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Some macros can be used with any kind of declaration. These include: + +.. envvar:: DECL_NAME + + This macro returns an ``IDENTIFIER_NODE`` giving the name of the + entity. + +.. envvar:: TREE_TYPE + + This macro returns the type of the entity declared. + +.. envvar:: EXPR_FILENAME + + This macro returns the name of the file in which the entity was + declared, as a ``char*``. For an entity declared implicitly by the + compiler (like ``__builtin_memcpy``), this will be the string + ``""``. + +.. envvar:: EXPR_LINENO + + This macro returns the line number at which the entity was declared, as + an ``int``. + +.. envvar:: DECL_ARTIFICIAL + + This predicate holds if the declaration was implicitly generated by the + compiler. For example, this predicate will hold of an implicitly + declared member function, or of the ``TYPE_DECL`` implicitly + generated for a class type. Recall that in C++ code like: + + .. code-block:: c++ + + struct S {}; + + is roughly equivalent to C code like: + + .. code-block:: c++ + + struct S {}; + typedef struct S S; + + The implicitly generated ``typedef`` declaration is represented by a + ``TYPE_DECL`` for which ``DECL_ARTIFICIAL`` holds. + +The various kinds of declarations include: + +.. envvar:: LABEL_DECL + + These nodes are used to represent labels in function bodies. For more + information, see :ref:`functions`. These nodes only appear in block + scopes. + +.. envvar:: CONST_DECL + + These nodes are used to represent enumeration constants. The value of + the constant is given by ``DECL_INITIAL`` which will be an + ``INTEGER_CST`` with the same type as the ``TREE_TYPE`` of the + ``CONST_DECL``, i.e., an ``ENUMERAL_TYPE``. + +.. envvar:: RESULT_DECL + + These nodes represent the value returned by a function. When a value is + assigned to a ``RESULT_DECL``, that indicates that the value should + be returned, via bitwise copy, by the function. You can use + ``DECL_SIZE`` and ``DECL_ALIGN`` on a ``RESULT_DECL``, just as + with a ``VAR_DECL``. + +.. envvar:: TYPE_DECL + + These nodes represent ``typedef`` declarations. The ``TREE_TYPE`` + is the type declared to have the name given by ``DECL_NAME``. In + some cases, there is no associated name. + +.. envvar:: VAR_DECL + + These nodes represent variables with namespace or block scope, as well + as static data members. The ``DECL_SIZE`` and ``DECL_ALIGN`` are + analogous to ``TYPE_SIZE`` and ``TYPE_ALIGN``. For a declaration, + you should always use the ``DECL_SIZE`` and ``DECL_ALIGN`` rather + than the ``TYPE_SIZE`` and ``TYPE_ALIGN`` given by the + ``TREE_TYPE``, since special attributes may have been applied to the + variable to give it a particular size and alignment. You may use the + predicates ``DECL_THIS_STATIC`` or ``DECL_THIS_EXTERN`` to test + whether the storage class specifiers ``static`` or ``extern`` were + used to declare a variable. + + If this variable is initialized (but does not require a constructor), + the ``DECL_INITIAL`` will be an expression for the initializer. The + initializer should be evaluated, and a bitwise copy into the variable + performed. If the ``DECL_INITIAL`` is the ``error_mark_node``, + there is an initializer, but it is given by an explicit statement later + in the code; no bitwise copy is required. + + GCC provides an extension that allows either automatic variables, or + global variables, to be placed in particular registers. This extension + is being used for a particular ``VAR_DECL`` if ``DECL_REGISTER`` + holds for the ``VAR_DECL``, and if ``DECL_ASSEMBLER_NAME`` is not + equal to ``DECL_NAME``. In that case, ``DECL_ASSEMBLER_NAME`` is + the name of the register into which the variable will be placed. + +.. envvar:: PARM_DECL + + Used to represent a parameter to a function. Treat these nodes + similarly to ``VAR_DECL`` nodes. These nodes only appear in the + ``DECL_ARGUMENTS`` for a ``FUNCTION_DECL``. + + The ``DECL_ARG_TYPE`` for a ``PARM_DECL`` is the type that will + actually be used when a value is passed to this function. It may be a + wider type than the ``TREE_TYPE`` of the parameter; for example, the + ordinary type might be ``short`` while the ``DECL_ARG_TYPE`` is + ``int``. + +.. envvar:: DEBUG_EXPR_DECL + + Used to represent an anonymous debug-information temporary created to + hold an expression as it is optimized away, so that its value can be + referenced in debug bind statements. + +.. envvar:: FIELD_DECL + + These nodes represent non-static data members. The ``DECL_SIZE`` and + ``DECL_ALIGN`` behave as for ``VAR_DECL`` nodes. + The position of the field within the parent record is specified by a + combination of three attributes. ``DECL_FIELD_OFFSET`` is the position, + counting in bytes, of the ``DECL_OFFSET_ALIGN`` -bit sized word containing + the bit of the field closest to the beginning of the structure. + ``DECL_FIELD_BIT_OFFSET`` is the bit offset of the first bit of the field + within this word; this may be nonzero even for fields that are not bit-fields, + since ``DECL_OFFSET_ALIGN`` may be greater than the natural alignment + of the field's type. + + If ``DECL_C_BIT_FIELD`` holds, this field is a bit-field. In a bit-field, + ``DECL_BIT_FIELD_TYPE`` also contains the type that was originally + specified for it, while DECL_TYPE may be a modified type with lesser precision, + according to the size of the bit field. + +.. envvar:: NAMESPACE_DECL + + Namespaces provide a name hierarchy for other declarations. They + appear in the ``DECL_CONTEXT`` of other ``_DECL`` nodes. + +.. _internal-structure: + +Internal structure +^^^^^^^^^^^^^^^^^^ + +``DECL`` nodes are represented internally as a hierarchy of +structures. + +.. toctree:: + :maxdepth: 2 + + +.. _current-structure-hierarchy: + +Current structure hierarchy +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``struct tree_decl_minimal`` + This is the minimal structure to inherit from in order for common + ``DECL`` macros to work. The fields it contains are a unique ID, + source location, context, and name. + +``struct tree_decl_common`` + This structure inherits from ``struct tree_decl_minimal``. It + contains fields that most ``DECL`` nodes need, such as a field to + store alignment, machine mode, size, and attributes. + +``struct tree_field_decl`` + This structure inherits from ``struct tree_decl_common``. It is + used to represent ``FIELD_DECL``. + +``struct tree_label_decl`` + This structure inherits from ``struct tree_decl_common``. It is + used to represent ``LABEL_DECL``. + +``struct tree_translation_unit_decl`` + This structure inherits from ``struct tree_decl_common``. It is + used to represent ``TRANSLATION_UNIT_DECL``. + +``struct tree_decl_with_rtl`` + This structure inherits from ``struct tree_decl_common``. It + contains a field to store the low-level RTL associated with a + ``DECL`` node. + +``struct tree_result_decl`` + This structure inherits from ``struct tree_decl_with_rtl``. It is + used to represent ``RESULT_DECL``. + +``struct tree_const_decl`` + This structure inherits from ``struct tree_decl_with_rtl``. It is + used to represent ``CONST_DECL``. + +``struct tree_parm_decl`` + This structure inherits from ``struct tree_decl_with_rtl``. It is + used to represent ``PARM_DECL``. + +``struct tree_decl_with_vis`` + This structure inherits from ``struct tree_decl_with_rtl``. It + contains fields necessary to store visibility information, as well as + a section name and assembler name. + +``struct tree_var_decl`` + This structure inherits from ``struct tree_decl_with_vis``. It is + used to represent ``VAR_DECL``. + +``struct tree_function_decl`` + This structure inherits from ``struct tree_decl_with_vis``. It is + used to represent ``FUNCTION_DECL``. + +.. _adding-new-decl-node-types: + +Adding new DECL node types +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Adding a new ``DECL`` tree consists of the following steps + +:samp:`Add a new tree code for the {DECL} node` + For language specific ``DECL`` nodes, there is a :samp:`.def` file + in each frontend directory where the tree code should be added. + For ``DECL`` nodes that are part of the middle-end, the code should + be added to :samp:`tree.def`. + +:samp:`Create a new structure type for the {DECL} node` + These structures should inherit from one of the existing structures in + the language hierarchy by using that structure as the first member. + + .. code-block:: c++ + + struct tree_foo_decl + { + struct tree_decl_with_vis common; + } + + Would create a structure name ``tree_foo_decl`` that inherits from + ``struct tree_decl_with_vis``. + + For language specific ``DECL`` nodes, this new structure type + should go in the appropriate :samp:`.h` file. + For ``DECL`` nodes that are part of the middle-end, the structure + type should go in :samp:`tree.h`. + +Add a member to the tree structure enumerator for the node + For garbage collection and dynamic checking purposes, each ``DECL`` + node structure type is required to have a unique enumerator value + specified with it. + For language specific ``DECL`` nodes, this new enumerator value + should go in the appropriate :samp:`.def` file. + For ``DECL`` nodes that are part of the middle-end, the enumerator + values are specified in :samp:`treestruct.def`. + +:samp:`Update {union tree_node}` + In order to make your new structure type usable, it must be added to + ``union tree_node``. + For language specific ``DECL`` nodes, a new entry should be added + to the appropriate :samp:`.h` file of the form + + .. code-block:: c++ + + struct tree_foo_decl GTY ((tag ("TS_VAR_DECL"))) foo_decl; + + For ``DECL`` nodes that are part of the middle-end, the additional + member goes directly into ``union tree_node`` in :samp:`tree.h`. + +Update dynamic checking info + In order to be able to check whether accessing a named portion of + ``union tree_node`` is legal, and whether a certain ``DECL`` node + contains one of the enumerated ``DECL`` node structures in the + hierarchy, a simple lookup table is used. + This lookup table needs to be kept up to date with the tree structure + hierarchy, or else checking and containment macros will fail + inappropriately. + + For language specific ``DECL`` nodes, there is an ``init_ts`` + function in an appropriate :samp:`.c` file, which initializes the lookup + table. + Code setting up the table for new ``DECL`` nodes should be added + there. + For each ``DECL`` tree code and enumerator value representing a + member of the inheritance hierarchy, the table should contain 1 if + that tree code inherits (directly or indirectly) from that member. + Thus, a ``FOO_DECL`` node derived from ``struct decl_with_rtl``, + and enumerator value ``TS_FOO_DECL``, would be set up as follows + + .. code-block:: c++ + + tree_contains_struct[FOO_DECL][TS_FOO_DECL] = 1; + tree_contains_struct[FOO_DECL][TS_DECL_WRTL] = 1; + tree_contains_struct[FOO_DECL][TS_DECL_COMMON] = 1; + tree_contains_struct[FOO_DECL][TS_DECL_MINIMAL] = 1; + + For ``DECL`` nodes that are part of the middle-end, the setup code + goes into :samp:`tree.cc`. + +Add macros to access any new fields and flags + Each added field or flag should have a macro that is used to access + it, that performs appropriate checking to ensure only the right type of + ``DECL`` nodes access the field. + + These macros generally take the following form + + .. code-block:: c++ + + #define FOO_DECL_FIELDNAME(NODE) FOO_DECL_CHECK(NODE)->foo_decl.fieldname + + However, if the structure is simply a base class for further + structures, something like the following should be used + + .. code-block:: c++ + + #define BASE_STRUCT_CHECK(T) CONTAINS_STRUCT_CHECK(T, TS_BASE_STRUCT) + #define BASE_STRUCT_FIELDNAME(NODE) \ + (BASE_STRUCT_CHECK(NODE)->base_struct.fieldname + + Reading them from the generated :samp:`all-tree.def` file (which in + turn includes all the :samp:`tree.def` files), :samp:`gencheck.cc` is + used during GCC's build to generate the ``*_CHECK`` macros for all + tree codes. \ No newline at end of file diff --git a/gcc/doc/gccint/generic/deficiencies.rst b/gcc/doc/gccint/generic/deficiencies.rst new file mode 100644 index 00000000000..05a3575d0b4 --- /dev/null +++ b/gcc/doc/gccint/generic/deficiencies.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _deficiencies: + +Deficiencies +************ + +.. The spelling of "incomplet" and "incorrekt" below is intentional. + +There are many places in which this document is incomplet and incorrekt. +It is, as of yet, only *preliminary* documentation. \ No newline at end of file diff --git a/gcc/doc/gccint/generic/expressions.rst b/gcc/doc/gccint/generic/expressions.rst new file mode 100644 index 00000000000..8c3e623caa3 --- /dev/null +++ b/gcc/doc/gccint/generic/expressions.rst @@ -0,0 +1,910 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: expression, TREE_TYPE, TREE_OPERAND + +.. _expression-trees: + +Expressions +*********** + +The internal representation for expressions is for the most part quite +straightforward. However, there are a few facts that one must bear in +mind. In particular, the expression 'tree' is actually a directed +acyclic graph. (For example there may be many references to the integer +constant zero throughout the source program; many of these will be +represented by the same expression node.) You should not rely on +certain kinds of node being shared, nor should you rely on certain kinds of +nodes being unshared. + +The following macros can be used with all expression nodes: + +.. envvar:: TREE_TYPE + + Returns the type of the expression. This value may not be precisely the + same type that would be given the expression in the original program. + +In what follows, some nodes that one might expect to always have type +``bool`` are documented to have either integral or boolean type. At +some point in the future, the C front end may also make use of this same +intermediate representation, and at this point these nodes will +certainly have integral type. The previous sentence is not meant to +imply that the C++ front end does not or will not give these nodes +integral type. + +Below, we list the various kinds of expression nodes. Except where +noted otherwise, the operands to an expression are accessed using the +``TREE_OPERAND`` macro. For example, to access the first operand to +a binary plus expression ``expr``, use: + +.. code-block:: c++ + + TREE_OPERAND (expr, 0) + +As this example indicates, the operands are zero-indexed. + +.. toctree:: + :maxdepth: 2 + + +.. _constant-expressions: + +Constant expressions +^^^^^^^^^^^^^^^^^^^^ + +.. index:: INTEGER_CST, tree_int_cst_lt, tree_int_cst_equal, tree_fits_uhwi_p, tree_fits_shwi_p, tree_to_uhwi, tree_to_shwi, TREE_INT_CST_NUNITS, TREE_INT_CST_ELT, TREE_INT_CST_LOW, REAL_CST, FIXED_CST, COMPLEX_CST, VECTOR_CST, STRING_CST, POLY_INT_CST, TREE_STRING_LENGTH, TREE_STRING_POINTER + +The table below begins with constants, moves on to unary expressions, +then proceeds to binary expressions, and concludes with various other +kinds of expressions: + +.. envvar:: INTEGER_CST + + These nodes represent integer constants. Note that the type of these + constants is obtained with ``TREE_TYPE`` ; they are not always of type + ``int``. In particular, ``char`` constants are represented with + ``INTEGER_CST`` nodes. The value of the integer constant ``e`` is + represented in an array of HOST_WIDE_INT. There are enough elements + in the array to represent the value without taking extra elements for + redundant 0s or -1. The number of elements used to represent ``e`` + is available via ``TREE_INT_CST_NUNITS``. Element ``i`` can be + extracted by using ``TREE_INT_CST_ELT (e, i)``. + ``TREE_INT_CST_LOW`` is a shorthand for ``TREE_INT_CST_ELT (e, 0)``. + + The functions ``tree_fits_shwi_p`` and ``tree_fits_uhwi_p`` + can be used to tell if the value is small enough to fit in a + signed HOST_WIDE_INT or an unsigned HOST_WIDE_INT respectively. + The value can then be extracted using ``tree_to_shwi`` and + ``tree_to_uhwi``. + +.. envvar:: REAL_CST + + .. todo:: Talk about how to obtain representations of this constant, do + comparisons, and so forth. + +.. envvar:: FIXED_CST + + These nodes represent fixed-point constants. The type of these constants + is obtained with ``TREE_TYPE``. ``TREE_FIXED_CST_PTR`` points to + a ``struct fixed_value`` ; ``TREE_FIXED_CST`` returns the structure + itself. ``struct fixed_value`` contains ``data`` with the size of two + ``HOST_BITS_PER_WIDE_INT`` and ``mode`` as the associated fixed-point + machine mode for ``data``. + +.. envvar:: COMPLEX_CST + + These nodes are used to represent complex number constants, that is a + ``__complex__`` whose parts are constant nodes. The + ``TREE_REALPART`` and ``TREE_IMAGPART`` return the real and the + imaginary parts respectively. + +.. envvar:: VECTOR_CST + + These nodes are used to represent vector constants. Each vector + constant :samp:`{v}` is treated as a specific instance of an arbitrary-length + sequence that itself contains :samp:`VECTOR_CST_NPATTERNS ({v})` + interleaved patterns. Each pattern has the form: + + .. code-block:: c++ + + { base0, base1, base1 + step, base1 + step * 2, ... } + + The first three elements in each pattern are enough to determine the + values of the other elements. However, if all :samp:`{step}` s are zero, + only the first two elements are needed. If in addition each :samp:`{base1}` + is equal to the corresponding :samp:`{base0}`, only the first element in + each pattern is needed. The number of encoded elements per pattern + is given by :samp:`VECTOR_CST_NELTS_PER_PATTERN ({v})`. + + For example, the constant: + + .. code-block:: c++ + + { 0, 1, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18 } + + is interpreted as an interleaving of the sequences: + + .. code-block:: c++ + + { 0, 2, 3, 4, 5, 6, 7, 8 } + { 1, 6, 8, 10, 12, 14, 16, 18 } + + where the sequences are represented by the following patterns: + + .. code-block:: c++ + + base0 == 0, base1 == 2, step == 1 + base0 == 1, base1 == 6, step == 2 + + In this case: + + .. code-block:: c++ + + VECTOR_CST_NPATTERNS (v) == 2 + VECTOR_CST_NELTS_PER_PATTERN (v) == 3 + + The vector is therefore encoded using the first 6 elements + (:samp:`{ 0, 1, 2, 6, 3, 8 }`), with the remaining 10 elements + being implicit extensions of them. + + Sometimes this scheme can create two possible encodings of the same + vector. For example { 0, 1 } could be seen as two patterns with + one element each or one pattern with two elements (:samp:`{base0}` and + :samp:`{base1}`). The canonical encoding is always the one with the + fewest patterns or (if both encodings have the same number of + petterns) the one with the fewest encoded elements. + + :samp:`vector_cst_encoding_nelts ({v})` gives the total number of + encoded elements in :samp:`{v}`, which is 6 in the example above. + ``VECTOR_CST_ENCODED_ELTS (v)`` gives a pointer to the elements + encoded in :samp:`{v}` and ``VECTOR_CST_ENCODED_ELT (v, i)`` + accesses the value of encoded element :samp:`{i}`. + + :samp:`VECTOR_CST_DUPLICATE_P ({v})` is true if :samp:`{v}` simply contains + repeated instances of :samp:`VECTOR_CST_NPATTERNS ({v})` values. This is + a shorthand for testing :samp:`VECTOR_CST_NELTS_PER_PATTERN ({v}) == 1`. + + :samp:`VECTOR_CST_STEPPED_P ({v})` is true if at least one + pattern in :samp:`{v}` has a nonzero step. This is a shorthand for + testing :samp:`VECTOR_CST_NELTS_PER_PATTERN ({v}) == 3`. + + The utility function ``vector_cst_elt`` gives the value of an + arbitrary index as a ``tree``. ``vector_cst_int_elt`` gives + the same value as a ``wide_int``. + +.. envvar:: STRING_CST + + These nodes represent string-constants. The ``TREE_STRING_LENGTH`` + returns the length of the string, as an ``int``. The + ``TREE_STRING_POINTER`` is a ``char*`` containing the string + itself. The string may not be ``NUL`` -terminated, and it may contain + embedded ``NUL`` characters. Therefore, the + ``TREE_STRING_LENGTH`` includes the trailing ``NUL`` if it is + present. + + For wide string constants, the ``TREE_STRING_LENGTH`` is the number + of bytes in the string, and the ``TREE_STRING_POINTER`` + points to an array of the bytes of the string, as represented on the + target system (that is, as integers in the target endianness). Wide and + non-wide string constants are distinguished only by the ``TREE_TYPE`` + of the ``STRING_CST``. + + .. todo:: The formats of string constants are not well-defined when the + target system bytes are not the same width as host system bytes. + +.. envvar:: POLY_INT_CST + + These nodes represent invariants that depend on some target-specific + runtime parameters. They consist of ``NUM_POLY_INT_COEFFS`` + coefficients, with the first coefficient being the constant term and + the others being multipliers that are applied to the runtime parameters. + + ``POLY_INT_CST_ELT (x, i)`` references coefficient number + :samp:`{i}` of ``POLY_INT_CST`` node :samp:`{x}`. Each coefficient is an + ``INTEGER_CST``. + +.. _storage-references: + +References to storage +^^^^^^^^^^^^^^^^^^^^^ + +.. index:: ADDR_EXPR, INDIRECT_REF, MEM_REF, ARRAY_REF, ARRAY_RANGE_REF, TARGET_MEM_REF, COMPONENT_REF + +.. envvar:: ARRAY_REF + + These nodes represent array accesses. The first operand is the array; + the second is the index. To calculate the address of the memory + accessed, you must scale the index by the size of the type of the array + elements. The type of these expressions must be the type of a component of + the array. The third and fourth operands are used after gimplification + to represent the lower bound and component size but should not be used + directly; call ``array_ref_low_bound`` and ``array_ref_element_size`` + instead. + +.. envvar:: ARRAY_RANGE_REF + + These nodes represent access to a range (or 'slice') of an array. The + operands are the same as that for ``ARRAY_REF`` and have the same + meanings. The type of these expressions must be an array whose component + type is the same as that of the first operand. The range of that array + type determines the amount of data these expressions access. + +.. envvar:: COMPONENT_REF + + These nodes represent non-static data member accesses. The first + operand is the object (rather than a pointer to it); the second operand + is the ``FIELD_DECL`` for the data member. The third operand represents + the byte offset of the field, but should not be used directly; call + ``component_ref_field_offset`` instead. + +.. envvar:: ADDR_EXPR + + These nodes are used to represent the address of an object. (These + expressions will always have pointer or reference type.) The operand may + be another expression, or it may be a declaration. + + As an extension, GCC allows users to take the address of a label. In + this case, the operand of the ``ADDR_EXPR`` will be a + ``LABEL_DECL``. The type of such an expression is ``void*``. + + If the object addressed is not an lvalue, a temporary is created, and + the address of the temporary is used. + +.. envvar:: INDIRECT_REF + + These nodes are used to represent the object pointed to by a pointer. + The operand is the pointer being dereferenced; it will always have + pointer or reference type. + +.. envvar:: MEM_REF + + These nodes are used to represent the object pointed to by a pointer + offset by a constant. + The first operand is the pointer being dereferenced; it will always have + pointer or reference type. The second operand is a pointer constant + serving as constant offset applied to the pointer being dereferenced + with its type specifying the type to be used for type-based alias analysis. + The type of the node specifies the alignment of the access. + +.. envvar:: TARGET_MEM_REF + + These nodes represent memory accesses whose address directly map to + an addressing mode of the target architecture. The first argument + is ``TMR_BASE`` and is a pointer to the object being accessed. + The second argument is ``TMR_OFFSET`` which is a pointer constant + with dual purpose serving both as constant offset and holder of + the type used for type-based alias analysis. The first two operands + have exactly the same semantics as ``MEM_REF``. The third + and fourth operand are ``TMR_INDEX`` and ``TMR_STEP`` where + the former is an integer and the latter an integer constant. The + fifth and last operand is ``TMR_INDEX2`` which is an alternate + non-constant offset. Any of the third to last operands may be + ``NULL`` if the corresponding component does not appear in + the address, but ``TMR_INDEX`` and ``TMR_STEP`` shall be + always supplied in pair. The Address of the ``TARGET_MEM_REF`` + is determined in the following way. + + .. code-block:: c++ + + TMR_BASE + TMR_OFFSET + TMR_INDEX * TMR_STEP + TMR_INDEX2 + + The type of the node specifies the alignment of the access. + +.. _unary-and-binary-expressions: + +Unary and Binary Expressions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. index:: NEGATE_EXPR, ABS_EXPR, ABSU_EXPR, BIT_NOT_EXPR, TRUTH_NOT_EXPR, PREDECREMENT_EXPR, PREINCREMENT_EXPR, POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, FIX_TRUNC_EXPR, FLOAT_EXPR, COMPLEX_EXPR, CONJ_EXPR, REALPART_EXPR, IMAGPART_EXPR, NON_LVALUE_EXPR, NOP_EXPR, CONVERT_EXPR, FIXED_CONVERT_EXPR, THROW_EXPR, LSHIFT_EXPR, RSHIFT_EXPR, BIT_IOR_EXPR, BIT_XOR_EXPR, BIT_AND_EXPR, TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR, TRUTH_AND_EXPR, TRUTH_OR_EXPR, TRUTH_XOR_EXPR, POINTER_PLUS_EXPR, POINTER_DIFF_EXPR, PLUS_EXPR, MINUS_EXPR, MULT_EXPR, WIDEN_MULT_EXPR, MULT_HIGHPART_EXPR, RDIV_EXPR, TRUNC_DIV_EXPR, FLOOR_DIV_EXPR, CEIL_DIV_EXPR, ROUND_DIV_EXPR, TRUNC_MOD_EXPR, FLOOR_MOD_EXPR, CEIL_MOD_EXPR, ROUND_MOD_EXPR, EXACT_DIV_EXPR, LT_EXPR, LE_EXPR, GT_EXPR, GE_EXPR, EQ_EXPR, NE_EXPR, ORDERED_EXPR, UNORDERED_EXPR, UNLT_EXPR, UNLE_EXPR, UNGT_EXPR, UNGE_EXPR, UNEQ_EXPR, LTGT_EXPR, MODIFY_EXPR, INIT_EXPR, COMPOUND_EXPR, COND_EXPR, CALL_EXPR, STMT_EXPR, BIND_EXPR, LOOP_EXPR, EXIT_EXPR, CLEANUP_POINT_EXPR, CONSTRUCTOR, COMPOUND_LITERAL_EXPR, SAVE_EXPR, TARGET_EXPR, VA_ARG_EXPR, ANNOTATE_EXPR + +.. envvar:: NEGATE_EXPR + + These nodes represent unary negation of the single operand, for both + integer and floating-point types. The type of negation can be + determined by looking at the type of the expression. + + The behavior of this operation on signed arithmetic overflow is + controlled by the ``flag_wrapv`` and ``flag_trapv`` variables. + +.. envvar:: ABS_EXPR + + These nodes represent the absolute value of the single operand, for + both integer and floating-point types. This is typically used to + implement the ``abs``, ``labs`` and ``llabs`` builtins for + integer types, and the ``fabs``, ``fabsf`` and ``fabsl`` + builtins for floating point types. The type of abs operation can + be determined by looking at the type of the expression. + + This node is not used for complex types. To represent the modulus + or complex abs of a complex value, use the ``BUILT_IN_CABS``, + ``BUILT_IN_CABSF`` or ``BUILT_IN_CABSL`` builtins, as used + to implement the C99 ``cabs``, ``cabsf`` and ``cabsl`` + built-in functions. + +.. envvar:: ABSU_EXPR + + These nodes represent the absolute value of the single operand in + equivalent unsigned type such that ``ABSU_EXPR`` of ``TYPE_MIN`` + is well defined. + +.. envvar:: BIT_NOT_EXPR + + These nodes represent bitwise complement, and will always have integral + type. The only operand is the value to be complemented. + +.. envvar:: TRUTH_NOT_EXPR + + These nodes represent logical negation, and will always have integral + (or boolean) type. The operand is the value being negated. The type + of the operand and that of the result are always of ``BOOLEAN_TYPE`` + or ``INTEGER_TYPE``. + +.. envvar:: PREDECREMENT_EXPR + + These nodes represent increment and decrement expressions. The value of + the single operand is computed, and the operand incremented or + decremented. In the case of ``PREDECREMENT_EXPR`` and + ``PREINCREMENT_EXPR``, the value of the expression is the value + resulting after the increment or decrement; in the case of + ``POSTDECREMENT_EXPR`` and ``POSTINCREMENT_EXPR`` is the value + before the increment or decrement occurs. The type of the operand, like + that of the result, will be either integral, boolean, or floating-point. + +.. envvar:: FIX_TRUNC_EXPR + + These nodes represent conversion of a floating-point value to an + integer. The single operand will have a floating-point type, while + the complete expression will have an integral (or boolean) type. The + operand is rounded towards zero. + +.. envvar:: FLOAT_EXPR + + These nodes represent conversion of an integral (or boolean) value to a + floating-point value. The single operand will have integral type, while + the complete expression will have a floating-point type. + + .. todo:: How is the operand supposed to be rounded? Is this dependent on + :option:`-mieee` ? + +.. envvar:: COMPLEX_EXPR + + These nodes are used to represent complex numbers constructed from two + expressions of the same (integer or real) type. The first operand is the + real part and the second operand is the imaginary part. + +.. envvar:: CONJ_EXPR + + These nodes represent the conjugate of their operand. + +.. envvar:: REALPART_EXPR + + These nodes represent respectively the real and the imaginary parts + of complex numbers (their sole argument). + +.. envvar:: NON_LVALUE_EXPR + + These nodes indicate that their one and only operand is not an lvalue. + A back end can treat these identically to the single operand. + +.. envvar:: NOP_EXPR + + These nodes are used to represent conversions that do not require any + code-generation. For example, conversion of a ``char*`` to an + ``int*`` does not require any code be generated; such a conversion is + represented by a ``NOP_EXPR``. The single operand is the expression + to be converted. The conversion from a pointer to a reference is also + represented with a ``NOP_EXPR``. + +.. envvar:: CONVERT_EXPR + + These nodes are similar to ``NOP_EXPR`` s, but are used in those + situations where code may need to be generated. For example, if an + ``int*`` is converted to an ``int`` code may need to be generated + on some platforms. These nodes are never used for C++-specific + conversions, like conversions between pointers to different classes in + an inheritance hierarchy. Any adjustments that need to be made in such + cases are always indicated explicitly. Similarly, a user-defined + conversion is never represented by a ``CONVERT_EXPR`` ; instead, the + function calls are made explicit. + +.. envvar:: FIXED_CONVERT_EXPR + + These nodes are used to represent conversions that involve fixed-point + values. For example, from a fixed-point value to another fixed-point value, + from an integer to a fixed-point value, from a fixed-point value to an + integer, from a floating-point value to a fixed-point value, or from + a fixed-point value to a floating-point value. + +.. envvar:: LSHIFT_EXPR + + These nodes represent left and right shifts, respectively. The first + operand is the value to shift; it will always be of integral type. The + second operand is an expression for the number of bits by which to + shift. Right shift should be treated as arithmetic, i.e., the + high-order bits should be zero-filled when the expression has unsigned + type and filled with the sign bit when the expression has signed type. + Note that the result is undefined if the second operand is larger + than or equal to the first operand's type size. Unlike most nodes, these + can have a vector as first operand and a scalar as second operand. + +.. envvar:: BIT_IOR_EXPR + + These nodes represent bitwise inclusive or, bitwise exclusive or, and + bitwise and, respectively. Both operands will always have integral + type. + +.. envvar:: TRUTH_ANDIF_EXPR + + These nodes represent logical 'and' and logical 'or', respectively. + These operators are not strict; i.e., the second operand is evaluated + only if the value of the expression is not determined by evaluation of + the first operand. The type of the operands and that of the result are + always of ``BOOLEAN_TYPE`` or ``INTEGER_TYPE``. + +.. envvar:: TRUTH_AND_EXPR + + These nodes represent logical and, logical or, and logical exclusive or. + They are strict; both arguments are always evaluated. There are no + corresponding operators in C or C++, but the front end will sometimes + generate these expressions anyhow, if it can tell that strictness does + not matter. The type of the operands and that of the result are + always of ``BOOLEAN_TYPE`` or ``INTEGER_TYPE``. + +.. envvar:: POINTER_PLUS_EXPR + + This node represents pointer arithmetic. The first operand is always + a pointer/reference type. The second operand is always an unsigned + integer type compatible with sizetype. This and POINTER_DIFF_EXPR are + the only binary arithmetic operators that can operate on pointer types. + +.. envvar:: POINTER_DIFF_EXPR + + This node represents pointer subtraction. The two operands always + have pointer/reference type. It returns a signed integer of the same + precision as the pointers. The behavior is undefined if the difference + of the two pointers, seen as infinite precision non-negative integers, + does not fit in the result type. The result does not depend on the + pointer type, it is not divided by the size of the pointed-to type. + +.. envvar:: PLUS_EXPR + + These nodes represent various binary arithmetic operations. + Respectively, these operations are addition, subtraction (of the second + operand from the first) and multiplication. Their operands may have + either integral or floating type, but there will never be case in which + one operand is of floating type and the other is of integral type. + + The behavior of these operations on signed arithmetic overflow is + controlled by the ``flag_wrapv`` and ``flag_trapv`` variables. + +.. envvar:: WIDEN_MULT_EXPR + + This node represents a widening multiplication. The operands have + integral types with same :samp:`{b}` bits of precision, producing an + integral type result with at least 2 :samp:`{b}` bits of precision. + The behaviour is equivalent to extending both operands, possibly of + different signedness, to the result type, then multiplying them. + +.. envvar:: MULT_HIGHPART_EXPR + + This node represents the 'high-part' of a widening multiplication. + For an integral type with :samp:`{b}` bits of precision, the result is + the most significant :samp:`{b}` bits of the full 2 :samp:`{b}` product. + Both operands must have the same precision and same signedness. + +.. envvar:: RDIV_EXPR + + This node represents a floating point division operation. + +.. envvar:: TRUNC_DIV_EXPR + + These nodes represent integer division operations that return an integer + result. ``TRUNC_DIV_EXPR`` rounds towards zero, ``FLOOR_DIV_EXPR`` + rounds towards negative infinity, ``CEIL_DIV_EXPR`` rounds towards + positive infinity and ``ROUND_DIV_EXPR`` rounds to the closest integer. + Integer division in C and C++ is truncating, i.e. ``TRUNC_DIV_EXPR``. + + The behavior of these operations on signed arithmetic overflow, when + dividing the minimum signed integer by minus one, is controlled by the + ``flag_wrapv`` and ``flag_trapv`` variables. + +.. envvar:: TRUNC_MOD_EXPR + + These nodes represent the integer remainder or modulus operation. + The integer modulus of two operands ``a`` and ``b`` is + defined as ``a - (a/b)*b`` where the division calculated using + the corresponding division operator. Hence for ``TRUNC_MOD_EXPR`` + this definition assumes division using truncation towards zero, i.e. + ``TRUNC_DIV_EXPR``. Integer remainder in C and C++ uses truncating + division, i.e. ``TRUNC_MOD_EXPR``. + +.. envvar:: EXACT_DIV_EXPR + + The ``EXACT_DIV_EXPR`` code is used to represent integer divisions where + the numerator is known to be an exact multiple of the denominator. This + allows the backend to choose between the faster of ``TRUNC_DIV_EXPR``, + ``CEIL_DIV_EXPR`` and ``FLOOR_DIV_EXPR`` for the current target. + +.. envvar:: LT_EXPR + + These nodes represent the less than, less than or equal to, greater than, + greater than or equal to, less or greater than, equal, and not equal + comparison operators. The first and second operands will either be both + of integral type, both of floating type or both of vector type, except for + LTGT_EXPR where they will only be both of floating type. The result type + of these expressions will always be of integral, boolean or signed integral + vector type. These operations return the result type's zero value for false, + the result type's one value for true, and a vector whose elements are zero + (false) or minus one (true) for vectors. + + For floating point comparisons, if we honor IEEE NaNs and either operand + is NaN, then ``NE_EXPR`` always returns true and the remaining operators + always return false. On some targets, comparisons against an IEEE NaN, + other than equality and inequality, may generate a floating-point exception. + +.. envvar:: ORDERED_EXPR + + These nodes represent non-trapping ordered and unordered comparison + operators. These operations take two floating point operands and + determine whether they are ordered or unordered relative to each other. + If either operand is an IEEE NaN, their comparison is defined to be + unordered, otherwise the comparison is defined to be ordered. The + result type of these expressions will always be of integral or boolean + type. These operations return the result type's zero value for false, + and the result type's one value for true. + +.. envvar:: UNLT_EXPR + + These nodes represent the unordered comparison operators. + These operations take two floating point operands and determine whether + the operands are unordered or are less than, less than or equal to, + greater than, greater than or equal to, or equal respectively. For + example, ``UNLT_EXPR`` returns true if either operand is an IEEE + NaN or the first operand is less than the second. All these operations + are guaranteed not to generate a floating point exception. The result + type of these expressions will always be of integral or boolean type. + These operations return the result type's zero value for false, + and the result type's one value for true. + +.. envvar:: MODIFY_EXPR + + These nodes represent assignment. The left-hand side is the first + operand; the right-hand side is the second operand. The left-hand side + will be a ``VAR_DECL``, ``INDIRECT_REF``, ``COMPONENT_REF``, or + other lvalue. + + These nodes are used to represent not only assignment with :samp:`=` but + also compound assignments (like :samp:`+=`), by reduction to :samp:`=` + assignment. In other words, the representation for :samp:`i += 3` looks + just like that for :samp:`i = i + 3`. + +.. envvar:: INIT_EXPR + + These nodes are just like ``MODIFY_EXPR``, but are used only when a + variable is initialized, rather than assigned to subsequently. This + means that we can assume that the target of the initialization is not + used in computing its own value; any reference to the lhs in computing + the rhs is undefined. + +.. envvar:: COMPOUND_EXPR + + These nodes represent comma-expressions. The first operand is an + expression whose value is computed and thrown away prior to the + evaluation of the second operand. The value of the entire expression is + the value of the second operand. + +.. envvar:: COND_EXPR + + These nodes represent ``?:`` expressions. The first operand + is of boolean or integral type. If it evaluates to a nonzero value, + the second operand should be evaluated, and returned as the value of the + expression. Otherwise, the third operand is evaluated, and returned as + the value of the expression. + + The second operand must have the same type as the entire expression, + unless it unconditionally throws an exception or calls a noreturn + function, in which case it should have void type. The same constraints + apply to the third operand. This allows array bounds checks to be + represented conveniently as ``(i >= 0 && i < 10) ? i : abort()``. + + As a GNU extension, the C language front-ends allow the second + operand of the ``?:`` operator may be omitted in the source. + For example, ``x ? : 3`` is equivalent to ``x ? x : 3``, + assuming that ``x`` is an expression without side effects. + In the tree representation, however, the second operand is always + present, possibly protected by ``SAVE_EXPR`` if the first + argument does cause side effects. + +.. envvar:: CALL_EXPR + + These nodes are used to represent calls to functions, including + non-static member functions. ``CALL_EXPR`` s are implemented as + expression nodes with a variable number of operands. Rather than using + ``TREE_OPERAND`` to extract them, it is preferable to use the + specialized accessor macros and functions that operate specifically on + ``CALL_EXPR`` nodes. + + ``CALL_EXPR_FN`` returns a pointer to the + function to call; it is always an expression whose type is a + ``POINTER_TYPE``. + + The number of arguments to the call is returned by ``call_expr_nargs``, + while the arguments themselves can be accessed with the ``CALL_EXPR_ARG`` + macro. The arguments are zero-indexed and numbered left-to-right. + You can iterate over the arguments using ``FOR_EACH_CALL_EXPR_ARG``, as in: + + .. code-block:: c++ + + tree call, arg; + call_expr_arg_iterator iter; + FOR_EACH_CALL_EXPR_ARG (arg, iter, call) + /* arg is bound to successive arguments of call. */ + ...; + + For non-static + member functions, there will be an operand corresponding to the + ``this`` pointer. There will always be expressions corresponding to + all of the arguments, even if the function is declared with default + arguments and some arguments are not explicitly provided at the call + sites. + + ``CALL_EXPR`` s also have a ``CALL_EXPR_STATIC_CHAIN`` operand that + is used to implement nested functions. This operand is otherwise null. + +.. envvar:: CLEANUP_POINT_EXPR + + These nodes represent full-expressions. The single operand is an + expression to evaluate. Any destructor calls engendered by the creation + of temporaries during the evaluation of that expression should be + performed immediately after the expression is evaluated. + +.. envvar:: CONSTRUCTOR + + These nodes represent the brace-enclosed initializers for a structure or an + array. They contain a sequence of component values made out of a vector of + constructor_elt, which is a (``INDEX``, ``VALUE``) pair. + + If the ``TREE_TYPE`` of the ``CONSTRUCTOR`` is a ``RECORD_TYPE``, + ``UNION_TYPE`` or ``QUAL_UNION_TYPE`` then the ``INDEX`` of each + node in the sequence will be a ``FIELD_DECL`` and the ``VALUE`` will + be the expression used to initialize that field. + + If the ``TREE_TYPE`` of the ``CONSTRUCTOR`` is an ``ARRAY_TYPE``, + then the ``INDEX`` of each node in the sequence will be an + ``INTEGER_CST`` or a ``RANGE_EXPR`` of two ``INTEGER_CST`` s. + A single ``INTEGER_CST`` indicates which element of the array is being + assigned to. A ``RANGE_EXPR`` indicates an inclusive range of elements + to initialize. In both cases the ``VALUE`` is the corresponding + initializer. It is re-evaluated for each element of a + ``RANGE_EXPR``. If the ``INDEX`` is ``NULL_TREE``, then + the initializer is for the next available array element. + + In the front end, you should not depend on the fields appearing in any + particular order. However, in the middle end, fields must appear in + declaration order. You should not assume that all fields will be + represented. Unrepresented fields will be cleared (zeroed), unless the + CONSTRUCTOR_NO_CLEARING flag is set, in which case their value becomes + undefined. + +.. envvar:: COMPOUND_LITERAL_EXPR + + These nodes represent ISO C99 compound literals. The + ``COMPOUND_LITERAL_EXPR_DECL_EXPR`` is a ``DECL_EXPR`` + containing an anonymous ``VAR_DECL`` for + the unnamed object represented by the compound literal; the + ``DECL_INITIAL`` of that ``VAR_DECL`` is a ``CONSTRUCTOR`` + representing the brace-enclosed list of initializers in the compound + literal. That anonymous ``VAR_DECL`` can also be accessed directly + by the ``COMPOUND_LITERAL_EXPR_DECL`` macro. + +.. envvar:: SAVE_EXPR + + A ``SAVE_EXPR`` represents an expression (possibly involving + side effects) that is used more than once. The side effects should + occur only the first time the expression is evaluated. Subsequent uses + should just reuse the computed value. The first operand to the + ``SAVE_EXPR`` is the expression to evaluate. The side effects should + be executed where the ``SAVE_EXPR`` is first encountered in a + depth-first preorder traversal of the expression tree. + +.. envvar:: TARGET_EXPR + + A ``TARGET_EXPR`` represents a temporary object. The first operand + is a ``VAR_DECL`` for the temporary variable. The second operand is + the initializer for the temporary. The initializer is evaluated and, + if non-void, copied (bitwise) into the temporary. If the initializer + is void, that means that it will perform the initialization itself. + + Often, a ``TARGET_EXPR`` occurs on the right-hand side of an + assignment, or as the second operand to a comma-expression which is + itself the right-hand side of an assignment, etc. In this case, we say + that the ``TARGET_EXPR`` is 'normal'; otherwise, we say it is + 'orphaned'. For a normal ``TARGET_EXPR`` the temporary variable + should be treated as an alias for the left-hand side of the assignment, + rather than as a new temporary variable. + + The third operand to the ``TARGET_EXPR``, if present, is a + cleanup-expression (i.e., destructor call) for the temporary. If this + expression is orphaned, then this expression must be executed when the + statement containing this expression is complete. These cleanups must + always be executed in the order opposite to that in which they were + encountered. Note that if a temporary is created on one branch of a + conditional operator (i.e., in the second or third operand to a + ``COND_EXPR``), the cleanup must be run only if that branch is + actually executed. + +.. envvar:: VA_ARG_EXPR + + This node is used to implement support for the C/C++ variable argument-list + mechanism. It represents expressions like ``va_arg (ap, type)``. + Its ``TREE_TYPE`` yields the tree representation for ``type`` and + its sole argument yields the representation for ``ap``. + +.. envvar:: ANNOTATE_EXPR + + This node is used to attach markers to an expression. The first operand + is the annotated expression, the second is an ``INTEGER_CST`` with + a value from ``enum annot_expr_kind``, the third is an ``INTEGER_CST``. + +.. _vectors: + +Vectors +^^^^^^^ + +.. index:: VEC_DUPLICATE_EXPR, VEC_SERIES_EXPR, VEC_LSHIFT_EXPR, VEC_RSHIFT_EXPR, VEC_WIDEN_MULT_HI_EXPR, VEC_WIDEN_MULT_LO_EXPR, VEC_WIDEN_PLUS_HI_EXPR, VEC_WIDEN_PLUS_LO_EXPR, VEC_WIDEN_MINUS_HI_EXPR, VEC_WIDEN_MINUS_LO_EXPR, VEC_UNPACK_HI_EXPR, VEC_UNPACK_LO_EXPR, VEC_UNPACK_FLOAT_HI_EXPR, VEC_UNPACK_FLOAT_LO_EXPR, VEC_UNPACK_FIX_TRUNC_HI_EXPR, VEC_UNPACK_FIX_TRUNC_LO_EXPR, VEC_PACK_TRUNC_EXPR, VEC_PACK_SAT_EXPR, VEC_PACK_FIX_TRUNC_EXPR, VEC_PACK_FLOAT_EXPR, VEC_COND_EXPR, SAD_EXPR + +.. envvar:: VEC_DUPLICATE_EXPR + + This node has a single operand and represents a vector in which every + element is equal to that operand. + +.. envvar:: VEC_SERIES_EXPR + + This node represents a vector formed from a scalar base and step, + given as the first and second operands respectively. Element :samp:`{i}` + of the result is equal to :samp:`{base} + {i}*{step}`. + + This node is restricted to integral types, in order to avoid + specifying the rounding behavior for floating-point types. + +.. envvar:: VEC_LSHIFT_EXPR + + These nodes represent whole vector left and right shifts, respectively. + The first operand is the vector to shift; it will always be of vector type. + The second operand is an expression for the number of bits by which to + shift. Note that the result is undefined if the second operand is larger + than or equal to the first operand's type size. + +.. envvar:: VEC_WIDEN_MULT_HI_EXPR + + These nodes represent widening vector multiplication of the high and low + parts of the two input vectors, respectively. Their operands are vectors + that contain the same number of elements (``N``) of the same integral type. + The result is a vector that contains half as many elements, of an integral type + whose size is twice as wide. In the case of ``VEC_WIDEN_MULT_HI_EXPR`` the + high ``N/2`` elements of the two vector are multiplied to produce the + vector of ``N/2`` products. In the case of ``VEC_WIDEN_MULT_LO_EXPR`` the + low ``N/2`` elements of the two vector are multiplied to produce the + vector of ``N/2`` products. + +.. envvar:: VEC_WIDEN_PLUS_HI_EXPR + + These nodes represent widening vector addition of the high and low parts of + the two input vectors, respectively. Their operands are vectors that contain + the same number of elements (``N``) of the same integral type. The result + is a vector that contains half as many elements, of an integral type whose size + is twice as wide. In the case of ``VEC_WIDEN_PLUS_HI_EXPR`` the high + ``N/2`` elements of the two vectors are added to produce the vector of + ``N/2`` products. In the case of ``VEC_WIDEN_PLUS_LO_EXPR`` the low + ``N/2`` elements of the two vectors are added to produce the vector of + ``N/2`` products. + +.. envvar:: VEC_WIDEN_MINUS_HI_EXPR + + These nodes represent widening vector subtraction of the high and low parts of + the two input vectors, respectively. Their operands are vectors that contain + the same number of elements (``N``) of the same integral type. The high/low + elements of the second vector are subtracted from the high/low elements of the + first. The result is a vector that contains half as many elements, of an + integral type whose size is twice as wide. In the case of + ``VEC_WIDEN_MINUS_HI_EXPR`` the high ``N/2`` elements of the second + vector are subtracted from the high ``N/2`` of the first to produce the + vector of ``N/2`` products. In the case of + ``VEC_WIDEN_MINUS_LO_EXPR`` the low ``N/2`` elements of the second + vector are subtracted from the low ``N/2`` of the first to produce the + vector of ``N/2`` products. + +.. envvar:: VEC_UNPACK_HI_EXPR + + These nodes represent unpacking of the high and low parts of the input vector, + respectively. The single operand is a vector that contains ``N`` elements + of the same integral or floating point type. The result is a vector + that contains half as many elements, of an integral or floating point type + whose size is twice as wide. In the case of ``VEC_UNPACK_HI_EXPR`` the + high ``N/2`` elements of the vector are extracted and widened (promoted). + In the case of ``VEC_UNPACK_LO_EXPR`` the low ``N/2`` elements of the + vector are extracted and widened (promoted). + +.. envvar:: VEC_UNPACK_FLOAT_HI_EXPR + + These nodes represent unpacking of the high and low parts of the input vector, + where the values are converted from fixed point to floating point. The + single operand is a vector that contains ``N`` elements of the same + integral type. The result is a vector that contains half as many elements + of a floating point type whose size is twice as wide. In the case of + ``VEC_UNPACK_FLOAT_HI_EXPR`` the high ``N/2`` elements of the vector are + extracted, converted and widened. In the case of ``VEC_UNPACK_FLOAT_LO_EXPR`` + the low ``N/2`` elements of the vector are extracted, converted and widened. + +.. envvar:: VEC_UNPACK_FIX_TRUNC_HI_EXPR + + These nodes represent unpacking of the high and low parts of the input vector, + where the values are truncated from floating point to fixed point. The + single operand is a vector that contains ``N`` elements of the same + floating point type. The result is a vector that contains half as many + elements of an integral type whose size is twice as wide. In the case of + ``VEC_UNPACK_FIX_TRUNC_HI_EXPR`` the high ``N/2`` elements of the + vector are extracted and converted with truncation. In the case of + ``VEC_UNPACK_FIX_TRUNC_LO_EXPR`` the low ``N/2`` elements of the + vector are extracted and converted with truncation. + +.. envvar:: VEC_PACK_TRUNC_EXPR + + This node represents packing of truncated elements of the two input vectors + into the output vector. Input operands are vectors that contain the same + number of elements of the same integral or floating point type. The result + is a vector that contains twice as many elements of an integral or floating + point type whose size is half as wide. The elements of the two vectors are + demoted and merged (concatenated) to form the output vector. + +.. envvar:: VEC_PACK_SAT_EXPR + + This node represents packing of elements of the two input vectors into the + output vector using saturation. Input operands are vectors that contain + the same number of elements of the same integral type. The result is a + vector that contains twice as many elements of an integral type whose size + is half as wide. The elements of the two vectors are demoted and merged + (concatenated) to form the output vector. + +.. envvar:: VEC_PACK_FIX_TRUNC_EXPR + + This node represents packing of elements of the two input vectors into the + output vector, where the values are converted from floating point + to fixed point. Input operands are vectors that contain the same number + of elements of a floating point type. The result is a vector that contains + twice as many elements of an integral type whose size is half as wide. The + elements of the two vectors are merged (concatenated) to form the output + vector. + +.. envvar:: VEC_PACK_FLOAT_EXPR + + This node represents packing of elements of the two input vectors into the + output vector, where the values are converted from fixed point to floating + point. Input operands are vectors that contain the same number of elements + of an integral type. The result is a vector that contains twice as many + elements of floating point type whose size is half as wide. The elements of + the two vectors are merged (concatenated) to form the output vector. + +.. envvar:: VEC_COND_EXPR + + These nodes represent ``?:`` expressions. The three operands must be + vectors of the same size and number of elements. The second and third + operands must have the same type as the entire expression. The first + operand is of signed integral vector type. If an element of the first + operand evaluates to a zero value, the corresponding element of the + result is taken from the third operand. If it evaluates to a minus one + value, it is taken from the second operand. It should never evaluate to + any other value currently, but optimizations should not rely on that + property. In contrast with a ``COND_EXPR``, all operands are always + evaluated. + +.. envvar:: SAD_EXPR + + This node represents the Sum of Absolute Differences operation. The three + operands must be vectors of integral types. The first and second operand + must have the same type. The size of the vector element of the third + operand must be at lease twice of the size of the vector element of the + first and second one. The SAD is calculated between the first and second + operands, added to the third operand, and returned. \ No newline at end of file diff --git a/gcc/doc/gccint/generic/functions.rst b/gcc/doc/gccint/generic/functions.rst new file mode 100644 index 00000000000..50e5bbc2d92 --- /dev/null +++ b/gcc/doc/gccint/generic/functions.rst @@ -0,0 +1,212 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: function + +.. _functions: + +Functions +********* + +.. index:: FUNCTION_DECL + +A function is represented by a ``FUNCTION_DECL`` node. It stores +the basic pieces of the function such as body, parameters, and return +type as well as information on the surrounding context, visibility, +and linkage. + +.. toctree:: + :maxdepth: 2 + + +.. - + Function Basics + - + +.. index:: DECL_NAME, DECL_ASSEMBLER_NAME, TREE_PUBLIC, DECL_ARTIFICIAL, DECL_FUNCTION_SPECIFIC_TARGET, DECL_FUNCTION_SPECIFIC_OPTIMIZATION + +.. _function-basics: + +Function Basics +^^^^^^^^^^^^^^^ + +A function has four core parts: the name, the parameters, the result, +and the body. The following macros and functions access these parts +of a ``FUNCTION_DECL`` as well as other basic features: + +.. envvar:: DECL_NAME + + This macro returns the unqualified name of the function, as an + ``IDENTIFIER_NODE``. For an instantiation of a function template, + the ``DECL_NAME`` is the unqualified name of the template, not + something like ``f``. The value of ``DECL_NAME`` is + undefined when used on a constructor, destructor, overloaded operator, + or type-conversion operator, or any function that is implicitly + generated by the compiler. See below for macros that can be used to + distinguish these cases. + +.. envvar:: DECL_ASSEMBLER_NAME + + This macro returns the mangled name of the function, also an + ``IDENTIFIER_NODE``. This name does not contain leading underscores + on systems that prefix all identifiers with underscores. The mangled + name is computed in the same way on all platforms; if special processing + is required to deal with the object file format used on a particular + platform, it is the responsibility of the back end to perform those + modifications. (Of course, the back end should not modify + ``DECL_ASSEMBLER_NAME`` itself.) + + Using ``DECL_ASSEMBLER_NAME`` will cause additional memory to be + allocated (for the mangled name of the entity) so it should be used + only when emitting assembly code. It should not be used within the + optimizers to determine whether or not two declarations are the same, + even though some of the existing optimizers do use it in that way. + These uses will be removed over time. + +.. envvar:: DECL_ARGUMENTS + + This macro returns the ``PARM_DECL`` for the first argument to the + function. Subsequent ``PARM_DECL`` nodes can be obtained by + following the ``TREE_CHAIN`` links. + +.. envvar:: DECL_RESULT + + This macro returns the ``RESULT_DECL`` for the function. + +.. envvar:: DECL_SAVED_TREE + + This macro returns the complete body of the function. + +.. envvar:: TREE_TYPE + + This macro returns the ``FUNCTION_TYPE`` or ``METHOD_TYPE`` for + the function. + +.. envvar:: DECL_INITIAL + + A function that has a definition in the current translation unit will + have a non- ``NULL`` ``DECL_INITIAL``. However, back ends should not make + use of the particular value given by ``DECL_INITIAL``. + + It should contain a tree of ``BLOCK`` nodes that mirrors the scopes + that variables are bound in the function. Each block contains a list + of decls declared in a basic block, a pointer to a chain of blocks at + the next lower scope level, then a pointer to the next block at the + same level and a backpointer to the parent ``BLOCK`` or + ``FUNCTION_DECL``. So given a function as follows: + + .. code-block:: c++ + + void foo() + { + int a; + { + int b; + } + int c; + } + + you would get the following: + + .. code-block:: c++ + + tree foo = FUNCTION_DECL; + tree decl_a = VAR_DECL; + tree decl_b = VAR_DECL; + tree decl_c = VAR_DECL; + tree block_a = BLOCK; + tree block_b = BLOCK; + tree block_c = BLOCK; + BLOCK_VARS(block_a) = decl_a; + BLOCK_SUBBLOCKS(block_a) = block_b; + BLOCK_CHAIN(block_a) = block_c; + BLOCK_SUPERCONTEXT(block_a) = foo; + BLOCK_VARS(block_b) = decl_b; + BLOCK_SUPERCONTEXT(block_b) = block_a; + BLOCK_VARS(block_c) = decl_c; + BLOCK_SUPERCONTEXT(block_c) = foo; + DECL_INITIAL(foo) = block_a; + +.. - + Function Properties + - + +.. index:: function properties, statements + +.. _function-properties: + +Function Properties +^^^^^^^^^^^^^^^^^^^ + +To determine the scope of a function, you can use the +``DECL_CONTEXT`` macro. This macro will return the class +(either a ``RECORD_TYPE`` or a ``UNION_TYPE``) or namespace (a +``NAMESPACE_DECL``) of which the function is a member. For a virtual +function, this macro returns the class in which the function was +actually defined, not the base class in which the virtual declaration +occurred. + +In C, the ``DECL_CONTEXT`` for a function maybe another function. +This representation indicates that the GNU nested function extension +is in use. For details on the semantics of nested functions, see the +GCC Manual. The nested function can refer to local variables in its +containing function. Such references are not explicitly marked in the +tree structure; back ends must look at the ``DECL_CONTEXT`` for the +referenced ``VAR_DECL``. If the ``DECL_CONTEXT`` for the +referenced ``VAR_DECL`` is not the same as the function currently +being processed, and neither ``DECL_EXTERNAL`` nor +``TREE_STATIC`` hold, then the reference is to a local variable in +a containing function, and the back end must take appropriate action. + +.. envvar:: DECL_EXTERNAL + + This predicate holds if the function is undefined. + +.. envvar:: TREE_PUBLIC + + This predicate holds if the function has external linkage. + +.. envvar:: TREE_STATIC + + This predicate holds if the function has been defined. + +.. envvar:: TREE_THIS_VOLATILE + + This predicate holds if the function does not return normally. + +.. envvar:: TREE_READONLY + + This predicate holds if the function can only read its arguments. + +.. envvar:: DECL_PURE_P + + This predicate holds if the function can only read its arguments, but + may also read global memory. + +.. envvar:: DECL_VIRTUAL_P + + This predicate holds if the function is virtual. + +.. envvar:: DECL_ARTIFICIAL + + This macro holds if the function was implicitly generated by the + compiler, rather than explicitly declared. In addition to implicitly + generated class member functions, this macro holds for the special + functions created to implement static initialization and destruction, to + compute run-time type information, and so forth. + +.. envvar:: DECL_FUNCTION_SPECIFIC_TARGET + + This macro returns a tree node that holds the target options that are + to be used to compile this particular function or ``NULL_TREE`` if + the function is to be compiled with the target options specified on + the command line. + +.. envvar:: DECL_FUNCTION_SPECIFIC_OPTIMIZATION + + This macro returns a tree node that holds the optimization options + that are to be used to compile this particular function or + ``NULL_TREE`` if the function is to be compiled with the + optimization options specified on the command line. \ No newline at end of file diff --git a/gcc/doc/gccint/generic/language-dependent-trees.rst b/gcc/doc/gccint/generic/language-dependent-trees.rst new file mode 100644 index 00000000000..dde4c51e2da --- /dev/null +++ b/gcc/doc/gccint/generic/language-dependent-trees.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: language-dependent trees + +.. _language-dependent-trees: + +Language-dependent trees +************************ + +Front ends may wish to keep some state associated with various GENERIC +trees while parsing. To support this, trees provide a set of flags +that may be used by the front end. They are accessed using +``TREE_LANG_FLAG_n`` where :samp:`n` is currently 0 through 6. + +If necessary, a front end can use some language-dependent tree +codes in its GENERIC representation, so long as it provides a +hook for converting them to GIMPLE and doesn't expect them to +work with any (hypothetical) optimizers that run before the +conversion to GIMPLE. The intermediate representation used while +parsing C and C++ looks very little like GENERIC, but the C and +C++ gimplifier hooks are perfectly happy to take it as input and +spit out GIMPLE. \ No newline at end of file diff --git a/gcc/doc/gccint/generic/overview.rst b/gcc/doc/gccint/generic/overview.rst new file mode 100644 index 00000000000..0593c0f641c --- /dev/null +++ b/gcc/doc/gccint/generic/overview.rst @@ -0,0 +1,213 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: tree, TREE_CODE + +.. _tree-overview: + +Overview +******** + +The central data structure used by the internal representation is the +``tree``. These nodes, while all of the C type ``tree``, are of +many varieties. A ``tree`` is a pointer type, but the object to +which it points may be of a variety of types. From this point forward, +we will refer to trees in ordinary type, rather than in ``this +font``, except when talking about the actual C type ``tree``. + +You can tell what kind of node a particular tree is by using the +``TREE_CODE`` macro. Many, many macros take trees as input and +return trees as output. However, most macros require a certain kind of +tree node as input. In other words, there is a type-system for trees, +but it is not reflected in the C type-system. + +For safety, it is useful to configure GCC with :option:`--enable-checking`. +Although this results in a significant performance penalty (since all +tree types are checked at run-time), and is therefore inappropriate in a +release version, it is extremely helpful during the development process. + +Many macros behave as predicates. Many, although not all, of these +predicates end in :samp:`_P`. Do not rely on the result type of these +macros being of any particular type. You may, however, rely on the fact +that the type can be compared to ``0``, so that statements like + +.. code-block:: c++ + + if (TEST_P (t) && !TEST_P (y)) + x = 1; + +and + +.. code-block:: c++ + + int i = (TEST_P (t) != 0); + +are legal. Macros that return ``int`` values now may be changed to +return ``tree`` values, or other pointers in the future. Even those +that continue to return ``int`` may return multiple nonzero codes +where previously they returned only zero and one. Therefore, you should +not write code like + +.. code-block:: c++ + + if (TEST_P (t) == 1) + +as this code is not guaranteed to work correctly in the future. + +You should not take the address of values returned by the macros or +functions described here. In particular, no guarantee is given that the +values are lvalues. + +In general, the names of macros are all in uppercase, while the names of +functions are entirely in lowercase. There are rare exceptions to this +rule. You should assume that any macro or function whose name is made +up entirely of uppercase letters may evaluate its arguments more than +once. You may assume that a macro or function whose name is made up +entirely of lowercase letters will evaluate its arguments only once. + +The ``error_mark_node`` is a special tree. Its tree code is +``ERROR_MARK``, but since there is only ever one node with that code, +the usual practice is to compare the tree against +``error_mark_node``. (This test is just a test for pointer +equality.) If an error has occurred during front-end processing the +flag ``errorcount`` will be set. If the front end has encountered +code it cannot handle, it will issue a message to the user and set +``sorrycount``. When these flags are set, any macro or function +which normally returns a tree of a particular kind may instead return +the ``error_mark_node``. Thus, if you intend to do any processing of +erroneous code, you must be prepared to deal with the +``error_mark_node``. + +Occasionally, a particular tree slot (like an operand to an expression, +or a particular field in a declaration) will be referred to as +'reserved for the back end'. These slots are used to store RTL when +the tree is converted to RTL for use by the GCC back end. However, if +that process is not taking place (e.g., if the front end is being hooked +up to an intelligent editor), then those slots may be used by the +back end presently in use. + +If you encounter situations that do not match this documentation, such +as tree nodes of types not mentioned here, or macros documented to +return entities of a particular kind that instead return entities of +some different kind, you have found a bug, either in the front end or in +the documentation. Please report these bugs as you would any other +bug. + +.. toctree:: + :maxdepth: 2 + + +.. - + Trees + - + +.. index:: tree, TREE_CHAIN, TREE_TYPE + +.. _macros-and-functions: + +Trees +^^^^^ + +All GENERIC trees have two fields in common. First, ``TREE_CHAIN`` +is a pointer that can be used as a singly-linked list to other trees. +The other is ``TREE_TYPE``. Many trees store the type of an +expression or declaration in this field. + +These are some other functions for handling trees: + +``tree_size`` + Return the number of bytes a tree takes. + +``build0``, ``build1``, ``build2``, ``build3``, ``build4``, ``build5``, ``build6`` + These functions build a tree and supply values to put in each + parameter. The basic signature is :samp:`code, type, [operands]`. + ``code`` is the ``TREE_CODE``, and ``type`` is a tree + representing the ``TREE_TYPE``. These are followed by the + operands, each of which is also a tree. + +.. - + Identifiers + - + +.. index:: identifier, name + +.. _identifiers: + +Identifiers +^^^^^^^^^^^ + +.. index:: IDENTIFIER_NODE + +An ``IDENTIFIER_NODE`` represents a slightly more general concept +than the standard C or C++ concept of identifier. In particular, an +``IDENTIFIER_NODE`` may contain a :samp:`$`, or other extraordinary +characters. + +There are never two distinct ``IDENTIFIER_NODE`` s representing the +same identifier. Therefore, you may use pointer equality to compare +``IDENTIFIER_NODE`` s, rather than using a routine like +``strcmp``. Use ``get_identifier`` to obtain the unique +``IDENTIFIER_NODE`` for a supplied string. + +You can use the following macros to access identifiers: + +.. envvar:: IDENTIFIER_POINTER + + The string represented by the identifier, represented as a + ``char*``. This string is always ``NUL`` -terminated, and contains + no embedded ``NUL`` characters. + +.. envvar:: IDENTIFIER_LENGTH + + The length of the string returned by ``IDENTIFIER_POINTER``, not + including the trailing ``NUL``. This value of + ``IDENTIFIER_LENGTH (x)`` is always the same as ``strlen + (IDENTIFIER_POINTER (x))``. + +.. envvar:: IDENTIFIER_OPNAME_P + + This predicate holds if the identifier represents the name of an + overloaded operator. In this case, you should not depend on the + contents of either the ``IDENTIFIER_POINTER`` or the + ``IDENTIFIER_LENGTH``. + +.. envvar:: IDENTIFIER_TYPENAME_P + + This predicate holds if the identifier represents the name of a + user-defined conversion operator. In this case, the ``TREE_TYPE`` of + the ``IDENTIFIER_NODE`` holds the type to which the conversion + operator converts. + +.. - + Containers + - + +.. index:: container, list, vector + +.. _containers: + +Containers +^^^^^^^^^^ + +.. index:: TREE_LIST, TREE_VEC, TREE_PURPOSE, TREE_VALUE, TREE_VEC_LENGTH, TREE_VEC_ELT + +Two common container data structures can be represented directly with +tree nodes. A ``TREE_LIST`` is a singly linked list containing two +trees per node. These are the ``TREE_PURPOSE`` and ``TREE_VALUE`` +of each node. (Often, the ``TREE_PURPOSE`` contains some kind of +tag, or additional information, while the ``TREE_VALUE`` contains the +majority of the payload. In other cases, the ``TREE_PURPOSE`` is +simply ``NULL_TREE``, while in still others both the +``TREE_PURPOSE`` and ``TREE_VALUE`` are of equal stature.) Given +one ``TREE_LIST`` node, the next node is found by following the +``TREE_CHAIN``. If the ``TREE_CHAIN`` is ``NULL_TREE``, then +you have reached the end of the list. + +A ``TREE_VEC`` is a simple vector. The ``TREE_VEC_LENGTH`` is an +integer (not a tree) giving the number of nodes in the vector. The +nodes themselves are accessed using the ``TREE_VEC_ELT`` macro, which +takes two arguments. The first is the ``TREE_VEC`` in question; the +second is an integer indicating which element in the vector is desired. +The elements are indexed from zero. \ No newline at end of file diff --git a/gcc/doc/gccint/generic/statements.rst b/gcc/doc/gccint/generic/statements.rst new file mode 100644 index 00000000000..be101d1e768 --- /dev/null +++ b/gcc/doc/gccint/generic/statements.rst @@ -0,0 +1,516 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Statements + +.. _statements: + +Statements +********** + +Most statements in GIMPLE are assignment statements, represented by +``GIMPLE_ASSIGN``. No other C expressions can appear at statement level; +a reference to a volatile object is converted into a +``GIMPLE_ASSIGN``. + +There are also several varieties of complex statements. + +.. toctree:: + :maxdepth: 2 + + +.. index:: Basic Statements + +.. _basic-statements: + +Basic Statements +^^^^^^^^^^^^^^^^ + +.. envvar:: ASM_EXPR + + Used to represent an inline assembly statement. For an inline assembly + statement like: + + .. code-block:: c++ + + asm ("mov x, y"); + + The ``ASM_STRING`` macro will return a ``STRING_CST`` node for + ``"mov x, y"``. If the original statement made use of the + extended-assembly syntax, then ``ASM_OUTPUTS``, + ``ASM_INPUTS``, and ``ASM_CLOBBERS`` will be the outputs, inputs, + and clobbers for the statement, represented as ``STRING_CST`` nodes. + The extended-assembly syntax looks like: + + .. code-block:: c++ + + asm ("fsinx %1,%0" : "=f" (result) : "f" (angle)); + + The first string is the ``ASM_STRING``, containing the instruction + template. The next two strings are the output and inputs, respectively; + this statement has no clobbers. As this example indicates, 'plain' + assembly statements are merely a special case of extended assembly + statements; they have no cv-qualifiers, outputs, inputs, or clobbers. + All of the strings will be ``NUL`` -terminated, and will contain no + embedded ``NUL`` -characters. + + If the assembly statement is declared ``volatile``, or if the + statement was not an extended assembly statement, and is therefore + implicitly volatile, then the predicate ``ASM_VOLATILE_P`` will hold + of the ``ASM_EXPR``. + +.. envvar:: DECL_EXPR + + Used to represent a local declaration. The ``DECL_EXPR_DECL`` macro + can be used to obtain the entity declared. This declaration may be a + ``LABEL_DECL``, indicating that the label declared is a local label. + (As an extension, GCC allows the declaration of labels with scope.) In + C, this declaration may be a ``FUNCTION_DECL``, indicating the + use of the GCC nested function extension. For more information, + see :ref:`functions`. + +.. envvar:: LABEL_EXPR + + Used to represent a label. The ``LABEL_DECL`` declared by this + statement can be obtained with the ``LABEL_EXPR_LABEL`` macro. The + ``IDENTIFIER_NODE`` giving the name of the label can be obtained from + the ``LABEL_DECL`` with ``DECL_NAME``. + +.. envvar:: GOTO_EXPR + + Used to represent a ``goto`` statement. The ``GOTO_DESTINATION`` will + usually be a ``LABEL_DECL``. However, if the 'computed goto' extension + has been used, the ``GOTO_DESTINATION`` will be an arbitrary expression + indicating the destination. This expression will always have pointer type. + +.. envvar:: RETURN_EXPR + + Used to represent a ``return`` statement. Operand 0 represents the + value to return. It should either be the ``RESULT_DECL`` for the + containing function, or a ``MODIFY_EXPR`` or ``INIT_EXPR`` + setting the function's ``RESULT_DECL``. It will be + ``NULL_TREE`` if the statement was just + + .. code-block:: c++ + + return; + +.. envvar:: LOOP_EXPR + + These nodes represent 'infinite' loops. The ``LOOP_EXPR_BODY`` + represents the body of the loop. It should be executed forever, unless + an ``EXIT_EXPR`` is encountered. + +.. envvar:: EXIT_EXPR + + These nodes represent conditional exits from the nearest enclosing + ``LOOP_EXPR``. The single operand is the condition; if it is + nonzero, then the loop should be exited. An ``EXIT_EXPR`` will only + appear within a ``LOOP_EXPR``. + +.. envvar:: SWITCH_EXPR + + Used to represent a ``switch`` statement. The ``SWITCH_COND`` + is the expression on which the switch is occurring. The + ``SWITCH_BODY`` is the body of the switch statement. + ``SWITCH_ALL_CASES_P`` is true if the switch includes a default + label or the case label ranges cover all possible values of the + condition expression. + + Note that ``TREE_TYPE`` for a ``SWITCH_EXPR`` represents the + original type of switch expression as given in the source, before any + compiler conversions, instead of the type of the switch expression + itself (which is not meaningful). + +.. envvar:: CASE_LABEL_EXPR + + Use to represent a ``case`` label, range of ``case`` labels, or a + ``default`` label. If ``CASE_LOW`` is ``NULL_TREE``, then this is a + ``default`` label. Otherwise, if ``CASE_HIGH`` is ``NULL_TREE``, then + this is an ordinary ``case`` label. In this case, ``CASE_LOW`` is + an expression giving the value of the label. Both ``CASE_LOW`` and + ``CASE_HIGH`` are ``INTEGER_CST`` nodes. These values will have + the same type as the condition expression in the switch statement. + + Otherwise, if both ``CASE_LOW`` and ``CASE_HIGH`` are defined, the + statement is a range of case labels. Such statements originate with the + extension that allows users to write things of the form: + + .. code-block:: c++ + + case 2 ... 5: + + The first value will be ``CASE_LOW``, while the second will be + ``CASE_HIGH``. + +.. envvar:: DEBUG_BEGIN_STMT + + Marks the beginning of a source statement, for purposes of debug + information generation. + +.. index:: Blocks + +.. _blocks: + +Blocks +^^^^^^ + +Block scopes and the variables they declare in GENERIC are +expressed using the ``BIND_EXPR`` code, which in previous +versions of GCC was primarily used for the C statement-expression +extension. + +Variables in a block are collected into ``BIND_EXPR_VARS`` in +declaration order through their ``TREE_CHAIN`` field. Any runtime +initialization is moved out of ``DECL_INITIAL`` and into a +statement in the controlled block. When gimplifying from C or C++, +this initialization replaces the ``DECL_STMT``. These variables +will never require cleanups. The scope of these variables is just the +body + +Variable-length arrays (VLAs) complicate this process, as their size +often refers to variables initialized earlier in the block and their +initialization involves an explicit stack allocation. To handle this, +we add an indirection and replace them with a pointer to stack space +allocated by means of ``alloca``. In most cases, we also arrange +for this space to be reclaimed when the enclosing ``BIND_EXPR`` is +exited, the exception to this being when there is an explicit call to +``alloca`` in the source code, in which case the stack is left +depressed on exit of the ``BIND_EXPR``. + +A C++ program will usually contain more ``BIND_EXPR`` s than +there are syntactic blocks in the source code, since several C++ +constructs have implicit scopes associated with them. On the +other hand, although the C++ front end uses pseudo-scopes to +handle cleanups for objects with destructors, these don't +translate into the GIMPLE form; multiple declarations at the same +level use the same ``BIND_EXPR``. + +.. index:: Statement Sequences + +.. _statement-sequences: + +Statement Sequences +^^^^^^^^^^^^^^^^^^^ + +Multiple statements at the same nesting level are collected into +a ``STATEMENT_LIST``. Statement lists are modified and +traversed using the interface in :samp:`tree-iterator.h`. + +.. index:: Empty Statements + +.. _empty-statements: + +Empty Statements +^^^^^^^^^^^^^^^^ + +Whenever possible, statements with no effect are discarded. But +if they are nested within another construct which cannot be +discarded for some reason, they are instead replaced with an +empty statement, generated by ``build_empty_stmt``. +Initially, all empty statements were shared, after the pattern of +the Java front end, but this caused a lot of trouble in practice. + +An empty statement is represented as ``(void)0``. + +.. index:: Jumps + +.. _jumps: + +Jumps +^^^^^ + +Other jumps are expressed by either ``GOTO_EXPR`` or +``RETURN_EXPR``. + +The operand of a ``GOTO_EXPR`` must be either a label or a +variable containing the address to jump to. + +The operand of a ``RETURN_EXPR`` is either ``NULL_TREE``, +``RESULT_DECL``, or a ``MODIFY_EXPR`` which sets the return +value. It would be nice to move the ``MODIFY_EXPR`` into a +separate statement, but the special return semantics in +``expand_return`` make that difficult. It may still happen in +the future, perhaps by moving most of that logic into +``expand_assignment``. + +.. index:: Cleanups + +.. _cleanups: + +Cleanups +^^^^^^^^ + +Destructors for local C++ objects and similar dynamic cleanups are +represented in GIMPLE by a ``TRY_FINALLY_EXPR``. +``TRY_FINALLY_EXPR`` has two operands, both of which are a sequence +of statements to execute. The first sequence is executed. When it +completes the second sequence is executed. + +The first sequence may complete in the following ways: + +* Execute the last statement in the sequence and fall off the + end. + +* Execute a goto statement (``GOTO_EXPR``) to an ordinary + label outside the sequence. + +* Execute a return statement (``RETURN_EXPR``). + +* Throw an exception. This is currently not explicitly represented in + GIMPLE. + +The second sequence is not executed if the first sequence completes by +calling ``setjmp`` or ``exit`` or any other function that does +not return. The second sequence is also not executed if the first +sequence completes via a non-local goto or a computed goto (in general +the compiler does not know whether such a goto statement exits the +first sequence or not, so we assume that it doesn't). + +After the second sequence is executed, if it completes normally by +falling off the end, execution continues wherever the first sequence +would have continued, by falling off the end, or doing a goto, etc. + +If the second sequence is an ``EH_ELSE_EXPR`` selector, then the +sequence in its first operand is used when the first sequence completes +normally, and that in its second operand is used for exceptional +cleanups, i.e., when an exception propagates out of the first sequence. + +``TRY_FINALLY_EXPR`` complicates the flow graph, since the cleanup +needs to appear on every edge out of the controlled block; this +reduces the freedom to move code across these edges. Therefore, the +EH lowering pass which runs before most of the optimization passes +eliminates these expressions by explicitly adding the cleanup to each +edge. Rethrowing the exception is represented using ``RESX_EXPR``. + +.. _openmp: + +OpenMP +^^^^^^ + +.. index:: OMP_PARALLEL, OMP_FOR, OMP_SECTIONS, OMP_SINGLE, OMP_SECTION, OMP_MASTER, OMP_ORDERED, OMP_CRITICAL, OMP_RETURN, OMP_CONTINUE, OMP_ATOMIC, OMP_CLAUSE + +All the statements starting with ``OMP_`` represent directives and +clauses used by the OpenMP API https://www.openmp.org. + +.. envvar:: OMP_PARALLEL + + Represents ``#pragma omp parallel [clause1 ... clauseN]``. It + has four operands: + + Operand ``OMP_PARALLEL_BODY`` is valid while in GENERIC and + High GIMPLE forms. It contains the body of code to be executed + by all the threads. During GIMPLE lowering, this operand becomes + ``NULL`` and the body is emitted linearly after + ``OMP_PARALLEL``. + + Operand ``OMP_PARALLEL_CLAUSES`` is the list of clauses + associated with the directive. + + Operand ``OMP_PARALLEL_FN`` is created by + ``pass_lower_omp``, it contains the ``FUNCTION_DECL`` + for the function that will contain the body of the parallel + region. + + Operand ``OMP_PARALLEL_DATA_ARG`` is also created by + ``pass_lower_omp``. If there are shared variables to be + communicated to the children threads, this operand will contain + the ``VAR_DECL`` that contains all the shared values and + variables. + +.. envvar:: OMP_FOR + + Represents ``#pragma omp for [clause1 ... clauseN]``. It has + six operands: + + Operand ``OMP_FOR_BODY`` contains the loop body. + + Operand ``OMP_FOR_CLAUSES`` is the list of clauses + associated with the directive. + + Operand ``OMP_FOR_INIT`` is the loop initialization code of + the form ``VAR = N1``. + + Operand ``OMP_FOR_COND`` is the loop conditional expression + of the form ``VAR {<,>,<=,>=} N2``. + + Operand ``OMP_FOR_INCR`` is the loop index increment of the + form ``VAR {+=,-=} INCR``. + + Operand ``OMP_FOR_PRE_BODY`` contains side effect code from + operands ``OMP_FOR_INIT``, ``OMP_FOR_COND`` and + ``OMP_FOR_INC``. These side effects are part of the + ``OMP_FOR`` block but must be evaluated before the start of + loop body. + + The loop index variable ``VAR`` must be a signed integer variable, + which is implicitly private to each thread. Bounds + ``N1`` and ``N2`` and the increment expression + ``INCR`` are required to be loop invariant integer + expressions that are evaluated without any synchronization. The + evaluation order, frequency of evaluation and side effects are + unspecified by the standard. + +.. envvar:: OMP_SECTIONS + + Represents ``#pragma omp sections [clause1 ... clauseN]``. + + Operand ``OMP_SECTIONS_BODY`` contains the sections body, + which in turn contains a set of ``OMP_SECTION`` nodes for + each of the concurrent sections delimited by ``#pragma omp + section``. + + Operand ``OMP_SECTIONS_CLAUSES`` is the list of clauses + associated with the directive. + +.. envvar:: OMP_SECTION + + Section delimiter for ``OMP_SECTIONS``. + +.. envvar:: OMP_SINGLE + + Represents ``#pragma omp single``. + + Operand ``OMP_SINGLE_BODY`` contains the body of code to be + executed by a single thread. + + Operand ``OMP_SINGLE_CLAUSES`` is the list of clauses + associated with the directive. + +.. envvar:: OMP_MASTER + + Represents ``#pragma omp master``. + + Operand ``OMP_MASTER_BODY`` contains the body of code to be + executed by the master thread. + +.. envvar:: OMP_ORDERED + + Represents ``#pragma omp ordered``. + + Operand ``OMP_ORDERED_BODY`` contains the body of code to be + executed in the sequential order dictated by the loop index + variable. + +.. envvar:: OMP_CRITICAL + + Represents ``#pragma omp critical [name]``. + + Operand ``OMP_CRITICAL_BODY`` is the critical section. + + Operand ``OMP_CRITICAL_NAME`` is an optional identifier to + label the critical section. + +.. envvar:: OMP_RETURN + + This does not represent any OpenMP directive, it is an artificial + marker to indicate the end of the body of an OpenMP. It is used + by the flow graph (``tree-cfg.cc``) and OpenMP region + building code (``omp-low.cc``). + +.. envvar:: OMP_CONTINUE + + Similarly, this instruction does not represent an OpenMP + directive, it is used by ``OMP_FOR`` (and similar codes) as well as + ``OMP_SECTIONS`` to mark the place where the code needs to + loop to the next iteration, or the next section, respectively. + + In some cases, ``OMP_CONTINUE`` is placed right before + ``OMP_RETURN``. But if there are cleanups that need to + occur right after the looping body, it will be emitted between + ``OMP_CONTINUE`` and ``OMP_RETURN``. + +.. envvar:: OMP_ATOMIC + + Represents ``#pragma omp atomic``. + + Operand 0 is the address at which the atomic operation is to be + performed. + + Operand 1 is the expression to evaluate. The gimplifier tries + three alternative code generation strategies. Whenever possible, + an atomic update built-in is used. If that fails, a + compare-and-swap loop is attempted. If that also fails, a + regular critical section around the expression is used. + +.. envvar:: OMP_CLAUSE + + Represents clauses associated with one of the ``OMP_`` directives. + Clauses are represented by separate subcodes defined in + :samp:`tree.h`. Clauses codes can be one of: + ``OMP_CLAUSE_PRIVATE``, ``OMP_CLAUSE_SHARED``, + ``OMP_CLAUSE_FIRSTPRIVATE``, + ``OMP_CLAUSE_LASTPRIVATE``, ``OMP_CLAUSE_COPYIN``, + ``OMP_CLAUSE_COPYPRIVATE``, ``OMP_CLAUSE_IF``, + ``OMP_CLAUSE_NUM_THREADS``, ``OMP_CLAUSE_SCHEDULE``, + ``OMP_CLAUSE_NOWAIT``, ``OMP_CLAUSE_ORDERED``, + ``OMP_CLAUSE_DEFAULT``, ``OMP_CLAUSE_REDUCTION``, + ``OMP_CLAUSE_COLLAPSE``, ``OMP_CLAUSE_UNTIED``, + ``OMP_CLAUSE_FINAL``, and ``OMP_CLAUSE_MERGEABLE``. Each code + represents the corresponding OpenMP clause. + + Clauses associated with the same directive are chained together + via ``OMP_CLAUSE_CHAIN``. Those clauses that accept a list + of variables are restricted to exactly one, accessed with + ``OMP_CLAUSE_VAR``. Therefore, multiple variables under the + same clause ``C`` need to be represented as multiple ``C`` clauses + chained together. This facilitates adding new clauses during + compilation. + +.. _openacc: + +OpenACC +^^^^^^^ + +.. index:: OACC_CACHE, OACC_DATA, OACC_DECLARE, OACC_ENTER_DATA, OACC_EXIT_DATA, OACC_HOST_DATA, OACC_KERNELS, OACC_LOOP, OACC_PARALLEL, OACC_SERIAL, OACC_UPDATE + +All the statements starting with ``OACC_`` represent directives and +clauses used by the OpenACC API https://www.openacc.org. + +.. envvar:: OACC_CACHE + + Represents ``#pragma acc cache (var ...)``. + +.. envvar:: OACC_DATA + + Represents ``#pragma acc data [clause1 ... clauseN]``. + +.. envvar:: OACC_DECLARE + + Represents ``#pragma acc declare [clause1 ... clauseN]``. + +.. envvar:: OACC_ENTER_DATA + + Represents ``#pragma acc enter data [clause1 ... clauseN]``. + +.. envvar:: OACC_EXIT_DATA + + Represents ``#pragma acc exit data [clause1 ... clauseN]``. + +.. envvar:: OACC_HOST_DATA + + Represents ``#pragma acc host_data [clause1 ... clauseN]``. + +.. envvar:: OACC_KERNELS + + Represents ``#pragma acc kernels [clause1 ... clauseN]``. + +.. envvar:: OACC_LOOP + + Represents ``#pragma acc loop [clause1 ... clauseN]``. + + See the description of the ``OMP_FOR`` code. + +.. envvar:: OACC_PARALLEL + + Represents ``#pragma acc parallel [clause1 ... clauseN]``. + +.. envvar:: OACC_SERIAL + + Represents ``#pragma acc serial [clause1 ... clauseN]``. + +.. envvar:: OACC_UPDATE + + Represents ``#pragma acc update [clause1 ... clauseN]``. \ No newline at end of file diff --git a/gcc/doc/gccint/generic/types.rst b/gcc/doc/gccint/generic/types.rst new file mode 100644 index 00000000000..b2946499960 --- /dev/null +++ b/gcc/doc/gccint/generic/types.rst @@ -0,0 +1,299 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: type, pointer, reference, fundamental type, array + +.. _types: + +Types +***** + +.. index:: VOID_TYPE, INTEGER_TYPE, TYPE_MIN_VALUE, TYPE_MAX_VALUE, REAL_TYPE, FIXED_POINT_TYPE, COMPLEX_TYPE, ENUMERAL_TYPE, BOOLEAN_TYPE, POINTER_TYPE, REFERENCE_TYPE, FUNCTION_TYPE, METHOD_TYPE, ARRAY_TYPE, RECORD_TYPE, UNION_TYPE, OPAQUE_TYPE, UNKNOWN_TYPE, OFFSET_TYPE, TYPE_UNQUALIFIED, TYPE_QUAL_CONST, TYPE_QUAL_VOLATILE, TYPE_QUAL_RESTRICT, TYPE_MAIN_VARIANT, qualified type, TYPE_SIZE, TYPE_ALIGN, TYPE_PRECISION, TYPE_ARG_TYPES, TYPE_METHOD_BASETYPE, TYPE_OFFSET_BASETYPE, TREE_TYPE, TYPE_CONTEXT, TYPE_NAME, TYPENAME_TYPE_FULLNAME, TYPE_FIELDS, TYPE_CANONICAL, TYPE_STRUCTURAL_EQUALITY_P, SET_TYPE_STRUCTURAL_EQUALITY + +All types have corresponding tree nodes. However, you should not assume +that there is exactly one tree node corresponding to each type. There +are often multiple nodes corresponding to the same type. + +For the most part, different kinds of types have different tree codes. +(For example, pointer types use a ``POINTER_TYPE`` code while arrays +use an ``ARRAY_TYPE`` code.) However, pointers to member functions +use the ``RECORD_TYPE`` code. Therefore, when writing a +``switch`` statement that depends on the code associated with a +particular type, you should take care to handle pointers to member +functions under the ``RECORD_TYPE`` case label. + +The following functions and macros deal with cv-qualification of types: + +.. envvar:: TYPE_MAIN_VARIANT + + This macro returns the unqualified version of a type. It may be applied + to an unqualified type, but it is not always the identity function in + that case. + +A few other macros and functions are usable with all types: + +.. envvar:: TYPE_SIZE + + The number of bits required to represent the type, represented as an + ``INTEGER_CST``. For an incomplete type, ``TYPE_SIZE`` will be + ``NULL_TREE``. + +.. envvar:: TYPE_ALIGN + + The alignment of the type, in bits, represented as an ``int``. + +.. envvar:: TYPE_NAME + + This macro returns a declaration (in the form of a ``TYPE_DECL``) for + the type. (Note this macro does *not* return an + ``IDENTIFIER_NODE``, as you might expect, given its name!) You can + look at the ``DECL_NAME`` of the ``TYPE_DECL`` to obtain the + actual name of the type. The ``TYPE_NAME`` will be ``NULL_TREE`` + for a type that is not a built-in type, the result of a typedef, or a + named class type. + +.. envvar:: TYPE_CANONICAL + + This macro returns the 'canonical' type for the given type + node. Canonical types are used to improve performance in the C++ and + Objective-C++ front ends by allowing efficient comparison between two + type nodes in ``same_type_p`` : if the ``TYPE_CANONICAL`` values + of the types are equal, the types are equivalent; otherwise, the types + are not equivalent. The notion of equivalence for canonical types is + the same as the notion of type equivalence in the language itself. For + instance, + + When ``TYPE_CANONICAL`` is ``NULL_TREE``, there is no canonical + type for the given type node. In this case, comparison between this + type and any other type requires the compiler to perform a deep, + 'structural' comparison to see if the two type nodes have the same + form and properties. + + The canonical type for a node is always the most fundamental type in + the equivalence class of types. For instance, ``int`` is its own + canonical type. A typedef ``I`` of ``int`` will have ``int`` + as its canonical type. Similarly, ``I*``and a typedef ``IP``(defined to ``I*``) will has ``int*`` as their canonical + type. When building a new type node, be sure to set + ``TYPE_CANONICAL`` to the appropriate canonical type. If the new + type is a compound type (built from other types), and any of those + other types require structural equality, use + ``SET_TYPE_STRUCTURAL_EQUALITY`` to ensure that the new type also + requires structural equality. Finally, if for some reason you cannot + guarantee that ``TYPE_CANONICAL`` will point to the canonical type, + use ``SET_TYPE_STRUCTURAL_EQUALITY`` to make sure that the new + type--and any type constructed based on it--requires structural + equality. If you suspect that the canonical type system is + miscomparing types, pass :option:`--param` :gcc-param:`verify-canonical-types`:samp:`=1` to + the compiler or configure with ``--enable-checking`` to force the + compiler to verify its canonical-type comparisons against the + structural comparisons; the compiler will then print any warnings if + the canonical types miscompare. + +.. envvar:: TYPE_STRUCTURAL_EQUALITY_P + + This predicate holds when the node requires structural equality + checks, e.g., when ``TYPE_CANONICAL`` is ``NULL_TREE``. + +.. envvar:: SET_TYPE_STRUCTURAL_EQUALITY + + This macro states that the type node it is given requires structural + equality checks, e.g., it sets ``TYPE_CANONICAL`` to + ``NULL_TREE``. + +``same_type_p`` + This predicate takes two types as input, and holds if they are the same + type. For example, if one type is a ``typedef`` for the other, or + both are ``typedef`` s for the same type. This predicate also holds if + the two trees given as input are simply copies of one another; i.e., + there is no difference between them at the source level, but, for + whatever reason, a duplicate has been made in the representation. You + should never use ``==`` (pointer equality) to compare types; always + use ``same_type_p`` instead. + + Detailed below are the various kinds of types, and the macros that can + be used to access them. Although other kinds of types are used + elsewhere in G++, the types described here are the only ones that you + will encounter while examining the intermediate representation. + +.. envvar:: VOID_TYPE + + Used to represent the ``void`` type. + +.. envvar:: INTEGER_TYPE + + Used to represent the various integral types, including ``char``, + ``short``, ``int``, ``long``, and ``long long``. This code + is not used for enumeration types, nor for the ``bool`` type. + The ``TYPE_PRECISION`` is the number of bits used in + the representation, represented as an ``unsigned int``. (Note that + in the general case this is not the same value as ``TYPE_SIZE`` ; + suppose that there were a 24-bit integer type, but that alignment + requirements for the ABI required 32-bit alignment. Then, + ``TYPE_SIZE`` would be an ``INTEGER_CST`` for 32, while + ``TYPE_PRECISION`` would be 24.) The integer type is unsigned if + ``TYPE_UNSIGNED`` holds; otherwise, it is signed. + + The ``TYPE_MIN_VALUE`` is an ``INTEGER_CST`` for the smallest + integer that may be represented by this type. Similarly, the + ``TYPE_MAX_VALUE`` is an ``INTEGER_CST`` for the largest integer + that may be represented by this type. + +.. envvar:: REAL_TYPE + + Used to represent the ``float``, ``double``, and ``long + double`` types. The number of bits in the floating-point representation + is given by ``TYPE_PRECISION``, as in the ``INTEGER_TYPE`` case. + +.. envvar:: FIXED_POINT_TYPE + + Used to represent the ``short _Fract``, ``_Fract``, ``long + _Fract``, ``long long _Fract``, ``short _Accum``, ``_Accum``, + ``long _Accum``, and ``long long _Accum`` types. The number of bits + in the fixed-point representation is given by ``TYPE_PRECISION``, + as in the ``INTEGER_TYPE`` case. There may be padding bits, fractional + bits and integral bits. The number of fractional bits is given by + ``TYPE_FBIT``, and the number of integral bits is given by ``TYPE_IBIT``. + The fixed-point type is unsigned if ``TYPE_UNSIGNED`` holds; otherwise, + it is signed. + The fixed-point type is saturating if ``TYPE_SATURATING`` holds; otherwise, + it is not saturating. + +.. envvar:: COMPLEX_TYPE + + Used to represent GCC built-in ``__complex__`` data types. The + ``TREE_TYPE`` is the type of the real and imaginary parts. + +.. envvar:: ENUMERAL_TYPE + + Used to represent an enumeration type. The ``TYPE_PRECISION`` gives + (as an ``int``), the number of bits used to represent the type. If + there are no negative enumeration constants, ``TYPE_UNSIGNED`` will + hold. The minimum and maximum enumeration constants may be obtained + with ``TYPE_MIN_VALUE`` and ``TYPE_MAX_VALUE``, respectively; each + of these macros returns an ``INTEGER_CST``. + + The actual enumeration constants themselves may be obtained by looking + at the ``TYPE_VALUES``. This macro will return a ``TREE_LIST``, + containing the constants. The ``TREE_PURPOSE`` of each node will be + an ``IDENTIFIER_NODE`` giving the name of the constant; the + ``TREE_VALUE`` will be an ``INTEGER_CST`` giving the value + assigned to that constant. These constants will appear in the order in + which they were declared. The ``TREE_TYPE`` of each of these + constants will be the type of enumeration type itself. + +.. envvar:: OPAQUE_TYPE + + Used for things that have a ``MODE_OPAQUE`` mode class in the + backend. Opaque types have a size and precision, and can be held in + memory or registers. They are used when we do not want the compiler to + make assumptions about the availability of other operations as would + happen with integer types. + +.. envvar:: BOOLEAN_TYPE + + Used to represent the ``bool`` type. + +.. envvar:: POINTER_TYPE + + Used to represent pointer types, and pointer to data member types. The + ``TREE_TYPE`` gives the type to which this type points. + +.. envvar:: REFERENCE_TYPE + + Used to represent reference types. The ``TREE_TYPE`` gives the type + to which this type refers. + +.. envvar:: FUNCTION_TYPE + + Used to represent the type of non-member functions and of static member + functions. The ``TREE_TYPE`` gives the return type of the function. + The ``TYPE_ARG_TYPES`` are a ``TREE_LIST`` of the argument types. + The ``TREE_VALUE`` of each node in this list is the type of the + corresponding argument; the ``TREE_PURPOSE`` is an expression for the + default argument value, if any. If the last node in the list is + ``void_list_node`` (a ``TREE_LIST`` node whose ``TREE_VALUE`` + is the ``void_type_node``), then functions of this type do not take + variable arguments. Otherwise, they do take a variable number of + arguments. + + Note that in C (but not in C++) a function declared like ``void f()`` + is an unprototyped function taking a variable number of arguments; the + ``TYPE_ARG_TYPES`` of such a function will be ``NULL``. + +.. envvar:: METHOD_TYPE + + Used to represent the type of a non-static member function. Like a + ``FUNCTION_TYPE``, the return type is given by the ``TREE_TYPE``. + The type of ``*this``, i.e., the class of which functions of this + type are a member, is given by the ``TYPE_METHOD_BASETYPE``. The + ``TYPE_ARG_TYPES`` is the parameter list, as for a + ``FUNCTION_TYPE``, and includes the ``this`` argument. + +.. envvar:: ARRAY_TYPE + + Used to represent array types. The ``TREE_TYPE`` gives the type of + the elements in the array. If the array-bound is present in the type, + the ``TYPE_DOMAIN`` is an ``INTEGER_TYPE`` whose + ``TYPE_MIN_VALUE`` and ``TYPE_MAX_VALUE`` will be the lower and + upper bounds of the array, respectively. The ``TYPE_MIN_VALUE`` will + always be an ``INTEGER_CST`` for zero, while the + ``TYPE_MAX_VALUE`` will be one less than the number of elements in + the array, i.e., the highest value which may be used to index an element + in the array. + +.. envvar:: RECORD_TYPE + + Used to represent ``struct`` and ``class`` types, as well as + pointers to member functions and similar constructs in other languages. + ``TYPE_FIELDS`` contains the items contained in this type, each of + which can be a ``FIELD_DECL``, ``VAR_DECL``, ``CONST_DECL``, or + ``TYPE_DECL``. You may not make any assumptions about the ordering + of the fields in the type or whether one or more of them overlap. + +.. envvar:: UNION_TYPE + + Used to represent ``union`` types. Similar to ``RECORD_TYPE`` + except that all ``FIELD_DECL`` nodes in ``TYPE_FIELD`` start at + bit position zero. + +.. envvar:: QUAL_UNION_TYPE + + Used to represent part of a variant record in Ada. Similar to + ``UNION_TYPE`` except that each ``FIELD_DECL`` has a + ``DECL_QUALIFIER`` field, which contains a boolean expression that + indicates whether the field is present in the object. The type will only + have one field, so each field's ``DECL_QUALIFIER`` is only evaluated + if none of the expressions in the previous fields in ``TYPE_FIELDS`` + are nonzero. Normally these expressions will reference a field in the + outer object using a ``PLACEHOLDER_EXPR``. + +.. envvar:: LANG_TYPE + + This node is used to represent a language-specific type. The front + end must handle it. + +.. envvar:: OFFSET_TYPE + + This node is used to represent a pointer-to-data member. For a data + member ``X::m`` the ``TYPE_OFFSET_BASETYPE`` is ``X`` and the + ``TREE_TYPE`` is the type of ``m``. + +There are variables whose values represent some of the basic types. +These include: + +``void_type_node`` + A node for ``void``. + +``integer_type_node`` + A node for ``int``. + +``unsigned_type_node.`` + A node for ``unsigned int``. + +``char_type_node.`` + A node for ``char``. + + It may sometimes be useful to compare one of these variables with a type + in hand, using ``same_type_p``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple-api.rst b/gcc/doc/gccint/gimple-api.rst new file mode 100644 index 00000000000..e91a790f681 --- /dev/null +++ b/gcc/doc/gccint/gimple-api.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE API + +.. _gimple-api: + +GIMPLE API +********** + +.. function:: tree gimple_simplify (enum tree_code, tree, tree, gimple_seq *, tree (*)(tree)) + tree gimple_simplify (enum tree_code, tree, tree, tree, gimple_seq *, tree (*)(tree)) + tree gimple_simplify (enum tree_code, tree, tree, tree, tree, gimple_seq *, tree (*)(tree)) + tree gimple_simplify (enum built_in_function, tree, tree, gimple_seq *, tree (*)(tree)) + tree gimple_simplify (enum built_in_function, tree, tree, tree, gimple_seq *, tree (*)(tree)) + tree gimple_simplify (enum built_in_function, tree, tree, tree, tree, gimple_seq *, tree (*)(tree)) + + The main GIMPLE API entry to the expression simplifications mimicking + that of the GENERIC fold_{unary,binary,ternary} functions. + +thus providing n-ary overloads for operation or function. The +additional arguments are a gimple_seq where built statements are +inserted on (if ``NULL`` then simplifications requiring new statements +are not performed) and a valueization hook that can be used to +tie simplifications to a SSA lattice. + +In addition to those APIs ``fold_stmt`` is overloaded with +a valueization hook: + +.. function:: fold_stmt (gimple_stmt_iterator *, tree (*)(tree)); + +On top of these a ``fold_buildN`` -like API for GIMPLE is introduced: + +.. function:: tree gimple_build (gimple_seq *, location_t, enum tree_code, tree, tree, tree (*valueize) (tree) = NULL); + tree gimple_build (gimple_seq *, location_t, enum tree_code, tree, tree, tree, tree (*valueize) (tree) = NULL); + tree gimple_build (gimple_seq *, location_t, enum tree_code, tree, tree, tree, tree, tree (*valueize) (tree) = NULL); + tree gimple_build (gimple_seq *, location_t, enum built_in_function, tree, tree, tree (*valueize) (tree) = NULL); + tree gimple_build (gimple_seq *, location_t, enum built_in_function, tree, tree, tree, tree (*valueize) (tree) = NULL); + tree gimple_build (gimple_seq *, location_t, enum built_in_function, tree, tree, tree, tree, tree (*valueize) (tree) = NULL); + tree gimple_convert (gimple_seq *, location_t, tree, tree); + +which is supposed to replace ``force_gimple_operand (fold_buildN (...), ...)`` +and calls to ``fold_convert``. Overloads without the ``location_t`` +argument exist. Built statements are inserted on the provided sequence +and simplification is performed using the optional valueization hook. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple.rst b/gcc/doc/gccint/gimple.rst new file mode 100644 index 00000000000..fa653bb018a --- /dev/null +++ b/gcc/doc/gccint/gimple.rst @@ -0,0 +1,88 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE + +.. _gimple: + +GIMPLE +------ + +GIMPLE is a three-address representation derived from GENERIC by +breaking down GENERIC expressions into tuples of no more than 3 +operands (with some exceptions like function calls). GIMPLE was +heavily influenced by the SIMPLE IL used by the McCAT compiler +project at McGill University, though we have made some different +choices. For one thing, SIMPLE doesn't support ``goto``. + +Temporaries are introduced to hold intermediate values needed to +compute complex expressions. Additionally, all the control +structures used in GENERIC are lowered into conditional jumps, +lexical scopes are removed and exception regions are converted +into an on the side exception region tree. + +The compiler pass which converts GENERIC into GIMPLE is referred to as +the :samp:`gimplifier`. The gimplifier works recursively, generating +GIMPLE tuples out of the original GENERIC expressions. + +One of the early implementation strategies used for the GIMPLE +representation was to use the same internal data structures used +by front ends to represent parse trees. This simplified +implementation because we could leverage existing functionality +and interfaces. However, GIMPLE is a much more restrictive +representation than abstract syntax trees (AST), therefore it +does not require the full structural complexity provided by the +main tree data structure. + +The GENERIC representation of a function is stored in the +``DECL_SAVED_TREE`` field of the associated ``FUNCTION_DECL`` +tree node. It is converted to GIMPLE by a call to +``gimplify_function_tree``. + +If a front end wants to include language-specific tree codes in the tree +representation which it provides to the back end, it must provide a +definition of ``LANG_HOOKS_GIMPLIFY_EXPR`` which knows how to +convert the front end trees to GIMPLE. Usually such a hook will involve +much of the same code for expanding front end trees to RTL. This function +can return fully lowered GIMPLE, or it can return GENERIC trees and let the +main gimplifier lower them the rest of the way; this is often simpler. +GIMPLE that is not fully lowered is known as 'High GIMPLE' and +consists of the IL before the pass ``pass_lower_cf``. High GIMPLE +contains some container statements like lexical scopes +(represented by ``GIMPLE_BIND``) and nested expressions (e.g., +``GIMPLE_TRY``), while 'Low GIMPLE' exposes all of the +implicit jumps for control and exception expressions directly in +the IL and EH region trees. + +The C and C++ front ends currently convert directly from front end +trees to GIMPLE, and hand that off to the back end rather than first +converting to GENERIC. Their gimplifier hooks know about all the +``_STMT`` nodes and how to convert them to GENERIC forms. There +was some work done on a genericization pass which would run first, but +the existence of ``STMT_EXPR`` meant that in order to convert all +of the C statements into GENERIC equivalents would involve walking the +entire tree anyway, so it was simpler to lower all the way. This +might change in the future if someone writes an optimization pass +which would work better with higher-level trees, but currently the +optimizers all expect GIMPLE. + +You can request to dump a C-like representation of the GIMPLE form +with the flag :option:`-fdump-tree-gimple`. + +.. toctree:: + :maxdepth: 2 + + gimple/tuple-representation + gimple/class-hierarchy-of-gimple-statements + gimple/gimple-instruction-set + gimple/temporaries + gimple/operands + gimple/manipulating-gimple-statements + gimple/tuple-specific-accessors + gimple/gimple-sequences + gimple/sequence-iterators + gimple/adding-a-new-gimple-statement-code + gimple/statement-and-operand-traversals + gimple/exception-handling \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/adding-a-new-gimple-statement-code.rst b/gcc/doc/gccint/gimple/adding-a-new-gimple-statement-code.rst new file mode 100644 index 00000000000..aa8b81cc6c5 --- /dev/null +++ b/gcc/doc/gccint/gimple/adding-a-new-gimple-statement-code.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Adding a new GIMPLE statement code + +.. _adding-a-new-gimple-statement-code: + +Adding a new GIMPLE statement code +********************************** + +The first step in adding a new GIMPLE statement code, is +modifying the file ``gimple.def``, which contains all the GIMPLE +codes. Then you must add a corresponding gimple subclass +located in ``gimple.h``. This in turn, will require you to add a +corresponding ``GTY`` tag in ``gsstruct.def``, and code to handle +this tag in ``gss_for_code`` which is located in ``gimple.cc``. + +In order for the garbage collector to know the size of the +structure you created in ``gimple.h``, you need to add a case to +handle your new GIMPLE statement in ``gimple_size`` which is located +in ``gimple.cc``. + +You will probably want to create a function to build the new +gimple statement in ``gimple.cc``. The function should be called +``gimple_build_new-tuple-name``, and should return the new tuple +as a pointer to the appropriate gimple subclass. + +If your new statement requires accessors for any members or +operands it may have, put simple inline accessors in +``gimple.h`` and any non-trivial accessors in ``gimple.cc`` with a +corresponding prototype in ``gimple.h``. + +You should add the new statement subclass to the class hierarchy diagram +in ``gimple.texi``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/class-hierarchy-of-gimple-statements.rst b/gcc/doc/gccint/gimple/class-hierarchy-of-gimple-statements.rst new file mode 100644 index 00000000000..b7d3b897fc1 --- /dev/null +++ b/gcc/doc/gccint/gimple/class-hierarchy-of-gimple-statements.rst @@ -0,0 +1,150 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE class hierarchy + +.. _class-hierarchy-of-gimple-statements: + +Class hierarchy of GIMPLE statements +************************************ + +The following diagram shows the C++ inheritance hierarchy of statement +kinds, along with their relationships to ``GSS_`` values (layouts) and +``GIMPLE_`` values (codes): + +.. code-block:: c++ + + gimple + | layout: GSS_BASE + | used for 4 codes: GIMPLE_ERROR_MARK + | GIMPLE_NOP + | GIMPLE_OMP_SECTIONS_SWITCH + | GIMPLE_PREDICT + | + + gimple_statement_with_ops_base + | | (no GSS layout) + | | + | + gimple_statement_with_ops + | | | layout: GSS_WITH_OPS + | | | + | | + gcond + | | | code: GIMPLE_COND + | | | + | | + gdebug + | | | code: GIMPLE_DEBUG + | | | + | | + ggoto + | | | code: GIMPLE_GOTO + | | | + | | + glabel + | | | code: GIMPLE_LABEL + | | | + | | + gswitch + | | code: GIMPLE_SWITCH + | | + | + gimple_statement_with_memory_ops_base + | | layout: GSS_WITH_MEM_OPS_BASE + | | + | + gimple_statement_with_memory_ops + | | | layout: GSS_WITH_MEM_OPS + | | | + | | + gassign + | | | code GIMPLE_ASSIGN + | | | + | | + greturn + | | code GIMPLE_RETURN + | | + | + gcall + | | layout: GSS_CALL, code: GIMPLE_CALL + | | + | + gasm + | | layout: GSS_ASM, code: GIMPLE_ASM + | | + | + gtransaction + | layout: GSS_TRANSACTION, code: GIMPLE_TRANSACTION + | + + gimple_statement_omp + | | layout: GSS_OMP. Used for code GIMPLE_OMP_SECTION + | | + | + gomp_critical + | | layout: GSS_OMP_CRITICAL, code: GIMPLE_OMP_CRITICAL + | | + | + gomp_for + | | layout: GSS_OMP_FOR, code: GIMPLE_OMP_FOR + | | + | + gomp_parallel_layout + | | | layout: GSS_OMP_PARALLEL_LAYOUT + | | | + | | + gimple_statement_omp_taskreg + | | | | + | | | + gomp_parallel + | | | | code: GIMPLE_OMP_PARALLEL + | | | | + | | | + gomp_task + | | | code: GIMPLE_OMP_TASK + | | | + | | + gimple_statement_omp_target + | | code: GIMPLE_OMP_TARGET + | | + | + gomp_sections + | | layout: GSS_OMP_SECTIONS, code: GIMPLE_OMP_SECTIONS + | | + | + gimple_statement_omp_single_layout + | | layout: GSS_OMP_SINGLE_LAYOUT + | | + | + gomp_single + | | code: GIMPLE_OMP_SINGLE + | | + | + gomp_teams + | code: GIMPLE_OMP_TEAMS + | + + gbind + | layout: GSS_BIND, code: GIMPLE_BIND + | + + gcatch + | layout: GSS_CATCH, code: GIMPLE_CATCH + | + + geh_filter + | layout: GSS_EH_FILTER, code: GIMPLE_EH_FILTER + | + + geh_else + | layout: GSS_EH_ELSE, code: GIMPLE_EH_ELSE + | + + geh_mnt + | layout: GSS_EH_MNT, code: GIMPLE_EH_MUST_NOT_THROW + | + + gphi + | layout: GSS_PHI, code: GIMPLE_PHI + | + + gimple_statement_eh_ctrl + | | layout: GSS_EH_CTRL + | | + | + gresx + | | code: GIMPLE_RESX + | | + | + geh_dispatch + | code: GIMPLE_EH_DISPATCH + | + + gtry + | layout: GSS_TRY, code: GIMPLE_TRY + | + + gimple_statement_wce + | layout: GSS_WCE, code: GIMPLE_WITH_CLEANUP_EXPR + | + + gomp_continue + | layout: GSS_OMP_CONTINUE, code: GIMPLE_OMP_CONTINUE + | + + gomp_atomic_load + | layout: GSS_OMP_ATOMIC_LOAD, code: GIMPLE_OMP_ATOMIC_LOAD + | + + gimple_statement_omp_atomic_store_layout + | layout: GSS_OMP_ATOMIC_STORE_LAYOUT, + | code: GIMPLE_OMP_ATOMIC_STORE + | + + gomp_atomic_store + | code: GIMPLE_OMP_ATOMIC_STORE + | + + gomp_return + code: GIMPLE_OMP_RETURN \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/exception-handling.rst b/gcc/doc/gccint/gimple/exception-handling.rst new file mode 100644 index 00000000000..a34fcfe2bc0 --- /dev/null +++ b/gcc/doc/gccint/gimple/exception-handling.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE Exception Handling + +.. _gimple-exception-handling: + +Exception Handling +****************** + +Other exception handling constructs are represented using +``GIMPLE_TRY_CATCH``. ``GIMPLE_TRY_CATCH`` has two operands. The +first operand is a sequence of statements to execute. If executing +these statements does not throw an exception, then the second operand +is ignored. Otherwise, if an exception is thrown, then the second +operand of the ``GIMPLE_TRY_CATCH`` is checked. The second +operand may have the following forms: + +* A sequence of statements to execute. When an exception occurs, + these statements are executed, and then the exception is rethrown. + +* A sequence of ``GIMPLE_CATCH`` statements. Each + ``GIMPLE_CATCH`` has a list of applicable exception types and + handler code. If the thrown exception matches one of the caught + types, the associated handler code is executed. If the handler + code falls off the bottom, execution continues after the original + ``GIMPLE_TRY_CATCH``. + +* A ``GIMPLE_EH_FILTER`` statement. This has a list of + permitted exception types, and code to handle a match failure. If the + thrown exception does not match one of the allowed types, the + associated match failure code is executed. If the thrown exception + does match, it continues unwinding the stack looking for the next + handler. + +Currently throwing an exception is not directly represented in +GIMPLE, since it is implemented by calling a function. At some +point in the future we will want to add some way to express that +the call will throw an exception of a known type. + +Just before running the optimizers, the compiler lowers the +high-level EH constructs above into a set of ``goto`` s, magic +labels, and EH regions. Continuing to unwind at the end of a +cleanup is represented with a ``GIMPLE_RESX``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/gimple-instruction-set.rst b/gcc/doc/gccint/gimple/gimple-instruction-set.rst new file mode 100644 index 00000000000..07a4fd09bd8 --- /dev/null +++ b/gcc/doc/gccint/gimple/gimple-instruction-set.rst @@ -0,0 +1,106 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE instruction set + +.. _gimple-instruction-set: + +GIMPLE instruction set +********************** + +The following table briefly describes the GIMPLE instruction set. + +.. list-table:: + + * - Instruction + - High GIMPLE + - Low GIMPLE + * - ``GIMPLE_ASM`` + - x + - x + * - ``GIMPLE_ASSIGN`` + - x + - x + * - ``GIMPLE_BIND`` + - x + - + * - ``GIMPLE_CALL`` + - x + - x + * - ``GIMPLE_CATCH`` + - x + - + * - ``GIMPLE_COND`` + - x + - x + * - ``GIMPLE_DEBUG`` + - x + - x + * - ``GIMPLE_EH_FILTER`` + - x + - + * - ``GIMPLE_GOTO`` + - x + - x + * - ``GIMPLE_LABEL`` + - x + - x + * - ``GIMPLE_NOP`` + - x + - x + * - ``GIMPLE_OMP_ATOMIC_LOAD`` + - x + - x + * - ``GIMPLE_OMP_ATOMIC_STORE`` + - x + - x + * - ``GIMPLE_OMP_CONTINUE`` + - x + - x + * - ``GIMPLE_OMP_CRITICAL`` + - x + - x + * - ``GIMPLE_OMP_FOR`` + - x + - x + * - ``GIMPLE_OMP_MASTER`` + - x + - x + * - ``GIMPLE_OMP_ORDERED`` + - x + - x + * - ``GIMPLE_OMP_PARALLEL`` + - x + - x + * - ``GIMPLE_OMP_RETURN`` + - x + - x + * - ``GIMPLE_OMP_SECTION`` + - x + - x + * - ``GIMPLE_OMP_SECTIONS`` + - x + - x + * - ``GIMPLE_OMP_SECTIONS_SWITCH`` + - x + - x + * - ``GIMPLE_OMP_SINGLE`` + - x + - x + * - ``GIMPLE_PHI`` + - + - x + * - ``GIMPLE_RESX`` + - + - x + * - ``GIMPLE_RETURN`` + - x + - x + * - ``GIMPLE_SWITCH`` + - x + - x + * - ``GIMPLE_TRY`` + - x + - \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/gimple-sequences.rst b/gcc/doc/gccint/gimple/gimple-sequences.rst new file mode 100644 index 00000000000..2c52cb5d39d --- /dev/null +++ b/gcc/doc/gccint/gimple/gimple-sequences.rst @@ -0,0 +1,94 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE sequences + +.. _gimple-sequences: + +GIMPLE sequences +**************** + +GIMPLE sequences are the tuple equivalent of ``STATEMENT_LIST`` 's +used in ``GENERIC``. They are used to chain statements together, and +when used in conjunction with sequence iterators, provide a +framework for iterating through statements. + +GIMPLE sequences are of type struct ``gimple_sequence``, but are more +commonly passed by reference to functions dealing with sequences. +The type for a sequence pointer is ``gimple_seq`` which is the same +as struct ``gimple_sequence`` \*. When declaring a local sequence, +you can define a local variable of type struct ``gimple_sequence``. +When declaring a sequence allocated on the garbage collected +heap, use the function ``gimple_seq_alloc`` documented below. + +There are convenience functions for iterating through sequences +in the section entitled Sequence Iterators. + +Below is a list of functions to manipulate and query sequences. + +.. function:: void gimple_seq_add_stmt (gimple_seq *seq, gimple g) + + Link a gimple statement to the end of the sequence \* ``SEQ`` if ``G`` is + not ``NULL``. If \* ``SEQ`` is ``NULL``, allocate a sequence before linking. + +.. function:: void gimple_seq_add_seq (gimple_seq *dest, gimple_seq src) + + Append sequence ``SRC`` to the end of sequence \* ``DEST`` if ``SRC`` is not + ``NULL``. If \* ``DEST`` is ``NULL``, allocate a new sequence before + appending. + +.. function:: gimple_seq gimple_seq_deep_copy (gimple_seq src) + + Perform a deep copy of sequence ``SRC`` and return the result. + +.. function:: gimple_seq gimple_seq_reverse (gimple_seq seq) + + Reverse the order of the statements in the sequence ``SEQ``. Return + ``SEQ``. + +.. function:: gimple gimple_seq_first (gimple_seq s) + + Return the first statement in sequence ``S``. + +.. function:: gimple gimple_seq_last (gimple_seq s) + + Return the last statement in sequence ``S``. + +.. function:: void gimple_seq_set_last (gimple_seq s, gimple last) + + Set the last statement in sequence ``S`` to the statement in ``LAST``. + +.. function:: void gimple_seq_set_first (gimple_seq s, gimple first) + + Set the first statement in sequence ``S`` to the statement in ``FIRST``. + +.. function:: void gimple_seq_init (gimple_seq s) + + Initialize sequence ``S`` to an empty sequence. + +.. function:: gimple_seq gimple_seq_alloc (void) + + Allocate a new sequence in the garbage collected store and return + it. + +.. function:: void gimple_seq_copy (gimple_seq dest, gimple_seq src) + + Copy the sequence ``SRC`` into the sequence ``DEST``. + +.. function:: bool gimple_seq_empty_p (gimple_seq s) + + Return true if the sequence ``S`` is empty. + +.. function:: gimple_seq bb_seq (basic_block bb) + + Returns the sequence of statements in ``BB``. + +.. function:: void set_bb_seq (basic_block bb, gimple_seq seq) + + Sets the sequence of statements in ``BB`` to ``SEQ``. + +.. function:: bool gimple_seq_singleton_p (gimple_seq seq) + + Determine whether ``SEQ`` contains exactly one statement. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/manipulating-gimple-statements.rst b/gcc/doc/gccint/gimple/manipulating-gimple-statements.rst new file mode 100644 index 00000000000..60415a17f0c --- /dev/null +++ b/gcc/doc/gccint/gimple/manipulating-gimple-statements.rst @@ -0,0 +1,176 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Manipulating GIMPLE statements + +.. _manipulating-gimple-statements: + +Manipulating GIMPLE statements +****************************** + +This section documents all the functions available to handle each +of the GIMPLE instructions. + +Common accessors +^^^^^^^^^^^^^^^^ + +The following are common accessors for gimple statements. + +.. function:: enum gimple_code gimple_code (gimple g) + + Return the code for statement ``G``. + +.. function:: basic_block gimple_bb (gimple g) + + Return the basic block to which statement ``G`` belongs to. + +.. function:: tree gimple_block (gimple g) + + Return the lexical scope block holding statement ``G``. + +.. function:: enum tree_code gimple_expr_code (gimple stmt) + + Return the tree code for the expression computed by ``STMT``. This + is only meaningful for ``GIMPLE_CALL``, ``GIMPLE_ASSIGN`` and + ``GIMPLE_COND``. If ``STMT`` is ``GIMPLE_CALL``, it will return ``CALL_EXPR``. + For ``GIMPLE_COND``, it returns the code of the comparison predicate. + For ``GIMPLE_ASSIGN`` it returns the code of the operation performed + by the ``RHS`` of the assignment. + +.. function:: void gimple_set_block (gimple g, tree block) + + Set the lexical scope block of ``G`` to ``BLOCK``. + +.. function:: location_t gimple_locus (gimple g) + + Return locus information for statement ``G``. + +.. function:: void gimple_set_locus (gimple g, location_t locus) + + Set locus information for statement ``G``. + +.. function:: bool gimple_locus_empty_p (gimple g) + + Return true if ``G`` does not have locus information. + +.. function:: bool gimple_no_warning_p (gimple stmt) + + Return true if no warnings should be emitted for statement ``STMT``. + +.. function:: void gimple_set_visited (gimple stmt, bool visited_p) + + Set the visited status on statement ``STMT`` to ``VISITED_P``. + +.. function:: bool gimple_visited_p (gimple stmt) + + Return the visited status on statement ``STMT``. + +.. function:: void gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p) + + Set pass local flag ``PLF`` on statement ``STMT`` to ``VAL_P``. + +.. function:: unsigned int gimple_plf (gimple stmt, enum plf_mask plf) + + Return the value of pass local flag ``PLF`` on statement ``STMT``. + +.. function:: bool gimple_has_ops (gimple g) + + Return true if statement ``G`` has register or memory operands. + +.. function:: bool gimple_has_mem_ops (gimple g) + + Return true if statement ``G`` has memory operands. + +.. function:: unsigned gimple_num_ops (gimple g) + + Return the number of operands for statement ``G``. + +.. function:: tree * gimple_ops (gimple g) + + Return the array of operands for statement ``G``. + +.. function:: tree gimple_op (gimple g, unsigned i) + + Return operand ``I`` for statement ``G``. + +.. function:: tree * gimple_op_ptr (gimple g, unsigned i) + + Return a pointer to operand ``I`` for statement ``G``. + +.. function:: void gimple_set_op (gimple g, unsigned i, tree op) + + Set operand ``I`` of statement ``G`` to ``OP``. + +.. function:: bitmap gimple_addresses_taken (gimple stmt) + + Return the set of symbols that have had their address taken by + ``STMT``. + +.. function:: struct def_optype_d * gimple_def_ops (gimple g) + + Return the set of ``DEF`` operands for statement ``G``. + +.. function:: void gimple_set_def_ops (gimple g, struct def_optype_d *def) + + Set ``DEF`` to be the set of ``DEF`` operands for statement ``G``. + +.. function:: struct use_optype_d * gimple_use_ops (gimple g) + + Return the set of ``USE`` operands for statement ``G``. + +.. function:: void gimple_set_use_ops (gimple g, struct use_optype_d *use) + + Set ``USE`` to be the set of ``USE`` operands for statement ``G``. + +.. function:: struct voptype_d * gimple_vuse_ops (gimple g) + + Return the set of ``VUSE`` operands for statement ``G``. + +.. function:: void gimple_set_vuse_ops (gimple g, struct voptype_d *ops) + + Set ``OPS`` to be the set of ``VUSE`` operands for statement ``G``. + +.. function:: struct voptype_d * gimple_vdef_ops (gimple g) + + Return the set of ``VDEF`` operands for statement ``G``. + +.. function:: void gimple_set_vdef_ops (gimple g, struct voptype_d *ops) + + Set ``OPS`` to be the set of ``VDEF`` operands for statement ``G``. + +.. function:: bitmap gimple_loaded_syms (gimple g) + + Return the set of symbols loaded by statement ``G``. Each element of + the set is the ``DECL_UID`` of the corresponding symbol. + +.. function:: bitmap gimple_stored_syms (gimple g) + + Return the set of symbols stored by statement ``G``. Each element of + the set is the ``DECL_UID`` of the corresponding symbol. + +.. function:: bool gimple_modified_p (gimple g) + + Return true if statement ``G`` has operands and the modified field + has been set. + +.. function:: bool gimple_has_volatile_ops (gimple stmt) + + Return true if statement ``STMT`` contains volatile operands. + +.. function:: void gimple_set_has_volatile_ops (gimple stmt, bool volatilep) + + Return true if statement ``STMT`` contains volatile operands. + +.. function:: void update_stmt (gimple s) + + Mark statement ``S`` as modified, and update it. + +.. function:: void update_stmt_if_modified (gimple s) + + Update statement ``S`` if it has been marked modified. + +.. function:: gimple gimple_copy (gimple stmt) + + Return a deep copy of statement ``STMT``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/operands.rst b/gcc/doc/gccint/gimple/operands.rst new file mode 100644 index 00000000000..715dae80b4b --- /dev/null +++ b/gcc/doc/gccint/gimple/operands.rst @@ -0,0 +1,319 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Operands + +.. _operands: + +Operands +******** + +In general, expressions in GIMPLE consist of an operation and the +appropriate number of simple operands; these operands must either be a +GIMPLE rvalue (``is_gimple_val``), i.e. a constant or a register +variable. More complex operands are factored out into temporaries, so +that + +.. code-block:: c++ + + a = b + c + d + +becomes + +.. code-block:: c++ + + T1 = b + c; + a = T1 + d; + +The same rule holds for arguments to a ``GIMPLE_CALL``. + +The target of an assignment is usually a variable, but can also be a +``MEM_REF`` or a compound lvalue as described below. + +.. toctree:: + :maxdepth: 2 + + +.. index:: Compound Expressions + +.. _compound-expressions: + +Compound Expressions +^^^^^^^^^^^^^^^^^^^^ + +The left-hand side of a C comma expression is simply moved into a separate +statement. + +.. index:: Compound Lvalues + +.. _compound-lvalues: + +Compound Lvalues +^^^^^^^^^^^^^^^^ + +Currently compound lvalues involving array and structure field references +are not broken down; an expression like ``a.b[2] = 42`` is not reduced +any further (though complex array subscripts are). This restriction is a +workaround for limitations in later optimizers; if we were to convert this +to + +.. code-block:: c++ + + T1 = &a.b; + T1[2] = 42; + +alias analysis would not remember that the reference to ``T1[2]`` came +by way of ``a.b``, so it would think that the assignment could alias +another member of ``a`` ; this broke ``struct-alias-1.c``. Future +optimizer improvements may make this limitation unnecessary. + +.. index:: Conditional Expressions + +.. _conditional-expressions: + +Conditional Expressions +^^^^^^^^^^^^^^^^^^^^^^^ + +A C ``?:`` expression is converted into an ``if`` statement with +each branch assigning to the same temporary. So, + +.. code-block:: c++ + + a = b ? c : d; + +becomes + +.. code-block:: c++ + + if (b == 1) + T1 = c; + else + T1 = d; + a = T1; + +The GIMPLE level if-conversion pass re-introduces ``?:`` +expression, if appropriate. It is used to vectorize loops with +conditions using vector conditional operations. + +Note that in GIMPLE, ``if`` statements are represented using +``GIMPLE_COND``, as described below. + +.. index:: Logical Operators + +.. _logical-operators: + +Logical Operators +^^^^^^^^^^^^^^^^^ + +Except when they appear in the condition operand of a +``GIMPLE_COND``, logical 'and' and 'or' operators are simplified +as follows: ``a = b && c`` becomes + +.. code-block:: c++ + + T1 = (bool)b; + if (T1 == true) + T1 = (bool)c; + a = T1; + +Note that ``T1`` in this example cannot be an expression temporary, +because it has two different assignments. + +Manipulating operands +^^^^^^^^^^^^^^^^^^^^^ + +All gimple operands are of type ``tree``. But only certain +types of trees are allowed to be used as operand tuples. Basic +validation is controlled by the function +``get_gimple_rhs_class``, which given a tree code, returns an +``enum`` with the following values of type ``enum +gimple_rhs_class`` + +* ``GIMPLE_INVALID_RHS`` + The tree cannot be used as a GIMPLE operand. + +* ``GIMPLE_TERNARY_RHS`` + The tree is a valid GIMPLE ternary operation. + +* ``GIMPLE_BINARY_RHS`` + The tree is a valid GIMPLE binary operation. + +* ``GIMPLE_UNARY_RHS`` + The tree is a valid GIMPLE unary operation. + +* ``GIMPLE_SINGLE_RHS`` + The tree is a single object, that cannot be split into simpler + operands (for instance, ``SSA_NAME``, ``VAR_DECL``, ``COMPONENT_REF``, etc). + + This operand class also acts as an escape hatch for tree nodes + that may be flattened out into the operand vector, but would need + more than two slots on the RHS. For instance, a ``COND_EXPR`` + expression of the form ``(a op b) ? x : y`` could be flattened + out on the operand vector using 4 slots, but it would also + require additional processing to distinguish ``c = a op b`` + from ``c = a op b ? x : y``. Something similar occurs with + ``ASSERT_EXPR``. In time, these special case tree + expressions should be flattened into the operand vector. + +For tree nodes in the categories ``GIMPLE_TERNARY_RHS``, +``GIMPLE_BINARY_RHS`` and ``GIMPLE_UNARY_RHS``, they cannot be +stored inside tuples directly. They first need to be flattened and +separated into individual components. For instance, given the GENERIC +expression + +.. code-block:: c++ + + a = b + c + +its tree representation is: + +.. code-block:: c++ + + MODIFY_EXPR , PLUS_EXPR , VAR_DECL >> + +In this case, the GIMPLE form for this statement is logically +identical to its GENERIC form but in GIMPLE, the ``PLUS_EXPR`` +on the RHS of the assignment is not represented as a tree, +instead the two operands are taken out of the ``PLUS_EXPR`` sub-tree +and flattened into the GIMPLE tuple as follows: + +.. code-block:: c++ + + GIMPLE_ASSIGN , VAR_DECL , VAR_DECL > + +Operand vector allocation +^^^^^^^^^^^^^^^^^^^^^^^^^ + +The operand vector is stored at the bottom of the three tuple +structures that accept operands. This means, that depending on +the code of a given statement, its operand vector will be at +different offsets from the base of the structure. To access +tuple operands use the following accessors + +.. function:: unsigned gimple_num_ops (gimple g) + + Returns the number of operands in statement G. + +.. function:: tree gimple_op (gimple g, unsigned i) + + Returns operand ``I`` from statement ``G``. + +.. function:: tree * gimple_ops (gimple g) + + Returns a pointer into the operand vector for statement ``G``. This + is computed using an internal table called ``gimple_ops_offset_`` []. + This table is indexed by the gimple code of ``G``. + + When the compiler is built, this table is filled-in using the + sizes of the structures used by each statement code defined in + gimple.def. Since the operand vector is at the bottom of the + structure, for a gimple code ``C`` the offset is computed as sizeof + (struct-of ``C``) - sizeof (tree). + + This mechanism adds one memory indirection to every access when + using ``gimple_op`` (), if this becomes a bottleneck, a pass can + choose to memoize the result from ``gimple_ops`` () and use that to + access the operands. + +Operand validation +^^^^^^^^^^^^^^^^^^ + +When adding a new operand to a gimple statement, the operand will +be validated according to what each tuple accepts in its operand +vector. These predicates are called by the +``gimple_name_set_...()``. Each tuple will use one of the +following predicates (Note, this list is not exhaustive): + +.. function:: bool is_gimple_val (tree t) + + Returns true if t is a "GIMPLE value", which are all the + non-addressable stack variables (variables for which + ``is_gimple_reg`` returns true) and constants (expressions for which + ``is_gimple_min_invariant`` returns true). + +.. function:: bool is_gimple_addressable (tree t) + + Returns true if t is a symbol or memory reference whose address + can be taken. + +.. function:: bool is_gimple_asm_val (tree t) + + Similar to ``is_gimple_val`` but it also accepts hard registers. + +.. function:: bool is_gimple_call_addr (tree t) + + Return true if t is a valid expression to use as the function + called by a ``GIMPLE_CALL``. + +.. function:: bool is_gimple_mem_ref_addr (tree t) + + Return true if t is a valid expression to use as first operand + of a ``MEM_REF`` expression. + +.. function:: bool is_gimple_constant (tree t) + + Return true if t is a valid gimple constant. + +.. function:: bool is_gimple_min_invariant (tree t) + + Return true if t is a valid minimal invariant. This is different + from constants, in that the specific value of t may not be known + at compile time, but it is known that it doesn't change (e.g., + the address of a function local variable). + +.. function:: bool is_gimple_ip_invariant (tree t) + + Return true if t is an interprocedural invariant. This means that t + is a valid invariant in all functions (e.g. it can be an address of a + global variable but not of a local one). + +.. function:: bool is_gimple_ip_invariant_address (tree t) + + Return true if t is an ``ADDR_EXPR`` that does not change once the + program is running (and which is valid in all functions). + +Statement validation +^^^^^^^^^^^^^^^^^^^^ + +.. function:: bool is_gimple_assign (gimple g) + + Return true if the code of g is ``GIMPLE_ASSIGN``. + +.. function:: bool is_gimple_call (gimple g) + + Return true if the code of g is ``GIMPLE_CALL``. + +.. function:: bool is_gimple_debug (gimple g) + + Return true if the code of g is ``GIMPLE_DEBUG``. + +.. function:: bool gimple_assign_cast_p (const_gimple g) + + Return true if g is a ``GIMPLE_ASSIGN`` that performs a type cast + operation. + +.. function:: bool gimple_debug_bind_p (gimple g) + + Return true if g is a ``GIMPLE_DEBUG`` that binds the value of an + expression to a variable. + +.. function:: bool is_gimple_omp (gimple g) + + Return true if g is any of the OpenMP codes. + +.. function:: bool gimple_debug_begin_stmt_p (gimple g) + + Return true if g is a ``GIMPLE_DEBUG`` that marks the beginning of + a source statement. + +.. function:: bool gimple_debug_inline_entry_p (gimple g) + + Return true if g is a ``GIMPLE_DEBUG`` that marks the entry + point of an inlined function. + +.. function:: bool gimple_debug_nonbind_marker_p (gimple g) + + Return true if g is a ``GIMPLE_DEBUG`` that marks a program location, + without any variable binding. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/sequence-iterators.rst b/gcc/doc/gccint/gimple/sequence-iterators.rst new file mode 100644 index 00000000000..22104c90e55 --- /dev/null +++ b/gcc/doc/gccint/gimple/sequence-iterators.rst @@ -0,0 +1,223 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Sequence iterators + +.. _sequence-iterators: + +Sequence iterators +****************** + +Sequence iterators are convenience constructs for iterating +through statements in a sequence. Given a sequence ``SEQ``, here is +a typical use of gimple sequence iterators: + +.. code-block:: c++ + + gimple_stmt_iterator gsi; + + for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (&gsi)) + { + gimple g = gsi_stmt (gsi); + /* Do something with gimple statement G. */ + } + +Backward iterations are possible: + +.. code-block:: c++ + + for (gsi = gsi_last (seq); !gsi_end_p (gsi); gsi_prev (&gsi)) + +Forward and backward iterations on basic blocks are possible with +``gsi_start_bb`` and ``gsi_last_bb``. + +In the documentation below we sometimes refer to enum +``gsi_iterator_update``. The valid options for this enumeration are: + +* ``GSI_NEW_STMT`` + Only valid when a single statement is added. Move the iterator to it. + +* ``GSI_SAME_STMT`` + Leave the iterator at the same statement. + +* ``GSI_CONTINUE_LINKING`` + Move iterator to whatever position is suitable for linking other + statements in the same direction. + +Below is a list of the functions used to manipulate and use +statement iterators. + +.. function:: gimple_stmt_iterator gsi_start (gimple_seq seq) + + Return a new iterator pointing to the sequence ``SEQ`` 's first + statement. If ``SEQ`` is empty, the iterator's basic block is ``NULL``. + Use ``gsi_start_bb`` instead when the iterator needs to always have + the correct basic block set. + +.. function:: gimple_stmt_iterator gsi_start_bb (basic_block bb) + + Return a new iterator pointing to the first statement in basic + block ``BB``. + +.. function:: gimple_stmt_iterator gsi_last (gimple_seq seq) + + Return a new iterator initially pointing to the last statement of + sequence ``SEQ``. If ``SEQ`` is empty, the iterator's basic block is + ``NULL``. Use ``gsi_last_bb`` instead when the iterator needs to always + have the correct basic block set. + +.. function:: gimple_stmt_iterator gsi_last_bb (basic_block bb) + + Return a new iterator pointing to the last statement in basic + block ``BB``. + +.. function:: bool gsi_end_p (gimple_stmt_iterator i) + + Return ``TRUE`` if at the end of ``I``. + +.. function:: bool gsi_one_before_end_p (gimple_stmt_iterator i) + + Return ``TRUE`` if we're one statement before the end of ``I``. + +.. function:: void gsi_next (gimple_stmt_iterator *i) + + Advance the iterator to the next gimple statement. + +.. function:: void gsi_prev (gimple_stmt_iterator *i) + + Advance the iterator to the previous gimple statement. + +.. function:: gimple gsi_stmt (gimple_stmt_iterator i) + + Return the current stmt. + +.. function:: gimple_stmt_iterator gsi_after_labels (basic_block bb) + + Return a block statement iterator that points to the first + non-label statement in block ``BB``. + +.. function:: gimple * gsi_stmt_ptr (gimple_stmt_iterator *i) + + Return a pointer to the current stmt. + +.. function:: basic_block gsi_bb (gimple_stmt_iterator i) + + Return the basic block associated with this iterator. + +.. function:: gimple_seq gsi_seq (gimple_stmt_iterator i) + + Return the sequence associated with this iterator. + +.. function:: void gsi_remove (gimple_stmt_iterator *i, bool remove_eh_info) + + Remove the current stmt from the sequence. The iterator is + updated to point to the next statement. When ``REMOVE_EH_INFO`` is + true we remove the statement pointed to by iterator ``I`` from the ``EH`` + tables. Otherwise we do not modify the ``EH`` tables. Generally, + ``REMOVE_EH_INFO`` should be true when the statement is going to be + removed from the ``IL`` and not reinserted elsewhere. + +.. function:: void gsi_link_seq_before (gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode) + + Links the sequence of statements ``SEQ`` before the statement pointed + by iterator ``I``. ``MODE`` indicates what to do with the iterator + after insertion (see ``enum gsi_iterator_update`` above). + +.. function:: void gsi_link_before (gimple_stmt_iterator *i, gimple g, enum gsi_iterator_update mode) + + Links statement ``G`` before the statement pointed-to by iterator ``I``. + Updates iterator ``I`` according to ``MODE``. + +.. function:: void gsi_link_seq_after (gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode) + + Links sequence ``SEQ`` after the statement pointed-to by iterator ``I``. + ``MODE`` is as in ``gsi_insert_after``. + +.. function:: void gsi_link_after (gimple_stmt_iterator *i, gimple g, enum gsi_iterator_update mode) + + Links statement ``G`` after the statement pointed-to by iterator ``I``. + ``MODE`` is as in ``gsi_insert_after``. + +.. function:: gimple_seq gsi_split_seq_after (gimple_stmt_iterator i) + + Move all statements in the sequence after ``I`` to a new sequence. + Return this new sequence. + +.. function:: gimple_seq gsi_split_seq_before (gimple_stmt_iterator *i) + + Move all statements in the sequence before ``I`` to a new sequence. + Return this new sequence. + +.. function:: void gsi_replace (gimple_stmt_iterator *i, gimple stmt, bool update_eh_info) + + Replace the statement pointed-to by ``I`` to ``STMT``. If ``UPDATE_EH_INFO`` + is true, the exception handling information of the original + statement is moved to the new statement. + +.. function:: void gsi_insert_before (gimple_stmt_iterator *i, gimple stmt, enum gsi_iterator_update mode) + + Insert statement ``STMT`` before the statement pointed-to by iterator + ``I``, update ``STMT`` 's basic block and scan it for new operands. ``MODE`` + specifies how to update iterator ``I`` after insertion (see enum + ``gsi_iterator_update``). + +.. function:: void gsi_insert_seq_before (gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode) + + Like ``gsi_insert_before``, but for all the statements in ``SEQ``. + +.. function:: void gsi_insert_after (gimple_stmt_iterator *i, gimple stmt, enum gsi_iterator_update mode) + + Insert statement ``STMT`` after the statement pointed-to by iterator + ``I``, update ``STMT`` 's basic block and scan it for new operands. ``MODE`` + specifies how to update iterator ``I`` after insertion (see enum + ``gsi_iterator_update``). + +.. function:: void gsi_insert_seq_after (gimple_stmt_iterator *i, gimple_seq seq, enum gsi_iterator_update mode) + + Like ``gsi_insert_after``, but for all the statements in ``SEQ``. + +.. function:: gimple_stmt_iterator gsi_for_stmt (gimple stmt) + + Finds iterator for ``STMT``. + +.. function:: void gsi_move_after (gimple_stmt_iterator *from, gimple_stmt_iterator *to) + + Move the statement at ``FROM`` so it comes right after the statement + at ``TO``. + +.. function:: void gsi_move_before (gimple_stmt_iterator *from, gimple_stmt_iterator *to) + + Move the statement at ``FROM`` so it comes right before the statement + at ``TO``. + +.. function:: void gsi_move_to_bb_end (gimple_stmt_iterator *from, basic_block bb) + + Move the statement at ``FROM`` to the end of basic block ``BB``. + +.. function:: void gsi_insert_on_edge (edge e, gimple stmt) + + Add ``STMT`` to the pending list of edge ``E``. No actual insertion is + made until a call to ``gsi_commit_edge_inserts`` () is made. + +.. function:: void gsi_insert_seq_on_edge (edge e, gimple_seq seq) + + Add the sequence of statements in ``SEQ`` to the pending list of edge + ``E``. No actual insertion is made until a call to + ``gsi_commit_edge_inserts`` () is made. + +.. function:: basic_block gsi_insert_on_edge_immediate (edge e, gimple stmt) + + Similar to ``gsi_insert_on_edge`` + ``gsi_commit_edge_inserts``. If a new + block has to be created, it is returned. + +.. function:: void gsi_commit_one_edge_insert (edge e, basic_block *new_bb) + + Commit insertions pending at edge ``E``. If a new block is created, + set ``NEW_BB`` to this block, otherwise set it to ``NULL``. + +.. function:: void gsi_commit_edge_inserts (void) + + This routine will commit all pending edge insertions, creating + any new basic blocks which are necessary. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/statement-and-operand-traversals.rst b/gcc/doc/gccint/gimple/statement-and-operand-traversals.rst new file mode 100644 index 00000000000..bb9629ab3e7 --- /dev/null +++ b/gcc/doc/gccint/gimple/statement-and-operand-traversals.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Statement and operand traversals + +.. _statement-and-operand-traversals: + +Statement and operand traversals +******************************** + +There are two functions available for walking statements and +sequences: ``walk_gimple_stmt`` and ``walk_gimple_seq``, +accordingly, and a third function for walking the operands in a +statement: ``walk_gimple_op``. + +.. function:: tree walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi) + + This function is used to walk the current statement in ``GSI``, + optionally using traversal state stored in ``WI``. If ``WI`` is ``NULL``, no + state is kept during the traversal. + + The callback ``CALLBACK_STMT`` is called. If ``CALLBACK_STMT`` returns + true, it means that the callback function has handled all the + operands of the statement and it is not necessary to walk its + operands. + + If ``CALLBACK_STMT`` is ``NULL`` or it returns false, ``CALLBACK_OP`` is + called on each operand of the statement via ``walk_gimple_op``. If + ``walk_gimple_op`` returns non- ``NULL`` for any operand, the remaining + operands are not scanned. + + The return value is that returned by the last call to + ``walk_gimple_op``, or ``NULL_TREE`` if no ``CALLBACK_OP`` is specified. + +.. function:: tree walk_gimple_op (gimple stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi) + + Use this function to walk the operands of statement ``STMT``. Every + operand is walked via ``walk_tree`` with optional state information + in ``WI``. + + ``CALLBACK_OP`` is called on each operand of ``STMT`` via ``walk_tree``. + Additional parameters to ``walk_tree`` must be stored in ``WI``. For + each operand ``OP``, ``walk_tree`` is called as: + + .. code-block:: c++ + + walk_tree (&OP, CALLBACK_OP, WI, PSET) + + If ``CALLBACK_OP`` returns non- ``NULL`` for an operand, the remaining + operands are not scanned. The return value is that returned by + the last call to ``walk_tree``, or ``NULL_TREE`` if no ``CALLBACK_OP`` is + specified. + +.. function:: tree walk_gimple_seq (gimple_seq seq, walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi) + + This function walks all the statements in the sequence ``SEQ`` + calling ``walk_gimple_stmt`` on each one. ``WI`` is as in + ``walk_gimple_stmt``. If ``walk_gimple_stmt`` returns non- ``NULL``, the walk + is stopped and the value returned. Otherwise, all the statements + are walked and ``NULL_TREE`` returned. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/temporaries.rst b/gcc/doc/gccint/gimple/temporaries.rst new file mode 100644 index 00000000000..d743b40610f --- /dev/null +++ b/gcc/doc/gccint/gimple/temporaries.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Temporaries + +.. _temporaries: + +Temporaries +*********** + +When gimplification encounters a subexpression that is too +complex, it creates a new temporary variable to hold the value of +the subexpression, and adds a new statement to initialize it +before the current statement. These special temporaries are known +as :samp:`expression temporaries`, and are allocated using +``get_formal_tmp_var``. The compiler tries to always evaluate +identical expressions into the same temporary, to simplify +elimination of redundant calculations. + +We can only use expression temporaries when we know that it will +not be reevaluated before its value is used, and that it will not +be otherwise modified [#f1]_. + +. Other temporaries can be allocated +using ``get_initialized_tmp_var`` or ``create_tmp_var``. + +Currently, an expression like ``a = b + 5`` is not reduced any +further. We tried converting it to something like + +.. code-block:: c++ + + T1 = b + 5; + a = T1; + +but this bloated the representation for minimal benefit. However, a +variable which must live in memory cannot appear in an expression; its +value is explicitly loaded into a temporary first. Similarly, storing +the value of an expression to a memory variable goes through a +temporary. + +.. [#f1] These restrictions are derived from those in Morgan 4.8. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-representation.rst b/gcc/doc/gccint/gimple/tuple-representation.rst new file mode 100644 index 00000000000..6fa0af32203 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-representation.rst @@ -0,0 +1,242 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: tuples + +.. _tuple-representation: + +Tuple representation +******************** + +GIMPLE instructions are tuples of variable size divided in two +groups: a header describing the instruction and its locations, +and a variable length body with all the operands. Tuples are +organized into a hierarchy with 3 main classes of tuples. + +.. index:: gimple + +gimple (gsbase) +^^^^^^^^^^^^^^^ + +This is the root of the hierarchy, it holds basic information +needed by most GIMPLE statements. There are some fields that +may not be relevant to every GIMPLE statement, but those were +moved into the base structure to take advantage of holes left by +other fields (thus making the structure more compact). The +structure takes 4 words (32 bytes) on 64 bit hosts: + +.. list-table:: + + * - Field + - Size (bits) + * - ``code`` + - 8 + * - ``subcode`` + - 16 + * - ``no_warning`` + - 1 + * - ``visited`` + - 1 + * - ``nontemporal_move`` + - 1 + * - ``plf`` + - 2 + * - ``modified`` + - 1 + * - ``has_volatile_ops`` + - 1 + * - ``references_memory_p`` + - 1 + * - ``uid`` + - 32 + * - ``location`` + - 32 + * - ``num_ops`` + - 32 + * - ``bb`` + - 64 + * - ``block`` + - 63 + * - Total size + - 32 bytes + +* ``code`` + Main identifier for a GIMPLE instruction. + +* ``subcode`` + Used to distinguish different variants of the same basic + instruction or provide flags applicable to a given code. The + ``subcode`` flags field has different uses depending on the code of + the instruction, but mostly it distinguishes instructions of the + same family. The most prominent use of this field is in + assignments, where subcode indicates the operation done on the + RHS of the assignment. For example, a = b + c is encoded as + ``GIMPLE_ASSIGN ``. + +* ``no_warning`` + Bitflag to indicate whether a warning has already been issued on + this statement. + +* ``visited`` + General purpose 'visited' marker. Set and cleared by each pass + when needed. + +* ``nontemporal_move`` + Bitflag used in assignments that represent non-temporal moves. + Although this bitflag is only used in assignments, it was moved + into the base to take advantage of the bit holes left by the + previous fields. + +* ``plf`` + Pass Local Flags. This 2-bit mask can be used as general purpose + markers by any pass. Passes are responsible for clearing and + setting these two flags accordingly. + +* ``modified`` + Bitflag to indicate whether the statement has been modified. + Used mainly by the operand scanner to determine when to re-scan a + statement for operands. + +* ``has_volatile_ops`` + Bitflag to indicate whether this statement contains operands that + have been marked volatile. + +* ``references_memory_p`` + Bitflag to indicate whether this statement contains memory + references (i.e., its operands are either global variables, or + pointer dereferences or anything that must reside in memory). + +* ``uid`` + This is an unsigned integer used by passes that want to assign + IDs to every statement. These IDs must be assigned and used by + each pass. + +* ``location`` + This is a ``location_t`` identifier to specify source code + location for this statement. It is inherited from the front + end. + +* ``num_ops`` + Number of operands that this statement has. This specifies the + size of the operand vector embedded in the tuple. Only used in + some tuples, but it is declared in the base tuple to take + advantage of the 32-bit hole left by the previous fields. + +* ``bb`` + Basic block holding the instruction. + +* ``block`` + Lexical block holding this statement. Also used for debug + information generation. + +.. index:: gimple_statement_with_ops + +gimple_statement_with_ops +^^^^^^^^^^^^^^^^^^^^^^^^^ + +This tuple is actually split in two: +``gimple_statement_with_ops_base`` and +``gimple_statement_with_ops``. This is needed to accommodate the +way the operand vector is allocated. The operand vector is +defined to be an array of 1 element. So, to allocate a dynamic +number of operands, the memory allocator (``gimple_alloc``) simply +allocates enough memory to hold the structure itself plus ``N +- 1`` operands which run 'off the end' of the structure. For +example, to allocate space for a tuple with 3 operands, +``gimple_alloc`` reserves ``sizeof (struct +gimple_statement_with_ops) + 2 * sizeof (tree)`` bytes. + +On the other hand, several fields in this tuple need to be shared +with the ``gimple_statement_with_memory_ops`` tuple. So, these +common fields are placed in ``gimple_statement_with_ops_base`` which +is then inherited from the other two tuples. + +.. list-table:: + + * - ``gsbase`` + - 256 + * - ``def_ops`` + - 64 + * - ``use_ops`` + - 64 + * - ``op`` + - ``num_ops`` \* 64 + * - Total size + - 48 + 8 \* ``num_ops`` bytes + +* ``gsbase`` + Inherited from ``struct gimple``. + +* ``def_ops`` + Array of pointers into the operand array indicating all the slots that + contain a variable written-to by the statement. This array is + also used for immediate use chaining. Note that it would be + possible to not rely on this array, but the changes required to + implement this are pretty invasive. + +* ``use_ops`` + Similar to ``def_ops`` but for variables read by the statement. + +* ``op`` + Array of trees with ``num_ops`` slots. + +gimple_statement_with_memory_ops +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This tuple is essentially identical to ``gimple_statement_with_ops``, +except that it contains 4 additional fields to hold vectors +related memory stores and loads. Similar to the previous case, +the structure is split in two to accommodate for the operand +vector (``gimple_statement_with_memory_ops_base`` and +``gimple_statement_with_memory_ops``). + +.. list-table:: + + * - Field + - Size (bits) + * - ``gsbase`` + - 256 + * - ``def_ops`` + - 64 + * - ``use_ops`` + - 64 + * - ``vdef_ops`` + - 64 + * - ``vuse_ops`` + - 64 + * - ``stores`` + - 64 + * - ``loads`` + - 64 + * - ``op`` + - ``num_ops`` \* 64 + * - Total size + - 80 + 8 \* ``num_ops`` bytes + +* ``vdef_ops`` + Similar to ``def_ops`` but for ``VDEF`` operators. There is + one entry per memory symbol written by this statement. This is + used to maintain the memory SSA use-def and def-def chains. + +* ``vuse_ops`` + Similar to ``use_ops`` but for ``VUSE`` operators. There is + one entry per memory symbol loaded by this statement. This is + used to maintain the memory SSA use-def chains. + +* ``stores`` + Bitset with all the UIDs for the symbols written-to by the + statement. This is different than ``vdef_ops`` in that all the + affected symbols are mentioned in this set. If memory + partitioning is enabled, the ``vdef_ops`` vector will refer to memory + partitions. Furthermore, no SSA information is stored in this + set. + +* ``loads`` + Similar to ``stores``, but for memory loads. (Note that there + is some amount of redundancy here, it should be possible to + reduce memory utilization further by removing these sets). + +All the other tuples are defined in terms of these three basic +ones. Each tuple will add some fields. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors.rst new file mode 100644 index 00000000000..fe189cde53f --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Tuple specific accessors + +.. _tuple-specific-accessors: + +Tuple specific accessors +************************ + +.. toctree:: + :maxdepth: 2 + + tuple-specific-accessors/gimpleasm + tuple-specific-accessors/gimpleassign + tuple-specific-accessors/gimplebind + tuple-specific-accessors/gimplecall + tuple-specific-accessors/gimplecatch + tuple-specific-accessors/gimplecond + tuple-specific-accessors/gimpledebug + tuple-specific-accessors/gimpleehfilter + tuple-specific-accessors/gimplelabel + tuple-specific-accessors/gimplegoto + tuple-specific-accessors/gimplenop + tuple-specific-accessors/gimpleompatomicload + tuple-specific-accessors/gimpleompatomicstore + tuple-specific-accessors/gimpleompcontinue + tuple-specific-accessors/gimpleompcritical + tuple-specific-accessors/gimpleompfor + tuple-specific-accessors/gimpleompmaster + tuple-specific-accessors/gimpleompordered + tuple-specific-accessors/gimpleompparallel + tuple-specific-accessors/gimpleompreturn + tuple-specific-accessors/gimpleompsection + tuple-specific-accessors/gimpleompsections + tuple-specific-accessors/gimpleompsingle + tuple-specific-accessors/gimplephi + tuple-specific-accessors/gimpleresx + tuple-specific-accessors/gimplereturn + tuple-specific-accessors/gimpleswitch + tuple-specific-accessors/gimpletry + tuple-specific-accessors/gimplewithcleanupexpr \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleasm.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleasm.rst new file mode 100644 index 00000000000..082b6dcfa20 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleasm.rst @@ -0,0 +1,66 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_ASM + +GIMPLE_ASM +^^^^^^^^^^ + +.. function:: gasm *gimple_build_asm_vec ( const char *string, vec *inputs, vec *outputs, vec *clobbers, vec *labels) + + Build a ``GIMPLE_ASM`` statement. This statement is used for + building in-line assembly constructs. ``STRING`` is the assembly + code. ``INPUTS``, ``OUTPUTS``, ``CLOBBERS`` and ``LABELS`` + are the inputs, outputs, clobbered registers and labels. + +.. function:: unsigned gimple_asm_ninputs (const gasm *g) + + Return the number of input operands for ``GIMPLE_ASM`` ``G``. + +.. function:: unsigned gimple_asm_noutputs (const gasm *g) + + Return the number of output operands for ``GIMPLE_ASM`` ``G``. + +.. function:: unsigned gimple_asm_nclobbers (const gasm *g) + + Return the number of clobber operands for ``GIMPLE_ASM`` ``G``. + +.. function:: tree gimple_asm_input_op (const gasm *g, unsigned index) + + Return input operand ``INDEX`` of ``GIMPLE_ASM`` ``G``. + +.. function:: void gimple_asm_set_input_op (gasm *g, unsigned index, tree in_op) + + Set ``IN_OP`` to be input operand ``INDEX`` in ``GIMPLE_ASM`` ``G``. + +.. function:: tree gimple_asm_output_op (const gasm *g, unsigned index) + + Return output operand ``INDEX`` of ``GIMPLE_ASM`` ``G``. + +.. function:: void gimple_asm_set_output_op (gasm *g, unsigned index, tree out_op) + + Set ``OUT_OP`` to be output operand ``INDEX`` in ``GIMPLE_ASM`` ``G``. + +.. function:: tree gimple_asm_clobber_op (const gasm *g, unsigned index) + + Return clobber operand ``INDEX`` of ``GIMPLE_ASM`` ``G``. + +.. function:: void gimple_asm_set_clobber_op (gasm *g, unsigned index, tree clobber_op) + + Set ``CLOBBER_OP`` to be clobber operand ``INDEX`` in ``GIMPLE_ASM`` ``G``. + +.. function:: const char * gimple_asm_string (const gasm *g) + + Return the string representing the assembly instruction in + ``GIMPLE_ASM`` ``G``. + +.. function:: bool gimple_asm_volatile_p (const gasm *g) + + Return true if ``G`` is an asm statement marked volatile. + +.. function:: void gimple_asm_set_volatile (gasm *g, bool volatile_p) + + Mark asm statement ``G`` as volatile or non-volatile based on + ``VOLATILE_P``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleassign.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleassign.rst new file mode 100644 index 00000000000..fd030e30353 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleassign.rst @@ -0,0 +1,126 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_ASSIGN + +GIMPLE_ASSIGN +^^^^^^^^^^^^^ + +.. function:: gassign *gimple_build_assign (tree lhs, tree rhs) + + Build a ``GIMPLE_ASSIGN`` statement. The left-hand side is an lvalue + passed in lhs. The right-hand side can be either a unary or + binary tree expression. The expression tree rhs will be + flattened and its operands assigned to the corresponding operand + slots in the new statement. This function is useful when you + already have a tree expression that you want to convert into a + tuple. However, try to avoid building expression trees for the + sole purpose of calling this function. If you already have the + operands in separate trees, it is better to use + ``gimple_build_assign`` with ``enum tree_code`` argument and separate + arguments for each operand. + +.. function:: gassign *gimple_build_assign (tree lhs, enum tree_code subcode, tree op1, tree op2, tree op3) + + This function is similar to two operand ``gimple_build_assign``, + but is used to build a ``GIMPLE_ASSIGN`` statement when the operands of the + right-hand side of the assignment are already split into + different operands. + + The left-hand side is an lvalue passed in lhs. Subcode is the + ``tree_code`` for the right-hand side of the assignment. Op1, op2 and op3 + are the operands. + +.. function:: gassign *gimple_build_assign (tree lhs, enum tree_code subcode, tree op1, tree op2) + + Like the above 5 operand ``gimple_build_assign``, but with the last + argument ``NULL`` - this overload should not be used for + ``GIMPLE_TERNARY_RHS`` assignments. + +.. function:: gassign *gimple_build_assign (tree lhs, enum tree_code subcode, tree op1) + + Like the above 4 operand ``gimple_build_assign``, but with the last + argument ``NULL`` - this overload should be used only for + ``GIMPLE_UNARY_RHS`` and ``GIMPLE_SINGLE_RHS`` assignments. + +.. function:: gimple gimplify_assign (tree dst, tree src, gimple_seq *seq_p) + + Build a new ``GIMPLE_ASSIGN`` tuple and append it to the end of + ``*SEQ_P``. + +``DST`` / ``SRC`` are the destination and source respectively. You can +pass ungimplified trees in ``DST`` or ``SRC``, in which +case they will be converted to a gimple operand if necessary. + +This function returns the newly created ``GIMPLE_ASSIGN`` tuple. + +.. function:: enum tree_code gimple_assign_rhs_code (gimple g) + + Return the code of the expression computed on the ``RHS`` of + assignment statement ``G``. + +.. function:: enum gimple_rhs_class gimple_assign_rhs_class (gimple g) + + Return the gimple rhs class of the code for the expression + computed on the rhs of assignment statement ``G``. This will never + return ``GIMPLE_INVALID_RHS``. + +.. function:: tree gimple_assign_lhs (gimple g) + + Return the ``LHS`` of assignment statement ``G``. + +.. function:: tree * gimple_assign_lhs_ptr (gimple g) + + Return a pointer to the ``LHS`` of assignment statement ``G``. + +.. function:: tree gimple_assign_rhs1 (gimple g) + + Return the first operand on the ``RHS`` of assignment statement ``G``. + +.. function:: tree * gimple_assign_rhs1_ptr (gimple g) + + Return the address of the first operand on the ``RHS`` of assignment + statement ``G``. + +.. function:: tree gimple_assign_rhs2 (gimple g) + + Return the second operand on the ``RHS`` of assignment statement ``G``. + +.. function:: tree * gimple_assign_rhs2_ptr (gimple g) + + Return the address of the second operand on the ``RHS`` of assignment + statement ``G``. + +.. function:: tree gimple_assign_rhs3 (gimple g) + + Return the third operand on the ``RHS`` of assignment statement ``G``. + +.. function:: tree * gimple_assign_rhs3_ptr (gimple g) + + Return the address of the third operand on the ``RHS`` of assignment + statement ``G``. + +.. function:: void gimple_assign_set_lhs (gimple g, tree lhs) + + Set ``LHS`` to be the ``LHS`` operand of assignment statement ``G``. + +.. function:: void gimple_assign_set_rhs1 (gimple g, tree rhs) + + Set ``RHS`` to be the first operand on the ``RHS`` of assignment + statement ``G``. + +.. function:: void gimple_assign_set_rhs2 (gimple g, tree rhs) + + Set ``RHS`` to be the second operand on the ``RHS`` of assignment + statement ``G``. + +.. function:: void gimple_assign_set_rhs3 (gimple g, tree rhs) + + Set ``RHS`` to be the third operand on the ``RHS`` of assignment + statement ``G``. + +.. function:: bool gimple_assign_cast_p (const_gimple s) + + Return true if ``S`` is a type-cast assignment. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplebind.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplebind.rst new file mode 100644 index 00000000000..fbb194407ad --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplebind.rst @@ -0,0 +1,56 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_BIND + +GIMPLE_BIND +^^^^^^^^^^^ + +.. function:: gbind *gimple_build_bind (tree vars, gimple_seq body) + + Build a ``GIMPLE_BIND`` statement with a list of variables in ``VARS`` + and a body of statements in sequence ``BODY``. + +.. function:: tree gimple_bind_vars (const gbind *g) + + Return the variables declared in the ``GIMPLE_BIND`` statement ``G``. + +.. function:: void gimple_bind_set_vars (gbind *g, tree vars) + + Set ``VARS`` to be the set of variables declared in the ``GIMPLE_BIND`` + statement ``G``. + +.. function:: void gimple_bind_append_vars (gbind *g, tree vars) + + Append ``VARS`` to the set of variables declared in the ``GIMPLE_BIND`` + statement ``G``. + +.. function:: gimple_seq gimple_bind_body (gbind *g) + + Return the GIMPLE sequence contained in the ``GIMPLE_BIND`` statement + ``G``. + +.. function:: void gimple_bind_set_body (gbind *g, gimple_seq seq) + + Set ``SEQ`` to be sequence contained in the ``GIMPLE_BIND`` statement ``G``. + +.. function:: void gimple_bind_add_stmt (gbind *gs, gimple stmt) + + Append a statement to the end of a ``GIMPLE_BIND`` 's body. + +.. function:: void gimple_bind_add_seq (gbind *gs, gimple_seq seq) + + Append a sequence of statements to the end of a ``GIMPLE_BIND`` 's + body. + +.. function:: tree gimple_bind_block (const gbind *g) + + Return the ``TREE_BLOCK`` node associated with ``GIMPLE_BIND`` statement + ``G``. This is analogous to the ``BIND_EXPR_BLOCK`` field in trees. + +.. function:: void gimple_bind_set_block (gbind *g, tree block) + + Set ``BLOCK`` to be the ``TREE_BLOCK`` node associated with ``GIMPLE_BIND`` + statement ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplecall.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplecall.rst new file mode 100644 index 00000000000..42d27d7b9ce --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplecall.rst @@ -0,0 +1,116 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_CALL + +GIMPLE_CALL +^^^^^^^^^^^ + +.. function:: gcall *gimple_build_call (tree fn, unsigned nargs, ...) + + Build a ``GIMPLE_CALL`` statement to function ``FN``. The argument ``FN`` + must be either a ``FUNCTION_DECL`` or a gimple call address as + determined by ``is_gimple_call_addr``. ``NARGS`` are the number of + arguments. The rest of the arguments follow the argument ``NARGS``, + and must be trees that are valid as rvalues in gimple (i.e., each + operand is validated with ``is_gimple_operand``). + +.. function:: gcall *gimple_build_call_from_tree (tree call_expr, tree fnptrtype) + + Build a ``GIMPLE_CALL`` from a ``CALL_EXPR`` node. The arguments + and the function are taken from the expression directly. The type of the + ``GIMPLE_CALL`` is set from the second parameter passed by a caller. + This routine assumes that ``call_expr`` is already in GIMPLE form. + That is, its operands are GIMPLE values and the function call needs no further + simplification. All the call flags in ``call_expr`` are copied over + to the new ``GIMPLE_CALL``. + +.. function:: gcall *gimple_build_call_vec (tree fn, vec args) + + Identical to ``gimple_build_call`` but the arguments are stored in a + ``vec``. + +.. function:: tree gimple_call_lhs (gimple g) + + Return the ``LHS`` of call statement ``G``. + +.. function:: tree * gimple_call_lhs_ptr (gimple g) + + Return a pointer to the ``LHS`` of call statement ``G``. + +.. function:: void gimple_call_set_lhs (gimple g, tree lhs) + + Set ``LHS`` to be the ``LHS`` operand of call statement ``G``. + +.. function:: tree gimple_call_fn (gimple g) + + Return the tree node representing the function called by call + statement ``G``. + +.. function:: void gimple_call_set_fn (gcall *g, tree fn) + + Set ``FN`` to be the function called by call statement ``G``. This has + to be a gimple value specifying the address of the called + function. + +.. function:: tree gimple_call_fndecl (gimple g) + + If a given ``GIMPLE_CALL`` 's callee is a ``FUNCTION_DECL``, return it. + Otherwise return ``NULL``. This function is analogous to + ``get_callee_fndecl`` in ``GENERIC``. + +.. function:: tree gimple_call_set_fndecl (gimple g, tree fndecl) + + Set the called function to ``FNDECL``. + +.. function:: tree gimple_call_return_type (const gcall *g) + + Return the type returned by call statement ``G``. + +.. function:: tree gimple_call_chain (gimple g) + + Return the static chain for call statement ``G``. + +.. function:: void gimple_call_set_chain (gcall *g, tree chain) + + Set ``CHAIN`` to be the static chain for call statement ``G``. + +.. function:: unsigned gimple_call_num_args (gimple g) + + Return the number of arguments used by call statement ``G``. + +.. function:: tree gimple_call_arg (gimple g, unsigned index) + + Return the argument at position ``INDEX`` for call statement ``G``. The + first argument is 0. + +.. function:: tree * gimple_call_arg_ptr (gimple g, unsigned index) + + Return a pointer to the argument at position ``INDEX`` for call + statement ``G``. + +.. function:: void gimple_call_set_arg (gimple g, unsigned index, tree arg) + + Set ``ARG`` to be the argument at position ``INDEX`` for call statement + ``G``. + +.. function:: void gimple_call_set_tail (gcall *s) + + Mark call statement ``S`` as being a tail call (i.e., a call just + before the exit of a function). These calls are candidate for + tail call optimization. + +.. function:: bool gimple_call_tail_p (gcall *s) + + Return true if ``GIMPLE_CALL`` ``S`` is marked as a tail call. + +.. function:: bool gimple_call_noreturn_p (gimple s) + + Return true if ``S`` is a noreturn call. + +.. function:: gimple gimple_call_copy_skip_args (gcall *stmt, bitmap args_to_skip) + + Build a ``GIMPLE_CALL`` identical to ``STMT`` but skipping the arguments + in the positions marked by the set ``ARGS_TO_SKIP``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplecatch.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplecatch.rst new file mode 100644 index 00000000000..ef47d7108c5 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplecatch.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_CATCH + +GIMPLE_CATCH +^^^^^^^^^^^^ + +.. function:: gcatch *gimple_build_catch (tree types, gimple_seq handler) + + Build a ``GIMPLE_CATCH`` statement. ``TYPES`` are the tree types this + catch handles. ``HANDLER`` is a sequence of statements with the code + for the handler. + +.. function:: tree gimple_catch_types (const gcatch *g) + + Return the types handled by ``GIMPLE_CATCH`` statement ``G``. + +.. function:: tree * gimple_catch_types_ptr (gcatch *g) + + Return a pointer to the types handled by ``GIMPLE_CATCH`` statement + ``G``. + +.. function:: gimple_seq gimple_catch_handler (gcatch *g) + + Return the GIMPLE sequence representing the body of the handler + of ``GIMPLE_CATCH`` statement ``G``. + +.. function:: void gimple_catch_set_types (gcatch *g, tree t) + + Set ``T`` to be the set of types handled by ``GIMPLE_CATCH`` ``G``. + +.. function:: void gimple_catch_set_handler (gcatch *g, gimple_seq handler) + + Set ``HANDLER`` to be the body of ``GIMPLE_CATCH`` ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplecond.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplecond.rst new file mode 100644 index 00000000000..daa5f1693b1 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplecond.rst @@ -0,0 +1,80 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_COND + +GIMPLE_COND +^^^^^^^^^^^ + +.. function:: gcond *gimple_build_cond ( enum tree_code pred_code, tree lhs, tree rhs, tree t_label, tree f_label) + + Build a ``GIMPLE_COND`` statement. ``A`` ``GIMPLE_COND`` statement compares + ``LHS`` and ``RHS`` and if the condition in ``PRED_CODE`` is true, jump to + the label in ``t_label``, otherwise jump to the label in ``f_label``. + ``PRED_CODE`` are relational operator tree codes like ``EQ_EXPR``, + ``LT_EXPR``, ``LE_EXPR``, ``NE_EXPR``, etc. + +.. function:: gcond *gimple_build_cond_from_tree (tree cond, tree t_label, tree f_label) + + Build a ``GIMPLE_COND`` statement from the conditional expression + tree ``COND``. ``T_LABEL`` and ``F_LABEL`` are as in ``gimple_build_cond``. + +.. function:: enum tree_code gimple_cond_code (gimple g) + + Return the code of the predicate computed by conditional + statement ``G``. + +.. function:: void gimple_cond_set_code (gcond *g, enum tree_code code) + + Set ``CODE`` to be the predicate code for the conditional statement + ``G``. + +.. function:: tree gimple_cond_lhs (gimple g) + + Return the ``LHS`` of the predicate computed by conditional statement + ``G``. + +.. function:: void gimple_cond_set_lhs (gcond *g, tree lhs) + + Set ``LHS`` to be the ``LHS`` operand of the predicate computed by + conditional statement ``G``. + +.. function:: tree gimple_cond_rhs (gimple g) + + Return the ``RHS`` operand of the predicate computed by conditional + ``G``. + +.. function:: void gimple_cond_set_rhs (gcond *g, tree rhs) + + Set ``RHS`` to be the ``RHS`` operand of the predicate computed by + conditional statement ``G``. + +.. function:: tree gimple_cond_true_label (const gcond *g) + + Return the label used by conditional statement ``G`` when its + predicate evaluates to true. + +.. function:: void gimple_cond_set_true_label (gcond *g, tree label) + + Set ``LABEL`` to be the label used by conditional statement ``G`` when + its predicate evaluates to true. + +.. function:: void gimple_cond_set_false_label (gcond *g, tree label) + + Set ``LABEL`` to be the label used by conditional statement ``G`` when + its predicate evaluates to false. + +.. function:: tree gimple_cond_false_label (const gcond *g) + + Return the label used by conditional statement ``G`` when its + predicate evaluates to false. + +.. function:: void gimple_cond_make_false (gcond *g) + + Set the conditional ``COND_STMT`` to be of the form 'if (1 == 0)'. + +.. function:: void gimple_cond_make_true (gcond *g) + + Set the conditional ``COND_STMT`` to be of the form 'if (1 == 1)'. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpledebug.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpledebug.rst new file mode 100644 index 00000000000..96fd6c7dafd --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpledebug.rst @@ -0,0 +1,106 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_DEBUG, GIMPLE_DEBUG_BIND, GIMPLE_DEBUG_BEGIN_STMT, GIMPLE_DEBUG_INLINE_ENTRY + +.. _gimple_debug: + +GIMPLE_DEBUG +^^^^^^^^^^^^ + +.. function:: gdebug *gimple_build_debug_bind (tree var, tree value, gimple stmt) + + Build a ``GIMPLE_DEBUG`` statement with ``GIMPLE_DEBUG_BIND`` + ``subcode``. The effect of this statement is to tell debug + information generation machinery that the value of user variable + ``var`` is given by ``value`` at that point, and to remain with + that value until ``var`` runs out of scope, a + dynamically-subsequent debug bind statement overrides the binding, or + conflicting values reach a control flow merge point. Even if + components of the ``value`` expression change afterwards, the + variable is supposed to retain the same value, though not necessarily + the same location. + + It is expected that ``var`` be most often a tree for automatic user + variables (``VAR_DECL`` or ``PARM_DECL``) that satisfy the + requirements for gimple registers, but it may also be a tree for a + scalarized component of a user variable (``ARRAY_REF``, + ``COMPONENT_REF``), or a debug temporary (``DEBUG_EXPR_DECL``). + + As for ``value``, it can be an arbitrary tree expression, but it is + recommended that it be in a suitable form for a gimple assignment + ``RHS``. It is not expected that user variables that could appear + as ``var`` ever appear in ``value``, because in the latter we'd + have their ``SSA_NAME`` s instead, but even if they were not in SSA + form, user variables appearing in ``value`` are to be regarded as + part of the executable code space, whereas those in ``var`` are to + be regarded as part of the source code space. There is no way to + refer to the value bound to a user variable within a ``value`` + expression. + + If ``value`` is ``GIMPLE_DEBUG_BIND_NOVALUE``, debug information + generation machinery is informed that the variable ``var`` is + unbound, i.e., that its value is indeterminate, which sometimes means + it is really unavailable, and other times that the compiler could not + keep track of it. + + Block and location information for the newly-created stmt are + taken from ``stmt``, if given. + +.. function:: tree gimple_debug_bind_get_var (gimple stmt) + + Return the user variable :samp:`{var}` that is bound at ``stmt``. + +.. function:: tree gimple_debug_bind_get_value (gimple stmt) + + Return the value expression that is bound to a user variable at + ``stmt``. + +.. function:: tree * gimple_debug_bind_get_value_ptr (gimple stmt) + + Return a pointer to the value expression that is bound to a user + variable at ``stmt``. + +.. function:: void gimple_debug_bind_set_var (gimple stmt, tree var) + + Modify the user variable bound at ``stmt`` to :samp:`{var}`. + +.. function:: void gimple_debug_bind_set_value (gimple stmt, tree var) + + Modify the value bound to the user variable bound at ``stmt`` to + :samp:`{value}`. + +.. function:: void gimple_debug_bind_reset_value (gimple stmt) + + Modify the value bound to the user variable bound at ``stmt`` so + that the variable becomes unbound. + +.. function:: bool gimple_debug_bind_has_value_p (gimple stmt) + + Return ``TRUE`` if ``stmt`` binds a user variable to a value, + and ``FALSE`` if it unbinds the variable. + +.. function:: gimple gimple_build_debug_begin_stmt (tree block, location_t location) + + Build a ``GIMPLE_DEBUG`` statement with + ``GIMPLE_DEBUG_BEGIN_STMT`` ``subcode``. The effect of this + statement is to tell debug information generation machinery that the + user statement at the given ``location`` and ``block`` starts at + the point at which the statement is inserted. The intent is that side + effects (e.g. variable bindings) of all prior user statements are + observable, and that none of the side effects of subsequent user + statements are. + +.. function:: gimple gimple_build_debug_inline_entry (tree block, location_t location) + + Build a ``GIMPLE_DEBUG`` statement with + ``GIMPLE_DEBUG_INLINE_ENTRY`` ``subcode``. The effect of this + statement is to tell debug information generation machinery that a + function call at ``location`` underwent inline substitution, that + ``block`` is the enclosing lexical block created for the + substitution, and that at the point of the program in which the stmt is + inserted, all parameters for the inlined function are bound to the + respective arguments, and none of the side effects of its stmts are + observable. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleehfilter.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleehfilter.rst new file mode 100644 index 00000000000..9ba5673286b --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleehfilter.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_EH_FILTER + +GIMPLE_EH_FILTER +^^^^^^^^^^^^^^^^ + +.. function:: geh_filter *gimple_build_eh_filter (tree types, gimple_seq failure) + + Build a ``GIMPLE_EH_FILTER`` statement. ``TYPES`` are the filter's + types. ``FAILURE`` is a sequence with the filter's failure action. + +.. function:: tree gimple_eh_filter_types (gimple g) + + Return the types handled by ``GIMPLE_EH_FILTER`` statement ``G``. + +.. function:: tree * gimple_eh_filter_types_ptr (gimple g) + + Return a pointer to the types handled by ``GIMPLE_EH_FILTER`` + statement ``G``. + +.. function:: gimple_seq gimple_eh_filter_failure (gimple g) + + Return the sequence of statement to execute when ``GIMPLE_EH_FILTER`` + statement fails. + +.. function:: void gimple_eh_filter_set_types (geh_filter *g, tree types) + + Set ``TYPES`` to be the set of types handled by ``GIMPLE_EH_FILTER`` ``G``. + +.. function:: void gimple_eh_filter_set_failure (geh_filter *g, gimple_seq failure) + + Set ``FAILURE`` to be the sequence of statements to execute on + failure for ``GIMPLE_EH_FILTER`` ``G``. + +.. function:: tree gimple_eh_must_not_throw_fndecl ( geh_mnt *eh_mnt_stmt) + + Get the function decl to be called by the MUST_NOT_THROW region. + +.. function:: void gimple_eh_must_not_throw_set_fndecl ( geh_mnt *eh_mnt_stmt, tree decl) + + Set the function decl to be called by GS to DECL. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplegoto.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplegoto.rst new file mode 100644 index 00000000000..3ff689f8c90 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplegoto.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_GOTO + +GIMPLE_GOTO +^^^^^^^^^^^ + +.. function:: ggoto *gimple_build_goto (tree dest) + + Build a ``GIMPLE_GOTO`` statement to label ``DEST``. + +.. function:: tree gimple_goto_dest (gimple g) + + Return the destination of the unconditional jump ``G``. + +.. function:: void gimple_goto_set_dest (ggoto *g, tree dest) + + Set ``DEST`` to be the destination of the unconditional jump ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplelabel.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplelabel.rst new file mode 100644 index 00000000000..6eb2e677392 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplelabel.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_LABEL + +GIMPLE_LABEL +^^^^^^^^^^^^ + +.. function:: glabel *gimple_build_label (tree label) + + Build a ``GIMPLE_LABEL`` statement with corresponding to the tree + label, ``LABEL``. + +.. function:: tree gimple_label_label (const glabel *g) + + Return the ``LABEL_DECL`` node used by ``GIMPLE_LABEL`` statement ``G``. + +.. function:: void gimple_label_set_label (glabel *g, tree label) + + Set ``LABEL`` to be the ``LABEL_DECL`` node used by ``GIMPLE_LABEL`` + statement ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplenop.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplenop.rst new file mode 100644 index 00000000000..0f4def08977 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplenop.rst @@ -0,0 +1,17 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_NOP + +GIMPLE_NOP +^^^^^^^^^^ + +.. function:: gimple gimple_build_nop (void) + + Build a ``GIMPLE_NOP`` statement. + +.. function:: bool gimple_nop_p (gimple g) + + Returns ``TRUE`` if statement ``G`` is a ``GIMPLE_NOP``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompatomicload.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompatomicload.rst new file mode 100644 index 00000000000..7716628c550 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompatomicload.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_OMP_ATOMIC_LOAD + +GIMPLE_OMP_ATOMIC_LOAD +^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: gomp_atomic_load *gimple_build_omp_atomic_load ( tree lhs, tree rhs) + + Build a ``GIMPLE_OMP_ATOMIC_LOAD`` statement. ``LHS`` is the left-hand + side of the assignment. ``RHS`` is the right-hand side of the + assignment. + +.. function:: void gimple_omp_atomic_load_set_lhs ( gomp_atomic_load *g, tree lhs) + + Set the ``LHS`` of an atomic load. + +.. function:: tree gimple_omp_atomic_load_lhs ( const gomp_atomic_load *g) + + Get the ``LHS`` of an atomic load. + +.. function:: void gimple_omp_atomic_load_set_rhs ( gomp_atomic_load *g, tree rhs) + + Set the ``RHS`` of an atomic set. + +.. function:: tree gimple_omp_atomic_load_rhs ( const gomp_atomic_load *g) + + Get the ``RHS`` of an atomic set. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompatomicstore.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompatomicstore.rst new file mode 100644 index 00000000000..43d91e8fda7 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompatomicstore.rst @@ -0,0 +1,22 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_OMP_ATOMIC_STORE + +GIMPLE_OMP_ATOMIC_STORE +^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: gomp_atomic_store *gimple_build_omp_atomic_store ( tree val) + + Build a ``GIMPLE_OMP_ATOMIC_STORE`` statement. ``VAL`` is the value to be + stored. + +.. function:: void gimple_omp_atomic_store_set_val ( gomp_atomic_store *g, tree val) + + Set the value being stored in an atomic store. + +.. function:: tree gimple_omp_atomic_store_val ( const gomp_atomic_store *g) + + Return the value being stored in an atomic store. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompcontinue.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompcontinue.rst new file mode 100644 index 00000000000..5a256036100 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompcontinue.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_OMP_CONTINUE + +GIMPLE_OMP_CONTINUE +^^^^^^^^^^^^^^^^^^^ + +.. function:: gomp_continue *gimple_build_omp_continue ( tree control_def, tree control_use) + + Build a ``GIMPLE_OMP_CONTINUE`` statement. ``CONTROL_DEF`` is the + definition of the control variable. ``CONTROL_USE`` is the use of + the control variable. + +.. function:: tree gimple_omp_continue_control_def ( const gomp_continue *s) + + Return the definition of the control variable on a + ``GIMPLE_OMP_CONTINUE`` in ``S``. + +.. function:: tree gimple_omp_continue_control_def_ptr ( gomp_continue *s) + + Same as above, but return the pointer. + +.. function:: tree gimple_omp_continue_set_control_def ( gomp_continue *s) + + Set the control variable definition for a ``GIMPLE_OMP_CONTINUE`` + statement in ``S``. + +.. function:: tree gimple_omp_continue_control_use ( const gomp_continue *s) + + Return the use of the control variable on a ``GIMPLE_OMP_CONTINUE`` + in ``S``. + +.. function:: tree gimple_omp_continue_control_use_ptr ( gomp_continue *s) + + Same as above, but return the pointer. + +.. function:: tree gimple_omp_continue_set_control_use ( gomp_continue *s) + + Set the control variable use for a ``GIMPLE_OMP_CONTINUE`` statement + in ``S``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompcritical.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompcritical.rst new file mode 100644 index 00000000000..fde1d202ca8 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompcritical.rst @@ -0,0 +1,28 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_OMP_CRITICAL + +GIMPLE_OMP_CRITICAL +^^^^^^^^^^^^^^^^^^^ + +.. function:: gomp_critical *gimple_build_omp_critical ( gimple_seq body, tree name) + + Build a ``GIMPLE_OMP_CRITICAL`` statement. ``BODY`` is the sequence of + statements for which only one thread can execute. ``NAME`` is an + optional identifier for this critical block. + +.. function:: tree gimple_omp_critical_name ( const gomp_critical *g) + + Return the name associated with ``OMP_CRITICAL`` statement ``G``. + +.. function:: tree * gimple_omp_critical_name_ptr ( gomp_critical *g) + + Return a pointer to the name associated with ``OMP`` critical + statement ``G``. + +.. function:: void gimple_omp_critical_set_name ( gomp_critical *g, tree name) + + Set ``NAME`` to be the name associated with ``OMP`` critical statement ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompfor.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompfor.rst new file mode 100644 index 00000000000..a21a3ad7f5c --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompfor.rst @@ -0,0 +1,97 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_OMP_FOR + +GIMPLE_OMP_FOR +^^^^^^^^^^^^^^ + +.. function:: gomp_for *gimple_build_omp_for (gimple_seq body, tree clauses, tree index, tree initial, tree final, tree incr, gimple_seq pre_body, enum tree_code omp_for_cond) + + Build a ``GIMPLE_OMP_FOR`` statement. ``BODY`` is sequence of statements + inside the for loop. ``CLAUSES``, are any of the loop + construct's clauses. ``PRE_BODY`` is the + sequence of statements that are loop invariant. ``INDEX`` is the + index variable. ``INITIAL`` is the initial value of ``INDEX``. ``FINAL`` is + final value of ``INDEX``. OMP_FOR_COND is the predicate used to + compare ``INDEX`` and ``FINAL``. ``INCR`` is the increment expression. + +.. function:: tree gimple_omp_for_clauses (gimple g) + + Return the clauses associated with ``OMP_FOR`` ``G``. + +.. function:: tree * gimple_omp_for_clauses_ptr (gimple g) + + Return a pointer to the ``OMP_FOR`` ``G``. + +.. function:: void gimple_omp_for_set_clauses (gimple g, tree clauses) + + Set ``CLAUSES`` to be the list of clauses associated with ``OMP_FOR`` ``G``. + +.. function:: tree gimple_omp_for_index (gimple g) + + Return the index variable for ``OMP_FOR`` ``G``. + +.. function:: tree * gimple_omp_for_index_ptr (gimple g) + + Return a pointer to the index variable for ``OMP_FOR`` ``G``. + +.. function:: void gimple_omp_for_set_index (gimple g, tree index) + + Set ``INDEX`` to be the index variable for ``OMP_FOR`` ``G``. + +.. function:: tree gimple_omp_for_initial (gimple g) + + Return the initial value for ``OMP_FOR`` ``G``. + +.. function:: tree * gimple_omp_for_initial_ptr (gimple g) + + Return a pointer to the initial value for ``OMP_FOR`` ``G``. + +.. function:: void gimple_omp_for_set_initial (gimple g, tree initial) + + Set ``INITIAL`` to be the initial value for ``OMP_FOR`` ``G``. + +.. function:: tree gimple_omp_for_final (gimple g) + + Return the final value for ``OMP_FOR`` ``G``. + +.. function:: tree * gimple_omp_for_final_ptr (gimple g) + + turn a pointer to the final value for ``OMP_FOR`` ``G``. + +.. function:: void gimple_omp_for_set_final (gimple g, tree final) + + Set ``FINAL`` to be the final value for ``OMP_FOR`` ``G``. + +.. function:: tree gimple_omp_for_incr (gimple g) + + Return the increment value for ``OMP_FOR`` ``G``. + +.. function:: tree * gimple_omp_for_incr_ptr (gimple g) + + Return a pointer to the increment value for ``OMP_FOR`` ``G``. + +.. function:: void gimple_omp_for_set_incr (gimple g, tree incr) + + Set ``INCR`` to be the increment value for ``OMP_FOR`` ``G``. + +.. function:: gimple_seq gimple_omp_for_pre_body (gimple g) + + Return the sequence of statements to execute before the ``OMP_FOR`` + statement ``G`` starts. + +.. function:: void gimple_omp_for_set_pre_body (gimple g, gimple_seq pre_body) + + Set ``PRE_BODY`` to be the sequence of statements to execute before + the ``OMP_FOR`` statement ``G`` starts. + +.. function:: void gimple_omp_for_set_cond (gimple g, enum tree_code cond) + + Set ``COND`` to be the condition code for ``OMP_FOR`` ``G``. + +.. function:: enum tree_code gimple_omp_for_cond (gimple g) + + Return the condition code associated with ``OMP_FOR`` ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompmaster.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompmaster.rst new file mode 100644 index 00000000000..430f806b4d4 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompmaster.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_OMP_MASTER + +GIMPLE_OMP_MASTER +^^^^^^^^^^^^^^^^^ + +.. function:: gimple gimple_build_omp_master (gimple_seq body) + + Build a ``GIMPLE_OMP_MASTER`` statement. ``BODY`` is the sequence of + statements to be executed by just the master. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompordered.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompordered.rst new file mode 100644 index 00000000000..09042615c6f --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompordered.rst @@ -0,0 +1,16 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_OMP_ORDERED + +GIMPLE_OMP_ORDERED +^^^^^^^^^^^^^^^^^^ + +.. function:: gimple gimple_build_omp_ordered (gimple_seq body) + + Build a ``GIMPLE_OMP_ORDERED`` statement. + + ``BODY`` is the sequence of statements inside a loop that will + executed in sequence. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompparallel.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompparallel.rst new file mode 100644 index 00000000000..784e170e4de --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompparallel.rst @@ -0,0 +1,76 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_OMP_PARALLEL + +GIMPLE_OMP_PARALLEL +^^^^^^^^^^^^^^^^^^^ + +.. function:: gomp_parallel *gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn, tree data_arg) + + Build a ``GIMPLE_OMP_PARALLEL`` statement. + + ``BODY`` is sequence of statements which are executed in parallel. + ``CLAUSES``, are the ``OMP`` parallel construct's clauses. ``CHILD_FN`` is + the function created for the parallel threads to execute. + ``DATA_ARG`` are the shared data argument(s). + +.. function:: bool gimple_omp_parallel_combined_p (gimple g) + + Return true if ``OMP`` parallel statement ``G`` has the + ``GF_OMP_PARALLEL_COMBINED`` flag set. + +.. function:: void gimple_omp_parallel_set_combined_p (gimple g) + + Set the ``GF_OMP_PARALLEL_COMBINED`` field in ``OMP`` parallel statement + ``G``. + +.. function:: gimple_seq gimple_omp_body (gimple g) + + Return the body for the ``OMP`` statement ``G``. + +.. function:: void gimple_omp_set_body (gimple g, gimple_seq body) + + Set ``BODY`` to be the body for the ``OMP`` statement ``G``. + +.. function:: tree gimple_omp_parallel_clauses (gimple g) + + Return the clauses associated with ``OMP_PARALLEL`` ``G``. + +.. function:: tree * gimple_omp_parallel_clauses_ptr ( gomp_parallel *g) + + Return a pointer to the clauses associated with ``OMP_PARALLEL`` ``G``. + +.. function:: void gimple_omp_parallel_set_clauses ( gomp_parallel *g, tree clauses) + + Set ``CLAUSES`` to be the list of clauses associated with + ``OMP_PARALLEL`` ``G``. + +.. function:: tree gimple_omp_parallel_child_fn ( const gomp_parallel *g) + + Return the child function used to hold the body of ``OMP_PARALLEL`` + ``G``. + +.. function:: tree * gimple_omp_parallel_child_fn_ptr ( gomp_parallel *g) + + Return a pointer to the child function used to hold the body of + ``OMP_PARALLEL`` ``G``. + +.. function:: void gimple_omp_parallel_set_child_fn ( gomp_parallel *g, tree child_fn) + + Set ``CHILD_FN`` to be the child function for ``OMP_PARALLEL`` ``G``. + +.. function:: tree gimple_omp_parallel_data_arg ( const gomp_parallel *g) + + Return the artificial argument used to send variables and values + from the parent to the children threads in ``OMP_PARALLEL`` ``G``. + +.. function:: tree * gimple_omp_parallel_data_arg_ptr ( gomp_parallel *g) + + Return a pointer to the data argument for ``OMP_PARALLEL`` ``G``. + +.. function:: void gimple_omp_parallel_set_data_arg ( gomp_parallel *g, tree data_arg) + + Set ``DATA_ARG`` to be the data argument for ``OMP_PARALLEL`` ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompreturn.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompreturn.rst new file mode 100644 index 00000000000..f03d35a8225 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompreturn.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_OMP_RETURN + +GIMPLE_OMP_RETURN +^^^^^^^^^^^^^^^^^ + +.. function:: gimple gimple_build_omp_return (bool wait_p) + + Build a ``GIMPLE_OMP_RETURN`` statement. ``WAIT_P`` is true if this is a + non-waiting return. + +.. function:: void gimple_omp_return_set_nowait (gimple s) + + Set the nowait flag on ``GIMPLE_OMP_RETURN`` statement ``S``. + +.. function:: bool gimple_omp_return_nowait_p (gimple g) + + Return true if ``OMP`` return statement ``G`` has the + ``GF_OMP_RETURN_NOWAIT`` flag set. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompsection.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompsection.rst new file mode 100644 index 00000000000..ff9a321fa1e --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompsection.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_OMP_SECTION + +GIMPLE_OMP_SECTION +^^^^^^^^^^^^^^^^^^ + +.. function:: gimple gimple_build_omp_section (gimple_seq body) + + Build a ``GIMPLE_OMP_SECTION`` statement for a sections statement. + + ``BODY`` is the sequence of statements in the section. + +.. function:: bool gimple_omp_section_last_p (gimple g) + + Return true if ``OMP`` section statement ``G`` has the + ``GF_OMP_SECTION_LAST`` flag set. + +.. function:: void gimple_omp_section_set_last (gimple g) + + Set the ``GF_OMP_SECTION_LAST`` flag on ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompsections.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompsections.rst new file mode 100644 index 00000000000..10b34930b78 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompsections.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_OMP_SECTIONS + +GIMPLE_OMP_SECTIONS +^^^^^^^^^^^^^^^^^^^ + +.. function:: gomp_sections *gimple_build_omp_sections ( gimple_seq body, tree clauses) + + Build a ``GIMPLE_OMP_SECTIONS`` statement. ``BODY`` is a sequence of + section statements. ``CLAUSES`` are any of the ``OMP`` sections + construct's clauses: private, firstprivate, lastprivate, + reduction, and nowait. + +.. function:: gimple gimple_build_omp_sections_switch (void) + + Build a ``GIMPLE_OMP_SECTIONS_SWITCH`` statement. + +.. function:: tree gimple_omp_sections_control (gimple g) + + Return the control variable associated with the + ``GIMPLE_OMP_SECTIONS`` in ``G``. + +.. function:: tree * gimple_omp_sections_control_ptr (gimple g) + + Return a pointer to the clauses associated with the + ``GIMPLE_OMP_SECTIONS`` in ``G``. + +.. function:: void gimple_omp_sections_set_control (gimple g, tree control) + + Set ``CONTROL`` to be the set of clauses associated with the + ``GIMPLE_OMP_SECTIONS`` in ``G``. + +.. function:: tree gimple_omp_sections_clauses (gimple g) + + Return the clauses associated with ``OMP_SECTIONS`` ``G``. + +.. function:: tree * gimple_omp_sections_clauses_ptr (gimple g) + + Return a pointer to the clauses associated with ``OMP_SECTIONS`` ``G``. + +.. function:: void gimple_omp_sections_set_clauses (gimple g, tree clauses) + + Set ``CLAUSES`` to be the set of clauses associated with ``OMP_SECTIONS`` + ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompsingle.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompsingle.rst new file mode 100644 index 00000000000..d2e7bca70c4 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleompsingle.rst @@ -0,0 +1,28 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_OMP_SINGLE + +GIMPLE_OMP_SINGLE +^^^^^^^^^^^^^^^^^ + +.. function:: gomp_single *gimple_build_omp_single ( gimple_seq body, tree clauses) + + Build a ``GIMPLE_OMP_SINGLE`` statement. ``BODY`` is the sequence of + statements that will be executed once. ``CLAUSES`` are any of the + ``OMP`` single construct's clauses: private, firstprivate, + copyprivate, nowait. + +.. function:: tree gimple_omp_single_clauses (gimple g) + + Return the clauses associated with ``OMP_SINGLE`` ``G``. + +.. function:: tree * gimple_omp_single_clauses_ptr (gimple g) + + Return a pointer to the clauses associated with ``OMP_SINGLE`` ``G``. + +.. function:: void gimple_omp_single_set_clauses ( gomp_single *g, tree clauses) + + Set ``CLAUSES`` to be the clauses associated with ``OMP_SINGLE`` ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplephi.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplephi.rst new file mode 100644 index 00000000000..f4c1e727944 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplephi.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_PHI + +GIMPLE_PHI +^^^^^^^^^^ + +.. function:: unsigned gimple_phi_capacity (gimple g) + + Return the maximum number of arguments supported by ``GIMPLE_PHI`` ``G``. + +.. function:: unsigned gimple_phi_num_args (gimple g) + + Return the number of arguments in ``GIMPLE_PHI`` ``G``. This must always + be exactly the number of incoming edges for the basic block + holding ``G``. + +.. function:: tree gimple_phi_result (gimple g) + + Return the ``SSA`` name created by ``GIMPLE_PHI`` ``G``. + +.. function:: tree * gimple_phi_result_ptr (gimple g) + + Return a pointer to the ``SSA`` name created by ``GIMPLE_PHI`` ``G``. + +.. function:: void gimple_phi_set_result (gphi *g, tree result) + + Set ``RESULT`` to be the ``SSA`` name created by ``GIMPLE_PHI`` ``G``. + +.. function:: struct phi_arg_d * gimple_phi_arg (gimple g, index) + + Return the ``PHI`` argument corresponding to incoming edge ``INDEX`` for + ``GIMPLE_PHI`` ``G``. + +.. function:: void gimple_phi_set_arg (gphi *g, index, struct phi_arg_d * phiarg) + + Set ``PHIARG`` to be the argument corresponding to incoming edge + ``INDEX`` for ``GIMPLE_PHI`` ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleresx.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleresx.rst new file mode 100644 index 00000000000..60772a4c2e3 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleresx.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_RESX + +GIMPLE_RESX +^^^^^^^^^^^ + +.. function:: gresx *gimple_build_resx (int region) + + Build a ``GIMPLE_RESX`` statement which is a statement. This + statement is a placeholder for _Unwind_Resume before we know if a + function call or a branch is needed. ``REGION`` is the exception + region from which control is flowing. + +.. function:: int gimple_resx_region (const gresx *g) + + Return the region number for ``GIMPLE_RESX`` ``G``. + +.. function:: void gimple_resx_set_region (gresx *g, int region) + + Set ``REGION`` to be the region number for ``GIMPLE_RESX`` ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplereturn.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplereturn.rst new file mode 100644 index 00000000000..f451443527e --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplereturn.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_RETURN + +GIMPLE_RETURN +^^^^^^^^^^^^^ + +.. function:: greturn *gimple_build_return (tree retval) + + Build a ``GIMPLE_RETURN`` statement whose return value is retval. + +.. function:: tree gimple_return_retval (const greturn *g) + + Return the return value for ``GIMPLE_RETURN`` ``G``. + +.. function:: void gimple_return_set_retval (greturn *g, tree retval) + + Set ``RETVAL`` to be the return value for ``GIMPLE_RETURN`` ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleswitch.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleswitch.rst new file mode 100644 index 00000000000..9202458acb2 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpleswitch.rst @@ -0,0 +1,52 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_SWITCH + +GIMPLE_SWITCH +^^^^^^^^^^^^^ + +.. function:: gswitch *gimple_build_switch (tree index, tree default_label, vec *args) + + Build a ``GIMPLE_SWITCH`` statement. ``INDEX`` is the index variable + to switch on, and ``DEFAULT_LABEL`` represents the default label. + ``ARGS`` is a vector of ``CASE_LABEL_EXPR`` trees that contain the + non-default case labels. Each label is a tree of code ``CASE_LABEL_EXPR``. + +.. function:: unsigned gimple_switch_num_labels ( const gswitch *g) + + Return the number of labels associated with the switch statement + ``G``. + +.. function:: void gimple_switch_set_num_labels (gswitch *g, unsigned nlabels) + + Set ``NLABELS`` to be the number of labels for the switch statement + ``G``. + +.. function:: tree gimple_switch_index (const gswitch *g) + + Return the index variable used by the switch statement ``G``. + +.. function:: void gimple_switch_set_index (gswitch *g, tree index) + + Set ``INDEX`` to be the index variable for switch statement ``G``. + +.. function:: tree gimple_switch_label (const gswitch *g, unsigned index) + + Return the label numbered ``INDEX``. The default label is 0, followed + by any labels in a switch statement. + +.. function:: void gimple_switch_set_label (gswitch *g, unsigned index, tree label) + + Set the label number ``INDEX`` to ``LABEL``. 0 is always the default + label. + +.. function:: tree gimple_switch_default_label ( const gswitch *g) + + Return the default label for a switch statement. + +.. function:: void gimple_switch_set_default_label (gswitch *g, tree label) + + Set the default label for a switch statement. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpletry.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpletry.rst new file mode 100644 index 00000000000..50d75f71e56 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimpletry.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_TRY + +GIMPLE_TRY +^^^^^^^^^^ + +.. function:: gtry *gimple_build_try (gimple_seq eval, gimple_seq cleanup, unsigned int kind) + + Build a ``GIMPLE_TRY`` statement. ``EVAL`` is a sequence with the + expression to evaluate. ``CLEANUP`` is a sequence of statements to + run at clean-up time. ``KIND`` is the enumeration value + ``GIMPLE_TRY_CATCH`` if this statement denotes a try/catch construct + or ``GIMPLE_TRY_FINALLY`` if this statement denotes a try/finally + construct. + +.. function:: enum gimple_try_flags gimple_try_kind (gimple g) + + Return the kind of try block represented by ``GIMPLE_TRY`` ``G``. This is + either ``GIMPLE_TRY_CATCH`` or ``GIMPLE_TRY_FINALLY``. + +.. function:: bool gimple_try_catch_is_cleanup (gimple g) + + Return the ``GIMPLE_TRY_CATCH_IS_CLEANUP`` flag. + +.. function:: gimple_seq gimple_try_eval (gimple g) + + Return the sequence of statements used as the body for ``GIMPLE_TRY`` + ``G``. + +.. function:: gimple_seq gimple_try_cleanup (gimple g) + + Return the sequence of statements used as the cleanup body for + ``GIMPLE_TRY`` ``G``. + +.. function:: void gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup) + + Set the ``GIMPLE_TRY_CATCH_IS_CLEANUP`` flag. + +.. function:: void gimple_try_set_eval (gtry *g, gimple_seq eval) + + Set ``EVAL`` to be the sequence of statements to use as the body for + ``GIMPLE_TRY`` ``G``. + +.. function:: void gimple_try_set_cleanup (gtry *g, gimple_seq cleanup) + + Set ``CLEANUP`` to be the sequence of statements to use as the + cleanup body for ``GIMPLE_TRY`` ``G``. \ No newline at end of file diff --git a/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplewithcleanupexpr.rst b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplewithcleanupexpr.rst new file mode 100644 index 00000000000..f3274c92395 --- /dev/null +++ b/gcc/doc/gccint/gimple/tuple-specific-accessors/gimplewithcleanupexpr.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GIMPLE_WITH_CLEANUP_EXPR + +GIMPLE_WITH_CLEANUP_EXPR +^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: gimple gimple_build_wce (gimple_seq cleanup) + + Build a ``GIMPLE_WITH_CLEANUP_EXPR`` statement. ``CLEANUP`` is the + clean-up expression. + +.. function:: gimple_seq gimple_wce_cleanup (gimple g) + + Return the cleanup sequence for cleanup statement ``G``. + +.. function:: void gimple_wce_set_cleanup (gimple g, gimple_seq cleanup) + + Set ``CLEANUP`` to be the cleanup sequence for ``G``. + +.. function:: bool gimple_wce_cleanup_eh_only (gimple g) + + Return the ``CLEANUP_EH_ONLY`` flag for a ``WCE`` tuple. + +.. function:: void gimple_wce_set_cleanup_eh_only (gimple g, bool eh_only_p) + + Set the ``CLEANUP_EH_ONLY`` flag for a ``WCE`` tuple. \ No newline at end of file diff --git a/gcc/doc/gccint/gnu-free-documentation-license.rst b/gcc/doc/gccint/gnu-free-documentation-license.rst new file mode 100644 index 00000000000..1de809b3636 --- /dev/null +++ b/gcc/doc/gccint/gnu-free-documentation-license.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/gnu_free_documentation_license.rst \ No newline at end of file diff --git a/gcc/doc/gccint/guidelines-for-diagnostics.rst b/gcc/doc/gccint/guidelines-for-diagnostics.rst new file mode 100644 index 00000000000..1a568151b9c --- /dev/null +++ b/gcc/doc/gccint/guidelines-for-diagnostics.rst @@ -0,0 +1,598 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: guidelines for diagnostics, diagnostics, guidelines for + +.. _guidelines-for-diagnostics: + +Guidelines for Diagnostics +************************** + +Talk in terms of the user's code +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Diagnostics should be worded in terms of the user's source code, and the +source language, rather than GCC's own implementation details. + +.. index:: diagnostics, actionable + +Diagnostics are actionable +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A good diagnostic is :dfn:`actionable`: it should assist the user in +taking action. + +Consider what an end user will want to do when encountering a diagnostic. + +Given an error, an end user will think: 'How do I fix this?' + +Given a warning, an end user will think: + +* 'Is this a real problem?' + +* 'Do I care?' + +* if they decide it's genuine: 'How do I fix this?' + +A good diagnostic provides pertinent information to allow the user to +easily answer the above questions. + +The user's attention is important +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A perfect compiler would issue a warning on every aspect of the user's +source code that ought to be fixed, and issue no other warnings. +Naturally, this ideal is impossible to achieve. + +.. index:: signal-to-noise ratio (metaphorical usage for diagnostics), diagnostics, false positive, diagnostics, true positive, false positive, true positive + +Warnings should have a good :dfn:`signal-to-noise ratio`: we should have few +:dfn:`false positives` (falsely issuing a warning when no warning is +warranted) and few :dfn:`false negatives` (failing to issue a warning when +one *is* justified). + +Note that a false positive can mean, in practice, a warning that the +user doesn't agree with. Ideally a diagnostic should contain enough +information to allow the user to make an informed choice about whether +they should care (and how to fix it), but a balance must be drawn against +overloading the user with irrelevant data. + +Sometimes the user didn't write the code +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC is typically used in two different ways: + +* Semi-interactive usage: GCC is used as a development tool when the user + is writing code, as the 'compile' part of the 'edit-compile-debug' + cycle. The user is actively hacking on the code themself (perhaps a + project they wrote, or someone else's), where they just made a change + to the code and want to see what happens, and to be warned about + mistakes. + +* Batch rebuilds: where the user is recompiling one or more existing + packages, and GCC is a detail that's being invoked by various build + scripts. Examples include a user trying to bring up an operating system + consisting of hundreds of packages on a new CPU architecture, where the + packages were written by many different people, or simply rebuilding + packages after a dependency changed, where the user is hoping + 'nothing breaks', since they are unfamiliar with the code. + +Keep both of these styles of usage in mind when implementing diagnostics. + +Precision of Wording +^^^^^^^^^^^^^^^^^^^^ + +Provide the user with details that allow them to identify what the +problem is. For example, the vaguely-worded message: + +.. code-block:: + + demo.c:1:1: warning: 'noinline' attribute ignored [-Wattributes] + 1 | int foo __attribute__((noinline)); + | ^~~ + +doesn't tell the user why the attribute was ignored, or what kind of +entity the compiler thought the attribute was being applied to (the +source location for the diagnostic is also poor; +see :ref:`input_location_example`). +A better message would be: + +.. code-block:: + + demo.c:1:24: warning: attribute 'noinline' on variable 'foo' was + ignored [-Wattributes] + 1 | int foo __attribute__((noinline)); + | ~~~ ~~~~~~~~~~~~~~~^~~~~~~~~ + demo.c:1:24: note: attribute 'noinline' is only applicable to functions + +which spells out the missing information (and fixes the location +information, as discussed below). + +The above example uses a note to avoid a combinatorial explosion of possible +messages. + +Try the diagnostic on real-world code +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +It's worth testing a new warning on many instances of real-world code, +written by different people, and seeing what it complains about, and +what it doesn't complain about. + +This may suggest heuristics that silence common false positives. + +It may also suggest ways to improve the precision of the message. + +Make mismatches clear +^^^^^^^^^^^^^^^^^^^^^ + +Many diagnostics relate to a mismatch between two different places in the +user's source code. Examples include: + +* a type mismatch, where the type at a usage site does not match the type + at a declaration + +* the argument count at a call site does not match the parameter count + at the declaration + +* something is erroneously duplicated (e.g. an error, due to breaking a + uniqueness requirement, or a warning, if it's suggestive of a bug) + +* an 'opened' syntactic construct (such as an open-parenthesis) is not + closed + +.. todo:: more examples? + +In each case, the diagnostic should indicate **both** pertinent +locations (so that the user can easily see the problem and how to fix it). + +The standard way to do this is with a note (via ``inform``). For +example: + +.. code-block:: c++ + + auto_diagnostic_group d; + if (warning_at (loc, OPT_Wduplicated_cond, + "duplicated % condition")) + inform (EXPR_LOCATION (t), "previously used here"); + +which leads to: + +.. code-block:: + + demo.c: In function 'test': + demo.c:5:17: warning: duplicated 'if' condition [-Wduplicated-cond] + 5 | else if (flag > 3) + | ~~~~~^~~ + demo.c:3:12: note: previously used here + 3 | if (flag > 3) + | ~~~~~^~~ + +The ``inform`` call should be guarded by the return value from the +``warning_at`` call so that the note isn't emitted when the warning +is suppressed. + +For cases involving punctuation where the locations might be near +each other, they can be conditionally consolidated via +``gcc_rich_location::add_location_if_nearby`` : + +.. code-block:: c++ + + auto_diagnostic_group d; + gcc_rich_location richloc (primary_loc); + bool added secondary = richloc.add_location_if_nearby (secondary_loc); + error_at (&richloc, "main message"); + if (!added secondary) + inform (secondary_loc, "message for secondary"); + +This will emit either one diagnostic with two locations: + +.. code-block:: c++ + + demo.c:42:10: error: main message + (foo) + ~ ^ + +or two diagnostics: + +.. code-block:: c++ + + demo.c:42:4: error: main message + foo) + ^ + demo.c:40:2: note: message for secondary + ( + ^ + +.. index:: diagnostics, locations, location information, source code, location information, caret + +Location Information +^^^^^^^^^^^^^^^^^^^^ + +GCC's ``location_t`` type can support both ordinary locations, +and locations relating to a macro expansion. + +As of GCC 6, ordinary locations changed from supporting just a +point in the user's source code to supporting three points: the +:dfn:`caret` location, plus a start and a finish: + +.. code-block:: c++ + + a = foo && bar; + ~~~~^~~~~~ + | | | + | | finish + | caret + start + +Tokens coming out of libcpp have locations of the form ``caret == start``, +such as for ``foo`` here: + +.. code-block:: c++ + + a = foo && bar; + ^~~ + | | + | finish + caret == start + +Compound expressions should be reported using the location of the +expression as a whole, rather than just of one token within it. + +For example, in ``-Wformat``, rather than underlining just the first +token of a bad argument: + +.. code-block:: c++ + + printf("hello %i %s", (long)0, "world"); + ~^ ~ + %li + +the whole of the expression should be underlined, so that the user can +easily identify what is being referred to: + +.. code-block:: c++ + + printf("hello %i %s", (long)0, "world"); + ~^ ~~~~~~~ + %li + +.. this was r251239 + +Avoid using the ``input_location`` global, and the diagnostic functions +that implicitly use it---use ``error_at`` and ``warning_at`` rather +than ``error`` and ``warning``, and provide the most appropriate +``location_t`` value available at that phase of the compilation. It's +possible to supply secondary ``location_t`` values via +``rich_location``. + +.. _input_location_example: + +For example, in the example of imprecise wording above, generating the +diagnostic using ``warning`` : + +.. code-block:: c++ + + // BAD: implicitly uses input_location + warning (OPT_Wattributes, "%qE attribute ignored", name); + +leads to: + +.. code-block:: + + // BAD: uses input_location + demo.c:1:1: warning: 'noinline' attribute ignored [-Wattributes] + 1 | int foo __attribute__((noinline)); + | ^~~ + +which thus happened to use the location of the ``int`` token, rather +than that of the attribute. Using ``warning_at`` with the location of +the attribute, providing the location of the declaration in question +as a secondary location, and adding a note: + +.. code-block:: c++ + + auto_diagnostic_group d; + gcc_rich_location richloc (attrib_loc); + richloc.add_range (decl_loc); + if (warning_at (OPT_Wattributes, &richloc, + "attribute %qE on variable %qE was ignored", name)) + inform (attrib_loc, "attribute %qE is only applicable to functions"); + +would lead to: + +.. code-block:: + + // OK: use location of attribute, with a secondary location + demo.c:1:24: warning: attribute 'noinline' on variable 'foo' was + ignored [-Wattributes] + 1 | int foo __attribute__((noinline)); + | ~~~ ~~~~~~~~~~~~~~~^~~~~~~~~ + demo.c:1:24: note: attribute 'noinline' is only applicable to functions + +..todo:: labelling of ranges + +Coding Conventions +^^^^^^^^^^^^^^^^^^ + +See the `diagnostics section `_ of the GCC coding conventions. + +In the C++ front end, when comparing two types in a message, use :samp:`%H` +and :samp:`%I` rather than :samp:`%T`, as this allows the diagnostics +subsystem to highlight differences between template-based types. +For example, rather than using :samp:`%qT`: + +.. code-block:: c++ + + // BAD: a pair of %qT used in C++ front end for type comparison + error_at (loc, "could not convert %qE from %qT to %qT", expr, + TREE_TYPE (expr), type); + +which could lead to: + +.. code-block:: + + error: could not convert 'map()' from 'map' + to 'map' + +using :samp:`%H` and :samp:`%I` (via :samp:`%qH` and :samp:`%qI`): + +.. code-block:: c++ + + // OK: compare types in C++ front end via %qH and %qI + error_at (loc, "could not convert %qE from %qH to %qI", expr, + TREE_TYPE (expr), type); + +allows the above output to be simplified to: + +.. code-block:: + + error: could not convert 'map()' from 'map<[...],double>' + to 'map<[...],int>' + +where the ``double`` and ``int`` are colorized to highlight them. + +.. %H and %I were added in r248698. + +Group logically-related diagnostics +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Use ``auto_diagnostic_group`` when issuing multiple related +diagnostics (seen in various examples on this page). This informs the +diagnostic subsystem that all diagnostics issued within the lifetime +of the ``auto_diagnostic_group`` are related. For example, +:option:`-fdiagnostics-format=json` will treat the first diagnostic +emitted within the group as a top-level diagnostic, and all subsequent +diagnostics within the group as its children. + +Quoting +^^^^^^^ + +Text should be quoted by either using the :samp:`q` modifier in a directive +such as :samp:`%qE`, or by enclosing the quoted text in a pair of :samp:`%<` +and :samp:`%>` directives, and never by using explicit quote characters. +The directives handle the appropriate quote characters for each language +and apply the correct color or highlighting. + +The following elements should be quoted in GCC diagnostics: + +* Language keywords. + +* Tokens. + +* Boolean, numerical, character, and string constants that appear in the + source code. + +* Identifiers, including function, macro, type, and variable names. + +Other elements such as numbers that do not refer to numeric constants that +appear in the source code should not be quoted. For example, in the message: + +.. code-block:: c++ + + argument %d of %qE must be a pointer type + +since the argument number does not refer to a numerical constant in the +source code it should not be quoted. + +Spelling and Terminology +^^^^^^^^^^^^^^^^^^^^^^^^ + +See the `Spelling, terminology and markup `_ +section of the GCC coding conventions. + +.. index:: fix-it hints, diagnostics guidelines, fix-it hints + +Fix-it hints +^^^^^^^^^^^^ + +GCC's diagnostic subsystem can emit :dfn:`fix-it hints`: small suggested +edits to the user's source code. + +They are printed by default underneath the code in question. They +can also be viewed via :option:`-fdiagnostics-generate-patch` and +:option:`-fdiagnostics-parseable-fixits`. With the latter, an IDE +ought to be able to offer to automatically apply the suggested fix. + +Fix-it hints contain code fragments, and thus they should not be marked +for translation. + +Fix-it hints can be added to a diagnostic by using a ``rich_location`` +rather than a ``location_t`` - the fix-it hints are added to the +``rich_location`` using one of the various ``add_fixit`` member +functions of ``rich_location``. They are documented with +``rich_location`` in :samp:`libcpp/line-map.h`. +It's easiest to use the ``gcc_rich_location`` subclass of +``rich_location`` found in :samp:`gcc-rich-location.h`, as this +implicitly supplies the ``line_table`` variable. + +For example: + +.. code-block:: c++ + + if (const char *suggestion = hint.suggestion ()) + { + gcc_rich_location richloc (location); + richloc.add_fixit_replace (suggestion); + error_at (&richloc, + "%qE does not name a type; did you mean %qs?", + id, suggestion); + } + +which can lead to: + +.. code-block:: + + spellcheck-typenames.C:73:1: error: 'singed' does not name a type; did + you mean 'signed'? + 73 | singed char ch; + | ^~~~~~ + | signed + +Non-trivial edits can be built up by adding multiple fix-it hints to one +``rich_location``. It's best to express the edits in terms of the +locations of individual tokens. Various handy functions for adding +fix-it hints for idiomatic C and C++ can be seen in +:samp:`gcc-rich-location.h`. + +Fix-it hints should work +~~~~~~~~~~~~~~~~~~~~~~~~ + +When implementing a fix-it hint, please verify that the suggested edit +leads to fixed, compilable code. (Unfortunately, this currently must be +done by hand using :option:`-fdiagnostics-generate-patch`. It would be +good to have an automated way of verifying that fix-it hints actually fix +the code). + +For example, a 'gotcha' here is to forget to add a space when adding a +missing reserved word. Consider a C++ fix-it hint that adds +``typename`` in front of a template declaration. A naive way to +implement this might be: + +.. code-block:: c++ + + gcc_rich_location richloc (loc); + // BAD: insertion is missing a trailing space + richloc.add_fixit_insert_before ("typename"); + error_at (&richloc, "need % before %<%T::%E%> because " + "%qT is a dependent scope", + parser->scope, id, parser->scope); + +When applied to the code, this might lead to: + +.. code-block:: c++ + + T::type x; + +being 'corrected' to: + +.. code-block:: c++ + + typenameT::type x; + +In this case, the correct thing to do is to add a trailing space after +``typename`` : + +.. code-block:: c++ + + gcc_rich_location richloc (loc); + // OK: note that here we have a trailing space + richloc.add_fixit_insert_before ("typename "); + error_at (&richloc, "need % before %<%T::%E%> because " + "%qT is a dependent scope", + parser->scope, id, parser->scope); + +leading to this corrected code: + +.. code-block:: c++ + + typename T::type x; + +Express deletion in terms of deletion, not replacement +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +It's best to express deletion suggestions in terms of deletion fix-it +hints, rather than replacement fix-it hints. For example, consider this: + +.. code-block:: c++ + + auto_diagnostic_group d; + gcc_rich_location richloc (location_of (retval)); + tree name = DECL_NAME (arg); + richloc.add_fixit_replace (IDENTIFIER_POINTER (name)); + warning_at (&richloc, OPT_Wredundant_move, + "redundant move in return statement"); + +which is intended to e.g. replace a ``std::move`` with the underlying +value: + +.. code-block:: c++ + + return std::move (retval); + ~~~~~~~~~~^~~~~~~~ + retval + +where the change has been expressed as replacement, replacing +with the name of the declaration. +This works for simple cases, but consider this case: + +.. code-block:: c++ + + #ifdef SOME_CONFIG_FLAG + # define CONFIGURY_GLOBAL global_a + #else + # define CONFIGURY_GLOBAL global_b + #endif + + int fn () + { + return std::move (CONFIGURY_GLOBAL /* some comment */); + } + +The above implementation erroneously strips out the macro and the +comment in the fix-it hint: + +.. code-block:: c++ + + return std::move (CONFIGURY_GLOBAL /* some comment */); + ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + global_a + +and thus this resulting code: + +.. code-block:: c++ + + return global_a; + +It's better to do deletions in terms of deletions; deleting the +``std::move (`` and the trailing close-paren, leading to +this: + +.. code-block:: c++ + + return std::move (CONFIGURY_GLOBAL /* some comment */); + ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CONFIGURY_GLOBAL /* some comment */ + +and thus this result: + +.. code-block:: c++ + + return CONFIGURY_GLOBAL /* some comment */; + +Unfortunately, the pertinent ``location_t`` values are not always +available. + +.. the above was https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01474.html + +Multiple suggestions +~~~~~~~~~~~~~~~~~~~~ + +In the rare cases where you need to suggest more than one mutually +exclusive solution to a problem, this can be done by emitting +multiple notes and calling +``rich_location::fixits_cannot_be_auto_applied`` on each note's +``rich_location``. If this is called, then the fix-it hints in +the ``rich_location`` will be printed, but will not be added to +generated patches. \ No newline at end of file diff --git a/gcc/doc/gccint/guidelines-for-options.rst b/gcc/doc/gccint/guidelines-for-options.rst new file mode 100644 index 00000000000..f6a2962b32d --- /dev/null +++ b/gcc/doc/gccint/guidelines-for-options.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: command-line options, guidelines for, options, guidelines for, guidelines for options + +.. _guidelines-for-options: + +Guidelines for Options +********************** + +.. todo:: write part \ No newline at end of file diff --git a/gcc/doc/gccint/host-common.rst b/gcc/doc/gccint/host-common.rst new file mode 100644 index 00000000000..bbd0fcc4c55 --- /dev/null +++ b/gcc/doc/gccint/host-common.rst @@ -0,0 +1,57 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: host hooks, host functions + +.. _host-common: + +Host Common +*********** + +Some things are just not portable, even between similar operating systems, +and are too difficult for autoconf to detect. They get implemented using +hook functions in the file specified by the :samp:`{host_hook_obj}` +variable in :samp:`config.gcc`. + +.. function:: void HOST_HOOKS_EXTRA_SIGNALS (void) + + This host hook is used to set up handling for extra signals. The most + common thing to do in this hook is to detect stack overflow. + +.. function:: void * HOST_HOOKS_GT_PCH_GET_ADDRESS (size_t size, int fd) + + This host hook returns the address of some space that is likely to be + free in some subsequent invocation of the compiler. We intend to load + the PCH data at this address such that the data need not be relocated. + The area should be able to hold :samp:`{size}` bytes. If the host uses + ``mmap``, :samp:`{fd}` is an open file descriptor that can be used for + probing. + +.. function:: int HOST_HOOKS_GT_PCH_USE_ADDRESS (void * address, size_t size, int fd, size_t offset) + + This host hook is called when a PCH file is about to be loaded. + We want to load :samp:`{size}` bytes from :samp:`{fd}` at :samp:`{offset}` + into memory at :samp:`{address}`. The given address will be the result of + a previous invocation of ``HOST_HOOKS_GT_PCH_GET_ADDRESS``. + Return -1 if we couldn't allocate :samp:`{size}` bytes at :samp:`{address}`. + Return 0 if the memory is allocated but the data is not loaded. Return 1 + if the hook has performed everything. + + If the implementation uses reserved address space, free any reserved + space beyond :samp:`{size}`, regardless of the return value. If no PCH will + be loaded, this hook may be called with :samp:`{size}` zero, in which case + all reserved address space should be freed. + + Do not try to handle values of :samp:`{address}` that could not have been + returned by this executable; just return -1. Such values usually + indicate an out-of-date PCH file (built by some other GCC executable), + and such a PCH file won't work. + +.. function:: size_t HOST_HOOKS_GT_PCH_ALLOC_GRANULARITY (void); + + This host hook returns the alignment required for allocating virtual + memory. Usually this is the same as getpagesize, but on some hosts the + alignment for reserving memory differs from the pagesize for committing + memory. \ No newline at end of file diff --git a/gcc/doc/gccint/host-configuration.rst b/gcc/doc/gccint/host-configuration.rst new file mode 100644 index 00000000000..08df320e8d0 --- /dev/null +++ b/gcc/doc/gccint/host-configuration.rst @@ -0,0 +1,32 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: host configuration + +.. _host-config: + +Host Configuration +------------------ + +Most details about the machine and system on which the compiler is +actually running are detected by the :command:`configure` script. Some +things are impossible for :command:`configure` to detect; these are +described in two ways, either by macros defined in a file named +:samp:`xm-{machine}.h` or by hook functions in the file specified +by the :samp:`{out_host_hook_obj}` variable in :samp:`config.gcc`. (The +intention is that very few hosts will need a header file but nearly +every fully supported host will need to override some hooks.) + +If you need to define only a few macros, and they have simple +definitions, consider using the ``xm_defines`` variable in your +:samp:`config.gcc` entry instead of creating a host configuration +header. See :ref:`system-config`. + +.. toctree:: + :maxdepth: 2 + + host-common + host-misc + host-filesystem \ No newline at end of file diff --git a/gcc/doc/gccint/host-filesystem.rst b/gcc/doc/gccint/host-filesystem.rst new file mode 100644 index 00000000000..cb9e634fe43 --- /dev/null +++ b/gcc/doc/gccint/host-filesystem.rst @@ -0,0 +1,103 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: configuration file, xm-machine.h + +.. _filesystem: + +Host Filesystem +*************** + +GCC needs to know a number of things about the semantics of the host +machine's filesystem. Filesystems with Unix and MS-DOS semantics are +automatically detected. For other systems, you can define the +following macros in :samp:`xm-{machine}.h`. + +.. envvar:: HAVE_DOS_BASED_FILE_SYSTEM + + This macro is automatically defined by :samp:`system.h` if the host + file system obeys the semantics defined by MS-DOS instead of Unix. + DOS file systems are case insensitive, file specifications may begin + with a drive letter, and both forward slash and backslash (``/`` + and ``\``) are directory separators. + +.. envvar:: DIR_SEPARATOR + + If defined, these macros expand to character constants specifying + separators for directory names within a file specification. + :samp:`system.h` will automatically give them appropriate values on + Unix and MS-DOS file systems. If your file system is neither of + these, define one or both appropriately in :samp:`xm-{machine}.h`. + + However, operating systems like VMS, where constructing a pathname is + more complicated than just stringing together directory names + separated by a special character, should not define either of these + macros. + +.. envvar:: PATH_SEPARATOR + + If defined, this macro should expand to a character constant + specifying the separator for elements of search paths. The default + value is a colon (:samp:`:`). DOS-based systems usually, but not + always, use semicolon (:samp:`;`). + +``VMS`` + Define this macro if the host system is VMS. + +.. envvar:: HOST_OBJECT_SUFFIX + + Define this macro to be a C string representing the suffix for object + files on your host machine. If you do not define this macro, GCC will + use :samp:`.o` as the suffix for object files. + +.. envvar:: HOST_EXECUTABLE_SUFFIX + + Define this macro to be a C string representing the suffix for + executable files on your host machine. If you do not define this macro, + GCC will use the null string as the suffix for executable files. + +.. envvar:: HOST_BIT_BUCKET + + A pathname defined by the host operating system, which can be opened as + a file and written to, but all the information written is discarded. + This is commonly known as a :dfn:`bit bucket` or :dfn:`null device`. If + you do not define this macro, GCC will use :samp:`/dev/null` as the bit + bucket. If the host does not support a bit bucket, define this macro to + an invalid filename. + +:samp:`UPDATE_PATH_HOST_CANONICALIZE ({path})` + If defined, a C statement (sans semicolon) that performs host-dependent + canonicalization when a path used in a compilation driver or + preprocessor is canonicalized. :samp:`{path}` is a malloc-ed path to be + canonicalized. If the C statement does canonicalize :samp:`{path}` into a + different buffer, the old path should be freed and the new buffer should + have been allocated with malloc. + +.. envvar:: DUMPFILE_FORMAT + + Define this macro to be a C string representing the format to use for + constructing the index part of debugging dump file names. The resultant + string must fit in fifteen bytes. The full filename will be the + concatenation of: the prefix of the assembler file name, the string + resulting from applying this format to an index number, and a string + unique to each dump file kind, e.g. :samp:`rtl`. + + If you do not define this macro, GCC will use :samp:`.%02d.`. You should + define this macro if using the default will create an invalid file name. + +.. envvar:: DELETE_IF_ORDINARY + + Define this macro to be a C statement (sans semicolon) that performs + host-dependent removal of ordinary temp files in the compilation driver. + + If you do not define this macro, GCC will use the default version. You + should define this macro if the default version does not reliably remove + the temp file as, for example, on VMS which allows multiple versions + of a file. + +.. envvar:: HOST_LACKS_INODE_NUMBERS + + Define this macro if the host filesystem does not report meaningful inode + numbers in struct stat. \ No newline at end of file diff --git a/gcc/doc/gccint/host-makefile-fragments.rst b/gcc/doc/gccint/host-makefile-fragments.rst new file mode 100644 index 00000000000..3e8294acf97 --- /dev/null +++ b/gcc/doc/gccint/host-makefile-fragments.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: host makefile fragment, x-host + +.. _host-fragment: + +Host Makefile Fragments +*********************** + +The use of :samp:`x-{host}` fragments is discouraged. You should only +use it for makefile dependencies. \ No newline at end of file diff --git a/gcc/doc/gccint/host-misc.rst b/gcc/doc/gccint/host-misc.rst new file mode 100644 index 00000000000..8ce4de3c295 --- /dev/null +++ b/gcc/doc/gccint/host-misc.rst @@ -0,0 +1,70 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: configuration file, xm-machine.h + +.. _host-misc: + +Host Misc +********* + +.. envvar:: FATAL_EXIT_CODE + + A C expression for the status code to be returned when the compiler + exits after serious errors. The default is the system-provided macro + :samp:`EXIT_FAILURE`, or :samp:`1` if the system doesn't define that + macro. Define this macro only if these defaults are incorrect. + +.. envvar:: SUCCESS_EXIT_CODE + + A C expression for the status code to be returned when the compiler + exits without serious errors. (Warnings are not serious errors.) The + default is the system-provided macro :samp:`EXIT_SUCCESS`, or :samp:`0` if + the system doesn't define that macro. Define this macro only if these + defaults are incorrect. + +.. envvar:: USE_C_ALLOCA + + Define this macro if GCC should use the C implementation of ``alloca`` + provided by :samp:`libiberty.a`. This only affects how some parts of the + compiler itself allocate memory. It does not change code generation. + + When GCC is built with a compiler other than itself, the C ``alloca`` + is always used. This is because most other implementations have serious + bugs. You should define this macro only on a system where no + stack-based ``alloca`` can possibly work. For instance, if a system + has a small limit on the size of the stack, GCC's builtin ``alloca`` + will not work reliably. + +.. envvar:: COLLECT2_HOST_INITIALIZATION + + If defined, a C statement (sans semicolon) that performs host-dependent + initialization when ``collect2`` is being initialized. + +.. envvar:: GCC_DRIVER_HOST_INITIALIZATION + + If defined, a C statement (sans semicolon) that performs host-dependent + initialization when a compilation driver is being initialized. + +.. envvar:: HOST_LONG_LONG_FORMAT + + If defined, the string used to indicate an argument of type ``long + long`` to functions like ``printf``. The default value is + ``"ll"``. + +.. envvar:: HOST_LONG_FORMAT + + If defined, the string used to indicate an argument of type ``long`` + to functions like ``printf``. The default value is ``"l"``. + +.. envvar:: HOST_PTR_PRINTF + + If defined, the string used to indicate an argument of type ``void *`` + to functions like ``printf``. The default value is ``"%p"``. + +In addition, if :command:`configure` generates an incorrect definition of +any of the macros in :samp:`auto-host.h`, you can override that +definition in a host configuration header. If you need to do this, +first see if it is possible to fix :command:`configure`. \ No newline at end of file diff --git a/gcc/doc/gccint/index.rst b/gcc/doc/gccint/index.rst new file mode 100644 index 00000000000..600f12c5369 --- /dev/null +++ b/gcc/doc/gccint/index.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +GNU Compiler Collection (GCC) Internals +======================================= + +.. only:: html + + Contents: + +.. toctree:: + + copyright + introduction + contributing-to-gcc-development + gcc-and-portability + interfacing-to-gcc-output + the-gcc-low-level-runtime-library + language-front-ends-in-gcc + source-tree-structure-and-build-system + testsuites + option-specification-files + passes-and-files-of-the-compiler + sizes-and-offsets-as-runtime-invariants + generic + gimple + analysis-and-optimization-of-gimple-tuples + rtl-representation + control-flow-graph + analysis-and-representation-of-loops + machine-descriptions + target-macros + host-configuration + makefile-fragments + collect2 + standard-header-file-directories + memory-management-and-type-information + plugins + link-time-optimization + match-and-simplify + static-analyzer + user-experience-guidelines + + funding + contributors-to-gcc + general-public-license-3 + gnu-free-documentation-license + + indices-and-tables \ No newline at end of file diff --git a/gcc/doc/gccint/indices-and-tables.rst b/gcc/doc/gccint/indices-and-tables.rst new file mode 100644 index 00000000000..6c215a391d9 --- /dev/null +++ b/gcc/doc/gccint/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/gcc/doc/gccint/interfacing-to-gcc-output.rst b/gcc/doc/gccint/interfacing-to-gcc-output.rst new file mode 100644 index 00000000000..3c923567131 --- /dev/null +++ b/gcc/doc/gccint/interfacing-to-gcc-output.rst @@ -0,0 +1,71 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: interfacing to GCC output, run-time conventions, function call conventions, conventions, run-time + +.. _interface: + +Interfacing to GCC Output +------------------------- + +GCC is normally configured to use the same function calling convention +normally in use on the target system. This is done with the +machine-description macros described (see :ref:`target-macros`). + +.. index:: unions, returning, structures, returning, returning structures and unions + +However, returning of structure and union values is done differently on +some target machines. As a result, functions compiled with PCC +returning such types cannot be called from code compiled with GCC, +and vice versa. This does not cause trouble often because few Unix +library routines return structures or unions. + +GCC code returns structures and unions that are 1, 2, 4 or 8 bytes +long in the same registers used for ``int`` or ``double`` return +values. (GCC typically allocates variables of such types in +registers also.) Structures and unions of other sizes are returned by +storing them into an address passed by the caller (usually in a +register). The target hook ``TARGET_STRUCT_VALUE_RTX`` +tells GCC where to pass this address. + +By contrast, PCC on most target machines returns structures and unions +of any size by copying the data into an area of static storage, and then +returning the address of that storage as if it were a pointer value. +The caller must copy the data from that memory area to the place where +the value is wanted. This is slower than the method used by GCC, and +fails to be reentrant. + +On some target machines, such as RISC machines and the 80386, the +standard system convention is to pass to the subroutine the address of +where to return the value. On these machines, GCC has been +configured to be compatible with the standard compiler, when this method +is used. It may not be compatible for structures of 1, 2, 4 or 8 bytes. + +.. index:: argument passing, passing arguments + +GCC uses the system's standard convention for passing arguments. On +some machines, the first few arguments are passed in registers; in +others, all are passed on the stack. It would be possible to use +registers for argument passing on any machine, and this would probably +result in a significant speedup. But the result would be complete +incompatibility with code that follows the standard convention. So this +change is practical only if you are switching to GCC as the sole C +compiler for the system. We may implement register argument passing on +certain machines once we have a complete GNU system so that we can +compile the libraries with GCC. + +On some machines (particularly the SPARC), certain types of arguments +are passed 'by invisible reference'. This means that the value is +stored in memory, and the address of the memory location is passed to +the subroutine. + +.. index:: longjmp and automatic variables + +If you use ``longjmp``, beware of automatic variables. ISO C says that +automatic variables that are not declared ``volatile`` have undefined +values after a ``longjmp``. And this is all GCC promises to do, +because it is very difficult to restore register variables correctly, and +one of GCC's features is that it can put variables in registers without +your asking it to. \ No newline at end of file diff --git a/gcc/doc/gccint/introduction.rst b/gcc/doc/gccint/introduction.rst new file mode 100644 index 00000000000..65e963efd8e --- /dev/null +++ b/gcc/doc/gccint/introduction.rst @@ -0,0 +1,26 @@ +.. _top: + +Introduction +============ + +.. index:: introduction + +This manual documents the internals of the GNU compilers, including +how to port them to new targets and some information about how to +write front ends for new languages. It corresponds to the compilers +|package_version| +version |gcc_version|. The use of the GNU compilers is documented in a +separate manual. See :ref:`gcc:top`. + +This manual is mainly a reference manual rather than a tutorial. It +discusses how to contribute to GCC (see :ref:`contributing`), the +characteristics of the machines supported by GCC as hosts and targets +(see :ref:`portability`), how GCC relates to the ABIs on such systems +(see :ref:`interface`), and the characteristics of the languages for +which GCC front ends are written (see :ref:`languages`). It then +describes the GCC source tree structure and build system, some of the +interfaces to GCC front ends, and how support for a target system is +implemented in GCC. + +Additional tutorial information is linked to from +https://gcc.gnu.org/readings.html. \ No newline at end of file diff --git a/gcc/doc/gccint/language-front-ends-in-gcc.rst b/gcc/doc/gccint/language-front-ends-in-gcc.rst new file mode 100644 index 00000000000..3ad4dbd3bac --- /dev/null +++ b/gcc/doc/gccint/language-front-ends-in-gcc.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _languages: + +Language Front Ends in GCC +-------------------------- + +The interface to front ends for languages in GCC, and in particular +the ``tree`` structure (see :ref:`generic`), was initially designed for +C, and many aspects of it are still somewhat biased towards C and +C-like languages. It is, however, reasonably well suited to other +procedural languages, and front ends for many such languages have been +written for GCC. + +Writing a compiler as a front end for GCC, rather than compiling +directly to assembler or generating C code which is then compiled by +GCC, has several advantages: + +* GCC front ends benefit from the support for many different + target machines already present in GCC. + +* GCC front ends benefit from all the optimizations in GCC. Some + of these, such as alias analysis, may work better when GCC is + compiling directly from source code than when it is compiling from + generated C code. + +* Better debugging information is generated when compiling + directly from source code than when going via intermediate generated C + code. + +Because of the advantages of writing a compiler as a GCC front end, +GCC front ends have also been created for languages very different +from those for which GCC was designed, such as the declarative +logic/functional language Mercury. For these reasons, it may also be +useful to implement compilers created for specialized purposes (for +example, as part of a research project) as GCC front ends. \ No newline at end of file diff --git a/gcc/doc/gccint/link-time-optimization.rst b/gcc/doc/gccint/link-time-optimization.rst new file mode 100644 index 00000000000..b280003950e --- /dev/null +++ b/gcc/doc/gccint/link-time-optimization.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + + Contributed by Jan Hubicka and + Diego Novillo + + + +.. index:: lto, whopr, wpa, ltrans + +.. _lto: + +Link Time Optimization +---------------------- + +Link Time Optimization (LTO) gives GCC the capability of +dumping its internal representation (GIMPLE) to disk, +so that all the different compilation units that make up +a single executable can be optimized as a single module. +This expands the scope of inter-procedural optimizations +to encompass the whole program (or, rather, everything +that is visible at link time). + +.. toctree:: + :maxdepth: 2 + + link-time-optimization/design-overview + link-time-optimization/lto-file-sections + link-time-optimization/using-summary-information-in-ipa-passes + link-time-optimization/whole-program-assumptions-linker-plugin-and-symbol-visibilities + link-time-optimization/internal-flags-controlling-lto1 \ No newline at end of file diff --git a/gcc/doc/gccint/link-time-optimization/design-overview.rst b/gcc/doc/gccint/link-time-optimization/design-overview.rst new file mode 100644 index 00000000000..7583a3bd7d9 --- /dev/null +++ b/gcc/doc/gccint/link-time-optimization/design-overview.rst @@ -0,0 +1,123 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _lto-overview: + +Design Overview +*************** + +Link time optimization is implemented as a GCC front end for a +bytecode representation of GIMPLE that is emitted in special sections +of ``.o`` files. Currently, LTO support is enabled in most +ELF-based systems, as well as darwin, cygwin and mingw systems. + +By default, object files generated with LTO support contain only GIMPLE +bytecode. Such objects are called 'slim', and they require that +tools like ``ar`` and ``nm`` understand symbol tables of LTO +sections. For most targets these tools have been extended to use the +plugin infrastructure, so GCC can support 'slim' objects consisting +of the intermediate code alone. + +GIMPLE bytecode could also be saved alongside final object code if +the :option:`-ffat-lto-objects` option is passed, or if no plugin support +is detected for ``ar`` and ``nm`` when GCC is configured. It makes +the object files generated with LTO support larger than regular object +files. This 'fat' object format allows to ship one set of fat +objects which could be used both for development and the production of +optimized builds. A, perhaps surprising, side effect of this feature +is that any mistake in the toolchain leads to LTO information not +being used (e.g. an older ``libtool`` calling ``ld`` directly). +This is both an advantage, as the system is more robust, and a +disadvantage, as the user is not informed that the optimization has +been disabled. + +At the highest level, LTO splits the compiler in two. The first half +(the 'writer') produces a streaming representation of all the +internal data structures needed to optimize and generate code. This +includes declarations, types, the callgraph and the GIMPLE representation +of function bodies. + +When :option:`-flto` is given during compilation of a source file, the +pass manager executes all the passes in ``all_lto_gen_passes``. +Currently, this phase is composed of two IPA passes: + +* ``pass_ipa_lto_gimple_out`` + This pass executes the function ``lto_output`` in + :samp:`lto-streamer-out.cc`, which traverses the call graph encoding + every reachable declaration, type and function. This generates a + memory representation of all the file sections described below. + +* ``pass_ipa_lto_finish_out`` + This pass executes the function ``produce_asm_for_decls`` in + :samp:`lto-streamer-out.cc`, which takes the memory image built in the + previous pass and encodes it in the corresponding ELF file sections. + +The second half of LTO support is the 'reader'. This is implemented +as the GCC front end :samp:`lto1` in :samp:`lto/lto.cc`. When +:samp:`collect2` detects a link set of ``.o`` / ``.a`` files with +LTO information and the :option:`-flto` is enabled, it invokes +:samp:`lto1` which reads the set of files and aggregates them into a +single translation unit for optimization. The main entry point for +the reader is :samp:`lto/lto.cc`: ``lto_main``. + +LTO modes of operation +^^^^^^^^^^^^^^^^^^^^^^ + +One of the main goals of the GCC link-time infrastructure was to allow +effective compilation of large programs. For this reason GCC implements two +link-time compilation modes. + +* *LTO mode*, in which the whole program is read into the + compiler at link-time and optimized in a similar way as if it + were a single source-level compilation unit. + +* *WHOPR or partitioned mode*, designed to utilize multiple + CPUs and/or a distributed compilation environment to quickly link + large applications. WHOPR stands for WHOle Program optimizeR (not to + be confused with the semantics of :option:`-fwhole-program`). It + partitions the aggregated callgraph from many different ``.o`` + files and distributes the compilation of the sub-graphs to different + CPUs. + + Note that distributed compilation is not implemented yet, but since + the parallelism is facilitated via generating a ``Makefile``, it + would be easy to implement. + +WHOPR splits LTO into three main stages: + +* Local generation (LGEN) + This stage executes in parallel. Every file in the program is compiled + into the intermediate language and packaged together with the local + call-graph and summary information. This stage is the same for both + the LTO and WHOPR compilation mode. + +* Whole Program Analysis (WPA) + WPA is performed sequentially. The global call-graph is generated, and + a global analysis procedure makes transformation decisions. The global + call-graph is partitioned to facilitate parallel optimization during + phase 3. The results of the WPA stage are stored into new object files + which contain the partitions of program expressed in the intermediate + language and the optimization decisions. + +* Local transformations (LTRANS) + This stage executes in parallel. All the decisions made during phase 2 + are implemented locally in each partitioned object file, and the final + object code is generated. Optimizations which cannot be decided + efficiently during the phase 2 may be performed on the local + call-graph partitions. + +WHOPR can be seen as an extension of the usual LTO mode of +compilation. In LTO, WPA and LTRANS are executed within a single +execution of the compiler, after the whole program has been read into +memory. + +When compiling in WHOPR mode, the callgraph is partitioned during +the WPA stage. The whole program is split into a given number of +partitions of roughly the same size. The compiler tries to +minimize the number of references which cross partition boundaries. +The main advantage of WHOPR is to allow the parallel execution of +LTRANS stages, which are the most time-consuming part of the +compilation process. Additionally, it avoids the need to load the +whole program into memory. \ No newline at end of file diff --git a/gcc/doc/gccint/link-time-optimization/internal-flags-controlling-lto1.rst b/gcc/doc/gccint/link-time-optimization/internal-flags-controlling-lto1.rst new file mode 100644 index 00000000000..d9ea9a3e2ce --- /dev/null +++ b/gcc/doc/gccint/link-time-optimization/internal-flags-controlling-lto1.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _internal-flags: + +Internal flags controlling lto1 +******************************* + +The following flags are passed into :command:`lto1` and are not +meant to be used directly from the command line. + +.. option:: -fwpa + + This option runs the serial part of the link-time optimizer + performing the inter-procedural propagation (WPA mode). The + compiler reads in summary information from all inputs and + performs an analysis based on summary information only. It + generates object files for subsequent runs of the link-time + optimizer where individual object files are optimized using both + summary information from the WPA mode and the actual function + bodies. It then drives the LTRANS phase. + +.. option:: -fltrans + + This option runs the link-time optimizer in the + local-transformation (LTRANS) mode, which reads in output from a + previous run of the LTO in WPA mode. In the LTRANS mode, LTO + optimizes an object and produces the final assembly. + +.. option:: -fltrans-output-list=file + + This option specifies a file to which the names of LTRANS output + files are written. This option is only meaningful in conjunction + with :option:`-fwpa`. + +.. option:: -fresolution=file + + This option specifies the linker resolution file. This option is + only meaningful in conjunction with :option:`-fwpa` and as option + to pass through to the LTO linker plugin. \ No newline at end of file diff --git a/gcc/doc/gccint/link-time-optimization/lto-file-sections.rst b/gcc/doc/gccint/link-time-optimization/lto-file-sections.rst new file mode 100644 index 00000000000..1307e0c8ba9 --- /dev/null +++ b/gcc/doc/gccint/link-time-optimization/lto-file-sections.rst @@ -0,0 +1,110 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _lto-object-file-layout: + +LTO file sections +***************** + +LTO information is stored in several ELF sections inside object files. +Data structures and enum codes for sections are defined in +:samp:`lto-streamer.h`. + +These sections are emitted from :samp:`lto-streamer-out.cc` and mapped +in all at once from :samp:`lto/lto.cc`: ``lto_file_read``. The +individual functions dealing with the reading/writing of each section +are described below. + +* Command line options (``.gnu.lto_.opts``) + + This section contains the command line options used to generate the + object files. This is used at link time to determine the optimization + level and other settings when they are not explicitly specified at the + linker command line. + + Currently, GCC does not support combining LTO object files compiled + with different set of the command line options into a single binary. + At link time, the options given on the command line and the options + saved on all the files in a link-time set are applied globally. No + attempt is made at validating the combination of flags (other than the + usual validation done by option processing). This is implemented in + :samp:`lto/lto.cc`: ``lto_read_all_file_options``. + +* Symbol table (``.gnu.lto_.symtab``) + + This table replaces the ELF symbol table for functions and variables + represented in the LTO IL. Symbols used and exported by the optimized + assembly code of 'fat' objects might not match the ones used and + exported by the intermediate code. This table is necessary because + the intermediate code is less optimized and thus requires a separate + symbol table. + + Additionally, the binary code in the 'fat' object will lack a call + to a function, since the call was optimized out at compilation time + after the intermediate language was streamed out. In some special + cases, the same optimization may not happen during link-time + optimization. This would lead to an undefined symbol if only one + symbol table was used. + + The symbol table is emitted in + :samp:`lto-streamer-out.cc`: ``produce_symtab``. + +* Global declarations and types (``.gnu.lto_.decls``) + + This section contains an intermediate language dump of all + declarations and types required to represent the callgraph, static + variables and top-level debug info. + + The contents of this section are emitted in + :samp:`lto-streamer-out.cc`: ``produce_asm_for_decls``. Types and + symbols are emitted in a topological order that preserves the sharing + of pointers when the file is read back in + (:samp:`lto.cc`: ``read_cgraph_and_symbols``). + +* The callgraph (``.gnu.lto_.cgraph``) + + This section contains the basic data structure used by the GCC + inter-procedural optimization infrastructure. This section stores an + annotated multi-graph which represents the functions and call sites as + well as the variables, aliases and top-level ``asm`` statements. + + This section is emitted in + :samp:`lto-streamer-out.cc`: ``output_cgraph`` and read in + :samp:`lto-cgraph.cc`: ``input_cgraph``. + +* IPA references (``.gnu.lto_.refs``) + + This section contains references between function and static + variables. It is emitted by :samp:`lto-cgraph.cc`: ``output_refs`` + and read by :samp:`lto-cgraph.cc`: ``input_refs``. + +* Function bodies (``.gnu.lto_.function_body.``) + + This section contains function bodies in the intermediate language + representation. Every function body is in a separate section to allow + copying of the section independently to different object files or + reading the function on demand. + + Functions are emitted in + :samp:`lto-streamer-out.cc`: ``output_function`` and read in + :samp:`lto-streamer-in.cc`: ``input_function``. + +* Static variable initializers (``.gnu.lto_.vars``) + + This section contains all the symbols in the global variable pool. It + is emitted by :samp:`lto-cgraph.cc`: ``output_varpool`` and read in + :samp:`lto-cgraph.cc`: ``input_cgraph``. + +* Summaries and optimization summaries used by IPA passes + (``.gnu.lto_.``, where ```` is one of ``jmpfuncs``, + ``pureconst`` or ``reference``) + + These sections are used by IPA passes that need to emit summary + information during LTO generation to be read and aggregated at + link time. Each pass is responsible for implementing two pass manager + hooks: one for writing the summary and another for reading it in. The + format of these sections is entirely up to each individual pass. The + only requirement is that the writer and reader hooks agree on the + format. \ No newline at end of file diff --git a/gcc/doc/gccint/link-time-optimization/using-summary-information-in-ipa-passes.rst b/gcc/doc/gccint/link-time-optimization/using-summary-information-in-ipa-passes.rst new file mode 100644 index 00000000000..6f760285c79 --- /dev/null +++ b/gcc/doc/gccint/link-time-optimization/using-summary-information-in-ipa-passes.rst @@ -0,0 +1,206 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ipa: + +Using summary information in IPA passes +*************************************** + +Programs are represented internally as a *callgraph* (a +multi-graph where nodes are functions and edges are call sites) +and a *varpool* (a list of static and external variables in +the program). + +The inter-procedural optimization is organized as a sequence of +individual passes, which operate on the callgraph and the +varpool. To make the implementation of WHOPR possible, every +inter-procedural optimization pass is split into several stages +that are executed at different times during WHOPR compilation: + +* LGEN time + + * *Generate summary* (``generate_summary`` in + ``struct ipa_opt_pass_d``). This stage analyzes every function + body and variable initializer is examined and stores relevant + information into a pass-specific data structure. + + * *Write summary* (``write_summary`` in + ``struct ipa_opt_pass_d``). This stage writes all the + pass-specific information generated by ``generate_summary``. + Summaries go into their own ``LTO_section_*`` sections that + have to be declared in :samp:`lto-streamer.h`: ``enum + lto_section_type``. A new section is created by calling + ``create_output_block`` and data can be written using the + ``lto_output_*`` routines. + +* WPA time + + * *Read summary* (``read_summary`` in + ``struct ipa_opt_pass_d``). This stage reads all the + pass-specific information in exactly the same order that it was + written by ``write_summary``. + + * *Execute* (``execute`` in ``struct + opt_pass``). This performs inter-procedural propagation. This + must be done without actual access to the individual function + bodies or variable initializers. Typically, this results in a + transitive closure operation over the summary information of all + the nodes in the callgraph. + + * *Write optimization summary* + (``write_optimization_summary`` in ``struct + ipa_opt_pass_d``). This writes the result of the inter-procedural + propagation into the object file. This can use the same data + structures and helper routines used in ``write_summary``. + +* LTRANS time + + * *Read optimization summary* + (``read_optimization_summary`` in ``struct + ipa_opt_pass_d``). The counterpart to + ``write_optimization_summary``. This reads the interprocedural + optimization decisions in exactly the same format emitted by + ``write_optimization_summary``. + + * *Transform* (``function_transform`` and + ``variable_transform`` in ``struct ipa_opt_pass_d``). + The actual function bodies and variable initializers are updated + based on the information passed down from the *Execute* stage. + +The implementation of the inter-procedural passes are shared +between LTO, WHOPR and classic non-LTO compilation. + +* During the traditional file-by-file mode every pass executes its + own *Generate summary*, *Execute*, and *Transform* + stages within the single execution context of the compiler. + +* In LTO compilation mode, every pass uses *Generate + summary* and *Write summary* stages at compilation time, + while the *Read summary*, *Execute*, and + *Transform* stages are executed at link time. + +* In WHOPR mode all stages are used. + +To simplify development, the GCC pass manager differentiates +between normal inter-procedural passes (see :ref:`regular-ipa-passes`), +small inter-procedural passes (see :ref:`small-ipa-passes`) +and late inter-procedural passes (see :ref:`late-ipa-passes`). +A small or late IPA pass (``SIMPLE_IPA_PASS``) does +everything at once and thus cannot be executed during WPA in +WHOPR mode. It defines only the *Execute* stage and during +this stage it accesses and modifies the function bodies. Such +passes are useful for optimization at LGEN or LTRANS time and are +used, for example, to implement early optimization before writing +object files. The simple inter-procedural passes can also be used +for easier prototyping and development of a new inter-procedural +pass. + +Virtual clones +^^^^^^^^^^^^^^ + +One of the main challenges of introducing the WHOPR compilation +mode was addressing the interactions between optimization passes. +In LTO compilation mode, the passes are executed in a sequence, +each of which consists of analysis (or *Generate summary*), +propagation (or *Execute*) and *Transform* stages. +Once the work of one pass is finished, the next pass sees the +updated program representation and can execute. This makes the +individual passes dependent on each other. + +In WHOPR mode all passes first execute their *Generate +summary* stage. Then summary writing marks the end of the LGEN +stage. At WPA time, +the summaries are read back into memory and all passes run the +*Execute* stage. Optimization summaries are streamed and +sent to LTRANS, where all the passes execute the *Transform* +stage. + +Most optimization passes split naturally into analysis, +propagation and transformation stages. But some do not. The +main problem arises when one pass performs changes and the +following pass gets confused by seeing different callgraphs +between the *Transform* stage and the *Generate summary* +or *Execute* stage. This means that the passes are required +to communicate their decisions with each other. + +To facilitate this communication, the GCC callgraph +infrastructure implements *virtual clones*, a method of +representing the changes performed by the optimization passes in +the callgraph without needing to update function bodies. + +A *virtual clone* in the callgraph is a function that has no +associated body, just a description of how to create its body based +on a different function (which itself may be a virtual clone). + +The description of function modifications includes adjustments to +the function's signature (which allows, for example, removing or +adding function arguments), substitutions to perform on the +function body, and, for inlined functions, a pointer to the +function that it will be inlined into. + +It is also possible to redirect any edge of the callgraph from a +function to its virtual clone. This implies updating of the call +site to adjust for the new function signature. + +Most of the transformations performed by inter-procedural +optimizations can be represented via virtual clones. For +instance, a constant propagation pass can produce a virtual clone +of the function which replaces one of its arguments by a +constant. The inliner can represent its decisions by producing a +clone of a function whose body will be later integrated into +a given function. + +Using *virtual clones*, the program can be easily updated +during the *Execute* stage, solving most of pass interactions +problems that would otherwise occur during *Transform*. + +Virtual clones are later materialized in the LTRANS stage and +turned into real functions. Passes executed after the virtual +clone were introduced also perform their *Transform* stage +on new functions, so for a pass there is no significant +difference between operating on a real function or a virtual +clone introduced before its *Execute* stage. + +Optimization passes then work on virtual clones introduced before +their *Execute* stage as if they were real functions. The +only difference is that clones are not visible during the +*Generate Summary* stage. + +To keep function summaries updated, the callgraph interface +allows an optimizer to register a callback that is called every +time a new clone is introduced as well as when the actual +function or variable is generated or when a function or variable +is removed. These hooks are registered in the *Generate +summary* stage and allow the pass to keep its information intact +until the *Execute* stage. The same hooks can also be +registered during the *Execute* stage to keep the +optimization summaries updated for the *Transform* stage. + +IPA references +^^^^^^^^^^^^^^ + +GCC represents IPA references in the callgraph. For a function +or variable ``A``, the *IPA reference* is a list of all +locations where the address of ``A`` is taken and, when +``A`` is a variable, a list of all direct stores and reads +to/from ``A``. References represent an oriented multi-graph on +the union of nodes of the callgraph and the varpool. See +:samp:`ipa-reference.cc`: ``ipa_reference_write_optimization_summary`` +and +:samp:`ipa-reference.cc`: ``ipa_reference_read_optimization_summary`` +for details. + +Jump functions +^^^^^^^^^^^^^^ + +Suppose that an optimization pass sees a function ``A`` and it +knows the values of (some of) its arguments. The *jump +function* describes the value of a parameter of a given function +call in function ``A`` based on this knowledge. + +Jump functions are used by several optimizations, such as the +inter-procedural constant propagation pass and the +devirtualization pass. The inliner also uses jump functions to +perform inlining of callbacks. \ No newline at end of file diff --git a/gcc/doc/gccint/link-time-optimization/whole-program-assumptions-linker-plugin-and-symbol-visibilities.rst b/gcc/doc/gccint/link-time-optimization/whole-program-assumptions-linker-plugin-and-symbol-visibilities.rst new file mode 100644 index 00000000000..024cc335812 --- /dev/null +++ b/gcc/doc/gccint/link-time-optimization/whole-program-assumptions-linker-plugin-and-symbol-visibilities.rst @@ -0,0 +1,91 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _whopr: + +Whole program assumptions, linker plugin and symbol visibilities +**************************************************************** + +Link-time optimization gives relatively minor benefits when used +alone. The problem is that propagation of inter-procedural +information does not work well across functions and variables +that are called or referenced by other compilation units (such as +from a dynamically linked library). We say that such functions +and variables are *externally visible*. + +To make the situation even more difficult, many applications +organize themselves as a set of shared libraries, and the default +ELF visibility rules allow one to overwrite any externally +visible symbol with a different symbol at runtime. This +basically disables any optimizations across such functions and +variables, because the compiler cannot be sure that the function +body it is seeing is the same function body that will be used at +runtime. Any function or variable not declared ``static`` in +the sources degrades the quality of inter-procedural +optimization. + +To avoid this problem the compiler must assume that it sees the +whole program when doing link-time optimization. Strictly +speaking, the whole program is rarely visible even at link-time. +Standard system libraries are usually linked dynamically or not +provided with the link-time information. In GCC, the whole +program option (:option:`-fwhole-program`) asserts that every +function and variable defined in the current compilation +unit is static, except for function ``main`` (note: at +link time, the current unit is the union of all objects compiled +with LTO). Since some functions and variables need to +be referenced externally, for example by another DSO or from an +assembler file, GCC also provides the function and variable +attribute ``externally_visible`` which can be used to disable +the effect of :option:`-fwhole-program` on a specific symbol. + +The whole program mode assumptions are slightly more complex in +C++, where inline functions in headers are put into *COMDAT* +sections. COMDAT function and variables can be defined by +multiple object files and their bodies are unified at link-time +and dynamic link-time. COMDAT functions are changed to local only +when their address is not taken and thus un-sharing them with a +library is not harmful. COMDAT variables always remain externally +visible, however for readonly variables it is assumed that their +initializers cannot be overwritten by a different value. + +GCC provides the function and variable attribute +``visibility`` that can be used to specify the visibility of +externally visible symbols (or alternatively an +:option:`-fdefault-visibility` command line option). ELF defines +the ``default``, ``protected``, ``hidden`` and +``internal`` visibilities. + +The most commonly used is visibility is ``hidden``. It +specifies that the symbol cannot be referenced from outside of +the current shared library. Unfortunately, this information +cannot be used directly by the link-time optimization in the +compiler since the whole shared library also might contain +non-LTO objects and those are not visible to the compiler. + +GCC solves this problem using linker plugins. A *linker +plugin* is an interface to the linker that allows an external +program to claim the ownership of a given object file. The linker +then performs the linking procedure by querying the plugin about +the symbol table of the claimed objects and once the linking +decisions are complete, the plugin is allowed to provide the +final object file before the actual linking is made. The linker +plugin obtains the symbol resolution information which specifies +which symbols provided by the claimed objects are bound from the +rest of a binary being linked. + +GCC is designed to be independent of the rest of the toolchain +and aims to support linkers without plugin support. For this +reason it does not use the linker plugin by default. Instead, +the object files are examined by :command:`collect2` before being +passed to the linker and objects found to have LTO sections are +passed to :command:`lto1` first. This mode does not work for +library archives. The decision on what object files from the +archive are needed depends on the actual linking and thus GCC +would have to implement the linker itself. The resolution +information is missing too and thus GCC needs to make an educated +guess based on :option:`-fwhole-program`. Without the linker +plugin GCC also assumes that symbols are declared ``hidden`` +and not referred by non-LTO code by default. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions.rst b/gcc/doc/gccint/machine-descriptions.rst new file mode 100644 index 00000000000..b2308084a92 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions.rst @@ -0,0 +1,49 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: machine descriptions + +.. _machine-desc: + +Machine Descriptions +-------------------- + +A machine description has two parts: a file of instruction patterns +(:samp:`.md` file) and a C header file of macro definitions. + +The :samp:`.md` file for a target machine contains a pattern for each +instruction that the target machine supports (or at least each instruction +that is worth telling the compiler about). It may also contain comments. +A semicolon causes the rest of the line to be a comment, unless the semicolon +is inside a quoted string. + +See the next chapter for information on the C header file. + +.. toctree:: + :maxdepth: 2 + + machine-descriptions/overview-of-how-the-machine-description-is-used + machine-descriptions/everything-about-instruction-patterns + machine-descriptions/example-of-defineinsn + machine-descriptions/rtl-template + machine-descriptions/output-templates-and-operand-substitution + machine-descriptions/c-statements-for-assembler-output + machine-descriptions/predicates + machine-descriptions/operand-constraints + machine-descriptions/standard-pattern-names-for-generation + machine-descriptions/when-the-order-of-patterns-matters + machine-descriptions/interdependence-of-patterns + machine-descriptions/defining-jump-instruction-patterns + machine-descriptions/defining-looping-instruction-patterns + machine-descriptions/canonicalization-of-instructions + machine-descriptions/defining-rtl-sequences-for-code-generation + machine-descriptions/defining-how-to-split-instructions + machine-descriptions/including-patterns-in-machine-descriptions + machine-descriptions/machine-specific-peephole-optimizers + machine-descriptions/instruction-attributes + machine-descriptions/conditional-execution + machine-descriptions/rtl-templates-transformations + machine-descriptions/constant-definitions + machine-descriptions/iterators \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/c-statements-for-assembler-output.rst b/gcc/doc/gccint/machine-descriptions/c-statements-for-assembler-output.rst new file mode 100644 index 00000000000..55def814edd --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/c-statements-for-assembler-output.rst @@ -0,0 +1,122 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: output statements, C statements for assembler output, generating assembler output + +.. _output-statement: + +C Statements for Assembler Output +********************************* + +Often a single fixed template string cannot produce correct and efficient +assembler code for all the cases that are recognized by a single +instruction pattern. For example, the opcodes may depend on the kinds of +operands; or some unfortunate combinations of operands may require extra +machine instructions. + +If the output control string starts with a :samp:`@`, then it is actually +a series of templates, each on a separate line. (Blank lines and +leading spaces and tabs are ignored.) The templates correspond to the +pattern's constraint alternatives (see :ref:`multi-alternative`). For example, +if a target machine has a two-address add instruction :samp:`addr` to add +into a register and another :samp:`addm` to add a register to memory, you +might write this pattern: + +.. code-block:: + + (define_insn "addsi3" + [(set (match_operand:SI 0 "general_operand" "=r,m") + (plus:SI (match_operand:SI 1 "general_operand" "0,0") + (match_operand:SI 2 "general_operand" "g,r")))] + "" + "@ + addr %2,%0 + addm %2,%0") + +.. index:: * in template, asterisk in template + +If the output control string starts with a :samp:`*`, then it is not an +output template but rather a piece of C program that should compute a +template. It should execute a ``return`` statement to return the +template-string you want. Most such templates use C string literals, which +require doublequote characters to delimit them. To include these +doublequote characters in the string, prefix each one with ``\``. + +If the output control string is written as a brace block instead of a +double-quoted string, it is automatically assumed to be C code. In that +case, it is not necessary to put in a leading asterisk, or to escape the +doublequotes surrounding C string literals. + +The operands may be found in the array ``operands``, whose C data type +is ``rtx []``. + +It is very common to select different ways of generating assembler code +based on whether an immediate operand is within a certain range. Be +careful when doing this, because the result of ``INTVAL`` is an +integer on the host machine. If the host machine has more bits in an +``int`` than the target machine has in the mode in which the constant +will be used, then some of the bits you get from ``INTVAL`` will be +superfluous. For proper results, you must carefully disregard the +values of those bits. + +.. index:: output_asm_insn + +It is possible to output an assembler instruction and then go on to output +or compute more of them, using the subroutine ``output_asm_insn``. This +receives two arguments: a template-string and a vector of operands. The +vector may be ``operands``, or it may be another array of ``rtx`` +that you declare locally and initialize yourself. + +.. index:: which_alternative + +When an insn pattern has multiple alternatives in its constraints, often +the appearance of the assembler code is determined mostly by which alternative +was matched. When this is so, the C code can test the variable +``which_alternative``, which is the ordinal number of the alternative +that was actually satisfied (0 for the first, 1 for the second alternative, +etc.). + +For example, suppose there are two opcodes for storing zero, :samp:`clrreg` +for registers and :samp:`clrmem` for memory locations. Here is how +a pattern could use ``which_alternative`` to choose between them: + +.. code-block:: + + (define_insn "" + [(set (match_operand:SI 0 "general_operand" "=r,m") + (const_int 0))] + "" + { + return (which_alternative == 0 + ? "clrreg %0" : "clrmem %0"); + }) + +The example above, where the assembler code to generate was +*solely* determined by the alternative, could also have been specified +as follows, having the output control string start with a :samp:`@`: + +.. code-block:: + + (define_insn "" + [(set (match_operand:SI 0 "general_operand" "=r,m") + (const_int 0))] + "" + "@ + clrreg %0 + clrmem %0") + +If you just need a little bit of C code in one (or a few) alternatives, +you can use :samp:`*` inside of a :samp:`@` multi-alternative template: + +.. code-block:: + + (define_insn "" + [(set (match_operand:SI 0 "general_operand" "=r,<,m") + (const_int 0))] + "" + "@ + clrreg %0 + * return stack_mem_p (operands[0]) ? \"push 0\" : \"clrmem %0\"; + clrmem %0") \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/canonicalization-of-instructions.rst b/gcc/doc/gccint/machine-descriptions/canonicalization-of-instructions.rst new file mode 100644 index 00000000000..f0dfafad778 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/canonicalization-of-instructions.rst @@ -0,0 +1,152 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: canonicalization of instructions, insn canonicalization + +.. _insn-canonicalizations: + +Canonicalization of Instructions +******************************** + +There are often cases where multiple RTL expressions could represent an +operation performed by a single machine instruction. This situation is +most commonly encountered with logical, branch, and multiply-accumulate +instructions. In such cases, the compiler attempts to convert these +multiple RTL expressions into a single canonical form to reduce the +number of insn patterns required. + +In addition to algebraic simplifications, following canonicalizations +are performed: + +* For commutative and comparison operators, a constant is always made the + second operand. If a machine only supports a constant as the second + operand, only patterns that match a constant in the second operand need + be supplied. + +* For associative operators, a sequence of operators will always chain + to the left; for instance, only the left operand of an integer ``plus`` + can itself be a ``plus``. ``and``, ``ior``, ``xor``, + ``plus``, ``mult``, ``smin``, ``smax``, ``umin``, and + ``umax`` are associative when applied to integers, and sometimes to + floating-point. + +.. index:: neg, canonicalization of, not, canonicalization of, mult, canonicalization of, plus, canonicalization of, minus, canonicalization of + +* For these operators, if only one operand is a ``neg``, ``not``, + ``mult``, ``plus``, or ``minus`` expression, it will be the + first operand. + +* In combinations of ``neg``, ``mult``, ``plus``, and + ``minus``, the ``neg`` operations (if any) will be moved inside + the operations as far as possible. For instance, + ``(neg (mult A B))`` is canonicalized as ``(mult (neg A) B)``, but + ``(plus (mult (neg B) C) A)`` is canonicalized as + ``(minus A (mult B C))``. + + .. index:: compare, canonicalization of + +* For the ``compare`` operator, a constant is always the second operand + if the first argument is a condition code register. + +* For instructions that inherently set a condition code register, the + ``compare`` operator is always written as the first RTL expression of + the ``parallel`` instruction pattern. For example, + + .. code-block:: + + (define_insn "" + [(set (reg:CCZ FLAGS_REG) + (compare:CCZ + (plus:SI + (match_operand:SI 1 "register_operand" "%r") + (match_operand:SI 2 "register_operand" "r")) + (const_int 0))) + (set (match_operand:SI 0 "register_operand" "=r") + (plus:SI (match_dup 1) (match_dup 2)))] + "" + "addl %0, %1, %2") + +* An operand of ``neg``, ``not``, ``mult``, ``plus``, or + ``minus`` is made the first operand under the same conditions as + above. + +* ``(ltu (plus ab) b)`` is converted to + ``(ltu (plus ab) a)``. Likewise with ``geu`` instead + of ``ltu``. + +* ``(minus x (const_int n))`` is converted to + ``(plus x (const_int -n))``. + +* Within address computations (i.e., inside ``mem``), a left shift is + converted into the appropriate multiplication by a power of two. + + .. index:: ior, canonicalization of, and, canonicalization of, De Morgan's law + +* De Morgan's Law is used to move bitwise negation inside a bitwise + logical-and or logical-or operation. If this results in only one + operand being a ``not`` expression, it will be the first one. + + A machine that has an instruction that performs a bitwise logical-and of one + operand with the bitwise negation of the other should specify the pattern + for that instruction as + + .. code-block:: + + (define_insn "" + [(set (match_operand:m 0 ...) + (and:m (not:m (match_operand:m 1 ...)) + (match_operand:m 2 ...)))] + "..." + "...") + + Similarly, a pattern for a 'NAND' instruction should be written + + .. code-block:: + + (define_insn "" + [(set (match_operand:m 0 ...) + (ior:m (not:m (match_operand:m 1 ...)) + (not:m (match_operand:m 2 ...))))] + "..." + "...") + + In both cases, it is not necessary to include patterns for the many + logically equivalent RTL expressions. + + .. index:: xor, canonicalization of + +* The only possible RTL expressions involving both bitwise exclusive-or + and bitwise negation are ``(xor:mxy)`` + and ``(not:m (xor:mxy))``. + +* The sum of three items, one of which is a constant, will only appear in + the form + + .. code-block:: c++ + + (plus:m (plus:m x y) constant) + + .. index:: zero_extract, canonicalization of, sign_extract, canonicalization of + +* Equality comparisons of a group of bits (usually a single bit) with zero + will be written using ``zero_extract`` rather than the equivalent + ``and`` or ``sign_extract`` operations. + + .. index:: mult, canonicalization of + +* ``(sign_extend:m1 (mult:m2 (sign_extend:m2x) + (sign_extend:m2y)))`` is converted to ``(mult:m1 + (sign_extend:m1x) (sign_extend:m1y))``, and likewise + for ``zero_extend``. + +* ``(sign_extend:m1 (mult:m2 (ashiftrt:m2xs) (sign_extend:m2y)))`` is converted + to ``(mult:m1 (sign_extend:m1 (ashiftrt:m2xs)) (sign_extend:m1y))``, and likewise for + patterns using ``zero_extend`` and ``lshiftrt``. If the second + operand of ``mult`` is also a shift, then that is extended also. + This transformation is only applied when it can be proven that the + original operation had sufficient precision to prevent overflow. + +Further canonicalization rules are defined in the function +``commutative_operand_precedence`` in :samp:`gcc/rtlanal.cc`. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/conditional-execution.rst b/gcc/doc/gccint/machine-descriptions/conditional-execution.rst new file mode 100644 index 00000000000..5f64464be4f --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/conditional-execution.rst @@ -0,0 +1,98 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: conditional execution, predication + +.. _conditional-execution: + +Conditional Execution +********************* + +A number of architectures provide for some form of conditional +execution, or predication. The hallmark of this feature is the +ability to nullify most of the instructions in the instruction set. +When the instruction set is large and not entirely symmetric, it +can be quite tedious to describe these forms directly in the +:samp:`.md` file. An alternative is the ``define_cond_exec`` template. + +.. index:: define_cond_exec + +.. code-block:: + + (define_cond_exec + [predicate-pattern] + "condition" + "output-template" + "optional-insn-attribues") + +:samp:`{predicate-pattern}` is the condition that must be true for the +insn to be executed at runtime and should match a relational operator. +One can use ``match_operator`` to match several relational operators +at once. Any ``match_operand`` operands must have no more than one +alternative. + +:samp:`{condition}` is a C expression that must be true for the generated +pattern to match. + +.. index:: current_insn_predicate + +:samp:`{output-template}` is a string similar to the ``define_insn`` +output template (see :ref:`output-template`), except that the :samp:`*` +and :samp:`@` special cases do not apply. This is only useful if the +assembly text for the predicate is a simple prefix to the main insn. +In order to handle the general case, there is a global variable +``current_insn_predicate`` that will contain the entire predicate +if the current insn is predicated, and will otherwise be ``NULL``. + +:samp:`{optional-insn-attributes}` is an optional vector of attributes that gets +appended to the insn attributes of the produced cond_exec rtx. It can +be used to add some distinguishing attribute to cond_exec rtxs produced +that way. An example usage would be to use this attribute in conjunction +with attributes on the main pattern to disable particular alternatives under +certain conditions. + +When ``define_cond_exec`` is used, an implicit reference to +the ``predicable`` instruction attribute is made. +See :ref:`insn-attributes`. This attribute must be a boolean (i.e. have +exactly two elements in its :samp:`{list-of-values}`), with the possible +values being ``no`` and ``yes``. The default and all uses in +the insns must be a simple constant, not a complex expressions. It +may, however, depend on the alternative, by using a comma-separated +list of values. If that is the case, the port should also define an +``enabled`` attribute (see :ref:`disable-insn-alternatives`), which +should also allow only ``no`` and ``yes`` as its values. + +For each ``define_insn`` for which the ``predicable`` +attribute is true, a new ``define_insn`` pattern will be +generated that matches a predicated version of the instruction. +For example, + +.. code-block:: + + (define_insn "addsi" + [(set (match_operand:SI 0 "register_operand" "r") + (plus:SI (match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "register_operand" "r")))] + "test1" + "add %2,%1,%0") + + (define_cond_exec + [(ne (match_operand:CC 0 "register_operand" "c") + (const_int 0))] + "test2" + "(%0)") + +generates a new pattern + +.. code-block:: + + (define_insn "" + [(cond_exec + (ne (match_operand:CC 3 "register_operand" "c") (const_int 0)) + (set (match_operand:SI 0 "register_operand" "r") + (plus:SI (match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "register_operand" "r"))))] + "(test2) && (test1)" + "(%3) add %2,%1,%0") \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/constant-definitions.rst b/gcc/doc/gccint/machine-descriptions/constant-definitions.rst new file mode 100644 index 00000000000..d5db0186adf --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/constant-definitions.rst @@ -0,0 +1,185 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: constant definitions, define_constants + +.. _constant-definitions: + +Constant Definitions +******************** + +Using literal constants inside instruction patterns reduces legibility and +can be a maintenance problem. + +To overcome this problem, you may use the ``define_constants`` +expression. It contains a vector of name-value pairs. From that +point on, wherever any of the names appears in the MD file, it is as +if the corresponding value had been written instead. You may use +``define_constants`` multiple times; each appearance adds more +constants to the table. It is an error to redefine a constant with +a different value. + +To come back to the a29k load multiple example, instead of + +.. code-block:: + + (define_insn "" + [(match_parallel 0 "load_multiple_operation" + [(set (match_operand:SI 1 "gpc_reg_operand" "=r") + (match_operand:SI 2 "memory_operand" "m")) + (use (reg:SI 179)) + (clobber (reg:SI 179))])] + "" + "loadm 0,0,%1,%2") + +You could write: + +.. code-block:: + + (define_constants [ + (R_BP 177) + (R_FC 178) + (R_CR 179) + (R_Q 180) + ]) + + (define_insn "" + [(match_parallel 0 "load_multiple_operation" + [(set (match_operand:SI 1 "gpc_reg_operand" "=r") + (match_operand:SI 2 "memory_operand" "m")) + (use (reg:SI R_CR)) + (clobber (reg:SI R_CR))])] + "" + "loadm 0,0,%1,%2") + +The constants that are defined with a define_constant are also output +in the insn-codes.h header file as #defines. + +.. index:: enumerations, define_c_enum + +You can also use the machine description file to define enumerations. +Like the constants defined by ``define_constant``, these enumerations +are visible to both the machine description file and the main C code. + +The syntax is as follows: + +.. code-block:: + + (define_c_enum "name" [ + value0 + value1 + (value32 32) + value33 + ... + valuen + ]) + +This definition causes the equivalent of the following C code to appear +in :samp:`insn-constants.h`: + +.. code-block:: c++ + + enum name { + value0 = 0, + value1 = 1, + value32 = 32, + value33 = 33, + ... + valuen = n + }; + #define NUM_cname_VALUES (n + 1) + +where :samp:`{cname}` is the capitalized form of :samp:`{name}`. +It also makes each :samp:`{valuei}` available in the machine description +file, just as if it had been declared with: + +.. code-block:: + + (define_constants [(valuei i)]) + +Each :samp:`{valuei}` is usually an upper-case identifier and usually +begins with :samp:`{cname}`. + +You can split the enumeration definition into as many statements as +you like. The above example is directly equivalent to: + +.. code-block:: + + (define_c_enum "name" [value0]) + (define_c_enum "name" [value1]) + ... + (define_c_enum "name" [valuen]) + +Splitting the enumeration helps to improve the modularity of each +individual ``.md`` file. For example, if a port defines its +synchronization instructions in a separate :samp:`sync.md` file, +it is convenient to define all synchronization-specific enumeration +values in :samp:`sync.md` rather than in the main :samp:`.md` file. + +Some enumeration names have special significance to GCC: + +``unspecv`` + + .. index:: unspec_volatile + + If an enumeration called ``unspecv`` is defined, GCC will use it + when printing out ``unspec_volatile`` expressions. For example: + + .. code-block:: + + (define_c_enum "unspecv" [ + UNSPECV_BLOCKAGE + ]) + + causes GCC to print :samp:`(unspec_volatile ... 0)` as: + + .. code-block:: c++ + + (unspec_volatile ... UNSPECV_BLOCKAGE) + +``unspec`` + + .. index:: unspec + + If an enumeration called ``unspec`` is defined, GCC will use + it when printing out ``unspec`` expressions. GCC will also use + it when printing out ``unspec_volatile`` expressions unless an + ``unspecv`` enumeration is also defined. You can therefore + decide whether to keep separate enumerations for volatile and + non-volatile expressions or whether to use the same enumeration + for both. + +.. index:: define_enum + +.. _define_enum: + +Another way of defining an enumeration is to use ``define_enum`` : + +.. code-block:: + + (define_enum "name" [ + value0 + value1 + ... + valuen + ]) + +This directive implies: + +.. code-block:: + + (define_c_enum "name" [ + cname_cvalue0 + cname_cvalue1 + ... + cname_cvaluen + ]) + +.. index:: define_enum_attr + +where :samp:`{cvaluei}` is the capitalized form of :samp:`{valuei}`. +However, unlike ``define_c_enum``, the enumerations defined +by ``define_enum`` can be used in attribute specifications +(see :ref:`define_enum_attr`). \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/defining-how-to-split-instructions.rst b/gcc/doc/gccint/machine-descriptions/defining-how-to-split-instructions.rst new file mode 100644 index 00000000000..494e0e45191 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/defining-how-to-split-instructions.rst @@ -0,0 +1,374 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: insn splitting, instruction splitting, splitting instructions + +.. _insn-splitting: + +Defining How to Split Instructions +********************************** + +There are two cases where you should specify how to split a pattern +into multiple insns. On machines that have instructions requiring +delay slots (see :ref:`delay-slots`) or that have instructions whose +output is not available for multiple cycles (see :ref:`processor-pipeline-description`), the compiler phases that optimize these cases need to +be able to move insns into one-instruction delay slots. However, some +insns may generate more than one machine instruction. These insns +cannot be placed into a delay slot. + +Often you can rewrite the single insn as a list of individual insns, +each corresponding to one machine instruction. The disadvantage of +doing so is that it will cause the compilation to be slower and require +more space. If the resulting insns are too complex, it may also +suppress some optimizations. The compiler splits the insn if there is a +reason to believe that it might improve instruction or delay slot +scheduling. + +The insn combiner phase also splits putative insns. If three insns are +merged into one insn with a complex expression that cannot be matched by +some ``define_insn`` pattern, the combiner phase attempts to split +the complex pattern into two insns that are recognized. Usually it can +break the complex pattern into two patterns by splitting out some +subexpression. However, in some other cases, such as performing an +addition of a large constant in two insns on a RISC machine, the way to +split the addition into two insns is machine-dependent. + +.. index:: define_split + +The ``define_split`` definition tells the compiler how to split a +complex insn into several simpler insns. It looks like this: + +.. code-block:: + + (define_split + [insn-pattern] + "condition" + [new-insn-pattern-1 + new-insn-pattern-2 + ...] + "preparation-statements") + +:samp:`{insn-pattern}` is a pattern that needs to be split and +:samp:`{condition}` is the final condition to be tested, as in a +``define_insn``. When an insn matching :samp:`{insn-pattern}` and +satisfying :samp:`{condition}` is found, it is replaced in the insn list +with the insns given by :samp:`{new-insn-pattern-1}`, +:samp:`{new-insn-pattern-2}`, etc. + +The :samp:`{preparation-statements}` are similar to those statements that +are specified for ``define_expand`` (see :ref:`expander-definitions`) +and are executed before the new RTL is generated to prepare for the +generated code or emit some insns whose pattern is not fixed. Unlike +those in ``define_expand``, however, these statements must not +generate any new pseudo-registers. Once reload has completed, they also +must not allocate any space in the stack frame. + +There are two special macros defined for use in the preparation statements: +``DONE`` and ``FAIL``. Use them with a following semicolon, +as a statement. + +.. index:: DONE + +.. envvar:: DONE + + Use the ``DONE`` macro to end RTL generation for the splitter. The + only RTL insns generated as replacement for the matched input insn will + be those already emitted by explicit calls to ``emit_insn`` within + the preparation statements; the replacement pattern is not used. + +.. envvar:: FAIL + + Make the ``define_split`` fail on this occasion. When a ``define_split`` + fails, it means that the splitter was not truly available for the inputs + it was given, and the input insn will not be split. + +If the preparation falls through (invokes neither ``DONE`` nor +``FAIL``), then the ``define_split`` uses the replacement +template. + +Patterns are matched against :samp:`{insn-pattern}` in two different +circumstances. If an insn needs to be split for delay slot scheduling +or insn scheduling, the insn is already known to be valid, which means +that it must have been matched by some ``define_insn`` and, if +``reload_completed`` is nonzero, is known to satisfy the constraints +of that ``define_insn``. In that case, the new insn patterns must +also be insns that are matched by some ``define_insn`` and, if +``reload_completed`` is nonzero, must also satisfy the constraints +of those definitions. + +As an example of this usage of ``define_split``, consider the following +example from :samp:`a29k.md`, which splits a ``sign_extend`` from +``HImode`` to ``SImode`` into a pair of shift insns: + +.. code-block:: + + (define_split + [(set (match_operand:SI 0 "gen_reg_operand" "") + (sign_extend:SI (match_operand:HI 1 "gen_reg_operand" "")))] + "" + [(set (match_dup 0) + (ashift:SI (match_dup 1) + (const_int 16))) + (set (match_dup 0) + (ashiftrt:SI (match_dup 0) + (const_int 16)))] + " + { operands[1] = gen_lowpart (SImode, operands[1]); }") + +When the combiner phase tries to split an insn pattern, it is always the +case that the pattern is *not* matched by any ``define_insn``. +The combiner pass first tries to split a single ``set`` expression +and then the same ``set`` expression inside a ``parallel``, but +followed by a ``clobber`` of a pseudo-reg to use as a scratch +register. In these cases, the combiner expects exactly one or two new insn +patterns to be generated. It will verify that these patterns match some +``define_insn`` definitions, so you need not do this test in the +``define_split`` (of course, there is no point in writing a +``define_split`` that will never produce insns that match). + +Here is an example of this use of ``define_split``, taken from +:samp:`rs6000.md`: + +.. code-block:: + + (define_split + [(set (match_operand:SI 0 "gen_reg_operand" "") + (plus:SI (match_operand:SI 1 "gen_reg_operand" "") + (match_operand:SI 2 "non_add_cint_operand" "")))] + "" + [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3))) + (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))] + " + { + int low = INTVAL (operands[2]) & 0xffff; + int high = (unsigned) INTVAL (operands[2]) >> 16; + + if (low & 0x8000) + high++, low |= 0xffff0000; + + operands[3] = GEN_INT (high << 16); + operands[4] = GEN_INT (low); + }") + +Here the predicate ``non_add_cint_operand`` matches any +``const_int`` that is *not* a valid operand of a single add +insn. The add with the smaller displacement is written so that it +can be substituted into the address of a subsequent operation. + +An example that uses a scratch register, from the same file, generates +an equality comparison of a register and a large constant: + +.. code-block:: + + (define_split + [(set (match_operand:CC 0 "cc_reg_operand" "") + (compare:CC (match_operand:SI 1 "gen_reg_operand" "") + (match_operand:SI 2 "non_short_cint_operand" ""))) + (clobber (match_operand:SI 3 "gen_reg_operand" ""))] + "find_single_use (operands[0], insn, 0) + && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ + || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)" + [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4))) + (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))] + " + { + /* Get the constant we are comparing against, C, and see what it + looks like sign-extended to 16 bits. Then see what constant + could be XOR'ed with C to get the sign-extended value. */ + + int c = INTVAL (operands[2]); + int sextc = (c << 16) >> 16; + int xorv = c ^ sextc; + + operands[4] = GEN_INT (xorv); + operands[5] = GEN_INT (sextc); + }") + +To avoid confusion, don't write a single ``define_split`` that +accepts some insns that match some ``define_insn`` as well as some +insns that don't. Instead, write two separate ``define_split`` +definitions, one for the insns that are valid and one for the insns that +are not valid. + +The splitter is allowed to split jump instructions into sequence of +jumps or create new jumps in while splitting non-jump instructions. As +the control flow graph and branch prediction information needs to be updated, +several restriction apply. + +Splitting of jump instruction into sequence that over by another jump +instruction is always valid, as compiler expect identical behavior of new +jump. When new sequence contains multiple jump instructions or new labels, +more assistance is needed. Splitter is required to create only unconditional +jumps, or simple conditional jump instructions. Additionally it must attach a +``REG_BR_PROB`` note to each conditional jump. A global variable +``split_branch_probability`` holds the probability of the original branch in case +it was a simple conditional jump, -1 otherwise. To simplify +recomputing of edge frequencies, the new sequence is required to have only +forward jumps to the newly created labels. + +.. index:: define_insn_and_split + +For the common case where the pattern of a define_split exactly matches the +pattern of a define_insn, use ``define_insn_and_split``. It looks like +this: + +.. code-block:: + + (define_insn_and_split + [insn-pattern] + "condition" + "output-template" + "split-condition" + [new-insn-pattern-1 + new-insn-pattern-2 + ...] + "preparation-statements" + [insn-attributes]) + +:samp:`{insn-pattern}`, :samp:`{condition}`, :samp:`{output-template}`, and +:samp:`{insn-attributes}` are used as in ``define_insn``. The +:samp:`{new-insn-pattern}` vector and the :samp:`{preparation-statements}` are used as +in a ``define_split``. The :samp:`{split-condition}` is also used as in +``define_split``, with the additional behavior that if the condition starts +with :samp:`&&`, the condition used for the split will be the constructed as a +logical 'and' of the split condition with the insn condition. For example, +from i386.md: + +.. code-block:: + + (define_insn_and_split "zero_extendhisi2_and" + [(set (match_operand:SI 0 "register_operand" "=r") + (zero_extend:SI (match_operand:HI 1 "register_operand" "0"))) + (clobber (reg:CC 17))] + "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size" + "#" + "&& reload_completed" + [(parallel [(set (match_dup 0) + (and:SI (match_dup 0) (const_int 65535))) + (clobber (reg:CC 17))])] + "" + [(set_attr "type" "alu1")]) + +In this case, the actual split condition will be +:samp:`TARGET_ZERO_EXTEND_WITH_AND && !optimize_size && reload_completed`. + +The ``define_insn_and_split`` construction provides exactly the same +functionality as two separate ``define_insn`` and ``define_split`` +patterns. It exists for compactness, and as a maintenance tool to prevent +having to ensure the two patterns' templates match. + +.. index:: define_insn_and_rewrite + +It is sometimes useful to have a ``define_insn_and_split`` +that replaces specific operands of an instruction but leaves the +rest of the instruction pattern unchanged. You can do this directly +with a ``define_insn_and_split``, but it requires a +:samp:`{new-insn-pattern-1}` that repeats most of the original :samp:`{insn-pattern}`. +There is also the complication that an implicit ``parallel`` in +:samp:`{insn-pattern}` must become an explicit ``parallel`` in +:samp:`{new-insn-pattern-1}`, which is easy to overlook. +A simpler alternative is to use ``define_insn_and_rewrite``, which +is a form of ``define_insn_and_split`` that automatically generates +:samp:`{new-insn-pattern-1}` by replacing each ``match_operand`` +in :samp:`{insn-pattern}` with a corresponding ``match_dup``, and each +``match_operator`` in the pattern with a corresponding ``match_op_dup``. +The arguments are otherwise identical to ``define_insn_and_split`` : + +.. code-block:: + + (define_insn_and_rewrite + [insn-pattern] + "condition" + "output-template" + "split-condition" + "preparation-statements" + [insn-attributes]) + +The ``match_dup`` s and ``match_op_dup`` s in the new +instruction pattern use any new operand values that the +:samp:`{preparation-statements}` store in the ``operands`` array, +as for a normal ``define_insn_and_split``. :samp:`{preparation-statements}` +can also emit additional instructions before the new instruction. +They can even emit an entirely different sequence of instructions and +use ``DONE`` to avoid emitting a new form of the original +instruction. + +The split in a ``define_insn_and_rewrite`` is only intended +to apply to existing instructions that match :samp:`{insn-pattern}`. +:samp:`{split-condition}` must therefore start with ``&&``, +so that the split condition applies on top of :samp:`{condition}`. + +Here is an example from the AArch64 SVE port, in which operand 1 is +known to be equivalent to an all-true constant and isn't used by the +output template: + +.. code-block:: + + (define_insn_and_rewrite "*while_ult_cc" + [(set (reg:CC CC_REGNUM) + (compare:CC + (unspec:SI [(match_operand:PRED_ALL 1) + (unspec:PRED_ALL + [(match_operand:GPI 2 "aarch64_reg_or_zero" "rZ") + (match_operand:GPI 3 "aarch64_reg_or_zero" "rZ")] + UNSPEC_WHILE_LO)] + UNSPEC_PTEST_PTRUE) + (const_int 0))) + (set (match_operand:PRED_ALL 0 "register_operand" "=Upa") + (unspec:PRED_ALL [(match_dup 2) + (match_dup 3)] + UNSPEC_WHILE_LO))] + "TARGET_SVE" + "whilelo\t%0., %2, %3" + ;; Force the compiler to drop the unused predicate operand, so that we + ;; don't have an unnecessary PTRUE. + "&& !CONSTANT_P (operands[1])" + { + operands[1] = CONSTM1_RTX (mode); + } + ) + +The splitter in this case simply replaces operand 1 with the constant +value that it is known to have. The equivalent ``define_insn_and_split`` +would be: + +.. code-block:: + + (define_insn_and_split "*while_ult_cc" + [(set (reg:CC CC_REGNUM) + (compare:CC + (unspec:SI [(match_operand:PRED_ALL 1) + (unspec:PRED_ALL + [(match_operand:GPI 2 "aarch64_reg_or_zero" "rZ") + (match_operand:GPI 3 "aarch64_reg_or_zero" "rZ")] + UNSPEC_WHILE_LO)] + UNSPEC_PTEST_PTRUE) + (const_int 0))) + (set (match_operand:PRED_ALL 0 "register_operand" "=Upa") + (unspec:PRED_ALL [(match_dup 2) + (match_dup 3)] + UNSPEC_WHILE_LO))] + "TARGET_SVE" + "whilelo\t%0., %2, %3" + ;; Force the compiler to drop the unused predicate operand, so that we + ;; don't have an unnecessary PTRUE. + "&& !CONSTANT_P (operands[1])" + [(parallel + [(set (reg:CC CC_REGNUM) + (compare:CC + (unspec:SI [(match_dup 1) + (unspec:PRED_ALL [(match_dup 2) + (match_dup 3)] + UNSPEC_WHILE_LO)] + UNSPEC_PTEST_PTRUE) + (const_int 0))) + (set (match_dup 0) + (unspec:PRED_ALL [(match_dup 2) + (match_dup 3)] + UNSPEC_WHILE_LO))])] + { + operands[1] = CONSTM1_RTX (mode); + } + ) \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/defining-jump-instruction-patterns.rst b/gcc/doc/gccint/machine-descriptions/defining-jump-instruction-patterns.rst new file mode 100644 index 00000000000..5fa645bde71 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/defining-jump-instruction-patterns.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: jump instruction patterns, defining jump instruction patterns + +.. _jump-patterns: + +Defining Jump Instruction Patterns +********************************** + +GCC does not assume anything about how the machine realizes jumps. +The machine description should define a single pattern, usually +a ``define_expand``, which expands to all the required insns. + +Usually, this would be a comparison insn to set the condition code +and a separate branch insn testing the condition code and branching +or not according to its value. For many machines, however, +separating compares and branches is limiting, which is why the +more flexible approach with one ``define_expand`` is used in GCC. +The machine description becomes clearer for architectures that +have compare-and-branch instructions but no condition code. It also +works better when different sets of comparison operators are supported +by different kinds of conditional branches (e.g. integer vs. +floating-point), or by conditional branches with respect to conditional stores. + +Two separate insns are always used on most machines that use a separate +condition code register (see :ref:`condition-code`). + +Even in this case having a single entry point for conditional branches +is advantageous, because it handles equally well the case where a single +comparison instruction records the results of both signed and unsigned +comparison of the given operands (with the branch insns coming in distinct +signed and unsigned flavors) as in the x86 or SPARC, and the case where +there are distinct signed and unsigned compare instructions and only +one set of conditional branch instructions as in the PowerPC. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/defining-looping-instruction-patterns.rst b/gcc/doc/gccint/machine-descriptions/defining-looping-instruction-patterns.rst new file mode 100644 index 00000000000..214bd34c99e --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/defining-looping-instruction-patterns.rst @@ -0,0 +1,134 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: looping instruction patterns, defining looping instruction patterns + +.. _looping-patterns: + +Defining Looping Instruction Patterns +************************************* + +Some machines have special jump instructions that can be utilized to +make loops more efficient. A common example is the 68000 :samp:`dbra` +instruction which performs a decrement of a register and a branch if the +result was greater than zero. Other machines, in particular digital +signal processors (DSPs), have special block repeat instructions to +provide low-overhead loop support. For example, the TI TMS320C3x/C4x +DSPs have a block repeat instruction that loads special registers to +mark the top and end of a loop and to count the number of loop +iterations. This avoids the need for fetching and executing a +:samp:`dbra`-like instruction and avoids pipeline stalls associated with +the jump. + +GCC has two special named patterns to support low overhead looping. +They are :samp:`doloop_begin` and :samp:`doloop_end`. These are emitted +by the loop optimizer for certain well-behaved loops with a finite +number of loop iterations using information collected during strength +reduction. + +The :samp:`doloop_end` pattern describes the actual looping instruction +(or the implicit looping operation) and the :samp:`doloop_begin` pattern +is an optional companion pattern that can be used for initialization +needed for some low-overhead looping instructions. + +Note that some machines require the actual looping instruction to be +emitted at the top of the loop (e.g., the TMS320C3x/C4x DSPs). Emitting +the true RTL for a looping instruction at the top of the loop can cause +problems with flow analysis. So instead, a dummy ``doloop`` insn is +emitted at the end of the loop. The machine dependent reorg pass checks +for the presence of this ``doloop`` insn and then searches back to +the top of the loop, where it inserts the true looping insn (provided +there are no instructions in the loop which would cause problems). Any +additional labels can be emitted at this point. In addition, if the +desired special iteration counter register was not allocated, this +machine dependent reorg pass could emit a traditional compare and jump +instruction pair. + +For the :samp:`doloop_end` pattern, the loop optimizer allocates an +additional pseudo register as an iteration counter. This pseudo +register cannot be used within the loop (i.e., general induction +variables cannot be derived from it), however, in many cases the loop +induction variable may become redundant and removed by the flow pass. + +The :samp:`doloop_end` pattern must have a specific structure to be +handled correctly by GCC. The example below is taken (slightly +simplified) from the PDP-11 target: + +.. code-block:: + + (define_expand "doloop_end" + [(parallel [(set (pc) + (if_then_else + (ne (match_operand:HI 0 "nonimmediate_operand" "+r,!m") + (const_int 1)) + (label_ref (match_operand 1 "" "")) + (pc))) + (set (match_dup 0) + (plus:HI (match_dup 0) + (const_int -1)))])] + "" + "{ + if (GET_MODE (operands[0]) != HImode) + FAIL; + }") + + (define_insn "doloop_end_insn" + [(set (pc) + (if_then_else + (ne (match_operand:HI 0 "nonimmediate_operand" "+r,!m") + (const_int 1)) + (label_ref (match_operand 1 "" "")) + (pc))) + (set (match_dup 0) + (plus:HI (match_dup 0) + (const_int -1)))] + "" + + { + if (which_alternative == 0) + return "sob %0,%l1"; + + /* emulate sob */ + output_asm_insn ("dec %0", operands); + return "bne %l1"; + }) + +The first part of the pattern describes the branch condition. GCC +supports three cases for the way the target machine handles the loop +counter: + +* Loop terminates when the loop register decrements to zero. This + is represented by a ``ne`` comparison of the register (its old value) + with constant 1 (as in the example above). + +* Loop terminates when the loop register decrements to -1. + This is represented by a ``ne`` comparison of the register with + constant zero. + +* Loop terminates when the loop register decrements to a negative + value. This is represented by a ``ge`` comparison of the register + with constant zero. For this case, GCC will attach a ``REG_NONNEG`` + note to the ``doloop_end`` insn if it can determine that the register + will be non-negative. + +Since the ``doloop_end`` insn is a jump insn that also has an output, +the reload pass does not handle the output operand. Therefore, the +constraint must allow for that operand to be in memory rather than a +register. In the example shown above, that is handled (in the +``doloop_end_insn`` pattern) by using a loop instruction sequence +that can handle memory operands when the memory alternative appears. + +GCC does not check the mode of the loop register operand when generating +the ``doloop_end`` pattern. If the pattern is only valid for some +modes but not others, the pattern should be a ``define_expand`` +pattern that checks the operand mode in the preparation code, and issues +``FAIL`` if an unsupported mode is found. The example above does +this, since the machine instruction to be used only exists for +``HImode``. + +If the ``doloop_end`` pattern is a ``define_expand``, there must +also be a ``define_insn`` or ``define_insn_and_split`` matching +the generated pattern. Otherwise, the compiler will fail during loop +optimization. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/defining-rtl-sequences-for-code-generation.rst b/gcc/doc/gccint/machine-descriptions/defining-rtl-sequences-for-code-generation.rst new file mode 100644 index 00000000000..3f2447fba5b --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/defining-rtl-sequences-for-code-generation.rst @@ -0,0 +1,206 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: expander definitions, code generation RTL sequences, defining RTL sequences for code generation + +.. _expander-definitions: + +Defining RTL Sequences for Code Generation +****************************************** + +On some target machines, some standard pattern names for RTL generation +cannot be handled with single insn, but a sequence of RTL insns can +represent them. For these target machines, you can write a +``define_expand`` to specify how to generate the sequence of RTL. + +.. index:: define_expand + +A ``define_expand`` is an RTL expression that looks almost like a +``define_insn`` ; but, unlike the latter, a ``define_expand`` is used +only for RTL generation and it can produce more than one RTL insn. + +A ``define_expand`` RTX has four operands: + +* The name. Each ``define_expand`` must have a name, since the only + use for it is to refer to it by name. + +* The RTL template. This is a vector of RTL expressions representing + a sequence of separate instructions. Unlike ``define_insn``, there + is no implicit surrounding ``PARALLEL``. + +* The condition, a string containing a C expression. This expression is + used to express how the availability of this pattern depends on + subclasses of target machine, selected by command-line options when GCC + is run. This is just like the condition of a ``define_insn`` that + has a standard name. Therefore, the condition (if present) may not + depend on the data in the insn being matched, but only the + target-machine-type flags. The compiler needs to test these conditions + during initialization in order to learn exactly which named instructions + are available in a particular run. + +* The preparation statements, a string containing zero or more C + statements which are to be executed before RTL code is generated from + the RTL template. + + Usually these statements prepare temporary registers for use as + internal operands in the RTL template, but they can also generate RTL + insns directly by calling routines such as ``emit_insn``, etc. + Any such insns precede the ones that come from the RTL template. + +* Optionally, a vector containing the values of attributes. See :ref:`insn-attributes`. + +Every RTL insn emitted by a ``define_expand`` must match some +``define_insn`` in the machine description. Otherwise, the compiler +will crash when trying to generate code for the insn or trying to optimize +it. + +The RTL template, in addition to controlling generation of RTL insns, +also describes the operands that need to be specified when this pattern +is used. In particular, it gives a predicate for each operand. + +A true operand, which needs to be specified in order to generate RTL from +the pattern, should be described with a ``match_operand`` in its first +occurrence in the RTL template. This enters information on the operand's +predicate into the tables that record such things. GCC uses the +information to preload the operand into a register if that is required for +valid RTL code. If the operand is referred to more than once, subsequent +references should use ``match_dup``. + +The RTL template may also refer to internal 'operands' which are +temporary registers or labels used only within the sequence made by the +``define_expand``. Internal operands are substituted into the RTL +template with ``match_dup``, never with ``match_operand``. The +values of the internal operands are not passed in as arguments by the +compiler when it requests use of this pattern. Instead, they are computed +within the pattern, in the preparation statements. These statements +compute the values and store them into the appropriate elements of +``operands`` so that ``match_dup`` can find them. + +There are two special macros defined for use in the preparation statements: +``DONE`` and ``FAIL``. Use them with a following semicolon, +as a statement. + +.. index:: DONE + +.. envvar:: DONE + + Use the ``DONE`` macro to end RTL generation for the pattern. The + only RTL insns resulting from the pattern on this occasion will be + those already emitted by explicit calls to ``emit_insn`` within the + preparation statements; the RTL template will not be generated. + +.. envvar:: FAIL + + Make the pattern fail on this occasion. When a pattern fails, it means + that the pattern was not truly available. The calling routines in the + compiler will try other strategies for code generation using other patterns. + + Failure is currently supported only for binary (addition, multiplication, + shifting, etc.) and bit-field (``extv``, ``extzv``, and ``insv``) + operations. + +If the preparation falls through (invokes neither ``DONE`` nor +``FAIL``), then the ``define_expand`` acts like a +``define_insn`` in that the RTL template is used to generate the +insn. + +The RTL template is not used for matching, only for generating the +initial insn list. If the preparation statement always invokes +``DONE`` or ``FAIL``, the RTL template may be reduced to a simple +list of operands, such as this example: + +.. code-block:: + + (define_expand "addsi3" + [(match_operand:SI 0 "register_operand" "") + (match_operand:SI 1 "register_operand" "") + (match_operand:SI 2 "register_operand" "")] + "" + " + { + handle_add (operands[0], operands[1], operands[2]); + DONE; + }") + +Here is an example, the definition of left-shift for the SPUR chip: + +.. code-block:: + + (define_expand "ashlsi3" + [(set (match_operand:SI 0 "register_operand" "") + (ashift:SI + (match_operand:SI 1 "register_operand" "") + (match_operand:SI 2 "nonmemory_operand" "")))] + "" + " + { + if (GET_CODE (operands[2]) != CONST_INT + || (unsigned) INTVAL (operands[2]) > 3) + FAIL; + }") + +This example uses ``define_expand`` so that it can generate an RTL insn +for shifting when the shift-count is in the supported range of 0 to 3 but +fail in other cases where machine insns aren't available. When it fails, +the compiler tries another strategy using different patterns (such as, a +library call). + +If the compiler were able to handle nontrivial condition-strings in +patterns with names, then it would be possible to use a +``define_insn`` in that case. Here is another case (zero-extension +on the 68000) which makes more use of the power of ``define_expand`` : + +.. code-block:: + + (define_expand "zero_extendhisi2" + [(set (match_operand:SI 0 "general_operand" "") + (const_int 0)) + (set (strict_low_part + (subreg:HI + (match_dup 0) + 0)) + (match_operand:HI 1 "general_operand" ""))] + "" + "operands[1] = make_safe_from (operands[1], operands[0]);") + +.. index:: make_safe_from + +Here two RTL insns are generated, one to clear the entire output operand +and the other to copy the input operand into its low half. This sequence +is incorrect if the input operand refers to [the old value of] the output +operand, so the preparation statement makes sure this isn't so. The +function ``make_safe_from`` copies the ``operands[1]`` into a +temporary register if it refers to ``operands[0]``. It does this +by emitting another RTL insn. + +Finally, a third example shows the use of an internal operand. +Zero-extension on the SPUR chip is done by ``and`` -ing the result +against a halfword mask. But this mask cannot be represented by a +``const_int`` because the constant value is too large to be legitimate +on this machine. So it must be copied into a register with +``force_reg`` and then the register used in the ``and``. + +.. code-block:: + + (define_expand "zero_extendhisi2" + [(set (match_operand:SI 0 "register_operand" "") + (and:SI (subreg:SI + (match_operand:HI 1 "register_operand" "") + 0) + (match_dup 2)))] + "" + "operands[2] + = force_reg (SImode, GEN_INT (65535)); ") + +.. note:: + + If the ``define_expand`` is used to serve a + standard binary or unary arithmetic operation or a bit-field operation, + then the last insn it generates must not be a ``code_label``, + ``barrier`` or ``note``. It must be an ``insn``, + ``jump_insn`` or ``call_insn``. If you don't need a real insn + at the end, emit an insn to copy the result of the operation into + itself. Such an insn will generate no code, but it can avoid problems + in the compiler. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/everything-about-instruction-patterns.rst b/gcc/doc/gccint/machine-descriptions/everything-about-instruction-patterns.rst new file mode 100644 index 00000000000..6ca81fb0964 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/everything-about-instruction-patterns.rst @@ -0,0 +1,106 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: patterns, instruction patterns, define_insn + +.. _patterns: + +Everything about Instruction Patterns +************************************* + +A ``define_insn`` expression is used to define instruction patterns +to which insns may be matched. A ``define_insn`` expression contains +an incomplete RTL expression, with pieces to be filled in later, operand +constraints that restrict how the pieces can be filled in, and an output +template or C code to generate the assembler output. + +A ``define_insn`` is an RTL expression containing four or five operands: + +* An optional name :samp:`{n}`. When a name is present, the compiler + automically generates a C++ function :samp:`gen_{n}` that takes + the operands of the instruction as arguments and returns the instruction's + rtx pattern. The compiler also assigns the instruction a unique code + :samp:`CODE_FOR_{n}`, with all such codes belonging to an enum + called ``insn_code``. + + These names serve one of two purposes. The first is to indicate that the + instruction performs a certain standard job for the RTL-generation + pass of the compiler, such as a move, an addition, or a conditional + jump. The second is to help the target generate certain target-specific + operations, such as when implementing target-specific intrinsic functions. + + It is better to prefix target-specific names with the name of the + target, to avoid any clash with current or future standard names. + + The absence of a name is indicated by writing an empty string + where the name should go. Nameless instruction patterns are never + used for generating RTL code, but they may permit several simpler insns + to be combined later on. + + For the purpose of debugging the compiler, you may also specify a + name beginning with the :samp:`*` character. Such a name is used only + for identifying the instruction in RTL dumps; it is equivalent to having + a nameless pattern for all other purposes. Names beginning with the + :samp:`*` character are not required to be unique. + + The name may also have the form :samp:`@{n}`. This has the same + effect as a name :samp:`{n}`, but in addition tells the compiler to + generate further helper functions; see :ref:`parameterized-names` for details. + +* The :dfn:`RTL template`: This is a vector of incomplete RTL expressions + which describe the semantics of the instruction (see :ref:`rtl-template`). + It is incomplete because it may contain ``match_operand``, + ``match_operator``, and ``match_dup`` expressions that stand for + operands of the instruction. + + If the vector has multiple elements, the RTL template is treated as a + ``parallel`` expression. + +.. index:: pattern conditions, conditions, in patterns + +* The condition: This is a string which contains a C expression. When the + compiler attempts to match RTL against a pattern, the condition is + evaluated. If the condition evaluates to ``true``, the match is + permitted. The condition may be an empty string, which is treated + as always ``true``. + + .. index:: named patterns and conditions + + For a named pattern, the condition may not depend on the data in the + insn being matched, but only the target-machine-type flags. The compiler + needs to test these conditions during initialization in order to learn + exactly which named instructions are available in a particular run. + + .. index:: operands + + For nameless patterns, the condition is applied only when matching an + individual insn, and only after the insn has matched the pattern's + recognition template. The insn's operands may be found in the vector + ``operands``. + + An instruction condition cannot become more restrictive as compilation + progresses. If the condition accepts a particular RTL instruction at + one stage of compilation, it must continue to accept that instruction + until the final pass. For example, :samp:`!reload_completed` and + :samp:`can_create_pseudo_p ()` are both invalid instruction conditions, + because they are true during the earlier RTL passes and false during + the later ones. For the same reason, if a condition accepts an + instruction before register allocation, it cannot later try to control + register allocation by excluding certain register or value combinations. + + Although a condition cannot become more restrictive as compilation + progresses, the condition for a nameless pattern *can* become + more permissive. For example, a nameless instruction can require + :samp:`reload_completed` to be true, in which case it only matches + after register allocation. + +* The :dfn:`output template` or :dfn:`output statement`: This is either + a string, or a fragment of C code which returns a string. + + When simple substitution isn't general enough, you can specify a piece + of C code to compute the output. See :ref:`output-statement`. + +* The :dfn:`insn attributes`: This is an optional vector containing the values of + attributes for insns matching this pattern (see :ref:`insn-attributes`). \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/example-of-defineinsn.rst b/gcc/doc/gccint/machine-descriptions/example-of-defineinsn.rst new file mode 100644 index 00000000000..9af89e99b73 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/example-of-defineinsn.rst @@ -0,0 +1,54 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: define_insn example + +.. _example: + +Example of define_insn +********************** + +Here is an example of an instruction pattern, taken from the machine +description for the 68000/68020. + +.. code-block:: + + (define_insn "tstsi" + [(set (cc0) + (match_operand:SI 0 "general_operand" "rm"))] + "" + "* + { + if (TARGET_68020 || ! ADDRESS_REG_P (operands[0])) + return \"tstl %0\"; + return \"cmpl #0,%0\"; + }") + +This can also be written using braced strings: + +.. code-block:: + + (define_insn "tstsi" + [(set (cc0) + (match_operand:SI 0 "general_operand" "rm"))] + "" + { + if (TARGET_68020 || ! ADDRESS_REG_P (operands[0])) + return "tstl %0"; + return "cmpl #0,%0"; + }) + +This describes an instruction which sets the condition codes based on the +value of a general operand. It has no condition, so any insn with an RTL +description of the form shown may be matched to this pattern. The name +:samp:`tstsi` means 'test a ``SImode`` value' and tells the RTL +generation pass that, when it is necessary to test such a value, an insn +to do so can be constructed using this pattern. + +The output control string is a piece of C code which chooses which +output template to return based on the kind of operand and the specific +type of CPU for which code is being generated. + +:samp:`"rm"` is an operand constraint. Its meaning is explained below. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/including-patterns-in-machine-descriptions.rst b/gcc/doc/gccint/machine-descriptions/including-patterns-in-machine-descriptions.rst new file mode 100644 index 00000000000..349369401f5 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/including-patterns-in-machine-descriptions.rst @@ -0,0 +1,70 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: insn includes, include + +.. _including-patterns: + +Including Patterns in Machine Descriptions. +******************************************* + +The ``include`` pattern tells the compiler tools where to +look for patterns that are in files other than in the file +:samp:`.md`. This is used only at build time and there is no preprocessing allowed. + +It looks like: + +.. code-block:: c++ + + (include + pathname) + +For example: + +.. code-block:: c++ + + (include "filestuff") + +Where :samp:`{pathname}` is a string that specifies the location of the file, +specifies the include file to be in :samp:`gcc/config/target/filestuff`. The +directory :samp:`gcc/config/target` is regarded as the default directory. + +Machine descriptions may be split up into smaller more manageable subsections +and placed into subdirectories. + +By specifying: + +.. code-block:: c++ + + (include "BOGUS/filestuff") + +the include file is specified to be in :samp:`gcc/config/{target}/BOGUS/filestuff`. + +Specifying an absolute path for the include file such as; + +.. code-block:: c++ + + (include "/u2/BOGUS/filestuff") + +is permitted but is not encouraged. + +.. index:: directory options .md, options, directory search, search options + +RTL Generation Tool Options for Directory Search +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The :option:`-Idir` option specifies directories to search for machine descriptions. +For example: + +.. code-block:: c++ + + genrecog -I/p1/abc/proc1 -I/p2/abcd/pro2 target.md + +Add the directory :samp:`{dir}` to the head of the list of directories to be +searched for header files. This can be used to override a system machine definition +file, substituting your own version, since these directories are +searched before the default machine description file directories. If you use more than +one :option:`-I` option, the directories are scanned in left-to-right +order; the standard default directory come after. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/instruction-attributes.rst b/gcc/doc/gccint/machine-descriptions/instruction-attributes.rst new file mode 100644 index 00000000000..72c65f7b413 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/instruction-attributes.rst @@ -0,0 +1,1248 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: insn attributes, instruction attributes + +.. _insn-attributes: + +Instruction Attributes +********************** + +In addition to describing the instruction supported by the target machine, +the :samp:`md` file also defines a group of :dfn:`attributes` and a set of +values for each. Every generated insn is assigned a value for each attribute. +One possible attribute would be the effect that the insn has on the machine's +condition code. + +.. toctree:: + :maxdepth: 2 + + +.. index:: defining attributes and their values, attributes, defining, define_attr + +.. _defining-attributes: + +Defining Attributes and their Values +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The ``define_attr`` expression is used to define each attribute required +by the target machine. It looks like: + +.. code-block:: + + (define_attr name list-of-values default) + +:samp:`{name}` is a string specifying the name of the attribute being +defined. Some attributes are used in a special way by the rest of the +compiler. The ``enabled`` attribute can be used to conditionally +enable or disable insn alternatives (see :ref:`disable-insn-alternatives`). The ``predicable`` attribute, together with a +suitable ``define_cond_exec`` (see :ref:`conditional-execution`), can +be used to automatically generate conditional variants of instruction +patterns. The ``mnemonic`` attribute can be used to check for the +instruction mnemonic (see :ref:`mnemonic-attribute`). The compiler +internally uses the names ``ce_enabled`` and ``nonce_enabled``, +so they should not be used elsewhere as alternative names. + +:samp:`{list-of-values}` is either a string that specifies a comma-separated +list of values that can be assigned to the attribute, or a null string to +indicate that the attribute takes numeric values. + +:samp:`{default}` is an attribute expression that gives the value of this +attribute for insns that match patterns whose definition does not include +an explicit value for this attribute. See :ref:`attr-example`, for more +information on the handling of defaults. See :ref:`constant-attributes`, +for information on attributes that do not depend on any particular insn. + +.. index:: insn-attr.h + +For each defined attribute, a number of definitions are written to the +:samp:`insn-attr.h` file. For cases where an explicit set of values is +specified for an attribute, the following are defined: + +* A :samp:`#define` is written for the symbol :samp:`HAVE_ATTR_{name}`. + +* An enumerated class is defined for :samp:`attr_{name}` with + elements of the form :samp:`{upper-name}_{upper-value}` where + the attribute name and value are first converted to uppercase. + +* A function :samp:`get_attr_{name}` is defined that is passed an insn and + returns the attribute value for that insn. + +For example, if the following is present in the :samp:`md` file: + +.. code-block:: + + (define_attr "type" "branch,fp,load,store,arith" ...) + +the following lines will be written to the file :samp:`insn-attr.h`. + +.. code-block:: c++ + + #define HAVE_ATTR_type 1 + enum attr_type {TYPE_BRANCH, TYPE_FP, TYPE_LOAD, + TYPE_STORE, TYPE_ARITH}; + extern enum attr_type get_attr_type (); + +If the attribute takes numeric values, no ``enum`` type will be +defined and the function to obtain the attribute's value will return +``int``. + +There are attributes which are tied to a specific meaning. These +attributes are not free to use for other purposes: + +``length`` + The ``length`` attribute is used to calculate the length of emitted + code chunks. This is especially important when verifying branch + distances. See :ref:`insn-lengths`. + +``enabled`` + The ``enabled`` attribute can be defined to prevent certain + alternatives of an insn definition from being used during code + generation. See :ref:`disable-insn-alternatives`. + +``mnemonic`` + The ``mnemonic`` attribute can be defined to implement instruction + specific checks in e.g. the pipeline description. + See :ref:`mnemonic-attribute`. + +For each of these special attributes, the corresponding +:samp:`HAVE_ATTR_{name}` :samp:`#define` is also written when the +attribute is not defined; in that case, it is defined as :samp:`0`. + +.. index:: define_enum_attr + +.. _define_enum_attr: + +Another way of defining an attribute is to use: + +.. code-block:: + + (define_enum_attr "attr" "enum" default) + +This works in just the same way as ``define_attr``, except that +the list of values is taken from a separate enumeration called +:samp:`{enum}` (see :ref:`define_enum`). This form allows you to use +the same list of values for several attributes without having to +repeat the list each time. For example: + +.. code-block:: + + (define_enum "processor" [ + model_a + model_b + ... + ]) + (define_enum_attr "arch" "processor" + (const (symbol_ref "target_arch"))) + (define_enum_attr "tune" "processor" + (const (symbol_ref "target_tune"))) + +defines the same attributes as: + +.. code-block:: + + (define_attr "arch" "model_a,model_b,..." + (const (symbol_ref "target_arch"))) + (define_attr "tune" "model_a,model_b,..." + (const (symbol_ref "target_tune"))) + +but without duplicating the processor list. The second example defines two +separate C enums (``attr_arch`` and ``attr_tune``) whereas the first +defines a single C enum (``processor``). + +.. index:: attribute expressions + +.. _expressions: + +Attribute Expressions +^^^^^^^^^^^^^^^^^^^^^ + +RTL expressions used to define attributes use the codes described above +plus a few specific to attribute definitions, to be discussed below. +Attribute value expressions must have one of the following forms: + +.. index:: const_int and attributes + +:samp:`(const_int {i})` + The integer :samp:`{i}` specifies the value of a numeric attribute. :samp:`{i}` + must be non-negative. + + The value of a numeric attribute can be specified either with a + ``const_int``, or as an integer represented as a string in + ``const_string``, ``eq_attr`` (see below), ``attr``, + ``symbol_ref``, simple arithmetic expressions, and ``set_attr`` + overrides on specific instructions (see :ref:`tagging-insns`). + + .. index:: const_string and attributes + +:samp:`(const_string {value})` + The string :samp:`{value}` specifies a constant attribute value. + If :samp:`{value}` is specified as :samp:`"*"`, it means that the default value of + the attribute is to be used for the insn containing this expression. + :samp:`"*"` obviously cannot be used in the :samp:`{default}` expression + of a ``define_attr``. + + If the attribute whose value is being specified is numeric, :samp:`{value}` + must be a string containing a non-negative integer (normally + ``const_int`` would be used in this case). Otherwise, it must + contain one of the valid values for the attribute. + + .. index:: if_then_else and attributes + +:samp:`(if_then_else {test} {true-value} {false-value})` + :samp:`{test}` specifies an attribute test, whose format is defined below. + The value of this expression is :samp:`{true-value}` if :samp:`{test}` is true, + otherwise it is :samp:`{false-value}`. + + .. index:: cond and attributes + +:samp:`(cond [{test1} {value1} ...] {default})` + The first operand of this expression is a vector containing an even + number of expressions and consisting of pairs of :samp:`{test}` and :samp:`{value}` + expressions. The value of the ``cond`` expression is that of the + :samp:`{value}` corresponding to the first true :samp:`{test}` expression. If + none of the :samp:`{test}` expressions are true, the value of the ``cond`` + expression is that of the :samp:`{default}` expression. + + :samp:`{test}` expressions can have one of the following forms: + +.. index:: const_int and attribute tests + +:samp:`(const_int {i})` + This test is true if :samp:`{i}` is nonzero and false otherwise. + + .. index:: not and attributes, ior and attributes, and and attributes + +:samp:`(not {test})` :samp:`(ior {test1} {test2})` :samp:`(and {test1} {test2})` + These tests are true if the indicated logical function is true. + + .. index:: match_operand and attributes + +:samp:`(match_operand:{m} {n} {pred} {constraints})` + This test is true if operand :samp:`{n}` of the insn whose attribute value + is being determined has mode :samp:`{m}` (this part of the test is ignored + if :samp:`{m}` is ``VOIDmode``) and the function specified by the string + :samp:`{pred}` returns a nonzero value when passed operand :samp:`{n}` and mode + :samp:`{m}` (this part of the test is ignored if :samp:`{pred}` is the null + string). + + The :samp:`{constraints}` operand is ignored and should be the null string. + + .. index:: match_test and attributes + +:samp:`(match_test {c-expr})` + The test is true if C expression :samp:`{c-expr}` is true. In non-constant + attributes, :samp:`{c-expr}` has access to the following variables: + + :samp:`{insn}` + The rtl instruction under test. + + :samp:`{which_alternative}` + The ``define_insn`` alternative that :samp:`{insn}` matches. + See :ref:`output-statement`. + + :samp:`{operands}` + An array of :samp:`{insn}` 's rtl operands. + + :samp:`{c-expr}` behaves like the condition in a C ``if`` statement, + so there is no need to explicitly convert the expression into a boolean + 0 or 1 value. For example, the following two tests are equivalent: + + .. code-block:: c++ + + (match_test "x & 2") + (match_test "(x & 2) != 0") + + .. index:: le and attributes, leu and attributes, lt and attributes, gt and attributes, gtu and attributes, ge and attributes, geu and attributes, ne and attributes, eq and attributes, plus and attributes, minus and attributes, mult and attributes, div and attributes, mod and attributes, abs and attributes, neg and attributes, ashift and attributes, lshiftrt and attributes, ashiftrt and attributes + +:samp:`(le {arith1} {arith2})` :samp:`(leu {arith1} {arith2})` :samp:`(lt {arith1} {arith2})` :samp:`(ltu {arith1} {arith2})` :samp:`(gt {arith1} {arith2})` :samp:`(gtu {arith1} {arith2})` :samp:`(ge {arith1} {arith2})` :samp:`(geu {arith1} {arith2})` :samp:`(ne {arith1} {arith2})` :samp:`(eq {arith1} {arith2})` + These tests are true if the indicated comparison of the two arithmetic + expressions is true. Arithmetic expressions are formed with + ``plus``, ``minus``, ``mult``, ``div``, ``mod``, + ``abs``, ``neg``, ``and``, ``ior``, ``xor``, ``not``, + ``ashift``, ``lshiftrt``, and ``ashiftrt`` expressions. + + .. index:: get_attr + + ``const_int`` and ``symbol_ref`` are always valid terms (see :ref:`insn-lengths`,for additional forms). ``symbol_ref`` is a string + denoting a C expression that yields an ``int`` when evaluated by the + :samp:`get_attr_...` routine. It should normally be a global + variable. + + .. index:: eq_attr + +:samp:`(eq_attr {name} {value})` + :samp:`{name}` is a string specifying the name of an attribute. + + :samp:`{value}` is a string that is either a valid value for attribute + :samp:`{name}`, a comma-separated list of values, or :samp:`!` followed by a + value or list. If :samp:`{value}` does not begin with a :samp:`!`, this + test is true if the value of the :samp:`{name}` attribute of the current + insn is in the list specified by :samp:`{value}`. If :samp:`{value}` begins + with a :samp:`!`, this test is true if the attribute's value is + *not* in the specified list. + + For example, + + .. code-block:: + + (eq_attr "type" "load,store") + + is equivalent to + + .. code-block:: + + (ior (eq_attr "type" "load") (eq_attr "type" "store")) + + If :samp:`{name}` specifies an attribute of :samp:`alternative`, it refers to the + value of the compiler variable ``which_alternative`` + (see :ref:`output-statement`) and the values must be small integers. For + example, + + .. code-block:: + + (eq_attr "alternative" "2,3") + + is equivalent to + + .. code-block:: c++ + + (ior (eq (symbol_ref "which_alternative") (const_int 2)) + (eq (symbol_ref "which_alternative") (const_int 3))) + + Note that, for most attributes, an ``eq_attr`` test is simplified in cases + where the value of the attribute being tested is known for all insns matching + a particular pattern. This is by far the most common case. + + .. index:: attr_flag + +:samp:`(attr_flag {name})` + The value of an ``attr_flag`` expression is true if the flag + specified by :samp:`{name}` is true for the ``insn`` currently being + scheduled. + + :samp:`{name}` is a string specifying one of a fixed set of flags to test. + Test the flags ``forward`` and ``backward`` to determine the + direction of a conditional branch. + + This example describes a conditional branch delay slot which + can be nullified for forward branches that are taken (annul-true) or + for backward branches which are not taken (annul-false). + + .. code-block:: + + (define_delay (eq_attr "type" "cbranch") + [(eq_attr "in_branch_delay" "true") + (and (eq_attr "in_branch_delay" "true") + (attr_flag "forward")) + (and (eq_attr "in_branch_delay" "true") + (attr_flag "backward"))]) + + The ``forward`` and ``backward`` flags are false if the current + ``insn`` being scheduled is not a conditional branch. + + ``attr_flag`` is only used during delay slot scheduling and has no + meaning to other passes of the compiler. + + .. index:: attr + +:samp:`(attr {name})` + The value of another attribute is returned. This is most useful + for numeric attributes, as ``eq_attr`` and ``attr_flag`` + produce more efficient code for non-numeric attributes. + +.. index:: tagging insns, assigning attribute values to insns + +.. _tagging-insns: + +Assigning Attribute Values to Insns +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The value assigned to an attribute of an insn is primarily determined by +which pattern is matched by that insn (or which ``define_peephole`` +generated it). Every ``define_insn`` and ``define_peephole`` can +have an optional last argument to specify the values of attributes for +matching insns. The value of any attribute not specified in a particular +insn is set to the default value for that attribute, as specified in its +``define_attr``. Extensive use of default values for attributes +permits the specification of the values for only one or two attributes +in the definition of most insn patterns, as seen in the example in the +next section. + +The optional last argument of ``define_insn`` and +``define_peephole`` is a vector of expressions, each of which defines +the value for a single attribute. The most general way of assigning an +attribute's value is to use a ``set`` expression whose first operand is an +``attr`` expression giving the name of the attribute being set. The +second operand of the ``set`` is an attribute expression +(see :ref:`expressions`) giving the value of the attribute. + +When the attribute value depends on the :samp:`alternative` attribute +(i.e., which is the applicable alternative in the constraint of the +insn), the ``set_attr_alternative`` expression can be used. It +allows the specification of a vector of attribute expressions, one for +each alternative. + +.. index:: set_attr + +When the generality of arbitrary attribute expressions is not required, +the simpler ``set_attr`` expression can be used, which allows +specifying a string giving either a single attribute value or a list +of attribute values, one for each alternative. + +The form of each of the above specifications is shown below. In each case, +:samp:`{name}` is a string specifying the attribute to be set. + +:samp:`(set_attr {name} {value-string})` + :samp:`{value-string}` is either a string giving the desired attribute value, + or a string containing a comma-separated list giving the values for + succeeding alternatives. The number of elements must match the number + of alternatives in the constraint of the insn pattern. + + Note that it may be useful to specify :samp:`*` for some alternative, in + which case the attribute will assume its default value for insns matching + that alternative. + + .. index:: set_attr_alternative + +:samp:`(set_attr_alternative {name} [{value1} {value2} ...])` + Depending on the alternative of the insn, the value will be one of the + specified values. This is a shorthand for using a ``cond`` with + tests on the :samp:`alternative` attribute. + + .. index:: attr + +:samp:`(set (attr {name}) {value})` + The first operand of this ``set`` must be the special RTL expression + ``attr``, whose sole operand is a string giving the name of the + attribute being set. :samp:`{value}` is the value of the attribute. + +The following shows three different ways of representing the same +attribute value specification: + +.. code-block:: + + (set_attr "type" "load,store,arith") + + (set_attr_alternative "type" + [(const_string "load") (const_string "store") + (const_string "arith")]) + + (set (attr "type") + (cond [(eq_attr "alternative" "1") (const_string "load") + (eq_attr "alternative" "2") (const_string "store")] + (const_string "arith"))) + +.. index:: define_asm_attributes + +The ``define_asm_attributes`` expression provides a mechanism to +specify the attributes assigned to insns produced from an ``asm`` +statement. It has the form: + +.. code-block:: + + (define_asm_attributes [attr-sets]) + +where :samp:`{attr-sets}` is specified the same as for both the +``define_insn`` and the ``define_peephole`` expressions. + +These values will typically be the 'worst case' attribute values. For +example, they might indicate that the condition code will be clobbered. + +A specification for a ``length`` attribute is handled specially. The +way to compute the length of an ``asm`` insn is to multiply the +length specified in the expression ``define_asm_attributes`` by the +number of machine instructions specified in the ``asm`` statement, +determined by counting the number of semicolons and newlines in the +string. Therefore, the value of the ``length`` attribute specified +in a ``define_asm_attributes`` should be the maximum possible length +of a single machine instruction. + +.. index:: attribute specifications example, attribute specifications + +.. _attr-example: + +Example of Attribute Specifications +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The judicious use of defaulting is important in the efficient use of +insn attributes. Typically, insns are divided into :dfn:`types` and an +attribute, customarily called ``type``, is used to represent this +value. This attribute is normally used only to define the default value +for other attributes. An example will clarify this usage. + +Assume we have a RISC machine with a condition code and in which only +full-word operations are performed in registers. Let us assume that we +can divide all insns into loads, stores, (integer) arithmetic +operations, floating point operations, and branches. + +Here we will concern ourselves with determining the effect of an insn on +the condition code and will limit ourselves to the following possible +effects: The condition code can be set unpredictably (clobbered), not +be changed, be set to agree with the results of the operation, or only +changed if the item previously set into the condition code has been +modified. + +Here is part of a sample :samp:`md` file for such a machine: + +.. code-block:: + + (define_attr "type" "load,store,arith,fp,branch" (const_string "arith")) + + (define_attr "cc" "clobber,unchanged,set,change0" + (cond [(eq_attr "type" "load") + (const_string "change0") + (eq_attr "type" "store,branch") + (const_string "unchanged") + (eq_attr "type" "arith") + (if_then_else (match_operand:SI 0 "" "") + (const_string "set") + (const_string "clobber"))] + (const_string "clobber"))) + + (define_insn "" + [(set (match_operand:SI 0 "general_operand" "=r,r,m") + (match_operand:SI 1 "general_operand" "r,m,r"))] + "" + "@ + move %0,%1 + load %0,%1 + store %0,%1" + [(set_attr "type" "arith,load,store")]) + +Note that we assume in the above example that arithmetic operations +performed on quantities smaller than a machine word clobber the condition +code since they will set the condition code to a value corresponding to the +full-word result. + +.. index:: insn lengths, computing, computing the length of an insn + +.. _insn-lengths: + +Computing the Length of an Insn +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +For many machines, multiple types of branch instructions are provided, each +for different length branch displacements. In most cases, the assembler +will choose the correct instruction to use. However, when the assembler +cannot do so, GCC can when a special attribute, the ``length`` +attribute, is defined. This attribute must be defined to have numeric +values by specifying a null string in its ``define_attr``. + +In the case of the ``length`` attribute, two additional forms of +arithmetic terms are allowed in test expressions: + +.. index:: match_dup and attributes + +:samp:`(match_dup {n})` + This refers to the address of operand :samp:`{n}` of the current insn, which + must be a ``label_ref``. + + .. index:: pc and attributes + +``(pc)`` + For non-branch instructions and backward branch instructions, this refers + to the address of the current insn. But for forward branch instructions, + this refers to the address of the next insn, because the length of the + current insn is to be computed. + +.. index:: addr_vec, length of, addr_diff_vec, length of + +For normal insns, the length will be determined by value of the +``length`` attribute. In the case of ``addr_vec`` and +``addr_diff_vec`` insn patterns, the length is computed as +the number of vectors multiplied by the size of each vector. + +Lengths are measured in addressable storage units (bytes). + +Note that it is possible to call functions via the ``symbol_ref`` +mechanism to compute the length of an insn. However, if you use this +mechanism you must provide dummy clauses to express the maximum length +without using the function call. You can see an example of this in the +``pa`` machine description for the ``call_symref`` pattern. + +The following macros can be used to refine the length computation: + +.. index:: ADJUST_INSN_LENGTH + +:samp:`ADJUST_INSN_LENGTH ({insn}, {length})` + If defined, modifies the length assigned to instruction :samp:`{insn}` as a + function of the context in which it is used. :samp:`{length}` is an lvalue + that contains the initially computed length of the insn and should be + updated with the correct length of the insn. + + This macro will normally not be required. A case in which it is + required is the ROMP. On this machine, the size of an ``addr_vec`` + insn must be increased by two to compensate for the fact that alignment + may be required. + +.. index:: get_attr_length + +The routine that returns ``get_attr_length`` (the value of the +``length`` attribute) can be used by the output routine to +determine the form of the branch instruction to be written, as the +example below illustrates. + +As an example of the specification of variable-length branches, consider +the IBM 360. If we adopt the convention that a register will be set to +the starting address of a function, we can jump to labels within 4k of +the start using a four-byte instruction. Otherwise, we need a six-byte +sequence to load the address from memory and then branch to it. + +On such a machine, a pattern for a branch instruction might be specified +as follows: + +.. code-block:: + + (define_insn "jump" + [(set (pc) + (label_ref (match_operand 0 "" "")))] + "" + { + return (get_attr_length (insn) == 4 + ? "b %l0" : "l r15,=a(%l0); br r15"); + } + [(set (attr "length") + (if_then_else (lt (match_dup 0) (const_int 4096)) + (const_int 4) + (const_int 6)))]) + +.. index:: constant attributes + +.. _constant-attributes: + +Constant Attributes +^^^^^^^^^^^^^^^^^^^ + +A special form of ``define_attr``, where the expression for the +default value is a ``const`` expression, indicates an attribute that +is constant for a given run of the compiler. Constant attributes may be +used to specify which variety of processor is used. For example, + +.. code-block:: + + (define_attr "cpu" "m88100,m88110,m88000" + (const + (cond [(symbol_ref "TARGET_88100") (const_string "m88100") + (symbol_ref "TARGET_88110") (const_string "m88110")] + (const_string "m88000")))) + + (define_attr "memory" "fast,slow" + (const + (if_then_else (symbol_ref "TARGET_FAST_MEM") + (const_string "fast") + (const_string "slow")))) + +The routine generated for constant attributes has no parameters as it +does not depend on any particular insn. RTL expressions used to define +the value of a constant attribute may use the ``symbol_ref`` form, +but may not use either the ``match_operand`` form or ``eq_attr`` +forms involving insn attributes. + +.. index:: mnemonic attribute + +.. _mnemonic-attribute: + +Mnemonic Attribute +^^^^^^^^^^^^^^^^^^ + +The ``mnemonic`` attribute is a string type attribute holding the +instruction mnemonic for an insn alternative. The attribute values +will automatically be generated by the machine description parser if +there is an attribute definition in the md file: + +.. code-block:: + + (define_attr "mnemonic" "unknown" (const_string "unknown")) + +The default value can be freely chosen as long as it does not collide +with any of the instruction mnemonics. This value will be used +whenever the machine description parser is not able to determine the +mnemonic string. This might be the case for output templates +containing more than a single instruction as in +``"mvcle\t%0,%1,0\;jo\t.-4"``. + +The ``mnemonic`` attribute set is not generated automatically if the +instruction string is generated via C code. + +An existing ``mnemonic`` attribute set in an insn definition will not +be overriden by the md file parser. That way it is possible to +manually set the instruction mnemonics for the cases where the md file +parser fails to determine it automatically. + +The ``mnemonic`` attribute is useful for dealing with instruction +specific properties in the pipeline description without defining +additional insn attributes. + +.. code-block:: + + (define_attr "ooo_expanded" "" + (cond [(eq_attr "mnemonic" "dlr,dsgr,d,dsgf,stam,dsgfr,dlgr") + (const_int 1)] + (const_int 0))) + +.. index:: delay slots, defining + +.. _delay-slots: + +Delay Slot Scheduling +^^^^^^^^^^^^^^^^^^^^^ + +The insn attribute mechanism can be used to specify the requirements for +delay slots, if any, on a target machine. An instruction is said to +require a :dfn:`delay slot` if some instructions that are physically +after the instruction are executed as if they were located before it. +Classic examples are branch and call instructions, which often execute +the following instruction before the branch or call is performed. + +On some machines, conditional branch instructions can optionally +:dfn:`annul` instructions in the delay slot. This means that the +instruction will not be executed for certain branch outcomes. Both +instructions that annul if the branch is true and instructions that +annul if the branch is false are supported. + +Delay slot scheduling differs from instruction scheduling in that +determining whether an instruction needs a delay slot is dependent only +on the type of instruction being generated, not on data flow between the +instructions. See the next section for a discussion of data-dependent +instruction scheduling. + +.. index:: define_delay + +The requirement of an insn needing one or more delay slots is indicated +via the ``define_delay`` expression. It has the following form: + +.. code-block:: + + (define_delay test + [delay-1 annul-true-1 annul-false-1 + delay-2 annul-true-2 annul-false-2 + ...]) + +:samp:`{test}` is an attribute test that indicates whether this +``define_delay`` applies to a particular insn. If so, the number of +required delay slots is determined by the length of the vector specified +as the second argument. An insn placed in delay slot :samp:`{n}` must +satisfy attribute test :samp:`{delay-n}`. :samp:`{annul-true-n}` is an +attribute test that specifies which insns may be annulled if the branch +is true. Similarly, :samp:`{annul-false-n}` specifies which insns in the +delay slot may be annulled if the branch is false. If annulling is not +supported for that delay slot, ``(nil)`` should be coded. + +For example, in the common case where branch and call insns require +a single delay slot, which may contain any insn other than a branch or +call, the following would be placed in the :samp:`md` file: + +.. code-block:: + + (define_delay (eq_attr "type" "branch,call") + [(eq_attr "type" "!branch,call") (nil) (nil)]) + +Multiple ``define_delay`` expressions may be specified. In this +case, each such expression specifies different delay slot requirements +and there must be no insn for which tests in two ``define_delay`` +expressions are both true. + +For example, if we have a machine that requires one delay slot for branches +but two for calls, no delay slot can contain a branch or call insn, +and any valid insn in the delay slot for the branch can be annulled if the +branch is true, we might represent this as follows: + +.. code-block:: + + (define_delay (eq_attr "type" "branch") + [(eq_attr "type" "!branch,call") + (eq_attr "type" "!branch,call") + (nil)]) + + (define_delay (eq_attr "type" "call") + [(eq_attr "type" "!branch,call") (nil) (nil) + (eq_attr "type" "!branch,call") (nil) (nil)]) + +.. the above is *still* too long. -mew 4feb93 + +.. index:: processor pipeline description, processor functional units, instruction latency time, interlock delays, data dependence delays, reservation delays, pipeline hazard recognizer, automaton based pipeline description, regular expressions, deterministic finite state automaton, automaton based scheduler, RISC, VLIW + +.. _processor-pipeline-description: + +Specifying processor pipeline description +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To achieve better performance, most modern processors +(super-pipelined, superscalar RISC, and VLIW +processors) have many :dfn:`functional units` on which several +instructions can be executed simultaneously. An instruction starts +execution if its issue conditions are satisfied. If not, the +instruction is stalled until its conditions are satisfied. Such +:dfn:`interlock (pipeline) delay` causes interruption of the fetching +of successor instructions (or demands nop instructions, e.g. for some +MIPS processors). + +There are two major kinds of interlock delays in modern processors. +The first one is a data dependence delay determining :dfn:`instruction +latency time`. The instruction execution is not started until all +source data have been evaluated by prior instructions (there are more +complex cases when the instruction execution starts even when the data +are not available but will be ready in given time after the +instruction execution start). Taking the data dependence delays into +account is simple. The data dependence (true, output, and +anti-dependence) delay between two instructions is given by a +constant. In most cases this approach is adequate. The second kind +of interlock delays is a reservation delay. The reservation delay +means that two instructions under execution will be in need of shared +processors resources, i.e. buses, internal registers, and/or +functional units, which are reserved for some time. Taking this kind +of delay into account is complex especially for modern RISC +processors. + +The task of exploiting more processor parallelism is solved by an +instruction scheduler. For a better solution to this problem, the +instruction scheduler has to have an adequate description of the +processor parallelism (or :dfn:`pipeline description`). GCC +machine descriptions describe processor parallelism and functional +unit reservations for groups of instructions with the aid of +:dfn:`regular expressions`. + +The GCC instruction scheduler uses a :dfn:`pipeline hazard recognizer` to +figure out the possibility of the instruction issue by the processor +on a given simulated processor cycle. The pipeline hazard recognizer is +automatically generated from the processor pipeline description. The +pipeline hazard recognizer generated from the machine description +is based on a deterministic finite state automaton (DFA): +the instruction issue is possible if there is a transition from one +automaton state to another one. This algorithm is very fast, and +furthermore, its speed is not dependent on processor +complexity [#f1]_. + +.. [#f1] However, the size of the automaton depends on + processor complexity. To limit this effect, machine descriptions + can split orthogonal parts of the machine description among several + automata: but then, since each of these must be stepped independently, + this does cause a small decrease in the algorithm's performance. + +.. index:: automaton based pipeline description + +The rest of this section describes the directives that constitute +an automaton-based processor pipeline description. The order of +these constructions within the machine description file is not +important. + +.. index:: define_automaton, pipeline hazard recognizer + +The following optional construction describes names of automata +generated and used for the pipeline hazards recognition. Sometimes +the generated finite state automaton used by the pipeline hazard +recognizer is large. If we use more than one automaton and bind functional +units to the automata, the total size of the automata is usually +less than the size of the single automaton. If there is no one such +construction, only one finite state automaton is generated. + +.. code-block:: + + (define_automaton automata-names) + +:samp:`{automata-names}` is a string giving names of the automata. The +names are separated by commas. All the automata should have unique names. +The automaton name is used in the constructions ``define_cpu_unit`` and +``define_query_cpu_unit``. + +.. index:: define_cpu_unit, processor functional units + +Each processor functional unit used in the description of instruction +reservations should be described by the following construction. + +.. code-block:: + + (define_cpu_unit unit-names [automaton-name]) + +:samp:`{unit-names}` is a string giving the names of the functional units +separated by commas. Don't use name :samp:`nothing`, it is reserved +for other goals. + +:samp:`{automaton-name}` is a string giving the name of the automaton with +which the unit is bound. The automaton should be described in +construction ``define_automaton``. You should give +:dfn:`automaton-name`, if there is a defined automaton. + +The assignment of units to automata are constrained by the uses of the +units in insn reservations. The most important constraint is: if a +unit reservation is present on a particular cycle of an alternative +for an insn reservation, then some unit from the same automaton must +be present on the same cycle for the other alternatives of the insn +reservation. The rest of the constraints are mentioned in the +description of the subsequent constructions. + +.. index:: define_query_cpu_unit, querying function unit reservations + +The following construction describes CPU functional units analogously +to ``define_cpu_unit``. The reservation of such units can be +queried for an automaton state. The instruction scheduler never +queries reservation of functional units for given automaton state. So +as a rule, you don't need this construction. This construction could +be used for future code generation goals (e.g. to generate +VLIW insn templates). + +.. code-block:: + + (define_query_cpu_unit unit-names [automaton-name]) + +:samp:`{unit-names}` is a string giving names of the functional units +separated by commas. + +:samp:`{automaton-name}` is a string giving the name of the automaton with +which the unit is bound. + +.. index:: define_insn_reservation, instruction latency time, regular expressions, data bypass + +The following construction is the major one to describe pipeline +characteristics of an instruction. + +.. code-block:: + + (define_insn_reservation insn-name default_latency + condition regexp) + +:samp:`{default_latency}` is a number giving latency time of the +instruction. There is an important difference between the old +description and the automaton based pipeline description. The latency +time is used for all dependencies when we use the old description. In +the automaton based pipeline description, the given latency time is only +used for true dependencies. The cost of anti-dependencies is always +zero and the cost of output dependencies is the difference between +latency times of the producing and consuming insns (if the difference +is negative, the cost is considered to be zero). You can always +change the default costs for any description by using the target hook +``TARGET_SCHED_ADJUST_COST`` (see :ref:`scheduling`). + +:samp:`{insn-name}` is a string giving the internal name of the insn. The +internal names are used in constructions ``define_bypass`` and in +the automaton description file generated for debugging. The internal +name has nothing in common with the names in ``define_insn``. It is a +good practice to use insn classes described in the processor manual. + +:samp:`{condition}` defines what RTL insns are described by this +construction. You should remember that you will be in trouble if +:samp:`{condition}` for two or more different +``define_insn_reservation`` constructions is TRUE for an insn. In +this case what reservation will be used for the insn is not defined. +Such cases are not checked during generation of the pipeline hazards +recognizer because in general recognizing that two conditions may have +the same value is quite difficult (especially if the conditions +contain ``symbol_ref``). It is also not checked during the +pipeline hazard recognizer work because it would slow down the +recognizer considerably. + +:samp:`{regexp}` is a string describing the reservation of the cpu's functional +units by the instruction. The reservations are described by a regular +expression according to the following syntax: + +.. code-block:: c++ + + regexp = regexp "," oneof + | oneof + + oneof = oneof "|" allof + | allof + + allof = allof "+" repeat + | repeat + + repeat = element "*" number + | element + + element = cpu_function_unit_name + | reservation_name + | result_name + | "nothing" + | "(" regexp ")" + +* :samp:`,` is used for describing the start of the next cycle in + the reservation. + +* :samp:`|` is used for describing a reservation described by the first + regular expression **or** a reservation described by the second + regular expression **or** etc. + +* :samp:`+` is used for describing a reservation described by the first + regular expression **and** a reservation described by the + second regular expression **and** etc. + +* :samp:`*` is used for convenience and simply means a sequence in which + the regular expression are repeated :samp:`{number}` times with cycle + advancing (see :samp:`,`). + +* :samp:`cpu_function_unit_name` denotes reservation of the named + functional unit. + +* :samp:`reservation_name` --- see description of construction + :samp:`define_reservation`. + +* :samp:`nothing` denotes no unit reservations. + +.. index:: define_reservation + +Sometimes unit reservations for different insns contain common parts. +In such case, you can simplify the pipeline description by describing +the common part by the following construction + +.. code-block:: + + (define_reservation reservation-name regexp) + +:samp:`{reservation-name}` is a string giving name of :samp:`{regexp}`. +Functional unit names and reservation names are in the same name +space. So the reservation names should be different from the +functional unit names and cannot be the reserved name :samp:`nothing`. + +.. index:: define_bypass, instruction latency time, data bypass + +The following construction is used to describe exceptions in the +latency time for given instruction pair. This is so called bypasses. + +.. code-block:: + + (define_bypass number out_insn_names in_insn_names + [guard]) + +:samp:`{number}` defines when the result generated by the instructions +given in string :samp:`{out_insn_names}` will be ready for the +instructions given in string :samp:`{in_insn_names}`. Each of these +strings is a comma-separated list of filename-style globs and +they refer to the names of ``define_insn_reservation`` s. +For example: + +.. code-block:: + + (define_bypass 1 "cpu1_load_*, cpu1_store_*" "cpu1_load_*") + +defines a bypass between instructions that start with +:samp:`cpu1_load_` or :samp:`cpu1_store_` and those that start with +:samp:`cpu1_load_`. + +:samp:`{guard}` is an optional string giving the name of a C function which +defines an additional guard for the bypass. The function will get the +two insns as parameters. If the function returns zero the bypass will +be ignored for this case. The additional guard is necessary to +recognize complicated bypasses, e.g. when the consumer is only an address +of insn :samp:`store` (not a stored value). + +If there are more one bypass with the same output and input insns, the +chosen bypass is the first bypass with a guard in description whose +guard function returns nonzero. If there is no such bypass, then +bypass without the guard function is chosen. + +.. index:: exclusion_set, presence_set, final_presence_set, absence_set, final_absence_set, VLIW, RISC + +The following five constructions are usually used to describe +VLIW processors, or more precisely, to describe a placement +of small instructions into VLIW instruction slots. They +can be used for RISC processors, too. + +.. code-block:: c++ + + (exclusion_set unit-names unit-names) + (presence_set unit-names patterns) + (final_presence_set unit-names patterns) + (absence_set unit-names patterns) + (final_absence_set unit-names patterns) + +:samp:`{unit-names}` is a string giving names of functional units +separated by commas. + +:samp:`{patterns}` is a string giving patterns of functional units +separated by comma. Currently pattern is one unit or units +separated by white-spaces. + +The first construction (:samp:`exclusion_set`) means that each +functional unit in the first string cannot be reserved simultaneously +with a unit whose name is in the second string and vice versa. For +example, the construction is useful for describing processors +(e.g. some SPARC processors) with a fully pipelined floating point +functional unit which can execute simultaneously only single floating +point insns or only double floating point insns. + +The second construction (:samp:`presence_set`) means that each +functional unit in the first string cannot be reserved unless at +least one of pattern of units whose names are in the second string is +reserved. This is an asymmetric relation. For example, it is useful +for description that VLIW :samp:`slot1` is reserved after +:samp:`slot0` reservation. We could describe it by the following +construction + +.. code-block:: c++ + + (presence_set "slot1" "slot0") + +Or :samp:`slot1` is reserved only after :samp:`slot0` and unit :samp:`b0` +reservation. In this case we could write + +.. code-block:: c++ + + (presence_set "slot1" "slot0 b0") + +The third construction (:samp:`final_presence_set`) is analogous to +:samp:`presence_set`. The difference between them is when checking is +done. When an instruction is issued in given automaton state +reflecting all current and planned unit reservations, the automaton +state is changed. The first state is a source state, the second one +is a result state. Checking for :samp:`presence_set` is done on the +source state reservation, checking for :samp:`final_presence_set` is +done on the result reservation. This construction is useful to +describe a reservation which is actually two subsequent reservations. +For example, if we use + +.. code-block:: c++ + + (presence_set "slot1" "slot0") + +the following insn will be never issued (because :samp:`slot1` requires +:samp:`slot0` which is absent in the source state). + +.. code-block:: + + (define_reservation "insn_and_nop" "slot0 + slot1") + +but it can be issued if we use analogous :samp:`final_presence_set`. + +The forth construction (:samp:`absence_set`) means that each functional +unit in the first string can be reserved only if each pattern of units +whose names are in the second string is not reserved. This is an +asymmetric relation (actually :samp:`exclusion_set` is analogous to +this one but it is symmetric). For example it might be useful in a +VLIW description to say that :samp:`slot0` cannot be reserved +after either :samp:`slot1` or :samp:`slot2` have been reserved. This +can be described as: + +.. code-block:: c++ + + (absence_set "slot0" "slot1, slot2") + +Or :samp:`slot2` cannot be reserved if :samp:`slot0` and unit :samp:`b0` +are reserved or :samp:`slot1` and unit :samp:`b1` are reserved. In +this case we could write + +.. code-block:: c++ + + (absence_set "slot2" "slot0 b0, slot1 b1") + +All functional units mentioned in a set should belong to the same +automaton. + +The last construction (:samp:`final_absence_set`) is analogous to +:samp:`absence_set` but checking is done on the result (state) +reservation. See comments for :samp:`final_presence_set`. + +.. index:: automata_option, deterministic finite state automaton, nondeterministic finite state automaton, finite state automaton minimization + +You can control the generator of the pipeline hazard recognizer with +the following construction. + +.. code-block:: c++ + + (automata_option options) + +:samp:`{options}` is a string giving options which affect the generated +code. Currently there are the following options: + +* :dfn:`no-minimization` makes no minimization of the automaton. This is + only worth to do when we are debugging the description and need to + look more accurately at reservations of states. + +* :dfn:`time` means printing time statistics about the generation of + automata. + +* :dfn:`stats` means printing statistics about the generated automata + such as the number of DFA states, NDFA states and arcs. + +* :dfn:`v` means a generation of the file describing the result automata. + The file has suffix :samp:`.dfa` and can be used for the description + verification and debugging. + +* :dfn:`w` means a generation of warning instead of error for + non-critical errors. + +* :dfn:`no-comb-vect` prevents the automaton generator from generating + two data structures and comparing them for space efficiency. Using + a comb vector to represent transitions may be better, but it can be + very expensive to construct. This option is useful if the build + process spends an unacceptably long time in genautomata. + +* :dfn:`ndfa` makes nondeterministic finite state automata. This affects + the treatment of operator :samp:`|` in the regular expressions. The + usual treatment of the operator is to try the first alternative and, + if the reservation is not possible, the second alternative. The + nondeterministic treatment means trying all alternatives, some of them + may be rejected by reservations in the subsequent insns. + +* :dfn:`collapse-ndfa` modifies the behavior of the generator when + producing an automaton. An additional state transition to collapse a + nondeterministic NDFA state to a deterministic DFA + state is generated. It can be triggered by passing ``const0_rtx`` to + state_transition. In such an automaton, cycle advance transitions are + available only for these collapsed states. This option is useful for + ports that want to use the ``ndfa`` option, but also want to use + ``define_query_cpu_unit`` to assign units to insns issued in a cycle. + +* :dfn:`progress` means output of a progress bar showing how many states + were generated so far for automaton being processed. This is useful + during debugging a DFA description. If you see too many + generated states, you could interrupt the generator of the pipeline + hazard recognizer and try to figure out a reason for generation of the + huge automaton. + +As an example, consider a superscalar RISC machine which can +issue three insns (two integer insns and one floating point insn) on +the cycle but can finish only two insns. To describe this, we define +the following functional units. + +.. code-block:: + + (define_cpu_unit "i0_pipeline, i1_pipeline, f_pipeline") + (define_cpu_unit "port0, port1") + +All simple integer insns can be executed in any integer pipeline and +their result is ready in two cycles. The simple integer insns are +issued into the first pipeline unless it is reserved, otherwise they +are issued into the second pipeline. Integer division and +multiplication insns can be executed only in the second integer +pipeline and their results are ready correspondingly in 9 and 4 +cycles. The integer division is not pipelined, i.e. the subsequent +integer division insn cannot be issued until the current division +insn finished. Floating point insns are fully pipelined and their +results are ready in 3 cycles. Where the result of a floating point +insn is used by an integer insn, an additional delay of one cycle is +incurred. To describe all of this we could specify + +.. code-block:: + + (define_cpu_unit "div") + + (define_insn_reservation "simple" 2 (eq_attr "type" "int") + "(i0_pipeline | i1_pipeline), (port0 | port1)") + + (define_insn_reservation "mult" 4 (eq_attr "type" "mult") + "i1_pipeline, nothing*2, (port0 | port1)") + + (define_insn_reservation "div" 9 (eq_attr "type" "div") + "i1_pipeline, div*7, div + (port0 | port1)") + + (define_insn_reservation "float" 3 (eq_attr "type" "float") + "f_pipeline, nothing, (port0 | port1)) + + (define_bypass 4 "float" "simple,mult,div") + +To simplify the description we could describe the following reservation + +.. code-block:: + + (define_reservation "finish" "port0|port1") + +and use it in all ``define_insn_reservation`` as in the following +construction + +.. code-block:: + + (define_insn_reservation "simple" 2 (eq_attr "type" "int") + "(i0_pipeline | i1_pipeline), finish") \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/interdependence-of-patterns.rst b/gcc/doc/gccint/machine-descriptions/interdependence-of-patterns.rst new file mode 100644 index 00000000000..37a906493ee --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/interdependence-of-patterns.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Dependent Patterns, Interdependence of Patterns + +.. _dependent-patterns: + +Interdependence of Patterns +*************************** + +In some cases machines support instructions identical except for the +machine mode of one or more operands. For example, there may be +'sign-extend halfword' and 'sign-extend byte' instructions whose +patterns are + +.. code-block:: c++ + + (set (match_operand:SI 0 ...) + (extend:SI (match_operand:HI 1 ...))) + + (set (match_operand:SI 0 ...) + (extend:SI (match_operand:QI 1 ...))) + +Constant integers do not specify a machine mode, so an instruction to +extend a constant value could match either pattern. The pattern it +actually will match is the one that appears first in the file. For correct +results, this must be the one for the widest possible mode (``HImode``, +here). If the pattern matches the ``QImode`` instruction, the results +will be incorrect if the constant value does not actually fit that mode. + +Such instructions to extend constants are rarely generated because they are +optimized away, but they do occasionally happen in nonoptimized +compilations. + +If a constraint in a pattern allows a constant, the reload pass may +replace a register with a constant permitted by the constraint in some +cases. Similarly for memory references. Because of this substitution, +you should not provide separate patterns for increment and decrement +instructions. Instead, they should be generated from the same pattern +that supports register-register add insns by examining the operands and +generating the appropriate machine instruction. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/iterators.rst b/gcc/doc/gccint/machine-descriptions/iterators.rst new file mode 100644 index 00000000000..03dd7804ec9 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/iterators.rst @@ -0,0 +1,543 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: iterators in .md files + +.. _iterators: + +Iterators +********* + +Ports often need to define similar patterns for more than one machine +mode or for more than one rtx code. GCC provides some simple iterator +facilities to make this process easier. + +.. toctree:: + :maxdepth: 2 + + +.. index:: mode iterators in .md files + +.. _mode-iterators: + +Mode Iterators +^^^^^^^^^^^^^^ + +Ports often need to define similar patterns for two or more different modes. +For example: + +* If a processor has hardware support for both single and double + floating-point arithmetic, the ``SFmode`` patterns tend to be + very similar to the ``DFmode`` ones. + +* If a port uses ``SImode`` pointers in one configuration and + ``DImode`` pointers in another, it will usually have very similar + ``SImode`` and ``DImode`` patterns for manipulating pointers. + +Mode iterators allow several patterns to be instantiated from one +:samp:`.md` file template. They can be used with any type of +rtx-based construct, such as a ``define_insn``, +``define_split``, or ``define_peephole2``. + +.. toctree:: + :maxdepth: 2 + + +.. index:: define_mode_iterator + +.. _defining-mode-iterators: + +Defining Mode Iterators +~~~~~~~~~~~~~~~~~~~~~~~ + +The syntax for defining a mode iterator is: + +.. code-block:: + + (define_mode_iterator name [(mode1 "cond1") ... (moden "condn")]) + +This allows subsequent :samp:`.md` file constructs to use the mode suffix +``:name``. Every construct that does so will be expanded +:samp:`{n}` times, once with every use of ``:name`` replaced by +``:mode1``, once with every use replaced by ``:mode2``, +and so on. In the expansion for a particular :samp:`{modei}`, every +C condition will also require that :samp:`{condi}` be true. + +For example: + +.. code-block:: + + (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")]) + +defines a new mode suffix ``:P``. Every construct that uses +``:P`` will be expanded twice, once with every ``:P`` replaced +by ``:SI`` and once with every ``:P`` replaced by ``:DI``. +The ``:SI`` version will only apply if ``Pmode == SImode`` and +the ``:DI`` version will only apply if ``Pmode == DImode``. + +As with other :samp:`.md` conditions, an empty string is treated +as 'always true'. ``(mode "")`` can also be abbreviated +to ``mode``. For example: + +.. code-block:: + + (define_mode_iterator GPR [SI (DI "TARGET_64BIT")]) + +means that the ``:DI`` expansion only applies if ``TARGET_64BIT`` +but that the ``:SI`` expansion has no such constraint. + +Iterators are applied in the order they are defined. This can be +significant if two iterators are used in a construct that requires +substitutions. See :ref:`substitutions`. + +.. index:: define_mode_attr + +.. _substitutions: + +Substitution in Mode Iterators +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If an :samp:`.md` file construct uses mode iterators, each version of the +construct will often need slightly different strings or modes. For +example: + +* When a ``define_expand`` defines several ``addm3`` patterns + (see :ref:`standard-names`), each expander will need to use the + appropriate mode name for :samp:`{m}`. + +* When a ``define_insn`` defines several instruction patterns, + each instruction will often use a different assembler mnemonic. + +* When a ``define_insn`` requires operands with different modes, + using an iterator for one of the operand modes usually requires a specific + mode for the other operand(s). + +GCC supports such variations through a system of 'mode attributes'. +There are two standard attributes: ``mode``, which is the name of +the mode in lower case, and ``MODE``, which is the same thing in +upper case. You can define other attributes using: + +.. code-block:: + + (define_mode_attr name [(mode1 "value1") ... (moden "valuen")]) + +where :samp:`{name}` is the name of the attribute and :samp:`{valuei}` +is the value associated with :samp:`{modei}`. + +When GCC replaces some :samp:`{:iterator}` with :samp:`{:mode}`, it will scan +each string and mode in the pattern for sequences of the form +````, where :samp:`{attr}` is the name of a +mode attribute. If the attribute is defined for :samp:`{mode}`, the whole +``<...>`` sequence will be replaced by the appropriate attribute +value. + +For example, suppose an :samp:`.md` file has: + +.. code-block:: + + (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")]) + (define_mode_attr load [(SI "lw") (DI "ld")]) + +If one of the patterns that uses ``:P`` contains the string +``"\t%0,%1"``, the ``SI`` version of that pattern +will use ``"lw\t%0,%1"`` and the ``DI`` version will use +``"ld\t%0,%1"``. + +Here is an example of using an attribute for a mode: + +.. code-block:: + + (define_mode_iterator LONG [SI DI]) + (define_mode_attr SHORT [(SI "HI") (DI "SI")]) + (define_insn ... + (sign_extend:LONG (match_operand: ...)) ...) + +The ``iterator:`` prefix may be omitted, in which case the +substitution will be attempted for every iterator expansion. + +.. _examples: + +Mode Iterator Examples +~~~~~~~~~~~~~~~~~~~~~~ + +Here is an example from the MIPS port. It defines the following +modes and attributes (among others): + +.. code-block:: + + (define_mode_iterator GPR [SI (DI "TARGET_64BIT")]) + (define_mode_attr d [(SI "") (DI "d")]) + +and uses the following template to define both ``subsi3`` +and ``subdi3`` : + +.. code-block:: + + (define_insn "sub3" + [(set (match_operand:GPR 0 "register_operand" "=d") + (minus:GPR (match_operand:GPR 1 "register_operand" "d") + (match_operand:GPR 2 "register_operand" "d")))] + "" + "subu\t%0,%1,%2" + [(set_attr "type" "arith") + (set_attr "mode" "")]) + +This is exactly equivalent to: + +.. code-block:: + + (define_insn "subsi3" + [(set (match_operand:SI 0 "register_operand" "=d") + (minus:SI (match_operand:SI 1 "register_operand" "d") + (match_operand:SI 2 "register_operand" "d")))] + "" + "subu\t%0,%1,%2" + [(set_attr "type" "arith") + (set_attr "mode" "SI")]) + + (define_insn "subdi3" + [(set (match_operand:DI 0 "register_operand" "=d") + (minus:DI (match_operand:DI 1 "register_operand" "d") + (match_operand:DI 2 "register_operand" "d")))] + "TARGET_64BIT" + "dsubu\t%0,%1,%2" + [(set_attr "type" "arith") + (set_attr "mode" "DI")]) + +.. index:: code iterators in .md files, define_code_iterator, define_code_attr + +.. _code-iterators: + +Code Iterators +^^^^^^^^^^^^^^ + +Code iterators operate in a similar way to mode iterators. See :ref:`mode-iterators`. + +The construct: + +.. code-block:: + + (define_code_iterator name [(code1 "cond1") ... (coden "condn")]) + +defines a pseudo rtx code :samp:`{name}` that can be instantiated as +:samp:`{codei}` if condition :samp:`{condi}` is true. Each :samp:`{codei}` +must have the same rtx format. See :ref:`rtl-classes`. + +As with mode iterators, each pattern that uses :samp:`{name}` will be +expanded :samp:`{n}` times, once with all uses of :samp:`{name}` replaced by +:samp:`{code1}`, once with all uses replaced by :samp:`{code2}`, and so on. +See :ref:`defining-mode-iterators`. + +It is possible to define attributes for codes as well as for modes. +There are two standard code attributes: ``code``, the name of the +code in lower case, and ``CODE``, the name of the code in upper case. +Other attributes are defined using: + +.. code-block:: + + (define_code_attr name [(code1 "value1") ... (coden "valuen")]) + +Instruction patterns can use code attributes as rtx codes, which can be +useful if two sets of codes act in tandem. For example, the following +``define_insn`` defines two patterns, one calculating a signed absolute +difference and another calculating an unsigned absolute difference: + +.. code-block:: + + (define_code_iterator any_max [smax umax]) + (define_code_attr paired_min [(smax "smin") (umax "umin")]) + (define_insn ... + [(set (match_operand:SI 0 ...) + (minus:SI (any_max:SI (match_operand:SI 1 ...) + (match_operand:SI 2 ...)) + (:SI (match_dup 1) (match_dup 2))))] + ...) + +The signed version of the instruction uses ``smax`` and ``smin`` +while the unsigned version uses ``umax`` and ``umin``. There +are no versions that pair ``smax`` with ``umin`` or ``umax`` +with ``smin``. + +Here's an example of code iterators in action, taken from the MIPS port: + +.. code-block:: + + (define_code_iterator any_cond [unordered ordered unlt unge uneq ltgt unle ungt + eq ne gt ge lt le gtu geu ltu leu]) + + (define_expand "b" + [(set (pc) + (if_then_else (any_cond:CC (cc0) + (const_int 0)) + (label_ref (match_operand 0 "")) + (pc)))] + "" + { + gen_conditional_branch (operands, ); + DONE; + }) + +This is equivalent to: + +.. code-block:: + + (define_expand "bunordered" + [(set (pc) + (if_then_else (unordered:CC (cc0) + (const_int 0)) + (label_ref (match_operand 0 "")) + (pc)))] + "" + { + gen_conditional_branch (operands, UNORDERED); + DONE; + }) + + (define_expand "bordered" + [(set (pc) + (if_then_else (ordered:CC (cc0) + (const_int 0)) + (label_ref (match_operand 0 "")) + (pc)))] + "" + { + gen_conditional_branch (operands, ORDERED); + DONE; + }) + + ... + +.. index:: int iterators in .md files, define_int_iterator, define_int_attr + +.. _int-iterators: + +Int Iterators +^^^^^^^^^^^^^ + +Int iterators operate in a similar way to code iterators. See :ref:`code-iterators`. + +The construct: + +.. code-block:: + + (define_int_iterator name [(int1 "cond1") ... (intn "condn")]) + +defines a pseudo integer constant :samp:`{name}` that can be instantiated as +:samp:`{inti}` if condition :samp:`{condi}` is true. Each :samp:`{int}` must have the +same rtx format. See :ref:`rtl-classes`. Int iterators can appear in only +those rtx fields that have 'i', 'n', 'w', or 'p' as the specifier. This +means that each :samp:`{int}` has to be a constant defined using define_constant +or define_c_enum. + +As with mode and code iterators, each pattern that uses :samp:`{name}` will be +expanded :samp:`{n}` times, once with all uses of :samp:`{name}` replaced by +:samp:`{int1}`, once with all uses replaced by :samp:`{int2}`, and so on. +See :ref:`defining-mode-iterators`. + +It is possible to define attributes for ints as well as for codes and modes. +Attributes are defined using: + +.. code-block:: + + (define_int_attr name [(int1 "value1") ... (intn "valuen")]) + +Here's an example of int iterators in action, taken from the ARM port: + +.. code-block:: + + (define_int_iterator QABSNEG [UNSPEC_VQABS UNSPEC_VQNEG]) + + (define_int_attr absneg [(UNSPEC_VQABS "abs") (UNSPEC_VQNEG "neg")]) + + (define_insn "neon_vq" + [(set (match_operand:VDQIW 0 "s_register_operand" "=w") + (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w") + (match_operand:SI 2 "immediate_operand" "i")] + QABSNEG))] + "TARGET_NEON" + "vq.\t%0, %1" + [(set_attr "type" "neon_vqneg_vqabs")] + ) + +This is equivalent to: + +.. code-block:: + + (define_insn "neon_vqabs" + [(set (match_operand:VDQIW 0 "s_register_operand" "=w") + (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w") + (match_operand:SI 2 "immediate_operand" "i")] + UNSPEC_VQABS))] + "TARGET_NEON" + "vqabs.\t%0, %1" + [(set_attr "type" "neon_vqneg_vqabs")] + ) + + (define_insn "neon_vqneg" + [(set (match_operand:VDQIW 0 "s_register_operand" "=w") + (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w") + (match_operand:SI 2 "immediate_operand" "i")] + UNSPEC_VQNEG))] + "TARGET_NEON" + "vqneg.\t%0, %1" + [(set_attr "type" "neon_vqneg_vqabs")] + ) + +.. index:: subst iterators in .md files, define_subst, define_subst_attr + +.. _subst-iterators: + +Subst Iterators +^^^^^^^^^^^^^^^ + +Subst iterators are special type of iterators with the following +restrictions: they could not be declared explicitly, they always have +only two values, and they do not have explicit dedicated name. +Subst-iterators are triggered only when corresponding subst-attribute is +used in RTL-pattern. + +Subst iterators transform templates in the following way: the templates +are duplicated, the subst-attributes in these templates are replaced +with the corresponding values, and a new attribute is implicitly added +to the given ``define_insn`` / ``define_expand``. The name of the +added attribute matches the name of ``define_subst``. Such +attributes are declared implicitly, and it is not allowed to have a +``define_attr`` named as a ``define_subst``. + +Each subst iterator is linked to a ``define_subst``. It is declared +implicitly by the first appearance of the corresponding +``define_subst_attr``, and it is not allowed to define it explicitly. + +Declarations of subst-attributes have the following syntax: + +.. index:: define_subst_attr + +.. code-block:: + + (define_subst_attr "name" + "subst-name" + "no-subst-value" + "subst-applied-value") + +:samp:`{name}` is a string with which the given subst-attribute could be +referred to. + +:samp:`{subst-name}` shows which ``define_subst`` should be applied to an +RTL-template if the given subst-attribute is present in the +RTL-template. + +:samp:`{no-subst-value}` is a value with which subst-attribute would be +replaced in the first copy of the original RTL-template. + +:samp:`{subst-applied-value}` is a value with which subst-attribute would be +replaced in the second copy of the original RTL-template. + +.. index:: @ in instruction pattern names + +.. _parameterized-names: + +Parameterized Names +^^^^^^^^^^^^^^^^^^^ + +Ports sometimes need to apply iterators using C++ code, in order to +get the code or RTL pattern for a specific instruction. For example, +suppose we have the :samp:`neon_vq` pattern given above: + +.. code-block:: + + (define_int_iterator QABSNEG [UNSPEC_VQABS UNSPEC_VQNEG]) + + (define_int_attr absneg [(UNSPEC_VQABS "abs") (UNSPEC_VQNEG "neg")]) + + (define_insn "neon_vq" + [(set (match_operand:VDQIW 0 "s_register_operand" "=w") + (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w") + (match_operand:SI 2 "immediate_operand" "i")] + QABSNEG))] + ... + ) + +A port might need to generate this pattern for a variable +:samp:`QABSNEG` value and a variable :samp:`VDQIW` mode. There are two +ways of doing this. The first is to build the rtx for the pattern +directly from C++ code; this is a valid technique and avoids any risk +of combinatorial explosion. The second is to prefix the instruction +name with the special character :samp:`@`, which tells GCC to generate +the four additional functions below. In each case, :samp:`{name}` is the +name of the instruction without the leading :samp:`@` character, +without the :samp:`<...>` placeholders, and with any underscore +before a :samp:`<...>` placeholder removed if keeping it would +lead to a double or trailing underscore. + +:samp:`insn_code maybe_code_for_{name} ({i1}, {i2}, ...)` + See whether replacing the first :samp:`<...>` placeholder with + iterator value :samp:`{i1}`, the second with iterator value :samp:`{i2}`, and + so on, gives a valid instruction. Return its code if so, otherwise + return ``CODE_FOR_nothing``. + +:samp:`insn_code code_for_{name} ({i1}, {i2}, ...)` + Same, but abort the compiler if the requested instruction does not exist. + +:samp:`rtx maybe_gen_{name} ({i1}, {i2}, ..., {op0}, {op1}, ...)` + Check for a valid instruction in the same way as + ``maybe_code_for_name``. If the instruction exists, + generate an instance of it using the operand values given by :samp:`{op0}`, + :samp:`{op1}`, and so on, otherwise return null. + +:samp:`rtx gen_{name} ({i1}, {i2}, ..., {op0}, {op1}, ...)` + Same, but abort the compiler if the requested instruction does not exist, + or if the instruction generator invoked the ``FAIL`` macro. + + For example, changing the pattern above to: + +.. code-block:: + + (define_insn "@neon_vq" + [(set (match_operand:VDQIW 0 "s_register_operand" "=w") + (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w") + (match_operand:SI 2 "immediate_operand" "i")] + QABSNEG))] + ... + ) + +would define the same patterns as before, but in addition would generate +the four functions below: + +.. code-block:: c++ + + insn_code maybe_code_for_neon_vq (int, machine_mode); + insn_code code_for_neon_vq (int, machine_mode); + rtx maybe_gen_neon_vq (int, machine_mode, rtx, rtx, rtx); + rtx gen_neon_vq (int, machine_mode, rtx, rtx, rtx); + +Calling :samp:`code_for_neon_vq (UNSPEC_VQABS, V8QImode)` +would then give ``CODE_FOR_neon_vqabsv8qi``. + +It is possible to have multiple :samp:`@` patterns with the same +name and same types of iterator. For example: + +.. code-block:: + + (define_insn "@some_arithmetic_op" + [(set (match_operand:INTEGER_MODES 0 "register_operand") ...)] + ... + ) + + (define_insn "@some_arithmetic_op" + [(set (match_operand:FLOAT_MODES 0 "register_operand") ...)] + ... + ) + +would produce a single set of functions that handles both +``INTEGER_MODES`` and ``FLOAT_MODES``. + +It is also possible for these :samp:`@` patterns to have different +numbers of operands from each other. For example, patterns with +a binary rtl code might take three operands (one output and two inputs) +while patterns with a ternary rtl code might take four operands (one +output and three inputs). This combination would produce separate +:samp:`maybe_gen_{name}` and :samp:`gen_{name}` functions for +each operand count, but it would still produce a single +:samp:`maybe_code_for_{name}` and a single :samp:`code_for_{name}`. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/machine-specific-peephole-optimizers.rst b/gcc/doc/gccint/machine-descriptions/machine-specific-peephole-optimizers.rst new file mode 100644 index 00000000000..99742b69fc9 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/machine-specific-peephole-optimizers.rst @@ -0,0 +1,330 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: peephole optimizer definitions, defining peephole optimizers + +.. _peephole-definitions: + +Machine-Specific Peephole Optimizers +************************************ + +In addition to instruction patterns the :samp:`md` file may contain +definitions of machine-specific peephole optimizations. + +The combiner does not notice certain peephole optimizations when the data +flow in the program does not suggest that it should try them. For example, +sometimes two consecutive insns related in purpose can be combined even +though the second one does not appear to use a register computed in the +first one. A machine-specific peephole optimizer can detect such +opportunities. + +There are two forms of peephole definitions that may be used. The +original ``define_peephole`` is run at assembly output time to +match insns and substitute assembly text. Use of ``define_peephole`` +is deprecated. + +A newer ``define_peephole2`` matches insns and substitutes new +insns. The ``peephole2`` pass is run after register allocation +but before scheduling, which may result in much better code for +targets that do scheduling. + +.. toctree:: + :maxdepth: 2 + + +.. index:: define_peephole + +.. _define_peephole: + +RTL to Text Peephole Optimizers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A definition looks like this: + +.. code-block:: + + (define_peephole + [insn-pattern-1 + insn-pattern-2 + ...] + "condition" + "template" + "optional-insn-attributes") + +The last string operand may be omitted if you are not using any +machine-specific information in this machine description. If present, +it must obey the same rules as in a ``define_insn``. + +In this skeleton, :samp:`{insn-pattern-1}` and so on are patterns to match +consecutive insns. The optimization applies to a sequence of insns when +:samp:`{insn-pattern-1}` matches the first one, :samp:`{insn-pattern-2}` matches +the next, and so on. + +Each of the insns matched by a peephole must also match a +``define_insn``. Peepholes are checked only at the last stage just +before code generation, and only optionally. Therefore, any insn which +would match a peephole but no ``define_insn`` will cause a crash in code +generation in an unoptimized compilation, or at various optimization +stages. + +The operands of the insns are matched with ``match_operands``, +``match_operator``, and ``match_dup``, as usual. What is not +usual is that the operand numbers apply to all the insn patterns in the +definition. So, you can check for identical operands in two insns by +using ``match_operand`` in one insn and ``match_dup`` in the +other. + +The operand constraints used in ``match_operand`` patterns do not have +any direct effect on the applicability of the peephole, but they will +be validated afterward, so make sure your constraints are general enough +to apply whenever the peephole matches. If the peephole matches +but the constraints are not satisfied, the compiler will crash. + +It is safe to omit constraints in all the operands of the peephole; or +you can write constraints which serve as a double-check on the criteria +previously tested. + +Once a sequence of insns matches the patterns, the :samp:`{condition}` is +checked. This is a C expression which makes the final decision whether to +perform the optimization (we do so if the expression is nonzero). If +:samp:`{condition}` is omitted (in other words, the string is empty) then the +optimization is applied to every sequence of insns that matches the +patterns. + +The defined peephole optimizations are applied after register allocation +is complete. Therefore, the peephole definition can check which +operands have ended up in which kinds of registers, just by looking at +the operands. + +.. index:: prev_active_insn + +The way to refer to the operands in :samp:`{condition}` is to write +``operands[i]`` for operand number :samp:`{i}` (as matched by +``(match_operand i ...)``). Use the variable ``insn`` +to refer to the last of the insns being matched; use +``prev_active_insn`` to find the preceding insns. + +.. index:: dead_or_set_p + +When optimizing computations with intermediate results, you can use +:samp:`{condition}` to match only when the intermediate results are not used +elsewhere. Use the C expression ``dead_or_set_p (insn, +op)``, where :samp:`{insn}` is the insn in which you expect the value +to be used for the last time (from the value of ``insn``, together +with use of ``prev_nonnote_insn``), and :samp:`{op}` is the intermediate +value (from ``operands[i]``). + +Applying the optimization means replacing the sequence of insns with one +new insn. The :samp:`{template}` controls ultimate output of assembler code +for this combined insn. It works exactly like the template of a +``define_insn``. Operand numbers in this template are the same ones +used in matching the original sequence of insns. + +The result of a defined peephole optimizer does not need to match any of +the insn patterns in the machine description; it does not even have an +opportunity to match them. The peephole optimizer definition itself serves +as the insn pattern to control how the insn is output. + +Defined peephole optimizers are run as assembler code is being output, +so the insns they produce are never combined or rearranged in any way. + +Here is an example, taken from the 68000 machine description: + +.. code-block:: + + (define_peephole + [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int 4))) + (set (match_operand:DF 0 "register_operand" "=f") + (match_operand:DF 1 "register_operand" "ad"))] + "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])" + { + rtx xoperands[2]; + xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1); + #ifdef MOTOROLA + output_asm_insn ("move.l %1,(sp)", xoperands); + output_asm_insn ("move.l %1,-(sp)", operands); + return "fmove.d (sp)+,%0"; + #else + output_asm_insn ("movel %1,sp@", xoperands); + output_asm_insn ("movel %1,sp@-", operands); + return "fmoved sp@+,%0"; + #endif + }) + +The effect of this optimization is to change + +.. code-block:: + + jbsr _foobar + addql #4,sp + movel d1,sp@- + movel d0,sp@- + fmoved sp@+,fp0 + +into + +.. code-block:: + + jbsr _foobar + movel d1,sp@ + movel d0,sp@- + fmoved sp@+,fp0 + +If a peephole matches a sequence including one or more jump insns, you must +take account of the flags such as ``CC_REVERSED`` which specify that the +condition codes are represented in an unusual manner. The compiler +automatically alters any ordinary conditional jumps which occur in such +situations, but the compiler cannot alter jumps which have been replaced by +peephole optimizations. So it is up to you to alter the assembler code +that the peephole produces. Supply C code to write the assembler output, +and in this C code check the condition code status flags and change the +assembler code as appropriate. +:samp:`{insn-pattern-1}` and so on look *almost* like the second +operand of ``define_insn``. There is one important difference: the +second operand of ``define_insn`` consists of one or more RTX's +enclosed in square brackets. Usually, there is only one: then the same +action can be written as an element of a ``define_peephole``. But +when there are multiple actions in a ``define_insn``, they are +implicitly enclosed in a ``parallel``. Then you must explicitly +write the ``parallel``, and the square brackets within it, in the +``define_peephole``. Thus, if an insn pattern looks like this, + +.. code-block:: + + (define_insn "divmodsi4" + [(set (match_operand:SI 0 "general_operand" "=d") + (div:SI (match_operand:SI 1 "general_operand" "0") + (match_operand:SI 2 "general_operand" "dmsK"))) + (set (match_operand:SI 3 "general_operand" "=d") + (mod:SI (match_dup 1) (match_dup 2)))] + "TARGET_68020" + "divsl%.l %2,%3:%0") + +then the way to mention this insn in a peephole is as follows: + +.. code-block:: + + (define_peephole + [... + (parallel + [(set (match_operand:SI 0 "general_operand" "=d") + (div:SI (match_operand:SI 1 "general_operand" "0") + (match_operand:SI 2 "general_operand" "dmsK"))) + (set (match_operand:SI 3 "general_operand" "=d") + (mod:SI (match_dup 1) (match_dup 2)))]) + ...] + ...) + +.. index:: define_peephole2 + +.. _define_peephole2: + +RTL to RTL Peephole Optimizers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The ``define_peephole2`` definition tells the compiler how to +substitute one sequence of instructions for another sequence, +what additional scratch registers may be needed and what their +lifetimes must be. + +.. code-block:: + + (define_peephole2 + [insn-pattern-1 + insn-pattern-2 + ...] + "condition" + [new-insn-pattern-1 + new-insn-pattern-2 + ...] + "preparation-statements") + +The definition is almost identical to ``define_split`` +(see :ref:`insn-splitting`) except that the pattern to match is not a +single instruction, but a sequence of instructions. + +It is possible to request additional scratch registers for use in the +output template. If appropriate registers are not free, the pattern +will simply not match. + +.. index:: match_scratch, match_dup + +Scratch registers are requested with a ``match_scratch`` pattern at +the top level of the input pattern. The allocated register (initially) will +be dead at the point requested within the original sequence. If the scratch +is used at more than a single point, a ``match_dup`` pattern at the +top level of the input pattern marks the last position in the input sequence +at which the register must be available. + +Here is an example from the IA-32 machine description: + +.. code-block:: + + (define_peephole2 + [(match_scratch:SI 2 "r") + (parallel [(set (match_operand:SI 0 "register_operand" "") + (match_operator:SI 3 "arith_or_logical_operator" + [(match_dup 0) + (match_operand:SI 1 "memory_operand" "")])) + (clobber (reg:CC 17))])] + "! optimize_size && ! TARGET_READ_MODIFY" + [(set (match_dup 2) (match_dup 1)) + (parallel [(set (match_dup 0) + (match_op_dup 3 [(match_dup 0) (match_dup 2)])) + (clobber (reg:CC 17))])] + "") + +This pattern tries to split a load from its use in the hopes that we'll be +able to schedule around the memory load latency. It allocates a single +``SImode`` register of class ``GENERAL_REGS`` (``"r"``) that needs +to be live only at the point just before the arithmetic. + +A real example requiring extended scratch lifetimes is harder to come by, +so here's a silly made-up example: + +.. code-block:: + + (define_peephole2 + [(match_scratch:SI 4 "r") + (set (match_operand:SI 0 "" "") (match_operand:SI 1 "" "")) + (set (match_operand:SI 2 "" "") (match_dup 1)) + (match_dup 4) + (set (match_operand:SI 3 "" "") (match_dup 1))] + "/* determine 1 does not overlap 0 and 2 */" + [(set (match_dup 4) (match_dup 1)) + (set (match_dup 0) (match_dup 4)) + (set (match_dup 2) (match_dup 4)) + (set (match_dup 3) (match_dup 4))] + "") + +There are two special macros defined for use in the preparation statements: +``DONE`` and ``FAIL``. Use them with a following semicolon, +as a statement. + +.. index:: DONE + +.. envvar:: DONE + + Use the ``DONE`` macro to end RTL generation for the peephole. The + only RTL insns generated as replacement for the matched input insn will + be those already emitted by explicit calls to ``emit_insn`` within + the preparation statements; the replacement pattern is not used. + +.. envvar:: FAIL + + Make the ``define_peephole2`` fail on this occasion. When a ``define_peephole2`` + fails, it means that the replacement was not truly available for the + particular inputs it was given. In that case, GCC may still apply a + later ``define_peephole2`` that also matches the given insn pattern. + (Note that this is different from ``define_split``, where ``FAIL`` + prevents the input insn from being split at all.) + +If the preparation falls through (invokes neither ``DONE`` nor +``FAIL``), then the ``define_peephole2`` uses the replacement +template. + +If we had not added the ``(match_dup 4)`` in the middle of the input +sequence, it might have been the case that the register we chose at the +beginning of the sequence is killed by the first or second ``set``. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/operand-constraints.rst b/gcc/doc/gccint/machine-descriptions/operand-constraints.rst new file mode 100644 index 00000000000..e94a67cd70b --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/operand-constraints.rst @@ -0,0 +1,426 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. Most of this node appears by itself (in a different place) even + when the INTERNALS flag is clear. Passages that require the internals + manual's context are conditionalized to appear only in the internals manual. + +.. index:: operand constraints, constraints + +.. _constraints: + +Operand Constraints +******************* + +Each ``match_operand`` in an instruction pattern can specify +constraints for the operands allowed. The constraints allow you to +fine-tune matching within the set of operands allowed by the +predicate. + +Constraints can say whether +an operand may be in a register, and which kinds of register; whether the +operand can be a memory reference, and which kinds of address; whether the +operand may be an immediate constant, and which possible values it may +have. Constraints can also require two operands to match. +Side-effects aren't allowed in operands of inline ``asm``, unless +:samp:`<` or :samp:`>` constraints are used, because there is no guarantee +that the side effects will happen exactly once in an instruction that can update +the addressing register. + +.. toctree:: + :maxdepth: 2 + + +.. include:: ../../../../doc/md.rst + + +.. index:: enabled + +.. _disable-insn-alternatives: + +Disable insn alternatives using the enabled attribute +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +There are three insn attributes that may be used to selectively disable +instruction alternatives: + +``enabled`` + Says whether an alternative is available on the current subtarget. + +``preferred_for_size`` + Says whether an enabled alternative should be used in code that is + optimized for size. + +``preferred_for_speed`` + Says whether an enabled alternative should be used in code that is + optimized for speed. + +All these attributes should use ``(const_int 1)`` to allow an alternative +or ``(const_int 0)`` to disallow it. The attributes must be a static +property of the subtarget; they cannot for example depend on the +current operands, on the current optimization level, on the location +of the insn within the body of a loop, on whether register allocation +has finished, or on the current compiler pass. + +The ``enabled`` attribute is a correctness property. It tells GCC to act +as though the disabled alternatives were never defined in the first place. +This is useful when adding new instructions to an existing pattern in +cases where the new instructions are only available for certain cpu +architecture levels (typically mapped to the ``-march=`` command-line +option). + +In contrast, the ``preferred_for_size`` and ``preferred_for_speed`` +attributes are strong optimization hints rather than correctness properties. +``preferred_for_size`` tells GCC which alternatives to consider when +adding or modifying an instruction that GCC wants to optimize for size. +``preferred_for_speed`` does the same thing for speed. Note that things +like code motion can lead to cases where code optimized for size uses +alternatives that are not preferred for size, and similarly for speed. + +Although ``define_insn`` s can in principle specify the ``enabled`` +attribute directly, it is often clearer to have subsiduary attributes +for each architectural feature of interest. The ``define_insn`` s +can then use these subsiduary attributes to say which alternatives +require which features. The example below does this for ``cpu_facility``. + +E.g. the following two patterns could easily be merged using the ``enabled`` +attribute: + +.. code-block:: + + (define_insn "*movdi_old" + [(set (match_operand:DI 0 "register_operand" "=d") + (match_operand:DI 1 "register_operand" " d"))] + "!TARGET_NEW" + "lgr %0,%1") + + (define_insn "*movdi_new" + [(set (match_operand:DI 0 "register_operand" "=d,f,d") + (match_operand:DI 1 "register_operand" " d,d,f"))] + "TARGET_NEW" + "@ + lgr %0,%1 + ldgr %0,%1 + lgdr %0,%1") + +to: + +.. code-block:: + + (define_insn "*movdi_combined" + [(set (match_operand:DI 0 "register_operand" "=d,f,d") + (match_operand:DI 1 "register_operand" " d,d,f"))] + "" + "@ + lgr %0,%1 + ldgr %0,%1 + lgdr %0,%1" + [(set_attr "cpu_facility" "*,new,new")]) + +with the ``enabled`` attribute defined like this: + +.. code-block:: + + (define_attr "cpu_facility" "standard,new" (const_string "standard")) + + (define_attr "enabled" "" + (cond [(eq_attr "cpu_facility" "standard") (const_int 1) + (and (eq_attr "cpu_facility" "new") + (ne (symbol_ref "TARGET_NEW") (const_int 0))) + (const_int 1)] + (const_int 0))) + +.. index:: defining constraints, constraints, defining + +.. _define-constraints: + +Defining Machine-Specific Constraints +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Machine-specific constraints fall into two categories: register and +non-register constraints. Within the latter category, constraints +which allow subsets of all possible memory or address operands should +be specially marked, to give ``reload`` more information. + +Machine-specific constraints can be given names of arbitrary length, +but they must be entirely composed of letters, digits, underscores +(:samp:`_`), and angle brackets (:samp:`< >`). Like C identifiers, they +must begin with a letter or underscore. + +In order to avoid ambiguity in operand constraint strings, no +constraint can have a name that begins with any other constraint's +name. For example, if ``x`` is defined as a constraint name, +``xy`` may not be, and vice versa. As a consequence of this rule, +no constraint may begin with one of the generic constraint letters: +:samp:`E F V X g i m n o p r s`. + +Register constraints correspond directly to register classes. +See :ref:`register-classes`. There is thus not much flexibility in their +definitions. + +.. index:: define_register_constraint + +MD Expression define_register_constraint name regclass docstringAll three arguments are string constants. +:samp:`{name}` is the name of the constraint, as it will appear in +``match_operand`` expressions. If :samp:`{name}` is a multi-letter +constraint its length shall be the same for all constraints starting +with the same letter. :samp:`{regclass}` can be either the +name of the corresponding register class (see :ref:`register-classes`), +or a C expression which evaluates to the appropriate register class. +If it is an expression, it must have no side effects, and it cannot +look at the operand. The usual use of expressions is to map some +register constraints to ``NO_REGS`` when the register class +is not available on a given subarchitecture. + +:samp:`{docstring}` is a sentence documenting the meaning of the +constraint. Docstrings are explained further below. + +Non-register constraints are more like predicates: the constraint +definition gives a boolean expression which indicates whether the +constraint matches. + +.. index:: define_constraint + +MD Expression define_constraint name docstring expThe :samp:`{name}` and :samp:`{docstring}` arguments are the same as for +``define_register_constraint``, but note that the docstring comes +immediately after the name for these expressions. :samp:`{exp}` is an RTL +expression, obeying the same rules as the RTL expressions in predicate +definitions. See :ref:`defining-predicates`, for details. If it +evaluates true, the constraint matches; if it evaluates false, it +doesn't. Constraint expressions should indicate which RTL codes they +might match, just like predicate expressions. + +``match_test`` C expressions have access to the +following variables: + +:samp:`{op}` + The RTL object defining the operand. + +:samp:`{mode}` + The machine mode of :samp:`{op}`. + +:samp:`{ival}` + :samp:`INTVAL ({op})`, if :samp:`{op}` is a ``const_int``. + +:samp:`{hval}` + :samp:`CONST_DOUBLE_HIGH ({op})`, if :samp:`{op}` is an integer + ``const_double``. + +:samp:`{lval}` + :samp:`CONST_DOUBLE_LOW ({op})`, if :samp:`{op}` is an integer + ``const_double``. + +:samp:`{rval}` + :samp:`CONST_DOUBLE_REAL_VALUE ({op})`, if :samp:`{op}` is a floating-point + ``const_double``. + +The :samp:`{*val}` variables should only be used once another piece of the +expression has verified that :samp:`{op}` is the appropriate kind of RTL +object. + +Most non-register constraints should be defined with +``define_constraint``. The remaining two definition expressions +are only appropriate for constraints that should be handled specially +by ``reload`` if they fail to match. + +.. index:: define_memory_constraint + +MD Expression define_memory_constraint name docstring expUse this expression for constraints that match a subset of all memory +operands: that is, ``reload`` can make them match by converting the +operand to the form :samp:`(mem (reg {X} ))`, where :samp:`{X}` is a +base register (from the register class specified by +``BASE_REG_CLASS``, see :ref:`register-classes`). + +For example, on the S/390, some instructions do not accept arbitrary +memory references, but only those that do not make use of an index +register. The constraint letter :samp:`Q` is defined to represent a +memory address of this type. If :samp:`Q` is defined with +``define_memory_constraint``, a :samp:`Q` constraint can handle any +memory operand, because ``reload`` knows it can simply copy the +memory address into a base register if required. This is analogous to +the way an :samp:`o` constraint can handle any memory operand. + +The syntax and semantics are otherwise identical to +``define_constraint``. + +.. index:: define_special_memory_constraint + +MD Expression define_special_memory_constraint name docstring expUse this expression for constraints that match a subset of all memory +operands: that is, ``reload`` cannot make them match by reloading +the address as it is described for ``define_memory_constraint`` or +such address reload is undesirable with the performance point of view. + +For example, ``define_special_memory_constraint`` can be useful if +specifically aligned memory is necessary or desirable for some insn +operand. + +The syntax and semantics are otherwise identical to +``define_memory_constraint``. + +.. index:: define_relaxed_memory_constraint + +MD Expression define_relaxed_memory_constraint name docstring expThe test expression in a ``define_memory_constraint`` can assume +that ``TARGET_LEGITIMATE_ADDRESS_P`` holds for the address inside +a ``mem`` rtx and so it does not need to test this condition itself. +In other words, a ``define_memory_constraint`` test of the form: + +.. code-block:: c++ + + (match_test "mem") + +is enough to test whether an rtx is a ``mem`` *and* whether +its address satisfies ``TARGET_MEM_CONSTRAINT`` (which is usually +:samp:`'m'`). Thus the conditions imposed by a ``define_memory_constraint`` +always apply on top of the conditions imposed by ``TARGET_MEM_CONSTRAINT``. + +However, it is sometimes useful to define memory constraints that allow +addresses beyond those accepted by ``TARGET_LEGITIMATE_ADDRESS_P``. +``define_relaxed_memory_constraint`` exists for this case. +The test expression in a ``define_relaxed_memory_constraint`` is +applied with no preconditions, so that the expression can determine +'from scratch' exactly which addresses are valid and which are not. + +The syntax and semantics are otherwise identical to +``define_memory_constraint``. + +.. index:: define_address_constraint + +MD Expression define_address_constraint name docstring expUse this expression for constraints that match a subset of all address +operands: that is, ``reload`` can make the constraint match by +converting the operand to the form :samp:`(reg {X} )`, again +with :samp:`{X}` a base register. + +Constraints defined with ``define_address_constraint`` can only be +used with the ``address_operand`` predicate, or machine-specific +predicates that work the same way. They are treated analogously to +the generic :samp:`p` constraint. + +The syntax and semantics are otherwise identical to +``define_constraint``. + +For historical reasons, names beginning with the letters :samp:`G H` +are reserved for constraints that match only ``const_double`` s, and +names beginning with the letters :samp:`I J K L M N O P` are reserved +for constraints that match only ``const_int`` s. This may change in +the future. For the time being, constraints with these names must be +written in a stylized form, so that ``genpreds`` can tell you did +it correctly: + +.. code-block:: + + (define_constraint "[GHIJKLMNOP]..." + "doc..." + (and (match_code "const_int") ; const_double for G/H + condition...)) ; usually a match_test + +.. the semicolons line up in the formatted manual + +It is fine to use names beginning with other letters for constraints +that match ``const_double`` s or ``const_int`` s. + +Each docstring in a constraint definition should be one or more complete +sentences, marked up in Texinfo format. *They are currently unused.* +In the future they will be copied into the GCC manual, in :ref:`machine-constraints`, replacing the hand-maintained tables currently found in +that section. Also, in the future the compiler may use this to give +more helpful diagnostics when poor choice of ``asm`` constraints +causes a reload failure. + +If you put the pseudo-Texinfo directive :samp:`@internal` at the +beginning of a docstring, then (in the future) it will appear only in +the internals manual's version of the machine-specific constraint tables. +Use this for constraints that should not appear in ``asm`` statements. + +.. index:: testing constraints, constraints, testing + +.. _c-constraint-interface: + +Testing constraints from C +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +It is occasionally useful to test a constraint from C code rather than +implicitly via the constraint string in a ``match_operand``. The +generated file :samp:`tm_p.h` declares a few interfaces for working +with constraints. At present these are defined for all constraints +except ``g`` (which is equivalent to ``general_operand``). + +Some valid constraint names are not valid C identifiers, so there is a +mangling scheme for referring to them from C. Constraint names that +do not contain angle brackets or underscores are left unchanged. +Underscores are doubled, each :samp:`<` is replaced with :samp:`_l`, and +each :samp:`>` with :samp:`_g`. Here are some examples: + +.. the @c's prevent double blank lines in the printed manual. + +.. list-table:: + + * - **Original** + - **Mangled** .. c + * - ``x`` + - ``x`` .. c + * - ``P42x`` + - ``P42x`` .. c + * - ``P4_x`` + - ``P4__x`` .. c + * - ``P4>x`` + - ``P4_gx`` .. c + * - ``P4>>`` + - ``P4_g_g`` .. c + * - ``P4_g>`` + - ``P4__g_g`` .. c + +Throughout this section, the variable :samp:`{c}` is either a constraint +in the abstract sense, or a constant from ``enum constraint_num`` ; +the variable :samp:`{m}` is a mangled constraint name (usually as part of +a larger identifier). + +.. index:: constraint_num + +Enum constraint_numFor each constraint except ``g``, there is a corresponding +enumeration constant: :samp:`CONSTRAINT_` plus the mangled name of the +constraint. Functions that take an ``enum constraint_num`` as an +argument expect one of these constants. + +.. function:: inline bool satisfies_constraint_m (rtx exp) + + For each non-register constraint :samp:`{m}` except ``g``, there is + one of these functions; it returns ``true`` if :samp:`{exp}` satisfies the + constraint. These functions are only visible if :samp:`rtl.h` was included + before :samp:`tm_p.h`. + +.. function:: bool constraint_satisfied_p (rtx exp, enum constraint_num c) + + Like the ``satisfies_constraint_m`` functions, but the + constraint to test is given as an argument, :samp:`{c}`. If :samp:`{c}` + specifies a register constraint, this function will always return + ``false``. + +.. function:: enum reg_class reg_class_for_constraint (enum constraint_num c) + + Returns the register class associated with :samp:`{c}`. If :samp:`{c}` is not + a register constraint, or those registers are not available for the + currently selected subtarget, returns ``NO_REGS``. + +Here is an example use of ``satisfies_constraint_m``. In +peephole optimizations (see :ref:`peephole-definitions`), operand +constraint strings are ignored, so if there are relevant constraints, +they must be tested in the C condition. In the example, the +optimization is applied if operand 2 does *not* satisfy the +:samp:`K` constraint. (This is a simplified version of a peephole +definition from the i386 machine description.) + +.. code-block:: + + (define_peephole2 + [(match_scratch:SI 3 "r") + (set (match_operand:SI 0 "register_operand" "") + (mult:SI (match_operand:SI 1 "memory_operand" "") + (match_operand:SI 2 "immediate_operand" "")))] + + "!satisfies_constraint_K (operands[2])" + + [(set (match_dup 3) (match_dup 1)) + (set (match_dup 0) (mult:SI (match_dup 3) (match_dup 2)))] + + "") \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/output-templates-and-operand-substitution.rst b/gcc/doc/gccint/machine-descriptions/output-templates-and-operand-substitution.rst new file mode 100644 index 00000000000..3edf4b9e094 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/output-templates-and-operand-substitution.rst @@ -0,0 +1,99 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: output templates, operand substitution, % in template, percent sign + +.. _output-template: + +Output Templates and Operand Substitution +***************************************** + +The :dfn:`output template` is a string which specifies how to output the +assembler code for an instruction pattern. Most of the template is a +fixed string which is output literally. The character :samp:`%` is used +to specify where to substitute an operand; it can also be used to +identify places where different variants of the assembler require +different syntax. + +In the simplest case, a :samp:`%` followed by a digit :samp:`{n}` says to output +operand :samp:`{n}` at that point in the string. + +:samp:`%` followed by a letter and a digit says to output an operand in an +alternate fashion. Four letters have standard, built-in meanings described +below. The machine description macro ``PRINT_OPERAND`` can define +additional letters with nonstandard meanings. + +:samp:`%c{digit}` can be used to substitute an operand that is a +constant value without the syntax that normally indicates an immediate +operand. + +:samp:`%n{digit}` is like :samp:`%c{digit}` except that the value of +the constant is negated before printing. + +:samp:`%a{digit}` can be used to substitute an operand as if it were a +memory reference, with the actual operand treated as the address. This may +be useful when outputting a 'load address' instruction, because often the +assembler syntax for such an instruction requires you to write the operand +as if it were a memory reference. + +:samp:`%l{digit}` is used to substitute a ``label_ref`` into a jump +instruction. + +:samp:`%=` outputs a number which is unique to each instruction in the +entire compilation. This is useful for making local labels to be +referred to more than once in a single template that generates multiple +assembler instructions. + +:samp:`%` followed by a punctuation character specifies a substitution that +does not use an operand. Only one case is standard: :samp:`%%` outputs a +:samp:`%` into the assembler code. Other nonstandard cases can be +defined in the ``PRINT_OPERAND`` macro. You must also define +which punctuation characters are valid with the +``PRINT_OPERAND_PUNCT_VALID_P`` macro. + +.. index:: \, backslash + +The template may generate multiple assembler instructions. Write the text +for the instructions, with :samp:`\\;` between them. + +.. index:: matching operands + +When the RTL contains two operands which are required by constraint to match +each other, the output template must refer only to the lower-numbered operand. +Matching operands are not always identical, and the rest of the compiler +arranges to put the proper RTL expression for printing into the lower-numbered +operand. + +One use of nonstandard letters or punctuation following :samp:`%` is to +distinguish between different assembler languages for the same machine; for +example, Motorola syntax versus MIT syntax for the 68000. Motorola syntax +requires periods in most opcode names, while MIT syntax does not. For +example, the opcode :samp:`movel` in MIT syntax is :samp:`move.l` in Motorola +syntax. The same file of patterns is used for both kinds of output syntax, +but the character sequence :samp:`%.` is used in each place where Motorola +syntax wants a period. The ``PRINT_OPERAND`` macro for Motorola syntax +defines the sequence to output a period; the macro for MIT syntax defines +it to do nothing. + +.. index:: # in template + +As a special case, a template consisting of the single character ``#`` +instructs the compiler to first split the insn, and then output the +resulting instructions separately. This helps eliminate redundancy in the +output templates. If you have a ``define_insn`` that needs to emit +multiple assembler instructions, and there is a matching ``define_split`` +already defined, then you can simply use ``#`` as the output template +instead of writing an output template that emits the multiple assembler +instructions. + +Note that ``#`` only has an effect while generating assembly code; +it does not affect whether a split occurs earlier. An associated +``define_split`` must exist and it must be suitable for use after +register allocation. + +If the macro ``ASSEMBLER_DIALECT`` is defined, you can use construct +of the form :samp:`{option0|option1|option2}` in the templates. These +describe multiple variants of assembler language syntax. +See :ref:`instruction-output`. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/overview-of-how-the-machine-description-is-used.rst b/gcc/doc/gccint/machine-descriptions/overview-of-how-the-machine-description-is-used.rst new file mode 100644 index 00000000000..b973e961a58 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/overview-of-how-the-machine-description-is-used.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _overview: + +Overview of How the Machine Description is Used +*********************************************** + +There are three main conversions that happen in the compiler: + +* The front end reads the source code and builds a parse tree. + +* The parse tree is used to generate an RTL insn list based on named + instruction patterns. + +* The insn list is matched against the RTL templates to produce assembler + code. + +For the generate pass, only the names of the insns matter, from either a +named ``define_insn`` or a ``define_expand``. The compiler will +choose the pattern with the right name and apply the operands according +to the documentation later in this chapter, without regard for the RTL +template or operand constraints. Note that the names the compiler looks +for are hard-coded in the compiler---it will ignore unnamed patterns and +patterns with names it doesn't know about, but if you don't provide a +named pattern it needs, it will abort. + +If a ``define_insn`` is used, the template given is inserted into the +insn list. If a ``define_expand`` is used, one of three things +happens, based on the condition logic. The condition logic may manually +create new insns for the insn list, say via ``emit_insn()``, and +invoke ``DONE``. For certain named patterns, it may invoke ``FAIL`` to tell the +compiler to use an alternate way of performing that task. If it invokes +neither ``DONE`` nor ``FAIL``, the template given in the pattern +is inserted, as if the ``define_expand`` were a ``define_insn``. + +Once the insn list is generated, various optimization passes convert, +replace, and rearrange the insns in the insn list. This is where the +``define_split`` and ``define_peephole`` patterns get used, for +example. + +Finally, the insn list's RTL is matched up with the RTL templates in the +``define_insn`` patterns, and those patterns are used to emit the +final assembly code. For this purpose, each named ``define_insn`` +acts like it's unnamed, since the names are ignored. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/predicates.rst b/gcc/doc/gccint/machine-descriptions/predicates.rst new file mode 100644 index 00000000000..0a1c8e26854 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/predicates.rst @@ -0,0 +1,343 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: predicates, operand predicates, operator predicates + +.. _predicates: + +Predicates +********** + +A predicate determines whether a ``match_operand`` or +``match_operator`` expression matches, and therefore whether the +surrounding instruction pattern will be used for that combination of +operands. GCC has a number of machine-independent predicates, and you +can define machine-specific predicates as needed. By convention, +predicates used with ``match_operand`` have names that end in +:samp:`_operand`, and those used with ``match_operator`` have names +that end in :samp:`_operator`. + +All predicates are boolean functions (in the mathematical sense) of +two arguments: the RTL expression that is being considered at that +position in the instruction pattern, and the machine mode that the +``match_operand`` or ``match_operator`` specifies. In this +section, the first argument is called :samp:`{op}` and the second argument +:samp:`{mode}`. Predicates can be called from C as ordinary two-argument +functions; this can be useful in output templates or other +machine-specific code. + +Operand predicates can allow operands that are not actually acceptable +to the hardware, as long as the constraints give reload the ability to +fix them up (see :ref:`constraints`). However, GCC will usually generate +better code if the predicates specify the requirements of the machine +instructions as closely as possible. Reload cannot fix up operands +that must be constants ('immediate operands'); you must use a +predicate that allows only constants, or else enforce the requirement +in the extra condition. + +.. index:: predicates and machine modes, normal predicates, special predicates + +Most predicates handle their :samp:`{mode}` argument in a uniform manner. +If :samp:`{mode}` is ``VOIDmode`` (unspecified), then :samp:`{op}` can have +any mode. If :samp:`{mode}` is anything else, then :samp:`{op}` must have the +same mode, unless :samp:`{op}` is a ``CONST_INT`` or integer +``CONST_DOUBLE``. These RTL expressions always have +``VOIDmode``, so it would be counterproductive to check that their +mode matches. Instead, predicates that accept ``CONST_INT`` and/or +integer ``CONST_DOUBLE`` check that the value stored in the +constant will fit in the requested mode. + +Predicates with this behavior are called :dfn:`normal`. +:command:`genrecog` can optimize the instruction recognizer based on +knowledge of how normal predicates treat modes. It can also diagnose +certain kinds of common errors in the use of normal predicates; for +instance, it is almost always an error to use a normal predicate +without specifying a mode. + +Predicates that do something different with their :samp:`{mode}` argument +are called :dfn:`special`. The generic predicates +``address_operand`` and ``pmode_register_operand`` are special +predicates. :command:`genrecog` does not do any optimizations or +diagnosis when special predicates are used. + +.. toctree:: + :maxdepth: 2 + + +.. index:: machine-independent predicates, generic predicates + +.. _machine-independent-predicates: + +Machine-Independent Predicates +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These are the generic predicates available to all back ends. They are +defined in :samp:`recog.cc`. The first category of predicates allow +only constant, or :dfn:`immediate`, operands. + +.. index:: immediate_operand + +Function immediate_operandThis predicate allows any sort of constant that fits in :samp:`{mode}`. +It is an appropriate choice for instructions that take operands that +must be constant. + +.. index:: const_int_operand + +Function const_int_operandThis predicate allows any ``CONST_INT`` expression that fits in +:samp:`{mode}`. It is an appropriate choice for an immediate operand that +does not allow a symbol or label. + +.. index:: const_double_operand + +Function const_double_operandThis predicate accepts any ``CONST_DOUBLE`` expression that has +exactly :samp:`{mode}`. If :samp:`{mode}` is ``VOIDmode``, it will also +accept ``CONST_INT``. It is intended for immediate floating point +constants. + +The second category of predicates allow only some kind of machine +register. + +.. index:: register_operand + +Function register_operandThis predicate allows any ``REG`` or ``SUBREG`` expression that +is valid for :samp:`{mode}`. It is often suitable for arithmetic +instruction operands on a RISC machine. + +.. index:: pmode_register_operand + +Function pmode_register_operandThis is a slight variant on ``register_operand`` which works around +a limitation in the machine-description reader. + +.. code-block:: c++ + + (match_operand n "pmode_register_operand" constraint) + +means exactly what + +.. code-block:: c++ + + (match_operand:P n "register_operand" constraint) + +would mean, if the machine-description reader accepted :samp:`:P` +mode suffixes. Unfortunately, it cannot, because ``Pmode`` is an +alias for some other mode, and might vary with machine-specific +options. See :ref:`misc`. + +.. index:: scratch_operand + +Function scratch_operandThis predicate allows hard registers and ``SCRATCH`` expressions, +but not pseudo-registers. It is used internally by ``match_scratch`` ; +it should not be used directly. + +The third category of predicates allow only some kind of memory reference. + +.. index:: memory_operand + +Function memory_operandThis predicate allows any valid reference to a quantity of mode +:samp:`{mode}` in memory, as determined by the weak form of +``GO_IF_LEGITIMATE_ADDRESS`` (see :ref:`addressing-modes`). + +.. index:: address_operand + +Function address_operandThis predicate is a little unusual; it allows any operand that is a +valid expression for the *address* of a quantity of mode +:samp:`{mode}`, again determined by the weak form of +``GO_IF_LEGITIMATE_ADDRESS``. To first order, if +:samp:`(mem: {mode} ( {exp ))` is acceptable to +``memory_operand``, then :samp:`{exp}` is acceptable to +``address_operand``. Note that :samp:`{exp}` does not necessarily have +the mode :samp:`{mode}`. + +.. index:: indirect_operand + +Function indirect_operandThis is a stricter form of ``memory_operand`` which allows only +memory references with a ``general_operand`` as the address +expression. New uses of this predicate are discouraged, because +``general_operand`` is very permissive, so it's hard to tell what +an ``indirect_operand`` does or does not allow. If a target has +different requirements for memory operands for different instructions, +it is better to define target-specific predicates which enforce the +hardware's requirements explicitly. + +.. index:: push_operand + +Function push_operandThis predicate allows a memory reference suitable for pushing a value +onto the stack. This will be a ``MEM`` which refers to +``stack_pointer_rtx``, with a side effect in its address expression +(see :ref:`incdec`); which one is determined by the +``STACK_PUSH_CODE`` macro (see :ref:`frame-layout`). + +.. index:: pop_operand + +Function pop_operandThis predicate allows a memory reference suitable for popping a value +off the stack. Again, this will be a ``MEM`` referring to +``stack_pointer_rtx``, with a side effect in its address +expression. However, this time ``STACK_POP_CODE`` is expected. + +The fourth category of predicates allow some combination of the above +operands. + +.. index:: nonmemory_operand + +Function nonmemory_operandThis predicate allows any immediate or register operand valid for :samp:`{mode}`. + +.. index:: nonimmediate_operand + +Function nonimmediate_operandThis predicate allows any register or memory operand valid for :samp:`{mode}`. + +.. index:: general_operand + +Function general_operandThis predicate allows any immediate, register, or memory operand +valid for :samp:`{mode}`. + +Finally, there are two generic operator predicates. + +.. index:: comparison_operator + +Function comparison_operatorThis predicate matches any expression which performs an arithmetic +comparison in :samp:`{mode}` ; that is, ``COMPARISON_P`` is true for the +expression code. + +.. index:: ordered_comparison_operator + +Function ordered_comparison_operatorThis predicate matches any expression which performs an arithmetic +comparison in :samp:`{mode}` and whose expression code is valid for integer +modes; that is, the expression code will be one of ``eq``, ``ne``, +``lt``, ``ltu``, ``le``, ``leu``, ``gt``, ``gtu``, +``ge``, ``geu``. + +.. index:: defining predicates, define_predicate, define_special_predicate + +.. _defining-predicates: + +Defining Machine-Specific Predicates +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Many machines have requirements for their operands that cannot be +expressed precisely using the generic predicates. You can define +additional predicates using ``define_predicate`` and +``define_special_predicate`` expressions. These expressions have +three operands: + +* The name of the predicate, as it will be referred to in + ``match_operand`` or ``match_operator`` expressions. + +* An RTL expression which evaluates to true if the predicate allows the + operand :samp:`{op}`, false if it does not. This expression can only use + the following RTL codes: + + .. envvar:: MATCH_OPERAND + + When written inside a predicate expression, a ``MATCH_OPERAND`` + expression evaluates to true if the predicate it names would allow + :samp:`{op}`. The operand number and constraint are ignored. Due to + limitations in :command:`genrecog`, you can only refer to generic + predicates and predicates that have already been defined. + + .. envvar:: MATCH_CODE + + This expression evaluates to true if :samp:`{op}` or a specified + subexpression of :samp:`{op}` has one of a given list of RTX codes. + + The first operand of this expression is a string constant containing a + comma-separated list of RTX code names (in lower case). These are the + codes for which the ``MATCH_CODE`` will be true. + + The second operand is a string constant which indicates what + subexpression of :samp:`{op}` to examine. If it is absent or the empty + string, :samp:`{op}` itself is examined. Otherwise, the string constant + must be a sequence of digits and/or lowercase letters. Each character + indicates a subexpression to extract from the current expression; for + the first character this is :samp:`{op}`, for the second and subsequent + characters it is the result of the previous character. A digit + :samp:`{n}` extracts :samp:`XEXP ({e}, {n})`; a letter :samp:`{l}` + extracts :samp:`XVECEXP ({e}, 0, {n})` where :samp:`{n}` is the + alphabetic ordinal of :samp:`{l}` (0 for 'a', 1 for 'b', and so on). The + ``MATCH_CODE`` then examines the RTX code of the subexpression + extracted by the complete string. It is not possible to extract + components of an ``rtvec`` that is not at position 0 within its RTX + object. + + .. envvar:: MATCH_TEST + + This expression has one operand, a string constant containing a C + expression. The predicate's arguments, :samp:`{op}` and :samp:`{mode}`, are + available with those names in the C expression. The ``MATCH_TEST`` + evaluates to true if the C expression evaluates to a nonzero value. + ``MATCH_TEST`` expressions must not have side effects. + + ``AND`` ``IOR`` ``NOT`` ``IF_THEN_ELSE`` + The basic :samp:`MATCH_` expressions can be combined using these + logical operators, which have the semantics of the C operators + :samp:`&&`, :samp:`||`, :samp:`!`, and :samp:`? :` respectively. As + in Common Lisp, you may give an ``AND`` or ``IOR`` expression an + arbitrary number of arguments; this has exactly the same effect as + writing a chain of two-argument ``AND`` or ``IOR`` expressions. + +* An optional block of C code, which should execute + :samp:`return true` if the predicate is found to match and + :samp:`return false` if it does not. It must not have any side + effects. The predicate arguments, :samp:`{op}` and :samp:`{mode}`, are + available with those names. + + If a code block is present in a predicate definition, then the RTL + expression must evaluate to true *and* the code block must + execute :samp:`return true` for the predicate to allow the operand. + The RTL expression is evaluated first; do not re-check anything in the + code block that was checked in the RTL expression. + +The program :command:`genrecog` scans ``define_predicate`` and +``define_special_predicate`` expressions to determine which RTX +codes are possibly allowed. You should always make this explicit in +the RTL predicate expression, using ``MATCH_OPERAND`` and +``MATCH_CODE``. + +Here is an example of a simple predicate definition, from the IA64 +machine description: + +.. code-block:: c++ + + ;; True if op is a SYMBOL_REF which refers to the sdata section. + (define_predicate "small_addr_symbolic_operand" + (and (match_code "symbol_ref") + (match_test "SYMBOL_REF_SMALL_ADDR_P (op)"))) + +And here is another, showing the use of the C block. + +.. code-block:: c++ + + ;; True if op is a register operand that is (or could be) a GR reg. + (define_predicate "gr_register_operand" + (match_operand 0 "register_operand") + { + unsigned int regno; + if (GET_CODE (op) == SUBREG) + op = SUBREG_REG (op); + + regno = REGNO (op); + return (regno >= FIRST_PSEUDO_REGISTER || GENERAL_REGNO_P (regno)); + }) + +Predicates written with ``define_predicate`` automatically include +a test that :samp:`{mode}` is ``VOIDmode``, or :samp:`{op}` has the same +mode as :samp:`{mode}`, or :samp:`{op}` is a ``CONST_INT`` or +``CONST_DOUBLE``. They do *not* check specifically for +integer ``CONST_DOUBLE``, nor do they test that the value of either +kind of constant fits in the requested mode. This is because +target-specific predicates that take constants usually have to do more +stringent value checks anyway. If you need the exact same treatment +of ``CONST_INT`` or ``CONST_DOUBLE`` that the generic predicates +provide, use a ``MATCH_OPERAND`` subexpression to call +``const_int_operand``, ``const_double_operand``, or +``immediate_operand``. + +Predicates written with ``define_special_predicate`` do not get any +automatic mode checks, and are treated as having special mode handling +by :command:`genrecog`. + +The program :command:`genpreds` is responsible for generating code to +test predicates. It also writes a header file containing function +declarations for all machine-specific predicates. It is not necessary +to declare these predicates in :samp:`{cpu}-protos.h`. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/rtl-template.rst b/gcc/doc/gccint/machine-descriptions/rtl-template.rst new file mode 100644 index 00000000000..2b69a78df12 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/rtl-template.rst @@ -0,0 +1,255 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RTL insn template, generating insns, insns, generating, recognizing insns, insns, recognizing + +.. _rtl-template: + +RTL Template +************ + +The RTL template is used to define which insns match the particular pattern +and how to find their operands. For named patterns, the RTL template also +says how to construct an insn from specified operands. + +Construction involves substituting specified operands into a copy of the +template. Matching involves determining the values that serve as the +operands in the insn being matched. Both of these activities are +controlled by special expression types that direct matching and +substitution of the operands. + +.. index:: match_operand + +:samp:`(match_operand:{m} {n} {predicate} {constraint})` + This expression is a placeholder for operand number :samp:`{n}` of + the insn. When constructing an insn, operand number :samp:`{n}` + will be substituted at this point. When matching an insn, whatever + appears at this position in the insn will be taken as operand + number :samp:`{n}` ; but it must satisfy :samp:`{predicate}` or this instruction + pattern will not match at all. + + Operand numbers must be chosen consecutively counting from zero in + each instruction pattern. There may be only one ``match_operand`` + expression in the pattern for each operand number. Usually operands + are numbered in the order of appearance in ``match_operand`` + expressions. In the case of a ``define_expand``, any operand numbers + used only in ``match_dup`` expressions have higher values than all + other operand numbers. + + :samp:`{predicate}` is a string that is the name of a function that + accepts two arguments, an expression and a machine mode. + See :ref:`predicates`. During matching, the function will be called with + the putative operand as the expression and :samp:`{m}` as the mode + argument (if :samp:`{m}` is not specified, ``VOIDmode`` will be used, + which normally causes :samp:`{predicate}` to accept any mode). If it + returns zero, this instruction pattern fails to match. + :samp:`{predicate}` may be an empty string; then it means no test is to be + done on the operand, so anything which occurs in this position is + valid. + + Most of the time, :samp:`{predicate}` will reject modes other than :samp:`{m}` ---but + not always. For example, the predicate ``address_operand`` uses + :samp:`{m}` as the mode of memory ref that the address should be valid for. + Many predicates accept ``const_int`` nodes even though their mode is + ``VOIDmode``. + + :samp:`{constraint}` controls reloading and the choice of the best register + class to use for a value, as explained later (see :ref:`constraints`). + If the constraint would be an empty string, it can be omitted. + + People are often unclear on the difference between the constraint and the + predicate. The predicate helps decide whether a given insn matches the + pattern. The constraint plays no role in this decision; instead, it + controls various decisions in the case of an insn which does match. + + .. index:: match_scratch + +:samp:`(match_scratch:{m} {n} {constraint})` + This expression is also a placeholder for operand number :samp:`{n}` + and indicates that operand must be a ``scratch`` or ``reg`` + expression. + + When matching patterns, this is equivalent to + + .. code-block:: + + (match_operand:m n "scratch_operand" constraint) + + but, when generating RTL, it produces a (``scratch`` : :samp:`{m}`) + expression. + + If the last few expressions in a ``parallel`` are ``clobber`` + expressions whose operands are either a hard register or + ``match_scratch``, the combiner can add or delete them when + necessary. See :ref:`side-effects`. + + .. index:: match_dup + +:samp:`(match_dup {n})` + This expression is also a placeholder for operand number :samp:`{n}`. + It is used when the operand needs to appear more than once in the + insn. + + In construction, ``match_dup`` acts just like ``match_operand`` : + the operand is substituted into the insn being constructed. But in + matching, ``match_dup`` behaves differently. It assumes that operand + number :samp:`{n}` has already been determined by a ``match_operand`` + appearing earlier in the recognition template, and it matches only an + identical-looking expression. + + Note that ``match_dup`` should not be used to tell the compiler that + a particular register is being used for two operands (example: + ``add`` that adds one register to another; the second register is + both an input operand and the output operand). Use a matching + constraint (see :ref:`simple-constraints`) for those. ``match_dup`` is for the cases where one + operand is used in two places in the template, such as an instruction + that computes both a quotient and a remainder, where the opcode takes + two input operands but the RTL template has to refer to each of those + twice; once for the quotient pattern and once for the remainder pattern. + + .. index:: match_operator + +:samp:`(match_operator:{m} {n} {predicate} [{operands}...])` + This pattern is a kind of placeholder for a variable RTL expression + code. + + When constructing an insn, it stands for an RTL expression whose + expression code is taken from that of operand :samp:`{n}`, and whose + operands are constructed from the patterns :samp:`{operands}`. + + When matching an expression, it matches an expression if the function + :samp:`{predicate}` returns nonzero on that expression *and* the + patterns :samp:`{operands}` match the operands of the expression. + + Suppose that the function ``commutative_operator`` is defined as + follows, to match any expression whose operator is one of the + commutative arithmetic operators of RTL and whose mode is :samp:`{mode}` : + + .. code-block:: + + int + commutative_integer_operator (x, mode) + rtx x; + machine_mode mode; + { + enum rtx_code code = GET_CODE (x); + if (GET_MODE (x) != mode) + return 0; + return (GET_RTX_CLASS (code) == RTX_COMM_ARITH + || code == EQ || code == NE); + } + + Then the following pattern will match any RTL expression consisting + of a commutative operator applied to two general operands: + + .. code-block:: + + (match_operator:SI 3 "commutative_operator" + [(match_operand:SI 1 "general_operand" "g") + (match_operand:SI 2 "general_operand" "g")]) + + Here the vector ``[operands...]`` contains two patterns + because the expressions to be matched all contain two operands. + + When this pattern does match, the two operands of the commutative + operator are recorded as operands 1 and 2 of the insn. (This is done + by the two instances of ``match_operand``.) Operand 3 of the insn + will be the entire commutative expression: use ``GET_CODE + (operands[3])`` to see which commutative operator was used. + + The machine mode :samp:`{m}` of ``match_operator`` works like that of + ``match_operand`` : it is passed as the second argument to the + predicate function, and that function is solely responsible for + deciding whether the expression to be matched 'has' that mode. + + When constructing an insn, argument 3 of the gen-function will specify + the operation (i.e. the expression code) for the expression to be + made. It should be an RTL expression, whose expression code is copied + into a new expression whose operands are arguments 1 and 2 of the + gen-function. The subexpressions of argument 3 are not used; + only its expression code matters. + + When ``match_operator`` is used in a pattern for matching an insn, + it usually best if the operand number of the ``match_operator`` + is higher than that of the actual operands of the insn. This improves + register allocation because the register allocator often looks at + operands 1 and 2 of insns to see if it can do register tying. + + There is no way to specify constraints in ``match_operator``. The + operand of the insn which corresponds to the ``match_operator`` + never has any constraints because it is never reloaded as a whole. + However, if parts of its :samp:`{operands}` are matched by + ``match_operand`` patterns, those parts may have constraints of + their own. + + .. index:: match_op_dup + +:samp:`(match_op_dup:{m} {n}[{operands}...])` + Like ``match_dup``, except that it applies to operators instead of + operands. When constructing an insn, operand number :samp:`{n}` will be + substituted at this point. But in matching, ``match_op_dup`` behaves + differently. It assumes that operand number :samp:`{n}` has already been + determined by a ``match_operator`` appearing earlier in the + recognition template, and it matches only an identical-looking + expression. + + .. index:: match_parallel + +:samp:`(match_parallel {n} {predicate} [{subpat}...])` + This pattern is a placeholder for an insn that consists of a + ``parallel`` expression with a variable number of elements. This + expression should only appear at the top level of an insn pattern. + + When constructing an insn, operand number :samp:`{n}` will be substituted at + this point. When matching an insn, it matches if the body of the insn + is a ``parallel`` expression with at least as many elements as the + vector of :samp:`{subpat}` expressions in the ``match_parallel``, if each + :samp:`{subpat}` matches the corresponding element of the ``parallel``, + *and* the function :samp:`{predicate}` returns nonzero on the + ``parallel`` that is the body of the insn. It is the responsibility + of the predicate to validate elements of the ``parallel`` beyond + those listed in the ``match_parallel``. + + A typical use of ``match_parallel`` is to match load and store + multiple expressions, which can contain a variable number of elements + in a ``parallel``. For example, + + .. code-block:: + + (define_insn "" + [(match_parallel 0 "load_multiple_operation" + [(set (match_operand:SI 1 "gpc_reg_operand" "=r") + (match_operand:SI 2 "memory_operand" "m")) + (use (reg:SI 179)) + (clobber (reg:SI 179))])] + "" + "loadm 0,0,%1,%2") + + This example comes from :samp:`a29k.md`. The function + ``load_multiple_operation`` is defined in :samp:`a29k.c` and checks + that subsequent elements in the ``parallel`` are the same as the + ``set`` in the pattern, except that they are referencing subsequent + registers and memory locations. + + An insn that matches this pattern might look like: + + .. code-block:: + + (parallel + [(set (reg:SI 20) (mem:SI (reg:SI 100))) + (use (reg:SI 179)) + (clobber (reg:SI 179)) + (set (reg:SI 21) + (mem:SI (plus:SI (reg:SI 100) + (const_int 4)))) + (set (reg:SI 22) + (mem:SI (plus:SI (reg:SI 100) + (const_int 8))))]) + + .. index:: match_par_dup + +:samp:`(match_par_dup {n} [{subpat}...])` + Like ``match_op_dup``, but for ``match_parallel`` instead of + ``match_operator``. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/rtl-templates-transformations.rst b/gcc/doc/gccint/machine-descriptions/rtl-templates-transformations.rst new file mode 100644 index 00000000000..824f6a7a188 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/rtl-templates-transformations.rst @@ -0,0 +1,225 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: define_subst + +.. _define-subst: + +RTL Templates Transformations +***************************** + +For some hardware architectures there are common cases when the RTL +templates for the instructions can be derived from the other RTL +templates using simple transformations. E.g., :samp:`i386.md` contains +an RTL template for the ordinary ``sub`` instruction--- +``*subsi_1``, and for the ``sub`` instruction with subsequent +zero-extension--- ``*subsi_1_zext``. Such cases can be easily +implemented by a single meta-template capable of generating a modified +case based on the initial one: + +.. index:: define_subst + +.. code-block:: + + (define_subst "name" + [input-template] + "condition" + [output-template]) + +:samp:`{input-template}` is a pattern describing the source RTL template, +which will be transformed. + +:samp:`{condition}` is a C expression that is conjunct with the condition +from the input-template to generate a condition to be used in the +output-template. + +:samp:`{output-template}` is a pattern that will be used in the resulting +template. + +``define_subst`` mechanism is tightly coupled with the notion of the +subst attribute (see :ref:`subst-iterators`). The use of +``define_subst`` is triggered by a reference to a subst attribute in +the transforming RTL template. This reference initiates duplication of +the source RTL template and substitution of the attributes with their +values. The source RTL template is left unchanged, while the copy is +transformed by ``define_subst``. This transformation can fail in the +case when the source RTL template is not matched against the +input-template of the ``define_subst``. In such case the copy is +deleted. + +``define_subst`` can be used only in ``define_insn`` and +``define_expand``, it cannot be used in other expressions (e.g. in +``define_insn_and_split``). + +.. toctree:: + :maxdepth: 2 + + +.. index:: define_subst + +.. _define-subst-example: + +define_subst Example +^^^^^^^^^^^^^^^^^^^^ + +To illustrate how ``define_subst`` works, let us examine a simple +template transformation. + +Suppose there are two kinds of instructions: one that touches flags and +the other that does not. The instructions of the second type could be +generated with the following ``define_subst`` : + +.. code-block:: + + (define_subst "add_clobber_subst" + [(set (match_operand:SI 0 "" "") + (match_operand:SI 1 "" ""))] + "" + [(set (match_dup 0) + (match_dup 1)) + (clobber (reg:CC FLAGS_REG))]) + +This ``define_subst`` can be applied to any RTL pattern containing +``set`` of mode SI and generates a copy with clobber when it is +applied. + +Assume there is an RTL template for a ``max`` instruction to be used +in ``define_subst`` mentioned above: + +.. code-block:: + + (define_insn "maxsi" + [(set (match_operand:SI 0 "register_operand" "=r") + (max:SI + (match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "register_operand" "r")))] + "" + "max\t{%2, %1, %0|%0, %1, %2}" + [...]) + +To mark the RTL template for ``define_subst`` application, +subst-attributes are used. They should be declared in advance: + +.. code-block:: + + (define_subst_attr "add_clobber_name" "add_clobber_subst" "_noclobber" "_clobber") + +Here :samp:`add_clobber_name` is the attribute name, +:samp:`add_clobber_subst` is the name of the corresponding +``define_subst``, the third argument (:samp:`_noclobber`) is the +attribute value that would be substituted into the unchanged version of +the source RTL template, and the last argument (:samp:`_clobber`) is the +value that would be substituted into the second, transformed, +version of the RTL template. + +Once the subst-attribute has been defined, it should be used in RTL +templates which need to be processed by the ``define_subst``. So, +the original RTL template should be changed: + +.. code-block:: + + (define_insn "maxsi" + [(set (match_operand:SI 0 "register_operand" "=r") + (max:SI + (match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "register_operand" "r")))] + "" + "max\t{%2, %1, %0|%0, %1, %2}" + [...]) + +The result of the ``define_subst`` usage would look like the following: + +.. code-block:: + + (define_insn "maxsi_noclobber" + [(set (match_operand:SI 0 "register_operand" "=r") + (max:SI + (match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "register_operand" "r")))] + "" + "max\t{%2, %1, %0|%0, %1, %2}" + [...]) + (define_insn "maxsi_clobber" + [(set (match_operand:SI 0 "register_operand" "=r") + (max:SI + (match_operand:SI 1 "register_operand" "r") + (match_operand:SI 2 "register_operand" "r"))) + (clobber (reg:CC FLAGS_REG))] + "" + "max\t{%2, %1, %0|%0, %1, %2}" + [...]) + +.. index:: define_subst + +.. _define-subst-pattern-matching: + +Pattern Matching in define_subst +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +All expressions, allowed in ``define_insn`` or ``define_expand``, +are allowed in the input-template of ``define_subst``, except +``match_par_dup``, ``match_scratch``, ``match_parallel``. The +meanings of expressions in the input-template were changed: + +``match_operand`` matches any expression (possibly, a subtree in +RTL-template), if modes of the ``match_operand`` and this expression +are the same, or mode of the ``match_operand`` is ``VOIDmode``, or +this expression is ``match_dup``, ``match_op_dup``. If the +expression is ``match_operand`` too, and predicate of +``match_operand`` from the input pattern is not empty, then the +predicates are compared. That can be used for more accurate filtering +of accepted RTL-templates. + +``match_operator`` matches common operators (like ``plus``, +``minus``), ``unspec``, ``unspec_volatile`` operators and +``match_operator`` s from the original pattern if the modes match and +``match_operator`` from the input pattern has the same number of +operands as the operator from the original pattern. + +.. index:: define_subst + +.. _define-subst-output-template: + +Generation of output template in define_subst +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If all necessary checks for ``define_subst`` application pass, a new +RTL-pattern, based on the output-template, is created to replace the old +template. Like in input-patterns, meanings of some RTL expressions are +changed when they are used in output-patterns of a ``define_subst``. +Thus, ``match_dup`` is used for copying the whole expression from the +original pattern, which matched corresponding ``match_operand`` from +the input pattern. + +``match_dup N`` is used in the output template to be replaced with +the expression from the original pattern, which matched +``match_operand N`` from the input pattern. As a consequence, +``match_dup`` cannot be used to point to ``match_operand`` s from +the output pattern, it should always refer to a ``match_operand`` +from the input pattern. If a ``match_dup N`` occurs more than once +in the output template, its first occurrence is replaced with the +expression from the original pattern, and the subsequent expressions +are replaced with ``match_dup N``, i.e., a reference to the first +expression. + +In the output template one can refer to the expressions from the +original pattern and create new ones. For instance, some operands could +be added by means of standard ``match_operand``. + +After replacing ``match_dup`` with some RTL-subtree from the original +pattern, it could happen that several ``match_operand`` s in the +output pattern have the same indexes. It is unknown, how many and what +indexes would be used in the expression which would replace +``match_dup``, so such conflicts in indexes are inevitable. To +overcome this issue, ``match_operands`` and ``match_operators``, +which were introduced into the output pattern, are renumerated when all +``match_dup`` s are replaced. + +Number of alternatives in ``match_operand`` s introduced into the +output template ``M`` could differ from the number of alternatives in +the original pattern ``N``, so in the resultant pattern there would +be ``N*M`` alternatives. Thus, constraints from the original pattern +would be duplicated ``N`` times, constraints from the output pattern +would be duplicated ``M`` times, producing all possible combinations. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/standard-pattern-names-for-generation.rst b/gcc/doc/gccint/machine-descriptions/standard-pattern-names-for-generation.rst new file mode 100644 index 00000000000..116f0a83ec9 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/standard-pattern-names-for-generation.rst @@ -0,0 +1,3413 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: standard pattern names, pattern names, names, pattern + +.. _standard-names: + +Standard Pattern Names For Generation +************************************* + +Here is a table of the instruction names that are meaningful in the RTL +generation pass of the compiler. Giving one of these names to an +instruction pattern tells the RTL generation pass that it can use the +pattern to accomplish a certain task. + +.. index:: movm instruction pattern + +movm + Here :samp:`{m}` stands for a two-letter machine mode name, in lowercase. + This instruction pattern moves data with that machine mode from operand + 1 to operand 0. For example, :samp:`movsi` moves full-word data. + + If operand 0 is a ``subreg`` with mode :samp:`{m}` of a register whose + own mode is wider than :samp:`{m}`, the effect of this instruction is + to store the specified value in the part of the register that corresponds + to mode :samp:`{m}`. Bits outside of :samp:`{m}`, but which are within the + same target word as the ``subreg`` are undefined. Bits which are + outside the target word are left unchanged. + + This class of patterns is special in several ways. First of all, each + of these names up to and including full word size *must* be defined, + because there is no other way to copy a datum from one place to another. + If there are patterns accepting operands in larger modes, + :samp:`mov{m}` must be defined for integer modes of those sizes. + + Second, these patterns are not used solely in the RTL generation pass. + Even the reload pass can generate move insns to copy values from stack + slots into temporary registers. When it does so, one of the operands is + a hard register and the other is an operand that can need to be reloaded + into a register. + + .. index:: force_reg + + Therefore, when given such a pair of operands, the pattern must generate + RTL which needs no reloading and needs no temporary registers---no + registers other than the operands. For example, if you support the + pattern with a ``define_expand``, then in such a case the + ``define_expand`` mustn't call ``force_reg`` or any other such + function which might generate new pseudo registers. + + This requirement exists even for subword modes on a RISC machine where + fetching those modes from memory normally requires several insns and + some temporary registers. + + .. index:: change_address + + During reload a memory reference with an invalid address may be passed + as an operand. Such an address will be replaced with a valid address + later in the reload pass. In this case, nothing may be done with the + address except to use it as it stands. If it is copied, it will not be + replaced with a valid address. No attempt should be made to make such + an address into a valid address and no routine (such as + ``change_address``) that will do so may be called. Note that + ``general_operand`` will fail when applied to such an address. + + .. index:: reload_in_progress + + The global variable ``reload_in_progress`` (which must be explicitly + declared if required) can be used to determine whether such special + handling is required. + + The variety of operands that have reloads depends on the rest of the + machine description, but typically on a RISC machine these can only be + pseudo registers that did not get hard registers, while on other + machines explicit memory references will get optional reloads. + + If a scratch register is required to move an object to or from memory, + it can be allocated using ``gen_reg_rtx`` prior to life analysis. + + If there are cases which need scratch registers during or after reload, + you must provide an appropriate secondary_reload target hook. + + .. index:: can_create_pseudo_p + + The macro ``can_create_pseudo_p`` can be used to determine if it + is unsafe to create new pseudo registers. If this variable is nonzero, then + it is unsafe to call ``gen_reg_rtx`` to allocate a new pseudo. + + The constraints on a :samp:`mov{m}` must permit moving any hard + register to any other hard register provided that + ``TARGET_HARD_REGNO_MODE_OK`` permits mode :samp:`{m}` in both registers and + ``TARGET_REGISTER_MOVE_COST`` applied to their classes returns a value + of 2. + + It is obligatory to support floating point :samp:`mov{m}` + instructions into and out of any registers that can hold fixed point + values, because unions and structures (which have modes ``SImode`` or + ``DImode``) can be in those registers and they may have floating + point members. + + There may also be a need to support fixed point :samp:`mov{m}` + instructions in and out of floating point registers. Unfortunately, I + have forgotten why this was so, and I don't know whether it is still + true. If ``TARGET_HARD_REGNO_MODE_OK`` rejects fixed point values in + floating point registers, then the constraints of the fixed point + :samp:`mov{m}` instructions must be designed to avoid ever trying to + reload into a floating point register. + + .. index:: reload_in instruction pattern, reload_out instruction pattern + +reload_inm reload_outm + These named patterns have been obsoleted by the target hook + ``secondary_reload``. + + Like :samp:`mov{m}`, but used when a scratch register is required to + move between operand 0 and operand 1. Operand 2 describes the scratch + register. See the discussion of the ``SECONDARY_RELOAD_CLASS`` + macro in see :ref:`register-classes`. + + There are special restrictions on the form of the ``match_operand`` s + used in these patterns. First, only the predicate for the reload + operand is examined, i.e., ``reload_in`` examines operand 1, but not + the predicates for operand 0 or 2. Second, there may be only one + alternative in the constraints. Third, only a single register class + letter may be used for the constraint; subsequent constraint letters + are ignored. As a special exception, an empty constraint string + matches the ``ALL_REGS`` register class. This may relieve ports + of the burden of defining an ``ALL_REGS`` constraint letter just + for these patterns. + + .. index:: movstrictm instruction pattern + +movstrictm + Like :samp:`mov{m}` except that if operand 0 is a ``subreg`` + with mode :samp:`{m}` of a register whose natural mode is wider, + the :samp:`movstrict{m}` instruction is guaranteed not to alter + any of the register except the part which belongs to mode :samp:`{m}`. + + .. index:: movmisalignm instruction pattern + +movmisalignm + This variant of a move pattern is designed to load or store a value + from a memory address that is not naturally aligned for its mode. + For a store, the memory will be in operand 0; for a load, the memory + will be in operand 1. The other operand is guaranteed not to be a + memory, so that it's easy to tell whether this is a load or store. + + This pattern is used by the autovectorizer, and when expanding a + ``MISALIGNED_INDIRECT_REF`` expression. + + .. index:: load_multiple instruction pattern + +load_multiple + Load several consecutive memory locations into consecutive registers. + Operand 0 is the first of the consecutive registers, operand 1 + is the first memory location, and operand 2 is a constant: the + number of consecutive registers. + + Define this only if the target machine really has such an instruction; + do not define this if the most efficient way of loading consecutive + registers from memory is to do them one at a time. + + On some machines, there are restrictions as to which consecutive + registers can be stored into memory, such as particular starting or + ending register numbers or only a range of valid counts. For those + machines, use a ``define_expand`` (see :ref:`expander-definitions`) + and make the pattern fail if the restrictions are not met. + + Write the generated insn as a ``parallel`` with elements being a + ``set`` of one register from the appropriate memory location (you may + also need ``use`` or ``clobber`` elements). Use a + ``match_parallel`` (see :ref:`rtl-template`) to recognize the insn. See + :samp:`rs6000.md` for examples of the use of this insn pattern. + + .. index:: store_multiple instruction pattern + +store_multiple + Similar to :samp:`load_multiple`, but store several consecutive registers + into consecutive memory locations. Operand 0 is the first of the + consecutive memory locations, operand 1 is the first register, and + operand 2 is a constant: the number of consecutive registers. + + .. index:: vec_load_lanesmn instruction pattern + +vec_load_lanesmn + Perform an interleaved load of several vectors from memory operand 1 + into register operand 0. Both operands have mode :samp:`{m}`. The register + operand is viewed as holding consecutive vectors of mode :samp:`{n}`, + while the memory operand is a flat array that contains the same number + of elements. The operation is equivalent to: + + .. code-block:: c++ + + int c = GET_MODE_SIZE (m) / GET_MODE_SIZE (n); + for (j = 0; j < GET_MODE_NUNITS (n); j++) + for (i = 0; i < c; i++) + operand0[i][j] = operand1[j * c + i]; + + For example, :samp:`vec_load_lanestiv4hi` loads 8 16-bit values + from memory into a register of mode :samp:`TI`. The register + contains two consecutive vectors of mode :samp:`V4HI`. + + This pattern can only be used if: + + .. code-block:: c++ + + TARGET_ARRAY_MODE_SUPPORTED_P (n, c) + + is true. GCC assumes that, if a target supports this kind of + instruction for some mode :samp:`{n}`, it also supports unaligned + loads for vectors of mode :samp:`{n}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: vec_mask_load_lanesmn instruction pattern + +vec_mask_load_lanesmn + Like :samp:`vec_load_lanes{m}{n}`, but takes an additional + mask operand (operand 2) that specifies which elements of the destination + vectors should be loaded. Other elements of the destination + vectors are set to zero. The operation is equivalent to: + + .. code-block:: c++ + + int c = GET_MODE_SIZE (m) / GET_MODE_SIZE (n); + for (j = 0; j < GET_MODE_NUNITS (n); j++) + if (operand2[j]) + for (i = 0; i < c; i++) + operand0[i][j] = operand1[j * c + i]; + else + for (i = 0; i < c; i++) + operand0[i][j] = 0; + + This pattern is not allowed to ``FAIL``. + + .. index:: vec_store_lanesmn instruction pattern + +vec_store_lanesmn + Equivalent to :samp:`vec_load_lanes{m}{n}`, with the memory + and register operands reversed. That is, the instruction is + equivalent to: + + .. code-block:: c++ + + int c = GET_MODE_SIZE (m) / GET_MODE_SIZE (n); + for (j = 0; j < GET_MODE_NUNITS (n); j++) + for (i = 0; i < c; i++) + operand0[j * c + i] = operand1[i][j]; + + for a memory operand 0 and register operand 1. + + This pattern is not allowed to ``FAIL``. + + .. index:: vec_mask_store_lanesmn instruction pattern + +vec_mask_store_lanesmn + Like :samp:`vec_store_lanes{m}{n}`, but takes an additional + mask operand (operand 2) that specifies which elements of the source + vectors should be stored. The operation is equivalent to: + + .. code-block:: c++ + + int c = GET_MODE_SIZE (m) / GET_MODE_SIZE (n); + for (j = 0; j < GET_MODE_NUNITS (n); j++) + if (operand2[j]) + for (i = 0; i < c; i++) + operand0[j * c + i] = operand1[i][j]; + + This pattern is not allowed to ``FAIL``. + + .. index:: gather_loadmn instruction pattern + +gather_loadmn + Load several separate memory locations into a vector of mode :samp:`{m}`. + Operand 1 is a scalar base address and operand 2 is a vector of mode :samp:`{n}` + containing offsets from that base. Operand 0 is a destination vector with + the same number of elements as :samp:`{n}`. For each element index :samp:`{i}` : + + * extend the offset element :samp:`{i}` to address width, using zero + extension if operand 3 is 1 and sign extension if operand 3 is zero; + + * multiply the extended offset by operand 4; + + * add the result to the base; and + + * load the value at that address into element :samp:`{i}` of operand 0. + + The value of operand 3 does not matter if the offsets are already + address width. + + .. index:: mask_gather_loadmn instruction pattern + +mask_gather_loadmn + Like :samp:`gather_load{m}{n}`, but takes an extra mask operand as + operand 5. Bit :samp:`{i}` of the mask is set if element :samp:`{i}` + of the result should be loaded from memory and clear if element :samp:`{i}` + of the result should be set to zero. + + .. index:: scatter_storemn instruction pattern + +scatter_storemn + Store a vector of mode :samp:`{m}` into several distinct memory locations. + Operand 0 is a scalar base address and operand 1 is a vector of mode + :samp:`{n}` containing offsets from that base. Operand 4 is the vector of + values that should be stored, which has the same number of elements as + :samp:`{n}`. For each element index :samp:`{i}` : + + * extend the offset element :samp:`{i}` to address width, using zero + extension if operand 2 is 1 and sign extension if operand 2 is zero; + + * multiply the extended offset by operand 3; + + * add the result to the base; and + + * store element :samp:`{i}` of operand 4 to that address. + + The value of operand 2 does not matter if the offsets are already + address width. + + .. index:: mask_scatter_storemn instruction pattern + +mask_scatter_storemn + Like :samp:`scatter_store{m}{n}`, but takes an extra mask operand as + operand 5. Bit :samp:`{i}` of the mask is set if element :samp:`{i}` + of the result should be stored to memory. + + .. index:: vec_setm instruction pattern + +vec_setm + Set given field in the vector value. Operand 0 is the vector to modify, + operand 1 is new value of field and operand 2 specify the field index. + + .. index:: vec_extractmn instruction pattern + +vec_extractmn + Extract given field from the vector value. Operand 1 is the vector, operand 2 + specify field index and operand 0 place to store value into. The + :samp:`{n}` mode is the mode of the field or vector of fields that should be + extracted, should be either element mode of the vector mode :samp:`{m}`, or + a vector mode with the same element mode and smaller number of elements. + If :samp:`{n}` is a vector mode, the index is counted in units of that mode. + + .. index:: vec_initmn instruction pattern + +vec_initmn + Initialize the vector to given values. Operand 0 is the vector to initialize + and operand 1 is parallel containing values for individual fields. The + :samp:`{n}` mode is the mode of the elements, should be either element mode of + the vector mode :samp:`{m}`, or a vector mode with the same element mode and + smaller number of elements. + + .. index:: vec_duplicatem instruction pattern + +vec_duplicatem + Initialize vector output operand 0 so that each element has the value given + by scalar input operand 1. The vector has mode :samp:`{m}` and the scalar has + the mode appropriate for one element of :samp:`{m}`. + + This pattern only handles duplicates of non-constant inputs. Constant + vectors go through the ``movm`` pattern instead. + + This pattern is not allowed to ``FAIL``. + + .. index:: vec_seriesm instruction pattern + +vec_seriesm + Initialize vector output operand 0 so that element :samp:`{i}` is equal to + operand 1 plus :samp:`{i}` times operand 2. In other words, create a linear + series whose base value is operand 1 and whose step is operand 2. + + The vector output has mode :samp:`{m}` and the scalar inputs have the mode + appropriate for one element of :samp:`{m}`. This pattern is not used for + floating-point vectors, in order to avoid having to specify the + rounding behavior for :samp:`{i}` > 1. + + This pattern is not allowed to ``FAIL``. + + .. index:: while_ultmn instruction pattern + +while_ultmn + Set operand 0 to a mask that is true while incrementing operand 1 + gives a value that is less than operand 2, for a vector length up to operand 3. + Operand 0 has mode :samp:`{n}` and operands 1 and 2 are scalar integers of mode + :samp:`{m}`. Operand 3 should be omitted when :samp:`{n}` is a vector mode, and + a ``CONST_INT`` otherwise. The operation for vector modes is equivalent to: + + .. code-block:: c++ + + operand0[0] = operand1 < operand2; + for (i = 1; i < GET_MODE_NUNITS (n); i++) + operand0[i] = operand0[i - 1] && (operand1 + i < operand2); + + And for non-vector modes the operation is equivalent to: + + .. code-block:: c++ + + operand0[0] = operand1 < operand2; + for (i = 1; i < operand3; i++) + operand0[i] = operand0[i - 1] && (operand1 + i < operand2); + + .. index:: check_raw_ptrsm instruction pattern + +check_raw_ptrsm + Check whether, given two pointers :samp:`{a}` and :samp:`{b}` and a length :samp:`{len}`, + a write of :samp:`{len}` bytes at :samp:`{a}` followed by a read of :samp:`{len}` bytes + at :samp:`{b}` can be split into interleaved byte accesses + :samp:`{a}[0], {b}[0], {a}[1], {b}[1], ...` + without affecting the dependencies between the bytes. Set operand 0 + to true if the split is possible and false otherwise. + + Operands 1, 2 and 3 provide the values of :samp:`{a}`, :samp:`{b}` and :samp:`{len}` + respectively. Operand 4 is a constant integer that provides the known + common alignment of :samp:`{a}` and :samp:`{b}`. All inputs have mode :samp:`{m}`. + + This split is possible if: + + .. code-block:: c++ + + a == b || a + len <= b || b + len <= a + + You should only define this pattern if the target has a way of accelerating + the test without having to do the individual comparisons. + + .. index:: check_war_ptrsm instruction pattern + +check_war_ptrsm + Like :samp:`check_raw_ptrs{m}`, but with the read and write swapped round. + The split is possible in this case if: + + .. code-block:: c++ + + b <= a || a + len <= b + + .. index:: vec_cmpmn instruction pattern + +vec_cmpmn + Output a vector comparison. Operand 0 of mode :samp:`{n}` is the destination for + predicate in operand 1 which is a signed vector comparison with operands of + mode :samp:`{m}` in operands 2 and 3. Predicate is computed by element-wise + evaluation of the vector comparison with a truth value of all-ones and a false + value of all-zeros. + + .. index:: vec_cmpumn instruction pattern + +vec_cmpumn + Similar to ``vec_cmpmn`` but perform unsigned vector comparison. + + .. index:: vec_cmpeqmn instruction pattern + +vec_cmpeqmn + Similar to ``vec_cmpmn`` but perform equality or non-equality + vector comparison only. If ``vec_cmpmn`` + or ``vec_cmpumn`` instruction pattern is supported, + it will be preferred over ``vec_cmpeqmn``, so there is + no need to define this instruction pattern if the others are supported. + + .. index:: vcondmn instruction pattern + +vcondmn + Output a conditional vector move. Operand 0 is the destination to + receive a combination of operand 1 and operand 2, which are of mode :samp:`{m}`, + dependent on the outcome of the predicate in operand 3 which is a signed + vector comparison with operands of mode :samp:`{n}` in operands 4 and 5. The + modes :samp:`{m}` and :samp:`{n}` should have the same size. Operand 0 + will be set to the value :samp:`{op1}` & :samp:`{msk}` | :samp:`{op2}` & ~ :samp:`{msk}` + where :samp:`{msk}` is computed by element-wise evaluation of the vector + comparison with a truth value of all-ones and a false value of all-zeros. + + .. index:: vcondumn instruction pattern + +vcondumn + Similar to ``vcondmn`` but performs unsigned vector + comparison. + + .. index:: vcondeqmn instruction pattern + +vcondeqmn + Similar to ``vcondmn`` but performs equality or + non-equality vector comparison only. If ``vcondmn`` + or ``vcondumn`` instruction pattern is supported, + it will be preferred over ``vcondeqmn``, so there is + no need to define this instruction pattern if the others are supported. + + .. index:: vcond_mask_mn instruction pattern + +vcond_mask_mn + Similar to ``vcondmn`` but operand 3 holds a pre-computed + result of vector comparison. + + .. index:: maskloadmn instruction pattern + +maskloadmn + Perform a masked load of vector from memory operand 1 of mode :samp:`{m}` + into register operand 0. Mask is provided in register operand 2 of + mode :samp:`{n}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: maskstoremn instruction pattern + +maskstoremn + Perform a masked store of vector from register operand 1 of mode :samp:`{m}` + into memory operand 0. Mask is provided in register operand 2 of + mode :samp:`{n}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: len_load_m instruction pattern + +len_load_m + Load (operand 2 - operand 3) elements from vector memory operand 1 + into vector register operand 0, setting the other elements of + operand 0 to undefined values. Operands 0 and 1 have mode :samp:`{m}`, + which must be a vector mode. Operand 2 has whichever integer mode the + target prefers. Operand 3 conceptually has mode ``QI``. + + Operand 2 can be a variable or a constant amount. Operand 3 specifies a + constant bias: it is either a constant 0 or a constant -1. The predicate on + operand 3 must only accept the bias values that the target actually supports. + GCC handles a bias of 0 more efficiently than a bias of -1. + + If (operand 2 - operand 3) exceeds the number of elements in mode + :samp:`{m}`, the behavior is undefined. + + If the target prefers the length to be measured in bytes rather than + elements, it should only implement this pattern for vectors of ``QI`` + elements. + + This pattern is not allowed to ``FAIL``. + + .. index:: len_store_m instruction pattern + +len_store_m + Store (operand 2 - operand 3) vector elements from vector register operand 1 + into memory operand 0, leaving the other elements of + operand 0 unchanged. Operands 0 and 1 have mode :samp:`{m}`, which must be + a vector mode. Operand 2 has whichever integer mode the target prefers. + Operand 3 conceptually has mode ``QI``. + + Operand 2 can be a variable or a constant amount. Operand 3 specifies a + constant bias: it is either a constant 0 or a constant -1. The predicate on + operand 3 must only accept the bias values that the target actually supports. + GCC handles a bias of 0 more efficiently than a bias of -1. + + If (operand 2 - operand 3) exceeds the number of elements in mode + :samp:`{m}`, the behavior is undefined. + + If the target prefers the length to be measured in bytes + rather than elements, it should only implement this pattern for vectors + of ``QI`` elements. + + This pattern is not allowed to ``FAIL``. + + .. index:: vec_permm instruction pattern + +vec_permm + Output a (variable) vector permutation. Operand 0 is the destination + to receive elements from operand 1 and operand 2, which are of mode + :samp:`{m}`. Operand 3 is the :dfn:`selector`. It is an integral mode + vector of the same width and number of elements as mode :samp:`{m}`. + + The input elements are numbered from 0 in operand 1 through + 2\* :samp:`{N}` -1 in operand 2. The elements of the selector must + be computed modulo 2\* :samp:`{N}`. Note that if + ``rtx_equal_p(operand1, operand2)``, this can be implemented + with just operand 1 and selector elements modulo :samp:`{N}`. + + In order to make things easy for a number of targets, if there is no + :samp:`vec_perm` pattern for mode :samp:`{m}`, but there is for mode :samp:`{q}` + where :samp:`{q}` is a vector of ``QImode`` of the same width as :samp:`{m}`, + the middle-end will lower the mode :samp:`{m}` ``VEC_PERM_EXPR`` to + mode :samp:`{q}`. + + See also ``TARGET_VECTORIZER_VEC_PERM_CONST``, which performs + the analogous operation for constant selectors. + + .. index:: pushm1 instruction pattern + +pushm1 + Output a push instruction. Operand 0 is value to push. Used only when + ``PUSH_ROUNDING`` is defined. For historical reason, this pattern may be + missing and in such case an ``mov`` expander is used instead, with a + ``MEM`` expression forming the push operation. The ``mov`` expander + method is deprecated. + + .. index:: addm3 instruction pattern + +addm3 + Add operand 2 and operand 1, storing the result in operand 0. All operands + must have mode :samp:`{m}`. This can be used even on two-address machines, by + means of constraints requiring operands 1 and 0 to be the same location. + + .. index:: ssaddm3 instruction pattern, usaddm3 instruction pattern, subm3 instruction pattern, sssubm3 instruction pattern, ussubm3 instruction pattern, mulm3 instruction pattern, ssmulm3 instruction pattern, usmulm3 instruction pattern, divm3 instruction pattern, ssdivm3 instruction pattern, udivm3 instruction pattern, usdivm3 instruction pattern, modm3 instruction pattern, umodm3 instruction pattern, uminm3 instruction pattern, umaxm3 instruction pattern, andm3 instruction pattern, iorm3 instruction pattern, xorm3 instruction pattern + +:samp:`ssadd{m}3`, :samp:`usadd{m}3` :samp:`sub{m}3`, :samp:`sssub{m}3`, :samp:`ussub{m}3` :samp:`mul{m}3`, :samp:`ssmul{m}3`, :samp:`usmul{m}3` :samp:`div{m}3`, :samp:`ssdiv{m}3` :samp:`udiv{m}3`, :samp:`usdiv{m}3` :samp:`mod{m}3`, :samp:`umod{m}3` :samp:`umin{m}3`, :samp:`umax{m}3` :samp:`and{m}3`, :samp:`ior{m}3`, :samp:`xor{m}3` + Similar, for other arithmetic operations. + + .. index:: addvm4 instruction pattern + +addvm4 + Like ``addm3`` but takes a ``code_label`` as operand 3 and + emits code to jump to it if signed overflow occurs during the addition. + This pattern is used to implement the built-in functions performing + signed integer addition with overflow checking. + + .. index:: subvm4 instruction pattern, mulvm4 instruction pattern + +:samp:`subv{m}4`, :samp:`mulv{m}4` + Similar, for other signed arithmetic operations. + + .. index:: uaddvm4 instruction pattern + +uaddvm4 + Like ``addvm4`` but for unsigned addition. That is to + say, the operation is the same as signed addition but the jump + is taken only on unsigned overflow. + + .. index:: usubvm4 instruction pattern, umulvm4 instruction pattern + +:samp:`usubv{m}4`, :samp:`umulv{m}4` + Similar, for other unsigned arithmetic operations. + + .. index:: addptrm3 instruction pattern + +addptrm3 + Like ``addm3`` but is guaranteed to only be used for address + calculations. The expanded code is not allowed to clobber the + condition code. It only needs to be defined if ``addm3`` + sets the condition code. If adds used for address calculations and + normal adds are not compatible it is required to expand a distinct + pattern (e.g. using an unspec). The pattern is used by LRA to emit + address calculations. ``addm3`` is used if + ``addptrm3`` is not defined. + + .. index:: fmam4 instruction pattern + +fmam4 + Multiply operand 2 and operand 1, then add operand 3, storing the + result in operand 0 without doing an intermediate rounding step. All + operands must have mode :samp:`{m}`. This pattern is used to implement + the ``fma``, ``fmaf``, and ``fmal`` builtin functions from + the ISO C99 standard. + + .. index:: fmsm4 instruction pattern + +fmsm4 + Like ``fmam4``, except operand 3 subtracted from the + product instead of added to the product. This is represented + in the rtl as + + .. code-block:: c++ + + (fma:m op1 op2 (neg:m op3)) + + .. index:: fnmam4 instruction pattern + +fnmam4 + Like ``fmam4`` except that the intermediate product + is negated before being added to operand 3. This is represented + in the rtl as + + .. code-block:: c++ + + (fma:m (neg:m op1) op2 op3) + + .. index:: fnmsm4 instruction pattern + +fnmsm4 + Like ``fmsm4`` except that the intermediate product + is negated before subtracting operand 3. This is represented + in the rtl as + + .. code-block:: c++ + + (fma:m (neg:m op1) op2 (neg:m op3)) + + .. index:: minm3 instruction pattern, maxm3 instruction pattern + +:samp:`smin{m}3`, :samp:`smax{m}3` + Signed minimum and maximum operations. When used with floating point, + if both operands are zeros, or if either operand is ``NaN``, then + it is unspecified which of the two operands is returned as the result. + + .. index:: fminm3 instruction pattern, fmaxm3 instruction pattern + +:samp:`fmin{m}3`, :samp:`fmax{m}3` + IEEE-conformant minimum and maximum operations. If one operand is a quiet + ``NaN``, then the other operand is returned. If both operands are quiet + ``NaN``, then a quiet ``NaN`` is returned. In the case when gcc supports + signaling ``NaN`` (-fsignaling-nans) an invalid floating point exception is + raised and a quiet ``NaN`` is returned. + + All operands have mode :samp:`{m}`, which is a scalar or vector + floating-point mode. These patterns are not allowed to ``FAIL``. + + .. index:: reduc_smin_scal_m instruction pattern, reduc_smax_scal_m instruction pattern + +:samp:`reduc_smin_scal_{m}`, :samp:`reduc_smax_scal_{m}` + Find the signed minimum/maximum of the elements of a vector. The vector is + operand 1, and operand 0 is the scalar result, with mode equal to the mode of + the elements of the input vector. + + .. index:: reduc_umin_scal_m instruction pattern, reduc_umax_scal_m instruction pattern + +:samp:`reduc_umin_scal_{m}`, :samp:`reduc_umax_scal_{m}` + Find the unsigned minimum/maximum of the elements of a vector. The vector is + operand 1, and operand 0 is the scalar result, with mode equal to the mode of + the elements of the input vector. + + .. index:: reduc_fmin_scal_m instruction pattern, reduc_fmax_scal_m instruction pattern + +:samp:`reduc_fmin_scal_{m}`, :samp:`reduc_fmax_scal_{m}` + Find the floating-point minimum/maximum of the elements of a vector, + using the same rules as ``fminm3`` and ``fmaxm3``. + Operand 1 is a vector of mode :samp:`{m}` and operand 0 is the scalar + result, which has mode ``GET_MODE_INNER (m)``. + + .. index:: reduc_plus_scal_m instruction pattern + +reduc_plus_scal_m + Compute the sum of the elements of a vector. The vector is operand 1, and + operand 0 is the scalar result, with mode equal to the mode of the elements of + the input vector. + + .. index:: reduc_and_scal_m instruction pattern + +reduc_and_scal_m, reduc_ior_scal_m, reduc_xor_scal_m + Compute the bitwise ``AND`` / ``IOR`` / ``XOR`` reduction of the elements + of a vector of mode :samp:`{m}`. Operand 1 is the vector input and operand 0 + is the scalar result. The mode of the scalar result is the same as one + element of :samp:`{m}`. + + .. index:: extract_last_m instruction pattern + +extract_last_m + Find the last set bit in mask operand 1 and extract the associated element + of vector operand 2. Store the result in scalar operand 0. Operand 2 + has vector mode :samp:`{m}` while operand 0 has the mode appropriate for one + element of :samp:`{m}`. Operand 1 has the usual mask mode for vectors of mode + :samp:`{m}` ; see ``TARGET_VECTORIZE_GET_MASK_MODE``. + + .. index:: fold_extract_last_m instruction pattern + +fold_extract_last_m + If any bits of mask operand 2 are set, find the last set bit, extract + the associated element from vector operand 3, and store the result + in operand 0. Store operand 1 in operand 0 otherwise. Operand 3 + has mode :samp:`{m}` and operands 0 and 1 have the mode appropriate for + one element of :samp:`{m}`. Operand 2 has the usual mask mode for vectors + of mode :samp:`{m}` ; see ``TARGET_VECTORIZE_GET_MASK_MODE``. + + .. index:: fold_left_plus_m instruction pattern + +fold_left_plus_m + Take scalar operand 1 and successively add each element from vector + operand 2. Store the result in scalar operand 0. The vector has + mode :samp:`{m}` and the scalars have the mode appropriate for one + element of :samp:`{m}`. The operation is strictly in-order: there is + no reassociation. + + .. index:: mask_fold_left_plus_m instruction pattern + +mask_fold_left_plus_m + Like :samp:`fold_left_plus_{m}`, but takes an additional mask operand + (operand 3) that specifies which elements of the source vector should be added. + + .. index:: sdot_prodm instruction pattern + +sdot_prodm + Compute the sum of the products of two signed elements. + Operand 1 and operand 2 are of the same mode. Their + product, which is of a wider mode, is computed and added to operand 3. + Operand 3 is of a mode equal or wider than the mode of the product. The + result is placed in operand 0, which is of the same mode as operand 3. + + Semantically the expressions perform the multiplication in the following signs + + .. code-block:: c++ + + sdot == + op0 = sign-ext (op1) * sign-ext (op2) + op3 + ... + + .. index:: udot_prodm instruction pattern + +udot_prodm + Compute the sum of the products of two unsigned elements. + Operand 1 and operand 2 are of the same mode. Their + product, which is of a wider mode, is computed and added to operand 3. + Operand 3 is of a mode equal or wider than the mode of the product. The + result is placed in operand 0, which is of the same mode as operand 3. + + Semantically the expressions perform the multiplication in the following signs + + .. code-block:: c++ + + udot == + op0 = zero-ext (op1) * zero-ext (op2) + op3 + ... + + .. index:: usdot_prodm instruction pattern + +usdot_prodm + Compute the sum of the products of elements of different signs. + Operand 1 must be unsigned and operand 2 signed. Their + product, which is of a wider mode, is computed and added to operand 3. + Operand 3 is of a mode equal or wider than the mode of the product. The + result is placed in operand 0, which is of the same mode as operand 3. + + Semantically the expressions perform the multiplication in the following signs + + .. code-block:: c++ + + usdot == + op0 = ((signed-conv) zero-ext (op1)) * sign-ext (op2) + op3 + ... + + .. index:: ssadm instruction pattern + .. index:: usadm instruction pattern + +ssadm, usadm + Compute the sum of absolute differences of two signed/unsigned elements. + Operand 1 and operand 2 are of the same mode. Their absolute difference, which + is of a wider mode, is computed and added to operand 3. Operand 3 is of a mode + equal or wider than the mode of the absolute difference. The result is placed + in operand 0, which is of the same mode as operand 3. + + .. index:: widen_ssumm3 instruction pattern + +widen_ssumm3 + +.. index:: widen_usumm3 instruction pattern + +widen_usumm3 + + Operands 0 and 2 are of the same mode, which is wider than the mode of + operand 1. Add operand 1 to operand 2 and place the widened result in + operand 0. (This is used express accumulation of elements into an accumulator + of a wider mode.) + +.. index:: smulhsm3 instruction pattern +.. index:: umulhsm3 instruction pattern + +smulhsm3, umulhsm3 + + Signed/unsigned multiply high with scale. This is equivalent to the C code: + + .. code-block:: c++ + + narrow op0, op1, op2; + ... + op0 = (narrow) (((wide) op1 * (wide) op2) >> (N / 2 - 1)); + + where the sign of :samp:`narrow` determines whether this is a signed + or unsigned operation, and :samp:`{N}` is the size of :samp:`wide` in bits. + +.. index:: smulhrsm3 instruction pattern +.. index:: umulhrsm3 instruction pattern + +smulhrsm3, umulhrsm3 + + Signed/unsigned multiply high with round and scale. This is + equivalent to the C code: + + .. code-block:: c++ + + narrow op0, op1, op2; + ... + op0 = (narrow) (((((wide) op1 * (wide) op2) >> (N / 2 - 2)) + 1) >> 1); + + where the sign of :samp:`narrow` determines whether this is a signed + or unsigned operation, and :samp:`{N}` is the size of :samp:`wide` in bits. + +.. index:: sdiv_pow2m3 instruction pattern + +sdiv_pow2m3 + Signed division by power-of-2 immediate. Equivalent to: + + .. code-block:: c++ + + signed op0, op1; + ... + op0 = op1 / (1 << imm); + + .. index:: vec_shl_insert_m instruction pattern + +vec_shl_insert_m + Shift the elements in vector input operand 1 left one element (i.e. + away from element 0) and fill the vacated element 0 with the scalar + in operand 2. Store the result in vector output operand 0. Operands + 0 and 1 have mode :samp:`{m}` and operand 2 has the mode appropriate for + one element of :samp:`{m}`. + + .. index:: vec_shl_m instruction pattern + +vec_shl_m + Whole vector left shift in bits, i.e. away from element 0. + Operand 1 is a vector to be shifted. + Operand 2 is an integer shift amount in bits. + Operand 0 is where the resulting shifted vector is stored. + The output and input vectors should have the same modes. + + .. index:: vec_shr_m instruction pattern + +vec_shr_m + Whole vector right shift in bits, i.e. towards element 0. + Operand 1 is a vector to be shifted. + Operand 2 is an integer shift amount in bits. + Operand 0 is where the resulting shifted vector is stored. + The output and input vectors should have the same modes. + + .. index:: vec_pack_trunc_m instruction pattern + +vec_pack_trunc_m + Narrow (demote) and merge the elements of two vectors. Operands 1 and 2 + are vectors of the same mode having N integral or floating point elements + of size S. Operand 0 is the resulting vector in which 2\*N elements of + size S/2 are concatenated after narrowing them down using truncation. + + .. index:: vec_pack_sbool_trunc_m instruction pattern + +vec_pack_sbool_trunc_m + Narrow and merge the elements of two vectors. Operands 1 and 2 are vectors + of the same type having N boolean elements. Operand 0 is the resulting + vector in which 2\*N elements are concatenated. The last operand (operand 3) + is the number of elements in the output vector 2\*N as a ``CONST_INT``. + This instruction pattern is used when all the vector input and output + operands have the same scalar mode :samp:`{m}` and thus using + ``vec_pack_trunc_m`` would be ambiguous. + + .. index:: vec_pack_ssat_m instruction pattern, vec_pack_usat_m instruction pattern + +:samp:`vec_pack_ssat_{m}`, :samp:`vec_pack_usat_{m}` + Narrow (demote) and merge the elements of two vectors. Operands 1 and 2 + are vectors of the same mode having N integral elements of size S. + Operand 0 is the resulting vector in which the elements of the two input + vectors are concatenated after narrowing them down using signed/unsigned + saturating arithmetic. + + .. index:: vec_pack_sfix_trunc_m instruction pattern, vec_pack_ufix_trunc_m instruction pattern + +:samp:`vec_pack_sfix_trunc_{m}`, :samp:`vec_pack_ufix_trunc_{m}` + Narrow, convert to signed/unsigned integral type and merge the elements + of two vectors. Operands 1 and 2 are vectors of the same mode having N + floating point elements of size S. Operand 0 is the resulting vector + in which 2\*N elements of size S/2 are concatenated. + + .. index:: vec_packs_float_m instruction pattern, vec_packu_float_m instruction pattern + +:samp:`vec_packs_float_{m}`, :samp:`vec_packu_float_{m}` + Narrow, convert to floating point type and merge the elements + of two vectors. Operands 1 and 2 are vectors of the same mode having N + signed/unsigned integral elements of size S. Operand 0 is the resulting vector + in which 2\*N elements of size S/2 are concatenated. + + .. index:: vec_unpacks_hi_m instruction pattern, vec_unpacks_lo_m instruction pattern + +:samp:`vec_unpacks_hi_{m}`, :samp:`vec_unpacks_lo_{m}` + Extract and widen (promote) the high/low part of a vector of signed + integral or floating point elements. The input vector (operand 1) has N + elements of size S. Widen (promote) the high/low elements of the vector + using signed or floating point extension and place the resulting N/2 + values of size 2\*S in the output vector (operand 0). + + .. index:: vec_unpacku_hi_m instruction pattern, vec_unpacku_lo_m instruction pattern + +:samp:`vec_unpacku_hi_{m}`, :samp:`vec_unpacku_lo_{m}` + Extract and widen (promote) the high/low part of a vector of unsigned + integral elements. The input vector (operand 1) has N elements of size S. + Widen (promote) the high/low elements of the vector using zero extension and + place the resulting N/2 values of size 2\*S in the output vector (operand 0). + + .. index:: vec_unpacks_sbool_hi_m instruction pattern, vec_unpacks_sbool_lo_m instruction pattern + +:samp:`vec_unpacks_sbool_hi_{m}`, :samp:`vec_unpacks_sbool_lo_{m}` + Extract the high/low part of a vector of boolean elements that have scalar + mode :samp:`{m}`. The input vector (operand 1) has N elements, the output + vector (operand 0) has N/2 elements. The last operand (operand 2) is the + number of elements of the input vector N as a ``CONST_INT``. These + patterns are used if both the input and output vectors have the same scalar + mode :samp:`{m}` and thus using ``vec_unpacks_hi_m`` or + ``vec_unpacks_lo_m`` would be ambiguous. + + .. index:: vec_unpacks_float_hi_m instruction pattern, vec_unpacks_float_lo_m instruction pattern, vec_unpacku_float_hi_m instruction pattern, vec_unpacku_float_lo_m instruction pattern + +:samp:`vec_unpacks_float_hi_{m}`, :samp:`vec_unpacks_float_lo_{m}` :samp:`vec_unpacku_float_hi_{m}`, :samp:`vec_unpacku_float_lo_{m}` + Extract, convert to floating point type and widen the high/low part of a + vector of signed/unsigned integral elements. The input vector (operand 1) + has N elements of size S. Convert the high/low elements of the vector using + floating point conversion and place the resulting N/2 values of size 2\*S in + the output vector (operand 0). + + .. index:: vec_unpack_sfix_trunc_hi_m instruction pattern, vec_unpack_sfix_trunc_lo_m instruction pattern, vec_unpack_ufix_trunc_hi_m instruction pattern, vec_unpack_ufix_trunc_lo_m instruction pattern + +:samp:`vec_unpack_sfix_trunc_hi_{m}`, vec_unpack_sfix_trunc_lo_m vec_unpack_ufix_trunc_hi_m vec_unpack_ufix_trunc_lo_m + Extract, convert to signed/unsigned integer type and widen the high/low part of a + vector of floating point elements. The input vector (operand 1) + has N elements of size S. Convert the high/low elements of the vector + to integers and place the resulting N/2 values of size 2\*S in + the output vector (operand 0). + + .. index:: vec_widen_umult_hi_m instruction pattern, vec_widen_umult_lo_m instruction pattern, vec_widen_smult_hi_m instruction pattern, vec_widen_smult_lo_m instruction pattern, vec_widen_umult_even_m instruction pattern, vec_widen_umult_odd_m instruction pattern, vec_widen_smult_even_m instruction pattern, vec_widen_smult_odd_m instruction pattern + +:samp:`vec_widen_umult_hi_{m}`, :samp:`vec_widen_umult_lo_{m}` :samp:`vec_widen_smult_hi_{m}`, :samp:`vec_widen_smult_lo_{m}` :samp:`vec_widen_umult_even_{m}`, :samp:`vec_widen_umult_odd_{m}` :samp:`vec_widen_smult_even_{m}`, :samp:`vec_widen_smult_odd_{m}` + Signed/Unsigned widening multiplication. The two inputs (operands 1 and 2) + are vectors with N signed/unsigned elements of size S. Multiply the high/low + or even/odd elements of the two vectors, and put the N/2 products of size 2\*S + in the output vector (operand 0). A target shouldn't implement even/odd pattern + pair if it is less efficient than lo/hi one. + + .. index:: vec_widen_ushiftl_hi_m instruction pattern, vec_widen_ushiftl_lo_m instruction pattern, vec_widen_sshiftl_hi_m instruction pattern, vec_widen_sshiftl_lo_m instruction pattern + +:samp:`vec_widen_ushiftl_hi_{m}`, :samp:`vec_widen_ushiftl_lo_{m}` :samp:`vec_widen_sshiftl_hi_{m}`, :samp:`vec_widen_sshiftl_lo_{m}` + Signed/Unsigned widening shift left. The first input (operand 1) is a vector + with N signed/unsigned elements of size S. Operand 2 is a constant. Shift + the high/low elements of operand 1, and put the N/2 results of size 2\*S in the + output vector (operand 0). + + .. index:: vec_widen_saddl_hi_m instruction pattern, vec_widen_saddl_lo_m instruction pattern, vec_widen_uaddl_hi_m instruction pattern, vec_widen_uaddl_lo_m instruction pattern + +:samp:`vec_widen_uaddl_hi_{m}`, :samp:`vec_widen_uaddl_lo_{m}` :samp:`vec_widen_saddl_hi_{m}`, :samp:`vec_widen_saddl_lo_{m}` + Signed/Unsigned widening add long. Operands 1 and 2 are vectors with N + signed/unsigned elements of size S. Add the high/low elements of 1 and 2 + together, widen the resulting elements and put the N/2 results of size 2\*S in + the output vector (operand 0). + + .. index:: vec_widen_ssubl_hi_m instruction pattern, vec_widen_ssubl_lo_m instruction pattern, vec_widen_usubl_hi_m instruction pattern, vec_widen_usubl_lo_m instruction pattern + +:samp:`vec_widen_usubl_hi_{m}`, :samp:`vec_widen_usubl_lo_{m}` :samp:`vec_widen_ssubl_hi_{m}`, :samp:`vec_widen_ssubl_lo_{m}` + Signed/Unsigned widening subtract long. Operands 1 and 2 are vectors with N + signed/unsigned elements of size S. Subtract the high/low elements of 2 from + 1 and widen the resulting elements. Put the N/2 results of size 2\*S in the + output vector (operand 0). + + .. index:: vec_addsubm3 instruction pattern + +vec_addsubm3 + Alternating subtract, add with even lanes doing subtract and odd + lanes doing addition. Operands 1 and 2 and the outout operand are vectors + with mode :samp:`{m}`. + + .. index:: vec_fmaddsubm4 instruction pattern + +vec_fmaddsubm4 + Alternating multiply subtract, add with even lanes doing subtract and odd + lanes doing addition of the third operand to the multiplication result + of the first two operands. Operands 1, 2 and 3 and the outout operand are vectors + with mode :samp:`{m}`. + + .. index:: vec_fmsubaddm4 instruction pattern + +vec_fmsubaddm4 + Alternating multiply add, subtract with even lanes doing addition and odd + lanes doing subtraction of the third operand to the multiplication result + of the first two operands. Operands 1, 2 and 3 and the outout operand are vectors + with mode :samp:`{m}`. + + These instructions are not allowed to ``FAIL``. + + .. index:: mulhisi3 instruction pattern + +mulhisi3 + Multiply operands 1 and 2, which have mode ``HImode``, and store + a ``SImode`` product in operand 0. + + .. index:: mulqihi3 instruction pattern, mulsidi3 instruction pattern + +:samp:`{mulqihi3}, {mulsidi3}` + Similar widening-multiplication instructions of other widths. + + .. index:: umulqihi3 instruction pattern, umulhisi3 instruction pattern, umulsidi3 instruction pattern + +:samp:`{umulqihi3}, {umulhisi3}, {umulsidi3}` + Similar widening-multiplication instructions that do unsigned + multiplication. + + .. index:: usmulqihi3 instruction pattern, usmulhisi3 instruction pattern, usmulsidi3 instruction pattern + +:samp:`{usmulqihi3}, {usmulhisi3}, {usmulsidi3}` + Similar widening-multiplication instructions that interpret the first + operand as unsigned and the second operand as signed, then do a signed + multiplication. + + .. index:: smulm3_highpart instruction pattern + +smulm3_highpart + Perform a signed multiplication of operands 1 and 2, which have mode + :samp:`{m}`, and store the most significant half of the product in operand 0. + The least significant half of the product is discarded. This may be + represented in RTL using a ``smul_highpart`` RTX expression. + + .. index:: umulm3_highpart instruction pattern + +umulm3_highpart + Similar, but the multiplication is unsigned. This may be represented + in RTL using an ``umul_highpart`` RTX expression. + + .. index:: maddmn4 instruction pattern + +maddmn4 + Multiply operands 1 and 2, sign-extend them to mode :samp:`{n}`, add + operand 3, and store the result in operand 0. Operands 1 and 2 + have mode :samp:`{m}` and operands 0 and 3 have mode :samp:`{n}`. + Both modes must be integer or fixed-point modes and :samp:`{n}` must be twice + the size of :samp:`{m}`. + + In other words, ``maddmn4`` is like + ``mulmn3`` except that it also adds operand 3. + + These instructions are not allowed to ``FAIL``. + + .. index:: umaddmn4 instruction pattern + +umaddmn4 + Like ``maddmn4``, but zero-extend the multiplication + operands instead of sign-extending them. + + .. index:: ssmaddmn4 instruction pattern + +ssmaddmn4 + Like ``maddmn4``, but all involved operations must be + signed-saturating. + + .. index:: usmaddmn4 instruction pattern + +usmaddmn4 + Like ``umaddmn4``, but all involved operations must be + unsigned-saturating. + + .. index:: msubmn4 instruction pattern + +msubmn4 + Multiply operands 1 and 2, sign-extend them to mode :samp:`{n}`, subtract the + result from operand 3, and store the result in operand 0. Operands 1 and 2 + have mode :samp:`{m}` and operands 0 and 3 have mode :samp:`{n}`. + Both modes must be integer or fixed-point modes and :samp:`{n}` must be twice + the size of :samp:`{m}`. + + In other words, ``msubmn4`` is like + ``mulmn3`` except that it also subtracts the result + from operand 3. + + These instructions are not allowed to ``FAIL``. + + .. index:: umsubmn4 instruction pattern + +umsubmn4 + Like ``msubmn4``, but zero-extend the multiplication + operands instead of sign-extending them. + + .. index:: ssmsubmn4 instruction pattern + +ssmsubmn4 + Like ``msubmn4``, but all involved operations must be + signed-saturating. + + .. index:: usmsubmn4 instruction pattern + +usmsubmn4 + Like ``umsubmn4``, but all involved operations must be + unsigned-saturating. + + .. index:: divmodm4 instruction pattern + +divmodm4 + Signed division that produces both a quotient and a remainder. + Operand 1 is divided by operand 2 to produce a quotient stored + in operand 0 and a remainder stored in operand 3. + + For machines with an instruction that produces both a quotient and a + remainder, provide a pattern for :samp:`divmod{m}4` but do not + provide patterns for :samp:`div{m}3` and :samp:`mod{m}3`. This + allows optimization in the relatively common case when both the quotient + and remainder are computed. + + If an instruction that just produces a quotient or just a remainder + exists and is more efficient than the instruction that produces both, + write the output routine of :samp:`divmod{m}4` to call + ``find_reg_note`` and look for a ``REG_UNUSED`` note on the + quotient or remainder and generate the appropriate instruction. + + .. index:: udivmodm4 instruction pattern + +udivmodm4 + Similar, but does unsigned division. + + .. index:: ashlm3 instruction pattern, ssashlm3 instruction pattern, usashlm3 instruction pattern + +.. _shift-patterns: + +:samp:`ashl{m}3`, :samp:`ssashl{m}3`, :samp:`usashl{m}3` + Arithmetic-shift operand 1 left by a number of bits specified by operand + 2, and store the result in operand 0. Here :samp:`{m}` is the mode of + operand 0 and operand 1; operand 2's mode is specified by the + instruction pattern, and the compiler will convert the operand to that + mode before generating the instruction. The shift or rotate expander + or instruction pattern should explicitly specify the mode of the operand 2, + it should never be ``VOIDmode``. The meaning of out-of-range shift + counts can optionally be specified by ``TARGET_SHIFT_TRUNCATION_MASK``. + See :ref:`target_shift_truncation_mask`. Operand 2 is always a scalar type. + + .. index:: ashrm3 instruction pattern, lshrm3 instruction pattern, rotlm3 instruction pattern, rotrm3 instruction pattern + +:samp:`ashr{m}3`, :samp:`lshr{m}3`, :samp:`rotl{m}3`, :samp:`rotr{m}3` + Other shift and rotate instructions, analogous to the + ``ashlm3`` instructions. Operand 2 is always a scalar type. + + .. index:: vashlm3 instruction pattern, vashrm3 instruction pattern, vlshrm3 instruction pattern, vrotlm3 instruction pattern, vrotrm3 instruction pattern + +:samp:`vashl{m}3`, :samp:`vashr{m}3`, :samp:`vlshr{m}3`, :samp:`vrotl{m}3`, :samp:`vrotr{m}3` + Vector shift and rotate instructions that take vectors as operand 2 + instead of a scalar type. + + .. index:: avgm3_floor instruction pattern, uavgm3_floor instruction pattern + +avgm3_floor uavgm3_floor + Signed and unsigned average instructions. These instructions add + operands 1 and 2 without truncation, divide the result by 2, + round towards -Inf, and store the result in operand 0. This is + equivalent to the C code: + + .. code-block:: c++ + + narrow op0, op1, op2; + ... + op0 = (narrow) (((wide) op1 + (wide) op2) >> 1); + + where the sign of :samp:`narrow` determines whether this is a signed + or unsigned operation. + + .. index:: avgm3_ceil instruction pattern, uavgm3_ceil instruction pattern + +avgm3_ceil uavgm3_ceil + Like :samp:`avg{m}3_floor` and :samp:`uavg{m}3_floor`, but round + towards +Inf. This is equivalent to the C code: + + .. code-block:: c++ + + narrow op0, op1, op2; + ... + op0 = (narrow) (((wide) op1 + (wide) op2 + 1) >> 1); + + .. index:: bswapm2 instruction pattern + +bswapm2 + Reverse the order of bytes of operand 1 and store the result in operand 0. + + .. index:: negm2 instruction pattern, ssnegm2 instruction pattern, usnegm2 instruction pattern + +:samp:`neg{m}2`, :samp:`ssneg{m}2`, :samp:`usneg{m}2` + Negate operand 1 and store the result in operand 0. + + .. index:: negvm3 instruction pattern + +negvm3 + Like ``negm2`` but takes a ``code_label`` as operand 2 and + emits code to jump to it if signed overflow occurs during the negation. + + .. index:: absm2 instruction pattern + +absm2 + Store the absolute value of operand 1 into operand 0. + + .. index:: sqrtm2 instruction pattern + +sqrtm2 + Store the square root of operand 1 into operand 0. Both operands have + mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: rsqrtm2 instruction pattern + +rsqrtm2 + Store the reciprocal of the square root of operand 1 into operand 0. + Both operands have mode :samp:`{m}`, which is a scalar or vector + floating-point mode. + + On most architectures this pattern is only approximate, so either + its C condition or the ``TARGET_OPTAB_SUPPORTED_P`` hook should + check for the appropriate math flags. (Using the C condition is + more direct, but using ``TARGET_OPTAB_SUPPORTED_P`` can be useful + if a target-specific built-in also uses the :samp:`rsqrt{m}2` + pattern.) + + This pattern is not allowed to ``FAIL``. + + .. index:: fmodm3 instruction pattern + +fmodm3 + Store the remainder of dividing operand 1 by operand 2 into + operand 0, rounded towards zero to an integer. All operands have + mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: remainderm3 instruction pattern + +remainderm3 + Store the remainder of dividing operand 1 by operand 2 into + operand 0, rounded to the nearest integer. All operands have + mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: scalbm3 instruction pattern + +scalbm3 + Raise ``FLT_RADIX`` to the power of operand 2, multiply it by + operand 1, and store the result in operand 0. All operands have + mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: ldexpm3 instruction pattern + +ldexpm3 + Raise 2 to the power of operand 2, multiply it by operand 1, and store + the result in operand 0. Operands 0 and 1 have mode :samp:`{m}`, which is + a scalar or vector floating-point mode. Operand 2's mode has + the same number of elements as :samp:`{m}` and each element is wide + enough to store an ``int``. The integers are signed. + + This pattern is not allowed to ``FAIL``. + + .. index:: cosm2 instruction pattern + +cosm2 + Store the cosine of operand 1 into operand 0. Both operands have + mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: sinm2 instruction pattern + +sinm2 + Store the sine of operand 1 into operand 0. Both operands have + mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: sincosm3 instruction pattern + +sincosm3 + Store the cosine of operand 2 into operand 0 and the sine of + operand 2 into operand 1. All operands have mode :samp:`{m}`, + which is a scalar or vector floating-point mode. + + Targets that can calculate the sine and cosine simultaneously can + implement this pattern as opposed to implementing individual + ``sinm2`` and ``cosm2`` patterns. The ``sin`` + and ``cos`` built-in functions will then be expanded to the + ``sincosm3`` pattern, with one of the output values + left unused. + + .. index:: tanm2 instruction pattern + +tanm2 + Store the tangent of operand 1 into operand 0. Both operands have + mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: asinm2 instruction pattern + +asinm2 + Store the arc sine of operand 1 into operand 0. Both operands have + mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: acosm2 instruction pattern + +acosm2 + Store the arc cosine of operand 1 into operand 0. Both operands have + mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: atanm2 instruction pattern + +atanm2 + Store the arc tangent of operand 1 into operand 0. Both operands have + mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: fegetroundm instruction pattern + +fegetroundm + Store the current machine floating-point rounding mode into operand 0. + Operand 0 has mode :samp:`{m}`, which is scalar. This pattern is used to + implement the ``fegetround`` function from the ISO C99 standard. + + .. index:: feclearexceptm instruction pattern, feraiseexceptm instruction pattern + + feclearexceptm +feraiseexceptm + Clears or raises the supported machine floating-point exceptions + represented by the bits in operand 1. Error status is stored as + nonzero value in operand 0. Both operands have mode :samp:`{m}`, which is + a scalar. These patterns are used to implement the + ``feclearexcept`` and ``feraiseexcept`` functions from the ISO + C99 standard. + + .. index:: expm2 instruction pattern + +expm2 + Raise e (the base of natural logarithms) to the power of operand 1 + and store the result in operand 0. Both operands have mode :samp:`{m}`, + which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: expm1m2 instruction pattern + +expm1m2 + Raise e (the base of natural logarithms) to the power of operand 1, + subtract 1, and store the result in operand 0. Both operands have + mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + For inputs close to zero, the pattern is expected to be more + accurate than a separate ``expm2`` and ``subm3`` + would be. + + This pattern is not allowed to ``FAIL``. + + .. index:: exp10m2 instruction pattern + +exp10m2 + Raise 10 to the power of operand 1 and store the result in operand 0. + Both operands have mode :samp:`{m}`, which is a scalar or vector + floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: exp2m2 instruction pattern + +exp2m2 + Raise 2 to the power of operand 1 and store the result in operand 0. + Both operands have mode :samp:`{m}`, which is a scalar or vector + floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: logm2 instruction pattern + +logm2 + Store the natural logarithm of operand 1 into operand 0. Both operands + have mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: log1pm2 instruction pattern + +log1pm2 + Add 1 to operand 1, compute the natural logarithm, and store + the result in operand 0. Both operands have mode :samp:`{m}`, which is + a scalar or vector floating-point mode. + + For inputs close to zero, the pattern is expected to be more + accurate than a separate ``addm3`` and ``logm2`` + would be. + + This pattern is not allowed to ``FAIL``. + + .. index:: log10m2 instruction pattern + +log10m2 + Store the base-10 logarithm of operand 1 into operand 0. Both operands + have mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: log2m2 instruction pattern + +log2m2 + Store the base-2 logarithm of operand 1 into operand 0. Both operands + have mode :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: logbm2 instruction pattern + +logbm2 + Store the base- ``FLT_RADIX`` logarithm of operand 1 into operand 0. + Both operands have mode :samp:`{m}`, which is a scalar or vector + floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: significandm2 instruction pattern + +significandm2 + Store the significand of floating-point operand 1 in operand 0. + Both operands have mode :samp:`{m}`, which is a scalar or vector + floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: powm3 instruction pattern + +powm3 + Store the value of operand 1 raised to the exponent operand 2 + into operand 0. All operands have mode :samp:`{m}`, which is a scalar + or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: atan2m3 instruction pattern + +atan2m3 + Store the arc tangent (inverse tangent) of operand 1 divided by + operand 2 into operand 0, using the signs of both arguments to + determine the quadrant of the result. All operands have mode + :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: floorm2 instruction pattern + +floorm2 + Store the largest integral value not greater than operand 1 in operand 0. + Both operands have mode :samp:`{m}`, which is a scalar or vector + floating-point mode. If :option:`-ffp-int-builtin-inexact` is in + effect, the 'inexact' exception may be raised for noninteger + operands; otherwise, it may not. + + This pattern is not allowed to ``FAIL``. + + .. index:: btruncm2 instruction pattern + +btruncm2 + Round operand 1 to an integer, towards zero, and store the result in + operand 0. Both operands have mode :samp:`{m}`, which is a scalar or + vector floating-point mode. If :option:`-ffp-int-builtin-inexact` is + in effect, the 'inexact' exception may be raised for noninteger + operands; otherwise, it may not. + + This pattern is not allowed to ``FAIL``. + + .. index:: roundm2 instruction pattern + +roundm2 + Round operand 1 to the nearest integer, rounding away from zero in the + event of a tie, and store the result in operand 0. Both operands have + mode :samp:`{m}`, which is a scalar or vector floating-point mode. If + :option:`-ffp-int-builtin-inexact` is in effect, the 'inexact' + exception may be raised for noninteger operands; otherwise, it may + not. + + This pattern is not allowed to ``FAIL``. + + .. index:: ceilm2 instruction pattern + +ceilm2 + Store the smallest integral value not less than operand 1 in operand 0. + Both operands have mode :samp:`{m}`, which is a scalar or vector + floating-point mode. If :option:`-ffp-int-builtin-inexact` is in + effect, the 'inexact' exception may be raised for noninteger + operands; otherwise, it may not. + + This pattern is not allowed to ``FAIL``. + + .. index:: nearbyintm2 instruction pattern + +nearbyintm2 + Round operand 1 to an integer, using the current rounding mode, and + store the result in operand 0. Do not raise an inexact condition when + the result is different from the argument. Both operands have mode + :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: rintm2 instruction pattern + +rintm2 + Round operand 1 to an integer, using the current rounding mode, and + store the result in operand 0. Raise an inexact condition when + the result is different from the argument. Both operands have mode + :samp:`{m}`, which is a scalar or vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: lrintmn2 + +lrintmn2 + Convert operand 1 (valid for floating point mode :samp:`{m}`) to fixed + point mode :samp:`{n}` as a signed number according to the current + rounding mode and store in operand 0 (which has mode :samp:`{n}`). + + .. index:: lroundmn2 + +lroundmn2 + Convert operand 1 (valid for floating point mode :samp:`{m}`) to fixed + point mode :samp:`{n}` as a signed number rounding to nearest and away + from zero and store in operand 0 (which has mode :samp:`{n}`). + + .. index:: lfloormn2 + +lfloormn2 + Convert operand 1 (valid for floating point mode :samp:`{m}`) to fixed + point mode :samp:`{n}` as a signed number rounding down and store in + operand 0 (which has mode :samp:`{n}`). + + .. index:: lceilmn2 + +lceilmn2 + Convert operand 1 (valid for floating point mode :samp:`{m}`) to fixed + point mode :samp:`{n}` as a signed number rounding up and store in + operand 0 (which has mode :samp:`{n}`). + + .. index:: copysignm3 instruction pattern + +copysignm3 + Store a value with the magnitude of operand 1 and the sign of operand + 2 into operand 0. All operands have mode :samp:`{m}`, which is a scalar or + vector floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: xorsignm3 instruction pattern + +xorsignm3 + Equivalent to :samp:`op0 = op1 * copysign (1.0, op2)`: store a value with + the magnitude of operand 1 and the sign of operand 2 into operand 0. + All operands have mode :samp:`{m}`, which is a scalar or vector + floating-point mode. + + This pattern is not allowed to ``FAIL``. + + .. index:: issignalingm2 instruction pattern + +issignalingm2 + Set operand 0 to 1 if operand 1 is a signaling NaN and to 0 otherwise. + + .. index:: cadd90m3 instruction pattern + +cadd90m3 + Perform vector add and subtract on even/odd number pairs. The operation being + matched is semantically described as + + .. code-block:: c++ + + for (int i = 0; i < N; i += 2) + { + c[i] = a[i] - b[i+1]; + c[i+1] = a[i+1] + b[i]; + } + + This operation is semantically equivalent to performing a vector addition of + complex numbers in operand 1 with operand 2 rotated by 90 degrees around + the argand plane and storing the result in operand 0. + + In GCC lane ordering the real part of the number must be in the even lanes with + the imaginary part in the odd lanes. + + The operation is only supported for vector modes :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: cadd270m3 instruction pattern + +cadd270m3 + Perform vector add and subtract on even/odd number pairs. The operation being + matched is semantically described as + + .. code-block:: c++ + + for (int i = 0; i < N; i += 2) + { + c[i] = a[i] + b[i+1]; + c[i+1] = a[i+1] - b[i]; + } + + This operation is semantically equivalent to performing a vector addition of + complex numbers in operand 1 with operand 2 rotated by 270 degrees around + the argand plane and storing the result in operand 0. + + In GCC lane ordering the real part of the number must be in the even lanes with + the imaginary part in the odd lanes. + + The operation is only supported for vector modes :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: cmlam4 instruction pattern + +cmlam4 + Perform a vector multiply and accumulate that is semantically the same as + a multiply and accumulate of complex numbers. + + .. code-block:: c++ + + complex TYPE op0[N]; + complex TYPE op1[N]; + complex TYPE op2[N]; + complex TYPE op3[N]; + for (int i = 0; i < N; i += 1) + { + op0[i] = op1[i] * op2[i] + op3[i]; + } + + In GCC lane ordering the real part of the number must be in the even lanes with + the imaginary part in the odd lanes. + + The operation is only supported for vector modes :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: cmla_conjm4 instruction pattern + +cmla_conjm4 + Perform a vector multiply by conjugate and accumulate that is semantically + the same as a multiply and accumulate of complex numbers where the second + multiply arguments is conjugated. + + .. code-block:: c++ + + complex TYPE op0[N]; + complex TYPE op1[N]; + complex TYPE op2[N]; + complex TYPE op3[N]; + for (int i = 0; i < N; i += 1) + { + op0[i] = op1[i] * conj (op2[i]) + op3[i]; + } + + In GCC lane ordering the real part of the number must be in the even lanes with + the imaginary part in the odd lanes. + + The operation is only supported for vector modes :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: cmlsm4 instruction pattern + +cmlsm4 + Perform a vector multiply and subtract that is semantically the same as + a multiply and subtract of complex numbers. + + .. code-block:: c++ + + complex TYPE op0[N]; + complex TYPE op1[N]; + complex TYPE op2[N]; + complex TYPE op3[N]; + for (int i = 0; i < N; i += 1) + { + op0[i] = op1[i] * op2[i] - op3[i]; + } + + In GCC lane ordering the real part of the number must be in the even lanes with + the imaginary part in the odd lanes. + + The operation is only supported for vector modes :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: cmls_conjm4 instruction pattern + +cmls_conjm4 + Perform a vector multiply by conjugate and subtract that is semantically + the same as a multiply and subtract of complex numbers where the second + multiply arguments is conjugated. + + .. code-block:: c++ + + complex TYPE op0[N]; + complex TYPE op1[N]; + complex TYPE op2[N]; + complex TYPE op3[N]; + for (int i = 0; i < N; i += 1) + { + op0[i] = op1[i] * conj (op2[i]) - op3[i]; + } + + In GCC lane ordering the real part of the number must be in the even lanes with + the imaginary part in the odd lanes. + + The operation is only supported for vector modes :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: cmulm4 instruction pattern + +cmulm4 + Perform a vector multiply that is semantically the same as multiply of + complex numbers. + + .. code-block:: c++ + + complex TYPE op0[N]; + complex TYPE op1[N]; + complex TYPE op2[N]; + for (int i = 0; i < N; i += 1) + { + op0[i] = op1[i] * op2[i]; + } + + In GCC lane ordering the real part of the number must be in the even lanes with + the imaginary part in the odd lanes. + + The operation is only supported for vector modes :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: cmul_conjm4 instruction pattern + +cmul_conjm4 + Perform a vector multiply by conjugate that is semantically the same as a + multiply of complex numbers where the second multiply arguments is conjugated. + + .. code-block:: c++ + + complex TYPE op0[N]; + complex TYPE op1[N]; + complex TYPE op2[N]; + for (int i = 0; i < N; i += 1) + { + op0[i] = op1[i] * conj (op2[i]); + } + + In GCC lane ordering the real part of the number must be in the even lanes with + the imaginary part in the odd lanes. + + The operation is only supported for vector modes :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: ffsm2 instruction pattern + +ffsm2 + Store into operand 0 one plus the index of the least significant 1-bit + of operand 1. If operand 1 is zero, store zero. + + :samp:`{m}` is either a scalar or vector integer mode. When it is a scalar, + operand 1 has mode :samp:`{m}` but operand 0 can have whatever scalar + integer mode is suitable for the target. The compiler will insert + conversion instructions as necessary (typically to convert the result + to the same width as ``int``). When :samp:`{m}` is a vector, both + operands must have mode :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: clrsbm2 instruction pattern + +clrsbm2 + Count leading redundant sign bits. + Store into operand 0 the number of redundant sign bits in operand 1, starting + at the most significant bit position. + A redundant sign bit is defined as any sign bit after the first. As such, + this count will be one less than the count of leading sign bits. + + :samp:`{m}` is either a scalar or vector integer mode. When it is a scalar, + operand 1 has mode :samp:`{m}` but operand 0 can have whatever scalar + integer mode is suitable for the target. The compiler will insert + conversion instructions as necessary (typically to convert the result + to the same width as ``int``). When :samp:`{m}` is a vector, both + operands must have mode :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: clzm2 instruction pattern + +clzm2 + Store into operand 0 the number of leading 0-bits in operand 1, starting + at the most significant bit position. If operand 1 is 0, the + ``CLZ_DEFINED_VALUE_AT_ZERO`` (see :ref:`misc`) macro defines if + the result is undefined or has a useful value. + + :samp:`{m}` is either a scalar or vector integer mode. When it is a scalar, + operand 1 has mode :samp:`{m}` but operand 0 can have whatever scalar + integer mode is suitable for the target. The compiler will insert + conversion instructions as necessary (typically to convert the result + to the same width as ``int``). When :samp:`{m}` is a vector, both + operands must have mode :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: ctzm2 instruction pattern + +ctzm2 + Store into operand 0 the number of trailing 0-bits in operand 1, starting + at the least significant bit position. If operand 1 is 0, the + ``CTZ_DEFINED_VALUE_AT_ZERO`` (see :ref:`misc`) macro defines if + the result is undefined or has a useful value. + + :samp:`{m}` is either a scalar or vector integer mode. When it is a scalar, + operand 1 has mode :samp:`{m}` but operand 0 can have whatever scalar + integer mode is suitable for the target. The compiler will insert + conversion instructions as necessary (typically to convert the result + to the same width as ``int``). When :samp:`{m}` is a vector, both + operands must have mode :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: popcountm2 instruction pattern + +popcountm2 + Store into operand 0 the number of 1-bits in operand 1. + + :samp:`{m}` is either a scalar or vector integer mode. When it is a scalar, + operand 1 has mode :samp:`{m}` but operand 0 can have whatever scalar + integer mode is suitable for the target. The compiler will insert + conversion instructions as necessary (typically to convert the result + to the same width as ``int``). When :samp:`{m}` is a vector, both + operands must have mode :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: paritym2 instruction pattern + +paritym2 + Store into operand 0 the parity of operand 1, i.e. the number of 1-bits + in operand 1 modulo 2. + + :samp:`{m}` is either a scalar or vector integer mode. When it is a scalar, + operand 1 has mode :samp:`{m}` but operand 0 can have whatever scalar + integer mode is suitable for the target. The compiler will insert + conversion instructions as necessary (typically to convert the result + to the same width as ``int``). When :samp:`{m}` is a vector, both + operands must have mode :samp:`{m}`. + + This pattern is not allowed to ``FAIL``. + + .. index:: one_cmplm2 instruction pattern + +one_cmplm2 + Store the bitwise-complement of operand 1 into operand 0. + + .. index:: cpymemm instruction pattern + +cpymemm + Block copy instruction. The destination and source blocks of memory + are the first two operands, and both are ``mem:BLK`` s with an + address in mode ``Pmode``. + + The number of bytes to copy is the third operand, in mode :samp:`{m}`. + Usually, you specify ``Pmode`` for :samp:`{m}`. However, if you can + generate better code knowing the range of valid lengths is smaller than + those representable in a full Pmode pointer, you should provide + a pattern with a + mode corresponding to the range of values you can handle efficiently + (e.g., ``QImode`` for values in the range 0--127; note we avoid numbers + that appear negative) and also a pattern with ``Pmode``. + + The fourth operand is the known shared alignment of the source and + destination, in the form of a ``const_int`` rtx. Thus, if the + compiler knows that both source and destination are word-aligned, + it may provide the value 4 for this operand. + + Optional operands 5 and 6 specify expected alignment and size of block + respectively. The expected alignment differs from alignment in operand 4 + in a way that the blocks are not required to be aligned according to it in + all cases. This expected alignment is also in bytes, just like operand 4. + Expected size, when unknown, is set to ``(const_int -1)``. + + Descriptions of multiple ``cpymemm`` patterns can only be + beneficial if the patterns for smaller modes have fewer restrictions + on their first, second and fourth operands. Note that the mode :samp:`{m}` + in ``cpymemm`` does not impose any restriction on the mode of + individually copied data units in the block. + + The ``cpymemm`` patterns need not give special consideration + to the possibility that the source and destination strings might + overlap. These patterns are used to do inline expansion of + ``__builtin_memcpy``. + + .. index:: movmemm instruction pattern + +movmemm + Block move instruction. The destination and source blocks of memory + are the first two operands, and both are ``mem:BLK`` s with an + address in mode ``Pmode``. + + The number of bytes to copy is the third operand, in mode :samp:`{m}`. + Usually, you specify ``Pmode`` for :samp:`{m}`. However, if you can + generate better code knowing the range of valid lengths is smaller than + those representable in a full Pmode pointer, you should provide + a pattern with a + mode corresponding to the range of values you can handle efficiently + (e.g., ``QImode`` for values in the range 0--127; note we avoid numbers + that appear negative) and also a pattern with ``Pmode``. + + The fourth operand is the known shared alignment of the source and + destination, in the form of a ``const_int`` rtx. Thus, if the + compiler knows that both source and destination are word-aligned, + it may provide the value 4 for this operand. + + Optional operands 5 and 6 specify expected alignment and size of block + respectively. The expected alignment differs from alignment in operand 4 + in a way that the blocks are not required to be aligned according to it in + all cases. This expected alignment is also in bytes, just like operand 4. + Expected size, when unknown, is set to ``(const_int -1)``. + + Descriptions of multiple ``movmemm`` patterns can only be + beneficial if the patterns for smaller modes have fewer restrictions + on their first, second and fourth operands. Note that the mode :samp:`{m}` + in ``movmemm`` does not impose any restriction on the mode of + individually copied data units in the block. + + The ``movmemm`` patterns must correctly handle the case where + the source and destination strings overlap. These patterns are used to + do inline expansion of ``__builtin_memmove``. + + .. index:: movstr instruction pattern + +movstr + String copy instruction, with ``stpcpy`` semantics. Operand 0 is + an output operand in mode ``Pmode``. The addresses of the + destination and source strings are operands 1 and 2, and both are + ``mem:BLK`` s with addresses in mode ``Pmode``. The execution of + the expansion of this pattern should store in operand 0 the address in + which the ``NUL`` terminator was stored in the destination string. + + This pattern has also several optional operands that are same as in + ``setmem``. + + .. index:: setmemm instruction pattern + +setmemm + Block set instruction. The destination string is the first operand, + given as a ``mem:BLK`` whose address is in mode ``Pmode``. The + number of bytes to set is the second operand, in mode :samp:`{m}`. The value to + initialize the memory with is the third operand. Targets that only support the + clearing of memory should reject any value that is not the constant 0. See + :samp:`cpymem{m}` for a discussion of the choice of mode. + + The fourth operand is the known alignment of the destination, in the form + of a ``const_int`` rtx. Thus, if the compiler knows that the + destination is word-aligned, it may provide the value 4 for this + operand. + + Optional operands 5 and 6 specify expected alignment and size of block + respectively. The expected alignment differs from alignment in operand 4 + in a way that the blocks are not required to be aligned according to it in + all cases. This expected alignment is also in bytes, just like operand 4. + Expected size, when unknown, is set to ``(const_int -1)``. + Operand 7 is the minimal size of the block and operand 8 is the + maximal size of the block (NULL if it cannot be represented as CONST_INT). + Operand 9 is the probable maximal size (i.e. we cannot rely on it for + correctness, but it can be used for choosing proper code sequence for a + given size). + + The use for multiple ``setmemm`` is as for ``cpymemm``. + + .. index:: cmpstrnm instruction pattern + +cmpstrnm + String compare instruction, with five operands. Operand 0 is the output; + it has mode :samp:`{m}`. The remaining four operands are like the operands + of :samp:`cpymem{m}`. The two memory blocks specified are compared + byte by byte in lexicographic order starting at the beginning of each + string. The instruction is not allowed to prefetch more than one byte + at a time since either string may end in the first byte and reading past + that may access an invalid page or segment and cause a fault. The + comparison terminates early if the fetched bytes are different or if + they are equal to zero. The effect of the instruction is to store a + value in operand 0 whose sign indicates the result of the comparison. + + .. index:: cmpstrm instruction pattern + +cmpstrm + String compare instruction, without known maximum length. Operand 0 is the + output; it has mode :samp:`{m}`. The second and third operand are the blocks of + memory to be compared; both are ``mem:BLK`` with an address in mode + ``Pmode``. + + The fourth operand is the known shared alignment of the source and + destination, in the form of a ``const_int`` rtx. Thus, if the + compiler knows that both source and destination are word-aligned, + it may provide the value 4 for this operand. + + The two memory blocks specified are compared byte by byte in lexicographic + order starting at the beginning of each string. The instruction is not allowed + to prefetch more than one byte at a time since either string may end in the + first byte and reading past that may access an invalid page or segment and + cause a fault. The comparison will terminate when the fetched bytes + are different or if they are equal to zero. The effect of the + instruction is to store a value in operand 0 whose sign indicates the + result of the comparison. + + .. index:: cmpmemm instruction pattern + +cmpmemm + Block compare instruction, with five operands like the operands + of :samp:`cmpstr{m}`. The two memory blocks specified are compared + byte by byte in lexicographic order starting at the beginning of each + block. Unlike :samp:`cmpstr{m}` the instruction can prefetch + any bytes in the two memory blocks. Also unlike :samp:`cmpstr{m}` + the comparison will not stop if both bytes are zero. The effect of + the instruction is to store a value in operand 0 whose sign indicates + the result of the comparison. + + .. index:: strlenm instruction pattern + +strlenm + Compute the length of a string, with three operands. + Operand 0 is the result (of mode :samp:`{m}`), operand 1 is + a ``mem`` referring to the first character of the string, + operand 2 is the character to search for (normally zero), + and operand 3 is a constant describing the known alignment + of the beginning of the string. + + .. index:: rawmemchrm instruction pattern + +rawmemchrm + Scan memory referred to by operand 1 for the first occurrence of operand 2. + Operand 1 is a ``mem`` and operand 2 a ``const_int`` of mode :samp:`{m}`. + Operand 0 is the result, i.e., a pointer to the first occurrence of operand 2 + in the memory block given by operand 1. + + .. index:: floatmn2 instruction pattern + +floatmn2 + Convert signed integer operand 1 (valid for fixed point mode :samp:`{m}`) to + floating point mode :samp:`{n}` and store in operand 0 (which has mode + :samp:`{n}`). + + .. index:: floatunsmn2 instruction pattern + +floatunsmn2 + Convert unsigned integer operand 1 (valid for fixed point mode :samp:`{m}`) + to floating point mode :samp:`{n}` and store in operand 0 (which has mode + :samp:`{n}`). + + .. index:: fixmn2 instruction pattern + +fixmn2 + Convert operand 1 (valid for floating point mode :samp:`{m}`) to fixed + point mode :samp:`{n}` as a signed number and store in operand 0 (which + has mode :samp:`{n}`). This instruction's result is defined only when + the value of operand 1 is an integer. + + If the machine description defines this pattern, it also needs to + define the ``ftrunc`` pattern. + + .. index:: fixunsmn2 instruction pattern + +fixunsmn2 + Convert operand 1 (valid for floating point mode :samp:`{m}`) to fixed + point mode :samp:`{n}` as an unsigned number and store in operand 0 (which + has mode :samp:`{n}`). This instruction's result is defined only when the + value of operand 1 is an integer. + + .. index:: ftruncm2 instruction pattern + +ftruncm2 + Convert operand 1 (valid for floating point mode :samp:`{m}`) to an + integer value, still represented in floating point mode :samp:`{m}`, and + store it in operand 0 (valid for floating point mode :samp:`{m}`). + + .. index:: fix_truncmn2 instruction pattern + +fix_truncmn2 + Like :samp:`fix{m}{n}2` but works for any floating point value + of mode :samp:`{m}` by converting the value to an integer. + + .. index:: fixuns_truncmn2 instruction pattern + +fixuns_truncmn2 + Like :samp:`fixuns{m}{n}2` but works for any floating point + value of mode :samp:`{m}` by converting the value to an integer. + + .. index:: truncmn2 instruction pattern + +truncmn2 + Truncate operand 1 (valid for mode :samp:`{m}`) to mode :samp:`{n}` and + store in operand 0 (which has mode :samp:`{n}`). Both modes must be fixed + point or both floating point. + + .. index:: extendmn2 instruction pattern + +extendmn2 + Sign-extend operand 1 (valid for mode :samp:`{m}`) to mode :samp:`{n}` and + store in operand 0 (which has mode :samp:`{n}`). Both modes must be fixed + point or both floating point. + + .. index:: zero_extendmn2 instruction pattern + +zero_extendmn2 + Zero-extend operand 1 (valid for mode :samp:`{m}`) to mode :samp:`{n}` and + store in operand 0 (which has mode :samp:`{n}`). Both modes must be fixed + point. + + .. index:: fractmn2 instruction pattern + +fractmn2 + Convert operand 1 of mode :samp:`{m}` to mode :samp:`{n}` and store in + operand 0 (which has mode :samp:`{n}`). Mode :samp:`{m}` and mode :samp:`{n}` + could be fixed-point to fixed-point, signed integer to fixed-point, + fixed-point to signed integer, floating-point to fixed-point, + or fixed-point to floating-point. + When overflows or underflows happen, the results are undefined. + + .. index:: satfractmn2 instruction pattern + +satfractmn2 + Convert operand 1 of mode :samp:`{m}` to mode :samp:`{n}` and store in + operand 0 (which has mode :samp:`{n}`). Mode :samp:`{m}` and mode :samp:`{n}` + could be fixed-point to fixed-point, signed integer to fixed-point, + or floating-point to fixed-point. + When overflows or underflows happen, the instruction saturates the + results to the maximum or the minimum. + + .. index:: fractunsmn2 instruction pattern + +fractunsmn2 + Convert operand 1 of mode :samp:`{m}` to mode :samp:`{n}` and store in + operand 0 (which has mode :samp:`{n}`). Mode :samp:`{m}` and mode :samp:`{n}` + could be unsigned integer to fixed-point, or + fixed-point to unsigned integer. + When overflows or underflows happen, the results are undefined. + + .. index:: satfractunsmn2 instruction pattern + +satfractunsmn2 + Convert unsigned integer operand 1 of mode :samp:`{m}` to fixed-point mode + :samp:`{n}` and store in operand 0 (which has mode :samp:`{n}`). + When overflows or underflows happen, the instruction saturates the + results to the maximum or the minimum. + + .. index:: extvm instruction pattern + +extvm + Extract a bit-field from register operand 1, sign-extend it, and store + it in operand 0. Operand 2 specifies the width of the field in bits + and operand 3 the starting bit, which counts from the most significant + bit if :samp:`BITS_BIG_ENDIAN` is true and from the least significant bit + otherwise. + + Operands 0 and 1 both have mode :samp:`{m}`. Operands 2 and 3 have a + target-specific mode. + + .. index:: extvmisalignm instruction pattern + +extvmisalignm + Extract a bit-field from memory operand 1, sign extend it, and store + it in operand 0. Operand 2 specifies the width in bits and operand 3 + the starting bit. The starting bit is always somewhere in the first byte of + operand 1; it counts from the most significant bit if :samp:`BITS_BIG_ENDIAN` + is true and from the least significant bit otherwise. + + Operand 0 has mode :samp:`{m}` while operand 1 has ``BLK`` mode. + Operands 2 and 3 have a target-specific mode. + + The instruction must not read beyond the last byte of the bit-field. + + .. index:: extzvm instruction pattern + +extzvm + Like :samp:`extv{m}` except that the bit-field value is zero-extended. + + .. index:: extzvmisalignm instruction pattern + +extzvmisalignm + Like :samp:`extvmisalign{m}` except that the bit-field value is + zero-extended. + + .. index:: insvm instruction pattern + +insvm + Insert operand 3 into a bit-field of register operand 0. Operand 1 + specifies the width of the field in bits and operand 2 the starting bit, + which counts from the most significant bit if :samp:`BITS_BIG_ENDIAN` + is true and from the least significant bit otherwise. + + Operands 0 and 3 both have mode :samp:`{m}`. Operands 1 and 2 have a + target-specific mode. + + .. index:: insvmisalignm instruction pattern + +insvmisalignm + Insert operand 3 into a bit-field of memory operand 0. Operand 1 + specifies the width of the field in bits and operand 2 the starting bit. + The starting bit is always somewhere in the first byte of operand 0; + it counts from the most significant bit if :samp:`BITS_BIG_ENDIAN` + is true and from the least significant bit otherwise. + + Operand 3 has mode :samp:`{m}` while operand 0 has ``BLK`` mode. + Operands 1 and 2 have a target-specific mode. + + The instruction must not read or write beyond the last byte of the bit-field. + + .. index:: extv instruction pattern + +extv + Extract a bit-field from operand 1 (a register or memory operand), where + operand 2 specifies the width in bits and operand 3 the starting bit, + and store it in operand 0. Operand 0 must have mode ``word_mode``. + Operand 1 may have mode ``byte_mode`` or ``word_mode`` ; often + ``word_mode`` is allowed only for registers. Operands 2 and 3 must + be valid for ``word_mode``. + + The RTL generation pass generates this instruction only with constants + for operands 2 and 3 and the constant is never zero for operand 2. + + The bit-field value is sign-extended to a full word integer + before it is stored in operand 0. + + This pattern is deprecated; please use :samp:`extv{m}` and + ``extvmisalignm`` instead. + + .. index:: extzv instruction pattern + +extzv + Like :samp:`extv` except that the bit-field value is zero-extended. + + This pattern is deprecated; please use :samp:`extzv{m}` and + ``extzvmisalignm`` instead. + + .. index:: insv instruction pattern + +insv + Store operand 3 (which must be valid for ``word_mode``) into a + bit-field in operand 0, where operand 1 specifies the width in bits and + operand 2 the starting bit. Operand 0 may have mode ``byte_mode`` or + ``word_mode`` ; often ``word_mode`` is allowed only for registers. + Operands 1 and 2 must be valid for ``word_mode``. + + The RTL generation pass generates this instruction only with constants + for operands 1 and 2 and the constant is never zero for operand 1. + + This pattern is deprecated; please use :samp:`insv{m}` and + ``insvmisalignm`` instead. + + .. index:: movmodecc instruction pattern + +movmodecc + Conditionally move operand 2 or operand 3 into operand 0 according to the + comparison in operand 1. If the comparison is true, operand 2 is moved + into operand 0, otherwise operand 3 is moved. + + The mode of the operands being compared need not be the same as the operands + being moved. Some machines, sparc64 for example, have instructions that + conditionally move an integer value based on the floating point condition + codes and vice versa. + + If the machine does not have conditional move instructions, do not + define these patterns. + + .. index:: addmodecc instruction pattern + +addmodecc + Similar to :samp:`mov{mode}cc` but for conditional addition. Conditionally + move operand 2 or (operands 2 + operand 3) into operand 0 according to the + comparison in operand 1. If the comparison is false, operand 2 is moved into + operand 0, otherwise (operand 2 + operand 3) is moved. + + .. index:: cond_addmode instruction pattern, cond_submode instruction pattern, cond_mulmode instruction pattern, cond_divmode instruction pattern, cond_udivmode instruction pattern, cond_modmode instruction pattern, cond_umodmode instruction pattern, cond_andmode instruction pattern, cond_iormode instruction pattern, cond_xormode instruction pattern, cond_sminmode instruction pattern, cond_smaxmode instruction pattern, cond_uminmode instruction pattern, cond_umaxmode instruction pattern, cond_fminmode instruction pattern, cond_fmaxmode instruction pattern, cond_ashlmode instruction pattern, cond_ashrmode instruction pattern, cond_lshrmode instruction pattern + +cond_addmode cond_submode cond_mulmode cond_divmode cond_udivmode cond_modmode cond_umodmode cond_andmode cond_iormode cond_xormode cond_sminmode cond_smaxmode cond_uminmode cond_umaxmode cond_fminmode cond_fmaxmode cond_ashlmode cond_ashrmode cond_lshrmode + When operand 1 is true, perform an operation on operands 2 and 3 and + store the result in operand 0, otherwise store operand 4 in operand 0. + The operation works elementwise if the operands are vectors. + + The scalar case is equivalent to: + + .. code-block:: c++ + + op0 = op1 ? op2 op op3 : op4; + + while the vector case is equivalent to: + + .. code-block:: c++ + + for (i = 0; i < GET_MODE_NUNITS (m); i++) + op0[i] = op1[i] ? op2[i] op op3[i] : op4[i]; + + where, for example, :samp:`{op}` is ``+`` for :samp:`cond_add{mode}`. + + When defined for floating-point modes, the contents of :samp:`op3[i]` + are not interpreted if :samp:`op1[i]` is false, just like they would not + be in a normal C :samp:`?:` condition. + + Operands 0, 2, 3 and 4 all have mode :samp:`{m}`. Operand 1 is a scalar + integer if :samp:`{m}` is scalar, otherwise it has the mode returned by + ``TARGET_VECTORIZE_GET_MASK_MODE``. + + :samp:`cond_{op}{mode}` generally corresponds to a conditional + form of :samp:`{op}{mode}3`. As an exception, the vector forms + of shifts correspond to patterns like ``vashlmode3`` rather + than patterns like ``ashlmode3``. + + .. index:: cond_fmamode instruction pattern, cond_fmsmode instruction pattern, cond_fnmamode instruction pattern, cond_fnmsmode instruction pattern + +cond_fmamode cond_fmsmode cond_fnmamode cond_fnmsmode + Like :samp:`cond_add{m}`, except that the conditional operation + takes 3 operands rather than two. For example, the vector form of + :samp:`cond_fma{mode}` is equivalent to: + + .. code-block:: c++ + + for (i = 0; i < GET_MODE_NUNITS (m); i++) + op0[i] = op1[i] ? fma (op2[i], op3[i], op4[i]) : op5[i]; + + .. index:: negmodecc instruction pattern + +negmodecc + Similar to :samp:`mov{mode}cc` but for conditional negation. Conditionally + move the negation of operand 2 or the unchanged operand 3 into operand 0 + according to the comparison in operand 1. If the comparison is true, the negation + of operand 2 is moved into operand 0, otherwise operand 3 is moved. + + .. index:: notmodecc instruction pattern + +notmodecc + Similar to :samp:`neg{mode}cc` but for conditional complement. + Conditionally move the bitwise complement of operand 2 or the unchanged + operand 3 into operand 0 according to the comparison in operand 1. + If the comparison is true, the complement of operand 2 is moved into + operand 0, otherwise operand 3 is moved. + + .. index:: cstoremode4 instruction pattern + +cstoremode4 + Store zero or nonzero in operand 0 according to whether a comparison + is true. Operand 1 is a comparison operator. Operand 2 and operand 3 + are the first and second operand of the comparison, respectively. + You specify the mode that operand 0 must have when you write the + ``match_operand`` expression. The compiler automatically sees which + mode you have used and supplies an operand of that mode. + + The value stored for a true condition must have 1 as its low bit, or + else must be negative. Otherwise the instruction is not suitable and + you should omit it from the machine description. You describe to the + compiler exactly which value is stored by defining the macro + ``STORE_FLAG_VALUE`` (see :ref:`misc`). If a description cannot be + found that can be used for all the possible comparison operators, you + should pick one and use a ``define_expand`` to map all results + onto the one you chose. + + These operations may ``FAIL``, but should do so only in relatively + uncommon cases; if they would ``FAIL`` for common cases involving + integer comparisons, it is best to restrict the predicates to not + allow these operands. Likewise if a given comparison operator will + always fail, independent of the operands (for floating-point modes, the + ``ordered_comparison_operator`` predicate is often useful in this case). + + If this pattern is omitted, the compiler will generate a conditional + branch---for example, it may copy a constant one to the target and branching + around an assignment of zero to the target---or a libcall. If the predicate + for operand 1 only rejects some operators, it will also try reordering the + operands and/or inverting the result value (e.g. by an exclusive OR). + These possibilities could be cheaper or equivalent to the instructions + used for the :samp:`cstore{mode}4` pattern followed by those required + to convert a positive result from ``STORE_FLAG_VALUE`` to 1; in this + case, you can and should make operand 1's predicate reject some operators + in the :samp:`cstore{mode}4` pattern, or remove the pattern altogether + from the machine description. + + .. index:: cbranchmode4 instruction pattern + +cbranchmode4 + Conditional branch instruction combined with a compare instruction. + Operand 0 is a comparison operator. Operand 1 and operand 2 are the + first and second operands of the comparison, respectively. Operand 3 + is the ``code_label`` to jump to. + + .. index:: jump instruction pattern + +jump + A jump inside a function; an unconditional branch. Operand 0 is the + ``code_label`` to jump to. This pattern name is mandatory on all + machines. + + .. index:: call instruction pattern + +call + Subroutine call instruction returning no value. Operand 0 is the + function to call; operand 1 is the number of bytes of arguments pushed + as a ``const_int``. Operand 2 is the result of calling the target + hook ``TARGET_FUNCTION_ARG`` with the second argument ``arg`` + yielding true for ``arg.end_marker_p ()``, in a call after all + parameters have been passed to that hook. By default this is the first + register beyond those used for arguments in the call, or ``NULL`` if + all the argument-registers are used in the call. + + On most machines, operand 2 is not actually stored into the RTL + pattern. It is supplied for the sake of some RISC machines which need + to put this information into the assembler code; they can put it in + the RTL instead of operand 1. + + Operand 0 should be a ``mem`` RTX whose address is the address of the + function. Note, however, that this address can be a ``symbol_ref`` + expression even if it would not be a legitimate memory address on the + target machine. If it is also not a valid argument for a call + instruction, the pattern for this operation should be a + ``define_expand`` (see :ref:`expander-definitions`) that places the + address into a register and uses that register in the call instruction. + + .. index:: call_value instruction pattern + +call_value + Subroutine call instruction returning a value. Operand 0 is the hard + register in which the value is returned. There are three more + operands, the same as the three operands of the :samp:`call` + instruction (but with numbers increased by one). + + Subroutines that return ``BLKmode`` objects use the :samp:`call` + insn. + + .. index:: call_pop instruction pattern, call_value_pop instruction pattern + +:samp:`{call_pop}, {call_value_pop}` + Similar to :samp:`call` and :samp:`call_value`, except used if defined and + if ``RETURN_POPS_ARGS`` is nonzero. They should emit a ``parallel`` + that contains both the function call and a ``set`` to indicate the + adjustment made to the frame pointer. + + For machines where ``RETURN_POPS_ARGS`` can be nonzero, the use of these + patterns increases the number of functions for which the frame pointer + can be eliminated, if desired. + + .. index:: untyped_call instruction pattern + +untyped_call + Subroutine call instruction returning a value of any type. Operand 0 is + the function to call; operand 1 is a memory location where the result of + calling the function is to be stored; operand 2 is a ``parallel`` + expression where each element is a ``set`` expression that indicates + the saving of a function return value into the result block. + + This instruction pattern should be defined to support + ``__builtin_apply`` on machines where special instructions are needed + to call a subroutine with arbitrary arguments or to save the value + returned. This instruction pattern is required on machines that have + multiple registers that can hold a return value + (i.e. ``FUNCTION_VALUE_REGNO_P`` is true for more than one register). + + .. index:: return instruction pattern + +return + Subroutine return instruction. This instruction pattern name should be + defined only if a single instruction can do all the work of returning + from a function. + + Like the :samp:`mov{m}` patterns, this pattern is also used after the + RTL generation phase. In this case it is to support machines where + multiple instructions are usually needed to return from a function, but + some class of functions only requires one instruction to implement a + return. Normally, the applicable functions are those which do not need + to save any registers or allocate stack space. + + It is valid for this pattern to expand to an instruction using + ``simple_return`` if no epilogue is required. + + .. index:: simple_return instruction pattern + +simple_return + Subroutine return instruction. This instruction pattern name should be + defined only if a single instruction can do all the work of returning + from a function on a path where no epilogue is required. This pattern + is very similar to the ``return`` instruction pattern, but it is emitted + only by the shrink-wrapping optimization on paths where the function + prologue has not been executed, and a function return should occur without + any of the effects of the epilogue. Additional uses may be introduced on + paths where both the prologue and the epilogue have executed. + + .. index:: reload_completed, leaf_function_p + + For such machines, the condition specified in this pattern should only + be true when ``reload_completed`` is nonzero and the function's + epilogue would only be a single instruction. For machines with register + windows, the routine ``leaf_function_p`` may be used to determine if + a register window push is required. + + Machines that have conditional return instructions should define patterns + such as + + .. code-block:: + + (define_insn "" + [(set (pc) + (if_then_else (match_operator + 0 "comparison_operator" + [(reg:CC CC_REG) (const_int 0)]) + (return) + (pc)))] + "condition" + "...") + + where :samp:`{condition}` would normally be the same condition specified on the + named :samp:`return` pattern. + + .. index:: untyped_return instruction pattern + +untyped_return + Untyped subroutine return instruction. This instruction pattern should + be defined to support ``__builtin_return`` on machines where special + instructions are needed to return a value of any type. + + Operand 0 is a memory location where the result of calling a function + with ``__builtin_apply`` is stored; operand 1 is a ``parallel`` + expression where each element is a ``set`` expression that indicates + the restoring of a function return value from the result block. + + .. index:: nop instruction pattern + +nop + No-op instruction. This instruction pattern name should always be defined + to output a no-op in assembler code. ``(const_int 0)`` will do as an + RTL pattern. + + .. index:: indirect_jump instruction pattern + +indirect_jump + An instruction to jump to an address which is operand zero. + This pattern name is mandatory on all machines. + + .. index:: casesi instruction pattern + +casesi + Instruction to jump through a dispatch table, including bounds checking. + This instruction takes five operands: + + * The index to dispatch on, which has mode ``SImode``. + + * The lower bound for indices in the table, an integer constant. + + * The total range of indices in the table---the largest index + minus the smallest one (both inclusive). + + * A label that precedes the table itself. + + * A label to jump to if the index has a value outside the bounds. + + The table is an ``addr_vec`` or ``addr_diff_vec`` inside of a + ``jump_table_data``. The number of elements in the table is one plus the + difference between the upper bound and the lower bound. + + .. index:: tablejump instruction pattern + +tablejump + Instruction to jump to a variable address. This is a low-level + capability which can be used to implement a dispatch table when there + is no :samp:`casesi` pattern. + + This pattern requires two operands: the address or offset, and a label + which should immediately precede the jump table. If the macro + ``CASE_VECTOR_PC_RELATIVE`` evaluates to a nonzero value then the first + operand is an offset which counts from the address of the table; otherwise, + it is an absolute address to jump to. In either case, the first operand has + mode ``Pmode``. + + The :samp:`tablejump` insn is always the last insn before the jump + table it uses. Its assembler code normally has no need to use the + second operand, but you should incorporate it in the RTL pattern so + that the jump optimizer will not delete the table as unreachable code. + + .. index:: doloop_end instruction pattern + +doloop_end + Conditional branch instruction that decrements a register and + jumps if the register is nonzero. Operand 0 is the register to + decrement and test; operand 1 is the label to jump to if the + register is nonzero. + See :ref:`looping-patterns`. + + This optional instruction pattern should be defined for machines with + low-overhead looping instructions as the loop optimizer will try to + modify suitable loops to utilize it. The target hook + ``TARGET_CAN_USE_DOLOOP_P`` controls the conditions under which + low-overhead loops can be used. + + .. index:: doloop_begin instruction pattern + +doloop_begin + Companion instruction to ``doloop_end`` required for machines that + need to perform some initialization, such as loading a special counter + register. Operand 1 is the associated ``doloop_end`` pattern and + operand 0 is the register that it decrements. + + If initialization insns do not always need to be emitted, use a + ``define_expand`` (see :ref:`expander-definitions`) and make it fail. + + .. index:: canonicalize_funcptr_for_compare instruction pattern + +canonicalize_funcptr_for_compare + Canonicalize the function pointer in operand 1 and store the result + into operand 0. + + Operand 0 is always a ``reg`` and has mode ``Pmode`` ; operand 1 + may be a ``reg``, ``mem``, ``symbol_ref``, ``const_int``, etc + and also has mode ``Pmode``. + + Canonicalization of a function pointer usually involves computing + the address of the function which would be called if the function + pointer were used in an indirect call. + + Only define this pattern if function pointers on the target machine + can have different values but still call the same function when + used in an indirect call. + + .. index:: save_stack_block instruction pattern, save_stack_function instruction pattern, save_stack_nonlocal instruction pattern, restore_stack_block instruction pattern, restore_stack_function instruction pattern, restore_stack_nonlocal instruction pattern + +save_stack_block save_stack_function save_stack_nonlocal restore_stack_block restore_stack_function restore_stack_nonlocal + Most machines save and restore the stack pointer by copying it to or + from an object of mode ``Pmode``. Do not define these patterns on + such machines. + + Some machines require special handling for stack pointer saves and + restores. On those machines, define the patterns corresponding to the + non-standard cases by using a ``define_expand`` (see :ref:`expander-definitions`) that produces the required insns. The three types of + saves and restores are: + + * :samp:`save_stack_block` saves the stack pointer at the start of a block + that allocates a variable-sized object, and :samp:`restore_stack_block` + restores the stack pointer when the block is exited. + + * :samp:`save_stack_function` and :samp:`restore_stack_function` do a + similar job for the outermost block of a function and are used when the + function allocates variable-sized objects or calls ``alloca``. Only + the epilogue uses the restored stack pointer, allowing a simpler save or + restore sequence on some machines. + + * :samp:`save_stack_nonlocal` is used in functions that contain labels + branched to by nested functions. It saves the stack pointer in such a + way that the inner function can use :samp:`restore_stack_nonlocal` to + restore the stack pointer. The compiler generates code to restore the + frame and argument pointer registers, but some machines require saving + and restoring additional data such as register window information or + stack backchains. Place insns in these patterns to save and restore any + such required data. + + When saving the stack pointer, operand 0 is the save area and operand 1 + is the stack pointer. The mode used to allocate the save area defaults + to ``Pmode`` but you can override that choice by defining the + ``STACK_SAVEAREA_MODE`` macro (see :ref:`storage-layout`). You must + specify an integral mode, or ``VOIDmode`` if no save area is needed + for a particular type of save (either because no save is needed or + because a machine-specific save area can be used). Operand 0 is the + stack pointer and operand 1 is the save area for restore operations. If + :samp:`save_stack_block` is defined, operand 0 must not be + ``VOIDmode`` since these saves can be arbitrarily nested. + + A save area is a ``mem`` that is at a constant offset from + ``virtual_stack_vars_rtx`` when the stack pointer is saved for use by + nonlocal gotos and a ``reg`` in the other two cases. + + .. index:: allocate_stack instruction pattern + +allocate_stack + Subtract (or add if ``STACK_GROWS_DOWNWARD`` is undefined) operand 1 from + the stack pointer to create space for dynamically allocated data. + + Store the resultant pointer to this space into operand 0. If you + are allocating space from the main stack, do this by emitting a + move insn to copy ``virtual_stack_dynamic_rtx`` to operand 0. + If you are allocating the space elsewhere, generate code to copy the + location of the space to operand 0. In the latter case, you must + ensure this space gets freed when the corresponding space on the main + stack is free. + + Do not define this pattern if all that must be done is the subtraction. + Some machines require other operations such as stack probes or + maintaining the back chain. Define this pattern to emit those + operations in addition to updating the stack pointer. + + .. index:: check_stack instruction pattern + +check_stack + If stack checking (see :ref:`stack-checking`) cannot be done on your system by + probing the stack, define this pattern to perform the needed check and signal + an error if the stack has overflowed. The single operand is the address in + the stack farthest from the current stack pointer that you need to validate. + Normally, on platforms where this pattern is needed, you would obtain the + stack limit from a global or thread-specific variable or register. + + .. index:: probe_stack_address instruction pattern + +probe_stack_address + If stack checking (see :ref:`stack-checking`) can be done on your system by + probing the stack but without the need to actually access it, define this + pattern and signal an error if the stack has overflowed. The single operand + is the memory address in the stack that needs to be probed. + + .. index:: probe_stack instruction pattern + +probe_stack + If stack checking (see :ref:`stack-checking`) can be done on your system by + probing the stack but doing it with a 'store zero' instruction is not valid + or optimal, define this pattern to do the probing differently and signal an + error if the stack has overflowed. The single operand is the memory reference + in the stack that needs to be probed. + + .. index:: nonlocal_goto instruction pattern + +nonlocal_goto + Emit code to generate a non-local goto, e.g., a jump from one function + to a label in an outer function. This pattern has four arguments, + each representing a value to be used in the jump. The first + argument is to be loaded into the frame pointer, the second is + the address to branch to (code to dispatch to the actual label), + the third is the address of a location where the stack is saved, + and the last is the address of the label, to be placed in the + location for the incoming static chain. + + On most machines you need not define this pattern, since GCC will + already generate the correct code, which is to load the frame pointer + and static chain, restore the stack (using the + :samp:`restore_stack_nonlocal` pattern, if defined), and jump indirectly + to the dispatcher. You need only define this pattern if this code will + not work on your machine. + + .. index:: nonlocal_goto_receiver instruction pattern + +nonlocal_goto_receiver + This pattern, if defined, contains code needed at the target of a + nonlocal goto after the code already generated by GCC. You will not + normally need to define this pattern. A typical reason why you might + need this pattern is if some value, such as a pointer to a global table, + must be restored when the frame pointer is restored. Note that a nonlocal + goto only occurs within a unit-of-translation, so a global table pointer + that is shared by all functions of a given module need not be restored. + There are no arguments. + + .. index:: exception_receiver instruction pattern + +exception_receiver + This pattern, if defined, contains code needed at the site of an + exception handler that isn't needed at the site of a nonlocal goto. You + will not normally need to define this pattern. A typical reason why you + might need this pattern is if some value, such as a pointer to a global + table, must be restored after control flow is branched to the handler of + an exception. There are no arguments. + + .. index:: builtin_setjmp_setup instruction pattern + +builtin_setjmp_setup + This pattern, if defined, contains additional code needed to initialize + the ``jmp_buf``. You will not normally need to define this pattern. + A typical reason why you might need this pattern is if some value, such + as a pointer to a global table, must be restored. Though it is + preferred that the pointer value be recalculated if possible (given the + address of a label for instance). The single argument is a pointer to + the ``jmp_buf``. Note that the buffer is five words long and that + the first three are normally used by the generic mechanism. + + .. index:: builtin_setjmp_receiver instruction pattern + +builtin_setjmp_receiver + This pattern, if defined, contains code needed at the site of a + built-in setjmp that isn't needed at the site of a nonlocal goto. You + will not normally need to define this pattern. A typical reason why you + might need this pattern is if some value, such as a pointer to a global + table, must be restored. It takes one argument, which is the label + to which builtin_longjmp transferred control; this pattern may be emitted + at a small offset from that label. + + .. index:: builtin_longjmp instruction pattern + +builtin_longjmp + This pattern, if defined, performs the entire action of the longjmp. + You will not normally need to define this pattern unless you also define + ``builtin_setjmp_setup``. The single argument is a pointer to the + ``jmp_buf``. + + .. index:: eh_return instruction pattern + +eh_return + This pattern, if defined, affects the way ``__builtin_eh_return``, + and thence the call frame exception handling library routines, are + built. It is intended to handle non-trivial actions needed along + the abnormal return path. + + The address of the exception handler to which the function should return + is passed as operand to this pattern. It will normally need to copied by + the pattern to some special register or memory location. + If the pattern needs to determine the location of the target call + frame in order to do so, it may use ``EH_RETURN_STACKADJ_RTX``, + if defined; it will have already been assigned. + + If this pattern is not defined, the default action will be to simply + copy the return address to ``EH_RETURN_HANDLER_RTX``. Either + that macro or this pattern needs to be defined if call frame exception + handling is to be used. + + .. index:: prologue instruction pattern + +.. _prologue-instruction-pattern: + +prologue + This pattern, if defined, emits RTL for entry to a function. The function + entry is responsible for setting up the stack frame, initializing the frame + pointer register, saving callee saved registers, etc. + + Using a prologue pattern is generally preferred over defining + ``TARGET_ASM_FUNCTION_PROLOGUE`` to emit assembly code for the prologue. + + The ``prologue`` pattern is particularly useful for targets which perform + instruction scheduling. + + .. index:: window_save instruction pattern + +.. _window_save-instruction-pattern: + +window_save + This pattern, if defined, emits RTL for a register window save. It should + be defined if the target machine has register windows but the window events + are decoupled from calls to subroutines. The canonical example is the SPARC + architecture. + + .. index:: epilogue instruction pattern + +.. _epilogue-instruction-pattern: + +epilogue + This pattern emits RTL for exit from a function. The function + exit is responsible for deallocating the stack frame, restoring callee saved + registers and emitting the return instruction. + + Using an epilogue pattern is generally preferred over defining + ``TARGET_ASM_FUNCTION_EPILOGUE`` to emit assembly code for the epilogue. + + The ``epilogue`` pattern is particularly useful for targets which perform + instruction scheduling or which have delay slots for their return instruction. + + .. index:: sibcall_epilogue instruction pattern + +sibcall_epilogue + This pattern, if defined, emits RTL for exit from a function without the final + branch back to the calling function. This pattern will be emitted before any + sibling call (aka tail call) sites. + + The ``sibcall_epilogue`` pattern must not clobber any arguments used for + parameter passing or any stack slots for arguments passed to the current + function. + + .. index:: trap instruction pattern + +trap + This pattern, if defined, signals an error, typically by causing some + kind of signal to be raised. + + .. index:: ctrapMM4 instruction pattern + +ctrapMM4 + Conditional trap instruction. Operand 0 is a piece of RTL which + performs a comparison, and operands 1 and 2 are the arms of the + comparison. Operand 3 is the trap code, an integer. + + A typical ``ctrap`` pattern looks like + + .. code-block:: + + (define_insn "ctrapsi4" + [(trap_if (match_operator 0 "trap_operator" + [(match_operand 1 "register_operand") + (match_operand 2 "immediate_operand")]) + (match_operand 3 "const_int_operand" "i"))] + "" + "...") + + .. index:: prefetch instruction pattern + +prefetch + This pattern, if defined, emits code for a non-faulting data prefetch + instruction. Operand 0 is the address of the memory to prefetch. Operand 1 + is a constant 1 if the prefetch is preparing for a write to the memory + address, or a constant 0 otherwise. Operand 2 is the expected degree of + temporal locality of the data and is a value between 0 and 3, inclusive; 0 + means that the data has no temporal locality, so it need not be left in the + cache after the access; 3 means that the data has a high degree of temporal + locality and should be left in all levels of cache possible; 1 and 2 mean, + respectively, a low or moderate degree of temporal locality. + + Targets that do not support write prefetches or locality hints can ignore + the values of operands 1 and 2. + + .. index:: blockage instruction pattern + +blockage + This pattern defines a pseudo insn that prevents the instruction + scheduler and other passes from moving instructions and using register + equivalences across the boundary defined by the blockage insn. + This needs to be an UNSPEC_VOLATILE pattern or a volatile ASM. + + .. index:: memory_blockage instruction pattern + +memory_blockage + This pattern, if defined, represents a compiler memory barrier, and will be + placed at points across which RTL passes may not propagate memory accesses. + This instruction needs to read and write volatile BLKmode memory. It does + not need to generate any machine instruction. If this pattern is not defined, + the compiler falls back to emitting an instruction corresponding + to ``asm volatile ("" ::: "memory")``. + + .. index:: memory_barrier instruction pattern + +memory_barrier + If the target memory model is not fully synchronous, then this pattern + should be defined to an instruction that orders both loads and stores + before the instruction with respect to loads and stores after the instruction. + This pattern has no operands. + + .. index:: speculation_barrier instruction pattern + +speculation_barrier + If the target can support speculative execution, then this pattern should + be defined to an instruction that will block subsequent execution until + any prior speculation conditions has been resolved. The pattern must also + ensure that the compiler cannot move memory operations past the barrier, + so it needs to be an UNSPEC_VOLATILE pattern. The pattern has no + operands. + + If this pattern is not defined then the default expansion of + ``__builtin_speculation_safe_value`` will emit a warning. You can + suppress this warning by defining this pattern with a final condition + of ``0`` (zero), which tells the compiler that a speculation + barrier is not needed for this target. + + .. index:: sync_compare_and_swapmode instruction pattern + +sync_compare_and_swapmode + This pattern, if defined, emits code for an atomic compare-and-swap + operation. Operand 1 is the memory on which the atomic operation is + performed. Operand 2 is the 'old' value to be compared against the + current contents of the memory location. Operand 3 is the 'new' value + to store in the memory if the compare succeeds. Operand 0 is the result + of the operation; it should contain the contents of the memory + before the operation. If the compare succeeds, this should obviously be + a copy of operand 2. + + This pattern must show that both operand 0 and operand 1 are modified. + + This pattern must issue any memory barrier instructions such that all + memory operations before the atomic operation occur before the atomic + operation and all memory operations after the atomic operation occur + after the atomic operation. + + For targets where the success or failure of the compare-and-swap + operation is available via the status flags, it is possible to + avoid a separate compare operation and issue the subsequent + branch or store-flag operation immediately after the compare-and-swap. + To this end, GCC will look for a ``MODE_CC`` set in the + output of ``sync_compare_and_swapmode`` ; if the machine + description includes such a set, the target should also define special + ``cbranchcc4`` and/or ``cstorecc4`` instructions. GCC will then + be able to take the destination of the ``MODE_CC`` set and pass it + to the ``cbranchcc4`` or ``cstorecc4`` pattern as the first + operand of the comparison (the second will be ``(const_int 0)``). + + For targets where the operating system may provide support for this + operation via library calls, the ``sync_compare_and_swap_optab`` + may be initialized to a function with the same interface as the + ``__sync_val_compare_and_swap_n`` built-in. If the entire + set of :samp:`{__sync}` builtins are supported via library calls, the + target can initialize all of the optabs at once with + ``init_sync_libfuncs``. + For the purposes of C++11 ``std::atomic::is_lock_free``, it is + assumed that these library calls do *not* use any kind of + interruptable locking. + + .. index:: sync_addmode instruction pattern, sync_submode instruction pattern, sync_iormode instruction pattern, sync_andmode instruction pattern, sync_xormode instruction pattern, sync_nandmode instruction pattern + +:samp:`sync_add{mode}`, :samp:`sync_sub{mode}` :samp:`sync_ior{mode}`, :samp:`sync_and{mode}` :samp:`sync_xor{mode}`, :samp:`sync_nand{mode}` + These patterns emit code for an atomic operation on memory. + Operand 0 is the memory on which the atomic operation is performed. + Operand 1 is the second operand to the binary operator. + + This pattern must issue any memory barrier instructions such that all + memory operations before the atomic operation occur before the atomic + operation and all memory operations after the atomic operation occur + after the atomic operation. + + If these patterns are not defined, the operation will be constructed + from a compare-and-swap operation, if defined. + + .. index:: sync_old_addmode instruction pattern, sync_old_submode instruction pattern, sync_old_iormode instruction pattern, sync_old_andmode instruction pattern, sync_old_xormode instruction pattern, sync_old_nandmode instruction pattern + +:samp:`sync_old_add{mode}`, :samp:`sync_old_sub{mode}` :samp:`sync_old_ior{mode}`, :samp:`sync_old_and{mode}` :samp:`sync_old_xor{mode}`, :samp:`sync_old_nand{mode}` + These patterns emit code for an atomic operation on memory, + and return the value that the memory contained before the operation. + Operand 0 is the result value, operand 1 is the memory on which the + atomic operation is performed, and operand 2 is the second operand + to the binary operator. + + This pattern must issue any memory barrier instructions such that all + memory operations before the atomic operation occur before the atomic + operation and all memory operations after the atomic operation occur + after the atomic operation. + + If these patterns are not defined, the operation will be constructed + from a compare-and-swap operation, if defined. + + .. index:: sync_new_addmode instruction pattern, sync_new_submode instruction pattern, sync_new_iormode instruction pattern, sync_new_andmode instruction pattern, sync_new_xormode instruction pattern, sync_new_nandmode instruction pattern + +:samp:`sync_new_add{mode}`, :samp:`sync_new_sub{mode}` :samp:`sync_new_ior{mode}`, :samp:`sync_new_and{mode}` :samp:`sync_new_xor{mode}`, :samp:`sync_new_nand{mode}` + These patterns are like their ``sync_old_op`` counterparts, + except that they return the value that exists in the memory location + after the operation, rather than before the operation. + + .. index:: sync_lock_test_and_setmode instruction pattern + +sync_lock_test_and_setmode + This pattern takes two forms, based on the capabilities of the target. + In either case, operand 0 is the result of the operand, operand 1 is + the memory on which the atomic operation is performed, and operand 2 + is the value to set in the lock. + + In the ideal case, this operation is an atomic exchange operation, in + which the previous value in memory operand is copied into the result + operand, and the value operand is stored in the memory operand. + + For less capable targets, any value operand that is not the constant 1 + should be rejected with ``FAIL``. In this case the target may use + an atomic test-and-set bit operation. The result operand should contain + 1 if the bit was previously set and 0 if the bit was previously clear. + The true contents of the memory operand are implementation defined. + + This pattern must issue any memory barrier instructions such that the + pattern as a whole acts as an acquire barrier, that is all memory + operations after the pattern do not occur until the lock is acquired. + + If this pattern is not defined, the operation will be constructed from + a compare-and-swap operation, if defined. + + .. index:: sync_lock_releasemode instruction pattern + +sync_lock_releasemode + This pattern, if defined, releases a lock set by + ``sync_lock_test_and_setmode``. Operand 0 is the memory + that contains the lock; operand 1 is the value to store in the lock. + + If the target doesn't implement full semantics for + ``sync_lock_test_and_setmode``, any value operand which is not + the constant 0 should be rejected with ``FAIL``, and the true contents + of the memory operand are implementation defined. + + This pattern must issue any memory barrier instructions such that the + pattern as a whole acts as a release barrier, that is the lock is + released only after all previous memory operations have completed. + + If this pattern is not defined, then a ``memory_barrier`` pattern + will be emitted, followed by a store of the value to the memory operand. + + .. index:: atomic_compare_and_swapmode instruction pattern + +atomic_compare_and_swapmode + This pattern, if defined, emits code for an atomic compare-and-swap + operation with memory model semantics. Operand 2 is the memory on which + the atomic operation is performed. Operand 0 is an output operand which + is set to true or false based on whether the operation succeeded. Operand + 1 is an output operand which is set to the contents of the memory before + the operation was attempted. Operand 3 is the value that is expected to + be in memory. Operand 4 is the value to put in memory if the expected + value is found there. Operand 5 is set to 1 if this compare and swap is to + be treated as a weak operation. Operand 6 is the memory model to be used + if the operation is a success. Operand 7 is the memory model to be used + if the operation fails. + + If memory referred to in operand 2 contains the value in operand 3, then + operand 4 is stored in memory pointed to by operand 2 and fencing based on + the memory model in operand 6 is issued. + + If memory referred to in operand 2 does not contain the value in operand 3, + then fencing based on the memory model in operand 7 is issued. + + If a target does not support weak compare-and-swap operations, or the port + elects not to implement weak operations, the argument in operand 5 can be + ignored. Note a strong implementation must be provided. + + If this pattern is not provided, the ``__atomic_compare_exchange`` + built-in functions will utilize the legacy ``sync_compare_and_swap`` + pattern with an ``__ATOMIC_SEQ_CST`` memory model. + + .. index:: atomic_loadmode instruction pattern + +atomic_loadmode + This pattern implements an atomic load operation with memory model + semantics. Operand 1 is the memory address being loaded from. Operand 0 + is the result of the load. Operand 2 is the memory model to be used for + the load operation. + + If not present, the ``__atomic_load`` built-in function will either + resort to a normal load with memory barriers, or a compare-and-swap + operation if a normal load would not be atomic. + + .. index:: atomic_storemode instruction pattern + +atomic_storemode + This pattern implements an atomic store operation with memory model + semantics. Operand 0 is the memory address being stored to. Operand 1 + is the value to be written. Operand 2 is the memory model to be used for + the operation. + + If not present, the ``__atomic_store`` built-in function will attempt to + perform a normal store and surround it with any required memory fences. If + the store would not be atomic, then an ``__atomic_exchange`` is + attempted with the result being ignored. + + .. index:: atomic_exchangemode instruction pattern + +atomic_exchangemode + This pattern implements an atomic exchange operation with memory model + semantics. Operand 1 is the memory location the operation is performed on. + Operand 0 is an output operand which is set to the original value contained + in the memory pointed to by operand 1. Operand 2 is the value to be + stored. Operand 3 is the memory model to be used. + + If this pattern is not present, the built-in function + ``__atomic_exchange`` will attempt to preform the operation with a + compare and swap loop. + + .. index:: atomic_addmode instruction pattern, atomic_submode instruction pattern, atomic_ormode instruction pattern, atomic_andmode instruction pattern, atomic_xormode instruction pattern, atomic_nandmode instruction pattern + +:samp:`atomic_add{mode}`, :samp:`atomic_sub{mode}` :samp:`atomic_or{mode}`, :samp:`atomic_and{mode}` :samp:`atomic_xor{mode}`, :samp:`atomic_nand{mode}` + These patterns emit code for an atomic operation on memory with memory + model semantics. Operand 0 is the memory on which the atomic operation is + performed. Operand 1 is the second operand to the binary operator. + Operand 2 is the memory model to be used by the operation. + + If these patterns are not defined, attempts will be made to use legacy + ``sync`` patterns, or equivalent patterns which return a result. If + none of these are available a compare-and-swap loop will be used. + + .. index:: atomic_fetch_addmode instruction pattern, atomic_fetch_submode instruction pattern, atomic_fetch_ormode instruction pattern, atomic_fetch_andmode instruction pattern, atomic_fetch_xormode instruction pattern, atomic_fetch_nandmode instruction pattern + +:samp:`atomic_fetch_add{mode}`, :samp:`atomic_fetch_sub{mode}` :samp:`atomic_fetch_or{mode}`, :samp:`atomic_fetch_and{mode}` :samp:`atomic_fetch_xor{mode}`, :samp:`atomic_fetch_nand{mode}` + These patterns emit code for an atomic operation on memory with memory + model semantics, and return the original value. Operand 0 is an output + operand which contains the value of the memory location before the + operation was performed. Operand 1 is the memory on which the atomic + operation is performed. Operand 2 is the second operand to the binary + operator. Operand 3 is the memory model to be used by the operation. + + If these patterns are not defined, attempts will be made to use legacy + ``sync`` patterns. If none of these are available a compare-and-swap + loop will be used. + + .. index:: atomic_add_fetchmode instruction pattern, atomic_sub_fetchmode instruction pattern, atomic_or_fetchmode instruction pattern, atomic_and_fetchmode instruction pattern, atomic_xor_fetchmode instruction pattern, atomic_nand_fetchmode instruction pattern + +:samp:`atomic_add_fetch{mode}`, :samp:`atomic_sub_fetch{mode}` :samp:`atomic_or_fetch{mode}`, :samp:`atomic_and_fetch{mode}` :samp:`atomic_xor_fetch{mode}`, :samp:`atomic_nand_fetch{mode}` + These patterns emit code for an atomic operation on memory with memory + model semantics and return the result after the operation is performed. + Operand 0 is an output operand which contains the value after the + operation. Operand 1 is the memory on which the atomic operation is + performed. Operand 2 is the second operand to the binary operator. + Operand 3 is the memory model to be used by the operation. + + If these patterns are not defined, attempts will be made to use legacy + ``sync`` patterns, or equivalent patterns which return the result before + the operation followed by the arithmetic operation required to produce the + result. If none of these are available a compare-and-swap loop will be + used. + + .. index:: atomic_test_and_set instruction pattern + +atomic_test_and_set + This pattern emits code for ``__builtin_atomic_test_and_set``. + Operand 0 is an output operand which is set to true if the previous + previous contents of the byte was "set", and false otherwise. Operand 1 + is the ``QImode`` memory to be modified. Operand 2 is the memory + model to be used. + + The specific value that defines "set" is implementation defined, and + is normally based on what is performed by the native atomic test and set + instruction. + + .. index:: atomic_bit_test_and_setmode instruction pattern, atomic_bit_test_and_complementmode instruction pattern, atomic_bit_test_and_resetmode instruction pattern + +atomic_bit_test_and_setmode atomic_bit_test_and_complementmode atomic_bit_test_and_resetmode + These patterns emit code for an atomic bitwise operation on memory with memory + model semantics, and return the original value of the specified bit. + Operand 0 is an output operand which contains the value of the specified bit + from the memory location before the operation was performed. Operand 1 is the + memory on which the atomic operation is performed. Operand 2 is the bit within + the operand, starting with least significant bit. Operand 3 is the memory model + to be used by the operation. Operand 4 is a flag - it is ``const1_rtx`` + if operand 0 should contain the original value of the specified bit in the + least significant bit of the operand, and ``const0_rtx`` if the bit should + be in its original position in the operand. + ``atomic_bit_test_and_setmode`` atomically sets the specified bit after + remembering its original value, ``atomic_bit_test_and_complementmode`` + inverts the specified bit and ``atomic_bit_test_and_resetmode`` clears + the specified bit. + + If these patterns are not defined, attempts will be made to use + ``atomic_fetch_ormode``, ``atomic_fetch_xormode`` or + ``atomic_fetch_andmode`` instruction patterns, or their ``sync`` + counterparts. If none of these are available a compare-and-swap + loop will be used. + + .. index:: atomic_add_fetch_cmp_0mode instruction pattern, atomic_sub_fetch_cmp_0mode instruction pattern, atomic_and_fetch_cmp_0mode instruction pattern, atomic_or_fetch_cmp_0mode instruction pattern, atomic_xor_fetch_cmp_0mode instruction pattern + +atomic_add_fetch_cmp_0mode atomic_sub_fetch_cmp_0mode atomic_and_fetch_cmp_0mode atomic_or_fetch_cmp_0mode atomic_xor_fetch_cmp_0mode + These patterns emit code for an atomic operation on memory with memory + model semantics if the fetch result is used only in a comparison against + zero. + Operand 0 is an output operand which contains a boolean result of comparison + of the value after the operation against zero. Operand 1 is the memory on + which the atomic operation is performed. Operand 2 is the second operand + to the binary operator. Operand 3 is the memory model to be used by the + operation. Operand 4 is an integer holding the comparison code, one of + ``EQ``, ``NE``, ``LT``, ``GT``, ``LE`` or ``GE``. + + If these patterns are not defined, attempts will be made to use separate + atomic operation and fetch pattern followed by comparison of the result + against zero. + + .. index:: mem_thread_fence instruction pattern + +mem_thread_fence + This pattern emits code required to implement a thread fence with + memory model semantics. Operand 0 is the memory model to be used. + + For the ``__ATOMIC_RELAXED`` model no instructions need to be issued + and this expansion is not invoked. + + The compiler always emits a compiler memory barrier regardless of what + expanding this pattern produced. + + If this pattern is not defined, the compiler falls back to expanding the + ``memory_barrier`` pattern, then to emitting ``__sync_synchronize`` + library call, and finally to just placing a compiler memory barrier. + + .. index:: get_thread_pointermode instruction pattern, set_thread_pointermode instruction pattern + +get_thread_pointermode set_thread_pointermode + These patterns emit code that reads/sets the TLS thread pointer. Currently, + these are only needed if the target needs to support the + ``__builtin_thread_pointer`` and ``__builtin_set_thread_pointer`` + builtins. + + The get/set patterns have a single output/input operand respectively, + with :samp:`{mode}` intended to be ``Pmode``. + + .. index:: stack_protect_combined_set instruction pattern + +stack_protect_combined_set + This pattern, if defined, moves a ``ptr_mode`` value from an address + whose declaration RTX is given in operand 1 to the memory in operand 0 + without leaving the value in a register afterward. If several + instructions are needed by the target to perform the operation (eg. to + load the address from a GOT entry then load the ``ptr_mode`` value + and finally store it), it is the backend's responsibility to ensure no + intermediate result gets spilled. This is to avoid leaking the value + some place that an attacker might use to rewrite the stack guard slot + after having clobbered it. + + If this pattern is not defined, then the address declaration is + expanded first in the standard way and a ``stack_protect_set`` + pattern is then generated to move the value from that address to the + address in operand 0. + + .. index:: stack_protect_set instruction pattern + +stack_protect_set + This pattern, if defined, moves a ``ptr_mode`` value from the valid + memory location in operand 1 to the memory in operand 0 without leaving + the value in a register afterward. This is to avoid leaking the value + some place that an attacker might use to rewrite the stack guard slot + after having clobbered it. + + Note: on targets where the addressing modes do not allow to load + directly from stack guard address, the address is expanded in a standard + way first which could cause some spills. + + If this pattern is not defined, then a plain move pattern is generated. + + .. index:: stack_protect_combined_test instruction pattern + +stack_protect_combined_test + This pattern, if defined, compares a ``ptr_mode`` value from an + address whose declaration RTX is given in operand 1 with the memory in + operand 0 without leaving the value in a register afterward and + branches to operand 2 if the values were equal. If several + instructions are needed by the target to perform the operation (eg. to + load the address from a GOT entry then load the ``ptr_mode`` value + and finally store it), it is the backend's responsibility to ensure no + intermediate result gets spilled. This is to avoid leaking the value + some place that an attacker might use to rewrite the stack guard slot + after having clobbered it. + + If this pattern is not defined, then the address declaration is + expanded first in the standard way and a ``stack_protect_test`` + pattern is then generated to compare the value from that address to the + value at the memory in operand 0. + + .. index:: stack_protect_test instruction pattern + +stack_protect_test + This pattern, if defined, compares a ``ptr_mode`` value from the + valid memory location in operand 1 with the memory in operand 0 without + leaving the value in a register afterward and branches to operand 2 if + the values were equal. + + If this pattern is not defined, then a plain compare pattern and + conditional branch pattern is used. + + .. index:: clear_cache instruction pattern + +clear_cache + This pattern, if defined, flushes the instruction cache for a region of + memory. The region is bounded to by the Pmode pointers in operand 0 + inclusive and operand 1 exclusive. + + If this pattern is not defined, a call to the library function + ``__clear_cache`` is used. + + .. index:: spaceshipm3 instruction pattern + +spaceshipm3 + Initialize output operand 0 with mode of integer type to -1, 0, 1 or 2 + if operand 1 with mode :samp:`{m}` compares less than operand 2, equal to + operand 2, greater than operand 2 or is unordered with operand 2. + :samp:`{m}` should be a scalar floating point mode. + + This pattern is not allowed to ``FAIL``. \ No newline at end of file diff --git a/gcc/doc/gccint/machine-descriptions/when-the-order-of-patterns-matters.rst b/gcc/doc/gccint/machine-descriptions/when-the-order-of-patterns-matters.rst new file mode 100644 index 00000000000..8fc2e6b5ca4 --- /dev/null +++ b/gcc/doc/gccint/machine-descriptions/when-the-order-of-patterns-matters.rst @@ -0,0 +1,29 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Pattern Ordering, Ordering of Patterns + +.. _pattern-ordering: + +When the Order of Patterns Matters +********************************** + +Sometimes an insn can match more than one instruction pattern. Then the +pattern that appears first in the machine description is the one used. +Therefore, more specific patterns (patterns that will match fewer things) +and faster instructions (those that will produce better code when they +do match) should usually go first in the description. + +In some cases the effect of ordering the patterns can be used to hide +a pattern when it is not valid. For example, the 68000 has an +instruction for converting a fullword to floating point and another +for converting a byte to floating point. An instruction converting +an integer to floating point could match either one. We put the +pattern to convert the fullword first to make sure that one will +be used rather than the other. (Otherwise a large integer might +be generated as a single-byte immediate quantity, which would not work.) +Instead of using this pattern ordering it would be possible to make the +pattern for convert-a-byte smart enough to deal properly with any +constant value. \ No newline at end of file diff --git a/gcc/doc/gccint/makefile-fragments.rst b/gcc/doc/gccint/makefile-fragments.rst new file mode 100644 index 00000000000..5ccfe7f070f --- /dev/null +++ b/gcc/doc/gccint/makefile-fragments.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: makefile fragment + +.. _fragments: + +Makefile Fragments +------------------ + +When you configure GCC using the :samp:`configure` script, it will +construct the file :samp:`Makefile` from the template file +:samp:`Makefile.in`. When it does this, it can incorporate makefile +fragments from the :samp:`config` directory. These are used to set +Makefile parameters that are not amenable to being calculated by +autoconf. The list of fragments to incorporate is set by +:samp:`config.gcc` (and occasionally :samp:`config.build` +and :samp:`config.host`); See :ref:`system-config`. + +Fragments are named either :samp:`t-{target}` or :samp:`x-{host}`, +depending on whether they are relevant to configuring GCC to produce +code for a particular target, or to configuring GCC to run on a +particular host. Here :samp:`{target}` and :samp:`{host}` are mnemonics +which usually have some relationship to the canonical system name, but +no formal connection. + +If these files do not exist, it means nothing needs to be added for a +given target or host. Most targets need a few :samp:`t-{target}` +fragments, but needing :samp:`x-{host}` fragments is rare. + +.. toctree:: + :maxdepth: 2 + + target-makefile-fragments + host-makefile-fragments \ No newline at end of file diff --git a/gcc/doc/gccint/match-and-simplify.rst b/gcc/doc/gccint/match-and-simplify.rst new file mode 100644 index 00000000000..84dea4ad4c0 --- /dev/null +++ b/gcc/doc/gccint/match-and-simplify.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Match and Simplify + +.. _match-and-simplify: + +Match and Simplify +------------------ + +The GIMPLE and GENERIC pattern matching project match-and-simplify +tries to address several issues. + +* unify expression simplifications currently spread and duplicated + over separate files like fold-const.cc, gimple-fold.cc and builtins.cc + +* allow for a cheap way to implement building and simplifying + non-trivial GIMPLE expressions, avoiding the need to go through + building and simplifying GENERIC via fold_buildN and then + gimplifying via force_gimple_operand + +To address these the project introduces a simple domain-specific language +to write expression simplifications from which code targeting GIMPLE +and GENERIC is auto-generated. The GENERIC variant follows the +fold_buildN API while for the GIMPLE variant and to address 2) new +APIs are introduced. + +.. toctree:: + :maxdepth: 2 + + gimple-api + the-language \ No newline at end of file diff --git a/gcc/doc/gccint/memory-management-and-type-information.rst b/gcc/doc/gccint/memory-management-and-type-information.rst new file mode 100644 index 00000000000..46ccf48ea37 --- /dev/null +++ b/gcc/doc/gccint/memory-management-and-type-information.rst @@ -0,0 +1,103 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GGC, GTY + +.. _type-information: + +Memory Management and Type Information +-------------------------------------- + +GCC uses some fairly sophisticated memory management techniques, which +involve determining information about GCC's data structures from GCC's +source code and using this information to perform garbage collection and +implement precompiled headers. + +A full C++ parser would be too complicated for this task, so a limited +subset of C++ is interpreted and special markers are used to determine +what parts of the source to look at. All ``struct``, ``union`` +and ``template`` structure declarations that define data structures +that are allocated under control of the garbage collector must be +marked. All global variables that hold pointers to garbage-collected +memory must also be marked. Finally, all global variables that need +to be saved and restored by a precompiled header must be marked. (The +precompiled header mechanism can only save static variables if they're +scalar. Complex data structures must be allocated in garbage-collected +memory to be saved in a precompiled header.) + +The full format of a marker is + +.. code-block:: c++ + + GTY (([option] [(param)], [option] [(param)] ...)) + +but in most cases no options are needed. The outer double parentheses +are still necessary, though: ``GTY(())``. Markers can appear: + +* In a structure definition, before the open brace; + +* In a global variable declaration, after the keyword ``static`` or + ``extern`` ; and + +* In a structure field definition, before the name of the field. + +Here are some examples of marking simple data structures and globals. + +.. code-block:: c++ + + struct GTY(()) tag + { + fields... + }; + + typedef struct GTY(()) tag + { + fields... + } *typename; + + static GTY(()) struct tag *list; /* points to GC memory */ + static GTY(()) int counter; /* save counter in a PCH */ + +The parser understands simple typedefs such as +``typedef struct tag *name;`` and +``typedef int name;``. +These don't need to be marked. + +However, in combination with GTY, avoid using typedefs such as +``typedef int_hash<...> name;`` +for these generate infinite-recursion code. +See :pr:`103157`. +Instead, you may use +``struct name : int_hash<...> {};``, +for example. + +Since ``gengtype`` 's understanding of C++ is limited, there are +several constructs and declarations that are not supported inside +classes/structures marked for automatic GC code generation. The +following C++ constructs produce a ``gengtype`` error on +structures/classes marked for automatic GC code generation: + +* Type definitions inside classes/structures are not supported. + +* Enumerations inside classes/structures are not supported. + +If you have a class or structure using any of the above constructs, +you need to mark that class as ``GTY ((user))`` and provide your +own marking routines (see section :ref:`user-gc` for details). + +It is always valid to include function definitions inside classes. +Those are always ignored by ``gengtype``, as it only cares about +data members. + +.. toctree:: + :maxdepth: 2 + + memory-management-and-type-information/the-inside-of-a-gty + memory-management-and-type-information/support-for-inheritance + memory-management-and-type-information/support-for-user-provided-gc-marking-routines + memory-management-and-type-information/marking-roots-for-the-garbage-collector + memory-management-and-type-information/source-files-containing-type-information + memory-management-and-type-information/how-to-invoke-the-garbage-collector + memory-management-and-type-information/troubleshooting-the-garbage-collector \ No newline at end of file diff --git a/gcc/doc/gccint/memory-management-and-type-information/how-to-invoke-the-garbage-collector.rst b/gcc/doc/gccint/memory-management-and-type-information/how-to-invoke-the-garbage-collector.rst new file mode 100644 index 00000000000..8d8a2180041 --- /dev/null +++ b/gcc/doc/gccint/memory-management-and-type-information/how-to-invoke-the-garbage-collector.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: garbage collector, invocation, ggc_collect + +.. _invoking-the-garbage-collector: + +How to invoke the garbage collector +*********************************** + +The GCC garbage collector GGC is only invoked explicitly. In contrast +with many other garbage collectors, it is not implicitly invoked by +allocation routines when a lot of memory has been consumed. So the +only way to have GGC reclaim storage is to call the ``ggc_collect`` +function explicitly. +With :samp:`{mode}` ``GGC_COLLECT_FORCE`` or otherwise (default +``GGC_COLLECT_HEURISTIC``) when the internal heuristic decides to +collect, this call is potentially an expensive operation, as it may +have to scan the entire heap. Beware that local variables (on the GCC +call stack) are not followed by such an invocation (as many other +garbage collectors do): you should reference all your data from static +or external ``GTY`` -ed variables, and it is advised to call +``ggc_collect`` with a shallow call stack. The GGC is an exact mark +and sweep garbage collector (so it does not scan the call stack for +pointers). In practice GCC passes don't often call ``ggc_collect`` +themselves, because it is called by the pass manager between passes. + +At the time of the ``ggc_collect`` call all pointers in the GC-marked +structures must be valid or ``NULL``. In practice this means that +there should not be uninitialized pointer fields in the structures even +if your code never reads or writes those fields at a particular +instance. One way to ensure this is to use cleared versions of +allocators unless all the fields are initialized manually immediately +after allocation. \ No newline at end of file diff --git a/gcc/doc/gccint/memory-management-and-type-information/marking-roots-for-the-garbage-collector.rst b/gcc/doc/gccint/memory-management-and-type-information/marking-roots-for-the-garbage-collector.rst new file mode 100644 index 00000000000..13cdf4632cf --- /dev/null +++ b/gcc/doc/gccint/memory-management-and-type-information/marking-roots-for-the-garbage-collector.rst @@ -0,0 +1,28 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: roots, marking, marking roots + +.. _ggc-roots: + +Marking Roots for the Garbage Collector +*************************************** + +In addition to keeping track of types, the type machinery also locates +the global variables (:dfn:`roots`) that the garbage collector starts +at. Roots must be declared using one of the following syntaxes: + +* ``extern GTY(([options])) typename;`` + +* ``static GTY(([options])) typename;`` + +The syntax + +* ``GTY(([options])) typename;`` + +is *not* accepted. There should be an ``extern`` declaration +of such a variable in a header somewhere---mark that, not the +definition. Or, if the variable is only used in one file, make it +``static``. \ No newline at end of file diff --git a/gcc/doc/gccint/memory-management-and-type-information/source-files-containing-type-information.rst b/gcc/doc/gccint/memory-management-and-type-information/source-files-containing-type-information.rst new file mode 100644 index 00000000000..b3caafe61b2 --- /dev/null +++ b/gcc/doc/gccint/memory-management-and-type-information/source-files-containing-type-information.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: generated files, files, generated + +.. _files: + +Source Files Containing Type Information +**************************************** + +Whenever you add ``GTY`` markers to a source file that previously +had none, or create a new source file containing ``GTY`` markers, +there are three things you need to do: + +* You need to add the file to the list of source files the type + machinery scans. There are four cases: + + * For a back-end file, this is usually done + automatically; if not, you should add it to ``target_gtfiles`` in + the appropriate port's entries in :samp:`config.gcc`. + + * For files shared by all front ends, add the filename to the + ``GTFILES`` variable in :samp:`Makefile.in`. + + * For files that are part of one front end, add the filename to the + ``gtfiles`` variable defined in the appropriate + :samp:`config-lang.in`. + Headers should appear before non-headers in this list. + + * For files that are part of some but not all front ends, add the + filename to the ``gtfiles`` variable of *all* the front ends + that use it. + +* If the file was a header file, you'll need to check that it's included + in the right place to be visible to the generated files. For a back-end + header file, this should be done automatically. For a front-end header + file, it needs to be included by the same file that includes + :samp:`gtype-{lang}.h`. For other header files, it needs to be + included in :samp:`gtype-desc.cc`, which is a generated file, so add it to + ``ifiles`` in ``open_base_file`` in :samp:`gengtype.cc`. + + For source files that aren't header files, the machinery will generate a + header file that should be included in the source file you just changed. + The file will be called :samp:`gt-{path}.h` where :samp:`{path}` is the + pathname relative to the :samp:`gcc` directory with slashes replaced by + -, so for example the header file to be included in + :samp:`cp/parser.cc` is called :samp:`gt-cp-parser.h`. The + generated header file should be included after everything else in the + source file. + +For language frontends, there is another file that needs to be included +somewhere. It will be called :samp:`gtype-{lang}.h`, where +:samp:`{lang}` is the name of the subdirectory the language is contained in. + +Plugins can add additional root tables. Run the ``gengtype`` +utility in plugin mode as ``gengtype -P pluginout.h source-dirfile-listplugin*.c`` with your plugin files +:samp:`{plugin*.c}` using ``GTY`` to generate the :samp:`{pluginout.h}` file. +The GCC build tree is needed to be present in that mode. \ No newline at end of file diff --git a/gcc/doc/gccint/memory-management-and-type-information/support-for-inheritance.rst b/gcc/doc/gccint/memory-management-and-type-information/support-for-inheritance.rst new file mode 100644 index 00000000000..1089f9879b9 --- /dev/null +++ b/gcc/doc/gccint/memory-management-and-type-information/support-for-inheritance.rst @@ -0,0 +1,59 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _inheritance-and-gty: + +Support for inheritance +*********************** + +gengtype has some support for simple class hierarchies. You can use +this to have gengtype autogenerate marking routines, provided: + +* There must be a concrete base class, with a discriminator expression + that can be used to identify which subclass an instance is. + +* Only single inheritance is used. + +* None of the classes within the hierarchy are templates. + +If your class hierarchy does not fit in this pattern, you must use +:ref:`user-gc` instead. + +The base class and its discriminator must be identified using the 'desc' +option. Each concrete subclass must use the 'tag' option to identify +which value of the discriminator it corresponds to. + +Every class in the hierarchy must have a ``GTY(())`` marker, as +gengtype will only attempt to parse classes that have such a marker [#f1]_. + +.. code-block:: c++ + + class GTY((desc("%h.kind"), tag("0"))) example_base + { + public: + int kind; + tree a; + }; + + class GTY((tag("1"))) some_subclass : public example_base + { + public: + tree b; + }; + + class GTY((tag("2"))) some_other_subclass : public example_base + { + public: + tree c; + }; + +The generated marking routines for the above will contain a 'switch' +on 'kind', visiting all appropriate fields. For example, if kind is +2, it will cast to 'some_other_subclass' and visit fields a, b, and c. + +.. [#f1] Classes lacking such a marker will not be identified as being + part of the hierarchy, and so the marking routines will not handle them, + leading to a assertion failure within the marking routines due to an + unknown tag value (assuming that assertions are enabled). \ No newline at end of file diff --git a/gcc/doc/gccint/memory-management-and-type-information/support-for-user-provided-gc-marking-routines.rst b/gcc/doc/gccint/memory-management-and-type-information/support-for-user-provided-gc-marking-routines.rst new file mode 100644 index 00000000000..be97da1ef82 --- /dev/null +++ b/gcc/doc/gccint/memory-management-and-type-information/support-for-user-provided-gc-marking-routines.rst @@ -0,0 +1,121 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: user gc + +.. _user-gc: + +Support for user-provided GC marking routines +********************************************* + +The garbage collector supports types for which no automatic marking +code is generated. For these types, the user is required to provide +three functions: one to act as a marker for garbage collection, and +two functions to act as marker and pointer walker for pre-compiled +headers. + +Given a structure ``struct GTY((user)) my_struct``, the following functions +should be defined to mark ``my_struct`` : + +.. code-block:: c++ + + void gt_ggc_mx (my_struct *p) + { + /* This marks field 'fld'. */ + gt_ggc_mx (p->fld); + } + + void gt_pch_nx (my_struct *p) + { + /* This marks field 'fld'. */ + gt_pch_nx (tp->fld); + } + + void gt_pch_nx (my_struct *p, gt_pointer_operator op, void *cookie) + { + /* For every field 'fld', call the given pointer operator. */ + op (&(tp->fld), NULL, cookie); + } + +In general, each marker ``M`` should call ``M`` for every +pointer field in the structure. Fields that are not allocated in GC +or are not pointers must be ignored. + +For embedded lists (e.g., structures with a ``next`` or ``prev`` +pointer), the marker must follow the chain and mark every element in +it. + +Note that the rules for the pointer walker ``gt_pch_nx (my_struct +*, gt_pointer_operator, void *)`` are slightly different. In this +case, the operation ``op`` must be applied to the *address* of +every pointer field. + +User-provided marking routines for template types +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When a template type ``TP`` is marked with ``GTY``, all +instances of that type are considered user-provided types. This means +that the individual instances of ``TP`` do not need to be marked +with ``GTY``. The user needs to provide template functions to mark +all the fields of the type. + +The following code snippets represent all the functions that need to +be provided. Note that type ``TP`` may reference to more than one +type. In these snippets, there is only one type ``T``, but there +could be more. + +.. code-block:: c++ + + template + void gt_ggc_mx (TP *tp) + { + extern void gt_ggc_mx (T&); + + /* This marks field 'fld' of type 'T'. */ + gt_ggc_mx (tp->fld); + } + + template + void gt_pch_nx (TP *tp) + { + extern void gt_pch_nx (T&); + + /* This marks field 'fld' of type 'T'. */ + gt_pch_nx (tp->fld); + } + + template + void gt_pch_nx (TP *tp, gt_pointer_operator op, void *cookie) + { + /* For every field 'fld' of 'tp' with type 'T *', call the given + pointer operator. */ + op (&(tp->fld), NULL, cookie); + } + + template + void gt_pch_nx (TP *tp, gt_pointer_operator, void *cookie) + { + extern void gt_pch_nx (T *, gt_pointer_operator, void *); + + /* For every field 'fld' of 'tp' with type 'T', call the pointer + walker for all the fields of T. */ + gt_pch_nx (&(tp->fld), op, cookie); + } + +Support for user-defined types is currently limited. The following +restrictions apply: + +* Type ``TP`` and all the argument types ``T`` must be + marked with ``GTY``. + +* Type ``TP`` can only have type names in its argument list. + +* The pointer walker functions are different for ``TP`` and + ``TP``. In the case of ``TP``, references to + ``T`` must be handled by calling ``gt_pch_nx`` (which + will, in turn, walk all the pointers inside fields of ``T``). + In the case of ``TP``, references to ``T *`` must be + handled by calling the ``op`` function on the address of the + pointer (see the code snippets above). \ No newline at end of file diff --git a/gcc/doc/gccint/memory-management-and-type-information/the-inside-of-a-gty.rst b/gcc/doc/gccint/memory-management-and-type-information/the-inside-of-a-gty.rst new file mode 100644 index 00000000000..fafe342a02b --- /dev/null +++ b/gcc/doc/gccint/memory-management-and-type-information/the-inside-of-a-gty.rst @@ -0,0 +1,324 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gty-options: + +The Inside of a GTY(()) +*********************** + +Sometimes the C code is not enough to fully describe the type +structure. Extra information can be provided with ``GTY`` options +and additional markers. Some options take a parameter, which may be +either a string or a type name, depending on the parameter. If an +option takes no parameter, it is acceptable either to omit the +parameter entirely, or to provide an empty string as a parameter. For +example, ``GTY ((skip))`` and ``GTY ((skip ("")))`` are +equivalent. + +When the parameter is a string, often it is a fragment of C code. Four +special escapes may be used in these strings, to refer to pieces of +the data structure being marked: + +.. index:: % in GTY option + +``%h`` + The current structure. + +``%1`` + The structure that immediately contains the current structure. + +``%0`` + The outermost structure that contains the current structure. + +``%a`` + A partial expression of the form ``[i1][i2]...`` that indexes + the array item currently being marked. + + For instance, suppose that you have a structure of the form + +.. code-block:: c++ + + struct A { + ... + }; + struct B { + struct A foo[12]; + }; + +and ``b`` is a variable of type ``struct B``. When marking +:samp:`b.foo[11]`, ``%h`` would expand to :samp:`b.foo[11]`, +``%0`` and ``%1`` would both expand to :samp:`b`, and ``%a`` +would expand to :samp:`[11]`. + +As in ordinary C, adjacent strings will be concatenated; this is +helpful when you have a complicated expression. + +.. code-block:: c++ + + GTY ((chain_next ("TREE_CODE (&%h.generic) == INTEGER_TYPE" + " ? TYPE_NEXT_VARIANT (&%h.generic)" + " : TREE_CHAIN (&%h.generic)"))) + +The available options are: + +.. index:: length + +:samp:`length ("{expression}")` + There are two places the type machinery will need to be explicitly told + the length of an array of non-atomic objects. The first case is when a + structure ends in a variable-length array, like this: + + .. code-block:: c++ + + struct GTY(()) rtvec_def { + int num_elem; /* number of elements */ + rtx GTY ((length ("%h.num_elem"))) elem[1]; + }; + + In this case, the ``length`` option is used to override the specified + array length (which should usually be ``1``). The parameter of the + option is a fragment of C code that calculates the length. + + The second case is when a structure or a global variable contains a + pointer to an array, like this: + + .. code-block:: c++ + + struct gimple_omp_for_iter * GTY((length ("%h.collapse"))) iter; + + In this case, ``iter`` has been allocated by writing something like + + .. code-block:: c++ + + x->iter = ggc_alloc_cleared_vec_gimple_omp_for_iter (collapse); + + and the ``collapse`` provides the length of the field. + + This second use of ``length`` also works on global variables, like: + + .. code-block:: c++ + + static GTY((length("reg_known_value_size"))) rtx *reg_known_value; + + Note that the ``length`` option is only meant for use with arrays of + non-atomic objects, that is, objects that contain pointers pointing to + other GTY-managed objects. For other GC-allocated arrays and strings + you should use ``atomic`` or ``string_length``. + + .. index:: string_length + +:samp:`string_length ("{expression}")` + In order to simplify production of PCH, a structure member that is a plain + array of bytes (an optionally ``const`` and/or ``unsigned`` ``char + *``) is treated specially by the infrastructure. Even if such an array has not + been allocated in GC-controlled memory, it will still be written properly into + a PCH. The machinery responsible for this needs to know the length of the + data; by default, the length is determined by calling ``strlen`` on the + pointer. The ``string_length`` option specifies an alternate way to + determine the length, such as by inspecting another struct member: + + .. code-block:: c++ + + struct GTY(()) non_terminated_string { + size_t sz; + const char * GTY((string_length ("%h.sz"))) data; + }; + + .. index:: skip + +``skip`` + If ``skip`` is applied to a field, the type machinery will ignore it. + This is somewhat dangerous; the only safe use is in a union when one + field really isn't ever used. + + .. index:: callback + +``callback`` + ``callback`` should be applied to fields with pointer to function type + and causes the field to be ignored similarly to ``skip``, except when + writing PCH and the field is non-NULL it will remember the field's address + for relocation purposes if the process writing PCH has different load base + from a process reading PCH. + + .. index:: for_user + +``for_user`` + Use this to mark types that need to be marked by user gc routines, but are not + refered to in a template argument. So if you have some user gc type T1 and a + non user gc type T2 you can give T2 the for_user option so that the marking + functions for T1 can call non mangled functions to mark T2. + + .. index:: desc, tag, default + +:samp:`desc ("{expression}")` :samp:`tag ("{constant}")` ``default`` + The type machinery needs to be told which field of a ``union`` is + currently active. This is done by giving each field a constant + ``tag`` value, and then specifying a discriminator using ``desc``. + The value of the expression given by ``desc`` is compared against + each ``tag`` value, each of which should be different. If no + ``tag`` is matched, the field marked with ``default`` is used if + there is one, otherwise no field in the union will be marked. + + In the ``desc`` option, the 'current structure' is the union that + it discriminates. Use ``%1`` to mean the structure containing it. + There are no escapes available to the ``tag`` option, since it is a + constant. + + For example, + + .. code-block:: c++ + + struct GTY(()) tree_binding + { + struct tree_common common; + union tree_binding_u { + tree GTY ((tag ("0"))) scope; + struct cp_binding_level * GTY ((tag ("1"))) level; + } GTY ((desc ("BINDING_HAS_LEVEL_P ((tree)&%0)"))) xscope; + tree value; + }; + + In this example, the value of BINDING_HAS_LEVEL_P when applied to a + ``struct tree_binding *`` is presumed to be 0 or 1. If 1, the type + mechanism will treat the field ``level`` as being present and if 0, + will treat the field ``scope`` as being present. + + The ``desc`` and ``tag`` options can also be used for inheritance + to denote which subclass an instance is. See :ref:`inheritance-and-gty` + for more information. + + .. index:: cache + +``cache`` + When the ``cache`` option is applied to a global variable gt_cleare_cache is + called on that variable between the mark and sweep phases of garbage + collection. The gt_clear_cache function is free to mark blocks as used, or to + clear pointers in the variable. + + .. index:: deletable + +``deletable`` + ``deletable``, when applied to a global variable, indicates that when + garbage collection runs, there's no need to mark anything pointed to + by this variable, it can just be set to ``NULL`` instead. This is used + to keep a list of free structures around for re-use. + + .. index:: maybe_undef + +``maybe_undef`` + When applied to a field, ``maybe_undef`` indicates that it's OK if + the structure that this fields points to is never defined, so long as + this field is always ``NULL``. This is used to avoid requiring + backends to define certain optional structures. It doesn't work with + language frontends. + + .. index:: nested_ptr + +:samp:`nested_ptr ({type}, "{to expression}", "{from expression}")` + The type machinery expects all pointers to point to the start of an + object. Sometimes for abstraction purposes it's convenient to have + a pointer which points inside an object. So long as it's possible to + convert the original object to and from the pointer, such pointers + can still be used. :samp:`{type}` is the type of the original object, + the :samp:`{to expression}` returns the pointer given the original object, + and the :samp:`{from expression}` returns the original object given + the pointer. The pointer will be available using the ``%h`` + escape. + + .. index:: chain_next, chain_prev, chain_circular + +:samp:`chain_next ("{expression}")` :samp:`chain_prev ("{expression}")` :samp:`chain_circular ("{expression}")` + It's helpful for the type machinery to know if objects are often + chained together in long lists; this lets it generate code that uses + less stack space by iterating along the list instead of recursing down + it. ``chain_next`` is an expression for the next item in the list, + ``chain_prev`` is an expression for the previous item. For singly + linked lists, use only ``chain_next`` ; for doubly linked lists, use + both. The machinery requires that taking the next item of the + previous item gives the original item. ``chain_circular`` is similar + to ``chain_next``, but can be used for circular single linked lists. + + .. index:: reorder + +:samp:`reorder ("{function name}")` + Some data structures depend on the relative ordering of pointers. If + the precompiled header machinery needs to change that ordering, it + will call the function referenced by the ``reorder`` option, before + changing the pointers in the object that's pointed to by the field the + option applies to. The function must take four arguments, with the + signature :samp:`void \*, void \*, gt_pointer_operator, void \*`. + The first parameter is a pointer to the structure that contains the + object being updated, or the object itself if there is no containing + structure. The second parameter is a cookie that should be ignored. + The third parameter is a routine that, given a pointer, will update it + to its correct new value. The fourth parameter is a cookie that must + be passed to the second parameter. + + PCH cannot handle data structures that depend on the absolute values + of pointers. ``reorder`` functions can be expensive. When + possible, it is better to depend on properties of the data, like an ID + number or the hash of a string instead. + + .. index:: atomic + +``atomic`` + The ``atomic`` option can only be used with pointers. It informs + the GC machinery that the memory that the pointer points to does not + contain any pointers, and hence it should be treated by the GC and PCH + machinery as an 'atomic' block of memory that does not need to be + examined when scanning memory for pointers. In particular, the + machinery will not scan that memory for pointers to mark them as + reachable (when marking pointers for GC) or to relocate them (when + writing a PCH file). + + The ``atomic`` option differs from the ``skip`` option. + ``atomic`` keeps the memory under Garbage Collection, but makes the + GC ignore the contents of the memory. ``skip`` is more drastic in + that it causes the pointer and the memory to be completely ignored by + the Garbage Collector. So, memory marked as ``atomic`` is + automatically freed when no longer reachable, while memory marked as + ``skip`` is not. + + The ``atomic`` option must be used with great care, because all + sorts of problem can occur if used incorrectly, that is, if the memory + the pointer points to does actually contain a pointer. + + Here is an example of how to use it: + + .. code-block:: c++ + + struct GTY(()) my_struct { + int number_of_elements; + unsigned int * GTY ((atomic)) elements; + }; + + In this case, ``elements`` is a pointer under GC, and the memory it + points to needs to be allocated using the Garbage Collector, and will + be freed automatically by the Garbage Collector when it is no longer + referenced. But the memory that the pointer points to is an array of + ``unsigned int`` elements, and the GC must not try to scan it to + find pointers to mark or relocate, which is why it is marked with the + ``atomic`` option. + + Note that, currently, global variables cannot be marked with + ``atomic`` ; only fields of a struct can. This is a known + limitation. It would be useful to be able to mark global pointers + with ``atomic`` to make the PCH machinery aware of them so that + they are saved and restored correctly to PCH files. + + .. index:: special + +:samp:`special ("{name}")` + The ``special`` option is used to mark types that have to be dealt + with by special case machinery. The parameter is the name of the + special case. See :samp:`gengtype.cc` for further details. Avoid + adding new special cases unless there is no other alternative. + + .. index:: user + +``user`` + The ``user`` option indicates that the code to mark structure + fields is completely handled by user-provided routines. See section + :ref:`user-gc` for details on what functions need to be provided. \ No newline at end of file diff --git a/gcc/doc/gccint/memory-management-and-type-information/troubleshooting-the-garbage-collector.rst b/gcc/doc/gccint/memory-management-and-type-information/troubleshooting-the-garbage-collector.rst new file mode 100644 index 00000000000..42b4b43e90f --- /dev/null +++ b/gcc/doc/gccint/memory-management-and-type-information/troubleshooting-the-garbage-collector.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: garbage collector, troubleshooting + +.. _troubleshooting: + +Troubleshooting the garbage collector +************************************* + +With the current garbage collector implementation, most issues should +show up as GCC compilation errors. Some of the most commonly +encountered issues are described below. + +* Gengtype does not produce allocators for a ``GTY`` -marked type. + Gengtype checks if there is at least one possible path from GC roots to + at least one instance of each type before outputting allocators. If + there is no such path, the ``GTY`` markers will be ignored and no + allocators will be output. Solve this by making sure that there exists + at least one such path. If creating it is unfeasible or raises a 'code + smell', consider if you really must use GC for allocating such type. + +* Link-time errors about undefined ``gt_ggc_r_foo_bar`` and + similarly-named symbols. Check if your :samp:`foo_bar` source file has + ``#include "gt-foo_bar.h"`` as its very last line. \ No newline at end of file diff --git a/gcc/doc/gccint/option-file-format.rst b/gcc/doc/gccint/option-file-format.rst new file mode 100644 index 00000000000..18738340e84 --- /dev/null +++ b/gcc/doc/gccint/option-file-format.rst @@ -0,0 +1,175 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _option-file-format: + +Option file format +****************** + +Option files are a simple list of records in which each field occupies +its own line and in which the records themselves are separated by +blank lines. Comments may appear on their own line anywhere within +the file and are preceded by semicolons. Whitespace is allowed before +the semicolon. + +The files can contain the following types of record: + +* A language definition record. These records have two fields: the + string :samp:`Language` and the name of the language. Once a language + has been declared in this way, it can be used as an option property. + See :ref:`option-properties`. + +* A target specific save record to save additional information. These + records have two fields: the string :samp:`TargetSave`, and a + declaration type to go in the ``cl_target_option`` structure. + +* A variable record to define a variable used to store option + information. These records have two fields: the string + :samp:`Variable`, and a declaration of the type and name of the + variable, optionally with an initializer (but without any trailing + :samp:`;`). These records may be used for variables used for many + options where declaring the initializer in a single option definition + record, or duplicating it in many records, would be inappropriate, or + for variables set in option handlers rather than referenced by + ``Var`` properties. + +* A variable record to define a variable used to store option + information. These records have two fields: the string + :samp:`TargetVariable`, and a declaration of the type and name of the + variable, optionally with an initializer (but without any trailing + :samp:`;`). :samp:`TargetVariable` is a combination of :samp:`Variable` + and :samp:`TargetSave` records in that the variable is defined in the + ``gcc_options`` structure, but these variables are also stored in + the ``cl_target_option`` structure. The variables are saved in the + target save code and restored in the target restore code. + +* A variable record to record any additional files that the + :samp:`options.h` file should include. This is useful to provide + enumeration or structure definitions needed for target variables. + These records have two fields: the string :samp:`HeaderInclude` and the + name of the include file. + +* A variable record to record any additional files that the + :samp:`options.cc` or :samp:`options-save.cc` file should include. This + is useful to provide + inline functions needed for target variables and/or ``#ifdef`` + sequences to properly set up the initialization. These records have + two fields: the string :samp:`SourceInclude` and the name of the + include file. + +* An enumeration record to define a set of strings that may be used as + arguments to an option or options. These records have three fields: + the string :samp:`Enum`, a space-separated list of properties and help + text used to describe the set of strings in :option:`--help` output. + Properties use the same format as option properties; the following are + valid: + + :samp:`Name({name})` + This property is required; :samp:`{name}` must be a name (suitable for use + in C identifiers) used to identify the set of strings in ``Enum`` + option properties. + + :samp:`Type({type})` + This property is required; :samp:`{type}` is the C type for variables set + by options using this enumeration together with ``Var``. + + :samp:`UnknownError({message})` + The message :samp:`{message}` will be used as an error message if the + argument is invalid; for enumerations without ``UnknownError``, a + generic error message is used. :samp:`{message}` should contain a single + :samp:`%qs` format, which will be used to format the invalid argument. + +* An enumeration value record to define one of the strings in a set + given in an :samp:`Enum` record. These records have two fields: the + string :samp:`EnumValue` and a space-separated list of properties. + Properties use the same format as option properties; the following are + valid: + + :samp:`Enum({name})` + This property is required; :samp:`{name}` says which :samp:`Enum` record + this :samp:`EnumValue` record corresponds to. + + :samp:`String({string})` + This property is required; :samp:`{string}` is the string option argument + being described by this record. + + :samp:`Value({value})` + This property is required; it says what value (representable as + ``int``) should be used for the given string. + + ``Canonical`` + This property is optional. If present, it says the present string is + the canonical one among all those with the given value. Other strings + yielding that value will be mapped to this one so specs do not need to + handle them. + + ``DriverOnly`` + This property is optional. If present, the present string will only + be accepted by the driver. This is used for cases such as + :option:`-march=native` that are processed by the driver so that + :samp:`gcc -v` shows how the options chosen depended on the system on + which the compiler was run. + + :samp:`Set({number})` + This property is optional, required for enumerations used in + ``EnumSet`` options. :samp:`{number}` should be decimal number between + 1 and 64 inclusive and divides the enumeration into a set of + sets of mutually exclusive arguments. Arguments with the same + :samp:`{number}` can't be specified together in the same option, but + arguments with different :samp:`{number}` can. :samp:`{value}` needs to be + chosen such that a mask of all :samp:`{value}` values from the same set + :samp:`{number}` bitwise ored doesn't overlap with masks for other sets. + When ``-foption=arg_from_set1,arg_from_set4`` and + ``-fno-option=arg_from_set3`` are used, the effect is that previous + value of the ``Var`` will get bits from set 1 and 4 masks cleared, + ored ``Value`` of ``arg_from_set1`` and ``arg_from_set4`` + and then will get bits from set 3 mask cleared. + +* An option definition record. These records have the following fields: + + * the name of the option, with the leading '-' removed + + * a space-separated list of option properties (see :ref:`option-properties`) + + * the help text to use for :option:`--help` (omitted if the second field + contains the ``Undocumented`` property). + + By default, all options beginning with 'f', 'W' or 'm' are + implicitly assumed to take a 'no-' form. This form should not be + listed separately. If an option beginning with one of these letters + does not have a 'no-' form, you can use the ``RejectNegative`` + property to reject it. + + The help text is automatically line-wrapped before being displayed. + Normally the name of the option is printed on the left-hand side of + the output and the help text is printed on the right. However, if the + help text contains a tab character, the text to the left of the tab is + used instead of the option's name and the text to the right of the + tab forms the help text. This allows you to elaborate on what type + of argument the option takes. + + There is no support for different help texts for different languages. + If an option is supported for multiple languages, use a generic + description that is correct for all of them. + + If an option has multiple option definition records (in different + front ends' :samp:`*.opt` files, and/or :samp:`gcc/common.opt`, for + example), convention is to not duplicate the help text for each of + them, but instead put a comment like ``; documented in common.opt`` + in place of the help text for all but one of the multiple option + definition records. + +* A target mask record. These records have one field of the form + :samp:`Mask({x})`. The options-processing script will automatically + allocate a bit in ``target_flags`` (see :ref:`run-time-target`) for + each mask name :samp:`{x}` and set the macro ``MASK_x`` to the + appropriate bitmask. It will also declare a ``TARGET_x`` + macro that has the value 1 when bit ``MASK_x`` is set and + 0 otherwise. + + They are primarily intended to declare target masks that are not + associated with user options, either because these masks represent + internal switches or because the options are not available on all + configurations and yet the masks always need to be defined. \ No newline at end of file diff --git a/gcc/doc/gccint/option-properties.rst b/gcc/doc/gccint/option-properties.rst new file mode 100644 index 00000000000..0f6d0b7970b --- /dev/null +++ b/gcc/doc/gccint/option-properties.rst @@ -0,0 +1,376 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _option-properties: + +Option properties +***************** + +The second field of an option record can specify any of the following +properties. When an option takes an argument, it is enclosed in parentheses +following the option property name. The parser that handles option files +is quite simplistic, and will be tricked by any nested parentheses within +the argument text itself; in this case, the entire option argument can +be wrapped in curly braces within the parentheses to demarcate it, e.g.: + +.. code-block:: c++ + + Condition({defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS)}) + +``Common`` + The option is available for all languages and targets. + +``Target`` + The option is available for all languages but is target-specific. + +``Driver`` + The option is handled by the compiler driver using code not shared + with the compilers proper (:samp:`cc1` etc.). + +``language`` + The option is available when compiling for the given language. + + It is possible to specify several different languages for the same + option. Each :samp:`{language}` must have been declared by an earlier + ``Language`` record. See :ref:`option-file-format`. + +``RejectDriver`` + The option is only handled by the compilers proper (:samp:`cc1` etc.) + and should not be accepted by the driver. + +``RejectNegative`` + The option does not have a 'no-' form. All options beginning with + 'f', 'W' or 'm' are assumed to have a 'no-' form unless this + property is used. + +:samp:`Negative({othername})` + The option will turn off another option :samp:`{othername}`, which is + the option name with the leading '-' removed. This chain action will + propagate through the ``Negative`` property of the option to be + turned off. The driver will prune options, removing those that are + turned off by some later option. This pruning is not done for options + with ``Joined`` or ``JoinedOrMissing`` properties, unless the + options have both the ``RejectNegative`` property and the ``Negative`` + property mentions itself. + + As a consequence, if you have a group of mutually-exclusive + options, their ``Negative`` properties should form a circular chain. + For example, if options :option:`-a`, :option:`-b` and + :option:`-c` are mutually exclusive, their respective ``Negative`` + properties should be :samp:`Negative({b})`, :samp:`Negative({c})` + and :samp:`Negative({a})`. + +``Joined`` ``Separate`` + The option takes a mandatory argument. ``Joined`` indicates + that the option and argument can be included in the same ``argv`` + entry (as with ``-mflush-func=name``, for example). + ``Separate`` indicates that the option and argument can be + separate ``argv`` entries (as with ``-o``). An option is + allowed to have both of these properties. + +``JoinedOrMissing`` + The option takes an optional argument. If the argument is given, + it will be part of the same ``argv`` entry as the option itself. + + This property cannot be used alongside ``Joined`` or ``Separate``. + +:samp:`MissingArgError({message})` + For an option marked ``Joined`` or ``Separate``, the message + :samp:`{message}` will be used as an error message if the mandatory + argument is missing; for options without ``MissingArgError``, a + generic error message is used. :samp:`{message}` should contain a single + :samp:`%qs` format, which will be used to format the name of the option + passed. + +:samp:`Args({n})` + For an option marked ``Separate``, indicate that it takes :samp:`{n}` + arguments. The default is 1. + +``UInteger`` + The option's argument is a non-negative integer consisting of either + decimal or hexadecimal digits interpreted as ``int``. Hexadecimal + integers may optionally start with the ``0x`` or ``0X`` prefix. + The option parser validates and converts the argument before passing + it to the relevant option handler. ``UInteger`` should also be used + with options like ``-falign-loops`` where both ``-falign-loops`` + and ``-falign-loops`` = :samp:`{n}` are supported to make sure the saved + options are given a full integer. Positive values of the argument in + excess of ``INT_MAX`` wrap around zero. + +``Host_Wide_Int`` + The option's argument is a non-negative integer consisting of either + decimal or hexadecimal digits interpreted as the widest integer type + on the host. As with an ``UInteger`` argument, hexadecimal integers + may optionally start with the ``0x`` or ``0X`` prefix. The option + parser validates and converts the argument before passing it to + the relevant option handler. ``Host_Wide_Int`` should be used with + options that need to accept very large values. Positive values of + the argument in excess of ``HOST_WIDE_INT_M1U`` are assigned + ``HOST_WIDE_INT_M1U``. + +:samp:`IntegerRange({n}, {m})` + The options's arguments are integers of type ``int``. The option's + parser validates that the value of an option integer argument is within + the closed range [ :samp:`{n}`, :samp:`{m}` ]. + +``ByteSize`` + A property applicable only to ``UInteger`` or ``Host_Wide_Int`` + arguments. The option's integer argument is interpreted as if in infinite + precision using saturation arithmetic in the corresponding type. The argument + may be followed by a :samp:`byte-size` suffix designating a multiple of bytes + such as ``kB`` and ``KiB`` for kilobyte and kibibyte, respectively, + ``MB`` and ``MiB`` for megabyte and mebibyte, ``GB`` and ``GiB`` + for gigabyte and gigibyte, and so on. ``ByteSize`` should be used for + with options that take a very large argument representing a size in bytes, + such as :option:`-Wlarger-than=`. + +``ToLower`` + The option's argument should be converted to lowercase as part of + putting it in canonical form, and before comparing with the strings + indicated by any ``Enum`` property. + +``NoDriverArg`` + For an option marked ``Separate``, the option only takes an + argument in the compiler proper, not in the driver. This is for + compatibility with existing options that are used both directly and + via :option:`-Wp,` ; new options should not have this property. + +:samp:`Var({var})` + The state of this option should be stored in variable :samp:`{var}` + (actually a macro for ``global_options.x_var``). + The way that the state is stored depends on the type of option: + +``WarnRemoved`` + The option is removed and every usage of such option will + result in a warning. We use it option backward compatibility. + +:samp:`Var({var}, {set})` + The option controls an integer variable :samp:`{var}` and is active when + :samp:`{var}` equals :samp:`{set}`. The option parser will set :samp:`{var}` to + :samp:`{set}` when the positive form of the option is used and ``!set`` + when the 'no-' form is used. + + :samp:`{var}` is declared in the same way as for the single-argument form + described above. + + * If the option uses the ``Mask`` or ``InverseMask`` properties, + :samp:`{var}` is the integer variable that contains the mask. + + * If the option is a normal on/off switch, :samp:`{var}` is an integer + variable that is nonzero when the option is enabled. The options + parser will set the variable to 1 when the positive form of the + option is used and 0 when the 'no-' form is used. + + * If the option takes an argument and has the ``UInteger`` property, + :samp:`{var}` is an integer variable that stores the value of the argument. + + * If the option takes an argument and has the ``Enum`` property, + :samp:`{var}` is a variable (type given in the ``Type`` property of the + :samp:`Enum` record whose ``Name`` property has the same argument as + the ``Enum`` property of this option) that stores the value of the + argument. + + * If the option has the ``Defer`` property, :samp:`{var}` is a pointer to + a ``VEC(cl_deferred_option,heap)`` that stores the option for later + processing. (:samp:`{var}` is declared with type ``void *`` and needs + to be cast to ``VEC(cl_deferred_option,heap)`` before use.) + + * Otherwise, if the option takes an argument, :samp:`{var}` is a pointer to + the argument string. The pointer will be null if the argument is optional + and wasn't given. + + The option-processing script will usually zero-initialize :samp:`{var}`. + You can modify this behavior using ``Init``. + +:samp:`Init({value})` + The variable specified by the ``Var`` property should be statically + initialized to :samp:`{value}`. If more than one option using the same + variable specifies ``Init``, all must specify the same initializer. + +:samp:`Mask({name})` + The option is associated with a bit in the ``target_flags`` + variable (see :ref:`run-time-target`) and is active when that bit is set. + You may also specify ``Var`` to select a variable other than + ``target_flags``. + + The options-processing script will automatically allocate a unique bit + for the option. If the option is attached to :samp:`target_flags`, + the script will set the macro ``MASK_name`` to the appropriate + bitmask. It will also declare a ``TARGET_name`` macro that has + the value 1 when the option is active and 0 otherwise. If you use ``Var`` + to attach the option to a different variable, the bitmask macro with be + called ``OPTION_MASK_name``. + +:samp:`InverseMask({othername})` :samp:`InverseMask({othername}, {thisname})` + The option is the inverse of another option that has the + ``Mask(othername)`` property. If :samp:`{thisname}` is given, + the options-processing script will declare a ``TARGET_thisname`` + macro that is 1 when the option is active and 0 otherwise. + +:samp:`Enum({name})` + The option's argument is a string from the set of strings associated + with the corresponding :samp:`Enum` record. The string is checked and + converted to the integer specified in the corresponding + :samp:`EnumValue` record before being passed to option handlers. + +``EnumSet`` + Must be used together with the ``Enum(name)`` property. + Corresponding :samp:`Enum` record must use ``Set`` properties. + The option's argument is either a string from the set like for + ``Enum(name)``, but with a slightly different behavior that + the whole ``Var`` isn't overwritten, but only the bits in all the + enumeration values with the same set bitwise ored together. + Or option's argument can be a comma separated list of strings where + each string is from a different ``Set(number)``. + +``EnumBitSet`` + Must be used together with the ``Enum(name)`` property. + Similar to :samp:`EnumSet`, but corresponding :samp:`Enum` record must + not use ``Set`` properties, each ``EnumValue`` should have + ``Value`` that is a power of 2, each value is treated as its own + set and its value as the set's mask, so there are no mutually + exclusive arguments. + +``Defer`` + The option should be stored in a vector, specified with ``Var``, + for later processing. + +:samp:`Alias({opt})` :samp:`Alias({opt}, {arg})` :samp:`Alias({opt}, {posarg}, {negarg})` + The option is an alias for :option:`-opt` (or the negative form + of that option, depending on ``NegativeAlias``). In the first form, + any argument passed to the alias is considered to be passed to + :option:`-opt`, and :option:`-opt` is considered to be + negated if the alias is used in negated form. In the second form, the + alias may not be negated or have an argument, and :samp:`{posarg}` is + considered to be passed as an argument to :option:`-opt`. In the + third form, the alias may not have an argument, if the alias is used + in the positive form then :samp:`{posarg}` is considered to be passed to + :option:`-opt`, and if the alias is used in the negative form + then :samp:`{negarg}` is considered to be passed to :option:`-opt`. + + Aliases should not specify ``Var`` or ``Mask`` or + ``UInteger``. Aliases should normally specify the same languages + as the target of the alias; the flags on the target will be used to + determine any diagnostic for use of an option for the wrong language, + while those on the alias will be used to identify what command-line + text is the option and what text is any argument to that option. + + When an ``Alias`` definition is used for an option, driver specs do + not need to handle it and no :samp:`OPT_` enumeration value is defined + for it; only the canonical form of the option will be seen in those + places. + +``NegativeAlias`` + For an option marked with ``Alias(opt)``, the option is + considered to be an alias for the positive form of :option:`-opt` + if negated and for the negative form of :option:`-opt` if not + negated. ``NegativeAlias`` may not be used with the forms of + ``Alias`` taking more than one argument. + +``Ignore`` + This option is ignored apart from printing any warning specified using + ``Warn``. The option will not be seen by specs and no :samp:`OPT_` + enumeration value is defined for it. + +``SeparateAlias`` + For an option marked with ``Joined``, ``Separate`` and + ``Alias``, the option only acts as an alias when passed a separate + argument; with a joined argument it acts as a normal option, with an + :samp:`OPT_` enumeration value. This is for compatibility with the + Java :option:`-d` option and should not be used for new options. + +:samp:`Warn({message})` + If this option is used, output the warning :samp:`{message}`. + :samp:`{message}` is a format string, either taking a single operand with + a :samp:`%qs` format which is the option name, or not taking any + operands, which is passed to the :samp:`warning` function. If an alias + is marked ``Warn``, the target of the alias must not also be marked + ``Warn``. + +``Warning`` + This is a warning option and should be shown as such in + :option:`--help` output. This flag does not currently affect anything + other than :option:`--help`. + +``Optimization`` + This is an optimization option. It should be shown as such in + :option:`--help` output, and any associated variable named using + ``Var`` should be saved and restored when the optimization level is + changed with ``optimize`` attributes. + +``PerFunction`` + This is an option that can be overridden on a per-function basis. + ``Optimization`` implies ``PerFunction``, but options that do not + affect executable code generation may use this flag instead, so that the + option is not taken into account in ways that might affect executable + code generation. + +``Param`` + This is an option that is a parameter. + +``Undocumented`` + The option is deliberately missing documentation and should not + be included in the :option:`--help` output. + +:samp:`Condition({cond})` + The option should only be accepted if preprocessor condition + :samp:`{cond}` is true. Note that any C declarations associated with the + option will be present even if :samp:`{cond}` is false; :samp:`{cond}` simply + controls whether the option is accepted and whether it is printed in + the :option:`--help` output. + +``Save`` + Build the ``cl_target_option`` structure to hold a copy of the + option, add the functions ``cl_target_option_save`` and + ``cl_target_option_restore`` to save and restore the options. + +``SetByCombined`` + The option may also be set by a combined option such as + :option:`-ffast-math`. This causes the ``gcc_options`` struct to + have a field ``frontend_set_name``, where ``name`` + is the name of the field holding the value of this option (without the + leading ``x_``). This gives the front end a way to indicate that + the value has been set explicitly and should not be changed by the + combined option. For example, some front ends use this to prevent + :option:`-ffast-math` and :option:`-fno-fast-math` from changing the + value of :option:`-fmath-errno` for languages that do not use + ``errno``. + +:samp:`EnabledBy({opt})` :samp:`EnabledBy({opt} || {opt2})` :samp:`EnabledBy({opt} && {opt2})` + If not explicitly set, the option is set to the value of + :option:`-opt` ; multiple options can be given, separated by + ``||``. The third form using ``&&`` specifies that the option is + only set if both :samp:`{opt}` and :samp:`{opt2}` are set. The options :samp:`{opt}` + and :samp:`{opt2}` must have the ``Common`` property; otherwise, use + ``LangEnabledBy``. + +:samp:`LangEnabledBy({language}, {opt})` :samp:`LangEnabledBy({language}, {opt}, {posarg}, {negarg})` + When compiling for the given language, the option is set to the value + of :option:`-opt`, if not explicitly set. :samp:`{opt}` can be also a list + of ``||`` separated options. In the second form, if + :samp:`{opt}` is used in the positive form then :samp:`{posarg}` is considered + to be passed to the option, and if :samp:`{opt}` is used in the negative + form then :samp:`{negarg}` is considered to be passed to the option. It + is possible to specify several different languages. Each + :samp:`{language}` must have been declared by an earlier ``Language`` + record. See :ref:`option-file-format`. + +``NoDWARFRecord`` + The option is omitted from the producer string written by + :option:`-grecord-gcc-switches`. + +``PchIgnore`` + Even if this is a target option, this option will not be recorded / compared + to determine if a precompiled header file matches. + +:samp:`CPP({var})` + The state of this option should be kept in sync with the preprocessor + option :samp:`{var}`. If this property is set, then properties ``Var`` + and ``Init`` must be set as well. + +:samp:`CppReason({CPP_W_Enum})` + This warning option corresponds to ``cpplib.h`` warning reason code + :samp:`{CPP_W_Enum}`. This should only be used for warning options of the + C-family front-ends. \ No newline at end of file diff --git a/gcc/doc/gccint/option-specification-files.rst b/gcc/doc/gccint/option-specification-files.rst new file mode 100644 index 00000000000..0a3459285a9 --- /dev/null +++ b/gcc/doc/gccint/option-specification-files.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: option specification files, optc-gen.awk + +.. _options: + +Option specification files +-------------------------- + +Most GCC command-line options are described by special option +definition files, the names of which conventionally end in +``.opt``. This chapter describes the format of these files. + +.. toctree:: + :maxdepth: 2 + + option-file-format + option-properties \ No newline at end of file diff --git a/gcc/doc/gccint/passes-and-files-of-the-compiler.rst b/gcc/doc/gccint/passes-and-files-of-the-compiler.rst new file mode 100644 index 00000000000..207d3814f63 --- /dev/null +++ b/gcc/doc/gccint/passes-and-files-of-the-compiler.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: passes and files of the compiler, files and passes of the compiler, compiler passes and files, pass dumps + +.. _passes: + +Passes and Files of the Compiler +-------------------------------- + +This chapter is dedicated to giving an overview of the optimization and +code generation passes of the compiler. In the process, it describes +some of the language front end interface, though this description is no +where near complete. + +.. toctree:: + :maxdepth: 2 + + passes-and-files-of-the-compiler/parsing-pass + passes-and-files-of-the-compiler/gimplification-pass + passes-and-files-of-the-compiler/pass-manager + passes-and-files-of-the-compiler/inter-procedural-optimization-passes + passes-and-files-of-the-compiler/tree-ssa-passes + passes-and-files-of-the-compiler/rtl-passes + passes-and-files-of-the-compiler/optimization-info \ No newline at end of file diff --git a/gcc/doc/gccint/passes-and-files-of-the-compiler/gimplification-pass.rst b/gcc/doc/gccint/passes-and-files-of-the-compiler/gimplification-pass.rst new file mode 100644 index 00000000000..fb9fa64e4fc --- /dev/null +++ b/gcc/doc/gccint/passes-and-files-of-the-compiler/gimplification-pass.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: gimplification, GIMPLE + +.. _gimplification-pass: + +Gimplification pass +******************* + +:dfn:`Gimplification` is a whimsical term for the process of converting +the intermediate representation of a function into the GIMPLE language +(see :ref:`gimple`). The term stuck, and so words like 'gimplification', +'gimplify', 'gimplifier' and the like are sprinkled throughout this +section of code. + +While a front end may certainly choose to generate GIMPLE directly if +it chooses, this can be a moderately complex process unless the +intermediate language used by the front end is already fairly simple. +Usually it is easier to generate GENERIC trees plus extensions +and let the language-independent gimplifier do most of the work. + +.. index:: gimplify_function_tree, gimplify_expr, lang_hooks.gimplify_expr + +The main entry point to this pass is ``gimplify_function_tree`` +located in :samp:`gimplify.cc`. From here we process the entire +function gimplifying each statement in turn. The main workhorse +for this pass is ``gimplify_expr``. Approximately everything +passes through here at least once, and it is from here that we +invoke the ``lang_hooks.gimplify_expr`` callback. + +The callback should examine the expression in question and return +``GS_UNHANDLED`` if the expression is not a language specific +construct that requires attention. Otherwise it should alter the +expression in some way to such that forward progress is made toward +producing valid GIMPLE. If the callback is certain that the +transformation is complete and the expression is valid GIMPLE, it +should return ``GS_ALL_DONE``. Otherwise it should return +``GS_OK``, which will cause the expression to be processed again. +If the callback encounters an error during the transformation (because +the front end is relying on the gimplification process to finish +semantic checks), it should return ``GS_ERROR``. \ No newline at end of file diff --git a/gcc/doc/gccint/passes-and-files-of-the-compiler/inter-procedural-optimization-passes.rst b/gcc/doc/gccint/passes-and-files-of-the-compiler/inter-procedural-optimization-passes.rst new file mode 100644 index 00000000000..18d4598baee --- /dev/null +++ b/gcc/doc/gccint/passes-and-files-of-the-compiler/inter-procedural-optimization-passes.rst @@ -0,0 +1,269 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: IPA passes, inter-procedural optimization passes + +.. _ipa-passes: + +Inter-procedural optimization passes +************************************ + +The inter-procedural optimization (IPA) passes use call graph +information to perform transformations across function boundaries. +IPA is a critical part of link-time optimization (LTO) and +whole-program (WHOPR) optimization, and these passes are structured +with the needs of LTO and WHOPR in mind by dividing their operations +into stages. For detailed discussion of the LTO/WHOPR IPA pass stages +and interfaces, see :ref:`IPA`. + +The following briefly describes the inter-procedural optimization (IPA) +passes, which are split into small IPA passes, regular IPA passes, +and late IPA passes, according to the LTO/WHOPR processing model. + +.. toctree:: + :maxdepth: 2 + + +.. index:: small IPA passes + +.. _small-ipa-passes: + +Small IPA passes +^^^^^^^^^^^^^^^^ + +A small IPA pass is a pass derived from ``simple_ipa_opt_pass``. +As described in :ref:`IPA`, it does everything at once and +defines only the *Execute* stage. During this +stage it accesses and modifies the function bodies. +No ``generate_summary``, ``read_summary``, or ``write_summary`` +hooks are defined. + +* IPA free lang data + + This pass frees resources that are used by the front end but are + not needed once it is done. It is located in :samp:`tree.cc` and is described by + ``pass_ipa_free_lang_data``. + +* IPA function and variable visibility + + This is a local function pass handling visibilities of all symbols. This + happens before LTO streaming, so :option:`-fwhole-program` should be ignored + at this level. It is located in :samp:`ipa-visibility.cc` and is described by + ``pass_ipa_function_and_variable_visibility``. + +* IPA remove symbols + + This pass performs reachability analysis and reclaims all unreachable nodes. + It is located in :samp:`passes.cc` and is described by + ``pass_ipa_remove_symbols``. + +* IPA OpenACC + + This is a pass group for OpenACC processing. It is located in + :samp:`tree-ssa-loop.cc` and is described by ``pass_ipa_oacc``. + +* IPA points-to analysis + + This is a tree-based points-to analysis pass. The idea behind this analyzer + is to generate set constraints from the program, then solve the resulting + constraints in order to generate the points-to sets. It is located in + :samp:`tree-ssa-structalias.cc` and is described by ``pass_ipa_pta``. + +* IPA OpenACC kernels + + This is a pass group for processing OpenACC kernels regions. It is a + subpass of the IPA OpenACC pass group that runs on offloaded functions + containing OpenACC kernels loops. It is located in + :samp:`tree-ssa-loop.cc` and is described by + ``pass_ipa_oacc_kernels``. + +* Target clone + + This is a pass for parsing functions with multiple target attributes. + It is located in :samp:`multiple_target.cc` and is described by + ``pass_target_clone``. + +* IPA auto profile + + This pass uses AutoFDO profiling data to annotate the control flow graph. + It is located in :samp:`auto-profile.cc` and is described by + ``pass_ipa_auto_profile``. + +* IPA tree profile + + This pass does profiling for all functions in the call graph. + It calculates branch + probabilities and basic block execution counts. It is located + in :samp:`tree-profile.cc` and is described by ``pass_ipa_tree_profile``. + +* IPA free function summary + + This pass is a small IPA pass when argument ``small_p`` is true. + It releases inline function summaries and call summaries. + It is located in :samp:`ipa-fnsummary.cc` and is described by + ``pass_ipa_free_free_fn_summary``. + +* IPA increase alignment + + This pass increases the alignment of global arrays to improve + vectorization. It is located in :samp:`tree-vectorizer.cc` + and is described by ``pass_ipa_increase_alignment``. + +* IPA transactional memory + + This pass is for transactional memory support. + It is located in :samp:`trans-mem.cc` and is described by + ``pass_ipa_tm``. + +* IPA lower emulated TLS + + This pass lowers thread-local storage (TLS) operations + to emulation functions provided by libgcc. + It is located in :samp:`tree-emutls.cc` and is described by + ``pass_ipa_lower_emutls``. + +.. index:: regular IPA passes + +.. _regular-ipa-passes: + +Regular IPA passes +^^^^^^^^^^^^^^^^^^ + +A regular IPA pass is a pass derived from ``ipa_opt_pass_d`` that +is executed in WHOPR compilation. Regular IPA passes may have summary +hooks implemented in any of the LGEN, WPA or LTRANS stages (see :ref:`ipa`). + +* IPA whole program visibility + + This pass performs various optimizations involving symbol visibility + with :option:`-fwhole-program`, including symbol privatization, + discovering local functions, and dismantling comdat groups. It is + located in :samp:`ipa-visibility.cc` and is described by + ``pass_ipa_whole_program_visibility``. + +* IPA profile + + The IPA profile pass propagates profiling frequencies across the call + graph. It is located in :samp:`ipa-profile.cc` and is described by + ``pass_ipa_profile``. + +* IPA identical code folding + + This is the inter-procedural identical code folding pass. + The goal of this transformation is to discover functions + and read-only variables that have exactly the same semantics. It is + located in :samp:`ipa-icf.cc` and is described by ``pass_ipa_icf``. + +* IPA devirtualization + + This pass performs speculative devirtualization based on the type + inheritance graph. When a polymorphic call has only one likely target + in the unit, it is turned into a speculative call. It is located in + :samp:`ipa-devirt.cc` and is described by ``pass_ipa_devirt``. + +* IPA constant propagation + + The goal of this pass is to discover functions that are always invoked + with some arguments with the same known constant values and to modify + the functions accordingly. It can also do partial specialization and + type-based devirtualization. It is located in :samp:`ipa-cp.cc` and is + described by ``pass_ipa_cp``. + +* IPA scalar replacement of aggregates + + This pass can replace an aggregate parameter with a set of other parameters + representing part of the original, turning those passed by reference + into new ones which pass the value directly. It also removes unused + function return values and unused function parameters. This pass is + located in :samp:`ipa-sra.cc` and is described by ``pass_ipa_sra``. + +* IPA constructor/destructor merge + + This pass merges multiple constructors and destructors for static + objects into single functions. It's only run at LTO time unless the + target doesn't support constructors and destructors natively. The + pass is located in :samp:`ipa.cc` and is described by + ``pass_ipa_cdtor_merge``. + +* IPA function summary + + This pass provides function analysis for inter-procedural passes. + It collects estimates of function body size, execution time, and frame + size for each function. It also estimates information about function + calls: call statement size, time and how often the parameters change + for each call. It is located in :samp:`ipa-fnsummary.cc` and is + described by ``pass_ipa_fn_summary``. + +* IPA inline + + The IPA inline pass handles function inlining with whole-program + knowledge. Small functions that are candidates for inlining are + ordered in increasing badness, bounded by unit growth parameters. + Unreachable functions are removed from the call graph. Functions called + once and not exported from the unit are inlined. This pass is located in + :samp:`ipa-inline.cc` and is described by ``pass_ipa_inline``. + +* IPA pure/const analysis + + This pass marks functions as being either const (``TREE_READONLY``) or + pure (``DECL_PURE_P``). The per-function information is produced + by ``pure_const_generate_summary``, then the global information is computed + by performing a transitive closure over the call graph. It is located in + :samp:`ipa-pure-const.cc` and is described by ``pass_ipa_pure_const``. + +* IPA free function summary + + This pass is a regular IPA pass when argument ``small_p`` is false. + It releases inline function summaries and call summaries. + It is located in :samp:`ipa-fnsummary.cc` and is described by + ``pass_ipa_free_fn_summary``. + +* IPA reference + + This pass gathers information about how variables whose scope is + confined to the compilation unit are used. It is located in + :samp:`ipa-reference.cc` and is described by ``pass_ipa_reference``. + +* IPA single use + + This pass checks whether variables are used by a single function. + It is located in :samp:`ipa.cc` and is described by + ``pass_ipa_single_use``. + +* IPA comdats + + This pass looks for static symbols that are used exclusively + within one comdat group, and moves them into that comdat group. It is + located in :samp:`ipa-comdats.cc` and is described by + ``pass_ipa_comdats``. + +.. index:: late IPA passes + +.. _late-ipa-passes: + +Late IPA passes +^^^^^^^^^^^^^^^ + +Late IPA passes are simple IPA passes executed after +the regular passes. In WHOPR mode the passes are executed after +partitioning and thus see just parts of the compiled unit. + +* Materialize all clones + + Once all functions from compilation unit are in memory, produce all clones + and update all calls. It is located in :samp:`ipa.cc` and is described by + ``pass_materialize_all_clones``. + +* IPA points-to analysis + + Points-to analysis; this is the same as the points-to-analysis pass + run with the small IPA passes (see :ref:`small-ipa-passes`). + +* OpenMP simd clone + + This is the OpenMP constructs' SIMD clone pass. It creates the appropriate + SIMD clones for functions tagged as elemental SIMD functions. + It is located in :samp:`omp-simd-clone.cc` and is described by + ``pass_omp_simd_clone``. \ No newline at end of file diff --git a/gcc/doc/gccint/passes-and-files-of-the-compiler/optimization-info.rst b/gcc/doc/gccint/passes-and-files-of-the-compiler/optimization-info.rst new file mode 100644 index 00000000000..b7a6fa1bd54 --- /dev/null +++ b/gcc/doc/gccint/passes-and-files-of-the-compiler/optimization-info.rst @@ -0,0 +1,262 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: optimization dumps + +.. _optimization-info: + +Optimization info +***************** + +This section is describes dump infrastructure which is common to both +pass dumps as well as optimization dumps. The goal for this +infrastructure is to provide both gcc developers and users detailed +information about various compiler transformations and optimizations. + +.. toctree:: + :maxdepth: 2 + + +.. index:: dump setup + +.. _dump-setup: + +Dump setup +^^^^^^^^^^ + +A dump_manager class is defined in :samp:`dumpfile.h`. Various passes +register dumping pass-specific information via ``dump_register`` in +:samp:`passes.cc`. During the registration, an optimization pass can +select its optimization group (see :ref:`optimization-groups`). After +that optimization information corresponding to the entire group +(presumably from multiple passes) can be output via command-line +switches. Note that if a pass does not fit into any of the pre-defined +groups, it can select ``OPTGROUP_NONE``. + +Note that in general, a pass need not know its dump output file name, +whether certain flags are enabled, etc. However, for legacy reasons, +passes could also call ``dump_begin`` which returns a stream in +case the particular pass has optimization dumps enabled. A pass could +call ``dump_end`` when the dump has ended. These methods should go +away once all the passes are converted to use the new dump +infrastructure. + +The recommended way to setup the dump output is via ``dump_start`` +and ``dump_end``. + +.. index:: optimization groups + +.. _optimization-groups: + +Optimization groups +^^^^^^^^^^^^^^^^^^^ + +The optimization passes are grouped into several categories. Currently +defined categories in :samp:`dumpfile.h` are + +.. envvar:: OPTGROUP_IPA + + IPA optimization passes. Enabled by :option:`-ipa` + +.. envvar:: OPTGROUP_LOOP + + Loop optimization passes. Enabled by :option:`-loop`. + +.. envvar:: OPTGROUP_INLINE + + Inlining passes. Enabled by :option:`-inline`. + +.. envvar:: OPTGROUP_OMP + + OMP (Offloading and Multi Processing) passes. Enabled by + :option:`-omp`. + +.. envvar:: OPTGROUP_VEC + + Vectorization passes. Enabled by :option:`-vec`. + +.. envvar:: OPTGROUP_OTHER + + All other optimization passes which do not fall into one of the above. + +.. envvar:: OPTGROUP_ALL + + All optimization passes. Enabled by :option:`-optall`. + +By using groups a user could selectively enable optimization +information only for a group of passes. By default, the optimization +information for all the passes is dumped. + +.. index:: optimization info file names + +.. _dump-files-and-streams: + +Dump files and streams +^^^^^^^^^^^^^^^^^^^^^^ + +There are two separate output streams available for outputting +optimization information from passes. Note that both these streams +accept ``stderr`` and ``stdout`` as valid streams and thus it is +possible to dump output to standard output or error. This is specially +handy for outputting all available information in a single file by +redirecting ``stderr``. + +``pstream`` + This stream is for pass-specific dump output. For example, + :option:`-fdump-tree-vect=foo.v` dumps tree vectorization pass output + into the given file name :samp:`foo.v`. If the file name is not provided, + the default file name is based on the source file and pass number. Note + that one could also use special file names ``stdout`` and + ``stderr`` for dumping to standard output and standard error + respectively. + +``alt_stream`` + This steam is used for printing optimization specific output in + response to the :option:`-fopt-info`. Again a file name can be given. If + the file name is not given, it defaults to ``stderr``. + +.. index:: dump verbosity + +.. _dump-output-verbosity: + +Dump output verbosity +^^^^^^^^^^^^^^^^^^^^^ + +The dump verbosity has the following options + +:samp:`optimized` + Print information when an optimization is successfully applied. It is + up to a pass to decide which information is relevant. For example, the + vectorizer passes print the source location of loops which got + successfully vectorized. + +:samp:`missed` + Print information about missed optimizations. Individual passes + control which information to include in the output. For example, + + .. code-block:: shell + + gcc -O2 -ftree-vectorize -fopt-info-vec-missed + + will print information about missed optimization opportunities from + vectorization passes on stderr. + +:samp:`note` + Print verbose information about optimizations, such as certain + transformations, more detailed messages about decisions etc. + +:samp:`all` + Print detailed optimization information. This includes + :samp:`{optimized}`, :samp:`{missed}`, and :samp:`{note}`. + +.. index:: dump types + +.. _dump-types: + +Dump types +^^^^^^^^^^ + +``dump_printf`` + This is a generic method for doing formatted output. It takes an + additional argument ``dump_kind`` which signifies the type of + dump. This method outputs information only when the dumps are enabled + for this particular ``dump_kind``. Note that the caller doesn't + need to know if the particular dump is enabled or not, or even the + file name. The caller only needs to decide which dump output + information is relevant, and under what conditions. This determines + the associated flags. + + Consider the following example from :samp:`loop-unroll.cc` where an + informative message about a loop (along with its location) is printed + when any of the following flags is enabled + + * optimization messages + + * RTL dumps + + * detailed dumps + + .. code-block:: c++ + + int report_flags = MSG_OPTIMIZED_LOCATIONS | TDF_RTL | TDF_DETAILS; + dump_printf_loc (report_flags, insn, + "loop turned into non-loop; it never loops.\n"); + +``dump_basic_block`` + Output basic block. + +``dump_generic_expr`` + Output generic expression. + +``dump_gimple_stmt`` + Output gimple statement. + + Note that the above methods also have variants prefixed with + ``_loc``, such as ``dump_printf_loc``, which are similar except + they also output the source location information. The ``_loc`` variants + take a ``const dump_location_t &``. This class can be constructed from + a ``gimple *`` or from a ``rtx_insn *``, and so callers can pass + a ``gimple *`` or a ``rtx_insn *`` as the ``_loc`` argument. + The ``dump_location_t`` constructor will extract the source location + from the statement or instruction, along with the profile count, and + the location in GCC's own source code (or the plugin) from which the dump + call was emitted. Only the source location is currently used. + There is also a ``dump_user_location_t`` class, capturing the + source location and profile count, but not the dump emission location, + so that locations in the user's code can be passed around. This + can also be constructed from a ``gimple *`` and from a ``rtx_insn *``, + and it too can be passed as the ``_loc`` argument. + +.. index:: dump examples + +.. _dump-examples: + +Dump examples +^^^^^^^^^^^^^ + +.. code-block:: shell + + gcc -O3 -fopt-info-missed=missed.all + +outputs missed optimization report from all the passes into +:samp:`missed.all`. + +As another example, + +.. code-block:: shell + + gcc -O3 -fopt-info-inline-optimized-missed=inline.txt + +will output information about missed optimizations as well as +optimized locations from all the inlining passes into +:samp:`inline.txt`. + +If the :samp:`{filename}` is provided, then the dumps from all the +applicable optimizations are concatenated into the :samp:`filename`. +Otherwise the dump is output onto :samp:`stderr`. If :samp:`{options}` is +omitted, it defaults to optimized-optall, which means dump +all information about successful optimizations from all the passes. +In the following example, the optimization information is output on +to :samp:`stderr`. + +.. code-block:: shell + + gcc -O3 -fopt-info + +Note that :option:`-fopt-info-vec-missed` behaves the same as +:option:`-fopt-info-missed-vec`. The order of the optimization group +names and message types listed after :option:`-fopt-info` does not matter. + +As another example, consider + +.. code-block:: shell + + gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt + +Here the two output file names :samp:`vec.miss` and :samp:`loop.opt` are +in conflict since only one output file is allowed. In this case, only +the first option takes effect and the subsequent options are +ignored. Thus only the :samp:`vec.miss` is produced which containts +dumps from the vectorizer about missed opportunities. \ No newline at end of file diff --git a/gcc/doc/gccint/passes-and-files-of-the-compiler/parsing-pass.rst b/gcc/doc/gccint/passes-and-files-of-the-compiler/parsing-pass.rst new file mode 100644 index 00000000000..bd30efe8aba --- /dev/null +++ b/gcc/doc/gccint/passes-and-files-of-the-compiler/parsing-pass.rst @@ -0,0 +1,80 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GENERIC, lang_hooks.parse_file + +.. _parsing-pass: + +Parsing pass +************ + +The language front end is invoked only once, via +``lang_hooks.parse_file``, to parse the entire input. The language +front end may use any intermediate language representation deemed +appropriate. The C front end uses GENERIC trees (see :ref:`generic`), plus +a double handful of language specific tree codes defined in +:samp:`c-common.def`. The Fortran front end uses a completely different +private representation. + +.. index:: GIMPLE, gimplification, gimplifier, language-independent intermediate representation, intermediate representation lowering, lowering, language-dependent intermediate representation + +At some point the front end must translate the representation used in the +front end to a representation understood by the language-independent +portions of the compiler. Current practice takes one of two forms. +The C front end manually invokes the gimplifier (see :ref:`gimple`) on each function, +and uses the gimplifier callbacks to convert the language-specific tree +nodes directly to GIMPLE before passing the function off to be compiled. +The Fortran front end converts from a private representation to GENERIC, +which is later lowered to GIMPLE when the function is compiled. Which +route to choose probably depends on how well GENERIC (plus extensions) +can be made to match up with the source language and necessary parsing +data structures. + +BUG: Gimplification must occur before nested function lowering, +and nested function lowering must be done by the front end before +passing the data off to cgraph. + +.. todo:: Cgraph should control nested function lowering. It would + only be invoked when it is certain that the outer-most function + is used. + +.. todo:: Cgraph needs a gimplify_function callback. It should be + invoked when (1) it is certain that the function is used, (2) + warning flags specified by the user require some amount of + compilation in order to honor, (3) the language indicates that + semantic analysis is not complete until gimplification occurs. + Hum... this sounds overly complicated. Perhaps we should just + have the front end gimplify always; in most cases it's only one + function call. + +The front end needs to pass all function definitions and top level +declarations off to the middle-end so that they can be compiled and +emitted to the object file. For a simple procedural language, it is +usually most convenient to do this as each top level declaration or +definition is seen. There is also a distinction to be made between +generating functional code and generating complete debug information. +The only thing that is absolutely required for functional code is that +function and data *definitions* be passed to the middle-end. For +complete debug information, function, data and type declarations +should all be passed as well. + +.. index:: rest_of_decl_compilation, rest_of_type_compilation, cgraph_finalize_function + +In any case, the front end needs each complete top-level function or +data declaration, and each data definition should be passed to +``rest_of_decl_compilation``. Each complete type definition should +be passed to ``rest_of_type_compilation``. Each function definition +should be passed to ``cgraph_finalize_function``. + +.. todo:: I know rest_of_compilation currently has all sorts of + RTL generation semantics. I plan to move all code generation + bits (both Tree and RTL) to compile_function. Should we hide + cgraph from the front ends and move back to rest_of_compilation + as the official interface? Possibly we should rename all three + interfaces such that the names match in some meaningful way and + that is more descriptive than "rest_of". + +The middle-end will, at its option, emit the function and data +definitions immediately or queue them for later processing. \ No newline at end of file diff --git a/gcc/doc/gccint/passes-and-files-of-the-compiler/pass-manager.rst b/gcc/doc/gccint/passes-and-files-of-the-compiler/pass-manager.rst new file mode 100644 index 00000000000..d98c9ed6c6d --- /dev/null +++ b/gcc/doc/gccint/passes-and-files-of-the-compiler/pass-manager.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _pass-manager: + +Pass manager +************ + +The pass manager is located in :samp:`passes.cc`, :samp:`tree-optimize.c` +and :samp:`tree-pass.h`. +It processes passes as described in :samp:`passes.def`. +Its job is to run all of the individual passes in the correct order, +and take care of standard bookkeeping that applies to every pass. + +The theory of operation is that each pass defines a structure that +represents everything we need to know about that pass---when it +should be run, how it should be run, what intermediate language +form or on-the-side data structures it needs. We register the pass +to be run in some particular order, and the pass manager arranges +for everything to happen in the correct order. + +The actuality doesn't completely live up to the theory at present. +Command-line switches and ``timevar_id_t`` enumerations must still +be defined elsewhere. The pass manager validates constraints but does +not attempt to (re-)generate data structures or lower intermediate +language form based on the requirements of the next pass. Nevertheless, +what is present is useful, and a far sight better than nothing at all. + +Each pass should have a unique name. +Each pass may have its own dump file (for GCC debugging purposes). +Passes with a name starting with a star do not dump anything. +Sometimes passes are supposed to share a dump file / option name. +To still give these unique names, you can use a prefix that is delimited +by a space from the part that is used for the dump file / option name. +E.g. When the pass name is "ud dce", the name used for dump file/options +is "dce". + +.. todo:: describe the global variables set up by the pass manager, + and a brief description of how a new pass should use it. + I need to look at what info RTL passes use first… \ No newline at end of file diff --git a/gcc/doc/gccint/passes-and-files-of-the-compiler/rtl-passes.rst b/gcc/doc/gccint/passes-and-files-of-the-compiler/rtl-passes.rst new file mode 100644 index 00000000000..7848281d57b --- /dev/null +++ b/gcc/doc/gccint/passes-and-files-of-the-compiler/rtl-passes.rst @@ -0,0 +1,275 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _rtl-passes: + +RTL passes +********** + +The following briefly describes the RTL generation and optimization +passes that are run after the Tree optimization passes. + +* RTL generation + + .. Avoiding overfull is tricky here. + + The source files for RTL generation include + :samp:`stmt.cc`, + :samp:`calls.cc`, + :samp:`expr.cc`, + :samp:`explow.cc`, + :samp:`expmed.cc`, + :samp:`function.cc`, + :samp:`optabs.cc` + and :samp:`emit-rtl.cc`. + Also, the file + :samp:`insn-emit.cc`, generated from the machine description by the + program ``genemit``, is used in this pass. The header file + :samp:`expr.h` is used for communication within this pass. + + .. index:: genflags, gencodes + + The header files :samp:`insn-flags.h` and :samp:`insn-codes.h`, + generated from the machine description by the programs ``genflags`` + and ``gencodes``, tell this pass which standard names are available + for use and which patterns correspond to them. + +* Generation of exception landing pads + + This pass generates the glue that handles communication between the + exception handling library routines and the exception handlers within + the function. Entry points in the function that are invoked by the + exception handling library are called :dfn:`landing pads`. The code + for this pass is located in :samp:`except.cc`. + +* Control flow graph cleanup + + This pass removes unreachable code, simplifies jumps to next, jumps to + jump, jumps across jumps, etc. The pass is run multiple times. + For historical reasons, it is occasionally referred to as the 'jump + optimization pass'. The bulk of the code for this pass is in + :samp:`cfgcleanup.cc`, and there are support routines in :samp:`cfgrtl.cc` + and :samp:`jump.cc`. + +* Forward propagation of single-def values + + This pass attempts to remove redundant computation by substituting + variables that come from a single definition, and + seeing if the result can be simplified. It performs copy propagation + and addressing mode selection. The pass is run twice, with values + being propagated into loops only on the second run. The code is + located in :samp:`fwprop.cc`. + +* Common subexpression elimination + + This pass removes redundant computation within basic blocks, and + optimizes addressing modes based on cost. The pass is run twice. + The code for this pass is located in :samp:`cse.cc`. + +* Global common subexpression elimination + + This pass performs two + different types of GCSE depending on whether you are optimizing for + size or not (LCM based GCSE tends to increase code size for a gain in + speed, while Morel-Renvoise based GCSE does not). + When optimizing for size, GCSE is done using Morel-Renvoise Partial + Redundancy Elimination, with the exception that it does not try to move + invariants out of loops---that is left to the loop optimization pass. + If MR PRE GCSE is done, code hoisting (aka unification) is also done, as + well as load motion. + If you are optimizing for speed, LCM (lazy code motion) based GCSE is + done. LCM is based on the work of Knoop, Ruthing, and Steffen. LCM + based GCSE also does loop invariant code motion. We also perform load + and store motion when optimizing for speed. + Regardless of which type of GCSE is used, the GCSE pass also performs + global constant and copy propagation. + The source file for this pass is :samp:`gcse.cc`, and the LCM routines + are in :samp:`lcm.cc`. + +* Loop optimization + + This pass performs several loop related optimizations. + The source files :samp:`cfgloopanal.cc` and :samp:`cfgloopmanip.cc` contain + generic loop analysis and manipulation code. Initialization and finalization + of loop structures is handled by :samp:`loop-init.cc`. + A loop invariant motion pass is implemented in :samp:`loop-invariant.cc`. + Basic block level optimizations---unrolling, and peeling loops--- + are implemented in :samp:`loop-unroll.cc`. + Replacing of the exit condition of loops by special machine-dependent + instructions is handled by :samp:`loop-doloop.cc`. + +* Jump bypassing + + This pass is an aggressive form of GCSE that transforms the control + flow graph of a function by propagating constants into conditional + branch instructions. The source file for this pass is :samp:`gcse.cc`. + +* If conversion + + This pass attempts to replace conditional branches and surrounding + assignments with arithmetic, boolean value producing comparison + instructions, and conditional move instructions. In the very last + invocation after reload/LRA, it will generate predicated instructions + when supported by the target. The code is located in :samp:`ifcvt.cc`. + +* Web construction + + This pass splits independent uses of each pseudo-register. This can + improve effect of the other transformation, such as CSE or register + allocation. The code for this pass is located in :samp:`web.cc`. + +* Instruction combination + + This pass attempts to combine groups of two or three instructions that + are related by data flow into single instructions. It combines the + RTL expressions for the instructions by substitution, simplifies the + result using algebra, and then attempts to match the result against + the machine description. The code is located in :samp:`combine.cc`. + +* Mode switching optimization + + This pass looks for instructions that require the processor to be in a + specific 'mode' and minimizes the number of mode changes required to + satisfy all users. What these modes are, and what they apply to are + completely target-specific. The code for this pass is located in + :samp:`mode-switching.cc`. + + .. index:: modulo scheduling, sms, swing, software pipelining + +* Modulo scheduling + + This pass looks at innermost loops and reorders their instructions + by overlapping different iterations. Modulo scheduling is performed + immediately before instruction scheduling. The code for this pass is + located in :samp:`modulo-sched.cc`. + +* Instruction scheduling + + This pass looks for instructions whose output will not be available by + the time that it is used in subsequent instructions. Memory loads and + floating point instructions often have this behavior on RISC machines. + It re-orders instructions within a basic block to try to separate the + definition and use of items that otherwise would cause pipeline + stalls. This pass is performed twice, before and after register + allocation. The code for this pass is located in :samp:`haifa-sched.cc`, + :samp:`sched-deps.cc`, :samp:`sched-ebb.cc`, :samp:`sched-rgn.cc` and + :samp:`sched-vis.c`. + +* Register allocation + + These passes make sure that all occurrences of pseudo registers are + eliminated, either by allocating them to a hard register, replacing + them by an equivalent expression (e.g. a constant) or by placing + them on the stack. This is done in several subpasses: + + * The integrated register allocator (IRA). It is called + integrated because coalescing, register live range splitting, and hard + register preferencing are done on-the-fly during coloring. It also + has better integration with the reload/LRA pass. Pseudo-registers spilled + by the allocator or the reload/LRA have still a chance to get + hard-registers if the reload/LRA evicts some pseudo-registers from + hard-registers. The allocator helps to choose better pseudos for + spilling based on their live ranges and to coalesce stack slots + allocated for the spilled pseudo-registers. IRA is a regional + register allocator which is transformed into Chaitin-Briggs allocator + if there is one region. By default, IRA chooses regions using + register pressure but the user can force it to use one region or + regions corresponding to all loops. + + Source files of the allocator are :samp:`ira.cc`, :samp:`ira-build.cc`, + :samp:`ira-costs.cc`, :samp:`ira-conflicts.cc`, :samp:`ira-color.cc`, + :samp:`ira-emit.cc`, :samp:`ira-lives`, plus header files :samp:`ira.h` + and :samp:`ira-int.h` used for the communication between the allocator + and the rest of the compiler and between the IRA files. + + .. index:: reloading + + * Reloading. This pass renumbers pseudo registers with the hardware + registers numbers they were allocated. Pseudo registers that did not + get hard registers are replaced with stack slots. Then it finds + instructions that are invalid because a value has failed to end up in + a register, or has ended up in a register of the wrong kind. It fixes + up these instructions by reloading the problematical values + temporarily into registers. Additional instructions are generated to + do the copying. + + The reload pass also optionally eliminates the frame pointer and inserts + instructions to save and restore call-clobbered registers around calls. + + Source files are :samp:`reload.cc` and :samp:`reload1.cc`, plus the header + :samp:`reload.h` used for communication between them. + + .. index:: Local Register Allocator (LRA) + + * This pass is a modern replacement of the reload pass. Source files + are :samp:`lra.cc`, :samp:`lra-assign.c`, :samp:`lra-coalesce.cc`, + :samp:`lra-constraints.cc`, :samp:`lra-eliminations.cc`, + :samp:`lra-lives.cc`, :samp:`lra-remat.cc`, :samp:`lra-spills.cc`, the + header :samp:`lra-int.h` used for communication between them, and the + header :samp:`lra.h` used for communication between LRA and the rest of + compiler. + + Unlike the reload pass, intermediate LRA decisions are reflected in + RTL as much as possible. This reduces the number of target-dependent + macros and hooks, leaving instruction constraints as the primary + source of control. + + LRA is run on targets for which TARGET_LRA_P returns true. + +* Basic block reordering + + This pass implements profile guided code positioning. If profile + information is not available, various types of static analysis are + performed to make the predictions normally coming from the profile + feedback (IE execution frequency, branch probability, etc). It is + implemented in the file :samp:`bb-reorder.cc`, and the various + prediction routines are in :samp:`predict.cc`. + +* Variable tracking + + This pass computes where the variables are stored at each + position in code and generates notes describing the variable locations + to RTL code. The location lists are then generated according to these + notes to debug information if the debugging information format supports + location lists. The code is located in :samp:`var-tracking.cc`. + +* Delayed branch scheduling + + This optional pass attempts to find instructions that can go into the + delay slots of other instructions, usually jumps and calls. The code + for this pass is located in :samp:`reorg.cc`. + +* Branch shortening + + On many RISC machines, branch instructions have a limited range. + Thus, longer sequences of instructions must be used for long branches. + In this pass, the compiler figures out what how far each instruction + will be from each other instruction, and therefore whether the usual + instructions, or the longer sequences, must be used for each branch. + The code for this pass is located in :samp:`final.cc`. + +* Register-to-stack conversion + + Conversion from usage of some hard registers to usage of a register + stack may be done at this point. Currently, this is supported only + for the floating-point registers of the Intel 80387 coprocessor. The + code for this pass is located in :samp:`reg-stack.cc`. + +* Final + + This pass outputs the assembler code for the function. The source files + are :samp:`final.cc` plus :samp:`insn-output.cc`; the latter is generated + automatically from the machine description by the tool :samp:`genoutput`. + The header file :samp:`conditions.h` is used for communication between + these files. + +* Debugging information output + + This is run after final because it must output the stack slot offsets + for pseudo registers that did not get hard registers. Source files + are :samp:`dwarfout.c` for + DWARF symbol table format, files :samp:`dwarf2out.cc` and :samp:`dwarf2asm.cc` + for DWARF2 symbol table format, and :samp:`vmsdbgout.cc` for VMS debug + symbol table format. \ No newline at end of file diff --git a/gcc/doc/gccint/passes-and-files-of-the-compiler/tree-ssa-passes.rst b/gcc/doc/gccint/passes-and-files-of-the-compiler/tree-ssa-passes.rst new file mode 100644 index 00000000000..d4a883221fb --- /dev/null +++ b/gcc/doc/gccint/passes-and-files-of-the-compiler/tree-ssa-passes.rst @@ -0,0 +1,477 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _tree-ssa-passes: + +Tree SSA passes +*************** + +The following briefly describes the Tree optimization passes that are +run after gimplification and what source files they are located in. + +* Remove useless statements + + This pass is an extremely simple sweep across the gimple code in which + we identify obviously dead code and remove it. Here we do things like + simplify ``if`` statements with constant conditions, remove + exception handling constructs surrounding code that obviously cannot + throw, remove lexical bindings that contain no variables, and other + assorted simplistic cleanups. The idea is to get rid of the obvious + stuff quickly rather than wait until later when it's more work to get + rid of it. This pass is located in :samp:`tree-cfg.cc` and described by + ``pass_remove_useless_stmts``. + +* OpenMP lowering + + If OpenMP generation (:option:`-fopenmp`) is enabled, this pass lowers + OpenMP constructs into GIMPLE. + + Lowering of OpenMP constructs involves creating replacement + expressions for local variables that have been mapped using data + sharing clauses, exposing the control flow of most synchronization + directives and adding region markers to facilitate the creation of the + control flow graph. The pass is located in :samp:`omp-low.cc` and is + described by ``pass_lower_omp``. + +* OpenMP expansion + + If OpenMP generation (:option:`-fopenmp`) is enabled, this pass expands + parallel regions into their own functions to be invoked by the thread + library. The pass is located in :samp:`omp-low.cc` and is described by + ``pass_expand_omp``. + +* Lower control flow + + This pass flattens ``if`` statements (``COND_EXPR``) + and moves lexical bindings (``BIND_EXPR``) out of line. After + this pass, all ``if`` statements will have exactly two ``goto`` + statements in its ``then`` and ``else`` arms. Lexical binding + information for each statement will be found in ``TREE_BLOCK`` rather + than being inferred from its position under a ``BIND_EXPR``. This + pass is found in :samp:`gimple-low.cc` and is described by + ``pass_lower_cf``. + +* Lower exception handling control flow + + This pass decomposes high-level exception handling constructs + (``TRY_FINALLY_EXPR`` and ``TRY_CATCH_EXPR``) into a form + that explicitly represents the control flow involved. After this + pass, ``lookup_stmt_eh_region`` will return a non-negative + number for any statement that may have EH control flow semantics; + examine ``tree_can_throw_internal`` or ``tree_can_throw_external`` + for exact semantics. Exact control flow may be extracted from + ``foreach_reachable_handler``. The EH region nesting tree is defined + in :samp:`except.h` and built in :samp:`except.cc`. The lowering pass + itself is in :samp:`tree-eh.cc` and is described by ``pass_lower_eh``. + +* Build the control flow graph + + This pass decomposes a function into basic blocks and creates all of + the edges that connect them. It is located in :samp:`tree-cfg.cc` and + is described by ``pass_build_cfg``. + +* Find all referenced variables + + This pass walks the entire function and collects an array of all + variables referenced in the function, ``referenced_vars``. The + index at which a variable is found in the array is used as a UID + for the variable within this function. This data is needed by the + SSA rewriting routines. The pass is located in :samp:`tree-dfa.cc` + and is described by ``pass_referenced_vars``. + +* Enter static single assignment form + + This pass rewrites the function such that it is in SSA form. After + this pass, all ``is_gimple_reg`` variables will be referenced by + ``SSA_NAME``, and all occurrences of other variables will be + annotated with ``VDEFS`` and ``VUSES`` ; PHI nodes will have + been inserted as necessary for each basic block. This pass is + located in :samp:`tree-ssa.cc` and is described by ``pass_build_ssa``. + +* Warn for uninitialized variables + + This pass scans the function for uses of ``SSA_NAME`` s that + are fed by default definition. For non-parameter variables, such + uses are uninitialized. The pass is run twice, before and after + optimization (if turned on). In the first pass we only warn for uses that are + positively uninitialized; in the second pass we warn for uses that + are possibly uninitialized. The pass is located in :samp:`tree-ssa.cc` + and is defined by ``pass_early_warn_uninitialized`` and + ``pass_late_warn_uninitialized``. + +* Dead code elimination + + This pass scans the function for statements without side effects whose + result is unused. It does not do memory life analysis, so any value + that is stored in memory is considered used. The pass is run multiple + times throughout the optimization process. It is located in + :samp:`tree-ssa-dce.cc` and is described by ``pass_dce``. + +* Dominator optimizations + + This pass performs trivial dominator-based copy and constant propagation, + expression simplification, and jump threading. It is run multiple times + throughout the optimization process. It is located in :samp:`tree-ssa-dom.cc` + and is described by ``pass_dominator``. + +* Forward propagation of single-use variables + + This pass attempts to remove redundant computation by substituting + variables that are used once into the expression that uses them and + seeing if the result can be simplified. It is located in + :samp:`tree-ssa-forwprop.cc` and is described by ``pass_forwprop``. + +* Copy Renaming + + This pass attempts to change the name of compiler temporaries involved in + copy operations such that SSA->normal can coalesce the copy away. When compiler + temporaries are copies of user variables, it also renames the compiler + temporary to the user variable resulting in better use of user symbols. It is + located in :samp:`tree-ssa-copyrename.c` and is described by + ``pass_copyrename``. + +* PHI node optimizations + + This pass recognizes forms of PHI inputs that can be represented as + conditional expressions and rewrites them into straight line code. + It is located in :samp:`tree-ssa-phiopt.cc` and is described by + ``pass_phiopt``. + +* May-alias optimization + + This pass performs a flow sensitive SSA-based points-to analysis. + The resulting may-alias, must-alias, and escape analysis information + is used to promote variables from in-memory addressable objects to + non-aliased variables that can be renamed into SSA form. We also + update the ``VDEF`` / ``VUSE`` memory tags for non-renameable + aggregates so that we get fewer false kills. The pass is located + in :samp:`tree-ssa-alias.cc` and is described by ``pass_may_alias``. + + Interprocedural points-to information is located in + :samp:`tree-ssa-structalias.cc` and described by ``pass_ipa_pta``. + +* Profiling + + This pass instruments the function in order to collect runtime block + and value profiling data. Such data may be fed back into the compiler + on a subsequent run so as to allow optimization based on expected + execution frequencies. The pass is located in :samp:`tree-profile.cc` and + is described by ``pass_ipa_tree_profile``. + +* Static profile estimation + + This pass implements series of heuristics to guess propababilities + of branches. The resulting predictions are turned into edge profile + by propagating branches across the control flow graphs. + The pass is located in :samp:`tree-profile.cc` and is described by + ``pass_profile``. + +* Lower complex arithmetic + + This pass rewrites complex arithmetic operations into their component + scalar arithmetic operations. The pass is located in :samp:`tree-complex.cc` + and is described by ``pass_lower_complex``. + +* Scalar replacement of aggregates + + This pass rewrites suitable non-aliased local aggregate variables into + a set of scalar variables. The resulting scalar variables are + rewritten into SSA form, which allows subsequent optimization passes + to do a significantly better job with them. The pass is located in + :samp:`tree-sra.cc` and is described by ``pass_sra``. + +* Dead store elimination + + This pass eliminates stores to memory that are subsequently overwritten + by another store, without any intervening loads. The pass is located + in :samp:`tree-ssa-dse.cc` and is described by ``pass_dse``. + +* Tail recursion elimination + + This pass transforms tail recursion into a loop. It is located in + :samp:`tree-tailcall.cc` and is described by ``pass_tail_recursion``. + +* Forward store motion + + This pass sinks stores and assignments down the flowgraph closer to their + use point. The pass is located in :samp:`tree-ssa-sink.cc` and is + described by ``pass_sink_code``. + +* Partial redundancy elimination + + This pass eliminates partially redundant computations, as well as + performing load motion. The pass is located in :samp:`tree-ssa-pre.cc` + and is described by ``pass_pre``. + + Just before partial redundancy elimination, if + :option:`-funsafe-math-optimizations` is on, GCC tries to convert + divisions to multiplications by the reciprocal. The pass is located + in :samp:`tree-ssa-math-opts.cc` and is described by + ``pass_cse_reciprocal``. + +* Full redundancy elimination + + This is a simpler form of PRE that only eliminates redundancies that + occur on all paths. It is located in :samp:`tree-ssa-pre.cc` and + described by ``pass_fre``. + +* Loop optimization + + The main driver of the pass is placed in :samp:`tree-ssa-loop.cc` + and described by ``pass_loop``. + + The optimizations performed by this pass are: + + Loop invariant motion. This pass moves only invariants that + would be hard to handle on RTL level (function calls, operations that expand to + nontrivial sequences of insns). With :option:`-funswitch-loops` it also moves + operands of conditions that are invariant out of the loop, so that we can use + just trivial invariantness analysis in loop unswitching. The pass also includes + store motion. The pass is implemented in :samp:`tree-ssa-loop-im.cc`. + + Canonical induction variable creation. This pass creates a simple counter + for number of iterations of the loop and replaces the exit condition of the + loop using it, in case when a complicated analysis is necessary to determine + the number of iterations. Later optimizations then may determine the number + easily. The pass is implemented in :samp:`tree-ssa-loop-ivcanon.cc`. + + Induction variable optimizations. This pass performs standard induction + variable optimizations, including strength reduction, induction variable + merging and induction variable elimination. The pass is implemented in + :samp:`tree-ssa-loop-ivopts.cc`. + + Loop unswitching. This pass moves the conditional jumps that are invariant + out of the loops. To achieve this, a duplicate of the loop is created for + each possible outcome of conditional jump(s). The pass is implemented in + :samp:`tree-ssa-loop-unswitch.cc`. + + Loop splitting. If a loop contains a conditional statement that is + always true for one part of the iteration space and false for the other + this pass splits the loop into two, one dealing with one side the other + only with the other, thereby removing one inner-loop conditional. The + pass is implemented in :samp:`tree-ssa-loop-split.cc`. + + The optimizations also use various utility functions contained in + :samp:`tree-ssa-loop-manip.cc`, :samp:`cfgloop.cc`, :samp:`cfgloopanal.cc` and + :samp:`cfgloopmanip.cc`. + + Vectorization. This pass transforms loops to operate on vector types + instead of scalar types. Data parallelism across loop iterations is exploited + to group data elements from consecutive iterations into a vector and operate + on them in parallel. Depending on available target support the loop is + conceptually unrolled by a factor ``VF`` (vectorization factor), which is + the number of elements operated upon in parallel in each iteration, and the + ``VF`` copies of each scalar operation are fused to form a vector operation. + Additional loop transformations such as peeling and versioning may take place + to align the number of iterations, and to align the memory accesses in the + loop. + The pass is implemented in :samp:`tree-vectorizer.cc` (the main driver), + :samp:`tree-vect-loop.cc` and :samp:`tree-vect-loop-manip.cc` (loop specific parts + and general loop utilities), :samp:`tree-vect-slp` (loop-aware SLP + functionality), :samp:`tree-vect-stmts.cc`, :samp:`tree-vect-data-refs.cc` and + :samp:`tree-vect-slp-patterns.cc` containing the SLP pattern matcher. + Analysis of data references is in :samp:`tree-data-ref.cc`. + + SLP Vectorization. This pass performs vectorization of straight-line code. The + pass is implemented in :samp:`tree-vectorizer.cc` (the main driver), + :samp:`tree-vect-slp.cc`, :samp:`tree-vect-stmts.cc` and + :samp:`tree-vect-data-refs.cc`. + + Autoparallelization. This pass splits the loop iteration space to run + into several threads. The pass is implemented in :samp:`tree-parloops.cc`. + + Graphite is a loop transformation framework based on the polyhedral + model. Graphite stands for Gimple Represented as Polyhedra. The + internals of this infrastructure are documented in + https://gcc.gnu.org/wiki/Graphite. The passes working on + this representation are implemented in the various :samp:`graphite-*` + files. + +* Tree level if-conversion for vectorizer + + This pass applies if-conversion to simple loops to help vectorizer. + We identify if convertible loops, if-convert statements and merge + basic blocks in one big block. The idea is to present loop in such + form so that vectorizer can have one to one mapping between statements + and available vector operations. This pass is located in + :samp:`tree-if-conv.cc` and is described by ``pass_if_conversion``. + +* Conditional constant propagation + + This pass relaxes a lattice of values in order to identify those + that must be constant even in the presence of conditional branches. + The pass is located in :samp:`tree-ssa-ccp.cc` and is described + by ``pass_ccp``. + + A related pass that works on memory loads and stores, and not just + register values, is located in :samp:`tree-ssa-ccp.cc` and described by + ``pass_store_ccp``. + +* Conditional copy propagation + + This is similar to constant propagation but the lattice of values is + the 'copy-of' relation. It eliminates redundant copies from the + code. The pass is located in :samp:`tree-ssa-copy.cc` and described by + ``pass_copy_prop``. + + A related pass that works on memory copies, and not just register + copies, is located in :samp:`tree-ssa-copy.cc` and described by + ``pass_store_copy_prop``. + +* Value range propagation + + This transformation is similar to constant propagation but + instead of propagating single constant values, it propagates + known value ranges. The implementation is based on Patterson's + range propagation algorithm (Accurate Static Branch Prediction by + Value Range Propagation, J. R. C. Patterson, PLDI '95). In + contrast to Patterson's algorithm, this implementation does not + propagate branch probabilities nor it uses more than a single + range per SSA name. This means that the current implementation + cannot be used for branch prediction (though adapting it would + not be difficult). The pass is located in :samp:`tree-vrp.cc` and is + described by ``pass_vrp``. + +* Folding built-in functions + + This pass simplifies built-in functions, as applicable, with constant + arguments or with inferable string lengths. It is located in + :samp:`tree-ssa-ccp.cc` and is described by ``pass_fold_builtins``. + +* Split critical edges + + This pass identifies critical edges and inserts empty basic blocks + such that the edge is no longer critical. The pass is located in + :samp:`tree-cfg.cc` and is described by ``pass_split_crit_edges``. + +* Control dependence dead code elimination + + This pass is a stronger form of dead code elimination that can + eliminate unnecessary control flow statements. It is located + in :samp:`tree-ssa-dce.cc` and is described by ``pass_cd_dce``. + +* Tail call elimination + + This pass identifies function calls that may be rewritten into + jumps. No code transformation is actually applied here, but the + data and control flow problem is solved. The code transformation + requires target support, and so is delayed until RTL. In the + meantime ``CALL_EXPR_TAILCALL`` is set indicating the possibility. + The pass is located in :samp:`tree-tailcall.cc` and is described by + ``pass_tail_calls``. The RTL transformation is handled by + ``fixup_tail_calls`` in :samp:`calls.cc`. + +* Warn for function return without value + + For non-void functions, this pass locates return statements that do + not specify a value and issues a warning. Such a statement may have + been injected by falling off the end of the function. This pass is + run last so that we have as much time as possible to prove that the + statement is not reachable. It is located in :samp:`tree-cfg.cc` and + is described by ``pass_warn_function_return``. + +* Leave static single assignment form + + This pass rewrites the function such that it is in normal form. At + the same time, we eliminate as many single-use temporaries as possible, + so the intermediate language is no longer GIMPLE, but GENERIC. The + pass is located in :samp:`tree-outof-ssa.cc` and is described by + ``pass_del_ssa``. + +* Merge PHI nodes that feed into one another + + This is part of the CFG cleanup passes. It attempts to join PHI nodes + from a forwarder CFG block into another block with PHI nodes. The + pass is located in :samp:`tree-cfgcleanup.cc` and is described by + ``pass_merge_phi``. + +* Return value optimization + + If a function always returns the same local variable, and that local + variable is an aggregate type, then the variable is replaced with the + return value for the function (i.e., the function's DECL_RESULT). This + is equivalent to the C++ named return value optimization applied to + GIMPLE. The pass is located in :samp:`tree-nrv.cc` and is described by + ``pass_nrv``. + +* Return slot optimization + + If a function returns a memory object and is called as ``var = + foo()``, this pass tries to change the call so that the address of + ``var`` is sent to the caller to avoid an extra memory copy. This + pass is located in ``tree-nrv.cc`` and is described by + ``pass_return_slot``. + +* Optimize calls to ``__builtin_object_size`` + + This is a propagation pass similar to CCP that tries to remove calls + to ``__builtin_object_size`` when the size of the object can be + computed at compile-time. This pass is located in + :samp:`tree-object-size.cc` and is described by + ``pass_object_sizes``. + +* Loop invariant motion + + This pass removes expensive loop-invariant computations out of loops. + The pass is located in :samp:`tree-ssa-loop.cc` and described by + ``pass_lim``. + +* Loop nest optimizations + + This is a family of loop transformations that works on loop nests. It + includes loop interchange, scaling, skewing and reversal and they are + all geared to the optimization of data locality in array traversals + and the removal of dependencies that hamper optimizations such as loop + parallelization and vectorization. The pass is located in + :samp:`tree-loop-linear.c` and described by + ``pass_linear_transform``. + +* Removal of empty loops + + This pass removes loops with no code in them. The pass is located in + :samp:`tree-ssa-loop-ivcanon.cc` and described by + ``pass_empty_loop``. + +* Unrolling of small loops + + This pass completely unrolls loops with few iterations. The pass + is located in :samp:`tree-ssa-loop-ivcanon.cc` and described by + ``pass_complete_unroll``. + +* Predictive commoning + + This pass makes the code reuse the computations from the previous + iterations of the loops, especially loads and stores to memory. + It does so by storing the values of these computations to a bank + of temporary variables that are rotated at the end of loop. To avoid + the need for this rotation, the loop is then unrolled and the copies + of the loop body are rewritten to use the appropriate version of + the temporary variable. This pass is located in :samp:`tree-predcom.cc` + and described by ``pass_predcom``. + +* Array prefetching + + This pass issues prefetch instructions for array references inside + loops. The pass is located in :samp:`tree-ssa-loop-prefetch.cc` and + described by ``pass_loop_prefetch``. + +* Reassociation + + This pass rewrites arithmetic expressions to enable optimizations that + operate on them, like redundancy elimination and vectorization. The + pass is located in :samp:`tree-ssa-reassoc.cc` and described by + ``pass_reassoc``. + +* Optimization of ``stdarg`` functions + + This pass tries to avoid the saving of register arguments into the + stack on entry to ``stdarg`` functions. If the function doesn't + use any ``va_start`` macros, no registers need to be saved. If + ``va_start`` macros are used, the ``va_list`` variables don't + escape the function, it is only necessary to save registers that will + be used in ``va_arg`` macros. For instance, if ``va_arg`` is + only used with integral types in the function, floating point + registers don't need to be saved. This pass is located in + ``tree-stdarg.cc`` and described by ``pass_stdarg``. \ No newline at end of file diff --git a/gcc/doc/gccint/plugins.rst b/gcc/doc/gccint/plugins.rst new file mode 100644 index 00000000000..2c3c479d22a --- /dev/null +++ b/gcc/doc/gccint/plugins.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Plugins + +.. _plugins: + +Plugins +------- + +GCC plugins are loadable modules that provide extra features to the +compiler. Like GCC itself they can be distributed in source and +binary forms. + +GCC plugins provide developers with a rich subset of +the GCC API to allow them to extend GCC as they see fit. +Whether it is writing an additional optimization pass, +transforming code, or analyzing information, plugins +can be quite useful. + +.. toctree:: + :maxdepth: 2 + + plugins/loading-plugins + plugins/plugin-api + plugins/interacting-with-the-pass-manager + plugins/interacting-with-the-gcc-garbage-collector + plugins/giving-information-about-a-plugin + plugins/registering-custom-attributes-or-pragmas + plugins/recording-information-about-pass-execution + plugins/controlling-which-passes-are-being-run + plugins/keeping-track-of-available-passes + plugins/building-gcc-plugins \ No newline at end of file diff --git a/gcc/doc/gccint/plugins/building-gcc-plugins.rst b/gcc/doc/gccint/plugins/building-gcc-plugins.rst new file mode 100644 index 00000000000..8c8fe28b0d6 --- /dev/null +++ b/gcc/doc/gccint/plugins/building-gcc-plugins.rst @@ -0,0 +1,97 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _plugins-building: + +Building GCC plugins +******************** + +If plugins are enabled, GCC installs the headers needed to build a +plugin (somewhere in the installation tree, e.g. under +:samp:`/usr/local`). In particular a :samp:`plugin/include` directory +is installed, containing all the header files needed to build plugins. + +On most systems, you can query this ``plugin`` directory by +invoking :command:`gcc -print-file-name=plugin` (replace if needed +:command:`gcc` with the appropriate program path). + +Inside plugins, this ``plugin`` directory name can be queried by +calling ``default_plugin_dir_name ()``. + +Plugins may know, when they are compiled, the GCC version for which +:samp:`plugin-version.h` is provided. The constant macros +``GCCPLUGIN_VERSION_MAJOR``, ``GCCPLUGIN_VERSION_MINOR``, +``GCCPLUGIN_VERSION_PATCHLEVEL``, ``GCCPLUGIN_VERSION`` are +integer numbers, so a plugin could ensure it is built for GCC 4.7 with + +.. code-block:: c++ + + #if GCCPLUGIN_VERSION != 4007 + #error this GCC plugin is for GCC 4.7 + #endif + +The following GNU Makefile excerpt shows how to build a simple plugin: + +.. code-block:: + + HOST_GCC=g++ + TARGET_GCC=gcc + PLUGIN_SOURCE_FILES= plugin1.c plugin2.cc + GCCPLUGINS_DIR:= $(shell $(TARGET_GCC) -print-file-name=plugin) + CXXFLAGS+= -I$(GCCPLUGINS_DIR)/include -fPIC -fno-rtti -O2 + + plugin.so: $(PLUGIN_SOURCE_FILES) + $(HOST_GCC) -shared $(CXXFLAGS) $^ -o $@ + +A single source file plugin may be built with ``g++ -I`gcc +-print-file-name=plugin`/include -fPIC -shared -fno-rtti -O2 plugin.cc -o +plugin.so``, using backquote shell syntax to query the :samp:`plugin` +directory. + +Plugin support on Windows/MinGW has a number of limitations and +additional requirements. When building a plugin on Windows we have to +link an import library for the corresponding backend executable, for +example, :samp:`cc1.exe`, :samp:`cc1plus.exe`, etc., in order to gain +access to the symbols provided by GCC. This means that on Windows a +plugin is language-specific, for example, for C, C++, etc. If you wish +to use your plugin with multiple languages, then you will need to +build multiple plugin libraries and either instruct your users on how +to load the correct version or provide a compiler wrapper that does +this automatically. + +Additionally, on Windows the plugin library has to export the +``plugin_is_GPL_compatible`` and ``plugin_init`` symbols. If you +do not wish to modify the source code of your plugin, then you can use +the :option:`-Wl,--export-all-symbols` option or provide a suitable DEF +file. Alternatively, you can export just these two symbols by decorating +them with ``__declspec(dllexport)``, for example: + +.. code-block:: c++ + + #ifdef _WIN32 + __declspec(dllexport) + #endif + int plugin_is_GPL_compatible; + + #ifdef _WIN32 + __declspec(dllexport) + #endif + int plugin_init (plugin_name_args *, plugin_gcc_version *) + +The import libraries are installed into the ``plugin`` directory +and their names are derived by appending the ``.a`` extension to +the backend executable names, for example, :samp:`cc1.exe.a`, +:samp:`cc1plus.exe.a`, etc. The following command line shows how to +build the single source file plugin on Windows to be used with the C++ +compiler: + +.. code-block:: + + g++ -I`gcc -print-file-name=plugin`/include -shared -Wl,--export-all-symbols \ + -o plugin.dll plugin.cc `gcc -print-file-name=plugin`/cc1plus.exe.a + +When a plugin needs to use :command:`gengtype`, be sure that both +:samp:`gengtype` and :samp:`gtype.state` have the same version as the +GCC for which the plugin is built. \ No newline at end of file diff --git a/gcc/doc/gccint/plugins/controlling-which-passes-are-being-run.rst b/gcc/doc/gccint/plugins/controlling-which-passes-are-being-run.rst new file mode 100644 index 00000000000..09bd9d2d396 --- /dev/null +++ b/gcc/doc/gccint/plugins/controlling-which-passes-are-being-run.rst @@ -0,0 +1,16 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _plugins-gate: + +Controlling which passes are being run +************************************** + +After the original gate function for a pass is called, its result +- the gate status - is stored as an integer. +Then the event ``PLUGIN_OVERRIDE_GATE`` is invoked, with a pointer +to the gate status in the ``gcc_data`` parameter to the callback function. +A nonzero value of the gate status means that the pass is to be executed. +You can both read and write the gate status via the passed pointer. \ No newline at end of file diff --git a/gcc/doc/gccint/plugins/giving-information-about-a-plugin.rst b/gcc/doc/gccint/plugins/giving-information-about-a-plugin.rst new file mode 100644 index 00000000000..ca6690c0973 --- /dev/null +++ b/gcc/doc/gccint/plugins/giving-information-about-a-plugin.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _plugins-description: + +Giving information about a plugin +********************************* + +A plugin should give some information to the user about itself. This +uses the following structure: + +.. code-block:: c++ + + struct plugin_info + { + const char *version; + const char *help; + }; + +Such a structure is passed as the ``user_data`` by the plugin's +init routine using ``register_callback`` with the +``PLUGIN_INFO`` pseudo-event and a null callback. \ No newline at end of file diff --git a/gcc/doc/gccint/plugins/interacting-with-the-gcc-garbage-collector.rst b/gcc/doc/gccint/plugins/interacting-with-the-gcc-garbage-collector.rst new file mode 100644 index 00000000000..1f26b158c8a --- /dev/null +++ b/gcc/doc/gccint/plugins/interacting-with-the-gcc-garbage-collector.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _plugins-gc: + +Interacting with the GCC Garbage Collector +****************************************** + +Some plugins may want to be informed when GGC (the GCC Garbage +Collector) is running. They can register callbacks for the +``PLUGIN_GGC_START`` and ``PLUGIN_GGC_END`` events (for which +the callback is called with a null ``gcc_data``) to be notified of +the start or end of the GCC garbage collection. + +Some plugins may need to have GGC mark additional data. This can be +done by registering a callback (called with a null ``gcc_data``) +for the ``PLUGIN_GGC_MARKING`` event. Such callbacks can call the +``ggc_set_mark`` routine, preferably through the ``ggc_mark`` macro +(and conversely, these routines should usually not be used in plugins +outside of the ``PLUGIN_GGC_MARKING`` event). Plugins that wish to hold +weak references to gc data may also use this event to drop weak references when +the object is about to be collected. The ``ggc_marked_p`` function can be +used to tell if an object is marked, or is about to be collected. The +``gt_clear_cache`` overloads which some types define may also be of use in +managing weak references. + +Some plugins may need to add extra GGC root tables, e.g. to handle their own +``GTY`` -ed data. This can be done with the ``PLUGIN_REGISTER_GGC_ROOTS`` +pseudo-event with a null callback and the extra root table (of type ``struct +ggc_root_tab*``) as ``user_data``. Running the +``gengtype -p source-dirfile-listplugin*.c ...`` +utility generates these extra root tables. + +You should understand the details of memory management inside GCC +before using ``PLUGIN_GGC_MARKING`` or ``PLUGIN_REGISTER_GGC_ROOTS``. \ No newline at end of file diff --git a/gcc/doc/gccint/plugins/interacting-with-the-pass-manager.rst b/gcc/doc/gccint/plugins/interacting-with-the-pass-manager.rst new file mode 100644 index 00000000000..38fe515c661 --- /dev/null +++ b/gcc/doc/gccint/plugins/interacting-with-the-pass-manager.rst @@ -0,0 +1,57 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _plugins-pass: + +Interacting with the pass manager +********************************* + +There needs to be a way to add/reorder/remove passes dynamically. This +is useful for both analysis plugins (plugging in after a certain pass +such as CFG or an IPA pass) and optimization plugins. + +Basic support for inserting new passes or replacing existing passes is +provided. A plugin registers a new pass with GCC by calling +``register_callback`` with the ``PLUGIN_PASS_MANAGER_SETUP`` +event and a pointer to a ``struct register_pass_info`` object defined as follows + +.. code-block:: c++ + + enum pass_positioning_ops + { + PASS_POS_INSERT_AFTER, // Insert after the reference pass. + PASS_POS_INSERT_BEFORE, // Insert before the reference pass. + PASS_POS_REPLACE // Replace the reference pass. + }; + + struct register_pass_info + { + struct opt_pass *pass; /* New pass provided by the plugin. */ + const char *reference_pass_name; /* Name of the reference pass for hooking + up the new pass. */ + int ref_pass_instance_number; /* Insert the pass at the specified + instance number of the reference pass. */ + /* Do it for every instance if it is 0. */ + enum pass_positioning_ops pos_op; /* how to insert the new pass. */ + }; + + /* Sample plugin code that registers a new pass. */ + int + plugin_init (struct plugin_name_args *plugin_info, + struct plugin_gcc_version *version) + { + struct register_pass_info pass_info; + + ... + + /* Code to fill in the pass_info object with new pass information. */ + + ... + + /* Register the new pass. */ + register_callback (plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info); + + ... + } \ No newline at end of file diff --git a/gcc/doc/gccint/plugins/keeping-track-of-available-passes.rst b/gcc/doc/gccint/plugins/keeping-track-of-available-passes.rst new file mode 100644 index 00000000000..8af79754524 --- /dev/null +++ b/gcc/doc/gccint/plugins/keeping-track-of-available-passes.rst @@ -0,0 +1,17 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _plugins-tracking: + +Keeping track of available passes +********************************* + +When your plugin is loaded, you can inspect the various +pass lists to determine what passes are available. However, other +plugins might add new passes. Also, future changes to GCC might cause +generic passes to be added after plugin loading. +When a pass is first added to one of the pass lists, the event +``PLUGIN_NEW_PASS`` is invoked, with the callback parameter +``gcc_data`` pointing to the new pass. \ No newline at end of file diff --git a/gcc/doc/gccint/plugins/loading-plugins.rst b/gcc/doc/gccint/plugins/loading-plugins.rst new file mode 100644 index 00000000000..dbcff491d8c --- /dev/null +++ b/gcc/doc/gccint/plugins/loading-plugins.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _plugins-loading: + +Loading Plugins +*************** + +Plugins are supported on platforms that support :option:`-ldl +-rdynamic` as well as Windows/MinGW. They are loaded by the compiler +using ``dlopen`` or equivalent and invoked at pre-determined +locations in the compilation process. + +Plugins are loaded with + +:option:`-fplugin=/path/to/name.ext` :option:`-fplugin-arg-name-key1[=value1]` + +Where :samp:`{name}` is the plugin name and :samp:`{ext}` is the platform-specific +dynamic library extension. It should be ``dll`` on Windows/MinGW, +``dylib`` on Darwin/Mac OS X, and ``so`` on all other platforms. +The plugin arguments are parsed by GCC and passed to respective +plugins as key-value pairs. Multiple plugins can be invoked by +specifying multiple :option:`-fplugin` arguments. + +A plugin can be simply given by its short name (no dots or +slashes). When simply passing :option:`-fplugin=name`, the plugin is +loaded from the :samp:`plugin` directory, so :option:`-fplugin=name` is +the same as :option:`-fplugin\=\`gcc -print-file-name=plugin\`/name.ext`, +using backquote shell syntax to query the :samp:`plugin` directory. \ No newline at end of file diff --git a/gcc/doc/gccint/plugins/plugin-api.rst b/gcc/doc/gccint/plugins/plugin-api.rst new file mode 100644 index 00000000000..a3b0ffe69d1 --- /dev/null +++ b/gcc/doc/gccint/plugins/plugin-api.rst @@ -0,0 +1,213 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _plugin-api: + +Plugin API +********** + +Plugins are activated by the compiler at specific events as defined in +:samp:`gcc-plugin.h`. For each event of interest, the plugin should +call ``register_callback`` specifying the name of the event and +address of the callback function that will handle that event. + +The header :samp:`gcc-plugin.h` must be the first gcc header to be included. + +Plugin license check +^^^^^^^^^^^^^^^^^^^^ + +Every plugin should define the global symbol ``plugin_is_GPL_compatible`` +to assert that it has been licensed under a GPL-compatible license. +If this symbol does not exist, the compiler will emit a fatal error +and exit with the error message: + +.. code-block:: + + fatal error: plugin name is not licensed under a GPL-compatible license + name: undefined symbol: plugin_is_GPL_compatible + compilation terminated + +The declared type of the symbol should be int, to match a forward declaration +in :samp:`gcc-plugin.h` that suppresses C++ mangling. It does not need to be in +any allocated section, though. The compiler merely asserts that +the symbol exists in the global scope. Something like this is enough: + +.. code-block:: c++ + + int plugin_is_GPL_compatible; + +Plugin initialization +^^^^^^^^^^^^^^^^^^^^^ + +Every plugin should export a function called ``plugin_init`` that +is called right after the plugin is loaded. This function is +responsible for registering all the callbacks required by the plugin +and do any other required initialization. + +This function is called from ``compile_file`` right before invoking +the parser. The arguments to ``plugin_init`` are: + +* ``plugin_info`` : Plugin invocation information. + +* ``version`` : GCC version. + +The ``plugin_info`` struct is defined as follows: + +.. code-block:: c++ + + struct plugin_name_args + { + char *base_name; /* Short name of the plugin + (filename without .so suffix). */ + const char *full_name; /* Path to the plugin as specified with + -fplugin=. */ + int argc; /* Number of arguments specified with + -fplugin-arg-.... */ + struct plugin_argument *argv; /* Array of ARGC key-value pairs. */ + const char *version; /* Version string provided by plugin. */ + const char *help; /* Help string provided by plugin. */ + } + +If initialization fails, ``plugin_init`` must return a non-zero +value. Otherwise, it should return 0. + +The version of the GCC compiler loading the plugin is described by the +following structure: + +.. code-block:: c++ + + struct plugin_gcc_version + { + const char *basever; + const char *datestamp; + const char *devphase; + const char *revision; + const char *configuration_arguments; + }; + +The function ``plugin_default_version_check`` takes two pointers to +such structure and compare them field by field. It can be used by the +plugin's ``plugin_init`` function. + +The version of GCC used to compile the plugin can be found in the symbol +``gcc_version`` defined in the header :samp:`plugin-version.h`. The +recommended version check to perform looks like + +.. code-block:: c++ + + #include "plugin-version.h" + ... + + int + plugin_init (struct plugin_name_args *plugin_info, + struct plugin_gcc_version *version) + { + if (!plugin_default_version_check (version, &gcc_version)) + return 1; + + } + +but you can also check the individual fields if you want a less strict check. + +Plugin callbacks +^^^^^^^^^^^^^^^^ + +Callback functions have the following prototype: + +.. code-block:: c++ + + /* The prototype for a plugin callback function. + gcc_data - event-specific data provided by GCC + user_data - plugin-specific data provided by the plug-in. */ + typedef void (*plugin_callback_func)(void *gcc_data, void *user_data); + +Callbacks can be invoked at the following pre-determined events: + +.. code-block:: c++ + + enum plugin_event + { + PLUGIN_START_PARSE_FUNCTION, /* Called before parsing the body of a function. */ + PLUGIN_FINISH_PARSE_FUNCTION, /* After finishing parsing a function. */ + PLUGIN_PASS_MANAGER_SETUP, /* To hook into pass manager. */ + PLUGIN_FINISH_TYPE, /* After finishing parsing a type. */ + PLUGIN_FINISH_DECL, /* After finishing parsing a declaration. */ + PLUGIN_FINISH_UNIT, /* Useful for summary processing. */ + PLUGIN_PRE_GENERICIZE, /* Allows to see low level AST in C and C++ frontends. */ + PLUGIN_FINISH, /* Called before GCC exits. */ + PLUGIN_INFO, /* Information about the plugin. */ + PLUGIN_GGC_START, /* Called at start of GCC Garbage Collection. */ + PLUGIN_GGC_MARKING, /* Extend the GGC marking. */ + PLUGIN_GGC_END, /* Called at end of GGC. */ + PLUGIN_REGISTER_GGC_ROOTS, /* Register an extra GGC root table. */ + PLUGIN_ATTRIBUTES, /* Called during attribute registration */ + PLUGIN_START_UNIT, /* Called before processing a translation unit. */ + PLUGIN_PRAGMAS, /* Called during pragma registration. */ + /* Called before first pass from all_passes. */ + PLUGIN_ALL_PASSES_START, + /* Called after last pass from all_passes. */ + PLUGIN_ALL_PASSES_END, + /* Called before first ipa pass. */ + PLUGIN_ALL_IPA_PASSES_START, + /* Called after last ipa pass. */ + PLUGIN_ALL_IPA_PASSES_END, + /* Allows to override pass gate decision for current_pass. */ + PLUGIN_OVERRIDE_GATE, + /* Called before executing a pass. */ + PLUGIN_PASS_EXECUTION, + /* Called before executing subpasses of a GIMPLE_PASS in + execute_ipa_pass_list. */ + PLUGIN_EARLY_GIMPLE_PASSES_START, + /* Called after executing subpasses of a GIMPLE_PASS in + execute_ipa_pass_list. */ + PLUGIN_EARLY_GIMPLE_PASSES_END, + /* Called when a pass is first instantiated. */ + PLUGIN_NEW_PASS, + /* Called when a file is #include-d or given via the #line directive. + This could happen many times. The event data is the included file path, + as a const char* pointer. */ + PLUGIN_INCLUDE_FILE, + + /* Called when -fanalyzer starts. The event data is an + ana::plugin_analyzer_init_iface *. */ + PLUGIN_ANALYZER_INIT, + + PLUGIN_EVENT_FIRST_DYNAMIC /* Dummy event used for indexing callback + array. */ + }; + +In addition, plugins can also look up the enumerator of a named event, +and / or generate new events dynamically, by calling the function +``get_named_event_id``. + +To register a callback, the plugin calls ``register_callback`` with +the arguments: + +* ``char *name`` : Plugin name. + +* ``int event`` : The event code. + +* ``plugin_callback_func callback`` : The function that handles ``event``. + +* ``void *user_data`` : Pointer to plugin-specific data. + +For the PLUGIN_PASS_MANAGER_SETUP, PLUGIN_INFO, and +PLUGIN_REGISTER_GGC_ROOTS pseudo-events the ``callback`` should be null, +and the ``user_data`` is specific. + +When the PLUGIN_PRAGMAS event is triggered (with a null pointer as +data from GCC), plugins may register their own pragmas. Notice that +pragmas are not available from :samp:`lto1`, so plugins used with +``-flto`` option to GCC during link-time optimization cannot use +pragmas and do not even see functions like ``c_register_pragma`` or +``pragma_lex``. + +The PLUGIN_INCLUDE_FILE event, with a ``const char*`` file path as +GCC data, is triggered for processing of ``#include`` or +``#line`` directives. + +The PLUGIN_FINISH event is the last time that plugins can call GCC +functions, notably emit diagnostics with ``warning``, ``error`` +etc. \ No newline at end of file diff --git a/gcc/doc/gccint/plugins/recording-information-about-pass-execution.rst b/gcc/doc/gccint/plugins/recording-information-about-pass-execution.rst new file mode 100644 index 00000000000..4418c986824 --- /dev/null +++ b/gcc/doc/gccint/plugins/recording-information-about-pass-execution.rst @@ -0,0 +1,20 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _plugins-recording: + +Recording information about pass execution +****************************************** + +The event PLUGIN_PASS_EXECUTION passes the pointer to the executed pass +(the same as current_pass) as ``gcc_data`` to the callback. You can also +inspect cfun to find out about which function this pass is executed for. +Note that this event will only be invoked if the gate check (if +applicable, modified by PLUGIN_OVERRIDE_GATE) succeeds. +You can use other hooks, like ``PLUGIN_ALL_PASSES_START``, +``PLUGIN_ALL_PASSES_END``, ``PLUGIN_ALL_IPA_PASSES_START``, +``PLUGIN_ALL_IPA_PASSES_END``, ``PLUGIN_EARLY_GIMPLE_PASSES_START``, +and/or ``PLUGIN_EARLY_GIMPLE_PASSES_END`` to manipulate global state +in your plugin(s) in order to get context for the pass execution. \ No newline at end of file diff --git a/gcc/doc/gccint/plugins/registering-custom-attributes-or-pragmas.rst b/gcc/doc/gccint/plugins/registering-custom-attributes-or-pragmas.rst new file mode 100644 index 00000000000..0b2b62a9abf --- /dev/null +++ b/gcc/doc/gccint/plugins/registering-custom-attributes-or-pragmas.rst @@ -0,0 +1,73 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _plugins-attr: + +Registering custom attributes or pragmas +**************************************** + +For analysis (or other) purposes it is useful to be able to add custom +attributes or pragmas. + +The ``PLUGIN_ATTRIBUTES`` callback is called during attribute +registration. Use the ``register_attribute`` function to register +custom attributes. + +.. code-block:: c++ + + /* Attribute handler callback */ + static tree + handle_user_attribute (tree *node, tree name, tree args, + int flags, bool *no_add_attrs) + { + return NULL_TREE; + } + + /* Attribute definition */ + static struct attribute_spec user_attr = + { "user", 1, 1, false, false, false, false, handle_user_attribute, NULL }; + + /* Plugin callback called during attribute registration. + Registered with register_callback (plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL) + */ + static void + register_attributes (void *event_data, void *data) + { + warning (0, G_("Callback to register attributes")); + register_attribute (&user_attr); + } + +The PLUGIN_PRAGMAS callback is called once during pragmas +registration. Use the ``c_register_pragma``, +``c_register_pragma_with_data``, +``c_register_pragma_with_expansion``, +``c_register_pragma_with_expansion_and_data`` functions to register +custom pragmas and their handlers (which often want to call +``pragma_lex``) from :samp:`c-family/c-pragma.h`. + +.. code-block:: c++ + + /* Plugin callback called during pragmas registration. Registered with + register_callback (plugin_name, PLUGIN_PRAGMAS, + register_my_pragma, NULL); + */ + static void + register_my_pragma (void *event_data, void *data) + { + warning (0, G_("Callback to register pragmas")); + c_register_pragma ("GCCPLUGIN", "sayhello", handle_pragma_sayhello); + } + +It is suggested to pass ``"GCCPLUGIN"`` (or a short name identifying +your plugin) as the 'space' argument of your pragma. + +Pragmas registered with ``c_register_pragma_with_expansion`` or +``c_register_pragma_with_expansion_and_data`` support +preprocessor expansions. For example: + +.. code-block:: c++ + + #define NUMBER 10 + #pragma GCCPLUGIN foothreshold (NUMBER) \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation.rst b/gcc/doc/gccint/rtl-representation.rst new file mode 100644 index 00000000000..f472b03cef4 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RTL representation, representation of RTL, Register Transfer Language (RTL) + +.. _rtl: + +RTL Representation +------------------ + +The last part of the compiler work is done on a low-level intermediate +representation called Register Transfer Language. In this language, the +instructions to be output are described, pretty much one by one, in an +algebraic form that describes what the instruction does. + +RTL is inspired by Lisp lists. It has both an internal form, made up of +structures that point at other structures, and a textual form that is used +in the machine description and in printed debugging dumps. The textual +form uses nested parentheses to indicate the pointers in the internal form. + +.. toctree:: + :maxdepth: 2 + + rtl-representation/rtl-object-types + rtl-representation/rtl-classes-and-formats + rtl-representation/access-to-operands + rtl-representation/access-to-special-operands + rtl-representation/flags-in-an-rtl-expression + rtl-representation/machine-modes + rtl-representation/constant-expression-types + rtl-representation/registers-and-memory + rtl-representation/rtl-expressions-for-arithmetic + rtl-representation/comparison-operations + rtl-representation/bit-fields + rtl-representation/vector-operations + rtl-representation/conversions + rtl-representation/declarations + rtl-representation/side-effect-expressions + rtl-representation/embedded-side-effects-on-addresses + rtl-representation/assembler-instructions-as-expressions + rtl-representation/variable-location-debug-information-in-rtl + rtl-representation/insns + rtl-representation/rtl-representation-of-function-call-insns + rtl-representation/on-the-side-ssa-form-for-rtl + rtl-representation/structure-sharing-assumptions + rtl-representation/reading-rtl \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/access-to-operands.rst b/gcc/doc/gccint/rtl-representation/access-to-operands.rst new file mode 100644 index 00000000000..90fc73ba609 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/access-to-operands.rst @@ -0,0 +1,73 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: accessors, access to operands, operand access, XEXP, XINT, XWINT, XSTR + +.. _accessors: + +Access to Operands +****************** + +Operands of expressions are accessed using the macros ``XEXP``, +``XINT``, ``XWINT`` and ``XSTR``. Each of these macros takes +two arguments: an expression-pointer (RTX) and an operand number +(counting from zero). Thus, + +.. code-block:: c++ + + XEXP (x, 2) + +accesses operand 2 of expression :samp:`{x}`, as an expression. + +.. code-block:: c++ + + XINT (x, 2) + +accesses the same operand as an integer. ``XSTR``, used in the same +fashion, would access it as a string. + +Any operand can be accessed as an integer, as an expression or as a string. +You must choose the correct method of access for the kind of value actually +stored in the operand. You would do this based on the expression code of +the containing expression. That is also how you would know how many +operands there are. + +For example, if :samp:`{x}` is an ``int_list`` expression, you know that it has +two operands which can be correctly accessed as ``XINT (x, 0)`` +and ``XEXP (x, 1)``. Incorrect accesses like +``XEXP (x, 0)`` and ``XINT (x, 1)`` would compile, +but would trigger an internal compiler error when rtl checking is enabled. +Nothing stops you from writing ``XEXP (x, 28)`` either, but +this will access memory past the end of the expression with +unpredictable results. + +Access to operands which are vectors is more complicated. You can use the +macro ``XVEC`` to get the vector-pointer itself, or the macros +``XVECEXP`` and ``XVECLEN`` to access the elements and length of a +vector. + +.. index:: XVEC + +:samp:`XVEC ({exp}, {idx})` + Access the vector-pointer which is operand number :samp:`{idx}` in :samp:`{exp}`. + + .. index:: XVECLEN + +:samp:`XVECLEN ({exp}, {idx})` + Access the length (number of elements) in the vector which is + in operand number :samp:`{idx}` in :samp:`{exp}`. This value is an ``int``. + + .. index:: XVECEXP + +:samp:`XVECEXP ({exp}, {idx}, {eltnum})` + Access element number :samp:`{eltnum}` in the vector which is + in operand number :samp:`{idx}` in :samp:`{exp}`. This value is an RTX. + + It is up to you to make sure that :samp:`{eltnum}` is not negative + and is less than ``XVECLEN (exp, idx)``. + +All the macros defined in this section expand into lvalues and therefore +can be used to assign the operands, lengths and vector elements as well as +to access them. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/access-to-special-operands.rst b/gcc/doc/gccint/rtl-representation/access-to-special-operands.rst new file mode 100644 index 00000000000..b344dc7f5f9 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/access-to-special-operands.rst @@ -0,0 +1,188 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: access to special operands + +.. _special-accessors: + +Access to Special Operands +************************** + +Some RTL nodes have special annotations associated with them. + +``MEM`` + + .. index:: MEM_ALIAS_SET + + :samp:`MEM_ALIAS_SET ({x})` + If 0, :samp:`{x}` is not in any alias set, and may alias anything. Otherwise, + :samp:`{x}` can only alias ``MEM`` s in a conflicting alias set. This value + is set in a language-dependent manner in the front-end, and should not be + altered in the back-end. In some front-ends, these numbers may correspond + in some way to types, or other language-level entities, but they need not, + and the back-end makes no such assumptions. + These set numbers are tested with ``alias_sets_conflict_p``. + + .. index:: MEM_EXPR + + :samp:`MEM_EXPR ({x})` + If this register is known to hold the value of some user-level + declaration, this is that tree node. It may also be a + ``COMPONENT_REF``, in which case this is some field reference, + and ``TREE_OPERAND (x, 0)`` contains the declaration, + or another ``COMPONENT_REF``, or null if there is no compile-time + object associated with the reference. + + .. index:: MEM_OFFSET_KNOWN_P + + :samp:`MEM_OFFSET_KNOWN_P ({x})` + True if the offset of the memory reference from ``MEM_EXPR`` is known. + :samp:`MEM_OFFSET ({x})` provides the offset if so. + + .. index:: MEM_OFFSET + + :samp:`MEM_OFFSET ({x})` + The offset from the start of ``MEM_EXPR``. The value is only valid if + :samp:`MEM_OFFSET_KNOWN_P ({x})` is true. + + .. index:: MEM_SIZE_KNOWN_P + + :samp:`MEM_SIZE_KNOWN_P ({x})` + True if the size of the memory reference is known. + :samp:`MEM_SIZE ({x})` provides its size if so. + + .. index:: MEM_SIZE + + :samp:`MEM_SIZE ({x})` + The size in bytes of the memory reference. + This is mostly relevant for ``BLKmode`` references as otherwise + the size is implied by the mode. The value is only valid if + :samp:`MEM_SIZE_KNOWN_P ({x})` is true. + + .. index:: MEM_ALIGN + + :samp:`MEM_ALIGN ({x})` + The known alignment in bits of the memory reference. + + .. index:: MEM_ADDR_SPACE + + :samp:`MEM_ADDR_SPACE ({x})` + The address space of the memory reference. This will commonly be zero + for the generic address space. + +``REG`` + + .. index:: ORIGINAL_REGNO + + :samp:`ORIGINAL_REGNO ({x})` + This field holds the number the register 'originally' had; for a + pseudo register turned into a hard reg this will hold the old pseudo + register number. + + .. index:: REG_EXPR + + :samp:`REG_EXPR ({x})` + If this register is known to hold the value of some user-level + declaration, this is that tree node. + + .. index:: REG_OFFSET + + :samp:`REG_OFFSET ({x})` + If this register is known to hold the value of some user-level + declaration, this is the offset into that logical storage. + +.. envvar:: SYMBOL_REF + + .. index:: SYMBOL_REF_DECL + + :samp:`SYMBOL_REF_DECL ({x})` + If the ``symbol_ref`` :samp:`{x}` was created for a ``VAR_DECL`` or + a ``FUNCTION_DECL``, that tree is recorded here. If this value is + null, then :samp:`{x}` was created by back end code generation routines, + and there is no associated front end symbol table entry. + + ``SYMBOL_REF_DECL`` may also point to a tree of class ``'c'``, + that is, some sort of constant. In this case, the ``symbol_ref`` + is an entry in the per-file constant pool; again, there is no associated + front end symbol table entry. + + .. index:: SYMBOL_REF_CONSTANT + + :samp:`SYMBOL_REF_CONSTANT ({x})` + If :samp:`CONSTANT_POOL_ADDRESS_P ({x})` is true, this is the constant + pool entry for :samp:`{x}`. It is null otherwise. + + .. index:: SYMBOL_REF_DATA + + :samp:`SYMBOL_REF_DATA ({x})` + A field of opaque type used to store ``SYMBOL_REF_DECL`` or + ``SYMBOL_REF_CONSTANT``. + + .. index:: SYMBOL_REF_FLAGS + + :samp:`SYMBOL_REF_FLAGS ({x})` + In a ``symbol_ref``, this is used to communicate various predicates + about the symbol. Some of these are common enough to be computed by + common code, some are specific to the target. The common bits are: + + .. index:: SYMBOL_REF_FUNCTION_P, SYMBOL_FLAG_FUNCTION + + .. envvar:: SYMBOL_FLAG_FUNCTION + + Set if the symbol refers to a function. + + .. envvar:: SYMBOL_FLAG_LOCAL + + Set if the symbol is local to this 'module'. + See ``TARGET_BINDS_LOCAL_P``. + + .. envvar:: SYMBOL_FLAG_EXTERNAL + + Set if this symbol is not defined in this translation unit. + Note that this is not the inverse of ``SYMBOL_FLAG_LOCAL``. + + .. envvar:: SYMBOL_FLAG_SMALL + + Set if the symbol is located in the small data section. + See ``TARGET_IN_SMALL_DATA_P``. + + :samp:`SYMBOL_REF_TLS_MODEL ({x})` + This is a multi-bit field accessor that returns the ``tls_model`` + to be used for a thread-local storage symbol. It returns zero for + non-thread-local symbols. + + .. index:: SYMBOL_REF_HAS_BLOCK_INFO_P, SYMBOL_FLAG_HAS_BLOCK_INFO + + .. envvar:: SYMBOL_FLAG_HAS_BLOCK_INFO + + Set if the symbol has ``SYMBOL_REF_BLOCK`` and + ``SYMBOL_REF_BLOCK_OFFSET`` fields. + + .. index:: -fsection-anchors + + .. envvar:: SYMBOL_FLAG_ANCHOR + + Set if the symbol is used as a section anchor. 'Section anchors' + are symbols that have a known position within an ``object_block`` + and that can be used to access nearby members of that block. + They are used to implement :option:`-fsection-anchors`. + + If this flag is set, then ``SYMBOL_FLAG_HAS_BLOCK_INFO`` will be too. + + Bits beginning with ``SYMBOL_FLAG_MACH_DEP`` are available for + the target's use. + +:samp:`SYMBOL_REF_BLOCK ({x})` + If :samp:`SYMBOL_REF_HAS_BLOCK_INFO_P ({x})`, this is the + :samp:`object_block` structure to which the symbol belongs, + or ``NULL`` if it has not been assigned a block. + + .. index:: SYMBOL_REF_BLOCK_OFFSET + +:samp:`SYMBOL_REF_BLOCK_OFFSET ({x})` + If :samp:`SYMBOL_REF_HAS_BLOCK_INFO_P ({x})`, this is the offset of :samp:`{x}` + from the first object in :samp:`SYMBOL_REF_BLOCK ({x})`. The value is + negative if :samp:`{x}` has not yet been assigned to a block, or it has not + been given an offset within that block. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/assembler-instructions-as-expressions.rst b/gcc/doc/gccint/rtl-representation/assembler-instructions-as-expressions.rst new file mode 100644 index 00000000000..1d49a0a963c --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/assembler-instructions-as-expressions.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: assembler instructions in RTL, asm_operands, usage + +.. _assembler: + +Assembler Instructions as Expressions +************************************* + +The RTX code ``asm_operands`` represents a value produced by a +user-specified assembler instruction. It is used to represent +an ``asm`` statement with arguments. An ``asm`` statement with +a single output operand, like this: + +.. code-block:: c++ + + asm ("foo %1,%2,%0" : "=a" (outputvar) : "g" (x + y), "di" (*z)); + +is represented using a single ``asm_operands`` RTX which represents +the value that is stored in ``outputvar`` : + +.. code-block:: c++ + + (set rtx-for-outputvar + (asm_operands "foo %1,%2,%0" "a" 0 + [rtx-for-addition-result rtx-for-*z] + [(asm_input:m1 "g") + (asm_input:m2 "di")])) + +Here the operands of the ``asm_operands`` RTX are the assembler +template string, the output-operand's constraint, the index-number of the +output operand among the output operands specified, a vector of input +operand RTX's, and a vector of input-operand modes and constraints. The +mode :samp:`{m1}` is the mode of the sum ``x+y`` ; :samp:`{m2}` is that of +``*z``. + +When an ``asm`` statement has multiple output values, its insn has +several such ``set`` RTX's inside of a ``parallel``. Each ``set`` +contains an ``asm_operands`` ; all of these share the same assembler +template and vectors, but each contains the constraint for the respective +output operand. They are also distinguished by the output-operand index +number, which is 0, 1, ... for successive output operands. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/bit-fields.rst b/gcc/doc/gccint/rtl-representation/bit-fields.rst new file mode 100644 index 00000000000..aeef77bef3e --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/bit-fields.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: bit-fields + +.. _bit-fields: + +Bit-Fields +********** + +Special expression codes exist to represent bit-field instructions. + +.. index:: sign_extract, BITS_BIG_ENDIAN, effect on sign_extract + +:samp:`(sign_extract:{m} {loc} {size} {pos})` + This represents a reference to a sign-extended bit-field contained or + starting in :samp:`{loc}` (a memory or register reference). The bit-field + is :samp:`{size}` bits wide and starts at bit :samp:`{pos}`. The compilation + option ``BITS_BIG_ENDIAN`` says which end of the memory unit + :samp:`{pos}` counts from. + + If :samp:`{loc}` is in memory, its mode must be a single-byte integer mode. + If :samp:`{loc}` is in a register, the mode to use is specified by the + operand of the ``insv`` or ``extv`` pattern + (see :ref:`standard-names`) and is usually a full-word integer mode, + which is the default if none is specified. + + The mode of :samp:`{pos}` is machine-specific and is also specified + in the ``insv`` or ``extv`` pattern. + + The mode :samp:`{m}` is the same as the mode that would be used for + :samp:`{loc}` if it were a register. + + A ``sign_extract`` cannot appear as an lvalue, or part thereof, + in RTL. + + .. index:: zero_extract + +:samp:`(zero_extract:{m} {loc} {size} {pos})` + Like ``sign_extract`` but refers to an unsigned or zero-extended + bit-field. The same sequence of bits are extracted, but they + are filled to an entire word with zeros instead of by sign-extension. + + Unlike ``sign_extract``, this type of expressions can be lvalues + in RTL; they may appear on the left side of an assignment, indicating + insertion of a value into the specified bit-field. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/comparison-operations.rst b/gcc/doc/gccint/rtl-representation/comparison-operations.rst new file mode 100644 index 00000000000..bfa0b6c01d7 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/comparison-operations.rst @@ -0,0 +1,112 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RTL comparison operations + +.. _comparisons: + +Comparison Operations +********************* + +Comparison operators test a relation on two operands and are considered +to represent a machine-dependent nonzero value described by, but not +necessarily equal to, ``STORE_FLAG_VALUE`` (see :ref:`misc`) +if the relation holds, or zero if it does not, for comparison operators +whose results have a 'MODE_INT' mode, +``FLOAT_STORE_FLAG_VALUE`` (see :ref:`misc`) if the relation holds, or +zero if it does not, for comparison operators that return floating-point +values, and a vector of either ``VECTOR_STORE_FLAG_VALUE`` (see :ref:`misc`) +if the relation holds, or of zeros if it does not, for comparison operators +that return vector results. +The mode of the comparison operation is independent of the mode +of the data being compared. If the comparison operation is being tested +(e.g., the first operand of an ``if_then_else``), the mode must be +``VOIDmode``. + +.. index:: condition codes + +A comparison operation compares two data +objects. The mode of the comparison is determined by the operands; they +must both be valid for a common machine mode. A comparison with both +operands constant would be invalid as the machine mode could not be +deduced from it, but such a comparison should never exist in RTL due to +constant folding. + +Usually only one style +of comparisons is supported on a particular machine, but the combine +pass will try to merge operations to produce code like +``(eq xy)``, +in case it exists in the context of the particular insn involved. + +Inequality comparisons come in two flavors, signed and unsigned. Thus, +there are distinct expression codes ``gt`` and ``gtu`` for signed and +unsigned greater-than. These can produce different results for the same +pair of integer values: for example, 1 is signed greater-than -1 but not +unsigned greater-than, because -1 when regarded as unsigned is actually +``0xffffffff`` which is greater than 1. + +The signed comparisons are also used for floating point values. Floating +point comparisons are distinguished by the machine modes of the operands. + +.. index:: eq, equal + +:samp:`(eq:{m} {x} {y})` + ``STORE_FLAG_VALUE`` if the values represented by :samp:`{x}` and :samp:`{y}` + are equal, otherwise 0. + + .. index:: ne, not equal + +:samp:`(ne:{m} {x} {y})` + ``STORE_FLAG_VALUE`` if the values represented by :samp:`{x}` and :samp:`{y}` + are not equal, otherwise 0. + + .. index:: gt, greater than + +:samp:`(gt:{m} {x} {y})` + ``STORE_FLAG_VALUE`` if the :samp:`{x}` is greater than :samp:`{y}`. If they + are fixed-point, the comparison is done in a signed sense. + + .. index:: gtu, greater than, unsigned greater than + +:samp:`(gtu:{m} {x} {y})` + Like ``gt`` but does unsigned comparison, on fixed-point numbers only. + + .. index:: lt, less than, ltu, unsigned less than + +:samp:`(lt:{m} {x} {y})` :samp:`(ltu:{m} {x} {y})` + Like ``gt`` and ``gtu`` but test for 'less than'. + + .. index:: ge, greater than, geu, unsigned greater than + +:samp:`(ge:{m} {x} {y})` :samp:`(geu:{m} {x} {y})` + Like ``gt`` and ``gtu`` but test for 'greater than or equal'. + + .. index:: le, less than or equal, leu, unsigned less than + +:samp:`(le:{m} {x} {y})` :samp:`(leu:{m} {x} {y})` + Like ``gt`` and ``gtu`` but test for 'less than or equal'. + + .. index:: if_then_else + +:samp:`(if_then_else {cond} {then} {else})` + This is not a comparison operation but is listed here because it is + always used in conjunction with a comparison operation. To be + precise, :samp:`{cond}` is a comparison expression. This expression + represents a choice, according to :samp:`{cond}`, between the value + represented by :samp:`{then}` and the one represented by :samp:`{else}`. + + On most machines, ``if_then_else`` expressions are valid only + to express conditional jumps. + + .. index:: cond + +:samp:`(cond [{test1} {value1} {test2} {value2} ...] {default})` + Similar to ``if_then_else``, but more general. Each of :samp:`{test1}`, + :samp:`{test2}`, ... is performed in turn. The result of this expression is + the :samp:`{value}` corresponding to the first nonzero test, or :samp:`{default}` if + none of the tests are nonzero expressions. + + This is currently not valid for instruction patterns and is supported only + for insn attributes. See :ref:`insn-attributes`. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/constant-expression-types.rst b/gcc/doc/gccint/rtl-representation/constant-expression-types.rst new file mode 100644 index 00000000000..5f10caf0478 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/constant-expression-types.rst @@ -0,0 +1,313 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RTL constants, RTL constant expression types + +.. _constants: + +Constant Expression Types +************************* + +The simplest RTL expressions are those that represent constant values. + +.. index:: const_int + +:samp:`(const_int {i})` + This type of expression represents the integer value :samp:`{i}`. :samp:`{i}` + is customarily accessed with the macro ``INTVAL`` as in + ``INTVAL (exp)``, which is equivalent to ``XWINT (exp, 0)``. + + Constants generated for modes with fewer bits than in + ``HOST_WIDE_INT`` must be sign extended to full width (e.g., with + ``gen_int_mode``). For constants for modes with more bits than in + ``HOST_WIDE_INT`` the implied high order bits of that constant are + copies of the top bit. Note however that values are neither + inherently signed nor inherently unsigned; where necessary, signedness + is determined by the rtl operation instead. + + .. index:: const0_rtx, const1_rtx, const2_rtx, constm1_rtx + + There is only one expression object for the integer value zero; it is + the value of the variable ``const0_rtx``. Likewise, the only + expression for integer value one is found in ``const1_rtx``, the only + expression for integer value two is found in ``const2_rtx``, and the + only expression for integer value negative one is found in + ``constm1_rtx``. Any attempt to create an expression of code + ``const_int`` and value zero, one, two or negative one will return + ``const0_rtx``, ``const1_rtx``, ``const2_rtx`` or + ``constm1_rtx`` as appropriate. + + .. index:: const_true_rtx + + Similarly, there is only one object for the integer whose value is + ``STORE_FLAG_VALUE``. It is found in ``const_true_rtx``. If + ``STORE_FLAG_VALUE`` is one, ``const_true_rtx`` and + ``const1_rtx`` will point to the same object. If + ``STORE_FLAG_VALUE`` is -1, ``const_true_rtx`` and + ``constm1_rtx`` will point to the same object. + + .. index:: const_double + +:samp:`(const_double:{m} {i0} {i1} ...)` + This represents either a floating-point constant of mode :samp:`{m}` or + (on older ports that do not define + ``TARGET_SUPPORTS_WIDE_INT``) an integer constant too large to fit + into ``HOST_BITS_PER_WIDE_INT`` bits but small enough to fit within + twice that number of bits. In the latter case, :samp:`{m}` will be + ``VOIDmode``. For integral values constants for modes with more + bits than twice the number in ``HOST_WIDE_INT`` the implied high + order bits of that constant are copies of the top bit of + ``CONST_DOUBLE_HIGH``. Note however that integral values are + neither inherently signed nor inherently unsigned; where necessary, + signedness is determined by the rtl operation instead. + + On more modern ports, ``CONST_DOUBLE`` only represents floating + point values. New ports define ``TARGET_SUPPORTS_WIDE_INT`` to + make this designation. + + .. index:: CONST_DOUBLE_LOW + + If :samp:`{m}` is ``VOIDmode``, the bits of the value are stored in + :samp:`{i0}` and :samp:`{i1}`. :samp:`{i0}` is customarily accessed with the macro + ``CONST_DOUBLE_LOW`` and :samp:`{i1}` with ``CONST_DOUBLE_HIGH``. + + If the constant is floating point (regardless of its precision), then + the number of integers used to store the value depends on the size of + ``REAL_VALUE_TYPE`` (see :ref:`floating-point`). The integers + represent a floating point number, but not precisely in the target + machine's or host machine's floating point format. To convert them to + the precise bit pattern used by the target machine, use the macro + ``REAL_VALUE_TO_TARGET_DOUBLE`` and friends (see :ref:`data-output`). + + .. index:: const_double_zero + + The host dependency for the number of integers used to store a double + value makes it problematic for machine descriptions to use expressions + of code ``const_double`` and therefore a syntactic alias has been + provided: + + .. code-block:: c++ + + (const_double_zero:m) + + standing for: + + .. code-block:: c++ + + (const_double:m 0 0 ...) + + for matching the floating-point value zero, possibly the only useful one. + + .. index:: CONST_WIDE_INT + +:samp:`(const_wide_int:{m} {nunits} {elt0} ...)` + This contains an array of ``HOST_WIDE_INT`` s that is large enough + to hold any constant that can be represented on the target. This form + of rtl is only used on targets that define + ``TARGET_SUPPORTS_WIDE_INT`` to be nonzero and then + ``CONST_DOUBLE`` s are only used to hold floating-point values. If + the target leaves ``TARGET_SUPPORTS_WIDE_INT`` defined as 0, + ``CONST_WIDE_INT`` s are not used and ``CONST_DOUBLE`` s are as + they were before. + + The values are stored in a compressed format. The higher-order + 0s or -1s are not represented if they are just the logical sign + extension of the number that is represented. + + .. index:: CONST_WIDE_INT_VEC + +:samp:`CONST_WIDE_INT_VEC ({code})` + Returns the entire array of ``HOST_WIDE_INT`` s that are used to + store the value. This macro should be rarely used. + + .. index:: CONST_WIDE_INT_NUNITS + +:samp:`CONST_WIDE_INT_NUNITS ({code})` + The number of ``HOST_WIDE_INT`` s used to represent the number. + Note that this generally is smaller than the number of + ``HOST_WIDE_INT`` s implied by the mode size. + + .. index:: CONST_WIDE_INT_ELT + +:samp:`CONST_WIDE_INT_ELT ({code},{i})` + Returns the ``i`` th element of the array. Element 0 is contains + the low order bits of the constant. + + .. index:: const_fixed + +:samp:`(const_fixed:{m} ...)` + Represents a fixed-point constant of mode :samp:`{m}`. + The operand is a data structure of type ``struct fixed_value`` and + is accessed with the macro ``CONST_FIXED_VALUE``. The high part of + data is accessed with ``CONST_FIXED_VALUE_HIGH`` ; the low part is + accessed with ``CONST_FIXED_VALUE_LOW``. + + .. index:: const_poly_int + +:samp:`(const_poly_int:{m} [{c0} {c1} ...])` + Represents a ``poly_int`` -style polynomial integer with coefficients + :samp:`{c0}`, :samp:`{c1}`, .... The coefficients are ``wide_int`` -based + integers rather than rtxes. ``CONST_POLY_INT_COEFFS`` gives the + values of individual coefficients (which is mostly only useful in + low-level routines) and ``const_poly_int_value`` gives the full + ``poly_int`` value. + + .. index:: const_vector + +:samp:`(const_vector:{m} [{x0} {x1} ...])` + Represents a vector constant. The values in square brackets are + elements of the vector, which are always ``const_int``, + ``const_wide_int``, ``const_double`` or ``const_fixed`` + expressions. + + Each vector constant :samp:`{v}` is treated as a specific instance of an + arbitrary-length sequence that itself contains + :samp:`CONST_VECTOR_NPATTERNS ({v})` interleaved patterns. Each + pattern has the form: + + .. code-block:: c++ + + { base0, base1, base1 + step, base1 + step * 2, ... } + + The first three elements in each pattern are enough to determine the + values of the other elements. However, if all :samp:`{step}` s are zero, + only the first two elements are needed. If in addition each :samp:`{base1}` + is equal to the corresponding :samp:`{base0}`, only the first element in + each pattern is needed. The number of determining elements per pattern + is given by :samp:`CONST_VECTOR_NELTS_PER_PATTERN ({v})`. + + For example, the constant: + + .. code-block:: c++ + + { 0, 1, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18 } + + is interpreted as an interleaving of the sequences: + + .. code-block:: c++ + + { 0, 2, 3, 4, 5, 6, 7, 8 } + { 1, 6, 8, 10, 12, 14, 16, 18 } + + where the sequences are represented by the following patterns: + + .. code-block:: c++ + + base0 == 0, base1 == 2, step == 1 + base0 == 1, base1 == 6, step == 2 + + In this case: + + .. code-block:: c++ + + CONST_VECTOR_NPATTERNS (v) == 2 + CONST_VECTOR_NELTS_PER_PATTERN (v) == 3 + + Thus the first 6 elements (:samp:`{ 0, 1, 2, 6, 3, 8 }`) are enough + to determine the whole sequence; we refer to them as the 'encoded' + elements. They are the only elements present in the square brackets + for variable-length ``const_vector`` s (i.e. for + ``const_vector`` s whose mode :samp:`{m}` has a variable number of + elements). However, as a convenience to code that needs to handle + both ``const_vector`` s and ``parallel`` s, all elements are + present in the square brackets for fixed-length ``const_vector`` s; + the encoding scheme simply reduces the amount of work involved in + processing constants that follow a regular pattern. + + Sometimes this scheme can create two possible encodings of the same + vector. For example { 0, 1 } could be seen as two patterns with + one element each or one pattern with two elements (:samp:`{base0}` and + :samp:`{base1}`). The canonical encoding is always the one with the + fewest patterns or (if both encodings have the same number of + petterns) the one with the fewest encoded elements. + + :samp:`const_vector_encoding_nelts ({v})` gives the total number of + encoded elements in :samp:`{v}`, which is 6 in the example above. + ``CONST_VECTOR_ENCODED_ELT (v, i)`` accesses the value + of encoded element :samp:`{i}`. + + :samp:`CONST_VECTOR_DUPLICATE_P ({v})` is true if :samp:`{v}` simply contains + repeated instances of :samp:`CONST_VECTOR_NPATTERNS ({v})` values. This is + a shorthand for testing :samp:`CONST_VECTOR_NELTS_PER_PATTERN ({v}) == 1`. + + :samp:`CONST_VECTOR_STEPPED_P ({v})` is true if at least one + pattern in :samp:`{v}` has a nonzero step. This is a shorthand for + testing :samp:`CONST_VECTOR_NELTS_PER_PATTERN ({v}) == 3`. + + ``CONST_VECTOR_NUNITS (v)`` gives the total number of elements + in :samp:`{v}` ; it is a shorthand for getting the number of units in + :samp:`GET_MODE ({v})`. + + The utility function ``const_vector_elt`` gives the value of an + arbitrary element as an ``rtx``. ``const_vector_int_elt`` gives + the same value as a ``wide_int``. + + .. index:: const_string + +:samp:`(const_string {str})` + Represents a constant string with value :samp:`{str}`. Currently this is + used only for insn attributes (see :ref:`insn-attributes`) since constant + strings in C are placed in memory. + + .. index:: symbol_ref + +:samp:`(symbol_ref:{mode} {symbol})` + Represents the value of an assembler label for data. :samp:`{symbol}` is + a string that describes the name of the assembler label. If it starts + with a :samp:`*`, the label is the rest of :samp:`{symbol}` not including + the :samp:`*`. Otherwise, the label is :samp:`{symbol}`, usually prefixed + with :samp:`_`. + + The ``symbol_ref`` contains a mode, which is usually ``Pmode``. + Usually that is the only mode for which a symbol is directly valid. + + .. index:: label_ref + +:samp:`(label_ref:{mode} {label})` + Represents the value of an assembler label for code. It contains one + operand, an expression, which must be a ``code_label`` or a ``note`` + of type ``NOTE_INSN_DELETED_LABEL`` that appears in the instruction + sequence to identify the place where the label should go. + + The reason for using a distinct expression type for code label + references is so that jump optimization can distinguish them. + + The ``label_ref`` contains a mode, which is usually ``Pmode``. + Usually that is the only mode for which a label is directly valid. + + .. index:: const + +:samp:`(const:{m} {exp})` + Represents a constant that is the result of an assembly-time + arithmetic computation. The operand, :samp:`{exp}`, contains only + ``const_int``, ``symbol_ref``, ``label_ref`` or ``unspec`` + expressions, combined with ``plus`` and ``minus``. Any such + ``unspec`` s are target-specific and typically represent some form + of relocation operator. :samp:`{m}` should be a valid address mode. + + .. index:: high + +:samp:`(high:{m} {exp})` + Represents the high-order bits of :samp:`{exp}`. + The number of bits is machine-dependent and is + normally the number of bits specified in an instruction that initializes + the high order bits of a register. It is used with ``lo_sum`` to + represent the typical two-instruction sequence used in RISC machines to + reference large immediate values and/or link-time constants such + as global memory addresses. In the latter case, :samp:`{m}` is ``Pmode`` + and :samp:`{exp}` is usually a constant expression involving ``symbol_ref``. + +.. index:: CONST0_RTX, CONST1_RTX, CONST2_RTX + +The macro ``CONST0_RTX (mode)`` refers to an expression with +value 0 in mode :samp:`{mode}`. If mode :samp:`{mode}` is of mode class +``MODE_INT``, it returns ``const0_rtx``. If mode :samp:`{mode}` is of +mode class ``MODE_FLOAT``, it returns a ``CONST_DOUBLE`` +expression in mode :samp:`{mode}`. Otherwise, it returns a +``CONST_VECTOR`` expression in mode :samp:`{mode}`. Similarly, the macro +``CONST1_RTX (mode)`` refers to an expression with value 1 in +mode :samp:`{mode}` and similarly for ``CONST2_RTX``. The +``CONST1_RTX`` and ``CONST2_RTX`` macros are undefined +for vector modes. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/conversions.rst b/gcc/doc/gccint/rtl-representation/conversions.rst new file mode 100644 index 00000000000..f279a0c99ed --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/conversions.rst @@ -0,0 +1,152 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: conversions, machine mode conversions + +.. _conversions: + +Conversions +*********** + +All conversions between machine modes must be represented by +explicit conversion operations. For example, an expression +which is the sum of a byte and a full word cannot be written as +``(plus:SI (reg:QI 34) (reg:SI 80))`` because the ``plus`` +operation requires two operands of the same machine mode. +Therefore, the byte-sized operand is enclosed in a conversion +operation, as in + +.. code-block:: c++ + + (plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80)) + +The conversion operation is not a mere placeholder, because there +may be more than one way of converting from a given starting mode +to the desired final mode. The conversion operation code says how +to do it. + +For all conversion operations, :samp:`{x}` must not be ``VOIDmode`` +because the mode in which to do the conversion would not be known. +The conversion must either be done at compile-time or :samp:`{x}` +must be placed into a register. + +.. index:: sign_extend + +:samp:`(sign_extend:{m} {x})` + Represents the result of sign-extending the value :samp:`{x}` + to machine mode :samp:`{m}`. :samp:`{m}` must be a fixed-point mode + and :samp:`{x}` a fixed-point value of a mode narrower than :samp:`{m}`. + + .. index:: zero_extend + +:samp:`(zero_extend:{m} {x})` + Represents the result of zero-extending the value :samp:`{x}` + to machine mode :samp:`{m}`. :samp:`{m}` must be a fixed-point mode + and :samp:`{x}` a fixed-point value of a mode narrower than :samp:`{m}`. + + .. index:: float_extend + +:samp:`(float_extend:{m} {x})` + Represents the result of extending the value :samp:`{x}` + to machine mode :samp:`{m}`. :samp:`{m}` must be a floating point mode + and :samp:`{x}` a floating point value of a mode narrower than :samp:`{m}`. + + .. index:: truncate + +:samp:`(truncate:{m} {x})` + Represents the result of truncating the value :samp:`{x}` + to machine mode :samp:`{m}`. :samp:`{m}` must be a fixed-point mode + and :samp:`{x}` a fixed-point value of a mode wider than :samp:`{m}`. + + .. index:: ss_truncate + +:samp:`(ss_truncate:{m} {x})` + Represents the result of truncating the value :samp:`{x}` + to machine mode :samp:`{m}`, using signed saturation in the case of + overflow. Both :samp:`{m}` and the mode of :samp:`{x}` must be fixed-point + modes. + + .. index:: us_truncate + +:samp:`(us_truncate:{m} {x})` + Represents the result of truncating the value :samp:`{x}` + to machine mode :samp:`{m}`, using unsigned saturation in the case of + overflow. Both :samp:`{m}` and the mode of :samp:`{x}` must be fixed-point + modes. + + .. index:: float_truncate + +:samp:`(float_truncate:{m} {x})` + Represents the result of truncating the value :samp:`{x}` + to machine mode :samp:`{m}`. :samp:`{m}` must be a floating point mode + and :samp:`{x}` a floating point value of a mode wider than :samp:`{m}`. + + .. index:: float + +:samp:`(float:{m} {x})` + Represents the result of converting fixed point value :samp:`{x}`, + regarded as signed, to floating point mode :samp:`{m}`. + + .. index:: unsigned_float + +:samp:`(unsigned_float:{m} {x})` + Represents the result of converting fixed point value :samp:`{x}`, + regarded as unsigned, to floating point mode :samp:`{m}`. + + .. index:: fix + +:samp:`(fix:{m} {x})` + When :samp:`{m}` is a floating-point mode, represents the result of + converting floating point value :samp:`{x}` (valid for mode :samp:`{m}`) to an + integer, still represented in floating point mode :samp:`{m}`, by rounding + towards zero. + + When :samp:`{m}` is a fixed-point mode, represents the result of + converting floating point value :samp:`{x}` to mode :samp:`{m}`, regarded as + signed. How rounding is done is not specified, so this operation may + be used validly in compiling C code only for integer-valued operands. + + .. index:: unsigned_fix + +:samp:`(unsigned_fix:{m} {x})` + Represents the result of converting floating point value :samp:`{x}` to + fixed point mode :samp:`{m}`, regarded as unsigned. How rounding is done + is not specified. + + .. index:: fract_convert + +:samp:`(fract_convert:{m} {x})` + Represents the result of converting fixed-point value :samp:`{x}` to + fixed-point mode :samp:`{m}`, signed integer value :samp:`{x}` to + fixed-point mode :samp:`{m}`, floating-point value :samp:`{x}` to + fixed-point mode :samp:`{m}`, fixed-point value :samp:`{x}` to integer mode :samp:`{m}` + regarded as signed, or fixed-point value :samp:`{x}` to floating-point mode :samp:`{m}`. + When overflows or underflows happen, the results are undefined. + + .. index:: sat_fract + +:samp:`(sat_fract:{m} {x})` + Represents the result of converting fixed-point value :samp:`{x}` to + fixed-point mode :samp:`{m}`, signed integer value :samp:`{x}` to + fixed-point mode :samp:`{m}`, or floating-point value :samp:`{x}` to + fixed-point mode :samp:`{m}`. + When overflows or underflows happen, the results are saturated to the + maximum or the minimum. + + .. index:: unsigned_fract_convert + +:samp:`(unsigned_fract_convert:{m} {x})` + Represents the result of converting fixed-point value :samp:`{x}` to + integer mode :samp:`{m}` regarded as unsigned, or unsigned integer value :samp:`{x}` to + fixed-point mode :samp:`{m}`. + When overflows or underflows happen, the results are undefined. + + .. index:: unsigned_sat_fract + +:samp:`(unsigned_sat_fract:{m} {x})` + Represents the result of converting unsigned integer value :samp:`{x}` to + fixed-point mode :samp:`{m}`. + When overflows or underflows happen, the results are saturated to the + maximum or the minimum. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/declarations.rst b/gcc/doc/gccint/rtl-representation/declarations.rst new file mode 100644 index 00000000000..77b477a0028 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/declarations.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RTL declarations, declarations, RTL + +.. _rtl-declarations: + +Declarations +************ + +Declaration expression codes do not represent arithmetic operations +but rather state assertions about their operands. + +.. index:: strict_low_part, subreg, in strict_low_part + +:samp:`(strict_low_part (subreg:{m} (reg:{n} {r}) 0))` + This expression code is used in only one context: as the destination operand of a + ``set`` expression. In addition, the operand of this expression + must be a non-paradoxical ``subreg`` expression. + + The presence of ``strict_low_part`` says that the part of the + register which is meaningful in mode :samp:`{n}`, but is not part of + mode :samp:`{m}`, is not to be altered. Normally, an assignment to such + a subreg is allowed to have undefined effects on the rest of the + register when :samp:`{m}` is smaller than :samp:`REGMODE_NATURAL_SIZE ({n})`. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/embedded-side-effects-on-addresses.rst b/gcc/doc/gccint/rtl-representation/embedded-side-effects-on-addresses.rst new file mode 100644 index 00000000000..663bbfb198a --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/embedded-side-effects-on-addresses.rst @@ -0,0 +1,100 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RTL preincrement, RTL postincrement, RTL predecrement, RTL postdecrement + +.. _incdec: + +Embedded Side-Effects on Addresses +********************************** + +Six special side-effect expression codes appear as memory addresses. + +.. index:: pre_dec + +:samp:`(pre_dec:{m} {x})` + Represents the side effect of decrementing :samp:`{x}` by a standard + amount and represents also the value that :samp:`{x}` has after being + decremented. :samp:`{x}` must be a ``reg`` or ``mem``, but most + machines allow only a ``reg``. :samp:`{m}` must be the machine mode + for pointers on the machine in use. The amount :samp:`{x}` is decremented + by is the length in bytes of the machine mode of the containing memory + reference of which this expression serves as the address. Here is an + example of its use: + + .. code-block:: c++ + + (mem:DF (pre_dec:SI (reg:SI 39))) + + This says to decrement pseudo register 39 by the length of a ``DFmode`` + value and use the result to address a ``DFmode`` value. + + .. index:: pre_inc + +:samp:`(pre_inc:{m} {x})` + Similar, but specifies incrementing :samp:`{x}` instead of decrementing it. + + .. index:: post_dec + +:samp:`(post_dec:{m} {x})` + Represents the same side effect as ``pre_dec`` but a different + value. The value represented here is the value :samp:`{x}` has before + being decremented. + + .. index:: post_inc + +:samp:`(post_inc:{m} {x})` + Similar, but specifies incrementing :samp:`{x}` instead of decrementing it. + + .. index:: post_modify + +:samp:`(post_modify:{m} {x} {y})` + Represents the side effect of setting :samp:`{x}` to :samp:`{y}` and + represents :samp:`{x}` before :samp:`{x}` is modified. :samp:`{x}` must be a + ``reg`` or ``mem``, but most machines allow only a ``reg``. + :samp:`{m}` must be the machine mode for pointers on the machine in use. + + The expression :samp:`{y}` must be one of three forms: + ``(plus:mxz)``, + ``(minus:mxz)``, or + ``(plus:mxi)``, + where :samp:`{z}` is an index register and :samp:`{i}` is a constant. + + Here is an example of its use: + + .. code-block:: c++ + + (mem:SF (post_modify:SI (reg:SI 42) (plus (reg:SI 42) + (reg:SI 48)))) + + This says to modify pseudo register 42 by adding the contents of pseudo + register 48 to it, after the use of what ever 42 points to. + + .. index:: pre_modify + +:samp:`(pre_modify:{m} {x} {expr})` + Similar except side effects happen before the use. + +These embedded side effect expressions must be used with care. Instruction +patterns may not use them. Until the :samp:`flow` pass of the compiler, +they may occur only to represent pushes onto the stack. The :samp:`flow` +pass finds cases where registers are incremented or decremented in one +instruction and used as an address shortly before or after; these cases are +then transformed to use pre- or post-increment or -decrement. + +If a register used as the operand of these expressions is used in +another address in an insn, the original value of the register is used. +Uses of the register outside of an address are not permitted within the +same insn as a use in an embedded side effect expression because such +insns behave differently on different machines and hence must be treated +as ambiguous and disallowed. + +An instruction that can be represented with an embedded side effect +could also be represented using ``parallel`` containing an additional +``set`` to describe how the address register is altered. This is not +done because machines that allow these operations at all typically +allow them wherever a memory address is called for. Describing them as +additional parallel stores would require doubling the number of entries +in the machine description. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/flags-in-an-rtl-expression.rst b/gcc/doc/gccint/rtl-representation/flags-in-an-rtl-expression.rst new file mode 100644 index 00000000000..4692acaac88 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/flags-in-an-rtl-expression.rst @@ -0,0 +1,447 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: flags in RTL expression + +.. _flags: + +Flags in an RTL Expression +************************** + +RTL expressions contain several flags (one-bit bit-fields) +that are used in certain types of expression. Most often they +are accessed with the following macros, which expand into lvalues. + +.. index:: CROSSING_JUMP_P, jump_insn and /j + +:samp:`CROSSING_JUMP_P ({x})` + Nonzero in a ``jump_insn`` if it crosses between hot and cold sections, + which could potentially be very far apart in the executable. The presence + of this flag indicates to other optimizations that this branching instruction + should not be 'collapsed' into a simpler branching construct. It is used + when the optimization to partition basic blocks into hot and cold sections + is turned on. + + .. index:: CONSTANT_POOL_ADDRESS_P, symbol_ref and /u, unchanging, in symbol_ref + +:samp:`CONSTANT_POOL_ADDRESS_P ({x})` + Nonzero in a ``symbol_ref`` if it refers to part of the current + function's constant pool. For most targets these addresses are in a + ``.rodata`` section entirely separate from the function, but for + some targets the addresses are close to the beginning of the function. + In either case GCC assumes these addresses can be addressed directly, + perhaps with the help of base registers. + Stored in the ``unchanging`` field and printed as :samp:`/u`. + + .. index:: INSN_ANNULLED_BRANCH_P, jump_insn and /u, call_insn and /u, insn and /u, unchanging, in jump_insn, call_insn and insn + +:samp:`INSN_ANNULLED_BRANCH_P ({x})` + In a ``jump_insn``, ``call_insn``, or ``insn`` indicates + that the branch is an annulling one. See the discussion under + ``sequence`` below. Stored in the ``unchanging`` field and + printed as :samp:`/u`. + + .. index:: INSN_DELETED_P, insn and /v, call_insn and /v, jump_insn and /v, code_label and /v, jump_table_data and /v, barrier and /v, note and /v, volatil, in insn, call_insn, jump_insn, code_label, jump_table_data, barrier, and note + +:samp:`INSN_DELETED_P ({x})` + In an ``insn``, ``call_insn``, ``jump_insn``, ``code_label``, + ``jump_table_data``, ``barrier``, or ``note``, + nonzero if the insn has been deleted. Stored in the + ``volatil`` field and printed as :samp:`/v`. + + .. index:: INSN_FROM_TARGET_P, insn and /s, jump_insn and /s, call_insn and /s, in_struct, in insn and jump_insn and call_insn + +:samp:`INSN_FROM_TARGET_P ({x})` + In an ``insn`` or ``jump_insn`` or ``call_insn`` in a delay + slot of a branch, indicates that the insn + is from the target of the branch. If the branch insn has + ``INSN_ANNULLED_BRANCH_P`` set, this insn will only be executed if + the branch is taken. For annulled branches with + ``INSN_FROM_TARGET_P`` clear, the insn will be executed only if the + branch is not taken. When ``INSN_ANNULLED_BRANCH_P`` is not set, + this insn will always be executed. Stored in the ``in_struct`` + field and printed as :samp:`/s`. + + .. index:: LABEL_PRESERVE_P, code_label and /i, note and /i, in_struct, in code_label and note + +:samp:`LABEL_PRESERVE_P ({x})` + In a ``code_label`` or ``note``, indicates that the label is referenced by + code or data not visible to the RTL of a given function. + Labels referenced by a non-local goto will have this bit set. Stored + in the ``in_struct`` field and printed as :samp:`/s`. + + .. index:: LABEL_REF_NONLOCAL_P, label_ref and /v, reg_label and /v, volatil, in label_ref and reg_label + +:samp:`LABEL_REF_NONLOCAL_P ({x})` + In ``label_ref`` and ``reg_label`` expressions, nonzero if this is + a reference to a non-local label. + Stored in the ``volatil`` field and printed as :samp:`/v`. + + .. index:: MEM_KEEP_ALIAS_SET_P, mem and /j, jump, in mem + +:samp:`MEM_KEEP_ALIAS_SET_P ({x})` + In ``mem`` expressions, 1 if we should keep the alias set for this + mem unchanged when we access a component. Set to 1, for example, when we + are already in a non-addressable component of an aggregate. + Stored in the ``jump`` field and printed as :samp:`/j`. + + .. index:: MEM_VOLATILE_P, mem and /v, asm_input and /v, asm_operands and /v, volatil, in mem, asm_operands, and asm_input + +:samp:`MEM_VOLATILE_P ({x})` + In ``mem``, ``asm_operands``, and ``asm_input`` expressions, + nonzero for volatile memory references. + Stored in the ``volatil`` field and printed as :samp:`/v`. + + .. index:: MEM_NOTRAP_P, mem and /c, call, in mem + +:samp:`MEM_NOTRAP_P ({x})` + In ``mem``, nonzero for memory references that will not trap. + Stored in the ``call`` field and printed as :samp:`/c`. + + .. index:: MEM_POINTER, mem and /f, frame_related, in mem + +:samp:`MEM_POINTER ({x})` + Nonzero in a ``mem`` if the memory reference holds a pointer. + Stored in the ``frame_related`` field and printed as :samp:`/f`. + + .. index:: MEM_READONLY_P, mem and /u, unchanging, in mem + +:samp:`MEM_READONLY_P ({x})` + Nonzero in a ``mem``, if the memory is statically allocated and read-only. + + Read-only in this context means never modified during the lifetime of the + program, not necessarily in ROM or in write-disabled pages. A common + example of the later is a shared library's global offset table. This + table is initialized by the runtime loader, so the memory is technically + writable, but after control is transferred from the runtime loader to the + application, this memory will never be subsequently modified. + + Stored in the ``unchanging`` field and printed as :samp:`/u`. + + .. index:: PREFETCH_SCHEDULE_BARRIER_P, prefetch and /v, volatile, in prefetch + +:samp:`PREFETCH_SCHEDULE_BARRIER_P ({x})` + In a ``prefetch``, indicates that the prefetch is a scheduling barrier. + No other INSNs will be moved over it. + Stored in the ``volatil`` field and printed as :samp:`/v`. + + .. index:: REG_FUNCTION_VALUE_P, reg and /i, return_val, in reg + +:samp:`REG_FUNCTION_VALUE_P ({x})` + Nonzero in a ``reg`` if it is the place in which this function's + value is going to be returned. (This happens only in a hard + register.) Stored in the ``return_val`` field and printed as + :samp:`/i`. + + .. index:: REG_POINTER, reg and /f, frame_related, in reg + +:samp:`REG_POINTER ({x})` + Nonzero in a ``reg`` if the register holds a pointer. Stored in the + ``frame_related`` field and printed as :samp:`/f`. + + .. index:: REG_USERVAR_P, reg and /v, volatil, in reg + +:samp:`REG_USERVAR_P ({x})` + In a ``reg``, nonzero if it corresponds to a variable present in + the user's source code. Zero for temporaries generated internally by + the compiler. Stored in the ``volatil`` field and printed as + :samp:`/v`. + + The same hard register may be used also for collecting the values of + functions called by this one, but ``REG_FUNCTION_VALUE_P`` is zero + in this kind of use. + + .. index:: RTL_CONST_CALL_P, call_insn and /u, unchanging, in call_insn + +:samp:`RTL_CONST_CALL_P ({x})` + In a ``call_insn`` indicates that the insn represents a call to a + const function. Stored in the ``unchanging`` field and printed as + :samp:`/u`. + + .. index:: RTL_PURE_CALL_P, call_insn and /i, return_val, in call_insn + +:samp:`RTL_PURE_CALL_P ({x})` + In a ``call_insn`` indicates that the insn represents a call to a + pure function. Stored in the ``return_val`` field and printed as + :samp:`/i`. + + .. index:: RTL_CONST_OR_PURE_CALL_P, call_insn and /u or /i + +:samp:`RTL_CONST_OR_PURE_CALL_P ({x})` + In a ``call_insn``, true if ``RTL_CONST_CALL_P`` or + ``RTL_PURE_CALL_P`` is true. + + .. index:: RTL_LOOPING_CONST_OR_PURE_CALL_P, call_insn and /c, call, in call_insn + +:samp:`RTL_LOOPING_CONST_OR_PURE_CALL_P ({x})` + In a ``call_insn`` indicates that the insn represents a possibly + infinite looping call to a const or pure function. Stored in the + ``call`` field and printed as :samp:`/c`. Only true if one of + ``RTL_CONST_CALL_P`` or ``RTL_PURE_CALL_P`` is true. + + .. index:: RTX_FRAME_RELATED_P, insn and /f, call_insn and /f, jump_insn and /f, barrier and /f, set and /f, frame_related, in insn, call_insn, jump_insn, barrier, and set + +:samp:`RTX_FRAME_RELATED_P ({x})` + Nonzero in an ``insn``, ``call_insn``, ``jump_insn``, + ``barrier``, or ``set`` which is part of a function prologue + and sets the stack pointer, sets the frame pointer, or saves a register. + This flag should also be set on an instruction that sets up a temporary + register to use in place of the frame pointer. + Stored in the ``frame_related`` field and printed as :samp:`/f`. + + In particular, on RISC targets where there are limits on the sizes of + immediate constants, it is sometimes impossible to reach the register + save area directly from the stack pointer. In that case, a temporary + register is used that is near enough to the register save area, and the + Canonical Frame Address, i.e., DWARF2's logical frame pointer, register + must (temporarily) be changed to be this temporary register. So, the + instruction that sets this temporary register must be marked as + ``RTX_FRAME_RELATED_P``. + + If the marked instruction is overly complex (defined in terms of what + ``dwarf2out_frame_debug_expr`` can handle), you will also have to + create a ``REG_FRAME_RELATED_EXPR`` note and attach it to the + instruction. This note should contain a simple expression of the + computation performed by this instruction, i.e., one that + ``dwarf2out_frame_debug_expr`` can handle. + + This flag is required for exception handling support on targets with RTL + prologues. + + .. index:: SCHED_GROUP_P, insn and /s, call_insn and /s, jump_insn and /s, jump_table_data and /s, in_struct, in insn, call_insn, jump_insn and jump_table_data + +:samp:`SCHED_GROUP_P ({x})` + During instruction scheduling, in an ``insn``, ``call_insn``, + ``jump_insn`` or ``jump_table_data``, indicates that the + previous insn must be scheduled together with this insn. This is used to + ensure that certain groups of instructions will not be split up by the + instruction scheduling pass, for example, ``use`` insns before + a ``call_insn`` may not be separated from the ``call_insn``. + Stored in the ``in_struct`` field and printed as :samp:`/s`. + + .. index:: SET_IS_RETURN_P, insn and /j, jump, in insn + +:samp:`SET_IS_RETURN_P ({x})` + For a ``set``, nonzero if it is for a return. + Stored in the ``jump`` field and printed as :samp:`/j`. + + .. index:: SIBLING_CALL_P, call_insn and /j, jump, in call_insn + +:samp:`SIBLING_CALL_P ({x})` + For a ``call_insn``, nonzero if the insn is a sibling call. + Stored in the ``jump`` field and printed as :samp:`/j`. + + .. index:: STRING_POOL_ADDRESS_P, symbol_ref and /f, frame_related, in symbol_ref + +:samp:`STRING_POOL_ADDRESS_P ({x})` + For a ``symbol_ref`` expression, nonzero if it addresses this function's + string constant pool. + Stored in the ``frame_related`` field and printed as :samp:`/f`. + + .. index:: SUBREG_PROMOTED_UNSIGNED_P, subreg and /u and /v, unchanging, in subreg, volatil, in subreg + +:samp:`SUBREG_PROMOTED_UNSIGNED_P ({x})` + Returns a value greater then zero for a ``subreg`` that has + ``SUBREG_PROMOTED_VAR_P`` nonzero if the object being referenced is kept + zero-extended, zero if it is kept sign-extended, and less then zero if it is + extended some other way via the ``ptr_extend`` instruction. + Stored in the ``unchanging`` + field and ``volatil`` field, printed as :samp:`/u` and :samp:`/v`. + This macro may only be used to get the value it may not be used to change + the value. Use ``SUBREG_PROMOTED_UNSIGNED_SET`` to change the value. + + .. index:: SUBREG_PROMOTED_UNSIGNED_SET, subreg and /u, unchanging, in subreg, volatil, in subreg + +:samp:`SUBREG_PROMOTED_UNSIGNED_SET ({x})` + Set the ``unchanging`` and ``volatil`` fields in a ``subreg`` + to reflect zero, sign, or other extension. If ``volatil`` is + zero, then ``unchanging`` as nonzero means zero extension and as + zero means sign extension. If ``volatil`` is nonzero then some + other type of extension was done via the ``ptr_extend`` instruction. + + .. index:: SUBREG_PROMOTED_VAR_P, subreg and /s, in_struct, in subreg + +:samp:`SUBREG_PROMOTED_VAR_P ({x})` + Nonzero in a ``subreg`` if it was made when accessing an object that + was promoted to a wider mode in accord with the ``PROMOTED_MODE`` machine + description macro (see :ref:`storage-layout`). In this case, the mode of + the ``subreg`` is the declared mode of the object and the mode of + ``SUBREG_REG`` is the mode of the register that holds the object. + Promoted variables are always either sign- or zero-extended to the wider + mode on every assignment. Stored in the ``in_struct`` field and + printed as :samp:`/s`. + + .. index:: SYMBOL_REF_USED, used, in symbol_ref + +:samp:`SYMBOL_REF_USED ({x})` + In a ``symbol_ref``, indicates that :samp:`{x}` has been used. This is + normally only used to ensure that :samp:`{x}` is only declared external + once. Stored in the ``used`` field. + + .. index:: SYMBOL_REF_WEAK, symbol_ref and /i, return_val, in symbol_ref + +:samp:`SYMBOL_REF_WEAK ({x})` + In a ``symbol_ref``, indicates that :samp:`{x}` has been declared weak. + Stored in the ``return_val`` field and printed as :samp:`/i`. + + .. index:: SYMBOL_REF_FLAG, symbol_ref and /v, volatil, in symbol_ref + +:samp:`SYMBOL_REF_FLAG ({x})` + In a ``symbol_ref``, this is used as a flag for machine-specific purposes. + Stored in the ``volatil`` field and printed as :samp:`/v`. + + Most uses of ``SYMBOL_REF_FLAG`` are historic and may be subsumed + by ``SYMBOL_REF_FLAGS``. Certainly use of ``SYMBOL_REF_FLAGS`` + is mandatory if the target requires more than one bit of storage. + + These are the fields to which the above macros refer: + +.. index:: call, /c in RTL dump + +``call`` + In a ``mem``, 1 means that the memory reference will not trap. + + In a ``call``, 1 means that this pure or const call may possibly + infinite loop. + + In an RTL dump, this flag is represented as :samp:`/c`. + + .. index:: frame_related, /f in RTL dump + +``frame_related`` + In an ``insn`` or ``set`` expression, 1 means that it is part of + a function prologue and sets the stack pointer, sets the frame pointer, + saves a register, or sets up a temporary register to use in place of the + frame pointer. + + In ``reg`` expressions, 1 means that the register holds a pointer. + + In ``mem`` expressions, 1 means that the memory reference holds a pointer. + + In ``symbol_ref`` expressions, 1 means that the reference addresses + this function's string constant pool. + + In an RTL dump, this flag is represented as :samp:`/f`. + + .. index:: in_struct, /s in RTL dump + +``in_struct`` + In ``reg`` expressions, it is 1 if the register has its entire life + contained within the test expression of some loop. + + In ``subreg`` expressions, 1 means that the ``subreg`` is accessing + an object that has had its mode promoted from a wider mode. + + In ``label_ref`` expressions, 1 means that the referenced label is + outside the innermost loop containing the insn in which the ``label_ref`` + was found. + + In ``code_label`` expressions, it is 1 if the label may never be deleted. + This is used for labels which are the target of non-local gotos. Such a + label that would have been deleted is replaced with a ``note`` of type + ``NOTE_INSN_DELETED_LABEL``. + + In an ``insn`` during dead-code elimination, 1 means that the insn is + dead code. + + In an ``insn`` or ``jump_insn`` during reorg for an insn in the + delay slot of a branch, + 1 means that this insn is from the target of the branch. + + In an ``insn`` during instruction scheduling, 1 means that this insn + must be scheduled as part of a group together with the previous insn. + + In an RTL dump, this flag is represented as :samp:`/s`. + + .. index:: return_val, /i in RTL dump + +``return_val`` + In ``reg`` expressions, 1 means the register contains + the value to be returned by the current function. On + machines that pass parameters in registers, the same register number + may be used for parameters as well, but this flag is not set on such + uses. + + In ``symbol_ref`` expressions, 1 means the referenced symbol is weak. + + In ``call`` expressions, 1 means the call is pure. + + In an RTL dump, this flag is represented as :samp:`/i`. + + .. index:: jump, /j in RTL dump + +``jump`` + In a ``mem`` expression, 1 means we should keep the alias set for this + mem unchanged when we access a component. + + In a ``set``, 1 means it is for a return. + + In a ``call_insn``, 1 means it is a sibling call. + + In a ``jump_insn``, 1 means it is a crossing jump. + + In an RTL dump, this flag is represented as :samp:`/j`. + + .. index:: unchanging, /u in RTL dump + +``unchanging`` + In ``reg`` and ``mem`` expressions, 1 means + that the value of the expression never changes. + + In ``subreg`` expressions, it is 1 if the ``subreg`` references an + unsigned object whose mode has been promoted to a wider mode. + + In an ``insn`` or ``jump_insn`` in the delay slot of a branch + instruction, 1 means an annulling branch should be used. + + In a ``symbol_ref`` expression, 1 means that this symbol addresses + something in the per-function constant pool. + + In a ``call_insn`` 1 means that this instruction is a call to a const + function. + + In an RTL dump, this flag is represented as :samp:`/u`. + + .. index:: used + +``used`` + This flag is used directly (without an access macro) at the end of RTL + generation for a function, to count the number of times an expression + appears in insns. Expressions that appear more than once are copied, + according to the rules for shared structure (see :ref:`sharing`). + + For a ``reg``, it is used directly (without an access macro) by the + leaf register renumbering code to ensure that each register is only + renumbered once. + + In a ``symbol_ref``, it indicates that an external declaration for + the symbol has already been written. + + .. index:: volatil, /v in RTL dump + +``volatil`` + + .. index:: volatile memory references + + In a ``mem``, ``asm_operands``, or ``asm_input`` + expression, it is 1 if the memory + reference is volatile. Volatile memory references may not be deleted, + reordered or combined. + + In a ``symbol_ref`` expression, it is used for machine-specific + purposes. + + In a ``reg`` expression, it is 1 if the value is a user-level variable. + 0 indicates an internal compiler temporary. + + In an ``insn``, 1 means the insn has been deleted. + + In ``label_ref`` and ``reg_label`` expressions, 1 means a reference + to a non-local label. + + In ``prefetch`` expressions, 1 means that the containing insn is a + scheduling barrier. + + In an RTL dump, this flag is represented as :samp:`/v`. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/insns.rst b/gcc/doc/gccint/rtl-representation/insns.rst new file mode 100644 index 00000000000..3b83d1eb6d9 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/insns.rst @@ -0,0 +1,624 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: insns + +.. _insns: + +Insns +***** + +The RTL representation of the code for a function is a doubly-linked +chain of objects called :dfn:`insns`. Insns are expressions with +special codes that are used for no other purpose. Some insns are +actual instructions; others represent dispatch tables for ``switch`` +statements; others represent labels to jump to or various sorts of +declarative information. + +In addition to its own specific data, each insn must have a unique +id-number that distinguishes it from all other insns in the current +function (after delayed branch scheduling, copies of an insn with the +same id-number may be present in multiple places in a function, but +these copies will always be identical and will only appear inside a +``sequence``), and chain pointers to the preceding and following +insns. These three fields occupy the same position in every insn, +independent of the expression code of the insn. They could be accessed +with ``XEXP`` and ``XINT``, but instead three special macros are +always used: + +.. index:: INSN_UID + +:samp:`INSN_UID ({i})` + Accesses the unique id of insn :samp:`{i}`. + + .. index:: PREV_INSN + +:samp:`PREV_INSN ({i})` + Accesses the chain pointer to the insn preceding :samp:`{i}`. + If :samp:`{i}` is the first insn, this is a null pointer. + + .. index:: NEXT_INSN + +:samp:`NEXT_INSN ({i})` + Accesses the chain pointer to the insn following :samp:`{i}`. + If :samp:`{i}` is the last insn, this is a null pointer. + +.. index:: get_insns, get_last_insn + +The first insn in the chain is obtained by calling ``get_insns`` ; the +last insn is the result of calling ``get_last_insn``. Within the +chain delimited by these insns, the ``NEXT_INSN`` and +``PREV_INSN`` pointers must always correspond: if :samp:`{insn}` is not +the first insn, + +.. code-block:: c++ + + NEXT_INSN (PREV_INSN (insn)) == insn + +is always true and if :samp:`{insn}` is not the last insn, + +.. code-block:: c++ + + PREV_INSN (NEXT_INSN (insn)) == insn + +is always true. + +After delay slot scheduling, some of the insns in the chain might be +``sequence`` expressions, which contain a vector of insns. The value +of ``NEXT_INSN`` in all but the last of these insns is the next insn +in the vector; the value of ``NEXT_INSN`` of the last insn in the vector +is the same as the value of ``NEXT_INSN`` for the ``sequence`` in +which it is contained. Similar rules apply for ``PREV_INSN``. + +This means that the above invariants are not necessarily true for insns +inside ``sequence`` expressions. Specifically, if :samp:`{insn}` is the +first insn in a ``sequence``, ``NEXT_INSN (PREV_INSN (insn))`` +is the insn containing the ``sequence`` expression, as is the value +of ``PREV_INSN (NEXT_INSN (insn))`` if :samp:`{insn}` is the last +insn in the ``sequence`` expression. You can use these expressions +to find the containing ``sequence`` expression. + +Every insn has one of the following expression codes: + +.. index:: insn + +``insn`` + The expression code ``insn`` is used for instructions that do not jump + and do not do function calls. ``sequence`` expressions are always + contained in insns with code ``insn`` even if one of those insns + should jump or do function calls. + + Insns with code ``insn`` have four additional fields beyond the three + mandatory ones listed above. These four are described in a table below. + + .. index:: jump_insn + +``jump_insn`` + The expression code ``jump_insn`` is used for instructions that may + jump (or, more generally, may contain ``label_ref`` expressions to + which ``pc`` can be set in that instruction). If there is an + instruction to return from the current function, it is recorded as a + ``jump_insn``. + + .. index:: JUMP_LABEL + + ``jump_insn`` insns have the same extra fields as ``insn`` insns, + accessed in the same way and in addition contain a field + ``JUMP_LABEL`` which is defined once jump optimization has completed. + + For simple conditional and unconditional jumps, this field contains + the ``code_label`` to which this insn will (possibly conditionally) + branch. In a more complex jump, ``JUMP_LABEL`` records one of the + labels that the insn refers to; other jump target labels are recorded + as ``REG_LABEL_TARGET`` notes. The exception is ``addr_vec`` + and ``addr_diff_vec``, where ``JUMP_LABEL`` is ``NULL_RTX`` + and the only way to find the labels is to scan the entire body of the + insn. + + Return insns count as jumps, but their ``JUMP_LABEL`` is ``RETURN`` + or ``SIMPLE_RETURN``. + + .. index:: call_insn + +``call_insn`` + The expression code ``call_insn`` is used for instructions that may do + function calls. It is important to distinguish these instructions because + they imply that certain registers and memory locations may be altered + unpredictably. + + .. index:: CALL_INSN_FUNCTION_USAGE + + ``call_insn`` insns have the same extra fields as ``insn`` insns, + accessed in the same way and in addition contain a field + ``CALL_INSN_FUNCTION_USAGE``, which contains a list (chain of + ``expr_list`` expressions) containing ``use``, ``clobber`` and + sometimes ``set`` expressions that denote hard registers and + ``mem`` s used or clobbered by the called function. + + A ``mem`` generally points to a stack slot in which arguments passed + to the libcall by reference (see :ref:`register-arguments`) are stored. If the argument is + caller-copied (see :ref:`register-arguments`), + the stack slot will be mentioned in ``clobber`` and ``use`` + entries; if it's callee-copied, only a ``use`` will appear, and the + ``mem`` may point to addresses that are not stack slots. + + Registers occurring inside a ``clobber`` in this list augment + registers specified in ``CALL_USED_REGISTERS`` (see :ref:`register-basics`). + + If the list contains a ``set`` involving two registers, it indicates + that the function returns one of its arguments. Such a ``set`` may + look like a no-op if the same register holds the argument and the return + value. + + .. index:: code_label, CODE_LABEL_NUMBER + +``code_label`` + A ``code_label`` insn represents a label that a jump insn can jump + to. It contains two special fields of data in addition to the three + standard ones. ``CODE_LABEL_NUMBER`` is used to hold the :dfn:`label + number`, a number that identifies this label uniquely among all the + labels in the compilation (not just in the current function). + Ultimately, the label is represented in the assembler output as an + assembler label, usually of the form :samp:`L{n}` where :samp:`{n}` is + the label number. + + When a ``code_label`` appears in an RTL expression, it normally + appears within a ``label_ref`` which represents the address of + the label, as a number. + + Besides as a ``code_label``, a label can also be represented as a + ``note`` of type ``NOTE_INSN_DELETED_LABEL``. + + .. index:: LABEL_NUSES + + The field ``LABEL_NUSES`` is only defined once the jump optimization + phase is completed. It contains the number of times this label is + referenced in the current function. + + .. index:: LABEL_KIND, SET_LABEL_KIND, LABEL_ALT_ENTRY_P, alternate entry points + + The field ``LABEL_KIND`` differentiates four different types of + labels: ``LABEL_NORMAL``, ``LABEL_STATIC_ENTRY``, + ``LABEL_GLOBAL_ENTRY``, and ``LABEL_WEAK_ENTRY``. The only labels + that do not have type ``LABEL_NORMAL`` are :dfn:`alternate entry + points` to the current function. These may be static (visible only in + the containing translation unit), global (exposed to all translation + units), or weak (global, but can be overridden by another symbol with the + same name). + + Much of the compiler treats all four kinds of label identically. Some + of it needs to know whether or not a label is an alternate entry point; + for this purpose, the macro ``LABEL_ALT_ENTRY_P`` is provided. It is + equivalent to testing whether :samp:`LABEL_KIND (label) == LABEL_NORMAL`. + The only place that cares about the distinction between static, global, + and weak alternate entry points, besides the front-end code that creates + them, is the function ``output_alternate_entry_point``, in + :samp:`final.cc`. + + To set the kind of a label, use the ``SET_LABEL_KIND`` macro. + + .. index:: jump_table_data + +``jump_table_data`` + A ``jump_table_data`` insn is a placeholder for the jump-table data + of a ``casesi`` or ``tablejump`` insn. They are placed after + a ``tablejump_p`` insn. A ``jump_table_data`` insn is not part o + a basic blockm but it is associated with the basic block that ends with + the ``tablejump_p`` insn. The ``PATTERN`` of a ``jump_table_data`` + is always either an ``addr_vec`` or an ``addr_diff_vec``, and a + ``jump_table_data`` insn is always preceded by a ``code_label``. + The ``tablejump_p`` insn refers to that ``code_label`` via its + ``JUMP_LABEL``. + + .. index:: barrier + +``barrier`` + Barriers are placed in the instruction stream when control cannot flow + past them. They are placed after unconditional jump instructions to + indicate that the jumps are unconditional and after calls to + ``volatile`` functions, which do not return (e.g., ``exit``). + They contain no information beyond the three standard fields. + + .. index:: note, NOTE_LINE_NUMBER, NOTE_SOURCE_FILE + +``note`` + ``note`` insns are used to represent additional debugging and + declarative information. They contain two nonstandard fields, an + integer which is accessed with the macro ``NOTE_LINE_NUMBER`` and a + string accessed with ``NOTE_SOURCE_FILE``. + + If ``NOTE_LINE_NUMBER`` is positive, the note represents the + position of a source line and ``NOTE_SOURCE_FILE`` is the source file name + that the line came from. These notes control generation of line + number data in the assembler output. + + Otherwise, ``NOTE_LINE_NUMBER`` is not really a line number but a + code with one of the following values (and ``NOTE_SOURCE_FILE`` + must contain a null pointer): + + .. index:: NOTE_INSN_DELETED + + .. envvar:: NOTE_INSN_DELETED + + Such a note is completely ignorable. Some passes of the compiler + delete insns by altering them into notes of this kind. + + .. envvar:: NOTE_INSN_DELETED_LABEL + + This marks what used to be a ``code_label``, but was not used for other + purposes than taking its address and was transformed to mark that no + code jumps to it. + + .. envvar:: NOTE_INSN_BLOCK_BEG + + These types of notes indicate the position of the beginning and end + of a level of scoping of variable names. They control the output + of debugging information. + + .. envvar:: NOTE_INSN_EH_REGION_BEG + + These types of notes indicate the position of the beginning and end of a + level of scoping for exception handling. ``NOTE_EH_HANDLER`` + identifies which region is associated with these notes. + + .. envvar:: NOTE_INSN_FUNCTION_BEG + + Appears at the start of the function body, after the function + prologue. + + .. envvar:: NOTE_INSN_VAR_LOCATION + + This note is used to generate variable location debugging information. + It indicates that the user variable in its ``VAR_LOCATION`` operand + is at the location given in the RTL expression, or holds a value that + can be computed by evaluating the RTL expression from that static + point in the program up to the next such note for the same user + variable. + + .. envvar:: NOTE_INSN_BEGIN_STMT + + This note is used to generate ``is_stmt`` markers in line number + debugging information. It indicates the beginning of a user + statement. + + .. envvar:: NOTE_INSN_INLINE_ENTRY + + This note is used to generate ``entry_pc`` for inlined subroutines in + debugging information. It indicates an inspection point at which all + arguments for the inlined function have been bound, and before its first + statement. + + These codes are printed symbolically when they appear in debugging dumps. + + .. index:: debug_insn, INSN_VAR_LOCATION + +``debug_insn`` + The expression code ``debug_insn`` is used for pseudo-instructions + that hold debugging information for variable tracking at assignments + (see :option:`-fvar-tracking-assignments` option). They are the RTL + representation of ``GIMPLE_DEBUG`` statements + (:ref:`GIMPLE_DEBUG`), with a ``VAR_LOCATION`` operand that + binds a user variable tree to an RTL representation of the + ``value`` in the corresponding statement. A ``DEBUG_EXPR`` in + it stands for the value bound to the corresponding + ``DEBUG_EXPR_DECL``. + + ``GIMPLE_DEBUG_BEGIN_STMT`` and ``GIMPLE_DEBUG_INLINE_ENTRY`` are + expanded to RTL as a ``DEBUG_INSN`` with a ``DEBUG_MARKER`` + ``PATTERN`` ; the difference is the RTL mode: the former's + ``DEBUG_MARKER`` is ``VOIDmode``, whereas the latter is + ``BLKmode`` ; information about the inlined function can be taken from + the lexical block encoded in the ``INSN_LOCATION``. These + ``DEBUG_INSN`` s, that do not carry ``VAR_LOCATION`` information, + just ``DEBUG_MARKER`` s, can be detected by testing + ``DEBUG_MARKER_INSN_P``, whereas those that do can be recognized as + ``DEBUG_BIND_INSN_P``. + + Throughout optimization passes, ``DEBUG_INSN`` s are not reordered + with respect to each other, particularly during scheduling. Binding + information is kept in pseudo-instruction form, so that, unlike notes, + it gets the same treatment and adjustments that regular instructions + would. It is the variable tracking pass that turns these + pseudo-instructions into ``NOTE_INSN_VAR_LOCATION``, + ``NOTE_INSN_BEGIN_STMT`` and ``NOTE_INSN_INLINE_ENTRY`` notes, + analyzing control flow, value equivalences and changes to registers and + memory referenced in value expressions, propagating the values of debug + temporaries and determining expressions that can be used to compute the + value of each user variable at as many points (ranges, actually) in the + program as possible. + + Unlike ``NOTE_INSN_VAR_LOCATION``, the value expression in an + ``INSN_VAR_LOCATION`` denotes a value at that specific point in the + program, rather than an expression that can be evaluated at any later + point before an overriding ``VAR_LOCATION`` is encountered. E.g., + if a user variable is bound to a ``REG`` and then a subsequent insn + modifies the ``REG``, the note location would keep mapping the user + variable to the register across the insn, whereas the insn location + would keep the variable bound to the value, so that the variable + tracking pass would emit another location note for the variable at the + point in which the register is modified. + +.. index:: TImode, in insn, HImode, in insn, QImode, in insn + +The machine mode of an insn is normally ``VOIDmode``, but some +phases use the mode for various purposes. + +The common subexpression elimination pass sets the mode of an insn to +``QImode`` when it is the first insn in a block that has already +been processed. + +The second Haifa scheduling pass, for targets that can multiple issue, +sets the mode of an insn to ``TImode`` when it is believed that the +instruction begins an issue group. That is, when the instruction +cannot issue simultaneously with the previous. This may be relied on +by later passes, in particular machine-dependent reorg. + +Here is a table of the extra fields of ``insn``, ``jump_insn`` +and ``call_insn`` insns: + +.. index:: PATTERN + +:samp:`PATTERN ({i})` + An expression for the side effect performed by this insn. This must + be one of the following codes: ``set``, ``call``, ``use``, + ``clobber``, ``return``, ``simple_return``, ``asm_input``, + ``asm_output``, ``addr_vec``, ``addr_diff_vec``, + ``trap_if``, ``unspec``, ``unspec_volatile``, + ``parallel``, ``cond_exec``, or ``sequence``. If it is a + ``parallel``, each element of the ``parallel`` must be one these + codes, except that ``parallel`` expressions cannot be nested and + ``addr_vec`` and ``addr_diff_vec`` are not permitted inside a + ``parallel`` expression. + + .. index:: INSN_CODE + +:samp:`INSN_CODE ({i})` + An integer that says which pattern in the machine description matches + this insn, or -1 if the matching has not yet been attempted. + + Such matching is never attempted and this field remains -1 on an insn + whose pattern consists of a single ``use``, ``clobber``, + ``asm_input``, ``addr_vec`` or ``addr_diff_vec`` expression. + + .. index:: asm_noperands + + Matching is also never attempted on insns that result from an ``asm`` + statement. These contain at least one ``asm_operands`` expression. + The function ``asm_noperands`` returns a non-negative value for + such insns. + + In the debugging output, this field is printed as a number followed by + a symbolic representation that locates the pattern in the :samp:`md` + file as some small positive or negative offset from a named pattern. + + .. index:: REG_NOTES + +:samp:`REG_NOTES ({i})` + A list (chain of ``expr_list``, ``insn_list`` and ``int_list`` + expressions) giving miscellaneous information about the insn. It is often + information pertaining to the registers used in this insn. + +The ``REG_NOTES`` field of an insn is a chain that includes +``expr_list`` and ``int_list`` expressions as well as ``insn_list`` +expressions. There are several +kinds of register notes, which are distinguished by the machine mode, which +in a register note is really understood as being an ``enum reg_note``. +The first operand :samp:`{op}` of the note is data whose meaning depends on +the kind of note. + +.. index:: REG_NOTE_KIND, PUT_REG_NOTE_KIND + +The macro ``REG_NOTE_KIND (x)`` returns the kind of +register note. Its counterpart, the macro ``PUT_REG_NOTE_KIND +(x, newkind)`` sets the register note type of :samp:`{x}` to be +:samp:`{newkind}`. + +Register notes are of three classes: They may say something about an +input to an insn, they may say something about an output of an insn, or +they may create a linkage between two insns. + +These register notes annotate inputs to an insn: + +.. index:: REG_DEAD + +.. envvar:: REG_DEAD + + The value in :samp:`{op}` dies in this insn; that is to say, altering the + value immediately after this insn would not affect the future behavior + of the program. + + It does not follow that the register :samp:`{op}` has no useful value after + this insn since :samp:`{op}` is not necessarily modified by this insn. + Rather, no subsequent instruction uses the contents of :samp:`{op}`. + +.. envvar:: REG_UNUSED + + The register :samp:`{op}` being set by this insn will not be used in a + subsequent insn. This differs from a ``REG_DEAD`` note, which + indicates that the value in an input will not be used subsequently. + These two notes are independent; both may be present for the same + register. + +.. envvar:: REG_INC + + The register :samp:`{op}` is incremented (or decremented; at this level + there is no distinction) by an embedded side effect inside this insn. + This means it appears in a ``post_inc``, ``pre_inc``, + ``post_dec`` or ``pre_dec`` expression. + +.. envvar:: REG_NONNEG + + The register :samp:`{op}` is known to have a nonnegative value when this + insn is reached. This is used by special looping instructions + that terminate when the register goes negative. + + The ``REG_NONNEG`` note is added only to :samp:`doloop_end` + insns, if its pattern uses a ``ge`` condition. + +.. envvar:: REG_LABEL_OPERAND + + This insn uses :samp:`{op}`, a ``code_label`` or a ``note`` of type + ``NOTE_INSN_DELETED_LABEL``, but is not a ``jump_insn``, or it + is a ``jump_insn`` that refers to the operand as an ordinary + operand. The label may still eventually be a jump target, but if so + in an indirect jump in a subsequent insn. The presence of this note + allows jump optimization to be aware that :samp:`{op}` is, in fact, being + used, and flow optimization to build an accurate flow graph. + +.. envvar:: REG_LABEL_TARGET + + This insn is a ``jump_insn`` but not an ``addr_vec`` or + ``addr_diff_vec``. It uses :samp:`{op}`, a ``code_label`` as a + direct or indirect jump target. Its purpose is similar to that of + ``REG_LABEL_OPERAND``. This note is only present if the insn has + multiple targets; the last label in the insn (in the highest numbered + insn-field) goes into the ``JUMP_LABEL`` field and does not have a + ``REG_LABEL_TARGET`` note. See :ref:`insns`. + +.. envvar:: REG_SETJMP + + Appears attached to each ``CALL_INSN`` to ``setjmp`` or a + related function. + +The following notes describe attributes of outputs of an insn: + +.. index:: REG_EQUIV, REG_EQUAL + +.. envvar:: REG_EQUIV + + This note is only valid on an insn that sets only one register and + indicates that that register will be equal to :samp:`{op}` at run time; the + scope of this equivalence differs between the two types of notes. The + value which the insn explicitly copies into the register may look + different from :samp:`{op}`, but they will be equal at run time. If the + output of the single ``set`` is a ``strict_low_part`` or + ``zero_extract`` expression, the note refers to the register that + is contained in its first operand. + + For ``REG_EQUIV``, the register is equivalent to :samp:`{op}` throughout + the entire function, and could validly be replaced in all its + occurrences by :samp:`{op}`. ('Validly' here refers to the data flow of + the program; simple replacement may make some insns invalid.) For + example, when a constant is loaded into a register that is never + assigned any other value, this kind of note is used. + + When a parameter is copied into a pseudo-register at entry to a function, + a note of this kind records that the register is equivalent to the stack + slot where the parameter was passed. Although in this case the register + may be set by other insns, it is still valid to replace the register + by the stack slot throughout the function. + + A ``REG_EQUIV`` note is also used on an instruction which copies a + register parameter into a pseudo-register at entry to a function, if + there is a stack slot where that parameter could be stored. Although + other insns may set the pseudo-register, it is valid for the compiler to + replace the pseudo-register by stack slot throughout the function, + provided the compiler ensures that the stack slot is properly + initialized by making the replacement in the initial copy instruction as + well. This is used on machines for which the calling convention + allocates stack space for register parameters. See + ``REG_PARM_STACK_SPACE`` in :ref:`stack-arguments`. + + In the case of ``REG_EQUAL``, the register that is set by this insn + will be equal to :samp:`{op}` at run time at the end of this insn but not + necessarily elsewhere in the function. In this case, :samp:`{op}` + is typically an arithmetic expression. For example, when a sequence of + insns such as a library call is used to perform an arithmetic operation, + this kind of note is attached to the insn that produces or copies the + final value. + + These two notes are used in different ways by the compiler passes. + ``REG_EQUAL`` is used by passes prior to register allocation (such as + common subexpression elimination and loop optimization) to tell them how + to think of that value. ``REG_EQUIV`` notes are used by register + allocation to indicate that there is an available substitute expression + (either a constant or a ``mem`` expression for the location of a + parameter on the stack) that may be used in place of a register if + insufficient registers are available. + + Except for stack homes for parameters, which are indicated by a + ``REG_EQUIV`` note and are not useful to the early optimization + passes and pseudo registers that are equivalent to a memory location + throughout their entire life, which is not detected until later in + the compilation, all equivalences are initially indicated by an attached + ``REG_EQUAL`` note. In the early stages of register allocation, a + ``REG_EQUAL`` note is changed into a ``REG_EQUIV`` note if + :samp:`{op}` is a constant and the insn represents the only set of its + destination register. + + Thus, compiler passes prior to register allocation need only check for + ``REG_EQUAL`` notes and passes subsequent to register allocation + need only check for ``REG_EQUIV`` notes. + +These notes describe linkages between insns. They occur in pairs: one +insn has one of a pair of notes that points to a second insn, which has +the inverse note pointing back to the first insn. + +.. index:: REG_DEP_TRUE + +.. envvar:: REG_DEP_TRUE + + This indicates a true dependence (a read after write dependence). + +.. envvar:: REG_DEP_OUTPUT + + This indicates an output dependence (a write after write dependence). + +.. envvar:: REG_DEP_ANTI + + This indicates an anti dependence (a write after read dependence). + +These notes describe information gathered from gcov profile data. They +are stored in the ``REG_NOTES`` field of an insn. + +.. index:: REG_BR_PROB + +.. envvar:: REG_BR_PROB + + This is used to specify the ratio of branches to non-branches of a + branch insn according to the profile data. The note is represented + as an ``int_list`` expression whose integer value is an encoding + of ``profile_probability`` type. ``profile_probability`` provide + member function ``from_reg_br_prob_note`` and ``to_reg_br_prob_note`` + to extract and store the probability into the RTL encoding. + +.. envvar:: REG_BR_PRED + + These notes are found in JUMP insns after delayed branch scheduling + has taken place. They indicate both the direction and the likelihood + of the JUMP. The format is a bitmask of ATTR_FLAG\_\* values. + +.. envvar:: REG_FRAME_RELATED_EXPR + + This is used on an RTX_FRAME_RELATED_P insn wherein the attached expression + is used in place of the actual insn pattern. This is done in cases where + the pattern is either complex or misleading. + +The note ``REG_CALL_NOCF_CHECK`` is used in conjunction with the +:option:`-fcf-protection=branch` option. The note is set if a +``nocf_check`` attribute is specified for a function type or a +pointer to function type. The note is stored in the ``REG_NOTES`` +field of an insn. + +.. index:: REG_CALL_NOCF_CHECK + +.. envvar:: REG_CALL_NOCF_CHECK + + Users have control through the ``nocf_check`` attribute to identify + which calls to a function should be skipped from control-flow instrumentation + when the option :option:`-fcf-protection=branch` is specified. The compiler + puts a ``REG_CALL_NOCF_CHECK`` note on each ``CALL_INSN`` instruction + that has a function type marked with a ``nocf_check`` attribute. + +For convenience, the machine mode in an ``insn_list`` or +``expr_list`` is printed using these symbolic codes in debugging dumps. + +.. index:: insn_list, expr_list + +The only difference between the expression codes ``insn_list`` and +``expr_list`` is that the first operand of an ``insn_list`` is +assumed to be an insn and is printed in debugging dumps as the insn's +unique id; the first operand of an ``expr_list`` is printed in the +ordinary way as an expression. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/machine-modes.rst b/gcc/doc/gccint/rtl-representation/machine-modes.rst new file mode 100644 index 00000000000..3355da0da89 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/machine-modes.rst @@ -0,0 +1,635 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: machine modes, machine_mode + +.. _machine-modes: + +Machine Modes +************* + +A machine mode describes a size of data object and the representation used +for it. In the C code, machine modes are represented by an enumeration +type, ``machine_mode``, defined in :samp:`machmode.def`. Each RTL +expression has room for a machine mode and so do certain kinds of tree +expressions (declarations and types, to be precise). + +In debugging dumps and machine descriptions, the machine mode of an RTL +expression is written after the expression code with a colon to separate +them. The letters :samp:`mode` which appear at the end of each machine mode +name are omitted. For example, ``(reg:SI 38)`` is a ``reg`` +expression with machine mode ``SImode``. If the mode is +``VOIDmode``, it is not written at all. + +Here is a table of machine modes. The term 'byte' below refers to an +object of ``BITS_PER_UNIT`` bits (see :ref:`storage-layout`). + +.. index:: BImode + +``BImode`` + 'Bit' mode represents a single bit, for predicate registers. + + .. index:: QImode + +``QImode`` + 'Quarter-Integer' mode represents a single byte treated as an integer. + + .. index:: HImode + +``HImode`` + 'Half-Integer' mode represents a two-byte integer. + + .. index:: PSImode + +``PSImode`` + 'Partial Single Integer' mode represents an integer which occupies + four bytes but which doesn't really use all four. On some machines, + this is the right mode to use for pointers. + + .. index:: SImode + +``SImode`` + 'Single Integer' mode represents a four-byte integer. + + .. index:: PDImode + +``PDImode`` + 'Partial Double Integer' mode represents an integer which occupies + eight bytes but which doesn't really use all eight. On some machines, + this is the right mode to use for certain pointers. + + .. index:: DImode + +``DImode`` + 'Double Integer' mode represents an eight-byte integer. + + .. index:: TImode + +``TImode`` + 'Tetra Integer' (?) mode represents a sixteen-byte integer. + + .. index:: OImode + +``OImode`` + 'Octa Integer' (?) mode represents a thirty-two-byte integer. + + .. index:: XImode + +``XImode`` + 'Hexadeca Integer' (?) mode represents a sixty-four-byte integer. + + .. index:: QFmode + +``QFmode`` + 'Quarter-Floating' mode represents a quarter-precision (single byte) + floating point number. + + .. index:: HFmode + +``HFmode`` + 'Half-Floating' mode represents a half-precision (two byte) floating + point number. + + .. index:: TQFmode + +``TQFmode`` + 'Three-Quarter-Floating' (?) mode represents a three-quarter-precision + (three byte) floating point number. + + .. index:: SFmode + +``SFmode`` + 'Single Floating' mode represents a four byte floating point number. + In the common case, of a processor with IEEE arithmetic and 8-bit bytes, + this is a single-precision IEEE floating point number; it can also be + used for double-precision (on processors with 16-bit bytes) and + single-precision VAX and IBM types. + + .. index:: DFmode + +``DFmode`` + 'Double Floating' mode represents an eight byte floating point number. + In the common case, of a processor with IEEE arithmetic and 8-bit bytes, + this is a double-precision IEEE floating point number. + + .. index:: XFmode + +``XFmode`` + 'Extended Floating' mode represents an IEEE extended floating point + number. This mode only has 80 meaningful bits (ten bytes). Some + processors require such numbers to be padded to twelve bytes, others + to sixteen; this mode is used for either. + + .. index:: SDmode + +``SDmode`` + 'Single Decimal Floating' mode represents a four byte decimal + floating point number (as distinct from conventional binary floating + point). + + .. index:: DDmode + +``DDmode`` + 'Double Decimal Floating' mode represents an eight byte decimal + floating point number. + + .. index:: TDmode + +``TDmode`` + 'Tetra Decimal Floating' mode represents a sixteen byte decimal + floating point number all 128 of whose bits are meaningful. + + .. index:: TFmode + +``TFmode`` + 'Tetra Floating' mode represents a sixteen byte floating point number + all 128 of whose bits are meaningful. One common use is the + IEEE quad-precision format. + + .. index:: QQmode + +``QQmode`` + 'Quarter-Fractional' mode represents a single byte treated as a signed + fractional number. The default format is 's.7'. + + .. index:: HQmode + +``HQmode`` + 'Half-Fractional' mode represents a two-byte signed fractional number. + The default format is 's.15'. + + .. index:: SQmode + +``SQmode`` + 'Single Fractional' mode represents a four-byte signed fractional number. + The default format is 's.31'. + + .. index:: DQmode + +``DQmode`` + 'Double Fractional' mode represents an eight-byte signed fractional number. + The default format is 's.63'. + + .. index:: TQmode + +``TQmode`` + 'Tetra Fractional' mode represents a sixteen-byte signed fractional number. + The default format is 's.127'. + + .. index:: UQQmode + +``UQQmode`` + 'Unsigned Quarter-Fractional' mode represents a single byte treated as an + unsigned fractional number. The default format is '.8'. + + .. index:: UHQmode + +``UHQmode`` + 'Unsigned Half-Fractional' mode represents a two-byte unsigned fractional + number. The default format is '.16'. + + .. index:: USQmode + +``USQmode`` + 'Unsigned Single Fractional' mode represents a four-byte unsigned fractional + number. The default format is '.32'. + + .. index:: UDQmode + +``UDQmode`` + 'Unsigned Double Fractional' mode represents an eight-byte unsigned + fractional number. The default format is '.64'. + + .. index:: UTQmode + +``UTQmode`` + 'Unsigned Tetra Fractional' mode represents a sixteen-byte unsigned + fractional number. The default format is '.128'. + + .. index:: HAmode + +``HAmode`` + 'Half-Accumulator' mode represents a two-byte signed accumulator. + The default format is 's8.7'. + + .. index:: SAmode + +``SAmode`` + 'Single Accumulator' mode represents a four-byte signed accumulator. + The default format is 's16.15'. + + .. index:: DAmode + +``DAmode`` + 'Double Accumulator' mode represents an eight-byte signed accumulator. + The default format is 's32.31'. + + .. index:: TAmode + +``TAmode`` + 'Tetra Accumulator' mode represents a sixteen-byte signed accumulator. + The default format is 's64.63'. + + .. index:: UHAmode + +``UHAmode`` + 'Unsigned Half-Accumulator' mode represents a two-byte unsigned accumulator. + The default format is '8.8'. + + .. index:: USAmode + +``USAmode`` + 'Unsigned Single Accumulator' mode represents a four-byte unsigned + accumulator. The default format is '16.16'. + + .. index:: UDAmode + +``UDAmode`` + 'Unsigned Double Accumulator' mode represents an eight-byte unsigned + accumulator. The default format is '32.32'. + + .. index:: UTAmode + +``UTAmode`` + 'Unsigned Tetra Accumulator' mode represents a sixteen-byte unsigned + accumulator. The default format is '64.64'. + + .. index:: CCmode + +``CCmode`` + 'Condition Code' mode represents the value of a condition code, which + is a machine-specific set of bits used to represent the result of a + comparison operation. Other machine-specific modes may also be used for + the condition code. (see :ref:`condition-code`). + + .. index:: BLKmode + +``BLKmode`` + 'Block' mode represents values that are aggregates to which none of + the other modes apply. In RTL, only memory references can have this mode, + and only if they appear in string-move or vector instructions. On machines + which have no such instructions, ``BLKmode`` will not appear in RTL. + + .. index:: VOIDmode + +``VOIDmode`` + Void mode means the absence of a mode or an unspecified mode. + For example, RTL expressions of code ``const_int`` have mode + ``VOIDmode`` because they can be taken to have whatever mode the context + requires. In debugging dumps of RTL, ``VOIDmode`` is expressed by + the absence of any mode. + + .. index:: QCmode, HCmode, SCmode, DCmode, XCmode, TCmode + +``QCmode, HCmode, SCmode, DCmode, XCmode, TCmode`` + These modes stand for a complex number represented as a pair of floating + point values. The floating point values are in ``QFmode``, + ``HFmode``, ``SFmode``, ``DFmode``, ``XFmode``, and + ``TFmode``, respectively. + + .. index:: CQImode, CHImode, CSImode, CDImode, CTImode, COImode, CPSImode + +``CQImode, CHImode, CSImode, CDImode, CTImode, COImode, CPSImode`` + These modes stand for a complex number represented as a pair of integer + values. The integer values are in ``QImode``, ``HImode``, + ``SImode``, ``DImode``, ``TImode``, ``OImode``, and ``PSImode``, + respectively. + + .. index:: BND32mode, BND64mode + +``BND32mode BND64mode`` + These modes stand for bounds for pointer of 32 and 64 bit size respectively. + Mode size is double pointer mode size. + +The machine description defines ``Pmode`` as a C macro which expands +into the machine mode used for addresses. Normally this is the mode +whose size is ``BITS_PER_WORD``, ``SImode`` on 32-bit machines. + +The only modes which a machine description must support are +``QImode``, and the modes corresponding to ``BITS_PER_WORD``, +``FLOAT_TYPE_SIZE`` and ``DOUBLE_TYPE_SIZE``. +The compiler will attempt to use ``DImode`` for 8-byte structures and +unions, but this can be prevented by overriding the definition of +``MAX_FIXED_MODE_SIZE``. Alternatively, you can have the compiler +use ``TImode`` for 16-byte structures and unions. Likewise, you can +arrange for the C type ``short int`` to avoid using ``HImode``. + +.. index:: mode classes + +Very few explicit references to machine modes remain in the compiler and +these few references will soon be removed. Instead, the machine modes +are divided into mode classes. These are represented by the enumeration +type ``enum mode_class`` defined in :samp:`machmode.h`. The possible +mode classes are: + +.. index:: MODE_INT + +.. envvar:: MODE_INT + + Integer modes. By default these are ``BImode``, ``QImode``, + ``HImode``, ``SImode``, ``DImode``, ``TImode``, and + ``OImode``. + +.. envvar:: MODE_PARTIAL_INT + + The 'partial integer' modes, ``PQImode``, ``PHImode``, + ``PSImode`` and ``PDImode``. + +.. envvar:: MODE_FLOAT + + Floating point modes. By default these are ``QFmode``, + ``HFmode``, ``TQFmode``, ``SFmode``, ``DFmode``, + ``XFmode`` and ``TFmode``. + +.. envvar:: MODE_DECIMAL_FLOAT + + Decimal floating point modes. By default these are ``SDmode``, + ``DDmode`` and ``TDmode``. + +.. envvar:: MODE_FRACT + + Signed fractional modes. By default these are ``QQmode``, ``HQmode``, + ``SQmode``, ``DQmode`` and ``TQmode``. + +.. envvar:: MODE_UFRACT + + Unsigned fractional modes. By default these are ``UQQmode``, ``UHQmode``, + ``USQmode``, ``UDQmode`` and ``UTQmode``. + +.. envvar:: MODE_ACCUM + + Signed accumulator modes. By default these are ``HAmode``, + ``SAmode``, ``DAmode`` and ``TAmode``. + +.. envvar:: MODE_UACCUM + + Unsigned accumulator modes. By default these are ``UHAmode``, + ``USAmode``, ``UDAmode`` and ``UTAmode``. + +.. envvar:: MODE_COMPLEX_INT + + Complex integer modes. (These are not currently implemented). + +.. envvar:: MODE_COMPLEX_FLOAT + + Complex floating point modes. By default these are ``QCmode``, + ``HCmode``, ``SCmode``, ``DCmode``, ``XCmode``, and + ``TCmode``. + +.. envvar:: MODE_CC + + Modes representing condition code values. These are ``CCmode`` plus + any ``CC_MODE`` modes listed in the :samp:`{machine}-modes.def`. + See :ref:`jump-patterns`, + also see :ref:`condition-code`. + +.. envvar:: MODE_POINTER_BOUNDS + + Pointer bounds modes. Used to represent values of pointer bounds type. + Operations in these modes may be executed as NOPs depending on hardware + features and environment setup. + +.. envvar:: MODE_OPAQUE + + This is a mode class for modes that don't want to provide operations + other than register moves, memory moves, loads, stores, and + ``unspec`` s. They have a size and precision and that's all. + +.. envvar:: MODE_RANDOM + + This is a catchall mode class for modes which don't fit into the above + classes. Currently ``VOIDmode`` and ``BLKmode`` are in + ``MODE_RANDOM``. + +.. index:: machine mode wrapper classes + +``machmode.h`` also defines various wrapper classes that combine a +``machine_mode`` with a static assertion that a particular +condition holds. The classes are: + +.. index:: scalar_int_mode + +``scalar_int_mode`` + A mode that has class ``MODE_INT`` or ``MODE_PARTIAL_INT``. + + .. index:: scalar_float_mode + +``scalar_float_mode`` + A mode that has class ``MODE_FLOAT`` or ``MODE_DECIMAL_FLOAT``. + + .. index:: scalar_mode + +``scalar_mode`` + A mode that holds a single numerical value. In practice this means + that the mode is a ``scalar_int_mode``, is a ``scalar_float_mode``, + or has class ``MODE_FRACT``, ``MODE_UFRACT``, ``MODE_ACCUM``, + ``MODE_UACCUM`` or ``MODE_POINTER_BOUNDS``. + + .. index:: complex_mode + +``complex_mode`` + A mode that has class ``MODE_COMPLEX_INT`` or ``MODE_COMPLEX_FLOAT``. + + .. index:: fixed_size_mode + +``fixed_size_mode`` + A mode whose size is known at compile time. + +Named modes use the most constrained of the available wrapper classes, +if one exists, otherwise they use ``machine_mode``. For example, +``QImode`` is a ``scalar_int_mode``, ``SFmode`` is a +``scalar_float_mode`` and ``BLKmode`` is a plain +``machine_mode``. It is possible to refer to any mode as a raw +``machine_mode`` by adding the ``E_`` prefix, where ``E`` +stands for 'enumeration'. For example, the raw ``machine_mode`` +names of the modes just mentioned are ``E_QImode``, ``E_SFmode`` +and ``E_BLKmode`` respectively. + +The wrapper classes implicitly convert to ``machine_mode`` and to any +wrapper class that represents a more general condition; for example +``scalar_int_mode`` and ``scalar_float_mode`` both convert +to ``scalar_mode`` and all three convert to ``fixed_size_mode``. +The classes act like ``machine_mode`` s that accept only certain +named modes. + +.. index:: opt_mode + +:samp:`machmode.h` also defines a template class ``opt_mode`` +that holds a ``T`` or nothing, where ``T`` can be either +``machine_mode`` or one of the wrapper classes above. The main +operations on an ``opt_mode`` :samp:`{x}` are as follows: + +:samp:`{x}.exists ()` + Return true if :samp:`{x}` holds a mode rather than nothing. + +:samp:`{x}.exists (&{y})` + Return true if :samp:`{x}` holds a mode rather than nothing, storing the + mode in :samp:`{y}` if so. :samp:`{y}` must be assignment-compatible with :samp:`{T}`. + +:samp:`{x}.require ()` + Assert that :samp:`{x}` holds a mode rather than nothing and return that mode. + +:samp:`{x} = {y}` + Set :samp:`{x}` to :samp:`{y}`, where :samp:`{y}` is a :samp:`{T}` or implicitly converts + to a :samp:`{T}`. + +The default constructor sets an ``opt_mode`` to nothing. +There is also a constructor that takes an initial value of type :samp:`{T}`. + +It is possible to use the :samp:`is-a.h` accessors on a ``machine_mode`` +or machine mode wrapper :samp:`{x}` : + +.. index:: is_a + +:samp:`is_a <{T}> ({x})` + Return true if :samp:`{x}` meets the conditions for wrapper class :samp:`{T}`. + +:samp:`is_a <{T}> ({x}, &{y})` + Return true if :samp:`{x}` meets the conditions for wrapper class :samp:`{T}`, + storing it in :samp:`{y}` if so. :samp:`{y}` must be assignment-compatible with + :samp:`{T}`. + +:samp:`as_a <{T}> ({x})` + Assert that :samp:`{x}` meets the conditions for wrapper class :samp:`{T}` + and return it as a :samp:`{T}`. + +:samp:`dyn_cast <{T}> ({x})` + Return an ``opt_mode`` that holds :samp:`{x}` if :samp:`{x}` meets + the conditions for wrapper class :samp:`{T}` and that holds nothing otherwise. + +The purpose of these wrapper classes is to give stronger static type +checking. For example, if a function takes a ``scalar_int_mode``, +a caller that has a general ``machine_mode`` must either check or +assert that the code is indeed a scalar integer first, using one of +the functions above. + +The wrapper classes are normal C++ classes, with user-defined +constructors. Sometimes it is useful to have a POD version of +the same type, particularly if the type appears in a ``union``. +The template class ``pod_mode`` provides a POD version +of wrapper class :samp:`{T}`. It is assignment-compatible with :samp:`{T}` +and implicitly converts to both ``machine_mode`` and :samp:`{T}`. + +Here are some C macros that relate to machine modes: + +.. index:: GET_MODE + +:samp:`GET_MODE ({x})` + Returns the machine mode of the RTX :samp:`{x}`. + + .. index:: PUT_MODE + +:samp:`PUT_MODE ({x}, {newmode})` + Alters the machine mode of the RTX :samp:`{x}` to be :samp:`{newmode}`. + + .. index:: NUM_MACHINE_MODES + +.. envvar:: NUM_MACHINE_MODES + + Stands for the number of machine modes available on the target + machine. This is one greater than the largest numeric value of any + machine mode. + +:samp:`GET_MODE_NAME ({m})` + Returns the name of mode :samp:`{m}` as a string. + + .. index:: GET_MODE_CLASS + +:samp:`GET_MODE_CLASS ({m})` + Returns the mode class of mode :samp:`{m}`. + + .. index:: GET_MODE_WIDER_MODE + +:samp:`GET_MODE_WIDER_MODE ({m})` + Returns the next wider natural mode. For example, the expression + ``GET_MODE_WIDER_MODE (QImode)`` returns ``HImode``. + + .. index:: GET_MODE_SIZE + +:samp:`GET_MODE_SIZE ({m})` + Returns the size in bytes of a datum of mode :samp:`{m}`. + + .. index:: GET_MODE_BITSIZE + +:samp:`GET_MODE_BITSIZE ({m})` + Returns the size in bits of a datum of mode :samp:`{m}`. + + .. index:: GET_MODE_IBIT + +:samp:`GET_MODE_IBIT ({m})` + Returns the number of integral bits of a datum of fixed-point mode :samp:`{m}`. + + .. index:: GET_MODE_FBIT + +:samp:`GET_MODE_FBIT ({m})` + Returns the number of fractional bits of a datum of fixed-point mode :samp:`{m}`. + + .. index:: GET_MODE_MASK + +:samp:`GET_MODE_MASK ({m})` + Returns a bitmask containing 1 for all bits in a word that fit within + mode :samp:`{m}`. This macro can only be used for modes whose bitsize is + less than or equal to ``HOST_BITS_PER_INT``. + + .. index:: GET_MODE_ALIGNMENT + +:samp:`GET_MODE_ALIGNMENT ({m})` + Return the required alignment, in bits, for an object of mode :samp:`{m}`. + + .. index:: GET_MODE_UNIT_SIZE + +:samp:`GET_MODE_UNIT_SIZE ({m})` + Returns the size in bytes of the subunits of a datum of mode :samp:`{m}`. + This is the same as ``GET_MODE_SIZE`` except in the case of complex + modes. For them, the unit size is the size of the real or imaginary + part. + + .. index:: GET_MODE_NUNITS + +:samp:`GET_MODE_NUNITS ({m})` + Returns the number of units contained in a mode, i.e., + ``GET_MODE_SIZE`` divided by ``GET_MODE_UNIT_SIZE``. + + .. index:: GET_CLASS_NARROWEST_MODE + +:samp:`GET_CLASS_NARROWEST_MODE ({c})` + Returns the narrowest mode in mode class :samp:`{c}`. + +The following 3 variables are defined on every target. They can be +used to allocate buffers that are guaranteed to be large enough to +hold any value that can be represented on the target. The first two +can be overridden by defining them in the target's mode.def file, +however, the value must be a constant that can determined very early +in the compilation process. The third symbol cannot be overridden. + +.. index:: BITS_PER_UNIT + +.. envvar:: BITS_PER_UNIT + + The number of bits in an addressable storage unit (byte). If you do + not define this, the default is 8. + +.. envvar:: MAX_BITSIZE_MODE_ANY_INT + + The maximum bitsize of any mode that is used in integer math. This + should be overridden by the target if it uses large integers as + containers for larger vectors but otherwise never uses the contents to + compute integer values. + +.. envvar:: MAX_BITSIZE_MODE_ANY_MODE + + The bitsize of the largest mode on the target. The default value is + the largest mode size given in the mode definition file, which is + always correct for targets whose modes have a fixed size. Targets + that might increase the size of a mode beyond this default should define + ``MAX_BITSIZE_MODE_ANY_MODE`` to the actual upper limit in + :samp:`{machine}-modes.def`. + +.. index:: byte_mode, word_mode + +The global variables ``byte_mode`` and ``word_mode`` contain modes +whose classes are ``MODE_INT`` and whose bitsizes are either +``BITS_PER_UNIT`` or ``BITS_PER_WORD``, respectively. On 32-bit +machines, these are ``QImode`` and ``SImode``, respectively. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/on-the-side-ssa-form-for-rtl.rst b/gcc/doc/gccint/rtl-representation/on-the-side-ssa-form-for-rtl.rst new file mode 100644 index 00000000000..f46b7030085 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/on-the-side-ssa-form-for-rtl.rst @@ -0,0 +1,748 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SSA, RTL form, RTL SSA + +.. _rtl-ssa: + +On-the-Side SSA Form for RTL +**************************** + +The patterns of an individual RTL instruction describe which registers +are inputs to that instruction and which registers are outputs from +that instruction. However, it is often useful to know where the +definition of a register input comes from and where the result of +a register output is used. One way of obtaining this information +is to use the RTL SSA form, which provides a Static Single Assignment +representation of the RTL instructions. + +The RTL SSA code is located in the :samp:`rtl-ssa` subdirectory of the GCC +source tree. This section only gives a brief overview of it; please +see the comments in the source code for more details. + +.. toctree:: + :maxdepth: 2 + + +.. _using-rtl-ssa: + +Using RTL SSA in a pass +^^^^^^^^^^^^^^^^^^^^^^^ + +A pass that wants to use the RTL SSA form should start with the following: + +.. code-block:: c++ + + #define INCLUDE_ALGORITHM + #define INCLUDE_FUNCTIONAL + #include "config.h" + #include "system.h" + #include "coretypes.h" + #include "backend.h" + #include "rtl.h" + #include "df.h" + #include "rtl-ssa.h" + +All the RTL SSA code is contained in the ``rtl_ssa`` namespace, +so most passes will then want to do: + +.. code-block:: c++ + + using namespace rtl_ssa; + +However, this is purely a matter of taste, and the examples in the rest of +this section do not require it. + +The RTL SSA represention is an optional on-the-side feature that applies +on top of the normal RTL instructions. It is currently local to individual +RTL passes and is not maintained across passes. + +However, in order to allow the RTL SSA information to be preserved across +passes in future, :samp:`crtl->ssa` points to the current function's +SSA form (if any). Passes that want to use the RTL SSA form should +first do: + +.. code-block:: c++ + + crtl->ssa = new rtl_ssa::function_info (fn); + +where :samp:`{fn}` is the function that the pass is processing. +(Passes that are ``using namespace rtl_ssa`` do not need +the :samp:`rtl_ssa::`.) + +Once the pass has finished with the SSA form, it should do the following: + +.. code-block:: c++ + + free_dominance_info (CDI_DOMINATORS); + if (crtl->ssa->perform_pending_updates ()) + cleanup_cfg (0); + + delete crtl->ssa; + crtl->ssa = nullptr; + +The ``free_dominance_info`` call is necessary because +dominance information is not currently maintained between RTL passes. +The next two lines commit any changes to the RTL instructions that +were queued for later; see the comment above the declaration of +``perform_pending_updates`` for details. The final two lines +discard the RTL SSA form and free the associated memory. + +.. index:: RPO, reverse postorder, instructions, RTL SSA, rtl_ssa::insn_info + +.. _rtl-ssa-instructions: + +RTL SSA Instructions +^^^^^^^^^^^^^^^^^^^^ + +RTL SSA instructions are represented by an ``rtl_ssa::insn_info``. +These instructions are chained together in a single list that follows +a reverse postorder (RPO) traversal of the function. This means that +if any path through the function can execute an instruction :samp:`{I1}` +and then later execute an instruction :samp:`{I2}` for the first time, +:samp:`{I1}` appears before :samp:`{I2}` in the list. +Note that this +order is different from the order of the underlying RTL instructions, +which follow machine code order instead. + +Two RTL SSA instructions can be compared to find which instruction +occurs earlier than the other in the RPO. One way to do this is +to use the C++ comparison operators, such as: + +.. code-block:: c++ + + *insn1 < *insn2 + +Another way is to use the ``compare_with`` function: + +.. code-block:: c++ + + insn1->compare_with (insn2) + +This expression is greater than zero if :samp:`{insn1}` comes after :samp:`{insn2}` +in the RPO, less than zero if :samp:`{insn1}` comes before :samp:`{insn2}` in the +RPO, or zero if :samp:`{insn1}` and :samp:`{insn2}` are the same. This order is +maintained even if instructions are added to the function or moved around. + +The main purpose of ``rtl_ssa::insn_info`` is to hold +SSA information about an instruction. However, it also caches +certain properties of the instruction, such as whether it is an +inline assembly instruction, whether it has volatile accesses, and so on. + +.. index:: basic blocks, RTL SSA, basic_block, rtl_ssa::bb_info + +.. _rtl-ssa-basic-blocks: + +RTL SSA Basic Blocks +^^^^^^^^^^^^^^^^^^^^ + +RTL SSA instructions (see :ref:`rtl-ssa-instructions`) are organized into +basic blocks, with each block being represented by an ``rtl_ssa:bb_info``. +There is a one-to-one mapping between these ``rtl_ssa:bb_info`` +structures and the underlying CFG ``basic_block`` structures +(see :ref:`basic-blocks`). + +.. index:: 'real' instructions, RTL SSA + +.. _real-rtl-ssa-insns: + +If a CFG basic block :samp:`{bb}` contains an RTL instruction :samp:`{insn}`, +the RTL SSA represenation of :samp:`{bb}` also contains an RTL SSA representation +of :samp:`{insn}`. +Note that this excludes non-instruction things like +``note`` s and ``barrier`` s that also appear in the chain of RTL +instructions. + +Within RTL SSA, these instructions are referred to as +'real' instructions. These real instructions fall into two groups: +debug instructions and nondebug instructions. Only nondebug instructions +should affect code generation decisions. + +In addition, each RTL SSA basic block has two 'artificial' +instructions: a 'head' instruction that comes before all the real +instructions and an 'end' instruction that comes after all real +instructions. These instructions exist to represent things that +are conceptually defined or used at the start and end of a basic block. +The instructions always exist, even if they do not currently do anything. + +Like instructions, these blocks are chained together in a reverse +postorder. This list includes the entry block (which always comes +first) and the exit block (which always comes last). + +.. index:: extended basic blocks, RTL SSA, rtl_ssa::ebb_info + +RTL SSA basic blocks are chained together into 'extended basic blocks' +(EBBs), represented by an ``rtl_ssa::ebb_info``. Extended basic +blocks contain one or more basic blocks. They have the property +that if a block :samp:`{bby}` comes immediately after a block :samp:`{bbx}` +in an EBB, then :samp:`{bby}` can only be reached by :samp:`{bbx}` ; in other words, +:samp:`{bbx}` is the sole predecessor of :samp:`{bby}`. + +Each extended basic block starts with an artificial 'phi node' +instruction. This instruction defines all phi nodes for the EBB +(see :ref:`rtl-ssa-phi-nodes`). (Individual blocks in an EBB do not +need phi nodes because their live values can only come from one source.) + +The contents of a function are therefore represented using a +four-level hierarchy: + +* functions (``rtl_ssa::function_info``), which contain ... + +* extended basic blocks (``rtl_ssa::ebb_info``), which contain ... + +* basic blocks (``rtl_ssa::bb_info``), which contain ... + +* instructions (``rtl_ssa::insn_info``) + +In dumps, a basic block is identified as ``bbn``, where :samp:`{n}` +is the index of the associated CFG ``basic_block`` structure. +An EBB is in turn identified by the index of its first block. +For example, an EBB that contains :samp:`bb10`, ``bb5``, ``bb6`` +and ``bb9`` is identified as :samp:`{ebb10}`. + +.. _rtl-ssa-resources: + +RTL SSA Resources +^^^^^^^^^^^^^^^^^ + +The RTL SSA form tracks two types of 'resource': registers and memory. +Each hard and pseudo register is a separate resource. Memory is a +single unified resource, like it is in GIMPLE (see :ref:`gimple`). + +Each resource has a unique identifier. The unique identifier for a +register is simply its register number. The unique identifier for +memory is a special register number called ``MEM_REGNO``. + +Since resource numbers so closely match register numbers, it is sometimes +convenient to refer to them simply as register numbers, or 'regnos' +for short. However, the RTL SSA form also provides an abstraction +of resources in the form of ``rtl_ssa::resource_info``. +This is a lightweight class that records both the regno of a resource +and the ``machine_mode`` that the resource has (see :ref:`machine-modes`). +It has functions for testing whether a resource is a register or memory. +In principle it could be extended to other kinds of resource in future. + +.. _rtl-ssa-accesses: + +RTL SSA Register and Memory Accesses +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In the RTL SSA form, most reads or writes of a resource are +represented as a ``rtl_ssa::access_info``. +The exceptions +are call clobbers, which are generally represented separately. +See the comment above ``rtl_ssa::insn_info`` for details. + +These ``rtl_ssa::access_info`` s are organized into the following +class hierarchy: + +.. index:: rtl_ssa::access_info, rtl_ssa::use_info, rtl_ssa::def_info, rtl_ssa::clobber_info, rtl_ssa::set_info, rtl_ssa::phi_info + +.. code-block:: c++ + + rtl_ssa::access_info + | + +-- rtl_ssa::use_info + | + +-- rtl_ssa::def_info + | + +-- rtl_ssa::clobber_info + | + +-- rtl_ssa::set_info + | + +-- rtl_ssa::phi_info + +A ``rtl_ssa::use_info`` represents a read or use of a resource and +a ``rtl_ssa::def_info`` represents a write or definition of a resource. +As in the main RTL representation, there are two basic types of +definition: clobbers and sets. The difference is that a clobber +leaves the register with an unspecified value that cannot be used +or relied on by later instructions, while a set leaves the register +with a known value that later instructions could use if they wanted to. +A ``rtl_ssa::clobber_info`` represents a clobber and +a ``rtl_ssa::set_info`` represent a set. + +Each ``rtl_ssa::use_info`` records which single ``rtl_ssa::set_info`` +provides the value of the resource; this is null if the resource is +completely undefined at the point of use. Each ``rtl_ssa::set_info`` +in turn records all the ``rtl_ssa::use_info`` s that use its value. + +If a value of a resource can come from multiple sources, +a ``rtl_ssa::phi_info`` brings those multiple sources together +into a single definition (see :ref:`rtl-ssa-phi-nodes`). + +.. index:: phi nodes, RTL SSA, rtl_ssa::phi_info + +.. _rtl-ssa-phi-nodes: + +RTL SSA Phi Nodes +^^^^^^^^^^^^^^^^^ + +If a resource is live on entry to an extended basic block and if the +resource's value can come from multiple sources, the extended basic block +has a 'phi node' that collects together these multiple sources. +The phi node conceptually has one input for each incoming edge of +the extended basic block, with the input specifying the value of +the resource on that edge. For example, suppose a function contains +the following RTL: + +.. code-block:: c++ + + ;; Basic block bb3 + ... + (set (reg:SI R1) (const_int 0)) ;; A + (set (pc) (label_ref bb5)) + + ;; Basic block bb4 + ... + (set (reg:SI R1) (const_int 1)) ;; B + ;; Fall through + + ;; Basic block bb5 + ;; preds: bb3, bb4 + ;; live in: R1 ... + (code_label bb5) + ... + (set (reg:SI R2) + (plus:SI (reg:SI R1) ...)) ;; C + +The value of R1 on entry to block 5 can come from either A or B. +The extended basic block that contains block 5 would therefore have a +phi node with two inputs: the first input would have the value of +R1 defined by A and the second input would have the value of +R1 defined by B. This phi node would then provide the value of +R1 for C (assuming that R1 does not change again between +the start of block 5 and C). + +Since RTL is not a 'native' SSA representation, these phi nodes +simply collect together definitions that already exist. Each input +to a phi node for a resource :samp:`{R}` is itself a definition of +resource :samp:`{R}` (or is null if the resource is completely +undefined for a particular incoming edge). This is in contrast +to a native SSA representation like GIMPLE, where the phi inputs +can be arbitrary expressions. As a result, RTL SSA phi nodes +never involve 'hidden' moves: all moves are instead explicit. + +Phi nodes are represented as a ``rtl_ssa::phi_node``. +Each input to a phi node is represented as an ``rtl_ssa::use_info``. + +.. _rtl-ssa-access-lists: + +RTL SSA Access Lists +^^^^^^^^^^^^^^^^^^^^ + +All the definitions of a resource are chained together in reverse postorder. +In general, this list can contain an arbitrary mix of both sets +(``rtl_ssa::set_info``) and clobbers (``rtl_ssa::clobber_info``). +However, it is often useful to skip over all intervening clobbers +of a resource in order to find the next set. The list is constructed +in such a way that this can be done in amortized constant time. + +All uses (``rtl_ssa::use_info``) of a given set are also chained +together into a list. This list of uses is divided into three parts: + +* uses by 'real' nondebug instructions (see :ref:`real-rtl-ssa-insns`) + +* uses by real debug instructions + +* uses by phi nodes (see :ref:`rtl-ssa-phi-nodes`) + +The first and second parts individually follow reverse postorder. +The third part has no particular order. + +.. index:: degenerate phi node, RTL SSA + +The last use by a real nondebug instruction always comes earlier in +the reverse postorder than the next definition of the resource (if any). +This means that the accesses follow a linear sequence of the form: + +* first definition of resource R + + * first use by a real nondebug instruction of the first definition of resource R + + * ... + + * last use by a real nondebug instruction of the first definition of resource R + +* second definition of resource R + + * first use by a real nondebug instruction of the second definition of resource R + + * ... + + * last use by a real nondebug instruction of the second definition of resource R + +* ... + +* last definition of resource R + + * first use by a real nondebug instruction of the last definition of resource R + + * ... + + * last use by a real nondebug instruction of the last definition of resource R + +(Note that clobbers never have uses; only sets do.) + +This linear view is easy to achieve when there is only a single definition +of a resource, which is commonly true for pseudo registers. However, +things are more complex if code has a structure like the following: + +.. code-block:: c++ + + // ebb2, bb2 + R = va; // A + if (...) + { + // ebb2, bb3 + use1 (R); // B + ... + R = vc; // C + } + else + { + // ebb4, bb4 + use2 (R); // D + } + +The list of accesses would begin as follows: + +* definition of R by A + + * use of A's definition of R by B + +* definition of R by C + +The next access to R is in D, but the value of R that D uses comes from +A rather than C. + +This is resolved by adding a phi node for ``ebb4``. All inputs to this +phi node have the same value, which in the example above is A's definition +of R. In other circumstances, it would not be necessary to create a phi +node when all inputs are equal, so these phi nodes are referred to as +'degenerate' phi nodes. + +The full list of accesses to R is therefore: + +* definition of R by A + + * use of A's definition of R by B + +* definition of R by C + +* definition of R by ebb4's phi instruction, with the input coming from A + + * use of the ebb4's R phi definition of R by B + +Note that A's definition is also used by ebb4's phi node, but this +use belongs to the third part of the use list described above and +so does not form part of the linear sequence. + +It is possible to 'look through' any degenerate phi to the ultimate +definition using the function ``look_through_degenerate_phi``. +Note that the input to a degenerate phi is never itself provided +by a degenerate phi. + +At present, the SSA form takes this principle one step further +and guarantees that, for any given resource :samp:`{res}`, one of the +following is true: + +* The resource has a single definition :samp:`{def}`, which is not a phi node. + Excluding uses of undefined registers, all uses of :samp:`{res}` by real + nondebug instructions use the value provided by :samp:`{def}`. + +* Excluding uses of undefined registers, all uses of :samp:`{res}` use + values provided by definitions that occur earlier in the same + extended basic block. These definitions might come from phi nodes + or from real instructions. + +.. index:: rtl_ssa::insn_change + +.. _changing-rtl-instructions: + +Using the RTL SSA framework to change instructions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +There are various routines that help to change a single RTL instruction +or a group of RTL instructions while keeping the RTL SSA form up-to-date. +This section first describes the process for changing a single instruction, +then goes on to describe the differences when changing multiple instructions. + +.. toctree:: + :maxdepth: 2 + + +.. _changing-one-rtl-ssa-instruction: + +Changing One RTL SSA Instruction +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Before making a change, passes should first use a statement like the +following: + +.. code-block:: c++ + + auto attempt = crtl->ssa->new_change_attempt (); + +Here, ``attempt`` is an RAII object that should remain in scope +for the entire change attempt. It automatically frees temporary +memory related to the changes when it goes out of scope. + +Next, the pass should create an ``rtl_ssa::insn_change`` object +for the instruction that it wants to change. This object specifies +several things: + +* what the instruction's new list of uses should be (``new_uses``). + By default this is the same as the instruction's current list of uses. + +* what the instruction's new list of definitions should be (``new_defs``). + By default this is the same as the instruction's current list of + definitions. + +* where the instruction should be located (``move_range``). + This is a range of instructions after which the instruction could + be placed, represented as an ``rtl_ssa::insn_range``. + By default the instruction must remain at its current position. + +If a pass was attempting to change all these properties of an instruction +``insn``, it might do something like this: + +.. code-block:: c++ + + rtl_ssa::insn_change change (insn); + change.new_defs = ...; + change.new_uses = ...; + change.move_range = ...; + +This ``rtl_ssa::insn_change`` only describes something that the +pass *might* do; at this stage, nothing has actually changed. + +As noted above, the default ``move_range`` requires the instruction +to remain where it is. At the other extreme, it is possible to allow +the instruction to move anywhere within its extended basic block, +provided that all the new uses and definitions can be performed +at the new location. The way to do this is: + +.. code-block:: c++ + + change.move_range = insn->ebb ()->insn_range (); + +In either case, the next step is to make sure that move range is +consistent with the new uses and definitions. The way to do this is: + +.. code-block:: c++ + + if (!rtl_ssa::restrict_movement (change)) + return false; + +This function tries to limit ``move_range`` to a range of instructions +at which ``new_uses`` and ``new_defs`` can be correctly performed. +It returns true on success or false if no suitable location exists. + +The pass should also tentatively change the pattern of the instruction +to whatever form the pass wants the instruction to have. This should use +the facilities provided by :samp:`recog.cc`. For example: + +.. code-block:: c++ + + rtl_insn *rtl = insn->rtl (); + insn_change_watermark watermark; + validate_change (rtl, &PATTERN (rtl), new_pat, 1); + +will tentatively replace ``insn`` 's pattern with ``new_pat``. + +These changes and the construction of the ``rtl_ssa::insn_change`` +can happen in either order or be interleaved. + +After the tentative changes to the instruction are complete, +the pass should check whether the new pattern matches a target +instruction or satisfies the requirements of an inline asm: + +.. code-block:: c++ + + if (!rtl_ssa::recog (change)) + return false; + +This step might change the instruction pattern further in order to +make it match. It might also add new definitions or restrict the range +of the move. For example, if the new pattern did not match in its original +form, but could be made to match by adding a clobber of the flags +register, ``rtl_ssa::recog`` will check whether the flags register +is free at an appropriate point. If so, it will add a clobber of the +flags register to ``new_defs`` and restrict ``move_range`` to +the locations at which the flags register can be safely clobbered. + +Even if the proposed new instruction is valid according to +``rtl_ssa::recog``, the change might not be worthwhile. +For example, when optimizing for speed, the new instruction might +turn out to be slower than the original one. When optimizing for +size, the new instruction might turn out to be bigger than the +original one. + +Passes should check for this case using ``change_is_worthwhile``. +For example: + +.. code-block:: c++ + + if (!rtl_ssa::change_is_worthwhile (change)) + return false; + +If the change passes this test too then the pass can perform the change using: + +.. code-block:: c++ + + confirm_change_group (); + crtl->ssa->change_insn (change); + +Putting all this together, the change has the following form: + +.. code-block:: c++ + + auto attempt = crtl->ssa->new_change_attempt (); + + rtl_ssa::insn_change change (insn); + change.new_defs = ...; + change.new_uses = ...; + change.move_range = ...; + + if (!rtl_ssa::restrict_movement (change)) + return false; + + insn_change_watermark watermark; + // Use validate_change etc. to change INSN's pattern. + ... + if (!rtl_ssa::recog (change) + || !rtl_ssa::change_is_worthwhile (change)) + return false; + + confirm_change_group (); + crtl->ssa->change_insn (change); + +.. _changing-multiple-rtl-ssa-instructions: + +Changing Multiple RTL SSA Instructions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The process for changing multiple instructions is similar +to the process for changing single instructions +(see :ref:`changing-one-rtl-ssa-instruction`). The pass should +again start the change attempt with: + +.. code-block:: c++ + + auto attempt = crtl->ssa->new_change_attempt (); + +and keep ``attempt`` in scope for the duration of the change +attempt. It should then construct an ``rtl_ssa::insn_change`` +for each change that it wants to make. + +After this, it should combine the changes into a sequence of +``rtl_ssa::insn_change`` pointers. This sequence must be in +reverse postorder; the instructions will remain strictly in the +order that the sequence specifies. + +For example, if a pass is changing exactly two instructions, +it might do: + +.. code-block:: c++ + + rtl_ssa::insn_change *changes[] = { &change1, change2 }; + +where ``change1`` 's instruction must come before ``change2`` 's. +Alternatively, if the pass is changing a variable number of +instructions, it might build up the sequence in a +``vec``. + +By default, ``rtl_ssa::restrict_movement`` assumes that all +instructions other than the one passed to it will remain in their +current positions and will retain their current uses and definitions. +When changing multiple instructions, it is usually more effective +to ignore the other instructions that are changing. The sequencing +described above ensures that the changing instructions remain +in the correct order with respect to each other. +The way to do this is: + +.. code-block:: c++ + + if (!rtl_ssa::restrict_movement (change, insn_is_changing (changes))) + return false; + +Similarly, when ``rtl_ssa::restrict_movement`` is detecting +whether a register can be clobbered, it by default assumes that +all other instructions will remain in their current positions and +retain their current form. It is again more effective to ignore +changing instructions (which might, for example, no longer need +to clobber the flags register). The way to do this is: + +.. code-block:: c++ + + if (!rtl_ssa::recog (change, insn_is_changing (changes))) + return false; + +When changing multiple instructions, the important question is usually +not whether each individual change is worthwhile, but whether the changes +as a whole are worthwhile. The way to test this is: + +.. code-block:: c++ + + if (!rtl_ssa::changes_are_worthwhile (changes)) + return false; + +The process for changing single instructions makes sure that one +``rtl_ssa::insn_change`` in isolation is valid. But when changing +multiple instructions, it is also necessary to test whether the +sequence as a whole is valid. For example, it might be impossible +to satisfy all of the ``move_range`` s at once. + +Therefore, once the pass has a sequence of changes that are +individually correct, it should use: + +.. code-block:: c++ + + if (!crtl->ssa->verify_insn_changes (changes)) + return false; + +to check whether the sequence as a whole is valid. If all checks pass, +the final step is: + +.. code-block:: c++ + + confirm_change_group (); + crtl->ssa->change_insns (changes); + +Putting all this together, the process for a two-instruction change is: + +.. code-block:: c++ + + auto attempt = crtl->ssa->new_change_attempt (); + + rtl_ssa::insn_change change (insn1); + change1.new_defs = ...; + change1.new_uses = ...; + change1.move_range = ...; + + rtl_ssa::insn_change change (insn2); + change2.new_defs = ...; + change2.new_uses = ...; + change2.move_range = ...; + + rtl_ssa::insn_change *changes[] = { &change1, change2 }; + + auto is_changing = insn_is_changing (changes); + if (!rtl_ssa::restrict_movement (change1, is_changing) + || !rtl_ssa::restrict_movement (change2, is_changing)) + return false; + + insn_change_watermark watermark; + // Use validate_change etc. to change INSN1's and INSN2's patterns. + ... + if (!rtl_ssa::recog (change1, is_changing) + || !rtl_ssa::recog (change2, is_changing) + || !rtl_ssa::changes_are_worthwhile (changes) + || !crtl->ssa->verify_insn_changes (changes)) + return false; + + confirm_change_group (); + crtl->ssa->change_insns (changes); \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/reading-rtl.rst b/gcc/doc/gccint/rtl-representation/reading-rtl.rst new file mode 100644 index 00000000000..4ad1edc416b --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/reading-rtl.rst @@ -0,0 +1,28 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _reading-rtl: + +Reading RTL +*********** + +To read an RTL object from a file, call ``read_rtx``. It takes one +argument, a stdio stream, and returns a single RTL object. This routine +is defined in :samp:`read-rtl.cc`. It is not available in the compiler +itself, only the various programs that generate the compiler back end +from the machine description. + +People frequently have the idea of using RTL stored as text in a file as +an interface between a language front end and the bulk of GCC. This +idea is not feasible. + +GCC was designed to use RTL internally only. Correct RTL for a given +program is very dependent on the particular target machine. And the RTL +does not contain all the information about the program. + +The proper way to interface GCC to a new language front end is with +the 'tree' data structure, described in the files :samp:`tree.h` and +:samp:`tree.def`. The documentation for this structure (see :ref:`generic`) +is incomplete. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/registers-and-memory.rst b/gcc/doc/gccint/rtl-representation/registers-and-memory.rst new file mode 100644 index 00000000000..293565c4ee0 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/registers-and-memory.rst @@ -0,0 +1,451 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RTL register expressions, RTL memory expressions + +.. _regs-and-memory: + +Registers and Memory +******************** + +Here are the RTL expression types for describing access to machine +registers and to main memory. + +.. index:: reg, hard registers, pseudo registers + +:samp:`(reg:{m} {n})` + For small values of the integer :samp:`{n}` (those that are less than + ``FIRST_PSEUDO_REGISTER``), this stands for a reference to machine + register number :samp:`{n}` : a :dfn:`hard register`. For larger values of + :samp:`{n}`, it stands for a temporary value or :dfn:`pseudo register`. + The compiler's strategy is to generate code assuming an unlimited + number of such pseudo registers, and later convert them into hard + registers or into memory references. + + :samp:`{m}` is the machine mode of the reference. It is necessary because + machines can generally refer to each register in more than one mode. + For example, a register may contain a full word but there may be + instructions to refer to it as a half word or as a single byte, as + well as instructions to refer to it as a floating point number of + various precisions. + + Even for a register that the machine can access in only one mode, + the mode must always be specified. + + The symbol ``FIRST_PSEUDO_REGISTER`` is defined by the machine + description, since the number of hard registers on the machine is an + invariant characteristic of the machine. Note, however, that not + all of the machine registers must be general registers. All the + machine registers that can be used for storage of data are given + hard register numbers, even those that can be used only in certain + instructions or can hold only certain types of data. + + A hard register may be accessed in various modes throughout one + function, but each pseudo register is given a natural mode + and is accessed only in that mode. When it is necessary to describe + an access to a pseudo register using a nonnatural mode, a ``subreg`` + expression is used. + + A ``reg`` expression with a machine mode that specifies more than + one word of data may actually stand for several consecutive registers. + If in addition the register number specifies a hardware register, then + it actually represents several consecutive hardware registers starting + with the specified one. + + Each pseudo register number used in a function's RTL code is + represented by a unique ``reg`` expression. + + .. index:: FIRST_VIRTUAL_REGISTER, LAST_VIRTUAL_REGISTER + + Some pseudo register numbers, those within the range of + ``FIRST_VIRTUAL_REGISTER`` to ``LAST_VIRTUAL_REGISTER`` only + appear during the RTL generation phase and are eliminated before the + optimization phases. These represent locations in the stack frame that + cannot be determined until RTL generation for the function has been + completed. The following virtual register numbers are defined: + + .. index:: VIRTUAL_INCOMING_ARGS_REGNUM + + .. envvar:: VIRTUAL_INCOMING_ARGS_REGNUM + + This points to the first word of the incoming arguments passed on the + stack. Normally these arguments are placed there by the caller, but the + callee may have pushed some arguments that were previously passed in + registers. + + .. index:: FIRST_PARM_OFFSET and virtual registers, ARG_POINTER_REGNUM and virtual registers + + When RTL generation is complete, this virtual register is replaced + by the sum of the register given by ``ARG_POINTER_REGNUM`` and the + value of ``FIRST_PARM_OFFSET``. + + .. index:: FRAME_GROWS_DOWNWARD and virtual registers + + .. envvar:: VIRTUAL_STACK_VARS_REGNUM + + If ``FRAME_GROWS_DOWNWARD`` is defined to a nonzero value, this points + to immediately above the first variable on the stack. Otherwise, it points + to the first variable on the stack. + + .. index:: TARGET_STARTING_FRAME_OFFSET and virtual registers, FRAME_POINTER_REGNUM and virtual registers + + ``VIRTUAL_STACK_VARS_REGNUM`` is replaced with the sum of the + register given by ``FRAME_POINTER_REGNUM`` and the value + ``TARGET_STARTING_FRAME_OFFSET``. + + .. envvar:: VIRTUAL_STACK_DYNAMIC_REGNUM + + This points to the location of dynamically allocated memory on the stack + immediately after the stack pointer has been adjusted by the amount of + memory desired. + + .. index:: STACK_DYNAMIC_OFFSET and virtual registers, STACK_POINTER_REGNUM and virtual registers + + This virtual register is replaced by the sum of the register given by + ``STACK_POINTER_REGNUM`` and the value ``STACK_DYNAMIC_OFFSET``. + + .. envvar:: VIRTUAL_OUTGOING_ARGS_REGNUM + + This points to the location in the stack at which outgoing arguments + should be written when the stack is pre-pushed (arguments pushed using + push insns should always use ``STACK_POINTER_REGNUM``). + + .. index:: STACK_POINTER_OFFSET and virtual registers + + This virtual register is replaced by the sum of the register given by + ``STACK_POINTER_REGNUM`` and the value ``STACK_POINTER_OFFSET``. + + .. index:: subreg + +:samp:`(subreg:{m1} {reg:m2} {bytenum})` + ``subreg`` expressions are used to refer to a register in a machine + mode other than its natural one, or to refer to one register of + a multi-part ``reg`` that actually refers to several registers. + + Each pseudo register has a natural mode. If it is necessary to + operate on it in a different mode, the register must be + enclosed in a ``subreg``. + + There are currently three supported types for the first operand of a + ``subreg`` : + + * pseudo registers + This is the most common case. Most ``subreg`` s have pseudo + ``reg`` s as their first operand. + + * mem + ``subreg`` s of ``mem`` were common in earlier versions of GCC and + are still supported. During the reload pass these are replaced by plain + ``mem`` s. On machines that do not do instruction scheduling, use of + ``subreg`` s of ``mem`` are still used, but this is no longer + recommended. Such ``subreg`` s are considered to be + ``register_operand`` s rather than ``memory_operand`` s before and + during reload. Because of this, the scheduling passes cannot properly + schedule instructions with ``subreg`` s of ``mem``, so for machines + that do scheduling, ``subreg`` s of ``mem`` should never be used. + To support this, the combine and recog passes have explicit code to + inhibit the creation of ``subreg`` s of ``mem`` when + ``INSN_SCHEDULING`` is defined. + + The use of ``subreg`` s of ``mem`` after the reload pass is an area + that is not well understood and should be avoided. There is still some + code in the compiler to support this, but this code has possibly rotted. + This use of ``subreg`` s is discouraged and will most likely not be + supported in the future. + + * hard registers + It is seldom necessary to wrap hard registers in ``subreg`` s; such + registers would normally reduce to a single ``reg`` rtx. This use of + ``subreg`` s is discouraged and may not be supported in the future. + + ``subreg`` s of ``subreg`` s are not supported. Using + ``simplify_gen_subreg`` is the recommended way to avoid this problem. + + ``subreg`` s come in two distinct flavors, each having its own + usage and rules: + + Paradoxical subregs + When :samp:`{m1}` is strictly wider than :samp:`{m2}`, the ``subreg`` + expression is called :dfn:`paradoxical`. The canonical test for this + class of ``subreg`` is: + + .. code-block:: c++ + + paradoxical_subreg_p (m1, m2) + + Paradoxical ``subreg`` s can be used as both lvalues and rvalues. + When used as an lvalue, the low-order bits of the source value + are stored in :samp:`{reg}` and the high-order bits are discarded. + When used as an rvalue, the low-order bits of the ``subreg`` are + taken from :samp:`{reg}` while the high-order bits may or may not be + defined. + + The high-order bits of rvalues are defined in the following circumstances: + + * ``subreg`` s of ``mem`` + When :samp:`{m2}` is smaller than a word, the macro ``LOAD_EXTEND_OP``, + can control how the high-order bits are defined. + + * ``subreg`` of ``reg`` s + The upper bits are defined when ``SUBREG_PROMOTED_VAR_P`` is true. + ``SUBREG_PROMOTED_UNSIGNED_P`` describes what the upper bits hold. + Such subregs usually represent local variables, register variables + and parameter pseudo variables that have been promoted to a wider mode. + + :samp:`{bytenum}` is always zero for a paradoxical ``subreg``, even on + big-endian targets. + + For example, the paradoxical ``subreg`` : + + .. code-block:: c++ + + (set (subreg:SI (reg:HI x) 0) y) + + stores the lower 2 bytes of :samp:`{y}` in :samp:`{x}` and discards the upper + 2 bytes. A subsequent: + + .. code-block:: c++ + + (set z (subreg:SI (reg:HI x) 0)) + + would set the lower two bytes of :samp:`{z}` to :samp:`{y}` and set the upper + two bytes to an unknown value assuming ``SUBREG_PROMOTED_VAR_P`` is + false. + + Normal subregs + When :samp:`{m1}` is at least as narrow as :samp:`{m2}` the ``subreg`` + expression is called :dfn:`normal`. + + .. index:: REGMODE_NATURAL_SIZE + + Normal ``subreg`` s restrict consideration to certain bits of + :samp:`{reg}`. For this purpose, :samp:`{reg}` is divided into + individually-addressable blocks in which each block has: + + .. code-block:: c++ + + REGMODE_NATURAL_SIZE (m2) + + bytes. Usually the value is ``UNITS_PER_WORD`` ; that is, + most targets usually treat each word of a register as being + independently addressable. + + There are two types of normal ``subreg``. If :samp:`{m1}` is known + to be no bigger than a block, the ``subreg`` refers to the + least-significant part (or :dfn:`lowpart`) of one block of :samp:`{reg}`. + If :samp:`{m1}` is known to be larger than a block, the ``subreg`` refers + to two or more complete blocks. + + When used as an lvalue, ``subreg`` is a block-based accessor. + Storing to a ``subreg`` modifies all the blocks of :samp:`{reg}` that + overlap the ``subreg``, but it leaves the other blocks of :samp:`{reg}` + alone. + + When storing to a normal ``subreg`` that is smaller than a block, + the other bits of the referenced block are usually left in an undefined + state. This laxity makes it easier to generate efficient code for + such instructions. To represent an instruction that preserves all the + bits outside of those in the ``subreg``, use ``strict_low_part`` + or ``zero_extract`` around the ``subreg``. + + :samp:`{bytenum}` must identify the offset of the first byte of the + ``subreg`` from the start of :samp:`{reg}`, assuming that :samp:`{reg}` is + laid out in memory order. The memory order of bytes is defined by + two target macros, ``WORDS_BIG_ENDIAN`` and ``BYTES_BIG_ENDIAN`` : + + .. index:: WORDS_BIG_ENDIAN, effect on subreg + + * ``WORDS_BIG_ENDIAN``, if set to 1, says that byte number zero is + part of the most significant word; otherwise, it is part of the least + significant word. + + .. index:: BYTES_BIG_ENDIAN, effect on subreg + + * ``BYTES_BIG_ENDIAN``, if set to 1, says that byte number zero is + the most significant byte within a word; otherwise, it is the least + significant byte within a word. + + .. index:: FLOAT_WORDS_BIG_ENDIAN, (lack of) effect on subreg + + On a few targets, ``FLOAT_WORDS_BIG_ENDIAN`` disagrees with + ``WORDS_BIG_ENDIAN``. However, most parts of the compiler treat + floating point values as if they had the same endianness as integer + values. This works because they handle them solely as a collection of + integer values, with no particular numerical value. Only real.cc and + the runtime libraries care about ``FLOAT_WORDS_BIG_ENDIAN``. + + Thus, + + .. code-block:: c++ + + (subreg:HI (reg:SI x) 2) + + on a ``BYTES_BIG_ENDIAN``, :samp:`UNITS_PER_WORD == 4` target is the same as + + .. code-block:: c++ + + (subreg:HI (reg:SI x) 0) + + on a little-endian, :samp:`UNITS_PER_WORD == 4` target. Both + ``subreg`` s access the lower two bytes of register :samp:`{x}`. + + Note that the byte offset is a polynomial integer; it may not be a + compile-time constant on targets with variable-sized modes. However, + the restrictions above mean that there are only a certain set of + acceptable offsets for a given combination of :samp:`{m1}` and :samp:`{m2}`. + The compiler can always tell which blocks a valid subreg occupies, and + whether the subreg is a lowpart of a block. + + A ``MODE_PARTIAL_INT`` mode behaves as if it were as wide as the + corresponding ``MODE_INT`` mode, except that it has a number of + undefined bits, which are determined by the precision of the + mode. + + For example, on a little-endian target which defines ``PSImode`` + to have a precision of 20 bits: + + .. code-block:: c++ + + (subreg:PSI (reg:SI 0) 0) + + accesses the low 20 bits of :samp:`(reg:SI 0)`. + + .. index:: REGMODE_NATURAL_SIZE + + Continuing with a ``PSImode`` precision of 20 bits, if we assume + :samp:`REGMODE_NATURAL_SIZE (DImode) <= 4`, + then the following two ``subreg`` s: + + .. code-block:: c++ + + (subreg:PSI (reg:DI 0) 0) + (subreg:PSI (reg:DI 0) 4) + + represent accesses to the low 20 bits of the two halves of + :samp:`(reg:DI 0)`. + + If :samp:`REGMODE_NATURAL_SIZE (PSImode) <= 2` then these two ``subreg`` s: + + .. code-block:: c++ + + (subreg:HI (reg:PSI 0) 0) + (subreg:HI (reg:PSI 0) 2) + + represent independent 2-byte accesses that together span the whole + of :samp:`(reg:PSI 0)`. Storing to the first ``subreg`` does not + affect the value of the second, and vice versa, so the assignment: + + .. code-block:: c++ + + (set (subreg:HI (reg:PSI 0) 0) (reg:HI 4)) + + sets the low 16 bits of :samp:`(reg:PSI 0)` to :samp:`(reg:HI 4)`, and + the high 4 defined bits of :samp:`(reg:PSI 0)` retain their + original value. The behavior here is the same as for + normal ``subreg`` s, when there are no + ``MODE_PARTIAL_INT`` modes involved. + + .. index:: TARGET_CAN_CHANGE_MODE_CLASS and subreg semantics + + The rules above apply to both pseudo :samp:`{reg}` s and hard :samp:`{reg}` s. + If the semantics are not correct for particular combinations of + :samp:`{m1}`, :samp:`{m2}` and hard :samp:`{reg}`, the target-specific code + must ensure that those combinations are never used. For example: + + .. code-block:: c++ + + TARGET_CAN_CHANGE_MODE_CLASS (m2, m1, class) + + must be false for every class :samp:`{class}` that includes :samp:`{reg}`. + + GCC must be able to determine at compile time whether a subreg is + paradoxical, whether it occupies a whole number of blocks, or whether + it is a lowpart of a block. This means that certain combinations of + variable-sized mode are not permitted. For example, if :samp:`{m2}` + holds :samp:`{n}` ``SI`` values, where :samp:`{n}` is greater than zero, + it is not possible to form a ``DI`` ``subreg`` of it; such a + ``subreg`` would be paradoxical when :samp:`{n}` is 1 but not when + :samp:`{n}` is greater than 1. + + .. index:: SUBREG_REG, SUBREG_BYTE + + The first operand of a ``subreg`` expression is customarily accessed + with the ``SUBREG_REG`` macro and the second operand is customarily + accessed with the ``SUBREG_BYTE`` macro. + + It has been several years since a platform in which + ``BYTES_BIG_ENDIAN`` not equal to ``WORDS_BIG_ENDIAN`` has + been tested. Anyone wishing to support such a platform in the future + may be confronted with code rot. + + .. index:: scratch, scratch operands + +:samp:`(scratch:{m})` + This represents a scratch register that will be required for the + execution of a single instruction and not used subsequently. It is + converted into a ``reg`` by either the local register allocator or + the reload pass. + + ``scratch`` is usually present inside a ``clobber`` operation + (see :ref:`side-effects`). + + On some machines, the condition code register is given a register number + and a ``reg`` is used. + Other machines store condition codes in general + registers; in such cases a pseudo register should be used. + + Some machines, such as the SPARC and RS/6000, have two sets of + arithmetic instructions, one that sets and one that does not set the + condition code. This is best handled by normally generating the + instruction that does not set the condition code, and making a pattern + that both performs the arithmetic and sets the condition code register. + For examples, search for :samp:`addcc` and :samp:`andcc` in :samp:`sparc.md`. + + .. index:: pc + +``(pc)`` + + .. index:: program counter + + This represents the machine's program counter. It has no operands and + may not have a machine mode. ``(pc)`` may be validly used only in + certain specific contexts in jump instructions. + + .. index:: pc_rtx + + There is only one expression object of code ``pc`` ; it is the value + of the variable ``pc_rtx``. Any attempt to create an expression of + code ``pc`` will return ``pc_rtx``. + + All instructions that do not jump alter the program counter implicitly + by incrementing it, but there is no need to mention this in the RTL. + + .. index:: mem + +:samp:`(mem:{m} {addr} {alias})` + This RTX represents a reference to main memory at an address + represented by the expression :samp:`{addr}`. :samp:`{m}` specifies how large + a unit of memory is accessed. :samp:`{alias}` specifies an alias set for the + reference. In general two items are in different alias sets if they cannot + reference the same memory address. + + The construct ``(mem:BLK (scratch))`` is considered to alias all + other memories. Thus it may be used as a memory barrier in epilogue + stack deallocation patterns. + + .. index:: concat + +:samp:`(concat{m} {rtx} {rtx})` + This RTX represents the concatenation of two other RTXs. This is used + for complex values. It should only appear in the RTL attached to + declarations and during RTL generation. It should not appear in the + ordinary insn chain. + + .. index:: concatn + +:samp:`(concatn{m} [{rtx} ...])` + This RTX represents the concatenation of all the :samp:`{rtx}` to make a + single value. Like ``concat``, this should only appear in + declarations, and not in the insn chain. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/rtl-classes-and-formats.rst b/gcc/doc/gccint/rtl-representation/rtl-classes-and-formats.rst new file mode 100644 index 00000000000..169b7e82f91 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/rtl-classes-and-formats.rst @@ -0,0 +1,192 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RTL classes, classes of RTX codes, RTX codes, classes of, GET_RTX_CLASS + +.. _rtl-classes: + +RTL Classes and Formats +*********************** + +The various expression codes are divided into several :dfn:`classes`, +which are represented by single characters. You can determine the class +of an RTX code with the macro ``GET_RTX_CLASS (code)``. +Currently, :samp:`rtl.def` defines these classes: + +.. envvar:: RTX_OBJ + + An RTX code that represents an actual object, such as a register + (``REG``) or a memory location (``MEM``, ``SYMBOL_REF``). + ``LO_SUM`` is also included; instead, ``SUBREG`` and + ``STRICT_LOW_PART`` are not in this class, but in class + ``RTX_EXTRA``. + +.. envvar:: RTX_CONST_OBJ + + An RTX code that represents a constant object. ``HIGH`` is also + included in this class. + +.. envvar:: RTX_COMPARE + + An RTX code for a non-symmetric comparison, such as ``GEU`` or + ``LT``. + +.. envvar:: RTX_COMM_COMPARE + + An RTX code for a symmetric (commutative) comparison, such as ``EQ`` + or ``ORDERED``. + +.. envvar:: RTX_UNARY + + An RTX code for a unary arithmetic operation, such as ``NEG``, + ``NOT``, or ``ABS``. This category also includes value extension + (sign or zero) and conversions between integer and floating point. + +.. envvar:: RTX_COMM_ARITH + + An RTX code for a commutative binary operation, such as ``PLUS`` or + ``AND``. ``NE`` and ``EQ`` are comparisons, so they have class + ``RTX_COMM_COMPARE``. + +.. envvar:: RTX_BIN_ARITH + + An RTX code for a non-commutative binary operation, such as ``MINUS``, + ``DIV``, or ``ASHIFTRT``. + +.. envvar:: RTX_BITFIELD_OPS + + An RTX code for a bit-field operation. Currently only + ``ZERO_EXTRACT`` and ``SIGN_EXTRACT``. These have three inputs + and are lvalues (so they can be used for insertion as well). + See :ref:`bit-fields`. + +.. envvar:: RTX_TERNARY + + An RTX code for other three input operations. Currently only + ``IF_THEN_ELSE``, ``VEC_MERGE``, ``SIGN_EXTRACT``, + ``ZERO_EXTRACT``, and ``FMA``. + +.. envvar:: RTX_INSN + + An RTX code for an entire instruction: ``INSN``, ``JUMP_INSN``, and + ``CALL_INSN``. See :ref:`insns`. + +.. envvar:: RTX_MATCH + + An RTX code for something that matches in insns, such as + ``MATCH_DUP``. These only occur in machine descriptions. + +.. envvar:: RTX_AUTOINC + + An RTX code for an auto-increment addressing mode, such as + ``POST_INC``. :samp:`XEXP ({x}, 0)` gives the auto-modified + register. + +.. envvar:: RTX_EXTRA + + All other RTX codes. This category includes the remaining codes used + only in machine descriptions (``DEFINE_*``, etc.). It also includes + all the codes describing side effects (``SET``, ``USE``, + ``CLOBBER``, etc.) and the non-insns that may appear on an insn + chain, such as ``NOTE``, ``BARRIER``, and ``CODE_LABEL``. + ``SUBREG`` is also part of this class. + +.. index:: RTL format + +For each expression code, :samp:`rtl.def` specifies the number of +contained objects and their kinds using a sequence of characters +called the :dfn:`format` of the expression code. For example, +the format of ``subreg`` is :samp:`ep`. + +.. index:: RTL format characters + +These are the most commonly used format characters: + +``e`` + An expression (actually a pointer to an expression). + +``i`` + An integer. + +``w`` + A wide integer. + +``s`` + A string. + +``E`` + A vector of expressions. + + A few other format characters are used occasionally: + +``u`` + :samp:`u` is equivalent to :samp:`e` except that it is printed differently + in debugging dumps. It is used for pointers to insns. + +``n`` + :samp:`n` is equivalent to :samp:`i` except that it is printed differently + in debugging dumps. It is used for the line number or code number of a + ``note`` insn. + +``S`` + :samp:`S` indicates a string which is optional. In the RTL objects in + core, :samp:`S` is equivalent to :samp:`s`, but when the object is read, + from an :samp:`md` file, the string value of this operand may be omitted. + An omitted string is taken to be the null string. + +``V`` + :samp:`V` indicates a vector which is optional. In the RTL objects in + core, :samp:`V` is equivalent to :samp:`E`, but when the object is read + from an :samp:`md` file, the vector value of this operand may be omitted. + An omitted vector is effectively the same as a vector of no elements. + +``B`` + :samp:`B` indicates a pointer to basic block structure. + +``p`` + A polynomial integer. At present this is used only for ``SUBREG_BYTE``. + +``0`` + :samp:`0` means a slot whose contents do not fit any normal category. + :samp:`0` slots are not printed at all in dumps, and are often used in + special ways by small parts of the compiler. + +There are macros to get the number of operands and the format +of an expression code: + +.. index:: GET_RTX_LENGTH + +:samp:`GET_RTX_LENGTH ({code})` + Number of operands of an RTX of code :samp:`{code}`. + + .. index:: GET_RTX_FORMAT + +:samp:`GET_RTX_FORMAT ({code})` + The format of an RTX of code :samp:`{code}`, as a C string. + +Some classes of RTX codes always have the same format. For example, it +is safe to assume that all comparison operations have format ``ee``. + +.. envvar:: RTX_UNARY + + All codes of this class have format ``e``. + +.. envvar:: RTX_BIN_ARITH + + All codes of these classes have format ``ee``. + +.. envvar:: RTX_BITFIELD_OPS + + All codes of these classes have format ``eee``. + +.. envvar:: RTX_INSN + + All codes of this class have formats that begin with ``iuueiee``. + See :ref:`insns`. Note that not all RTL objects linked onto an insn chain + are of class ``RTX_INSN``. + +.. envvar:: RTX_CONST_OBJ + + You can make no assumptions about the format of these codes. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/rtl-expressions-for-arithmetic.rst b/gcc/doc/gccint/rtl-representation/rtl-expressions-for-arithmetic.rst new file mode 100644 index 00000000000..c6ff51e0658 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/rtl-expressions-for-arithmetic.rst @@ -0,0 +1,310 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: arithmetic, in RTL, math, in RTL, RTL expressions for arithmetic + +.. _arithmetic: + +RTL Expressions for Arithmetic +****************************** + +Unless otherwise specified, all the operands of arithmetic expressions +must be valid for mode :samp:`{m}`. An operand is valid for mode :samp:`{m}` +if it has mode :samp:`{m}`, or if it is a ``const_int`` or +``const_double`` and :samp:`{m}` is a mode of class ``MODE_INT``. + +For commutative binary operations, constants should be placed in the +second operand. + +.. index:: plus, ss_plus, us_plus, RTL sum, RTL addition, RTL addition with signed saturation, RTL addition with unsigned saturation + +:samp:`(plus:{m} {x} {y})` :samp:`(ss_plus:{m} {x} {y})` :samp:`(us_plus:{m} {x} {y})` + These three expressions all represent the sum of the values + represented by :samp:`{x}` and :samp:`{y}` carried out in machine mode + :samp:`{m}`. They differ in their behavior on overflow of integer modes. + ``plus`` wraps round modulo the width of :samp:`{m}` ; ``ss_plus`` + saturates at the maximum signed value representable in :samp:`{m}` ; + ``us_plus`` saturates at the maximum unsigned value. + + .. ??? What happens on overflow of floating point modes? + + .. index:: lo_sum + +:samp:`(lo_sum:{m} {x} {y})` + This expression represents the sum of :samp:`{x}` and the low-order bits + of :samp:`{y}`. It is used with ``high`` (see :ref:`constants`) to + represent the typical two-instruction sequence used in RISC machines to + reference large immediate values and/or link-time constants such + as global memory addresses. In the latter case, :samp:`{m}` is ``Pmode`` + and :samp:`{y}` is usually a constant expression involving ``symbol_ref``. + + The number of low order bits is machine-dependent but is + normally the number of bits in mode :samp:`{m}` minus the number of + bits set by ``high``. + + .. index:: minus, ss_minus, us_minus, RTL difference, RTL subtraction, RTL subtraction with signed saturation, RTL subtraction with unsigned saturation + +:samp:`(minus:{m} {x} {y})` :samp:`(ss_minus:{m} {x} {y})` :samp:`(us_minus:{m} {x} {y})` + These three expressions represent the result of subtracting :samp:`{y}` + from :samp:`{x}`, carried out in mode :samp:`{M}`. Behavior on overflow is + the same as for the three variants of ``plus`` (see above). + + .. index:: compare, RTL comparison + +:samp:`(compare:{m} {x} {y})` + Represents the result of subtracting :samp:`{y}` from :samp:`{x}` for purposes + of comparison. The result is computed without overflow, as if with + infinite precision. + + Of course, machines cannot really subtract with infinite precision. + However, they can pretend to do so when only the sign of the result will + be used, which is the case when the result is stored in the condition + code. And that is the *only* way this kind of expression may + validly be used: as a value to be stored in the condition codes, in a + register. See :ref:`comparisons`. + + The mode :samp:`{m}` is not related to the modes of :samp:`{x}` and :samp:`{y}`, but + instead is the mode of the condition code value. It is some mode in class + ``MODE_CC``, often ``CCmode``. See :ref:`condition-code`. If :samp:`{m}` + is ``CCmode``, the operation returns sufficient + information (in an unspecified format) so that any comparison operator + can be applied to the result of the ``COMPARE`` operation. For other + modes in class ``MODE_CC``, the operation only returns a subset of + this information. + + Normally, :samp:`{x}` and :samp:`{y}` must have the same mode. Otherwise, + ``compare`` is valid only if the mode of :samp:`{x}` is in class + ``MODE_INT`` and :samp:`{y}` is a ``const_int`` or + ``const_double`` with mode ``VOIDmode``. The mode of :samp:`{x}` + determines what mode the comparison is to be done in; thus it must not + be ``VOIDmode``. + + If one of the operands is a constant, it should be placed in the + second operand and the comparison code adjusted as appropriate. + + A ``compare`` specifying two ``VOIDmode`` constants is not valid + since there is no way to know in what mode the comparison is to be + performed; the comparison must either be folded during the compilation + or the first operand must be loaded into a register while its mode is + still known. + + .. index:: neg, ss_neg, us_neg, negation, negation with signed saturation, negation with unsigned saturation + +:samp:`(neg:{m} {x})` :samp:`(ss_neg:{m} {x})` :samp:`(us_neg:{m} {x})` + These two expressions represent the negation (subtraction from zero) of + the value represented by :samp:`{x}`, carried out in mode :samp:`{m}`. They + differ in the behavior on overflow of integer modes. In the case of + ``neg``, the negation of the operand may be a number not representable + in mode :samp:`{m}`, in which case it is truncated to :samp:`{m}`. ``ss_neg`` + and ``us_neg`` ensure that an out-of-bounds result saturates to the + maximum or minimum signed or unsigned value. + + .. index:: mult, ss_mult, us_mult, multiplication, product, multiplication with signed saturation, multiplication with unsigned saturation + +:samp:`(mult:{m} {x} {y})` :samp:`(ss_mult:{m} {x} {y})` :samp:`(us_mult:{m} {x} {y})` + Represents the signed product of the values represented by :samp:`{x}` and + :samp:`{y}` carried out in machine mode :samp:`{m}`. + ``ss_mult`` and ``us_mult`` ensure that an out-of-bounds result + saturates to the maximum or minimum signed or unsigned value. + + Some machines support a multiplication that generates a product wider + than the operands. Write the pattern for this as + + .. code-block:: c++ + + (mult:m (sign_extend:m x) (sign_extend:m y)) + + where :samp:`{m}` is wider than the modes of :samp:`{x}` and :samp:`{y}`, which need + not be the same. + + For unsigned widening multiplication, use the same idiom, but with + ``zero_extend`` instead of ``sign_extend``. + + .. index:: smul_highpart, umul_highpart, high-part multiplication, multiplication high part + +:samp:`(smul_highpart:{m} {x} {y})` :samp:`(umul_highpart:{m} {x} {y})` + Represents the high-part multiplication of :samp:`{x}` and :samp:`{y}` carried + out in machine mode :samp:`{m}`. ``smul_highpart`` returns the high part + of a signed multiplication, ``umul_highpart`` returns the high part + of an unsigned multiplication. + + .. index:: fma, fused multiply-add + +:samp:`(fma:{m} {x} {y} {z})` + Represents the ``fma``, ``fmaf``, and ``fmal`` builtin + functions, which compute :samp:`{x} * {y} + {z}` + without doing an intermediate rounding step. + + .. index:: div, ss_div, division, signed division, signed division with signed saturation, quotient + +:samp:`(div:{m} {x} {y})` :samp:`(ss_div:{m} {x} {y})` + Represents the quotient in signed division of :samp:`{x}` by :samp:`{y}`, + carried out in machine mode :samp:`{m}`. If :samp:`{m}` is a floating point + mode, it represents the exact quotient; otherwise, the integerized + quotient. + ``ss_div`` ensures that an out-of-bounds result saturates to the maximum + or minimum signed value. + + Some machines have division instructions in which the operands and + quotient widths are not all the same; you should represent + such instructions using ``truncate`` and ``sign_extend`` as in, + + .. code-block:: c++ + + (truncate:m1 (div:m2 x (sign_extend:m2 y))) + + .. index:: udiv, unsigned division, unsigned division with unsigned saturation, division + +:samp:`(udiv:{m} {x} {y})` :samp:`(us_div:{m} {x} {y})` + Like ``div`` but represents unsigned division. + ``us_div`` ensures that an out-of-bounds result saturates to the maximum + or minimum unsigned value. + + .. index:: mod, umod, remainder, division + +:samp:`(mod:{m} {x} {y})` :samp:`(umod:{m} {x} {y})` + Like ``div`` and ``udiv`` but represent the remainder instead of + the quotient. + + .. index:: smin, smax, signed minimum, signed maximum + +:samp:`(smin:{m} {x} {y})` :samp:`(smax:{m} {x} {y})` + Represents the smaller (for ``smin``) or larger (for ``smax``) of + :samp:`{x}` and :samp:`{y}`, interpreted as signed values in mode :samp:`{m}`. + When used with floating point, if both operands are zeros, or if either + operand is ``NaN``, then it is unspecified which of the two operands + is returned as the result. + + .. index:: umin, umax, unsigned minimum and maximum + +:samp:`(umin:{m} {x} {y})` :samp:`(umax:{m} {x} {y})` + Like ``smin`` and ``smax``, but the values are interpreted as unsigned + integers. + + .. index:: not, complement, bitwise, bitwise complement + +:samp:`(not:{m} {x})` + Represents the bitwise complement of the value represented by :samp:`{x}`, + carried out in mode :samp:`{m}`, which must be a fixed-point machine mode. + + .. index:: and, logical-and, bitwise, bitwise logical-and + +:samp:`(and:{m} {x} {y})` + Represents the bitwise logical-and of the values represented by + :samp:`{x}` and :samp:`{y}`, carried out in machine mode :samp:`{m}`, which must be + a fixed-point machine mode. + + .. index:: ior, inclusive-or, bitwise, bitwise inclusive-or + +:samp:`(ior:{m} {x} {y})` + Represents the bitwise inclusive-or of the values represented by :samp:`{x}` + and :samp:`{y}`, carried out in machine mode :samp:`{m}`, which must be a + fixed-point mode. + + .. index:: xor, exclusive-or, bitwise, bitwise exclusive-or + +:samp:`(xor:{m} {x} {y})` + Represents the bitwise exclusive-or of the values represented by :samp:`{x}` + and :samp:`{y}`, carried out in machine mode :samp:`{m}`, which must be a + fixed-point mode. + + .. index:: ashift, ss_ashift, us_ashift, left shift, shift, arithmetic shift, arithmetic shift with signed saturation, arithmetic shift with unsigned saturation + +:samp:`(ashift:{m} {x} {c})` :samp:`(ss_ashift:{m} {x} {c})` :samp:`(us_ashift:{m} {x} {c})` + These three expressions represent the result of arithmetically shifting :samp:`{x}` + left by :samp:`{c}` places. They differ in their behavior on overflow of integer + modes. An ``ashift`` operation is a plain shift with no special behavior + in case of a change in the sign bit; ``ss_ashift`` and ``us_ashift`` + saturates to the minimum or maximum representable value if any of the bits + shifted out differs from the final sign bit. + + :samp:`{x}` have mode :samp:`{m}`, a fixed-point machine mode. :samp:`{c}` + be a fixed-point mode or be a constant with mode ``VOIDmode`` ; which + mode is determined by the mode called for in the machine description + entry for the left-shift instruction. For example, on the VAX, the mode + of :samp:`{c}` is ``QImode`` regardless of :samp:`{m}`. + + .. index:: lshiftrt, right shift, ashiftrt + +:samp:`(lshiftrt:{m} {x} {c})` :samp:`(ashiftrt:{m} {x} {c})` + Like ``ashift`` but for right shift. Unlike the case for left shift, + these two operations are distinct. + + .. index:: rotate, rotate, left rotate, rotatert, right rotate + +:samp:`(rotate:{m} {x} {c})` :samp:`(rotatert:{m} {x} {c})` + Similar but represent left and right rotate. If :samp:`{c}` is a constant, + use ``rotate``. + + .. index:: abs, ss_abs, absolute value + + :samp:`(abs:{m} {x})` +:samp:`(ss_abs:{m} {x})` + Represents the absolute value of :samp:`{x}`, computed in mode :samp:`{m}`. + ``ss_abs`` ensures that an out-of-bounds result saturates to the + maximum signed value. + + .. index:: sqrt, square root + +:samp:`(sqrt:{m} {x})` + Represents the square root of :samp:`{x}`, computed in mode :samp:`{m}`. + Most often :samp:`{m}` will be a floating point mode. + + .. index:: ffs + +:samp:`(ffs:{m} {x})` + Represents one plus the index of the least significant 1-bit in + :samp:`{x}`, represented as an integer of mode :samp:`{m}`. (The value is + zero if :samp:`{x}` is zero.) The mode of :samp:`{x}` must be :samp:`{m}` + or ``VOIDmode``. + + .. index:: clrsb + +:samp:`(clrsb:{m} {x})` + Represents the number of redundant leading sign bits in :samp:`{x}`, + represented as an integer of mode :samp:`{m}`, starting at the most + significant bit position. This is one less than the number of leading + sign bits (either 0 or 1), with no special cases. The mode of :samp:`{x}` + must be :samp:`{m}` or ``VOIDmode``. + + .. index:: clz + +:samp:`(clz:{m} {x})` + Represents the number of leading 0-bits in :samp:`{x}`, represented as an + integer of mode :samp:`{m}`, starting at the most significant bit position. + If :samp:`{x}` is zero, the value is determined by + ``CLZ_DEFINED_VALUE_AT_ZERO`` (see :ref:`misc`). Note that this is one of + the few expressions that is not invariant under widening. The mode of + :samp:`{x}` must be :samp:`{m}` or ``VOIDmode``. + + .. index:: ctz + +:samp:`(ctz:{m} {x})` + Represents the number of trailing 0-bits in :samp:`{x}`, represented as an + integer of mode :samp:`{m}`, starting at the least significant bit position. + If :samp:`{x}` is zero, the value is determined by + ``CTZ_DEFINED_VALUE_AT_ZERO`` (see :ref:`misc`). Except for this case, + ``ctz(x)`` is equivalent to ``ffs(x) - 1``. The mode of + :samp:`{x}` must be :samp:`{m}` or ``VOIDmode``. + + .. index:: popcount + +:samp:`(popcount:{m} {x})` + Represents the number of 1-bits in :samp:`{x}`, represented as an integer of + mode :samp:`{m}`. The mode of :samp:`{x}` must be :samp:`{m}` or ``VOIDmode``. + + .. index:: parity + +:samp:`(parity:{m} {x})` + Represents the number of 1-bits modulo 2 in :samp:`{x}`, represented as an + integer of mode :samp:`{m}`. The mode of :samp:`{x}` must be :samp:`{m}` or + ``VOIDmode``. + + .. index:: bswap + +:samp:`(bswap:{m} {x})` + Represents the value :samp:`{x}` with the order of bytes reversed, carried out + in mode :samp:`{m}`, which must be a fixed-point machine mode. + The mode of :samp:`{x}` must be :samp:`{m}` or ``VOIDmode``. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/rtl-object-types.rst b/gcc/doc/gccint/rtl-representation/rtl-object-types.rst new file mode 100644 index 00000000000..6ec8921b7bd --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/rtl-object-types.rst @@ -0,0 +1,84 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RTL object types, RTL integers, RTL strings, RTL vectors, RTL expression, RTX (See RTL) + +.. _rtl-objects: + +RTL Object Types +**************** + +RTL uses five kinds of objects: expressions, integers, wide integers, +strings and vectors. Expressions are the most important ones. An RTL +expression ('RTX', for short) is a C structure, but it is usually +referred to with a pointer; a type that is given the typedef name +``rtx``. + +An integer is simply an ``int`` ; their written form uses decimal +digits. A wide integer is an integral object whose type is +``HOST_WIDE_INT`` ; their written form uses decimal digits. + +A string is a sequence of characters. In core it is represented as a +``char *`` in usual C fashion, and it is written in C syntax as well. +However, strings in RTL may never be null. If you write an empty string in +a machine description, it is represented in core as a null pointer rather +than as a pointer to a null character. In certain contexts, these null +pointers instead of strings are valid. Within RTL code, strings are most +commonly found inside ``symbol_ref`` expressions, but they appear in +other contexts in the RTL expressions that make up machine descriptions. + +In a machine description, strings are normally written with double +quotes, as you would in C. However, strings in machine descriptions may +extend over many lines, which is invalid C, and adjacent string +constants are not concatenated as they are in C. Any string constant +may be surrounded with a single set of parentheses. Sometimes this +makes the machine description easier to read. + +There is also a special syntax for strings, which can be useful when C +code is embedded in a machine description. Wherever a string can +appear, it is also valid to write a C-style brace block. The entire +brace block, including the outermost pair of braces, is considered to be +the string constant. Double quote characters inside the braces are not +special. Therefore, if you write string constants in the C code, you +need not escape each quote character with a backslash. + +A vector contains an arbitrary number of pointers to expressions. The +number of elements in the vector is explicitly present in the vector. +The written form of a vector consists of square brackets +(:samp:`[...]`) surrounding the elements, in sequence and with +whitespace separating them. Vectors of length zero are not created; +null pointers are used instead. + +.. index:: expression codes, codes, RTL expression, GET_CODE, PUT_CODE + +Expressions are classified by :dfn:`expression codes` (also called RTX +codes). The expression code is a name defined in :samp:`rtl.def`, which is +also (in uppercase) a C enumeration constant. The possible expression +codes and their meanings are machine-independent. The code of an RTX can +be extracted with the macro ``GET_CODE (x)`` and altered with +``PUT_CODE (x, newcode)``. + +The expression code determines how many operands the expression contains, +and what kinds of objects they are. In RTL, unlike Lisp, you cannot tell +by looking at an operand what kind of object it is. Instead, you must know +from its context---from the expression code of the containing expression. +For example, in an expression of code ``subreg``, the first operand is +to be regarded as an expression and the second operand as a polynomial +integer. In an expression of code ``plus``, there are two operands, +both of which are to be regarded as expressions. In a ``symbol_ref`` +expression, there is one operand, which is to be regarded as a string. + +Expressions are written as parentheses containing the name of the +expression type, its flags and machine mode if any, and then the operands +of the expression (separated by spaces). + +Expression code names in the :samp:`md` file are written in lowercase, +but when they appear in C code they are written in uppercase. In this +manual, they are shown as follows: ``const_int``. + +.. index:: (nil), nil + +In a few contexts a null pointer is valid where an expression is normally +wanted. The written form of this is ``(nil)``. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/rtl-representation-of-function-call-insns.rst b/gcc/doc/gccint/rtl-representation/rtl-representation-of-function-call-insns.rst new file mode 100644 index 00000000000..e7abb63937e --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/rtl-representation-of-function-call-insns.rst @@ -0,0 +1,72 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: calling functions in RTL, RTL function-call insns, function-call insns + +.. _calls: + +RTL Representation of Function-Call Insns +***************************************** + +Insns that call subroutines have the RTL expression code ``call_insn``. +These insns must satisfy special rules, and their bodies must use a special +RTL expression code, ``call``. + +.. index:: call usage + +A ``call`` expression has two operands, as follows: + +.. code-block:: c++ + + (call (mem:fm addr) nbytes) + +Here :samp:`{nbytes}` is an operand that represents the number of bytes of +argument data being passed to the subroutine, :samp:`{fm}` is a machine mode +(which must equal as the definition of the ``FUNCTION_MODE`` macro in +the machine description) and :samp:`{addr}` represents the address of the +subroutine. + +For a subroutine that returns no value, the ``call`` expression as +shown above is the entire body of the insn, except that the insn might +also contain ``use`` or ``clobber`` expressions. + +.. index:: BLKmode, and function return values + +For a subroutine that returns a value whose mode is not ``BLKmode``, +the value is returned in a hard register. If this register's number is +:samp:`{r}`, then the body of the call insn looks like this: + +.. code-block:: c++ + + (set (reg:m r) + (call (mem:fm addr) nbytes)) + +This RTL expression makes it clear (to the optimizer passes) that the +appropriate register receives a useful value in this insn. + +When a subroutine returns a ``BLKmode`` value, it is handled by +passing to the subroutine the address of a place to store the value. +So the call insn itself does not 'return' any value, and it has the +same RTL form as a call that returns nothing. + +On some machines, the call instruction itself clobbers some register, +for example to contain the return address. ``call_insn`` insns +on these machines should have a body which is a ``parallel`` +that contains both the ``call`` expression and ``clobber`` +expressions that indicate which registers are destroyed. Similarly, +if the call instruction requires some register other than the stack +pointer that is not explicitly mentioned in its RTL, a ``use`` +subexpression should mention that register. + +Functions that are called are assumed to modify all registers listed in +the configuration macro ``CALL_USED_REGISTERS`` (see :ref:`register-basics`) and, with the exception of ``const`` functions and library +calls, to modify all of memory. + +Insns containing just ``use`` expressions directly precede the +``call_insn`` insn to indicate which registers contain inputs to the +function. Similarly, if registers other than those in +``CALL_USED_REGISTERS`` are clobbered by the called function, insns +containing a single ``clobber`` follow immediately after the call to +indicate which registers. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/side-effect-expressions.rst b/gcc/doc/gccint/rtl-representation/side-effect-expressions.rst new file mode 100644 index 00000000000..3d768102d49 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/side-effect-expressions.rst @@ -0,0 +1,374 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RTL side effect expressions + +.. _side-effects: + +Side Effect Expressions +*********************** + +The expression codes described so far represent values, not actions. +But machine instructions never produce values; they are meaningful +only for their side effects on the state of the machine. Special +expression codes are used to represent side effects. + +The body of an instruction is always one of these side effect codes; +the codes described above, which represent values, appear only as +the operands of these. + +.. index:: set + +:samp:`(set {lval} {x})` + Represents the action of storing the value of :samp:`{x}` into the place + represented by :samp:`{lval}`. :samp:`{lval}` must be an expression + representing a place that can be stored in: ``reg`` (or ``subreg``, + ``strict_low_part`` or ``zero_extract``), ``mem``, ``pc``, + or ``parallel``. + + If :samp:`{lval}` is a ``reg``, ``subreg`` or ``mem``, it has a + machine mode; then :samp:`{x}` must be valid for that mode. + + If :samp:`{lval}` is a ``reg`` whose machine mode is less than the full + width of the register, then it means that the part of the register + specified by the machine mode is given the specified value and the + rest of the register receives an undefined value. Likewise, if + :samp:`{lval}` is a ``subreg`` whose machine mode is narrower than + the mode of the register, the rest of the register can be changed in + an undefined way. + + If :samp:`{lval}` is a ``strict_low_part`` of a subreg, then the part + of the register specified by the machine mode of the ``subreg`` is + given the value :samp:`{x}` and the rest of the register is not changed. + + If :samp:`{lval}` is a ``zero_extract``, then the referenced part of + the bit-field (a memory or register reference) specified by the + ``zero_extract`` is given the value :samp:`{x}` and the rest of the + bit-field is not changed. Note that ``sign_extract`` cannot + appear in :samp:`{lval}`. + + If :samp:`{lval}` is a ``parallel``, it is used to represent the case of + a function returning a structure in multiple registers. Each element + of the ``parallel`` is an ``expr_list`` whose first operand is a + ``reg`` and whose second operand is a ``const_int`` representing the + offset (in bytes) into the structure at which the data in that register + corresponds. The first element may be null to indicate that the structure + is also passed partly in memory. + + .. index:: jump instructions and set, if_then_else usage + + If :samp:`{lval}` is ``(pc)``, we have a jump instruction, and the + possibilities for :samp:`{x}` are very limited. It may be a + ``label_ref`` expression (unconditional jump). It may be an + ``if_then_else`` (conditional jump), in which case either the + second or the third operand must be ``(pc)`` (for the case which + does not jump) and the other of the two must be a ``label_ref`` + (for the case which does jump). :samp:`{x}` may also be a ``mem`` or + ``(plus:SI (pc) y)``, where :samp:`{y}` may be a ``reg`` or a + ``mem`` ; these unusual patterns are used to represent jumps through + branch tables. + + If :samp:`{lval}` is not ``(pc)``, the mode of + :samp:`{lval}` must not be ``VOIDmode`` and the mode of :samp:`{x}` must be + valid for the mode of :samp:`{lval}`. + + .. index:: SET_DEST, SET_SRC + + :samp:`{lval}` is customarily accessed with the ``SET_DEST`` macro and + :samp:`{x}` with the ``SET_SRC`` macro. + + .. index:: return + +``(return)`` + As the sole expression in a pattern, represents a return from the + current function, on machines where this can be done with one + instruction, such as VAXen. On machines where a multi-instruction + 'epilogue' must be executed in order to return from the function, + returning is done by jumping to a label which precedes the epilogue, and + the ``return`` expression code is never used. + + Inside an ``if_then_else`` expression, represents the value to be + placed in ``pc`` to return to the caller. + + Note that an insn pattern of ``(return)`` is logically equivalent to + ``(set (pc) (return))``, but the latter form is never used. + + .. index:: simple_return + +``(simple_return)`` + Like ``(return)``, but truly represents only a function return, while + ``(return)`` may represent an insn that also performs other functions + of the function epilogue. Like ``(return)``, this may also occur in + conditional jumps. + + .. index:: call + +:samp:`(call {function} {nargs})` + Represents a function call. :samp:`{function}` is a ``mem`` expression + whose address is the address of the function to be called. + :samp:`{nargs}` is an expression which can be used for two purposes: on + some machines it represents the number of bytes of stack argument; on + others, it represents the number of argument registers. + + Each machine has a standard machine mode which :samp:`{function}` must + have. The machine description defines macro ``FUNCTION_MODE`` to + expand into the requisite mode name. The purpose of this mode is to + specify what kind of addressing is allowed, on machines where the + allowed kinds of addressing depend on the machine mode being + addressed. + + .. index:: clobber + +:samp:`(clobber {x})` + Represents the storing or possible storing of an unpredictable, + undescribed value into :samp:`{x}`, which must be a ``reg``, + ``scratch``, ``parallel`` or ``mem`` expression. + + One place this is used is in string instructions that store standard + values into particular hard registers. It may not be worth the + trouble to describe the values that are stored, but it is essential to + inform the compiler that the registers will be altered, lest it + attempt to keep data in them across the string instruction. + + If :samp:`{x}` is ``(mem:BLK (const_int 0))`` or + ``(mem:BLK (scratch))``, it means that all memory + locations must be presumed clobbered. If :samp:`{x}` is a ``parallel``, + it has the same meaning as a ``parallel`` in a ``set`` expression. + + Note that the machine description classifies certain hard registers as + 'call-clobbered'. All function call instructions are assumed by + default to clobber these registers, so there is no need to use + ``clobber`` expressions to indicate this fact. Also, each function + call is assumed to have the potential to alter any memory location, + unless the function is declared ``const``. + + If the last group of expressions in a ``parallel`` are each a + ``clobber`` expression whose arguments are ``reg`` or + ``match_scratch`` (see :ref:`rtl-template`) expressions, the combiner + phase can add the appropriate ``clobber`` expressions to an insn it + has constructed when doing so will cause a pattern to be matched. + + This feature can be used, for example, on a machine that whose multiply + and add instructions don't use an MQ register but which has an + add-accumulate instruction that does clobber the MQ register. Similarly, + a combined instruction might require a temporary register while the + constituent instructions might not. + + When a ``clobber`` expression for a register appears inside a + ``parallel`` with other side effects, the register allocator + guarantees that the register is unoccupied both before and after that + insn if it is a hard register clobber. For pseudo-register clobber, + the register allocator and the reload pass do not assign the same hard + register to the clobber and the input operands if there is an insn + alternative containing the :samp:`&` constraint (see :ref:`modifiers`) for + the clobber and the hard register is in register classes of the + clobber in the alternative. You can clobber either a specific hard + register, a pseudo register, or a ``scratch`` expression; in the + latter two cases, GCC will allocate a hard register that is available + there for use as a temporary. + + For instructions that require a temporary register, you should use + ``scratch`` instead of a pseudo-register because this will allow the + combiner phase to add the ``clobber`` when required. You do this by + coding (``clobber`` (``match_scratch`` ...)). If you do + clobber a pseudo register, use one which appears nowhere else---generate + a new one each time. Otherwise, you may confuse CSE. + + There is one other known use for clobbering a pseudo register in a + ``parallel`` : when one of the input operands of the insn is also + clobbered by the insn. In this case, using the same pseudo register in + the clobber and elsewhere in the insn produces the expected results. + + .. index:: use + +:samp:`(use {x})` + Represents the use of the value of :samp:`{x}`. It indicates that the + value in :samp:`{x}` at this point in the program is needed, even though + it may not be apparent why this is so. Therefore, the compiler will + not attempt to delete previous instructions whose only effect is to + store a value in :samp:`{x}`. :samp:`{x}` must be a ``reg`` expression. + + In some situations, it may be tempting to add a ``use`` of a + register in a ``parallel`` to describe a situation where the value + of a special register will modify the behavior of the instruction. + A hypothetical example might be a pattern for an addition that can + either wrap around or use saturating addition depending on the value + of a special control register: + + .. code-block:: c++ + + (parallel [(set (reg:SI 2) (unspec:SI [(reg:SI 3) + (reg:SI 4)] 0)) + (use (reg:SI 1))]) + + This will not work, several of the optimizers only look at expressions + locally; it is very likely that if you have multiple insns with + identical inputs to the ``unspec``, they will be optimized away even + if register 1 changes in between. + + This means that ``use`` can *only* be used to describe + that the register is live. You should think twice before adding + ``use`` statements, more often you will want to use ``unspec`` + instead. The ``use`` RTX is most commonly useful to describe that + a fixed register is implicitly used in an insn. It is also safe to use + in patterns where the compiler knows for other reasons that the result + of the whole pattern is variable, such as :samp:`cpymem{m}` or + :samp:`call` patterns. + + During the reload phase, an insn that has a ``use`` as pattern + can carry a reg_equal note. These ``use`` insns will be deleted + before the reload phase exits. + + During the delayed branch scheduling phase, :samp:`{x}` may be an insn. + This indicates that :samp:`{x}` previously was located at this place in the + code and its data dependencies need to be taken into account. These + ``use`` insns will be deleted before the delayed branch scheduling + phase exits. + + .. index:: parallel + +:samp:`(parallel [{x0} {x1} ...])` + Represents several side effects performed in parallel. The square + brackets stand for a vector; the operand of ``parallel`` is a + vector of expressions. :samp:`{x0}`, :samp:`{x1}` and so on are individual + side effect expressions---expressions of code ``set``, ``call``, + ``return``, ``simple_return``, ``clobber`` or ``use``. + + 'In parallel' means that first all the values used in the individual + side-effects are computed, and second all the actual side-effects are + performed. For example, + + .. code-block:: c++ + + (parallel [(set (reg:SI 1) (mem:SI (reg:SI 1))) + (set (mem:SI (reg:SI 1)) (reg:SI 1))]) + + says unambiguously that the values of hard register 1 and the memory + location addressed by it are interchanged. In both places where + ``(reg:SI 1)`` appears as a memory address it refers to the value + in register 1 *before* the execution of the insn. + + It follows that it is *incorrect* to use ``parallel`` and + expect the result of one ``set`` to be available for the next one. + For example, people sometimes attempt to represent a jump-if-zero + instruction this way: + + .. code-block:: c++ + + (parallel [(set (reg:CC CC_REG) (reg:SI 34)) + (set (pc) (if_then_else + (eq (reg:CC CC_REG) (const_int 0)) + (label_ref ...) + (pc)))]) + + But this is incorrect, because it says that the jump condition depends + on the condition code value *before* this instruction, not on the + new value that is set by this instruction. + + .. index:: peephole optimization, RTL representation + + Peephole optimization, which takes place together with final assembly + code output, can produce insns whose patterns consist of a ``parallel`` + whose elements are the operands needed to output the resulting + assembler code---often ``reg``, ``mem`` or constant expressions. + This would not be well-formed RTL at any other stage in compilation, + but it is OK then because no further optimization remains to be done. + + .. index:: cond_exec + +:samp:`(cond_exec [{cond} {expr}])` + Represents a conditionally executed expression. The :samp:`{expr}` is + executed only if the :samp:`{cond}` is nonzero. The :samp:`{cond}` expression + must not have side-effects, but the :samp:`{expr}` may very well have + side-effects. + + .. index:: sequence + +:samp:`(sequence [{insns} ...])` + Represents a sequence of insns. If a ``sequence`` appears in the + chain of insns, then each of the :samp:`{insns}` that appears in the sequence + must be suitable for appearing in the chain of insns, i.e. must satisfy + the ``INSN_P`` predicate. + + After delay-slot scheduling is completed, an insn and all the insns that + reside in its delay slots are grouped together into a ``sequence``. + The insn requiring the delay slot is the first insn in the vector; + subsequent insns are to be placed in the delay slot. + + ``INSN_ANNULLED_BRANCH_P`` is set on an insn in a delay slot to + indicate that a branch insn should be used that will conditionally annul + the effect of the insns in the delay slots. In such a case, + ``INSN_FROM_TARGET_P`` indicates that the insn is from the target of + the branch and should be executed only if the branch is taken; otherwise + the insn should be executed only if the branch is not taken. + See :ref:`delay-slots`. + + Some back ends also use ``sequence`` objects for purposes other than + delay-slot groups. This is not supported in the common parts of the + compiler, which treat such sequences as delay-slot groups. + + DWARF2 Call Frame Address (CFA) adjustments are sometimes also expressed + using ``sequence`` objects as the value of a ``RTX_FRAME_RELATED_P`` + note. This only happens if the CFA adjustments cannot be easily derived + from the pattern of the instruction to which the note is attached. In + such cases, the value of the note is used instead of best-guesing the + semantics of the instruction. The back end can attach notes containing + a ``sequence`` of ``set`` patterns that express the effect of the + parent instruction. + + These expression codes appear in place of a side effect, as the body of + an insn, though strictly speaking they do not always describe side + effects as such: + +.. index:: asm_input + +:samp:`(asm_input {s})` + Represents literal assembler code as described by the string :samp:`{s}`. + + .. index:: unspec, unspec_volatile + +:samp:`(unspec [{operands} ...] {index})` :samp:`(unspec_volatile [{operands} ...] {index})` + Represents a machine-specific operation on :samp:`{operands}`. :samp:`{index}` + selects between multiple machine-specific operations. + ``unspec_volatile`` is used for volatile operations and operations + that may trap; ``unspec`` is used for other operations. + + These codes may appear inside a ``pattern`` of an + insn, inside a ``parallel``, or inside an expression. + + .. index:: addr_vec + +:samp:`(addr_vec:{m} [{lr0} {lr1} ...])` + Represents a table of jump addresses. The vector elements :samp:`{lr0}`, + etc., are ``label_ref`` expressions. The mode :samp:`{m}` specifies + how much space is given to each address; normally :samp:`{m}` would be + ``Pmode``. + + .. index:: addr_diff_vec + +:samp:`(addr_diff_vec:{m} {base} [{lr0} {lr1} ...] {min} {max} {flags})` + Represents a table of jump addresses expressed as offsets from + :samp:`{base}`. The vector elements :samp:`{lr0}`, etc., are ``label_ref`` + expressions and so is :samp:`{base}`. The mode :samp:`{m}` specifies how much + space is given to each address-difference. :samp:`{min}` and :samp:`{max}` + are set up by branch shortening and hold a label with a minimum and a + maximum address, respectively. :samp:`{flags}` indicates the relative + position of :samp:`{base}`, :samp:`{min}` and :samp:`{max}` to the containing insn + and of :samp:`{min}` and :samp:`{max}` to :samp:`{base}`. See rtl.def for details. + + .. index:: prefetch + +:samp:`(prefetch:{m} {addr} {rw} {locality})` + Represents prefetch of memory at address :samp:`{addr}`. + Operand :samp:`{rw}` is 1 if the prefetch is for data to be written, 0 otherwise; + targets that do not support write prefetches should treat this as a normal + prefetch. + Operand :samp:`{locality}` specifies the amount of temporal locality; 0 if there + is none or 1, 2, or 3 for increasing levels of temporal locality; + targets that do not support locality hints should ignore this. + + This insn is used to minimize cache-miss latency by moving data into a + cache before it is accessed. It should use only non-faulting data prefetch + instructions. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/structure-sharing-assumptions.rst b/gcc/doc/gccint/rtl-representation/structure-sharing-assumptions.rst new file mode 100644 index 00000000000..34f33fc817d --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/structure-sharing-assumptions.rst @@ -0,0 +1,99 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: sharing of RTL components, RTL structure sharing assumptions + +.. _sharing: + +Structure Sharing Assumptions +***************************** + +The compiler assumes that certain kinds of RTL expressions are unique; +there do not exist two distinct objects representing the same value. +In other cases, it makes an opposite assumption: that no RTL expression +object of a certain kind appears in more than one place in the +containing structure. + +These assumptions refer to a single function; except for the RTL +objects that describe global variables and external functions, +and a few standard objects such as small integer constants, +no RTL objects are common to two functions. + +.. index:: reg, RTL sharing + +* Each pseudo-register has only a single ``reg`` object to represent it, + and therefore only a single machine mode. + + .. index:: symbolic label, symbol_ref, RTL sharing + +* For any symbolic label, there is only one ``symbol_ref`` object + referring to it. + + .. index:: const_int, RTL sharing + +* All ``const_int`` expressions with equal values are shared. + + .. index:: const_poly_int, RTL sharing + +* All ``const_poly_int`` expressions with equal modes and values + are shared. + + .. index:: pc, RTL sharing + +* There is only one ``pc`` expression. + + .. index:: const_double, RTL sharing + +* There is only one ``const_double`` expression with value 0 for + each floating point mode. Likewise for values 1 and 2. + + .. index:: const_vector, RTL sharing + +* There is only one ``const_vector`` expression with value 0 for + each vector mode, be it an integer or a double constant vector. + + .. index:: label_ref, RTL sharing, scratch, RTL sharing + +* No ``label_ref`` or ``scratch`` appears in more than one place in + the RTL structure; in other words, it is safe to do a tree-walk of all + the insns in the function and assume that each time a ``label_ref`` + or ``scratch`` is seen it is distinct from all others that are seen. + + .. index:: mem, RTL sharing + +* Only one ``mem`` object is normally created for each static + variable or stack slot, so these objects are frequently shared in all + the places they appear. However, separate but equal objects for these + variables are occasionally made. + + .. index:: asm_operands, RTL sharing + +* When a single ``asm`` statement has multiple output operands, a + distinct ``asm_operands`` expression is made for each output operand. + However, these all share the vector which contains the sequence of input + operands. This sharing is used later on to test whether two + ``asm_operands`` expressions come from the same statement, so all + optimizations must carefully preserve the sharing if they copy the + vector at all. + +* No RTL object appears in more than one place in the RTL structure + except as described above. Many passes of the compiler rely on this + by assuming that they can modify RTL objects in place without unwanted + side-effects on other insns. + + .. index:: unshare_all_rtl + +* During initial RTL generation, shared structure is freely introduced. + After all the RTL for a function has been generated, all shared + structure is copied by ``unshare_all_rtl`` in :samp:`emit-rtl.cc`, + after which the above rules are guaranteed to be followed. + + .. index:: copy_rtx_if_shared + +* During the combiner pass, shared structure within an insn can exist + temporarily. However, the shared structure is copied before the + combiner is finished with the insn. This is done by calling + ``copy_rtx_if_shared``, which is a subroutine of + ``unshare_all_rtl``. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/variable-location-debug-information-in-rtl.rst b/gcc/doc/gccint/rtl-representation/variable-location-debug-information-in-rtl.rst new file mode 100644 index 00000000000..77c20210193 --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/variable-location-debug-information-in-rtl.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Variable Location Debug Information in RTL + +.. _debug-information: + +Variable Location Debug Information in RTL +****************************************** + +Variable tracking relies on ``MEM_EXPR`` and ``REG_EXPR`` +annotations to determine what user variables memory and register +references refer to. + +Variable tracking at assignments uses these notes only when they refer +to variables that live at fixed locations (e.g., addressable +variables, global non-automatic variables). For variables whose +location may vary, it relies on the following types of notes. + +.. index:: var_location + +:samp:`(var_location:{mode} {var} {exp} {stat})` + Binds variable ``var``, a tree, to value :samp:`{exp}`, an RTL + expression. It appears only in ``NOTE_INSN_VAR_LOCATION`` and + ``DEBUG_INSN`` s, with slightly different meanings. :samp:`{mode}`, if + present, represents the mode of :samp:`{exp}`, which is useful if it is a + modeless expression. :samp:`{stat}` is only meaningful in notes, + indicating whether the variable is known to be initialized or + uninitialized. + + .. index:: debug_expr + +:samp:`(debug_expr:{mode} {decl})` + Stands for the value bound to the ``DEBUG_EXPR_DECL`` :samp:`{decl}`, + that points back to it, within value expressions in + ``VAR_LOCATION`` nodes. + + .. index:: debug_implicit_ptr + +:samp:`(debug_implicit_ptr:{mode} {decl})` + Stands for the location of a :samp:`{decl}` that is no longer addressable. + + .. index:: entry_value + +:samp:`(entry_value:{mode} {decl})` + Stands for the value a :samp:`{decl}` had at the entry point of the + containing function. + + .. index:: debug_parameter_ref + +:samp:`(debug_parameter_ref:{mode} {decl})` + Refers to a parameter that was completely optimized out. + + .. index:: debug_marker + +:samp:`(debug_marker:{mode})` + Marks a program location. With ``VOIDmode``, it stands for the + beginning of a statement, a recommended inspection point logically after + all prior side effects, and before any subsequent side effects. With + ``BLKmode``, it indicates an inline entry point: the lexical block + encoded in the ``INSN_LOCATION`` is the enclosing block that encloses + the inlined function. \ No newline at end of file diff --git a/gcc/doc/gccint/rtl-representation/vector-operations.rst b/gcc/doc/gccint/rtl-representation/vector-operations.rst new file mode 100644 index 00000000000..2062342f6de --- /dev/null +++ b/gcc/doc/gccint/rtl-representation/vector-operations.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: vector operations + +.. _vector-operations: + +Vector Operations +***************** + +All normal RTL expressions can be used with vector modes; they are +interpreted as operating on each part of the vector independently. +Additionally, there are a few new expressions to describe specific vector +operations. + +.. index:: vec_merge + +:samp:`(vec_merge:{m} {vec1} {vec2} {items})` + This describes a merge operation between two vectors. The result is a vector + of mode :samp:`{m}` ; its elements are selected from either :samp:`{vec1}` or + :samp:`{vec2}`. Which elements are selected is described by :samp:`{items}`, which + is a bit mask represented by a ``const_int`` ; a zero bit indicates the + corresponding element in the result vector is taken from :samp:`{vec2}` while + a set bit indicates it is taken from :samp:`{vec1}`. + + .. index:: vec_select + +:samp:`(vec_select:{m} {vec1} {selection})` + This describes an operation that selects parts of a vector. :samp:`{vec1}` is + the source vector, and :samp:`{selection}` is a ``parallel`` that contains a + ``const_int`` (or another expression, if the selection can be made at + runtime) for each of the subparts of the result vector, giving the number of + the source subpart that should be stored into it. The result mode :samp:`{m}` is + either the submode for a single element of :samp:`{vec1}` (if only one subpart is + selected), or another vector mode with that element submode (if multiple + subparts are selected). + + .. index:: vec_concat + +:samp:`(vec_concat:{m} {x1} {x2})` + Describes a vector concat operation. The result is a concatenation of the + vectors or scalars :samp:`{x1}` and :samp:`{x2}` ; its length is the sum of the + lengths of the two inputs. + + .. index:: vec_duplicate + +:samp:`(vec_duplicate:{m} {x})` + This operation converts a scalar into a vector or a small vector into a + larger one by duplicating the input values. The output vector mode must have + the same submodes as the input vector mode or the scalar modes, and the + number of output parts must be an integer multiple of the number of input + parts. + + .. index:: vec_series + +:samp:`(vec_series:{m} {base} {step})` + This operation creates a vector in which element :samp:`{i}` is equal to + :samp:`{base} + {i}*{step}`. :samp:`{m}` must be a vector integer mode. \ No newline at end of file diff --git a/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants.rst b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants.rst new file mode 100644 index 00000000000..38df171ff12 --- /dev/null +++ b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: polynomial integers, poly_int + +.. _poly_int: + +Sizes and offsets as runtime invariants +--------------------------------------- + +GCC allows the size of a hardware register to be a runtime invariant +rather than a compile-time constant. This in turn means that various +sizes and offsets must also be runtime invariants rather than +compile-time constants, such as: + +* the size of a general ``machine_mode`` (see :ref:`machine-modes`); + +* the size of a spill slot; + +* the offset of something within a stack frame; + +* the number of elements in a vector; + +* the size and offset of a ``mem`` rtx (see :ref:`regs-and-memory`); and + +* the byte offset in a ``subreg`` rtx (see :ref:`regs-and-memory`). + +The motivating example is the Arm SVE ISA, whose vector registers can be +any multiple of 128 bits between 128 and 2048 inclusive. The compiler +normally produces code that works for all SVE register sizes, with the +actual size only being known at runtime. + +GCC's main representation of such runtime invariants is the +``poly_int`` class. This chapter describes what ``poly_int`` +does, lists the available operations, and gives some general +usage guidelines. + +.. toctree:: + :maxdepth: 2 + + sizes-and-offsets-as-runtime-invariants/overview-of-polyint + sizes-and-offsets-as-runtime-invariants/consequences-of-using-polyint + sizes-and-offsets-as-runtime-invariants/comparisons-involving-polyint + sizes-and-offsets-as-runtime-invariants/arithmetic-on-polyints + sizes-and-offsets-as-runtime-invariants/alignment-of-polyints + sizes-and-offsets-as-runtime-invariants/computing-bounds-on-polyints + sizes-and-offsets-as-runtime-invariants/converting-polyints + sizes-and-offsets-as-runtime-invariants/miscellaneous-polyint-routines + sizes-and-offsets-as-runtime-invariants/guidelines-for-using-polyint \ No newline at end of file diff --git a/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/alignment-of-polyints.rst b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/alignment-of-polyints.rst new file mode 100644 index 00000000000..ba65ab3dc20 --- /dev/null +++ b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/alignment-of-polyints.rst @@ -0,0 +1,84 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _alignment-of-poly_ints: + +Alignment of poly_ints +********************** + +``poly_int`` provides various routines for aligning values and for querying +misalignments. In each case the alignment must be a power of 2. + +:samp:`can_align_p ({value}, {align})` + Return true if we can align :samp:`{value}` up or down to the nearest multiple + of :samp:`{align}` at compile time. The answer is the same for both directions. + +:samp:`can_align_down ({value}, {align}, &{aligned})` + Return true if ``can_align_p`` ; if so, set :samp:`{aligned}` to the greatest + aligned value that is less than or equal to :samp:`{value}`. + +:samp:`can_align_up ({value}, {align}, &{aligned})` + Return true if ``can_align_p`` ; if so, set :samp:`{aligned}` to the lowest + aligned value that is greater than or equal to :samp:`{value}`. + +:samp:`known_equal_after_align_down ({a}, {b}, {align})` + Return true if we can align :samp:`{a}` and :samp:`{b}` down to the nearest + :samp:`{align}` boundary at compile time and if the two results are equal. + +:samp:`known_equal_after_align_up ({a}, {b}, {align})` + Return true if we can align :samp:`{a}` and :samp:`{b}` up to the nearest + :samp:`{align}` boundary at compile time and if the two results are equal. + +:samp:`aligned_lower_bound ({value}, {align})` + Return a result that is no greater than :samp:`{value}` and that is aligned + to :samp:`{align}`. The result will the closest aligned value for some + indeterminate values but not necessarily for all. + + For example, suppose we are allocating an object of :samp:`{size}` bytes + in a downward-growing stack whose current limit is given by :samp:`{limit}`. + If the object requires :samp:`{align}` bytes of alignment, the new stack + limit is given by: + + .. code-block:: c++ + + aligned_lower_bound (limit - size, align) + +:samp:`aligned_upper_bound ({value}, {align})` + Likewise return a result that is no less than :samp:`{value}` and that is + aligned to :samp:`{align}`. This is the routine that would be used for + upward-growing stacks in the scenario just described. + +:samp:`known_misalignment ({value}, {align}, &{misalign})` + Return true if we can calculate the misalignment of :samp:`{value}` + with respect to :samp:`{align}` at compile time, storing the result in + :samp:`{misalign}` if so. + +:samp:`known_alignment ({value})` + Return the minimum alignment that :samp:`{value}` is known to have + (in other words, the largest alignment that can be guaranteed + whatever the values of the indeterminates turn out to be). + Return 0 if :samp:`{value}` is known to be 0. + +:samp:`force_align_down ({value}, {align})` + Assert that :samp:`{value}` can be aligned down to :samp:`{align}` at compile + time and return the result. When using this routine, please add a + comment explaining why the assertion is known to hold. + +:samp:`force_align_up ({value}, {align})` + Likewise, but aligning up. + +:samp:`force_align_down_and_div ({value}, {align})` + Divide the result of ``force_align_down`` by :samp:`{align}`. Again, + please add a comment explaining why the assertion in ``force_align_down`` + is known to hold. + +:samp:`force_align_up_and_div ({value}, {align})` + Likewise for ``force_align_up``. + +:samp:`force_get_misalignment ({value}, {align})` + Assert that we can calculate the misalignment of :samp:`{value}` with + respect to :samp:`{align}` at compile time and return the misalignment. + When using this function, please add a comment explaining why + the assertion is known to hold. \ No newline at end of file diff --git a/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/arithmetic-on-polyints.rst b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/arithmetic-on-polyints.rst new file mode 100644 index 00000000000..e2324d774be --- /dev/null +++ b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/arithmetic-on-polyints.rst @@ -0,0 +1,178 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Arithmetic on poly_ints +*********************** + +Addition, subtraction, negation and bit inversion all work normally for +``poly_int`` s. Multiplication by a constant multiplier and left +shifting by a constant shift amount also work normally. General +multiplication of two ``poly_int`` s is not supported and is not +useful in practice. + +Other operations are only conditionally supported: the operation +might succeed or might fail, depending on the inputs. + +This section describes both types of operation. + +.. toctree:: + :maxdepth: 2 + + +Using poly_int with C++ arithmetic operators +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following C++ expressions are supported, where :samp:`{p1}` and :samp:`{p2}` +are ``poly_int`` s and where :samp:`{c1}` and :samp:`{c2}` are scalars: + +.. code-block:: c++ + + -p1 + ~p1 + + p1 + p2 + p1 + c2 + c1 + p2 + + p1 - p2 + p1 - c2 + c1 - p2 + + c1 * p2 + p1 * c2 + + p1 << c2 + + p1 += p2 + p1 += c2 + + p1 -= p2 + p1 -= c2 + + p1 *= c2 + p1 <<= c2 + +These arithmetic operations handle integer ranks in a similar way +to C++. The main difference is that every coefficient narrower than +``HOST_WIDE_INT`` promotes to ``HOST_WIDE_INT``, whereas in +C++ everything narrower than ``int`` promotes to ``int``. +For example: + +.. code-block:: c++ + + poly_uint16 + int -> poly_int64 + unsigned int + poly_uint16 -> poly_int64 + poly_int64 + int -> poly_int64 + poly_int32 + poly_uint64 -> poly_uint64 + uint64 + poly_int64 -> poly_uint64 + poly_offset_int + int32 -> poly_offset_int + offset_int + poly_uint16 -> poly_offset_int + +In the first two examples, both coefficients are narrower than +``HOST_WIDE_INT``, so the result has coefficients of type +``HOST_WIDE_INT``. In the other examples, the coefficient +with the highest rank 'wins'. + +If one of the operands is ``wide_int`` or ``poly_wide_int``, +the rules are the same as for ``wide_int`` arithmetic. + +wi arithmetic on poly_ints +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +As well as the C++ operators, ``poly_int`` supports the following +``wi`` routines: + +.. code-block:: c++ + + wi::neg (p1, &overflow) + + wi::add (p1, p2) + wi::add (p1, c2) + wi::add (c1, p1) + wi::add (p1, p2, sign, &overflow) + + wi::sub (p1, p2) + wi::sub (p1, c2) + wi::sub (c1, p1) + wi::sub (p1, p2, sign, &overflow) + + wi::mul (p1, c2) + wi::mul (c1, p1) + wi::mul (p1, c2, sign, &overflow) + + wi::lshift (p1, c2) + +These routines just check whether overflow occurs on any individual +coefficient; it is not possible to know at compile time whether the +final runtime value would overflow. + +Division of poly_ints +^^^^^^^^^^^^^^^^^^^^^ + +Division of ``poly_int`` s is possible for certain inputs. The functions +for division return true if the operation is possible and in most cases +return the results by pointer. The routines are: + +:samp:`multiple_p ({a}, {b})` :samp:`multiple_p ({a}, {b}, &{quotient})` + Return true if :samp:`{a}` is an exact multiple of :samp:`{b}`, storing the result + in :samp:`{quotient}` if so. There are overloads for various combinations + of polynomial and constant :samp:`{a}`, :samp:`{b}` and :samp:`{quotient}`. + +:samp:`constant_multiple_p ({a}, {b})` :samp:`constant_multiple_p ({a}, {b}, &{quotient})` + Like ``multiple_p``, but also test whether the multiple is a + compile-time constant. + +:samp:`can_div_trunc_p ({a}, {b}, &{quotient})` :samp:`can_div_trunc_p ({a}, {b}, &{quotient}, &{remainder})` + Return true if we can calculate :samp:`trunc ({a} / {b})` at compile + time, storing the result in :samp:`{quotient}` and :samp:`{remainder}` if so. + +:samp:`can_div_away_from_zero_p ({a}, {b}, &{quotient})` + Return true if we can calculate :samp:`{a} / {b}` at compile time, + rounding away from zero. Store the result in :samp:`{quotient}` if so. + + Note that this is true if and only if ``can_div_trunc_p`` is true. + The only difference is in the rounding of the result. + + There is also an asserting form of division: + +:samp:`exact_div ({a}, {b})` + Assert that :samp:`{a}` is a multiple of :samp:`{b}` and return + :samp:`{a} / {b}`. The result is a ``poly_int`` if :samp:`{a}` + is a ``poly_int``. + +Other poly_int arithmetic +^^^^^^^^^^^^^^^^^^^^^^^^^ + +There are tentative routines for other operations besides division: + +:samp:`can_ior_p ({a}, {b}, &{result})` + Return true if we can calculate :samp:`{a} | {b}` at compile time, + storing the result in :samp:`{result}` if so. + + Also, ANDs with a value :samp:`(1 << {y}) - 1` or its inverse can be + treated as alignment operations. See :ref:`alignment-of-poly_ints`. + +In addition, the following miscellaneous routines are available: + +:samp:`coeff_gcd ({a})` + Return the greatest common divisor of all nonzero coefficients in + :samp:`{a}`, or zero if :samp:`{a}` is known to be zero. + +:samp:`common_multiple ({a}, {b})` + Return a value that is a multiple of both :samp:`{a}` and :samp:`{b}`, where + one value is a ``poly_int`` and the other is a scalar. The result + will be the least common multiple for some indeterminate values but + not necessarily for all. + +:samp:`force_common_multiple ({a}, {b})` + Return a value that is a multiple of both ``poly_int`` :samp:`{a}` and + ``poly_int`` :samp:`{b}`, asserting that such a value exists. The + result will be the least common multiple for some indeterminate values + but not necessarily for all. + + When using this routine, please add a comment explaining why the + assertion is known to hold. + + Please add any other operations that you find to be useful. \ No newline at end of file diff --git a/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/comparisons-involving-polyint.rst b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/comparisons-involving-polyint.rst new file mode 100644 index 00000000000..df32240a0d8 --- /dev/null +++ b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/comparisons-involving-polyint.rst @@ -0,0 +1,324 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Comparisons involving poly_int +****************************** + +In general we need to compare sizes and offsets in two situations: +those in which the values need to be ordered, and those in which +the values can be unordered. More loosely, the distinction is often +between values that have a definite link (usually because they refer to the +same underlying register or memory location) and values that have +no definite link. An example of the former is the relationship between +the inner and outer sizes of a subreg, where we must know at compile time +whether the subreg is paradoxical, partial, or complete. An example of +the latter is alias analysis: we might want to check whether two +arbitrary memory references overlap. + +Referring back to the examples in the previous section, it makes sense +to ask whether a memory reference of size :samp:`3 + 4{x}` overlaps +one of size :samp:`1 + 5{x}`, but it does not make sense to have a +subreg in which the outer mode has :samp:`3 + 4{x}` bytes and the +inner mode has :samp:`1 + 5{x}` bytes (or vice versa). Such subregs +are always invalid and should trigger an internal compiler error +if formed. + +The underlying operators are the same in both cases, but the distinction +affects how they are used. + +.. toctree:: + :maxdepth: 2 + +.. _comparison-functions-for-poly_int: + +Comparison functions for poly_int +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +``poly_int`` provides the following routines for checking whether +a particular condition 'may be' (might be) true: + +.. code-block:: c++ + + maybe_lt maybe_le maybe_eq maybe_ge maybe_gt + maybe_ne + +The functions have their natural meaning: + +:samp:`maybe_lt({a}, {b})` + Return true if :samp:`{a}` might be less than :samp:`{b}`. + +:samp:`maybe_le({a}, {b})` + Return true if :samp:`{a}` might be less than or equal to :samp:`{b}`. + +:samp:`maybe_eq({a}, {b})` + Return true if :samp:`{a}` might be equal to :samp:`{b}`. + +:samp:`maybe_ne({a}, {b})` + Return true if :samp:`{a}` might not be equal to :samp:`{b}`. + +:samp:`maybe_ge({a}, {b})` + Return true if :samp:`{a}` might be greater than or equal to :samp:`{b}`. + +:samp:`maybe_gt({a}, {b})` + Return true if :samp:`{a}` might be greater than :samp:`{b}`. + + For readability, ``poly_int`` also provides 'known' inverses of these functions: + +.. code-block:: c++ + + known_lt (a, b) == !maybe_ge (a, b) + known_le (a, b) == !maybe_gt (a, b) + known_eq (a, b) == !maybe_ne (a, b) + known_ge (a, b) == !maybe_lt (a, b) + known_gt (a, b) == !maybe_le (a, b) + known_ne (a, b) == !maybe_eq (a, b) + +Properties of the poly_int comparisons +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +All 'maybe' relations except ``maybe_ne`` are transitive, so for example: + +.. code-block:: c++ + + maybe_lt (a, b) && maybe_lt (b, c) implies maybe_lt (a, c) + +for all :samp:`{a}`, :samp:`{b}` and :samp:`{c}`. ``maybe_lt``, ``maybe_gt`` +and ``maybe_ne`` are irreflexive, so for example: + +.. code-block:: c++ + + !maybe_lt (a, a) + +is true for all :samp:`{a}`. ``maybe_le``, ``maybe_eq`` and ``maybe_ge`` +are reflexive, so for example: + +.. code-block:: c++ + + maybe_le (a, a) + +is true for all :samp:`{a}`. ``maybe_eq`` and ``maybe_ne`` are symmetric, so: + +.. code-block:: c++ + + maybe_eq (a, b) == maybe_eq (b, a) + maybe_ne (a, b) == maybe_ne (b, a) + +for all :samp:`{a}` and :samp:`{b}`. In addition: + +.. code-block:: c++ + + maybe_le (a, b) == maybe_lt (a, b) || maybe_eq (a, b) + maybe_ge (a, b) == maybe_gt (a, b) || maybe_eq (a, b) + maybe_lt (a, b) == maybe_gt (b, a) + maybe_le (a, b) == maybe_ge (b, a) + +However: + +.. code-block:: c++ + + maybe_le (a, b) && maybe_le (b, a) does not imply !maybe_ne (a, b) [== known_eq (a, b)] + maybe_ge (a, b) && maybe_ge (b, a) does not imply !maybe_ne (a, b) [== known_eq (a, b)] + +One example is again :samp:`{a} == 3 + 4{x}` +and :samp:`{b} == 1 + 5{x}`, where :samp:`maybe_le ({a}, {b})`, +:samp:`maybe_ge ({a}, {b})` and :samp:`maybe_ne ({a}, {b})` +all hold. ``maybe_le`` and ``maybe_ge`` are therefore not antisymetric +and do not form a partial order. + +From the above, it follows that: + +* All 'known' relations except ``known_ne`` are transitive. + +* ``known_lt``, ``known_ne`` and ``known_gt`` are irreflexive. + +* ``known_le``, ``known_eq`` and ``known_ge`` are reflexive. + +Also: + +.. code-block:: c++ + + known_lt (a, b) == known_gt (b, a) + known_le (a, b) == known_ge (b, a) + known_lt (a, b) implies !known_lt (b, a) [asymmetry] + known_gt (a, b) implies !known_gt (b, a) + known_le (a, b) && known_le (b, a) == known_eq (a, b) [== !maybe_ne (a, b)] + known_ge (a, b) && known_ge (b, a) == known_eq (a, b) [== !maybe_ne (a, b)] + +``known_le`` and ``known_ge`` are therefore antisymmetric and are +partial orders. However: + +.. code-block:: c++ + + known_le (a, b) does not imply known_lt (a, b) || known_eq (a, b) + known_ge (a, b) does not imply known_gt (a, b) || known_eq (a, b) + +For example, :samp:`known_le (4, 4 + 4{x})` holds because the runtime +indeterminate :samp:`{x}` is a nonnegative integer, but neither +``known_lt (4, 4 + 4x)`` nor ``known_eq (4, 4 + 4x)`` hold. + +Comparing potentially-unordered poly_ints +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In cases where there is no definite link between two ``poly_int`` s, +we can usually make a conservatively-correct assumption. For example, +the conservative assumption for alias analysis is that two references +*might* alias. + +One way of checking whether [ :samp:`{begin1}`, :samp:`{end1}`) might overlap +[ :samp:`{begin2}`, :samp:`{end2}`) using the ``poly_int`` comparisons is: + +.. code-block:: c++ + + maybe_gt (end1, begin2) && maybe_gt (end2, begin1) + +and another (equivalent) way is: + +.. code-block:: c++ + + !(known_le (end1, begin2) || known_le (end2, begin1)) + +However, in this particular example, it is better to use the range helper +functions instead. See :ref:`range-checks-on-poly_ints`. + +Comparing ordered poly_ints +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In cases where there is a definite link between two ``poly_int`` s, +such as the outer and inner sizes of subregs, we usually require the sizes +to be ordered by the ``known_le`` partial order. ``poly_int`` provides +the following utility functions for ordered values: + +:samp:`ordered_p ({a}, {b})` + Return true if :samp:`{a}` and :samp:`{b}` are ordered by the ``known_le`` + partial order. + +:samp:`ordered_min ({a}, {b})` + Assert that :samp:`{a}` and :samp:`{b}` are ordered by ``known_le`` and return the + minimum of the two. When using this function, please add a comment explaining + why the values are known to be ordered. + +:samp:`ordered_max ({a}, {b})` + Assert that :samp:`{a}` and :samp:`{b}` are ordered by ``known_le`` and return the + maximum of the two. When using this function, please add a comment explaining + why the values are known to be ordered. + + For example, if a subreg has an outer mode of size :samp:`{outer}` and an + inner mode of size :samp:`{inner}` : + +* the subreg is complete if known_eq (:samp:`{inner}`, :samp:`{outer}`) + +* otherwise, the subreg is paradoxical if known_le (:samp:`{inner}`, :samp:`{outer}`) + +* otherwise, the subreg is partial if known_le (:samp:`{outer}`, :samp:`{inner}`) + +* otherwise, the subreg is ill-formed + +Thus the subreg is only valid if +:samp:`ordered_p ({outer}, {inner})` is true. If this condition +is already known to be true then: + +* the subreg is complete if known_eq (:samp:`{inner}`, :samp:`{outer}`) + +* the subreg is paradoxical if maybe_lt (:samp:`{inner}`, :samp:`{outer}`) + +* the subreg is partial if maybe_lt (:samp:`{outer}`, :samp:`{inner}`) + +with the three conditions being mutually exclusive. + +Code that checks whether a subreg is valid would therefore generally +check whether ``ordered_p`` holds (in addition to whatever other +checks are required for subreg validity). Code that is dealing +with existing subregs can assert that ``ordered_p`` holds +and use either of the classifications above. + +Checking for a poly_int marker value +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +It is sometimes useful to have a special 'marker value' that is not +meant to be taken literally. For example, some code uses a size +of -1 to represent an unknown size, rather than having to carry around +a separate boolean to say whether the size is known. + +The best way of checking whether something is a marker value is +``known_eq``. Conversely the best way of checking whether something +is *not* a marker value is ``maybe_ne``. + +Thus in the size example just mentioned, :samp:`known_eq (size, -1)` would +check for an unknown size and :samp:`maybe_ne (size, -1)` would check for a +known size. + +.. _range-checks-on-poly_ints: + +Range checks on poly_ints +^^^^^^^^^^^^^^^^^^^^^^^^^ + +As well as the core comparisons +(see :ref:`comparison-functions-for-poly_int`), ``poly_int`` provides +utilities for various kinds of range check. In each case the range +is represented by a start position and a size rather than a start +position and an end position; this is because the former is used +much more often than the latter in GCC. Also, the sizes can be +-1 (or all ones for unsigned sizes) to indicate a range with a known +start position but an unknown size. All other sizes must be nonnegative. +A range of size 0 does not contain anything or overlap anything. + +:samp:`known_size_p ({size})` + Return true if :samp:`{size}` represents a known range size, false if it + is -1 or all ones (for signed and unsigned types respectively). + +:samp:`ranges_maybe_overlap_p ({pos1}, {size1}, {pos2}, {size2})` + Return true if the range described by :samp:`{pos1}` and :samp:`{size1}` *might* + overlap the range described by :samp:`{pos2}` and :samp:`{size2}` (in other words, + return true if we cannot prove that the ranges are disjoint). + +:samp:`ranges_known_overlap_p ({pos1}, {size1}, {pos2}, {size2})` + Return true if the range described by :samp:`{pos1}` and :samp:`{size1}` is known to + overlap the range described by :samp:`{pos2}` and :samp:`{size2}`. + +:samp:`known_subrange_p ({pos1}, {size1}, {pos2}, {size2})` + Return true if the range described by :samp:`{pos1}` and :samp:`{size1}` is known to + be contained in the range described by :samp:`{pos2}` and :samp:`{size2}`. + +:samp:`maybe_in_range_p ({value}, {pos}, {size})` + Return true if :samp:`{value}` *might* be in the range described by + :samp:`{pos}` and :samp:`{size}` (in other words, return true if we cannot + prove that :samp:`{value}` is outside that range). + +:samp:`known_in_range_p ({value}, {pos}, {size})` + Return true if :samp:`{value}` is known to be in the range described + by :samp:`{pos}` and :samp:`{size}`. + +:samp:`endpoint_representable_p ({pos}, {size})` + Return true if the range described by :samp:`{pos}` and :samp:`{size}` is + open-ended or if the endpoint (:samp:`{pos}` + :samp:`{size}`) is representable + in the same type as :samp:`{pos}` and :samp:`{size}`. The function returns false + if adding :samp:`{size}` to :samp:`{pos}` makes conceptual sense but could overflow. + + There is also a ``poly_int`` version of the ``IN_RANGE_P`` macro: + +:samp:`coeffs_in_range_p ({x}, {lower}, {upper})` + Return true if every coefficient of :samp:`{x}` is in the inclusive range + [ :samp:`{lower}`, :samp:`{upper}` ]. This function can be useful when testing + whether an operation would cause the values of coefficients to + overflow. + + Note that the function does not indicate whether :samp:`{x}` itself is in the + given range. :samp:`{x}` can be either a constant or a ``poly_int``. + +Sorting poly_ints +^^^^^^^^^^^^^^^^^ + +``poly_int`` provides the following routine for sorting: + +:samp:`compare_sizes_for_sort ({a}, {b})` + Compare :samp:`{a}` and :samp:`{b}` in reverse lexicographical order (that is, + compare the highest-indexed coefficients first). This can be useful when + sorting data structures, since it has the effect of separating constant + and non-constant values. If all values are nonnegative, the constant + values come first. + + Note that the values do not necessarily end up in numerical order. + For example, :samp:`1 + 1{x}` would come after :samp:`100` in the sort order, + but may well be less than :samp:`100` at run time. \ No newline at end of file diff --git a/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/computing-bounds-on-polyints.rst b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/computing-bounds-on-polyints.rst new file mode 100644 index 00000000000..596f26e44bf --- /dev/null +++ b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/computing-bounds-on-polyints.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Computing bounds on poly_ints +***************************** + +``poly_int`` also provides routines for calculating lower and upper bounds: + +:samp:`constant_lower_bound ({a})` + Assert that :samp:`{a}` is nonnegative and return the smallest value it can have. + +:samp:`constant_lower_bound_with_limit ({a}, {b})` + Return the least value :samp:`{a}` can have, given that the context in + which :samp:`{a}` appears guarantees that the answer is no less than :samp:`{b}`. + In other words, the caller is asserting that :samp:`{a}` is greater than or + equal to :samp:`{b}` even if :samp:`known_ge ({a}, {b})` doesn't hold. + +:samp:`constant_upper_bound_with_limit ({a}, {b})` + Return the greatest value :samp:`{a}` can have, given that the context in + which :samp:`{a}` appears guarantees that the answer is no greater than :samp:`{b}`. + In other words, the caller is asserting that :samp:`{a}` is less than or equal + to :samp:`{b}` even if :samp:`known_le ({a}, {b})` doesn't hold. + +:samp:`lower_bound ({a}, {b})` + Return a value that is always less than or equal to both :samp:`{a}` and :samp:`{b}`. + It will be the greatest such value for some indeterminate values + but necessarily for all. + +:samp:`upper_bound ({a}, {b})` + Return a value that is always greater than or equal to both :samp:`{a}` and + :samp:`{b}`. It will be the least such value for some indeterminate values + but necessarily for all. \ No newline at end of file diff --git a/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/consequences-of-using-polyint.rst b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/consequences-of-using-polyint.rst new file mode 100644 index 00000000000..7c6ebe518c6 --- /dev/null +++ b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/consequences-of-using-polyint.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Consequences of using poly_int +****************************** + +The two main consequences of using polynomial sizes and offsets are that: + +* there is no total ordering between the values at compile time, and + +* some operations might yield results that cannot be expressed as a + ``poly_int``. + +For example, if :samp:`{x}` is a runtime invariant, we cannot tell at +compile time whether: + +.. code-block:: c++ + + 3 + 4x <= 1 + 5x + +since the condition is false when :samp:`{x}` <= 1 and true when :samp:`{x}` >= 2. + +Similarly, ``poly_int`` cannot represent the result of: + +.. code-block:: c++ + + (3 + 4x) * (1 + 5x) + +since it cannot (and in practice does not need to) store powers greater +than one. It also cannot represent the result of: + +.. code-block:: c++ + + (3 + 4x) / (1 + 5x) + +The following sections describe how we deal with these restrictions. + +.. index:: poly_int, use in target-independent code + +As described earlier, a ``poly_int<1, T>`` has no indeterminates +and so degenerates to a compile-time constant of type :samp:`{T}`. It would +be possible in that case to do all normal arithmetic on the :samp:`{T}`, +and to compare the :samp:`{T}` using the normal C++ operators. We deliberately +prevent target-independent code from doing this, since the compiler needs +to support other ``poly_int`` as well, regardless of +the current target's ``NUM_POLY_INT_COEFFS``. + +.. index:: poly_int, use in target-specific code + +However, it would be very artificial to force target-specific code +to follow these restrictions if the target has no runtime indeterminates. +There is therefore an implicit conversion from ``poly_int<1, T>`` +to :samp:`{T}` when compiling target-specific translation units. \ No newline at end of file diff --git a/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/converting-polyints.rst b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/converting-polyints.rst new file mode 100644 index 00000000000..0f5703702bb --- /dev/null +++ b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/converting-polyints.rst @@ -0,0 +1,91 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Converting poly_ints +******************** + +A ``poly_int`` can be constructed from up to +:samp:`{n}` individual :samp:`{T}` coefficients, with the remaining coefficients +being implicitly zero. In particular, this means that every +``poly_int`` can be constructed from a single +scalar :samp:`{T}`, or something compatible with :samp:`{T}`. + +Also, a ``poly_int`` can be constructed from +a ``poly_int`` if :samp:`{T}` can be constructed +from :samp:`{U}`. + +The following functions provide other forms of conversion, +or test whether such a conversion would succeed. + +:samp:`{value}.is_constant ()` + Return true if ``poly_int`` :samp:`{value}` is a compile-time constant. + +:samp:`{value}.is_constant (&{c1})` + Return true if ``poly_int`` :samp:`{value}` is a compile-time constant, + storing it in :samp:`{c1}` if so. :samp:`{c1}` must be able to hold all + constant values of :samp:`{value}` without loss of precision. + +:samp:`{value}.to_constant ()` + Assert that :samp:`{value}` is a compile-time constant and return its value. + When using this function, please add a comment explaining why the + condition is known to hold (for example, because an earlier phase + of analysis rejected non-constants). + +:samp:`{value}.to_shwi (&{p2})` + Return true if :samp:`poly_int<{N}, {T}>` :samp:`{value}` can be + represented without loss of precision as a + :samp:`poly_int<{N}, ``HOST_WIDE_INT`` >`, storing it in that + form in :samp:`{p2}` if so. + +:samp:`{value}.to_uhwi (&{p2})` + Return true if :samp:`poly_int<{N}, {T}>` :samp:`{value}` can be + represented without loss of precision as a + :samp:`poly_int<{N}, ``unsigned HOST_WIDE_INT`` >`, storing it in that + form in :samp:`{p2}` if so. + +:samp:`{value}.force_shwi ()` + Forcibly convert each coefficient of :samp:`poly_int<{N}, {T}>` + :samp:`{value}` to ``HOST_WIDE_INT``, truncating any that are out of range. + Return the result as a :samp:`poly_int<{N}, ``HOST_WIDE_INT`` >`. + +:samp:`{value}.force_uhwi ()` + Forcibly convert each coefficient of :samp:`poly_int<{N}, {T}>` + :samp:`{value}` to ``unsigned HOST_WIDE_INT``, truncating any that are + out of range. Return the result as a + :samp:`poly_int<{N}, ``unsigned HOST_WIDE_INT`` >`. + +:samp:`wi::shwi ({value}, {precision})` + Return a ``poly_int`` with the same value as :samp:`{value}`, but with + the coefficients converted from ``HOST_WIDE_INT`` to ``wide_int``. + :samp:`{precision}` specifies the precision of the ``wide_int`` cofficients; + if this is wider than a ``HOST_WIDE_INT``, the coefficients of + :samp:`{value}` will be sign-extended to fit. + +:samp:`wi::uhwi ({value}, {precision})` + Like ``wi::shwi``, except that :samp:`{value}` has coefficients of + type ``unsigned HOST_WIDE_INT``. If :samp:`{precision}` is wider than + a ``HOST_WIDE_INT``, the coefficients of :samp:`{value}` will be + zero-extended to fit. + +:samp:`wi::sext ({value}, {precision})` + Return a ``poly_int`` of the same type as :samp:`{value}`, sign-extending + every coefficient from the low :samp:`{precision}` bits. This in effect + applies ``wi::sext`` to each coefficient individually. + +:samp:`wi::zext ({value}, {precision})` + Like ``wi::sext``, but for zero extension. + +:samp:`poly_wide_int::from ({value}, {precision}, {sign})` + Convert :samp:`{value}` to a ``poly_wide_int`` in which each coefficient + has :samp:`{precision}` bits. Extend the coefficients according to + :samp:`{sign}` if the coefficients have fewer bits. + +:samp:`poly_offset_int::from ({value}, {sign})` + Convert :samp:`{value}` to a ``poly_offset_int``, extending its coefficients + according to :samp:`{sign}` if they have fewer bits than ``offset_int``. + +:samp:`poly_widest_int::from ({value}, {sign})` + Convert :samp:`{value}` to a ``poly_widest_int``, extending its coefficients + according to :samp:`{sign}` if they have fewer bits than ``widest_int``. \ No newline at end of file diff --git a/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/guidelines-for-using-polyint.rst b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/guidelines-for-using-polyint.rst new file mode 100644 index 00000000000..84f7cdeefad --- /dev/null +++ b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/guidelines-for-using-polyint.rst @@ -0,0 +1,119 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Guidelines for using poly_int +***************************** + +One of the main design goals of ``poly_int`` was to make it easy +to write target-independent code that handles variable-sized registers +even when the current target has fixed-sized registers. There are two +aspects to this: + +* The set of ``poly_int`` operations should be complete enough that + the question in most cases becomes 'Can we do this operation on these + particular ``poly_int`` values? If not, bail out' rather than + 'Are these ``poly_int`` values constant? If so, do the operation, + otherwise bail out'. + +* If target-independent code compiles and runs correctly on a target + with one value of ``NUM_POLY_INT_COEFFS``, and if the code does not + use asserting functions like ``to_constant``, it is reasonable to + assume that the code also works on targets with other values of + ``NUM_POLY_INT_COEFFS``. There is no need to check this during + everyday development. + +So the general principle is: if target-independent code is dealing +with a ``poly_int`` value, it is better to operate on it as a +``poly_int`` if at all possible, choosing conservatively-correct +behavior if a particular operation fails. For example, the following +code handles an index ``pos`` into a sequence of vectors that each +have ``nunits`` elements: + +.. code-block:: c++ + + /* Calculate which vector contains the result, and which lane of + that vector we need. */ + if (!can_div_trunc_p (pos, nunits, &vec_entry, &vec_index)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "Cannot determine which vector holds the" + " final result.\n"); + return false; + } + +However, there are some contexts in which operating on a +``poly_int`` is not possible or does not make sense. One example +is when handling static initializers, since no current target supports +the concept of a variable-length static initializer. In these +situations, a reasonable fallback is: + +.. code-block:: c++ + + if (poly_value.is_constant (&const_value)) + { + ... + /* Operate on const_value. */ + ... + } + else + { + ... + /* Conservatively correct fallback. */ + ... + } + +``poly_int`` also provides some asserting functions like +``to_constant``. Please only use these functions if there is a +good theoretical reason to believe that the assertion cannot fire. +For example, if some work is divided into an analysis phase and an +implementation phase, the analysis phase might reject inputs that are +not ``is_constant``, in which case the implementation phase can +reasonably use ``to_constant`` on the remaining inputs. The assertions +should not be used to discover whether a condition ever occurs 'in the +field'; in other words, they should not be used to restrict code to +constants at first, with the intention of only implementing a +``poly_int`` version if a user hits the assertion. + +If a particular asserting function like ``to_constant`` is needed +more than once for the same reason, it is probably worth adding a +helper function or macro for that situation, so that the justification +only needs to be given once. For example: + +.. code-block:: c++ + + /* Return the size of an element in a vector of size SIZE, given that + the vector has NELTS elements. The return value is in the same units + as SIZE (either bits or bytes). + + to_constant () is safe in this situation because vector elements are + always constant-sized scalars. */ + #define vector_element_size(SIZE, NELTS) \ + (exact_div (SIZE, NELTS).to_constant ()) + +Target-specific code in :samp:`config/{cpu}` only needs to handle +non-constant ``poly_int`` s if ``NUM_POLY_INT_COEFFS`` is greater +than one. For other targets, ``poly_int`` degenerates to a compile-time +constant and is often interchangable with a normal scalar integer. +There are two main exceptions: + +* Sometimes an explicit cast to an integer type might be needed, such as to + resolve ambiguities in a ``?:`` expression, or when passing values + through ``...`` to things like print functions. + +* Target macros are included in target-independent code and so do not + have access to the implicit conversion to a scalar integer. + If this becomes a problem for a particular target macro, the + possible solutions, in order of preference, are: + + * Convert the target macro to a target hook (for all targets). + + * Put the target's implementation of the target macro in its + :samp:`{cpu}.c` file and call it from the target macro in the + :samp:`{cpu}.h` file. + + * Add ``to_constant ()`` calls where necessary. The previous option + is preferable because it will help with any future conversion of the + macro to a hook. \ No newline at end of file diff --git a/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/miscellaneous-polyint-routines.rst b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/miscellaneous-polyint-routines.rst new file mode 100644 index 00000000000..97a5bf1f783 --- /dev/null +++ b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/miscellaneous-polyint-routines.rst @@ -0,0 +1,16 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Miscellaneous poly_int routines +******************************* + +:samp:`print_dec ({value}, {file}, {sign})` :samp:`print_dec ({value}, {file})` + Print :samp:`{value}` to :samp:`{file}` as a decimal value, interpreting + the coefficients according to :samp:`{sign}`. The final argument is + optional if :samp:`{value}` has an inherent sign; for example, + ``poly_int64`` values print as signed by default and + ``poly_uint64`` values print as unsigned by default. + + This is a simply a ``poly_int`` version of a wide-int routine. \ No newline at end of file diff --git a/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/overview-of-polyint.rst b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/overview-of-polyint.rst new file mode 100644 index 00000000000..5151fdf91b7 --- /dev/null +++ b/gcc/doc/gccint/sizes-and-offsets-as-runtime-invariants/overview-of-polyint.rst @@ -0,0 +1,78 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: poly_int, runtime value + +Overview of poly_int +******************** + +We define indeterminates :samp:`{x1}`, ..., :samp:`{xn}` whose values are +only known at runtime and use polynomials of the form: + +.. code-block:: c++ + + c0 + c1 * x1 + ... + cn * xn + +to represent a size or offset whose value might depend on some +of these indeterminates. The coefficients :samp:`{c0}`, ..., :samp:`{cn}` +are always known at compile time, with the :samp:`{c0}` term being the +'constant' part that does not depend on any runtime value. + +GCC uses the ``poly_int`` class to represent these coefficients. +The class has two template parameters: the first specifies the number of +coefficients (:samp:`{n}` + 1) and the second specifies the type of the +coefficients. For example, :samp:`poly_int<2, unsigned short>` represents +a polynomial with two coefficients (and thus one indeterminate), with each +coefficient having type ``unsigned short``. When :samp:`{n}` is 0, +the class degenerates to a single compile-time constant :samp:`{c0}`. + +.. index:: poly_int, template parameters, NUM_POLY_INT_COEFFS + +The number of coefficients needed for compilation is a fixed +property of each target and is specified by the configuration macro +``NUM_POLY_INT_COEFFS``. The default value is 1, since most targets +do not have such runtime invariants. Targets that need a different +value should ``#define`` the macro in their :samp:`{cpu}-modes.def` +file. See :ref:`back-end`. + +.. index:: poly_int, invariant range + +``poly_int`` makes the simplifying requirement that each indeterminate +must be a nonnegative integer. An indeterminate value of 0 should usually +represent the minimum possible runtime value, with :samp:`{c0}` specifying +the value in that case. + +For example, when targetting the Arm SVE ISA, the single indeterminate +represents the number of 128-bit blocks in a vector *beyond the minimum +length of 128 bits*. Thus the number of 64-bit doublewords in a vector +is 2 + 2 \* :samp:`{x1}`. If an aggregate has a single SVE vector and 16 +additional bytes, its total size is 32 + 16 \* :samp:`{x1}` bytes. + +The header file :samp:`poly-int-types.h` provides typedefs for the +most common forms of ``poly_int``, all having +``NUM_POLY_INT_COEFFS`` coefficients: + +.. index:: poly_int, main typedefs + +``poly_uint16`` + a :samp:`poly_int` with ``unsigned short`` coefficients. + +``poly_int64`` + a :samp:`poly_int` with ``HOST_WIDE_INT`` coefficients. + +``poly_uint64`` + a :samp:`poly_int` with ``unsigned HOST_WIDE_INT`` coefficients. + +``poly_offset_int`` + a :samp:`poly_int` with ``offset_int`` coefficients. + +``poly_wide_int`` + a :samp:`poly_int` with ``wide_int`` coefficients. + +``poly_widest_int`` + a :samp:`poly_int` with ``widest_int`` coefficients. + + Since the main purpose of ``poly_int`` is to represent sizes and + offsets, the last two typedefs are only rarely used. \ No newline at end of file diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system.rst b/gcc/doc/gccint/source-tree-structure-and-build-system.rst new file mode 100644 index 00000000000..cfc1ad40820 --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _source-tree: + +Source Tree Structure and Build System +-------------------------------------- + +This chapter describes the structure of the GCC source tree, and how +GCC is built. The user documentation for building and installing GCC +is in a separate manual (https://gcc.gnu.org/install/), with +which it is presumed that you are familiar. + +.. toctree:: + :maxdepth: 2 + + source-tree-structure-and-build-system/configure-terms-and-history + source-tree-structure-and-build-system/top-level-source-directory + source-tree-structure-and-build-system/the-gcc-subdirectory \ No newline at end of file diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system/configure-terms-and-history.rst b/gcc/doc/gccint/source-tree-structure-and-build-system/configure-terms-and-history.rst new file mode 100644 index 00000000000..5610f0c3bcb --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system/configure-terms-and-history.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: configure terms, canadian + +.. _configure-terms: + +Configure Terms and History +*************************** + +The configure and build process has a long and colorful history, and can +be confusing to anyone who doesn't know why things are the way they are. +While there are other documents which describe the configuration process +in detail, here are a few things that everyone working on GCC should +know. + +There are three system names that the build knows about: the machine you +are building on (:dfn:`build`), the machine that you are building for +(:dfn:`host`), and the machine that GCC will produce code for +(:dfn:`target`). When you configure GCC, you specify these with +:option:`--build=`, :option:`--host=`, and :option:`--target=`. + +Specifying the host without specifying the build should be avoided, as +:command:`configure` may (and once did) assume that the host you specify +is also the build, which may not be true. + +If build, host, and target are all the same, this is called a +:dfn:`native`. If build and host are the same but target is different, +this is called a :dfn:`cross`. If build, host, and target are all +different this is called a :dfn:`canadian` (for obscure reasons dealing +with Canada's political party and the background of the person working +on the build at that time). If host and target are the same, but build +is different, you are using a cross-compiler to build a native for a +different system. Some people call this a :dfn:`host-x-host`, +:dfn:`crossed native`, or :dfn:`cross-built native`. If build and target +are the same, but host is different, you are using a cross compiler to +build a cross compiler that produces code for the machine you're +building on. This is rare, so there is no common way of describing it. +There is a proposal to call this a :dfn:`crossback`. + +If build and host are the same, the GCC you are building will also be +used to build the target libraries (like ``libstdc++``). If build and host +are different, you must have already built and installed a cross +compiler that will be used to build the target libraries (if you +configured with :option:`--target=foo-bar`, this compiler will be called +:command:`foo-bar-gcc`). + +In the case of target libraries, the machine you're building for is the +machine you specified with :option:`--target`. So, build is the machine +you're building on (no change there), host is the machine you're +building for (the target libraries are built for the target, so host is +the target you specified), and target doesn't apply (because you're not +building a compiler, you're building libraries). The configure/make +process will adjust these variables as needed. It also sets +``$with_cross_host`` to the original :option:`--host` value in case you +need it. + +The ``libiberty`` support library is built up to three times: once +for the host, once for the target (even if they are the same), and once +for the build if build and host are different. This allows it to be +used by all programs which are generated in the course of the build +process. \ No newline at end of file diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory.rst b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory.rst new file mode 100644 index 00000000000..318a059d9ce --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory.rst @@ -0,0 +1,28 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gcc-directory: + +The gcc Subdirectory +******************** + +The :samp:`gcc` directory contains many files that are part of the C +sources of GCC, other files used as part of the configuration and +build process, and subdirectories including documentation and a +testsuite. The files that are sources of GCC are documented in a +separate chapter. See :ref:`passes`. + +.. toctree:: + :maxdepth: 2 + + the-gcc-subdirectory/subdirectories-of-gcc + the-gcc-subdirectory/configuration-in-the-gcc-directory + the-gcc-subdirectory/build-system-in-the-gcc-directory + the-gcc-subdirectory/makefile-targets + the-gcc-subdirectory/library-source-files-and-headers-under-the-gcc-directory + the-gcc-subdirectory/headers-installed-by-gcc + the-gcc-subdirectory/building-documentation + the-gcc-subdirectory/anatomy-of-a-language-front-end + the-gcc-subdirectory/anatomy-of-a-target-back-end \ No newline at end of file diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/anatomy-of-a-language-front-end.rst b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/anatomy-of-a-language-front-end.rst new file mode 100644 index 00000000000..112f5bc9923 --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/anatomy-of-a-language-front-end.rst @@ -0,0 +1,281 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _front-end: + +Anatomy of a Language Front End +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A front end for a language in GCC has the following parts: + +* A directory :samp:`{language}` under :samp:`gcc` containing source + files for that front end. See :ref:`front-end-directory`, for details. + +* A mention of the language in the list of supported languages in + :samp:`gcc/doc/install.texi`. + +* A mention of the name under which the language's runtime library is + recognized by :option:`--enable-shared=package` in the + documentation of that option in :samp:`gcc/doc/install.texi`. + +* A mention of any special prerequisites for building the front end in + the documentation of prerequisites in :samp:`gcc/doc/install.texi`. + +* Details of contributors to that front end in + :samp:`gcc/doc/contrib.texi`. If the details are in that front end's + own manual then there should be a link to that manual's list in + :samp:`contrib.texi`. + +* Information about support for that language in + :samp:`gcc/doc/frontends.texi`. + +* Information about standards for that language, and the front end's + support for them, in :samp:`gcc/doc/standards.texi`. This may be a + link to such information in the front end's own manual. + +* Details of source file suffixes for that language and :option:`-x lang` + options supported, in :samp:`gcc/doc/invoke.texi`. + +* Entries in ``default_compilers`` in :samp:`gcc.cc` for source file + suffixes for that language. + +* Preferably testsuites, which may be under :samp:`gcc/testsuite` or + runtime library directories. + + .. todo:: document somewhere how to write testsuite harnesses + +* Probably a runtime library for the language, outside the :samp:`gcc` + directory. + + .. todo:: document this further + +* Details of the directories of any runtime libraries in + :samp:`gcc/doc/sourcebuild.texi`. + +* Check targets in :samp:`Makefile.def` for the top-level :samp:`Makefile` + to check just the compiler or the compiler and runtime library for the + language. + +If the front end is added to the official GCC source repository, the +following are also necessary: + +* At least one Bugzilla component for bugs in that front end and runtime + libraries. This category needs to be added to the Bugzilla database. + +* Normally, one or more maintainers of that front end listed in + :samp:`MAINTAINERS`. + +* Mentions on the GCC web site in :samp:`index.html` and + :samp:`frontends.html`, with any relevant links on + :samp:`readings.html`. (Front ends that are not an official part of + GCC may also be listed on :samp:`frontends.html`, with relevant links.) + +* A news item on :samp:`index.html`, and possibly an announcement on the + gcc-announce@gcc.gnu.org mailing list. + +* The front end's manuals should be mentioned in + :samp:`maintainer-scripts/update_web_docs_git` (see :ref:`building_documentation`) + and the online manuals should be linked to from + :samp:`onlinedocs/index.html`. + +* Any old releases or CVS repositories of the front end, before its + inclusion in GCC, should be made available on the GCC web site at + https://gcc.gnu.org/pub/gcc/old-releases/. + +* The release and snapshot script :samp:`maintainer-scripts/gcc_release` + should be updated to generate appropriate tarballs for this front end. + +* If this front end includes its own version files that include the + current date, :samp:`maintainer-scripts/update_version` should be + updated accordingly. + +.. toctree:: + :maxdepth: 2 + + +.. _front-end-directory: + +The Front End language Directory +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A front end :samp:`{language}` directory contains the source files +of that front end (but not of any runtime libraries, which should be +outside the :samp:`gcc` directory). This includes documentation, and +possibly some subsidiary programs built alongside the front end. +Certain files are special and other parts of the compiler depend on +their names: + +:samp:`config-lang.in` + This file is required in all language subdirectories. See :ref:`front-end-config`, for details of + its contents + +:samp:`Make-lang.in` + This file is required in all language subdirectories. See :ref:`front-end-makefile`, for details of its + contents. + +:samp:`lang.opt` + This file registers the set of switches that the front end accepts on + the command line, and their :option:`--help` text. See :ref:`options`. + +:samp:`lang-specs.h` + This file provides entries for ``default_compilers`` in + :samp:`gcc.cc` which override the default of giving an error that a + compiler for that language is not installed. + +:samp:`{language}-tree.def` + This file, which need not exist, defines any language-specific tree + codes. + +.. _front-end-config: + +The Front End config-lang.in File +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Each language subdirectory contains a :samp:`config-lang.in` file. +This file is a shell script that may define some variables describing +the language: + +``language`` + This definition must be present, and gives the name of the language + for some purposes such as arguments to :option:`--enable-languages`. + +``lang_requires`` + If defined, this variable lists (space-separated) language front ends + other than C that this front end requires to be enabled (with the + names given being their ``language`` settings). For example, the + Obj-C++ front end depends on the C++ and ObjC front ends, so sets + :samp:`lang_requires="objc c++"`. + +``subdir_requires`` + If defined, this variable lists (space-separated) front end directories + other than C that this front end requires to be present. For example, + the Objective-C++ front end uses source files from the C++ and + Objective-C front ends, so sets :samp:`subdir_requires="cp objc"`. + +``target_libs`` + If defined, this variable lists (space-separated) targets in the top + level :samp:`Makefile` to build the runtime libraries for this + language, such as ``target-libobjc``. + +``lang_dirs`` + If defined, this variable lists (space-separated) top level + directories (parallel to :samp:`gcc`), apart from the runtime libraries, + that should not be configured if this front end is not built. + +``build_by_default`` + If defined to :samp:`no`, this language front end is not built unless + enabled in a :option:`--enable-languages` argument. Otherwise, front + ends are built by default, subject to any special logic in + :samp:`configure.ac` (as is present to disable the Ada front end if the + Ada compiler is not already installed). + +``boot_language`` + If defined to :samp:`yes`, this front end is built in stage1 of the + bootstrap. This is only relevant to front ends written in their own + languages. + +``compilers`` + If defined, a space-separated list of compiler executables that will + be run by the driver. The names here will each end + with :samp:`\\$(exeext)`. + +``outputs`` + If defined, a space-separated list of files that should be generated + by :samp:`configure` substituting values in them. This mechanism can + be used to create a file :samp:`{language}/Makefile` from + :samp:`{language}/Makefile.in`, but this is deprecated, building + everything from the single :samp:`gcc/Makefile` is preferred. + +``gtfiles`` + If defined, a space-separated list of files that should be scanned by + :samp:`gengtype.cc` to generate the garbage collection tables and routines for + this language. This excludes the files that are common to all front + ends. See :ref:`type-information`. + +.. _front-end-makefile: + +The Front End Make-lang.in File +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Each language subdirectory contains a :samp:`Make-lang.in` file. It contains +targets ``lang.hook`` (where ``lang`` is the +setting of ``language`` in :samp:`config-lang.in`) for the following +values of ``hook``, and any other Makefile rules required to +build those targets (which may if necessary use other Makefiles +specified in ``outputs`` in :samp:`config-lang.in`, although this is +deprecated). It also adds any testsuite targets that can use the +standard rule in :samp:`gcc/Makefile.in` to the variable +``lang_checks``. + +``all.cross`` ``start.encap`` ``rest.encap`` + + .. todo:: exactly what goes in each of these targets? + +``tags`` + Build an :command:`etags` :samp:`TAGS` file in the language subdirectory + in the source tree. + +``info`` + Build info documentation for the front end, in the build directory. + This target is only called by :samp:`make bootstrap` if a suitable + version of :command:`sphinx` is available, so does not need to check + for this, and should fail if an error occurs. + +``pdf`` + Build PDF documentation for the front end, in the build directory. + +``html`` + Build HTML documentation for the front end, in the build directory. + +``man`` + Build generated man pages for the front end from reStructuredText format + (see :ref:`building_documentation`), in the build directory. This target + is only called if the necessary tools are available, but should ignore + errors so as not to stop the build if errors occur; man pages are + optional and the tools involved may be installed in a broken way. + +``install-common`` + Install everything that is part of the front end, apart from the + compiler executables listed in ``compilers`` in + :samp:`config-lang.in`. + +``install-info`` + Install info documentation for the front end, if it is present in the + source directory. This target should have dependencies on info files + that should be installed. + +``install-man`` + Install man pages for the front end. This target should ignore + errors. + +``install-plugin`` + Install headers needed for plugins. + +``srcextra`` + Copies its dependencies into the source directory. This generally should + be used for generated files such as Bison output files which are not + version-controlled, but should be included in any release tarballs. This + target will be executed during a bootstrap if + :samp:`--enable-generated-files-in-srcdir` was specified as a + :samp:`configure` option. + +``srcinfo`` ``srcman`` + Copies its dependencies into the source directory. These targets will be + executed during a bootstrap if :samp:`--enable-generated-files-in-srcdir` + was specified as a :samp:`configure` option. + +``uninstall`` + Uninstall files installed by installing the compiler. This is + currently documented not to be supported, so the hook need not do + anything. + +``mostlyclean`` ``clean`` ``distclean`` ``maintainer-clean`` + The language parts of the standard GNU + :samp:`*clean` targets. For GCC, ``maintainer-clean`` should delete + all generated files in the source directory that are not version-controlled, + but should not delete anything that is. + + :samp:`Make-lang.in` must also define a variable ``lang_OBJS`` + to a list of host object files that are used by that language. \ No newline at end of file diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/anatomy-of-a-target-back-end.rst b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/anatomy-of-a-target-back-end.rst new file mode 100644 index 00000000000..59e914a5ea0 --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/anatomy-of-a-target-back-end.rst @@ -0,0 +1,116 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _back-end: + +Anatomy of a Target Back End +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A back end for a target architecture in GCC has the following parts: + +* A directory :samp:`{machine}` under :samp:`gcc/config`, containing a + machine description :samp:`{machine}.md` file (see :ref:`machine-desc`), header files :samp:`{machine}.h` and + :samp:`{machine}-protos.h` and a source file :samp:`{machine}.c` + (see :ref:`target-macros`), + possibly a target Makefile fragment :samp:`t-{machine}` + (see :ref:`target-fragment`), and maybe + some other files. The names of these files may be changed from the + defaults given by explicit specifications in :samp:`config.gcc`. + +* If necessary, a file :samp:`{machine}-modes.def` in the + :samp:`{machine}` directory, containing additional machine modes to + represent condition codes. See :ref:`condition-code`, for further details. + +* An optional :samp:`{machine}.opt` file in the :samp:`{machine}` + directory, containing a list of target-specific options. You can also + add other option files using the ``extra_options`` variable in + :samp:`config.gcc`. See :ref:`options`. + +* Entries in :samp:`config.gcc` (see :ref:`system-config`) for the systems with this target + architecture. + +* Documentation in :samp:`gcc/doc/invoke.texi` for any command-line + options supported by this target (see :ref:`run-time-target`). This means both entries in the summary table + of options and details of the individual options. + +* Documentation in :samp:`gcc/doc/extend.texi` for any target-specific + attributes supported (see :ref:`target-attributes`), including where the + same attribute is already supported on some targets, which are + enumerated in the manual. + +* Documentation in :samp:`gcc/doc/extend.texi` for any target-specific + pragmas supported. + +* Documentation in :samp:`gcc/doc/extend.texi` of any target-specific + built-in functions supported. + +* Documentation in :samp:`gcc/doc/extend.texi` of any target-specific + format checking styles supported. + +* Documentation in :samp:`gcc/doc/md.texi` of any target-specific + constraint letters (see :ref:`machine-constraints`). + +* A note in :samp:`gcc/doc/contrib.texi` under the person or people who + contributed the target support. + +* Entries in :samp:`gcc/doc/install.texi` for all target triplets + supported with this target architecture, giving details of any special + notes about installation for this target, or saying that there are no + special notes if there are none. + +* Possibly other support outside the :samp:`gcc` directory for runtime + libraries. The ``libstdc++`` porting + manual needs to be installed as info for this to work, or to be a + chapter of this manual. + + .. todo:: reference docs for this + +The :samp:`{machine}.h` header is included very early in GCC's +standard sequence of header files, while :samp:`{machine}-protos.h` +is included late in the sequence. Thus :samp:`{machine}-protos.h` +can include declarations referencing types that are not defined when +:samp:`{machine}.h` is included, specifically including those from +:samp:`rtl.h` and :samp:`tree.h`. Since both RTL and tree types may not +be available in every context where :samp:`{machine}-protos.h` is +included, in this file you should guard declarations using these types +inside appropriate ``#ifdef RTX_CODE`` or ``#ifdef TREE_CODE`` +conditional code segments. + +If the backend uses shared data structures that require ``GTY`` markers +for garbage collection (see :ref:`type-information`), you must declare those +in :samp:`{machine}.h` rather than :samp:`{machine}-protos.h`. +Any definitions required for building libgcc must also go in +:samp:`{machine}.h`. + +GCC uses the macro ``IN_TARGET_CODE`` to distinguish between +machine-specific :samp:`.c` and :samp:`.cc` files and +machine-independent :samp:`.c` and :samp:`.cc` files. Machine-specific +files should use the directive: + +.. code-block:: c++ + + #define IN_TARGET_CODE 1 + +before including ``config.h``. + +If the back end is added to the official GCC source repository, the +following are also necessary: + +* An entry for the target architecture in :samp:`readings.html` on the + GCC web site, with any relevant links. + +* Details of the properties of the back end and target architecture in + :samp:`backends.html` on the GCC web site. + +* A news item about the contribution of support for that target + architecture, in :samp:`index.html` on the GCC web site. + +* Normally, one or more maintainers of that target listed in + :samp:`MAINTAINERS`. Some existing architectures may be unmaintained, + but it would be unusual to add support for a target that does not have + a maintainer when support is added. + +* Target triplets covering all :samp:`config.gcc` stanzas for the target, + in the list in :samp:`contrib/config-list.mk`. \ No newline at end of file diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/build-system-in-the-gcc-directory.rst b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/build-system-in-the-gcc-directory.rst new file mode 100644 index 00000000000..b1ce12fe286 --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/build-system-in-the-gcc-directory.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _build: + +Build System in the gcc Directory +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. todo:: describe the build system, including what is built in what + stages. Also list the various source files that are used in the build + process but aren't source files of GCC itself and so aren't documented + below (see :ref:`passes`). \ No newline at end of file diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/building-documentation.rst b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/building-documentation.rst new file mode 100644 index 00000000000..421f91003e8 --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/building-documentation.rst @@ -0,0 +1,247 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _building_documentation: + +Building Documentation +^^^^^^^^^^^^^^^^^^^^^^ + +The main GCC documentation uses `Sphinx`_ to generate pretty documentation +from `reStructuredText`_ format. +These are input for Manual pages format (:command:`make man`), +Info format (:command:`make info`), HTML format (:command:`make html`) +and PDF format (:command:`make pdf`). + +.. _Sphinx: http://www.sphinx-doc.org/ +.. _reStructuredText: http://docutils.sourceforge.net/rst.html + +.. _sphinx_install: + +Sphinx Install +============== + +The ReST markups currently used by the documentation files are meant to be +built with ``Sphinx`` version |needs_sphinx| or higher. + +Most distributions are shipped with Sphinx, but its toolchain is fragile, +and it is not uncommon that upgrading it or some other Python packages +on your machine would cause the documentation build to break. + +A way to avoid that is to use a different version than the one shipped +with your distributions. In order to do so, it is recommended to install +Sphinx inside a virtual environment, using ``virtualenv-3`` +or ``virtualenv``, depending on how your distribution packaged Python 3. + +.. code-block:: shell-session + + $ virtualenv /tmp/venv + $ source /tmp/venv/bin/activate + $ pip install -r requirements.txt + +Note the :file:`requirements.txt` file is placed in :rst:dir:`gcc/doc` folder and contains the following packages: + +.. literalinclude:: ../../../../../doc/requirements.txt + :caption: requirements.txt + +Then the virtualenv can be provided to the configure script :option:`install:--with-sphinx-build` +and will be used by the build system: + +.. code-block:: shell-session + + $ configure --with-sphinx-build=/tmp/venv/bin/sphinx-build + +If you want to build the PDF documentation, you will need ``python3-Sphinx-latex`` sub-package. + +.. note:: + + When building **manual** and **info** pages (built by default), the only dependency + is Sphinx package and one can ignore other dependencies mentioned in :file:`requirements.txt`. + +Writing Documentation +===================== + +Adding new documentation can be as simple as: + +1. Add a new ``.rst`` file somewhere under a ``doc`` subfolder. +2. Refer to it from the Sphinx main `TOC tree`_ in a ``index.rst`` file. + +.. _TOC tree: http://www.sphinx-doc.org/en/stable/markup/toctree.html + +This is usually good enough for simple documentation (like the one you're +reading right now), but for larger documents it may be advisable to create a +subdirectory (or use an existing one). + +See the documentation for `Sphinx`_ and `reStructuredText`_ on what you can do +with them. In particular, the Sphinx `reStructuredText Primer`_ is a good place +to get started with reStructuredText. There are also some `Sphinx specific +markup constructs`_ and `Usefull RST cheatsheet`_. + +.. _reStructuredText Primer: http://www.sphinx-doc.org/en/stable/rest.html +.. _Sphinx specific markup constructs: http://www.sphinx-doc.org/en/stable/markup/index.html +.. _Usefull RST cheatsheet: https://github.com/ralsina/rst-cheatsheet/blob/master/rst-cheatsheet.rst + +Specific guidelines for the GCC documentation +--------------------------------------------- + +Here are some specific guidelines for the GCC documentation: + +* Please stick to this order of heading adornments: + + 1. ``=`` with overline for document title: + + .. code-block:: rst + + ============== + Document title + ============== + + 2. ``-`` for chapters: + + .. code-block:: rst + + Chapter + ------- + + 3. ``*`` for sections: + + .. code-block:: rst + + Section + ******* + + 4. ``^`` for subsections: + + .. code-block:: rst + + Subsection + ^^^^^^^^^^ + + 5. ``~`` for subsubsections: + + .. code-block:: rst + + Subsubsection + ~~~~~~~~~~~~~ + + Although RST doesn't mandate a specific order ("Rather than imposing a fixed + number and order of section title adornment styles, the order enforced will be + the order as encountered."), having the higher levels the same overall makes + it easier to follow the documents. + +* For inserting fixed width text blocks (for code examples, use case + examples, etc.), use ``::`` for anything that doesn't really benefit + from syntax highlighting, especially short snippets. Use + ``.. code-block:: `` for longer code blocks that benefit + from highlighting. For a short snippet of code embedded in the text, use ````code snippet````. + +* For parts of documentation that needs to be written or enhanced, use ``.. todo::`` directive + (part of the official ``sphinx.ext.todo`` extension). In development mode, all items + are listed at the very end of the documentation for easier navigation. + +GCC-specific directives and roles +--------------------------------- + +GCC uses its own extension (:file:`gcc_sphinx.py`) that defined various directives. For the complete +list of target-specific attributes, please take a look at the extension definition: + +.. list-table:: + :header-rows: 1 + + * - Directive + - Description + + * - ``gcc-attr`` + - Generic GCC attribute + * - ``fn-attr`` + - Function attribute + * - ``var-attr`` + - Variable attribute + * - ``type-attr`` + - Type attribute + * - ``enum-attr`` + - Enumeral attribute + * - ``label-attr`` + - Label attribute + * - ``$target-fn-attr`` + - Target-specific function attribute (e.g. ``.. x86-fn-attr:: interrupt``) + * - ``$target-var-attr`` + - Target-specific variable attribute + * - ``$target-type-attr`` + - Target-specific type attribute + * - ``gcc-param`` + - GCC parameter directive, (e.g. ``.. gcc-param: inline-unit-growth``) + +Apart from the directives, we also define various inline roles: + +.. list-table:: + :header-rows: 1 + + * - Role + - Description + + * - ``:P:`$num``` + - Link to WG21 - The C++ Standards Committee (e.g. ``:P:`2003```) + * - ``:PR:`$num``` + - Link to GCC bugzilla entry + * - ``:openmp:`$version``` + - Link to OpenMP documentation version ``$version`` (e.g. ``:openmp:`4.5```) + * - ``:openacc:`$version``` + - Link to OpenACC documentation version ``$version`` + * - ``|gcc_version|`` + - Version of the documentation (e.g. |gcc_version|, taken from :file:`BASE-VER`) + * - ``|needs_sphinx|`` + - Minimal required Sphinx version (e.g. |needs_sphinx|, taken from :file:`baseconf.py`) + * - ``|bugurl|`` + - URL to bugzilla instance (e.g. |bugurl|) + * - ``|package_version|`` + - Package version (e.g. |package_version|) + * - ``|gol|`` + - Line break used for PDF version + * - ``|nbsp|`` + - Non-breaking space character + +.. _miscellaneous-docs: + +Miscellaneous Documentation +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In addition to the formal documentation that is installed by GCC, +there are several other text files in the :samp:`gcc` subdirectory +with miscellaneous documentation: + +:samp:`ABOUT-GCC-NLS` + Notes on GCC's Native Language Support. + + .. todo:: this should be part of this manual rather than a separate file + +:samp:`ABOUT-NLS` + Notes on the Free Translation Project. + +:samp:`COPYING` + The GNU General Public License, Versions 2 and 3. + +:samp:`COPYING.LIB` :samp:`COPYING3.LIB` + The GNU Lesser General Public License, Versions 2.1 and 3. + +:samp:`*ChangeLog*` :samp:`*/ChangeLog*` + Change log files for various parts of GCC. + +:samp:`LANGUAGES` + Details of a few changes to the GCC front-end interface. + + .. todo:: the information in this file should be part of general documentation of + the front-end interface in this manual. + +:samp:`ONEWS` + Information about new features in old versions of GCC. (For recent + versions, the information is on the GCC web site.) + +:samp:`README.Portability` + Information about portability issues when writing code in GCC. + + .. todo:: why isn't this part of this manual or of the GCC Coding Conventions? + + .. todo:: document such files in subdirectories, at least :samp:`config`, + :samp:`c`, :samp:`cp`, :samp:`objc`, :samp:`testsuite`. diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/configuration-in-the-gcc-directory.rst b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/configuration-in-the-gcc-directory.rst new file mode 100644 index 00000000000..aa2f843a53e --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/configuration-in-the-gcc-directory.rst @@ -0,0 +1,127 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _configuration: + +Configuration in the gcc Directory +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The :samp:`gcc` directory is configured with an Autoconf-generated +script :samp:`configure`. The :samp:`configure` script is generated +from :samp:`configure.ac` and :samp:`aclocal.m4`. From the files +:samp:`configure.ac` and :samp:`acconfig.h`, Autoheader generates the +file :samp:`config.in`. The file :samp:`cstamp-h.in` is used as a +timestamp. + +.. toctree:: + :maxdepth: 2 + + +.. _config-fragments: + +Scripts Used by configure +~~~~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`configure` uses some other scripts to help in its work: + +* The standard GNU :samp:`config.sub` and :samp:`config.guess` + files, kept in the top level directory, are used. + +* The file :samp:`config.gcc` is used to handle configuration + specific to the particular target machine. The file + :samp:`config.build` is used to handle configuration specific to the + particular build machine. The file :samp:`config.host` is used to handle + configuration specific to the particular host machine. (In general, + these should only be used for features that cannot reasonably be tested in + Autoconf feature tests.) + See :ref:`system-config`, for details of the contents of these files. + +* Each language subdirectory has a file + :samp:`{language}/config-lang.in` that is used for + front-end-specific configuration. See :ref:`front-end-config`, for details of this file. + +* A helper script :samp:`configure.frag` is used as part of + creating the output of :samp:`configure`. + +.. _system-config: + +The config.build; config.host; and config.gcc Files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The :samp:`config.build` file contains specific rules for particular systems +which GCC is built on. This should be used as rarely as possible, as the +behavior of the build system can always be detected by autoconf. + +The :samp:`config.host` file contains specific rules for particular systems +which GCC will run on. This is rarely needed. + +The :samp:`config.gcc` file contains specific rules for particular systems +which GCC will generate code for. This is usually needed. + +Each file has a list of the shell variables it sets, with descriptions, at the +top of the file. + +.. todo:: document the contents of these files, and what variables should + be set to control build, host and target configuration. + +.. _configuration-files: + +Files Created by configure +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here we spell out what files will be set up by :samp:`configure` in the +:samp:`gcc` directory. Some other files are created as temporary files +in the configuration process, and are not used in the subsequent +build; these are not documented. + +* :samp:`Makefile` is constructed from :samp:`Makefile.in`, together with + the host and target fragments (see :ref:`fragments`) :samp:`t-{target}` and :samp:`x-{host}` from + :samp:`config`, if any, and language Makefile fragments + :samp:`{language}/Make-lang.in`. + +* :samp:`auto-host.h` contains information about the host machine + determined by :samp:`configure`. If the host machine is different from + the build machine, then :samp:`auto-build.h` is also created, + containing such information about the build machine. + +* :samp:`config.status` is a script that may be run to recreate the + current configuration. + +* :samp:`configargs.h` is a header containing details of the arguments + passed to :samp:`configure` to configure GCC, and of the thread model + used. + +* :samp:`cstamp-h` is used as a timestamp. + +* If a language :samp:`config-lang.in` file (see :ref:`front-end-config`) sets ``outputs``, then + the files listed in ``outputs`` there are also generated. + +The following configuration headers are created from the Makefile, +using :samp:`mkconfig.sh`, rather than directly by :samp:`configure`. +:samp:`config.h`, :samp:`bconfig.h` and :samp:`tconfig.h` all contain the +:samp:`xm-{machine}.h` header, if any, appropriate to the host, +build and target machines respectively, the configuration headers for +the target, and some definitions; for the host and build machines, +these include the autoconfigured headers generated by +:samp:`configure`. The other configuration headers are determined by +:samp:`config.gcc`. They also contain the typedefs for ``rtx``, +``rtvec`` and ``tree``. + +* :samp:`config.h`, for use in programs that run on the host machine. + +* :samp:`bconfig.h`, for use in programs that run on the build machine. + +* :samp:`tconfig.h`, for use in programs and libraries for the target + machine. + +* :samp:`tm_p.h`, which includes the header :samp:`{machine}-protos.h` + that contains prototypes for functions in the target + :samp:`{machine}.c` file. The + :samp:`{machine}-protos.h` header is included after the :samp:`rtl.h` + and/or :samp:`tree.h` would have been included. + The :samp:`tm_p.h` also + includes the header :samp:`tm-preds.h` which is generated by + :samp:`genpreds` program during the build to define the declarations + and inline functions for the predicate functions. \ No newline at end of file diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/headers-installed-by-gcc.rst b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/headers-installed-by-gcc.rst new file mode 100644 index 00000000000..05cc6f2aefc --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/headers-installed-by-gcc.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _headers: + +Headers Installed by GCC +^^^^^^^^^^^^^^^^^^^^^^^^ + +In general, GCC expects the system C library to provide most of the +headers to be used with it. However, GCC will fix those headers if +necessary to make them work with GCC, and will install some headers +required of freestanding implementations. These headers are installed +in :samp:`{libsubdir}/include`. Headers for non-C runtime +libraries are also installed by GCC; these are not documented here. + +.. todo:: document them somewhere + +Several of the headers GCC installs are in the :samp:`ginclude` +directory. These headers, :samp:`iso646.h`, +:samp:`stdarg.h`, :samp:`stdbool.h`, and :samp:`stddef.h`, +are installed in :samp:`{libsubdir}/include`, +unless the target Makefile fragment (see :ref:`target-fragment`) +overrides this by setting ``USER_H``. + +In addition to these headers and those generated by fixing system +headers to work with GCC, some other headers may also be installed in +:samp:`{libsubdir}/include`. :samp:`config.gcc` may set +``extra_headers`` ; this specifies additional headers under +:samp:`config` to be installed on some systems. + +GCC installs its own version of ````, from :samp:`ginclude/float.h`. +This is done to cope with command-line options that change the +representation of floating point numbers. + +GCC also installs its own version of ```` ; this is generated +from :samp:`glimits.h`, together with :samp:`limitx.h` and +:samp:`limity.h` if the system also has its own version of +````. (GCC provides its own header because it is +required of ISO C freestanding implementations, but needs to include +the system header from its own header as well because other standards +such as POSIX specify additional values to be defined in +````.) The system's ```` header is used via +:samp:`{libsubdir}/include/syslimits.h`, which is copied from +:samp:`gsyslimits.h` if it does not need fixing to work with GCC; if it +needs fixing, :samp:`syslimits.h` is the fixed copy. + +GCC can also install ````. It will do this when +:samp:`config.gcc` sets ``use_gcc_tgmath`` to ``yes``. \ No newline at end of file diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/library-source-files-and-headers-under-the-gcc-directory.rst b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/library-source-files-and-headers-under-the-gcc-directory.rst new file mode 100644 index 00000000000..2f1106174a6 --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/library-source-files-and-headers-under-the-gcc-directory.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _library-files: + +Library Source Files and Headers under the gcc Directory +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. todo:: list here, with explanation, all the C source files and headers + under the :samp:`gcc` directory that aren't built into the GCC + executable but rather are part of runtime libraries and object files, + such as :samp:`crtstuff.c` and :samp:`unwind-dw2.c`. See :ref:`headers`, for more information about the + :samp:`ginclude` directory. \ No newline at end of file diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/makefile-targets.rst b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/makefile-targets.rst new file mode 100644 index 00000000000..31fa75b0930 --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/makefile-targets.rst @@ -0,0 +1,195 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: makefile targets, targets, makefile + +.. _makefile: + +Makefile Targets +^^^^^^^^^^^^^^^^ + +These targets are available from the :samp:`gcc` directory: + +``all`` + This is the default target. Depending on what your build/host/target + configuration is, it coordinates all the things that need to be built. + +``doc`` + Produce info-formatted documentation and man pages. Essentially it + calls :samp:`make man` and :samp:`make info`. + +``pdf`` + Produce PDF-formatted documentation. + +``html`` + Produce HTML-formatted documentation. + +``man`` + Generate man pages. + +``info`` + Generate info-formatted pages. + +``mostlyclean`` + Delete the files made while building the compiler. + +``clean`` + That, and all the other files built by :samp:`make all`. + +``distclean`` + That, and all the files created by :command:`configure`. + +``maintainer-clean`` + Distclean plus any file that can be generated from other files. Note + that additional tools may be required beyond what is normally needed to + build GCC. + +``srcextra`` + Generates files in the source directory that are not version-controlled but + should go into a release tarball. + +``srcinfo`` ``srcman`` + Copies the info-formatted and manpage documentation into the source + directory usually for the purpose of generating a release tarball. + +``install`` + Installs GCC. + +``uninstall`` + Deletes installed files, though this is not supported. + +``check`` + Run the testsuite. This creates a :samp:`testsuite` subdirectory that + has various :samp:`.sum` and :samp:`.log` files containing the results of + the testing. You can run subsets with, for example, :samp:`make check-gcc`. + You can specify specific tests by setting :envvar:`RUNTESTFLAGS` to be the name + of the :samp:`.exp` file, optionally followed by (for some tests) an equals + and a file wildcard, like: + + .. code-block:: c++ + + make check-gcc RUNTESTFLAGS="execute.exp=19980413-*" + + Note that running the testsuite may require additional tools be + installed, such as Tcl or DejaGnu. + + The toplevel tree from which you start GCC compilation is not + the GCC directory, but rather a complex Makefile that coordinates + the various steps of the build, including bootstrapping the compiler + and using the new compiler to build target libraries. + +When GCC is configured for a native configuration, the default action +for :command:`make` is to do a full three-stage bootstrap. This means +that GCC is built three times---once with the native compiler, once with +the native-built compiler it just built, and once with the compiler it +built the second time. In theory, the last two should produce the same +results, which :samp:`make compare` can check. Each stage is configured +separately and compiled into a separate directory, to minimize problems +due to ABI incompatibilities between the native compiler and GCC. + +If you do a change, rebuilding will also start from the first stage +and 'bubble' up the change through the three stages. Each stage +is taken from its build directory (if it had been built previously), +rebuilt, and copied to its subdirectory. This will allow you to, for +example, continue a bootstrap after fixing a bug which causes the +stage2 build to crash. It does not provide as good coverage of the +compiler as bootstrapping from scratch, but it ensures that the new +code is syntactically correct (e.g., that you did not use GCC extensions +by mistake), and avoids spurious bootstrap comparison +failuresExcept if the compiler was buggy and miscompiled +some of the files that were not modified. In this case, it's best +to use :command:`make restrap`. + +Other targets available from the top level include: + +``bootstrap-lean`` + Like ``bootstrap``, except that the various stages are removed once + they're no longer needed. This saves disk space. + +``bootstrap2`` ``bootstrap2-lean`` + Performs only the first two stages of bootstrap. Unlike a three-stage + bootstrap, this does not perform a comparison to test that the compiler + is running properly. Note that the disk space required by a 'lean' + bootstrap is approximately independent of the number of stages. + +:samp:`stage{N}-bubble ({N} = 1...4, profile, feedback)` + Rebuild all the stages up to :samp:`{N}`, with the appropriate flags, + 'bubbling' the changes as described above. + +:samp:`all-stage{N} ({N} = 1...4, profile, feedback)` + Assuming that stage :samp:`{N}` has already been built, rebuild it with the + appropriate flags. This is rarely needed. + +``cleanstrap`` + Remove everything (:samp:`make clean`) and rebuilds (:samp:`make bootstrap`). + +``compare`` + Compares the results of stages 2 and 3. This ensures that the compiler + is running properly, since it should produce the same object files + regardless of how it itself was compiled. + +:samp:`distclean-stage{N} ({N} = 1...4, profile, feedback)` + Wipe stage :samp:`{N}` and all the following ones. + + For example, + :samp:`make distclean-stage3` wipes stage 3 and all the following ones, + so that another :command:`make` then rebuilds them from scratch. + This can be useful if you're doing changes where + 'bubbling' the changes as described above is not sufficient, + but a full :command:`make restrap` isn't necessary either. + +``profiledbootstrap`` + Builds a compiler with profiling feedback information. In this case, + the second and third stages are named :samp:`profile` and :samp:`feedback`, + respectively. For more information, see the installation instructions. + +``restrap`` + Restart a bootstrap, so that everything that was not built with + the system compiler is rebuilt. + +:samp:`stage{N}-start ({N} = 1...4, profile, feedback)` + For each package that is bootstrapped, rename directories so that, + for example, :samp:`gcc` points to the stage :samp:`{N}` GCC, compiled + with the stage :samp:`{N-1}` GCCCustomarily, the system compiler + is also termed the :samp:`stage0` GCC. + + . + + You will invoke this target if you need to test or debug the + stage :samp:`{N}` GCC. If you only need to execute GCC (but you need + not run :samp:`make` either to rebuild it or to run test suites), + you should be able to work directly in the :samp:`stage{N}-gcc` + directory. This makes it easier to debug multiple stages in + parallel. + +``stage`` + For each package that is bootstrapped, relocate its build directory + to indicate its stage. For example, if the :samp:`gcc` directory + points to the stage2 GCC, after invoking this target it will be + renamed to :samp:`stage2-gcc`. + + If you wish to use non-default GCC flags when compiling the stage2 and + stage3 compilers, set ``BOOT_CFLAGS`` on the command line when doing + :samp:`make`. + +Usually, the first stage only builds the languages that the compiler +is written in: typically, C and maybe Ada. If you are debugging a +miscompilation of a different stage2 front-end (for example, of the +Fortran front-end), you may want to have front-ends for other languages +in the first stage as well. To do so, set ``STAGE1_LANGUAGES`` +on the command line when doing :samp:`make`. + +For example, in the aforementioned scenario of debugging a Fortran +front-end miscompilation caused by the stage1 compiler, you may need a +command like + +.. code-block:: c++ + + make stage2-bubble STAGE1_LANGUAGES=c,fortran + +Alternatively, you can use per-language targets to build and test +languages that are not enabled by default in stage1. For example, +:command:`make f951` will build a Fortran compiler even in the stage1 +build directory. \ No newline at end of file diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/subdirectories-of-gcc.rst b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/subdirectories-of-gcc.rst new file mode 100644 index 00000000000..d857aa6c028 --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system/the-gcc-subdirectory/subdirectories-of-gcc.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _subdirectories: + +Subdirectories of gcc +^^^^^^^^^^^^^^^^^^^^^ + +The :samp:`gcc` directory contains the following subdirectories: + +:samp:`language` + Subdirectories for various languages. Directories containing a file + :samp:`config-lang.in` are language subdirectories. The contents of + the subdirectories :samp:`c` (for C), :samp:`cp` (for C++), + :samp:`objc` (for Objective-C), :samp:`objcp` (for Objective-C++), + and :samp:`lto` (for LTO) are documented in this + manual (see :ref:`passes`); + those for other languages are not. See :ref:`front-end`, for details of the files in these + directories. + +:samp:`common` + Source files shared between the compiler drivers (such as + :command:`gcc`) and the compilers proper (such as :samp:`cc1`). If an + architecture defines target hooks shared between those places, it also + has a subdirectory in :samp:`common/config`. See :ref:`target-structure`. + +:samp:`config` + Configuration files for supported architectures and operating + systems. See :ref:`back-end`, for + details of the files in this directory. + +:samp:`doc` + ReStructuredText documentation for GCC, together with automatically generated + man pages and support for converting the installation manual to + HTML. See :ref:`building_documentation`. + +:samp:`ginclude` + System headers installed by GCC, mainly those required by the C + standard of freestanding implementations. See :ref:`headers`, for details of when these and other headers are + installed. + +:samp:`po` + Message catalogs with translations of messages produced by GCC into + various languages, :samp:`{language}.po`. This directory also + contains :samp:`gcc.pot`, the template for these message catalogues, + :samp:`exgettext`, a wrapper around :command:`gettext` to extract the + messages from the GCC sources and create :samp:`gcc.pot`, which is run + by :samp:`make gcc.pot`, and :samp:`EXCLUDES`, a list of files from + which messages should not be extracted. + +:samp:`testsuite` + The GCC testsuites (except for those for runtime libraries). + See :ref:`testsuites`. \ No newline at end of file diff --git a/gcc/doc/gccint/source-tree-structure-and-build-system/top-level-source-directory.rst b/gcc/doc/gccint/source-tree-structure-and-build-system/top-level-source-directory.rst new file mode 100644 index 00000000000..abd6fa91962 --- /dev/null +++ b/gcc/doc/gccint/source-tree-structure-and-build-system/top-level-source-directory.rst @@ -0,0 +1,135 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _top-level: + +Top Level Source Directory +************************** + +The top level source directory in a GCC distribution contains several +files and directories that are shared with other software +distributions such as that of GNU Binutils. It also contains several +subdirectories that contain parts of GCC and its runtime libraries: + +:samp:`c++tools` + Contains the sources for the g++-mapper-server, a tool used with + C++ modules. + +:samp:`config` + Autoconf macros and Makefile fragments used throughout the tree. + +:samp:`contrib` + Contributed scripts that may be found useful in conjunction with GCC. + +:samp:`fixincludes` + The support for fixing system headers to work with GCC. See + :samp:`fixincludes/README` for more information. The headers fixed by + this mechanism are installed in :samp:`{libsubdir}/include-fixed`. + Along with those headers, :samp:`README-fixinc` is also installed, as + :samp:`{libsubdir}/include-fixed/README`. + +:samp:`gcc` + The main sources of GCC itself (except for runtime libraries), + including optimizers, support for different target architectures, + language front ends, and testsuites. See :ref:`gcc-directory`, for details. + +:samp:`gnattools` + Support tools for GNAT. + +:samp:`gotools` + Support tools for Go. + +:samp:`include` + Headers for the ``libiberty`` library. + +:samp:`intl` + GNU ``libintl``, from GNU ``gettext``, for systems which do not + include it in ``libc``. + +:samp:`libada` + The Ada runtime library. + +:samp:`libatomic` + The runtime support library for atomic operations (e.g. for ``__sync`` + and ``__atomic``). + +:samp:`libbacktrace` + A library that allows gcc to produce backtraces when it crashes. + +:samp:`libcc1` + A library that allows gdb to make use of the compiler. + +:samp:`libcody` + A compiler dynamism library to allow communication between compilers and + build systems, for purposes such as C++ modules. + +:samp:`libcpp` + The C preprocessor library. + +:samp:`libdecnumber` + The Decimal Float support library. + +:samp:`libffi` + The ``libffi`` library, used as part of the Go runtime library. + +:samp:`libgcc` + The GCC runtime library. + +:samp:`libgfortran` + The Fortran runtime library. + +:samp:`libgo` + The Go runtime library. The bulk of this library is mirrored from the + `master Go repository `_. + +:samp:`libgomp` + The GNU Offloading and Multi Processing Runtime Library. + +:samp:`libiberty` + The ``libiberty`` library, used for portability and for some + generally useful data structures and algorithms. See :ref:`libiberty:top`, for more information + about this library. + +:samp:`libitm` + The runtime support library for transactional memory. + +:samp:`libobjc` + The Objective-C and Objective-C++ runtime library. + +:samp:`libphobos` + The D standard and runtime library. The bulk of this library is mirrored + from the `master D repositories `_. + +:samp:`libquadmath` + The runtime support library for quad-precision math operations. + +:samp:`libsanitizer` + Libraries for various sanitizers. The bulk of this directory is mirrored + from the `Google sanitizers + repositories `_. + +:samp:`libssp` + The Stack protector runtime library. + +:samp:`libstdc++-v3` + The C++ runtime library. + +:samp:`libvtv` + The vtable verification library. + +:samp:`lto-plugin` + Plugin used by the linker if link-time optimizations are enabled. + +:samp:`maintainer-scripts` + Scripts used by the ``gccadmin`` account on ``gcc.gnu.org``. + +:samp:`zlib` + The ``zlib`` compression library, used for compressing and + uncompressing GCC's intermediate language in LTO object files. + +The build system in the top level directory, including how recursion +into subdirectories works and how building runtime libraries for +multilibs is handled, is documented in a separate manual, included +with GNU Binutils. \ No newline at end of file diff --git a/gcc/doc/gccint/standard-header-file-directories.rst b/gcc/doc/gccint/standard-header-file-directories.rst new file mode 100644 index 00000000000..0319e3caaca --- /dev/null +++ b/gcc/doc/gccint/standard-header-file-directories.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _header-dirs: + +Standard Header File Directories +-------------------------------- + +``GCC_INCLUDE_DIR`` means the same thing for native and cross. It is +where GCC stores its private include files, and also where GCC +stores the fixed include files. A cross compiled GCC runs +``fixincludes`` on the header files in :samp:`$(tooldir)/include`. +(If the cross compilation header files need to be fixed, they must be +installed before GCC is built. If the cross compilation header files +are already suitable for GCC, nothing special need be done). + +``GPLUSPLUS_INCLUDE_DIR`` means the same thing for native and cross. It +is where :command:`g++` looks first for header files. The C++ library +installs only target independent header files in that directory. + +``LOCAL_INCLUDE_DIR`` is used only by native compilers. GCC +doesn't install anything there. It is normally +:samp:`/usr/local/include`. This is where local additions to a packaged +system should place header files. + +``CROSS_INCLUDE_DIR`` is used only by cross compilers. GCC +doesn't install anything there. + +``TOOL_INCLUDE_DIR`` is used for both native and cross compilers. It +is the place for other packages to install header files that GCC will +use. For a cross-compiler, this is the equivalent of +:samp:`/usr/include`. When you build a cross-compiler, +``fixincludes`` processes any header files in this directory. \ No newline at end of file diff --git a/gcc/doc/gccint/static-analyzer.rst b/gcc/doc/gccint/static-analyzer.rst new file mode 100644 index 00000000000..a7ff1790f8e --- /dev/null +++ b/gcc/doc/gccint/static-analyzer.rst @@ -0,0 +1,19 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + + Contributed by David Malcolm . + +.. index:: analyzer, static analysis, static analyzer + +.. _static-analyzer: + +Static Analyzer +--------------- + +.. toctree:: + :maxdepth: 2 + + analyzer-internals + debugging-the-analyzer \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros.rst b/gcc/doc/gccint/target-macros.rst new file mode 100644 index 00000000000..fcdd4df85a9 --- /dev/null +++ b/gcc/doc/gccint/target-macros.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: machine description macros, target description macros, macros, target description, tm.h macros + +.. _target-macros: + +Target Description Macros and Functions +--------------------------------------- + +In addition to the file :samp:`{machine}.md`, a machine description +includes a C header file conventionally given the name +:samp:`{machine}.h` and a C source file named :samp:`{machine}.c`. +The header file defines numerous macros that convey the information +about the target machine that does not fit into the scheme of the +:samp:`.md` file. The file :samp:`tm.h` should be a link to +:samp:`{machine}.h`. The header file :samp:`config.h` includes +:samp:`tm.h` and most compiler source files include :samp:`config.h`. The +source file defines a variable ``targetm``, which is a structure +containing pointers to functions and data relating to the target +machine. :samp:`{machine}.c` should also contain their definitions, +if they are not defined elsewhere in GCC, and other functions called +through the macros defined in the :samp:`.h` file. + +.. toctree:: + :maxdepth: 2 + + target-macros/the-global-targetm-variable + target-macros/controlling-the-compilation-driver-gcc + target-macros/run-time-target-specification + target-macros/defining-data-structures-for-per-function-information + target-macros/storage-layout + target-macros/layout-of-source-language-data-types + target-macros/register-usage + target-macros/register-classes + target-macros/stack-layout-and-calling-conventions + target-macros/implementing-the-varargs-macros + target-macros/support-for-nested-functions + target-macros/implicit-calls-to-library-routines + target-macros/addressing-modes + target-macros/anchored-addresses + target-macros/condition-code-status + target-macros/describing-relative-costs-of-operations + target-macros/adjusting-the-instruction-scheduler + target-macros/dividing-the-output-into-sections-texts-data + target-macros/position-independent-code + target-macros/defining-the-output-assembler-language + target-macros/controlling-debugging-information-format + target-macros/cross-compilation-and-floating-point + target-macros/mode-switching-instructions + target-macros/defining-target-specific-uses-of-attribute + target-macros/emulating-tls + target-macros/defining-coprocessor-specifics-for-mips-targets + target-macros/parameters-for-precompiled-header-validity-checking + target-macros/c++-abi-parameters + target-macros/d-abi-parameters + target-macros/adding-support-for-named-address-spaces + target-macros/miscellaneous-parameters \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/adding-support-for-named-address-spaces.rst b/gcc/doc/gccint/target-macros/adding-support-for-named-address-spaces.rst new file mode 100644 index 00000000000..fcff73bb179 --- /dev/null +++ b/gcc/doc/gccint/target-macros/adding-support-for-named-address-spaces.rst @@ -0,0 +1,163 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: named address spaces + +.. _named-address-spaces: + +Adding support for named address spaces +*************************************** + +The draft technical report of the ISO/IEC JTC1 S22 WG14 N1275 +standards committee, Programming Languages - C - Extensions to +support embedded processors, specifies a syntax for embedded +processors to specify alternate address spaces. You can configure a +GCC port to support section 5.1 of the draft report to add support for +address spaces other than the default address space. These address +spaces are new keywords that are similar to the ``volatile`` and +``const`` type attributes. + +Pointers to named address spaces can have a different size than +pointers to the generic address space. + +For example, the SPU port uses the ``__ea`` address space to refer +to memory in the host processor, rather than memory local to the SPU +processor. Access to memory in the ``__ea`` address space involves +issuing DMA operations to move data between the host processor and the +local processor memory address space. Pointers in the ``__ea`` +address space are either 32 bits or 64 bits based on the +:option:`-mea32` or :option:`-mea64` switches (native SPU pointers are +always 32 bits). + +Internally, address spaces are represented as a small integer in the +range 0 to 15 with address space 0 being reserved for the generic +address space. + +To register a named address space qualifier keyword with the C front end, +the target may call the ``c_register_addr_space`` routine. For example, +the SPU port uses the following to declare ``__ea`` as the keyword for +named address space #1: + +.. code-block:: c++ + + #define ADDR_SPACE_EA 1 + c_register_addr_space ("__ea", ADDR_SPACE_EA); + +.. function:: scalar_int_mode TARGET_ADDR_SPACE_POINTER_MODE (addr_space_t address_space) + + .. hook-start:TARGET_ADDR_SPACE_POINTER_MODE + + Define this to return the machine mode to use for pointers to + :samp:`{address_space}` if the target supports named address spaces. + The default version of this hook returns ``ptr_mode``. + +.. hook-end + +.. function:: scalar_int_mode TARGET_ADDR_SPACE_ADDRESS_MODE (addr_space_t address_space) + + .. hook-start:TARGET_ADDR_SPACE_ADDRESS_MODE + + Define this to return the machine mode to use for addresses in + :samp:`{address_space}` if the target supports named address spaces. + The default version of this hook returns ``Pmode``. + +.. hook-end + +.. function:: bool TARGET_ADDR_SPACE_VALID_POINTER_MODE (scalar_int_mode mode, addr_space_t as) + + .. hook-start:TARGET_ADDR_SPACE_VALID_POINTER_MODE + + Define this to return nonzero if the port can handle pointers + with machine mode :samp:`{mode}` to address space :samp:`{as}`. This target + hook is the same as the ``TARGET_VALID_POINTER_MODE`` target hook, + except that it includes explicit named address space support. The default + version of this hook returns true for the modes returned by either the + ``TARGET_ADDR_SPACE_POINTER_MODE`` or ``TARGET_ADDR_SPACE_ADDRESS_MODE`` + target hooks for the given address space. + +.. hook-end + +.. function:: bool TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P (machine_mode mode, rtx exp, bool strict, addr_space_t as) + + .. hook-start:TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P + + Define this to return true if :samp:`{exp}` is a valid address for mode + :samp:`{mode}` in the named address space :samp:`{as}`. The :samp:`{strict}` + parameter says whether strict addressing is in effect after reload has + finished. This target hook is the same as the + ``TARGET_LEGITIMATE_ADDRESS_P`` target hook, except that it includes + explicit named address space support. + +.. hook-end + +.. function:: rtx TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS (rtx x, rtx oldx, machine_mode mode, addr_space_t as) + + .. hook-start:TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS + + Define this to modify an invalid address :samp:`{x}` to be a valid address + with mode :samp:`{mode}` in the named address space :samp:`{as}`. This target + hook is the same as the ``TARGET_LEGITIMIZE_ADDRESS`` target hook, + except that it includes explicit named address space support. + +.. hook-end + +.. function:: bool TARGET_ADDR_SPACE_SUBSET_P (addr_space_t subset, addr_space_t superset) + + .. hook-start:TARGET_ADDR_SPACE_SUBSET_P + + Define this to return whether the :samp:`{subset}` named address space is + contained within the :samp:`{superset}` named address space. Pointers to + a named address space that is a subset of another named address space + will be converted automatically without a cast if used together in + arithmetic operations. Pointers to a superset address space can be + converted to pointers to a subset address space via explicit casts. + +.. hook-end + +.. function:: bool TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID (addr_space_t as) + + .. hook-start:TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID + + Define this to modify the default handling of address 0 for the + address space. Return true if 0 should be considered a valid address. + +.. hook-end + +.. function:: rtx TARGET_ADDR_SPACE_CONVERT (rtx op, tree from_type, tree to_type) + + .. hook-start:TARGET_ADDR_SPACE_CONVERT + + Define this to convert the pointer expression represented by the RTL + :samp:`{op}` with type :samp:`{from_type}` that points to a named address + space to a new pointer expression with type :samp:`{to_type}` that points + to a different named address space. When this hook it called, it is + guaranteed that one of the two address spaces is a subset of the other, + as determined by the ``TARGET_ADDR_SPACE_SUBSET_P`` target hook. + +.. hook-end + +.. function:: int TARGET_ADDR_SPACE_DEBUG (addr_space_t as) + + .. hook-start:TARGET_ADDR_SPACE_DEBUG + + Define this to define how the address space is encoded in dwarf. + The result is the value to be used with ``DW_AT_address_class``. + +.. hook-end + +.. function:: void TARGET_ADDR_SPACE_DIAGNOSE_USAGE (addr_space_t as, location_t loc) + + .. hook-start:TARGET_ADDR_SPACE_DIAGNOSE_USAGE + + Define this hook if the availability of an address space depends on + command line options and some diagnostics should be printed when the + address space is used. This hook is called during parsing and allows + to emit a better diagnostic compared to the case where the address space + was not registered with ``c_register_addr_space``. :samp:`{as}` is + the address space as registered with ``c_register_addr_space``. + :samp:`{loc}` is the location of the address space qualifier token. + The default implementation does nothing. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/addressing-modes.rst b/gcc/doc/gccint/target-macros/addressing-modes.rst new file mode 100644 index 00000000000..03428bd48ca --- /dev/null +++ b/gcc/doc/gccint/target-macros/addressing-modes.rst @@ -0,0 +1,824 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: addressing modes + +.. _addressing-modes: + +Addressing Modes +**************** + +.. prevent bad page break with this line + +This is about addressing modes. + +.. c:macro:: HAVE_PRE_INCREMENT + HAVE_PRE_DECREMENT + HAVE_POST_INCREMENT + HAVE_POST_DECREMENT + + A C expression that is nonzero if the machine supports pre-increment, + pre-decrement, post-increment, or post-decrement addressing respectively. + +.. c:macro:: HAVE_PRE_MODIFY_DISP + HAVE_POST_MODIFY_DISP + + A C expression that is nonzero if the machine supports pre- or + post-address side-effect generation involving constants other than + the size of the memory operand. + +.. c:macro:: HAVE_PRE_MODIFY_REG + HAVE_POST_MODIFY_REG + + A C expression that is nonzero if the machine supports pre- or + post-address side-effect generation involving a register displacement. + +.. c:macro:: CONSTANT_ADDRESS_P (x) + + A C expression that is 1 if the RTX :samp:`{x}` is a constant which + is a valid address. On most machines the default definition of + ``(CONSTANT_P (x) && GET_CODE (x) != CONST_DOUBLE)`` + is acceptable, but a few machines are more restrictive as to which + constant addresses are supported. + +.. c:macro:: CONSTANT_P (x) + + ``CONSTANT_P``, which is defined by target-independent code, + accepts integer-values expressions whose values are not explicitly + known, such as ``symbol_ref``, ``label_ref``, and ``high`` + expressions and ``const`` arithmetic expressions, in addition to + ``const_int`` and ``const_double`` expressions. + +.. c:macro:: MAX_REGS_PER_ADDRESS + + A number, the maximum number of registers that can appear in a valid + memory address. Note that it is up to you to specify a value equal to + the maximum number that ``TARGET_LEGITIMATE_ADDRESS_P`` would ever + accept. + +.. function:: bool TARGET_LEGITIMATE_ADDRESS_P (machine_mode mode, rtx x, bool strict) + + .. hook-start:TARGET_LEGITIMATE_ADDRESS_P + + A function that returns whether :samp:`{x}` (an RTX) is a legitimate memory + address on the target machine for a memory operand of mode :samp:`{mode}`. + + Legitimate addresses are defined in two variants: a strict variant and a + non-strict one. The :samp:`{strict}` parameter chooses which variant is + desired by the caller. + + The strict variant is used in the reload pass. It must be defined so + that any pseudo-register that has not been allocated a hard register is + considered a memory reference. This is because in contexts where some + kind of register is required, a pseudo-register with no hard register + must be rejected. For non-hard registers, the strict variant should look + up the ``reg_renumber`` array; it should then proceed using the hard + register number in the array, or treat the pseudo as a memory reference + if the array holds ``-1``. + + The non-strict variant is used in other passes. It must be defined to + accept all pseudo-registers in every context where some kind of + register is required. + + Normally, constant addresses which are the sum of a ``symbol_ref`` + and an integer are stored inside a ``const`` RTX to mark them as + constant. Therefore, there is no need to recognize such sums + specifically as legitimate addresses. Normally you would simply + recognize any ``const`` as legitimate. + + Usually ``PRINT_OPERAND_ADDRESS`` is not prepared to handle constant + sums that are not marked with ``const``. It assumes that a naked + ``plus`` indicates indexing. If so, then you *must* reject such + naked constant sums as illegitimate addresses, so that none of them will + be given to ``PRINT_OPERAND_ADDRESS``. + + .. index:: TARGET_ENCODE_SECTION_INFO and address validation + + On some machines, whether a symbolic address is legitimate depends on + the section that the address refers to. On these machines, define the + target hook ``TARGET_ENCODE_SECTION_INFO`` to store the information + into the ``symbol_ref``, and then check for it here. When you see a + ``const``, you will have to look inside it to find the + ``symbol_ref`` in order to determine the section. See :ref:`assembler-format`. + + .. index:: GO_IF_LEGITIMATE_ADDRESS + + Some ports are still using a deprecated legacy substitute for + this hook, the ``GO_IF_LEGITIMATE_ADDRESS`` macro. This macro + has this syntax: + + .. code-block:: c++ + + #define GO_IF_LEGITIMATE_ADDRESS (mode, x, label) + + and should ``goto label`` if the address :samp:`{x}` is a valid + address on the target machine for a memory operand of mode :samp:`{mode}`. + + .. index:: REG_OK_STRICT + + Compiler source files that want to use the strict variant of this + macro define the macro ``REG_OK_STRICT``. You should use an + ``#ifdef REG_OK_STRICT`` conditional to define the strict variant in + that case and the non-strict variant otherwise. + + Using the hook is usually simpler because it limits the number of + files that are recompiled when changes are made. + +.. hook-end + +.. c:macro:: TARGET_MEM_CONSTRAINT + + A single character to be used instead of the default ``'m'`` + character for general memory addresses. This defines the constraint + letter which matches the memory addresses accepted by + ``TARGET_LEGITIMATE_ADDRESS_P``. Define this macro if you want to + support new address formats in your back end without changing the + semantics of the ``'m'`` constraint. This is necessary in order to + preserve functionality of inline assembly constructs using the + ``'m'`` constraint. + +.. c:macro:: FIND_BASE_TERM (x) + + A C expression to determine the base term of address :samp:`{x}`, + or to provide a simplified version of :samp:`{x}` from which :samp:`alias.cc` + can easily find the base term. This macro is used in only two places: + ``find_base_value`` and ``find_base_term`` in :samp:`alias.cc`. + + It is always safe for this macro to not be defined. It exists so + that alias analysis can understand machine-dependent addresses. + + The typical use of this macro is to handle addresses containing + a label_ref or symbol_ref within an UNSPEC. + +.. function:: rtx TARGET_LEGITIMIZE_ADDRESS (rtx x, rtx oldx, machine_mode mode) + + .. hook-start:TARGET_LEGITIMIZE_ADDRESS + + This hook is given an invalid memory address :samp:`{x}` for an + operand of mode :samp:`{mode}` and should try to return a valid memory + address. + + .. index:: break_out_memory_refs + + :samp:`{x}` will always be the result of a call to ``break_out_memory_refs``, + and :samp:`{oldx}` will be the operand that was given to that function to produce + :samp:`{x}`. + + The code of the hook should not alter the substructure of + :samp:`{x}`. If it transforms :samp:`{x}` into a more legitimate form, it + should return the new :samp:`{x}`. + + It is not necessary for this hook to come up with a legitimate address, + with the exception of native TLS addresses (see :ref:`emulated-tls`). + The compiler has standard ways of doing so in all cases. In fact, if + the target supports only emulated TLS, it + is safe to omit this hook or make it return :samp:`{x}` if it cannot find + a valid way to legitimize the address. But often a machine-dependent + strategy can generate better code. + +.. hook-end + +.. c:macro:: LEGITIMIZE_RELOAD_ADDRESS (x, mode, opnum, type, ind_levels, win) + + A C compound statement that attempts to replace :samp:`{x}`, which is an address + that needs reloading, with a valid memory address for an operand of mode + :samp:`{mode}`. :samp:`{win}` will be a C statement label elsewhere in the code. + It is not necessary to define this macro, but it might be useful for + performance reasons. + + For example, on the i386, it is sometimes possible to use a single + reload register instead of two by reloading a sum of two pseudo + registers into a register. On the other hand, for number of RISC + processors offsets are limited so that often an intermediate address + needs to be generated in order to address a stack slot. By defining + ``LEGITIMIZE_RELOAD_ADDRESS`` appropriately, the intermediate addresses + generated for adjacent some stack slots can be made identical, and thus + be shared. + + .. note:: + + This macro should be used with caution. It is necessary + to know something of how reload works in order to effectively use this, + and it is quite easy to produce macros that build in too much knowledge + of reload internals. + + .. note:: + + This macro must be able to reload an address created by a + previous invocation of this macro. If it fails to handle such addresses + then the compiler may generate incorrect code or abort. + + .. index:: push_reload + + The macro definition should use ``push_reload`` to indicate parts that + need reloading; :samp:`{opnum}`, :samp:`{type}` and :samp:`{ind_levels}` are usually + suitable to be passed unaltered to ``push_reload``. + + The code generated by this macro must not alter the substructure of + :samp:`{x}`. If it transforms :samp:`{x}` into a more legitimate form, it + should assign :samp:`{x}` (which will always be a C variable) a new value. + This also applies to parts that you change indirectly by calling + ``push_reload``. + + .. index:: strict_memory_address_p + + The macro definition may use ``strict_memory_address_p`` to test if + the address has become legitimate. + + .. index:: copy_rtx + + If you want to change only a part of :samp:`{x}`, one standard way of doing + this is to use ``copy_rtx``. Note, however, that it unshares only a + single level of rtl. Thus, if the part to be changed is not at the + top level, you'll need to replace first the top level. + It is not necessary for this macro to come up with a legitimate + address; but often a machine-dependent strategy can generate better code. + +.. function:: bool TARGET_MODE_DEPENDENT_ADDRESS_P (const_rtx addr, addr_space_t addrspace) + + .. hook-start:TARGET_MODE_DEPENDENT_ADDRESS_P + + This hook returns ``true`` if memory address :samp:`{addr}` in address + space :samp:`{addrspace}` can have + different meanings depending on the machine mode of the memory + reference it is used for or if the address is valid for some modes + but not others. + + Autoincrement and autodecrement addresses typically have mode-dependent + effects because the amount of the increment or decrement is the size + of the operand being addressed. Some machines have other mode-dependent + addresses. Many RISC machines have no mode-dependent addresses. + + You may assume that :samp:`{addr}` is a valid address for the machine. + + The default version of this hook returns ``false``. + +.. hook-end + +.. function:: bool TARGET_LEGITIMATE_CONSTANT_P (machine_mode mode, rtx x) + + .. hook-start:TARGET_LEGITIMATE_CONSTANT_P + + This hook returns true if :samp:`{x}` is a legitimate constant for a + :samp:`{mode}` -mode immediate operand on the target machine. You can assume that + :samp:`{x}` satisfies ``CONSTANT_P``, so you need not check this. + + The default definition returns true. + +.. hook-end + +.. function:: bool TARGET_PRECOMPUTE_TLS_P (machine_mode mode, rtx x) + + .. hook-start:TARGET_PRECOMPUTE_TLS_P + + This hook returns true if :samp:`{x}` is a TLS operand on the target + machine that should be pre-computed when used as the argument in a call. + You can assume that :samp:`{x}` satisfies ``CONSTANT_P``, so you need not + check this. + + The default definition returns false. + +.. hook-end + +.. function:: rtx TARGET_DELEGITIMIZE_ADDRESS (rtx x) + + .. hook-start:TARGET_DELEGITIMIZE_ADDRESS + + This hook is used to undo the possibly obfuscating effects of the + ``LEGITIMIZE_ADDRESS`` and ``LEGITIMIZE_RELOAD_ADDRESS`` target + macros. Some backend implementations of these macros wrap symbol + references inside an ``UNSPEC`` rtx to represent PIC or similar + addressing modes. This target hook allows GCC's optimizers to understand + the semantics of these opaque ``UNSPEC`` s by converting them back + into their original form. + +.. hook-end + +.. function:: bool TARGET_CONST_NOT_OK_FOR_DEBUG_P (rtx x) + + .. hook-start:TARGET_CONST_NOT_OK_FOR_DEBUG_P + + This hook should return true if :samp:`{x}` should not be emitted into + debug sections. + +.. hook-end + +.. function:: bool TARGET_CANNOT_FORCE_CONST_MEM (machine_mode mode, rtx x) + + .. hook-start:TARGET_CANNOT_FORCE_CONST_MEM + + This hook should return true if :samp:`{x}` is of a form that cannot (or + should not) be spilled to the constant pool. :samp:`{mode}` is the mode + of :samp:`{x}`. + + The default version of this hook returns false. + + The primary reason to define this hook is to prevent reload from + deciding that a non-legitimate constant would be better reloaded + from the constant pool instead of spilling and reloading a register + holding the constant. This restriction is often true of addresses + of TLS symbols for various targets. + +.. hook-end + +.. function:: bool TARGET_USE_BLOCKS_FOR_CONSTANT_P (machine_mode mode, const_rtx x) + + .. hook-start:TARGET_USE_BLOCKS_FOR_CONSTANT_P + + This hook should return true if pool entries for constant :samp:`{x}` can + be placed in an ``object_block`` structure. :samp:`{mode}` is the mode + of :samp:`{x}`. + + The default version returns false for all constants. + +.. hook-end + +.. function:: bool TARGET_USE_BLOCKS_FOR_DECL_P (const_tree decl) + + .. hook-start:TARGET_USE_BLOCKS_FOR_DECL_P + + This hook should return true if pool entries for :samp:`{decl}` should + be placed in an ``object_block`` structure. + + The default version returns true for all decls. + +.. hook-end + +.. function:: tree TARGET_BUILTIN_RECIPROCAL (tree fndecl) + + .. hook-start:TARGET_BUILTIN_RECIPROCAL + + This hook should return the DECL of a function that implements the + reciprocal of the machine-specific builtin function :samp:`{fndecl}`, or + ``NULL_TREE`` if such a function is not available. + +.. hook-end + +.. function:: tree TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD (void) + + .. hook-start:TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD + + This hook should return the DECL of a function :samp:`{f}` that given an + address :samp:`{addr}` as an argument returns a mask :samp:`{m}` that can be + used to extract from two vectors the relevant data that resides in + :samp:`{addr}` in case :samp:`{addr}` is not properly aligned. + + The autovectorizer, when vectorizing a load operation from an address + :samp:`{addr}` that may be unaligned, will generate two vector loads from + the two aligned addresses around :samp:`{addr}`. It then generates a + ``REALIGN_LOAD`` operation to extract the relevant data from the + two loaded vectors. The first two arguments to ``REALIGN_LOAD``, + :samp:`{v1}` and :samp:`{v2}`, are the two vectors, each of size :samp:`{VS}`, and + the third argument, :samp:`{OFF}`, defines how the data will be extracted + from these two vectors: if :samp:`{OFF}` is 0, then the returned vector is + :samp:`{v2}` ; otherwise, the returned vector is composed from the last + :samp:`{VS}` - :samp:`{OFF}` elements of :samp:`{v1}` concatenated to the first + :samp:`{OFF}` elements of :samp:`{v2}`. + + If this hook is defined, the autovectorizer will generate a call + to :samp:`{f}` (using the DECL tree that this hook returns) and will + use the return value of :samp:`{f}` as the argument :samp:`{OFF}` to + ``REALIGN_LOAD``. Therefore, the mask :samp:`{m}` returned by :samp:`{f}` + should comply with the semantics expected by ``REALIGN_LOAD`` + described above. + If this hook is not defined, then :samp:`{addr}` will be used as + the argument :samp:`{OFF}` to ``REALIGN_LOAD``, in which case the low + log2(:samp:`{VS}`) - 1 bits of :samp:`{addr}` will be considered. + +.. hook-end + +.. function:: int TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST (enum vect_cost_for_stmt type_of_cost, tree vectype, int misalign) + + .. hook-start:TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST + + Returns cost of different scalar or vector statements for vectorization cost model. + For vector memory operations the cost may depend on type (:samp:`{vectype}`) and + misalignment value (:samp:`{misalign}`). + +.. hook-end + +.. function:: poly_uint64 TARGET_VECTORIZE_PREFERRED_VECTOR_ALIGNMENT (const_tree type) + + .. hook-start:TARGET_VECTORIZE_PREFERRED_VECTOR_ALIGNMENT + + This hook returns the preferred alignment in bits for accesses to + vectors of type :samp:`{type}` in vectorized code. This might be less than + or greater than the ABI-defined value returned by + ``TARGET_VECTOR_ALIGNMENT``. It can be equal to the alignment of + a single element, in which case the vectorizer will not try to optimize + for alignment. + + The default hook returns ``TYPE_ALIGN (type)``, which is + correct for most targets. + +.. hook-end + +.. function:: bool TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE (const_tree type, bool is_packed) + + .. hook-start:TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE + + Return true if vector alignment is reachable (by peeling N iterations) + for the given scalar type :samp:`{type}`. :samp:`{is_packed}` is false if the scalar + access using :samp:`{type}` is known to be naturally aligned. + +.. hook-end + +.. function:: bool TARGET_VECTORIZE_VEC_PERM_CONST (machine_mode mode, machine_mode op_mode, rtx output, rtx in0, rtx in1, const vec_perm_indices &sel) + + .. hook-start:TARGET_VECTORIZE_VEC_PERM_CONST + + This hook is used to test whether the target can permute up to two + vectors of mode :samp:`{op_mode}` using the permutation vector ``sel``, + producing a vector of mode :samp:`{mode}`. The hook is also used to emit such + a permutation. + + When the hook is being used to test whether the target supports a permutation, + :samp:`{in0}`, :samp:`{in1}`, and :samp:`{out}` are all null. When the hook is being used + to emit a permutation, :samp:`{in0}` and :samp:`{in1}` are the source vectors of mode + :samp:`{op_mode}` and :samp:`{out}` is the destination vector of mode :samp:`{mode}`. + :samp:`{in1}` is the same as :samp:`{in0}` if :samp:`{sel}` describes a permutation on one + vector instead of two. + + Return true if the operation is possible, emitting instructions for it + if rtxes are provided. + + .. index:: vec_permm instruction pattern + + If the hook returns false for a mode with multibyte elements, GCC will + try the equivalent byte operation. If that also fails, it will try forcing + the selector into a register and using the :samp:`{vec_perm {mode} }` + instruction pattern. There is no need for the hook to handle these two + implementation approaches itself. + +.. hook-end + +.. function:: tree TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION (unsigned code, tree vec_type_out, tree vec_type_in) + + .. hook-start:TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION + + This hook should return the decl of a function that implements the + vectorized variant of the function with the ``combined_fn`` code + :samp:`{code}` or ``NULL_TREE`` if such a function is not available. + The return type of the vectorized function shall be of vector type + :samp:`{vec_type_out}` and the argument types should be :samp:`{vec_type_in}`. + +.. hook-end + +.. function:: tree TARGET_VECTORIZE_BUILTIN_MD_VECTORIZED_FUNCTION (tree fndecl, tree vec_type_out, tree vec_type_in) + + .. hook-start:TARGET_VECTORIZE_BUILTIN_MD_VECTORIZED_FUNCTION + + This hook should return the decl of a function that implements the + vectorized variant of target built-in function ``fndecl``. The + return type of the vectorized function shall be of vector type + :samp:`{vec_type_out}` and the argument types should be :samp:`{vec_type_in}`. + +.. hook-end + +.. function:: bool TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT (machine_mode mode, const_tree type, int misalignment, bool is_packed) + + .. hook-start:TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT + + This hook should return true if the target supports misaligned vector + store/load of a specific factor denoted in the :samp:`{misalignment}` + parameter. The vector store/load should be of machine mode :samp:`{mode}` and + the elements in the vectors should be of type :samp:`{type}`. :samp:`{is_packed}` + parameter is true if the memory access is defined in a packed struct. + +.. hook-end + +.. function:: machine_mode TARGET_VECTORIZE_PREFERRED_SIMD_MODE (scalar_mode mode) + + .. hook-start:TARGET_VECTORIZE_PREFERRED_SIMD_MODE + + This hook should return the preferred mode for vectorizing scalar + mode :samp:`{mode}`. The default is + equal to ``word_mode``, because the vectorizer can do some + transformations even in absence of specialized SIMD hardware. + +.. hook-end + +.. function:: machine_mode TARGET_VECTORIZE_SPLIT_REDUCTION (machine_mode) + + .. hook-start:TARGET_VECTORIZE_SPLIT_REDUCTION + + This hook should return the preferred mode to split the final reduction + step on :samp:`{mode}` to. The reduction is then carried out reducing upper + against lower halves of vectors recursively until the specified mode is + reached. The default is :samp:`{mode}` which means no splitting. + +.. hook-end + +.. function:: unsigned int TARGET_VECTORIZE_AUTOVECTORIZE_VECTOR_MODES (vector_modes *modes, bool all) + + .. hook-start:TARGET_VECTORIZE_AUTOVECTORIZE_VECTOR_MODES + + If using the mode returned by ``TARGET_VECTORIZE_PREFERRED_SIMD_MODE`` + is not the only approach worth considering, this hook should add one mode to + :samp:`{modes}` for each useful alternative approach. These modes are then + passed to ``TARGET_VECTORIZE_RELATED_MODE`` to obtain the vector mode + for a given element mode. + + The modes returned in :samp:`{modes}` should use the smallest element mode + possible for the vectorization approach that they represent, preferring + integer modes over floating-poing modes in the event of a tie. The first + mode should be the ``TARGET_VECTORIZE_PREFERRED_SIMD_MODE`` for its + element mode. + + If :samp:`{all}` is true, add suitable vector modes even when they are generally + not expected to be worthwhile. + + The hook returns a bitmask of flags that control how the modes in + :samp:`{modes}` are used. The flags are: + + .. envvar:: VECT_COMPARE_COSTS + + Tells the loop vectorizer to try all the provided modes and pick the one + with the lowest cost. By default the vectorizer will choose the first + mode that works. + + The hook does not need to do anything if the vector returned by + ``TARGET_VECTORIZE_PREFERRED_SIMD_MODE`` is the only one relevant + for autovectorization. The default implementation adds no modes and + returns 0. + +.. hook-end + +.. function:: opt_machine_mode TARGET_VECTORIZE_RELATED_MODE (machine_mode vector_mode, scalar_mode element_mode, poly_uint64 nunits) + + .. hook-start:TARGET_VECTORIZE_RELATED_MODE + + If a piece of code is using vector mode :samp:`{vector_mode}` and also wants + to operate on elements of mode :samp:`{element_mode}`, return the vector mode + it should use for those elements. If :samp:`{nunits}` is nonzero, ensure that + the mode has exactly :samp:`{nunits}` elements, otherwise pick whichever vector + size pairs the most naturally with :samp:`{vector_mode}`. Return an empty + ``opt_machine_mode`` if there is no supported vector mode with the + required properties. + + There is no prescribed way of handling the case in which :samp:`{nunits}` + is zero. One common choice is to pick a vector mode with the same size + as :samp:`{vector_mode}` ; this is the natural choice if the target has a + fixed vector size. Another option is to choose a vector mode with the + same number of elements as :samp:`{vector_mode}` ; this is the natural choice + if the target has a fixed number of elements. Alternatively, the hook + might choose a middle ground, such as trying to keep the number of + elements as similar as possible while applying maximum and minimum + vector sizes. + + The default implementation uses ``mode_for_vector`` to find the + requested mode, returning a mode with the same size as :samp:`{vector_mode}` + when :samp:`{nunits}` is zero. This is the correct behavior for most targets. + +.. hook-end + +.. function:: opt_machine_mode TARGET_VECTORIZE_GET_MASK_MODE (machine_mode mode) + + .. hook-start:TARGET_VECTORIZE_GET_MASK_MODE + + Return the mode to use for a vector mask that holds one boolean + result for each element of vector mode :samp:`{mode}`. The returned mask mode + can be a vector of integers (class ``MODE_VECTOR_INT``), a vector of + booleans (class ``MODE_VECTOR_BOOL``) or a scalar integer (class + ``MODE_INT``). Return an empty ``opt_machine_mode`` if no such + mask mode exists. + + The default implementation returns a ``MODE_VECTOR_INT`` with the + same size and number of elements as :samp:`{mode}`, if such a mode exists. + +.. hook-end + +.. function:: bool TARGET_VECTORIZE_EMPTY_MASK_IS_EXPENSIVE (unsigned ifn) + + .. hook-start:TARGET_VECTORIZE_EMPTY_MASK_IS_EXPENSIVE + + This hook returns true if masked internal function :samp:`{ifn}` (really of + type ``internal_fn``) should be considered expensive when the mask is + all zeros. GCC can then try to branch around the instruction instead. + +.. hook-end + +.. function:: class vector_costs * TARGET_VECTORIZE_CREATE_COSTS (vec_info *vinfo, bool costing_for_scalar) + + .. hook-start:TARGET_VECTORIZE_CREATE_COSTS + + This hook should initialize target-specific data structures in preparation + for modeling the costs of vectorizing a loop or basic block. The default + allocates three unsigned integers for accumulating costs for the prologue, + body, and epilogue of the loop or basic block. If :samp:`{loop_info}` is + non-NULL, it identifies the loop being vectorized; otherwise a single block + is being vectorized. If :samp:`{costing_for_scalar}` is true, it indicates the + current cost model is for the scalar version of a loop or block; otherwise + it is for the vector version. + +.. hook-end + +.. function:: tree TARGET_VECTORIZE_BUILTIN_GATHER (const_tree mem_vectype, const_tree index_type, int scale) + + .. hook-start:TARGET_VECTORIZE_BUILTIN_GATHER + + Target builtin that implements vector gather operation. :samp:`{mem_vectype}` + is the vector type of the load and :samp:`{index_type}` is scalar type of + the index, scaled by :samp:`{scale}`. + The default is ``NULL_TREE`` which means to not vectorize gather + loads. + +.. hook-end + +.. function:: tree TARGET_VECTORIZE_BUILTIN_SCATTER (const_tree vectype, const_tree index_type, int scale) + + .. hook-start:TARGET_VECTORIZE_BUILTIN_SCATTER + + Target builtin that implements vector scatter operation. :samp:`{vectype}` + is the vector type of the store and :samp:`{index_type}` is scalar type of + the index, scaled by :samp:`{scale}`. + The default is ``NULL_TREE`` which means to not vectorize scatter + stores. + +.. hook-end + +.. function:: int TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN (struct cgraph_node *, struct cgraph_simd_clone *, tree, int) + + .. hook-start:TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN + + This hook should set :samp:`{vecsize_mangle}`, :samp:`{vecsize_int}`, :samp:`{vecsize_float}` + fields in :samp:`{simd_clone}` structure pointed by :samp:`{clone_info}` argument and also + :samp:`{simdlen}` field if it was previously 0. + :samp:`{vecsize_mangle}` is a marker for the backend only. :samp:`{vecsize_int}` and + :samp:`{vecsize_float}` should be left zero on targets where the number of lanes is + not determined by the bitsize (in which case :samp:`{simdlen}` is always used). + The hook should return 0 if SIMD clones shouldn't be emitted, + or number of :samp:`{vecsize_mangle}` variants that should be emitted. + +.. hook-end + +.. function:: void TARGET_SIMD_CLONE_ADJUST (struct cgraph_node *) + + .. hook-start:TARGET_SIMD_CLONE_ADJUST + + This hook should add implicit ``attribute(target("..."))`` attribute + to SIMD clone :samp:`{node}` if needed. + +.. hook-end + +.. function:: int TARGET_SIMD_CLONE_USABLE (struct cgraph_node *) + + .. hook-start:TARGET_SIMD_CLONE_USABLE + + This hook should return -1 if SIMD clone :samp:`{node}` shouldn't be used + in vectorized loops in current function, or non-negative number if it is + usable. In that case, the smaller the number is, the more desirable it is + to use it. + +.. hook-end + +.. function:: int TARGET_SIMT_VF (void) + + .. hook-start:TARGET_SIMT_VF + + Return number of threads in SIMT thread group on the target. + +.. hook-end + +.. function:: int TARGET_OMP_DEVICE_KIND_ARCH_ISA (enum omp_device_kind_arch_isa trait, const char *name) + + .. hook-start:TARGET_OMP_DEVICE_KIND_ARCH_ISA + + Return 1 if :samp:`{trait}` :samp:`{name}` is present in the OpenMP context's + device trait set, return 0 if not present in any OpenMP context in the + whole translation unit, or -1 if not present in the current OpenMP context + but might be present in another OpenMP context in the same TU. + +.. hook-end + +.. function:: bool TARGET_GOACC_VALIDATE_DIMS (tree decl, int *dims, int fn_level, unsigned used) + + .. hook-start:TARGET_GOACC_VALIDATE_DIMS + + This hook should check the launch dimensions provided for an OpenACC + compute region, or routine. Defaulted values are represented as -1 + and non-constant values as 0. The :samp:`{fn_level}` is negative for the + function corresponding to the compute region. For a routine it is the + outermost level at which partitioned execution may be spawned. The hook + should verify non-default values. If DECL is NULL, global defaults + are being validated and unspecified defaults should be filled in. + Diagnostics should be issued as appropriate. Return + true, if changes have been made. You must override this hook to + provide dimensions larger than 1. + +.. hook-end + +.. function:: int TARGET_GOACC_DIM_LIMIT (int axis) + + .. hook-start:TARGET_GOACC_DIM_LIMIT + + This hook should return the maximum size of a particular dimension, + or zero if unbounded. + +.. hook-end + +.. function:: bool TARGET_GOACC_FORK_JOIN (gcall *call, const int *dims, bool is_fork) + + .. hook-start:TARGET_GOACC_FORK_JOIN + + This hook can be used to convert IFN_GOACC_FORK and IFN_GOACC_JOIN + function calls to target-specific gimple, or indicate whether they + should be retained. It is executed during the oacc_device_lower pass. + It should return true, if the call should be retained. It should + return false, if it is to be deleted (either because target-specific + gimple has been inserted before it, or there is no need for it). + The default hook returns false, if there are no RTL expanders for them. + +.. hook-end + +.. function:: void TARGET_GOACC_REDUCTION (gcall *call) + + .. hook-start:TARGET_GOACC_REDUCTION + + This hook is used by the oacc_transform pass to expand calls to the + :samp:`{GOACC_REDUCTION}` internal function, into a sequence of gimple + instructions. :samp:`{call}` is gimple statement containing the call to + the function. This hook removes statement :samp:`{call}` after the + expanded sequence has been inserted. This hook is also responsible + for allocating any storage for reductions when necessary. + +.. hook-end + +.. function:: tree TARGET_PREFERRED_ELSE_VALUE (unsigned ifn, tree type, unsigned nops, tree *ops) + + .. hook-start:TARGET_PREFERRED_ELSE_VALUE + + This hook returns the target's preferred final argument for a call + to conditional internal function :samp:`{ifn}` (really of type + ``internal_fn``). :samp:`{type}` specifies the return type of the + function and :samp:`{ops}` are the operands to the conditional operation, + of which there are :samp:`{nops}`. + + For example, if :samp:`{ifn}` is ``IFN_COND_ADD``, the hook returns + a value of type :samp:`{type}` that should be used when :samp:`{ops}[0]` + and :samp:`{ops}[1]` are conditionally added together. + + This hook is only relevant if the target supports conditional patterns + like ``cond_addm``. The default implementation returns a zero + constant of type :samp:`{type}`. + +.. hook-end + +.. function:: tree TARGET_GOACC_ADJUST_PRIVATE_DECL (location_t loc, tree var, int level) + + .. hook-start:TARGET_GOACC_ADJUST_PRIVATE_DECL + + This hook, if defined, is used by accelerator target back-ends to adjust + OpenACC variable declarations that should be made private to the given + parallelism level (i.e. ``GOMP_DIM_GANG``, ``GOMP_DIM_WORKER`` or + ``GOMP_DIM_VECTOR``). A typical use for this hook is to force variable + declarations at the ``gang`` level to reside in GPU shared memory. + :samp:`{loc}` may be used for diagnostic purposes. + + You may also use the ``TARGET_GOACC_EXPAND_VAR_DECL`` hook if the + adjusted variable declaration needs to be expanded to RTL in a non-standard + way. + +.. hook-end + +.. function:: rtx TARGET_GOACC_EXPAND_VAR_DECL (tree var) + + .. hook-start:TARGET_GOACC_EXPAND_VAR_DECL + + This hook, if defined, is used by accelerator target back-ends to expand + specially handled kinds of ``VAR_DECL`` expressions. A particular use is + to place variables with specific attributes inside special accelarator + memories. A return value of ``NULL`` indicates that the target does not + handle this ``VAR_DECL``, and normal RTL expanding is resumed. + + Only define this hook if your accelerator target needs to expand certain + ``VAR_DECL`` nodes in a way that differs from the default. You can also adjust + private variables at OpenACC device-lowering time using the + ``TARGET_GOACC_ADJUST_PRIVATE_DECL`` target hook. + +.. hook-end + +.. function:: tree TARGET_GOACC_CREATE_WORKER_BROADCAST_RECORD (tree rec, bool sender, const char *name, unsigned HOST_WIDE_INT offset) + + .. hook-start:TARGET_GOACC_CREATE_WORKER_BROADCAST_RECORD + + Create a record used to propagate local-variable state from an active + worker to other workers. A possible implementation might adjust the type + of REC to place the new variable in shared GPU memory. + + Presence of this target hook indicates that middle end neutering/broadcasting + be used. +.. hook-end + +.. function:: void TARGET_GOACC_SHARED_MEM_LAYOUT (unsigned HOST_WIDE_INT *, unsigned HOST_WIDE_INT *, int[], unsigned HOST_WIDE_INT[], unsigned HOST_WIDE_INT[]) + + .. hook-start:TARGET_GOACC_SHARED_MEM_LAYOUT + + Lay out a fixed shared-memory region on the target. The LO and HI + arguments should be set to a range of addresses that can be used for worker + broadcasting. The dimensions, reduction size and gang-private size + arguments are for the current offload region. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/adjusting-the-instruction-scheduler.rst b/gcc/doc/gccint/target-macros/adjusting-the-instruction-scheduler.rst new file mode 100644 index 00000000000..0c12d7ad24b --- /dev/null +++ b/gcc/doc/gccint/target-macros/adjusting-the-instruction-scheduler.rst @@ -0,0 +1,660 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _scheduling: + +Adjusting the Instruction Scheduler +*********************************** + +The instruction scheduler may need a fair amount of machine-specific +adjustment in order to produce good code. GCC provides several target +hooks for this purpose. It is usually enough to define just a few of +them: try the first ones in this list first. + +.. function:: int TARGET_SCHED_ISSUE_RATE (void) + + .. hook-start:TARGET_SCHED_ISSUE_RATE + + This hook returns the maximum number of instructions that can ever + issue at the same time on the target machine. The default is one. + Although the insn scheduler can define itself the possibility of issue + an insn on the same cycle, the value can serve as an additional + constraint to issue insns on the same simulated processor cycle (see + hooks :samp:`TARGET_SCHED_REORDER` and :samp:`TARGET_SCHED_REORDER2`). + This value must be constant over the entire compilation. If you need + it to vary depending on what the instructions are, you must use + :samp:`TARGET_SCHED_VARIABLE_ISSUE`. + +.. hook-end + +.. function:: int TARGET_SCHED_VARIABLE_ISSUE (FILE *file, int verbose, rtx_insn *insn, int more) + + .. hook-start:TARGET_SCHED_VARIABLE_ISSUE + + This hook is executed by the scheduler after it has scheduled an insn + from the ready list. It should return the number of insns which can + still be issued in the current cycle. The default is + :samp:`{more} - 1` for insns other than ``CLOBBER`` and + ``USE``, which normally are not counted against the issue rate. + You should define this hook if some insns take more machine resources + than others, so that fewer insns can follow them in the same cycle. + :samp:`{file}` is either a null pointer, or a stdio stream to write any + debug output to. :samp:`{verbose}` is the verbose level provided by + :option:`-fsched-verbose-n`. :samp:`{insn}` is the instruction that + was scheduled. + +.. hook-end + +.. function:: int TARGET_SCHED_ADJUST_COST (rtx_insn *insn, int dep_type1, rtx_insn *dep_insn, int cost, unsigned int dw) + + .. hook-start:TARGET_SCHED_ADJUST_COST + + This function corrects the value of :samp:`{cost}` based on the + relationship between :samp:`{insn}` and :samp:`{dep_insn}` through a + dependence of type dep_type, and strength :samp:`{dw}`. It should return the new + value. The default is to make no adjustment to :samp:`{cost}`. This can be + used for example to specify to the scheduler using the traditional pipeline + description that an output- or anti-dependence does not incur the same cost + as a data-dependence. If the scheduler using the automaton based pipeline + description, the cost of anti-dependence is zero and the cost of + output-dependence is maximum of one and the difference of latency + times of the first and the second insns. If these values are not + acceptable, you could use the hook to modify them too. See also + see :ref:`processor-pipeline-description`. + +.. hook-end + +.. function:: int TARGET_SCHED_ADJUST_PRIORITY (rtx_insn *insn, int priority) + + .. hook-start:TARGET_SCHED_ADJUST_PRIORITY + + This hook adjusts the integer scheduling priority :samp:`{priority}` of + :samp:`{insn}`. It should return the new priority. Increase the priority to + execute :samp:`{insn}` earlier, reduce the priority to execute :samp:`{insn}` + later. Do not define this hook if you do not need to adjust the + scheduling priorities of insns. + +.. hook-end + +.. function:: int TARGET_SCHED_REORDER (FILE *file, int verbose, rtx_insn **ready, int *n_readyp, int clock) + + .. hook-start:TARGET_SCHED_REORDER + + This hook is executed by the scheduler after it has scheduled the ready + list, to allow the machine description to reorder it (for example to + combine two small instructions together on :samp:`VLIW` machines). + :samp:`{file}` is either a null pointer, or a stdio stream to write any + debug output to. :samp:`{verbose}` is the verbose level provided by + :option:`-fsched-verbose-n`. :samp:`{ready}` is a pointer to the ready + list of instructions that are ready to be scheduled. :samp:`{n_readyp}` is + a pointer to the number of elements in the ready list. The scheduler + reads the ready list in reverse order, starting with + :samp:`{ready}` [ :samp:`{*n_readyp}` - 1] and going to :samp:`{ready}` [0]. :samp:`{clock}` + is the timer tick of the scheduler. You may modify the ready list and + the number of ready insns. The return value is the number of insns that + can issue this cycle; normally this is just ``issue_rate``. See also + :samp:`TARGET_SCHED_REORDER2`. + +.. hook-end + +.. function:: int TARGET_SCHED_REORDER2 (FILE *file, int verbose, rtx_insn **ready, int *n_readyp, int clock) + + .. hook-start:TARGET_SCHED_REORDER2 + + Like :samp:`TARGET_SCHED_REORDER`, but called at a different time. That + function is called whenever the scheduler starts a new cycle. This one + is called once per iteration over a cycle, immediately after + :samp:`TARGET_SCHED_VARIABLE_ISSUE`; it can reorder the ready list and + return the number of insns to be scheduled in the same cycle. Defining + this hook can be useful if there are frequent situations where + scheduling one insn causes other insns to become ready in the same + cycle. These other insns can then be taken into account properly. + +.. hook-end + +.. function:: bool TARGET_SCHED_MACRO_FUSION_P (void) + + .. hook-start:TARGET_SCHED_MACRO_FUSION_P + + This hook is used to check whether target platform supports macro fusion. + +.. hook-end + +.. function:: bool TARGET_SCHED_MACRO_FUSION_PAIR_P (rtx_insn *prev, rtx_insn *curr) + + .. hook-start:TARGET_SCHED_MACRO_FUSION_PAIR_P + + This hook is used to check whether two insns should be macro fused for + a target microarchitecture. If this hook returns true for the given insn pair + (:samp:`{prev}` and :samp:`{curr}`), the scheduler will put them into a sched + group, and they will not be scheduled apart. The two insns will be either + two SET insns or a compare and a conditional jump and this hook should + validate any dependencies needed to fuse the two insns together. + +.. hook-end + +.. function:: void TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK (rtx_insn *head, rtx_insn *tail) + + .. hook-start:TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK + + This hook is called after evaluation forward dependencies of insns in + chain given by two parameter values (:samp:`{head}` and :samp:`{tail}` + correspondingly) but before insns scheduling of the insn chain. For + example, it can be used for better insn classification if it requires + analysis of dependencies. This hook can use backward and forward + dependencies of the insn scheduler because they are already + calculated. + +.. hook-end + +.. function:: void TARGET_SCHED_INIT (FILE *file, int verbose, int max_ready) + + .. hook-start:TARGET_SCHED_INIT + + This hook is executed by the scheduler at the beginning of each block of + instructions that are to be scheduled. :samp:`{file}` is either a null + pointer, or a stdio stream to write any debug output to. :samp:`{verbose}` + is the verbose level provided by :option:`-fsched-verbose-n`. + :samp:`{max_ready}` is the maximum number of insns in the current scheduling + region that can be live at the same time. This can be used to allocate + scratch space if it is needed, e.g. by :samp:`TARGET_SCHED_REORDER`. + +.. hook-end + +.. function:: void TARGET_SCHED_FINISH (FILE *file, int verbose) + + .. hook-start:TARGET_SCHED_FINISH + + This hook is executed by the scheduler at the end of each block of + instructions that are to be scheduled. It can be used to perform + cleanup of any actions done by the other scheduling hooks. :samp:`{file}` + is either a null pointer, or a stdio stream to write any debug output + to. :samp:`{verbose}` is the verbose level provided by + :option:`-fsched-verbose-n`. + +.. hook-end + +.. function:: void TARGET_SCHED_INIT_GLOBAL (FILE *file, int verbose, int old_max_uid) + + .. hook-start:TARGET_SCHED_INIT_GLOBAL + + This hook is executed by the scheduler after function level initializations. + :samp:`{file}` is either a null pointer, or a stdio stream to write any debug output to. + :samp:`{verbose}` is the verbose level provided by :option:`-fsched-verbose-n`. + :samp:`{old_max_uid}` is the maximum insn uid when scheduling begins. + +.. hook-end + +.. function:: void TARGET_SCHED_FINISH_GLOBAL (FILE *file, int verbose) + + .. hook-start:TARGET_SCHED_FINISH_GLOBAL + + This is the cleanup hook corresponding to ``TARGET_SCHED_INIT_GLOBAL``. + :samp:`{file}` is either a null pointer, or a stdio stream to write any debug output to. + :samp:`{verbose}` is the verbose level provided by :option:`-fsched-verbose-n`. + +.. hook-end + +.. function:: rtx TARGET_SCHED_DFA_PRE_CYCLE_INSN (void) + + .. hook-start:TARGET_SCHED_DFA_PRE_CYCLE_INSN + + The hook returns an RTL insn. The automaton state used in the + pipeline hazard recognizer is changed as if the insn were scheduled + when the new simulated processor cycle starts. Usage of the hook may + simplify the automaton pipeline description for some VLIW + processors. If the hook is defined, it is used only for the automaton + based pipeline description. The default is not to change the state + when the new simulated processor cycle starts. + +.. hook-end + +.. function:: void TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN (void) + + .. hook-start:TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN + + The hook can be used to initialize data used by the previous hook. + +.. hook-end + +.. function:: rtx_insn * TARGET_SCHED_DFA_POST_CYCLE_INSN (void) + + .. hook-start:TARGET_SCHED_DFA_POST_CYCLE_INSN + + The hook is analogous to :samp:`TARGET_SCHED_DFA_PRE_CYCLE_INSN` but used + to changed the state as if the insn were scheduled when the new + simulated processor cycle finishes. + +.. hook-end + +.. function:: void TARGET_SCHED_INIT_DFA_POST_CYCLE_INSN (void) + + .. hook-start:TARGET_SCHED_INIT_DFA_POST_CYCLE_INSN + + The hook is analogous to :samp:`TARGET_SCHED_INIT_DFA_PRE_CYCLE_INSN` but + used to initialize data used by the previous hook. + +.. hook-end + +.. function:: void TARGET_SCHED_DFA_PRE_ADVANCE_CYCLE (void) + + .. hook-start:TARGET_SCHED_DFA_PRE_ADVANCE_CYCLE + + The hook to notify target that the current simulated cycle is about to finish. + The hook is analogous to :samp:`TARGET_SCHED_DFA_PRE_CYCLE_INSN` but used + to change the state in more complicated situations - e.g., when advancing + state on a single insn is not enough. + +.. hook-end + +.. function:: void TARGET_SCHED_DFA_POST_ADVANCE_CYCLE (void) + + .. hook-start:TARGET_SCHED_DFA_POST_ADVANCE_CYCLE + + The hook to notify target that new simulated cycle has just started. + The hook is analogous to :samp:`TARGET_SCHED_DFA_POST_CYCLE_INSN` but used + to change the state in more complicated situations - e.g., when advancing + state on a single insn is not enough. + +.. hook-end + +.. function:: int TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD (void) + + .. hook-start:TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD + + This hook controls better choosing an insn from the ready insn queue + for the DFA-based insn scheduler. Usually the scheduler + chooses the first insn from the queue. If the hook returns a positive + value, an additional scheduler code tries all permutations of + :samp:`TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD ()` + subsequent ready insns to choose an insn whose issue will result in + maximal number of issued insns on the same cycle. For the + VLIW processor, the code could actually solve the problem of + packing simple insns into the VLIW insn. Of course, if the + rules of VLIW packing are described in the automaton. + + This code also could be used for superscalar RISC + processors. Let us consider a superscalar RISC processor + with 3 pipelines. Some insns can be executed in pipelines :samp:`{A}` or + :samp:`{B}`, some insns can be executed only in pipelines :samp:`{B}` or + :samp:`{C}`, and one insn can be executed in pipeline :samp:`{B}`. The + processor may issue the 1st insn into :samp:`{A}` and the 2nd one into + :samp:`{B}`. In this case, the 3rd insn will wait for freeing :samp:`{B}` + until the next cycle. If the scheduler issues the 3rd insn the first, + the processor could issue all 3 insns per cycle. + + Actually this code demonstrates advantages of the automaton based + pipeline hazard recognizer. We try quickly and easy many insn + schedules to choose the best one. + + The default is no multipass scheduling. + +.. hook-end + +.. function:: int TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD (rtx_insn *insn, int ready_index) + + .. hook-start:TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD + + This hook controls what insns from the ready insn queue will be + considered for the multipass insn scheduling. If the hook returns + zero for :samp:`{insn}`, the insn will be considered in multipass scheduling. + Positive return values will remove :samp:`{insn}` from consideration on + the current round of multipass scheduling. + Negative return values will remove :samp:`{insn}` from consideration for given + number of cycles. + Backends should be careful about returning non-zero for highest priority + instruction at position 0 in the ready list. :samp:`{ready_index}` is passed + to allow backends make correct judgements. + + The default is that any ready insns can be chosen to be issued. + +.. hook-end + +.. function:: void TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BEGIN (void *data, signed char *ready_try, int n_ready, bool first_cycle_insn_p) + + .. hook-start:TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BEGIN + + This hook prepares the target backend for a new round of multipass + scheduling. + +.. hook-end + +.. function:: void TARGET_SCHED_FIRST_CYCLE_MULTIPASS_ISSUE (void *data, signed char *ready_try, int n_ready, rtx_insn *insn, const void *prev_data) + + .. hook-start:TARGET_SCHED_FIRST_CYCLE_MULTIPASS_ISSUE + + This hook is called when multipass scheduling evaluates instruction INSN. + +.. hook-end + +.. function:: void TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BACKTRACK (const void *data, signed char *ready_try, int n_ready) + + .. hook-start:TARGET_SCHED_FIRST_CYCLE_MULTIPASS_BACKTRACK + + This is called when multipass scheduling backtracks from evaluation of + an instruction. + +.. hook-end + +.. function:: void TARGET_SCHED_FIRST_CYCLE_MULTIPASS_END (const void *data) + + .. hook-start:TARGET_SCHED_FIRST_CYCLE_MULTIPASS_END + + This hook notifies the target about the result of the concluded current + round of multipass scheduling. + +.. hook-end + +.. function:: void TARGET_SCHED_FIRST_CYCLE_MULTIPASS_INIT (void *data) + + .. hook-start:TARGET_SCHED_FIRST_CYCLE_MULTIPASS_INIT + + This hook initializes target-specific data used in multipass scheduling. + +.. hook-end + +.. function:: void TARGET_SCHED_FIRST_CYCLE_MULTIPASS_FINI (void *data) + + .. hook-start:TARGET_SCHED_FIRST_CYCLE_MULTIPASS_FINI + + This hook finalizes target-specific data used in multipass scheduling. + +.. hook-end + +.. function:: int TARGET_SCHED_DFA_NEW_CYCLE (FILE *dump, int verbose, rtx_insn *insn, int last_clock, int clock, int *sort_p) + + .. hook-start:TARGET_SCHED_DFA_NEW_CYCLE + + This hook is called by the insn scheduler before issuing :samp:`{insn}` + on cycle :samp:`{clock}`. If the hook returns nonzero, + :samp:`{insn}` is not issued on this processor cycle. Instead, + the processor cycle is advanced. If \* :samp:`{sort_p}` + is zero, the insn ready queue is not sorted on the new cycle + start as usually. :samp:`{dump}` and :samp:`{verbose}` specify the file and + verbosity level to use for debugging output. + :samp:`{last_clock}` and :samp:`{clock}` are, respectively, the + processor cycle on which the previous insn has been issued, + and the current processor cycle. + +.. hook-end + +.. function:: bool TARGET_SCHED_IS_COSTLY_DEPENDENCE (struct _dep *_dep, int cost, int distance) + + .. hook-start:TARGET_SCHED_IS_COSTLY_DEPENDENCE + + This hook is used to define which dependences are considered costly by + the target, so costly that it is not advisable to schedule the insns that + are involved in the dependence too close to one another. The parameters + to this hook are as follows: The first parameter :samp:`{_dep}` is the dependence + being evaluated. The second parameter :samp:`{cost}` is the cost of the + dependence as estimated by the scheduler, and the third + parameter :samp:`{distance}` is the distance in cycles between the two insns. + The hook returns ``true`` if considering the distance between the two + insns the dependence between them is considered costly by the target, + and ``false`` otherwise. + + Defining this hook can be useful in multiple-issue out-of-order machines, + where (a) it's practically hopeless to predict the actual data/resource + delays, however: (b) there's a better chance to predict the actual grouping + that will be formed, and (c) correctly emulating the grouping can be very + important. In such targets one may want to allow issuing dependent insns + closer to one another---i.e., closer than the dependence distance; however, + not in cases of 'costly dependences', which this hooks allows to define. + +.. hook-end + +.. function:: void TARGET_SCHED_H_I_D_EXTENDED (void) + + .. hook-start:TARGET_SCHED_H_I_D_EXTENDED + + This hook is called by the insn scheduler after emitting a new instruction to + the instruction stream. The hook notifies a target backend to extend its + per instruction data structures. + +.. hook-end + +.. function:: void * TARGET_SCHED_ALLOC_SCHED_CONTEXT (void) + + .. hook-start:TARGET_SCHED_ALLOC_SCHED_CONTEXT + + Return a pointer to a store large enough to hold target scheduling context. + +.. hook-end + +.. function:: void TARGET_SCHED_INIT_SCHED_CONTEXT (void *tc, bool clean_p) + + .. hook-start:TARGET_SCHED_INIT_SCHED_CONTEXT + + Initialize store pointed to by :samp:`{tc}` to hold target scheduling context. + It :samp:`{clean_p}` is true then initialize :samp:`{tc}` as if scheduler is at the + beginning of the block. Otherwise, copy the current context into :samp:`{tc}`. + +.. hook-end + +.. function:: void TARGET_SCHED_SET_SCHED_CONTEXT (void *tc) + + .. hook-start:TARGET_SCHED_SET_SCHED_CONTEXT + + Copy target scheduling context pointed to by :samp:`{tc}` to the current context. + +.. hook-end + +.. function:: void TARGET_SCHED_CLEAR_SCHED_CONTEXT (void *tc) + + .. hook-start:TARGET_SCHED_CLEAR_SCHED_CONTEXT + + Deallocate internal data in target scheduling context pointed to by :samp:`{tc}`. + +.. hook-end + +.. function:: void TARGET_SCHED_FREE_SCHED_CONTEXT (void *tc) + + .. hook-start:TARGET_SCHED_FREE_SCHED_CONTEXT + + Deallocate a store for target scheduling context pointed to by :samp:`{tc}`. + +.. hook-end + +.. function:: int TARGET_SCHED_SPECULATE_INSN (rtx_insn *insn, unsigned int dep_status, rtx *new_pat) + + .. hook-start:TARGET_SCHED_SPECULATE_INSN + + This hook is called by the insn scheduler when :samp:`{insn}` has only + speculative dependencies and therefore can be scheduled speculatively. + The hook is used to check if the pattern of :samp:`{insn}` has a speculative + version and, in case of successful check, to generate that speculative + pattern. The hook should return 1, if the instruction has a speculative form, + or -1, if it doesn't. :samp:`{request}` describes the type of requested + speculation. If the return value equals 1 then :samp:`{new_pat}` is assigned + the generated speculative pattern. + +.. hook-end + +.. function:: bool TARGET_SCHED_NEEDS_BLOCK_P (unsigned int dep_status) + + .. hook-start:TARGET_SCHED_NEEDS_BLOCK_P + + This hook is called by the insn scheduler during generation of recovery code + for :samp:`{insn}`. It should return ``true``, if the corresponding check + instruction should branch to recovery code, or ``false`` otherwise. + +.. hook-end + +.. function:: rtx TARGET_SCHED_GEN_SPEC_CHECK (rtx_insn *insn, rtx_insn *label, unsigned int ds) + + .. hook-start:TARGET_SCHED_GEN_SPEC_CHECK + + This hook is called by the insn scheduler to generate a pattern for recovery + check instruction. If :samp:`{mutate_p}` is zero, then :samp:`{insn}` is a + speculative instruction for which the check should be generated. + :samp:`{label}` is either a label of a basic block, where recovery code should + be emitted, or a null pointer, when requested check doesn't branch to + recovery code (a simple check). If :samp:`{mutate_p}` is nonzero, then + a pattern for a branchy check corresponding to a simple check denoted by + :samp:`{insn}` should be generated. In this case :samp:`{label}` can't be null. + +.. hook-end + +.. function:: void TARGET_SCHED_SET_SCHED_FLAGS (struct spec_info_def *spec_info) + + .. hook-start:TARGET_SCHED_SET_SCHED_FLAGS + + This hook is used by the insn scheduler to find out what features should be + enabled/used. + The structure \* :samp:`{spec_info}` should be filled in by the target. + The structure describes speculation types that can be used in the scheduler. + +.. hook-end + +.. function:: bool TARGET_SCHED_CAN_SPECULATE_INSN (rtx_insn *insn) + + .. hook-start:TARGET_SCHED_CAN_SPECULATE_INSN + + Some instructions should never be speculated by the schedulers, usually + because the instruction is too expensive to get this wrong. Often such + instructions have long latency, and often they are not fully modeled in the + pipeline descriptions. This hook should return ``false`` if :samp:`{insn}` + should not be speculated. + +.. hook-end + +.. function:: int TARGET_SCHED_SMS_RES_MII (struct ddg *g) + + .. hook-start:TARGET_SCHED_SMS_RES_MII + + This hook is called by the swing modulo scheduler to calculate a + resource-based lower bound which is based on the resources available in + the machine and the resources required by each instruction. The target + backend can use :samp:`{g}` to calculate such bound. A very simple lower + bound will be used in case this hook is not implemented: the total number + of instructions divided by the issue rate. + +.. hook-end + +.. function:: bool TARGET_SCHED_DISPATCH (rtx_insn *insn, int x) + + .. hook-start:TARGET_SCHED_DISPATCH + + This hook is called by Haifa Scheduler. It returns true if dispatch scheduling + is supported in hardware and the condition specified in the parameter is true. + +.. hook-end + +.. function:: void TARGET_SCHED_DISPATCH_DO (rtx_insn *insn, int x) + + .. hook-start:TARGET_SCHED_DISPATCH_DO + + This hook is called by Haifa Scheduler. It performs the operation specified + in its second parameter. + +.. hook-end + +.. c:var:: bool TARGET_SCHED_EXPOSED_PIPELINE + + .. hook-start:TARGET_SCHED_EXPOSED_PIPELINE + + True if the processor has an exposed pipeline, which means that not just + the order of instructions is important for correctness when scheduling, but + also the latencies of operations. + +.. hook-end + +.. function:: int TARGET_SCHED_REASSOCIATION_WIDTH (unsigned int opc, machine_mode mode) + + .. hook-start:TARGET_SCHED_REASSOCIATION_WIDTH + + This hook is called by tree reassociator to determine a level of + parallelism required in output calculations chain. + +.. hook-end + +.. function:: void TARGET_SCHED_FUSION_PRIORITY (rtx_insn *insn, int max_pri, int *fusion_pri, int *pri) + + .. hook-start:TARGET_SCHED_FUSION_PRIORITY + + This hook is called by scheduling fusion pass. It calculates fusion + priorities for each instruction passed in by parameter. The priorities + are returned via pointer parameters. + + :samp:`{insn}` is the instruction whose priorities need to be calculated. + :samp:`{max_pri}` is the maximum priority can be returned in any cases. + :samp:`{fusion_pri}` is the pointer parameter through which :samp:`{insn}` 's + fusion priority should be calculated and returned. + :samp:`{pri}` is the pointer parameter through which :samp:`{insn}` 's priority + should be calculated and returned. + + Same :samp:`{fusion_pri}` should be returned for instructions which should + be scheduled together. Different :samp:`{pri}` should be returned for + instructions with same :samp:`{fusion_pri}`. :samp:`{fusion_pri}` is the major + sort key, :samp:`{pri}` is the minor sort key. All instructions will be + scheduled according to the two priorities. All priorities calculated + should be between 0 (exclusive) and :samp:`{max_pri}` (inclusive). To avoid + false dependencies, :samp:`{fusion_pri}` of instructions which need to be + scheduled together should be smaller than :samp:`{fusion_pri}` of irrelevant + instructions. + + Given below example: + + .. code-block:: c++ + + ldr r10, [r1, 4] + add r4, r4, r10 + ldr r15, [r2, 8] + sub r5, r5, r15 + ldr r11, [r1, 0] + add r4, r4, r11 + ldr r16, [r2, 12] + sub r5, r5, r16 + + On targets like ARM/AArch64, the two pairs of consecutive loads should be + merged. Since peephole2 pass can't help in this case unless consecutive + loads are actually next to each other in instruction flow. That's where + this scheduling fusion pass works. This hook calculates priority for each + instruction based on its fustion type, like: + + .. code-block:: c++ + + ldr r10, [r1, 4] ; fusion_pri=99, pri=96 + add r4, r4, r10 ; fusion_pri=100, pri=100 + ldr r15, [r2, 8] ; fusion_pri=98, pri=92 + sub r5, r5, r15 ; fusion_pri=100, pri=100 + ldr r11, [r1, 0] ; fusion_pri=99, pri=100 + add r4, r4, r11 ; fusion_pri=100, pri=100 + ldr r16, [r2, 12] ; fusion_pri=98, pri=88 + sub r5, r5, r16 ; fusion_pri=100, pri=100 + + Scheduling fusion pass then sorts all ready to issue instructions according + to the priorities. As a result, instructions of same fusion type will be + pushed together in instruction flow, like: + + .. code-block:: c++ + + ldr r11, [r1, 0] + ldr r10, [r1, 4] + ldr r15, [r2, 8] + ldr r16, [r2, 12] + add r4, r4, r10 + sub r5, r5, r15 + add r4, r4, r11 + sub r5, r5, r16 + + Now peephole2 pass can simply merge the two pairs of loads. + + Since scheduling fusion pass relies on peephole2 to do real fusion + work, it is only enabled by default when peephole2 is in effect. + + This is firstly introduced on ARM/AArch64 targets, please refer to + the hook implementation for how different fusion types are supported. + +.. hook-end + +.. function:: void TARGET_EXPAND_DIVMOD_LIBFUNC (rtx libfunc, machine_mode mode, rtx op0, rtx op1, rtx *quot, rtx *rem) + + .. hook-start:TARGET_EXPAND_DIVMOD_LIBFUNC + + Define this hook for enabling divmod transform if the port does not have + hardware divmod insn but defines target-specific divmod libfuncs. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/anchored-addresses.rst b/gcc/doc/gccint/target-macros/anchored-addresses.rst new file mode 100644 index 00000000000..52f588a3ca0 --- /dev/null +++ b/gcc/doc/gccint/target-macros/anchored-addresses.rst @@ -0,0 +1,92 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: anchored addresses, -fsection-anchors + +.. _anchored-addresses: + +Anchored Addresses +****************** + +GCC usually addresses every static object as a separate entity. +For example, if we have: + +.. code-block:: c++ + + static int a, b, c; + int foo (void) { return a + b + c; } + +the code for ``foo`` will usually calculate three separate symbolic +addresses: those of ``a``, ``b`` and ``c``. On some targets, +it would be better to calculate just one symbolic address and access +the three variables relative to it. The equivalent pseudocode would +be something like: + +.. code-block:: c++ + + int foo (void) + { + register int *xr = &x; + return xr[&a - &x] + xr[&b - &x] + xr[&c - &x]; + } + +(which isn't valid C). We refer to shared addresses like ``x`` as +'section anchors'. Their use is controlled by :option:`-fsection-anchors`. + +The hooks below describe the target properties that GCC needs to know +in order to make effective use of section anchors. It won't use +section anchors at all unless either ``TARGET_MIN_ANCHOR_OFFSET`` +or ``TARGET_MAX_ANCHOR_OFFSET`` is set to a nonzero value. + +.. c:var:: HOST_WIDE_INT TARGET_MIN_ANCHOR_OFFSET + + .. hook-start:TARGET_MIN_ANCHOR_OFFSET + + The minimum offset that should be applied to a section anchor. + On most targets, it should be the smallest offset that can be + applied to a base register while still giving a legitimate address + for every mode. The default value is 0. + +.. hook-end + +.. c:var:: HOST_WIDE_INT TARGET_MAX_ANCHOR_OFFSET + + .. hook-start:TARGET_MAX_ANCHOR_OFFSET + + Like ``TARGET_MIN_ANCHOR_OFFSET``, but the maximum (inclusive) + offset that should be applied to section anchors. The default + value is 0. + +.. hook-end + +.. function:: void TARGET_ASM_OUTPUT_ANCHOR (rtx x) + + .. hook-start:TARGET_ASM_OUTPUT_ANCHOR + + Write the assembly code to define section anchor :samp:`{x}`, which is a + ``SYMBOL_REF`` for which :samp:`SYMBOL_REF_ANCHOR_P ({x})` is true. + The hook is called with the assembly output position set to the beginning + of ``SYMBOL_REF_BLOCK (x)``. + + If ``ASM_OUTPUT_DEF`` is available, the hook's default definition uses + it to define the symbol as :samp:`. + SYMBOL_REF_BLOCK_OFFSET ({x})`. + If ``ASM_OUTPUT_DEF`` is not available, the hook's default definition + is ``NULL``, which disables the use of section anchors altogether. + +.. hook-end + +.. function:: bool TARGET_USE_ANCHORS_FOR_SYMBOL_P (const_rtx x) + + .. hook-start:TARGET_USE_ANCHORS_FOR_SYMBOL_P + + Return true if GCC should attempt to use anchors to access ``SYMBOL_REF`` + :samp:`{x}`. You can assume :samp:`SYMBOL_REF_HAS_BLOCK_INFO_P ({x})` and + :samp:`!SYMBOL_REF_ANCHOR_P ({x})`. + + The default version is correct for most targets, but you might need to + intercept this hook to handle things like target-specific attributes + or target-specific sections. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/c++-abi-parameters.rst b/gcc/doc/gccint/target-macros/c++-abi-parameters.rst new file mode 100644 index 00000000000..4dd9f67a2ea --- /dev/null +++ b/gcc/doc/gccint/target-macros/c++-abi-parameters.rst @@ -0,0 +1,164 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: parameters, c++ abi + +.. _c++-abi: + +C++ ABI parameters +****************** + +.. function:: tree TARGET_CXX_GUARD_TYPE (void) + + .. hook-start:TARGET_CXX_GUARD_TYPE + + Define this hook to override the integer type used for guard variables. + These are used to implement one-time construction of static objects. The + default is long_long_integer_type_node. + +.. hook-end + +.. function:: bool TARGET_CXX_GUARD_MASK_BIT (void) + + .. hook-start:TARGET_CXX_GUARD_MASK_BIT + + This hook determines how guard variables are used. It should return + ``false`` (the default) if the first byte should be used. A return value of + ``true`` indicates that only the least significant bit should be used. + +.. hook-end + +.. function:: tree TARGET_CXX_GET_COOKIE_SIZE (tree type) + + .. hook-start:TARGET_CXX_GET_COOKIE_SIZE + + This hook returns the size of the cookie to use when allocating an array + whose elements have the indicated :samp:`{type}`. Assumes that it is already + known that a cookie is needed. The default is + ``max(sizeof (size_t), alignof(type))``, as defined in section 2.7 of the + IA64/Generic C++ ABI. + +.. hook-end + +.. function:: bool TARGET_CXX_COOKIE_HAS_SIZE (void) + + .. hook-start:TARGET_CXX_COOKIE_HAS_SIZE + + This hook should return ``true`` if the element size should be stored in + array cookies. The default is to return ``false``. + +.. hook-end + +.. function:: int TARGET_CXX_IMPORT_EXPORT_CLASS (tree type, int import_export) + + .. hook-start:TARGET_CXX_IMPORT_EXPORT_CLASS + + If defined by a backend this hook allows the decision made to export + class :samp:`{type}` to be overruled. Upon entry :samp:`{import_export}` + will contain 1 if the class is going to be exported, -1 if it is going + to be imported and 0 otherwise. This function should return the + modified value and perform any other actions necessary to support the + backend's targeted operating system. + +.. hook-end + +.. function:: bool TARGET_CXX_CDTOR_RETURNS_THIS (void) + + .. hook-start:TARGET_CXX_CDTOR_RETURNS_THIS + + This hook should return ``true`` if constructors and destructors return + the address of the object created/destroyed. The default is to return + ``false``. + +.. hook-end + +.. function:: bool TARGET_CXX_KEY_METHOD_MAY_BE_INLINE (void) + + .. hook-start:TARGET_CXX_KEY_METHOD_MAY_BE_INLINE + + This hook returns true if the key method for a class (i.e., the method + which, if defined in the current translation unit, causes the virtual + table to be emitted) may be an inline function. Under the standard + Itanium C++ ABI the key method may be an inline function so long as + the function is not declared inline in the class definition. Under + some variants of the ABI, an inline function can never be the key + method. The default is to return ``true``. + +.. hook-end + +.. function:: void TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY (tree decl) + + .. hook-start:TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY + + :samp:`{decl}` is a virtual table, virtual table table, typeinfo object, + or other similar implicit class data object that will be emitted with + external linkage in this translation unit. No ELF visibility has been + explicitly specified. If the target needs to specify a visibility + other than that of the containing class, use this hook to set + ``DECL_VISIBILITY`` and ``DECL_VISIBILITY_SPECIFIED``. + +.. hook-end + +.. function:: bool TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT (void) + + .. hook-start:TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT + + This hook returns true (the default) if virtual tables and other + similar implicit class data objects are always COMDAT if they have + external linkage. If this hook returns false, then class data for + classes whose virtual table will be emitted in only one translation + unit will not be COMDAT. + +.. hook-end + +.. function:: bool TARGET_CXX_LIBRARY_RTTI_COMDAT (void) + + .. hook-start:TARGET_CXX_LIBRARY_RTTI_COMDAT + + This hook returns true (the default) if the RTTI information for + the basic types which is defined in the C++ runtime should always + be COMDAT, false if it should not be COMDAT. + +.. hook-end + +.. function:: bool TARGET_CXX_USE_AEABI_ATEXIT (void) + + .. hook-start:TARGET_CXX_USE_AEABI_ATEXIT + + This hook returns true if ``__aeabi_atexit`` (as defined by the ARM EABI) + should be used to register static destructors when :option:`-fuse-cxa-atexit` + is in effect. The default is to return false to use ``__cxa_atexit``. + +.. hook-end + +.. function:: bool TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT (void) + + .. hook-start:TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT + + This hook returns true if the target ``atexit`` function can be used + in the same manner as ``__cxa_atexit`` to register C++ static + destructors. This requires that ``atexit`` -registered functions in + shared libraries are run in the correct order when the libraries are + unloaded. The default is to return false. + +.. hook-end + +.. function:: void TARGET_CXX_ADJUST_CLASS_AT_DEFINITION (tree type) + + .. hook-start:TARGET_CXX_ADJUST_CLASS_AT_DEFINITION + + :samp:`{type}` is a C++ class (i.e., RECORD_TYPE or UNION_TYPE) that has just + been defined. Use this hook to make adjustments to the class (eg, tweak + visibility or perform any other required target modifications). + +.. hook-end + +.. function:: tree TARGET_CXX_DECL_MANGLING_CONTEXT (const_tree decl) + + .. hook-start:TARGET_CXX_DECL_MANGLING_CONTEXT + + Return target-specific mangling context of :samp:`{decl}` or ``NULL_TREE``. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/condition-code-status.rst b/gcc/doc/gccint/target-macros/condition-code-status.rst new file mode 100644 index 00000000000..e62de9dc7b5 --- /dev/null +++ b/gcc/doc/gccint/target-macros/condition-code-status.rst @@ -0,0 +1,210 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: condition code status + +.. _condition-code: + +Condition Code Status +********************* + +Condition codes in GCC are represented as registers, +which provides better schedulability for +architectures that do have a condition code register, but on which +most instructions do not affect it. The latter category includes +most RISC machines. + +Implicit clobbering would pose a strong restriction on the placement of +the definition and use of the condition code. In the past the definition +and use were always adjacent. However, recent changes to support trapping +arithmetic may result in the definition and user being in different blocks. +Thus, there may be a ``NOTE_INSN_BASIC_BLOCK`` between them. Additionally, +the definition may be the source of exception handling edges. + +These restrictions can prevent important +optimizations on some machines. For example, on the IBM RS/6000, there +is a delay for taken branches unless the condition code register is set +three instructions earlier than the conditional branch. The instruction +scheduler cannot perform this optimization if it is not permitted to +separate the definition and use of the condition code register. + +If there is a specific +condition code register in the machine, use a hard register. If the +condition code or comparison result can be placed in any general register, +or if there are multiple condition registers, use a pseudo register. +Registers used to store the condition code value will usually have a mode +that is in class ``MODE_CC``. + +Alternatively, you can use ``BImode`` if the comparison operator is +specified already in the compare instruction. In this case, you are not +interested in most macros in this section. + +.. toctree:: + :maxdepth: 2 + + +.. index:: CCmode, MODE_CC + +.. _mode_cc-condition-codes: + +Representation of condition codes using registers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. c:macro:: SELECT_CC_MODE (op, x, y) + + On many machines, the condition code may be produced by other instructions + than compares, for example the branch can use directly the condition + code set by a subtract instruction. However, on some machines + when the condition code is set this way some bits (such as the overflow + bit) are not set in the same way as a test instruction, so that a different + branch instruction must be used for some conditional branches. When + this happens, use the machine mode of the condition code register to + record different formats of the condition code register. Modes can + also be used to record which compare instruction (e.g. a signed or an + unsigned comparison) produced the condition codes. + + If other modes than ``CCmode`` are required, add them to + :samp:`{machine}-modes.def` and define ``SELECT_CC_MODE`` to choose + a mode given an operand of a compare. This is needed because the modes + have to be chosen not only during RTL generation but also, for example, + by instruction combination. The result of ``SELECT_CC_MODE`` should + be consistent with the mode used in the patterns; for example to support + the case of the add on the SPARC discussed above, we have the pattern + + .. code-block:: c++ + + (define_insn "" + [(set (reg:CCNZ 0) + (compare:CCNZ + (plus:SI (match_operand:SI 0 "register_operand" "%r") + (match_operand:SI 1 "arith_operand" "rI")) + (const_int 0)))] + "" + "...") + + together with a ``SELECT_CC_MODE`` that returns ``CCNZmode`` + for comparisons whose argument is a ``plus`` : + + .. code-block:: c++ + + #define SELECT_CC_MODE(OP,X,Y) \ + (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \ + ? ((OP == LT || OP == LE || OP == GT || OP == GE) \ + ? CCFPEmode : CCFPmode) \ + : ((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS \ + || GET_CODE (X) == NEG || GET_CODE (x) == ASHIFT) \ + ? CCNZmode : CCmode)) + + Another reason to use modes is to retain information on which operands + were used by the comparison; see ``REVERSIBLE_CC_MODE`` later in + this section. + + You should define this macro if and only if you define extra CC modes + in :samp:`{machine}-modes.def`. + +.. function:: void TARGET_CANONICALIZE_COMPARISON (int *code, rtx *op0, rtx *op1, bool op0_preserve_value) + + .. hook-start:TARGET_CANONICALIZE_COMPARISON + + On some machines not all possible comparisons are defined, but you can + convert an invalid comparison into a valid one. For example, the Alpha + does not have a ``GT`` comparison, but you can use an ``LT`` + comparison instead and swap the order of the operands. + + On such machines, implement this hook to do any required conversions. + :samp:`{code}` is the initial comparison code and :samp:`{op0}` and :samp:`{op1}` + are the left and right operands of the comparison, respectively. If + :samp:`{op0_preserve_value}` is ``true`` the implementation is not + allowed to change the value of :samp:`{op0}` since the value might be used + in RTXs which aren't comparisons. E.g. the implementation is not + allowed to swap operands in that case. + + GCC will not assume that the comparison resulting from this macro is + valid but will see if the resulting insn matches a pattern in the + :samp:`md` file. + + You need not to implement this hook if it would never change the + comparison code or operands. + +.. hook-end + +.. c:macro:: REVERSIBLE_CC_MODE (mode) + + A C expression whose value is one if it is always safe to reverse a + comparison whose mode is :samp:`{mode}`. If ``SELECT_CC_MODE`` + can ever return :samp:`{mode}` for a floating-point inequality comparison, + then ``REVERSIBLE_CC_MODE (mode)`` must be zero. + + You need not define this macro if it would always returns zero or if the + floating-point format is anything other than ``IEEE_FLOAT_FORMAT``. + For example, here is the definition used on the SPARC, where floating-point + inequality comparisons are given either ``CCFPEmode`` or ``CCFPmode`` : + + .. code-block:: c++ + + #define REVERSIBLE_CC_MODE(MODE) \ + ((MODE) != CCFPEmode && (MODE) != CCFPmode) + +.. c:macro:: REVERSE_CONDITION (code, mode) + + A C expression whose value is reversed condition code of the :samp:`{code}` for + comparison done in CC_MODE :samp:`{mode}`. The macro is used only in case + ``REVERSIBLE_CC_MODE (mode)`` is nonzero. Define this macro in case + machine has some non-standard way how to reverse certain conditionals. For + instance in case all floating point conditions are non-trapping, compiler may + freely convert unordered compares to ordered ones. Then definition may look + like: + + .. code-block:: c++ + + #define REVERSE_CONDITION(CODE, MODE) \ + ((MODE) != CCFPmode ? reverse_condition (CODE) \ + : reverse_condition_maybe_unordered (CODE)) + +.. function:: bool TARGET_FIXED_CONDITION_CODE_REGS (unsigned int *p1, unsigned int *p2) + + .. hook-start:TARGET_FIXED_CONDITION_CODE_REGS + + On targets which use a hard + register rather than a pseudo-register to hold condition codes, the + regular CSE passes are often not able to identify cases in which the + hard register is set to a common value. Use this hook to enable a + small pass which optimizes such cases. This hook should return true + to enable this pass, and it should set the integers to which its + arguments point to the hard register numbers used for condition codes. + When there is only one such register, as is true on most systems, the + integer pointed to by :samp:`{p2}` should be set to + ``INVALID_REGNUM``. + + The default version of this hook returns false. + +.. hook-end + +.. function:: machine_mode TARGET_CC_MODES_COMPATIBLE (machine_mode m1, machine_mode m2) + + .. hook-start:TARGET_CC_MODES_COMPATIBLE + + On targets which use multiple condition code modes in class + ``MODE_CC``, it is sometimes the case that a comparison can be + validly done in more than one mode. On such a system, define this + target hook to take two mode arguments and to return a mode in which + both comparisons may be validly done. If there is no such mode, + return ``VOIDmode``. + + The default version of this hook checks whether the modes are the + same. If they are, it returns that mode. If they are different, it + returns ``VOIDmode``. + +.. hook-end + +.. c:var:: unsigned int TARGET_FLAGS_REGNUM + + .. hook-start:TARGET_FLAGS_REGNUM + + If the target has a dedicated flags register, and it needs to use the + post-reload comparison elimination pass, or the delay slot filler pass, + then this value should be set appropriately. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/controlling-debugging-information-format.rst b/gcc/doc/gccint/target-macros/controlling-debugging-information-format.rst new file mode 100644 index 00000000000..e1eb465ea07 --- /dev/null +++ b/gcc/doc/gccint/target-macros/controlling-debugging-information-format.rst @@ -0,0 +1,306 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _debugging-info: + +Controlling Debugging Information Format +**************************************** + +.. prevent bad page break with this line + +This describes how to specify debugging information. + +.. toctree:: + :maxdepth: 2 + +.. _all-debuggers: + +Macros Affecting All Debugging Formats +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +These macros affect all debugging formats. + +.. c:macro:: DEBUGGER_REGNO (regno) + + A C expression that returns the debugger register number for the compiler + register number :samp:`{regno}`. In the default macro provided, the value + of this expression will be :samp:`{regno}` itself. But sometimes there are + some registers that the compiler knows about and debugger does not, or vice + versa. In such cases, some register may need to have one number in the + compiler and another for debugger. + + If two registers have consecutive numbers inside GCC, and they can be + used as a pair to hold a multiword value, then they *must* have + consecutive numbers after renumbering with ``DEBUGGER_REGNO``. + Otherwise, debuggers will be unable to access such a pair, because they + expect register pairs to be consecutive in their own numbering scheme. + + If you find yourself defining ``DEBUGGER_REGNO`` in way that + does not preserve register pairs, then what you must do instead is + redefine the actual register numbering scheme. + +.. c:macro:: DEBUGGER_AUTO_OFFSET (x) + + A C expression that returns the integer offset value for an automatic + variable having address :samp:`{x}` (an RTL expression). The default + computation assumes that :samp:`{x}` is based on the frame-pointer and + gives the offset from the frame-pointer. This is required for targets + that produce debugging output for debugger and allow the frame-pointer to be + eliminated when the :option:`-g` option is used. + +.. c:macro:: DEBUGGER_ARG_OFFSET (offset, x) + + A C expression that returns the integer offset value for an argument + having address :samp:`{x}` (an RTL expression). The nominal offset is + :samp:`{offset}`. + +.. c:macro:: PREFERRED_DEBUGGING_TYPE + + A C expression that returns the type of debugging output GCC should + produce when the user specifies just :option:`-g`. Define + this if you have arranged for GCC to support more than one format of + debugging output. Currently, the allowable values are + ``DWARF2_DEBUG``, ``VMS_DEBUG``, + and ``VMS_AND_DWARF2_DEBUG``. + + When the user specifies :option:`-ggdb`, GCC normally also uses the + value of this macro to select the debugging output format, but with two + exceptions. If ``DWARF2_DEBUGGING_INFO`` is defined, GCC uses the + value ``DWARF2_DEBUG``. + + The value of this macro only affects the default debugging output; the + user can always get a specific type of output by using :option:`-gdwarf-2`, + or :option:`-gvms`. + +.. c:macro:: DEFAULT_GDB_EXTENSIONS + + Define this macro to control whether GCC should by default generate + GDB's extended version of debugging information. If you don't define the + macro, the default is 1: always generate the extended information + if there is any occasion to. + +.. _dwarf: + +Macros for DWARF Output +^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +Here are macros for DWARF output. + +.. c:macro:: DWARF2_DEBUGGING_INFO + + Define this macro if GCC should produce dwarf version 2 format + debugging output in response to the :option:`-g` option. + + To support optional call frame debugging information, you must also + define ``INCOMING_RETURN_ADDR_RTX`` and either set + ``RTX_FRAME_RELATED_P`` on the prologue insns if you use RTL for the + prologue, or call ``dwarf2out_def_cfa`` and ``dwarf2out_reg_save`` + as appropriate from ``TARGET_ASM_FUNCTION_PROLOGUE`` if you don't. + +.. function:: int TARGET_DWARF_CALLING_CONVENTION (const_tree function) + + .. hook-start:TARGET_DWARF_CALLING_CONVENTION + + Define this to enable the dwarf attribute ``DW_AT_calling_convention`` to + be emitted for each function. Instead of an integer return the enum + value for the ``DW_CC_`` tag. + +.. hook-end + +.. function:: int TARGET_DWARF_CALLING_CONVENTION (const_tree function) + + Define this to enable the dwarf attribute ``DW_AT_calling_convention`` to + be emitted for each function. Instead of an integer return the enum + value for the ``DW_CC_`` tag. + +.. c:macro:: DWARF2_FRAME_INFO + + Define this macro to a nonzero value if GCC should always output + Dwarf 2 frame information. If ``TARGET_EXCEPT_UNWIND_INFO`` + (see :ref:`exception-region-output`) returns ``UI_DWARF2``, and + exceptions are enabled, GCC will output this information not matter + how you define ``DWARF2_FRAME_INFO``. + +.. function:: enum unwind_info_type TARGET_DEBUG_UNWIND_INFO (void) + + .. hook-start:TARGET_DEBUG_UNWIND_INFO + + This hook defines the mechanism that will be used for describing frame + unwind information to the debugger. Normally the hook will return + ``UI_DWARF2`` if DWARF 2 debug information is enabled, and + return ``UI_NONE`` otherwise. + + A target may return ``UI_DWARF2`` even when DWARF 2 debug information + is disabled in order to always output DWARF 2 frame information. + + A target may return ``UI_TARGET`` if it has ABI specified unwind tables. + This will suppress generation of the normal debug frame unwind information. + +.. hook-end + +.. c:macro:: DWARF2_ASM_LINE_DEBUG_INFO + + Define this macro to be a nonzero value if the assembler can generate Dwarf 2 + line debug info sections. This will result in much more compact line number + tables, and hence is desirable if it works. + +.. c:macro:: DWARF2_ASM_VIEW_DEBUG_INFO + + Define this macro to be a nonzero value if the assembler supports view + assignment and verification in ``.loc``. If it does not, but the + user enables location views, the compiler may have to fallback to + internal line number tables. + +.. function:: int TARGET_RESET_LOCATION_VIEW (rtx_insn *) + + .. hook-start:TARGET_RESET_LOCATION_VIEW + + This hook, if defined, enables -ginternal-reset-location-views, and + uses its result to override cases in which the estimated min insn + length might be nonzero even when a PC advance (i.e., a view reset) + cannot be taken for granted. + + If the hook is defined, it must return a positive value to indicate + the insn definitely advances the PC, and so the view number can be + safely assumed to be reset; a negative value to mean the insn + definitely does not advance the PC, and os the view number must not + be reset; or zero to decide based on the estimated insn length. + + If insn length is to be regarded as reliable, set the hook to + ``hook_int_rtx_insn_0``. + +.. hook-end + +.. c:var:: bool TARGET_WANT_DEBUG_PUB_SECTIONS + + .. hook-start:TARGET_WANT_DEBUG_PUB_SECTIONS + + True if the ``.debug_pubtypes`` and ``.debug_pubnames`` sections + should be emitted. These sections are not used on most platforms, and + in particular GDB does not use them. + +.. hook-end + +.. c:var:: bool TARGET_DELAY_SCHED2 + + .. hook-start:TARGET_DELAY_SCHED2 + + True if sched2 is not to be run at its normal place. + This usually means it will be run as part of machine-specific reorg. + +.. hook-end + +.. c:var:: bool TARGET_DELAY_VARTRACK + + .. hook-start:TARGET_DELAY_VARTRACK + + True if vartrack is not to be run at its normal place. + This usually means it will be run as part of machine-specific reorg. + +.. hook-end + +.. c:var:: bool TARGET_NO_REGISTER_ALLOCATION + + .. hook-start:TARGET_NO_REGISTER_ALLOCATION + + True if register allocation and the passes + following it should not be run. Usually true only for virtual assembler + targets. + +.. hook-end + +.. c:macro:: ASM_OUTPUT_DWARF_DELTA (stream, size, label1, label2) + + A C statement to issue assembly directives that create a difference + :samp:`{lab1}` minus :samp:`{lab2}`, using an integer of the given :samp:`{size}`. + +.. c:macro:: ASM_OUTPUT_DWARF_VMS_DELTA (stream, size, label1, label2) + + A C statement to issue assembly directives that create a difference + between the two given labels in system defined units, e.g. instruction + slots on IA64 VMS, using an integer of the given size. + +.. c:macro:: ASM_OUTPUT_DWARF_OFFSET (stream, size, label, offset, section) + + A C statement to issue assembly directives that create a + section-relative reference to the given :samp:`{label}` plus :samp:`{offset}`, using + an integer of the given :samp:`{size}`. The label is known to be defined in the + given :samp:`{section}`. + +.. c:macro:: ASM_OUTPUT_DWARF_PCREL (stream, size, label) + + A C statement to issue assembly directives that create a self-relative + reference to the given :samp:`{label}`, using an integer of the given :samp:`{size}`. + +.. c:macro:: ASM_OUTPUT_DWARF_DATAREL (stream, size, label) + + A C statement to issue assembly directives that create a reference to the + given :samp:`{label}` relative to the dbase, using an integer of the given :samp:`{size}`. + +.. c:macro:: ASM_OUTPUT_DWARF_TABLE_REF (label) + + A C statement to issue assembly directives that create a reference to + the DWARF table identifier :samp:`{label}` from the current section. This + is used on some systems to avoid garbage collecting a DWARF table which + is referenced by a function. + +.. function:: void TARGET_ASM_OUTPUT_DWARF_DTPREL (FILE *file, int size, rtx x) + + .. hook-start:TARGET_ASM_OUTPUT_DWARF_DTPREL + + If defined, this target hook is a function which outputs a DTP-relative + reference to the given TLS symbol of the specified size. + +.. hook-end + +.. _vms-debug: + +Macros for VMS Debug Format +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +Here are macros for VMS debug format. + +.. c:macro:: VMS_DEBUGGING_INFO + + Define this macro if GCC should produce debugging output for VMS + in response to the :option:`-g` option. The default behavior for VMS + is to generate minimal debug info for a traceback in the absence of + :option:`-g` unless explicitly overridden with :option:`-g0`. This + behavior is controlled by ``TARGET_OPTION_OPTIMIZATION`` and + ``TARGET_OPTION_OVERRIDE``. + +.. _ctf-debug: + +Macros for CTF Debug Format +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +Here are macros for CTF debug format. + +.. c:macro:: CTF_DEBUGGING_INFO + + Define this macro if GCC should produce debugging output in CTF debug + format in response to the :option:`-gctf` option. + +.. _btf-debug: + +Macros for BTF Debug Format +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +Here are macros for BTF debug format. + +.. c:macro:: BTF_DEBUGGING_INFO + + Define this macro if GCC should produce debugging output in BTF debug + format in response to the :option:`-gbtf` option. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/controlling-the-compilation-driver-gcc.rst b/gcc/doc/gccint/target-macros/controlling-the-compilation-driver-gcc.rst new file mode 100644 index 00000000000..9a201c7eaa7 --- /dev/null +++ b/gcc/doc/gccint/target-macros/controlling-the-compilation-driver-gcc.rst @@ -0,0 +1,482 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: driver, controlling the compilation driver + +.. _driver: + +Controlling the Compilation Driver, gcc +*************************************** + +.. prevent bad page break with this line + +You can control the compilation driver. + +.. c:macro:: DRIVER_SELF_SPECS + + A list of specs for the driver itself. It should be a suitable + initializer for an array of strings, with no surrounding braces. + + The driver applies these specs to its own command line between loading + default :samp:`specs` files (but not command-line specified ones) and + choosing the multilib directory or running any subcommands. It + applies them in the order given, so each spec can depend on the + options added by earlier ones. It is also possible to remove options + using :samp:`%<{option}` in the usual way. + + This macro can be useful when a port has several interdependent target + options. It provides a way of standardizing the command line so + that the other specs are easier to write. + + Do not define this macro if it does not need to do anything. + +.. c:macro:: OPTION_DEFAULT_SPECS + + A list of specs used to support configure-time default options (i.e. + :option:`--with` options) in the driver. It should be a suitable initializer + for an array of structures, each containing two strings, without the + outermost pair of surrounding braces. + + The first item in the pair is the name of the default. This must match + the code in :samp:`config.gcc` for the target. The second item is a spec + to apply if a default with this name was specified. The string + :samp:`%(VALUE)` in the spec will be replaced by the value of the default + everywhere it occurs. + + The driver will apply these specs to its own command line between loading + default :samp:`specs` files and processing ``DRIVER_SELF_SPECS``, using + the same mechanism as ``DRIVER_SELF_SPECS``. + + Do not define this macro if it does not need to do anything. + +.. c:macro:: CPP_SPEC + + A C string constant that tells the GCC driver program options to + pass to CPP. It can also specify how to translate options you + give to GCC into options for GCC to pass to the CPP. + + Do not define this macro if it does not need to do anything. + +.. c:macro:: CPLUSPLUS_CPP_SPEC + + This macro is just like ``CPP_SPEC``, but is used for C++, rather + than C. If you do not define this macro, then the value of + ``CPP_SPEC`` (if any) will be used instead. + +.. c:macro:: CC1_SPEC + + A C string constant that tells the GCC driver program options to + pass to ``cc1``, ``cc1plus``, ``f771``, and the other language + front ends. + It can also specify how to translate options you give to GCC into options + for GCC to pass to front ends. + + Do not define this macro if it does not need to do anything. + +.. c:macro:: CC1PLUS_SPEC + + A C string constant that tells the GCC driver program options to + pass to ``cc1plus``. It can also specify how to translate options you + give to GCC into options for GCC to pass to the ``cc1plus``. + + Do not define this macro if it does not need to do anything. + Note that everything defined in CC1_SPEC is already passed to + ``cc1plus`` so there is no need to duplicate the contents of + CC1_SPEC in CC1PLUS_SPEC. + +.. c:macro:: ASM_SPEC + + A C string constant that tells the GCC driver program options to + pass to the assembler. It can also specify how to translate options + you give to GCC into options for GCC to pass to the assembler. + See the file :samp:`sun3.h` for an example of this. + + Do not define this macro if it does not need to do anything. + +.. c:macro:: ASM_FINAL_SPEC + + A C string constant that tells the GCC driver program how to + run any programs which cleanup after the normal assembler. + Normally, this is not needed. See the file :samp:`mips.h` for + an example of this. + + Do not define this macro if it does not need to do anything. + +.. c:macro:: AS_NEEDS_DASH_FOR_PIPED_INPUT + + Define this macro, with no value, if the driver should give the assembler + an argument consisting of a single dash, :option:`-`, to instruct it to + read from its standard input (which will be a pipe connected to the + output of the compiler proper). This argument is given after any + :option:`-o` option specifying the name of the output file. + + If you do not define this macro, the assembler is assumed to read its + standard input if given no non-option arguments. If your assembler + cannot read standard input at all, use a :samp:`%{pipe:%e}` construct; + see :samp:`mips.h` for instance. + +.. c:macro:: LINK_SPEC + + A C string constant that tells the GCC driver program options to + pass to the linker. It can also specify how to translate options you + give to GCC into options for GCC to pass to the linker. + + Do not define this macro if it does not need to do anything. + +.. c:macro:: LIB_SPEC + + Another C string constant used much like ``LINK_SPEC``. The difference + between the two is that ``LIB_SPEC`` is used at the end of the + command given to the linker. + + If this macro is not defined, a default is provided that + loads the standard C library from the usual place. See :samp:`gcc.cc`. + +.. c:macro:: LIBGCC_SPEC + + Another C string constant that tells the GCC driver program + how and when to place a reference to :samp:`libgcc.a` into the + linker command line. This constant is placed both before and after + the value of ``LIB_SPEC``. + + If this macro is not defined, the GCC driver provides a default that + passes the string :option:`-lgcc` to the linker. + +.. c:macro:: REAL_LIBGCC_SPEC + + By default, if ``ENABLE_SHARED_LIBGCC`` is defined, the + ``LIBGCC_SPEC`` is not directly used by the driver program but is + instead modified to refer to different versions of :samp:`libgcc.a` + depending on the values of the command line flags :option:`-static`, + :option:`-shared`, :option:`-static-libgcc`, and :option:`-shared-libgcc`. On + targets where these modifications are inappropriate, define + ``REAL_LIBGCC_SPEC`` instead. ``REAL_LIBGCC_SPEC`` tells the + driver how to place a reference to :samp:`libgcc` on the link command + line, but, unlike ``LIBGCC_SPEC``, it is used unmodified. + +.. c:macro:: USE_LD_AS_NEEDED + + A macro that controls the modifications to ``LIBGCC_SPEC`` + mentioned in ``REAL_LIBGCC_SPEC``. If nonzero, a spec will be + generated that uses :option:`--as-needed` or equivalent options and the + shared :samp:`libgcc` in place of the + static exception handler library, when linking without any of + ``-static``, ``-static-libgcc``, or ``-shared-libgcc``. + +.. c:macro:: LINK_EH_SPEC + + If defined, this C string constant is added to ``LINK_SPEC``. + When ``USE_LD_AS_NEEDED`` is zero or undefined, it also affects + the modifications to ``LIBGCC_SPEC`` mentioned in + ``REAL_LIBGCC_SPEC``. + +.. c:macro:: STARTFILE_SPEC + + Another C string constant used much like ``LINK_SPEC``. The + difference between the two is that ``STARTFILE_SPEC`` is used at + the very beginning of the command given to the linker. + + If this macro is not defined, a default is provided that loads the + standard C startup file from the usual place. See :samp:`gcc.cc`. + +.. c:macro:: ENDFILE_SPEC + + Another C string constant used much like ``LINK_SPEC``. The + difference between the two is that ``ENDFILE_SPEC`` is used at + the very end of the command given to the linker. + + Do not define this macro if it does not need to do anything. + +.. c:macro:: THREAD_MODEL_SPEC + + GCC ``-v`` will print the thread model GCC was configured to use. + However, this doesn't work on platforms that are multilibbed on thread + models, such as AIX 4.3. On such platforms, define + ``THREAD_MODEL_SPEC`` such that it evaluates to a string without + blanks that names one of the recognized thread models. ``%*``, the + default value of this macro, will expand to the value of + ``thread_file`` set in :samp:`config.gcc`. + +.. c:macro:: SYSROOT_SUFFIX_SPEC + + Define this macro to add a suffix to the target sysroot when GCC is + configured with a sysroot. This will cause GCC to search for usr/lib, + et al, within sysroot+suffix. + +.. c:macro:: SYSROOT_HEADERS_SUFFIX_SPEC + + Define this macro to add a headers_suffix to the target sysroot when + GCC is configured with a sysroot. This will cause GCC to pass the + updated sysroot+headers_suffix to CPP, causing it to search for + usr/include, et al, within sysroot+headers_suffix. + +.. c:macro:: EXTRA_SPECS + + Define this macro to provide additional specifications to put in the + :samp:`specs` file that can be used in various specifications like + ``CC1_SPEC``. + + The definition should be an initializer for an array of structures, + containing a string constant, that defines the specification name, and a + string constant that provides the specification. + + Do not define this macro if it does not need to do anything. + + ``EXTRA_SPECS`` is useful when an architecture contains several + related targets, which have various ``..._SPECS`` which are similar + to each other, and the maintainer would like one central place to keep + these definitions. + + For example, the PowerPC System V.4 targets use ``EXTRA_SPECS`` to + define either ``_CALL_SYSV`` when the System V calling sequence is + used or ``_CALL_AIX`` when the older AIX-based calling sequence is + used. + + The :samp:`config/rs6000/rs6000.h` target file defines: + + .. code-block:: c++ + + #define EXTRA_SPECS \ + { "cpp_sysv_default", CPP_SYSV_DEFAULT }, + + #define CPP_SYS_DEFAULT "" + + The :samp:`config/rs6000/sysv.h` target file defines: + + .. code-block:: c++ + + #undef CPP_SPEC + #define CPP_SPEC \ + "%{posix: -D_POSIX_SOURCE } \ + %{mcall-sysv: -D_CALL_SYSV } \ + %{!mcall-sysv: %(cpp_sysv_default) } \ + %{msoft-float: -D_SOFT_FLOAT} %{mcpu=403: -D_SOFT_FLOAT}" + + #undef CPP_SYSV_DEFAULT + #define CPP_SYSV_DEFAULT "-D_CALL_SYSV" + + while the :samp:`config/rs6000/eabiaix.h` target file defines + ``CPP_SYSV_DEFAULT`` as: + + .. code-block:: c++ + + #undef CPP_SYSV_DEFAULT + #define CPP_SYSV_DEFAULT "-D_CALL_AIX" + +.. c:macro:: LINK_LIBGCC_SPECIAL_1 + + Define this macro if the driver program should find the library + :samp:`libgcc.a`. If you do not define this macro, the driver program will pass + the argument :option:`-lgcc` to tell the linker to do the search. + +.. c:macro:: LINK_GCC_C_SEQUENCE_SPEC + + The sequence in which libgcc and libc are specified to the linker. + By default this is ``%G %L %G``. + +.. c:macro:: POST_LINK_SPEC + + Define this macro to add additional steps to be executed after linker. + The default value of this macro is empty string. + +.. c:macro:: LINK_COMMAND_SPEC + + A C string constant giving the complete command line need to execute the + linker. When you do this, you will need to update your port each time a + change is made to the link command line within :samp:`gcc.cc`. Therefore, + define this macro only if you need to completely redefine the command + line for invoking the linker and there is no other way to accomplish + the effect you need. Overriding this macro may be avoidable by overriding + ``LINK_GCC_C_SEQUENCE_SPEC`` instead. + +.. c:var:: bool TARGET_ALWAYS_STRIP_DOTDOT + + .. hook-start:TARGET_ALWAYS_STRIP_DOTDOT + + True if :samp:`..` components should always be removed from directory names + computed relative to GCC's internal directories, false (default) if such + components should be preserved and directory names containing them passed + to other tools such as the linker. + +.. hook-end + +.. c:macro:: MULTILIB_DEFAULTS + + Define this macro as a C expression for the initializer of an array of + string to tell the driver program which options are defaults for this + target and thus do not need to be handled specially when using + ``MULTILIB_OPTIONS``. + + Do not define this macro if ``MULTILIB_OPTIONS`` is not defined in + the target makefile fragment or if none of the options listed in + ``MULTILIB_OPTIONS`` are set by default. + See :ref:`target-fragment`. + +.. c:macro:: RELATIVE_PREFIX_NOT_LINKDIR + + Define this macro to tell :command:`gcc` that it should only translate + a :option:`-B` prefix into a :option:`-L` linker option if the prefix + indicates an absolute file name. + +.. c:macro:: MD_EXEC_PREFIX + + If defined, this macro is an additional prefix to try after + ``STANDARD_EXEC_PREFIX``. ``MD_EXEC_PREFIX`` is not searched + when the compiler is built as a cross + compiler. If you define ``MD_EXEC_PREFIX``, then be sure to add it + to the list of directories used to find the assembler in :samp:`configure.ac`. + +.. c:macro:: STANDARD_STARTFILE_PREFIX + + Define this macro as a C string constant if you wish to override the + standard choice of ``libdir`` as the default prefix to + try when searching for startup files such as :samp:`crt0.o`. + ``STANDARD_STARTFILE_PREFIX`` is not searched when the compiler + is built as a cross compiler. + +.. c:macro:: STANDARD_STARTFILE_PREFIX_1 + + Define this macro as a C string constant if you wish to override the + standard choice of ``/lib`` as a prefix to try after the default prefix + when searching for startup files such as :samp:`crt0.o`. + ``STANDARD_STARTFILE_PREFIX_1`` is not searched when the compiler + is built as a cross compiler. + +.. c:macro:: STANDARD_STARTFILE_PREFIX_2 + + Define this macro as a C string constant if you wish to override the + standard choice of ``/lib`` as yet another prefix to try after the + default prefix when searching for startup files such as :samp:`crt0.o`. + ``STANDARD_STARTFILE_PREFIX_2`` is not searched when the compiler + is built as a cross compiler. + +.. c:macro:: MD_STARTFILE_PREFIX + + If defined, this macro supplies an additional prefix to try after the + standard prefixes. ``MD_EXEC_PREFIX`` is not searched when the + compiler is built as a cross compiler. + +.. c:macro:: MD_STARTFILE_PREFIX_1 + + If defined, this macro supplies yet another prefix to try after the + standard prefixes. It is not searched when the compiler is built as a + cross compiler. + +.. c:macro:: INIT_ENVIRONMENT + + Define this macro as a C string constant if you wish to set environment + variables for programs called by the driver, such as the assembler and + loader. The driver passes the value of this macro to ``putenv`` to + initialize the necessary environment variables. + +.. c:macro:: LOCAL_INCLUDE_DIR + + Define this macro as a C string constant if you wish to override the + standard choice of :samp:`/usr/local/include` as the default prefix to + try when searching for local header files. ``LOCAL_INCLUDE_DIR`` + comes before ``NATIVE_SYSTEM_HEADER_DIR`` (set in + :samp:`config.gcc`, normally :samp:`/usr/include`) in the search order. + + Cross compilers do not search either :samp:`/usr/local/include` or its + replacement. + +.. c:macro:: NATIVE_SYSTEM_HEADER_COMPONENT + + The 'component' corresponding to ``NATIVE_SYSTEM_HEADER_DIR``. + See ``INCLUDE_DEFAULTS``, below, for the description of components. + If you do not define this macro, no component is used. + +.. c:macro:: INCLUDE_DEFAULTS + + Define this macro if you wish to override the entire default search path + for include files. For a native compiler, the default search path + usually consists of ``GCC_INCLUDE_DIR``, ``LOCAL_INCLUDE_DIR``, + ``GPLUSPLUS_INCLUDE_DIR``, and + ``NATIVE_SYSTEM_HEADER_DIR``. In addition, ``GPLUSPLUS_INCLUDE_DIR`` + and ``GCC_INCLUDE_DIR`` are defined automatically by :samp:`Makefile`, + and specify private search areas for GCC. The directory + ``GPLUSPLUS_INCLUDE_DIR`` is used only for C++ programs. + + The definition should be an initializer for an array of structures. + Each array element should have four elements: the directory name (a + string constant), the component name (also a string constant), a flag + for C++-only directories, + and a flag showing that the includes in the directory don't need to be + wrapped in ``extern C`` when compiling C++. Mark the end of + the array with a null element. + + The component name denotes what GNU package the include file is part of, + if any, in all uppercase letters. For example, it might be :samp:`GCC` + or :samp:`BINUTILS`. If the package is part of a vendor-supplied + operating system, code the component name as :samp:`0`. + + For example, here is the definition used for VAX/VMS: + + .. code-block:: c++ + + #define INCLUDE_DEFAULTS \ + { \ + { "GNU_GXX_INCLUDE:", "G++", 1, 1}, \ + { "GNU_CC_INCLUDE:", "GCC", 0, 0}, \ + { "SYS$SYSROOT:[SYSLIB.]", 0, 0, 0}, \ + { ".", 0, 0, 0}, \ + { 0, 0, 0, 0} \ + } + +Here is the order of prefixes tried for exec files: + +* Any prefixes specified by the user with :option:`-B`. + +* The environment variable ``GCC_EXEC_PREFIX`` or, if ``GCC_EXEC_PREFIX`` + is not set and the compiler has not been installed in the configure-time + :samp:`{prefix}`, the location in which the compiler has actually been installed. + +* The directories specified by the environment variable ``COMPILER_PATH``. + +* The macro ``STANDARD_EXEC_PREFIX``, if the compiler has been installed + in the configured-time :samp:`{prefix}`. + +* The location :samp:`/usr/libexec/gcc/`, but only if this is a native compiler. + +* The location :samp:`/usr/lib/gcc/`, but only if this is a native compiler. + +* The macro ``MD_EXEC_PREFIX``, if defined, but only if this is a native + compiler. + +Here is the order of prefixes tried for startfiles: + +* Any prefixes specified by the user with :option:`-B`. + +* The environment variable ``GCC_EXEC_PREFIX`` or its automatically determined + value based on the installed toolchain location. + +* The directories specified by the environment variable ``LIBRARY_PATH`` + (or port-specific name; native only, cross compilers do not use this). + +* The macro ``STANDARD_EXEC_PREFIX``, but only if the toolchain is installed + in the configured :samp:`{prefix}` or this is a native compiler. + +* The location :samp:`/usr/lib/gcc/`, but only if this is a native compiler. + +* The macro ``MD_EXEC_PREFIX``, if defined, but only if this is a native + compiler. + +* The macro ``MD_STARTFILE_PREFIX``, if defined, but only if this is a + native compiler, or we have a target system root. + +* The macro ``MD_STARTFILE_PREFIX_1``, if defined, but only if this is a + native compiler, or we have a target system root. + +* The macro ``STANDARD_STARTFILE_PREFIX``, with any sysroot modifications. + If this path is relative it will be prefixed by ``GCC_EXEC_PREFIX`` and + the machine suffix or ``STANDARD_EXEC_PREFIX`` and the machine suffix. + +* The macro ``STANDARD_STARTFILE_PREFIX_1``, but only if this is a native + compiler, or we have a target system root. The default for this macro is + :samp:`/lib/`. + +* The macro ``STANDARD_STARTFILE_PREFIX_2``, but only if this is a native + compiler, or we have a target system root. The default for this macro is + :samp:`/usr/lib/`. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/cross-compilation-and-floating-point.rst b/gcc/doc/gccint/target-macros/cross-compilation-and-floating-point.rst new file mode 100644 index 00000000000..50e152a258f --- /dev/null +++ b/gcc/doc/gccint/target-macros/cross-compilation-and-floating-point.rst @@ -0,0 +1,73 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: cross compilation and floating point, floating point and cross compilation + +.. _floating-point: + +Cross Compilation and Floating Point +************************************ + +While all modern machines use twos-complement representation for integers, +there are a variety of representations for floating point numbers. This +means that in a cross-compiler the representation of floating point numbers +in the compiled program may be different from that used in the machine +doing the compilation. + +Because different representation systems may offer different amounts of +range and precision, all floating point constants must be represented in +the target machine's format. Therefore, the cross compiler cannot +safely use the host machine's floating point arithmetic; it must emulate +the target's arithmetic. To ensure consistency, GCC always uses +emulation to work with floating point values, even when the host and +target floating point formats are identical. + +The following macros are provided by :samp:`real.h` for the compiler to +use. All parts of the compiler which generate or optimize +floating-point calculations must use these macros. They may evaluate +their operands more than once, so operands must not have side effects. + +.. c:macro:: REAL_VALUE_TYPE + + The C data type to be used to hold a floating point value in the target + machine's format. Typically this is a ``struct`` containing an + array of ``HOST_WIDE_INT``, but all code should treat it as an opaque + quantity. + +.. function:: HOST_WIDE_INT REAL_VALUE_FIX (REAL_VALUE_TYPE x) + + Truncates :samp:`{x}` to a signed integer, rounding toward zero. + +.. function:: unsigned HOST_WIDE_INT REAL_VALUE_UNSIGNED_FIX (REAL_VALUE_TYPE x) + + Truncates :samp:`{x}` to an unsigned integer, rounding toward zero. If + :samp:`{x}` is negative, returns zero. + +.. function:: REAL_VALUE_TYPE REAL_VALUE_ATOF (const char *string, machine_mode mode) + + Converts :samp:`{string}` into a floating point number in the target machine's + representation for mode :samp:`{mode}`. This routine can handle both + decimal and hexadecimal floating point constants, using the syntax + defined by the C language for both. + +.. function:: int REAL_VALUE_NEGATIVE (REAL_VALUE_TYPE x) + + Returns 1 if :samp:`{x}` is negative (including negative zero), 0 otherwise. + +.. function:: int REAL_VALUE_ISINF (REAL_VALUE_TYPE x) + + Determines whether :samp:`{x}` represents infinity (positive or negative). + +.. function:: int REAL_VALUE_ISNAN (REAL_VALUE_TYPE x) + + Determines whether :samp:`{x}` represents a 'NaN' (not-a-number). + +.. function:: REAL_VALUE_TYPE REAL_VALUE_NEGATE (REAL_VALUE_TYPE x) + + Returns the negative of the floating point value :samp:`{x}`. + +.. function:: REAL_VALUE_TYPE REAL_VALUE_ABS (REAL_VALUE_TYPE x) + + Returns the absolute value of :samp:`{x}`. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/d-abi-parameters.rst b/gcc/doc/gccint/target-macros/d-abi-parameters.rst new file mode 100644 index 00000000000..38ee6ab3ff2 --- /dev/null +++ b/gcc/doc/gccint/target-macros/d-abi-parameters.rst @@ -0,0 +1,111 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: parameters, d abi + +.. _d-language-and-abi: + +D ABI parameters +**************** + +.. function:: void TARGET_D_CPU_VERSIONS (void) + + .. hook-start:TARGET_D_CPU_VERSIONS + + Declare all environmental version identifiers relating to the target CPU + using the function ``builtin_version``, which takes a string representing + the name of the version. Version identifiers predefined by this hook apply + to all modules that are being compiled and imported. + +.. hook-end + +.. function:: void TARGET_D_OS_VERSIONS (void) + + .. hook-start:TARGET_D_OS_VERSIONS + + Similarly to ``TARGET_D_CPU_VERSIONS``, but is used for versions + relating to the target operating system. + +.. hook-end + +.. function:: void TARGET_D_REGISTER_CPU_TARGET_INFO (void) + + .. hook-start:TARGET_D_REGISTER_CPU_TARGET_INFO + + Register all target information keys relating to the target CPU using the + function ``d_add_target_info_handlers``, which takes a + :samp:`struct d_target_info_spec` (defined in :samp:`d/d-target.h`). The keys + added by this hook are made available at compile time by the + ``__traits(getTargetInfo)`` extension, the result is an expression + describing the requested target information. + +.. hook-end + +.. function:: void TARGET_D_REGISTER_OS_TARGET_INFO (void) + + .. hook-start:TARGET_D_REGISTER_OS_TARGET_INFO + + Same as ``TARGET_D_CPU_TARGET_INFO``, but is used for keys relating to + the target operating system. + +.. hook-end + +.. c:var:: const char * TARGET_D_MINFO_SECTION + + .. hook-start:TARGET_D_MINFO_SECTION + + Contains the name of the section in which module info references should be + placed. By default, the compiler puts all module info symbols in the + ``"minfo"`` section. Define this macro to override the string if a + different section name should be used. This section is expected to be + bracketed by two symbols ``TARGET_D_MINFO_SECTION_START`` and + ``TARGET_D_MINFO_SECTION_END`` to indicate the start and end address of + the section, so that the runtime library can collect all modules for each + loaded shared library and executable. Setting the value to ``NULL`` + disables the use of sections for storing module info altogether. + +.. hook-end + +.. c:var:: const char * TARGET_D_MINFO_SECTION_START + + .. hook-start:TARGET_D_MINFO_SECTION_START + + If ``TARGET_D_MINFO_SECTION`` is defined, then this must also be defined + as the name of the symbol indicating the start address of the module info + section + +.. hook-end + +.. c:var:: const char * TARGET_D_MINFO_SECTION_END + + .. hook-start:TARGET_D_MINFO_SECTION_END + + If ``TARGET_D_MINFO_SECTION`` is defined, then this must also be defined + as the name of the symbol indicating the end address of the module info + section + +.. hook-end + +.. function:: bool TARGET_D_HAS_STDCALL_CONVENTION (unsigned int *link_system, unsigned int *link_windows) + + .. hook-start:TARGET_D_HAS_STDCALL_CONVENTION + + Returns ``true`` if the target supports the stdcall calling convention. + The hook should also set :samp:`{link_system}` to ``1`` if the ``stdcall`` + attribute should be applied to functions with ``extern(System)`` linkage, + and :samp:`{link_windows}` to ``1`` to apply ``stdcall`` to functions with + ``extern(Windows)`` linkage. + +.. hook-end + +.. c:var:: bool TARGET_D_TEMPLATES_ALWAYS_COMDAT + + .. hook-start:TARGET_D_TEMPLATES_ALWAYS_COMDAT + + This flag is true if instantiated functions and variables are always COMDAT + if they have external linkage. If this flag is false, then instantiated + decls will be emitted as weak symbols. The default is ``false``. + +.. hook-end diff --git a/gcc/doc/gccint/target-macros/defining-coprocessor-specifics-for-mips-targets.rst b/gcc/doc/gccint/target-macros/defining-coprocessor-specifics-for-mips-targets.rst new file mode 100644 index 00000000000..48c95bc9fc5 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-coprocessor-specifics-for-mips-targets.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MIPS coprocessor-definition macros + +.. _mips-coprocessors: + +Defining coprocessor specifics for MIPS targets. +************************************************ + +The MIPS specification allows MIPS implementations to have as many as 4 +coprocessors, each with as many as 32 private registers. GCC supports +accessing these registers and transferring values between the registers +and memory using asm-ized variables. For example: + +.. code-block:: c++ + + register unsigned int cp0count asm ("c0r1"); + unsigned int d; + + d = cp0count + 3; + +('c0r1' is the default name of register 1 in coprocessor 0; alternate +names may be added as described below, or the default names may be +overridden entirely in ``SUBTARGET_CONDITIONAL_REGISTER_USAGE``.) + +Coprocessor registers are assumed to be epilogue-used; sets to them will +be preserved even if it does not appear that the register is used again +later in the function. + +Another note: according to the MIPS spec, coprocessor 1 (if present) is +the FPU. One accesses COP1 registers through standard mips +floating-point support; they are not included in this mechanism. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-data-structures-for-per-function-information.rst b/gcc/doc/gccint/target-macros/defining-data-structures-for-per-function-information.rst new file mode 100644 index 00000000000..d291e772f35 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-data-structures-for-per-function-information.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: per-function data, data structures + +.. _per-function-data: + +Defining data structures for per-function information. +****************************************************** + +If the target needs to store information on a per-function basis, GCC +provides a macro and a couple of variables to allow this. Note, just +using statics to store the information is a bad idea, since GCC supports +nested functions, so you can be halfway through encoding one function +when another one comes along. + +GCC defines a data structure called ``struct function`` which +contains all of the data specific to an individual function. This +structure contains a field called ``machine`` whose type is +``struct machine_function *``, which can be used by targets to point +to their own specific data. + +If a target needs per-function specific data it should define the type +``struct machine_function`` and also the macro ``INIT_EXPANDERS``. +This macro should be used to initialize the function pointer +``init_machine_status``. This pointer is explained below. + +One typical use of per-function, target specific data is to create an +RTX to hold the register containing the function's return address. This +RTX can then be used to implement the ``__builtin_return_address`` +function, for level 0. + +Note---earlier implementations of GCC used a single data area to hold +all of the per-function information. Thus when processing of a nested +function began the old per-function data had to be pushed onto a +stack, and when the processing was finished, it had to be popped off the +stack. GCC used to provide function pointers called +``save_machine_status`` and ``restore_machine_status`` to handle +the saving and restoring of the target specific information. Since the +single data area approach is no longer used, these pointers are no +longer supported. + +.. c:macro:: INIT_EXPANDERS + + Macro called to initialize any target specific information. This macro + is called once per function, before generation of any RTL has begun. + The intention of this macro is to allow the initialization of the + function pointer ``init_machine_status``. + +.. index:: init_machine_status + +Variable void (\*)(struct function \*) init_machine_statusIf this function pointer is non- ``NULL`` it will be called once per +function, before function compilation starts, in order to allow the +target to perform any target specific initialization of the +``struct function`` structure. It is intended that this would be +used to initialize the ``machine`` of that structure. + +``struct machine_function`` structures are expected to be freed by GC. +Generally, any memory that they reference must be allocated by using +GC allocation, including the structure itself. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-target-specific-uses-of-attribute.rst b/gcc/doc/gccint/target-macros/defining-target-specific-uses-of-attribute.rst new file mode 100644 index 00000000000..0a265b2d1c9 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-target-specific-uses-of-attribute.rst @@ -0,0 +1,319 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: target attributes, machine attributes, attributes, target-specific + +.. _target-attributes: + +Defining target-specific uses of __attribute__ +********************************************** + +Target-specific attributes may be defined for functions, data and types. +These are described using the following target hooks; they also need to +be documented in :samp:`extend.texi`. + +.. c:var:: const struct attribute_spec * TARGET_ATTRIBUTE_TABLE + + .. hook-start:TARGET_ATTRIBUTE_TABLE + + If defined, this target hook points to an array of :samp:`struct + attribute_spec` (defined in :samp:`tree-core.h`) specifying the machine + specific attributes for this target and some of the restrictions on the + entities to which these attributes are applied and the arguments they + take. + +.. hook-end + +.. function:: bool TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P (const_tree name) + + .. hook-start:TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P + + If defined, this target hook is a function which returns true if the + machine-specific attribute named :samp:`{name}` expects an identifier + given as its first argument to be passed on as a plain identifier, not + subjected to name lookup. If this is not defined, the default is + false for all machine-specific attributes. + +.. hook-end + +.. function:: int TARGET_COMP_TYPE_ATTRIBUTES (const_tree type1, const_tree type2) + + .. hook-start:TARGET_COMP_TYPE_ATTRIBUTES + + If defined, this target hook is a function which returns zero if the attributes on + :samp:`{type1}` and :samp:`{type2}` are incompatible, one if they are compatible, + and two if they are nearly compatible (which causes a warning to be + generated). If this is not defined, machine-specific attributes are + supposed always to be compatible. + +.. hook-end + +.. function:: void TARGET_SET_DEFAULT_TYPE_ATTRIBUTES (tree type) + + .. hook-start:TARGET_SET_DEFAULT_TYPE_ATTRIBUTES + + If defined, this target hook is a function which assigns default attributes to + the newly defined :samp:`{type}`. + +.. hook-end + +.. function:: tree TARGET_MERGE_TYPE_ATTRIBUTES (tree type1, tree type2) + + .. hook-start:TARGET_MERGE_TYPE_ATTRIBUTES + + Define this target hook if the merging of type attributes needs special + handling. If defined, the result is a list of the combined + ``TYPE_ATTRIBUTES`` of :samp:`{type1}` and :samp:`{type2}`. It is assumed + that ``comptypes`` has already been called and returned 1. This + function may call ``merge_attributes`` to handle machine-independent + merging. + +.. hook-end + +.. function:: tree TARGET_MERGE_DECL_ATTRIBUTES (tree olddecl, tree newdecl) + + .. hook-start:TARGET_MERGE_DECL_ATTRIBUTES + + Define this target hook if the merging of decl attributes needs special + handling. If defined, the result is a list of the combined + ``DECL_ATTRIBUTES`` of :samp:`{olddecl}` and :samp:`{newdecl}`. + :samp:`{newdecl}` is a duplicate declaration of :samp:`{olddecl}`. Examples of + when this is needed are when one attribute overrides another, or when an + attribute is nullified by a subsequent definition. This function may + call ``merge_attributes`` to handle machine-independent merging. + + .. index:: TARGET_DLLIMPORT_DECL_ATTRIBUTES + + If the only target-specific handling you require is :samp:`dllimport` + for Microsoft Windows targets, you should define the macro + ``TARGET_DLLIMPORT_DECL_ATTRIBUTES`` to ``1``. The compiler + will then define a function called + ``merge_dllimport_decl_attributes`` which can then be defined as + the expansion of ``TARGET_MERGE_DECL_ATTRIBUTES``. You can also + add ``handle_dll_attribute`` in the attribute table for your port + to perform initial processing of the :samp:`dllimport` and + :samp:`dllexport` attributes. This is done in :samp:`i386/cygwin.h` and + :samp:`i386/i386.cc`, for example. + +.. hook-end + +.. function:: bool TARGET_VALID_DLLIMPORT_ATTRIBUTE_P (const_tree decl) + + .. hook-start:TARGET_VALID_DLLIMPORT_ATTRIBUTE_P + + :samp:`{decl}` is a variable or function with ``__attribute__((dllimport))`` + specified. Use this hook if the target needs to add extra validation + checks to ``handle_dll_attribute``. + +.. hook-end + +.. c:macro:: TARGET_DECLSPEC + + Define this macro to a nonzero value if you want to treat + ``__declspec(X)`` as equivalent to ``__attribute((X))``. By + default, this behavior is enabled only for targets that define + ``TARGET_DLLIMPORT_DECL_ATTRIBUTES``. The current implementation + of ``__declspec`` is via a built-in macro, but you should not rely + on this implementation detail. + +.. function:: void TARGET_INSERT_ATTRIBUTES (tree node, tree *attr_ptr) + + .. hook-start:TARGET_INSERT_ATTRIBUTES + + Define this target hook if you want to be able to add attributes to a decl + when it is being created. This is normally useful for back ends which + wish to implement a pragma by using the attributes which correspond to + the pragma's effect. The :samp:`{node}` argument is the decl which is being + created. The :samp:`{attr_ptr}` argument is a pointer to the attribute list + for this decl. The list itself should not be modified, since it may be + shared with other decls, but attributes may be chained on the head of + the list and ``*attr_ptr`` modified to point to the new + attributes, or a copy of the list may be made if further changes are + needed. + +.. hook-end + +.. function:: tree TARGET_HANDLE_GENERIC_ATTRIBUTE (tree *node, tree name, tree args, int flags, bool *no_add_attrs) + + .. hook-start:TARGET_HANDLE_GENERIC_ATTRIBUTE + + Define this target hook if you want to be able to perform additional + target-specific processing of an attribute which is handled generically + by a front end. The arguments are the same as those which are passed to + attribute handlers. So far this only affects the :samp:`{noinit}` and + :samp:`{section}` attribute. + +.. hook-end + +.. function:: bool TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P (const_tree fndecl) + + .. hook-start:TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P + + .. index:: inlining + + This target hook returns ``true`` if it is OK to inline :samp:`{fndecl}` + into the current function, despite its having target-specific + attributes, ``false`` otherwise. By default, if a function has a + target specific attribute attached to it, it will not be inlined. + +.. hook-end + +.. function:: bool TARGET_OPTION_VALID_ATTRIBUTE_P (tree fndecl, tree name, tree args, int flags) + + .. hook-start:TARGET_OPTION_VALID_ATTRIBUTE_P + + This hook is called to parse ``attribute(target("..."))``, which + allows setting target-specific options on individual functions. + These function-specific options may differ + from the options specified on the command line. The hook should return + ``true`` if the options are valid. + + The hook should set the ``DECL_FUNCTION_SPECIFIC_TARGET`` field in + the function declaration to hold a pointer to a target-specific + ``struct cl_target_option`` structure. + +.. hook-end + +.. function:: void TARGET_OPTION_SAVE (struct cl_target_option *ptr, struct gcc_options *opts, struct gcc_options *opts_set) + + .. hook-start:TARGET_OPTION_SAVE + + This hook is called to save any additional target-specific information + in the ``struct cl_target_option`` structure for function-specific + options from the ``struct gcc_options`` structure. + See :ref:`option-file-format`. + +.. hook-end + +.. function:: void TARGET_OPTION_RESTORE (struct gcc_options *opts, struct gcc_options *opts_set, struct cl_target_option *ptr) + + .. hook-start:TARGET_OPTION_RESTORE + + This hook is called to restore any additional target-specific + information in the ``struct cl_target_option`` structure for + function-specific options to the ``struct gcc_options`` structure. + +.. hook-end + +.. function:: void TARGET_OPTION_POST_STREAM_IN (struct cl_target_option *ptr) + + .. hook-start:TARGET_OPTION_POST_STREAM_IN + + This hook is called to update target-specific information in the + ``struct cl_target_option`` structure after it is streamed in from + LTO bytecode. + +.. hook-end + +.. function:: void TARGET_OPTION_PRINT (FILE *file, int indent, struct cl_target_option *ptr) + + .. hook-start:TARGET_OPTION_PRINT + + This hook is called to print any additional target-specific + information in the ``struct cl_target_option`` structure for + function-specific options. + +.. hook-end + +.. function:: bool TARGET_OPTION_PRAGMA_PARSE (tree args, tree pop_target) + + .. hook-start:TARGET_OPTION_PRAGMA_PARSE + + This target hook parses the options for ``#pragma GCC target``, which + sets the target-specific options for functions that occur later in the + input stream. The options accepted should be the same as those handled by the + ``TARGET_OPTION_VALID_ATTRIBUTE_P`` hook. + +.. hook-end + +.. function:: void TARGET_OPTION_OVERRIDE (void) + + .. hook-start:TARGET_OPTION_OVERRIDE + + Sometimes certain combinations of command options do not make sense on + a particular target machine. You can override the hook + ``TARGET_OPTION_OVERRIDE`` to take account of this. This hooks is called + once just after all the command options have been parsed. + + Don't use this hook to turn on various extra optimizations for + :option:`-O`. That is what ``TARGET_OPTION_OPTIMIZATION`` is for. + + If you need to do something whenever the optimization level is + changed via the optimize attribute or pragma, see + ``TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE`` + +.. hook-end + +.. function:: bool TARGET_OPTION_FUNCTION_VERSIONS (tree decl1, tree decl2) + + .. hook-start:TARGET_OPTION_FUNCTION_VERSIONS + + This target hook returns ``true`` if :samp:`{DECL1}` and :samp:`{DECL2}` are + versions of the same function. :samp:`{DECL1}` and :samp:`{DECL2}` are function + versions if and only if they have the same function signature and + different target specific attributes, that is, they are compiled for + different target machines. + +.. hook-end + +.. function:: bool TARGET_CAN_INLINE_P (tree caller, tree callee) + + .. hook-start:TARGET_CAN_INLINE_P + + This target hook returns ``false`` if the :samp:`{caller}` function + cannot inline :samp:`{callee}`, based on target specific information. By + default, inlining is not allowed if the callee function has function + specific target options and the caller does not use the same options. + +.. hook-end + +.. function:: bool TARGET_UPDATE_IPA_FN_TARGET_INFO (unsigned int& info, const gimple* stmt) + + .. hook-start:TARGET_UPDATE_IPA_FN_TARGET_INFO + + Allow target to analyze all gimple statements for the given function to + record and update some target specific information for inlining. A typical + example is that a caller with one isa feature disabled is normally not + allowed to inline a callee with that same isa feature enabled even which is + attributed by always_inline, but with the conservative analysis on all + statements of the callee if we are able to guarantee the callee does not + exploit any instructions from the mismatch isa feature, it would be safe to + allow the caller to inline the callee. + :samp:`{info}` is one ``unsigned int`` value to record information in which + one set bit indicates one corresponding feature is detected in the analysis, + :samp:`{stmt}` is the statement being analyzed. Return true if target still + need to analyze the subsequent statements, otherwise return false to stop + subsequent analysis. + The default version of this hook returns false. + +.. hook-end + +.. function:: bool TARGET_NEED_IPA_FN_TARGET_INFO (const_tree decl, unsigned int& info) + + .. hook-start:TARGET_NEED_IPA_FN_TARGET_INFO + + Allow target to check early whether it is necessary to analyze all gimple + statements in the given function to update target specific information for + inlining. See hook ``update_ipa_fn_target_info`` for usage example of + target specific information. This hook is expected to be invoked ahead of + the iterating with hook ``update_ipa_fn_target_info``. + :samp:`{decl}` is the function being analyzed, :samp:`{info}` is the same as what + in hook ``update_ipa_fn_target_info``, target can do one time update + into :samp:`{info}` without iterating for some case. Return true if target + decides to analyze all gimple statements to collect information, otherwise + return false. + The default version of this hook returns false. + +.. hook-end + +.. function:: void TARGET_RELAYOUT_FUNCTION (tree fndecl) + + .. hook-start:TARGET_RELAYOUT_FUNCTION + + This target hook fixes function :samp:`{fndecl}` after attributes are processed. + Default does nothing. On ARM, the default function's alignment is updated + with the attribute target. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-the-output-assembler-language.rst b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language.rst new file mode 100644 index 00000000000..9c5de6398c6 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _assembler-format: + +Defining the Output Assembler Language +************************************** + +This section describes macros whose principal purpose is to describe how +to write instructions in assembler language---rather than what the +instructions do. + +.. toctree:: + :maxdepth: 2 + + defining-the-output-assembler-language/the-overall-framework-of-an-assembler-file + defining-the-output-assembler-language/output-of-data + defining-the-output-assembler-language/output-of-uninitialized-variables + defining-the-output-assembler-language/output-and-generation-of-labels + defining-the-output-assembler-language/how-initialization-functions-are-handled + defining-the-output-assembler-language/macros-controlling-initialization-routines + defining-the-output-assembler-language/output-of-assembler-instructions + defining-the-output-assembler-language/output-of-dispatch-tables + defining-the-output-assembler-language/assembler-commands-for-exception-regions + defining-the-output-assembler-language/assembler-commands-for-alignment \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/assembler-commands-for-alignment.rst b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/assembler-commands-for-alignment.rst new file mode 100644 index 00000000000..d356a71f050 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/assembler-commands-for-alignment.rst @@ -0,0 +1,95 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _alignment-output: + +Assembler Commands for Alignment +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +This describes commands for alignment. + +.. c:macro:: JUMP_ALIGN (label) + + The alignment (log base 2) to put in front of :samp:`{label}`, which is + a common destination of jumps and has no fallthru incoming edge. + + This macro need not be defined if you don't want any special alignment + to be done at such a time. Most machine descriptions do not currently + define the macro. + + Unless it's necessary to inspect the :samp:`{label}` parameter, it is better + to set the variable :samp:`{align_jumps}` in the target's + ``TARGET_OPTION_OVERRIDE``. Otherwise, you should try to honor the user's + selection in :samp:`{align_jumps}` in a ``JUMP_ALIGN`` implementation. + +.. c:macro:: LABEL_ALIGN_AFTER_BARRIER (label) + + The alignment (log base 2) to put in front of :samp:`{label}`, which follows + a ``BARRIER``. + + This macro need not be defined if you don't want any special alignment + to be done at such a time. Most machine descriptions do not currently + define the macro. + +.. c:macro:: LOOP_ALIGN (label) + + The alignment (log base 2) to put in front of :samp:`{label}` that heads + a frequently executed basic block (usually the header of a loop). + + This macro need not be defined if you don't want any special alignment + to be done at such a time. Most machine descriptions do not currently + define the macro. + + Unless it's necessary to inspect the :samp:`{label}` parameter, it is better + to set the variable ``align_loops`` in the target's + ``TARGET_OPTION_OVERRIDE``. Otherwise, you should try to honor the user's + selection in ``align_loops`` in a ``LOOP_ALIGN`` implementation. + +.. c:macro:: LABEL_ALIGN (label) + + The alignment (log base 2) to put in front of :samp:`{label}`. + If ``LABEL_ALIGN_AFTER_BARRIER`` / ``LOOP_ALIGN`` specify a different alignment, + the maximum of the specified values is used. + + Unless it's necessary to inspect the :samp:`{label}` parameter, it is better + to set the variable ``align_labels`` in the target's + ``TARGET_OPTION_OVERRIDE``. Otherwise, you should try to honor the user's + selection in ``align_labels`` in a ``LABEL_ALIGN`` implementation. + +.. c:macro:: ASM_OUTPUT_SKIP (stream, nbytes) + + A C statement to output to the stdio stream :samp:`{stream}` an assembler + instruction to advance the location counter by :samp:`{nbytes}` bytes. + Those bytes should be zero when loaded. :samp:`{nbytes}` will be a C + expression of type ``unsigned HOST_WIDE_INT``. + +.. c:macro:: ASM_NO_SKIP_IN_TEXT + + Define this macro if ``ASM_OUTPUT_SKIP`` should not be used in the + text section because it fails to put zeros in the bytes that are skipped. + This is true on many Unix systems, where the pseudo--op to skip bytes + produces no-op instructions rather than zeros when used in the text + section. + +.. c:macro:: ASM_OUTPUT_ALIGN (stream, power) + + A C statement to output to the stdio stream :samp:`{stream}` an assembler + command to advance the location counter to a multiple of 2 to the + :samp:`{power}` bytes. :samp:`{power}` will be a C expression of type ``int``. + +.. c:macro:: ASM_OUTPUT_ALIGN_WITH_NOP (stream, power) + + Like ``ASM_OUTPUT_ALIGN``, except that the 'nop' instruction is used + for padding, if necessary. + +.. c:macro:: ASM_OUTPUT_MAX_SKIP_ALIGN (stream, power, max_skip) + + A C statement to output to the stdio stream :samp:`{stream}` an assembler + command to advance the location counter to a multiple of 2 to the + :samp:`{power}` bytes, but only if :samp:`{max_skip}` or fewer bytes are needed to + satisfy the alignment request. :samp:`{power}` and :samp:`{max_skip}` will be + a C expression of type ``int``. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/assembler-commands-for-exception-regions.rst b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/assembler-commands-for-exception-regions.rst new file mode 100644 index 00000000000..3f38048f932 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/assembler-commands-for-exception-regions.rst @@ -0,0 +1,188 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _exception-region-output: + +Assembler Commands for Exception Regions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +This describes commands marking the start and the end of an exception +region. + +.. c:macro:: EH_FRAME_SECTION_NAME + + If defined, a C string constant for the name of the section containing + exception handling frame unwind information. If not defined, GCC will + provide a default definition if the target supports named sections. + :samp:`crtstuff.c` uses this macro to switch to the appropriate section. + + You should define this symbol if your target supports DWARF 2 frame + unwind information and the default definition does not work. + +.. c:macro:: EH_FRAME_THROUGH_COLLECT2 + + If defined, DWARF 2 frame unwind information will identified by + specially named labels. The collect2 process will locate these + labels and generate code to register the frames. + + This might be necessary, for instance, if the system linker will not + place the eh_frames in-between the sentinals from :samp:`crtstuff.c`, + or if the system linker does garbage collection and sections cannot + be marked as not to be collected. + +.. c:macro:: EH_TABLES_CAN_BE_READ_ONLY + + Define this macro to 1 if your target is such that no frame unwind + information encoding used with non-PIC code will ever require a + runtime relocation, but the linker may not support merging read-only + and read-write sections into a single read-write section. + +.. c:macro:: MASK_RETURN_ADDR + + An rtx used to mask the return address found via ``RETURN_ADDR_RTX``, so + that it does not contain any extraneous set bits in it. + +.. c:macro:: DWARF2_UNWIND_INFO + + Define this macro to 0 if your target supports DWARF 2 frame unwind + information, but it does not yet work with exception handling. + Otherwise, if your target supports this information (if it defines + ``INCOMING_RETURN_ADDR_RTX`` and ``OBJECT_FORMAT_ELF``), + GCC will provide a default definition of 1. + +.. function:: enum unwind_info_type TARGET_EXCEPT_UNWIND_INFO (struct gcc_options *opts) + + .. hook-start:TARGET_EXCEPT_UNWIND_INFO + + .. hook-end + + This hook defines the mechanism that will be used for exception handling + by the target. If the target has ABI specified unwind tables, the hook + should return ``UI_TARGET``. If the target is to use the + ``setjmp`` / ``longjmp`` -based exception handling scheme, the hook + should return ``UI_SJLJ``. If the target supports DWARF 2 frame unwind + information, the hook should return ``UI_DWARF2``. + + A target may, if exceptions are disabled, choose to return ``UI_NONE``. + This may end up simplifying other parts of target-specific code. The + default implementation of this hook never returns ``UI_NONE``. + + Note that the value returned by this hook should be constant. It should + not depend on anything except the command-line switches described by + :samp:`{opts}`. In particular, the + setting ``UI_SJLJ`` must be fixed at compiler start-up as C pre-processor + macros and builtin functions related to exception handling are set up + depending on this setting. + + The default implementation of the hook first honors the + :option:`--enable-sjlj-exceptions` configure option, then + ``DWARF2_UNWIND_INFO``, and finally defaults to ``UI_SJLJ``. If + ``DWARF2_UNWIND_INFO`` depends on command-line options, the target + must define this hook so that :samp:`{opts}` is used correctly. + +.. c:var:: bool TARGET_UNWIND_TABLES_DEFAULT + + .. hook-start:TARGET_UNWIND_TABLES_DEFAULT + + .. hook-end + + This variable should be set to ``true`` if the target ABI requires unwinding + tables even when exceptions are not used. It must not be modified by + command-line option processing. + +.. c:macro:: DONT_USE_BUILTIN_SETJMP + + Define this macro to 1 if the ``setjmp`` / ``longjmp`` -based scheme + should use the ``setjmp`` / ``longjmp`` functions from the C library + instead of the ``__builtin_setjmp`` / ``__builtin_longjmp`` machinery. + +.. c:macro:: JMP_BUF_SIZE + + This macro has no effect unless ``DONT_USE_BUILTIN_SETJMP`` is also + defined. Define this macro if the default size of ``jmp_buf`` buffer + for the ``setjmp`` / ``longjmp`` -based exception handling mechanism + is not large enough, or if it is much too large. + The default size is ``FIRST_PSEUDO_REGISTER * sizeof(void *)``. + +.. c:macro:: DWARF_CIE_DATA_ALIGNMENT + + This macro need only be defined if the target might save registers in the + function prologue at an offset to the stack pointer that is not aligned to + ``UNITS_PER_WORD``. The definition should be the negative minimum + alignment if ``STACK_GROWS_DOWNWARD`` is true, and the positive + minimum alignment otherwise. See :ref:`dwarf`. Only applicable if + the target supports DWARF 2 frame unwind information. + +.. c:var:: bool TARGET_TERMINATE_DW2_EH_FRAME_INFO + + .. hook-start:TARGET_TERMINATE_DW2_EH_FRAME_INFO + + Contains the value true if the target should add a zero word onto the + end of a Dwarf-2 frame info section when used for exception handling. + Default value is false if ``EH_FRAME_SECTION_NAME`` is defined, and + true otherwise. + +.. hook-end + +.. function:: rtx TARGET_DWARF_REGISTER_SPAN (rtx reg) + + .. hook-start:TARGET_DWARF_REGISTER_SPAN + + Given a register, this hook should return a parallel of registers to + represent where to find the register pieces. Define this hook if the + register and its mode are represented in Dwarf in non-contiguous + locations, or if the register should be represented in more than one + register in Dwarf. Otherwise, this hook should return ``NULL_RTX``. + If not defined, the default is to return ``NULL_RTX``. + +.. hook-end + +.. function:: machine_mode TARGET_DWARF_FRAME_REG_MODE (int regno) + + .. hook-start:TARGET_DWARF_FRAME_REG_MODE + + Given a register, this hook should return the mode which the + corresponding Dwarf frame register should have. This is normally + used to return a smaller mode than the raw mode to prevent call + clobbered parts of a register altering the frame register size + +.. hook-end + +.. function:: void TARGET_INIT_DWARF_REG_SIZES_EXTRA (tree address) + + .. hook-start:TARGET_INIT_DWARF_REG_SIZES_EXTRA + + If some registers are represented in Dwarf-2 unwind information in + multiple pieces, define this hook to fill in information about the + sizes of those pieces in the table used by the unwinder at runtime. + It will be called by ``expand_builtin_init_dwarf_reg_sizes`` after + filling in a single size corresponding to each hard register; + :samp:`{address}` is the address of the table. + +.. hook-end + +.. function:: bool TARGET_ASM_TTYPE (rtx sym) + + .. hook-start:TARGET_ASM_TTYPE + + This hook is used to output a reference from a frame unwinding table to + the type_info object identified by :samp:`{sym}`. It should return ``true`` + if the reference was output. Returning ``false`` will cause the + reference to be output using the normal Dwarf2 routines. + +.. hook-end + +.. c:var:: bool TARGET_ARM_EABI_UNWINDER + + .. hook-start:TARGET_ARM_EABI_UNWINDER + + This flag should be set to ``true`` on targets that use an ARM EABI + based unwinding library, and ``false`` on other targets. This effects + the format of unwinding tables, and how the unwinder in entered after + running a cleanup. The default is ``false``. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/how-initialization-functions-are-handled.rst b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/how-initialization-functions-are-handled.rst new file mode 100644 index 00000000000..7058c56600a --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/how-initialization-functions-are-handled.rst @@ -0,0 +1,122 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: initialization routines, termination routines, constructors, output of, destructors, output of + +.. _initialization: + +How Initialization Functions Are Handled +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The compiled code for certain languages includes :dfn:`constructors` +(also called :dfn:`initialization routines`)---functions to initialize +data in the program when the program is started. These functions need +to be called before the program is 'started'---that is to say, before +``main`` is called. + +Compiling some languages generates :dfn:`destructors` (also called +:dfn:`termination routines`) that should be called when the program +terminates. + +To make the initialization and termination functions work, the compiler +must output something in the assembler code to cause those functions to +be called at the appropriate time. When you port the compiler to a new +system, you need to specify how to do this. + +There are two major ways that GCC currently supports the execution of +initialization and termination functions. Each way has two variants. +Much of the structure is common to all four variations. + +.. index:: __CTOR_LIST__, __DTOR_LIST__ + +The linker must build two lists of these functions---a list of +initialization functions, called ``__CTOR_LIST__``, and a list of +termination functions, called ``__DTOR_LIST__``. + +Each list always begins with an ignored function pointer (which may hold +0, -1, or a count of the function pointers after it, depending on +the environment). This is followed by a series of zero or more function +pointers to constructors (or destructors), followed by a function +pointer containing zero. + +Depending on the operating system and its executable file format, either +:samp:`crtstuff.c` or :samp:`libgcc2.c` traverses these lists at startup +time and exit time. Constructors are called in reverse order of the +list; destructors in forward order. + +The best way to handle static constructors works only for object file +formats which provide arbitrarily-named sections. A section is set +aside for a list of constructors, and another for a list of destructors. +Traditionally these are called :samp:`.ctors` and :samp:`.dtors`. Each +object file that defines an initialization function also puts a word in +the constructor section to point to that function. The linker +accumulates all these words into one contiguous :samp:`.ctors` section. +Termination functions are handled similarly. + +This method will be chosen as the default by :samp:`target-def.h` if +``TARGET_ASM_NAMED_SECTION`` is defined. A target that does not +support arbitrary sections, but does support special designated +constructor and destructor sections may define ``CTORS_SECTION_ASM_OP`` +and ``DTORS_SECTION_ASM_OP`` to achieve the same effect. + +When arbitrary sections are available, there are two variants, depending +upon how the code in :samp:`crtstuff.c` is called. On systems that +support a :dfn:`.init` section which is executed at program startup, +parts of :samp:`crtstuff.c` are compiled into that section. The +program is linked by the :command:`gcc` driver like this: + +.. code-block:: c++ + + ld -o output_file crti.o crtbegin.o ... -lgcc crtend.o crtn.o + +The prologue of a function (``__init``) appears in the ``.init`` +section of :samp:`crti.o`; the epilogue appears in :samp:`crtn.o`. Likewise +for the function ``__fini`` in the :dfn:`.fini` section. Normally these +files are provided by the operating system or by the GNU C library, but +are provided by GCC for a few targets. + +The objects :samp:`crtbegin.o` and :samp:`crtend.o` are (for most targets) +compiled from :samp:`crtstuff.c`. They contain, among other things, code +fragments within the ``.init`` and ``.fini`` sections that branch +to routines in the ``.text`` section. The linker will pull all parts +of a section together, which results in a complete ``__init`` function +that invokes the routines we need at startup. + +To use this variant, you must define the ``INIT_SECTION_ASM_OP`` +macro properly. + +If no init section is available, when GCC compiles any function called +``main`` (or more accurately, any function designated as a program +entry point by the language front end calling ``expand_main_function``), +it inserts a procedure call to ``__main`` as the first executable code +after the function prologue. The ``__main`` function is defined +in :samp:`libgcc2.c` and runs the global constructors. + +In file formats that don't support arbitrary sections, there are again +two variants. In the simplest variant, the GNU linker (GNU ``ld``) +and an 'a.out' format must be used. In this case, +``TARGET_ASM_CONSTRUCTOR`` is defined to produce a ``.stabs`` +entry of type :samp:`N_SETT`, referencing the name ``__CTOR_LIST__``, +and with the address of the void function containing the initialization +code as its value. The GNU linker recognizes this as a request to add +the value to a :dfn:`set`; the values are accumulated, and are eventually +placed in the executable as a vector in the format described above, with +a leading (ignored) count and a trailing zero element. +``TARGET_ASM_DESTRUCTOR`` is handled similarly. Since no init +section is available, the absence of ``INIT_SECTION_ASM_OP`` causes +the compilation of ``main`` to call ``__main`` as above, starting +the initialization process. + +The last variant uses neither arbitrary sections nor the GNU linker. +This is preferable when you want to do dynamic linking and when using +file formats which the GNU linker does not support, such as 'ECOFF'. In +this case, ``TARGET_HAVE_CTORS_DTORS`` is false, initialization and +termination functions are recognized simply by their names. This requires +an extra program in the linkage step, called :command:`collect2`. This program +pretends to be the linker, for use with GCC; it does its job by running +the ordinary linker, but also arranges to include the vectors of +initialization and termination functions. These functions are called +via ``__main`` as described above. In order to use this method, +``use_collect2`` must be defined in the target in :samp:`config.gcc`. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/macros-controlling-initialization-routines.rst b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/macros-controlling-initialization-routines.rst new file mode 100644 index 00000000000..2cfe0c8e3d7 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/macros-controlling-initialization-routines.rst @@ -0,0 +1,182 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _macros-for-initialization: + +Macros Controlling Initialization Routines +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Here are the macros that control how the compiler handles initialization +and termination functions: + +.. c:macro:: INIT_SECTION_ASM_OP + + If defined, a C string constant, including spacing, for the assembler + operation to identify the following data as initialization code. If not + defined, GCC will assume such a section does not exist. When you are + using special sections for initialization and termination functions, this + macro also controls how :samp:`crtstuff.c` and :samp:`libgcc2.c` arrange to + run the initialization functions. + +.. c:macro:: HAS_INIT_SECTION + + If defined, ``main`` will not call ``__main`` as described above. + This macro should be defined for systems that control start-up code + on a symbol-by-symbol basis, such as OSF/1, and should not + be defined explicitly for systems that support ``INIT_SECTION_ASM_OP``. + +.. c:macro:: LD_INIT_SWITCH + + If defined, a C string constant for a switch that tells the linker that + the following symbol is an initialization routine. + +.. c:macro:: LD_FINI_SWITCH + + If defined, a C string constant for a switch that tells the linker that + the following symbol is a finalization routine. + +.. c:macro:: COLLECT_SHARED_INIT_FUNC (stream, func) + + If defined, a C statement that will write a function that can be + automatically called when a shared library is loaded. The function + should call :samp:`{func}`, which takes no arguments. If not defined, and + the object format requires an explicit initialization function, then a + function called ``_GLOBAL__DI`` will be generated. + + This function and the following one are used by collect2 when linking a + shared library that needs constructors or destructors, or has DWARF2 + exception tables embedded in the code. + +.. c:macro:: COLLECT_SHARED_FINI_FUNC (stream, func) + + If defined, a C statement that will write a function that can be + automatically called when a shared library is unloaded. The function + should call :samp:`{func}`, which takes no arguments. If not defined, and + the object format requires an explicit finalization function, then a + function called ``_GLOBAL__DD`` will be generated. + +.. c:macro:: INVOKE__main + + If defined, ``main`` will call ``__main`` despite the presence of + ``INIT_SECTION_ASM_OP``. This macro should be defined for systems + where the init section is not actually run automatically, but is still + useful for collecting the lists of constructors and destructors. + +.. c:macro:: SUPPORTS_INIT_PRIORITY + + If nonzero, the C++ ``init_priority`` attribute is supported and the + compiler should emit instructions to control the order of initialization + of objects. If zero, the compiler will issue an error message upon + encountering an ``init_priority`` attribute. + +.. c:var:: bool TARGET_HAVE_CTORS_DTORS + + .. hook-start:TARGET_HAVE_CTORS_DTORS + + This value is true if the target supports some 'native' method of + collecting constructors and destructors to be run at startup and exit. + It is false if we must use :command:`collect2`. + +.. hook-end + +.. c:var:: bool TARGET_DTORS_FROM_CXA_ATEXIT + + .. hook-start:TARGET_DTORS_FROM_CXA_ATEXIT + + This value is true if the target wants destructors to be queued to be + run from __cxa_atexit. If this is the case then, for each priority level, + a new constructor will be entered that registers the destructors for that + level with __cxa_atexit (and there will be no destructors emitted). + It is false the method implied by ``have_ctors_dtors`` is used. + +.. hook-end + +.. function:: void TARGET_ASM_CONSTRUCTOR (rtx symbol, int priority) + + .. hook-start:TARGET_ASM_CONSTRUCTOR + + If defined, a function that outputs assembler code to arrange to call + the function referenced by :samp:`{symbol}` at initialization time. + + Assume that :samp:`{symbol}` is a ``SYMBOL_REF`` for a function taking + no arguments and with no return value. If the target supports initialization + priorities, :samp:`{priority}` is a value between 0 and ``MAX_INIT_PRIORITY`` ; + otherwise it must be ``DEFAULT_INIT_PRIORITY``. + + If this macro is not defined by the target, a suitable default will + be chosen if (1) the target supports arbitrary section names, (2) the + target defines ``CTORS_SECTION_ASM_OP``, or (3) ``USE_COLLECT2`` + is not defined. + +.. hook-end + +.. function:: void TARGET_ASM_DESTRUCTOR (rtx symbol, int priority) + + .. hook-start:TARGET_ASM_DESTRUCTOR + + This is like ``TARGET_ASM_CONSTRUCTOR`` but used for termination + functions rather than initialization functions. + +.. hook-end + +If ``TARGET_HAVE_CTORS_DTORS`` is true, the initialization routine +generated for the generated object file will have static linkage. + +If your system uses :command:`collect2` as the means of processing +constructors, then that program normally uses :command:`nm` to scan +an object file for constructor functions to be called. + +On certain kinds of systems, you can define this macro to make +:command:`collect2` work faster (and, in some cases, make it work at all): + +.. c:macro:: OBJECT_FORMAT_COFF + + Define this macro if the system uses COFF (Common Object File Format) + object files, so that :command:`collect2` can assume this format and scan + object files directly for dynamic constructor/destructor functions. + + This macro is effective only in a native compiler; :command:`collect2` as + part of a cross compiler always uses :command:`nm` for the target machine. + +.. c:macro:: REAL_NM_FILE_NAME + + Define this macro as a C string constant containing the file name to use + to execute :command:`nm`. The default is to search the path normally for + :command:`nm`. + +.. c:macro:: NM_FLAGS + + :command:`collect2` calls :command:`nm` to scan object files for static + constructors and destructors and LTO info. By default, :option:`-n` is + passed. Define ``NM_FLAGS`` to a C string constant if other options + are needed to get the same output format as GNU :command:`nm -n` + produces. + +If your system supports shared libraries and has a program to list the +dynamic dependencies of a given library or executable, you can define +these macros to enable support for running initialization and +termination functions in shared libraries: + +.. c:macro:: LDD_SUFFIX + + Define this macro to a C string constant containing the name of the program + which lists dynamic dependencies, like :command:`ldd` under SunOS 4. + +.. c:macro:: PARSE_LDD_OUTPUT (ptr) + + Define this macro to be C code that extracts filenames from the output + of the program denoted by ``LDD_SUFFIX``. :samp:`{ptr}` is a variable + of type ``char *`` that points to the beginning of a line of output + from ``LDD_SUFFIX``. If the line lists a dynamic dependency, the + code must advance :samp:`{ptr}` to the beginning of the filename on that + line. Otherwise, it must set :samp:`{ptr}` to ``NULL``. + +.. c:macro:: SHLIB_SUFFIX + + Define this macro to a C string constant containing the default shared + library extension of the target (e.g., :samp:`".so"`). :command:`collect2` + strips version information after this suffix when generating global + constructor and destructor names. This define is only needed on targets + that use :command:`collect2` to process constructors and destructors. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-and-generation-of-labels.rst b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-and-generation-of-labels.rst new file mode 100644 index 00000000000..e729ff3fab2 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-and-generation-of-labels.rst @@ -0,0 +1,586 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _label-output: + +Output and Generation of Labels +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +This is about outputting labels. + +.. index:: assemble_name + +.. c:macro:: ASM_OUTPUT_LABEL (stream, name) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` the assembler definition of a label named :samp:`{name}`. + Use the expression ``assemble_name (stream, name)`` to + output the name itself; before and after that, output the additional + assembler syntax for defining the name, and a newline. A default + definition of this macro is provided which is correct for most systems. + +.. c:macro:: ASM_OUTPUT_FUNCTION_LABEL (stream, name, decl) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` the assembler definition of a label named :samp:`{name}` of + a function. + Use the expression ``assemble_name (stream, name)`` to + output the name itself; before and after that, output the additional + assembler syntax for defining the name, and a newline. A default + definition of this macro is provided which is correct for most systems. + + If this macro is not defined, then the function name is defined in the + usual manner as a label (by means of ``ASM_OUTPUT_LABEL``). + +.. index:: assemble_name_raw + +.. c:macro:: ASM_OUTPUT_INTERNAL_LABEL (stream, name) + + Identical to ``ASM_OUTPUT_LABEL``, except that :samp:`{name}` is known + to refer to a compiler-generated label. The default definition uses + ``assemble_name_raw``, which is like ``assemble_name`` except + that it is more efficient. + +.. c:macro:: SIZE_ASM_OP + + A C string containing the appropriate assembler directive to specify the + size of a symbol, without any arguments. On systems that use ELF, the + default (in :samp:`config/elfos.h`) is :samp:`"\\t.size\\t"`; on other + systems, the default is not to define this macro. + + Define this macro only if it is correct to use the default definitions + of ``ASM_OUTPUT_SIZE_DIRECTIVE`` and ``ASM_OUTPUT_MEASURED_SIZE`` + for your system. If you need your own custom definitions of those + macros, or if you do not need explicit symbol sizes at all, do not + define this macro. + +.. c:macro:: ASM_OUTPUT_SIZE_DIRECTIVE (stream, name, size) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` a directive telling the assembler that the size of the + symbol :samp:`{name}` is :samp:`{size}`. :samp:`{size}` is a ``HOST_WIDE_INT``. + If you define ``SIZE_ASM_OP``, a default definition of this macro is + provided. + +.. c:macro:: ASM_OUTPUT_MEASURED_SIZE (stream, name) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` a directive telling the assembler to calculate the size of + the symbol :samp:`{name}` by subtracting its address from the current + address. + + If you define ``SIZE_ASM_OP``, a default definition of this macro is + provided. The default assumes that the assembler recognizes a special + :samp:`.` symbol as referring to the current address, and can calculate + the difference between this and another symbol. If your assembler does + not recognize :samp:`.` or cannot do calculations with it, you will need + to redefine ``ASM_OUTPUT_MEASURED_SIZE`` to use some other technique. + +.. c:macro:: NO_DOLLAR_IN_LABEL + + Define this macro if the assembler does not accept the character + :samp:`$` in label names. By default constructors and destructors in + G++ have :samp:`$` in the identifiers. If this macro is defined, + :samp:`.` is used instead. + +.. c:macro:: NO_DOT_IN_LABEL + + Define this macro if the assembler does not accept the character + :samp:`.` in label names. By default constructors and destructors in G++ + have names that use :samp:`.`. If this macro is defined, these names + are rewritten to avoid :samp:`.`. + +.. c:macro:: TYPE_ASM_OP + + A C string containing the appropriate assembler directive to specify the + type of a symbol, without any arguments. On systems that use ELF, the + default (in :samp:`config/elfos.h`) is :samp:`"\\t.type\\t"`; on other + systems, the default is not to define this macro. + + Define this macro only if it is correct to use the default definition of + ``ASM_OUTPUT_TYPE_DIRECTIVE`` for your system. If you need your own + custom definition of this macro, or if you do not need explicit symbol + types at all, do not define this macro. + +.. c:macro:: TYPE_OPERAND_FMT + + A C string which specifies (using ``printf`` syntax) the format of + the second operand to ``TYPE_ASM_OP``. On systems that use ELF, the + default (in :samp:`config/elfos.h`) is :samp:`"@%s"`; on other systems, + the default is not to define this macro. + + Define this macro only if it is correct to use the default definition of + ``ASM_OUTPUT_TYPE_DIRECTIVE`` for your system. If you need your own + custom definition of this macro, or if you do not need explicit symbol + types at all, do not define this macro. + +.. c:macro:: ASM_OUTPUT_TYPE_DIRECTIVE (stream, type) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` a directive telling the assembler that the type of the + symbol :samp:`{name}` is :samp:`{type}`. :samp:`{type}` is a C string; currently, + that string is always either :samp:`"function"` or :samp:`"object"`, but + you should not count on this. + + If you define ``TYPE_ASM_OP`` and ``TYPE_OPERAND_FMT``, a default + definition of this macro is provided. + +.. c:macro:: ASM_DECLARE_FUNCTION_NAME (stream, name, decl) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` any text necessary for declaring the name :samp:`{name}` of a + function which is being defined. This macro is responsible for + outputting the label definition (perhaps using + ``ASM_OUTPUT_FUNCTION_LABEL``). The argument :samp:`{decl}` is the + ``FUNCTION_DECL`` tree node representing the function. + + If this macro is not defined, then the function name is defined in the + usual manner as a label (by means of ``ASM_OUTPUT_FUNCTION_LABEL``). + + You may wish to use ``ASM_OUTPUT_TYPE_DIRECTIVE`` in the definition + of this macro. + +.. c:macro:: ASM_DECLARE_FUNCTION_SIZE (stream, name, decl) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` any text necessary for declaring the size of a function + which is being defined. The argument :samp:`{name}` is the name of the + function. The argument :samp:`{decl}` is the ``FUNCTION_DECL`` tree node + representing the function. + + If this macro is not defined, then the function size is not defined. + + You may wish to use ``ASM_OUTPUT_MEASURED_SIZE`` in the definition + of this macro. + +.. c:macro:: ASM_DECLARE_COLD_FUNCTION_NAME (stream, name, decl) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` any text necessary for declaring the name :samp:`{name}` of a + cold function partition which is being defined. This macro is responsible + for outputting the label definition (perhaps using + ``ASM_OUTPUT_FUNCTION_LABEL``). The argument :samp:`{decl}` is the + ``FUNCTION_DECL`` tree node representing the function. + + If this macro is not defined, then the cold partition name is defined in the + usual manner as a label (by means of ``ASM_OUTPUT_LABEL``). + + You may wish to use ``ASM_OUTPUT_TYPE_DIRECTIVE`` in the definition + of this macro. + +.. c:macro:: ASM_DECLARE_COLD_FUNCTION_SIZE (stream, name, decl) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` any text necessary for declaring the size of a cold function + partition which is being defined. The argument :samp:`{name}` is the name of the + cold partition of the function. The argument :samp:`{decl}` is the + ``FUNCTION_DECL`` tree node representing the function. + + If this macro is not defined, then the partition size is not defined. + + You may wish to use ``ASM_OUTPUT_MEASURED_SIZE`` in the definition + of this macro. + +.. c:macro:: ASM_DECLARE_OBJECT_NAME (stream, name, decl) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` any text necessary for declaring the name :samp:`{name}` of an + initialized variable which is being defined. This macro must output the + label definition (perhaps using ``ASM_OUTPUT_LABEL``). The argument + :samp:`{decl}` is the ``VAR_DECL`` tree node representing the variable. + + If this macro is not defined, then the variable name is defined in the + usual manner as a label (by means of ``ASM_OUTPUT_LABEL``). + + You may wish to use ``ASM_OUTPUT_TYPE_DIRECTIVE`` and/or + ``ASM_OUTPUT_SIZE_DIRECTIVE`` in the definition of this macro. + +.. function:: void TARGET_ASM_DECLARE_CONSTANT_NAME (FILE *file, const char *name, const_tree expr, HOST_WIDE_INT size) + + .. hook-start:TARGET_ASM_DECLARE_CONSTANT_NAME + + A target hook to output to the stdio stream :samp:`{file}` any text necessary + for declaring the name :samp:`{name}` of a constant which is being defined. This + target hook is responsible for outputting the label definition (perhaps using + ``assemble_label``). The argument :samp:`{exp}` is the value of the constant, + and :samp:`{size}` is the size of the constant in bytes. The :samp:`{name}` + will be an internal label. + + The default version of this target hook, define the :samp:`{name}` in the + usual manner as a label (by means of ``assemble_label``). + + You may wish to use ``ASM_OUTPUT_TYPE_DIRECTIVE`` in this target hook. + +.. hook-end + +.. c:macro:: ASM_DECLARE_REGISTER_GLOBAL (stream, decl, regno, name) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` any text necessary for claiming a register :samp:`{regno}` + for a global variable :samp:`{decl}` with name :samp:`{name}`. + + If you don't define this macro, that is equivalent to defining it to do + nothing. + +.. c:macro:: ASM_FINISH_DECLARE_OBJECT (stream, decl, toplevel, atend) + + A C statement (sans semicolon) to finish up declaring a variable name + once the compiler has processed its initializer fully and thus has had a + chance to determine the size of an array when controlled by an + initializer. This is used on systems where it's necessary to declare + something about the size of the object. + + If you don't define this macro, that is equivalent to defining it to do + nothing. + + You may wish to use ``ASM_OUTPUT_SIZE_DIRECTIVE`` and/or + ``ASM_OUTPUT_MEASURED_SIZE`` in the definition of this macro. + +.. function:: void TARGET_ASM_GLOBALIZE_LABEL (FILE *stream, const char *name) + + .. hook-start:TARGET_ASM_GLOBALIZE_LABEL + + This target hook is a function to output to the stdio stream + :samp:`{stream}` some commands that will make the label :samp:`{name}` global; + that is, available for reference from other files. + + The default implementation relies on a proper definition of + ``GLOBAL_ASM_OP``. + +.. hook-end + +.. function:: void TARGET_ASM_GLOBALIZE_DECL_NAME (FILE *stream, tree decl) + + .. hook-start:TARGET_ASM_GLOBALIZE_DECL_NAME + + This target hook is a function to output to the stdio stream + :samp:`{stream}` some commands that will make the name associated with :samp:`{decl}` + global; that is, available for reference from other files. + + The default implementation uses the TARGET_ASM_GLOBALIZE_LABEL target hook. + +.. hook-end + +.. function:: void TARGET_ASM_ASSEMBLE_UNDEFINED_DECL (FILE *stream, const char *name, const_tree decl) + + .. hook-start:TARGET_ASM_ASSEMBLE_UNDEFINED_DECL + + This target hook is a function to output to the stdio stream + :samp:`{stream}` some commands that will declare the name associated with + :samp:`{decl}` which is not defined in the current translation unit. Most + assemblers do not require anything to be output in this case. + +.. hook-end + +.. c:macro:: ASM_WEAKEN_LABEL (stream, name) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` some commands that will make the label :samp:`{name}` weak; + that is, available for reference from other files but only used if + no other definition is available. Use the expression + ``assemble_name (stream, name)`` to output the name + itself; before and after that, output the additional assembler syntax + for making that name weak, and a newline. + + If you don't define this macro or ``ASM_WEAKEN_DECL``, GCC will not + support weak symbols and you should not define the ``SUPPORTS_WEAK`` + macro. + +.. c:macro:: ASM_WEAKEN_DECL (stream, decl, name, value) + + Combines (and replaces) the function of ``ASM_WEAKEN_LABEL`` and + ``ASM_OUTPUT_WEAK_ALIAS``, allowing access to the associated function + or variable decl. If :samp:`{value}` is not ``NULL``, this C statement + should output to the stdio stream :samp:`{stream}` assembler code which + defines (equates) the weak symbol :samp:`{name}` to have the value + :samp:`{value}`. If :samp:`{value}` is ``NULL``, it should output commands + to make :samp:`{name}` weak. + +.. c:macro:: ASM_OUTPUT_WEAKREF (stream, decl, name, value) + + Outputs a directive that enables :samp:`{name}` to be used to refer to + symbol :samp:`{value}` with weak-symbol semantics. ``decl`` is the + declaration of ``name``. + +.. c:macro:: SUPPORTS_WEAK + + A preprocessor constant expression which evaluates to true if the target + supports weak symbols. + + If you don't define this macro, :samp:`defaults.h` provides a default + definition. If either ``ASM_WEAKEN_LABEL`` or ``ASM_WEAKEN_DECL`` + is defined, the default definition is :samp:`1`; otherwise, it is :samp:`0`. + +.. c:macro:: TARGET_SUPPORTS_WEAK + + A C expression which evaluates to true if the target supports weak symbols. + + If you don't define this macro, :samp:`defaults.h` provides a default + definition. The default definition is :samp:`(SUPPORTS_WEAK)`. Define + this macro if you want to control weak symbol support with a compiler + flag such as :option:`-melf`. + +.. c:macro:: MAKE_DECL_ONE_ONLY (decl) + + A C statement (sans semicolon) to mark :samp:`{decl}` to be emitted as a + public symbol such that extra copies in multiple translation units will + be discarded by the linker. Define this macro if your object file + format provides support for this concept, such as the :samp:`COMDAT` + section flags in the Microsoft Windows PE/COFF format, and this support + requires changes to :samp:`{decl}`, such as putting it in a separate section. + +.. c:macro:: SUPPORTS_ONE_ONLY + + A C expression which evaluates to true if the target supports one-only + semantics. + + If you don't define this macro, :samp:`varasm.cc` provides a default + definition. If ``MAKE_DECL_ONE_ONLY`` is defined, the default + definition is :samp:`1`; otherwise, it is :samp:`0`. Define this macro if + you want to control one-only symbol support with a compiler flag, or if + setting the ``DECL_ONE_ONLY`` flag is enough to mark a declaration to + be emitted as one-only. + +.. function:: void TARGET_ASM_ASSEMBLE_VISIBILITY (tree decl, int visibility) + + .. hook-start:TARGET_ASM_ASSEMBLE_VISIBILITY + + This target hook is a function to output to :samp:`{asm_out_file}` some + commands that will make the symbol(s) associated with :samp:`{decl}` have + hidden, protected or internal visibility as specified by :samp:`{visibility}`. + +.. hook-end + +.. c:macro:: TARGET_WEAK_NOT_IN_ARCHIVE_TOC + + A C expression that evaluates to true if the target's linker expects + that weak symbols do not appear in a static archive's table of contents. + The default is ``0``. + + Leaving weak symbols out of an archive's table of contents means that, + if a symbol will only have a definition in one translation unit and + will have undefined references from other translation units, that + symbol should not be weak. Defining this macro to be nonzero will + thus have the effect that certain symbols that would normally be weak + (explicit template instantiations, and vtables for polymorphic classes + with noninline key methods) will instead be nonweak. + + The C++ ABI requires this macro to be zero. Define this macro for + targets where full C++ ABI compliance is impossible and where linker + restrictions require weak symbols to be left out of a static archive's + table of contents. + +.. c:macro:: ASM_OUTPUT_EXTERNAL (stream, decl, name) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` any text necessary for declaring the name of an external + symbol named :samp:`{name}` which is referenced in this compilation but + not defined. The value of :samp:`{decl}` is the tree node for the + declaration. + + This macro need not be defined if it does not need to output anything. + The GNU assembler and most Unix assemblers don't require anything. + +.. function:: void TARGET_ASM_EXTERNAL_LIBCALL (rtx symref) + + .. hook-start:TARGET_ASM_EXTERNAL_LIBCALL + + This target hook is a function to output to :samp:`{asm_out_file}` an assembler + pseudo-op to declare a library function name external. The name of the + library function is given by :samp:`{symref}`, which is a ``symbol_ref``. + +.. hook-end + +.. function:: void TARGET_ASM_MARK_DECL_PRESERVED (const char *symbol) + + .. hook-start:TARGET_ASM_MARK_DECL_PRESERVED + + This target hook is a function to output to :samp:`{asm_out_file}` an assembler + directive to annotate :samp:`{symbol}` as used. The Darwin target uses the + .no_dead_code_strip directive. + +.. hook-end + +.. c:macro:: ASM_OUTPUT_LABELREF (stream, name) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` a reference in assembler syntax to a label named + :samp:`{name}`. This should add :samp:`_` to the front of the name, if that + is customary on your operating system, as it is in most Berkeley Unix + systems. This macro is used in ``assemble_name``. + +.. function:: tree TARGET_MANGLE_ASSEMBLER_NAME (const char *name) + + .. hook-start:TARGET_MANGLE_ASSEMBLER_NAME + + Given a symbol :samp:`{name}`, perform same mangling as ``varasm.cc`` 's + ``assemble_name``, but in memory rather than to a file stream, returning + result as an ``IDENTIFIER_NODE``. Required for correct LTO symtabs. The + default implementation calls the ``TARGET_STRIP_NAME_ENCODING`` hook and + then prepends the ``USER_LABEL_PREFIX``, if any. + +.. hook-end + +.. c:macro:: ASM_OUTPUT_SYMBOL_REF (stream, sym) + + A C statement (sans semicolon) to output a reference to + ``SYMBOL_REF`` :samp:`{sym}`. If not defined, ``assemble_name`` + will be used to output the name of the symbol. This macro may be used + to modify the way a symbol is referenced depending on information + encoded by ``TARGET_ENCODE_SECTION_INFO``. + +.. c:macro:: ASM_OUTPUT_LABEL_REF (stream, buf) + + A C statement (sans semicolon) to output a reference to :samp:`{buf}`, the + result of ``ASM_GENERATE_INTERNAL_LABEL``. If not defined, + ``assemble_name`` will be used to output the name of the symbol. + This macro is not used by ``output_asm_label``, or the ``%l`` + specifier that calls it; the intention is that this macro should be set + when it is necessary to output a label differently when its address is + being taken. + +.. function:: void TARGET_ASM_INTERNAL_LABEL (FILE *stream, const char *prefix, unsigned long labelno) + + .. hook-start:TARGET_ASM_INTERNAL_LABEL + + A function to output to the stdio stream :samp:`{stream}` a label whose + name is made from the string :samp:`{prefix}` and the number :samp:`{labelno}`. + + It is absolutely essential that these labels be distinct from the labels + used for user-level functions and variables. Otherwise, certain programs + will have name conflicts with internal labels. + + It is desirable to exclude internal labels from the symbol table of the + object file. Most assemblers have a naming convention for labels that + should be excluded; on many systems, the letter :samp:`L` at the + beginning of a label has this effect. You should find out what + convention your system uses, and follow it. + + The default version of this function utilizes ``ASM_GENERATE_INTERNAL_LABEL``. + +.. hook-end + +.. c:macro:: ASM_OUTPUT_DEBUG_LABEL (stream, prefix, num) + + A C statement to output to the stdio stream :samp:`{stream}` a debug info + label whose name is made from the string :samp:`{prefix}` and the number + :samp:`{num}`. This is useful for VLIW targets, where debug info labels + may need to be treated differently than branch target labels. On some + systems, branch target labels must be at the beginning of instruction + bundles, but debug info labels can occur in the middle of instruction + bundles. + + If this macro is not defined, then ``(*targetm.asm_out.internal_label)`` will be + used. + +.. c:macro:: ASM_GENERATE_INTERNAL_LABEL (string, prefix, num) + + A C statement to store into the string :samp:`{string}` a label whose name + is made from the string :samp:`{prefix}` and the number :samp:`{num}`. + + This string, when output subsequently by ``assemble_name``, should + produce the output that ``(*targetm.asm_out.internal_label)`` would produce + with the same :samp:`{prefix}` and :samp:`{num}`. + + If the string begins with :samp:`*`, then ``assemble_name`` will + output the rest of the string unchanged. It is often convenient for + ``ASM_GENERATE_INTERNAL_LABEL`` to use :samp:`*` in this way. If the + string doesn't start with :samp:`*`, then ``ASM_OUTPUT_LABELREF`` gets + to output the string, and may change it. (Of course, + ``ASM_OUTPUT_LABELREF`` is also part of your machine description, so + you should know what it does on your machine.) + +.. c:macro:: ASM_FORMAT_PRIVATE_NAME (outvar, name, number) + + A C expression to assign to :samp:`{outvar}` (which is a variable of type + ``char *``) a newly allocated string made from the string + :samp:`{name}` and the number :samp:`{number}`, with some suitable punctuation + added. Use ``alloca`` to get space for the string. + + The string will be used as an argument to ``ASM_OUTPUT_LABELREF`` to + produce an assembler label for an internal static variable whose name is + :samp:`{name}`. Therefore, the string must be such as to result in valid + assembler code. The argument :samp:`{number}` is different each time this + macro is executed; it prevents conflicts between similarly-named + internal static variables in different scopes. + + Ideally this string should not be a valid C identifier, to prevent any + conflict with the user's own symbols. Most assemblers allow periods + or percent signs in assembler symbols; putting at least one of these + between the name and the number will suffice. + + If this macro is not defined, a default definition will be provided + which is correct for most systems. + +.. c:macro:: ASM_OUTPUT_DEF (stream, name, value) + + A C statement to output to the stdio stream :samp:`{stream}` assembler code + which defines (equates) the symbol :samp:`{name}` to have the value :samp:`{value}`. + + .. index:: SET_ASM_OP + + If ``SET_ASM_OP`` is defined, a default definition is provided which is + correct for most systems. + +.. c:macro:: ASM_OUTPUT_DEF_FROM_DECLS (stream, decl_of_name, decl_of_value) + + A C statement to output to the stdio stream :samp:`{stream}` assembler code + which defines (equates) the symbol whose tree node is :samp:`{decl_of_name}` + to have the value of the tree node :samp:`{decl_of_value}`. This macro will + be used in preference to :samp:`ASM_OUTPUT_DEF` if it is defined and if + the tree nodes are available. + + .. index:: SET_ASM_OP + + If ``SET_ASM_OP`` is defined, a default definition is provided which is + correct for most systems. + +.. c:macro:: TARGET_DEFERRED_OUTPUT_DEFS (decl_of_name, decl_of_value) + + A C statement that evaluates to true if the assembler code which defines + (equates) the symbol whose tree node is :samp:`{decl_of_name}` to have the value + of the tree node :samp:`{decl_of_value}` should be emitted near the end of the + current compilation unit. The default is to not defer output of defines. + This macro affects defines output by :samp:`ASM_OUTPUT_DEF` and + :samp:`ASM_OUTPUT_DEF_FROM_DECLS`. + +.. c:macro:: ASM_OUTPUT_WEAK_ALIAS (stream, name, value) + + A C statement to output to the stdio stream :samp:`{stream}` assembler code + which defines (equates) the weak symbol :samp:`{name}` to have the value + :samp:`{value}`. If :samp:`{value}` is ``NULL``, it defines :samp:`{name}` as + an undefined weak symbol. + + Define this macro if the target only supports weak aliases; define + ``ASM_OUTPUT_DEF`` instead if possible. + +.. c:macro:: OBJC_GEN_METHOD_LABEL (buf, is_inst, class_name, cat_name, sel_name) + + Define this macro to override the default assembler names used for + Objective-C methods. + + The default name is a unique method number followed by the name of the + class (e.g. :samp:`_1_Foo`). For methods in categories, the name of + the category is also included in the assembler name (e.g. + :samp:`_1_Foo_Bar`). + + These names are safe on most systems, but make debugging difficult since + the method's selector is not present in the name. Therefore, particular + systems define other ways of computing names. + + :samp:`{buf}` is an expression of type ``char *`` which gives you a + buffer in which to store the name; its length is as long as + :samp:`{class_name}`, :samp:`{cat_name}` and :samp:`{sel_name}` put together, plus + 50 characters extra. + + The argument :samp:`{is_inst}` specifies whether the method is an instance + method or a class method; :samp:`{class_name}` is the name of the class; + :samp:`{cat_name}` is the name of the category (or ``NULL`` if the method is not + in a category); and :samp:`{sel_name}` is the name of the selector. + + On systems where the assembler can handle quoted names, you can use this + macro to provide more human-readable names. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-assembler-instructions.rst b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-assembler-instructions.rst new file mode 100644 index 00000000000..66a32f5f888 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-assembler-instructions.rst @@ -0,0 +1,252 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _instruction-output: + +Output of Assembler Instructions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +This describes assembler instruction output. + +.. c:macro:: REGISTER_NAMES + + A C initializer containing the assembler's names for the machine + registers, each one as a C string constant. This is what translates + register numbers in the compiler into assembler language. + +.. c:macro:: ADDITIONAL_REGISTER_NAMES + + If defined, a C initializer for an array of structures containing a name + and a register number. This macro defines additional names for hard + registers, thus allowing the ``asm`` option in declarations to refer + to registers using alternate names. + +.. c:macro:: OVERLAPPING_REGISTER_NAMES + + If defined, a C initializer for an array of structures containing a + name, a register number and a count of the number of consecutive + machine registers the name overlaps. This macro defines additional + names for hard registers, thus allowing the ``asm`` option in + declarations to refer to registers using alternate names. Unlike + ``ADDITIONAL_REGISTER_NAMES``, this macro should be used when the + register name implies multiple underlying registers. + + This macro should be used when it is important that a clobber in an + ``asm`` statement clobbers all the underlying values implied by the + register name. For example, on ARM, clobbering the double-precision + VFP register 'd0' implies clobbering both single-precision registers + 's0' and 's1'. + +.. c:macro:: ASM_OUTPUT_OPCODE (stream, ptr) + + Define this macro if you are using an unusual assembler that + requires different names for the machine instructions. + + The definition is a C statement or statements which output an + assembler instruction opcode to the stdio stream :samp:`{stream}`. The + macro-operand :samp:`{ptr}` is a variable of type ``char *`` which + points to the opcode name in its 'internal' form---the form that is + written in the machine description. The definition should output the + opcode name to :samp:`{stream}`, performing any translation you desire, and + increment the variable :samp:`{ptr}` to point at the end of the opcode + so that it will not be output twice. + + In fact, your macro definition may process less than the entire opcode + name, or more than the opcode name; but if you want to process text + that includes :samp:`%`-sequences to substitute operands, you must take + care of the substitution yourself. Just be sure to increment + :samp:`{ptr}` over whatever text should not be output normally. + + .. index:: recog_data.operand + + If you need to look at the operand values, they can be found as the + elements of ``recog_data.operand``. + + If the macro definition does nothing, the instruction is output + in the usual way. + +.. c:macro:: FINAL_PRESCAN_INSN (insn, opvec, noperands) + + If defined, a C statement to be executed just prior to the output of + assembler code for :samp:`{insn}`, to modify the extracted operands so + they will be output differently. + + Here the argument :samp:`{opvec}` is the vector containing the operands + extracted from :samp:`{insn}`, and :samp:`{noperands}` is the number of + elements of the vector which contain meaningful data for this insn. + The contents of this vector are what will be used to convert the insn + template into assembler code, so you can change the assembler output + by changing the contents of the vector. + + This macro is useful when various assembler syntaxes share a single + file of instruction patterns; by defining this macro differently, you + can cause a large class of instructions to be output differently (such + as with rearranged operands). Naturally, variations in assembler + syntax affecting individual insn patterns ought to be handled by + writing conditional output routines in those patterns. + + If this macro is not defined, it is equivalent to a null statement. + +.. function:: void TARGET_ASM_FINAL_POSTSCAN_INSN (FILE *file, rtx_insn *insn, rtx *opvec, int noperands) + + .. hook-start:TARGET_ASM_FINAL_POSTSCAN_INSN + + If defined, this target hook is a function which is executed just after the + output of assembler code for :samp:`{insn}`, to change the mode of the assembler + if necessary. + + Here the argument :samp:`{opvec}` is the vector containing the operands + extracted from :samp:`{insn}`, and :samp:`{noperands}` is the number of + elements of the vector which contain meaningful data for this insn. + The contents of this vector are what was used to convert the insn + template into assembler code, so you can change the assembler mode + by checking the contents of the vector. + +.. hook-end + +.. c:macro:: PRINT_OPERAND (stream, x, code) + + A C compound statement to output to stdio stream :samp:`{stream}` the + assembler syntax for an instruction operand :samp:`{x}`. :samp:`{x}` is an + RTL expression. + + :samp:`{code}` is a value that can be used to specify one of several ways + of printing the operand. It is used when identical operands must be + printed differently depending on the context. :samp:`{code}` comes from + the :samp:`%` specification that was used to request printing of the + operand. If the specification was just :samp:`%{digit}` then + :samp:`{code}` is 0; if the specification was :samp:`%{ltr}{digit}` then :samp:`{code}` is the ASCII code for :samp:`{ltr}`. + + .. index:: reg_names + + If :samp:`{x}` is a register, this macro should print the register's name. + The names can be found in an array ``reg_names`` whose type is + ``char *[]``. ``reg_names`` is initialized from + ``REGISTER_NAMES``. + + When the machine description has a specification :samp:`%{punct}` + (a :samp:`%` followed by a punctuation character), this macro is called + with a null pointer for :samp:`{x}` and the punctuation character for + :samp:`{code}`. + +.. c:macro:: PRINT_OPERAND_PUNCT_VALID_P (code) + + A C expression which evaluates to true if :samp:`{code}` is a valid + punctuation character for use in the ``PRINT_OPERAND`` macro. If + ``PRINT_OPERAND_PUNCT_VALID_P`` is not defined, it means that no + punctuation characters (except for the standard one, :samp:`%`) are used + in this way. + +.. c:macro:: PRINT_OPERAND_ADDRESS (stream, x) + + A C compound statement to output to stdio stream :samp:`{stream}` the + assembler syntax for an instruction operand that is a memory reference + whose address is :samp:`{x}`. :samp:`{x}` is an RTL expression. + + .. index:: TARGET_ENCODE_SECTION_INFO usage + + On some machines, the syntax for a symbolic address depends on the + section that the address refers to. On these machines, define the hook + ``TARGET_ENCODE_SECTION_INFO`` to store the information into the + ``symbol_ref``, and then check for it here. See :ref:`assembler-format`. + +.. index:: dbr_sequence_length + +.. c:macro:: DBR_OUTPUT_SEQEND (file) + + A C statement, to be executed after all slot-filler instructions have + been output. If necessary, call ``dbr_sequence_length`` to + determine the number of slots filled in a sequence (zero if not + currently outputting a sequence), to decide how many no-ops to output, + or whatever. + + Don't define this macro if it has nothing to do, but it is helpful in + reading assembly output if the extent of the delay sequence is made + explicit (e.g. with white space). + +.. index:: final_sequence + +Note that output routines for instructions with delay slots must be +prepared to deal with not being output as part of a sequence +(i.e. when the scheduling pass is not run, or when no slot fillers could be +found.) The variable ``final_sequence`` is null when not +processing a sequence, otherwise it contains the ``sequence`` rtx +being output. + +.. index:: asm_fprintf + +.. c:macro:: REGISTER_PREFIX + LOCAL_LABEL_PREFIX + USER_LABEL_PREFIX + IMMEDIATE_PREFIX + + If defined, C string expressions to be used for the :samp:`%R`, :samp:`%L`, + :samp:`%U`, and :samp:`%I` options of ``asm_fprintf`` (see + :samp:`final.cc`). These are useful when a single :samp:`md` file must + support multiple assembler formats. In that case, the various :samp:`tm.h` + files can define these macros differently. + +.. c:macro:: ASM_FPRINTF_EXTENSIONS (file, argptr, format) + + If defined this macro should expand to a series of ``case`` + statements which will be parsed inside the ``switch`` statement of + the ``asm_fprintf`` function. This allows targets to define extra + printf formats which may useful when generating their assembler + statements. Note that uppercase letters are reserved for future + generic extensions to asm_fprintf, and so are not available to target + specific code. The output file is given by the parameter :samp:`{file}`. + The varargs input pointer is :samp:`{argptr}` and the rest of the format + string, starting the character after the one that is being switched + upon, is pointed to by :samp:`{format}`. + +.. c:macro:: ASSEMBLER_DIALECT + + If your target supports multiple dialects of assembler language (such as + different opcodes), define this macro as a C expression that gives the + numeric index of the assembler language dialect to use, with zero as the + first variant. + + If this macro is defined, you may use constructs of the form + + .. code-block:: c++ + + {option0|option1|option2...} + + in the output templates of patterns (see :ref:`output-template`) or in the + first argument of ``asm_fprintf``. This construct outputs + :samp:`option0`, :samp:`option1`, :samp:`option2`, etc., if the value of + ``ASSEMBLER_DIALECT`` is zero, one, two, etc. Any special characters + within these strings retain their usual meaning. If there are fewer + alternatives within the braces than the value of + ``ASSEMBLER_DIALECT``, the construct outputs nothing. If it's needed + to print curly braces or :samp:`|` character in assembler output directly, + :samp:`%{`, :samp:`%}` and :samp:`%|` can be used. + + If you do not define this macro, the characters :samp:`{`, :samp:`|` and + :samp:`}` do not have any special meaning when used in templates or + operands to ``asm_fprintf``. + + Define the macros ``REGISTER_PREFIX``, ``LOCAL_LABEL_PREFIX``, + ``USER_LABEL_PREFIX`` and ``IMMEDIATE_PREFIX`` if you can express + the variations in assembler language syntax with that mechanism. Define + ``ASSEMBLER_DIALECT`` and use the :samp:`{option0|option1}` syntax + if the syntax variant are larger and involve such things as different + opcodes or operand order. + +.. c:macro:: ASM_OUTPUT_REG_PUSH (stream, regno) + + A C expression to output to :samp:`{stream}` some assembler code + which will push hard register number :samp:`{regno}` onto the stack. + The code need not be optimal, since this macro is used only when + profiling. + +.. c:macro:: ASM_OUTPUT_REG_POP (stream, regno) + + A C expression to output to :samp:`{stream}` some assembler code + which will pop hard register number :samp:`{regno}` off of the stack. + The code need not be optimal, since this macro is used only when + profiling. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-data.rst b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-data.rst new file mode 100644 index 00000000000..2a0bfce9b48 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-data.rst @@ -0,0 +1,191 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _data-output: + +Output of Data +^^^^^^^^^^^^^^ + +.. c:var:: const char * TARGET_ASM_BYTE_OP + + .. hook-start:TARGET_ASM_BYTE_OP + + These hooks specify assembly directives for creating certain kinds + of integer object. The ``TARGET_ASM_BYTE_OP`` directive creates a + byte-sized object, the ``TARGET_ASM_ALIGNED_HI_OP`` one creates an + aligned two-byte object, and so on. Any of the hooks may be + ``NULL``, indicating that no suitable directive is available. + + The compiler will print these strings at the start of a new line, + followed immediately by the object's initial value. In most cases, + the string should contain a tab, a pseudo-op, and then another tab. + +.. hook-end + +.. function:: bool TARGET_ASM_INTEGER (rtx x, unsigned int size, int aligned_p) + + .. hook-start:TARGET_ASM_INTEGER + + The ``assemble_integer`` function uses this hook to output an + integer object. :samp:`{x}` is the object's value, :samp:`{size}` is its size + in bytes and :samp:`{aligned_p}` indicates whether it is aligned. The + function should return ``true`` if it was able to output the + object. If it returns false, ``assemble_integer`` will try to + split the object into smaller parts. + + The default implementation of this hook will use the + ``TARGET_ASM_BYTE_OP`` family of strings, returning ``false`` + when the relevant string is ``NULL``. + +.. hook-end + +.. function:: void TARGET_ASM_DECL_END (void) + + .. hook-start:TARGET_ASM_DECL_END + + Define this hook if the target assembler requires a special marker to + terminate an initialized variable declaration. + +.. hook-end + +.. function:: bool TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA (FILE *file, rtx x) + + .. hook-start:TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA + + A target hook to recognize :samp:`{rtx}` patterns that ``output_addr_const`` + can't deal with, and output assembly code to :samp:`{file}` corresponding to + the pattern :samp:`{x}`. This may be used to allow machine-dependent + ``UNSPEC`` s to appear within constants. + + If target hook fails to recognize a pattern, it must return ``false``, + so that a standard error message is printed. If it prints an error message + itself, by calling, for example, ``output_operand_lossage``, it may just + return ``true``. + +.. hook-end + +.. c:macro:: ASM_OUTPUT_ASCII (stream, ptr, len) + + A C statement to output to the stdio stream :samp:`{stream}` an assembler + instruction to assemble a string constant containing the :samp:`{len}` + bytes at :samp:`{ptr}`. :samp:`{ptr}` will be a C expression of type + ``char *`` and :samp:`{len}` a C expression of type ``int``. + + If the assembler has a ``.ascii`` pseudo-op as found in the + Berkeley Unix assembler, do not define the macro + ``ASM_OUTPUT_ASCII``. + +.. c:macro:: ASM_OUTPUT_FDESC (stream, decl, n) + + A C statement to output word :samp:`{n}` of a function descriptor for + :samp:`{decl}`. This must be defined if ``TARGET_VTABLE_USES_DESCRIPTORS`` + is defined, and is otherwise unused. + +.. c:macro:: CONSTANT_POOL_BEFORE_FUNCTION + + You may define this macro as a C expression. You should define the + expression to have a nonzero value if GCC should output the constant + pool for a function before the code for the function, or a zero value if + GCC should output the constant pool after the function. If you do + not define this macro, the usual case, GCC will output the constant + pool before the function. + +.. c:macro:: ASM_OUTPUT_POOL_PROLOGUE (file, funname, fundecl, size) + + A C statement to output assembler commands to define the start of the + constant pool for a function. :samp:`{funname}` is a string giving + the name of the function. Should the return type of the function + be required, it can be obtained via :samp:`{fundecl}`. :samp:`{size}` + is the size, in bytes, of the constant pool that will be written + immediately after this call. + + If no constant-pool prefix is required, the usual case, this macro need + not be defined. + +.. c:macro:: ASM_OUTPUT_SPECIAL_POOL_ENTRY (file, x, mode, align, labelno, jumpto) + + A C statement (with or without semicolon) to output a constant in the + constant pool, if it needs special treatment. (This macro need not do + anything for RTL expressions that can be output normally.) + + The argument :samp:`{file}` is the standard I/O stream to output the + assembler code on. :samp:`{x}` is the RTL expression for the constant to + output, and :samp:`{mode}` is the machine mode (in case :samp:`{x}` is a + :samp:`const_int`). :samp:`{align}` is the required alignment for the value + :samp:`{x}` ; you should output an assembler directive to force this much + alignment. + + The argument :samp:`{labelno}` is a number to use in an internal label for + the address of this pool entry. The definition of this macro is + responsible for outputting the label definition at the proper place. + Here is how to do this: + + .. code-block:: c++ + + (*targetm.asm_out.internal_label) (file, "LC", labelno); + + When you output a pool entry specially, you should end with a + ``goto`` to the label :samp:`{jumpto}`. This will prevent the same pool + entry from being output a second time in the usual manner. + + You need not define this macro if it would do nothing. + +.. c:macro:: ASM_OUTPUT_POOL_EPILOGUE (file funname, fundecl size) + + A C statement to output assembler commands to at the end of the constant + pool for a function. :samp:`{funname}` is a string giving the name of the + function. Should the return type of the function be required, you can + obtain it via :samp:`{fundecl}`. :samp:`{size}` is the size, in bytes, of the + constant pool that GCC wrote immediately before this call. + + If no constant-pool epilogue is required, the usual case, you need not + define this macro. + +.. c:macro:: IS_ASM_LOGICAL_LINE_SEPARATOR (C, STR) + + Define this macro as a C expression which is nonzero if :samp:`{C}` is + used as a logical line separator by the assembler. :samp:`{STR}` points + to the position in the string where :samp:`{C}` was found; this can be used if + a line separator uses multiple characters. + + If you do not define this macro, the default is that only + the character :samp:`;` is treated as a logical line separator. + +.. c:var:: const char * TARGET_ASM_OPEN_PAREN + +.. c:var:: const char * TARGET_ASM_CLOSE_PAREN + + .. hook-start:TARGET_ASM_OPEN_PAREN + + These target hooks are C string constants, describing the syntax in the + assembler for grouping arithmetic expressions. If not overridden, they + default to normal parentheses, which is correct for most assemblers. + +.. hook-end + +These macros are provided by :samp:`real.h` for writing the definitions +of ``ASM_OUTPUT_DOUBLE`` and the like: + +.. c:macro:: REAL_VALUE_TO_TARGET_SINGLE (x, l) + REAL_VALUE_TO_TARGET_DOUBLE (x, l) + REAL_VALUE_TO_TARGET_LONG_DOUBLE (x, l) + REAL_VALUE_TO_TARGET_DECIMAL32 (x, l) + REAL_VALUE_TO_TARGET_DECIMAL64 (x, l) + REAL_VALUE_TO_TARGET_DECIMAL128 (x, l) + + These translate :samp:`{x}`, of type ``REAL_VALUE_TYPE``, to the + target's floating point representation, and store its bit pattern in + the variable :samp:`{l}`. For ``REAL_VALUE_TO_TARGET_SINGLE`` and + ``REAL_VALUE_TO_TARGET_DECIMAL32``, this variable should be a + simple ``long int``. For the others, it should be an array of + ``long int``. The number of elements in this array is determined + by the size of the desired target floating point data type: 32 bits of + it go in each ``long int`` array element. Each array element holds + 32 bits of the result, even if ``long int`` is wider than 32 bits + on the host machine. + + The array element values are designed so that you can print them out + using ``fprintf`` in the order they should appear in the target + machine's memory. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-dispatch-tables.rst b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-dispatch-tables.rst new file mode 100644 index 00000000000..a378099bf75 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-dispatch-tables.rst @@ -0,0 +1,171 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _dispatch-tables: + +Output of Dispatch Tables +^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +This concerns dispatch tables. + +.. index:: dispatch table + +.. c:macro:: ASM_OUTPUT_ADDR_DIFF_ELT (stream, body, value, rel) + + A C statement to output to the stdio stream :samp:`{stream}` an assembler + pseudo-instruction to generate a difference between two labels. + :samp:`{value}` and :samp:`{rel}` are the numbers of two internal labels. The + definitions of these labels are output using + ``(*targetm.asm_out.internal_label)``, and they must be printed in the same + way here. For example, + + .. code-block:: c++ + + fprintf (stream, "\t.word L%d-L%d\n", + value, rel) + + You must provide this macro on machines where the addresses in a + dispatch table are relative to the table's own address. If defined, GCC + will also use this macro on all machines when producing PIC. + :samp:`{body}` is the body of the ``ADDR_DIFF_VEC`` ; it is provided so that the + mode and flags can be read. + +.. c:macro:: ASM_OUTPUT_ADDR_VEC_ELT (stream, value) + + This macro should be provided on machines where the addresses + in a dispatch table are absolute. + + The definition should be a C statement to output to the stdio stream + :samp:`{stream}` an assembler pseudo-instruction to generate a reference to + a label. :samp:`{value}` is the number of an internal label whose + definition is output using ``(*targetm.asm_out.internal_label)``. + For example, + + .. code-block:: c++ + + fprintf (stream, "\t.word L%d\n", value) + +.. c:macro:: ASM_OUTPUT_CASE_LABEL (stream, prefix, num, table) + + Define this if the label before a jump-table needs to be output + specially. The first three arguments are the same as for + ``(*targetm.asm_out.internal_label)`` ; the fourth argument is the + jump-table which follows (a ``jump_table_data`` containing an + ``addr_vec`` or ``addr_diff_vec``). + + This feature is used on system V to output a ``swbeg`` statement + for the table. + + If this macro is not defined, these labels are output with + ``(*targetm.asm_out.internal_label)``. + +.. c:macro:: ASM_OUTPUT_CASE_END (stream, num, table) + + Define this if something special must be output at the end of a + jump-table. The definition should be a C statement to be executed + after the assembler code for the table is written. It should write + the appropriate code to stdio stream :samp:`{stream}`. The argument + :samp:`{table}` is the jump-table insn, and :samp:`{num}` is the label-number + of the preceding label. + + If this macro is not defined, nothing special is output at the end of + the jump-table. + +.. function:: void TARGET_ASM_POST_CFI_STARTPROC (FILE *, tree) + + .. hook-start:TARGET_ASM_POST_CFI_STARTPROC + + This target hook is used to emit assembly strings required by the target + after the .cfi_startproc directive. The first argument is the file stream to + write the strings to and the second argument is the function's declaration. The + expected use is to add more .cfi_\* directives. + + The default is to not output any assembly strings. + +.. hook-end + +.. function:: void TARGET_ASM_EMIT_UNWIND_LABEL (FILE *stream, tree decl, int for_eh, int empty) + + .. hook-start:TARGET_ASM_EMIT_UNWIND_LABEL + + This target hook emits a label at the beginning of each FDE. It + should be defined on targets where FDEs need special labels, and it + should write the appropriate label, for the FDE associated with the + function declaration :samp:`{decl}`, to the stdio stream :samp:`{stream}`. + The third argument, :samp:`{for_eh}`, is a boolean: true if this is for an + exception table. The fourth argument, :samp:`{empty}`, is a boolean: + true if this is a placeholder label for an omitted FDE. + + The default is that FDEs are not given nonlocal labels. + +.. hook-end + +.. function:: void TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL (FILE *stream) + + .. hook-start:TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL + + This target hook emits a label at the beginning of the exception table. + It should be defined on targets where it is desirable for the table + to be broken up according to function. + + The default is that no label is emitted. + +.. hook-end + +.. function:: void TARGET_ASM_EMIT_EXCEPT_PERSONALITY (rtx personality) + + .. hook-start:TARGET_ASM_EMIT_EXCEPT_PERSONALITY + + If the target implements ``TARGET_ASM_UNWIND_EMIT``, this hook may be + used to emit a directive to install a personality hook into the unwind + info. This hook should not be used if dwarf2 unwind info is used. + +.. hook-end + +.. function:: void TARGET_ASM_UNWIND_EMIT (FILE *stream, rtx_insn *insn) + + .. hook-start:TARGET_ASM_UNWIND_EMIT + + This target hook emits assembly directives required to unwind the + given instruction. This is only used when ``TARGET_EXCEPT_UNWIND_INFO`` + returns ``UI_TARGET``. + +.. hook-end + +.. function:: rtx TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT (rtx origsymbol, bool pubvis) + + .. hook-start:TARGET_ASM_MAKE_EH_SYMBOL_INDIRECT + + If necessary, modify personality and LSDA references to handle indirection. + The original symbol is in ``origsymbol`` and if ``pubvis`` is true + the symbol is visible outside the TU. + +.. hook-end + +.. c:var:: bool TARGET_ASM_UNWIND_EMIT_BEFORE_INSN + + .. hook-start:TARGET_ASM_UNWIND_EMIT_BEFORE_INSN + + True if the ``TARGET_ASM_UNWIND_EMIT`` hook should be called before + the assembly for :samp:`{insn}` has been emitted, false if the hook should + be called afterward. + +.. hook-end + +.. function:: bool TARGET_ASM_SHOULD_RESTORE_CFA_STATE (void) + + .. hook-start:TARGET_ASM_SHOULD_RESTORE_CFA_STATE + + For DWARF-based unwind frames, two CFI instructions provide for save and + restore of register state. GCC maintains the current frame address (CFA) + separately from the register bank but the unwinder in libgcc preserves this + state along with the registers (and this is expected by the code that writes + the unwind frames). This hook allows the target to specify that the CFA data + is not saved/restored along with the registers by the target unwinder so that + suitable additional instructions should be emitted to restore it. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-uninitialized-variables.rst b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-uninitialized-variables.rst new file mode 100644 index 00000000000..0c5e9244175 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/output-of-uninitialized-variables.rst @@ -0,0 +1,105 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _uninitialized-data: + +Output of Uninitialized Variables +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Each of the macros in this section is used to do the whole job of +outputting a single uninitialized variable. + +.. c:macro:: ASM_OUTPUT_COMMON (stream, name, size, rounded) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` the assembler definition of a common-label named + :samp:`{name}` whose size is :samp:`{size}` bytes. The variable :samp:`{rounded}` + is the size rounded up to whatever alignment the caller wants. It is + possible that :samp:`{size}` may be zero, for instance if a struct with no + other member than a zero-length array is defined. In this case, the + backend must output a symbol definition that allocates at least one + byte, both so that the address of the resulting object does not compare + equal to any other, and because some object formats cannot even express + the concept of a zero-sized common symbol, as that is how they represent + an ordinary undefined external. + + Use the expression ``assemble_name (stream, name)`` to + output the name itself; before and after that, output the additional + assembler syntax for defining the name, and a newline. + + This macro controls how the assembler definitions of uninitialized + common global variables are output. + +.. c:macro:: ASM_OUTPUT_ALIGNED_COMMON (stream, name, size, alignment) + + Like ``ASM_OUTPUT_COMMON`` except takes the required alignment as a + separate, explicit argument. If you define this macro, it is used in + place of ``ASM_OUTPUT_COMMON``, and gives you more flexibility in + handling the required alignment of the variable. The alignment is specified + as the number of bits. + +.. c:macro:: ASM_OUTPUT_ALIGNED_DECL_COMMON (stream, decl, name, size, alignment) + + Like ``ASM_OUTPUT_ALIGNED_COMMON`` except that :samp:`{decl}` of the + variable to be output, if there is one, or ``NULL_TREE`` if there + is no corresponding variable. If you define this macro, GCC will use it + in place of both ``ASM_OUTPUT_COMMON`` and + ``ASM_OUTPUT_ALIGNED_COMMON``. Define this macro when you need to see + the variable's decl in order to chose what to output. + +.. c:macro:: ASM_OUTPUT_ALIGNED_BSS (stream, decl, name, size, alignment) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` the assembler definition of uninitialized global :samp:`{decl}` named + :samp:`{name}` whose size is :samp:`{size}` bytes. The variable :samp:`{alignment}` + is the alignment specified as the number of bits. + + Try to use function ``asm_output_aligned_bss`` defined in file + :samp:`varasm.cc` when defining this macro. If unable, use the expression + ``assemble_name (stream, name)`` to output the name itself; + before and after that, output the additional assembler syntax for defining + the name, and a newline. + + There are two ways of handling global BSS. One is to define this macro. + The other is to have ``TARGET_ASM_SELECT_SECTION`` return a + switchable BSS section (see :ref:`target_have_switchable_bss_sections`). + You do not need to do both. + + Some languages do not have ``common`` data, and require a + non-common form of global BSS in order to handle uninitialized globals + efficiently. C++ is one example of this. However, if the target does + not support global BSS, the front end may choose to make globals + common in order to save space in the object file. + +.. c:macro:: ASM_OUTPUT_LOCAL (stream, name, size, rounded) + + A C statement (sans semicolon) to output to the stdio stream + :samp:`{stream}` the assembler definition of a local-common-label named + :samp:`{name}` whose size is :samp:`{size}` bytes. The variable :samp:`{rounded}` + is the size rounded up to whatever alignment the caller wants. + + Use the expression ``assemble_name (stream, name)`` to + output the name itself; before and after that, output the additional + assembler syntax for defining the name, and a newline. + + This macro controls how the assembler definitions of uninitialized + static variables are output. + +.. c:macro:: ASM_OUTPUT_ALIGNED_LOCAL (stream, name, size, alignment) + + Like ``ASM_OUTPUT_LOCAL`` except takes the required alignment as a + separate, explicit argument. If you define this macro, it is used in + place of ``ASM_OUTPUT_LOCAL``, and gives you more flexibility in + handling the required alignment of the variable. The alignment is specified + as the number of bits. + +.. c:macro:: ASM_OUTPUT_ALIGNED_DECL_LOCAL (stream, decl, name, size, alignment) + + Like ``ASM_OUTPUT_ALIGNED_LOCAL`` except that :samp:`{decl}` of the + variable to be output, if there is one, or ``NULL_TREE`` if there + is no corresponding variable. If you define this macro, GCC will use it + in place of both ``ASM_OUTPUT_LOCAL`` and + ``ASM_OUTPUT_ALIGNED_LOCAL``. Define this macro when you need to see + the variable's decl in order to chose what to output. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/the-overall-framework-of-an-assembler-file.rst b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/the-overall-framework-of-an-assembler-file.rst new file mode 100644 index 00000000000..d0dfe7dd558 --- /dev/null +++ b/gcc/doc/gccint/target-macros/defining-the-output-assembler-language/the-overall-framework-of-an-assembler-file.rst @@ -0,0 +1,287 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: assembler format, output of assembler code + +.. _file-framework: + +The Overall Framework of an Assembler File +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +This describes the overall framework of an assembly file. + +.. index:: default_file_start + +.. function:: void TARGET_ASM_FILE_START (void) + + .. hook-start:TARGET_ASM_FILE_START + + Output to ``asm_out_file`` any text which the assembler expects to + find at the beginning of a file. The default behavior is controlled + by two flags, documented below. Unless your target's assembler is + quite unusual, if you override the default, you should call + ``default_file_start`` at some point in your target hook. This + lets other target files rely on these variables. + +.. hook-end + +.. c:var:: bool TARGET_ASM_FILE_START_APP_OFF + + .. hook-start:TARGET_ASM_FILE_START_APP_OFF + + If this flag is true, the text of the macro ``ASM_APP_OFF`` will be + printed as the very first line in the assembly file, unless + :option:`-fverbose-asm` is in effect. (If that macro has been defined + to the empty string, this variable has no effect.) With the normal + definition of ``ASM_APP_OFF``, the effect is to notify the GNU + assembler that it need not bother stripping comments or extra + whitespace from its input. This allows it to work a bit faster. + + The default is false. You should not set it to true unless you have + verified that your port does not generate any extra whitespace or + comments that will cause GAS to issue errors in NO_APP mode. + +.. hook-end + +.. c:var:: bool TARGET_ASM_FILE_START_FILE_DIRECTIVE + + .. hook-start:TARGET_ASM_FILE_START_FILE_DIRECTIVE + + If this flag is true, ``output_file_directive`` will be called + for the primary source file, immediately after printing + ``ASM_APP_OFF`` (if that is enabled). Most ELF assemblers expect + this to be done. The default is false. + +.. hook-end + +.. function:: void TARGET_ASM_FILE_END (void) + + .. hook-start:TARGET_ASM_FILE_END + + Output to ``asm_out_file`` any text which the assembler expects + to find at the end of a file. The default is to output nothing. + +.. hook-end + +.. function:: void file_end_indicate_exec_stack () + + Some systems use a common convention, the :samp:`.note.GNU-stack` + special section, to indicate whether or not an object file relies on + the stack being executable. If your system uses this convention, you + should define ``TARGET_ASM_FILE_END`` to this function. If you + need to do other things in that hook, have your hook function call + this function. + +.. function:: void TARGET_ASM_LTO_START (void) + + .. hook-start:TARGET_ASM_LTO_START + + Output to ``asm_out_file`` any text which the assembler expects + to find at the start of an LTO section. The default is to output + nothing. + +.. hook-end + +.. function:: void TARGET_ASM_LTO_END (void) + + .. hook-start:TARGET_ASM_LTO_END + + Output to ``asm_out_file`` any text which the assembler expects + to find at the end of an LTO section. The default is to output + nothing. + +.. hook-end + +.. function:: void TARGET_ASM_CODE_END (void) + + .. hook-start:TARGET_ASM_CODE_END + + Output to ``asm_out_file`` any text which is needed before emitting + unwind info and debug info at the end of a file. Some targets emit + here PIC setup thunks that cannot be emitted at the end of file, + because they couldn't have unwind info then. The default is to output + nothing. + +.. hook-end + +.. c:macro:: ASM_COMMENT_START + + A C string constant describing how to begin a comment in the target + assembler language. The compiler assumes that the comment will end at + the end of the line. + +.. c:macro:: ASM_APP_ON + + A C string constant for text to be output before each ``asm`` + statement or group of consecutive ones. Normally this is + ``"#APP"``, which is a comment that has no effect on most + assemblers but tells the GNU assembler that it must check the lines + that follow for all valid assembler constructs. + +.. c:macro:: ASM_APP_OFF + + A C string constant for text to be output after each ``asm`` + statement or group of consecutive ones. Normally this is + ``"#NO_APP"``, which tells the GNU assembler to resume making the + time-saving assumptions that are valid for ordinary compiler output. + +.. c:macro:: ASM_OUTPUT_SOURCE_FILENAME (stream, name) + + A C statement to output COFF information or DWARF debugging information + which indicates that filename :samp:`{name}` is the current source file to + the stdio stream :samp:`{stream}`. + + This macro need not be defined if the standard form of output + for the file format in use is appropriate. + +.. function:: void TARGET_ASM_OUTPUT_SOURCE_FILENAME (FILE *file, const char *name) + + .. hook-start:TARGET_ASM_OUTPUT_SOURCE_FILENAME + + Output DWARF debugging information which indicates that filename + :samp:`{name}` is the current source file to the stdio stream :samp:`{file}`. + + This target hook need not be defined if the standard form of output + for the file format in use is appropriate. + +.. hook-end + +.. function:: void TARGET_ASM_OUTPUT_IDENT (const char *name) + + .. hook-start:TARGET_ASM_OUTPUT_IDENT + + Output a string based on :samp:`{name}`, suitable for the :samp:`#ident` + directive, or the equivalent directive or pragma in non-C-family languages. + If this hook is not defined, nothing is output for the :samp:`#ident` + directive. + +.. hook-end + +.. c:macro:: OUTPUT_QUOTED_STRING (stream, string) + + A C statement to output the string :samp:`{string}` to the stdio stream + :samp:`{stream}`. If you do not call the function ``output_quoted_string`` + in your config files, GCC will only call it to output filenames to + the assembler source. So you can use it to canonicalize the format + of the filename using this macro. + +.. function:: void TARGET_ASM_NAMED_SECTION (const char *name, unsigned int flags, tree decl) + + .. hook-start:TARGET_ASM_NAMED_SECTION + + Output assembly directives to switch to section :samp:`{name}`. The section + should have attributes as specified by :samp:`{flags}`, which is a bit mask + of the ``SECTION_*`` flags defined in :samp:`output.h`. If :samp:`{decl}` + is non-NULL, it is the ``VAR_DECL`` or ``FUNCTION_DECL`` with which + this section is associated. + +.. hook-end + +.. function:: bool TARGET_ASM_ELF_FLAGS_NUMERIC (unsigned int flags, unsigned int *num) + + .. hook-start:TARGET_ASM_ELF_FLAGS_NUMERIC + + This hook can be used to encode ELF section flags for which no letter + code has been defined in the assembler. It is called by + ``default_asm_named_section`` whenever the section flags need to be + emitted in the assembler output. If the hook returns true, then the + numerical value for ELF section flags should be calculated from + :samp:`{flags}` and saved in :samp:`{*num}` ; the value is printed out instead of the + normal sequence of letter codes. If the hook is not defined, or if it + returns false, then :samp:`{num}` is ignored and the traditional letter sequence + is emitted. + +.. hook-end + +.. function:: section * TARGET_ASM_FUNCTION_SECTION (tree decl, enum node_frequency freq, bool startup, bool exit) + + .. hook-start:TARGET_ASM_FUNCTION_SECTION + + Return preferred text (sub)section for function :samp:`{decl}`. + Main purpose of this function is to separate cold, normal and hot + functions. :samp:`{startup}` is true when function is known to be used only + at startup (from static constructors or it is ``main()``). + :samp:`{exit}` is true when function is known to be used only at exit + (from static destructors). + Return NULL if function should go to default text section. + +.. hook-end + +.. function:: void TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS (FILE *file, tree decl, bool new_is_cold) + + .. hook-start:TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS + + Used by the target to emit any assembler directives or additional + labels needed when a function is partitioned between different + sections. Output should be written to :samp:`{file}`. The function + decl is available as :samp:`{decl}` and the new section is 'cold' if + :samp:`{new_is_cold}` is ``true``. + +.. hook-end + +.. c:var:: bool TARGET_HAVE_NAMED_SECTIONS + + .. hook-start:TARGET_HAVE_NAMED_SECTIONS + + .. hook-end + + This flag is true if the target supports ``TARGET_ASM_NAMED_SECTION``. + It must not be modified by command-line option processing. + +.. _target_have_switchable_bss_sections: + +.. c:var:: bool TARGET_HAVE_SWITCHABLE_BSS_SECTIONS + + .. hook-start:TARGET_HAVE_SWITCHABLE_BSS_SECTIONS + + This flag is true if we can create zeroed data by switching to a BSS + section and then using ``ASM_OUTPUT_SKIP`` to allocate the space. + This is true on most ELF targets. + +.. hook-end + +.. function:: unsigned int TARGET_SECTION_TYPE_FLAGS (tree decl, const char *name, int reloc) + + .. hook-start:TARGET_SECTION_TYPE_FLAGS + + Choose a set of section attributes for use by ``TARGET_ASM_NAMED_SECTION`` + based on a variable or function decl, a section name, and whether or not the + declaration's initializer may contain runtime relocations. :samp:`{decl}` may be + null, in which case read-write data should be assumed. + + The default version of this function handles choosing code vs data, + read-only vs read-write data, and ``flag_pic``. You should only + need to override this if your target has special flags that might be + set via ``__attribute__``. + +.. hook-end + +.. function:: void TARGET_ASM_RECORD_GCC_SWITCHES (const char *) + + .. hook-start:TARGET_ASM_RECORD_GCC_SWITCHES + + Provides the target with the ability to record the gcc command line + switches provided as argument. + + By default this hook is set to NULL, but an example implementation is + provided for ELF based targets. Called :samp:`{elf_record_gcc_switches}`, + it records the switches as ASCII text inside a new, string mergeable + section in the assembler output file. The name of the new section is + provided by the ``TARGET_ASM_RECORD_GCC_SWITCHES_SECTION`` target + hook. + +.. hook-end + +.. c:var:: const char * TARGET_ASM_RECORD_GCC_SWITCHES_SECTION + + .. hook-start:TARGET_ASM_RECORD_GCC_SWITCHES_SECTION + + This is the name of the section that will be created by the example + ELF implementation of the ``TARGET_ASM_RECORD_GCC_SWITCHES`` target + hook. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/describing-relative-costs-of-operations.rst b/gcc/doc/gccint/target-macros/describing-relative-costs-of-operations.rst new file mode 100644 index 00000000000..4991d3da98e --- /dev/null +++ b/gcc/doc/gccint/target-macros/describing-relative-costs-of-operations.rst @@ -0,0 +1,528 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: costs of instructions, relative costs, speed of instructions + +.. _costs: + +Describing Relative Costs of Operations +*************************************** + +These macros let you describe the relative speed of various operations +on the target machine. + +.. c:macro:: REGISTER_MOVE_COST (mode, from, to) + + A C expression for the cost of moving data of mode :samp:`{mode}` from a + register in class :samp:`{from}` to one in class :samp:`{to}`. The classes are + expressed using the enumeration values such as ``GENERAL_REGS``. A + value of 2 is the default; other values are interpreted relative to + that. + + It is not required that the cost always equal 2 when :samp:`{from}` is the + same as :samp:`{to}` ; on some machines it is expensive to move between + registers if they are not general registers. + + If reload sees an insn consisting of a single ``set`` between two + hard registers, and if ``REGISTER_MOVE_COST`` applied to their + classes returns a value of 2, reload does not check to ensure that the + constraints of the insn are met. Setting a cost of other than 2 will + allow reload to verify that the constraints are met. You should do this + if the :samp:`mov{m}` pattern's constraints do not allow such copying. + + These macros are obsolete, new ports should use the target hook + ``TARGET_REGISTER_MOVE_COST`` instead. + +.. function:: int TARGET_REGISTER_MOVE_COST (machine_mode mode, reg_class_t from, reg_class_t to) + + .. hook-start:TARGET_REGISTER_MOVE_COST + + This target hook should return the cost of moving data of mode :samp:`{mode}` + from a register in class :samp:`{from}` to one in class :samp:`{to}`. The classes + are expressed using the enumeration values such as ``GENERAL_REGS``. + A value of 2 is the default; other values are interpreted relative to + that. + + It is not required that the cost always equal 2 when :samp:`{from}` is the + same as :samp:`{to}` ; on some machines it is expensive to move between + registers if they are not general registers. + + If reload sees an insn consisting of a single ``set`` between two + hard registers, and if ``TARGET_REGISTER_MOVE_COST`` applied to their + classes returns a value of 2, reload does not check to ensure that the + constraints of the insn are met. Setting a cost of other than 2 will + allow reload to verify that the constraints are met. You should do this + if the :samp:`mov{m}` pattern's constraints do not allow such copying. + + The default version of this function returns 2. + +.. hook-end + +.. c:macro:: MEMORY_MOVE_COST (mode, class, in) + + A C expression for the cost of moving data of mode :samp:`{mode}` between a + register of class :samp:`{class}` and memory; :samp:`{in}` is zero if the value + is to be written to memory, nonzero if it is to be read in. This cost + is relative to those in ``REGISTER_MOVE_COST``. If moving between + registers and memory is more expensive than between two registers, you + should define this macro to express the relative cost. + + If you do not define this macro, GCC uses a default cost of 4 plus + the cost of copying via a secondary reload register, if one is + needed. If your machine requires a secondary reload register to copy + between memory and a register of :samp:`{class}` but the reload mechanism is + more complex than copying via an intermediate, define this macro to + reflect the actual cost of the move. + + GCC defines the function ``memory_move_secondary_cost`` if + secondary reloads are needed. It computes the costs due to copying via + a secondary register. If your machine copies from memory using a + secondary register in the conventional way but the default base value of + 4 is not correct for your machine, define this macro to add some other + value to the result of that function. The arguments to that function + are the same as to this macro. + + These macros are obsolete, new ports should use the target hook + ``TARGET_MEMORY_MOVE_COST`` instead. + +.. function:: int TARGET_MEMORY_MOVE_COST (machine_mode mode, reg_class_t rclass, bool in) + + .. hook-start:TARGET_MEMORY_MOVE_COST + + This target hook should return the cost of moving data of mode :samp:`{mode}` + between a register of class :samp:`{rclass}` and memory; :samp:`{in}` is ``false`` + if the value is to be written to memory, ``true`` if it is to be read in. + This cost is relative to those in ``TARGET_REGISTER_MOVE_COST``. + If moving between registers and memory is more expensive than between two + registers, you should add this target hook to express the relative cost. + + If you do not add this target hook, GCC uses a default cost of 4 plus + the cost of copying via a secondary reload register, if one is + needed. If your machine requires a secondary reload register to copy + between memory and a register of :samp:`{rclass}` but the reload mechanism is + more complex than copying via an intermediate, use this target hook to + reflect the actual cost of the move. + + GCC defines the function ``memory_move_secondary_cost`` if + secondary reloads are needed. It computes the costs due to copying via + a secondary register. If your machine copies from memory using a + secondary register in the conventional way but the default base value of + 4 is not correct for your machine, use this target hook to add some other + value to the result of that function. The arguments to that function + are the same as to this target hook. + +.. hook-end + +.. c:macro:: BRANCH_COST (speed_p, predictable_p) + + A C expression for the cost of a branch instruction. A value of 1 is + the default; other values are interpreted relative to that. Parameter + :samp:`{speed_p}` is true when the branch in question should be optimized + for speed. When it is false, ``BRANCH_COST`` should return a value + optimal for code size rather than performance. :samp:`{predictable_p}` is + true for well-predicted branches. On many architectures the + ``BRANCH_COST`` can be reduced then. + +Here are additional macros which do not specify precise relative costs, +but only that certain actions are more expensive than GCC would +ordinarily expect. + +.. c:macro:: SLOW_BYTE_ACCESS + + Define this macro as a C expression which is nonzero if accessing less + than a word of memory (i.e. a ``char`` or a ``short``) is no + faster than accessing a word of memory, i.e., if such access + require more than one instruction or if there is no difference in cost + between byte and (aligned) word loads. + + When this macro is not defined, the compiler will access a field by + finding the smallest containing object; when it is defined, a fullword + load will be used if alignment permits. Unless bytes accesses are + faster than word accesses, using word accesses is preferable since it + may eliminate subsequent memory access if subsequent accesses occur to + other fields in the same word of the structure, but to different bytes. + +.. function:: bool TARGET_SLOW_UNALIGNED_ACCESS (machine_mode mode, unsigned int align) + + .. hook-start:TARGET_SLOW_UNALIGNED_ACCESS + + This hook returns true if memory accesses described by the + :samp:`{mode}` and :samp:`{alignment}` parameters have a cost many times greater + than aligned accesses, for example if they are emulated in a trap handler. + This hook is invoked only for unaligned accesses, i.e. when + ``alignment < GET_MODE_ALIGNMENT (mode)``. + + When this hook returns true, the compiler will act as if + ``STRICT_ALIGNMENT`` were true when generating code for block + moves. This can cause significantly more instructions to be produced. + Therefore, do not make this hook return true if unaligned accesses only + add a cycle or two to the time for a memory access. + + The hook must return true whenever ``STRICT_ALIGNMENT`` is true. + The default implementation returns ``STRICT_ALIGNMENT``. + +.. hook-end + +.. c:macro:: MOVE_RATIO (speed) + + The threshold of number of scalar memory-to-memory move insns, *below* + which a sequence of insns should be generated instead of a + string move insn or a library call. Increasing the value will always + make code faster, but eventually incurs high cost in increased code size. + + Note that on machines where the corresponding move insn is a + ``define_expand`` that emits a sequence of insns, this macro counts + the number of such sequences. + + The parameter :samp:`{speed}` is true if the code is currently being + optimized for speed rather than size. + + If you don't define this, a reasonable default is used. + +.. function:: bool TARGET_USE_BY_PIECES_INFRASTRUCTURE_P (unsigned HOST_WIDE_INT size, unsigned int alignment, enum by_pieces_operation op, bool speed_p) + + .. hook-start:TARGET_USE_BY_PIECES_INFRASTRUCTURE_P + + GCC will attempt several strategies when asked to copy between + two areas of memory, or to set, clear or store to memory, for example + when copying a ``struct``. The ``by_pieces`` infrastructure + implements such memory operations as a sequence of load, store or move + insns. Alternate strategies are to expand the + ``cpymem`` or ``setmem`` optabs, to emit a library call, or to emit + unit-by-unit, loop-based operations. + + This target hook should return true if, for a memory operation with a + given :samp:`{size}` and :samp:`{alignment}`, using the ``by_pieces`` + infrastructure is expected to result in better code generation. + Both :samp:`{size}` and :samp:`{alignment}` are measured in terms of storage + units. + + The parameter :samp:`{op}` is one of: ``CLEAR_BY_PIECES``, + ``MOVE_BY_PIECES``, ``SET_BY_PIECES``, ``STORE_BY_PIECES`` or + ``COMPARE_BY_PIECES``. These describe the type of memory operation + under consideration. + + The parameter :samp:`{speed_p}` is true if the code is currently being + optimized for speed rather than size. + + Returning true for higher values of :samp:`{size}` can improve code generation + for speed if the target does not provide an implementation of the + ``cpymem`` or ``setmem`` standard names, if the ``cpymem`` or + ``setmem`` implementation would be more expensive than a sequence of + insns, or if the overhead of a library call would dominate that of + the body of the memory operation. + + Returning true for higher values of ``size`` may also cause an increase + in code size, for example where the number of insns emitted to perform a + move would be greater than that of a library call. + +.. hook-end + +.. function:: bool TARGET_OVERLAP_OP_BY_PIECES_P (void) + + .. hook-start:TARGET_OVERLAP_OP_BY_PIECES_P + + This target hook should return true if when the ``by_pieces`` + infrastructure is used, an offset adjusted unaligned memory operation + in the smallest integer mode for the last piece operation of a memory + region can be generated to avoid doing more than one smaller operations. + +.. hook-end + +.. function:: int TARGET_COMPARE_BY_PIECES_BRANCH_RATIO (machine_mode mode) + + .. hook-start:TARGET_COMPARE_BY_PIECES_BRANCH_RATIO + + When expanding a block comparison in MODE, gcc can try to reduce the + number of branches at the expense of more memory operations. This hook + allows the target to override the default choice. It should return the + factor by which branches should be reduced over the plain expansion with + one comparison per :samp:`{mode}` -sized piece. A port can also prevent a + particular mode from being used for block comparisons by returning a + negative number from this hook. + +.. hook-end + +.. c:macro:: MOVE_MAX_PIECES + + A C expression used by ``move_by_pieces`` to determine the largest unit + a load or store used to copy memory is. Defaults to ``MOVE_MAX``. + +.. c:macro:: STORE_MAX_PIECES + + A C expression used by ``store_by_pieces`` to determine the largest unit + a store used to memory is. Defaults to ``MOVE_MAX_PIECES``, or two times + the size of ``HOST_WIDE_INT``, whichever is smaller. + +.. c:macro:: COMPARE_MAX_PIECES + + A C expression used by ``compare_by_pieces`` to determine the largest unit + a load or store used to compare memory is. Defaults to + ``MOVE_MAX_PIECES``. + +.. c:macro:: CLEAR_RATIO (speed) + + The threshold of number of scalar move insns, *below* which a sequence + of insns should be generated to clear memory instead of a string clear insn + or a library call. Increasing the value will always make code faster, but + eventually incurs high cost in increased code size. + + The parameter :samp:`{speed}` is true if the code is currently being + optimized for speed rather than size. + + If you don't define this, a reasonable default is used. + +.. c:macro:: SET_RATIO (speed) + + The threshold of number of scalar move insns, *below* which a sequence + of insns should be generated to set memory to a constant value, instead of + a block set insn or a library call. + Increasing the value will always make code faster, but + eventually incurs high cost in increased code size. + + The parameter :samp:`{speed}` is true if the code is currently being + optimized for speed rather than size. + + If you don't define this, it defaults to the value of ``MOVE_RATIO``. + +.. c:macro:: USE_LOAD_POST_INCREMENT (mode) + + A C expression used to determine whether a load postincrement is a good + thing to use for a given mode. Defaults to the value of + ``HAVE_POST_INCREMENT``. + +.. c:macro:: USE_LOAD_POST_DECREMENT (mode) + + A C expression used to determine whether a load postdecrement is a good + thing to use for a given mode. Defaults to the value of + ``HAVE_POST_DECREMENT``. + +.. c:macro:: USE_LOAD_PRE_INCREMENT (mode) + + A C expression used to determine whether a load preincrement is a good + thing to use for a given mode. Defaults to the value of + ``HAVE_PRE_INCREMENT``. + +.. c:macro:: USE_LOAD_PRE_DECREMENT (mode) + + A C expression used to determine whether a load predecrement is a good + thing to use for a given mode. Defaults to the value of + ``HAVE_PRE_DECREMENT``. + +.. c:macro:: USE_STORE_POST_INCREMENT (mode) + + A C expression used to determine whether a store postincrement is a good + thing to use for a given mode. Defaults to the value of + ``HAVE_POST_INCREMENT``. + +.. c:macro:: USE_STORE_POST_DECREMENT (mode) + + A C expression used to determine whether a store postdecrement is a good + thing to use for a given mode. Defaults to the value of + ``HAVE_POST_DECREMENT``. + +.. c:macro:: USE_STORE_PRE_INCREMENT (mode) + + This macro is used to determine whether a store preincrement is a good + thing to use for a given mode. Defaults to the value of + ``HAVE_PRE_INCREMENT``. + +.. c:macro:: USE_STORE_PRE_DECREMENT (mode) + + This macro is used to determine whether a store predecrement is a good + thing to use for a given mode. Defaults to the value of + ``HAVE_PRE_DECREMENT``. + +.. c:macro:: NO_FUNCTION_CSE + + Define this macro to be true if it is as good or better to call a constant + function address than to call an address kept in a register. + +.. c:macro:: LOGICAL_OP_NON_SHORT_CIRCUIT + + Define this macro if a non-short-circuit operation produced by + :samp:`fold_range_test ()` is optimal. This macro defaults to true if + ``BRANCH_COST`` is greater than or equal to the value 2. + +.. function:: bool TARGET_OPTAB_SUPPORTED_P (int op, machine_mode mode1, machine_mode mode2, optimization_type opt_type) + + .. hook-start:TARGET_OPTAB_SUPPORTED_P + + Return true if the optimizers should use optab :samp:`{op}` with + modes :samp:`{mode1}` and :samp:`{mode2}` for optimization type :samp:`{opt_type}`. + The optab is known to have an associated :samp:`.md` instruction + whose C condition is true. :samp:`{mode2}` is only meaningful for conversion + optabs; for direct optabs it is a copy of :samp:`{mode1}`. + + For example, when called with :samp:`{op}` equal to ``rint_optab`` and + :samp:`{mode1}` equal to ``DFmode``, the hook should say whether the + optimizers should use optab ``rintdf2``. + + The default hook returns true for all inputs. + +.. hook-end + +.. function:: bool TARGET_RTX_COSTS (rtx x, machine_mode mode, int outer_code, int opno, int *total, bool speed) + + .. hook-start:TARGET_RTX_COSTS + + This target hook describes the relative costs of RTL expressions. + + The cost may depend on the precise form of the expression, which is + available for examination in :samp:`{x}`, and the fact that :samp:`{x}` appears + as operand :samp:`{opno}` of an expression with rtx code :samp:`{outer_code}`. + That is, the hook can assume that there is some rtx :samp:`{y}` such + that :samp:`GET_CODE ({y}) == {outer_code}` and such that + either (a) :samp:`XEXP ({y}, {opno}) == {x}` or + (b) :samp:`XVEC ({y}, {opno})` contains :samp:`{x}`. + + :samp:`{mode}` is :samp:`{x}` 's machine mode, or for cases like ``const_int`` that + do not have a mode, the mode in which :samp:`{x}` is used. + + In implementing this hook, you can use the construct + ``COSTS_N_INSNS (n)`` to specify a cost equal to :samp:`{n}` fast + instructions. + + On entry to the hook, ``*total`` contains a default estimate + for the cost of the expression. The hook should modify this value as + necessary. Traditionally, the default costs are ``COSTS_N_INSNS (5)`` + for multiplications, ``COSTS_N_INSNS (7)`` for division and modulus + operations, and ``COSTS_N_INSNS (1)`` for all other operations. + + When optimizing for code size, i.e. when ``speed`` is + false, this target hook should be used to estimate the relative + size cost of an expression, again relative to ``COSTS_N_INSNS``. + + The hook returns true when all subexpressions of :samp:`{x}` have been + processed, and false when ``rtx_cost`` should recurse. + +.. hook-end + +.. function:: int TARGET_ADDRESS_COST (rtx address, machine_mode mode, addr_space_t as, bool speed) + + .. hook-start:TARGET_ADDRESS_COST + + This hook computes the cost of an addressing mode that contains + :samp:`{address}`. If not defined, the cost is computed from + the :samp:`{address}` expression and the ``TARGET_RTX_COST`` hook. + + For most CISC machines, the default cost is a good approximation of the + true cost of the addressing mode. However, on RISC machines, all + instructions normally have the same length and execution time. Hence + all addresses will have equal costs. + + In cases where more than one form of an address is known, the form with + the lowest cost will be used. If multiple forms have the same, lowest, + cost, the one that is the most complex will be used. + + For example, suppose an address that is equal to the sum of a register + and a constant is used twice in the same basic block. When this macro + is not defined, the address will be computed in a register and memory + references will be indirect through that register. On machines where + the cost of the addressing mode containing the sum is no higher than + that of a simple indirect reference, this will produce an additional + instruction and possibly require an additional register. Proper + specification of this macro eliminates this overhead for such machines. + + This hook is never called with an invalid address. + + On machines where an address involving more than one register is as + cheap as an address computation involving only one register, defining + ``TARGET_ADDRESS_COST`` to reflect this can cause two registers to + be live over a region of code where only one would have been if + ``TARGET_ADDRESS_COST`` were not defined in that manner. This effect + should be considered in the definition of this macro. Equivalent costs + should probably only be given to addresses with different numbers of + registers on machines with lots of registers. + +.. hook-end + +.. function:: int TARGET_INSN_COST (rtx_insn *insn, bool speed) + + .. hook-start:TARGET_INSN_COST + + This target hook describes the relative costs of RTL instructions. + + In implementing this hook, you can use the construct + ``COSTS_N_INSNS (n)`` to specify a cost equal to :samp:`{n}` fast + instructions. + + When optimizing for code size, i.e. when ``speed`` is + false, this target hook should be used to estimate the relative + size cost of an expression, again relative to ``COSTS_N_INSNS``. + +.. hook-end + +.. function:: unsigned int TARGET_MAX_NOCE_IFCVT_SEQ_COST (edge e) + + .. hook-start:TARGET_MAX_NOCE_IFCVT_SEQ_COST + + This hook returns a value in the same units as ``TARGET_RTX_COSTS``, + giving the maximum acceptable cost for a sequence generated by the RTL + if-conversion pass when conditional execution is not available. + The RTL if-conversion pass attempts to convert conditional operations + that would require a branch to a series of unconditional operations and + ``movmodecc`` insns. This hook returns the maximum cost of the + unconditional instructions and the ``movmodecc`` insns. + RTL if-conversion is cancelled if the cost of the converted sequence + is greater than the value returned by this hook. + + ``e`` is the edge between the basic block containing the conditional + branch to the basic block which would be executed if the condition + were true. + + The default implementation of this hook uses the + ``max-rtl-if-conversion-[un]predictable`` parameters if they are set, + and uses a multiple of ``BRANCH_COST`` otherwise. + +.. hook-end + +.. function:: bool TARGET_NOCE_CONVERSION_PROFITABLE_P (rtx_insn *seq, struct noce_if_info *if_info) + + .. hook-start:TARGET_NOCE_CONVERSION_PROFITABLE_P + + This hook returns true if the instruction sequence ``seq`` is a good + candidate as a replacement for the if-convertible sequence described in + ``if_info``. + +.. hook-end + +.. function:: bool TARGET_NEW_ADDRESS_PROFITABLE_P (rtx memref, rtx_insn * insn, rtx new_addr) + + .. hook-start:TARGET_NEW_ADDRESS_PROFITABLE_P + + Return ``true`` if it is profitable to replace the address in + :samp:`{memref}` with :samp:`{new_addr}`. This allows targets to prevent the + scheduler from undoing address optimizations. The instruction containing the + memref is :samp:`{insn}`. The default implementation returns ``true``. + +.. hook-end + +.. function:: bool TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P (void) + + .. hook-start:TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P + + This predicate controls the use of the eager delay slot filler to disallow + speculatively executed instructions being placed in delay slots. Targets + such as certain MIPS architectures possess both branches with and without + delay slots. As the eager delay slot filler can decrease performance, + disabling it is beneficial when ordinary branches are available. Use of + delay slot branches filled using the basic filler is often still desirable + as the delay slot can hide a pipeline bubble. + +.. hook-end + +.. function:: HOST_WIDE_INT TARGET_ESTIMATED_POLY_VALUE (poly_int64 val, poly_value_estimate_kind kind) + + .. hook-start:TARGET_ESTIMATED_POLY_VALUE + + Return an estimate of the runtime value of :samp:`{val}`, for use in + things like cost calculations or profiling frequencies. :samp:`{kind}` is used + to ask for the minimum, maximum, and likely estimates of the value through + the ``POLY_VALUE_MIN``, ``POLY_VALUE_MAX`` and + ``POLY_VALUE_LIKELY`` values. The default + implementation returns the lowest possible value of :samp:`{val}`. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/dividing-the-output-into-sections-texts-data.rst b/gcc/doc/gccint/target-macros/dividing-the-output-into-sections-texts-data.rst new file mode 100644 index 00000000000..f5adf3d0f80 --- /dev/null +++ b/gcc/doc/gccint/target-macros/dividing-the-output-into-sections-texts-data.rst @@ -0,0 +1,445 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _sections: + +Dividing the Output into Sections (Texts, Data, ...) +**************************************************** + +.. the above section title is WAY too long. maybe cut the part between + the (...)? -mew 10feb93 + +.. the (...)? -mew 10feb93 + +An object file is divided into sections containing different types of +data. In the most common case, there are three sections: the :dfn:`text +section`, which holds instructions and read-only data; the :dfn:`data +section`, which holds initialized writable data; and the :dfn:`bss +section`, which holds uninitialized data. Some systems have other kinds +of sections. + +:samp:`varasm.cc` provides several well-known sections, such as +``text_section``, ``data_section`` and ``bss_section``. +The normal way of controlling a ``foo_section`` variable +is to define the associated ``FOO_SECTION_ASM_OP`` macro, +as described below. The macros are only read once, when :samp:`varasm.cc` +initializes itself, so their values must be run-time constants. +They may however depend on command-line flags. + +.. note:: + + Some run-time files, such :samp:`crtstuff.c`, also make + use of the ``FOO_SECTION_ASM_OP`` macros, and expect them + to be string literals. + +Some assemblers require a different string to be written every time a +section is selected. If your assembler falls into this category, you +should define the ``TARGET_ASM_INIT_SECTIONS`` hook and use +``get_unnamed_section`` to set up the sections. + +You must always create a ``text_section``, either by defining +``TEXT_SECTION_ASM_OP`` or by initializing ``text_section`` +in ``TARGET_ASM_INIT_SECTIONS``. The same is true of +``data_section`` and ``DATA_SECTION_ASM_OP``. If you do not +create a distinct ``readonly_data_section``, the default is to +reuse ``text_section``. + +All the other :samp:`varasm.cc` sections are optional, and are null +if the target does not provide them. + +.. c:macro:: TEXT_SECTION_ASM_OP + + A C expression whose value is a string, including spacing, containing the + assembler operation that should precede instructions and read-only data. + Normally ``"\t.text"`` is right. + +.. c:macro:: HOT_TEXT_SECTION_NAME + + If defined, a C string constant for the name of the section containing most + frequently executed functions of the program. If not defined, GCC will provide + a default definition if the target supports named sections. + +.. c:macro:: UNLIKELY_EXECUTED_TEXT_SECTION_NAME + + If defined, a C string constant for the name of the section containing unlikely + executed functions in the program. + +.. c:macro:: DATA_SECTION_ASM_OP + + A C expression whose value is a string, including spacing, containing the + assembler operation to identify the following data as writable initialized + data. Normally ``"\t.data"`` is right. + +.. c:macro:: SDATA_SECTION_ASM_OP + + If defined, a C expression whose value is a string, including spacing, + containing the assembler operation to identify the following data as + initialized, writable small data. + +.. c:macro:: READONLY_DATA_SECTION_ASM_OP + + A C expression whose value is a string, including spacing, containing the + assembler operation to identify the following data as read-only initialized + data. + +.. c:macro:: BSS_SECTION_ASM_OP + + If defined, a C expression whose value is a string, including spacing, + containing the assembler operation to identify the following data as + uninitialized global data. If not defined, and + ``ASM_OUTPUT_ALIGNED_BSS`` not defined, + uninitialized global data will be output in the data section if + :option:`-fno-common` is passed, otherwise ``ASM_OUTPUT_COMMON`` will be + used. + +.. c:macro:: SBSS_SECTION_ASM_OP + + If defined, a C expression whose value is a string, including spacing, + containing the assembler operation to identify the following data as + uninitialized, writable small data. + +.. c:macro:: TLS_COMMON_ASM_OP + + If defined, a C expression whose value is a string containing the + assembler operation to identify the following data as thread-local + common data. The default is ``".tls_common"``. + +.. c:macro:: TLS_SECTION_ASM_FLAG + + If defined, a C expression whose value is a character constant + containing the flag used to mark a section as a TLS section. The + default is ``'T'``. + +.. c:macro:: INIT_SECTION_ASM_OP + + If defined, a C expression whose value is a string, including spacing, + containing the assembler operation to identify the following data as + initialization code. If not defined, GCC will assume such a section does + not exist. This section has no corresponding ``init_section`` + variable; it is used entirely in runtime code. + +.. c:macro:: FINI_SECTION_ASM_OP + + If defined, a C expression whose value is a string, including spacing, + containing the assembler operation to identify the following data as + finalization code. If not defined, GCC will assume such a section does + not exist. This section has no corresponding ``fini_section`` + variable; it is used entirely in runtime code. + +.. c:macro:: INIT_ARRAY_SECTION_ASM_OP + + If defined, a C expression whose value is a string, including spacing, + containing the assembler operation to identify the following data as + part of the ``.init_array`` (or equivalent) section. If not + defined, GCC will assume such a section does not exist. Do not define + both this macro and ``INIT_SECTION_ASM_OP``. + +.. c:macro:: FINI_ARRAY_SECTION_ASM_OP + + If defined, a C expression whose value is a string, including spacing, + containing the assembler operation to identify the following data as + part of the ``.fini_array`` (or equivalent) section. If not + defined, GCC will assume such a section does not exist. Do not define + both this macro and ``FINI_SECTION_ASM_OP``. + +.. c:macro:: MACH_DEP_SECTION_ASM_FLAG + + If defined, a C expression whose value is a character constant + containing the flag used to mark a machine-dependent section. This + corresponds to the ``SECTION_MACH_DEP`` section flag. + +.. c:macro:: CRT_CALL_STATIC_FUNCTION (section_op, function) + + If defined, an ASM statement that switches to a different section + via :samp:`{section_op}`, calls :samp:`{function}`, and switches back to + the text section. This is used in :samp:`crtstuff.c` if + ``INIT_SECTION_ASM_OP`` or ``FINI_SECTION_ASM_OP`` to calls + to initialization and finalization functions from the init and fini + sections. By default, this macro uses a simple function call. Some + ports need hand-crafted assembly code to avoid dependencies on + registers initialized in the function prologue or to ensure that + constant pools don't end up too far way in the text section. + +.. c:macro:: TARGET_LIBGCC_SDATA_SECTION + + If defined, a string which names the section into which small + variables defined in crtstuff and libgcc should go. This is useful + when the target has options for optimizing access to small data, and + you want the crtstuff and libgcc routines to be conservative in what + they expect of your application yet liberal in what your application + expects. For example, for targets with a ``.sdata`` section (like + MIPS), you could compile crtstuff with ``-G 0`` so that it doesn't + require small data support from your application, but use this macro + to put small data into ``.sdata`` so that your application can + access these variables whether it uses small data or not. + +.. c:macro:: FORCE_CODE_SECTION_ALIGN + + If defined, an ASM statement that aligns a code section to some + arbitrary boundary. This is used to force all fragments of the + ``.init`` and ``.fini`` sections to have to same alignment + and thus prevent the linker from having to add any padding. + +.. c:macro:: JUMP_TABLES_IN_TEXT_SECTION + + Define this macro to be an expression with a nonzero value if jump + tables (for ``tablejump`` insns) should be output in the text + section, along with the assembler instructions. Otherwise, the + readonly data section is used. + + This macro is irrelevant if there is no separate readonly data section. + +.. function:: void TARGET_ASM_INIT_SECTIONS (void) + + .. hook-start:TARGET_ASM_INIT_SECTIONS + + Define this hook if you need to do something special to set up the + :samp:`varasm.cc` sections, or if your target has some special sections + of its own that you need to create. + + GCC calls this hook after processing the command line, but before writing + any assembly code, and before calling any of the section-returning hooks + described below. + +.. hook-end + +.. function:: int TARGET_ASM_RELOC_RW_MASK (void) + + .. hook-start:TARGET_ASM_RELOC_RW_MASK + + Return a mask describing how relocations should be treated when + selecting sections. Bit 1 should be set if global relocations + should be placed in a read-write section; bit 0 should be set if + local relocations should be placed in a read-write section. + + The default version of this function returns 3 when :option:`-fpic` + is in effect, and 0 otherwise. The hook is typically redefined + when the target cannot support (some kinds of) dynamic relocations + in read-only sections even in executables. + +.. hook-end + +.. function:: bool TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC (void) + + .. hook-start:TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC + + Return true to generate ADDR_DIF_VEC table + or false to generate ADDR_VEC table for jumps in case of -fPIC. + + The default version of this function returns true if flag_pic + equals true and false otherwise + +.. hook-end + +.. function:: section * TARGET_ASM_SELECT_SECTION (tree exp, int reloc, unsigned HOST_WIDE_INT align) + + .. hook-start:TARGET_ASM_SELECT_SECTION + + Return the section into which :samp:`{exp}` should be placed. You can + assume that :samp:`{exp}` is either a ``VAR_DECL`` node or a constant of + some sort. :samp:`{reloc}` indicates whether the initial value of :samp:`{exp}` + requires link-time relocations. Bit 0 is set when variable contains + local relocations only, while bit 1 is set for global relocations. + :samp:`{align}` is the constant alignment in bits. + + The default version of this function takes care of putting read-only + variables in ``readonly_data_section``. + + See also :samp:`{USE_SELECT_SECTION_FOR_FUNCTIONS}`. + +.. hook-end + +.. c:macro:: USE_SELECT_SECTION_FOR_FUNCTIONS + + Define this macro if you wish TARGET_ASM_SELECT_SECTION to be called + for ``FUNCTION_DECL`` s as well as for variables and constants. + + In the case of a ``FUNCTION_DECL``, :samp:`{reloc}` will be zero if the + function has been determined to be likely to be called, and nonzero if + it is unlikely to be called. + +.. function:: void TARGET_ASM_UNIQUE_SECTION (tree decl, int reloc) + + .. hook-start:TARGET_ASM_UNIQUE_SECTION + + Build up a unique section name, expressed as a ``STRING_CST`` node, + and assign it to :samp:`DECL_SECTION_NAME ({decl})`. + As with ``TARGET_ASM_SELECT_SECTION``, :samp:`{reloc}` indicates whether + the initial value of :samp:`{exp}` requires link-time relocations. + + The default version of this function appends the symbol name to the + ELF section name that would normally be used for the symbol. For + example, the function ``foo`` would be placed in ``.text.foo``. + Whatever the actual target object format, this is often good enough. + +.. hook-end + +.. function:: section * TARGET_ASM_FUNCTION_RODATA_SECTION (tree decl, bool relocatable) + + .. hook-start:TARGET_ASM_FUNCTION_RODATA_SECTION + + Return the readonly data or reloc readonly data section associated with + :samp:`DECL_SECTION_NAME ({decl})`. :samp:`{relocatable}` selects the latter + over the former. + The default version of this function selects ``.gnu.linkonce.r.name`` if + the function's section is ``.gnu.linkonce.t.name``, ``.rodata.name`` + or ``.data.rel.ro.name`` if function is in ``.text.name``, and + the normal readonly-data or reloc readonly data section otherwise. + +.. hook-end + +.. c:var:: const char * TARGET_ASM_MERGEABLE_RODATA_PREFIX + + .. hook-start:TARGET_ASM_MERGEABLE_RODATA_PREFIX + + Usually, the compiler uses the prefix ``".rodata"`` to construct + section names for mergeable constant data. Define this macro to override + the string if a different section name should be used. + +.. hook-end + +.. function:: section * TARGET_ASM_TM_CLONE_TABLE_SECTION (void) + + .. hook-start:TARGET_ASM_TM_CLONE_TABLE_SECTION + + Return the section that should be used for transactional memory clone + tables. + +.. hook-end + +.. function:: section * TARGET_ASM_SELECT_RTX_SECTION (machine_mode mode, rtx x, unsigned HOST_WIDE_INT align) + + .. hook-start:TARGET_ASM_SELECT_RTX_SECTION + + Return the section into which a constant :samp:`{x}`, of mode :samp:`{mode}`, + should be placed. You can assume that :samp:`{x}` is some kind of + constant in RTL. The argument :samp:`{mode}` is redundant except in the + case of a ``const_int`` rtx. :samp:`{align}` is the constant alignment + in bits. + + The default version of this function takes care of putting symbolic + constants in ``flag_pic`` mode in ``data_section`` and everything + else in ``readonly_data_section``. + +.. hook-end + +.. function:: tree TARGET_MANGLE_DECL_ASSEMBLER_NAME (tree decl, tree id) + + .. hook-start:TARGET_MANGLE_DECL_ASSEMBLER_NAME + + Define this hook if you need to postprocess the assembler name generated + by target-independent code. The :samp:`{id}` provided to this hook will be + the computed name (e.g., the macro ``DECL_NAME`` of the :samp:`{decl}` in C, + or the mangled name of the :samp:`{decl}` in C++). The return value of the + hook is an ``IDENTIFIER_NODE`` for the appropriate mangled name on + your target system. The default implementation of this hook just + returns the :samp:`{id}` provided. + +.. hook-end + +.. function:: void TARGET_ENCODE_SECTION_INFO (tree decl, rtx rtl, int new_decl_p) + + .. hook-start:TARGET_ENCODE_SECTION_INFO + + Define this hook if references to a symbol or a constant must be + treated differently depending on something about the variable or + function named by the symbol (such as what section it is in). + + The hook is executed immediately after rtl has been created for + :samp:`{decl}`, which may be a variable or function declaration or + an entry in the constant pool. In either case, :samp:`{rtl}` is the + rtl in question. Do *not* use ``DECL_RTL (decl)`` + in this hook; that field may not have been initialized yet. + + In the case of a constant, it is safe to assume that the rtl is + a ``mem`` whose address is a ``symbol_ref``. Most decls + will also have this form, but that is not guaranteed. Global + register variables, for instance, will have a ``reg`` for their + rtl. (Normally the right thing to do with such unusual rtl is + leave it alone.) + + The :samp:`{new_decl_p}` argument will be true if this is the first time + that ``TARGET_ENCODE_SECTION_INFO`` has been invoked on this decl. It will + be false for subsequent invocations, which will happen for duplicate + declarations. Whether or not anything must be done for the duplicate + declaration depends on whether the hook examines ``DECL_ATTRIBUTES``. + :samp:`{new_decl_p}` is always true when the hook is called for a constant. + + .. index:: SYMBOL_REF_FLAG, in TARGET_ENCODE_SECTION_INFO + + The usual thing for this hook to do is to record flags in the + ``symbol_ref``, using ``SYMBOL_REF_FLAG`` or ``SYMBOL_REF_FLAGS``. + Historically, the name string was modified if it was necessary to + encode more than one bit of information, but this practice is now + discouraged; use ``SYMBOL_REF_FLAGS``. + + The default definition of this hook, ``default_encode_section_info`` + in :samp:`varasm.cc`, sets a number of commonly-useful bits in + ``SYMBOL_REF_FLAGS``. Check whether the default does what you need + before overriding it. + +.. hook-end + +.. function:: const char * TARGET_STRIP_NAME_ENCODING (const char *name) + + .. hook-start:TARGET_STRIP_NAME_ENCODING + + Decode :samp:`{name}` and return the real name part, sans + the characters that ``TARGET_ENCODE_SECTION_INFO`` + may have added. + +.. hook-end + +.. function:: bool TARGET_IN_SMALL_DATA_P (const_tree exp) + + .. hook-start:TARGET_IN_SMALL_DATA_P + + Returns true if :samp:`{exp}` should be placed into a 'small data' section. + The default version of this hook always returns false. + +.. hook-end + +.. c:var:: bool TARGET_HAVE_SRODATA_SECTION + + .. hook-start:TARGET_HAVE_SRODATA_SECTION + + Contains the value true if the target places read-only + 'small data' into a separate section. The default value is false. + +.. hook-end + +.. function:: bool TARGET_PROFILE_BEFORE_PROLOGUE (void) + + .. hook-start:TARGET_PROFILE_BEFORE_PROLOGUE + + It returns true if target wants profile code emitted before prologue. + + The default version of this hook use the target macro + ``PROFILE_BEFORE_PROLOGUE``. + +.. hook-end + +.. function:: bool TARGET_BINDS_LOCAL_P (const_tree exp) + + .. hook-start:TARGET_BINDS_LOCAL_P + + Returns true if :samp:`{exp}` names an object for which name resolution + rules must resolve to the current 'module' (dynamic shared library + or executable image). + + The default version of this hook implements the name resolution rules + for ELF, which has a looser model of global name binding than other + currently supported object file formats. + +.. hook-end + +.. c:var:: bool TARGET_HAVE_TLS + + .. hook-start:TARGET_HAVE_TLS + + Contains the value true if the target supports thread-local storage. + The default value is false. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/emulating-tls.rst b/gcc/doc/gccint/target-macros/emulating-tls.rst new file mode 100644 index 00000000000..d8d33b00fa2 --- /dev/null +++ b/gcc/doc/gccint/target-macros/emulating-tls.rst @@ -0,0 +1,125 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Emulated TLS + +.. _emulated-tls: + +Emulating TLS +************* + +For targets whose psABI does not provide Thread Local Storage via +specific relocations and instruction sequences, an emulation layer is +used. A set of target hooks allows this emulation layer to be +configured for the requirements of a particular target. For instance +the psABI may in fact specify TLS support in terms of an emulation +layer. + +The emulation layer works by creating a control object for every TLS +object. To access the TLS object, a lookup function is provided +which, when given the address of the control object, will return the +address of the current thread's instance of the TLS object. + +.. c:var:: const char * TARGET_EMUTLS_GET_ADDRESS + + .. hook-start:TARGET_EMUTLS_GET_ADDRESS + + Contains the name of the helper function that uses a TLS control + object to locate a TLS instance. The default causes libgcc's + emulated TLS helper function to be used. + +.. hook-end + +.. c:var:: const char * TARGET_EMUTLS_REGISTER_COMMON + + .. hook-start:TARGET_EMUTLS_REGISTER_COMMON + + Contains the name of the helper function that should be used at + program startup to register TLS objects that are implicitly + initialized to zero. If this is ``NULL``, all TLS objects will + have explicit initializers. The default causes libgcc's emulated TLS + registration function to be used. + +.. hook-end + +.. c:var:: const char * TARGET_EMUTLS_VAR_SECTION + + .. hook-start:TARGET_EMUTLS_VAR_SECTION + + Contains the name of the section in which TLS control variables should + be placed. The default of ``NULL`` allows these to be placed in + any section. + +.. hook-end + +.. c:var:: const char * TARGET_EMUTLS_TMPL_SECTION + + .. hook-start:TARGET_EMUTLS_TMPL_SECTION + + Contains the name of the section in which TLS initializers should be + placed. The default of ``NULL`` allows these to be placed in any + section. + +.. hook-end + +.. c:var:: const char * TARGET_EMUTLS_VAR_PREFIX + + .. hook-start:TARGET_EMUTLS_VAR_PREFIX + + Contains the prefix to be prepended to TLS control variable names. + The default of ``NULL`` uses a target-specific prefix. + +.. hook-end + +.. c:var:: const char * TARGET_EMUTLS_TMPL_PREFIX + + .. hook-start:TARGET_EMUTLS_TMPL_PREFIX + + Contains the prefix to be prepended to TLS initializer objects. The + default of ``NULL`` uses a target-specific prefix. + +.. hook-end + +.. function:: tree TARGET_EMUTLS_VAR_FIELDS (tree type, tree *name) + + .. hook-start:TARGET_EMUTLS_VAR_FIELDS + + Specifies a function that generates the FIELD_DECLs for a TLS control + object type. :samp:`{type}` is the RECORD_TYPE the fields are for and + :samp:`{name}` should be filled with the structure tag, if the default of + ``__emutls_object`` is unsuitable. The default creates a type suitable + for libgcc's emulated TLS function. + +.. hook-end + +.. function:: tree TARGET_EMUTLS_VAR_INIT (tree var, tree decl, tree tmpl_addr) + + .. hook-start:TARGET_EMUTLS_VAR_INIT + + Specifies a function that generates the CONSTRUCTOR to initialize a + TLS control object. :samp:`{var}` is the TLS control object, :samp:`{decl}` + is the TLS object and :samp:`{tmpl_addr}` is the address of the + initializer. The default initializes libgcc's emulated TLS control object. + +.. hook-end + +.. c:var:: bool TARGET_EMUTLS_VAR_ALIGN_FIXED + + .. hook-start:TARGET_EMUTLS_VAR_ALIGN_FIXED + + Specifies whether the alignment of TLS control variable objects is + fixed and should not be increased as some backends may do to optimize + single objects. The default is false. + +.. hook-end + +.. c:var:: bool TARGET_EMUTLS_DEBUG_FORM_TLS_ADDRESS + + .. hook-start:TARGET_EMUTLS_DEBUG_FORM_TLS_ADDRESS + + Specifies whether a DWARF ``DW_OP_form_tls_address`` location descriptor + may be used to describe emulated TLS control objects. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/implementing-the-varargs-macros.rst b/gcc/doc/gccint/target-macros/implementing-the-varargs-macros.rst new file mode 100644 index 00000000000..e64357f1505 --- /dev/null +++ b/gcc/doc/gccint/target-macros/implementing-the-varargs-macros.rst @@ -0,0 +1,192 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: varargs implementation + +.. _varargs: + +Implementing the Varargs Macros +******************************* + +GCC comes with an implementation of ```` and +```` that work without change on machines that pass arguments +on the stack. Other machines require their own implementations of +varargs, and the two machine independent header files must have +conditionals to include it. + +ISO ```` differs from traditional ```` mainly in +the calling convention for ``va_start``. The traditional +implementation takes just one argument, which is the variable in which +to store the argument pointer. The ISO implementation of +``va_start`` takes an additional second argument. The user is +supposed to write the last named argument of the function here. + +However, ``va_start`` should not use this argument. The way to find +the end of the named arguments is with the built-in functions described +below. + +.. c:macro:: __builtin_saveregs () + + Use this built-in function to save the argument registers in memory so + that the varargs mechanism can access them. Both ISO and traditional + versions of ``va_start`` must use ``__builtin_saveregs``, unless + you use ``TARGET_SETUP_INCOMING_VARARGS`` (see below) instead. + + On some machines, ``__builtin_saveregs`` is open-coded under the + control of the target hook ``TARGET_EXPAND_BUILTIN_SAVEREGS``. On + other machines, it calls a routine written in assembler language, + found in :samp:`libgcc2.c`. + + Code generated for the call to ``__builtin_saveregs`` appears at the + beginning of the function, as opposed to where the call to + ``__builtin_saveregs`` is written, regardless of what the code is. + This is because the registers must be saved before the function starts + to use them for its own purposes. + + .. i rewrote the first sentence above to fix an overfull hbox. -mew + + .. 10feb93 + +.. c:macro:: __builtin_next_arg (lastarg) + + This builtin returns the address of the first anonymous stack + argument, as type ``void *``. If ``ARGS_GROW_DOWNWARD``, it + returns the address of the location above the first anonymous stack + argument. Use it in ``va_start`` to initialize the pointer for + fetching arguments from the stack. Also use it in ``va_start`` to + verify that the second parameter :samp:`{lastarg}` is the last named argument + of the current function. + +.. c:macro:: __builtin_classify_type (object) + + Since each machine has its own conventions for which data types are + passed in which kind of register, your implementation of ``va_arg`` + has to embody these conventions. The easiest way to categorize the + specified data type is to use ``__builtin_classify_type`` together + with ``sizeof`` and ``__alignof__``. + + ``__builtin_classify_type`` ignores the value of :samp:`{object}`, + considering only its data type. It returns an integer describing what + kind of type that is---integer, floating, pointer, structure, and so on. + + The file :samp:`typeclass.h` defines an enumeration that you can use to + interpret the values of ``__builtin_classify_type``. + +These machine description macros help implement varargs: + +.. function:: rtx TARGET_EXPAND_BUILTIN_SAVEREGS (void) + + .. hook-start:TARGET_EXPAND_BUILTIN_SAVEREGS + + If defined, this hook produces the machine-specific code for a call to + ``__builtin_saveregs``. This code will be moved to the very + beginning of the function, before any parameter access are made. The + return value of this function should be an RTX that contains the value + to use as the return of ``__builtin_saveregs``. + +.. hook-end + +.. function:: void TARGET_SETUP_INCOMING_VARARGS (cumulative_args_t args_so_far, const function_arg_info &arg, int *pretend_args_size, int second_time) + + .. hook-start:TARGET_SETUP_INCOMING_VARARGS + + This target hook offers an alternative to using + ``__builtin_saveregs`` and defining the hook + ``TARGET_EXPAND_BUILTIN_SAVEREGS``. Use it to store the anonymous + register arguments into the stack so that all the arguments appear to + have been passed consecutively on the stack. Once this is done, you can + use the standard implementation of varargs that works for machines that + pass all their arguments on the stack. + + The argument :samp:`{args_so_far}` points to the ``CUMULATIVE_ARGS`` data + structure, containing the values that are obtained after processing the + named arguments. The argument :samp:`{arg}` describes the last of these named + arguments. The argument :samp:`{arg}` should not be used if the function type + satisfies ``TYPE_NO_NAMED_ARGS_STDARG_P``, since in that case there are + no named arguments and all arguments are accessed with ``va_arg``. + + The target hook should do two things: first, push onto the stack all the + argument registers *not* used for the named arguments, and second, + store the size of the data thus pushed into the ``int`` -valued + variable pointed to by :samp:`{pretend_args_size}`. The value that you + store here will serve as additional offset for setting up the stack + frame. + + Because you must generate code to push the anonymous arguments at + compile time without knowing their data types, + ``TARGET_SETUP_INCOMING_VARARGS`` is only useful on machines that + have just a single category of argument register and use it uniformly + for all data types. + + If the argument :samp:`{second_time}` is nonzero, it means that the + arguments of the function are being analyzed for the second time. This + happens for an inline function, which is not actually compiled until the + end of the source file. The hook ``TARGET_SETUP_INCOMING_VARARGS`` should + not generate any instructions in this case. + +.. hook-end + +.. function:: bool TARGET_STRICT_ARGUMENT_NAMING (cumulative_args_t ca) + + .. hook-start:TARGET_STRICT_ARGUMENT_NAMING + + Define this hook to return ``true`` if the location where a function + argument is passed depends on whether or not it is a named argument. + + This hook controls how the :samp:`{named}` argument to ``TARGET_FUNCTION_ARG`` + is set for varargs and stdarg functions. If this hook returns + ``true``, the :samp:`{named}` argument is always true for named + arguments, and false for unnamed arguments. If it returns ``false``, + but ``TARGET_PRETEND_OUTGOING_VARARGS_NAMED`` returns ``true``, + then all arguments are treated as named. Otherwise, all named arguments + except the last are treated as named. + + You need not define this hook if it always returns ``false``. + +.. hook-end + +.. function:: void TARGET_CALL_ARGS (rtx, tree) + + .. hook-start:TARGET_CALL_ARGS + + While generating RTL for a function call, this target hook is invoked once + for each argument passed to the function, either a register returned by + ``TARGET_FUNCTION_ARG`` or a memory location. It is called just + before the point where argument registers are stored. The type of the + function to be called is also passed as the second argument; it is + ``NULL_TREE`` for libcalls. The ``TARGET_END_CALL_ARGS`` hook is + invoked just after the code to copy the return reg has been emitted. + This functionality can be used to perform special setup of call argument + registers if a target needs it. + For functions without arguments, the hook is called once with ``pc_rtx`` + passed instead of an argument register. + Most ports do not need to implement anything for this hook. + +.. hook-end + +.. function:: void TARGET_END_CALL_ARGS (void) + + .. hook-start:TARGET_END_CALL_ARGS + + This target hook is invoked while generating RTL for a function call, + just after the point where the return reg is copied into a pseudo. It + signals that all the call argument and return registers for the just + emitted call are now no longer in use. + Most ports do not need to implement anything for this hook. + +.. hook-end + +.. function:: bool TARGET_PRETEND_OUTGOING_VARARGS_NAMED (cumulative_args_t ca) + + .. hook-start:TARGET_PRETEND_OUTGOING_VARARGS_NAMED + + If you need to conditionally change ABIs so that one works with + ``TARGET_SETUP_INCOMING_VARARGS``, but the other works like neither + ``TARGET_SETUP_INCOMING_VARARGS`` nor ``TARGET_STRICT_ARGUMENT_NAMING`` was + defined, then define this hook to return ``true`` if + ``TARGET_SETUP_INCOMING_VARARGS`` is used, ``false`` otherwise. + Otherwise, you should not define this hook. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/implicit-calls-to-library-routines.rst b/gcc/doc/gccint/target-macros/implicit-calls-to-library-routines.rst new file mode 100644 index 00000000000..cefd33d3814 --- /dev/null +++ b/gcc/doc/gccint/target-macros/implicit-calls-to-library-routines.rst @@ -0,0 +1,141 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: library subroutine names, libgcc.a + +.. _library-calls: + +Implicit Calls to Library Routines +********************************** + +.. prevent bad page break with this line + +Here is an explanation of implicit calls to library routines. + +.. c:macro:: DECLARE_LIBRARY_RENAMES + + This macro, if defined, should expand to a piece of C code that will get + expanded when compiling functions for libgcc.a. It can be used to + provide alternate names for GCC's internal library functions if there + are ABI-mandated names that the compiler should provide. + +.. index:: set_optab_libfunc, init_one_libfunc + +.. function:: void TARGET_INIT_LIBFUNCS (void) + + .. hook-start:TARGET_INIT_LIBFUNCS + + This hook should declare additional library routines or rename + existing ones, using the functions ``set_optab_libfunc`` and + ``init_one_libfunc`` defined in :samp:`optabs.cc`. + ``init_optabs`` calls this macro after initializing all the normal + library routines. + + The default is to do nothing. Most ports don't need to define this hook. + +.. hook-end + +.. c:var:: bool TARGET_LIBFUNC_GNU_PREFIX + + .. hook-start:TARGET_LIBFUNC_GNU_PREFIX + + If false (the default), internal library routines start with two + underscores. If set to true, these routines start with ``__gnu_`` + instead. E.g., ``__muldi3`` changes to ``__gnu_muldi3``. This + currently only affects functions defined in :samp:`libgcc2.c`. If this + is set to true, the :samp:`tm.h` file must also + ``#define LIBGCC2_GNU_PREFIX``. + +.. hook-end + +.. c:macro:: FLOAT_LIB_COMPARE_RETURNS_BOOL (mode, comparison) + + This macro should return ``true`` if the library routine that + implements the floating point comparison operator :samp:`{comparison}` in + mode :samp:`{mode}` will return a boolean, and :samp:`{false}` if it will + return a tristate. + + GCC's own floating point libraries return tristates from the + comparison operators, so the default returns false always. Most ports + don't need to define this macro. + +.. c:macro:: TARGET_LIB_INT_CMP_BIASED + + This macro should evaluate to ``true`` if the integer comparison + functions (like ``__cmpdi2``) return 0 to indicate that the first + operand is smaller than the second, 1 to indicate that they are equal, + and 2 to indicate that the first operand is greater than the second. + If this macro evaluates to ``false`` the comparison functions return + -1, 0, and 1 instead of 0, 1, and 2. If the target uses the routines + in :samp:`libgcc.a`, you do not need to define this macro. + +.. c:macro:: TARGET_HAS_NO_HW_DIVIDE + + This macro should be defined if the target has no hardware divide + instructions. If this macro is defined, GCC will use an algorithm which + make use of simple logical and arithmetic operations for 64-bit + division. If the macro is not defined, GCC will use an algorithm which + make use of a 64-bit by 32-bit divide primitive. + +.. index:: EDOM, implicit usage, matherr + +.. c:macro:: TARGET_EDOM + + The value of ``EDOM`` on the target machine, as a C integer constant + expression. If you don't define this macro, GCC does not attempt to + deposit the value of ``EDOM`` into ``errno`` directly. Look in + :samp:`/usr/include/errno.h` to find the value of ``EDOM`` on your + system. + + If you do not define ``TARGET_EDOM``, then compiled code reports + domain errors by calling the library function and letting it report the + error. If mathematical functions on your system use ``matherr`` when + there is an error, then you should leave ``TARGET_EDOM`` undefined so + that ``matherr`` is used normally. + +.. index:: errno, implicit usage + +.. c:macro:: GEN_ERRNO_RTX + + Define this macro as a C expression to create an rtl expression that + refers to the global 'variable' ``errno``. (On certain systems, + ``errno`` may not actually be a variable.) If you don't define this + macro, a reasonable default is used. + +.. function:: bool TARGET_LIBC_HAS_FUNCTION (enum function_class fn_class, tree type) + + .. hook-start:TARGET_LIBC_HAS_FUNCTION + + This hook determines whether a function from a class of functions + :samp:`{fn_class}` is present in the target C library. If :samp:`{type}` is NULL, + the caller asks for support for all standard (float, double, long double) + types. If :samp:`{type}` is non-NULL, the caller asks for support for a + specific type. + +.. hook-end + +.. function:: bool TARGET_LIBC_HAS_FAST_FUNCTION (int fcode) + + .. hook-start:TARGET_LIBC_HAS_FAST_FUNCTION + + This hook determines whether a function from a class of functions + ``(enum function_class)``:samp:`{fcode}` has a fast implementation. + +.. hook-end + +.. c:macro:: NEXT_OBJC_RUNTIME + + Set this macro to 1 to use the "NeXT" Objective-C message sending conventions + by default. This calling convention involves passing the object, the selector + and the method arguments all at once to the method-lookup library function. + This is the usual setting when targeting Darwin/Mac OS X systems, which have + the NeXT runtime installed. + + If the macro is set to 0, the "GNU" Objective-C message sending convention + will be used by default. This convention passes just the object and the + selector to the method-lookup function, which returns a pointer to the method. + + In either case, it remains possible to select code-generation for the alternate + scheme, by means of compiler command line switches. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/layout-of-source-language-data-types.rst b/gcc/doc/gccint/target-macros/layout-of-source-language-data-types.rst new file mode 100644 index 00000000000..082293c6b4f --- /dev/null +++ b/gcc/doc/gccint/target-macros/layout-of-source-language-data-types.rst @@ -0,0 +1,355 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _type-layout: + +Layout of Source Language Data Types +************************************ + +These macros define the sizes and other characteristics of the standard +basic data types used in programs being compiled. Unlike the macros in +the previous section, these apply to specific features of C and related +languages, rather than to fundamental aspects of storage layout. + +.. c:macro:: INT_TYPE_SIZE + + A C expression for the size in bits of the type ``int`` on the + target machine. If you don't define this, the default is one word. + +.. c:macro:: SHORT_TYPE_SIZE + + A C expression for the size in bits of the type ``short`` on the + target machine. If you don't define this, the default is half a word. + (If this would be less than one storage unit, it is rounded up to one + unit.) + +.. c:macro:: LONG_TYPE_SIZE + + A C expression for the size in bits of the type ``long`` on the + target machine. If you don't define this, the default is one word. + +.. c:macro:: ADA_LONG_TYPE_SIZE + + On some machines, the size used for the Ada equivalent of the type + ``long`` by a native Ada compiler differs from that used by C. In + that situation, define this macro to be a C expression to be used for + the size of that type. If you don't define this, the default is the + value of ``LONG_TYPE_SIZE``. + +.. c:macro:: LONG_LONG_TYPE_SIZE + + A C expression for the size in bits of the type ``long long`` on the + target machine. If you don't define this, the default is two + words. If you want to support GNU Ada on your machine, the value of this + macro must be at least 64. + +.. c:macro:: CHAR_TYPE_SIZE + + A C expression for the size in bits of the type ``char`` on the + target machine. If you don't define this, the default is + ``BITS_PER_UNIT``. + +.. c:macro:: BOOL_TYPE_SIZE + + A C expression for the size in bits of the C++ type ``bool`` and + C99 type ``_Bool`` on the target machine. If you don't define + this, and you probably shouldn't, the default is ``CHAR_TYPE_SIZE``. + +.. c:macro:: FLOAT_TYPE_SIZE + + A C expression for the size in bits of the type ``float`` on the + target machine. If you don't define this, the default is one word. + +.. c:macro:: DOUBLE_TYPE_SIZE + + A C expression for the size in bits of the type ``double`` on the + target machine. If you don't define this, the default is two + words. + +.. c:macro:: LONG_DOUBLE_TYPE_SIZE + + A C expression for the size in bits of the type ``long double`` on + the target machine. If you don't define this, the default is two + words. + +.. c:macro:: SHORT_FRACT_TYPE_SIZE + + A C expression for the size in bits of the type ``short _Fract`` on + the target machine. If you don't define this, the default is + ``BITS_PER_UNIT``. + +.. c:macro:: FRACT_TYPE_SIZE + + A C expression for the size in bits of the type ``_Fract`` on + the target machine. If you don't define this, the default is + ``BITS_PER_UNIT * 2``. + +.. c:macro:: LONG_FRACT_TYPE_SIZE + + A C expression for the size in bits of the type ``long _Fract`` on + the target machine. If you don't define this, the default is + ``BITS_PER_UNIT * 4``. + +.. c:macro:: LONG_LONG_FRACT_TYPE_SIZE + + A C expression for the size in bits of the type ``long long _Fract`` on + the target machine. If you don't define this, the default is + ``BITS_PER_UNIT * 8``. + +.. c:macro:: SHORT_ACCUM_TYPE_SIZE + + A C expression for the size in bits of the type ``short _Accum`` on + the target machine. If you don't define this, the default is + ``BITS_PER_UNIT * 2``. + +.. c:macro:: ACCUM_TYPE_SIZE + + A C expression for the size in bits of the type ``_Accum`` on + the target machine. If you don't define this, the default is + ``BITS_PER_UNIT * 4``. + +.. c:macro:: LONG_ACCUM_TYPE_SIZE + + A C expression for the size in bits of the type ``long _Accum`` on + the target machine. If you don't define this, the default is + ``BITS_PER_UNIT * 8``. + +.. c:macro:: LONG_LONG_ACCUM_TYPE_SIZE + + A C expression for the size in bits of the type ``long long _Accum`` on + the target machine. If you don't define this, the default is + ``BITS_PER_UNIT * 16``. + +.. c:macro:: LIBGCC2_GNU_PREFIX + + This macro corresponds to the ``TARGET_LIBFUNC_GNU_PREFIX`` target + hook and should be defined if that hook is overriden to be true. It + causes function names in libgcc to be changed to use a ``__gnu_`` + prefix for their name rather than the default ``__``. A port which + uses this macro should also arrange to use :samp:`t-gnu-prefix` in + the libgcc :samp:`config.host`. + +.. c:macro:: WIDEST_HARDWARE_FP_SIZE + + A C expression for the size in bits of the widest floating-point format + supported by the hardware. If you define this macro, you must specify a + value less than or equal to the value of ``LONG_DOUBLE_TYPE_SIZE``. + If you do not define this macro, the value of ``LONG_DOUBLE_TYPE_SIZE`` + is the default. + +.. c:macro:: DEFAULT_SIGNED_CHAR + + An expression whose value is 1 or 0, according to whether the type + ``char`` should be signed or unsigned by default. The user can + always override this default with the options :option:`-fsigned-char` + and :option:`-funsigned-char`. + +.. function:: bool TARGET_DEFAULT_SHORT_ENUMS (void) + + .. hook-start:TARGET_DEFAULT_SHORT_ENUMS + + This target hook should return true if the compiler should give an + ``enum`` type only as many bytes as it takes to represent the range + of possible values of that type. It should return false if all + ``enum`` types should be allocated like ``int``. + + The default is to return false. + +.. hook-end + +.. c:macro:: SIZE_TYPE + + A C expression for a string describing the name of the data type to use + for size values. The typedef name ``size_t`` is defined using the + contents of the string. + + The string can contain more than one keyword. If so, separate them with + spaces, and write first any length keyword, then ``unsigned`` if + appropriate, and finally ``int``. The string must exactly match one + of the data type names defined in the function + ``c_common_nodes_and_builtins`` in the file :samp:`c-family/c-common.cc`. + You may not omit ``int`` or change the order---that would cause the + compiler to crash on startup. + + If you don't define this macro, the default is ``"long unsigned + int"``. + +.. c:macro:: SIZETYPE + + GCC defines internal types (``sizetype``, ``ssizetype``, + ``bitsizetype`` and ``sbitsizetype``) for expressions + dealing with size. This macro is a C expression for a string describing + the name of the data type from which the precision of ``sizetype`` + is extracted. + + The string has the same restrictions as ``SIZE_TYPE`` string. + + If you don't define this macro, the default is ``SIZE_TYPE``. + +.. c:macro:: PTRDIFF_TYPE + + A C expression for a string describing the name of the data type to use + for the result of subtracting two pointers. The typedef name + ``ptrdiff_t`` is defined using the contents of the string. See + ``SIZE_TYPE`` above for more information. + + If you don't define this macro, the default is ``"long int"``. + +.. c:macro:: WCHAR_TYPE + + A C expression for a string describing the name of the data type to use + for wide characters. The typedef name ``wchar_t`` is defined using + the contents of the string. See ``SIZE_TYPE`` above for more + information. + + If you don't define this macro, the default is ``"int"``. + +.. c:macro:: WCHAR_TYPE_SIZE + + A C expression for the size in bits of the data type for wide + characters. This is used in ``cpp``, which cannot make use of + ``WCHAR_TYPE``. + +.. c:macro:: WINT_TYPE + + A C expression for a string describing the name of the data type to + use for wide characters passed to ``printf`` and returned from + ``getwc``. The typedef name ``wint_t`` is defined using the + contents of the string. See ``SIZE_TYPE`` above for more + information. + + If you don't define this macro, the default is ``"unsigned int"``. + +.. c:macro:: INTMAX_TYPE + + A C expression for a string describing the name of the data type that + can represent any value of any standard or extended signed integer type. + The typedef name ``intmax_t`` is defined using the contents of the + string. See ``SIZE_TYPE`` above for more information. + + If you don't define this macro, the default is the first of + ``"int"``, ``"long int"``, or ``"long long int"`` that has as + much precision as ``long long int``. + +.. c:macro:: UINTMAX_TYPE + + A C expression for a string describing the name of the data type that + can represent any value of any standard or extended unsigned integer + type. The typedef name ``uintmax_t`` is defined using the contents + of the string. See ``SIZE_TYPE`` above for more information. + + If you don't define this macro, the default is the first of + ``"unsigned int"``, ``"long unsigned int"``, or ``"long long + unsigned int"`` that has as much precision as ``long long unsigned + int``. + +.. c:macro:: SIG_ATOMIC_TYPE + INT8_TYPE + INT16_TYPE + INT32_TYPE + INT64_TYPE + UINT8_TYPE + UINT16_TYPE + UINT32_TYPE + UINT64_TYPE + INT_LEAST8_TYPE + INT_LEAST16_TYPE + INT_LEAST32_TYPE + INT_LEAST64_TYPE + UINT_LEAST8_TYPE + UINT_LEAST16_TYPE + UINT_LEAST32_TYPE + UINT_LEAST64_TYPE + INT_FAST8_TYPE + INT_FAST16_TYPE + INT_FAST32_TYPE + INT_FAST64_TYPE + UINT_FAST8_TYPE + UINT_FAST16_TYPE + UINT_FAST32_TYPE + UINT_FAST64_TYPE + INTPTR_TYPE + UINTPTR_TYPE + + C expressions for the standard types ``sig_atomic_t``, + ``int8_t``, ``int16_t``, ``int32_t``, ``int64_t``, + ``uint8_t``, ``uint16_t``, ``uint32_t``, ``uint64_t``, + ``int_least8_t``, ``int_least16_t``, ``int_least32_t``, + ``int_least64_t``, ``uint_least8_t``, ``uint_least16_t``, + ``uint_least32_t``, ``uint_least64_t``, ``int_fast8_t``, + ``int_fast16_t``, ``int_fast32_t``, ``int_fast64_t``, + ``uint_fast8_t``, ``uint_fast16_t``, ``uint_fast32_t``, + ``uint_fast64_t``, ``intptr_t``, and ``uintptr_t``. See + ``SIZE_TYPE`` above for more information. + + If any of these macros evaluates to a null pointer, the corresponding + type is not supported; if GCC is configured to provide + ```` in such a case, the header provided may not conform + to C99, depending on the type in question. The defaults for all of + these macros are null pointers. + +.. c:macro:: TARGET_PTRMEMFUNC_VBIT_LOCATION + + The C++ compiler represents a pointer-to-member-function with a struct + that looks like: + + .. code-block:: c++ + + struct { + union { + void (*fn)(); + ptrdiff_t vtable_index; + }; + ptrdiff_t delta; + }; + + The C++ compiler must use one bit to indicate whether the function that + will be called through a pointer-to-member-function is virtual. + Normally, we assume that the low-order bit of a function pointer must + always be zero. Then, by ensuring that the vtable_index is odd, we can + distinguish which variant of the union is in use. But, on some + platforms function pointers can be odd, and so this doesn't work. In + that case, we use the low-order bit of the ``delta`` field, and shift + the remainder of the ``delta`` field to the left. + + GCC will automatically make the right selection about where to store + this bit using the ``FUNCTION_BOUNDARY`` setting for your platform. + However, some platforms such as ARM/Thumb have ``FUNCTION_BOUNDARY`` + set such that functions always start at even addresses, but the lowest + bit of pointers to functions indicate whether the function at that + address is in ARM or Thumb mode. If this is the case of your + architecture, you should define this macro to + ``ptrmemfunc_vbit_in_delta``. + + In general, you should not have to define this macro. On architectures + in which function addresses are always even, according to + ``FUNCTION_BOUNDARY``, GCC will automatically define this macro to + ``ptrmemfunc_vbit_in_pfn``. + +.. c:macro:: TARGET_VTABLE_USES_DESCRIPTORS + + Normally, the C++ compiler uses function pointers in vtables. This + macro allows the target to change to use 'function descriptors' + instead. Function descriptors are found on targets for whom a + function pointer is actually a small data structure. Normally the + data structure consists of the actual code address plus a data + pointer to which the function's data is relative. + + If vtables are used, the value of this macro should be the number + of words that the function descriptor occupies. + +.. c:macro:: TARGET_VTABLE_ENTRY_ALIGN + + By default, the vtable entries are void pointers, the so the alignment + is the same as pointer alignment. The value of this macro specifies + the alignment of the vtable entry in bits. It should be defined only + when special alignment is necessary. \*/ + +.. c:macro:: TARGET_VTABLE_DATA_ENTRY_DISTANCE + + There are a few non-descriptor entries in the vtable at offsets below + zero. If these entries must be padded (say, to preserve the alignment + specified by ``TARGET_VTABLE_ENTRY_ALIGN``), set this to the number + of words in each data entry. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/miscellaneous-parameters.rst b/gcc/doc/gccint/target-macros/miscellaneous-parameters.rst new file mode 100644 index 00000000000..4476d3e8f74 --- /dev/null +++ b/gcc/doc/gccint/target-macros/miscellaneous-parameters.rst @@ -0,0 +1,1718 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: parameters, miscellaneous + +.. _misc: + +Miscellaneous Parameters +************************ + +.. prevent bad page break with this line + +Here are several miscellaneous parameters. + +.. c:macro:: HAS_LONG_COND_BRANCH + + Define this boolean macro to indicate whether or not your architecture + has conditional branches that can span all of memory. It is used in + conjunction with an optimization that partitions hot and cold basic + blocks into separate sections of the executable. If this macro is + set to false, gcc will convert any conditional branches that attempt + to cross between sections into unconditional branches or indirect jumps. + +.. c:macro:: HAS_LONG_UNCOND_BRANCH + + Define this boolean macro to indicate whether or not your architecture + has unconditional branches that can span all of memory. It is used in + conjunction with an optimization that partitions hot and cold basic + blocks into separate sections of the executable. If this macro is + set to false, gcc will convert any unconditional branches that attempt + to cross between sections into indirect jumps. + +.. c:macro:: CASE_VECTOR_MODE + + An alias for a machine mode name. This is the machine mode that + elements of a jump-table should have. + +.. c:macro:: CASE_VECTOR_SHORTEN_MODE (min_offset, max_offset, body) + + Optional: return the preferred mode for an ``addr_diff_vec`` + when the minimum and maximum offset are known. If you define this, + it enables extra code in branch shortening to deal with ``addr_diff_vec``. + To make this work, you also have to define ``INSN_ALIGN`` and + make the alignment for ``addr_diff_vec`` explicit. + The :samp:`{body}` argument is provided so that the offset_unsigned and scale + flags can be updated. + +.. c:macro:: CASE_VECTOR_PC_RELATIVE + + Define this macro to be a C expression to indicate when jump-tables + should contain relative addresses. You need not define this macro if + jump-tables never contain relative addresses, or jump-tables should + contain relative addresses only when :option:`-fPIC` or :option:`-fPIC` + is in effect. + +.. function:: unsigned int TARGET_CASE_VALUES_THRESHOLD (void) + + .. hook-start:TARGET_CASE_VALUES_THRESHOLD + + This function return the smallest number of different values for which it + is best to use a jump-table instead of a tree of conditional branches. + The default is four for machines with a ``casesi`` instruction and + five otherwise. This is best for most machines. + +.. hook-end + +.. c:macro:: WORD_REGISTER_OPERATIONS + + Define this macro to 1 if operations between registers with integral mode + smaller than a word are always performed on the entire register. To be + more explicit, if you start with a pair of ``word_mode`` registers with + known values and you do a subword, for example ``QImode``, addition on + the low part of the registers, then the compiler may consider that the + result has a known value in ``word_mode`` too if the macro is defined + to 1. Most RISC machines have this property and most CISC machines do not. + +.. function:: unsigned int TARGET_MIN_ARITHMETIC_PRECISION (void) + + .. hook-start:TARGET_MIN_ARITHMETIC_PRECISION + + On some RISC architectures with 64-bit registers, the processor also + maintains 32-bit condition codes that make it possible to do real 32-bit + arithmetic, although the operations are performed on the full registers. + + On such architectures, defining this hook to 32 tells the compiler to try + using 32-bit arithmetical operations setting the condition codes instead + of doing full 64-bit arithmetic. + + More generally, define this hook on RISC architectures if you want the + compiler to try using arithmetical operations setting the condition codes + with a precision lower than the word precision. + + You need not define this hook if ``WORD_REGISTER_OPERATIONS`` is not + defined to 1. + +.. hook-end + +.. c:macro:: LOAD_EXTEND_OP (mem_mode) + + Define this macro to be a C expression indicating when insns that read + memory in :samp:`{mem_mode}`, an integral mode narrower than a word, set the + bits outside of :samp:`{mem_mode}` to be either the sign-extension or the + zero-extension of the data read. Return ``SIGN_EXTEND`` for values + of :samp:`{mem_mode}` for which the + insn sign-extends, ``ZERO_EXTEND`` for which it zero-extends, and + ``UNKNOWN`` for other modes. + + This macro is not called with :samp:`{mem_mode}` non-integral or with a width + greater than or equal to ``BITS_PER_WORD``, so you may return any + value in this case. Do not define this macro if it would always return + ``UNKNOWN``. On machines where this macro is defined, you will normally + define it as the constant ``SIGN_EXTEND`` or ``ZERO_EXTEND``. + + You may return a non- ``UNKNOWN`` value even if for some hard registers + the sign extension is not performed, if for the ``REGNO_REG_CLASS`` + of these hard registers ``TARGET_CAN_CHANGE_MODE_CLASS`` returns false + when the :samp:`{from}` mode is :samp:`{mem_mode}` and the :samp:`{to}` mode is any + integral mode larger than this but not larger than ``word_mode``. + + You must return ``UNKNOWN`` if for some hard registers that allow this + mode, ``TARGET_CAN_CHANGE_MODE_CLASS`` says that they cannot change to + ``word_mode``, but that they can change to another integral mode that + is larger then :samp:`{mem_mode}` but still smaller than ``word_mode``. + +.. c:macro:: SHORT_IMMEDIATES_SIGN_EXTEND + + Define this macro to 1 if loading short immediate values into registers sign + extends. + +.. function:: unsigned int TARGET_MIN_DIVISIONS_FOR_RECIP_MUL (machine_mode mode) + + .. hook-start:TARGET_MIN_DIVISIONS_FOR_RECIP_MUL + + When :option:`-ffast-math` is in effect, GCC tries to optimize + divisions by the same divisor, by turning them into multiplications by + the reciprocal. This target hook specifies the minimum number of divisions + that should be there for GCC to perform the optimization for a variable + of mode :samp:`{mode}`. The default implementation returns 3 if the machine + has an instruction for the division, and 2 if it does not. + +.. hook-end + +.. c:macro:: MOVE_MAX + + The maximum number of bytes that a single instruction can move quickly + between memory and registers or between two memory locations. + +.. c:macro:: MAX_MOVE_MAX + + The maximum number of bytes that a single instruction can move quickly + between memory and registers or between two memory locations. If this + is undefined, the default is ``MOVE_MAX``. Otherwise, it is the + constant value that is the largest value that ``MOVE_MAX`` can have + at run-time. + +.. c:macro:: SHIFT_COUNT_TRUNCATED + + A C expression that is nonzero if on this machine the number of bits + actually used for the count of a shift operation is equal to the number + of bits needed to represent the size of the object being shifted. When + this macro is nonzero, the compiler will assume that it is safe to omit + a sign-extend, zero-extend, and certain bitwise 'and' instructions that + truncates the count of a shift operation. On machines that have + instructions that act on bit-fields at variable positions, which may + include 'bit test' instructions, a nonzero ``SHIFT_COUNT_TRUNCATED`` + also enables deletion of truncations of the values that serve as + arguments to bit-field instructions. + + If both types of instructions truncate the count (for shifts) and + position (for bit-field operations), or if no variable-position bit-field + instructions exist, you should define this macro. + + However, on some machines, such as the 80386 and the 680x0, truncation + only applies to shift operations and not the (real or pretended) + bit-field operations. Define ``SHIFT_COUNT_TRUNCATED`` to be zero on + such machines. Instead, add patterns to the :samp:`md` file that include + the implied truncation of the shift instructions. + + You need not define this macro if it would always have the value of zero. + +.. _target_shift_truncation_mask: + +.. function:: unsigned HOST_WIDE_INT TARGET_SHIFT_TRUNCATION_MASK (machine_mode mode) + + .. hook-start:TARGET_SHIFT_TRUNCATION_MASK + + This function describes how the standard shift patterns for :samp:`{mode}` + deal with shifts by negative amounts or by more than the width of the mode. + See :ref:`shift-patterns`. + + On many machines, the shift patterns will apply a mask :samp:`{m}` to the + shift count, meaning that a fixed-width shift of :samp:`{x}` by :samp:`{y}` is + equivalent to an arbitrary-width shift of :samp:`{x}` by :samp:`{y & m}`. If + this is true for mode :samp:`{mode}`, the function should return :samp:`{m}`, + otherwise it should return 0. A return value of 0 indicates that no + particular behavior is guaranteed. + + Note that, unlike ``SHIFT_COUNT_TRUNCATED``, this function does + *not* apply to general shift rtxes; it applies only to instructions + that are generated by the named shift patterns. + + The default implementation of this function returns + ``GET_MODE_BITSIZE (mode) - 1`` if ``SHIFT_COUNT_TRUNCATED`` + and 0 otherwise. This definition is always safe, but if + ``SHIFT_COUNT_TRUNCATED`` is false, and some shift patterns + nevertheless truncate the shift count, you may get better code + by overriding it. + +.. hook-end + +.. function:: bool TARGET_TRULY_NOOP_TRUNCATION (poly_uint64 outprec, poly_uint64 inprec) + + .. hook-start:TARGET_TRULY_NOOP_TRUNCATION + + This hook returns true if it is safe to 'convert' a value of + :samp:`{inprec}` bits to one of :samp:`{outprec}` bits (where :samp:`{outprec}` is + smaller than :samp:`{inprec}`) by merely operating on it as if it had only + :samp:`{outprec}` bits. The default returns true unconditionally, which + is correct for most machines. When ``TARGET_TRULY_NOOP_TRUNCATION`` + returns false, the machine description should provide a ``trunc`` + optab to specify the RTL that performs the required truncation. + + If ``TARGET_MODES_TIEABLE_P`` returns false for a pair of modes, + suboptimal code can result if this hook returns true for the corresponding + mode sizes. Making this hook return false in such cases may improve things. + +.. hook-end + +.. function:: int TARGET_MODE_REP_EXTENDED (scalar_int_mode mode, scalar_int_mode rep_mode) + + .. hook-start:TARGET_MODE_REP_EXTENDED + + The representation of an integral mode can be such that the values + are always extended to a wider integral mode. Return + ``SIGN_EXTEND`` if values of :samp:`{mode}` are represented in + sign-extended form to :samp:`{rep_mode}`. Return ``UNKNOWN`` + otherwise. (Currently, none of the targets use zero-extended + representation this way so unlike ``LOAD_EXTEND_OP``, + ``TARGET_MODE_REP_EXTENDED`` is expected to return either + ``SIGN_EXTEND`` or ``UNKNOWN``. Also no target extends + :samp:`{mode}` to :samp:`{rep_mode}` so that :samp:`{rep_mode}` is not the next + widest integral mode and currently we take advantage of this fact.) + + Similarly to ``LOAD_EXTEND_OP`` you may return a non- ``UNKNOWN`` + value even if the extension is not performed on certain hard registers + as long as for the ``REGNO_REG_CLASS`` of these hard registers + ``TARGET_CAN_CHANGE_MODE_CLASS`` returns false. + + Note that ``TARGET_MODE_REP_EXTENDED`` and ``LOAD_EXTEND_OP`` + describe two related properties. If you define + ``TARGET_MODE_REP_EXTENDED (mode, word_mode)`` you probably also want + to define ``LOAD_EXTEND_OP (mode)`` to return the same type of + extension. + + In order to enforce the representation of ``mode``, + ``TARGET_TRULY_NOOP_TRUNCATION`` should return false when truncating to + ``mode``. + +.. hook-end + +.. function:: bool TARGET_SETJMP_PRESERVES_NONVOLATILE_REGS_P (void) + + .. hook-start:TARGET_SETJMP_PRESERVES_NONVOLATILE_REGS_P + + On some targets, it is assumed that the compiler will spill all pseudos + that are live across a call to ``setjmp``, while other targets treat + ``setjmp`` calls as normal function calls. + + This hook returns false if ``setjmp`` calls do not preserve all + non-volatile registers so that gcc that must spill all pseudos that are + live across ``setjmp`` calls. Define this to return true if the + target does not need to spill all pseudos live across ``setjmp`` calls. + The default implementation conservatively assumes all pseudos must be + spilled across ``setjmp`` calls. + +.. hook-end + +.. c:macro:: STORE_FLAG_VALUE + + A C expression describing the value returned by a comparison operator + with an integral mode and stored by a store-flag instruction + (:samp:`cstore{mode}4`) when the condition is true. This description must + apply to *all* the :samp:`cstore{mode}4` patterns and all the + comparison operators whose results have a ``MODE_INT`` mode. + + A value of 1 or -1 means that the instruction implementing the + comparison operator returns exactly 1 or -1 when the comparison is true + and 0 when the comparison is false. Otherwise, the value indicates + which bits of the result are guaranteed to be 1 when the comparison is + true. This value is interpreted in the mode of the comparison + operation, which is given by the mode of the first operand in the + :samp:`cstore{mode}4` pattern. Either the low bit or the sign bit of + ``STORE_FLAG_VALUE`` be on. Presently, only those bits are used by + the compiler. + + If ``STORE_FLAG_VALUE`` is neither 1 or -1, the compiler will + generate code that depends only on the specified bits. It can also + replace comparison operators with equivalent operations if they cause + the required bits to be set, even if the remaining bits are undefined. + For example, on a machine whose comparison operators return an + ``SImode`` value and where ``STORE_FLAG_VALUE`` is defined as + :samp:`0x80000000`, saying that just the sign bit is relevant, the + expression + + .. code-block:: c++ + + (ne:SI (and:SI x (const_int power-of-2)) (const_int 0)) + + can be converted to + + .. code-block:: c++ + + (ashift:SI x (const_int n)) + + where :samp:`{n}` is the appropriate shift count to move the bit being + tested into the sign bit. + + There is no way to describe a machine that always sets the low-order bit + for a true value, but does not guarantee the value of any other bits, + but we do not know of any machine that has such an instruction. If you + are trying to port GCC to such a machine, include an instruction to + perform a logical-and of the result with 1 in the pattern for the + comparison operators and let us know at gcc@gcc.gnu.org. + + Often, a machine will have multiple instructions that obtain a value + from a comparison (or the condition codes). Here are rules to guide the + choice of value for ``STORE_FLAG_VALUE``, and hence the instructions + to be used: + + * Use the shortest sequence that yields a valid definition for + ``STORE_FLAG_VALUE``. It is more efficient for the compiler to + 'normalize' the value (convert it to, e.g., 1 or 0) than for the + comparison operators to do so because there may be opportunities to + combine the normalization with other operations. + + * For equal-length sequences, use a value of 1 or -1, with -1 being + slightly preferred on machines with expensive jumps and 1 preferred on + other machines. + + * As a second choice, choose a value of :samp:`0x80000001` if instructions + exist that set both the sign and low-order bits but do not define the + others. + + * Otherwise, use a value of :samp:`0x80000000`. + + Many machines can produce both the value chosen for + ``STORE_FLAG_VALUE`` and its negation in the same number of + instructions. On those machines, you should also define a pattern for + those cases, e.g., one matching + + .. code-block:: c++ + + (set A (neg:m (ne:m B C))) + + Some machines can also perform ``and`` or ``plus`` operations on + condition code values with less instructions than the corresponding + :samp:`cstore{mode}4` insn followed by ``and`` or ``plus``. On those + machines, define the appropriate patterns. Use the names ``incscc`` + and ``decscc``, respectively, for the patterns which perform + ``plus`` or ``minus`` operations on condition code values. See + :samp:`rs6000.md` for some examples. The GNU Superoptimizer can be used to + find such instruction sequences on other machines. + + If this macro is not defined, the default value, 1, is used. You need + not define ``STORE_FLAG_VALUE`` if the machine has no store-flag + instructions, or if the value generated by these instructions is 1. + +.. c:macro:: FLOAT_STORE_FLAG_VALUE (mode) + + A C expression that gives a nonzero ``REAL_VALUE_TYPE`` value that is + returned when comparison operators with floating-point results are true. + Define this macro on machines that have comparison operations that return + floating-point values. If there are no such operations, do not define + this macro. + +.. c:macro:: VECTOR_STORE_FLAG_VALUE (mode) + + A C expression that gives an rtx representing the nonzero true element + for vector comparisons. The returned rtx should be valid for the inner + mode of :samp:`{mode}` which is guaranteed to be a vector mode. Define + this macro on machines that have vector comparison operations that + return a vector result. If there are no such operations, do not define + this macro. Typically, this macro is defined as ``const1_rtx`` or + ``constm1_rtx``. This macro may return ``NULL_RTX`` to prevent + the compiler optimizing such vector comparison operations for the + given mode. + +.. c:macro:: CLZ_DEFINED_VALUE_AT_ZERO (mode, value) + +.. c:macro:: CTZ_DEFINED_VALUE_AT_ZERO (mode, value) + + A C expression that indicates whether the architecture defines a value + for ``clz`` or ``ctz`` with a zero operand. + A result of ``0`` indicates the value is undefined. + If the value is defined for only the RTL expression, the macro should + evaluate to ``1`` ; if the value applies also to the corresponding optab + entry (which is normally the case if it expands directly into + the corresponding RTL), then the macro should evaluate to ``2``. + In the cases where the value is defined, :samp:`{value}` should be set to + this value. + + If this macro is not defined, the value of ``clz`` or + ``ctz`` at zero is assumed to be undefined. + + This macro must be defined if the target's expansion for ``ffs`` + relies on a particular value to get correct results. Otherwise it + is not necessary, though it may be used to optimize some corner cases, and + to provide a default expansion for the ``ffs`` optab. + + Note that regardless of this macro the 'definedness' of ``clz`` + and ``ctz`` at zero do *not* extend to the builtin functions + visible to the user. Thus one may be free to adjust the value at will + to match the target expansion of these operations without fear of + breaking the API. + +.. c:macro:: Pmode + + An alias for the machine mode for pointers. On most machines, define + this to be the integer mode corresponding to the width of a hardware + pointer; ``SImode`` on 32-bit machine or ``DImode`` on 64-bit machines. + On some machines you must define this to be one of the partial integer + modes, such as ``PSImode``. + + The width of ``Pmode`` must be at least as large as the value of + ``POINTER_SIZE``. If it is not equal, you must define the macro + ``POINTERS_EXTEND_UNSIGNED`` to specify how pointers are extended + to ``Pmode``. + +.. c:macro:: FUNCTION_MODE + + An alias for the machine mode used for memory references to functions + being called, in ``call`` RTL expressions. On most CISC machines, + where an instruction can begin at any byte address, this should be + ``QImode``. On most RISC machines, where all instructions have fixed + size and alignment, this should be a mode with the same size and alignment + as the machine instruction words - typically ``SImode`` or ``HImode``. + +.. c:macro:: STDC_0_IN_SYSTEM_HEADERS + + In normal operation, the preprocessor expands ``__STDC__`` to the + constant 1, to signify that GCC conforms to ISO Standard C. On some + hosts, like Solaris, the system compiler uses a different convention, + where ``__STDC__`` is normally 0, but is 1 if the user specifies + strict conformance to the C Standard. + + Defining ``STDC_0_IN_SYSTEM_HEADERS`` makes GNU CPP follows the host + convention when processing system header files, but when processing user + files ``__STDC__`` will always expand to 1. + +.. function:: const char * TARGET_C_PREINCLUDE (void) + + .. hook-start:TARGET_C_PREINCLUDE + + Define this hook to return the name of a header file to be included at + the start of all compilations, as if it had been included with + ``#include ``. If this hook returns ``NULL``, or is + not defined, or the header is not found, or if the user specifies + :option:`-ffreestanding` or :option:`-nostdinc`, no header is included. + + This hook can be used together with a header provided by the system C + library to implement ISO C requirements for certain macros to be + predefined that describe properties of the whole implementation rather + than just the compiler. + +.. hook-end + +.. function:: bool TARGET_CXX_IMPLICIT_EXTERN_C (const char*) + + .. hook-start:TARGET_CXX_IMPLICIT_EXTERN_C + + Define this hook to add target-specific C++ implicit extern C functions. + If this function returns true for the name of a file-scope function, that + function implicitly gets extern "C" linkage rather than whatever language + linkage the declaration would normally have. An example of such function + is WinMain on Win32 targets. + +.. hook-end + +.. c:macro:: SYSTEM_IMPLICIT_EXTERN_C + + Define this macro if the system header files do not support C++. + This macro handles system header files by pretending that system + header files are enclosed in :samp:`extern "C" {...}`. + +.. index:: #pragma, pragma + +.. c:macro:: REGISTER_TARGET_PRAGMAS () + + Define this macro if you want to implement any target-specific pragmas. + If defined, it is a C expression which makes a series of calls to + ``c_register_pragma`` or ``c_register_pragma_with_expansion`` + for each pragma. The macro may also do any + setup required for the pragmas. + + The primary reason to define this macro is to provide compatibility with + other compilers for the same target. In general, we discourage + definition of target-specific pragmas for GCC. + + If the pragma can be implemented by attributes then you should consider + defining the target hook :samp:`TARGET_INSERT_ATTRIBUTES` as well. + + Preprocessor macros that appear on pragma lines are not expanded. All + :samp:`#pragma` directives that do not match any registered pragma are + silently ignored, unless the user specifies :option:`-Wunknown-pragmas`. + +.. function:: void c_register_pragma (const char *space, const char *name, void (*callback) (struct cpp_reader *)) + + Each call to ``c_register_pragma`` or + ``c_register_pragma_with_expansion`` establishes one pragma. The + :samp:`{callback}` routine will be called when the preprocessor encounters a + pragma of the form + + .. code-block:: c++ + + #pragma [space] name ... + + :samp:`{space}` is the case-sensitive namespace of the pragma, or + ``NULL`` to put the pragma in the global namespace. The callback + routine receives :samp:`{pfile}` as its first argument, which can be passed + on to cpplib's functions if necessary. You can lex tokens after the + :samp:`{name}` by calling ``pragma_lex``. Tokens that are not read by the + callback will be silently ignored. The end of the line is indicated by + a token of type ``CPP_EOF``. Macro expansion occurs on the + arguments of pragmas registered with + ``c_register_pragma_with_expansion`` but not on the arguments of + pragmas registered with ``c_register_pragma``. + + Note that the use of ``pragma_lex`` is specific to the C and C++ + compilers. It will not work in the Java or Fortran compilers, or any + other language compilers for that matter. Thus if ``pragma_lex`` is going + to be called from target-specific code, it must only be done so when + building the C and C++ compilers. This can be done by defining the + variables ``c_target_objs`` and ``cxx_target_objs`` in the + target entry in the :samp:`config.gcc` file. These variables should name + the target-specific, language-specific object file which contains the + code that uses ``pragma_lex``. Note it will also be necessary to add a + rule to the makefile fragment pointed to by ``tmake_file`` that shows + how to build this object file. + +.. c:macro:: HANDLE_PRAGMA_PACK_WITH_EXPANSION + + Define this macro if macros should be expanded in the + arguments of :samp:`#pragma pack`. + +.. c:macro:: TARGET_DEFAULT_PACK_STRUCT + + If your target requires a structure packing default other than 0 (meaning + the machine default), define this macro to the necessary value (in bytes). + This must be a value that would also be valid to use with + :samp:`#pragma pack()` (that is, a small power of two). + +.. c:macro:: DOLLARS_IN_IDENTIFIERS + + Define this macro to control use of the character :samp:`$` in + identifier names for the C family of languages. 0 means :samp:`$` is + not allowed by default; 1 means it is allowed. 1 is the default; + there is no need to define this macro in that case. + +.. c:macro:: INSN_SETS_ARE_DELAYED (insn) + + Define this macro as a C expression that is nonzero if it is safe for the + delay slot scheduler to place instructions in the delay slot of :samp:`{insn}`, + even if they appear to use a resource set or clobbered in :samp:`{insn}`. + :samp:`{insn}` is always a ``jump_insn`` or an ``insn`` ; GCC knows that + every ``call_insn`` has this behavior. On machines where some ``insn`` + or ``jump_insn`` is really a function call and hence has this behavior, + you should define this macro. + + You need not define this macro if it would always return zero. + +.. c:macro:: INSN_REFERENCES_ARE_DELAYED (insn) + + Define this macro as a C expression that is nonzero if it is safe for the + delay slot scheduler to place instructions in the delay slot of :samp:`{insn}`, + even if they appear to set or clobber a resource referenced in :samp:`{insn}`. + :samp:`{insn}` is always a ``jump_insn`` or an ``insn``. On machines where + some ``insn`` or ``jump_insn`` is really a function call and its operands + are registers whose use is actually in the subroutine it calls, you should + define this macro. Doing so allows the delay slot scheduler to move + instructions which copy arguments into the argument registers into the delay + slot of :samp:`{insn}`. + + You need not define this macro if it would always return zero. + +.. c:macro:: MULTIPLE_SYMBOL_SPACES + + Define this macro as a C expression that is nonzero if, in some cases, + global symbols from one translation unit may not be bound to undefined + symbols in another translation unit without user intervention. For + instance, under Microsoft Windows symbols must be explicitly imported + from shared libraries (DLLs). + + You need not define this macro if it would always evaluate to zero. + +.. function:: rtx_insn * TARGET_MD_ASM_ADJUST (vec& outputs, vec& inputs, vec& input_modes, vec& constraints, vec& clobbers, HARD_REG_SET& clobbered_regs, location_t loc) + + .. hook-start:TARGET_MD_ASM_ADJUST + + This target hook may add :dfn:`clobbers` to :samp:`{clobbers}` and + :samp:`{clobbered_regs}` for any hard regs the port wishes to automatically + clobber for an asm. The :samp:`{outputs}` and :samp:`{inputs}` may be inspected + to avoid clobbering a register that is already used by the asm. :samp:`{loc}` + is the source location of the asm. + + It may modify the :samp:`{outputs}`, :samp:`{inputs}`, :samp:`{input_modes}`, and + :samp:`{constraints}` as necessary for other pre-processing. In this case the + return value is a sequence of insns to emit after the asm. Note that + changes to :samp:`{inputs}` must be accompanied by the corresponding changes + to :samp:`{input_modes}`. + +.. hook-end + +.. c:macro:: MATH_LIBRARY + + Define this macro as a C string constant for the linker argument to link + in the system math library, minus the initial :samp:`"-l"`, or + :samp:`""` if the target does not have a + separate math library. + + You need only define this macro if the default of :samp:`"m"` is wrong. + +.. c:macro:: LIBRARY_PATH_ENV + + Define this macro as a C string constant for the environment variable that + specifies where the linker should look for libraries. + + You need only define this macro if the default of :samp:`"LIBRARY_PATH"` + is wrong. + +.. c:macro:: TARGET_POSIX_IO + + Define this macro if the target supports the following POSIXfile + functions, access, mkdir and file locking with fcntl / F_SETLKW. + Defining ``TARGET_POSIX_IO`` will enable the test coverage code + to use file locking when exiting a program, which avoids race conditions + if the program has forked. It will also create directories at run-time + for cross-profiling. + +.. c:macro:: MAX_CONDITIONAL_EXECUTE + + A C expression for the maximum number of instructions to execute via + conditional execution instructions instead of a branch. A value of + ``BRANCH_COST`` +1 is the default. + +.. c:macro:: IFCVT_MODIFY_TESTS (ce_info, true_expr, false_expr) + + Used if the target needs to perform machine-dependent modifications on the + conditionals used for turning basic blocks into conditionally executed code. + :samp:`{ce_info}` points to a data structure, ``struct ce_if_block``, which + contains information about the currently processed blocks. :samp:`{true_expr}` + and :samp:`{false_expr}` are the tests that are used for converting the + then-block and the else-block, respectively. Set either :samp:`{true_expr}` or + :samp:`{false_expr}` to a null pointer if the tests cannot be converted. + +.. c:macro:: IFCVT_MODIFY_MULTIPLE_TESTS (ce_info, bb, true_expr, false_expr) + + Like ``IFCVT_MODIFY_TESTS``, but used when converting more complicated + if-statements into conditions combined by ``and`` and ``or`` operations. + :samp:`{bb}` contains the basic block that contains the test that is currently + being processed and about to be turned into a condition. + +.. c:macro:: IFCVT_MODIFY_INSN (ce_info, pattern, insn) + + A C expression to modify the :samp:`{PATTERN}` of an :samp:`{INSN}` that is to + be converted to conditional execution format. :samp:`{ce_info}` points to + a data structure, ``struct ce_if_block``, which contains information + about the currently processed blocks. + +.. c:macro:: IFCVT_MODIFY_FINAL (ce_info) + + A C expression to perform any final machine dependent modifications in + converting code to conditional execution. The involved basic blocks + can be found in the ``struct ce_if_block`` structure that is pointed + to by :samp:`{ce_info}`. + +.. c:macro:: IFCVT_MODIFY_CANCEL (ce_info) + + A C expression to cancel any machine dependent modifications in + converting code to conditional execution. The involved basic blocks + can be found in the ``struct ce_if_block`` structure that is pointed + to by :samp:`{ce_info}`. + +.. c:macro:: IFCVT_MACHDEP_INIT (ce_info) + + A C expression to initialize any machine specific data for if-conversion + of the if-block in the ``struct ce_if_block`` structure that is pointed + to by :samp:`{ce_info}`. + +.. function:: void TARGET_MACHINE_DEPENDENT_REORG (void) + + .. hook-start:TARGET_MACHINE_DEPENDENT_REORG + + If non-null, this hook performs a target-specific pass over the + instruction stream. The compiler will run it at all optimization levels, + just before the point at which it normally does delayed-branch scheduling. + + The exact purpose of the hook varies from target to target. Some use + it to do transformations that are necessary for correctness, such as + laying out in-function constant pools or avoiding hardware hazards. + Others use it as an opportunity to do some machine-dependent optimizations. + + You need not implement the hook if it has nothing to do. The default + definition is null. + +.. hook-end + +.. function:: void TARGET_INIT_BUILTINS (void) + + .. hook-start:TARGET_INIT_BUILTINS + + Define this hook if you have any machine-specific built-in functions + that need to be defined. It should be a function that performs the + necessary setup. + + Machine specific built-in functions can be useful to expand special machine + instructions that would otherwise not normally be generated because + they have no equivalent in the source language (for example, SIMD vector + instructions or prefetch instructions). + + To create a built-in function, call the function + ``lang_hooks.builtin_function`` + which is defined by the language front end. You can use any type nodes set + up by ``build_common_tree_nodes`` ; + only language front ends that use those two functions will call + :samp:`TARGET_INIT_BUILTINS`. + +.. hook-end + +.. function:: tree TARGET_BUILTIN_DECL (unsigned code, bool initialize_p) + + .. hook-start:TARGET_BUILTIN_DECL + + Define this hook if you have any machine-specific built-in functions + that need to be defined. It should be a function that returns the + builtin function declaration for the builtin function code :samp:`{code}`. + If there is no such builtin and it cannot be initialized at this time + if :samp:`{initialize_p}` is true the function should return ``NULL_TREE``. + If :samp:`{code}` is out of range the function should return + ``error_mark_node``. + +.. hook-end + +.. function:: rtx TARGET_EXPAND_BUILTIN (tree exp, rtx target, rtx subtarget, machine_mode mode, int ignore) + + .. hook-start:TARGET_EXPAND_BUILTIN + + Expand a call to a machine specific built-in function that was set up by + :samp:`TARGET_INIT_BUILTINS`. :samp:`{exp}` is the expression for the + function call; the result should go to :samp:`{target}` if that is + convenient, and have mode :samp:`{mode}` if that is convenient. + :samp:`{subtarget}` may be used as the target for computing one of + :samp:`{exp}` 's operands. :samp:`{ignore}` is nonzero if the value is to be + ignored. This function should return the result of the call to the + built-in function. + +.. hook-end + +.. function:: tree TARGET_RESOLVE_OVERLOADED_BUILTIN (unsigned int loc, tree fndecl, void *arglist) + + .. hook-start:TARGET_RESOLVE_OVERLOADED_BUILTIN + + Select a replacement for a machine specific built-in function that + was set up by :samp:`TARGET_INIT_BUILTINS`. This is done + *before* regular type checking, and so allows the target to + implement a crude form of function overloading. :samp:`{fndecl}` is the + declaration of the built-in function. :samp:`{arglist}` is the list of + arguments passed to the built-in function. The result is a + complete expression that implements the operation, usually + another ``CALL_EXPR``. + :samp:`{arglist}` really has type :samp:`VEC(tree,gc)*` + +.. hook-end + +.. function:: bool TARGET_CHECK_BUILTIN_CALL (location_t loc, vec arg_loc, tree fndecl, tree orig_fndecl, unsigned int nargs, tree *args) + + .. hook-start:TARGET_CHECK_BUILTIN_CALL + + Perform semantic checking on a call to a machine-specific built-in + function after its arguments have been constrained to the function + signature. Return true if the call is valid, otherwise report an error + and return false. + + This hook is called after ``TARGET_RESOLVE_OVERLOADED_BUILTIN``. + The call was originally to built-in function :samp:`{orig_fndecl}`, + but after the optional ``TARGET_RESOLVE_OVERLOADED_BUILTIN`` + step is now to built-in function :samp:`{fndecl}`. :samp:`{loc}` is the + location of the call and :samp:`{args}` is an array of function arguments, + of which there are :samp:`{nargs}`. :samp:`{arg_loc}` specifies the location + of each argument. + +.. hook-end + +.. function:: tree TARGET_FOLD_BUILTIN (tree fndecl, int n_args, tree *argp, bool ignore) + + .. hook-start:TARGET_FOLD_BUILTIN + + Fold a call to a machine specific built-in function that was set up by + :samp:`TARGET_INIT_BUILTINS`. :samp:`{fndecl}` is the declaration of the + built-in function. :samp:`{n_args}` is the number of arguments passed to + the function; the arguments themselves are pointed to by :samp:`{argp}`. + The result is another tree, valid for both GIMPLE and GENERIC, + containing a simplified expression for the call's result. If + :samp:`{ignore}` is true the value will be ignored. + +.. hook-end + +.. function:: bool TARGET_GIMPLE_FOLD_BUILTIN (gimple_stmt_iterator *gsi) + + .. hook-start:TARGET_GIMPLE_FOLD_BUILTIN + + Fold a call to a machine specific built-in function that was set up + by :samp:`TARGET_INIT_BUILTINS`. :samp:`{gsi}` points to the gimple + statement holding the function call. Returns true if any change + was made to the GIMPLE stream. + +.. hook-end + +.. function:: int TARGET_COMPARE_VERSION_PRIORITY (tree decl1, tree decl2) + + .. hook-start:TARGET_COMPARE_VERSION_PRIORITY + + This hook is used to compare the target attributes in two functions to + determine which function's features get higher priority. This is used + during function multi-versioning to figure out the order in which two + versions must be dispatched. A function version with a higher priority + is checked for dispatching earlier. :samp:`{decl1}` and :samp:`{decl2}` are + the two function decls that will be compared. + +.. hook-end + +.. function:: tree TARGET_GET_FUNCTION_VERSIONS_DISPATCHER (void *decl) + + .. hook-start:TARGET_GET_FUNCTION_VERSIONS_DISPATCHER + + This hook is used to get the dispatcher function for a set of function + versions. The dispatcher function is called to invoke the right function + version at run-time. :samp:`{decl}` is one version from a set of semantically + identical versions. + +.. hook-end + +.. function:: tree TARGET_GENERATE_VERSION_DISPATCHER_BODY (void *arg) + + .. hook-start:TARGET_GENERATE_VERSION_DISPATCHER_BODY + + This hook is used to generate the dispatcher logic to invoke the right + function version at run-time for a given set of function versions. + :samp:`{arg}` points to the callgraph node of the dispatcher function whose + body must be generated. + +.. hook-end + +.. function:: bool TARGET_PREDICT_DOLOOP_P (class loop *loop) + + .. hook-start:TARGET_PREDICT_DOLOOP_P + + Return true if we can predict it is possible to use a low-overhead loop + for a particular loop. The parameter :samp:`{loop}` is a pointer to the loop. + This target hook is required only when the target supports low-overhead + loops, and will help ivopts to make some decisions. + The default version of this hook returns false. + +.. hook-end + +.. c:var:: bool TARGET_HAVE_COUNT_REG_DECR_P + + .. hook-start:TARGET_HAVE_COUNT_REG_DECR_P + + Return true if the target supports hardware count register for decrement + and branch. + The default value is false. + +.. hook-end + +.. c:var:: int64_t TARGET_DOLOOP_COST_FOR_GENERIC + + .. hook-start:TARGET_DOLOOP_COST_FOR_GENERIC + + One IV candidate dedicated for doloop is introduced in IVOPTs, we can + calculate the computation cost of adopting it to any generic IV use by + function get_computation_cost as before. But for targets which have + hardware count register support for decrement and branch, it may have to + move IV value from hardware count register to general purpose register + while doloop IV candidate is used for generic IV uses. It probably takes + expensive penalty. This hook allows target owners to define the cost for + this especially for generic IV uses. + The default value is zero. + +.. hook-end + +.. c:var:: int64_t TARGET_DOLOOP_COST_FOR_ADDRESS + + .. hook-start:TARGET_DOLOOP_COST_FOR_ADDRESS + + One IV candidate dedicated for doloop is introduced in IVOPTs, we can + calculate the computation cost of adopting it to any address IV use by + function get_computation_cost as before. But for targets which have + hardware count register support for decrement and branch, it may have to + move IV value from hardware count register to general purpose register + while doloop IV candidate is used for address IV uses. It probably takes + expensive penalty. This hook allows target owners to define the cost for + this escpecially for address IV uses. + The default value is zero. + +.. hook-end + +.. function:: bool TARGET_CAN_USE_DOLOOP_P (const widest_int &iterations, const widest_int &iterations_max, unsigned int loop_depth, bool entered_at_top) + + .. hook-start:TARGET_CAN_USE_DOLOOP_P + + Return true if it is possible to use low-overhead loops (``doloop_end`` + and ``doloop_begin``) for a particular loop. :samp:`{iterations}` gives the + exact number of iterations, or 0 if not known. :samp:`{iterations_max}` gives + the maximum number of iterations, or 0 if not known. :samp:`{loop_depth}` is + the nesting depth of the loop, with 1 for innermost loops, 2 for loops that + contain innermost loops, and so on. :samp:`{entered_at_top}` is true if the + loop is only entered from the top. + + This hook is only used if ``doloop_end`` is available. The default + implementation returns true. You can use ``can_use_doloop_if_innermost`` + if the loop must be the innermost, and if there are no other restrictions. + +.. hook-end + +.. function:: const char * TARGET_INVALID_WITHIN_DOLOOP (const rtx_insn *insn) + + .. hook-start:TARGET_INVALID_WITHIN_DOLOOP + + Take an instruction in :samp:`{insn}` and return NULL if it is valid within a + low-overhead loop, otherwise return a string explaining why doloop + could not be applied. + + Many targets use special registers for low-overhead looping. For any + instruction that clobbers these this function should return a string indicating + the reason why the doloop could not be applied. + By default, the RTL loop optimizer does not use a present doloop pattern for + loops containing function calls or branch on table instructions. + +.. hook-end + +.. function:: machine_mode TARGET_PREFERRED_DOLOOP_MODE (machine_mode mode) + + .. hook-start:TARGET_PREFERRED_DOLOOP_MODE + + This hook takes a :samp:`{mode}` for a doloop IV, where ``mode`` is the + original mode for the operation. If the target prefers an alternate + ``mode`` for the operation, then this hook should return that mode; + otherwise the original ``mode`` should be returned. For example, on a + 64-bit target, ``DImode`` might be preferred over ``SImode``. Both the + original and the returned modes should be ``MODE_INT``. + +.. hook-end + +.. function:: bool TARGET_LEGITIMATE_COMBINED_INSN (rtx_insn *insn) + + .. hook-start:TARGET_LEGITIMATE_COMBINED_INSN + + Take an instruction in :samp:`{insn}` and return ``false`` if the instruction + is not appropriate as a combination of two or more instructions. The + default is to accept all instructions. + +.. hook-end + +.. function:: bool TARGET_CAN_FOLLOW_JUMP (const rtx_insn *follower, const rtx_insn *followee) + + .. hook-start:TARGET_CAN_FOLLOW_JUMP + + FOLLOWER and FOLLOWEE are JUMP_INSN instructions; + return true if FOLLOWER may be modified to follow FOLLOWEE; + false, if it can't. + For example, on some targets, certain kinds of branches can't be made to + follow through a hot/cold partitioning. + +.. hook-end + +.. function:: bool TARGET_COMMUTATIVE_P (const_rtx x, int outer_code) + + .. hook-start:TARGET_COMMUTATIVE_P + + This target hook returns ``true`` if :samp:`{x}` is considered to be commutative. + Usually, this is just COMMUTATIVE_P (:samp:`{x}`), but the HP PA doesn't consider + PLUS to be commutative inside a MEM. :samp:`{outer_code}` is the rtx code + of the enclosing rtl, if known, otherwise it is UNKNOWN. + +.. hook-end + +.. function:: rtx TARGET_ALLOCATE_INITIAL_VALUE (rtx hard_reg) + + .. hook-start:TARGET_ALLOCATE_INITIAL_VALUE + + When the initial value of a hard register has been copied in a pseudo + register, it is often not necessary to actually allocate another register + to this pseudo register, because the original hard register or a stack slot + it has been saved into can be used. ``TARGET_ALLOCATE_INITIAL_VALUE`` + is called at the start of register allocation once for each hard register + that had its initial value copied by using + ``get_func_hard_reg_initial_val`` or ``get_hard_reg_initial_val``. + Possible values are ``NULL_RTX``, if you don't want + to do any special allocation, a ``REG`` rtx---that would typically be + the hard register itself, if it is known not to be clobbered---or a + ``MEM``. + If you are returning a ``MEM``, this is only a hint for the allocator; + it might decide to use another register anyways. + You may use ``current_function_is_leaf`` or + ``REG_N_SETS`` in the hook to determine if the hard + register in question will not be clobbered. + The default value of this hook is ``NULL``, which disables any special + allocation. + +.. hook-end + +.. function:: int TARGET_UNSPEC_MAY_TRAP_P (const_rtx x, unsigned flags) + + .. hook-start:TARGET_UNSPEC_MAY_TRAP_P + + This target hook returns nonzero if :samp:`{x}`, an ``unspec`` or + ``unspec_volatile`` operation, might cause a trap. Targets can use + this hook to enhance precision of analysis for ``unspec`` and + ``unspec_volatile`` operations. You may call ``may_trap_p_1`` + to analyze inner elements of :samp:`{x}` in which case :samp:`{flags}` should be + passed along. + +.. hook-end + +.. function:: void TARGET_SET_CURRENT_FUNCTION (tree decl) + + .. hook-start:TARGET_SET_CURRENT_FUNCTION + + The compiler invokes this hook whenever it changes its current function + context (``cfun``). You can define this function if + the back end needs to perform any initialization or reset actions on a + per-function basis. For example, it may be used to implement function + attributes that affect register usage or code generation patterns. + The argument :samp:`{decl}` is the declaration for the new function context, + and may be null to indicate that the compiler has left a function context + and is returning to processing at the top level. + The default hook function does nothing. + + GCC sets ``cfun`` to a dummy function context during initialization of + some parts of the back end. The hook function is not invoked in this + situation; you need not worry about the hook being invoked recursively, + or when the back end is in a partially-initialized state. + ``cfun`` might be ``NULL`` to indicate processing at top level, + outside of any function scope. + +.. hook-end + +.. c:macro:: TARGET_OBJECT_SUFFIX + + Define this macro to be a C string representing the suffix for object + files on your target machine. If you do not define this macro, GCC will + use :samp:`.o` as the suffix for object files. + +.. c:macro:: TARGET_EXECUTABLE_SUFFIX + + Define this macro to be a C string representing the suffix to be + automatically added to executable files on your target machine. If you + do not define this macro, GCC will use the null string as the suffix for + executable files. + +.. c:macro:: COLLECT_EXPORT_LIST + + If defined, ``collect2`` will scan the individual object files + specified on its command line and create an export list for the linker. + Define this macro for systems like AIX, where the linker discards + object files that are not referenced from ``main`` and uses export + lists. + +.. function:: bool TARGET_CANNOT_MODIFY_JUMPS_P (void) + + .. hook-start:TARGET_CANNOT_MODIFY_JUMPS_P + + This target hook returns ``true`` past the point in which new jump + instructions could be created. On machines that require a register for + every jump such as the SHmedia ISA of SH5, this point would typically be + reload, so this target hook should be defined to a function such as: + + .. code-block:: c++ + + static bool + cannot_modify_jumps_past_reload_p () + { + return (reload_completed || reload_in_progress); + } + +.. hook-end + +.. function:: bool TARGET_HAVE_CONDITIONAL_EXECUTION (void) + + .. hook-start:TARGET_HAVE_CONDITIONAL_EXECUTION + + This target hook returns true if the target supports conditional execution. + This target hook is required only when the target has several different + modes and they have different conditional execution capability, such as ARM. + +.. hook-end + +.. function:: rtx TARGET_GEN_CCMP_FIRST (rtx_insn **prep_seq, rtx_insn **gen_seq, int code, tree op0, tree op1) + + .. hook-start:TARGET_GEN_CCMP_FIRST + + This function prepares to emit a comparison insn for the first compare in a + sequence of conditional comparisions. It returns an appropriate comparison + with ``CC`` for passing to ``gen_ccmp_next`` or ``cbranch_optab``. + The insns to prepare the compare are saved in :samp:`{prep_seq}` and the compare + insns are saved in :samp:`{gen_seq}`. They will be emitted when all the + compares in the conditional comparision are generated without error. + :samp:`{code}` is the ``rtx_code`` of the compare for :samp:`{op0}` and :samp:`{op1}`. + +.. hook-end + +.. function:: rtx TARGET_GEN_CCMP_NEXT (rtx_insn **prep_seq, rtx_insn **gen_seq, rtx prev, int cmp_code, tree op0, tree op1, int bit_code) + + .. hook-start:TARGET_GEN_CCMP_NEXT + + This function prepares to emit a conditional comparison within a sequence + of conditional comparisons. It returns an appropriate comparison with + ``CC`` for passing to ``gen_ccmp_next`` or ``cbranch_optab``. + The insns to prepare the compare are saved in :samp:`{prep_seq}` and the compare + insns are saved in :samp:`{gen_seq}`. They will be emitted when all the + compares in the conditional comparision are generated without error. The + :samp:`{prev}` expression is the result of a prior call to ``gen_ccmp_first`` + or ``gen_ccmp_next``. It may return ``NULL`` if the combination of + :samp:`{prev}` and this comparison is not supported, otherwise the result must + be appropriate for passing to ``gen_ccmp_next`` or ``cbranch_optab``. + :samp:`{code}` is the ``rtx_code`` of the compare for :samp:`{op0}` and :samp:`{op1}`. + :samp:`{bit_code}` is ``AND`` or ``IOR``, which is the op on the compares. + +.. hook-end + +.. function:: rtx TARGET_GEN_MEMSET_SCRATCH_RTX (machine_mode mode) + + .. hook-start:TARGET_GEN_MEMSET_SCRATCH_RTX + + This hook should return an rtx for a scratch register in :samp:`{mode}` to + be used when expanding memset calls. The backend can use a hard scratch + register to avoid stack realignment when expanding memset. The default + is ``gen_reg_rtx``. + +.. hook-end + +.. function:: unsigned TARGET_LOOP_UNROLL_ADJUST (unsigned nunroll, class loop *loop) + + .. hook-start:TARGET_LOOP_UNROLL_ADJUST + + This target hook returns a new value for the number of times :samp:`{loop}` + should be unrolled. The parameter :samp:`{nunroll}` is the number of times + the loop is to be unrolled. The parameter :samp:`{loop}` is a pointer to + the loop, which is going to be checked for unrolling. This target hook + is required only when the target has special constraints like maximum + number of memory accesses. + +.. hook-end + +.. c:macro:: POWI_MAX_MULTS + + If defined, this macro is interpreted as a signed integer C expression + that specifies the maximum number of floating point multiplications + that should be emitted when expanding exponentiation by an integer + constant inline. When this value is defined, exponentiation requiring + more than this number of multiplications is implemented by calling the + system library's ``pow``, ``powf`` or ``powl`` routines. + The default value places no upper bound on the multiplication count. + +.. function:: void TARGET_EXTRA_INCLUDES (const char *sysroot, const char *iprefix, int stdinc) + + This target hook should register any extra include files for the + target. The parameter :samp:`{stdinc}` indicates if normal include files + are present. The parameter :samp:`{sysroot}` is the system root directory. + The parameter :samp:`{iprefix}` is the prefix for the gcc directory. + +.. function:: void TARGET_EXTRA_PRE_INCLUDES (const char *sysroot, const char *iprefix, int stdinc) + + This target hook should register any extra include files for the + target before any standard headers. The parameter :samp:`{stdinc}` + indicates if normal include files are present. The parameter + :samp:`{sysroot}` is the system root directory. The parameter + :samp:`{iprefix}` is the prefix for the gcc directory. + +.. function:: void TARGET_OPTF (char *path) + + This target hook should register special include paths for the target. + The parameter :samp:`{path}` is the include to register. On Darwin + systems, this is used for Framework includes, which have semantics + that are different from :option:`-I`. + +.. function:: bool TARGET_USE_LOCAL_THUNK_ALIAS_P (tree fndecl) + + This target macro returns ``true`` if it is safe to use a local alias + for a virtual function :samp:`{fndecl}` when constructing thunks, + ``false`` otherwise. By default, the macro returns ``true`` for all + functions, if a target supports aliases (i.e. defines + ``ASM_OUTPUT_DEF``), ``false`` otherwise, + +.. c:macro:: TARGET_FORMAT_TYPES + + If defined, this macro is the name of a global variable containing + target-specific format checking information for the :option:`-Wformat` + option. The default is to have no target-specific format checks. + +.. c:macro:: TARGET_N_FORMAT_TYPES + + If defined, this macro is the number of entries in + ``TARGET_FORMAT_TYPES``. + +.. c:macro:: TARGET_OVERRIDES_FORMAT_ATTRIBUTES + + If defined, this macro is the name of a global variable containing + target-specific format overrides for the :option:`-Wformat` option. The + default is to have no target-specific format overrides. If defined, + ``TARGET_FORMAT_TYPES`` and ``TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT`` + must be defined, too. + +.. c:macro:: TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT + + If defined, this macro specifies the number of entries in + ``TARGET_OVERRIDES_FORMAT_ATTRIBUTES``. + +.. c:macro:: TARGET_OVERRIDES_FORMAT_INIT + + If defined, this macro specifies the optional initialization + routine for target specific customizations of the system printf + and scanf formatter settings. + +.. function:: const char * TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN (const_tree typelist, const_tree funcdecl, const_tree val) + + .. hook-start:TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN + + If defined, this macro returns the diagnostic message when it is + illegal to pass argument :samp:`{val}` to function :samp:`{funcdecl}` + with prototype :samp:`{typelist}`. + +.. hook-end + +.. function:: const char * TARGET_INVALID_CONVERSION (const_tree fromtype, const_tree totype) + + .. hook-start:TARGET_INVALID_CONVERSION + + If defined, this macro returns the diagnostic message when it is + invalid to convert from :samp:`{fromtype}` to :samp:`{totype}`, or ``NULL`` + if validity should be determined by the front end. + +.. hook-end + +.. function:: const char * TARGET_INVALID_UNARY_OP (int op, const_tree type) + + .. hook-start:TARGET_INVALID_UNARY_OP + + If defined, this macro returns the diagnostic message when it is + invalid to apply operation :samp:`{op}` (where unary plus is denoted by + ``CONVERT_EXPR``) to an operand of type :samp:`{type}`, or ``NULL`` + if validity should be determined by the front end. + +.. hook-end + +.. function:: const char * TARGET_INVALID_BINARY_OP (int op, const_tree type1, const_tree type2) + + .. hook-start:TARGET_INVALID_BINARY_OP + + If defined, this macro returns the diagnostic message when it is + invalid to apply operation :samp:`{op}` to operands of types :samp:`{type1}` + and :samp:`{type2}`, or ``NULL`` if validity should be determined by + the front end. + +.. hook-end + +.. function:: tree TARGET_PROMOTED_TYPE (const_tree type) + + .. hook-start:TARGET_PROMOTED_TYPE + + If defined, this target hook returns the type to which values of + :samp:`{type}` should be promoted when they appear in expressions, + analogous to the integer promotions, or ``NULL_TREE`` to use the + front end's normal promotion rules. This hook is useful when there are + target-specific types with special promotion rules. + This is currently used only by the C and C++ front ends. + +.. hook-end + +.. function:: tree TARGET_CONVERT_TO_TYPE (tree type, tree expr) + + .. hook-start:TARGET_CONVERT_TO_TYPE + + If defined, this hook returns the result of converting :samp:`{expr}` to + :samp:`{type}`. It should return the converted expression, + or ``NULL_TREE`` to apply the front end's normal conversion rules. + This hook is useful when there are target-specific types with special + conversion rules. + This is currently used only by the C and C++ front ends. + +.. hook-end + +.. function:: bool TARGET_VERIFY_TYPE_CONTEXT (location_t loc, type_context_kind context, const_tree type, bool silent_p) + + .. hook-start:TARGET_VERIFY_TYPE_CONTEXT + + If defined, this hook returns false if there is a target-specific reason + why type :samp:`{type}` cannot be used in the source language context described + by :samp:`{context}`. When :samp:`{silent_p}` is false, the hook also reports an + error against :samp:`{loc}` for invalid uses of :samp:`{type}`. + + Calls to this hook should be made through the global function + ``verify_type_context``, which makes the :samp:`{silent_p}` parameter + default to false and also handles ``error_mark_node``. + + The default implementation always returns true. + +.. hook-end + +.. c:macro:: OBJC_JBLEN + + This macro determines the size of the objective C jump buffer for the + NeXT runtime. By default, OBJC_JBLEN is defined to an innocuous value. + +.. c:macro:: LIBGCC2_UNWIND_ATTRIBUTE + + Define this macro if any target-specific attributes need to be attached + to the functions in :samp:`libgcc` that provide low-level support for + call stack unwinding. It is used in declarations in :samp:`unwind-generic.h` + and the associated definitions of those functions. + +.. function:: void TARGET_UPDATE_STACK_BOUNDARY (void) + + .. hook-start:TARGET_UPDATE_STACK_BOUNDARY + + Define this macro to update the current function stack boundary if + necessary. + +.. hook-end + +.. function:: rtx TARGET_GET_DRAP_RTX (void) + + .. hook-start:TARGET_GET_DRAP_RTX + + This hook should return an rtx for Dynamic Realign Argument Pointer (DRAP) if a + different argument pointer register is needed to access the function's + argument list due to stack realignment. Return ``NULL`` if no DRAP + is needed. + +.. hook-end + +.. function:: HARD_REG_SET TARGET_ZERO_CALL_USED_REGS (HARD_REG_SET selected_regs) + + .. hook-start:TARGET_ZERO_CALL_USED_REGS + + This target hook emits instructions to zero the subset of :samp:`{selected_regs}` + that could conceivably contain values that are useful to an attacker. + Return the set of registers that were actually cleared. + + For most targets, the returned set of registers is a subset of + :samp:`{selected_regs}`, however, for some of the targets (for example MIPS), + clearing some registers that are in the :samp:`{selected_regs}` requires + clearing other call used registers that are not in the :samp:`{selected_regs}`, + under such situation, the returned set of registers must be a subset of all + call used registers. + + The default implementation uses normal move instructions to zero + all the registers in :samp:`{selected_regs}`. Define this hook if the + target has more efficient ways of zeroing certain registers, + or if you believe that certain registers would never contain + values that are useful to an attacker. + +.. hook-end + +.. function:: bool TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS (void) + + .. hook-start:TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS + + When optimization is disabled, this hook indicates whether or not + arguments should be allocated to stack slots. Normally, GCC allocates + stacks slots for arguments when not optimizing in order to make + debugging easier. However, when a function is declared with + ``__attribute__((naked))``, there is no stack frame, and the compiler + cannot safely move arguments from the registers in which they are passed + to the stack. Therefore, this hook should return true in general, but + false for naked functions. The default implementation always returns true. + +.. hook-end + +.. c:var:: unsigned HOST_WIDE_INT TARGET_CONST_ANCHOR + + .. hook-start:TARGET_CONST_ANCHOR + + On some architectures it can take multiple instructions to synthesize + a constant. If there is another constant already in a register that + is close enough in value then it is preferable that the new constant + is computed from this register using immediate addition or + subtraction. We accomplish this through CSE. Besides the value of + the constant we also add a lower and an upper constant anchor to the + available expressions. These are then queried when encountering new + constants. The anchors are computed by rounding the constant up and + down to a multiple of the value of ``TARGET_CONST_ANCHOR``. + ``TARGET_CONST_ANCHOR`` should be the maximum positive value + accepted by immediate-add plus one. We currently assume that the + value of ``TARGET_CONST_ANCHOR`` is a power of 2. For example, on + MIPS, where add-immediate takes a 16-bit signed value, + ``TARGET_CONST_ANCHOR`` is set to :samp:`0x8000`. The default value + is zero, which disables this optimization. + +.. hook-end + +.. function:: unsigned HOST_WIDE_INT TARGET_ASAN_SHADOW_OFFSET (void) + + .. hook-start:TARGET_ASAN_SHADOW_OFFSET + + Return the offset bitwise ored into shifted address to get corresponding + Address Sanitizer shadow memory address. NULL if Address Sanitizer is not + supported by the target. May return 0 if Address Sanitizer is not supported + by a subtarget. + +.. hook-end + +.. function:: unsigned HOST_WIDE_INT TARGET_MEMMODEL_CHECK (unsigned HOST_WIDE_INT val) + + .. hook-start:TARGET_MEMMODEL_CHECK + + Validate target specific memory model mask bits. When NULL no target specific + memory model bits are allowed. + +.. hook-end + +.. c:var:: unsigned char TARGET_ATOMIC_TEST_AND_SET_TRUEVAL + + .. hook-start:TARGET_ATOMIC_TEST_AND_SET_TRUEVAL + + This value should be set if the result written by + ``atomic_test_and_set`` is not exactly 1, i.e. the + ``bool`` ``true``. + +.. hook-end + +.. function:: bool TARGET_HAS_IFUNC_P (void) + + .. hook-start:TARGET_HAS_IFUNC_P + + It returns true if the target supports GNU indirect functions. + The support includes the assembler, linker and dynamic linker. + The default value of this hook is based on target's libc. + +.. hook-end + +.. function:: bool TARGET_IFUNC_REF_LOCAL_OK (void) + + .. hook-start:TARGET_IFUNC_REF_LOCAL_OK + + Return true if it is OK to reference indirect function resolvers + locally. The default is to return false. + +.. hook-end + +.. function:: unsigned int TARGET_ATOMIC_ALIGN_FOR_MODE (machine_mode mode) + + .. hook-start:TARGET_ATOMIC_ALIGN_FOR_MODE + + If defined, this function returns an appropriate alignment in bits for an + atomic object of machine_mode :samp:`{mode}`. If 0 is returned then the + default alignment for the specified mode is used. + +.. hook-end + +.. function:: void TARGET_ATOMIC_ASSIGN_EXPAND_FENV (tree *hold, tree *clear, tree *update) + + .. hook-start:TARGET_ATOMIC_ASSIGN_EXPAND_FENV + + ISO C11 requires atomic compound assignments that may raise floating-point + exceptions to raise exceptions corresponding to the arithmetic operation + whose result was successfully stored in a compare-and-exchange sequence. + This requires code equivalent to calls to ``feholdexcept``, + ``feclearexcept`` and ``feupdateenv`` to be generated at + appropriate points in the compare-and-exchange sequence. This hook should + set ``*hold`` to an expression equivalent to the call to + ``feholdexcept``, ``*clear`` to an expression equivalent to + the call to ``feclearexcept`` and ``*update`` to an expression + equivalent to the call to ``feupdateenv``. The three expressions are + ``NULL_TREE`` on entry to the hook and may be left as ``NULL_TREE`` + if no code is required in a particular place. The default implementation + leaves all three expressions as ``NULL_TREE``. The + ``__atomic_feraiseexcept`` function from ``libatomic`` may be of use + as part of the code generated in ``*update``. + +.. hook-end + +.. function:: void TARGET_RECORD_OFFLOAD_SYMBOL (tree) + + .. hook-start:TARGET_RECORD_OFFLOAD_SYMBOL + + Used when offloaded functions are seen in the compilation unit and no named + sections are available. It is called once for each symbol that must be + recorded in the offload function and variable table. + +.. hook-end + +.. function:: char * TARGET_OFFLOAD_OPTIONS (void) + + .. hook-start:TARGET_OFFLOAD_OPTIONS + + Used when writing out the list of options into an LTO file. It should + translate any relevant target-specific options (such as the ABI in use) + into one of the :option:`-foffload` options that exist as a common interface + to express such options. It should return a string containing these options, + separated by spaces, which the caller will free. + +.. hook-end + +.. c:macro:: TARGET_SUPPORTS_WIDE_INT + + On older ports, large integers are stored in ``CONST_DOUBLE`` rtl + objects. Newer ports define ``TARGET_SUPPORTS_WIDE_INT`` to be nonzero + to indicate that large integers are stored in + ``CONST_WIDE_INT`` rtl objects. The ``CONST_WIDE_INT`` allows + very large integer constants to be represented. ``CONST_DOUBLE`` + is limited to twice the size of the host's ``HOST_WIDE_INT`` + representation. + + Converting a port mostly requires looking for the places where + ``CONST_DOUBLE`` s are used with ``VOIDmode`` and replacing that + code with code that accesses ``CONST_WIDE_INT`` s. :samp:`"grep -i + const_double"` at the port level gets you to 95% of the changes that + need to be made. There are a few places that require a deeper look. + + * There is no equivalent to ``hval`` and ``lval`` for + ``CONST_WIDE_INT`` s. This would be difficult to express in the md + language since there are a variable number of elements. + + Most ports only check that ``hval`` is either 0 or -1 to see if the + value is small. As mentioned above, this will no longer be necessary + since small constants are always ``CONST_INT``. Of course there + are still a few exceptions, the alpha's constraint used by the zap + instruction certainly requires careful examination by C code. + However, all the current code does is pass the hval and lval to C + code, so evolving the c code to look at the ``CONST_WIDE_INT`` is + not really a large change. + + * Because there is no standard template that ports use to materialize + constants, there is likely to be some futzing that is unique to each + port in this code. + + * The rtx costs may have to be adjusted to properly account for larger + constants that are represented as ``CONST_WIDE_INT``. + + All and all it does not take long to convert ports that the + maintainer is familiar with. + +.. function:: bool TARGET_HAVE_SPECULATION_SAFE_VALUE (bool active) + + .. hook-start:TARGET_HAVE_SPECULATION_SAFE_VALUE + + This hook is used to determine the level of target support for + ``__builtin_speculation_safe_value``. If called with an argument + of false, it returns true if the target has been modified to support + this builtin. If called with an argument of true, it returns true + if the target requires active mitigation execution might be speculative. + + The default implementation returns false if the target does not define + a pattern named ``speculation_barrier``. Else it returns true + for the first case and whether the pattern is enabled for the current + compilation for the second case. + + For targets that have no processors that can execute instructions + speculatively an alternative implemenation of this hook is available: + simply redefine this hook to ``speculation_safe_value_not_needed`` + along with your other target hooks. + +.. hook-end + +.. function:: rtx TARGET_SPECULATION_SAFE_VALUE (machine_mode mode, rtx result, rtx val, rtx failval) + + .. hook-start:TARGET_SPECULATION_SAFE_VALUE + + This target hook can be used to generate a target-specific code + sequence that implements the ``__builtin_speculation_safe_value`` + built-in function. The function must always return :samp:`{val}` in + :samp:`{result}` in mode :samp:`{mode}` when the cpu is not executing + speculatively, but must never return that when speculating until it + is known that the speculation will not be unwound. The hook supports + two primary mechanisms for implementing the requirements. The first + is to emit a speculation barrier which forces the processor to wait + until all prior speculative operations have been resolved; the second + is to use a target-specific mechanism that can track the speculation + state and to return :samp:`{failval}` if it can determine that + speculation must be unwound at a later time. + + The default implementation simply copies :samp:`{val}` to :samp:`{result}` and + emits a ``speculation_barrier`` instruction if that is defined. + +.. hook-end + +.. function:: void TARGET_RUN_TARGET_SELFTESTS (void) + + .. hook-start:TARGET_RUN_TARGET_SELFTESTS + + If selftests are enabled, run any selftests for this target. + +.. hook-end + +.. function:: bool TARGET_MEMTAG_CAN_TAG_ADDRESSES () + + .. hook-start:TARGET_MEMTAG_CAN_TAG_ADDRESSES + + True if the backend architecture naturally supports ignoring some region + of pointers. This feature means that :option:`-fsanitize=hwaddress` can + work. + + At preset, this feature does not support address spaces. It also requires + ``Pmode`` to be the same as ``ptr_mode``. + +.. hook-end + +.. function:: uint8_t TARGET_MEMTAG_TAG_SIZE () + + .. hook-start:TARGET_MEMTAG_TAG_SIZE + + Return the size of a tag (in bits) for this platform. + + The default returns 8. + +.. hook-end + +.. function:: uint8_t TARGET_MEMTAG_GRANULE_SIZE () + + .. hook-start:TARGET_MEMTAG_GRANULE_SIZE + + Return the size in real memory that each byte in shadow memory refers to. + I.e. if a variable is :samp:`{X}` bytes long in memory, then this hook should + return the value :samp:`{Y}` such that the tag in shadow memory spans + :samp:`{X}` / :samp:`{Y}` bytes. + + Most variables will need to be aligned to this amount since two variables + that are neighbors in memory and share a tag granule would need to share + the same tag. + + The default returns 16. + +.. hook-end + +.. function:: rtx TARGET_MEMTAG_INSERT_RANDOM_TAG (rtx untagged, rtx target) + + .. hook-start:TARGET_MEMTAG_INSERT_RANDOM_TAG + + Return an RTX representing the value of :samp:`{untagged}` but with a + (possibly) random tag in it. + Put that value into :samp:`{target}` if it is convenient to do so. + This function is used to generate a tagged base for the current stack frame. + +.. hook-end + +.. function:: rtx TARGET_MEMTAG_ADD_TAG (rtx base, poly_int64 addr_offset, uint8_t tag_offset) + + .. hook-start:TARGET_MEMTAG_ADD_TAG + + Return an RTX that represents the result of adding :samp:`{addr_offset}` to + the address in pointer :samp:`{base}` and :samp:`{tag_offset}` to the tag in pointer + :samp:`{base}`. + The resulting RTX must either be a valid memory address or be able to get + put into an operand with ``force_operand``. + + Unlike other memtag hooks, this must return an expression and not emit any + RTL. + +.. hook-end + +.. function:: rtx TARGET_MEMTAG_SET_TAG (rtx untagged_base, rtx tag, rtx target) + + .. hook-start:TARGET_MEMTAG_SET_TAG + + Return an RTX representing :samp:`{untagged_base}` but with the tag :samp:`{tag}`. + Try and store this in :samp:`{target}` if convenient. + :samp:`{untagged_base}` is required to have a zero tag when this hook is called. + The default of this hook is to set the top byte of :samp:`{untagged_base}` to + :samp:`{tag}`. + +.. hook-end + +.. function:: rtx TARGET_MEMTAG_EXTRACT_TAG (rtx tagged_pointer, rtx target) + + .. hook-start:TARGET_MEMTAG_EXTRACT_TAG + + Return an RTX representing the tag stored in :samp:`{tagged_pointer}`. + Store the result in :samp:`{target}` if it is convenient. + The default represents the top byte of the original pointer. + +.. hook-end + +.. function:: rtx TARGET_MEMTAG_UNTAGGED_POINTER (rtx tagged_pointer, rtx target) + + .. hook-start:TARGET_MEMTAG_UNTAGGED_POINTER + + Return an RTX representing :samp:`{tagged_pointer}` with its tag set to zero. + Store the result in :samp:`{target}` if convenient. + The default clears the top byte of the original pointer. + +.. hook-end + +.. function:: HOST_WIDE_INT TARGET_GCOV_TYPE_SIZE (void) + + .. hook-start:TARGET_GCOV_TYPE_SIZE + + Returns the gcov type size in bits. This type is used for example for + counters incremented by profiling and code-coverage events. The default + value is 64, if the type size of long long is greater than 32, otherwise the + default value is 32. A 64-bit type is recommended to avoid overflows of the + counters. If the :option:`-fprofile-update=atomic` is used, then the + counters are incremented using atomic operations. Targets not supporting + 64-bit atomic operations may override the default value and request a 32-bit + type. + +.. hook-end + +.. c:var:: bool TARGET_HAVE_SHADOW_CALL_STACK + + .. hook-start:TARGET_HAVE_SHADOW_CALL_STACK + + This value is true if the target platform supports + :option:`-fsanitize=shadow-call-stack`. The default value is false. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/mode-switching-instructions.rst b/gcc/doc/gccint/target-macros/mode-switching-instructions.rst new file mode 100644 index 00000000000..e60f941dd8a --- /dev/null +++ b/gcc/doc/gccint/target-macros/mode-switching-instructions.rst @@ -0,0 +1,121 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: mode switching + +.. _mode-switching: + +Mode Switching Instructions +*************************** + +The following macros control mode switching optimizations: + +.. c:macro:: OPTIMIZE_MODE_SWITCHING (entity) + + Define this macro if the port needs extra instructions inserted for mode + switching in an optimizing compilation. + + For an example, the SH4 can perform both single and double precision + floating point operations, but to perform a single precision operation, + the FPSCR PR bit has to be cleared, while for a double precision + operation, this bit has to be set. Changing the PR bit requires a general + purpose register as a scratch register, hence these FPSCR sets have to + be inserted before reload, i.e. you cannot put this into instruction emitting + or ``TARGET_MACHINE_DEPENDENT_REORG``. + + You can have multiple entities that are mode-switched, and select at run time + which entities actually need it. ``OPTIMIZE_MODE_SWITCHING`` should + return nonzero for any :samp:`{entity}` that needs mode-switching. + If you define this macro, you also have to define + ``NUM_MODES_FOR_MODE_SWITCHING``, ``TARGET_MODE_NEEDED``, + ``TARGET_MODE_PRIORITY`` and ``TARGET_MODE_EMIT``. + ``TARGET_MODE_AFTER``, ``TARGET_MODE_ENTRY``, and ``TARGET_MODE_EXIT`` + are optional. + +.. c:macro:: NUM_MODES_FOR_MODE_SWITCHING + + If you define ``OPTIMIZE_MODE_SWITCHING``, you have to define this as + initializer for an array of integers. Each initializer element + N refers to an entity that needs mode switching, and specifies the number + of different modes that might need to be set for this entity. + The position of the initializer in the initializer---starting counting at + zero---determines the integer that is used to refer to the mode-switched + entity in question. + In macros that take mode arguments / yield a mode result, modes are + represented as numbers 0 ... N - 1. N is used to specify that no mode + switch is needed / supplied. + +.. function:: void TARGET_MODE_EMIT (int entity, int mode, int prev_mode, HARD_REG_SET regs_live) + + .. hook-start:TARGET_MODE_EMIT + + Generate one or more insns to set :samp:`{entity}` to :samp:`{mode}`. + :samp:`{hard_reg_live}` is the set of hard registers live at the point where + the insn(s) are to be inserted. :samp:`{prev_moxde}` indicates the mode + to switch from. Sets of a lower numbered entity will be emitted before + sets of a higher numbered entity to a mode of the same or lower priority. + +.. hook-end + +.. function:: int TARGET_MODE_NEEDED (int entity, rtx_insn *insn) + + .. hook-start:TARGET_MODE_NEEDED + + :samp:`{entity}` is an integer specifying a mode-switched entity. + If ``OPTIMIZE_MODE_SWITCHING`` is defined, you must define this macro + to return an integer value not larger than the corresponding element + in ``NUM_MODES_FOR_MODE_SWITCHING``, to denote the mode that :samp:`{entity}` + must be switched into prior to the execution of :samp:`{insn}`. + +.. hook-end + +.. function:: int TARGET_MODE_AFTER (int entity, int mode, rtx_insn *insn) + + .. hook-start:TARGET_MODE_AFTER + + :samp:`{entity}` is an integer specifying a mode-switched entity. + If this macro is defined, it is evaluated for every :samp:`{insn}` during mode + switching. It determines the mode that an insn results + in (if different from the incoming mode). + +.. hook-end + +.. function:: int TARGET_MODE_ENTRY (int entity) + + .. hook-start:TARGET_MODE_ENTRY + + If this macro is defined, it is evaluated for every :samp:`{entity}` that + needs mode switching. It should evaluate to an integer, which is a mode + that :samp:`{entity}` is assumed to be switched to at function entry. + If ``TARGET_MODE_ENTRY`` is defined then ``TARGET_MODE_EXIT`` + must be defined. + +.. hook-end + +.. function:: int TARGET_MODE_EXIT (int entity) + + .. hook-start:TARGET_MODE_EXIT + + If this macro is defined, it is evaluated for every :samp:`{entity}` that + needs mode switching. It should evaluate to an integer, which is a mode + that :samp:`{entity}` is assumed to be switched to at function exit. + If ``TARGET_MODE_EXIT`` is defined then ``TARGET_MODE_ENTRY`` + must be defined. + +.. hook-end + +.. function:: int TARGET_MODE_PRIORITY (int entity, int n) + + .. hook-start:TARGET_MODE_PRIORITY + + This macro specifies the order in which modes for :samp:`{entity}` + are processed. 0 is the highest priority, + ``NUM_MODES_FOR_MODE_SWITCHING[entity] - 1`` the lowest. + The value of the macro should be an integer designating a mode + for :samp:`{entity}`. For any fixed :samp:`{entity}`, ``mode_priority`` + (:samp:`{entity}`, :samp:`{n}`) shall be a bijection in 0 ... + ``num_modes_for_mode_switching[entity] - 1``. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/parameters-for-precompiled-header-validity-checking.rst b/gcc/doc/gccint/target-macros/parameters-for-precompiled-header-validity-checking.rst new file mode 100644 index 00000000000..a85e4a0646a --- /dev/null +++ b/gcc/doc/gccint/target-macros/parameters-for-precompiled-header-validity-checking.rst @@ -0,0 +1,63 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: parameters, precompiled headers + +.. _pch-target: + +Parameters for Precompiled Header Validity Checking +*************************************************** + +.. function:: void * TARGET_GET_PCH_VALIDITY (size_t *sz) + + .. hook-start:TARGET_GET_PCH_VALIDITY + + This hook returns a pointer to the data needed by + ``TARGET_PCH_VALID_P`` and sets + :samp:`*{sz}` to the size of the data in bytes. + +.. hook-end + +.. function:: const char * TARGET_PCH_VALID_P (const void *data, size_t sz) + + .. hook-start:TARGET_PCH_VALID_P + + This hook checks whether the options used to create a PCH file are + compatible with the current settings. It returns ``NULL`` + if so and a suitable error message if not. Error messages will + be presented to the user and must be localized using :samp:`_({msg})`. + + :samp:`{data}` is the data that was returned by ``TARGET_GET_PCH_VALIDITY`` + when the PCH file was created and :samp:`{sz}` is the size of that data in bytes. + It's safe to assume that the data was created by the same version of the + compiler, so no format checking is needed. + + The default definition of ``default_pch_valid_p`` should be + suitable for most targets. + +.. hook-end + +.. function:: const char * TARGET_CHECK_PCH_TARGET_FLAGS (int pch_flags) + + .. hook-start:TARGET_CHECK_PCH_TARGET_FLAGS + + If this hook is nonnull, the default implementation of + ``TARGET_PCH_VALID_P`` will use it to check for compatible values + of ``target_flags``. :samp:`{pch_flags}` specifies the value that + ``target_flags`` had when the PCH file was created. The return + value is the same as for ``TARGET_PCH_VALID_P``. + +.. hook-end + +.. function:: void TARGET_PREPARE_PCH_SAVE (void) + + .. hook-start:TARGET_PREPARE_PCH_SAVE + + Called before writing out a PCH file. If the target has some + garbage-collected data that needs to be in a particular state on PCH loads, + it can use this hook to enforce that state. Very few targets need + to do anything here. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/position-independent-code.rst b/gcc/doc/gccint/target-macros/position-independent-code.rst new file mode 100644 index 00000000000..5bcec1b3b25 --- /dev/null +++ b/gcc/doc/gccint/target-macros/position-independent-code.rst @@ -0,0 +1,53 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: position independent code, PIC + +.. _pic: + +Position Independent Code +************************* + +This section describes macros that help implement generation of position +independent code. Simply defining these macros is not enough to +generate valid PIC; you must also add support to the hook +``TARGET_LEGITIMATE_ADDRESS_P`` and to the macro +``PRINT_OPERAND_ADDRESS``, as well as ``LEGITIMIZE_ADDRESS``. You +must modify the definition of :samp:`movsi` to do something appropriate +when the source operand contains a symbolic address. You may also +need to alter the handling of switch statements so that they use +relative addresses. + +.. i rearranged the order of the macros above to try to force one of + +.. them to the next line, to eliminate an overfull hbox. -mew 10feb93 + +.. c:macro:: PIC_OFFSET_TABLE_REGNUM + + The register number of the register used to address a table of static + data addresses in memory. In some cases this register is defined by a + processor's 'application binary interface' (ABI). When this macro + is defined, RTL is generated for this register once, as with the stack + pointer and frame pointer registers. If this macro is not defined, it + is up to the machine-dependent files to allocate such a register (if + necessary). Note that this register must be fixed when in use (e.g. + when ``flag_pic`` is true). + +.. c:macro:: PIC_OFFSET_TABLE_REG_CALL_CLOBBERED + + A C expression that is nonzero if the register defined by + ``PIC_OFFSET_TABLE_REGNUM`` is clobbered by calls. If not defined, + the default is zero. Do not define + this macro if ``PIC_OFFSET_TABLE_REGNUM`` is not defined. + +.. c:macro:: LEGITIMATE_PIC_OPERAND_P (x) + + A C expression that is nonzero if :samp:`{x}` is a legitimate immediate + operand on the target machine when generating position independent code. + You can assume that :samp:`{x}` satisfies ``CONSTANT_P``, so you need not + check this. You can also assume :samp:`{flag_pic}` is true, so you need not + check it either. You need not define this macro if all constants + (including ``SYMBOL_REF``) can be immediate operands when generating + position independent code. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/register-classes.rst b/gcc/doc/gccint/target-macros/register-classes.rst new file mode 100644 index 00000000000..b1654579576 --- /dev/null +++ b/gcc/doc/gccint/target-macros/register-classes.rst @@ -0,0 +1,801 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: register class definitions, class definitions, register + +.. _register-classes: + +Register Classes +**************** + +On many machines, the numbered registers are not all equivalent. +For example, certain registers may not be allowed for indexed addressing; +certain registers may not be allowed in some instructions. These machine +restrictions are described to the compiler using :dfn:`register classes`. + +You define a number of register classes, giving each one a name and saying +which of the registers belong to it. Then you can specify register classes +that are allowed as operands to particular instruction patterns. + +.. index:: ALL_REGS, NO_REGS + +In general, each register will belong to several classes. In fact, one +class must be named ``ALL_REGS`` and contain all the registers. Another +class must be named ``NO_REGS`` and contain no registers. Often the +union of two classes will be another class; however, this is not required. + +.. index:: GENERAL_REGS + +One of the classes must be named ``GENERAL_REGS``. There is nothing +terribly special about the name, but the operand constraint letters +:samp:`r` and :samp:`g` specify this class. If ``GENERAL_REGS`` is +the same as ``ALL_REGS``, just define it as a macro which expands +to ``ALL_REGS``. + +Order the classes so that if class :samp:`{x}` is contained in class :samp:`{y}` +then :samp:`{x}` has a lower class number than :samp:`{y}`. + +The way classes other than ``GENERAL_REGS`` are specified in operand +constraints is through machine-dependent operand constraint letters. +You can define such letters to correspond to various classes, then use +them in operand constraints. + +You must define the narrowest register classes for allocatable +registers, so that each class either has no subclasses, or that for +some mode, the move cost between registers within the class is +cheaper than moving a register in the class to or from memory +(see :ref:`costs`). + +You should define a class for the union of two classes whenever some +instruction allows both classes. For example, if an instruction allows +either a floating point (coprocessor) register or a general register for a +certain operand, you should define a class ``FLOAT_OR_GENERAL_REGS`` +which includes both of them. Otherwise you will get suboptimal code, +or even internal compiler errors when reload cannot find a register in the +class computed via ``reg_class_subunion``. + +You must also specify certain redundant information about the register +classes: for each class, which classes contain it and which ones are +contained in it; for each pair of classes, the largest class contained +in their union. + +When a value occupying several consecutive registers is expected in a +certain class, all the registers used must belong to that class. +Therefore, register classes cannot be used to enforce a requirement for +a register pair to start with an even-numbered register. The way to +specify this requirement is with ``TARGET_HARD_REGNO_MODE_OK``. + +Register classes used for input-operands of bitwise-and or shift +instructions have a special requirement: each such class must have, for +each fixed-point machine mode, a subclass whose registers can transfer that +mode to or from memory. For example, on some machines, the operations for +single-byte values (``QImode``) are limited to certain registers. When +this is so, each register class that is used in a bitwise-and or shift +instruction must have a subclass consisting of registers from which +single-byte values can be loaded or stored. This is so that +``PREFERRED_RELOAD_CLASS`` can always have a possible value to return. + +.. index:: enum reg_class + +Data type enum reg_classAn enumerated type that must be defined with all the register class names +as enumerated values. ``NO_REGS`` must be first. ``ALL_REGS`` +must be the last register class, followed by one more enumerated value, +``LIM_REG_CLASSES``, which is not a register class but rather +tells how many classes there are. + +Each register class has a number, which is the value of casting +the class name to type ``int``. The number serves as an index +in many of the tables described below. + +.. c:macro:: N_REG_CLASSES + + The number of distinct register classes, defined as follows: + + .. code-block:: c++ + + #define N_REG_CLASSES (int) LIM_REG_CLASSES + +.. c:macro:: REG_CLASS_NAMES + + An initializer containing the names of the register classes as C string + constants. These names are used in writing some of the debugging dumps. + +.. c:macro:: REG_CLASS_CONTENTS + + An initializer containing the contents of the register classes, as integers + which are bit masks. The :samp:`{n}` th integer specifies the contents of class + :samp:`{n}`. The way the integer :samp:`{mask}` is interpreted is that + register :samp:`{r}` is in the class if ``mask & (1 << r)`` is 1. + + When the machine has more than 32 registers, an integer does not suffice. + Then the integers are replaced by sub-initializers, braced groupings containing + several integers. Each sub-initializer must be suitable as an initializer + for the type ``HARD_REG_SET`` which is defined in :samp:`hard-reg-set.h`. + In this situation, the first integer in each sub-initializer corresponds to + registers 0 through 31, the second integer to registers 32 through 63, and + so on. + +.. c:macro:: REGNO_REG_CLASS (regno) + + A C expression whose value is a register class containing hard register + :samp:`{regno}`. In general there is more than one such class; choose a class + which is :dfn:`minimal`, meaning that no smaller class also contains the + register. + +.. c:macro:: BASE_REG_CLASS + + A macro whose definition is the name of the class to which a valid + base register must belong. A base register is one used in an address + which is the register value plus a displacement. + +.. c:macro:: MODE_BASE_REG_CLASS (mode) + + This is a variation of the ``BASE_REG_CLASS`` macro which allows + the selection of a base register in a mode dependent manner. If + :samp:`{mode}` is VOIDmode then it should return the same value as + ``BASE_REG_CLASS``. + +.. c:macro:: MODE_BASE_REG_REG_CLASS (mode) + + A C expression whose value is the register class to which a valid + base register must belong in order to be used in a base plus index + register address. You should define this macro if base plus index + addresses have different requirements than other base register uses. + +.. c:macro:: MODE_CODE_BASE_REG_CLASS (mode, address_space, outer_code, index_code) + + A C expression whose value is the register class to which a valid + base register for a memory reference in mode :samp:`{mode}` to address + space :samp:`{address_space}` must belong. :samp:`{outer_code}` and :samp:`{index_code}` + define the context in which the base register occurs. :samp:`{outer_code}` is + the code of the immediately enclosing expression (``MEM`` for the top level + of an address, ``ADDRESS`` for something that occurs in an + ``address_operand``). :samp:`{index_code}` is the code of the corresponding + index expression if :samp:`{outer_code}` is ``PLUS`` ; ``SCRATCH`` otherwise. + +.. c:macro:: INDEX_REG_CLASS + + A macro whose definition is the name of the class to which a valid + index register must belong. An index register is one used in an + address where its value is either multiplied by a scale factor or + added to another register (as well as added to a displacement). + +.. c:macro:: REGNO_OK_FOR_BASE_P (num) + + A C expression which is nonzero if register number :samp:`{num}` is + suitable for use as a base register in operand addresses. + +.. c:macro:: REGNO_MODE_OK_FOR_BASE_P (num, mode) + + A C expression that is just like ``REGNO_OK_FOR_BASE_P``, except that + that expression may examine the mode of the memory reference in + :samp:`{mode}`. You should define this macro if the mode of the memory + reference affects whether a register may be used as a base register. If + you define this macro, the compiler will use it instead of + ``REGNO_OK_FOR_BASE_P``. The mode may be ``VOIDmode`` for + addresses that appear outside a ``MEM``, i.e., as an + ``address_operand``. + +.. c:macro:: REGNO_MODE_OK_FOR_REG_BASE_P (num, mode) + + A C expression which is nonzero if register number :samp:`{num}` is suitable for + use as a base register in base plus index operand addresses, accessing + memory in mode :samp:`{mode}`. It may be either a suitable hard register or a + pseudo register that has been allocated such a hard register. You should + define this macro if base plus index addresses have different requirements + than other base register uses. + + Use of this macro is deprecated; please use the more general + ``REGNO_MODE_CODE_OK_FOR_BASE_P``. + +.. c:macro:: REGNO_MODE_CODE_OK_FOR_BASE_P (num, mode, address_space, outer_code, index_code) + + A C expression which is nonzero if register number :samp:`{num}` is + suitable for use as a base register in operand addresses, accessing + memory in mode :samp:`{mode}` in address space :samp:`{address_space}`. + This is similar to ``REGNO_MODE_OK_FOR_BASE_P``, except + that that expression may examine the context in which the register + appears in the memory reference. :samp:`{outer_code}` is the code of the + immediately enclosing expression (``MEM`` if at the top level of the + address, ``ADDRESS`` for something that occurs in an + ``address_operand``). :samp:`{index_code}` is the code of the + corresponding index expression if :samp:`{outer_code}` is ``PLUS`` ; + ``SCRATCH`` otherwise. The mode may be ``VOIDmode`` for addresses + that appear outside a ``MEM``, i.e., as an ``address_operand``. + +.. c:macro:: REGNO_OK_FOR_INDEX_P (num) + + A C expression which is nonzero if register number :samp:`{num}` is + suitable for use as an index register in operand addresses. It may be + either a suitable hard register or a pseudo register that has been + allocated such a hard register. + + The difference between an index register and a base register is that + the index register may be scaled. If an address involves the sum of + two registers, neither one of them scaled, then either one may be + labeled the 'base' and the other the 'index'; but whichever + labeling is used must fit the machine's constraints of which registers + may serve in each capacity. The compiler will try both labelings, + looking for one that is valid, and will reload one or both registers + only if neither labeling works. + +.. function:: reg_class_t TARGET_PREFERRED_RENAME_CLASS (reg_class_t rclass) + + .. hook-start:TARGET_PREFERRED_RENAME_CLASS + + A target hook that places additional preference on the register + class to use when it is necessary to rename a register in class + :samp:`{rclass}` to another class, or perhaps :samp:`{NO_REGS}`, if no + preferred register class is found or hook ``preferred_rename_class`` + is not implemented. + Sometimes returning a more restrictive class makes better code. For + example, on ARM, thumb-2 instructions using ``LO_REGS`` may be + smaller than instructions using ``GENERIC_REGS``. By returning + ``LO_REGS`` from ``preferred_rename_class``, code size can + be reduced. + +.. hook-end + +.. function:: reg_class_t TARGET_PREFERRED_RELOAD_CLASS (rtx x, reg_class_t rclass) + + .. hook-start:TARGET_PREFERRED_RELOAD_CLASS + + A target hook that places additional restrictions on the register class + to use when it is necessary to copy value :samp:`{x}` into a register in class + :samp:`{rclass}`. The value is a register class; perhaps :samp:`{rclass}`, or perhaps + another, smaller class. + + The default version of this hook always returns value of ``rclass`` argument. + + Sometimes returning a more restrictive class makes better code. For + example, on the 68000, when :samp:`{x}` is an integer constant that is in range + for a :samp:`moveq` instruction, the value of this macro is always + ``DATA_REGS`` as long as :samp:`{rclass}` includes the data registers. + Requiring a data register guarantees that a :samp:`moveq` will be used. + + One case where ``TARGET_PREFERRED_RELOAD_CLASS`` must not return + :samp:`{rclass}` is if :samp:`{x}` is a legitimate constant which cannot be + loaded into some register class. By returning ``NO_REGS`` you can + force :samp:`{x}` into a memory location. For example, rs6000 can load + immediate values into general-purpose registers, but does not have an + instruction for loading an immediate value into a floating-point + register, so ``TARGET_PREFERRED_RELOAD_CLASS`` returns ``NO_REGS`` when + :samp:`{x}` is a floating-point constant. If the constant can't be loaded + into any kind of register, code generation will be better if + ``TARGET_LEGITIMATE_CONSTANT_P`` makes the constant illegitimate instead + of using ``TARGET_PREFERRED_RELOAD_CLASS``. + + If an insn has pseudos in it after register allocation, reload will go + through the alternatives and call repeatedly ``TARGET_PREFERRED_RELOAD_CLASS`` + to find the best one. Returning ``NO_REGS``, in this case, makes + reload add a ``!`` in front of the constraint: the x86 back-end uses + this feature to discourage usage of 387 registers when math is done in + the SSE registers (and vice versa). + +.. hook-end + +.. c:macro:: PREFERRED_RELOAD_CLASS (x, class) + + A C expression that places additional restrictions on the register class + to use when it is necessary to copy value :samp:`{x}` into a register in class + :samp:`{class}`. The value is a register class; perhaps :samp:`{class}`, or perhaps + another, smaller class. On many machines, the following definition is + safe: + + .. code-block:: c++ + + #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS + + Sometimes returning a more restrictive class makes better code. For + example, on the 68000, when :samp:`{x}` is an integer constant that is in range + for a :samp:`moveq` instruction, the value of this macro is always + ``DATA_REGS`` as long as :samp:`{class}` includes the data registers. + Requiring a data register guarantees that a :samp:`moveq` will be used. + + One case where ``PREFERRED_RELOAD_CLASS`` must not return + :samp:`{class}` is if :samp:`{x}` is a legitimate constant which cannot be + loaded into some register class. By returning ``NO_REGS`` you can + force :samp:`{x}` into a memory location. For example, rs6000 can load + immediate values into general-purpose registers, but does not have an + instruction for loading an immediate value into a floating-point + register, so ``PREFERRED_RELOAD_CLASS`` returns ``NO_REGS`` when + :samp:`{x}` is a floating-point constant. If the constant cannot be loaded + into any kind of register, code generation will be better if + ``TARGET_LEGITIMATE_CONSTANT_P`` makes the constant illegitimate instead + of using ``TARGET_PREFERRED_RELOAD_CLASS``. + + If an insn has pseudos in it after register allocation, reload will go + through the alternatives and call repeatedly ``PREFERRED_RELOAD_CLASS`` + to find the best one. Returning ``NO_REGS``, in this case, makes + reload add a ``!`` in front of the constraint: the x86 back-end uses + this feature to discourage usage of 387 registers when math is done in + the SSE registers (and vice versa). + +.. function:: reg_class_t TARGET_PREFERRED_OUTPUT_RELOAD_CLASS (rtx x, reg_class_t rclass) + + .. hook-start:TARGET_PREFERRED_OUTPUT_RELOAD_CLASS + + Like ``TARGET_PREFERRED_RELOAD_CLASS``, but for output reloads instead of + input reloads. + + The default version of this hook always returns value of ``rclass`` + argument. + + You can also use ``TARGET_PREFERRED_OUTPUT_RELOAD_CLASS`` to discourage + reload from using some alternatives, like ``TARGET_PREFERRED_RELOAD_CLASS``. + +.. hook-end + +.. c:macro:: LIMIT_RELOAD_CLASS (mode, class) + + A C expression that places additional restrictions on the register class + to use when it is necessary to be able to hold a value of mode + :samp:`{mode}` in a reload register for which class :samp:`{class}` would + ordinarily be used. + + Unlike ``PREFERRED_RELOAD_CLASS``, this macro should be used when + there are certain modes that simply cannot go in certain reload classes. + + The value is a register class; perhaps :samp:`{class}`, or perhaps another, + smaller class. + + Don't define this macro unless the target machine has limitations which + require the macro to do something nontrivial. + +.. function:: reg_class_t TARGET_SECONDARY_RELOAD (bool in_p, rtx x, reg_class_t reload_class, machine_mode reload_mode, secondary_reload_info *sri) + + .. hook-start:TARGET_SECONDARY_RELOAD + + Many machines have some registers that cannot be copied directly to or + from memory or even from other types of registers. An example is the + :samp:`MQ` register, which on most machines, can only be copied to or + from general registers, but not memory. Below, we shall be using the + term 'intermediate register' when a move operation cannot be performed + directly, but has to be done by copying the source into the intermediate + register first, and then copying the intermediate register to the + destination. An intermediate register always has the same mode as + source and destination. Since it holds the actual value being copied, + reload might apply optimizations to re-use an intermediate register + and eliding the copy from the source when it can determine that the + intermediate register still holds the required value. + + Another kind of secondary reload is required on some machines which + allow copying all registers to and from memory, but require a scratch + register for stores to some memory locations (e.g., those with symbolic + address on the RT, and those with certain symbolic address on the SPARC + when compiling PIC). Scratch registers need not have the same mode + as the value being copied, and usually hold a different value than + that being copied. Special patterns in the md file are needed to + describe how the copy is performed with the help of the scratch register; + these patterns also describe the number, register class(es) and mode(s) + of the scratch register(s). + + In some cases, both an intermediate and a scratch register are required. + + For input reloads, this target hook is called with nonzero :samp:`{in_p}`, + and :samp:`{x}` is an rtx that needs to be copied to a register of class + :samp:`{reload_class}` in :samp:`{reload_mode}`. For output reloads, this target + hook is called with zero :samp:`{in_p}`, and a register of class :samp:`{reload_class}` + needs to be copied to rtx :samp:`{x}` in :samp:`{reload_mode}`. + + If copying a register of :samp:`{reload_class}` from/to :samp:`{x}` requires + an intermediate register, the hook ``secondary_reload`` should + return the register class required for this intermediate register. + If no intermediate register is required, it should return NO_REGS. + If more than one intermediate register is required, describe the one + that is closest in the copy chain to the reload register. + + If scratch registers are needed, you also have to describe how to + perform the copy from/to the reload register to/from this + closest intermediate register. Or if no intermediate register is + required, but still a scratch register is needed, describe the + copy from/to the reload register to/from the reload operand :samp:`{x}`. + + You do this by setting ``sri->icode`` to the instruction code of a pattern + in the md file which performs the move. Operands 0 and 1 are the output + and input of this copy, respectively. Operands from operand 2 onward are + for scratch operands. These scratch operands must have a mode, and a + single-register-class + + .. [later: or memory] + + output constraint. + + When an intermediate register is used, the ``secondary_reload`` + hook will be called again to determine how to copy the intermediate + register to/from the reload operand :samp:`{x}`, so your hook must also + have code to handle the register class of the intermediate operand. + + .. [For later: maybe we'll allow multi-alternative reload patterns - + + .. the port maintainer could name a mov pattern that has clobbers - + + .. and match the constraints of input and output to determine the required + + .. alternative. A restriction would be that constraints used to match + + .. against reloads registers would have to be written as register class + + .. constraints, or we need a new target macro / hook that tells us if an + + .. arbitrary constraint can match an unknown register of a given class. + + .. Such a macro / hook would also be useful in other places.] + + :samp:`{x}` might be a pseudo-register or a ``subreg`` of a + pseudo-register, which could either be in a hard register or in memory. + Use ``true_regnum`` to find out; it will return -1 if the pseudo is + in memory and the hard register number if it is in a register. + + Scratch operands in memory (constraint ``"=m"`` / ``"=&m"``) are + currently not supported. For the time being, you will have to continue + to use ``TARGET_SECONDARY_MEMORY_NEEDED`` for that purpose. + + ``copy_cost`` also uses this target hook to find out how values are + copied. If you want it to include some extra cost for the need to allocate + (a) scratch register(s), set ``sri->extra_cost`` to the additional cost. + Or if two dependent moves are supposed to have a lower cost than the sum + of the individual moves due to expected fortuitous scheduling and/or special + forwarding logic, you can set ``sri->extra_cost`` to a negative amount. + +.. hook-end + +.. c:macro:: SECONDARY_RELOAD_CLASS (class, mode, x) + SECONDARY_INPUT_RELOAD_CLASS (class, mode, x) + SECONDARY_OUTPUT_RELOAD_CLASS (class, mode, x) + + These macros are obsolete, new ports should use the target hook + ``TARGET_SECONDARY_RELOAD`` instead. + + These are obsolete macros, replaced by the ``TARGET_SECONDARY_RELOAD`` + target hook. Older ports still define these macros to indicate to the + reload phase that it may + need to allocate at least one register for a reload in addition to the + register to contain the data. Specifically, if copying :samp:`{x}` to a + register :samp:`{class}` in :samp:`{mode}` requires an intermediate register, + you were supposed to define ``SECONDARY_INPUT_RELOAD_CLASS`` to return the + largest register class all of whose registers can be used as + intermediate registers or scratch registers. + + If copying a register :samp:`{class}` in :samp:`{mode}` to :samp:`{x}` requires an + intermediate or scratch register, ``SECONDARY_OUTPUT_RELOAD_CLASS`` + was supposed to be defined to return the largest register + class required. If the + requirements for input and output reloads were the same, the macro + ``SECONDARY_RELOAD_CLASS`` should have been used instead of defining both + macros identically. + + The values returned by these macros are often ``GENERAL_REGS``. + Return ``NO_REGS`` if no spare register is needed; i.e., if :samp:`{x}` + can be directly copied to or from a register of :samp:`{class}` in + :samp:`{mode}` without requiring a scratch register. Do not define this + macro if it would always return ``NO_REGS``. + + If a scratch register is required (either with or without an + intermediate register), you were supposed to define patterns for + :samp:`reload_in{m}` or :samp:`reload_out{m}`, as required + (see :ref:`standard-names`. These patterns, which were normally + implemented with a ``define_expand``, should be similar to the + :samp:`mov{m}` patterns, except that operand 2 is the scratch + register. + + These patterns need constraints for the reload register and scratch + register that + contain a single register class. If the original reload register (whose + class is :samp:`{class}`) can meet the constraint given in the pattern, the + value returned by these macros is used for the class of the scratch + register. Otherwise, two additional reload registers are required. + Their classes are obtained from the constraints in the insn pattern. + + :samp:`{x}` might be a pseudo-register or a ``subreg`` of a + pseudo-register, which could either be in a hard register or in memory. + Use ``true_regnum`` to find out; it will return -1 if the pseudo is + in memory and the hard register number if it is in a register. + + These macros should not be used in the case where a particular class of + registers can only be copied to memory and not to another class of + registers. In that case, secondary reload registers are not needed and + would not be helpful. Instead, a stack location must be used to perform + the copy and the ``movm`` pattern should use memory as an + intermediate storage. This case often occurs between floating-point and + general registers. + +.. function:: bool TARGET_SECONDARY_MEMORY_NEEDED (machine_mode mode, reg_class_t class1, reg_class_t class2) + + .. hook-start:TARGET_SECONDARY_MEMORY_NEEDED + + Certain machines have the property that some registers cannot be copied + to some other registers without using memory. Define this hook on + those machines to return true if objects of mode :samp:`{m}` in registers + of :samp:`{class1}` can only be copied to registers of class :samp:`{class2}` by + storing a register of :samp:`{class1}` into memory and loading that memory + location into a register of :samp:`{class2}`. The default definition returns + false for all inputs. + +.. hook-end + +.. c:macro:: SECONDARY_MEMORY_NEEDED_RTX (mode) + + Normally when ``TARGET_SECONDARY_MEMORY_NEEDED`` is defined, the compiler + allocates a stack slot for a memory location needed for register copies. + If this macro is defined, the compiler instead uses the memory location + defined by this macro. + + Do not define this macro if you do not define + ``TARGET_SECONDARY_MEMORY_NEEDED``. + +.. function:: machine_mode TARGET_SECONDARY_MEMORY_NEEDED_MODE (machine_mode mode) + + .. hook-start:TARGET_SECONDARY_MEMORY_NEEDED_MODE + + If ``TARGET_SECONDARY_MEMORY_NEEDED`` tells the compiler to use memory + when moving between two particular registers of mode :samp:`{mode}`, + this hook specifies the mode that the memory should have. + + The default depends on ``TARGET_LRA_P``. Without LRA, the default + is to use a word-sized mode for integral modes that are smaller than a + a word. This is right thing to do on most machines because it ensures + that all bits of the register are copied and prevents accesses to the + registers in a narrower mode, which some machines prohibit for + floating-point registers. + + However, this default behavior is not correct on some machines, such as + the DEC Alpha, that store short integers in floating-point registers + differently than in integer registers. On those machines, the default + widening will not work correctly and you must define this hook to + suppress that widening in some cases. See the file :samp:`alpha.cc` for + details. + + With LRA, the default is to use :samp:`{mode}` unmodified. + +.. hook-end + +.. function:: void TARGET_SELECT_EARLY_REMAT_MODES (sbitmap modes) + + .. hook-start:TARGET_SELECT_EARLY_REMAT_MODES + + On some targets, certain modes cannot be held in registers around a + standard ABI call and are relatively expensive to spill to the stack. + The early rematerialization pass can help in such cases by aggressively + recomputing values after calls, so that they don't need to be spilled. + + This hook returns the set of such modes by setting the associated bits + in :samp:`{modes}`. The default implementation selects no modes, which has + the effect of disabling the early rematerialization pass. + +.. hook-end + +.. function:: bool TARGET_CLASS_LIKELY_SPILLED_P (reg_class_t rclass) + + .. hook-start:TARGET_CLASS_LIKELY_SPILLED_P + + A target hook which returns ``true`` if pseudos that have been assigned + to registers of class :samp:`{rclass}` would likely be spilled because + registers of :samp:`{rclass}` are needed for spill registers. + + The default version of this target hook returns ``true`` if :samp:`{rclass}` + has exactly one register and ``false`` otherwise. On most machines, this + default should be used. For generally register-starved machines, such as + i386, or machines with right register constraints, such as SH, this hook + can be used to avoid excessive spilling. + + This hook is also used by some of the global intra-procedural code + transformations to throtle code motion, to avoid increasing register + pressure. + +.. hook-end + +.. function:: unsigned char TARGET_CLASS_MAX_NREGS (reg_class_t rclass, machine_mode mode) + + .. hook-start:TARGET_CLASS_MAX_NREGS + + A target hook returns the maximum number of consecutive registers + of class :samp:`{rclass}` needed to hold a value of mode :samp:`{mode}`. + + This is closely related to the macro ``TARGET_HARD_REGNO_NREGS``. + In fact, the value returned by ``TARGET_CLASS_MAX_NREGS (rclass, + mode)`` target hook should be the maximum value of + ``TARGET_HARD_REGNO_NREGS (regno, mode)`` for all :samp:`{regno}` + values in the class :samp:`{rclass}`. + + This target hook helps control the handling of multiple-word values + in the reload pass. + + The default version of this target hook returns the size of :samp:`{mode}` + in words. + +.. hook-end + +.. c:macro:: CLASS_MAX_NREGS (class, mode) + + A C expression for the maximum number of consecutive registers + of class :samp:`{class}` needed to hold a value of mode :samp:`{mode}`. + + This is closely related to the macro ``TARGET_HARD_REGNO_NREGS``. In fact, + the value of the macro ``CLASS_MAX_NREGS (class, mode)`` + should be the maximum value of ``TARGET_HARD_REGNO_NREGS (regno, + mode)`` for all :samp:`{regno}` values in the class :samp:`{class}`. + + This macro helps control the handling of multiple-word values + in the reload pass. + +.. function:: bool TARGET_CAN_CHANGE_MODE_CLASS (machine_mode from, machine_mode to, reg_class_t rclass) + + .. hook-start:TARGET_CAN_CHANGE_MODE_CLASS + + This hook returns true if it is possible to bitcast values held in + registers of class :samp:`{rclass}` from mode :samp:`{from}` to mode :samp:`{to}` + and if doing so preserves the low-order bits that are common to both modes. + The result is only meaningful if :samp:`{rclass}` has registers that can hold + both ``from`` and ``to``. The default implementation returns true. + + As an example of when such bitcasting is invalid, loading 32-bit integer or + floating-point objects into floating-point registers on Alpha extends them + to 64 bits. Therefore loading a 64-bit object and then storing it as a + 32-bit object does not store the low-order 32 bits, as would be the case + for a normal register. Therefore, :samp:`alpha.h` defines + ``TARGET_CAN_CHANGE_MODE_CLASS`` to return: + + .. code-block:: c++ + + (GET_MODE_SIZE (from) == GET_MODE_SIZE (to) + || !reg_classes_intersect_p (FLOAT_REGS, rclass)) + + Even if storing from a register in mode :samp:`{to}` would be valid, + if both :samp:`{from}` and ``raw_reg_mode`` for :samp:`{rclass}` are wider + than ``word_mode``, then we must prevent :samp:`{to}` narrowing the + mode. This happens when the middle-end assumes that it can load + or store pieces of an :samp:`{N}` -word pseudo, and that the pseudo will + eventually be allocated to :samp:`{N}` ``word_mode`` hard registers. + Failure to prevent this kind of mode change will result in the + entire ``raw_reg_mode`` being modified instead of the partial + value that the middle-end intended. + +.. hook-end + +.. function:: reg_class_t TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS (int, reg_class_t, reg_class_t) + + .. hook-start:TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS + + A target hook which can change allocno class for given pseudo from + allocno and best class calculated by IRA. + + The default version of this target hook always returns given class. + +.. hook-end + +.. function:: bool TARGET_LRA_P (void) + + .. hook-start:TARGET_LRA_P + + A target hook which returns true if we use LRA instead of reload pass. + + The default version of this target hook returns true. New ports + should use LRA, and existing ports are encouraged to convert. + +.. hook-end + +.. function:: int TARGET_REGISTER_PRIORITY (int) + + .. hook-start:TARGET_REGISTER_PRIORITY + + A target hook which returns the register priority number to which the + register :samp:`{hard_regno}` belongs to. The bigger the number, the + more preferable the hard register usage (when all other conditions are + the same). This hook can be used to prefer some hard register over + others in LRA. For example, some x86-64 register usage needs + additional prefix which makes instructions longer. The hook can + return lower priority number for such registers make them less favorable + and as result making the generated code smaller. + + The default version of this target hook returns always zero. + +.. hook-end + +.. function:: bool TARGET_REGISTER_USAGE_LEVELING_P (void) + + .. hook-start:TARGET_REGISTER_USAGE_LEVELING_P + + A target hook which returns true if we need register usage leveling. + That means if a few hard registers are equally good for the + assignment, we choose the least used hard register. The register + usage leveling may be profitable for some targets. Don't use the + usage leveling for targets with conditional execution or targets + with big register files as it hurts if-conversion and cross-jumping + optimizations. + + The default version of this target hook returns always false. + +.. hook-end + +.. function:: bool TARGET_DIFFERENT_ADDR_DISPLACEMENT_P (void) + + .. hook-start:TARGET_DIFFERENT_ADDR_DISPLACEMENT_P + + A target hook which returns true if an address with the same structure + can have different maximal legitimate displacement. For example, the + displacement can depend on memory mode or on operand combinations in + the insn. + + The default version of this target hook returns always false. + +.. hook-end + +.. function:: bool TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P (rtx subst) + + .. hook-start:TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P + + A target hook which returns ``true`` if :samp:`{subst}` can't + substitute safely pseudos with equivalent memory values during + register allocation. + The default version of this target hook returns ``false``. + On most machines, this default should be used. For generally + machines with non orthogonal register usage for addressing, such + as SH, this hook can be used to avoid excessive spilling. + +.. hook-end + +.. function:: bool TARGET_LEGITIMIZE_ADDRESS_DISPLACEMENT (rtx *offset1, rtx *offset2, poly_int64 orig_offset, machine_mode mode) + + .. hook-start:TARGET_LEGITIMIZE_ADDRESS_DISPLACEMENT + + This hook tries to split address offset :samp:`{orig_offset}` into + two parts: one that should be added to the base address to create + a local anchor point, and an additional offset that can be applied + to the anchor to address a value of mode :samp:`{mode}`. The idea is that + the local anchor could be shared by other accesses to nearby locations. + + The hook returns true if it succeeds, storing the offset of the + anchor from the base in :samp:`{offset1}` and the offset of the final address + from the anchor in :samp:`{offset2}`. The default implementation returns false. + +.. hook-end + +.. function:: reg_class_t TARGET_SPILL_CLASS (reg_class_t, machine_mode) + + .. hook-start:TARGET_SPILL_CLASS + + This hook defines a class of registers which could be used for spilling + pseudos of the given mode and class, or ``NO_REGS`` if only memory + should be used. Not defining this hook is equivalent to returning + ``NO_REGS`` for all inputs. + +.. hook-end + +.. function:: bool TARGET_ADDITIONAL_ALLOCNO_CLASS_P (reg_class_t) + + .. hook-start:TARGET_ADDITIONAL_ALLOCNO_CLASS_P + + This hook should return ``true`` if given class of registers should + be an allocno class in any way. Usually RA uses only one register + class from all classes containing the same register set. In some + complicated cases, you need to have two or more such classes as + allocno ones for RA correct work. Not defining this hook is + equivalent to returning ``false`` for all inputs. + +.. hook-end + +.. function:: scalar_int_mode TARGET_CSTORE_MODE (enum insn_code icode) + + .. hook-start:TARGET_CSTORE_MODE + + This hook defines the machine mode to use for the boolean result of + conditional store patterns. The ICODE argument is the instruction code + for the cstore being performed. Not definiting this hook is the same + as accepting the mode encoded into operand 0 of the cstore expander + patterns. + +.. hook-end + +.. function:: int TARGET_COMPUTE_PRESSURE_CLASSES (enum reg_class *pressure_classes) + + .. hook-start:TARGET_COMPUTE_PRESSURE_CLASSES + + A target hook which lets a backend compute the set of pressure classes to + be used by those optimization passes which take register pressure into + account, as opposed to letting IRA compute them. It returns the number of + register classes stored in the array :samp:`{pressure_classes}`. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/register-usage.rst b/gcc/doc/gccint/target-macros/register-usage.rst new file mode 100644 index 00000000000..4860f0a766a --- /dev/null +++ b/gcc/doc/gccint/target-macros/register-usage.rst @@ -0,0 +1,563 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: register usage + +.. _registers: + +Register Usage +************** + +This section explains how to describe what registers the target machine +has, and how (in general) they can be used. + +The description of which registers a specific instruction can use is +done with register classes; see :ref:`register-classes`. For information +on using registers to access a stack frame, see :ref:`frame-registers`. +For passing values in registers, see :ref:`register-arguments`. +For returning values in registers, see :ref:`scalar-return`. + +.. toctree:: + :maxdepth: 2 + + +.. _register-basics: + +Basic Characteristics of Registers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +Registers have various characteristics. + +.. c:macro:: FIRST_PSEUDO_REGISTER + + Number of hardware registers known to the compiler. They receive + numbers 0 through ``FIRST_PSEUDO_REGISTER-1`` ; thus, the first + pseudo register's number really is assigned the number + ``FIRST_PSEUDO_REGISTER``. + +.. c:macro:: FIXED_REGISTERS + + .. index:: fixed register + + An initializer that says which registers are used for fixed purposes + all throughout the compiled code and are therefore not available for + general allocation. These would include the stack pointer, the frame + pointer (except on machines where that can be used as a general + register when no frame pointer is needed), the program counter on + machines where that is considered one of the addressable registers, + and any other numbered register with a standard use. + + This information is expressed as a sequence of numbers, separated by + commas and surrounded by braces. The :samp:`{n}` th number is 1 if + register :samp:`{n}` is fixed, 0 otherwise. + + The table initialized from this macro, and the table initialized by + the following one, may be overridden at run time either automatically, + by the actions of the macro ``CONDITIONAL_REGISTER_USAGE``, or by + the user with the command options :option:`-ffixed-reg`, + :option:`-fcall-used-reg` and :option:`-fcall-saved-reg`. + +.. c:macro:: CALL_USED_REGISTERS + + .. index:: call-used register, call-clobbered register, call-saved register + + Like ``FIXED_REGISTERS`` but has 1 for each register that is + clobbered (in general) by function calls as well as for fixed + registers. This macro therefore identifies the registers that are not + available for general allocation of values that must live across + function calls. + + If a register has 0 in ``CALL_USED_REGISTERS``, the compiler + automatically saves it on function entry and restores it on function + exit, if the register is used within the function. + + Exactly one of ``CALL_USED_REGISTERS`` and ``CALL_REALLY_USED_REGISTERS`` + must be defined. Modern ports should define ``CALL_REALLY_USED_REGISTERS``. + +.. c:macro:: CALL_REALLY_USED_REGISTERS + + .. index:: call-used register, call-clobbered register, call-saved register + + Like ``CALL_USED_REGISTERS`` except this macro doesn't require + that the entire set of ``FIXED_REGISTERS`` be included. + (``CALL_USED_REGISTERS`` must be a superset of ``FIXED_REGISTERS``). + + Exactly one of ``CALL_USED_REGISTERS`` and ``CALL_REALLY_USED_REGISTERS`` + must be defined. Modern ports should define ``CALL_REALLY_USED_REGISTERS``. + +.. index:: call-used register, call-clobbered register, call-saved register + +.. function:: const predefined_function_abi & TARGET_FNTYPE_ABI (const_tree type) + + .. hook-start:TARGET_FNTYPE_ABI + + Return the ABI used by a function with type :samp:`{type}` ; see the + definition of ``predefined_function_abi`` for details of the ABI + descriptor. Targets only need to define this hook if they support + interoperability between several ABIs in the same translation unit. + +.. hook-end + +.. function:: const predefined_function_abi & TARGET_INSN_CALLEE_ABI (const rtx_insn *insn) + + .. hook-start:TARGET_INSN_CALLEE_ABI + + This hook returns a description of the ABI used by the target of + call instruction :samp:`{insn}` ; see the definition of + ``predefined_function_abi`` for details of the ABI descriptor. + Only the global function ``insn_callee_abi`` should call this hook + directly. + + Targets only need to define this hook if they support + interoperability between several ABIs in the same translation unit. + +.. hook-end + +.. index:: call-used register, call-clobbered register, call-saved register + +.. function:: bool TARGET_HARD_REGNO_CALL_PART_CLOBBERED (unsigned int abi_id, unsigned int regno, machine_mode mode) + + .. hook-start:TARGET_HARD_REGNO_CALL_PART_CLOBBERED + + ABIs usually specify that calls must preserve the full contents + of a particular register, or that calls can alter any part of a + particular register. This information is captured by the target macro + ``CALL_REALLY_USED_REGISTERS``. However, some ABIs specify that calls + must preserve certain bits of a particular register but can alter others. + This hook should return true if this applies to at least one of the + registers in :samp:`(reg:{mode}{regno})`, and if as a result the + call would alter part of the :samp:`{mode}` value. For example, if a call + preserves the low 32 bits of a 64-bit hard register :samp:`{regno}` but can + clobber the upper 32 bits, this hook should return true for a 64-bit mode + but false for a 32-bit mode. + + The value of :samp:`{abi_id}` comes from the ``predefined_function_abi`` + structure that describes the ABI of the call; see the definition of the + structure for more details. If (as is usual) the target uses the same ABI + for all functions in a translation unit, :samp:`{abi_id}` is always 0. + + The default implementation returns false, which is correct + for targets that don't have partly call-clobbered registers. + +.. hook-end + +.. function:: const char * TARGET_GET_MULTILIB_ABI_NAME (void) + + .. hook-start:TARGET_GET_MULTILIB_ABI_NAME + + This hook returns name of multilib ABI name. + +.. hook-end + +.. index:: fixed_regs, call_used_regs, global_regs, reg_names, reg_class_contents + +.. function:: void TARGET_CONDITIONAL_REGISTER_USAGE (void) + + .. hook-start:TARGET_CONDITIONAL_REGISTER_USAGE + + This hook may conditionally modify five variables + ``fixed_regs``, ``call_used_regs``, ``global_regs``, + ``reg_names``, and ``reg_class_contents``, to take into account + any dependence of these register sets on target flags. The first three + of these are of type ``char []`` (interpreted as boolean vectors). + ``global_regs`` is a ``const char *[]``, and + ``reg_class_contents`` is a ``HARD_REG_SET``. Before the macro is + called, ``fixed_regs``, ``call_used_regs``, + ``reg_class_contents``, and ``reg_names`` have been initialized + from ``FIXED_REGISTERS``, ``CALL_USED_REGISTERS``, + ``REG_CLASS_CONTENTS``, and ``REGISTER_NAMES``, respectively. + ``global_regs`` has been cleared, and any :option:`-ffixed-reg`, + :option:`-fcall-used-reg` and :option:`-fcall-saved-reg` + command options have been applied. + + .. index:: disabling certain registers, controlling register usage + + If the usage of an entire class of registers depends on the target + flags, you may indicate this to GCC by using this macro to modify + ``fixed_regs`` and ``call_used_regs`` to 1 for each of the + registers in the classes which should not be used by GCC. Also make + ``define_register_constraint`` s return ``NO_REGS`` for constraints + that shouldn't be used. + + (However, if this class is not included in ``GENERAL_REGS`` and all + of the insn patterns whose constraints permit this class are + controlled by target switches, then GCC will automatically avoid using + these registers when the target switches are opposed to them.) + +.. hook-end + +.. c:macro:: INCOMING_REGNO (out) + + Define this macro if the target machine has register windows. This C + expression returns the register number as seen by the called function + corresponding to the register number :samp:`{out}` as seen by the calling + function. Return :samp:`{out}` if register number :samp:`{out}` is not an + outbound register. + +.. c:macro:: OUTGOING_REGNO (in) + + Define this macro if the target machine has register windows. This C + expression returns the register number as seen by the calling function + corresponding to the register number :samp:`{in}` as seen by the called + function. Return :samp:`{in}` if register number :samp:`{in}` is not an inbound + register. + +.. c:macro:: LOCAL_REGNO (regno) + + Define this macro if the target machine has register windows. This C + expression returns true if the register is call-saved but is in the + register window. Unlike most call-saved registers, such registers + need not be explicitly restored on function exit or during non-local + gotos. + +.. c:macro:: PC_REGNUM + + If the program counter has a register number, define this as that + register number. Otherwise, do not define it. + +.. index:: order of register allocation, register allocation order + +.. _allocation-order: + +Order of Allocation of Registers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +Registers are allocated in order. + +.. c:macro:: REG_ALLOC_ORDER + + If defined, an initializer for a vector of integers, containing the + numbers of hard registers in the order in which GCC should prefer + to use them (from most preferred to least). + + If this macro is not defined, registers are used lowest numbered first + (all else being equal). + + One use of this macro is on machines where the highest numbered + registers must always be saved and the save-multiple-registers + instruction supports only sequences of consecutive registers. On such + machines, define ``REG_ALLOC_ORDER`` to be an initializer that lists + the highest numbered allocable register first. + +.. c:macro:: ADJUST_REG_ALLOC_ORDER + + A C statement (sans semicolon) to choose the order in which to allocate + hard registers for pseudo-registers local to a basic block. + + Store the desired register order in the array ``reg_alloc_order``. + Element 0 should be the register to allocate first; element 1, the next + register; and so on. + + The macro body should not assume anything about the contents of + ``reg_alloc_order`` before execution of the macro. + + On most machines, it is not necessary to define this macro. + +.. c:macro:: HONOR_REG_ALLOC_ORDER + + Normally, IRA tries to estimate the costs for saving a register in the + prologue and restoring it in the epilogue. This discourages it from + using call-saved registers. If a machine wants to ensure that IRA + allocates registers in the order given by REG_ALLOC_ORDER even if some + call-saved registers appear earlier than call-used ones, then define this + macro as a C expression to nonzero. Default is 0. + +.. c:macro:: IRA_HARD_REGNO_ADD_COST_MULTIPLIER (regno) + + In some case register allocation order is not enough for the + Integrated Register Allocator (IRA) to generate a good code. + If this macro is defined, it should return a floating point value + based on :samp:`{regno}`. The cost of using :samp:`{regno}` for a pseudo will + be increased by approximately the pseudo's usage frequency times the + value returned by this macro. Not defining this macro is equivalent + to having it always return ``0.0``. + + On most machines, it is not necessary to define this macro. + +.. _values-in-registers: + +How Values Fit in Registers +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This section discusses the macros that describe which kinds of values +(specifically, which machine modes) each register can hold, and how many +consecutive registers are needed for a given mode. + +.. function:: unsigned int TARGET_HARD_REGNO_NREGS (unsigned int regno, machine_mode mode) + + .. hook-start:TARGET_HARD_REGNO_NREGS + + This hook returns the number of consecutive hard registers, starting + at register number :samp:`{regno}`, required to hold a value of mode + :samp:`{mode}`. This hook must never return zero, even if a register + cannot hold the requested mode - indicate that with + ``TARGET_HARD_REGNO_MODE_OK`` and/or + ``TARGET_CAN_CHANGE_MODE_CLASS`` instead. + + The default definition returns the number of words in :samp:`{mode}`. + +.. hook-end + +.. c:macro:: HARD_REGNO_NREGS_HAS_PADDING (regno, mode) + + A C expression that is nonzero if a value of mode :samp:`{mode}`, stored + in memory, ends with padding that causes it to take up more space than + in registers starting at register number :samp:`{regno}` (as determined by + multiplying GCC's notion of the size of the register when containing + this mode by the number of registers returned by + ``TARGET_HARD_REGNO_NREGS``). By default this is zero. + + For example, if a floating-point value is stored in three 32-bit + registers but takes up 128 bits in memory, then this would be + nonzero. + + This macros only needs to be defined if there are cases where + ``subreg_get_info`` + would otherwise wrongly determine that a ``subreg`` can be + represented by an offset to the register number, when in fact such a + ``subreg`` would contain some of the padding not stored in + registers and so not be representable. + +.. c:macro:: HARD_REGNO_NREGS_WITH_PADDING (regno, mode) + + For values of :samp:`{regno}` and :samp:`{mode}` for which + ``HARD_REGNO_NREGS_HAS_PADDING`` returns nonzero, a C expression + returning the greater number of registers required to hold the value + including any padding. In the example above, the value would be four. + +.. c:macro:: REGMODE_NATURAL_SIZE (mode) + + Define this macro if the natural size of registers that hold values + of mode :samp:`{mode}` is not the word size. It is a C expression that + should give the natural size in bytes for the specified mode. It is + used by the register allocator to try to optimize its results. This + happens for example on SPARC 64-bit where the natural size of + floating-point registers is still 32-bit. + +.. function:: bool TARGET_HARD_REGNO_MODE_OK (unsigned int regno, machine_mode mode) + + .. hook-start:TARGET_HARD_REGNO_MODE_OK + + This hook returns true if it is permissible to store a value + of mode :samp:`{mode}` in hard register number :samp:`{regno}` (or in several + registers starting with that one). The default definition returns true + unconditionally. + + You need not include code to check for the numbers of fixed registers, + because the allocation mechanism considers them to be always occupied. + + .. index:: register pairs + + On some machines, double-precision values must be kept in even/odd + register pairs. You can implement that by defining this hook to reject + odd register numbers for such modes. + + The minimum requirement for a mode to be OK in a register is that the + :samp:`mov{mode}` instruction pattern support moves between the + register and other hard register in the same class and that moving a + value into the register and back out not alter it. + + Since the same instruction used to move ``word_mode`` will work for + all narrower integer modes, it is not necessary on any machine for + this hook to distinguish between these modes, provided you define + patterns :samp:`movhi`, etc., to take advantage of this. This is + useful because of the interaction between ``TARGET_HARD_REGNO_MODE_OK`` + and ``TARGET_MODES_TIEABLE_P`` ; it is very desirable for all integer + modes to be tieable. + + Many machines have special registers for floating point arithmetic. + Often people assume that floating point machine modes are allowed only + in floating point registers. This is not true. Any registers that + can hold integers can safely *hold* a floating point machine + mode, whether or not floating arithmetic can be done on it in those + registers. Integer move instructions can be used to move the values. + + On some machines, though, the converse is true: fixed-point machine + modes may not go in floating registers. This is true if the floating + registers normalize any value stored in them, because storing a + non-floating value there would garble it. In this case, + ``TARGET_HARD_REGNO_MODE_OK`` should reject fixed-point machine modes in + floating registers. But if the floating registers do not automatically + normalize, if you can store any bit pattern in one and retrieve it + unchanged without a trap, then any machine mode may go in a floating + register, so you can define this hook to say so. + + The primary significance of special floating registers is rather that + they are the registers acceptable in floating point arithmetic + instructions. However, this is of no concern to + ``TARGET_HARD_REGNO_MODE_OK``. You handle it by writing the proper + constraints for those instructions. + + On some machines, the floating registers are especially slow to access, + so that it is better to store a value in a stack frame than in such a + register if floating point arithmetic is not being done. As long as the + floating registers are not in class ``GENERAL_REGS``, they will not + be used unless some pattern's constraint asks for one. + +.. hook-end + +.. c:macro:: HARD_REGNO_RENAME_OK (from, to) + + A C expression that is nonzero if it is OK to rename a hard register + :samp:`{from}` to another hard register :samp:`{to}`. + + One common use of this macro is to prevent renaming of a register to + another register that is not saved by a prologue in an interrupt + handler. + + The default is always nonzero. + +.. function:: bool TARGET_MODES_TIEABLE_P (machine_mode mode1, machine_mode mode2) + + .. hook-start:TARGET_MODES_TIEABLE_P + + This hook returns true if a value of mode :samp:`{mode1}` is accessible + in mode :samp:`{mode2}` without copying. + + If ``TARGET_HARD_REGNO_MODE_OK (r, mode1)`` and + ``TARGET_HARD_REGNO_MODE_OK (r, mode2)`` are always + the same for any :samp:`{r}`, then + ``TARGET_MODES_TIEABLE_P (mode1, mode2)`` + should be true. If they differ for any :samp:`{r}`, you should define + this hook to return false unless some other mechanism ensures the + accessibility of the value in a narrower mode. + + You should define this hook to return true in as many cases as + possible since doing so will allow GCC to perform better register + allocation. The default definition returns true unconditionally. + +.. hook-end + +.. function:: bool TARGET_HARD_REGNO_SCRATCH_OK (unsigned int regno) + + .. hook-start:TARGET_HARD_REGNO_SCRATCH_OK + + This target hook should return ``true`` if it is OK to use a hard register + :samp:`{regno}` as scratch reg in peephole2. + + One common use of this macro is to prevent using of a register that + is not saved by a prologue in an interrupt handler. + + The default version of this hook always returns ``true``. + +.. hook-end + +.. c:macro:: AVOID_CCMODE_COPIES + + Define this macro if the compiler should avoid copies to/from ``CCmode`` + registers. You should only define this macro if support for copying to/from + ``CCmode`` is incomplete. + +.. index:: leaf functions, functions, leaf + +.. _leaf-functions: + +Handling Leaf Functions +^^^^^^^^^^^^^^^^^^^^^^^ + +On some machines, a leaf function (i.e., one which makes no calls) can run +more efficiently if it does not make its own register window. Often this +means it is required to receive its arguments in the registers where they +are passed by the caller, instead of the registers where they would +normally arrive. + +The special treatment for leaf functions generally applies only when +other conditions are met; for example, often they may use only those +registers for its own variables and temporaries. We use the term 'leaf +function' to mean a function that is suitable for this special +handling, so that functions with no calls are not necessarily 'leaf +functions'. + +GCC assigns register numbers before it knows whether the function is +suitable for leaf function treatment. So it needs to renumber the +registers in order to output a leaf function. The following macros +accomplish this. + +.. c:macro:: LEAF_REGISTERS + + Name of a char vector, indexed by hard register number, which + contains 1 for a register that is allowable in a candidate for leaf + function treatment. + + If leaf function treatment involves renumbering the registers, then the + registers marked here should be the ones before renumbering---those that + GCC would ordinarily allocate. The registers which will actually be + used in the assembler code, after renumbering, should not be marked with 1 + in this vector. + + Define this macro only if the target machine offers a way to optimize + the treatment of leaf functions. + +.. c:macro:: LEAF_REG_REMAP (regno) + + A C expression whose value is the register number to which :samp:`{regno}` + should be renumbered, when a function is treated as a leaf function. + + If :samp:`{regno}` is a register number which should not appear in a leaf + function before renumbering, then the expression should yield -1, which + will cause the compiler to abort. + + Define this macro only if the target machine offers a way to optimize the + treatment of leaf functions, and registers need to be renumbered to do + this. + +.. index:: current_function_is_leaf, current_function_uses_only_leaf_regs + +``TARGET_ASM_FUNCTION_PROLOGUE`` and +``TARGET_ASM_FUNCTION_EPILOGUE`` must usually treat leaf functions +specially. They can test the C variable ``current_function_is_leaf`` +which is nonzero for leaf functions. ``current_function_is_leaf`` is +set prior to local register allocation and is valid for the remaining +compiler passes. They can also test the C variable +``current_function_uses_only_leaf_regs`` which is nonzero for leaf +functions which only use leaf registers. +``current_function_uses_only_leaf_regs`` is valid after all passes +that modify the instructions have been run and is only useful if +``LEAF_REGISTERS`` is defined. + +.. changed this to fix overfull. ALSO: why the "it" at the beginning + +.. of the next paragraph?! -mew 2feb93 + +.. _stack-registers: + +Registers That Form a Stack +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +There are special features to handle computers where some of the +'registers' form a stack. Stack registers are normally written by +pushing onto the stack, and are numbered relative to the top of the +stack. + +Currently, GCC can only handle one group of stack-like registers, and +they must be consecutively numbered. Furthermore, the existing +support for stack-like registers is specific to the 80387 floating +point coprocessor. If you have a new architecture that uses +stack-like registers, you will need to do substantial work on +:samp:`reg-stack.cc` and write your machine description to cooperate +with it, as well as defining these macros. + +.. c:macro:: STACK_REGS + + Define this if the machine has any stack-like registers. + +.. c:macro:: STACK_REG_COVER_CLASS + + This is a cover class containing the stack registers. Define this if + the machine has any stack-like registers. + +.. c:macro:: FIRST_STACK_REG + + The number of the first stack-like register. This one is the top + of the stack. + +.. c:macro:: LAST_STACK_REG + + The number of the last stack-like register. This one is the bottom of + the stack. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/run-time-target-specification.rst b/gcc/doc/gccint/target-macros/run-time-target-specification.rst new file mode 100644 index 00000000000..b2f4015df8b --- /dev/null +++ b/gcc/doc/gccint/target-macros/run-time-target-specification.rst @@ -0,0 +1,273 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: run-time target specification, predefined macros, target specifications + +.. _run-time-target: + +Run-time Target Specification +***************************** + +.. prevent bad page break with this line + +Here are run-time target specifications. + +.. c:macro:: TARGET_CPU_CPP_BUILTINS () + + This function-like macro expands to a block of code that defines + built-in preprocessor macros and assertions for the target CPU, using + the functions ``builtin_define``, ``builtin_define_std`` and + ``builtin_assert``. When the front end + calls this macro it provides a trailing semicolon, and since it has + finished command line option processing your code can use those + results freely. + + ``builtin_assert`` takes a string in the form you pass to the + command-line option :option:`-A`, such as ``cpu=mips``, and creates + the assertion. ``builtin_define`` takes a string in the form + accepted by option :option:`-D` and unconditionally defines the macro. + + ``builtin_define_std`` takes a string representing the name of an + object-like macro. If it doesn't lie in the user's namespace, + ``builtin_define_std`` defines it unconditionally. Otherwise, it + defines a version with two leading underscores, and another version + with two leading and trailing underscores, and defines the original + only if an ISO standard was not requested on the command line. For + example, passing ``unix`` defines ``__unix``, ``__unix__`` + and possibly ``unix`` ; passing ``_mips`` defines ``__mips``, + ``__mips__`` and possibly ``_mips``, and passing ``_ABI64`` + defines only ``_ABI64``. + + You can also test for the C dialect being compiled. The variable + ``c_language`` is set to one of ``clk_c``, ``clk_cplusplus`` + or ``clk_objective_c``. Note that if we are preprocessing + assembler, this variable will be ``clk_c`` but the function-like + macro ``preprocessing_asm_p()`` will return true, so you might want + to check for that first. If you need to check for strict ANSI, the + variable ``flag_iso`` can be used. The function-like macro + ``preprocessing_trad_p()`` can be used to check for traditional + preprocessing. + +.. c:macro:: TARGET_OS_CPP_BUILTINS () + + Similarly to ``TARGET_CPU_CPP_BUILTINS`` but this macro is optional + and is used for the target operating system instead. + +.. c:macro:: TARGET_OBJFMT_CPP_BUILTINS () + + Similarly to ``TARGET_CPU_CPP_BUILTINS`` but this macro is optional + and is used for the target object format. :samp:`elfos.h` uses this + macro to define ``__ELF__``, so you probably do not need to define + it yourself. + +.. index:: target_flags + +Variable extern int target_flagsThis variable is declared in :samp:`options.h`, which is included before +any target-specific headers. + +.. c:var:: int TARGET_DEFAULT_TARGET_FLAGS + + .. hook-start:TARGET_DEFAULT_TARGET_FLAGS + + .. hook-end + + This variable specifies the initial value of ``target_flags``. + Its default setting is 0. + +.. index:: optional hardware or system features, features, optional, in system conventions + +.. function:: bool TARGET_HANDLE_OPTION (struct gcc_options *opts, struct gcc_options *opts_set, const struct cl_decoded_option *decoded, location_t loc) + + .. hook-start:TARGET_HANDLE_OPTION + + .. hook-end + + This hook is called whenever the user specifies one of the + target-specific options described by the :samp:`.opt` definition files + (see :ref:`options`). It has the opportunity to do some option-specific + processing and should return true if the option is valid. The default + definition does nothing but return true. + + :samp:`{decoded}` specifies the option and its arguments. :samp:`{opts}` and + :samp:`{opts_set}` are the ``gcc_options`` structures to be used for + storing option state, and :samp:`{loc}` is the location at which the + option was passed (``UNKNOWN_LOCATION`` except for options passed + via attributes). + +.. function:: bool TARGET_HANDLE_C_OPTION (size_t code, const char *arg, int value) + + .. hook-start:TARGET_HANDLE_C_OPTION + + .. hook-end + + This target hook is called whenever the user specifies one of the + target-specific C language family options described by the :samp:`.opt` + definition files(see :ref:`options`). It has the opportunity to do some + option-specific processing and should return true if the option is + valid. The arguments are like for ``TARGET_HANDLE_OPTION``. The + default definition does nothing but return false. + + In general, you should use ``TARGET_HANDLE_OPTION`` to handle + options. However, if processing an option requires routines that are + only available in the C (and related language) front ends, then you + should use ``TARGET_HANDLE_C_OPTION`` instead. + +.. function:: tree TARGET_OBJC_CONSTRUCT_STRING_OBJECT (tree string) + + .. hook-start:TARGET_OBJC_CONSTRUCT_STRING_OBJECT + + Targets may provide a string object type that can be used within + and between C, C++ and their respective Objective-C dialects. + A string object might, for example, embed encoding and length information. + These objects are considered opaque to the compiler and handled as references. + An ideal implementation makes the composition of the string object + match that of the Objective-C ``NSString`` (``NXString`` for GNUStep), + allowing efficient interworking between C-only and Objective-C code. + If a target implements string objects then this hook should return a + reference to such an object constructed from the normal 'C' string + representation provided in :samp:`{string}`. + At present, the hook is used by Objective-C only, to obtain a + common-format string object when the target provides one. + +.. hook-end + +.. function:: void TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE (const char *classname) + + .. hook-start:TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE + + Declare that Objective C class :samp:`{classname}` is referenced + by the current TU. + +.. hook-end + +.. function:: void TARGET_OBJC_DECLARE_CLASS_DEFINITION (const char *classname) + + .. hook-start:TARGET_OBJC_DECLARE_CLASS_DEFINITION + + Declare that Objective C class :samp:`{classname}` is defined + by the current TU. + +.. hook-end + +.. function:: bool TARGET_STRING_OBJECT_REF_TYPE_P (const_tree stringref) + + .. hook-start:TARGET_STRING_OBJECT_REF_TYPE_P + + If a target implements string objects then this hook should return + ``true`` if :samp:`{stringref}` is a valid reference to such an object. + +.. hook-end + +.. function:: void TARGET_CHECK_STRING_OBJECT_FORMAT_ARG (tree format_arg, tree args_list) + + .. hook-start:TARGET_CHECK_STRING_OBJECT_FORMAT_ARG + + If a target implements string objects then this hook should + provide a facility to check the function arguments in :samp:`{args_list}` + against the format specifiers in :samp:`{format_arg}` where the type of + :samp:`{format_arg}` is one recognized as a valid string reference type. + +.. hook-end + +.. function:: void TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE (void) + + .. hook-start:TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE + + This target function is similar to the hook ``TARGET_OPTION_OVERRIDE`` + but is called when the optimize level is changed via an attribute or + pragma or when it is reset at the end of the code affected by the + attribute or pragma. It is not called at the beginning of compilation + when ``TARGET_OPTION_OVERRIDE`` is called so if you want to perform these + actions then, you should have ``TARGET_OPTION_OVERRIDE`` call + ``TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE``. + +.. hook-end + +.. c:macro:: C_COMMON_OVERRIDE_OPTIONS + + This is similar to the ``TARGET_OPTION_OVERRIDE`` hook + but is only used in the C + language frontends (C, Objective-C, C++, Objective-C++) and so can be + used to alter option flag variables which only exist in those + frontends. + +.. c:var:: const struct default_options * TARGET_OPTION_OPTIMIZATION_TABLE + + .. hook-start:TARGET_OPTION_OPTIMIZATION_TABLE + + .. hook-end + + Some machines may desire to change what optimizations are performed for + various optimization levels. This variable, if defined, describes + options to enable at particular sets of optimization levels. These + options are processed once + just after the optimization level is determined and before the remainder + of the command options have been parsed, so may be overridden by other + options passed explicitly. + + This processing is run once at program startup and when the optimization + options are changed via ``#pragma GCC optimize`` or by using the + ``optimize`` attribute. + +.. function:: void TARGET_OPTION_INIT_STRUCT (struct gcc_options *opts) + + .. hook-start:TARGET_OPTION_INIT_STRUCT + + Set target-dependent initial values of fields in :samp:`{opts}`. + +.. hook-end + +.. function:: const char * TARGET_COMPUTE_MULTILIB (const struct switchstr *switches, int n_switches, const char *multilib_dir, const char *multilib_defaults, const char *multilib_select, const char *multilib_matches, const char *multilib_exclusions, const char *multilib_reuse) + + .. hook-start:TARGET_COMPUTE_MULTILIB + + Some targets like RISC-V might have complicated multilib reuse rules which + are hard to implement with the current multilib scheme. This hook allows + targets to override the result from the built-in multilib mechanism. + :samp:`{switches}` is the raw option list with :samp:`{n_switches}` items; + :samp:`{multilib_dir}` is the multi-lib result which is computed by the built-in + multi-lib mechanism; + :samp:`{multilib_defaults}` is the default options list for multi-lib; + :samp:`{multilib_select}` is the string containing the list of supported + multi-libs, and the option checking list. + :samp:`{multilib_matches}`, :samp:`{multilib_exclusions}`, and :samp:`{multilib_reuse}` + are corresponding to :samp:`{MULTILIB_MATCHES}`, :samp:`{MULTILIB_EXCLUSIONS}`, + and :samp:`{MULTILIB_REUSE}`. + The default definition does nothing but return :samp:`{multilib_dir}` directly. + +.. hook-end + +.. c:macro:: SWITCHABLE_TARGET + + Some targets need to switch between substantially different subtargets + during compilation. For example, the MIPS target has one subtarget for + the traditional MIPS architecture and another for MIPS16. Source code + can switch between these two subarchitectures using the ``mips16`` + and ``nomips16`` attributes. + + Such subtargets can differ in things like the set of available + registers, the set of available instructions, the costs of various + operations, and so on. GCC caches a lot of this type of information + in global variables, and recomputing them for each subtarget takes a + significant amount of time. The compiler therefore provides a facility + for maintaining several versions of the global variables and quickly + switching between them; see :samp:`target-globals.h` for details. + + Define this macro to 1 if your target needs this facility. The default + is 0. + +.. function:: bool TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P (void) + + .. hook-start:TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P + + Returns true if the target supports IEEE 754 floating-point exceptions + and rounding modes, false otherwise. This is intended to relate to the + ``float`` and ``double`` types, but not necessarily ``long double``. + By default, returns true if the ``adddf3`` instruction pattern is + available and false otherwise, on the assumption that hardware floating + point supports exceptions and rounding modes but software floating point + does not. + +.. hook-end diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions.rst new file mode 100644 index 00000000000..1d1f5feeea4 --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: calling conventions + +.. _stack-and-calling: + +Stack Layout and Calling Conventions +************************************ + +.. prevent bad page break with this line + +This describes the stack layout and calling conventions. + +.. toctree:: + :maxdepth: 2 + + stack-layout-and-calling-conventions/basic-stack-layout + stack-layout-and-calling-conventions/exception-handling-support + stack-layout-and-calling-conventions/specifying-how-stack-checking-is-done + stack-layout-and-calling-conventions/registers-that-address-the-stack-frame + stack-layout-and-calling-conventions/eliminating-frame-pointer-and-arg-pointer + stack-layout-and-calling-conventions/passing-function-arguments-on-the-stack + stack-layout-and-calling-conventions/passing-arguments-in-registers + stack-layout-and-calling-conventions/how-scalar-function-values-are-returned + stack-layout-and-calling-conventions/how-large-values-are-returned + stack-layout-and-calling-conventions/caller-saves-register-allocation + stack-layout-and-calling-conventions/function-entry-and-exit + stack-layout-and-calling-conventions/generating-code-for-profiling + stack-layout-and-calling-conventions/permitting-tail-calls + stack-layout-and-calling-conventions/shrink-wrapping-separate-components + stack-layout-and-calling-conventions/stack-smashing-protection + stack-layout-and-calling-conventions/miscellaneous-register-hooks \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/basic-stack-layout.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/basic-stack-layout.rst new file mode 100644 index 00000000000..4b5bb18be8f --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/basic-stack-layout.rst @@ -0,0 +1,304 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: stack frame layout, frame layout + +.. _frame-layout: + +Basic Stack Layout +^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +Here is the basic stack layout. + +.. c:macro:: STACK_GROWS_DOWNWARD + + Define this macro to be true if pushing a word onto the stack moves the stack + pointer to a smaller address, and false otherwise. + +.. c:macro:: STACK_PUSH_CODE + + This macro defines the operation used when something is pushed + on the stack. In RTL, a push operation will be + ``(set (mem (STACK_PUSH_CODE (reg sp))) ...)`` + + The choices are ``PRE_DEC``, ``POST_DEC``, ``PRE_INC``, + and ``POST_INC``. Which of these is correct depends on + the stack direction and on whether the stack pointer points + to the last item on the stack or whether it points to the + space for the next item on the stack. + + The default is ``PRE_DEC`` when ``STACK_GROWS_DOWNWARD`` is + true, which is almost always right, and ``PRE_INC`` otherwise, + which is often wrong. + +.. c:macro:: FRAME_GROWS_DOWNWARD + + Define this macro to nonzero value if the addresses of local variable slots + are at negative offsets from the frame pointer. + +.. c:macro:: ARGS_GROW_DOWNWARD + + Define this macro if successive arguments to a function occupy decreasing + addresses on the stack. + +.. function:: HOST_WIDE_INT TARGET_STARTING_FRAME_OFFSET (void) + + .. hook-start:TARGET_STARTING_FRAME_OFFSET + + This hook returns the offset from the frame pointer to the first local + variable slot to be allocated. If ``FRAME_GROWS_DOWNWARD``, it is the + offset to *end* of the first slot allocated, otherwise it is the + offset to *beginning* of the first slot allocated. The default + implementation returns 0. + +.. hook-end + +.. c:macro:: STACK_ALIGNMENT_NEEDED + + Define to zero to disable final alignment of the stack during reload. + The nonzero default for this macro is suitable for most ports. + + On ports where ``TARGET_STARTING_FRAME_OFFSET`` is nonzero or where there + is a register save block following the local block that doesn't require + alignment to ``STACK_BOUNDARY``, it may be beneficial to disable + stack alignment and do it in the backend. + +.. c:macro:: STACK_POINTER_OFFSET + + Offset from the stack pointer register to the first location at which + outgoing arguments are placed. If not specified, the default value of + zero is used. This is the proper value for most machines. + + If ``ARGS_GROW_DOWNWARD``, this is the offset to the location above + the first location at which outgoing arguments are placed. + +.. c:macro:: FIRST_PARM_OFFSET (fundecl) + + Offset from the argument pointer register to the first argument's + address. On some machines it may depend on the data type of the + function. + + If ``ARGS_GROW_DOWNWARD``, this is the offset to the location above + the first argument's address. + +.. c:macro:: STACK_DYNAMIC_OFFSET (fundecl) + + Offset from the stack pointer register to an item dynamically allocated + on the stack, e.g., by ``alloca``. + + The default value for this macro is ``STACK_POINTER_OFFSET`` plus the + length of the outgoing arguments. The default is correct for most + machines. See :samp:`function.cc` for details. + +.. c:macro:: INITIAL_FRAME_ADDRESS_RTX + + A C expression whose value is RTL representing the address of the initial + stack frame. This address is passed to ``RETURN_ADDR_RTX`` and + ``DYNAMIC_CHAIN_ADDRESS``. If you don't define this macro, a reasonable + default value will be used. Define this macro in order to make frame pointer + elimination work in the presence of ``__builtin_frame_address (count)`` and + ``__builtin_return_address (count)`` for ``count`` not equal to zero. + +.. c:macro:: DYNAMIC_CHAIN_ADDRESS (frameaddr) + + A C expression whose value is RTL representing the address in a stack + frame where the pointer to the caller's frame is stored. Assume that + :samp:`{frameaddr}` is an RTL expression for the address of the stack frame + itself. + + If you don't define this macro, the default is to return the value + of :samp:`{frameaddr}` ---that is, the stack frame address is also the + address of the stack word that points to the previous frame. + +.. c:macro:: SETUP_FRAME_ADDRESSES + + A C expression that produces the machine-specific code to + setup the stack so that arbitrary frames can be accessed. For example, + on the SPARC, we must flush all of the register windows to the stack + before we can access arbitrary stack frames. You will seldom need to + define this macro. The default is to do nothing. + +.. function:: rtx TARGET_BUILTIN_SETJMP_FRAME_VALUE (void) + + .. hook-start:TARGET_BUILTIN_SETJMP_FRAME_VALUE + + This target hook should return an rtx that is used to store + the address of the current frame into the built in ``setjmp`` buffer. + The default value, ``virtual_stack_vars_rtx``, is correct for most + machines. One reason you may need to define this target hook is if + ``hard_frame_pointer_rtx`` is the appropriate value on your machine. + +.. hook-end + +.. c:macro:: FRAME_ADDR_RTX (frameaddr) + + A C expression whose value is RTL representing the value of the frame + address for the current frame. :samp:`{frameaddr}` is the frame pointer + of the current frame. This is used for __builtin_frame_address. + You need only define this macro if the frame address is not the same + as the frame pointer. Most machines do not need to define it. + +.. c:macro:: RETURN_ADDR_RTX (count, frameaddr) + + A C expression whose value is RTL representing the value of the return + address for the frame :samp:`{count}` steps up from the current frame, after + the prologue. :samp:`{frameaddr}` is the frame pointer of the :samp:`{count}` + frame, or the frame pointer of the :samp:`{count}` - 1 frame if + ``RETURN_ADDR_IN_PREVIOUS_FRAME`` is nonzero. + + The value of the expression must always be the correct address when + :samp:`{count}` is zero, but may be ``NULL_RTX`` if there is no way to + determine the return address of other frames. + +.. c:macro:: RETURN_ADDR_IN_PREVIOUS_FRAME + + Define this macro to nonzero value if the return address of a particular + stack frame is accessed from the frame pointer of the previous stack + frame. The zero default for this macro is suitable for most ports. + +.. c:macro:: INCOMING_RETURN_ADDR_RTX + + A C expression whose value is RTL representing the location of the + incoming return address at the beginning of any function, before the + prologue. This RTL is either a ``REG``, indicating that the return + value is saved in :samp:`REG`, or a ``MEM`` representing a location in + the stack. + + You only need to define this macro if you want to support call frame + debugging information like that provided by DWARF 2. + + If this RTL is a ``REG``, you should also define + ``DWARF_FRAME_RETURN_COLUMN`` to ``DWARF_FRAME_REGNUM (REGNO)``. + +.. c:macro:: DWARF_ALT_FRAME_RETURN_COLUMN + + A C expression whose value is an integer giving a DWARF 2 column + number that may be used as an alternative return column. The column + must not correspond to any gcc hard register (that is, it must not + be in the range of ``DWARF_FRAME_REGNUM``). + + This macro can be useful if ``DWARF_FRAME_RETURN_COLUMN`` is set to a + general register, but an alternative column needs to be used for signal + frames. Some targets have also used different frame return columns + over time. + +.. c:macro:: DWARF_ZERO_REG + + A C expression whose value is an integer giving a DWARF 2 register + number that is considered to always have the value zero. This should + only be defined if the target has an architected zero register, and + someone decided it was a good idea to use that register number to + terminate the stack backtrace. New ports should avoid this. + +.. c:macro:: DWARF_VERSION_DEFAULT + + A C expression whose value is the default dwarf standard version we'll honor + and advertise when generating dwarf debug information, in absence of + an explicit :option:`-gdwarf-version` option on the command line. + +.. function:: void TARGET_DWARF_HANDLE_FRAME_UNSPEC (const char *label, rtx pattern, int index) + + .. hook-start:TARGET_DWARF_HANDLE_FRAME_UNSPEC + + This target hook allows the backend to emit frame-related insns that + contain UNSPECs or UNSPEC_VOLATILEs. The DWARF 2 call frame debugging + info engine will invoke it on insns of the form + + .. code-block:: c++ + + (set (reg) (unspec [...] UNSPEC_INDEX)) + + and + + .. code-block:: c++ + + (set (reg) (unspec_volatile [...] UNSPECV_INDEX)). + + to let the backend emit the call frame instructions. :samp:`{label}` is + the CFI label attached to the insn, :samp:`{pattern}` is the pattern of + the insn and :samp:`{index}` is ``UNSPEC_INDEX`` or ``UNSPECV_INDEX``. + +.. hook-end + +.. function:: unsigned int TARGET_DWARF_POLY_INDETERMINATE_VALUE (unsigned int i, unsigned int *factor, int *offset) + + .. hook-start:TARGET_DWARF_POLY_INDETERMINATE_VALUE + + Express the value of ``poly_int`` indeterminate :samp:`{i}` as a DWARF + expression, with :samp:`{i}` counting from 1. Return the number of a DWARF + register :samp:`{R}` and set :samp:`*{factor}` and :samp:`*{offset}` such + that the value of the indeterminate is: + + .. code-block:: c++ + + value_of(R) / factor - offset + + A target only needs to define this hook if it sets + :samp:`NUM_POLY_INT_COEFFS` to a value greater than 1. + +.. hook-end + +.. c:macro:: INCOMING_FRAME_SP_OFFSET + + A C expression whose value is an integer giving the offset, in bytes, + from the value of the stack pointer register to the top of the stack + frame at the beginning of any function, before the prologue. The top of + the frame is defined to be the value of the stack pointer in the + previous frame, just before the call instruction. + + You only need to define this macro if you want to support call frame + debugging information like that provided by DWARF 2. + +.. c:macro:: DEFAULT_INCOMING_FRAME_SP_OFFSET + + Like ``INCOMING_FRAME_SP_OFFSET``, but must be the same for all + functions of the same ABI, and when using GAS ``.cfi_*`` directives + must also agree with the default CFI GAS emits. Define this macro + only if ``INCOMING_FRAME_SP_OFFSET`` can have different values + between different functions of the same ABI or when + ``INCOMING_FRAME_SP_OFFSET`` does not agree with GAS default CFI. + +.. c:macro:: ARG_POINTER_CFA_OFFSET (fundecl) + + A C expression whose value is an integer giving the offset, in bytes, + from the argument pointer to the canonical frame address (cfa). The + final value should coincide with that calculated by + ``INCOMING_FRAME_SP_OFFSET``. Which is unfortunately not usable + during virtual register instantiation. + + The default value for this macro is + ``FIRST_PARM_OFFSET (fundecl) + crtl->args.pretend_args_size``, + which is correct for most machines; in general, the arguments are found + immediately before the stack frame. Note that this is not the case on + some targets that save registers into the caller's frame, such as SPARC + and rs6000, and so such targets need to define this macro. + + You only need to define this macro if the default is incorrect, and you + want to support call frame debugging information like that provided by + DWARF 2. + +.. c:macro:: FRAME_POINTER_CFA_OFFSET (fundecl) + + If defined, a C expression whose value is an integer giving the offset + in bytes from the frame pointer to the canonical frame address (cfa). + The final value should coincide with that calculated by + ``INCOMING_FRAME_SP_OFFSET``. + + Normally the CFA is calculated as an offset from the argument pointer, + via ``ARG_POINTER_CFA_OFFSET``, but if the argument pointer is + variable due to the ABI, this may not be possible. If this macro is + defined, it implies that the virtual register instantiation should be + based on the frame pointer instead of the argument pointer. Only one + of ``FRAME_POINTER_CFA_OFFSET`` and ``ARG_POINTER_CFA_OFFSET`` + should be defined. + +.. c:macro:: CFA_FRAME_BASE_OFFSET (fundecl) + + If defined, a C expression whose value is an integer giving the offset + in bytes from the canonical frame address (cfa) to the frame base used + in DWARF 2 debug information. The default is zero. A different value + may reduce the size of debug information on some ports. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/caller-saves-register-allocation.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/caller-saves-register-allocation.rst new file mode 100644 index 00000000000..ce7ee3af9f2 --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/caller-saves-register-allocation.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _caller-saves: + +Caller-Saves Register Allocation +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If you enable it, GCC can save registers around function calls. This +makes it possible to use call-clobbered registers to hold variables that +must live across calls. + +.. c:macro:: HARD_REGNO_CALLER_SAVE_MODE (regno, nregs) + + A C expression specifying which mode is required for saving :samp:`{nregs}` + of a pseudo-register in call-clobbered hard register :samp:`{regno}`. If + :samp:`{regno}` is unsuitable for caller save, ``VOIDmode`` should be + returned. For most machines this macro need not be defined since GCC + will select the smallest suitable mode. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/eliminating-frame-pointer-and-arg-pointer.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/eliminating-frame-pointer-and-arg-pointer.rst new file mode 100644 index 00000000000..79118da6452 --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/eliminating-frame-pointer-and-arg-pointer.rst @@ -0,0 +1,102 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _elimination: + +Eliminating Frame Pointer and Arg Pointer +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +This is about eliminating the frame pointer and arg pointer. + +.. function:: bool TARGET_FRAME_POINTER_REQUIRED (void) + + .. hook-start:TARGET_FRAME_POINTER_REQUIRED + + This target hook should return ``true`` if a function must have and use + a frame pointer. This target hook is called in the reload pass. If its return + value is ``true`` the function will have a frame pointer. + + This target hook can in principle examine the current function and decide + according to the facts, but on most machines the constant ``false`` or the + constant ``true`` suffices. Use ``false`` when the machine allows code + to be generated with no frame pointer, and doing so saves some time or space. + Use ``true`` when there is no possible advantage to avoiding a frame + pointer. + + In certain cases, the compiler does not know how to produce valid code + without a frame pointer. The compiler recognizes those cases and + automatically gives the function a frame pointer regardless of what + ``targetm.frame_pointer_required`` returns. You don't need to worry about + them. + + In a function that does not require a frame pointer, the frame pointer + register can be allocated for ordinary usage, unless you mark it as a + fixed register. See ``FIXED_REGISTERS`` for more information. + + Default return value is ``false``. + +.. hook-end + +.. c:macro:: ELIMINABLE_REGS + + This macro specifies a table of register pairs used to eliminate + unneeded registers that point into the stack frame. + + The definition of this macro is a list of structure initializations, each + of which specifies an original and replacement register. + + On some machines, the position of the argument pointer is not known until + the compilation is completed. In such a case, a separate hard register + must be used for the argument pointer. This register can be eliminated by + replacing it with either the frame pointer or the argument pointer, + depending on whether or not the frame pointer has been eliminated. + + In this case, you might specify: + + .. code-block:: c++ + + #define ELIMINABLE_REGS \ + {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ + {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \ + {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}} + + Note that the elimination of the argument pointer with the stack pointer is + specified first since that is the preferred elimination. + +.. function:: bool TARGET_CAN_ELIMINATE (const int from_reg, const int to_reg) + + .. hook-start:TARGET_CAN_ELIMINATE + + This target hook should return ``true`` if the compiler is allowed to + try to replace register number :samp:`{from_reg}` with register number + :samp:`{to_reg}`. This target hook will usually be ``true``, since most of the + cases preventing register elimination are things that the compiler already + knows about. + + Default return value is ``true``. + +.. hook-end + +.. c:macro:: INITIAL_ELIMINATION_OFFSET (from_reg, to_reg, offset_var) + + This macro returns the initial difference between the specified pair + of registers. The value would be computed from information + such as the result of ``get_frame_size ()`` and the tables of + registers ``df_regs_ever_live_p`` and ``call_used_regs``. + +.. function:: void TARGET_COMPUTE_FRAME_LAYOUT (void) + + .. hook-start:TARGET_COMPUTE_FRAME_LAYOUT + + This target hook is called once each time the frame layout needs to be + recalculated. The calculations can be cached by the target and can then + be used by ``INITIAL_ELIMINATION_OFFSET`` instead of re-computing the + layout on every invocation of that hook. This is particularly useful + for targets that have an expensive frame layout function. Implementing + this callback is optional. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/exception-handling-support.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/exception-handling-support.rst new file mode 100644 index 00000000000..946d6139e2a --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/exception-handling-support.rst @@ -0,0 +1,137 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: exception handling + +.. _exception-handling: + +Exception Handling Support +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. c:macro:: EH_RETURN_DATA_REGNO (N) + + A C expression whose value is the :samp:`{N}` th register number used for + data by exception handlers, or ``INVALID_REGNUM`` if fewer than + :samp:`{N}` registers are usable. + + The exception handling library routines communicate with the exception + handlers via a set of agreed upon registers. Ideally these registers + should be call-clobbered; it is possible to use call-saved registers, + but may negatively impact code size. The target must support at least + 2 data registers, but should define 4 if there are enough free registers. + + You must define this macro if you want to support call frame exception + handling like that provided by DWARF 2. + +.. c:macro:: EH_RETURN_STACKADJ_RTX + + A C expression whose value is RTL representing a location in which + to store a stack adjustment to be applied before function return. + This is used to unwind the stack to an exception handler's call frame. + It will be assigned zero on code paths that return normally. + + Typically this is a call-clobbered hard register that is otherwise + untouched by the epilogue, but could also be a stack slot. + + Do not define this macro if the stack pointer is saved and restored + by the regular prolog and epilog code in the call frame itself; in + this case, the exception handling library routines will update the + stack location to be restored in place. Otherwise, you must define + this macro if you want to support call frame exception handling like + that provided by DWARF 2. + +.. c:macro:: EH_RETURN_HANDLER_RTX + + A C expression whose value is RTL representing a location in which + to store the address of an exception handler to which we should + return. It will not be assigned on code paths that return normally. + + Typically this is the location in the call frame at which the normal + return address is stored. For targets that return by popping an + address off the stack, this might be a memory address just below + the *target* call frame rather than inside the current call + frame. If defined, ``EH_RETURN_STACKADJ_RTX`` will have already + been assigned, so it may be used to calculate the location of the + target call frame. + + Some targets have more complex requirements than storing to an + address calculable during initial code generation. In that case + the ``eh_return`` instruction pattern should be used instead. + + If you want to support call frame exception handling, you must + define either this macro or the ``eh_return`` instruction pattern. + +.. c:macro:: RETURN_ADDR_OFFSET + + If defined, an integer-valued C expression for which rtl will be generated + to add it to the exception handler address before it is searched in the + exception handling tables, and to subtract it again from the address before + using it to return to the exception handler. + +.. c:macro:: ASM_PREFERRED_EH_DATA_FORMAT (code, global) + + This macro chooses the encoding of pointers embedded in the exception + handling sections. If at all possible, this should be defined such + that the exception handling section will not require dynamic relocations, + and so may be read-only. + + :samp:`{code}` is 0 for data, 1 for code labels, 2 for function pointers. + :samp:`{global}` is true if the symbol may be affected by dynamic relocations. + The macro should return a combination of the ``DW_EH_PE_*`` defines + as found in :samp:`dwarf2.h`. + + If this macro is not defined, pointers will not be encoded but + represented directly. + +.. c:macro:: ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (file, encoding, size, addr, done) + + This macro allows the target to emit whatever special magic is required + to represent the encoding chosen by ``ASM_PREFERRED_EH_DATA_FORMAT``. + Generic code takes care of pc-relative and indirect encodings; this must + be defined if the target uses text-relative or data-relative encodings. + + This is a C statement that branches to :samp:`{done}` if the format was + handled. :samp:`{encoding}` is the format chosen, :samp:`{size}` is the number + of bytes that the format occupies, :samp:`{addr}` is the ``SYMBOL_REF`` + to be emitted. + +.. c:macro:: MD_FALLBACK_FRAME_STATE_FOR (context, fs) + + This macro allows the target to add CPU and operating system specific + code to the call-frame unwinder for use when there is no unwind data + available. The most common reason to implement this macro is to unwind + through signal frames. + + This macro is called from ``uw_frame_state_for`` in + :samp:`unwind-dw2.c`, :samp:`unwind-dw2-xtensa.c` and + :samp:`unwind-ia64.c`. :samp:`{context}` is an ``_Unwind_Context`` ; + :samp:`{fs}` is an ``_Unwind_FrameState``. Examine ``context->ra`` + for the address of the code being executed and ``context->cfa`` for + the stack pointer value. If the frame can be decoded, the register + save addresses should be updated in :samp:`{fs}` and the macro should + evaluate to ``_URC_NO_REASON``. If the frame cannot be decoded, + the macro should evaluate to ``_URC_END_OF_STACK``. + + For proper signal handling in Java this macro is accompanied by + ``MAKE_THROW_FRAME``, defined in :samp:`libjava/include/*-signal.h` headers. + +.. c:macro:: MD_HANDLE_UNWABI (context, fs) + + This macro allows the target to add operating system specific code to the + call-frame unwinder to handle the IA-64 ``.unwabi`` unwinding directive, + usually used for signal or interrupt frames. + + This macro is called from ``uw_update_context`` in libgcc's + :samp:`unwind-ia64.c`. :samp:`{context}` is an ``_Unwind_Context`` ; + :samp:`{fs}` is an ``_Unwind_FrameState``. Examine ``fs->unwabi`` + for the abi and context in the ``.unwabi`` directive. If the + ``.unwabi`` directive can be handled, the register save addresses should + be updated in :samp:`{fs}`. + +.. c:macro:: TARGET_USES_WEAK_UNWIND_INFO + + A C expression that evaluates to true if the target requires unwind + info to be given comdat linkage. Define it to be ``1`` if comdat + linkage is necessary. The default is ``0``. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/function-entry-and-exit.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/function-entry-and-exit.rst new file mode 100644 index 00000000000..d1055c81d09 --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/function-entry-and-exit.rst @@ -0,0 +1,265 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: function entry and exit, prologue, epilogue + +.. _function-entry: + +Function Entry and Exit +^^^^^^^^^^^^^^^^^^^^^^^ + +This section describes the macros that output function entry +(:dfn:`prologue`) and exit (:dfn:`epilogue`) code. + +.. function:: void TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY (FILE *file, unsigned HOST_WIDE_INT patch_area_size, bool record_p) + + .. hook-start:TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY + + Generate a patchable area at the function start, consisting of + :samp:`{patch_area_size}` NOP instructions. If the target supports named + sections and if :samp:`{record_p}` is true, insert a pointer to the current + location in the table of patchable functions. The default implementation + of the hook places the table of pointers in the special section named + ``__patchable_function_entries``. + +.. hook-end + +.. function:: void TARGET_ASM_FUNCTION_PROLOGUE (FILE *file) + + .. hook-start:TARGET_ASM_FUNCTION_PROLOGUE + + If defined, a function that outputs the assembler code for entry to a + function. The prologue is responsible for setting up the stack frame, + initializing the frame pointer register, saving registers that must be + saved, and allocating :samp:`{size}` additional bytes of storage for the + local variables. :samp:`{file}` is a stdio stream to which the assembler + code should be output. + + The label for the beginning of the function need not be output by this + macro. That has already been done when the macro is run. + + .. index:: regs_ever_live + + To determine which registers to save, the macro can refer to the array + ``regs_ever_live`` : element :samp:`{r}` is nonzero if hard register + :samp:`{r}` is used anywhere within the function. This implies the function + prologue should save register :samp:`{r}`, provided it is not one of the + call-used registers. (``TARGET_ASM_FUNCTION_EPILOGUE`` must likewise use + ``regs_ever_live``.) + + On machines that have 'register windows', the function entry code does + not save on the stack the registers that are in the windows, even if + they are supposed to be preserved by function calls; instead it takes + appropriate steps to 'push' the register stack, if any non-call-used + registers are used in the function. + + .. index:: frame_pointer_needed + + On machines where functions may or may not have frame-pointers, the + function entry code must vary accordingly; it must set up the frame + pointer if one is wanted, and not otherwise. To determine whether a + frame pointer is in wanted, the macro can refer to the variable + ``frame_pointer_needed``. The variable's value will be 1 at run + time in a function that needs a frame pointer. See :ref:`elimination`. + + The function entry code is responsible for allocating any stack space + required for the function. This stack space consists of the regions + listed below. In most cases, these regions are allocated in the + order listed, with the last listed region closest to the top of the + stack (the lowest address if ``STACK_GROWS_DOWNWARD`` is defined, and + the highest address if it is not defined). You can use a different order + for a machine if doing so is more convenient or required for + compatibility reasons. Except in cases where required by standard + or by a debugger, there is no reason why the stack layout used by GCC + need agree with that used by other compilers for a machine. + +.. hook-end + +.. function:: void TARGET_ASM_FUNCTION_END_PROLOGUE (FILE *file) + + .. hook-start:TARGET_ASM_FUNCTION_END_PROLOGUE + + If defined, a function that outputs assembler code at the end of a + prologue. This should be used when the function prologue is being + emitted as RTL, and you have some extra assembler that needs to be + emitted. See :ref:`prologue-instruction-pattern`. + +.. hook-end + +.. function:: void TARGET_ASM_FUNCTION_BEGIN_EPILOGUE (FILE *file) + + .. hook-start:TARGET_ASM_FUNCTION_BEGIN_EPILOGUE + + If defined, a function that outputs assembler code at the start of an + epilogue. This should be used when the function epilogue is being + emitted as RTL, and you have some extra assembler that needs to be + emitted. See :ref:`epilogue-instruction-pattern`. + +.. hook-end + +.. function:: void TARGET_ASM_FUNCTION_EPILOGUE (FILE *file) + + .. hook-start:TARGET_ASM_FUNCTION_EPILOGUE + + If defined, a function that outputs the assembler code for exit from a + function. The epilogue is responsible for restoring the saved + registers and stack pointer to their values when the function was + called, and returning control to the caller. This macro takes the + same argument as the macro ``TARGET_ASM_FUNCTION_PROLOGUE``, and the + registers to restore are determined from ``regs_ever_live`` and + ``CALL_USED_REGISTERS`` in the same way. + + On some machines, there is a single instruction that does all the work + of returning from the function. On these machines, give that + instruction the name :samp:`return` and do not define the macro + ``TARGET_ASM_FUNCTION_EPILOGUE`` at all. + + Do not define a pattern named :samp:`return` if you want the + ``TARGET_ASM_FUNCTION_EPILOGUE`` to be used. If you want the target + switches to control whether return instructions or epilogues are used, + define a :samp:`return` pattern with a validity condition that tests the + target switches appropriately. If the :samp:`return` pattern's validity + condition is false, epilogues will be used. + + On machines where functions may or may not have frame-pointers, the + function exit code must vary accordingly. Sometimes the code for these + two cases is completely different. To determine whether a frame pointer + is wanted, the macro can refer to the variable + ``frame_pointer_needed``. The variable's value will be 1 when compiling + a function that needs a frame pointer. + + Normally, ``TARGET_ASM_FUNCTION_PROLOGUE`` and + ``TARGET_ASM_FUNCTION_EPILOGUE`` must treat leaf functions specially. + The C variable ``current_function_is_leaf`` is nonzero for such a + function. See :ref:`leaf-functions`. + + On some machines, some functions pop their arguments on exit while + others leave that for the caller to do. For example, the 68020 when + given :option:`-mrtd` pops arguments in functions that take a fixed + number of arguments. + + .. index:: pops_args, crtl->args.pops_args + + Your definition of the macro ``RETURN_POPS_ARGS`` decides which + functions pop their own arguments. ``TARGET_ASM_FUNCTION_EPILOGUE`` + needs to know what was decided. The number of bytes of the current + function's arguments that this function should pop is available in + ``crtl->args.pops_args``. See :ref:`scalar-return`. + +.. hook-end + +* + .. index:: pretend_args_size, crtl->args.pretend_args_size + + A region of ``crtl->args.pretend_args_size`` bytes of + uninitialized space just underneath the first argument arriving on the + stack. (This may not be at the very start of the allocated stack region + if the calling sequence has pushed anything else since pushing the stack + arguments. But usually, on such machines, nothing else has been pushed + yet, because the function prologue itself does all the pushing.) This + region is used on machines where an argument may be passed partly in + registers and partly in memory, and, in some cases to support the + features in ````. + +* An area of memory used to save certain registers used by the function. + The size of this area, which may also include space for such things as + the return address and pointers to previous stack frames, is + machine-specific and usually depends on which registers have been used + in the function. Machines with register windows often do not require + a save area. + +* A region of at least :samp:`{size}` bytes, possibly rounded up to an allocation + boundary, to contain the local variables of the function. On some machines, + this region and the save area may occur in the opposite order, with the + save area closer to the top of the stack. + +.. index:: ACCUMULATE_OUTGOING_ARGS and stack frames + +* Optionally, when ``ACCUMULATE_OUTGOING_ARGS`` is defined, a region of + ``crtl->outgoing_args_size`` bytes to be used for outgoing + argument lists of the function. See :ref:`stack-arguments`. + +.. c:macro:: EXIT_IGNORE_STACK + + Define this macro as a C expression that is nonzero if the return + instruction or the function epilogue ignores the value of the stack + pointer; in other words, if it is safe to delete an instruction to + adjust the stack pointer before a return from the function. The + default is 0. + + Note that this macro's value is relevant only for functions for which + frame pointers are maintained. It is never safe to delete a final + stack adjustment in a function that has no frame pointer, and the + compiler knows this regardless of ``EXIT_IGNORE_STACK``. + +.. c:macro:: EPILOGUE_USES (regno) + + Define this macro as a C expression that is nonzero for registers that are + used by the epilogue or the :samp:`return` pattern. The stack and frame + pointer registers are already assumed to be used as needed. + +.. c:macro:: EH_USES (regno) + + Define this macro as a C expression that is nonzero for registers that are + used by the exception handling mechanism, and so should be considered live + on entry to an exception edge. + +.. function:: void TARGET_ASM_OUTPUT_MI_THUNK (FILE *file, tree thunk_fndecl, HOST_WIDE_INT delta, HOST_WIDE_INT vcall_offset, tree function) + + .. hook-start:TARGET_ASM_OUTPUT_MI_THUNK + + A function that outputs the assembler code for a thunk + function, used to implement C++ virtual function calls with multiple + inheritance. The thunk acts as a wrapper around a virtual function, + adjusting the implicit object parameter before handing control off to + the real function. + + First, emit code to add the integer :samp:`{delta}` to the location that + contains the incoming first argument. Assume that this argument + contains a pointer, and is the one used to pass the ``this`` pointer + in C++. This is the incoming argument *before* the function prologue, + e.g. :samp:`%o0` on a sparc. The addition must preserve the values of + all other incoming arguments. + + Then, if :samp:`{vcall_offset}` is nonzero, an additional adjustment should be + made after adding ``delta``. In particular, if :samp:`{p}` is the + adjusted pointer, the following adjustment should be made: + + .. code-block:: c++ + + p += (*((ptrdiff_t **)p))[vcall_offset/sizeof(ptrdiff_t)] + + After the additions, emit code to jump to :samp:`{function}`, which is a + ``FUNCTION_DECL``. This is a direct pure jump, not a call, and does + not touch the return address. Hence returning from :samp:`{FUNCTION}` will + return to whoever called the current :samp:`thunk`. + + The effect must be as if :samp:`{function}` had been called directly with + the adjusted first argument. This macro is responsible for emitting all + of the code for a thunk function; ``TARGET_ASM_FUNCTION_PROLOGUE`` + and ``TARGET_ASM_FUNCTION_EPILOGUE`` are not invoked. + + The :samp:`{thunk_fndecl}` is redundant. (:samp:`{delta}` and :samp:`{function}` + have already been extracted from it.) It might possibly be useful on + some targets, but probably not. + + If you do not define this macro, the target-independent code in the C++ + front end will generate a less efficient heavyweight thunk that calls + :samp:`{function}` instead of jumping to it. The generic approach does + not support varargs. + +.. hook-end + +.. function:: bool TARGET_ASM_CAN_OUTPUT_MI_THUNK (const_tree thunk_fndecl, HOST_WIDE_INT delta, HOST_WIDE_INT vcall_offset, const_tree function) + + .. hook-start:TARGET_ASM_CAN_OUTPUT_MI_THUNK + + A function that returns true if TARGET_ASM_OUTPUT_MI_THUNK would be able + to output the assembler code for the thunk function specified by the + arguments it is passed, and false otherwise. In the latter case, the + generic approach will be used by the C++ front end, with the limitations + previously exposed. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/generating-code-for-profiling.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/generating-code-for-profiling.rst new file mode 100644 index 00000000000..c68796aa882 --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/generating-code-for-profiling.rst @@ -0,0 +1,61 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: profiling, code generation + +.. _profiling: + +Generating Code for Profiling +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These macros will help you generate code for profiling. + +.. c:macro:: FUNCTION_PROFILER (file, labelno) + + A C statement or compound statement to output to :samp:`{file}` some + assembler code to call the profiling subroutine ``mcount``. + + .. index:: mcount + + The details of how ``mcount`` expects to be called are determined by + your operating system environment, not by GCC. To figure them out, + compile a small program for profiling using the system's installed C + compiler and look at the assembler code that results. + + Older implementations of ``mcount`` expect the address of a counter + variable to be loaded into some register. The name of this variable is + :samp:`LP` followed by the number :samp:`{labelno}`, so you would generate + the name using :samp:`LP%d` in a ``fprintf``. + +.. c:macro:: PROFILE_HOOK + + A C statement or compound statement to output to :samp:`{file}` some assembly + code to call the profiling subroutine ``mcount`` even the target does + not support profiling. + +.. c:macro:: NO_PROFILE_COUNTERS + + Define this macro to be an expression with a nonzero value if the + ``mcount`` subroutine on your system does not need a counter variable + allocated for each function. This is true for almost all modern + implementations. If you define this macro, you must not use the + :samp:`{labelno}` argument to ``FUNCTION_PROFILER``. + +.. c:macro:: PROFILE_BEFORE_PROLOGUE + + Define this macro if the code for function profiling should come before + the function prologue. Normally, the profiling code comes after. + +.. function:: bool TARGET_KEEP_LEAF_WHEN_PROFILED (void) + + .. hook-start:TARGET_KEEP_LEAF_WHEN_PROFILED + + This target hook returns true if the target wants the leaf flag for + the current function to stay true even if it calls mcount. This might + make sense for targets using the leaf flag only to determine whether a + stack frame needs to be generated or not and for which the call to + mcount is generated before the function prologue. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/how-large-values-are-returned.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/how-large-values-are-returned.rst new file mode 100644 index 00000000000..ebd8af4a7ff --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/how-large-values-are-returned.rst @@ -0,0 +1,132 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: aggregates as return values, large return values, returning aggregate values, structure value address + +.. _aggregate-return: + +How Large Values Are Returned +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When a function value's mode is ``BLKmode`` (and in some other +cases), the value is not returned according to +``TARGET_FUNCTION_VALUE`` (see :ref:`scalar-return`). Instead, the +caller passes the address of a block of memory in which the value +should be stored. This address is called the :dfn:`structure value +address`. + +This section describes how to control returning structure values in +memory. + +.. function:: bool TARGET_RETURN_IN_MEMORY (const_tree type, const_tree fntype) + + .. hook-start:TARGET_RETURN_IN_MEMORY + + This target hook should return a nonzero value to say to return the + function value in memory, just as large structures are always returned. + Here :samp:`{type}` will be the data type of the value, and :samp:`{fntype}` + will be the type of the function doing the returning, or ``NULL`` for + libcalls. + + Note that values of mode ``BLKmode`` must be explicitly handled + by this function. Also, the option :option:`-fpcc-struct-return` + takes effect regardless of this macro. On most systems, it is + possible to leave the hook undefined; this causes a default + definition to be used, whose value is the constant 1 for ``BLKmode`` + values, and 0 otherwise. + + Do not use this hook to indicate that structures and unions should always + be returned in memory. You should instead use ``DEFAULT_PCC_STRUCT_RETURN`` + to indicate this. + +.. hook-end + +.. c:macro:: DEFAULT_PCC_STRUCT_RETURN + + Define this macro to be 1 if all structure and union return values must be + in memory. Since this results in slower code, this should be defined + only if needed for compatibility with other compilers or with an ABI. + If you define this macro to be 0, then the conventions used for structure + and union return values are decided by the ``TARGET_RETURN_IN_MEMORY`` + target hook. + + If not defined, this defaults to the value 1. + +.. function:: rtx TARGET_STRUCT_VALUE_RTX (tree fndecl, int incoming) + + .. hook-start:TARGET_STRUCT_VALUE_RTX + + This target hook should return the location of the structure value + address (normally a ``mem`` or ``reg``), or 0 if the address is + passed as an 'invisible' first argument. Note that :samp:`{fndecl}` may + be ``NULL``, for libcalls. You do not need to define this target + hook if the address is always passed as an 'invisible' first + argument. + + On some architectures the place where the structure value address + is found by the called function is not the same place that the + caller put it. This can be due to register windows, or it could + be because the function prologue moves it to a different place. + :samp:`{incoming}` is ``1`` or ``2`` when the location is needed in + the context of the called function, and ``0`` in the context of + the caller. + + If :samp:`{incoming}` is nonzero and the address is to be found on the + stack, return a ``mem`` which refers to the frame pointer. If + :samp:`{incoming}` is ``2``, the result is being used to fetch the + structure value address at the beginning of a function. If you need + to emit adjusting code, you should do it at this point. + +.. hook-end + +.. c:macro:: PCC_STATIC_STRUCT_RETURN + + Define this macro if the usual system convention on the target machine + for returning structures and unions is for the called function to return + the address of a static variable containing the value. + + Do not define this if the usual system convention is for the caller to + pass an address to the subroutine. + + This macro has effect in :option:`-fpcc-struct-return` mode, but it does + nothing when you use :option:`-freg-struct-return` mode. + +.. function:: fixed_size_mode TARGET_GET_RAW_RESULT_MODE (int regno) + + .. hook-start:TARGET_GET_RAW_RESULT_MODE + + This target hook returns the mode to be used when accessing raw return + registers in ``__builtin_return``. Define this macro if the value + in :samp:`{reg_raw_mode}` is not correct. + +.. hook-end + +.. function:: fixed_size_mode TARGET_GET_RAW_ARG_MODE (int regno) + + .. hook-start:TARGET_GET_RAW_ARG_MODE + + This target hook returns the mode to be used when accessing raw argument + registers in ``__builtin_apply_args``. Define this macro if the value + in :samp:`{reg_raw_mode}` is not correct. + +.. hook-end + +.. function:: bool TARGET_EMPTY_RECORD_P (const_tree type) + + .. hook-start:TARGET_EMPTY_RECORD_P + + This target hook returns true if the type is an empty record. The default + is to return ``false``. + +.. hook-end + +.. function:: void TARGET_WARN_PARAMETER_PASSING_ABI (cumulative_args_t ca, tree type) + + .. hook-start:TARGET_WARN_PARAMETER_PASSING_ABI + + This target hook warns about the change in empty class parameter passing + ABI. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/how-scalar-function-values-are-returned.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/how-scalar-function-values-are-returned.rst new file mode 100644 index 00000000000..ea11268807d --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/how-scalar-function-values-are-returned.rst @@ -0,0 +1,166 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: return values in registers, values, returned by functions, scalars, returned as values + +.. _scalar-return: + +How Scalar Function Values Are Returned +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This section discusses the macros that control returning scalars as +values---values that can fit in registers. + +.. function:: rtx TARGET_FUNCTION_VALUE (const_tree ret_type, const_tree fn_decl_or_type, bool outgoing) + + .. hook-start:TARGET_FUNCTION_VALUE + + Define this to return an RTX representing the place where a function + returns or receives a value of data type :samp:`{ret_type}`, a tree node + representing a data type. :samp:`{fn_decl_or_type}` is a tree node + representing ``FUNCTION_DECL`` or ``FUNCTION_TYPE`` of a + function being called. If :samp:`{outgoing}` is false, the hook should + compute the register in which the caller will see the return value. + Otherwise, the hook should return an RTX representing the place where + a function returns a value. + + On many machines, only ``TYPE_MODE (ret_type)`` is relevant. + (Actually, on most machines, scalar values are returned in the same + place regardless of mode.) The value of the expression is usually a + ``reg`` RTX for the hard register where the return value is stored. + The value can also be a ``parallel`` RTX, if the return value is in + multiple places. See ``TARGET_FUNCTION_ARG`` for an explanation of the + ``parallel`` form. Note that the callee will populate every + location specified in the ``parallel``, but if the first element of + the ``parallel`` contains the whole return value, callers will use + that element as the canonical location and ignore the others. The m68k + port uses this type of ``parallel`` to return pointers in both + :samp:`%a0` (the canonical location) and :samp:`%d0`. + + If ``TARGET_PROMOTE_FUNCTION_RETURN`` returns true, you must apply + the same promotion rules specified in ``PROMOTE_MODE`` if + :samp:`{valtype}` is a scalar type. + + If the precise function being called is known, :samp:`{func}` is a tree + node (``FUNCTION_DECL``) for it; otherwise, :samp:`{func}` is a null + pointer. This makes it possible to use a different value-returning + convention for specific functions when all their calls are + known. + + Some target machines have 'register windows' so that the register in + which a function returns its value is not the same as the one in which + the caller sees the value. For such machines, you should return + different RTX depending on :samp:`{outgoing}`. + + ``TARGET_FUNCTION_VALUE`` is not used for return values with + aggregate data types, because these are returned in another way. See + ``TARGET_STRUCT_VALUE_RTX`` and related macros, below. + +.. hook-end + +.. c:macro:: FUNCTION_VALUE (valtype, func) + + This macro has been deprecated. Use ``TARGET_FUNCTION_VALUE`` for + a new target instead. + +.. c:macro:: LIBCALL_VALUE (mode) + + A C expression to create an RTX representing the place where a library + function returns a value of mode :samp:`{mode}`. + + Note that 'library function' in this context means a compiler + support routine, used to perform arithmetic, whose name is known + specially by the compiler and was not mentioned in the C code being + compiled. + +.. function:: rtx TARGET_LIBCALL_VALUE (machine_mode mode, const_rtx fun) + + .. hook-start:TARGET_LIBCALL_VALUE + + Define this hook if the back-end needs to know the name of the libcall + function in order to determine where the result should be returned. + + The mode of the result is given by :samp:`{mode}` and the name of the called + library function is given by :samp:`{fun}`. The hook should return an RTX + representing the place where the library function result will be returned. + + If this hook is not defined, then LIBCALL_VALUE will be used. + +.. hook-end + +.. c:macro:: FUNCTION_VALUE_REGNO_P (regno) + + A C expression that is nonzero if :samp:`{regno}` is the number of a hard + register in which the values of called function may come back. + + A register whose use for returning values is limited to serving as the + second of a pair (for a value of type ``double``, say) need not be + recognized by this macro. So for most machines, this definition + suffices: + + .. code-block:: c++ + + #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0) + + If the machine has register windows, so that the caller and the called + function use different registers for the return value, this macro + should recognize only the caller's register numbers. + + This macro has been deprecated. Use ``TARGET_FUNCTION_VALUE_REGNO_P`` + for a new target instead. + +.. function:: bool TARGET_FUNCTION_VALUE_REGNO_P (const unsigned int regno) + + .. hook-start:TARGET_FUNCTION_VALUE_REGNO_P + + A target hook that return ``true`` if :samp:`{regno}` is the number of a hard + register in which the values of called function may come back. + + A register whose use for returning values is limited to serving as the + second of a pair (for a value of type ``double``, say) need not be + recognized by this target hook. + + If the machine has register windows, so that the caller and the called + function use different registers for the return value, this target hook + should recognize only the caller's register numbers. + + If this hook is not defined, then FUNCTION_VALUE_REGNO_P will be used. + +.. hook-end + +.. c:macro:: APPLY_RESULT_SIZE + + Define this macro if :samp:`untyped_call` and :samp:`untyped_return` + need more space than is implied by ``FUNCTION_VALUE_REGNO_P`` for + saving and restoring an arbitrary return value. + +.. c:var:: bool TARGET_OMIT_STRUCT_RETURN_REG + + .. hook-start:TARGET_OMIT_STRUCT_RETURN_REG + + Normally, when a function returns a structure by memory, the address + is passed as an invisible pointer argument, but the compiler also + arranges to return the address from the function like it would a normal + pointer return value. Define this to true if that behavior is + undesirable on your target. + +.. hook-end + +.. function:: bool TARGET_RETURN_IN_MSB (const_tree type) + + .. hook-start:TARGET_RETURN_IN_MSB + + This hook should return true if values of type :samp:`{type}` are returned + at the most significant end of a register (in other words, if they are + padded at the least significant end). You can assume that :samp:`{type}` + is returned in a register; the caller is required to check this. + + Note that the register provided by ``TARGET_FUNCTION_VALUE`` must + be able to hold the complete return value. For example, if a 1-, 2- + or 3-byte structure is returned at the most significant end of a + 4-byte register, ``TARGET_FUNCTION_VALUE`` should provide an + ``SImode`` rtx. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/miscellaneous-register-hooks.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/miscellaneous-register-hooks.rst new file mode 100644 index 00000000000..907ea8228fd --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/miscellaneous-register-hooks.rst @@ -0,0 +1,26 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: miscellaneous register hooks + +.. _miscellaneous-register-hooks: + +Miscellaneous register hooks +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. c:var:: bool TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS + + .. hook-start:TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS + + Set to true if each call that binds to a local definition explicitly + clobbers or sets all non-fixed registers modified by performing the call. + That is, by the call pattern itself, or by code that might be inserted by the + linker (e.g. stubs, veneers, branch islands), but not including those + modifiable by the callee. The affected registers may be mentioned explicitly + in the call pattern, or included as clobbers in CALL_INSN_FUNCTION_USAGE. + The default version of this hook is set to false. The purpose of this hook + is to enable the fipa-ra optimization. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/passing-arguments-in-registers.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/passing-arguments-in-registers.rst new file mode 100644 index 00000000000..d724d655163 --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/passing-arguments-in-registers.rst @@ -0,0 +1,633 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: arguments in registers, registers arguments + +.. _register-arguments: + +Passing Arguments in Registers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This section describes the macros which let you control how various +types of arguments are passed in registers or how they are arranged in +the stack. + +.. function:: rtx TARGET_FUNCTION_ARG (cumulative_args_t ca, const function_arg_info &arg) + + .. hook-start:TARGET_FUNCTION_ARG + + Return an RTX indicating whether function argument :samp:`{arg}` is passed + in a register and if so, which register. Argument :samp:`{ca}` summarizes all + the previous arguments. + + The return value is usually either a ``reg`` RTX for the hard + register in which to pass the argument, or zero to pass the argument + on the stack. + + The value of the expression can also be a ``parallel`` RTX. This is + used when an argument is passed in multiple locations. The mode of the + ``parallel`` should be the mode of the entire argument. The + ``parallel`` holds any number of ``expr_list`` pairs; each one + describes where part of the argument is passed. In each + ``expr_list`` the first operand must be a ``reg`` RTX for the hard + register in which to pass this part of the argument, and the mode of the + register RTX indicates how large this part of the argument is. The + second operand of the ``expr_list`` is a ``const_int`` which gives + the offset in bytes into the entire argument of where this part starts. + As a special exception the first ``expr_list`` in the ``parallel`` + RTX may have a first operand of zero. This indicates that the entire + argument is also stored on the stack. + + The last time this hook is called, it is called with ``MODE == + VOIDmode``, and its result is passed to the ``call`` or ``call_value`` + pattern as operands 2 and 3 respectively. + + .. index:: stdarg.h and register arguments + + The usual way to make the ISO library :samp:`stdarg.h` work on a + machine where some arguments are usually passed in registers, is to + cause nameless arguments to be passed on the stack instead. This is + done by making ``TARGET_FUNCTION_ARG`` return 0 whenever + :samp:`{named}` is ``false``. + + .. index:: TARGET_MUST_PASS_IN_STACK, and TARGET_FUNCTION_ARG, REG_PARM_STACK_SPACE, and TARGET_FUNCTION_ARG + + You may use the hook ``targetm.calls.must_pass_in_stack`` + in the definition of this macro to determine if this argument is of a + type that must be passed in the stack. If ``REG_PARM_STACK_SPACE`` + is not defined and ``TARGET_FUNCTION_ARG`` returns nonzero for such an + argument, the compiler will abort. If ``REG_PARM_STACK_SPACE`` is + defined, the argument will be computed in the stack and then loaded into + a register. + +.. hook-end + +.. function:: bool TARGET_MUST_PASS_IN_STACK (const function_arg_info &arg) + + .. hook-start:TARGET_MUST_PASS_IN_STACK + + This target hook should return ``true`` if we should not pass :samp:`{arg}` + solely in registers. The file :samp:`expr.h` defines a + definition that is usually appropriate, refer to :samp:`expr.h` for additional + documentation. + +.. hook-end + +.. function:: rtx TARGET_FUNCTION_INCOMING_ARG (cumulative_args_t ca, const function_arg_info &arg) + + .. hook-start:TARGET_FUNCTION_INCOMING_ARG + + Define this hook if the caller and callee on the target have different + views of where arguments are passed. Also define this hook if there are + functions that are never directly called, but are invoked by the hardware + and which have nonstandard calling conventions. + + In this case ``TARGET_FUNCTION_ARG`` computes the register in + which the caller passes the value, and + ``TARGET_FUNCTION_INCOMING_ARG`` should be defined in a similar + fashion to tell the function being called where the arguments will + arrive. + + ``TARGET_FUNCTION_INCOMING_ARG`` can also return arbitrary address + computation using hard register, which can be forced into a register, + so that it can be used to pass special arguments. + + If ``TARGET_FUNCTION_INCOMING_ARG`` is not defined, + ``TARGET_FUNCTION_ARG`` serves both purposes. + +.. hook-end + +.. function:: bool TARGET_USE_PSEUDO_PIC_REG (void) + + .. hook-start:TARGET_USE_PSEUDO_PIC_REG + + This hook should return 1 in case pseudo register should be created + for pic_offset_table_rtx during function expand. + +.. hook-end + +.. function:: void TARGET_INIT_PIC_REG (void) + + .. hook-start:TARGET_INIT_PIC_REG + + Perform a target dependent initialization of pic_offset_table_rtx. + This hook is called at the start of register allocation. + +.. hook-end + +.. function:: int TARGET_ARG_PARTIAL_BYTES (cumulative_args_t cum, const function_arg_info &arg) + + .. hook-start:TARGET_ARG_PARTIAL_BYTES + + This target hook returns the number of bytes at the beginning of an + argument that must be put in registers. The value must be zero for + arguments that are passed entirely in registers or that are entirely + pushed on the stack. + + On some machines, certain arguments must be passed partially in + registers and partially in memory. On these machines, typically the + first few words of arguments are passed in registers, and the rest + on the stack. If a multi-word argument (a ``double`` or a + structure) crosses that boundary, its first few words must be passed + in registers and the rest must be pushed. This macro tells the + compiler when this occurs, and how many bytes should go in registers. + + ``TARGET_FUNCTION_ARG`` for these arguments should return the first + register to be used by the caller for this argument; likewise + ``TARGET_FUNCTION_INCOMING_ARG``, for the called function. + +.. hook-end + +.. function:: bool TARGET_PASS_BY_REFERENCE (cumulative_args_t cum, const function_arg_info &arg) + + .. hook-start:TARGET_PASS_BY_REFERENCE + + This target hook should return ``true`` if argument :samp:`{arg}` at the + position indicated by :samp:`{cum}` should be passed by reference. This + predicate is queried after target independent reasons for being + passed by reference, such as ``TREE_ADDRESSABLE (arg.type)``. + + If the hook returns true, a copy of that argument is made in memory and a + pointer to the argument is passed instead of the argument itself. + The pointer is passed in whatever way is appropriate for passing a pointer + to that type. + +.. hook-end + +.. function:: bool TARGET_CALLEE_COPIES (cumulative_args_t cum, const function_arg_info &arg) + + .. hook-start:TARGET_CALLEE_COPIES + + The function argument described by the parameters to this hook is + known to be passed by reference. The hook should return true if the + function argument should be copied by the callee instead of copied + by the caller. + + For any argument for which the hook returns true, if it can be + determined that the argument is not modified, then a copy need + not be generated. + + The default version of this hook always returns false. + +.. hook-end + +.. c:macro:: CUMULATIVE_ARGS + + A C type for declaring a variable that is used as the first argument + of ``TARGET_FUNCTION_ARG`` and other related values. For some + target machines, the type ``int`` suffices and can hold the number + of bytes of argument so far. + + There is no need to record in ``CUMULATIVE_ARGS`` anything about the + arguments that have been passed on the stack. The compiler has other + variables to keep track of that. For target machines on which all + arguments are passed on the stack, there is no need to store anything in + ``CUMULATIVE_ARGS`` ; however, the data structure must exist and + should not be empty, so use ``int``. + +.. c:macro:: OVERRIDE_ABI_FORMAT (fndecl) + + If defined, this macro is called before generating any code for a + function, but after the :samp:`{cfun}` descriptor for the function has been + created. The back end may use this macro to update :samp:`{cfun}` to + reflect an ABI other than that which would normally be used by default. + If the compiler is generating code for a compiler-generated function, + :samp:`{fndecl}` may be ``NULL``. + +.. c:macro:: INIT_CUMULATIVE_ARGS (cum, fntype, libname, fndecl, n_named_args) + + A C statement (sans semicolon) for initializing the variable + :samp:`{cum}` for the state at the beginning of the argument list. The + variable has type ``CUMULATIVE_ARGS``. The value of :samp:`{fntype}` + is the tree node for the data type of the function which will receive + the args, or 0 if the args are to a compiler support library function. + For direct calls that are not libcalls, :samp:`{fndecl}` contain the + declaration node of the function. :samp:`{fndecl}` is also set when + ``INIT_CUMULATIVE_ARGS`` is used to find arguments for the function + being compiled. :samp:`{n_named_args}` is set to the number of named + arguments, including a structure return address if it is passed as a + parameter, when making a call. When processing incoming arguments, + :samp:`{n_named_args}` is set to -1. + + When processing a call to a compiler support library function, + :samp:`{libname}` identifies which one. It is a ``symbol_ref`` rtx which + contains the name of the function, as a string. :samp:`{libname}` is 0 when + an ordinary C function call is being processed. Thus, each time this + macro is called, either :samp:`{libname}` or :samp:`{fntype}` is nonzero, but + never both of them at once. + +.. c:macro:: INIT_CUMULATIVE_LIBCALL_ARGS (cum, mode, libname) + + Like ``INIT_CUMULATIVE_ARGS`` but only used for outgoing libcalls, + it gets a ``MODE`` argument instead of :samp:`{fntype}`, that would be + ``NULL``. :samp:`{indirect}` would always be zero, too. If this macro + is not defined, ``INIT_CUMULATIVE_ARGS (cum, NULL_RTX, libname, + 0)`` is used instead. + +.. c:macro:: INIT_CUMULATIVE_INCOMING_ARGS (cum, fntype, libname) + + Like ``INIT_CUMULATIVE_ARGS`` but overrides it for the purposes of + finding the arguments for the function being compiled. If this macro is + undefined, ``INIT_CUMULATIVE_ARGS`` is used instead. + + The value passed for :samp:`{libname}` is always 0, since library routines + with special calling conventions are never compiled with GCC. The + argument :samp:`{libname}` exists for symmetry with + ``INIT_CUMULATIVE_ARGS``. + + .. could use "this macro" in place of @code{INIT_CUMULATIVE_ARGS}, maybe. + + .. -mew 5feb93 i switched the order of the sentences. -mew 10feb93 + +.. function:: void TARGET_FUNCTION_ARG_ADVANCE (cumulative_args_t ca, const function_arg_info &arg) + + .. hook-start:TARGET_FUNCTION_ARG_ADVANCE + + This hook updates the summarizer variable pointed to by :samp:`{ca}` to + advance past argument :samp:`{arg}` in the argument list. Once this is done, + the variable :samp:`{cum}` is suitable for analyzing the *following* + argument with ``TARGET_FUNCTION_ARG``, etc. + + This hook need not do anything if the argument in question was passed + on the stack. The compiler knows how to track the amount of stack space + used for arguments without any special help. + +.. hook-end + +.. function:: HOST_WIDE_INT TARGET_FUNCTION_ARG_OFFSET (machine_mode mode, const_tree type) + + .. hook-start:TARGET_FUNCTION_ARG_OFFSET + + This hook returns the number of bytes to add to the offset of an + argument of type :samp:`{type}` and mode :samp:`{mode}` when passed in memory. + This is needed for the SPU, which passes ``char`` and ``short`` + arguments in the preferred slot that is in the middle of the quad word + instead of starting at the top. The default implementation returns 0. + +.. hook-end + +.. function:: pad_direction TARGET_FUNCTION_ARG_PADDING (machine_mode mode, const_tree type) + + .. hook-start:TARGET_FUNCTION_ARG_PADDING + + This hook determines whether, and in which direction, to pad out + an argument of mode :samp:`{mode}` and type :samp:`{type}`. It returns + ``PAD_UPWARD`` to insert padding above the argument, ``PAD_DOWNWARD`` + to insert padding below the argument, or ``PAD_NONE`` to inhibit padding. + + The *amount* of padding is not controlled by this hook, but by + ``TARGET_FUNCTION_ARG_ROUND_BOUNDARY``. It is always just enough + to reach the next multiple of that boundary. + + This hook has a default definition that is right for most systems. + For little-endian machines, the default is to pad upward. For + big-endian machines, the default is to pad downward for an argument of + constant size shorter than an ``int``, and upward otherwise. + +.. hook-end + +.. c:macro:: PAD_VARARGS_DOWN + + If defined, a C expression which determines whether the default + implementation of va_arg will attempt to pad down before reading the + next argument, if that argument is smaller than its aligned space as + controlled by ``PARM_BOUNDARY``. If this macro is not defined, all such + arguments are padded down if ``BYTES_BIG_ENDIAN`` is true. + +.. c:macro:: BLOCK_REG_PADDING (mode, type, first) + + Specify padding for the last element of a block move between registers and + memory. :samp:`{first}` is nonzero if this is the only element. Defining this + macro allows better control of register function parameters on big-endian + machines, without using ``PARALLEL`` rtl. In particular, + ``MUST_PASS_IN_STACK`` need not test padding and mode of types in + registers, as there is no longer a "wrong" part of a register; For example, + a three byte aggregate may be passed in the high part of a register if so + required. + +.. function:: unsigned int TARGET_FUNCTION_ARG_BOUNDARY (machine_mode mode, const_tree type) + + .. hook-start:TARGET_FUNCTION_ARG_BOUNDARY + + This hook returns the alignment boundary, in bits, of an argument + with the specified mode and type. The default hook returns + ``PARM_BOUNDARY`` for all arguments. + +.. hook-end + +.. function:: unsigned int TARGET_FUNCTION_ARG_ROUND_BOUNDARY (machine_mode mode, const_tree type) + + .. hook-start:TARGET_FUNCTION_ARG_ROUND_BOUNDARY + + Normally, the size of an argument is rounded up to ``PARM_BOUNDARY``, + which is the default value for this hook. You can define this hook to + return a different value if an argument size must be rounded to a larger + value. + +.. hook-end + +.. c:macro:: FUNCTION_ARG_REGNO_P (regno) + + A C expression that is nonzero if :samp:`{regno}` is the number of a hard + register in which function arguments are sometimes passed. This does + *not* include implicit arguments such as the static chain and + the structure-value address. On many machines, no registers can be + used for this purpose since all function arguments are pushed on the + stack. + +.. function:: bool TARGET_SPLIT_COMPLEX_ARG (const_tree type) + + .. hook-start:TARGET_SPLIT_COMPLEX_ARG + + This hook should return true if parameter of type :samp:`{type}` are passed + as two scalar parameters. By default, GCC will attempt to pack complex + arguments into the target's word size. Some ABIs require complex arguments + to be split and treated as their individual components. For example, on + AIX64, complex floats should be passed in a pair of floating point + registers, even though a complex float would fit in one 64-bit floating + point register. + + The default value of this hook is ``NULL``, which is treated as always + false. + +.. hook-end + +.. function:: tree TARGET_BUILD_BUILTIN_VA_LIST (void) + + .. hook-start:TARGET_BUILD_BUILTIN_VA_LIST + + This hook returns a type node for ``va_list`` for the target. + The default version of the hook returns ``void*``. + +.. hook-end + +.. function:: int TARGET_ENUM_VA_LIST_P (int idx, const char **pname, tree *ptree) + + .. hook-start:TARGET_ENUM_VA_LIST_P + + This target hook is used in function ``c_common_nodes_and_builtins`` + to iterate through the target specific builtin types for va_list. The + variable :samp:`{idx}` is used as iterator. :samp:`{pname}` has to be a pointer + to a ``const char *`` and :samp:`{ptree}` a pointer to a ``tree`` typed + variable. + The arguments :samp:`{pname}` and :samp:`{ptree}` are used to store the result of + this macro and are set to the name of the va_list builtin type and its + internal type. + If the return value of this macro is zero, then there is no more element. + Otherwise the :samp:`{IDX}` should be increased for the next call of this + macro to iterate through all types. + +.. hook-end + +.. function:: tree TARGET_FN_ABI_VA_LIST (tree fndecl) + + .. hook-start:TARGET_FN_ABI_VA_LIST + + This hook returns the va_list type of the calling convention specified by + :samp:`{fndecl}`. + The default version of this hook returns ``va_list_type_node``. + +.. hook-end + +.. function:: tree TARGET_CANONICAL_VA_LIST_TYPE (tree type) + + .. hook-start:TARGET_CANONICAL_VA_LIST_TYPE + + This hook returns the va_list type of the calling convention specified by the + type of :samp:`{type}`. If :samp:`{type}` is not a valid va_list type, it returns + ``NULL_TREE``. + +.. hook-end + +.. function:: tree TARGET_GIMPLIFY_VA_ARG_EXPR (tree valist, tree type, gimple_seq *pre_p, gimple_seq *post_p) + + .. hook-start:TARGET_GIMPLIFY_VA_ARG_EXPR + + This hook performs target-specific gimplification of + ``VA_ARG_EXPR``. The first two parameters correspond to the + arguments to ``va_arg`` ; the latter two are as in + ``gimplify.cc:gimplify_expr``. + +.. hook-end + +.. function:: bool TARGET_VALID_POINTER_MODE (scalar_int_mode mode) + + .. hook-start:TARGET_VALID_POINTER_MODE + + Define this to return nonzero if the port can handle pointers + with machine mode :samp:`{mode}`. The default version of this + hook returns true for both ``ptr_mode`` and ``Pmode``. + +.. hook-end + +.. function:: bool TARGET_REF_MAY_ALIAS_ERRNO (ao_ref *ref) + + .. hook-start:TARGET_REF_MAY_ALIAS_ERRNO + + Define this to return nonzero if the memory reference :samp:`{ref}` + may alias with the system C library errno location. The default + version of this hook assumes the system C library errno location + is either a declaration of type int or accessed by dereferencing + a pointer to int. + +.. hook-end + +.. function:: machine_mode TARGET_TRANSLATE_MODE_ATTRIBUTE (machine_mode mode) + + .. hook-start:TARGET_TRANSLATE_MODE_ATTRIBUTE + + Define this hook if during mode attribute processing, the port should + translate machine_mode :samp:`{mode}` to another mode. For example, rs6000's + ``KFmode``, when it is the same as ``TFmode``. + + The default version of the hook returns that mode that was passed in. + +.. hook-end + +.. function:: bool TARGET_SCALAR_MODE_SUPPORTED_P (scalar_mode mode) + + .. hook-start:TARGET_SCALAR_MODE_SUPPORTED_P + + Define this to return nonzero if the port is prepared to handle + insns involving scalar mode :samp:`{mode}`. For a scalar mode to be + considered supported, all the basic arithmetic and comparisons + must work. + + The default version of this hook returns true for any mode + required to handle the basic C types (as defined by the port). + Included here are the double-word arithmetic supported by the + code in :samp:`optabs.cc`. + +.. hook-end + +.. function:: bool TARGET_VECTOR_MODE_SUPPORTED_P (machine_mode mode) + + .. hook-start:TARGET_VECTOR_MODE_SUPPORTED_P + + Define this to return nonzero if the port is prepared to handle + insns involving vector mode :samp:`{mode}`. At the very least, it + must have move patterns for this mode. + +.. hook-end + +.. function:: bool TARGET_COMPATIBLE_VECTOR_TYPES_P (const_tree type1, const_tree type2) + + .. hook-start:TARGET_COMPATIBLE_VECTOR_TYPES_P + + Return true if there is no target-specific reason for treating + vector types :samp:`{type1}` and :samp:`{type2}` as distinct types. The caller + has already checked for target-independent reasons, meaning that the + types are known to have the same mode, to have the same number of elements, + and to have what the caller considers to be compatible element types. + + The main reason for defining this hook is to reject pairs of types + that are handled differently by the target's calling convention. + For example, when a new :samp:`{N}` -bit vector architecture is added + to a target, the target may want to handle normal :samp:`{N}` -bit + ``VECTOR_TYPE`` arguments and return values in the same way as + before, to maintain backwards compatibility. However, it may also + provide new, architecture-specific ``VECTOR_TYPE`` s that are passed + and returned in a more efficient way. It is then important to maintain + a distinction between the 'normal' ``VECTOR_TYPE`` s and the new + architecture-specific ones. + + The default implementation returns true, which is correct for most targets. + +.. hook-end + +.. function:: opt_machine_mode TARGET_ARRAY_MODE (machine_mode mode, unsigned HOST_WIDE_INT nelems) + + .. hook-start:TARGET_ARRAY_MODE + + Return the mode that GCC should use for an array that has + :samp:`{nelems}` elements, with each element having mode :samp:`{mode}`. + Return no mode if the target has no special requirements. In the + latter case, GCC looks for an integer mode of the appropriate size + if available and uses BLKmode otherwise. Usually the search for the + integer mode is limited to ``MAX_FIXED_MODE_SIZE``, but the + ``TARGET_ARRAY_MODE_SUPPORTED_P`` hook allows a larger mode to be + used in specific cases. + + The main use of this hook is to specify that an array of vectors should + also have a vector mode. The default implementation returns no mode. + +.. hook-end + +.. function:: bool TARGET_ARRAY_MODE_SUPPORTED_P (machine_mode mode, unsigned HOST_WIDE_INT nelems) + + .. hook-start:TARGET_ARRAY_MODE_SUPPORTED_P + + Return true if GCC should try to use a scalar mode to store an array + of :samp:`{nelems}` elements, given that each element has mode :samp:`{mode}`. + Returning true here overrides the usual ``MAX_FIXED_MODE`` limit + and allows GCC to use any defined integer mode. + + One use of this hook is to support vector load and store operations + that operate on several homogeneous vectors. For example, ARM NEON + has operations like: + + .. code-block:: c++ + + int8x8x3_t vld3_s8 (const int8_t *) + + where the return type is defined as: + + .. code-block:: c++ + + typedef struct int8x8x3_t + { + int8x8_t val[3]; + } int8x8x3_t; + + If this hook allows ``val`` to have a scalar mode, then + ``int8x8x3_t`` can have the same mode. GCC can then store + ``int8x8x3_t`` s in registers rather than forcing them onto the stack. + +.. hook-end + +.. function:: bool TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P (scalar_float_mode mode) + + .. hook-start:TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P + + Define this to return nonzero if libgcc provides support for the + floating-point mode :samp:`{mode}`, which is known to pass + ``TARGET_SCALAR_MODE_SUPPORTED_P``. The default version of this + hook returns true for all of ``SFmode``, ``DFmode``, + ``XFmode`` and ``TFmode``, if such modes exist. + +.. hook-end + +.. function:: opt_scalar_float_mode TARGET_FLOATN_MODE (int n, bool extended) + + .. hook-start:TARGET_FLOATN_MODE + + Define this to return the machine mode to use for the type + ``_Floatn``, if :samp:`{extended}` is false, or the type + ``_Floatnx``, if :samp:`{extended}` is true. If such a type is not + supported, return ``opt_scalar_float_mode ()``. The default version of + this hook returns ``SFmode`` for ``_Float32``, ``DFmode`` for + ``_Float64`` and ``_Float32x`` and ``TFmode`` for + ``_Float128``, if those modes exist and satisfy the requirements for + those types and pass ``TARGET_SCALAR_MODE_SUPPORTED_P`` and + ``TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P`` ; for ``_Float64x``, it + returns the first of ``XFmode`` and ``TFmode`` that exists and + satisfies the same requirements; for other types, it returns + ``opt_scalar_float_mode ()``. The hook is only called for values + of :samp:`{n}` and :samp:`{extended}` that are valid according to + ISO/IEC TS 18661-3:2015; that is, :samp:`{n}` is one of 32, 64, 128, or, + if :samp:`{extended}` is false, 16 or greater than 128 and a multiple of 32. + +.. hook-end + +.. function:: bool TARGET_FLOATN_BUILTIN_P (int func) + + .. hook-start:TARGET_FLOATN_BUILTIN_P + + Define this to return true if the ``_Floatn`` and + ``_Floatnx`` built-in functions should implicitly enable the + built-in function without the ``__builtin_`` prefix in addition to the + normal built-in function with the ``__builtin_`` prefix. The default is + to only enable built-in functions without the ``__builtin_`` prefix for + the GNU C langauge. In strict ANSI/ISO mode, the built-in function without + the ``__builtin_`` prefix is not enabled. The argument ``FUNC`` is the + ``enum built_in_function`` id of the function to be enabled. + +.. hook-end + +.. function:: bool TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P (machine_mode mode) + + .. hook-start:TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P + + Define this to return nonzero for machine modes for which the port has + small register classes. If this target hook returns nonzero for a given + :samp:`{mode}`, the compiler will try to minimize the lifetime of registers + in :samp:`{mode}`. The hook may be called with ``VOIDmode`` as argument. + In this case, the hook is expected to return nonzero if it returns nonzero + for any mode. + + On some machines, it is risky to let hard registers live across arbitrary + insns. Typically, these machines have instructions that require values + to be in specific registers (like an accumulator), and reload will fail + if the required hard register is used for another purpose across such an + insn. + + Passes before reload do not know which hard registers will be used + in an instruction, but the machine modes of the registers set or used in + the instruction are already known. And for some machines, register + classes are small for, say, integer registers but not for floating point + registers. For example, the AMD x86-64 architecture requires specific + registers for the legacy x86 integer instructions, but there are many + SSE registers for floating point operations. On such targets, a good + strategy may be to return nonzero from this hook for ``INTEGRAL_MODE_P`` + machine modes but zero for the SSE register classes. + + The default version of this hook returns false for any mode. It is always + safe to redefine this hook to return with a nonzero value. But if you + unnecessarily define it, you will reduce the amount of optimizations + that can be performed in some cases. If you do not define this hook + to return a nonzero value when it is required, the compiler will run out + of spill registers and print a fatal error message. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/passing-function-arguments-on-the-stack.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/passing-function-arguments-on-the-stack.rst new file mode 100644 index 00000000000..ed99faaf4b4 --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/passing-function-arguments-on-the-stack.rst @@ -0,0 +1,193 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: arguments on stack, stack arguments + +.. _stack-arguments: + +Passing Function Arguments on the Stack +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The macros in this section control how arguments are passed +on the stack. See the following section for other macros that +control passing certain arguments in registers. + +.. function:: bool TARGET_PROMOTE_PROTOTYPES (const_tree fntype) + + .. hook-start:TARGET_PROMOTE_PROTOTYPES + + This target hook returns ``true`` if an argument declared in a + prototype as an integral type smaller than ``int`` should actually be + passed as an ``int``. In addition to avoiding errors in certain + cases of mismatch, it also makes for better code on certain machines. + The default is to not promote prototypes. + +.. hook-end + +.. function:: bool TARGET_PUSH_ARGUMENT (unsigned int npush) + + .. hook-start:TARGET_PUSH_ARGUMENT + + This target hook returns ``true`` if push instructions will be + used to pass outgoing arguments. When the push instruction usage is + optional, :samp:`{npush}` is nonzero to indicate the number of bytes to + push. Otherwise, :samp:`{npush}` is zero. If the target machine does not + have a push instruction or push instruction should be avoided, + ``false`` should be returned. That directs GCC to use an alternate + strategy: to allocate the entire argument block and then store the + arguments into it. If this target hook may return ``true``, + ``PUSH_ROUNDING`` must be defined. + +.. hook-end + +.. c:macro:: PUSH_ARGS_REVERSED + + A C expression. If nonzero, function arguments will be evaluated from + last to first, rather than from first to last. If this macro is not + defined, it defaults to ``PUSH_ARGS`` on targets where the stack + and args grow in opposite directions, and 0 otherwise. + +.. c:macro:: PUSH_ROUNDING (npushed) + + A C expression that is the number of bytes actually pushed onto the + stack when an instruction attempts to push :samp:`{npushed}` bytes. + + On some machines, the definition + + .. code-block:: c++ + + #define PUSH_ROUNDING(BYTES) (BYTES) + + will suffice. But on other machines, instructions that appear + to push one byte actually push two bytes in an attempt to maintain + alignment. Then the definition should be + + .. code-block:: c++ + + #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1) + + If the value of this macro has a type, it should be an unsigned type. + +.. index:: outgoing_args_size, crtl->outgoing_args_size + +.. c:macro:: ACCUMULATE_OUTGOING_ARGS + + A C expression. If nonzero, the maximum amount of space required for outgoing arguments + will be computed and placed into + ``crtl->outgoing_args_size``. No space will be pushed + onto the stack for each call; instead, the function prologue should + increase the stack frame size by this amount. + + Setting both ``PUSH_ARGS`` and ``ACCUMULATE_OUTGOING_ARGS`` + is not proper. + +.. c:macro:: REG_PARM_STACK_SPACE (fndecl) + + Define this macro if functions should assume that stack space has been + allocated for arguments even when their values are passed in + registers. + + The value of this macro is the size, in bytes, of the area reserved for + arguments passed in registers for the function represented by :samp:`{fndecl}`, + which can be zero if GCC is calling a library function. + The argument :samp:`{fndecl}` can be the FUNCTION_DECL, or the type itself + of the function. + + This space can be allocated by the caller, or be a part of the + machine-dependent stack frame: ``OUTGOING_REG_PARM_STACK_SPACE`` says + which. + +.. above is overfull. not sure what to do. -mew 5feb93 did + +.. something, not sure if it looks good. -mew 10feb93 + +.. c:macro:: INCOMING_REG_PARM_STACK_SPACE (fndecl) + + Like ``REG_PARM_STACK_SPACE``, but for incoming register arguments. + Define this macro if space guaranteed when compiling a function body + is different to space required when making a call, a situation that + can arise with K&R style function definitions. + +.. c:macro:: OUTGOING_REG_PARM_STACK_SPACE (fntype) + + Define this to a nonzero value if it is the responsibility of the + caller to allocate the area reserved for arguments passed in registers + when calling a function of :samp:`{fntype}`. :samp:`{fntype}` may be NULL + if the function called is a library function. + + If ``ACCUMULATE_OUTGOING_ARGS`` is defined, this macro controls + whether the space for these arguments counts in the value of + ``crtl->outgoing_args_size``. + +.. c:macro:: STACK_PARMS_IN_REG_PARM_AREA + + Define this macro if ``REG_PARM_STACK_SPACE`` is defined, but the + stack parameters don't skip the area specified by it. + + .. i changed this, makes more sens and it should have taken care of the + + .. overfull.. not as specific, tho. -mew 5feb93 + + Normally, when a parameter is not passed in registers, it is placed on the + stack beyond the ``REG_PARM_STACK_SPACE`` area. Defining this macro + suppresses this behavior and causes the parameter to be passed on the + stack in its natural location. + +.. function:: poly_int64 TARGET_RETURN_POPS_ARGS (tree fundecl, tree funtype, poly_int64 size) + + .. hook-start:TARGET_RETURN_POPS_ARGS + + This target hook returns the number of bytes of its own arguments that + a function pops on returning, or 0 if the function pops no arguments + and the caller must therefore pop them all after the function returns. + + :samp:`{fundecl}` is a C variable whose value is a tree node that describes + the function in question. Normally it is a node of type + ``FUNCTION_DECL`` that describes the declaration of the function. + From this you can obtain the ``DECL_ATTRIBUTES`` of the function. + + :samp:`{funtype}` is a C variable whose value is a tree node that + describes the function in question. Normally it is a node of type + ``FUNCTION_TYPE`` that describes the data type of the function. + From this it is possible to obtain the data types of the value and + arguments (if known). + + When a call to a library function is being considered, :samp:`{fundecl}` + will contain an identifier node for the library function. Thus, if + you need to distinguish among various library functions, you can do so + by their names. Note that 'library function' in this context means + a function used to perform arithmetic, whose name is known specially + in the compiler and was not mentioned in the C code being compiled. + + :samp:`{size}` is the number of bytes of arguments passed on the + stack. If a variable number of bytes is passed, it is zero, and + argument popping will always be the responsibility of the calling function. + + On the VAX, all functions always pop their arguments, so the definition + of this macro is :samp:`{size}`. On the 68000, using the standard + calling convention, no functions pop their arguments, so the value of + the macro is always 0 in this case. But an alternative calling + convention is available in which functions that take a fixed number of + arguments pop them but other functions (such as ``printf``) pop + nothing (the caller pops all). When this convention is in use, + :samp:`{funtype}` is examined to determine whether a function takes a fixed + number of arguments. + +.. hook-end + +.. c:macro:: CALL_POPS_ARGS (cum) + + A C expression that should indicate the number of bytes a call sequence + pops off the stack. It is added to the value of ``RETURN_POPS_ARGS`` + when compiling a function call. + + :samp:`{cum}` is the variable in which all arguments to the called function + have been accumulated. + + On certain architectures, such as the SH5, a call trampoline is used + that pops certain registers off the stack, depending on the arguments + that have been passed to the function. Since this is a property of the + call site, not of the called function, ``RETURN_POPS_ARGS`` is not + appropriate. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/permitting-tail-calls.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/permitting-tail-calls.rst new file mode 100644 index 00000000000..229248cac3e --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/permitting-tail-calls.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: tail calls + +.. _tail-calls: + +Permitting tail calls +^^^^^^^^^^^^^^^^^^^^^ + +.. function:: bool TARGET_FUNCTION_OK_FOR_SIBCALL (tree decl, tree exp) + + .. hook-start:TARGET_FUNCTION_OK_FOR_SIBCALL + + True if it is OK to do sibling call optimization for the specified + call expression :samp:`{exp}`. :samp:`{decl}` will be the called function, + or ``NULL`` if this is an indirect call. + + It is not uncommon for limitations of calling conventions to prevent + tail calls to functions outside the current unit of translation, or + during PIC compilation. The hook is used to enforce these restrictions, + as the ``sibcall`` md pattern cannot fail, or fall over to a + 'normal' call. The criteria for successful sibling call optimization + may vary greatly between different architectures. + +.. hook-end + +.. function:: void TARGET_EXTRA_LIVE_ON_ENTRY (bitmap regs) + + .. hook-start:TARGET_EXTRA_LIVE_ON_ENTRY + + Add any hard registers to :samp:`{regs}` that are live on entry to the + function. This hook only needs to be defined to provide registers that + cannot be found by examination of FUNCTION_ARG_REGNO_P, the callee saved + registers, STATIC_CHAIN_INCOMING_REGNUM, STATIC_CHAIN_REGNUM, + TARGET_STRUCT_VALUE_RTX, FRAME_POINTER_REGNUM, EH_USES, + FRAME_POINTER_REGNUM, ARG_POINTER_REGNUM, and the PIC_OFFSET_TABLE_REGNUM. + +.. hook-end + +.. function:: void TARGET_SET_UP_BY_PROLOGUE (struct hard_reg_set_container *) + + .. hook-start:TARGET_SET_UP_BY_PROLOGUE + + This hook should add additional registers that are computed by the prologue + to the hard regset for shrink-wrapping optimization purposes. + +.. hook-end + +.. function:: bool TARGET_WARN_FUNC_RETURN (tree) + + .. hook-start:TARGET_WARN_FUNC_RETURN + + True if a function's return statements should be checked for matching + the function's return type. This includes checking for falling off the end + of a non-void function. Return false if no such check should be made. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/registers-that-address-the-stack-frame.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/registers-that-address-the-stack-frame.rst new file mode 100644 index 00000000000..129d22b899e --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/registers-that-address-the-stack-frame.rst @@ -0,0 +1,198 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _frame-registers: + +Registers That Address the Stack Frame +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. prevent bad page break with this line + +This discusses registers that address the stack frame. + +.. c:macro:: STACK_POINTER_REGNUM + + The register number of the stack pointer register, which must also be a + fixed register according to ``FIXED_REGISTERS``. On most machines, + the hardware determines which register this is. + +.. c:macro:: FRAME_POINTER_REGNUM + + The register number of the frame pointer register, which is used to + access automatic variables in the stack frame. On some machines, the + hardware determines which register this is. On other machines, you can + choose any register you wish for this purpose. + +.. c:macro:: HARD_FRAME_POINTER_REGNUM + + On some machines the offset between the frame pointer and starting + offset of the automatic variables is not known until after register + allocation has been done (for example, because the saved registers are + between these two locations). On those machines, define + ``FRAME_POINTER_REGNUM`` the number of a special, fixed register to + be used internally until the offset is known, and define + ``HARD_FRAME_POINTER_REGNUM`` to be the actual hard register number + used for the frame pointer. + + You should define this macro only in the very rare circumstances when it + is not possible to calculate the offset between the frame pointer and + the automatic variables until after register allocation has been + completed. When this macro is defined, you must also indicate in your + definition of ``ELIMINABLE_REGS`` how to eliminate + ``FRAME_POINTER_REGNUM`` into either ``HARD_FRAME_POINTER_REGNUM`` + or ``STACK_POINTER_REGNUM``. + + Do not define this macro if it would be the same as + ``FRAME_POINTER_REGNUM``. + +.. c:macro:: ARG_POINTER_REGNUM + + The register number of the arg pointer register, which is used to access + the function's argument list. On some machines, this is the same as the + frame pointer register. On some machines, the hardware determines which + register this is. On other machines, you can choose any register you + wish for this purpose. If this is not the same register as the frame + pointer register, then you must mark it as a fixed register according to + ``FIXED_REGISTERS``, or arrange to be able to eliminate it + (see :ref:`elimination`). + +.. c:macro:: HARD_FRAME_POINTER_IS_FRAME_POINTER + + Define this to a preprocessor constant that is nonzero if + ``hard_frame_pointer_rtx`` and ``frame_pointer_rtx`` should be + the same. The default definition is :samp:`(HARD_FRAME_POINTER_REGNUM + == FRAME_POINTER_REGNUM)`; you only need to define this macro if that + definition is not suitable for use in preprocessor conditionals. + +.. c:macro:: HARD_FRAME_POINTER_IS_ARG_POINTER + + Define this to a preprocessor constant that is nonzero if + ``hard_frame_pointer_rtx`` and ``arg_pointer_rtx`` should be the + same. The default definition is :samp:`(HARD_FRAME_POINTER_REGNUM == + ARG_POINTER_REGNUM)`; you only need to define this macro if that + definition is not suitable for use in preprocessor conditionals. + +.. c:macro:: RETURN_ADDRESS_POINTER_REGNUM + + The register number of the return address pointer register, which is used to + access the current function's return address from the stack. On some + machines, the return address is not at a fixed offset from the frame + pointer or stack pointer or argument pointer. This register can be defined + to point to the return address on the stack, and then be converted by + ``ELIMINABLE_REGS`` into either the frame pointer or stack pointer. + + Do not define this macro unless there is no other way to get the return + address from the stack. + +.. c:macro:: STATIC_CHAIN_REGNUM + +.. c:macro:: STATIC_CHAIN_INCOMING_REGNUM + + Register numbers used for passing a function's static chain pointer. If + register windows are used, the register number as seen by the called + function is ``STATIC_CHAIN_INCOMING_REGNUM``, while the register + number as seen by the calling function is ``STATIC_CHAIN_REGNUM``. If + these registers are the same, ``STATIC_CHAIN_INCOMING_REGNUM`` need + not be defined. + + The static chain register need not be a fixed register. + + If the static chain is passed in memory, these macros should not be + defined; instead, the ``TARGET_STATIC_CHAIN`` hook should be used. + +.. function:: rtx TARGET_STATIC_CHAIN (const_tree fndecl_or_type, bool incoming_p) + + .. hook-start:TARGET_STATIC_CHAIN + + This hook replaces the use of ``STATIC_CHAIN_REGNUM`` et al for + targets that may use different static chain locations for different + nested functions. This may be required if the target has function + attributes that affect the calling conventions of the function and + those calling conventions use different static chain locations. + + The default version of this hook uses ``STATIC_CHAIN_REGNUM`` et al. + + If the static chain is passed in memory, this hook should be used to + provide rtx giving ``mem`` expressions that denote where they are stored. + Often the ``mem`` expression as seen by the caller will be at an offset + from the stack pointer and the ``mem`` expression as seen by the callee + will be at an offset from the frame pointer. + + .. index:: stack_pointer_rtx, frame_pointer_rtx, arg_pointer_rtx + + The variables ``stack_pointer_rtx``, ``frame_pointer_rtx``, and + ``arg_pointer_rtx`` will have been initialized and should be used + to refer to those items. + +.. hook-end + +.. c:macro:: DWARF_FRAME_REGISTERS + + This macro specifies the maximum number of hard registers that can be + saved in a call frame. This is used to size data structures used in + DWARF2 exception handling. + + Prior to GCC 3.0, this macro was needed in order to establish a stable + exception handling ABI in the face of adding new hard registers for ISA + extensions. In GCC 3.0 and later, the EH ABI is insulated from changes + in the number of hard registers. Nevertheless, this macro can still be + used to reduce the runtime memory requirements of the exception handling + routines, which can be substantial if the ISA contains a lot of + registers that are not call-saved. + + If this macro is not defined, it defaults to + ``FIRST_PSEUDO_REGISTER``. + +.. c:macro:: PRE_GCC3_DWARF_FRAME_REGISTERS + + This macro is similar to ``DWARF_FRAME_REGISTERS``, but is provided + for backward compatibility in pre GCC 3.0 compiled code. + + If this macro is not defined, it defaults to + ``DWARF_FRAME_REGISTERS``. + +.. c:macro:: DWARF_REG_TO_UNWIND_COLUMN (regno) + + Define this macro if the target's representation for dwarf registers + is different than the internal representation for unwind column. + Given a dwarf register, this macro should return the internal unwind + column number to use instead. + +.. c:macro:: DWARF_FRAME_REGNUM (regno) + + Define this macro if the target's representation for dwarf registers + used in .eh_frame or .debug_frame is different from that used in other + debug info sections. Given a GCC hard register number, this macro + should return the .eh_frame register number. The default is + ``DEBUGGER_REGNO (regno)``. + +.. c:macro:: DWARF2_FRAME_REG_OUT (regno, for_eh) + + Define this macro to map register numbers held in the call frame info + that GCC has collected using ``DWARF_FRAME_REGNUM`` to those that + should be output in .debug_frame (``for_eh`` is zero) and + .eh_frame (``for_eh`` is nonzero). The default is to + return ``regno``. + +.. c:macro:: REG_VALUE_IN_UNWIND_CONTEXT + + Define this macro if the target stores register values as + ``_Unwind_Word`` type in unwind context. It should be defined if + target register size is larger than the size of ``void *``. The + default is to store register values as ``void *`` type. + +.. c:macro:: ASSUME_EXTENDED_UNWIND_CONTEXT + + Define this macro to be 1 if the target always uses extended unwind + context with version, args_size and by_value fields. If it is undefined, + it will be defined to 1 when ``REG_VALUE_IN_UNWIND_CONTEXT`` is + defined and 0 otherwise. + +.. c:macro:: DWARF_LAZY_REGISTER_VALUE (regno, value) + + Define this macro if the target has pseudo DWARF registers whose + values need to be computed lazily on demand by the unwinder (such as when + referenced in a CFA expression). The macro returns true if :samp:`{regno}` + is such a register and stores its value in :samp:`*{value}` if so. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/shrink-wrapping-separate-components.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/shrink-wrapping-separate-components.rst new file mode 100644 index 00000000000..f2c85db45fa --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/shrink-wrapping-separate-components.rst @@ -0,0 +1,93 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: shrink-wrapping separate components + +.. _shrink-wrapping-separate-components: + +Shrink-wrapping separate components +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The prologue may perform a variety of target dependent tasks such as +saving callee-saved registers, saving the return address, aligning the +stack, creating a stack frame, initializing the PIC register, setting +up the static chain, etc. + +On some targets some of these tasks may be independent of others and +thus may be shrink-wrapped separately. These independent tasks are +referred to as components and are handled generically by the target +independent parts of GCC. + +Using the following hooks those prologue or epilogue components can be +shrink-wrapped separately, so that the initialization (and possibly +teardown) those components do is not done as frequently on execution +paths where this would unnecessary. + +What exactly those components are is up to the target code; the generic +code treats them abstractly, as a bit in an ``sbitmap``. These +``sbitmap`` s are allocated by the ``shrink_wrap.get_separate_components`` +and ``shrink_wrap.components_for_bb`` hooks, and deallocated by the +generic code. + +.. function:: sbitmap TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS (void) + + .. hook-start:TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS + + This hook should return an ``sbitmap`` with the bits set for those + components that can be separately shrink-wrapped in the current function. + Return ``NULL`` if the current function should not get any separate + shrink-wrapping. + Don't define this hook if it would always return ``NULL``. + If it is defined, the other hooks in this group have to be defined as well. + +.. hook-end + +.. function:: sbitmap TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB (basic_block) + + .. hook-start:TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB + + This hook should return an ``sbitmap`` with the bits set for those + components where either the prologue component has to be executed before + the ``basic_block``, or the epilogue component after it, or both. + +.. hook-end + +.. function:: void TARGET_SHRINK_WRAP_DISQUALIFY_COMPONENTS (sbitmap components, edge e, sbitmap edge_components, bool is_prologue) + + .. hook-start:TARGET_SHRINK_WRAP_DISQUALIFY_COMPONENTS + + This hook should clear the bits in the :samp:`{components}` bitmap for those + components in :samp:`{edge_components}` that the target cannot handle on edge + :samp:`{e}`, where :samp:`{is_prologue}` says if this is for a prologue or an + epilogue instead. + +.. hook-end + +.. function:: void TARGET_SHRINK_WRAP_EMIT_PROLOGUE_COMPONENTS (sbitmap) + + .. hook-start:TARGET_SHRINK_WRAP_EMIT_PROLOGUE_COMPONENTS + + Emit prologue insns for the components indicated by the parameter. + +.. hook-end + +.. function:: void TARGET_SHRINK_WRAP_EMIT_EPILOGUE_COMPONENTS (sbitmap) + + .. hook-start:TARGET_SHRINK_WRAP_EMIT_EPILOGUE_COMPONENTS + + Emit epilogue insns for the components indicated by the parameter. + +.. hook-end + +.. function:: void TARGET_SHRINK_WRAP_SET_HANDLED_COMPONENTS (sbitmap) + + .. hook-start:TARGET_SHRINK_WRAP_SET_HANDLED_COMPONENTS + + Mark the components in the parameter as handled, so that the + ``prologue`` and ``epilogue`` named patterns know to ignore those + components. The target code should not hang on to the ``sbitmap``, it + will be deleted after this call. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/specifying-how-stack-checking-is-done.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/specifying-how-stack-checking-is-done.rst new file mode 100644 index 00000000000..cc23c7063f4 --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/specifying-how-stack-checking-is-done.rst @@ -0,0 +1,118 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _stack-checking: + +Specifying How Stack Checking is Done +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GCC will check that stack references are within the boundaries of the +stack, if the option :option:`-fstack-check` is specified, in one of +three ways: + +* If the value of the ``STACK_CHECK_BUILTIN`` macro is nonzero, GCC + will assume that you have arranged for full stack checking to be done + at appropriate places in the configuration files. GCC will not do + other special processing. + +* If ``STACK_CHECK_BUILTIN`` is zero and the value of the + ``STACK_CHECK_STATIC_BUILTIN`` macro is nonzero, GCC will assume + that you have arranged for static stack checking (checking of the + static stack frame of functions) to be done at appropriate places + in the configuration files. GCC will only emit code to do dynamic + stack checking (checking on dynamic stack allocations) using the third + approach below. + +* If neither of the above are true, GCC will generate code to periodically + 'probe' the stack pointer using the values of the macros defined below. + +If neither STACK_CHECK_BUILTIN nor STACK_CHECK_STATIC_BUILTIN is defined, +GCC will change its allocation strategy for large objects if the option +:option:`-fstack-check` is specified: they will always be allocated +dynamically if their size exceeds ``STACK_CHECK_MAX_VAR_SIZE`` bytes. + +.. c:macro:: STACK_CHECK_BUILTIN + + A nonzero value if stack checking is done by the configuration files in a + machine-dependent manner. You should define this macro if stack checking + is required by the ABI of your machine or if you would like to do stack + checking in some more efficient way than the generic approach. The default + value of this macro is zero. + +.. c:macro:: STACK_CHECK_STATIC_BUILTIN + + A nonzero value if static stack checking is done by the configuration files + in a machine-dependent manner. You should define this macro if you would + like to do static stack checking in some more efficient way than the generic + approach. The default value of this macro is zero. + +.. c:macro:: STACK_CHECK_PROBE_INTERVAL_EXP + + An integer specifying the interval at which GCC must generate stack probe + instructions, defined as 2 raised to this integer. You will normally + define this macro so that the interval be no larger than the size of + the 'guard pages' at the end of a stack area. The default value + of 12 (4096-byte interval) is suitable for most systems. + +.. c:macro:: STACK_CHECK_MOVING_SP + + An integer which is nonzero if GCC should move the stack pointer page by page + when doing probes. This can be necessary on systems where the stack pointer + contains the bottom address of the memory area accessible to the executing + thread at any point in time. In this situation an alternate signal stack + is required in order to be able to recover from a stack overflow. The + default value of this macro is zero. + +.. c:macro:: STACK_CHECK_PROTECT + + The number of bytes of stack needed to recover from a stack overflow, for + languages where such a recovery is supported. The default value of 4KB/8KB + with the ``setjmp`` / ``longjmp`` -based exception handling mechanism and + 8KB/12KB with other exception handling mechanisms should be adequate for most + architectures and operating systems. + +The following macros are relevant only if neither STACK_CHECK_BUILTIN +nor STACK_CHECK_STATIC_BUILTIN is defined; you can omit them altogether +in the opposite case. + +.. c:macro:: STACK_CHECK_MAX_FRAME_SIZE + + The maximum size of a stack frame, in bytes. GCC will generate probe + instructions in non-leaf functions to ensure at least this many bytes of + stack are available. If a stack frame is larger than this size, stack + checking will not be reliable and GCC will issue a warning. The + default is chosen so that GCC only generates one instruction on most + systems. You should normally not change the default value of this macro. + +.. c:macro:: STACK_CHECK_FIXED_FRAME_SIZE + + GCC uses this value to generate the above warning message. It + represents the amount of fixed frame used by a function, not including + space for any callee-saved registers, temporaries and user variables. + You need only specify an upper bound for this amount and will normally + use the default of four words. + +.. c:macro:: STACK_CHECK_MAX_VAR_SIZE + + The maximum size, in bytes, of an object that GCC will place in the + fixed area of the stack frame when the user specifies + :option:`-fstack-check`. + GCC computed the default from the values of the above macros and you will + normally not need to override that default. + +.. function:: HOST_WIDE_INT TARGET_STACK_CLASH_PROTECTION_ALLOCA_PROBE_RANGE (void) + + .. hook-start:TARGET_STACK_CLASH_PROTECTION_ALLOCA_PROBE_RANGE + + Some targets have an ABI defined interval for which no probing needs to be done. + When a probe does need to be done this same interval is used as the probe distance + up when doing stack clash protection for alloca. + On such targets this value can be set to override the default probing up interval. + Define this variable to return nonzero if such a probe range is required or zero otherwise. + Defining this hook also requires your functions which make use of alloca to have at least 8 byes + of outgoing arguments. If this is not the case the stack will be corrupted. + You need not define this macro if it would always have the value zero. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/stack-smashing-protection.rst b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/stack-smashing-protection.rst new file mode 100644 index 00000000000..d27a27118b6 --- /dev/null +++ b/gcc/doc/gccint/target-macros/stack-layout-and-calling-conventions/stack-smashing-protection.rst @@ -0,0 +1,75 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: stack smashing protection + +.. _stack-smashing-protection: + +Stack smashing protection +^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: tree TARGET_STACK_PROTECT_GUARD (void) + + .. hook-start:TARGET_STACK_PROTECT_GUARD + + This hook returns a ``DECL`` node for the external variable to use + for the stack protection guard. This variable is initialized by the + runtime to some random value and is used to initialize the guard value + that is placed at the top of the local stack frame. The type of this + variable must be ``ptr_type_node``. + + The default version of this hook creates a variable called + :samp:`__stack_chk_guard`, which is normally defined in :samp:`libgcc2.c`. + +.. hook-end + +.. function:: tree TARGET_STACK_PROTECT_FAIL (void) + + .. hook-start:TARGET_STACK_PROTECT_FAIL + + This hook returns a ``CALL_EXPR`` that alerts the runtime that the + stack protect guard variable has been modified. This expression should + involve a call to a ``noreturn`` function. + + The default version of this hook invokes a function called + :samp:`__stack_chk_fail`, taking no arguments. This function is + normally defined in :samp:`libgcc2.c`. + +.. hook-end + +.. function:: bool TARGET_STACK_PROTECT_RUNTIME_ENABLED_P (void) + + .. hook-start:TARGET_STACK_PROTECT_RUNTIME_ENABLED_P + + Returns true if the target wants GCC's default stack protect runtime support, + otherwise return false. The default implementation always returns true. + +.. hook-end + +.. function:: bool TARGET_SUPPORTS_SPLIT_STACK (bool report, struct gcc_options *opts) + + .. hook-start:TARGET_SUPPORTS_SPLIT_STACK + + Whether this target supports splitting the stack when the options + described in :samp:`{opts}` have been passed. This is called + after options have been parsed, so the target may reject splitting + the stack in some configurations. The default version of this hook + returns false. If :samp:`{report}` is true, this function may issue a warning + or error; if :samp:`{report}` is false, it must simply return a value + +.. hook-end + +.. function:: vec TARGET_GET_VALID_OPTION_VALUES (int option_code, const char *prefix) + + .. hook-start:TARGET_GET_VALID_OPTION_VALUES + + The hook is used for options that have a non-trivial list of + possible option values. OPTION_CODE is option code of opt_code + enum type. PREFIX is used for bash completion and allows an implementation + to return more specific completion based on the prefix. All string values + should be allocated from heap memory and consumers should release them. + The result will be pruned to cases with PREFIX if not NULL. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/storage-layout.rst b/gcc/doc/gccint/target-macros/storage-layout.rst new file mode 100644 index 00000000000..3b68e400bf2 --- /dev/null +++ b/gcc/doc/gccint/target-macros/storage-layout.rst @@ -0,0 +1,729 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: storage layout + +.. _storage-layout: + +Storage Layout +************** + +Note that the definitions of the macros in this table which are sizes or +alignments measured in bits do not need to be constant. They can be C +expressions that refer to static variables, such as the ``target_flags``. +See :ref:`run-time-target`. + +.. c:macro:: BITS_BIG_ENDIAN + + Define this macro to have the value 1 if the most significant bit in a + byte has the lowest number; otherwise define it to have the value zero. + This means that bit-field instructions count from the most significant + bit. If the machine has no bit-field instructions, then this must still + be defined, but it doesn't matter which value it is defined to. This + macro need not be a constant. + + This macro does not affect the way structure fields are packed into + bytes or words; that is controlled by ``BYTES_BIG_ENDIAN``. + +.. c:macro:: BYTES_BIG_ENDIAN + + Define this macro to have the value 1 if the most significant byte in a + word has the lowest number. This macro need not be a constant. + +.. c:macro:: WORDS_BIG_ENDIAN + + Define this macro to have the value 1 if, in a multiword object, the + most significant word has the lowest number. This applies to both + memory locations and registers; see ``REG_WORDS_BIG_ENDIAN`` if the + order of words in memory is not the same as the order in registers. This + macro need not be a constant. + +.. c:macro:: REG_WORDS_BIG_ENDIAN + + On some machines, the order of words in a multiword object differs between + registers in memory. In such a situation, define this macro to describe + the order of words in a register. The macro ``WORDS_BIG_ENDIAN`` controls + the order of words in memory. + +.. c:macro:: FLOAT_WORDS_BIG_ENDIAN + + Define this macro to have the value 1 if ``DFmode``, ``XFmode`` or + ``TFmode`` floating point numbers are stored in memory with the word + containing the sign bit at the lowest address; otherwise define it to + have the value 0. This macro need not be a constant. + + You need not define this macro if the ordering is the same as for + multi-word integers. + +.. c:macro:: BITS_PER_WORD + + Number of bits in a word. If you do not define this macro, the default + is ``BITS_PER_UNIT * UNITS_PER_WORD``. + +.. c:macro:: MAX_BITS_PER_WORD + + Maximum number of bits in a word. If this is undefined, the default is + ``BITS_PER_WORD``. Otherwise, it is the constant value that is the + largest value that ``BITS_PER_WORD`` can have at run-time. + +.. c:macro:: UNITS_PER_WORD + + Number of storage units in a word; normally the size of a general-purpose + register, a power of two from 1 or 8. + +.. c:macro:: MIN_UNITS_PER_WORD + + Minimum number of units in a word. If this is undefined, the default is + ``UNITS_PER_WORD``. Otherwise, it is the constant value that is the + smallest value that ``UNITS_PER_WORD`` can have at run-time. + +.. c:macro:: POINTER_SIZE + + Width of a pointer, in bits. You must specify a value no wider than the + width of ``Pmode``. If it is not equal to the width of ``Pmode``, + you must define ``POINTERS_EXTEND_UNSIGNED``. If you do not specify + a value the default is ``BITS_PER_WORD``. + +.. c:macro:: POINTERS_EXTEND_UNSIGNED + + A C expression that determines how pointers should be extended from + ``ptr_mode`` to either ``Pmode`` or ``word_mode``. It is + greater than zero if pointers should be zero-extended, zero if they + should be sign-extended, and negative if some other sort of conversion + is needed. In the last case, the extension is done by the target's + ``ptr_extend`` instruction. + + You need not define this macro if the ``ptr_mode``, ``Pmode`` + and ``word_mode`` are all the same width. + +.. c:macro:: PROMOTE_MODE (m, unsignedp, type) + + A macro to update :samp:`{m}` and :samp:`{unsignedp}` when an object whose type + is :samp:`{type}` and which has the specified mode and signedness is to be + stored in a register. This macro is only called when :samp:`{type}` is a + scalar type. + + On most RISC machines, which only have operations that operate on a full + register, define this macro to set :samp:`{m}` to ``word_mode`` if + :samp:`{m}` is an integer mode narrower than ``BITS_PER_WORD``. In most + cases, only integer modes should be widened because wider-precision + floating-point operations are usually more expensive than their narrower + counterparts. + + For most machines, the macro definition does not change :samp:`{unsignedp}`. + However, some machines, have instructions that preferentially handle + either signed or unsigned quantities of certain modes. For example, on + the DEC Alpha, 32-bit loads from memory and 32-bit add instructions + sign-extend the result to 64 bits. On such machines, set + :samp:`{unsignedp}` according to which kind of extension is more efficient. + + Do not define this macro if it would never modify :samp:`{m}`. + +.. function:: enum flt_eval_method TARGET_C_EXCESS_PRECISION (enum excess_precision_type type) + + .. hook-start:TARGET_C_EXCESS_PRECISION + + Return a value, with the same meaning as the C99 macro + ``FLT_EVAL_METHOD`` that describes which excess precision should be + applied. :samp:`{type}` is either ``EXCESS_PRECISION_TYPE_IMPLICIT``, + ``EXCESS_PRECISION_TYPE_FAST``, + ``EXCESS_PRECISION_TYPE_STANDARD``, or + ``EXCESS_PRECISION_TYPE_FLOAT16``. For + ``EXCESS_PRECISION_TYPE_IMPLICIT``, the target should return which + precision and range operations will be implictly evaluated in regardless + of the excess precision explicitly added. For + ``EXCESS_PRECISION_TYPE_STANDARD``, + ``EXCESS_PRECISION_TYPE_FLOAT16``, and + ``EXCESS_PRECISION_TYPE_FAST``, the target should return the + explicit excess precision that should be added depending on the + value set for :option:`-fexcess-precision=[standard|fast|16]`. + Note that unpredictable explicit excess precision does not make sense, + so a target should never return ``FLT_EVAL_METHOD_UNPREDICTABLE`` + when :samp:`{type}` is ``EXCESS_PRECISION_TYPE_STANDARD``, + ``EXCESS_PRECISION_TYPE_FLOAT16`` or + ``EXCESS_PRECISION_TYPE_FAST``. + +Return a value, with the same meaning as the C99 macro +``FLT_EVAL_METHOD`` that describes which excess precision should be +applied. + +.. hook-end + +.. function:: machine_mode TARGET_PROMOTE_FUNCTION_MODE (const_tree type, machine_mode mode, int *punsignedp, const_tree funtype, int for_return) + + .. hook-start:TARGET_PROMOTE_FUNCTION_MODE + + Like ``PROMOTE_MODE``, but it is applied to outgoing function arguments or + function return values. The target hook should return the new mode + and possibly change ``*punsignedp`` if the promotion should + change signedness. This function is called only for scalar *or + pointer* types. + + :samp:`{for_return}` allows to distinguish the promotion of arguments and + return values. If it is ``1``, a return value is being promoted and + ``TARGET_FUNCTION_VALUE`` must perform the same promotions done here. + If it is ``2``, the returned mode should be that of the register in + which an incoming parameter is copied, or the outgoing result is computed; + then the hook should return the same mode as ``promote_mode``, though + the signedness may be different. + + :samp:`{type}` can be NULL when promoting function arguments of libcalls. + + The default is to not promote arguments and return values. You can + also define the hook to ``default_promote_function_mode_always_promote`` + if you would like to apply the same rules given by ``PROMOTE_MODE``. + +.. hook-end + +.. c:macro:: PARM_BOUNDARY + + Normal alignment required for function parameters on the stack, in + bits. All stack parameters receive at least this much alignment + regardless of data type. On most machines, this is the same as the + size of an integer. + +.. c:macro:: STACK_BOUNDARY + + Define this macro to the minimum alignment enforced by hardware for the + stack pointer on this machine. The definition is a C expression for the + desired alignment (measured in bits). This value is used as a default + if ``PREFERRED_STACK_BOUNDARY`` is not defined. On most machines, + this should be the same as ``PARM_BOUNDARY``. + +.. c:macro:: PREFERRED_STACK_BOUNDARY + + Define this macro if you wish to preserve a certain alignment for the + stack pointer, greater than what the hardware enforces. The definition + is a C expression for the desired alignment (measured in bits). This + macro must evaluate to a value equal to or larger than + ``STACK_BOUNDARY``. + +.. c:macro:: INCOMING_STACK_BOUNDARY + + Define this macro if the incoming stack boundary may be different + from ``PREFERRED_STACK_BOUNDARY``. This macro must evaluate + to a value equal to or larger than ``STACK_BOUNDARY``. + +.. c:macro:: FUNCTION_BOUNDARY + + Alignment required for a function entry point, in bits. + +.. c:macro:: BIGGEST_ALIGNMENT + + Biggest alignment that any data type can require on this machine, in + bits. Note that this is not the biggest alignment that is supported, + just the biggest alignment that, when violated, may cause a fault. + +.. c:var:: HOST_WIDE_INT TARGET_ABSOLUTE_BIGGEST_ALIGNMENT + + .. hook-start:TARGET_ABSOLUTE_BIGGEST_ALIGNMENT + + If defined, this target hook specifies the absolute biggest alignment + that a type or variable can have on this machine, otherwise, + ``BIGGEST_ALIGNMENT`` is used. + +.. hook-end + +.. c:macro:: MALLOC_ABI_ALIGNMENT + + Alignment, in bits, a C conformant malloc implementation has to + provide. If not defined, the default value is ``BITS_PER_WORD``. + +.. c:macro:: ATTRIBUTE_ALIGNED_VALUE + + Alignment used by the ``__attribute__ ((aligned))`` construct. If + not defined, the default value is ``BIGGEST_ALIGNMENT``. + +.. c:macro:: MINIMUM_ATOMIC_ALIGNMENT + + If defined, the smallest alignment, in bits, that can be given to an + object that can be referenced in one operation, without disturbing any + nearby object. Normally, this is ``BITS_PER_UNIT``, but may be larger + on machines that don't have byte or half-word store operations. + +.. c:macro:: BIGGEST_FIELD_ALIGNMENT + + Biggest alignment that any structure or union field can require on this + machine, in bits. If defined, this overrides ``BIGGEST_ALIGNMENT`` for + structure and union fields only, unless the field alignment has been set + by the ``__attribute__ ((aligned (n)))`` construct. + +.. c:macro:: ADJUST_FIELD_ALIGN (field, type, computed) + + An expression for the alignment of a structure field :samp:`{field}` of + type :samp:`{type}` if the alignment computed in the usual way (including + applying of ``BIGGEST_ALIGNMENT`` and ``BIGGEST_FIELD_ALIGNMENT`` to the + alignment) is :samp:`{computed}`. It overrides alignment only if the + field alignment has not been set by the + ``__attribute__ ((aligned (n)))`` construct. Note that :samp:`{field}` + may be ``NULL_TREE`` in case we just query for the minimum alignment + of a field of type :samp:`{type}` in structure context. + +.. c:macro:: MAX_STACK_ALIGNMENT + + Biggest stack alignment guaranteed by the backend. Use this macro + to specify the maximum alignment of a variable on stack. + + If not defined, the default value is ``STACK_BOUNDARY``. + + .. todo:: The default should be @code{PREFERRED_STACK_BOUNDARY}. + But the fix for PR 32893 indicates that we can only guarantee + maximum stack alignment on stack up to @code{STACK_BOUNDARY}, not + @code{PREFERRED_STACK_BOUNDARY}, if stack alignment isn't supported. + +.. c:macro:: MAX_OFILE_ALIGNMENT + + Biggest alignment supported by the object file format of this machine. + Use this macro to limit the alignment which can be specified using the + ``__attribute__ ((aligned (n)))`` construct for functions and + objects with static storage duration. The alignment of automatic + objects may exceed the object file format maximum up to the maximum + supported by GCC. If not defined, the default value is + ``BIGGEST_ALIGNMENT``. + + On systems that use ELF, the default (in :samp:`config/elfos.h`) is + the largest supported 32-bit ELF section alignment representable on + a 32-bit host e.g. :samp:`(((uint64_t) 1 << 28) * 8)`. + On 32-bit ELF the largest supported section alignment in bits is + :samp:`(0x80000000 * 8)`, but this is not representable on 32-bit hosts. + +.. function:: void TARGET_LOWER_LOCAL_DECL_ALIGNMENT (tree decl) + + .. hook-start:TARGET_LOWER_LOCAL_DECL_ALIGNMENT + + Define this hook to lower alignment of local, parm or result + decl :samp:`({decl})`. + +.. hook-end + +.. function:: HOST_WIDE_INT TARGET_STATIC_RTX_ALIGNMENT (machine_mode mode) + + .. hook-start:TARGET_STATIC_RTX_ALIGNMENT + + This hook returns the preferred alignment in bits for a + statically-allocated rtx, such as a constant pool entry. :samp:`{mode}` + is the mode of the rtx. The default implementation returns + :samp:`GET_MODE_ALIGNMENT ({mode})`. + +.. hook-end + +.. c:macro:: DATA_ALIGNMENT (type, basic_align) + + If defined, a C expression to compute the alignment for a variable in + the static store. :samp:`{type}` is the data type, and :samp:`{basic_align}` is + the alignment that the object would ordinarily have. The value of this + macro is used instead of that alignment to align the object. + + If this macro is not defined, then :samp:`{basic_align}` is used. + + .. index:: strcpy + + One use of this macro is to increase alignment of medium-size data to + make it all fit in fewer cache lines. Another is to cause character + arrays to be word-aligned so that ``strcpy`` calls that copy + constants to character arrays can be done inline. + +.. c:macro:: DATA_ABI_ALIGNMENT (type, basic_align) + + Similar to ``DATA_ALIGNMENT``, but for the cases where the ABI mandates + some alignment increase, instead of optimization only purposes. E.g.AMD x86-64 psABI says that variables with array type larger than 15 bytes + must be aligned to 16 byte boundaries. + + If this macro is not defined, then :samp:`{basic_align}` is used. + +.. function:: HOST_WIDE_INT TARGET_CONSTANT_ALIGNMENT (const_tree constant, HOST_WIDE_INT basic_align) + + .. hook-start:TARGET_CONSTANT_ALIGNMENT + + This hook returns the alignment in bits of a constant that is being + placed in memory. :samp:`{constant}` is the constant and :samp:`{basic_align}` + is the alignment that the object would ordinarily have. + + The default definition just returns :samp:`{basic_align}`. + + The typical use of this hook is to increase alignment for string + constants to be word aligned so that ``strcpy`` calls that copy + constants can be done inline. The function + ``constant_alignment_word_strings`` provides such a definition. + +.. hook-end + +.. c:macro:: LOCAL_ALIGNMENT (type, basic_align) + + If defined, a C expression to compute the alignment for a variable in + the local store. :samp:`{type}` is the data type, and :samp:`{basic_align}` is + the alignment that the object would ordinarily have. The value of this + macro is used instead of that alignment to align the object. + + If this macro is not defined, then :samp:`{basic_align}` is used. + + One use of this macro is to increase alignment of medium-size data to + make it all fit in fewer cache lines. + + If the value of this macro has a type, it should be an unsigned type. + +.. function:: HOST_WIDE_INT TARGET_VECTOR_ALIGNMENT (const_tree type) + + .. hook-start:TARGET_VECTOR_ALIGNMENT + + This hook can be used to define the alignment for a vector of type + :samp:`{type}`, in order to comply with a platform ABI. The default is to + require natural alignment for vector types. The alignment returned by + this hook must be a power-of-two multiple of the default alignment of + the vector element type. + +.. hook-end + +.. c:macro:: STACK_SLOT_ALIGNMENT (type, mode, basic_align) + + If defined, a C expression to compute the alignment for stack slot. + :samp:`{type}` is the data type, :samp:`{mode}` is the widest mode available, + and :samp:`{basic_align}` is the alignment that the slot would ordinarily + have. The value of this macro is used instead of that alignment to + align the slot. + + If this macro is not defined, then :samp:`{basic_align}` is used when + :samp:`{type}` is ``NULL``. Otherwise, ``LOCAL_ALIGNMENT`` will + be used. + + This macro is to set alignment of stack slot to the maximum alignment + of all possible modes which the slot may have. + + If the value of this macro has a type, it should be an unsigned type. + +.. c:macro:: LOCAL_DECL_ALIGNMENT (decl) + + If defined, a C expression to compute the alignment for a local + variable :samp:`{decl}`. + + If this macro is not defined, then + ``LOCAL_ALIGNMENT (TREE_TYPE (decl), DECL_ALIGN (decl))`` + is used. + + One use of this macro is to increase alignment of medium-size data to + make it all fit in fewer cache lines. + + If the value of this macro has a type, it should be an unsigned type. + +.. c:macro:: MINIMUM_ALIGNMENT (exp, mode, align) + + If defined, a C expression to compute the minimum required alignment + for dynamic stack realignment purposes for :samp:`{exp}` (a type or decl), + :samp:`{mode}`, assuming normal alignment :samp:`{align}`. + + If this macro is not defined, then :samp:`{align}` will be used. + +.. c:macro:: EMPTY_FIELD_BOUNDARY + + Alignment in bits to be given to a structure bit-field that follows an + empty field such as ``int : 0;``. + + If ``PCC_BITFIELD_TYPE_MATTERS`` is true, it overrides this macro. + +.. c:macro:: STRUCTURE_SIZE_BOUNDARY + + Number of bits which any structure or union's size must be a multiple of. + Each structure or union's size is rounded up to a multiple of this. + + If you do not define this macro, the default is the same as + ``BITS_PER_UNIT``. + +.. c:macro:: STRICT_ALIGNMENT + + Define this macro to be the value 1 if instructions will fail to work + if given data not on the nominal alignment. If instructions will merely + go slower in that case, define this macro as 0. + +.. c:macro:: PCC_BITFIELD_TYPE_MATTERS + + Define this if you wish to imitate the way many other C compilers handle + alignment of bit-fields and the structures that contain them. + + The behavior is that the type written for a named bit-field (``int``, + ``short``, or other integer type) imposes an alignment for the entire + structure, as if the structure really did contain an ordinary field of + that type. In addition, the bit-field is placed within the structure so + that it would fit within such a field, not crossing a boundary for it. + + Thus, on most machines, a named bit-field whose type is written as + ``int`` would not cross a four-byte boundary, and would force + four-byte alignment for the whole structure. (The alignment used may + not be four bytes; it is controlled by the other alignment parameters.) + + An unnamed bit-field will not affect the alignment of the containing + structure. + + If the macro is defined, its definition should be a C expression; + a nonzero value for the expression enables this behavior. + + Note that if this macro is not defined, or its value is zero, some + bit-fields may cross more than one alignment boundary. The compiler can + support such references if there are :samp:`insv`, :samp:`extv`, and + :samp:`extzv` insns that can directly reference memory. + + The other known way of making bit-fields work is to define + ``STRUCTURE_SIZE_BOUNDARY`` as large as ``BIGGEST_ALIGNMENT``. + Then every structure can be accessed with fullwords. + + Unless the machine has bit-field instructions or you define + ``STRUCTURE_SIZE_BOUNDARY`` that way, you must define + ``PCC_BITFIELD_TYPE_MATTERS`` to have a nonzero value. + + If your aim is to make GCC use the same conventions for laying out + bit-fields as are used by another compiler, here is how to investigate + what the other compiler does. Compile and run this program: + + .. code-block:: c++ + + struct foo1 + { + char x; + char :0; + char y; + }; + + struct foo2 + { + char x; + int :0; + char y; + }; + + main () + { + printf ("Size of foo1 is %d\n", + sizeof (struct foo1)); + printf ("Size of foo2 is %d\n", + sizeof (struct foo2)); + exit (0); + } + + If this prints 2 and 5, then the compiler's behavior is what you would + get from ``PCC_BITFIELD_TYPE_MATTERS``. + +.. c:macro:: BITFIELD_NBYTES_LIMITED + + Like ``PCC_BITFIELD_TYPE_MATTERS`` except that its effect is limited + to aligning a bit-field within the structure. + +.. function:: bool TARGET_ALIGN_ANON_BITFIELD (void) + + .. hook-start:TARGET_ALIGN_ANON_BITFIELD + + When ``PCC_BITFIELD_TYPE_MATTERS`` is true this hook will determine + whether unnamed bitfields affect the alignment of the containing + structure. The hook should return true if the structure should inherit + the alignment requirements of an unnamed bitfield's type. + +.. hook-end + +.. function:: bool TARGET_NARROW_VOLATILE_BITFIELD (void) + + .. hook-start:TARGET_NARROW_VOLATILE_BITFIELD + + This target hook should return ``true`` if accesses to volatile bitfields + should use the narrowest mode possible. It should return ``false`` if + these accesses should use the bitfield container type. + + The default is ``false``. + +.. hook-end + +.. function:: bool TARGET_MEMBER_TYPE_FORCES_BLK (const_tree field, machine_mode mode) + + .. hook-start:TARGET_MEMBER_TYPE_FORCES_BLK + + Return true if a structure, union or array containing :samp:`{field}` should + be accessed using ``BLKMODE``. + + If :samp:`{field}` is the only field in the structure, :samp:`{mode}` is its + mode, otherwise :samp:`{mode}` is VOIDmode. :samp:`{mode}` is provided in the + case where structures of one field would require the structure's mode to + retain the field's mode. + + Normally, this is not needed. + +.. hook-end + +.. c:macro:: ROUND_TYPE_ALIGN (type, computed, specified) + + Define this macro as an expression for the alignment of a type (given + by :samp:`{type}` as a tree node) if the alignment computed in the usual + way is :samp:`{computed}` and the alignment explicitly specified was + :samp:`{specified}`. + + The default is to use :samp:`{specified}` if it is larger; otherwise, use + the smaller of :samp:`{computed}` and ``BIGGEST_ALIGNMENT`` + +.. c:macro:: MAX_FIXED_MODE_SIZE + + An integer expression for the size in bits of the largest integer + machine mode that should actually be used. All integer machine modes of + this size or smaller can be used for structures and unions with the + appropriate sizes. If this macro is undefined, ``GET_MODE_BITSIZE + (DImode)`` is assumed. + +.. c:macro:: STACK_SAVEAREA_MODE (save_level) + + If defined, an expression of type ``machine_mode`` that + specifies the mode of the save area operand of a + ``save_stack_level`` named pattern (see :ref:`standard-names`). + :samp:`{save_level}` is one of ``SAVE_BLOCK``, ``SAVE_FUNCTION``, or + ``SAVE_NONLOCAL`` and selects which of the three named patterns is + having its mode specified. + + You need not define this macro if it always returns ``Pmode``. You + would most commonly define this macro if the + ``save_stack_level`` patterns need to support both a 32- and a + 64-bit mode. + +.. c:macro:: STACK_SIZE_MODE + + If defined, an expression of type ``machine_mode`` that + specifies the mode of the size increment operand of an + ``allocate_stack`` named pattern (see :ref:`standard-names`). + + You need not define this macro if it always returns ``word_mode``. + You would most commonly define this macro if the ``allocate_stack`` + pattern needs to support both a 32- and a 64-bit mode. + +.. function:: scalar_int_mode TARGET_LIBGCC_CMP_RETURN_MODE (void) + + .. hook-start:TARGET_LIBGCC_CMP_RETURN_MODE + + This target hook should return the mode to be used for the return value + of compare instructions expanded to libgcc calls. If not defined + ``word_mode`` is returned which is the right choice for a majority of + targets. + +.. hook-end + +.. function:: scalar_int_mode TARGET_LIBGCC_SHIFT_COUNT_MODE (void) + + .. hook-start:TARGET_LIBGCC_SHIFT_COUNT_MODE + + This target hook should return the mode to be used for the shift count operand + of shift instructions expanded to libgcc calls. If not defined + ``word_mode`` is returned which is the right choice for a majority of + targets. + +.. hook-end + +.. function:: scalar_int_mode TARGET_UNWIND_WORD_MODE (void) + + .. hook-start:TARGET_UNWIND_WORD_MODE + + Return machine mode to be used for ``_Unwind_Word`` type. + The default is to use ``word_mode``. + +.. hook-end + +.. function:: bool TARGET_MS_BITFIELD_LAYOUT_P (const_tree record_type) + + .. hook-start:TARGET_MS_BITFIELD_LAYOUT_P + + This target hook returns ``true`` if bit-fields in the given + :samp:`{record_type}` are to be laid out following the rules of Microsoft + Visual C/C++, namely: (i) a bit-field won't share the same storage + unit with the previous bit-field if their underlying types have + different sizes, and the bit-field will be aligned to the highest + alignment of the underlying types of itself and of the previous + bit-field; (ii) a zero-sized bit-field will affect the alignment of + the whole enclosing structure, even if it is unnamed; except that + (iii) a zero-sized bit-field will be disregarded unless it follows + another bit-field of nonzero size. If this hook returns ``true``, + other macros that control bit-field layout are ignored. + + When a bit-field is inserted into a packed record, the whole size + of the underlying type is used by one or more same-size adjacent + bit-fields (that is, if its long:3, 32 bits is used in the record, + and any additional adjacent long bit-fields are packed into the same + chunk of 32 bits. However, if the size changes, a new field of that + size is allocated). In an unpacked record, this is the same as using + alignment, but not equivalent when packing. + + If both MS bit-fields and :samp:`__attribute__((packed))` are used, + the latter will take precedence. If :samp:`__attribute__((packed))` is + used on a single field when MS bit-fields are in use, it will take + precedence for that field, but the alignment of the rest of the structure + may affect its placement. + +.. hook-end + +.. function:: bool TARGET_DECIMAL_FLOAT_SUPPORTED_P (void) + + .. hook-start:TARGET_DECIMAL_FLOAT_SUPPORTED_P + + Returns true if the target supports decimal floating point. + +.. hook-end + +.. function:: bool TARGET_FIXED_POINT_SUPPORTED_P (void) + + .. hook-start:TARGET_FIXED_POINT_SUPPORTED_P + + Returns true if the target supports fixed-point arithmetic. + +.. hook-end + +.. function:: void TARGET_EXPAND_TO_RTL_HOOK (void) + + .. hook-start:TARGET_EXPAND_TO_RTL_HOOK + + This hook is called just before expansion into rtl, allowing the target + to perform additional initializations or analysis before the expansion. + For example, the rs6000 port uses it to allocate a scratch stack slot + for use in copying SDmode values between memory and floating point + registers whenever the function being expanded has any SDmode + usage. + +.. hook-end + +.. function:: void TARGET_INSTANTIATE_DECLS (void) + + .. hook-start:TARGET_INSTANTIATE_DECLS + + This hook allows the backend to perform additional instantiations on rtl + that are not actually in any insns yet, but will be later. + +.. hook-end + +.. function:: const char * TARGET_MANGLE_TYPE (const_tree type) + + .. hook-start:TARGET_MANGLE_TYPE + + If your target defines any fundamental types, or any types your target + uses should be mangled differently from the default, define this hook + to return the appropriate encoding for these types as part of a C++ + mangled name. The :samp:`{type}` argument is the tree structure representing + the type to be mangled. The hook may be applied to trees which are + not target-specific fundamental types; it should return ``NULL`` + for all such types, as well as arguments it does not recognize. If the + return value is not ``NULL``, it must point to a statically-allocated + string constant. + + Target-specific fundamental types might be new fundamental types or + qualified versions of ordinary fundamental types. Encode new + fundamental types as :samp:`u {n}{name}`, where :samp:`{name}` + is the name used for the type in source code, and :samp:`{n}` is the + length of :samp:`{name}` in decimal. Encode qualified versions of + ordinary types as :samp:`U{n}{name}{code}`, where + :samp:`{name}` is the name used for the type qualifier in source code, + :samp:`{n}` is the length of :samp:`{name}` as above, and :samp:`{code}` is the + code used to represent the unqualified version of this type. (See + ``write_builtin_type`` in :samp:`cp/mangle.cc` for the list of + codes.) In both cases the spaces are for clarity; do not include any + spaces in your string. + + This hook is applied to types prior to typedef resolution. If the mangled + name for a particular type depends only on that type's main variant, you + can perform typedef resolution yourself using ``TYPE_MAIN_VARIANT`` + before mangling. + + The default version of this hook always returns ``NULL``, which is + appropriate for a target that does not define any new fundamental + types. + +.. hook-end \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/support-for-nested-functions.rst b/gcc/doc/gccint/target-macros/support-for-nested-functions.rst new file mode 100644 index 00000000000..72c389d0633 --- /dev/null +++ b/gcc/doc/gccint/target-macros/support-for-nested-functions.rst @@ -0,0 +1,222 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: support for nested functions, trampolines for nested functions, descriptors for nested functions, nested functions, support for + +.. _trampolines: + +Support for Nested Functions +**************************** + +Taking the address of a nested function requires special compiler +handling to ensure that the static chain register is loaded when +the function is invoked via an indirect call. + +GCC has traditionally supported nested functions by creating an +executable :dfn:`trampoline` at run time when the address of a nested +function is taken. This is a small piece of code which normally +resides on the stack, in the stack frame of the containing function. +The trampoline loads the static chain register and then jumps to the +real address of the nested function. + +The use of trampolines requires an executable stack, which is a +security risk. To avoid this problem, GCC also supports another +strategy: using descriptors for nested functions. Under this model, +taking the address of a nested function results in a pointer to a +non-executable function descriptor object. Initializing the static chain +from the descriptor is handled at indirect call sites. + +On some targets, including HPPA and IA-64, function descriptors may be +mandated by the ABI or be otherwise handled in a target-specific way +by the back end in its code generation strategy for indirect calls. +GCC also provides its own generic descriptor implementation to support the +:option:`-fno-trampolines` option. In this case runtime detection of +function descriptors at indirect call sites relies on descriptor +pointers being tagged with a bit that is never set in bare function +addresses. Since GCC's generic function descriptors are +not ABI-compliant, this option is typically used only on a +per-language basis (notably by Ada) or when it can otherwise be +applied to the whole program. + +For languages other than Ada, the ``-ftrampolines`` and +``-fno-trampolines`` options currently have no effect, and +trampolines are always generated on platforms that need them +for nested functions. + +Define the following hook if your backend either implements ABI-specified +descriptor support, or can use GCC's generic descriptor implementation +for nested functions. + +.. c:var:: int TARGET_CUSTOM_FUNCTION_DESCRIPTORS + + .. hook-start:TARGET_CUSTOM_FUNCTION_DESCRIPTORS + + If the target can use GCC's generic descriptor mechanism for nested + functions, define this hook to a power of 2 representing an unused bit + in function pointers which can be used to differentiate descriptors at + run time. This value gives the number of bytes by which descriptor + pointers are misaligned compared to function pointers. For example, on + targets that require functions to be aligned to a 4-byte boundary, a + value of either 1 or 2 is appropriate unless the architecture already + reserves the bit for another purpose, such as on ARM. + + Define this hook to 0 if the target implements ABI support for + function descriptors in its standard calling sequence, like for example + HPPA or IA-64. + + Using descriptors for nested functions + eliminates the need for trampolines that reside on the stack and require + it to be made executable. + +.. hook-end + +The following macros tell GCC how to generate code to allocate and +initialize an executable trampoline. You can also use this interface +if your back end needs to create ABI-specified non-executable descriptors; in +this case the "trampoline" created is the descriptor containing data only. + +The instructions in an executable trampoline must do two things: load +a constant address into the static chain register, and jump to the real +address of the nested function. On CISC machines such as the m68k, +this requires two instructions, a move immediate and a jump. Then the +two addresses exist in the trampoline as word-long immediate operands. +On RISC machines, it is often necessary to load each address into a +register in two parts. Then pieces of each address form separate +immediate operands. + +The code generated to initialize the trampoline must store the variable +parts---the static chain value and the function address---into the +immediate operands of the instructions. On a CISC machine, this is +simply a matter of copying each address to a memory reference at the +proper offset from the start of the trampoline. On a RISC machine, it +may be necessary to take out pieces of the address and store them +separately. + +.. function:: void TARGET_ASM_TRAMPOLINE_TEMPLATE (FILE *f) + + .. hook-start:TARGET_ASM_TRAMPOLINE_TEMPLATE + + This hook is called by ``assemble_trampoline_template`` to output, + on the stream :samp:`{f}`, assembler code for a block of data that contains + the constant parts of a trampoline. This code should not include a + label---the label is taken care of automatically. + + If you do not define this hook, it means no template is needed + for the target. Do not define this hook on systems where the block move + code to copy the trampoline into place would be larger than the code + to generate it on the spot. + +.. hook-end + +.. c:macro:: TRAMPOLINE_SECTION + + Return the section into which the trampoline template is to be placed + (see :ref:`sections`). The default value is ``readonly_data_section``. + +.. c:macro:: TRAMPOLINE_SIZE + + A C expression for the size in bytes of the trampoline, as an integer. + +.. c:macro:: TRAMPOLINE_ALIGNMENT + + Alignment required for trampolines, in bits. + + If you don't define this macro, the value of ``FUNCTION_ALIGNMENT`` + is used for aligning trampolines. + +.. function:: void TARGET_TRAMPOLINE_INIT (rtx m_tramp, tree fndecl, rtx static_chain) + + .. hook-start:TARGET_TRAMPOLINE_INIT + + This hook is called to initialize a trampoline. + :samp:`{m_tramp}` is an RTX for the memory block for the trampoline; :samp:`{fndecl}` + is the ``FUNCTION_DECL`` for the nested function; :samp:`{static_chain}` is an + RTX for the static chain value that should be passed to the function + when it is called. + + If the target defines ``TARGET_ASM_TRAMPOLINE_TEMPLATE``, then the + first thing this hook should do is emit a block move into :samp:`{m_tramp}` + from the memory block returned by ``assemble_trampoline_template``. + Note that the block move need only cover the constant parts of the + trampoline. If the target isolates the variable parts of the trampoline + to the end, not all ``TRAMPOLINE_SIZE`` bytes need be copied. + + If the target requires any other actions, such as flushing caches + (possibly calling function maybe_emit_call_builtin___clear_cache) or + enabling stack execution, these actions should be performed after + initializing the trampoline proper. + +.. hook-end + +.. function:: void TARGET_EMIT_CALL_BUILTIN___CLEAR_CACHE (rtx begin, rtx end) + + .. hook-start:TARGET_EMIT_CALL_BUILTIN___CLEAR_CACHE + + On targets that do not define a ``clear_cache`` insn expander, + but that define the ``CLEAR_CACHE_INSN`` macro, + maybe_emit_call_builtin___clear_cache relies on this target hook + to clear an address range in the instruction cache. + + The default implementation calls the ``__clear_cache`` builtin, + taking the assembler name from the builtin declaration. Overriding + definitions may call alternate functions, with alternate calling + conventions, or emit alternate RTX to perform the job. + +.. hook-end + +.. function:: rtx TARGET_TRAMPOLINE_ADJUST_ADDRESS (rtx addr) + + .. hook-start:TARGET_TRAMPOLINE_ADJUST_ADDRESS + + This hook should perform any machine-specific adjustment in + the address of the trampoline. Its argument contains the address of the + memory block that was passed to ``TARGET_TRAMPOLINE_INIT``. In case + the address to be used for a function call should be different from the + address at which the template was stored, the different address should + be returned; otherwise :samp:`{addr}` should be returned unchanged. + If this hook is not defined, :samp:`{addr}` will be used for function calls. + +.. hook-end + +Implementing trampolines is difficult on many machines because they have +separate instruction and data caches. Writing into a stack location +fails to clear the memory in the instruction cache, so when the program +jumps to that location, it executes the old contents. + +Here are two possible solutions. One is to clear the relevant parts of +the instruction cache whenever a trampoline is set up. The other is to +make all trampolines identical, by having them jump to a standard +subroutine. The former technique makes trampoline execution faster; the +latter makes initialization faster. + +To clear the instruction cache when a trampoline is initialized, define +the following macro. + +.. c:macro:: CLEAR_INSN_CACHE (beg, end) + + If defined, expands to a C expression clearing the *instruction + cache* in the specified interval. The definition of this macro would + typically be a series of ``asm`` statements. Both :samp:`{beg}` and + :samp:`{end}` are pointer expressions. + +To use a standard subroutine, define the following macro. In addition, +you must make sure that the instructions in a trampoline fill an entire +cache line with identical instructions, or else ensure that the +beginning of the trampoline code is always aligned at the same point in +its cache line. Look in :samp:`m68k.h` as a guide. + +.. c:macro:: TRANSFER_FROM_TRAMPOLINE + + Define this macro if trampolines need a special subroutine to do their + work. The macro should expand to a series of ``asm`` statements + which will be compiled with GCC. They go in a library function named + ``__transfer_from_trampoline``. + + If you need to avoid executing the ordinary prologue code of a compiled + C function when you jump to the subroutine, you can do so by placing a + special label of your own in the assembler code. Use one ``asm`` + statement to generate an assembler label, and another to make the label + global. Then trampolines can use that label to jump directly to your + special assembler code. \ No newline at end of file diff --git a/gcc/doc/gccint/target-macros/the-global-targetm-variable.rst b/gcc/doc/gccint/target-macros/the-global-targetm-variable.rst new file mode 100644 index 00000000000..194daa80a0e --- /dev/null +++ b/gcc/doc/gccint/target-macros/the-global-targetm-variable.rst @@ -0,0 +1,65 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: target hooks, target functions + +.. _target-structure: + +The Global targetm Variable +*************************** + +.. index:: targetm + +Variable struct gcc_target targetmThe target :samp:`.c` file must define the global ``targetm`` variable +which contains pointers to functions and data relating to the target +machine. The variable is declared in :samp:`target.h`; +:samp:`target-def.h` defines the macro ``TARGET_INITIALIZER`` which is +used to initialize the variable, and macros for the default initializers +for elements of the structure. The :samp:`.c` file should override those +macros for which the default definition is inappropriate. For example: + +.. code-block:: c++ + + #include "target.h" + #include "target-def.h" + + /* Initialize the GCC target structure. */ + + #undef TARGET_COMP_TYPE_ATTRIBUTES + #define TARGET_COMP_TYPE_ATTRIBUTES machine_comp_type_attributes + + struct gcc_target targetm = TARGET_INITIALIZER; + +Where a macro should be defined in the :samp:`.c` file in this manner to +form part of the ``targetm`` structure, it is documented below as a +'Target Hook' with a prototype. Many macros will change in future +from being defined in the :samp:`.h` file to being part of the +``targetm`` structure. + +Similarly, there is a ``targetcm`` variable for hooks that are +specific to front ends for C-family languages, documented as 'C +Target Hook'. This is declared in :samp:`c-family/c-target.h`, the +initializer ``TARGETCM_INITIALIZER`` in +:samp:`c-family/c-target-def.h`. If targets initialize ``targetcm`` +themselves, they should set ``target_has_targetcm=yes`` in +:samp:`config.gcc`; otherwise a default definition is used. + +Similarly, there is a ``targetm_common`` variable for hooks that +are shared between the compiler driver and the compilers proper, +documented as 'Common Target Hook'. This is declared in +:samp:`common/common-target.h`, the initializer +``TARGETM_COMMON_INITIALIZER`` in +:samp:`common/common-target-def.h`. If targets initialize +``targetm_common`` themselves, they should set +``target_has_targetm_common=yes`` in :samp:`config.gcc`; otherwise a +default definition is used. + +Similarly, there is a ``targetdm`` variable for hooks that are +specific to the D language front end, documented as 'D Target Hook'. +This is declared in :samp:`d/d-target.h`, the initializer +``TARGETDM_INITIALIZER`` in :samp:`d/d-target-def.h`. If targets +initialize ``targetdm`` themselves, they should set +``target_has_targetdm=yes`` in :samp:`config.gcc`; otherwise a default +definition is used. \ No newline at end of file diff --git a/gcc/doc/gccint/target-makefile-fragments.rst b/gcc/doc/gccint/target-makefile-fragments.rst new file mode 100644 index 00000000000..2d1d87de218 --- /dev/null +++ b/gcc/doc/gccint/target-makefile-fragments.rst @@ -0,0 +1,245 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: target makefile fragment, t-target + +.. _target-fragment: + +Target Makefile Fragments +************************* + +Target makefile fragments can set these Makefile variables. + +.. index:: LIBGCC2_CFLAGS + +``LIBGCC2_CFLAGS`` + Compiler flags to use when compiling :samp:`libgcc2.c`. + + .. index:: LIB2FUNCS_EXTRA + +``LIB2FUNCS_EXTRA`` + A list of source file names to be compiled or assembled and inserted + into :samp:`libgcc.a`. + + .. index:: CRTSTUFF_T_CFLAGS + +.. envvar:: CRTSTUFF_T_CFLAGS + + Special flags used when compiling :samp:`crtstuff.c`. + See :ref:`initialization`. + +.. envvar:: CRTSTUFF_T_CFLAGS_S + + Special flags used when compiling :samp:`crtstuff.c` for shared + linking. Used if you use :samp:`crtbeginS.o` and :samp:`crtendS.o` + in ``EXTRA-PARTS``. + See :ref:`initialization`. + +.. envvar:: MULTILIB_OPTIONS + + For some targets, invoking GCC in different ways produces objects + that cannot be linked together. For example, for some targets GCC + produces both big and little endian code. For these targets, you must + arrange for multiple versions of :samp:`libgcc.a` to be compiled, one for + each set of incompatible options. When GCC invokes the linker, it + arranges to link in the right version of :samp:`libgcc.a`, based on + the command line options used. + + The ``MULTILIB_OPTIONS`` macro lists the set of options for which + special versions of :samp:`libgcc.a` must be built. Write options that + are mutually incompatible side by side, separated by a slash. Write + options that may be used together separated by a space. The build + procedure will build all combinations of compatible options. + + For example, if you set ``MULTILIB_OPTIONS`` to :samp:`m68000/m68020 + msoft-float`, :samp:`Makefile` will build special versions of + :samp:`libgcc.a` using the following sets of options: :option:`-m68000`, + :option:`-m68020`, :option:`-msoft-float`, :samp:`-m68000 -msoft-float`, and + :samp:`-m68020 -msoft-float`. + +.. envvar:: MULTILIB_DIRNAMES + + If ``MULTILIB_OPTIONS`` is used, this variable specifies the + directory names that should be used to hold the various libraries. + Write one element in ``MULTILIB_DIRNAMES`` for each element in + ``MULTILIB_OPTIONS``. If ``MULTILIB_DIRNAMES`` is not used, the + default value will be ``MULTILIB_OPTIONS``, with all slashes treated + as spaces. + + ``MULTILIB_DIRNAMES`` describes the multilib directories using GCC + conventions and is applied to directories that are part of the GCC + installation. When multilib-enabled, the compiler will add a + subdirectory of the form :samp:`{prefix}` / :samp:`{multilib}` before each + directory in the search path for libraries and crt files. + + For example, if ``MULTILIB_OPTIONS`` is set to :samp:`m68000/m68020 + msoft-float`, then the default value of ``MULTILIB_DIRNAMES`` is + :samp:`m68000 m68020 msoft-float`. You may specify a different value if + you desire a different set of directory names. + +.. envvar:: MULTILIB_MATCHES + + Sometimes the same option may be written in two different ways. If an + option is listed in ``MULTILIB_OPTIONS``, GCC needs to know about + any synonyms. In that case, set ``MULTILIB_MATCHES`` to a list of + items of the form :samp:`option=option` to describe all relevant + synonyms. For example, :samp:`m68000=mc68000 m68020=mc68020`. + +.. envvar:: MULTILIB_EXCEPTIONS + + Sometimes when there are multiple sets of ``MULTILIB_OPTIONS`` being + specified, there are combinations that should not be built. In that + case, set ``MULTILIB_EXCEPTIONS`` to be all of the switch exceptions + in shell case syntax that should not be built. + + For example the ARM processor cannot execute both hardware floating + point instructions and the reduced size THUMB instructions at the same + time, so there is no need to build libraries with both of these + options enabled. Therefore ``MULTILIB_EXCEPTIONS`` is set to: + + .. code-block:: c++ + + *mthumb/*mhard-float* + +.. envvar:: MULTILIB_REQUIRED + + Sometimes when there are only a few combinations are required, it would + be a big effort to come up with a ``MULTILIB_EXCEPTIONS`` list to + cover all undesired ones. In such a case, just listing all the required + combinations in ``MULTILIB_REQUIRED`` would be more straightforward. + + The way to specify the entries in ``MULTILIB_REQUIRED`` is same with + the way used for ``MULTILIB_EXCEPTIONS``, only this time what are + required will be specified. Suppose there are multiple sets of + ``MULTILIB_OPTIONS`` and only two combinations are required, one + for ARMv7-M and one for ARMv7-R with hard floating-point ABI and FPU, the + ``MULTILIB_REQUIRED`` can be set to: + + .. code-block:: c++ + + MULTILIB_REQUIRED = mthumb/march=armv7-m + MULTILIB_REQUIRED += march=armv7-r/mfloat-abi=hard/mfpu=vfpv3-d16 + + The ``MULTILIB_REQUIRED`` can be used together with + ``MULTILIB_EXCEPTIONS``. The option combinations generated from + ``MULTILIB_OPTIONS`` will be filtered by ``MULTILIB_EXCEPTIONS`` + and then by ``MULTILIB_REQUIRED``. + +.. envvar:: MULTILIB_REUSE + + Sometimes it is desirable to reuse one existing multilib for different + sets of options. Such kind of reuse can minimize the number of multilib + variants. And for some targets it is better to reuse an existing multilib + than to fall back to default multilib when there is no corresponding multilib. + This can be done by adding reuse rules to ``MULTILIB_REUSE``. + + A reuse rule is comprised of two parts connected by equality sign. The left + part is the option set used to build multilib and the right part is the option + set that will reuse this multilib. Both parts should only use options + specified in ``MULTILIB_OPTIONS`` and the equality signs found in options + name should be replaced with periods. An explicit period in the rule can be + escaped by preceding it with a backslash. The order of options in the left + part matters and should be same with those specified in + ``MULTILIB_REQUIRED`` or aligned with the order in ``MULTILIB_OPTIONS``. + There is no such limitation for options in the right part as we don't build + multilib from them. + + ``MULTILIB_REUSE`` is different from ``MULTILIB_MATCHES`` in that it + sets up relations between two option sets rather than two options. Here is an + example to demo how we reuse libraries built in Thumb mode for applications built + in ARM mode: + + .. code-block:: c++ + + MULTILIB_REUSE = mthumb/march.armv7-r=marm/march.armv7-r + + Before the advent of ``MULTILIB_REUSE``, GCC select multilib by comparing command + line options with options used to build multilib. The ``MULTILIB_REUSE`` is + complementary to that way. Only when the original comparison matches nothing it will + work to see if it is OK to reuse some existing multilib. + +.. envvar:: MULTILIB_EXTRA_OPTS + + Sometimes it is desirable that when building multiple versions of + :samp:`libgcc.a` certain options should always be passed on to the + compiler. In that case, set ``MULTILIB_EXTRA_OPTS`` to be the list + of options to be used for all builds. If you set this, you should + probably set ``CRTSTUFF_T_CFLAGS`` to a dash followed by it. + +.. envvar:: MULTILIB_OSDIRNAMES + + If ``MULTILIB_OPTIONS`` is used, this variable specifies + a list of subdirectory names, that are used to modify the search + path depending on the chosen multilib. Unlike ``MULTILIB_DIRNAMES``, + ``MULTILIB_OSDIRNAMES`` describes the multilib directories using + operating systems conventions, and is applied to the directories such as + ``lib`` or those in the :envvar:`LIBRARY_PATH` environment variable. + The format is either the same as of + ``MULTILIB_DIRNAMES``, or a set of mappings. When it is the same + as ``MULTILIB_DIRNAMES``, it describes the multilib directories + using operating system conventions, rather than GCC conventions. When it is a set + of mappings of the form :samp:`{gccdir}` = :samp:`{osdir}`, the left side gives + the GCC convention and the right gives the equivalent OS defined + location. If the :samp:`{osdir}` part begins with a :samp:`!`, + GCC will not search in the non-multilib directory and use + exclusively the multilib directory. Otherwise, the compiler will + examine the search path for libraries and crt files twice; the first + time it will add :samp:`{multilib}` to each directory in the search path, + the second it will not. + + For configurations that support both multilib and multiarch, + ``MULTILIB_OSDIRNAMES`` also encodes the multiarch name, thus + subsuming ``MULTIARCH_DIRNAME``. The multiarch name is appended to + each directory name, separated by a colon (e.g. + :samp:`../lib32:i386-linux-gnu`). + + Each multiarch subdirectory will be searched before the corresponding OS + multilib directory, for example :samp:`/lib/i386-linux-gnu` before + :samp:`/lib/../lib32`. The multiarch name will also be used to modify the + system header search path, as explained for ``MULTIARCH_DIRNAME``. + +.. envvar:: MULTIARCH_DIRNAME + + This variable specifies the multiarch name for configurations that are + multiarch-enabled but not multilibbed configurations. + + The multiarch name is used to augment the search path for libraries, crt + files and system header files with additional locations. The compiler + will add a multiarch subdirectory of the form + :samp:`{prefix}` / :samp:`{multiarch}` before each directory in the library and + crt search path. It will also add two directories + ``LOCAL_INCLUDE_DIR`` / :samp:`{multiarch}` and + ``NATIVE_SYSTEM_HEADER_DIR`` / :samp:`{multiarch}`) to the system header + search path, respectively before ``LOCAL_INCLUDE_DIR`` and + ``NATIVE_SYSTEM_HEADER_DIR``. + + ``MULTIARCH_DIRNAME`` is not used for configurations that support + both multilib and multiarch. In that case, multiarch names are encoded + in ``MULTILIB_OSDIRNAMES`` instead. + + More documentation about multiarch can be found at + https://wiki.debian.org/Multiarch. + +.. envvar:: SPECS + + Unfortunately, setting ``MULTILIB_EXTRA_OPTS`` is not enough, since + it does not affect the build of target libraries, at least not the + build of the default multilib. One possible work-around is to use + ``DRIVER_SELF_SPECS`` to bring options from the :samp:`specs` file + as if they had been passed in the compiler driver command line. + However, you don't want to be adding these options after the toolchain + is installed, so you can instead tweak the :samp:`specs` file that will + be used during the toolchain build, while you still install the + original, built-in :samp:`specs`. The trick is to set ``SPECS`` to + some other filename (say :samp:`specs.install`), that will then be + created out of the built-in specs, and introduce a :samp:`Makefile` + rule to generate the :samp:`specs` file that's going to be used at + build time out of your :samp:`specs.install`. + +.. envvar:: T_CFLAGS + + These are extra flags to pass to the C compiler. They are used both + when building GCC, and when compiling things with the just-built GCC. + This variable is deprecated and should not be used. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites.rst b/gcc/doc/gccint/testsuites.rst new file mode 100644 index 00000000000..dd9119153d0 --- /dev/null +++ b/gcc/doc/gccint/testsuites.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _testsuites: + +Testsuites +---------- + +GCC contains several testsuites to help maintain compiler quality. +Most of the runtime libraries and language front ends in GCC have +testsuites. Currently only the C language testsuites are documented +here; + +.. todo:: document the others + +.. toctree:: + :maxdepth: 2 + + testsuites/idioms-used-in-testsuite-code + testsuites/directives-used-within-dejagnu-tests + testsuites/ada-language-testsuites + testsuites/c-language-testsuites + testsuites/support-for-testing-link-time-optimizations + testsuites/support-for-testing-gcov + testsuites/support-for-testing-profile-directed-optimizations + testsuites/support-for-testing-binary-compatibility + testsuites/support-for-torture-testing-using-multiple-options + testsuites/support-for-testing-gimple-passes + testsuites/support-for-testing-rtl-passes \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/ada-language-testsuites.rst b/gcc/doc/gccint/testsuites/ada-language-testsuites.rst new file mode 100644 index 00000000000..aabf13cba58 --- /dev/null +++ b/gcc/doc/gccint/testsuites/ada-language-testsuites.rst @@ -0,0 +1,38 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ada-tests: + +Ada Language Testsuites +*********************** + +The Ada testsuite includes executable tests from the ACATS +testsuite, publicly available at +http://www.ada-auth.org/acats.html. + +These tests are integrated in the GCC testsuite in the +:samp:`ada/acats` directory, and +enabled automatically when running ``make check``, assuming +the Ada language has been enabled when configuring GCC. + +You can also run the Ada testsuite independently, using +``make check-ada``, or run a subset of the tests by specifying which +chapter to run, e.g.: + +.. code-block:: c++ + + $ make check-ada CHAPTERS="c3 c9" + +The tests are organized by directory, each directory corresponding to +a chapter of the Ada Reference Manual. So for example, :samp:`c9` corresponds +to chapter 9, which deals with tasking features of the language. + +The tests are run using two :command:`sh` scripts: :samp:`run_acats` and +:samp:`run_all.sh`. To run the tests using a simulator or a cross +target, see the small +customization section at the top of :samp:`run_all.sh`. + +These tests are run using the build tree: they can be run without doing +a ``make install``. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/c-language-testsuites.rst b/gcc/doc/gccint/testsuites/c-language-testsuites.rst new file mode 100644 index 00000000000..676c7358506 --- /dev/null +++ b/gcc/doc/gccint/testsuites/c-language-testsuites.rst @@ -0,0 +1,113 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _c-tests: + +C Language Testsuites +********************* + +GCC contains the following C language testsuites, in the +:samp:`gcc/testsuite` directory: + +:samp:`gcc.dg` + This contains tests of particular features of the C compiler, using the + more modern :samp:`dg` harness. Correctness tests for various compiler + features should go here if possible. + + Magic comments determine whether the file + is preprocessed, compiled, linked or run. In these tests, error and warning + message texts are compared against expected texts or regular expressions + given in comments. These tests are run with the options :samp:`-ansi -pedantic` + unless other options are given in the test. Except as noted below they + are not run with multiple optimization options. + +:samp:`gcc.dg/compat` + This subdirectory contains tests for binary compatibility using + :samp:`lib/compat.exp`, which in turn uses the language-independent support + (see :ref:`compat-testing`). + +:samp:`gcc.dg/cpp` + This subdirectory contains tests of the preprocessor. + +:samp:`gcc.dg/debug` + This subdirectory contains tests for debug formats. Tests in this + subdirectory are run for each debug format that the compiler supports. + +:samp:`gcc.dg/format` + This subdirectory contains tests of the :option:`-Wformat` format + checking. Tests in this directory are run with and without + :option:`-DWIDE`. + +:samp:`gcc.dg/noncompile` + This subdirectory contains tests of code that should not compile and + does not need any special compilation options. They are run with + multiple optimization options, since sometimes invalid code crashes + the compiler with optimization. + +:samp:`gcc.dg/special` + .. todo:: describe this + +:samp:`gcc.c-torture` + This contains particular code fragments which have historically broken easily. + These tests are run with multiple optimization options, so tests for features + which only break at some optimization levels belong here. This also contains + tests to check that certain optimizations occur. It might be worthwhile to + separate the correctness tests cleanly from the code quality tests, but + it hasn't been done yet. + +:samp:`gcc.c-torture/compat` + .. todo:: describe this + + This directory should probably not be used for new tests. + +:samp:`gcc.c-torture/compile` + This testsuite contains test cases that should compile, but do not + need to link or run. These test cases are compiled with several + different combinations of optimization options. All warnings are + disabled for these test cases, so this directory is not suitable if + you wish to test for the presence or absence of compiler warnings. + While special options can be set, and tests disabled on specific + platforms, by the use of :samp:`.x` files, mostly these test cases + should not contain platform dependencies. + + .. todo:: discuss how defines such as ``STACK_SIZE`` are used + +:samp:`gcc.c-torture/execute` + This testsuite contains test cases that should compile, link and run; + otherwise the same comments as for :samp:`gcc.c-torture/compile` apply. + +:samp:`gcc.c-torture/execute/ieee` + This contains tests which are specific to IEEE floating point. + +:samp:`gcc.c-torture/unsorted` + .. todo:: describe this + + This directory should probably not be used for new tests. + +:samp:`gcc.misc-tests` + This directory contains C tests that require special handling. Some + of these tests have individual expect files, and others share + special-purpose expect files: + + :samp:`bprob*.c` + Test :option:`-fbranch-probabilities` using + :samp:`gcc.misc-tests/bprob.exp`, which + in turn uses the generic, language-independent framework + (see :ref:`profopt-testing`). + + :samp:`gcov*.c` + Test :command:`gcov` output using :samp:`gcov.exp`, which in turn uses the + language-independent support (see :ref:`gcov-testing`). + + :samp:`i386-pf-*.c` + Test i386-specific support for data prefetch using :samp:`i386-prefetch.exp`. + +:samp:`gcc.test-framework` + + :samp:`dg-*.c` + Test the testsuite itself using :samp:`gcc.test-framework/test-framework.exp`. + +.. todo:: merge in :samp:`testsuite/README.gcc` and discuss the format of + test cases and magic comments more. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests.rst b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests.rst new file mode 100644 index 00000000000..db567c61eeb --- /dev/null +++ b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests.rst @@ -0,0 +1,19 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _test-directives: + +Directives used within DejaGnu tests +************************************ + +.. toctree:: + :maxdepth: 2 + + directives-used-within-dejagnu-tests/syntax-and-descriptions-of-test-directives + directives-used-within-dejagnu-tests/selecting-targets-to-which-a-test-applies + directives-used-within-dejagnu-tests/keywords-describing-target-attributes + directives-used-within-dejagnu-tests/features-for-dg-add-options + directives-used-within-dejagnu-tests/variants-of-dg-require-support + directives-used-within-dejagnu-tests/commands-for-use-in-dg-final \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/commands-for-use-in-dg-final.rst b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/commands-for-use-in-dg-final.rst new file mode 100644 index 00000000000..95a04942505 --- /dev/null +++ b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/commands-for-use-in-dg-final.rst @@ -0,0 +1,291 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _final-actions: + +Commands for use in dg-final +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The GCC testsuite defines the following directives to be used within +``dg-final``. + +Scan a particular file +~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`scan-file {filename}{regexp} [{ target/xfail {selector} }]` + Passes if :samp:`{regexp}` matches text in :samp:`{filename}`. + +:samp:`scan-file-not {filename}{regexp} [{ target/xfail {selector} }]` + Passes if :samp:`{regexp}` does not match text in :samp:`{filename}`. + +:samp:`scan-module {module}{regexp} [{ target/xfail {selector} }]` + Passes if :samp:`{regexp}` matches in Fortran module :samp:`{module}`. + +:samp:`dg-check-dot {filename}` + Passes if :samp:`{filename}` is a valid :samp:`.dot` file (by running + ``dot -Tpng`` on it, and verifying the exit code is 0). + +:samp:`scan-sarif-file {regexp} [{ target/xfail {selector} }]` + Passes if :samp:`{regexp}` matches text in the file generated by + :option:`-fdiagnostics-format=sarif-file`. + +:samp:`scan-sarif-file-not {regexp} [{ target/xfail {selector} }]` + Passes if :samp:`{regexp}` does not match text in the file generated by + :option:`-fdiagnostics-format=sarif-file`. + +Scan the assembly output +~~~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`scan-assembler {regex} [{ target/xfail {selector} }]` + Passes if :samp:`{regex}` matches text in the test's assembler output. + +:samp:`scan-assembler-not {regex} [{ target/xfail {selector} }]` + Passes if :samp:`{regex}` does not match text in the test's assembler output. + +:samp:`scan-assembler-times {regex}{num} [{ target/xfail {selector} }]` + Passes if :samp:`{regex}` is matched exactly :samp:`{num}` times in the test's + assembler output. + +:samp:`scan-assembler-dem {regex} [{ target/xfail {selector} }]` + Passes if :samp:`{regex}` matches text in the test's demangled assembler output. + +:samp:`scan-assembler-dem-not {regex} [{ target/xfail {selector} }]` + Passes if :samp:`{regex}` does not match text in the test's demangled assembler + output. + +:samp:`scan-assembler-symbol-section {functions}{section} [{ target/xfail {selector} }]` + Passes if :samp:`{functions}` are all in :samp:`{section}`. The caller needs to + allow for ``USER_LABEL_PREFIX`` and different section name conventions. + +:samp:`scan-symbol-section {filename}{functions}{section} [{ target/xfail {selector} }]` + Passes if :samp:`{functions}` are all in :samp:`{section}` in :samp:`{filename}`. + The same caveats as for ``scan-assembler-symbol-section`` apply. + +:samp:`scan-hidden {symbol} [{ target/xfail {selector} }]` + Passes if :samp:`{symbol}` is defined as a hidden symbol in the test's + assembly output. + +:samp:`scan-not-hidden {symbol} [{ target/xfail {selector} }]` + Passes if :samp:`{symbol}` is not defined as a hidden symbol in the test's + assembly output. + +:samp:`check-function-bodies {prefix}{terminator} [{options} [{ target/xfail {selector} }]]` + Looks through the source file for comments that give the expected assembly + output for selected functions. Each line of expected output starts with the + prefix string :samp:`{prefix}` and the expected output for a function as a whole + is followed by a line that starts with the string :samp:`{terminator}`. + Specifying an empty terminator is equivalent to specifying :samp:`"*/"`. + + :samp:`{options}`, if specified, is a list of regular expressions, each of + which matches a full command-line option. A non-empty list prevents + the test from running unless all of the given options are present on the + command line. This can help if a source file is compiled both with + and without optimization, since it is rarely useful to check the full + function body for unoptimized code. + + The first line of the expected output for a function :samp:`{fn}` has the form: + + .. code-block:: c++ + + prefix fn: [{ target/xfail selector }] + + Subsequent lines of the expected output also start with :samp:`{prefix}`. + In both cases, whitespace after :samp:`{prefix}` is not significant. + + The test discards assembly directives such as ``.cfi_startproc`` + and local label definitions such as ``.LFB0`` from the compiler's + assembly output. It then matches the result against the expected + output for a function as a single regular expression. This means that + later lines can use backslashes to refer back to :samp:`(...)` + captures on earlier lines. For example: + + .. code-block:: c++ + + /* { dg-final { check-function-bodies "**" "" "-DCHECK_ASM" } } */ + ... + /* + ** add_w0_s8_m: + ** mov (z[0-9]+\.b), w0 + ** add z0\.b, p0/m, z0\.b, \1 + ** ret + */ + svint8_t add_w0_s8_m (...) { ... } + ... + /* + ** add_b0_s8_m: + ** mov (z[0-9]+\.b), b0 + ** add z1\.b, p0/m, z1\.b, \1 + ** ret + */ + svint8_t add_b0_s8_m (...) { ... } + + checks whether the implementations of ``add_w0_s8_m`` and + ``add_b0_s8_m`` match the regular expressions given. The test only + runs when :samp:`-DCHECK_ASM` is passed on the command line. + + It is possible to create non-capturing multi-line regular expression + groups of the form :samp:`({a}|{b}|...)` by putting the + :samp:`(`, :samp:`|` and :samp:`)` on separate lines (each still using + :samp:`{prefix}`). For example: + + .. code-block:: c++ + + /* + ** cmple_f16_tied: + ** ( + ** fcmge p0\.h, p0/z, z1\.h, z0\.h + ** | + ** fcmle p0\.h, p0/z, z0\.h, z1\.h + ** ) + ** ret + */ + svbool_t cmple_f16_tied (...) { ... } + + checks whether ``cmple_f16_tied`` is implemented by the + ``fcmge`` instruction followed by ``ret`` or by the + ``fcmle`` instruction followed by ``ret``. The test is + still a single regular rexpression. + + A line containing just: + + .. code-block:: c++ + + prefix ... + + stands for zero or more unmatched lines; the whitespace after + :samp:`{prefix}` is again not significant. + +Scan optimization dump files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +These commands are available for :samp:`{kind}` of ``tree``, ``ltrans-tree``, +``offload-tree``, ``rtl``, ``offload-rtl``, ``ipa``, and +``wpa-ipa``. + +:samp:`scan-{kind}-dump {regex}{suffix} [{ target/xfail {selector} }]` + Passes if :samp:`{regex}` matches text in the dump file with suffix :samp:`{suffix}`. + +:samp:`scan-{kind}-dump-not {regex}{suffix} [{ target/xfail {selector} }]` + Passes if :samp:`{regex}` does not match text in the dump file with suffix + :samp:`{suffix}`. + +:samp:`scan-{kind}-dump-times {regex}{num}{suffix} [{ target/xfail {selector} }]` + Passes if :samp:`{regex}` is found exactly :samp:`{num}` times in the dump file + with suffix :samp:`{suffix}`. + +:samp:`scan-{kind}-dump-dem {regex}{suffix} [{ target/xfail {selector} }]` + Passes if :samp:`{regex}` matches demangled text in the dump file with + suffix :samp:`{suffix}`. + +:samp:`scan-{kind}-dump-dem-not {regex}{suffix} [{ target/xfail {selector} }]` + Passes if :samp:`{regex}` does not match demangled text in the dump file with + suffix :samp:`{suffix}`. + +The :samp:`{suffix}` argument which describes the dump file to be scanned +may contain a glob pattern that must expand to exactly one file +name. This is useful if, e.g., different pass instances are executed +depending on torture testing command-line flags, producing dump files +whose names differ only in their pass instance number suffix. For +example, to scan instances 1, 2, 3 of a tree pass 'mypass' for +occurrences of the string 'code has been optimized', use: + +.. code-block:: c++ + + /* { dg-options "-fdump-tree-mypass" } */ + /* { dg-final { scan-tree-dump "code has been optimized" "mypass\[1-3\]" } } */ + +Check for output files +~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`output-exists [{ target/xfail {selector} }]` + Passes if compiler output file exists. + +:samp:`output-exists-not [{ target/xfail {selector} }]` + Passes if compiler output file does not exist. + +:samp:`scan-symbol {regexp} [{ target/xfail {selector} }]` + Passes if the pattern is present in the final executable. + +:samp:`scan-symbol-not {regexp} [{ target/xfail {selector} }]` + Passes if the pattern is absent from the final executable. + +Checks for gcov tests +~~~~~~~~~~~~~~~~~~~~~ + +:samp:`run-gcov {sourcefile}` + Check line counts in :command:`gcov` tests. + +:samp:`run-gcov [branches] [calls] { {opts}{sourcefile} }` + Check branch and/or call counts, in addition to line counts, in + :command:`gcov` tests. + +:samp:`run-gcov-pytest { {sourcefile}{pytest_file} }` + Check output of :command:`gcov` intermediate format with a pytest + script. + +Clean up generated test files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Usually the test-framework removes files that were generated during +testing. If a testcase, for example, uses any dumping mechanism to +inspect a passes dump file, the testsuite recognized the dump option +passed to the tool and schedules a final cleanup to remove these files. + +There are, however, following additional cleanup directives that can be +used to annotate a testcase "manually". + +``cleanup-coverage-files`` + Removes coverage data files generated for this test. + +:samp:`cleanup-modules "{list-of-extra-modules}"` + Removes Fortran module files generated for this test, excluding the + module names listed in keep-modules. + Cleaning up module files is usually done automatically by the testsuite + by looking at the source files and removing the modules after the test + has been executed. + + .. code-block:: c++ + + module MoD1 + end module MoD1 + module Mod2 + end module Mod2 + module moD3 + end module moD3 + module mod4 + end module mod4 + ! { dg-final { cleanup-modules "mod1 mod2" } } ! redundant + ! { dg-final { keep-modules "mod3 mod4" } } + +:samp:`keep-modules "{list-of-modules-not-to-delete}"` + Whitespace separated list of module names that should not be deleted by + cleanup-modules. + If the list of modules is empty, all modules defined in this file are kept. + + .. code-block:: c++ + + module maybe_unneeded + end module maybe_unneeded + module keep1 + end module keep1 + module keep2 + end module keep2 + ! { dg-final { keep-modules "keep1 keep2" } } ! just keep these two + ! { dg-final { keep-modules "" } } ! keep all + +:samp:`dg-keep-saved-temps "{list-of-suffixes-not-to-delete}"` + Whitespace separated list of suffixes that should not be deleted + automatically in a testcase that uses :option:`-save-temps`. + + .. code-block:: c++ + + // { dg-options "-save-temps -fpch-preprocess -I." } + int main() { return 0; } + // { dg-keep-saved-temps ".s" } ! just keep assembler file + // { dg-keep-saved-temps ".s" ".i" } ! ... and .i + // { dg-keep-saved-temps ".ii" ".o" } ! or just .ii and .o + +``cleanup-profile-file`` + Removes profiling files generated for this test. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/features-for-dg-add-options.rst b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/features-for-dg-add-options.rst new file mode 100644 index 00000000000..3fef0abca2d --- /dev/null +++ b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/features-for-dg-add-options.rst @@ -0,0 +1,122 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _add-options: + +Features for dg-add-options +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The supported values of :samp:`{feature}` for directive ``dg-add-options`` +are: + +``arm_fp`` + ``__ARM_FP`` definition. Only ARM targets support this feature, and only then + in certain modes; see the :ref:`arm_fp_ok `. + +``arm_fp_dp`` + ``__ARM_FP`` definition with double-precision support. Only ARM + targets support this feature, and only then in certain modes; see the + :ref:`arm_fp_dp_ok `. + +``arm_neon`` + NEON support. Only ARM targets support this feature, and only then + in certain modes; see the :ref:`arm_neon_ok `. + +``arm_fp16`` + VFP half-precision floating point support. This does not select the + FP16 format; for that, use :ref:`arm_fp16_ieee ` or + :ref:`arm_fp16_alternative ` instead. This + feature is only supported by ARM targets and then only in certain + modes; see the :ref:`arm_fp16_ok `. + +.. _arm_fp16_ieee: + +``arm_fp16_ieee`` + ARM IEEE 754-2008 format VFP half-precision floating point support. + This feature is only supported by ARM targets and then only in certain + modes; see the :ref:`arm_fp16_ok `. + +.. _arm_fp16_alternative: + +``arm_fp16_alternative`` + ARM Alternative format VFP half-precision floating point support. + This feature is only supported by ARM targets and then only in certain + modes; see the :ref:`arm_fp16_ok `. + +``arm_neon_fp16`` + NEON and half-precision floating point support. Only ARM targets + support this feature, and only then in certain modes; see + the :ref:`arm_neon_fp16_ok `. + +``arm_vfp3`` + arm vfp3 floating point support; see + the :ref:`arm_vfp3_ok `. + +``arm_arch_v8a_hard`` + Add options for ARMv8-A and the hard-float variant of the AAPCS, + if this is supported by the compiler; see the + :ref:`arm_arch_v8a_hard_ok ` effective target keyword. + +``arm_v8_1a_neon`` + Add options for ARMv8.1-A with Adv.SIMD support, if this is supported + by the target; see the :ref:`arm_v8_1a_neon_ok ` + effective target keyword. + +``arm_v8_2a_fp16_scalar`` + Add options for ARMv8.2-A with scalar FP16 support, if this is + supported by the target; see the + :ref:`arm_v8_2a_fp16_scalar_ok ` effective + target keyword. + +``arm_v8_2a_fp16_neon`` + Add options for ARMv8.2-A with Adv.SIMD FP16 support, if this is + supported by the target; see the + :ref:`arm_v8_2a_fp16_neon_ok ` effective target + keyword. + +``arm_v8_2a_dotprod_neon`` + Add options for ARMv8.2-A with Adv.SIMD Dot Product support, if this is + supported by the target; see the + :ref:`arm_v8_2a_dotprod_neon_ok ` effective target keyword. + +``arm_fp16fml_neon`` + Add options to enable generation of the ``VFMAL`` and ``VFMSL`` + instructions, if this is supported by the target; see the + :ref:`arm_fp16fml_neon_ok ` effective target keyword. + +``arm_dsp`` + Add options for ARM DSP intrinsics support, if this is supported by + the target; see the :ref:`arm_dsp_ok `. + +``bind_pic_locally`` + Add the target-specific flags needed to enable functions to bind + locally when using pic/PIC passes in the testsuite. + +:samp:`float{n}` + Add the target-specific flags needed to use the ``_Floatn`` type. + +:samp:`float{n}x` + Add the target-specific flags needed to use the ``_Floatnx`` type. + +``ieee`` + Add the target-specific flags needed to enable full IEEE + compliance mode. + +``mips16_attribute`` + ``mips16`` function attributes. + Only MIPS targets support this feature, and only then in certain modes. + +.. _stack_size_ao: + +``stack_size`` + Add the flags needed to define macro STACK_SIZE and set it to the stack size + limit associated with the :ref:`stack_size_et `. + +``sqrt_insn`` + Add the target-specific flags needed to enable hardware square root + instructions, if any. + +``tls`` + Add the target-specific flags needed to use thread-local storage. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/keywords-describing-target-attributes.rst b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/keywords-describing-target-attributes.rst new file mode 100644 index 00000000000..2ae4a0d21bb --- /dev/null +++ b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/keywords-describing-target-attributes.rst @@ -0,0 +1,1524 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _effective-target-keywords: + +Keywords describing target attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Effective-target keywords identify sets of targets that support +particular functionality. They are used to limit tests to be run only +for particular targets, or to specify that particular sets of targets +are expected to fail some tests. + +Effective-target keywords are defined in :samp:`lib/target-supports.exp` in +the GCC testsuite, with the exception of those that are documented as +being local to a particular test directory. + +The :samp:`effective target` takes into account all of the compiler options +with which the test will be compiled, including the multilib options. +By convention, keywords ending in ``_nocache`` can also include options +specified for the particular test in an earlier ``dg-options`` or +``dg-add-options`` directive. + +Endianness +~~~~~~~~~~ + +``be`` + Target uses big-endian memory order for multi-byte and multi-word data. + +``le`` + Target uses little-endian memory order for multi-byte and multi-word data. + +Data type sizes +~~~~~~~~~~~~~~~ + +``ilp32`` + Target has 32-bit ``int``, ``long``, and pointers. + +``lp64`` + Target has 32-bit ``int``, 64-bit ``long`` and pointers. + +``llp64`` + Target has 32-bit ``int`` and ``long``, 64-bit ``long long`` + and pointers. + +``double64`` + Target has 64-bit ``double``. + +``double64plus`` + Target has ``double`` that is 64 bits or longer. + +``longdouble128`` + Target has 128-bit ``long double``. + +``int32plus`` + Target has ``int`` that is at 32 bits or longer. + +``int16`` + Target has ``int`` that is 16 bits or shorter. + +``longlong64`` + Target has 64-bit ``long long``. + +``long_neq_int`` + Target has ``int`` and ``long`` with different sizes. + +``short_eq_int`` + Target has ``short`` and ``int`` with the same size. + +``ptr_eq_short`` + Target has pointers (``void *``) and ``short`` with the same size. + +``int_eq_float`` + Target has ``int`` and ``float`` with the same size. + +``ptr_eq_long`` + Target has pointers (``void *``) and ``long`` with the same size. + +``large_double`` + Target supports ``double`` that is longer than ``float``. + +``large_long_double`` + Target supports ``long double`` that is longer than ``double``. + +``ptr32plus`` + Target has pointers that are 32 bits or longer. + +``size20plus`` + Target has a 20-bit or larger address space, so supports at least + 16-bit array and structure sizes. + +``size24plus`` + Target has a 24-bit or larger address space, so supports at least + 20-bit array and structure sizes. + +``size32plus`` + Target has a 32-bit or larger address space, so supports at least + 24-bit array and structure sizes. + +``4byte_wchar_t`` + Target has ``wchar_t`` that is at least 4 bytes. + +:samp:`float{n}` + Target has the ``_Floatn`` type. + +:samp:`float{n}x` + Target has the ``_Floatnx`` type. + +:samp:`float{n}_runtime` + Target has the ``_Floatn`` type, including runtime support + for any options added with ``dg-add-options``. + +:samp:`float{n}x_runtime` + Target has the ``_Floatnx`` type, including runtime support + for any options added with ``dg-add-options``. + +``floatn_nx_runtime`` + Target has runtime support for any options added with + ``dg-add-options`` for any ``_Floatn`` or + ``_Floatnx`` type. + +``inf`` + Target supports floating point infinite (``inf``) for type + ``double``. + +``inff`` + Target supports floating point infinite (``inf``) for type + ``float``. + +Fortran-specific attributes +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``fortran_integer_16`` + Target supports Fortran ``integer`` that is 16 bytes or longer. + +``fortran_real_10`` + Target supports Fortran ``real`` that is 10 bytes or longer. + +``fortran_real_16`` + Target supports Fortran ``real`` that is 16 bytes or longer. + +``fortran_large_int`` + Target supports Fortran ``integer`` kinds larger than ``integer(8)``. + +``fortran_large_real`` + Target supports Fortran ``real`` kinds larger than ``real(8)``. + +Vector-specific attributes +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``vect_align_stack_vars`` + The target's ABI allows stack variables to be aligned to the preferred + vector alignment. + +``vect_avg_qi`` + Target supports both signed and unsigned averaging operations on vectors + of bytes. + +``vect_mulhrs_hi`` + Target supports both signed and unsigned multiply-high-with-round-and-scale + operations on vectors of half-words. + +``vect_sdiv_pow2_si`` + Target supports signed division by constant power-of-2 operations + on vectors of 4-byte integers. + +``vect_condition`` + Target supports vector conditional operations. + +``vect_cond_mixed`` + Target supports vector conditional operations where comparison operands + have different type from the value operands. + +``vect_double`` + Target supports hardware vectors of ``double``. + +``vect_double_cond_arith`` + Target supports conditional addition, subtraction, multiplication, + division, minimum and maximum on vectors of ``double``, via the + ``cond_`` optabs. + +``vect_element_align_preferred`` + The target's preferred vector alignment is the same as the element + alignment. + +``vect_float`` + Target supports hardware vectors of ``float`` when + :option:`-funsafe-math-optimizations` is in effect. + +``vect_float_strict`` + Target supports hardware vectors of ``float`` when + :option:`-funsafe-math-optimizations` is not in effect. + This implies ``vect_float``. + +``vect_int`` + Target supports hardware vectors of ``int``. + +``vect_long`` + Target supports hardware vectors of ``long``. + +``vect_long_long`` + Target supports hardware vectors of ``long long``. + +``vect_check_ptrs`` + Target supports the ``check_raw_ptrs`` and ``check_war_ptrs`` + optabs on vectors. + +``vect_fully_masked`` + Target supports fully-masked (also known as fully-predicated) loops, + so that vector loops can handle partial as well as full vectors. + +``vect_masked_load`` + Target supports vector masked loads. + +``vect_masked_store`` + Target supports vector masked stores. + +``vect_gather_load_ifn`` + Target supports vector gather loads using internal functions + (rather than via built-in functions or emulation). + +``vect_scatter_store`` + Target supports vector scatter stores. + +``vect_aligned_arrays`` + Target aligns arrays to vector alignment boundary. + +``vect_hw_misalign`` + Target supports a vector misalign access. + +``vect_no_align`` + Target does not support a vector alignment mechanism. + +``vect_peeling_profitable`` + Target might require to peel loops for alignment purposes. + +``vect_no_int_min_max`` + Target does not support a vector min and max instruction on ``int``. + +``vect_no_int_add`` + Target does not support a vector add instruction on ``int``. + +``vect_no_bitwise`` + Target does not support vector bitwise instructions. + +``vect_bool_cmp`` + Target supports comparison of ``bool`` vectors for at least one + vector length. + +``vect_char_add`` + Target supports addition of ``char`` vectors for at least one + vector length. + +``vect_char_mult`` + Target supports ``vector char`` multiplication. + +``vect_short_mult`` + Target supports ``vector short`` multiplication. + +``vect_int_mult`` + Target supports ``vector int`` multiplication. + +``vect_long_mult`` + Target supports 64 bit ``vector long`` multiplication. + +``vect_extract_even_odd`` + Target supports vector even/odd element extraction. + +``vect_extract_even_odd_wide`` + Target supports vector even/odd element extraction of vectors with elements + ``SImode`` or larger. + +``vect_interleave`` + Target supports vector interleaving. + +``vect_strided`` + Target supports vector interleaving and extract even/odd. + +``vect_strided_wide`` + Target supports vector interleaving and extract even/odd for wide + element types. + +``vect_perm`` + Target supports vector permutation. + +``vect_perm_byte`` + Target supports permutation of vectors with 8-bit elements. + +``vect_perm_short`` + Target supports permutation of vectors with 16-bit elements. + +``vect_perm3_byte`` + Target supports permutation of vectors with 8-bit elements, and for the + default vector length it is possible to permute: + + .. code-block:: c++ + + { a0, a1, a2, b0, b1, b2, ... } + + to: + + .. code-block:: c++ + + { a0, a0, a0, b0, b0, b0, ... } + { a1, a1, a1, b1, b1, b1, ... } + { a2, a2, a2, b2, b2, b2, ... } + + using only two-vector permutes, regardless of how long the sequence is. + +``vect_perm3_int`` + Like ``vect_perm3_byte``, but for 32-bit elements. + +``vect_perm3_short`` + Like ``vect_perm3_byte``, but for 16-bit elements. + +``vect_shift`` + Target supports a hardware vector shift operation. + +``vect_unaligned_possible`` + Target prefers vectors to have an alignment greater than element + alignment, but also allows unaligned vector accesses in some + circumstances. + +``vect_variable_length`` + Target has variable-length vectors. + +``vect64`` + Target supports vectors of 64 bits. + +``vect32`` + Target supports vectors of 32 bits. + +``vect_widen_sum_hi_to_si`` + Target supports a vector widening summation of ``short`` operands + into ``int`` results, or can promote (unpack) from ``short`` + to ``int``. + +``vect_widen_sum_qi_to_hi`` + Target supports a vector widening summation of ``char`` operands + into ``short`` results, or can promote (unpack) from ``char`` + to ``short``. + +``vect_widen_sum_qi_to_si`` + Target supports a vector widening summation of ``char`` operands + into ``int`` results. + +``vect_widen_mult_qi_to_hi`` + Target supports a vector widening multiplication of ``char`` operands + into ``short`` results, or can promote (unpack) from ``char`` to + ``short`` and perform non-widening multiplication of ``short``. + +``vect_widen_mult_hi_to_si`` + Target supports a vector widening multiplication of ``short`` operands + into ``int`` results, or can promote (unpack) from ``short`` to + ``int`` and perform non-widening multiplication of ``int``. + +``vect_widen_mult_si_to_di_pattern`` + Target supports a vector widening multiplication of ``int`` operands + into ``long`` results. + +``vect_sdot_qi`` + Target supports a vector dot-product of ``signed char``. + +``vect_udot_qi`` + Target supports a vector dot-product of ``unsigned char``. + +``vect_usdot_qi`` + Target supports a vector dot-product where one operand of the multiply is + ``signed char`` and the other of ``unsigned char``. + +``vect_sdot_hi`` + Target supports a vector dot-product of ``signed short``. + +``vect_udot_hi`` + Target supports a vector dot-product of ``unsigned short``. + +``vect_pack_trunc`` + Target supports a vector demotion (packing) of ``short`` to ``char`` + and from ``int`` to ``short`` using modulo arithmetic. + +``vect_unpack`` + Target supports a vector promotion (unpacking) of ``char`` to ``short`` + and from ``char`` to ``int``. + +``vect_intfloat_cvt`` + Target supports conversion from ``signed int`` to ``float``. + +``vect_uintfloat_cvt`` + Target supports conversion from ``unsigned int`` to ``float``. + +``vect_floatint_cvt`` + Target supports conversion from ``float`` to ``signed int``. + +``vect_floatuint_cvt`` + Target supports conversion from ``float`` to ``unsigned int``. + +``vect_intdouble_cvt`` + Target supports conversion from ``signed int`` to ``double``. + +``vect_doubleint_cvt`` + Target supports conversion from ``double`` to ``signed int``. + +``vect_max_reduc`` + Target supports max reduction for vectors. + +``vect_sizes_16B_8B`` + Target supports 16- and 8-bytes vectors. + +``vect_sizes_32B_16B`` + Target supports 32- and 16-bytes vectors. + +``vect_logical_reduc`` + Target supports AND, IOR and XOR reduction on vectors. + +``vect_fold_extract_last`` + Target supports the ``fold_extract_last`` optab. + +``vect_len_load_store`` + Target supports the ``len_load`` and ``len_store`` optabs. + +``vect_partial_vectors_usage_1`` + Target supports loop vectorization with partial vectors and + ``vect-partial-vector-usage`` is set to 1. + +``vect_partial_vectors_usage_2`` + Target supports loop vectorization with partial vectors and + ``vect-partial-vector-usage`` is set to 2. + +``vect_partial_vectors`` + Target supports loop vectorization with partial vectors and + ``vect-partial-vector-usage`` is nonzero. + +``vect_slp_v2qi_store_align`` + Target supports vectorization of 2-byte char stores with 2-byte aligned + address at plain :option:`-O2`. + +``vect_slp_v4qi_store_align`` + Target supports vectorization of 4-byte char stores with 4-byte aligned + address at plain :option:`-O2`. + +``vect_slp_v4qi_store_unalign`` + Target supports vectorization of 4-byte char stores with unaligned address + at plain :option:`-O2`. + +``struct_4char_block_move`` + Target supports block move for 8-byte aligned 4-byte size struct initialization. + +``vect_slp_v4qi_store_unalign_1`` + Target supports vectorization of 4-byte char stores with unaligned address + or store them with constant pool at plain :option:`-O2`. + +``struct_8char_block_move`` + Target supports block move for 8-byte aligned 8-byte size struct initialization. + +``vect_slp_v8qi_store_unalign_1`` + Target supports vectorization of 8-byte char stores with unaligned address + or store them with constant pool at plain :option:`-O2`. + +``struct_16char_block_move`` + Target supports block move for 8-byte aligned 16-byte size struct + initialization. + +``vect_slp_v16qi_store_unalign_1`` + Target supports vectorization of 16-byte char stores with unaligned address + or store them with constant pool at plain :option:`-O2`. + +``vect_slp_v2hi_store_align`` + Target supports vectorization of 4-byte short stores with 4-byte aligned + addressat plain :option:`-O2`. + +``vect_slp_v2hi_store_unalign`` + Target supports vectorization of 4-byte short stores with unaligned address + at plain :option:`-O2`. + +``vect_slp_v4hi_store_unalign`` + Target supports vectorization of 8-byte short stores with unaligned address + at plain :option:`-O2`. + +``vect_slp_v2si_store_align`` + Target supports vectorization of 8-byte int stores with 8-byte aligned address + at plain :option:`-O2`. + +``vect_slp_v4si_store_unalign`` + Target supports vectorization of 16-byte int stores with unaligned address + at plain :option:`-O2`. + +Thread Local Storage attributes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``tls`` + Target supports thread-local storage. + +``tls_native`` + Target supports native (rather than emulated) thread-local storage. + +``tls_runtime`` + Test system supports executing TLS executables. + +Decimal floating point attributes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``dfp`` + Targets supports compiling decimal floating point extension to C. + +``dfp_nocache`` + Including the options used to compile this particular test, the + target supports compiling decimal floating point extension to C. + +``dfprt`` + Test system can execute decimal floating point tests. + +``dfprt_nocache`` + Including the options used to compile this particular test, the + test system can execute decimal floating point tests. + +``hard_dfp`` + Target generates decimal floating point instructions with current options. + +``dfp_bid`` + Target uses the BID format for decimal floating point. + +ARM-specific attributes +~~~~~~~~~~~~~~~~~~~~~~~ + +``arm32`` + ARM target generates 32-bit code. + +``arm_little_endian`` + ARM target that generates little-endian code. + +``arm_eabi`` + ARM target adheres to the ABI for the ARM Architecture. + +.. _arm_fp_ok: + +``arm_fp_ok`` + ARM target defines ``__ARM_FP`` using ``-mfloat-abi=softfp`` or + equivalent options. Some multilibs may be incompatible with these + options. + +.. _arm_fp_dp_ok: + +``arm_fp_dp_ok`` + ARM target defines ``__ARM_FP`` with double-precision support using + ``-mfloat-abi=softfp`` or equivalent options. Some multilibs may + be incompatible with these options. + +``arm_hf_eabi`` + ARM target adheres to the VFP and Advanced SIMD Register Arguments + variant of the ABI for the ARM Architecture (as selected with + ``-mfloat-abi=hard``). + +``arm_softfloat`` + ARM target uses emulated floating point operations. + +``arm_hard_vfp_ok`` + ARM target supports ``-mfpu=vfp -mfloat-abi=hard``. + Some multilibs may be incompatible with these options. + +``arm_iwmmxt_ok`` + ARM target supports ``-mcpu=iwmmxt``. + Some multilibs may be incompatible with this option. + +``arm_neon`` + ARM target supports generating NEON instructions. + +``arm_tune_string_ops_prefer_neon`` + Test CPU tune supports inlining string operations with NEON instructions. + +``arm_neon_hw`` + Test system supports executing NEON instructions. + +``arm_neonv2_hw`` + Test system supports executing NEON v2 instructions. + +.. _arm_neon_ok: + +``arm_neon_ok`` + ARM Target supports ``-mfpu=neon -mfloat-abi=softfp`` or compatible + options. Some multilibs may be incompatible with these options. + +``arm_neon_ok_no_float_abi`` + ARM Target supports NEON with ``-mfpu=neon``, but without any + -mfloat-abi= option. Some multilibs may be incompatible with this + option. + +``arm_neonv2_ok`` + ARM Target supports ``-mfpu=neon-vfpv4 -mfloat-abi=softfp`` or compatible + options. Some multilibs may be incompatible with these options. + +.. _arm_fp16_ok: + +``arm_fp16_ok`` + Target supports options to generate VFP half-precision floating-point + instructions. Some multilibs may be incompatible with these + options. This test is valid for ARM only. + +``arm_fp16_hw`` + Target supports executing VFP half-precision floating-point + instructions. This test is valid for ARM only. + +.. _arm_neon_fp16_ok: + +``arm_neon_fp16_ok`` + ARM Target supports ``-mfpu=neon-fp16 -mfloat-abi=softfp`` or compatible + options, including ``-mfp16-format=ieee`` if necessary to obtain the + ``__fp16`` type. Some multilibs may be incompatible with these options. + +``arm_neon_fp16_hw`` + Test system supports executing Neon half-precision float instructions. + (Implies previous.) + +``arm_fp16_alternative_ok`` + ARM target supports the ARM FP16 alternative format. Some multilibs + may be incompatible with the options needed. + +``arm_fp16_none_ok`` + ARM target supports specifying none as the ARM FP16 format. + +``arm_thumb1_ok`` + ARM target generates Thumb-1 code for ``-mthumb``. + +``arm_thumb2_ok`` + ARM target generates Thumb-2 code for ``-mthumb``. + +``arm_nothumb`` + ARM target that is not using Thumb. + +``arm_vfp_ok`` + ARM target supports ``-mfpu=vfp -mfloat-abi=softfp``. + Some multilibs may be incompatible with these options. + +.. _arm_vfp3_ok: + +``arm_vfp3_ok`` + ARM target supports ``-mfpu=vfp3 -mfloat-abi=softfp``. + Some multilibs may be incompatible with these options. + +.. _arm_arch_v8a_hard_ok: + +``arm_arch_v8a_hard_ok`` + The compiler is targeting ``arm*-*-*`` and can compile and assemble code + using the options ``-march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard``. + This is not enough to guarantee that linking works. + +``arm_arch_v8a_hard_multilib`` + The compiler is targeting ``arm*-*-*`` and can build programs using + the options ``-march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard``. + The target can also run the resulting binaries. + +``arm_v8_vfp_ok`` + ARM target supports ``-mfpu=fp-armv8 -mfloat-abi=softfp``. + Some multilibs may be incompatible with these options. + +``arm_v8_neon_ok`` + ARM target supports ``-mfpu=neon-fp-armv8 -mfloat-abi=softfp``. + Some multilibs may be incompatible with these options. + +.. _arm_v8_1a_neon_ok: + +``arm_v8_1a_neon_ok`` + ARM target supports options to generate ARMv8.1-A Adv.SIMD instructions. + Some multilibs may be incompatible with these options. + +``arm_v8_1a_neon_hw`` + ARM target supports executing ARMv8.1-A Adv.SIMD instructions. Some + multilibs may be incompatible with the options needed. Implies + arm_v8_1a_neon_ok. + +``arm_acq_rel`` + ARM target supports acquire-release instructions. + +.. _arm_v8_2a_fp16_scalar_ok: + +``arm_v8_2a_fp16_scalar_ok`` + ARM target supports options to generate instructions for ARMv8.2-A and + scalar instructions from the FP16 extension. Some multilibs may be + incompatible with these options. + +``arm_v8_2a_fp16_scalar_hw`` + ARM target supports executing instructions for ARMv8.2-A and scalar + instructions from the FP16 extension. Some multilibs may be + incompatible with these options. Implies arm_v8_2a_fp16_neon_ok. + +.. _arm_v8_2a_fp16_neon_ok: + +``arm_v8_2a_fp16_neon_ok`` + ARM target supports options to generate instructions from ARMv8.2-A with + the FP16 extension. Some multilibs may be incompatible with these + options. Implies arm_v8_2a_fp16_scalar_ok. + +``arm_v8_2a_fp16_neon_hw`` + ARM target supports executing instructions from ARMv8.2-A with the FP16 + extension. Some multilibs may be incompatible with these options. + Implies arm_v8_2a_fp16_neon_ok and arm_v8_2a_fp16_scalar_hw. + +.. _arm_v8_2a_dotprod_neon_ok: + +``arm_v8_2a_dotprod_neon_ok`` + ARM target supports options to generate instructions from ARMv8.2-A with + the Dot Product extension. Some multilibs may be incompatible with these + options. + +``arm_v8_2a_dotprod_neon_hw`` + ARM target supports executing instructions from ARMv8.2-A with the Dot + Product extension. Some multilibs may be incompatible with these options. + Implies arm_v8_2a_dotprod_neon_ok. + +``arm_v8_2a_i8mm_neon_hw`` + ARM target supports executing instructions from ARMv8.2-A with the 8-bit + Matrix Multiply extension. Some multilibs may be incompatible with these + options. Implies arm_v8_2a_i8mm_ok. + +.. _arm_fp16fml_neon_ok: + +``arm_fp16fml_neon_ok`` + ARM target supports extensions to generate the ``VFMAL`` and ``VFMLS`` + half-precision floating-point instructions available from ARMv8.2-A and + onwards. Some multilibs may be incompatible with these options. + +``arm_v8_2a_bf16_neon_ok`` + ARM target supports options to generate instructions from ARMv8.2-A with + the BFloat16 extension (bf16). Some multilibs may be incompatible with these + options. + +``arm_v8_2a_i8mm_ok`` + ARM target supports options to generate instructions from ARMv8.2-A with + the 8-Bit Integer Matrix Multiply extension (i8mm). Some multilibs may be + incompatible with these options. + +``arm_v8_1m_mve_ok`` + ARM target supports options to generate instructions from ARMv8.1-M with + the M-Profile Vector Extension (MVE). Some multilibs may be incompatible + with these options. + +``arm_v8_1m_mve_fp_ok`` + ARM target supports options to generate instructions from ARMv8.1-M with + the Half-precision floating-point instructions (HP), Floating-point Extension + (FP) along with M-Profile Vector Extension (MVE). Some multilibs may be + incompatible with these options. + +``arm_mve_hw`` + Test system supports executing MVE instructions. + +``arm_v8m_main_cde`` + ARM target supports options to generate instructions from ARMv8-M with + the Custom Datapath Extension (CDE). Some multilibs may be incompatible + with these options. + +``arm_v8m_main_cde_fp`` + ARM target supports options to generate instructions from ARMv8-M with + the Custom Datapath Extension (CDE) and floating-point (VFP). + Some multilibs may be incompatible with these options. + +``arm_v8_1m_main_cde_mve`` + ARM target supports options to generate instructions from ARMv8.1-M with + the Custom Datapath Extension (CDE) and M-Profile Vector Extension (MVE). + Some multilibs may be incompatible with these options. + +``arm_prefer_ldrd_strd`` + ARM target prefers ``LDRD`` and ``STRD`` instructions over + ``LDM`` and ``STM`` instructions. + +``arm_thumb1_movt_ok`` + ARM target generates Thumb-1 code for ``-mthumb`` with ``MOVW`` + and ``MOVT`` instructions available. + +``arm_thumb1_cbz_ok`` + ARM target generates Thumb-1 code for ``-mthumb`` with + ``CBZ`` and ``CBNZ`` instructions available. + +``arm_divmod_simode`` + ARM target for which divmod transform is disabled, if it supports hardware + div instruction. + +``arm_cmse_ok`` + ARM target supports ARMv8-M Security Extensions, enabled by the ``-mcmse`` + option. + +``arm_cmse_hw`` + Test system supports executing CMSE instructions. + +.. _arm_coproc1_ok: + +``arm_coproc1_ok`` + ARM target supports the following coprocessor instructions: ``CDP``, + ``LDC``, ``STC``, ``MCR`` and ``MRC``. + +.. _arm_coproc2_ok: + +``arm_coproc2_ok`` + ARM target supports all the coprocessor instructions also listed as supported + in :ref:`_arm_coproc1_ok ` in addition to the following: ``CDP2``, ``LDC2``, + ``LDC2l``, ``STC2``, ``STC2l``, ``MCR2`` and ``MRC2``. + +.. _arm_coproc3_ok: + +``arm_coproc3_ok`` + ARM target supports all the coprocessor instructions also listed as supported + in :ref:`arm_coproc2_ok ` in addition the following: ``MCRR`` and ``MRRC``. + +``arm_coproc4_ok`` + ARM target supports all the coprocessor instructions also listed as supported + in :ref:`arm_coproc3_ok ` in addition the following: ``MCRR2`` and ``MRRC2``. + +``arm_simd32_ok`` + ARM Target supports options suitable for accessing the SIMD32 intrinsics from + ``arm_acle.h``. + Some multilibs may be incompatible with these options. + +``arm_sat_ok`` + ARM Target supports options suitable for accessing the saturation + intrinsics from ``arm_acle.h``. + Some multilibs may be incompatible with these options. + +.. _arm_dsp_ok: + +``arm_dsp_ok`` + ARM Target supports options suitable for accessing the DSP intrinsics + from ``arm_acle.h``. + Some multilibs may be incompatible with these options. + +``arm_softfp_ok`` + ARM target supports the ``-mfloat-abi=softfp`` option. + +``arm_hard_ok`` + ARM target supports the ``-mfloat-abi=hard`` option. + + +.. _arm_mve: + +``arm_mve`` + ARM target supports generating MVE instructions. + +``arm_v8_1_lob_ok`` + ARM Target supports executing the Armv8.1-M Mainline Low Overhead Loop + instructions ``DLS`` and ``LE``. + Some multilibs may be incompatible with these options. + +``arm_thumb2_no_arm_v8_1_lob`` + ARM target where Thumb-2 is used without options but does not support + executing the Armv8.1-M Mainline Low Overhead Loop instructions + ``DLS`` and ``LE``. + +``arm_thumb2_ok_no_arm_v8_1_lob`` + ARM target generates Thumb-2 code for ``-mthumb`` but does not + support executing the Armv8.1-M Mainline Low Overhead Loop + instructions ``DLS`` and ``LE``. + +AArch64-specific attributes +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``aarch64_asm__ok`` + AArch64 assembler supports the architecture extension ``ext`` via the + ``.arch_extension`` pseudo-op. + +``aarch64_tiny`` + AArch64 target which generates instruction sequences for tiny memory model. + +``aarch64_small`` + AArch64 target which generates instruction sequences for small memory model. + +``aarch64_large`` + AArch64 target which generates instruction sequences for large memory model. + +``aarch64_little_endian`` + AArch64 target which generates instruction sequences for little endian. + +``aarch64_big_endian`` + AArch64 target which generates instruction sequences for big endian. + +``aarch64_small_fpic`` + Binutils installed on test system supports relocation types required by -fpic + for AArch64 small memory model. + +``aarch64_sve_hw`` + AArch64 target that is able to generate and execute SVE code (regardless of + whether it does so by default). + +``aarch64_sve128_hw`` ``aarch64_sve256_hw`` ``aarch64_sve512_hw`` ``aarch64_sve1024_hw`` ``aarch64_sve2048_hw`` + Like ``aarch64_sve_hw``, but also test for an exact hardware vector length. + +``aarch64_fjcvtzs_hw`` + AArch64 target that is able to generate and execute armv8.3-a FJCVTZS + instruction. + +MIPS-specific attributes +~~~~~~~~~~~~~~~~~~~~~~~~ + +``mips64`` + MIPS target supports 64-bit instructions. + +``nomips16`` + MIPS target does not produce MIPS16 code. + +``mips16_attribute`` + MIPS target can generate MIPS16 code. + +``mips_loongson`` + MIPS target is a Loongson-2E or -2F target using an ABI that supports + the Loongson vector modes. + +``mips_msa`` + MIPS target supports ``-mmsa``, MIPS SIMD Architecture (MSA). + +``mips_newabi_large_long_double`` + MIPS target supports ``long double`` larger than ``double`` + when using the new ABI. + +``mpaired_single`` + MIPS target supports ``-mpaired-single``. + +MSP430-specific attributes +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``msp430_small`` + MSP430 target has the small memory model enabled (``-msmall``). + +``msp430_large`` + MSP430 target has the large memory model enabled (``-mlarge``). + +PowerPC-specific attributes +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``dfp_hw`` + PowerPC target supports executing hardware DFP instructions. + +``p8vector_hw`` + PowerPC target supports executing VSX instructions (ISA 2.07). + +``powerpc64`` + Test system supports executing 64-bit instructions. + +``powerpc_altivec`` + PowerPC target supports AltiVec. + +``powerpc_altivec_ok`` + PowerPC target supports ``-maltivec``. + +``powerpc_eabi_ok`` + PowerPC target supports ``-meabi``. + +``powerpc_elfv2`` + PowerPC target supports ``-mabi=elfv2``. + +``powerpc_fprs`` + PowerPC target supports floating-point registers. + +``powerpc_hard_double`` + PowerPC target supports hardware double-precision floating-point. + +``powerpc_htm_ok`` + PowerPC target supports ``-mhtm`` + +``powerpc_p8vector_ok`` + PowerPC target supports ``-mpower8-vector`` + +``powerpc_popcntb_ok`` + PowerPC target supports the ``popcntb`` instruction, indicating + that this target supports ``-mcpu=power5``. + +``powerpc_ppu_ok`` + PowerPC target supports ``-mcpu=cell``. + +``powerpc_spe`` + PowerPC target supports PowerPC SPE. + +``powerpc_spe_nocache`` + Including the options used to compile this particular test, the + PowerPC target supports PowerPC SPE. + +``powerpc_spu`` + PowerPC target supports PowerPC SPU. + +``powerpc_vsx_ok`` + PowerPC target supports ``-mvsx``. + +``powerpc_405_nocache`` + Including the options used to compile this particular test, the + PowerPC target supports PowerPC 405. + +``ppc_recip_hw`` + PowerPC target supports executing reciprocal estimate instructions. + +``vmx_hw`` + PowerPC target supports executing AltiVec instructions. + +``vsx_hw`` + PowerPC target supports executing VSX instructions (ISA 2.06). + +``has_arch_pwr5`` + PowerPC target pre-defines macro _ARCH_PWR5 which means the ``-mcpu`` + setting is Power5 or later. + +``has_arch_pwr6`` + PowerPC target pre-defines macro _ARCH_PWR6 which means the ``-mcpu`` + setting is Power6 or later. + +``has_arch_pwr7`` + PowerPC target pre-defines macro _ARCH_PWR7 which means the ``-mcpu`` + setting is Power7 or later. + +``has_arch_pwr8`` + PowerPC target pre-defines macro _ARCH_PWR8 which means the ``-mcpu`` + setting is Power8 or later. + +``has_arch_pwr9`` + PowerPC target pre-defines macro _ARCH_PWR9 which means the ``-mcpu`` + setting is Power9 or later. + +RISC-V specific attributes +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``rv32`` + Test system has an integer register width of 32 bits. + +``rv64`` + Test system has an integer register width of 64 bits. + +Other hardware attributes +~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. Please keep this table sorted alphabetically. + +``autoincdec`` + Target supports autoincrement/decrement addressing. + +``avx`` + Target supports compiling ``avx`` instructions. + +``avx_runtime`` + Target supports the execution of ``avx`` instructions. + +``avx2`` + Target supports compiling ``avx2`` instructions. + +``avx2_runtime`` + Target supports the execution of ``avx2`` instructions. + +``avxvnni`` + Target supports the execution of ``avxvnni`` instructions. + +``avx512f`` + Target supports compiling ``avx512f`` instructions. + +``avx512f_runtime`` + Target supports the execution of ``avx512f`` instructions. + +``avx512vp2intersect`` + Target supports the execution of ``avx512vp2intersect`` instructions. + +``avxifma`` + Target supports the execution of ``avxifma`` instructions. + +``avxneconvert`` + Target supports the execution of ``avxneconvert`` instructions. + +``avxvnniint8`` + Target supports the execution of ``avxvnniint8`` instructions. + +``amx_tile`` + Target supports the execution of ``amx-tile`` instructions. + +``amx_int8`` + Target supports the execution of ``amx-int8`` instructions. + +``amx_bf16`` + Target supports the execution of ``amx-bf16`` instructions. + +``amx_fp16`` + Target supports the execution of ``amx-fp16`` instructions. + +``cell_hw`` + Test system can execute AltiVec and Cell PPU instructions. + +``cmpccxadd`` + Target supports the execution of ``cmpccxadd`` instructions. + +``coldfire_fpu`` + Target uses a ColdFire FPU. + +``divmod`` + Target supporting hardware divmod insn or divmod libcall. + +``divmod_simode`` + Target supporting hardware divmod insn or divmod libcall for SImode. + +``hard_float`` + Target supports FPU instructions. + +``non_strict_align`` + Target does not require strict alignment. + +``pie_copyreloc`` + The x86-64 target linker supports PIE with copy reloc. + +``prefetchi`` + Target supports the execution of ``prefetchi`` instructions. + +``raoint`` + Target supports the execution of ``raoint`` instructions. + +``rdrand`` + Target supports x86 ``rdrand`` instruction. + +``sqrt_insn`` + Target has a square root instruction that the compiler can generate. + +``sse`` + Target supports compiling ``sse`` instructions. + +``sse_runtime`` + Target supports the execution of ``sse`` instructions. + +``sse2`` + Target supports compiling ``sse2`` instructions. + +``sse2_runtime`` + Target supports the execution of ``sse2`` instructions. + +``sync_char_short`` + Target supports atomic operations on ``char`` and ``short``. + +``sync_int_long`` + Target supports atomic operations on ``int`` and ``long``. + +``ultrasparc_hw`` + Test environment appears to run executables on a simulator that + accepts only ``EM_SPARC`` executables and chokes on ``EM_SPARC32PLUS`` + or ``EM_SPARCV9`` executables. + +``vect_cmdline_needed`` + Target requires a command line argument to enable a SIMD instruction set. + +``xorsign`` + Target supports the xorsign optab expansion. + +Environment attributes +~~~~~~~~~~~~~~~~~~~~~~ + +``c`` + The language for the compiler under test is C. + +``c++`` + The language for the compiler under test is C++. + +``c99_runtime`` + Target provides a full C99 runtime. + +``correct_iso_cpp_string_wchar_protos`` + Target ``string.h`` and ``wchar.h`` headers provide C++ required + overloads for ``strchr`` etc. functions. + +``d_runtime`` + Target provides the D runtime. + +``d_runtime_has_std_library`` + Target provides the D standard library (Phobos). + +``dummy_wcsftime`` + Target uses a dummy ``wcsftime`` function that always returns zero. + +``fd_truncate`` + Target can truncate a file from a file descriptor, as used by + :samp:`libgfortran/io/unix.c:fd_truncate`; i.e. ``ftruncate`` or + ``chsize``. + +``fenv`` + Target provides :samp:`fenv.h` include file. + +``fenv_exceptions`` + Target supports :samp:`fenv.h` with all the standard IEEE exceptions + and floating-point exceptions are raised by arithmetic operations. + +``fenv_exceptions_dfp`` + Target supports :samp:`fenv.h` with all the standard IEEE exceptions + and floating-point exceptions are raised by arithmetic operations for + decimal floating point. + +``fileio`` + Target offers such file I/O library functions as ``fopen``, + ``fclose``, ``tmpnam``, and ``remove``. This is a link-time + requirement for the presence of the functions in the library; even if + they fail at runtime, the requirement is still regarded as satisfied. + +``freestanding`` + Target is :samp:`freestanding` as defined in section 4 of the C99 standard. + Effectively, it is a target which supports no extra headers or libraries + other than what is considered essential. + +``gettimeofday`` + Target supports ``gettimeofday``. + +``init_priority`` + Target supports constructors with initialization priority arguments. + +``inttypes_types`` + Target has the basic signed and unsigned types in ``inttypes.h``. + This is for tests that GCC's notions of these types agree with those + in the header, as some systems have only ``inttypes.h``. + +``lax_strtofp`` + Target might have errors of a few ULP in string to floating-point + conversion functions and overflow is not always detected correctly by + those functions. + +``mempcpy`` + Target provides ``mempcpy`` function. + +``mmap`` + Target supports ``mmap``. + +``newlib`` + Target supports Newlib. + +``newlib_nano_io`` + GCC was configured with ``--enable-newlib-nano-formatted-io``, which reduces + the code size of Newlib formatted I/O functions. + +``pow10`` + Target provides ``pow10`` function. + +``pthread`` + Target can compile using ``pthread.h`` with no errors or warnings. + +``pthread_h`` + Target has ``pthread.h``. + +``run_expensive_tests`` + Expensive testcases (usually those that consume excessive amounts of CPU + time) should be run on this target. This can be enabled by setting the + :envvar:`GCC_TEST_RUN_EXPENSIVE` environment variable to a non-empty string. + +``simulator`` + Test system runs executables on a simulator (i.e. slowly) rather than + hardware (i.e. fast). + +``signal`` + Target has ``signal.h``. + +``stabs`` + Target supports the stabs debugging format. + +``stdint_types`` + Target has the basic signed and unsigned C types in ``stdint.h``. + This will be obsolete when GCC ensures a working ``stdint.h`` for + all targets. + +``stdint_types_mbig_endian`` + Target accepts the option :option:`-mbig-endian` and ``stdint.h`` + can be included without error when :option:`-mbig-endian` is passed. + +``stpcpy`` + Target provides ``stpcpy`` function. + +``sysconf`` + Target supports ``sysconf``. + +``trampolines`` + Target supports trampolines. + +``two_plus_gigs`` + Target supports linking programs with 2+GiB of data. + +``uclibc`` + Target supports uClibc. + +``unwrapped`` + Target does not use a status wrapper. + +``vxworks_kernel`` + Target is a VxWorks kernel. + +``vxworks_rtp`` + Target is a VxWorks RTP. + +``wchar`` + Target supports wide characters. + +Other attributes +~~~~~~~~~~~~~~~~ + +``R_flag_in_section`` + Target supports the 'R' flag in .section directive in assembly inputs. + +``automatic_stack_alignment`` + Target supports automatic stack alignment. + +``branch_cost`` + Target supports :option:`-branch-cost=N`. + +``cxa_atexit`` + Target uses ``__cxa_atexit``. + +.. _default_packed: + +``default_packed`` + Target has packed layout of structure members by default. + +``exceptions`` + Target supports exceptions. + +``exceptions_enabled`` + Target supports exceptions and they are enabled in the current + testing configuration. + +``fgraphite`` + Target supports Graphite optimizations. + +``fixed_point`` + Target supports fixed-point extension to C. + +``fopenacc`` + Target supports OpenACC via :option:`-fopenacc`. + +``fopenmp`` + Target supports OpenMP via :option:`-fopenmp`. + +``fpic`` + Target supports :option:`-fpic` and :option:`-fPIC`. + +``freorder`` + Target supports :option:`-freorder-blocks-and-partition`. + +``fstack_protector`` + Target supports :option:`-fstack-protector`. + +``gas`` + Target uses GNU :command:`as`. + +``gc_sections`` + Target supports :option:`--gc-sections`. + +``gld`` + Target uses GNU :command:`ld`. + +``keeps_null_pointer_checks`` + Target keeps null pointer checks, either due to the use of + :option:`-fno-delete-null-pointer-checks` or hardwired into the target. + +``llvm_binutils`` + Target is using an LLVM assembler and/or linker, instead of GNU Binutils. + +``lra`` + Target supports local register allocator (LRA). + +``lto`` + Compiler has been configured to support link-time optimization (LTO). + +``lto_incremental`` + Compiler and linker support link-time optimization relocatable linking + with :option:`-r` and :option:`-flto` options. + +``naked_functions`` + Target supports the ``naked`` function attribute. + +``named_sections`` + Target supports named sections. + +``natural_alignment_32`` + Target uses natural alignment (aligned to type size) for types of + 32 bits or less. + +``target_natural_alignment_64`` + Target uses natural alignment (aligned to type size) for types of + 64 bits or less. + +``no_alignment_constraints`` + Target defines __BIGGEST_ALIGNMENT__=1. Hence target imposes + no alignment constraints. This is similar, but not necessarily + the same as :ref:`default_packed`. Although ``BIGGEST_FIELD_ALIGNMENT`` + defaults to ``BIGGEST_ALIGNMENT`` for most targets, it is possible + for a target to set those two with different values and have different + alignment constraints for aggregate and non-aggregate types. + +``noinit`` + Target supports the ``noinit`` variable attribute. + +``nonpic`` + Target does not generate PIC by default. + +``o_flag_in_section`` + Target supports the 'o' flag in .section directive in assembly inputs. + +``offload_gcn`` + Target has been configured for OpenACC/OpenMP offloading on AMD GCN. + +``persistent`` + Target supports the ``persistent`` variable attribute. + +``pie_enabled`` + Target generates PIE by default. + +``pcc_bitfield_type_matters`` + Target defines ``PCC_BITFIELD_TYPE_MATTERS``. + +``pe_aligned_commons`` + Target supports :option:`-mpe-aligned-commons`. + +``pie`` + Target supports :option:`-pie`, :option:`-fpie` and :option:`-fPIE`. + +``rdynamic`` + Target supports :option:`-rdynamic`. + +``scalar_all_fma`` + Target supports all four fused multiply-add optabs for both ``float`` + and ``double``. These optabs are: ``fma_optab``, ``fms_optab``, + ``fnma_optab`` and ``fnms_optab``. + +``section_anchors`` + Target supports section anchors. + +``short_enums`` + Target defaults to short enums. + +.. _stack_size_et: + +``stack_size`` + Target has limited stack size. The stack size limit can be obtained using the + STACK_SIZE macro defined by :ref:`stack_size_ao`. + +``static`` + Target supports :option:`-static`. + +``static_libgfortran`` + Target supports statically linking :samp:`libgfortran`. + +``string_merging`` + Target supports merging string constants at link time. + +``ucn`` + Target supports compiling and assembling UCN. + +``ucn_nocache`` + Including the options used to compile this particular test, the + target supports compiling and assembling UCN. + +``unaligned_stack`` + Target does not guarantee that its ``STACK_BOUNDARY`` is greater than + or equal to the required vector alignment. + +``vector_alignment_reachable`` + Vector alignment is reachable for types of 32 bits or less. + +``vector_alignment_reachable_for_64bit`` + Vector alignment is reachable for types of 64 bits or less. + +``vma_equals_lma`` + Target generates executable with VMA equal to LMA for .data section. + +``wchar_t_char16_t_compatible`` + Target supports ``wchar_t`` that is compatible with ``char16_t``. + +``wchar_t_char32_t_compatible`` + Target supports ``wchar_t`` that is compatible with ``char32_t``. + +``comdat_group`` + Target uses comdat groups. + +``indirect_calls`` + Target supports indirect calls, i.e. calls where the target is not + constant. + +``lgccjit`` + Target supports -lgccjit, i.e. libgccjit.so can be linked into jit tests. + +``__OPTIMIZE__`` + Optimizations are enabled (``__OPTIMIZE__``) per the current + compiler flags. + +Local to tests in gcc.target/i386 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``3dnow`` + Target supports compiling ``3dnow`` instructions. + +``aes`` + Target supports compiling ``aes`` instructions. + +``fma4`` + Target supports compiling ``fma4`` instructions. + +``mfentry`` + Target supports the ``-mfentry`` option that alters the + position of profiling calls such that they precede the prologue. + +``ms_hook_prologue`` + Target supports attribute ``ms_hook_prologue``. + +``pclmul`` + Target supports compiling ``pclmul`` instructions. + +``sse3`` + Target supports compiling ``sse3`` instructions. + +``sse4`` + Target supports compiling ``sse4`` instructions. + +``sse4a`` + Target supports compiling ``sse4a`` instructions. + +``ssse3`` + Target supports compiling ``ssse3`` instructions. + +``vaes`` + Target supports compiling ``vaes`` instructions. + +``vpclmul`` + Target supports compiling ``vpclmul`` instructions. + +``xop`` + Target supports compiling ``xop`` instructions. + +Local to tests in gcc.test-framework +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``no`` + Always returns 0. + +``yes`` + Always returns 1. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/selecting-targets-to-which-a-test-applies.rst b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/selecting-targets-to-which-a-test-applies.rst new file mode 100644 index 00000000000..f30ea1257e2 --- /dev/null +++ b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/selecting-targets-to-which-a-test-applies.rst @@ -0,0 +1,106 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _selectors: + +Selecting targets to which a test applies +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Several test directives include :samp:`{selector}` s to limit the targets +for which a test is run or to declare that a test is expected to fail +on particular targets. + +A selector is: + +* one or more target triplets, possibly including wildcard characters; + use :samp:`*-*-*` to match any target + +* a single effective-target keyword (see :ref:`effective-target-keywords`) + +* a list of compiler options that should be included or excluded + (as described in more detail below) + +* a logical expression + +Depending on the context, the selector specifies whether a test is +skipped and reported as unsupported or is expected to fail. A context +that allows either :samp:`target` or :samp:`xfail` also allows +:samp:`{ target {selector1} xfail {selector2} }` +to skip the test for targets that don't match :samp:`{selector1}` and the +test to fail for targets that match :samp:`{selector2}`. + +A selector expression appears within curly braces and uses a single +logical operator: one of :samp:`!`, :samp:`&&`, or :samp:`||`. An +operand is one of the following: + +* another selector expression, in curly braces + +* an effective-target keyword, such as ``lp64`` + +* a single target triplet + +* a list of target triplets within quotes or curly braces + +* one of the following: + + :samp:`{ any-opts {opt1} ... {optn} }` + Each of :samp:`{opt1}` to :samp:`{optn}` is a space-separated list of option globs. + The selector expression evaluates to true if, for one of these strings, + every glob in the string matches an option that was passed to the compiler. + For example: + + .. code-block:: c++ + + { any-opts "-O3 -flto" "-O[2g]" } + + is true if any of the following are true: + + * :option:`-O2` was passed to the compiler + + * :option:`-Og` was passed to the compiler + + * both :option:`-O3` and :option:`-flto` were passed to the compiler + + This kind of selector can only be used within ``dg-final`` directives. + Use ``dg-skip-if``, ``dg-xfail-if`` or ``dg-xfail-run-if`` to + skip whole tests based on options, or to mark them as expected to fail + with certain options. + + :samp:`{ no-opts {opt1} ... {optn} }` + As for ``any-opts`` above, each of :samp:`{opt1}` to :samp:`{optn}` is a + space-separated list of option globs. The selector expression + evaluates to true if, for all of these strings, there is at least + one glob that does not match an option that was passed to the compiler. + It is shorthand for: + + .. code-block:: c++ + + { ! { any-opts opt1 ... optn } } + + For example: + + .. code-block:: c++ + + { no-opts "-O3 -flto" "-O[2g]" } + + is true if all of the following are true: + + * :option:`-O2` was not passed to the compiler + + * :option:`-Og` was not passed to the compiler + + * at least one of :option:`-O3` or :option:`-flto` was not passed to the compiler + + Like ``any-opts``, this kind of selector can only be used within + ``dg-final`` directives. + +Here are some examples of full target selectors: + +.. code-block:: c++ + + { target { ! "hppa*-*-* ia64*-*-*" } } + { target { powerpc*-*-* && lp64 } } + { xfail { lp64 || vect_no_align } } + { xfail { aarch64*-*-* && { any-opts "-O2" } } } \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/syntax-and-descriptions-of-test-directives.rst b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/syntax-and-descriptions-of-test-directives.rst new file mode 100644 index 00000000000..b630de0579f --- /dev/null +++ b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/syntax-and-descriptions-of-test-directives.rst @@ -0,0 +1,311 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _directives: + +Syntax and Descriptions of test directives +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Test directives appear within comments in a test source file and begin +with ``dg-``. Some of these are defined within DejaGnu and others +are local to the GCC testsuite. + +The order in which test directives appear in a test can be important: +directives local to GCC sometimes override information used by the +DejaGnu directives, which know nothing about the GCC directives, so the +DejaGnu directives must precede GCC directives. + +Several test directives include selectors (see :ref:`selectors`) +which are usually preceded by the keyword ``target`` or ``xfail``. + +Specify how to build the test +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`{ dg-do {do-what-keyword} [{ target/xfail {selector} }] }` + :samp:`{do-what-keyword}` specifies how the test is compiled and whether + it is executed. It is one of: + + ``preprocess`` + Compile with :option:`-E` to run only the preprocessor. + + ``compile`` + Compile with :option:`-S` to produce an assembly code file. + + ``assemble`` + Compile with :option:`-c` to produce a relocatable object file. + + ``link`` + Compile, assemble, and link to produce an executable file. + + ``run`` + Produce and run an executable file, which is expected to return + an exit code of 0. + + The default is ``compile``. That can be overridden for a set of + tests by redefining ``dg-do-what-default`` within the ``.exp`` + file for those tests. + + If the directive includes the optional :samp:`{ target {selector} }` + then the test is skipped unless the target system matches the + :samp:`{selector}`. + + If :samp:`{do-what-keyword}` is ``run`` and the directive includes + the optional :samp:`{ xfail {selector} }` and the selector is met + then the test is expected to fail. The ``xfail`` clause is ignored + for other values of :samp:`{do-what-keyword}` ; those tests can use + directive ``dg-xfail-if``. + +Specify additional compiler options +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`{ dg-options {options} [{ target {selector} }] }` + This DejaGnu directive provides a list of compiler options, to be used + if the target system matches :samp:`{selector}`, that replace the default + options used for this set of tests. + +:samp:`{ dg-add-options {feature} ... }` + Add any compiler options that are needed to access certain features. + This directive does nothing on targets that enable the features by + default, or that don't provide them at all. It must come after + all ``dg-options`` directives. + For supported values of :samp:`{feature}` see :ref:`add-options`. + +:samp:`{ dg-additional-options {options} [{ target {selector} }] }` + This directive provides a list of compiler options, to be used + if the target system matches :samp:`{selector}`, that are added to the default + options used for this set of tests. + +Modify the test timeout value +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The normal timeout limit, in seconds, is found by searching the +following in order: + +* the value defined by an earlier ``dg-timeout`` directive in + the test + +* variable :samp:`{tool_timeout}` defined by the set of tests + +* :samp:`{gcc}`, :samp:`{timeout}` set in the target board + +* 300 + +:samp:`{ dg-timeout {n} [{target {selector} }] }` + Set the time limit for the compilation and for the execution of the test + to the specified number of seconds. + +:samp:`{ dg-timeout-factor {x} [{ target {selector} }] }` + Multiply the normal time limit for compilation and execution of the test + by the specified floating-point factor. + +Skip a test for some targets +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`{ dg-skip-if {comment} { {selector} } [{ {include-opts} } [{ {exclude-opts} }]] }` + Arguments :samp:`{include-opts}` and :samp:`{exclude-opts}` are lists in which + each element is a string of zero or more GCC options. + Skip the test if all of the following conditions are met: + + * the test system is included in :samp:`{selector}` + + * for at least one of the option strings in :samp:`{include-opts}`, + every option from that string is in the set of options with which + the test would be compiled; use :samp:`"*"` for an :samp:`{include-opts}` list + that matches any options; that is the default if :samp:`{include-opts}` is + not specified + + * for each of the option strings in :samp:`{exclude-opts}`, at least one + option from that string is not in the set of options with which the test + would be compiled; use :samp:`""` for an empty :samp:`{exclude-opts}` list; + that is the default if :samp:`{exclude-opts}` is not specified + + For example, to skip a test if option ``-Os`` is present: + + .. code-block:: c++ + + /* { dg-skip-if "" { *-*-* } { "-Os" } { "" } } */ + + To skip a test if both options ``-O2`` and ``-g`` are present: + + .. code-block:: c++ + + /* { dg-skip-if "" { *-*-* } { "-O2 -g" } { "" } } */ + + To skip a test if either ``-O2`` or ``-O3`` is present: + + .. code-block:: c++ + + /* { dg-skip-if "" { *-*-* } { "-O2" "-O3" } { "" } } */ + + To skip a test unless option ``-Os`` is present: + + .. code-block:: c++ + + /* { dg-skip-if "" { *-*-* } { "*" } { "-Os" } } */ + + To skip a test if either ``-O2`` or ``-O3`` is used with ``-g`` + but not if ``-fpic`` is also present: + + .. code-block:: c++ + + /* { dg-skip-if "" { *-*-* } { "-O2 -g" "-O3 -g" } { "-fpic" } } */ + +:samp:`{ dg-require-effective-target {keyword} [{ target {selector} }] }` + Skip the test if the test target, including current multilib flags, + is not covered by the effective-target keyword. + If the directive includes the optional :samp:`{ {selector} }` + then the effective-target test is only performed if the target system + matches the :samp:`{selector}`. + This directive must appear after any ``dg-do`` directive in the test + and before any ``dg-additional-sources`` directive. + See :ref:`effective-target-keywords`. + +:samp:`{ dg-require-{support} args }` + Skip the test if the target does not provide the required support. + These directives must appear after any ``dg-do`` directive in the test + and before any ``dg-additional-sources`` directive. + They require at least one argument, which can be an empty string if the + specific procedure does not examine the argument. + See :ref:`require-support`, for a complete list of these directives. + +Expect a test to fail for some targets +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`{ dg-xfail-if {comment} { {selector} } [{ {include-opts} } [{ {exclude-opts} }]] }` + Expect the test to fail if the conditions (which are the same as for + ``dg-skip-if``) are met. This does not affect the execute step. + +:samp:`{ dg-xfail-run-if {comment} { {selector} } [{ {include-opts} } [{ {exclude-opts} }]] }` + Expect the execute step of a test to fail if the conditions (which are + the same as for ``dg-skip-if``) are met. + +Expect the compiler to crash +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`{ dg-ice {comment} [{ {selector} } [{ {include-opts} } [{ {exclude-opts} }]]] }` + Expect the compiler to crash with an internal compiler error and return + a nonzero exit status if the conditions (which are the same as for + ``dg-skip-if``) are met. Used for tests that test bugs that have not been + fixed yet. + +Expect the test executable to fail +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`{ dg-shouldfail {comment} [{ {selector} } [{ {include-opts} } [{ {exclude-opts} }]]] }` + Expect the test executable to return a nonzero exit status if the + conditions (which are the same as for ``dg-skip-if``) are met. + +Verify compiler messages +~~~~~~~~~~~~~~~~~~~~~~~~ + +Where :samp:`{line}` is an accepted argument for these commands, a value of :samp:`0` +can be used if there is no line associated with the message. + +:samp:`{ dg-error {regexp} [{comment} [{ target/xfail {selector} } [{line}] ]] }` + This DejaGnu directive appears on a source line that is expected to get + an error message, or else specifies the source line associated with the + message. If there is no message for that line or if the text of that + message is not matched by :samp:`{regexp}` then the check fails and + :samp:`{comment}` is included in the ``FAIL`` message. The check does + not look for the string :samp:`error` unless it is part of :samp:`{regexp}`. + +:samp:`{ dg-warning {regexp} [{comment} [{ target/xfail {selector} } [{line}] ]] }` + This DejaGnu directive appears on a source line that is expected to get + a warning message, or else specifies the source line associated with the + message. If there is no message for that line or if the text of that + message is not matched by :samp:`{regexp}` then the check fails and + :samp:`{comment}` is included in the ``FAIL`` message. The check does + not look for the string :samp:`warning` unless it is part of :samp:`{regexp}`. + +:samp:`{ dg-message {regexp} [{comment} [{ target/xfail {selector} } [{line}] ]] }` + The line is expected to get a message other than an error or warning. + If there is no message for that line or if the text of that message is + not matched by :samp:`{regexp}` then the check fails and :samp:`{comment}` is + included in the ``FAIL`` message. + +:samp:`{ dg-note {regexp} [{comment} [{ target/xfail {selector} } [{line}] ]] }` + The line is expected to get a :samp:`note` message. + If there is no message for that line or if the text of that message is + not matched by :samp:`{regexp}` then the check fails and :samp:`{comment}` is + included in the ``FAIL`` message. + + By default, any *excess* :samp:`note` messages are pruned, meaning + their appearance doesn't trigger *excess errors*. + However, if :samp:`dg-note` is used at least once in a testcase, + they're not pruned and instead must *all* be handled explicitly. + Thus, if looking for just single instances of messages with + :samp:`note:` prefixes without caring for all of them, use + :samp:`dg-message "note: [...]"` instead of :samp:`dg-note`, or use + :samp:`dg-note` together with :samp:`dg-prune-output "note: "`. + +:samp:`{ dg-bogus {regexp} [{comment} [{ target/xfail {selector} } [{line}] ]] }` + This DejaGnu directive appears on a source line that should not get a + message matching :samp:`{regexp}`, or else specifies the source line + associated with the bogus message. It is usually used with :samp:`xfail` + to indicate that the message is a known problem for a particular set of + targets. + +:samp:`{ dg-line {linenumvar} }` + This DejaGnu directive sets the variable :samp:`{linenumvar}` to the line number of + the source line. The variable :samp:`{linenumvar}` can then be used in subsequent + ``dg-error``, ``dg-warning``, ``dg-message``, ``dg-note`` + and ``dg-bogus`` + directives. For example: + + .. code-block:: c++ + + int a; /* { dg-line first_def_a } */ + float a; /* { dg-error "conflicting types of" } */ + /* { dg-message "previous declaration of" "" { target *-*-* } first_def_a } */ + +:samp:`{ dg-excess-errors {comment} [{ target/xfail {selector} }] }` + This DejaGnu directive indicates that the test is expected to fail due + to compiler messages that are not handled by :samp:`dg-error`, + :samp:`dg-warning`, ``dg-message``, :samp:`dg-note` or + :samp:`dg-bogus`. + For this directive :samp:`xfail` + has the same effect as :samp:`target`. + +:samp:`{ dg-prune-output {regexp} }` + Prune messages matching :samp:`{regexp}` from the test output. + +Verify output of the test executable +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`{ dg-output {regexp} [{ target/xfail {selector} }] }` + This DejaGnu directive compares :samp:`{regexp}` to the combined output + that the test executable writes to :samp:`stdout` and :samp:`stderr`. + +Specify environment variables for a test +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`{ dg-set-compiler-env-var {var_name} "{var_value}" }` + Specify that the environment variable :samp:`{var_name}` needs to be set + to :samp:`{var_value}` before invoking the compiler on the test file. + +:samp:`{ dg-set-target-env-var {var_name} "{var_value}" }` + Specify that the environment variable :samp:`{var_name}` needs to be set + to :samp:`{var_value}` before execution of the program created by the test. + +Specify additional files for a test +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`{ dg-additional-files "{filelist}" }` + Specify additional files, other than source files, that must be copied + to the system where the compiler runs. + +:samp:`{ dg-additional-sources "{filelist}" }` + Specify additional source files to appear in the compile line + following the main test file. + +Add checks at the end of a test +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:samp:`{ dg-final { {local-directive} } }` + This DejaGnu directive is placed within a comment anywhere in the + source file and is processed after the test has been compiled and run. + Multiple :samp:`dg-final` commands are processed in the order in which + they appear in the source file. See :ref:`final-actions`, for a list + of directives that can be used within ``dg-final``. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/variants-of-dg-require-support.rst b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/variants-of-dg-require-support.rst new file mode 100644 index 00000000000..6b5122c2265 --- /dev/null +++ b/gcc/doc/gccint/testsuites/directives-used-within-dejagnu-tests/variants-of-dg-require-support.rst @@ -0,0 +1,83 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _require-support: + +Variants of dg-require-support +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A few of the ``dg-require`` directives take arguments. + +:samp:`dg-require-iconv {codeset}` + Skip the test if the target does not support iconv. :samp:`{codeset}` is + the codeset to convert to. + +:samp:`dg-require-profiling {profopt}` + Skip the test if the target does not support profiling with option + :samp:`{profopt}`. + +:samp:`dg-require-stack-check {check}` + Skip the test if the target does not support the ``-fstack-check`` + option. If :samp:`{check}` is ``""``, support for ``-fstack-check`` + is checked, for ``-fstack-check=("check")`` otherwise. + +:samp:`dg-require-stack-size {size}` + Skip the test if the target does not support a stack size of :samp:`{size}`. + +:samp:`dg-require-visibility {vis}` + Skip the test if the target does not support the ``visibility`` attribute. + If :samp:`{vis}` is ``""``, support for ``visibility("hidden")`` is + checked, for ``visibility("vis")`` otherwise. + + The original ``dg-require`` directives were defined before there + was support for effective-target keywords. The directives that do not + take arguments could be replaced with effective-target keywords. + +``dg-require-alias ""`` + Skip the test if the target does not support the :samp:`alias` attribute. + +``dg-require-ascii-locale ""`` + Skip the test if the host does not support an ASCII locale. + +``dg-require-compat-dfp ""`` + Skip this test unless both compilers in a :samp:`compat` testsuite + support decimal floating point. + +``dg-require-cxa-atexit ""`` + Skip the test if the target does not support ``__cxa_atexit``. + This is equivalent to ``dg-require-effective-target cxa_atexit``. + +``dg-require-dll ""`` + Skip the test if the target does not support DLL attributes. + +``dg-require-dot ""`` + Skip the test if the host does not have :command:`dot`. + +``dg-require-fork ""`` + Skip the test if the target does not support ``fork``. + +``dg-require-gc-sections ""`` + Skip the test if the target's linker does not support the + ``--gc-sections`` flags. + This is equivalent to ``dg-require-effective-target gc-sections``. + +``dg-require-host-local ""`` + Skip the test if the host is remote, rather than the same as the build + system. Some tests are incompatible with DejaGnu's handling of remote + hosts, which involves copying the source file to the host and compiling + it with a relative path and " ``-o a.out`` ". + +``dg-require-mkfifo ""`` + Skip the test if the target does not support ``mkfifo``. + +``dg-require-named-sections ""`` + Skip the test is the target does not support named sections. + This is equivalent to ``dg-require-effective-target named_sections``. + +``dg-require-weak ""`` + Skip the test if the target does not support weak symbols. + +``dg-require-weak-override ""`` + Skip the test if the target does not support overriding weak symbols. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/idioms-used-in-testsuite-code.rst b/gcc/doc/gccint/testsuites/idioms-used-in-testsuite-code.rst new file mode 100644 index 00000000000..8acbb92ebc7 --- /dev/null +++ b/gcc/doc/gccint/testsuites/idioms-used-in-testsuite-code.rst @@ -0,0 +1,84 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _test-idioms: + +Idioms Used in Testsuite Code +***************************** + +In general, C testcases have a trailing :samp:`-{n}.c`, starting +with :samp:`-1.c`, in case other testcases with similar names are added +later. If the test is a test of some well-defined feature, it should +have a name referring to that feature such as +:samp:`{feature}-1.c`. If it does not test a well-defined feature +but just happens to exercise a bug somewhere in the compiler, and a +bug report has been filed for this bug in the GCC bug database, +:samp:`pr{bug-number}-1.c` is the appropriate form of name. +Otherwise (for miscellaneous bugs not filed in the GCC bug database), +and previously more generally, test cases are named after the date on +which they were added. This allows people to tell at a glance whether +a test failure is because of a recently found bug that has not yet +been fixed, or whether it may be a regression, but does not give any +other information about the bug or where discussion of it may be +found. Some other language testsuites follow similar conventions. + +In the :samp:`gcc.dg` testsuite, it is often necessary to test that an +error is indeed a hard error and not just a warning---for example, +where it is a constraint violation in the C standard, which must +become an error with :option:`-pedantic-errors`. The following idiom, +where the first line shown is line :samp:`{line}` of the file and the line +that generates the error, is used for this: + +.. code-block:: c++ + + /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "regexp" "message" { target *-*-* } line } */ + +It may be necessary to check that an expression is an integer constant +expression and has a certain value. To check that ``E`` has +value ``V``, an idiom similar to the following is used: + +.. code-block:: c++ + + char x[((E) == (V) ? 1 : -1)]; + +In :samp:`gcc.dg` tests, ``__typeof__`` is sometimes used to make +assertions about the types of expressions. See, for example, +:samp:`gcc.dg/c99-condexpr-1.c`. The more subtle uses depend on the +exact rules for the types of conditional expressions in the C +standard; see, for example, :samp:`gcc.dg/c99-intconst-1.c`. + +It is useful to be able to test that optimizations are being made +properly. This cannot be done in all cases, but it can be done where +the optimization will lead to code being optimized away (for example, +where flow analysis or alias analysis should show that certain code +cannot be called) or to functions not being called because they have +been expanded as built-in functions. Such tests go in +:samp:`gcc.c-torture/execute`. Where code should be optimized away, a +call to a nonexistent function such as ``link_failure ()`` may be +inserted; a definition + +.. code-block:: c++ + + #ifndef __OPTIMIZE__ + void + link_failure (void) + { + abort (); + } + #endif + +will also be needed so that linking still succeeds when the test is +run without optimization. When all calls to a built-in function +should have been optimized and no calls to the non-built-in version of +the function should remain, that function may be defined as +``static`` to call ``abort ()`` (although redeclaring a function +as static may not work on all targets). + +All testcases must be portable. Target-specific testcases must have +appropriate code to avoid causing failures on unsupported systems; +unfortunately, the mechanisms for this differ by directory. + +.. todo:: discuss non-C testsuites here \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/support-for-testing-binary-compatibility.rst b/gcc/doc/gccint/testsuites/support-for-testing-binary-compatibility.rst new file mode 100644 index 00000000000..cc03aa8b0d7 --- /dev/null +++ b/gcc/doc/gccint/testsuites/support-for-testing-binary-compatibility.rst @@ -0,0 +1,109 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _compat-testing: + +Support for testing binary compatibility +**************************************** + +The file :samp:`compat.exp` provides language-independent support for +binary compatibility testing. It supports testing interoperability of +two compilers that follow the same ABI, or of multiple sets of +compiler options that should not affect binary compatibility. It is +intended to be used for testsuites that complement ABI testsuites. + +A test supported by this framework has three parts, each in a +separate source file: a main program and two pieces that interact +with each other to split up the functionality being tested. + +:samp:`{testname}_main.{suffix}` + Contains the main program, which calls a function in file + :samp:`{testname}_x.{suffix}`. + +:samp:`{testname}_x.{suffix}` + Contains at least one call to a function in + :samp:`{testname}_y.{suffix}`. + +:samp:`{testname}_y.{suffix}` + Shares data with, or gets arguments from, + :samp:`{testname}_x.{suffix}`. + +Within each test, the main program and one functional piece are +compiled by the GCC under test. The other piece can be compiled by +an alternate compiler. If no alternate compiler is specified, +then all three source files are all compiled by the GCC under test. +You can specify pairs of sets of compiler options. The first element +of such a pair specifies options used with the GCC under test, and the +second element of the pair specifies options used with the alternate +compiler. Each test is compiled with each pair of options. + +:samp:`compat.exp` defines default pairs of compiler options. +These can be overridden by defining the environment variable +:envvar:`COMPAT_OPTIONS` as: + +.. code-block:: + + COMPAT_OPTIONS="[list [list {tst1} {alt1}] + ...[list {tstn} {altn}]]" + +where :samp:`{tsti}` and :samp:`{alti}` are lists of options, with :samp:`{tsti}` +used by the compiler under test and :samp:`{alti}` used by the alternate +compiler. For example, with +``[list [list {-g -O0} {-O3}] [list {-fpic} {-fPIC -O2}]]``, +the test is first built with :option:`-g -O0` by the compiler under +test and with :option:`-O3` by the alternate compiler. The test is +built a second time using :option:`-fpic` by the compiler under test +and :option:`-fPIC -O2` by the alternate compiler. + +An alternate compiler is specified by defining an environment +variable to be the full pathname of an installed compiler; for C +define :envvar:`ALT_CC_UNDER_TEST`, and for C++ define +:envvar:`ALT_CXX_UNDER_TEST`. These will be written to the +:samp:`site.exp` file used by DejaGnu. The default is to build each +test with the compiler under test using the first of each pair of +compiler options from :envvar:`COMPAT_OPTIONS`. When +:envvar:`ALT_CC_UNDER_TEST` or +:envvar:`ALT_CXX_UNDER_TEST` is ``same``, each test is built using +the compiler under test but with combinations of the options from +:envvar:`COMPAT_OPTIONS`. + +To run only the C++ compatibility suite using the compiler under test +and another version of GCC using specific compiler options, do the +following from :samp:`{objdir}/gcc`: + +.. code-block:: + + rm site.exp + make -k \ + ALT_CXX_UNDER_TEST=${alt_prefix}/bin/g++ \ + COMPAT_OPTIONS="lists as shown above" \ + check-c++ \ + RUNTESTFLAGS="compat.exp" + +A test that fails when the source files are compiled with different +compilers, but passes when the files are compiled with the same +compiler, demonstrates incompatibility of the generated code or +runtime support. A test that fails for the alternate compiler but +passes for the compiler under test probably tests for a bug that was +fixed in the compiler under test but is present in the alternate +compiler. + +The binary compatibility tests support a small number of test framework +commands that appear within comments in a test file. + +``dg-require-*`` + These commands can be used in :samp:`{testname}_main.{suffix}` + to skip the test if specific support is not available on the target. + +``dg-options`` + The specified options are used for compiling this particular source + file, appended to the options from :envvar:`COMPAT_OPTIONS`. When this + command appears in :samp:`{testname}_main.{suffix}` the options + are also used to link the test program. + +``dg-xfail-if`` + This command can be used in a secondary source file to specify that + compilation is expected to fail for particular options on particular + targets. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/support-for-testing-gcov.rst b/gcc/doc/gccint/testsuites/support-for-testing-gcov.rst new file mode 100644 index 00000000000..f6780983007 --- /dev/null +++ b/gcc/doc/gccint/testsuites/support-for-testing-gcov.rst @@ -0,0 +1,72 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gcov-testing: + +Support for testing gcov +************************ + +Language-independent support for testing :command:`gcov`, and for checking +that branch profiling produces expected values, is provided by the +expect file :samp:`lib/gcov.exp`. :command:`gcov` tests also rely on procedures +in :samp:`lib/gcc-dg.exp` to compile and run the test program. A typical +:command:`gcov` test contains the following DejaGnu commands within comments: + +.. code-block:: c++ + + { dg-options "--coverage" } + { dg-do run { target native } } + { dg-final { run-gcov sourcefile } } + +Checks of :command:`gcov` output can include line counts, branch percentages, +and call return percentages. All of these checks are requested via +commands that appear in comments in the test's source file. +Commands to check line counts are processed by default. +Commands to check branch percentages and call return percentages are +processed if the :command:`run-gcov` command has arguments ``branches`` +or ``calls``, respectively. For example, the following specifies +checking both, as well as passing :option:`-b` to :command:`gcov`: + +.. code-block:: c++ + + { dg-final { run-gcov branches calls { -b sourcefile } } } + +A line count command appears within a comment on the source line +that is expected to get the specified count and has the form +``count(cnt)``. A test should only check line counts for +lines that will get the same count for any architecture. + +Commands to check branch percentages (``branch``) and call +return percentages (``returns``) are very similar to each other. +A beginning command appears on or before the first of a range of +lines that will report the percentage, and the ending command +follows that range of lines. The beginning command can include a +list of percentages, all of which are expected to be found within +the range. A range is terminated by the next command of the same +kind. A command ``branch(end)`` or ``returns(end)`` marks +the end of a range without starting a new one. For example: + +.. code-block:: c++ + + if (i > 10 && j > i && j < 20) /* branch(27 50 75) */ + /* branch(end) */ + foo (i, j); + +For a call return percentage, the value specified is the +percentage of calls reported to return. For a branch percentage, +the value is either the expected percentage or 100 minus that +value, since the direction of a branch can differ depending on the +target or the optimization level. + +Not all branches and calls need to be checked. A test should not +check for branches that might be optimized away or replaced with +predicated instructions. Don't check for calls inserted by the +compiler or ones that might be inlined or optimized away. + +A single test can check for combinations of line counts, branch +percentages, and call return percentages. The command to check a +line count must appear on the line that will report that count, but +commands to check branch percentages and call return percentages can +bracket the lines that report them. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/support-for-testing-gimple-passes.rst b/gcc/doc/gccint/testsuites/support-for-testing-gimple-passes.rst new file mode 100644 index 00000000000..e2413a190eb --- /dev/null +++ b/gcc/doc/gccint/testsuites/support-for-testing-gimple-passes.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gimple-tests: + +Support for testing GIMPLE passes +********************************* + +As of gcc 7, C functions can be tagged with ``__GIMPLE`` to indicate +that the function body will be GIMPLE, rather than C. The compiler requires +the option :option:`-fgimple` to enable this functionality. For example: + +.. code-block:: c++ + + /* { dg-do compile } */ + /* { dg-options "-O -fgimple" } */ + + void __GIMPLE (startwith ("dse2")) foo () + { + int a; + + bb_2: + if (a > 4) + goto bb_3; + else + goto bb_4; + + bb_3: + a_2 = 10; + goto bb_5; + + bb_4: + a_3 = 20; + + bb_5: + a_1 = __PHI (bb_3: a_2, bb_4: a_3); + a_4 = a_1 + 4; + + return; + } + +The ``startwith`` argument indicates at which pass to begin. + +Use the dump modifier ``-gimple`` (e.g. :option:`-fdump-tree-all-gimple`) +to make tree dumps more closely follow the format accepted by the GIMPLE +parser. + +Example DejaGnu tests of GIMPLE can be seen in the source tree at +:samp:`gcc/testsuite/gcc.dg/gimplefe-*.c`. + +The ``__GIMPLE`` parser is integrated with the C tokenizer and +preprocessor, so it should be possible to use macros to build out +test coverage. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/support-for-testing-link-time-optimizations.rst b/gcc/doc/gccint/testsuites/support-for-testing-link-time-optimizations.rst new file mode 100644 index 00000000000..e295d94cd6f --- /dev/null +++ b/gcc/doc/gccint/testsuites/support-for-testing-link-time-optimizations.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _lto-testing: + +Support for testing link-time optimizations +******************************************* + +Tests for link-time optimizations usually require multiple source files +that are compiled separately, perhaps with different sets of options. +There are several special-purpose test directives used for these tests. + +:samp:`{ dg-lto-do {do-what-keyword} }` + :samp:`{do-what-keyword}` specifies how the test is compiled and whether + it is executed. It is one of: + + ``assemble`` + Compile with :option:`-c` to produce a relocatable object file. + + ``link`` + Compile, assemble, and link to produce an executable file. + + ``run`` + Produce and run an executable file, which is expected to return + an exit code of 0. + + The default is ``assemble``. That can be overridden for a set of + tests by redefining ``dg-do-what-default`` within the ``.exp`` + file for those tests. + + Unlike ``dg-do``, ``dg-lto-do`` does not support an optional + :samp:`target` or :samp:`xfail` list. Use ``dg-skip-if``, + ``dg-xfail-if``, or ``dg-xfail-run-if``. + +:samp:`{ dg-lto-options { { {options} } [{ {options} }] } [{ target {selector} }]}` + This directive provides a list of one or more sets of compiler options + to override :samp:`{LTO_OPTIONS}`. Each test will be compiled and run with + each of these sets of options. + +:samp:`{ dg-extra-ld-options {options} [{ target {selector} }]}` + This directive adds :samp:`{options}` to the linker options used. + +:samp:`{ dg-suppress-ld-options {options} [{ target {selector} }]}` + This directive removes :samp:`{options}` from the set of linker options used. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/support-for-testing-profile-directed-optimizations.rst b/gcc/doc/gccint/testsuites/support-for-testing-profile-directed-optimizations.rst new file mode 100644 index 00000000000..10190ad9cac --- /dev/null +++ b/gcc/doc/gccint/testsuites/support-for-testing-profile-directed-optimizations.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _profopt-testing: + +Support for testing profile-directed optimizations +************************************************** + +The file :samp:`profopt.exp` provides language-independent support for +checking correct execution of a test built with profile-directed +optimization. This testing requires that a test program be built and +executed twice. The first time it is compiled to generate profile +data, and the second time it is compiled to use the data that was +generated during the first execution. The second execution is to +verify that the test produces the expected results. + +To check that the optimization actually generated better code, a +test can be built and run a third time with normal optimizations to +verify that the performance is better with the profile-directed +optimizations. :samp:`profopt.exp` has the beginnings of this kind +of support. + +:samp:`profopt.exp` provides generic support for profile-directed +optimizations. Each set of tests that uses it provides information +about a specific optimization: + +``tool`` + tool being tested, e.g., :command:`gcc` + +``profile_option`` + options used to generate profile data + +``feedback_option`` + options used to optimize using that profile data + +``prof_ext`` + suffix of profile data files + +``PROFOPT_OPTIONS`` + list of options with which to run each test, similar to the lists for + torture tests + +:samp:`{ dg-final-generate { {local-directive} } }` + This directive is similar to ``dg-final``, but the + :samp:`{local-directive}` is run after the generation of profile data. + +:samp:`{ dg-final-use { {local-directive} } }` + The :samp:`{local-directive}` is run after the profile data have been + used. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/support-for-testing-rtl-passes.rst b/gcc/doc/gccint/testsuites/support-for-testing-rtl-passes.rst new file mode 100644 index 00000000000..ed49aeefb40 --- /dev/null +++ b/gcc/doc/gccint/testsuites/support-for-testing-rtl-passes.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _rtl-tests: + +Support for testing RTL passes +****************************** + +As of gcc 7, C functions can be tagged with ``__RTL`` to indicate that the +function body will be RTL, rather than C. For example: + +.. code-block:: c++ + + double __RTL (startwith ("ira")) test (struct foo *f, const struct bar *b) + { + (function "test" + [...snip; various directives go in here...] + ) ;; function "test" + } + +The ``startwith`` argument indicates at which pass to begin. + +The parser expects the RTL body to be in the format emitted by this +dumping function: + +.. code-block:: c++ + + DEBUG_FUNCTION void + print_rtx_function (FILE *outfile, function *fn, bool compact); + +when "compact" is true. So you can capture RTL in the correct format +from the debugger using: + +.. code-block:: c++ + + (gdb) print_rtx_function (stderr, cfun, true); + +and copy and paste the output into the body of the C function. + +Example DejaGnu tests of RTL can be seen in the source tree under +:samp:`gcc/testsuite/gcc.dg/rtl`. + +The ``__RTL`` parser is not integrated with the C tokenizer or +preprocessor, and works simply by reading the relevant lines within +the braces. In particular, the RTL body must be on separate lines from +the enclosing braces, and the preprocessor is not usable within it. \ No newline at end of file diff --git a/gcc/doc/gccint/testsuites/support-for-torture-testing-using-multiple-options.rst b/gcc/doc/gccint/testsuites/support-for-torture-testing-using-multiple-options.rst new file mode 100644 index 00000000000..76f1dc8d955 --- /dev/null +++ b/gcc/doc/gccint/testsuites/support-for-torture-testing-using-multiple-options.rst @@ -0,0 +1,52 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _torture-tests: + +Support for torture testing using multiple options +************************************************** + +Throughout the compiler testsuite there are several directories whose +tests are run multiple times, each with a different set of options. +These are known as torture tests. +:samp:`lib/torture-options.exp` defines procedures to +set up these lists: + +``torture-init`` + Initialize use of torture lists. + +``set-torture-options`` + Set lists of torture options to use for tests with and without loops. + Optionally combine a set of torture options with a set of other + options, as is done with Objective-C runtime options. + +``torture-finish`` + Finalize use of torture lists. + +The :samp:`.exp` file for a set of tests that use torture options must +include calls to these three procedures if: + +* It calls ``gcc-dg-runtest`` and overrides :samp:`{DG_TORTURE_OPTIONS}`. + +* It calls :samp:`{${tool}}` ``-torture`` or + :samp:`{${tool}}` ``-torture-execute``, where :samp:`{tool}` is ``c``, + ``fortran``, or ``objc``. + +* It calls ``dg-pch``. + +It is not necessary for a :samp:`.exp` file that calls ``gcc-dg-runtest`` +to call the torture procedures if the tests should use the list in +:samp:`{DG_TORTURE_OPTIONS}` defined in :samp:`gcc-dg.exp`. + +Most uses of torture options can override the default lists by defining +:samp:`{TORTURE_OPTIONS}` or add to the default list by defining +:samp:`{ADDITIONAL_TORTURE_OPTIONS}`. Define these in a :samp:`.dejagnurc` +file or add them to the :samp:`site.exp` file; for example + +.. code-block:: c++ + + set ADDITIONAL_TORTURE_OPTIONS [list \ + { -O2 -ftree-loop-linear } \ + { -O2 -fpeel-loops } ] \ No newline at end of file diff --git a/gcc/doc/gccint/the-gcc-low-level-runtime-library.rst b/gcc/doc/gccint/the-gcc-low-level-runtime-library.rst new file mode 100644 index 00000000000..f986c19445f --- /dev/null +++ b/gcc/doc/gccint/the-gcc-low-level-runtime-library.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + + Contributed by Aldy Hernandez + +.. _libgcc: + +The GCC low-level runtime library +--------------------------------- + +GCC provides a low-level runtime library, :samp:`libgcc.a` or +:samp:`libgcc_s.so.1` on some platforms. GCC generates calls to +routines in this library automatically, whenever it needs to perform +some operation that is too complicated to emit inline code for. + +Most of the routines in ``libgcc`` handle arithmetic operations +that the target processor cannot perform directly. This includes +integer multiply and divide on some machines, and all floating-point +and fixed-point operations on other machines. ``libgcc`` also includes +routines for exception handling, and a handful of miscellaneous operations. + +Some of these routines can be defined in mostly machine-independent C. +Others must be hand-written in assembly language for each processor +that needs them. + +GCC will also generate calls to C library routines, such as +``memcpy`` and ``memset``, in some cases. The set of routines +that GCC may possibly use is documented in :ref:`gcc:other-builtins`. + +These routines take arguments and return values of a specific machine +mode, not a specific C type. See :ref:`machine-modes`, for an explanation +of this concept. For illustrative purposes, in this chapter the +floating point type ``float`` is assumed to correspond to ``SFmode`` ; +``double`` to ``DFmode`` ; and ``long double`` to both +``TFmode`` and ``XFmode``. Similarly, the integer types ``int`` +and ``unsigned int`` correspond to ``SImode`` ; ``long`` and +``unsigned long`` to ``DImode`` ; and ``long long`` and +``unsigned long long`` to ``TImode``. + +.. toctree:: + :maxdepth: 2 + + the-gcc-low-level-runtime-library/routines-for-integer-arithmetic + the-gcc-low-level-runtime-library/routines-for-floating-point-emulation + the-gcc-low-level-runtime-library/routines-for-decimal-floating-point-emulation + the-gcc-low-level-runtime-library/routines-for-fixed-point-fractional-emulation + the-gcc-low-level-runtime-library/language-independent-routines-for-exception-handling + the-gcc-low-level-runtime-library/miscellaneous-runtime-library-routines \ No newline at end of file diff --git a/gcc/doc/gccint/the-gcc-low-level-runtime-library/language-independent-routines-for-exception-handling.rst b/gcc/doc/gccint/the-gcc-low-level-runtime-library/language-independent-routines-for-exception-handling.rst new file mode 100644 index 00000000000..ceb891750c6 --- /dev/null +++ b/gcc/doc/gccint/the-gcc-low-level-runtime-library/language-independent-routines-for-exception-handling.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _exception-handling-routines: + +Language-independent routines for exception handling +**************************************************** + +document me! + +.. code-block:: c++ + + _Unwind_DeleteException + _Unwind_Find_FDE + _Unwind_ForcedUnwind + _Unwind_GetGR + _Unwind_GetIP + _Unwind_GetLanguageSpecificData + _Unwind_GetRegionStart + _Unwind_GetTextRelBase + _Unwind_GetDataRelBase + _Unwind_RaiseException + _Unwind_Resume + _Unwind_SetGR + _Unwind_SetIP + _Unwind_FindEnclosingFunction + _Unwind_SjLj_Register + _Unwind_SjLj_Unregister + _Unwind_SjLj_RaiseException + _Unwind_SjLj_ForcedUnwind + _Unwind_SjLj_Resume + __deregister_frame + __deregister_frame_info + __deregister_frame_info_bases + __register_frame + __register_frame_info + __register_frame_info_bases + __register_frame_info_table + __register_frame_info_table_bases + __register_frame_table \ No newline at end of file diff --git a/gcc/doc/gccint/the-gcc-low-level-runtime-library/miscellaneous-runtime-library-routines.rst b/gcc/doc/gccint/the-gcc-low-level-runtime-library/miscellaneous-runtime-library-routines.rst new file mode 100644 index 00000000000..5ebfe54a0a5 --- /dev/null +++ b/gcc/doc/gccint/the-gcc-low-level-runtime-library/miscellaneous-runtime-library-routines.rst @@ -0,0 +1,59 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _miscellaneous-routines: + +Miscellaneous runtime library routines +************************************** + +Cache control functions +^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void __clear_cache (char *beg, char *end) + + This function clears the instruction cache between :samp:`{beg}` and :samp:`{end}`. + +Split stack functions and variables +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void * __splitstack_find (void *segment_arg, void *sp, size_t len, void **next_segment, void **next_sp, void **initial_sp) + + When using :option:`-fsplit-stack`, this call may be used to iterate + over the stack segments. It may be called like this: + + .. code-block:: c++ + + void *next_segment = NULL; + void *next_sp = NULL; + void *initial_sp = NULL; + void *stack; + size_t stack_size; + while ((stack = __splitstack_find (next_segment, next_sp, + &stack_size, &next_segment, + &next_sp, &initial_sp)) + != NULL) + { + /* Stack segment starts at stack and is + stack_size bytes long. */ + } + + There is no way to iterate over the stack segments of a different + thread. However, what is permitted is for one thread to call this + with the :samp:`{segment_arg}` and :samp:`{sp}` arguments NULL, to pass + :samp:`{next_segment}`, :samp:`{next_sp}`, and :samp:`{initial_sp}` to a different + thread, and then to suspend one way or another. A different thread + may run the subsequent ``__splitstack_find`` iterations. Of + course, this will only work if the first thread is suspended while the + second thread is calling ``__splitstack_find``. If not, the second + thread could be looking at the stack while it is changing, and + anything could happen. + +.. c:var:: struct stack_segment *__morestack_segments + +.. c:var:: stack_segment * __morestack_current_segment + +.. c:var:: struct initial_sp __morestack_initial_sp + +Internal variables used by the :option:`-fsplit-stack` implementation. \ No newline at end of file diff --git a/gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-decimal-floating-point-emulation.rst b/gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-decimal-floating-point-emulation.rst new file mode 100644 index 00000000000..c2f2ee202a2 --- /dev/null +++ b/gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-decimal-floating-point-emulation.rst @@ -0,0 +1,312 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: decimal float library, IEEE 754-2008 + +.. _decimal-float-library-routines: + +Routines for decimal floating point emulation +********************************************* + +The software decimal floating point library implements IEEE 754-2008 +decimal floating point arithmetic and is only activated on selected +targets. + +The software decimal floating point library supports either DPD +(Densely Packed Decimal) or BID (Binary Integer Decimal) encoding +as selected at configure time. + +Arithmetic functions +^^^^^^^^^^^^^^^^^^^^ + +.. function:: _Decimal32 __dpd_addsd3 (_Decimal32 a, _Decimal32 b) + _Decimal32 __bid_addsd3 (_Decimal32 a, _Decimal32 b) + _Decimal64 __dpd_adddd3 (_Decimal64 a, _Decimal64 b) + _Decimal64 __bid_adddd3 (_Decimal64 a, _Decimal64 b) + _Decimal128 __dpd_addtd3 (_Decimal128 a, _Decimal128 b) + _Decimal128 __bid_addtd3 (_Decimal128 a, _Decimal128 b) + + These functions return the sum of :samp:`{a}` and :samp:`{b}`. + +.. function:: _Decimal32 __dpd_subsd3 (_Decimal32 a, _Decimal32 b) + _Decimal32 __bid_subsd3 (_Decimal32 a, _Decimal32 b) + _Decimal64 __dpd_subdd3 (_Decimal64 a, _Decimal64 b) + _Decimal64 __bid_subdd3 (_Decimal64 a, _Decimal64 b) + _Decimal128 __dpd_subtd3 (_Decimal128 a, _Decimal128 b) + _Decimal128 __bid_subtd3 (_Decimal128 a, _Decimal128 b) + + These functions return the difference between :samp:`{b}` and :samp:`{a}` ; + that is, :samp:`{a}` - :samp:`{b}`. + +.. function:: _Decimal32 __dpd_mulsd3 (_Decimal32 a, _Decimal32 b) + _Decimal32 __bid_mulsd3 (_Decimal32 a, _Decimal32 b) + _Decimal64 __dpd_muldd3 (_Decimal64 a, _Decimal64 b) + _Decimal64 __bid_muldd3 (_Decimal64 a, _Decimal64 b) + _Decimal128 __dpd_multd3 (_Decimal128 a, _Decimal128 b) + _Decimal128 __bid_multd3 (_Decimal128 a, _Decimal128 b) + + These functions return the product of :samp:`{a}` and :samp:`{b}`. + +.. function:: _Decimal32 __dpd_divsd3 (_Decimal32 a, _Decimal32 b) + _Decimal32 __bid_divsd3 (_Decimal32 a, _Decimal32 b) + _Decimal64 __dpd_divdd3 (_Decimal64 a, _Decimal64 b) + _Decimal64 __bid_divdd3 (_Decimal64 a, _Decimal64 b) + _Decimal128 __dpd_divtd3 (_Decimal128 a, _Decimal128 b) + _Decimal128 __bid_divtd3 (_Decimal128 a, _Decimal128 b) + + These functions return the quotient of :samp:`{a}` and :samp:`{b}` ; that is, + :samp:`{a}` / :samp:`{b}`. + +.. function:: _Decimal32 __dpd_negsd2 (_Decimal32 a) + _Decimal32 __bid_negsd2 (_Decimal32 a) + _Decimal64 __dpd_negdd2 (_Decimal64 a) + _Decimal64 __bid_negdd2 (_Decimal64 a) + _Decimal128 __dpd_negtd2 (_Decimal128 a) + _Decimal128 __bid_negtd2 (_Decimal128 a) + + These functions return the negation of :samp:`{a}`. They simply flip the + sign bit, so they can produce negative zero and negative NaN. + +Conversion functions +^^^^^^^^^^^^^^^^^^^^ + +.. function:: _Decimal64 __dpd_extendsddd2 (_Decimal32 a) + _Decimal64 __bid_extendsddd2 (_Decimal32 a) + _Decimal128 __dpd_extendsdtd2 (_Decimal32 a) + _Decimal128 __bid_extendsdtd2 (_Decimal32 a) + _Decimal128 __dpd_extendddtd2 (_Decimal64 a) + _Decimal128 __bid_extendddtd2 (_Decimal64 a) + _Decimal32 __dpd_truncddsd2 (_Decimal64 a) + _Decimal32 __bid_truncddsd2 (_Decimal64 a) + _Decimal32 __dpd_trunctdsd2 (_Decimal128 a) + _Decimal32 __bid_trunctdsd2 (_Decimal128 a) + _Decimal64 __dpd_trunctddd2 (_Decimal128 a) + _Decimal64 __bid_trunctddd2 (_Decimal128 a) + + These functions convert the value :samp:`{a}` from one decimal floating type + to another. + +.. function:: _Decimal64 __dpd_extendsfdd (float a) + _Decimal64 __bid_extendsfdd (float a) + _Decimal128 __dpd_extendsftd (float a) + _Decimal128 __bid_extendsftd (float a) + _Decimal128 __dpd_extenddftd (double a) + _Decimal128 __bid_extenddftd (double a) + _Decimal128 __dpd_extendxftd (long double a) + _Decimal128 __bid_extendxftd (long double a) + _Decimal32 __dpd_truncdfsd (double a) + _Decimal32 __bid_truncdfsd (double a) + _Decimal32 __dpd_truncxfsd (long double a) + _Decimal32 __bid_truncxfsd (long double a) + _Decimal32 __dpd_trunctfsd (long double a) + _Decimal32 __bid_trunctfsd (long double a) + _Decimal64 __dpd_truncxfdd (long double a) + _Decimal64 __bid_truncxfdd (long double a) + _Decimal64 __dpd_trunctfdd (long double a) + _Decimal64 __bid_trunctfdd (long double a) + + These functions convert the value of :samp:`{a}` from a binary floating type + to a decimal floating type of a different size. + +.. function:: float __dpd_truncddsf (_Decimal64 a) + float __bid_truncddsf (_Decimal64 a) + float __dpd_trunctdsf (_Decimal128 a) + float __bid_trunctdsf (_Decimal128 a) + double __dpd_extendsddf (_Decimal32 a) + double __bid_extendsddf (_Decimal32 a) + double __dpd_trunctddf (_Decimal128 a) + double __bid_trunctddf (_Decimal128 a) + long double __dpd_extendsdxf (_Decimal32 a) + long double __bid_extendsdxf (_Decimal32 a) + long double __dpd_extendddxf (_Decimal64 a) + long double __bid_extendddxf (_Decimal64 a) + long double __dpd_trunctdxf (_Decimal128 a) + long double __bid_trunctdxf (_Decimal128 a) + long double __dpd_extendsdtf (_Decimal32 a) + long double __bid_extendsdtf (_Decimal32 a) + long double __dpd_extendddtf (_Decimal64 a) + long double __bid_extendddtf (_Decimal64 a) + + These functions convert the value of :samp:`{a}` from a decimal floating type + to a binary floating type of a different size. + +.. function:: _Decimal32 __dpd_extendsfsd (float a) + _Decimal32 __bid_extendsfsd (float a) + _Decimal64 __dpd_extenddfdd (double a) + _Decimal64 __bid_extenddfdd (double a) + _Decimal128 __dpd_extendtftd (long double a) + _Decimal128 __bid_extendtftd (long double a) + float __dpd_truncsdsf (_Decimal32 a) + float __bid_truncsdsf (_Decimal32 a) + double __dpd_truncdddf (_Decimal64 a) + double __bid_truncdddf (_Decimal64 a) + long double __dpd_trunctdtf (_Decimal128 a) + long double __bid_trunctdtf (_Decimal128 a) + + These functions convert the value of :samp:`{a}` between decimal and + binary floating types of the same size. + +.. function:: int __dpd_fixsdsi (_Decimal32 a) + int __bid_fixsdsi (_Decimal32 a) + int __dpd_fixddsi (_Decimal64 a) + int __bid_fixddsi (_Decimal64 a) + int __dpd_fixtdsi (_Decimal128 a) + int __bid_fixtdsi (_Decimal128 a) + + These functions convert :samp:`{a}` to a signed integer. + +.. function:: long __dpd_fixsddi (_Decimal32 a) + long __bid_fixsddi (_Decimal32 a) + long __dpd_fixdddi (_Decimal64 a) + long __bid_fixdddi (_Decimal64 a) + long __dpd_fixtddi (_Decimal128 a) + long __bid_fixtddi (_Decimal128 a) + + These functions convert :samp:`{a}` to a signed long. + +.. function:: unsigned int __dpd_fixunssdsi (_Decimal32 a) + unsigned int __bid_fixunssdsi (_Decimal32 a) + unsigned int __dpd_fixunsddsi (_Decimal64 a) + unsigned int __bid_fixunsddsi (_Decimal64 a) + unsigned int __dpd_fixunstdsi (_Decimal128 a) + unsigned int __bid_fixunstdsi (_Decimal128 a) + + These functions convert :samp:`{a}` to an unsigned integer. Negative values all become zero. + +.. function:: unsigned long __dpd_fixunssddi (_Decimal32 a) + unsigned long __bid_fixunssddi (_Decimal32 a) + unsigned long __dpd_fixunsdddi (_Decimal64 a) + unsigned long __bid_fixunsdddi (_Decimal64 a) + unsigned long __dpd_fixunstddi (_Decimal128 a) + unsigned long __bid_fixunstddi (_Decimal128 a) + + These functions convert :samp:`{a}` to an unsigned long. Negative values + all become zero. + +.. function:: _Decimal32 __dpd_floatsisd (int i) + _Decimal32 __bid_floatsisd (int i) + _Decimal64 __dpd_floatsidd (int i) + _Decimal64 __bid_floatsidd (int i) + _Decimal128 __dpd_floatsitd (int i) + _Decimal128 __bid_floatsitd (int i) + + These functions convert :samp:`{i}`, a signed integer, to decimal floating point. + +.. function:: _Decimal32 __dpd_floatdisd (long i) + _Decimal32 __bid_floatdisd (long i) + _Decimal64 __dpd_floatdidd (long i) + _Decimal64 __bid_floatdidd (long i) + _Decimal128 __dpd_floatditd (long i) + _Decimal128 __bid_floatditd (long i) + + These functions convert :samp:`{i}`, a signed long, to decimal floating point. + +.. function:: _Decimal32 __dpd_floatunssisd (unsigned int i) + _Decimal32 __bid_floatunssisd (unsigned int i) + _Decimal64 __dpd_floatunssidd (unsigned int i) + _Decimal64 __bid_floatunssidd (unsigned int i) + _Decimal128 __dpd_floatunssitd (unsigned int i) + _Decimal128 __bid_floatunssitd (unsigned int i) + + These functions convert :samp:`{i}`, an unsigned integer, to decimal floating point. + +.. function:: _Decimal32 __dpd_floatunsdisd (unsigned long i) + _Decimal32 __bid_floatunsdisd (unsigned long i) + _Decimal64 __dpd_floatunsdidd (unsigned long i) + _Decimal64 __bid_floatunsdidd (unsigned long i) + _Decimal128 __dpd_floatunsditd (unsigned long i) + _Decimal128 __bid_floatunsditd (unsigned long i) + + These functions convert :samp:`{i}`, an unsigned long, to decimal floating point. + +Comparison functions +^^^^^^^^^^^^^^^^^^^^ + +.. function:: int __dpd_unordsd2 (_Decimal32 a, _Decimal32 b) + int __bid_unordsd2 (_Decimal32 a, _Decimal32 b) + int __dpd_unorddd2 (_Decimal64 a, _Decimal64 b) + int __bid_unorddd2 (_Decimal64 a, _Decimal64 b) + int __dpd_unordtd2 (_Decimal128 a, _Decimal128 b) + int __bid_unordtd2 (_Decimal128 a, _Decimal128 b) + + These functions return a nonzero value if either argument is NaN, otherwise 0. + +There is also a complete group of higher level functions which +correspond directly to comparison operators. They implement the ISO C +semantics for floating-point comparisons, taking NaN into account. +Pay careful attention to the return values defined for each set. +Under the hood, all of these routines are implemented as + +.. code-block:: c++ + + if (__bid_unordXd2 (a, b)) + return E; + return __bid_cmpXd2 (a, b); + +where :samp:`{E}` is a constant chosen to give the proper behavior for +NaN. Thus, the meaning of the return value is different for each set. +Do not rely on this implementation; only the semantics documented +below are guaranteed. + +.. function:: int __dpd_eqsd2 (_Decimal32 a, _Decimal32 b) + int __bid_eqsd2 (_Decimal32 a, _Decimal32 b) + int __dpd_eqdd2 (_Decimal64 a, _Decimal64 b) + int __bid_eqdd2 (_Decimal64 a, _Decimal64 b) + int __dpd_eqtd2 (_Decimal128 a, _Decimal128 b) + int __bid_eqtd2 (_Decimal128 a, _Decimal128 b) + + These functions return zero if neither argument is NaN, and :samp:`{a}` and + :samp:`{b}` are equal. + +.. function:: int __dpd_nesd2 (_Decimal32 a, _Decimal32 b) + int __bid_nesd2 (_Decimal32 a, _Decimal32 b) + int __dpd_nedd2 (_Decimal64 a, _Decimal64 b) + int __bid_nedd2 (_Decimal64 a, _Decimal64 b) + int __dpd_netd2 (_Decimal128 a, _Decimal128 b) + int __bid_netd2 (_Decimal128 a, _Decimal128 b) + + These functions return a nonzero value if either argument is NaN, or + if :samp:`{a}` and :samp:`{b}` are unequal. + +.. function:: int __dpd_gesd2 (_Decimal32 a, _Decimal32 b) + int __bid_gesd2 (_Decimal32 a, _Decimal32 b) + int __dpd_gedd2 (_Decimal64 a, _Decimal64 b) + int __bid_gedd2 (_Decimal64 a, _Decimal64 b) + int __dpd_getd2 (_Decimal128 a, _Decimal128 b) + int __bid_getd2 (_Decimal128 a, _Decimal128 b) + + These functions return a value greater than or equal to zero if + neither argument is NaN, and :samp:`{a}` is greater than or equal to + :samp:`{b}`. + +.. function:: int __dpd_ltsd2 (_Decimal32 a, _Decimal32 b) + int __bid_ltsd2 (_Decimal32 a, _Decimal32 b) + int __dpd_ltdd2 (_Decimal64 a, _Decimal64 b) + int __bid_ltdd2 (_Decimal64 a, _Decimal64 b) + int __dpd_lttd2 (_Decimal128 a, _Decimal128 b) + int __bid_lttd2 (_Decimal128 a, _Decimal128 b) + + These functions return a value less than zero if neither argument is + NaN, and :samp:`{a}` is strictly less than :samp:`{b}`. + +.. function:: int __dpd_lesd2 (_Decimal32 a, _Decimal32 b) + int __bid_lesd2 (_Decimal32 a, _Decimal32 b) + int __dpd_ledd2 (_Decimal64 a, _Decimal64 b) + int __bid_ledd2 (_Decimal64 a, _Decimal64 b) + int __dpd_letd2 (_Decimal128 a, _Decimal128 b) + int __bid_letd2 (_Decimal128 a, _Decimal128 b) + + These functions return a value less than or equal to zero if neither + argument is NaN, and :samp:`{a}` is less than or equal to :samp:`{b}`. + +.. function:: int __dpd_gtsd2 (_Decimal32 a, _Decimal32 b) + int __bid_gtsd2 (_Decimal32 a, _Decimal32 b) + int __dpd_gtdd2 (_Decimal64 a, _Decimal64 b) + int __bid_gtdd2 (_Decimal64 a, _Decimal64 b) + int __dpd_gttd2 (_Decimal128 a, _Decimal128 b) + int __bid_gttd2 (_Decimal128 a, _Decimal128 b) + + These functions return a value greater than zero if neither argument + is NaN, and :samp:`{a}` is strictly greater than :samp:`{b}`. \ No newline at end of file diff --git a/gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-fixed-point-fractional-emulation.rst b/gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-fixed-point-fractional-emulation.rst new file mode 100644 index 00000000000..4ec5e11c402 --- /dev/null +++ b/gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-fixed-point-fractional-emulation.rst @@ -0,0 +1,1432 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. default-domain:: c + +.. index:: fixed-point fractional library, fractional types, Embedded C + +.. _fixed-point-fractional-library-routines: + +Routines for fixed-point fractional emulation +********************************************* + +The software fixed-point library implements fixed-point fractional +arithmetic, and is only activated on selected targets. + +For ease of comprehension ``fract`` is an alias for the +``_Fract`` type, ``accum`` an alias for ``_Accum``, and +``sat`` an alias for ``_Sat``. + +For illustrative purposes, in this section the fixed-point fractional type +``short fract`` is assumed to correspond to machine mode ``QQmode`` ; +``unsigned short fract`` to ``UQQmode`` ; +``fract`` to ``HQmode`` ; +``unsigned fract`` to ``UHQmode`` ; +``long fract`` to ``SQmode`` ; +``unsigned long fract`` to ``USQmode`` ; +``long long fract`` to ``DQmode`` ; +and ``unsigned long long fract`` to ``UDQmode``. +Similarly the fixed-point accumulator type +``short accum`` corresponds to ``HAmode`` ; +``unsigned short accum`` to ``UHAmode`` ; +``accum`` to ``SAmode`` ; +``unsigned accum`` to ``USAmode`` ; +``long accum`` to ``DAmode`` ; +``unsigned long accum`` to ``UDAmode`` ; +``long long accum`` to ``TAmode`` ; +and ``unsigned long long accum`` to ``UTAmode``. + +Arithmetic functions +^^^^^^^^^^^^^^^^^^^^ + +.. function:: short fract __addqq3 (short fract a, short fract b) + fract __addhq3 (fract a, fract b) + long fract __addsq3 (long fract a, long fract b) + long long fract __adddq3 (long long fract a, long long fract b) + unsigned short fract __adduqq3 (unsigned short fract a, unsigned short fract b) + unsigned fract __adduhq3 (unsigned fract a, unsigned fract b) + unsigned long fract __addusq3 (unsigned long fract a, unsigned long fract b) + unsigned long long fract __addudq3 (unsigned long long fract a, unsigned long long fract b) + short accum __addha3 (short accum a, short accum b) + accum __addsa3 (accum a, accum b) + long accum __addda3 (long accum a, long accum b) + long long accum __addta3 (long long accum a, long long accum b) + unsigned short accum __adduha3 (unsigned short accum a, unsigned short accum b) + unsigned accum __addusa3 (unsigned accum a, unsigned accum b) + unsigned long accum __adduda3 (unsigned long accum a, unsigned long accum b) + unsigned long long accum __adduta3 (unsigned long long accum a, unsigned long long accum b) + + These functions return the sum of :samp:`{a}` and :samp:`{b}`. + +.. function:: short fract __ssaddqq3 (short fract a, short fract b) + fract __ssaddhq3 (fract a, fract b) + long fract __ssaddsq3 (long fract a, long fract b) + long long fract __ssadddq3 (long long fract a, long long fract b) + short accum __ssaddha3 (short accum a, short accum b) + accum __ssaddsa3 (accum a, accum b) + long accum __ssaddda3 (long accum a, long accum b) + long long accum __ssaddta3 (long long accum a, long long accum b) + + These functions return the sum of :samp:`{a}` and :samp:`{b}` with signed saturation. + +.. function:: unsigned short fract __usadduqq3 (unsigned short fract a, unsigned short fract b) + unsigned fract __usadduhq3 (unsigned fract a, unsigned fract b) + unsigned long fract __usaddusq3 (unsigned long fract a, unsigned long fract b) + unsigned long long fract __usaddudq3 (unsigned long long fract a, unsigned long long fract b) + unsigned short accum __usadduha3 (unsigned short accum a, unsigned short accum b) + unsigned accum __usaddusa3 (unsigned accum a, unsigned accum b) + unsigned long accum __usadduda3 (unsigned long accum a, unsigned long accum b) + unsigned long long accum __usadduta3 (unsigned long long accum a, unsigned long long accum b) + + These functions return the sum of :samp:`{a}` and :samp:`{b}` with unsigned saturation. + +.. function:: short fract __subqq3 (short fract a, short fract b) + fract __subhq3 (fract a, fract b) + long fract __subsq3 (long fract a, long fract b) + long long fract __subdq3 (long long fract a, long long fract b) + unsigned short fract __subuqq3 (unsigned short fract a, unsigned short fract b) + unsigned fract __subuhq3 (unsigned fract a, unsigned fract b) + unsigned long fract __subusq3 (unsigned long fract a, unsigned long fract b) + unsigned long long fract __subudq3 (unsigned long long fract a, unsigned long long fract b) + short accum __subha3 (short accum a, short accum b) + accum __subsa3 (accum a, accum b) + long accum __subda3 (long accum a, long accum b) + long long accum __subta3 (long long accum a, long long accum b) + unsigned short accum __subuha3 (unsigned short accum a, unsigned short accum b) + unsigned accum __subusa3 (unsigned accum a, unsigned accum b) + unsigned long accum __subuda3 (unsigned long accum a, unsigned long accum b) + unsigned long long accum __subuta3 (unsigned long long accum a, unsigned long long accum b) + + These functions return the difference of :samp:`{a}` and :samp:`{b}` ; + that is, ``a - b``. + +.. function:: short fract __sssubqq3 (short fract a, short fract b) + fract __sssubhq3 (fract a, fract b) + long fract __sssubsq3 (long fract a, long fract b) + long long fract __sssubdq3 (long long fract a, long long fract b) + short accum __sssubha3 (short accum a, short accum b) + accum __sssubsa3 (accum a, accum b) + long accum __sssubda3 (long accum a, long accum b) + long long accum __sssubta3 (long long accum a, long long accum b) + + These functions return the difference of :samp:`{a}` and :samp:`{b}` with signed + saturation; that is, ``a - b``. + +.. function:: unsigned short fract __ussubuqq3 (unsigned short fract a, unsigned short fract b) + unsigned fract __ussubuhq3 (unsigned fract a, unsigned fract b) + unsigned long fract __ussubusq3 (unsigned long fract a, unsigned long fract b) + unsigned long long fract __ussubudq3 (unsigned long long fract a, unsigned long long fract b) + unsigned short accum __ussubuha3 (unsigned short accum a, unsigned short accum b) + unsigned accum __ussubusa3 (unsigned accum a, unsigned accum b) + unsigned long accum __ussubuda3 (unsigned long accum a, unsigned long accum b) + unsigned long long accum __ussubuta3 (unsigned long long accum a, unsigned long long accum b) + + These functions return the difference of :samp:`{a}` and :samp:`{b}` with unsigned + saturation; that is, ``a - b``. + +.. function:: short fract __mulqq3 (short fract a, short fract b) + fract __mulhq3 (fract a, fract b) + long fract __mulsq3 (long fract a, long fract b) + long long fract __muldq3 (long long fract a, long long fract b) + unsigned short fract __muluqq3 (unsigned short fract a, unsigned short fract b) + unsigned fract __muluhq3 (unsigned fract a, unsigned fract b) + unsigned long fract __mulusq3 (unsigned long fract a, unsigned long fract b) + unsigned long long fract __muludq3 (unsigned long long fract a, unsigned long long fract b) + short accum __mulha3 (short accum a, short accum b) + accum __mulsa3 (accum a, accum b) + long accum __mulda3 (long accum a, long accum b) + long long accum __multa3 (long long accum a, long long accum b) + unsigned short accum __muluha3 (unsigned short accum a, unsigned short accum b) + unsigned accum __mulusa3 (unsigned accum a, unsigned accum b) + unsigned long accum __muluda3 (unsigned long accum a, unsigned long accum b) + unsigned long long accum __muluta3 (unsigned long long accum a, unsigned long long accum b) + + These functions return the product of :samp:`{a}` and :samp:`{b}`. + +.. function:: short fract __ssmulqq3 (short fract a, short fract b) + fract __ssmulhq3 (fract a, fract b) + long fract __ssmulsq3 (long fract a, long fract b) + long long fract __ssmuldq3 (long long fract a, long long fract b) + short accum __ssmulha3 (short accum a, short accum b) + accum __ssmulsa3 (accum a, accum b) + long accum __ssmulda3 (long accum a, long accum b) + long long accum __ssmulta3 (long long accum a, long long accum b) + + These functions return the product of :samp:`{a}` and :samp:`{b}` with signed + saturation. + +.. function:: unsigned short fract __usmuluqq3 (unsigned short fract a, unsigned short fract b) + unsigned fract __usmuluhq3 (unsigned fract a, unsigned fract b) + unsigned long fract __usmulusq3 (unsigned long fract a, unsigned long fract b) + unsigned long long fract __usmuludq3 (unsigned long long fract a, unsigned long long fract b) + unsigned short accum __usmuluha3 (unsigned short accum a, unsigned short accum b) + unsigned accum __usmulusa3 (unsigned accum a, unsigned accum b) + unsigned long accum __usmuluda3 (unsigned long accum a, unsigned long accum b) + unsigned long long accum __usmuluta3 (unsigned long long accum a, unsigned long long accum b) + + These functions return the product of :samp:`{a}` and :samp:`{b}` with unsigned + saturation. + +.. function:: short fract __divqq3 (short fract a, short fract b) + fract __divhq3 (fract a, fract b) + long fract __divsq3 (long fract a, long fract b) + long long fract __divdq3 (long long fract a, long long fract b) + short accum __divha3 (short accum a, short accum b) + accum __divsa3 (accum a, accum b) + long accum __divda3 (long accum a, long accum b) + long long accum __divta3 (long long accum a, long long accum b) + + These functions return the quotient of the signed division of :samp:`{a}` + and :samp:`{b}`. + +.. function:: unsigned short fract __udivuqq3 (unsigned short fract a, unsigned short fract b) + unsigned fract __udivuhq3 (unsigned fract a, unsigned fract b) + unsigned long fract __udivusq3 (unsigned long fract a, unsigned long fract b) + unsigned long long fract __udivudq3 (unsigned long long fract a, unsigned long long fract b) + unsigned short accum __udivuha3 (unsigned short accum a, unsigned short accum b) + unsigned accum __udivusa3 (unsigned accum a, unsigned accum b) + unsigned long accum __udivuda3 (unsigned long accum a, unsigned long accum b) + unsigned long long accum __udivuta3 (unsigned long long accum a, unsigned long long accum b) + + These functions return the quotient of the unsigned division of :samp:`{a}` + and :samp:`{b}`. + +.. function:: short fract __ssdivqq3 (short fract a, short fract b) + fract __ssdivhq3 (fract a, fract b) + long fract __ssdivsq3 (long fract a, long fract b) + long long fract __ssdivdq3 (long long fract a, long long fract b) + short accum __ssdivha3 (short accum a, short accum b) + accum __ssdivsa3 (accum a, accum b) + long accum __ssdivda3 (long accum a, long accum b) + long long accum __ssdivta3 (long long accum a, long long accum b) + + These functions return the quotient of the signed division of :samp:`{a}` + and :samp:`{b}` with signed saturation. + +.. function:: unsigned short fract __usdivuqq3 (unsigned short fract a, unsigned short fract b) + unsigned fract __usdivuhq3 (unsigned fract a, unsigned fract b) + unsigned long fract __usdivusq3 (unsigned long fract a, unsigned long fract b) + unsigned long long fract __usdivudq3 (unsigned long long fract a, unsigned long long fract b) + unsigned short accum __usdivuha3 (unsigned short accum a, unsigned short accum b) + unsigned accum __usdivusa3 (unsigned accum a, unsigned accum b) + unsigned long accum __usdivuda3 (unsigned long accum a, unsigned long accum b) + unsigned long long accum __usdivuta3 (unsigned long long accum a, unsigned long long accum b) + + These functions return the quotient of the unsigned division of :samp:`{a}` + and :samp:`{b}` with unsigned saturation. + +.. function:: short fract __negqq2 (short fract a) + fract __neghq2 (fract a) + long fract __negsq2 (long fract a) + long long fract __negdq2 (long long fract a) + unsigned short fract __neguqq2 (unsigned short fract a) + unsigned fract __neguhq2 (unsigned fract a) + unsigned long fract __negusq2 (unsigned long fract a) + unsigned long long fract __negudq2 (unsigned long long fract a) + short accum __negha2 (short accum a) + accum __negsa2 (accum a) + long accum __negda2 (long accum a) + long long accum __negta2 (long long accum a) + unsigned short accum __neguha2 (unsigned short accum a) + unsigned accum __negusa2 (unsigned accum a) + unsigned long accum __neguda2 (unsigned long accum a) + unsigned long long accum __neguta2 (unsigned long long accum a) + + These functions return the negation of :samp:`{a}`. + +.. function:: short fract __ssnegqq2 (short fract a) + fract __ssneghq2 (fract a) + long fract __ssnegsq2 (long fract a) + long long fract __ssnegdq2 (long long fract a) + short accum __ssnegha2 (short accum a) + accum __ssnegsa2 (accum a) + long accum __ssnegda2 (long accum a) + long long accum __ssnegta2 (long long accum a) + + These functions return the negation of :samp:`{a}` with signed saturation. + +.. function:: unsigned short fract __usneguqq2 (unsigned short fract a) + unsigned fract __usneguhq2 (unsigned fract a) + unsigned long fract __usnegusq2 (unsigned long fract a) + unsigned long long fract __usnegudq2 (unsigned long long fract a) + unsigned short accum __usneguha2 (unsigned short accum a) + unsigned accum __usnegusa2 (unsigned accum a) + unsigned long accum __usneguda2 (unsigned long accum a) + unsigned long long accum __usneguta2 (unsigned long long accum a) + + These functions return the negation of :samp:`{a}` with unsigned saturation. + +.. function:: short fract __ashlqq3 (short fract a, int b) + fract __ashlhq3 (fract a, int b) + long fract __ashlsq3 (long fract a, int b) + long long fract __ashldq3 (long long fract a, int b) + unsigned short fract __ashluqq3 (unsigned short fract a, int b) + unsigned fract __ashluhq3 (unsigned fract a, int b) + unsigned long fract __ashlusq3 (unsigned long fract a, int b) + unsigned long long fract __ashludq3 (unsigned long long fract a, int b) + short accum __ashlha3 (short accum a, int b) + accum __ashlsa3 (accum a, int b) + long accum __ashlda3 (long accum a, int b) + long long accum __ashlta3 (long long accum a, int b) + unsigned short accum __ashluha3 (unsigned short accum a, int b) + unsigned accum __ashlusa3 (unsigned accum a, int b) + unsigned long accum __ashluda3 (unsigned long accum a, int b) + unsigned long long accum __ashluta3 (unsigned long long accum a, int b) + + These functions return the result of shifting :samp:`{a}` left by :samp:`{b}` bits. + +.. function:: short fract __ashrqq3 (short fract a, int b) + fract __ashrhq3 (fract a, int b) + long fract __ashrsq3 (long fract a, int b) + long long fract __ashrdq3 (long long fract a, int b) + short accum __ashrha3 (short accum a, int b) + accum __ashrsa3 (accum a, int b) + long accum __ashrda3 (long accum a, int b) + long long accum __ashrta3 (long long accum a, int b) + + These functions return the result of arithmetically shifting :samp:`{a}` right + by :samp:`{b}` bits. + +.. function:: unsigned short fract __lshruqq3 (unsigned short fract a, int b) + unsigned fract __lshruhq3 (unsigned fract a, int b) + unsigned long fract __lshrusq3 (unsigned long fract a, int b) + unsigned long long fract __lshrudq3 (unsigned long long fract a, int b) + unsigned short accum __lshruha3 (unsigned short accum a, int b) + unsigned accum __lshrusa3 (unsigned accum a, int b) + unsigned long accum __lshruda3 (unsigned long accum a, int b) + unsigned long long accum __lshruta3 (unsigned long long accum a, int b) + + These functions return the result of logically shifting :samp:`{a}` right + by :samp:`{b}` bits. + +.. function:: fract __ssashlhq3 (fract a, int b) + long fract __ssashlsq3 (long fract a, int b) + long long fract __ssashldq3 (long long fract a, int b) + short accum __ssashlha3 (short accum a, int b) + accum __ssashlsa3 (accum a, int b) + long accum __ssashlda3 (long accum a, int b) + long long accum __ssashlta3 (long long accum a, int b) + + These functions return the result of shifting :samp:`{a}` left by :samp:`{b}` bits + with signed saturation. + +.. function:: unsigned short fract __usashluqq3 (unsigned short fract a, int b) + unsigned fract __usashluhq3 (unsigned fract a, int b) + unsigned long fract __usashlusq3 (unsigned long fract a, int b) + unsigned long long fract __usashludq3 (unsigned long long fract a, int b) + unsigned short accum __usashluha3 (unsigned short accum a, int b) + unsigned accum __usashlusa3 (unsigned accum a, int b) + unsigned long accum __usashluda3 (unsigned long accum a, int b) + unsigned long long accum __usashluta3 (unsigned long long accum a, int b) + + These functions return the result of shifting :samp:`{a}` left by :samp:`{b}` bits + with unsigned saturation. + +Comparison functions +^^^^^^^^^^^^^^^^^^^^ + +The following functions implement fixed-point comparisons. These functions +implement a low-level compare, upon which the higher level comparison +operators (such as less than and greater than or equal to) can be +constructed. The returned values lie in the range zero to two, to allow +the high-level operators to be implemented by testing the returned +result using either signed or unsigned comparison. + +.. function:: int __cmpqq2 (short fract a, short fract b) + int __cmphq2 (fract a, fract b) + int __cmpsq2 (long fract a, long fract b) + int __cmpdq2 (long long fract a, long long fract b) + int __cmpuqq2 (unsigned short fract a, unsigned short fract b) + int __cmpuhq2 (unsigned fract a, unsigned fract b) + int __cmpusq2 (unsigned long fract a, unsigned long fract b) + int __cmpudq2 (unsigned long long fract a, unsigned long long fract b) + int __cmpha2 (short accum a, short accum b) + int __cmpsa2 (accum a, accum b) + int __cmpda2 (long accum a, long accum b) + int __cmpta2 (long long accum a, long long accum b) + int __cmpuha2 (unsigned short accum a, unsigned short accum b) + int __cmpusa2 (unsigned accum a, unsigned accum b) + int __cmpuda2 (unsigned long accum a, unsigned long accum b) + int __cmputa2 (unsigned long long accum a, unsigned long long accum b) + + These functions perform a signed or unsigned comparison of :samp:`{a}` and + :samp:`{b}` (depending on the selected machine mode). If :samp:`{a}` is less + than :samp:`{b}`, they return 0; if :samp:`{a}` is greater than :samp:`{b}`, they + return 2; and if :samp:`{a}` and :samp:`{b}` are equal they return 1. + +Conversion functions +^^^^^^^^^^^^^^^^^^^^ + +.. function:: fract __fractqqhq2 (short fract a) + long fract __fractqqsq2 (short fract a) + long long fract __fractqqdq2 (short fract a) + short accum __fractqqha (short fract a) + accum __fractqqsa (short fract a) + long accum __fractqqda (short fract a) + long long accum __fractqqta (short fract a) + unsigned short fract __fractqquqq (short fract a) + unsigned fract __fractqquhq (short fract a) + unsigned long fract __fractqqusq (short fract a) + unsigned long long fract __fractqqudq (short fract a) + unsigned short accum __fractqquha (short fract a) + unsigned accum __fractqqusa (short fract a) + unsigned long accum __fractqquda (short fract a) + unsigned long long accum __fractqquta (short fract a) + signed char __fractqqqi (short fract a) + short __fractqqhi (short fract a) + int __fractqqsi (short fract a) + long __fractqqdi (short fract a) + long long __fractqqti (short fract a) + float __fractqqsf (short fract a) + double __fractqqdf (short fract a) + short fract __fracthqqq2 (fract a) + long fract __fracthqsq2 (fract a) + long long fract __fracthqdq2 (fract a) + short accum __fracthqha (fract a) + accum __fracthqsa (fract a) + long accum __fracthqda (fract a) + long long accum __fracthqta (fract a) + unsigned short fract __fracthquqq (fract a) + unsigned fract __fracthquhq (fract a) + unsigned long fract __fracthqusq (fract a) + unsigned long long fract __fracthqudq (fract a) + unsigned short accum __fracthquha (fract a) + unsigned accum __fracthqusa (fract a) + unsigned long accum __fracthquda (fract a) + unsigned long long accum __fracthquta (fract a) + signed char __fracthqqi (fract a) + short __fracthqhi (fract a) + int __fracthqsi (fract a) + long __fracthqdi (fract a) + long long __fracthqti (fract a) + float __fracthqsf (fract a) + double __fracthqdf (fract a) + short fract __fractsqqq2 (long fract a) + fract __fractsqhq2 (long fract a) + long long fract __fractsqdq2 (long fract a) + short accum __fractsqha (long fract a) + accum __fractsqsa (long fract a) + long accum __fractsqda (long fract a) + long long accum __fractsqta (long fract a) + unsigned short fract __fractsquqq (long fract a) + unsigned fract __fractsquhq (long fract a) + unsigned long fract __fractsqusq (long fract a) + unsigned long long fract __fractsqudq (long fract a) + unsigned short accum __fractsquha (long fract a) + unsigned accum __fractsqusa (long fract a) + unsigned long accum __fractsquda (long fract a) + unsigned long long accum __fractsquta (long fract a) + signed char __fractsqqi (long fract a) + short __fractsqhi (long fract a) + int __fractsqsi (long fract a) + long __fractsqdi (long fract a) + long long __fractsqti (long fract a) + float __fractsqsf (long fract a) + double __fractsqdf (long fract a) + short fract __fractdqqq2 (long long fract a) + fract __fractdqhq2 (long long fract a) + long fract __fractdqsq2 (long long fract a) + short accum __fractdqha (long long fract a) + accum __fractdqsa (long long fract a) + long accum __fractdqda (long long fract a) + long long accum __fractdqta (long long fract a) + unsigned short fract __fractdquqq (long long fract a) + unsigned fract __fractdquhq (long long fract a) + unsigned long fract __fractdqusq (long long fract a) + unsigned long long fract __fractdqudq (long long fract a) + unsigned short accum __fractdquha (long long fract a) + unsigned accum __fractdqusa (long long fract a) + unsigned long accum __fractdquda (long long fract a) + unsigned long long accum __fractdquta (long long fract a) + signed char __fractdqqi (long long fract a) + short __fractdqhi (long long fract a) + int __fractdqsi (long long fract a) + long __fractdqdi (long long fract a) + long long __fractdqti (long long fract a) + float __fractdqsf (long long fract a) + double __fractdqdf (long long fract a) + short fract __fracthaqq (short accum a) + fract __fracthahq (short accum a) + long fract __fracthasq (short accum a) + long long fract __fracthadq (short accum a) + accum __fracthasa2 (short accum a) + long accum __fracthada2 (short accum a) + long long accum __fracthata2 (short accum a) + unsigned short fract __fracthauqq (short accum a) + unsigned fract __fracthauhq (short accum a) + unsigned long fract __fracthausq (short accum a) + unsigned long long fract __fracthaudq (short accum a) + unsigned short accum __fracthauha (short accum a) + unsigned accum __fracthausa (short accum a) + unsigned long accum __fracthauda (short accum a) + unsigned long long accum __fracthauta (short accum a) + signed char __fracthaqi (short accum a) + short __fracthahi (short accum a) + int __fracthasi (short accum a) + long __fracthadi (short accum a) + long long __fracthati (short accum a) + float __fracthasf (short accum a) + double __fracthadf (short accum a) + short fract __fractsaqq (accum a) + fract __fractsahq (accum a) + long fract __fractsasq (accum a) + long long fract __fractsadq (accum a) + short accum __fractsaha2 (accum a) + long accum __fractsada2 (accum a) + long long accum __fractsata2 (accum a) + unsigned short fract __fractsauqq (accum a) + unsigned fract __fractsauhq (accum a) + unsigned long fract __fractsausq (accum a) + unsigned long long fract __fractsaudq (accum a) + unsigned short accum __fractsauha (accum a) + unsigned accum __fractsausa (accum a) + unsigned long accum __fractsauda (accum a) + unsigned long long accum __fractsauta (accum a) + signed char __fractsaqi (accum a) + short __fractsahi (accum a) + int __fractsasi (accum a) + long __fractsadi (accum a) + long long __fractsati (accum a) + float __fractsasf (accum a) + double __fractsadf (accum a) + short fract __fractdaqq (long accum a) + fract __fractdahq (long accum a) + long fract __fractdasq (long accum a) + long long fract __fractdadq (long accum a) + short accum __fractdaha2 (long accum a) + accum __fractdasa2 (long accum a) + long long accum __fractdata2 (long accum a) + unsigned short fract __fractdauqq (long accum a) + unsigned fract __fractdauhq (long accum a) + unsigned long fract __fractdausq (long accum a) + unsigned long long fract __fractdaudq (long accum a) + unsigned short accum __fractdauha (long accum a) + unsigned accum __fractdausa (long accum a) + unsigned long accum __fractdauda (long accum a) + unsigned long long accum __fractdauta (long accum a) + signed char __fractdaqi (long accum a) + short __fractdahi (long accum a) + int __fractdasi (long accum a) + long __fractdadi (long accum a) + long long __fractdati (long accum a) + float __fractdasf (long accum a) + double __fractdadf (long accum a) + short fract __fracttaqq (long long accum a) + fract __fracttahq (long long accum a) + long fract __fracttasq (long long accum a) + long long fract __fracttadq (long long accum a) + short accum __fracttaha2 (long long accum a) + accum __fracttasa2 (long long accum a) + long accum __fracttada2 (long long accum a) + unsigned short fract __fracttauqq (long long accum a) + unsigned fract __fracttauhq (long long accum a) + unsigned long fract __fracttausq (long long accum a) + unsigned long long fract __fracttaudq (long long accum a) + unsigned short accum __fracttauha (long long accum a) + unsigned accum __fracttausa (long long accum a) + unsigned long accum __fracttauda (long long accum a) + unsigned long long accum __fracttauta (long long accum a) + signed char __fracttaqi (long long accum a) + short __fracttahi (long long accum a) + int __fracttasi (long long accum a) + long __fracttadi (long long accum a) + long long __fracttati (long long accum a) + float __fracttasf (long long accum a) + double __fracttadf (long long accum a) + short fract __fractuqqqq (unsigned short fract a) + fract __fractuqqhq (unsigned short fract a) + long fract __fractuqqsq (unsigned short fract a) + long long fract __fractuqqdq (unsigned short fract a) + short accum __fractuqqha (unsigned short fract a) + accum __fractuqqsa (unsigned short fract a) + long accum __fractuqqda (unsigned short fract a) + long long accum __fractuqqta (unsigned short fract a) + unsigned fract __fractuqquhq2 (unsigned short fract a) + unsigned long fract __fractuqqusq2 (unsigned short fract a) + unsigned long long fract __fractuqqudq2 (unsigned short fract a) + unsigned short accum __fractuqquha (unsigned short fract a) + unsigned accum __fractuqqusa (unsigned short fract a) + unsigned long accum __fractuqquda (unsigned short fract a) + unsigned long long accum __fractuqquta (unsigned short fract a) + signed char __fractuqqqi (unsigned short fract a) + short __fractuqqhi (unsigned short fract a) + int __fractuqqsi (unsigned short fract a) + long __fractuqqdi (unsigned short fract a) + long long __fractuqqti (unsigned short fract a) + float __fractuqqsf (unsigned short fract a) + double __fractuqqdf (unsigned short fract a) + short fract __fractuhqqq (unsigned fract a) + fract __fractuhqhq (unsigned fract a) + long fract __fractuhqsq (unsigned fract a) + long long fract __fractuhqdq (unsigned fract a) + short accum __fractuhqha (unsigned fract a) + accum __fractuhqsa (unsigned fract a) + long accum __fractuhqda (unsigned fract a) + long long accum __fractuhqta (unsigned fract a) + unsigned short fract __fractuhquqq2 (unsigned fract a) + unsigned long fract __fractuhqusq2 (unsigned fract a) + unsigned long long fract __fractuhqudq2 (unsigned fract a) + unsigned short accum __fractuhquha (unsigned fract a) + unsigned accum __fractuhqusa (unsigned fract a) + unsigned long accum __fractuhquda (unsigned fract a) + unsigned long long accum __fractuhquta (unsigned fract a) + signed char __fractuhqqi (unsigned fract a) + short __fractuhqhi (unsigned fract a) + int __fractuhqsi (unsigned fract a) + long __fractuhqdi (unsigned fract a) + long long __fractuhqti (unsigned fract a) + float __fractuhqsf (unsigned fract a) + double __fractuhqdf (unsigned fract a) + short fract __fractusqqq (unsigned long fract a) + fract __fractusqhq (unsigned long fract a) + long fract __fractusqsq (unsigned long fract a) + long long fract __fractusqdq (unsigned long fract a) + short accum __fractusqha (unsigned long fract a) + accum __fractusqsa (unsigned long fract a) + long accum __fractusqda (unsigned long fract a) + long long accum __fractusqta (unsigned long fract a) + unsigned short fract __fractusquqq2 (unsigned long fract a) + unsigned fract __fractusquhq2 (unsigned long fract a) + unsigned long long fract __fractusqudq2 (unsigned long fract a) + unsigned short accum __fractusquha (unsigned long fract a) + unsigned accum __fractusqusa (unsigned long fract a) + unsigned long accum __fractusquda (unsigned long fract a) + unsigned long long accum __fractusquta (unsigned long fract a) + signed char __fractusqqi (unsigned long fract a) + short __fractusqhi (unsigned long fract a) + int __fractusqsi (unsigned long fract a) + long __fractusqdi (unsigned long fract a) + long long __fractusqti (unsigned long fract a) + float __fractusqsf (unsigned long fract a) + double __fractusqdf (unsigned long fract a) + short fract __fractudqqq (unsigned long long fract a) + fract __fractudqhq (unsigned long long fract a) + long fract __fractudqsq (unsigned long long fract a) + long long fract __fractudqdq (unsigned long long fract a) + short accum __fractudqha (unsigned long long fract a) + accum __fractudqsa (unsigned long long fract a) + long accum __fractudqda (unsigned long long fract a) + long long accum __fractudqta (unsigned long long fract a) + unsigned short fract __fractudquqq2 (unsigned long long fract a) + unsigned fract __fractudquhq2 (unsigned long long fract a) + unsigned long fract __fractudqusq2 (unsigned long long fract a) + unsigned short accum __fractudquha (unsigned long long fract a) + unsigned accum __fractudqusa (unsigned long long fract a) + unsigned long accum __fractudquda (unsigned long long fract a) + unsigned long long accum __fractudquta (unsigned long long fract a) + signed char __fractudqqi (unsigned long long fract a) + short __fractudqhi (unsigned long long fract a) + int __fractudqsi (unsigned long long fract a) + long __fractudqdi (unsigned long long fract a) + long long __fractudqti (unsigned long long fract a) + float __fractudqsf (unsigned long long fract a) + double __fractudqdf (unsigned long long fract a) + short fract __fractuhaqq (unsigned short accum a) + fract __fractuhahq (unsigned short accum a) + long fract __fractuhasq (unsigned short accum a) + long long fract __fractuhadq (unsigned short accum a) + short accum __fractuhaha (unsigned short accum a) + accum __fractuhasa (unsigned short accum a) + long accum __fractuhada (unsigned short accum a) + long long accum __fractuhata (unsigned short accum a) + unsigned short fract __fractuhauqq (unsigned short accum a) + unsigned fract __fractuhauhq (unsigned short accum a) + unsigned long fract __fractuhausq (unsigned short accum a) + unsigned long long fract __fractuhaudq (unsigned short accum a) + unsigned accum __fractuhausa2 (unsigned short accum a) + unsigned long accum __fractuhauda2 (unsigned short accum a) + unsigned long long accum __fractuhauta2 (unsigned short accum a) + signed char __fractuhaqi (unsigned short accum a) + short __fractuhahi (unsigned short accum a) + int __fractuhasi (unsigned short accum a) + long __fractuhadi (unsigned short accum a) + long long __fractuhati (unsigned short accum a) + float __fractuhasf (unsigned short accum a) + double __fractuhadf (unsigned short accum a) + short fract __fractusaqq (unsigned accum a) + fract __fractusahq (unsigned accum a) + long fract __fractusasq (unsigned accum a) + long long fract __fractusadq (unsigned accum a) + short accum __fractusaha (unsigned accum a) + accum __fractusasa (unsigned accum a) + long accum __fractusada (unsigned accum a) + long long accum __fractusata (unsigned accum a) + unsigned short fract __fractusauqq (unsigned accum a) + unsigned fract __fractusauhq (unsigned accum a) + unsigned long fract __fractusausq (unsigned accum a) + unsigned long long fract __fractusaudq (unsigned accum a) + unsigned short accum __fractusauha2 (unsigned accum a) + unsigned long accum __fractusauda2 (unsigned accum a) + unsigned long long accum __fractusauta2 (unsigned accum a) + signed char __fractusaqi (unsigned accum a) + short __fractusahi (unsigned accum a) + int __fractusasi (unsigned accum a) + long __fractusadi (unsigned accum a) + long long __fractusati (unsigned accum a) + float __fractusasf (unsigned accum a) + double __fractusadf (unsigned accum a) + short fract __fractudaqq (unsigned long accum a) + fract __fractudahq (unsigned long accum a) + long fract __fractudasq (unsigned long accum a) + long long fract __fractudadq (unsigned long accum a) + short accum __fractudaha (unsigned long accum a) + accum __fractudasa (unsigned long accum a) + long accum __fractudada (unsigned long accum a) + long long accum __fractudata (unsigned long accum a) + unsigned short fract __fractudauqq (unsigned long accum a) + unsigned fract __fractudauhq (unsigned long accum a) + unsigned long fract __fractudausq (unsigned long accum a) + unsigned long long fract __fractudaudq (unsigned long accum a) + unsigned short accum __fractudauha2 (unsigned long accum a) + unsigned accum __fractudausa2 (unsigned long accum a) + unsigned long long accum __fractudauta2 (unsigned long accum a) + signed char __fractudaqi (unsigned long accum a) + short __fractudahi (unsigned long accum a) + int __fractudasi (unsigned long accum a) + long __fractudadi (unsigned long accum a) + long long __fractudati (unsigned long accum a) + float __fractudasf (unsigned long accum a) + double __fractudadf (unsigned long accum a) + short fract __fractutaqq (unsigned long long accum a) + fract __fractutahq (unsigned long long accum a) + long fract __fractutasq (unsigned long long accum a) + long long fract __fractutadq (unsigned long long accum a) + short accum __fractutaha (unsigned long long accum a) + accum __fractutasa (unsigned long long accum a) + long accum __fractutada (unsigned long long accum a) + long long accum __fractutata (unsigned long long accum a) + unsigned short fract __fractutauqq (unsigned long long accum a) + unsigned fract __fractutauhq (unsigned long long accum a) + unsigned long fract __fractutausq (unsigned long long accum a) + unsigned long long fract __fractutaudq (unsigned long long accum a) + unsigned short accum __fractutauha2 (unsigned long long accum a) + unsigned accum __fractutausa2 (unsigned long long accum a) + unsigned long accum __fractutauda2 (unsigned long long accum a) + signed char __fractutaqi (unsigned long long accum a) + short __fractutahi (unsigned long long accum a) + int __fractutasi (unsigned long long accum a) + long __fractutadi (unsigned long long accum a) + long long __fractutati (unsigned long long accum a) + float __fractutasf (unsigned long long accum a) + double __fractutadf (unsigned long long accum a) + short fract __fractqiqq (signed char a) + fract __fractqihq (signed char a) + long fract __fractqisq (signed char a) + long long fract __fractqidq (signed char a) + short accum __fractqiha (signed char a) + accum __fractqisa (signed char a) + long accum __fractqida (signed char a) + long long accum __fractqita (signed char a) + unsigned short fract __fractqiuqq (signed char a) + unsigned fract __fractqiuhq (signed char a) + unsigned long fract __fractqiusq (signed char a) + unsigned long long fract __fractqiudq (signed char a) + unsigned short accum __fractqiuha (signed char a) + unsigned accum __fractqiusa (signed char a) + unsigned long accum __fractqiuda (signed char a) + unsigned long long accum __fractqiuta (signed char a) + short fract __fracthiqq (short a) + fract __fracthihq (short a) + long fract __fracthisq (short a) + long long fract __fracthidq (short a) + short accum __fracthiha (short a) + accum __fracthisa (short a) + long accum __fracthida (short a) + long long accum __fracthita (short a) + unsigned short fract __fracthiuqq (short a) + unsigned fract __fracthiuhq (short a) + unsigned long fract __fracthiusq (short a) + unsigned long long fract __fracthiudq (short a) + unsigned short accum __fracthiuha (short a) + unsigned accum __fracthiusa (short a) + unsigned long accum __fracthiuda (short a) + unsigned long long accum __fracthiuta (short a) + short fract __fractsiqq (int a) + fract __fractsihq (int a) + long fract __fractsisq (int a) + long long fract __fractsidq (int a) + short accum __fractsiha (int a) + accum __fractsisa (int a) + long accum __fractsida (int a) + long long accum __fractsita (int a) + unsigned short fract __fractsiuqq (int a) + unsigned fract __fractsiuhq (int a) + unsigned long fract __fractsiusq (int a) + unsigned long long fract __fractsiudq (int a) + unsigned short accum __fractsiuha (int a) + unsigned accum __fractsiusa (int a) + unsigned long accum __fractsiuda (int a) + unsigned long long accum __fractsiuta (int a) + short fract __fractdiqq (long a) + fract __fractdihq (long a) + long fract __fractdisq (long a) + long long fract __fractdidq (long a) + short accum __fractdiha (long a) + accum __fractdisa (long a) + long accum __fractdida (long a) + long long accum __fractdita (long a) + unsigned short fract __fractdiuqq (long a) + unsigned fract __fractdiuhq (long a) + unsigned long fract __fractdiusq (long a) + unsigned long long fract __fractdiudq (long a) + unsigned short accum __fractdiuha (long a) + unsigned accum __fractdiusa (long a) + unsigned long accum __fractdiuda (long a) + unsigned long long accum __fractdiuta (long a) + short fract __fracttiqq (long long a) + fract __fracttihq (long long a) + long fract __fracttisq (long long a) + long long fract __fracttidq (long long a) + short accum __fracttiha (long long a) + accum __fracttisa (long long a) + long accum __fracttida (long long a) + long long accum __fracttita (long long a) + unsigned short fract __fracttiuqq (long long a) + unsigned fract __fracttiuhq (long long a) + unsigned long fract __fracttiusq (long long a) + unsigned long long fract __fracttiudq (long long a) + unsigned short accum __fracttiuha (long long a) + unsigned accum __fracttiusa (long long a) + unsigned long accum __fracttiuda (long long a) + unsigned long long accum __fracttiuta (long long a) + short fract __fractsfqq (float a) + fract __fractsfhq (float a) + long fract __fractsfsq (float a) + long long fract __fractsfdq (float a) + short accum __fractsfha (float a) + accum __fractsfsa (float a) + long accum __fractsfda (float a) + long long accum __fractsfta (float a) + unsigned short fract __fractsfuqq (float a) + unsigned fract __fractsfuhq (float a) + unsigned long fract __fractsfusq (float a) + unsigned long long fract __fractsfudq (float a) + unsigned short accum __fractsfuha (float a) + unsigned accum __fractsfusa (float a) + unsigned long accum __fractsfuda (float a) + unsigned long long accum __fractsfuta (float a) + short fract __fractdfqq (double a) + fract __fractdfhq (double a) + long fract __fractdfsq (double a) + long long fract __fractdfdq (double a) + short accum __fractdfha (double a) + accum __fractdfsa (double a) + long accum __fractdfda (double a) + long long accum __fractdfta (double a) + unsigned short fract __fractdfuqq (double a) + unsigned fract __fractdfuhq (double a) + unsigned long fract __fractdfusq (double a) + unsigned long long fract __fractdfudq (double a) + unsigned short accum __fractdfuha (double a) + unsigned accum __fractdfusa (double a) + unsigned long accum __fractdfuda (double a) + unsigned long long accum __fractdfuta (double a) + + These functions convert from fractional and signed non-fractionals to + fractionals and signed non-fractionals, without saturation. + +.. function:: fract __satfractqqhq2 (short fract a) + long fract __satfractqqsq2 (short fract a) + long long fract __satfractqqdq2 (short fract a) + short accum __satfractqqha (short fract a) + accum __satfractqqsa (short fract a) + long accum __satfractqqda (short fract a) + long long accum __satfractqqta (short fract a) + unsigned short fract __satfractqquqq (short fract a) + unsigned fract __satfractqquhq (short fract a) + unsigned long fract __satfractqqusq (short fract a) + unsigned long long fract __satfractqqudq (short fract a) + unsigned short accum __satfractqquha (short fract a) + unsigned accum __satfractqqusa (short fract a) + unsigned long accum __satfractqquda (short fract a) + unsigned long long accum __satfractqquta (short fract a) + short fract __satfracthqqq2 (fract a) + long fract __satfracthqsq2 (fract a) + long long fract __satfracthqdq2 (fract a) + short accum __satfracthqha (fract a) + accum __satfracthqsa (fract a) + long accum __satfracthqda (fract a) + long long accum __satfracthqta (fract a) + unsigned short fract __satfracthquqq (fract a) + unsigned fract __satfracthquhq (fract a) + unsigned long fract __satfracthqusq (fract a) + unsigned long long fract __satfracthqudq (fract a) + unsigned short accum __satfracthquha (fract a) + unsigned accum __satfracthqusa (fract a) + unsigned long accum __satfracthquda (fract a) + unsigned long long accum __satfracthquta (fract a) + short fract __satfractsqqq2 (long fract a) + fract __satfractsqhq2 (long fract a) + long long fract __satfractsqdq2 (long fract a) + short accum __satfractsqha (long fract a) + accum __satfractsqsa (long fract a) + long accum __satfractsqda (long fract a) + long long accum __satfractsqta (long fract a) + unsigned short fract __satfractsquqq (long fract a) + unsigned fract __satfractsquhq (long fract a) + unsigned long fract __satfractsqusq (long fract a) + unsigned long long fract __satfractsqudq (long fract a) + unsigned short accum __satfractsquha (long fract a) + unsigned accum __satfractsqusa (long fract a) + unsigned long accum __satfractsquda (long fract a) + unsigned long long accum __satfractsquta (long fract a) + short fract __satfractdqqq2 (long long fract a) + fract __satfractdqhq2 (long long fract a) + long fract __satfractdqsq2 (long long fract a) + short accum __satfractdqha (long long fract a) + accum __satfractdqsa (long long fract a) + long accum __satfractdqda (long long fract a) + long long accum __satfractdqta (long long fract a) + unsigned short fract __satfractdquqq (long long fract a) + unsigned fract __satfractdquhq (long long fract a) + unsigned long fract __satfractdqusq (long long fract a) + unsigned long long fract __satfractdqudq (long long fract a) + unsigned short accum __satfractdquha (long long fract a) + unsigned accum __satfractdqusa (long long fract a) + unsigned long accum __satfractdquda (long long fract a) + unsigned long long accum __satfractdquta (long long fract a) + short fract __satfracthaqq (short accum a) + fract __satfracthahq (short accum a) + long fract __satfracthasq (short accum a) + long long fract __satfracthadq (short accum a) + accum __satfracthasa2 (short accum a) + long accum __satfracthada2 (short accum a) + long long accum __satfracthata2 (short accum a) + unsigned short fract __satfracthauqq (short accum a) + unsigned fract __satfracthauhq (short accum a) + unsigned long fract __satfracthausq (short accum a) + unsigned long long fract __satfracthaudq (short accum a) + unsigned short accum __satfracthauha (short accum a) + unsigned accum __satfracthausa (short accum a) + unsigned long accum __satfracthauda (short accum a) + unsigned long long accum __satfracthauta (short accum a) + short fract __satfractsaqq (accum a) + fract __satfractsahq (accum a) + long fract __satfractsasq (accum a) + long long fract __satfractsadq (accum a) + short accum __satfractsaha2 (accum a) + long accum __satfractsada2 (accum a) + long long accum __satfractsata2 (accum a) + unsigned short fract __satfractsauqq (accum a) + unsigned fract __satfractsauhq (accum a) + unsigned long fract __satfractsausq (accum a) + unsigned long long fract __satfractsaudq (accum a) + unsigned short accum __satfractsauha (accum a) + unsigned accum __satfractsausa (accum a) + unsigned long accum __satfractsauda (accum a) + unsigned long long accum __satfractsauta (accum a) + short fract __satfractdaqq (long accum a) + fract __satfractdahq (long accum a) + long fract __satfractdasq (long accum a) + long long fract __satfractdadq (long accum a) + short accum __satfractdaha2 (long accum a) + accum __satfractdasa2 (long accum a) + long long accum __satfractdata2 (long accum a) + unsigned short fract __satfractdauqq (long accum a) + unsigned fract __satfractdauhq (long accum a) + unsigned long fract __satfractdausq (long accum a) + unsigned long long fract __satfractdaudq (long accum a) + unsigned short accum __satfractdauha (long accum a) + unsigned accum __satfractdausa (long accum a) + unsigned long accum __satfractdauda (long accum a) + unsigned long long accum __satfractdauta (long accum a) + short fract __satfracttaqq (long long accum a) + fract __satfracttahq (long long accum a) + long fract __satfracttasq (long long accum a) + long long fract __satfracttadq (long long accum a) + short accum __satfracttaha2 (long long accum a) + accum __satfracttasa2 (long long accum a) + long accum __satfracttada2 (long long accum a) + unsigned short fract __satfracttauqq (long long accum a) + unsigned fract __satfracttauhq (long long accum a) + unsigned long fract __satfracttausq (long long accum a) + unsigned long long fract __satfracttaudq (long long accum a) + unsigned short accum __satfracttauha (long long accum a) + unsigned accum __satfracttausa (long long accum a) + unsigned long accum __satfracttauda (long long accum a) + unsigned long long accum __satfracttauta (long long accum a) + short fract __satfractuqqqq (unsigned short fract a) + fract __satfractuqqhq (unsigned short fract a) + long fract __satfractuqqsq (unsigned short fract a) + long long fract __satfractuqqdq (unsigned short fract a) + short accum __satfractuqqha (unsigned short fract a) + accum __satfractuqqsa (unsigned short fract a) + long accum __satfractuqqda (unsigned short fract a) + long long accum __satfractuqqta (unsigned short fract a) + unsigned fract __satfractuqquhq2 (unsigned short fract a) + unsigned long fract __satfractuqqusq2 (unsigned short fract a) + unsigned long long fract __satfractuqqudq2 (unsigned short fract a) + unsigned short accum __satfractuqquha (unsigned short fract a) + unsigned accum __satfractuqqusa (unsigned short fract a) + unsigned long accum __satfractuqquda (unsigned short fract a) + unsigned long long accum __satfractuqquta (unsigned short fract a) + short fract __satfractuhqqq (unsigned fract a) + fract __satfractuhqhq (unsigned fract a) + long fract __satfractuhqsq (unsigned fract a) + long long fract __satfractuhqdq (unsigned fract a) + short accum __satfractuhqha (unsigned fract a) + accum __satfractuhqsa (unsigned fract a) + long accum __satfractuhqda (unsigned fract a) + long long accum __satfractuhqta (unsigned fract a) + unsigned short fract __satfractuhquqq2 (unsigned fract a) + unsigned long fract __satfractuhqusq2 (unsigned fract a) + unsigned long long fract __satfractuhqudq2 (unsigned fract a) + unsigned short accum __satfractuhquha (unsigned fract a) + unsigned accum __satfractuhqusa (unsigned fract a) + unsigned long accum __satfractuhquda (unsigned fract a) + unsigned long long accum __satfractuhquta (unsigned fract a) + short fract __satfractusqqq (unsigned long fract a) + fract __satfractusqhq (unsigned long fract a) + long fract __satfractusqsq (unsigned long fract a) + long long fract __satfractusqdq (unsigned long fract a) + short accum __satfractusqha (unsigned long fract a) + accum __satfractusqsa (unsigned long fract a) + long accum __satfractusqda (unsigned long fract a) + long long accum __satfractusqta (unsigned long fract a) + unsigned short fract __satfractusquqq2 (unsigned long fract a) + unsigned fract __satfractusquhq2 (unsigned long fract a) + unsigned long long fract __satfractusqudq2 (unsigned long fract a) + unsigned short accum __satfractusquha (unsigned long fract a) + unsigned accum __satfractusqusa (unsigned long fract a) + unsigned long accum __satfractusquda (unsigned long fract a) + unsigned long long accum __satfractusquta (unsigned long fract a) + short fract __satfractudqqq (unsigned long long fract a) + fract __satfractudqhq (unsigned long long fract a) + long fract __satfractudqsq (unsigned long long fract a) + long long fract __satfractudqdq (unsigned long long fract a) + short accum __satfractudqha (unsigned long long fract a) + accum __satfractudqsa (unsigned long long fract a) + long accum __satfractudqda (unsigned long long fract a) + long long accum __satfractudqta (unsigned long long fract a) + unsigned short fract __satfractudquqq2 (unsigned long long fract a) + unsigned fract __satfractudquhq2 (unsigned long long fract a) + unsigned long fract __satfractudqusq2 (unsigned long long fract a) + unsigned short accum __satfractudquha (unsigned long long fract a) + unsigned accum __satfractudqusa (unsigned long long fract a) + unsigned long accum __satfractudquda (unsigned long long fract a) + unsigned long long accum __satfractudquta (unsigned long long fract a) + short fract __satfractuhaqq (unsigned short accum a) + fract __satfractuhahq (unsigned short accum a) + long fract __satfractuhasq (unsigned short accum a) + long long fract __satfractuhadq (unsigned short accum a) + short accum __satfractuhaha (unsigned short accum a) + accum __satfractuhasa (unsigned short accum a) + long accum __satfractuhada (unsigned short accum a) + long long accum __satfractuhata (unsigned short accum a) + unsigned short fract __satfractuhauqq (unsigned short accum a) + unsigned fract __satfractuhauhq (unsigned short accum a) + unsigned long fract __satfractuhausq (unsigned short accum a) + unsigned long long fract __satfractuhaudq (unsigned short accum a) + unsigned accum __satfractuhausa2 (unsigned short accum a) + unsigned long accum __satfractuhauda2 (unsigned short accum a) + unsigned long long accum __satfractuhauta2 (unsigned short accum a) + short fract __satfractusaqq (unsigned accum a) + fract __satfractusahq (unsigned accum a) + long fract __satfractusasq (unsigned accum a) + long long fract __satfractusadq (unsigned accum a) + short accum __satfractusaha (unsigned accum a) + accum __satfractusasa (unsigned accum a) + long accum __satfractusada (unsigned accum a) + long long accum __satfractusata (unsigned accum a) + unsigned short fract __satfractusauqq (unsigned accum a) + unsigned fract __satfractusauhq (unsigned accum a) + unsigned long fract __satfractusausq (unsigned accum a) + unsigned long long fract __satfractusaudq (unsigned accum a) + unsigned short accum __satfractusauha2 (unsigned accum a) + unsigned long accum __satfractusauda2 (unsigned accum a) + unsigned long long accum __satfractusauta2 (unsigned accum a) + short fract __satfractudaqq (unsigned long accum a) + fract __satfractudahq (unsigned long accum a) + long fract __satfractudasq (unsigned long accum a) + long long fract __satfractudadq (unsigned long accum a) + short accum __satfractudaha (unsigned long accum a) + accum __satfractudasa (unsigned long accum a) + long accum __satfractudada (unsigned long accum a) + long long accum __satfractudata (unsigned long accum a) + unsigned short fract __satfractudauqq (unsigned long accum a) + unsigned fract __satfractudauhq (unsigned long accum a) + unsigned long fract __satfractudausq (unsigned long accum a) + unsigned long long fract __satfractudaudq (unsigned long accum a) + unsigned short accum __satfractudauha2 (unsigned long accum a) + unsigned accum __satfractudausa2 (unsigned long accum a) + unsigned long long accum __satfractudauta2 (unsigned long accum a) + short fract __satfractutaqq (unsigned long long accum a) + fract __satfractutahq (unsigned long long accum a) + long fract __satfractutasq (unsigned long long accum a) + long long fract __satfractutadq (unsigned long long accum a) + short accum __satfractutaha (unsigned long long accum a) + accum __satfractutasa (unsigned long long accum a) + long accum __satfractutada (unsigned long long accum a) + long long accum __satfractutata (unsigned long long accum a) + unsigned short fract __satfractutauqq (unsigned long long accum a) + unsigned fract __satfractutauhq (unsigned long long accum a) + unsigned long fract __satfractutausq (unsigned long long accum a) + unsigned long long fract __satfractutaudq (unsigned long long accum a) + unsigned short accum __satfractutauha2 (unsigned long long accum a) + unsigned accum __satfractutausa2 (unsigned long long accum a) + unsigned long accum __satfractutauda2 (unsigned long long accum a) + short fract __satfractqiqq (signed char a) + fract __satfractqihq (signed char a) + long fract __satfractqisq (signed char a) + long long fract __satfractqidq (signed char a) + short accum __satfractqiha (signed char a) + accum __satfractqisa (signed char a) + long accum __satfractqida (signed char a) + long long accum __satfractqita (signed char a) + unsigned short fract __satfractqiuqq (signed char a) + unsigned fract __satfractqiuhq (signed char a) + unsigned long fract __satfractqiusq (signed char a) + unsigned long long fract __satfractqiudq (signed char a) + unsigned short accum __satfractqiuha (signed char a) + unsigned accum __satfractqiusa (signed char a) + unsigned long accum __satfractqiuda (signed char a) + unsigned long long accum __satfractqiuta (signed char a) + short fract __satfracthiqq (short a) + fract __satfracthihq (short a) + long fract __satfracthisq (short a) + long long fract __satfracthidq (short a) + short accum __satfracthiha (short a) + accum __satfracthisa (short a) + long accum __satfracthida (short a) + long long accum __satfracthita (short a) + unsigned short fract __satfracthiuqq (short a) + unsigned fract __satfracthiuhq (short a) + unsigned long fract __satfracthiusq (short a) + unsigned long long fract __satfracthiudq (short a) + unsigned short accum __satfracthiuha (short a) + unsigned accum __satfracthiusa (short a) + unsigned long accum __satfracthiuda (short a) + unsigned long long accum __satfracthiuta (short a) + short fract __satfractsiqq (int a) + fract __satfractsihq (int a) + long fract __satfractsisq (int a) + long long fract __satfractsidq (int a) + short accum __satfractsiha (int a) + accum __satfractsisa (int a) + long accum __satfractsida (int a) + long long accum __satfractsita (int a) + unsigned short fract __satfractsiuqq (int a) + unsigned fract __satfractsiuhq (int a) + unsigned long fract __satfractsiusq (int a) + unsigned long long fract __satfractsiudq (int a) + unsigned short accum __satfractsiuha (int a) + unsigned accum __satfractsiusa (int a) + unsigned long accum __satfractsiuda (int a) + unsigned long long accum __satfractsiuta (int a) + short fract __satfractdiqq (long a) + fract __satfractdihq (long a) + long fract __satfractdisq (long a) + long long fract __satfractdidq (long a) + short accum __satfractdiha (long a) + accum __satfractdisa (long a) + long accum __satfractdida (long a) + long long accum __satfractdita (long a) + unsigned short fract __satfractdiuqq (long a) + unsigned fract __satfractdiuhq (long a) + unsigned long fract __satfractdiusq (long a) + unsigned long long fract __satfractdiudq (long a) + unsigned short accum __satfractdiuha (long a) + unsigned accum __satfractdiusa (long a) + unsigned long accum __satfractdiuda (long a) + unsigned long long accum __satfractdiuta (long a) + short fract __satfracttiqq (long long a) + fract __satfracttihq (long long a) + long fract __satfracttisq (long long a) + long long fract __satfracttidq (long long a) + short accum __satfracttiha (long long a) + accum __satfracttisa (long long a) + long accum __satfracttida (long long a) + long long accum __satfracttita (long long a) + unsigned short fract __satfracttiuqq (long long a) + unsigned fract __satfracttiuhq (long long a) + unsigned long fract __satfracttiusq (long long a) + unsigned long long fract __satfracttiudq (long long a) + unsigned short accum __satfracttiuha (long long a) + unsigned accum __satfracttiusa (long long a) + unsigned long accum __satfracttiuda (long long a) + unsigned long long accum __satfracttiuta (long long a) + short fract __satfractsfqq (float a) + fract __satfractsfhq (float a) + long fract __satfractsfsq (float a) + long long fract __satfractsfdq (float a) + short accum __satfractsfha (float a) + accum __satfractsfsa (float a) + long accum __satfractsfda (float a) + long long accum __satfractsfta (float a) + unsigned short fract __satfractsfuqq (float a) + unsigned fract __satfractsfuhq (float a) + unsigned long fract __satfractsfusq (float a) + unsigned long long fract __satfractsfudq (float a) + unsigned short accum __satfractsfuha (float a) + unsigned accum __satfractsfusa (float a) + unsigned long accum __satfractsfuda (float a) + unsigned long long accum __satfractsfuta (float a) + short fract __satfractdfqq (double a) + fract __satfractdfhq (double a) + long fract __satfractdfsq (double a) + long long fract __satfractdfdq (double a) + short accum __satfractdfha (double a) + accum __satfractdfsa (double a) + long accum __satfractdfda (double a) + long long accum __satfractdfta (double a) + unsigned short fract __satfractdfuqq (double a) + unsigned fract __satfractdfuhq (double a) + unsigned long fract __satfractdfusq (double a) + unsigned long long fract __satfractdfudq (double a) + unsigned short accum __satfractdfuha (double a) + unsigned accum __satfractdfusa (double a) + unsigned long accum __satfractdfuda (double a) + unsigned long long accum __satfractdfuta (double a) + + The functions convert from fractional and signed non-fractionals to + fractionals, with saturation. + +.. function:: unsigned char __fractunsqqqi (short fract a) + unsigned short __fractunsqqhi (short fract a) + unsigned int __fractunsqqsi (short fract a) + unsigned long __fractunsqqdi (short fract a) + unsigned long long __fractunsqqti (short fract a) + unsigned char __fractunshqqi (fract a) + unsigned short __fractunshqhi (fract a) + unsigned int __fractunshqsi (fract a) + unsigned long __fractunshqdi (fract a) + unsigned long long __fractunshqti (fract a) + unsigned char __fractunssqqi (long fract a) + unsigned short __fractunssqhi (long fract a) + unsigned int __fractunssqsi (long fract a) + unsigned long __fractunssqdi (long fract a) + unsigned long long __fractunssqti (long fract a) + unsigned char __fractunsdqqi (long long fract a) + unsigned short __fractunsdqhi (long long fract a) + unsigned int __fractunsdqsi (long long fract a) + unsigned long __fractunsdqdi (long long fract a) + unsigned long long __fractunsdqti (long long fract a) + unsigned char __fractunshaqi (short accum a) + unsigned short __fractunshahi (short accum a) + unsigned int __fractunshasi (short accum a) + unsigned long __fractunshadi (short accum a) + unsigned long long __fractunshati (short accum a) + unsigned char __fractunssaqi (accum a) + unsigned short __fractunssahi (accum a) + unsigned int __fractunssasi (accum a) + unsigned long __fractunssadi (accum a) + unsigned long long __fractunssati (accum a) + unsigned char __fractunsdaqi (long accum a) + unsigned short __fractunsdahi (long accum a) + unsigned int __fractunsdasi (long accum a) + unsigned long __fractunsdadi (long accum a) + unsigned long long __fractunsdati (long accum a) + unsigned char __fractunstaqi (long long accum a) + unsigned short __fractunstahi (long long accum a) + unsigned int __fractunstasi (long long accum a) + unsigned long __fractunstadi (long long accum a) + unsigned long long __fractunstati (long long accum a) + unsigned char __fractunsuqqqi (unsigned short fract a) + unsigned short __fractunsuqqhi (unsigned short fract a) + unsigned int __fractunsuqqsi (unsigned short fract a) + unsigned long __fractunsuqqdi (unsigned short fract a) + unsigned long long __fractunsuqqti (unsigned short fract a) + unsigned char __fractunsuhqqi (unsigned fract a) + unsigned short __fractunsuhqhi (unsigned fract a) + unsigned int __fractunsuhqsi (unsigned fract a) + unsigned long __fractunsuhqdi (unsigned fract a) + unsigned long long __fractunsuhqti (unsigned fract a) + unsigned char __fractunsusqqi (unsigned long fract a) + unsigned short __fractunsusqhi (unsigned long fract a) + unsigned int __fractunsusqsi (unsigned long fract a) + unsigned long __fractunsusqdi (unsigned long fract a) + unsigned long long __fractunsusqti (unsigned long fract a) + unsigned char __fractunsudqqi (unsigned long long fract a) + unsigned short __fractunsudqhi (unsigned long long fract a) + unsigned int __fractunsudqsi (unsigned long long fract a) + unsigned long __fractunsudqdi (unsigned long long fract a) + unsigned long long __fractunsudqti (unsigned long long fract a) + unsigned char __fractunsuhaqi (unsigned short accum a) + unsigned short __fractunsuhahi (unsigned short accum a) + unsigned int __fractunsuhasi (unsigned short accum a) + unsigned long __fractunsuhadi (unsigned short accum a) + unsigned long long __fractunsuhati (unsigned short accum a) + unsigned char __fractunsusaqi (unsigned accum a) + unsigned short __fractunsusahi (unsigned accum a) + unsigned int __fractunsusasi (unsigned accum a) + unsigned long __fractunsusadi (unsigned accum a) + unsigned long long __fractunsusati (unsigned accum a) + unsigned char __fractunsudaqi (unsigned long accum a) + unsigned short __fractunsudahi (unsigned long accum a) + unsigned int __fractunsudasi (unsigned long accum a) + unsigned long __fractunsudadi (unsigned long accum a) + unsigned long long __fractunsudati (unsigned long accum a) + unsigned char __fractunsutaqi (unsigned long long accum a) + unsigned short __fractunsutahi (unsigned long long accum a) + unsigned int __fractunsutasi (unsigned long long accum a) + unsigned long __fractunsutadi (unsigned long long accum a) + unsigned long long __fractunsutati (unsigned long long accum a) + short fract __fractunsqiqq (unsigned char a) + fract __fractunsqihq (unsigned char a) + long fract __fractunsqisq (unsigned char a) + long long fract __fractunsqidq (unsigned char a) + short accum __fractunsqiha (unsigned char a) + accum __fractunsqisa (unsigned char a) + long accum __fractunsqida (unsigned char a) + long long accum __fractunsqita (unsigned char a) + unsigned short fract __fractunsqiuqq (unsigned char a) + unsigned fract __fractunsqiuhq (unsigned char a) + unsigned long fract __fractunsqiusq (unsigned char a) + unsigned long long fract __fractunsqiudq (unsigned char a) + unsigned short accum __fractunsqiuha (unsigned char a) + unsigned accum __fractunsqiusa (unsigned char a) + unsigned long accum __fractunsqiuda (unsigned char a) + unsigned long long accum __fractunsqiuta (unsigned char a) + short fract __fractunshiqq (unsigned short a) + fract __fractunshihq (unsigned short a) + long fract __fractunshisq (unsigned short a) + long long fract __fractunshidq (unsigned short a) + short accum __fractunshiha (unsigned short a) + accum __fractunshisa (unsigned short a) + long accum __fractunshida (unsigned short a) + long long accum __fractunshita (unsigned short a) + unsigned short fract __fractunshiuqq (unsigned short a) + unsigned fract __fractunshiuhq (unsigned short a) + unsigned long fract __fractunshiusq (unsigned short a) + unsigned long long fract __fractunshiudq (unsigned short a) + unsigned short accum __fractunshiuha (unsigned short a) + unsigned accum __fractunshiusa (unsigned short a) + unsigned long accum __fractunshiuda (unsigned short a) + unsigned long long accum __fractunshiuta (unsigned short a) + short fract __fractunssiqq (unsigned int a) + fract __fractunssihq (unsigned int a) + long fract __fractunssisq (unsigned int a) + long long fract __fractunssidq (unsigned int a) + short accum __fractunssiha (unsigned int a) + accum __fractunssisa (unsigned int a) + long accum __fractunssida (unsigned int a) + long long accum __fractunssita (unsigned int a) + unsigned short fract __fractunssiuqq (unsigned int a) + unsigned fract __fractunssiuhq (unsigned int a) + unsigned long fract __fractunssiusq (unsigned int a) + unsigned long long fract __fractunssiudq (unsigned int a) + unsigned short accum __fractunssiuha (unsigned int a) + unsigned accum __fractunssiusa (unsigned int a) + unsigned long accum __fractunssiuda (unsigned int a) + unsigned long long accum __fractunssiuta (unsigned int a) + short fract __fractunsdiqq (unsigned long a) + fract __fractunsdihq (unsigned long a) + long fract __fractunsdisq (unsigned long a) + long long fract __fractunsdidq (unsigned long a) + short accum __fractunsdiha (unsigned long a) + accum __fractunsdisa (unsigned long a) + long accum __fractunsdida (unsigned long a) + long long accum __fractunsdita (unsigned long a) + unsigned short fract __fractunsdiuqq (unsigned long a) + unsigned fract __fractunsdiuhq (unsigned long a) + unsigned long fract __fractunsdiusq (unsigned long a) + unsigned long long fract __fractunsdiudq (unsigned long a) + unsigned short accum __fractunsdiuha (unsigned long a) + unsigned accum __fractunsdiusa (unsigned long a) + unsigned long accum __fractunsdiuda (unsigned long a) + unsigned long long accum __fractunsdiuta (unsigned long a) + short fract __fractunstiqq (unsigned long long a) + fract __fractunstihq (unsigned long long a) + long fract __fractunstisq (unsigned long long a) + long long fract __fractunstidq (unsigned long long a) + short accum __fractunstiha (unsigned long long a) + accum __fractunstisa (unsigned long long a) + long accum __fractunstida (unsigned long long a) + long long accum __fractunstita (unsigned long long a) + unsigned short fract __fractunstiuqq (unsigned long long a) + unsigned fract __fractunstiuhq (unsigned long long a) + unsigned long fract __fractunstiusq (unsigned long long a) + unsigned long long fract __fractunstiudq (unsigned long long a) + unsigned short accum __fractunstiuha (unsigned long long a) + unsigned accum __fractunstiusa (unsigned long long a) + unsigned long accum __fractunstiuda (unsigned long long a) + unsigned long long accum __fractunstiuta (unsigned long long a) + + These functions convert from fractionals to unsigned non-fractionals; + and from unsigned non-fractionals to fractionals, without saturation. + +.. function:: short fract __satfractunsqiqq (unsigned char a) + fract __satfractunsqihq (unsigned char a) + long fract __satfractunsqisq (unsigned char a) + long long fract __satfractunsqidq (unsigned char a) + short accum __satfractunsqiha (unsigned char a) + accum __satfractunsqisa (unsigned char a) + long accum __satfractunsqida (unsigned char a) + long long accum __satfractunsqita (unsigned char a) + unsigned short fract __satfractunsqiuqq (unsigned char a) + unsigned fract __satfractunsqiuhq (unsigned char a) + unsigned long fract __satfractunsqiusq (unsigned char a) + unsigned long long fract __satfractunsqiudq (unsigned char a) + unsigned short accum __satfractunsqiuha (unsigned char a) + unsigned accum __satfractunsqiusa (unsigned char a) + unsigned long accum __satfractunsqiuda (unsigned char a) + unsigned long long accum __satfractunsqiuta (unsigned char a) + short fract __satfractunshiqq (unsigned short a) + fract __satfractunshihq (unsigned short a) + long fract __satfractunshisq (unsigned short a) + long long fract __satfractunshidq (unsigned short a) + short accum __satfractunshiha (unsigned short a) + accum __satfractunshisa (unsigned short a) + long accum __satfractunshida (unsigned short a) + long long accum __satfractunshita (unsigned short a) + unsigned short fract __satfractunshiuqq (unsigned short a) + unsigned fract __satfractunshiuhq (unsigned short a) + unsigned long fract __satfractunshiusq (unsigned short a) + unsigned long long fract __satfractunshiudq (unsigned short a) + unsigned short accum __satfractunshiuha (unsigned short a) + unsigned accum __satfractunshiusa (unsigned short a) + unsigned long accum __satfractunshiuda (unsigned short a) + unsigned long long accum __satfractunshiuta (unsigned short a) + short fract __satfractunssiqq (unsigned int a) + fract __satfractunssihq (unsigned int a) + long fract __satfractunssisq (unsigned int a) + long long fract __satfractunssidq (unsigned int a) + short accum __satfractunssiha (unsigned int a) + accum __satfractunssisa (unsigned int a) + long accum __satfractunssida (unsigned int a) + long long accum __satfractunssita (unsigned int a) + unsigned short fract __satfractunssiuqq (unsigned int a) + unsigned fract __satfractunssiuhq (unsigned int a) + unsigned long fract __satfractunssiusq (unsigned int a) + unsigned long long fract __satfractunssiudq (unsigned int a) + unsigned short accum __satfractunssiuha (unsigned int a) + unsigned accum __satfractunssiusa (unsigned int a) + unsigned long accum __satfractunssiuda (unsigned int a) + unsigned long long accum __satfractunssiuta (unsigned int a) + short fract __satfractunsdiqq (unsigned long a) + fract __satfractunsdihq (unsigned long a) + long fract __satfractunsdisq (unsigned long a) + long long fract __satfractunsdidq (unsigned long a) + short accum __satfractunsdiha (unsigned long a) + accum __satfractunsdisa (unsigned long a) + long accum __satfractunsdida (unsigned long a) + long long accum __satfractunsdita (unsigned long a) + unsigned short fract __satfractunsdiuqq (unsigned long a) + unsigned fract __satfractunsdiuhq (unsigned long a) + unsigned long fract __satfractunsdiusq (unsigned long a) + unsigned long long fract __satfractunsdiudq (unsigned long a) + unsigned short accum __satfractunsdiuha (unsigned long a) + unsigned accum __satfractunsdiusa (unsigned long a) + unsigned long accum __satfractunsdiuda (unsigned long a) + unsigned long long accum __satfractunsdiuta (unsigned long a) + short fract __satfractunstiqq (unsigned long long a) + fract __satfractunstihq (unsigned long long a) + long fract __satfractunstisq (unsigned long long a) + long long fract __satfractunstidq (unsigned long long a) + short accum __satfractunstiha (unsigned long long a) + accum __satfractunstisa (unsigned long long a) + long accum __satfractunstida (unsigned long long a) + long long accum __satfractunstita (unsigned long long a) + unsigned short fract __satfractunstiuqq (unsigned long long a) + unsigned fract __satfractunstiuhq (unsigned long long a) + unsigned long fract __satfractunstiusq (unsigned long long a) + unsigned long long fract __satfractunstiudq (unsigned long long a) + unsigned short accum __satfractunstiuha (unsigned long long a) + unsigned accum __satfractunstiusa (unsigned long long a) + unsigned long accum __satfractunstiuda (unsigned long long a) + unsigned long long accum __satfractunstiuta (unsigned long long a) + + These functions convert from unsigned non-fractionals to fractionals, + with saturation. \ No newline at end of file diff --git a/gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-floating-point-emulation.rst b/gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-floating-point-emulation.rst new file mode 100644 index 00000000000..54bf19fd33e --- /dev/null +++ b/gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-floating-point-emulation.rst @@ -0,0 +1,283 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. default-domain:: c + +.. index:: soft float library, arithmetic library, math library, msoft-float + +.. _soft-float-library-routines: + +Routines for floating point emulation +************************************* + +The software floating point library is used on machines which do not +have hardware support for floating point. It is also used whenever +:option:`-msoft-float` is used to disable generation of floating point +instructions. (Not all targets support this switch.) + +For compatibility with other compilers, the floating point emulation +routines can be renamed with the ``DECLARE_LIBRARY_RENAMES`` macro +(see :ref:`library-calls`). In this section, the default names are used. + +Presently the library does not support ``XFmode``, which is used +for ``long double`` on some architectures. + +Arithmetic functions +^^^^^^^^^^^^^^^^^^^^ + +.. function:: float __addsf3 (float a, float b) + double __adddf3 (double a, double b) + long double __addtf3 (long double a, long double b) + long double __addxf3 (long double a, long double b) + + These functions return the sum of :samp:`{a}` and :samp:`{b}`. + +.. function:: float __subsf3 (float a, float b) + double __subdf3 (double a, double b) + long double __subtf3 (long double a, long double b) + long double __subxf3 (long double a, long double b) + + These functions return the difference between :samp:`{b}` and :samp:`{a}` ; + that is, :samp:`{a}` - :samp:`{b}`. + +.. function:: float __mulsf3 (float a, float b) + double __muldf3 (double a, double b) + long double __multf3 (long double a, long double b) + long double __mulxf3 (long double a, long double b) + + These functions return the product of :samp:`{a}` and :samp:`{b}`. + +.. function:: float __divsf3 (float a, float b) + double __divdf3 (double a, double b) + long double __divtf3 (long double a, long double b) + long double __divxf3 (long double a, long double b) + + These functions return the quotient of :samp:`{a}` and :samp:`{b}` ; that is, + :samp:`{a}` / :samp:`{b}`. + +.. function:: float __negsf2 (float a) + double __negdf2 (double a) + long double __negtf2 (long double a) + long double __negxf2 (long double a) + + These functions return the negation of :samp:`{a}`. They simply flip the + sign bit, so they can produce negative zero and negative NaN. + +Conversion functions +^^^^^^^^^^^^^^^^^^^^ + +.. function:: double __extendsfdf2 (float a) + long double __extendsftf2 (float a) + long double __extendsfxf2 (float a) + long double __extenddftf2 (double a) + long double __extenddfxf2 (double a) + + These functions extend :samp:`{a}` to the wider mode of their return + type. + +.. function:: double __truncxfdf2 (long double a) + double __trunctfdf2 (long double a) + float __truncxfsf2 (long double a) + float __trunctfsf2 (long double a) + float __truncdfsf2 (double a) + + These functions truncate :samp:`{a}` to the narrower mode of their return + type, rounding toward zero. + +.. function:: int __fixsfsi (float a) + int __fixdfsi (double a) + int __fixtfsi (long double a) + int __fixxfsi (long double a) + + These functions convert :samp:`{a}` to a signed integer, rounding toward zero. + +.. function:: long __fixsfdi (float a) + long __fixdfdi (double a) + long __fixtfdi (long double a) + long __fixxfdi (long double a) + + These functions convert :samp:`{a}` to a signed long, rounding toward zero. + +.. function:: long long __fixsfti (float a) + long long __fixdfti (double a) + long long __fixtfti (long double a) + long long __fixxfti (long double a) + + These functions convert :samp:`{a}` to a signed long long, rounding toward zero. + +.. function:: unsigned int __fixunssfsi (float a) + unsigned int __fixunsdfsi (double a) + unsigned int __fixunstfsi (long double a) + unsigned int __fixunsxfsi (long double a) + + These functions convert :samp:`{a}` to an unsigned integer, rounding + toward zero. Negative values all become zero. + +.. function:: unsigned long __fixunssfdi (float a) + unsigned long __fixunsdfdi (double a) + unsigned long __fixunstfdi (long double a) + unsigned long __fixunsxfdi (long double a) + + These functions convert :samp:`{a}` to an unsigned long, rounding + toward zero. Negative values all become zero. + +.. function:: unsigned long long __fixunssfti (float a) + unsigned long long __fixunsdfti (double a) + unsigned long long __fixunstfti (long double a) + unsigned long long __fixunsxfti (long double a) + + These functions convert :samp:`{a}` to an unsigned long long, rounding + toward zero. Negative values all become zero. + +.. function:: float __floatsisf (int i) + double __floatsidf (int i) + long double __floatsitf (int i) + long double __floatsixf (int i) + + These functions convert :samp:`{i}`, a signed integer, to floating point. + +.. function:: float __floatdisf (long i) + double __floatdidf (long i) + long double __floatditf (long i) + long double __floatdixf (long i) + + These functions convert :samp:`{i}`, a signed long, to floating point. + +.. function:: float __floattisf (long long i) + double __floattidf (long long i) + long double __floattitf (long long i) + long double __floattixf (long long i) + + These functions convert :samp:`{i}`, a signed long long, to floating point. + +.. function:: float __floatunsisf (unsigned int i) + double __floatunsidf (unsigned int i) + long double __floatunsitf (unsigned int i) + long double __floatunsixf (unsigned int i) + + These functions convert :samp:`{i}`, an unsigned integer, to floating point. + +.. function:: float __floatundisf (unsigned long i) + double __floatundidf (unsigned long i) + long double __floatunditf (unsigned long i) + long double __floatundixf (unsigned long i) + + These functions convert :samp:`{i}`, an unsigned long, to floating point. + +.. function:: float __floatuntisf (unsigned long long i) + double __floatuntidf (unsigned long long i) + long double __floatuntitf (unsigned long long i) + long double __floatuntixf (unsigned long long i) + + These functions convert :samp:`{i}`, an unsigned long long, to floating point. + +Comparison functions +^^^^^^^^^^^^^^^^^^^^ + +There are two sets of basic comparison functions. + +.. function:: int __cmpsf2 (float a, float b) + int __cmpdf2 (double a, double b) + int __cmptf2 (long double a, long double b) + + These functions calculate a <=> b. That is, if :samp:`{a}` is less + than :samp:`{b}`, they return -1; if :samp:`{a}` is greater than :samp:`{b}`, they + return 1; and if :samp:`{a}` and :samp:`{b}` are equal they return 0. If + either argument is NaN they return 1, but you should not rely on this; + if NaN is a possibility, use one of the higher-level comparison + functions. + +.. function:: int __unordsf2 (float a, float b) + int __unorddf2 (double a, double b) + int __unordtf2 (long double a, long double b) + + These functions return a nonzero value if either argument is NaN, otherwise 0. + +There is also a complete group of higher level functions which +correspond directly to comparison operators. They implement the ISO C +semantics for floating-point comparisons, taking NaN into account. +Pay careful attention to the return values defined for each set. +Under the hood, all of these routines are implemented as + +.. code-block:: c++ + + if (__unordXf2 (a, b)) + return E; + return __cmpXf2 (a, b); + +where :samp:`{E}` is a constant chosen to give the proper behavior for +NaN. Thus, the meaning of the return value is different for each set. +Do not rely on this implementation; only the semantics documented +below are guaranteed. + +.. function:: int __eqsf2 (float a, float b) + int __eqdf2 (double a, double b) + int __eqtf2 (long double a, long double b) + + These functions return zero if neither argument is NaN, and :samp:`{a}` and + :samp:`{b}` are equal. + +.. function:: int __nesf2 (float a, float b) + int __nedf2 (double a, double b) + int __netf2 (long double a, long double b) + + These functions return a nonzero value if either argument is NaN, or + if :samp:`{a}` and :samp:`{b}` are unequal. + +.. function:: int __gesf2 (float a, float b) + int __gedf2 (double a, double b) + int __getf2 (long double a, long double b) + + These functions return a value greater than or equal to zero if + neither argument is NaN, and :samp:`{a}` is greater than or equal to + :samp:`{b}`. + +.. function:: int __ltsf2 (float a, float b) + int __ltdf2 (double a, double b) + int __lttf2 (long double a, long double b) + + These functions return a value less than zero if neither argument is + NaN, and :samp:`{a}` is strictly less than :samp:`{b}`. + +.. function:: int __lesf2 (float a, float b) + int __ledf2 (double a, double b) + int __letf2 (long double a, long double b) + + These functions return a value less than or equal to zero if neither + argument is NaN, and :samp:`{a}` is less than or equal to :samp:`{b}`. + +.. function:: int __gtsf2 (float a, float b) + int __gtdf2 (double a, double b) + int __gttf2 (long double a, long double b) + + These functions return a value greater than zero if neither argument + is NaN, and :samp:`{a}` is strictly greater than :samp:`{b}`. + +Other floating-point functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: float __powisf2 (float a, int b) + double __powidf2 (double a, int b) + long double __powitf2 (long double a, int b) + long double __powixf2 (long double a, int b) + + These functions convert raise :samp:`{a}` to the power :samp:`{b}`. + +.. function:: complex float __mulsc3 (float a, float b, float c, float d) + complex double __muldc3 (double a, double b, double c, double d) + complex long double __multc3 (long double a, long double b, long double c, long double d) + complex long double __mulxc3 (long double a, long double b, long double c, long double d) + + These functions return the product of :samp:`{a}` + i :samp:`{b}` and + :samp:`{c}` + i :samp:`{d}`, following the rules of C99 Annex G. + +.. function:: complex float __divsc3 (float a, float b, float c, float d) + complex double __divdc3 (double a, double b, double c, double d) + complex long double __divtc3 (long double a, long double b, long double c, long double d) + complex long double __divxc3 (long double a, long double b, long double c, long double d) + + These functions return the quotient of :samp:`{a}` + i :samp:`{b}` and + :samp:`{c}` + i :samp:`{d}` (i.e., (:samp:`{a}` + i :samp:`{b}`) / (:samp:`{c}` + + i :samp:`{d}`)), following the rules of C99 Annex G. \ No newline at end of file diff --git a/gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-integer-arithmetic.rst b/gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-integer-arithmetic.rst new file mode 100644 index 00000000000..a43181b102d --- /dev/null +++ b/gcc/doc/gccint/the-gcc-low-level-runtime-library/routines-for-integer-arithmetic.rst @@ -0,0 +1,183 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _integer-library-routines: + +Routines for integer arithmetic +******************************* + +The integer arithmetic routines are used on platforms that don't provide +hardware support for arithmetic operations on some modes. + +Arithmetic functions +^^^^^^^^^^^^^^^^^^^^ + +.. function:: int __ashlsi3 (int a, int b) + long __ashldi3 (long a, int b) + long long __ashlti3 (long long a, int b) + + These functions return the result of shifting :samp:`{a}` left by :samp:`{b}` bits. + +.. function:: int __ashrsi3 (int a, int b) + long __ashrdi3 (long a, int b) + long long __ashrti3 (long long a, int b) + + These functions return the result of arithmetically shifting :samp:`{a}` right + by :samp:`{b}` bits. + +.. function:: int __divsi3 (int a, int b) + long __divdi3 (long a, long b) + long long __divti3 (long long a, long long b) + + These functions return the quotient of the signed division of :samp:`{a}` and + :samp:`{b}`. + +.. function:: int __lshrsi3 (int a, int b) + long __lshrdi3 (long a, int b) + long long __lshrti3 (long long a, int b) + + These functions return the result of logically shifting :samp:`{a}` right by + :samp:`{b}` bits. + +.. function:: int __modsi3 (int a, int b) + long __moddi3 (long a, long b) + long long __modti3 (long long a, long long b) + + These functions return the remainder of the signed division of :samp:`{a}` + and :samp:`{b}`. + +.. function:: int __mulsi3 (int a, int b) + long __muldi3 (long a, long b) + long long __multi3 (long long a, long long b) + + These functions return the product of :samp:`{a}` and :samp:`{b}`. + +.. function:: long __negdi2 (long a) + long long __negti2 (long long a) + + These functions return the negation of :samp:`{a}`. + +.. function:: unsigned int __udivsi3 (unsigned int a, unsigned int b) + unsigned long __udivdi3 (unsigned long a, unsigned long b) + unsigned long long __udivti3 (unsigned long long a, unsigned long long b) + + These functions return the quotient of the unsigned division of :samp:`{a}` + and :samp:`{b}`. + +.. function:: unsigned long __udivmoddi4 (unsigned long a, unsigned long b, unsigned long *c) + unsigned long long __udivmodti4 (unsigned long long a, unsigned long long b, unsigned long long *c) + + These functions calculate both the quotient and remainder of the unsigned + division of :samp:`{a}` and :samp:`{b}`. The return value is the quotient, and + the remainder is placed in variable pointed to by :samp:`{c}`. + +.. function:: unsigned int __umodsi3 (unsigned int a, unsigned int b) + unsigned long __umoddi3 (unsigned long a, unsigned long b) + unsigned long long __umodti3 (unsigned long long a, unsigned long long b) + + These functions return the remainder of the unsigned division of :samp:`{a}` + and :samp:`{b}`. + +Comparison functions +^^^^^^^^^^^^^^^^^^^^ + +The following functions implement integral comparisons. These functions +implement a low-level compare, upon which the higher level comparison +operators (such as less than and greater than or equal to) can be +constructed. The returned values lie in the range zero to two, to allow +the high-level operators to be implemented by testing the returned +result using either signed or unsigned comparison. + +.. function:: int __cmpdi2 (long a, long b) + int __cmpti2 (long long a, long long b) + + These functions perform a signed comparison of :samp:`{a}` and :samp:`{b}`. If + :samp:`{a}` is less than :samp:`{b}`, they return 0; if :samp:`{a}` is greater than + :samp:`{b}`, they return 2; and if :samp:`{a}` and :samp:`{b}` are equal they return 1. + +.. function:: int __ucmpdi2 (unsigned long a, unsigned long b) + int __ucmpti2 (unsigned long long a, unsigned long long b) + + These functions perform an unsigned comparison of :samp:`{a}` and :samp:`{b}`. + If :samp:`{a}` is less than :samp:`{b}`, they return 0; if :samp:`{a}` is greater than + :samp:`{b}`, they return 2; and if :samp:`{a}` and :samp:`{b}` are equal they return 1. + +Trapping arithmetic functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following functions implement trapping arithmetic. These functions +call the libc function ``abort`` upon signed arithmetic overflow. + +.. function:: int __absvsi2 (int a) + long __absvdi2 (long a) + + These functions return the absolute value of :samp:`{a}`. + +.. function:: int __addvsi3 (int a, int b) + long __addvdi3 (long a, long b) + + These functions return the sum of :samp:`{a}` and :samp:`{b}` ; that is + ``a + b``. + +.. function:: int __mulvsi3 (int a, int b) + long __mulvdi3 (long a, long b) + + The functions return the product of :samp:`{a}` and :samp:`{b}` ; that is + ``a * b``. + +.. function:: int __negvsi2 (int a) + long __negvdi2 (long a) + + These functions return the negation of :samp:`{a}` ; that is ``-a``. + +.. function:: int __subvsi3 (int a, int b) + long __subvdi3 (long a, long b) + + These functions return the difference between :samp:`{b}` and :samp:`{a}` ; + that is ``a - b``. + +Bit operations +^^^^^^^^^^^^^^ + +.. function:: int __clzsi2 (unsigned int a) + int __clzdi2 (unsigned long a) + int __clzti2 (unsigned long long a) + + These functions return the number of leading 0-bits in :samp:`{a}`, starting + at the most significant bit position. If :samp:`{a}` is zero, the result is + undefined. + +.. function:: int __ctzsi2 (unsigned int a) + int __ctzdi2 (unsigned long a) + int __ctzti2 (unsigned long long a) + + These functions return the number of trailing 0-bits in :samp:`{a}`, starting + at the least significant bit position. If :samp:`{a}` is zero, the result is + undefined. + +.. function:: int __ffsdi2 (unsigned long a) + int __ffsti2 (unsigned long long a) + + These functions return the index of the least significant 1-bit in :samp:`{a}`, + or the value zero if :samp:`{a}` is zero. The least significant bit is index + one. + +.. function:: int __paritysi2 (unsigned int a) + int __paritydi2 (unsigned long a) + int __parityti2 (unsigned long long a) + + These functions return the value zero if the number of bits set in + :samp:`{a}` is even, and the value one otherwise. + +.. function:: int __popcountsi2 (unsigned int a) + int __popcountdi2 (unsigned long a) + int __popcountti2 (unsigned long long a) + + These functions return the number of bits set in :samp:`{a}`. + +.. function:: int32_t __bswapsi2 (int32_t a) + int64_t __bswapdi2 (int64_t a) + + These functions return the :samp:`{a}` byteswapped. \ No newline at end of file diff --git a/gcc/doc/gccint/the-language.rst b/gcc/doc/gccint/the-language.rst new file mode 100644 index 00000000000..b7ab5508512 --- /dev/null +++ b/gcc/doc/gccint/the-language.rst @@ -0,0 +1,384 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: The Language + +.. _the-language: + +The Language +************ + +The language in which to write expression simplifications resembles +other domain-specific languages GCC uses. Thus it is lispy. Let's +start with an example from the match.pd file: + +.. code-block:: + + (simplify + (bit_and @0 integer_all_onesp) + @0) + +This example contains all required parts of an expression simplification. +A simplification is wrapped inside a ``(simplify ...)`` expression. +That contains at least two operands - an expression that is matched +with the GIMPLE or GENERIC IL and a replacement expression that is +returned if the match was successful. + +Expressions have an operator ID, ``bit_and`` in this case. Expressions can +be lower-case tree codes with ``_expr`` stripped off or builtin +function code names in all-caps, like ``BUILT_IN_SQRT``. + +``@n`` denotes a so-called capture. It captures the operand and lets +you refer to it in other places of the match-and-simplify. In the +above example it is referred to in the replacement expression. Captures +are ``@`` followed by a number or an identifier. + +.. code-block:: + + (simplify + (bit_xor @0 @0) + { build_zero_cst (type); }) + +In this example ``@0`` is mentioned twice which constrains the matched +expression to have two equal operands. Usually matches are constrained +to equal types. If operands may be constants and conversions are involved, +matching by value might be preferred in which case use ``@@0`` to +denote a by-value match and the specific operand you want to refer to +in the result part. This example also introduces +operands written in C code. These can be used in the expression +replacements and are supposed to evaluate to a tree node which has to +be a valid GIMPLE operand (so you cannot generate expressions in C code). + +.. code-block:: + + (simplify + (trunc_mod integer_zerop@0 @1) + (if (!integer_zerop (@1)) + @0)) + +Here ``@0`` captures the first operand of the trunc_mod expression +which is also predicated with ``integer_zerop``. Expression operands +may be either expressions, predicates or captures. Captures +can be unconstrained or capture expressions or predicates. + +This example introduces an optional operand of simplify, +the if-expression. This condition is evaluated after the +expression matched in the IL and is required to evaluate to true +to enable the replacement expression in the second operand +position. The expression operand of the ``if`` is a standard C +expression which may contain references to captures. The ``if`` +has an optional third operand which may contain the replacement +expression that is enabled when the condition evaluates to false. + +A ``if`` expression can be used to specify a common condition +for multiple simplify patterns, avoiding the need +to repeat that multiple times: + +.. code-block:: + + (if (!TYPE_SATURATING (type) + && !FLOAT_TYPE_P (type) && !FIXED_POINT_TYPE_P (type)) + (simplify + (minus (plus @0 @1) @0) + @1) + (simplify + (minus (minus @0 @1) @0) + (negate @1))) + +Note that ``if`` s in outer position do not have the optional +else clause but instead have multiple then clauses. + +Ifs can be nested. + +There exists a ``switch`` expression which can be used to +chain conditions avoiding nesting ``if`` s too much: + +.. code-block:: + + (simplify + (simple_comparison @0 REAL_CST@1) + (switch + /* a CMP (-0) -> a CMP 0 */ + (if (REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (@1))) + (cmp @0 { build_real (TREE_TYPE (@1), dconst0); })) + /* x != NaN is always true, other ops are always false. */ + (if (REAL_VALUE_ISNAN (TREE_REAL_CST (@1)) + && ! HONOR_SNANS (@1)) + { constant_boolean_node (cmp == NE_EXPR, type); }))) + +Is equal to + +.. code-block:: + + (simplify + (simple_comparison @0 REAL_CST@1) + (switch + /* a CMP (-0) -> a CMP 0 */ + (if (REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (@1))) + (cmp @0 { build_real (TREE_TYPE (@1), dconst0); }) + /* x != NaN is always true, other ops are always false. */ + (if (REAL_VALUE_ISNAN (TREE_REAL_CST (@1)) + && ! HONOR_SNANS (@1)) + { constant_boolean_node (cmp == NE_EXPR, type); })))) + +which has the second ``if`` in the else operand of the first. +The ``switch`` expression takes ``if`` expressions as +operands (which may not have else clauses) and as a last operand +a replacement expression which should be enabled by default if +no other condition evaluated to true. + +Captures can also be used for capturing results of sub-expressions. + +.. code-block:: + + #if GIMPLE + (simplify + (pointer_plus (addr@2 @0) INTEGER_CST_P@1) + (if (is_gimple_min_invariant (@2))) + { + poly_int64 off; + tree base = get_addr_base_and_unit_offset (@0, &off); + off += tree_to_uhwi (@1); + /* Now with that we should be able to simply write + (addr (mem_ref (addr @base) (plus @off @1))) */ + build1 (ADDR_EXPR, type, + build2 (MEM_REF, TREE_TYPE (TREE_TYPE (@2)), + build_fold_addr_expr (base), + build_int_cst (ptr_type_node, off))); + }) + #endif + +In the above example, ``@2`` captures the result of the expression +``(addr @0)``. For the outermost expression only its type can be +captured, and the keyword ``type`` is reserved for this purpose. The +above example also gives a way to conditionalize patterns to only apply +to ``GIMPLE`` or ``GENERIC`` by means of using the pre-defined +preprocessor macros ``GIMPLE`` and ``GENERIC`` and using +preprocessor directives. + +.. code-block:: + + (simplify + (bit_and:c integral_op_p@0 (bit_ior:c (bit_not @0) @1)) + (bit_and @1 @0)) + +Here we introduce flags on match expressions. The flag used +above, ``c``, denotes that the expression should +be also matched commutated. Thus the above match expression +is really the following four match expressions: + +.. code-block:: + + (bit_and integral_op_p@0 (bit_ior (bit_not @0) @1)) + (bit_and (bit_ior (bit_not @0) @1) integral_op_p@0) + (bit_and integral_op_p@0 (bit_ior @1 (bit_not @0))) + (bit_and (bit_ior @1 (bit_not @0)) integral_op_p@0) + +Usual canonicalizations you know from GENERIC expressions are +applied before matching, so for example constant operands always +come second in commutative expressions. + +The second supported flag is ``s`` which tells the code +generator to fail the pattern if the expression marked with +``s`` does have more than one use and the simplification +results in an expression with more than one operator. +For example in + +.. code-block:: + + (simplify + (pointer_plus (pointer_plus:s @0 @1) @3) + (pointer_plus @0 (plus @1 @3))) + +this avoids the association if ``(pointer_plus @0 @1)`` is +used outside of the matched expression and thus it would stay +live and not trivially removed by dead code elimination. +Now consider ``((x + 3) + -3)`` with the temporary +holding ``(x + 3)`` used elsewhere. This simplifies down +to ``x`` which is desirable and thus flagging with ``s`` +does not prevent the transform. Now consider ``((x + 3) + 1)`` +which simplifies to ``(x + 4)``. Despite being flagged with +``s`` the simplification will be performed. The +simplification of ``((x + a) + 1)`` to ``(x + (a + 1))`` will +not performed in this case though. + +More features exist to avoid too much repetition. + +.. code-block:: + + (for op (plus pointer_plus minus bit_ior bit_xor) + (simplify + (op @0 integer_zerop) + @0)) + +A ``for`` expression can be used to repeat a pattern for each +operator specified, substituting ``op``. ``for`` can be +nested and a ``for`` can have multiple operators to iterate. + +.. code-block:: + + (for opa (plus minus) + opb (minus plus) + (for opc (plus minus) + (simplify... + +In this example the pattern will be repeated four times with +``opa, opb, opc`` being ``plus, minus, plus`` ; +``plus, minus, minus`` ; ``minus, plus, plus`` ; +``minus, plus, minus``. + +To avoid repeating operator lists in ``for`` you can name +them via + +.. code-block:: c++ + + (define_operator_list pmm plus minus mult) + +and use them in ``for`` operator lists where they get expanded. + +.. code-block:: c++ + + (for opa (pmm trunc_div) + (simplify... + +So this example iterates over ``plus``, ``minus``, ``mult`` +and ``trunc_div``. + +Using operator lists can also remove the need to explicitly write +a ``for``. All operator list uses that appear in a ``simplify`` +or ``match`` pattern in operator positions will implicitly +be added to a new ``for``. For example + +.. code-block:: + + (define_operator_list SQRT BUILT_IN_SQRTF BUILT_IN_SQRT BUILT_IN_SQRTL) + (define_operator_list POW BUILT_IN_POWF BUILT_IN_POW BUILT_IN_POWL) + (simplify + (SQRT (POW @0 @1)) + (POW (abs @0) (mult @1 { built_real (TREE_TYPE (@1), dconsthalf); }))) + +is the same as + +.. code-block:: + + (for SQRT (BUILT_IN_SQRTF BUILT_IN_SQRT BUILT_IN_SQRTL) + POW (BUILT_IN_POWF BUILT_IN_POW BUILT_IN_POWL) + (simplify + (SQRT (POW @0 @1)) + (POW (abs @0) (mult @1 { built_real (TREE_TYPE (@1), dconsthalf); })))) + +``for`` s and operator lists can include the special identifier +``null`` that matches nothing and can never be generated. This can +be used to pad an operator list so that it has a standard form, +even if there isn't a suitable operator for every form. + +Another building block are ``with`` expressions in the +result expression which nest the generated code in a new C block +followed by its argument: + +.. code-block:: + + (simplify + (convert (mult @0 @1)) + (with { tree utype = unsigned_type_for (type); } + (convert (mult (convert:utype @0) (convert:utype @1))))) + +This allows code nested in the ``with`` to refer to the declared +variables. In the above case we use the feature to specify the +type of a generated expression with the ``:type`` syntax where +``type`` needs to be an identifier that refers to the desired type. +Usually the types of the generated result expressions are +determined from the context, but sometimes like in the above case +it is required that you specify them explicitly. + +Another modifier for generated expressions is ``!`` which +tells the machinery to only consider the simplification in case +the marked expression simplified to a simple operand. Consider +for example + +.. code-block:: + + (simplify + (plus (vec_cond:s @0 @1 @2) @3) + (vec_cond @0 (plus! @1 @3) (plus! @2 @3))) + +which moves the outer ``plus`` operation to the inner arms +of the ``vec_cond`` expression but only if the actual plus +operations both simplify. Note that on ``GENERIC`` a simple +operand means that the result satisfies ``!EXPR_P`` which +can be limiting if the operation itself simplifies but the +remaining operand is an (unrelated) expression. + +As intermediate conversions are often optional there is a way to +avoid the need to repeat patterns both with and without such +conversions. Namely you can mark a conversion as being optional +with a ``?`` : + +.. code-block:: + + (simplify + (eq (convert@0 @1) (convert? @2)) + (eq @1 (convert @2))) + +which will match both ``(eq (convert @1) (convert @2))`` and +``(eq (convert @1) @2)``. The optional converts are supposed +to be all either present or not, thus +``(eq (convert? @1) (convert? @2))`` will result in two +patterns only. If you want to match all four combinations you +have access to two additional conditional converts as in +``(eq (convert1? @1) (convert2? @2))``. + +The support for ``?`` marking extends to all unary operations +including predicates you declare yourself with ``match``. + +Predicates available from the GCC middle-end need to be made +available explicitly via ``define_predicates`` : + +.. code-block:: + + (define_predicates + integer_onep integer_zerop integer_all_onesp) + +You can also define predicates using the pattern matching language +and the ``match`` form: + +.. code-block:: + + (match negate_expr_p + INTEGER_CST + (if (TYPE_OVERFLOW_WRAPS (type) + || may_negate_without_overflow_p (t)))) + (match negate_expr_p + (negate @0)) + +This shows that for ``match`` expressions there is ``t`` +available which captures the outermost expression (something +not possible in the ``simplify`` context). As you can see +``match`` has an identifier as first operand which is how +you refer to the predicate in patterns. Multiple ``match`` +for the same identifier add additional cases where the predicate +matches. + +Predicates can also match an expression in which case you need +to provide a template specifying the identifier and where to +get its operands from: + +.. code-block:: + + (match (logical_inverted_value @0) + (eq @0 integer_zerop)) + (match (logical_inverted_value @0) + (bit_not truth_valued_p@0)) + +You can use the above predicate like + +.. code-block:: + + (simplify + (bit_and @0 (logical_inverted_value @0)) + { build_zero_cst (type); }) + +Which will match a bitwise and of an operand with its logical +inverted value. \ No newline at end of file diff --git a/gcc/doc/gccint/user-experience-guidelines.rst b/gcc/doc/gccint/user-experience-guidelines.rst new file mode 100644 index 00000000000..18183807637 --- /dev/null +++ b/gcc/doc/gccint/user-experience-guidelines.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: user experience guidelines, guidelines, user experience + +.. _user-experience-guidelines: + +User Experience Guidelines +-------------------------- + +To borrow a slogan from +`Elm `_, + +**Compilers should be assistants, not adversaries.** A compiler should +not just detect bugs, it should then help you understand why there is a bug. +It should not berate you in a robot voice, it should give you specific hints +that help you write better code. Ultimately, a compiler should make +programming faster and more fun! +Evan Czaplicki + +This chapter provides guidelines on how to implement diagnostics and +command-line options in ways that we hope achieve the above ideal. + +.. toctree:: + :maxdepth: 2 + + guidelines-for-diagnostics + guidelines-for-options \ No newline at end of file diff --git a/gcc/doc/install/binaries.rst b/gcc/doc/install/binaries.rst new file mode 100644 index 00000000000..5144c3faf44 --- /dev/null +++ b/gcc/doc/install/binaries.rst @@ -0,0 +1,54 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Binaries, Binaries + +.. _binaries: + +Binaries +-------- + +We are often asked about pre-compiled versions of GCC. While we cannot +provide these for all platforms, below you'll find links to binaries for +various platforms where creating them by yourself is not easy due to various +reasons. + +Please note that we did not create these binaries, nor do we +support them. If you have any problems installing them, please +contact their makers. + +* AIX: + + * `AIX Open Source Packages (AIX5L AIX 6.1 + AIX 7.1) `_. + +* DOS---`DJGPP `_. + +* HP-UX: + + * `HP-UX Porting Center `_; + +* Solaris 2 (SPARC, Intel): + + * `OpenCSW `_ + +* macOS: + + * The `Homebrew `_ package manager; + + * `MacPorts `_. + +* Microsoft Windows: + + * The `Cygwin `_ project; + + * The `MinGW `_ and + `mingw-w64 `_ projects. + +* `OpenPKG `_ offers binaries for quite a + number of platforms. + +* The `GFortran Wiki `_ has + links to GNU Fortran binaries for several platforms. \ No newline at end of file diff --git a/gcc/doc/install/building.rst b/gcc/doc/install/building.rst new file mode 100644 index 00000000000..6e0b5870e64 --- /dev/null +++ b/gcc/doc/install/building.rst @@ -0,0 +1,67 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Building + +.. _building: + +Building +-------- + +Now that GCC is configured, you are ready to build the compiler and +runtime libraries. + +Some commands executed when making the compiler may fail (return a +nonzero status) and be ignored by :command:`make`. These failures, which +are often due to files that were not found, are expected, and can safely +be ignored. + +It is normal to have compiler warnings when compiling certain files. +Unless you are a GCC developer, you can generally ignore these warnings +unless they cause compilation to fail. Developers should attempt to fix +any warnings encountered, however they can temporarily continue past +warnings-as-errors by specifying the configure flag +:option:`--disable-werror`. + +On certain old systems, defining certain environment variables such as +:envvar:`CC` can interfere with the functioning of :command:`make`. + +If you encounter seemingly strange errors when trying to build the +compiler in a directory other than the source directory, it could be +because you have previously configured the compiler in the source +directory. Make sure you have done all the necessary preparations. + +If you build GCC on a BSD system using a directory stored in an old System +V file system, problems may occur in running :command:`fixincludes` if the +System V file system doesn't support symbolic links. These problems +result in a failure to fix the declaration of ``size_t`` in +:samp:`sys/types.h`. If you find that ``size_t`` is a signed type and +that type mismatches occur, this could be the cause. + +The solution is not to use such a directory for building GCC. + +Similarly, when building from the source repository or snapshots, or if you modify +:samp:`*.l` files, you need the Flex lexical analyzer generator +installed. If you do not modify :samp:`*.l` files, releases contain +the Flex-generated files and you do not need Flex installed to build +them. There is still one Flex-based lexical analyzer (part of the +build machinery, not of GCC itself) that is used even if you only +build the C front end. + +When building from the source repository or snapshots, or if you modify +a manual page (an info page) documentation, you need version |needs_sphinx| or later +of Sphinx if you want man pages (or info documentation) to be regenerated. +Releases contain manual pages and +info documentation pre-built for the unmodified documentation in the release. + +.. toctree:: + :maxdepth: 2 + + building/building-a-native-compiler + building/building-a-cross-compiler + building/building-in-parallel + building/building-the-ada-compiler + building/building-the-d-compiler + building/building-with-profile-feedback \ No newline at end of file diff --git a/gcc/doc/install/building/building-a-cross-compiler.rst b/gcc/doc/install/building/building-a-cross-compiler.rst new file mode 100644 index 00000000000..c3fa1ce55f4 --- /dev/null +++ b/gcc/doc/install/building/building-a-cross-compiler.rst @@ -0,0 +1,74 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Building a cross compiler +************************* + +When building a cross compiler, it is not generally possible to do a +3-stage bootstrap of the compiler. This makes for an interesting problem +as parts of GCC can only be built with GCC. + +To build a cross compiler, we recommend first building and installing a +native compiler. You can then use the native GCC compiler to build the +cross compiler. The installed native compiler needs to be GCC version +2.95 or later. + +Assuming you have already installed a native copy of GCC and configured +your cross compiler, issue the command :command:`make`, which performs the +following steps: + +* Build host tools necessary to build the compiler. + +* Build target tools for use by the compiler such as binutils (bfd, + binutils, gas, gprof, ld, and opcodes) + if they have been individually linked or moved into the top level GCC source + tree before configuring. + +* Build the compiler (single stage only). + +* Build runtime libraries using the compiler from the previous step. + +Note that if an error occurs in any step the make process will exit. + +If you are not building GNU binutils in the same source tree as GCC, +you will need a cross-assembler and cross-linker installed before +configuring GCC. Put them in the directory +:samp:`{prefix}/{target}/bin`. Here is a table of the tools +you should put in this directory: + +:samp:`as` + This should be the cross-assembler. + +:samp:`ld` + This should be the cross-linker. + +:samp:`ar` + This should be the cross-archiver: a program which can manipulate + archive files (linker libraries) in the target machine's format. + +:samp:`ranlib` + This should be a program to construct a symbol table in an archive file. + +The installation of GCC will find these programs in that directory, +and copy or link them to the proper place to for the cross-compiler to +find them when run later. + +The easiest way to provide these files is to build the Binutils package. +Configure it with the same :option:`--host` and :option:`--target` +options that you use for configuring GCC, then build and install +them. They install their executables automatically into the proper +directory. Alas, they do not support all the targets that GCC +supports. + +If you are not building a C library in the same source tree as GCC, +you should also provide the target libraries and headers before +configuring GCC, specifying the directories with +:option:`--with-sysroot` or :option:`--with-headers` and +:option:`--with-libs`. Many targets also require 'start files' such +as :samp:`crt0.o` and +:samp:`crtn.o` which are linked into each executable. There may be several +alternatives for :samp:`crt0.o`, for use with profiling or other +compilation options. Check your target's definition of +``STARTFILE_SPEC`` to find out what start files it uses. \ No newline at end of file diff --git a/gcc/doc/install/building/building-a-native-compiler.rst b/gcc/doc/install/building/building-a-native-compiler.rst new file mode 100644 index 00000000000..c2276c9c83b --- /dev/null +++ b/gcc/doc/install/building/building-a-native-compiler.rst @@ -0,0 +1,191 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Building a native compiler +************************** + +For a native build, the default configuration is to perform +a 3-stage bootstrap of the compiler when :samp:`make` is invoked. +This will build the entire GCC system and ensure that it compiles +itself correctly. It can be disabled with the :option:`--disable-bootstrap` +parameter to :samp:`configure`, but bootstrapping is suggested because +the compiler will be tested more completely and could also have +better performance. + +The bootstrapping process will complete the following steps: + +* Build tools necessary to build the compiler. + +* Perform a 3-stage bootstrap of the compiler. This includes building + three times the target tools for use by the compiler such as binutils + (bfd, binutils, gas, gprof, ld, and opcodes) if they have been + individually linked or moved into the top level GCC source tree before + configuring. + +* Perform a comparison test of the stage2 and stage3 compilers. + +* Build runtime libraries using the stage3 compiler from the previous step. + +If you are short on disk space you might consider :samp:`make +bootstrap-lean` instead. The sequence of compilation is the +same described above, but object files from the stage1 and +stage2 of the 3-stage bootstrap of the compiler are deleted as +soon as they are no longer needed. + +If you wish to use non-default GCC flags when compiling the stage2 +and stage3 compilers, set ``BOOT_CFLAGS`` on the command line when +doing :samp:`make`. For example, if you want to save additional space +during the bootstrap and in the final installation as well, you can +build the compiler binaries without debugging information as in the +following example. This will save roughly 40% of disk space both for +the bootstrap and the final installation. (Libraries will still contain +debugging information.) + +.. code-block:: bash + + make BOOT_CFLAGS='-O' bootstrap + +You can place non-default optimization flags into ``BOOT_CFLAGS`` ; they +are less well tested here than the default of :samp:`-g -O2`, but should +still work. In a few cases, you may find that you need to specify special +flags such as :option:`-msoft-float` here to complete the bootstrap; or, +if the native compiler miscompiles the stage1 compiler, you may need +to work around this, by choosing ``BOOT_CFLAGS`` to avoid the parts +of the stage1 compiler that were miscompiled, or by using :samp:`make +bootstrap4` to increase the number of stages of bootstrap. + +``BOOT_CFLAGS`` does not apply to bootstrapped target libraries. +Since these are always compiled with the compiler currently being +bootstrapped, you can use ``CFLAGS_FOR_TARGET`` to modify their +compilation flags, as for non-bootstrapped target libraries. +Again, if the native compiler miscompiles the stage1 compiler, you may +need to work around this by avoiding non-working parts of the stage1 +compiler. Use ``STAGE1_TFLAGS`` to this end. + +If you used the flag :option:`--enable-languages=...` to restrict +the compilers to be built, only those you've actually enabled will be +built. This will of course only build those runtime libraries, for +which the particular compiler has been built. Please note, +that re-defining :envvar:`LANGUAGES` when calling :samp:`make` +**does not** work anymore! + +If the comparison of stage2 and stage3 fails, this normally indicates +that the stage2 compiler has compiled GCC incorrectly, and is therefore +a potentially serious bug which you should investigate and report. (On +a few systems, meaningful comparison of object files is impossible; they +always appear 'different'. If you encounter this problem, you will +need to disable comparison in the :samp:`Makefile`.) + +If you do not want to bootstrap your compiler, you can configure with +:option:`--disable-bootstrap`. In particular cases, you may want to +bootstrap your compiler even if the target system is not the same as +the one you are building on: for example, you could build a +``powerpc-unknown-linux-gnu`` toolchain on a +``powerpc64-unknown-linux-gnu`` host. In this case, pass +:option:`--enable-bootstrap` to the configure script. + +``BUILD_CONFIG`` can be used to bring in additional customization +to the build. It can be set to a whitespace-separated list of names. +For each such ``NAME``, top-level :samp:`config/ ``NAME``.mk` will +be included by the top-level :samp:`Makefile`, bringing in any settings +it contains. The default ``BUILD_CONFIG`` can be set using the +configure option :option:`--with-build-config=NAME...`. Some +examples of supported build configurations are: + +bootstrap-O1 + Removes any :option:`-O` -started option from ``BOOT_CFLAGS``, and adds + :option:`-O1` to it. :samp:`BUILD_CONFIG=bootstrap-O1` is equivalent to + :samp:`BOOT_CFLAGS='-g -O1'`. + +bootstrap-O3 bootstrap-Og + Analogous to ``bootstrap-O1``. + +bootstrap-lto + Enables Link-Time Optimization for host tools during bootstrapping. + :samp:`BUILD_CONFIG=bootstrap-lto` is equivalent to adding + :option:`-flto` to :samp:`BOOT_CFLAGS`. This option assumes that the host + supports the linker plugin (e.g. GNU ld version 2.21 or later or GNU gold + version 2.21 or later). + +bootstrap-lto-noplugin + This option is similar to ``bootstrap-lto``, but is intended for + hosts that do not support the linker plugin. Without the linker plugin + static libraries are not compiled with link-time optimizations. Since + the GCC middle end and back end are in :samp:`libbackend.a` this means + that only the front end is actually LTO optimized. + +bootstrap-lto-lean + This option is similar to ``bootstrap-lto``, but is intended for + faster build by only using LTO in the final bootstrap stage. + With :samp:`make profiledbootstrap` the LTO frontend + is trained only on generator files. + +bootstrap-debug + Verifies that the compiler generates the same executable code, whether + or not it is asked to emit debug information. To this end, this + option builds stage2 host programs without debug information, and uses + :samp:`contrib/compare-debug` to compare them with the stripped stage3 + object files. If ``BOOT_CFLAGS`` is overridden so as to not enable + debug information, stage2 will have it, and stage3 won't. This option + is enabled by default when GCC bootstrapping is enabled, if + ``strip`` can turn object files compiled with and without debug + info into identical object files. In addition to better test + coverage, this option makes default bootstraps faster and leaner. + +bootstrap-debug-big + Rather than comparing stripped object files, as in + ``bootstrap-debug``, this option saves internal compiler dumps + during stage2 and stage3 and compares them as well, which helps catch + additional potential problems, but at a great cost in terms of disk + space. It can be specified in addition to :samp:`bootstrap-debug`. + +bootstrap-debug-lean + This option saves disk space compared with ``bootstrap-debug-big``, + but at the expense of some recompilation. Instead of saving the dumps + of stage2 and stage3 until the final compare, it uses + :option:`-fcompare-debug` to generate, compare and remove the dumps + during stage3, repeating the compilation that already took place in + stage2, whose dumps were not saved. + +bootstrap-debug-lib + This option tests executable code invariance over debug information + generation on target libraries, just like ``bootstrap-debug-lean`` + tests it on host programs. It builds stage3 libraries with + :option:`-fcompare-debug`, and it can be used along with any of the + ``bootstrap-debug`` options above. + + There aren't ``-lean`` or ``-big`` counterparts to this option + because most libraries are only build in stage3, so bootstrap compares + would not get significant coverage. Moreover, the few libraries built + in stage2 are used in stage3 host programs, so we wouldn't want to + compile stage2 libraries with different options for comparison purposes. + +bootstrap-debug-ckovw + Arranges for error messages to be issued if the compiler built on any + stage is run without the option :option:`-fcompare-debug`. This is + useful to verify the full :option:`-fcompare-debug` testing coverage. It + must be used along with ``bootstrap-debug-lean`` and + ``bootstrap-debug-lib``. + +bootstrap-cet + This option enables Intel CET for host tools during bootstrapping. + :samp:`BUILD_CONFIG=bootstrap-cet` is equivalent to adding + :option:`-fcf-protection` to :samp:`BOOT_CFLAGS`. This option + assumes that the host supports Intel CET (e.g. GNU assembler version + 2.30 or later). + +bootstrap-time + Arranges for the run time of each program started by the GCC driver, + built in any stage, to be logged to :samp:`time.log`, in the top level of + the build tree. + +bootstrap-asan + Compiles GCC itself using Address Sanitization in order to catch invalid memory + accesses within the GCC code. + +bootstrap-hwasan + Compiles GCC itself using HWAddress Sanitization in order to catch invalid + memory accesses within the GCC code. This option is only available on AArch64 + systems that are running Linux kernel version 5.4 or later. \ No newline at end of file diff --git a/gcc/doc/install/building/building-in-parallel.rst b/gcc/doc/install/building/building-in-parallel.rst new file mode 100644 index 00000000000..1c5024a24e3 --- /dev/null +++ b/gcc/doc/install/building/building-in-parallel.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Building in parallel +******************** + +GNU Make 3.80 and above, which is necessary to build GCC, support +building in parallel. To activate this, you can use :samp:`make -j 2` +instead of :samp:`make`. You can also specify a bigger number, and +in most cases using a value greater than the number of processors in +your machine will result in fewer and shorter I/O latency hits, thus +improving overall throughput; this is especially true for slow drives +and network filesystems. \ No newline at end of file diff --git a/gcc/doc/install/building/building-the-ada-compiler.rst b/gcc/doc/install/building/building-the-ada-compiler.rst new file mode 100644 index 00000000000..e3875cf0cde --- /dev/null +++ b/gcc/doc/install/building/building-the-ada-compiler.rst @@ -0,0 +1,9 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Building the Ada compiler +************************* + +:ref:`GNAT `. \ No newline at end of file diff --git a/gcc/doc/install/building/building-the-d-compiler.rst b/gcc/doc/install/building/building-the-d-compiler.rst new file mode 100644 index 00000000000..0a596cf8b31 --- /dev/null +++ b/gcc/doc/install/building/building-the-d-compiler.rst @@ -0,0 +1,9 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Building the D compiler +*********************** + +:ref:`GDC `. \ No newline at end of file diff --git a/gcc/doc/install/building/building-with-profile-feedback.rst b/gcc/doc/install/building/building-with-profile-feedback.rst new file mode 100644 index 00000000000..bb02bf5fa14 --- /dev/null +++ b/gcc/doc/install/building/building-with-profile-feedback.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Building with profile feedback +****************************** + +It is possible to use profile feedback to optimize the compiler itself. This +should result in a faster compiler binary. Experiments done on x86 using gcc +3.3 showed approximately 7 percent speedup on compiling C programs. To +bootstrap the compiler with profile feedback, use ``make profiledbootstrap``. + +When :samp:`make profiledbootstrap` is run, it will first build a ``stage1`` +compiler. This compiler is used to build a ``stageprofile`` compiler +instrumented to collect execution counts of instruction and branch +probabilities. Training run is done by building ``stagetrain`` +compiler. Finally a ``stagefeedback`` compiler is built +using the information collected. + +Unlike standard bootstrap, several additional restrictions apply. The +compiler used to build ``stage1`` needs to support a 64-bit integral type. +It is recommended to only use GCC for this. + +On Linux/x86_64 hosts with some restrictions (no virtualization) it is +also possible to do autofdo build with :samp:`make +autoprofiledback`. This uses Linux perf to sample branches in the +binary and then rebuild it with feedback derived from the profile. +Linux perf and the ``autofdo`` toolkit needs to be installed for +this. + +Only the profile from the current build is used, so when an error +occurs it is recommended to clean before restarting. Otherwise +the code quality may be much worse. \ No newline at end of file diff --git a/gcc/doc/install/conf.py b/gcc/doc/install/conf.py new file mode 100644 index 00000000000..ebc1b40482b --- /dev/null +++ b/gcc/doc/install/conf.py @@ -0,0 +1,24 @@ +# Configuration file for the Sphinx documentation builder. + +import sys +sys.path.append('../../..//doc') + +from baseconf import * + +name = 'install' +project = 'GCC Installation Instructions' +copyright = '1988-2022 Free Software Foundation, Inc.' +authors = 'GCC Developer Community' + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +latex_documents = [ + ('index', f'{name}.tex', project, authors, 'manual'), +] + +texinfo_documents = [ + ('index', name, project, authors, None, None, None, True) +] + +set_common(name, globals()) \ No newline at end of file diff --git a/gcc/doc/install/configuration.rst b/gcc/doc/install/configuration.rst new file mode 100644 index 00000000000..24aaa9ed578 --- /dev/null +++ b/gcc/doc/install/configuration.rst @@ -0,0 +1,2098 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Configuration, Configuration + +.. _configuration: + +Configuration +------------- + +Like most GNU software, GCC must be configured before it can be built. +This document describes the recommended configuration procedure +for both native and cross targets. + +We use :samp:`{srcdir}` to refer to the toplevel source directory for +GCC; we use :samp:`{objdir}` to refer to the toplevel build/object directory. + +If you obtained the sources by cloning the repository, :samp:`{srcdir}` +must refer to the top :samp:`gcc` directory, the one where the +:samp:`MAINTAINERS` file can be found, and not its :samp:`gcc` +subdirectory, otherwise the build will fail. + +If either :samp:`{srcdir}` or :samp:`{objdir}` is located on an automounted NFS +file system, the shell's built-in :command:`pwd` command will return +temporary pathnames. Using these can lead to various sorts of build +problems. To avoid this issue, set the :envvar:`PWDCMD` environment +variable to an automounter-aware :command:`pwd` command, e.g., +:command:`pawd` or :samp:`amq -w`, during the configuration and build +phases. + +First, we **highly** recommend that GCC be built into a +separate directory from the sources which does **not** reside +within the source tree. This is how we generally build GCC; building +where :samp:`{srcdir}` == :samp:`{objdir}` should still work, but doesn't +get extensive testing; building where :samp:`{objdir}` is a subdirectory +of :samp:`{srcdir}` is unsupported. + +If you have previously built GCC in the same directory for a +different target machine, do :samp:`make distclean` to delete all files +that might be invalid. One of the files this deletes is :samp:`Makefile`; +if :samp:`make distclean` complains that :samp:`Makefile` does not exist +or issues a message like 'don't know how to make distclean' it probably +means that the directory is already suitably clean. However, with the +recommended method of building in a separate :samp:`{objdir}`, you should +simply use a different :samp:`{objdir}` for each target. + +Second, when configuring a native system, either :command:`cc` or +:command:`gcc` must be in your path or you must set :envvar:`CC` in +your environment before running configure. Otherwise the configuration +scripts may fail. + +Note that the bootstrap compiler and the resulting GCC must be link +compatible, else the bootstrap will fail with linker errors about +incompatible object file formats. Several multilibed targets are +affected by this requirement, see +Specific, host/target specific installation notes. +To configure GCC: + +.. code-block:: bash + + % mkdir objdir + % cd objdir + % srcdir/configure [options] [target] + +Distributor options +=================== + +If you will be distributing binary versions of GCC, with modifications +to the source code, you should use the options described in this +section to make clear that your version contains modifications. + +.. option:: --with-pkgversion=version + + Specify a string that identifies your package. You may wish + to include a build number or build date. This version string will be + included in the output of :command:`gcc --version`. This suffix does + not replace the default version string, only the :samp:`GCC` part. + + The default value is :samp:`GCC`. + +.. option:: --with-bugurl=url + + Specify the URL that users should visit if they wish to report a bug. + You are of course welcome to forward bugs reported to you to the FSF, + if you determine that they are not bugs in your modifications. + + The default value refers to the FSF's GCC bug tracker. + +.. option:: --with-documentation-root-url=url + + Specify the URL root that contains GCC option documentation. The :samp:`{url}` + should end with a ``/`` character. + + The default value is `https://gcc.gnu.org/onlinedocs/ `_. + +.. option:: --with-changes-root-url=url + + Specify the URL root that contains information about changes in GCC + releases like ``gcc-version/changes.html``. + The :samp:`{url}` should end with a ``/`` character. + + The default value is `https://gcc.gnu.org/ `_. + +Host, Build and Target specification +==================================== + +Specify the host, build and target machine configurations. You do this +when you run the :samp:`configure` script. + +The :dfn:`build` machine is the system which you are using, the +:dfn:`host` machine is the system where you want to run the resulting +compiler (normally the build machine), and the :dfn:`target` machine is +the system for which you want the compiler to generate code. + +If you are building a compiler to produce code for the machine it runs +on (a native compiler), you normally do not need to specify any operands +to :samp:`configure`; it will try to guess the type of machine you are on +and use that as the build, host and target machines. So you don't need +to specify a configuration when building a native compiler unless +:samp:`configure` cannot figure out what your configuration is or guesses +wrong. + +In those cases, specify the build machine's :dfn:`configuration name` +with the :option:`--host` option; the host and target will default to be +the same as the host machine. + +Here is an example: + +.. code-block:: bash + + ./configure --host=x86_64-pc-linux-gnu + +A configuration name may be canonical or it may be more or less +abbreviated (:samp:`config.sub` script produces canonical versions). + +A canonical configuration name has three parts, separated by dashes. +It looks like this: :samp:`{cpu}-{company}-{system}`. + +Here are the possible CPU types: + +aarch64, aarch64_be, alpha, alpha64, amdgcn, arc, arceb, arm, armeb, avr, bfin, +bpf, cris, csky, epiphany, fido, fr30, frv, ft32, h8300, hppa, hppa2.0, +hppa64, i486, i686, ia64, iq2000, lm32, loongarch64, m32c, m32r, m32rle, m68k, +mcore, microblaze, microblazeel, mips, mips64, mips64el, mips64octeon, +mips64orion, mips64vr, mipsel, mipsisa32, mipsisa32r2, mipsisa64, mipsisa64r2, +mipsisa64r2el, mipsisa64sb1, mipsisa64sr71k, mipstx39, mmix, mn10300, moxie, +msp430, nds32be, nds32le, nios2, nvptx, or1k, pdp11, powerpc, powerpc64, +powerpc64le, powerpcle, pru, riscv32, riscv32be, riscv64, riscv64be, rl78, rx, +s390, s390x, sh, shle, sparc, sparc64, tic6x, v850, +v850e, v850e1, vax, visium, x86_64, xstormy16, xtensa + +Here is a list of system types: + +aix :samp:`{version}`, amdhsa, aout, cygwin, darwin :samp:`{version}`, +eabi, eabialtivec, eabisim, eabisimaltivec, elf, elf32, +elfbare, elfoabi, freebsd :samp:`{version}`, gnu, hpux, hpux :samp:`{version}`, +kfreebsd-gnu, kopensolaris-gnu, linux-androideabi, linux-gnu, +linux-gnu_altivec, linux-musl, linux-uclibc, lynxos, mingw32, mingw32crt, +mmixware, msdosdjgpp, netbsd, netbsdelf :samp:`{version}`, nto-qnx, openbsd, +rtems, solaris :samp:`{version}`, symbianelf, tpf, uclinux, uclinux_eabi, vms, +vxworks, vxworksae, vxworksmils + +Options specification +===================== + +Use :samp:`{options}` to override several configure time options for +GCC. A list of supported :samp:`{options}` follows; :samp:`configure +--help` may list other options, but those not listed below may not +work and should not normally be used. + +Note that each :option:`--enable` option has a corresponding +:option:`--disable` option and that each :option:`--with` option has a +corresponding :option:`--without` option. + +.. option:: --prefix=dirname + + Specify the toplevel installation + directory. This is the recommended way to install the tools into a directory + other than the default. The toplevel installation directory defaults to + :samp:`/usr/local`. + + We **highly** recommend against :samp:`{dirname}` being the same or a + subdirectory of :samp:`{objdir}` or vice versa. If specifying a directory + beneath a user's home directory tree, some shells will not expand + :samp:`{dirname}` correctly if it contains the :samp:`~` metacharacter; use + :envvar:`$HOME` instead. + + The following standard :command:`autoconf` options are supported. Normally you + should not need to use these options. + + .. option:: --exec-prefix=dirname + + Specify the toplevel installation directory for architecture-dependent + files. The default is :samp:`{prefix}`. + + .. option:: --bindir=dirname + + Specify the installation directory for the executables called by users + (such as :command:`gcc` and :command:`g++`). The default is + :samp:`{exec-prefix}/bin`. + + .. option:: --libdir=dirname + + Specify the installation directory for object code libraries and + internal data files of GCC. The default is :samp:`{exec-prefix}/lib`. + + .. option:: --libexecdir=dirname + + Specify the installation directory for internal executables of GCC. + The default is :samp:`{exec-prefix}/libexec`. + + .. option:: --with-slibdir=dirname + + Specify the installation directory for the shared libgcc library. The + default is :samp:`{libdir}`. + + .. option:: --datarootdir=dirname + + Specify the root of the directory tree for read-only architecture-independent + data files referenced by GCC. The default is :samp:`{prefix}/share`. + + .. option:: --infodir=dirname + + Specify the installation directory for documentation in info format. + The default is :samp:`{datarootdir}/info`. + + .. option:: --datadir=dirname + + Specify the installation directory for some architecture-independent + data files referenced by GCC. The default is :samp:`{datarootdir}`. + + .. option:: --docdir=dirname + + Specify the installation directory for documentation files (other + than Info) for GCC. The default is :samp:`{datarootdir}/doc`. + + .. option:: --htmldir=dirname + + Specify the installation directory for HTML documentation files. + The default is :samp:`{docdir}`. + + .. option:: --pdfdir=dirname + + Specify the installation directory for PDF documentation files. + The default is :samp:`{docdir}`. + + .. option:: --mandir=dirname + + Specify the installation directory for manual pages. The default is + :samp:`{datarootdir}/man`. + + .. option:: --with-gxx-include-dir=dirname + + Specify + the installation directory for G++ header files. The default depends + on other configuration options, and differs between cross and native + configurations. + + .. option:: --with-specs=specs + + Specify additional command line driver SPECS. + This can be useful if you need to turn on a non-standard feature by + default without modifying the compiler's source code, for instance + :option:`--with-specs=%{!fcommon:%{!fno-common:-fno-common}}`. + See 'Spec Files' in the main manual + +.. option:: --program-prefix=prefix + + GCC supports some transformations of the names of its programs when + installing them. This option prepends :samp:`{prefix}` to the names of + programs to install in :samp:`{bindir}` (see above). For example, specifying + :option:`--program-prefix=foo-` would result in :samp:`gcc` + being installed as :samp:`/usr/local/bin/foo-gcc`. + +.. option:: --program-suffix=suffix + + Appends :samp:`{suffix}` to the names of programs to install in :samp:`{bindir}` + (see above). For example, specifying :option:`--program-suffix=-3.1` + would result in :samp:`gcc` being installed as + :samp:`/usr/local/bin/gcc-3.1`. + +.. option:: --program-transform-name=pattern + + Applies the :samp:`sed` script :samp:`{pattern}` to be applied to the names + of programs to install in :samp:`{bindir}` (see above). :samp:`{pattern}` has to + consist of one or more basic :samp:`sed` editing commands, separated by + semicolons. For example, if you want the :samp:`gcc` program name to be + transformed to the installed program :samp:`/usr/local/bin/myowngcc` and + the :samp:`g++` program name to be transformed to + :samp:`/usr/local/bin/gspecial++` without changing other program names, + you could use the pattern + :option:`--program-transform-name='s/^gcc$/myowngcc/; s/^g++$/gspecial++/'` + to achieve this effect. + + All three options can be combined and used together, resulting in more + complex conversion patterns. As a basic rule, :samp:`{prefix}` (and + :samp:`{suffix}`) are prepended (appended) before further transformations + can happen with a special transformation script :samp:`{pattern}`. + + As currently implemented, this option only takes effect for native + builds; cross compiler binaries' names are not transformed even when a + transformation is explicitly asked for by one of these options. + + For native builds, some of the installed programs are also installed + with the target alias in front of their name, as in + :samp:`i686-pc-linux-gnu-gcc`. All of the above transformations happen + before the target alias is prepended to the name---so, specifying + :option:`--program-prefix=foo-` and program-suffix=-3.1, the + resulting binary would be installed as + :samp:`/usr/local/bin/i686-pc-linux-gnu-foo-gcc-3.1`. + + As a last shortcoming, none of the installed Ada programs are + transformed yet, which will be fixed in some time. + +.. option:: --with-local-prefix=dirname + + Specify the + installation directory for local include files. The default is + :samp:`/usr/local`. Specify this option if you want the compiler to + search directory :samp:`{dirname}/include` for locally installed + header files *instead* of :samp:`/usr/local/include`. + + You should specify :option:`--with-local-prefix` **only** if your + site has a different convention (not :samp:`/usr/local`) for where to put + site-specific files. + + The default value for :option:`--with-local-prefix` is :samp:`/usr/local` + regardless of the value of :option:`--prefix`. Specifying + :option:`--prefix` has no effect on which directory GCC searches for + local header files. This may seem counterintuitive, but actually it is + logical. + + The purpose of :option:`--prefix` is to specify where to *install + GCC*. The local header files in :samp:`/usr/local/include`---if you put + any in that directory---are not part of GCC. They are part of other + programs---perhaps many others. (GCC installs its own header files in + another directory which is based on the :option:`--prefix` value.) + + Both the local-prefix include directory and the GCC-prefix include + directory are part of GCC's 'system include' directories. Although these + two directories are not fixed, they need to be searched in the proper + order for the correct processing of the include_next directive. The + local-prefix include directory is searched before the GCC-prefix + include directory. Another characteristic of system include directories + is that pedantic warnings are turned off for headers in these directories. + + Some autoconf macros add :option:`-I directory` options to the + compiler command line, to ensure that directories containing installed + packages' headers are searched. When :samp:`{directory}` is one of GCC's + system include directories, GCC will ignore the option so that system + directories continue to be processed in the correct order. This + may result in a search order different from what was specified but the + directory will still be searched. + + GCC automatically searches for ordinary libraries using + :envvar:`GCC_EXEC_PREFIX`. Thus, when the same installation prefix is + used for both GCC and packages, GCC will automatically search for + both headers and libraries. This provides a configuration that is + easy to use. GCC behaves in a manner similar to that when it is + installed as a system compiler in :samp:`/usr`. + + Sites that need to install multiple versions of GCC may not want to + use the above simple configuration. It is possible to use the + :option:`--program-prefix`, :option:`--program-suffix` and + :option:`--program-transform-name` options to install multiple versions + into a single directory, but it may be simpler to use different prefixes + and the :option:`--with-local-prefix` option to specify the location of the + site-specific files for each version. It will then be necessary for + users to specify explicitly the location of local site libraries + (e.g., with :envvar:`LIBRARY_PATH`). + + The same value can be used for both :option:`--with-local-prefix` and + :option:`--prefix` provided it is not :samp:`/usr`. This can be used + to avoid the default search of :samp:`/usr/local/include`. + + **Do not** specify :samp:`/usr` as the :option:`--with-local-prefix` ! + The directory you use for :option:`--with-local-prefix` **must not** + contain any of the system's standard header files. If it did contain + them, certain programs would be miscompiled (including GNU Emacs, on + certain targets), because this would override and nullify the header + file corrections made by the :command:`fixincludes` script. + + Indications are that people who use this option use it based on mistaken + ideas of what it is for. People use it as if it specified where to + install part of GCC. Perhaps they make this assumption because + installing GCC creates the directory. + +.. option:: --with-gcc-major-version-only + + Specifies that GCC should use only the major number rather than + :samp:`{major}.{minor}.{patchlevel}` in filesystem paths. + +.. option:: --with-native-system-header-dir=dirname + + Specifies that :samp:`{dirname}` is the directory that contains native system + header files, rather than :samp:`/usr/include`. This option is most useful + if you are creating a compiler that should be isolated from the system + as much as possible. It is most commonly used with the + :option:`--with-sysroot` option and will cause GCC to search + :samp:`{dirname}` inside the system root specified by that option. + +.. option:: --enable-shared[=package[,...]] + + Build shared versions of libraries, if shared libraries are supported on + the target platform. Unlike GCC 2.95.x and earlier, shared libraries + are enabled by default on all platforms that support shared libraries. + + If a list of packages is given as an argument, build shared libraries + only for the listed packages. For other packages, only static libraries + will be built. Package names currently recognized in the GCC tree are + :samp:`libgcc` (also known as :samp:`gcc`), :samp:`libstdc++` (not + :samp:`libstdc++-v3`), :samp:`libffi`, :samp:`zlib`, :samp:`boehm-gc`, + :samp:`ada`, :samp:`libada`, :samp:`libgo`, :samp:`libobjc`, and :samp:`libphobos`. + Note :samp:`libiberty` does not support shared libraries at all. + + Use :option:`--disable-shared` to build only static libraries. Note that + :option:`--disable-shared` does not accept a list of package names as + argument, only :option:`--enable-shared` does. + + Contrast with :option:`--enable-host-shared`, which affects *host* + code. + +.. option:: --enable-host-shared + + Specify that the *host* code should be built into position-independent + machine code (with -fPIC), allowing it to be used within shared libraries, + but yielding a slightly slower compiler. + + This option is required when building the libgccjit.so library. + + Contrast with :option:`--enable-shared`, which affects *target* + libraries. + +.. option:: --with-gnu-as + +.. _with-gnu-as: + + Specify that the compiler should assume that the + assembler it finds is the GNU assembler. However, this does not modify + the rules to find an assembler and will result in confusion if the + assembler found is not actually the GNU assembler. (Confusion may also + result if the compiler finds the GNU assembler but has not been + configured with :option:`--with-gnu-as`.) If you have more than one + assembler installed on your system, you may want to use this option in + connection with :option:`--with-as=pathname` or + :option:`--with-build-time-tools=pathname`. + + The following systems are the only ones where it makes a difference + whether you use the GNU assembler. On any other system, + :option:`--with-gnu-as` has no effect. + + * :samp:`hppa1.0-{any}-{any}` + + * :samp:`hppa1.1-{any}-{any}` + + * :samp:`sparc-sun-solaris2.{any}` + + * :samp:`sparc64-{any}-solaris2.{any}` + +.. option:: --with-as=pathname + + Specify that the compiler should use the assembler pointed to by + :samp:`{pathname}`, rather than the one found by the standard rules to find + an assembler, which are: + + * Unless GCC is being built with a cross compiler, check the + :samp:`{libexec}/gcc/{target}/{version}` directory. + :samp:`{libexec}` defaults to :samp:`{exec-prefix}/libexec`; + :samp:`{exec-prefix}` defaults to :samp:`{prefix}`, which + defaults to :samp:`/usr/local` unless overridden by the + :option:`--prefix=pathname` switch described above. :samp:`{target}` + is the target system triple, such as :samp:`sparc-sun-solaris2.7`, and + :samp:`{version}` denotes the GCC version, such as 3.0. + + * If the target system is the same that you are building on, check + operating system specific directories (e.g. :samp:`/usr/ccs/bin` on + Solaris 2). + + * Check in the :envvar:`PATH` for a tool whose name is prefixed by the + target system triple. + + * Check in the :envvar:`PATH` for a tool whose name is not prefixed by the + target system triple, if the host and target system triple are + the same (in other words, we use a host tool if it can be used for + the target as well). + + You may want to use :option:`--with-as` if no assembler + is installed in the directories listed above, or if you have multiple + assemblers installed and want to choose one that is not found by the + above rules. + +.. option:: --with-gnu-ld + +.. _with-gnu-ld: + + Same as :option:`--with-gnu-as` but for the linker. + +.. option:: --with-ld=pathname + + Same as :option:`--with-as` + but for the linker. + +.. option:: --with-dsymutil=pathname + + Same as :option:`--with-as` + but for the debug linker (only used on Darwin platforms so far). + +.. option:: --with-tls=dialect + + Specify the default TLS dialect, for systems were there is a choice. + For ARM targets, possible values for :samp:`{dialect}` are ``gnu`` or + ``gnu2``, which select between the original GNU dialect and the GNU TLS + descriptor-based dialect. + +.. option:: --enable-multiarch + + Specify whether to enable or disable multiarch support. The default is + to check for glibc start files in a multiarch location, and enable it + if the files are found. The auto detection is enabled for native builds, + and for cross builds configured with :option:`--with-sysroot`, and without + :option:`--with-native-system-header-dir`. + More documentation about multiarch can be found at + https://wiki.debian.org/Multiarch. + +.. option:: --enable-sjlj-exceptions + + Force use of the ``setjmp`` / ``longjmp`` -based scheme for exceptions. + :samp:`configure` ordinarily picks the correct value based on the platform. + Only use this option if you are sure you need a different setting. + +.. option:: --enable-vtable-verify + + Specify whether to enable or disable the vtable verification feature. + Enabling this feature causes libstdc++ to be built with its virtual calls + in verifiable mode. This means that, when linked with libvtv, every + virtual call in libstdc++ will verify the vtable pointer through which the + call will be made before actually making the call. If not linked with libvtv, + the verifier will call stub functions (in libstdc++ itself) and do nothing. + If vtable verification is disabled, then libstdc++ is not built with its + virtual calls in verifiable mode at all. However the libvtv library will + still be built (see :option:`--disable-libvtv` to turn off building libvtv). + :option:`--disable-vtable-verify` is the default. + +.. option:: --disable-gcov + + Specify that the run-time library used for coverage analysis + and associated host tools should not be built. + +.. option:: --disable-multilib + + Specify that multiple target + libraries to support different target variants, calling + conventions, etc. should not be built. The default is to build a + predefined set of them. + + Some targets provide finer-grained control over which multilibs are built + (e.g., :option:`--disable-softfloat`): + + ``arm-*-*`` + fpu, 26bit, underscore, interwork, biendian, nofmult. + + ``m68*-*-*`` + softfloat, m68881, m68000, m68020. + + ``mips*-*-*`` + single-float, biendian, softfloat. + + ``msp430-*-*`` + no-exceptions + + ``powerpc*-*-*, rs6000*-*-*`` + aix64, pthread, softfloat, powercpu, powerpccpu, powerpcos, biendian, + sysv, aix. + +.. option:: --with-multilib-list=list + + Specify what multilibs to build. :samp:`{list}` is a comma separated list of + values, possibly consisting of a single value. Currently only implemented + for aarch64\*-\*-\*, arm\*-\*-\*, loongarch64-\*-\*, riscv\*-\*-\*, sh\*-\*-\* and + x86-64-\*-linux\*. The accepted values and meaning for each target is given + below. + + ``aarch64*-*-*`` + :samp:`{list}` is a comma separated list of ``ilp32``, and ``lp64`` + to enable ILP32 and LP64 run-time libraries, respectively. If + :samp:`{list}` is empty, then there will be no multilibs and only the + default run-time library will be built. If :samp:`{list}` is + ``default`` or --with-multilib-list= is not specified, then the + default set of libraries is selected based on the value of + :option:`--target`. + + ``arm*-*-*`` + :samp:`{list}` is a comma separated list of ``aprofile`` and + ``rmprofile`` to build multilibs for A or R and M architecture + profiles respectively. Note that, due to some limitation of the current + multilib framework, using the combined ``aprofile,rmprofile`` + multilibs selects in some cases a less optimal multilib than when using + the multilib profile for the architecture targetted. The special value + ``default`` is also accepted and is equivalent to omitting the + option, i.e., only the default run-time library will be enabled. + + :samp:`{list}` may instead contain ``@name``, to use the multilib + configuration Makefile fragment :samp:`name` in :samp:`gcc/config/arm` in + the source tree (it is part of the corresponding sources, after all). + It is recommended, but not required, that files used for this purpose to + be named starting with :samp:`t-ml-`, to make their intended purpose + self-evident, in line with GCC conventions. Such files enable custom, + user-chosen multilib lists to be configured. Whether multiple such + files can be used together depends on the contents of the supplied + files. See :samp:`gcc/config/arm/t-multilib` and its supplementary + :samp:`gcc/config/arm/t-*profile` files for an example of what such + Makefile fragments might look like for this version of GCC. The macros + expected to be defined in these fragments are not stable across GCC + releases, so make sure they define the ``MULTILIB`` -related macros + expected by the version of GCC you are building. + See :ref:`gccint:target-fragment`. + + The table below gives the combination of ISAs, architectures, FPUs and + floating-point ABIs for which multilibs are built for each predefined + profile. The union of these options is considered when specifying both + ``aprofile`` and ``rmprofile``. + + .. list-table:: + :widths: 15 30 30 + + * - Option + - aprofile + - rmprofile + * - ISAs + - ``-marm`` and ``-mthumb`` + - ``-mthumb`` + * - Architectures + - default architecture ``-march=armv7-a`` ``-march=armv7ve`` ``-march=armv8-a`` + - default architecture ``-march=armv6s-m`` ``-march=armv7-m`` ``-march=armv7e-m`` ``-march=armv8-m.base`` ``-march=armv8-m.main`` ``-march=armv7`` + * - FPUs + - none ``-mfpu=vfpv3-d16`` ``-mfpu=neon`` ``-mfpu=vfpv4-d16`` ``-mfpu=neon-vfpv4`` ``-mfpu=neon-fp-armv8`` + - none ``-mfpu=vfpv3-d16`` ``-mfpu=fpv4-sp-d16`` ``-mfpu=fpv5-sp-d16`` ``-mfpu=fpv5-d16`` + * - floating-point ABIs + - ``-mfloat-abi=soft`` ``-mfloat-abi=softfp`` ``-mfloat-abi=hard`` + - ``-mfloat-abi=soft`` ``-mfloat-abi=softfp`` ``-mfloat-abi=hard`` + + ``loongarch*-*-*`` + :samp:`{list}` is a comma-separated list of the following ABI identifiers: + ``lp64d[/base]`` ``lp64f[/base]`` ``lp64d[/base]``, where the + ``/base`` suffix may be omitted, to enable their respective run-time + libraries. If :samp:`{list}` is empty or ``default``, + or if :option:`--with-multilib-list` is not specified, then the default ABI + as specified by :option:`--with-abi` or implied by :option:`--target` is selected. + + ``riscv*-*-*`` + :samp:`{list}` is a single ABI name. The target architecture must be either + ``rv32gc`` or ``rv64gc``. This will build a single multilib for the + specified architecture and ABI pair. If ``--with-multilib-list`` is not + given, then a default set of multilibs is selected based on the value of + :option:`--target`. This is usually a large set of multilibs. + + ``sh*-*-*`` + :samp:`{list}` is a comma separated list of CPU names. These must be of the + form ``sh*`` or ``m*`` (in which case they match the compiler option + for that processor). The list should not contain any endian options - + these are handled by :option:`--with-endian`. + + If :samp:`{list}` is empty, then there will be no multilibs for extra + processors. The multilib for the secondary endian remains enabled. + + As a special case, if an entry in the list starts with a ``!`` + (exclamation point), then it is added to the list of excluded multilibs. + Entries of this sort should be compatible with :samp:`MULTILIB_EXCLUDES` + (once the leading ``!`` has been stripped). + + If :option:`--with-multilib-list` is not given, then a default set of + multilibs is selected based on the value of :option:`--target`. This is + usually the complete set of libraries, but some targets imply a more + specialized subset. + + Example 1: to configure a compiler for SH4A only, but supporting both + endians, with little endian being the default: + + :option:`--with-cpu=sh4a` :option:`--with-endian=little,big` :option:`--with-multilib-list=` + Example 2: to configure a compiler for both SH4A and SH4AL-DSP, but with + only little endian SH4AL: + + :option:`--with-cpu=sh4a` :option:`--with-endian=little,big` \ + :option:`--with-multilib-list=sh4al,!mb/m4al` + + ``x86-64-*-linux*`` + :samp:`{list}` is a comma separated list of ``m32``, ``m64`` and + ``mx32`` to enable 32-bit, 64-bit and x32 run-time libraries, + respectively. If :samp:`{list}` is empty, then there will be no multilibs + and only the default run-time library will be enabled. + + If :option:`--with-multilib-list` is not given, then only 32-bit and + 64-bit run-time libraries will be enabled. + +.. option:: --with-multilib-generator=config + + Specify what multilibs to build. :samp:`{config}` is a semicolon separated list of + values, possibly consisting of a single value. Currently only implemented + for riscv\*-\*-elf\*. The accepted values and meanings are given below. + + Every config is constructed with four components: architecture string, ABI, + reuse rule with architecture string and reuse rule with sub-extension. + + Example 1: Add multi-lib suppport for rv32i with ilp32. + + .. code-block:: bash + + rv32i-ilp32-- + + Example 2: Add multi-lib suppport for rv32i with ilp32 and rv32imafd with ilp32. + + .. code-block:: bash + + rv32i-ilp32--;rv32imafd-ilp32-- + + Example 3: Add multi-lib suppport for rv32i with ilp32; rv32im with ilp32 and + rv32ic with ilp32 will reuse this multi-lib set. + + .. code-block:: bash + + rv32i-ilp32-rv32im-c + + Example 4: Add multi-lib suppport for rv64ima with lp64; rv64imaf with lp64, + rv64imac with lp64 and rv64imafc with lp64 will reuse this multi-lib set. + + .. code-block:: bash + + rv64ima-lp64--f,c,fc + + :option:`--with-multilib-generator` have an optional configuration argument + :option:`--cmodel=val` for code model, this option will expand with other + config options, :samp:`{val}` is a comma separated list of possible code model, + currently we support medlow and medany. + + Example 5: Add multi-lib suppport for rv64ima with lp64; rv64ima with lp64 and + medlow code model + + .. code-block:: bash + + rv64ima-lp64--;--cmodel=medlow + + Example 6: Add multi-lib suppport for rv64ima with lp64; rv64ima with lp64 and + medlow code model; rv64ima with lp64 and medany code model + + .. code-block:: bash + + rv64ima-lp64--;--cmodel=medlow,medany + +.. option:: --with-endian=endians + + Specify what endians to use. + Currently only implemented for sh\*-\*-\*. + + :samp:`{endians}` may be one of the following: + + ``big`` + Use big endian exclusively. + + ``little`` + Use little endian exclusively. + + ``big,little`` + Use big endian by default. Provide a multilib for little endian. + + ``little,big`` + Use little endian by default. Provide a multilib for big endian. + +.. option:: --enable-threads + + Specify that the target + supports threads. This affects the Objective-C compiler and runtime + library, and exception handling for other languages like C++. + On some systems, this is the default. + + In general, the best (and, in many cases, the only known) threading + model available will be configured for use. Beware that on some + systems, GCC has not been taught what threading models are generally + available for the system. In this case, :option:`--enable-threads` is an + alias for :option:`--enable-threads=single`. + +.. option:: --disable-threads + + Specify that threading support should be disabled for the system. + This is an alias for :option:`--enable-threads=single`. + +.. option:: --enable-threads=lib + + Specify that + :samp:`{lib}` is the thread support library. This affects the Objective-C + compiler and runtime library, and exception handling for other languages + like C++. The possibilities for :samp:`{lib}` are: + + ``aix`` + AIX thread support. + + ``dce`` + DCE thread support. + + ``lynx`` + LynxOS thread support. + + ``mipssde`` + MIPS SDE thread support. + + ``no`` + This is an alias for :samp:`single`. + + ``posix`` + Generic POSIX/Unix98 thread support. + + ``rtems`` + RTEMS thread support. + + ``single`` + Disable thread support, should work for all platforms. + + ``tpf`` + TPF thread support. + + ``vxworks`` + VxWorks thread support. + + ``win32`` + Microsoft Win32 API thread support. + +.. option:: --enable-tls + + Specify that the target supports TLS (Thread Local Storage). Usually + configure can correctly determine if TLS is supported. In cases where + it guesses incorrectly, TLS can be explicitly enabled or disabled with + :option:`--enable-tls` or :option:`--disable-tls`. This can happen if + the assembler supports TLS but the C library does not, or if the + assumptions made by the configure test are incorrect. + +.. option:: --disable-tls + + Specify that the target does not support TLS. + This is an alias for :option:`--enable-tls=no`. + +.. option:: --disable-tm-clone-registry + + Disable TM clone registry in libgcc. It is enabled in libgcc by default. + This option helps to reduce code size for embedded targets which do + not use transactional memory. + +.. option:: --with-cpu=cpu + + Specify which cpu variant the compiler should generate code for by default. + :samp:`{cpu}` will be used as the default value of the :option:`-mcpu=` switch. + This option is only supported on some targets, including ARC, ARM, i386, M68k, + PowerPC, and SPARC. It is mandatory for ARC. The :option:`--with-cpu-32` and + :option:`--with-cpu-64` options specify separate default CPUs for + 32-bit and 64-bit modes; these options are only supported for aarch64, i386, + x86-64, PowerPC, and SPARC. + +.. option:: --with-schedule=cpu + + These configure options provide default values for the :option:`-mschedule=`, + :option:`-march=`, :option:`-mtune=`, :option:`-mabi=`, and :option:`-mfpu=` + options and for :option:`-mhard-float` or :option:`-msoft-float`. As with + :option:`--with-cpu`, which switches will be accepted and acceptable values + of the arguments depend on the target. + +.. option:: --with-mode=mode + + Specify if the compiler should default to :option:`-marm` or :option:`-mthumb`. + This option is only supported on ARM targets. + +.. option:: --with-stack-offset=num + + This option sets the default for the -mstack-offset= :samp:`{num}` option, + and will thus generally also control the setting of this option for + libraries. This option is only supported on Epiphany targets. + +.. option:: --with-fpmath=isa + + This options sets :option:`-mfpmath=sse` by default and specifies the default + ISA for floating-point arithmetics. You can select either :samp:`sse` which + enables :option:`-msse2` or :samp:`avx` which enables :option:`-mavx` by default. + This option is only supported on i386 and x86-64 targets. + +.. option:: --with-fp-32=mode + + On MIPS targets, set the default value for the :option:`-mfp` option when using + the o32 ABI. The possibilities for :samp:`{mode}` are: + + ``32`` + Use the o32 FP32 ABI extension, as with the :option:`-mfp32` command-line + option. + + ``xx`` + Use the o32 FPXX ABI extension, as with the :option:`-mfpxx` command-line + option. + + ``64`` + Use the o32 FP64 ABI extension, as with the :option:`-mfp64` command-line + option. + + In the absence of this configuration option the default is to use the o32 + FP32 ABI extension. + +.. option:: --with-odd-spreg-32 + + On MIPS targets, set the :option:`-modd-spreg` option by default when using + the o32 ABI. + +.. option:: --without-odd-spreg-32 + + On MIPS targets, set the :option:`-mno-odd-spreg` option by default when using + the o32 ABI. This is normally used in conjunction with + :option:`--with-fp-32=64` in order to target the o32 FP64A ABI extension. + +.. option:: --with-nan=encoding + + On MIPS targets, set the default encoding convention to use for the + special not-a-number (NaN) IEEE 754 floating-point data. The + possibilities for :samp:`{encoding}` are: + + ``legacy`` + Use the legacy encoding, as with the :option:`-mnan=legacy` command-line + option. + + ``2008`` + Use the 754-2008 encoding, as with the :option:`-mnan=2008` command-line + option. + + To use this configuration option you must have an assembler version + installed that supports the :option:`-mnan=` command-line option too. + In the absence of this configuration option the default convention is + the legacy encoding, as when neither of the :option:`-mnan=2008` and + :option:`-mnan=legacy` command-line options has been used. + +.. option:: --with-divide=type + + Specify how the compiler should generate code for checking for + division by zero. This option is only supported on the MIPS target. + The possibilities for :samp:`{type}` are: + + ``traps`` + Division by zero checks use conditional traps (this is the default on + systems that support conditional traps). + + ``breaks`` + Division by zero checks use the break instruction. + +.. option:: --with-compact-branches=policy + + Specify how the compiler should generate branch instructions. + This option is only supported on the MIPS target. + The possibilities for :samp:`{type}` are: + + ``optimal`` + Cause a delay slot branch to be used if one is available in the + current ISA and the delay slot is successfully filled. If the delay slot + is not filled, a compact branch will be chosen if one is available. + + ``never`` + Ensures that compact branch instructions will never be generated. + + ``always`` + Ensures that a compact branch instruction will be generated if available. + If a compact branch instruction is not available, + a delay slot form of the branch will be used instead. + This option is supported from MIPS Release 6 onwards. + For pre-R6/microMIPS/MIPS16, this option is just same as never/optimal. + + .. If you make -with-llsc the default for additional targets, + update the -with-llsc description in the MIPS section below. + +.. option:: --with-llsc + + On MIPS targets, make :option:`-mllsc` the default when no + :option:`-mno-llsc` option is passed. This is the default for + Linux-based targets, as the kernel will emulate them if the ISA does + not provide them. + +.. option:: --without-llsc + + On MIPS targets, make :option:`-mno-llsc` the default when no + :option:`-mllsc` option is passed. + +.. option:: --with-synci + + On MIPS targets, make :option:`-msynci` the default when no + :option:`-mno-synci` option is passed. + +.. option:: --without-synci + + On MIPS targets, make :option:`-mno-synci` the default when no + :option:`-msynci` option is passed. This is the default. + +.. option:: --with-lxc1-sxc1 + + On MIPS targets, make :option:`-mlxc1-sxc1` the default when no + :option:`-mno-lxc1-sxc1` option is passed. This is the default. + +.. option:: --without-lxc1-sxc1 + + On MIPS targets, make :option:`-mno-lxc1-sxc1` the default when no + :option:`-mlxc1-sxc1` option is passed. The indexed load/store + instructions are not directly a problem but can lead to unexpected + behaviour when deployed in an application intended for a 32-bit address + space but run on a 64-bit processor. The issue is seen because all + known MIPS 64-bit Linux kernels execute o32 and n32 applications + with 64-bit addressing enabled which affects the overflow behaviour + of the indexed addressing mode. GCC will assume that ordinary + 32-bit arithmetic overflow behaviour is the same whether performed + as an ``addu`` instruction or as part of the address calculation + in ``lwxc1`` type instructions. This assumption holds true in a + pure 32-bit environment and can hold true in a 64-bit environment if + the address space is accurately set to be 32-bit for o32 and n32. + +.. option:: --with-madd4 + + On MIPS targets, make :option:`-mmadd4` the default when no + :option:`-mno-madd4` option is passed. This is the default. + +.. option:: --without-madd4 + + On MIPS targets, make :option:`-mno-madd4` the default when no + :option:`-mmadd4` option is passed. The ``madd4`` instruction + family can be problematic when targeting a combination of cores that + implement these instructions differently. There are two known cores + that implement these as fused operations instead of unfused (where + unfused is normally expected). Disabling these instructions is the + only way to ensure compatible code is generated; this will incur + a performance penalty. + +.. option:: --with-mips-plt + + On MIPS targets, make use of copy relocations and PLTs. + These features are extensions to the traditional + SVR4-based MIPS ABIs and require support from GNU binutils + and the runtime C library. + +.. option:: --with-stack-clash-protection-guard-size=size + + On certain targets this option sets the default stack clash protection guard + size as a power of two in bytes. On AArch64 :samp:`{size}` is required to be either + 12 (4KB) or 16 (64KB). + +.. option:: --with-isa-spec=ISA-spec-string + + On RISC-V targets specify the default version of the RISC-V Unprivileged + (formerly User-Level) ISA specification to produce code conforming to. + The possibilities for :samp:`{ISA-spec-string}` are: + + ``2.2`` + Produce code conforming to version 2.2. + + ``20190608`` + Produce code conforming to version 20190608. + + ``20191213`` + Produce code conforming to version 20191213. + + In the absence of this configuration option the default version is 20191213. + +.. option:: --enable-__cxa_atexit + + Define if you want to use __cxa_atexit, rather than atexit, to + register C++ destructors for local statics and global objects. + This is essential for fully standards-compliant handling of + destructors, but requires __cxa_atexit in libc. This option is currently + only available on systems with GNU libc. When enabled, this will cause + :option:`-fuse-cxa-atexit` to be passed by default. + +.. option:: --enable-gnu-indirect-function + + Define if you want to enable the ``ifunc`` attribute. This option is + currently only available on systems with GNU libc on certain targets. + +.. option:: --enable-target-optspace + + Specify that target + libraries should be optimized for code space instead of code speed. + This is the default for the m32r platform. + +.. option:: --with-cpp-install-dir=dirname + + Specify that the user visible :command:`cpp` program should be installed + in :samp:`{prefix}/{dirname}/cpp`, in addition to :samp:`{bindir}`. + +.. option:: --enable-comdat + + Enable COMDAT group support. This is primarily used to override the + automatically detected value. + +.. option:: --enable-initfini-array + + Force the use of sections ``.init_array`` and ``.fini_array`` + (instead of ``.init`` and ``.fini``) for constructors and + destructors. Option :option:`--disable-initfini-array` has the + opposite effect. If neither option is specified, the configure script + will try to guess whether the ``.init_array`` and + ``.fini_array`` sections are supported and, if they are, use them. + +.. option:: --enable-link-mutex + + When building GCC, use a mutex to avoid linking the compilers for + multiple languages at the same time, to avoid thrashing on build + systems with limited free memory. The default is not to use such a mutex. + +.. option:: --enable-link-serialization + + When building GCC, use make dependencies to serialize linking the compilers for + multiple languages, to avoid thrashing on build + systems with limited free memory. The default is not to add such + dependencies and thus with parallel make potentially link different + compilers concurrently. If the argument is a positive integer, allow + that number of concurrent link processes for the large binaries. + +.. option:: --enable-maintainer-mode + + The build rules that regenerate the Autoconf and Automake output files as + well as the GCC master message catalog :samp:`gcc.pot` are normally + disabled. This is because it can only be rebuilt if the complete source + tree is present. If you have changed the sources and want to rebuild the + catalog, configuring with :option:`--enable-maintainer-mode` will enable + this. Note that you need a recent version of the ``gettext`` tools + to do so. + +.. option:: --disable-bootstrap + + For a native build, the default configuration is to perform + a 3-stage bootstrap of the compiler when :samp:`make` is invoked, + testing that GCC can compile itself correctly. If you want to disable + this process, you can configure with :option:`--disable-bootstrap`. + +.. option:: --enable-bootstrap + + In special cases, you may want to perform a 3-stage build + even if the target and host triplets are different. + This is possible when the host can run code compiled for + the target (e.g. host is i686-linux, target is i486-linux). + Starting from GCC 4.2, to do this you have to configure explicitly + with :option:`--enable-bootstrap`. + +.. option:: --enable-generated-files-in-srcdir + + Neither the .c and .h files that are generated from Bison and flex nor the + info manuals and man pages that are built from the .texi files are present + in the repository development tree. When building GCC from that development tree, + or from one of our snapshots, those generated files are placed in your + build directory, which allows for the source to be in a readonly + directory. + + If you configure with :option:`--enable-generated-files-in-srcdir` then those + generated files will go into the source directory. This is mainly intended + for generating release or prerelease tarballs of the GCC sources, since it + is not a requirement that the users of source releases to have flex, Bison, + or makeinfo. + +.. option:: --enable-version-specific-runtime-libs + + Specify + that runtime libraries should be installed in the compiler specific + subdirectory (:samp:`{libdir}/gcc`) rather than the usual places. In + addition, :samp:`libstdc++`'s include files will be installed into + :samp:`{libdir}` unless you overruled it by using + :option:`--with-gxx-include-dir=dirname`. Using this option is + particularly useful if you intend to use several versions of GCC in + parallel. The default is :samp:`yes` for :samp:`libada`, and :samp:`no` for + the remaining libraries. + +.. option:: --with-aix-soname=aix, svr4 or both + + Traditional AIX shared library versioning (versioned ``Shared Object`` + files as members of unversioned ``Archive Library`` files named + :samp:`lib.a`) causes numerous headaches for package managers. However, + ``Import Files`` as members of ``Archive Library`` files allow for + **filename-based versioning** of shared libraries as seen on Linux/SVR4, + where this is called the "SONAME". But as they prevent static linking, + ``Import Files`` may be used with ``Runtime Linking`` only, where the + linker does search for :samp:`libNAME.so` before :samp:`libNAME.a` library + filenames with the :samp:`-lNAME` linker flag. + +.. _aixldcommand: + + For detailed information please refer to the AIX + `ld + Command `_ reference. + + As long as shared library creation is enabled, upon: + + .. option:: --with-aix-soname=aix + .. option:: --with-aix-soname=both + + A (traditional AIX) ``Shared Archive Library`` file is created: + + * using the :samp:`libNAME.a` filename scheme + + * with the ``Shared Object`` file as archive member named + :samp:`libNAME.so.V` (except for :samp:`libgcc_s`, where the ``Shared + Object`` file is named :samp:`shr.o` for backwards compatibility), which + + * is used for runtime loading from inside the :samp:`libNAME.a` file + * is used for dynamic loading via ``dlopen("libNAME.a(libNAME.so.V)", RTLD_MEMBER)`` + * is used for shared linking + * is used for static linking, so no separate ``Static Archive Library`` file is needed + + .. option:: --with-aix-soname=both + .. option:: --with-aix-soname=svr4 + + A (second) ``Shared Archive Library`` file is created: + + * using the :samp:`libNAME.so.V` filename scheme + * with the ``Shared Object`` file as archive member named :samp:`shr.o`, which + + * is created with the ``-G linker flag`` + * has the ``F_LOADONLY`` flag set + * is used for runtime loading from inside the :samp:`libNAME.so.V` file + * is used for dynamic loading via ``dlopen("libNAME.so.V(shr.o)", RTLD_MEMBER)`` + + * with the ``Import File`` as archive member named :samp:`shr.imp`, which + * refers to :samp:`libNAME.so.V(shr.o)` as the "SONAME", to be recorded in the ``Loader Section`` of subsequent binaries + * indicates whether :samp:`libNAME.so.V(shr.o)` is 32 or 64 bit + * lists all the public symbols exported by :samp:`lib.so.V(shr.o)`, eventually decorated with the ``weak Keyword`` + * is necessary for shared linking against :samp:`lib.so.V(shr.o)` + + A symbolic link using the :samp:`libNAME.so` filename scheme is created: + * pointing to the :samp:`libNAME.so.V` ``Shared Archive Library`` file + * to permit the ``ld Command`` to find :samp:`lib.so.V(shr.imp)` via the :samp:`-lNAME` argument (requires ``Runtime Linking`` to be enabled) + * to permit dynamic loading of :samp:`lib.so.V(shr.o)` without the need to specify the version number via ``dlopen("libNAME.so(shr.o)", RTLD_MEMBER)`` + + As long as static library creation is enabled, upon: + + .. option:: --with-aix-soname=svr4 + + A ``Static Archive Library`` is created: + + * using the :samp:`libNAME.a` filename scheme + * with all the ``Static Object`` files as archive members, which + + * are used for static linking + + While the aix-soname= :samp:`svr4` option does not create ``Shared Object`` + files as members of unversioned ``Archive Library`` files any more, package + managers still are responsible to :ref:`transfer ` + ``Shared Object`` files + found as member of a previously installed unversioned ``Archive Library`` + file into the newly installed ``Archive Library`` file with the same + filename. + + .. warning:: + Creating ``Shared Object`` files with ``Runtime Linking`` + enabled may bloat the TOC, eventually leading to ``TOC overflow`` errors, + requiring the use of either the :option:`-Wl,-bbigtoc` linker flag (seen to + break with the ``GDB`` debugger) or some of the TOC-related compiler flags, + see :ref:`gcc:rs-6000-and-powerpc-options`. + + :option:`--with-aix-soname` is currently supported by :samp:`libgcc_s` only, so + this option is still experimental and not for normal use yet. + + Default is the traditional behavior :option:`--with-aix-soname=aix`. + +.. option:: --enable-languages=lang1,lang2,... + + Specify that only a particular subset of compilers and + their runtime libraries should be built. For a list of valid values for + :samp:`{langN}` you can issue the following command in the + :samp:`gcc` directory of your GCC source tree: + + .. code-block:: bash + + grep ^language= */config-lang.in + + Currently, you can use any of the following: + ``all``, ``default``, ``ada``, ``c``, ``c++``, ``d``, + ``fortran``, ``go``, ``jit``, ``lto``, ``objc``, ``obj-c++``. + Building the Ada compiler has special requirements, see below. + If you do not pass this flag, or specify the option ``default``, then the + default languages available in the :samp:`gcc` sub-tree will be configured. + Ada, D, Go, Jit, and Objective-C++ are not default languages. LTO is not a + default language, but is built by default because :option:`--enable-lto` is + enabled by default. The other languages are default languages. If + ``all`` is specified, then all available languages are built. An + exception is ``jit`` language, which requires + :option:`--enable-host-shared` to be included with ``all``. + +.. option:: --enable-stage1-languages=lang1,lang2,... + + Specify that a particular subset of compilers and their runtime + libraries should be built with the system C compiler during stage 1 of + the bootstrap process, rather than only in later stages with the + bootstrapped C compiler. The list of valid values is the same as for + :option:`--enable-languages`, and the option ``all`` will select all + of the languages enabled by :option:`--enable-languages`. This option is + primarily useful for GCC development; for instance, when a development + version of the compiler cannot bootstrap due to compiler bugs, or when + one is debugging front ends other than the C front end. When this + option is used, one can then build the target libraries for the + specified languages with the stage-1 compiler by using :command:`make + stage1-bubble all-target`, or run the testsuite on the stage-1 compiler + for the specified languages using :command:`make stage1-start check-gcc`. + +.. option:: --disable-libada + + Specify that the run-time libraries and tools used by GNAT should not + be built. This can be useful for debugging, or for compatibility with + previous Ada build procedures, when it was required to explicitly + do a :samp:`make -C gcc gnatlib_and_tools`. + +.. option:: --disable-libsanitizer + + Specify that the run-time libraries for the various sanitizers should + not be built. + +.. option:: --disable-libssp + + Specify that the run-time libraries for stack smashing protection + should not be built or linked against. On many targets library support + is provided by the C library instead. + +.. option:: --disable-libquadmath + + Specify that the GCC quad-precision math library should not be built. + On some systems, the library is required to be linkable when building + the Fortran front end, unless :option:`--disable-libquadmath-support` + is used. + +.. option:: --disable-libquadmath-support + + Specify that the Fortran front end and ``libgfortran`` do not add + support for ``libquadmath`` on systems supporting it. + +.. option:: --disable-libgomp + + Specify that the GNU Offloading and Multi Processing Runtime Library + should not be built. + +.. option:: --disable-libvtv + + Specify that the run-time libraries used by vtable verification + should not be built. + +.. option:: --with-dwarf2 + + Specify that the compiler should + use DWARF 2 debugging information as the default. + +.. option:: --with-advance-toolchain=at + + On 64-bit PowerPC Linux systems, configure the compiler to use the + header files, library files, and the dynamic linker from the Advance + Toolchain release :samp:`{at}` instead of the default versions that are + provided by the Linux distribution. In general, this option is + intended for the developers of GCC, and it is not intended for general + use. + +.. option:: --enable-targets=all + + Some GCC targets, e.g. powerpc64-linux, build bi-arch compilers. + These are compilers that are able to generate either 64-bit or 32-bit + code. Typically, the corresponding 32-bit target, e.g. + powerpc-linux for powerpc64-linux, only generates 32-bit code. This + option enables the 32-bit target to be a bi-arch compiler, which is + useful when you want a bi-arch compiler that defaults to 32-bit, and + you are building a bi-arch or multi-arch binutils in a combined tree. + On mips-linux, this will build a tri-arch compiler (ABI o32/n32/64), + defaulted to o32. + Currently, this option only affects sparc-linux, powerpc-linux, x86-linux, + mips-linux and s390-linux. + +.. option:: --enable-default-pie + + Turn on :option:`-fPIE` and :option:`-pie` by default. + +.. option:: --enable-secureplt + + This option enables :option:`-msecure-plt` by default for powerpc-linux. + See :ref:`gcc:rs-6000-and-powerpc-options`. + +.. option:: --enable-default-ssp + + Turn on :option:`-fstack-protector-strong` by default. + +.. option:: --enable-cld + + This option enables :option:`-mcld` by default for 32-bit x86 targets. + See :ref:`gcc:x86-options`. + +.. option:: --enable-large-address-aware + + The :option:`--enable-large-address-aware` option arranges for MinGW + executables to be linked using the :option:`--large-address-aware` + option, that enables the use of more than 2GB of memory. If GCC is + configured with this option, its effects can be reversed by passing the + :option:`-Wl,--disable-large-address-aware` option to the so-configured + compiler driver. + +.. option:: --enable-win32-registry + + The :option:`--enable-win32-registry` option enables Microsoft Windows-hosted GCC + to look up installations paths in the registry using the following key: + + .. code-block:: + + HKEY_LOCAL_MACHINE\SOFTWARE\Free Software Foundation\key + + :samp:`{key}` defaults to GCC version number, and can be overridden by the + :option:`--enable-win32-registry=key` option. Vendors and distributors + who use custom installers are encouraged to provide a different key, + perhaps one comprised of vendor name and GCC version number, to + avoid conflict with existing installations. This feature is enabled + by default, and can be disabled by :option:`--disable-win32-registry` + option. This option has no effect on the other hosts. + +.. option:: --nfp + + Specify that the machine does not have a floating point unit. This + option only applies to :samp:`m68k-sun-sunos{n}`. On any other + system, :option:`--nfp` has no effect. + +.. option:: --enable-werror + + When you specify this option, it controls whether certain files in the + compiler are built with :option:`-Werror` in bootstrap stage2 and later. + If you don't specify it, :option:`-Werror` is turned on for the main + development trunk. However it defaults to off for release branches and + final releases. The specific files which get :option:`-Werror` are + controlled by the Makefiles. + +.. option:: --enable-checking + + This option controls performing internal consistency checks in the compiler. + It does not change the generated code, but adds error checking of the + requested complexity. This slows down the compiler and may only work + properly if you are building the compiler with GCC. + + When the option is not specified, the active set of checks depends on context. + Namely, bootstrap stage 1 defaults to :samp:`--enable-checking=yes`, builds + from release branches or release archives default to + :samp:`--enable-checking=release`, and otherwise + :samp:`--enable-checking=yes,extra` is used. When the option is + specified without a :samp:`{list}`, the result is the same as + :samp:`--enable-checking=yes`. Likewise, :samp:`--disable-checking` is + equivalent to :samp:`--enable-checking=no`. + + The categories of checks available in :samp:`{list}` are :samp:`yes` (most common + checks :samp:`assert,misc,gc,gimple,rtlflag,runtime,tree,types`), :samp:`no` + (no checks at all), :samp:`all` (all but :samp:`valgrind`), :samp:`release` + (cheapest checks :samp:`assert,runtime`) or :samp:`none` (same as :samp:`no`). + :samp:`release` checks are always on and to disable them + :samp:`--disable-checking` or :samp:`--enable-checking=no[,]` + must be explicitly requested. Disabling assertions makes the compiler and + runtime slightly faster but increases the risk of undetected internal errors + causing wrong code to be generated. + + Individual checks can be enabled with these flags: :samp:`assert`, :samp:`df`, + :samp:`extra`, :samp:`fold`, :samp:`gc`, :samp:`gcac`, :samp:`gimple`, + :samp:`misc`, :samp:`rtl`, :samp:`rtlflag`, :samp:`runtime`, :samp:`tree`, + :samp:`types` and :samp:`valgrind`. :samp:`extra` extends :samp:`misc` + checking with extra checks that might affect code generation and should + therefore not differ between stage1 and later stages in bootstrap. + + The :samp:`valgrind` check requires the external :command:`valgrind` simulator, + available from https://valgrind.org. The :samp:`rtl` checks are + expensive and the :samp:`df`, :samp:`gcac` and :samp:`valgrind` checks are very + expensive. + +.. option:: --disable-stage1-checking + + This option affects only bootstrap build. If no :option:`--enable-checking` + option is specified the stage1 compiler is built with :samp:`yes` checking + enabled, otherwise the stage1 checking flags are the same as specified by + :option:`--enable-checking`. To build the stage1 compiler with + different checking options use :option:`--enable-stage1-checking`. + The list of checking options is the same as for :option:`--enable-checking`. + If your system is too slow or too small to bootstrap a released compiler + with checking for stage1 enabled, you can use :samp:`--disable-stage1-checking` + to disable checking for the stage1 compiler. + +.. option:: --enable-coverage + + With this option, the compiler is built to collect self coverage + information, every time it is run. This is for internal development + purposes, and only works when the compiler is being built with gcc. The + :samp:`{level}` argument controls whether the compiler is built optimized or + not, values are :samp:`opt` and :samp:`noopt`. For coverage analysis you + want to disable optimization, for performance analysis you want to + enable optimization. When coverage is enabled, the default level is + without optimization. + +.. option:: --enable-gather-detailed-mem-stats + + When this option is specified more detailed information on memory + allocation is gathered. This information is printed when using + :option:`-fmem-report`. + +.. option:: --enable-valgrind-annotations + + Mark selected memory related operations in the compiler when run under + valgrind to suppress false positives. + +.. option:: --enable-nls + + The :option:`--enable-nls` option enables Native Language Support (NLS), + which lets GCC output diagnostics in languages other than American + English. Native Language Support is enabled by default if not doing a + canadian cross build. The :option:`--disable-nls` option disables NLS. + +.. option:: --with-included-gettext + + If NLS is enabled, the :option:`--with-included-gettext` option causes the build + procedure to prefer its copy of GNU :command:`gettext`. + +.. option:: --with-catgets + + If NLS is enabled, and if the host lacks ``gettext`` but has the + inferior ``catgets`` interface, the GCC build procedure normally + ignores ``catgets`` and instead uses GCC's copy of the GNU + ``gettext`` library. The :option:`--with-catgets` option causes the + build procedure to use the host's ``catgets`` in this situation. + +.. option:: --with-libiconv-prefix=dir + + Search for libiconv header files in :samp:`{dir}/include` and + libiconv library files in :samp:`{dir}/lib`. + +.. option:: --enable-obsolete + + Enable configuration for an obsoleted system. If you attempt to + configure GCC for a system (build, host, or target) which has been + obsoleted, and you do not specify this flag, configure will halt with an + error message. + + All support for systems which have been obsoleted in one release of GCC + is removed entirely in the next major release, unless someone steps + forward to maintain the port. + +.. option:: --enable-decimal-float + + Enable (or disable) support for the C decimal floating point extension + that is in the IEEE 754-2008 standard. This is enabled by default only + on PowerPC, i386, and x86_64 GNU/Linux systems. Other systems may also + support it, but require the user to specifically enable it. You can + optionally control which decimal floating point format is used (either + :samp:`bid` or :samp:`dpd`). The :samp:`bid` (binary integer decimal) + format is default on i386 and x86_64 systems, and the :samp:`dpd` + (densely packed decimal) format is default on PowerPC systems. + +.. option:: --enable-fixed-point + + Enable (or disable) support for C fixed-point arithmetic. + This option is enabled by default for some targets (such as MIPS) which + have hardware-support for fixed-point operations. On other targets, you + may enable this option manually. + +.. option:: --with-long-double-128 + + Specify if ``long double`` type should be 128-bit by default on selected + GNU/Linux architectures. If using ``--without-long-double-128``, + ``long double`` will be by default 64-bit, the same as ``double`` type. + When neither of these configure options are used, the default will be + 128-bit ``long double`` when built against GNU C Library 2.4 and later, + 64-bit ``long double`` otherwise. + +.. option:: --with-long-double-format=ibm + + Specify whether ``long double`` uses the IBM extended double format + or the IEEE 128-bit floating point format on PowerPC Linux systems. + This configuration switch will only work on little endian PowerPC + Linux systems and on big endian 64-bit systems where the default cpu + is at least power7 (i.e. :option:`--with-cpu=power7`, + :option:`--with-cpu=power8`, or :option:`--with-cpu=power9` is used). + + If you use the :option:`--with-long-double-64` configuration option, + the :option:`--with-long-double-format=ibm` and + :option:`--with-long-double-format=ieee` options are ignored. + + The default ``long double`` format is to use IBM extended double. + Until all of the libraries are converted to use IEEE 128-bit floating + point, it is not recommended to use + :option:`--with-long-double-format=ieee`. + +.. option:: --enable-fdpic + + On SH Linux systems, generate ELF FDPIC code. + +.. option:: --with-gmp=pathname + + If you want to build GCC but do not have the GMP library, the MPFR + library and/or the MPC library installed in a standard location and + do not have their sources present in the GCC source tree then you + can explicitly specify the directory where they are installed + (:option:`--with-gmp=gmpinstalldir`, + :option:`--with-mpfr=mpfrinstalldir`, + :option:`--with-mpc=mpcinstalldir`). The + :option:`--with-gmp=gmpinstalldir` option is shorthand for + :option:`--with-gmp-lib=gmpinstalldir/lib` and + :option:`--with-gmp-include=gmpinstalldir/include`. Likewise the + :option:`--with-mpfr=mpfrinstalldir` option is shorthand for + :option:`--with-mpfr-lib=mpfrinstalldir/lib` and + :option:`--with-mpfr-include=mpfrinstalldir/include`, also the + :option:`--with-mpc=mpcinstalldir` option is shorthand for + :option:`--with-mpc-lib=mpcinstalldir/lib` and + :option:`--with-mpc-include=mpcinstalldir/include`. If these + shorthand assumptions are not correct, you can use the explicit + include and lib options directly. You might also need to ensure the + shared libraries can be found by the dynamic linker when building and + using GCC, for example by setting the runtime shared library path + variable (:envvar:`LD_LIBRARY_PATH` on GNU/Linux and Solaris systems). + + These flags are applicable to the host platform only. When building + a cross compiler, they will not be used to configure target libraries. + +.. option:: --with-isl=pathname + + If you do not have the isl library installed in a standard location and you + want to build GCC, you can explicitly specify the directory where it is + installed (:option:`--with-isl=islinstalldir`). The + :option:`--with-isl=islinstalldir` option is shorthand for + :option:`--with-isl-lib=islinstalldir/lib` and + :option:`--with-isl-include=islinstalldir/include`. If this + shorthand assumption is not correct, you can use the explicit + include and lib options directly. + + These flags are applicable to the host platform only. When building + a cross compiler, they will not be used to configure target libraries. + +.. option:: --with-stage1-ldflags=flags + + This option may be used to set linker flags to be used when linking + stage 1 of GCC. These are also used when linking GCC if configured with + :option:`--disable-bootstrap`. If :option:`--with-stage1-libs` is not set to a + value, then the default is :samp:`-static-libstdc++ -static-libgcc`, if + supported. + +.. option:: --with-stage1-libs=libs + + This option may be used to set libraries to be used when linking stage 1 + of GCC. These are also used when linking GCC if configured with + :option:`--disable-bootstrap`. + +.. option:: --with-boot-ldflags=flags + + This option may be used to set linker flags to be used when linking + stage 2 and later when bootstrapping GCC. If --with-boot-libs + is not is set to a value, then the default is + :samp:`-static-libstdc++ -static-libgcc`. + +.. option:: --with-boot-libs=libs + + This option may be used to set libraries to be used when linking stage 2 + and later when bootstrapping GCC. + +.. option:: --with-debug-prefix-map=map + + Convert source directory names using :option:`-fdebug-prefix-map` when + building runtime libraries. :samp:`{map}` is a space-separated + list of maps of the form :samp:`{old}={new}`. + +.. option:: --enable-linker-build-id + + Tells GCC to pass :option:`--build-id` option to the linker for all final + links (links performed without the :option:`-r` or :option:`--relocatable` + option), if the linker supports it. If you specify + :option:`--enable-linker-build-id`, but your linker does not + support :option:`--build-id` option, a warning is issued and the + :option:`--enable-linker-build-id` option is ignored. The default is off. + +.. option:: --with-linker-hash-style=choice + + Tells GCC to pass :option:`--hash-style=choice` option to the + linker for all final links. :samp:`{choice}` can be one of + :samp:`sysv`, :samp:`gnu`, and :samp:`both` where :samp:`sysv` is the default. + +.. option:: --enable-gnu-unique-object + + Tells GCC to use the gnu_unique_object relocation for C++ template + static data members and inline function local statics. Enabled by + default for a toolchain with an assembler that accepts it and + GLIBC 2.11 or above, otherwise disabled. + +.. option:: --with-diagnostics-color=choice + + Tells GCC to use :samp:`{choice}` as the default for :option:`-fdiagnostics-color=` + option (if not used explicitly on the command line). :samp:`{choice}` + can be one of :samp:`never`, :samp:`auto`, :samp:`always`, and :samp:`auto-if-env` + where :samp:`auto` is the default. :samp:`auto-if-env` makes + :option:`-fdiagnostics-color=auto` the default if :envvar:`GCC_COLORS` + is present and non-empty in the environment of the compiler, and + :option:`-fdiagnostics-color=never` otherwise. + +.. option:: --with-diagnostics-urls=choice + + Tells GCC to use :samp:`{choice}` as the default for :option:`-fdiagnostics-urls=` + option (if not used explicitly on the command line). :samp:`{choice}` + can be one of :samp:`never`, :samp:`auto`, :samp:`always`, and :samp:`auto-if-env` + where :samp:`auto` is the default. :samp:`auto-if-env` makes + :option:`-fdiagnostics-urls=auto` the default if :envvar:`GCC_URLS` + or :envvar:`TERM_URLS` is present and non-empty in the environment of the + compiler, and :option:`-fdiagnostics-urls=never` otherwise. + +.. option:: --enable-lto + + Enable support for link-time optimization (LTO). This is enabled by + default, and may be disabled using :option:`--disable-lto`. + +.. option:: --enable-linker-plugin-configure-flags=FLAGS + + By default, linker plugins (such as the LTO plugin) are built for the + host system architecture. For the case that the linker has a + different (but run-time compatible) architecture, these flags can be + specified to build plugins that are compatible to the linker. For + example, if you are building GCC for a 64-bit x86_64 + (:samp:`x86_64-pc-linux-gnu`) host system, but have a 32-bit x86 + GNU/Linux (:samp:`i686-pc-linux-gnu`) linker executable (which is + executable on the former system), you can configure GCC as follows for + getting compatible linker plugins: + + .. code-block:: bash + + % srcdir/configure \ + --host=x86_64-pc-linux-gnu \ + --enable-linker-plugin-configure-flags=--host=i686-pc-linux-gnu \ + --enable-linker-plugin-flags='CC=gcc\ -m32\ -Wl,-rpath,[...]/i686-pc-linux-gnu/lib' + +.. option:: --with-plugin-ld=pathname + + Enable an alternate linker to be used at link-time optimization (LTO) + link time when :option:`-fuse-linker-plugin` is enabled. + This linker should have plugin support such as gold starting with + version 2.20 or GNU ld starting with version 2.21. + See :option:`-fuse-linker-plugin` for details. + +.. option:: --enable-canonical-system-headers + + Enable system header path canonicalization for :samp:`libcpp`. This can + produce shorter header file paths in diagnostics and dependency output + files, but these changed header paths may conflict with some compilation + environments. Enabled by default, and may be disabled using + :option:`--disable-canonical-system-headers`. + +.. option:: --with-glibc-version=major.minor + + Tell GCC that when the GNU C Library (glibc) is used on the target it + will be version :samp:`{major}`. :samp:`{minor}` or later. Normally this can + be detected from the C library's header files, but this option may be + needed when bootstrapping a cross toolchain without the header files + available for building the initial bootstrap compiler. + + If GCC is configured with some multilibs that use glibc and some that + do not, this option applies only to the multilibs that use glibc. + However, such configurations may not work well as not all the relevant + configuration in GCC is on a per-multilib basis. + +.. option:: --enable-as-accelerator-for=target + + Build as offload target compiler. Specify offload host triple by :samp:`{target}`. + +.. option:: --enable-offload-targets=target1[=path1],...,targetN[=pathN] + + Enable offloading to targets :samp:`{target1}`, ..., :samp:`{targetN}`. + Offload compilers are expected to be already installed. Default search + path for them is :samp:`{exec-prefix}`, but it can be changed by + specifying paths :samp:`{path1}`, ..., :samp:`{pathN}`. + + .. code-block:: bash + + % srcdir/configure \ + --enable-offload-targets=amdgcn-amdhsa,nvptx-none + +.. option:: --enable-offload-defaulted + + Tell GCC that configured but not installed offload compilers and libgomp + plugins are silently ignored. Useful for distribution compilers where + those are in separate optional packages and where the presence or absence + of those optional packages should determine the actual supported offloading + target set rather than the GCC configure-time selection. + +.. option:: --enable-cet + + Enable building target run-time libraries with control-flow + instrumentation, see :option:`-fcf-protection` option. When + :option:`--enable-cet` is specified target libraries are configured + to add :option:`-fcf-protection` and, if needed, other target + specific options to a set of building options. + + :option:`--enable-cet`:samp:`=auto` is default. CET is enabled on Linux/x86 if + target binutils supports ``Intel CET`` instructions and disabled + otherwise. In this case, the target libraries are configured to get + additional :option:`-fcf-protection` option. + +.. option:: --with-riscv-attribute=yes, no or default + + Generate RISC-V attribute by default, in order to record extra build + information in object. + + The option is disabled by default. It is enabled on RISC-V/ELF (bare-metal) + target if target binutils supported. + +.. option:: --enable-s390-excess-float-precision + + On s390(x) targets, enable treatment of float expressions with double precision + when in standards-compliant mode (e.g., when ``--std=c99`` or + ``-fexcess-precision=standard`` are given). + + For a native build and cross compiles that have target headers, the option's + default is derived from glibc's behavior. When glibc clamps float_t to double, + GCC follows and enables the option. For other cross compiles, the default is + disabled. + +.. option:: --with-zstd=pathname + + If you do not have the ``zstd`` library installed in a standard + location and you want to build GCC, you can explicitly specify the + directory where it is installed (:samp:`--with-zstd={zstdinstalldir}`). + The :option:`--with-zstd=zstdinstalldir` option is shorthand for + :option:`--with-zstd-lib=zstdinstalldir/lib` and + :option:`--with-zstd-include=zstdinstalldir/include`. If this + shorthand assumption is not correct, you can use the explicit + include and lib options directly. + +.. option:: --with-sphinx-build + + The documentation depends on ``Sphinx`` version |needs_sphinx| and you can provide + an alternative path to ``sphinx-build`` which can be easily installed in + a virtual environment. For more information, please see :ref:`gccint:sphinx_install`. + +These flags are applicable to the host platform only. When building +a cross compiler, they will not be used to configure target libraries. + +Cross-Compiler-Specific Options +=============================== + +The following options only apply to building cross compilers. + +.. option:: --with-toolexeclibdir=dir + + Specify the installation directory for libraries built with a cross compiler. + The default is ``${gcc_tooldir}/lib``. + +.. option:: --with-sysroot + + Tells GCC to consider :samp:`{dir}` as the root of a tree that contains + (a subset of) the root filesystem of the target operating system. + Target system headers, libraries and run-time object files will be + searched for in there. More specifically, this acts as if + :option:`--sysroot=dir` was added to the default options of the built + compiler. The specified directory is not copied into the + install tree, unlike the options :option:`--with-headers` and + :option:`--with-libs` that this option obsoletes. The default value, + in case :option:`--with-sysroot` is not given an argument, is + ${gcc_tooldir}/sys-root. If the specified directory is a + subdirectory of ${exec_prefix}, then it will be found relative to + the GCC binaries if the installation tree is moved. + + This option affects the system root for the compiler used to build + target libraries (which runs on the build system) and the compiler newly + installed with ``make install`` ; it does not affect the compiler which is + used to build GCC itself. + + If you specify the :option:`--with-native-system-header-dir=dirname` + option then the compiler will search that directory within :samp:`{dirname}` for + native system headers rather than the default :samp:`/usr/include`. + +.. option:: --with-build-sysroot + + Tells GCC to consider :samp:`{dir}` as the system root (see + :option:`--with-sysroot`) while building target libraries, instead of + the directory specified with :option:`--with-sysroot`. This option is + only useful when you are already using :option:`--with-sysroot`. You + can use :option:`--with-build-sysroot` when you are configuring with + :option:`--prefix` set to a directory that is different from the one in + which you are installing GCC and your target libraries. + + This option affects the system root for the compiler used to build + target libraries (which runs on the build system); it does not affect + the compiler which is used to build GCC itself. + + If you specify the :option:`--with-native-system-header-dir=dirname` + option then the compiler will search that directory within :samp:`{dirname}` for + native system headers rather than the default :samp:`/usr/include`. + +.. option:: --with-headers + + Deprecated in favor of :option:`--with-sysroot`. + Specifies that target headers are available when building a cross compiler. + The :samp:`{dir}` argument specifies a directory which has the target include + files. These include files will be copied into the :samp:`gcc` install + directory. This option with the :samp:`{dir}` argument is required when + building a cross compiler, if :samp:`{prefix}/{target}/sys-include` + doesn't pre-exist. If :samp:`{prefix}/{target}/sys-include` does + pre-exist, the :samp:`{dir}` argument may be omitted. :command:`fixincludes` + will be run on these files to make them compatible with GCC. + +.. option:: --without-headers + + Tells GCC not use any target headers from a libc when building a cross + compiler. When crossing to GNU/Linux, you need the headers so GCC + can build the exception handling for libgcc. + +.. option:: --with-libs + + Deprecated in favor of :option:`--with-sysroot`. + Specifies a list of directories which contain the target runtime + libraries. These libraries will be copied into the :samp:`gcc` install + directory. If the directory list is omitted, this option has no + effect. + +.. option:: --with-newlib + + Specifies that :samp:`newlib` is + being used as the target C library. This causes ``__eprintf`` to be + omitted from :samp:`libgcc.a` on the assumption that it will be provided by + :samp:`newlib`. + +.. option:: --with-avrlibc + + Only supported for the AVR target. Specifies that :samp:`AVR-Libc` is + being used as the target C |nbsp| library. This causes float support + functions like ``__addsf3`` to be omitted from :samp:`libgcc.a` on + the assumption that it will be provided by :samp:`libm.a`. For more + technical details, cf. :pr:`54461`. + It is not supported for + RTEMS configurations, which currently use newlib. The option is + supported since version 4.7.2 and is the default in 4.8.0 and newer. + +.. option:: --with-double={32|64|32,64|64,32} + + Only supported for the AVR target since version |nbsp| 10. + Specify the default layout available for the C/C++ :samp:`double` + and :samp:`long double` type, respectively. The following rules apply: + + * The first value after the :samp:`=` specifies the default layout (in bits) + of the type and also the default for the :option:`-mdouble=` resp. + :option:`-mlong-double=` compiler option. + + * If more than one value is specified, respective multilib variants are + available, and :option:`-mdouble=` resp. :option:`-mlong-double=` acts + as a multilib option. + + * If :option:`--with-long-double=double` is specified, :samp:`double` and + :samp:`long double` will have the same layout. + + * The defaults are :option:`--with-long-double=64,32` and + :option:`--with-double=32,64`. The default :samp:`double` layout imposed by + the latter is compatible with older versions of the compiler that implement + :samp:`double` as a 32-bit type, which does not comply to the language standard. + + Not all combinations of :option:`--with-double=` and + :option:`--with-long-double=` are valid. For example, the combination + :option:`--with-double=32,64` :option:`--with-long-double=32` will be + rejected because the first option specifies the availability of + multilibs for :samp:`double`, whereas the second option implies + that :samp:`long double` --- and hence also :samp:`double` --- is always + 32 |nbsp| bits wide. + +.. option:: --with-double-comparison={tristate|bool|libf7} + + Only supported for the AVR target since version |nbsp| 10. + Specify what result format is returned by library functions that + compare 64-bit floating point values (``DFmode``). + The GCC default is :samp:`tristate`. If the floating point + implementation returns a boolean instead, set it to :samp:`bool`. + +.. option:: --with-libf7={libgcc|math|math-symbols|no} + + Only supported for the AVR target since version |nbsp| 10. + Specify to which degree code from LibF7 is included in libgcc. + LibF7 is an ad-hoc, AVR-specific, 64-bit floating point emulation + written in C and (inline) assembly. :samp:`libgcc` adds support + for functions that one would usually expect in libgcc like double addition, + double comparisons and double conversions. :samp:`math` also adds routines + that one would expect in :samp:`libm.a`, but with ``__`` (two underscores) + prepended to the symbol names as specified by :samp:`math.h`. + :samp:`math-symbols` also defines weak aliases for the functions + declared in :samp:`math.h`. However, ``--with-libf7`` won't + install no :samp:`math.h` header file whatsoever, this file must come + from elsewhere. This option sets :option:`--with-double-comparison` + to :samp:`bool`. + +.. option:: --with-nds32-lib=library + + Specifies that :samp:`{library}` setting is used for building :samp:`libgcc.a`. + Currently, the valid :samp:`{library}` is :samp:`newlib` or :samp:`mculib`. + This option is only supported for the NDS32 target. + +.. option:: --with-build-time-tools=dir + + Specifies where to find the set of target tools (assembler, linker, etc.) + that will be used while building GCC itself. This option can be useful + if the directory layouts are different between the system you are building + GCC on, and the system where you will deploy it. + + For example, on an :samp:`ia64-hp-hpux` system, you may have the GNU + assembler and linker in :samp:`/usr/bin`, and the native tools in a + different path, and build a toolchain that expects to find the + native tools in :samp:`/usr/bin`. + + When you use this option, you should ensure that :samp:`{dir}` includes + :command:`ar`, :command:`as`, :command:`ld`, :command:`nm`, + :command:`ranlib` and :command:`strip` if necessary, and possibly + :command:`objdump`. Otherwise, GCC may use an inconsistent set of + tools. + +Overriding configure test results +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Sometimes, it might be necessary to override the result of some +:command:`configure` test, for example in order to ease porting to a new +system or work around a bug in a test. The toplevel :command:`configure` +script provides three variables for this: + +``build_configargs`` + The contents of this variable is passed to all build :command:`configure` + scripts. + +``host_configargs`` + The contents of this variable is passed to all host :command:`configure` + scripts. + +``target_configargs`` + The contents of this variable is passed to all target :command:`configure` + scripts. + + In order to avoid shell and :command:`make` quoting issues for complex + overrides, you can pass a setting for :envvar:`CONFIG_SITE` and set + variables in the site file. + +Objective-C-Specific Options +============================ + +The following options apply to the build of the Objective-C runtime library. + +.. option:: --enable-objc-gc + + Specify that an additional variant of the GNU Objective-C runtime library + is built, using an external build of the Boehm-Demers-Weiser garbage + collector (https://www.hboehm.info/gc/). This library needs to be + available for each multilib variant, unless configured with + :option:`--enable-objc-gc=auto` in which case the build of the + additional runtime library is skipped when not available and the build + continues. + +.. option:: --with-target-bdw-gc=list + + Specify search directories for the garbage collector header files and + libraries. :samp:`{list}` is a comma separated list of key value pairs of the + form :samp:`{multilibdir}={path}`, where the default multilib key + is named as :samp:`.` (dot), or is omitted (e.g. + :samp:`--with-target-bdw-gc=/opt/bdw-gc,32=/opt-bdw-gc32`). + + The options :option:`--with-target-bdw-gc-include` and + :option:`--with-target-bdw-gc-lib` must always be specified together + for each multilib variant and they take precedence over + :option:`--with-target-bdw-gc`. If :option:`--with-target-bdw-gc-include` + is missing values for a multilib, then the value for the default + multilib is used (e.g. :samp:`--with-target-bdw-gc-include=/opt/bdw-gc/include` + :samp:`--with-target-bdw-gc-lib=/opt/bdw-gc/lib64,32=/opt-bdw-gc/lib32`). + If none of these options are specified, the library is assumed in + default locations. + +D-Specific Options +================== + +The following options apply to the build of the D runtime library. + +.. option:: --enable-libphobos-checking + + This option controls whether run-time checks and contracts are compiled into + the D runtime library. When the option is not specified, the library is built + with :samp:`release` checking. When the option is specified without a + :samp:`{list}`, the result is the same as :samp:`--enable-libphobos-checking=yes`. + Likewise, :samp:`--disable-libphobos-checking` is equivalent to + :samp:`--enable-libphobos-checking=no`. + + The categories of checks available in :samp:`{list}` are :samp:`yes` (compiles + libphobos with :option:`-fno-release`), :samp:`no` (compiles libphobos with + :option:`-frelease`), :samp:`all` (same as :samp:`yes`), :samp:`none` or + :samp:`release` (same as :samp:`no`). + + Individual checks available in :samp:`{list}` are :samp:`assert` (compiles libphobos + with an extra option :option:`-fassert`). + +.. option:: --with-libphobos-druntime-only + + Specify whether to build only the core D runtime library (druntime), or both + the core and standard library (phobos) into libphobos. This is useful for + targets that have full support in druntime, but no or incomplete support + in phobos. :samp:`{choice}` can be one of :samp:`auto`, :samp:`yes`, and :samp:`no` + where :samp:`auto` is the default. + + When the option is not specified, the default choice :samp:`auto` means that it + is inferred whether the target has support for the phobos standard library. + When the option is specified without a :samp:`{choice}`, the result is the same as + :samp:`--with-libphobos-druntime-only=yes`. + +.. option:: --with-target-system-zlib + + Use installed :samp:`zlib` rather than that included with GCC. This needs + to be available for each multilib variant, unless configured with + :option:`--with-target-system-zlib=auto` in which case the GCCincluded + :samp:`zlib` is only used when the system installed library is not available. \ No newline at end of file diff --git a/gcc/doc/install/copyright.rst b/gcc/doc/install/copyright.rst new file mode 100644 index 00000000000..8f9b3bc7d75 --- /dev/null +++ b/gcc/doc/install/copyright.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Copyright +^^^^^^^^^ + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, the Front-Cover texts being (a) (see below), and +with the Back-Cover Texts being (b) (see below). A copy of the license is +in the :ref:`gnu_fdl`. + +(a) The FSF's Front-Cover Text is: + + A GNU Manual + +(b) The FSF's Back-Cover Text is: + + You have freedom to copy and modify this GNU Manual, like GNU + software. Copies published by the Free Software Foundation raise + funds for GNU development. \ No newline at end of file diff --git a/gcc/doc/install/downloading-gcc.rst b/gcc/doc/install/downloading-gcc.rst new file mode 100644 index 00000000000..bb11f64a70d --- /dev/null +++ b/gcc/doc/install/downloading-gcc.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Downloading GCC, Downloading the Source + +.. _downloading-the-source: + +Downloading GCC +--------------- + +GCC is distributed via `git `_ and via +HTTPS as tarballs compressed with :command:`gzip` or :command:`bzip2`. + +Please refer to the `releases web page `_ +for information on how to obtain GCC. + +The source distribution includes the C, C++, Objective-C, Fortran, +and Ada (in the case of GCC 3.1 and later) compilers, as well as +runtime libraries for C++, Objective-C, and Fortran. +For previous versions these were downloadable as separate components such +as the core GCC distribution, which included the C language front end and +shared components, and language-specific distributions including the +language front end and the language runtime (where appropriate). + +If you also intend to build binutils (either to upgrade an existing +installation or for use in place of the corresponding tools of your +OS), unpack the binutils distribution either in the same directory or +a separate one. In the latter case, add symbolic links to any +components of the binutils you intend to build alongside the compiler +(:samp:`bfd`, :samp:`binutils`, :samp:`gas`, :samp:`gprof`, :samp:`ld`, +:samp:`opcodes`, ...) to the directory containing the GCC sources. + +Likewise the GMP, MPFR and MPC libraries can be automatically built +together with GCC. You may simply run the +:command:`contrib/download_prerequisites` script in the GCC source directory +to set up everything. +Otherwise unpack the GMP, MPFR and/or MPC source +distributions in the directory containing the GCC sources and rename +their directories to :samp:`gmp`, :samp:`mpfr` and :samp:`mpc`, +respectively (or use symbolic links with the same name). \ No newline at end of file diff --git a/gcc/doc/install/final-installation.rst b/gcc/doc/install/final-installation.rst new file mode 100644 index 00000000000..68702092621 --- /dev/null +++ b/gcc/doc/install/final-installation.rst @@ -0,0 +1,128 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _final-install: + +Final installation +------------------ + +Now that GCC has been built (and optionally tested), you can install it with + +.. code-block:: bash + + cd objdir && make install + +We strongly recommend to install into a target directory where there is +no previous version of GCC present. Also, the GNAT runtime should not +be stripped, as this would break certain features of the debugger that +depend on this debugging information (catching Ada exceptions for +instance). + +That step completes the installation of GCC; user level binaries can +be found in :samp:`{prefix}/bin` where :samp:`{prefix}` is the value +you specified with the :option:`--prefix` to configure (or +:samp:`/usr/local` by default). (If you specified :option:`--bindir`, +that directory will be used instead; otherwise, if you specified +:option:`--exec-prefix`, :samp:`{exec-prefix}/bin` will be used.) +Headers for the C++ library are installed in +:samp:`{prefix}/include`; libraries in :samp:`{libdir}` +(normally :samp:`{prefix}/lib`); internal parts of the compiler in +:samp:`{libdir}/gcc` and :samp:`{libexecdir}/gcc`; documentation +in info format in :samp:`{infodir}` (normally +:samp:`{prefix}/info`). + +When installing cross-compilers, GCC's executables +are not only installed into :samp:`{bindir}`, that +is, :samp:`{exec-prefix}/bin`, but additionally into +:samp:`{exec-prefix}/{target-alias}/bin`, if that directory +exists. Typically, such :dfn:`tooldirs` hold target-specific +binutils, including assembler and linker. + +Installation into a temporary staging area or into a :command:`chroot` +jail can be achieved with the command + +.. code-block:: bash + + make DESTDIR=path-to-rootdir install + +where :samp:`{path-to-rootdir}` is the absolute path of +a directory relative to which all installation paths will be +interpreted. Note that the directory specified by ``DESTDIR`` +need not exist yet; it will be created if necessary. + +There is a subtle point with tooldirs and ``DESTDIR`` : +If you relocate a cross-compiler installation with +e.g. :samp:`DESTDIR={rootdir}`, then the directory +:samp:`{rootdir}/{exec-prefix}/{target-alias}/bin` will +be filled with duplicated GCC executables only if it already exists, +it will not be created otherwise. This is regarded as a feature, +not as a bug, because it gives slightly more control to the packagers +using the ``DESTDIR`` feature. + +You can install stripped programs and libraries with + +.. code-block:: bash + + make install-strip + +If you are bootstrapping a released version of GCC then please +quickly review the build status page for your release, available from +https://gcc.gnu.org/buildstat.html. +If your system is not listed for the version of GCC that you built, +send a note to +gcc@gcc.gnu.org indicating +that you successfully built and installed GCC. +Include the following information: + +* Output from running :samp:`{srcdir}/config.guess`. Do not send + that file itself, just the one-line output from running it. + +* The output of :samp:`gcc -v` for your newly installed :command:`gcc`. + This tells us which version of GCC you built and the options you passed to + configure. + +* Whether you enabled all languages or a subset of them. If you used a + full distribution then this information is part of the configure + options in the output of :samp:`gcc -v`, but if you downloaded the + 'core' compiler plus additional front ends then it isn't apparent + which ones you built unless you tell us about it. + +* If the build was for GNU/Linux, also include: + + * The distribution name and version (e.g., Red Hat 7.1 or Debian 2.2.3); + this information should be available from :samp:`/etc/issue`. + + * The version of the Linux kernel, available from :samp:`uname --version` + or :samp:`uname -a`. + + * The version of glibc you used; for RPM-based systems like Red Hat, + Mandrake, and SuSE type :samp:`rpm -q glibc` to get the glibc version, + and on systems like Debian and Progeny use :samp:`dpkg -l libc6`. + + For other systems, you can include similar information if you think it is + relevant. + +* Any other information that you think would be useful to people building + GCC on the same configuration. The new entry in the build status list + will include a link to the archived copy of your message. + +We'd also like to know if the +:ref:`specific` +didn't include your host/target information or if that information is +incomplete or out of date. Send a note to +gcc@gcc.gnu.org detailing how the information should be changed. + +If you find a bug, please report it following the +`bug reporting guidelines `_. + +If you want to print the GCC manuals, do :samp:`cd {objdir}; make pdf` +You will need to have Sphinx (version at least |needs_sphinx|) +and XeLaTex installed. +You can also `buy printed manuals from the +Free Software Foundation `_, though such manuals may not be for the most +recent version of GCC. + +If you would like to generate online HTML documentation, do :samp:`cd +{objdir}; make html`. \ No newline at end of file diff --git a/gcc/doc/install/gnu-free-documentation-license.rst b/gcc/doc/install/gnu-free-documentation-license.rst new file mode 100644 index 00000000000..1de809b3636 --- /dev/null +++ b/gcc/doc/install/gnu-free-documentation-license.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/gnu_free_documentation_license.rst \ No newline at end of file diff --git a/gcc/doc/install/host-target-specific-installation-notes-for-gcc.rst b/gcc/doc/install/host-target-specific-installation-notes-for-gcc.rst new file mode 100644 index 00000000000..c05a65ab21f --- /dev/null +++ b/gcc/doc/install/host-target-specific-installation-notes-for-gcc.rst @@ -0,0 +1,1336 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Specific, Specific installation notes, Target specific installation, Host specific installation, Target specific installation notes + +.. _specific: + +Host/target specific installation notes for GCC +----------------------------------------------- + +Please read this document carefully *before* installing the +GNU Compiler Collection on your machine. + +Note that this list of install notes is *not* a list of supported +hosts or targets. Not all supported hosts and targets are listed +here, only the ones that require host-specific or target-specific +information have to. + +aarch64\*-\*-\* +=============== + +Binutils pre 2.24 does not have support for selecting :option:`-mabi` and +does not support ILP32. If it is used to build GCC 4.9 or later, GCC will +not support option :option:`-mabi=ilp32`. + +To enable a workaround for the Cortex-A53 erratum number 835769 by default +(for all CPUs regardless of -mcpu option given) at configure time use the +:option:`--enable-fix-cortex-a53-835769` option. This will enable the fix by +default and can be explicitly disabled during compilation by passing the +:option:`-mno-fix-cortex-a53-835769` option. Conversely, +:option:`--disable-fix-cortex-a53-835769` will disable the workaround by +default. The workaround is disabled by default if neither of +:option:`--enable-fix-cortex-a53-835769` or +:option:`--disable-fix-cortex-a53-835769` is given at configure time. + +To enable a workaround for the Cortex-A53 erratum number 843419 by default +(for all CPUs regardless of -mcpu option given) at configure time use the +:option:`--enable-fix-cortex-a53-843419` option. This workaround is applied at +link time. Enabling the workaround will cause GCC to pass the relevant option +to the linker. It can be explicitly disabled during compilation by passing the +:option:`-mno-fix-cortex-a53-843419` option. Conversely, +:option:`--disable-fix-cortex-a53-843419` will disable the workaround by default. +The workaround is disabled by default if neither of +:option:`--enable-fix-cortex-a53-843419` or +:option:`--disable-fix-cortex-a53-843419` is given at configure time. + +To enable Branch Target Identification Mechanism and Return Address Signing by +default at configure time use the :option:`--enable-standard-branch-protection` +option. This is equivalent to having :option:`-mbranch-protection=standard` +during compilation. This can be explicitly disabled during compilation by +passing the :option:`-mbranch-protection=none` option which turns off all +types of branch protections. Conversely, +:option:`--disable-standard-branch-protection` will disable both the +protections by default. This mechanism is turned off by default if neither +of the options are given at configure time. + +alpha\*-\*-\* +============= + +This section contains general configuration information for all +Alpha-based platforms using ELF. In addition to reading this +section, please read all other sections that match your target. + +amd64-\*-solaris2\* +=================== + +This is a synonym for :samp:`x86_64-*-solaris2*`. + +amdgcn-\*-amdhsa +================ + +AMD GCN GPU target. + +Instead of GNU Binutils, you will need to install LLVM 13.0.1, or later, and copy +:samp:`bin/llvm-mc` to :samp:`amdgcn-amdhsa/bin/as`, +:samp:`bin/lld` to :samp:`amdgcn-amdhsa/bin/ld`, +:samp:`bin/llvm-nm` to :samp:`amdgcn-amdhsa/bin/nm`, and +:samp:`bin/llvm-ar` to both :samp:`bin/amdgcn-amdhsa-ar` and +:samp:`bin/amdgcn-amdhsa-ranlib`. + +Use Newlib (3.2.0, or newer). + +To run the binaries, install the HSA Runtime from the +`ROCm Platform `_, and use +:samp:`libexec/gcc/amdhsa-amdhsa/{version}/gcn-run` to launch them +on the GPU. + +arc-\*-elf32 +============ + +Use :samp:`configure --target=arc-elf32 --with-cpu={cpu} --enable-languages="c,c++"` +to configure GCC, with :samp:`{cpu}` being one of :samp:`arc600`, :samp:`arc601`, +or :samp:`arc700`. + +arc-linux-uclibc +================ + +Use :samp:`configure --target=arc-linux-uclibc --with-cpu=arc700 --enable-languages="c,c++"` to configure GCC. + +arm-\*-eabi +=========== + +ARM-family processors. + +Building the Ada frontend commonly fails (an infinite loop executing +``xsinfo``) if the host compiler is GNAT 4.8. Host compilers built from the +GNAT 4.6, 4.9 or 5 release branches are known to succeed. + +avr +=== + +ATMEL AVR-family micro controllers. These are used in embedded +applications. There are no standard Unix configurations. +See :ref:`gcc:avr-options`, +for the list of supported MCU types. + +Use :samp:`configure --target=avr --enable-languages="c"` to configure GCC. + +Further installation notes and other useful information about AVR tools +can also be obtained from: + +* `http://www.nongnu.org/avr/ `_ + +* `http://www.amelek.gda.pl/avr/ `_ + +The following error: + +.. code-block:: bash + + Error: register required + +indicates that you should upgrade to a newer version of the binutils. + +Blackfin +======== + +The Blackfin processor, an Analog Devices DSP. +See :ref:`gcc:blackfin-options`, + +More information, and a version of binutils with support for this processor, +are available at https://sourceforge.net/projects/adi-toolchain/. + +CRIS +==== + +CRIS is a CPU architecture in Axis Communications systems-on-a-chip, for +example the ETRAX series. These are used in embedded applications. + +See :ref:`gcc:cris-options`, +for a list of CRIS-specific options. + +Use :samp:`configure --target=cris-elf` to configure GCCfor building +a cross-compiler for CRIS. + +DOS +=== + +Please have a look at the `binaries page `_. + +You cannot install GCC by itself on MSDOS; it will not compile under +any MSDOS compiler except itself. You need to get the complete +compilation package DJGPP, which includes binaries as well as sources, +and includes all the necessary compilation tools and libraries. + +epiphany-\*-elf +=============== + +Adapteva Epiphany. +This configuration is intended for embedded systems. + +\*-\*-freebsd\* +=============== + +In order to better utilize FreeBSD base system functionality and match +the configuration of the system compiler, GCC 4.5 and above as well as +GCC 4.4 past 2010-06-20 leverage SSP support in libc (which is present +on FreeBSD 7 or later) and the use of ``__cxa_atexit`` by default +(on FreeBSD 6 or later). The use of ``dl_iterate_phdr`` inside +:samp:`libgcc_s.so.1` and boehm-gc (on FreeBSD 7 or later) is enabled +by GCC 4.5 and above. + +We support FreeBSD using the ELF file format with DWARF 2 debugging +for all CPU architectures. There are +no known issues with mixing object files and libraries with different +debugging formats. Otherwise, this release of GCC should now match +more of the configuration used in the stock FreeBSD configuration of +GCC. In particular, :option:`--enable-threads` is now configured by +default. However, as a general user, do not attempt to replace the +system compiler with this release. Known to bootstrap and check with +good results on FreeBSD 7.2-STABLE. In the past, known to bootstrap +and check with good results on FreeBSD 3.0, 3.4, 4.0, 4.2, 4.3, 4.4, +4.5, 4.8, 4.9 and 5-CURRENT. + +The version of binutils installed in :samp:`/usr/bin` probably works +with this release of GCC. Bootstrapping against the latest GNU +binutils and/or the version found in :samp:`/usr/ports/devel/binutils` has +been known to enable additional features and improve overall testsuite +results. However, it is currently known that boehm-gc may not configure +properly on FreeBSD prior to the FreeBSD 7.0 release with GNU binutils +after 2.16.1. + +ft32-\*-elf +=========== + +The FT32 processor. +This configuration is intended for embedded systems. + +h8300-hms +========= + +Renesas H8/300 series of processors. + +Please have a look at the `binaries page `_. + +The calling convention and structure layout has changed in release 2.6. +All code must be recompiled. The calling convention now passes the +first three arguments in function calls in registers. Structures are no +longer a multiple of 2 bytes. + +hppa\*-hp-hpux\* +================ + +Support for HP-UX version 9 and older was discontinued in GCC 3.4. + +We require using gas/binutils on all hppa platforms. Version 2.19 or +later is recommended. + +It may be helpful to configure GCC with the :option:`--with-gnu-as` and +:option:`--with-as=...` options to ensure that GCC can find GAS. + +The HP assembler should not be used with GCC. It is rarely tested and may +not work. It shouldn't be used with any languages other than C due to its +many limitations. + +Specifically, :option:`-g` does not work (HP-UX uses a peculiar debugging +format which GCC does not know about). It also inserts timestamps +into each object file it creates, causing the 3-stage comparison test to +fail during a bootstrap. You should be able to continue by saying +:samp:`make all-host all-target` after getting the failure from :samp:`make`. + +Various GCC features are not supported. For example, it does not support weak +symbols or alias definitions. As a result, explicit template instantiations +are required when using C++. This makes it difficult if not impossible to +build many C++ applications. + +There are two default scheduling models for instructions. These are +PROCESSOR_7100LC and PROCESSOR_8000. They are selected from the pa-risc +architecture specified for the target machine when configuring. +PROCESSOR_8000 is the default. PROCESSOR_7100LC is selected when +the target is a :samp:`hppa1*` machine. + +The PROCESSOR_8000 model is not well suited to older processors. Thus, +it is important to completely specify the machine architecture when +configuring if you want a model other than PROCESSOR_8000. The macro +TARGET_SCHED_DEFAULT can be defined in BOOT_CFLAGS if a different +default scheduling model is desired. + +As of GCC 4.0, GCC uses the UNIX 95 namespace for HP-UX 10.10 +through 11.00, and the UNIX 98 namespace for HP-UX 11.11 and later. +This namespace change might cause problems when bootstrapping with +an earlier version of GCC or the HP compiler as essentially the same +namespace is required for an entire build. This problem can be avoided +in a number of ways. With HP cc, :envvar:`UNIX_STD` can be set to :samp:`95` +or :samp:`98`. Another way is to add an appropriate set of predefines +to :envvar:`CC`. The description for the munix= option contains +a list of the predefines used with each standard. + +More specific information to :samp:`hppa*-hp-hpux*` targets follows. + +hppa\*-hp-hpux10 +================ + +For hpux10.20, we *highly* recommend you pick up the latest sed patch +``PHCO_19798`` from HP. + +The C++ ABI has changed incompatibly in GCC 4.0. COMDAT subspaces are +used for one-only code and data. This resolves many of the previous +problems in using C++ on this target. However, the ABI is not compatible +with the one implemented under HP-UX 11 using secondary definitions. + +hppa\*-hp-hpux11 +================ + +GCC 3.0 and up support HP-UX 11. GCC 2.95.x is not supported and cannot +be used to compile GCC 3.0 and up. + +The libffi library haven't been ported to 64-bit HP-UXand doesn't build. + +Refer to `binaries page `_ for information about obtaining +precompiled GCC binaries for HP-UX. Precompiled binaries must be obtained +to build the Ada language as it cannot be bootstrapped using C. Ada is +only available for the 32-bit PA-RISC runtime. + +Starting with GCC 3.4 an ISO C compiler is required to bootstrap. The +bundled compiler supports only traditional C; you will need either HP's +unbundled compiler, or a binary distribution of GCC. + +It is possible to build GCC 3.3 starting with the bundled HP compiler, +but the process requires several steps. GCC 3.3 can then be used to +build later versions. + +There are several possible approaches to building the distribution. +Binutils can be built first using the HP tools. Then, the GCC +distribution can be built. The second approach is to build GCC +first using the HP tools, then build binutils, then rebuild GCC. +There have been problems with various binary distributions, so it +is best not to start from a binary distribution. + +On 64-bit capable systems, there are two distinct targets. Different +installation prefixes must be used if both are to be installed on +the same system. The :samp:`hppa[1-2]*-hp-hpux11*` target generates code +for the 32-bit PA-RISC runtime architecture and uses the HP linker. +The :samp:`hppa64-hp-hpux11*` target generates 64-bit code for the +PA-RISC 2.0 architecture. + +The script config.guess now selects the target type based on the compiler +detected during configuration. You must define :envvar:`PATH` or :envvar:`CC` so +that configure finds an appropriate compiler for the initial bootstrap. +When :envvar:`CC` is used, the definition should contain the options that are +needed whenever :envvar:`CC` is used. + +Specifically, options that determine the runtime architecture must be +in :envvar:`CC` to correctly select the target for the build. It is also +convenient to place many other compiler options in :envvar:`CC`. For example, +:envvar:`CC="cc -Ac +DA2.0W -Wp,-H16376 -D_CLASSIC_TYPES -D_HPUX_SOURCE"` +can be used to bootstrap the GCC 3.3 branch with the HP compiler in +64-bit K&R/bundled mode. The +DA2.0W option will result in +the automatic selection of the :samp:`hppa64-hp-hpux11*` target. The +macro definition table of cpp needs to be increased for a successful +build with the HP compiler. _CLASSIC_TYPES and _HPUX_SOURCE need to +be defined when building with the bundled compiler, or when using the +:option:`-Ac` option. These defines aren't necessary with :option:`-Ae`. + +It is best to explicitly configure the :samp:`hppa64-hp-hpux11*` target +with the :option:`--with-ld=...` option. This overrides the standard +search for ld. The two linkers supported on this target require different +commands. The default linker is determined during configuration. As a +result, it's not possible to switch linkers in the middle of a GCC build. +This has been reported to sometimes occur in unified builds of binutils +and GCC. + +A recent linker patch must be installed for the correct operation of +GCC 3.3 and later. ``PHSS_26559`` and ``PHSS_24304`` are the +oldest linker patches that are known to work. They are for HP-UX +11.00 and 11.11, respectively. ``PHSS_24303``, the companion to +``PHSS_24304``, might be usable but it hasn't been tested. These +patches have been superseded. Consult the HP patch database to obtain +the currently recommended linker patch for your system. + +The patches are necessary for the support of weak symbols on the +32-bit port, and for the running of initializers and finalizers. Weak +symbols are implemented using SOM secondary definition symbols. Prior +to HP-UX 11, there are bugs in the linker support for secondary symbols. +The patches correct a problem of linker core dumps creating shared +libraries containing secondary symbols, as well as various other +linking issues involving secondary symbols. + +GCC 3.3 uses the ELF DT_INIT_ARRAY and DT_FINI_ARRAY capabilities to +run initializers and finalizers on the 64-bit port. The 32-bit port +uses the linker +init and +fini options for the same +purpose. The patches correct various problems with the +init/+fini +options, including program core dumps. Binutils 2.14 corrects a +problem on the 64-bit port resulting from HP's non-standard use of +the .init and .fini sections for array initializers and finalizers. + +Although the HP and GNU linkers are both supported for the +:samp:`hppa64-hp-hpux11*` target, it is strongly recommended that the +HP linker be used for link editing on this target. + +At this time, the GNU linker does not support the creation of long +branch stubs. As a result, it cannot successfully link binaries +containing branch offsets larger than 8 megabytes. In addition, +there are problems linking shared libraries, linking executables +with :option:`-static`, and with dwarf2 unwind and exception support. +It also doesn't provide stubs for internal calls to global functions +in shared libraries, so these calls cannot be overloaded. + +The HP dynamic loader does not support GNU symbol versioning, so symbol +versioning is not supported. It may be necessary to disable symbol +versioning with :option:`--disable-symvers` when using GNU ld. + +POSIX threads are the default. The optional DCE thread library is not +supported, so :option:`--enable-threads=dce` does not work. + +\*-\*-linux-gnu +=============== + +The ``.init_array`` and ``.fini_array`` sections are enabled +unconditionally which requires at least glibc 2.1 and binutils 2.12. + +Versions of libstdc++-v3 starting with 3.2.1 require bug fixes present +in glibc 2.2.5 and later. More information is available in the +libstdc++-v3 documentation. + +i?86-\*-linux\* +=============== + +As of GCC 3.3, binutils 2.13.1 or later is required for this platform. +See :pr:`10877` for more information. + +If you receive Signal 11 errors when building on GNU/Linux, then it is +possible you have a hardware problem. Further information on this can be +found on `www.bitwizard.nl `_. + +i?86-\*-solaris2\* +================== + +Use this for Solaris 11.3 or later on x86 and x86-64 systems. Starting +with GCC 4.7, there is also a 64-bit :samp:`amd64-*-solaris2*` or +:samp:`x86_64-*-solaris2*` configuration that corresponds to +:samp:`sparcv9-sun-solaris2*`. + +It is recommended that you configure GCC to use the GNU assembler. The +versions included in Solaris 11.3, from GNU binutils 2.23.1 or +newer (available as :samp:`/usr/bin/gas` and +:samp:`/usr/gnu/bin/as`), work fine. The current version, from GNU +binutils 2.34, is known to work. Recent versions of the Solaris assembler in +:samp:`/usr/bin/as` work almost as well, though. + +For linking, the Solaris linker is preferred. If you want to use the GNU +linker instead, the version in Solaris 11.3, from GNU binutils 2.23.1 or +newer (in :samp:`/usr/gnu/bin/ld` and :samp:`/usr/bin/gld`), works, +as does the latest version, from GNU binutils 2.34. + +To use GNU :command:`as`, configure with the options +:option:`--with-gnu-as --with-as=/usr/gnu/bin/as`. It may be necessary +to configure with :option:`--without-gnu-ld --with-ld=/usr/ccs/bin/ld` to +guarantee use of Solaris :command:`ld`. + +.. todo:: why -without-gnu-ld -with-ld? + +ia64-\*-linux +============= + +IA-64 processor (also known as IPF, or Itanium Processor Family) +running GNU/Linux. + +If you are using the installed system libunwind library with +:option:`--with-system-libunwind`, then you must use libunwind 0.98 or +later. + +ia64-\*-hpux\* +============== + +Building GCC on this target requires the GNU Assembler. The bundled HP +assembler will not work. To prevent GCC from using the wrong assembler, +the option :option:`--with-gnu-as` may be necessary. + +The GCC libunwind library has not been ported to HPUX. This means that for +GCC versions 3.2.3 and earlier, :option:`--enable-libunwind-exceptions` +is required to build GCC. For GCC 3.3 and later, this is the default. +For gcc 3.4.3 and later, :option:`--enable-libunwind-exceptions` is +removed and the system libunwind library will always be used. + +\*-ibm-aix\* +============ + +Support for AIX version 3 and older was discontinued in GCC 3.4. +Support for AIX version 4.2 and older was discontinued in GCC 4.5. + +'out of memory' bootstrap failures may indicate a problem with +process resource limits (ulimit). Hard limits are configured in the +:samp:`/etc/security/limits` system configuration file. + +GCC 4.9 and above require a C++ compiler for bootstrap. IBM VAC++ / xlC +cannot bootstrap GCC. xlc can bootstrap an older version of GCC and +G++ can bootstrap recent releases of GCC. + +GCC can bootstrap with recent versions of IBM XLC, but bootstrapping +with an earlier release of GCC is recommended. Bootstrapping with XLC +requires a larger data segment, which can be enabled through the +:samp:`{LDR_CNTRL}` environment variable, e.g., + +.. code-block:: bash + + % LDR_CNTRL=MAXDATA=0x50000000 + % export LDR_CNTRL + +One can start with a pre-compiled version of GCC to build from +sources. One may delete GCC's 'fixed' header files when starting +with a version of GCC built for an earlier release of AIX. + +To speed up the configuration phases of bootstrapping and installing GCC, +one may use GNU Bash instead of AIX :command:`/bin/sh`, e.g., + +.. code-block:: bash + + % CONFIG_SHELL=/opt/freeware/bin/bash + % export CONFIG_SHELL + +and then proceed as described in :ref:`building`, +where we strongly recommend specifying an absolute path +to invoke :samp:`{srcdir}` /configure. + +Because GCC on AIX is built as a 32-bit executable by default, +(although it can generate 64-bit programs) the GMP and MPFR libraries +required by gfortran must be 32-bit libraries. Building GMP and MPFR +as static archive libraries works better than shared libraries. + +Errors involving ``alloca`` when building GCC generally are due +to an incorrect definition of ``CC`` in the Makefile or mixing files +compiled with the native C compiler and GCC. During the stage1 phase of +the build, the native AIX compiler **must** be invoked as :command:`cc` +(not :command:`xlc`). Once :command:`configure` has been informed of +:command:`xlc`, one needs to use :samp:`make distclean` to remove the +configure cache files and ensure that :envvar:`CC` environment variable +does not provide a definition that will confuse :command:`configure`. +If this error occurs during stage2 or later, then the problem most likely +is the version of Make (see above). + +The native :command:`as` and :command:`ld` are recommended for +bootstrapping on AIX. The GNU Assembler, GNU Linker, and GNU +Binutils version 2.20 is the minimum level that supports bootstrap on +AIX 5. The GNU Assembler has not been updated to support AIX 6or +AIX 7. The native AIX tools do interoperate with GCC. + +AIX 7.1 added partial support for DWARF debugging, but full support +requires AIX 7.1 TL03 SP7 that supports additional DWARF sections and +fixes a bug in the assembler. AIX 7.1 TL03 SP5 distributed a version +of libm.a missing important symbols; a fix for IV77796 will be +included in SP6. + +AIX 5.3 TL10, AIX 6.1 TL05 and AIX 7.1 TL00 introduced an AIX +assembler change that sometimes produces corrupt assembly files +causing AIX linker errors. The bug breaks GCC bootstrap on AIX and +can cause compilation failures with existing GCC installations. An +AIX iFix for AIX 5.3 is available (APAR IZ98385 for AIX 5.3 TL10, APAR +IZ98477 for AIX 5.3 TL11 and IZ98134 for AIX 5.3 TL12). AIX 5.3 TL11 SP8, +AIX 5.3 TL12 SP5, AIX 6.1 TL04 SP11, AIX 6.1 TL05 SP7, AIX 6.1 TL06 SP6, +AIX 6.1 TL07 and AIX 7.1 TL01 should include the fix. + +Building :samp:`libstdc++.a` requires a fix for an AIX Assembler bug +APAR IY26685 (AIX 4.3) or APAR IY25528 (AIX 5.1). It also requires a +fix for another AIX Assembler bug and a co-dependent AIX Archiver fix +referenced as APAR IY53606 (AIX 5.2) or as APAR IY54774 (AIX 5.1) + +.. _transferaixshobj: + +:samp:`libstdc++` in GCC 3.4 increments the major version number of the +shared object and GCC installation places the :samp:`libstdc++.a` +shared library in a common location which will overwrite the and GCC +3.3 version of the shared library. Applications either need to be +re-linked against the new shared library or the GCC 3.1 and GCC 3.3 +versions of the :samp:`libstdc++` shared object needs to be available +to the AIX runtime loader. The GCC 3.1 :samp:`libstdc++.so.4`, if +present, and GCC 3.3 :samp:`libstdc++.so.5` shared objects can be +installed for runtime dynamic loading using the following steps to set +the :samp:`F_LOADONLY` flag in the shared object for *each* +multilib :samp:`libstdc++.a` installed: + +Extract the shared objects from the currently installed +:samp:`libstdc++.a` archive: + +.. code-block:: bash + + % ar -x libstdc++.a libstdc++.so.4 libstdc++.so.5 + +Enable the :samp:`F_LOADONLY` flag so that the shared object will be +available for runtime dynamic loading, but not linking: + +.. code-block:: bash + + % strip -e libstdc++.so.4 libstdc++.so.5 + +Archive the runtime-only shared object in the GCC 3.4 +:samp:`libstdc++.a` archive: + +.. code-block:: bash + + % ar -q libstdc++.a libstdc++.so.4 libstdc++.so.5 + +Eventually, the :option:`--with-aix-soname=svr4` +configure option may drop the need for this procedure for libraries that +support it. + +Linking executables and shared libraries may produce warnings of +duplicate symbols. The assembly files generated by GCC for AIX always +have included multiple symbol definitions for certain global variable +and function declarations in the original program. The warnings should +not prevent the linker from producing a correct library or runnable +executable. + +AIX 4.3 utilizes a 'large format' archive to support both 32-bit and +64-bit object modules. The routines provided in AIX 4.3.0 and AIX 4.3.1 +to parse archive libraries did not handle the new format correctly. +These routines are used by GCC and result in error messages during +linking such as 'not a COFF file'. The version of the routines shipped +with AIX 4.3.1 should work for a 32-bit environment. The :option:`-g` +option of the archive command may be used to create archives of 32-bit +objects using the original 'small format'. A correct version of the +routines is shipped with AIX 4.3.2 and above. + +Some versions of the AIX binder (linker) can fail with a relocation +overflow severe error when the :option:`-bbigtoc` option is used to link +GCC-produced object files into an executable that overflows the TOC. A fix +for APAR IX75823 (OVERFLOW DURING LINK WHEN USING GCC AND -BBIGTOC) is +available from IBM Customer Support and from its +`techsupport.services.ibm.com `_ +website as PTF U455193. + +The AIX 4.3.2.1 linker (bos.rte.bind_cmds Level 4.3.2.1) will dump core +with a segmentation fault when invoked by any version of GCC. A fix for +APAR IX87327 is available from IBM Customer Support and from its +`techsupport.services.ibm.com `_ +website as PTF U461879. This fix is incorporated in AIX 4.3.3 and above. + +The initial assembler shipped with AIX 4.3.0 generates incorrect object +files. A fix for APAR IX74254 (64BIT DISASSEMBLED OUTPUT FROM COMPILER FAILS +TO ASSEMBLE/BIND) is available from IBM Customer Support and from its +`techsupport.services.ibm.com `_ +website as PTF U453956. This fix is incorporated in AIX 4.3.1 and above. + +AIX provides National Language Support (NLS). Compilers and assemblers +use NLS to support locale-specific representations of various data +formats including floating-point numbers (e.g., :samp:`.` vs :samp:`,` for +separating decimal fractions). There have been problems reported where +GCC does not produce the same floating-point formats that the assembler +expects. If one encounters this problem, set the :envvar:`LANG` +environment variable to :samp:`C` or :samp:`En_US`. + +A default can be specified with the :option:`-mcpu=cpu_type` +switch and using the configure option :option:`--with-cpu-cpu_type`. + +iq2000-\*-elf +============= + +Vitesse IQ2000 processors. These are used in embedded +applications. There are no standard Unix configurations. + +lm32-\*-elf +=========== + +Lattice Mico32 processor. +This configuration is intended for embedded systems. + +lm32-\*-uclinux +=============== + +Lattice Mico32 processor. +This configuration is intended for embedded systems running uClinux. + +LoongArch +========= + +LoongArch processor. +The following LoongArch targets are available: + +``loongarch64-linux-gnu*`` + LoongArch processor running GNU/Linux. This target triplet may be coupled + with a small set of possible suffixes to identify their default ABI type: + + ``f64`` + Uses ``lp64d/base`` ABI by default. + + ``f32`` + Uses ``lp64f/base`` ABI by default. + + ``sf`` + Uses ``lp64s/base`` ABI by default. + +``loongarch64-linux-gnu`` + Same as ``loongarch64-linux-gnuf64``, but may be used with + :option:`--with-abi=*` to configure the default ABI type. + + More information about LoongArch can be found at + https://github.com/loongson/LoongArch-Documentation. + +m32c-\*-elf +=========== + +Renesas M32C processor. +This configuration is intended for embedded systems. + +m32r-\*-elf +=========== + +Renesas M32R processor. +This configuration is intended for embedded systems. + +m68k-\*-\* +========== + +By default, +:samp:`m68k-*-elf*`, :samp:`m68k-*-rtems`, :samp:`m68k-*-uclinux` and +:samp:`m68k-*-linux` +build libraries for both M680x0 and ColdFire processors. If you only +need the M680x0 libraries, you can omit the ColdFire ones by passing +:option:`--with-arch=m68k` to :command:`configure`. Alternatively, you +can omit the M680x0 libraries by passing :option:`--with-arch=cf` to +:command:`configure`. These targets default to 5206 or 5475 code as +appropriate for the target system when +configured with :option:`--with-arch=cf` and 68020 code otherwise. + +The :samp:`m68k-*-netbsd` and +:samp:`m68k-*-openbsd` targets also support the :option:`--with-arch` +option. They will generate ColdFire CFV4e code when configured with +:option:`--with-arch=cf` and 68020 code otherwise. + +You can override the default processors listed above by configuring +with :option:`--with-cpu=target`. This :samp:`{target}` can either +be a :option:`-mcpu` argument or one of the following values: +:samp:`m68000`, :samp:`m68010`, :samp:`m68020`, :samp:`m68030`, +:samp:`m68040`, :samp:`m68060`, :samp:`m68020-40` and :samp:`m68020-60`. + +GCC requires at least binutils version 2.17 on these targets. + +m68k-\*-uclinux +=============== + +GCC 4.3 changed the uClinux configuration so that it uses the +:samp:`m68k-linux-gnu` ABI rather than the :samp:`m68k-elf` ABI. +It also added improved support for C++ and flat shared libraries, +both of which were ABI changes. + +microblaze-\*-elf +================= + +Xilinx MicroBlaze processor. +This configuration is intended for embedded systems. + +mips-\*-\* +========== + +If on a MIPS system you get an error message saying 'does not have gp +sections for all it's [sic] sectons [sic]', don't worry about it. This +happens whenever you use GAS with the MIPS linker, but there is not +really anything wrong, and it is okay to use the output file. You can +stop such warnings by installing the GNU linker. + +It would be nice to extend GAS to produce the gp tables, but they are +optional, and there should not be a warning about their absence. + +The libstdc++ atomic locking routines for MIPS targets requires MIPS II +and later. A patch went in just after the GCC 3.3 release to +make :samp:`mips*-*-*` use the generic implementation instead. You can also +configure for :samp:`mipsel-elf` as a workaround. The +:samp:`mips*-*-linux*` target continues to use the MIPS II routines. More +work on this is expected in future releases. + +.. If you make -with-llsc the default for another target, please also + update the description of the -with-llsc option. + +The built-in ``__sync_*`` functions are available on MIPS II and +later systems and others that support the :samp:`ll`, :samp:`sc` and +:samp:`sync` instructions. This can be overridden by passing +:option:`--with-llsc` or :option:`--without-llsc` when configuring GCC. +Since the Linux kernel emulates these instructions if they are +missing, the default for :samp:`mips*-*-linux*` targets is +:option:`--with-llsc`. The :option:`--with-llsc` and +:option:`--without-llsc` configure options may be overridden at compile +time by passing the :option:`-mllsc` or :option:`-mno-llsc` options to +the compiler. + +MIPS systems check for division by zero (unless +:option:`-mno-check-zero-division` is passed to the compiler) by +generating either a conditional trap or a break instruction. Using +trap results in smaller code, but is only supported on MIPS II and +later. Also, some versions of the Linux kernel have a bug that +prevents trap from generating the proper signal (``SIGFPE``). To enable +the use of break, use the :option:`--with-divide=breaks` +:command:`configure` option when configuring GCC. The default is to +use traps on systems that support them. + +moxie-\*-elf +============ + +The moxie processor. + +msp430-\*-elf\* +=============== + +TI MSP430 processor. +This configuration is intended for embedded systems. + +:samp:`msp430-*-elf` is the standard configuration with most GCC +features enabled by default. + +:samp:`msp430-*-elfbare` is tuned for a bare-metal environment, and disables +features related to shared libraries and other functionality not used for +this device. This reduces code and data usage of the GCC libraries, resulting +in a minimal run-time environment by default. + +Features disabled by default include: + +* transactional memory + +* __cxa_atexit + +nds32le-\*-elf +============== + +Andes NDS32 target in little endian mode. + +nds32be-\*-elf +============== + +Andes NDS32 target in big endian mode. + +nvptx-\*-none +============= + +Nvidia PTX target. + +Instead of GNU binutils, you will need to install +`nvptx-tools `_. +Tell GCC where to find it: +:option:`--with-build-time-tools=[install-nvptx-tools]/nvptx-none/bin`. + +You will need newlib 3.1.0 or later. It can be +automatically built together with GCC. For this, add a symbolic link +to nvptx-newlib's :samp:`newlib` directory to the directory containing +the GCC sources. + +Use the :option:`--disable-sjlj-exceptions` and +:option:`--enable-newlib-io-long-long` options when configuring. + +The :option:`--with-arch` option may be specified to override the +default value for the :option:`-march` option, and to also build +corresponding target libraries. +The default is :option:`--with-arch=sm_30`. + +For example, if :option:`--with-arch=sm_70` is specified, +:option:`-march=sm_30` and :option:`-march=sm_70` target libraries are +built, and code generation defaults to :option:`-march=sm_70`. + +or1k-\*-elf +=========== + +The OpenRISC 1000 32-bit processor with delay slots. +This configuration is intended for embedded systems. + +or1k-\*-linux +============= + +The OpenRISC 1000 32-bit processor with delay slots. + +powerpc-\*-\* +============= + +You can specify a default version for the :option:`-mcpu=cpu_type` +switch by using the configure option :option:`--with-cpu-cpu_type`. + +You will need GNU binutils 2.20 or newer. + +powerpc-\*-darwin\* +=================== + +PowerPC running Darwin (Mac OS X kernel). + +Pre-installed versions of Mac OS X may not include any developer tools, +meaning that you will not be able to build GCC from source. Tool +binaries are available at +https://opensource.apple.com. + +This version of GCC requires at least cctools-590.36. The +cctools-590.36 package referenced from +https://gcc.gnu.org/ml/gcc/2006-03/msg00507.html will not work +on systems older than 10.3.9 (aka darwin7.9.0). + +powerpc-\*-elf +============== + +PowerPC system in big endian mode, running System V.4. + +powerpc\*-\*-linux-gnu\* +======================== + +PowerPC system in big endian mode running Linux. + +powerpc-\*-netbsd\* +=================== + +PowerPC system in big endian mode running NetBSD. + +powerpc-\*-eabisim +================== + +Embedded PowerPC system in big endian mode for use in running under the +PSIM simulator. + +powerpc-\*-eabi +=============== + +Embedded PowerPC system in big endian mode. + +powerpcle-\*-elf +================ + +PowerPC system in little endian mode, running System V.4. + +powerpcle-\*-eabisim +==================== + +Embedded PowerPC system in little endian mode for use in running under +the PSIM simulator. + +powerpcle-\*-eabi +================= + +Embedded PowerPC system in little endian mode. + +rl78-\*-elf +=========== + +The Renesas RL78 processor. +This configuration is intended for embedded systems. + +riscv32-\*-elf +============== + +The RISC-V RV32 instruction set. +This configuration is intended for embedded systems. +This (and all other RISC-V) targets require the binutils 2.30 release. + +riscv32-\*-linux +================ + +The RISC-V RV32 instruction set running GNU/Linux. +This (and all other RISC-V) targets require the binutils 2.30 release. + +riscv64-\*-elf +============== + +The RISC-V RV64 instruction set. +This configuration is intended for embedded systems. +This (and all other RISC-V) targets require the binutils 2.30 release. + +riscv64-\*-linux +================ + +The RISC-V RV64 instruction set running GNU/Linux. +This (and all other RISC-V) targets require the binutils 2.30 release. + +rx-\*-elf +========= + +The Renesas RX processor. + +s390-\*-linux\* +=============== + +S/390 system running GNU/Linux for S/390. + +s390x-\*-linux\* +================ + +zSeries system (64-bit) running GNU/Linux for zSeries. + +s390x-ibm-tpf\* +=============== + +zSeries system (64-bit) running TPF. This platform is +supported as cross-compilation target only. + +.. Please use Solaris 2 to refer to all release of Solaris, starting + with 2.0 until 2.6, 7, 8, etc. Solaris 1 was a marketing name for + SunOS 4 releases which we don't use to avoid confusion. Solaris + alone is too unspecific and must be avoided. + +\*-\*-solaris2\* +================ + +Support for Solaris 10 has been removed in GCC 10. Support for Solaris +9 has been removed in GCC 5. Support for Solaris 8 has been removed in +GCC 4.8. Support for Solaris 7 has been removed in GCC 4.6. + +Solaris 11.3 provides GCC 4.5.2, 4.7.3, and 4.8.2 as +:command:`/usr/gcc/4.5/bin/gcc` or similar. Newer Solaris versions +provide one or more of GCC 5, 7, and 9. Alternatively, +you can install a pre-built GCC to bootstrap and install GCC. See the +:ref:`binaries` for details. + +The Solaris 2 :command:`/bin/sh` will often fail to configure +:samp:`libstdc++-v3`. We therefore recommend using the +following initial sequence of commands + +.. code-block:: bash + + % CONFIG_SHELL=/bin/ksh + % export CONFIG_SHELL + +and proceed as described in :ref:`configuration` the configure instructions. +In addition we strongly recommend specifying an absolute path to invoke +:samp:`{srcdir}/configure`. + +In Solaris 11, you need to check for ``system/header``, +``system/linker``, and ``developer/assembler`` packages. + +Trying to use the linker and other tools in +:samp:`/usr/ucb` to install GCC has been observed to cause trouble. +For example, the linker may hang indefinitely. The fix is to remove +:samp:`/usr/ucb` from your :envvar:`PATH`. + +The build process works more smoothly with the legacy Solaris tools so, if you +have :samp:`/usr/xpg4/bin` in your :envvar:`PATH`, we recommend that you place +:samp:`/usr/bin` before :samp:`/usr/xpg4/bin` for the duration of the build. + +We recommend the use of the Solaris assembler or the GNU assembler, in +conjunction with the Solaris linker. The GNU :command:`as` +versions included in Solaris 11.3, +from GNU binutils 2.23.1 or newer (in :samp:`/usr/bin/gas` and +:samp:`/usr/gnu/bin/as`), are known to work. +The current version, from GNU binutils 2.34, +is known to work as well. Note that your mileage may vary +if you use a combination of the GNU tools and the Solaris tools: while the +combination GNU :command:`as` + Solaris :command:`ld` should reasonably work, +the reverse combination Solaris :command:`as` + GNU :command:`ld` may fail to +build or cause memory corruption at runtime in some cases for C++ programs. + +.. todo:: still? + +GNU :command:`ld` usually works as well. Again, the current +version (2.34) is known to work, but generally lacks platform specific +features, so better stay with Solaris :command:`ld`. To use the LTO linker +plugin (:option:`-fuse-linker-plugin`) with GNU :command:`ld`, GNU +binutils *must* be configured with :option:`--enable-largefile`. + +To enable symbol versioning in :samp:`libstdc++` with the Solaris linker, +you need to have any version of GNU :command:`c++filt`, which is part of +GNU binutils. :samp:`libstdc++` symbol versioning will be disabled if no +appropriate version is found. Solaris :command:`c++filt` from the Solaris +Studio compilers does *not* work. + +In order to build the GNU D compiler, GDC, a working :samp:`libphobos` is +needed. That library wasn't built by default in GCC 9--11 on SPARC, or +on x86 when the Solaris assembler is used, but can be enabled by +configuring with :option:`--enable-libphobos`. Also, GDC 9.4.0 is +required on x86, while GDC 9.3.0 is known to work on SPARC. + +The versions of the GNU Multiple Precision Library (GMP), the MPFR +library and the MPC library bundled with Solaris 11.3 and later are +usually recent enough to match GCC's requirements. There are two +caveats: + +* While the version of the GMP library in Solaris 11.3 works with GCC, you + need to configure with :option:`--with-gmp-include=/usr/include/gmp`. + +* The version of the MPFR libary included in Solaris 11.3 is too old; you + need to provide a more recent one. + +sparc\*-\*-\* +============= + +This section contains general configuration information for all +SPARC-based platforms. In addition to reading this section, please +read all other sections that match your target. + +Newer versions of the GNU Multiple Precision Library (GMP), the MPFR +library and the MPC library are known to be miscompiled by earlier +versions of GCC on these platforms. We therefore recommend the use +of the exact versions of these libraries listed as minimal versions +in :ref:`prerequisites` the prerequisites. + +sparc-sun-solaris2\* +==================== + +When GCC is configured to use GNU binutils 2.14 or later, the binaries +produced are smaller than the ones produced using Solaris native tools; +this difference is quite significant for binaries containing debugging +information. + +Starting with Solaris 7, the operating system is capable of executing +64-bit SPARC V9 binaries. GCC 3.1 and later properly supports +this; the :option:`-m64` option enables 64-bit code generation. +However, if all you want is code tuned for the UltraSPARC CPU, you +should try the :option:`-mtune=ultrasparc` option instead, which produces +code that, unlike full 64-bit code, can still run on non-UltraSPARC +machines. + +When configuring the GNU Multiple Precision Library (GMP), the MPFR +library or the MPC library on a Solaris 7 or later system, the canonical +target triplet must be specified as the :command:`build` parameter on the +configure line. This target triplet can be obtained by invoking :command:`./config.guess` in the toplevel source directory of GCC (and +not that of GMP or MPFR or MPC). For example on a Solaris 11 system: + +.. code-block:: bash + + % ./configure --build=sparc-sun-solaris2.11 --prefix=xxx + +sparc-\*-linux\* +================ + +sparc64-\*-solaris2\* +===================== + +When configuring a 64-bit-default GCC on Solaris/SPARC, you must use a +build compiler that generates 64-bit code, either by default or by +specifying :samp:`CC='gcc -m64' CXX='gcc-m64'` to :command:`configure`. +Additionally, you *must* pass :option:`--build=sparc64-sun-solaris2.11` +or :option:`--build=sparcv9-sun-solaris2.11` because :samp:`config.guess` +misdetects this situation, which can cause build failures. + +When configuring the GNU Multiple Precision Library (GMP), the MPFR +library or the MPC library, the canonical target triplet must be specified +as the :command:`build` parameter on the configure line. For example +on a Solaris 11 system: + +.. code-block:: bash + + % ./configure --build=sparc64-sun-solaris2.11 --prefix=xxx + +sparcv9-\*-solaris2\* +===================== + +This is a synonym for :samp:`sparc64-*-solaris2*`. + +c6x-\*-\* +========= + +The C6X family of processors. This port requires binutils-2.22 or newer. + +visium-\*-elf +============= + +CDS VISIUMcore processor. +This configuration is intended for embedded systems. + +\*-\*-vxworks\* +=============== + +Support for VxWorks is in flux. At present GCC supports *only* the +very recent VxWorks 5.5 (aka Tornado 2.2) release, and only on PowerPC. +We welcome patches for other architectures supported by VxWorks 5.5. +Support for VxWorks AE would also be welcome; we believe this is merely +a matter of writing an appropriate 'configlette' (see below). We are +not interested in supporting older, a.out or COFF-based, versions of +VxWorks in GCC 3. + +VxWorks comes with an older version of GCC installed in +:samp:`{$WIND_BASE}/host`; we recommend you do not overwrite it. +Choose an installation :samp:`{prefix}` entirely outside :samp:`{$WIND_BASE}`. +Before running :command:`configure`, create the directories :samp:`{prefix}` +and :samp:`{prefix}/bin`. Link or copy the appropriate assembler, +linker, etc. into :samp:`{prefix}/bin`, and set your :samp:`{PATH}` to +include that directory while running both :command:`configure` and +:command:`make`. + +You must give :command:`configure` the +:option:`--with-headers=$WIND_BASE/target/h` switch so that it can +find the VxWorks system headers. Since VxWorks is a cross compilation +target only, you must also specify :option:`--target=target`. +:command:`configure` will attempt to create the directory +:samp:`{prefix}/{target}/sys-include` and copy files into it; +make sure the user running :command:`configure` has sufficient privilege +to do so. + +GCC's exception handling runtime requires a special 'configlette' +module, :samp:`contrib/gthr_supp_vxw_5x.c`. Follow the instructions in +that file to add the module to your kernel build. (Future versions of +VxWorks will incorporate this module.) + +x86_64-\*-\*, amd64-\*-\* +========================= + +GCC supports the x86-64 architecture implemented by the AMD64 processor +(amd64-\*-\* is an alias for x86_64-\*-\*) on GNU/Linux, FreeBSD and NetBSD. +On GNU/Linux the default is a bi-arch compiler which is able to generate +both 64-bit x86-64 and 32-bit x86 code (via the :option:`-m32` switch). + +x86_64-\*-solaris2\* +==================== + +GCC also supports the x86-64 architecture implemented by the AMD64 +processor (:samp:`amd64-*-*` is an alias for :samp:`x86_64-*-*`) on +Solaris 10 or later. Unlike other systems, without special options a +bi-arch compiler is built which generates 32-bit code by default, but +can generate 64-bit x86-64 code with the :option:`-m64` switch. Since +GCC 4.7, there is also a configuration that defaults to 64-bit code, but +can generate 32-bit code with :option:`-m32`. To configure and build +this way, you have to provide all support libraries like :samp:`libgmp` +as 64-bit code, configure with :option:`--target=x86_64-pc-solaris2.11` +and :samp:`CC=gcc -m64`. + +xtensa\*-\*-elf +=============== + +This target is intended for embedded Xtensa systems using the +:samp:`newlib` C library. It uses ELF but does not support shared +objects. Designed-defined instructions specified via the +Tensilica Instruction Extension (TIE) language are only supported +through inline assembly. + +The Xtensa configuration information must be specified prior to +building GCC. The :samp:`include/xtensa-config.h` header +file contains the configuration information. If you created your +own Xtensa configuration with the Xtensa Processor Generator, the +downloaded files include a customized copy of this header file, +which you can use to replace the default header file. + +xtensa\*-\*-linux\* +=================== + +This target is for Xtensa systems running GNU/Linux. It supports ELF +shared objects and the GNU C library (glibc). It also generates +position-independent code (PIC) regardless of whether the +:option:`-fpic` or :option:`-fPIC` options are used. In other +respects, this target is the same as the +:samp:`xtensa*-*-elf` target. + +Microsoft Windows +================= + +Intel 16-bit versions +===================== + +The 16-bit versions of Microsoft Windows, such as Windows 3.1, are not +supported. + +However, the 32-bit port has limited support for Microsoft +Windows 3.11 in the Win32s environment, as a target only. See below. + +Intel 32-bit versions +===================== + +The 32-bit versions of Windows, including Windows 95, Windows NT, Windows +XP, and Windows Vista, are supported by several different target +platforms. These targets differ in which Windows subsystem they target +and which C libraries are used. + +* Cygwin \*-\*-cygwin: Cygwin provides a user-space + Linux API emulation layer in the Win32 subsystem. + +* MinGW \*-\*-mingw32: MinGW is a native GCC port for + the Win32 subsystem that provides a subset of POSIX. + +* MKS i386-pc-mks: NuTCracker from MKS. See + https://www.mkssoftware.com for more information. + +Intel 64-bit versions +===================== + +GCC contains support for x86-64 using the mingw-w64 +runtime library, available from https://www.mingw-w64.org/downloads/. +This library should be used with the target triple x86_64-pc-mingw32. + +Windows CE +========== + +Windows CE is supported as a target only on Hitachi +SuperH (sh-wince-pe), and MIPS (mips-wince-pe). + +Other Windows Platforms +======================= + +GCC no longer supports Windows NT on the Alpha or PowerPC. + +GCC no longer supports the Windows POSIX subsystem. However, it does +support the Interix subsystem. See above. + +Old target names including \*-\*-winnt and \*-\*-windowsnt are no longer used. + +PW32 (i386-pc-pw32) support was never completed, and the project seems to +be inactive. See http://pw32.sourceforge.net/ for more information. + +UWIN support has been removed due to a lack of maintenance. + +\*-\*-cygwin +============ + +Ports of GCC are included with the +`Cygwin environment `_. + +GCC will build under Cygwin without modification; it does not build +with Microsoft's C++ compiler and there are no plans to make it do so. + +The Cygwin native compiler can be configured to target any 32-bit x86 +cpu architecture desired; the default is i686-pc-cygwin. It should be +used with as up-to-date a version of binutils as possible; use either +the latest official GNU binutils release in the Cygwin distribution, +or version 2.20 or above if building your own. + +\*-\*-mingw32 +============= + +GCC will build with and support only MinGW runtime 3.12 and later. +Earlier versions of headers are incompatible with the new default semantics +of ``extern inline`` in ``-std=c99`` and ``-std=gnu99`` modes. + +To support emitting DWARF debugging info you need to use GNU binutils +version 2.16 or above containing support for the ``.secrel32`` +assembler pseudo-op. + +Older systems +============= + +GCC contains support files for many older (1980s and early +1990s) Unix variants. For the most part, support for these systems +has not been deliberately removed, but it has not been maintained for +several years and may suffer from bitrot. + +Starting with GCC 3.1, each release has a list of 'obsoleted' systems. +Support for these systems is still present in that release, but +:command:`configure` will fail unless the :option:`--enable-obsolete` +option is given. Unless a maintainer steps forward, support for these +systems will be removed from the next release of GCC. + +Support for old systems as hosts for GCC can cause problems if the +workarounds for compiler, library and operating system bugs affect the +cleanliness or maintainability of the rest of GCC. In some cases, to +bring GCC up on such a system, if still possible with current GCC, may +require first installing an old version of GCC which did work on that +system, and using it to compile a more recent GCC, to avoid bugs in the +vendor compiler. Old releases of GCC 1 and GCC 2 are available in the +:samp:`old-releases` directory on the +`GCC mirror sites `_. +Header bugs may generally be avoided using +:command:`fixincludes`, but bugs or deficiencies in libraries and the +operating system may still cause problems. + +Support for older systems as targets for cross-compilation is less +problematic than support for them as hosts for GCC; if an enthusiast +wishes to make such a target work again (including resurrecting any of +the targets that never worked with GCC 2, starting from the last +version before they were removed), patches +https://gcc.gnu.org/contribute.html following the usual requirements would be +likely to be accepted, since they should not affect the support for more +modern targets. + +For some systems, old versions of GNU binutils may also be useful, +and are available from :samp:`pub/binutils/old-releases` on +`sourceware.org mirror sites `_. + +Some of the information on specific systems above relates to +such older systems, but much of the information +about GCC on such systems (which may no longer be applicable to +current GCC) is to be found in the GCC texinfo manual. + +all ELF targets (SVR4, Solaris 2, etc.) +======================================= + +C++ support is significantly better on ELF targets if you use the +GNU linker; duplicate copies of +inlines, vtables and template instantiations will be discarded +automatically. \ No newline at end of file diff --git a/gcc/doc/install/how-can-you-run-the-testsuite-on-selected-tests.rst b/gcc/doc/install/how-can-you-run-the-testsuite-on-selected-tests.rst new file mode 100644 index 00000000000..563a5b56260 --- /dev/null +++ b/gcc/doc/install/how-can-you-run-the-testsuite-on-selected-tests.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +How can you run the testsuite on selected tests? +************************************************ + +In order to run sets of tests selectively, there are targets +:samp:`make check-gcc` and language specific :samp:`make check-c`, +:samp:`make check-c++`, :samp:`make check-d` :samp:`make check-fortran`, +:samp:`make check-ada`, :samp:`make check-objc`, :samp:`make check-obj-c++`, +:samp:`make check-lto` +in the :samp:`gcc` subdirectory of the object directory. You can also +just run :samp:`make check` in a subdirectory of the object directory. + +A more selective way to just run all :command:`gcc` execute tests in the +testsuite is to use + +.. code-block:: bash + + make check-gcc RUNTESTFLAGS="execute.exp other-options" + +Likewise, in order to run only the :command:`g++` 'old-deja' tests in +the testsuite with filenames matching :samp:`9805*`, you would use + +.. code-block:: bash + + make check-g++ RUNTESTFLAGS="old-deja.exp=9805* other-options" + +The file-matching expression following :samp:`{filename}.exp=` is treated +as a series of whitespace-delimited glob expressions so that multiple patterns +may be passed, although any whitespace must either be escaped or surrounded by +single quotes if multiple expressions are desired. For example, + +.. code-block:: bash + + make check-g++ RUNTESTFLAGS="old-deja.exp=9805*\ virtual2.c other-options" + make check-g++ RUNTESTFLAGS="'old-deja.exp=9805* virtual2.c' other-options" + +The :samp:`*.exp` files are located in the testsuite directories of the GCC +source, the most important ones being :samp:`compile.exp`, +:samp:`execute.exp`, :samp:`dg.exp` and :samp:`old-deja.exp`. +To get a list of the possible :samp:`*.exp` files, pipe the +output of :samp:`make check` into a file and look at the +:samp:`Running ... .exp` lines. \ No newline at end of file diff --git a/gcc/doc/install/how-to-interpret-test-results.rst b/gcc/doc/install/how-to-interpret-test-results.rst new file mode 100644 index 00000000000..ad2a4366938 --- /dev/null +++ b/gcc/doc/install/how-to-interpret-test-results.rst @@ -0,0 +1,32 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +How to interpret test results +***************************** + +The result of running the testsuite are various :samp:`*.sum` and :samp:`*.log` +files in the testsuite subdirectories. The :samp:`*.log` files contain a +detailed log of the compiler invocations and the corresponding +results, the :samp:`*.sum` files summarize the results. These summaries +contain status codes for all tests: + +* PASS: the test passed as expected + +* XPASS: the test unexpectedly passed + +* FAIL: the test unexpectedly failed + +* XFAIL: the test failed as expected + +* UNSUPPORTED: the test is not supported on this platform + +* ERROR: the testsuite detected an error + +* WARNING: the testsuite detected a possible problem + +It is normal for some tests to report unexpected failures. At the +current time the testing harness does not allow fine grained control +over whether or not a test is expected to fail. This problem should +be fixed in future releases. \ No newline at end of file diff --git a/gcc/doc/install/index.rst b/gcc/doc/install/index.rst new file mode 100644 index 00000000000..c7924c66df7 --- /dev/null +++ b/gcc/doc/install/index.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Installing GCC +============== + +.. only:: html + + Contents: + +.. toctree:: + + copyright + installing-gcc + prerequisites + downloading-gcc + configuration + building + testing + final-installation + binaries + host-target-specific-installation-notes-for-gcc + gnu-free-documentation-license.rst + + indices-and-tables \ No newline at end of file diff --git a/gcc/doc/install/indices-and-tables.rst b/gcc/doc/install/indices-and-tables.rst new file mode 100644 index 00000000000..6c215a391d9 --- /dev/null +++ b/gcc/doc/install/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/gcc/doc/install/installing-gcc.rst b/gcc/doc/install/installing-gcc.rst new file mode 100644 index 00000000000..2d680f18a23 --- /dev/null +++ b/gcc/doc/install/installing-gcc.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _installing-gcc: + +Installing GCC +-------------- + +The latest version of this document is always available at +`https://gcc.gnu.org/install/ `_. +It refers to the current development sources, instructions for +specific released versions are included with the sources. + +This document describes the generic installation procedure for GCC as well +as detailing some target specific installation instructions. + +GCC includes several components that previously were separate distributions +with their own installation instructions. This document supersedes all +package-specific installation instructions. + +*Before* starting the build/install procedure please check the +:ref:`specific`. +We recommend you browse the entire generic installation instructions before +you proceed. + +Lists of successful builds for released versions of GCC are +available at https://gcc.gnu.org/buildstat.html. +These lists are updated as new information becomes available. + +The installation procedure itself is broken into five steps. + +Please note that GCC does not support :samp:`make uninstall` and probably +won't do so in the near future as this would open a can of worms. Instead, +we suggest that you install GCC into a directory of its own and simply +remove that directory when you do not need that specific version of GCC +any longer, and, if shared libraries are installed there as well, no +more binaries exist that use them. \ No newline at end of file diff --git a/gcc/doc/install/passing-options-and-running-multiple-testsuites.rst b/gcc/doc/install/passing-options-and-running-multiple-testsuites.rst new file mode 100644 index 00000000000..1dcc8701203 --- /dev/null +++ b/gcc/doc/install/passing-options-and-running-multiple-testsuites.rst @@ -0,0 +1,74 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Passing options and running multiple testsuites +*********************************************** + +You can pass multiple options to the testsuite using the +:samp:`--target_board` option of DejaGNU, either passed as part of +:samp:`RUNTESTFLAGS`, or directly to :command:`runtest` if you prefer to +work outside the makefiles. For example, + +.. code-block:: bash + + make check-g++ RUNTESTFLAGS="--target_board=unix/-O3/-fmerge-constants" + +will run the standard :command:`g++` testsuites ('unix' is the target name +for a standard native testsuite situation), passing +:samp:`-O3 -fmerge-constants` to the compiler on every test, i.e., +slashes separate options. + +You can run the testsuites multiple times using combinations of options +with a syntax similar to the brace expansion of popular shells: + +.. code-block:: bash + + ..."--target_board=arm-sim\{-mhard-float,-msoft-float\}\{-O1,-O2,-O3,\}" + +(Note the empty option caused by the trailing comma in the final group.) +The following will run each testsuite eight times using the :samp:`arm-sim` +target, as if you had specified all possible combinations yourself: + +.. code-block:: bash + + --target_board='arm-sim/-mhard-float/-O1 \ + arm -sim/-mhard-float/-O2 \ + arm -sim/-mhard-float/-O3 \ + arm -sim/-mhard-float \ + arm -sim/-msoft-float/-O1 \ + arm -sim/-msoft-float/-O2 \ + arm -sim/-msoft-float/-O3 \ + arm -sim/-msoft-float' + +They can be combined as many times as you wish, in arbitrary ways. This +list: + +.. code-block:: bash + + ..."--target_board=unix/-Wextra\{-O3,-fno-strength\}\{-fomit-frame,\}" + +will generate four combinations, all involving :samp:`-Wextra`. + +The disadvantage to this method is that the testsuites are run in serial, +which is a waste on multiprocessor systems. For users with GNU Make and +a shell which performs brace expansion, you can run the testsuites in +parallel by having the shell perform the combinations and :command:`make` +do the parallel runs. Instead of using :samp:`--target_board`, use a +special makefile target: + +.. code-block:: bash + + make -jN check-testsuite//test-target/option1/option2/... + +For example, + +.. code-block:: bash + + make -j3 check-gcc//sh-hms-sim/{-m1,-m2,-m3,-m3e,-m4}/{,-nofpu} + +will run three concurrent 'make-gcc' testsuites, eventually testing all +ten combinations as described above. Note that this is currently only +supported in the :samp:`gcc` subdirectory. (To see how this works, try +typing :command:`echo` before the example given here.) \ No newline at end of file diff --git a/gcc/doc/install/prerequisites.rst b/gcc/doc/install/prerequisites.rst new file mode 100644 index 00000000000..44c2f2c1bb1 --- /dev/null +++ b/gcc/doc/install/prerequisites.rst @@ -0,0 +1,319 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Prerequisites + +.. _prerequisites: + +Prerequisites +------------- + +GCC requires that various tools and packages be available for use in the +build procedure. Modifying GCC sources requires additional tools +described below. + +Tools/packages necessary for building GCC +***************************************** + +* ISO C++11 compiler + + Necessary to bootstrap GCC. + + Versions of GCC prior to 11 also allow bootstrapping with an ISO C++98 + compiler, versions of GCC prior to 4.8 also allow bootstrapping with a + ISO C89 compiler, and versions of GCC prior to 3.4 also allow + bootstrapping with a traditional (K&R) C compiler. + + To build all languages in a cross-compiler or other configuration where + 3-stage bootstrap is not performed, you need to start with an existing + GCC binary (version 4.8 or later) because source code for language + frontends other than C might use GCC extensions. + +* C standard library and headers + + In order to build GCC, the C standard library and headers must be present + for all target variants for which target libraries will be built (and not + only the variant of the host C++ compiler). + + This affects the popular :samp:`x86_64-pc-linux-gnu` platform (among + other multilib targets), for which 64-bit (:samp:`x86_64`) and 32-bit + (:samp:`i386`) libc headers are usually packaged separately. If you do a + build of a native compiler on :samp:`x86_64-pc-linux-gnu`, make sure you + either have the 32-bit libc developer package properly installed (the exact + name of the package depends on your distro) or you must build GCC as a + 64-bit only compiler by configuring with the option + :option:`--disable-multilib`. Otherwise, you may encounter an error such as + :samp:`fatal error: gnu/stubs-32.h: No such file` + +.. _gnat-prerequisite: + +* GNAT + + In order to build GNAT, the Ada compiler, you need a working GNAT + compiler (GCC version 5.1 or later). + + This includes GNAT tools such as :command:`gnatmake` and + :command:`gnatlink`, since the Ada front end is written in Ada and + uses some GNAT-specific extensions. + + In order to build a cross compiler, it is strongly recommended to install + the new compiler as native first, and then use it to build the cross + compiler. Other native compiler versions may work but this is not guaranteed and + will typically fail with hard to understand compilation errors during the + build. + + Similarly, it is strongly recommended to use an older version of GNAT to build + GNAT. More recent versions of GNAT than the version built are not guaranteed + to work and will often fail during the build with compilation errors. + + Note that :command:`configure` does not test whether the GNAT installation works + and has a sufficiently recent version; if too old a GNAT version is + installed and :option:`--enable-languages=ada` is used, the build will fail. + + :envvar:`ADA_INCLUDE_PATH` and :envvar:`ADA_OBJECT_PATH` environment variables + must not be set when building the Ada compiler, the Ada tools, or the + Ada runtime libraries. You can check that your build environment is clean + by verifying that :samp:`gnatls -v` lists only one explicit path in each + section. + +.. _gdc-prerequisite: + +* GDC + + In order to build GDC, the D compiler, you need a working GDC + compiler (GCC version 9.1 or later) and D runtime library, + :samp:`libphobos`, as the D front end is written in D. + + Versions of GDC prior to 12 can be built with an ISO C++11 compiler, which can + then be installed and used to bootstrap newer versions of the D front end. + + It is strongly recommended to use an older version of GDC to build GDC. More + recent versions of GDC than the version built are not guaranteed to work and + will often fail during the build with compilation errors relating to + deprecations or removed features. + + Note that :command:`configure` does not test whether the GDC installation works + and has a sufficiently recent version. Though the implementation of the D + front end does not make use of any GDC-specific extensions, or novel features + of the D language, if too old a GDC version is installed and + :option:`--enable-languages=d` is used, the build will fail. + + On some targets, :samp:`libphobos` isn't enabled by default, but compiles + and works if :option:`--enable-libphobos` is used. Specifics are + documented for affected targets. + +* A 'working' POSIX compatible shell, or GNU bash + + Necessary when running :command:`configure` because some + :command:`/bin/sh` shells have bugs and may crash when configuring the + target libraries. In other cases, :command:`/bin/sh` or :command:`ksh` + have disastrous corner-case performance problems. This + can cause target :command:`configure` runs to literally take days to + complete in some cases. + + So on some platforms :command:`/bin/ksh` is sufficient, on others it + isn't. See the host/target specific instructions for your platform, or + use :command:`bash` to be sure. Then set :envvar:`CONFIG_SHELL` in your + environment to your 'good' shell prior to running + :command:`configure`/:command:`make`. + + :command:`zsh` is not a fully compliant POSIX shell and will not + work when configuring GCC. + +* A POSIX or SVR4 awk + + Necessary for creating some of the generated source files for GCC. + If in doubt, use a recent GNU awk version, as some of the older ones + are broken. GNU awk version 3.1.5 is known to work. + +* GNU binutils + + Necessary in some circumstances, optional in others. See the + host/target specific instructions for your platform for the exact + requirements. + + Note binutils 2.35 or newer is required for LTO to work correctly + with GNU libtool that includes doing a bootstrap with LTO enabled. + +* gzip version 1.2.4 (or later) or +* bzip2 version 1.0.2 (or later) + + Necessary to uncompress GCC :command:`tar` files when source code is + obtained via HTTPS mirror sites. + +* GNU make version 3.80 (or later) + + You must have GNU make installed to build GCC. + +* GNU tar version 1.14 (or later) + + Necessary (only on some platforms) to untar the source code. Many + systems' :command:`tar` programs will also work, only try GNU + :command:`tar` if you have problems. + +* Perl version between 5.6.1 and 5.6.24 + + Necessary when targeting Darwin, building :samp:`libstdc++`, + and not using :option:`--disable-symvers`. + Necessary when targeting Solaris 2 with Solaris :command:`ld` and not using + :option:`--disable-symvers`. + + Necessary when regenerating :samp:`Makefile` dependencies in libiberty. + Used by various scripts to generate some files included in the source + repository (mainly Unicode-related and rarely changing) from source + tables. + + Used by :command:`automake`. + +Several support libraries are necessary to build GCC, some are required, +others optional. While any sufficiently new version of required tools +usually work, library requirements are generally stricter. Newer +versions may work in some cases, but it's safer to use the exact +versions documented. We appreciate bug reports about problems with +newer versions, though. If your OS vendor provides packages for the +support libraries then using those packages may be the simplest way to +install the libraries. + +* GNU Multiple Precision Library (GMP) version 4.3.2 (or later) + + Necessary to build GCC. If a GMP source distribution is found in a + subdirectory of your GCC sources named :samp:`gmp`, it will be built + together with GCC. Alternatively, if GMP is already installed but it + is not in your library search path, you will have to configure with the + :option:`--with-gmp` configure option. See also :option:`--with-gmp-lib` + and :option:`--with-gmp-include`. + The in-tree build is only supported with the GMP version that + :command:`download_prerequisites` installs. + +* MPFR Library version 3.1.0 (or later) + + Necessary to build GCC. It can be downloaded from + https://www.mpfr.org. If an MPFR source distribution is found + in a subdirectory of your GCC sources named :samp:`mpfr`, it will be + built together with GCC. Alternatively, if MPFR is already installed + but it is not in your default library search path, the + :option:`--with-mpfr` configure option should be used. See also + :option:`--with-mpfr-lib` and :option:`--with-mpfr-include`. + The in-tree build is only supported with the MPFR version that + :command:`download_prerequisites` installs. + +* MPC Library version 1.0.1 (or later) + + Necessary to build GCC. It can be downloaded from + https://www.multiprecision.org/mpc/. If an MPC source distribution + is found in a subdirectory of your GCC sources named :samp:`mpc`, it + will be built together with GCC. Alternatively, if MPC is already + installed but it is not in your default library search path, the + :option:`--with-mpc` configure option should be used. See also + :option:`--with-mpc-lib` and :option:`--with-mpc-include`. + The in-tree build is only supported with the MPC version that + :command:`download_prerequisites` installs. + +* isl Library version 0.15 or later. + + Necessary to build GCC with the Graphite loop optimizations. + It can be downloaded from https://gcc.gnu.org/pub/gcc/infrastructure/. + If an isl source distribution is found + in a subdirectory of your GCC sources named :samp:`isl`, it will be + built together with GCC. Alternatively, the :option:`--with-isl` configure + option should be used if isl is not installed in your default library + search path. + +* zstd Library. + + Necessary to build GCC with zstd compression used for LTO bytecode. + The library is searched in your default library patch search. + Alternatively, the :option:`--with-zstd` configure option should be used. + +Tools/packages necessary for modifying GCC +****************************************** + +* autoconf version 2.69 +* GNU m4 version 1.4.6 (or later) + + Necessary when modifying :samp:`configure.ac`, :samp:`aclocal.m4`, etc. + to regenerate :samp:`configure` and :samp:`config.in` files. + +* automake version 1.15.1 + + Necessary when modifying a :samp:`Makefile.am` file to regenerate its + associated :samp:`Makefile.in`. + + Much of GCC does not use automake, so directly edit the :samp:`Makefile.in` + file. Specifically this applies to the :samp:`gcc`, :samp:`intl`, + :samp:`libcpp`, :samp:`libiberty`, :samp:`libobjc` directories as well + as any of their subdirectories. + + For directories that use automake, GCC requires the latest release in + the 1.15 series, which is currently 1.15.1. When regenerating a directory + to a newer version, please update all the directories using an older 1.15 + to the latest released version. + +* gettext version 0.14.5 (or later) + + Needed to regenerate :samp:`gcc.pot`. + +* gperf version 2.7.2 (or later) + + Necessary when modifying :command:`gperf` input files, e.g. + :samp:`gcc/cp/cfns.gperf` to regenerate its associated header file, e.g. + :samp:`gcc/cp/cfns.h`. + +* DejaGnu version 1.5.3 (or later) +* Expect +* Tcl + + Necessary to run the GCC testsuite; see the section on testing for + details. + + .. Once Tcl 8.5 or higher is required, remove any obsolete + compatibility workarounds: + git grep 'compatibility with earlier Tcl releases' + +* autogen version 5.5.4 (or later) +* guile version 1.4.1 (or later) + + Necessary to regenerate :samp:`fixinc/fixincl.x` from + :samp:`fixinc/inclhack.def` and :samp:`fixinc/*.tpl`. + + Necessary to run :samp:`make check` for :samp:`fixinc`. + + Necessary to regenerate the top level :samp:`Makefile.in` file from + :samp:`Makefile.tpl` and :samp:`Makefile.def`. + +* Flex version 2.5.4 (or later) + + Necessary when modifying :samp:`*.l` files. + + Necessary to build GCC during development because the generated output + files are not included in the version-controlled source repository. + They are included in releases. + +* Sphinx version |needs_sphinx| (or later) + + Necessary to build HTML, PDF or EPUB documentation. See more in + :ref:`gccint:building_documentation`. + + Necessary for running :command:`make html` or :command:`make pdf` to + create printable documentation in HTML or PDF format. + + Necessary to build GCC documentation during development because the + generated output files are not included in the repository. They are + included in releases. + +* git (any version) +* SSH (any version) + + Necessary to access the source repository. Public releases and weekly + snapshots of the development sources are also available via HTTPS. + +* GNU diffutils version 2.7 (or later) + + Useful when submitting patches for the GCC source code. + +* patch version 2.5.4 (or later) + + Necessary when applying patches, created with :command:`diff`, to one's + own sources. \ No newline at end of file diff --git a/gcc/doc/install/submitting-test-results.rst b/gcc/doc/install/submitting-test-results.rst new file mode 100644 index 00000000000..695bac6f9f7 --- /dev/null +++ b/gcc/doc/install/submitting-test-results.rst @@ -0,0 +1,22 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Submitting test results +*********************** + +If you want to report the results to the GCC project, use the +:samp:`contrib/test_summary` shell script. Start it in the :samp:`{objdir}` with + +.. code-block:: bash + + srcdir/contrib/test_summary -p your_commentary.txt \ + -m gcc-testresults@gcc.gnu.org |sh + +This script uses the :command:`Mail` program to send the results, so +make sure it is in your :envvar:`PATH`. The file :samp:`your_commentary.txt` is +prepended to the testsuite summary and should contain any special +remarks you have on your results or your build environment. Please +do not edit the testsuite result block or the subject line, as these +messages may be automatically processed. \ No newline at end of file diff --git a/gcc/doc/install/testing.rst b/gcc/doc/install/testing.rst new file mode 100644 index 00000000000..08d25f7c9c2 --- /dev/null +++ b/gcc/doc/install/testing.rst @@ -0,0 +1,69 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Testing, Testing, Testsuite + +.. _testing: + +Testing +------- + +Before you install GCC, we encourage you to run the testsuites and to +compare your results with results from a similar configuration that have +been submitted to the +`gcc-testresults mailing list `_. +Some of these archived results are linked from the build status lists +at https://gcc.gnu.org/buildstat.html, although not everyone who +reports a successful build runs the testsuites and submits the results. +This step is optional and may require you to download additional software, +but it can give you confidence in your new GCC installation or point out +problems before you install and start using your new GCC. + +First, you must have :ref:`downloaded the testsuites `. +These are part of the full distribution, but if you downloaded the +'core' compiler plus any front ends, you must download the testsuites +separately. + +Second, you must have the testing tools installed. This includes +`DejaGnu `_, Tcl, and Expect; +the DejaGnu site has links to these. +Some optional tests also require Python3 and pytest module. + +If the directories where :command:`runtest` and :command:`expect` were +installed are not in the :envvar:`PATH`, you may need to set the following +environment variables appropriately, as in the following example (which +assumes that DejaGnu has been installed under :samp:`/usr/local`): + +.. code-block:: bash + + TCL_LIBRARY = /usr/local/share/tcl8.0 + DEJAGNULIBS = /usr/local/share/dejagnu + +(On systems such as Cygwin, these paths are required to be actual +paths, not mounts or links; presumably this is due to some lack of +portability in the DejaGnu code.) + +Finally, you can run the testsuite (which may take a long time): + +.. code-block:: bash + + cd objdir; make -k check + +This will test various components of GCC, such as compiler +front ends and runtime libraries. While running the testsuite, DejaGnu +might emit some harmless messages resembling +:samp:`WARNING: Couldn't find the global config file.` or +:samp:`WARNING: Couldn't find tool init file` that can be ignored. + +If you are testing a cross-compiler, you may want to run the testsuite +on a simulator as described at https://gcc.gnu.org/simtest-howto.html. + +.. toctree:: + :maxdepth: 2 + + how-can-you-run-the-testsuite-on-selected-tests + passing-options-and-running-multiple-testsuites + how-to-interpret-test-results + submitting-test-results \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/code-that-interacts-with-the-user.rst b/gcc/fortran/doc/gfc-internals/code-that-interacts-with-the-user.rst new file mode 100644 index 00000000000..43a47dba7b9 --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/code-that-interacts-with-the-user.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _user-interface: + +Code that Interacts with the User +--------------------------------- + +.. toctree:: + :maxdepth: 2 + + command-line-options + error-handling \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/command-line-options.rst b/gcc/fortran/doc/gfc-internals/command-line-options.rst new file mode 100644 index 00000000000..abb5fda4b48 --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/command-line-options.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _command-line-options: + +Command-Line Options +******************** + +Command-line options for :command:`gfortran` involve four interrelated +pieces within the Fortran compiler code. + +The relevant command-line flag is defined in :samp:`lang.opt`, according +to the documentation in :ref:`gccint:options`. This is then processed by the overall GCC +machinery to create the code that enables :command:`gfortran` and +:command:`gcc` to recognize the option in the command-line arguments and +call the relevant handler function. + +This generated code calls the ``gfc_handle_option`` code in +:samp:`options.cc` with an enumerator variable indicating which option is +to be processed, and the relevant integer or string values associated +with that option flag. Typically, ``gfc_handle_option`` uses these +arguments to set global flags which record the option states. + +The global flags that record the option states are stored in the +``gfc_option_t`` struct, which is defined in :samp:`gfortran.h`. +Before the options are processed, initial values for these flags are set +in ``gfc_init_option`` in :samp:`options.cc`; these become the default +values for the options. \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/conf.py b/gcc/fortran/doc/gfc-internals/conf.py new file mode 100644 index 00000000000..176e6310b89 --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/conf.py @@ -0,0 +1,24 @@ +# Configuration file for the Sphinx documentation builder. + +import sys +sys.path.append('../../../..//doc') + +from baseconf import * + +name = 'gfc-internals' +project = 'GNU Fortran Internals' +copyright = '2007-2022 Free Software Foundation, Inc.' +authors = 'The gfortran team' + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +latex_documents = [ + ('index', f'{name}.tex', project, authors, 'manual'), +] + +texinfo_documents = [ + ('index', name, project, authors, None, None, None, True) +] + +set_common(name, globals()) \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/copyright.rst b/gcc/fortran/doc/gfc-internals/copyright.rst new file mode 100644 index 00000000000..c778eb178c7 --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/copyright.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Copyright +^^^^^^^^^ + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with the +Invariant Sections being **GNU General Public License** and +**Funding Free Software**, the Front-Cover texts being (a) (see below), and with +the Back-Cover Texts being (b) (see below). A copy of the license is +in the :ref:`gnu_fdl`. + +(a) The FSF's Front-Cover Text is: + + A GNU Manual + +(b) The FSF's Back-Cover Text is: + + You have freedom to copy and modify this GNU Manual, like GNU + software. Copies published by the Free Software Foundation raise + funds for GNU development. \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/error-handling.rst b/gcc/fortran/doc/gfc-internals/error-handling.rst new file mode 100644 index 00000000000..11c12b688c9 --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/error-handling.rst @@ -0,0 +1,75 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _error-handling: + +Error Handling +************** + +The GNU Fortran compiler's parser operates by testing each piece of +source code against a variety of matchers. In some cases, if these +matchers do not match the source code, they will store an error message +in a buffer. If the parser later finds a matcher that does correctly +match the source code, then the buffered error is discarded. However, +if the parser cannot find a match, then the buffered error message is +reported to the user. This enables the compiler to provide more +meaningful error messages even in the many cases where (erroneous) +Fortran syntax is ambiguous due to things like the absence of reserved +keywords. + +As an example of how this works, consider the following line: + +.. code-block:: c++ + + IF = 3 + +Hypothetically, this may get passed to the matcher for an ``IF`` +statement. Since this could plausibly be an erroneous ``IF`` +statement, the matcher will buffer an error message reporting the +absence of an expected :samp:`(` following an ``IF``. Since no +matchers reported an error-free match, however, the parser will also try +matching this against a variable assignment. When ``IF`` is a valid +variable, this will be parsed as an assignment statement, and the error +discarded. However, when ``IF`` is not a valid variable, this +buffered error message will be reported to the user. + +The error handling code is implemented in :samp:`error.cc`. Errors are +normally entered into the buffer with the ``gfc_error`` function. +Warnings go through a similar buffering process, and are entered into +the buffer with ``gfc_warning``. There is also a special-purpose +function, ``gfc_notify_std``, for things which have an error/warning +status that depends on the currently-selected language standard. + +The ``gfc_error_check`` function checks the buffer for errors, +reports the error message to the user if one exists, clears the buffer, +and returns a flag to the user indicating whether or not an error +existed. To check the state of the buffer without changing its state or +reporting the errors, the ``gfc_error_flag_test`` function can be +used. The ``gfc_clear_error`` function will clear out any errors in +the buffer, without reporting them. The ``gfc_warning_check`` and +``gfc_clear_warning`` functions provide equivalent functionality for +the warning buffer. + +Only one error and one warning can be in the buffers at a time, and +buffering another will overwrite the existing one. In cases where one +may wish to work on a smaller piece of source code without disturbing an +existing error state, the ``gfc_push_error``, ``gfc_pop_error``, +and ``gfc_free_error`` mechanism exists to implement a stack for the +error buffer. + +For cases where an error or warning should be reported immediately +rather than buffered, the ``gfc_error_now`` and +``gfc_warning_now`` functions can be used. Normally, the compiler +will continue attempting to parse the program after an error has +occurred, but if this is not appropriate, the ``gfc_fatal_error`` +function should be used instead. For errors that are always the result +of a bug somewhere in the compiler, the ``gfc_internal_error`` +function should be used. + +The syntax for the strings used to produce the error/warning message in +the various error and warning functions is similar to the ``printf`` +syntax, with :samp:`%`-escapes to insert variable values. The details, +and the allowable codes, are documented in the ``error_print`` +function in :samp:`error.cc`. \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/frontend-data-structures.rst b/gcc/fortran/doc/gfc-internals/frontend-data-structures.rst new file mode 100644 index 00000000000..0b4411aad1c --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/frontend-data-structures.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: data structures + +.. _frontend-data-structures: + +Frontend Data Structures +------------------------ + +This chapter should describe the details necessary to understand how +the various ``gfc_*`` data are used and interact. In general it is +advisable to read the code in :samp:`dump-parse-tree.cc` as its routines +should exhaust all possible valid combinations of content for these +structures. + +.. toctree:: + :maxdepth: 2 + + gfccode + gfcexpr \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages.rst b/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages.rst new file mode 100644 index 00000000000..37bfe3033fc --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _translating-to-generic: + +Generating the intermediate language for later stages. +------------------------------------------------------ + +This chapter deals with the transformation of gfortran's frontend data +structures to the intermediate language used by the later stages of +the compiler, the so-called middle end. + +Data structures relating to this are found in the source files +:samp:`trans*.h` and :samp:`trans-*.c`. + +.. toctree:: + :maxdepth: 2 + + generating-the-intermediate-language-for-later-stages/basic-data-structures + generating-the-intermediate-language-for-later-stages/converting-expressions-to-tree + generating-the-intermediate-language-for-later-stages/translating-statements + generating-the-intermediate-language-for-later-stages/accessing-declarations \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/accessing-declarations.rst b/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/accessing-declarations.rst new file mode 100644 index 00000000000..0c2c0161757 --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/accessing-declarations.rst @@ -0,0 +1,16 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _accessing-declarations: + +Accessing declarations +********************** + +``gfc_symbol``, ``gfc_charlen`` and other front-end structures +contain a ``backend_decl`` variable, which contains the ``tree`` +used for accessing that entity in the middle-end. + +Accessing declarations is usually done by functions called +``gfc_get*``. \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/basic-data-structures.rst b/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/basic-data-structures.rst new file mode 100644 index 00000000000..2c564dae5da --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/basic-data-structures.rst @@ -0,0 +1,67 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _basic-data-structures: + +Basic data structures +********************* + +Gfortran creates GENERIC as an intermediate language for the +middle-end. Details about GENERIC can be found in the GCC manual. + +The basic data structure of GENERIC is a ``tree``. Everything in +GENERIC is a ``tree``, including types and statements. Fortunately +for the gfortran programmer, ``tree`` variables are +garbage-collected, so doing memory management for them is not +necessary. + +``tree`` expressions are built using functions such as, for +example, ``fold_build2_loc``. For two tree variables ``a`` and +``b``, both of which have the type ``gfc_arry_index_type``, +calculation ``c = a * b`` would be done by + +.. code-block:: c++ + + c = fold_build2_loc (input_location, MULT_EXPR, + gfc_array_index_type, a, b); + +The types have to agree, otherwise internal compiler errors will occur +at a later stage. Expressions can be converted to a different type +using ``fold_convert``. + +Accessing individual members in the ``tree`` structures should not +be done. Rather, access should be done via macros. + +One basic data structure is the ``stmtblock_t`` struct. This is +used for holding a list of statements, expressed as ``tree`` +expressions. If a block is created using ``gfc_start_block``, it +has its own scope for variables; if it is created using +``gfc_init_block``, it does not have its own scope. + +It is possible to + +* Add an expression to the end of a block using ``gfc_add_expr_to_block`` + +* Add an expression to the beginning of a block using ``void gfc_prepend_expr_to_block`` + +* Make a block into a single ``tree`` using + ``gfc_finish_block``. For example, this is needed to put the + contents of a block into the ``if`` or ``else`` branch of + a ``COND_EXPR``. + +Variables are also ``tree`` expressions, they can be created using +``gfc_create_var``. Assigning to a variable can be done with +``gfc_add_modify``. + +An example: Creating a default integer type variable in the current +scope with the prefix 'everything' in the ``stmt_block`` +``block`` and assigning the value 42 would be + +.. code-block:: c++ + + tree var, *block; + /* Initialize block somewhere here. */ + var = gfc_create_var (integer_type_node, "everything"); + gfc_add_modify (block, var, build_int_cst (integer_type_node, 42)); \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/converting-expressions-to-tree.rst b/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/converting-expressions-to-tree.rst new file mode 100644 index 00000000000..f6838049ad2 --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/converting-expressions-to-tree.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _converting-expressions: + +Converting Expressions to tree +****************************** + +Converting expressions to ``tree`` is done by functions called +``gfc_conv_*``. + +The central data structure for a GENERIC expression is the +``gfc_se`` structure. Its ``expr`` member is a ``tree`` that +holds the value of the expression. A ``gfc_se`` structure is +initialized using ``gfc_init_se`` ; it needs to be embedded in an +outer ``gfc_se``. + +Evaluating Fortran expressions often require things to be done before +and after evaluation of the expression, for example code for the +allocation of a temporary variable and its subsequent deallocation. +Therefore, ``gfc_se`` contains the members ``pre`` and +``post``, which point to ``stmt_block`` blocks for code that +needs to be executed before and after evaluation of the expression. + +When using a local ``gfc_se`` to convert some expression, it is +often necessary to add the generated ``pre`` and ``post`` blocks +to the ``pre`` or ``post`` blocks of the outer ``gfc_se``. +Code like this (lifted from :samp:`trans-expr.cc`) is fairly common: + +.. code-block:: c++ + + gfc_se cont_se; + tree cont_var; + + /* cont_var = is_contiguous (expr); . */ + gfc_init_se (&cont_se, parmse); + gfc_conv_is_contiguous_expr (&cont_se, expr); + gfc_add_block_to_block (&se->pre, &(&cont_se)->pre); + gfc_add_modify (&se->pre, cont_var, cont_se.expr); + gfc_add_block_to_block (&se->pre, &(&cont_se)->post); + +Conversion functions which need a ``gfc_se`` structure will have a +corresponding argument. + +``gfc_se`` also contains pointers to a ``gfc_ss`` and a +``gfc_loopinfo`` structure. These are needed by the scalarizer. \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/translating-statements.rst b/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/translating-statements.rst new file mode 100644 index 00000000000..f53310ef628 --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/generating-the-intermediate-language-for-later-stages/translating-statements.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _translating-statements: + +Translating statements +********************** + +Translating statements to ``tree`` is done by functions called +``gfc_trans_*``. These functions usually get passed a +``gfc_code`` structure, evaluate any expressions and then +return a ``tree`` structure. \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/gfccode.rst b/gcc/fortran/doc/gfc-internals/gfccode.rst new file mode 100644 index 00000000000..838205df52e --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/gfccode.rst @@ -0,0 +1,146 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: statement chaining + +.. _gfc_code: + +gfc_code +******** + +.. index:: gfc_code, struct gfc_code + +The executable statements in a program unit are represented by a +nested chain of ``gfc_code`` structures. The type of statement is +identified by the ``op`` member of the structure, the different +possible values are enumerated in ``gfc_exec_op``. A special +member of this ``enum`` is ``EXEC_NOP`` which is used to +represent the various ``END`` statements if they carry a label. +Depending on the type of statement some of the other fields will be +filled in. Fields that are generally applicable are the ``next`` +and ``here`` fields. The former points to the next statement in +the current block or is ``NULL`` if the current statement is the +last in a block, ``here`` points to the statement label of the +current statement. + +If the current statement is one of ``IF``, ``DO``, ``SELECT`` +it starts a block, i.e. a nested level in the program. In order to +represent this, the ``block`` member is set to point to a +``gfc_code`` structure whose ``next`` member starts the chain of +statements inside the block; this structure's ``op`` member should be set to +the same value as the parent structure's ``op`` member. The ``SELECT`` +and ``IF`` statements may contain various blocks (the chain of ``ELSE IF`` +and ``ELSE`` blocks or the various ``CASE`` s, respectively). These chains +are linked-lists formed by the ``block`` members. + +Consider the following example code: + +.. code-block:: fortran + + IF (foo < 20) THEN + PRINT *, "Too small" + foo = 20 + ELSEIF (foo > 50) THEN + PRINT *, "Too large" + foo = 50 + ELSE + PRINT *, "Good" + END IF + +This statement-block will be represented in the internal gfortran tree as +follows, were the horizontal link-chains are those induced by the ``next`` +members and vertical links down are those of ``block``. :samp:`==|` and +:samp:`--|` mean ``NULL`` pointers to mark the end of a chain: + +.. code-block:: c++ + + ... ==> IF ==> ... + | + +--> IF foo < 20 ==> PRINT *, "Too small" ==> foo = 20 ==| + | + +--> IF foo > 50 ==> PRINT *, "Too large" ==> foo = 50 ==| + | + +--> ELSE ==> PRINT *, "Good" ==| + | + +--| + +IF Blocks +^^^^^^^^^ + +Conditionals are represented by ``gfc_code`` structures with their +``op`` member set to ``EXEC_IF``. This structure's ``block`` +member must point to another ``gfc_code`` node that is the header of the +if-block. This header's ``op`` member must be set to ``EXEC_IF``, too, +its ``expr`` member holds the condition to check for, and its ``next`` +should point to the code-chain of the statements to execute if the condition is +true. + +If in addition an ``ELSEIF`` or ``ELSE`` block is present, the +``block`` member of the if-block-header node points to yet another +``gfc_code`` structure that is the header of the elseif- or else-block. Its +structure is identical to that of the if-block-header, except that in case of an +``ELSE`` block without a new condition the ``expr`` member should be +``NULL``. This block can itself have its ``block`` member point to the +next ``ELSEIF`` or ``ELSE`` block if there's a chain of them. + +Loops +^^^^^ + +``DO`` loops are stored in the tree as ``gfc_code`` nodes with their +``op`` set to ``EXEC_DO`` for a ``DO`` loop with iterator variable and +to ``EXEC_DO_WHILE`` for infinite ``DO`` s and ``DO WHILE`` blocks. +Their ``block`` member should point to a ``gfc_code`` structure heading +the code-chain of the loop body; its ``op`` member should be set to +``EXEC_DO`` or ``EXEC_DO_WHILE``, too, respectively. + +For ``DO WHILE`` loops, the loop condition is stored on the top +``gfc_code`` structure's ``expr`` member; ``DO`` forever loops are +simply ``DO WHILE`` loops with a constant ``.TRUE.`` loop condition in +the internal representation. + +Similarly, ``DO`` loops with an iterator have instead of the condition their +``ext.iterator`` member set to the correct values for the loop iterator +variable and its range. + +SELECT Statements +^^^^^^^^^^^^^^^^^ + +A ``SELECT`` block is introduced by a ``gfc_code`` structure with an +``op`` member of ``EXEC_SELECT`` and ``expr`` containing the expression +to evaluate and test. Its ``block`` member starts a list of ``gfc_code`` +structures linked together by their ``block`` members that stores the various +``CASE`` parts. + +Each ``CASE`` node has its ``op`` member set to ``EXEC_SELECT``, too, +its ``next`` member points to the code-chain to be executed in the current +case-block, and ``extx.case_list`` contains the case-values this block +corresponds to. The ``block`` member links to the next case in the list. + +BLOCK and ASSOCIATE +^^^^^^^^^^^^^^^^^^^ + +The code related to a ``BLOCK`` statement is stored inside an +``gfc_code`` structure (say :samp:`{c}`) +with ``c.op`` set to ``EXEC_BLOCK``. The +``gfc_namespace`` holding the locally defined variables of the +``BLOCK`` is stored in ``c.ext.block.ns``. The code inside the +construct is in ``c.code``. + +``ASSOCIATE`` constructs are based on ``BLOCK`` and thus also have +the internal storage structure described above (including ``EXEC_BLOCK``). +However, for them ``c.ext.block.assoc`` is set additionally and points +to a linked list of ``gfc_association_list`` structures. Those +structures basically store a link of associate-names to target expressions. +The associate-names themselves are still also added to the ``BLOCK`` 's +namespace as ordinary symbols, but they have their ``gfc_symbol`` 's +member ``assoc`` set also pointing to the association-list structure. +This way associate-names can be distinguished from ordinary variables +and their target expressions identified. + +For association to expressions (as opposed to variables), at the very beginning +of the ``BLOCK`` construct assignments are automatically generated to +set the corresponding variables to their target expressions' values, and +later on the compiler simply disallows using such associate-names in contexts +that may change the value. \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/gfcexpr.rst b/gcc/fortran/doc/gfc-internals/gfcexpr.rst new file mode 100644 index 00000000000..7036ee4386a --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/gfcexpr.rst @@ -0,0 +1,156 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfc_expr: + +gfc_expr +******** + +.. index:: gfc_expr, struct gfc_expr + +Expressions and 'values', including constants, variable-, array- and +component-references as well as complex expressions consisting of operators and +function calls are internally represented as one or a whole tree of +``gfc_expr`` objects. The member ``expr_type`` specifies the overall +type of an expression (for instance, ``EXPR_CONSTANT`` for constants or +``EXPR_VARIABLE`` for variable references). The members ``ts`` and +``rank`` as well as ``shape``, which can be ``NULL``, specify +the type, rank and, if applicable, shape of the whole expression or expression +tree of which the current structure is the root. ``where`` is the locus of +this expression in the source code. + +Depending on the flavor of the expression being described by the object +(that is, the value of its ``expr_type`` member), the corresponding structure +in the ``value`` union will usually contain additional data describing the +expression's value in a type-specific manner. The ``ref`` member is used to +build chains of (array-, component- and substring-) references if the expression +in question contains such references, see below for details. + +Constants +^^^^^^^^^ + +Scalar constants are represented by ``gfc_expr`` nodes with their +``expr_type`` set to ``EXPR_CONSTANT``. The constant's value shall +already be known at compile-time and is stored in the ``logical``, +``integer``, ``real``, ``complex`` or ``character`` struct inside +``value``, depending on the constant's type specification. + +Operators +^^^^^^^^^ + +Operator-expressions are expressions that are the result of the execution of +some operator on one or two operands. The expressions have an ``expr_type`` +of ``EXPR_OP``. Their ``value.op`` structure contains additional data. + +``op1`` and optionally ``op2`` if the operator is binary point to the +two operands, and ``operator`` or ``uop`` describe the operator that +should be evaluated on these operands, where ``uop`` describes a user-defined +operator. + +Function Calls +^^^^^^^^^^^^^^ + +If the expression is the return value of a function-call, its ``expr_type`` +is set to ``EXPR_FUNCTION``, and ``symtree`` must point to the symtree +identifying the function to be called. ``value.function.actual`` holds the +actual arguments given to the function as a linked list of +``gfc_actual_arglist`` nodes. + +The other members of ``value.function`` describe the function being called +in more detail, containing a link to the intrinsic symbol or user-defined +function symbol if the call is to an intrinsic or external function, +respectively. These values are determined during resolution-phase from the +structure's ``symtree`` member. + +A special case of function calls are 'component calls' to type-bound +procedures; those have the ``expr_type`` ``EXPR_COMPCALL`` with +``value.compcall`` containing the argument list and the procedure called, +while ``symtree`` and ``ref`` describe the object on which the procedure +was called in the same way as a ``EXPR_VARIABLE`` expression would. +See :ref:`type-bound-procedures`. + +Array- and Structure-Constructors +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Array- and structure-constructors (one could probably call them 'array-' and +'derived-type constants') are ``gfc_expr`` structures with their +``expr_type`` member set to ``EXPR_ARRAY`` or ``EXPR_STRUCTURE``, +respectively. For structure constructors, ``symtree`` points to the +derived-type symbol for the type being constructed. + +The values for initializing each array element or structure component are +stored as linked-list of ``gfc_constructor`` nodes in the +``value.constructor`` member. + +Null +^^^^ + +``NULL`` is a special value for pointers; it can be of different base types. +Such a ``NULL`` value is represented in the internal tree by a +``gfc_expr`` node with ``expr_type`` ``EXPR_NULL``. If the base type +of the ``NULL`` expression is known, it is stored in ``ts`` (that's for +instance the case for default-initializers of ``ALLOCATABLE`` components), +but this member can also be set to ``BT_UNKNOWN`` if the information is not +available (for instance, when the expression is a pointer-initializer +``NULL()``). + +Variables and Reference Expressions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Variable references are ``gfc_expr`` structures with their ``expr_type`` +set to ``EXPR_VARIABLE`` ; their ``symtree`` should point to the variable +that is referenced. + +For this type of expression, it's also possible to chain array-, component- +or substring-references to the original expression to get something like +:samp:`struct%component(2:5)`, where ``component`` is either an array or +a ``CHARACTER`` member of ``struct`` that is of some derived-type. Such a +chain of references is achieved by a linked list headed by ``ref`` of the +``gfc_expr`` node. For the example above it would be (:samp:`==|` is the +last ``NULL`` pointer): + +.. code-block:: c++ + + EXPR_VARIABLE(struct) ==> REF_COMPONENT(component) ==> REF_ARRAY(2:5) ==| + +If ``component`` is a string rather than an array, the last element would be +a ``REF_SUBSTRING`` reference, of course. If the variable itself or some +component referenced is an array and the expression should reference the whole +array rather than being followed by an array-element or -section reference, a +``REF_ARRAY`` reference must be built as the last element in the chain with +an array-reference type of ``AR_FULL``. Consider this example code: + +.. code-block:: fortran + + TYPE :: mytype + INTEGER :: array(42) + END TYPE mytype + + TYPE(mytype) :: variable + INTEGER :: local_array(5) + + CALL do_something (variable%array, local_array) + +The ``gfc_expr`` nodes representing the arguments to the :samp:`do_something` +call will have a reference-chain like this: + +.. code-block:: c++ + + EXPR_VARIABLE(variable) ==> REF_COMPONENT(array) ==> REF_ARRAY(FULL) ==| + EXPR_VARIABLE(local_array) ==> REF_ARRAY(FULL) ==| + +Constant Substring References +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +``EXPR_SUBSTRING`` is a special type of expression that encodes a substring +reference of a constant string, as in the following code snippet: + +.. code-block:: c++ + + x = "abcde"(1:2) + +In this case, ``value.character`` contains the full string's data as if it +was a string constant, but the ``ref`` member is also set and points to a +substring reference as described in the subsection above. \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/gnu-free-documentation-license.rst b/gcc/fortran/doc/gfc-internals/gnu-free-documentation-license.rst new file mode 100644 index 00000000000..9a3dac670fa --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/gnu-free-documentation-license.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../../doc/gnu_free_documentation_license.rst \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/index.rst b/gcc/fortran/doc/gfc-internals/index.rst new file mode 100644 index 00000000000..3e37acf8396 --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/index.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +GNU Fortran Compiler Internals +============================== + +.. only:: html + + Contents: + +.. toctree:: + + copyright + introduction + code-that-interacts-with-the-user + frontend-data-structures + internals-of-fortran-2003-oop-features + generating-the-intermediate-language-for-later-stages + the-libgfortran-runtime-library + gnu-free-documentation-license + + indices-and-tables \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/indices-and-tables.rst b/gcc/fortran/doc/gfc-internals/indices-and-tables.rst new file mode 100644 index 00000000000..50865c6ecb2 --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/internals-of-fortran-2003-oop-features.rst b/gcc/fortran/doc/gfc-internals/internals-of-fortran-2003-oop-features.rst new file mode 100644 index 00000000000..b57f60e461f --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/internals-of-fortran-2003-oop-features.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _object-orientation: + +Internals of Fortran 2003 OOP Features +-------------------------------------- + +.. toctree:: + :maxdepth: 2 + + type-bound-procedures + type-bound-operators \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/introduction.rst b/gcc/fortran/doc/gfc-internals/introduction.rst new file mode 100644 index 00000000000..cc13920f83c --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/introduction.rst @@ -0,0 +1,32 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _introduction: + +Introduction +============ + +.. index:: Introduction + +This manual documents the internals of :command:`gfortran`, +the GNU Fortran compiler. + +.. only:: development + + .. warning:: + This document, and the compiler it describes, are still + under development. While efforts are made to keep it up-to-date, it might + not accurately reflect the status of the most recent GNU Fortran compiler. + +------------ + +.. The following duplicates the text on the TexInfo table of contents. + +At present, this manual is very much a work in progress, containing +miscellaneous notes about the internals of the compiler. It is hoped +that at some point in the future it will become a reasonably complete +guide; in the interim, GNU Fortran developers are strongly encouraged to +contribute to it as a way of keeping notes while working on the +compiler. \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/symbol-versioning.rst b/gcc/fortran/doc/gfc-internals/symbol-versioning.rst new file mode 100644 index 00000000000..37bc1e7a5d5 --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/symbol-versioning.rst @@ -0,0 +1,63 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _symbol-versioning: + +Symbol Versioning +***************** + +In general, this capability exists only on a few platforms, thus there +is a need for configure magic so that it is used only on those targets +where it is supported. + +The central concept in symbol versioning is the so-called map file, +which specifies the version node(s) exported symbols are labeled with. +Also, the map file is used to hide local symbols. + +Some relevant references: + +* `GNU ld manual `_ + +* `ELF Symbol + Versioning - Ulrich Depper `_ + +* `How to Write Shared + Libraries - Ulrich Drepper (see Chapter 3) `_ + +If one adds a new symbol to a library that should be exported, the new +symbol should be mentioned in the map file and a new version node +defined, e.g., if one adds a new symbols ``foo`` and ``bar`` to +libgfortran for the next GCC release, the following should be added to +the map file: + +:: + + GFORTRAN_1.1 { + global: + foo; + bar; + } GFORTRAN_1.0; + +where ``GFORTRAN_1.0`` is the version node of the current release, +and ``GFORTRAN_1.1`` is the version node of the next release where +foo and bar are made available. + +If one wants to change an existing interface, it is possible by using +some asm trickery (from the :command:`ld` manual referenced above): + +.. code-block:: c++ + + __asm__(".symver original_foo,foo@"); + __asm__(".symver old_foo,foo@VERS_1.1"); + __asm__(".symver old_foo1,foo@VERS_1.2"); + __asm__(".symver new_foo,foo@VERS_2.0"); + +In this example, ``foo@`` represents the symbol ``foo`` bound to +the unspecified base version of the symbol. The source file that +contains this example would define 4 C functions: ``original_foo``, +``old_foo``, ``old_foo1``, and ``new_foo``. + +In this case the map file must contain ``foo`` in ``VERS_1.1`` +and ``VERS_1.2`` as well as in ``VERS_2.0``. \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/the-libgfortran-runtime-library.rst b/gcc/fortran/doc/gfc-internals/the-libgfortran-runtime-library.rst new file mode 100644 index 00000000000..6b48b39c3c2 --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/the-libgfortran-runtime-library.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _libgfortran: + +The LibGFortran Runtime Library +------------------------------- + +.. toctree:: + :maxdepth: 2 + + symbol-versioning \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/type-bound-operators.rst b/gcc/fortran/doc/gfc-internals/type-bound-operators.rst new file mode 100644 index 00000000000..395de8f677c --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/type-bound-operators.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _type-bound-operators: + +Type-bound Operators +******************** + +Type-bound operators are in fact basically just ``GENERIC`` procedure +bindings and are represented much in the same way as those (see +:ref:`type-bound-procedures`). + +They come in two flavours: +User-defined operators (like ``.MYOPERATOR.``) +are stored in the ``f2k_derived`` namespace's ``tb_uop_root`` +symtree exactly like ordinary type-bound procedures are stored in +``tb_sym_root`` ; their symtrees' names are the operator-names (e.g. +:samp:`myoperator` in the example). +Intrinsic operators on the other hand are stored in the namespace's +array member ``tb_op`` indexed by the intrinsic operator's enum +value. Those need not be packed into ``gfc_symtree`` structures and are +only ``gfc_typebound_proc`` instances. + +When an operator call or assignment is found that cannot be handled in +another way (i.e. neither matches an intrinsic nor interface operator +definition) but that contains a derived-type expression, all type-bound +operators defined on that derived-type are checked for a match with +the operator call. If there's indeed a relevant definition, the +operator call is replaced with an internally generated ``GENERIC`` +type-bound procedure call to the respective definition and that call is +further processed. \ No newline at end of file diff --git a/gcc/fortran/doc/gfc-internals/type-bound-procedures.rst b/gcc/fortran/doc/gfc-internals/type-bound-procedures.rst new file mode 100644 index 00000000000..2f2d7c112fa --- /dev/null +++ b/gcc/fortran/doc/gfc-internals/type-bound-procedures.rst @@ -0,0 +1,101 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _type-bound-procedures: + +Type-bound Procedures +********************* + +Type-bound procedures are stored in the ``tb_sym_root`` of the namespace +``f2k_derived`` associated with the derived-type symbol as ``gfc_symtree`` +nodes. The name and symbol of these symtrees corresponds to the binding-name +of the procedure, i.e. the name that is used to call it from the context of an +object of the derived-type. + +In addition, this type of symtrees stores in ``n.tb`` a struct of type +``gfc_typebound_proc`` containing the additional data needed: The +binding attributes (like ``PASS`` and ``NOPASS``, ``NON_OVERRIDABLE`` +or the access-specifier), the binding's target(s) and, if the current binding +overrides or extends an inherited binding of the same name, ``overridden`` +points to this binding's ``gfc_typebound_proc`` structure. + +Specific Bindings +^^^^^^^^^^^^^^^^^ + +.. - + +For specific bindings (declared with ``PROCEDURE``), if they have a +passed-object argument, the passed-object dummy argument is first saved by its +name, and later during resolution phase the corresponding argument is looked for +and its position remembered as ``pass_arg_num`` in ``gfc_typebound_proc``. +The binding's target procedure is pointed-to by ``u.specific``. + +``DEFERRED`` bindings are just like ordinary specific bindings, except +that their ``deferred`` flag is set of course and that ``u.specific`` +points to their 'interface' defining symbol (might be an abstract interface) +instead of the target procedure. + +At the moment, all type-bound procedure calls are statically dispatched and +transformed into ordinary procedure calls at resolution time; their actual +argument list is updated to include at the right position the passed-object +argument, if applicable, and then a simple procedure call to the binding's +target procedure is built. To handle dynamic dispatch in the future, this will +be extended to allow special code generation during the trans-phase to dispatch +based on the object's dynamic type. + +Generic Bindings +^^^^^^^^^^^^^^^^ + +.. - + +Bindings declared as ``GENERIC`` store the specific bindings they target as +a linked list using nodes of type ``gfc_tbp_generic`` in ``u.generic``. +For each specific target, the parser records its symtree and during resolution +this symtree is bound to the corresponding ``gfc_typebound_proc`` structure +of the specific target. + +Calls to generic bindings are handled entirely in the resolution-phase, where +for the actual argument list present the matching specific binding is found +and the call's target procedure (``value.compcall.tbp``) is re-pointed to +the found specific binding and this call is subsequently handled by the logic +for specific binding calls. + +Calls to Type-bound Procedures +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. - + +Calls to type-bound procedures are stored in the parse-tree as ``gfc_expr`` +nodes of type ``EXPR_COMPCALL``. Their ``value.compcall.actual`` saves +the actual argument list of the call and ``value.compcall.tbp`` points to the +``gfc_typebound_proc`` structure of the binding to be called. The object +in whose context the procedure was called is saved by combination of +``symtree`` and ``ref``, as if the expression was of type +``EXPR_VARIABLE``. + +For code like this: + +.. code-block:: fortran + + CALL myobj%procedure (arg1, arg2) + +the ``CALL`` is represented in the parse-tree as a ``gfc_code`` node of +type ``EXEC_COMPCALL``. The ``expr`` member of this node holds an +expression of type ``EXPR_COMPCALL`` of the same structure as mentioned above +except that its target procedure is of course a ``SUBROUTINE`` and not a +``FUNCTION``. + +Expressions that are generated internally (as expansion of a type-bound +operator call) may also use additional flags and members. +``value.compcall.ignore_pass`` signals that even though a ``PASS`` +attribute may be present the actual argument list should not be updated because +it already contains the passed-object. +``value.compcall.base_object`` overrides, if it is set, the base-object +(that is normally stored in ``symtree`` and ``ref`` as mentioned above); +this is needed because type-bound operators can be called on a base-object that +need not be of type ``EXPR_VARIABLE`` and thus representable in this way. +Finally, if ``value.compcall.assign`` is set, the call was produced in +expansion of a type-bound assignment; this means that proper dependency-checking +needs to be done when relevant. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/about-gnu-fortran.rst b/gcc/fortran/doc/gfortran/about-gnu-fortran.rst new file mode 100644 index 00000000000..81852484c4e --- /dev/null +++ b/gcc/fortran/doc/gfortran/about-gnu-fortran.rst @@ -0,0 +1,115 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _about-gnu-fortran: + +About GNU Fortran +***************** + +The GNU Fortran compiler is the successor to :command:`g77`, the +Fortran 77 front end included in GCC prior to version 4 (released in +2005). While it is backward-compatible with most :command:`g77` +extensions and command-line options, :command:`gfortran` is a completely new +implemention designed to support more modern dialects of Fortran. +GNU Fortran implements the Fortran 77, 90 and 95 standards +completely, most of the Fortran 2003 and 2008 standards, and some +features from the 2018 standard. It also implements several extensions +including OpenMP and OpenACC support for parallel programming. + +The GNU Fortran compiler passes the +`NIST Fortran 77 Test Suite `_, and produces acceptable results on the +`LAPACK Test Suite `_. +It also provides respectable performance on +the `Polyhedron Fortran compiler benchmarks `_ and the +`Livermore Fortran Kernels test `_. It has been used to compile a number of +large real-world programs, including +`the HARMONIE and HIRLAM weather forecasting code `_ and +`the Tonto quantum chemistry package `_; see +https://gcc.gnu.org/wiki/GfortranApps for an extended list. + +GNU Fortran provides the following functionality: + +* Read a program, stored in a file and containing :dfn:`source code` + instructions written in Fortran 77. + +* Translate the program into instructions a computer + can carry out more quickly than it takes to translate the + original Fortran instructions. + The result after compilation of a program is + :dfn:`machine code`, + which is efficiently translated and processed + by a machine such as your computer. + Humans usually are not as good writing machine code + as they are at writing Fortran (or C++, Ada, or Java), + because it is easy to make tiny mistakes writing machine code. + +* Provide information about the reasons why + the compiler may be unable to create a binary from the source code, + for example if the source code is flawed. + The Fortran language standards require that the compiler can point out + mistakes in your code. + An incorrect usage of the language causes an :dfn:`error message`. + + The compiler also attempts to diagnose cases where your + program contains a correct usage of the language, + but instructs the computer to do something questionable. + This kind of diagnostic message is called a :dfn:`warning message`. + +* Provide optional information about the translation passes + from the source code to machine code. + This can help you to find the cause of + certain bugs which may not be obvious in the source code, + but may be more easily found at a lower level compiler output. + It also helps developers to find bugs in the compiler itself. + +* Provide information in the generated machine code that can + make it easier to find bugs in the program (using a debugging tool, + called a :dfn:`debugger`, such as the GNU Debugger :command:`gdb`). + +* Locate and gather machine code already generated to + perform actions requested by statements in the program. + This machine code is organized into :dfn:`modules` and is located + and :dfn:`linked` to the user program. + +The GNU Fortran compiler consists of several components: + +* A version of the :command:`gcc` command + (which also might be installed as the system's :command:`cc` command) + that also understands and accepts Fortran source code. + The :command:`gcc` command is the :dfn:`driver` program for + all the languages in the GNU Compiler Collection (GCC); + With :command:`gcc`, + you can compile the source code of any language for + which a front end is available in GCC. + +* The :command:`gfortran` command itself, + which also might be installed as the + system's :command:`f95` command. + :command:`gfortran` is just another driver program, + but specifically for the Fortran compiler only. + The primary difference between the :command:`gcc` and :command:`gfortran` + commands is that the latter automatically links the correct libraries + to your program. + +* A collection of run-time libraries. + These libraries contain the machine code needed to support + capabilities of the Fortran language that are not directly + provided by the machine code generated by the + :command:`gfortran` compilation phase, + such as intrinsic functions and subroutines, + and routines for interaction with files and the operating system. + + .. and mechanisms to spawn, + + .. unleash and pause threads in parallelized code. + +* The Fortran compiler itself, (:command:`f951`). + This is the GNU Fortran parser and code generator, + linked to and interfaced with the GCC backend library. + :command:`f951` 'translates' the source code to + assembler code. You would typically not use this + program directly; + instead, the :command:`gcc` or :command:`gfortran` driver + programs call it for you. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/coarray-programming.rst b/gcc/fortran/doc/gfortran/coarray-programming.rst new file mode 100644 index 00000000000..4dce2021ff2 --- /dev/null +++ b/gcc/fortran/doc/gfortran/coarray-programming.rst @@ -0,0 +1,17 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Coarrays + +.. _coarray-programming: + +Coarray Programming +------------------- + +.. toctree:: + :maxdepth: 2 + + type-and-enum-abi-documentation + function-abi-documentation \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/compiler-characteristics.rst b/gcc/fortran/doc/gfortran/compiler-characteristics.rst new file mode 100644 index 00000000000..c222102c649 --- /dev/null +++ b/gcc/fortran/doc/gfortran/compiler-characteristics.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _compiler-characteristics: + +Compiler Characteristics +------------------------ + +This chapter describes certain characteristics of the GNU Fortran +compiler, that are not specified by the Fortran standard, but which +might in some way or another become visible to the programmer. + +.. toctree:: + :maxdepth: 2 + + compiler-characteristics/kind-type-parameters + compiler-characteristics/internal-representation-of-logical-variables + compiler-characteristics/evaluation-of-logical-expressions + compiler-characteristics/max-and-min-intrinsics-with-real-nan-arguments + compiler-characteristics/thread-safety-of-the-runtime-library + compiler-characteristics/data-consistency-and-durability + compiler-characteristics/files-opened-without-an-explicit-action=-specifier + compiler-characteristics/file-operations-on-symbolic-links + compiler-characteristics/file-format-of-unformatted-sequential-files + compiler-characteristics/asynchronous-i-o \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/compiler-characteristics/asynchronous-i-o.rst b/gcc/fortran/doc/gfortran/compiler-characteristics/asynchronous-i-o.rst new file mode 100644 index 00000000000..c5fd4eacfe3 --- /dev/null +++ b/gcc/fortran/doc/gfortran/compiler-characteristics/asynchronous-i-o.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: input/output, asynchronous, asynchronous I/O + +.. _asynchronous-i-o: + +Asynchronous I/O +**************** + +Asynchronous I/O is supported if the program is linked against the +POSIX thread library. If that is not the case, all I/O is performed +as synchronous. On systems which do not support pthread condition +variables, such as AIX, I/O is also performed as synchronous. + +On some systems, such as Darwin or Solaris, the POSIX thread library +is always linked in, so asynchronous I/O is always performed. On other +sytems, such as Linux, it is necessary to specify :option:`-pthread`, +:option:`-lpthread` or :option:`-fopenmp` during the linking step. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/compiler-characteristics/data-consistency-and-durability.rst b/gcc/fortran/doc/gfortran/compiler-characteristics/data-consistency-and-durability.rst new file mode 100644 index 00000000000..d499a8d3475 --- /dev/null +++ b/gcc/fortran/doc/gfortran/compiler-characteristics/data-consistency-and-durability.rst @@ -0,0 +1,80 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: consistency, durability + +.. _data-consistency-and-durability: + +Data consistency and durability +******************************* + +This section contains a brief overview of data and metadata +consistency and durability issues when doing I/O. + +With respect to durability, GNU Fortran makes no effort to ensure that +data is committed to stable storage. If this is required, the GNU +Fortran programmer can use the intrinsic ``FNUM`` to retrieve the +low level file descriptor corresponding to an open Fortran unit. Then, +using e.g. the ``ISO_C_BINDING`` feature, one can call the +underlying system call to flush dirty data to stable storage, such as +``fsync`` on POSIX, ``_commit`` on MingW, or ``fcntl(fd, +F_FULLSYNC, 0)`` on Mac OS X. The following example shows how to call +fsync: + +.. code-block:: fortran + + ! Declare the interface for POSIX fsync function + interface + function fsync (fd) bind(c,name="fsync") + use iso_c_binding, only: c_int + integer(c_int), value :: fd + integer(c_int) :: fsync + end function fsync + end interface + + ! Variable declaration + integer :: ret + + ! Opening unit 10 + open (10,file="foo") + + ! ... + ! Perform I/O on unit 10 + ! ... + + ! Flush and sync + flush(10) + ret = fsync(fnum(10)) + + ! Handle possible error + if (ret /= 0) stop "Error calling FSYNC" + +With respect to consistency, for regular files GNU Fortran uses +buffered I/O in order to improve performance. This buffer is flushed +automatically when full and in some other situations, e.g. when +closing a unit. It can also be explicitly flushed with the +``FLUSH`` statement. Also, the buffering can be turned off with the +``GFORTRAN_UNBUFFERED_ALL`` and +``GFORTRAN_UNBUFFERED_PRECONNECTED`` environment variables. Special +files, such as terminals and pipes, are always unbuffered. Sometimes, +however, further things may need to be done in order to allow other +processes to see data that GNU Fortran has written, as follows. + +The Windows platform supports a relaxed metadata consistency model, +where file metadata is written to the directory lazily. This means +that, for instance, the ``dir`` command can show a stale size for a +file. One can force a directory metadata update by closing the unit, +or by calling ``_commit`` on the file descriptor. Note, though, +that ``_commit`` will force all dirty data to stable storage, which +is often a very slow operation. + +The Network File System (NFS) implements a relaxed consistency model +called open-to-close consistency. Closing a file forces dirty data and +metadata to be flushed to the server, and opening a file forces the +client to contact the server in order to revalidate cached +data. ``fsync`` will also force a flush of dirty data and metadata +to the server. Similar to ``open`` and ``close``, acquiring and +releasing ``fcntl`` file locks, if the server supports them, will +also force cache validation and flushing dirty data and metadata. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/compiler-characteristics/evaluation-of-logical-expressions.rst b/gcc/fortran/doc/gfortran/compiler-characteristics/evaluation-of-logical-expressions.rst new file mode 100644 index 00000000000..ddb472b0899 --- /dev/null +++ b/gcc/fortran/doc/gfortran/compiler-characteristics/evaluation-of-logical-expressions.rst @@ -0,0 +1,18 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _evaluation-of-logical-expressions: + +Evaluation of logical expressions +********************************* + +The Fortran standard does not require the compiler to evaluate all parts of an +expression, if they do not contribute to the final result. For logical +expressions with ``.AND.`` or ``.OR.`` operators, in particular, GNU +Fortran will optimize out function calls (even to impure functions) if the +result of the expression can be established without them. However, since not +all compilers do that, and such an optimization can potentially modify the +program flow and subsequent results, GNU Fortran throws warnings for such +situations with the :option:`-Wfunction-elimination` flag. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/compiler-characteristics/file-format-of-unformatted-sequential-files.rst b/gcc/fortran/doc/gfortran/compiler-characteristics/file-format-of-unformatted-sequential-files.rst new file mode 100644 index 00000000000..55c332cca14 --- /dev/null +++ b/gcc/fortran/doc/gfortran/compiler-characteristics/file-format-of-unformatted-sequential-files.rst @@ -0,0 +1,63 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: file, unformatted sequential, unformatted sequential, sequential, unformatted, record marker, subrecord + +.. _file-format-of-unformatted-sequential-files: + +File format of unformatted sequential files +******************************************* + +Unformatted sequential files are stored as logical records using +record markers. Each logical record consists of one of more +subrecords. + +Each subrecord consists of a leading record marker, the data written +by the user program, and a trailing record marker. The record markers +are four-byte integers by default, and eight-byte integers if the +:option:`-fmax-subrecord-length=8` option (which exists for backwards +compability only) is in effect. + +The representation of the record markers is that of unformatted files +given with the :option:`-fconvert` option, the :ref:`convert-specifier` +in an open statement or the :ref:`GFORTRAN_CONVERT_UNIT` environment +variable. + +The maximum number of bytes of user data in a subrecord is 2147483639 +(2 GiB - 9) for a four-byte record marker. This limit can be lowered +with the :option:`-fmax-subrecord-length` option, although this is +rarely useful. If the length of a logical record exceeds this limit, +the data is distributed among several subrecords. + +The absolute of the number stored in the record markers is the number +of bytes of user data in the corresponding subrecord. If the leading +record marker of a subrecord contains a negative number, another +subrecord follows the current one. If the trailing record marker +contains a negative number, then there is a preceding subrecord. + +In the most simple case, with only one subrecord per logical record, +both record markers contain the number of bytes of user data in the +record. + +The format for unformatted sequential data can be duplicated using +unformatted stream, as shown in the example program for an unformatted +record containing a single subrecord: + +.. code-block:: fortran + + program main + use iso_fortran_env, only: int32 + implicit none + integer(int32) :: i + real, dimension(10) :: a, b + call random_number(a) + open (10,file='test.dat',form='unformatted',access='stream') + inquire (iolength=i) a + write (10) i, a, i + close (10) + open (10,file='test.dat',form='unformatted') + read (10) b + if (all (a == b)) print *,'success!' + end program main \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/compiler-characteristics/file-operations-on-symbolic-links.rst b/gcc/fortran/doc/gfortran/compiler-characteristics/file-operations-on-symbolic-links.rst new file mode 100644 index 00000000000..c0d1e10bbf8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/compiler-characteristics/file-operations-on-symbolic-links.rst @@ -0,0 +1,28 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: file, symbolic link + +.. _file-operations-on-symbolic-links: + +File operations on symbolic links +********************************* + +This section documents the behavior of GNU Fortran for file operations on +symbolic links, on systems that support them. + +* Results of INQUIRE statements of the 'inquire by file' form will + relate to the target of the symbolic link. For example, + ``INQUIRE(FILE="foo",EXIST=ex)`` will set :samp:`{ex}` to :samp:`{.true.}` if + :samp:`{foo}` is a symbolic link pointing to an existing file, and :samp:`{.false.}` + if :samp:`{foo}` points to an non-existing file ('dangling' symbolic link). + +* Using the ``OPEN`` statement with a ``STATUS="NEW"`` specifier + on a symbolic link will result in an error condition, whether the symbolic + link points to an existing target or is dangling. + +* If a symbolic link was connected, using the ``CLOSE`` statement + with a ``STATUS="DELETE"`` specifier will cause the symbolic link itself + to be deleted, not its target. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/compiler-characteristics/files-opened-without-an-explicit-action=-specifier.rst b/gcc/fortran/doc/gfortran/compiler-characteristics/files-opened-without-an-explicit-action=-specifier.rst new file mode 100644 index 00000000000..2f7a6dc2ebb --- /dev/null +++ b/gcc/fortran/doc/gfortran/compiler-characteristics/files-opened-without-an-explicit-action=-specifier.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: open, action + +.. _files-opened-without-an-explicit-action=-specifier: + +Files opened without an explicit ACTION= specifier +************************************************** + +The Fortran standard says that if an ``OPEN`` statement is executed +without an explicit ``ACTION=`` specifier, the default value is +processor dependent. GNU Fortran behaves as follows: + +* Attempt to open the file with ``ACTION='READWRITE'`` + +* If that fails, try to open with ``ACTION='READ'`` + +* If that fails, try to open with ``ACTION='WRITE'`` + +* If that fails, generate an error \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/compiler-characteristics/internal-representation-of-logical-variables.rst b/gcc/fortran/doc/gfortran/compiler-characteristics/internal-representation-of-logical-variables.rst new file mode 100644 index 00000000000..26280652170 --- /dev/null +++ b/gcc/fortran/doc/gfortran/compiler-characteristics/internal-representation-of-logical-variables.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: logical, variable representation + +.. _internal-representation-of-logical-variables: + +Internal representation of LOGICAL variables +******************************************** + +The Fortran standard does not specify how variables of ``LOGICAL`` +type are represented, beyond requiring that ``LOGICAL`` variables +of default kind have the same storage size as default ``INTEGER`` +and ``REAL`` variables. The GNU Fortran internal representation is +as follows. + +A ``LOGICAL(KIND=N)`` variable is represented as an +``INTEGER(KIND=N)`` variable, however, with only two permissible +values: ``1`` for ``.TRUE.`` and ``0`` for +``.FALSE.``. Any other integer value results in undefined behavior. + +See also :ref:`argument-passing-conventions` and :ref:`interoperability-with-c`. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/compiler-characteristics/kind-type-parameters.rst b/gcc/fortran/doc/gfortran/compiler-characteristics/kind-type-parameters.rst new file mode 100644 index 00000000000..8f74c8dddf5 --- /dev/null +++ b/gcc/fortran/doc/gfortran/compiler-characteristics/kind-type-parameters.rst @@ -0,0 +1,54 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: kind + +.. _kind-type-parameters: + +KIND Type Parameters +******************** + +The ``KIND`` type parameters supported by GNU Fortran for the primitive +data types are: + +``INTEGER`` + + 1, 2, 4, 8 [#f1]_, 16 [#f1]_, default: 4 [#f2]_ + +``LOGICAL`` + + 1, 2, 4, 8 [#f1]_, 16 [#f1]_, default: 4 [#f2]_ + +``REAL`` + + 4, 8, 10 [#f1]_, 16 [#f1]_, default: 4 [#f3]_ + +``COMPLEX`` + + 4, 8, 10 [#f1]_, 16 [#f1]_, default: 4 [#f3]_ + +``DOUBLE PRECISION`` + + 4, 8, 10 [#f1]_, 16 [#f1]_, default: 8 [#f3]_ + +``CHARACTER`` + + 1, 4, default: 1 + +.. [#f1] not available on all systems +.. [#f2] unless :option:`-fdefault-integer-8` is used +.. [#f3] unless :option:`-fdefault-real-8` is used (see :ref:`fortran-dialect-options`) + +The ``KIND`` value matches the storage size in bytes, except for +``COMPLEX`` where the storage size is twice as much (or both real and +imaginary part are a real value of the given size). It is recommended to use +the :ref:`SELECTED_CHAR_KIND`, :ref:`SELECTED_INT_KIND` and +:ref:`SELECTED_REAL_KIND` intrinsics or the ``INT8``, ``INT16``, +``INT32``, ``INT64``, ``REAL32``, ``REAL64``, and ``REAL128`` +parameters of the ``ISO_FORTRAN_ENV`` module instead of the concrete values. +The available kind parameters can be found in the constant arrays +``CHARACTER_KINDS``, ``INTEGER_KINDS``, ``LOGICAL_KINDS`` and +``REAL_KINDS`` in the :ref:`ISO_FORTRAN_ENV` module. For C interoperability, +the kind parameters of the :ref:`ISO_C_BINDING` module should be used. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/compiler-characteristics/max-and-min-intrinsics-with-real-nan-arguments.rst b/gcc/fortran/doc/gfortran/compiler-characteristics/max-and-min-intrinsics-with-real-nan-arguments.rst new file mode 100644 index 00000000000..5b56829bef2 --- /dev/null +++ b/gcc/fortran/doc/gfortran/compiler-characteristics/max-and-min-intrinsics-with-real-nan-arguments.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MAX, MIN, NaN + +.. _max-and-min-intrinsics-with-real-nan-arguments: + +MAX and MIN intrinsics with REAL NaN arguments +********************************************** + +The Fortran standard does not specify what the result of the +``MAX`` and ``MIN`` intrinsics are if one of the arguments is a +``NaN``. Accordingly, the GNU Fortran compiler does not specify +that either, as this allows for faster and more compact code to be +generated. If the programmer wishes to take some specific action in +case one of the arguments is a ``NaN``, it is necessary to +explicitly test the arguments before calling ``MAX`` or ``MIN``, +e.g. with the ``IEEE_IS_NAN`` function from the intrinsic module +``IEEE_ARITHMETIC``. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/compiler-characteristics/thread-safety-of-the-runtime-library.rst b/gcc/fortran/doc/gfortran/compiler-characteristics/thread-safety-of-the-runtime-library.rst new file mode 100644 index 00000000000..e2282cadcf1 --- /dev/null +++ b/gcc/fortran/doc/gfortran/compiler-characteristics/thread-safety-of-the-runtime-library.rst @@ -0,0 +1,53 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: thread-safety, threads + +.. _thread-safety-of-the-runtime-library: + +Thread-safety of the runtime library +************************************ + +GNU Fortran can be used in programs with multiple threads, e.g. by +using OpenMP, by calling OS thread handling functions via the +``ISO_C_BINDING`` facility, or by GNU Fortran compiled library code +being called from a multi-threaded program. + +The GNU Fortran runtime library, (``libgfortran``), supports being +called concurrently from multiple threads with the following +exceptions. + +During library initialization, the C ``getenv`` function is used, +which need not be thread-safe. Similarly, the ``getenv`` +function is used to implement the ``GET_ENVIRONMENT_VARIABLE`` and +``GETENV`` intrinsics. It is the responsibility of the user to +ensure that the environment is not being updated concurrently when any +of these actions are taking place. + +The ``EXECUTE_COMMAND_LINE`` and ``SYSTEM`` intrinsics are +implemented with the ``system`` function, which need not be +thread-safe. It is the responsibility of the user to ensure that +``system`` is not called concurrently. + +For platforms not supporting thread-safe POSIX functions, further +functionality might not be thread-safe. For details, please consult +the documentation for your operating system. + +The GNU Fortran runtime library uses various C library functions that +depend on the locale, such as ``strtod`` and ``snprintf``. In +order to work correctly in locale-aware programs that set the locale +using ``setlocale``, the locale is reset to the default 'C' +locale while executing a formatted ``READ`` or ``WRITE`` +statement. On targets supporting the POSIX 2008 per-thread locale +functions (e.g. ``newlocale``, ``uselocale``, +``freelocale``), these are used and thus the global locale set +using ``setlocale`` or the per-thread locales in other threads are +not affected. However, on targets lacking this functionality, the +global LC_NUMERIC locale is set to 'C' during the formatted I/O. +Thus, on such targets it's not safe to call ``setlocale`` +concurrently from another thread while a Fortran formatted I/O +operation is in progress. Also, other threads doing something +dependent on the LC_NUMERIC locale might not work correctly if a +formatted I/O operation is in progress in another thread. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/conf.py b/gcc/fortran/doc/gfortran/conf.py new file mode 100644 index 00000000000..8be1e53d872 --- /dev/null +++ b/gcc/fortran/doc/gfortran/conf.py @@ -0,0 +1,30 @@ +# Configuration file for the Sphinx documentation builder. + +import sys +sys.path.append('../../../..//doc') + +from baseconf import * + +name = 'gfortran' +project = 'Using GNU Fortran' +copyright = '1999-2022 Free Software Foundation, Inc.' +authors = 'The gfortran team' + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +latex_documents = [ + ('index', f'{name}.tex', project, authors, 'manual'), +] + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('gnu-fortran-command-options', name, 'GNU Fortran compiler', [authors], 1), +] + +texinfo_documents = [ + ('index', name, project, authors, None, None, None, True) +] + +set_common(name, globals()) \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/contributing.rst b/gcc/fortran/doc/gfortran/contributing.rst new file mode 100644 index 00000000000..bb06b37dc94 --- /dev/null +++ b/gcc/fortran/doc/gfortran/contributing.rst @@ -0,0 +1,28 @@ +.. _contributing: + +Contributing +============ + +.. index:: Contributing + +Free software is only possible if people contribute to efforts +to create it. +We're always in need of more people helping out with ideas +and comments, writing documentation and contributing code. + +If you want to contribute to GNU Fortran, +have a look at the long lists of projects you can take on. +Some of these projects are small, +some of them are large; +some are completely orthogonal to the rest of what is +happening on GNU Fortran, +but others are 'mainstream' projects in need of enthusiastic hackers. +All of these projects are important! +We will eventually get around to the things here, +but they are also things doable by someone who is willing and able. + +.. toctree:: + :maxdepth: 2 + + contributors-to-gnu-fortran + projects \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/contributors-to-gnu-fortran.rst b/gcc/fortran/doc/gfortran/contributors-to-gnu-fortran.rst new file mode 100644 index 00000000000..5a9c615a707 --- /dev/null +++ b/gcc/fortran/doc/gfortran/contributors-to-gnu-fortran.rst @@ -0,0 +1,109 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Contributors, Credits, Authors + +.. _contributors: + +Contributors to GNU Fortran +*************************** + +Most of the parser was hand-crafted by *Andy Vaught*, who is +also the initiator of the whole project. Thanks Andy! +Most of the interface with GCC was written by *Paul Brook*. + +The following individuals have contributed code and/or +ideas and significant help to the GNU Fortran project +(in alphabetical order): + +* Janne Blomqvist + +* Steven Bosscher + +* Paul Brook + +* Tobias Burnus + +* François-Xavier Coudert + +* Bud Davis + +* Jerry DeLisle + +* Erik Edelmann + +* Bernhard Fischer + +* Daniel Franke + +* Richard Guenther + +* Richard Henderson + +* Katherine Holcomb + +* Jakub Jelinek + +* Niels Kristian Bech Jensen + +* Steven Johnson + +* Steven G. Kargl + +* Thomas Koenig + +* Asher Langton + +* H.J. Lu + +* Toon Moene + +* Brooks Moses + +* Andrew Pinski + +* Tim Prince + +* Christopher D. Rickett + +* Richard Sandiford + +* Tobias Schlüter + +* Roger Sayle + +* Paul Thomas + +* Andy Vaught + +* Feng Wang + +* Janus Weil + +* Daniel Kraft + +The following people have contributed bug reports, +smaller or larger patches, +and much needed feedback and encouragement for the +GNU Fortran project: + +* Bill Clodius + +* Dominique d'Humiēres + +* Kate Hedstrom + +* Erik Schnetter + +* Gerhard Steinmetz + +* Joost VandeVondele + +Many other individuals have helped debug, +test and improve the GNU Fortran compiler over the past few years, +and we welcome you to do the same! +If you already have done so, +and you would like to see your name listed in the +list above, please contact us. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/copyright.rst b/gcc/fortran/doc/gfortran/copyright.rst new file mode 100644 index 00000000000..c778eb178c7 --- /dev/null +++ b/gcc/fortran/doc/gfortran/copyright.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Copyright +^^^^^^^^^ + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with the +Invariant Sections being **GNU General Public License** and +**Funding Free Software**, the Front-Cover texts being (a) (see below), and with +the Back-Cover Texts being (b) (see below). A copy of the license is +in the :ref:`gnu_fdl`. + +(a) The FSF's Front-Cover Text is: + + A GNU Manual + +(b) The FSF's Back-Cover Text is: + + You have freedom to copy and modify this GNU Manual, like GNU + software. Copies published by the Free Software Foundation raise + funds for GNU development. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/extensions-implemented-in-gnu-fortran.rst b/gcc/fortran/doc/gfortran/extensions-implemented-in-gnu-fortran.rst new file mode 100644 index 00000000000..bffdd27bcbb --- /dev/null +++ b/gcc/fortran/doc/gfortran/extensions-implemented-in-gnu-fortran.rst @@ -0,0 +1,1535 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: extensions, implemented + +.. _extensions-implemented-in-gnu-fortran: + +Extensions implemented in GNU Fortran +************************************* + +GNU Fortran implements a number of extensions over standard Fortran. +This chapter contains information on their syntax and meaning. There +are currently two categories of GNU Fortran extensions, those that +provide functionality beyond that provided by any standard, and those +that are supported by GNU Fortran purely for backward compatibility +with legacy compilers. By default, :option:`-std=gnu` allows the +compiler to accept both types of extensions, but to warn about the use +of the latter. Specifying either :option:`-std=f95`, +:option:`-std=f2003`, :option:`-std=f2008`, or :option:`-std=f2018` +disables both types of extensions, and :option:`-std=legacy` allows +both without warning. The special compile flag :option:`-fdec` enables +additional compatibility extensions along with those enabled by +:option:`-std=legacy`. + +.. toctree:: + :maxdepth: 2 + + +.. index:: kind, old-style + +.. _old-style-kind-specifications: + +Old-style kind specifications +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GNU Fortran allows old-style kind specifications in declarations. These +look like: + +.. code-block:: fortran + + TYPESPEC*size x,y,z + +where ``TYPESPEC`` is a basic type (``INTEGER``, ``REAL``, +etc.), and where ``size`` is a byte count corresponding to the +storage size of a valid kind for that type. (For ``COMPLEX`` +variables, ``size`` is the total size of the real and imaginary +parts.) The statement then declares ``x``, ``y`` and ``z`` to +be of type ``TYPESPEC`` with the appropriate kind. This is +equivalent to the standard-conforming declaration + +.. code-block:: fortran + + TYPESPEC(k) x,y,z + +where ``k`` is the kind parameter suitable for the intended precision. As +kind parameters are implementation-dependent, use the ``KIND``, +``SELECTED_INT_KIND`` and ``SELECTED_REAL_KIND`` intrinsics to retrieve +the correct value, for instance ``REAL*8 x`` can be replaced by: + +.. code-block:: fortran + + INTEGER, PARAMETER :: dbl = KIND(1.0d0) + REAL(KIND=dbl) :: x + +.. _old-style-variable-initialization: + +Old-style variable initialization +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GNU Fortran allows old-style initialization of variables of the +form: + +.. code-block:: fortran + + INTEGER i/1/,j/2/ + REAL x(2,2) /3*0.,1./ + +The syntax for the initializers is as for the ``DATA`` statement, but +unlike in a ``DATA`` statement, an initializer only applies to the +variable immediately preceding the initialization. In other words, +something like ``INTEGER I,J/2,3/`` is not valid. This style of +initialization is only allowed in declarations without double colons +(``::``); the double colons were introduced in Fortran 90, which also +introduced a standard syntax for initializing variables in type +declarations. + +Examples of standard-conforming code equivalent to the above example +are: + +.. code-block:: fortran + + ! Fortran 90 + INTEGER :: i = 1, j = 2 + REAL :: x(2,2) = RESHAPE((/0.,0.,0.,1./),SHAPE(x)) + ! Fortran 77 + INTEGER i, j + REAL x(2,2) + DATA i/1/, j/2/, x/3*0.,1./ + +Note that variables which are explicitly initialized in declarations +or in ``DATA`` statements automatically acquire the ``SAVE`` +attribute. + +.. index:: Namelist + +.. _extensions-to-namelist: + +Extensions to namelist +^^^^^^^^^^^^^^^^^^^^^^ + +GNU Fortran fully supports the Fortran 95 standard for namelist I/O +including array qualifiers, substrings and fully qualified derived types. +The output from a namelist write is compatible with namelist read. The +output has all names in upper case and indentation to column 1 after the +namelist name. Two extensions are permitted: + +Old-style use of :samp:`$` instead of :samp:`&` + +.. code-block:: + + $MYNML + X(:)%Y(2) = 1.0 2.0 3.0 + CH(1:4) = "abcd" + $END + +It should be noted that the default terminator is :samp:`/` rather than +:samp:`&END`. + +Querying of the namelist when inputting from stdin. After at least +one space, entering :samp:`?` sends to stdout the namelist name and the names of +the variables in the namelist: + +.. code-block:: + + ? + + &mynml + x + x%y + ch + &end + +Entering :samp:`=?` outputs the namelist to stdout, as if +``WRITE(*,NML = mynml)`` had been called: + +.. code-block:: + + =? + + &MYNML + X(1)%Y= 0.000000 , 1.000000 , 0.000000 , + X(2)%Y= 0.000000 , 2.000000 , 0.000000 , + X(3)%Y= 0.000000 , 3.000000 , 0.000000 , + CH=abcd, / + +To aid this dialog, when input is from stdin, errors send their +messages to stderr and execution continues, even if ``IOSTAT`` is set. + +``PRINT`` namelist is permitted. This causes an error if +:option:`-std=f95` is used. + +.. code-block:: fortran + + PROGRAM test_print + REAL, dimension (4) :: x = (/1.0, 2.0, 3.0, 4.0/) + NAMELIST /mynml/ x + PRINT mynml + END PROGRAM test_print + +Expanded namelist reads are permitted. This causes an error if +:option:`-std=f95` is used. In the following example, the first element +of the array will be given the value 0.00 and the two succeeding +elements will be given the values 1.00 and 2.00. + +.. code-block:: fortran + + &MYNML + X(1,1) = 0.00 , 1.00 , 2.00 + / + +When writing a namelist, if no ``DELIM=`` is specified, by default a +double quote is used to delimit character strings. If -std=F95, F2003, +or F2008, etc, the delim status is set to 'none'. Defaulting to +quotes ensures that namelists with character strings can be subsequently +read back in accurately. + +.. _x-format-descriptor-without-count-field: + +X format descriptor without count field +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To support legacy codes, GNU Fortran permits the count field of the +``X`` edit descriptor in ``FORMAT`` statements to be omitted. +When omitted, the count is implicitly assumed to be one. + +.. code-block:: fortran + + PRINT 10, 2, 3 + 10 FORMAT (I1, X, I1) + +.. _commas-in-format-specifications: + +Commas in FORMAT specifications +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To support legacy codes, GNU Fortran allows the comma separator +to be omitted immediately before and after character string edit +descriptors in ``FORMAT`` statements. A comma with no following format +decriptor is permited if the :option:`-fdec-blank-format-item` is given on +the command line. This is considered non-conforming code and is +discouraged. + +.. code-block:: fortran + + PRINT 10, 2, 3 + 10 FORMAT ('FOO='I1' BAR='I2) + print 20, 5, 6 + 20 FORMAT (I3, I3,) + +.. _missing-period-in-format-specifications: + +Missing period in FORMAT specifications +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To support legacy codes, GNU Fortran allows missing periods in format +specifications if and only if :option:`-std=legacy` is given on the +command line. This is considered non-conforming code and is +discouraged. + +.. code-block:: fortran + + REAL :: value + READ(*,10) value + 10 FORMAT ('F4') + +.. _default-widths-for-f,-g-and-i-format-descriptors: + +Default widths for F, G and I format descriptors +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To support legacy codes, GNU Fortran allows width to be omitted from format +specifications if and only if :option:`-fdec-format-defaults` is given on the +command line. Default widths will be used. This is considered non-conforming +code and is discouraged. + +.. code-block:: fortran + + REAL :: value1 + INTEGER :: value2 + WRITE(*,10) value1, value1, value2 + 10 FORMAT ('F, G, I') + +.. index:: I/O item lists + +.. _i-o-item-lists: + +I/O item lists +^^^^^^^^^^^^^^ + +To support legacy codes, GNU Fortran allows the input item list +of the ``READ`` statement, and the output item lists of the +``WRITE`` and ``PRINT`` statements, to start with a comma. + +.. index:: Q exponent-letter + +Q exponent-letter +^^^^^^^^^^^^^^^^^ + +GNU Fortran accepts real literal constants with an exponent-letter +of ``Q``, for example, ``1.23Q45``. The constant is interpreted +as a ``REAL(16)`` entity on targets that support this type. If +the target does not support ``REAL(16)`` but has a ``REAL(10)`` +type, then the real-literal-constant will be interpreted as a +``REAL(10)`` entity. In the absence of ``REAL(16)`` and +``REAL(10)``, an error will occur. + +.. index:: BOZ literal constants + +.. _boz-literal-constants: + +BOZ literal constants +^^^^^^^^^^^^^^^^^^^^^ + +Besides decimal constants, Fortran also supports binary (``b``), +octal (``o``) and hexadecimal (``z``) integer constants. The +syntax is: :samp:`prefix quote digits quote`, where the prefix is +either ``b``, ``o`` or ``z``, quote is either ``'`` or +``"`` and the digits are ``0`` or ``1`` for binary, +between ``0`` and ``7`` for octal, and between ``0`` and +``F`` for hexadecimal. (Example: ``b'01011101'``.) + +Up to Fortran 95, BOZ literal constants were only allowed to initialize +integer variables in DATA statements. Since Fortran 2003 BOZ literal +constants are also allowed as actual arguments to the ``REAL``, +``DBLE``, ``INT`` and ``CMPLX`` intrinsic functions. +The BOZ literal constant is simply a string of bits, which is padded +or truncated as needed, during conversion to a numeric type. The +Fortran standard states that the treatment of the sign bit is processor +dependent. Gfortran interprets the sign bit as a user would expect. + +As a deprecated extension, GNU Fortran allows hexadecimal BOZ literal +constants to be specified using the ``X`` prefix. That the BOZ literal +constant can also be specified by adding a suffix to the string, for +example, ``Z'ABC'`` and ``'ABC'X`` are equivalent. Additionally, +as extension, BOZ literals are permitted in some contexts outside of +``DATA`` and the intrinsic functions listed in the Fortran standard. +Use :option:`-fallow-invalid-boz` to enable the extension. + +.. index:: array, indices of type real + +.. _real-array-indices: + +Real array indices +^^^^^^^^^^^^^^^^^^ + +As an extension, GNU Fortran allows the use of ``REAL`` expressions +or variables as array indices. + +.. index:: operators, unary + +.. _unary-operators: + +Unary operators +^^^^^^^^^^^^^^^ + +As an extension, GNU Fortran allows unary plus and unary minus operators +to appear as the second operand of binary arithmetic operators without +the need for parenthesis. + +.. code-block:: fortran + + X = Y * -Z + +.. index:: conversion, to integer, conversion, to logical + +.. _implicitly-convert-logical-and-integer-values: + +Implicitly convert LOGICAL and INTEGER values +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +As an extension for backwards compatibility with other compilers, GNU +Fortran allows the implicit conversion of ``LOGICAL`` values to +``INTEGER`` values and vice versa. When converting from a +``LOGICAL`` to an ``INTEGER``, ``.FALSE.`` is interpreted as +zero, and ``.TRUE.`` is interpreted as one. When converting from +``INTEGER`` to ``LOGICAL``, the value zero is interpreted as +``.FALSE.`` and any nonzero value is interpreted as ``.TRUE.``. + +.. code-block:: fortran + + LOGICAL :: l + l = 1 + +.. code-block:: fortran + + INTEGER :: i + i = .TRUE. + +However, there is no implicit conversion of ``INTEGER`` values in +``if`` -statements, nor of ``LOGICAL`` or ``INTEGER`` values +in I/O operations. + +.. index:: Hollerith constants + +.. _hollerith-constants-support: + +Hollerith constants support +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GNU Fortran supports Hollerith constants in assignments, ``DATA`` +statements, function and subroutine arguments. A Hollerith constant is +written as a string of characters preceded by an integer constant +indicating the character count, and the letter ``H`` or +``h``, and stored in bytewise fashion in a numeric (``INTEGER``, +``REAL``, or ``COMPLEX``), ``LOGICAL`` or ``CHARACTER`` variable. +The constant will be padded with spaces or truncated to fit the size of +the variable in which it is stored. + +Examples of valid uses of Hollerith constants: + +.. code-block:: fortran + + complex*16 x(2) + data x /16Habcdefghijklmnop, 16Hqrstuvwxyz012345/ + x(1) = 16HABCDEFGHIJKLMNOP + call foo (4h abc) + +Examples of Hollerith constants: + +.. code-block:: fortran + + integer*4 a + a = 0H ! Invalid, at least one character is needed. + a = 4HAB12 ! Valid + a = 8H12345678 ! Valid, but the Hollerith constant will be truncated. + a = 3Hxyz ! Valid, but the Hollerith constant will be padded. + +In general, Hollerith constants were used to provide a rudimentary +facility for handling character strings in early Fortran compilers, +prior to the introduction of ``CHARACTER`` variables in Fortran 77; +in those cases, the standard-compliant equivalent is to convert the +program to use proper character strings. On occasion, there may be a +case where the intent is specifically to initialize a numeric variable +with a given byte sequence. In these cases, the same result can be +obtained by using the ``TRANSFER`` statement, as in this example. + +.. code-block:: fortran + + integer(kind=4) :: a + a = transfer ("abcd", a) ! equivalent to: a = 4Habcd + +The use of the :option:`-fdec` option extends support of Hollerith constants +to comparisons: + +.. code-block:: fortran + + integer*4 a + a = 4hABCD + if (a .ne. 4habcd) then + write(*,*) "no match" + end if + +Supported types are numeric (``INTEGER``, ``REAL``, or ``COMPLEX``), +and ``CHARACTER``. + +.. index:: conversion, to character + +.. _character-conversion: + +Character conversion +^^^^^^^^^^^^^^^^^^^^ + +Allowing character literals to be used in a similar way to Hollerith constants +is a non-standard extension. This feature is enabled using +-fdec-char-conversions and only applies to character literals of ``kind=1``. + +Character literals can be used in ``DATA`` statements and assignments with +numeric (``INTEGER``, ``REAL``, or ``COMPLEX``) or ``LOGICAL`` +variables. Like Hollerith constants they are copied byte-wise fashion. The +constant will be padded with spaces or truncated to fit the size of the +variable in which it is stored. + +Examples: + +.. code-block:: fortran + + integer*4 x + data x / 'abcd' / + + x = 'A' ! Will be padded. + x = 'ab1234' ! Will be truncated. + +.. index:: pointer, Cray + +.. _cray-pointers: + +Cray pointers +^^^^^^^^^^^^^ + +Cray pointers are part of a non-standard extension that provides a +C-like pointer in Fortran. This is accomplished through a pair of +variables: an integer "pointer" that holds a memory address, and a +"pointee" that is used to dereference the pointer. + +Pointer/pointee pairs are declared in statements of the form: + +.. code-block:: fortran + + pointer ( , ) + +or, + +.. code-block:: fortran + + pointer ( , ), ( , ), ... + +The pointer is an integer that is intended to hold a memory address. +The pointee may be an array or scalar. +If an assumed-size array is permitted within the scoping unit, a +pointee can be an assumed-size array. +That is, the last dimension may be left unspecified by using a ``*`` +in place of a value. A pointee cannot be an assumed shape array. +No space is allocated for the pointee. + +The pointee may have its type declared before or after the pointer +statement, and its array specification (if any) may be declared +before, during, or after the pointer statement. The pointer may be +declared as an integer prior to the pointer statement. However, some +machines have default integer sizes that are different than the size +of a pointer, and so the following code is not portable: + +.. code-block:: fortran + + integer ipt + pointer (ipt, iarr) + +If a pointer is declared with a kind that is too small, the compiler +will issue a warning; the resulting binary will probably not work +correctly, because the memory addresses stored in the pointers may be +truncated. It is safer to omit the first line of the above example; +if explicit declaration of ipt's type is omitted, then the compiler +will ensure that ipt is an integer variable large enough to hold a +pointer. + +Pointer arithmetic is valid with Cray pointers, but it is not the same +as C pointer arithmetic. Cray pointers are just ordinary integers, so +the user is responsible for determining how many bytes to add to a +pointer in order to increment it. Consider the following example: + +.. code-block:: fortran + + real target(10) + real pointee(10) + pointer (ipt, pointee) + ipt = loc (target) + ipt = ipt + 1 + +The last statement does not set ``ipt`` to the address of +``target(1)``, as it would in C pointer arithmetic. Adding ``1`` +to ``ipt`` just adds one byte to the address stored in ``ipt``. + +Any expression involving the pointee will be translated to use the +value stored in the pointer as the base address. + +To get the address of elements, this extension provides an intrinsic +function ``LOC()``. The ``LOC()`` function is equivalent to the +``&`` operator in C, except the address is cast to an integer type: + +.. code-block:: fortran + + real ar(10) + pointer(ipt, arpte(10)) + real arpte + ipt = loc(ar) ! Makes arpte is an alias for ar + arpte(1) = 1.0 ! Sets ar(1) to 1.0 + +The pointer can also be set by a call to the ``MALLOC`` intrinsic +(see :ref:`MALLOC`). + +Cray pointees often are used to alias an existing variable. For +example: + +.. code-block:: fortran + + integer target(10) + integer iarr(10) + pointer (ipt, iarr) + ipt = loc(target) + +As long as ``ipt`` remains unchanged, ``iarr`` is now an alias for +``target``. The optimizer, however, will not detect this aliasing, so +it is unsafe to use ``iarr`` and ``target`` simultaneously. Using +a pointee in any way that violates the Fortran aliasing rules or +assumptions is illegal. It is the user's responsibility to avoid doing +this; the compiler works under the assumption that no such aliasing +occurs. + +Cray pointers will work correctly when there is no aliasing (i.e., when +they are used to access a dynamically allocated block of memory), and +also in any routine where a pointee is used, but any variable with which +it shares storage is not used. Code that violates these rules may not +run as the user intends. This is not a bug in the optimizer; any code +that violates the aliasing rules is illegal. (Note that this is not +unique to GNU Fortran; any Fortran compiler that supports Cray pointers +will 'incorrectly' optimize code with illegal aliasing.) + +There are a number of restrictions on the attributes that can be applied +to Cray pointers and pointees. Pointees may not have the +``ALLOCATABLE``, ``INTENT``, ``OPTIONAL``, ``DUMMY``, +``TARGET``, ``INTRINSIC``, or ``POINTER`` attributes. Pointers +may not have the ``DIMENSION``, ``POINTER``, ``TARGET``, +``ALLOCATABLE``, ``EXTERNAL``, or ``INTRINSIC`` attributes, nor +may they be function results. Pointees may not occur in more than one +pointer statement. A pointee cannot be a pointer. Pointees cannot occur +in equivalence, common, or data statements. + +A Cray pointer may also point to a function or a subroutine. For +example, the following excerpt is valid: + +.. code-block:: fortran + + implicit none + external sub + pointer (subptr,subpte) + external subpte + subptr = loc(sub) + call subpte() + [...] + subroutine sub + [...] + end subroutine sub + +A pointer may be modified during the course of a program, and this +will change the location to which the pointee refers. However, when +pointees are passed as arguments, they are treated as ordinary +variables in the invoked function. Subsequent changes to the pointer +will not change the base address of the array that was passed. + +.. index:: CONVERT specifier + +.. _convert-specifier: + +CONVERT specifier +^^^^^^^^^^^^^^^^^ + +GNU Fortran allows the conversion of unformatted data between little- +and big-endian representation to facilitate moving of data +between different systems. The conversion can be indicated with +the ``CONVERT`` specifier on the ``OPEN`` statement. +See :ref:`gfortran_convert_unit`, for an alternative way of specifying +the data format via an environment variable. + +Valid values for ``CONVERT`` on most systems are: + +* ``CONVERT='NATIVE'`` Use the native format. This is the default. + +* ``CONVERT='SWAP'`` Swap between little- and big-endian. + +* ``CONVERT='LITTLE_ENDIAN'`` Use the little-endian representation + for unformatted files. + +* ``CONVERT='BIG_ENDIAN'`` Use the big-endian representation for + unformatted files. + +On POWER systems which support :option:`-mabi=ieeelongdouble`, +there are additional options, which can be combined with the others +with commas. Those are + +* ``CONVERT='R16_IEEE'`` Use IEEE 128-bit format for + ``REAL(KIND=16)``. + +* ``CONVERT='R16_IBM'`` Use IBM ``long double`` format for + real ``REAL(KIND=16)``. + +Using the option could look like this: + +.. code-block:: fortran + + open(file='big.dat',form='unformatted',access='sequential', & + convert='big_endian') + +The value of the conversion can be queried by using +``INQUIRE(CONVERT=ch)``. The values returned are +``'BIG_ENDIAN'`` and ``'LITTLE_ENDIAN'``. + +``CONVERT`` works between big- and little-endian for +``INTEGER`` values of all supported kinds and for ``REAL`` +on IEEE systems of kinds 4 and 8. Conversion between different +'extended double' types on different architectures such as +m68k and x86_64, which GNU Fortran +supports as ``REAL(KIND=10)`` and ``REAL(KIND=16)``, will +probably not work. + +*Note that the values specified via the GFORTRAN_CONVERT_UNIT +environment variable will override the CONVERT specifier in the +open statement*. This is to give control over data formats to +users who do not have the source code of their program available. + +Using anything but the native representation for unformatted data +carries a significant speed overhead. If speed in this area matters +to you, it is best if you use this only for data that needs to be +portable. + +.. index:: OpenMP + +.. _openmp: + +OpenMP +^^^^^^ + +OpenMP (Open Multi-Processing) is an application programming +interface (API) that supports multi-platform shared memory +multiprocessing programming in C/C++ and Fortran on many +architectures, including Unix and Microsoft Windows platforms. +It consists of a set of compiler directives, library routines, +and environment variables that influence run-time behavior. + +GNU Fortran strives to be compatible to the +`OpenMP Application Program Interface v4.5 `_. + +To enable the processing of the OpenMP directive ``!$omp`` in +free-form source code; the ``c$omp``, ``*$omp`` and ``!$omp`` +directives in fixed form; the ``!$`` conditional compilation sentinels +in free form; and the ``c$``, ``*$`` and ``!$`` sentinels +in fixed form, :command:`gfortran` needs to be invoked with the +:option:`-fopenmp`. This also arranges for automatic linking of the +GNU Offloading and Multi Processing Runtime Library +:ref:`libgomp:top`. + +The OpenMP Fortran runtime library routines are provided both in a +form of a Fortran 90 module named ``omp_lib`` and in a form of +a Fortran ``include`` file named :samp:`omp_lib.h`. + +An example of a parallelized loop taken from Appendix A.1 of +the OpenMP Application Program Interface v2.5: + +.. code-block:: fortran + + SUBROUTINE A1(N, A, B) + INTEGER I, N + REAL B(N), A(N) + !$OMP PARALLEL DO !I is private by default + DO I=2,N + B(I) = (A(I) + A(I-1)) / 2.0 + ENDDO + !$OMP END PARALLEL DO + END SUBROUTINE A1 + +.. note:: + + :option:`-fopenmp` implies :option:`-frecursive`, i.e., all local arrays + will be allocated on the stack. When porting existing code to OpenMP, + this may lead to surprising results, especially to segmentation faults + if the stacksize is limited. + +.. note:: + + On glibc-based systems, OpenMP enabled applications cannot be statically + linked due to limitations of the underlying pthreads-implementation. It + might be possible to get a working solution if + :command:`-Wl,--whole-archive -lpthread -Wl,--no-whole-archive` is added + to the command line. However, this is not supported by :command:`gcc` and + thus not recommended. + +.. index:: OpenACC + +.. _openacc: + +OpenACC +^^^^^^^ + +OpenACC is an application programming interface (API) that supports +offloading of code to accelerator devices. It consists of a set of +compiler directives, library routines, and environment variables that +influence run-time behavior. + +GNU Fortran strives to be compatible to the +`OpenACC Application Programming +Interface v2.6 `_. + +To enable the processing of the OpenACC directive ``!$acc`` in +free-form source code; the ``c$acc``, ``*$acc`` and ``!$acc`` +directives in fixed form; the ``!$`` conditional compilation +sentinels in free form; and the ``c$``, ``*$`` and ``!$`` +sentinels in fixed form, :command:`gfortran` needs to be invoked with +the :option:`-fopenacc`. This also arranges for automatic linking of +the GNU Offloading and Multi Processing Runtime Library +:ref:`libgomp:top`. + +The OpenACC Fortran runtime library routines are provided both in a +form of a Fortran 90 module named ``openacc`` and in a form of a +Fortran ``include`` file named :samp:`openacc_lib.h`. + +.. index:: argument list functions, %VAL, %REF, %LOC + +.. _argument-list-functions: + +Argument list functions %VAL, %REF and %LOC +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GNU Fortran supports argument list functions ``%VAL``, ``%REF`` +and ``%LOC`` statements, for backward compatibility with g77. +It is recommended that these should be used only for code that is +accessing facilities outside of GNU Fortran, such as operating system +or windowing facilities. It is best to constrain such uses to isolated +portions of a program--portions that deal specifically and exclusively +with low-level, system-dependent facilities. Such portions might well +provide a portable interface for use by the program as a whole, but are +themselves not portable, and should be thoroughly tested each time they +are rebuilt using a new compiler or version of a compiler. + +``%VAL`` passes a scalar argument by value, ``%REF`` passes it by +reference and ``%LOC`` passes its memory location. Since gfortran +already passes scalar arguments by reference, ``%REF`` is in effect +a do-nothing. ``%LOC`` has the same effect as a Fortran pointer. + +An example of passing an argument by value to a C subroutine foo.: + +.. code-block:: fortran + + C + C prototype void foo_ (float x); + C + external foo + real*4 x + x = 3.14159 + call foo (%VAL (x)) + end + +For details refer to the g77 manual +https://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/index.html#Top. + +Also, ``c_by_val.f`` and its partner ``c_by_val.c`` of the +GNU Fortran testsuite are worth a look. + +.. index:: EOF, BACKSPACE, REWIND + +.. _read-write-after-eof-marker: + +Read/Write after EOF marker +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Some legacy codes rely on allowing ``READ`` or ``WRITE`` after the +EOF file marker in order to find the end of a file. GNU Fortran normally +rejects these codes with a run-time error message and suggests the user +consider ``BACKSPACE`` or ``REWIND`` to properly position +the file before the EOF marker. As an extension, the run-time error may +be disabled using -std=legacy. + +.. index:: STRUCTURE, RECORD + +.. _structure-and-record: + +STRUCTURE and RECORD +^^^^^^^^^^^^^^^^^^^^ + +Record structures are a pre-Fortran-90 vendor extension to create +user-defined aggregate data types. Support for record structures in GNU +Fortran can be enabled with the :option:`-fdec-structure` compile flag. +If you have a choice, you should instead use Fortran 90's 'derived types', +which have a different syntax. + +In many cases, record structures can easily be converted to derived types. +To convert, replace ``STRUCTURE /``:samp:`{structure-name}` ``/`` +by ``TYPE`` :samp:`{type-name}`. Additionally, replace +``RECORD /``:samp:`{structure-name}` ``/`` by +``TYPE(``:samp:`{type-name}` ``)``. Finally, in the component access, +replace the period (``.``) by the percent sign (``%``). + +Here is an example of code using the non portable record structure syntax: + +.. code-block:: fortran + + ! Declaring a structure named ``item'' and containing three fields: + ! an integer ID, an description string and a floating-point price. + STRUCTURE /item/ + INTEGER id + CHARACTER(LEN=200) description + REAL price + END STRUCTURE + + ! Define two variables, an single record of type ``item'' + ! named ``pear'', and an array of items named ``store_catalog'' + RECORD /item/ pear, store_catalog(100) + + ! We can directly access the fields of both variables + pear.id = 92316 + pear.description = "juicy D'Anjou pear" + pear.price = 0.15 + store_catalog(7).id = 7831 + store_catalog(7).description = "milk bottle" + store_catalog(7).price = 1.2 + + ! We can also manipulate the whole structure + store_catalog(12) = pear + print *, store_catalog(12) + +This code can easily be rewritten in the Fortran 90 syntax as following: + +.. code-block:: fortran + + ! ``STRUCTURE /name/ ... END STRUCTURE'' becomes + ! ``TYPE name ... END TYPE'' + TYPE item + INTEGER id + CHARACTER(LEN=200) description + REAL price + END TYPE + + ! ``RECORD /name/ variable'' becomes ``TYPE(name) variable'' + TYPE(item) pear, store_catalog(100) + + ! Instead of using a dot (.) to access fields of a record, the + ! standard syntax uses a percent sign (%) + pear%id = 92316 + pear%description = "juicy D'Anjou pear" + pear%price = 0.15 + store_catalog(7)%id = 7831 + store_catalog(7)%description = "milk bottle" + store_catalog(7)%price = 1.2 + + ! Assignments of a whole variable do not change + store_catalog(12) = pear + print *, store_catalog(12) + +GNU Fortran implements STRUCTURES like derived types with the following +rules and exceptions: + +* Structures act like derived types with the ``SEQUENCE`` attribute. + Otherwise they may contain no specifiers. + +* Structures may contain a special field with the name ``%FILL``. + This will create an anonymous component which cannot be accessed but occupies + space just as if a component of the same type was declared in its place, useful + for alignment purposes. As an example, the following structure will consist + of at least sixteen bytes: + + .. code-block:: fortran + + structure /padded/ + character(4) start + character(8) %FILL + character(4) end + end structure + +* Structures may share names with other symbols. For example, the following + is invalid for derived types, but valid for structures: + + .. code-block:: fortran + + structure /header/ + ! ... + end structure + record /header/ header + +* Structure types may be declared nested within another parent structure. + The syntax is: + + .. code-block:: fortran + + structure /type-name/ + ... + structure [//] + ... + + The type name may be ommitted, in which case the structure type itself is + anonymous, and other structures of the same type cannot be instantiated. The + following shows some examples: + + .. code-block:: fortran + + structure /appointment/ + ! nested structure definition: app_time is an array of two 'time' + structure /time/ app_time (2) + integer(1) hour, minute + end structure + character(10) memo + end structure + + ! The 'time' structure is still usable + record /time/ now + now = time(5, 30) + + ... + + structure /appointment/ + ! anonymous nested structure definition + structure start, end + integer(1) hour, minute + end structure + character(10) memo + end structure + +* Structures may contain ``UNION`` blocks. For more detail see the + section on :ref:`union-and-map`. + +* Structures support old-style initialization of components, like + those described in :ref:`old-style-variable-initialization`. For array + initializers, an initializer may contain a repeat specification of the form + `` * ``. The value of the integer + indicates the number of times to repeat the constant initializer when expanding + the initializer list. + +.. index:: UNION, MAP + +.. _union-and-map: + +UNION and MAP +^^^^^^^^^^^^^ + +Unions are an old vendor extension which were commonly used with the +non-standard :ref:`structure-and-record` extensions. Use of ``UNION`` and +``MAP`` is automatically enabled with :option:`-fdec-structure`. + +A ``UNION`` declaration occurs within a structure; within the definition of +each union is a number of ``MAP`` blocks. Each ``MAP`` shares storage +with its sibling maps (in the same union), and the size of the union is the +size of the largest map within it, just as with unions in C. The major +difference is that component references do not indicate which union or map the +component is in (the compiler gets to figure that out). + +Here is a small example: + +.. code-block:: fortran + + structure /myunion/ + union + map + character(2) w0, w1, w2 + end map + map + character(6) long + end map + end union + end structure + + record /myunion/ rec + ! After this assignment... + rec.long = 'hello!' + + ! The following is true: + ! rec.w0 === 'he' + ! rec.w1 === 'll' + ! rec.w2 === 'o!' + +The two maps share memory, and the size of the union is ultimately six bytes: + +.. code-block:: + + 0 1 2 3 4 5 6 Byte offset + ------------------------------- + | | | | | | | + ------------------------------- + + ^ W0 ^ W1 ^ W2 ^ + \-------/ \-------/ \-------/ + + ^ LONG ^ + \---------------------------/ + +Following is an example mirroring the layout of an Intel x86_64 register: + +.. code-block:: fortran + + structure /reg/ + union ! U0 ! rax + map + character(16) rx + end map + map + character(8) rh ! rah + union ! U1 + map + character(8) rl ! ral + end map + map + character(8) ex ! eax + end map + map + character(4) eh ! eah + union ! U2 + map + character(4) el ! eal + end map + map + character(4) x ! ax + end map + map + character(2) h ! ah + character(2) l ! al + end map + end union + end map + end union + end map + end union + end structure + record /reg/ a + + ! After this assignment... + a.rx = 'AAAAAAAA.BBB.C.D' + + ! The following is true: + a.rx === 'AAAAAAAA.BBB.C.D' + a.rh === 'AAAAAAAA' + a.rl === '.BBB.C.D' + a.ex === '.BBB.C.D' + a.eh === '.BBB' + a.el === '.C.D' + a.x === '.C.D' + a.h === '.C' + a.l === '.D' + +.. index:: intrinsics, integer + +.. _type-variants-for-integer-intrinsics: + +Type variants for integer intrinsics +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Similar to the D/C prefixes to real functions to specify the input/output +types, GNU Fortran offers B/I/J/K prefixes to integer functions for +compatibility with DEC programs. The types implied by each are: + +.. code-block:: fortran + + B - INTEGER(kind=1) + I - INTEGER(kind=2) + J - INTEGER(kind=4) + K - INTEGER(kind=8) + +GNU Fortran supports these with the flag :option:`-fdec-intrinsic-ints`. +Intrinsics for which prefixed versions are available and in what form are noted +in :ref:`intrinsic-procedures`. The complete list of supported intrinsics is +here: + +.. list-table:: + :header-rows: 1 + + * - Intrinsic + - B + - I + - J + - K + + * - ``ABS`` + - ``BABS`` + - ``IIABS`` + - ``JIABS`` + - ``KIABS`` + * - ``BTEST`` + - ``BBTEST`` + - ``BITEST`` + - ``BJTEST`` + - ``BKTEST`` + * - ``IAND`` + - ``BIAND`` + - ``IIAND`` + - ``JIAND`` + - ``KIAND`` + * - ``IBCLR`` + - ``BBCLR`` + - ``IIBCLR`` + - ``JIBCLR`` + - ``KIBCLR`` + * - ``IBITS`` + - ``BBITS`` + - ``IIBITS`` + - ``JIBITS`` + - ``KIBITS`` + * - ``IBSET`` + - ``BBSET`` + - ``IIBSET`` + - ``JIBSET`` + - ``KIBSET`` + * - ``IEOR`` + - ``BIEOR`` + - ``IIEOR`` + - ``JIEOR`` + - ``KIEOR`` + * - ``IOR`` + - ``BIOR`` + - ``IIOR`` + - ``JIOR`` + - ``KIOR`` + * - ``ISHFT`` + - ``BSHFT`` + - ``IISHFT`` + - ``JISHFT`` + - ``KISHFT`` + * - ``ISHFTC`` + - ``BSHFTC`` + - ``IISHFTC`` + - ``JISHFTC`` + - ``KISHFTC`` + * - ``MOD`` + - ``BMOD`` + - ``IMOD`` + - ``JMOD`` + - ``KMOD`` + * - ``NOT`` + - ``BNOT`` + - ``INOT`` + - ``JNOT`` + - ``KNOT`` + * - ``REAL`` + - ``--`` + - ``FLOATI`` + - ``FLOATJ`` + - ``FLOATK`` + +.. _automatic-and-static-attributes: + +AUTOMATIC and STATIC attributes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +With :option:`-fdec-static` GNU Fortran supports the DEC extended attributes +``STATIC`` and ``AUTOMATIC`` to provide explicit specification of entity +storage. These follow the syntax of the Fortran standard ``SAVE`` attribute. + +``STATIC`` is exactly equivalent to ``SAVE``, and specifies that +an entity should be allocated in static memory. As an example, ``STATIC`` +local variables will retain their values across multiple calls to a function. + +Entities marked ``AUTOMATIC`` will be stack automatic whenever possible. +``AUTOMATIC`` is the default for local variables smaller than +:option:`-fmax-stack-var-size`, unless :option:`-fno-automatic` is given. This +attribute overrides :option:`-fno-automatic`, :option:`-fmax-stack-var-size`, and +blanket ``SAVE`` statements. + +Examples: + +.. code-block:: fortran + + subroutine f + integer, automatic :: i ! automatic variable + integer x, y ! static variables + save + ... + endsubroutine + +.. code-block:: fortran + + subroutine f + integer a, b, c, x, y, z + static :: x + save y + automatic z, c + ! a, b, c, and z are automatic + ! x and y are static + endsubroutine + +.. code-block:: fortran + + ! Compiled with -fno-automatic + subroutine f + integer a, b, c, d + automatic :: a + ! a is automatic; b, c, and d are static + endsubroutine + +.. index:: intrinsics, math, intrinsics, trigonometric functions + +.. _extended-math-intrinsics: + +Extended math intrinsics +^^^^^^^^^^^^^^^^^^^^^^^^ + +GNU Fortran supports an extended list of mathematical intrinsics with the +compile flag :option:`-fdec-math` for compatability with legacy code. +These intrinsics are described fully in :ref:`intrinsic-procedures` where it is +noted that they are extensions and should be avoided whenever possible. + +Specifically, :option:`-fdec-math` enables the :ref:`COTAN` intrinsic, and +trigonometric intrinsics which accept or produce values in degrees instead of +radians. Here is a summary of the new intrinsics: + +.. list-table:: + :header-rows: 1 + + * - Radians + - Degrees + + * - ``ACOS`` + - ``ACOSD`` \* + * - ``ASIN`` + - ``ASIND`` \* + * - ``ATAN`` + - ``ATAND`` \* + * - ``ATAN2`` + - ``ATAN2D`` \* + * - ``COS`` + - ``COSD`` \* + * - ``COTAN`` \* + - ``COTAND`` \* + * - ``SIN`` + - ``SIND`` \* + * - ``TAN`` + - ``TAND`` \* + +\* Enabled with :option:`-fdec-math`. + +For advanced users, it may be important to know the implementation of these +functions. They are simply wrappers around the standard radian functions, which +have more accurate builtin versions. These functions convert their arguments +(or results) to degrees (or radians) by taking the value modulus 360 (or 2\*pi) +and then multiplying it by a constant radian-to-degree (or degree-to-radian) +factor, as appropriate. The factor is computed at compile-time as 180/pi (or +pi/180). + +.. index:: form feed whitespace + +.. _form-feed-as-whitespace: + +Form feed as whitespace +^^^^^^^^^^^^^^^^^^^^^^^ + +Historically, legacy compilers allowed insertion of form feed characters ('\f', +ASCII 0xC) at the beginning of lines for formatted output to line printers, +though the Fortran standard does not mention this. GNU Fortran supports the +interpretation of form feed characters in source as whitespace for +compatibility. + +.. index:: type alias print + +.. _type-as-an-alias-for-print: + +TYPE as an alias for PRINT +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +For compatibility, GNU Fortran will interpret ``TYPE`` statements as +``PRINT`` statements with the flag :option:`-fdec`. With this flag asserted, +the following two examples are equivalent: + +.. code-block:: fortran + + TYPE *, 'hello world' + +.. code-block:: fortran + + PRINT *, 'hello world' + +.. index:: LOC + +.. _%loc-as-an-rvalue: + +%LOC as an rvalue +^^^^^^^^^^^^^^^^^ + +Normally ``%LOC`` is allowed only in parameter lists. However the intrinsic +function ``LOC`` does the same thing, and is usable as the right-hand-side of +assignments. For compatibility, GNU Fortran supports the use of ``%LOC`` as +an alias for the builtin ``LOC`` with :option:`-std=legacy`. With this +feature enabled the following two examples are equivalent: + +.. code-block:: fortran + + integer :: i, l + l = %loc(i) + call sub(l) + +.. code-block:: fortran + + integer :: i + call sub(%loc(i)) + +.. index:: operators, xor + +.. _.xor.-operator: + +.XOR. operator +^^^^^^^^^^^^^^ + +GNU Fortran supports ``.XOR.`` as a logical operator with ``-std=legacy`` +for compatibility with legacy code. ``.XOR.`` is equivalent to +``.NEQV.``. That is, the output is true if and only if the inputs differ. + +.. index:: logical, bitwise + +.. _bitwise-logical-operators: + +Bitwise logical operators +^^^^^^^^^^^^^^^^^^^^^^^^^ + +With :option:`-fdec`, GNU Fortran relaxes the type constraints on +logical operators to allow integer operands, and performs the corresponding +bitwise operation instead. This flag is for compatibility only, and should be +avoided in new code. Consider: + +.. code-block:: fortran + + INTEGER :: i, j + i = z'33' + j = z'cc' + print *, i .AND. j + +In this example, compiled with :option:`-fdec`, GNU Fortran will +replace the ``.AND.`` operation with a call to the intrinsic +function, yielding the bitwise-and of ``i`` and ``j``. + +Note that this conversion will occur if at least one operand is of integral +type. As a result, a logical operand will be converted to an integer when the +other operand is an integer in a logical operation. In this case, +``.TRUE.`` is converted to ``1`` and ``.FALSE.`` to ``0``. + +Here is the mapping of logical operator to bitwise intrinsic used with +:option:`-fdec` : + +.. list-table:: + :header-rows: 1 + + * - Operator + - Intrinsic + - Bitwise operation + + * - ``.NOT.`` + - ``NOT`` + - complement + * - ``.AND.`` + - ``IAND`` + - intersection + * - ``.OR.`` + - ``IOR`` + - union + * - ``.NEQV.`` + - ``IEOR`` + - exclusive or + * - ``.EQV.`` + - ``NOT(IEOR)`` + - complement of exclusive or + +.. _extended-i-o-specifiers: + +Extended I/O specifiers +^^^^^^^^^^^^^^^^^^^^^^^ + +GNU Fortran supports the additional legacy I/O specifiers +``CARRIAGECONTROL``, ``READONLY``, and ``SHARE`` with the +compile flag :option:`-fdec`, for compatibility. + +.. envvar:: CARRIAGECONTROL + + The ``CARRIAGECONTROL`` specifier allows a user to control line + termination settings between output records for an I/O unit. The specifier has + no meaning for readonly files. When ``CARRAIGECONTROL`` is specified upon + opening a unit for formatted writing, the exact ``CARRIAGECONTROL`` setting + determines what characters to write between output records. The syntax is: + + .. code-block:: fortran + + OPEN(..., CARRIAGECONTROL=cc) + + Where *cc* is a character expression that evaluates to one of the + following values: + + .. list-table:: + + * - ``'LIST'`` + - One line feed between records (default) + * - ``'FORTRAN'`` + - Legacy interpretation of the first character (see below) + * - ``'NONE'`` + - No separator between records + + With ``CARRIAGECONTROL='FORTRAN'``, when a record is written, the first + character of the input record is not written, and instead determines the output + record separator as follows: + + .. list-table:: + :header-rows: 1 + + * - Leading character + - Meaning + - Output separating character(s) + + * - ``'+'`` + - Overprinting + - Carriage return only + * - ``'-'`` + - New line + - Line feed and carriage return + * - ``'0'`` + - Skip line + - Two line feeds and carriage return + * - ``'1'`` + - New page + - Form feed and carriage return + * - ``'$'`` + - Prompting + - Line feed (no carriage return) + * - ``CHAR(0)`` + - Overprinting (no advance) + - None + +.. envvar:: READONLY + + The ``READONLY`` specifier may be given upon opening a unit, and is + equivalent to specifying ``ACTION='READ'``, except that the file may not be + deleted on close (i.e. ``CLOSE`` with ``STATUS="DELETE"``). The syntax + is: + + .. code-block:: fortran + + OPEN(..., READONLY) + +.. envvar:: SHARE + + The ``SHARE`` specifier allows system-level locking on a unit upon opening + it for controlled access from multiple processes/threads. The ``SHARE`` + specifier has several forms: + + .. code-block:: fortran + + OPEN(..., SHARE=sh) + OPEN(..., SHARED) + OPEN(..., NOSHARED) + + Where *sh* in the first form is a character expression that evaluates to + a value as seen in the table below. The latter two forms are aliases + for particular values of *sh*: + + .. list-table:: + :header-rows: 1 + + * - Explicit form + - Short form + - Meaning + + * - ``SHARE='DENYRW'`` + - ``NOSHARED`` + - Exclusive (write) lock + * - ``SHARE='DENYNONE'`` + - ``SHARED`` + - Shared (read) lock + + In general only one process may hold an exclusive (write) lock for a given file + at a time, whereas many processes may hold shared (read) locks for the same + file. + + The behavior of locking may vary with your operating system. On POSIX systems, + locking is implemented with ``fcntl``. Consult your corresponding operating + system's manual pages for further details. Locking via ``SHARE=`` is not + supported on other systems. + +.. index:: PARAMETER + +.. _legacy-parameter-statements: + +Legacy PARAMETER statements +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +For compatibility, GNU Fortran supports legacy PARAMETER statements without +parentheses with :option:`-std=legacy`. A warning is emitted if used with +:option:`-std=gnu`, and an error is acknowledged with a real Fortran standard +flag (:option:`-std=f95`, etc...). These statements take the following form: + +.. code-block:: fortran + + implicit real (E) + parameter e = 2.718282 + real c + parameter c = 3.0e8 + +.. index:: exponent + +.. _default-exponents: + +Default exponents +^^^^^^^^^^^^^^^^^ + +For compatibility, GNU Fortran supports a default exponent of zero in real +constants with :option:`-fdec`. For example, ``9e`` would be +interpreted as ``9e0``, rather than an error. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/extensions-not-implemented-in-gnu-fortran.rst b/gcc/fortran/doc/gfortran/extensions-not-implemented-in-gnu-fortran.rst new file mode 100644 index 00000000000..33bbd7b27ba --- /dev/null +++ b/gcc/fortran/doc/gfortran/extensions-not-implemented-in-gnu-fortran.rst @@ -0,0 +1,186 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: extensions, not implemented + +.. _extensions-not-implemented-in-gnu-fortran: + +Extensions not implemented in GNU Fortran +***************************************** + +The long history of the Fortran language, its wide use and broad +userbase, the large number of different compiler vendors and the lack of +some features crucial to users in the first standards have lead to the +existence of a number of important extensions to the language. While +some of the most useful or popular extensions are supported by the GNU +Fortran compiler, not all existing extensions are supported. This section +aims at listing these extensions and offering advice on how best make +code that uses them running with the GNU Fortran compiler. + +.. More can be found here: + - https://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Missing-Features.html + - the list of Fortran and libgfortran bugs closed as WONTFIX: + http://tinyurl.com/2u4h5y + +.. toctree:: + :maxdepth: 2 + + +.. index:: ENCODE, DECODE + +.. _encode-and-decode-statements: + +ENCODE and DECODE statements +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GNU Fortran does not support the ``ENCODE`` and ``DECODE`` +statements. These statements are best replaced by ``READ`` and +``WRITE`` statements involving internal files (``CHARACTER`` +variables and arrays), which have been part of the Fortran standard since +Fortran 77. For example, replace a code fragment like + +.. code-block:: fortran + + INTEGER*1 LINE(80) + REAL A, B, C + c ... Code that sets LINE + DECODE (80, 9000, LINE) A, B, C + 9000 FORMAT (1X, 3(F10.5)) + +with the following: + +.. code-block:: fortran + + CHARACTER(LEN=80) LINE + REAL A, B, C + c ... Code that sets LINE + READ (UNIT=LINE, FMT=9000) A, B, C + 9000 FORMAT (1X, 3(F10.5)) + +Similarly, replace a code fragment like + +.. code-block:: fortran + + INTEGER*1 LINE(80) + REAL A, B, C + c ... Code that sets A, B and C + ENCODE (80, 9000, LINE) A, B, C + 9000 FORMAT (1X, 'OUTPUT IS ', 3(F10.5)) + +with the following: + +.. code-block:: fortran + + CHARACTER(LEN=80) LINE + REAL A, B, C + c ... Code that sets A, B and C + WRITE (UNIT=LINE, FMT=9000) A, B, C + 9000 FORMAT (1X, 'OUTPUT IS ', 3(F10.5)) + +.. index:: FORMAT + +.. _variable-format-expressions: + +Variable FORMAT expressions +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A variable ``FORMAT`` expression is format statement which includes +angle brackets enclosing a Fortran expression: ``FORMAT(I)``. GNU +Fortran does not support this legacy extension. The effect of variable +format expressions can be reproduced by using the more powerful (and +standard) combination of internal output and string formats. For example, +replace a code fragment like this: + +.. code-block:: fortran + + WRITE(6,20) INT1 + 20 FORMAT(I) + +with the following: + +.. code-block:: fortran + + c Variable declaration + CHARACTER(LEN=20) FMT + c + c Other code here... + c + WRITE(FMT,'("(I", I0, ")")') N+1 + WRITE(6,FMT) INT1 + +or with: + +.. code-block:: fortran + + c Variable declaration + CHARACTER(LEN=20) FMT + c + c Other code here... + c + WRITE(FMT,*) N+1 + WRITE(6,"(I" // ADJUSTL(FMT) // ")") INT1 + +.. index:: Complex function + +.. _alternate-complex-function-syntax: + +Alternate complex function syntax +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Some Fortran compilers, including :command:`g77`, let the user declare +complex functions with the syntax ``COMPLEX FUNCTION name*16()``, as +well as ``COMPLEX*16 FUNCTION name()``. Both are non-standard, legacy +extensions. :command:`gfortran` accepts the latter form, which is more +common, but not the former. + +.. index:: VOLATILE, COMMON + +.. _volatile-common-blocks: + +Volatile COMMON blocks +^^^^^^^^^^^^^^^^^^^^^^ + +Some Fortran compilers, including :command:`g77`, let the user declare +``COMMON`` with the ``VOLATILE`` attribute. This is +invalid standard Fortran syntax and is not supported by +:command:`gfortran`. Note that :command:`gfortran` accepts +``VOLATILE`` variables in ``COMMON`` blocks since revision 4.3. + +.. index:: NAME + +.. _open(-...-name=): + +OPEN( ... NAME=) +^^^^^^^^^^^^^^^^ + +Some Fortran compilers, including :command:`g77`, let the user declare +``OPEN( ... NAME=)``. This is +invalid standard Fortran syntax and is not supported by +:command:`gfortran`. ``OPEN( ... NAME=)`` should be replaced +with ``OPEN( ... FILE=)``. + +.. index:: Q edit descriptor + +.. _q-edit-descriptor: + +Q edit descriptor +^^^^^^^^^^^^^^^^^ + +Some Fortran compilers provide the ``Q`` edit descriptor, which +transfers the number of characters left within an input record into an +integer variable. + +A direct replacement of the ``Q`` edit descriptor is not available +in :command:`gfortran`. How to replicate its functionality using +standard-conforming code depends on what the intent of the original +code is. + +Options to replace ``Q`` may be to read the whole line into a +character variable and then counting the number of non-blank +characters left using ``LEN_TRIM``. Another method may be to use +formatted stream, read the data up to the position where the ``Q`` +descriptor occurred, use ``INQUIRE`` to get the file position, +count the characters up to the next ``NEW_LINE`` and then start +reading from the position marked previously. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/extensions.rst b/gcc/fortran/doc/gfortran/extensions.rst new file mode 100644 index 00000000000..c151fc6fa37 --- /dev/null +++ b/gcc/fortran/doc/gfortran/extensions.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: extensions + +.. _extensions: + +Extensions +---------- + +The two sections below detail the extensions to standard Fortran that are +implemented in GNU Fortran, as well as some of the popular or +historically important extensions that are not (or not yet) implemented. +For the latter case, we explain the alternatives available to GNU Fortran +users, including replacement by standard-conforming code or GNU +extensions. + +.. toctree:: + :maxdepth: 2 + + extensions-implemented-in-gnu-fortran + extensions-not-implemented-in-gnu-fortran \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/function-abi-documentation.rst b/gcc/fortran/doc/gfortran/function-abi-documentation.rst new file mode 100644 index 00000000000..a26ea3f4651 --- /dev/null +++ b/gcc/fortran/doc/gfortran/function-abi-documentation.rst @@ -0,0 +1,1526 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _function-abi-documentation: + +Function ABI Documentation +************************** + +.. toctree:: + :maxdepth: 2 + + +.. index:: Coarray, _gfortran_caf_init + +.. _gfortran_caf_init: + +_gfortran_caf_init --- Initialiation function +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_init (int *argc, char ***argv) + + This function is called at startup of the program before the Fortran main + program, if the latter has been compiled with :option:`-fcoarray=lib`. + It takes as arguments the command-line arguments of the program. It is + permitted to pass two ``NULL`` pointers as argument; if non- ``NULL``, + the library is permitted to modify the arguments. + + :param argc: + intent(inout) An integer pointer with the number of + arguments passed to the program or ``NULL``. + + :param argv: + intent(inout) A pointer to an array of strings with the + command-line arguments or ``NULL``. + + .. note:: + + The function is modelled after the initialization function of the Message + Passing Interface (MPI) specification. Due to the way coarray registration + works, it might not be the first call to the library. If the main program is + not written in Fortran and only a library uses coarrays, it can happen that + this function is never called. Therefore, it is recommended that the library + does not rely on the passed arguments and whether the call has been done. + +.. index:: Coarray, _gfortran_caf_finish + +.. _gfortran_caf_finish: + +_gfortran_caf_finish --- Finalization function +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_finish (void) + + This function is called at the end of the Fortran main program, if it has + been compiled with the :option:`-fcoarray=lib` option. + + .. note:: + + For non-Fortran programs, it is recommended to call the function at the end + of the main program. To ensure that the shutdown is also performed for + programs where this function is not explicitly invoked, for instance + non-Fortran programs or calls to the system's exit() function, the library + can use a destructor function. Note that programs can also be terminated + using the STOP and ERROR STOP statements; those use different library calls. + +.. index:: Coarray, _gfortran_caf_this_image + +.. _gfortran_caf_this_image: + +_gfortran_caf_this_image --- Querying the image number +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: int _gfortran_caf_this_image (int distance) + + This function returns the current image number, which is a positive number. + + :param distance: + As specified for the ``this_image`` intrinsic + in TS18508. Shall be a non-negative number. + + .. note:: + + If the Fortran intrinsic ``this_image`` is invoked without an argument, which + is the only permitted form in Fortran 2008, GCC passes ``0`` as + first argument. + +.. index:: Coarray, _gfortran_caf_num_images + +.. _gfortran_caf_num_images: + +_gfortran_caf_num_images --- Querying the maximal number of images +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: int _gfortran_caf_num_images(int distance, int failed) + + This function returns the number of images in the current team, if + :samp:`{distance}` is 0 or the number of images in the parent team at the specified + distance. If failed is -1, the function returns the number of all images at + the specified distance; if it is 0, the function returns the number of + nonfailed images, and if it is 1, it returns the number of failed images. + + :param distance: + the distance from this image to the ancestor. + Shall be positive. + + :param failed: + shall be -1, 0, or 1 + + .. note:: + + This function follows TS18508. If the num_image intrinsic has no arguments, + then the compiler passes ``distance=0`` and ``failed=-1`` to the function. + +.. index:: Coarray, _gfortran_caf_image_status + +.. _gfortran_caf_image_status: + +_gfortran_caf_image_status --- Query the status of an image +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: int _gfortran_caf_image_status (int image, caf_team_t * team) + + Get the status of the image given by the id :samp:`{image}` of the team given by + :samp:`{team}`. Valid results are zero, for image is ok, ``STAT_STOPPED_IMAGE`` + from the ISO_FORTRAN_ENV module to indicate that the image has been stopped and + ``STAT_FAILED_IMAGE`` also from ISO_FORTRAN_ENV to indicate that the image + has executed a ``FAIL IMAGE`` statement. + + :param image: + the positive scalar id of the image in the current TEAM. + + :param team: + optional; team on the which the inquiry is to be + performed. + + .. note:: + + This function follows TS18508. Because team-functionality is not yet + implemented a null-pointer is passed for the :samp:`{team}` argument at the moment. + +.. index:: Coarray, _gfortran_caf_failed_images + +.. _gfortran_caf_failed_images: + +_gfortran_caf_failed_images --- Get an array of the indexes of the failed images +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: int _gfortran_caf_failed_images (caf_team_t * team, int * kind) + + Get an array of image indexes in the current :samp:`{team}` that have failed. The + array is sorted ascendingly. When :samp:`{team}` is not provided the current team + is to be used. When :samp:`{kind}` is provided then the resulting array is of that + integer kind else it is of default integer kind. The returns an unallocated + size zero array when no images have failed. + + :param team: + optional; team on the which the inquiry is to be + performed. + + :param image: + optional; the kind of the resulting integer array. + + .. note:: + + This function follows TS18508. Because team-functionality is not yet + implemented a null-pointer is passed for the :samp:`{team}` argument at the moment. + +.. index:: Coarray, _gfortran_caf_stopped_images + +.. _gfortran_caf_stopped_images: + +_gfortran_caf_stopped_images --- Get an array of the indexes of the stopped images +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: int _gfortran_caf_stopped_images (caf_team_t * team, int * kind) + + Get an array of image indexes in the current :samp:`{team}` that have stopped. The + array is sorted ascendingly. When :samp:`{team}` is not provided the current team + is to be used. When :samp:`{kind}` is provided then the resulting array is of that + integer kind else it is of default integer kind. The returns an unallocated + size zero array when no images have failed. + + :param team: + optional; team on the which the inquiry is to be + performed. + + :param image: + optional; the kind of the resulting integer array. + + .. note:: + + This function follows TS18508. Because team-functionality is not yet + implemented a null-pointer is passed for the :samp:`{team}` argument at the moment. + +.. index:: Coarray, _gfortran_caf_register + +.. _gfortran_caf_register: + +_gfortran_caf_register --- Registering coarrays +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void caf_register (size_t size, caf_register_t type, caf_token_t *token, gfc_descriptor_t *desc, int *stat, char *errmsg, size_t errmsg_len) + + Registers memory for a coarray and creates a token to identify the coarray. The + routine is called for both coarrays with ``SAVE`` attribute and using an + explicit ``ALLOCATE`` statement. If an error occurs and :samp:`{STAT}` is a + ``NULL`` pointer, the function shall abort with printing an error message + and starting the error termination. If no error occurs and :samp:`{STAT}` is + present, it shall be set to zero. Otherwise, it shall be set to a positive + value and, if not- ``NULL``, :samp:`{ERRMSG}` shall be set to a string describing + the failure. The routine shall register the memory provided in the + ``DATA`` -component of the array descriptor :samp:`{DESC}`, when that component + is non- ``NULL``, else it shall allocate sufficient memory and provide a + pointer to it in the ``DATA`` -component of :samp:`{DESC}`. The array descriptor + has rank zero, when a scalar object is to be registered and the array + descriptor may be invalid after the call to ``_gfortran_caf_register``. + When an array is to be allocated the descriptor persists. + + :param size: + For normal coarrays, the byte size of the coarray to be + allocated; for lock types and event types, the number of elements. + + :param type: + one of the caf_register_t types. + + :param token: + intent(out) An opaque pointer identifying the coarray. + + :param desc: + intent(inout) The (pseudo) array descriptor. + + :param stat: + intent(out) For allocatable coarrays, stores the STAT=; + may be ``NULL`` + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be ``NULL`` + + :param errmsg_len: + the buffer size of errmsg. + + .. note:: + + Nonallocatable coarrays have to be registered prior use from remote images. + In order to guarantee this, they have to be registered before the main + program. This can be achieved by creating constructor functions. That is what + GCC does such that also for nonallocatable coarrays the memory is allocated and + no static memory is used. The token permits to identify the coarray; to the + processor, the token is a nonaliasing pointer. The library can, for instance, + store the base address of the coarray in the token, some handle or a more + complicated struct. The library may also store the array descriptor + :samp:`{DESC}` when its rank is non-zero. + + For lock types, the value shall only be used for checking the allocation + status. Note that for critical blocks, the locking is only required on one + image; in the locking statement, the processor shall always pass an + image index of one for critical-block lock variables + (``CAF_REGTYPE_CRITICAL``). For lock types and critical-block variables, + the initial value shall be unlocked (or, respectively, not in critical + section) such as the value false; for event types, the initial state should + be no event, e.g. zero. + +.. index:: Coarray, _gfortran_caf_deregister + +.. _gfortran_caf_deregister: + +_gfortran_caf_deregister --- Deregistering coarrays +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void caf_deregister (caf_token_t *token, caf_deregister_t type, int *stat, char *errmsg, size_t errmsg_len) + + Called to free or deregister the memory of a coarray; the processor calls this + function for automatic and explicit deallocation. In case of an error, this + function shall fail with an error message, unless the :samp:`{STAT}` variable is + not null. The library is only expected to free memory it allocated itself + during a call to ``_gfortran_caf_register``. + + :param token: + the token to free. + + :param type: + the type of action to take for the coarray. A + ``CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY`` is allowed only for allocatable or + pointer components of derived type coarrays. The action only deallocates the + local memory without deleting the token. + + :param stat: + intent(out) Stores the STAT=; may be NULL + + :param errmsg: + intent(out) When an error occurs, this will be set + to an error message; may be NULL + + :param errmsg_len: + the buffer size of errmsg. + + .. note:: + + For nonalloatable coarrays this function is never called. If a cleanup is + required, it has to be handled via the finish, stop and error stop functions, + and via destructors. + +.. index:: Coarray, _gfortran_caf_is_present + +.. _gfortran_caf_is_present: + +_gfortran_caf_is_present --- Query whether an allocatable or pointer component in a derived type coarray is allocated +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_is_present (caf_token_t token, int image_index, gfc_reference_t *ref) + + Used to query the coarray library whether an allocatable component in a derived + type coarray is allocated on a remote image. + + :param token: + An opaque pointer identifying the coarray. + + :param image_index: + The ID of the remote image; must be a positive + number. + + :param ref: + A chain of references to address the allocatable or + pointer component in the derived type coarray. The object reference needs to be + a scalar or a full array reference, respectively. + +.. index:: Coarray, _gfortran_caf_send + +.. _gfortran_caf_send: + +_gfortran_caf_send --- Sending data from a local image to a remote image +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_send (caf_token_t token, size_t offset, int image_index, gfc_descriptor_t *dest, caf_vector_t *dst_vector, gfc_descriptor_t *src, int dst_kind, int src_kind, bool may_require_tmp, int *stat) + + Called to send a scalar, an array section or a whole array from a local + to a remote image identified by the image_index. + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param offset: + intent(in) By which amount of bytes the actual data is + shifted compared to the base address of the coarray. + + :param image_index: + intent(in) The ID of the remote image; must be a + positive number. + + :param dest: + intent(in) Array descriptor for the remote image for the + bounds and the size. The ``base_addr`` shall not be accessed. + + :param dst_vector: + intent(in) If not NULL, it contains the vector + subscript of the destination array; the values are relative to the dimension + triplet of the dest argument. + + :param src: + intent(in) Array descriptor of the local array to be + transferred to the remote image + + :param dst_kind: + intent(in) Kind of the destination argument + + :param src_kind: + intent(in) Kind of the source argument + + :param may_require_tmp: + intent(in) The variable is ``false`` when + it is known at compile time that the :samp:`{dest}` and :samp:`{src}` either cannot + overlap or overlap (fully or partially) such that walking :samp:`{src}` and + :samp:`{dest}` in element wise element order (honoring the stride value) will not + lead to wrong results. Otherwise, the value is ``true``. + + :param stat: + intent(out) when non-NULL give the result of the + operation, i.e., zero on success and non-zero on error. When NULL and an error + occurs, then an error message is printed and the program is terminated. + + .. note:: + + It is permitted to have :samp:`{image_index}` equal the current image; the memory + of the send-to and the send-from might (partially) overlap in that case. The + implementation has to take care that it handles this case, e.g. using + ``memmove`` which handles (partially) overlapping memory. If + :samp:`{may_require_tmp}` is true, the library might additionally create a + temporary variable, unless additional checks show that this is not required + (e.g. because walking backward is possible or because both arrays are + contiguous and ``memmove`` takes care of overlap issues). + + Note that the assignment of a scalar to an array is permitted. In addition, + the library has to handle numeric-type conversion and for strings, padding + and different character kinds. + +.. index:: Coarray, _gfortran_caf_get + +.. _gfortran_caf_get: + +_gfortran_caf_get --- Getting data from a remote image +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_get (caf_token_t token, size_t offset, int image_index, gfc_descriptor_t *src, caf_vector_t *src_vector, gfc_descriptor_t *dest, int src_kind, int dst_kind, bool may_require_tmp, int *stat) + + Called to get an array section or a whole array from a remote, + image identified by the image_index. + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param offset: + intent(in) By which amount of bytes the actual data is + shifted compared to the base address of the coarray. + + :param image_index: + intent(in) The ID of the remote image; must be a + positive number. + + :param dest: + intent(out) Array descriptor of the local array to store + the data retrieved from the remote image + + :param src: + intent(in) Array descriptor for the remote image for the + bounds and the size. The ``base_addr`` shall not be accessed. + + :param src_vector: + intent(in) If not NULL, it contains the vector + subscript of the source array; the values are relative to the dimension + triplet of the :samp:`{src}` argument. + + :param dst_kind: + intent(in) Kind of the destination argument + + :param src_kind: + intent(in) Kind of the source argument + + :param may_require_tmp: + intent(in) The variable is ``false`` when + it is known at compile time that the :samp:`{dest}` and :samp:`{src}` either cannot + overlap or overlap (fully or partially) such that walking :samp:`{src}` and + :samp:`{dest}` in element wise element order (honoring the stride value) will not + lead to wrong results. Otherwise, the value is ``true``. + + :param stat: + intent(out) When non-NULL give the result of the + operation, i.e., zero on success and non-zero on error. When NULL and an error + occurs, then an error message is printed and the program is terminated. + + .. note:: + + It is permitted to have :samp:`{image_index}` equal the current image; the memory of + the send-to and the send-from might (partially) overlap in that case. The + implementation has to take care that it handles this case, e.g. using + ``memmove`` which handles (partially) overlapping memory. If + :samp:`{may_require_tmp}` is true, the library might additionally create a + temporary variable, unless additional checks show that this is not required + (e.g. because walking backward is possible or because both arrays are + contiguous and ``memmove`` takes care of overlap issues). + + Note that the library has to handle numeric-type conversion and for strings, + padding and different character kinds. + +.. index:: Coarray, _gfortran_caf_sendget + +.. _gfortran_caf_sendget: + +_gfortran_caf_sendget --- Sending data between remote images +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_sendget (caf_token_t dst_token, size_t dst_offset, int dst_image_index, gfc_descriptor_t *dest, caf_vector_t *dst_vector, caf_token_t src_token, size_t src_offset, int src_image_index, gfc_descriptor_t *src, caf_vector_t *src_vector, int dst_kind, int src_kind, bool may_require_tmp, int *stat) + + Called to send a scalar, an array section or a whole array from a remote image + identified by the :samp:`{src_image_index}` to a remote image identified by the + :samp:`{dst_image_index}`. + + :param dst_token: + intent(in) An opaque pointer identifying the + destination coarray. + + :param dst_offset: + intent(in) By which amount of bytes the actual data + is shifted compared to the base address of the destination coarray. + + :param dst_image_index: + intent(in) The ID of the destination remote + image; must be a positive number. + + :param dest: + intent(in) Array descriptor for the destination + remote image for the bounds and the size. The ``base_addr`` shall not be + accessed. + + :param dst_vector: + intent(int) If not NULL, it contains the vector + subscript of the destination array; the values are relative to the dimension + triplet of the :samp:`{dest}` argument. + + :param src_token: + intent(in) An opaque pointer identifying the source + coarray. + + :param src_offset: + intent(in) By which amount of bytes the actual data + is shifted compared to the base address of the source coarray. + + :param src_image_index: + intent(in) The ID of the source remote image; + must be a positive number. + + :param src: + intent(in) Array descriptor of the local array to be + transferred to the remote image. + + :param src_vector: + intent(in) Array descriptor of the local array to + be transferred to the remote image + + :param dst_kind: + intent(in) Kind of the destination argument + + :param src_kind: + intent(in) Kind of the source argument + + :param may_require_tmp: + intent(in) The variable is ``false`` when + it is known at compile time that the :samp:`{dest}` and :samp:`{src}` either cannot + overlap or overlap (fully or partially) such that walking :samp:`{src}` and + :samp:`{dest}` in element wise element order (honoring the stride value) will not + lead to wrong results. Otherwise, the value is ``true``. + + :param stat: + intent(out) when non-NULL give the result of the + operation, i.e., zero on success and non-zero on error. When NULL and an error + occurs, then an error message is printed and the program is terminated. + + .. note:: + + It is permitted to have the same image index for both :samp:`{src_image_index}` and + :samp:`{dst_image_index}` ; the memory of the send-to and the send-from might + (partially) overlap in that case. The implementation has to take care that it + handles this case, e.g. using ``memmove`` which handles (partially) + overlapping memory. If :samp:`{may_require_tmp}` is true, the library + might additionally create a temporary variable, unless additional checks show + that this is not required (e.g. because walking backward is possible or because + both arrays are contiguous and ``memmove`` takes care of overlap issues). + + Note that the assignment of a scalar to an array is permitted. In addition, + the library has to handle numeric-type conversion and for strings, padding and + different character kinds. + +.. index:: Coarray, _gfortran_caf_send_by_ref + +.. _gfortran_caf_send_by_ref: + +_gfortran_caf_send_by_ref --- Sending data from a local image to a remote image with enhanced referencing options +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_send_by_ref (caf_token_t token, int image_index, gfc_descriptor_t *src, caf_reference_t *refs, int dst_kind, int src_kind, bool may_require_tmp, bool dst_reallocatable, int *stat, int dst_type) + + Called to send a scalar, an array section or a whole array from a local to a + remote image identified by the :samp:`{image_index}`. + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param image_index: + intent(in) The ID of the remote image; must be a + positive number. + + :param src: + intent(in) Array descriptor of the local array to be + transferred to the remote image + + :param refs: + intent(in) The references on the remote array to store + the data given by src. Guaranteed to have at least one entry. + + :param dst_kind: + intent(in) Kind of the destination argument + + :param src_kind: + intent(in) Kind of the source argument + + :param may_require_tmp: + intent(in) The variable is ``false`` when + it is known at compile time that the :samp:`{dest}` and :samp:`{src}` either cannot + overlap or overlap (fully or partially) such that walking :samp:`{src}` and + :samp:`{dest}` in element wise element order (honoring the stride value) will not + lead to wrong results. Otherwise, the value is ``true``. + + :param dst_reallocatable: + intent(in) Set when the destination is of + allocatable or pointer type and the refs will allow reallocation, i.e., the ref + is a full array or component ref. + + :param stat: + intent(out) When non- ``NULL`` give the result of the + operation, i.e., zero on success and non-zero on error. When ``NULL`` and + an error occurs, then an error message is printed and the program is terminated. + + :param dst_type: + intent(in) Give the type of the destination. When + the destination is not an array, than the precise type, e.g. of a component in + a derived type, is not known, but provided here. + + .. note:: + + It is permitted to have :samp:`{image_index}` equal the current image; the memory of + the send-to and the send-from might (partially) overlap in that case. The + implementation has to take care that it handles this case, e.g. using + ``memmove`` which handles (partially) overlapping memory. If + :samp:`{may_require_tmp}` is true, the library might additionally create a + temporary variable, unless additional checks show that this is not required + (e.g. because walking backward is possible or because both arrays are + contiguous and ``memmove`` takes care of overlap issues). + + Note that the assignment of a scalar to an array is permitted. In addition, + the library has to handle numeric-type conversion and for strings, padding + and different character kinds. + + Because of the more complicated references possible some operations may be + unsupported by certain libraries. The library is expected to issue a precise + error message why the operation is not permitted. + +.. index:: Coarray, _gfortran_caf_get_by_ref + +.. _gfortran_caf_get_by_ref: + +_gfortran_caf_get_by_ref --- Getting data from a remote image using enhanced references +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_get_by_ref (caf_token_t token, int image_index, caf_reference_t *refs, gfc_descriptor_t *dst, int dst_kind, int src_kind, bool may_require_tmp, bool dst_reallocatable, int *stat, int src_type) + + Called to get a scalar, an array section or a whole array from a remote image + identified by the :samp:`{image_index}`. + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param image_index: + intent(in) The ID of the remote image; must be a + positive number. + + :param refs: + intent(in) The references to apply to the remote structure + to get the data. + + :param dst: + intent(in) Array descriptor of the local array to store + the data transferred from the remote image. May be reallocated where needed + and when :samp:`{DST_REALLOCATABLE}` allows it. + + :param dst_kind: + intent(in) Kind of the destination argument + + :param src_kind: + intent(in) Kind of the source argument + + :param may_require_tmp: + intent(in) The variable is ``false`` when + it is known at compile time that the :samp:`{dest}` and :samp:`{src}` either cannot + overlap or overlap (fully or partially) such that walking :samp:`{src}` and + :samp:`{dest}` in element wise element order (honoring the stride value) will not + lead to wrong results. Otherwise, the value is ``true``. + + :param dst_reallocatable: + intent(in) Set when :samp:`{DST}` is of + allocatable or pointer type and its refs allow reallocation, i.e., the full + array or a component is referenced. + + :param stat: + intent(out) When non- ``NULL`` give the result of the + operation, i.e., zero on success and non-zero on error. When ``NULL`` and an + error occurs, then an error message is printed and the program is terminated. + + :param src_type: + intent(in) Give the type of the source. When the + source is not an array, than the precise type, e.g. of a component in a + derived type, is not known, but provided here. + + .. note:: + + It is permitted to have ``image_index`` equal the current image; the memory + of the send-to and the send-from might (partially) overlap in that case. The + implementation has to take care that it handles this case, e.g. using + ``memmove`` which handles (partially) overlapping memory. If + :samp:`{may_require_tmp}` is true, the library might additionally create a + temporary variable, unless additional checks show that this is not required + (e.g. because walking backward is possible or because both arrays are + contiguous and ``memmove`` takes care of overlap issues). + + Note that the library has to handle numeric-type conversion and for strings, + padding and different character kinds. + + Because of the more complicated references possible some operations may be + unsupported by certain libraries. The library is expected to issue a precise + error message why the operation is not permitted. + +.. index:: Coarray, _gfortran_caf_sendget_by_ref + +.. _gfortran_caf_sendget_by_ref: + +_gfortran_caf_sendget_by_ref --- Sending data between remote images using enhanced references on both sides +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_sendget_by_ref (caf_token_t dst_token, int dst_image_index, caf_reference_t *dst_refs, caf_token_t src_token, int src_image_index, caf_reference_t *src_refs, int dst_kind, int src_kind, bool may_require_tmp, int *dst_stat, int *src_stat, int dst_type, int src_type) + + Called to send a scalar, an array section or a whole array from a remote image + identified by the :samp:`{src_image_index}` to a remote image identified by the + :samp:`{dst_image_index}`. + + :param dst_token: + intent(in) An opaque pointer identifying the + destination coarray. + + :param dst_image_index: + intent(in) The ID of the destination remote + image; must be a positive number. + + :param dst_refs: + intent(in) The references on the remote array to store + the data given by the source. Guaranteed to have at least one entry. + + :param src_token: + intent(in) An opaque pointer identifying the source + coarray. + + :param src_image_index: + intent(in) The ID of the source remote image; + must be a positive number. + + :param src_refs: + intent(in) The references to apply to the remote + structure to get the data. + + :param dst_kind: + intent(in) Kind of the destination argument + + :param src_kind: + intent(in) Kind of the source argument + + :param may_require_tmp: + intent(in) The variable is ``false`` when + it is known at compile time that the :samp:`{dest}` and :samp:`{src}` either cannot + overlap or overlap (fully or partially) such that walking :samp:`{src}` and + :samp:`{dest}` in element wise element order (honoring the stride value) will not + lead to wrong results. Otherwise, the value is ``true``. + + :param dst_stat: + intent(out) when non- ``NULL`` give the result of + the send-operation, i.e., zero on success and non-zero on error. When + ``NULL`` and an error occurs, then an error message is printed and the + program is terminated. + + :param src_stat: + intent(out) When non- ``NULL`` give the result of + the get-operation, i.e., zero on success and non-zero on error. When + ``NULL`` and an error occurs, then an error message is printed and the + program is terminated. + + :param dst_type: + intent(in) Give the type of the destination. When + the destination is not an array, than the precise type, e.g. of a component in + a derived type, is not known, but provided here. + + :param src_type: + intent(in) Give the type of the source. When the + source is not an array, than the precise type, e.g. of a component in a + derived type, is not known, but provided here. + + .. note:: + + It is permitted to have the same image index for both :samp:`{src_image_index}` and + :samp:`{dst_image_index}` ; the memory of the send-to and the send-from might + (partially) overlap in that case. The implementation has to take care that it + handles this case, e.g. using ``memmove`` which handles (partially) + overlapping memory. If :samp:`{may_require_tmp}` is true, the library + might additionally create a temporary variable, unless additional checks show + that this is not required (e.g. because walking backward is possible or because + both arrays are contiguous and ``memmove`` takes care of overlap issues). + + Note that the assignment of a scalar to an array is permitted. In addition, + the library has to handle numeric-type conversion and for strings, padding and + different character kinds. + + Because of the more complicated references possible some operations may be + unsupported by certain libraries. The library is expected to issue a precise + error message why the operation is not permitted. + +.. index:: Coarray, _gfortran_caf_lock + +.. _gfortran_caf_lock: + +_gfortran_caf_lock --- Locking a lock variable +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_lock (caf_token_t token, size_t index, int image_index, int *acquired_lock, int *stat, char *errmsg, size_t errmsg_len) + + Acquire a lock on the given image on a scalar locking variable or for the + given array element for an array-valued variable. If the :samp:`{acquired_lock}` + is ``NULL``, the function returns after having obtained the lock. If it is + non- ``NULL``, then :samp:`{acquired_lock}` is assigned the value true (one) when + the lock could be obtained and false (zero) otherwise. Locking a lock variable + which has already been locked by the same image is an error. + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param index: + intent(in) Array index; first array index is 0. For + scalars, it is always 0. + + :param image_index: + intent(in) The ID of the remote image; must be a + positive number. + + :param acquired_lock: + intent(out) If not NULL, it returns whether lock + could be obtained. + + :param stat: + intent(out) Stores the STAT=; may be NULL. + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be NULL. + + :param errmsg_len: + intent(in) the buffer size of errmsg + + .. note:: + + This function is also called for critical blocks; for those, the array index + is always zero and the image index is one. Libraries are permitted to use other + images for critical-block locking variables. + +.. index:: Coarray, _gfortran_caf_unlock + +.. _gfortran_caf_unlock: + +_gfortran_caf_lock --- Unlocking a lock variable +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_unlock (caf_token_t token, size_t index, int image_index, int *stat, char *errmsg, size_t errmsg_len) + + Release a lock on the given image on a scalar locking variable or for the + given array element for an array-valued variable. Unlocking a lock variable + which is unlocked or has been locked by a different image is an error. + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param index: + intent(in) Array index; first array index is 0. For + scalars, it is always 0. + + :param image_index: + intent(in) The ID of the remote image; must be a + positive number. + + :param stat: + intent(out) For allocatable coarrays, stores the STAT=; + may be NULL. + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be NULL. + + :param errmsg_len: + intent(in) the buffer size of errmsg + + .. note:: + + This function is also called for critical block; for those, the array index + is always zero and the image index is one. Libraries are permitted to use other + images for critical-block locking variables. + +.. index:: Coarray, _gfortran_caf_event_post + +.. _gfortran_caf_event_post: + +_gfortran_caf_event_post --- Post an event +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_event_post (caf_token_t token, size_t index, int image_index, int *stat, char *errmsg, size_t errmsg_len) + + Increment the event count of the specified event variable. + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param index: + intent(in) Array index; first array index is 0. For + scalars, it is always 0. + + :param image_index: + intent(in) The ID of the remote image; must be a + positive number; zero indicates the current image, when accessed noncoindexed. + + :param stat: + intent(out) Stores the STAT=; may be NULL. + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be NULL. + + :param errmsg_len: + intent(in) the buffer size of errmsg + + .. note:: + + This acts like an atomic add of one to the remote image's event variable. + The statement is an image-control statement but does not imply sync memory. + Still, all preceeding push communications of this image to the specified + remote image have to be completed before ``event_wait`` on the remote + image returns. + +.. index:: Coarray, _gfortran_caf_event_wait + +.. _gfortran_caf_event_wait: + +_gfortran_caf_event_wait --- Wait that an event occurred +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_event_wait (caf_token_t token, size_t index, int until_count, int *stat, char *errmsg, size_t errmsg_len) + + Wait until the event count has reached at least the specified + :samp:`{until_count}` ; if so, atomically decrement the event variable by this + amount and return. + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param index: + intent(in) Array index; first array index is 0. For + scalars, it is always 0. + + :param until_count: + intent(in) The number of events which have to be + available before the function returns. + + :param stat: + intent(out) Stores the STAT=; may be NULL. + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be NULL. + + :param errmsg_len: + intent(in) the buffer size of errmsg + + .. note:: + + This function only operates on a local coarray. It acts like a loop checking + atomically the value of the event variable, breaking if the value is greater + or equal the requested number of counts. Before the function returns, the + event variable has to be decremented by the requested :samp:`{until_count}` value. + A possible implementation would be a busy loop for a certain number of spins + (possibly depending on the number of threads relative to the number of available + cores) followed by another waiting strategy such as a sleeping wait (possibly + with an increasing number of sleep time) or, if possible, a futex wait. + + The statement is an image-control statement but does not imply sync memory. + Still, all preceeding push communications of this image to the specified + remote image have to be completed before ``event_wait`` on the remote + image returns. + +.. index:: Coarray, _gfortran_caf_event_query + +.. _gfortran_caf_event_query: + +_gfortran_caf_event_query --- Query event count +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_event_query (caf_token_t token, size_t index, int image_index, int *count, int *stat) + + Return the event count of the specified event variable. + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param index: + intent(in) Array index; first array index is 0. For + scalars, it is always 0. + + :param image_index: + intent(in) The ID of the remote image; must be a + positive number; zero indicates the current image when accessed noncoindexed. + + :param count: + intent(out) The number of events currently posted to + the event variable. + + :param stat: + intent(out) Stores the STAT=; may be NULL. + + .. note:: + + The typical use is to check the local event variable to only call + ``event_wait`` when the data is available. However, a coindexed variable + is permitted; there is no ordering or synchronization implied. It acts like + an atomic fetch of the value of the event variable. + +.. index:: Coarray, _gfortran_caf_sync_all + +.. _gfortran_caf_sync_all: + +_gfortran_caf_sync_all --- All-image barrier +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_sync_all (int *stat, char *errmsg, size_t errmsg_len) + + Synchronization of all images in the current team; the program only continues + on a given image after this function has been called on all images of the + current team. Additionally, it ensures that all pending data transfers of + previous segment have completed. + + :param stat: + intent(out) Stores the status STAT= and may be NULL. + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be NULL. + + :param errmsg_len: + intent(in) the buffer size of errmsg + +.. index:: Coarray, _gfortran_caf_sync_images + +.. _gfortran_caf_sync_images: + +_gfortran_caf_sync_images --- Barrier for selected images +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg, size_t errmsg_len) + + Synchronization between the specified images; the program only continues on a + given image after this function has been called on all images specified for + that image. Note that one image can wait for all other images in the current + team (e.g. via ``sync images(*)``) while those only wait for that specific + image. Additionally, ``sync images`` ensures that all pending data + transfers of previous segments have completed. + + :param count: + intent(in) The number of images which are provided in + the next argument. For a zero-sized array, the value is zero. For + ``sync images (*)``, the value is -1. + + :param images: + intent(in) An array with the images provided by the + user. If :samp:`{count}` is zero, a NULL pointer is passed. + + :param stat: + intent(out) Stores the status STAT= and may be NULL. + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be NULL. + + :param errmsg_len: + intent(in) the buffer size of errmsg + +.. index:: Coarray, _gfortran_caf_sync_memory + +.. _gfortran_caf_sync_memory: + +_gfortran_caf_sync_memory --- Wait for completion of segment-memory operations +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_sync_memory (int *stat, char *errmsg, size_t errmsg_len) + + Acts as optimization barrier between different segments. It also ensures that + all pending memory operations of this image have been completed. + + :param stat: + intent(out) Stores the status STAT= and may be NULL. + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be NULL. + + :param errmsg_len: + intent(in) the buffer size of errmsg + + .. note:: + + A simple implementation could be + ``__asm__ __volatile__ ("":::"memory")`` to prevent code movements. + +.. index:: Coarray, _gfortran_caf_error_stop + +.. _gfortran_caf_error_stop: + +_gfortran_caf_error_stop --- Error termination with exit code +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_error_stop (int error) + + Invoked for an ``ERROR STOP`` statement which has an integer argument. The + function should terminate the program with the specified exit code. + + :param error: + intent(in) The exit status to be used. + +.. index:: Coarray, _gfortran_caf_error_stop_str + +.. _gfortran_caf_error_stop_str: + +_gfortran_caf_error_stop_str --- Error termination with string +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_error_stop (const char *string, size_t len) + + Invoked for an ``ERROR STOP`` statement which has a string as argument. The + function should terminate the program with a nonzero-exit code. + + :param string: + intent(in) the error message (not zero terminated) + + :param len: + intent(in) the length of the string + +.. index:: Coarray, _gfortran_caf_fail_image + +.. _gfortran_caf_fail_image: + +_gfortran_caf_fail_image --- Mark the image failed and end its execution +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_fail_image () + + Invoked for an ``FAIL IMAGE`` statement. The function should terminate the + current image. + + .. note:: + + This function follows TS18508. + +.. index:: Coarray, _gfortran_caf_atomic_define + +.. _gfortran_caf_atomic_define: + +_gfortran_caf_atomic_define --- Atomic variable assignment +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_atomic_define (caf_token_t token, size_t offset, int image_index, void *value, int *stat, int type, int kind) + + Assign atomically a value to an integer or logical variable. + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param offset: + intent(in) By which amount of bytes the actual data is + shifted compared to the base address of the coarray. + + :param image_index: + intent(in) The ID of the remote image; must be a + positive number; zero indicates the current image when used noncoindexed. + + :param value: + intent(in) the value to be assigned, passed by reference + + :param stat: + intent(out) Stores the status STAT= and may be NULL. + + :param type: + intent(in) The data type, i.e. ``BT_INTEGER`` (1) or + ``BT_LOGICAL`` (2). + + :param kind: + intent(in) The kind value (only 4; always ``int``) + +.. index:: Coarray, _gfortran_caf_atomic_ref + +.. _gfortran_caf_atomic_ref: + +_gfortran_caf_atomic_ref --- Atomic variable reference +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_atomic_ref (caf_token_t token, size_t offset, int image_index, void *value, int *stat, int type, int kind) + + Reference atomically a value of a kind-4 integer or logical variable. + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param offset: + intent(in) By which amount of bytes the actual data is + shifted compared to the base address of the coarray. + + :param image_index: + intent(in) The ID of the remote image; must be a + positive number; zero indicates the current image when used noncoindexed. + + :param value: + intent(out) The variable assigned the atomically + referenced variable. + + :param stat: + intent(out) Stores the status STAT= and may be NULL. + + :param type: + the data type, i.e. ``BT_INTEGER`` (1) or + ``BT_LOGICAL`` (2). + + :param kind: + The kind value (only 4; always ``int``) + +.. index:: Coarray, _gfortran_caf_atomic_cas + +.. _gfortran_caf_atomic_cas: + +_gfortran_caf_atomic_cas --- Atomic compare and swap +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_atomic_cas (caf_token_t token, size_t offset, int image_index, void *old, void *compare, void *new_val, int *stat, int type, int kind) + + Atomic compare and swap of a kind-4 integer or logical variable. Assigns + atomically the specified value to the atomic variable, if the latter has + the value specified by the passed condition value. + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param offset: + intent(in) By which amount of bytes the actual data is + shifted compared to the base address of the coarray. + + :param image_index: + intent(in) The ID of the remote image; must be a + positive number; zero indicates the current image when used noncoindexed. + + :param old: + intent(out) The value which the atomic variable had + just before the cas operation. + + :param compare: + intent(in) The value used for comparision. + + :param new_val: + intent(in) The new value for the atomic variable, + assigned to the atomic variable, if ``compare`` equals the value of the + atomic variable. + + :param stat: + intent(out) Stores the status STAT= and may be NULL. + + :param type: + intent(in) the data type, i.e. ``BT_INTEGER`` (1) or + ``BT_LOGICAL`` (2). + + :param kind: + intent(in) The kind value (only 4; always ``int``) + +.. index:: Coarray, _gfortran_caf_atomic_op + +.. _gfortran_caf_atomic_op: + +_gfortran_caf_atomic_op --- Atomic operation +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_atomic_op (int op, caf_token_t token, size_t offset, int image_index, void *value, void *old, int *stat, int type, int kind) + + Apply an operation atomically to an atomic integer or logical variable. + After the operation, :samp:`{old}` contains the value just before the operation, + which, respectively, adds (GFC_CAF_ATOMIC_ADD) atomically the ``value`` to + the atomic integer variable or does a bitwise AND, OR or exclusive OR + between the atomic variable and :samp:`{value}` ; the result is then stored in the + atomic variable. + + :param op: + intent(in) the operation to be performed; possible values + ``GFC_CAF_ATOMIC_ADD`` (1), ``GFC_CAF_ATOMIC_AND`` (2), + ``GFC_CAF_ATOMIC_OR`` (3), ``GFC_CAF_ATOMIC_XOR`` (4). + + :param token: + intent(in) An opaque pointer identifying the coarray. + + :param offset: + intent(in) By which amount of bytes the actual data is + shifted compared to the base address of the coarray. + + :param image_index: + intent(in) The ID of the remote image; must be a + positive number; zero indicates the current image when used noncoindexed. + + :param old: + intent(out) The value which the atomic variable had + just before the atomic operation. + + :param val: + intent(in) The new value for the atomic variable, + assigned to the atomic variable, if ``compare`` equals the value of the + atomic variable. + + :param stat: + intent(out) Stores the status STAT= and may be NULL. + + :param type: + intent(in) the data type, i.e. ``BT_INTEGER`` (1) or + ``BT_LOGICAL`` (2) + + :param kind: + intent(in) the kind value (only 4; always ``int``) + +.. index:: Coarray, _gfortran_caf_co_broadcast + +.. _gfortran_caf_co_broadcast: + +_gfortran_caf_co_broadcast --- Sending data to all images +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_co_broadcast (gfc_descriptor_t *a, int source_image, int *stat, char *errmsg, size_t errmsg_len) + + Distribute a value from a given image to all other images in the team. Has to + be called collectively. + + :param a: + intent(inout) An array descriptor with the data to be + broadcasted (on :samp:`{source_image}`) or to be received (other images). + + :param source_image: + intent(in) The ID of the image from which the + data should be broadcasted. + + :param stat: + intent(out) Stores the status STAT= and may be NULL. + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be NULL. + + :param errmsg_len: + intent(in) the buffer size of errmsg. + +.. index:: Coarray, _gfortran_caf_co_max + +.. _gfortran_caf_co_max: + +_gfortran_caf_co_max --- Collective maximum reduction +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_co_max (gfc_descriptor_t *a, int result_image, int *stat, char *errmsg, int a_len, size_t errmsg_len) + + Calculates for each array element of the variable :samp:`{a}` the maximum + value for that element in the current team; if :samp:`{result_image}` has the + value 0, the result shall be stored on all images, otherwise, only on the + specified image. This function operates on numeric values and character + strings. + + :param a: + intent(inout) An array descriptor for the data to be + processed. On the destination image(s) the result overwrites the old content. + + :param result_image: + intent(in) The ID of the image to which the + reduced value should be copied to; if zero, it has to be copied to all images. + + :param stat: + intent(out) Stores the status STAT= and may be NULL. + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be NULL. + + :param a_len: + intent(in) the string length of argument :samp:`{a}` + + :param errmsg_len: + intent(in) the buffer size of errmsg + + .. note:: + + If :samp:`{result_image}` is nonzero, the data in the array descriptor :samp:`{a}` on + all images except of the specified one become undefined; hence, the library may + make use of this. + +.. index:: Coarray, _gfortran_caf_co_min + +.. _gfortran_caf_co_min: + +_gfortran_caf_co_min --- Collective minimum reduction +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_co_min (gfc_descriptor_t *a, int result_image, int *stat, char *errmsg, int a_len, size_t errmsg_len) + + Calculates for each array element of the variable :samp:`{a}` the minimum + value for that element in the current team; if :samp:`{result_image}` has the + value 0, the result shall be stored on all images, otherwise, only on the + specified image. This function operates on numeric values and character + strings. + + :param a: + intent(inout) An array descriptor for the data to be + processed. On the destination image(s) the result overwrites the old content. + + :param result_image: + intent(in) The ID of the image to which the + reduced value should be copied to; if zero, it has to be copied to all images. + + :param stat: + intent(out) Stores the status STAT= and may be NULL. + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be NULL. + + :param a_len: + intent(in) the string length of argument :samp:`{a}` + + :param errmsg_len: + intent(in) the buffer size of errmsg + + .. note:: + + If :samp:`{result_image}` is nonzero, the data in the array descriptor :samp:`{a}` on + all images except of the specified one become undefined; hence, the library may + make use of this. + +.. index:: Coarray, _gfortran_caf_co_sum + +.. _gfortran_caf_co_sum: + +_gfortran_caf_co_sum --- Collective summing reduction +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_co_sum (gfc_descriptor_t *a, int result_image, int *stat, char *errmsg, size_t errmsg_len) + + Calculates for each array element of the variable :samp:`{a}` the sum of all + values for that element in the current team; if :samp:`{result_image}` has the + value 0, the result shall be stored on all images, otherwise, only on the + specified image. This function operates on numeric values only. + + :param a: + intent(inout) An array descriptor with the data to be + processed. On the destination image(s) the result overwrites the old content. + + :param result_image: + intent(in) The ID of the image to which the + reduced value should be copied to; if zero, it has to be copied to all images. + + :param stat: + intent(out) Stores the status STAT= and may be NULL. + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be NULL. + + :param errmsg_len: + intent(in) the buffer size of errmsg + + .. note:: + + If :samp:`{result_image}` is nonzero, the data in the array descriptor :samp:`{a}` on + all images except of the specified one become undefined; hence, the library may + make use of this. + +.. index:: Coarray, _gfortran_caf_co_reduce + +.. _gfortran_caf_co_reduce: + +_gfortran_caf_co_reduce --- Generic collective reduction +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_caf_co_reduce (gfc_descriptor_t *a, void * (*opr) (void *, void *), int opr_flags, int result_image, int *stat, char *errmsg, int a_len, size_t errmsg_len) + + Calculates for each array element of the variable :samp:`{a}` the reduction + value for that element in the current team; if :samp:`{result_image}` has the + value 0, the result shall be stored on all images, otherwise, only on the + specified image. The :samp:`{opr}` is a pure function doing a mathematically + commutative and associative operation. + + :param a: + intent(inout) An array descriptor with the data to be + processed. On the destination image(s) the result overwrites the old content. + + :param opr: + intent(in) Function pointer to the reduction function + + :param opr_flags: + intent(in) Flags regarding the reduction function + + :param result_image: + intent(in) The ID of the image to which the + reduced value should be copied to; if zero, it has to be copied to all images. + + :param stat: + intent(out) Stores the status STAT= and may be NULL. + + :param errmsg: + intent(out) When an error occurs, this will be set to + an error message; may be NULL. + + :param a_len: + intent(in) the string length of argument :samp:`{a}` + + :param errmsg_len: + intent(in) the buffer size of errmsg + + .. note:: + + If :samp:`{result_image}` is nonzero, the data in the array descriptor :samp:`{a}` on + all images except of the specified one become undefined; hence, the library may + make use of this. + + For character arguments, the result is passed as first argument, followed + by the result string length, next come the two string arguments, followed + by the two hidden string length arguments. With C binding, there are no hidden + arguments and by-reference passing and either only a single character is passed + or an array descriptor. + +.. Intrinsic Procedures + - + +Some basic guidelines for editing this document: + +(1) The intrinsic procedures are to be listed in alphabetical order. +(2) The generic name is to be used. +(3) The specific names are included in the function index and in a + table at the end of the node (See ABS entry). +(4) Try to maintain the same style for each entry. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/funding.rst b/gcc/fortran/doc/gfortran/funding.rst new file mode 100644 index 00000000000..2d76ad902d7 --- /dev/null +++ b/gcc/fortran/doc/gfortran/funding.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../../doc/funding.rst \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/general-public-license-3.rst b/gcc/fortran/doc/gfortran/general-public-license-3.rst new file mode 100644 index 00000000000..cfca1c3d6b8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/general-public-license-3.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../../doc/gpl-3.0.rst \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-and-gcc.rst b/gcc/fortran/doc/gfortran/gnu-fortran-and-gcc.rst new file mode 100644 index 00000000000..2ec86fbc4da --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-and-gcc.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GNU Compiler Collection, GCC + +.. _gnu-fortran-and-gcc: + +GNU Fortran and GCC +******************* + +GNU Fortran is a part of GCC, the :dfn:`GNU Compiler Collection`. GCC +consists of a collection of front ends for various languages, which +translate the source code into a language-independent form called +:dfn:`GENERIC`. This is then processed by a common middle end which +provides optimization, and then passed to one of a collection of back +ends which generate code for different computer architectures and +operating systems. + +Functionally, this is implemented with a driver program (:command:`gcc`) +which provides the command-line interface for the compiler. It calls +the relevant compiler front-end program (e.g., :command:`f951` for +Fortran) for each file in the source code, and then calls the assembler +and linker as appropriate to produce the compiled output. In a copy of +GCC that has been compiled with Fortran language support enabled, +:command:`gcc` recognizes files with :samp:`.f`, :samp:`.for`, :samp:`.ftn`, +:samp:`.f90`, :samp:`.f95`, :samp:`.f03` and :samp:`.f08` extensions as +Fortran source code, and compiles it accordingly. A :command:`gfortran` +driver program is also provided, which is identical to :command:`gcc` +except that it automatically links the Fortran runtime libraries into the +compiled program. + +Source files with :samp:`.f`, :samp:`.for`, :samp:`.fpp`, :samp:`.ftn`, :samp:`.F`, +:samp:`.FOR`, :samp:`.FPP`, and :samp:`.FTN` extensions are treated as fixed form. +Source files with :samp:`.f90`, :samp:`.f95`, :samp:`.f03`, :samp:`.f08`, +:samp:`.F90`, :samp:`.F95`, :samp:`.F03` and :samp:`.F08` extensions are +treated as free form. The capitalized versions of either form are run +through preprocessing. Source files with the lower case :samp:`.fpp` +extension are also run through preprocessing. + +This manual specifically documents the Fortran front end, which handles +the programming language's syntax and semantics. The aspects of GCC +which relate to the optimization passes and the back-end code generation +that relate to the optimization passes and the back-end code generation +are documented in the GCC manual; see :ref:`gcc:top`. +The two manuals together provide a complete reference for the GNU +Fortran compiler. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options.rst new file mode 100644 index 00000000000..880b34c04d2 --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GNU Fortran command options, command options, options, gfortran command + +GNU Fortran Command Options +--------------------------- + +.. _invoking-gnu-fortran: + +.. toctree:: + :maxdepth: 2 + + gnu-fortran-command-options/description + gnu-fortran-command-options/option-summary + gnu-fortran-command-options/options-controlling-fortran-dialect + gnu-fortran-command-options/enable-and-customize-preprocessing + gnu-fortran-command-options/options-to-request-or-suppress-errors-and-warnings + gnu-fortran-command-options/options-for-debugging-your-program-or-gnu-fortran + gnu-fortran-command-options/options-for-directory-search + gnu-fortran-command-options/influencing-the-linking-step + gnu-fortran-command-options/influencing-runtime-behavior + gnu-fortran-command-options/options-for-code-generation-conventions + gnu-fortran-command-options/options-for-interoperability-with-other-languages + gnu-fortran-command-options/environment-variables-affecting-gfortran + +.. only:: man + + .. toctree:: + + copyright \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options/description.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/description.rst new file mode 100644 index 00000000000..c0f0594f42c --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/description.rst @@ -0,0 +1,39 @@ +.. only:: man + + Synopsis + ^^^^^^^^ + + gfortran [ :option:`-c` | :option:`-S` | :option:`-E` ] + [ :option:`-g` ] [ :option:`-pg` ] [ :option:`-O`:samp:`{level}` ] + [ :option:`-W`:samp:`{warn}`...] [ :option:`-pedantic` ] + [ :option:`-I`:samp:`{dir}`...] [ :option:`-L`:samp:`{dir}`...] + [ :option:`-D`:samp:`{macro}` [= :samp:`{defn}` ]...] [ :option:`-U`:samp:`{macro}` ] + [ :option:`-f`:samp:`{option}`...] + [ :option:`-m`:samp:`{machine-option}`...] + [ :option:`-o` :samp:`{outfile}` ] :samp:`{infile}`... + +Description +^^^^^^^^^^^ + +The :command:`gfortran` command supports all the options supported by the +:command:`gcc` command. Only options specific to GNU Fortran are documented +here. + +See :ref:`gcc:invoking-gcc`, for information +on the non-Fortran-specific aspects of the :command:`gcc` command (and, +therefore, the :command:`gfortran` command). + +.. index:: options, negative forms + +All GCC and GNU Fortran options +are accepted both by :command:`gfortran` and by :command:`gcc` +(as well as any other drivers built at the same time, +such as :command:`g++`), +since adding GNU Fortran to the GCC distribution +enables acceptance of GNU Fortran options +by all of the relevant drivers. + +In some cases, options have positive and negative forms; +the negative form of :samp:`-ffoo` would be :samp:`-fno-foo`. +This manual documents only one of these two forms, whichever +one is not the default. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options/enable-and-customize-preprocessing.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/enable-and-customize-preprocessing.rst new file mode 100644 index 00000000000..0db92c669a4 --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/enable-and-customize-preprocessing.rst @@ -0,0 +1,298 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: preprocessor, options, preprocessor, CPP, FPP, Conditional compilation, Preprocessing, preprocessor, include file handling + +.. _preprocessing-options: + +Enable and customize preprocessing +********************************** + +Many Fortran compilers including GNU Fortran allow passing the source code +through a C preprocessor (CPP; sometimes also called the Fortran preprocessor, +FPP) to allow for conditional compilation. In the case of GNU Fortran, +this is the GNU C Preprocessor in the traditional mode. On systems with +case-preserving file names, the preprocessor is automatically invoked if the +filename extension is :samp:`.F`, :samp:`.FOR`, :samp:`.FTN`, :samp:`.fpp`, +:samp:`.FPP`, :samp:`.F90`, :samp:`.F95`, :samp:`.F03` or :samp:`.F08`. To manually +invoke the preprocessor on any file, use :option:`-cpp`, to disable +preprocessing on files where the preprocessor is run automatically, use +:option:`-nocpp`. + +If a preprocessed file includes another file with the Fortran ``INCLUDE`` +statement, the included file is not preprocessed. To preprocess included +files, use the equivalent preprocessor statement ``#include``. + +If GNU Fortran invokes the preprocessor, ``__GFORTRAN__`` +is defined. The macros ``__GNUC__``, ``__GNUC_MINOR__`` and +``__GNUC_PATCHLEVEL__`` can be used to determine the version of the +compiler. See :ref:`cpp:top` for details. + +GNU Fortran supports a number of ``INTEGER`` and ``REAL`` kind types +in additional to the kind types required by the Fortran standard. +The availability of any given kind type is architecture dependent. The +following pre-defined preprocessor macros can be used to conditionally +include code for these additional kind types: ``__GFC_INT_1__``, +``__GFC_INT_2__``, ``__GFC_INT_8__``, ``__GFC_INT_16__``, +``__GFC_REAL_10__``, and ``__GFC_REAL_16__``. + +While CPP is the de-facto standard for preprocessing Fortran code, +Part 3 of the Fortran 95 standard (ISO/IEC 1539-3:1998) defines +Conditional Compilation, which is not widely used and not directly +supported by the GNU Fortran compiler. You can use the program coco +to preprocess such files (http://www.daniellnagle.com/coco.html). + +The following options control preprocessing of Fortran code: + +.. index:: cpp, fpp, preprocessor, enable, preprocessor, disable + +.. option:: -cpp, -nocpp + + Enable preprocessing. The preprocessor is automatically invoked if + the file extension is :samp:`.fpp`, :samp:`.FPP`, :samp:`.F`, :samp:`.FOR`, + :samp:`.FTN`, :samp:`.F90`, :samp:`.F95`, :samp:`.F03` or :samp:`.F08`. Use + this option to manually enable preprocessing of any kind of Fortran file. + + To disable preprocessing of files with any of the above listed extensions, + use the negative form: :option:`-nocpp`. + + The preprocessor is run in traditional mode. Any restrictions of the + file-format, especially the limits on line length, apply for + preprocessed output as well, so it might be advisable to use the + :option:`-ffree-line-length-none` or :option:`-ffixed-line-length-none` + options. + +.. index:: dM, preprocessor, debugging, debugging, preprocessor + +.. option:: -dM + + Instead of the normal output, generate a list of ``'#define'`` + directives for all the macros defined during the execution of the + preprocessor, including predefined macros. This gives you a way + of finding out what is predefined in your version of the preprocessor. + Assuming you have no file :samp:`foo.f90`, the command + + .. code-block:: bash + + touch foo.f90; gfortran -cpp -E -dM foo.f90 + + will show all the predefined macros. + +.. index:: dD, preprocessor, debugging, debugging, preprocessor + +.. option:: -dD + + Like :option:`-dM` except in two respects: it does not include the + predefined macros, and it outputs both the ``#define`` directives + and the result of preprocessing. Both kinds of output go to the + standard output file. + +.. index:: dN, preprocessor, debugging, debugging, preprocessor + +.. option:: -dN + + Like :option:`-dD`, but emit only the macro names, not their expansions. + +.. index:: dU, preprocessor, debugging, debugging, preprocessor + +.. option:: -dU + + Like dD except that only macros that are expanded, or whose + definedness is tested in preprocessor directives, are output; the + output is delayed until the use or test of the macro; and ``'#undef'`` + directives are also output for macros tested but undefined at the time. + +.. index:: dI, preprocessor, debugging, debugging, preprocessor + +.. option:: -dI + + Output ``'#include'`` directives in addition to the result + of preprocessing. + +.. index:: fworking-directory, preprocessor, working directory + +.. option:: -fworking-directory + + Enable generation of linemarkers in the preprocessor output that will + let the compiler know the current working directory at the time of + preprocessing. When this option is enabled, the preprocessor will emit, + after the initial linemarker, a second linemarker with the current + working directory followed by two slashes. GCC will use this directory, + when it is present in the preprocessed input, as the directory emitted + as the current working directory in some debugging information formats. + This option is implicitly enabled if debugging information is enabled, + but this can be inhibited with the negated form + :option:`-fno-working-directory`. If the :option:`-P` flag is present + in the command line, this option has no effect, since no ``#line`` + directives are emitted whatsoever. + +.. index:: idirafter dir, preprocessing, include path + +.. option:: -idirafter {dir} + + Search :samp:`{dir}` for include files, but do it after all directories + specified with :option:`-I` and the standard system directories have + been exhausted. :samp:`{dir}` is treated as a system include directory. + If dir begins with ``=``, then the ``=`` will be replaced by + the sysroot prefix; see :option:`--sysroot` and :option:`-isysroot`. + +.. index:: imultilib dir, preprocessing, include path + +.. option:: -imultilib {dir} + + Use :samp:`{dir}` as a subdirectory of the directory containing target-specific + C++ headers. + +.. index:: iprefix prefix, preprocessing, include path + +.. option:: -iprefix {prefix} + + Specify :samp:`{prefix}` as the prefix for subsequent :option:`-iwithprefix` + options. If the :samp:`{prefix}` represents a directory, you should include + the final ``'/'``. + +.. index:: isysroot dir, preprocessing, include path + +.. option:: -isysroot {dir} + + This option is like the :option:`--sysroot` option, but applies only to + header files. See the :option:`--sysroot` option for more information. + +.. index:: iquote dir, preprocessing, include path + +.. option:: -iquote {dir} + + Search :samp:`{dir}` only for header files requested with ``#include "file"`` ; + they are not searched for ``#include ``, before all directories + specified by :option:`-I` and before the standard system directories. If + :samp:`{dir}` begins with ``=``, then the ``=`` will be replaced by the + sysroot prefix; see :option:`--sysroot` and :option:`-isysroot`. + +.. index:: isystem dir, preprocessing, include path + +.. option:: -isystem {dir} + + Search :samp:`{dir}` for header files, after all directories specified by + :option:`-I` but before the standard system directories. Mark it as a + system directory, so that it gets the same special treatment as is + applied to the standard system directories. If :samp:`{dir}` begins with + ``=``, then the ``=`` will be replaced by the sysroot prefix; + see :option:`--sysroot` and :option:`-isysroot`. + +.. index:: nostdinc + +.. option:: -nostdinc + + Do not search the standard system directories for header files. Only + the directories you have specified with :option:`-I` options (and the + directory of the current file, if appropriate) are searched. + +.. index:: undef + +.. option:: -undef + + Do not predefine any system-specific or GCC-specific macros. + The standard predefined macros remain defined. + +.. index:: Apredicate=answer, preprocessing, assertion + +.. option:: -Apredicate={answer} + + Make an assertion with the predicate :samp:`{predicate}` and answer :samp:`{answer}`. + This form is preferred to the older form -A predicate(answer), which is still + supported, because it does not use shell special characters. + +.. index:: A-predicate=answer, preprocessing, assertion + +.. option:: -A-predicate={answer} + + Cancel an assertion with the predicate :samp:`{predicate}` and answer :samp:`{answer}`. + +.. index:: C, preprocessing, keep comments + +.. option:: -C + + Do not discard comments. All comments are passed through to the output + file, except for comments in processed directives, which are deleted + along with the directive. + + You should be prepared for side effects when using :option:`-C` ; it causes + the preprocessor to treat comments as tokens in their own right. For example, + comments appearing at the start of what would be a directive line have the + effect of turning that line into an ordinary source line, since the first + token on the line is no longer a ``'#'``. + + Warning: this currently handles C-Style comments only. The preprocessor + does not yet recognize Fortran-style comments. + +.. index:: CC, preprocessing, keep comments + +.. option:: -CC + + Do not discard comments, including during macro expansion. This is like + :option:`-C`, except that comments contained within macros are also passed + through to the output file where the macro is expanded. + + In addition to the side-effects of the :option:`-C` option, the :option:`-CC` + option causes all C++-style comments inside a macro to be converted to C-style + comments. This is to prevent later use of that macro from inadvertently + commenting out the remainder of the source line. The :option:`-CC` option + is generally used to support lint comments. + + Warning: this currently handles C- and C++-Style comments only. The + preprocessor does not yet recognize Fortran-style comments. + +.. index:: Dname, preprocessing, define macros + +.. option:: -Dname + + Predefine name as a macro, with definition ``1``. + +.. index:: Dname=definition, preprocessing, define macros + +.. option:: -Dname={definition} + + The contents of :samp:`{definition}` are tokenized and processed as if they + appeared during translation phase three in a ``'#define'`` directive. + In particular, the definition will be truncated by embedded newline + characters. + + If you are invoking the preprocessor from a shell or shell-like program + you may need to use the shell's quoting syntax to protect characters such + as spaces that have a meaning in the shell syntax. + + If you wish to define a function-like macro on the command line, write + its argument list with surrounding parentheses before the equals sign + (if any). Parentheses are meaningful to most shells, so you will need + to quote the option. With sh and csh, ``-D'name(args...)=definition'`` + works. + + :option:`-D` and :option:`-U` options are processed in the order they are + given on the command line. All -imacros file and -include file options + are processed after all -D and -U options. + +.. index:: H + +.. option:: -H + + Print the name of each header file used, in addition to other normal + activities. Each name is indented to show how deep in the ``'#include'`` + stack it is. + +.. index:: P, preprocessing, no linemarkers + +.. option:: -P + + Inhibit generation of linemarkers in the output from the preprocessor. + This might be useful when running the preprocessor on something that + is not C code, and will be sent to a program which might be confused + by the linemarkers. + +.. index:: Uname, preprocessing, undefine macros + +.. option:: -Uname + + Cancel any previous definition of :samp:`{name}`, either built in or provided + with a :option:`-D` option. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options/environment-variables-affecting-gfortran.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/environment-variables-affecting-gfortran.rst new file mode 100644 index 00000000000..cd6af4c61c8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/environment-variables-affecting-gfortran.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: environment variable + +.. _environment-variables: + +Environment variables affecting gfortran +**************************************** + +Environment +^^^^^^^^^^^ + +The :command:`gfortran` compiler currently does not make use of any environment +variables to control its operation above and beyond those +that affect the operation of :command:`gcc`. + +See :ref:`gcc:environment-variables`, for information on environment +variables. + +See :ref:`runtime`, for environment variables that affect the +run-time behavior of programs compiled with GNU Fortran. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options/influencing-runtime-behavior.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/influencing-runtime-behavior.rst new file mode 100644 index 00000000000..08f05588e4f --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/influencing-runtime-behavior.rst @@ -0,0 +1,67 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: options, runtime + +.. _runtime-options: + +Influencing runtime behavior +**************************** + +These options affect the runtime behavior of programs compiled with GNU Fortran. + +.. index:: fconvert=conversion + +.. option:: -fconvert={conversion} + + Specify the representation of data for unformatted files. Valid + values for conversion on most systems are: :samp:`native`, the default; + :samp:`swap`, swap between big- and little-endian; :samp:`big-endian`, use + big-endian representation for unformatted files; :samp:`little-endian`, use + little-endian representation for unformatted files. + + On POWER systems which suppport :option:`-mabi=ieeelongdouble`, + there are additional options, which can be combined with others with + commas. Those are + + * :option:`-fconvert=r16_ieee` Use IEEE 128-bit format for + ``REAL(KIND=16)``. + + * :option:`-fconvert=r16_ibm` Use IBM long double format for + ``REAL(KIND=16)``. + + This option has an effect only when used in the main program. + The ``CONVERT`` specifier and the GFORTRAN_CONVERT_UNIT environment + variable override the default specified by :option:`-fconvert`. + +.. index:: frecord-marker=length + +.. option:: -frecord-marker={length} + + Specify the length of record markers for unformatted files. + Valid values for :samp:`{length}` are 4 and 8. Default is 4. + This is different from previous versions of :command:`gfortran`, + which specified a default record marker length of 8 on most + systems. If you want to read or write files compatible + with earlier versions of :command:`gfortran`, use :option:`-frecord-marker=8`. + +.. index:: fmax-subrecord-length=length + +.. option:: -fmax-subrecord-length={length} + + Specify the maximum length for a subrecord. The maximum permitted + value for length is 2147483639, which is also the default. Only + really useful for use by the gfortran testsuite. + +.. index:: fsign-zero + +.. option:: -fsign-zero + + When enabled, floating point numbers of value zero with the sign bit set + are written as negative number in formatted output and treated as + negative in the ``SIGN`` intrinsic. :option:`-fno-sign-zero` does not + print the negative sign of zero values (or values rounded to zero for I/O) + and regards zero as positive number in the ``SIGN`` intrinsic for + compatibility with Fortran 77. The default is :option:`-fsign-zero`. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options/influencing-the-linking-step.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/influencing-the-linking-step.rst new file mode 100644 index 00000000000..2e9e39f92cb --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/influencing-the-linking-step.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: options, linking, linking, static + +.. _link-options: + +Influencing the linking step +**************************** + +These options come into play when the compiler links object files into an +executable output file. They are meaningless if the compiler is not doing +a link step. + +.. index:: static-libgfortran + +.. option:: -static-libgfortran + + On systems that provide :samp:`libgfortran` as a shared and a static + library, this option forces the use of the static version. If no + shared version of :samp:`libgfortran` was built when the compiler was + configured, this option has no effect. + +.. index:: static-libquadmath + +.. option:: -static-libquadmath + + On systems that provide :samp:`libquadmath` as a shared and a static + library, this option forces the use of the static version. If no + shared version of :samp:`libquadmath` was built when the compiler was + configured, this option has no effect. + + Please note that the :samp:`libquadmath` runtime library is licensed under the + GNU Lesser General Public License (LGPL), and linking it statically introduces + requirements when redistributing the resulting binaries. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options/option-summary.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/option-summary.rst new file mode 100644 index 00000000000..7e69d40965b --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/option-summary.rst @@ -0,0 +1,104 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _option-summary: + +Option summary +************** + +Options +^^^^^^^ + +Here is a summary of all the options specific to GNU Fortran, grouped +by type. Explanations are in the following sections. + +*Fortran Language Options* + See :ref:`fortran-dialect-options`. + + :option:`-fall-intrinsics` :option:`-fallow-argument-mismatch` :option:`-fallow-invalid-boz` |gol| + :option:`-fbackslash` :option:`-fcray-pointer` :option:`-fd-lines-as-code` :option:`-fd-lines-as-comments` |gol| + :option:`-fdec` :option:`-fdec-char-conversions` :option:`-fdec-structure` :option:`-fdec-intrinsic-ints` |gol| + :option:`-fdec-static` :option:`-fdec-math` :option:`-fdec-include` :option:`-fdec-format-defaults` |gol| + :option:`-fdec-blank-format-item` :option:`-fdefault-double-8` :option:`-fdefault-integer-8` |gol| + :option:`-fdefault-real-8` :option:`-fdefault-real-10` :option:`-fdefault-real-16` :option:`-fdollar-ok` |gol| + :option:`-ffixed-line-length-n` :option:`-ffixed-line-length-none` :option:`-fpad-source` |gol| + :option:`-ffree-form` :option:`-ffree-line-length-n` :option:`-ffree-line-length-none` |gol| + :option:`-fimplicit-none` :option:`-finteger-4-integer-8` :option:`-fmax-identifier-length` |gol| + :option:`-fmodule-private` :option:`-ffixed-form` :option:`-fno-range-check` :option:`-fopenacc` :option:`-fopenmp` |gol| + :option:`-freal-4-real-10` :option:`-freal-4-real-16` :option:`-freal-4-real-8` :option:`-freal-8-real-10` |gol| + :option:`-freal-8-real-16` :option:`-freal-8-real-4` :option:`-std=std` :option:`-ftest-forall-temp` + +*Preprocessing Options* + See :ref:`preprocessing-options`. + + :option:`-A-question[=answer]` |gol| + :option:`-Aquestion` = :samp:`{answer}` :option:`-C` :option:`-CC` :option:`-Dmacro[=defn]` |gol| + :option:`-H` :option:`-P` |gol| + :option:`-Umacro` :option:`-cpp` :option:`-dD` :option:`-dI` :option:`-dM` :option:`-dN` :option:`-dU` :option:`-fworking-directory`|gol| + :option:`-imultilib` :samp:`{dir}` |gol| + :option:`-iprefix` :samp:`{file}` :option:`-iquote` :option:`-isysroot` :samp:`{dir}` :option:`-isystem` :samp:`{dir}` :option:`-nocpp` |gol| + :option:`-nostdinc` |gol| + :option:`-undef` + +*Error and Warning Options* + See :ref:`error-and-warning-options`. + + :option:`-Waliasing` :option:`-Wall` :option:`-Wampersand` :option:`-Warray-bounds` |gol| + :option:`-Wc-binding-type` :option:`-Wcharacter-truncation` :option:`-Wconversion` |gol| + :option:`-Wdo-subscript` :option:`-Wfunction-elimination` :option:`-Wimplicit-interface` |gol| + :option:`-Wimplicit-procedure` :option:`-Wintrinsic-shadow` :option:`-Wuse-without-only` |gol| + :option:`-Wintrinsics-std` :option:`-Wline-truncation` :option:`-Wno-align-commons` |gol| + :option:`-Wno-overwrite-recursive` :option:`-Wno-tabs` :option:`-Wreal-q-constant` :option:`-Wsurprising` |gol| + :option:`-Wunderflow` :option:`-Wunused-parameter` :option:`-Wrealloc-lhs` :option:`-Wrealloc-lhs-all` |gol| + :option:`-Wfrontend-loop-interchange` :option:`-Wtarget-lifetime` :option:`-fmax-errors=n` |gol| + :option:`-fsyntax-only` :option:`-pedantic` |gol| + :option:`-pedantic-errors` + +*Debugging Options* + See :ref:`debugging-options`. + + :option:`-fbacktrace` :option:`-fdump-fortran-optimized` :option:`-fdump-fortran-original` |gol| + :option:`-fdebug-aux-vars` :option:`-fdump-fortran-global` :option:`-fdump-parse-tree` :option:`-ffpe-trap=list` |gol| + :option:`-ffpe-summary=list` + +*Directory Options* + See :ref:`directory-options`. + + :option:`-Idir` :option:`-Jdir` :option:`-fintrinsic-modules-path` :samp:`{dir}` + +*Link Options* + See :ref:`link-options`. + + :option:`-static-libgfortran` :option:`-static-libquadmath` + +*Runtime Options* + See :ref:`runtime-options`. + + :option:`-fconvert=conversion` :option:`-fmax-subrecord-length=length` |gol| + :option:`-frecord-marker=length` :option:`-fsign-zero` + +*Interoperability Options* + See :ref:`interoperability-options`. + + :option:`-fc-prototypes` :option:`-fc-prototypes-external` + +*Code Generation Options* + See :ref:`code-gen-options`. + + :option:`-faggressive-function-elimination` :option:`-fblas-matmul-limit=n` |gol| + :option:`-fbounds-check` :option:`-ftail-call-workaround` :option:`-ftail-call-workaround=n` |gol| + :option:`-fcheck-array-temporaries` |gol| + :option:`-fcheck=` |gol| + :option:`-fcoarray=` :option:`-fexternal-blas` :option:`-ff2c` |gol| + :option:`-ffrontend-loop-interchange` :option:`-ffrontend-optimize` |gol| + :option:`-finit-character=n` :option:`-finit-integer=n` :option:`-finit-local-zero` |gol| + :option:`-finit-derived` :option:`-finit-logical=` |gol| + :option:`-finit-real=`|gol| + :option:`-finline-matmul-limit=n` |gol| + :option:`-finline-arg-packing` :option:`-fmax-array-constructor=n` |gol| + :option:`-fmax-stack-var-size=n` :option:`-fno-align-commons` :option:`-fno-automatic` |gol| + :option:`-fno-protect-parens` :option:`-fno-underscoring` :option:`-fsecond-underscore` |gol| + :option:`-fpack-derived` :option:`-frealloc-lhs` :option:`-frecursive` :option:`-frepack-arrays` |gol| + :option:`-fshort-enums` :option:`-fstack-arrays` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-controlling-fortran-dialect.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-controlling-fortran-dialect.rst new file mode 100644 index 00000000000..175f92528b5 --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-controlling-fortran-dialect.rst @@ -0,0 +1,411 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: dialect options, language, dialect options, options, dialect + +.. _fortran-dialect-options: + +Options controlling Fortran dialect +*********************************** + +The following options control the details of the Fortran dialect +accepted by the compiler: + +.. index:: ffree-form, ffixed-form, options, Fortran dialect, file format, free, file format, fixed + +.. option:: -ffree-form, -ffixed-form + + Specify the layout used by the source file. The free form layout + was introduced in Fortran 90. Fixed form was traditionally used in + older Fortran programs. When neither option is specified, the source + form is determined by the file extension. + +.. index:: fall-intrinsics + +.. option:: -fall-intrinsics + + This option causes all intrinsic procedures (including the GNU-specific + extensions) to be accepted. This can be useful with :option:`-std=` to + force standard-compliance but get access to the full range of intrinsics + available with :command:`gfortran`. As a consequence, :option:`-Wintrinsics-std` + will be ignored and no user-defined procedure with the same name as any + intrinsic will be called except when it is explicitly declared ``EXTERNAL``. + +.. index:: fallow-argument-mismatch + +.. option:: -fallow-argument-mismatch + + Some code contains calls to external procedures with mismatches + between the calls and the procedure definition, or with mismatches + between different calls. Such code is non-conforming, and will usually + be flagged with an error. This options degrades the error to a + warning, which can only be disabled by disabling all warnings via + :option:`-w`. Only a single occurrence per argument is flagged by this + warning. :option:`-fallow-argument-mismatch` is implied by + :option:`-std=legacy`. + + Using this option is *strongly* discouraged. It is possible to + provide standard-conforming code which allows different types of + arguments by using an explicit interface and ``TYPE(*)``. + +.. index:: allow-invalid-boz + +.. option:: -fallow-invalid-boz + + A BOZ literal constant can occur in a limited number of contexts in + standard conforming Fortran. This option degrades an error condition + to a warning, and allows a BOZ literal constant to appear where the + Fortran standard would otherwise prohibit its use. + +.. index:: fd-lines-as-code, fd-lines-as-comments + +.. option:: -fd-lines-as-code, -fd-lines-as-comments + + Enable special treatment for lines beginning with ``d`` or ``D`` + in fixed form sources. If the :option:`-fd-lines-as-code` option is + given they are treated as if the first column contained a blank. If the + :option:`-fd-lines-as-comments` option is given, they are treated as + comment lines. + +.. index:: fdec + +.. option:: -fdec + + DEC compatibility mode. Enables extensions and other features that mimic + the default behavior of older compilers (such as DEC). + These features are non-standard and should be avoided at all costs. + For details on GNU Fortran's implementation of these extensions see the + full documentation. + + Other flags enabled by this switch are: + + :option:`-fdollar-ok` :option:`-fcray-pointer` :option:`-fdec-char-conversions` |gol| + :option:`-fdec-structure` :option:`-fdec-intrinsic-ints` :option:`-fdec-static` |gol| + :option:`-fdec-math` :option:`-fdec-include` :option:`-fdec-blank-format-item` |gol| + :option:`-fdec-format-defaults` + + If :option:`-fd-lines-as-code` / :option:`-fd-lines-as-comments` are unset, then + :option:`-fdec` also sets :option:`-fd-lines-as-comments`. + +.. index:: fdec-char-conversions + +.. option:: -fdec-char-conversions + + Enable the use of character literals in assignments and ``DATA`` statements + for non-character variables. + +.. index:: fdec-structure + +.. option:: -fdec-structure + + Enable DEC ``STRUCTURE`` and ``RECORD`` as well as ``UNION``, + ``MAP``, and dot ('.') as a member separator (in addition to '%'). This is + provided for compatibility only; Fortran 90 derived types should be used + instead where possible. + +.. index:: fdec-intrinsic-ints + +.. option:: -fdec-intrinsic-ints + + Enable B/I/J/K kind variants of existing integer functions (e.g. BIAND, IIAND, + JIAND, etc...). For a complete list of intrinsics see the full documentation. + +.. index:: fdec-math + +.. option:: -fdec-math + + Enable legacy math intrinsics such as COTAN and degree-valued trigonometric + functions (e.g. TAND, ATAND, etc...) for compatability with older code. + +.. index:: fdec-static + +.. option:: -fdec-static + + Enable DEC-style STATIC and AUTOMATIC attributes to explicitly specify + the storage of variables and other objects. + +.. index:: fdec-include + +.. option:: -fdec-include + + Enable parsing of INCLUDE as a statement in addition to parsing it as + INCLUDE line. When parsed as INCLUDE statement, INCLUDE does not have to + be on a single line and can use line continuations. + +.. index:: fdec-format-defaults + +.. option:: -fdec-format-defaults + + Enable format specifiers F, G and I to be used without width specifiers, + default widths will be used instead. + +.. index:: fdec-blank-format-item + +.. option:: -fdec-blank-format-item + + Enable a blank format item at the end of a format specification i.e. nothing + following the final comma. + +.. index:: fdollar-ok, $, symbol names, character set + +.. option:: -fdollar-ok + + Allow :samp:`$` as a valid non-first character in a symbol name. Symbols + that start with :samp:`$` are rejected since it is unclear which rules to + apply to implicit typing as different vendors implement different rules. + Using :samp:`$` in ``IMPLICIT`` statements is also rejected. + +.. index:: backslash, backslash, escape characters + +.. option:: -fbackslash + + Change the interpretation of backslashes in string literals from a single + backslash character to 'C-style' escape characters. The following + combinations are expanded ``\a``, ``\b``, ``\f``, ``\n``, + ``\r``, ``\t``, ``\v``, ``\\``, and ``\0`` to the ASCII + characters alert, backspace, form feed, newline, carriage return, + horizontal tab, vertical tab, backslash, and NUL, respectively. + Additionally, ``\x``:samp:`{nn}`, ``\u``:samp:`{nnnn}` and + ``\U``:samp:`{nnnnnnnn}` (where each :samp:`{n}` is a hexadecimal digit) are + translated into the Unicode characters corresponding to the specified code + points. All other combinations of a character preceded by \ are + unexpanded. + +.. index:: fmodule-private, module entities, private + +.. option:: -fmodule-private + + Set the default accessibility of module entities to ``PRIVATE``. + Use-associated entities will not be accessible unless they are explicitly + declared as ``PUBLIC``. + +.. index:: ffixed-line-length-n, file format, fixed + +.. option:: -ffixed-line-length-n + -ffixed-line-length-none + -ffixed-line-length-0 + + Set column after which characters are ignored in typical fixed-form + lines in the source file, and, unless ``-fno-pad-source``, through which + spaces are assumed (as if padded to that length) after the ends of short + fixed-form lines. + + Popular values for :samp:`{n}` include 72 (the + standard and the default), 80 (card image), and 132 (corresponding + to 'extended-source' options in some popular compilers). + :samp:`{n}` may also be :samp:`none`, meaning that the entire line is meaningful + and that continued character constants never have implicit spaces appended + to them to fill out the line. + :option:`-ffixed-line-length-0` means the same thing as + :option:`-ffixed-line-length-none`. + +.. index:: fpad-source + +.. option:: -fno-pad-source + + By default fixed-form lines have spaces assumed (as if padded to that length) + after the ends of short fixed-form lines. This is not done either if + :option:`-ffixed-line-length-0`, :option:`-ffixed-line-length-none` or + if :option:`-fno-pad-source` option is used. With any of those options + continued character constants never have implicit spaces appended + to them to fill out the line. + +.. index:: ffree-line-length-n, file format, free + +.. option:: -ffree-line-length-n + -ffree-line-length-none + -ffree-line-length-0 + + Set column after which characters are ignored in typical free-form + lines in the source file. The default value is 132. + :samp:`{n}` may be :samp:`none`, meaning that the entire line is meaningful. + :option:`-ffree-line-length-0` means the same thing as + :option:`-ffree-line-length-none`. + +.. index:: fmax-identifier-length=n + +.. option:: -fmax-identifier-length={n} + + Specify the maximum allowed identifier length. Typical values are + 31 (Fortran 95) and 63 (Fortran 2003 and later). + +.. index:: fimplicit-none + +.. option:: -fimplicit-none + + Specify that no implicit typing is allowed, unless overridden by explicit + ``IMPLICIT`` statements. This is the equivalent of adding + ``implicit none`` to the start of every procedure. + +.. index:: fcray-pointer + +.. option:: -fcray-pointer + + Enable the Cray pointer extension, which provides C-like pointer + functionality. + +.. index:: fopenacc, OpenACC + +.. option:: -fopenacc + + Enable the OpenACC extensions. This includes OpenACC ``!$acc`` + directives in free form and ``c$acc``, ``*$acc`` and + ``!$acc`` directives in fixed form, ``!$`` conditional + compilation sentinels in free form and ``c$``, ``*$`` and + ``!$`` sentinels in fixed form, and when linking arranges for the + OpenACC runtime library to be linked in. + +.. index:: fopenmp, OpenMP + +.. option:: -fopenmp + + Enable the OpenMP extensions. This includes OpenMP ``!$omp`` directives + in free form + and ``c$omp``, ``*$omp`` and ``!$omp`` directives in fixed form, + ``!$`` conditional compilation sentinels in free form + and ``c$``, ``*$`` and ``!$`` sentinels in fixed form, + and when linking arranges for the OpenMP runtime library to be linked + in. The option :option:`-fopenmp` implies :option:`-frecursive`. + +.. index:: frange-check + +.. option:: -fno-range-check + + Disable range checking on results of simplification of constant + expressions during compilation. For example, GNU Fortran will give + an error at compile time when simplifying ``a = 1. / 0``. + With this option, no error will be given and ``a`` will be assigned + the value ``+Infinity``. If an expression evaluates to a value + outside of the relevant range of [ ``-HUGE()`` : ``HUGE()`` ], + then the expression will be replaced by ``-Inf`` or ``+Inf`` + as appropriate. + Similarly, ``DATA i/Z'FFFFFFFF'/`` will result in an integer overflow + on most systems, but with :option:`-fno-range-check` the value will + 'wrap around' and ``i`` will be initialized to -1 instead. + +.. index:: fdefault-integer-8 + +.. option:: -fdefault-integer-8 + + Set the default integer and logical types to an 8 byte wide type. This option + also affects the kind of integer constants like ``42``. Unlike + :option:`-finteger-4-integer-8`, it does not promote variables with explicit + kind declaration. + +.. index:: fdefault-real-8 + +.. option:: -fdefault-real-8 + + Set the default real type to an 8 byte wide type. This option also affects + the kind of non-double real constants like ``1.0``. This option promotes + the default width of ``DOUBLE PRECISION`` and double real constants + like ``1.d0`` to 16 bytes if possible. If ``-fdefault-double-8`` + is given along with ``fdefault-real-8``, ``DOUBLE PRECISION`` + and double real constants are not promoted. Unlike :option:`-freal-4-real-8`, + ``fdefault-real-8`` does not promote variables with explicit kind + declarations. + +.. index:: fdefault-real-10 + +.. option:: -fdefault-real-10 + + Set the default real type to an 10 byte wide type. This option also affects + the kind of non-double real constants like ``1.0``. This option promotes + the default width of ``DOUBLE PRECISION`` and double real constants + like ``1.d0`` to 16 bytes if possible. If ``-fdefault-double-8`` + is given along with ``fdefault-real-10``, ``DOUBLE PRECISION`` + and double real constants are not promoted. Unlike :option:`-freal-4-real-10`, + ``fdefault-real-10`` does not promote variables with explicit kind + declarations. + +.. index:: fdefault-real-16 + +.. option:: -fdefault-real-16 + + Set the default real type to an 16 byte wide type. This option also affects + the kind of non-double real constants like ``1.0``. This option promotes + the default width of ``DOUBLE PRECISION`` and double real constants + like ``1.d0`` to 16 bytes if possible. If ``-fdefault-double-8`` + is given along with ``fdefault-real-16``, ``DOUBLE PRECISION`` + and double real constants are not promoted. Unlike :option:`-freal-4-real-16`, + ``fdefault-real-16`` does not promote variables with explicit kind + declarations. + +.. index:: fdefault-double-8 + +.. option:: -fdefault-double-8 + + Set the ``DOUBLE PRECISION`` type and double real constants + like ``1.d0`` to an 8 byte wide type. Do nothing if this + is already the default. This option prevents :option:`-fdefault-real-8`, + :option:`-fdefault-real-10`, and :option:`-fdefault-real-16`, + from promoting ``DOUBLE PRECISION`` and double real constants like + ``1.d0`` to 16 bytes. + +.. index:: finteger-4-integer-8 + +.. option:: -finteger-4-integer-8 + + Promote all ``INTEGER(KIND=4)`` entities to an ``INTEGER(KIND=8)`` + entities. If ``KIND=8`` is unavailable, then an error will be issued. + This option should be used with care and may not be suitable for your codes. + Areas of possible concern include calls to external procedures, + alignment in ``EQUIVALENCE`` and/or ``COMMON``, generic interfaces, + BOZ literal constant conversion, and I/O. Inspection of the intermediate + representation of the translated Fortran code, produced by + :option:`-fdump-tree-original`, is suggested. + +.. index:: freal-4-real-8, freal-4-real-10, freal-4-real-16, freal-8-real-4, freal-8-real-10, freal-8-real-16, options, real kind type promotion + +.. option:: -freal-4-real-8, -freal-4-real-10, -freal-4-real-16, -freal-8-real-4, -freal-8-real-10, -freal-8-real-16 + + Promote all ``REAL(KIND=M)`` entities to ``REAL(KIND=N)`` entities. + If ``REAL(KIND=N)`` is unavailable, then an error will be issued. + The ``-freal-4-`` flags also affect the default real kind and the + ``-freal-8-`` flags also the double-precision real kind. All other + real-kind types are unaffected by this option. The promotion is also + applied to real literal constants of default and double-precision kind + and a specified kind number of 4 or 8, respectively. + However, ``-fdefault-real-8``, ``-fdefault-real-10``, + ``-fdefault-real-10``, and ``-fdefault-double-8`` take precedence + for the default and double-precision real kinds, both for real literal + constants and for declarations without a kind number. + Note that for ``REAL(KIND=KIND(1.0))`` the literal may get promoted and + then the result may get promoted again. + These options should be used with care and may not be suitable for your + codes. Areas of possible concern include calls to external procedures, + alignment in ``EQUIVALENCE`` and/or ``COMMON``, generic interfaces, + BOZ literal constant conversion, and I/O and calls to intrinsic procedures + when passing a value to the ``kind=`` dummy argument. Inspection of the + intermediate representation of the translated Fortran code, produced by + :option:`-fdump-fortran-original` or :option:`-fdump-tree-original`, is suggested. + +.. index:: std=std option + +.. option:: -std={std} + + Specify the standard to which the program is expected to conform, + which may be one of :samp:`f95`, :samp:`f2003`, :samp:`f2008`, + :samp:`f2018`, :samp:`gnu`, or :samp:`legacy`. The default value for + :samp:`{std}` is :samp:`gnu`, which specifies a superset of the latest + Fortran standard that includes all of the extensions supported by GNU + Fortran, although warnings will be given for obsolete extensions not + recommended for use in new code. The :samp:`legacy` value is + equivalent but without the warnings for obsolete extensions, and may + be useful for old non-standard programs. The :samp:`f95`, + :samp:`f2003`, :samp:`f2008`, and :samp:`f2018` values specify strict + conformance to the Fortran 95, Fortran 2003, Fortran 2008 and Fortran + 2018 standards, respectively; errors are given for all extensions + beyond the relevant language standard, and warnings are given for the + Fortran 77 features that are permitted but obsolescent in later + standards. The deprecated option :samp:`-std=f2008ts` acts as an alias for + :samp:`-std=f2018`. It is only present for backwards compatibility with + earlier gfortran versions and should not be used any more. + +.. index:: ftest-forall-temp + +.. option:: -ftest-forall-temp + + Enhance test coverage by forcing most forall assignments to use temporary. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-code-generation-conventions.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-code-generation-conventions.rst new file mode 100644 index 00000000000..f83846a4fb7 --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-code-generation-conventions.rst @@ -0,0 +1,583 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: code generation, conventions, options, code generation, options, run-time + +.. _code-gen-options: + +Options for code generation conventions +*************************************** + +These machine-independent options control the interface conventions +used in code generation. + +Most of them have both positive and negative forms; the negative form +of :samp:`-ffoo` would be :samp:`-fno-foo`. In the table below, only +one of the forms is listed---the one which is not the default. You +can figure out the other form by either removing no- or adding +it. + +.. index:: fno-automatic, SAVE statement, statement, SAVE + +.. option:: -fno-automatic + + Treat each program unit (except those marked as RECURSIVE) as if the + ``SAVE`` statement were specified for every local variable and array + referenced in it. Does not affect common blocks. (Some Fortran compilers + provide this option under the name :option:`-static` or :option:`-save`.) + The default, which is :option:`-fautomatic`, uses the stack for local + variables smaller than the value given by :option:`-fmax-stack-var-size`. + Use the option :option:`-frecursive` to use no static memory. + + Local variables or arrays having an explicit ``SAVE`` attribute are + silently ignored unless the :option:`-pedantic` option is added. + +.. index:: calling convention, f2c calling convention, g77 calling convention, libf2c calling convention + +.. option:: -ff2c + + Generate code designed to be compatible with code generated + by :command:`g77` and :command:`f2c`. + + The calling conventions used by :command:`g77` (originally implemented + in :command:`f2c`) require functions that return type + default ``REAL`` to actually return the C type ``double``, and + functions that return type ``COMPLEX`` to return the values via an + extra argument in the calling sequence that points to where to + store the return value. Under the default GNU calling conventions, such + functions simply return their results as they would in GNU + C---default ``REAL`` functions return the C type ``float``, and + ``COMPLEX`` functions return the GNU C type ``complex``. + Additionally, this option implies the :option:`-fsecond-underscore` + option, unless :option:`-fno-second-underscore` is explicitly requested. + + This does not affect the generation of code that interfaces with + the :command:`libgfortran` library. + + .. warning:: + + It is not a good idea to mix Fortran code compiled with + :option:`-ff2c` with code compiled with the default :option:`-fno-f2c` + calling conventions as, calling ``COMPLEX`` or default ``REAL`` + functions between program parts which were compiled with different + calling conventions will break at execution time. + + .. warning:: + + This will break code which passes intrinsic functions + of type default ``REAL`` or ``COMPLEX`` as actual arguments, as + the library implementations use the :option:`-fno-f2c` calling conventions. + +.. index:: fno-underscoring, underscore, symbol names, underscores, transforming symbol names, symbol names, transforming + +.. option:: -fno-underscoring + + Do not transform names of entities specified in the Fortran + source file by appending underscores to them. + + With :option:`-funderscoring` in effect, GNU Fortran appends one + underscore to external names with no underscores. This is done to ensure + compatibility with code produced by many UNIX Fortran compilers. + + .. warning:: + + The default behavior of GNU Fortran is + incompatible with :command:`f2c` and :command:`g77`, please use the + :option:`-ff2c` option if you want object files compiled with + GNU Fortran to be compatible with object code created with these + tools. + + Use of :option:`-fno-underscoring` is not recommended unless you are + experimenting with issues such as integration of GNU Fortran into + existing system environments (vis-ā-vis existing libraries, tools, + and so on). + + For example, with :option:`-funderscoring`, and assuming that ``j()`` and + ``max_count()`` are external functions while ``my_var`` and + ``lvar`` are local variables, a statement like + + .. code-block:: fortran + + I = J() + MAX_COUNT (MY_VAR, LVAR) + + is implemented as something akin to: + + .. code-block:: fortran + + i = j_() + max_count__(&my_var__, &lvar); + + With :option:`-fno-underscoring`, the same statement is implemented as: + + .. code-block:: fortran + + i = j() + max_count(&my_var, &lvar); + + Use of :option:`-fno-underscoring` allows direct specification of + user-defined names while debugging and when interfacing GNU Fortran + code with other languages. + + Note that just because the names match does *not* mean that the + interface implemented by GNU Fortran for an external name matches the + interface implemented by some other language for that same name. + That is, getting code produced by GNU Fortran to link to code produced + by some other compiler using this or any other method can be only a + small part of the overall solution---getting the code generated by + both compilers to agree on issues other than naming can require + significant effort, and, unlike naming disagreements, linkers normally + cannot detect disagreements in these other areas. + + Also, note that with :option:`-fno-underscoring`, the lack of appended + underscores introduces the very real possibility that a user-defined + external name will conflict with a name in a system library, which + could make finding unresolved-reference bugs quite difficult in some + cases---they might occur at program run time, and show up only as + buggy behavior at run time. + + In future versions of GNU Fortran we hope to improve naming and linking + issues so that debugging always involves using the names as they appear + in the source, even if the names as seen by the linker are mangled to + prevent accidental linking between procedures with incompatible + interfaces. + +.. index:: fsecond-underscore, underscore, symbol names, underscores, transforming symbol names, symbol names, transforming, f2c calling convention, g77 calling convention, libf2c calling convention + +.. option:: -fsecond-underscore + + By default, GNU Fortran appends an underscore to external + names. If this option is used GNU Fortran appends two + underscores to names with underscores and one underscore to external names + with no underscores. GNU Fortran also appends two underscores to + internal names with underscores to avoid naming collisions with external + names. + + This option has no effect if :option:`-fno-underscoring` is + in effect. It is implied by the :option:`-ff2c` option. + + Otherwise, with this option, an external name such as ``MAX_COUNT`` + is implemented as a reference to the link-time external symbol + ``max_count__``, instead of ``max_count_``. This is required + for compatibility with :command:`g77` and :command:`f2c`, and is implied + by use of the :option:`-ff2c` option. + +.. index:: fcoarray, coarrays + +.. option:: -fcoarray={} + + none + Disable coarray support; using coarray declarations and image-control + statements will produce a compile-time error. (Default) + + single + Single-image mode, i.e. ``num_images()`` is always one. + + lib + Library-based coarray parallelization; a suitable GNU Fortran coarray + library needs to be linked. + +.. index:: fcheck, array, bounds checking, bit intrinsics checking, bounds checking, pointer checking, memory checking, range checking, subscript checking, checking subscripts, run-time checking, checking array temporaries + +.. option:: -fcheck={} + + Enable the generation of run-time checks; the argument shall be + a comma-delimited list of the following keywords. Prefixing a check with + no- disables it if it was activated by a previous specification. + + all + Enable all run-time test of :option:`-fcheck`. + + array-temps + Warns at run time when for passing an actual argument a temporary array + had to be generated. The information generated by this warning is + sometimes useful in optimization, in order to avoid such temporaries. + + Note: The warning is only printed once per location. + + bits + Enable generation of run-time checks for invalid arguments to the bit + manipulation intrinsics. + + bounds + Enable generation of run-time checks for array subscripts + and against the declared minimum and maximum values. It also + checks array indices for assumed and deferred + shape arrays against the actual allocated bounds and ensures that all string + lengths are equal for character array constructors without an explicit + typespec. + + Some checks require that :option:`-fcheck=bounds` is set for + the compilation of the main program. + + Note: In the future this may also include other forms of checking, e.g., + checking substring references. + + do + Enable generation of run-time checks for invalid modification of loop + iteration variables. + + mem + Enable generation of run-time checks for memory allocation. + Note: This option does not affect explicit allocations using the + ``ALLOCATE`` statement, which will be always checked. + + pointer + Enable generation of run-time checks for pointers and allocatables. + + recursion + Enable generation of run-time checks for recursively called subroutines and + functions which are not marked as recursive. See also :option:`-frecursive`. + Note: This check does not work for OpenMP programs and is disabled if used + together with :option:`-frecursive` and :option:`-fopenmp`. + + Example: Assuming you have a file :samp:`foo.f90`, the command + + .. code-block:: bash + + gfortran -fcheck=all,no-array-temps foo.f90 + + will compile the file with all checks enabled as specified above except + warnings for generated array temporaries. + +.. index:: fbounds-check + +.. option:: -fbounds-check + + .. Note: This option is also referred in gcc's manpage + + Deprecated alias for :option:`-fcheck=bounds`. + +.. index:: tail-call-workaround + +.. option:: -ftail-call-workaround, -ftail-call-workaround={n} + + Some C interfaces to Fortran codes violate the gfortran ABI by + omitting the hidden character length arguments as described in + See :ref:`argument-passing-conventions`. This can lead to crashes + because pushing arguments for tail calls can overflow the stack. + + To provide a workaround for existing binary packages, this option + disables tail call optimization for gfortran procedures with character + arguments. With :option:`-ftail-call-workaround=2` tail call optimization + is disabled in all gfortran procedures with character arguments, + with :option:`-ftail-call-workaround=1` or equivalent + :option:`-ftail-call-workaround` only in gfortran procedures with character + arguments that call implicitly prototyped procedures. + + Using this option can lead to problems including crashes due to + insufficient stack space. + + It is *very strongly* recommended to fix the code in question. + The :option:`-fc-prototypes-external` option can be used to generate + prototypes which conform to gfortran's ABI, for inclusion in the + source code. + + Support for this option will likely be withdrawn in a future release + of gfortran. + + The negative form, :option:`-fno-tail-call-workaround` or equivalent + :option:`-ftail-call-workaround=0`, can be used to disable this option. + + Default is currently :option:`-ftail-call-workaround`, this will change + in future releases. + +.. index:: fcheck-array-temporaries + +.. option:: -fcheck-array-temporaries + + Deprecated alias for :option:`-fcheck=array-temps`. + +.. index:: fmax-array-constructor + +.. option:: -fmax-array-constructor={n} + + This option can be used to increase the upper limit permitted in + array constructors. The code below requires this option to expand + the array at compile time. + + .. code-block:: fortran + + program test + implicit none + integer j + integer, parameter :: n = 100000 + integer, parameter :: i(n) = (/ (2*j, j = 1, n) /) + print '(10(I0,1X))', i + end program test + + .. warning:: + This option can lead to long compile times and excessively + large object files. + + The default value for :samp:`{n}` is 65535. + +.. index:: fmax-stack-var-size + +.. option:: -fmax-stack-var-size={n} + + This option specifies the size in bytes of the largest array that will be put + on the stack; if the size is exceeded static memory is used (except in + procedures marked as RECURSIVE). Use the option :option:`-frecursive` to + allow for recursive procedures which do not have a RECURSIVE attribute or + for parallel programs. Use :option:`-fno-automatic` to never use the stack. + + This option currently only affects local arrays declared with constant + bounds, and may not apply to all character variables. + Future versions of GNU Fortran may improve this behavior. + + The default value for :samp:`{n}` is 65536. + +.. index:: fstack-arrays + +.. option:: -fstack-arrays + + Adding this option will make the Fortran compiler put all arrays of + unknown size and array temporaries onto stack memory. If your program uses very + large local arrays it is possible that you will have to extend your runtime + limits for stack memory on some operating systems. This flag is enabled + by default at optimization level :option:`-Ofast` unless + :option:`-fmax-stack-var-size` is specified. + +.. index:: fpack-derived, structure packing + +.. option:: -fpack-derived + + This option tells GNU Fortran to pack derived type members as closely as + possible. Code compiled with this option is likely to be incompatible + with code compiled without this option, and may execute slower. + +.. index:: frepack-arrays, repacking arrays + +.. option:: -frepack-arrays + + In some circumstances GNU Fortran may pass assumed shape array + sections via a descriptor describing a noncontiguous area of memory. + This option adds code to the function prologue to repack the data into + a contiguous block at runtime. + + This should result in faster accesses to the array. However it can introduce + significant overhead to the function call, especially when the passed data + is noncontiguous. + +.. index:: fshort-enums + +.. option:: -fshort-enums + + This option is provided for interoperability with C code that was + compiled with the :option:`-fshort-enums` option. It will make + GNU Fortran choose the smallest ``INTEGER`` kind a given + enumerator set will fit in, and give all its enumerators this kind. + +.. index:: finline-arg-packing + +.. option:: -finline-arg-packing + + When passing an assumed-shape argument of a procedure as actual + argument to an assumed-size or explicit size or as argument to a + procedure that does not have an explicit interface, the argument may + have to be packed, that is put into contiguous memory. An example is + the call to ``foo`` in + + .. code-block:: fortran + + subroutine foo(a) + real, dimension(*) :: a + end subroutine foo + subroutine bar(b) + real, dimension(:) :: b + call foo(b) + end subroutine bar + + When :option:`-finline-arg-packing` is in effect, this packing will be + performed by inline code. This allows for more optimization while + increasing code size. + + :option:`-finline-arg-packing` is implied by any of the :option:`-O` options + except when optimizing for size via :option:`-Os`. If the code + contains a very large number of argument that have to be packed, code + size and also compilation time may become excessive. If that is the + case, it may be better to disable this option. Instances of packing + can be found by using :option:`-Warray-temporaries`. + +.. index:: fexternal-blas + +.. option:: -fexternal-blas + + This option will make :command:`gfortran` generate calls to BLAS functions + for some matrix operations like ``MATMUL``, instead of using our own + algorithms, if the size of the matrices involved is larger than a given + limit (see :option:`-fblas-matmul-limit`). This may be profitable if an + optimized vendor BLAS library is available. The BLAS library will have + to be specified at link time. + +.. index:: fblas-matmul-limit + +.. option:: -fblas-matmul-limit={n} + + Only significant when :option:`-fexternal-blas` is in effect. + Matrix multiplication of matrices with size larger than (or equal to) :samp:`{n}` + will be performed by calls to BLAS functions, while others will be + handled by :command:`gfortran` internal algorithms. If the matrices + involved are not square, the size comparison is performed using the + geometric mean of the dimensions of the argument and result matrices. + + The default value for :samp:`{n}` is 30. + +.. index:: finline-matmul-limit + +.. option:: -finline-matmul-limit={n} + + When front-end optimization is active, some calls to the ``MATMUL`` + intrinsic function will be inlined. This may result in code size + increase if the size of the matrix cannot be determined at compile + time, as code for both cases is generated. Setting + ``-finline-matmul-limit=0`` will disable inlining in all cases. + Setting this option with a value of :samp:`{n}` will produce inline code + for matrices with size up to :samp:`{n}`. If the matrices involved are not + square, the size comparison is performed using the geometric mean of + the dimensions of the argument and result matrices. + + The default value for :samp:`{n}` is 30. The ``-fblas-matmul-limit`` + can be used to change this value. + +.. index:: frecursive + +.. option:: -frecursive + + Allow indirect recursion by forcing all local arrays to be allocated + on the stack. This flag cannot be used together with + :option:`-fmax-stack-var-size=` or :option:`-fno-automatic`. + +.. index:: finit-local-zero, finit-derived, finit-integer, finit-real, finit-logical, finit-character + +.. option:: -finit-local-zero + -finit-derived + -finit-integer={n} + -finit-real={} + -finit-logical={} + -finit-character={n} + + The :option:`-finit-local-zero` option instructs the compiler to + initialize local ``INTEGER``, ``REAL``, and ``COMPLEX`` + variables to zero, ``LOGICAL`` variables to false, and + ``CHARACTER`` variables to a string of null bytes. Finer-grained + initialization options are provided by the + :option:`-finit-integer=n`, + :option:`-finit-real=` (which also initializes + the real and imaginary parts of local ``COMPLEX`` variables), + :option:`-finit-logical=`, and + :option:`-finit-character=n` (where :samp:`{n}` is an ASCII character + value) options. + + With :option:`-finit-derived`, components of derived type variables will be + initialized according to these flags. Components whose type is not covered by + an explicit :option:`-finit-*` flag will be treated as described above with + :option:`-finit-local-zero`. + + These options do not initialize + + * objects with the POINTER attribute + + * allocatable arrays + + * variables that appear in an ``EQUIVALENCE`` statement. + + (These limitations may be removed in future releases). + + Note that the :option:`-finit-real=nan` option initializes ``REAL`` + and ``COMPLEX`` variables with a quiet NaN. For a signalling NaN + use :option:`-finit-real=snan` ; note, however, that compile-time + optimizations may convert them into quiet NaN and that trapping + needs to be enabled (e.g. via :option:`-ffpe-trap`). + + The :option:`-finit-integer` option will parse the value into an + integer of type ``INTEGER(kind=C_LONG)`` on the host. Said value + is then assigned to the integer variables in the Fortran code, which + might result in wraparound if the value is too large for the kind. + + Finally, note that enabling any of the :option:`-finit-*` options will + silence warnings that would have been emitted by :option:`-Wuninitialized` + for the affected local variables. + +.. index:: falign-commons, alignment of COMMON blocks + +.. option:: -falign-commons + + By default, :command:`gfortran` enforces proper alignment of all variables in a + ``COMMON`` block by padding them as needed. On certain platforms this is mandatory, + on others it increases performance. If a ``COMMON`` block is not declared with + consistent data types everywhere, this padding can cause trouble, and + :option:`-fno-align-commons` can be used to disable automatic alignment. The + same form of this option should be used for all files that share a ``COMMON`` block. + To avoid potential alignment issues in ``COMMON`` blocks, it is recommended to order + objects from largest to smallest. + +.. index:: fno-protect-parens, re-association of parenthesized expressions + +.. option:: -fno-protect-parens + + By default the parentheses in expression are honored for all optimization + levels such that the compiler does not do any re-association. Using + :option:`-fno-protect-parens` allows the compiler to reorder ``REAL`` and + ``COMPLEX`` expressions to produce faster code. Note that for the re-association + optimization :option:`-fno-signed-zeros` and :option:`-fno-trapping-math` + need to be in effect. The parentheses protection is enabled by default, unless + :option:`-Ofast` is given. + +.. index:: frealloc-lhs, Reallocate the LHS in assignments + +.. option:: -frealloc-lhs + + An allocatable left-hand side of an intrinsic assignment is automatically + (re)allocated if it is either unallocated or has a different shape. The + option is enabled by default except when :option:`-std=f95` is given. See + also :option:`-Wrealloc-lhs`. + +.. index:: faggressive-function-elimination, Elimination of functions with identical argument lists + +.. option:: -faggressive-function-elimination + + Functions with identical argument lists are eliminated within + statements, regardless of whether these functions are marked + ``PURE`` or not. For example, in + + .. code-block:: fortran + + a = f(b,c) + f(b,c) + + there will only be a single call to ``f``. This option only works + if :option:`-ffrontend-optimize` is in effect. + +.. index:: frontend-optimize, Front-end optimization + +.. option:: -ffrontend-optimize + + This option performs front-end optimization, based on manipulating + parts the Fortran parse tree. Enabled by default by any :option:`-O` option + except :option:`-O0` and :option:`-Og`. Optimizations enabled by this option + include: + + * inlining calls to ``MATMUL``, + + * elimination of identical function calls within expressions, + + * removing unnecessary calls to ``TRIM`` in comparisons and assignments, + + * replacing ``TRIM(a)`` with ``a(1:LEN_TRIM(a))`` and + + * short-circuiting of logical operators (``.AND.`` and ``.OR.``). + + It can be deselected by specifying :option:`-fno-frontend-optimize`. + +.. index:: frontend-loop-interchange, loop interchange, Fortran + +.. option:: -ffrontend-loop-interchange + + Attempt to interchange loops in the Fortran front end where + profitable. Enabled by default by any :option:`-O` option. + At the moment, this option only affects ``FORALL`` and + ``DO CONCURRENT`` statements with several forall triplets. + +See :ref:`gcc:code-gen-options`, for information on more options +offered by the GBE +shared by :command:`gfortran`, :command:`gcc`, and other GNU compilers. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-debugging-your-program-or-gnu-fortran.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-debugging-your-program-or-gnu-fortran.rst new file mode 100644 index 00000000000..d7ec72e2897 --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-debugging-your-program-or-gnu-fortran.rst @@ -0,0 +1,134 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: options, debugging, debugging information options + +.. _debugging-options: + +Options for debugging your program or GNU Fortran +************************************************* + +GNU Fortran has various special options that are used for debugging +either your program or the GNU Fortran compiler. + +.. index:: fdump-fortran-original + +.. option:: -fdump-fortran-original + + Output the internal parse tree after translating the source program + into internal representation. This option is mostly useful for + debugging the GNU Fortran compiler itself. The output generated by + this option might change between releases. This option may also + generate internal compiler errors for features which have only + recently been added. + +.. index:: fdump-fortran-optimized + +.. option:: -fdump-fortran-optimized + + Output the parse tree after front-end optimization. Mostly useful for + debugging the GNU Fortran compiler itself. The output generated by + this option might change between releases. This option may also + generate internal compiler errors for features which have only + recently been added. + +.. index:: fdump-parse-tree + +.. option:: -fdump-parse-tree + + Output the internal parse tree after translating the source program + into internal representation. Mostly useful for debugging the GNU + Fortran compiler itself. The output generated by this option might + change between releases. This option may also generate internal + compiler errors for features which have only recently been added. This + option is deprecated; use ``-fdump-fortran-original`` instead. + +.. index:: fdebug-aux-vars + +.. option:: -fdebug-aux-vars + + Renames internal variables created by the gfortran front end and makes + them accessible to a debugger. The name of the internal variables then + start with upper-case letters followed by an underscore. This option is + useful for debugging the compiler's code generation together with + ``-fdump-tree-original`` and enabling debugging of the executable + program by using ``-g`` or ``-ggdb3``. + +.. index:: fdump-fortran-global + +.. option:: -fdump-fortran-global + + Output a list of the global identifiers after translating into + middle-end representation. Mostly useful for debugging the GNU Fortran + compiler itself. The output generated by this option might change + between releases. This option may also generate internal compiler + errors for features which have only recently been added. + +.. index:: ffpe-trap=list + +.. option:: -ffpe-trap={list} + + Specify a list of floating point exception traps to enable. On most + systems, if a floating point exception occurs and the trap for that + exception is enabled, a SIGFPE signal will be sent and the program + being aborted, producing a core file useful for debugging. :samp:`{list}` + is a (possibly empty) comma-separated list of the following + exceptions: :samp:`invalid` (invalid floating point operation, such as + ``SQRT(-1.0)``), :samp:`zero` (division by zero), :samp:`overflow` + (overflow in a floating point operation), :samp:`underflow` (underflow + in a floating point operation), :samp:`inexact` (loss of precision + during operation), and :samp:`denormal` (operation performed on a + denormal value). The first five exceptions correspond to the five + IEEE 754 exceptions, whereas the last one (:samp:`denormal`) is not + part of the IEEE 754 standard but is available on some common + architectures such as x86. + + The first three exceptions (:samp:`invalid`, :samp:`zero`, and + :samp:`overflow`) often indicate serious errors, and unless the program + has provisions for dealing with these exceptions, enabling traps for + these three exceptions is probably a good idea. + + If the option is used more than once in the command line, the lists will + be joined: ' ``ffpe-trap=``:samp:`{list1}` ``ffpe-trap=``:samp:`{list2}` ' + is equivalent to ``ffpe-trap=``:samp:`{list1}`, :samp:`{list2}`. + + Note that once enabled an exception cannot be disabled (no negative form). + + Many, if not most, floating point operations incur loss of precision + due to rounding, and hence the ``ffpe-trap=inexact`` is likely to + be uninteresting in practice. + + By default no exception traps are enabled. + +.. index:: ffpe-summary=list + +.. option:: -ffpe-summary={list} + + Specify a list of floating-point exceptions, whose flag status is printed + to ``ERROR_UNIT`` when invoking ``STOP`` and ``ERROR STOP``. + :samp:`{list}` can be either :samp:`none`, :samp:`all` or a comma-separated list + of the following exceptions: :samp:`invalid`, :samp:`zero`, :samp:`overflow`, + :samp:`underflow`, :samp:`inexact` and :samp:`denormal`. (See + :option:`-ffpe-trap` for a description of the exceptions.) + + If the option is used more than once in the command line, only the + last one will be used. + + By default, a summary for all exceptions but :samp:`inexact` is shown. + +.. index:: fno-backtrace, backtrace, trace + +.. option:: -fno-backtrace + + When a serious runtime error is encountered or a deadly signal is + emitted (segmentation fault, illegal instruction, bus error, + floating-point exception, and the other POSIX signals that have the + action :samp:`core`), the Fortran runtime library tries to output a + backtrace of the error. ``-fno-backtrace`` disables the backtrace + generation. This option only has influence for compilation of the + Fortran main program. + +See :ref:`gcc:debugging-options`, for more information on +debugging options. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-directory-search.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-directory-search.rst new file mode 100644 index 00000000000..a76f1502e45 --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-directory-search.rst @@ -0,0 +1,54 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: directory, options, options, directory search, search path, INCLUDE directive, directive, INCLUDE + +.. _directory-options: + +Options for directory search +**************************** + +These options affect how GNU Fortran searches +for files specified by the ``INCLUDE`` directive and where it searches +for previously compiled modules. + +It also affects the search paths used by :command:`cpp` when used to preprocess +Fortran source. + +.. index:: Idir, directory, search paths for inclusion, inclusion, directory search paths for, search paths, for included files, paths, search, module search path + +.. option:: -Idir + + These affect interpretation of the ``INCLUDE`` directive + (as well as of the ``#include`` directive of the :command:`cpp` + preprocessor). + + Also note that the general behavior of :option:`-I` and + ``INCLUDE`` is pretty much the same as of :option:`-I` with + ``#include`` in the :command:`cpp` preprocessor, with regard to + looking for :samp:`header.gcc` files and other such things. + + This path is also used to search for :samp:`.mod` files when previously + compiled modules are required by a ``USE`` statement. + + See :ref:`gcc:directory-options`, for information on the + :option:`-I` option. + +.. index:: Jdir, Mdir, paths, search, module search path + +.. option:: -Jdir + + This option specifies where to put :samp:`.mod` files for compiled modules. + It is also added to the list of directories to searched by an ``USE`` + statement. + + The default is the current directory. + +.. index:: fintrinsic-modules-pathdir, paths, search, module search path + +.. option:: -fintrinsic-modules-path {dir} + + This option specifies the location of pre-compiled intrinsic modules, if + they are not in the default location expected by the compiler. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-interoperability-with-other-languages.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-interoperability-with-other-languages.rst new file mode 100644 index 00000000000..65f418cae83 --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-for-interoperability-with-other-languages.rst @@ -0,0 +1,63 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _interoperability-options: + +Options for interoperability with other languages +************************************************* + +.. index:: c-prototypes, Generating C prototypes from Fortran BIND(C) enteties + +.. option:: -fc-prototypes + + This option will generate C prototypes from ``BIND(C)`` variable + declarations, types and procedure interfaces and writes them to + standard output. ``ENUM`` is not yet supported. + + The generated prototypes may need inclusion of an appropriate header, + such as ```` or ````. For types which are + not specified using the appropriate kind from the ``iso_c_binding`` + module, a warning is added as a comment to the code. + + For function pointers, a pointer to a function returning ``int`` + without an explicit argument list is generated. + + Example of use: + + .. code-block:: shell-session + + $ gfortran -fc-prototypes -fsyntax-only foo.f90 > foo.h + + where the C code intended for interoperating with the Fortran code + then uses ``#include "foo.h"``. + +.. index:: c-prototypes-external, Generating C prototypes from external procedures + +.. option:: -fc-prototypes-external + + This option will generate C prototypes from external functions and + subroutines and write them to standard output. This may be useful for + making sure that C bindings to Fortran code are correct. This option + does not generate prototypes for ``BIND(C)`` procedures, use + :option:`-fc-prototypes` for that. + + The generated prototypes may need inclusion of an appropriate + header, such as ```` or ````. + + This is primarily meant for legacy code to ensure that existing C + bindings match what :command:`gfortran` emits. The generated C + prototypes should be correct for the current version of the compiler, + but may not match what other compilers or earlier versions of + :command:`gfortran` need. For new developments, use of the + ``BIND(C)`` features is recommended. + + Example of use: + + .. code-block:: shell-session + + $ gfortran -fc-prototypes-external -fsyntax-only foo.f > foo.h + + where the C code intended for interoperating with the Fortran code + then uses ``#include "foo.h"``. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-to-request-or-suppress-errors-and-warnings.rst b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-to-request-or-suppress-errors-and-warnings.rst new file mode 100644 index 00000000000..871fe57aab8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-command-options/options-to-request-or-suppress-errors-and-warnings.rst @@ -0,0 +1,411 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: options, warnings, options, errors, warnings, suppressing, messages, error, messages, warning, suppressing warnings + +.. _error-and-warning-options: + +Options to request or suppress errors and warnings +************************************************** + +Errors are diagnostic messages that report that the GNU Fortran compiler +cannot compile the relevant piece of source code. The compiler will +continue to process the program in an attempt to report further errors +to aid in debugging, but will not produce any compiled output. + +Warnings are diagnostic messages that report constructions which +are not inherently erroneous but which are risky or suggest there is +likely to be a bug in the program. Unless :option:`-Werror` is specified, +they do not prevent compilation of the program. + +You can request many specific warnings with options beginning :option:`-W`, +for example :option:`-Wimplicit` to request warnings on implicit +declarations. Each of these specific warning options also has a +negative form beginning :option:`-Wno-` to turn off warnings; +for example, :option:`-Wno-implicit`. This manual lists only one of the +two forms, whichever is not the default. + +These options control the amount and kinds of errors and warnings produced +by GNU Fortran: + +.. index:: fmax-errors=n, errors, limiting + +.. option:: -fmax-errors={n} + + Limits the maximum number of error messages to :samp:`{n}`, at which point + GNU Fortran bails out rather than attempting to continue processing the + source code. If :samp:`{n}` is 0, there is no limit on the number of error + messages produced. + +.. index:: fsyntax-only, syntax checking + +.. option:: -fsyntax-only + + Check the code for syntax errors, but do not actually compile it. This + will generate module files for each module present in the code, but no + other output file. + +.. index:: pedantic, Wpedantic + +.. option:: -Wpedantic, -pedantic + + Issue warnings for uses of extensions to Fortran. + :option:`-pedantic` also applies to C-language constructs where they + occur in GNU Fortran source files, such as use of :samp:`\\e` in a + character constant within a directive like ``#include``. + + Valid Fortran programs should compile properly with or without + this option. + However, without this option, certain GNU extensions and traditional + Fortran features are supported as well. + With this option, many of them are rejected. + + Some users try to use :option:`-pedantic` to check programs for conformance. + They soon find that it does not do quite what they want---it finds some + nonstandard practices, but not all. + However, improvements to GNU Fortran in this area are welcome. + + This should be used in conjunction with :option:`-std=f95`, + :option:`-std=f2003`, :option:`-std=f2008` or :option:`-std=f2018`. + +.. index:: pedantic-errors + +.. option:: -pedantic-errors + + Like :option:`-pedantic`, except that errors are produced rather than + warnings. + +.. index:: Wall, all warnings, warnings, all + +.. option:: -Wall + + Enables commonly used warning options pertaining to usage that + we recommend avoiding and that we believe are easy to avoid. + This currently includes :option:`-Waliasing`, :option:`-Wampersand`, + :option:`-Wconversion`, :option:`-Wsurprising`, :option:`-Wc-binding-type`, + :option:`-Wintrinsics-std`, :option:`-Wtabs`, :option:`-Wintrinsic-shadow`, + :option:`-Wline-truncation`, :option:`-Wtarget-lifetime`, + :option:`-Winteger-division`, :option:`-Wreal-q-constant`, :option:`-Wunused` + and :option:`-Wundefined-do-loop`. + +.. index:: Waliasing, aliasing, warnings, aliasing + +.. option:: -Waliasing + + Warn about possible aliasing of dummy arguments. Specifically, it warns + if the same actual argument is associated with a dummy argument with + ``INTENT(IN)`` and a dummy argument with ``INTENT(OUT)`` in a call + with an explicit interface. + + The following example will trigger the warning. + + .. code-block:: fortran + + interface + subroutine bar(a,b) + integer, intent(in) :: a + integer, intent(out) :: b + end subroutine + end interface + integer :: a + + call bar(a,a) + +.. index:: Wampersand, warnings, ampersand, & + +.. option:: -Wampersand + + Warn about missing ampersand in continued character constants. The + warning is given with :option:`-Wampersand`, :option:`-pedantic`, + :option:`-std=f95`, :option:`-std=f2003`, :option:`-std=f2008` and + :option:`-std=f2018`. Note: With no ampersand given in a continued + character constant, GNU Fortran assumes continuation at the first + non-comment, non-whitespace character after the ampersand that + initiated the continuation. + +.. index:: Warray-temporaries, warnings, array temporaries + +.. option:: -Warray-temporaries + + Warn about array temporaries generated by the compiler. The information + generated by this warning is sometimes useful in optimization, in order to + avoid such temporaries. + +.. index:: Wc-binding-type, warning, C binding type + +.. option:: -Wc-binding-type + + Warn if the a variable might not be C interoperable. In particular, warn if + the variable has been declared using an intrinsic type with default kind + instead of using a kind parameter defined for C interoperability in the + intrinsic ``ISO_C_Binding`` module. This option is implied by + :option:`-Wall`. + +.. index:: Wcharacter-truncation, warnings, character truncation + +.. option:: -Wcharacter-truncation + + Warn when a character assignment will truncate the assigned string. + +.. index:: Wline-truncation, warnings, line truncation + +.. option:: -Wline-truncation + + Warn when a source code line will be truncated. This option is + implied by :option:`-Wall`. For free-form source code, the default is + :option:`-Werror=line-truncation` such that truncations are reported as + error. + +.. index:: Wconversion, warnings, conversion, conversion + +.. option:: -Wconversion + + Warn about implicit conversions that are likely to change the value of + the expression after conversion. Implied by :option:`-Wall`. + +.. index:: Wconversion-extra, warnings, conversion, conversion + +.. option:: -Wconversion-extra + + Warn about implicit conversions between different types and kinds. This + option does *not* imply :option:`-Wconversion`. + +.. index:: Wextra, extra warnings, warnings, extra + +.. option:: -Wextra + + Enables some warning options for usages of language features which + may be problematic. This currently includes :option:`-Wcompare-reals`, + :option:`-Wunused-parameter` and :option:`-Wdo-subscript`. + +.. index:: Wfrontend-loop-interchange, warnings, loop interchange, loop interchange, warning + +.. option:: -Wfrontend-loop-interchange + + Warn when using :option:`-ffrontend-loop-interchange` for performing loop + interchanges. + +.. index:: Wimplicit-interface, warnings, implicit interface + +.. option:: -Wimplicit-interface + + Warn if a procedure is called without an explicit interface. + Note this only checks that an explicit interface is present. It does not + check that the declared interfaces are consistent across program units. + +.. index:: Wimplicit-procedure, warnings, implicit procedure + +.. option:: -Wimplicit-procedure + + Warn if a procedure is called that has neither an explicit interface + nor has been declared as ``EXTERNAL``. + +.. index:: Winteger-division, warnings, integer division, warnings, division of integers + +.. option:: -Winteger-division + + Warn if a constant integer division truncates its result. + As an example, 3/5 evaluates to 0. + +.. index:: Wintrinsics-std, warnings, non-standard intrinsics, warnings, intrinsics of other standards + +.. option:: -Wintrinsics-std + + Warn if :command:`gfortran` finds a procedure named like an intrinsic not + available in the currently selected standard (with :option:`-std`) and treats + it as ``EXTERNAL`` procedure because of this. :option:`-fall-intrinsics` can + be used to never trigger this behavior and always link to the intrinsic + regardless of the selected standard. + +.. index:: Woverwrite-recursive, warnings, overwrite recursive + +.. option:: -Wno-overwrite-recursive + + Do not warn when :option:`-fno-automatic` is used with :option:`-frecursive`. Recursion + will be broken if the relevant local variables do not have the attribute + ``AUTOMATIC`` explicitly declared. This option can be used to suppress the warning + when it is known that recursion is not broken. Useful for build environments that use + :option:`-Werror`. + +.. index:: Wreal-q-constant, warnings, q exponent-letter + +.. option:: -Wreal-q-constant + + Produce a warning if a real-literal-constant contains a ``q`` + exponent-letter. + +.. index:: Wsurprising, warnings, suspicious code + +.. option:: -Wsurprising + + Produce a warning when 'suspicious' code constructs are encountered. + While technically legal these usually indicate that an error has been made. + + This currently produces a warning under the following circumstances: + + * An INTEGER SELECT construct has a CASE that can never be matched as its + lower value is greater than its upper value. + + * A LOGICAL SELECT construct has three CASE statements. + + * A TRANSFER specifies a source that is shorter than the destination. + + * The type of a function result is declared more than once with the same type. If + :option:`-pedantic` or standard-conforming mode is enabled, this is an error. + + * A ``CHARACTER`` variable is declared with negative length. + + * With :option:`-fopenmp`, for fixed-form source code, when an ``omx`` + vendor-extension sentinel is encountered. (The equivalent ``ompx``, + used in free-form source code, is diagnosed by default.) + +.. index:: Wtabs, warnings, tabs, tabulators + +.. option:: -Wtabs + + By default, tabs are accepted as whitespace, but tabs are not members + of the Fortran Character Set. For continuation lines, a tab followed + by a digit between 1 and 9 is supported. :option:`-Wtabs` will cause a + warning to be issued if a tab is encountered. Note, :option:`-Wtabs` is + active for :option:`-pedantic`, :option:`-std=f95`, :option:`-std=f2003`, + :option:`-std=f2008`, :option:`-std=f2018` and + :option:`-Wall`. + +.. index:: Wundefined-do-loop, warnings, undefined do loop + +.. option:: -Wundefined-do-loop + + Warn if a DO loop with step either 1 or -1 yields an underflow or an overflow + during iteration of an induction variable of the loop. + This option is implied by :option:`-Wall`. + +.. index:: Wunderflow, warnings, underflow, underflow + +.. option:: -Wunderflow + + Produce a warning when numerical constant expressions are + encountered, which yield an UNDERFLOW during compilation. Enabled by default. + +.. index:: Wintrinsic-shadow, warnings, intrinsic, intrinsic + +.. option:: -Wintrinsic-shadow + + Warn if a user-defined procedure or module procedure has the same name as an + intrinsic; in this case, an explicit interface or ``EXTERNAL`` or + ``INTRINSIC`` declaration might be needed to get calls later resolved to + the desired intrinsic/procedure. This option is implied by :option:`-Wall`. + +.. index:: Wuse-without-only, warnings, use statements, intrinsic + +.. option:: -Wuse-without-only + + Warn if a ``USE`` statement has no ``ONLY`` qualifier and + thus implicitly imports all public entities of the used module. + +.. index:: Wunused-dummy-argument, warnings, unused dummy argument, unused dummy argument, dummy argument, unused + +.. option:: -Wunused-dummy-argument + + Warn about unused dummy arguments. This option is implied by :option:`-Wall`. + +.. index:: Wunused-parameter, warnings, unused parameter, unused parameter + +.. option:: -Wunused-parameter + + Contrary to :command:`gcc`'s meaning of :option:`-Wunused-parameter`, + :command:`gfortran`'s implementation of this option does not warn + about unused dummy arguments (see :option:`-Wunused-dummy-argument`), + but about unused ``PARAMETER`` values. :option:`-Wunused-parameter` + is implied by :option:`-Wextra` if also :option:`-Wunused` or + :option:`-Wall` is used. + +.. index:: Walign-commons, warnings, alignment of COMMON blocks, alignment of COMMON blocks + +.. option:: -Walign-commons + + By default, :command:`gfortran` warns about any occasion of variables being + padded for proper alignment inside a ``COMMON`` block. This warning can be turned + off via :option:`-Wno-align-commons`. See also :option:`-falign-commons`. + +.. index:: Wfunction-elimination, function elimination, warnings, function elimination + +.. option:: -Wfunction-elimination + + Warn if any calls to impure functions are eliminated by the optimizations + enabled by the :option:`-ffrontend-optimize` option. + This option is implied by :option:`-Wextra`. + +.. index:: Wrealloc-lhs, Reallocate the LHS in assignments, notification + +.. option:: -Wrealloc-lhs + + Warn when the compiler might insert code to for allocation or reallocation of + an allocatable array variable of intrinsic type in intrinsic assignments. In + hot loops, the Fortran 2003 reallocation feature may reduce the performance. + If the array is already allocated with the correct shape, consider using a + whole-array array-spec (e.g. ``(:,:,:)``) for the variable on the left-hand + side to prevent the reallocation check. Note that in some cases the warning + is shown, even if the compiler will optimize reallocation checks away. For + instance, when the right-hand side contains the same variable multiplied by + a scalar. See also :option:`-frealloc-lhs`. + +.. index:: Wrealloc-lhs-all + +.. option:: -Wrealloc-lhs-all + + Warn when the compiler inserts code to for allocation or reallocation of an + allocatable variable; this includes scalars and derived types. + +.. index:: Wcompare-reals + +.. option:: -Wcompare-reals + + Warn when comparing real or complex types for equality or inequality. + This option is implied by :option:`-Wextra`. + +.. index:: Wtargt-lifetime + +.. option:: -Wtarget-lifetime + + Warn if the pointer in a pointer assignment might be longer than the its + target. This option is implied by :option:`-Wall`. + +.. index:: Wzerotrip + +.. option:: -Wzerotrip + + Warn if a ``DO`` loop is known to execute zero times at compile + time. This option is implied by :option:`-Wall`. + +.. index:: Wdo-subscript + +.. option:: -Wdo-subscript + + Warn if an array subscript inside a DO loop could lead to an + out-of-bounds access even if the compiler cannot prove that the + statement is actually executed, in cases like + + .. code-block:: fortran + + real a(3) + do i=1,4 + if (condition(i)) then + a(i) = 1.2 + end if + end do + + This option is implied by :option:`-Wextra`. + +.. index:: Werror, warnings, to errors + +.. option:: -Werror + + Turns all warnings into errors. + +See :ref:`gcc:warning-options`, for information on +more options offered by the GBE shared by :command:`gfortran`, :command:`gcc` +and other GNU compilers. + +Some of these have no effect when compiling programs written in Fortran. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-fortran-compiler-directives.rst b/gcc/fortran/doc/gfortran/gnu-fortran-compiler-directives.rst new file mode 100644 index 00000000000..966be29452f --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-fortran-compiler-directives.rst @@ -0,0 +1,174 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gnu-fortran-compiler-directives: + +GNU Fortran Compiler Directives +******************************* + +.. toctree:: + :maxdepth: 2 + + +.. _attributes-directive: + +ATTRIBUTES directive +^^^^^^^^^^^^^^^^^^^^ + +The Fortran standard describes how a conforming program shall +behave; however, the exact implementation is not standardized. In order +to allow the user to choose specific implementation details, compiler +directives can be used to set attributes of variables and procedures +which are not part of the standard. Whether a given attribute is +supported and its exact effects depend on both the operating system and +on the processor; see +:ref:`gcc:top` +for details. + +For procedures and procedure pointers, the following attributes can +be used to change the calling convention: + +* ``CDECL`` -- standard C calling convention + +* ``STDCALL`` -- convention where the called procedure pops the stack + +* ``FASTCALL`` -- part of the arguments are passed via registers + instead using the stack + +Besides changing the calling convention, the attributes also influence +the decoration of the symbol name, e.g., by a leading underscore or by +a trailing at-sign followed by the number of bytes on the stack. When +assigning a procedure to a procedure pointer, both should use the same +calling convention. + +On some systems, procedures and global variables (module variables and +``COMMON`` blocks) need special handling to be accessible when they +are in a shared library. The following attributes are available: + +* ``DLLEXPORT`` -- provide a global pointer to a pointer in the DLL + +* ``DLLIMPORT`` -- reference the function or variable using a + global pointer + +For dummy arguments, the ``NO_ARG_CHECK`` attribute can be used; in +other compilers, it is also known as ``IGNORE_TKR``. For dummy arguments +with this attribute actual arguments of any type and kind (similar to +``TYPE(*)``), scalars and arrays of any rank (no equivalent +in Fortran standard) are accepted. As with ``TYPE(*)``, the argument +is unlimited polymorphic and no type information is available. +Additionally, the argument may only be passed to dummy arguments +with the ``NO_ARG_CHECK`` attribute and as argument to the +``PRESENT`` intrinsic function and to ``C_LOC`` of the +``ISO_C_BINDING`` module. + +Variables with ``NO_ARG_CHECK`` attribute shall be of assumed-type +(``TYPE(*)`` ; recommended) or of type ``INTEGER``, ``LOGICAL``, +``REAL`` or ``COMPLEX``. They shall not have the ``ALLOCATE``, +``CODIMENSION``, ``INTENT(OUT)``, ``POINTER`` or ``VALUE`` +attribute; furthermore, they shall be either scalar or of assumed-size +(``dimension(*)``). As ``TYPE(*)``, the ``NO_ARG_CHECK`` attribute +requires an explicit interface. + +* ``NO_ARG_CHECK`` -- disable the type, kind and rank checking + +* ``DEPRECATED`` -- print a warning when using a such-tagged + deprecated procedure, variable or parameter; the warning can be suppressed + with :option:`-Wno-deprecated-declarations`. + +The attributes are specified using the syntax + +``!GCC$ ATTRIBUTES`` :samp:`{attribute-list}` ``::`` :samp:`{variable-list}` + +where in free-form source code only whitespace is allowed before ``!GCC$`` +and in fixed-form source code ``!GCC$``, ``cGCC$`` or ``*GCC$`` shall +start in the first column. + +For procedures, the compiler directives shall be placed into the body +of the procedure; for variables and procedure pointers, they shall be in +the same declaration part as the variable or procedure pointer. + +.. _unroll-directive: + +UNROLL directive +^^^^^^^^^^^^^^^^ + +The syntax of the directive is + +``!GCC$ unroll N`` + +You can use this directive to control how many times a loop should be unrolled. +It must be placed immediately before a ``DO`` loop and applies only to the +loop that follows. N is an integer constant specifying the unrolling factor. +The values of 0 and 1 block any unrolling of the loop. + +.. _builtin-directive: + +BUILTIN directive +^^^^^^^^^^^^^^^^^ + +The syntax of the directive is + +``!GCC$ BUILTIN (B) attributes simd FLAGS IF('target')`` + +You can use this directive to define which middle-end built-ins provide vector +implementations. ``B`` is name of the middle-end built-in. ``FLAGS`` +are optional and must be either "(inbranch)" or "(notinbranch)". +``IF`` statement is optional and is used to filter multilib ABIs +for the built-in that should be vectorized. Example usage: + +.. code-block:: fortran + + !GCC$ builtin (sinf) attributes simd (notinbranch) if('x86_64') + +The purpose of the directive is to provide an API among the GCC compiler and +the GNU C Library which would define vector implementations of math routines. + +.. _ivdep-directive: + +IVDEP directive +^^^^^^^^^^^^^^^ + +The syntax of the directive is + +``!GCC$ ivdep`` + +This directive tells the compiler to ignore vector dependencies in the +following loop. It must be placed immediately before a ``DO`` loop +and applies only to the loop that follows. + +Sometimes the compiler may not have sufficient information to decide +whether a particular loop is vectorizable due to potential +dependencies between iterations. The purpose of the directive is to +tell the compiler that vectorization is safe. + +This directive is intended for annotation of existing code. For new +code it is recommended to consider OpenMP SIMD directives as potential +alternative. + +.. _vector-directive: + +VECTOR directive +^^^^^^^^^^^^^^^^ + +The syntax of the directive is + +``!GCC$ vector`` + +This directive tells the compiler to vectorize the following loop. It +must be placed immediately before a ``DO`` loop and applies only to +the loop that follows. + +.. _novector-directive: + +NOVECTOR directive +^^^^^^^^^^^^^^^^^^ + +The syntax of the directive is + +``!GCC$ novector`` + +This directive tells the compiler to not vectorize the following loop. +It must be placed immediately before a ``DO`` loop and applies only +to the loop that follows. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/gnu-free-documentation-license.rst b/gcc/fortran/doc/gfortran/gnu-free-documentation-license.rst new file mode 100644 index 00000000000..9a3dac670fa --- /dev/null +++ b/gcc/fortran/doc/gfortran/gnu-free-documentation-license.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../../doc/gnu_free_documentation_license.rst \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/index.rst b/gcc/fortran/doc/gfortran/index.rst new file mode 100644 index 00000000000..312da781379 --- /dev/null +++ b/gcc/fortran/doc/gfortran/index.rst @@ -0,0 +1,56 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +The GNU Fortran Compiler +======================== + +.. index:: Introduction + +This manual documents the use of :command:`gfortran`, +the GNU Fortran compiler. You can find in this manual how to invoke +:command:`gfortran`, as well as its features and incompatibilities. + +.. only:: development + + .. warning:: + + This document, and the compiler it describes, are still + under development. While efforts are made to keep it up-to-date, it might + not accurately reflect the status of the most recent GNU Fortran compiler. + +.. toctree:: + :maxdepth: 3 + + copyright + introduction + +Part I: Invoking GNU Fortran +---------------------------- + +.. toctree:: + :maxdepth: 3 + + gnu-fortran-command-options + runtime + +Part II: Language Reference +--------------------------- + +.. toctree:: + :maxdepth: 3 + + compiler-characteristics + extensions + mixed-language-programming + coarray-programming + intrinsic-procedures + intrinsic-modules + + contributing + general-public-license-3 + gnu-free-documentation-license + funding + + indices-and-tables \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/indices-and-tables.rst b/gcc/fortran/doc/gfortran/indices-and-tables.rst new file mode 100644 index 00000000000..50865c6ecb2 --- /dev/null +++ b/gcc/fortran/doc/gfortran/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/interoperability-with-c.rst b/gcc/fortran/doc/gfortran/interoperability-with-c.rst new file mode 100644 index 00000000000..52364ad3ed0 --- /dev/null +++ b/gcc/fortran/doc/gfortran/interoperability-with-c.rst @@ -0,0 +1,413 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: interoperability with C, C interoperability + +.. _interoperability-with-c: + +Interoperability with C +*********************** + +.. toctree:: + :maxdepth: 2 + +Since Fortran 2003 (ISO/IEC 1539-1:2004(E)) there is a +standardized way to generate procedure and derived-type +declarations and global variables that are interoperable with C +(ISO/IEC 9899:1999). The ``BIND(C)`` attribute has been added +to inform the compiler that a symbol shall be interoperable with C; +also, some constraints are added. Note, however, that not +all C features have a Fortran equivalent or vice versa. For instance, +neither C's unsigned integers nor C's functions with variable number +of arguments have an equivalent in Fortran. + +Note that array dimensions are reversely ordered in C and that arrays in +C always start with index 0 while in Fortran they start by default with +1. Thus, an array declaration ``A(n,m)`` in Fortran matches +``A[m][n]`` in C and accessing the element ``A(i,j)`` matches +``A[j-1][i-1]``. The element following ``A(i,j)`` (C: ``A[j-1][i-1]`` ; +assuming i < n) in memory is ``A(i+1,j)`` (C: ``A[j-1][i]``). + +.. index:: C intrinsic type interoperability, intrinsic type interoperability with C, interoperability, intrinsic type + +.. _intrinsic-types: + +Intrinsic Types +^^^^^^^^^^^^^^^ + +In order to ensure that exactly the same variable type and kind is used +in C and Fortran, you should use the named constants for kind parameters +that are defined in the ``ISO_C_BINDING`` intrinsic module. +That module contains named constants of character type representing +the escaped special characters in C, such as newline. +For a list of the constants, see :ref:`ISO_C_BINDING`. + +For logical types, please note that the Fortran standard only guarantees +interoperability between C99's ``_Bool`` and Fortran's ``C_Bool`` -kind +logicals and C99 defines that ``true`` has the value 1 and ``false`` +the value 0. Using any other integer value with GNU Fortran's ``LOGICAL`` +(with any kind parameter) gives an undefined result. (Passing other integer +values than 0 and 1 to GCC's ``_Bool`` is also undefined, unless the +integer is explicitly or implicitly casted to ``_Bool``.) + +.. index:: C derived type and struct interoperability, derived type interoperability with C, interoperability, derived type and struct + +.. _derived-types-and-struct: + +Derived Types and struct +^^^^^^^^^^^^^^^^^^^^^^^^ + +For compatibility of derived types with ``struct``, use +the ``BIND(C)`` attribute in the type declaration. For instance, the +following type declaration + +.. code-block:: fortran + + USE ISO_C_BINDING + TYPE, BIND(C) :: myType + INTEGER(C_INT) :: i1, i2 + INTEGER(C_SIGNED_CHAR) :: i3 + REAL(C_DOUBLE) :: d1 + COMPLEX(C_FLOAT_COMPLEX) :: c1 + CHARACTER(KIND=C_CHAR) :: str(5) + END TYPE + +matches the following ``struct`` declaration in C + +.. code-block:: c + + struct { + int i1, i2; + /* Note: "char" might be signed or unsigned. */ + signed char i3; + double d1; + float _Complex c1; + char str[5]; + } myType; + +Derived types with the C binding attribute shall not have the ``sequence`` +attribute, type parameters, the ``extends`` attribute, nor type-bound +procedures. Every component must be of interoperable type and kind and may not +have the ``pointer`` or ``allocatable`` attribute. The names of the +components are irrelevant for interoperability. + +As there exist no direct Fortran equivalents, neither unions nor structs +with bit field or variable-length array members are interoperable. + +.. index:: C variable interoperability, variable interoperability with C, interoperability, variable + +.. _interoperable-global-variables: + +Interoperable Global Variables +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Variables can be made accessible from C using the C binding attribute, +optionally together with specifying a binding name. Those variables +have to be declared in the declaration part of a ``MODULE``, +be of interoperable type, and have neither the ``pointer`` nor +the ``allocatable`` attribute. + +.. code-block:: fortran + + MODULE m + USE myType_module + USE ISO_C_BINDING + integer(C_INT), bind(C, name="_MyProject_flags") :: global_flag + type(myType), bind(C) :: tp + END MODULE + +Here, ``_MyProject_flags`` is the case-sensitive name of the variable +as seen from C programs while ``global_flag`` is the case-insensitive +name as seen from Fortran. If no binding name is specified, as for +:samp:`{tp}`, the C binding name is the (lowercase) Fortran binding name. +If a binding name is specified, only a single variable may be after the +double colon. Note of warning: You cannot use a global variable to +access :samp:`{errno}` of the C library as the C standard allows it to be +a macro. Use the ``IERRNO`` intrinsic (GNU extension) instead. + +.. index:: C procedure interoperability, procedure interoperability with C, function interoperability with C, subroutine interoperability with C, interoperability, subroutine and function + +.. _interoperable-subroutines-and-functions: + +Interoperable Subroutines and Functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Subroutines and functions have to have the ``BIND(C)`` attribute to +be compatible with C. The dummy argument declaration is relatively +straightforward. However, one needs to be careful because C uses +call-by-value by default while Fortran behaves usually similar to +call-by-reference. Furthermore, strings and pointers are handled +differently. + +To pass a variable by value, use the ``VALUE`` attribute. +Thus, the following C prototype + +.. code-block:: fortran + + int func(int i, int *j) + +matches the Fortran declaration + +.. code-block:: fortran + + integer(c_int) function func(i,j) + use iso_c_binding, only: c_int + integer(c_int), VALUE :: i + integer(c_int) :: j + +Note that pointer arguments also frequently need the ``VALUE`` attribute, +see :ref:`working-with-c-pointers`. + +Strings are handled quite differently in C and Fortran. In C a string +is a ``NUL`` -terminated array of characters while in Fortran each string +has a length associated with it and is thus not terminated (by e.g. +``NUL``). For example, if you want to use the following C function, + +.. code-block:: c + + #include + void print_C(char *string) /* equivalent: char string[] */ + { + printf("%s\n", string); + } + +to print 'Hello World' from Fortran, you can call it using + +.. code-block:: fortran + + use iso_c_binding, only: C_CHAR, C_NULL_CHAR + interface + subroutine print_c(string) bind(C, name="print_C") + use iso_c_binding, only: c_char + character(kind=c_char) :: string(*) + end subroutine print_c + end interface + call print_c(C_CHAR_"Hello World"//C_NULL_CHAR) + +As the example shows, you need to ensure that the +string is ``NUL`` terminated. Additionally, the dummy argument +:samp:`{string}` of ``print_C`` is a length-one assumed-size +array; using ``character(len=*)`` is not allowed. The example +above uses ``c_char_"Hello World"`` to ensure the string +literal has the right type; typically the default character +kind and ``c_char`` are the same and thus ``"Hello World"`` +is equivalent. However, the standard does not guarantee this. + +The use of strings is now further illustrated using the C library +function ``strncpy``, whose prototype is + +.. code-block:: c + + char *strncpy(char *restrict s1, const char *restrict s2, size_t n); + +The function ``strncpy`` copies at most :samp:`{n}` characters from +string :samp:`{s2}` to :samp:`{s1}` and returns :samp:`{s1}`. In the following +example, we ignore the return value: + +.. code-block:: fortran + + use iso_c_binding + implicit none + character(len=30) :: str,str2 + interface + ! Ignore the return value of strncpy -> subroutine + ! "restrict" is always assumed if we do not pass a pointer + subroutine strncpy(dest, src, n) bind(C) + import + character(kind=c_char), intent(out) :: dest(*) + character(kind=c_char), intent(in) :: src(*) + integer(c_size_t), value, intent(in) :: n + end subroutine strncpy + end interface + str = repeat('X',30) ! Initialize whole string with 'X' + call strncpy(str, c_char_"Hello World"//C_NULL_CHAR, & + len(c_char_"Hello World",kind=c_size_t)) + print '(a)', str ! prints: "Hello WorldXXXXXXXXXXXXXXXXXXX" + end + +The intrinsic procedures are described in :ref:`intrinsic-procedures`. + +.. index:: C pointers, pointers, C + +.. _working-with-c-pointers: + +Working with C Pointers +^^^^^^^^^^^^^^^^^^^^^^^ + +C pointers are represented in Fortran via the special opaque derived +type ``type(c_ptr)`` (with private components). C pointers are distinct +from Fortran objects with the ``POINTER`` attribute. Thus one needs to +use intrinsic conversion procedures to convert from or to C pointers. +For some applications, using an assumed type (``TYPE(*)``) can be +an alternative to a C pointer, and you can also use library routines +to access Fortran pointers from C. See :ref:`further-interoperability-of-fortran-with-c`. + +Here is an example of using C pointers in Fortran: + +.. code-block:: fortran + + use iso_c_binding + type(c_ptr) :: cptr1, cptr2 + integer, target :: array(7), scalar + integer, pointer :: pa(:), ps + cptr1 = c_loc(array(1)) ! The programmer needs to ensure that the + ! array is contiguous if required by the C + ! procedure + cptr2 = c_loc(scalar) + call c_f_pointer(cptr2, ps) + call c_f_pointer(cptr2, pa, shape=[7]) + +When converting C to Fortran arrays, the one-dimensional ``SHAPE`` argument +has to be passed. + +If a pointer is a dummy argument of an interoperable procedure, it usually +has to be declared using the ``VALUE`` attribute. ``void*`` +matches ``TYPE(C_PTR), VALUE``, while ``TYPE(C_PTR)`` alone +matches ``void**``. + +Procedure pointers are handled analogously to pointers; the C type is +``TYPE(C_FUNPTR)`` and the intrinsic conversion procedures are +``C_F_PROCPOINTER`` and ``C_FUNLOC``. + +Let us consider two examples of actually passing a procedure pointer from +C to Fortran and vice versa. Note that these examples are also very +similar to passing ordinary pointers between both languages. First, +consider this code in C: + +.. code-block:: c + + /* Procedure implemented in Fortran. */ + void get_values (void (*)(double)); + + /* Call-back routine we want called from Fortran. */ + void + print_it (double x) + { + printf ("Number is %f.\n", x); + } + + /* Call Fortran routine and pass call-back to it. */ + void + foobar () + { + get_values (&print_it); + } + +A matching implementation for ``get_values`` in Fortran, that correctly +receives the procedure pointer from C and is able to call it, is given +in the following ``MODULE`` : + +.. code-block:: fortran + + MODULE m + IMPLICIT NONE + + ! Define interface of call-back routine. + ABSTRACT INTERFACE + SUBROUTINE callback (x) + USE, INTRINSIC :: ISO_C_BINDING + REAL(KIND=C_DOUBLE), INTENT(IN), VALUE :: x + END SUBROUTINE callback + END INTERFACE + + CONTAINS + + ! Define C-bound procedure. + SUBROUTINE get_values (cproc) BIND(C) + USE, INTRINSIC :: ISO_C_BINDING + TYPE(C_FUNPTR), INTENT(IN), VALUE :: cproc + + PROCEDURE(callback), POINTER :: proc + + ! Convert C to Fortran procedure pointer. + CALL C_F_PROCPOINTER (cproc, proc) + + ! Call it. + CALL proc (1.0_C_DOUBLE) + CALL proc (-42.0_C_DOUBLE) + CALL proc (18.12_C_DOUBLE) + END SUBROUTINE get_values + + END MODULE m + +Next, we want to call a C routine that expects a procedure pointer argument +and pass it a Fortran procedure (which clearly must be interoperable!). +Again, the C function may be: + +.. code-block:: c + + int + call_it (int (*func)(int), int arg) + { + return func (arg); + } + +It can be used as in the following Fortran code: + +.. code-block:: fortran + + MODULE m + USE, INTRINSIC :: ISO_C_BINDING + IMPLICIT NONE + + ! Define interface of C function. + INTERFACE + INTEGER(KIND=C_INT) FUNCTION call_it (func, arg) BIND(C) + USE, INTRINSIC :: ISO_C_BINDING + TYPE(C_FUNPTR), INTENT(IN), VALUE :: func + INTEGER(KIND=C_INT), INTENT(IN), VALUE :: arg + END FUNCTION call_it + END INTERFACE + + CONTAINS + + ! Define procedure passed to C function. + ! It must be interoperable! + INTEGER(KIND=C_INT) FUNCTION double_it (arg) BIND(C) + INTEGER(KIND=C_INT), INTENT(IN), VALUE :: arg + double_it = arg + arg + END FUNCTION double_it + + ! Call C function. + SUBROUTINE foobar () + TYPE(C_FUNPTR) :: cproc + INTEGER(KIND=C_INT) :: i + + ! Get C procedure pointer. + cproc = C_FUNLOC (double_it) + + ! Use it. + DO i = 1_C_INT, 10_C_INT + PRINT *, call_it (cproc, i) + END DO + END SUBROUTINE foobar + + END MODULE m + +.. index:: Further Interoperability of Fortran with C, TS 29113, array descriptor, dope vector, assumed-type, assumed-rank + +.. _further-interoperability-of-fortran-with-c: + +Further Interoperability of Fortran with C +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +GNU Fortran implements the Technical Specification ISO/IEC TS +29113:2012, which extends the interoperability support of Fortran 2003 +and Fortran 2008 and is now part of the 2018 Fortran standard. +Besides removing some restrictions and constraints, the Technical +Specification adds assumed-type (``TYPE(*)``) and assumed-rank +(``DIMENSION(..)``) variables and allows for interoperability of +assumed-shape, assumed-rank, and deferred-shape arrays, as well as +allocatables and pointers. Objects of these types are passed to +``BIND(C)`` functions as descriptors with a standard interface, +declared in the header file ````. + +Note: Currently, GNU Fortran does not use internally the array descriptor +(dope vector) as specified in the Technical Specification, but uses +an array descriptor with different fields in functions without the +``BIND(C)`` attribute. Arguments to functions marked ``BIND(C)`` +are converted to the specified form. If you need to access GNU Fortran's +internal array descriptor, you can use the Chasm Language Interoperability +Tools, http://chasm-interop.sourceforge.net/. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-modules.rst b/gcc/fortran/doc/gfortran/intrinsic-modules.rst new file mode 100644 index 00000000000..3768d4f99f9 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-modules.rst @@ -0,0 +1,20 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: intrinsic Modules + +.. _intrinsic-modules: + +Intrinsic Modules +----------------- + +.. toctree:: + :maxdepth: 2 + + intrinsic-modules/openacc-module-openacc + intrinsic-modules/isofortranenv + intrinsic-modules/isocbinding + intrinsic-modules/ieee-modules-ieeeexceptions-ieeearithmetic-and-ieeefeatures + intrinsic-modules/openmp-modules-omplib-and-omplibkinds \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-modules/ieee-modules-ieeeexceptions-ieeearithmetic-and-ieeefeatures.rst b/gcc/fortran/doc/gfortran/intrinsic-modules/ieee-modules-ieeeexceptions-ieeearithmetic-and-ieeefeatures.rst new file mode 100644 index 00000000000..4bdf249176f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-modules/ieee-modules-ieeeexceptions-ieeearithmetic-and-ieeefeatures.rst @@ -0,0 +1,29 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ieee-modules: + +IEEE modules: IEEE_EXCEPTIONS, IEEE_ARITHMETIC, and IEEE_FEATURES +***************************************************************** + +:samp:`{Standard}:` + Fortran 2003 and later + + The ``IEEE_EXCEPTIONS``, ``IEEE_ARITHMETIC``, and ``IEEE_FEATURES`` + intrinsic modules provide support for exceptions and IEEE arithmetic, as + defined in Fortran 2003 and later standards, and the IEC 60559:1989 standard + (*Binary floating-point arithmetic for microprocessor systems*). These + modules are only provided on the following supported platforms: + + * i386 and x86_64 processors + * platforms which use the GNU C Library (glibc) + * platforms with support for SysV/386 routines for floating point + interface (including Solaris and BSDs) + * platforms with the AIX OS + +For full compliance with the Fortran standards, code using the +``IEEE_EXCEPTIONS`` or ``IEEE_ARITHMETIC`` modules should be compiled +with the following options: ``-fno-unsafe-math-optimizations +-frounding-math -fsignaling-nans``. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-modules/isocbinding.rst b/gcc/fortran/doc/gfortran/intrinsic-modules/isocbinding.rst new file mode 100644 index 00000000000..3750edafe91 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-modules/isocbinding.rst @@ -0,0 +1,227 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _iso_c_binding: + +ISO_C_BINDING +************* + +:samp:`{Standard}:` + Fortran 2003 and later, GNU extensions + + The following intrinsic procedures are provided by the module; their + definition can be found in the section Intrinsic Procedures of this + manual. + +* C_ASSOCIATED +* C_F_POINTER +* C_F_PROCPOINTER +* C_FUNLOCC_LOC +* C_SIZEOF + +The ``ISO_C_BINDING`` module provides the following named constants of +type default integer, which can be used as KIND type parameters. + +In addition to the integer named constants required by the Fortran 2003 +standard and ``C_PTRDIFF_T`` of TS 29113, GNU Fortran provides as an +extension named constants for the 128-bit integer types supported by the +C compiler: ``C_INT128_T, C_INT_LEAST128_T, C_INT_FAST128_T``. +Furthermore, if ``_Float128`` is supported in C, the named constants +``C_FLOAT128`` and ``C_FLOAT128_COMPLEX`` are defined. + +.. list-table:: + :header-rows: 1 + + * - Fortran Type + - Named constant + - C type + - Extension + + * - ``INTEGER`` + - ``C_INT`` + - ``int`` + - + * - ``INTEGER`` + - ``C_SHORT`` + - ``short int`` + - + * - ``INTEGER`` + - ``C_LONG`` + - ``long int`` + - + * - ``INTEGER`` + - ``C_LONG_LONG`` + - ``long long int`` + - + * - ``INTEGER`` + - ``C_SIGNED_CHAR`` + - ``signed char`` / ``unsigned char`` + - + * - ``INTEGER`` + - ``C_SIZE_T`` + - ``size_t`` + - + * - ``INTEGER`` + - ``C_INT8_T`` + - ``int8_t`` + - + * - ``INTEGER`` + - ``C_INT16_T`` + - ``int16_t`` + - + * - ``INTEGER`` + - ``C_INT32_T`` + - ``int32_t`` + - + * - ``INTEGER`` + - ``C_INT64_T`` + - ``int64_t`` + - + * - ``INTEGER`` + - ``C_INT128_T`` + - ``int128_t`` + - Ext. + * - ``INTEGER`` + - ``C_INT_LEAST8_T`` + - ``int_least8_t`` + - + * - ``INTEGER`` + - ``C_INT_LEAST16_T`` + - ``int_least16_t`` + - + * - ``INTEGER`` + - ``C_INT_LEAST32_T`` + - ``int_least32_t`` + - + * - ``INTEGER`` + - ``C_INT_LEAST64_T`` + - ``int_least64_t`` + - + * - ``INTEGER`` + - ``C_INT_LEAST128_T`` + - ``int_least128_t`` + - Ext. + * - ``INTEGER`` + - ``C_INT_FAST8_T`` + - ``int_fast8_t`` + - + * - ``INTEGER`` + - ``C_INT_FAST16_T`` + - ``int_fast16_t`` + - + * - ``INTEGER`` + - ``C_INT_FAST32_T`` + - ``int_fast32_t`` + - + * - ``INTEGER`` + - ``C_INT_FAST64_T`` + - ``int_fast64_t`` + - + * - ``INTEGER`` + - ``C_INT_FAST128_T`` + - ``int_fast128_t`` + - Ext. + * - ``INTEGER`` + - ``C_INTMAX_T`` + - ``intmax_t`` + - + * - ``INTEGER`` + - ``C_INTPTR_T`` + - ``intptr_t`` + - + * - ``INTEGER`` + - ``C_PTRDIFF_T`` + - ``ptrdiff_t`` + - TS 29113 + * - ``REAL`` + - ``C_FLOAT`` + - ``float`` + - + * - ``REAL`` + - ``C_DOUBLE`` + - ``double`` + - + * - ``REAL`` + - ``C_LONG_DOUBLE`` + - ``long double`` + - + * - ``REAL`` + - ``C_FLOAT128`` + - ``_Float128`` + - Ext. + * - ``COMPLEX`` + - ``C_FLOAT_COMPLEX`` + - ``float _Complex`` + - + * - ``COMPLEX`` + - ``C_DOUBLE_COMPLEX`` + - ``double _Complex`` + - + * - ``COMPLEX`` + - ``C_LONG_DOUBLE_COMPLEX`` + - ``long double _Complex`` + - + * - ``COMPLEX`` + - ``C_FLOAT128_COMPLEX`` + - ``_Float128 _Complex`` + - Ext. + * - ``LOGICAL`` + - ``C_BOOL`` + - ``_Bool`` + - + * - ``CHARACTER`` + - ``C_CHAR`` + - ``char`` + - + +Additionally, the following parameters of type ``CHARACTER(KIND=C_CHAR)`` +are defined. + +.. list-table:: + :header-rows: 1 + + * - Name + - C definition + - Value + + * - ``C_NULL_CHAR`` + - null character + - ``'\0'`` + * - ``C_ALERT`` + - alert + - ``'\a'`` + * - ``C_BACKSPACE`` + - backspace + - ``'\b'`` + * - ``C_FORM_FEED`` + - form feed + - ``'\f'`` + * - ``C_NEW_LINE`` + - new line + - ``'\n'`` + * - ``C_CARRIAGE_RETURN`` + - carriage return + - ``'\r'`` + * - ``C_HORIZONTAL_TAB`` + - horizontal tab + - ``'\t'`` + * - ``C_VERTICAL_TAB`` + - vertical tab + - ``'\v'`` + +Moreover, the following two named constants are defined: + +.. list-table:: + :header-rows: 1 + + * - Name + - Type + + * - ``C_NULL_PTR`` + - ``C_PTR`` + * - ``C_NULL_FUNPTR`` + - ``C_FUNPTR`` + +Both are equivalent to the value ``NULL`` in C. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-modules/isofortranenv.rst b/gcc/fortran/doc/gfortran/intrinsic-modules/isofortranenv.rst new file mode 100644 index 00000000000..a03e1eb0e08 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-modules/isofortranenv.rst @@ -0,0 +1,116 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _iso_fortran_env: + +ISO_FORTRAN_ENV +*************** + +:samp:`{Standard}:` + Fortran 2003 and later, except when otherwise noted + + The ``ISO_FORTRAN_ENV`` module provides the following scalar default-integer named constants: + +:samp:`{ATOMIC_INT_KIND}:` + Default-kind integer constant to be used as kind parameter when defining + integer variables used in atomic operations. (Fortran 2008 or later.) + +:samp:`{ATOMIC_LOGICAL_KIND}:` + Default-kind integer constant to be used as kind parameter when defining + logical variables used in atomic operations. (Fortran 2008 or later.) + +:samp:`{CHARACTER_KINDS}:` + Default-kind integer constant array of rank one containing the supported kind + parameters of the ``CHARACTER`` type. (Fortran 2008 or later.) + +:samp:`{CHARACTER_STORAGE_SIZE}:` + Size in bits of the character storage unit. + +:samp:`{ERROR_UNIT}:` + Identifies the preconnected unit used for error reporting. + +:samp:`{FILE_STORAGE_SIZE}:` + Size in bits of the file-storage unit. + +:samp:`{INPUT_UNIT}:` + Identifies the preconnected unit identified by the asterisk + (``*``) in ``READ`` statement. + +:samp:`{INT8}, {INT16}, {INT32}, {INT64}:` + Kind type parameters to specify an INTEGER type with a storage + size of 16, 32, and 64 bits. It is negative if a target platform + does not support the particular kind. (Fortran 2008 or later.) + +:samp:`{INTEGER_KINDS}:` + Default-kind integer constant array of rank one containing the supported kind + parameters of the ``INTEGER`` type. (Fortran 2008 or later.) + +:samp:`{IOSTAT_END}:` + The value assigned to the variable passed to the ``IOSTAT=`` specifier of + an input/output statement if an end-of-file condition occurred. + +:samp:`{IOSTAT_EOR}:` + The value assigned to the variable passed to the ``IOSTAT=`` specifier of + an input/output statement if an end-of-record condition occurred. + +:samp:`{IOSTAT_INQUIRE_INTERNAL_UNIT}:` + Scalar default-integer constant, used by ``INQUIRE`` for the + ``IOSTAT=`` specifier to denote an that a unit number identifies an + internal unit. (Fortran 2008 or later.) + +:samp:`{NUMERIC_STORAGE_SIZE}:` + The size in bits of the numeric storage unit. + +:samp:`{LOGICAL_KINDS}:` + Default-kind integer constant array of rank one containing the supported kind + parameters of the ``LOGICAL`` type. (Fortran 2008 or later.) + +:samp:`{OUTPUT_UNIT}:` + Identifies the preconnected unit identified by the asterisk + (``*``) in ``WRITE`` statement. + +:samp:`{REAL32}, {REAL64}, {REAL128}:` + Kind type parameters to specify a REAL type with a storage + size of 32, 64, and 128 bits. It is negative if a target platform + does not support the particular kind. (Fortran 2008 or later.) + +:samp:`{REAL_KINDS}:` + Default-kind integer constant array of rank one containing the supported kind + parameters of the ``REAL`` type. (Fortran 2008 or later.) + +:samp:`{STAT_LOCKED}:` + Scalar default-integer constant used as STAT= return value by ``LOCK`` to + denote that the lock variable is locked by the executing image. (Fortran 2008 + or later.) + +:samp:`{STAT_LOCKED_OTHER_IMAGE}:` + Scalar default-integer constant used as STAT= return value by ``UNLOCK`` to + denote that the lock variable is locked by another image. (Fortran 2008 or + later.) + +:samp:`{STAT_STOPPED_IMAGE}:` + Positive, scalar default-integer constant used as STAT= return value if the + argument in the statement requires synchronisation with an image, which has + initiated the termination of the execution. (Fortran 2008 or later.) + +:samp:`{STAT_FAILED_IMAGE}:` + Positive, scalar default-integer constant used as STAT= return value if the + argument in the statement requires communication with an image, which has + is in the failed state. (TS 18508 or later.) + +:samp:`{STAT_UNLOCKED}:` + Scalar default-integer constant used as STAT= return value by ``UNLOCK`` to + denote that the lock variable is unlocked. (Fortran 2008 or later.) + + The module provides the following derived type: + +:samp:`{LOCK_TYPE}:` + Derived type with private components to be use with the ``LOCK`` and + ``UNLOCK`` statement. A variable of its type has to be always declared + as coarray and may not appear in a variable-definition context. + (Fortran 2008 or later.) + + The module also provides the following intrinsic procedures: + :ref:`COMPILER_OPTIONS` and :ref:`COMPILER_VERSION`. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-modules/openacc-module-openacc.rst b/gcc/fortran/doc/gfortran/intrinsic-modules/openacc-module-openacc.rst new file mode 100644 index 00000000000..56a5d37e154 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-modules/openacc-module-openacc.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openacc-module-openacc: + +OpenACC Module OPENACC +********************** + +:samp:`{Standard}:` + OpenACC Application Programming Interface v2.6 + + The OpenACC Fortran runtime library routines are provided both in a + form of a Fortran 90 module, named ``OPENACC``, and in form of a + Fortran ``include`` file named :samp:`openacc_lib.h`. The + procedures provided by ``OPENACC`` can be found in the + :ref:`libgomp:top` manual, the named constants defined in the modules + are listed below. + +For details refer to the actual +`OpenACC Application Programming Interface v2.6 `_. + +``OPENACC`` provides the scalar default-integer +named constant ``openacc_version`` with a value of the form +:samp:`{yyyymm}`, where ``yyyy`` is the year and :samp:`{mm}` the month +of the OpenACC version; for OpenACC v2.6 the value is ``201711``. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-modules/openmp-modules-omplib-and-omplibkinds.rst b/gcc/fortran/doc/gfortran/intrinsic-modules/openmp-modules-omplib-and-omplibkinds.rst new file mode 100644 index 00000000000..56951f3c9d3 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-modules/openmp-modules-omplib-and-omplibkinds.rst @@ -0,0 +1,161 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openmp-modules-omp_lib-and-omp_lib_kinds: + +OpenMP Modules OMP_LIB and OMP_LIB_KINDS +**************************************** + +The OpenMP Fortran runtime library routines are provided both in +a form of two Fortran modules, named ``OMP_LIB`` and +``OMP_LIB_KINDS``, and in a form of a Fortran ``include`` file named +:samp:`omp_lib.h`. The procedures provided by ``OMP_LIB`` can be found +in the :ref:`libgomp:top` manual, +the named constants defined in the modules are listed +below. + +For details refer to the actual +`OpenMP Application Program Interface v4.5 `_ and +`OpenMP Application Program Interface v5.0 `_. + +``OMP_LIB_KINDS`` provides the following scalar default-integer +named constants: + +.. code-block:: + + omp_allocator_handle_kind + omp_alloctrait_key_kind + omp_alloctrait_val_kind + omp_depend_kind + omp_lock_kind + omp_lock_hint_kind + omp_nest_lock_kind + omp_pause_resource_kind + omp_memspace_handle_kind + omp_proc_bind_kind + omp_sched_kind + omp_sync_hint_kind + +``OMP_LIB`` provides the scalar default-integer +named constant ``openmp_version`` with a value of the form +:samp:`{yyyymm}`, where ``yyyy`` is the year and :samp:`{mm}` the month +of the OpenMP version; for OpenMP v4.5 the value is ``201511``. + +The following derived type: + +.. code-block:: + + omp_alloctrait + +The following scalar integer named constants of the +kind ``omp_sched_kind`` : + +.. code-block:: + + omp_sched_static + omp_sched_dynamic + omp_sched_guided + omp_sched_auto + +And the following scalar integer named constants of the +kind ``omp_proc_bind_kind`` : + +.. code-block:: + + omp_proc_bind_false + omp_proc_bind_true + omp_proc_bind_primary + omp_proc_bind_master + omp_proc_bind_close + omp_proc_bind_spread + +The following scalar integer named constants are of the +kind ``omp_lock_hint_kind`` : + +.. code-block:: + + omp_lock_hint_none + omp_lock_hint_uncontended + omp_lock_hint_contended + omp_lock_hint_nonspeculative + omp_lock_hint_speculative + omp_sync_hint_none + omp_sync_hint_uncontended + omp_sync_hint_contended + omp_sync_hint_nonspeculative + omp_sync_hint_speculative + +And the following two scalar integer named constants are of the +kind ``omp_pause_resource_kind`` : + +.. code-block:: + + omp_pause_soft + omp_pause_hard + +The following scalar integer named constants are of the kind +``omp_alloctrait_key_kind`` : + +.. code-block:: + + omp_atk_sync_hint + omp_atk_alignment + omp_atk_access + omp_atk_pool_size + omp_atk_fallback + omp_atk_fb_data + omp_atk_pinned + omp_atk_partition + +The following scalar integer named constants are of the kind +``omp_alloctrait_val_kind`` : + +.. code-block:: + + omp_atv_default + omp_atv_false + omp_atv_true + omp_atv_contended + omp_atv_uncontended + omp_atv_serialized + omp_atv_sequential + omp_atv_private + omp_atv_all + omp_atv_thread + omp_atv_pteam + omp_atv_cgroup + omp_atv_default_mem_fb + omp_atv_null_fb + omp_atv_abort_fb + omp_atv_allocator_fb + omp_atv_environment + omp_atv_nearest + omp_atv_blocked + +The following scalar integer named constants are of the kind +``omp_allocator_handle_kind`` : + +.. code-block:: + + omp_null_allocator + omp_default_mem_alloc + omp_large_cap_mem_alloc + omp_const_mem_alloc + omp_high_bw_mem_alloc + omp_low_lat_mem_alloc + omp_cgroup_mem_alloc + omp_pteam_mem_alloc + omp_thread_mem_alloc + +The following scalar integer named constants are of the kind +``omp_memspace_handle_kind`` : + +.. code-block:: + + omp_default_mem_space + omp_large_cap_mem_space + omp_const_mem_space + omp_high_bw_mem_space + omp_low_lat_mem_space \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures.rst new file mode 100644 index 00000000000..cf1b0c98c98 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures.rst @@ -0,0 +1,299 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: intrinsic procedures + +.. _intrinsic-procedures: + +Intrinsic Procedures +-------------------- + +.. toctree:: + :maxdepth: 2 + + + intrinsic-procedures/introduction-to-intrinsic-procedures + intrinsic-procedures/abort + intrinsic-procedures/abs + intrinsic-procedures/access + intrinsic-procedures/achar + intrinsic-procedures/acos + intrinsic-procedures/acosd + intrinsic-procedures/acosh + intrinsic-procedures/adjustl + intrinsic-procedures/adjustr + intrinsic-procedures/aimag + intrinsic-procedures/aint + intrinsic-procedures/alarm + intrinsic-procedures/all + intrinsic-procedures/allocated + intrinsic-procedures/and + intrinsic-procedures/anint + intrinsic-procedures/any + intrinsic-procedures/asin + intrinsic-procedures/asind + intrinsic-procedures/asinh + intrinsic-procedures/associated + intrinsic-procedures/atan + intrinsic-procedures/atand + intrinsic-procedures/atan2 + intrinsic-procedures/atan2d + intrinsic-procedures/atanh + intrinsic-procedures/atomicadd + intrinsic-procedures/atomicand + intrinsic-procedures/atomiccas + intrinsic-procedures/atomicdefine + intrinsic-procedures/atomicfetchadd + intrinsic-procedures/atomicfetchand + intrinsic-procedures/atomicfetchor + intrinsic-procedures/atomicfetchxor + intrinsic-procedures/atomicor + intrinsic-procedures/atomicref + intrinsic-procedures/atomicxor + intrinsic-procedures/backtrace + intrinsic-procedures/besselj0 + intrinsic-procedures/besselj1 + intrinsic-procedures/besseljn + intrinsic-procedures/bessely0 + intrinsic-procedures/bessely1 + intrinsic-procedures/besselyn + intrinsic-procedures/bge + intrinsic-procedures/bgt + intrinsic-procedures/bitsize + intrinsic-procedures/ble + intrinsic-procedures/blt + intrinsic-procedures/btest + intrinsic-procedures/cassociated + intrinsic-procedures/cfpointer + intrinsic-procedures/cfprocpointer + intrinsic-procedures/cfunloc + intrinsic-procedures/cloc + intrinsic-procedures/csizeof + intrinsic-procedures/ceiling + intrinsic-procedures/char + intrinsic-procedures/chdir + intrinsic-procedures/chmod + intrinsic-procedures/cmplx + intrinsic-procedures/cobroadcast + intrinsic-procedures/comax + intrinsic-procedures/comin + intrinsic-procedures/coreduce + intrinsic-procedures/cosum + intrinsic-procedures/commandargumentcount + intrinsic-procedures/compileroptions + intrinsic-procedures/compilerversion + intrinsic-procedures/complex + intrinsic-procedures/conjg + intrinsic-procedures/cos + intrinsic-procedures/cosd + intrinsic-procedures/cosh + intrinsic-procedures/cotan + intrinsic-procedures/cotand + intrinsic-procedures/count + intrinsic-procedures/cputime + intrinsic-procedures/cshift + intrinsic-procedures/ctime + intrinsic-procedures/dateandtime + intrinsic-procedures/dble + intrinsic-procedures/dcmplx + intrinsic-procedures/digits + intrinsic-procedures/dim + intrinsic-procedures/dotproduct + intrinsic-procedures/dprod + intrinsic-procedures/dreal + intrinsic-procedures/dshiftl + intrinsic-procedures/dshiftr + intrinsic-procedures/dtime + intrinsic-procedures/eoshift + intrinsic-procedures/epsilon + intrinsic-procedures/erf + intrinsic-procedures/erfc + intrinsic-procedures/erfcscaled + intrinsic-procedures/etime + intrinsic-procedures/eventquery + intrinsic-procedures/executecommandline + intrinsic-procedures/exit + intrinsic-procedures/exp + intrinsic-procedures/exponent + intrinsic-procedures/extendstypeof + intrinsic-procedures/fdate + intrinsic-procedures/fget + intrinsic-procedures/fgetc + intrinsic-procedures/findloc + intrinsic-procedures/floor + intrinsic-procedures/flush + intrinsic-procedures/fnum + intrinsic-procedures/fput + intrinsic-procedures/fputc + intrinsic-procedures/fraction + intrinsic-procedures/free + intrinsic-procedures/fseek + intrinsic-procedures/fstat + intrinsic-procedures/ftell + intrinsic-procedures/gamma + intrinsic-procedures/gerror + intrinsic-procedures/getarg + intrinsic-procedures/getcommand + intrinsic-procedures/getcommandargument + intrinsic-procedures/getcwd + intrinsic-procedures/getenv + intrinsic-procedures/getenvironmentvariable + intrinsic-procedures/getgid + intrinsic-procedures/getlog + intrinsic-procedures/getpid + intrinsic-procedures/getuid + intrinsic-procedures/gmtime + intrinsic-procedures/hostnm + intrinsic-procedures/huge + intrinsic-procedures/hypot + intrinsic-procedures/iachar + intrinsic-procedures/iall + intrinsic-procedures/iand + intrinsic-procedures/iany + intrinsic-procedures/iargc + intrinsic-procedures/ibclr + intrinsic-procedures/ibits + intrinsic-procedures/ibset + intrinsic-procedures/ichar + intrinsic-procedures/idate + intrinsic-procedures/ieor + intrinsic-procedures/ierrno + intrinsic-procedures/imageindex + intrinsic-procedures/index + intrinsic-procedures/int + intrinsic-procedures/int2 + intrinsic-procedures/int8 + intrinsic-procedures/ior + intrinsic-procedures/iparity + intrinsic-procedures/irand + intrinsic-procedures/iscontiguous + intrinsic-procedures/isiostatend + intrinsic-procedures/isiostateor + intrinsic-procedures/isatty + intrinsic-procedures/ishft + intrinsic-procedures/ishftc + intrinsic-procedures/isnan + intrinsic-procedures/itime + intrinsic-procedures/kill + intrinsic-procedures/kind + intrinsic-procedures/lbound + intrinsic-procedures/lcobound + intrinsic-procedures/leadz + intrinsic-procedures/len + intrinsic-procedures/lentrim + intrinsic-procedures/lge + intrinsic-procedures/lgt + intrinsic-procedures/link + intrinsic-procedures/lle + intrinsic-procedures/llt + intrinsic-procedures/lnblnk + intrinsic-procedures/loc + intrinsic-procedures/log + intrinsic-procedures/log10 + intrinsic-procedures/loggamma + intrinsic-procedures/logical + intrinsic-procedures/lshift + intrinsic-procedures/lstat + intrinsic-procedures/ltime + intrinsic-procedures/malloc + intrinsic-procedures/maskl + intrinsic-procedures/maskr + intrinsic-procedures/matmul + intrinsic-procedures/max + intrinsic-procedures/maxexponent + intrinsic-procedures/maxloc + intrinsic-procedures/maxval + intrinsic-procedures/mclock + intrinsic-procedures/mclock8 + intrinsic-procedures/merge + intrinsic-procedures/mergebits + intrinsic-procedures/min + intrinsic-procedures/minexponent + intrinsic-procedures/minloc + intrinsic-procedures/minval + intrinsic-procedures/mod + intrinsic-procedures/modulo + intrinsic-procedures/movealloc + intrinsic-procedures/mvbits + intrinsic-procedures/nearest + intrinsic-procedures/newline + intrinsic-procedures/nint + intrinsic-procedures/norm2 + intrinsic-procedures/not + intrinsic-procedures/null + intrinsic-procedures/numimages + intrinsic-procedures/or + intrinsic-procedures/pack + intrinsic-procedures/parity + intrinsic-procedures/perror + intrinsic-procedures/popcnt + intrinsic-procedures/poppar + intrinsic-procedures/precision + intrinsic-procedures/present + intrinsic-procedures/product + intrinsic-procedures/radix + intrinsic-procedures/ran + intrinsic-procedures/rand + intrinsic-procedures/randominit + intrinsic-procedures/randomnumber + intrinsic-procedures/randomseed + intrinsic-procedures/range + intrinsic-procedures/rank + intrinsic-procedures/real + intrinsic-procedures/rename + intrinsic-procedures/repeat + intrinsic-procedures/reshape + intrinsic-procedures/rrspacing + intrinsic-procedures/rshift + intrinsic-procedures/sametypeas + intrinsic-procedures/scale + intrinsic-procedures/scan + intrinsic-procedures/secnds + intrinsic-procedures/second + intrinsic-procedures/selectedcharkind + intrinsic-procedures/selectedintkind + intrinsic-procedures/selectedrealkind + intrinsic-procedures/setexponent + intrinsic-procedures/shape + intrinsic-procedures/shifta + intrinsic-procedures/shiftl + intrinsic-procedures/shiftr + intrinsic-procedures/sign + intrinsic-procedures/signal + intrinsic-procedures/sin + intrinsic-procedures/sind + intrinsic-procedures/sinh + intrinsic-procedures/size + intrinsic-procedures/sizeof + intrinsic-procedures/sleep + intrinsic-procedures/spacing + intrinsic-procedures/spread + intrinsic-procedures/sqrt + intrinsic-procedures/srand + intrinsic-procedures/stat + intrinsic-procedures/storagesize + intrinsic-procedures/sum + intrinsic-procedures/symlnk + intrinsic-procedures/system + intrinsic-procedures/systemclock + intrinsic-procedures/tan + intrinsic-procedures/tand + intrinsic-procedures/tanh + intrinsic-procedures/thisimage + intrinsic-procedures/time + intrinsic-procedures/time8 + intrinsic-procedures/tiny + intrinsic-procedures/trailz + intrinsic-procedures/transfer + intrinsic-procedures/transpose + intrinsic-procedures/trim + intrinsic-procedures/ttynam + intrinsic-procedures/ubound + intrinsic-procedures/ucobound + intrinsic-procedures/umask + intrinsic-procedures/unlink + intrinsic-procedures/unpack + intrinsic-procedures/verify + intrinsic-procedures/xor \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/abort.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/abort.rst new file mode 100644 index 00000000000..9ac38fade2d --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/abort.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _abort: + +ABORT --- Abort the program +*************************** + +.. index:: ABORT, program termination, with core dump, terminate program, with core dump, core, dump + +.. function:: ABORT() + + ``ABORT`` causes immediate termination of the program. On operating + systems that support a core dump, ``ABORT`` will produce a core dump. + It will also print a backtrace, unless ``-fno-backtrace`` is given. + + :return: + Does not return. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL ABORT + + Example: + .. code-block:: fortran + + program test_abort + integer :: i = 1, j = 2 + if (i /= j) call abort + end program test_abort + + See also: + :ref:`EXIT`, + :ref:`KILL`, + :ref:`BACKTRACE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/abs.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/abs.rst new file mode 100644 index 00000000000..ecc7495ba39 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/abs.rst @@ -0,0 +1,117 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _abs: + +.. index:: ABS + +.. index:: CABS + +.. index:: DABS + +.. index:: IABS + +.. index:: ZABS + +.. index:: CDABS + +.. index:: BABS + +.. index:: IIABS + +.. index:: JIABS + +.. index:: KIABS + +.. index:: absolute value + +ABS --- Absolute value +********************** + +.. function:: ABS(A) + + ``ABS(A)`` computes the absolute value of ``A``. + + :param A: + The type of the argument shall be an ``INTEGER``, + ``REAL``, or ``COMPLEX``. + + :return: + The return value is of the same type and + kind as the argument except the return value is ``REAL`` for a + ``COMPLEX`` argument. + + Standard: + Fortran 77 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ABS(A) + + Example: + .. code-block:: fortran + + program test_abs + integer :: i = -1 + real :: x = -1.e0 + complex :: z = (-1.e0,0.e0) + i = abs(i) + x = abs(x) + x = abs(z) + end program test_abs + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ABS(A)`` + - ``REAL(4) A`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``CABS(A)`` + - ``COMPLEX(4) A`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DABS(A)`` + - ``REAL(8) A`` + - ``REAL(8)`` + - Fortran 77 and later + * - ``IABS(A)`` + - ``INTEGER(4) A`` + - ``INTEGER(4)`` + - Fortran 77 and later + * - ``BABS(A)`` + - ``INTEGER(1) A`` + - ``INTEGER(1)`` + - GNU extension + * - ``IIABS(A)`` + - ``INTEGER(2) A`` + - ``INTEGER(2)`` + - GNU extension + * - ``JIABS(A)`` + - ``INTEGER(4) A`` + - ``INTEGER(4)`` + - GNU extension + * - ``KIABS(A)`` + - ``INTEGER(8) A`` + - ``INTEGER(8)`` + - GNU extension + * - ``ZABS(A)`` + - ``COMPLEX(8) A`` + - ``REAL(8)`` + - GNU extension + * - ``CDABS(A)`` + - ``COMPLEX(8) A`` + - ``REAL(8)`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/access.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/access.rst new file mode 100644 index 00000000000..82931332f25 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/access.rst @@ -0,0 +1,61 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ACCESS, file system, access mode + +.. _access: + +ACCESS --- Checks file access modes +*********************************** + +.. function:: ACCESS(NAME, MODE) + + ``ACCESS(NAME, MODE)`` checks whether the file :samp:`{NAME}` + exists, is readable, writable or executable. Except for the + executable check, ``ACCESS`` can be replaced by + Fortran 95's ``INQUIRE``. + + :param NAME: + Scalar ``CHARACTER`` of default kind with the + file name. Trailing blank are ignored unless the character ``achar(0)`` + is present, then all characters up to and excluding ``achar(0)`` are + used as file name. + + :param MODE: + Scalar ``CHARACTER`` of default kind with the + file access mode, may be any concatenation of ``"r"`` (readable), + ``"w"`` (writable) and ``"x"`` (executable), or ``" "`` to check + for existence. + + :return: + Returns a scalar ``INTEGER``, which is ``0`` if the file is + accessible in the given mode; otherwise or if an invalid argument + has been given for ``MODE`` the value ``1`` is returned. + + Standard: + GNU extension + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = ACCESS(NAME, MODE) + + Example: + .. code-block:: fortran + + program access_test + implicit none + character(len=*), parameter :: file = 'test.dat' + character(len=*), parameter :: file2 = 'test.dat '//achar(0) + if(access(file,' ') == 0) print *, trim(file),' is exists' + if(access(file,'r') == 0) print *, trim(file),' is readable' + if(access(file,'w') == 0) print *, trim(file),' is writable' + if(access(file,'x') == 0) print *, trim(file),' is executable' + if(access(file2,'rwx') == 0) & + print *, trim(file2),' is readable, writable and executable' + end program access_test \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/achar.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/achar.rst new file mode 100644 index 00000000000..81df1335607 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/achar.rst @@ -0,0 +1,56 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ACHAR, ASCII collating sequence, collating sequence, ASCII + +.. _achar: + +ACHAR --- Character in ASCII collating sequence +************************************************ + +.. function:: ACHAR(I) + + ``ACHAR(I)`` returns the character located at position ``I`` + in the ASCII collating sequence. + + :param I: + The type shall be ``INTEGER``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``CHARACTER`` with a length of one. + If the :samp:`{KIND}` argument is present, the return value is of the + specified kind and of the default kind otherwise. + + Standard: + Fortran 77 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ACHAR(I [, KIND]) + + Example: + .. code-block:: fortran + + program test_achar + character c + c = achar(32) + end program test_achar + + Note: + See :ref:`ICHAR` for a discussion of converting between numerical values + and formatted string representations. + + See also: + :ref:`CHAR`, + :ref:`IACHAR`, + :ref:`ICHAR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/acos.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/acos.rst new file mode 100644 index 00000000000..f744aafedb7 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/acos.rst @@ -0,0 +1,73 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acos: + +.. index:: ACOS + +.. index:: DACOS + +.. index:: trigonometric function, cosine, inverse + +.. index:: cosine, inverse + +ACOS --- Arccosine function +**************************** + +.. function:: ACOS(X) + + ``ACOS(X)`` computes the arccosine of :samp:`{X}` (inverse of ``COS(X)``). + + :param X: + The type shall either be ``REAL`` with a magnitude that is + less than or equal to one - or the type shall be ``COMPLEX``. + + :return: + The return value is of the same type and kind as :samp:`{X}`. + The real part of the result is in radians and lies in the range + 0 \leq \Re \acos(x) \leq \pi. + + Standard: + Fortran 77 and later, for a complex argument Fortran 2008 or later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ACOS(X) + + Example: + .. code-block:: fortran + + program test_acos + real(8) :: x = 0.866_8 + x = acos(x) + end program test_acos + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ACOS(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DACOS(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 77 and later + + See also: + Inverse function: + :ref:`COS` + Degrees function: + :ref:`ACOSD` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/acosd.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/acosd.rst new file mode 100644 index 00000000000..676b7a4422c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/acosd.rst @@ -0,0 +1,74 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acosd: + +.. index:: ACOSD + +.. index:: DACOSD + +.. index:: trigonometric function, cosine, inverse, degrees + +.. index:: cosine, inverse, degrees + +ACOSD --- Arccosine function, degrees +************************************* + +.. function:: ACOSD(X) + + ``ACOSD(X)`` computes the arccosine of :samp:`{X}` in degrees (inverse of + ``COSD(X)``). + + :param X: + The type shall either be ``REAL`` with a magnitude that is + less than or equal to one - or the type shall be ``COMPLEX``. + + :return: + The return value is of the same type and kind as :samp:`{X}`. + The real part of the result is in degrees and lies in the range + 0 \leq \Re \acos(x) \leq 180. + + Standard: + GNU extension, enabled with :option:`-fdec-math` + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ACOSD(X) + + Example: + .. code-block:: fortran + + program test_acosd + real(8) :: x = 0.866_8 + x = acosd(x) + end program test_acosd + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ACOSD(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - GNU extension + * - ``DACOSD(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension + + See also: + Inverse function: + :ref:`COSD` + Radians function: + :ref:`ACOS` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/acosh.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/acosh.rst new file mode 100644 index 00000000000..b2012d16d7b --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/acosh.rst @@ -0,0 +1,70 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acosh: + +.. index:: ACOSH + +.. index:: DACOSH + +.. index:: area hyperbolic cosine + +.. index:: inverse hyperbolic cosine + +.. index:: hyperbolic function, cosine, inverse + +.. index:: cosine, hyperbolic, inverse + +ACOSH --- Inverse hyperbolic cosine function +******************************************** + +.. function:: ACOSH(X) + + ``ACOSH(X)`` computes the inverse hyperbolic cosine of :samp:`{X}`. + + :param X: + The type shall be ``REAL`` or ``COMPLEX``. + + :return: + The return value has the same type and kind as :samp:`{X}`. If :samp:`{X}` is + complex, the imaginary part of the result is in radians and lies between + 0 \leq \Im \acosh(x) \leq \pi. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ACOSH(X) + + Example: + .. code-block:: fortran + + PROGRAM test_acosh + REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /) + WRITE (*,*) ACOSH(x) + END PROGRAM + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DACOSH(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension + + See also: + Inverse function: + :ref:`COSH` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/adjustl.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/adjustl.rst new file mode 100644 index 00000000000..233516a802a --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/adjustl.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ADJUSTL, string, adjust left, adjust string + +.. _adjustl: + +ADJUSTL --- Left adjust a string +********************************* + +.. function:: ADJUSTL(STRING) + + ``ADJUSTL(STRING)`` will left adjust a string by removing leading spaces. + Spaces are inserted at the end of the string as needed. + + :param STRING: + The type shall be ``CHARACTER``. + + :return: + The return value is of type ``CHARACTER`` and of the same kind as + :samp:`{STRING}` where leading spaces are removed and the same number of + spaces are inserted on the end of :samp:`{STRING}`. + + Standard: + Fortran 90 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ADJUSTL(STRING) + + Example: + .. code-block:: fortran + + program test_adjustl + character(len=20) :: str = ' gfortran' + str = adjustl(str) + print *, str + end program test_adjustl + + See also: + :ref:`ADJUSTR`, + :ref:`TRIM` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/adjustr.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/adjustr.rst new file mode 100644 index 00000000000..fac4b0cea47 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/adjustr.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ADJUSTR, string, adjust right, adjust string + +.. _adjustr: + +ADJUSTR --- Right adjust a string +********************************** + +.. function:: ADJUSTR(STRING) + + ``ADJUSTR(STRING)`` will right adjust a string by removing trailing spaces. + Spaces are inserted at the start of the string as needed. + + :param STR: + The type shall be ``CHARACTER``. + + :return: + The return value is of type ``CHARACTER`` and of the same kind as + :samp:`{STRING}` where trailing spaces are removed and the same number of + spaces are inserted at the start of :samp:`{STRING}`. + + Standard: + Fortran 90 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ADJUSTR(STRING) + + Example: + .. code-block:: fortran + + program test_adjustr + character(len=20) :: str = 'gfortran' + str = adjustr(str) + print *, str + end program test_adjustr + + See also: + :ref:`ADJUSTL`, + :ref:`TRIM` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/aimag.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/aimag.rst new file mode 100644 index 00000000000..cf51185a753 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/aimag.rst @@ -0,0 +1,81 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _aimag: + +.. index:: AIMAG + +.. index:: DIMAG + +.. index:: IMAG + +.. index:: IMAGPART + +.. index:: complex numbers, imaginary part + +AIMAG --- Imaginary part of complex number +******************************************** + +.. function:: AIMAG(Z) + + ``AIMAG(Z)`` yields the imaginary part of complex argument ``Z``. + The ``IMAG(Z)`` and ``IMAGPART(Z)`` intrinsic functions are provided + for compatibility with :command:`g77`, and their use in new code is + strongly discouraged. + + :param Z: + The type of the argument shall be ``COMPLEX``. + + :return: + The return value is of type ``REAL`` with the + kind type parameter of the argument. + + Standard: + Fortran 77 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = AIMAG(Z) + + Example: + .. code-block:: fortran + + program test_aimag + complex(4) z4 + complex(8) z8 + z4 = cmplx(1.e0_4, 0.e0_4) + z8 = cmplx(0.e0_8, 1.e0_8) + print *, aimag(z4), dimag(z8) + end program test_aimag + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``AIMAG(Z)`` + - ``COMPLEX Z`` + - ``REAL`` + - Fortran 77 and later + * - ``DIMAG(Z)`` + - ``COMPLEX(8) Z`` + - ``REAL(8)`` + - GNU extension + * - ``IMAG(Z)`` + - ``COMPLEX Z`` + - ``REAL`` + - GNU extension + * - ``IMAGPART(Z)`` + - ``COMPLEX Z`` + - ``REAL`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/aint.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/aint.rst new file mode 100644 index 00000000000..2550442c246 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/aint.rst @@ -0,0 +1,78 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _aint: + +.. index:: AINT + +.. index:: DINT + +.. index:: floor + +.. index:: rounding, floor + +AINT --- Truncate to a whole number +*********************************** + +.. function:: AINT(A [, KIND]) + + ``AINT(A [, KIND])`` truncates its argument to a whole number. + + :param A: + The type of the argument shall be ``REAL``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``REAL`` with the kind type parameter of the + argument if the optional :samp:`{KIND}` is absent; otherwise, the kind + type parameter will be given by :samp:`{KIND}`. If the magnitude of + :samp:`{X}` is less than one, ``AINT(X)`` returns zero. If the + magnitude is equal to or greater than one then it returns the largest + whole number that does not exceed its magnitude. The sign is the same + as the sign of :samp:`{X}`. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = AINT(A [, KIND]) + + Example: + .. code-block:: fortran + + program test_aint + real(4) x4 + real(8) x8 + x4 = 1.234E0_4 + x8 = 4.321_8 + print *, aint(x4), dint(x8) + x8 = aint(x4,8) + end program test_aint + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``AINT(A)`` + - ``REAL(4) A`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DINT(A)`` + - ``REAL(8) A`` + - ``REAL(8)`` + - Fortran 77 and later \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/alarm.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/alarm.rst new file mode 100644 index 00000000000..36709669de7 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/alarm.rst @@ -0,0 +1,59 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _alarm: + +ALARM --- Execute a routine after a given delay +*********************************************** + +.. index:: ALARM, delayed execution + +.. function:: ALARM(SECONDS, HANDLER, STATUS) + + ``ALARM(SECONDS, HANDLER [, STATUS])`` causes external subroutine :samp:`{HANDLER}` + to be executed after a delay of :samp:`{SECONDS}` by using ``alarm(2)`` to + set up a signal and ``signal(2)`` to catch it. If :samp:`{STATUS}` is + supplied, it will be returned with the number of seconds remaining until + any previously scheduled alarm was due to be delivered, or zero if there + was no previously scheduled alarm. + + :param SECONDS: + The type of the argument shall be a scalar + ``INTEGER``. It is ``INTENT(IN)``. + + :param HANDLER: + Signal handler (``INTEGER FUNCTION`` or + ``SUBROUTINE``) or dummy/global ``INTEGER`` scalar. The scalar + values may be either ``SIG_IGN=1`` to ignore the alarm generated + or ``SIG_DFL=0`` to set the default action. It is ``INTENT(IN)``. + + :param STATUS: + (Optional) :samp:`{STATUS}` shall be a scalar + variable of the default ``INTEGER`` kind. It is ``INTENT(OUT)``. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL ALARM(SECONDS, HANDLER [, STATUS]) + + Example: + .. code-block:: fortran + + program test_alarm + external handler_print + integer i + call alarm (3, handler_print, i) + print *, i + call sleep(10) + end program test_alarm + + This will cause the external routine :samp:`{handler_print}` to be called + after 3 seconds. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/all.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/all.rst new file mode 100644 index 00000000000..a023168d6f1 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/all.rst @@ -0,0 +1,61 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _all: + +ALL --- All values in MASK along DIM are true +********************************************** + +.. index:: ALL, array, apply condition, array, condition testing + +.. function:: ALL(MASK, DIM) + + ``ALL(MASK [, DIM])`` determines if all the values are true in :samp:`{MASK}` + in the array along dimension :samp:`{DIM}`. + + :param MASK: + The type of the argument shall be ``LOGICAL`` and + it shall not be scalar. + + :param DIM: + (Optional) :samp:`{DIM}` shall be a scalar integer + with a value that lies between one and the rank of :samp:`{MASK}`. + + :return: + ``ALL(MASK)`` returns a scalar value of type ``LOGICAL`` where + the kind type parameter is the same as the kind type parameter of + :samp:`{MASK}`. If :samp:`{DIM}` is present, then ``ALL(MASK, DIM)`` returns + an array with the rank of :samp:`{MASK}` minus 1. The shape is determined from + the shape of :samp:`{MASK}` where the :samp:`{DIM}` dimension is elided. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = ALL(MASK [, DIM]) + + Example: + .. code-block:: fortran + + program test_all + logical l + l = all((/.true., .true., .true./)) + print *, l + call section + contains + subroutine section + integer a(2,3), b(2,3) + a = 1 + b = 1 + b(2,2) = 2 + print *, all(a .eq. b, 1) + print *, all(a .eq. b, 2) + end subroutine section + end program test_all \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/allocated.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/allocated.rst new file mode 100644 index 00000000000..eed0f765414 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/allocated.rst @@ -0,0 +1,49 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ALLOCATED, allocation, status + +.. _allocated: + +ALLOCATED --- Status of an allocatable entity +********************************************* + +.. function:: ALLOCATED(ARRAY) + + ``ALLOCATED(ARRAY)`` and ``ALLOCATED(SCALAR)`` check the allocation + status of :samp:`{ARRAY}` and :samp:`{SCALAR}`, respectively. + + :param ARRAY: + The argument shall be an ``ALLOCATABLE`` array. + + :param SCALAR: + The argument shall be an ``ALLOCATABLE`` scalar. + + :return: + The return value is a scalar ``LOGICAL`` with the default logical + kind type parameter. If the argument is allocated, then the result is + ``.TRUE.`` ; otherwise, it returns ``.FALSE.`` + + Standard: + Fortran 90 and later. Note, the ``SCALAR=`` keyword and allocatable + scalar entities are available in Fortran 2003 and later. + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = ALLOCATED(ARRAY) + RESULT = ALLOCATED(SCALAR) + + Example: + .. code-block:: fortran + + program test_allocated + integer :: i = 4 + real(4), allocatable :: x(:) + if (.not. allocated(x)) allocate(x(i)) + end program test_allocated \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/and.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/and.rst new file mode 100644 index 00000000000..66a8d250c37 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/and.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _and: + +AND --- Bitwise logical AND +*************************** + +.. index:: AND, bitwise logical and, logical and, bitwise + +.. function:: AND(I, J) + + Bitwise logical ``AND``. + + :param I: + The type shall be either a scalar ``INTEGER`` + type or a scalar ``LOGICAL`` type or a boz-literal-constant. + + :param J: + The type shall be the same as the type of :samp:`{I}` or + a boz-literal-constant. :samp:`{I}` and :samp:`{J}` shall not both be + boz-literal-constants. If either :samp:`{I}` or :samp:`{J}` is a + boz-literal-constant, then the other argument must be a scalar ``INTEGER``. + + :return: + The return type is either a scalar ``INTEGER`` or a scalar + ``LOGICAL``. If the kind type parameters differ, then the + smaller kind type is implicitly converted to larger kind, and the + return has the larger kind. A boz-literal-constant is + converted to an ``INTEGER`` with the kind type parameter of + the other argument as-if a call to :ref:`INT` occurred. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = AND(I, J) + + Example: + .. code-block:: fortran + + PROGRAM test_and + LOGICAL :: T = .TRUE., F = .FALSE. + INTEGER :: a, b + DATA a / Z'F' /, b / Z'3' / + + WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F) + WRITE (*,*) AND(a, b) + END PROGRAM + + See also: + Fortran 95 elemental function: + :ref:`IAND` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/anint.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/anint.rst new file mode 100644 index 00000000000..889585c412f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/anint.rst @@ -0,0 +1,76 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _anint: + +.. index:: ANINT + +.. index:: DNINT + +.. index:: ceiling + +.. index:: rounding, ceiling + +ANINT --- Nearest whole number +****************************** + +.. function:: ANINT(A [, KIND]) + + ``ANINT(A [, KIND])`` rounds its argument to the nearest whole number. + + :param A: + The type of the argument shall be ``REAL``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type real with the kind type parameter of the + argument if the optional :samp:`{KIND}` is absent; otherwise, the kind + type parameter will be given by :samp:`{KIND}`. If :samp:`{A}` is greater than + zero, ``ANINT(A)`` returns ``AINT(X+0.5)``. If :samp:`{A}` is + less than or equal to zero then it returns ``AINT(X-0.5)``. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ANINT(A [, KIND]) + + Example: + .. code-block:: fortran + + program test_anint + real(4) x4 + real(8) x8 + x4 = 1.234E0_4 + x8 = 4.321_8 + print *, anint(x4), dnint(x8) + x8 = anint(x4,8) + end program test_anint + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ANINT(A)`` + - ``REAL(4) A`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DNINT(A)`` + - ``REAL(8) A`` + - ``REAL(8)`` + - Fortran 77 and later \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/any.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/any.rst new file mode 100644 index 00000000000..1a2ba102c81 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/any.rst @@ -0,0 +1,61 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _any: + +ANY --- Any value in MASK along DIM is true +******************************************** + +.. index:: ANY, array, apply condition, array, condition testing + +.. function:: ANY(MASK, DIM) + + ``ANY(MASK [, DIM])`` determines if any of the values in the logical array + :samp:`{MASK}` along dimension :samp:`{DIM}` are ``.TRUE.``. + + :param MASK: + The type of the argument shall be ``LOGICAL`` and + it shall not be scalar. + + :param DIM: + (Optional) :samp:`{DIM}` shall be a scalar integer + with a value that lies between one and the rank of :samp:`{MASK}`. + + :return: + ``ANY(MASK)`` returns a scalar value of type ``LOGICAL`` where + the kind type parameter is the same as the kind type parameter of + :samp:`{MASK}`. If :samp:`{DIM}` is present, then ``ANY(MASK, DIM)`` returns + an array with the rank of :samp:`{MASK}` minus 1. The shape is determined from + the shape of :samp:`{MASK}` where the :samp:`{DIM}` dimension is elided. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = ANY(MASK [, DIM]) + + Example: + .. code-block:: fortran + + program test_any + logical l + l = any((/.true., .true., .true./)) + print *, l + call section + contains + subroutine section + integer a(2,3), b(2,3) + a = 1 + b = 1 + b(2,2) = 2 + print *, any(a .eq. b, 1) + print *, any(a .eq. b, 2) + end subroutine section + end program test_any \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/asin.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/asin.rst new file mode 100644 index 00000000000..0b6c4194665 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/asin.rst @@ -0,0 +1,73 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _asin: + +.. index:: ASIN + +.. index:: DASIN + +.. index:: trigonometric function, sine, inverse + +.. index:: sine, inverse + +ASIN --- Arcsine function +************************** + +.. function:: ASIN(X) + + ``ASIN(X)`` computes the arcsine of its :samp:`{X}` (inverse of ``SIN(X)``). + + :param X: + The type shall be either ``REAL`` and a magnitude that is + less than or equal to one - or be ``COMPLEX``. + + :return: + The return value is of the same type and kind as :samp:`{X}`. + The real part of the result is in radians and lies in the range + -\pi/2 \leq \Re \asin(x) \leq \pi/2. + + Standard: + Fortran 77 and later, for a complex argument Fortran 2008 or later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ASIN(X) + + Example: + .. code-block:: fortran + + program test_asin + real(8) :: x = 0.866_8 + x = asin(x) + end program test_asin + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ASIN(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DASIN(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 77 and later + + See also: + Inverse function: + :ref:`SIN` + Degrees function: + :ref:`ASIND` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/asind.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/asind.rst new file mode 100644 index 00000000000..407542bfa16 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/asind.rst @@ -0,0 +1,74 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _asind: + +.. index:: ASIND + +.. index:: DASIND + +.. index:: trigonometric function, sine, inverse, degrees + +.. index:: sine, inverse, degrees + +ASIND --- Arcsine function, degrees +*********************************** + +.. function:: ASIND(X) + + ``ASIND(X)`` computes the arcsine of its :samp:`{X}` in degrees (inverse of + ``SIND(X)``). + + :param X: + The type shall be either ``REAL`` and a magnitude that is + less than or equal to one - or be ``COMPLEX``. + + :return: + The return value is of the same type and kind as :samp:`{X}`. + The real part of the result is in degrees and lies in the range + -90 \leq \Re \asin(x) \leq 90. + + Standard: + GNU extension, enabled with :option:`-fdec-math`. + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ASIND(X) + + Example: + .. code-block:: fortran + + program test_asind + real(8) :: x = 0.866_8 + x = asind(x) + end program test_asind + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ASIND(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - GNU extension + * - ``DASIND(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension + + See also: + Inverse function: + :ref:`SIND` + Radians function: + :ref:`ASIN` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/asinh.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/asinh.rst new file mode 100644 index 00000000000..08902e8fc89 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/asinh.rst @@ -0,0 +1,70 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _asinh: + +.. index:: ASINH + +.. index:: DASINH + +.. index:: area hyperbolic sine + +.. index:: inverse hyperbolic sine + +.. index:: hyperbolic function, sine, inverse + +.. index:: sine, hyperbolic, inverse + +ASINH --- Inverse hyperbolic sine function +****************************************** + +.. function:: ASINH(X) + + ``ASINH(X)`` computes the inverse hyperbolic sine of :samp:`{X}`. + + :param X: + The type shall be ``REAL`` or ``COMPLEX``. + + :return: + The return value is of the same type and kind as :samp:`{X}`. If :samp:`{X}` is + complex, the imaginary part of the result is in radians and lies between + -\pi/2 \leq \Im \asinh(x) \leq \pi/2. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ASINH(X) + + Example: + .. code-block:: fortran + + PROGRAM test_asinh + REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /) + WRITE (*,*) ASINH(x) + END PROGRAM + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DASINH(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension. + + See also: + Inverse function: + :ref:`SINH` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/associated.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/associated.rst new file mode 100644 index 00000000000..5988c212f32 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/associated.rst @@ -0,0 +1,74 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _associated: + +ASSOCIATED --- Status of a pointer or pointer/target pair +********************************************************** + +.. index:: ASSOCIATED, pointer, status, association status + +.. function:: ASSOCIATED(POINTER, TARGET) + + ``ASSOCIATED(POINTER [, TARGET])`` determines the status of the pointer + :samp:`{POINTER}` or if :samp:`{POINTER}` is associated with the target :samp:`{TARGET}`. + + :param POINTER: + :samp:`{POINTER}` shall have the ``POINTER`` attribute + and it can be of any type. + + :param TARGET: + (Optional) :samp:`{TARGET}` shall be a pointer or + a target. It must have the same type, kind type parameter, and + array rank as :samp:`{POINTER}`. + + :return: + ``ASSOCIATED(POINTER)`` returns a scalar value of type ``LOGICAL(4)``. + There are several cases: + + - When the optional TARGET is not present then + ASSOCIATED(POINTER) is true if POINTER is associated with a target; otherwise, it returns false. + + - If TARGET is present and a scalar target, the result is true if + TARGET is not a zero-sized storage sequence and the target associated with POINTER occupies the same storage units. If POINTER is disassociated, the result is false. + + - If TARGET is present and an array target, the result is true if + TARGET and POINTER have the same shape, are not zero-sized arrays, are arrays whose elements are not zero-sized storage sequences, + and TARGET and POINTER occupy the same storage units in array element order. As in case(B), the result is false, if POINTER is disassociated. + + - If TARGET is present and an scalar pointer, the result is true + if TARGET is associated with POINTER, the target associated with TARGET are not zero-sized storage sequences and occupy the same storage units. + The result is false, if either TARGET or POINTER is disassociated. + + - If TARGET is present and an array pointer, the result is true if + target associated with POINTER and the target associated with TARGET have the same shape, are not zero-sized arrays, + are arrays whose elements are not zero-sized storage sequences, and TARGET and POINTER occupy the same storage units in array element order. + The result is false, if either TARGET or POINTER is disassociated. + + Standard: + Fortran 90 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = ASSOCIATED(POINTER [, TARGET]) + + Example: + .. code-block:: fortran + + program test_associated + implicit none + real, target :: tgt(2) = (/1., 2./) + real, pointer :: ptr(:) + ptr => tgt + if (associated(ptr) .eqv. .false.) call abort + if (associated(ptr,tgt) .eqv. .false.) call abort + end program test_associated + + See also: + :ref:`NULL` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atan.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atan.rst new file mode 100644 index 00000000000..ae36dda83ab --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atan.rst @@ -0,0 +1,80 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _atan: + +.. index:: ATAN + +.. index:: DATAN + +.. index:: trigonometric function, tangent, inverse + +.. index:: tangent, inverse + +ATAN --- Arctangent function +***************************** + +.. function:: ATAN(X) + + ``ATAN(X)`` computes the arctangent of :samp:`{X}`. + + :param X: + The type shall be ``REAL`` or ``COMPLEX`` ; + if :samp:`{Y}` is present, :samp:`{X}` shall be REAL. + + :param Y: + The type and kind type parameter shall be the same as :samp:`{X}`. + + :return: + The return value is of the same type and kind as :samp:`{X}`. + If :samp:`{Y}` is present, the result is identical to ``ATAN2(Y,X)``. + Otherwise, it the arcus tangent of :samp:`{X}`, where the real part of + the result is in radians and lies in the range + -\pi/2 \leq \Re \atan(x) \leq \pi/2. + + Standard: + Fortran 77 and later, for a complex argument and for two arguments + Fortran 2008 or later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ATAN(X) + RESULT = ATAN(Y, X) + + Example: + .. code-block:: fortran + + program test_atan + real(8) :: x = 2.866_8 + x = atan(x) + end program test_atan + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ATAN(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DATAN(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 77 and later + + See also: + Inverse function: + :ref:`TAN` + Degrees function: + :ref:`ATAND` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atan2.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atan2.rst new file mode 100644 index 00000000000..0f61a798b34 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atan2.rst @@ -0,0 +1,85 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _atan2: + +.. index:: ATAN2 + +.. index:: DATAN2 + +.. index:: trigonometric function, tangent, inverse + +.. index:: tangent, inverse + +ATAN2 --- Arctangent function +****************************** + +.. function:: ATAN2(Y, X) + + ``ATAN2(Y, X)`` computes the principal value of the argument + function of the complex number X + i Y. This function can + be used to transform from Cartesian into polar coordinates and + allows to determine the angle in the correct quadrant. + + :param Y: + The type shall be ``REAL``. + + :param X: + The type and kind type parameter shall be the same as :samp:`{Y}`. + If :samp:`{Y}` is zero, then :samp:`{X}` must be nonzero. + + :return: + The return value has the same type and kind type parameter as :samp:`{Y}`. It + is the principal value of the complex number X + i Y. If :samp:`{X}` + is nonzero, then it lies in the range -\pi \le \atan (x) \leq \pi. + The sign is positive if :samp:`{Y}` is positive. If :samp:`{Y}` is zero, then + the return value is zero if :samp:`{X}` is strictly positive, \pi if + :samp:`{X}` is negative and :samp:`{Y}` is positive zero (or the processor does + not handle signed zeros), and -\pi if :samp:`{X}` is negative and + :samp:`{Y}` is negative zero. Finally, if :samp:`{X}` is zero, then the + magnitude of the result is \pi/2. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ATAN2(Y, X) + + Example: + .. code-block:: fortran + + program test_atan2 + real(4) :: x = 1.e0_4, y = 0.5e0_4 + x = atan2(y,x) + end program test_atan2 + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ATAN2(X, Y)`` + - ``REAL(4) X, Y`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DATAN2(X, Y)`` + - ``REAL(8) X, Y`` + - ``REAL(8)`` + - Fortran 77 and later + + See also: + Alias: + :ref:`ATAN` + Degrees function: + :ref:`ATAN2D` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atan2d.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atan2d.rst new file mode 100644 index 00000000000..1aed24a8c71 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atan2d.rst @@ -0,0 +1,85 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _atan2d: + +.. index:: ATAN2D + +.. index:: DATAN2D + +.. index:: trigonometric function, tangent, inverse, degrees + +.. index:: tangent, inverse, degrees + +ATAN2D --- Arctangent function, degrees +*************************************** + +.. function:: ATAN2D(Y, X) + + ``ATAN2D(Y, X)`` computes the principal value of the argument + function of the complex number X + i Y in degrees. This function can + be used to transform from Cartesian into polar coordinates and + allows to determine the angle in the correct quadrant. + + :param Y: + The type shall be ``REAL``. + + :param X: + The type and kind type parameter shall be the same as :samp:`{Y}`. + If :samp:`{Y}` is zero, then :samp:`{X}` must be nonzero. + + :return: + The return value has the same type and kind type parameter as :samp:`{Y}`. It + is the principal value of the complex number X + i Y. If :samp:`{X}` + is nonzero, then it lies in the range -180 \le \atan (x) \leq 180. + The sign is positive if :samp:`{Y}` is positive. If :samp:`{Y}` is zero, then + the return value is zero if :samp:`{X}` is strictly positive, 180 if + :samp:`{X}` is negative and :samp:`{Y}` is positive zero (or the processor does + not handle signed zeros), and -180 if :samp:`{X}` is negative and + :samp:`{Y}` is negative zero. Finally, if :samp:`{X}` is zero, then the + magnitude of the result is 90. + + Standard: + GNU extension, enabled with :option:`-fdec-math`. + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ATAN2D(Y, X) + + Example: + .. code-block:: fortran + + program test_atan2d + real(4) :: x = 1.e0_4, y = 0.5e0_4 + x = atan2d(y,x) + end program test_atan2d + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ATAN2D(X, Y)`` + - ``REAL(4) X, Y`` + - ``REAL(4)`` + - GNU extension + * - ``DATAN2D(X, Y)`` + - ``REAL(8) X, Y`` + - ``REAL(8)`` + - GNU extension + + See also: + Alias: + :ref:`ATAND` + Radians function: + :ref:`ATAN2` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atand.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atand.rst new file mode 100644 index 00000000000..f070cfc120f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atand.rst @@ -0,0 +1,80 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _atand: + +.. index:: ATAND + +.. index:: DATAND + +.. index:: trigonometric function, tangent, inverse, degrees + +.. index:: tangent, inverse, degrees + +ATAND --- Arctangent function, degrees +************************************** + +.. function:: ATAND(X) + + ``ATAND(X)`` computes the arctangent of :samp:`{X}` in degrees (inverse of + :ref:`TAND`). + + :param X: + The type shall be ``REAL`` or ``COMPLEX`` ; + if :samp:`{Y}` is present, :samp:`{X}` shall be REAL. + + :param Y: + The type and kind type parameter shall be the same as :samp:`{X}`. + + :return: + The return value is of the same type and kind as :samp:`{X}`. + If :samp:`{Y}` is present, the result is identical to ``ATAND2(Y,X)``. + Otherwise, it is the arcus tangent of :samp:`{X}`, where the real part of + the result is in degrees and lies in the range + -90 \leq \Re \atand(x) \leq 90. + + Standard: + GNU extension, enabled with :option:`-fdec-math`. + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ATAND(X) + RESULT = ATAND(Y, X) + + Example: + .. code-block:: fortran + + program test_atand + real(8) :: x = 2.866_8 + x = atand(x) + end program test_atand + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ATAND(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - GNU extension + * - ``DATAND(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension + + See also: + Inverse function: + :ref:`TAND` + Radians function: + :ref:`ATAN` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atanh.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atanh.rst new file mode 100644 index 00000000000..7d6f157889e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atanh.rst @@ -0,0 +1,70 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _atanh: + +.. index:: ATANH + +.. index:: DATANH + +.. index:: area hyperbolic tangent + +.. index:: inverse hyperbolic tangent + +.. index:: hyperbolic function, tangent, inverse + +.. index:: tangent, hyperbolic, inverse + +ATANH --- Inverse hyperbolic tangent function +********************************************* + +.. function:: ATANH(X) + + ``ATANH(X)`` computes the inverse hyperbolic tangent of :samp:`{X}`. + + :param X: + The type shall be ``REAL`` or ``COMPLEX``. + + :return: + The return value has same type and kind as :samp:`{X}`. If :samp:`{X}` is + complex, the imaginary part of the result is in radians and lies between + -\pi/2 \leq \Im \atanh(x) \leq \pi/2. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ATANH(X) + + Example: + .. code-block:: fortran + + PROGRAM test_atanh + REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /) + WRITE (*,*) ATANH(x) + END PROGRAM + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DATANH(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension + + See also: + Inverse function: + :ref:`TANH` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicadd.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicadd.rst new file mode 100644 index 00000000000..3b1195e6547 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicadd.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ATOMIC_ADD, Atomic subroutine, add + +.. _atomic_add: + +ATOMIC_ADD --- Atomic ADD operation +*********************************** + +.. function:: ATOMIC_ADD(ATOM, VALUE) + + ``ATOMIC_ADD(ATOM, VALUE)`` atomically adds the value of :samp:`{VALUE}` to the + variable :samp:`{ATOM}`. When :samp:`{STAT}` is present and the invocation was + successful, it is assigned the value 0. If it is present and the invocation + has failed, it is assigned a positive value; in particular, for a coindexed + :samp:`{ATOM}`, if the remote image has stopped, it is assigned the value of + ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote image has + failed, the value ``STAT_FAILED_IMAGE``. + + :param ATOM: + Scalar coarray or coindexed variable of integer + type with ``ATOMIC_INT_KIND`` kind. + + :param VALUE: + Scalar of the same type as :samp:`{ATOM}`. If the kind + is different, the value is converted to the kind of :samp:`{ATOM}`. + + :param STAT: + (optional) Scalar default-kind integer variable. + + Standard: + TS 18508 or later + + Class: + Atomic subroutine + + Syntax: + .. code-block:: fortran + + CALL ATOMIC_ADD (ATOM, VALUE [, STAT]) + + Example: + .. code-block:: fortran + + program atomic + use iso_fortran_env + integer(atomic_int_kind) :: atom[*] + call atomic_add (atom[1], this_image()) + end program atomic + + See also: + :ref:`ATOMIC_DEFINE`, + :ref:`ATOMIC_FETCH_ADD`, + :ref:`ISO_FORTRAN_ENV`, + :ref:`ATOMIC_AND`, + :ref:`ATOMIC_OR`, + :ref:`ATOMIC_XOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicand.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicand.rst new file mode 100644 index 00000000000..fd503c8e7d0 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicand.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ATOMIC_AND, Atomic subroutine, AND + +.. _atomic_and: + +ATOMIC_AND --- Atomic bitwise AND operation +******************************************* + +.. function:: ATOMIC_AND(ATOM, VALUE) + + ``ATOMIC_AND(ATOM, VALUE)`` atomically defines :samp:`{ATOM}` with the bitwise + AND between the values of :samp:`{ATOM}` and :samp:`{VALUE}`. When :samp:`{STAT}` is present + and the invocation was successful, it is assigned the value 0. If it is present + and the invocation has failed, it is assigned a positive value; in particular, + for a coindexed :samp:`{ATOM}`, if the remote image has stopped, it is assigned the + value of ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote + image has failed, the value ``STAT_FAILED_IMAGE``. + + :param ATOM: + Scalar coarray or coindexed variable of integer + type with ``ATOMIC_INT_KIND`` kind. + + :param VALUE: + Scalar of the same type as :samp:`{ATOM}`. If the kind + is different, the value is converted to the kind of :samp:`{ATOM}`. + + :param STAT: + (optional) Scalar default-kind integer variable. + + Standard: + TS 18508 or later + + Class: + Atomic subroutine + + Syntax: + .. code-block:: fortran + + CALL ATOMIC_AND (ATOM, VALUE [, STAT]) + + Example: + .. code-block:: fortran + + program atomic + use iso_fortran_env + integer(atomic_int_kind) :: atom[*] + call atomic_and (atom[1], int(b'10100011101')) + end program atomic + + See also: + :ref:`ATOMIC_DEFINE`, + :ref:`ATOMIC_FETCH_AND`, + :ref:`ISO_FORTRAN_ENV`, + :ref:`ATOMIC_ADD`, + :ref:`ATOMIC_OR`, + :ref:`ATOMIC_XOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atomiccas.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomiccas.rst new file mode 100644 index 00000000000..a26e1343107 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomiccas.rst @@ -0,0 +1,67 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _atomic_cas: + +ATOMIC_CAS --- Atomic compare and swap +************************************** + +.. index:: ATOMIC_DEFINE, Atomic subroutine, compare and swap + +.. function:: ATOMIC_CAS(ATOM, OLD, COMPARE, NEW, STAT) + + ``ATOMIC_CAS`` compares the variable :samp:`{ATOM}` with the value of + :samp:`{COMPARE}` ; if the value is the same, :samp:`{ATOM}` is set to the value + of :samp:`{NEW}`. Additionally, :samp:`{OLD}` is set to the value of :samp:`{ATOM}` + that was used for the comparison. When :samp:`{STAT}` is present and the invocation + was successful, it is assigned the value 0. If it is present and the invocation + has failed, it is assigned a positive value; in particular, for a coindexed + :samp:`{ATOM}`, if the remote image has stopped, it is assigned the value of + ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote image has + failed, the value ``STAT_FAILED_IMAGE``. + + :param ATOM: + Scalar coarray or coindexed variable of either integer + type with ``ATOMIC_INT_KIND`` kind or logical type with + ``ATOMIC_LOGICAL_KIND`` kind. + + :param OLD: + Scalar of the same type and kind as :samp:`{ATOM}`. + + :param COMPARE: + Scalar variable of the same type and kind as + :samp:`{ATOM}`. + + :param NEW: + Scalar variable of the same type as :samp:`{ATOM}`. If kind + is different, the value is converted to the kind of :samp:`{ATOM}`. + + :param STAT: + (optional) Scalar default-kind integer variable. + + Standard: + TS 18508 or later + + Class: + Atomic subroutine + + Syntax: + .. code-block:: fortran + + CALL ATOMIC_CAS (ATOM, OLD, COMPARE, NEW [, STAT]) + + Example: + .. code-block:: fortran + + program atomic + use iso_fortran_env + logical(atomic_logical_kind) :: atom[*], prev + call atomic_cas (atom[1], prev, .false., .true.)) + end program atomic + + See also: + :ref:`ATOMIC_DEFINE`, + :ref:`ATOMIC_REF`, + :ref:`ISO_FORTRAN_ENV` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicdefine.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicdefine.rst new file mode 100644 index 00000000000..4366028fc18 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicdefine.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ATOMIC_DEFINE, Atomic subroutine, define + +.. _atomic_define: + +ATOMIC_DEFINE --- Setting a variable atomically +*********************************************** + +.. function:: ATOMIC_DEFINE(ATOM, VALUE) + + ``ATOMIC_DEFINE(ATOM, VALUE)`` defines the variable :samp:`{ATOM}` with the value + :samp:`{VALUE}` atomically. When :samp:`{STAT}` is present and the invocation was + successful, it is assigned the value 0. If it is present and the invocation + has failed, it is assigned a positive value; in particular, for a coindexed + :samp:`{ATOM}`, if the remote image has stopped, it is assigned the value of + ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote image has + failed, the value ``STAT_FAILED_IMAGE``. + + :param ATOM: + Scalar coarray or coindexed variable of either integer + type with ``ATOMIC_INT_KIND`` kind or logical type with + ``ATOMIC_LOGICAL_KIND`` kind. + + :param VALUE: + Scalar of the same type as :samp:`{ATOM}`. If the kind + is different, the value is converted to the kind of :samp:`{ATOM}`. + + :param STAT: + (optional) Scalar default-kind integer variable. + + Standard: + Fortran 2008 and later; with :samp:`{STAT}`, TS 18508 or later + + Class: + Atomic subroutine + + Syntax: + .. code-block:: fortran + + CALL ATOMIC_DEFINE (ATOM, VALUE [, STAT]) + + Example: + .. code-block:: fortran + + program atomic + use iso_fortran_env + integer(atomic_int_kind) :: atom[*] + call atomic_define (atom[1], this_image()) + end program atomic + + See also: + :ref:`ATOMIC_REF`, + :ref:`ATOMIC_CAS`, + :ref:`ISO_FORTRAN_ENV`, + :ref:`ATOMIC_ADD`, + :ref:`ATOMIC_AND`, + :ref:`ATOMIC_OR`, + :ref:`ATOMIC_XOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchadd.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchadd.rst new file mode 100644 index 00000000000..a3b1059f35a --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchadd.rst @@ -0,0 +1,65 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ATOMIC_FETCH_ADD, Atomic subroutine, ADD with fetch + +.. _atomic_fetch_add: + +ATOMIC_FETCH_ADD --- Atomic ADD operation with prior fetch +********************************************************** + +.. function:: ATOMIC_FETCH_ADD(ATOM, VALUE, OLD) + + ``ATOMIC_FETCH_ADD(ATOM, VALUE, OLD)`` atomically stores the value of + :samp:`{ATOM}` in :samp:`{OLD}` and adds the value of :samp:`{VALUE}` to the + variable :samp:`{ATOM}`. When :samp:`{STAT}` is present and the invocation was + successful, it is assigned the value 0. If it is present and the invocation + has failed, it is assigned a positive value; in particular, for a coindexed + :samp:`{ATOM}`, if the remote image has stopped, it is assigned the value of + ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote image has + failed, the value ``STAT_FAILED_IMAGE``. + + :param ATOM: + Scalar coarray or coindexed variable of integer + type with ``ATOMIC_INT_KIND`` kind. + ``ATOMIC_LOGICAL_KIND`` kind. + + :param VALUE: + Scalar of the same type as :samp:`{ATOM}`. If the kind + is different, the value is converted to the kind of :samp:`{ATOM}`. + + :param OLD: + Scalar of the same type and kind as :samp:`{ATOM}`. + + :param STAT: + (optional) Scalar default-kind integer variable. + + Standard: + TS 18508 or later + + Class: + Atomic subroutine + + Syntax: + .. code-block:: fortran + + CALL ATOMIC_FETCH_ADD (ATOM, VALUE, old [, STAT]) + + Example: + .. code-block:: fortran + + program atomic + use iso_fortran_env + integer(atomic_int_kind) :: atom[*], old + call atomic_add (atom[1], this_image(), old) + end program atomic + + See also: + :ref:`ATOMIC_DEFINE`, + :ref:`ATOMIC_ADD`, + :ref:`ISO_FORTRAN_ENV`, + :ref:`ATOMIC_FETCH_AND`, + :ref:`ATOMIC_FETCH_OR`, + :ref:`ATOMIC_FETCH_XOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchand.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchand.rst new file mode 100644 index 00000000000..379a767177d --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchand.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ATOMIC_FETCH_AND, Atomic subroutine, AND with fetch + +.. _atomic_fetch_and: + +ATOMIC_FETCH_AND --- Atomic bitwise AND operation with prior fetch +****************************************************************** + +.. function:: ATOMIC_FETCH_AND (ATOM, VALUE, OLD , STAT) + + ``ATOMIC_AND(ATOM, VALUE)`` atomically stores the value of :samp:`{ATOM}` in + :samp:`{OLD}` and defines :samp:`{ATOM}` with the bitwise AND between the values of + :samp:`{ATOM}` and :samp:`{VALUE}`. When :samp:`{STAT}` is present and the invocation was + successful, it is assigned the value 0. If it is present and the invocation has + failed, it is assigned a positive value; in particular, for a coindexed + :samp:`{ATOM}`, if the remote image has stopped, it is assigned the value of + ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote image has + failed, the value ``STAT_FAILED_IMAGE``. + + :param ATOM: + Scalar coarray or coindexed variable of integer + type with ``ATOMIC_INT_KIND`` kind. + + :param VALUE: + Scalar of the same type as :samp:`{ATOM}`. If the kind + is different, the value is converted to the kind of :samp:`{ATOM}`. + + :param OLD: + Scalar of the same type and kind as :samp:`{ATOM}`. + + :param STAT: + (optional) Scalar default-kind integer variable. + + Standard: + TS 18508 or later + + Class: + Atomic subroutine + + Syntax: + .. code-block:: fortran + + CALL ATOMIC_FETCH_AND (ATOM, VALUE, OLD [, STAT]) + + Example: + .. code-block:: fortran + + program atomic + use iso_fortran_env + integer(atomic_int_kind) :: atom[*], old + call atomic_fetch_and (atom[1], int(b'10100011101'), old) + end program atomic + + See also: + :ref:`ATOMIC_DEFINE`, + :ref:`ATOMIC_AND`, + :ref:`ISO_FORTRAN_ENV`, + :ref:`ATOMIC_FETCH_ADD`, + :ref:`ATOMIC_FETCH_OR`, + :ref:`ATOMIC_FETCH_XOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchor.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchor.rst new file mode 100644 index 00000000000..5dd5391bcf2 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchor.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ATOMIC_FETCH_OR, Atomic subroutine, OR with fetch + +.. _atomic_fetch_or: + +ATOMIC_FETCH_OR --- Atomic bitwise OR operation with prior fetch +**************************************************************** + +.. function:: ATOMIC_FETCH_OR (ATOM, VALUE, OLD , STAT) + + ``ATOMIC_OR(ATOM, VALUE)`` atomically stores the value of :samp:`{ATOM}` in + :samp:`{OLD}` and defines :samp:`{ATOM}` with the bitwise OR between the values of + :samp:`{ATOM}` and :samp:`{VALUE}`. When :samp:`{STAT}` is present and the invocation was + successful, it is assigned the value 0. If it is present and the invocation has + failed, it is assigned a positive value; in particular, for a coindexed + :samp:`{ATOM}`, if the remote image has stopped, it is assigned the value of + ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote image has + failed, the value ``STAT_FAILED_IMAGE``. + + :param ATOM: + Scalar coarray or coindexed variable of integer + type with ``ATOMIC_INT_KIND`` kind. + + :param VALUE: + Scalar of the same type as :samp:`{ATOM}`. If the kind + is different, the value is converted to the kind of :samp:`{ATOM}`. + + :param OLD: + Scalar of the same type and kind as :samp:`{ATOM}`. + + :param STAT: + (optional) Scalar default-kind integer variable. + + Standard: + TS 18508 or later + + Class: + Atomic subroutine + + Syntax: + .. code-block:: fortran + + CALL ATOMIC_FETCH_OR (ATOM, VALUE, OLD [, STAT]) + + Example: + .. code-block:: fortran + + program atomic + use iso_fortran_env + integer(atomic_int_kind) :: atom[*], old + call atomic_fetch_or (atom[1], int(b'10100011101'), old) + end program atomic + + See also: + :ref:`ATOMIC_DEFINE`, + :ref:`ATOMIC_OR`, + :ref:`ISO_FORTRAN_ENV`, + :ref:`ATOMIC_FETCH_ADD`, + :ref:`ATOMIC_FETCH_AND`, + :ref:`ATOMIC_FETCH_XOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchxor.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchxor.rst new file mode 100644 index 00000000000..4f5a4c2827a --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicfetchxor.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ATOMIC_FETCH_XOR, Atomic subroutine, XOR with fetch + +.. _atomic_fetch_xor: + +ATOMIC_FETCH_XOR --- Atomic bitwise XOR operation with prior fetch +****************************************************************** + +.. function:: ATOMIC_FETCH_XOR (ATOM, VALUE, OLD , STAT) + + ``ATOMIC_XOR(ATOM, VALUE)`` atomically stores the value of :samp:`{ATOM}` in + :samp:`{OLD}` and defines :samp:`{ATOM}` with the bitwise XOR between the values of + :samp:`{ATOM}` and :samp:`{VALUE}`. When :samp:`{STAT}` is present and the invocation was + successful, it is assigned the value 0. If it is present and the invocation has + failed, it is assigned a positive value; in particular, for a coindexed + :samp:`{ATOM}`, if the remote image has stopped, it is assigned the value of + ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote image has + failed, the value ``STAT_FAILED_IMAGE``. + + :param ATOM: + Scalar coarray or coindexed variable of integer + type with ``ATOMIC_INT_KIND`` kind. + + :param VALUE: + Scalar of the same type as :samp:`{ATOM}`. If the kind + is different, the value is converted to the kind of :samp:`{ATOM}`. + + :param OLD: + Scalar of the same type and kind as :samp:`{ATOM}`. + + :param STAT: + (optional) Scalar default-kind integer variable. + + Standard: + TS 18508 or later + + Class: + Atomic subroutine + + Syntax: + .. code-block:: fortran + + CALL ATOMIC_FETCH_XOR (ATOM, VALUE, OLD [, STAT]) + + Example: + .. code-block:: fortran + + program atomic + use iso_fortran_env + integer(atomic_int_kind) :: atom[*], old + call atomic_fetch_xor (atom[1], int(b'10100011101'), old) + end program atomic + + See also: + :ref:`ATOMIC_DEFINE`, + :ref:`ATOMIC_XOR`, + :ref:`ISO_FORTRAN_ENV`, + :ref:`ATOMIC_FETCH_ADD`, + :ref:`ATOMIC_FETCH_AND`, + :ref:`ATOMIC_FETCH_OR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicor.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicor.rst new file mode 100644 index 00000000000..ed5ae9c0ba2 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicor.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ATOMIC_OR, Atomic subroutine, OR + +.. _atomic_or: + +ATOMIC_OR --- Atomic bitwise OR operation +***************************************** + +.. function:: ATOMIC_OR(ATOM, VALUE) + + ``ATOMIC_OR(ATOM, VALUE)`` atomically defines :samp:`{ATOM}` with the bitwise + AND between the values of :samp:`{ATOM}` and :samp:`{VALUE}`. When :samp:`{STAT}` is present + and the invocation was successful, it is assigned the value 0. If it is present + and the invocation has failed, it is assigned a positive value; in particular, + for a coindexed :samp:`{ATOM}`, if the remote image has stopped, it is assigned the + value of ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote + image has failed, the value ``STAT_FAILED_IMAGE``. + + :param ATOM: + Scalar coarray or coindexed variable of integer + type with ``ATOMIC_INT_KIND`` kind. + + :param VALUE: + Scalar of the same type as :samp:`{ATOM}`. If the kind + is different, the value is converted to the kind of :samp:`{ATOM}`. + + :param STAT: + (optional) Scalar default-kind integer variable. + + Standard: + TS 18508 or later + + Class: + Atomic subroutine + + Syntax: + .. code-block:: fortran + + CALL ATOMIC_OR (ATOM, VALUE [, STAT]) + + Example: + .. code-block:: fortran + + program atomic + use iso_fortran_env + integer(atomic_int_kind) :: atom[*] + call atomic_or (atom[1], int(b'10100011101')) + end program atomic + + See also: + :ref:`ATOMIC_DEFINE`, + :ref:`ATOMIC_FETCH_OR`, + :ref:`ISO_FORTRAN_ENV`, + :ref:`ATOMIC_ADD`, + :ref:`ATOMIC_OR`, + :ref:`ATOMIC_XOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicref.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicref.rst new file mode 100644 index 00000000000..2bbae373c68 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicref.rst @@ -0,0 +1,68 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ATOMIC_REF, Atomic subroutine, reference + +.. _atomic_ref: + +ATOMIC_REF --- Obtaining the value of a variable atomically +*********************************************************** + +.. function:: ATOMIC_REF(VALUE, ATOM , STAT) + + ``ATOMIC_DEFINE(ATOM, VALUE)`` atomically assigns the value of the + variable :samp:`{ATOM}` to :samp:`{VALUE}`. When :samp:`{STAT}` is present and the + invocation was successful, it is assigned the value 0. If it is present and the + invocation has failed, it is assigned a positive value; in particular, for a + coindexed :samp:`{ATOM}`, if the remote image has stopped, it is assigned the value + of ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote image + has failed, the value ``STAT_FAILED_IMAGE``. + + :param VALUE: + Scalar of the same type as :samp:`{ATOM}`. If the kind + is different, the value is converted to the kind of :samp:`{ATOM}`. + + :param ATOM: + Scalar coarray or coindexed variable of either integer + type with ``ATOMIC_INT_KIND`` kind or logical type with + ``ATOMIC_LOGICAL_KIND`` kind. + + :param STAT: + (optional) Scalar default-kind integer variable. + + Standard: + Fortran 2008 and later; with :samp:`{STAT}`, TS 18508 or later + + Class: + Atomic subroutine + + Syntax: + .. code-block:: fortran + + CALL ATOMIC_REF(VALUE, ATOM [, STAT]) + + Example: + .. code-block:: fortran + + program atomic + use iso_fortran_env + logical(atomic_logical_kind) :: atom[*] + logical :: val + call atomic_ref (atom, .false.) + ! ... + call atomic_ref (atom, val) + if (val) then + print *, "Obtained" + end if + end program atomic + + See also: + :ref:`ATOMIC_DEFINE`, + :ref:`ATOMIC_CAS`, + :ref:`ISO_FORTRAN_ENV`, + :ref:`ATOMIC_FETCH_ADD`, + :ref:`ATOMIC_FETCH_AND`, + :ref:`ATOMIC_FETCH_OR`, + :ref:`ATOMIC_FETCH_XOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicxor.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicxor.rst new file mode 100644 index 00000000000..7e4a38b2f8e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/atomicxor.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ATOMIC_XOR, Atomic subroutine, XOR + +.. _atomic_xor: + +ATOMIC_XOR --- Atomic bitwise OR operation +****************************************** + +.. function:: ATOMIC_XOR (ATOM, VALUE , STAT) + + ``ATOMIC_AND(ATOM, VALUE)`` atomically defines :samp:`{ATOM}` with the bitwise + XOR between the values of :samp:`{ATOM}` and :samp:`{VALUE}`. When :samp:`{STAT}` is present + and the invocation was successful, it is assigned the value 0. If it is present + and the invocation has failed, it is assigned a positive value; in particular, + for a coindexed :samp:`{ATOM}`, if the remote image has stopped, it is assigned the + value of ``ISO_FORTRAN_ENV`` 's ``STAT_STOPPED_IMAGE`` and if the remote + image has failed, the value ``STAT_FAILED_IMAGE``. + + :param ATOM: + Scalar coarray or coindexed variable of integer + type with ``ATOMIC_INT_KIND`` kind. + + :param VALUE: + Scalar of the same type as :samp:`{ATOM}`. If the kind + is different, the value is converted to the kind of :samp:`{ATOM}`. + + :param STAT: + (optional) Scalar default-kind integer variable. + + Standard: + TS 18508 or later + + Class: + Atomic subroutine + + Syntax: + .. code-block:: fortran + + CALL ATOMIC_XOR (ATOM, VALUE [, STAT]) + + Example: + .. code-block:: fortran + + program atomic + use iso_fortran_env + integer(atomic_int_kind) :: atom[*] + call atomic_xor (atom[1], int(b'10100011101')) + end program atomic + + See also: + :ref:`ATOMIC_DEFINE`, + :ref:`ATOMIC_FETCH_XOR`, + :ref:`ISO_FORTRAN_ENV`, + :ref:`ATOMIC_ADD`, + :ref:`ATOMIC_OR`, + :ref:`ATOMIC_XOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/backtrace.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/backtrace.rst new file mode 100644 index 00000000000..04b08547f62 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/backtrace.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _backtrace: + +BACKTRACE --- Show a backtrace +****************************** + +.. index:: BACKTRACE, backtrace + +.. function:: BACKTRACE() + + ``BACKTRACE`` shows a backtrace at an arbitrary place in user code. Program + execution continues normally afterwards. The backtrace information is printed + to the unit corresponding to ``ERROR_UNIT`` in ``ISO_FORTRAN_ENV``. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL BACKTRACE + + Arguments: + None + + See also: + :ref:`ABORT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/besselj0.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/besselj0.rst new file mode 100644 index 00000000000..5317b76abd8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/besselj0.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _bessel_j0: + +.. index:: BESSEL_J0 + +.. index:: BESJ0 + +.. index:: DBESJ0 + +.. index:: Bessel function, first kind + +BESSEL_J0 --- Bessel function of the first kind of order 0 +********************************************************** + +.. function:: BESSEL_J0(X) + + ``BESSEL_J0(X)`` computes the Bessel function of the first kind of + order 0 of :samp:`{X}`. This function is available under the name + ``BESJ0`` as a GNU extension. + + :param X: + The type shall be ``REAL``. + + :return: + The return value is of type ``REAL`` and lies in the + range - 0.4027... \leq Bessel (0,x) \leq 1. It has the same + kind as :samp:`{X}`. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = BESSEL_J0(X) + + Example: + .. code-block:: fortran + + program test_besj0 + real(8) :: x = 0.0_8 + x = bessel_j0(x) + end program test_besj0 + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DBESJ0(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/besselj1.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/besselj1.rst new file mode 100644 index 00000000000..973c387cbc6 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/besselj1.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _bessel_j1: + +.. index:: BESSEL_J1 + +.. index:: BESJ1 + +.. index:: DBESJ1 + +.. index:: Bessel function, first kind + +BESSEL_J1 --- Bessel function of the first kind of order 1 +********************************************************** + +.. function:: BESSEL_J1(X) + + ``BESSEL_J1(X)`` computes the Bessel function of the first kind of + order 1 of :samp:`{X}`. This function is available under the name + ``BESJ1`` as a GNU extension. + + :param X: + The type shall be ``REAL``. + + :return: + The return value is of type ``REAL`` and lies in the + range - 0.5818... \leq Bessel (0,x) \leq 0.5818 . It has the same + kind as :samp:`{X}`. + + Standard: + Fortran 2008 + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = BESSEL_J1(X) + + Example: + .. code-block:: fortran + + program test_besj1 + real(8) :: x = 1.0_8 + x = bessel_j1(x) + end program test_besj1 + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DBESJ1(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/besseljn.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/besseljn.rst new file mode 100644 index 00000000000..75efb2b01d5 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/besseljn.rst @@ -0,0 +1,85 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _bessel_jn: + +.. index:: BESSEL_JN + +.. index:: BESJN + +.. index:: DBESJN + +.. index:: Bessel function, first kind + +BESSEL_JN --- Bessel function of the first kind +*********************************************** + +.. function:: BESSEL_JN(N, X) + + ``BESSEL_JN(N, X)`` computes the Bessel function of the first kind of + order :samp:`{N}` of :samp:`{X}`. This function is available under the name + ``BESJN`` as a GNU extension. If :samp:`{N}` and :samp:`{X}` are arrays, + their ranks and shapes shall conform. + + :param N: + Shall be a scalar or an array of type ``INTEGER``. + + :param N1: + Shall be a non-negative scalar of type ``INTEGER``. + + :param N2: + Shall be a non-negative scalar of type ``INTEGER``. + + :param X: + Shall be a scalar or an array of type ``REAL`` ; + for ``BESSEL_JN(N1, N2, X)`` it shall be scalar. + + :return: + The return value is a scalar of type ``REAL``. It has the same + kind as :samp:`{X}`. + + Standard: + Fortran 2008 and later, negative :samp:`{N}` is allowed as GNU extension + + Class: + Elemental function, except for the transformational function + ``BESSEL_JN(N1, N2, X)`` + + Syntax: + .. code-block:: fortran + + RESULT = BESSEL_JN(N, X) + RESULT = BESSEL_JN(N1, N2, X) + + Note: + The transformational function uses a recurrence algorithm which might, + for some values of :samp:`{X}`, lead to different results than calls to + the elemental function. + + Example: + .. code-block:: fortran + + program test_besjn + real(8) :: x = 1.0_8 + x = bessel_jn(5,x) + end program test_besjn + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DBESJN(N, X)`` + - ``INTEGER N`` + - ``REAL(8)`` + - GNU extension + * - + - ``REAL(8) X`` + - + - \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/bessely0.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/bessely0.rst new file mode 100644 index 00000000000..455ba64c590 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/bessely0.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _bessel_y0: + +.. index:: BESSEL_Y0 + +.. index:: BESY0 + +.. index:: DBESY0 + +.. index:: Bessel function, second kind + +BESSEL_Y0 --- Bessel function of the second kind of order 0 +*********************************************************** + +.. function:: BESSEL_Y0(X) + + ``BESSEL_Y0(X)`` computes the Bessel function of the second kind of + order 0 of :samp:`{X}`. This function is available under the name + ``BESY0`` as a GNU extension. + + :param X: + The type shall be ``REAL``. + + :return: + The return value is of type ``REAL``. It has the same kind as :samp:`{X}`. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = BESSEL_Y0(X) + + Example: + .. code-block:: fortran + + program test_besy0 + real(8) :: x = 0.0_8 + x = bessel_y0(x) + end program test_besy0 + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DBESY0(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/bessely1.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/bessely1.rst new file mode 100644 index 00000000000..e1f26af0d64 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/bessely1.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _bessel_y1: + +.. index:: BESSEL_Y1 + +.. index:: BESY1 + +.. index:: DBESY1 + +.. index:: Bessel function, second kind + +BESSEL_Y1 --- Bessel function of the second kind of order 1 +*********************************************************** + +.. function:: BESSEL_Y1(X) + + ``BESSEL_Y1(X)`` computes the Bessel function of the second kind of + order 1 of :samp:`{X}`. This function is available under the name + ``BESY1`` as a GNU extension. + + :param X: + The type shall be ``REAL``. + + :return: + The return value is of type ``REAL``. It has the same kind as :samp:`{X}`. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = BESSEL_Y1(X) + + Example: + .. code-block:: fortran + + program test_besy1 + real(8) :: x = 1.0_8 + x = bessel_y1(x) + end program test_besy1 + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DBESY1(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/besselyn.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/besselyn.rst new file mode 100644 index 00000000000..2a0556e838e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/besselyn.rst @@ -0,0 +1,85 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _bessel_yn: + +.. index:: BESSEL_YN + +.. index:: BESYN + +.. index:: DBESYN + +.. index:: Bessel function, second kind + +BESSEL_YN --- Bessel function of the second kind +************************************************ + +.. function:: BESSEL_YN(N, X) + + ``BESSEL_YN(N, X)`` computes the Bessel function of the second kind of + order :samp:`{N}` of :samp:`{X}`. This function is available under the name + ``BESYN`` as a GNU extension. If :samp:`{N}` and :samp:`{X}` are arrays, + their ranks and shapes shall conform. + + :param N: + Shall be a scalar or an array of type ``INTEGER`` . + + :param N1: + Shall be a non-negative scalar of type ``INTEGER``. + + :param N2: + Shall be a non-negative scalar of type ``INTEGER``. + + :param X: + Shall be a scalar or an array of type ``REAL`` ; + for ``BESSEL_YN(N1, N2, X)`` it shall be scalar. + + :return: + The return value is a scalar of type ``REAL``. It has the same + kind as :samp:`{X}`. + + Standard: + Fortran 2008 and later, negative :samp:`{N}` is allowed as GNU extension + + Class: + Elemental function, except for the transformational function + ``BESSEL_YN(N1, N2, X)`` + + Syntax: + .. code-block:: fortran + + RESULT = BESSEL_YN(N, X) + RESULT = BESSEL_YN(N1, N2, X) + + Note: + The transformational function uses a recurrence algorithm which might, + for some values of :samp:`{X}`, lead to different results than calls to + the elemental function. + + Example: + .. code-block:: fortran + + program test_besyn + real(8) :: x = 1.0_8 + x = bessel_yn(5,x) + end program test_besyn + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DBESYN(N,X)`` + - ``INTEGER N`` + - ``REAL(8)`` + - GNU extension + * - + - ``REAL(8) X`` + - + - \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/bge.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/bge.rst new file mode 100644 index 00000000000..0b53692d0ef --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/bge.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: BGE, bitwise comparison + +.. _bge: + +BGE --- Bitwise greater than or equal to +**************************************** + +.. function:: BGE(I, J) + + Determines whether an integral is a bitwise greater than or equal to + another. + + :param I: + Shall be of ``INTEGER`` type. + + :param J: + Shall be of ``INTEGER`` type, and of the same kind + as :samp:`{I}`. + + :return: + The return value is of type ``LOGICAL`` and of the default kind. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = BGE(I, J) + + See also: + :ref:`BGT`, + :ref:`BLE`, + :ref:`BLT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/bgt.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/bgt.rst new file mode 100644 index 00000000000..b033ef57fc4 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/bgt.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: BGT, bitwise comparison + +.. _bgt: + +BGT --- Bitwise greater than +**************************** + +.. function:: BGT(I, J) + + Determines whether an integral is a bitwise greater than another. + + :param I: + Shall be of ``INTEGER`` type. + + :param J: + Shall be of ``INTEGER`` type, and of the same kind + as :samp:`{I}`. + + :return: + The return value is of type ``LOGICAL`` and of the default kind. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = BGT(I, J) + + See also: + :ref:`BGE`, + :ref:`BLE`, + :ref:`BLT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/bitsize.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/bitsize.rst new file mode 100644 index 00000000000..2aac37c6a9b --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/bitsize.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: BIT_SIZE, bits, number of, size of a variable, in bits + +.. _bit_size: + +BIT_SIZE --- Bit size inquiry function +************************************** + +.. function:: BIT_SIZE(I) + + ``BIT_SIZE(I)`` returns the number of bits (integer precision plus sign bit) + represented by the type of :samp:`{I}`. The result of ``BIT_SIZE(I)`` is + independent of the actual value of :samp:`{I}`. + + :param I: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` + + Standard: + Fortran 90 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = BIT_SIZE(I) + + Example: + .. code-block:: fortran + + program test_bit_size + integer :: i = 123 + integer :: size + size = bit_size(i) + print *, size + end program test_bit_size \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ble.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ble.rst new file mode 100644 index 00000000000..51444469570 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ble.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: BLE, bitwise comparison + +.. _ble: + +BLE --- Bitwise less than or equal to +************************************* + +.. function:: BLE(I, J) + + Determines whether an integral is a bitwise less than or equal to + another. + + :param I: + Shall be of ``INTEGER`` type. + + :param J: + Shall be of ``INTEGER`` type, and of the same kind + as :samp:`{I}`. + + :return: + The return value is of type ``LOGICAL`` and of the default kind. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = BLE(I, J) + + See also: + :ref:`BGT`, + :ref:`BGE`, + :ref:`BLT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/blt.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/blt.rst new file mode 100644 index 00000000000..225f63f200c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/blt.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: BLT, bitwise comparison + +.. _blt: + +BLT --- Bitwise less than +************************* + +.. function:: BLT(I, J) + + Determines whether an integral is a bitwise less than another. + + :param I: + Shall be of ``INTEGER`` type. + + :param J: + Shall be of ``INTEGER`` type, and of the same kind + as :samp:`{I}`. + + :return: + The return value is of type ``LOGICAL`` and of the default kind. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = BLT(I, J) + + See also: + :ref:`BGE`, + :ref:`BGT`, + :ref:`BLE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/btest.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/btest.rst new file mode 100644 index 00000000000..c0f9c914259 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/btest.rst @@ -0,0 +1,89 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _btest: + +.. index:: BTEST + +.. index:: BBTEST + +.. index:: BITEST + +.. index:: BJTEST + +.. index:: BKTEST + +.. index:: bits, testing + +BTEST --- Bit test function +*************************** + +.. function:: BTEST(I,POS) + + ``BTEST(I,POS)`` returns logical ``.TRUE.`` if the bit at :samp:`{POS}` + in :samp:`{I}` is set. The counting of the bits starts at 0. + + :param I: + The type shall be ``INTEGER``. + + :param POS: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``LOGICAL`` + + Standard: + Fortran 90 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = BTEST(I, POS) + + Example: + .. code-block:: fortran + + program test_btest + integer :: i = 32768 + 1024 + 64 + integer :: pos + logical :: bool + do pos=0,16 + bool = btest(i, pos) + print *, pos, bool + end do + end program test_btest + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``BTEST(I,POS)`` + - ``INTEGER I,POS`` + - ``LOGICAL`` + - Fortran 95 and later + * - ``BBTEST(I,POS)`` + - ``INTEGER(1) I,POS`` + - ``LOGICAL(1)`` + - GNU extension + * - ``BITEST(I,POS)`` + - ``INTEGER(2) I,POS`` + - ``LOGICAL(2)`` + - GNU extension + * - ``BJTEST(I,POS)`` + - ``INTEGER(4) I,POS`` + - ``LOGICAL(4)`` + - GNU extension + * - ``BKTEST(I,POS)`` + - ``INTEGER(8) I,POS`` + - ``LOGICAL(8)`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cassociated.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cassociated.rst new file mode 100644 index 00000000000..a42c04d1823 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cassociated.rst @@ -0,0 +1,54 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _c_associated: + +C_ASSOCIATED --- Status of a C pointer +************************************** + +.. index:: C_ASSOCIATED, association status, C pointer, pointer, C association status + +.. function:: C_ASSOCIATED(c_ptr_1, c_ptr_2) + + ``C_ASSOCIATED(c_ptr_1[, c_ptr_2])`` determines the status of the C pointer + :samp:`{c_ptr_1}` or if :samp:`{c_ptr_1}` is associated with the target :samp:`{c_ptr_2}`. + + :param c_ptr_1: + Scalar of the type ``C_PTR`` or ``C_FUNPTR``. + + :param c_ptr_2: + (Optional) Scalar of the same type as :samp:`{c_ptr_1}`. + + :return: + The return value is of type ``LOGICAL`` ; it is ``.false.`` if either + :samp:`{c_ptr_1}` is a C NULL pointer or if :samp:`{c_ptr1}` and :samp:`{c_ptr_2}` + point to different addresses. + + Standard: + Fortran 2003 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = C_ASSOCIATED(c_ptr_1[, c_ptr_2]) + + Example: + .. code-block:: fortran + + subroutine association_test(a,b) + use iso_c_binding, only: c_associated, c_loc, c_ptr + implicit none + real, pointer :: a + type(c_ptr) :: b + if(c_associated(b, c_loc(a))) & + stop 'b and a do not point to same target' + end subroutine association_test + + See also: + :ref:`C_LOC`, + :ref:`C_FUNLOC` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ceiling.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ceiling.rst new file mode 100644 index 00000000000..de9e21163a4 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ceiling.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: CEILING, ceiling, rounding, ceiling + +.. _ceiling: + +CEILING --- Integer ceiling function +************************************ + +.. function:: CEILING(A) + + ``CEILING(A)`` returns the least integer greater than or equal to :samp:`{A}`. + + :param A: + The type shall be ``REAL``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER(KIND)`` if :samp:`{KIND}` is present + and a default-kind ``INTEGER`` otherwise. + + Standard: + Fortran 95 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = CEILING(A [, KIND]) + + Example: + .. code-block:: fortran + + program test_ceiling + real :: x = 63.29 + real :: y = -63.59 + print *, ceiling(x) ! returns 64 + print *, ceiling(y) ! returns -63 + end program test_ceiling + + See also: + :ref:`FLOOR`, + :ref:`NINT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cfpointer.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cfpointer.rst new file mode 100644 index 00000000000..2d60e2c7914 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cfpointer.rst @@ -0,0 +1,63 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _c_f_pointer: + +C_F_POINTER --- Convert C into Fortran pointer +********************************************** + +.. index:: C_F_POINTER, pointer, convert C to Fortran + +.. function:: C_F_POINTER(CPTR, FPTR, SHAPE) + + ``C_F_POINTER(CPTR, FPTR[, SHAPE])`` assigns the target of the C pointer + :samp:`{CPTR}` to the Fortran pointer :samp:`{FPTR}` and specifies its shape. + + :param CPTR: + scalar of the type ``C_PTR``. It is + ``INTENT(IN)``. + + :param FPTR: + pointer interoperable with :samp:`{cptr}`. It is + ``INTENT(OUT)``. + + :param SHAPE: + (Optional) Rank-one array of type ``INTEGER`` + with ``INTENT(IN)``. It shall be present + if and only if :samp:`{fptr}` is an array. The size + must be equal to the rank of :samp:`{fptr}`. + + Standard: + Fortran 2003 and later + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL C_F_POINTER(CPTR, FPTR[, SHAPE]) + + Example: + .. code-block:: fortran + + program main + use iso_c_binding + implicit none + interface + subroutine my_routine(p) bind(c,name='myC_func') + import :: c_ptr + type(c_ptr), intent(out) :: p + end subroutine + end interface + type(c_ptr) :: cptr + real,pointer :: a(:) + call my_routine(cptr) + call c_f_pointer(cptr, a, [12]) + end program main + + See also: + :ref:`C_LOC`, + :ref:`C_F_PROCPOINTER` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cfprocpointer.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cfprocpointer.rst new file mode 100644 index 00000000000..2dedd69645c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cfprocpointer.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: C_F_PROCPOINTER, pointer, C address of pointers + +.. _c_f_procpointer: + +C_F_PROCPOINTER --- Convert C into Fortran procedure pointer +************************************************************ + +.. function:: C_F_PROCPOINTER(CPTR, FPTR) + + ``C_F_PROCPOINTER(CPTR, FPTR)`` Assign the target of the C function pointer + :samp:`{CPTR}` to the Fortran procedure pointer :samp:`{FPTR}`. + + :param CPTR: + scalar of the type ``C_FUNPTR``. It is + ``INTENT(IN)``. + + :param FPTR: + procedure pointer interoperable with :samp:`{cptr}`. It is + ``INTENT(OUT)``. + + Standard: + Fortran 2003 and later + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL C_F_PROCPOINTER(cptr, fptr) + + Example: + .. code-block:: fortran + + program main + use iso_c_binding + implicit none + abstract interface + function func(a) + import :: c_float + real(c_float), intent(in) :: a + real(c_float) :: func + end function + end interface + interface + function getIterFunc() bind(c,name="getIterFunc") + import :: c_funptr + type(c_funptr) :: getIterFunc + end function + end interface + type(c_funptr) :: cfunptr + procedure(func), pointer :: myFunc + cfunptr = getIterFunc() + call c_f_procpointer(cfunptr, myFunc) + end program main + + See also: + :ref:`C_LOC`, + :ref:`C_F_POINTER` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cfunloc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cfunloc.rst new file mode 100644 index 00000000000..19c8c19bf3d --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cfunloc.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: C_FUNLOC, pointer, C address of procedures + +.. _c_funloc: + +C_FUNLOC --- Obtain the C address of a procedure +************************************************ + +.. function:: C_FUNLOC(x) + + ``C_FUNLOC(x)`` determines the C address of the argument. + + :param x: + Interoperable function or pointer to such function. + + :return: + The return value is of type ``C_FUNPTR`` and contains the C address + of the argument. + + Standard: + Fortran 2003 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = C_FUNLOC(x) + + Example: + .. code-block:: fortran + + module x + use iso_c_binding + implicit none + contains + subroutine sub(a) bind(c) + real(c_float) :: a + a = sqrt(a)+5.0 + end subroutine sub + end module x + program main + use iso_c_binding + use x + implicit none + interface + subroutine my_routine(p) bind(c,name='myC_func') + import :: c_funptr + type(c_funptr), intent(in) :: p + end subroutine + end interface + call my_routine(c_funloc(sub)) + end program main + + See also: + :ref:`C_ASSOCIATED`, + :ref:`C_LOC`, + :ref:`C_F_POINTER`, + :ref:`C_F_PROCPOINTER` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/char.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/char.rst new file mode 100644 index 00000000000..221deca4882 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/char.rst @@ -0,0 +1,71 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _char: + +.. index:: CHAR + +.. index:: conversion, to character + +CHAR --- Character conversion function +************************************** + +.. function:: CHAR(I [, KIND]) + + ``CHAR(I [, KIND])`` returns the character represented by the integer :samp:`{I}`. + + :param I: + The type shall be ``INTEGER``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``CHARACTER(1)`` + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = CHAR(I [, KIND]) + + Example: + .. code-block:: fortran + + program test_char + integer :: i = 74 + character(1) :: c + c = char(i) + print *, i, c ! returns 'J' + end program test_char + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``CHAR(I)`` + - ``INTEGER I`` + - ``CHARACTER(LEN=1)`` + - Fortran 77 and later + + Note: + See :ref:`ICHAR` for a discussion of converting between numerical values + and formatted string representations. + + See also: + :ref:`ACHAR`, + :ref:`IACHAR`, + :ref:`ICHAR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/chdir.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/chdir.rst new file mode 100644 index 00000000000..45126dfbc0e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/chdir.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: CHDIR, system, working directory + +.. _chdir: + +CHDIR --- Change working directory +********************************** + +.. function:: CHDIR(NAME) + + Change current working directory to a specified path. + + :param NAME: + The type shall be ``CHARACTER`` of default + kind and shall specify a valid path within the file system. + + :param STATUS: + (Optional) ``INTEGER`` status flag of the default + kind. Returns 0 on success, and a system specific and nonzero error code + otherwise. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL CHDIR(NAME [, STATUS]) + STATUS = CHDIR(NAME) + + Example: + .. code-block:: fortran + + PROGRAM test_chdir + CHARACTER(len=255) :: path + CALL getcwd(path) + WRITE(*,*) TRIM(path) + CALL chdir("/tmp") + CALL getcwd(path) + WRITE(*,*) TRIM(path) + END PROGRAM + + See also: + :ref:`GETCWD` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/chmod.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/chmod.rst new file mode 100644 index 00000000000..890b4ffba21 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/chmod.rst @@ -0,0 +1,70 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _chmod: + +CHMOD --- Change access permissions of files +******************************************** + +.. index:: CHMOD(NAME, MODE, STATUS), file system, change access mode + +.. function:: CHMOD(NAME, MODE, STATUS) + + ``CHMOD`` changes the permissions of a file. + + :param NAME: + Scalar ``CHARACTER`` of default kind with the + file name. Trailing blanks are ignored unless the character + ``achar(0)`` is present, then all characters up to and excluding + ``achar(0)`` are used as the file name. + + :param MODE: + Scalar ``CHARACTER`` of default kind giving the + file permission. :samp:`{MODE}` uses the same syntax as the ``chmod`` utility + as defined by the POSIX standard. The argument shall either be a string of + a nonnegative octal number or a symbolic mode. + + :param STATUS: + (optional) scalar ``INTEGER``, which is + ``0`` on success and nonzero otherwise. + + :return: + In either syntax, :samp:`{STATUS}` is set to ``0`` on success and nonzero + otherwise. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL CHMOD(NAME, MODE[, STATUS]) + STATUS = CHMOD(NAME, MODE) + + Example: + ``CHMOD`` as subroutine + + .. code-block:: fortran + + program chmod_test + implicit none + integer :: status + call chmod('test.dat','u+x',status) + print *, 'Status: ', status + end program chmod_test + + ``CHMOD`` as function: + + .. code-block:: fortran + + program chmod_test + implicit none + integer :: status + status = chmod('test.dat','u+x') + print *, 'Status: ', status + end program chmod_test \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cloc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cloc.rst new file mode 100644 index 00000000000..8261e4d57a9 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cloc.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: C_LOC, procedure pointer, convert C to Fortran + +.. _c_loc: + +C_LOC --- Obtain the C address of an object +******************************************* + +.. function:: C_LOC(X) + + ``C_LOC(X)`` determines the C address of the argument. + + :param X: + Shall have either the POINTER or TARGET attribute. It shall not be a coindexed object. It shall either be a variable with interoperable type and kind type parameters, or be a scalar, nonpolymorphic variable with no length type parameters. + + :return: + The return value is of type ``C_PTR`` and contains the C address + of the argument. + + Standard: + Fortran 2003 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = C_LOC(X) + + Example: + .. code-block:: fortran + + subroutine association_test(a,b) + use iso_c_binding, only: c_associated, c_loc, c_ptr + implicit none + real, pointer :: a + type(c_ptr) :: b + if(c_associated(b, c_loc(a))) & + stop 'b and a do not point to same target' + end subroutine association_test + + See also: + :ref:`C_ASSOCIATED`, + :ref:`C_FUNLOC`, + :ref:`C_F_POINTER`, + :ref:`C_F_PROCPOINTER` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cmplx.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cmplx.rst new file mode 100644 index 00000000000..790c9d01475 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cmplx.rst @@ -0,0 +1,61 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _cmplx: + +CMPLX --- Complex conversion function +************************************* + +.. index:: CMPLX, complex numbers, conversion to, conversion, to complex + +.. function:: CMPLX(X, Y, KIND) + + ``CMPLX(X [, Y [, KIND]])`` returns a complex number where :samp:`{X}` is converted to + the real component. If :samp:`{Y}` is present it is converted to the imaginary + component. If :samp:`{Y}` is not present then the imaginary component is set to + 0.0. If :samp:`{X}` is complex then :samp:`{Y}` must not be present. + + :param X: + The type may be ``INTEGER``, ``REAL``, + or ``COMPLEX``. + + :param Y: + (Optional; only allowed if :samp:`{X}` is not + ``COMPLEX``.) May be ``INTEGER`` or ``REAL``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of ``COMPLEX`` type, with a kind equal to + :samp:`{KIND}` if it is specified. If :samp:`{KIND}` is not specified, the + result is of the default ``COMPLEX`` kind, regardless of the kinds of + :samp:`{X}` and :samp:`{Y}`. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = CMPLX(X [, Y [, KIND]]) + + Example: + .. code-block:: fortran + + program test_cmplx + integer :: i = 42 + real :: x = 3.14 + complex :: z + z = cmplx(i, x) + print *, z, cmplx(x) + end program test_cmplx + + See also: + :ref:`COMPLEX` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cobroadcast.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cobroadcast.rst new file mode 100644 index 00000000000..65a2e1ebbf0 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cobroadcast.rst @@ -0,0 +1,65 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _co_broadcast: + +CO_BROADCAST --- Copy a value to all images the current set of images +********************************************************************* + +.. index:: CO_BROADCAST, Collectives, value broadcasting + +.. function:: CO_BROADCAST(A, SOURCE_IMAGE, STAT, ERRMSG) + + ``CO_BROADCAST`` copies the value of argument :samp:`{A}` on the image with + image index ``SOURCE_IMAGE`` to all images in the current team. :samp:`{A}` + becomes defined as if by intrinsic assignment. If the execution was + successful and :samp:`{STAT}` is present, it is assigned the value zero. If the + execution failed, :samp:`{STAT}` gets assigned a nonzero value and, if present, + :samp:`{ERRMSG}` gets assigned a value describing the occurred error. + + :param A: + INTENT(INOUT) argument; shall have the same + dynamic type and type parameters on all images of the current team. If it + is an array, it shall have the same shape on all images. + + :param SOURCE_IMAGE: + a scalar integer expression. + It shall have the same value on all images and refer to an + image of the current team. + + :param STAT: + (optional) a scalar integer variable + + :param ERRMSG: + (optional) a scalar character variable + + Standard: + Technical Specification (TS) 18508 or later + + Class: + Collective subroutine + + Syntax: + .. code-block:: fortran + + CALL CO_BROADCAST(A, SOURCE_IMAGE [, STAT, ERRMSG]) + + Example: + .. code-block:: fortran + + program test + integer :: val(3) + if (this_image() == 1) then + val = [1, 5, 3] + end if + call co_broadcast (val, source_image=1) + print *, this_image, ":", val + end program test + + See also: + :ref:`CO_MAX`, + :ref:`CO_MIN`, + :ref:`CO_SUM`, + :ref:`CO_REDUCE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/comax.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/comax.rst new file mode 100644 index 00000000000..d8f1be6d4a9 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/comax.rst @@ -0,0 +1,66 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _co_max: + +CO_MAX --- Maximal value on the current set of images +***************************************************** + +.. index:: CO_MAX, Collectives, maximal value + +.. function:: CO_MAX(A, RESULT_IMAGE, STAT, ERRMSG) + + ``CO_MAX`` determines element-wise the maximal value of :samp:`{A}` on all + images of the current team. If :samp:`{RESULT_IMAGE}` is present, the maximum + values are returned in :samp:`{A}` on the specified image only and the value + of :samp:`{A}` on the other images become undefined. If :samp:`{RESULT_IMAGE}` is + not present, the value is returned on all images. If the execution was + successful and :samp:`{STAT}` is present, it is assigned the value zero. If the + execution failed, :samp:`{STAT}` gets assigned a nonzero value and, if present, + :samp:`{ERRMSG}` gets assigned a value describing the occurred error. + + :param A: + shall be an integer, real or character variable, + which has the same type and type parameters on all images of the team. + + :param RESULT_IMAGE: + (optional) a scalar integer expression; if + present, it shall have the same value on all images and refer to an + image of the current team. + + :param STAT: + (optional) a scalar integer variable + + :param ERRMSG: + (optional) a scalar character variable + + Standard: + Technical Specification (TS) 18508 or later + + Class: + Collective subroutine + + Syntax: + .. code-block:: fortran + + CALL CO_MAX(A [, RESULT_IMAGE, STAT, ERRMSG]) + + Example: + .. code-block:: fortran + + program test + integer :: val + val = this_image () + call co_max (val, result_image=1) + if (this_image() == 1) then + write(*,*) "Maximal value", val ! prints num_images() + end if + end program test + + See also: + :ref:`CO_MIN`, + :ref:`CO_SUM`, + :ref:`CO_REDUCE`, + :ref:`CO_BROADCAST` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/comin.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/comin.rst new file mode 100644 index 00000000000..4bf2739b43e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/comin.rst @@ -0,0 +1,66 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _co_min: + +CO_MIN --- Minimal value on the current set of images +***************************************************** + +.. index:: CO_MIN, Collectives, minimal value + +.. function:: CO_MIN(A, RESULT_IMAGE, STAT, ERRMSG) + + ``CO_MIN`` determines element-wise the minimal value of :samp:`{A}` on all + images of the current team. If :samp:`{RESULT_IMAGE}` is present, the minimal + values are returned in :samp:`{A}` on the specified image only and the value + of :samp:`{A}` on the other images become undefined. If :samp:`{RESULT_IMAGE}` is + not present, the value is returned on all images. If the execution was + successful and :samp:`{STAT}` is present, it is assigned the value zero. If the + execution failed, :samp:`{STAT}` gets assigned a nonzero value and, if present, + :samp:`{ERRMSG}` gets assigned a value describing the occurred error. + + :param A: + shall be an integer, real or character variable, + which has the same type and type parameters on all images of the team. + + :param RESULT_IMAGE: + (optional) a scalar integer expression; if + present, it shall have the same value on all images and refer to an + image of the current team. + + :param STAT: + (optional) a scalar integer variable + + :param ERRMSG: + (optional) a scalar character variable + + Standard: + Technical Specification (TS) 18508 or later + + Class: + Collective subroutine + + Syntax: + .. code-block:: fortran + + CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG]) + + Example: + .. code-block:: fortran + + program test + integer :: val + val = this_image () + call co_min (val, result_image=1) + if (this_image() == 1) then + write(*,*) "Minimal value", val ! prints 1 + end if + end program test + + See also: + :ref:`CO_MAX`, + :ref:`CO_SUM`, + :ref:`CO_REDUCE`, + :ref:`CO_BROADCAST` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/commandargumentcount.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/commandargumentcount.rst new file mode 100644 index 00000000000..2d344b79351 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/commandargumentcount.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _command_argument_count: + +COMMAND_ARGUMENT_COUNT --- Get number of command line arguments +*************************************************************** + +.. index:: COMMAND_ARGUMENT_COUNT, command-line arguments, command-line arguments, number of, arguments, to program + +.. function:: COMMAND_ARGUMENT_COUNT() + + ``COMMAND_ARGUMENT_COUNT`` returns the number of arguments passed on the + command line when the containing program was invoked. + + :return: + The return value is an ``INTEGER`` of default kind. + + Standard: + Fortran 2003 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = COMMAND_ARGUMENT_COUNT() + + Example: + .. code-block:: fortran + + program test_command_argument_count + integer :: count + count = command_argument_count() + print *, count + end program test_command_argument_count + + See also: + :ref:`GET_COMMAND`, + :ref:`GET_COMMAND_ARGUMENT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/compileroptions.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/compileroptions.rst new file mode 100644 index 00000000000..81552e11931 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/compileroptions.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _compiler_options: + +COMPILER_OPTIONS --- Options passed to the compiler +*************************************************** + +.. index:: COMPILER_OPTIONS, flags inquiry function, options inquiry function, compiler flags inquiry function + +.. function:: COMPILER_OPTIONS() + + ``COMPILER_OPTIONS`` returns a string with the options used for + compiling. + + :return: + The return value is a default-kind string with system-dependent length. + It contains the compiler flags used to compile the file, which called + the ``COMPILER_OPTIONS`` intrinsic. + + Standard: + Fortran 2008 + + Class: + Inquiry function of the module ``ISO_FORTRAN_ENV`` + + Syntax: + .. code-block:: fortran + + STR = COMPILER_OPTIONS() + + Arguments: + None + + Example: + .. code-block:: fortran + + use iso_fortran_env + print '(4a)', 'This file was compiled by ', & + compiler_version(), ' using the options ', & + compiler_options() + end + + See also: + :ref:`COMPILER_VERSION`, + :ref:`ISO_FORTRAN_ENV` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/compilerversion.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/compilerversion.rst new file mode 100644 index 00000000000..526d272c4a9 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/compilerversion.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _compiler_version: + +COMPILER_VERSION --- Compiler version string +******************************************** + +.. index:: COMPILER_VERSION, compiler, name and version, version of the compiler + +.. function:: COMPILER_VERSION() + + ``COMPILER_VERSION`` returns a string with the name and the + version of the compiler. + + :return: + The return value is a default-kind string with system-dependent length. + It contains the name of the compiler and its version number. + + Standard: + Fortran 2008 + + Class: + Inquiry function of the module ``ISO_FORTRAN_ENV`` + + Syntax: + .. code-block:: fortran + + STR = COMPILER_VERSION() + + Arguments: + None + + Example: + .. code-block:: fortran + + use iso_fortran_env + print '(4a)', 'This file was compiled by ', & + compiler_version(), ' using the options ', & + compiler_options() + end + + See also: + :ref:`COMPILER_OPTIONS`, + :ref:`ISO_FORTRAN_ENV` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/complex.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/complex.rst new file mode 100644 index 00000000000..dc5d54798ea --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/complex.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: COMPLEX, complex numbers, conversion to, conversion, to complex + +.. _complex: + +COMPLEX --- Complex conversion function +*************************************** + +.. function:: COMPLEX(X, Y) + + ``COMPLEX(X, Y)`` returns a complex number where :samp:`{X}` is converted + to the real component and :samp:`{Y}` is converted to the imaginary + component. + + :param X: + The type may be ``INTEGER`` or ``REAL``. + + :param Y: + The type may be ``INTEGER`` or ``REAL``. + + :return: + If :samp:`{X}` and :samp:`{Y}` are both of ``INTEGER`` type, then the return + value is of default ``COMPLEX`` type. + + Standard: + GNU extension + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = COMPLEX(X, Y) + + Example: + .. code-block:: fortran + + program test_complex + integer :: i = 42 + real :: x = 3.14 + print *, complex(i, x) + end program test_complex + + See also: + :ref:`CMPLX` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/conjg.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/conjg.rst new file mode 100644 index 00000000000..80d3f7bd79a --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/conjg.rst @@ -0,0 +1,63 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _conjg: + +.. index:: CONJG + +.. index:: DCONJG + +.. index:: complex conjugate + +CONJG --- Complex conjugate function +************************************ + +.. function:: CONJG(Z) + + ``CONJG(Z)`` returns the conjugate of :samp:`{Z}`. If :samp:`{Z}` is ``(x, y)`` + then the result is ``(x, -y)`` + + :param Z: + The type shall be ``COMPLEX``. + + :return: + The return value is of type ``COMPLEX``. + + Standard: + Fortran 77 and later, has an overload that is a GNU extension + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + Z = CONJG(Z) + + Example: + .. code-block:: fortran + + program test_conjg + complex :: z = (2.0, 3.0) + complex(8) :: dz = (2.71_8, -3.14_8) + z= conjg(z) + print *, z + dz = dconjg(dz) + print *, dz + end program test_conjg + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DCONJG(Z)`` + - ``COMPLEX(8) Z`` + - ``COMPLEX(8)`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/coreduce.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/coreduce.rst new file mode 100644 index 00000000000..cba765facc8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/coreduce.rst @@ -0,0 +1,94 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _co_reduce: + +CO_REDUCE --- Reduction of values on the current set of images +************************************************************** + +.. index:: CO_REDUCE, Collectives, generic reduction + +.. function:: CO_REDUCE(A, OPERATOR, RESULT_IMAGE, STAT, ERRMSG) + + ``CO_REDUCE`` determines element-wise the reduction of the value of :samp:`{A}` + on all images of the current team. The pure function passed as :samp:`{OPERATION}` + is used to pairwise reduce the values of :samp:`{A}` by passing either the value + of :samp:`{A}` of different images or the result values of such a reduction as + argument. If :samp:`{A}` is an array, the deduction is done element wise. If + :samp:`{RESULT_IMAGE}` is present, the result values are returned in :samp:`{A}` on + the specified image only and the value of :samp:`{A}` on the other images become + undefined. If :samp:`{RESULT_IMAGE}` is not present, the value is returned on all + images. If the execution was successful and :samp:`{STAT}` is present, it is + assigned the value zero. If the execution failed, :samp:`{STAT}` gets assigned + a nonzero value and, if present, :samp:`{ERRMSG}` gets assigned a value describing + the occurred error. + + :param A: + is an ``INTENT(INOUT)`` argument and shall be + nonpolymorphic. If it is allocatable, it shall be allocated; if it is a pointer, + it shall be associated. :samp:`{A}` shall have the same type and type parameters on + all images of the team; if it is an array, it shall have the same shape on all + images. + + :param OPERATION: + pure function with two scalar nonallocatable + arguments, which shall be nonpolymorphic and have the same type and type + parameters as :samp:`{A}`. The function shall return a nonallocatable scalar of + the same type and type parameters as :samp:`{A}`. The function shall be the same on + all images and with regards to the arguments mathematically commutative and + associative. Note that :samp:`{OPERATION}` may not be an elemental function, unless + it is an intrisic function. + + :param RESULT_IMAGE: + (optional) a scalar integer expression; if + present, it shall have the same value on all images and refer to an + image of the current team. + + :param STAT: + (optional) a scalar integer variable + + :param ERRMSG: + (optional) a scalar character variable + + Standard: + Technical Specification (TS) 18508 or later + + Class: + Collective subroutine + + Syntax: + .. code-block:: fortran + + CALL CO_REDUCE(A, OPERATION, [, RESULT_IMAGE, STAT, ERRMSG]) + + Example: + .. code-block:: fortran + + program test + integer :: val + val = this_image () + call co_reduce (val, result_image=1, operation=myprod) + if (this_image() == 1) then + write(*,*) "Product value", val ! prints num_images() factorial + end if + contains + pure function myprod(a, b) + integer, value :: a, b + integer :: myprod + myprod = a * b + end function myprod + end program test + + Note: + While the rules permit in principle an intrinsic function, none of the + intrinsics in the standard fulfill the criteria of having a specific + function, which takes two arguments of the same type and returning that + type as result. + + See also: + :ref:`CO_MIN`, + :ref:`CO_MAX`, + :ref:`CO_SUM`, + :ref:`CO_BROADCAST` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cos.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cos.rst new file mode 100644 index 00000000000..de283c412c8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cos.rst @@ -0,0 +1,91 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _cos: + +.. index:: COS + +.. index:: DCOS + +.. index:: CCOS + +.. index:: ZCOS + +.. index:: CDCOS + +.. index:: trigonometric function, cosine + +.. index:: cosine + +COS --- Cosine function +*********************** + +.. function:: COS(X) + + ``COS(X)`` computes the cosine of :samp:`{X}`. + + :param X: + The type shall be ``REAL`` or + ``COMPLEX``. + + :return: + The return value is of the same type and kind as :samp:`{X}`. The real part + of the result is in radians. If :samp:`{X}` is of the type ``REAL``, + the return value lies in the range -1 \leq \cos (x) \leq 1. + + Standard: + Fortran 77 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = COS(X) + + Example: + .. code-block:: fortran + + program test_cos + real :: x = 0.0 + x = cos(x) + end program test_cos + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``COS(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DCOS(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 77 and later + * - ``CCOS(X)`` + - ``COMPLEX(4) X`` + - ``COMPLEX(4)`` + - Fortran 77 and later + * - ``ZCOS(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension + * - ``CDCOS(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension + + See also: + Inverse function: + :ref:`ACOS` + Degrees function: + :ref:`COSD` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cosd.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cosd.rst new file mode 100644 index 00000000000..fa54ab49a20 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cosd.rst @@ -0,0 +1,91 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _cosd: + +.. index:: COSD + +.. index:: DCOSD + +.. index:: CCOSD + +.. index:: ZCOSD + +.. index:: CDCOSD + +.. index:: trigonometric function, cosine, degrees + +.. index:: cosine, degrees + +COSD --- Cosine function, degrees +********************************* + +.. function:: COSD(X) + + ``COSD(X)`` computes the cosine of :samp:`{X}` in degrees. + + :param X: + The type shall be ``REAL`` or + ``COMPLEX``. + + :return: + The return value is of the same type and kind as :samp:`{X}`. The real part + of the result is in degrees. If :samp:`{X}` is of the type ``REAL``, + the return value lies in the range -1 \leq \cosd (x) \leq 1. + + Standard: + GNU extension, enabled with :option:`-fdec-math`. + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = COSD(X) + + Example: + .. code-block:: fortran + + program test_cosd + real :: x = 0.0 + x = cosd(x) + end program test_cosd + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``COSD(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - GNU extension + * - ``DCOSD(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension + * - ``CCOSD(X)`` + - ``COMPLEX(4) X`` + - ``COMPLEX(4)`` + - GNU extension + * - ``ZCOSD(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension + * - ``CDCOSD(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension + + See also: + Inverse function: + :ref:`ACOSD` + Radians function: + :ref:`COS` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cosh.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cosh.rst new file mode 100644 index 00000000000..cf421dd5db5 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cosh.rst @@ -0,0 +1,73 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _cosh: + +.. index:: COSH + +.. index:: DCOSH + +.. index:: hyperbolic cosine + +.. index:: hyperbolic function, cosine + +.. index:: cosine, hyperbolic + +COSH --- Hyperbolic cosine function +*********************************** + +.. function:: COSH(X) + + ``COSH(X)`` computes the hyperbolic cosine of :samp:`{X}`. + + :param X: + The type shall be ``REAL`` or ``COMPLEX``. + + :return: + The return value has same type and kind as :samp:`{X}`. If :samp:`{X}` is + complex, the imaginary part of the result is in radians. If :samp:`{X}` + is ``REAL``, the return value has a lower bound of one, + \cosh (x) \geq 1. + + Standard: + Fortran 77 and later, for a complex argument Fortran 2008 or later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + X = COSH(X) + + Example: + .. code-block:: fortran + + program test_cosh + real(8) :: x = 1.0_8 + x = cosh(x) + end program test_cosh + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``COSH(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DCOSH(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 77 and later + + See also: + Inverse function: + :ref:`ACOSH` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cosum.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cosum.rst new file mode 100644 index 00000000000..49d4cbd100f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cosum.rst @@ -0,0 +1,67 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _co_sum: + +CO_SUM --- Sum of values on the current set of images +***************************************************** + +.. index:: CO_SUM, Collectives, sum of values + +.. function:: CO_SUM(A, RESULT_IMAGE, STAT, ERRMSG) + + ``CO_SUM`` sums up the values of each element of :samp:`{A}` on all + images of the current team. If :samp:`{RESULT_IMAGE}` is present, the summed-up + values are returned in :samp:`{A}` on the specified image only and the value + of :samp:`{A}` on the other images become undefined. If :samp:`{RESULT_IMAGE}` is + not present, the value is returned on all images. If the execution was + successful and :samp:`{STAT}` is present, it is assigned the value zero. If the + execution failed, :samp:`{STAT}` gets assigned a nonzero value and, if present, + :samp:`{ERRMSG}` gets assigned a value describing the occurred error. + + :param A: + shall be an integer, real or complex variable, + which has the same type and type parameters on all images of the team. + + :param RESULT_IMAGE: + (optional) a scalar integer expression; if + present, it shall have the same value on all images and refer to an + image of the current team. + + :param STAT: + (optional) a scalar integer variable + + :param ERRMSG: + (optional) a scalar character variable + + Standard: + Technical Specification (TS) 18508 or later + + Class: + Collective subroutine + + Syntax: + .. code-block:: fortran + + CALL CO_SUM(A [, RESULT_IMAGE, STAT, ERRMSG]) + + Example: + .. code-block:: fortran + + program test + integer :: val + val = this_image () + call co_sum (val, result_image=1) + if (this_image() == 1) then + write(*,*) "The sum is ", val ! prints (n**2 + n)/2, + ! with n = num_images() + end if + end program test + + See also: + :ref:`CO_MAX`, + :ref:`CO_MIN`, + :ref:`CO_REDUCE`, + :ref:`CO_BROADCAST` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cotan.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cotan.rst new file mode 100644 index 00000000000..82abca8c855 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cotan.rst @@ -0,0 +1,71 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _cotan: + +.. index:: COTAN + +.. index:: DCOTAN + +.. index:: trigonometric function, cotangent + +.. index:: cotangent + +COTAN --- Cotangent function +**************************** + +.. function:: COTAN(X) + + ``COTAN(X)`` computes the cotangent of :samp:`{X}`. Equivalent to ``COS(x)`` + divided by ``SIN(x)``, or ``1 / TAN(x)``. + + :param X: + The type shall be ``REAL`` or ``COMPLEX``. + + :return: + The return value has same type and kind as :samp:`{X}`, and its value is in radians. + + Standard: + GNU extension, enabled with :option:`-fdec-math`. + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = COTAN(X) + + Example: + .. code-block:: fortran + + program test_cotan + real(8) :: x = 0.165_8 + x = cotan(x) + end program test_cotan + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``COTAN(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - GNU extension + * - ``DCOTAN(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension + + See also: + Converse function: + :ref:`TAN` + Degrees function: + :ref:`COTAND` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cotand.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cotand.rst new file mode 100644 index 00000000000..e101c52eb6d --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cotand.rst @@ -0,0 +1,74 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _cotand: + +.. index:: COTAND + +.. index:: DCOTAND + +.. index:: trigonometric function, cotangent, degrees + +.. index:: cotangent, degrees + +COTAND --- Cotangent function, degrees +************************************** + +.. function:: COTAND(X) + + ``COTAND(X)`` computes the cotangent of :samp:`{X}` in degrees. Equivalent to + ``COSD(x)`` divided by ``SIND(x)``, or ``1 / TAND(x)``. + + :param X: + The type shall be ``REAL`` or ``COMPLEX``. + + :return: + The return value has same type and kind as :samp:`{X}`, and its value is in degrees. + + Standard: + GNU extension, enabled with :option:`-fdec-math`. + + This function is for compatibility only and should be avoided in favor of + standard constructs wherever possible. + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = COTAND(X) + + Example: + .. code-block:: fortran + + program test_cotand + real(8) :: x = 0.165_8 + x = cotand(x) + end program test_cotand + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``COTAND(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - GNU extension + * - ``DCOTAND(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension + + See also: + Converse function: + :ref:`TAND` + Radians function: + :ref:`COTAN` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/count.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/count.rst new file mode 100644 index 00000000000..e0988f71c1f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/count.rst @@ -0,0 +1,72 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: COUNT, array, conditionally count elements, array, element counting, array, number of elements + +.. _count: + +COUNT --- Count function +************************ + +.. function:: COUNT(MASK , DIM, KIND) + + Counts the number of ``.TRUE.`` elements in a logical :samp:`{MASK}`, + or, if the :samp:`{DIM}` argument is supplied, counts the number of + elements along each row of the array in the :samp:`{DIM}` direction. + If the array has zero size, or all of the elements of :samp:`{MASK}` are + ``.FALSE.``, then the result is ``0``. + + :param MASK: + The type shall be ``LOGICAL``. + + :param DIM: + (Optional) The type shall be ``INTEGER``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + If :samp:`{DIM}` is present, the result is an array with a rank one less + than the rank of :samp:`{ARRAY}`, and a size corresponding to the shape + of :samp:`{ARRAY}` with the :samp:`{DIM}` dimension removed. + + Standard: + Fortran 90 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = COUNT(MASK [, DIM, KIND]) + + Example: + .. code-block:: fortran + + program test_count + integer, dimension(2,3) :: a, b + logical, dimension(2,3) :: mask + a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /)) + b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /)) + print '(3i3)', a(1,:) + print '(3i3)', a(2,:) + print * + print '(3i3)', b(1,:) + print '(3i3)', b(2,:) + print * + mask = a.ne.b + print '(3l3)', mask(1,:) + print '(3l3)', mask(2,:) + print * + print '(3i3)', count(mask) + print * + print '(3i3)', count(mask, 1) + print * + print '(3i3)', count(mask, 2) + end program test_count \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cputime.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cputime.rst new file mode 100644 index 00000000000..c10df47e4fa --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cputime.rst @@ -0,0 +1,49 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: CPU_TIME, time, elapsed + +.. _cpu_time: + +CPU_TIME --- CPU elapsed time in seconds +**************************************** + +.. function:: CPU_TIME(TIME) + + Returns a ``REAL`` value representing the elapsed CPU time in + seconds. This is useful for testing segments of code to determine + execution time. + + :param TIME: + The type shall be ``REAL`` with ``INTENT(OUT)``. + + :return: + None + + Standard: + Fortran 95 and later + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL CPU_TIME(TIME) + + Example: + .. code-block:: fortran + + program test_cpu_time + real :: start, finish + call cpu_time(start) + ! put code to test here + call cpu_time(finish) + print '("Time = ",f6.3," seconds.")',finish-start + end program test_cpu_time + + See also: + :ref:`SYSTEM_CLOCK`, + :ref:`DATE_AND_TIME` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/cshift.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/cshift.rst new file mode 100644 index 00000000000..bc222790a3c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/cshift.rst @@ -0,0 +1,61 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _cshift: + +CSHIFT --- Circular shift elements of an array +********************************************** + +.. index:: CSHIFT, array, shift circularly, array, permutation, array, rotate + +.. function:: CSHIFT(ARRAY, SHIFT, DIM) + + ``CSHIFT(ARRAY, SHIFT [, DIM])`` performs a circular shift on elements of + :samp:`{ARRAY}` along the dimension of :samp:`{DIM}`. If :samp:`{DIM}` is omitted it is + taken to be ``1``. :samp:`{DIM}` is a scalar of type ``INTEGER`` in the + range of 1 \leq DIM \leq n) where n is the rank of :samp:`{ARRAY}`. + If the rank of :samp:`{ARRAY}` is one, then all elements of :samp:`{ARRAY}` are shifted + by :samp:`{SHIFT}` places. If rank is greater than one, then all complete rank one + sections of :samp:`{ARRAY}` along the given dimension are shifted. Elements + shifted out one end of each rank one section are shifted back in the other end. + + :param ARRAY: + Shall be an array of any type. + + :param SHIFT: + The type shall be ``INTEGER``. + + :param DIM: + The type shall be ``INTEGER``. + + :return: + Returns an array of same type and rank as the :samp:`{ARRAY}` argument. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = CSHIFT(ARRAY, SHIFT [, DIM]) + + Example: + .. code-block:: fortran + + program test_cshift + integer, dimension(3,3) :: a + a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /)) + print '(3i3)', a(1,:) + print '(3i3)', a(2,:) + print '(3i3)', a(3,:) + a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2) + print * + print '(3i3)', a(1,:) + print '(3i3)', a(2,:) + print '(3i3)', a(3,:) + end program test_cshift \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/csizeof.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/csizeof.rst new file mode 100644 index 00000000000..2cae1e800c0 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/csizeof.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: C_SIZEOF, expression size, size of an expression + +.. _c_sizeof: + +C_SIZEOF --- Size in bytes of an expression +******************************************* + +.. function:: C_SIZEOF(X) + + ``C_SIZEOF(X)`` calculates the number of bytes of storage the + expression ``X`` occupies. + + :param X: + The argument shall be an interoperable data entity. + + :return: + The return value is of type integer and of the system-dependent kind + ``C_SIZE_T`` (from the ``ISO_C_BINDING`` module). Its value is the + number of bytes occupied by the argument. If the argument has the + ``POINTER`` attribute, the number of bytes of the storage area pointed + to is returned. If the argument is of a derived type with ``POINTER`` + or ``ALLOCATABLE`` components, the return value does not account for + the sizes of the data pointed to by these components. + + Standard: + Fortran 2008 + + Class: + Inquiry function of the module ``ISO_C_BINDING`` + + Syntax: + .. code-block:: fortran + + N = C_SIZEOF(X) + + Example: + .. code-block:: fortran + + use iso_c_binding + integer(c_int) :: i + real(c_float) :: r, s(5) + print *, (c_sizeof(s)/c_sizeof(r) == 5) + end + + The example will print ``T`` unless you are using a platform + where default ``REAL`` variables are unusually padded. + + See also: + :ref:`SIZEOF`, + :ref:`STORAGE_SIZE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ctime.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ctime.rst new file mode 100644 index 00000000000..1cfc97ac768 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ctime.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ctime: + +CTIME --- Convert a time into a string +************************************** + +.. index:: CTIME, time, conversion to string, conversion, to string + +.. function:: CTIME(TIME, RESULT) + + ``CTIME`` converts a system time value, such as returned by + :ref:`TIME8`, to a string. The output will be of the form :samp:`Sat + Aug 19 18:13:14 1995`. + + :param TIME: + The type shall be of type ``INTEGER``. + + :param RESULT: + The type shall be of type ``CHARACTER`` and + of default kind. It is an ``INTENT(OUT)`` argument. If the length + of this variable is too short for the time and date string to fit + completely, it will be blank on procedure return. + + :return: + The converted date and time as a string. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL CTIME(TIME, RESULT). + RESULT = CTIME(TIME). + + Example: + .. code-block:: fortran + + program test_ctime + integer(8) :: i + character(len=30) :: date + i = time8() + + ! Do something, main part of the program + + call ctime(i,date) + print *, 'Program was started on ', date + end program test_ctime + + See Also: + :ref:`DATE_AND_TIME`, + :ref:`GMTIME`, + :ref:`LTIME`, + :ref:`TIME`, + :ref:`TIME8` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/dateandtime.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/dateandtime.rst new file mode 100644 index 00000000000..42268b8d062 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/dateandtime.rst @@ -0,0 +1,70 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: DATE_AND_TIME, date, current, current date, time, current, current time + +.. _date_and_time: + +DATE_AND_TIME --- Date and time subroutine +****************************************** + +.. function:: DATE_AND_TIME(DATE, TIME, ZONE, VALUES) + + ``DATE_AND_TIME(DATE, TIME, ZONE, VALUES)`` gets the corresponding date and + time information from the real-time system clock. :samp:`{DATE}` is + ``INTENT(OUT)`` and has form ccyymmdd. :samp:`{TIME}` is ``INTENT(OUT)`` and + has form hhmmss.sss. :samp:`{ZONE}` is ``INTENT(OUT)`` and has form (+-)hhmm, + representing the difference with respect to Coordinated Universal Time (UTC). + Unavailable time and date parameters return blanks. + + :param DATE: + (Optional) The type shall be ``CHARACTER(LEN=8)`` + or larger, and of default kind. + + :param TIME: + (Optional) The type shall be ``CHARACTER(LEN=10)`` + or larger, and of default kind. + + :param ZONE: + (Optional) The type shall be ``CHARACTER(LEN=5)`` + or larger, and of default kind. + + :param VALUES: + (Optional) The type shall be ``INTEGER(8)``. + + :return: + None + + Standard: + Fortran 90 and later + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES]) + + Example: + .. code-block:: fortran + + program test_time_and_date + character(8) :: date + character(10) :: time + character(5) :: zone + integer,dimension(8) :: values + ! using keyword arguments + call date_and_time(date,time,zone,values) + call date_and_time(DATE=date,ZONE=zone) + call date_and_time(TIME=time) + call date_and_time(VALUES=values) + print '(a,2x,a,2x,a)', date, time, zone + print '(8i5)', values + end program test_time_and_date + + See also: + :ref:`CPU_TIME`, + :ref:`SYSTEM_CLOCK` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/dble.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/dble.rst new file mode 100644 index 00000000000..60108a92fe1 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/dble.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: DBLE, conversion, to real + +.. _dble: + +DBLE --- Double conversion function +*********************************** + +.. function:: DBLE(A) + + ``DBLE(A)`` Converts :samp:`{A}` to double precision real type. + + :param A: + The type shall be ``INTEGER``, ``REAL``, + or ``COMPLEX``. + + :return: + The return value is of type double precision real. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = DBLE(A) + + Example: + .. code-block:: fortran + + program test_dble + real :: x = 2.18 + integer :: i = 5 + complex :: z = (2.3,1.14) + print *, dble(x), dble(i), dble(z) + end program test_dble + + See also: + :ref:`REAL` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/dcmplx.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/dcmplx.rst new file mode 100644 index 00000000000..358e9376ce4 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/dcmplx.rst @@ -0,0 +1,54 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _dcmplx: + +DCMPLX --- Double complex conversion function +********************************************* + +.. index:: DCMPLX, complex numbers, conversion to, conversion, to complex + +.. function:: DCMPLX(X, Y) + + ``DCMPLX(X [,Y])`` returns a double complex number where :samp:`{X}` is + converted to the real component. If :samp:`{Y}` is present it is converted to the + imaginary component. If :samp:`{Y}` is not present then the imaginary component is + set to 0.0. If :samp:`{X}` is complex then :samp:`{Y}` must not be present. + + :param X: + The type may be ``INTEGER``, ``REAL``, + or ``COMPLEX``. + + :param Y: + (Optional if :samp:`{X}` is not ``COMPLEX``.) May be + ``INTEGER`` or ``REAL``. + + :return: + The return value is of type ``COMPLEX(8)`` + + Standard: + GNU extension + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = DCMPLX(X [, Y]) + + Example: + .. code-block:: fortran + + program test_dcmplx + integer :: i = 42 + real :: x = 3.14 + complex :: z + z = cmplx(i, x) + print *, dcmplx(i) + print *, dcmplx(x) + print *, dcmplx(z) + print *, dcmplx(x,i) + end program test_dcmplx \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/digits.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/digits.rst new file mode 100644 index 00000000000..895a32c9e55 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/digits.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: DIGITS, model representation, significant digits + +.. _digits: + +DIGITS --- Significant binary digits function +********************************************* + +.. function:: DIGITS(X) + + ``DIGITS(X)`` returns the number of significant binary digits of the internal + model representation of :samp:`{X}`. For example, on a system using a 32-bit + floating point representation, a default real number would likely return 24. + + :param X: + The type may be ``INTEGER`` or ``REAL``. + + :return: + The return value is of type ``INTEGER``. + + Standard: + Fortran 90 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = DIGITS(X) + + Example: + .. code-block:: fortran + + program test_digits + integer :: i = 12345 + real :: x = 3.143 + real(8) :: y = 2.33 + print *, digits(i) + print *, digits(x) + print *, digits(y) + end program test_digits \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/dim.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/dim.rst new file mode 100644 index 00000000000..7a5f2e4ae19 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/dim.rst @@ -0,0 +1,78 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _dim: + +.. index:: DIM + +.. index:: IDIM + +.. index:: DDIM + +.. index:: positive difference + +DIM --- Positive difference +*************************** + +.. function:: DIM(X,Y) + + ``DIM(X,Y)`` returns the difference ``X-Y`` if the result is positive; + otherwise returns zero. + + :param X: + The type shall be ``INTEGER`` or ``REAL`` + + :param Y: + The type shall be the same type and kind as :samp:`{X}`. (As + a GNU extension, arguments of different kinds are permitted.) + + :return: + The return value is of type ``INTEGER`` or ``REAL``. (As a GNU + extension, kind is the largest kind of the actual arguments.) + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = DIM(X, Y) + + Example: + .. code-block:: fortran + + program test_dim + integer :: i + real(8) :: x + i = dim(4, 15) + x = dim(4.345_8, 2.111_8) + print *, i + print *, x + end program test_dim + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DIM(X,Y)`` + - ``REAL(4) X, Y`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``IDIM(X,Y)`` + - ``INTEGER(4) X, Y`` + - ``INTEGER(4)`` + - Fortran 77 and later + * - ``DDIM(X,Y)`` + - ``REAL(8) X, Y`` + - ``REAL(8)`` + - Fortran 77 and later \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/dotproduct.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/dotproduct.rst new file mode 100644 index 00000000000..396e221e4b4 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/dotproduct.rst @@ -0,0 +1,57 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: DOT_PRODUCT, dot product, vector product, product, vector + +.. _dot_product: + +DOT_PRODUCT --- Dot product function +************************************ + +.. function:: DOT_PRODUCT(VECTOR_A, VECTOR_B) + + ``DOT_PRODUCT(VECTOR_A, VECTOR_B)`` computes the dot product multiplication + of two vectors :samp:`{VECTOR_A}` and :samp:`{VECTOR_B}`. The two vectors may be + either numeric or logical and must be arrays of rank one and of equal size. If + the vectors are ``INTEGER`` or ``REAL``, the result is + ``SUM(VECTOR_A*VECTOR_B)``. If the vectors are ``COMPLEX``, the result + is ``SUM(CONJG(VECTOR_A)*VECTOR_B)``. If the vectors are ``LOGICAL``, + the result is ``ANY(VECTOR_A .AND. VECTOR_B)``. + + :param VECTOR_A: + The type shall be numeric or ``LOGICAL``, rank 1. + + :param VECTOR_B: + The type shall be numeric if :samp:`{VECTOR_A}` is of numeric type or ``LOGICAL`` if :samp:`{VECTOR_A}` is of type ``LOGICAL``. :samp:`{VECTOR_B}` shall be a rank-one array. + + :return: + If the arguments are numeric, the return value is a scalar of numeric type, + ``INTEGER``, ``REAL``, or ``COMPLEX``. If the arguments are + ``LOGICAL``, the return value is ``.TRUE.`` or ``.FALSE.``. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B) + + Example: + .. code-block:: fortran + + program test_dot_prod + integer, dimension(3) :: a, b + a = (/ 1, 2, 3 /) + b = (/ 4, 5, 6 /) + print '(3i3)', a + print * + print '(3i3)', b + print * + print *, dot_product(a,b) + end program test_dot_prod \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/dprod.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/dprod.rst new file mode 100644 index 00000000000..63dca09037a --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/dprod.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _dprod: + +.. index:: DPROD + +.. index:: product, double-precision + +DPROD --- Double product function +********************************* + +.. function:: DPROD(X,Y) + + ``DPROD(X,Y)`` returns the product ``X*Y``. + + :param X: + The type shall be ``REAL``. + + :param Y: + The type shall be ``REAL``. + + :return: + The return value is of type ``REAL(8)``. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = DPROD(X, Y) + + Example: + .. code-block:: fortran + + program test_dprod + real :: x = 5.2 + real :: y = 2.3 + real(8) :: d + d = dprod(x,y) + print *, d + end program test_dprod + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DPROD(X,Y)`` + - ``REAL(4) X, Y`` + - ``REAL(8)`` + - Fortran 77 and later \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/dreal.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/dreal.rst new file mode 100644 index 00000000000..f84da91eff1 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/dreal.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: DREAL, complex numbers, real part + +.. _dreal: + +DREAL --- Double real part function +*********************************** + +.. function:: DREAL(Z) + + ``DREAL(Z)`` returns the real part of complex variable :samp:`{Z}`. + + :param A: + The type shall be ``COMPLEX(8)``. + + :return: + The return value is of type ``REAL(8)``. + + Standard: + GNU extension + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = DREAL(A) + + Example: + .. code-block:: fortran + + program test_dreal + complex(8) :: z = (1.3_8,7.2_8) + print *, dreal(z) + end program test_dreal + + See also: + :ref:`AIMAG` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/dshiftl.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/dshiftl.rst new file mode 100644 index 00000000000..24ab08e231d --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/dshiftl.rst @@ -0,0 +1,52 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: DSHIFTL, left shift, combined, shift, left + +.. _dshiftl: + +DSHIFTL --- Combined left shift +******************************* + +.. function:: DSHIFTL(I, J, SHIFT) + + ``DSHIFTL(I, J, SHIFT)`` combines bits of :samp:`{I}` and :samp:`{J}`. The + rightmost :samp:`{SHIFT}` bits of the result are the leftmost :samp:`{SHIFT}` + bits of :samp:`{J}`, and the remaining bits are the rightmost bits of + :samp:`{I}`. + + :param I: + Shall be of type ``INTEGER`` or a BOZ constant. + + :param J: + Shall be of type ``INTEGER`` or a BOZ constant. + If both :samp:`{I}` and :samp:`{J}` have integer type, then they shall have + the same kind type parameter. :samp:`{I}` and :samp:`{J}` shall not both be + BOZ constants. + + :param SHIFT: + Shall be of type ``INTEGER``. It shall + be nonnegative. If :samp:`{I}` is not a BOZ constant, then :samp:`{SHIFT}` + shall be less than or equal to ``BIT_SIZE(I)`` ; otherwise, + :samp:`{SHIFT}` shall be less than or equal to ``BIT_SIZE(J)``. + + :return: + If either :samp:`{I}` or :samp:`{J}` is a BOZ constant, it is first converted + as if by the intrinsic function ``INT`` to an integer type with the + kind type parameter of the other. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = DSHIFTL(I, J, SHIFT) + + See also: + :ref:`DSHIFTR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/dshiftr.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/dshiftr.rst new file mode 100644 index 00000000000..a4d4ec4475d --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/dshiftr.rst @@ -0,0 +1,52 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: DSHIFTR, right shift, combined, shift, right + +.. _dshiftr: + +DSHIFTR --- Combined right shift +******************************** + +.. function:: DSHIFTR(I, J, SHIFT) + + ``DSHIFTR(I, J, SHIFT)`` combines bits of :samp:`{I}` and :samp:`{J}`. The + leftmost :samp:`{SHIFT}` bits of the result are the rightmost :samp:`{SHIFT}` + bits of :samp:`{I}`, and the remaining bits are the leftmost bits of + :samp:`{J}`. + + :param I: + Shall be of type ``INTEGER`` or a BOZ constant. + + :param J: + Shall be of type ``INTEGER`` or a BOZ constant. + If both :samp:`{I}` and :samp:`{J}` have integer type, then they shall have + the same kind type parameter. :samp:`{I}` and :samp:`{J}` shall not both be + BOZ constants. + + :param SHIFT: + Shall be of type ``INTEGER``. It shall + be nonnegative. If :samp:`{I}` is not a BOZ constant, then :samp:`{SHIFT}` + shall be less than or equal to ``BIT_SIZE(I)`` ; otherwise, + :samp:`{SHIFT}` shall be less than or equal to ``BIT_SIZE(J)``. + + :return: + If either :samp:`{I}` or :samp:`{J}` is a BOZ constant, it is first converted + as if by the intrinsic function ``INT`` to an integer type with the + kind type parameter of the other. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = DSHIFTR(I, J, SHIFT) + + See also: + :ref:`DSHIFTL` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/dtime.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/dtime.rst new file mode 100644 index 00000000000..4f63d97cf25 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/dtime.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: DTIME, time, elapsed, elapsed time + +.. _dtime: + +DTIME --- Execution time subroutine (or function) +************************************************* + +.. function:: DTIME(VALUES, TIME) + + ``DTIME(VALUES, TIME)`` initially returns the number of seconds of runtime + since the start of the process's execution in :samp:`{TIME}`. :samp:`{VALUES}` + returns the user and system components of this time in ``VALUES(1)`` and + ``VALUES(2)`` respectively. :samp:`{TIME}` is equal to ``VALUES(1) + + VALUES(2)``. + + :param VALUES: + The type shall be ``REAL(4), DIMENSION(2)``. + + :param TIME: + The type shall be ``REAL(4)``. + + :return: + Elapsed time in seconds since the last invocation or since the start of program + execution if not called before. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL DTIME(VALUES, TIME). + TIME = DTIME(VALUES), (not recommended). + + Example: + .. code-block:: fortran + + program test_dtime + integer(8) :: i, j + real, dimension(2) :: tarray + real :: result + call dtime(tarray, result) + print *, result + print *, tarray(1) + print *, tarray(2) + do i=1,100000000 ! Just a delay + j = i * i - i + end do + call dtime(tarray, result) + print *, result + print *, tarray(1) + print *, tarray(2) + end program test_dtime + + See also: + :ref:`CPU_TIME` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/eoshift.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/eoshift.rst new file mode 100644 index 00000000000..93f1e5af355 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/eoshift.rst @@ -0,0 +1,67 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _eoshift: + +EOSHIFT --- End-off shift elements of an array +********************************************** + +.. index:: EOSHIFT, array, shift + +.. function:: EOSHIFT(ARRAY, SHIFT, BOUNDARY, DIM) + + ``EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])`` performs an end-off shift on + elements of :samp:`{ARRAY}` along the dimension of :samp:`{DIM}`. If :samp:`{DIM}` is + omitted it is taken to be ``1``. :samp:`{DIM}` is a scalar of type + ``INTEGER`` in the range of 1 \leq DIM \leq n) where n is the + rank of :samp:`{ARRAY}`. If the rank of :samp:`{ARRAY}` is one, then all elements of + :samp:`{ARRAY}` are shifted by :samp:`{SHIFT}` places. If rank is greater than one, + then all complete rank one sections of :samp:`{ARRAY}` along the given dimension are + shifted. Elements shifted out one end of each rank one section are dropped. If + :samp:`{BOUNDARY}` is present then the corresponding value of from :samp:`{BOUNDARY}` + is copied back in the other end. If :samp:`{BOUNDARY}` is not present then the + following are copied in depending on the type of :samp:`{ARRAY}`. + + :param ARRAY: + May be any type, not scalar. + + :param SHIFT: + The type shall be ``INTEGER``. + + :param BOUNDARY: + Same type as :samp:`{ARRAY}`. + + :param DIM: + The type shall be ``INTEGER``. + + :return: + Returns an array of same type and rank as the :samp:`{ARRAY}` argument. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM]) + + Example: + .. code-block:: fortran + + program test_eoshift + integer, dimension(3,3) :: a + a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /)) + print '(3i3)', a(1,:) + print '(3i3)', a(2,:) + print '(3i3)', a(3,:) + a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2) + print * + print '(3i3)', a(1,:) + print '(3i3)', a(2,:) + print '(3i3)', a(3,:) + end program test_eoshift \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/epsilon.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/epsilon.rst new file mode 100644 index 00000000000..6ff2f2e8ab6 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/epsilon.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: EPSILON, model representation, epsilon + +.. _epsilon: + +EPSILON --- Epsilon function +**************************** + +.. function:: EPSILON(X) + + ``EPSILON(X)`` returns the smallest number :samp:`{E}` of the same kind + as :samp:`{X}` such that 1 + E > 1. + + :param X: + The type shall be ``REAL``. + + :return: + The return value is of same type as the argument. + + Standard: + Fortran 90 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = EPSILON(X) + + Example: + .. code-block:: fortran + + program test_epsilon + real :: x = 3.143 + real(8) :: y = 2.33 + print *, EPSILON(x) + print *, EPSILON(y) + end program test_epsilon \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/erf.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/erf.rst new file mode 100644 index 00000000000..9a1c6de6e2e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/erf.rst @@ -0,0 +1,57 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _erf: + +.. index:: ERF + +.. index:: error function + +ERF --- Error function +*********************** + +.. function:: ERF(X) + + ``ERF(X)`` computes the error function of :samp:`{X}`. + + :param X: + The type shall be ``REAL``. + + :return: + The return value is of type ``REAL``, of the same kind as + :samp:`{X}` and lies in the range -1 \leq erf (x) \leq 1 . + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ERF(X) + + Example: + .. code-block:: fortran + + program test_erf + real(8) :: x = 0.17_8 + x = erf(x) + end program test_erf + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DERF(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/erfc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/erfc.rst new file mode 100644 index 00000000000..d6ee377a172 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/erfc.rst @@ -0,0 +1,57 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _erfc: + +.. index:: ERFC + +.. index:: error function, complementary + +ERFC --- Error function +************************ + +.. function:: ERFC(X) + + ``ERFC(X)`` computes the complementary error function of :samp:`{X}`. + + :param X: + The type shall be ``REAL``. + + :return: + The return value is of type ``REAL`` and of the same kind as :samp:`{X}`. + It lies in the range 0 \leq erfc (x) \leq 2 . + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ERFC(X) + + Example: + .. code-block:: fortran + + program test_erfc + real(8) :: x = 0.17_8 + x = erfc(x) + end program test_erfc + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DERFC(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/erfcscaled.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/erfcscaled.rst new file mode 100644 index 00000000000..7842cb54757 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/erfcscaled.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ERFC_SCALED, error function, complementary, exponentially-scaled + +.. _erfc_scaled: + +ERFC_SCALED --- Error function +******************************* + +.. function:: ERFC_SCALED(X) + + ``ERFC_SCALED(X)`` computes the exponentially-scaled complementary + error function of :samp:`{X}`. + + :param X: + The type shall be ``REAL``. + + :return: + The return value is of type ``REAL`` and of the same kind as :samp:`{X}`. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ERFC_SCALED(X) + + Example: + .. code-block:: fortran + + program test_erfc_scaled + real(8) :: x = 0.17_8 + x = erfc_scaled(x) + end program test_erfc_scaled \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/etime.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/etime.rst new file mode 100644 index 00000000000..63d7431c50e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/etime.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ETIME, time, elapsed + +.. _etime: + +ETIME --- Execution time subroutine (or function) +************************************************* + +.. function:: ETIME(VALUES, TIME) + + ``ETIME(VALUES, TIME)`` returns the number of seconds of runtime + since the start of the process's execution in :samp:`{TIME}`. :samp:`{VALUES}` + returns the user and system components of this time in ``VALUES(1)`` and + ``VALUES(2)`` respectively. :samp:`{TIME}` is equal to ``VALUES(1) + VALUES(2)``. + + :param VALUES: + The type shall be ``REAL(4), DIMENSION(2)``. + + :param TIME: + The type shall be ``REAL(4)``. + + :return: + Elapsed time in seconds since the start of program execution. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL ETIME(VALUES, TIME). + TIME = ETIME(VALUES), (not recommended). + + Example: + .. code-block:: fortran + + program test_etime + integer(8) :: i, j + real, dimension(2) :: tarray + real :: result + call ETIME(tarray, result) + print *, result + print *, tarray(1) + print *, tarray(2) + do i=1,100000000 ! Just a delay + j = i * i - i + end do + call ETIME(tarray, result) + print *, result + print *, tarray(1) + print *, tarray(2) + end program test_etime + + See also: + :ref:`CPU_TIME` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/eventquery.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/eventquery.rst new file mode 100644 index 00000000000..f676ec09e02 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/eventquery.rst @@ -0,0 +1,57 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _event_query: + +EVENT_QUERY --- Query whether a coarray event has occurred +********************************************************** + +.. index:: EVENT_QUERY, Events, EVENT_QUERY + +.. function:: EVENT_QUERY(EVENT, COUNT, STAT) + + ``EVENT_QUERY`` assignes the number of events to :samp:`{COUNT}` which have been + posted to the :samp:`{EVENT}` variable and not yet been removed by calling + ``EVENT WAIT``. When :samp:`{STAT}` is present and the invocation was successful, + it is assigned the value 0. If it is present and the invocation has failed, + it is assigned a positive value and :samp:`{COUNT}` is assigned the value -1. + + :param EVENT: + (intent(IN)) Scalar of type ``EVENT_TYPE``, + defined in ``ISO_FORTRAN_ENV`` ; shall not be coindexed. + + :param COUNT: + (intent(out))Scalar integer with at least the + precision of default integer. + + :param STAT: + (optional) Scalar default-kind integer variable. + + Standard: + TS 18508 or later + + Class: + subroutine + + Syntax: + .. code-block:: fortran + + CALL EVENT_QUERY (EVENT, COUNT [, STAT]) + + Example: + .. code-block:: fortran + + program atomic + use iso_fortran_env + implicit none + type(event_type) :: event_value_has_been_set[*] + integer :: cnt + if (this_image() == 1) then + call event_query (event_value_has_been_set, cnt) + if (cnt > 0) write(*,*) "Value has been set" + elseif (this_image() == 2) then + event post (event_value_has_been_set[1]) + end if + end program atomic \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/executecommandline.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/executecommandline.rst new file mode 100644 index 00000000000..cfb3dffd5ac --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/executecommandline.rst @@ -0,0 +1,70 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _execute_command_line: + +EXECUTE_COMMAND_LINE --- Execute a shell command +************************************************ + +.. index:: EXECUTE_COMMAND_LINE, system, system call, command line + +.. function:: EXECUTE_COMMAND_LINE(COMMAND, WAIT, EXITSTAT, CMDSTAT, CMDMSG) + + ``EXECUTE_COMMAND_LINE`` runs a shell command, synchronously or + asynchronously. + + :param COMMAND: + Shall be a default ``CHARACTER`` scalar. + + :param WAIT: + (Optional) Shall be a default ``LOGICAL`` scalar. + + :param EXITSTAT: + (Optional) Shall be an ``INTEGER`` of the + default kind. + + :param CMDSTAT: + (Optional) Shall be an ``INTEGER`` of the + default kind. + + :param CMDMSG: + (Optional) Shall be an ``CHARACTER`` scalar of the + default kind. + + Standard: + Fortran 2008 and later + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ]) + + Example: + .. code-block:: fortran + + program test_exec + integer :: i + + call execute_command_line ("external_prog.exe", exitstat=i) + print *, "Exit status of external_prog.exe was ", i + + call execute_command_line ("reindex_files.exe", wait=.false.) + print *, "Now reindexing files in the background" + + end program test_exec + + Note: + Because this intrinsic is implemented in terms of the ``system`` + function call, its behavior with respect to signaling is processor + dependent. In particular, on POSIX-compliant systems, the SIGINT and + SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As + such, if the parent process is terminated, the child process might not be + terminated alongside. + + See also: + :ref:`SYSTEM` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/exit.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/exit.rst new file mode 100644 index 00000000000..40ac4bd8d48 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/exit.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _exit: + +EXIT --- Exit the program with status. +*************************************** + +.. index:: EXIT, program termination, terminate program + +.. function:: EXIT(STATUS) + + ``EXIT`` causes immediate termination of the program with status. If status + is omitted it returns the canonical *success* for the system. All Fortran + I/O units are closed. + + :param STATUS: + Shall be an ``INTEGER`` of the default kind. + + :return: + ``STATUS`` is passed to the parent process on exit. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL EXIT([STATUS]) + + Example: + .. code-block:: fortran + + program test_exit + integer :: STATUS = 0 + print *, 'This program is going to exit.' + call EXIT(STATUS) + end program test_exit + + See also: + :ref:`ABORT`, + :ref:`KILL` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/exp.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/exp.rst new file mode 100644 index 00000000000..205ad2753e7 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/exp.rst @@ -0,0 +1,83 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _exp: + +.. index:: EXP + +.. index:: DEXP + +.. index:: CEXP + +.. index:: ZEXP + +.. index:: CDEXP + +.. index:: exponential function + +.. index:: logarithm function, inverse + +EXP --- Exponential function +***************************** + +.. function:: EXP(X) + + ``EXP(X)`` computes the base e exponential of :samp:`{X}`. + + :param X: + The type shall be ``REAL`` or + ``COMPLEX``. + + :return: + The return value has same type and kind as :samp:`{X}`. + + Standard: + Fortran 77 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = EXP(X) + + Example: + .. code-block:: fortran + + program test_exp + real :: x = 1.0 + x = exp(x) + end program test_exp + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``EXP(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DEXP(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 77 and later + * - ``CEXP(X)`` + - ``COMPLEX(4) X`` + - ``COMPLEX(4)`` + - Fortran 77 and later + * - ``ZEXP(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension + * - ``CDEXP(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/exponent.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/exponent.rst new file mode 100644 index 00000000000..83c7aa0866c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/exponent.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: EXPONENT, real number, exponent, floating point, exponent + +.. _exponent: + +EXPONENT --- Exponent function +******************************* + +.. function:: EXPONENT(X) + + ``EXPONENT(X)`` returns the value of the exponent part of :samp:`{X}`. If :samp:`{X}` + is zero the value returned is zero. + + :param X: + The type shall be ``REAL``. + + :return: + The return value is of type default ``INTEGER``. + + Standard: + Fortran 90 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = EXPONENT(X) + + Example: + .. code-block:: fortran + + program test_exponent + real :: x = 1.0 + integer :: i + i = exponent(x) + print *, i + print *, exponent(0.0) + end program test_exponent \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/extendstypeof.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/extendstypeof.rst new file mode 100644 index 00000000000..1df242ebce8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/extendstypeof.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: EXTENDS_TYPE_OF + +.. _extends_type_of: + +EXTENDS_TYPE_OF --- Query dynamic type for extension +***************************************************** + +.. function:: EXTENDS_TYPE_OF(A, MOLD) + + Query dynamic type for extension. + + :param A: + Shall be an object of extensible declared type or + unlimited polymorphic. + + :param MOLD: + Shall be an object of extensible declared type or + unlimited polymorphic. + + :return: + The return value is a scalar of type default logical. It is true if and only if + the dynamic type of A is an extension type of the dynamic type of MOLD. + + Standard: + Fortran 2003 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = EXTENDS_TYPE_OF(A, MOLD) + + See also: + :ref:`SAME_TYPE_AS` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/fdate.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/fdate.rst new file mode 100644 index 00000000000..1b780a5f9b6 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/fdate.rst @@ -0,0 +1,57 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: FDATE, time, current, current time, date, current, current date + +.. _fdate: + +FDATE --- Get the current time as a string +****************************************** + +.. function:: FDATE(DATE) + + ``FDATE(DATE)`` returns the current date (using the same format as + :ref:`CTIME`) in :samp:`{DATE}`. It is equivalent to ``CALL CTIME(DATE, + TIME())``. + + :param DATE: + The type shall be of type ``CHARACTER`` of the + default kind. It is an ``INTENT(OUT)`` argument. If the length of + this variable is too short for the date and time string to fit + completely, it will be blank on procedure return. + + :return: + The current date and time as a string. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL FDATE(DATE). + DATE = FDATE(). + + Example: + .. code-block:: fortran + + program test_fdate + integer(8) :: i, j + character(len=30) :: date + call fdate(date) + print *, 'Program started on ', date + do i = 1, 100000000 ! Just a delay + j = i * i - i + end do + call fdate(date) + print *, 'Program ended on ', date + end program test_fdate + + See also: + :ref:`DATE_AND_TIME`, + :ref:`CTIME` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/fget.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/fget.rst new file mode 100644 index 00000000000..e9ac9eba380 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/fget.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: FGET, read character, stream mode, stream mode, read character, file operation, read character + +.. _fget: + +FGET --- Read a single character in stream mode from stdin +*********************************************************** + +.. function:: FGET(C) + + Read a single character in stream mode from stdin by bypassing normal + formatted output. Stream I/O should not be mixed with normal record-oriented + (formatted or unformatted) I/O on the same unit; the results are unpredictable. + + :param C: + The type shall be ``CHARACTER`` and of default + kind. + + :param STATUS: + (Optional) status flag of type ``INTEGER``. + Returns 0 on success, -1 on end-of-file, and a system specific positive + error code otherwise. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL FGET(C [, STATUS]) + STATUS = FGET(C) + + Example: + .. code-block:: fortran + + PROGRAM test_fget + INTEGER, PARAMETER :: strlen = 100 + INTEGER :: status, i = 1 + CHARACTER(len=strlen) :: str = "" + + WRITE (*,*) 'Enter text:' + DO + CALL fget(str(i:i), status) + if (status /= 0 .OR. i > strlen) exit + i = i + 1 + END DO + WRITE (*,*) TRIM(str) + END PROGRAM + + See also: + :ref:`FGETC`, + :ref:`FPUT`, + :ref:`FPUTC` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/fgetc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/fgetc.rst new file mode 100644 index 00000000000..7677fdcd7ad --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/fgetc.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: FGETC, read character, stream mode, stream mode, read character, file operation, read character + +.. _fgetc: + +FGETC --- Read a single character in stream mode +************************************************ + +.. function:: FGETC(UNIT, C) + + Read a single character in stream mode by bypassing normal formatted output. + Stream I/O should not be mixed with normal record-oriented (formatted or + unformatted) I/O on the same unit; the results are unpredictable. + + :param UNIT: + The type shall be ``INTEGER``. + + :param C: + The type shall be ``CHARACTER`` and of default + kind. + + :param STATUS: + (Optional) status flag of type ``INTEGER``. + Returns 0 on success, -1 on end-of-file and a system specific positive + error code otherwise. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL FGETC(UNIT, C [, STATUS]) + STATUS = FGETC(UNIT, C) + + Example: + .. code-block:: fortran + + PROGRAM test_fgetc + INTEGER :: fd = 42, status + CHARACTER :: c + + OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD") + DO + CALL fgetc(fd, c, status) + IF (status /= 0) EXIT + call fput(c) + END DO + CLOSE(UNIT=fd) + END PROGRAM + + See also: + :ref:`FGET`, + :ref:`FPUT`, + :ref:`FPUTC` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/findloc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/findloc.rst new file mode 100644 index 00000000000..7361872c39d --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/findloc.rst @@ -0,0 +1,78 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _findloc: + +FINDLOC --- Search an array for a value +*************************************** + +.. index:: FINDLOC, findloc + +.. function:: FINDLOC(ARRAY, VALUE, MASK, KIND, BACK) + + Determines the location of the element in the array with the value + given in the :samp:`{VALUE}` argument, or, if the :samp:`{DIM}` argument is + supplied, determines the locations of the elements equal to the + :samp:`{VALUE}` argument element along each + row of the array in the :samp:`{DIM}` direction. If :samp:`{MASK}` is + present, only the elements for which :samp:`{MASK}` is ``.TRUE.`` are + considered. If more than one element in the array has the value + :samp:`{VALUE}`, the location returned is that of the first such element + in array element order if the :samp:`{BACK}` is not present or if it is + ``.FALSE.``. If :samp:`{BACK}` is true, the location returned is that + of the last such element. If the array has zero size, or all of the + elements of :samp:`{MASK}` are ``.FALSE.``, then the result is an array + of zeroes. Similarly, if :samp:`{DIM}` is supplied and all of the + elements of :samp:`{MASK}` along a given row are zero, the result value + for that row is zero. + + :param ARRAY: + Shall be an array of intrinsic type. + + :param VALUE: + A scalar of intrinsic type which is in type + conformance with :samp:`{ARRAY}`. + + :param DIM: + (Optional) Shall be a scalar of type + ``INTEGER``, with a value between one and the rank of :samp:`{ARRAY}`, + inclusive. It may not be an optional dummy argument. + + :param MASK: + (Optional) Shall be of type ``LOGICAL``, + and conformable with :samp:`{ARRAY}`. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :param BACK: + (Optional) A scalar of type ``LOGICAL``. + + :return: + If :samp:`{DIM}` is absent, the result is a rank-one array with a length + equal to the rank of :samp:`{ARRAY}`. If :samp:`{DIM}` is present, the result + is an array with a rank one less than the rank of :samp:`{ARRAY}`, and a + size corresponding to the size of :samp:`{ARRAY}` with the :samp:`{DIM}` + dimension removed. If :samp:`{DIM}` is present and :samp:`{ARRAY}` has a rank + of one, the result is a scalar. If the optional argument :samp:`{KIND}` + is present, the result is an integer of kind :samp:`{KIND}`, otherwise it + is of default kind. + + Standard: + Fortran 2008 and later. + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = FINDLOC(ARRAY, VALUE, DIM [, MASK] [,KIND] [,BACK]) + RESULT = FINDLOC(ARRAY, VALUE, [, MASK] [,KIND] [,BACK]) + + See also: + :ref:`MAXLOC`, + :ref:`MINLOC` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/floor.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/floor.rst new file mode 100644 index 00000000000..7c7eaeedec7 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/floor.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: FLOOR, floor, rounding, floor + +.. _floor: + +FLOOR --- Integer floor function +******************************** + +.. function:: FLOOR(A) + + ``FLOOR(A)`` returns the greatest integer less than or equal to :samp:`{X}`. + + :param A: + The type shall be ``REAL``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER(KIND)`` if :samp:`{KIND}` is present + and of default-kind ``INTEGER`` otherwise. + + Standard: + Fortran 95 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = FLOOR(A [, KIND]) + + Example: + .. code-block:: fortran + + program test_floor + real :: x = 63.29 + real :: y = -63.59 + print *, floor(x) ! returns 63 + print *, floor(y) ! returns -64 + end program test_floor + + See also: + :ref:`CEILING`, + :ref:`NINT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/flush.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/flush.rst new file mode 100644 index 00000000000..c761b35a1ff --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/flush.rst @@ -0,0 +1,72 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: FLUSH, file operation, flush + +.. _flush: + +FLUSH --- Flush I/O unit(s) +*************************** + +.. function:: FLUSH(UNIT) + + Flushes Fortran unit(s) currently open for output. Without the optional + argument, all units are flushed, otherwise just the unit specified. + + :param UNIT: + (Optional) The type shall be ``INTEGER``. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL FLUSH(UNIT) + + Note: + Beginning with the Fortran 2003 standard, there is a ``FLUSH`` + statement that should be preferred over the ``FLUSH`` intrinsic. + + The ``FLUSH`` intrinsic and the Fortran 2003 ``FLUSH`` statement + have identical effect: they flush the runtime library's I/O buffer so + that the data becomes visible to other processes. This does not guarantee + that the data is committed to disk. + + On POSIX systems, you can request that all data is transferred to the + storage device by calling the ``fsync`` function, with the POSIX file + descriptor of the I/O unit as argument (retrieved with GNU intrinsic + ``FNUM``). The following example shows how: + + .. code-block:: fortran + + ! Declare the interface for POSIX fsync function + interface + function fsync (fd) bind(c,name="fsync") + use iso_c_binding, only: c_int + integer(c_int), value :: fd + integer(c_int) :: fsync + end function fsync + end interface + + ! Variable declaration + integer :: ret + + ! Opening unit 10 + open (10,file="foo") + + ! ... + ! Perform I/O on unit 10 + ! ... + + ! Flush and sync + flush(10) + ret = fsync(fnum(10)) + + ! Handle possible error + if (ret /= 0) stop "Error calling FSYNC" \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/fnum.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/fnum.rst new file mode 100644 index 00000000000..b756f0a32d1 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/fnum.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: FNUM, file operation, file number + +.. _fnum: + +FNUM --- File number function +***************************** + +.. function:: FNUM(UNIT) + + ``FNUM(UNIT)`` returns the POSIX file descriptor number corresponding to the + open Fortran I/O unit ``UNIT``. + + :param UNIT: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = FNUM(UNIT) + + Example: + .. code-block:: fortran + + program test_fnum + integer :: i + open (unit=10, status = "scratch") + i = fnum(10) + print *, i + close (10) + end program test_fnum \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/fput.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/fput.rst new file mode 100644 index 00000000000..54d1e6cc293 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/fput.rst @@ -0,0 +1,54 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: FPUT, write character, stream mode, stream mode, write character, file operation, write character + +.. _fput: + +FPUT --- Write a single character in stream mode to stdout +*********************************************************** + +.. function:: FPUT(C) + + Write a single character in stream mode to stdout by bypassing normal + formatted output. Stream I/O should not be mixed with normal record-oriented + (formatted or unformatted) I/O on the same unit; the results are unpredictable. + + :param C: + The type shall be ``CHARACTER`` and of default + kind. + + :param STATUS: + (Optional) status flag of type ``INTEGER``. + Returns 0 on success, -1 on end-of-file and a system specific positive + error code otherwise. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL FPUT(C [, STATUS]) + STATUS = FPUT(C) + + Example: + .. code-block:: fortran + + PROGRAM test_fput + CHARACTER(len=10) :: str = "gfortran" + INTEGER :: i + DO i = 1, len_trim(str) + CALL fput(str(i:i)) + END DO + END PROGRAM + + See also: + :ref:`FPUTC`, + :ref:`FGET`, + :ref:`FGETC` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/fputc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/fputc.rst new file mode 100644 index 00000000000..063c1a8e57f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/fputc.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: FPUTC, write character, stream mode, stream mode, write character, file operation, write character + +.. _fputc: + +FPUTC --- Write a single character in stream mode +************************************************* + +.. function:: FPUTC(UNIT, C) + + Write a single character in stream mode by bypassing normal formatted + output. Stream I/O should not be mixed with normal record-oriented + (formatted or unformatted) I/O on the same unit; the results are unpredictable. + + :param UNIT: + The type shall be ``INTEGER``. + + :param C: + The type shall be ``CHARACTER`` and of default + kind. + + :param STATUS: + (Optional) status flag of type ``INTEGER``. + Returns 0 on success, -1 on end-of-file and a system specific positive + error code otherwise. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL FPUTC(UNIT, C [, STATUS]) + STATUS = FPUTC(UNIT, C) + + Example: + .. code-block:: fortran + + PROGRAM test_fputc + CHARACTER(len=10) :: str = "gfortran" + INTEGER :: fd = 42, i + + OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW") + DO i = 1, len_trim(str) + CALL fputc(fd, str(i:i)) + END DO + CLOSE(fd) + END PROGRAM + + See also: + :ref:`FPUT`, + :ref:`FGET`, + :ref:`FGETC` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/fraction.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/fraction.rst new file mode 100644 index 00000000000..4e2586318ae --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/fraction.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: FRACTION, real number, fraction, floating point, fraction + +.. _fraction: + +FRACTION --- Fractional part of the model representation +******************************************************** + +.. function:: FRACTION(X) + + ``FRACTION(X)`` returns the fractional part of the model + representation of ``X``. + + :param X: + The type of the argument shall be a ``REAL``. + + :return: + The return value is of the same type and kind as the argument. + The fractional part of the model representation of ``X`` is returned; + it is ``X * RADIX(X)**(-EXPONENT(X))``. + + Standard: + Fortran 90 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + Y = FRACTION(X) + + Example: + .. code-block:: fortran + + program test_fraction + real :: x + x = 178.1387e-4 + print *, fraction(x), x * radix(x)**(-exponent(x)) + end program test_fraction \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/free.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/free.rst new file mode 100644 index 00000000000..9bf7f9acf03 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/free.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: FREE, pointer, cray + +.. _free: + +FREE --- Frees memory +********************* + +.. function:: FREE(PTR) + + Frees memory previously allocated by ``MALLOC``. The ``FREE`` + intrinsic is an extension intended to be used with Cray pointers, and is + provided in GNU Fortran to allow user to compile legacy code. For + new code using Fortran 95 pointers, the memory de-allocation intrinsic is + ``DEALLOCATE``. + + :param PTR: + The type shall be ``INTEGER``. It represents the + location of the memory that should be de-allocated. + + :return: + None + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL FREE(PTR) + + Example: + See ``MALLOC`` for an example. + + See also: + :ref:`MALLOC` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/fseek.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/fseek.rst new file mode 100644 index 00000000000..cddc4b87305 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/fseek.rst @@ -0,0 +1,72 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: FSEEK, file operation, seek, file operation, position + +.. _fseek: + +FSEEK --- Low level file positioning subroutine +*********************************************** + +.. function:: FSEEK(UNIT, OFFSET, WHENCE, STATUS) + + Moves :samp:`{UNIT}` to the specified :samp:`{OFFSET}`. If :samp:`{WHENCE}` + is set to 0, the :samp:`{OFFSET}` is taken as an absolute value ``SEEK_SET``, + if set to 1, :samp:`{OFFSET}` is taken to be relative to the current position + ``SEEK_CUR``, and if set to 2 relative to the end of the file ``SEEK_END``. + On error, :samp:`{STATUS}` is set to a nonzero value. If :samp:`{STATUS}` the seek + fails silently. + + :param UNIT: + Shall be a scalar of type ``INTEGER``. + + :param OFFSET: + Shall be a scalar of type ``INTEGER``. + + :param WHENCE: + Shall be a scalar of type ``INTEGER``. + Its value shall be either 0, 1 or 2. + + :param STATUS: + (Optional) shall be a scalar of type + ``INTEGER(4)``. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS]) + + Example: + .. code-block:: fortran + + PROGRAM test_fseek + INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2 + INTEGER :: fd, offset, ierr + + ierr = 0 + offset = 5 + fd = 10 + + OPEN(UNIT=fd, FILE="fseek.test") + CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET + print *, FTELL(fd), ierr + + CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end + print *, FTELL(fd), ierr + + CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning + print *, FTELL(fd), ierr + + CLOSE(UNIT=fd) + END PROGRAM + + See also: + :ref:`FTELL` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/fstat.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/fstat.rst new file mode 100644 index 00000000000..dfd44f8592b --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/fstat.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _fstat: + +FSTAT --- Get file status +************************* + +.. index:: FSTAT, file system, file status + +.. function:: FSTAT(UNIT, VALUES, STATUS) + + ``FSTAT`` is identical to :ref:`STAT`, except that information about an + already opened file is obtained. + + :param UNIT: + An open I/O unit number of type ``INTEGER``. + + :param VALUES: + The type shall be ``INTEGER(4), DIMENSION(13)``. + + :param STATUS: + (Optional) status flag of type ``INTEGER(4)``. Returns 0 + on success and a system specific error code otherwise. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL FSTAT(UNIT, VALUES [, STATUS]) + STATUS = FSTAT(UNIT, VALUES) + + Example: + See :ref:`STAT` for an example. + + See also: + To stat a link: + :ref:`LSTAT` + To stat a file: + :ref:`STAT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ftell.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ftell.rst new file mode 100644 index 00000000000..fcd0e265766 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ftell.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: FTELL, file operation, position + +.. _ftell: + +FTELL --- Current stream position +********************************* + +.. function:: FTELL(UNIT) + + Retrieves the current position within an open file. + + :param OFFSET: + Shall of type ``INTEGER``. + + :param UNIT: + Shall of type ``INTEGER``. + + :return: + In either syntax, :samp:`{OFFSET}` is set to the current offset of unit + number :samp:`{UNIT}`, or to -1 if the unit is not currently open. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL FTELL(UNIT, OFFSET) + OFFSET = FTELL(UNIT) + + Example: + .. code-block:: fortran + + PROGRAM test_ftell + INTEGER :: i + OPEN(10, FILE="temp.dat") + CALL ftell(10,i) + WRITE(*,*) i + END PROGRAM + + See also: + :ref:`FSEEK` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/gamma.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/gamma.rst new file mode 100644 index 00000000000..5d589723731 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/gamma.rst @@ -0,0 +1,67 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gamma: + +.. index:: GAMMA + +.. index:: DGAMMA + +.. index:: Gamma function + +.. index:: Factorial function + +GAMMA --- Gamma function +************************ + +.. function:: GAMMA(X) + + ``GAMMA(X)`` computes Gamma (\Gamma) of :samp:`{X}`. For positive, + integer values of :samp:`{X}` the Gamma function simplifies to the factorial + function \Gamma(x)=(x-1)!. + + :param X: + Shall be of type ``REAL`` and neither zero + nor a negative integer. + + :return: + The return value is of type ``REAL`` of the same kind as :samp:`{X}`. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + X = GAMMA(X) + + Example: + .. code-block:: fortran + + program test_gamma + real :: x = 1.0 + x = gamma(x) ! returns 1.0 + end program test_gamma + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DGAMMA(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension + + See also: + Logarithm of the Gamma function: + :ref:`LOG_GAMMA` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/gerror.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/gerror.rst new file mode 100644 index 00000000000..dedbef7e59f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/gerror.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GERROR, system, error handling + +.. _gerror: + +GERROR --- Get last system error message +**************************************** + +.. function:: GERROR(RESULT) + + Returns the system error message corresponding to the last system error. + This resembles the functionality of ``strerror(3)`` in C. + + :param RESULT: + Shall be of type ``CHARACTER`` and of default kind. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL GERROR(RESULT) + + Example: + .. code-block:: fortran + + PROGRAM test_gerror + CHARACTER(len=100) :: msg + CALL gerror(msg) + WRITE(*,*) msg + END PROGRAM + + See also: + :ref:`IERRNO`, + :ref:`PERROR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/getarg.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/getarg.rst new file mode 100644 index 00000000000..348c03a64bb --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/getarg.rst @@ -0,0 +1,64 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GETARG, command-line arguments, arguments, to program + +.. _getarg: + +GETARG --- Get command line arguments +************************************* + +.. function:: GETARG(POS, VALUE) + + Retrieve the :samp:`{POS}` -th argument that was passed on the + command line when the containing program was invoked. + + :param POS: + Shall be of type ``INTEGER`` and not wider than + the default integer kind; :samp:`{POS}` \geq 0 + + :param VALUE: + Shall be of type ``CHARACTER`` and of default + kind. + + :return: + After ``GETARG`` returns, the :samp:`{VALUE}` argument holds the + :samp:`{POS}` th command line argument. If :samp:`{VALUE}` cannot hold the + argument, it is truncated to fit the length of :samp:`{VALUE}`. If there are + less than :samp:`{POS}` arguments specified at the command line, :samp:`{VALUE}` + will be filled with blanks. If :samp:`{POS}` = 0, :samp:`{VALUE}` is set + to the name of the program (on systems that support this feature). + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL GETARG(POS, VALUE) + + Example: + .. code-block:: fortran + + PROGRAM test_getarg + INTEGER :: i + CHARACTER(len=32) :: arg + + DO i = 1, iargc() + CALL getarg(i, arg) + WRITE (*,*) arg + END DO + END PROGRAM + + See also: + GNU Fortran 77 compatibility function: + :ref:`IARGC` + Fortran 2003 functions and subroutines: + :ref:`GET_COMMAND`, + :ref:`GET_COMMAND_ARGUMENT`, + :ref:`COMMAND_ARGUMENT_COUNT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/getcommand.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/getcommand.rst new file mode 100644 index 00000000000..9c959996b63 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/getcommand.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GET_COMMAND, command-line arguments, arguments, to program + +.. _get_command: + +GET_COMMAND --- Get the entire command line +******************************************* + +.. function:: GET_COMMAND(COMMAND, LENGTH, STATUS) + + Retrieve the entire command line that was used to invoke the program. + + :param COMMAND: + (Optional) shall be of type ``CHARACTER`` and + of default kind. + + :param LENGTH: + (Optional) Shall be of type ``INTEGER`` and of + default kind. + + :param STATUS: + (Optional) Shall be of type ``INTEGER`` and of + default kind. + + :return: + If :samp:`{COMMAND}` is present, stores the entire command line that was used + to invoke the program in :samp:`{COMMAND}`. If :samp:`{LENGTH}` is present, it is + assigned the length of the command line. If :samp:`{STATUS}` is present, it + is assigned 0 upon success of the command, -1 if :samp:`{COMMAND}` is too + short to store the command line, or a positive value in case of an error. + + Standard: + Fortran 2003 and later + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL GET_COMMAND([COMMAND, LENGTH, STATUS]) + + Example: + .. code-block:: fortran + + PROGRAM test_get_command + CHARACTER(len=255) :: cmd + CALL get_command(cmd) + WRITE (*,*) TRIM(cmd) + END PROGRAM + + See also: + :ref:`GET_COMMAND_ARGUMENT`, + :ref:`COMMAND_ARGUMENT_COUNT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/getcommandargument.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/getcommandargument.rst new file mode 100644 index 00000000000..57c7d5647f5 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/getcommandargument.rst @@ -0,0 +1,76 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GET_COMMAND_ARGUMENT, command-line arguments, arguments, to program + +.. _get_command_argument: + +GET_COMMAND_ARGUMENT --- Get command line arguments +*************************************************** + +.. function:: GET_COMMAND_ARGUMENT(NUMBER , VALUE, LENGTH, STATUS) + + Retrieve the :samp:`{NUMBER}` -th argument that was passed on the + command line when the containing program was invoked. + + :param NUMBER: + Shall be a scalar of type ``INTEGER`` and of + default kind, :samp:`{NUMBER}` \geq 0 + + :param VALUE: + (Optional) Shall be a scalar of type ``CHARACTER`` + and of default kind. + + :param LENGTH: + (Optional) Shall be a scalar of type ``INTEGER`` + and of default kind. + + :param STATUS: + (Optional) Shall be a scalar of type ``INTEGER`` + and of default kind. + + :return: + After ``GET_COMMAND_ARGUMENT`` returns, the :samp:`{VALUE}` argument holds the + :samp:`{NUMBER}` -th command line argument. If :samp:`{VALUE}` cannot hold the argument, it is + truncated to fit the length of :samp:`{VALUE}`. If there are less than :samp:`{NUMBER}` + arguments specified at the command line, :samp:`{VALUE}` will be filled with blanks. + If :samp:`{NUMBER}` = 0, :samp:`{VALUE}` is set to the name of the program (on + systems that support this feature). The :samp:`{LENGTH}` argument contains the + length of the :samp:`{NUMBER}` -th command line argument. If the argument retrieval + fails, :samp:`{STATUS}` is a positive number; if :samp:`{VALUE}` contains a truncated + command line argument, :samp:`{STATUS}` is -1; and otherwise the :samp:`{STATUS}` is + zero. + + Standard: + Fortran 2003 and later + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS]) + + Example: + .. code-block:: fortran + + PROGRAM test_get_command_argument + INTEGER :: i + CHARACTER(len=32) :: arg + + i = 0 + DO + CALL get_command_argument(i, arg) + IF (LEN_TRIM(arg) == 0) EXIT + + WRITE (*,*) TRIM(arg) + i = i+1 + END DO + END PROGRAM + + See also: + :ref:`GET_COMMAND`, + :ref:`COMMAND_ARGUMENT_COUNT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/getcwd.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/getcwd.rst new file mode 100644 index 00000000000..2c226021d6e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/getcwd.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GETCWD, system, working directory + +.. _getcwd: + +GETCWD --- Get current working directory +**************************************** + +.. function:: GETCWD(C) + + Get current working directory. + + :param C: + The type shall be ``CHARACTER`` and of default kind. + + :param STATUS: + (Optional) status flag. Returns 0 on success, + a system specific and nonzero error code otherwise. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL GETCWD(C [, STATUS]) + STATUS = GETCWD(C) + + Example: + .. code-block:: fortran + + PROGRAM test_getcwd + CHARACTER(len=255) :: cwd + CALL getcwd(cwd) + WRITE(*,*) TRIM(cwd) + END PROGRAM + + See also: + :ref:`CHDIR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/getenv.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/getenv.rst new file mode 100644 index 00000000000..706d48a5cdc --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/getenv.rst @@ -0,0 +1,49 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GETENV, environment variable + +.. _getenv: + +GETENV --- Get an environmental variable +**************************************** + +.. function:: GETENV(NAME, VALUE) + + Get the :samp:`{VALUE}` of the environmental variable :samp:`{NAME}`. + + :param NAME: + Shall be of type ``CHARACTER`` and of default kind. + + :param VALUE: + Shall be of type ``CHARACTER`` and of default kind. + + :return: + Stores the value of :samp:`{NAME}` in :samp:`{VALUE}`. If :samp:`{VALUE}` is + not large enough to hold the data, it is truncated. If :samp:`{NAME}` + is not set, :samp:`{VALUE}` will be filled with blanks. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL GETENV(NAME, VALUE) + + Example: + .. code-block:: fortran + + PROGRAM test_getenv + CHARACTER(len=255) :: homedir + CALL getenv("HOME", homedir) + WRITE (*,*) TRIM(homedir) + END PROGRAM + + See also: + :ref:`GET_ENVIRONMENT_VARIABLE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/getenvironmentvariable.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/getenvironmentvariable.rst new file mode 100644 index 00000000000..22fec7ed009 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/getenvironmentvariable.rst @@ -0,0 +1,68 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GET_ENVIRONMENT_VARIABLE, environment variable + +.. _get_environment_variable: + +GET_ENVIRONMENT_VARIABLE --- Get an environmental variable +********************************************************** + +.. function:: GET_ENVIRONMENT_VARIABLE(NAME, VALUE, LENGTH, STATUS, TRIM_NAME) + + Get the :samp:`{VALUE}` of the environmental variable :samp:`{NAME}`. + + :param NAME: + Shall be a scalar of type ``CHARACTER`` + and of default kind. + + :param VALUE: + (Optional) Shall be a scalar of type ``CHARACTER`` + and of default kind. + + :param LENGTH: + (Optional) Shall be a scalar of type ``INTEGER`` + and of default kind. + + :param STATUS: + (Optional) Shall be a scalar of type ``INTEGER`` + and of default kind. + + :param TRIM_NAME: + (Optional) Shall be a scalar of type ``LOGICAL`` + and of default kind. + + :return: + Stores the value of :samp:`{NAME}` in :samp:`{VALUE}`. If :samp:`{VALUE}` is + not large enough to hold the data, it is truncated. If :samp:`{NAME}` + is not set, :samp:`{VALUE}` will be filled with blanks. Argument :samp:`{LENGTH}` + contains the length needed for storing the environment variable :samp:`{NAME}` + or zero if it is not present. :samp:`{STATUS}` is -1 if :samp:`{VALUE}` is present + but too short for the environment variable; it is 1 if the environment + variable does not exist and 2 if the processor does not support environment + variables; in all other cases :samp:`{STATUS}` is zero. If :samp:`{TRIM_NAME}` is + present with the value ``.FALSE.``, the trailing blanks in :samp:`{NAME}` + are significant; otherwise they are not part of the environment variable + name. + + Standard: + Fortran 2003 and later + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME) + + Example: + .. code-block:: fortran + + PROGRAM test_getenv + CHARACTER(len=255) :: homedir + CALL get_environment_variable("HOME", homedir) + WRITE (*,*) TRIM(homedir) + END PROGRAM \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/getgid.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/getgid.rst new file mode 100644 index 00000000000..07fc8e4b52d --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/getgid.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GETGID, system, group ID + +.. _getgid: + +GETGID --- Group ID function +**************************** + +.. function:: GETGID() + + Returns the numerical group ID of the current process. + + :return: + The return value of ``GETGID`` is an ``INTEGER`` of the default + kind. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = GETGID() + + Example: + See ``GETPID`` for an example. + + See also: + :ref:`GETPID`, + :ref:`GETUID` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/getlog.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/getlog.rst new file mode 100644 index 00000000000..888f8bb9392 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/getlog.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GETLOG, system, login name, login name + +.. _getlog: + +GETLOG --- Get login name +************************* + +.. function:: GETLOG(C) + + Gets the username under which the program is running. + + :param C: + Shall be of type ``CHARACTER`` and of default kind. + + :return: + Stores the current user name in :samp:`{C}`. (On systems where POSIX + functions ``geteuid`` and ``getpwuid`` are not available, and + the ``getlogin`` function is not implemented either, this will + return a blank string.) + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL GETLOG(C) + + Example: + .. code-block:: fortran + + PROGRAM TEST_GETLOG + CHARACTER(32) :: login + CALL GETLOG(login) + WRITE(*,*) login + END PROGRAM + + See also: + :ref:`GETUID` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/getpid.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/getpid.rst new file mode 100644 index 00000000000..a9a4d8370c4 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/getpid.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GETPID, system, process ID, process ID + +.. _getpid: + +GETPID --- Process ID function +****************************** + +.. function:: GETPID() + + Returns the numerical process identifier of the current process. + + :return: + The return value of ``GETPID`` is an ``INTEGER`` of the default + kind. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = GETPID() + + Example: + .. code-block:: fortran + + program info + print *, "The current process ID is ", getpid() + print *, "Your numerical user ID is ", getuid() + print *, "Your numerical group ID is ", getgid() + end program info + + See also: + :ref:`GETGID`, + :ref:`GETUID` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/getuid.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/getuid.rst new file mode 100644 index 00000000000..ab37b3f09c9 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/getuid.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GETUID, system, user ID, user id + +.. _getuid: + +GETUID --- User ID function +*************************** + +.. function:: GETUID() + + Returns the numerical user ID of the current process. + + :return: + The return value of ``GETUID`` is an ``INTEGER`` of the default + kind. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = GETUID() + + Example: + See ``GETPID`` for an example. + + See also: + :ref:`GETPID`, + :ref:`GETLOG` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/gmtime.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/gmtime.rst new file mode 100644 index 00000000000..35b24c447ef --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/gmtime.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: GMTIME, time, conversion to GMT info + +.. _gmtime: + +GMTIME --- Convert time to GMT info +*********************************** + +.. function:: GMTIME(TIME, VALUES) + + Given a system time value :samp:`{TIME}` (as provided by the :ref:`TIME` + intrinsic), fills :samp:`{VALUES}` with values extracted from it appropriate + to the UTC time zone (Universal Coordinated Time, also known in some + countries as GMT, Greenwich Mean Time), using ``gmtime(3)``. + + :param TIME: + An ``INTEGER`` scalar expression + corresponding to a system time, with ``INTENT(IN)``. + + :param VALUES: + A default ``INTEGER`` array with 9 elements, + with ``INTENT(OUT)``. + + :return: + The elements of :samp:`{VALUES}` are assigned as follows: + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL GMTIME(TIME, VALUES) + + See also: + :ref:`DATE_AND_TIME`, + :ref:`CTIME`, + :ref:`LTIME`, + :ref:`TIME`, + :ref:`TIME8` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/hostnm.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/hostnm.rst new file mode 100644 index 00000000000..319f09474d8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/hostnm.rst @@ -0,0 +1,38 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: HOSTNM, system, host name + +.. _hostnm: + +HOSTNM --- Get system host name +******************************* + +.. function:: HOSTNM(NAME) + + Retrieves the host name of the system on which the program is running. + + :param C: + Shall of type ``CHARACTER`` and of default kind. + + :param STATUS: + (Optional) status flag of type ``INTEGER``. + Returns 0 on success, or a system specific error code otherwise. + + :return: + In either syntax, :samp:`{NAME}` is set to the current hostname if it can + be obtained, or to a blank string otherwise. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL HOSTNM(C [, STATUS]) + STATUS = HOSTNM(NAME) \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/huge.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/huge.rst new file mode 100644 index 00000000000..6f7fec8aaad --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/huge.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: HUGE, limits, largest number, model representation, largest number + +.. _huge: + +HUGE --- Largest number of a kind +********************************* + +.. function:: HUGE(X) + + ``HUGE(X)`` returns the largest number that is not an infinity in + the model of the type of ``X``. + + :param X: + Shall be of type ``REAL`` or ``INTEGER``. + + :return: + The return value is of the same type and kind as :samp:`{X}` + + Standard: + Fortran 90 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = HUGE(X) + + Example: + .. code-block:: fortran + + program test_huge_tiny + print *, huge(0), huge(0.0), huge(0.0d0) + print *, tiny(0.0), tiny(0.0d0) + end program test_huge_tiny \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/hypot.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/hypot.rst new file mode 100644 index 00000000000..f567cc18e8f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/hypot.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: HYPOT, Euclidean distance + +.. _hypot: + +HYPOT --- Euclidean distance function +************************************* + +.. function:: HYPOT(X,Y) + + ``HYPOT(X,Y)`` is the Euclidean distance function. It is equal to + \sqrt{X^2 + Y^2}, without undue underflow or overflow. + + :param X: + The type shall be ``REAL``. + + :param Y: + The type and kind type parameter shall be the same as + :samp:`{X}`. + + :return: + The return value has the same type and kind type parameter as :samp:`{X}`. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = HYPOT(X, Y) + + Example: + .. code-block:: fortran + + program test_hypot + real(4) :: x = 1.e0_4, y = 0.5e0_4 + x = hypot(x,y) + end program test_hypot \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/iachar.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/iachar.rst new file mode 100644 index 00000000000..edc94e6a259 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/iachar.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: IACHAR, ASCII collating sequence, collating sequence, ASCII, conversion, to integer + +.. _iachar: + +IACHAR --- Code in ASCII collating sequence +******************************************** + +.. function:: IACHAR(C) + + ``IACHAR(C)`` returns the code for the ASCII character + in the first character position of ``C``. + + :param C: + Shall be a scalar ``CHARACTER``, with ``INTENT(IN)`` + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + + Standard: + Fortran 95 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = IACHAR(C [, KIND]) + + Example: + .. code-block:: fortran + + program test_iachar + integer i + i = iachar(' ') + end program test_iachar + + Note: + See :ref:`ICHAR` for a discussion of converting between numerical values + and formatted string representations. + + See also: + :ref:`ACHAR`, + :ref:`CHAR`, + :ref:`ICHAR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/iall.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/iall.rst new file mode 100644 index 00000000000..2f6a41d2546 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/iall.rst @@ -0,0 +1,61 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: IALL, array, AND, bits, AND of array elements + +.. _iall: + +IALL --- Bitwise AND of array elements +************************************** + +.. function:: IALL(ARRAY, DIM, MASK) + + Reduces with bitwise AND the elements of :samp:`{ARRAY}` along dimension :samp:`{DIM}` + if the corresponding element in :samp:`{MASK}` is ``TRUE``. + + :param ARRAY: + Shall be an array of type ``INTEGER`` + + :param DIM: + (Optional) shall be a scalar of type + ``INTEGER`` with a value in the range from 1 to n, where n + equals the rank of :samp:`{ARRAY}`. + + :param MASK: + (Optional) shall be of type ``LOGICAL`` + and either be a scalar or an array of the same shape as :samp:`{ARRAY}`. + + :return: + The result is of the same type as :samp:`{ARRAY}`. + + Standard: + Fortran 2008 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = IALL(ARRAY[, MASK]) + RESULT = IALL(ARRAY, DIM[, MASK]) + + Example: + .. code-block:: fortran + + PROGRAM test_iall + INTEGER(1) :: a(2) + + a(1) = b'00100100' + a(2) = b'01101010' + + ! prints 00100000 + PRINT '(b8.8)', IALL(a) + END PROGRAM + + See also: + :ref:`IANY`, + :ref:`IPARITY`, + :ref:`IAND` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/iand.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/iand.rst new file mode 100644 index 00000000000..804ce5e5824 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/iand.rst @@ -0,0 +1,99 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _iand: + +.. index:: IAND + +.. index:: BIAND + +.. index:: IIAND + +.. index:: JIAND + +.. index:: KIAND + +.. index:: bitwise logical and + +.. index:: logical and, bitwise + +IAND --- Bitwise logical and +**************************** + +.. function:: IAND(I, J) + + Bitwise logical ``AND``. + + :param I: + The type shall be ``INTEGER`` or a boz-literal-constant. + + :param J: + The type shall be ``INTEGER`` with the same + kind type parameter as :samp:`{I}` or a boz-literal-constant. + :samp:`{I}` and :samp:`{J}` shall not both be boz-literal-constants. + + :return: + The return type is ``INTEGER`` with the kind type parameter of the + arguments. + A boz-literal-constant is converted to an ``INTEGER`` with the kind + type parameter of the other argument as-if a call to :ref:`INT` occurred. + + Standard: + Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = IAND(I, J) + + Example: + .. code-block:: fortran + + PROGRAM test_iand + INTEGER :: a, b + DATA a / Z'F' /, b / Z'3' / + WRITE (*,*) IAND(a, b) + END PROGRAM + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``IAND(A)`` + - ``INTEGER A`` + - ``INTEGER`` + - Fortran 90 and later + * - ``BIAND(A)`` + - ``INTEGER(1) A`` + - ``INTEGER(1)`` + - GNU extension + * - ``IIAND(A)`` + - ``INTEGER(2) A`` + - ``INTEGER(2)`` + - GNU extension + * - ``JIAND(A)`` + - ``INTEGER(4) A`` + - ``INTEGER(4)`` + - GNU extension + * - ``KIAND(A)`` + - ``INTEGER(8) A`` + - ``INTEGER(8)`` + - GNU extension + + See also: + :ref:`IOR`, + :ref:`IEOR`, + :ref:`IBITS`, + :ref:`IBSET`, + :ref:`IBCLR`, + :ref:`NOT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/iany.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/iany.rst new file mode 100644 index 00000000000..523b04e5828 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/iany.rst @@ -0,0 +1,61 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: IANY, array, OR, bits, OR of array elements + +.. _iany: + +IANY --- Bitwise OR of array elements +************************************* + +.. function:: IANY(ARRAY, DIM, MASK) + + Reduces with bitwise OR (inclusive or) the elements of :samp:`{ARRAY}` along + dimension :samp:`{DIM}` if the corresponding element in :samp:`{MASK}` is ``TRUE``. + + :param ARRAY: + Shall be an array of type ``INTEGER`` + + :param DIM: + (Optional) shall be a scalar of type + ``INTEGER`` with a value in the range from 1 to n, where n + equals the rank of :samp:`{ARRAY}`. + + :param MASK: + (Optional) shall be of type ``LOGICAL`` + and either be a scalar or an array of the same shape as :samp:`{ARRAY}`. + + :return: + The result is of the same type as :samp:`{ARRAY}`. + + Standard: + Fortran 2008 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = IANY(ARRAY[, MASK]) + RESULT = IANY(ARRAY, DIM[, MASK]) + + Example: + .. code-block:: fortran + + PROGRAM test_iany + INTEGER(1) :: a(2) + + a(1) = b'00100100' + a(2) = b'01101010' + + ! prints 01101110 + PRINT '(b8.8)', IANY(a) + END PROGRAM + + See also: + :ref:`IPARITY`, + :ref:`IALL`, + :ref:`IOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/iargc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/iargc.rst new file mode 100644 index 00000000000..6242b1367bd --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/iargc.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _iargc: + +IARGC --- Get the number of command line arguments +************************************************** + +.. index:: IARGC, command-line arguments, command-line arguments, number of, arguments, to program + +.. function:: IARGC() + + ``IARGC`` returns the number of arguments passed on the + command line when the containing program was invoked. + + :return: + The number of command line arguments, type ``INTEGER(4)``. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = IARGC() + + Arguments: + None + + Example: + See :ref:`GETARG` + + See also: + GNU Fortran 77 compatibility subroutine: + :ref:`GETARG` + Fortran 2003 functions and subroutines: + :ref:`GET_COMMAND`, + :ref:`GET_COMMAND_ARGUMENT`, + :ref:`COMMAND_ARGUMENT_COUNT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ibclr.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ibclr.rst new file mode 100644 index 00000000000..44be678880c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ibclr.rst @@ -0,0 +1,87 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ibclr: + +.. index:: IBCLR + +.. index:: BBCLR + +.. index:: IIBCLR + +.. index:: JIBCLR + +.. index:: KIBCLR + +.. index:: bits, unset + +.. index:: bits, clear + +IBCLR --- Clear bit +******************* + +.. function:: IBCLR() + + ``IBCLR`` returns the value of :samp:`{I}` with the bit at position + :samp:`{POS}` set to zero. + + :param I: + The type shall be ``INTEGER``. + + :param POS: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` and of the same kind as + :samp:`{I}`. + + Standard: + Fortran 90 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = IBCLR(I, POS) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``IBCLR(A)`` + - ``INTEGER A`` + - ``INTEGER`` + - Fortran 90 and later + * - ``BBCLR(A)`` + - ``INTEGER(1) A`` + - ``INTEGER(1)`` + - GNU extension + * - ``IIBCLR(A)`` + - ``INTEGER(2) A`` + - ``INTEGER(2)`` + - GNU extension + * - ``JIBCLR(A)`` + - ``INTEGER(4) A`` + - ``INTEGER(4)`` + - GNU extension + * - ``KIBCLR(A)`` + - ``INTEGER(8) A`` + - ``INTEGER(8)`` + - GNU extension + + See also: + :ref:`IBITS`, + :ref:`IBSET`, + :ref:`IAND`, + :ref:`IOR`, + :ref:`IEOR`, + :ref:`MVBITS` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ibits.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ibits.rst new file mode 100644 index 00000000000..9c14634efd2 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ibits.rst @@ -0,0 +1,93 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ibits: + +.. index:: IBITS + +.. index:: BBITS + +.. index:: IIBITS + +.. index:: JIBITS + +.. index:: KIBITS + +.. index:: bits, get + +.. index:: bits, extract + +IBITS --- Bit extraction +************************ + +.. function:: IBITS() + + ``IBITS`` extracts a field of length :samp:`{LEN}` from :samp:`{I}`, + starting from bit position :samp:`{POS}` and extending left for :samp:`{LEN}` + bits. The result is right-justified and the remaining bits are + zeroed. The value of ``POS+LEN`` must be less than or equal to the + value ``BIT_SIZE(I)``. + + :param I: + The type shall be ``INTEGER``. + + :param POS: + The type shall be ``INTEGER``. + + :param LEN: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` and of the same kind as + :samp:`{I}`. + + Standard: + Fortran 90 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = IBITS(I, POS, LEN) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``IBITS(A)`` + - ``INTEGER A`` + - ``INTEGER`` + - Fortran 90 and later + * - ``BBITS(A)`` + - ``INTEGER(1) A`` + - ``INTEGER(1)`` + - GNU extension + * - ``IIBITS(A)`` + - ``INTEGER(2) A`` + - ``INTEGER(2)`` + - GNU extension + * - ``JIBITS(A)`` + - ``INTEGER(4) A`` + - ``INTEGER(4)`` + - GNU extension + * - ``KIBITS(A)`` + - ``INTEGER(8) A`` + - ``INTEGER(8)`` + - GNU extension + + See also: + :ref:`BIT_SIZE`, + :ref:`IBCLR`, + :ref:`IBSET`, + :ref:`IAND`, + :ref:`IOR`, + :ref:`IEOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ibset.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ibset.rst new file mode 100644 index 00000000000..502947f46e7 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ibset.rst @@ -0,0 +1,85 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ibset: + +.. index:: IBSET + +.. index:: BBSET + +.. index:: IIBSET + +.. index:: JIBSET + +.. index:: KIBSET + +.. index:: bits, set + +IBSET --- Set bit +***************** + +.. function:: IBSET() + + ``IBSET`` returns the value of :samp:`{I}` with the bit at position + :samp:`{POS}` set to one. + + :param I: + The type shall be ``INTEGER``. + + :param POS: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` and of the same kind as + :samp:`{I}`. + + Standard: + Fortran 90 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = IBSET(I, POS) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``IBSET(A)`` + - ``INTEGER A`` + - ``INTEGER`` + - Fortran 90 and later + * - ``BBSET(A)`` + - ``INTEGER(1) A`` + - ``INTEGER(1)`` + - GNU extension + * - ``IIBSET(A)`` + - ``INTEGER(2) A`` + - ``INTEGER(2)`` + - GNU extension + * - ``JIBSET(A)`` + - ``INTEGER(4) A`` + - ``INTEGER(4)`` + - GNU extension + * - ``KIBSET(A)`` + - ``INTEGER(8) A`` + - ``INTEGER(8)`` + - GNU extension + + See also: + :ref:`IBCLR`, + :ref:`IBITS`, + :ref:`IAND`, + :ref:`IOR`, + :ref:`IEOR`, + :ref:`MVBITS` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ichar.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ichar.rst new file mode 100644 index 00000000000..3ff689ecdcf --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ichar.rst @@ -0,0 +1,93 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ichar: + +.. index:: ICHAR + +.. index:: conversion, to integer + +ICHAR --- Character-to-integer conversion function +************************************************** + +.. function:: ICHAR(C) + + ``ICHAR(C)`` returns the code for the character in the first character + position of ``C`` in the system's native character set. + The correspondence between characters and their codes is not necessarily + the same across different GNU Fortran implementations. + + :param C: + Shall be a scalar ``CHARACTER``, with ``INTENT(IN)`` + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + + Standard: + Fortran 77 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ICHAR(C [, KIND]) + + Example: + .. code-block:: fortran + + program test_ichar + integer i + i = ichar(' ') + end program test_ichar + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ICHAR(C)`` + - ``CHARACTER C`` + - ``INTEGER(4)`` + - Fortran 77 and later + + Note: + No intrinsic exists to convert between a numeric value and a formatted + character string representation -- for instance, given the + ``CHARACTER`` value ``'154'``, obtaining an ``INTEGER`` or + ``REAL`` value with the value 154, or vice versa. Instead, this + functionality is provided by internal-file I/O, as in the following + example: + + .. code-block:: fortran + + program read_val + integer value + character(len=10) string, string2 + string = '154' + + ! Convert a string to a numeric value + read (string,'(I10)') value + print *, value + + ! Convert a value to a formatted string + write (string2,'(I10)') value + print *, string2 + end program read_val + + See also: + :ref:`ACHAR`, + :ref:`CHAR`, + :ref:`IACHAR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/idate.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/idate.rst new file mode 100644 index 00000000000..798e115352e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/idate.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: IDATE, date, current, current date + +.. _idate: + +IDATE --- Get current local time subroutine (day/month/year) +************************************************************* + +.. function:: IDATE(VALUES) + + ``IDATE(VALUES)`` Fills :samp:`{VALUES}` with the numerical values at the + current local time. The day (in the range 1-31), month (in the range 1-12), + and year appear in elements 1, 2, and 3 of :samp:`{VALUES}`, respectively. + The year has four significant digits. + + :param VALUES: + The type shall be ``INTEGER, DIMENSION(3)`` and + the kind shall be the default integer kind. + + :return: + Does not return anything. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL IDATE(VALUES) + + Example: + .. code-block:: fortran + + program test_idate + integer, dimension(3) :: tarray + call idate(tarray) + print *, tarray(1) + print *, tarray(2) + print *, tarray(3) + end program test_idate + + See also: + :ref:`DATE_AND_TIME` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ieor.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ieor.rst new file mode 100644 index 00000000000..79d6a3de447 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ieor.rst @@ -0,0 +1,91 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ieor: + +.. index:: IEOR + +.. index:: BIEOR + +.. index:: IIEOR + +.. index:: JIEOR + +.. index:: KIEOR + +.. index:: bitwise logical exclusive or + +.. index:: logical exclusive or, bitwise + +IEOR --- Bitwise logical exclusive or +************************************* + +.. function:: IEOR() + + ``IEOR`` returns the bitwise Boolean exclusive-OR of :samp:`{I}` and + :samp:`{J}`. + + :param I: + The type shall be ``INTEGER`` or a boz-literal-constant. + + :param J: + The type shall be ``INTEGER`` with the same + kind type parameter as :samp:`{I}` or a boz-literal-constant. + :samp:`{I}` and :samp:`{J}` shall not both be boz-literal-constants. + + :return: + The return type is ``INTEGER`` with the kind type parameter of the + arguments. + A boz-literal-constant is converted to an ``INTEGER`` with the kind + type parameter of the other argument as-if a call to :ref:`INT` occurred. + + Standard: + Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = IEOR(I, J) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``IEOR(A)`` + - ``INTEGER A`` + - ``INTEGER`` + - Fortran 90 and later + * - ``BIEOR(A)`` + - ``INTEGER(1) A`` + - ``INTEGER(1)`` + - GNU extension + * - ``IIEOR(A)`` + - ``INTEGER(2) A`` + - ``INTEGER(2)`` + - GNU extension + * - ``JIEOR(A)`` + - ``INTEGER(4) A`` + - ``INTEGER(4)`` + - GNU extension + * - ``KIEOR(A)`` + - ``INTEGER(8) A`` + - ``INTEGER(8)`` + - GNU extension + + See also: + :ref:`IOR`, + :ref:`IAND`, + :ref:`IBITS`, + :ref:`IBSET`, + :ref:`IBCLR`, + :ref:`NOT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ierrno.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ierrno.rst new file mode 100644 index 00000000000..fbeff170871 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ierrno.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: IERRNO, system, error handling + +.. _ierrno: + +IERRNO --- Get the last system error number +******************************************* + +.. function:: IERRNO() + + Returns the last system error number, as given by the C ``errno`` + variable. + + :return: + The return value is of type ``INTEGER`` and of the default integer + kind. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = IERRNO() + + Arguments: + None + + See also: + :ref:`PERROR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/imageindex.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/imageindex.rst new file mode 100644 index 00000000000..7f28957b985 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/imageindex.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: IMAGE_INDEX, coarray, IMAGE_INDEX, images, cosubscript to image index conversion + +.. _image_index: + +IMAGE_INDEX --- Function that converts a cosubscript to an image index +********************************************************************** + +.. function:: IMAGE_INDEX(COARRAY, SUB) + + Returns the image index belonging to a cosubscript. + + :param COARRAY: + Coarray of any type. + + :param SUB: + default integer rank-1 array of a size equal to + the corank of :samp:`{COARRAY}`. + + :return: + Scalar default integer with the value of the image index which corresponds + to the cosubscripts. For invalid cosubscripts the result is zero. + + Standard: + Fortran 2008 and later + + Class: + Inquiry function. + + Syntax: + .. code-block:: fortran + + RESULT = IMAGE_INDEX(COARRAY, SUB) + + Example: + .. code-block:: fortran + + INTEGER :: array[2,-1:4,8,*] + ! Writes 28 (or 0 if there are fewer than 28 images) + WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1]) + + See also: + :ref:`THIS_IMAGE`, + :ref:`NUM_IMAGES` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/index.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/index.rst new file mode 100644 index 00000000000..969aa612545 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/index.rst @@ -0,0 +1,72 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _index-intrinsic: + +.. index:: INDEX + +.. index:: substring position + +.. index:: string, find substring + +INDEX --- Position of a substring within a string +************************************************* + +.. function:: INDEX(STRING, SUBSTRING , BACK , KIND) + + Returns the position of the start of the first occurrence of string + :samp:`{SUBSTRING}` as a substring in :samp:`{STRING}`, counting from one. If + :samp:`{SUBSTRING}` is not present in :samp:`{STRING}`, zero is returned. If + the :samp:`{BACK}` argument is present and true, the return value is the + start of the last occurrence rather than the first. + + :param STRING: + Shall be a scalar ``CHARACTER``, with + ``INTENT(IN)`` + + :param SUBSTRING: + Shall be a scalar ``CHARACTER``, with + ``INTENT(IN)`` + + :param BACK: + (Optional) Shall be a scalar ``LOGICAL``, with + ``INTENT(IN)`` + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + + Standard: + Fortran 77 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]]) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``INDEX(STRING,SUBSTRING)`` + - ``CHARACTER`` + - ``INTEGER(4)`` + - Fortran 77 and later + + See also: + :ref:`SCAN`, + :ref:`VERIFY` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/int.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/int.rst new file mode 100644 index 00000000000..43d2a56be38 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/int.rst @@ -0,0 +1,76 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _int: + +.. index:: INT + +.. index:: IFIX + +.. index:: IDINT + +.. index:: conversion, to integer + +INT --- Convert to integer type +******************************* + +.. function:: INT(A , KIND)) + + Convert to integer type + + :param A: + Shall be of type ``INTEGER``, + ``REAL``, or ``COMPLEX`` or a boz-literal-constant. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + These functions return a ``INTEGER`` variable or array under + the following rules: + + Standard: + Fortran 77 and later, with boz-literal-constant Fortran 2008 and later. + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = INT(A [, KIND)) + + Example: + .. code-block:: fortran + + program test_int + integer :: i = 42 + complex :: z = (-3.7, 1.0) + print *, int(i) + print *, int(z), int(z,8) + end program + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``INT(A)`` + - ``REAL(4) A`` + - ``INTEGER`` + - Fortran 77 and later + * - ``IFIX(A)`` + - ``REAL(4) A`` + - ``INTEGER`` + - Fortran 77 and later + * - ``IDINT(A)`` + - ``REAL(8) A`` + - ``INTEGER`` + - Fortran 77 and later \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/int2.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/int2.rst new file mode 100644 index 00000000000..e650dd18b4a --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/int2.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: INT2, conversion, to integer + +.. _int2: + +INT2 --- Convert to 16-bit integer type +*************************************** + +.. function:: INT2(A) + + Convert to a ``KIND=2`` integer type. This is equivalent to the + standard ``INT`` intrinsic with an optional argument of + ``KIND=2``, and is only included for backwards compatibility. + + :param A: + Shall be of type ``INTEGER``, + ``REAL``, or ``COMPLEX``. + + :return: + The return value is a ``INTEGER(2)`` variable. + + Standard: + GNU extension + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = INT2(A) + + See also: + :ref:`INT`, + :ref:`INT8` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/int8.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/int8.rst new file mode 100644 index 00000000000..cb061a5e1e8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/int8.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: INT8, conversion, to integer + +.. _int8: + +INT8 --- Convert to 64-bit integer type +*************************************** + +.. function:: INT8(A) + + Convert to a ``KIND=8`` integer type. This is equivalent to the + standard ``INT`` intrinsic with an optional argument of + ``KIND=8``, and is only included for backwards compatibility. + + :param A: + Shall be of type ``INTEGER``, + ``REAL``, or ``COMPLEX``. + + :return: + The return value is a ``INTEGER(8)`` variable. + + Standard: + GNU extension + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = INT8(A) + + See also: + :ref:`INT`, + :ref:`INT2` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/introduction-to-intrinsic-procedures.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/introduction-to-intrinsic-procedures.rst new file mode 100644 index 00000000000..926e1b223e3 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/introduction-to-intrinsic-procedures.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _introduction-to-intrinsics: + +Introduction to intrinsic procedures +************************************ + +The intrinsic procedures provided by GNU Fortran include procedures required +by the Fortran 95 and later supported standards, and a set of intrinsic +procedures for backwards compatibility with G77. Any conflict between +a description here and a description in the Fortran standards is +unintentional, and the standard(s) should be considered authoritative. + +The enumeration of the ``KIND`` type parameter is processor defined in +the Fortran 95 standard. GNU Fortran defines the default integer type and +default real type by ``INTEGER(KIND=4)`` and ``REAL(KIND=4)``, +respectively. The standard mandates that both data types shall have +another kind, which have more precision. On typical target architectures +supported by :command:`gfortran`, this kind type parameter is ``KIND=8``. +Hence, ``REAL(KIND=8)`` and ``DOUBLE PRECISION`` are equivalent. +In the description of generic intrinsic procedures, the kind type parameter +will be specified by ``KIND=*``, and in the description of specific +names for an intrinsic procedure the kind type parameter will be explicitly +given (e.g., ``REAL(KIND=4)`` or ``REAL(KIND=8)``). Finally, for +brevity the optional ``KIND=`` syntax will be omitted. + +Many of the intrinsic procedures take one or more optional arguments. +This document follows the convention used in the Fortran 95 standard, +and denotes such arguments by square brackets. + +GNU Fortran offers the :option:`-std=` command-line option, +which can be used to restrict the set of intrinsic procedures to a +given standard. By default, :command:`gfortran` sets the :option:`-std=gnu` +option, and so all intrinsic procedures described here are accepted. There +is one caveat. For a select group of intrinsic procedures, :command:`g77` +implemented both a function and a subroutine. Both classes +have been implemented in :command:`gfortran` for backwards compatibility +with :command:`g77`. It is noted here that these functions and subroutines +cannot be intermixed in a given subprogram. In the descriptions that follow, +the applicable standard for each intrinsic procedure is noted. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ior.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ior.rst new file mode 100644 index 00000000000..f2106888476 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ior.rst @@ -0,0 +1,91 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ior: + +.. index:: IOR + +.. index:: BIOR + +.. index:: IIOR + +.. index:: JIOR + +.. index:: KIOR + +.. index:: bitwise logical or + +.. index:: logical or, bitwise + +IOR --- Bitwise logical or +************************** + +.. function:: IOR() + + ``IOR`` returns the bitwise Boolean inclusive-OR of :samp:`{I}` and + :samp:`{J}`. + + :param I: + The type shall be ``INTEGER`` or a boz-literal-constant. + + :param J: + The type shall be ``INTEGER`` with the same + kind type parameter as :samp:`{I}` or a boz-literal-constant. + :samp:`{I}` and :samp:`{J}` shall not both be boz-literal-constants. + + :return: + The return type is ``INTEGER`` with the kind type parameter of the + arguments. + A boz-literal-constant is converted to an ``INTEGER`` with the kind + type parameter of the other argument as-if a call to :ref:`INT` occurred. + + Standard: + Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = IOR(I, J) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``IOR(A)`` + - ``INTEGER A`` + - ``INTEGER`` + - Fortran 90 and later + * - ``BIOR(A)`` + - ``INTEGER(1) A`` + - ``INTEGER(1)`` + - GNU extension + * - ``IIOR(A)`` + - ``INTEGER(2) A`` + - ``INTEGER(2)`` + - GNU extension + * - ``JIOR(A)`` + - ``INTEGER(4) A`` + - ``INTEGER(4)`` + - GNU extension + * - ``KIOR(A)`` + - ``INTEGER(8) A`` + - ``INTEGER(8)`` + - GNU extension + + See also: + :ref:`IEOR`, + :ref:`IAND`, + :ref:`IBITS`, + :ref:`IBSET`, + :ref:`IBCLR`, + :ref:`NOT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/iparity.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/iparity.rst new file mode 100644 index 00000000000..5abd4e1e77e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/iparity.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: IPARITY, array, parity, array, XOR, bits, XOR of array elements + +.. _iparity: + +IPARITY --- Bitwise XOR of array elements +***************************************** + +.. function:: IPARITY(ARRAY, DIM, MASK) + + Reduces with bitwise XOR (exclusive or) the elements of :samp:`{ARRAY}` along + dimension :samp:`{DIM}` if the corresponding element in :samp:`{MASK}` is ``TRUE``. + + :param ARRAY: + Shall be an array of type ``INTEGER`` + + :param DIM: + (Optional) shall be a scalar of type + ``INTEGER`` with a value in the range from 1 to n, where n + equals the rank of :samp:`{ARRAY}`. + + :param MASK: + (Optional) shall be of type ``LOGICAL`` + and either be a scalar or an array of the same shape as :samp:`{ARRAY}`. + + :return: + The result is of the same type as :samp:`{ARRAY}`. + + Standard: + Fortran 2008 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = IPARITY(ARRAY[, MASK]) + RESULT = IPARITY(ARRAY, DIM[, MASK]) + + Example: + .. code-block:: fortran + + PROGRAM test_iparity + INTEGER(1) :: a(2) + + a(1) = int(b'00100100', 1) + a(2) = int(b'01101010', 1) + + ! prints 01001110 + PRINT '(b8.8)', IPARITY(a) + END PROGRAM + + See also: + :ref:`IANY`, + :ref:`IALL`, + :ref:`IEOR`, + :ref:`PARITY` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/irand.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/irand.rst new file mode 100644 index 00000000000..b7b0a6924ce --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/irand.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: IRAND, random number generation + +.. _irand: + +IRAND --- Integer pseudo-random number +************************************** + +.. function:: IRAND(FLAG) + + ``IRAND(FLAG)`` returns a pseudo-random number from a uniform + distribution between 0 and a system-dependent limit (which is in most + cases 2147483647). If :samp:`{FLAG}` is 0, the next number + in the current sequence is returned; if :samp:`{FLAG}` is 1, the generator + is restarted by ``CALL SRAND(0)`` ; if :samp:`{FLAG}` has any other value, + it is used as a new seed with ``SRAND``. + + :param I: + Shall be a scalar ``INTEGER`` of kind 4. + + :return: + The return value is of ``INTEGER(kind=4)`` type. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = IRAND(I) + + Example: + .. code-block:: fortran + + program test_irand + integer,parameter :: seed = 86456 + + call srand(seed) + print *, irand(), irand(), irand(), irand() + print *, irand(seed), irand(), irand(), irand() + end program test_irand \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/isatty.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/isatty.rst new file mode 100644 index 00000000000..6b0ef210e0f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/isatty.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ISATTY, system, terminal + +.. _isatty: + +ISATTY --- Whether a unit is a terminal device +********************************************** + +.. function:: ISATTY(UNIT) + + Determine whether a unit is connected to a terminal device. + + :param UNIT: + Shall be a scalar ``INTEGER``. + + :return: + Returns ``.TRUE.`` if the :samp:`{UNIT}` is connected to a terminal + device, ``.FALSE.`` otherwise. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = ISATTY(UNIT) + + Example: + .. code-block:: fortran + + PROGRAM test_isatty + INTEGER(kind=1) :: unit + DO unit = 1, 10 + write(*,*) isatty(unit=unit) + END DO + END PROGRAM + + See also: + :ref:`TTYNAM` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/iscontiguous.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/iscontiguous.rst new file mode 100644 index 00000000000..b7d84eee01b --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/iscontiguous.rst @@ -0,0 +1,52 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _is_contiguous: + +IS_CONTIGUOUS --- Test whether an array is contiguous +***************************************************** + +.. index:: IS_IOSTAT_EOR, array, contiguity + +.. function:: IS_CONTIGUOUS(ARRAY) + + ``IS_CONTIGUOUS`` tests whether an array is contiguous. + + :param ARRAY: + Shall be an array of any type. + + :return: + Returns a ``LOGICAL`` of the default kind, which ``.TRUE.`` if + :samp:`{ARRAY}` is contiguous and false otherwise. + + Standard: + Fortran 2008 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = IS_CONTIGUOUS(ARRAY) + + Example: + .. code-block:: fortran + + program test + integer :: a(10) + a = [1,2,3,4,5,6,7,8,9,10] + call sub (a) ! every element, is contiguous + call sub (a(::2)) ! every other element, is noncontiguous + contains + subroutine sub (x) + integer :: x(:) + if (is_contiguous (x)) then + write (*,*) 'X is contiguous' + else + write (*,*) 'X is not contiguous' + end if + end subroutine sub + end program test \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ishft.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ishft.rst new file mode 100644 index 00000000000..c5427f2dd0c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ishft.rst @@ -0,0 +1,85 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ishft: + +.. index:: ISHFT + +.. index:: BSHFT + +.. index:: IISHFT + +.. index:: JISHFT + +.. index:: KISHFT + +.. index:: bits, shift + +ISHFT --- Shift bits +******************** + +.. function:: ISHFT() + + ``ISHFT`` returns a value corresponding to :samp:`{I}` with all of the + bits shifted :samp:`{SHIFT}` places. A value of :samp:`{SHIFT}` greater than + zero corresponds to a left shift, a value of zero corresponds to no + shift, and a value less than zero corresponds to a right shift. If the + absolute value of :samp:`{SHIFT}` is greater than ``BIT_SIZE(I)``, the + value is undefined. Bits shifted out from the left end or right end are + lost; zeros are shifted in from the opposite end. + + :param I: + The type shall be ``INTEGER``. + + :param SHIFT: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` and of the same kind as + :samp:`{I}`. + + Standard: + Fortran 90 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ISHFT(I, SHIFT) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ISHFT(A)`` + - ``INTEGER A`` + - ``INTEGER`` + - Fortran 90 and later + * - ``BSHFT(A)`` + - ``INTEGER(1) A`` + - ``INTEGER(1)`` + - GNU extension + * - ``IISHFT(A)`` + - ``INTEGER(2) A`` + - ``INTEGER(2)`` + - GNU extension + * - ``JISHFT(A)`` + - ``INTEGER(4) A`` + - ``INTEGER(4)`` + - GNU extension + * - ``KISHFT(A)`` + - ``INTEGER(8) A`` + - ``INTEGER(8)`` + - GNU extension + + See also: + :ref:`ISHFTC` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ishftc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ishftc.rst new file mode 100644 index 00000000000..f3e1545a3ea --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ishftc.rst @@ -0,0 +1,91 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ishftc: + +.. index:: ISHFTC + +.. index:: BSHFTC + +.. index:: IISHFTC + +.. index:: JISHFTC + +.. index:: KISHFTC + +.. index:: bits, shift circular + +ISHFTC --- Shift bits circularly +******************************** + +.. function:: ISHFTC() + + ``ISHFTC`` returns a value corresponding to :samp:`{I}` with the + rightmost :samp:`{SIZE}` bits shifted circularly :samp:`{SHIFT}` places; that + is, bits shifted out one end are shifted into the opposite end. A value + of :samp:`{SHIFT}` greater than zero corresponds to a left shift, a value of + zero corresponds to no shift, and a value less than zero corresponds to + a right shift. The absolute value of :samp:`{SHIFT}` must be less than + :samp:`{SIZE}`. If the :samp:`{SIZE}` argument is omitted, it is taken to be + equivalent to ``BIT_SIZE(I)``. + + :param I: + The type shall be ``INTEGER``. + + :param SHIFT: + The type shall be ``INTEGER``. + + :param SIZE: + (Optional) The type shall be ``INTEGER`` ; + the value must be greater than zero and less than or equal to + ``BIT_SIZE(I)``. + + :return: + The return value is of type ``INTEGER`` and of the same kind as + :samp:`{I}`. + + Standard: + Fortran 90 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = ISHFTC(I, SHIFT [, SIZE]) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ISHFTC(A)`` + - ``INTEGER A`` + - ``INTEGER`` + - Fortran 90 and later + * - ``BSHFTC(A)`` + - ``INTEGER(1) A`` + - ``INTEGER(1)`` + - GNU extension + * - ``IISHFTC(A)`` + - ``INTEGER(2) A`` + - ``INTEGER(2)`` + - GNU extension + * - ``JISHFTC(A)`` + - ``INTEGER(4) A`` + - ``INTEGER(4)`` + - GNU extension + * - ``KISHFTC(A)`` + - ``INTEGER(8) A`` + - ``INTEGER(8)`` + - GNU extension + + See also: + :ref:`ISHFT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/isiostatend.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/isiostatend.rst new file mode 100644 index 00000000000..5efd23239e3 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/isiostatend.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _is_iostat_end: + +IS_IOSTAT_END --- Test for end-of-file value +******************************************** + +.. index:: IS_IOSTAT_END, IOSTAT, end of file + +.. function:: IS_IOSTAT_END(I) + + ``IS_IOSTAT_END`` tests whether an variable has the value of the I/O + status 'end of file'. The function is equivalent to comparing the variable + with the ``IOSTAT_END`` parameter of the intrinsic module + ``ISO_FORTRAN_ENV``. + + :param I: + Shall be of the type ``INTEGER``. + + :return: + Returns a ``LOGICAL`` of the default kind, which ``.TRUE.`` if + :samp:`{I}` has the value which indicates an end of file condition for + ``IOSTAT=`` specifiers, and is ``.FALSE.`` otherwise. + + Standard: + Fortran 2003 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = IS_IOSTAT_END(I) + + Example: + .. code-block:: fortran + + PROGRAM iostat + IMPLICIT NONE + INTEGER :: stat, i + OPEN(88, FILE='test.dat') + READ(88, *, IOSTAT=stat) i + IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE' + END PROGRAM \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/isiostateor.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/isiostateor.rst new file mode 100644 index 00000000000..bafc67fbe9e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/isiostateor.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _is_iostat_eor: + +IS_IOSTAT_EOR --- Test for end-of-record value +********************************************** + +.. index:: IS_IOSTAT_EOR, IOSTAT, end of record + +.. function:: IS_IOSTAT_EOR(I) + + ``IS_IOSTAT_EOR`` tests whether an variable has the value of the I/O + status 'end of record'. The function is equivalent to comparing the + variable with the ``IOSTAT_EOR`` parameter of the intrinsic module + ``ISO_FORTRAN_ENV``. + + :param I: + Shall be of the type ``INTEGER``. + + :return: + Returns a ``LOGICAL`` of the default kind, which ``.TRUE.`` if + :samp:`{I}` has the value which indicates an end of file condition for + ``IOSTAT=`` specifiers, and is ``.FALSE.`` otherwise. + + Standard: + Fortran 2003 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = IS_IOSTAT_EOR(I) + + Example: + .. code-block:: fortran + + PROGRAM iostat + IMPLICIT NONE + INTEGER :: stat, i(50) + OPEN(88, FILE='test.dat', FORM='UNFORMATTED') + READ(88, IOSTAT=stat) i + IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD' + END PROGRAM \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/isnan.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/isnan.rst new file mode 100644 index 00000000000..312e1dbf035 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/isnan.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _isnan: + +ISNAN --- Test for a NaN +************************ + +.. index:: ISNAN, IEEE, ISNAN + +.. function:: ISNAN(X) + + ``ISNAN`` tests whether a floating-point value is an IEEE + Not-a-Number (NaN). + + :param X: + Variable of the type ``REAL``. + + :return: + Returns a default-kind ``LOGICAL``. The returned value is ``TRUE`` + if :samp:`{X}` is a NaN and ``FALSE`` otherwise. + + Standard: + GNU extension + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + ISNAN(X) + + Example: + .. code-block:: fortran + + program test_nan + implicit none + real :: x + x = -1.0 + x = sqrt(x) + if (isnan(x)) stop '"x" is a NaN' + end program test_nan \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/itime.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/itime.rst new file mode 100644 index 00000000000..4fb25b22f2c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/itime.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: ITIME, time, current, current time + +.. _itime: + +ITIME --- Get current local time subroutine (hour/minutes/seconds) +******************************************************************* + +.. function:: ITIME(VALUES) + + ``ITIME(VALUES)`` Fills :samp:`{VALUES}` with the numerical values at the + current local time. The hour (in the range 1-24), minute (in the range 1-60), + and seconds (in the range 1-60) appear in elements 1, 2, and 3 of :samp:`{VALUES}`, + respectively. + + :param VALUES: + The type shall be ``INTEGER, DIMENSION(3)`` + and the kind shall be the default integer kind. + + :return: + Does not return anything. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL ITIME(VALUES) + + Example: + .. code-block:: fortran + + program test_itime + integer, dimension(3) :: tarray + call itime(tarray) + print *, tarray(1) + print *, tarray(2) + print *, tarray(3) + end program test_itime + + See also: + :ref:`DATE_AND_TIME` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/kill.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/kill.rst new file mode 100644 index 00000000000..9ffa4caf00c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/kill.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: KILL + +.. _kill: + +KILL --- Send a signal to a process +*********************************** + +.. function:: KILL(PID, SIG) + + Sends the signal specified by :samp:`{SIG}` to the process :samp:`{PID}`. + See ``kill(2)``. + + :param PID: + Shall be a scalar ``INTEGER`` with ``INTENT(IN)``. + + :param SIG: + Shall be a scalar ``INTEGER`` with ``INTENT(IN)``. + + :param STATUS: + [Subroutine](Optional) + Shall be a scalar ``INTEGER``. + Returns 0 on success; otherwise a system-specific error code is returned. + + :param STATUS: + [Function] The kind type parameter is that of + ``pid``. + Returns 0 on success; otherwise a system-specific error code is returned. + + Standard: + GNU extension + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL KILL(PID, SIG [, STATUS]) + STATUS = KILL(PID, SIG) + + See also: + :ref:`ABORT`, + :ref:`EXIT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/kind.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/kind.rst new file mode 100644 index 00000000000..594ce105a79 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/kind.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: KIND, kind + +.. _kind: + +KIND --- Kind of an entity +************************** + +.. function:: KIND(X) + + ``KIND(X)`` returns the kind value of the entity :samp:`{X}`. + + :param X: + Shall be of type ``LOGICAL``, ``INTEGER``, + ``REAL``, ``COMPLEX`` or ``CHARACTER``. It may be scalar or + array valued. + + :return: + The return value is a scalar of type ``INTEGER`` and of the default + integer kind. + + Standard: + Fortran 95 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + K = KIND(X) + + Example: + .. code-block:: fortran + + program test_kind + integer,parameter :: kc = kind(' ') + integer,parameter :: kl = kind(.true.) + + print *, "The default character kind is ", kc + print *, "The default logical kind is ", kl + end program test_kind \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/lbound.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/lbound.rst new file mode 100644 index 00000000000..d07e972c9b5 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/lbound.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: LBOUND, array, lower bound + +.. _lbound: + +LBOUND --- Lower dimension bounds of an array +********************************************* + +.. function:: LBOUND(ARRAY , DIM , KIND) + + Returns the lower bounds of an array, or a single lower bound + along the :samp:`{DIM}` dimension. + + :param ARRAY: + Shall be an array, of any type. + + :param DIM: + (Optional) Shall be a scalar ``INTEGER``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + If :samp:`{DIM}` is absent, the result is an array of the lower bounds of + :samp:`{ARRAY}`. If :samp:`{DIM}` is present, the result is a scalar + corresponding to the lower bound of the array along that dimension. If + :samp:`{ARRAY}` is an expression rather than a whole array or array + structure component, or if it has a zero extent along the relevant + dimension, the lower bound is taken to be 1. + + Standard: + Fortran 90 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = LBOUND(ARRAY [, DIM [, KIND]]) + + See also: + :ref:`UBOUND`, + :ref:`LCOBOUND` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/lcobound.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/lcobound.rst new file mode 100644 index 00000000000..eb998163d86 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/lcobound.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: LCOBOUND, coarray, lower bound + +.. _lcobound: + +LCOBOUND --- Lower codimension bounds of an array +************************************************* + +.. function:: LCOBOUND(COARRAY , DIM , KIND) + + Returns the lower bounds of a coarray, or a single lower cobound + along the :samp:`{DIM}` codimension. + + :param ARRAY: + Shall be an coarray, of any type. + + :param DIM: + (Optional) Shall be a scalar ``INTEGER``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + If :samp:`{DIM}` is absent, the result is an array of the lower cobounds of + :samp:`{COARRAY}`. If :samp:`{DIM}` is present, the result is a scalar + corresponding to the lower cobound of the array along that codimension. + + Standard: + Fortran 2008 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = LCOBOUND(COARRAY [, DIM [, KIND]]) + + See also: + :ref:`UCOBOUND`, + :ref:`LBOUND` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/leadz.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/leadz.rst new file mode 100644 index 00000000000..327cf8958c5 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/leadz.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _leadz: + +LEADZ --- Number of leading zero bits of an integer +*************************************************** + +.. index:: LEADZ, zero bits + +.. function:: LEADZ(I) + + ``LEADZ`` returns the number of leading zero bits of an integer. + + :param I: + Shall be of type ``INTEGER``. + + :return: + The type of the return value is the default ``INTEGER``. + If all the bits of ``I`` are zero, the result value is ``BIT_SIZE(I)``. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = LEADZ(I) + + Example: + .. code-block:: fortran + + PROGRAM test_leadz + WRITE (*,*) BIT_SIZE(1) ! prints 32 + WRITE (*,*) LEADZ(1) ! prints 31 + END PROGRAM + + See also: + :ref:`BIT_SIZE`, + :ref:`TRAILZ`, + :ref:`POPCNT`, + :ref:`POPPAR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/len.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/len.rst new file mode 100644 index 00000000000..433659ce9cf --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/len.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _len: + +.. index:: LEN + +.. index:: string, length + +LEN --- Length of a character entity +************************************ + +.. function:: LEN(STRING , KIND) + + Returns the length of a character string. If :samp:`{STRING}` is an array, + the length of an element of :samp:`{STRING}` is returned. Note that + :samp:`{STRING}` need not be defined when this intrinsic is invoked, since + only the length, not the content, of :samp:`{STRING}` is needed. + + :param STRING: + Shall be a scalar or array of type + ``CHARACTER``, with ``INTENT(IN)`` + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + + Standard: + Fortran 77 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + L = LEN(STRING [, KIND]) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``LEN(STRING)`` + - ``CHARACTER`` + - ``INTEGER`` + - Fortran 77 and later + + See also: + :ref:`LEN_TRIM`, + :ref:`ADJUSTL`, + :ref:`ADJUSTR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/lentrim.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/lentrim.rst new file mode 100644 index 00000000000..51c8e3aa73b --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/lentrim.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: LEN_TRIM, string, length, without trailing whitespace + +.. _len_trim: + +LEN_TRIM --- Length of a character entity without trailing blank characters +*************************************************************************** + +.. function:: LEN_TRIM(STRING , KIND) + + Returns the length of a character string, ignoring any trailing blanks. + + :param STRING: + Shall be a scalar of type ``CHARACTER``, + with ``INTENT(IN)`` + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + + Standard: + Fortran 90 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = LEN_TRIM(STRING [, KIND]) + + See also: + :ref:`LEN`, + :ref:`ADJUSTL`, + :ref:`ADJUSTR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/lge.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/lge.rst new file mode 100644 index 00000000000..f56ae88098b --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/lge.rst @@ -0,0 +1,63 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _lge: + +.. index:: LGE + +.. index:: lexical comparison of strings + +.. index:: string, comparison + +LGE --- Lexical greater than or equal +************************************* + +.. function:: LGE(STRING_A, STRING_B) + + Determines whether one string is lexically greater than or equal to + another string, where the two strings are interpreted as containing + ASCII character codes. If the String A and String B are not the same + length, the shorter is compared as if spaces were appended to it to form + a value that has the same length as the longer. + + :param STRING_A: + Shall be of default ``CHARACTER`` type. + + :param STRING_B: + Shall be of default ``CHARACTER`` type. + + :return: + Returns ``.TRUE.`` if ``STRING_A >= STRING_B``, and ``.FALSE.`` + otherwise, based on the ASCII ordering. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = LGE(STRING_A, STRING_B) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``LGE(STRING_A,STRING_B)`` + - ``CHARACTER`` + - ``LOGICAL`` + - Fortran 77 and later + + See also: + :ref:`LGT`, + :ref:`LLE`, + :ref:`LLT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/lgt.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/lgt.rst new file mode 100644 index 00000000000..06d70c768eb --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/lgt.rst @@ -0,0 +1,63 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _lgt: + +.. index:: LGT + +.. index:: lexical comparison of strings + +.. index:: string, comparison + +LGT --- Lexical greater than +**************************** + +.. function:: LGT(STRING_A, STRING_B) + + Determines whether one string is lexically greater than another string, + where the two strings are interpreted as containing ASCII character + codes. If the String A and String B are not the same length, the + shorter is compared as if spaces were appended to it to form a value + that has the same length as the longer. + + :param STRING_A: + Shall be of default ``CHARACTER`` type. + + :param STRING_B: + Shall be of default ``CHARACTER`` type. + + :return: + Returns ``.TRUE.`` if ``STRING_A > STRING_B``, and ``.FALSE.`` + otherwise, based on the ASCII ordering. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = LGT(STRING_A, STRING_B) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``LGT(STRING_A,STRING_B)`` + - ``CHARACTER`` + - ``LOGICAL`` + - Fortran 77 and later + + See also: + :ref:`LGE`, + :ref:`LLE`, + :ref:`LLT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/link.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/link.rst new file mode 100644 index 00000000000..e24cf2e632b --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/link.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: LINK, file system, create link, file system, hard link + +.. _link: + +LINK --- Create a hard link +*************************** + +.. function:: LINK(PATH1, PATH2) + + Makes a (hard) link from file :samp:`{PATH1}` to :samp:`{PATH2}`. A null + character (``CHAR(0)``) can be used to mark the end of the names in + :samp:`{PATH1}` and :samp:`{PATH2}` ; otherwise, trailing blanks in the file + names are ignored. If the :samp:`{STATUS}` argument is supplied, it + contains 0 on success or a nonzero error code upon return; see + ``link(2)``. + + :param PATH1: + Shall be of default ``CHARACTER`` type. + + :param PATH2: + Shall be of default ``CHARACTER`` type. + + :param STATUS: + (Optional) Shall be of default ``INTEGER`` type. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL LINK(PATH1, PATH2 [, STATUS]) + STATUS = LINK(PATH1, PATH2) + + See also: + :ref:`SYMLNK`, + :ref:`UNLINK` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/lle.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/lle.rst new file mode 100644 index 00000000000..f256bcc868c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/lle.rst @@ -0,0 +1,63 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _lle: + +.. index:: LLE + +.. index:: lexical comparison of strings + +.. index:: string, comparison + +LLE --- Lexical less than or equal +********************************** + +.. function:: LLE(STRING_A, STRING_B) + + Determines whether one string is lexically less than or equal to another + string, where the two strings are interpreted as containing ASCII + character codes. If the String A and String B are not the same length, + the shorter is compared as if spaces were appended to it to form a value + that has the same length as the longer. + + :param STRING_A: + Shall be of default ``CHARACTER`` type. + + :param STRING_B: + Shall be of default ``CHARACTER`` type. + + :return: + Returns ``.TRUE.`` if ``STRING_A <= STRING_B``, and ``.FALSE.`` + otherwise, based on the ASCII ordering. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = LLE(STRING_A, STRING_B) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``LLE(STRING_A,STRING_B)`` + - ``CHARACTER`` + - ``LOGICAL`` + - Fortran 77 and later + + See also: + :ref:`LGE`, + :ref:`LGT`, + :ref:`LLT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/llt.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/llt.rst new file mode 100644 index 00000000000..b7f18515f93 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/llt.rst @@ -0,0 +1,63 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _llt: + +.. index:: LLT + +.. index:: lexical comparison of strings + +.. index:: string, comparison + +LLT --- Lexical less than +************************* + +.. function:: LLT(STRING_A, STRING_B) + + Determines whether one string is lexically less than another string, + where the two strings are interpreted as containing ASCII character + codes. If the String A and String B are not the same length, the + shorter is compared as if spaces were appended to it to form a value + that has the same length as the longer. + + :param STRING_A: + Shall be of default ``CHARACTER`` type. + + :param STRING_B: + Shall be of default ``CHARACTER`` type. + + :return: + Returns ``.TRUE.`` if ``STRING_A < STRING_B``, and ``.FALSE.`` + otherwise, based on the ASCII ordering. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = LLT(STRING_A, STRING_B) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``LLT(STRING_A,STRING_B)`` + - ``CHARACTER`` + - ``LOGICAL`` + - Fortran 77 and later + + See also: + :ref:`LGE`, + :ref:`LGT`, + :ref:`LLE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/lnblnk.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/lnblnk.rst new file mode 100644 index 00000000000..aff68384011 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/lnblnk.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: LNBLNK, string, find non-blank character + +.. _lnblnk: + +LNBLNK --- Index of the last non-blank character in a string +************************************************************ + +.. function:: LNBLNK(STRING) + + Returns the length of a character string, ignoring any trailing blanks. + This is identical to the standard ``LEN_TRIM`` intrinsic, and is only + included for backwards compatibility. + + :param STRING: + Shall be a scalar of type ``CHARACTER``, + with ``INTENT(IN)`` + + :return: + The return value is of ``INTEGER(kind=4)`` type. + + Standard: + GNU extension + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = LNBLNK(STRING) + + See also: + :ref:`index-intrinsic`, + :ref:`LEN_TRIM` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/loc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/loc.rst new file mode 100644 index 00000000000..f503a018d86 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/loc.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: LOC, location of a variable in memory + +.. _loc: + +LOC --- Returns the address of a variable +***************************************** + +.. function:: LOC(X) + + ``LOC(X)`` returns the address of :samp:`{X}` as an integer. + + :param X: + Variable of any type. + + :return: + The return value is of type ``INTEGER``, with a ``KIND`` + corresponding to the size (in bytes) of a memory address on the target + machine. + + Standard: + GNU extension + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = LOC(X) + + Example: + .. code-block:: fortran + + program test_loc + integer :: i + real :: r + i = loc(r) + print *, i + end program test_loc \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/log.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/log.rst new file mode 100644 index 00000000000..dd960ba57ee --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/log.rst @@ -0,0 +1,93 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _log: + +.. index:: LOG + +.. index:: ALOG + +.. index:: DLOG + +.. index:: CLOG + +.. index:: ZLOG + +.. index:: CDLOG + +.. index:: exponential function, inverse + +.. index:: logarithm function + +.. index:: natural logarithm function + +LOG --- Natural logarithm function +********************************** + +.. function:: LOG(X) + + ``LOG(X)`` computes the natural logarithm of :samp:`{X}`, i.e. the + logarithm to the base e. + + :param X: + The type shall be ``REAL`` or + ``COMPLEX``. + + :return: + The return value is of type ``REAL`` or ``COMPLEX``. + The kind type parameter is the same as :samp:`{X}`. + If :samp:`{X}` is ``COMPLEX``, the imaginary part \omega is in the range + -\pi < \omega \leq \pi. + + Standard: + Fortran 77 and later, has GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = LOG(X) + + Example: + .. code-block:: fortran + + program test_log + real(8) :: x = 2.7182818284590451_8 + complex :: z = (1.0, 2.0) + x = log(x) ! will yield (approximately) 1 + z = log(z) + end program test_log + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ALOG(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - Fortran 77 or later + * - ``DLOG(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 77 or later + * - ``CLOG(X)`` + - ``COMPLEX(4) X`` + - ``COMPLEX(4)`` + - Fortran 77 or later + * - ``ZLOG(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension + * - ``CDLOG(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/log10.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/log10.rst new file mode 100644 index 00000000000..7529706da2b --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/log10.rst @@ -0,0 +1,69 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _log10: + +.. index:: LOG10 + +.. index:: ALOG10 + +.. index:: DLOG10 + +.. index:: exponential function, inverse + +.. index:: logarithm function with base 10 + +.. index:: base 10 logarithm function + +LOG10 --- Base 10 logarithm function +************************************ + +.. function:: LOG10(X) + + ``LOG10(X)`` computes the base 10 logarithm of :samp:`{X}`. + + :param X: + The type shall be ``REAL``. + + :return: + The return value is of type ``REAL`` or ``COMPLEX``. + The kind type parameter is the same as :samp:`{X}`. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = LOG10(X) + + Example: + .. code-block:: fortran + + program test_log10 + real(8) :: x = 10.0_8 + x = log10(x) + end program test_log10 + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``ALOG10(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DLOG10(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 77 and later \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/loggamma.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/loggamma.rst new file mode 100644 index 00000000000..e9952bd2b28 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/loggamma.rst @@ -0,0 +1,76 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _log_gamma: + +.. index:: LOG_GAMMA + +.. index:: LGAMMA + +.. index:: ALGAMA + +.. index:: DLGAMA + +.. index:: Gamma function, logarithm of + +LOG_GAMMA --- Logarithm of the Gamma function +********************************************* + +.. function:: LOG_GAMMA(X) + + ``LOG_GAMMA(X)`` computes the natural logarithm of the absolute value + of the Gamma (\Gamma) function. + + :param X: + Shall be of type ``REAL`` and neither zero + nor a negative integer. + + :return: + The return value is of type ``REAL`` of the same kind as :samp:`{X}`. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + X = LOG_GAMMA(X) + + Example: + .. code-block:: fortran + + program test_log_gamma + real :: x = 1.0 + x = lgamma(x) ! returns 0.0 + end program test_log_gamma + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``LGAMMA(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - GNU extension + * - ``ALGAMA(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - GNU extension + * - ``DLGAMA(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension + + See also: + Gamma function: + :ref:`GAMMA` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/logical.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/logical.rst new file mode 100644 index 00000000000..fe3706fa5d5 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/logical.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _logical: + +LOGICAL --- Convert to logical type +*********************************** + +.. index:: LOGICAL, conversion, to logical + +.. function:: LOGICAL(L, KIND) + + Converts one kind of ``LOGICAL`` variable to another. + + :param L: + The type shall be ``LOGICAL``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is a ``LOGICAL`` value equal to :samp:`{L}`, with a + kind corresponding to :samp:`{KIND}`, or of the default logical kind if + :samp:`{KIND}` is not given. + + Standard: + Fortran 90 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = LOGICAL(L [, KIND]) + + See also: + :ref:`INT`, + :ref:`REAL`, + :ref:`CMPLX` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/lshift.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/lshift.rst new file mode 100644 index 00000000000..031e3e1b9c5 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/lshift.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _lshift: + +LSHIFT --- Left shift bits +************************** + +.. index:: LSHIFT, bits, shift left + +.. function:: LSHIFT(I, SHIFT) + + ``LSHIFT`` returns a value corresponding to :samp:`{I}` with all of the + bits shifted left by :samp:`{SHIFT}` places. :samp:`{SHIFT}` shall be + nonnegative and less than or equal to ``BIT_SIZE(I)``, otherwise + the result value is undefined. Bits shifted out from the left end are + lost; zeros are shifted in from the opposite end. + + :param I: + The type shall be ``INTEGER``. + + :param SHIFT: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` and of the same kind as + :samp:`{I}`. + + Standard: + GNU extension + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = LSHIFT(I, SHIFT) + + See also: + :ref:`ISHFT`, + :ref:`ISHFTC`, + :ref:`RSHIFT`, + :ref:`SHIFTA`, + :ref:`SHIFTL`, + :ref:`SHIFTR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/lstat.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/lstat.rst new file mode 100644 index 00000000000..0abd89dc442 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/lstat.rst @@ -0,0 +1,49 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _lstat: + +LSTAT --- Get file status +************************* + +.. index:: LSTAT, file system, file status + +.. function:: LSTAT(NAME, VALUES, STATUS) + + ``LSTAT`` is identical to :ref:`STAT`, except that if path is a + symbolic link, then the link itself is statted, not the file that it + refers to. + + :param NAME: + The type shall be ``CHARACTER`` of the default + kind, a valid path within the file system. + + :param VALUES: + The type shall be ``INTEGER(4), DIMENSION(13)``. + + :param STATUS: + (Optional) status flag of type ``INTEGER(4)``. + Returns 0 on success and a system specific error code otherwise. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL LSTAT(NAME, VALUES [, STATUS]) + STATUS = LSTAT(NAME, VALUES) + + Example: + See :ref:`STAT` for an example. + + See also: + To stat an open file: + :ref:`FSTAT` + To stat a file: + :ref:`STAT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ltime.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ltime.rst new file mode 100644 index 00000000000..d09728e07bb --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ltime.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: LTIME, time, conversion to local time info + +.. _ltime: + +LTIME --- Convert time to local time info +***************************************** + +.. function:: LTIME(TIME, VALUES) + + Given a system time value :samp:`{TIME}` (as provided by the :ref:`TIME` + intrinsic), fills :samp:`{VALUES}` with values extracted from it appropriate + to the local time zone using ``localtime(3)``. + + :param TIME: + An ``INTEGER`` scalar expression + corresponding to a system time, with ``INTENT(IN)``. + + :param VALUES: + A default ``INTEGER`` array with 9 elements, + with ``INTENT(OUT)``. + + :return: + The elements of :samp:`{VALUES}` are assigned as follows: + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL LTIME(TIME, VALUES) + + See also: + :ref:`DATE_AND_TIME`, + :ref:`CTIME`, + :ref:`GMTIME`, + :ref:`TIME`, + :ref:`TIME8` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/malloc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/malloc.rst new file mode 100644 index 00000000000..581ae06d200 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/malloc.rst @@ -0,0 +1,66 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MALLOC, pointer, cray + +.. _malloc: + +MALLOC --- Allocate dynamic memory +********************************** + +.. function:: MALLOC(SIZE) + + ``MALLOC(SIZE)`` allocates :samp:`{SIZE}` bytes of dynamic memory and + returns the address of the allocated memory. The ``MALLOC`` intrinsic + is an extension intended to be used with Cray pointers, and is provided + in GNU Fortran to allow the user to compile legacy code. For new code + using Fortran 95 pointers, the memory allocation intrinsic is + ``ALLOCATE``. + + :param SIZE: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``INTEGER(K)``, with :samp:`{K}` such that + variables of type ``INTEGER(K)`` have the same size as + C pointers (``sizeof(void *)``). + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + PTR = MALLOC(SIZE) + + Example: + The following example demonstrates the use of ``MALLOC`` and + ``FREE`` with Cray pointers. + + .. code-block:: fortran + + program test_malloc + implicit none + integer i + real*8 x(*), z + pointer(ptr_x,x) + + ptr_x = malloc(20*8) + do i = 1, 20 + x(i) = sqrt(1.0d0 / i) + end do + z = 0 + do i = 1, 20 + z = z + x(i) + print *, z + end do + call free(ptr_x) + end program test_malloc + + See also: + :ref:`FREE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/maskl.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/maskl.rst new file mode 100644 index 00000000000..0d0ea90cad5 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/maskl.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _maskl: + +MASKL --- Left justified mask +***************************** + +.. index:: MASKL, mask, left justified + +.. function:: MASKL(I, KIND) + + ``MASKL(I[, KIND])`` has its leftmost :samp:`{I}` bits set to 1, and the + remaining bits set to 0. + + :param I: + Shall be of type ``INTEGER``. + + :param KIND: + Shall be a scalar constant expression of type + ``INTEGER``. + + :return: + The return value is of type ``INTEGER``. If :samp:`{KIND}` is present, it + specifies the kind value of the return type; otherwise, it is of the + default integer kind. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = MASKL(I[, KIND]) + + See also: + :ref:`MASKR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/maskr.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/maskr.rst new file mode 100644 index 00000000000..30f4e37f314 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/maskr.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MASKR, mask, right justified + +.. _maskr: + +MASKR --- Right justified mask +****************************** + +.. function:: MASKR(I, KIND) + + ``MASKL(I[, KIND])`` has its rightmost :samp:`{I}` bits set to 1, and the + remaining bits set to 0. + + :param I: + Shall be of type ``INTEGER``. + + :param KIND: + Shall be a scalar constant expression of type + ``INTEGER``. + + :return: + The return value is of type ``INTEGER``. If :samp:`{KIND}` is present, it + specifies the kind value of the return type; otherwise, it is of the + default integer kind. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = MASKR(I[, KIND]) + + See also: + :ref:`MASKL` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/matmul.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/matmul.rst new file mode 100644 index 00000000000..81884929a1a --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/matmul.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MATMUL, matrix multiplication, product, matrix + +.. _matmul: + +MATMUL --- matrix multiplication +******************************** + +.. function:: MATMUL(MATRIX_A, MATRIX_B) + + Performs a matrix multiplication on numeric or logical arguments. + + :param MATRIX_A: + An array of ``INTEGER``, + ``REAL``, ``COMPLEX``, or ``LOGICAL`` type, with a rank of + one or two. + + :param MATRIX_B: + An array of ``INTEGER``, + ``REAL``, or ``COMPLEX`` type if :samp:`{MATRIX_A}` is of a numeric + type; otherwise, an array of ``LOGICAL`` type. The rank shall be one + or two, and the first (or only) dimension of :samp:`{MATRIX_B}` shall be + equal to the last (or only) dimension of :samp:`{MATRIX_A}`. + :samp:`{MATRIX_A}` and :samp:`{MATRIX_B}` shall not both be rank one arrays. + + :return: + The matrix product of :samp:`{MATRIX_A}` and :samp:`{MATRIX_B}`. The type and + kind of the result follow the usual type and kind promotion rules, as + for the ``*`` or ``.AND.`` operators. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = MATMUL(MATRIX_A, MATRIX_B) \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/max.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/max.rst new file mode 100644 index 00000000000..7c6179ab548 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/max.rst @@ -0,0 +1,86 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _max: + +.. index:: MAX + +.. index:: MAX0 + +.. index:: AMAX0 + +.. index:: MAX1 + +.. index:: AMAX1 + +.. index:: DMAX1 + +.. index:: maximum value + +MAX --- Maximum value of an argument list +***************************************** + +.. function:: MAX(A1, A2 , A3 , ...) + + Returns the argument with the largest (most positive) value. + + :param A1: + The type shall be ``INTEGER`` or + ``REAL``. + + :param A2}, {A3}, ...: + An expression of the same type and kind + as :samp:`{A1}`. (As a GNU extension, arguments of different kinds are + permitted.) + + :return: + The return value corresponds to the maximum value among the arguments, + and has the same type and kind as the first argument. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = MAX(A1, A2 [, A3 [, ...]]) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``MAX0(A1)`` + - ``INTEGER(4) A1`` + - ``INTEGER(4)`` + - Fortran 77 and later + * - ``AMAX0(A1)`` + - ``INTEGER(4) A1`` + - ``REAL(MAX(X))`` + - Fortran 77 and later + * - ``MAX1(A1)`` + - ``REAL A1`` + - ``INT(MAX(X))`` + - Fortran 77 and later + * - ``AMAX1(A1)`` + - ``REAL(4) A1`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DMAX1(A1)`` + - ``REAL(8) A1`` + - ``REAL(8)`` + - Fortran 77 and later + + See also: + :ref:`MAXLOC` + :ref:`MAXVAL`, + :ref:`MIN` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/maxexponent.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/maxexponent.rst new file mode 100644 index 00000000000..8d42d60f6f3 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/maxexponent.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MAXEXPONENT, model representation, maximum exponent + +.. _maxexponent: + +MAXEXPONENT --- Maximum exponent of a real kind +*********************************************** + +.. function:: MAXEXPONENT(X) + + ``MAXEXPONENT(X)`` returns the maximum exponent in the model of the + type of ``X``. + + :param X: + Shall be of type ``REAL``. + + :return: + The return value is of type ``INTEGER`` and of the default integer + kind. + + Standard: + Fortran 90 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = MAXEXPONENT(X) + + Example: + .. code-block:: fortran + + program exponents + real(kind=4) :: x + real(kind=8) :: y + + print *, minexponent(x), maxexponent(x) + print *, minexponent(y), maxexponent(y) + end program exponents \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/maxloc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/maxloc.rst new file mode 100644 index 00000000000..2e3d2adf5de --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/maxloc.rst @@ -0,0 +1,76 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MAXLOC, array, location of maximum element + +.. _maxloc: + +MAXLOC --- Location of the maximum value within an array +******************************************************** + +.. function:: MAXLOC(ARRAY , MASK ,KIND ,BACK) + + Determines the location of the element in the array with the maximum + value, or, if the :samp:`{DIM}` argument is supplied, determines the + locations of the maximum element along each row of the array in the + :samp:`{DIM}` direction. If :samp:`{MASK}` is present, only the elements for + which :samp:`{MASK}` is ``.TRUE.`` are considered. If more than one + element in the array has the maximum value, the location returned is + that of the first such element in array element order if the + :samp:`{BACK}` is not present, or is false; if :samp:`{BACK}` is true, the location + returned is that of the last such element. If the array has zero + size, or all of the elements of :samp:`{MASK}` are ``.FALSE.``, then + the result is an array of zeroes. Similarly, if :samp:`{DIM}` is supplied + and all of the elements of :samp:`{MASK}` along a given row are zero, the + result value for that row is zero. + + :param ARRAY: + Shall be an array of type ``INTEGER`` or + ``REAL``. + + :param DIM: + (Optional) Shall be a scalar of type + ``INTEGER``, with a value between one and the rank of :samp:`{ARRAY}`, + inclusive. It may not be an optional dummy argument. + + :param MASK: + Shall be of type ``LOGICAL``, + and conformable with :samp:`{ARRAY}`. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :param BACK: + (Optional) A scalar of type ``LOGICAL``. + + :return: + If :samp:`{DIM}` is absent, the result is a rank-one array with a length + equal to the rank of :samp:`{ARRAY}`. If :samp:`{DIM}` is present, the result + is an array with a rank one less than the rank of :samp:`{ARRAY}`, and a + size corresponding to the size of :samp:`{ARRAY}` with the :samp:`{DIM}` + dimension removed. If :samp:`{DIM}` is present and :samp:`{ARRAY}` has a rank + of one, the result is a scalar. If the optional argument :samp:`{KIND}` + is present, the result is an integer of kind :samp:`{KIND}`, otherwise it + is of default kind. + + Standard: + Fortran 95 and later; :samp:`{ARRAY}` of ``CHARACTER`` and the + :samp:`{KIND}` argument are available in Fortran 2003 and later. + The :samp:`{BACK}` argument is available in Fortran 2008 and later. + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = MAXLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK]) + RESULT = MAXLOC(ARRAY [, MASK] [,KIND] [,BACK]) + + See also: + :ref:`FINDLOC`, + :ref:`MAX`, + :ref:`MAXVAL` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/maxval.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/maxval.rst new file mode 100644 index 00000000000..9b3dcc50403 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/maxval.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MAXVAL, array, maximum value, maximum value + +.. _maxval: + +MAXVAL --- Maximum value of an array +************************************ + +.. function:: MAXVAL(ARRAY , MASK) + + Determines the maximum value of the elements in an array value, or, if + the :samp:`{DIM}` argument is supplied, determines the maximum value along + each row of the array in the :samp:`{DIM}` direction. If :samp:`{MASK}` is + present, only the elements for which :samp:`{MASK}` is ``.TRUE.`` are + considered. If the array has zero size, or all of the elements of + :samp:`{MASK}` are ``.FALSE.``, then the result is ``-HUGE(ARRAY)`` + if :samp:`{ARRAY}` is numeric, or a string of nulls if :samp:`{ARRAY}` is of character + type. + + :param ARRAY: + Shall be an array of type ``INTEGER`` or + ``REAL``. + + :param DIM: + (Optional) Shall be a scalar of type + ``INTEGER``, with a value between one and the rank of :samp:`{ARRAY}`, + inclusive. It may not be an optional dummy argument. + + :param MASK: + (Optional) Shall be of type ``LOGICAL``, + and conformable with :samp:`{ARRAY}`. + + :return: + If :samp:`{DIM}` is absent, or if :samp:`{ARRAY}` has a rank of one, the result + is a scalar. If :samp:`{DIM}` is present, the result is an array with a + rank one less than the rank of :samp:`{ARRAY}`, and a size corresponding to + the size of :samp:`{ARRAY}` with the :samp:`{DIM}` dimension removed. In all + cases, the result is of the same type and kind as :samp:`{ARRAY}`. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = MAXVAL(ARRAY, DIM [, MASK]) + RESULT = MAXVAL(ARRAY [, MASK]) + + See also: + :ref:`MAX`, + :ref:`MAXLOC` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/mclock.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/mclock.rst new file mode 100644 index 00000000000..3ac35fb1f49 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/mclock.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MCLOCK, time, clock ticks, clock ticks + +.. _mclock: + +MCLOCK --- Time function +************************ + +.. function:: MCLOCK() + + Returns the number of clock ticks since the start of the process, based + on the function ``clock(3)`` in the C standard library. + + :return: + The return value is a scalar of type ``INTEGER(4)``, equal to the + number of clock ticks since the start of the process, or ``-1`` if + the system does not support ``clock(3)``. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = MCLOCK() + + See also: + :ref:`CTIME`, + :ref:`GMTIME`, + :ref:`LTIME`, + :ref:`MCLOCK`, + :ref:`TIME` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/mclock8.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/mclock8.rst new file mode 100644 index 00000000000..3524e52d4c1 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/mclock8.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MCLOCK8, time, clock ticks, clock ticks + +.. _mclock8: + +MCLOCK8 --- Time function (64-bit) +********************************** + +.. function:: MCLOCK8() + + Returns the number of clock ticks since the start of the process, based + on the function ``clock(3)`` in the C standard library. + + :return: + The return value is a scalar of type ``INTEGER(8)``, equal to the + number of clock ticks since the start of the process, or ``-1`` if + the system does not support ``clock(3)``. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = MCLOCK8() + + See also: + :ref:`CTIME`, + :ref:`GMTIME`, + :ref:`LTIME`, + :ref:`MCLOCK`, + :ref:`TIME8` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/merge.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/merge.rst new file mode 100644 index 00000000000..556358ab86c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/merge.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MERGE, array, merge arrays, array, combine arrays + +.. _merge: + +MERGE --- Merge variables +************************* + +.. function:: MERGE(TSOURCE, FSOURCE, MASK) + + Select values from two arrays according to a logical mask. The result + is equal to :samp:`{TSOURCE}` if :samp:`{MASK}` is ``.TRUE.``, or equal to + :samp:`{FSOURCE}` if it is ``.FALSE.``. + + :param TSOURCE: + May be of any type. + + :param FSOURCE: + Shall be of the same type and type parameters + as :samp:`{TSOURCE}`. + + :param MASK: + Shall be of type ``LOGICAL``. + + :return: + The result is of the same type and type parameters as :samp:`{TSOURCE}`. + + Standard: + Fortran 90 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = MERGE(TSOURCE, FSOURCE, MASK) \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/mergebits.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/mergebits.rst new file mode 100644 index 00000000000..80dd38b76f8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/mergebits.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MERGE_BITS, bits, merge + +.. _merge_bits: + +MERGE_BITS --- Merge of bits under mask +*************************************** + +.. function:: MERGE_BITS(I, J, MASK) + + ``MERGE_BITS(I, J, MASK)`` merges the bits of :samp:`{I}` and :samp:`{J}` + as determined by the mask. The i-th bit of the result is equal to the + i-th bit of :samp:`{I}` if the i-th bit of :samp:`{MASK}` is 1; it is equal to + the i-th bit of :samp:`{J}` otherwise. + + :param I: + Shall be of type ``INTEGER`` or a boz-literal-constant. + + :param J: + Shall be of type ``INTEGER`` with the same + kind type parameter as :samp:`{I}` or a boz-literal-constant. + :samp:`{I}` and :samp:`{J}` shall not both be boz-literal-constants. + + :param MASK: + Shall be of type ``INTEGER`` or a boz-literal-constant + and of the same kind as :samp:`{I}`. + + :return: + The result is of the same type and kind as :samp:`{I}`. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = MERGE_BITS(I, J, MASK) \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/min.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/min.rst new file mode 100644 index 00000000000..aefd814cbbe --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/min.rst @@ -0,0 +1,86 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _min: + +.. index:: MIN + +.. index:: MIN0 + +.. index:: AMIN0 + +.. index:: MIN1 + +.. index:: AMIN1 + +.. index:: DMIN1 + +.. index:: minimum value + +MIN --- Minimum value of an argument list +***************************************** + +.. function:: MIN(A1, A2 , A3, ...) + + Returns the argument with the smallest (most negative) value. + + :param A1: + The type shall be ``INTEGER`` or + ``REAL``. + + :param A2}, {A3}, ...: + An expression of the same type and kind + as :samp:`{A1}`. (As a GNU extension, arguments of different kinds are + permitted.) + + :return: + The return value corresponds to the minimum value among the arguments, + and has the same type and kind as the first argument. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = MIN(A1, A2 [, A3, ...]) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``MIN0(A1)`` + - ``INTEGER(4) A1`` + - ``INTEGER(4)`` + - Fortran 77 and later + * - ``AMIN0(A1)`` + - ``INTEGER(4) A1`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``MIN1(A1)`` + - ``REAL A1`` + - ``INTEGER(4)`` + - Fortran 77 and later + * - ``AMIN1(A1)`` + - ``REAL(4) A1`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DMIN1(A1)`` + - ``REAL(8) A1`` + - ``REAL(8)`` + - Fortran 77 and later + + See also: + :ref:`MAX`, + :ref:`MINLOC`, + :ref:`MINVAL` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/minexponent.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/minexponent.rst new file mode 100644 index 00000000000..546a46bb193 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/minexponent.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MINEXPONENT, model representation, minimum exponent + +.. _minexponent: + +MINEXPONENT --- Minimum exponent of a real kind +*********************************************** + +.. function:: MINEXPONENT(X) + + ``MINEXPONENT(X)`` returns the minimum exponent in the model of the + type of ``X``. + + :param X: + Shall be of type ``REAL``. + + :return: + The return value is of type ``INTEGER`` and of the default integer + kind. + + Standard: + Fortran 90 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = MINEXPONENT(X) + + Example: + See ``MAXEXPONENT`` for an example. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/minloc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/minloc.rst new file mode 100644 index 00000000000..49496bec599 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/minloc.rst @@ -0,0 +1,76 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _minloc: + +MINLOC --- Location of the minimum value within an array +******************************************************** + +.. index:: MINLOC, array, location of minimum element + +.. function:: MINLOC(ARRAY, MASK, KIND, BACK) + + Determines the location of the element in the array with the minimum + value, or, if the :samp:`{DIM}` argument is supplied, determines the + locations of the minimum element along each row of the array in the + :samp:`{DIM}` direction. If :samp:`{MASK}` is present, only the elements for + which :samp:`{MASK}` is ``.TRUE.`` are considered. If more than one + element in the array has the minimum value, the location returned is + that of the first such element in array element order if the + :samp:`{BACK}` is not present, or is false; if :samp:`{BACK}` is true, the location + returned is that of the last such element. If the array has + zero size, or all of the elements of :samp:`{MASK}` are ``.FALSE.``, then + the result is an array of zeroes. Similarly, if :samp:`{DIM}` is supplied + and all of the elements of :samp:`{MASK}` along a given row are zero, the + result value for that row is zero. + + :param ARRAY: + Shall be an array of type ``INTEGER``, + ``REAL`` or ``CHARACTER``. + + :param DIM: + (Optional) Shall be a scalar of type + ``INTEGER``, with a value between one and the rank of :samp:`{ARRAY}`, + inclusive. It may not be an optional dummy argument. + + :param MASK: + Shall be of type ``LOGICAL``, + and conformable with :samp:`{ARRAY}`. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :param BACK: + (Optional) A scalar of type ``LOGICAL``. + + :return: + If :samp:`{DIM}` is absent, the result is a rank-one array with a length + equal to the rank of :samp:`{ARRAY}`. If :samp:`{DIM}` is present, the result + is an array with a rank one less than the rank of :samp:`{ARRAY}`, and a + size corresponding to the size of :samp:`{ARRAY}` with the :samp:`{DIM}` + dimension removed. If :samp:`{DIM}` is present and :samp:`{ARRAY}` has a rank + of one, the result is a scalar. If the optional argument :samp:`{KIND}` + is present, the result is an integer of kind :samp:`{KIND}`, otherwise it + is of default kind. + + Standard: + Fortran 90 and later; :samp:`{ARRAY}` of ``CHARACTER`` and the + :samp:`{KIND}` argument are available in Fortran 2003 and later. + The :samp:`{BACK}` argument is available in Fortran 2008 and later. + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = MINLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK]) + RESULT = MINLOC(ARRAY [, MASK], [,KIND] [,BACK]) + + See also: + :ref:`FINDLOC`, + :ref:`MIN`, + :ref:`MINVAL` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/minval.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/minval.rst new file mode 100644 index 00000000000..55fd75d8a56 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/minval.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MINVAL, array, minimum value, minimum value + +.. _minval: + +MINVAL --- Minimum value of an array +************************************ + +.. function:: MINVAL(ARRAY , MASK) + + Determines the minimum value of the elements in an array value, or, if + the :samp:`{DIM}` argument is supplied, determines the minimum value along + each row of the array in the :samp:`{DIM}` direction. If :samp:`{MASK}` is + present, only the elements for which :samp:`{MASK}` is ``.TRUE.`` are + considered. If the array has zero size, or all of the elements of + :samp:`{MASK}` are ``.FALSE.``, then the result is ``HUGE(ARRAY)`` if + :samp:`{ARRAY}` is numeric, or a string of ``CHAR(255)`` characters if + :samp:`{ARRAY}` is of character type. + + :param ARRAY: + Shall be an array of type ``INTEGER`` or + ``REAL``. + + :param DIM: + (Optional) Shall be a scalar of type + ``INTEGER``, with a value between one and the rank of :samp:`{ARRAY}`, + inclusive. It may not be an optional dummy argument. + + :param MASK: + Shall be of type ``LOGICAL``, + and conformable with :samp:`{ARRAY}`. + + :return: + If :samp:`{DIM}` is absent, or if :samp:`{ARRAY}` has a rank of one, the result + is a scalar. If :samp:`{DIM}` is present, the result is an array with a + rank one less than the rank of :samp:`{ARRAY}`, and a size corresponding to + the size of :samp:`{ARRAY}` with the :samp:`{DIM}` dimension removed. In all + cases, the result is of the same type and kind as :samp:`{ARRAY}`. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = MINVAL(ARRAY, DIM [, MASK]) + RESULT = MINVAL(ARRAY [, MASK]) + + See also: + :ref:`MIN`, + :ref:`MINLOC` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/mod.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/mod.rst new file mode 100644 index 00000000000..35624ae322b --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/mod.rst @@ -0,0 +1,118 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _mod: + +.. index:: MOD + +.. index:: AMOD + +.. index:: DMOD + +.. index:: BMOD + +.. index:: IMOD + +.. index:: JMOD + +.. index:: KMOD + +.. index:: remainder + +.. index:: division, remainder + +MOD --- Remainder function +************************** + +.. function:: MOD(A,P) + + ``MOD(A,P)`` computes the remainder of the division of A by P. + + :param A: + Shall be a scalar of type ``INTEGER`` or ``REAL``. + + :param P: + Shall be a scalar of the same type and kind as :samp:`{A}` + and not equal to zero. (As a GNU extension, arguments of different kinds are + permitted.) + + :return: + The return value is the result of ``A - (INT(A/P) * P)``. The type + and kind of the return value is the same as that of the arguments. The + returned value has the same sign as A and a magnitude less than the + magnitude of P. (As a GNU extension, kind is the largest kind of the actual + arguments.) + + Standard: + Fortran 77 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = MOD(A, P) + + Example: + .. code-block:: fortran + + program test_mod + print *, mod(17,3) + print *, mod(17.5,5.5) + print *, mod(17.5d0,5.5) + print *, mod(17.5,5.5d0) + + print *, mod(-17,3) + print *, mod(-17.5,5.5) + print *, mod(-17.5d0,5.5) + print *, mod(-17.5,5.5d0) + + print *, mod(17,-3) + print *, mod(17.5,-5.5) + print *, mod(17.5d0,-5.5) + print *, mod(17.5,-5.5d0) + end program test_mod + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Arguments + - Return type + - Standard + + * - ``MOD(A,P)`` + - ``INTEGER A,P`` + - ``INTEGER`` + - Fortran 77 and later + * - ``AMOD(A,P)`` + - ``REAL(4) A,P`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DMOD(A,P)`` + - ``REAL(8) A,P`` + - ``REAL(8)`` + - Fortran 77 and later + * - ``BMOD(A,P)`` + - ``INTEGER(1) A,P`` + - ``INTEGER(1)`` + - GNU extension + * - ``IMOD(A,P)`` + - ``INTEGER(2) A,P`` + - ``INTEGER(2)`` + - GNU extension + * - ``JMOD(A,P)`` + - ``INTEGER(4) A,P`` + - ``INTEGER(4)`` + - GNU extension + * - ``KMOD(A,P)`` + - ``INTEGER(8) A,P`` + - ``INTEGER(8)`` + - GNU extension + + See also: + :ref:`MODULO` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/modulo.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/modulo.rst new file mode 100644 index 00000000000..82e21261d94 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/modulo.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MODULO, modulo, division, modulo + +.. _modulo: + +MODULO --- Modulo function +************************** + +.. function:: MODULO(A,P) + + ``MODULO(A,P)`` computes the :samp:`{A}` modulo :samp:`{P}`. + + :param A: + Shall be a scalar of type ``INTEGER`` or ``REAL``. + + :param P: + Shall be a scalar of the same type and kind as :samp:`{A}`. + It shall not be zero. (As a GNU extension, arguments of different kinds are + permitted.) + + :return: + The type and kind of the result are those of the arguments. (As a GNU + extension, kind is the largest kind of the actual arguments.) + + Standard: + Fortran 95 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = MODULO(A, P) + + Example: + .. code-block:: fortran + + program test_modulo + print *, modulo(17,3) + print *, modulo(17.5,5.5) + + print *, modulo(-17,3) + print *, modulo(-17.5,5.5) + + print *, modulo(17,-3) + print *, modulo(17.5,-5.5) + end program + + See also: + :ref:`MOD` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/movealloc.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/movealloc.rst new file mode 100644 index 00000000000..8c39ad8e824 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/movealloc.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: MOVE_ALLOC, moving allocation, allocation, moving + +.. _move_alloc: + +MOVE_ALLOC --- Move allocation from one object to another +********************************************************* + +.. function:: MOVE_ALLOC(FROM, TO) + + ``MOVE_ALLOC(FROM, TO)`` moves the allocation from :samp:`{FROM}` to + :samp:`{TO}`. :samp:`{FROM}` will become deallocated in the process. + + :param FROM: + ``ALLOCATABLE``, ``INTENT(INOUT)``, may be + of any type and kind. + + :param TO: + ``ALLOCATABLE``, ``INTENT(OUT)``, shall be + of the same type, kind and rank as :samp:`{FROM}`. + + :return: + None + + Standard: + Fortran 2003 and later + + Class: + Pure subroutine + + Syntax: + .. code-block:: fortran + + CALL MOVE_ALLOC(FROM, TO) + + Example: + .. code-block:: fortran + + program test_move_alloc + integer, allocatable :: a(:), b(:) + + allocate(a(3)) + a = [ 1, 2, 3 ] + call move_alloc(a, b) + print *, allocated(a), allocated(b) + print *, b + end program test_move_alloc \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/mvbits.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/mvbits.rst new file mode 100644 index 00000000000..a3b0121a5ba --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/mvbits.rst @@ -0,0 +1,95 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _mvbits: + +.. index:: MVBITS + +.. index:: BMVBITS + +.. index:: IMVBITS + +.. index:: JMVBITS + +.. index:: KMVBITS + +.. index:: bits, move + +MVBITS --- Move bits from one integer to another +************************************************ + +.. function:: MVBITS(FROM, FROMPOS, LEN, TO, TOPOS) + + Moves :samp:`{LEN}` bits from positions :samp:`{FROMPOS}` through + ``FROMPOS+LEN-1`` of :samp:`{FROM}` to positions :samp:`{TOPOS}` through + ``TOPOS+LEN-1`` of :samp:`{TO}`. The portion of argument :samp:`{TO}` not + affected by the movement of bits is unchanged. The values of + ``FROMPOS+LEN-1`` and ``TOPOS+LEN-1`` must be less than + ``BIT_SIZE(FROM)``. + + :param FROM: + The type shall be ``INTEGER``. + + :param FROMPOS: + The type shall be ``INTEGER``. + + :param LEN: + The type shall be ``INTEGER``. + + :param TO: + The type shall be ``INTEGER``, of the + same kind as :samp:`{FROM}`. + + :param TOPOS: + The type shall be ``INTEGER``. + + Standard: + Fortran 90 and later, has overloads that are GNU extensions + + Class: + Elemental subroutine + + Syntax: + .. code-block:: fortran + + CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``MVBITS(A)`` + - ``INTEGER A`` + - ``INTEGER`` + - Fortran 90 and later + * - ``BMVBITS(A)`` + - ``INTEGER(1) A`` + - ``INTEGER(1)`` + - GNU extension + * - ``IMVBITS(A)`` + - ``INTEGER(2) A`` + - ``INTEGER(2)`` + - GNU extension + * - ``JMVBITS(A)`` + - ``INTEGER(4) A`` + - ``INTEGER(4)`` + - GNU extension + * - ``KMVBITS(A)`` + - ``INTEGER(8) A`` + - ``INTEGER(8)`` + - GNU extension + + See also: + :ref:`IBCLR`, + :ref:`IBSET`, + :ref:`IBITS`, + :ref:`IAND`, + :ref:`IOR`, + :ref:`IEOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/nearest.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/nearest.rst new file mode 100644 index 00000000000..8c2292cd904 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/nearest.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: NEAREST, real number, nearest different, floating point, nearest different + +.. _nearest: + +NEAREST --- Nearest representable number +**************************************** + +.. function:: NEAREST(X, S) + + ``NEAREST(X, S)`` returns the processor-representable number nearest + to ``X`` in the direction indicated by the sign of ``S``. + + :param X: + Shall be of type ``REAL``. + + :param S: + Shall be of type ``REAL`` and + not equal to zero. + + :return: + The return value is of the same type as ``X``. If ``S`` is + positive, ``NEAREST`` returns the processor-representable number + greater than ``X`` and nearest to it. If ``S`` is negative, + ``NEAREST`` returns the processor-representable number smaller than + ``X`` and nearest to it. + + Standard: + Fortran 90 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = NEAREST(X, S) + + Example: + .. code-block:: fortran + + program test_nearest + real :: x, y + x = nearest(42.0, 1.0) + y = nearest(42.0, -1.0) + write (*,"(3(G20.15))") x, y, x - y + end program test_nearest \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/newline.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/newline.rst new file mode 100644 index 00000000000..0c5a830a826 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/newline.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: NEW_LINE, newline, output, newline + +.. _new_line: + +NEW_LINE --- New line character +******************************* + +.. function:: NEW_LINE(C) + + ``NEW_LINE(C)`` returns the new-line character. + + :param C: + The argument shall be a scalar or array of the + type ``CHARACTER``. + + :return: + Returns a :samp:`{CHARACTER}` scalar of length one with the new-line character of + the same kind as parameter :samp:`{C}`. + + Standard: + Fortran 2003 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = NEW_LINE(C) + + Example: + .. code-block:: fortran + + program newline + implicit none + write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.' + end program newline \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/nint.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/nint.rst new file mode 100644 index 00000000000..8c4eb56f00e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/nint.rst @@ -0,0 +1,75 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _nint: + +.. index:: NINT + +.. index:: IDNINT + +.. index:: rounding, nearest whole number + +NINT --- Nearest whole number +***************************** + +.. function:: NINT(A) + + ``NINT(A)`` rounds its argument to the nearest whole number. + + :param A: + The type of the argument shall be ``REAL``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + Returns :samp:`{A}` with the fractional portion of its magnitude eliminated by + rounding to the nearest whole number and with its sign preserved, + converted to an ``INTEGER`` of the default kind. + + Standard: + Fortran 77 and later, with :samp:`{KIND}` argument Fortran 90 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = NINT(A [, KIND]) + + Example: + .. code-block:: fortran + + program test_nint + real(4) x4 + real(8) x8 + x4 = 1.234E0_4 + x8 = 4.321_8 + print *, nint(x4), idnint(x8) + end program test_nint + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return Type + - Standard + + * - ``NINT(A)`` + - ``REAL(4) A`` + - ``INTEGER`` + - Fortran 77 and later + * - ``IDNINT(A)`` + - ``REAL(8) A`` + - ``INTEGER`` + - Fortran 77 and later + + See also: + :ref:`CEILING`, + :ref:`FLOOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/norm2.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/norm2.rst new file mode 100644 index 00000000000..05bb49134b3 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/norm2.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: NORM2, Euclidean vector norm, L2 vector norm, norm, Euclidean + +.. _norm2: + +NORM2 --- Euclidean vector norms +******************************** + +.. function:: NORM2(ARRAY, DIM) + + Calculates the Euclidean vector norm (L_2 norm) + of :samp:`{ARRAY}` along dimension :samp:`{DIM}`. + + :param ARRAY: + Shall be an array of type ``REAL`` + + :param DIM: + (Optional) shall be a scalar of type + ``INTEGER`` with a value in the range from 1 to n, where n + equals the rank of :samp:`{ARRAY}`. + + :return: + The result is of the same type as :samp:`{ARRAY}`. + + Standard: + Fortran 2008 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = NORM2(ARRAY[, DIM]) + + Example: + .. code-block:: fortran + + PROGRAM test_sum + REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ] + print *, NORM2(x) ! = sqrt(55.) ~ 7.416 + END PROGRAM \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/not.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/not.rst new file mode 100644 index 00000000000..841b19c9844 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/not.rst @@ -0,0 +1,85 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _not: + +.. index:: NOT + +.. index:: BNOT + +.. index:: INOT + +.. index:: JNOT + +.. index:: KNOT + +.. index:: bits, negate + +.. index:: bitwise logical not + +.. index:: logical not, bitwise + +NOT --- Logical negation +************************ + +.. function:: NOT() + + ``NOT`` returns the bitwise Boolean inverse of :samp:`{I}`. + + :param I: + The type shall be ``INTEGER``. + + :return: + The return type is ``INTEGER``, of the same kind as the + argument. + + Standard: + Fortran 90 and later, has overloads that are GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = NOT(I) + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``NOT(A)`` + - ``INTEGER A`` + - ``INTEGER`` + - Fortran 95 and later + * - ``BNOT(A)`` + - ``INTEGER(1) A`` + - ``INTEGER(1)`` + - GNU extension + * - ``INOT(A)`` + - ``INTEGER(2) A`` + - ``INTEGER(2)`` + - GNU extension + * - ``JNOT(A)`` + - ``INTEGER(4) A`` + - ``INTEGER(4)`` + - GNU extension + * - ``KNOT(A)`` + - ``INTEGER(8) A`` + - ``INTEGER(8)`` + - GNU extension + + See also: + :ref:`IAND`, + :ref:`IEOR`, + :ref:`IOR`, + :ref:`IBITS`, + :ref:`IBSET`, + :ref:`IBCLR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/null.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/null.rst new file mode 100644 index 00000000000..816887e23d9 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/null.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _null: + +NULL --- Function that returns an disassociated pointer +******************************************************* + +.. index:: NULL, pointer, status, pointer, disassociated + +.. function:: NULL(MOLD) + + Returns a disassociated pointer. + + :param MOLD: + (Optional) shall be a pointer of any association + status and of any type. + + :return: + A disassociated pointer. + + Standard: + Fortran 95 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + PTR => NULL([MOLD]) + + Example: + .. code-block:: fortran + + REAL, POINTER, DIMENSION(:) :: VEC => NULL () + + See also: + :ref:`ASSOCIATED` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/numimages.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/numimages.rst new file mode 100644 index 00000000000..bcb93e012fd --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/numimages.rst @@ -0,0 +1,61 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: NUM_IMAGES, coarray, NUM_IMAGES, images, number of + +.. _num_images: + +NUM_IMAGES --- Function that returns the number of images +********************************************************* + +.. function:: NUM_IMAGES(DISTANCE, FAILED) + + Returns the number of images. + + :param DISTANCE: + (optional, intent(in)) Nonnegative scalar integer + + :param FAILED: + (optional, intent(in)) Scalar logical expression + + :return: + Scalar default-kind integer. If :samp:`{DISTANCE}` is not present or has value 0, + the number of images in the current team is returned. For values smaller or + equal distance to the initial team, it returns the number of images index + on the ancestor team which has a distance of :samp:`{DISTANCE}` from the invoking + team. If :samp:`{DISTANCE}` is larger than the distance to the initial team, the + number of images of the initial team is returned. If :samp:`{FAILED}` is not present + the total number of images is returned; if it has the value ``.TRUE.``, + the number of failed images is returned, otherwise, the number of images which + do have not the failed status. + + Standard: + Fortran 2008 and later. With :samp:`{DISTANCE}` or :samp:`{FAILED}` argument, + Technical Specification (TS) 18508 or later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = NUM_IMAGES(DISTANCE, FAILED) + + Example: + .. code-block:: fortran + + INTEGER :: value[*] + INTEGER :: i + value = THIS_IMAGE() + SYNC ALL + IF (THIS_IMAGE() == 1) THEN + DO i = 1, NUM_IMAGES() + WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i] + END DO + END IF + + See also: + :ref:`THIS_IMAGE`, + :ref:`IMAGE_INDEX` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/or.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/or.rst new file mode 100644 index 00000000000..2ca58a5f3ee --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/or.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _or: + +OR --- Bitwise logical OR +************************* + +.. index:: OR, bitwise logical or, logical or, bitwise + +.. function:: OR(I, J) + + Bitwise logical ``OR``. + + :param I: + The type shall be either a scalar ``INTEGER`` + type or a scalar ``LOGICAL`` type or a boz-literal-constant. + + :param J: + The type shall be the same as the type of :samp:`{I}` or + a boz-literal-constant. :samp:`{I}` and :samp:`{J}` shall not both be + boz-literal-constants. If either :samp:`{I}` and :samp:`{J}` is a + boz-literal-constant, then the other argument must be a scalar ``INTEGER``. + + :return: + The return type is either a scalar ``INTEGER`` or a scalar + ``LOGICAL``. If the kind type parameters differ, then the + smaller kind type is implicitly converted to larger kind, and the + return has the larger kind. A boz-literal-constant is + converted to an ``INTEGER`` with the kind type parameter of + the other argument as-if a call to :ref:`INT` occurred. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = OR(I, J) + + Example: + .. code-block:: fortran + + PROGRAM test_or + LOGICAL :: T = .TRUE., F = .FALSE. + INTEGER :: a, b + DATA a / Z'F' /, b / Z'3' / + + WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F) + WRITE (*,*) OR(a, b) + END PROGRAM + + See also: + Fortran 95 elemental function: + :ref:`IOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/pack.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/pack.rst new file mode 100644 index 00000000000..183bb52acf0 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/pack.rst @@ -0,0 +1,72 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: PACK, array, packing, array, reduce dimension, array, gather elements + +.. _pack: + +PACK --- Pack an array into an array of rank one +************************************************ + +.. function:: PACK(ARRAY, MASK,VECTOR) + + Stores the elements of :samp:`{ARRAY}` in an array of rank one. + + :param ARRAY: + Shall be an array of any type. + + :param MASK: + Shall be an array of type ``LOGICAL`` and + of the same size as :samp:`{ARRAY}`. Alternatively, it may be a ``LOGICAL`` + scalar. + + :param VECTOR: + (Optional) shall be an array of the same type + as :samp:`{ARRAY}` and of rank one. If present, the number of elements in + :samp:`{VECTOR}` shall be equal to or greater than the number of true elements + in :samp:`{MASK}`. If :samp:`{MASK}` is scalar, the number of elements in + :samp:`{VECTOR}` shall be equal to or greater than the number of elements in + :samp:`{ARRAY}`. + + :return: + The result is an array of rank one and the same type as that of :samp:`{ARRAY}`. + If :samp:`{VECTOR}` is present, the result size is that of :samp:`{VECTOR}`, the + number of ``TRUE`` values in :samp:`{MASK}` otherwise. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = PACK(ARRAY, MASK[,VECTOR]) + + Example: + Gathering nonzero elements from an array: + + .. code-block:: fortran + + PROGRAM test_pack_1 + INTEGER :: m(6) + m = (/ 1, 0, 0, 0, 5, 0 /) + WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5" + END PROGRAM + + Gathering nonzero elements from an array and appending elements from :samp:`{VECTOR}` : + + .. code-block:: fortran + + PROGRAM test_pack_2 + INTEGER :: m(4) + m = (/ 1, 0, 0, 2 /) + ! The following results in "1 2 3 4" + WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /)) + END PROGRAM + + See also: + :ref:`UNPACK` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/parity.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/parity.rst new file mode 100644 index 00000000000..6617c0f4acc --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/parity.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: PARITY, Parity, Reduction, XOR, XOR reduction + +.. _parity: + +PARITY --- Reduction with exclusive OR +************************************** + +.. function:: PARITY(MASK, DIM) + + Calculates the parity, i.e. the reduction using ``.XOR.``, + of :samp:`{MASK}` along dimension :samp:`{DIM}`. + + :param MASK: + Shall be an array of type ``LOGICAL`` + + :param DIM: + (Optional) shall be a scalar of type + ``INTEGER`` with a value in the range from 1 to n, where n + equals the rank of :samp:`{MASK}`. + + :return: + The result is of the same type as :samp:`{MASK}`. + + Standard: + Fortran 2008 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = PARITY(MASK[, DIM]) + + Example: + .. code-block:: fortran + + PROGRAM test_sum + LOGICAL :: x(2) = [ .true., .false. ] + print *, PARITY(x) ! prints "T" (true). + END PROGRAM \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/perror.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/perror.rst new file mode 100644 index 00000000000..22e13e3cfd2 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/perror.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: PERROR, system, error handling + +.. _perror: + +PERROR --- Print system error message +************************************* + +.. function:: PERROR(STRING) + + Prints (on the C ``stderr`` stream) a newline-terminated error + message corresponding to the last system error. This is prefixed by + :samp:`{STRING}`, a colon and a space. See ``perror(3)``. + + :param STRING: + A scalar of type ``CHARACTER`` and of the + default kind. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL PERROR(STRING) + + See also: + :ref:`IERRNO` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/popcnt.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/popcnt.rst new file mode 100644 index 00000000000..5e9d19bad7e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/popcnt.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: POPCNT, binary representation, bits set + +.. _popcnt: + +POPCNT --- Number of bits set +***************************** + +.. function:: POPCNT(I) + + ``POPCNT(I)`` returns the number of bits set ('1' bits) in the binary + representation of ``I``. + + :param I: + Shall be of type ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` and of the default integer + kind. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = POPCNT(I) + + Example: + .. code-block:: fortran + + program test_population + print *, popcnt(127), poppar(127) + print *, popcnt(huge(0_4)), poppar(huge(0_4)) + print *, popcnt(huge(0_8)), poppar(huge(0_8)) + end program test_population + + See also: + :ref:`POPPAR`, + :ref:`LEADZ`, + :ref:`TRAILZ` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/poppar.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/poppar.rst new file mode 100644 index 00000000000..85f16416182 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/poppar.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: POPPAR, binary representation, parity + +.. _poppar: + +POPPAR --- Parity of the number of bits set +******************************************* + +.. function:: POPPAR(I) + + ``POPPAR(I)`` returns parity of the integer ``I``, i.e. the parity + of the number of bits set ('1' bits) in the binary representation of + ``I``. It is equal to 0 if ``I`` has an even number of bits set, + and 1 for an odd number of '1' bits. + + :param I: + Shall be of type ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` and of the default integer + kind. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = POPPAR(I) + + Example: + .. code-block:: fortran + + program test_population + print *, popcnt(127), poppar(127) + print *, popcnt(huge(0_4)), poppar(huge(0_4)) + print *, popcnt(huge(0_8)), poppar(huge(0_8)) + end program test_population + + See also: + :ref:`POPCNT`, + :ref:`LEADZ`, + :ref:`TRAILZ` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/precision.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/precision.rst new file mode 100644 index 00000000000..892786a4c5f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/precision.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: PRECISION, model representation, precision + +.. _precision: + +PRECISION --- Decimal precision of a real kind +********************************************** + +.. function:: PRECISION(X) + + ``PRECISION(X)`` returns the decimal precision in the model of the + type of ``X``. + + :param X: + Shall be of type ``REAL`` or ``COMPLEX``. It may + be scalar or valued. + + :return: + The return value is of type ``INTEGER`` and of the default integer + kind. + + Standard: + Fortran 90 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = PRECISION(X) + + Example: + .. code-block:: fortran + + program prec_and_range + real(kind=4) :: x(2) + complex(kind=8) :: y + + print *, precision(x), range(x) + print *, precision(y), range(y) + end program prec_and_range + + See also: + :ref:`SELECTED_REAL_KIND`, + :ref:`RANGE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/present.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/present.rst new file mode 100644 index 00000000000..c2f8f340d50 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/present.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: PRESENT + +.. _present: + +PRESENT --- Determine whether an optional dummy argument is specified +********************************************************************* + +.. function:: PRESENT(A) + + Determines whether an optional dummy argument is present. + + :param A: + May be of any type and may be a pointer, scalar or array + value, or a dummy procedure. It shall be the name of an optional dummy argument + accessible within the current subroutine or function. + + :return: + Returns either ``TRUE`` if the optional argument :samp:`{A}` is present, or + ``FALSE`` otherwise. + + Standard: + Fortran 90 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = PRESENT(A) + + Example: + .. code-block:: fortran + + PROGRAM test_present + WRITE(*,*) f(), f(42) ! "F T" + CONTAINS + LOGICAL FUNCTION f(x) + INTEGER, INTENT(IN), OPTIONAL :: x + f = PRESENT(x) + END FUNCTION + END PROGRAM \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/product.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/product.rst new file mode 100644 index 00000000000..81d59d6167d --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/product.rst @@ -0,0 +1,56 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: PRODUCT, array, product, array, multiply elements, array, conditionally multiply elements, multiply array elements + +.. _product: + +PRODUCT --- Product of array elements +************************************* + +.. function:: PRODUCT(ARRAY, DIM, MASK) + + Multiplies the elements of :samp:`{ARRAY}` along dimension :samp:`{DIM}` if + the corresponding element in :samp:`{MASK}` is ``TRUE``. + + :param ARRAY: + Shall be an array of type ``INTEGER``, + ``REAL`` or ``COMPLEX``. + + :param DIM: + (Optional) shall be a scalar of type + ``INTEGER`` with a value in the range from 1 to n, where n + equals the rank of :samp:`{ARRAY}`. + + :param MASK: + (Optional) shall be of type ``LOGICAL`` + and either be a scalar or an array of the same shape as :samp:`{ARRAY}`. + + :return: + The result is of the same type as :samp:`{ARRAY}`. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = PRODUCT(ARRAY[, MASK]) + RESULT = PRODUCT(ARRAY, DIM[, MASK]) + + Example: + .. code-block:: fortran + + PROGRAM test_product + INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /) + print *, PRODUCT(x) ! all elements, product = 120 + print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15 + END PROGRAM + + See also: + :ref:`SUM` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/radix.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/radix.rst new file mode 100644 index 00000000000..14379ce8900 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/radix.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RADIX, model representation, base, model representation, radix + +.. _radix: + +RADIX --- Base of a model number +******************************** + +.. function:: RADIX(X) + + ``RADIX(X)`` returns the base of the model representing the entity :samp:`{X}`. + + :param X: + Shall be of type ``INTEGER`` or ``REAL`` + + :return: + The return value is a scalar of type ``INTEGER`` and of the default + integer kind. + + Standard: + Fortran 90 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = RADIX(X) + + Example: + .. code-block:: fortran + + program test_radix + print *, "The radix for the default integer kind is", radix(0) + print *, "The radix for the default real kind is", radix(0.0) + end program test_radix + + See also: + :ref:`SELECTED_REAL_KIND` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ran.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ran.rst new file mode 100644 index 00000000000..deee7b0fdea --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ran.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _ran: + +RAN --- Real pseudo-random number +********************************* + +.. index:: RAN, random number generation + +.. function:: RAN() + + For compatibility with HP FORTRAN 77/iX, the ``RAN`` intrinsic is + provided as an alias for ``RAND``. See :ref:`RAND` for complete + documentation. + + Standard: + GNU extension + + Class: + Function + + See also: + :ref:`RAND`, + :ref:`RANDOM_NUMBER` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/rand.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/rand.rst new file mode 100644 index 00000000000..c8fe878d89a --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/rand.rst @@ -0,0 +1,51 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RAND, random number generation + +.. _rand: + +RAND --- Real pseudo-random number +********************************** + +.. function:: RAND(FLAG) + + ``RAND(FLAG)`` returns a pseudo-random number from a uniform + distribution between 0 and 1. If :samp:`{FLAG}` is 0, the next number + in the current sequence is returned; if :samp:`{FLAG}` is 1, the generator + is restarted by ``CALL SRAND(0)`` ; if :samp:`{FLAG}` has any other value, + it is used as a new seed with ``SRAND``. + + :param I: + Shall be a scalar ``INTEGER`` of kind 4. + + :return: + The return value is of ``REAL`` type and the default kind. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = RAND(I) + + Example: + .. code-block:: fortran + + program test_rand + integer,parameter :: seed = 86456 + + call srand(seed) + print *, rand(), rand(), rand(), rand() + print *, rand(seed), rand(), rand(), rand() + end program test_rand + + See also: + :ref:`SRAND`, + :ref:`RANDOM_NUMBER` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/randominit.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/randominit.rst new file mode 100644 index 00000000000..7e1ffd54350 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/randominit.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RANDOM_INIT, random number generation, initialization + +.. _random_init: + +RANDOM_INIT --- Initialize a pseudo-random number generator +*********************************************************** + +.. function:: RANDOM_INIT(REPEATABLE, IMAGE_DISTINCT) + + Initializes the state of the pseudorandom number generator used by + ``RANDOM_NUMBER``. + + :param REPEATABLE: + Shall be a scalar with a ``LOGICAL`` type, + and it is ``INTENT(IN)``. If it is ``.true.``, the seed is set to + a processor-dependent value that is the same each time ``RANDOM_INIT`` + is called from the same image. The term 'same image' means a single + instance of program execution. The sequence of random numbers is different + for repeated execution of the program. If it is ``.false.``, the seed + is set to a processor-dependent value. + + :param IMAGE_DISTINCT: + Shall be a scalar with a + ``LOGICAL`` type, and it is ``INTENT(IN)``. If it is ``.true.``, + the seed is set to a processor-dependent value that is distinct from th + seed set by a call to ``RANDOM_INIT`` in another image. If it is + ``.false.``, the seed is set to a value that does depend which image called + ``RANDOM_INIT``. + + Standard: + Fortran 2018 + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL RANDOM_INIT(REPEATABLE, IMAGE_DISTINCT) + + Example: + .. code-block:: fortran + + program test_random_seed + implicit none + real x(3), y(3) + call random_init(.true., .true.) + call random_number(x) + call random_init(.true., .true.) + call random_number(y) + ! x and y are the same sequence + if (any(x /= y)) call abort + end program test_random_seed + + See also: + :ref:`RANDOM_NUMBER`, + :ref:`RANDOM_SEED` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/randomnumber.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/randomnumber.rst new file mode 100644 index 00000000000..77935c9e8d3 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/randomnumber.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RANDOM_NUMBER, random number generation + +.. _random_number: + +RANDOM_NUMBER --- Pseudo-random number +************************************** + +.. function:: RANDOM_NUMBER(HARVEST) + + Returns a single pseudorandom number or an array of pseudorandom numbers + from the uniform distribution over the range 0 \leq x < 1. + + :param HARVEST: + Shall be a scalar or an array of type ``REAL``. + + Standard: + Fortran 90 and later + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL RANDOM_NUMBER(HARVEST) + + Example: + .. code-block:: fortran + + program test_random_number + REAL :: r(5,5) + CALL RANDOM_NUMBER(r) + end program + + See also: + :ref:`RANDOM_SEED`, + :ref:`RANDOM_INIT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/randomseed.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/randomseed.rst new file mode 100644 index 00000000000..01b2b9fb165 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/randomseed.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RANDOM_SEED, random number generation, seeding, seeding a random number generator + +.. _random_seed: + +RANDOM_SEED --- Initialize a pseudo-random number sequence +********************************************************** + +.. function:: RANDOM_SEED(SIZE, PUT, GET) + + Restarts or queries the state of the pseudorandom number generator used by + ``RANDOM_NUMBER``. + + :param SIZE: + (Optional) Shall be a scalar and of type default + ``INTEGER``, with ``INTENT(OUT)``. It specifies the minimum size + of the arrays used with the :samp:`{PUT}` and :samp:`{GET}` arguments. + + :param PUT: + (Optional) Shall be an array of type default + ``INTEGER`` and rank one. It is ``INTENT(IN)`` and the size of + the array must be larger than or equal to the number returned by the + :samp:`{SIZE}` argument. + + :param GET: + (Optional) Shall be an array of type default + ``INTEGER`` and rank one. It is ``INTENT(OUT)`` and the size + of the array must be larger than or equal to the number returned by + the :samp:`{SIZE}` argument. + + Standard: + Fortran 90 and later + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL RANDOM_SEED([SIZE, PUT, GET]) + + Example: + .. code-block:: fortran + + program test_random_seed + implicit none + integer, allocatable :: seed(:) + integer :: n + + call random_seed(size = n) + allocate(seed(n)) + call random_seed(get=seed) + write (*, *) seed + end program test_random_seed + + See also: + :ref:`RANDOM_NUMBER`, + :ref:`RANDOM_INIT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/range.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/range.rst new file mode 100644 index 00000000000..1bfd6b9e74c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/range.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RANGE, model representation, range + +.. _range: + +RANGE --- Decimal exponent range +******************************** + +.. function:: RANGE(X) + + ``RANGE(X)`` returns the decimal exponent range in the model of the + type of ``X``. + + :param X: + Shall be of type ``INTEGER``, ``REAL`` + or ``COMPLEX``. + + :return: + The return value is of type ``INTEGER`` and of the default integer + kind. + + Standard: + Fortran 90 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = RANGE(X) + + Example: + See ``PRECISION`` for an example. + + See also: + :ref:`SELECTED_REAL_KIND`, + :ref:`PRECISION` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/rank.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/rank.rst new file mode 100644 index 00000000000..4f4ab025812 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/rank.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RANK, rank + +.. _rank: + +RANK --- Rank of a data object +****************************** + +.. function:: RANK(A) + + ``RANK(A)`` returns the rank of a scalar or array data object. + + :param A: + can be of any type + + :return: + The return value is of type ``INTEGER`` and of the default integer + kind. For arrays, their rank is returned; for scalars zero is returned. + + Standard: + Technical Specification (TS) 29113 + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = RANK(A) + + Example: + .. code-block:: fortran + + program test_rank + integer :: a + real, allocatable :: b(:,:) + + print *, rank(a), rank(b) ! Prints: 0 2 + end program test_rank \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/real.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/real.rst new file mode 100644 index 00000000000..0f15f5cb8cc --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/real.rst @@ -0,0 +1,104 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _real: + +.. index:: REAL + +.. index:: REALPART + +.. index:: FLOAT + +.. index:: DFLOAT + +.. index:: FLOATI + +.. index:: FLOATJ + +.. index:: FLOATK + +.. index:: SNGL + +.. index:: conversion, to real + +.. index:: complex numbers, real part + +REAL --- Convert to real type +****************************** + +.. function:: REAL(A [, KIND]) + + ``REAL(A [, KIND])`` converts its argument :samp:`{A}` to a real type. The + ``REALPART`` function is provided for compatibility with :command:`g77`, + and its use is strongly discouraged. + + :param A: + Shall be ``INTEGER``, ``REAL``, or + ``COMPLEX``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + These functions return a ``REAL`` variable or array under + the following rules: + + Standard: + Fortran 77 and later, with :samp:`{KIND}` argument Fortran 90 and later, has GNU extensions + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = REAL(A [, KIND]) + RESULT = REALPART(Z) + + Example: + .. code-block:: fortran + + program test_real + complex :: x = (1.0, 2.0) + print *, real(x), real(x,8), realpart(x) + end program test_real + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``FLOAT(A)`` + - ``INTEGER(4)`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DFLOAT(A)`` + - ``INTEGER(4)`` + - ``REAL(8)`` + - GNU extension + * - ``FLOATI(A)`` + - ``INTEGER(2)`` + - ``REAL(4)`` + - GNU extension (-fdec) + * - ``FLOATJ(A)`` + - ``INTEGER(4)`` + - ``REAL(4)`` + - GNU extension (-fdec) + * - ``FLOATK(A)`` + - ``INTEGER(8)`` + - ``REAL(4)`` + - GNU extension (-fdec) + * - ``SNGL(A)`` + - ``REAL(8)`` + - ``REAL(4)`` + - Fortran 77 and later + + See also: + :ref:`DBLE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/rename.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/rename.rst new file mode 100644 index 00000000000..594cbd91efc --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/rename.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RENAME, file system, rename file + +.. _rename: + +RENAME --- Rename a file +************************ + +.. function:: RENAME(PATH1, PATH2) + + Renames a file from file :samp:`{PATH1}` to :samp:`{PATH2}`. A null + character (``CHAR(0)``) can be used to mark the end of the names in + :samp:`{PATH1}` and :samp:`{PATH2}` ; otherwise, trailing blanks in the file + names are ignored. If the :samp:`{STATUS}` argument is supplied, it + contains 0 on success or a nonzero error code upon return; see + ``rename(2)``. + + :param PATH1: + Shall be of default ``CHARACTER`` type. + + :param PATH2: + Shall be of default ``CHARACTER`` type. + + :param STATUS: + (Optional) Shall be of default ``INTEGER`` type. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL RENAME(PATH1, PATH2 [, STATUS]) + STATUS = RENAME(PATH1, PATH2) + + See also: + :ref:`LINK` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/repeat.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/repeat.rst new file mode 100644 index 00000000000..8fd52f604ac --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/repeat.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: REPEAT, string, repeat, string, concatenate + +.. _repeat: + +REPEAT --- Repeated string concatenation +***************************************** + +.. function:: REPEAT(STRING, NCOPIES) + + Concatenates :samp:`{NCOPIES}` copies of a string. + + :param STRING: + Shall be scalar and of type ``CHARACTER``. + + :param NCOPIES: + Shall be scalar and of type ``INTEGER``. + + :return: + A new scalar of type ``CHARACTER`` built up from :samp:`{NCOPIES}` copies + of :samp:`{STRING}`. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = REPEAT(STRING, NCOPIES) + + Example: + .. code-block:: fortran + + program test_repeat + write(*,*) repeat("x", 5) ! "xxxxx" + end program \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/reshape.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/reshape.rst new file mode 100644 index 00000000000..de975fdc800 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/reshape.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RESHAPE, array, change dimensions, array, transmogrify + +.. _reshape: + +RESHAPE --- Function to reshape an array +**************************************** + +.. function:: RESHAPE(SOURCE, SHAPE, PAD, ORDER) + + Reshapes :samp:`{SOURCE}` to correspond to :samp:`{SHAPE}`. If necessary, + the new array may be padded with elements from :samp:`{PAD}` or permuted + as defined by :samp:`{ORDER}`. + + :param SOURCE: + Shall be an array of any type. + + :param SHAPE: + Shall be of type ``INTEGER`` and an + array of rank one. Its values must be positive or zero. + + :param PAD: + (Optional) shall be an array of the same + type as :samp:`{SOURCE}`. + + :param ORDER: + (Optional) shall be of type ``INTEGER`` + and an array of the same shape as :samp:`{SHAPE}`. Its values shall + be a permutation of the numbers from 1 to n, where n is the size of + :samp:`{SHAPE}`. If :samp:`{ORDER}` is absent, the natural ordering shall + be assumed. + + :return: + The result is an array of shape :samp:`{SHAPE}` with the same type as + :samp:`{SOURCE}`. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER]) + + Example: + .. code-block:: fortran + + PROGRAM test_reshape + INTEGER, DIMENSION(4) :: x + WRITE(*,*) SHAPE(x) ! prints "4" + WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2" + END PROGRAM + + See also: + :ref:`SHAPE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/rrspacing.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/rrspacing.rst new file mode 100644 index 00000000000..c287aaa0536 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/rrspacing.rst @@ -0,0 +1,38 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: RRSPACING, real number, relative spacing, floating point, relative spacing + +.. _rrspacing: + +RRSPACING --- Reciprocal of the relative spacing +************************************************ + +.. function:: RRSPACING(X) + + ``RRSPACING(X)`` returns the reciprocal of the relative spacing of + model numbers near :samp:`{X}`. + + :param X: + Shall be of type ``REAL``. + + :return: + The return value is of the same type and kind as :samp:`{X}`. + The value returned is equal to + ``ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)``. + + Standard: + Fortran 90 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = RRSPACING(X) + + See also: + :ref:`SPACING` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/rshift.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/rshift.rst new file mode 100644 index 00000000000..34d0c6d1d54 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/rshift.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _rshift: + +RSHIFT --- Right shift bits +*************************** + +.. index:: RSHIFT, bits, shift right + +.. function:: RSHIFT(I, SHIFT) + + ``RSHIFT`` returns a value corresponding to :samp:`{I}` with all of the + bits shifted right by :samp:`{SHIFT}` places. :samp:`{SHIFT}` shall be + nonnegative and less than or equal to ``BIT_SIZE(I)``, otherwise + the result value is undefined. Bits shifted out from the right end + are lost. The fill is arithmetic: the bits shifted in from the left + end are equal to the leftmost bit, which in two's complement + representation is the sign bit. + + :param I: + The type shall be ``INTEGER``. + + :param SHIFT: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` and of the same kind as + :samp:`{I}`. + + Standard: + GNU extension + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = RSHIFT(I, SHIFT) + + See also: + :ref:`ISHFT`, + :ref:`ISHFTC`, + :ref:`LSHIFT`, + :ref:`SHIFTA`, + :ref:`SHIFTR`, + :ref:`SHIFTL` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/sametypeas.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/sametypeas.rst new file mode 100644 index 00000000000..9f19b37c846 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/sametypeas.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SAME_TYPE_AS + +.. _same_type_as: + +SAME_TYPE_AS --- Query dynamic types for equality +************************************************** + +.. function:: SAME_TYPE_AS(A, B) + + Query dynamic types for equality. + + :param A: + Shall be an object of extensible declared type or + unlimited polymorphic. + + :param B: + Shall be an object of extensible declared type or + unlimited polymorphic. + + :return: + The return value is a scalar of type default logical. It is true if and + only if the dynamic type of A is the same as the dynamic type of B. + + Standard: + Fortran 2003 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = SAME_TYPE_AS(A, B) + + See also: + :ref:`EXTENDS_TYPE_OF` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/scale.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/scale.rst new file mode 100644 index 00000000000..96ba1cffd71 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/scale.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SCALE, real number, scale, floating point, scale + +.. _scale: + +SCALE --- Scale a real value +**************************** + +.. function:: SCALE(X,I) + + ``SCALE(X,I)`` returns ``X * RADIX(X)**I``. + + :param X: + The type of the argument shall be a ``REAL``. + + :param I: + The type of the argument shall be a ``INTEGER``. + + :return: + The return value is of the same type and kind as :samp:`{X}`. + Its value is ``X * RADIX(X)**I``. + + Standard: + Fortran 90 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = SCALE(X, I) + + Example: + .. code-block:: fortran + + program test_scale + real :: x = 178.1387e-4 + integer :: i = 5 + print *, scale(x,i), x*radix(x)**i + end program test_scale \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/scan.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/scan.rst new file mode 100644 index 00000000000..20d4a869f57 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/scan.rst @@ -0,0 +1,57 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SCAN, string, find subset + +.. _scan: + +SCAN --- Scan a string for the presence of a set of characters +************************************************************** + +.. function:: SCAN(STRING, SET, BACK , KIND) + + Scans a :samp:`{STRING}` for any of the characters in a :samp:`{SET}` + of characters. + + :param STRING: + Shall be of type ``CHARACTER``. + + :param SET: + Shall be of type ``CHARACTER``. + + :param BACK: + (Optional) shall be of type ``LOGICAL``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + + Standard: + Fortran 90 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = SCAN(STRING, SET[, BACK [, KIND]]) + + Example: + .. code-block:: fortran + + PROGRAM test_scan + WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O' + WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A' + WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none + END PROGRAM + + See also: + :ref:`index-intrinsic`, + :ref:`VERIFY` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/secnds.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/secnds.rst new file mode 100644 index 00000000000..984bef5aa8e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/secnds.rst @@ -0,0 +1,52 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SECNDS, time, elapsed, elapsed time + +.. _secnds: + +SECNDS --- Time function +************************ + +.. function:: SECNDS(X) + + ``SECNDS(X)`` gets the time in seconds from the real-time system clock. + :samp:`{X}` is a reference time, also in seconds. If this is zero, the time in + seconds from midnight is returned. This function is non-standard and its + use is discouraged. + + :param T: + Shall be of type ``REAL(4)``. + + :param X: + Shall be of type ``REAL(4)``. + + :return: + None + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = SECNDS (X) + + Example: + .. code-block:: fortran + + program test_secnds + integer :: i + real(4) :: t1, t2 + print *, secnds (0.0) ! seconds since midnight + t1 = secnds (0.0) ! reference time + do i = 1, 10000000 ! do something + end do + t2 = secnds (t1) ! elapsed time + print *, "Something took ", t2, " seconds." + end program test_secnds \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/second.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/second.rst new file mode 100644 index 00000000000..6c300459df1 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/second.rst @@ -0,0 +1,40 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SECOND, time, elapsed, elapsed time + +.. _second: + +SECOND --- CPU time function +**************************** + +.. function:: SECOND() + + Returns a ``REAL(4)`` value representing the elapsed CPU time in + seconds. This provides the same functionality as the standard + ``CPU_TIME`` intrinsic, and is only included for backwards + compatibility. + + :param TIME: + Shall be of type ``REAL(4)``. + + :return: + In either syntax, :samp:`{TIME}` is set to the process's current runtime in + seconds. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL SECOND(TIME) + TIME = SECOND() + + See also: + :ref:`CPU_TIME` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/selectedcharkind.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/selectedcharkind.rst new file mode 100644 index 00000000000..f5321dda200 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/selectedcharkind.rst @@ -0,0 +1,56 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SELECTED_CHAR_KIND, character kind, kind, character + +.. _selected_char_kind: + +SELECTED_CHAR_KIND --- Choose character kind +******************************************** + +.. function:: SELECTED_CHAR_KIND(NAME) + + ``SELECTED_CHAR_KIND(NAME)`` returns the kind value for the character + set named :samp:`{NAME}`, if a character set with such a name is supported, + or -1 otherwise. Currently, supported character sets include + 'ASCII' and 'DEFAULT', which are equivalent, and 'ISO_10646' + (Universal Character Set, UCS-4) which is commonly known as Unicode. + + :param NAME: + Shall be a scalar and of the default character type. + + Standard: + Fortran 2003 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = SELECTED_CHAR_KIND(NAME) + + Example: + .. code-block:: fortran + + program character_kind + use iso_fortran_env + implicit none + integer, parameter :: ascii = selected_char_kind ("ascii") + integer, parameter :: ucs4 = selected_char_kind ('ISO_10646') + + character(kind=ascii, len=26) :: alphabet + character(kind=ucs4, len=30) :: hello_world + + alphabet = ascii_"abcdefghijklmnopqrstuvwxyz" + hello_world = ucs4_'Hello World and Ni Hao -- ' & + // char (int (z'4F60'), ucs4) & + // char (int (z'597D'), ucs4) + + write (*,*) alphabet + + open (output_unit, encoding='UTF-8') + write (*,*) trim (hello_world) + end program character_kind \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/selectedintkind.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/selectedintkind.rst new file mode 100644 index 00000000000..6e302d1f367 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/selectedintkind.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SELECTED_INT_KIND, integer kind, kind, integer + +.. _selected_int_kind: + +SELECTED_INT_KIND --- Choose integer kind +***************************************** + +.. function:: SELECTED_INT_KIND(R) + + ``SELECTED_INT_KIND(R)`` return the kind value of the smallest integer + type that can represent all values ranging from -10^R (exclusive) + to 10^R (exclusive). If there is no integer kind that accommodates + this range, ``SELECTED_INT_KIND`` returns -1. + + :param R: + Shall be a scalar and of type ``INTEGER``. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = SELECTED_INT_KIND(R) + + Example: + .. code-block:: fortran + + program large_integers + integer,parameter :: k5 = selected_int_kind(5) + integer,parameter :: k15 = selected_int_kind(15) + integer(kind=k5) :: i5 + integer(kind=k15) :: i15 + + print *, huge(i5), huge(i15) + + ! The following inequalities are always true + print *, huge(i5) >= 10_k5**5-1 + print *, huge(i15) >= 10_k15**15-1 + end program large_integers \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/selectedrealkind.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/selectedrealkind.rst new file mode 100644 index 00000000000..bf540f959e7 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/selectedrealkind.rst @@ -0,0 +1,67 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SELECTED_REAL_KIND, real kind, kind, real, radix, real + +.. _selected_real_kind: + +SELECTED_REAL_KIND --- Choose real kind +*************************************** + +.. function:: SELECTED_REAL_KIND(P,R) + + ``SELECTED_REAL_KIND(P,R)`` returns the kind value of a real data type + with decimal precision of at least ``P`` digits, exponent range of + at least ``R``, and with a radix of ``RADIX``. + + :param P: + (Optional) shall be a scalar and of type ``INTEGER``. + + :param R: + (Optional) shall be a scalar and of type ``INTEGER``. + + :param RADIX: + (Optional) shall be a scalar and of type ``INTEGER``. + + :return: + ``SELECTED_REAL_KIND`` returns the value of the kind type parameter of + a real data type with decimal precision of at least ``P`` digits, a + decimal exponent range of at least ``R``, and with the requested + ``RADIX``. If the ``RADIX`` parameter is absent, real kinds with + any radix can be returned. If more than one real data type meet the + criteria, the kind of the data type with the smallest decimal precision + is returned. If no real data type matches the criteria, the result is + + Standard: + Fortran 90 and later, with ``RADIX`` Fortran 2008 or later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = SELECTED_REAL_KIND([P, R, RADIX]) + + Example: + .. code-block:: fortran + + program real_kinds + integer,parameter :: p6 = selected_real_kind(6) + integer,parameter :: p10r100 = selected_real_kind(10,100) + integer,parameter :: r400 = selected_real_kind(r=400) + real(kind=p6) :: x + real(kind=p10r100) :: y + real(kind=r400) :: z + + print *, precision(x), range(x) + print *, precision(y), range(y) + print *, precision(z), range(z) + end program real_kinds + + See also: + :ref:`PRECISION`, + :ref:`RANGE`, + :ref:`RADIX` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/setexponent.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/setexponent.rst new file mode 100644 index 00000000000..2769cf9e53c --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/setexponent.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SET_EXPONENT, real number, set exponent, floating point, set exponent + +.. _set_exponent: + +SET_EXPONENT --- Set the exponent of the model +********************************************** + +.. function:: SET_EXPONENT(X, I) + + ``SET_EXPONENT(X, I)`` returns the real number whose fractional part + is that of :samp:`{X}` and whose exponent part is :samp:`{I}`. + + :param X: + Shall be of type ``REAL``. + + :param I: + Shall be of type ``INTEGER``. + + :return: + The return value is of the same type and kind as :samp:`{X}`. + The real number whose fractional part + is that of :samp:`{X}` and whose exponent part if :samp:`{I}` is returned; + it is ``FRACTION(X) * RADIX(X)**I``. + + Standard: + Fortran 90 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = SET_EXPONENT(X, I) + + Example: + .. code-block:: fortran + + PROGRAM test_setexp + REAL :: x = 178.1387e-4 + INTEGER :: i = 17 + PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i + END PROGRAM \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/shape.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/shape.rst new file mode 100644 index 00000000000..33b1cce85fa --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/shape.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SHAPE, array, shape + +.. _shape: + +SHAPE --- Determine the shape of an array +***************************************** + +.. function:: SHAPE(SOURCE , KIND) + + Determines the shape of an array. + + :param SOURCE: + Shall be an array or scalar of any type. + If :samp:`{SOURCE}` is a pointer it must be associated and allocatable + arrays must be allocated. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + An ``INTEGER`` array of rank one with as many elements as :samp:`{SOURCE}` + has dimensions. The elements of the resulting array correspond to the extend + of :samp:`{SOURCE}` along the respective dimensions. If :samp:`{SOURCE}` is a scalar, + the result is the rank one array of size zero. If :samp:`{KIND}` is absent, the + return value has the default integer kind otherwise the specified kind. + + Standard: + Fortran 90 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = SHAPE(SOURCE [, KIND]) + + Example: + .. code-block:: fortran + + PROGRAM test_shape + INTEGER, DIMENSION(-1:1, -1:2) :: A + WRITE(*,*) SHAPE(A) ! (/ 3, 4 /) + WRITE(*,*) SIZE(SHAPE(42)) ! (/ /) + END PROGRAM + + See also: + :ref:`RESHAPE`, + :ref:`SIZE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/shifta.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/shifta.rst new file mode 100644 index 00000000000..e897cbecab4 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/shifta.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _shifta: + +SHIFTA --- Right shift with fill +******************************** + +.. index:: SHIFTA, bits, shift right, shift, right with fill + +.. function:: SHIFTA(I, SHIFT) + + ``SHIFTA`` returns a value corresponding to :samp:`{I}` with all of the + bits shifted right by :samp:`{SHIFT}` places. :samp:`{SHIFT}` that be + nonnegative and less than or equal to ``BIT_SIZE(I)``, otherwise + the result value is undefined. Bits shifted out from the right end + are lost. The fill is arithmetic: the bits shifted in from the left + end are equal to the leftmost bit, which in two's complement + representation is the sign bit. + + :param I: + The type shall be ``INTEGER``. + + :param SHIFT: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` and of the same kind as + :samp:`{I}`. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = SHIFTA(I, SHIFT) + + See also: + :ref:`SHIFTL`, + :ref:`SHIFTR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/shiftl.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/shiftl.rst new file mode 100644 index 00000000000..5d160cae37d --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/shiftl.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _shiftl: + +SHIFTL --- Left shift +********************* + +.. index:: SHIFTL, bits, shift left, shift, left + +.. function:: SHIFTL(I, SHIFT) + + ``SHIFTL`` returns a value corresponding to :samp:`{I}` with all of the + bits shifted left by :samp:`{SHIFT}` places. :samp:`{SHIFT}` shall be + nonnegative and less than or equal to ``BIT_SIZE(I)``, otherwise + the result value is undefined. Bits shifted out from the left end are + lost, and bits shifted in from the right end are set to 0. + + :param I: + The type shall be ``INTEGER``. + + :param SHIFT: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` and of the same kind as + :samp:`{I}`. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = SHIFTL(I, SHIFT) + + See also: + :ref:`SHIFTA`, + :ref:`SHIFTR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/shiftr.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/shiftr.rst new file mode 100644 index 00000000000..6b127742ec1 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/shiftr.rst @@ -0,0 +1,44 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _shiftr: + +SHIFTR --- Right shift +********************** + +.. index:: SHIFTR, bits, shift right, shift, right + +.. function:: SHIFTR(I, SHIFT) + + ``SHIFTR`` returns a value corresponding to :samp:`{I}` with all of the + bits shifted right by :samp:`{SHIFT}` places. :samp:`{SHIFT}` shall be + nonnegative and less than or equal to ``BIT_SIZE(I)``, otherwise + the result value is undefined. Bits shifted out from the right end + are lost, and bits shifted in from the left end are set to 0. + + :param I: + The type shall be ``INTEGER``. + + :param SHIFT: + The type shall be ``INTEGER``. + + :return: + The return value is of type ``INTEGER`` and of the same kind as + :samp:`{I}`. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = SHIFTR(I, SHIFT) + + See also: + :ref:`SHIFTA`, + :ref:`SHIFTL` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/sign.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/sign.rst new file mode 100644 index 00000000000..04d00436e95 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/sign.rst @@ -0,0 +1,78 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _sign: + +.. index:: SIGN + +.. index:: ISIGN + +.. index:: DSIGN + +.. index:: sign copying + +SIGN --- Sign copying function +****************************** + +.. function:: SIGN(A,B) + + ``SIGN(A,B)`` returns the value of :samp:`{A}` with the sign of :samp:`{B}`. + + :param A: + Shall be of type ``INTEGER`` or ``REAL`` + + :param B: + Shall be of the same type and kind as :samp:`{A}`. + + :return: + The kind of the return value is that of :samp:`{A}` and :samp:`{B}`. + If B \ge 0 then the result is ``ABS(A)``, else + it is ``-ABS(A)``. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = SIGN(A, B) + + Example: + .. code-block:: fortran + + program test_sign + print *, sign(-12,1) + print *, sign(-12,0) + print *, sign(-12,-1) + + print *, sign(-12.,1.) + print *, sign(-12.,0.) + print *, sign(-12.,-1.) + end program test_sign + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Arguments + - Return type + - Standard + + * - ``SIGN(A,B)`` + - ``REAL(4) A, B`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``ISIGN(A,B)`` + - ``INTEGER(4) A, B`` + - ``INTEGER(4)`` + - Fortran 77 and later + * - ``DSIGN(A,B)`` + - ``REAL(8) A, B`` + - ``REAL(8)`` + - Fortran 77 and later \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/signal.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/signal.rst new file mode 100644 index 00000000000..0ae2b3b87c5 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/signal.rst @@ -0,0 +1,59 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _signal: + +SIGNAL --- Signal handling subroutine (or function) +*************************************************** + +.. index:: SIGNAL, system, signal handling + +.. function:: SIGNAL(NUMBER, HANDLER, STATUS) + + ``SIGNAL(NUMBER, HANDLER [, STATUS])`` causes external subroutine + :samp:`{HANDLER}` to be executed with a single integer argument when signal + :samp:`{NUMBER}` occurs. If :samp:`{HANDLER}` is an integer, it can be used to + turn off handling of signal :samp:`{NUMBER}` or revert to its default + action. See ``signal(2)``. + + :param NUMBER: + Shall be a scalar integer, with ``INTENT(IN)`` + + :param HANDLER: + Signal handler (``INTEGER FUNCTION`` or + ``SUBROUTINE``) or dummy/global ``INTEGER`` scalar. + ``INTEGER``. It is ``INTENT(IN)``. + + :param STATUS: + (Optional) :samp:`{STATUS}` shall be a scalar + integer. It has ``INTENT(OUT)``. + + :return: + The ``SIGNAL`` function returns the value returned by ``signal(2)``. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL SIGNAL(NUMBER, HANDLER [, STATUS]) + STATUS = SIGNAL(NUMBER, HANDLER) + + Example: + .. code-block:: fortran + + program test_signal + intrinsic signal + external handler_print + + call signal (12, handler_print) + call signal (10, 1) + + call sleep (30) + end program test_signal \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/sin.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/sin.rst new file mode 100644 index 00000000000..264f57ffb78 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/sin.rst @@ -0,0 +1,89 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _sin: + +.. index:: SIN + +.. index:: DSIN + +.. index:: CSIN + +.. index:: ZSIN + +.. index:: CDSIN + +.. index:: trigonometric function, sine + +.. index:: sine + +SIN --- Sine function +********************** + +.. function:: SIN(X) + + ``SIN(X)`` computes the sine of :samp:`{X}`. + + :param X: + The type shall be ``REAL`` or + ``COMPLEX``. + + :return: + The return value has same type and kind as :samp:`{X}`. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = SIN(X) + + Example: + .. code-block:: fortran + + program test_sin + real :: x = 0.0 + x = sin(x) + end program test_sin + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``SIN(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DSIN(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 77 and later + * - ``CSIN(X)`` + - ``COMPLEX(4) X`` + - ``COMPLEX(4)`` + - Fortran 77 and later + * - ``ZSIN(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension + * - ``CDSIN(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension + + See also: + Inverse function: + :ref:`ASIN` + Degrees function: + :ref:`SIND` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/sind.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/sind.rst new file mode 100644 index 00000000000..8cafb1026b4 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/sind.rst @@ -0,0 +1,89 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _sind: + +.. index:: SIND + +.. index:: DSIND + +.. index:: CSIND + +.. index:: ZSIND + +.. index:: CDSIND + +.. index:: trigonometric function, sine, degrees + +.. index:: sine, degrees + +SIND --- Sine function, degrees +******************************* + +.. function:: SIND(X) + + ``SIND(X)`` computes the sine of :samp:`{X}` in degrees. + + :param X: + The type shall be ``REAL`` or + ``COMPLEX``. + + :return: + The return value has same type and kind as :samp:`{X}`, and its value is in degrees. + + Standard: + GNU extension, enabled with :option:`-fdec-math`. + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = SIND(X) + + Example: + .. code-block:: fortran + + program test_sind + real :: x = 0.0 + x = sind(x) + end program test_sind + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``SIND(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - GNU extension + * - ``DSIND(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension + * - ``CSIND(X)`` + - ``COMPLEX(4) X`` + - ``COMPLEX(4)`` + - GNU extension + * - ``ZSIND(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension + * - ``CDSIND(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension + + See also: + Inverse function: + :ref:`ASIND` + Radians function: + :ref:`SIN` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/sinh.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/sinh.rst new file mode 100644 index 00000000000..f7483619465 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/sinh.rst @@ -0,0 +1,66 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _sinh: + +.. index:: SINH + +.. index:: DSINH + +.. index:: hyperbolic sine + +.. index:: hyperbolic function, sine + +.. index:: sine, hyperbolic + +SINH --- Hyperbolic sine function +********************************** + +.. function:: SINH(X) + + ``SINH(X)`` computes the hyperbolic sine of :samp:`{X}`. + + :param X: + The type shall be ``REAL`` or ``COMPLEX``. + + :return: + The return value has same type and kind as :samp:`{X}`. + + Standard: + Fortran 90 and later, for a complex argument Fortran 2008 or later, has + a GNU extension + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = SINH(X) + + Example: + .. code-block:: fortran + + program test_sinh + real(8) :: x = - 1.0_8 + x = sinh(x) + end program test_sinh + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``DSINH(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 90 and later + + See also: + :ref:`ASINH` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/size.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/size.rst new file mode 100644 index 00000000000..6196a1a0822 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/size.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SIZE, array, size, array, number of elements, array, count elements + +.. _size: + +SIZE --- Determine the size of an array +*************************************** + +.. function:: SIZE(ARRAY, DIM , KIND) + + Determine the extent of :samp:`{ARRAY}` along a specified dimension :samp:`{DIM}`, + or the total number of elements in :samp:`{ARRAY}` if :samp:`{DIM}` is absent. + + :param ARRAY: + Shall be an array of any type. If :samp:`{ARRAY}` is + a pointer it must be associated and allocatable arrays must be allocated. + + :param DIM: + (Optional) shall be a scalar of type ``INTEGER`` + and its value shall be in the range from 1 to n, where n equals the rank + of :samp:`{ARRAY}`. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + + Standard: + Fortran 90 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = SIZE(ARRAY[, DIM [, KIND]]) + + Example: + .. code-block:: fortran + + PROGRAM test_size + WRITE(*,*) SIZE((/ 1, 2 /)) ! 2 + END PROGRAM + + See also: + :ref:`SHAPE`, + :ref:`RESHAPE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/sizeof.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/sizeof.rst new file mode 100644 index 00000000000..8870efc57c6 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/sizeof.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SIZEOF, expression size, size of an expression + +.. _sizeof: + +SIZEOF --- Size in bytes of an expression +***************************************** + +.. function:: SIZEOF(X) + + ``SIZEOF(X)`` calculates the number of bytes of storage the + expression ``X`` occupies. + + :param X: + The argument shall be of any type, rank or shape. + + :return: + The return value is of type integer and of the system-dependent kind + :samp:`{C_SIZE_T}` (from the :samp:`{ISO_C_BINDING}` module). Its value is the + number of bytes occupied by the argument. If the argument has the + ``POINTER`` attribute, the number of bytes of the storage area pointed + to is returned. If the argument is of a derived type with ``POINTER`` + or ``ALLOCATABLE`` components, the return value does not account for + the sizes of the data pointed to by these components. If the argument is + polymorphic, the size according to the dynamic type is returned. The argument + may not be a procedure or procedure pointer. Note that the code assumes for + arrays that those are contiguous; for contiguous arrays, it returns the + storage or an array element multiplied by the size of the array. + + Standard: + GNU extension + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + N = SIZEOF(X) + + Example: + .. code-block:: fortran + + integer :: i + real :: r, s(5) + print *, (sizeof(s)/sizeof(r) == 5) + end + + The example will print ``.TRUE.`` unless you are using a platform + where default ``REAL`` variables are unusually padded. + + See also: + :ref:`C_SIZEOF`, + :ref:`STORAGE_SIZE` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/sleep.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/sleep.rst new file mode 100644 index 00000000000..d87a498e404 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/sleep.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SLEEP, delayed execution + +.. _sleep: + +SLEEP --- Sleep for the specified number of seconds +*************************************************** + +.. function:: SLEEP(SECONDS) + + Calling this subroutine causes the process to pause for :samp:`{SECONDS}` seconds. + + :param SECONDS: + The type shall be of default ``INTEGER``. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL SLEEP(SECONDS) + + Example: + .. code-block:: fortran + + program test_sleep + call sleep(5) + end \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/spacing.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/spacing.rst new file mode 100644 index 00000000000..3cc0a861ed9 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/spacing.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SPACING, real number, relative spacing, floating point, relative spacing + +.. _spacing: + +SPACING --- Smallest distance between two numbers of a given type +***************************************************************** + +.. function:: SPACING(X) + + Determines the distance between the argument :samp:`{X}` and the nearest + adjacent number of the same type. + + :param X: + Shall be of type ``REAL``. + + :return: + The result is of the same type as the input argument :samp:`{X}`. + + Standard: + Fortran 90 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = SPACING(X) + + Example: + .. code-block:: fortran + + PROGRAM test_spacing + INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37) + INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200) + + WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686 + WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686 + END PROGRAM + + See also: + :ref:`RRSPACING` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/spread.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/spread.rst new file mode 100644 index 00000000000..a0d914fa901 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/spread.rst @@ -0,0 +1,54 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SPREAD, array, increase dimension, array, duplicate elements, array, duplicate dimensions + +.. _spread: + +SPREAD --- Add a dimension to an array +************************************** + +.. function:: SPREAD(SOURCE, DIM, NCOPIES) + + Replicates a :samp:`{SOURCE}` array :samp:`{NCOPIES}` times along a specified + dimension :samp:`{DIM}`. + + :param SOURCE: + Shall be a scalar or an array of any type and + a rank less than seven. + + :param DIM: + Shall be a scalar of type ``INTEGER`` with a + value in the range from 1 to n+1, where n equals the rank of :samp:`{SOURCE}`. + + :param NCOPIES: + Shall be a scalar of type ``INTEGER``. + + :return: + The result is an array of the same type as :samp:`{SOURCE}` and has rank n+1 + where n equals the rank of :samp:`{SOURCE}`. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = SPREAD(SOURCE, DIM, NCOPIES) + + Example: + .. code-block:: fortran + + PROGRAM test_spread + INTEGER :: a = 1, b(2) = (/ 1, 2 /) + WRITE(*,*) SPREAD(A, 1, 2) ! "1 1" + WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2" + END PROGRAM + + See also: + :ref:`UNPACK` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/sqrt.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/sqrt.rst new file mode 100644 index 00000000000..0acfabcd90d --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/sqrt.rst @@ -0,0 +1,86 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _sqrt: + +.. index:: SQRT + +.. index:: DSQRT + +.. index:: CSQRT + +.. index:: ZSQRT + +.. index:: CDSQRT + +.. index:: root + +.. index:: square-root + +SQRT --- Square-root function +***************************** + +.. function:: SQRT(X) + + ``SQRT(X)`` computes the square root of :samp:`{X}`. + + :param X: + The type shall be ``REAL`` or + ``COMPLEX``. + + :return: + The return value is of type ``REAL`` or ``COMPLEX``. + The kind type parameter is the same as :samp:`{X}`. + + Standard: + Fortran 77 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = SQRT(X) + + Example: + .. code-block:: fortran + + program test_sqrt + real(8) :: x = 2.0_8 + complex :: z = (1.0, 2.0) + x = sqrt(x) + z = sqrt(z) + end program test_sqrt + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``SQRT(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DSQRT(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 77 and later + * - ``CSQRT(X)`` + - ``COMPLEX(4) X`` + - ``COMPLEX(4)`` + - Fortran 77 and later + * - ``ZSQRT(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension + * - ``CDSQRT(X)`` + - ``COMPLEX(8) X`` + - ``COMPLEX(8)`` + - GNU extension \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/srand.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/srand.rst new file mode 100644 index 00000000000..3c74d887add --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/srand.rst @@ -0,0 +1,53 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _srand: + +SRAND --- Reinitialize the random number generator +************************************************** + +.. index:: SRAND, random number generation, seeding, seeding a random number generator + +.. function:: SRAND(SEED) + + ``SRAND`` reinitializes the pseudo-random number generator + called by ``RAND`` and ``IRAND``. The new seed used by the + generator is specified by the required argument :samp:`{SEED}`. + + :param SEED: + Shall be a scalar ``INTEGER(kind=4)``. + + :return: + Does not return anything. + + Standard: + GNU extension + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL SRAND(SEED) + + Example: + See ``RAND`` and ``IRAND`` for examples. + + Notes: + The Fortran standard specifies the intrinsic subroutines + ``RANDOM_SEED`` to initialize the pseudo-random number + generator and ``RANDOM_NUMBER`` to generate pseudo-random numbers. + These subroutines should be used in new codes. + + Please note that in GNU Fortran, these two sets of intrinsics (``RAND``, + ``IRAND`` and ``SRAND`` on the one hand, ``RANDOM_NUMBER`` and + ``RANDOM_SEED`` on the other hand) access two independent + pseudo-random number generators. + + See also: + :ref:`RAND`, + :ref:`RANDOM_SEED`, + :ref:`RANDOM_NUMBER` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/stat.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/stat.rst new file mode 100644 index 00000000000..379854b86af --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/stat.rst @@ -0,0 +1,72 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: STAT, file system, file status + +.. _stat: + +STAT --- Get file status +************************ + +.. function:: STAT(NAME, VALUES) + + This function returns information about a file. No permissions are required on + the file itself, but execute (search) permission is required on all of the + directories in path that lead to the file. + + :param NAME: + The type shall be ``CHARACTER``, of the + default kind and a valid path within the file system. + + :param VALUES: + The type shall be ``INTEGER(4), DIMENSION(13)``. + + :param STATUS: + (Optional) status flag of type ``INTEGER(4)``. Returns 0 + on success and a system specific error code otherwise. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL STAT(NAME, VALUES [, STATUS]) + STATUS = STAT(NAME, VALUES) + + Example: + .. code-block:: fortran + + PROGRAM test_stat + INTEGER, DIMENSION(13) :: buff + INTEGER :: status + + CALL STAT("/etc/passwd", buff, status) + + IF (status == 0) THEN + WRITE (*, FMT="('Device ID:', T30, I19)") buff(1) + WRITE (*, FMT="('Inode number:', T30, I19)") buff(2) + WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3) + WRITE (*, FMT="('Number of links:', T30, I19)") buff(4) + WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5) + WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6) + WRITE (*, FMT="('Device where located:', T30, I19)") buff(7) + WRITE (*, FMT="('File size:', T30, I19)") buff(8) + WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9)) + WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10)) + WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11)) + WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12) + WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13) + END IF + END PROGRAM + + See also: + To stat an open file: + :ref:`FSTAT` + To stat a link: + :ref:`LSTAT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/storagesize.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/storagesize.rst new file mode 100644 index 00000000000..eca012bbdbb --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/storagesize.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: STORAGE_SIZE, storage size + +.. _storage_size: + +STORAGE_SIZE --- Storage size in bits +************************************* + +.. function:: STORAGE_SIZE(A , KIND) + + Returns the storage size of argument :samp:`{A}` in bits. + + :param A: + Shall be a scalar or array of any type. + + :param KIND: + (Optional) shall be a scalar integer constant expression. + + Standard: + Fortran 2008 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = STORAGE_SIZE(A [, KIND]) + + Return Value: + The result is a scalar integer with the kind type parameter specified by KIND + (or default integer type if KIND is missing). The result value is the size + expressed in bits for an element of an array that has the dynamic type and type + parameters of A. + + See also: + :ref:`C_SIZEOF`, + :ref:`SIZEOF` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/sum.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/sum.rst new file mode 100644 index 00000000000..ba4d0bea2d7 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/sum.rst @@ -0,0 +1,56 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SUM, array, sum, array, add elements, array, conditionally add elements, sum array elements + +.. _sum: + +SUM --- Sum of array elements +***************************** + +.. function:: SUM(ARRAY, DIM, MASK) + + Adds the elements of :samp:`{ARRAY}` along dimension :samp:`{DIM}` if + the corresponding element in :samp:`{MASK}` is ``TRUE``. + + :param ARRAY: + Shall be an array of type ``INTEGER``, + ``REAL`` or ``COMPLEX``. + + :param DIM: + (Optional) shall be a scalar of type + ``INTEGER`` with a value in the range from 1 to n, where n + equals the rank of :samp:`{ARRAY}`. + + :param MASK: + (Optional) shall be of type ``LOGICAL`` + and either be a scalar or an array of the same shape as :samp:`{ARRAY}`. + + :return: + The result is of the same type as :samp:`{ARRAY}`. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = SUM(ARRAY[, MASK]) + RESULT = SUM(ARRAY, DIM[, MASK]) + + Example: + .. code-block:: fortran + + PROGRAM test_sum + INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /) + print *, SUM(x) ! all elements, sum = 15 + print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9 + END PROGRAM + + See also: + :ref:`PRODUCT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/symlnk.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/symlnk.rst new file mode 100644 index 00000000000..537560aee35 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/symlnk.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SYMLNK, file system, create link, file system, soft link + +.. _symlnk: + +SYMLNK --- Create a symbolic link +********************************* + +.. function:: SYMLNK(PATH1, PATH2) + + Makes a symbolic link from file :samp:`{PATH1}` to :samp:`{PATH2}`. A null + character (``CHAR(0)``) can be used to mark the end of the names in + :samp:`{PATH1}` and :samp:`{PATH2}` ; otherwise, trailing blanks in the file + names are ignored. If the :samp:`{STATUS}` argument is supplied, it + contains 0 on success or a nonzero error code upon return; see + ``symlink(2)``. If the system does not supply ``symlink(2)``, + ``ENOSYS`` is returned. + + :param PATH1: + Shall be of default ``CHARACTER`` type. + + :param PATH2: + Shall be of default ``CHARACTER`` type. + + :param STATUS: + (Optional) Shall be of default ``INTEGER`` type. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL SYMLNK(PATH1, PATH2 [, STATUS]) + STATUS = SYMLNK(PATH1, PATH2) + + See also: + :ref:`LINK`, + :ref:`UNLINK` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/system.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/system.rst new file mode 100644 index 00000000000..d111b942e9b --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/system.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SYSTEM, system, system call + +.. _system: + +SYSTEM --- Execute a shell command +********************************** + +.. function:: SYSTEM(COMMAND) + + Passes the command :samp:`{COMMAND}` to a shell (see ``system(3)``). If + argument :samp:`{STATUS}` is present, it contains the value returned by + ``system(3)``, which is presumably 0 if the shell command succeeded. + Note that which shell is used to invoke the command is system-dependent + and environment-dependent. + + :param COMMAND: + Shall be of default ``CHARACTER`` type. + + :param STATUS: + (Optional) Shall be of default ``INTEGER`` type. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL SYSTEM(COMMAND [, STATUS]) + STATUS = SYSTEM(COMMAND) + + See also: + :ref:`EXECUTE_COMMAND_LINE`, which is part of the Fortran 2008 standard + and should considered in new code for future portability. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/systemclock.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/systemclock.rst new file mode 100644 index 00000000000..2f4273811cf --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/systemclock.rst @@ -0,0 +1,57 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: SYSTEM_CLOCK, time, clock ticks, clock ticks + +.. _system_clock: + +SYSTEM_CLOCK --- Time function +****************************** + +.. function:: SYSTEM_CLOCK(COUNT, COUNT_RATE, COUNT_MAX) + + Determines the :samp:`{COUNT}` of a processor clock since an unspecified + time in the past modulo :samp:`{COUNT_MAX}`, :samp:`{COUNT_RATE}` determines + the number of clock ticks per second. If the platform supports a + monotonic clock, that clock is used and can, depending on the platform + clock implementation, provide up to nanosecond resolution. If a + monotonic clock is not available, the implementation falls back to a + realtime clock. + + :param COUNT: + (Optional) shall be a scalar of type + ``INTEGER`` with ``INTENT(OUT)``. + + :param COUNT_RATE: + (Optional) shall be a scalar of type + ``INTEGER`` or ``REAL``, with ``INTENT(OUT)``. + + :param COUNT_MAX: + (Optional) shall be a scalar of type + ``INTEGER`` with ``INTENT(OUT)``. + + Standard: + Fortran 90 and later + + Class: + Subroutine + + Syntax: + .. code-block:: fortran + + CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX]) + + Example: + .. code-block:: fortran + + PROGRAM test_system_clock + INTEGER :: count, count_rate, count_max + CALL SYSTEM_CLOCK(count, count_rate, count_max) + WRITE(*,*) count, count_rate, count_max + END PROGRAM + + See also: + :ref:`DATE_AND_TIME`, + :ref:`CPU_TIME` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/tan.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/tan.rst new file mode 100644 index 00000000000..3788b2ae29e --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/tan.rst @@ -0,0 +1,70 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _tan: + +.. index:: TAN + +.. index:: DTAN + +.. index:: trigonometric function, tangent + +.. index:: tangent + +TAN --- Tangent function +************************ + +.. function:: TAN(X) + + ``TAN(X)`` computes the tangent of :samp:`{X}`. + + :param X: + The type shall be ``REAL`` or ``COMPLEX``. + + :return: + The return value has same type and kind as :samp:`{X}`, and its value is in radians. + + Standard: + Fortran 77 and later, for a complex argument Fortran 2008 or later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = TAN(X) + + Example: + .. code-block:: fortran + + program test_tan + real(8) :: x = 0.165_8 + x = tan(x) + end program test_tan + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``TAN(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DTAN(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 77 and later + + See also: + Inverse function: + :ref:`ATAN` + Degrees function: + :ref:`TAND` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/tand.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/tand.rst new file mode 100644 index 00000000000..a720c531b6d --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/tand.rst @@ -0,0 +1,70 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _tand: + +.. index:: TAND + +.. index:: DTAND + +.. index:: trigonometric function, tangent, degrees + +.. index:: tangent, degrees + +TAND --- Tangent function, degrees +********************************** + +.. function:: TAND(X) + + ``TAND(X)`` computes the tangent of :samp:`{X}` in degrees. + + :param X: + The type shall be ``REAL`` or ``COMPLEX``. + + :return: + The return value has same type and kind as :samp:`{X}`, and its value is in degrees. + + Standard: + GNU extension, enabled with :option:`-fdec-math`. + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = TAND(X) + + Example: + .. code-block:: fortran + + program test_tand + real(8) :: x = 0.165_8 + x = tand(x) + end program test_tand + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``TAND(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - GNU extension + * - ``DTAND(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - GNU extension + + See also: + Inverse function: + :ref:`ATAND` + Radians function: + :ref:`TAN` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/tanh.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/tanh.rst new file mode 100644 index 00000000000..d15bd8ce7c8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/tanh.rst @@ -0,0 +1,72 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _tanh: + +.. index:: TANH + +.. index:: DTANH + +.. index:: hyperbolic tangent + +.. index:: hyperbolic function, tangent + +.. index:: tangent, hyperbolic + +TANH --- Hyperbolic tangent function +************************************* + +.. function:: TANH(X) + + ``TANH(X)`` computes the hyperbolic tangent of :samp:`{X}`. + + :param X: + The type shall be ``REAL`` or ``COMPLEX``. + + :return: + The return value has same type and kind as :samp:`{X}`. If :samp:`{X}` is + complex, the imaginary part of the result is in radians. If :samp:`{X}` + is ``REAL``, the return value lies in the range + - 1 \leq tanh(x) \leq 1 . + + Standard: + Fortran 77 and later, for a complex argument Fortran 2008 or later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + X = TANH(X) + + Example: + .. code-block:: fortran + + program test_tanh + real(8) :: x = 2.1_8 + x = tanh(x) + end program test_tanh + + Specific names: + .. list-table:: + :header-rows: 1 + + * - Name + - Argument + - Return type + - Standard + + * - ``TANH(X)`` + - ``REAL(4) X`` + - ``REAL(4)`` + - Fortran 77 and later + * - ``DTANH(X)`` + - ``REAL(8) X`` + - ``REAL(8)`` + - Fortran 77 and later + + See also: + :ref:`ATANH` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/thisimage.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/thisimage.rst new file mode 100644 index 00000000000..8dee8a4a478 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/thisimage.rst @@ -0,0 +1,75 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: THIS_IMAGE, coarray, THIS_IMAGE, images, index of this image + +.. _this_image: + +THIS_IMAGE --- Function that returns the cosubscript index of this image +************************************************************************ + +.. function:: THIS_IMAGE(COARRAY , DIM) + + Returns the cosubscript for this image. + + :param DISTANCE: + (optional, intent(in)) Nonnegative scalar integer + (not permitted together with :samp:`{COARRAY}`). + + :param COARRAY: + Coarray of any type (optional; if :samp:`{DIM}` + present, required). + + :param DIM: + default integer scalar (optional). If present, + :samp:`{DIM}` shall be between one and the corank of :samp:`{COARRAY}`. + + :return: + Default integer. If :samp:`{COARRAY}` is not present, it is scalar; if + :samp:`{DISTANCE}` is not present or has value 0, its value is the image index on + the invoking image for the current team, for values smaller or equal + distance to the initial team, it returns the image index on the ancestor team + which has a distance of :samp:`{DISTANCE}` from the invoking team. If + :samp:`{DISTANCE}` is larger than the distance to the initial team, the image + index of the initial team is returned. Otherwise when the :samp:`{COARRAY}` is + present, if :samp:`{DIM}` is not present, a rank-1 array with corank elements is + returned, containing the cosubscripts for :samp:`{COARRAY}` specifying the invoking + image. If :samp:`{DIM}` is present, a scalar is returned, with the value of + the :samp:`{DIM}` element of ``THIS_IMAGE(COARRAY)``. + + Standard: + Fortran 2008 and later. With :samp:`{DISTANCE}` argument, + Technical Specification (TS) 18508 or later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = THIS_IMAGE() + RESULT = THIS_IMAGE(DISTANCE) + RESULT = THIS_IMAGE(COARRAY [, DIM]) + + Example: + .. code-block:: fortran + + INTEGER :: value[*] + INTEGER :: i + value = THIS_IMAGE() + SYNC ALL + IF (THIS_IMAGE() == 1) THEN + DO i = 1, NUM_IMAGES() + WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i] + END DO + END IF + + ! Check whether the current image is the initial image + IF (THIS_IMAGE(HUGE(1)) /= THIS_IMAGE()) + error stop "something is rotten here" + + See also: + :ref:`NUM_IMAGES`, + :ref:`IMAGE_INDEX` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/time.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/time.rst new file mode 100644 index 00000000000..7b72b73e75a --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/time.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: TIME, time, current, current time + +.. _time: + +TIME --- Time function +********************** + +.. function:: TIME() + + Returns the current time encoded as an integer (in the manner of the + function ``time(3)`` in the C standard library). This value is + suitable for passing to :ref:`CTIME`, :ref:`GMTIME`, and :ref:`LTIME`. + + :return: + The return value is a scalar of type ``INTEGER(4)``. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = TIME() + + See also: + :ref:`DATE_AND_TIME`, + :ref:`CTIME`, + :ref:`GMTIME`, + :ref:`LTIME`, + :ref:`MCLOCK`, + :ref:`TIME8` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/time8.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/time8.rst new file mode 100644 index 00000000000..029393de19f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/time8.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: TIME8, time, current, current time + +.. _time8: + +TIME8 --- Time function (64-bit) +******************************** + +.. function:: TIME8() + + Returns the current time encoded as an integer (in the manner of the + function ``time(3)`` in the C standard library). This value is + suitable for passing to :ref:`CTIME`, :ref:`GMTIME`, and :ref:`LTIME`. + + :return: + The return value is a scalar of type ``INTEGER(8)``. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = TIME8() + + See also: + :ref:`DATE_AND_TIME`, + :ref:`CTIME`, + :ref:`GMTIME`, + :ref:`LTIME`, + :ref:`MCLOCK8`, + :ref:`TIME` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/tiny.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/tiny.rst new file mode 100644 index 00000000000..45c378b56cf --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/tiny.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: TINY, limits, smallest number, model representation, smallest number + +.. _tiny: + +TINY --- Smallest positive number of a real kind +************************************************ + +.. function:: TINY(X) + + ``TINY(X)`` returns the smallest positive (non zero) number + in the model of the type of ``X``. + + :param X: + Shall be of type ``REAL``. + + :return: + The return value is of the same type and kind as :samp:`{X}` + + Standard: + Fortran 90 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = TINY(X) + + Example: + See ``HUGE`` for an example. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/trailz.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/trailz.rst new file mode 100644 index 00000000000..b16b6dee318 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/trailz.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _trailz: + +TRAILZ --- Number of trailing zero bits of an integer +***************************************************** + +.. index:: TRAILZ, zero bits + +.. function:: TRAILZ(I) + + ``TRAILZ`` returns the number of trailing zero bits of an integer. + + :param I: + Shall be of type ``INTEGER``. + + :return: + The type of the return value is the default ``INTEGER``. + If all the bits of ``I`` are zero, the result value is ``BIT_SIZE(I)``. + + Standard: + Fortran 2008 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = TRAILZ(I) + + Example: + .. code-block:: fortran + + PROGRAM test_trailz + WRITE (*,*) TRAILZ(8) ! prints 3 + END PROGRAM + + See also: + :ref:`BIT_SIZE`, + :ref:`LEADZ`, + :ref:`POPPAR`, + :ref:`POPCNT` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/transfer.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/transfer.rst new file mode 100644 index 00000000000..51d8e940e54 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/transfer.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: TRANSFER, bits, move, type cast + +.. _transfer: + +TRANSFER --- Transfer bit patterns +********************************** + +.. function:: TRANSFER(SOURCE, MOLD, SIZE) + + Interprets the bitwise representation of :samp:`{SOURCE}` in memory as if it + is the representation of a variable or array of the same type and type + parameters as :samp:`{MOLD}`. + + :param SOURCE: + Shall be a scalar or an array of any type. + + :param MOLD: + Shall be a scalar or an array of any type. + + :param SIZE: + (Optional) shall be a scalar of type + ``INTEGER``. + + :return: + The result has the same type as :samp:`{MOLD}`, with the bit level + representation of :samp:`{SOURCE}`. If :samp:`{SIZE}` is present, the result is + a one-dimensional array of length :samp:`{SIZE}`. If :samp:`{SIZE}` is absent + but :samp:`{MOLD}` is an array (of any size or shape), the result is a one- + dimensional array of the minimum length needed to contain the entirety + of the bitwise representation of :samp:`{SOURCE}`. If :samp:`{SIZE}` is absent + and :samp:`{MOLD}` is a scalar, the result is a scalar. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = TRANSFER(SOURCE, MOLD[, SIZE]) + + Example: + .. code-block:: fortran + + PROGRAM test_transfer + integer :: x = 2143289344 + print *, transfer(x, 1.0) ! prints "NaN" on i686 + END PROGRAM \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/transpose.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/transpose.rst new file mode 100644 index 00000000000..7eada6942e7 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/transpose.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: TRANSPOSE, array, transpose, matrix, transpose, transpose + +.. _transpose: + +TRANSPOSE --- Transpose an array of rank two +******************************************** + +.. function:: TRANSPOSE(MATRIX) + + Transpose an array of rank two. Element (i, j) of the result has the value + ``MATRIX(j, i)``, for all i, j. + + :param MATRIX: + Shall be an array of any type and have a rank of two. + + :return: + The result has the same type as :samp:`{MATRIX}`, and has shape + ``(/ m, n /)`` if :samp:`{MATRIX}` has shape ``(/ n, m /)``. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = TRANSPOSE(MATRIX) \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/trim.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/trim.rst new file mode 100644 index 00000000000..9e501af2531 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/trim.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: TRIM, string, remove trailing whitespace + +.. _trim: + +TRIM --- Remove trailing blank characters of a string +***************************************************** + +.. function:: TRIM(STRING) + + Removes trailing blank characters of a string. + + :param STRING: + Shall be a scalar of type ``CHARACTER``. + + :return: + A scalar of type ``CHARACTER`` which length is that of :samp:`{STRING}` + less the number of trailing blanks. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = TRIM(STRING) + + Example: + .. code-block:: fortran + + PROGRAM test_trim + CHARACTER(len=10), PARAMETER :: s = "GFORTRAN " + WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks + END PROGRAM + + See also: + :ref:`ADJUSTL`, + :ref:`ADJUSTR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ttynam.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ttynam.rst new file mode 100644 index 00000000000..4ca0572e261 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ttynam.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: TTYNAM, system, terminal + +.. _ttynam: + +TTYNAM --- Get the name of a terminal device +******************************************** + +.. function:: TTYNAM(UNIT) + + Get the name of a terminal device. For more information, + see ``ttyname(3)``. + + :param UNIT: + Shall be a scalar ``INTEGER``. + + :param NAME: + Shall be of type ``CHARACTER``. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL TTYNAM(UNIT, NAME) + NAME = TTYNAM(UNIT) + + Example: + .. code-block:: fortran + + PROGRAM test_ttynam + INTEGER :: unit + DO unit = 1, 10 + IF (isatty(unit=unit)) write(*,*) ttynam(unit) + END DO + END PROGRAM + + See also: + :ref:`ISATTY` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ubound.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ubound.rst new file mode 100644 index 00000000000..81f97053357 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ubound.rst @@ -0,0 +1,52 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: UBOUND, array, upper bound + +.. _ubound: + +UBOUND --- Upper dimension bounds of an array +********************************************* + +.. function:: UBOUND(ARRAY , DIM , KIND) + + Returns the upper bounds of an array, or a single upper bound + along the :samp:`{DIM}` dimension. + + :param ARRAY: + Shall be an array, of any type. + + :param DIM: + (Optional) Shall be a scalar ``INTEGER``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + If :samp:`{DIM}` is absent, the result is an array of the upper bounds of + :samp:`{ARRAY}`. If :samp:`{DIM}` is present, the result is a scalar + corresponding to the upper bound of the array along that dimension. If + :samp:`{ARRAY}` is an expression rather than a whole array or array + structure component, or if it has a zero extent along the relevant + dimension, the upper bound is taken to be the number of elements along + the relevant dimension. + + Standard: + Fortran 90 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = UBOUND(ARRAY [, DIM [, KIND]]) + + See also: + :ref:`LBOUND`, + :ref:`LCOBOUND` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/ucobound.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/ucobound.rst new file mode 100644 index 00000000000..9a0066b96fa --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/ucobound.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: UCOBOUND, coarray, upper bound + +.. _ucobound: + +UCOBOUND --- Upper codimension bounds of an array +************************************************* + +.. function:: UCOBOUND(COARRAY , DIM , KIND) + + Returns the upper cobounds of a coarray, or a single upper cobound + along the :samp:`{DIM}` codimension. + + :param ARRAY: + Shall be an coarray, of any type. + + :param DIM: + (Optional) Shall be a scalar ``INTEGER``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + If :samp:`{DIM}` is absent, the result is an array of the lower cobounds of + :samp:`{COARRAY}`. If :samp:`{DIM}` is present, the result is a scalar + corresponding to the lower cobound of the array along that codimension. + + Standard: + Fortran 2008 and later + + Class: + Inquiry function + + Syntax: + .. code-block:: fortran + + RESULT = UCOBOUND(COARRAY [, DIM [, KIND]]) + + See also: + :ref:`LCOBOUND`, + :ref:`LBOUND` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/umask.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/umask.rst new file mode 100644 index 00000000000..ea94dd6d90f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/umask.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: UMASK, file system, file creation mask + +.. _umask: + +UMASK --- Set the file creation mask +************************************ + +.. function:: UMASK(MASK) + + Sets the file creation mask to :samp:`{MASK}`. If called as a function, it + returns the old value. If called as a subroutine and argument :samp:`{OLD}` + if it is supplied, it is set to the old value. See ``umask(2)``. + + :param MASK: + Shall be a scalar of type ``INTEGER``. + + :param OLD: + (Optional) Shall be a scalar of type + ``INTEGER``. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL UMASK(MASK [, OLD]) + OLD = UMASK(MASK) \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/unlink.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/unlink.rst new file mode 100644 index 00000000000..15a91af4319 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/unlink.rst @@ -0,0 +1,41 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: UNLINK, file system, remove file + +.. _unlink: + +UNLINK --- Remove a file from the file system +********************************************* + +.. function:: UNLINK(PATH) + + Unlinks the file :samp:`{PATH}`. A null character (``CHAR(0)``) can be + used to mark the end of the name in :samp:`{PATH}` ; otherwise, trailing + blanks in the file name are ignored. If the :samp:`{STATUS}` argument is + supplied, it contains 0 on success or a nonzero error code upon return; + see ``unlink(2)``. + + :param PATH: + Shall be of default ``CHARACTER`` type. + + :param STATUS: + (Optional) Shall be of default ``INTEGER`` type. + + Standard: + GNU extension + + Class: + Subroutine, function + + Syntax: + .. code-block:: fortran + + CALL UNLINK(PATH [, STATUS]) + STATUS = UNLINK(PATH) + + See also: + :ref:`LINK`, + :ref:`SYMLNK` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/unpack.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/unpack.rst new file mode 100644 index 00000000000..21078b6dd4f --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/unpack.rst @@ -0,0 +1,57 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: UNPACK, array, unpacking, array, increase dimension, array, scatter elements + +.. _unpack: + +UNPACK --- Unpack an array of rank one into an array +**************************************************** + +.. function:: UNPACK(VECTOR, MASK, FIELD) + + Store the elements of :samp:`{VECTOR}` in an array of higher rank. + + :param VECTOR: + Shall be an array of any type and rank one. It + shall have at least as many elements as :samp:`{MASK}` has ``TRUE`` values. + + :param MASK: + Shall be an array of type ``LOGICAL``. + + :param FIELD: + Shall be of the same type as :samp:`{VECTOR}` and have + the same shape as :samp:`{MASK}`. + + :return: + The resulting array corresponds to :samp:`{FIELD}` with ``TRUE`` elements + of :samp:`{MASK}` replaced by values from :samp:`{VECTOR}` in array element order. + + Standard: + Fortran 90 and later + + Class: + Transformational function + + Syntax: + .. code-block:: fortran + + RESULT = UNPACK(VECTOR, MASK, FIELD) + + Example: + .. code-block:: fortran + + PROGRAM test_unpack + integer :: vector(2) = (/1,1/) + logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /) + integer :: field(2,2) = 0, unity(2,2) + + ! result: unity matrix + unity = unpack(vector, reshape(mask, (/2,2/)), field) + END PROGRAM + + See also: + :ref:`PACK`, + :ref:`SPREAD` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/verify.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/verify.rst new file mode 100644 index 00000000000..e4e9aeb3fd0 --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/verify.rst @@ -0,0 +1,59 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: VERIFY, string, find missing set + +.. _verify: + +VERIFY --- Scan a string for characters not a given set +******************************************************* + +.. function:: VERIFY(STRING, SET, BACK , KIND) + + Verifies that all the characters in :samp:`{STRING}` belong to the set of + characters in :samp:`{SET}`. + + :param STRING: + Shall be of type ``CHARACTER``. + + :param SET: + Shall be of type ``CHARACTER``. + + :param BACK: + (Optional) shall be of type ``LOGICAL``. + + :param KIND: + (Optional) An ``INTEGER`` initialization + expression indicating the kind parameter of the result. + + :return: + The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If + :samp:`{KIND}` is absent, the return value is of default integer kind. + + Standard: + Fortran 90 and later, with :samp:`{KIND}` argument Fortran 2003 and later + + Class: + Elemental function + + Syntax: + .. code-block:: fortran + + RESULT = VERIFY(STRING, SET[, BACK [, KIND]]) + + Example: + .. code-block:: fortran + + PROGRAM test_verify + WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F' + WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R' + WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F' + WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N' + WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none + END PROGRAM + + See also: + :ref:`SCAN`, + :ref:`index-intrinsic` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/intrinsic-procedures/xor.rst b/gcc/fortran/doc/gfortran/intrinsic-procedures/xor.rst new file mode 100644 index 00000000000..fee343ce12a --- /dev/null +++ b/gcc/fortran/doc/gfortran/intrinsic-procedures/xor.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: XOR, bitwise logical exclusive or, logical exclusive or, bitwise + +.. _xor: + +XOR --- Bitwise logical exclusive OR +************************************ + +.. function:: XOR(I, J) + + Bitwise logical exclusive or. + + :param I: + The type shall be either a scalar ``INTEGER`` + type or a scalar ``LOGICAL`` type or a boz-literal-constant. + + :param J: + The type shall be the same as the type of :samp:`{I}` or + a boz-literal-constant. :samp:`{I}` and :samp:`{J}` shall not both be + boz-literal-constants. If either :samp:`{I}` and :samp:`{J}` is a + boz-literal-constant, then the other argument must be a scalar ``INTEGER``. + + :return: + The return type is either a scalar ``INTEGER`` or a scalar + ``LOGICAL``. If the kind type parameters differ, then the + smaller kind type is implicitly converted to larger kind, and the + return has the larger kind. A boz-literal-constant is + converted to an ``INTEGER`` with the kind type parameter of + the other argument as-if a call to :ref:`INT` occurred. + + Standard: + GNU extension + + Class: + Function + + Syntax: + .. code-block:: fortran + + RESULT = XOR(I, J) + + Example: + .. code-block:: fortran + + PROGRAM test_xor + LOGICAL :: T = .TRUE., F = .FALSE. + INTEGER :: a, b + DATA a / Z'F' /, b / Z'3' / + + WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F) + WRITE (*,*) XOR(a, b) + END PROGRAM + + See also: + Fortran 95 elemental function: + :ref:`IEOR` \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/introduction.rst b/gcc/fortran/doc/gfortran/introduction.rst new file mode 100644 index 00000000000..3684e786bcb --- /dev/null +++ b/gcc/fortran/doc/gfortran/introduction.rst @@ -0,0 +1,18 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _introduction: + +Introduction +------------ + +.. The following duplicates the text on the TexInfo table of contents. + +.. toctree:: + :maxdepth: 2 + + about-gnu-fortran + gnu-fortran-and-gcc + standards \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/mixed-language-programming.rst b/gcc/fortran/doc/gfortran/mixed-language-programming.rst new file mode 100644 index 00000000000..506fe0ed446 --- /dev/null +++ b/gcc/fortran/doc/gfortran/mixed-language-programming.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Interoperability, Mixed-language programming + +.. _mixed-language-programming: + +Mixed-Language Programming +-------------------------- + +.. toctree:: + :maxdepth: 2 + + interoperability-with-c + gnu-fortran-compiler-directives + non-fortran-main-program + naming-and-argument-passing-conventions + +This chapter is about mixed-language interoperability, but also +applies if you link Fortran code compiled by different compilers. In +most cases, use of the C Binding features of the Fortran 2003 and +later standards is sufficient. + +For example, it is possible to mix Fortran code with C++ code as well +as C, if you declare the interface functions as ``extern "C"`` on +the C++ side and ``BIND(C)`` on the Fortran side, and follow the +rules for interoperability with C. Note that you cannot manipulate +C++ class objects in Fortran or vice versa except as opaque pointers. + +You can use the :command:`gfortran` command to link both Fortran and +non-Fortran code into the same program, or you can use :command:`gcc` +or :command:`g++` if you also add an explicit :option:`-lgfortran` option +to link with the Fortran library. If your main program is written in +C or some other language instead of Fortran, see +:ref:`non-fortran-main-program`, below. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/naming-and-argument-passing-conventions.rst b/gcc/fortran/doc/gfortran/naming-and-argument-passing-conventions.rst new file mode 100644 index 00000000000..298bf0cacef --- /dev/null +++ b/gcc/fortran/doc/gfortran/naming-and-argument-passing-conventions.rst @@ -0,0 +1,178 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _naming-and-argument-passing-conventions: + +Naming and argument-passing conventions +*************************************** + +This section gives an overview about the naming convention of procedures +and global variables and about the argument passing conventions used by +GNU Fortran. If a C binding has been specified, the naming convention +and some of the argument-passing conventions change. If possible, +mixed-language and mixed-compiler projects should use the better defined +C binding for interoperability. See see :ref:`interoperability-with-c`. + +.. toctree:: + :maxdepth: 2 + + +.. _naming-conventions: + +Naming conventions +^^^^^^^^^^^^^^^^^^ + +According the Fortran standard, valid Fortran names consist of a letter +between ``A`` to ``Z``, ``a`` to ``z``, digits ``0``, +``1`` to ``9`` and underscores (``_``) with the restriction +that names may only start with a letter. As vendor extension, the +dollar sign (``$``) is additionally permitted with the option +:option:`-fdollar-ok`, but not as first character and only if the +target system supports it. + +By default, the procedure name is the lower-cased Fortran name with an +appended underscore (``_``); using :option:`-fno-underscoring` no +underscore is appended while ``-fsecond-underscore`` appends two +underscores. Depending on the target system and the calling convention, +the procedure might be additionally dressed; for instance, on 32bit +Windows with ``stdcall``, an at-sign ``@`` followed by an integer +number is appended. For the changing the calling convention, see +see :ref:`gnu-fortran-compiler-directives`. + +For common blocks, the same convention is used, i.e. by default an +underscore is appended to the lower-cased Fortran name. Blank commons +have the name ``__BLNK__``. + +For procedures and variables declared in the specification space of a +module, the name is formed by ``__``, followed by the lower-cased +module name, ``_MOD_``, and the lower-cased Fortran name. Note that +no underscore is appended. + +.. _argument-passing-conventions: + +Argument passing conventions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Subroutines do not return a value (matching C99's ``void``) while +functions either return a value as specified in the platform ABI or +the result variable is passed as hidden argument to the function and +no result is returned. A hidden result variable is used when the +result variable is an array or of type ``CHARACTER``. + +Arguments are passed according to the platform ABI. In particular, +complex arguments might not be compatible to a struct with two real +components for the real and imaginary part. The argument passing +matches the one of C99's ``_Complex``. Functions with scalar +complex result variables return their value and do not use a +by-reference argument. Note that with the :option:`-ff2c` option, +the argument passing is modified and no longer completely matches +the platform ABI. Some other Fortran compilers use ``f2c`` +semantic by default; this might cause problems with +interoperablility. + +GNU Fortran passes most arguments by reference, i.e. by passing a +pointer to the data. Note that the compiler might use a temporary +variable into which the actual argument has been copied, if required +semantically (copy-in/copy-out). + +For arguments with ``ALLOCATABLE`` and ``POINTER`` +attribute (including procedure pointers), a pointer to the pointer +is passed such that the pointer address can be modified in the +procedure. + +For dummy arguments with the ``VALUE`` attribute: Scalar arguments +of the type ``INTEGER``, ``LOGICAL``, ``REAL`` and +``COMPLEX`` are passed by value according to the platform ABI. +(As vendor extension and not recommended, using ``%VAL()`` in the +call to a procedure has the same effect.) For ``TYPE(C_PTR)`` and +procedure pointers, the pointer itself is passed such that it can be +modified without affecting the caller. + +.. todo:: Document how VALUE is handled for CHARACTER, TYPE, + CLASS and arrays, i.e. whether the copy-in is done in the caller + or in the callee. + +For Boolean (``LOGICAL``) arguments, please note that GCC expects +only the integer value 0 and 1. If a GNU Fortran ``LOGICAL`` +variable contains another integer value, the result is undefined. +As some other Fortran compilers use -1 for ``.TRUE.``, +extra care has to be taken -- such as passing the value as +``INTEGER``. (The same value restriction also applies to other +front ends of GCC, e.g. to GCC's C99 compiler for ``_Bool`` +or GCC's Ada compiler for ``Boolean``.) + +For arguments of ``CHARACTER`` type, the character length is passed +as a hidden argument at the end of the argument list. For +deferred-length strings, the value is passed by reference, otherwise +by value. The character length has the C type ``size_t`` (or +``INTEGER(kind=C_SIZE_T)`` in Fortran). Note that this is +different to older versions of the GNU Fortran compiler, where the +type of the hidden character length argument was a C ``int``. In +order to retain compatibility with older versions, one can e.g. for +the following Fortran procedure + +.. code-block:: fortran + + subroutine fstrlen (s, a) + character(len=*) :: s + integer :: a + print*, len(s) + end subroutine fstrlen + +define the corresponding C prototype as follows: + +.. code-block:: fortran + + #if __GNUC__ > 7 + typedef size_t fortran_charlen_t; + #else + typedef int fortran_charlen_t; + #endif + + void fstrlen_ (char*, int*, fortran_charlen_t); + +In order to avoid such compiler-specific details, for new code it is +instead recommended to use the ISO_C_BINDING feature. + +Note with C binding, ``CHARACTER(len=1)`` result variables are +returned according to the platform ABI and no hidden length argument +is used for dummy arguments; with ``VALUE``, those variables are +passed by value. + +For ``OPTIONAL`` dummy arguments, an absent argument is denoted +by a NULL pointer, except for scalar dummy arguments of type +``INTEGER``, ``LOGICAL``, ``REAL`` and ``COMPLEX`` +which have the ``VALUE`` attribute. For those, a hidden Boolean +argument (``logical(kind=C_bool),value``) is used to indicate +whether the argument is present. + +Arguments which are assumed-shape, assumed-rank or deferred-rank +arrays or, with :option:`-fcoarray=lib`, allocatable scalar coarrays use +an array descriptor. All other arrays pass the address of the +first element of the array. With :option:`-fcoarray=lib`, the token +and the offset belonging to nonallocatable coarrays dummy arguments +are passed as hidden argument along the character length hidden +arguments. The token is an opaque pointer identifying the coarray +and the offset is a passed-by-value integer of kind ``C_PTRDIFF_T``, +denoting the byte offset between the base address of the coarray and +the passed scalar or first element of the passed array. + +The arguments are passed in the following order + +* Result variable, when the function result is passed by reference + +* Character length of the function result, if it is a of type + ``CHARACTER`` and no C binding is used + +* The arguments in the order in which they appear in the Fortran + declaration + +* The present status for optional arguments with value attribute, + which are internally passed by value + +* The character length and/or coarray token and offset for the first + argument which is a ``CHARACTER`` or a nonallocatable coarray dummy + argument, followed by the hidden arguments of the next dummy argument + of such a type \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/non-fortran-main-program.rst b/gcc/fortran/doc/gfortran/non-fortran-main-program.rst new file mode 100644 index 00000000000..91e0ff88432 --- /dev/null +++ b/gcc/fortran/doc/gfortran/non-fortran-main-program.rst @@ -0,0 +1,251 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _non-fortran-main-program: + +Non-Fortran Main Program +************************ + +.. toctree:: + :maxdepth: 2 + + +Even if you are doing mixed-language programming, it is very +likely that you do not need to know or use the information in this +section. Since it is about the internal structure of GNU Fortran, +it may also change in GCC minor releases. + +When you compile a ``PROGRAM`` with GNU Fortran, a function +with the name ``main`` (in the symbol table of the object file) +is generated, which initializes the libgfortran library and then +calls the actual program which uses the name ``MAIN__``, for +historic reasons. If you link GNU Fortran compiled procedures +to, e.g., a C or C++ program or to a Fortran program compiled by +a different compiler, the libgfortran library is not initialized +and thus a few intrinsic procedures do not work properly, e.g. +those for obtaining the command-line arguments. + +Therefore, if your ``PROGRAM`` is not compiled with +GNU Fortran and the GNU Fortran compiled procedures require +intrinsics relying on the library initialization, you need to +initialize the library yourself. Using the default options, +gfortran calls ``_gfortran_set_args`` and +``_gfortran_set_options``. The initialization of the former +is needed if the called procedures access the command line +(and for backtracing); the latter sets some flags based on the +standard chosen or to enable backtracing. In typical programs, +it is not necessary to call any initialization function. + +If your ``PROGRAM`` is compiled with GNU Fortran, you shall +not call any of the following functions. The libgfortran +initialization functions are shown in C syntax but using C +bindings they are also accessible from Fortran. + +.. index:: _gfortran_set_args, libgfortran initialization, set_args + +.. _gfortran_set_args: + +_gfortran_set_args --- Save command-line arguments +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_set_args (int argc, char *argv[]) + + ``_gfortran_set_args`` saves the command-line arguments; this + initialization is required if any of the command-line intrinsics + is called. Additionally, it shall be called if backtracing is + enabled (see ``_gfortran_set_options``). + + :param argc: + number of command line argument strings + + :param argv: + the command-line argument strings; argv[0] + is the pathname of the executable itself. + + :samp:`{Example}:` + + .. code-block:: c + + int main (int argc, char *argv[]) + { + /* Initialize libgfortran. */ + _gfortran_set_args (argc, argv); + return 0; + } + +.. index:: _gfortran_set_options, libgfortran initialization, set_options + +.. _gfortran_set_options: + +_gfortran_set_options --- Set library option flags +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_set_options (int num, int options[]) + + ``_gfortran_set_options`` sets several flags related to the Fortran + standard to be used, whether backtracing should be enabled + and whether range checks should be performed. The syntax allows for + upward compatibility since the number of passed flags is specified; for + non-passed flags, the default value is used. See also + see :ref:`code-gen-options`. Please note that not all flags are actually + used. + + :param num: + number of options passed + + :param argv: + The list of flag values + + :samp:`{option flag list}:` + + .. list-table:: + :widths: 15 85 + + * - :samp:`{option}` [0] + - Allowed standard; can give run-time errors if e.g. an input-output edit descriptor is invalid in a given standard. Possible values are (bitwise or-ed) ``GFC_STD_F77`` (1), ``GFC_STD_F95_OBS`` (2), ``GFC_STD_F95_DEL`` (4), ``GFC_STD_F95`` (8), ``GFC_STD_F2003`` (16), ``GFC_STD_GNU`` (32), ``GFC_STD_LEGACY`` (64), ``GFC_STD_F2008`` (128), ``GFC_STD_F2008_OBS`` (256), ``GFC_STD_F2008_TS`` (512), ``GFC_STD_F2018`` (1024), ``GFC_STD_F2018_OBS`` (2048), and ``GFC_STD=F2018_DEL`` (4096). Default: ``GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_F95 | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F2008_TS | GFC_STD_F2008_OBS | GFC_STD_F77 | GFC_STD_F2018 | GFC_STD_F2018_OBS | GFC_STD_F2018_DEL | GFC_STD_GNU | GFC_STD_LEGACY``. + * - :samp:`{option}` [1] + - Standard-warning flag; prints a warning to standard error. Default: ``GFC_STD_F95_DEL | GFC_STD_LEGACY``. + * - :samp:`{option}` [2] + - If non zero, enable pedantic checking. Default: off. + * - :samp:`{option}` [3] + - Unused. + * - :samp:`{option}` [4] + - If non zero, enable backtracing on run-time errors. Default: off. (Default in the compiler: on.) Note: Installs a signal handler and requires command-line initialization using ``_gfortran_set_args``. + * - :samp:`{option}` [5] + - If non zero, supports signed zeros. Default: enabled. + * - :samp:`{option}` [6] + - Enables run-time checking. Possible values are (bitwise or-ed): GFC_RTCHECK_BOUNDS (1), GFC_RTCHECK_ARRAY_TEMPS (2), GFC_RTCHECK_RECURSION (4), GFC_RTCHECK_DO (8), GFC_RTCHECK_POINTER (16), GFC_RTCHECK_MEM (32), GFC_RTCHECK_BITS (64). Default: disabled. + * - :samp:`{option}` [7] + - Unused. + * - :samp:`{option}` [8] + - Show a warning when invoking ``STOP`` and ``ERROR STOP`` if a floating-point exception occurred. Possible values are (bitwise or-ed) ``GFC_FPE_INVALID`` (1), ``GFC_FPE_DENORMAL`` (2), ``GFC_FPE_ZERO`` (4), ``GFC_FPE_OVERFLOW`` (8), ``GFC_FPE_UNDERFLOW`` (16), ``GFC_FPE_INEXACT`` (32). Default: None (0). (Default in the compiler: ``GFC_FPE_INVALID | GFC_FPE_DENORMAL | GFC_FPE_ZERO | GFC_FPE_OVERFLOW | GFC_FPE_UNDERFLOW``.) + + :samp:`{Example}:` + + .. code-block:: c + + /* Use gfortran 4.9 default options. */ + static int options[] = {68, 511, 0, 0, 1, 1, 0, 0, 31}; + _gfortran_set_options (9, &options); + +.. index:: _gfortran_set_convert, libgfortran initialization, set_convert + +.. _gfortran_set_convert: + +_gfortran_set_convert --- Set endian conversion +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_set_convert (int conv) + + ``_gfortran_set_convert`` set the representation of data for + unformatted files. + + :param conv: + Endian conversion, possible values: + GFC_CONVERT_NATIVE (0, default), GFC_CONVERT_SWAP (1), + GFC_CONVERT_BIG (2), GFC_CONVERT_LITTLE (3). + + :samp:`{Example}:` + + .. code-block:: c + + int main (int argc, char *argv[]) + { + /* Initialize libgfortran. */ + _gfortran_set_args (argc, argv); + _gfortran_set_convert (1); + return 0; + } + +.. index:: _gfortran_set_record_marker, libgfortran initialization, set_record_marker + +.. _gfortran_set_record_marker: + +_gfortran_set_record_marker --- Set length of record markers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_set_record_marker (int val) + + ``_gfortran_set_record_marker`` sets the length of record markers + for unformatted files. + + :param val: + Length of the record marker; valid values + are 4 and 8. Default is 4. + + :samp:`{Example}:` + + .. code-block:: c + + int main (int argc, char *argv[]) + { + /* Initialize libgfortran. */ + _gfortran_set_args (argc, argv); + _gfortran_set_record_marker (8); + return 0; + } + +.. index:: _gfortran_set_fpe, libgfortran initialization, set_fpe + +.. _gfortran_set_fpe: + +_gfortran_set_fpe --- Enable floating point exception traps +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_set_fpe (int val) + + ``_gfortran_set_fpe`` enables floating point exception traps for + the specified exceptions. On most systems, this will result in a + SIGFPE signal being sent and the program being aborted. + + :param option} [0]: + IEEE exceptions. Possible values are + (bitwise or-ed) zero (0, default) no trapping, + ``GFC_FPE_INVALID`` (1), ``GFC_FPE_DENORMAL`` (2), + ``GFC_FPE_ZERO`` (4), ``GFC_FPE_OVERFLOW`` (8), + ``GFC_FPE_UNDERFLOW`` (16), and ``GFC_FPE_INEXACT`` (32). + + :samp:`{Example}:` + + .. code-block:: c + + int main (int argc, char *argv[]) + { + /* Initialize libgfortran. */ + _gfortran_set_args (argc, argv); + /* FPE for invalid operations such as SQRT(-1.0). */ + _gfortran_set_fpe (1); + return 0; + } + +.. index:: _gfortran_set_max_subrecord_length, libgfortran initialization, set_max_subrecord_length + +.. _gfortran_set_max_subrecord_length: + +_gfortran_set_max_subrecord_length --- Set subrecord length +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. function:: void _gfortran_set_max_subrecord_length (int val) + + ``_gfortran_set_max_subrecord_length`` set the maximum length + for a subrecord. This option only makes sense for testing and + debugging of unformatted I/O. + + :param val: + the maximum length for a subrecord; + the maximum permitted value is 2147483639, which is also + the default. + + :samp:`{Example}:` + + .. code-block:: c + + int main (int argc, char *argv[]) + { + /* Initialize libgfortran. */ + _gfortran_set_args (argc, argv); + _gfortran_set_max_subrecord_length (8); + return 0; + } \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/projects.rst b/gcc/fortran/doc/gfortran/projects.rst new file mode 100644 index 00000000000..99d8e1e0a98 --- /dev/null +++ b/gcc/fortran/doc/gfortran/projects.rst @@ -0,0 +1,29 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _projects: + +Projects +******** + +*Help build the test suite* + Solicit more code for donation to the test suite: the more extensive the + testsuite, the smaller the risk of breaking things in the future! We can + keep code private on request. + +*Bug hunting/squishing* + Find bugs and write more test cases! Test cases are especially very + welcome, because it allows us to concentrate on fixing bugs instead of + isolating them. Going through the bugzilla database at + https://gcc.gnu.org/bugzilla/ to reduce testcases posted there and + add more information (for example, for which version does the testcase + work, for which versions does it fail?) is also very helpful. + +*Missing features* + For a larger project, consider working on the missing features required for + Fortran language standards compliance (see :ref:`standards`), or contributing + to the implementation of extensions such as OpenMP (see :ref:`openmp`) or + OpenACC (see :ref:`openacc`) that are under active development. Again, + contributing test cases for these features is useful too! \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime.rst b/gcc/fortran/doc/gfortran/runtime.rst new file mode 100644 index 00000000000..e83c300d982 --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: environment variable + +.. _runtime: + +Runtime: Influencing runtime behavior with environment variables +----------------------------------------------------------------- + +The behavior of the :command:`gfortran` can be influenced by +environment variables. + +Malformed environment variables are silently ignored. + +.. toctree:: + :maxdepth: 2 + + runtime/tmpdir + runtime/gfortranstdinunit + runtime/gfortranstdoutunit + runtime/gfortranstderrunit + runtime/gfortranunbufferedall + runtime/gfortranunbufferedpreconnected + runtime/gfortranshowlocus + runtime/gfortranoptionalplus + runtime/gfortranlistseparator + runtime/gfortranconvertunit + runtime/gfortranerrorbacktrace + runtime/gfortranformattedbuffersize + runtime/gfortranunformattedbuffersize \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/gfortranconvertunit.rst b/gcc/fortran/doc/gfortran/runtime/gfortranconvertunit.rst new file mode 100644 index 00000000000..5ac40f8301e --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/gfortranconvertunit.rst @@ -0,0 +1,97 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfortran_convert_unit: + +GFORTRAN_CONVERT_UNIT---Set conversion for unformatted I/O +********************************************************** + +By setting the :envvar:`GFORTRAN_CONVERT_UNIT` variable, it is possible +to change the representation of data for unformatted files. +The syntax for the :envvar:`GFORTRAN_CONVERT_UNIT` variable for +most systems is: + +.. code-block:: + + GFORTRAN_CONVERT_UNIT: mode | mode ';' exception | exception ; + mode: 'native' | 'swap' | 'big_endian' | 'little_endian' ; + exception: mode ':' unit_list | unit_list ; + unit_list: unit_spec | unit_list unit_spec ; + unit_spec: INTEGER | INTEGER '-' INTEGER ; + +The variable consists of an optional default mode, followed by +a list of optional exceptions, which are separated by semicolons +from the preceding default and each other. Each exception consists +of a format and a comma-separated list of units. Valid values for +the modes are the same as for the ``CONVERT`` specifier: + +* ``NATIVE`` Use the native format. This is the default. + +* ``SWAP`` Swap between little- and big-endian. + +* ``LITTLE_ENDIAN`` Use the little-endian format + for unformatted files. + +* ``BIG_ENDIAN`` Use the big-endian format for unformatted files. + +For POWER systems which support :option:`-mabi=ieeelongdouble`, +there are additional options, which can be combined with the +others with commas. Those are + +* ``R16_IEEE`` Use IEEE 128-bit format for ``REAL(KIND=16)``. + +* ``R16_IBM`` Use IBM ``long double`` format for + ``REAL(KIND=16)``. + +A missing mode for an exception is taken to mean ``BIG_ENDIAN``. +Examples of values for :envvar:`GFORTRAN_CONVERT_UNIT` are: + +* ``'big_endian'`` Do all unformatted I/O in big_endian mode. + +* ``'little_endian;native:10-20,25'`` Do all unformatted I/O + in little_endian mode, except for units 10 to 20 and 25, which are in + native format. + +* ``'10-20'`` Units 10 to 20 are big-endian, the rest is native. + +* ``'big_endian,r16_ibm'`` Do all unformatted I/O in big-endian + mode and use IBM long double for output of ``REAL(KIND=16)`` values. + +Setting the environment variables should be done on the command +line or via the :command:`export` +command for :command:`sh`-compatible shells and via :command:`setenv` +for :command:`csh`-compatible shells. + +Example for :command:`sh`: + +.. code-block:: shell-session + + $ gfortran foo.f90 + $ GFORTRAN_CONVERT_UNIT='big_endian;native:10-20' ./a.out + +Example code for :command:`csh`: + +.. code-block:: shell-session + + % gfortran foo.f90 + % setenv GFORTRAN_CONVERT_UNIT 'big_endian;native:10-20' + % ./a.out + +Using anything but the native representation for unformatted data +carries a significant speed overhead. If speed in this area matters +to you, it is best if you use this only for data that needs to be +portable. + +See :ref:`convert-specifier`, for an alternative way to specify the +data representation for unformatted files. See :ref:`runtime-options`, for +setting a default data representation for the whole program. The +``CONVERT`` specifier overrides the :option:`-fconvert` compile options. + +.. note:: + + The values specified via the GFORTRAN_CONVERT_UNIT + environment variable will override the CONVERT specifier in the + open statement*. This is to give control over data formats to + users who do not have the source code of their program available. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/gfortranerrorbacktrace.rst b/gcc/fortran/doc/gfortran/runtime/gfortranerrorbacktrace.rst new file mode 100644 index 00000000000..9b8c3e7b35b --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/gfortranerrorbacktrace.rst @@ -0,0 +1,16 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfortran_error_backtrace: + +GFORTRAN_ERROR_BACKTRACE---Show backtrace on run-time errors +************************************************************ + +If the :envvar:`GFORTRAN_ERROR_BACKTRACE` variable is set to :samp:`y`, +:samp:`Y` or :samp:`1` (only the first letter is relevant) then a +backtrace is printed when a serious run-time error occurs. To disable +the backtracing, set the variable to :samp:`n`, :samp:`N`, :samp:`0`. +Default is to print a backtrace unless the :option:`-fno-backtrace` +compile option was used. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/gfortranformattedbuffersize.rst b/gcc/fortran/doc/gfortran/runtime/gfortranformattedbuffersize.rst new file mode 100644 index 00000000000..329f9219a75 --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/gfortranformattedbuffersize.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfortran_formatted_buffer_size: + +GFORTRAN_FORMATTED_BUFFER_SIZE---Set buffer size for formatted I/O +****************************************************************** + +The :envvar:`GFORTRAN_FORMATTED_BUFFER_SIZE` environment variable +specifies buffer size in bytes to be used for formatted output. +The default value is 8192. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/gfortranlistseparator.rst b/gcc/fortran/doc/gfortran/runtime/gfortranlistseparator.rst new file mode 100644 index 00000000000..6eb2b184f47 --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/gfortranlistseparator.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfortran_list_separator: + +GFORTRAN_LIST_SEPARATOR---Separator for list output +*************************************************** + +This environment variable specifies the separator when writing +list-directed output. It may contain any number of spaces and +at most one comma. If you specify this on the command line, +be sure to quote spaces, as in + +.. code-block:: shell-session + + $ GFORTRAN_LIST_SEPARATOR=' , ' ./a.out + +when :command:`a.out` is the compiled Fortran program that you want to run. +Default is a single space. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/gfortranoptionalplus.rst b/gcc/fortran/doc/gfortran/runtime/gfortranoptionalplus.rst new file mode 100644 index 00000000000..2f95f9f71eb --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/gfortranoptionalplus.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfortran_optional_plus: + +GFORTRAN_OPTIONAL_PLUS---Print leading + where permitted +******************************************************** + +If the first letter is :samp:`y`, :samp:`Y` or :samp:`1`, +a plus sign is printed +where permitted by the Fortran standard. If the first letter +is :samp:`n`, :samp:`N` or :samp:`0`, a plus sign is not printed +in most cases. Default is not to print plus signs. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/gfortranshowlocus.rst b/gcc/fortran/doc/gfortran/runtime/gfortranshowlocus.rst new file mode 100644 index 00000000000..76564614c56 --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/gfortranshowlocus.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfortran_show_locus: + +GFORTRAN_SHOW_LOCUS---Show location for runtime errors +****************************************************** + +If the first letter is :samp:`y`, :samp:`Y` or :samp:`1`, filename and +line numbers for runtime errors are printed. If the first letter is +:samp:`n`, :samp:`N` or :samp:`0`, do not print filename and line numbers +for runtime errors. The default is to print the location. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/gfortranstderrunit.rst b/gcc/fortran/doc/gfortran/runtime/gfortranstderrunit.rst new file mode 100644 index 00000000000..6a847af72a9 --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/gfortranstderrunit.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfortran_stderr_unit: + +GFORTRAN_STDERR_UNIT---Unit number for standard error +***************************************************** + +This environment variable can be used to select the unit number +preconnected to standard error. This must be a positive integer. +The default value is 0. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/gfortranstdinunit.rst b/gcc/fortran/doc/gfortran/runtime/gfortranstdinunit.rst new file mode 100644 index 00000000000..362ddbd9013 --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/gfortranstdinunit.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfortran_stdin_unit: + +GFORTRAN_STDIN_UNIT---Unit number for standard input +**************************************************** + +This environment variable can be used to select the unit number +preconnected to standard input. This must be a positive integer. +The default value is 5. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/gfortranstdoutunit.rst b/gcc/fortran/doc/gfortran/runtime/gfortranstdoutunit.rst new file mode 100644 index 00000000000..a6863bc0a94 --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/gfortranstdoutunit.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfortran_stdout_unit: + +GFORTRAN_STDOUT_UNIT---Unit number for standard output +****************************************************** + +This environment variable can be used to select the unit number +preconnected to standard output. This must be a positive integer. +The default value is 6. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/gfortranunbufferedall.rst b/gcc/fortran/doc/gfortran/runtime/gfortranunbufferedall.rst new file mode 100644 index 00000000000..6e8eee11d25 --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/gfortranunbufferedall.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfortran_unbuffered_all: + +GFORTRAN_UNBUFFERED_ALL---Do not buffer I/O on all units +******************************************************** + +This environment variable controls whether all I/O is unbuffered. If +the first letter is :samp:`y`, :samp:`Y` or :samp:`1`, all I/O is +unbuffered. This will slow down small sequential reads and writes. If +the first letter is :samp:`n`, :samp:`N` or :samp:`0`, I/O is buffered. +This is the default. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/gfortranunbufferedpreconnected.rst b/gcc/fortran/doc/gfortran/runtime/gfortranunbufferedpreconnected.rst new file mode 100644 index 00000000000..3a9f8e4659d --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/gfortranunbufferedpreconnected.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfortran_unbuffered_preconnected: + +GFORTRAN_UNBUFFERED_PRECONNECTED---Do not buffer I/O on preconnected units +************************************************************************** + +The environment variable named :envvar:`GFORTRAN_UNBUFFERED_PRECONNECTED` controls +whether I/O on a preconnected unit (i.e. STDOUT or STDERR) is unbuffered. If +the first letter is :samp:`y`, :samp:`Y` or :samp:`1`, I/O is unbuffered. This +will slow down small sequential reads and writes. If the first letter +is :samp:`n`, :samp:`N` or :samp:`0`, I/O is buffered. This is the default. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/gfortranunformattedbuffersize.rst b/gcc/fortran/doc/gfortran/runtime/gfortranunformattedbuffersize.rst new file mode 100644 index 00000000000..fa26cf8630a --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/gfortranunformattedbuffersize.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gfortran_unformatted_buffer_size: + +GFORTRAN_UNFORMATTED_BUFFER_SIZE---Set buffer size for unformatted I/O +********************************************************************** + +The :envvar:`GFORTRAN_UNFORMATTED_BUFFER_SIZE` environment variable +specifies buffer size in bytes to be used for unformatted output. +The default value is 131072. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/runtime/tmpdir.rst b/gcc/fortran/doc/gfortran/runtime/tmpdir.rst new file mode 100644 index 00000000000..6c5625d1dd8 --- /dev/null +++ b/gcc/fortran/doc/gfortran/runtime/tmpdir.rst @@ -0,0 +1,22 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _tmpdir: + +TMPDIR---Directory for scratch files +************************************ + +When opening a file with ``STATUS='SCRATCH'``, GNU Fortran tries to +create the file in one of the potential directories by testing each +directory in the order below. + +* The environment variable :envvar:`TMPDIR`, if it exists. + +* On the MinGW target, the directory returned by the ``GetTempPath`` + function. Alternatively, on the Cygwin target, the :envvar:`TMP` and + :envvar:`TEMP` environment variables, if they exist, in that order. + +* The ``P_tmpdir`` macro if it is defined, otherwise the directory + :samp:`/tmp`. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/standards.rst b/gcc/fortran/doc/gfortran/standards.rst new file mode 100644 index 00000000000..eff1b182051 --- /dev/null +++ b/gcc/fortran/doc/gfortran/standards.rst @@ -0,0 +1,130 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Standards + +.. _standards: + +Standards +********* + +Fortran is developed by the Working Group 5 of Sub-Committee 22 of the +Joint Technical Committee 1 of the International Organization for +Standardization and the International Electrotechnical Commission (IEC). +This group is known as `WG5 `_. +Official Fortran standard documents are available for purchase +from ISO; a collection of free documents (typically final drafts) are +also available on the `wiki `_. + +The GNU Fortran compiler implements ISO/IEC 1539:1997 (Fortran 95). +As such, it can also compile essentially all standard-compliant +Fortran 90 and Fortran 77 programs. It also supports the ISO/IEC +TR-15581 enhancements to allocatable arrays. + +GNU Fortran also supports almost all of ISO/IEC 1539-1:2004 +(Fortran 2003) and ISO/IEC 1539-1:2010 (Fortran 2008). +It has partial support for features introduced in ISO/IEC +1539:2018 (Fortran 2018), the most recent version of the Fortran +language standard, including full support for the Technical Specification +``Further Interoperability of Fortran with C`` (ISO/IEC TS 29113:2012). +More details on support for these standards can be +found in the following sections of the documentation. + +Additionally, the GNU Fortran compilers supports the OpenMP specification +(version 4.5 and partial support of the features of the 5.0 version, +https://openmp.org/specifications/). +There also is support for the OpenACC specification (targeting +version 2.6, https://www.openacc.org/). See +https://gcc.gnu.org/wiki/OpenACC for more information. + +.. index:: Varying length strings, strings, varying length, conditional compilation + +.. _fortran-95-status: + +Fortran 95 status +^^^^^^^^^^^^^^^^^ + +The Fortran 95 standard specifies in Part 2 (ISO/IEC 1539-2:2000) +varying length character strings. While GNU Fortran currently does not +support such strings directly, there exist two Fortran implementations +for them, which work with GNU Fortran. One can be found at +http://user.astro.wisc.edu/~townsend/static.php?ref=iso-varying-string. + +Deferred-length character strings of Fortran 2003 supports part of +the features of ``ISO_VARYING_STRING`` and should be considered as +replacement. (Namely, allocatable or pointers of the type +``character(len=:)``.) + +Part 3 of the Fortran 95 standard (ISO/IEC 1539-3:1998) defines +Conditional Compilation, which is not widely used and not directly +supported by the GNU Fortran compiler. You can use the program coco +to preprocess such files (http://www.daniellnagle.com/coco.html). + +.. _fortran-2003-status: + +Fortran 2003 status +^^^^^^^^^^^^^^^^^^^ + +GNU Fortran implements the Fortran 2003 (ISO/IEC 1539-1:2004) standard +except for finalization support, which is incomplete. +See the +`Fortran 2003 wiki page `_ for a full list +of new features introduced by Fortran 2003 and their implementation status. + +.. _fortran-2008-status: + +Fortran 2008 status +^^^^^^^^^^^^^^^^^^^ + +The GNU Fortran compiler supports almost all features of Fortran 2008; +the `Fortran 2008 wiki `_ +has some information about the current implementation status. +In particular, the following are not yet supported: + +* ``DO CONCURRENT`` and ``FORALL`` do not recognize a + type-spec in the loop header. + +* The change to permit any constant expression in subscripts and + nested implied-do limits in a ``DATA`` statement has not been implemented. + +.. _fortran-2018-status: + +Fortran 2018 status +^^^^^^^^^^^^^^^^^^^ + +Fortran 2018 (ISO/IEC 1539:2018) is the most recent version +of the Fortran language standard. GNU Fortran implements some of the +new features of this standard: + +* All Fortran 2018 features derived from ISO/IEC TS 29113:2012, + 'Further Interoperability of Fortran with C', are supported by GNU Fortran. + This includes assumed-type and assumed-rank objects and + the ``SELECT RANK`` construct as well as the parts relating to + ``BIND(C)`` functions. + See also :ref:`further-interoperability-of-fortran-with-c`. + +* GNU Fortran supports a subset of features derived from ISO/IEC TS 18508:2015, + 'Additional Parallel Features in Fortran': + + * The new atomic ADD, CAS, FETCH and ADD/OR/XOR, OR and XOR intrinsics. + + * The ``CO_MIN`` and ``CO_MAX`` and ``SUM`` reduction intrinsics, + and the ``CO_BROADCAST`` and ``CO_REDUCE`` intrinsic, except that those + do not support polymorphic types or types with allocatable, pointer or + polymorphic components. + + * Events (``EVENT POST``, ``EVENT WAIT``, ``EVENT_QUERY``). + + * Failed images (``FAIL IMAGE``, ``IMAGE_STATUS``, + ``FAILED_IMAGES``, ``STOPPED_IMAGES``). + +* An ``ERROR STOP`` statement is permitted in a ``PURE`` + procedure. + +* GNU Fortran supports the ``IMPLICIT NONE`` statement with an + ``implicit-none-spec-list``. + +* The behavior of the ``INQUIRE`` statement with the ``RECL=`` + specifier now conforms to Fortran 2018. \ No newline at end of file diff --git a/gcc/fortran/doc/gfortran/type-and-enum-abi-documentation.rst b/gcc/fortran/doc/gfortran/type-and-enum-abi-documentation.rst new file mode 100644 index 00000000000..ec87873fbeb --- /dev/null +++ b/gcc/fortran/doc/gfortran/type-and-enum-abi-documentation.rst @@ -0,0 +1,189 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _type-and-enum-abi-documentation: + +Type and enum ABI Documentation +******************************* + +.. toctree:: + :maxdepth: 2 + + +.. _caf_token_t: + +caf_token_t +^^^^^^^^^^^ + +Typedef of type ``void *`` on the compiler side. Can be any data +type on the library side. + +.. _caf_register_t: + +caf_register_t +^^^^^^^^^^^^^^ + +Indicates which kind of coarray variable should be registered. + +.. code-block:: c++ + + typedef enum caf_register_t { + CAF_REGTYPE_COARRAY_STATIC, + CAF_REGTYPE_COARRAY_ALLOC, + CAF_REGTYPE_LOCK_STATIC, + CAF_REGTYPE_LOCK_ALLOC, + CAF_REGTYPE_CRITICAL, + CAF_REGTYPE_EVENT_STATIC, + CAF_REGTYPE_EVENT_ALLOC, + CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY, + CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY + } + caf_register_t; + +The values ``CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY`` and +``CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY`` are for allocatable components +in derived type coarrays only. The first one sets up the token without +allocating memory for allocatable component. The latter one only allocates the +memory for an allocatable component in a derived type coarray. The token +needs to be setup previously by the REGISTER_ONLY. This allows to have +allocatable components un-allocated on some images. The status whether an +allocatable component is allocated on a remote image can be queried by +``_caf_is_present`` which used internally by the ``ALLOCATED`` +intrinsic. + +.. _caf_deregister_t: + +caf_deregister_t +^^^^^^^^^^^^^^^^ + +.. code-block:: c++ + + typedef enum caf_deregister_t { + CAF_DEREGTYPE_COARRAY_DEREGISTER, + CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY + } + caf_deregister_t; + +Allows to specifiy the type of deregistration of a coarray object. The +``CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY`` flag is only allowed for +allocatable components in derived type coarrays. + +.. _caf_reference_t: + +caf_reference_t +^^^^^^^^^^^^^^^ + +The structure used for implementing arbitrary reference chains. +A ``CAF_REFERENCE_T`` allows to specify a component reference or any kind +of array reference of any rank supported by gfortran. For array references all +kinds as known by the compiler/Fortran standard are supported indicated by +a ``MODE``. + +.. code-block:: c++ + + typedef enum caf_ref_type_t { + /* Reference a component of a derived type, either regular one or an + allocatable or pointer type. For regular ones idx in caf_reference_t is + set to -1. */ + CAF_REF_COMPONENT, + /* Reference an allocatable array. */ + CAF_REF_ARRAY, + /* Reference a non-allocatable/non-pointer array. I.e., the coarray object + has no array descriptor associated and the addressing is done + completely using the ref. */ + CAF_REF_STATIC_ARRAY + } caf_ref_type_t; + +.. code-block:: c++ + + typedef enum caf_array_ref_t { + /* No array ref. This terminates the array ref. */ + CAF_ARR_REF_NONE = 0, + /* Reference array elements given by a vector. Only for this mode + caf_reference_t.u.a.dim[i].v is valid. */ + CAF_ARR_REF_VECTOR, + /* A full array ref (:). */ + CAF_ARR_REF_FULL, + /* Reference a range on elements given by start, end and stride. */ + CAF_ARR_REF_RANGE, + /* Only a single item is referenced given in the start member. */ + CAF_ARR_REF_SINGLE, + /* An array ref of the kind (i:), where i is an arbitrary valid index in the + array. The index i is given in the start member. */ + CAF_ARR_REF_OPEN_END, + /* An array ref of the kind (:i), where the lower bound of the array ref + is given by the remote side. The index i is given in the end member. */ + CAF_ARR_REF_OPEN_START + } caf_array_ref_t; + +.. code-block:: c++ + + /* References to remote components of a derived type. */ + typedef struct caf_reference_t { + /* A pointer to the next ref or NULL. */ + struct caf_reference_t *next; + /* The type of the reference. */ + /* caf_ref_type_t, replaced by int to allow specification in fortran FE. */ + int type; + /* The size of an item referenced in bytes. I.e. in an array ref this is + the factor to advance the array pointer with to get to the next item. + For component refs this gives just the size of the element referenced. */ + size_t item_size; + union { + struct { + /* The offset (in bytes) of the component in the derived type. + Unused for allocatable or pointer components. */ + ptrdiff_t offset; + /* The offset (in bytes) to the caf_token associated with this + component. NULL, when not allocatable/pointer ref. */ + ptrdiff_t caf_token_offset; + } c; + struct { + /* The mode of the array ref. See CAF_ARR_REF_*. */ + /* caf_array_ref_t, replaced by unsigend char to allow specification in + fortran FE. */ + unsigned char mode[GFC_MAX_DIMENSIONS]; + /* The type of a static array. Unset for array's with descriptors. */ + int static_array_type; + /* Subscript refs (s) or vector refs (v). */ + union { + struct { + /* The start and end boundary of the ref and the stride. */ + index_type start, end, stride; + } s; + struct { + /* nvec entries of kind giving the elements to reference. */ + void *vector; + /* The number of entries in vector. */ + size_t nvec; + /* The integer kind used for the elements in vector. */ + int kind; + } v; + } dim[GFC_MAX_DIMENSIONS]; + } a; + } u; + } caf_reference_t; + +The references make up a single linked list of reference operations. The +``NEXT`` member links to the next reference or NULL to indicate the end of +the chain. Component and array refs can be arbitrarily mixed as long as they +comply to the Fortran standard. + +.. note:: + The member ``STATIC_ARRAY_TYPE`` is used only when the ``TYPE`` is + ``CAF_REF_STATIC_ARRAY``. The member gives the type of the data referenced. + Because no array descriptor is available for a descriptor-less array and + type conversion still needs to take place the type is transported here. + + At the moment ``CAF_ARR_REF_VECTOR`` is not implemented in the front end for + descriptor-less arrays. The library caf_single has untested support for it. + +.. _caf_team_t: + +caf_team_t +^^^^^^^^^^ + +Opaque pointer to represent a team-handle. This type is a stand-in for the +future implementation of teams. It is about to change without further notice. \ No newline at end of file diff --git a/gcc/go/doc/c-interoperability.rst b/gcc/go/doc/c-interoperability.rst new file mode 100644 index 00000000000..8eaaf001335 --- /dev/null +++ b/gcc/go/doc/c-interoperability.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _c-interoperability: + +C Interoperability +------------------ + +When using :command:`gccgo` there is limited interoperability with C, +or with C++ code compiled using ``extern "C"``. + +This information is provided largely for documentation purposes. For +ordinary use it is best to build programs with the go tool and then +use ``import "C"``, as described at +https://golang.org/cmd/cgo. + +.. toctree:: + :maxdepth: 2 + + c-type-interoperability + function-names \ No newline at end of file diff --git a/gcc/go/doc/c-type-interoperability.rst b/gcc/go/doc/c-type-interoperability.rst new file mode 100644 index 00000000000..fb2acc96df8 --- /dev/null +++ b/gcc/go/doc/c-type-interoperability.rst @@ -0,0 +1,77 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _c-type-interoperability: + +C Type Interoperability +*********************** + +Basic types map directly: an ``int`` in Go is an ``int`` in C, +etc. Go ``byte`` is equivalent to C ``unsigned char``. +Pointers in Go are pointers in C. A Go ``struct`` is the same as C +``struct`` with the same field names and types. + +.. index:: string in C + +The Go ``string`` type is currently defined as a two-element +structure: + +.. code-block:: c++ + + struct __go_string { + const unsigned char *__data; + int __length; + }; + +You can't pass arrays between C and Go. However, a pointer to an +array in Go is equivalent to a C pointer to the equivalent of the +element type. For example, Go ``*[10]int`` is equivalent to C +``int*``, assuming that the C pointer does point to 10 elements. + +.. index:: slice in C + +A slice in Go is a structure. The current definition is: + +.. code-block:: c++ + + struct __go_slice { + void *__values; + int __count; + int __capacity; + }; + +The type of a Go function with no receiver is equivalent to a C +function whose parameter types are equivalent. When a Go function +returns more than one value, the C function returns a struct. For +example, these functions have equivalent types: + +.. code-block:: c++ + + func GoFunction(int) (int, float) + struct { int i; float f; } CFunction(int) + +A pointer to a Go function is equivalent to a pointer to a C function +when the functions have equivalent types. + +Go ``interface``, ``channel``, and ``map`` types have no +corresponding C type (``interface`` is a two-element struct and +``channel`` and ``map`` are pointers to structs in C, but the +structs are deliberately undocumented). C ``enum`` types +correspond to some integer type, but precisely which one is difficult +to predict in general; use a cast. C ``union`` types have no +corresponding Go type. C ``struct`` types containing bitfields +have no corresponding Go type. C++ ``class`` types have no +corresponding Go type. + +Memory allocation is completely different between C and Go, as Go uses +garbage collection. The exact guidelines in this area are +undetermined, but it is likely that it will be permitted to pass a +pointer to allocated memory from C to Go. The responsibility of +eventually freeing the pointer will remain with C side, and of course +if the C side frees the pointer while the Go side still has a copy the +program will fail. When passing a pointer from Go to C, the Go +function must retain a visible copy of it in some Go variable. +Otherwise the Go garbage collector may delete the pointer while the C +function is still using it. \ No newline at end of file diff --git a/gcc/go/doc/compiler-directives.rst b/gcc/go/doc/compiler-directives.rst new file mode 100644 index 00000000000..1567d64b056 --- /dev/null +++ b/gcc/go/doc/compiler-directives.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _compiler-directives: + +Compiler Directives +------------------- + +The Go compiler supports a few compiler directives. A compiler +directive uses a ``//`` comment at the start of a line. There must +be no space between the ``//`` and the name of the directive. + +:samp:`//line {file}:{line}` + The ``//line`` directive specifies that the source line that + follows should be recorded as having come from the given file path and + line number. Successive lines are recorded using increasing line + numbers, until the next directive. This directive typically appears + in machine-generated code, so that compilers and debuggers will show + lines in the original input to the generator. + +:samp:`//extern {extern_name}` + The ``extern`` directive sets the externally visible name of the + next function declaration. See :ref:`function-names`. + +:samp:`//go:compile {go_name}{extern_name}` + The ``go:compile`` directives sets the externally visible name of a + function definition or declaration. See :ref:`function-names`. + +``//go:noescape`` + The ``//go:noescape`` directive specifies that the next declaration + in the file, which must be a func without a body (meaning that it has + an implementation not written in Go) does not allow any of the + pointers passed as arguments to escape into the heap or into the + values returned from the function. This information can be used during + the compiler's escape analysis of Go code calling the function. + +``//go:nosplit`` + The ``//go:nosplit`` directive specifies that the next function + declared in the file must not include a stack overflow check. This is + most commonly used by low-level runtime sources invoked at times when + it is unsafe for the calling goroutine to be preempted. + +``//go:noinline`` + The ``//go:noinline`` directive specifies that the next function + defined in the file may not be inlined. \ No newline at end of file diff --git a/gcc/go/doc/conf.py b/gcc/go/doc/conf.py new file mode 100644 index 00000000000..9157fba79ee --- /dev/null +++ b/gcc/go/doc/conf.py @@ -0,0 +1,30 @@ +# Configuration file for the Sphinx documentation builder. + +import sys +sys.path.append('../../..//doc') + +from baseconf import * + +name = 'gccgo' +project = 'The GNU Go Compiler' +copyright = '2010-2022 Free Software Foundation, Inc.' +authors = 'Ian Lance Taylor' + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +latex_documents = [ + ('index', f'{name}.tex', project, authors, 'manual'), +] + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('invoking-gccgo', name, 'A GCC-based compiler for the Go language', [authors], 1), +] + +texinfo_documents = [ + ('index', name, project, authors, None, None, None, True) +] + +set_common(name, globals()) \ No newline at end of file diff --git a/gcc/go/doc/copyright.rst b/gcc/go/doc/copyright.rst new file mode 100644 index 00000000000..fa61190ddf7 --- /dev/null +++ b/gcc/go/doc/copyright.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Copyright +^^^^^^^^^ + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, the Front-Cover Texts being (a) (see below), and +with the Back-Cover Texts being (b) (see below). +A copy of the license is included in the :ref:`gnu_fdl`. + +(a) The FSF's Front-Cover Text is: + + A GNU Manual + +(b) The FSF's Back-Cover Text is: + + You have freedom to copy and modify this GNU Manual, like GNU + software. Copies published by the Free Software Foundation raise + funds for GNU development. \ No newline at end of file diff --git a/gcc/go/doc/function-names.rst b/gcc/go/doc/function-names.rst new file mode 100644 index 00000000000..1ed57606eab --- /dev/null +++ b/gcc/go/doc/function-names.rst @@ -0,0 +1,61 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: extern, external names + +.. _function-names: + +Function Names +************** + +Go code can call C functions directly using the ``//extern`` or +``//go:linkname`` compiler directives. An ``//extern`` +directive must be at the beginning of the line and must start with +``//extern``. This must be followed by a space and then the +external name of the function. The function declaration must be on +the line immediately after the comment. For example, here is how the +C function ``open`` can be declared in Go: + +.. code-block:: c++ + + //extern open + func c_open(name *byte, mode int, perm int) int + +You can do the same thing using the ``//go:linkname`` compiler +directive. The ``//go:linkname`` directive must be at the start of +the line. It is followed by whitespace, the name of the Go function, +more whitespace, and the external name of the function. Unlike +``//extern``, ``//go:linkname`` does not need to appear +immediately adjacent to the function definition or declaration. + +.. code-block:: c++ + + //go:linkname c_open open + func c_open(name *byte, mode int, perm int) int + +The C function naturally expects a nul terminated string, which in Go +is equivalent to a pointer to an array (not a slice!) of ``byte`` +with a terminating zero byte. So a sample call from Go would look +like (after importing the ``os`` package): + +.. code-block:: c++ + + var name = [4]byte{'f', 'o', 'o', 0}; + i := c_open(&name[0], os.O_RDONLY, 0); + +Note that this serves as an example only. To open a file in Go please +use Go's ``os.Open`` function instead. + +The name of Go functions accessed from C is subject to change. At +present the name of a Go function that does not have a receiver is +``pkgpath.Functionname``. The :samp:`{pkgpath}` is set by the +:option:`-fgo-pkgpath` option used when the package is compiled; if the +option is not used, the default is ``go.packagename``. To +call the function from C you must set the name using the :command:`gcc` +``__asm__`` extension. + +.. code-block:: c++ + + extern int go_function(int) __asm__ ("mypkgpath.Function"); \ No newline at end of file diff --git a/gcc/go/doc/general-public-license-3.rst b/gcc/go/doc/general-public-license-3.rst new file mode 100644 index 00000000000..becda773ca0 --- /dev/null +++ b/gcc/go/doc/general-public-license-3.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/gpl-3.0.rst \ No newline at end of file diff --git a/gcc/go/doc/gnu-free-documentation-license.rst b/gcc/go/doc/gnu-free-documentation-license.rst new file mode 100644 index 00000000000..1de809b3636 --- /dev/null +++ b/gcc/go/doc/gnu-free-documentation-license.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../../doc/gnu_free_documentation_license.rst \ No newline at end of file diff --git a/gcc/go/doc/import-and-export.rst b/gcc/go/doc/import-and-export.rst new file mode 100644 index 00000000000..285fb5f11de --- /dev/null +++ b/gcc/go/doc/import-and-export.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _import-and-export: + +Import and Export +----------------- + +When :command:`gccgo` compiles a package which exports anything, the +export information will be stored directly in the object file. When a +package is imported, :command:`gccgo` must be able to find the file. + +.. index:: .gox + +When Go code imports the package :samp:`{gopackage}`, :command:`gccgo` +will look for the import data using the following filenames, using the +first one that it finds. + +.. code-block:: + + gopackage.gox + libgopackage.so + libgopackage.a + gopackage.o + +The compiler will search for these files in the directories named by +any :option:`-I` options, in order in which the directories appear on +the command line. The compiler will then search several standard +system directories. Finally the compiler will search the current +directory (to search the current directory earlier, use :samp:`-I.`). + +The compiler will extract the export information directly from the +compiled object file. The file :samp:`{gopackage}.gox` will +typically contain nothing but export data. This can be generated from +:samp:`{gopackage}.o` via + +.. code-block:: c++ + + objcopy -j .go_export gopackage.o gopackage.gox + +For example, it may be desirable to extract the export information +from several different packages into their independent +:samp:`{gopackage}.gox` files, and then to combine the different +package object files together into a single shared library or archive. + +At link time you must explicitly tell :command:`gccgo` which files to +link together into the executable, as is usual with :command:`gcc`. +This is different from the behavior of other Go compilers. \ No newline at end of file diff --git a/gcc/go/doc/index.rst b/gcc/go/doc/index.rst new file mode 100644 index 00000000000..76951a40b3e --- /dev/null +++ b/gcc/go/doc/index.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +The GNU Go Compiler +=================== + +.. only:: html + + Contents: + +.. toctree:: + + copyright + introduction + invoking-gccgo + import-and-export + compiler-directives + c-interoperability + general-public-license-3 + gnu-free-documentation-license + indices-and-tables \ No newline at end of file diff --git a/gcc/go/doc/indices-and-tables.rst b/gcc/go/doc/indices-and-tables.rst new file mode 100644 index 00000000000..6c215a391d9 --- /dev/null +++ b/gcc/go/doc/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/gcc/go/doc/introduction.rst b/gcc/go/doc/introduction.rst new file mode 100644 index 00000000000..c38ff7d23fa --- /dev/null +++ b/gcc/go/doc/introduction.rst @@ -0,0 +1,8 @@ +Introduction +============ + +This manual describes how to use :command:`gccgo`, the GNU compiler for +the Go programming language. This manual is specifically about +:command:`gccgo`. For more information about the Go programming +language in general, including language specifications and standard +package documentation, see http://golang.org/. \ No newline at end of file diff --git a/gcc/go/doc/invoking-gccgo.rst b/gcc/go/doc/invoking-gccgo.rst new file mode 100644 index 00000000000..ccca40ecf7a --- /dev/null +++ b/gcc/go/doc/invoking-gccgo.rst @@ -0,0 +1,214 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _invoking-gccgo: + +Invoking gccgo +-------------- + +.. only:: man + + Synopsis + ^^^^^^^^ + + gccgo [ :option:`-c` | :option:`-S` ] + [ :option:`-g` ] [ :option:`-pg` ] [ :option:`-O`:samp:`{level}` ] + [ :option:`-I dir...` ] [ :option:`-L dir...` ] + [ :option:`-o` :samp:`{outfile}` ] :samp:`{infile}`... + +Description +^^^^^^^^^^^ + +Only the most useful options are listed here; see below for the +remainder. + +The :command:`gccgo` command is a frontend to :command:`gcc` and +supports many of the same options. See :ref:`gcc:option-summary`. This manual +only documents the options specific to :command:`gccgo`. + +The :command:`gccgo` command may be used to compile Go source code into +an object file, link a collection of object files together, or do both +in sequence. + +Go source code is compiled as packages. A package consists of one or +more Go source files. All the files in a single package must be +compiled together, by passing all the files as arguments to +:command:`gccgo`. A single invocation of :command:`gccgo` may only +compile a single package. + +One Go package may ``import`` a different Go package. The imported +package must have already been compiled; :command:`gccgo` will read +the import data directly from the compiled package. When this package +is later linked, the compiled form of the package must be included in +the link command. + +Go programs must generally be compiled with debugging information, and +:option:`-g1` is the default as described below. Stripping a Go +program will generally cause it to misbehave or fail. + +Options +^^^^^^^ + +.. option:: -Idir + + .. index:: -I + + Specify a directory to use when searching for an import package at + compile time. + +.. option:: -Ldir + + .. index:: -L + + When linking, specify a library search directory, as with + :command:`gcc`. + +.. option:: -fgo-pkgpath=string + + .. index:: -fgo-pkgpath + + Set the package path to use. This sets the value returned by the + PkgPath method of reflect.Type objects. It is also used for the names + of globally visible symbols. The argument to this option should + normally be the string that will be used to import this package after + it has been installed; in other words, a pathname within the + directories specified by the :option:`-I` option. + +.. option:: -fgo-prefix=string + + .. index:: -fgo-prefix + + An alternative to :option:`-fgo-pkgpath`. The argument will be + combined with the package name from the source file to produce the + package path. If :option:`-fgo-pkgpath` is used, :option:`-fgo-prefix` + will be ignored. + + Go permits a single program to include more than one package with the + same name in the ``package`` clause in the source file, though + obviously the two packages must be imported using different pathnames. + In order for this to work with :command:`gccgo`, either + :option:`-fgo-pkgpath` or :option:`-fgo-prefix` must be specified when + compiling a package. + + Using either :option:`-fgo-pkgpath` or :option:`-fgo-prefix` disables + the special treatment of the ``main`` package and permits that + package to be imported like any other. + +.. option:: -fgo-relative-import-path=dir + + .. index:: -fgo-relative-import-path + + A relative import is an import that starts with :samp:`./` or + :samp:`../`. If this option is used, :command:`gccgo` will use + :samp:`{dir}` as a prefix for the relative import when searching for it. + +.. option:: -frequire-return-statement +.. option:: -fno-require-return-statement + + .. index:: -frequire-return-statement, -fno-require-return-statement + + By default :command:`gccgo` will warn about functions which have one or + more return parameters but lack an explicit ``return`` statement. + This warning may be disabled using + :option:`-fno-require-return-statement`. + +.. option:: -fgo-check-divide-zero + + .. index:: -fgo-check-divide-zero, -fno-go-check-divide-zero + + Add explicit checks for division by zero. In Go a division (or + modulos) by zero causes a panic. On Unix systems this is detected in + the runtime by catching the ``SIGFPE`` signal. Some processors, + such as PowerPC, do not generate a SIGFPE on division by zero. Some + runtimes do not generate a signal that can be caught. On those + systems, this option may be used. Or the checks may be removed via + :option:`-fno-go-check-divide-zero`. This option is currently on by + default, but in the future may be off by default on systems that do + not require it. + +.. option:: -fgo-check-divide-overflow + + .. index:: -fgo-check-divide-overflow, -fno-go-check-divide-overflow + + Add explicit checks for division overflow. For example, division + overflow occurs when computing ``INT_MIN / -1``. In Go this should + be wrapped, to produce ``INT_MIN``. Some processors, such as x86, + generate a trap on division overflow. On those systems, this option + may be used. Or the checks may be removed via + :option:`-fno-go-check-divide-overflow`. This option is currently on + by default, but in the future may be off by default on systems that do + not require it. + +.. option:: -fno-go-optimize-allocs + + .. index:: -fno-go-optimize-allocs + + Disable escape analysis, which tries to allocate objects on the stack + rather than the heap. + +.. option:: -fgo-debug-escapen + + .. index:: -fgo-debug-escape + + Output escape analysis debugging information. Larger values of + :samp:`{n}` generate more information. + +.. option:: -fgo-debug-escape-hash=n + + .. index:: -fgo-debug-escape-hash + + A hash value to debug escape analysis. :samp:`{n}` is a binary string. + This runs escape analysis only on functions whose names hash to values + that match the given suffix :samp:`{n}`. This can be used to binary + search across functions to uncover escape analysis bugs. + +.. option:: -fgo-debug-optimization + + .. index:: -fgo-debug-optimization, -fno-go-debug-optimization + + Output optimization diagnostics. + +.. option:: -fgo-c-header=file + + .. index:: -fgo-c-header + + Write top-level named Go struct definitions to :samp:`{file}` as C code. + This is used when compiling the runtime package. + +.. option:: -fgo-compiling-runtime + + .. index:: -fgo-compiling-runtime + + Apply special rules for compiling the runtime package. Implicit + memory allocation is forbidden. Some additional compiler directives + are supported. + +.. option:: -fgo-embedcfg=file + + .. index:: -fgo-embedcfg + + Identify a JSON file used to map patterns used with special + ``//go:embed`` comments to the files named by the patterns. The + JSON file should have two components: ``Patterns`` maps each + pattern to a list of file names, and ``Files`` maps each file name + to a full path to the file. This option is intended for use by the + :command:`go` command to implement ``//go:embed``. + +.. option:: -g + + .. index:: -g for gccgo + + This is the standard :command:`gcc` option (see :ref:`gcc:debugging-options`). It + is mentioned here because by default :command:`gccgo` turns on + debugging information generation with the equivalent of the standard + option :option:`-g1`. This is because Go programs require debugging + information to be available in order to get backtrace information. An + explicit :option:`-g0` may be used to disable the generation of + debugging information, in which case certain standard library + functions, such as ``runtime.Callers``, will not operate correctly. + +.. only:: man + + .. include:: copyright.rst \ No newline at end of file diff --git a/libgomp/doc/amd-radeon-gcn.rst b/libgomp/doc/amd-radeon-gcn.rst new file mode 100644 index 00000000000..60ff060e828 --- /dev/null +++ b/libgomp/doc/amd-radeon-gcn.rst @@ -0,0 +1,57 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _amd-radeon: + +AMD Radeon (GCN) +**************** + +On the hardware side, there is the hierarchy (fine to coarse): + +* work item (thread) + +* wavefront + +* work group + +* compute unite (CU) + +All OpenMP and OpenACC levels are used, i.e. + +* OpenMP's simd and OpenACC's vector map to work items (thread) + +* OpenMP's threads ('parallel') and OpenACC's workers map + to wavefronts + +* OpenMP's teams and OpenACC's gang use a threadpool with the + size of the number of teams or gangs, respectively. + +The used sizes are + +* Number of teams is the specified ``num_teams`` (OpenMP) or + ``num_gangs`` (OpenACC) or otherwise the number of CU + +* Number of wavefronts is 4 for gfx900 and 16 otherwise; + ``num_threads`` (OpenMP) and ``num_workers`` (OpenACC) + overrides this if smaller. + +* The wavefront has 102 scalars and 64 vectors + +* Number of workitems is always 64 + +* The hardware permits maximally 40 workgroups/CU and + 16 wavefronts/workgroup up to a limit of 40 wavefronts in total per CU. + +* 80 scalars registers and 24 vector registers in non-kernel functions + (the chosen procedure-calling API). + +* For the kernel itself: as many as register pressure demands (number of + teams and number of threads, scaled down if registers are exhausted) + +The implementation remark: + +* I/O within OpenMP target regions and OpenACC parallel/kernels is supported + using the C library ``printf`` functions and the Fortran + ``print`` / ``write`` statements. \ No newline at end of file diff --git a/libgomp/doc/conf.py b/libgomp/doc/conf.py new file mode 100644 index 00000000000..27e3131fae8 --- /dev/null +++ b/libgomp/doc/conf.py @@ -0,0 +1,24 @@ +# Configuration file for the Sphinx documentation builder. + +import sys +sys.path.append('../..//doc') + +from baseconf import * + +name = 'libgomp' +project = 'GNU Offloading and Multi Processing Runtime Library' +copyright = '2006-2022 Free Software Foundation, Inc.' +authors = 'GCC Developer Community' + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +latex_documents = [ + ('index', f'{name}.tex', project, authors, 'manual'), +] + +texinfo_documents = [ + ('index', name, project, authors, None, None, None, True) +] + +set_common(name, globals()) \ No newline at end of file diff --git a/libgomp/doc/copyright.rst b/libgomp/doc/copyright.rst new file mode 100644 index 00000000000..0f99e93a99b --- /dev/null +++ b/libgomp/doc/copyright.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Copyright +^^^^^^^^^ + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with the +Invariant Sections being **Funding Free Software**, +the Front-Cover texts being (a) (see below), and with +the Back-Cover Texts being (b) (see below). A copy of the license is +in the :ref:`gnu_fdl`. + +(a) The FSF's Front-Cover Text is: + + A GNU Manual + +(b) The FSF's Back-Cover Text is: + + You have freedom to copy and modify this GNU Manual, like GNU + software. Copies published by the Free Software Foundation raise + funds for GNU development. \ No newline at end of file diff --git a/libgomp/doc/cuda-streams-usage.rst b/libgomp/doc/cuda-streams-usage.rst new file mode 100644 index 00000000000..4e81ec45ca5 --- /dev/null +++ b/libgomp/doc/cuda-streams-usage.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _cuda-streams-usage: + +CUDA Streams Usage +------------------ + +This applies to the ``nvptx`` plugin only. + +The library provides elements that perform asynchronous movement of +data and asynchronous operation of computing constructs. This +asynchronous functionality is implemented by making use of CUDA +streams [#f1]_. + +The primary means by that the asynchronous functionality is accessed +is through the use of those OpenACC directives which make use of the +``async`` and ``wait`` clauses. When the ``async`` clause is +first used with a directive, it creates a CUDA stream. If an +``async-argument`` is used with the ``async`` clause, then the +stream is associated with the specified ``async-argument``. + +Following the creation of an association between a CUDA stream and the +``async-argument`` of an ``async`` clause, both the ``wait`` +clause and the ``wait`` directive can be used. When either the +clause or directive is used after stream creation, it creates a +rendezvous point whereby execution waits until all operations +associated with the ``async-argument``, that is, stream, have +completed. + +Normally, the management of the streams that are created as a result of +using the ``async`` clause, is done without any intervention by the +caller. This implies the association between the ``async-argument`` +and the CUDA stream will be maintained for the lifetime of the program. +However, this association can be changed through the use of the library +function ``acc_set_cuda_stream``. When the function +``acc_set_cuda_stream`` is called, the CUDA stream that was +originally associated with the ``async`` clause will be destroyed. +Caution should be taken when changing the association as subsequent +references to the ``async-argument`` refer to a different +CUDA stream. + +.. - + OpenACC Library Interoperability + - + +.. [#f1] See "Stream Management" in "CUDA Driver API", + TRM-06703-001, Version 5.5, for additional information \ No newline at end of file diff --git a/libgomp/doc/enabling-openacc.rst b/libgomp/doc/enabling-openacc.rst new file mode 100644 index 00000000000..dedb403a70a --- /dev/null +++ b/libgomp/doc/enabling-openacc.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _enabling-openacc: + +Enabling OpenACC +---------------- + +To activate the OpenACC extensions for C/C++ and Fortran, the compile-time +flag :option:`-fopenacc` must be specified. This enables the OpenACC directive +``#pragma acc`` in C/C++ and ``!$acc`` directives in free form, +``c$acc``, ``*$acc`` and ``!$acc`` directives in fixed form, +``!$`` conditional compilation sentinels in free form and ``c$``, +``*$`` and ``!$`` sentinels in fixed form, for Fortran. The flag also +arranges for automatic linking of the OpenACC runtime library +(:ref:`openacc-runtime-library-routines`). + +See https://gcc.gnu.org/wiki/OpenACC for more information. + +A complete description of all OpenACC directives accepted may be found in +the `OpenACC `_ Application Programming +Interface manual, version 2.6. \ No newline at end of file diff --git a/libgomp/doc/enabling-openmp.rst b/libgomp/doc/enabling-openmp.rst new file mode 100644 index 00000000000..368bc44fe12 --- /dev/null +++ b/libgomp/doc/enabling-openmp.rst @@ -0,0 +1,22 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _enabling-openmp: + +Enabling OpenMP +--------------- + +To activate the OpenMP extensions for C/C++ and Fortran, the compile-time +flag :command:`-fopenmp` must be specified. This enables the OpenMP directive +``#pragma omp`` in C/C++ and ``!$omp`` directives in free form, +``c$omp``, ``*$omp`` and ``!$omp`` directives in fixed form, +``!$`` conditional compilation sentinels in free form and ``c$``, +``*$`` and ``!$`` sentinels in fixed form, for Fortran. The flag also +arranges for automatic linking of the OpenMP runtime library +(:ref:`runtime-library-routines`). + +A complete description of all OpenMP directives may be found in the +`OpenMP Application Program Interface `_ manuals. +See also :ref:`openmp-implementation-status`. \ No newline at end of file diff --git a/libgomp/doc/first-invocation-nvidia-cublas-library-api.rst b/libgomp/doc/first-invocation-nvidia-cublas-library-api.rst new file mode 100644 index 00000000000..a3b30d0636a --- /dev/null +++ b/libgomp/doc/first-invocation-nvidia-cublas-library-api.rst @@ -0,0 +1,52 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +First invocation: NVIDIA CUBLAS library API +******************************************* + +In this first use case (see below), a function in the CUBLAS library is called +prior to any of the functions in the OpenACC library. More specifically, the +function ``cublasCreate()``. + +When invoked, the function initializes the library and allocates the +hardware resources on the host and the device on behalf of the caller. Once +the initialization and allocation has completed, a handle is returned to the +caller. The OpenACC library also requires initialization and allocation of +hardware resources. Since the CUBLAS library has already allocated the +hardware resources for the device, all that is left to do is to initialize +the OpenACC library and acquire the hardware resources on the host. + +Prior to calling the OpenACC function that initializes the library and +allocate the host hardware resources, you need to acquire the device number +that was allocated during the call to ``cublasCreate()``. The invoking of the +runtime library function ``cudaGetDevice()`` accomplishes this. Once +acquired, the device number is passed along with the device type as +parameters to the OpenACC library function ``acc_set_device_num()``. + +Once the call to ``acc_set_device_num()`` has completed, the OpenACC +library uses the context that was created during the call to +``cublasCreate()``. In other words, both libraries will be sharing the +same context. + +.. code-block:: c++ + + /* Create the handle */ + s = cublasCreate(&h); + if (s != CUBLAS_STATUS_SUCCESS) + { + fprintf(stderr, "cublasCreate failed %d\n", s); + exit(EXIT_FAILURE); + } + + /* Get the device number */ + e = cudaGetDevice(&dev); + if (e != cudaSuccess) + { + fprintf(stderr, "cudaGetDevice failed %d\n", e); + exit(EXIT_FAILURE); + } + + /* Initialize OpenACC library and use device 'dev' */ + acc_set_device_num(dev, acc_device_nvidia); \ No newline at end of file diff --git a/libgomp/doc/first-invocation-openacc-library-api.rst b/libgomp/doc/first-invocation-openacc-library-api.rst new file mode 100644 index 00000000000..1962daa9e69 --- /dev/null +++ b/libgomp/doc/first-invocation-openacc-library-api.rst @@ -0,0 +1,74 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +First invocation: OpenACC library API +************************************* + +In this second use case (see below), a function in the OpenACC library is +called prior to any of the functions in the CUBLAS library. More specificially, +the function ``acc_set_device_num()``. + +In the use case presented here, the function ``acc_set_device_num()`` +is used to both initialize the OpenACC library and allocate the hardware +resources on the host and the device. In the call to the function, the +call parameters specify which device to use and what device +type to use, i.e., ``acc_device_nvidia``. It should be noted that this +is but one method to initialize the OpenACC library and allocate the +appropriate hardware resources. Other methods are available through the +use of environment variables and these will be discussed in the next section. + +Once the call to ``acc_set_device_num()`` has completed, other OpenACC +functions can be called as seen with multiple calls being made to +``acc_copyin()``. In addition, calls can be made to functions in the +CUBLAS library. In the use case a call to ``cublasCreate()`` is made +subsequent to the calls to ``acc_copyin()``. +As seen in the previous use case, a call to ``cublasCreate()`` +initializes the CUBLAS library and allocates the hardware resources on the +host and the device. However, since the device has already been allocated, +``cublasCreate()`` will only initialize the CUBLAS library and allocate +the appropriate hardware resources on the host. The context that was created +as part of the OpenACC initialization is shared with the CUBLAS library, +similarly to the first use case. + +.. code-block:: c++ + + dev = 0; + + acc_set_device_num(dev, acc_device_nvidia); + + /* Copy the first set to the device */ + d_X = acc_copyin(&h_X[0], N * sizeof (float)); + if (d_X == NULL) + { + fprintf(stderr, "copyin error h_X\n"); + exit(EXIT_FAILURE); + } + + /* Copy the second set to the device */ + d_Y = acc_copyin(&h_Y1[0], N * sizeof (float)); + if (d_Y == NULL) + { + fprintf(stderr, "copyin error h_Y1\n"); + exit(EXIT_FAILURE); + } + + /* Create the handle */ + s = cublasCreate(&h); + if (s != CUBLAS_STATUS_SUCCESS) + { + fprintf(stderr, "cublasCreate failed %d\n", s); + exit(EXIT_FAILURE); + } + + /* Perform saxpy using CUBLAS library function */ + s = cublasSaxpy(h, N, &alpha, d_X, 1, d_Y, 1); + if (s != CUBLAS_STATUS_SUCCESS) + { + fprintf(stderr, "cublasSaxpy failed %d\n", s); + exit(EXIT_FAILURE); + } + + /* Copy the results from the device */ + acc_memcpy_from_device(&h_Y1[0], d_Y, N * sizeof (float)); \ No newline at end of file diff --git a/libgomp/doc/funding.rst b/libgomp/doc/funding.rst new file mode 100644 index 00000000000..09aa11490f7 --- /dev/null +++ b/libgomp/doc/funding.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../doc/funding.rst \ No newline at end of file diff --git a/libgomp/doc/general-public-license-3.rst b/libgomp/doc/general-public-license-3.rst new file mode 100644 index 00000000000..eadeef0b1f7 --- /dev/null +++ b/libgomp/doc/general-public-license-3.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../doc/gpl-3.0.rst \ No newline at end of file diff --git a/libgomp/doc/gnu-free-documentation-license.rst b/libgomp/doc/gnu-free-documentation-license.rst new file mode 100644 index 00000000000..089cc682de2 --- /dev/null +++ b/libgomp/doc/gnu-free-documentation-license.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../doc/gnu_free_documentation_license.rst \ No newline at end of file diff --git a/libgomp/doc/implementation-status-and-implementation-defined-behavior.rst b/libgomp/doc/implementation-status-and-implementation-defined-behavior.rst new file mode 100644 index 00000000000..2c65c71c42d --- /dev/null +++ b/libgomp/doc/implementation-status-and-implementation-defined-behavior.rst @@ -0,0 +1,281 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Implementation Status and Implementation-Defined Behavior +********************************************************* + +We're implementing the OpenACC Profiling Interface as defined by the +OpenACC 2.6 specification. We're clarifying some aspects here as +*implementation-defined behavior*, while they're still under +discussion within the OpenACC Technical Committee. + +This implementation is tuned to keep the performance impact as low as +possible for the (very common) case that the Profiling Interface is +not enabled. This is relevant, as the Profiling Interface affects all +the *hot* code paths (in the target code, not in the offloaded +code). Users of the OpenACC Profiling Interface can be expected to +understand that performance will be impacted to some degree once the +Profiling Interface has gotten enabled: for example, because of the +*runtime* (libgomp) calling into a third-party *library* for +every event that has been registered. + +We're not yet accounting for the fact that OpenACC events may +occur during event processing. +We just handle one case specially, as required by CUDA 9.0 +:command:`nvprof`, that ``acc_get_device_type`` +(:ref:`acc_get_device_type`)) may be called from +``acc_ev_device_init_start``, ``acc_ev_device_init_end`` +callbacks. + +We're not yet implementing initialization via a +``acc_register_library`` function that is either statically linked +in, or dynamically via :envvar:`LD_PRELOAD`. +Initialization via ``acc_register_library`` functions dynamically +loaded via the :envvar:`ACC_PROFLIB` environment variable does work, as +does directly calling ``acc_prof_register``, +``acc_prof_unregister``, ``acc_prof_lookup``. + +As currently there are no inquiry functions defined, calls to +``acc_prof_lookup`` will always return ``NULL``. + +There aren't separate *start*, *stop* events defined for the +event types ``acc_ev_create``, ``acc_ev_delete``, +``acc_ev_alloc``, ``acc_ev_free``. It's not clear if these +should be triggered before or after the actual device-specific call is +made. We trigger them after. + +Remarks about data provided to callbacks: + +acc_prof_info.event_type + It's not clear if for *nested* event callbacks (for example, + ``acc_ev_enqueue_launch_start`` as part of a parent compute + construct), this should be set for the nested event + (``acc_ev_enqueue_launch_start``), or if the value of the parent + construct should remain (``acc_ev_compute_construct_start``). In + this implementation, the value will generally correspond to the + innermost nested event type. + +acc_prof_info.device_type + * For ``acc_ev_compute_construct_start``, and in presence of an + ``if`` clause with *false* argument, this will still refer to + the offloading device type. + It's not clear if that's the expected behavior. + + * Complementary to the item before, for + ``acc_ev_compute_construct_end``, this is set to + ``acc_device_host`` in presence of an ``if`` clause with + *false* argument. + It's not clear if that's the expected behavior. + +acc_prof_info.thread_id + Always ``-1`` ; not yet implemented. + +acc_prof_info.async + * Not yet implemented correctly for + ``acc_ev_compute_construct_start``. + + * In a compute construct, for host-fallback + execution/ ``acc_device_host`` it will always be + ``acc_async_sync``. + It's not clear if that's the expected behavior. + + * For ``acc_ev_device_init_start`` and ``acc_ev_device_init_end``, + it will always be ``acc_async_sync``. + It's not clear if that's the expected behavior. + +acc_prof_info.async_queue + There is no limited number of asynchronous queues in libgomp. + This will always have the same value as ``acc_prof_info.async``. + +acc_prof_info.src_file + Always ``NULL`` ; not yet implemented. + +acc_prof_info.func_name + Always ``NULL`` ; not yet implemented. + +acc_prof_info.line_no + Always ``-1`` ; not yet implemented. + +acc_prof_info.end_line_no + Always ``-1`` ; not yet implemented. + +acc_prof_info.func_line_no + Always ``-1`` ; not yet implemented. + +acc_prof_info.func_end_line_no + Always ``-1`` ; not yet implemented. + +acc_event_info.event_type, acc_event_info.*.event_type + Relating to ``acc_prof_info.event_type`` discussed above, in this + implementation, this will always be the same value as + ``acc_prof_info.event_type``. + +acc_event_info.\*.parent_construct + * Will be ``acc_construct_parallel`` for all OpenACC compute + constructs as well as many OpenACC Runtime API calls; should be the + one matching the actual construct, or + ``acc_construct_runtime_api``, respectively. + + * Will be ``acc_construct_enter_data`` or + ``acc_construct_exit_data`` when processing variable mappings + specified in OpenACC *declare* directives; should be + ``acc_construct_declare``. + + * For implicit ``acc_ev_device_init_start``, + ``acc_ev_device_init_end``, and explicit as well as implicit + ``acc_ev_alloc``, ``acc_ev_free``, + ``acc_ev_enqueue_upload_start``, ``acc_ev_enqueue_upload_end``, + ``acc_ev_enqueue_download_start``, and + ``acc_ev_enqueue_download_end``, will be + ``acc_construct_parallel`` ; should reflect the real parent + construct. + +acc_event_info.\*.implicit + For ``acc_ev_alloc``, ``acc_ev_free``, + ``acc_ev_enqueue_upload_start``, ``acc_ev_enqueue_upload_end``, + ``acc_ev_enqueue_download_start``, and + ``acc_ev_enqueue_download_end``, this currently will be ``1`` + also for explicit usage. + +acc_event_info.data_event.var_name + Always ``NULL`` ; not yet implemented. + +acc_event_info.data_event.host_ptr + For ``acc_ev_alloc``, and ``acc_ev_free``, this is always + ``NULL``. + +typedef union acc_api_info + ... as printed in 5.2.3. Third Argument: API-Specific + Information. This should obviously be ``typedef struct + acc_api_info``. + +acc_api_info.device_api + Possibly not yet implemented correctly for + ``acc_ev_compute_construct_start``, + ``acc_ev_device_init_start``, ``acc_ev_device_init_end`` : + will always be ``acc_device_api_none`` for these event types. + For ``acc_ev_enter_data_start``, it will be + ``acc_device_api_none`` in some cases. + +acc_api_info.device_type + Always the same as ``acc_prof_info.device_type``. + +acc_api_info.vendor + Always ``-1`` ; not yet implemented. + +acc_api_info.device_handle + Always ``NULL`` ; not yet implemented. + +acc_api_info.context_handle + Always ``NULL`` ; not yet implemented. + +acc_api_info.async_handle + Always ``NULL`` ; not yet implemented. + +Remarks about certain event types: + +acc_ev_device_init_start, acc_ev_device_init_end + * + .. See 'DEVICE_INIT_INSIDE_COMPUTE_CONSTRUCT' in + 'libgomp.oacc-c-c++-common/acc_prof-kernels-1.c', + 'libgomp.oacc-c-c++-common/acc_prof-parallel-1.c'. + + When a compute construct triggers implicit + ``acc_ev_device_init_start`` and ``acc_ev_device_init_end`` + events, they currently aren't *nested within* the corresponding + ``acc_ev_compute_construct_start`` and + ``acc_ev_compute_construct_end``, but they're currently observed + *before* ``acc_ev_compute_construct_start``. + It's not clear what to do: the standard asks us provide a lot of + details to the ``acc_ev_compute_construct_start`` callback, without + (implicitly) initializing a device before? + + * Callbacks for these event types will not be invoked for calls to the + ``acc_set_device_type`` and ``acc_set_device_num`` functions. + It's not clear if they should be. + +acc_ev_enter_data_start, acc_ev_enter_data_end, acc_ev_exit_data_start, acc_ev_exit_data_end + * Callbacks for these event types will also be invoked for OpenACC + *host_data* constructs. + It's not clear if they should be. + + * Callbacks for these event types will also be invoked when processing + variable mappings specified in OpenACC *declare* directives. + It's not clear if they should be. + +Callbacks for the following event types will be invoked, but dispatch +and information provided therein has not yet been thoroughly reviewed: + +* ``acc_ev_alloc`` + +* ``acc_ev_free`` + +* ``acc_ev_update_start``, ``acc_ev_update_end`` + +* ``acc_ev_enqueue_upload_start``, ``acc_ev_enqueue_upload_end`` + +* ``acc_ev_enqueue_download_start``, ``acc_ev_enqueue_download_end`` + +During device initialization, and finalization, respectively, +callbacks for the following event types will not yet be invoked: + +* ``acc_ev_alloc`` + +* ``acc_ev_free`` + +Callbacks for the following event types have not yet been implemented, +so currently won't be invoked: + +* ``acc_ev_device_shutdown_start``, ``acc_ev_device_shutdown_end`` + +* ``acc_ev_runtime_shutdown`` + +* ``acc_ev_create``, ``acc_ev_delete`` + +* ``acc_ev_wait_start``, ``acc_ev_wait_end`` + +For the following runtime library functions, not all expected +callbacks will be invoked (mostly concerning implicit device +initialization): + +* ``acc_get_num_devices`` + +* ``acc_set_device_type`` + +* ``acc_get_device_type`` + +* ``acc_set_device_num`` + +* ``acc_get_device_num`` + +* ``acc_init`` + +* ``acc_shutdown`` + +Aside from implicit device initialization, for the following runtime +library functions, no callbacks will be invoked for shared-memory +offloading devices (it's not clear if they should be): + +* ``acc_malloc`` + +* ``acc_free`` + +* ``acc_copyin``, ``acc_present_or_copyin``, ``acc_copyin_async`` + +* ``acc_create``, ``acc_present_or_create``, ``acc_create_async`` + +* ``acc_copyout``, ``acc_copyout_async``, ``acc_copyout_finalize``, ``acc_copyout_finalize_async`` + +* ``acc_delete``, ``acc_delete_async``, ``acc_delete_finalize``, ``acc_delete_finalize_async`` + +* ``acc_update_device``, ``acc_update_device_async`` + +* ``acc_update_self``, ``acc_update_self_async`` + +* ``acc_map_data``, ``acc_unmap_data`` + +* ``acc_memcpy_to_device``, ``acc_memcpy_to_device_async`` + +* ``acc_memcpy_from_device``, ``acc_memcpy_from_device_async`` \ No newline at end of file diff --git a/libgomp/doc/index.rst b/libgomp/doc/index.rst new file mode 100644 index 00000000000..066ed4848f1 --- /dev/null +++ b/libgomp/doc/index.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +GNU libgomp +=========== + +.. only:: html + + Contents: + +.. toctree:: + + copyright + introduction + enabling-openmp + openmp-implementation-status + openmp-runtime-library-routines + openmp-environment-variables + enabling-openacc + openacc-runtime-library-routines + openacc-environment-variables + cuda-streams-usage + openacc-library-interoperability + openacc-profiling-interface + openmp-implementation-specifics + offload-target-specifics + the-libgomp-abi + reporting-bugs + general-public-license-3 + gnu-free-documentation-license + funding + + indices-and-tables \ No newline at end of file diff --git a/libgomp/doc/indices-and-tables.rst b/libgomp/doc/indices-and-tables.rst new file mode 100644 index 00000000000..9799e4e2e48 --- /dev/null +++ b/libgomp/doc/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/libgomp/doc/introduction.rst b/libgomp/doc/introduction.rst new file mode 100644 index 00000000000..758fed7b006 --- /dev/null +++ b/libgomp/doc/introduction.rst @@ -0,0 +1,25 @@ +.. _top: + +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Introduction +============ + +.. index:: Introduction + +This manual documents the usage of libgomp, the GNU Offloading and +Multi Processing Runtime Library. This includes the GNU +implementation of the `OpenMP `_ Application +Programming Interface (API) for multi-platform shared-memory parallel +programming in C/C++ and Fortran, and the GNU implementation of the +`OpenACC `_ Application Programming +Interface (API) for offloading of code to accelerator devices in C/C++ +and Fortran. + +Originally, libgomp implemented the GNU OpenMP Runtime Library. Based +on this, support for OpenACC and offloading (both OpenACC and OpenMP +4's target construct) has been added later on, and the library's name +changed to GNU Offloading and Multi Processing Runtime Library. \ No newline at end of file diff --git a/libgomp/doc/memory-allocation-with-libmemkind.rst b/libgomp/doc/memory-allocation-with-libmemkind.rst new file mode 100644 index 00000000000..28c102c888d --- /dev/null +++ b/libgomp/doc/memory-allocation-with-libmemkind.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _memory-allocation-with-libmemkind: + +Memory allocation with libmemkind +********************************* + +On Linux systems, where the `memkind +library `_ (``libmemkind.so.0``) is available at runtime, it is used when +creating memory allocators requesting + +* the memory space ``omp_high_bw_mem_space`` + +* the memory space ``omp_large_cap_mem_space`` + +* the partition trait ``omp_atv_interleaved`` + +.. - + Offload-Target Specifics + - \ No newline at end of file diff --git a/libgomp/doc/nvptx.rst b/libgomp/doc/nvptx.rst new file mode 100644 index 00000000000..c121e9994b4 --- /dev/null +++ b/libgomp/doc/nvptx.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _nvptx: + +nvptx +***** + +On the hardware side, there is the hierarchy (fine to coarse): + +* thread + +* warp + +* thread block + +* streaming multiprocessor + +All OpenMP and OpenACC levels are used, i.e. + +* OpenMP's simd and OpenACC's vector map to threads + +* OpenMP's threads ('parallel') and OpenACC's workers map to warps + +* OpenMP's teams and OpenACC's gang use a threadpool with the + size of the number of teams or gangs, respectively. + +The used sizes are + +* The ``warp_size`` is always 32 + +* CUDA kernel launched: ``dim={#teams,1,1}, blocks={#threads,warp_size,1}``. + +Additional information can be obtained by setting the environment variable to +``GOMP_DEBUG=1`` (very verbose; grep for ``kernel.*launch`` for launch +parameters). + +GCC generates generic PTX ISA code, which is just-in-time compiled by CUDA, +which caches the JIT in the user's directory (see CUDA documentation; can be +tuned by the environment variables ``CUDA_CACHE_{DISABLE,MAXSIZE,PATH}``. + +Note: While PTX ISA is generic, the ``-mptx=`` and ``-march=`` commandline +options still affect the used PTX ISA code and, thus, the requirments on +CUDA version and hardware. + +The implementation remark: + +* I/O within OpenMP target regions and OpenACC parallel/kernels is supported + using the C library ``printf`` functions. Note that the Fortran + ``print`` / ``write`` statements are not supported, yet. + +* Compilation OpenMP code that contains ``requires reverse_offload`` + requires at least ``-march=sm_35``, compiling for ``-march=sm_30`` + is not supported. + +.. - + The libgomp ABI + - \ No newline at end of file diff --git a/libgomp/doc/offload-target-specifics.rst b/libgomp/doc/offload-target-specifics.rst new file mode 100644 index 00000000000..25d46d02cb0 --- /dev/null +++ b/libgomp/doc/offload-target-specifics.rst @@ -0,0 +1,17 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _offload-target-specifics: + +Offload-Target Specifics +------------------------ + +The following sections present notes on the offload-target specifics + +.. toctree:: + :maxdepth: 2 + + amd-radeon-gcn + nvptx \ No newline at end of file diff --git a/libgomp/doc/openacc-environment-variables.rst b/libgomp/doc/openacc-environment-variables.rst new file mode 100644 index 00000000000..ec677a788d7 --- /dev/null +++ b/libgomp/doc/openacc-environment-variables.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openacc-environment-variables: + +OpenACC Environment Variables +----------------------------- + +The variables :envvar:`ACC_DEVICE_TYPE` and :envvar:`ACC_DEVICE_NUM` +are defined by section 4 of the OpenACC specification in version 2.0. +The variable :envvar:`ACC_PROFLIB` +is defined by section 4 of the OpenACC specification in version 2.6. +The variable :envvar:`GCC_ACC_NOTIFY` is used for diagnostic purposes. + +.. toctree:: + :maxdepth: 2 + + openacc-environment-variables/accdevicetype + openacc-environment-variables/accdevicenum + openacc-environment-variables/accproflib + openacc-environment-variables/gccaccnotify \ No newline at end of file diff --git a/libgomp/doc/openacc-environment-variables/accdevicenum.rst b/libgomp/doc/openacc-environment-variables/accdevicenum.rst new file mode 100644 index 00000000000..2779126944c --- /dev/null +++ b/libgomp/doc/openacc-environment-variables/accdevicenum.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_device_num: + +ACC_DEVICE_NUM +************** + +Reference: + :openacc:`2.6`, section + 4.2. \ No newline at end of file diff --git a/libgomp/doc/openacc-environment-variables/accdevicetype.rst b/libgomp/doc/openacc-environment-variables/accdevicetype.rst new file mode 100644 index 00000000000..10aa4fcef7f --- /dev/null +++ b/libgomp/doc/openacc-environment-variables/accdevicetype.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_device_type: + +ACC_DEVICE_TYPE +*************** + +Reference: + :openacc:`2.6`, section + 4.1. \ No newline at end of file diff --git a/libgomp/doc/openacc-environment-variables/accproflib.rst b/libgomp/doc/openacc-environment-variables/accproflib.rst new file mode 100644 index 00000000000..3309368defb --- /dev/null +++ b/libgomp/doc/openacc-environment-variables/accproflib.rst @@ -0,0 +1,16 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_proflib: + +ACC_PROFLIB +*********** + +See also: + :ref:`acc_register_library`, :ref:`openacc-profiling-interface` + +Reference: + :openacc:`2.6`, section + 4.3. \ No newline at end of file diff --git a/libgomp/doc/openacc-environment-variables/gccaccnotify.rst b/libgomp/doc/openacc-environment-variables/gccaccnotify.rst new file mode 100644 index 00000000000..315795feb79 --- /dev/null +++ b/libgomp/doc/openacc-environment-variables/gccaccnotify.rst @@ -0,0 +1,12 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _gcc_acc_notify: + +GCC_ACC_NOTIFY +************** + +Description: + Print debug information pertaining to the accelerator. \ No newline at end of file diff --git a/libgomp/doc/openacc-introduction.rst b/libgomp/doc/openacc-introduction.rst new file mode 100644 index 00000000000..96d9f80c37a --- /dev/null +++ b/libgomp/doc/openacc-introduction.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Introduction +************ + +The OpenACC library uses the CUDA Driver API, and may interact with +programs that use the Runtime library directly, or another library +based on the Runtime library, e.g., CUBLAS [#f1]_. + +This chapter describes the use cases and what changes are +required in order to use both the OpenACC library and the CUBLAS and Runtime +libraries within a program. + +.. [#f1] See section 2.26, + "Interactions with the CUDA Driver API" in + "CUDA Runtime API", Version 5.5, and section 2.27, "VDPAU + Interoperability", in "CUDA Driver API", TRM-06703-001, Version 5.5, + for additional information on library interoperability. \ No newline at end of file diff --git a/libgomp/doc/openacc-library-and-environment-variables.rst b/libgomp/doc/openacc-library-and-environment-variables.rst new file mode 100644 index 00000000000..d9e06e3188b --- /dev/null +++ b/libgomp/doc/openacc-library-and-environment-variables.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +OpenACC library and environment variables +***************************************** + +There are two environment variables associated with the OpenACC library +that may be used to control the device type and device number: +:envvar:`ACC_DEVICE_TYPE` and :envvar:`ACC_DEVICE_NUM`, respectively. These two +environment variables can be used as an alternative to calling +``acc_set_device_num()``. As seen in the second use case, the device +type and device number were specified using ``acc_set_device_num()``. +If however, the aforementioned environment variables were set, then the +call to ``acc_set_device_num()`` would not be required. + +The use of the environment variables is only relevant when an OpenACC function +is called prior to a call to ``cudaCreate()``. If ``cudaCreate()`` +is called prior to a call to an OpenACC function, then you must call +``acc_set_device_num()`` [#f1]_. + +.. - + OpenACC Profiling Interface + - + +.. [#f1] More complete information + about :envvar:`ACC_DEVICE_TYPE` and :envvar:`ACC_DEVICE_NUM` can be found in + sections 4.1 and 4.2 of the `OpenACC `_ + Application Programming Interface”, Version 2.6. \ No newline at end of file diff --git a/libgomp/doc/openacc-library-interoperability.rst b/libgomp/doc/openacc-library-interoperability.rst new file mode 100644 index 00000000000..bdd5e22057b --- /dev/null +++ b/libgomp/doc/openacc-library-interoperability.rst @@ -0,0 +1,17 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openacc-library-interoperability: + +OpenACC Library Interoperability +-------------------------------- + +.. toctree:: + :maxdepth: 2 + + openacc-introduction + first-invocation-nvidia-cublas-library-api + first-invocation-openacc-library-api + openacc-library-and-environment-variables \ No newline at end of file diff --git a/libgomp/doc/openacc-profiling-interface.rst b/libgomp/doc/openacc-profiling-interface.rst new file mode 100644 index 00000000000..4c5e94a38f2 --- /dev/null +++ b/libgomp/doc/openacc-profiling-interface.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openacc-profiling-interface: + +OpenACC Profiling Interface +--------------------------- + +.. toctree:: + :maxdepth: 2 + + implementation-status-and-implementation-defined-behavior \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines.rst b/libgomp/doc/openacc-runtime-library-routines.rst new file mode 100644 index 00000000000..ec8ecd1b57f --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines.rst @@ -0,0 +1,74 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openacc-runtime-library-routines: + +OpenACC Runtime Library Routines +-------------------------------- + +The runtime routines described here are defined by section 3 of the OpenACC +specifications in version 2.6. +They have C linkage, and do not throw exceptions. +Generally, they are available only for the host, with the exception of +``acc_on_device``, which is available for both the host and the +acceleration device. + +.. toctree:: + :maxdepth: 2 + + openacc-runtime-library-routines/accgetnumdevices + openacc-runtime-library-routines/accsetdevicetype + openacc-runtime-library-routines/accgetdevicetype + openacc-runtime-library-routines/accsetdevicenum + openacc-runtime-library-routines/accgetdevicenum + openacc-runtime-library-routines/accgetproperty + openacc-runtime-library-routines/accasynctest + openacc-runtime-library-routines/accasynctestall + openacc-runtime-library-routines/accwait + openacc-runtime-library-routines/accwaitall + openacc-runtime-library-routines/accwaitallasync + openacc-runtime-library-routines/accwaitasync + openacc-runtime-library-routines/accinit + openacc-runtime-library-routines/accshutdown + openacc-runtime-library-routines/accondevice + openacc-runtime-library-routines/accmalloc + openacc-runtime-library-routines/accfree + openacc-runtime-library-routines/acccopyin + openacc-runtime-library-routines/accpresentorcopyin + openacc-runtime-library-routines/acccreate + openacc-runtime-library-routines/accpresentorcreate + openacc-runtime-library-routines/acccopyout + openacc-runtime-library-routines/accdelete + openacc-runtime-library-routines/accupdatedevice + openacc-runtime-library-routines/accupdateself + openacc-runtime-library-routines/accmapdata + openacc-runtime-library-routines/accunmapdata + openacc-runtime-library-routines/accdeviceptr + openacc-runtime-library-routines/acchostptr + openacc-runtime-library-routines/accispresent + openacc-runtime-library-routines/accmemcpytodevice + openacc-runtime-library-routines/accmemcpyfromdevice + openacc-runtime-library-routines/accattach + openacc-runtime-library-routines/accdetach + +API routines for target platforms. + +.. toctree:: + :maxdepth: 2 + + openacc-runtime-library-routines/accgetcurrentcudadevice + openacc-runtime-library-routines/accgetcurrentcudacontext + openacc-runtime-library-routines/accgetcudastream + openacc-runtime-library-routines/accsetcudastream + +API routines for the OpenACC Profiling Interface. + +.. toctree:: + :maxdepth: 2 + + openacc-runtime-library-routines/accprofregister + openacc-runtime-library-routines/accprofunregister + openacc-runtime-library-routines/accproflookup + openacc-runtime-library-routines/accregisterlibrary \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accasynctest.rst b/libgomp/doc/openacc-runtime-library-routines/accasynctest.rst new file mode 100644 index 00000000000..57b1025a6c4 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accasynctest.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_async_test: + +acc_async_test -- Test for completion of a specific asynchronous operation. +*************************************************************************** + +Description + This function tests for completion of the asynchronous operation specified + in :samp:`{arg}`. In C/C++, a non-zero value will be returned to indicate + the specified asynchronous operation has completed. While Fortran will return + a ``true``. If the asynchronous operation has not completed, C/C++ returns + a zero and Fortran returns a ``false``. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int acc_async_test(int arg);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``function acc_async_test(arg)`` + * - + - ``integer(kind=acc_handle_kind) arg`` + * - + - ``logical acc_async_test`` + +Reference: + :openacc:`2.6`, section + 3.2.9. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accasynctestall.rst b/libgomp/doc/openacc-runtime-library-routines/accasynctestall.rst new file mode 100644 index 00000000000..2191a26745b --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accasynctestall.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_async_test_all: + +acc_async_test_all -- Tests for completion of all asynchronous operations. +************************************************************************** + +Description + This function tests for completion of all asynchronous operations. + In C/C++, a non-zero value will be returned to indicate all asynchronous + operations have completed. While Fortran will return a ``true``. If + any asynchronous operation has not completed, C/C++ returns a zero and + Fortran returns a ``false``. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int acc_async_test_all(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``function acc_async_test()`` + * - + - ``logical acc_get_device_num`` + +Reference: + :openacc:`2.6`, section + 3.2.10. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accattach.rst b/libgomp/doc/openacc-runtime-library-routines/accattach.rst new file mode 100644 index 00000000000..ecc920350ba --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accattach.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_attach: + +acc_attach -- Let device pointer point to device-pointer target. +**************************************************************** + +Description + This function updates a pointer on the device from pointing to a host-pointer + address to pointing to the corresponding device data. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_attach(h_void **ptr);`` + * - *Prototype*: + - ``acc_attach_async(h_void **ptr, int async);`` + +Reference: + :openacc:`2.6`, section + 3.2.34. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/acccopyin.rst b/libgomp/doc/openacc-runtime-library-routines/acccopyin.rst new file mode 100644 index 00000000000..02c7aaa3548 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/acccopyin.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_copyin: + +acc_copyin -- Allocate device memory and copy host memory to it. +**************************************************************** + +Description + In C/C++, this function allocates :samp:`{len}` bytes of device memory + and maps it to the specified host address in :samp:`{a}`. The device + address of the newly allocated device memory is returned. + + In Fortran, two (2) forms are supported. In the first form, :samp:`{a}` specifies + a contiguous array section. The second form :samp:`{a}` specifies a + variable or array element and :samp:`{len}` specifies the length in bytes. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void *acc_copyin(h_void *a, size_t len);`` + * - *Prototype*: + - ``void *acc_copyin_async(h_void *a, size_t len, int async);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_copyin(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - *Interface*: + - ``subroutine acc_copyin(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - *Interface*: + - ``subroutine acc_copyin_async(a, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer(acc_handle_kind) :: async`` + * - *Interface*: + - ``subroutine acc_copyin_async(a, len, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - + - ``integer(acc_handle_kind) :: async`` + +Reference: + :openacc:`2.6`, section + 3.2.20. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/acccopyout.rst b/libgomp/doc/openacc-runtime-library-routines/acccopyout.rst new file mode 100644 index 00000000000..aa2194585b3 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/acccopyout.rst @@ -0,0 +1,85 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_copyout: + +acc_copyout -- Copy device memory to host memory. +************************************************* + +Description + This function copies mapped device memory to host memory which is specified + by host address :samp:`{a}` for a length :samp:`{len}` bytes in C/C++. + + In Fortran, two (2) forms are supported. In the first form, :samp:`{a}` specifies + a contiguous array section. The second form :samp:`{a}` specifies a variable or + array element and :samp:`{len}` specifies the length in bytes. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_copyout(h_void *a, size_t len);`` + * - *Prototype*: + - ``acc_copyout_async(h_void *a, size_t len, int async);`` + * - *Prototype*: + - ``acc_copyout_finalize(h_void *a, size_t len);`` + * - *Prototype*: + - ``acc_copyout_finalize_async(h_void *a, size_t len, int async);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_copyout(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - *Interface*: + - ``subroutine acc_copyout(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - *Interface*: + - ``subroutine acc_copyout_async(a, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer(acc_handle_kind) :: async`` + * - *Interface*: + - ``subroutine acc_copyout_async(a, len, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - + - ``integer(acc_handle_kind) :: async`` + * - *Interface*: + - ``subroutine acc_copyout_finalize(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - *Interface*: + - ``subroutine acc_copyout_finalize(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - *Interface*: + - ``subroutine acc_copyout_finalize_async(a, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer(acc_handle_kind) :: async`` + * - *Interface*: + - ``subroutine acc_copyout_finalize_async(a, len, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - + - ``integer(acc_handle_kind) :: async`` + +Reference: + :openacc:`2.6`, section + 3.2.22. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/acccreate.rst b/libgomp/doc/openacc-runtime-library-routines/acccreate.rst new file mode 100644 index 00000000000..ab02142547d --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/acccreate.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_create: + +acc_create -- Allocate device memory and map it to host memory. +*************************************************************** + +Description + This function allocates device memory and maps it to host memory specified + by the host address :samp:`{a}` with a length of :samp:`{len}` bytes. In C/C++, + the function returns the device address of the allocated device memory. + + In Fortran, two (2) forms are supported. In the first form, :samp:`{a}` specifies + a contiguous array section. The second form :samp:`{a}` specifies a variable or + array element and :samp:`{len}` specifies the length in bytes. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void *acc_create(h_void *a, size_t len);`` + * - *Prototype*: + - ``void *acc_create_async(h_void *a, size_t len, int async);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_create(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - *Interface*: + - ``subroutine acc_create(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - *Interface*: + - ``subroutine acc_create_async(a, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer(acc_handle_kind) :: async`` + * - *Interface*: + - ``subroutine acc_create_async(a, len, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - + - ``integer(acc_handle_kind) :: async`` + +Reference: + :openacc:`2.6`, section + 3.2.21. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accdelete.rst b/libgomp/doc/openacc-runtime-library-routines/accdelete.rst new file mode 100644 index 00000000000..6814e543fd3 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accdelete.rst @@ -0,0 +1,85 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_delete: + +acc_delete -- Free device memory. +********************************* + +Description + This function frees previously allocated device memory specified by + the device address :samp:`{a}` and the length of :samp:`{len}` bytes. + + In Fortran, two (2) forms are supported. In the first form, :samp:`{a}` specifies + a contiguous array section. The second form :samp:`{a}` specifies a variable or + array element and :samp:`{len}` specifies the length in bytes. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_delete(h_void *a, size_t len);`` + * - *Prototype*: + - ``acc_delete_async(h_void *a, size_t len, int async);`` + * - *Prototype*: + - ``acc_delete_finalize(h_void *a, size_t len);`` + * - *Prototype*: + - ``acc_delete_finalize_async(h_void *a, size_t len, int async);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_delete(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - *Interface*: + - ``subroutine acc_delete(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - *Interface*: + - ``subroutine acc_delete_async(a, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer(acc_handle_kind) :: async`` + * - *Interface*: + - ``subroutine acc_delete_async(a, len, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - + - ``integer(acc_handle_kind) :: async`` + * - *Interface*: + - ``subroutine acc_delete_finalize(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - *Interface*: + - ``subroutine acc_delete_finalize(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - *Interface*: + - ``subroutine acc_delete_async_finalize(a, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer(acc_handle_kind) :: async`` + * - *Interface*: + - ``subroutine acc_delete_async_finalize(a, len, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - + - ``integer(acc_handle_kind) :: async`` + +Reference: + :openacc:`2.6`, section + 3.2.23. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accdetach.rst b/libgomp/doc/openacc-runtime-library-routines/accdetach.rst new file mode 100644 index 00000000000..ed3691a8afa --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accdetach.rst @@ -0,0 +1,29 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_detach: + +acc_detach -- Let device pointer point to host-pointer target. +************************************************************** + +Description + This function updates a pointer on the device from pointing to a device-pointer + address to pointing to the corresponding host data. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_detach(h_void **ptr);`` + * - *Prototype*: + - ``acc_detach_async(h_void **ptr, int async);`` + * - *Prototype*: + - ``acc_detach_finalize(h_void **ptr);`` + * - *Prototype*: + - ``acc_detach_finalize_async(h_void **ptr, int async);`` + +Reference: + :openacc:`2.6`, section + 3.2.35. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accdeviceptr.rst b/libgomp/doc/openacc-runtime-library-routines/accdeviceptr.rst new file mode 100644 index 00000000000..094cca40b73 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accdeviceptr.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_deviceptr: + +acc_deviceptr -- Get device pointer associated with specific host address. +************************************************************************** + +Description + This function returns the device address that has been mapped to the + host address specified by :samp:`{h}`. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void *acc_deviceptr(h_void *h);`` + +Reference: + :openacc:`2.6`, section + 3.2.28. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accfree.rst b/libgomp/doc/openacc-runtime-library-routines/accfree.rst new file mode 100644 index 00000000000..8f5b4f01016 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accfree.rst @@ -0,0 +1,22 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_free: + +acc_free -- Free device memory. +******************************* + +Description + Free previously allocated device memory at the device address ``a``. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_free(d_void *a);`` + +Reference: + :openacc:`2.6`, section + 3.2.19. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accgetcudastream.rst b/libgomp/doc/openacc-runtime-library-routines/accgetcudastream.rst new file mode 100644 index 00000000000..d13d913a26e --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accgetcudastream.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_get_cuda_stream: + +acc_get_cuda_stream -- Get CUDA stream handle. +********************************************** + +Description + This function returns the CUDA stream handle for the queue :samp:`{async}`. + This handle is the same as used by the CUDA Runtime or Driver API's. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void *acc_get_cuda_stream(int async);`` + +Reference: + :openacc:`2.6`, section + A.2.1.3. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accgetcurrentcudacontext.rst b/libgomp/doc/openacc-runtime-library-routines/accgetcurrentcudacontext.rst new file mode 100644 index 00000000000..b39db0e36bf --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accgetcurrentcudacontext.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_get_current_cuda_context: + +acc_get_current_cuda_context -- Get CUDA context handle. +******************************************************** + +Description + This function returns the CUDA context handle. This handle is the same + as used by the CUDA Runtime or Driver API's. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void *acc_get_current_cuda_context(void);`` + +Reference: + :openacc:`2.6`, section + A.2.1.2. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accgetcurrentcudadevice.rst b/libgomp/doc/openacc-runtime-library-routines/accgetcurrentcudadevice.rst new file mode 100644 index 00000000000..17ba5754e66 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accgetcurrentcudadevice.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_get_current_cuda_device: + +acc_get_current_cuda_device -- Get CUDA device handle. +****************************************************** + +Description + This function returns the CUDA device handle. This handle is the same + as used by the CUDA Runtime or Driver API's. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void *acc_get_current_cuda_device(void);`` + +Reference: + :openacc:`2.6`, section + A.2.1.1. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accgetdevicenum.rst b/libgomp/doc/openacc-runtime-library-routines/accgetdevicenum.rst new file mode 100644 index 00000000000..40c97b8923f --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accgetdevicenum.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_get_device_num: + +acc_get_device_num -- Get device number to be used. +*************************************************** + +Description + This function returns which device number associated with the specified device + type :samp:`{devicetype}`, will be used when executing a parallel or kernels + region. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int acc_get_device_num(acc_device_t devicetype);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``function acc_get_device_num(devicetype)`` + * - + - ``integer(kind=acc_device_kind) devicetype`` + * - + - ``integer acc_get_device_num`` + +Reference: + :openacc:`2.6`, section + 3.2.5. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accgetdevicetype.rst b/libgomp/doc/openacc-runtime-library-routines/accgetdevicetype.rst new file mode 100644 index 00000000000..45cc03b2749 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accgetdevicetype.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_get_device_type: + +acc_get_device_type -- Get type of device accelerator to be used. +***************************************************************** + +Description + This function returns what device type will be used when executing a + parallel or kernels region. + + This function returns ``acc_device_none`` if + ``acc_get_device_type`` is called from + ``acc_ev_device_init_start``, ``acc_ev_device_init_end`` + callbacks of the OpenACC Profiling Interface (:ref:`openacc-profiling-interface`), that is, if the device is currently being initialized. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_device_t acc_get_device_type(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``function acc_get_device_type(void)`` + * - + - ``integer(kind=acc_device_kind) acc_get_device_type`` + +Reference: + :openacc:`2.6`, section + 3.2.3. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accgetnumdevices.rst b/libgomp/doc/openacc-runtime-library-routines/accgetnumdevices.rst new file mode 100644 index 00000000000..529f129467f --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accgetnumdevices.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_get_num_devices: + +acc_get_num_devices -- Get number of devices for given device type +****************************************************************** + +Description + This function returns a value indicating the number of devices available + for the device type specified in :samp:`{devicetype}`. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int acc_get_num_devices(acc_device_t devicetype);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function acc_get_num_devices(devicetype)`` + * - + - ``integer(kind=acc_device_kind) devicetype`` + +Reference: + :openacc:`2.6`, section + 3.2.1. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accgetproperty.rst b/libgomp/doc/openacc-runtime-library-routines/accgetproperty.rst new file mode 100644 index 00000000000..e6687e9fb90 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accgetproperty.rst @@ -0,0 +1,60 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: acc_get_property, acc_get_property_string + +.. _acc_get_property: + +acc_get_property -- Get device property. +**************************************** + +Description + These routines return the value of the specified :samp:`{property}` for the + device being queried according to :samp:`{devicenum}` and :samp:`{devicetype}`. + Integer-valued and string-valued properties are returned by + ``acc_get_property`` and ``acc_get_property_string`` respectively. + The Fortran ``acc_get_property_string`` subroutine returns the string + retrieved in its fourth argument while the remaining entry points are + functions, which pass the return value as their result. + + Note for Fortran, only: the OpenACC technical committee corrected and, hence, + modified the interface introduced in OpenACC 2.6. The kind-value parameter + ``acc_device_property`` has been renamed to ``acc_device_property_kind`` + for consistency and the return type of the ``acc_get_property`` function is + now a ``c_size_t`` integer instead of a ``acc_device_property`` integer. + The parameter ``acc_device_property`` will continue to be provided, + but might be removed in a future version of GCC. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``size_t acc_get_property(int devicenum, acc_device_t devicetype, acc_device_property_t property);`` + * - *Prototype*: + - ``const char *acc_get_property_string(int devicenum, acc_device_t devicetype, acc_device_property_t property);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``function acc_get_property(devicenum, devicetype, property)`` + * - *Interface*: + - ``subroutine acc_get_property_string(devicenum, devicetype, property, string)`` + * - + - ``use ISO_C_Binding, only: c_size_t`` + * - + - ``integer devicenum`` + * - + - ``integer(kind=acc_device_kind) devicetype`` + * - + - ``integer(kind=acc_device_property_kind) property`` + * - + - ``integer(kind=c_size_t) acc_get_property`` + * - + - ``character(*) string`` + +Reference: + :openacc:`2.6`, section + 3.2.6. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/acchostptr.rst b/libgomp/doc/openacc-runtime-library-routines/acchostptr.rst new file mode 100644 index 00000000000..4c63f948ab2 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/acchostptr.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_hostptr: + +acc_hostptr -- Get host pointer associated with specific device address. +************************************************************************ + +Description + This function returns the host address that has been mapped to the + device address specified by :samp:`{d}`. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void *acc_hostptr(d_void *d);`` + +Reference: + :openacc:`2.6`, section + 3.2.29. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accinit.rst b/libgomp/doc/openacc-runtime-library-routines/accinit.rst new file mode 100644 index 00000000000..b656c983b2e --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accinit.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_init: + +acc_init -- Initialize runtime for a specific device type. +********************************************************** + +Description + This function initializes the runtime for the device type specified in + :samp:`{devicetype}`. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_init(acc_device_t devicetype);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_init(devicetype)`` + * - + - ``integer(acc_device_kind) devicetype`` + +Reference: + :openacc:`2.6`, section + 3.2.7. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accispresent.rst b/libgomp/doc/openacc-runtime-library-routines/accispresent.rst new file mode 100644 index 00000000000..0513f63c597 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accispresent.rst @@ -0,0 +1,50 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_is_present: + +acc_is_present -- Indicate whether host variable / array is present on device. +****************************************************************************** + +Description + This function indicates whether the specified host address in :samp:`{a}` and a + length of :samp:`{len}` bytes is present on the device. In C/C++, a non-zero + value is returned to indicate the presence of the mapped memory on the + device. A zero is returned to indicate the memory is not mapped on the + device. + + In Fortran, two (2) forms are supported. In the first form, :samp:`{a}` specifies + a contiguous array section. The second form :samp:`{a}` specifies a variable or + array element and :samp:`{len}` specifies the length in bytes. If the host + memory is mapped to device memory, then a ``true`` is returned. Otherwise, + a ``false`` is return to indicate the mapped memory is not present. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int acc_is_present(h_void *a, size_t len);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``function acc_is_present(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``logical acc_is_present`` + * - *Interface*: + - ``function acc_is_present(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - + - ``logical acc_is_present`` + +Reference: + :openacc:`2.6`, section + 3.2.30. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accmalloc.rst b/libgomp/doc/openacc-runtime-library-routines/accmalloc.rst new file mode 100644 index 00000000000..2602b9e2ef1 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accmalloc.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_malloc: + +acc_malloc -- Allocate device memory. +************************************* + +Description + This function allocates :samp:`{len}` bytes of device memory. It returns + the device address of the allocated memory. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``d_void* acc_malloc(size_t len);`` + +Reference: + :openacc:`2.6`, section + 3.2.18. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accmapdata.rst b/libgomp/doc/openacc-runtime-library-routines/accmapdata.rst new file mode 100644 index 00000000000..0a586809076 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accmapdata.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_map_data: + +acc_map_data -- Map previously allocated device memory to host memory. +********************************************************************** + +Description + This function maps previously allocated device and host memory. The device + memory is specified with the device address :samp:`{d}`. The host memory is + specified with the host address :samp:`{h}` and a length of :samp:`{len}`. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_map_data(h_void *h, d_void *d, size_t len);`` + +Reference: + :openacc:`2.6`, section + 3.2.26. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accmemcpyfromdevice.rst b/libgomp/doc/openacc-runtime-library-routines/accmemcpyfromdevice.rst new file mode 100644 index 00000000000..3e23b5bb920 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accmemcpyfromdevice.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_memcpy_from_device: + +acc_memcpy_from_device -- Copy device memory to host memory. +************************************************************ + +Description + This function copies host memory specified by host address of :samp:`{src}` from + device memory specified by the device address :samp:`{dest}` for a length of + :samp:`{bytes}` bytes. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_memcpy_from_device(d_void *dest, h_void *src, size_t bytes);`` + +Reference: + :openacc:`2.6`, section + 3.2.32. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accmemcpytodevice.rst b/libgomp/doc/openacc-runtime-library-routines/accmemcpytodevice.rst new file mode 100644 index 00000000000..e57c06e2bed --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accmemcpytodevice.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_memcpy_to_device: + +acc_memcpy_to_device -- Copy host memory to device memory. +********************************************************** + +Description + This function copies host memory specified by host address of :samp:`{src}` to + device memory specified by the device address :samp:`{dest}` for a length of + :samp:`{bytes}` bytes. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_memcpy_to_device(d_void *dest, h_void *src, size_t bytes);`` + +Reference: + :openacc:`2.6`, section + 3.2.31. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accondevice.rst b/libgomp/doc/openacc-runtime-library-routines/accondevice.rst new file mode 100644 index 00000000000..f5c89768ae1 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accondevice.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_on_device: + +acc_on_device -- Whether executing on a particular device +********************************************************* + +Description: + This function returns whether the program is executing on a particular + device specified in :samp:`{devicetype}`. In C/C++ a non-zero value is + returned to indicate the device is executing on the specified device type. + In Fortran, ``true`` will be returned. If the program is not executing + on the specified device type C/C++ will return a zero, while Fortran will + return ``false``. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_on_device(acc_device_t devicetype);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``function acc_on_device(devicetype)`` + * - + - ``integer(acc_device_kind) devicetype`` + * - + - ``logical acc_on_device`` + +Reference: + :openacc:`2.6`, section + 3.2.17. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accpresentorcopyin.rst b/libgomp/doc/openacc-runtime-library-routines/accpresentorcopyin.rst new file mode 100644 index 00000000000..5f17155c78f --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accpresentorcopyin.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_present_or_copyin: + +acc_present_or_copyin -- If the data is not present on the device, allocate device memory and copy from host memory. +******************************************************************************************************************** + +Description + This function tests if the host data specified by :samp:`{a}` and of length + :samp:`{len}` is present or not. If it is not present, then device memory + will be allocated and the host memory copied. The device address of + the newly allocated device memory is returned. + + In Fortran, two (2) forms are supported. In the first form, :samp:`{a}` specifies + a contiguous array section. The second form :samp:`{a}` specifies a variable or + array element and :samp:`{len}` specifies the length in bytes. + + Note that ``acc_present_or_copyin`` and ``acc_pcopyin`` exist for + backward compatibility with OpenACC 2.0; use :ref:`acc_copyin` instead. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void *acc_present_or_copyin(h_void *a, size_t len);`` + * - *Prototype*: + - ``void *acc_pcopyin(h_void *a, size_t len);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_present_or_copyin(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - *Interface*: + - ``subroutine acc_present_or_copyin(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - *Interface*: + - ``subroutine acc_pcopyin(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - *Interface*: + - ``subroutine acc_pcopyin(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + +Reference: + :openacc:`2.6`, section + 3.2.20. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accpresentorcreate.rst b/libgomp/doc/openacc-runtime-library-routines/accpresentorcreate.rst new file mode 100644 index 00000000000..b1bff29a74c --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accpresentorcreate.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_present_or_create: + +acc_present_or_create -- If the data is not present on the device, allocate device memory and map it to host memory. +******************************************************************************************************************** + +Description + This function tests if the host data specified by :samp:`{a}` and of length + :samp:`{len}` is present or not. If it is not present, then device memory + will be allocated and mapped to host memory. In C/C++, the device address + of the newly allocated device memory is returned. + + In Fortran, two (2) forms are supported. In the first form, :samp:`{a}` specifies + a contiguous array section. The second form :samp:`{a}` specifies a variable or + array element and :samp:`{len}` specifies the length in bytes. + + Note that ``acc_present_or_create`` and ``acc_pcreate`` exist for + backward compatibility with OpenACC 2.0; use :ref:`acc_create` instead. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void *acc_present_or_create(h_void *a, size_t len)`` + * - *Prototype*: + - ``void *acc_pcreate(h_void *a, size_t len)`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_present_or_create(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - *Interface*: + - ``subroutine acc_present_or_create(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - *Interface*: + - ``subroutine acc_pcreate(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - *Interface*: + - ``subroutine acc_pcreate(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + +Reference: + :openacc:`2.6`, section + 3.2.21. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accproflookup.rst b/libgomp/doc/openacc-runtime-library-routines/accproflookup.rst new file mode 100644 index 00000000000..91f37656e2e --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accproflookup.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_prof_lookup: + +acc_prof_lookup -- Obtain inquiry functions. +******************************************** + +Description: + Function to obtain inquiry functions. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_query_fn acc_prof_lookup (const char *);`` + +See also: + :ref:`openacc-profiling-interface` + +Reference: + :openacc:`2.6`, section + 5.3. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accprofregister.rst b/libgomp/doc/openacc-runtime-library-routines/accprofregister.rst new file mode 100644 index 00000000000..20dbe69fd31 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accprofregister.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_prof_register: + +acc_prof_register -- Register callbacks. +**************************************** + +Description: + This function registers callbacks. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void acc_prof_register (acc_event_t, acc_prof_callback, acc_register_t);`` + +See also: + :ref:`openacc-profiling-interface` + +Reference: + :openacc:`2.6`, section + 5.3. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accprofunregister.rst b/libgomp/doc/openacc-runtime-library-routines/accprofunregister.rst new file mode 100644 index 00000000000..bc648d28ae6 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accprofunregister.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_prof_unregister: + +acc_prof_unregister -- Unregister callbacks. +******************************************** + +Description: + This function unregisters callbacks. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void acc_prof_unregister (acc_event_t, acc_prof_callback, acc_register_t);`` + +See also: + :ref:`openacc-profiling-interface` + +Reference: + :openacc:`2.6`, section + 5.3. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accregisterlibrary.rst b/libgomp/doc/openacc-runtime-library-routines/accregisterlibrary.rst new file mode 100644 index 00000000000..befa7d3fae2 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accregisterlibrary.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_register_library: + +acc_register_library -- Library registration. +********************************************* + +Description: + Function for library registration. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void acc_register_library (acc_prof_reg, acc_prof_reg, acc_prof_lookup_func);`` + +See also: + :ref:`openacc-profiling-interface`, :ref:`ACC_PROFLIB` + +Reference: + :openacc:`2.6`, section + 5.3. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accsetcudastream.rst b/libgomp/doc/openacc-runtime-library-routines/accsetcudastream.rst new file mode 100644 index 00000000000..d400baa0b09 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accsetcudastream.rst @@ -0,0 +1,28 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_set_cuda_stream: + +acc_set_cuda_stream -- Set CUDA stream handle. +********************************************** + +Description + This function associates the stream handle specified by :samp:`{stream}` with + the queue :samp:`{async}`. + + This cannot be used to change the stream handle associated with + ``acc_async_sync``. + + The return value is not specified. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int acc_set_cuda_stream(int async, void *stream);`` + +Reference: + :openacc:`2.6`, section + A.2.1.4. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accsetdevicenum.rst b/libgomp/doc/openacc-runtime-library-routines/accsetdevicenum.rst new file mode 100644 index 00000000000..a87e385be18 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accsetdevicenum.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_set_device_num: + +acc_set_device_num -- Set device number to use. +*********************************************** + +Description + This function will indicate to the runtime which device number, + specified by :samp:`{devicenum}`, associated with the specified device + type :samp:`{devicetype}`. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_set_device_num(int devicenum, acc_device_t devicetype);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_set_device_num(devicenum, devicetype)`` + * - + - ``integer devicenum`` + * - + - ``integer(kind=acc_device_kind) devicetype`` + +Reference: + :openacc:`2.6`, section + 3.2.4. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accsetdevicetype.rst b/libgomp/doc/openacc-runtime-library-routines/accsetdevicetype.rst new file mode 100644 index 00000000000..fa8ca764bf6 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accsetdevicetype.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_set_device_type: + +acc_set_device_type -- Set type of device accelerator to use. +************************************************************* + +Description + This function indicates to the runtime library which device type, specified + in :samp:`{devicetype}`, to use when executing a parallel or kernels region. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_set_device_type(acc_device_t devicetype);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_set_device_type(devicetype)`` + * - + - ``integer(kind=acc_device_kind) devicetype`` + +Reference: + :openacc:`2.6`, section + 3.2.2. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accshutdown.rst b/libgomp/doc/openacc-runtime-library-routines/accshutdown.rst new file mode 100644 index 00000000000..f214d4d4e61 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accshutdown.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_shutdown: + +acc_shutdown -- Shuts down the runtime for a specific device type. +****************************************************************** + +Description + This function shuts down the runtime for the device type specified in + :samp:`{devicetype}`. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_shutdown(acc_device_t devicetype);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_shutdown(devicetype)`` + * - + - ``integer(acc_device_kind) devicetype`` + +Reference: + :openacc:`2.6`, section + 3.2.8. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accunmapdata.rst b/libgomp/doc/openacc-runtime-library-routines/accunmapdata.rst new file mode 100644 index 00000000000..bea0388c37e --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accunmapdata.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_unmap_data: + +acc_unmap_data -- Unmap device memory from host memory. +******************************************************* + +Description + This function unmaps previously mapped device and host memory. The latter + specified by :samp:`{h}`. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_unmap_data(h_void *h);`` + +Reference: + :openacc:`2.6`, section + 3.2.27. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accupdatedevice.rst b/libgomp/doc/openacc-runtime-library-routines/accupdatedevice.rst new file mode 100644 index 00000000000..6fbc269ecf9 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accupdatedevice.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_update_device: + +acc_update_device -- Update device memory from mapped host memory. +****************************************************************** + +Description + This function updates the device copy from the previously mapped host memory. + The host memory is specified with the host address :samp:`{a}` and a length of + :samp:`{len}` bytes. + + In Fortran, two (2) forms are supported. In the first form, :samp:`{a}` specifies + a contiguous array section. The second form :samp:`{a}` specifies a variable or + array element and :samp:`{len}` specifies the length in bytes. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_update_device(h_void *a, size_t len);`` + * - *Prototype*: + - ``acc_update_device(h_void *a, size_t len, async);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_update_device(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - *Interface*: + - ``subroutine acc_update_device(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - *Interface*: + - ``subroutine acc_update_device_async(a, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer(acc_handle_kind) :: async`` + * - *Interface*: + - ``subroutine acc_update_device_async(a, len, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - + - ``integer(acc_handle_kind) :: async`` + +Reference: + :openacc:`2.6`, section + 3.2.24. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accupdateself.rst b/libgomp/doc/openacc-runtime-library-routines/accupdateself.rst new file mode 100644 index 00000000000..b1eabb998a6 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accupdateself.rst @@ -0,0 +1,58 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_update_self: + +acc_update_self -- Update host memory from mapped device memory. +**************************************************************** + +Description + This function updates the host copy from the previously mapped device memory. + The host memory is specified with the host address :samp:`{a}` and a length of + :samp:`{len}` bytes. + + In Fortran, two (2) forms are supported. In the first form, :samp:`{a}` specifies + a contiguous array section. The second form :samp:`{a}` specifies a variable or + array element and :samp:`{len}` specifies the length in bytes. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_update_self(h_void *a, size_t len);`` + * - *Prototype*: + - ``acc_update_self_async(h_void *a, size_t len, int async);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_update_self(a)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - *Interface*: + - ``subroutine acc_update_self(a, len)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - *Interface*: + - ``subroutine acc_update_self_async(a, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer(acc_handle_kind) :: async`` + * - *Interface*: + - ``subroutine acc_update_self_async(a, len, async)`` + * - + - ``type, dimension(:[,:]...) :: a`` + * - + - ``integer len`` + * - + - ``integer(acc_handle_kind) :: async`` + +Reference: + :openacc:`2.6`, section + 3.2.25. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accwait.rst b/libgomp/doc/openacc-runtime-library-routines/accwait.rst new file mode 100644 index 00000000000..27dc78d0f89 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accwait.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_wait: + +acc_wait -- Wait for completion of a specific asynchronous operation. +********************************************************************* + +Description + This function waits for completion of the asynchronous operation + specified in :samp:`{arg}`. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_wait(arg);`` + * - *Prototype (OpenACC 1.0 compatibility)*: + - ``acc_async_wait(arg);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_wait(arg)`` + * - + - ``integer(acc_handle_kind) arg`` + * - *Interface (OpenACC 1.0 compatibility)*: + - ``subroutine acc_async_wait(arg)`` + * - + - ``integer(acc_handle_kind) arg`` + +Reference: + :openacc:`2.6`, section + 3.2.11. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accwaitall.rst b/libgomp/doc/openacc-runtime-library-routines/accwaitall.rst new file mode 100644 index 00000000000..398c248840b --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accwaitall.rst @@ -0,0 +1,32 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_wait_all: + +acc_wait_all -- Waits for completion of all asynchronous operations. +******************************************************************** + +Description + This function waits for the completion of all asynchronous operations. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_wait_all(void);`` + * - *Prototype (OpenACC 1.0 compatibility)*: + - ``acc_async_wait_all(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_wait_all()`` + * - *Interface (OpenACC 1.0 compatibility)*: + - ``subroutine acc_async_wait_all()`` + +Reference: + :openacc:`2.6`, section + 3.2.13. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accwaitallasync.rst b/libgomp/doc/openacc-runtime-library-routines/accwaitallasync.rst new file mode 100644 index 00000000000..6589f2a7a59 --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accwaitallasync.rst @@ -0,0 +1,32 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_wait_all_async: + +acc_wait_all_async -- Wait for completion of all asynchronous operations. +************************************************************************* + +Description + This function enqueues a wait operation on the queue :samp:`{async}` for any + and all asynchronous operations that have been previously enqueued on + any queue. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_wait_all_async(int async);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_wait_all_async(async)`` + * - + - ``integer(acc_handle_kind) async`` + +Reference: + :openacc:`2.6`, section + 3.2.14. \ No newline at end of file diff --git a/libgomp/doc/openacc-runtime-library-routines/accwaitasync.rst b/libgomp/doc/openacc-runtime-library-routines/accwaitasync.rst new file mode 100644 index 00000000000..1fbb54b350a --- /dev/null +++ b/libgomp/doc/openacc-runtime-library-routines/accwaitasync.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _acc_wait_async: + +acc_wait_async -- Wait for completion of asynchronous operations. +***************************************************************** + +Description + This function enqueues a wait operation on queue :samp:`{async}` for any and all + asynchronous operations enqueued on queue :samp:`{arg}`. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``acc_wait_async(int arg, int async);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine acc_wait_async(arg, async)`` + * - + - ``integer(acc_handle_kind) arg, async`` + +Reference: + :openacc:`2.6`, section + 3.2.12. \ No newline at end of file diff --git a/libgomp/doc/openmp-context-selectors.rst b/libgomp/doc/openmp-context-selectors.rst new file mode 100644 index 00000000000..8a32cf17116 --- /dev/null +++ b/libgomp/doc/openmp-context-selectors.rst @@ -0,0 +1,28 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openmp-context-selectors: + +OpenMP Context Selectors +************************ + +``vendor`` is always ``gnu``. References are to the GCC manual. + +.. list-table:: + :header-rows: 1 + + * - ``arch`` + - ``kind`` + - ``isa`` + + * - ``x86``, ``x86_64``, ``i386``, ``i486``, ``i586``, ``i686``, ``ia32`` + - ``host`` + - See ``-m...`` flags in :ref:`gcc:x86-options` (without ``-m``) + * - ``amdgcn``, ``gcn`` + - ``gpu`` + - See ``-march=`` in :ref:`gcc:amd-gcn-options` + * - ``nvptx`` + - ``gpu`` + - See ``-march=`` in :ref:`gcc:nvidia-ptx-options` \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables.rst b/libgomp/doc/openmp-environment-variables.rst new file mode 100644 index 00000000000..0893e8d02ca --- /dev/null +++ b/libgomp/doc/openmp-environment-variables.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _environment-variables: + +OpenMP Environment Variables +---------------------------- + +The environment variables which beginning with :envvar:`OMP_` are defined by +section 4 of the OpenMP specification in version 4.5, while those +beginning with :envvar:`GOMP_` are GNU extensions. + +.. toctree:: + :maxdepth: 2 + + openmp-environment-variables/ompcancellation + openmp-environment-variables/ompdisplayenv + openmp-environment-variables/ompdefaultdevice + openmp-environment-variables/ompdynamic + openmp-environment-variables/ompmaxactivelevels + openmp-environment-variables/ompmaxtaskpriority + openmp-environment-variables/ompnested + openmp-environment-variables/ompnumteams + openmp-environment-variables/ompnumthreads + openmp-environment-variables/ompprocbind + openmp-environment-variables/ompplaces + openmp-environment-variables/ompstacksize + openmp-environment-variables/ompschedule + openmp-environment-variables/omptargetoffload + openmp-environment-variables/ompteamsthreadlimit + openmp-environment-variables/ompthreadlimit + openmp-environment-variables/ompwaitpolicy + openmp-environment-variables/gompcpuaffinity + openmp-environment-variables/gompdebug + openmp-environment-variables/gompstacksize + openmp-environment-variables/gompspincount + openmp-environment-variables/gomprtemsthreadpools \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/gompcpuaffinity.rst b/libgomp/doc/openmp-environment-variables/gompcpuaffinity.rst new file mode 100644 index 00000000000..9b15d11953a --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/gompcpuaffinity.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _gomp_cpu_affinity: + +GOMP_CPU_AFFINITY -- Bind threads to specific CPUs +************************************************** + +Description: + Binds threads to specific CPUs. The variable should contain a space-separated + or comma-separated list of CPUs. This list may contain different kinds of + entries: either single CPU numbers in any order, a range of CPUs (M-N) + or a range with some stride (M-N:S). CPU numbers are zero based. For example, + ``GOMP_CPU_AFFINITY="0 3 1-2 4-15:2"`` will bind the initial thread + to CPU 0, the second to CPU 3, the third to CPU 1, the fourth to + CPU 2, the fifth to CPU 4, the sixth through tenth to CPUs 6, 8, 10, 12, + and 14 respectively and then start assigning back from the beginning of + the list. ``GOMP_CPU_AFFINITY=0`` binds all threads to CPU 0. + + There is no libgomp library routine to determine whether a CPU affinity + specification is in effect. As a workaround, language-specific library + functions, e.g., ``getenv`` in C or ``GET_ENVIRONMENT_VARIABLE`` in + Fortran, may be used to query the setting of the ``GOMP_CPU_AFFINITY`` + environment variable. A defined CPU affinity on startup cannot be changed + or disabled during the runtime of the application. + + If both :envvar:`GOMP_CPU_AFFINITY` and :envvar:`OMP_PROC_BIND` are set, + :envvar:`OMP_PROC_BIND` has a higher precedence. If neither has been set and + :envvar:`OMP_PROC_BIND` is unset, or when :envvar:`OMP_PROC_BIND` is set to + ``FALSE``, the host system will handle the assignment of threads to CPUs. + +See also: + :ref:`OMP_PLACES`, :ref:`OMP_PROC_BIND` \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/gompdebug.rst b/libgomp/doc/openmp-environment-variables/gompdebug.rst new file mode 100644 index 00000000000..39619535842 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/gompdebug.rst @@ -0,0 +1,18 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _gomp_debug: + +GOMP_DEBUG -- Enable debugging output +************************************* + +Description: + Enable debugging output. The variable should be set to ``0`` + (disabled, also the default if not set), or ``1`` (enabled). + + If enabled, some debugging output will be printed during execution. + This is currently not specified in more detail, and subject to change. \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/gomprtemsthreadpools.rst b/libgomp/doc/openmp-environment-variables/gomprtemsthreadpools.rst new file mode 100644 index 00000000000..cb921750962 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/gomprtemsthreadpools.rst @@ -0,0 +1,46 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable, Implementation specific setting + +.. _gomp_rtems_thread_pools: + +GOMP_RTEMS_THREAD_POOLS -- Set the RTEMS specific thread pools +************************************************************** + +Description: + This environment variable is only used on the RTEMS real-time operating system. + It determines the scheduler instance specific thread pools. The format for + :envvar:`GOMP_RTEMS_THREAD_POOLS` is a list of optional + ``[$]@`` configurations + separated by ``:`` where: + + * ```` is the thread pool count for this scheduler + instance. + + * ``$`` is an optional priority for the worker threads of a + thread pool according to ``pthread_setschedparam``. In case a priority + value is omitted, then a worker thread will inherit the priority of the OpenMP + primary thread that created it. The priority of the worker thread is not + changed after creation, even if a new OpenMP primary thread using the worker has + a different priority. + + * ``@`` is the scheduler instance name according to the + RTEMS application configuration. + + In case no thread pool configuration is specified for a scheduler instance, + then each OpenMP primary thread of this scheduler instance will use its own + dynamically allocated thread pool. To limit the worker thread count of the + thread pools, each OpenMP primary thread must call ``omp_set_num_threads``. + +Example: + Lets suppose we have three scheduler instances ``IO``, ``WRK0``, and + ``WRK1`` with :envvar:`GOMP_RTEMS_THREAD_POOLS` set to + ``"1@WRK0:3$4@WRK1"``. Then there are no thread pool restrictions for + scheduler instance ``IO``. In the scheduler instance ``WRK0`` there is + one thread pool available. Since no priority is specified for this scheduler + instance, the worker thread inherits the priority of the OpenMP primary thread + that created it. In the scheduler instance ``WRK1`` there are three thread + pools available and their worker threads run at priority four. \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/gompspincount.rst b/libgomp/doc/openmp-environment-variables/gompspincount.rst new file mode 100644 index 00000000000..7bd819b0bf5 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/gompspincount.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable, Implementation specific setting + +.. _gomp_spincount: + +GOMP_SPINCOUNT -- Set the busy-wait spin count +********************************************** + +Description: + Determines how long a threads waits actively with consuming CPU power + before waiting passively without consuming CPU power. The value may be + either ``INFINITE``, ``INFINITY`` to always wait actively or an + integer which gives the number of spins of the busy-wait loop. The + integer may optionally be followed by the following suffixes acting + as multiplication factors: ``k`` (kilo, thousand), ``M`` (mega, + million), ``G`` (giga, billion), or ``T`` (tera, trillion). + If undefined, 0 is used when :envvar:`OMP_WAIT_POLICY` is ``PASSIVE``, + 300,000 is used when :envvar:`OMP_WAIT_POLICY` is undefined and + 30 billion is used when :envvar:`OMP_WAIT_POLICY` is ``ACTIVE``. + If there are more OpenMP threads than available CPUs, 1000 and 100 + spins are used for :envvar:`OMP_WAIT_POLICY` being ``ACTIVE`` or + undefined, respectively; unless the :envvar:`GOMP_SPINCOUNT` is lower + or :envvar:`OMP_WAIT_POLICY` is ``PASSIVE``. + +See also: + :ref:`OMP_WAIT_POLICY` \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/gompstacksize.rst b/libgomp/doc/openmp-environment-variables/gompstacksize.rst new file mode 100644 index 00000000000..c07a391a024 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/gompstacksize.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable, Implementation specific setting + +.. _gomp_stacksize: + +GOMP_STACKSIZE -- Set default thread stack size +*********************************************** + +Description: + Set the default thread stack size in kilobytes. This is different from + ``pthread_attr_setstacksize`` which gets the number of bytes as an + argument. If the stack size cannot be set due to system constraints, an + error is reported and the initial stack size is left unchanged. If undefined, + the stack size is system dependent. + +See also: + :ref:`OMP_STACKSIZE` + +Reference: + `GCC Patches Mailinglist `_, + `GCC Patches Mailinglist (2) `_ \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompcancellation.rst b/libgomp/doc/openmp-environment-variables/ompcancellation.rst new file mode 100644 index 00000000000..b17cf4ceaab --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompcancellation.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _omp_cancellation: + +OMP_CANCELLATION -- Set whether cancellation is activated +********************************************************* + +Description: + If set to ``TRUE``, the cancellation is activated. If set to ``FALSE`` or + if unset, cancellation is disabled and the ``cancel`` construct is ignored. + +See also: + :ref:`omp_get_cancellation` + +Reference: + :openmp:`4.5`, Section 4.11 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompdefaultdevice.rst b/libgomp/doc/openmp-environment-variables/ompdefaultdevice.rst new file mode 100644 index 00000000000..81389037561 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompdefaultdevice.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _omp_default_device: + +OMP_DEFAULT_DEVICE -- Set the device used in target regions +*********************************************************** + +Description: + Set to choose the device which is used in a ``target`` region, unless the + value is overridden by ``omp_set_default_device`` or by a ``device`` + clause. The value shall be the nonnegative device number. If no device with + the given device number exists, the code is executed on the host. If unset, + device number 0 will be used. + +See also: + :ref:`omp_get_default_device`, :ref:`omp_set_default_device`, + +Reference: + :openmp:`4.5`, Section 4.13 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompdisplayenv.rst b/libgomp/doc/openmp-environment-variables/ompdisplayenv.rst new file mode 100644 index 00000000000..684d3f2361e --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompdisplayenv.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _omp_display_env: + +OMP_DISPLAY_ENV -- Show OpenMP version and environment variables +**************************************************************** + +Description: + If set to ``TRUE``, the OpenMP version number and the values + associated with the OpenMP environment variables are printed to ``stderr``. + If set to ``VERBOSE``, it additionally shows the value of the environment + variables which are GNU extensions. If undefined or set to ``FALSE``, + this information will not be shown. + +Reference: + :openmp:`4.5`, Section 4.12 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompdynamic.rst b/libgomp/doc/openmp-environment-variables/ompdynamic.rst new file mode 100644 index 00000000000..ab66f410375 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompdynamic.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _omp_dynamic: + +OMP_DYNAMIC -- Dynamic adjustment of threads +******************************************** + +Description: + Enable or disable the dynamic adjustment of the number of threads + within a team. The value of this environment variable shall be + ``TRUE`` or ``FALSE``. If undefined, dynamic adjustment is + disabled by default. + +See also: + :ref:`omp_set_dynamic` + +Reference: + :openmp:`4.5`, Section 4.3 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompmaxactivelevels.rst b/libgomp/doc/openmp-environment-variables/ompmaxactivelevels.rst new file mode 100644 index 00000000000..505055fe54b --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompmaxactivelevels.rst @@ -0,0 +1,26 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _omp_max_active_levels: + +OMP_MAX_ACTIVE_LEVELS -- Set the maximum number of nested parallel regions +************************************************************************** + +Description: + Specifies the initial value for the maximum number of nested parallel + regions. The value of this variable shall be a positive integer. + If undefined, then if :envvar:`OMP_NESTED` is defined and set to true, or + if :envvar:`OMP_NUM_THREADS` or :envvar:`OMP_PROC_BIND` are defined and set to + a list with more than one item, the maximum number of nested parallel + regions will be initialized to the largest number supported, otherwise + it will be set to one. + +See also: + :ref:`omp_set_max_active_levels`, :ref:`OMP_NESTED` + +Reference: + :openmp:`4.5`, Section 4.9 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompmaxtaskpriority.rst b/libgomp/doc/openmp-environment-variables/ompmaxtaskpriority.rst new file mode 100644 index 00000000000..56f79e98cb3 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompmaxtaskpriority.rst @@ -0,0 +1,25 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_max_task_priority: + +OMP_MAX_TASK_PRIORITY -- Set the maximum priority +************************************************* + +number that can be set for a task. + +.. index:: Environment Variable + +Description: + Specifies the initial value for the maximum priority value that can be + set for a task. The value of this variable shall be a non-negative + integer, and zero is allowed. If undefined, the default priority is + 0. + +See also: + :ref:`omp_get_max_task_priority` + +Reference: + :openmp:`4.5`, Section 4.14 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompnested.rst b/libgomp/doc/openmp-environment-variables/ompnested.rst new file mode 100644 index 00000000000..683b0440be3 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompnested.rst @@ -0,0 +1,28 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable, Implementation specific setting + +.. _omp_nested: + +OMP_NESTED -- Nested parallel regions +************************************* + +Description: + Enable or disable nested parallel regions, i.e., whether team members + are allowed to create new teams. The value of this environment variable + shall be ``TRUE`` or ``FALSE``. If set to ``TRUE``, the number + of maximum active nested regions supported will by default be set to the + maximum supported, otherwise it will be set to one. If + :envvar:`OMP_MAX_ACTIVE_LEVELS` is defined, its setting will override this + setting. If both are undefined, nested parallel regions are enabled if + :envvar:`OMP_NUM_THREADS` or :envvar:`OMP_PROC_BINDS` are defined to a list with + more than one item, otherwise they are disabled by default. + +See also: + :ref:`omp_set_max_active_levels`, :ref:`omp_set_nested` + +Reference: + :openmp:`4.5`, Section 4.6 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompnumteams.rst b/libgomp/doc/openmp-environment-variables/ompnumteams.rst new file mode 100644 index 00000000000..4a1ed15ae3b --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompnumteams.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _omp_num_teams: + +OMP_NUM_TEAMS -- Specifies the number of teams to use by teams region +********************************************************************* + +Description: + Specifies the upper bound for number of teams to use in teams regions + without explicit ``num_teams`` clause. The value of this variable shall + be a positive integer. If undefined it defaults to 0 which means + implementation defined upper bound. + +See also: + :ref:`omp_set_num_teams` + +Reference: + :openmp:`5.1`, Section 6.23 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompnumthreads.rst b/libgomp/doc/openmp-environment-variables/ompnumthreads.rst new file mode 100644 index 00000000000..224a7d0851f --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompnumthreads.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable, Implementation specific setting + +.. _omp_num_threads: + +OMP_NUM_THREADS -- Specifies the number of threads to use +********************************************************* + +Description: + Specifies the default number of threads to use in parallel regions. The + value of this variable shall be a comma-separated list of positive integers; + the value specifies the number of threads to use for the corresponding nested + level. Specifying more than one item in the list will automatically enable + nesting by default. If undefined one thread per CPU is used. + +See also: + :ref:`omp_set_num_threads`, :ref:`OMP_NESTED` + +Reference: + :openmp:`4.5`, Section 4.2 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompplaces.rst b/libgomp/doc/openmp-environment-variables/ompplaces.rst new file mode 100644 index 00000000000..e78bd0a7a42 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompplaces.rst @@ -0,0 +1,54 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _omp_places: + +OMP_PLACES -- Specifies on which CPUs the theads should be placed +***************************************************************** + +Description: + The thread placement can be either specified using an abstract name or by an + explicit list of the places. The abstract names ``threads``, ``cores``, + ``sockets``, ``ll_caches`` and ``numa_domains`` can be optionally + followed by a positive number in parentheses, which denotes the how many places + shall be created. With ``threads`` each place corresponds to a single + hardware thread; ``cores`` to a single core with the corresponding number of + hardware threads; with ``sockets`` the place corresponds to a single + socket; with ``ll_caches`` to a set of cores that shares the last level + cache on the device; and ``numa_domains`` to a set of cores for which their + closest memory on the device is the same memory and at a similar distance from + the cores. The resulting placement can be shown by setting the + :envvar:`OMP_DISPLAY_ENV` environment variable. + + Alternatively, the placement can be specified explicitly as comma-separated + list of places. A place is specified by set of nonnegative numbers in curly + braces, denoting the hardware threads. The curly braces can be omitted + when only a single number has been specified. The hardware threads + belonging to a place can either be specified as comma-separated list of + nonnegative thread numbers or using an interval. Multiple places can also be + either specified by a comma-separated list of places or by an interval. To + specify an interval, a colon followed by the count is placed after + the hardware thread number or the place. Optionally, the length can be + followed by a colon and the stride number -- otherwise a unit stride is + assumed. Placing an exclamation mark (``!``) directly before a curly + brace or numbers inside the curly braces (excluding intervals) will + exclude those hardware threads. + + For instance, the following specifies the same places list: + ``"{0,1,2}, {3,4,6}, {7,8,9}, {10,11,12}"`` ; + ``"{0:3}, {3:3}, {7:3}, {10:3}"`` ; and ``"{0:2}:4:3"``. + + If :envvar:`OMP_PLACES` and :envvar:`GOMP_CPU_AFFINITY` are unset and + :envvar:`OMP_PROC_BIND` is either unset or ``false``, threads may be moved + between CPUs following no placement policy. + +See also: + :ref:`OMP_PROC_BIND`, :ref:`GOMP_CPU_AFFINITY`, :ref:`omp_get_proc_bind`, + :ref:`OMP_DISPLAY_ENV` + +Reference: + :openmp:`4.5`, Section 4.5 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompprocbind.rst b/libgomp/doc/openmp-environment-variables/ompprocbind.rst new file mode 100644 index 00000000000..22a9473c1a1 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompprocbind.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _omp_proc_bind: + +OMP_PROC_BIND -- Whether theads may be moved between CPUs +********************************************************* + +Description: + Specifies whether threads may be moved between processors. If set to + ``TRUE``, OpenMP theads should not be moved; if set to ``FALSE`` + they may be moved. Alternatively, a comma separated list with the + values ``PRIMARY``, ``MASTER``, ``CLOSE`` and ``SPREAD`` can + be used to specify the thread affinity policy for the corresponding nesting + level. With ``PRIMARY`` and ``MASTER`` the worker threads are in the + same place partition as the primary thread. With ``CLOSE`` those are + kept close to the primary thread in contiguous place partitions. And + with ``SPREAD`` a sparse distribution + across the place partitions is used. Specifying more than one item in the + list will automatically enable nesting by default. + + When undefined, :envvar:`OMP_PROC_BIND` defaults to ``TRUE`` when + :envvar:`OMP_PLACES` or :envvar:`GOMP_CPU_AFFINITY` is set and ``FALSE`` otherwise. + +See also: + :ref:`omp_get_proc_bind`, :ref:`GOMP_CPU_AFFINITY`, + :ref:`OMP_NESTED`, :ref:`OMP_PLACES` + +Reference: + :openmp:`4.5`, Section 4.4 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompschedule.rst b/libgomp/doc/openmp-environment-variables/ompschedule.rst new file mode 100644 index 00000000000..b8b6c414563 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompschedule.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable, Implementation specific setting + +.. _omp_schedule: + +OMP_SCHEDULE -- How threads are scheduled +***************************************** + +Description: + Allows to specify ``schedule type`` and ``chunk size``. + The value of the variable shall have the form: ``type[,chunk]`` where + ``type`` is one of ``static``, ``dynamic``, ``guided`` or ``auto`` + The optional ``chunk`` size shall be a positive integer. If undefined, + dynamic scheduling and a chunk size of 1 is used. + +See also: + :ref:`omp_set_schedule` + +Reference: + :openmp:`4.5`, Sections 2.7.1.1 and 4.1 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompstacksize.rst b/libgomp/doc/openmp-environment-variables/ompstacksize.rst new file mode 100644 index 00000000000..15235526fa3 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompstacksize.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _omp_stacksize: + +OMP_STACKSIZE -- Set default thread stack size +********************************************** + +Description: + Set the default thread stack size in kilobytes, unless the number + is suffixed by ``B``, ``K``, ``M`` or ``G``, in which + case the size is, respectively, in bytes, kilobytes, megabytes + or gigabytes. This is different from ``pthread_attr_setstacksize`` + which gets the number of bytes as an argument. If the stack size cannot + be set due to system constraints, an error is reported and the initial + stack size is left unchanged. If undefined, the stack size is system + dependent. + +Reference: + :openmp:`4.5`, Section 4.7 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/omptargetoffload.rst b/libgomp/doc/openmp-environment-variables/omptargetoffload.rst new file mode 100644 index 00000000000..4aaba8e5c45 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/omptargetoffload.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable, Implementation specific setting + +.. _omp_target_offload: + +OMP_TARGET_OFFLOAD -- Controls offloading behaviour +*************************************************** + +Description: + Specifies the behaviour with regard to offloading code to a device. This + variable can be set to one of three values - ``MANDATORY``, ``DISABLED`` + or ``DEFAULT``. + + If set to ``MANDATORY``, the program will terminate with an error if + the offload device is not present or is not supported. If set to + ``DISABLED``, then offloading is disabled and all code will run on the + host. If set to ``DEFAULT``, the program will try offloading to the + device first, then fall back to running code on the host if it cannot. + + If undefined, then the program will behave as if ``DEFAULT`` was set. + +Reference: + :openmp:`5.0`, Section 6.17 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompteamsthreadlimit.rst b/libgomp/doc/openmp-environment-variables/ompteamsthreadlimit.rst new file mode 100644 index 00000000000..18654288f06 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompteamsthreadlimit.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _omp_teams_thread_limit: + +OMP_TEAMS_THREAD_LIMIT -- Set the maximum number of threads imposed by teams +**************************************************************************** + +Description: + Specifies an upper bound for the number of threads to use by each contention + group created by a teams construct without explicit ``thread_limit`` + clause. The value of this variable shall be a positive integer. If undefined, + the value of 0 is used which stands for an implementation defined upper + limit. + +See also: + :ref:`OMP_THREAD_LIMIT`, :ref:`omp_set_teams_thread_limit` + +Reference: + :openmp:`5.1`, Section 6.24 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompthreadlimit.rst b/libgomp/doc/openmp-environment-variables/ompthreadlimit.rst new file mode 100644 index 00000000000..3157eda50d2 --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompthreadlimit.rst @@ -0,0 +1,22 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _omp_thread_limit: + +OMP_THREAD_LIMIT -- Set the maximum number of threads +***************************************************** + +Description: + Specifies the number of threads to use for the whole program. The + value of this variable shall be a positive integer. If undefined, + the number of threads is not limited. + +See also: + :ref:`OMP_NUM_THREADS`, :ref:`omp_get_thread_limit` + +Reference: + :openmp:`4.5`, Section 4.10 \ No newline at end of file diff --git a/libgomp/doc/openmp-environment-variables/ompwaitpolicy.rst b/libgomp/doc/openmp-environment-variables/ompwaitpolicy.rst new file mode 100644 index 00000000000..c88f0fd25dd --- /dev/null +++ b/libgomp/doc/openmp-environment-variables/ompwaitpolicy.rst @@ -0,0 +1,24 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: Environment Variable + +.. _omp_wait_policy: + +OMP_WAIT_POLICY -- How waiting threads are handled +************************************************** + +Description: + Specifies whether waiting threads should be active or passive. If + the value is ``PASSIVE``, waiting threads should not consume CPU + power while waiting; while the value is ``ACTIVE`` specifies that + they should. If undefined, threads wait actively for a short time + before waiting passively. + +See also: + :ref:`GOMP_SPINCOUNT` + +Reference: + :openmp:`4.5`, Section 4.8 \ No newline at end of file diff --git a/libgomp/doc/openmp-implementation-specifics.rst b/libgomp/doc/openmp-implementation-specifics.rst new file mode 100644 index 00000000000..1a18bde7963 --- /dev/null +++ b/libgomp/doc/openmp-implementation-specifics.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openmp-implementation-specifics: + +OpenMP-Implementation Specifics +------------------------------- + +.. toctree:: + :maxdepth: 2 + + openmp-context-selectors + memory-allocation-with-libmemkind \ No newline at end of file diff --git a/libgomp/doc/openmp-implementation-status.rst b/libgomp/doc/openmp-implementation-status.rst new file mode 100644 index 00000000000..223ee68e275 --- /dev/null +++ b/libgomp/doc/openmp-implementation-status.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openmp-implementation-status: + +OpenMP Implementation Status +---------------------------- + +The ``_OPENMP`` preprocessor macro and Fortran's ``openmp_version`` +parameter, provided by ``omp_lib.h`` and the ``omp_lib`` module, have +the value ``201511`` (i.e. OpenMP 4.5). + +.. toctree:: + :maxdepth: 2 + + openmp-implementation-status/openmp-45 + openmp-implementation-status/openmp-50 + openmp-implementation-status/openmp-51 + openmp-implementation-status/openmp-52 \ No newline at end of file diff --git a/libgomp/doc/openmp-implementation-status/openmp-45.rst b/libgomp/doc/openmp-implementation-status/openmp-45.rst new file mode 100644 index 00000000000..bd77b0d6ff1 --- /dev/null +++ b/libgomp/doc/openmp-implementation-status/openmp-45.rst @@ -0,0 +1,11 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openmp-4.5: + +OpenMP 4.5 +********** + +The OpenMP 4.5 specification is fully supported. \ No newline at end of file diff --git a/libgomp/doc/openmp-implementation-status/openmp-50.rst b/libgomp/doc/openmp-implementation-status/openmp-50.rst new file mode 100644 index 00000000000..c5127a0bfd7 --- /dev/null +++ b/libgomp/doc/openmp-implementation-status/openmp-50.rst @@ -0,0 +1,212 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openmp-5.0: + +OpenMP 5.0 +********** + +New features listed in Appendix B of the OpenMP specification +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. This list is sorted as in OpenMP 5.1's B.3 not as in OpenMP 5.0's B.2 + +.. list-table:: + :header-rows: 1 + :widths: 50 10 25 + + * - Description + - Status + - Comments + + * - Array shaping + - N + - + * - Array sections with non-unit strides in C and C++ + - N + - + * - Iterators + - Y + - + * - ``metadirective`` directive + - N + - + * - ``declare variant`` directive + - P + - *simd* traits not handled correctly + * - *target-offload-var* ICV and ``OMP_TARGET_OFFLOAD`` env variable + - Y + - + * - Nested-parallel changes to *max-active-levels-var* ICV + - Y + - + * - ``requires`` directive + - P + - complete but no non-host devices provides ``unified_address``, ``unified_shared_memory`` or ``reverse_offload`` + * - ``teams`` construct outside an enclosing target region + - Y + - + * - Non-rectangular loop nests + - Y + - + * - ``!=`` as relational-op in canonical loop form for C/C++ + - Y + - + * - ``nonmonotonic`` as default loop schedule modifier for worksharing-loop constructs + - Y + - + * - Collapse of associated loops that are imperfectly nested loops + - N + - + * - Clauses ``if``, ``nontemporal`` and ``order(concurrent)`` in ``simd`` construct + - Y + - + * - ``atomic`` constructs in ``simd`` + - Y + - + * - ``loop`` construct + - Y + - + * - ``order(concurrent)`` clause + - Y + - + * - ``scan`` directive and ``in_scan`` modifier for the ``reduction`` clause + - Y + - + * - ``in_reduction`` clause on ``task`` constructs + - Y + - + * - ``in_reduction`` clause on ``target`` constructs + - P + - ``nowait`` only stub + * - ``task_reduction`` clause with ``taskgroup`` + - Y + - + * - ``task`` modifier to ``reduction`` clause + - Y + - + * - ``affinity`` clause to ``task`` construct + - Y + - Stub only + * - ``detach`` clause to ``task`` construct + - Y + - + * - ``omp_fulfill_event`` runtime routine + - Y + - + * - ``reduction`` and ``in_reduction`` clauses on ``taskloop`` and ``taskloop simd`` constructs + - Y + - + * - ``taskloop`` construct cancelable by ``cancel`` construct + - Y + - + * - ``mutexinoutset`` *dependence-type* for ``depend`` clause + - Y + - + * - Predefined memory spaces, memory allocators, allocator traits + - Y + - Some are only stubs + * - Memory management routines + - Y + - + * - ``allocate`` directive + - N + - + * - ``allocate`` clause + - P + - Initial support + * - ``use_device_addr`` clause on ``target data`` + - Y + - + * - ``ancestor`` modifier on ``device`` clause + - Y + - See comment for ``requires`` + * - Implicit declare target directive + - Y + - + * - Discontiguous array section with ``target update`` construct + - N + - + * - C/C++'s lvalue expressions in ``to``, ``from`` and ``map`` clauses + - N + - + * - C/C++'s lvalue expressions in ``depend`` clauses + - Y + - + * - Nested ``declare target`` directive + - Y + - + * - Combined ``master`` constructs + - Y + - + * - ``depend`` clause on ``taskwait`` + - Y + - + * - Weak memory ordering clauses on ``atomic`` and ``flush`` construct + - Y + - + * - ``hint`` clause on the ``atomic`` construct + - Y + - Stub only + * - ``depobj`` construct and depend objects + - Y + - + * - Lock hints were renamed to synchronization hints + - Y + - + * - ``conditional`` modifier to ``lastprivate`` clause + - Y + - + * - Map-order clarifications + - P + - + * - ``close`` *map-type-modifier* + - Y + - + * - Mapping C/C++ pointer variables and to assign the address of device memory mapped by an array section + - P + - + * - Mapping of Fortran pointer and allocatable variables, including pointer and allocatable components of variables + - P + - Mapping of vars with allocatable components unsupported + * - ``defaultmap`` extensions + - Y + - + * - ``declare mapper`` directive + - N + - + * - ``omp_get_supported_active_levels`` routine + - Y + - + * - Runtime routines and environment variables to display runtime thread affinity information + - Y + - + * - ``omp_pause_resource`` and ``omp_pause_resource_all`` runtime routines + - Y + - + * - ``omp_get_device_num`` runtime routine + - Y + - + * - OMPT interface + - N + - + * - OMPD interface + - N + - + +Other new OpenMP 5.0 features +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 50 10 25 + + * - Description + - Status + - Comments + + * - Supporting C++'s range-based for loop + - Y + - \ No newline at end of file diff --git a/libgomp/doc/openmp-implementation-status/openmp-51.rst b/libgomp/doc/openmp-implementation-status/openmp-51.rst new file mode 100644 index 00000000000..07c3b111b0b --- /dev/null +++ b/libgomp/doc/openmp-implementation-status/openmp-51.rst @@ -0,0 +1,177 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openmp-5.1: + +OpenMP 5.1 +********** + +New features listed in Appendix B of the OpenMP specification +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 50 10 25 + + * - Description + - Status + - Comments + + * - OpenMP directive as C++ attribute specifiers + - Y + - + * - ``omp_all_memory`` reserved locator + - Y + - + * - *target_device trait* in OpenMP Context + - N + - + * - ``target_device`` selector set in context selectors + - N + - + * - C/C++'s ``declare variant`` directive: elision support of preprocessed code + - N + - + * - ``declare variant`` : new clauses ``adjust_args`` and ``append_args`` + - N + - + * - ``dispatch`` construct + - N + - + * - device-specific ICV settings with environment variables + - Y + - + * - ``assume`` directive + - Y + - + * - ``nothing`` directive + - Y + - + * - ``error`` directive + - Y + - + * - ``masked`` construct + - Y + - + * - ``scope`` directive + - Y + - + * - Loop transformation constructs + - N + - + * - ``strict`` modifier in the ``grainsize`` and ``num_tasks`` clauses of the ``taskloop`` construct + - Y + - + * - ``align`` clause/modifier in ``allocate`` directive/clause and ``allocator`` directive + - P + - C/C++ on clause only + * - ``thread_limit`` clause to ``target`` construct + - Y + - + * - ``has_device_addr`` clause to ``target`` construct + - Y + - + * - Iterators in ``target update`` motion clauses and ``map`` clauses + - N + - + * - Indirect calls to the device version of a procedure or function in ``target`` regions + - N + - + * - ``interop`` directive + - N + - + * - ``omp_interop_t`` object support in runtime routines + - N + - + * - ``nowait`` clause in ``taskwait`` directive + - Y + - + * - Extensions to the ``atomic`` directive + - Y + - + * - ``seq_cst`` clause on a ``flush`` construct + - Y + - + * - ``inoutset`` argument to the ``depend`` clause + - Y + - + * - ``private`` and ``firstprivate`` argument to ``default`` clause in C and C++ + - Y + - + * - ``present`` argument to ``defaultmap`` clause + - N + - + * - ``omp_set_num_teams``, ``omp_set_teams_thread_limit``, ``omp_get_max_teams``, ``omp_get_teams_thread_limit`` runtime routines + - Y + - + * - ``omp_target_is_accessible`` runtime routine + - Y + - + * - ``omp_target_memcpy_async`` and ``omp_target_memcpy_rect_async`` runtime routines + - Y + - + * - ``omp_get_mapped_ptr`` runtime routine + - Y + - + * - ``omp_calloc``, ``omp_realloc``, ``omp_aligned_alloc`` and ``omp_aligned_calloc`` runtime routines + - Y + - + * - ``omp_alloctrait_key_t`` enum: ``omp_atv_serialized`` added, ``omp_atv_default`` changed + - Y + - + * - ``omp_display_env`` runtime routine + - Y + - + * - ``ompt_scope_endpoint_t`` enum: ``ompt_scope_beginend`` + - N + - + * - ``ompt_sync_region_t`` enum additions + - N + - + * - ``ompt_state_t`` enum: ``ompt_state_wait_barrier_implementation`` and ``ompt_state_wait_barrier_teams`` + - N + - + * - ``ompt_callback_target_data_op_emi_t``, ``ompt_callback_target_emi_t``, ``ompt_callback_target_map_emi_t`` and ``ompt_callback_target_submit_emi_t`` + - N + - + * - ``ompt_callback_error_t`` type + - N + - + * - ``OMP_PLACES`` syntax extensions + - Y + - + * - ``OMP_NUM_TEAMS`` and ``OMP_TEAMS_THREAD_LIMIT`` environment variables + - Y + - + +Other new OpenMP 5.1 features +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 50 10 25 + + * - Description + - Status + - Comments + + * - Support of strictly structured blocks in Fortran + - Y + - + * - Support of structured block sequences in C/C++ + - Y + - + * - ``unconstrained`` and ``reproducible`` modifiers on ``order`` clause + - Y + - + * - Support ``begin/end declare target`` syntax in C/C++ + - Y + - + * - Pointer predetermined firstprivate getting initialized to address of matching mapped list item per 5.1, Sect. 2.21.7.2 + - N + - + * - For Fortran, diagnose placing declarative before/between ``USE``, ``IMPORT``, and ``IMPLICIT`` as invalid + - N + - \ No newline at end of file diff --git a/libgomp/doc/openmp-implementation-status/openmp-52.rst b/libgomp/doc/openmp-implementation-status/openmp-52.rst new file mode 100644 index 00000000000..cbdd20d1a72 --- /dev/null +++ b/libgomp/doc/openmp-implementation-status/openmp-52.rst @@ -0,0 +1,132 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _openmp-5.2: + +OpenMP 5.2 +********** + +New features listed in Appendix B of the OpenMP specification +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 50 10 25 + + * - Description + - Status + - Comments + + * - ``omp_in_explicit_task`` routine and *explicit-task-var* ICV + - Y + - + * - ``omp`` / ``ompx`` / ``omx`` sentinels and ``omp_`` / ``ompx_`` namespaces + - N/A + - warning for ``ompx/omx`` sentinels [#f1]_ + * - Clauses on ``end`` directive can be on directive + - N + - + * - Deprecation of no-argument ``destroy`` clause on ``depobj`` + - N + - + * - ``linear`` clause syntax changes and ``step`` modifier + - Y + - + * - Deprecation of minus operator for reductions + - N + - + * - Deprecation of separating ``map`` modifiers without comma + - N + - + * - ``declare mapper`` with iterator and ``present`` modifiers + - N + - + * - If a matching mapped list item is not found in the data environment, the pointer retains its original value + - N + - + * - New ``enter`` clause as alias for ``to`` on declare target directive + - Y + - + * - Deprecation of ``to`` clause on declare target directive + - N + - + * - Extended list of directives permitted in Fortran pure procedures + - N + - + * - New ``allocators`` directive for Fortran + - N + - + * - Deprecation of ``allocate`` directive for Fortran allocatables/pointers + - N + - + * - Optional paired ``end`` directive with ``dispatch`` + - N + - + * - New ``memspace`` and ``traits`` modifiers for ``uses_allocators`` + - N + - + * - Deprecation of traits array following the allocator_handle expression in ``uses_allocators`` + - N + - + * - New ``otherwise`` clause as alias for ``default`` on metadirectives + - N + - + * - Deprecation of ``default`` clause on metadirectives + - N + - + * - Deprecation of delimited form of ``declare target`` + - N + - + * - Reproducible semantics changed for ``order(concurrent)`` + - N + - + * - ``allocate`` and ``firstprivate`` clauses on ``scope`` + - Y + - + * - ``ompt_callback_work`` + - N + - + * - Default map-type for ``map`` clause in ``target enter/exit data`` + - Y + - + * - New ``doacross`` clause as alias for ``depend`` with ``source`` / ``sink`` modifier + - Y + - + * - Deprecation of ``depend`` with ``source`` / ``sink`` modifier + - N + - + * - ``omp_cur_iteration`` keyword + - Y + - + +.. [#f1] The ``ompx`` sentinel as C/C++ pragma and C++ attributes are warned for with ``-Wunknown-pragmas`` (implied by ``-Wall``) and ``-Wattributes`` (enabled by default), respectively; for Fortran free-source code, there is a warning enabled by default and, for fixed-source code, the ``omx`` sentinel is warned for with with ``-Wsurprising`` (enabled by ``-Wall``). Unknown clauses are always rejected with an error. + +Other new OpenMP 5.2 features +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. list-table:: + :header-rows: 1 + :widths: 50 10 25 + + * - Description + - Status + - Comments + + * - For Fortran, optional comma between directive and clause + - N + - + * - Conforming device numbers and ``omp_initial_device`` and ``omp_invalid_device`` enum/PARAMETER + - Y + - + * - Initial value of *default-device-var* ICV with ``OMP_TARGET_OFFLOAD=mandatory`` + - N + - + * - *interop_types* in any position of the modifier list for the ``init`` clause of the ``interop`` construct + - N + - + +.. - + OpenMP Runtime Library Routines + - \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines.rst b/libgomp/doc/openmp-runtime-library-routines.rst new file mode 100644 index 00000000000..77c5c75bffc --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines.rst @@ -0,0 +1,87 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _runtime-library-routines: + +OpenMP Runtime Library Routines +------------------------------- + +The runtime routines described here are defined by Section 3 of the OpenMP +specification in version 4.5. The routines are structured in following +three parts: + +Control threads, processors and the parallel environment. They have C +linkage, and do not throw exceptions. + +.. toctree:: + :maxdepth: 2 + + openmp-runtime-library-routines/ompgetactivelevel + openmp-runtime-library-routines/ompgetancestorthreadnum + openmp-runtime-library-routines/ompgetcancellation + openmp-runtime-library-routines/ompgetdefaultdevice + openmp-runtime-library-routines/ompgetdevicenum + openmp-runtime-library-routines/ompgetdynamic + openmp-runtime-library-routines/ompgetinitialdevice + openmp-runtime-library-routines/ompgetlevel + openmp-runtime-library-routines/ompgetmaxactivelevels + openmp-runtime-library-routines/ompgetmaxtaskpriority + openmp-runtime-library-routines/ompgetmaxteams + openmp-runtime-library-routines/ompgetmaxthreads + openmp-runtime-library-routines/ompgetnested + openmp-runtime-library-routines/ompgetnumdevices + openmp-runtime-library-routines/ompgetnumprocs + openmp-runtime-library-routines/ompgetnumteams + openmp-runtime-library-routines/ompgetnumthreads + openmp-runtime-library-routines/ompgetprocbind + openmp-runtime-library-routines/ompgetschedule + openmp-runtime-library-routines/ompgetsupportedactivelevels + openmp-runtime-library-routines/ompgetteamnum + openmp-runtime-library-routines/ompgetteamsize + openmp-runtime-library-routines/ompgetteamsthreadlimit + openmp-runtime-library-routines/ompgetthreadlimit + openmp-runtime-library-routines/ompgetthreadnum + openmp-runtime-library-routines/ompinparallel + openmp-runtime-library-routines/ompinfinal + openmp-runtime-library-routines/ompisinitialdevice + openmp-runtime-library-routines/ompsetdefaultdevice + openmp-runtime-library-routines/ompsetdynamic + openmp-runtime-library-routines/ompsetmaxactivelevels + openmp-runtime-library-routines/ompsetnested + openmp-runtime-library-routines/ompsetnumteams + openmp-runtime-library-routines/ompsetnumthreads + openmp-runtime-library-routines/ompsetschedule + openmp-runtime-library-routines/ompsetteamsthreadlimit + +Initialize, set, test, unset and destroy simple and nested locks. + +.. toctree:: + :maxdepth: 2 + + openmp-runtime-library-routines/ompinitlock + openmp-runtime-library-routines/ompsetlock + openmp-runtime-library-routines/omptestlock + openmp-runtime-library-routines/ompunsetlock + openmp-runtime-library-routines/ompdestroylock + openmp-runtime-library-routines/ompinitnestlock + openmp-runtime-library-routines/ompsetnestlock + openmp-runtime-library-routines/omptestnestlock + openmp-runtime-library-routines/ompunsetnestlock + openmp-runtime-library-routines/ompdestroynestlock + +Portable, thread-based, wall clock timer. + +.. toctree:: + :maxdepth: 2 + + openmp-runtime-library-routines/ompgetwtick + openmp-runtime-library-routines/ompgetwtime + +Support for event objects. + +.. toctree:: + :maxdepth: 2 + + openmp-runtime-library-routines/ompfulfillevent \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompdestroylock.rst b/libgomp/doc/openmp-runtime-library-routines/ompdestroylock.rst new file mode 100644 index 00000000000..5de285bb96c --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompdestroylock.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_destroy_lock: + +omp_destroy_lock -- Destroy simple lock +*************************************** + +Description: + Destroy a simple lock. In order to be destroyed, a simple lock must be + in the unlocked state. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_destroy_lock(omp_lock_t *lock);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_destroy_lock(svar)`` + * - + - ``integer(omp_lock_kind), intent(inout) :: svar`` + +See also: + :ref:`omp_init_lock` + +Reference: + :openmp:`4.5`, Section 3.3.3. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompdestroynestlock.rst b/libgomp/doc/openmp-runtime-library-routines/ompdestroynestlock.rst new file mode 100644 index 00000000000..a4a991eb7b3 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompdestroynestlock.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_destroy_nest_lock: + +omp_destroy_nest_lock -- Destroy nested lock +******************************************** + +Description: + Destroy a nested lock. In order to be destroyed, a nested lock must be + in the unlocked state and its nesting count must equal zero. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_destroy_nest_lock(omp_nest_lock_t *);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_destroy_nest_lock(nvar)`` + * - + - ``integer(omp_nest_lock_kind), intent(inout) :: nvar`` + +See also: + :ref:`omp_init_lock` + +Reference: + :openmp:`4.5`, Section 3.3.3. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompfulfillevent.rst b/libgomp/doc/openmp-runtime-library-routines/ompfulfillevent.rst new file mode 100644 index 00000000000..b0beddd8034 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompfulfillevent.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_fulfill_event: + +omp_fulfill_event -- Fulfill and destroy an OpenMP event +******************************************************** + +Description: + Fulfill the event associated with the event handle argument. Currently, it + is only used to fulfill events generated by detach clauses on task + constructs - the effect of fulfilling the event is to allow the task to + complete. + + The result of calling ``omp_fulfill_event`` with an event handle other + than that generated by a detach clause is undefined. Calling it with an + event handle that has already been fulfilled is also undefined. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_fulfill_event(omp_event_handle_t event);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_fulfill_event(event)`` + * - + - ``integer (kind=omp_event_handle_kind) :: event`` + +Reference: + :openmp:`5.0`, Section 3.5.1. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetactivelevel.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetactivelevel.rst new file mode 100644 index 00000000000..da26ecd4f64 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetactivelevel.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_active_level: + +omp_get_active_level -- Number of parallel regions +************************************************** + +Description: + This function returns the nesting level for the active parallel blocks, + which enclose the calling call. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_active_level(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_active_level()`` + +See also: + :ref:`omp_get_level`, :ref:`omp_get_max_active_levels`, :ref:`omp_set_max_active_levels` + +Reference: + :openmp:`4.5`, Section 3.2.20. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetancestorthreadnum.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetancestorthreadnum.rst new file mode 100644 index 00000000000..b5ea5693daf --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetancestorthreadnum.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_ancestor_thread_num: + +omp_get_ancestor_thread_num -- Ancestor thread ID +************************************************* + +Description: + This function returns the thread identification number for the given + nesting level of the current thread. For values of :samp:`{level}` outside + zero to ``omp_get_level`` -1 is returned; if :samp:`{level}` is + ``omp_get_level`` the result is identical to ``omp_get_thread_num``. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_ancestor_thread_num(int level);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_ancestor_thread_num(level)`` + * - + - ``integer level`` + +See also: + :ref:`omp_get_level`, :ref:`omp_get_thread_num`, :ref:`omp_get_team_size` + +Reference: + :openmp:`4.5`, Section 3.2.18. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetcancellation.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetcancellation.rst new file mode 100644 index 00000000000..92c6793d987 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetcancellation.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_cancellation: + +omp_get_cancellation -- Whether cancellation support is enabled +*************************************************************** + +Description: + This function returns ``true`` if cancellation is activated, ``false`` + otherwise. Here, ``true`` and ``false`` represent their language-specific + counterparts. Unless :envvar:`OMP_CANCELLATION` is set true, cancellations are + deactivated. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_cancellation(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``logical function omp_get_cancellation()`` + +See also: + :ref:`OMP_CANCELLATION` + +Reference: + :openmp:`4.5`, Section 3.2.9. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetdefaultdevice.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetdefaultdevice.rst new file mode 100644 index 00000000000..5d8c5faeafe --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetdefaultdevice.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_default_device: + +omp_get_default_device -- Get the default device for target regions +******************************************************************* + +Description: + Get the default device for target regions without device clause. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_default_device(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_default_device()`` + +See also: + :ref:`OMP_DEFAULT_DEVICE`, :ref:`omp_set_default_device` + +Reference: + :openmp:`4.5`, Section 3.2.30. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetdevicenum.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetdevicenum.rst new file mode 100644 index 00000000000..04158ceffe1 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetdevicenum.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_device_num: + +omp_get_device_num -- Return device number of current device +************************************************************ + +Description: + This function returns a device number that represents the device that the + current thread is executing on. For OpenMP 5.0, this must be equal to the + value returned by the ``omp_get_initial_device`` function when called + from the host. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_device_num(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_device_num()`` + +See also: + :ref:`omp_get_initial_device` + +Reference: + :openmp:`5.0`, Section 3.2.37. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetdynamic.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetdynamic.rst new file mode 100644 index 00000000000..6e461f1e233 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetdynamic.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_dynamic: + +omp_get_dynamic -- Dynamic teams setting +**************************************** + +Description: + This function returns ``true`` if enabled, ``false`` otherwise. + Here, ``true`` and ``false`` represent their language-specific + counterparts. + + The dynamic team setting may be initialized at startup by the + :envvar:`OMP_DYNAMIC` environment variable or at runtime using + ``omp_set_dynamic``. If undefined, dynamic adjustment is + disabled by default. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_dynamic(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``logical function omp_get_dynamic()`` + +See also: + :ref:`omp_set_dynamic`, :ref:`OMP_DYNAMIC` + +Reference: + :openmp:`4.5`, Section 3.2.8. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetinitialdevice.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetinitialdevice.rst new file mode 100644 index 00000000000..670fea8f095 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetinitialdevice.rst @@ -0,0 +1,32 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_initial_device: + +omp_get_initial_device -- Return device number of initial device +**************************************************************** + +Description: + This function returns a device number that represents the host device. + For OpenMP 5.1, this must be equal to the value returned by the + ``omp_get_num_devices`` function. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_initial_device(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_initial_device()`` + +See also: + :ref:`omp_get_num_devices` + +Reference: + :openmp:`4.5`, Section 3.2.35. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetlevel.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetlevel.rst new file mode 100644 index 00000000000..604aa8d505e --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetlevel.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_level: + +omp_get_level -- Obtain the current nesting level +************************************************* + +Description: + This function returns the nesting level for the parallel blocks, + which enclose the calling call. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_level(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_level()`` + +See also: + :ref:`omp_get_active_level` + +Reference: + :openmp:`4.5`, Section 3.2.17. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetmaxactivelevels.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetmaxactivelevels.rst new file mode 100644 index 00000000000..a1e631fe553 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetmaxactivelevels.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_max_active_levels: + +omp_get_max_active_levels -- Current maximum number of active regions +********************************************************************* + +Description: + This function obtains the maximum allowed number of nested, active parallel regions. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_max_active_levels(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_max_active_levels()`` + +See also: + :ref:`omp_set_max_active_levels`, :ref:`omp_get_active_level` + +Reference: + :openmp:`4.5`, Section 3.2.16. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetmaxtaskpriority.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetmaxtaskpriority.rst new file mode 100644 index 00000000000..e41dd28e452 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetmaxtaskpriority.rst @@ -0,0 +1,29 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_max_task_priority: + +omp_get_max_task_priority -- Maximum priority value +*************************************************** + +that can be set for tasks. + +Description: + This function obtains the maximum allowed priority number for tasks. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_max_task_priority(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_max_task_priority()`` + +Reference: + :openmp:`4.5`, Section 3.2.29. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetmaxteams.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetmaxteams.rst new file mode 100644 index 00000000000..6e7355525da --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetmaxteams.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_max_teams: + +omp_get_max_teams -- Maximum number of teams of teams region +************************************************************ + +Description: + Return the maximum number of teams used for the teams region + that does not use the clause ``num_teams``. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_max_teams(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_max_teams()`` + +See also: + :ref:`omp_set_num_teams`, :ref:`omp_get_num_teams` + +Reference: + :openmp:`5.1`, Section 3.4.4. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetmaxthreads.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetmaxthreads.rst new file mode 100644 index 00000000000..d8c4fb82568 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetmaxthreads.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_max_threads: + +omp_get_max_threads -- Maximum number of threads of parallel region +******************************************************************* + +Description: + Return the maximum number of threads used for the current parallel region + that does not use the clause ``num_threads``. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_max_threads(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_max_threads()`` + +See also: + :ref:`omp_set_num_threads`, :ref:`omp_set_dynamic`, :ref:`omp_get_thread_limit` + +Reference: + :openmp:`4.5`, Section 3.2.3. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetnested.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetnested.rst new file mode 100644 index 00000000000..a5d73393efa --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetnested.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_nested: + +omp_get_nested -- Nested parallel regions +***************************************** + +Description: + This function returns ``true`` if nested parallel regions are + enabled, ``false`` otherwise. Here, ``true`` and ``false`` + represent their language-specific counterparts. + + The state of nested parallel regions at startup depends on several + environment variables. If :envvar:`OMP_MAX_ACTIVE_LEVELS` is defined + and is set to greater than one, then nested parallel regions will be + enabled. If not defined, then the value of the :envvar:`OMP_NESTED` + environment variable will be followed if defined. If neither are + defined, then if either :envvar:`OMP_NUM_THREADS` or :envvar:`OMP_PROC_BIND` + are defined with a list of more than one value, then nested parallel + regions are enabled. If none of these are defined, then nested parallel + regions are disabled by default. + + Nested parallel regions can be enabled or disabled at runtime using + ``omp_set_nested``, or by setting the maximum number of nested + regions with ``omp_set_max_active_levels`` to one to disable, or + above one to enable. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_nested(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``logical function omp_get_nested()`` + +See also: + :ref:`omp_set_max_active_levels`, :ref:`omp_set_nested`, + :ref:`OMP_MAX_ACTIVE_LEVELS`, :ref:`OMP_NESTED` + +Reference: + :openmp:`4.5`, Section 3.2.11. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetnumdevices.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetnumdevices.rst new file mode 100644 index 00000000000..4e44a5b5873 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetnumdevices.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_num_devices: + +omp_get_num_devices -- Number of target devices +*********************************************** + +Description: + Returns the number of target devices. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_num_devices(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_num_devices()`` + +Reference: + :openmp:`4.5`, Section 3.2.31. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetnumprocs.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetnumprocs.rst new file mode 100644 index 00000000000..20db47b4eb7 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetnumprocs.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_num_procs: + +omp_get_num_procs -- Number of processors online +************************************************ + +Description: + Returns the number of processors online on that device. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_num_procs(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_num_procs()`` + +Reference: + :openmp:`4.5`, Section 3.2.5. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetnumteams.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetnumteams.rst new file mode 100644 index 00000000000..da3af055780 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetnumteams.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_num_teams: + +omp_get_num_teams -- Number of teams +************************************ + +Description: + Returns the number of teams in the current team region. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_num_teams(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_num_teams()`` + +Reference: + :openmp:`4.5`, Section 3.2.32. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetnumthreads.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetnumthreads.rst new file mode 100644 index 00000000000..1b4bc595db1 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetnumthreads.rst @@ -0,0 +1,38 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_num_threads: + +omp_get_num_threads -- Size of the active team +********************************************** + +Description: + Returns the number of threads in the current team. In a sequential section of + the program ``omp_get_num_threads`` returns 1. + + The default team size may be initialized at startup by the + :envvar:`OMP_NUM_THREADS` environment variable. At runtime, the size + of the current team may be set either by the ``NUM_THREADS`` + clause or by ``omp_set_num_threads``. If none of the above were + used to define a specific value and :envvar:`OMP_DYNAMIC` is disabled, + one thread per CPU online is used. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_num_threads(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_num_threads()`` + +See also: + :ref:`omp_get_max_threads`, :ref:`omp_set_num_threads`, :ref:`OMP_NUM_THREADS` + +Reference: + :openmp:`4.5`, Section 3.2.2. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetprocbind.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetprocbind.rst new file mode 100644 index 00000000000..027065776f5 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetprocbind.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_proc_bind: + +omp_get_proc_bind -- Whether theads may be moved between CPUs +************************************************************* + +Description: + This functions returns the currently active thread affinity policy, which is + set via :envvar:`OMP_PROC_BIND`. Possible values are ``omp_proc_bind_false``, + ``omp_proc_bind_true``, ``omp_proc_bind_primary``, + ``omp_proc_bind_master``, ``omp_proc_bind_close`` and ``omp_proc_bind_spread``, + where ``omp_proc_bind_master`` is an alias for ``omp_proc_bind_primary``. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``omp_proc_bind_t omp_get_proc_bind(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer(kind=omp_proc_bind_kind) function omp_get_proc_bind()`` + +See also: + :ref:`OMP_PROC_BIND`, :ref:`OMP_PLACES`, :ref:`GOMP_CPU_AFFINITY`, + +Reference: + :openmp:`4.5`, Section 3.2.22. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetschedule.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetschedule.rst new file mode 100644 index 00000000000..43a25887910 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetschedule.rst @@ -0,0 +1,37 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_schedule: + +omp_get_schedule -- Obtain the runtime scheduling method +******************************************************** + +Description: + Obtain the runtime scheduling method. The :samp:`{kind}` argument will be + set to the value ``omp_sched_static``, ``omp_sched_dynamic``, + ``omp_sched_guided`` or ``omp_sched_auto``. The second argument, + :samp:`{chunk_size}`, is set to the chunk size. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_get_schedule(omp_sched_t *kind, int *chunk_size);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_get_schedule(kind, chunk_size)`` + * - + - ``integer(kind=omp_sched_kind) kind`` + * - + - ``integer chunk_size`` + +See also: + :ref:`omp_set_schedule`, :ref:`OMP_SCHEDULE` + +Reference: + :openmp:`4.5`, Section 3.2.13. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetsupportedactivelevels.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetsupportedactivelevels.rst new file mode 100644 index 00000000000..b8d69291122 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetsupportedactivelevels.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_supported_active_levels: + +omp_get_supported_active_levels -- Maximum number of active regions supported +***************************************************************************** + +Description: + This function returns the maximum number of nested, active parallel regions + supported by this implementation. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_supported_active_levels(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_supported_active_levels()`` + +See also: + :ref:`omp_get_max_active_levels`, :ref:`omp_set_max_active_levels` + +Reference: + :openmp:`5.0`, Section 3.2.15. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetteamnum.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetteamnum.rst new file mode 100644 index 00000000000..6b1727ebbfd --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetteamnum.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_team_num: + +omp_get_team_num -- Get team number +*********************************** + +Description: + Returns the team number of the calling thread. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_team_num(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_team_num()`` + +Reference: + :openmp:`4.5`, Section 3.2.33. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetteamsize.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetteamsize.rst new file mode 100644 index 00000000000..03c09efee44 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetteamsize.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_team_size: + +omp_get_team_size -- Number of threads in a team +************************************************ + +Description: + This function returns the number of threads in a thread team to which + either the current thread or its ancestor belongs. For values of :samp:`{level}` + outside zero to ``omp_get_level``, -1 is returned; if :samp:`{level}` is zero, + 1 is returned, and for ``omp_get_level``, the result is identical + to ``omp_get_num_threads``. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_team_size(int level);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_team_size(level)`` + * - + - ``integer level`` + +See also: + :ref:`omp_get_num_threads`, :ref:`omp_get_level`, :ref:`omp_get_ancestor_thread_num` + +Reference: + :openmp:`4.5`, Section 3.2.19. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetteamsthreadlimit.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetteamsthreadlimit.rst new file mode 100644 index 00000000000..5e4e2eec15a --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetteamsthreadlimit.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_teams_thread_limit: + +omp_get_teams_thread_limit -- Maximum number of threads imposed by teams +************************************************************************ + +Description: + Return the maximum number of threads that will be able to participate in + each team created by a teams construct. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_teams_thread_limit(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_teams_thread_limit()`` + +See also: + :ref:`omp_set_teams_thread_limit`, :ref:`OMP_TEAMS_THREAD_LIMIT` + +Reference: + :openmp:`5.1`, Section 3.4.6. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetthreadlimit.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetthreadlimit.rst new file mode 100644 index 00000000000..6c35a69932f --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetthreadlimit.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_thread_limit: + +omp_get_thread_limit -- Maximum number of threads +************************************************* + +Description: + Return the maximum number of threads of the program. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_thread_limit(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_thread_limit()`` + +See also: + :ref:`omp_get_max_threads`, :ref:`OMP_THREAD_LIMIT` + +Reference: + :openmp:`4.5`, Section 3.2.14. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetthreadnum.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetthreadnum.rst new file mode 100644 index 00000000000..584157a5d9b --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetthreadnum.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_thread_num: + +omp_get_thread_num -- Current thread ID +*************************************** + +Description: + Returns a unique thread identification number within the current team. + In a sequential parts of the program, ``omp_get_thread_num`` + always returns 0. In parallel regions the return value varies + from 0 to ``omp_get_num_threads`` -1 inclusive. The return + value of the primary thread of a team is always 0. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_get_thread_num(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``integer function omp_get_thread_num()`` + +See also: + :ref:`omp_get_num_threads`, :ref:`omp_get_ancestor_thread_num` + +Reference: + :openmp:`4.5`, Section 3.2.4. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetwtick.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetwtick.rst new file mode 100644 index 00000000000..b188d942b23 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetwtick.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_wtick: + +omp_get_wtick -- Get timer precision +************************************ + +Description: + Gets the timer precision, i.e., the number of seconds between two + successive clock ticks. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``double omp_get_wtick(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``double precision function omp_get_wtick()`` + +See also: + :ref:`omp_get_wtime` + +Reference: + :openmp:`4.5`, Section 3.4.2. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompgetwtime.rst b/libgomp/doc/openmp-runtime-library-routines/ompgetwtime.rst new file mode 100644 index 00000000000..27b3b2f56a1 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompgetwtime.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_get_wtime: + +omp_get_wtime -- Elapsed wall clock time +**************************************** + +Description: + Elapsed wall clock time in seconds. The time is measured per thread, no + guarantee can be made that two distinct threads measure the same time. + Time is measured from some "time in the past", which is an arbitrary time + guaranteed not to change during the execution of the program. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``double omp_get_wtime(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``double precision function omp_get_wtime()`` + +See also: + :ref:`omp_get_wtick` + +Reference: + :openmp:`4.5`, Section 3.4.1. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompinfinal.rst b/libgomp/doc/openmp-runtime-library-routines/ompinfinal.rst new file mode 100644 index 00000000000..e36af9f951b --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompinfinal.rst @@ -0,0 +1,29 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_in_final: + +omp_in_final -- Whether in final or included task region +******************************************************** + +Description: + This function returns ``true`` if currently running in a final + or included task region, ``false`` otherwise. Here, ``true`` + and ``false`` represent their language-specific counterparts. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_in_final(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``logical function omp_in_final()`` + +Reference: + :openmp:`4.5`, Section 3.2.21. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompinitlock.rst b/libgomp/doc/openmp-runtime-library-routines/ompinitlock.rst new file mode 100644 index 00000000000..34c52e1014d --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompinitlock.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_init_lock: + +omp_init_lock -- Initialize simple lock +*************************************** + +Description: + Initialize a simple lock. After initialization, the lock is in + an unlocked state. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_init_lock(omp_lock_t *lock);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_init_lock(svar)`` + * - + - ``integer(omp_lock_kind), intent(out) :: svar`` + +See also: + :ref:`omp_destroy_lock` + +Reference: + :openmp:`4.5`, Section 3.3.1. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompinitnestlock.rst b/libgomp/doc/openmp-runtime-library-routines/ompinitnestlock.rst new file mode 100644 index 00000000000..042c1881960 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompinitnestlock.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_init_nest_lock: + +omp_init_nest_lock -- Initialize nested lock +******************************************** + +Description: + Initialize a nested lock. After initialization, the lock is in + an unlocked state and the nesting count is set to zero. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_init_nest_lock(omp_nest_lock_t *lock);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_init_nest_lock(nvar)`` + * - + - ``integer(omp_nest_lock_kind), intent(out) :: nvar`` + +See also: + :ref:`omp_destroy_nest_lock` + +Reference: + :openmp:`4.5`, Section 3.3.1. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompinparallel.rst b/libgomp/doc/openmp-runtime-library-routines/ompinparallel.rst new file mode 100644 index 00000000000..55bc1e1c1c3 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompinparallel.rst @@ -0,0 +1,29 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_in_parallel: + +omp_in_parallel -- Whether a parallel region is active +****************************************************** + +Description: + This function returns ``true`` if currently running in parallel, + ``false`` otherwise. Here, ``true`` and ``false`` represent + their language-specific counterparts. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_in_parallel(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``logical function omp_in_parallel()`` + +Reference: + :openmp:`4.5`, Section 3.2.6. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompisinitialdevice.rst b/libgomp/doc/openmp-runtime-library-routines/ompisinitialdevice.rst new file mode 100644 index 00000000000..501891f548b --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompisinitialdevice.rst @@ -0,0 +1,29 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_is_initial_device: + +omp_is_initial_device -- Whether executing on the host device +************************************************************* + +Description: + This function returns ``true`` if currently running on the host device, + ``false`` otherwise. Here, ``true`` and ``false`` represent + their language-specific counterparts. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_is_initial_device(void);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``logical function omp_is_initial_device()`` + +Reference: + :openmp:`4.5`, Section 3.2.34. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompsetdefaultdevice.rst b/libgomp/doc/openmp-runtime-library-routines/ompsetdefaultdevice.rst new file mode 100644 index 00000000000..33202b9e8ab --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompsetdefaultdevice.rst @@ -0,0 +1,33 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_set_default_device: + +omp_set_default_device -- Set the default device for target regions +******************************************************************* + +Description: + Set the default device for target regions without device clause. The argument + shall be a nonnegative device number. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_set_default_device(int device_num);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_set_default_device(device_num)`` + * - + - ``integer device_num`` + +See also: + :ref:`OMP_DEFAULT_DEVICE`, :ref:`omp_get_default_device` + +Reference: + :openmp:`4.5`, Section 3.2.29. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompsetdynamic.rst b/libgomp/doc/openmp-runtime-library-routines/ompsetdynamic.rst new file mode 100644 index 00000000000..d18346b44c2 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompsetdynamic.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_set_dynamic: + +omp_set_dynamic -- Enable/disable dynamic teams +*********************************************** + +Description: + Enable or disable the dynamic adjustment of the number of threads + within a team. The function takes the language-specific equivalent + of ``true`` and ``false``, where ``true`` enables dynamic + adjustment of team sizes and ``false`` disables it. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_set_dynamic(int dynamic_threads);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_set_dynamic(dynamic_threads)`` + * - + - ``logical, intent(in) :: dynamic_threads`` + +See also: + :ref:`OMP_DYNAMIC`, :ref:`omp_get_dynamic` + +Reference: + :openmp:`4.5`, Section 3.2.7. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompsetlock.rst b/libgomp/doc/openmp-runtime-library-routines/ompsetlock.rst new file mode 100644 index 00000000000..fbaea1d07ec --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompsetlock.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_set_lock: + +omp_set_lock -- Wait for and set simple lock +******************************************** + +Description: + Before setting a simple lock, the lock variable must be initialized by + ``omp_init_lock``. The calling thread is blocked until the lock + is available. If the lock is already held by the current thread, + a deadlock occurs. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_set_lock(omp_lock_t *lock);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_set_lock(svar)`` + * - + - ``integer(omp_lock_kind), intent(inout) :: svar`` + +See also: + :ref:`omp_init_lock`, :ref:`omp_test_lock`, :ref:`omp_unset_lock` + +Reference: + :openmp:`4.5`, Section 3.3.4. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompsetmaxactivelevels.rst b/libgomp/doc/openmp-runtime-library-routines/ompsetmaxactivelevels.rst new file mode 100644 index 00000000000..24c1fd14c0f --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompsetmaxactivelevels.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_set_max_active_levels: + +omp_set_max_active_levels -- Limits the number of active parallel regions +************************************************************************* + +Description: + This function limits the maximum allowed number of nested, active + parallel regions. :samp:`{max_levels}` must be less or equal to + the value returned by ``omp_get_supported_active_levels``. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_set_max_active_levels(int max_levels);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_set_max_active_levels(max_levels)`` + * - + - ``integer max_levels`` + +See also: + :ref:`omp_get_max_active_levels`, :ref:`omp_get_active_level`, + :ref:`omp_get_supported_active_levels` + +Reference: + :openmp:`4.5`, Section 3.2.15. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompsetnested.rst b/libgomp/doc/openmp-runtime-library-routines/ompsetnested.rst new file mode 100644 index 00000000000..37005852f1a --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompsetnested.rst @@ -0,0 +1,40 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_set_nested: + +omp_set_nested -- Enable/disable nested parallel regions +******************************************************** + +Description: + Enable or disable nested parallel regions, i.e., whether team members + are allowed to create new teams. The function takes the language-specific + equivalent of ``true`` and ``false``, where ``true`` enables + dynamic adjustment of team sizes and ``false`` disables it. + + Enabling nested parallel regions will also set the maximum number of + active nested regions to the maximum supported. Disabling nested parallel + regions will set the maximum number of active nested regions to one. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_set_nested(int nested);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_set_nested(nested)`` + * - + - ``logical, intent(in) :: nested`` + +See also: + :ref:`omp_get_nested`, :ref:`omp_set_max_active_levels`, + :ref:`OMP_MAX_ACTIVE_LEVELS`, :ref:`OMP_NESTED` + +Reference: + :openmp:`4.5`, Section 3.2.10. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompsetnestlock.rst b/libgomp/doc/openmp-runtime-library-routines/ompsetnestlock.rst new file mode 100644 index 00000000000..c159d9560a6 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompsetnestlock.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_set_nest_lock: + +omp_set_nest_lock -- Wait for and set nested lock +************************************************* + +Description: + Before setting a nested lock, the lock variable must be initialized by + ``omp_init_nest_lock``. The calling thread is blocked until the lock + is available. If the lock is already held by the current thread, the + nesting count for the lock is incremented. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_set_nest_lock(omp_nest_lock_t *lock);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_set_nest_lock(nvar)`` + * - + - ``integer(omp_nest_lock_kind), intent(inout) :: nvar`` + +See also: + :ref:`omp_init_nest_lock`, :ref:`omp_unset_nest_lock` + +Reference: + :openmp:`4.5`, Section 3.3.4. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompsetnumteams.rst b/libgomp/doc/openmp-runtime-library-routines/ompsetnumteams.rst new file mode 100644 index 00000000000..83642f6d4e9 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompsetnumteams.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_set_num_teams: + +omp_set_num_teams -- Set upper teams limit for teams construct +************************************************************** + +Description: + Specifies the upper bound for number of teams created by the teams construct + which does not specify a ``num_teams`` clause. The + argument of ``omp_set_num_teams`` shall be a positive integer. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_set_num_teams(int num_teams);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_set_num_teams(num_teams)`` + * - + - ``integer, intent(in) :: num_teams`` + +See also: + :ref:`OMP_NUM_TEAMS`, :ref:`omp_get_num_teams`, :ref:`omp_get_max_teams` + +Reference: + :openmp:`5.1`, Section 3.4.3. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompsetnumthreads.rst b/libgomp/doc/openmp-runtime-library-routines/ompsetnumthreads.rst new file mode 100644 index 00000000000..dd9ad459d69 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompsetnumthreads.rst @@ -0,0 +1,34 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_set_num_threads: + +omp_set_num_threads -- Set upper team size limit +************************************************ + +Description: + Specifies the number of threads used by default in subsequent parallel + sections, if those do not specify a ``num_threads`` clause. The + argument of ``omp_set_num_threads`` shall be a positive integer. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_set_num_threads(int num_threads);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_set_num_threads(num_threads)`` + * - + - ``integer, intent(in) :: num_threads`` + +See also: + :ref:`OMP_NUM_THREADS`, :ref:`omp_get_num_threads`, :ref:`omp_get_max_threads` + +Reference: + :openmp:`4.5`, Section 3.2.1. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompsetschedule.rst b/libgomp/doc/openmp-runtime-library-routines/ompsetschedule.rst new file mode 100644 index 00000000000..4c7e08f2b09 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompsetschedule.rst @@ -0,0 +1,40 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_set_schedule: + +omp_set_schedule -- Set the runtime scheduling method +***************************************************** + +Description: + Sets the runtime scheduling method. The :samp:`{kind}` argument can have the + value ``omp_sched_static``, ``omp_sched_dynamic``, + ``omp_sched_guided`` or ``omp_sched_auto``. Except for + ``omp_sched_auto``, the chunk size is set to the value of + :samp:`{chunk_size}` if positive, or to the default value if zero or negative. + For ``omp_sched_auto`` the :samp:`{chunk_size}` argument is ignored. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_set_schedule(omp_sched_t kind, int chunk_size);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_set_schedule(kind, chunk_size)`` + * - + - ``integer(kind=omp_sched_kind) kind`` + * - + - ``integer chunk_size`` + +See also: + :ref:`omp_get_schedule` + :ref:`OMP_SCHEDULE` + +Reference: + :openmp:`4.5`, Section 3.2.12. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompsetteamsthreadlimit.rst b/libgomp/doc/openmp-runtime-library-routines/ompsetteamsthreadlimit.rst new file mode 100644 index 00000000000..36385b46e61 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompsetteamsthreadlimit.rst @@ -0,0 +1,35 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_set_teams_thread_limit: + +omp_set_teams_thread_limit -- Set upper thread limit for teams construct +************************************************************************ + +Description: + Specifies the upper bound for number of threads that will be available + for each team created by the teams construct which does not specify a + ``thread_limit`` clause. The argument of + ``omp_set_teams_thread_limit`` shall be a positive integer. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_set_teams_thread_limit(int thread_limit);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_set_teams_thread_limit(thread_limit)`` + * - + - ``integer, intent(in) :: thread_limit`` + +See also: + :ref:`OMP_TEAMS_THREAD_LIMIT`, :ref:`omp_get_teams_thread_limit`, :ref:`omp_get_thread_limit` + +Reference: + :openmp:`5.1`, Section 3.4.5. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/omptestlock.rst b/libgomp/doc/openmp-runtime-library-routines/omptestlock.rst new file mode 100644 index 00000000000..500c12ba516 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/omptestlock.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_test_lock: + +omp_test_lock -- Test and set simple lock if available +****************************************************** + +Description: + Before setting a simple lock, the lock variable must be initialized by + ``omp_init_lock``. Contrary to ``omp_set_lock``, ``omp_test_lock`` + does not block if the lock is not available. This function returns + ``true`` upon success, ``false`` otherwise. Here, ``true`` and + ``false`` represent their language-specific counterparts. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_test_lock(omp_lock_t *lock);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``logical function omp_test_lock(svar)`` + * - + - ``integer(omp_lock_kind), intent(inout) :: svar`` + +See also: + :ref:`omp_init_lock`, :ref:`omp_set_lock`, :ref:`omp_set_lock` + +Reference: + :openmp:`4.5`, Section 3.3.6. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/omptestnestlock.rst b/libgomp/doc/openmp-runtime-library-routines/omptestnestlock.rst new file mode 100644 index 00000000000..9a6df1c7e5d --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/omptestnestlock.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_test_nest_lock: + +omp_test_nest_lock -- Test and set nested lock if available +*********************************************************** + +Description: + Before setting a nested lock, the lock variable must be initialized by + ``omp_init_nest_lock``. Contrary to ``omp_set_nest_lock``, + ``omp_test_nest_lock`` does not block if the lock is not available. + If the lock is already held by the current thread, the new nesting count + is returned. Otherwise, the return value equals zero. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``int omp_test_nest_lock(omp_nest_lock_t *lock);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``logical function omp_test_nest_lock(nvar)`` + * - + - ``integer(omp_nest_lock_kind), intent(inout) :: nvar`` + +See also: + :ref:`omp_init_lock`, :ref:`omp_set_lock`, :ref:`omp_set_lock` + +Reference: + :openmp:`4.5`, Section 3.3.6. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompunsetlock.rst b/libgomp/doc/openmp-runtime-library-routines/ompunsetlock.rst new file mode 100644 index 00000000000..d8940a9b7dd --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompunsetlock.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_unset_lock: + +omp_unset_lock -- Unset simple lock +*********************************** + +Description: + A simple lock about to be unset must have been locked by ``omp_set_lock`` + or ``omp_test_lock`` before. In addition, the lock must be held by the + thread calling ``omp_unset_lock``. Then, the lock becomes unlocked. If one + or more threads attempted to set the lock before, one of them is chosen to, + again, set the lock to itself. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_unset_lock(omp_lock_t *lock);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_unset_lock(svar)`` + * - + - ``integer(omp_lock_kind), intent(inout) :: svar`` + +See also: + :ref:`omp_set_lock`, :ref:`omp_test_lock` + +Reference: + :openmp:`4.5`, Section 3.3.5. \ No newline at end of file diff --git a/libgomp/doc/openmp-runtime-library-routines/ompunsetnestlock.rst b/libgomp/doc/openmp-runtime-library-routines/ompunsetnestlock.rst new file mode 100644 index 00000000000..a39115daf54 --- /dev/null +++ b/libgomp/doc/openmp-runtime-library-routines/ompunsetnestlock.rst @@ -0,0 +1,36 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _omp_unset_nest_lock: + +omp_unset_nest_lock -- Unset nested lock +**************************************** + +Description: + A nested lock about to be unset must have been locked by ``omp_set_nested_lock`` + or ``omp_test_nested_lock`` before. In addition, the lock must be held by the + thread calling ``omp_unset_nested_lock``. If the nesting count drops to zero, the + lock becomes unlocked. If one ore more threads attempted to set the lock before, + one of them is chosen to, again, set the lock to itself. + +C/C++: + .. list-table:: + + * - *Prototype*: + - ``void omp_unset_nest_lock(omp_nest_lock_t *lock);`` + +Fortran: + .. list-table:: + + * - *Interface*: + - ``subroutine omp_unset_nest_lock(nvar)`` + * - + - ``integer(omp_nest_lock_kind), intent(inout) :: nvar`` + +See also: + :ref:`omp_set_nest_lock` + +Reference: + :openmp:`4.5`, Section 3.3.5. \ No newline at end of file diff --git a/libgomp/doc/reporting-bugs.rst b/libgomp/doc/reporting-bugs.rst new file mode 100644 index 00000000000..46beaf85306 --- /dev/null +++ b/libgomp/doc/reporting-bugs.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _reporting-bugs: + +Reporting Bugs +-------------- + +Bugs in the GNU Offloading and Multi Processing Runtime Library should +be reported via `Bugzilla `_. Please add +"openacc", or "openmp", or both to the keywords field in the bug +report, as appropriate. \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi.rst b/libgomp/doc/the-libgomp-abi.rst new file mode 100644 index 00000000000..3b5308532e7 --- /dev/null +++ b/libgomp/doc/the-libgomp-abi.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _the-libgomp-abi: + +The libgomp ABI +--------------- + +The following sections present notes on the external ABI as +presented by libgomp. Only maintainers should need them. + +.. toctree:: + :maxdepth: 2 + + the-libgomp-abi/implementing-master-construct + the-libgomp-abi/implementing-critical-construct + the-libgomp-abi/implementing-atomic-construct + the-libgomp-abi/implementing-flush-construct + the-libgomp-abi/implementing-barrier-construct + the-libgomp-abi/implementing-threadprivate-construct + the-libgomp-abi/implementing-private-clause + the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses + the-libgomp-abi/implementing-reduction-clause + the-libgomp-abi/implementing-parallel-construct + the-libgomp-abi/implementing-for-construct + the-libgomp-abi/implementing-ordered-construct + the-libgomp-abi/implementing-sections-construct + the-libgomp-abi/implementing-single-construct + the-libgomp-abi/implementing-openaccs-parallel-construct \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-atomic-construct.rst b/libgomp/doc/the-libgomp-abi/implementing-atomic-construct.rst new file mode 100644 index 00000000000..f66155e9e3f --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-atomic-construct.rst @@ -0,0 +1,21 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-atomic-construct: + +Implementing ATOMIC construct +***************************** + +The target should implement the ``__sync`` builtins. + +Failing that we could add + +.. code-block:: c++ + + void GOMP_atomic_enter (void) + void GOMP_atomic_exit (void) + +which reuses the regular lock code, but with yet another lock +object private to the library. \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-barrier-construct.rst b/libgomp/doc/the-libgomp-abi/implementing-barrier-construct.rst new file mode 100644 index 00000000000..444afcccc09 --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-barrier-construct.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-barrier-construct: + +Implementing BARRIER construct +****************************** + +.. code-block:: c++ + + void GOMP_barrier (void) \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-critical-construct.rst b/libgomp/doc/the-libgomp-abi/implementing-critical-construct.rst new file mode 100644 index 00000000000..587163e574c --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-critical-construct.rst @@ -0,0 +1,30 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-critical-construct: + +Implementing CRITICAL construct +******************************* + +Without a specified name, + +.. code-block:: c++ + + void GOMP_critical_start (void); + void GOMP_critical_end (void); + +so that we don't get COPY relocations from libgomp to the main +application. + +With a specified name, use omp_set_lock and omp_unset_lock with +name being transformed into a variable declared like + +.. code-block:: c++ + + omp_lock_t gomp_critical_user_ __attribute__((common)) + +Ideally the ABI would specify that all zero is a valid unlocked +state, and so we wouldn't need to initialize this at +startup. \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst b/libgomp/doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst new file mode 100644 index 00000000000..cfda2a875b9 --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst @@ -0,0 +1,45 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses: + +Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses +******************************************************************** + +This seems simple enough for PARALLEL blocks. Create a private +struct for communicating between the parent and subfunction. +In the parent, copy in values for scalar and "small" structs; +copy in addresses for others TREE_ADDRESSABLE types. In the +subfunction, copy the value into the local variable. + +It is not clear what to do with bare FOR or SECTION blocks. +The only thing I can figure is that we do something like: + +.. code-block:: c++ + + #pragma omp for firstprivate(x) lastprivate(y) + for (int i = 0; i < n; ++i) + body; + +which becomes + +.. code-block:: c++ + + { + int x = x, y; + + // for stuff + + if (i == n) + y = y; + } + +where the "x=x" and "y=y" assignments actually have different +uids for the two variables, i.e. not something you could write +directly in C. Presumably this only makes sense if the "outer" +x and y are global variables. + +COPYPRIVATE would work the same way, except the structure +broadcast would have to happen via SINGLE machinery instead. \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-flush-construct.rst b/libgomp/doc/the-libgomp-abi/implementing-flush-construct.rst new file mode 100644 index 00000000000..9f9419e7484 --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-flush-construct.rst @@ -0,0 +1,11 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-flush-construct: + +Implementing FLUSH construct +**************************** + +Expands to the ``__sync_synchronize`` builtin. \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-for-construct.rst b/libgomp/doc/the-libgomp-abi/implementing-for-construct.rst new file mode 100644 index 00000000000..5291465bdfb --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-for-construct.rst @@ -0,0 +1,73 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-for-construct: + +Implementing FOR construct +************************** + +.. code-block:: c++ + + #pragma omp parallel for + for (i = lb; i <= ub; i++) + body; + +becomes + +.. code-block:: c++ + + void subfunction (void *data) + { + long _s0, _e0; + while (GOMP_loop_static_next (&_s0, &_e0)) + { + long _e1 = _e0, i; + for (i = _s0; i < _e1; i++) + body; + } + GOMP_loop_end_nowait (); + } + + GOMP_parallel_loop_static (subfunction, NULL, 0, lb, ub+1, 1, 0); + subfunction (NULL); + GOMP_parallel_end (); + +.. code-block:: c++ + + #pragma omp for schedule(runtime) + for (i = 0; i < n; i++) + body; + +becomes + +.. code-block:: c++ + + { + long i, _s0, _e0; + if (GOMP_loop_runtime_start (0, n, 1, &_s0, &_e0)) + do { + long _e1 = _e0; + for (i = _s0, i < _e0; i++) + body; + } while (GOMP_loop_runtime_next (&_s0, _&e0)); + GOMP_loop_end (); + } + +Note that while it looks like there is trickiness to propagating +a non-constant STEP, there isn't really. We're explicitly allowed +to evaluate it as many times as we want, and any variables involved +should automatically be handled as PRIVATE or SHARED like any other +variables. So the expression should remain evaluable in the +subfunction. We can also pull it into a local variable if we like, +but since its supposed to remain unchanged, we can also not if we like. + +If we have SCHEDULE(STATIC), and no ORDERED, then we ought to be +able to get away with no work-sharing context at all, since we can +simply perform the arithmetic directly in each thread to divide up +the iterations. Which would mean that we wouldn't need to call any +of these routines. + +There are separate routines for handling loops with an ORDERED +clause. Bookkeeping for that is non-trivial... \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-master-construct.rst b/libgomp/doc/the-libgomp-abi/implementing-master-construct.rst new file mode 100644 index 00000000000..29e085c87c5 --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-master-construct.rst @@ -0,0 +1,18 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-master-construct: + +Implementing MASTER construct +***************************** + +.. code-block:: c++ + + if (omp_get_thread_num () == 0) + block + +Alternately, we generate two copies of the parallel subfunction +and only include this in the version run by the primary thread. +Surely this is not worthwhile though... \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-openaccs-parallel-construct.rst b/libgomp/doc/the-libgomp-abi/implementing-openaccs-parallel-construct.rst new file mode 100644 index 00000000000..03b905338a4 --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-openaccs-parallel-construct.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-openacc's-parallel-construct: + +Implementing OpenACC's PARALLEL construct +***************************************** + +.. code-block:: c++ + + void GOACC_parallel () \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-ordered-construct.rst b/libgomp/doc/the-libgomp-abi/implementing-ordered-construct.rst new file mode 100644 index 00000000000..2c5a1960d8a --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-ordered-construct.rst @@ -0,0 +1,14 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-ordered-construct: + +Implementing ORDERED construct +****************************** + +.. code-block:: c++ + + void GOMP_ordered_start (void) + void GOMP_ordered_end (void) \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-parallel-construct.rst b/libgomp/doc/the-libgomp-abi/implementing-parallel-construct.rst new file mode 100644 index 00000000000..c2f0dc3e3e0 --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-parallel-construct.rst @@ -0,0 +1,55 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-parallel-construct: + +Implementing PARALLEL construct +******************************* + +.. code-block:: c++ + + #pragma omp parallel + { + body; + } + +becomes + +.. code-block:: c++ + + void subfunction (void *data) + { + use data; + body; + } + + setup data; + GOMP_parallel_start (subfunction, &data, num_threads); + subfunction (&data); + GOMP_parallel_end (); + +.. code-block:: c++ + + void GOMP_parallel_start (void (*fn)(void *), void *data, unsigned num_threads) + +The :samp:`{FN}` argument is the subfunction to be run in parallel. + +The :samp:`{DATA}` argument is a pointer to a structure used to +communicate data in and out of the subfunction, as discussed +above with respect to FIRSTPRIVATE et al. + +The :samp:`{NUM_THREADS}` argument is 1 if an IF clause is present +and false, or the value of the NUM_THREADS clause, if +present, or 0. + +The function needs to create the appropriate number of +threads and/or launch them from the dock. It needs to +create the team structure and assign team ids. + +.. code-block:: c++ + + void GOMP_parallel_end (void) + +Tears down the team and returns us to the previous ``omp_in_parallel()`` state. \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-private-clause.rst b/libgomp/doc/the-libgomp-abi/implementing-private-clause.rst new file mode 100644 index 00000000000..9b36da6c3f1 --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-private-clause.rst @@ -0,0 +1,17 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-private-clause: + +Implementing PRIVATE clause +*************************** + +In association with a PARALLEL, or within the lexical extent +of a PARALLEL block, the variable becomes a local variable in +the parallel subfunction. + +In association with FOR or SECTIONS blocks, create a new +automatic variable within the current function. This preserves +the semantic of new variable creation. \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-reduction-clause.rst b/libgomp/doc/the-libgomp-abi/implementing-reduction-clause.rst new file mode 100644 index 00000000000..5db34e05077 --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-reduction-clause.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-reduction-clause: + +Implementing REDUCTION clause +***************************** + +The private struct mentioned in the previous section should have +a pointer to an array of the type of the variable, indexed by the +thread's :samp:`{team_id}`. The thread stores its final value into the +array, and after the barrier, the primary thread iterates over the +array to collect the values. \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-sections-construct.rst b/libgomp/doc/the-libgomp-abi/implementing-sections-construct.rst new file mode 100644 index 00000000000..4fcdf496b77 --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-sections-construct.rst @@ -0,0 +1,42 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-sections-construct: + +Implementing SECTIONS construct +******************************* + +A block as + +.. code-block:: c++ + + #pragma omp sections + { + #pragma omp section + stmt1; + #pragma omp section + stmt2; + #pragma omp section + stmt3; + } + +becomes + +.. code-block:: c++ + + for (i = GOMP_sections_start (3); i != 0; i = GOMP_sections_next ()) + switch (i) + { + case 1: + stmt1; + break; + case 2: + stmt2; + break; + case 3: + stmt3; + break; + } + GOMP_barrier (); \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-single-construct.rst b/libgomp/doc/the-libgomp-abi/implementing-single-construct.rst new file mode 100644 index 00000000000..2919e6bf91f --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-single-construct.rst @@ -0,0 +1,48 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-single-construct: + +Implementing SINGLE construct +***************************** + +A block like + +.. code-block:: c++ + + #pragma omp single + { + body; + } + +becomes + +.. code-block:: c++ + + if (GOMP_single_start ()) + body; + GOMP_barrier (); + +while + +.. code-block:: c++ + + #pragma omp single copyprivate(x) + body; + +becomes + +.. code-block:: c++ + + datap = GOMP_single_copy_start (); + if (datap == NULL) + { + body; + data.x = x; + GOMP_single_copy_end (&data); + } + else + x = datap->x; + GOMP_barrier (); \ No newline at end of file diff --git a/libgomp/doc/the-libgomp-abi/implementing-threadprivate-construct.rst b/libgomp/doc/the-libgomp-abi/implementing-threadprivate-construct.rst new file mode 100644 index 00000000000..0ea107e9201 --- /dev/null +++ b/libgomp/doc/the-libgomp-abi/implementing-threadprivate-construct.rst @@ -0,0 +1,18 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _implementing-threadprivate-construct: + +Implementing THREADPRIVATE construct +************************************ + +In _most_ cases we can map this directly to ``__thread``. Except +that OMP allows constructors for C++ objects. We can either +refuse to support this (how often is it used?) or we can +implement something akin to .ctors. + +Even more ideally, this ctor feature is handled by extensions +to the main pthreads library. Failing that, we can have a set +of entry points to register ctor functions to be called. \ No newline at end of file diff --git a/libiberty/doc/bsd.rst b/libiberty/doc/bsd.rst new file mode 100644 index 00000000000..bb786e2deed --- /dev/null +++ b/libiberty/doc/bsd.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../doc/bsd.rst \ No newline at end of file diff --git a/libiberty/doc/conf.py b/libiberty/doc/conf.py new file mode 100644 index 00000000000..b255fd906b8 --- /dev/null +++ b/libiberty/doc/conf.py @@ -0,0 +1,25 @@ +# Configuration file for the Sphinx documentation builder. + +import sys +sys.path.append('../..//doc') + +from baseconf import * + +name = 'libiberty' +project = 'GNU libiberty' +copyright = '2001-2022 Free Software Foundation, Inc.' +authors = 'Phil Edwards et al.' + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +latex_documents = [ + ('index', f'{name}.tex', project, authors, 'manual'), +] + + +texinfo_documents = [ + ('index', name, project, authors, None, None, None, True) +] + +set_common(name, globals()) \ No newline at end of file diff --git a/libiberty/doc/copyright.rst b/libiberty/doc/copyright.rst new file mode 100644 index 00000000000..5afce611a7a --- /dev/null +++ b/libiberty/doc/copyright.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Copyright +^^^^^^^^^ + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +A copy of the license is in the :ref:`gnu_fdl`. \ No newline at end of file diff --git a/libiberty/doc/extensions.rst b/libiberty/doc/extensions.rst new file mode 100644 index 00000000000..03a2419cf27 --- /dev/null +++ b/libiberty/doc/extensions.rst @@ -0,0 +1,767 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: extensions, functions, extension + +.. _extensions: + +Extensions +********** + +``libiberty`` includes additional functionality above and beyond standard +functions, which has proven generically useful in GNU programs, such as +obstacks and regex. These functions are often copied from other +projects as they gain popularity, and are included here to provide a +central location from which to use, maintain, and distribute them. + +.. toctree:: + :maxdepth: 2 + + +.. This is generated from the glibc manual using contrib/make-obstacks-texi.pl + +.. index:: obstacks + +.. _obstacks: + +Obstacks +^^^^^^^^ + +An :dfn:`obstack` is a pool of memory containing a stack of objects. You +can create any number of separate obstacks, and then allocate objects in +specified obstacks. Within each obstack, the last object allocated must +always be the first one freed, but distinct obstacks are independent of +each other. + +Aside from this one constraint of order of freeing, obstacks are totally +general: an obstack can contain any number of objects of any size. They +are implemented with macros, so allocation is usually very fast as long as +the objects are usually small. And the only space overhead per object is +the padding needed to start each object on a suitable boundary. + +.. toctree:: + :maxdepth: 2 + + +.. _creating-obstacks: + +Creating Obstacks +~~~~~~~~~~~~~~~~~ + +The utilities for manipulating obstacks are declared in the header +file :samp:`obstack.h`. + +.. index:: obstack.h, struct obstack + +Data Type struct obstackAn obstack is represented by a data structure of type ``struct +obstack``. This structure has a small fixed size; it records the status +of the obstack and how to find the space in which objects are allocated. +It does not contain any of the objects themselves. You should not try +to access the contents of the structure directly; use only the macros +described in this chapter. + +You can declare variables of type ``struct obstack`` and use them as +obstacks, or you can allocate obstacks dynamically like any other kind +of object. Dynamic allocation of obstacks allows your program to have a +variable number of different stacks. (You can even allocate an +obstack structure in another obstack, but this is rarely useful.) + +All the macros that work with obstacks require you to specify which +obstack to use. You do this with a pointer of type ``struct obstack +*``. In the following, we often say 'an obstack' when strictly +speaking the object at hand is such a pointer. + +The objects in the obstack are packed into large blocks called +:dfn:`chunks`. The ``struct obstack`` structure points to a chain of +the chunks currently in use. + +The obstack library obtains a new chunk whenever you allocate an object +that won't fit in the previous chunk. Since the obstack library manages +chunks automatically, you don't need to pay much attention to them, but +you do need to supply a function which the obstack library should use to +get a chunk. Usually you supply a function which uses ``malloc`` +directly or indirectly. You must also supply a function to free a chunk. +These matters are described in the following section. + +.. _preparing-for-obstacks: + +Preparing for Using Obstacks +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Each source file in which you plan to use obstacks +must include the header file :samp:`obstack.h`, like this: + +.. code-block:: c++ + + #include + +.. index:: obstack_chunk_alloc, obstack_chunk_free + +Also, if the source file uses the macro ``obstack_init``, it must +declare or define two macros that will be called by the +obstack library. One, ``obstack_chunk_alloc``, is used to allocate +the chunks of memory into which objects are packed. The other, +``obstack_chunk_free``, is used to return chunks when the objects in +them are freed. These macros should appear before any use of obstacks +in the source file. + +Usually these are defined to use ``malloc`` via the intermediary +``xmalloc`` (see `Unconstrained Allocation `_ +in The GNU C Library Reference Manual). This is done with +the following pair of macro definitions: + +.. code-block:: c++ + + #define obstack_chunk_alloc xmalloc + #define obstack_chunk_free free + +Though the memory you get using obstacks really comes from ``malloc``, +using obstacks is faster because ``malloc`` is called less often, for +larger blocks of memory. See :ref:`obstack-chunks`, for full details. + +At run time, before the program can use a ``struct obstack`` object +as an obstack, it must initialize the obstack by calling +``obstack_init`` or one of its variants, ``obstack_begin``, +``obstack_specify_allocation``, or +``obstack_specify_allocation_with_arg``. + +.. function:: int obstack_init (struct obstack *obstack_ptr) + + Initialize obstack :samp:`{obstack_ptr}` for allocation of objects. This + macro calls the obstack's ``obstack_chunk_alloc`` function. If + allocation of memory fails, the function pointed to by + ``obstack_alloc_failed_handler`` is called. The ``obstack_init`` + macro always returns 1 (Compatibility notice: Former versions of + obstack returned 0 if allocation failed). + +Here are two examples of how to allocate the space for an obstack and +initialize it. First, an obstack that is a static variable: + +.. code-block:: c++ + + static struct obstack myobstack; + ... + obstack_init (&myobstack); + +Second, an obstack that is itself dynamically allocated: + +.. code-block:: c++ + + struct obstack *myobstack_ptr + = (struct obstack *) xmalloc (sizeof (struct obstack)); + + obstack_init (myobstack_ptr); + +.. function:: int obstack_begin (struct obstack *obstack_ptr, size_t chunk_size) + + Like ``obstack_init``, but specify chunks to be at least + :samp:`{chunk_size}` bytes in size. + +.. function:: int obstack_specify_allocation (struct obstack *obstack_ptr, size_t chunk_size, size_t alignment, void *(*chunkfun) (size_t), void (*freefun) (void *)) + + Like ``obstack_init``, specifying chunk size, chunk + alignment, and memory allocation functions. A :samp:`{chunk_size}` or + :samp:`{alignment}` of zero results in the default size or alignment + respectively being used. + +.. function:: int obstack_specify_allocation_with_arg (struct obstack *obstack_ptr, size_t chunk_size, size_t alignment, void *(*chunkfun) (void *, size_t), void (*freefun) (void *, void *), void *arg) + + Like ``obstack_specify_allocation``, but specifying memory + allocation functions that take an extra first argument, :samp:`{arg}`. + +.. index:: obstack_alloc_failed_handler + +Variable obstack_alloc_failed_handlerThe value of this variable is a pointer to a function that +``obstack`` uses when ``obstack_chunk_alloc`` fails to allocate +memory. The default action is to print a message and abort. +You should supply a function that either calls ``exit`` +(see `Program Termination `_ in The GNU C Library Reference Manual) +or ``longjmp`` and doesn't return. + +.. code-block:: c++ + + void my_obstack_alloc_failed (void) + ... + obstack_alloc_failed_handler = &my_obstack_alloc_failed; + +.. index:: allocation (obstacks) + +.. _allocation-in-an-obstack: + +Allocation in an Obstack +~~~~~~~~~~~~~~~~~~~~~~~~ + +The most direct way to allocate an object in an obstack is with +``obstack_alloc``, which is invoked almost like ``malloc``. + +.. function:: void * obstack_alloc (struct obstack *obstack_ptr, size_t size) + + This allocates an uninitialized block of :samp:`{size}` bytes in an obstack + and returns its address. Here :samp:`{obstack_ptr}` specifies which obstack + to allocate the block in; it is the address of the ``struct obstack`` + object which represents the obstack. Each obstack macro + requires you to specify an :samp:`{obstack_ptr}` as the first argument. + + This macro calls the obstack's ``obstack_chunk_alloc`` function if + it needs to allocate a new chunk of memory; it calls + ``obstack_alloc_failed_handler`` if allocation of memory by + ``obstack_chunk_alloc`` failed. + +For example, here is a function that allocates a copy of a string :samp:`{str}` +in a specific obstack, which is in the variable ``string_obstack`` : + +.. code-block:: c++ + + struct obstack string_obstack; + + char * + copystring (char *string) + { + size_t len = strlen (string) + 1; + char *s = (char *) obstack_alloc (&string_obstack, len); + memcpy (s, string, len); + return s; + } + +To allocate a block with specified contents, use the macro ``obstack_copy``. + +.. function:: void * obstack_copy (struct obstack *obstack_ptr, void *address, size_t size) + + This allocates a block and initializes it by copying :samp:`{size}` + bytes of data starting at :samp:`{address}`. It calls + ``obstack_alloc_failed_handler`` if allocation of memory by + ``obstack_chunk_alloc`` failed. + +.. function:: void * obstack_copy0 (struct obstack *obstack_ptr, void *address, size_t size) + + Like ``obstack_copy``, but appends an extra byte containing a null + character. This extra byte is not counted in the argument :samp:`{size}`. + +The ``obstack_copy0`` macro is convenient for copying a sequence +of characters into an obstack as a null-terminated string. Here is an +example of its use: + +.. code-block:: c++ + + char * + obstack_savestring (char *addr, size_t size) + { + return obstack_copy0 (&myobstack, addr, size); + } + +Contrast this with the previous example of ``savestring`` using +``malloc`` see (`Basic Allocation `_). + +.. index:: freeing (obstacks) + +.. _freeing-obstack-objects: + +Freeing Objects in an Obstack +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To free an object allocated in an obstack, use the macro +``obstack_free``. Since the obstack is a stack of objects, freeing +one object automatically frees all other objects allocated more recently +in the same obstack. + +.. function:: void obstack_free (struct obstack *obstack_ptr, void *object) + + If :samp:`{object}` is a null pointer, everything allocated in the obstack + is freed. Otherwise, :samp:`{object}` must be the address of an object + allocated in the obstack. Then :samp:`{object}` is freed, along with + everything allocated in :samp:`{obstack}` since :samp:`{object}`. + +Note that if :samp:`{object}` is a null pointer, the result is an +uninitialized obstack. To free all memory in an obstack but leave it +valid for further allocation, call ``obstack_free`` with the address +of the first object allocated on the obstack: + +.. code-block:: c++ + + obstack_free (obstack_ptr, first_object_allocated_ptr); + +Recall that the objects in an obstack are grouped into chunks. When all +the objects in a chunk become free, the obstack library automatically +frees the chunk (see :ref:`preparing-for-obstacks`). Then other +obstacks, or non-obstack allocation, can reuse the space of the chunk. + +.. index:: macros + +.. _obstack-functions: + +Obstack Functions and Macros +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The interfaces for using obstacks are shown here as functions to +specify the return type and argument types, but they are really +defined as macros. This means that the arguments don't actually have +types, but they generally behave as if they have the types shown. +You can call these macros like functions, but you cannot use them in +any other way (for example, you cannot take their address). + +Calling the macros requires a special precaution: namely, the first +operand (the obstack pointer) may not contain any side effects, because +it may be computed more than once. For example, if you write this: + +.. code-block:: c++ + + obstack_alloc (get_obstack (), 4); + +you will find that ``get_obstack`` may be called several times. +If you use ``*obstack_list_ptr++`` as the obstack pointer argument, +you will get very strange results since the incrementation may occur +several times. + +If you use the GNU C compiler, this precaution is not necessary, because +various language extensions in GNU C permit defining the macros so as to +compute each argument only once. + +Note that arguments other than the first will only be evaluated once, +even when not using GNU C. + +``obstack.h`` does declare a number of functions, +``_obstack_begin``, ``_obstack_begin_1``, +``_obstack_newchunk``, ``_obstack_free``, and +``_obstack_memory_used``. You should not call these directly. + +.. index:: growing objects (in obstacks), changing the size of a block (obstacks) + +.. _growing-objects: + +Growing Objects +~~~~~~~~~~~~~~~ + +Because memory in obstack chunks is used sequentially, it is possible to +build up an object step by step, adding one or more bytes at a time to the +end of the object. With this technique, you do not need to know how much +data you will put in the object until you come to the end of it. We call +this the technique of :dfn:`growing objects`. The special macros +for adding data to the growing object are described in this section. + +You don't need to do anything special when you start to grow an object. +Using one of the macros to add data to the object automatically +starts it. However, it is necessary to say explicitly when the object is +finished. This is done with ``obstack_finish``. + +The actual address of the object thus built up is not known until the +object is finished. Until then, it always remains possible that you will +add so much data that the object must be copied into a new chunk. + +While the obstack is in use for a growing object, you cannot use it for +ordinary allocation of another object. If you try to do so, the space +already added to the growing object will become part of the other object. + +.. function:: void obstack_blank (struct obstack *obstack_ptr, size_t size) + + The most basic macro for adding to a growing object is + ``obstack_blank``, which adds space without initializing it. + +.. function:: void obstack_grow (struct obstack *obstack_ptr, void *data, size_t size) + + To add a block of initialized space, use ``obstack_grow``, which is + the growing-object analogue of ``obstack_copy``. It adds :samp:`{size}` + bytes of data to the growing object, copying the contents from + :samp:`{data}`. + +.. function:: void obstack_grow0 (struct obstack *obstack_ptr, void *data, size_t size) + + This is the growing-object analogue of ``obstack_copy0``. It adds + :samp:`{size}` bytes copied from :samp:`{data}`, followed by an additional null + character. + +.. function:: void obstack_1grow (struct obstack *obstack_ptr, char c) + + To add one character at a time, use ``obstack_1grow``. + It adds a single byte containing :samp:`{c}` to the growing object. + +.. function:: void obstack_ptr_grow (struct obstack *obstack_ptr, void *data) + + Adding the value of a pointer one can use + ``obstack_ptr_grow``. It adds ``sizeof (void *)`` bytes + containing the value of :samp:`{data}`. + +.. function:: void obstack_int_grow (struct obstack *obstack_ptr, int data) + + A single value of type ``int`` can be added by using + ``obstack_int_grow``. It adds ``sizeof (int)`` bytes to + the growing object and initializes them with the value of :samp:`{data}`. + +.. function:: void * obstack_finish (struct obstack *obstack_ptr) + + When you are finished growing the object, use + ``obstack_finish`` to close it off and return its final address. + + Once you have finished the object, the obstack is available for ordinary + allocation or for growing another object. + +When you build an object by growing it, you will probably need to know +afterward how long it became. You need not keep track of this as you grow +the object, because you can find out the length from the obstack +with ``obstack_object_size``, before finishing the object. + +.. function:: size_t obstack_object_size (struct obstack *obstack_ptr) + + This macro returns the current size of the growing object, in bytes. + Remember to call ``obstack_object_size`` *before* finishing the object. + After it is finished, ``obstack_object_size`` will return zero. + +If you have started growing an object and wish to cancel it, you should +finish it and then free it, like this: + +.. code-block:: c++ + + obstack_free (obstack_ptr, obstack_finish (obstack_ptr)); + +This has no effect if no object was growing. + +.. index:: efficiency and obstacks + +.. _extra-fast-growing: + +Extra Fast Growing Objects +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The usual macros for growing objects incur overhead for checking +whether there is room for the new growth in the current chunk. If you +are frequently constructing objects in small steps of growth, this +overhead can be significant. + +You can reduce the overhead by using special 'fast growth' +macros that grow the object without checking. In order to have a +robust program, you must do the checking yourself. If you do this checking +in the simplest way each time you are about to add data to the object, you +have not saved anything, because that is what the ordinary growth +macros do. But if you can arrange to check less often, or check +more efficiently, then you make the program faster. + +``obstack_room`` returns the amount of room available +in the current chunk. + +.. function:: size_t obstack_room (struct obstack *obstack_ptr) + + This returns the number of bytes that can be added safely to the current + growing object (or to an object about to be started) in obstack + :samp:`{obstack}` using the fast growth macros. + +While you know there is room, you can use these fast growth macros +for adding data to a growing object: + +.. function:: void obstack_1grow_fast (struct obstack *obstack_ptr, char c) + + ``obstack_1grow_fast`` adds one byte containing the + character :samp:`{c}` to the growing object in obstack :samp:`{obstack_ptr}`. + +.. function:: void obstack_ptr_grow_fast (struct obstack *obstack_ptr, void *data) + + ``obstack_ptr_grow_fast`` adds ``sizeof (void *)`` + bytes containing the value of :samp:`{data}` to the growing object in + obstack :samp:`{obstack_ptr}`. + +.. function:: void obstack_int_grow_fast (struct obstack *obstack_ptr, int data) + + ``obstack_int_grow_fast`` adds ``sizeof (int)`` bytes + containing the value of :samp:`{data}` to the growing object in obstack + :samp:`{obstack_ptr}`. + +.. function:: void obstack_blank_fast (struct obstack *obstack_ptr, size_t size) + + ``obstack_blank_fast`` adds :samp:`{size}` bytes to the + growing object in obstack :samp:`{obstack_ptr}` without initializing them. + +When you check for space using ``obstack_room`` and there is not +enough room for what you want to add, the fast growth macros +are not safe. In this case, simply use the corresponding ordinary +growth macro instead. Very soon this will copy the object to a +new chunk; then there will be lots of room available again. + +So, each time you use an ordinary growth macro, check afterward for +sufficient space using ``obstack_room``. Once the object is copied +to a new chunk, there will be plenty of space again, so the program will +start using the fast growth macros again. + +Here is an example: + +.. code-block:: c++ + + void + add_string (struct obstack *obstack, const char *ptr, size_t len) + { + while (len > 0) + { + size_t room = obstack_room (obstack); + if (room == 0) + { + /* Not enough room. Add one character slowly, + which may copy to a new chunk and make room. */ + obstack_1grow (obstack, *ptr++); + len--; + } + else + { + if (room > len) + room = len; + /* Add fast as much as we have room for. */ + len -= room; + while (room-- > 0) + obstack_1grow_fast (obstack, *ptr++); + } + } + } + +.. index:: shrinking objects + +You can use ``obstack_blank_fast`` with a 'negative' size +argument to make the current object smaller. Just don't try to shrink +it beyond zero length---there's no telling what will happen if you do +that. Earlier versions of obstacks allowed you to use +``obstack_blank`` to shrink objects. This will no longer work. + +.. index:: obstack status, status of obstack + +.. _status-of-an-obstack: + +Status of an Obstack +~~~~~~~~~~~~~~~~~~~~ + +Here are macros that provide information on the current status of +allocation in an obstack. You can use them to learn about an object while +still growing it. + +.. function:: void * obstack_base (struct obstack *obstack_ptr) + + This macro returns the tentative address of the beginning of the + currently growing object in :samp:`{obstack_ptr}`. If you finish the object + immediately, it will have that address. If you make it larger first, it + may outgrow the current chunk---then its address will change! + + If no object is growing, this value says where the next object you + allocate will start (once again assuming it fits in the current + chunk). + +.. function:: void * obstack_next_free (struct obstack *obstack_ptr) + + This macro returns the address of the first free byte in the current + chunk of obstack :samp:`{obstack_ptr}`. This is the end of the currently + growing object. If no object is growing, ``obstack_next_free`` + returns the same value as ``obstack_base``. + +.. function:: size_t obstack_object_size (struct obstack *obstack_ptr) + + This macro returns the size in bytes of the currently growing object. + This is equivalent to + + .. code-block:: c++ + + ((size_t) (obstack_next_free (obstack_ptr) - obstack_base (obstack_ptr))) + +.. index:: alignment (in obstacks) + +.. _obstacks-data-alignment: + +Alignment of Data in Obstacks +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Each obstack has an :dfn:`alignment boundary`; each object allocated in +the obstack automatically starts on an address that is a multiple of the +specified boundary. By default, this boundary is aligned so that +the object can hold any type of data. + +To access an obstack's alignment boundary, use the macro +``obstack_alignment_mask``. + +.. function:: size_t obstack_alignment_mask (struct obstack *obstack_ptr) + + The value is a bit mask; a bit that is 1 indicates that the corresponding + bit in the address of an object should be 0. The mask value should be one + less than a power of 2; the effect is that all object addresses are + multiples of that power of 2. The default value of the mask is a value + that allows aligned objects to hold any type of data: for example, if + its value is 3, any type of data can be stored at locations whose + addresses are multiples of 4. A mask value of 0 means an object can start + on any multiple of 1 (that is, no alignment is required). + + The expansion of the macro ``obstack_alignment_mask`` is an lvalue, + so you can alter the mask by assignment. For example, this statement: + + .. code-block:: c++ + + obstack_alignment_mask (obstack_ptr) = 0; + + has the effect of turning off alignment processing in the specified obstack. + +Note that a change in alignment mask does not take effect until +*after* the next time an object is allocated or finished in the +obstack. If you are not growing an object, you can make the new +alignment mask take effect immediately by calling ``obstack_finish``. +This will finish a zero-length object and then do proper alignment for +the next object. + +.. index:: efficiency of chunks, chunks + +.. _obstack-chunks: + +Obstack Chunks +~~~~~~~~~~~~~~ + +Obstacks work by allocating space for themselves in large chunks, and +then parceling out space in the chunks to satisfy your requests. Chunks +are normally 4096 bytes long unless you specify a different chunk size. +The chunk size includes 8 bytes of overhead that are not actually used +for storing objects. Regardless of the specified size, longer chunks +will be allocated when necessary for long objects. + +The obstack library allocates chunks by calling the function +``obstack_chunk_alloc``, which you must define. When a chunk is no +longer needed because you have freed all the objects in it, the obstack +library frees the chunk by calling ``obstack_chunk_free``, which you +must also define. + +These two must be defined (as macros) or declared (as functions) in each +source file that uses ``obstack_init`` (see :ref:`creating-obstacks`). +Most often they are defined as macros like this: + +.. code-block:: c++ + + #define obstack_chunk_alloc malloc + #define obstack_chunk_free free + +Note that these are simple macros (no arguments). Macro definitions with +arguments will not work! It is necessary that ``obstack_chunk_alloc`` +or ``obstack_chunk_free``, alone, expand into a function name if it is +not itself a function name. + +If you allocate chunks with ``malloc``, the chunk size should be a +power of 2. The default chunk size, 4096, was chosen because it is long +enough to satisfy many typical requests on the obstack yet short enough +not to waste too much memory in the portion of the last chunk not yet used. + +.. function:: size_t obstack_chunk_size (struct obstack *obstack_ptr) + + This returns the chunk size of the given obstack. + +Since this macro expands to an lvalue, you can specify a new chunk size by +assigning it a new value. Doing so does not affect the chunks already +allocated, but will change the size of chunks allocated for that particular +obstack in the future. It is unlikely to be useful to make the chunk size +smaller, but making it larger might improve efficiency if you are +allocating many objects whose size is comparable to the chunk size. Here +is how to do so cleanly: + +.. code-block:: c++ + + if (obstack_chunk_size (obstack_ptr) < new-chunk-size) + obstack_chunk_size (obstack_ptr) = new-chunk-size; + +.. _summary-of-obstacks: + +Summary of Obstack Macros +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is a summary of all the macros associated with obstacks. Each +takes the address of an obstack (``struct obstack *``) as its first +argument. + +.. function:: int obstack_init (struct obstack *obstack_ptr) + + Initialize use of an obstack. See :ref:`creating-obstacks`. + +.. function:: int obstack_begin (struct obstack *obstack_ptr, size_t chunk_size) + + Initialize use of an obstack, with an initial chunk of + :samp:`{chunk_size}` bytes. + +.. function:: int obstack_specify_allocation (struct obstack *obstack_ptr, size_t chunk_size, size_t alignment, void *(*chunkfun) (size_t), void (*freefun) (void *)) + + Initialize use of an obstack, specifying intial chunk size, chunk + alignment, and memory allocation functions. + +.. function:: int obstack_specify_allocation_with_arg (struct obstack *obstack_ptr, size_t chunk_size, size_t alignment, void *(*chunkfun) (void *, size_t), void (*freefun) (void *, void *), void *arg) + + Like ``obstack_specify_allocation``, but specifying memory + allocation functions that take an extra first argument, :samp:`{arg}`. + +.. function:: void *obstack_alloc (struct obstack *obstack_ptr, size_t size) + + Allocate an object of :samp:`{size}` uninitialized bytes. + See :ref:`allocation-in-an-obstack`. + +.. function:: void *obstack_copy (struct obstack *obstack_ptr, void *address, size_t size) + + Allocate an object of :samp:`{size}` bytes, with contents copied from + :samp:`{address}`. See :ref:`allocation-in-an-obstack`. + +.. function:: void *obstack_copy0 (struct obstack *obstack_ptr, void *address, size_t size) + + Allocate an object of :samp:`{size}` +1 bytes, with :samp:`{size}` of them copied + from :samp:`{address}`, followed by a null character at the end. + See :ref:`allocation-in-an-obstack`. + +.. function:: void obstack_free (struct obstack *obstack_ptr, void *object) + + Free :samp:`{object}` (and everything allocated in the specified obstack + more recently than :samp:`{object}`). See :ref:`freeing-obstack-objects`. + +.. function:: void obstack_blank (struct obstack *obstack_ptr, size_t size) + + Add :samp:`{size}` uninitialized bytes to a growing object. + See :ref:`growing-objects`. + +.. function:: void obstack_grow (struct obstack *obstack_ptr, void *address, size_t size) + + Add :samp:`{size}` bytes, copied from :samp:`{address}`, to a growing object. + See :ref:`growing-objects`. + +.. function:: void obstack_grow0 (struct obstack *obstack_ptr, void *address, size_t size) + + Add :samp:`{size}` bytes, copied from :samp:`{address}`, to a growing object, + and then add another byte containing a null character. See :ref:`growing-objects`. + +.. function:: void obstack_1grow (struct obstack *obstack_ptr, char data_char) + + Add one byte containing :samp:`{data-char}` to a growing object. + See :ref:`growing-objects`. + +.. function:: void *obstack_finish (struct obstack *obstack_ptr) + + Finalize the object that is growing and return its permanent address. + See :ref:`growing-objects`. + +.. function:: size_t obstack_object_size (struct obstack *obstack_ptr) + + Get the current size of the currently growing object. See :ref:`growing-objects`. + +.. function:: void obstack_blank_fast (struct obstack *obstack_ptr, size_t size) + + Add :samp:`{size}` uninitialized bytes to a growing object without checking + that there is enough room. See :ref:`extra-fast-growing`. + +.. function:: void obstack_1grow_fast (struct obstack *obstack_ptr, char data_char) + + Add one byte containing :samp:`{data-char}` to a growing object without + checking that there is enough room. See :ref:`extra-fast-growing`. + +.. function:: size_t obstack_room (struct obstack *obstack_ptr) + + Get the amount of room now available for growing the current object. + See :ref:`extra-fast-growing`. + +.. function:: size_t obstack_alignment_mask (struct obstack *obstack_ptr) + + The mask used for aligning the beginning of an object. This is an + lvalue. See :ref:`obstacks-data-alignment`. + +.. function:: size_t obstack_chunk_size (struct obstack *obstack_ptr) + + The size for allocating chunks. This is an lvalue. See :ref:`obstack-chunks`. + +.. function:: void *obstack_base (struct obstack *obstack_ptr) + + Tentative starting address of the currently growing object. + See :ref:`status-of-an-obstack`. + +.. function:: void *obstack_next_free (struct obstack *obstack_ptr) + + Address just after the end of the currently growing object. + See :ref:`status-of-an-obstack`. \ No newline at end of file diff --git a/libiberty/doc/function-variable-and-macro-listing.rst b/libiberty/doc/function-variable-and-macro-listing.rst new file mode 100644 index 00000000000..244ec9eeee5 --- /dev/null +++ b/libiberty/doc/function-variable-and-macro-listing.rst @@ -0,0 +1,1857 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _functions: + +Function, Variable, and Macro Listing. +-------------------------------------- + +.. Automatically generated from *.c and others (the comments before + each entry tell you which file and where in that file). DO NOT EDIT! + Edit the *.c files, configure with -enable-maintainer-mode, + run 'make stamp-functions' and gather-docs will build a new copy. + alloca.c:26 + +.. function:: void* alloca (size_t size) + + This function allocates memory which will be automatically reclaimed + after the procedure exits. The ``libiberty`` implementation does not free + the memory immediately but will do so eventually during subsequent + calls to this function. Memory is allocated using ``xmalloc`` under + normal circumstances. + + The header file :samp:`alloca-conf.h` can be used in conjunction with the + GNU Autoconf test ``AC_FUNC_ALLOCA`` to test for and properly make + available this function. The ``AC_FUNC_ALLOCA`` test requires that + client code use a block of preprocessor code to be safe (see the Autoconf + manual for more); this header incorporates that logic and more, including + the possibility of a GCC built-in function. + +.. asprintf.c:32 + +.. function:: int asprintf (char **resptr, const char *format, ...) + + Like ``sprintf``, but instead of passing a pointer to a buffer, you + pass a pointer to a pointer. This function will compute the size of + the buffer needed, allocate memory with ``malloc``, and store a + pointer to the allocated memory in ``*resptr``. The value + returned is the same as ``sprintf`` would return. If memory could + not be allocated, minus one is returned and ``NULL`` is stored in + ``*resptr``. + +.. atexit.c:6 + +.. function:: int atexit (void (*f)()) + + Causes function :samp:`{f}` to be called at exit. Returns 0. + +.. basename.c:6 + +.. function:: char* basename (const char *name) + + Returns a pointer to the last component of pathname :samp:`{name}`. + Behavior is undefined if the pathname ends in a directory separator. + +.. bcmp.c:6 + +.. function:: int bcmp (char *x, char *y, int count) + + Compares the first :samp:`{count}` bytes of two areas of memory. Returns + zero if they are the same, nonzero otherwise. Returns zero if + :samp:`{count}` is zero. A nonzero result only indicates a difference, + it does not indicate any sorting order (say, by having a positive + result mean :samp:`{x}` sorts before :samp:`{y}`). + +.. bcopy.c:3 + +.. function:: void bcopy (char *in, char *out, int length) + + Copies :samp:`{length}` bytes from memory region :samp:`{in}` to region + :samp:`{out}`. The use of ``bcopy`` is deprecated in new programs. + +.. bsearch.c:33 + +.. function:: void* bsearch (const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) + + Performs a search over an array of :samp:`{nmemb}` elements pointed to by + :samp:`{base}` for a member that matches the object pointed to by :samp:`{key}`. + The size of each member is specified by :samp:`{size}`. The array contents + should be sorted in ascending order according to the :samp:`{compar}` + comparison function. This routine should take two arguments pointing to + the :samp:`{key}` and to an array member, in that order, and should return an + integer less than, equal to, or greater than zero if the :samp:`{key}` object + is respectively less than, matching, or greater than the array member. + +.. bsearch_r.c:33 + +.. function:: void* bsearch_r (const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg) + + Performs a search over an array of :samp:`{nmemb}` elements pointed to by + :samp:`{base}` for a member that matches the object pointed to by :samp:`{key}`. + The size of each member is specified by :samp:`{size}`. The array contents + should be sorted in ascending order according to the :samp:`{compar}` + comparison function. This routine should take three arguments: the first + two point to the :samp:`{key}` and to an array member, and the last is passed + down unchanged from ``bsearch_r`` 's last argument. It should return an + integer less than, equal to, or greater than zero if the :samp:`{key}` object + is respectively less than, matching, or greater than the array member. + +.. argv.c:138 + +.. function:: char** buildargv (char *sp) + + Given a pointer to a string, parse the string extracting fields + separated by whitespace and optionally enclosed within either single + or double quotes (which are stripped off), and build a vector of + pointers to copies of the string for each field. The input string + remains unchanged. The last element of the vector is followed by a + ``NULL`` element. + + All of the memory for the pointer array and copies of the string + is obtained from ``xmalloc``. All of the memory can be returned to the + system with the single function call ``freeargv``, which takes the + returned result of ``buildargv``, as it's argument. + + Returns a pointer to the argument vector if successful. Returns + ``NULL`` if :samp:`{sp}` is ``NULL`` or if there is insufficient + memory to complete building the argument vector. + + If the input is a null string (as opposed to a ``NULL`` pointer), + then buildarg returns an argument vector that has one arg, a null + string. + +.. bzero.c:6 + +.. function:: void bzero (char *mem, int count) + + Zeros :samp:`{count}` bytes starting at :samp:`{mem}`. Use of this function + is deprecated in favor of ``memset``. + +.. calloc.c:6 + +.. function:: void* calloc (size_t nelem, size_t elsize) + + Uses ``malloc`` to allocate storage for :samp:`{nelem}` objects of + :samp:`{elsize}` bytes each, then zeros the memory. + +.. filename_cmp.c:201 + +.. function:: int canonical_filename_eq (const char *a, const char *b) + + Return non-zero if file names :samp:`{a}` and :samp:`{b}` are equivalent. + This function compares the canonical versions of the filenames as returned by + ``lrealpath()``, so that so that different file names pointing to the same + underlying file are treated as being identical. + +.. choose-temp.c:45 + +.. function:: char* choose_temp_base (void) + + Return a prefix for temporary file names or ``NULL`` if unable to + find one. The current directory is chosen if all else fails so the + program is exited if a temporary directory can't be found (``mktemp`` + fails). The buffer for the result is obtained with ``xmalloc``. + + This function is provided for backwards compatibility only. Its use is + not recommended. + +.. make-temp-file.c:95 + +.. function:: const char* choose_tmpdir () + + Returns a pointer to a directory path suitable for creating temporary + files in. + +.. clock.c:27 + +.. function:: long clock (void) + + Returns an approximation of the CPU time used by the process as a + ``clock_t`` ; divide this number by :samp:`CLOCKS_PER_SEC` to get the + number of seconds used. + +.. concat.c:24 + +.. function:: char* concat (const char *s1, const char *s2, ..., NULL) + + Concatenate zero or more of strings and return the result in freshly + ``xmalloc`` ed memory. The argument list is terminated by the first + ``NULL`` pointer encountered. Pointers to empty strings are ignored. + +.. argv.c:495 + +.. function:: int countargv (char * const *argv) + + Return the number of elements in :samp:`{argv}`. + Returns zero if :samp:`{argv}` is NULL. + +.. crc32.c:140 + +.. function:: unsigned int crc32 (const unsigned char *buf, int len, unsigned int init) + + Compute the 32-bit CRC of :samp:`{buf}` which has length :samp:`{len}`. The + starting value is :samp:`{init}` ; this may be used to compute the CRC of + data split across multiple buffers by passing the return value of each + call as the :samp:`{init}` parameter of the next. + + This is used by the :command:`gdb` remote protocol for the :samp:`qCRC` + command. In order to get the same results as gdb for a block of data, + you must pass the first CRC parameter as ``0xffffffff``. + + This CRC can be specified as: + + Width : 32 + Poly : 0x04c11db7 + Init : parameter, typically 0xffffffff + RefIn : false + RefOut : false + XorOut : 0 + + This differs from the "standard" CRC-32 algorithm in that the values + are not reflected, and there is no final XOR value. These differences + make it easy to compose the values of multiple blocks. + +.. argv.c:59 + +.. function:: char** dupargv (char * const *vector) + + Duplicate an argument vector. Simply scans through :samp:`{vector}`, + duplicating each argument until the terminating ``NULL`` is found. + Returns a pointer to the argument vector if successful. Returns + ``NULL`` if there is insufficient memory to complete building the + argument vector. + +.. strerror.c:572 + +.. function:: int errno_max (void) + + Returns the maximum ``errno`` value for which a corresponding + symbolic name or message is available. Note that in the case where we + use the ``sys_errlist`` supplied by the system, it is possible for + there to be more symbolic names than messages, or vice versa. In + fact, the manual page for ``perror(3C)`` explicitly warns that one + should check the size of the table (``sys_nerr``) before indexing + it, since new error codes may be added to the system before they are + added to the table. Thus ``sys_nerr`` might be smaller than value + implied by the largest ``errno`` value defined in ````. + + We return the maximum value that can be used to obtain a meaningful + symbolic name or message. + +.. argv.c:352 + +.. function:: void expandargv (int *argcp, char ***argvp) + + The :samp:`{argcp}` and ``argvp`` arguments are pointers to the usual + ``argc`` and ``argv`` arguments to ``main``. This function + looks for arguments that begin with the character :samp:`@`. Any such + arguments are interpreted as 'response files'. The contents of the + response file are interpreted as additional command line options. In + particular, the file is separated into whitespace-separated strings; + each such string is taken as a command-line option. The new options + are inserted in place of the option naming the response file, and + ``*argcp`` and ``*argvp`` will be updated. If the value of + ``*argvp`` is modified by this function, then the new value has + been dynamically allocated and can be deallocated by the caller with + ``freeargv``. However, most callers will simply call + ``expandargv`` near the beginning of ``main`` and allow the + operating system to free the memory when the program exits. + +.. fdmatch.c:23 + +.. function:: int fdmatch (int fd1, int fd2) + + Check to see if two open file descriptors refer to the same file. + This is useful, for example, when we have an open file descriptor for + an unnamed file, and the name of a file that we believe to correspond + to that fd. This can happen when we are exec'd with an already open + file (``stdout`` for example) or from the SVR4 :samp:`/proc` calls + that return open file descriptors for mapped address spaces. All we + have to do is open the file by name and check the two file descriptors + for a match, which is done by comparing major and minor device numbers + and inode numbers. + +.. fopen_unlocked.c:49 + +.. function:: FILE * fdopen_unlocked (int fildes, const char * mode) + + Opens and returns a ``FILE`` pointer via ``fdopen``. If the + operating system supports it, ensure that the stream is setup to avoid + any multi-threaded locking. Otherwise return the ``FILE`` pointer + unchanged. + +.. ffs.c:3 + +.. function:: int ffs (int valu) + + Find the first (least significant) bit set in :samp:`{valu}`. Bits are + numbered from right to left, starting with bit 1 (corresponding to the + value 1). If :samp:`{valu}` is zero, zero is returned. + +.. filename_cmp.c:37 + +.. function:: int filename_cmp (const char *s1, const char *s2) + + Return zero if the two file names :samp:`{s1}` and :samp:`{s2}` are equivalent. + If not equivalent, the returned value is similar to what ``strcmp`` + would return. In other words, it returns a negative value if :samp:`{s1}` + is less than :samp:`{s2}`, or a positive value if :samp:`{s2}` is greater than + :samp:`{s2}`. + + This function does not normalize file names. As a result, this function + will treat filenames that are spelled differently as different even in + the case when the two filenames point to the same underlying file. + However, it does handle the fact that on DOS-like file systems, forward + and backward slashes are equal. + +.. filename_cmp.c:183 + +.. function:: int filename_eq (const void *s1, const void *s2) + + Return non-zero if file names :samp:`{s1}` and :samp:`{s2}` are equivalent. + This function is for use with hashtab.c hash tables. + +.. filename_cmp.c:152 + +.. function:: hashval_t filename_hash (const void *s) + + Return the hash value for file name :samp:`{s}` that will be compared + using filename_cmp. + This function is for use with hashtab.c hash tables. + +.. filename_cmp.c:94 + +.. function:: int filename_ncmp (const char *s1, const char *s2, size_t n) + + Return zero if the two file names :samp:`{s1}` and :samp:`{s2}` are equivalent + in range :samp:`{n}`. + If not equivalent, the returned value is similar to what ``strncmp`` + would return. In other words, it returns a negative value if :samp:`{s1}` + is less than :samp:`{s2}`, or a positive value if :samp:`{s2}` is greater than + :samp:`{s2}`. + + This function does not normalize file names. As a result, this function + will treat filenames that are spelled differently as different even in + the case when the two filenames point to the same underlying file. + However, it does handle the fact that on DOS-like file systems, forward + and backward slashes are equal. + +.. fnmatch.txh:1 + +.. function:: int fnmatch (const char *pattern, const char *string, int flags) + + Matches :samp:`{string}` against :samp:`{pattern}`, returning zero if it + matches, ``FNM_NOMATCH`` if not. :samp:`{pattern}` may contain the + wildcards ``?`` to match any one character, ``*`` to match any + zero or more characters, or a set of alternate characters in square + brackets, like :samp:`[a-gt8]`, which match one character (``a`` + through ``g``, or ``t``, or ``8``, in this example) if that one + character is in the set. A set may be inverted (i.e., match anything + except what's in the set) by giving ``^`` or ``!`` as the first + character in the set. To include those characters in the set, list them + as anything other than the first character of the set. To include a + dash in the set, list it last in the set. A backslash character makes + the following character not special, so for example you could match + against a literal asterisk with :samp:`\\*`. To match a literal + backslash, use :samp:`\\\\`. + + ``flags`` controls various aspects of the matching process, and is a + boolean OR of zero or more of the following values (defined in + ````): + + .. envvar:: FNM_PATHNAME + + :samp:`{string}` is assumed to be a path name. No wildcard will ever match + ``/``. + + .. envvar:: FNM_NOESCAPE + + Do not interpret backslashes as quoting the following special character. + + .. envvar:: FNM_PERIOD + + A leading period (at the beginning of :samp:`{string}`, or if + ``FNM_PATHNAME`` after a slash) is not matched by ``*`` or + ``?`` but must be matched explicitly. + + .. envvar:: FNM_LEADING_DIR + + Means that :samp:`{string}` also matches :samp:`{pattern}` if some initial part + of :samp:`{string}` matches, and is followed by ``/`` and zero or more + characters. For example, :samp:`foo*` would match either :samp:`foobar` + or :samp:`foobar/grill`. + + .. envvar:: FNM_CASEFOLD + + Ignores case when performing the comparison. + +.. fopen_unlocked.c:39 + +.. function:: FILE * fopen_unlocked (const char *path, const char * mode) + + Opens and returns a ``FILE`` pointer via ``fopen``. If the + operating system supports it, ensure that the stream is setup to avoid + any multi-threaded locking. Otherwise return the ``FILE`` pointer + unchanged. + +.. argv.c:93 + +.. function:: void freeargv (char **vector) + + Free an argument vector that was built using ``buildargv``. Simply + scans through :samp:`{vector}`, freeing the memory for each argument until + the terminating ``NULL`` is found, and then frees :samp:`{vector}` + itself. + +.. fopen_unlocked.c:59 + +.. function:: FILE * freopen_unlocked (const char * path, const char * mode, FILE * stream) + + Opens and returns a ``FILE`` pointer via ``freopen``. If the + operating system supports it, ensure that the stream is setup to avoid + any multi-threaded locking. Otherwise return the ``FILE`` pointer + unchanged. + +.. getruntime.c:86 + +.. function:: long get_run_time (void) + + Returns the time used so far, in microseconds. If possible, this is + the time used by this process, else it is the elapsed time since the + process started. + +.. getcwd.c:6 + +.. function:: char* getcwd (char *pathname, int len) + + Copy the absolute pathname for the current working directory into + :samp:`{pathname}`, which is assumed to point to a buffer of at least + :samp:`{len}` bytes, and return a pointer to the buffer. If the current + directory's path doesn't fit in :samp:`{len}` characters, the result is + ``NULL`` and ``errno`` is set. If :samp:`{pathname}` is a null pointer, + ``getcwd`` will obtain :samp:`{len}` bytes of space using + ``malloc``. + +.. getpagesize.c:5 + +.. function:: int getpagesize (void) + + Returns the number of bytes in a page of memory. This is the + granularity of many of the system memory management routines. No + guarantee is made as to whether or not it is the same as the basic + memory management hardware page size. + +.. getpwd.c:5 + +.. function:: char* getpwd (void) + + Returns the current working directory. This implementation caches the + result on the assumption that the process will not call ``chdir`` + between calls to ``getpwd``. + +.. gettimeofday.c:12 + +.. function:: int gettimeofday (struct timeval *tp, void *tz) + + Writes the current time to :samp:`{tp}`. This implementation requires + that :samp:`{tz}` be NULL. Returns 0 on success, -1 on failure. + +.. hex.c:33 + +.. function:: void hex_init (void) + + Initializes the array mapping the current character set to + corresponding hex values. This function must be called before any + call to ``hex_p`` or ``hex_value``. If you fail to call it, a + default ASCII-based table will normally be used on ASCII systems. + +.. hex.c:42 + +.. function:: int hex_p (int c) + + Evaluates to non-zero if the given character is a valid hex character, + or zero if it is not. Note that the value you pass will be cast to + ``unsigned char`` within the macro. + +.. hex.c:50 + +.. function:: unsigned int hex_value (int c) + + Returns the numeric equivalent of the given character when interpreted + as a hexadecimal digit. The result is undefined if you pass an + invalid hex digit. Note that the value you pass will be cast to + ``unsigned char`` within the macro. + + The ``hex_value`` macro returns ``unsigned int``, rather than + signed ``int``, to make it easier to use in parsing addresses from + hex dump files: a signed ``int`` would be sign-extended when + converted to a wider unsigned type --- like ``bfd_vma``, on some + systems. + +.. safe-ctype.c:24 + +.. index:: HOST_CHARSET + +.. c:macro:: HOST_CHARSET + + This macro indicates the basic character set and encoding used by the + host: more precisely, the encoding used for character constants in + preprocessor :samp:`#if` statements (the C "execution character set"). + It is defined by :samp:`safe-ctype.h`, and will be an integer constant + with one of the following values: + +.. envvar:: HOST_CHARSET_UNKNOWN + + The host character set is unknown - that is, not one of the next two + possibilities. + +.. envvar:: HOST_CHARSET_ASCII + + The host character set is ASCII. + +.. envvar:: HOST_CHARSET_EBCDIC + + The host character set is some variant of EBCDIC. (Only one of the + nineteen EBCDIC varying characters is tested; exercise caution.) + +.. hashtab.c:327 + +.. function:: htab_t htab_create_typed_alloc (size_t size, htab_hash hash_f, htab_eq eq_f, htab_del del_f, htab_alloc alloc_tab_f, htab_alloc alloc_f, htab_free free_f) + + This function creates a hash table that uses two different allocators + :samp:`{alloc_tab_f}` and :samp:`{alloc_f}` to use for allocating the table itself + and its entries respectively. This is useful when variables of different + types need to be allocated with different allocators. + + The created hash table is slightly larger than :samp:`{size}` and it is + initially empty (all the hash table entries are ``HTAB_EMPTY_ENTRY``). + The function returns the created hash table, or ``NULL`` if memory + allocation fails. + +.. index.c:5 + +.. function:: char* index (char *s, int c) + + Returns a pointer to the first occurrence of the character :samp:`{c}` in + the string :samp:`{s}`, or ``NULL`` if not found. The use of ``index`` is + deprecated in new programs in favor of ``strchr``. + +.. insque.c:6 + +.. function:: void insque (struct qelem *elem, struct qelem *pred) + void remque (struct qelem *elem) + + Routines to manipulate queues built from doubly linked lists. The + ``insque`` routine inserts :samp:`{elem}` in the queue immediately + after :samp:`{pred}`. The ``remque`` routine removes :samp:`{elem}` from + its containing queue. These routines expect to be passed pointers to + structures which have as their first members a forward pointer and a + back pointer, like this prototype (although no prototype is provided): + + .. code-block:: c++ + + struct qelem { + struct qelem *q_forw; + struct qelem *q_back; + char q_data[]; + }; + +.. safe-ctype.c:45 + +.. c:macro:: ISALPHA (c) + ISALNUM (c) + ISBLANK (c) + ISCNTRL (c) + ISDIGIT (c) + ISGRAPH (c) + ISLOWER (c) + ISPRINT (c) + ISPUNCT (c) + ISSPACE (c) + ISUPPER (c) + ISXDIGIT (c) + +These twelve macros are defined by :samp:`safe-ctype.h`. Each has the +same meaning as the corresponding macro (with name in lowercase) +defined by the standard header :samp:`ctype.h`. For example, +``ISALPHA`` returns true for alphabetic characters and false for +others. However, there are two differences between these macros and +those provided by :samp:`ctype.h`: + +* These macros are guaranteed to have well-defined behavior for all + values representable by ``signed char`` and ``unsigned char``, and + for ``EOF``. + +* These macros ignore the current locale; they are true for these + fixed sets of characters: + + .. list-table:: + + * - ``ALPHA`` + - A-Za-z + * - ``ALNUM`` + - A-Za-z0-9 + * - ``BLANK`` + - space tab + * - ``CNTRL`` + - ``!PRINT`` + * - ``DIGIT`` + - 0-9 + * - ``GRAPH`` + - ``ALNUM || PUNCT`` + * - ``LOWER`` + - a-z + * - ``PRINT`` + - ``GRAPH ||`` space + * - ``PUNCT`` + - `~!@#$%^&\*()_-=+[{]}\|;:'",<.>/? + * - ``SPACE`` + - space tab \n \r \f \v + * - ``UPPER`` + - A-Z + * - ``XDIGIT`` + - 0-9A-Fa-f + + Note that, if the host character set is ASCII or a superset thereof, + all these macros will return false for all values of ``char`` outside + the range of 7-bit ASCII. In particular, both ISPRINT and ISCNTRL return + false for characters with numeric values from 128 to 255. + +.. safe-ctype.c:94 + +.. c:macro:: ISIDNUM (c) + ISIDST (c) + IS_VSPACE (c) + IS_NVSPACE (c) + IS_SPACE_OR_NUL (c) + IS_ISOBASIC (c) + +These six macros are defined by safe-ctype.h and provide +additional character classes which are useful when doing lexical +analysis of C or similar languages. They are true for the following +sets of characters: + +.. list-table:: + + * - ``IDNUM`` + - A-Za-z0-9\_ + * - ``IDST`` + - A-Za-z\_ + * - ``VSPACE`` + - \r \n + * - ``NVSPACE`` + - space tab \f \v \0 + * - ``SPACE_OR_NUL`` + - ``VSPACE || NVSPACE`` + * - ``ISOBASIC`` + - ``VSPACE || NVSPACE || PRINT`` + +.. lbasename.c:23 + +.. function:: const char* lbasename (const char *name) + + Given a pointer to a string containing a typical pathname + (:samp:`/usr/src/cmd/ls/ls.c` for example), returns a pointer to the + last component of the pathname (:samp:`ls.c` in this case). The + returned pointer is guaranteed to lie within the original + string. This latter fact is not true of many vendor C + libraries, which return special strings or modify the passed + strings for particular input. + + In particular, the empty string returns the same empty string, + and a path ending in ``/`` returns the empty string after it. + +.. lrealpath.c:25 + +.. function:: const char* lrealpath (const char *name) + + Given a pointer to a string containing a pathname, returns a canonical + version of the filename. Symlinks will be resolved, and '.' and '..' + components will be simplified. The returned value will be allocated using + ``malloc``, or ``NULL`` will be returned on a memory allocation error. + +.. make-relative-prefix.c:23 + +.. function:: const char* make_relative_prefix (const char *progname, const char *bin_prefix, const char *prefix) + + Given three paths :samp:`{progname}`, :samp:`{bin_prefix}`, :samp:`{prefix}`, + return the path that is in the same position relative to + :samp:`{progname}` 's directory as :samp:`{prefix}` is relative to + :samp:`{bin_prefix}`. That is, a string starting with the directory + portion of :samp:`{progname}`, followed by a relative pathname of the + difference between :samp:`{bin_prefix}` and :samp:`{prefix}`. + + If :samp:`{progname}` does not contain any directory separators, + ``make_relative_prefix`` will search :envvar:`PATH` to find a program + named :samp:`{progname}`. Also, if :samp:`{progname}` is a symbolic link, + the symbolic link will be resolved. + + For example, if :samp:`{bin_prefix}` is ``/alpha/beta/gamma/gcc/delta``, + :samp:`{prefix}` is ``/alpha/beta/gamma/omega/``, and :samp:`{progname}` is + ``/red/green/blue/gcc``, then this function will return + ``/red/green/blue/../../omega/``. + + The return value is normally allocated via ``malloc``. If no + relative prefix can be found, return ``NULL``. + +.. make-temp-file.c:173 + +.. function:: char* make_temp_file (const char *suffix) + + Return a temporary file name (as a string) or ``NULL`` if unable to + create one. :samp:`{suffix}` is a suffix to append to the file name. The + string is ``malloc`` ed, and the temporary file has been created. + +.. memchr.c:3 + +.. function:: void* memchr (const void *s, int c, size_t n) + + This function searches memory starting at ``*s`` for the + character :samp:`{c}`. The search only ends with the first occurrence of + :samp:`{c}`, or after :samp:`{length}` characters; in particular, a null + character does not terminate the search. If the character :samp:`{c}` is + found within :samp:`{length}` characters of ``*s``, a pointer + to the character is returned. If :samp:`{c}` is not found, then ``NULL`` is + returned. + +.. memcmp.c:6 + +.. function:: int memcmp (const void *x, const void *y, size_t count) + + Compares the first :samp:`{count}` bytes of two areas of memory. Returns + zero if they are the same, a value less than zero if :samp:`{x}` is + lexically less than :samp:`{y}`, or a value greater than zero if :samp:`{x}` + is lexically greater than :samp:`{y}`. Note that lexical order is determined + as if comparing unsigned char arrays. + +.. memcpy.c:6 + +.. function:: void* memcpy (void *out, const void *in, size_t length) + + Copies :samp:`{length}` bytes from memory region :samp:`{in}` to region + :samp:`{out}`. Returns a pointer to :samp:`{out}`. + +.. memmem.c:20 + +.. function:: void* memmem (const void *haystack,size_t haystack_len, const void *needle, size_t needle_len) + + Returns a pointer to the first occurrence of :samp:`{needle}` (length + :samp:`{needle_len}`) in :samp:`{haystack}` (length :samp:`{haystack_len}`). + Returns ``NULL`` if not found. + +.. memmove.c:6 + +.. function:: void* memmove (void *from, const void *to, size_t count) + + Copies :samp:`{count}` bytes from memory area :samp:`{from}` to memory area + :samp:`{to}`, returning a pointer to :samp:`{to}`. + +.. mempcpy.c:23 + +.. function:: void* mempcpy (void *out, const void *in, size_t length) + + Copies :samp:`{length}` bytes from memory region :samp:`{in}` to region + :samp:`{out}`. Returns a pointer to :samp:`{out}` + :samp:`{length}`. + +.. memset.c:6 + +.. function:: void* memset (void *s, int c, size_t count) + + Sets the first :samp:`{count}` bytes of :samp:`{s}` to the constant byte + :samp:`{c}`, returning a pointer to :samp:`{s}`. + +.. mkstemps.c:60 + +.. function:: int mkstemps (char *pattern, int suffix_len) + + Generate a unique temporary file name from :samp:`{pattern}`. + :samp:`{pattern}` has the form: + + .. code-block:: c++ + + path/ccXXXXXXsuffix + + :samp:`{suffix_len}` tells us how long :samp:`{suffix}` is (it can be zero + length). The last six characters of :samp:`{pattern}` before :samp:`{suffix}` + must be :samp:`XXXXXX`; they are replaced with a string that makes the + filename unique. Returns a file descriptor open on the file for + reading and writing. + +.. pexecute.txh:278 + +.. function:: void pex_free (struct pex_obj obj) + + Clean up and free all data associated with :samp:`{obj}`. If you have not + yet called ``pex_get_times`` or ``pex_get_status``, this will + try to kill the subprocesses. + +.. pexecute.txh:251 + +.. function:: int pex_get_status (struct pex_obj *obj, int count, int *vector) + + Returns the exit status of all programs run using :samp:`{obj}`. + :samp:`{count}` is the number of results expected. The results will be + placed into :samp:`{vector}`. The results are in the order of the calls + to ``pex_run``. Returns 0 on error, 1 on success. + +.. pexecute.txh:261 + +.. function:: int pex_get_times (struct pex_obj *obj, int count, struct pex_time *vector) + + Returns the process execution times of all programs run using + :samp:`{obj}`. :samp:`{count}` is the number of results expected. The + results will be placed into :samp:`{vector}`. The results are in the + order of the calls to ``pex_run``. Returns 0 on error, 1 on + success. + + ``struct pex_time`` has the following fields of the type + ``unsigned long`` : ``user_seconds``, + ``user_microseconds``, ``system_seconds``, + ``system_microseconds``. On systems which do not support reporting + process times, all the fields will be set to ``0``. + +.. pexecute.txh:2 + +.. function:: struct pex_obj * pex_init (int flags, const char *pname, const char *tempbase) + + Prepare to execute one or more programs, with standard output of each + program fed to standard input of the next. This is a system + independent interface to execute a pipeline. + + :samp:`{flags}` is a bitwise combination of the following: + + .. index:: PEX_RECORD_TIMES + + .. envvar:: PEX_RECORD_TIMES + + Record subprocess times if possible. + + .. index:: PEX_USE_PIPES + + .. envvar:: PEX_USE_PIPES + + Use pipes for communication between processes, if possible. + + .. index:: PEX_SAVE_TEMPS + + .. envvar:: PEX_SAVE_TEMPS + + Don't delete temporary files used for communication between + processes. + + :samp:`{pname}` is the name of program to be executed, used in error + messages. :samp:`{tempbase}` is a base name to use for any required + temporary files; it may be ``NULL`` to use a randomly chosen name. + +.. pexecute.txh:161 + +.. function:: FILE * pex_input_file (struct pex_obj *obj, int flags, const char *in_name) + + Return a stream for a temporary file to pass to the first program in + the pipeline as input. + + The name of the input file is chosen according to the same rules + ``pex_run`` uses to choose output file names, based on + :samp:`{in_name}`, :samp:`{obj}` and the ``PEX_SUFFIX`` bit in :samp:`{flags}`. + + Don't call ``fclose`` on the returned stream; the first call to + ``pex_run`` closes it automatically. + + If :samp:`{flags}` includes ``PEX_BINARY_OUTPUT``, open the stream in + binary mode; otherwise, open it in the default mode. Including + ``PEX_BINARY_OUTPUT`` in :samp:`{flags}` has no effect on Unix. + +.. pexecute.txh:179 + +.. function:: FILE * pex_input_pipe (struct pex_obj *obj, int binary) + + Return a stream :samp:`{fp}` for a pipe connected to the standard input of + the first program in the pipeline; :samp:`{fp}` is opened for writing. + You must have passed ``PEX_USE_PIPES`` to the ``pex_init`` call + that returned :samp:`{obj}`. + + You must close :samp:`{fp}` using ``fclose`` yourself when you have + finished writing data to the pipeline. + + The file descriptor underlying :samp:`{fp}` is marked not to be inherited + by child processes. + + On systems that do not support pipes, this function returns + ``NULL``, and sets ``errno`` to ``EINVAL``. If you would + like to write code that is portable to all systems the ``pex`` + functions support, consider using ``pex_input_file`` instead. + + There are two opportunities for deadlock using + ``pex_input_pipe`` : + + * Most systems' pipes can buffer only a fixed amount of data; a process + that writes to a full pipe blocks. Thus, if you write to :samp:`fp` + before starting the first process, you run the risk of blocking when + there is no child process yet to read the data and allow you to + continue. ``pex_input_pipe`` makes no promises about the + size of the pipe's buffer, so if you need to write any data at all + before starting the first process in the pipeline, consider using + ``pex_input_file`` instead. + + * Using ``pex_input_pipe`` and ``pex_read_output`` together + may also cause deadlock. If the output pipe fills up, so that each + program in the pipeline is waiting for the next to read more data, and + you fill the input pipe by writing more data to :samp:`{fp}`, then there + is no way to make progress: the only process that could read data from + the output pipe is you, but you are blocked on the input pipe. + +.. pexecute.txh:286 + +.. function:: const char * pex_one (int flags, const char *executable, char * const *argv, const char *pname, const char *outname, const char *errname, int *status, int *err) + + An interface to permit the easy execution of a + single program. The return value and most of the parameters are as + for a call to ``pex_run``. :samp:`{flags}` is restricted to a + combination of ``PEX_SEARCH``, ``PEX_STDERR_TO_STDOUT``, and + ``PEX_BINARY_OUTPUT``. :samp:`{outname}` is interpreted as if + ``PEX_LAST`` were set. On a successful return, ``*status`` will + be set to the exit status of the program. + +.. pexecute.txh:237 + +.. function:: FILE * pex_read_err (struct pex_obj *obj, int binary) + + Returns a ``FILE`` pointer which may be used to read the standard + error of the last program in the pipeline. When this is used, + ``PEX_LAST`` should not be used in a call to ``pex_run``. After + this is called, ``pex_run`` may no longer be called with the same + :samp:`{obj}`. :samp:`{binary}` should be non-zero if the file should be + opened in binary mode. Don't call ``fclose`` on the returned file; + it will be closed by ``pex_free``. + +.. pexecute.txh:224 + +.. function:: FILE * pex_read_output (struct pex_obj *obj, int binary) + + Returns a ``FILE`` pointer which may be used to read the standard + output of the last program in the pipeline. When this is used, + ``PEX_LAST`` should not be used in a call to ``pex_run``. After + this is called, ``pex_run`` may no longer be called with the same + :samp:`{obj}`. :samp:`{binary}` should be non-zero if the file should be + opened in binary mode. Don't call ``fclose`` on the returned file; + it will be closed by ``pex_free``. + +.. pexecute.txh:34 + +.. function:: const char * pex_run (struct pex_obj *obj, int flags, const char *executable, char * const *argv, const char *outname, const char *errname, int *err) + + Execute one program in a pipeline. On success this returns + ``NULL``. On failure it returns an error message, a statically + allocated string. + + :samp:`{obj}` is returned by a previous call to ``pex_init``. + + :samp:`{flags}` is a bitwise combination of the following: + + .. index:: PEX_LAST + + .. envvar:: PEX_LAST + + This must be set on the last program in the pipeline. In particular, + it should be set when executing a single program. The standard output + of the program will be sent to :samp:`{outname}`, or, if :samp:`{outname}` is + ``NULL``, to the standard output of the calling program. Do *not* + set this bit if you want to call ``pex_read_output`` + (described below). After a call to ``pex_run`` with this bit set, + :samp:`{pex_run}` may no longer be called with the same :samp:`{obj}`. + + .. index:: PEX_SEARCH + + .. envvar:: PEX_SEARCH + + Search for the program using the user's executable search path. + + .. index:: PEX_SUFFIX + + .. envvar:: PEX_SUFFIX + + :samp:`{outname}` is a suffix. See the description of :samp:`{outname}`, + below. + + .. index:: PEX_STDERR_TO_STDOUT + + .. envvar:: PEX_STDERR_TO_STDOUT + + Send the program's standard error to standard output, if possible. + + .. index:: PEX_BINARY_INPUT, PEX_BINARY_OUTPUT, PEX_BINARY_ERROR + + .. envvar:: PEX_BINARY_INPUT + + The standard input (output or error) of the program should be read (written) in + binary mode rather than text mode. These flags are ignored on systems + which do not distinguish binary mode and text mode, such as Unix. For + proper behavior these flags should match appropriately---a call to + ``pex_run`` using ``PEX_BINARY_OUTPUT`` should be followed by a + call using ``PEX_BINARY_INPUT``. + + .. index:: PEX_STDERR_TO_PIPE + + .. envvar:: PEX_STDERR_TO_PIPE + + Send the program's standard error to a pipe, if possible. This flag + cannot be specified together with ``PEX_STDERR_TO_STDOUT``. This + flag can be specified only on the last program in pipeline. + + :samp:`{executable}` is the program to execute. :samp:`{argv}` is the set of + arguments to pass to the program; normally ``argv[0]`` will + be a copy of :samp:`{executable}`. + + :samp:`{outname}` is used to set the name of the file to use for standard + output. There are two cases in which no output file will be used: + + * if ``PEX_LAST`` is not set in :samp:`{flags}`, and ``PEX_USE_PIPES`` + was set in the call to ``pex_init``, and the system supports pipes + + * if ``PEX_LAST`` is set in :samp:`{flags}`, and :samp:`{outname}` is + ``NULL`` + + Otherwise the code will use a file to hold standard + output. If ``PEX_LAST`` is not set, this file is considered to be + a temporary file, and it will be removed when no longer needed, unless + ``PEX_SAVE_TEMPS`` was set in the call to ``pex_init``. + + There are two cases to consider when setting the name of the file to + hold standard output. + + * ``PEX_SUFFIX`` is set in :samp:`{flags}`. In this case + :samp:`{outname}` may not be ``NULL``. If the :samp:`{tempbase}` parameter + to ``pex_init`` was not ``NULL``, then the output file name is + the concatenation of :samp:`{tempbase}` and :samp:`{outname}`. If + :samp:`{tempbase}` was ``NULL``, then the output file name is a random + file name ending in :samp:`{outname}`. + + * ``PEX_SUFFIX`` was not set in :samp:`{flags}`. In this + case, if :samp:`{outname}` is not ``NULL``, it is used as the output + file name. If :samp:`{outname}` is ``NULL``, and :samp:`{tempbase}` was + not NULL, the output file name is randomly chosen using + :samp:`{tempbase}`. Otherwise the output file name is chosen completely + at random. + + :samp:`{errname}` is the file name to use for standard error output. If + it is ``NULL``, standard error is the same as the caller's. + Otherwise, standard error is written to the named file. + + On an error return, the code sets ``*err`` to an ``errno`` + value, or to 0 if there is no relevant ``errno``. + +.. pexecute.txh:145 + +.. function:: const char * pex_run_in_environment (struct pex_obj *obj, int flags, const char *executable, char * const *argv, char * const *env, int env_size, const char *outname, const char *errname, int *err) + + Execute one program in a pipeline, permitting the environment for the + program to be specified. Behaviour and parameters not listed below are + as for ``pex_run``. + + :samp:`{env}` is the environment for the child process, specified as an array of + character pointers. Each element of the array should point to a string of the + form ``VAR=VALUE``, with the exception of the last element that must be + ``NULL``. + +.. pexecute.txh:301 + +.. function:: int pexecute (const char *program, char * const *argv, const char *this_pname, const char *temp_base, char **errmsg_fmt, char **errmsg_arg, int flags) + + This is the old interface to execute one or more programs. It is + still supported for compatibility purposes, but is no longer + documented. + +.. strsignal.c:541 + +.. function:: void psignal (int signo, char *message) + + Print :samp:`{message}` to the standard error, followed by a colon, + followed by the description of the signal specified by :samp:`{signo}`, + followed by a newline. + +.. putenv.c:21 + +.. function:: int putenv (const char *string) + + Uses ``setenv`` or ``unsetenv`` to put :samp:`{string}` into + the environment or remove it. If :samp:`{string}` is of the form + :samp:`name=value` the string is added; if no :samp:`=` is present the + name is unset/removed. + +.. pexecute.txh:312 + +.. function:: int pwait (int pid, int *status, int flags) + + Another part of the old execution interface. + +.. random.c:39 + +.. function:: long int random (void) + void srandom (unsigned int seed) + void* initstate (unsigned int seed, void *arg_state, unsigned long n) + void* setstate (void *arg_state) + + Random number functions. ``random`` returns a random number in the + range 0 to ``LONG_MAX``. ``srandom`` initializes the random + number generator to some starting point determined by :samp:`{seed}` + (else, the values returned by ``random`` are always the same for each + run of the program). ``initstate`` and ``setstate`` allow fine-grained + control over the state of the random number generator. + +.. concat.c:160 + +.. function:: char* reconcat (char *optr, const char *s1, ..., NULL) + + Same as ``concat``, except that if :samp:`{optr}` is not ``NULL`` it + is freed after the string is created. This is intended to be useful + when you're extending an existing string or building up a string in a + loop: + + .. code-block:: c++ + + str = reconcat (str, "pre-", str, NULL); + +.. rename.c:6 + +.. function:: int rename (const char *old, const char *new) + + Renames a file from :samp:`{old}` to :samp:`{new}`. If :samp:`{new}` already + exists, it is removed. + +.. rindex.c:5 + +.. function:: char* rindex (const char *s, int c) + + Returns a pointer to the last occurrence of the character :samp:`{c}` in + the string :samp:`{s}`, or ``NULL`` if not found. The use of ``rindex`` is + deprecated in new programs in favor of ``strrchr``. + +.. setenv.c:22 + +.. function:: int setenv (const char *name, const char *value, int overwrite) + void unsetenv (const char *name) + + ``setenv`` adds :samp:`{name}` to the environment with value + :samp:`{value}`. If the name was already present in the environment, + the new value will be stored only if :samp:`{overwrite}` is nonzero. + The companion ``unsetenv`` function removes :samp:`{name}` from the + environment. This implementation is not safe for multithreaded code. + +.. setproctitle.c:31 + +.. function:: void setproctitle (const char *fmt, ...) + + Set the title of a process to :samp:`{fmt}`. va args not supported for now, + but defined for compatibility with BSD. + +.. strsignal.c:348 + +.. function:: int signo_max (void) + + Returns the maximum signal value for which a corresponding symbolic + name or message is available. Note that in the case where we use the + ``sys_siglist`` supplied by the system, it is possible for there to + be more symbolic names than messages, or vice versa. In fact, the + manual page for ``psignal(3b)`` explicitly warns that one should + check the size of the table (``NSIG``) before indexing it, since + new signal codes may be added to the system before they are added to + the table. Thus ``NSIG`` might be smaller than value implied by + the largest signo value defined in ````. + + We return the maximum value that can be used to obtain a meaningful + symbolic name or message. + +.. sigsetmask.c:8 + +.. function:: int sigsetmask (int set) + + Sets the signal mask to the one provided in :samp:`{set}` and returns + the old mask (which, for libiberty's implementation, will always + be the value ``1``). + +.. simple-object.txh:96 + +.. function:: const char * simple_object_attributes_compare (simple_object_attributes *attrs1, simple_object_attributes *attrs2, int *err) + + Compare :samp:`{attrs1}` and :samp:`{attrs2}`. If they could be linked + together without error, return ``NULL``. Otherwise, return an + error message and set ``*err`` to an errno value or ``0`` + if there is no relevant errno. + +.. simple-object.txh:81 + +.. function:: simple_object_attributes * simple_object_fetch_attributes (simple_object_read *simple_object, const char **errmsg, int *err) + + Fetch the attributes of :samp:`{simple_object}`. The attributes are + internal information such as the format of the object file, or the + architecture it was compiled for. This information will persist until + ``simple_object_attributes_release`` is called, even if + :samp:`{simple_object}` itself is released. + + On error this returns ``NULL``, sets ``*errmsg`` to an + error message, and sets ``*err`` to an errno value or + ``0`` if there is no relevant errno. + +.. simple-object.txh:49 + +.. function:: int simple_object_find_section (simple_object_read *simple_object, off_t *offset, off_t *length, const char **errmsg, int *err) + + Look for the section :samp:`{name}` in :samp:`{simple_object}`. This returns + information for the first section with that name. + + If found, return 1 and set ``*offset`` to the offset in the + file of the section contents and set ``*length`` to the + length of the section contents. The value in ``*offset`` + will be relative to the offset passed to + ``simple_object_open_read``. + + If the section is not found, and no error occurs, + ``simple_object_find_section`` returns ``0`` and set + ``*errmsg`` to ``NULL``. + + If an error occurs, ``simple_object_find_section`` returns + ``0``, sets ``*errmsg`` to an error message, and sets + ``*err`` to an errno value or ``0`` if there is no + relevant errno. + +.. simple-object.txh:27 + +.. function:: const char * simple_object_find_sections (simple_object_read *simple_object, int (*pfn) (void *data, const char *name, off_t offset, off_t length), void *data, int *err) + + This function calls :samp:`{pfn}` for each section in :samp:`{simple_object}`. + It calls :samp:`{pfn}` with the section name, the offset within the file + of the section contents, and the length of the section contents. The + offset within the file is relative to the offset passed to + ``simple_object_open_read``. The :samp:`{data}` argument to this + function is passed along to :samp:`{pfn}`. + + If :samp:`{pfn}` returns ``0``, the loop over the sections stops and + ``simple_object_find_sections`` returns. If :samp:`{pfn}` returns some + other value, the loop continues. + + On success ``simple_object_find_sections`` returns. On error it + returns an error string, and sets ``*err`` to an errno value + or ``0`` if there is no relevant errno. + +.. simple-object.txh:2 + +.. function:: simple_object_read * simple_object_open_read (int descriptor, off_t offset, const char *segment_name, const char **errmsg, int *err) + + Opens an object file for reading. Creates and returns an + ``simple_object_read`` pointer which may be passed to other + functions to extract data from the object file. + + :samp:`{descriptor}` holds a file descriptor which permits reading. + + :samp:`{offset}` is the offset into the file; this will be ``0`` in the + normal case, but may be a different value when reading an object file + in an archive file. + + :samp:`{segment_name}` is only used with the Mach-O file format used on + Darwin aka Mac OS X. It is required on that platform, and means to + only look at sections within the segment with that name. The + parameter is ignored on other systems. + + If an error occurs, this functions returns ``NULL`` and sets + ``*errmsg`` to an error string and sets ``*err`` to + an errno value or ``0`` if there is no relevant errno. + +.. simple-object.txh:107 + +.. function:: void simple_object_release_attributes (simple_object_attributes *attrs) + + Release all resources associated with :samp:`{attrs}`. + +.. simple-object.txh:73 + +.. function:: void simple_object_release_read (simple_object_read *simple_object) + + Release all resources associated with :samp:`{simple_object}`. This does + not close the file descriptor. + +.. simple-object.txh:184 + +.. function:: void simple_object_release_write (simple_object_write *simple_object) + + Release all resources associated with :samp:`{simple_object}`. + +.. simple-object.txh:114 + +.. function:: simple_object_write * simple_object_start_write (simple_object_attributes attrs, const char *segment_name, const char **errmsg, int *err) + + Start creating a new object file using the object file format + described in :samp:`{attrs}`. You must fetch attribute information from + an existing object file before you can create a new one. There is + currently no support for creating an object file de novo. + + :samp:`{segment_name}` is only used with Mach-O as found on Darwin aka Mac + OS X. The parameter is required on that target. It means that all + sections are created within the named segment. It is ignored for + other object file formats. + + On error ``simple_object_start_write`` returns ``NULL``, sets + ``*ERRMSG`` to an error message, and sets ``*err`` + to an errno value or ``0`` if there is no relevant errno. + +.. simple-object.txh:153 + +.. function:: const char * simple_object_write_add_data (simple_object_write *simple_object, simple_object_write_section *section, const void *buffer, size_t size, int copy, int *err) + + Add data :samp:`{buffer}` / :samp:`{size}` to :samp:`{section}` in + :samp:`{simple_object}`. If :samp:`{copy}` is non-zero, the data will be + copied into memory if necessary. If :samp:`{copy}` is zero, :samp:`{buffer}` + must persist until ``simple_object_write_to_file`` is called. is + released. + + On success this returns ``NULL``. On error this returns an error + message, and sets ``*err`` to an errno value or 0 if there is + no relevant erro. + +.. simple-object.txh:134 + +.. function:: simple_object_write_section * simple_object_write_create_section (simple_object_write *simple_object, const char *name, unsigned int align, const char **errmsg, int *err) + + Add a section to :samp:`{simple_object}`. :samp:`{name}` is the name of the + new section. :samp:`{align}` is the required alignment expressed as the + number of required low-order 0 bits (e.g., 2 for alignment to a 32-bit + boundary). + + The section is created as containing data, readable, not writable, not + executable, not loaded at runtime. The section is not written to the + file until ``simple_object_write_to_file`` is called. + + On error this returns ``NULL``, sets ``*errmsg`` to an + error message, and sets ``*err`` to an errno value or + ``0`` if there is no relevant errno. + +.. simple-object.txh:170 + +.. function:: const char * simple_object_write_to_file (simple_object_write *simple_object, int descriptor, int *err) + + Write the complete object file to :samp:`{descriptor}`, an open file + descriptor. This writes out all the data accumulated by calls to + ``simple_object_write_create_section`` and + :samp:`{simple_object_write_add_data}`. + + This returns ``NULL`` on success. On error this returns an error + message and sets ``*err`` to an errno value or ``0`` if + there is no relevant errno. + +.. snprintf.c:28 + +.. function:: int snprintf (char *buf, size_t n, const char *format, ...) + + This function is similar to ``sprintf``, but it will write to + :samp:`{buf}` at most ``n-1`` bytes of text, followed by a + terminating null byte, for a total of :samp:`{n}` bytes. + On error the return value is -1, otherwise it returns the number of + bytes, not including the terminating null byte, that would have been + written had :samp:`{n}` been sufficiently large, regardless of the actual + value of :samp:`{n}`. Note some pre-C99 system libraries do not implement + this correctly so users cannot generally rely on the return value if + the system version of this function is used. + +.. spaces.c:22 + +.. function:: char* spaces (int count) + + Returns a pointer to a memory region filled with the specified + number of spaces and null terminated. The returned pointer is + valid until at least the next call. + +.. splay-tree.c:305 + +.. function:: splay_tree splay_tree_new_with_typed_alloc (splay_tree_compare_fn compare_fn, splay_tree_delete_key_fn delete_key_fn, splay_tree_delete_value_fn delete_value_fn, splay_tree_allocate_fn tree_allocate_fn, splay_tree_allocate_fn node_allocate_fn, splay_tree_deallocate_fn deallocate_fn, void * allocate_data) + + This function creates a splay tree that uses two different allocators + :samp:`{tree_allocate_fn}` and :samp:`{node_allocate_fn}` to use for allocating the + tree itself and its nodes respectively. This is useful when variables of + different types need to be allocated with different allocators. + + The splay tree will use :samp:`{compare_fn}` to compare nodes, + :samp:`{delete_key_fn}` to deallocate keys, and :samp:`{delete_value_fn}` to + deallocate values. Keys and values will be deallocated when the + tree is deleted using splay_tree_delete or when a node is removed + using splay_tree_remove. splay_tree_insert will release the previously + inserted key and value using :samp:`{delete_key_fn}` and :samp:`{delete_value_fn}` + if the inserted key is already found in the tree. + +.. stack-limit.c:28 + +.. function:: void stack_limit_increase (unsigned long pref) + + Attempt to increase stack size limit to :samp:`{pref}` bytes if possible. + +.. stpcpy.c:23 + +.. function:: char* stpcpy (char *dst, const char *src) + + Copies the string :samp:`{src}` into :samp:`{dst}`. Returns a pointer to + :samp:`{dst}` + strlen(:samp:`{src}`). + +.. stpncpy.c:23 + +.. function:: char* stpncpy (char *dst, const char *src, size_t len) + + Copies the string :samp:`{src}` into :samp:`{dst}`, copying exactly :samp:`{len}` + and padding with zeros if necessary. If :samp:`{len}` < strlen(:samp:`{src}`) + then return :samp:`{dst}` + :samp:`{len}`, otherwise returns :samp:`{dst}` + + strlen(:samp:`{src}`). + +.. strcasecmp.c:15 + +.. function:: int strcasecmp (const char *s1, const char *s2) + + A case-insensitive ``strcmp``. + +.. strchr.c:6 + +.. function:: char* strchr (const char *s, int c) + + Returns a pointer to the first occurrence of the character :samp:`{c}` in + the string :samp:`{s}`, or ``NULL`` if not found. If :samp:`{c}` is itself the + null character, the results are undefined. + +.. strdup.c:3 + +.. function:: char* strdup (const char *s) + + Returns a pointer to a copy of :samp:`{s}` in memory obtained from + ``malloc``, or ``NULL`` if insufficient memory was available. + +.. strerror.c:675 + +.. function:: const char* strerrno (int errnum) + + Given an error number returned from a system call (typically returned + in ``errno``), returns a pointer to a string containing the + symbolic name of that error number, as found in ````. + + If the supplied error number is within the valid range of indices for + symbolic names, but no name is available for the particular error + number, then returns the string :samp:`Error {num}`, where :samp:`{num}` + is the error number. + + If the supplied error number is not within the range of valid + indices, then returns ``NULL``. + + The contents of the location pointed to are only guaranteed to be + valid until the next call to ``strerrno``. + +.. strerror.c:608 + +.. function:: char* strerror (int errnoval) + + Maps an ``errno`` number to an error message string, the contents + of which are implementation defined. On systems which have the + external variables ``sys_nerr`` and ``sys_errlist``, these + strings will be the same as the ones used by ``perror``. + + If the supplied error number is within the valid range of indices for + the ``sys_errlist``, but no message is available for the particular + error number, then returns the string :samp:`Error {num}`, where + :samp:`{num}` is the error number. + + If the supplied error number is not a valid index into + ``sys_errlist``, returns ``NULL``. + + The returned string is only guaranteed to be valid only until the + next call to ``strerror``. + +.. strncasecmp.c:15 + +.. function:: int strncasecmp (const char *s1, const char *s2) + + A case-insensitive ``strncmp``. + +.. strncmp.c:6 + +.. function:: int strncmp (const char *s1, const char *s2, size_t n) + + Compares the first :samp:`{n}` bytes of two strings, returning a value as + ``strcmp``. + +.. strndup.c:23 + +.. function:: char* strndup (const char *s, size_t n) + + Returns a pointer to a copy of :samp:`{s}` with at most :samp:`{n}` characters + in memory obtained from ``malloc``, or ``NULL`` if insufficient + memory was available. The result is always NUL terminated. + +.. strnlen.c:6 + +.. function:: size_t strnlen (const char *s, size_t maxlen) + + Returns the length of :samp:`{s}`, as with ``strlen``, but never looks + past the first :samp:`{maxlen}` characters in the string. If there is no + '\0' character in the first :samp:`{maxlen}` characters, returns + :samp:`{maxlen}`. + +.. strrchr.c:6 + +.. function:: char* strrchr (const char *s, int c) + + Returns a pointer to the last occurrence of the character :samp:`{c}` in + the string :samp:`{s}`, or ``NULL`` if not found. If :samp:`{c}` is itself the + null character, the results are undefined. + +.. strsignal.c:383 + +.. function:: const char * strsignal (int signo) + + Maps an signal number to an signal message string, the contents of + which are implementation defined. On systems which have the external + variable ``sys_siglist``, these strings will be the same as the + ones used by ``psignal()``. + + If the supplied signal number is within the valid range of indices for + the ``sys_siglist``, but no message is available for the particular + signal number, then returns the string :samp:`Signal {num}`, where + :samp:`{num}` is the signal number. + + If the supplied signal number is not a valid index into + ``sys_siglist``, returns ``NULL``. + + The returned string is only guaranteed to be valid only until the next + call to ``strsignal``. + +.. strsignal.c:448 + +.. function:: const char* strsigno (int signo) + + Given an signal number, returns a pointer to a string containing the + symbolic name of that signal number, as found in ````. + + If the supplied signal number is within the valid range of indices for + symbolic names, but no name is available for the particular signal + number, then returns the string :samp:`Signal {num}`, where + :samp:`{num}` is the signal number. + + If the supplied signal number is not within the range of valid + indices, then returns ``NULL``. + + The contents of the location pointed to are only guaranteed to be + valid until the next call to ``strsigno``. + +.. strstr.c:6 + +.. function:: char* strstr (const char *string, const char *sub) + + This function searches for the substring :samp:`{sub}` in the string + :samp:`{string}`, not including the terminating null characters. A pointer + to the first occurrence of :samp:`{sub}` is returned, or ``NULL`` if the + substring is absent. If :samp:`{sub}` points to a string with zero + length, the function returns :samp:`{string}`. + +.. strtod.c:27 + +.. function:: double strtod (const char *string, char **endptr) + + This ISO C function converts the initial portion of :samp:`{string}` to a + ``double``. If :samp:`{endptr}` is not ``NULL``, a pointer to the + character after the last character used in the conversion is stored in + the location referenced by :samp:`{endptr}`. If no conversion is + performed, zero is returned and the value of :samp:`{string}` is stored in + the location referenced by :samp:`{endptr}`. + +.. strerror.c:734 + +.. function:: int strtoerrno (const char *name) + + Given the symbolic name of a error number (e.g., ``EACCES``), map it + to an errno value. If no translation is found, returns 0. + +.. strtol.c:33 + +.. function:: long int strtol (const char *string, char **endptr, int base) + unsigned long int strtoul (const char *string, char **endptr, int base) + + The ``strtol`` function converts the string in :samp:`{string}` to a + long integer value according to the given :samp:`{base}`, which must be + between 2 and 36 inclusive, or be the special value 0. If :samp:`{base}` + is 0, ``strtol`` will look for the prefixes ``0`` and ``0x`` + to indicate bases 8 and 16, respectively, else default to base 10. + When the base is 16 (either explicitly or implicitly), a prefix of + ``0x`` is allowed. The handling of :samp:`{endptr}` is as that of + ``strtod`` above. The ``strtoul`` function is the same, except + that the converted value is unsigned. + +.. strtoll.c:33 + +.. function:: long long int strtoll (const char *string, char **endptr, int base) + unsigned long long int strtoull (const char *string, char **endptr, int base) + + The ``strtoll`` function converts the string in :samp:`{string}` to a + long long integer value according to the given :samp:`{base}`, which must be + between 2 and 36 inclusive, or be the special value 0. If :samp:`{base}` + is 0, ``strtoll`` will look for the prefixes ``0`` and ``0x`` + to indicate bases 8 and 16, respectively, else default to base 10. + When the base is 16 (either explicitly or implicitly), a prefix of + ``0x`` is allowed. The handling of :samp:`{endptr}` is as that of + ``strtod`` above. The ``strtoull`` function is the same, except + that the converted value is unsigned. + +.. strsignal.c:502 + +.. function:: int strtosigno (const char *name) + + Given the symbolic name of a signal, map it to a signal number. If no + translation is found, returns 0. + +.. strverscmp.c:25 + +.. function:: int strverscmp (const char *s1, const char *s2) + + The ``strverscmp`` function compares the string :samp:`{s1}` against + :samp:`{s2}`, considering them as holding indices/version numbers. Return + value follows the same conventions as found in the ``strverscmp`` + function. In fact, if :samp:`{s1}` and :samp:`{s2}` contain no digits, + ``strverscmp`` behaves like ``strcmp``. + + Basically, we compare strings normally (character by character), until + we find a digit in each string - then we enter a special comparison + mode, where each sequence of digits is taken as a whole. If we reach the + end of these two parts without noticing a difference, we return to the + standard comparison mode. There are two types of numeric parts: + "integral" and "fractional" (those begin with a '0'). The types + of the numeric parts affect the way we sort them: + + * integral/integral: we compare values as you would expect. + + * fractional/integral: the fractional part is less than the integral one. + Again, no surprise. + + * fractional/fractional: the things become a bit more complex. + If the common prefix contains only leading zeroes, the longest part is less + than the other one; else the comparison behaves normally. + + .. code-block:: + + strverscmp ("no digit", "no digit") + ⇒ 0 // same behavior as strcmp. + strverscmp ("item#99", "item#100") + ⇒ <0 // same prefix, but 99 < 100. + strverscmp ("alpha1", "alpha001") + ⇒ >0 // fractional part inferior to integral one. + strverscmp ("part1_f012", "part1_f01") + ⇒ >0 // two fractional parts. + strverscmp ("foo.009", "foo.0") + ⇒ <0 // idem, but with leading zeroes only. + + This function is especially useful when dealing with filename sorting, + because filenames frequently hold indices/version numbers. + +.. timeval-utils.c:43 + +.. function:: void timeval_add (struct timeval *a, struct timeval *b, struct timeval *result) + + Adds :samp:`{a}` to :samp:`{b}` and stores the result in :samp:`{result}`. + +.. timeval-utils.c:67 + +.. function:: void timeval_sub (struct timeval *a, struct timeval *b, struct timeval *result) + + Subtracts :samp:`{b}` from :samp:`{a}` and stores the result in :samp:`{result}`. + +.. tmpnam.c:3 + +.. function:: char* tmpnam (char *s) + + This function attempts to create a name for a temporary file, which + will be a valid file name yet not exist when ``tmpnam`` checks for + it. :samp:`{s}` must point to a buffer of at least ``L_tmpnam`` bytes, + or be ``NULL``. Use of this function creates a security risk, and it must + not be used in new projects. Use ``mkstemp`` instead. + +.. unlink-if-ordinary.c:27 + +.. function:: int unlink_if_ordinary (const char*) + + Unlinks the named file, unless it is special (e.g. a device file). + Returns 0 when the file was unlinked, a negative value (and errno set) when + there was an error deleting the file, and a positive value if no attempt + was made to unlink the file because it is special. + +.. fopen_unlocked.c:31 + +.. function:: void unlock_std_streams (void) + + If the OS supports it, ensure that the standard I/O streams, + ``stdin``, ``stdout`` and ``stderr`` are setup to avoid any + multi-threaded locking. Otherwise do nothing. + +.. fopen_unlocked.c:23 + +.. function:: void unlock_stream (FILE * stream) + + If the OS supports it, ensure that the supplied stream is setup to + avoid any multi-threaded locking. Otherwise leave the ``FILE`` + pointer unchanged. If the :samp:`{stream}` is ``NULL`` do nothing. + +.. vasprintf.c:47 + +.. function:: int vasprintf (char **resptr, const char *format, va_list args) + + Like ``vsprintf``, but instead of passing a pointer to a buffer, + you pass a pointer to a pointer. This function will compute the size + of the buffer needed, allocate memory with ``malloc``, and store a + pointer to the allocated memory in ``*resptr``. The value + returned is the same as ``vsprintf`` would return. If memory could + not be allocated, minus one is returned and ``NULL`` is stored in + ``*resptr``. + +.. vfork.c:6 + +.. function:: int vfork (void) + + Emulates ``vfork`` by calling ``fork`` and returning its value. + +.. vprintf.c:3 + +.. function:: int vprintf (const char *format, va_list ap) + int vfprintf (FILE *stream, const char *format, va_list ap) + int vsprintf (char *str, const char *format, va_list ap) + + These functions are the same as ``printf``, ``fprintf``, and + ``sprintf``, respectively, except that they are called with a + ``va_list`` instead of a variable number of arguments. Note that + they do not call ``va_end`` ; this is the application's + responsibility. In ``libiberty`` they are implemented in terms of the + nonstandard but common function ``_doprnt``. + +.. vsnprintf.c:28 + +.. function:: int vsnprintf (char *buf, size_t n, const char *format, va_list ap) + + This function is similar to ``vsprintf``, but it will write to + :samp:`{buf}` at most ``n-1`` bytes of text, followed by a + terminating null byte, for a total of :samp:`{n}` bytes. On error the + return value is -1, otherwise it returns the number of characters that + would have been printed had :samp:`{n}` been sufficiently large, + regardless of the actual value of :samp:`{n}`. Note some pre-C99 system + libraries do not implement this correctly so users cannot generally + rely on the return value if the system version of this function is + used. + +.. waitpid.c:3 + +.. function:: int waitpid (int pid, int *status, int) + + This is a wrapper around the ``wait`` function. Any 'special' + values of :samp:`{pid}` depend on your implementation of ``wait``, as + does the return value. The third argument is unused in ``libiberty``. + +.. argv.c:289 + +.. function:: int writeargv (char * const *argv, FILE *file) + + Write each member of ARGV, handling all necessary quoting, to the file + named by FILE, separated by whitespace. Return 0 on success, non-zero + if an error occurred while writing to FILE. + +.. xasprintf.c:31 + +.. function:: char* xasprintf (const char *format, ...) + + Print to allocated string without fail. If ``xasprintf`` fails, + this will print a message to ``stderr`` (using the name set by + ``xmalloc_set_program_name``, if any) and then call ``xexit``. + +.. xatexit.c:11 + +.. function:: int xatexit (void (*fn) (void)) + + Behaves as the standard ``atexit`` function, but with no limit on + the number of registered functions. Returns 0 on success, or -1 on + failure. If you use ``xatexit`` to register functions, you must use + ``xexit`` to terminate your program. + +.. xmalloc.c:38 + +.. function:: void* xcalloc (size_t nelem, size_t elsize) + + Allocate memory without fail, and set it to zero. This routine functions + like ``calloc``, but will behave the same as ``xmalloc`` if memory + cannot be found. + +.. xexit.c:22 + +.. function:: void xexit (int code) + + Terminates the program. If any functions have been registered with + the ``xatexit`` replacement function, they will be called first. + Termination is handled via the system's normal ``exit`` call. + +.. xmalloc.c:22 + +.. function:: void* xmalloc (size_t) + + Allocate memory without fail. If ``malloc`` fails, this will print + a message to ``stderr`` (using the name set by + ``xmalloc_set_program_name``, + if any) and then call ``xexit``. Note that it is therefore safe for + a program to contain ``#define malloc xmalloc`` in its source. + +.. xmalloc.c:53 + +.. function:: void xmalloc_failed (size_t) + + This function is not meant to be called by client code, and is listed + here for completeness only. If any of the allocation routines fail, this + function will be called to print an error message and terminate execution. + +.. xmalloc.c:46 + +.. function:: void xmalloc_set_program_name (const char *name) + + You can use this to set the name of the program used by + ``xmalloc_failed`` when printing a failure message. + +.. xmemdup.c:7 + +.. function:: void* xmemdup (void *input, size_t copy_size, size_t alloc_size) + + Duplicates a region of memory without fail. First, :samp:`{alloc_size}` bytes + are allocated, then :samp:`{copy_size}` bytes from :samp:`{input}` are copied into + it, and the new memory is returned. If fewer bytes are copied than were + allocated, the remaining memory is zeroed. + +.. xmalloc.c:32 + +.. function:: void* xrealloc (void *ptr, size_t size) + + Reallocate memory without fail. This routine functions like ``realloc``, + but will behave the same as ``xmalloc`` if memory cannot be found. + +.. xstrdup.c:7 + +.. function:: char* xstrdup (const char *s) + + Duplicates a character string without fail, using ``xmalloc`` to + obtain memory. + +.. xstrerror.c:7 + +.. function:: char* xstrerror (int errnum) + + Behaves exactly like the standard ``strerror`` function, but + will never return a ``NULL`` pointer. + +.. xstrndup.c:23 + +.. function:: char* xstrndup (const char *s, size_t n) + + Returns a pointer to a copy of :samp:`{s}` with at most :samp:`{n}` characters + without fail, using ``xmalloc`` to obtain memory. The result is + always NUL terminated. + +.. xvasprintf.c:38 + +.. function:: char* xvasprintf (const char *format, va_list args) + + Print to allocated string without fail. If ``xvasprintf`` fails, + this will print a message to ``stderr`` (using the name set by + ``xmalloc_set_program_name``, if any) and then call ``xexit``. \ No newline at end of file diff --git a/libiberty/doc/index.rst b/libiberty/doc/index.rst new file mode 100644 index 00000000000..6770b9ed961 --- /dev/null +++ b/libiberty/doc/index.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +GNU libiberty +============= + +.. only:: html + + Contents: + +.. toctree:: + + copyright + introduction + using + overview + function-variable-and-macro-listing + lesser-general-public-license-2.1 + bsd + + indices-and-tables \ No newline at end of file diff --git a/libiberty/doc/indices-and-tables.rst b/libiberty/doc/indices-and-tables.rst new file mode 100644 index 00000000000..9799e4e2e48 --- /dev/null +++ b/libiberty/doc/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/libiberty/doc/introduction.rst b/libiberty/doc/introduction.rst new file mode 100644 index 00000000000..b26f6432d7f --- /dev/null +++ b/libiberty/doc/introduction.rst @@ -0,0 +1,8 @@ +.. _top: + +Introduction +============ + +The ``libiberty`` library is a collection of subroutines used by various +GNU programs. It is available under the Library General Public +License; for more information, see Library Copying. \ No newline at end of file diff --git a/libiberty/doc/lesser-general-public-license-2.1.rst b/libiberty/doc/lesser-general-public-license-2.1.rst new file mode 100644 index 00000000000..a4c8739844b --- /dev/null +++ b/libiberty/doc/lesser-general-public-license-2.1.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../doc/lgpl-2.1.rst \ No newline at end of file diff --git a/libiberty/doc/overview.rst b/libiberty/doc/overview.rst new file mode 100644 index 00000000000..e16601e604b --- /dev/null +++ b/libiberty/doc/overview.rst @@ -0,0 +1,20 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _overview: + +Overview +-------- + +Functions contained in ``libiberty`` can be divided into three general categories. + +.. toctree:: + :maxdepth: 2 + + supplemental-functions + + replacement-functions + + extensions \ No newline at end of file diff --git a/libiberty/doc/replacement-functions.rst b/libiberty/doc/replacement-functions.rst new file mode 100644 index 00000000000..4439674cad3 --- /dev/null +++ b/libiberty/doc/replacement-functions.rst @@ -0,0 +1,62 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: replacement functions, functions, replacement + +.. _replacement-functions: + +Replacement Functions +********************* + +Some functions have extremely limited implementations on different +platforms. Other functions are tedious to use correctly; for example, +proper use of ``malloc`` calls for the return value to be checked and +appropriate action taken if memory has been exhausted. A group of +'replacement functions' is available in ``libiberty`` to address these issues +for some of the most commonly used subroutines. + +All of these functions are declared in the :samp:`libiberty.h` header +file. Many of the implementations will use preprocessor macros set by +GNU Autoconf, if you decide to make use of that program. Some of these +functions may call one another. + +.. toctree:: + :maxdepth: 2 + + +.. index:: memory allocation + +.. _memory-allocation: + +Memory Allocation +^^^^^^^^^^^^^^^^^ + +The functions beginning with the letter :samp:`x` are wrappers around +standard functions; the functions provided by the system environment +are called and their results checked before the results are passed back +to client code. If the standard functions fail, these wrappers will +terminate the program. Thus, these versions can be used with impunity. + +.. index:: exit handlers + +.. _exit-handlers: + +Exit Handlers +^^^^^^^^^^^^^ + +The existence and implementation of the ``atexit`` routine varies +amongst the flavors of Unix. ``libiberty`` provides an unvarying dependable +implementation via ``xatexit`` and ``xexit``. + +.. index:: error reporting + +.. _error-reporting: + +Error Reporting +^^^^^^^^^^^^^^^ + +These are a set of routines to facilitate programming with the system +``errno`` interface. The ``libiberty`` source file :samp:`strerror.c` +contains a good deal of documentation for these functions. \ No newline at end of file diff --git a/libiberty/doc/supplemental-functions.rst b/libiberty/doc/supplemental-functions.rst new file mode 100644 index 00000000000..d8387fcecaa --- /dev/null +++ b/libiberty/doc/supplemental-functions.rst @@ -0,0 +1,31 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: supplemental functions, functions, supplemental, functions, missing + +.. _supplemental-functions: + +Supplemental Functions +********************** + +Certain operating systems do not provide functions which have since +become standardized, or at least common. For example, the Single +Unix Specification Version 2 requires that the ``basename`` +function be provided, but an OS which predates that specification +might not have this function. This should not prevent well-written +code from running on such a system. + +Similarly, some functions exist only among a particular 'flavor' +or 'family' of operating systems. As an example, the ``bzero`` +function is often not present on systems outside the BSD-derived +family of systems. + +Many such functions are provided in ``libiberty``. They are quickly +listed here with little description, as systems which lack them +become less and less common. Each function :samp:`{foo}` is implemented +in :samp:`{foo}.c` but not declared in any ``libiberty`` header file; more +comments and caveats for each function's implementation are often +available in the source file. Generally, the function can simply +be declared as ``extern``. \ No newline at end of file diff --git a/libiberty/doc/using.rst b/libiberty/doc/using.rst new file mode 100644 index 00000000000..16974f38051 --- /dev/null +++ b/libiberty/doc/using.rst @@ -0,0 +1,40 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. index:: using libiberty, libiberty usage, how to use + +.. _using: + +Using +----- + +.. THIS SECTION IS CRAP AND NEEDS REWRITING BADLY. + +To date, ``libiberty`` is generally not installed on its own. It has evolved +over years but does not have its own version number nor release schedule. + +Possibly the easiest way to use ``libiberty`` in your projects is to drop the +``libiberty`` code into your project's sources, and to build the library along +with your own sources; the library would then be linked in at the end. This +prevents any possible version mismatches with other copies of libiberty +elsewhere on the system. + +Passing :option:`--enable-install-libiberty` to the :command:`configure` +script when building ``libiberty`` causes the header files and archive library +to be installed when make install is run. This option also takes +an (optional) argument to specify the installation location, in the same +manner as :option:`--prefix`. + +For your own projects, an approach which offers stability and flexibility +is to include ``libiberty`` with your code, but allow the end user to optionally +choose to use a previously-installed version instead. In this way the +user may choose (for example) to install ``libiberty`` as part of GCC, and use +that version for all software built with that compiler. (This approach +has proven useful with software using the GNU ``readline`` library.) + +Making use of ``libiberty`` code usually requires that you include one or more +header files from the ``libiberty`` distribution. (They will be named as +necessary in the function descriptions.) At link time, you will need to +add :option:`-liberty` to your link command invocation. \ No newline at end of file diff --git a/libitm/doc/c-c++-language-constructs-for-tm.rst b/libitm/doc/c-c++-language-constructs-for-tm.rst new file mode 100644 index 00000000000..8487eae034b --- /dev/null +++ b/libitm/doc/c-c++-language-constructs-for-tm.rst @@ -0,0 +1,39 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _c-c++-language-constructs-for-tm: + +C/C++ Language Constructs for TM +-------------------------------- + +Transactions are supported in C++ and C in the form of transaction statements, +transaction expressions, and function transactions. In the following example, +both ``a`` and ``b`` will be read and the difference will be written to +``c``, all atomically and isolated from other transactions: + +.. code-block:: c++ + + __transaction_atomic { c = a - b; } + +Therefore, another thread can use the following code to concurrently update +``b`` without ever causing ``c`` to hold a negative value (and without +having to use other synchronization constructs such as locks or C++11 +atomics): + +.. code-block:: c++ + + __transaction_atomic { if (a > b) b++; } + +GCC follows the `Draft +Specification of Transactional Language Constructs for C++ (v1.1) `_ in its +implementation of transactions. + +The precise semantics of transactions are defined in terms of the C++11/C11 +memory model (see the specification). Roughly, transactions provide +synchronization guarantees that are similar to what would be guaranteed when +using a single global lock as a guard for all transactions. Note that like +other synchronization constructs in C/C++, transactions rely on a +data-race-free program (e.g., a nontransactional write that is concurrent +with a transactional read to the same memory location is a data race). \ No newline at end of file diff --git a/libitm/doc/conf.py b/libitm/doc/conf.py new file mode 100644 index 00000000000..c288e34fdba --- /dev/null +++ b/libitm/doc/conf.py @@ -0,0 +1,24 @@ +# Configuration file for the Sphinx documentation builder. + +import sys +sys.path.append('../..//doc') + +from baseconf import * + +name = 'libitm' +project = 'The GNU Transactional Memory Library' +copyright = '2011-2022 Free Software Foundation, Inc.' +authors = 'GCC Developer Community' + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +latex_documents = [ + ('index', f'{name}.tex', project, authors, 'manual'), +] + +texinfo_documents = [ + ('index', name, project, authors, None, None, None, True) +] + +set_common(name, globals()) \ No newline at end of file diff --git a/libitm/doc/copyright.rst b/libitm/doc/copyright.rst new file mode 100644 index 00000000000..f0a7a075ef7 --- /dev/null +++ b/libitm/doc/copyright.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Copyright +^^^^^^^^^ + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no +Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +A copy of the license is included in the section entitled :ref:`gnu_fdl`. \ No newline at end of file diff --git a/libitm/doc/enabling-libitm.rst b/libitm/doc/enabling-libitm.rst new file mode 100644 index 00000000000..212c120c387 --- /dev/null +++ b/libitm/doc/enabling-libitm.rst @@ -0,0 +1,13 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _enabling-libitm: + +Enabling libitm +--------------- + +To activate support for TM in C/C++, the compile-time flag :option:`-fgnu-tm` +must be specified. This enables TM language-level constructs such as +transaction statements (e.g., ``__transaction_atomic``, see :ref:`c-c++-language-constructs-for-tm` for details). \ No newline at end of file diff --git a/libitm/doc/gnu-free-documentation-license.rst b/libitm/doc/gnu-free-documentation-license.rst new file mode 100644 index 00000000000..089cc682de2 --- /dev/null +++ b/libitm/doc/gnu-free-documentation-license.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../doc/gnu_free_documentation_license.rst \ No newline at end of file diff --git a/libitm/doc/index.rst b/libitm/doc/index.rst new file mode 100644 index 00000000000..45ff20f332b --- /dev/null +++ b/libitm/doc/index.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +GCC libquadmath +=============== + +Introduction +============ + +.. index:: Introduction + +This manual documents the usage and internals of libitm, the GNU Transactional +Memory Library. It provides transaction support for accesses to a process' +memory, enabling easy-to-use synchronization of accesses to shared memory by +several threads. + +.. toctree:: + + copyright + enabling-libitm + c-c++-language-constructs-for-tm + the-libitm-abi + internals + gnu-free-documentation-license + indices-and-tables \ No newline at end of file diff --git a/libitm/doc/indices-and-tables.rst b/libitm/doc/indices-and-tables.rst new file mode 100644 index 00000000000..9799e4e2e48 --- /dev/null +++ b/libitm/doc/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/libitm/doc/internals.rst b/libitm/doc/internals.rst new file mode 100644 index 00000000000..2e1c24c4e80 --- /dev/null +++ b/libitm/doc/internals.rst @@ -0,0 +1,16 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _internals: + +Internals +--------- + +.. toctree:: + :maxdepth: 2 + + tm-methods-and-method-groups + nesting-flat-vs-closed + locking-conventions \ No newline at end of file diff --git a/libitm/doc/locking-conventions.rst b/libitm/doc/locking-conventions.rst new file mode 100644 index 00000000000..b7a8d310f08 --- /dev/null +++ b/libitm/doc/locking-conventions.rst @@ -0,0 +1,261 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Locking conventions +******************* + +This section documents the locking scheme and rules for all uses of locking +in libitm. We have to support serial(-irrevocable) mode, which is implemented +using a global lock as explained next (called the *serial lock*). To +simplify the overall design, we use the same lock as catch-all locking +mechanism for other infrequent tasks such as (de)registering clone tables or +threads. Besides the serial lock, there are *per-method-group locks* that +are managed by specific method groups (i.e., groups of similar TM concurrency +control algorithms), and lock-like constructs for quiescence-based operations +such as ensuring privatization safety. + +Thus, the actions that participate in the libitm-internal locking are either +*active transactions* that do not run in serial mode, *serial +transactions* (which (are about to) run in serial mode), and management tasks +that do not execute within a transaction but have acquired the serial mode +like a serial transaction would do (e.g., to be able to register threads with +libitm). Transactions become active as soon as they have successfully used the +serial lock to announce this globally (see :ref:`serial-lock-impl`). Likewise, transactions become serial transactions as soon as +they have acquired the exclusive rights provided by the serial lock (i.e., +serial mode, which also means that there are no other concurrent active or +serial transactions). Note that active transactions can become serial +transactions when they enter serial mode during the runtime of the +transaction. + +State-to-lock mapping +^^^^^^^^^^^^^^^^^^^^^ + +Application data is protected by the serial lock if there is a serial +transaction and no concurrently running active transaction (i.e., non-serial). +Otherwise, application data is protected by the currently selected method +group, which might use per-method-group locks or other mechanisms. Also note +that application data that is about to be privatized might not be allowed to be +accessed by nontransactional code until privatization safety has been ensured; +the details of this are handled by the current method group. + +libitm-internal state is either protected by the serial lock or accessed +through custom concurrent code. The latter applies to the public/shared part +of a transaction object and most typical method-group-specific state. + +The former category (protected by the serial lock) includes: + +* The list of active threads that have used transactions. + +* The tables that map functions to their transactional clones. + +* The current selection of which method group to use. + +* Some method-group-specific data, or invariants of this data. For example, + resetting a method group to its initial state is handled by switching to the + same method group, so the serial lock protects such resetting as well. + +In general, such state is immutable whenever there exists an active +(non-serial) transaction. If there is no active transaction, a serial +transaction (or a thread that is not currently executing a transaction but has +acquired the serial lock) is allowed to modify this state (but must of course +be careful to not surprise the current method group's implementation with such +modifications). + +Lock acquisition order +^^^^^^^^^^^^^^^^^^^^^^ + +To prevent deadlocks, locks acquisition must happen in a globally agreed-upon +order. Note that this applies to other forms of blocking too, but does not +necessarily apply to lock acquisitions that do not block (e.g., trylock() +calls that do not get retried forever). Note that serial transactions are +never return back to active transactions until the transaction has committed. +Likewise, active transactions stay active until they have committed. +Per-method-group locks are typically also not released before commit. + +Lock acquisition / blocking rules: + +* Transactions must become active or serial before they are allowed to + use method-group-specific locks or blocking (i.e., the serial lock must be + acquired before those other locks, either in serial or nonserial mode). + +* Any number of threads that do not currently run active transactions can + block while trying to get the serial lock in exclusive mode. Note that active + transactions must not block when trying to upgrade to serial mode unless there + is no other transaction that is trying that (the latter is ensured by the + serial lock implementation. + +* Method groups must prevent deadlocks on their locks. In particular, they + must also be prepared for another active transaction that has acquired + method-group-specific locks but is blocked during an attempt to upgrade to + being a serial transaction. See below for details. + +* Serial transactions can acquire method-group-specific locks because there + will be no other active nor serial transaction. + +There is no single rule for per-method-group blocking because this depends on +when a TM method might acquire locks. If no active transaction can upgrade to +being a serial transaction after it has acquired per-method-group locks (e.g., +when those locks are only acquired during an attempt to commit), then the TM +method does not need to consider a potential deadlock due to serial mode. + +If there can be upgrades to serial mode after the acquisition of +per-method-group locks, then TM methods need to avoid those deadlocks: + +* When upgrading to a serial transaction, after acquiring exclusive rights + to the serial lock but before waiting for concurrent active transactions to + finish (see :ref:`serial-lock-impl` for details), + we have to wake up all active transactions waiting on the upgrader's + per-method-group locks. + +* Active transactions blocking on per-method-group locks need to check the + serial lock and abort if there is a pending serial transaction. + +* Lost wake-ups have to be prevented (e.g., by changing a bit in each + per-method-group lock before doing the wake-up, and only blocking on this lock + using a futex if this bit is not group). + +.. todo:: Can reuse serial lock for gl-\*? And if we can, does it make + sense to introduce further complexity in the serial lock? For gl-\*, we can + really only avoid an abort if we do -wb and -vbv. + +.. _serial-lock-impl: + +Serial lock implementation +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The serial lock implementation is optimized towards assuming that serial +transactions are infrequent and not the common case. However, the performance +of entering serial mode can matter because when only few transactions are run +concurrently or if there are few threads, then it can be efficient to run +transactions serially. + +The serial lock is similar to a multi-reader-single-writer lock in that there +can be several active transactions but only one serial transaction. However, +we do want to avoid contention (in the lock implementation) between active +transactions, so we split up the reader side of the lock into per-transaction +flags that are true iff the transaction is active. The exclusive writer side +remains a shared single flag, which is acquired using a CAS, for example. +On the fast-path, the serial lock then works similar to Dekker's algorithm but +with several reader flags that a serial transaction would have to check. +A serial transaction thus requires a list of all threads with potentially +active transactions; we can use the serial lock itself to protect this list +(i.e., only threads that have acquired the serial lock can modify this list). + +We want starvation-freedom for the serial lock to allow for using it to ensure +progress for potentially starved transactions (see :ref:`progress-guarantees` for details). However, this is currently not enforced by +the implementation of the serial lock. + +Here is pseudo-code for the read/write fast paths of acquiring the serial +lock (read-to-write upgrade is similar to write_lock: + +.. code-block:: c++ + + // read_lock: + tx->shared_state |= active; + __sync_synchronize(); // or STLD membar, or C++0x seq-cst fence + while (!serial_lock.exclusive) + if (spinning_for_too_long) goto slowpath; + + // write_lock: + if (CAS(&serial_lock.exclusive, 0, this) != 0) + goto slowpath; // writer-writer contention + // need a membar here, but CAS already has full membar semantics + bool need_blocking = false; + for (t: all txns) + { + for (;t->shared_state & active;) + if (spinning_for_too_long) { need_blocking = true; break; } + } + if (need_blocking) goto slowpath; + +Releasing a lock in this spin-lock version then just consists of resetting +``tx->shared_state`` to inactive or clearing ``serial_lock.exclusive``. + +However, we can't rely on a pure spinlock because we need to get the OS +involved at some time (e.g., when there are more threads than CPUs to run on). +Therefore, the real implementation falls back to a blocking slow path, either +based on pthread mutexes or Linux futexes. + +Reentrancy +^^^^^^^^^^ + +libitm has to consider the following cases of reentrancy: + +* Transaction calls unsafe code that starts a new transaction: The outer + transaction will become a serial transaction before executing unsafe code. + Therefore, nesting within serial transactions must work, even if the nested + transaction is called from within uninstrumented code. + +* Transaction calls either a transactional wrapper or safe code, which in + turn starts a new transaction: It is not yet defined in the specification + whether this is allowed. Thus, it is undefined whether libitm supports this. + +* Code that starts new transactions might be called from within any part + of libitm: This kind of reentrancy would likely be rather complex and can + probably be avoided. Therefore, it is not supported. + +Privatization safety +^^^^^^^^^^^^^^^^^^^^ + +Privatization safety is ensured by libitm using a quiescence-based approach. +Basically, a privatizing transaction waits until all concurrent active +transactions will either have finished (are not active anymore) or operate on +a sufficiently recent snapshot to not access the privatized data anymore. This +happens after the privatizing transaction has stopped being an active +transaction, so waiting for quiescence does not contribute to deadlocks. + +In method groups that need to ensure publication safety explicitly, active +transactions maintain a flag or timestamp in the public/shared part of the +transaction descriptor. Before blocking, privatizers need to let the other +transactions know that they should wake up the privatizer. + +.. todo:: How to implement the waiters? Should those flags be + per-transaction or at a central place? We want to avoid one wake/wait call + per active transactions, so we might want to use either a tree or combining + to reduce the syscall overhead, or rather spin for a long amount of time + instead of doing blocking. Also, it would be good if only the last transaction + that the privatizer waits for would do the wake-up. + +.. _progress-guarantees: + +Progress guarantees +^^^^^^^^^^^^^^^^^^^ + +Transactions that do not make progress when using the current TM method will +eventually try to execute in serial mode. Thus, the serial lock's progress +guarantees determine the progress guarantees of the whole TM. Obviously, we at +least need deadlock-freedom for the serial lock, but it would also be good to +provide starvation-freedom (informally, all threads will finish executing a +transaction eventually iff they get enough cycles). + +However, the scheduling of transactions (e.g., thread scheduling by the OS) +also affects the handling of progress guarantees by the TM. First, the TM +can only guarantee deadlock-freedom if threads do not get stopped. Likewise, +low-priority threads can starve if they do not get scheduled when other +high-priority threads get those cycles instead. + +If all threads get scheduled eventually, correct lock implementations will +provide deadlock-freedom, but might not provide starvation-freedom. We can +either enforce the latter in the TM's lock implementation, or assume that +the scheduling is sufficiently random to yield a probabilistic guarantee that +no thread will starve (because eventually, a transaction will encounter a +scheduling that will allow it to run). This can indeed work well in practice +but is not necessarily guaranteed to work (e.g., simple spin locks can be +pretty efficient). + +Because enforcing stronger progress guarantees in the TM has a higher runtime +overhead, we focus on deadlock-freedom right now and assume that the threads +will get scheduled eventually by the OS (but don't consider threads with +different priorities). We should support starvation-freedom for serial +transactions in the future. Everything beyond that is highly related to proper +contention management across all of the TM (including with TM method to +choose), and is future work. + +**TODO** Handling thread priorities: We want to avoid priority inversion +but it's unclear how often that actually matters in practice. Workloads that +have threads with different priorities will likely also require lower latency +or higher throughput for high-priority threads. Therefore, it probably makes +not that much sense (except for eventual progress guarantees) to use +priority inheritance until the TM has priority-aware contention management. \ No newline at end of file diff --git a/libitm/doc/nesting-flat-vs-closed.rst b/libitm/doc/nesting-flat-vs-closed.rst new file mode 100644 index 00000000000..8b157baed98 --- /dev/null +++ b/libitm/doc/nesting-flat-vs-closed.rst @@ -0,0 +1,28 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Nesting: flat vs. closed +************************ + +We support two different kinds of nesting of transactions. In the case of +*flat nesting*, the nesting structure is flattened and all nested +transactions are subsumed by the enclosing transaction. In contrast, +with *closed nesting*, nested transactions that have not yet committed +can be rolled back separately from the enclosing transactions; when they +commit, they are subsumed by the enclosing transaction, and their effects +will be finally committed when the outermost transaction commits. +*Open nesting* (where nested transactions can commit independently of the +enclosing transactions) are not supported. + +Flat nesting is the default nesting mode, but closed nesting is supported and +used when transactions contain user-controlled aborts +(``__transaction_cancel`` statements). We assume that user-controlled +aborts are rare in typical code and used mostly in exceptional situations. +Thus, it makes more sense to use flat nesting by default to avoid the +performance overhead of the additional checkpoints required for closed +nesting. User-controlled aborts will correctly abort the innermost enclosing +transaction, whereas the whole (i.e., outermost) transaction will be restarted +otherwise (e.g., when a transaction encounters data conflicts during +optimistic execution). \ No newline at end of file diff --git a/libitm/doc/the-libitm-abi.rst b/libitm/doc/the-libitm-abi.rst new file mode 100644 index 00000000000..2340074a4f6 --- /dev/null +++ b/libitm/doc/the-libitm-abi.rst @@ -0,0 +1,27 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _the-libitm-abi: + +The libitm ABI +-------------- + +The ABI provided by libitm is basically equal to the Linux variant of Intel's +current TM ABI specification document (Revision 1.1, May 6 2009) but with the +differences listed in this chapter. It would be good if these changes would +eventually be merged into a future version of this specification. To ease +look-up, the following subsections mirror the structure of this specification. + +.. toctree:: + :maxdepth: 2 + + the-libitm-abi/objectives + the-libitm-abi/non-objectives + the-libitm-abi/library-design-principles + the-libitm-abi/types-and-macros-list + the-libitm-abi/function-list + the-libitm-abi/future-enhancements-to-the-abi + the-libitm-abi/sample-code + the-libitm-abi/memory-model \ No newline at end of file diff --git a/libitm/doc/the-libitm-abi/function-list.rst b/libitm/doc/the-libitm-abi/function-list.rst new file mode 100644 index 00000000000..79cc5d820e5 --- /dev/null +++ b/libitm/doc/the-libitm-abi/function-list.rst @@ -0,0 +1,272 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Function list +************* + +Initialization and finalization functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These functions are not part of the ABI. + +[No changes] Version checking +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +[No changes] Error reporting +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +[No changes] inTransaction call +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +State manipulation functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +There is no ``getTransaction`` function. Transaction identifiers for +nested transactions will be ordered but not necessarily sequential (i.e., for +a nested transaction's identifier :samp:`{IN}` and its enclosing transaction's +identifier :samp:`{IE}`, it is guaranteed that IN >= IE). + +[No changes] Source locations +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Starting a transaction +^^^^^^^^^^^^^^^^^^^^^^ + +.. _txn-code-properties: + +Transaction code properties +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The bit ``hasNoXMMUpdate`` is instead called ``hasNoVectorUpdate``. +Iff it is set, vector register save/restore is not necessary for any target +machine. + +The ``hasNoFloatUpdate`` bit (``0x0010``) is new. Iff it is set, floating +point register save/restore is not necessary for any target machine. + +``undoLogCode`` is not supported and a fatal runtime error will be raised +if this bit is set. It is not properly defined in the ABI why barriers +other than undo logging are not present; Are they not necessary (e.g., a +transaction operating purely on thread-local data) or have they been omitted by +the compiler because it thinks that some kind of global synchronization +(e.g., serial mode) might perform better? The specification suggests that the +latter might be the case, but the former seems to be more useful. + +The ``readOnly`` bit (``0x4000``) is new. + +.. todo:: Lexical or dynamic scope? + +``hasNoRetry`` is not supported. If this bit is not set, but +``hasNoAbort`` is set, the library can assume that transaction +rollback will not be requested. + +It would be useful if the absence of externally-triggered rollbacks would be +reported for the dynamic scope as well, not just for the lexical scope +(``hasNoAbort``). Without this, a library cannot exploit this together +with flat nesting. + +``exceptionBlock`` is not supported because exception blocks are not used. + +[No changes] Windows exception state +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +[No changes] Other machine state +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +[No changes] Results from beginTransaction +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Aborting a transaction +^^^^^^^^^^^^^^^^^^^^^^ + +``_ITM_rollbackTransaction`` is not supported. ``_ITM_abortTransaction`` +is supported but the abort reasons ``exceptionBlockAbort``, +``TMConflict``, and ``userRetry`` are not supported. There are no +exception blocks in general, so the related cases also do not have to be +considered. To encode ``__transaction_cancel [[outer]]``, compilers must +set the new ``outerAbort`` bit (``0x10``) additionally to the +``userAbort`` bit in the abort reason. + +Committing a transaction +^^^^^^^^^^^^^^^^^^^^^^^^ + +The exception handling (EH) scheme is different. The Intel ABI requires the +``_ITM_tryCommitTransaction`` function that will return even when the +commit failed and will have to be matched with calls to either +``_ITM_abortTransaction`` or ``_ITM_commitTransaction``. In contrast, +gcc relies on transactional wrappers for the functions of the Exception +Handling ABI and on one additional commit function (shown below). This allows +the TM to keep track of EH internally and thus it does not have to embed the +cleanup of EH state into the existing EH code in the program. +``_ITM_tryCommitTransaction`` is not supported. +``_ITM_commitTransactionToId`` is also not supported because the +propagation of thrown exceptions will not bypass commits of nested +transactions. + +.. code-block:: c++ + + void _ITM_commitTransactionEH(void *exc_ptr) ITM_REGPARM; + void *_ITM_cxa_allocate_exception (size_t); + void _ITM_cxa_free_exception (void *exc_ptr); + void _ITM_cxa_throw (void *obj, void *tinfo, void (*dest) (void *)); + void *_ITM_cxa_begin_catch (void *exc_ptr); + void _ITM_cxa_end_catch (void); + +The EH scheme changed in version 6 of GCC. Previously, the compiler +added a call to ``_ITM_commitTransactionEH`` to commit a transaction if +an exception could be in flight at this position in the code; ``exc_ptr`` is +the address of the current exception and must be non-zero. Now, the +compiler must catch all exceptions that are about to be thrown out of a +transaction and call ``_ITM_commitTransactionEH`` from the catch clause, +with ``exc_ptr`` being zero. + +Note that the old EH scheme never worked completely in GCC's implementation; +libitm currently does not try to be compatible with the old scheme. + +The ``_ITM_cxa...`` functions are transactional wrappers for the respective +``__cxa...`` functions and must be called instead of these in transactional +code. ``_ITM_cxa_free_exception`` is new in GCC 6. + +To support this EH scheme, libstdc++ needs to provide one additional function +(``_cxa_tm_cleanup``), which is used by the TM to clean up the exception +handling state while rolling back a transaction: + +.. code-block:: c++ + + void __cxa_tm_cleanup (void *unthrown_obj, void *cleanup_exc, + unsigned int caught_count); + +Since GCC 6, ``unthrown_obj`` is not used anymore and always null; +prior to that, ``unthrown_obj`` is non-null if the program called +``__cxa_allocate_exception`` for this exception but did not yet called +``__cxa_throw`` for it. ``cleanup_exc`` is non-null if the program is +currently processing a cleanup along an exception path but has not caught this +exception yet. ``caught_count`` is the nesting depth of +``__cxa_begin_catch`` within the transaction (which can be counted by the TM +using ``_ITM_cxa_begin_catch`` and ``_ITM_cxa_end_catch``); +``__cxa_tm_cleanup`` then performs rollback by essentially performing +``__cxa_end_catch`` that many times. + +Exception handling support +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Currently, there is no support for functionality like +``__transaction_cancel throw`` as described in the C++ TM specification. +Supporting this should be possible with the EH scheme explained previously +because via the transactional wrappers for the EH ABI, the TM is able to +observe and intercept EH. + +[No changes] Transition to serial--irrevocable mode +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +[No changes] Data transfer functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +[No changes] Transactional memory copies +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Transactional versions of memmove +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If either the source or destination memory region is to be accessed +nontransactionally, then source and destination regions must not be +overlapping. The respective ``_ITM_memmove`` functions are still +available but a fatal runtime error will be raised if such regions do overlap. +To support this functionality, the ABI would have to specify how the +intersection of the regions has to be accessed (i.e., transactionally or +nontransactionally). + +[No changes] Transactional versions of memset +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +[No changes] Logging functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +User-registered commit and undo actions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Commit actions will get executed in the same order in which the respective +calls to ``_ITM_addUserCommitAction`` happened. Only +``_ITM_noTransactionId`` is allowed as value for the +``resumingTransactionId`` argument. Commit actions get executed after +privatization safety has been ensured. + +Undo actions will get executed in reverse order compared to the order in which +the respective calls to ``_ITM_addUserUndoAction`` happened. The ordering of +undo actions w.r.t. the roll-back of other actions (e.g., data transfers or +memory allocations) is undefined. + +``_ITM_getThreadnum`` is not supported currently because its only purpose +is to provide a thread ID that matches some assumed performance tuning output, +but this output is not part of the ABI nor further defined by it. + +``_ITM_dropReferences`` is not supported currently because its semantics and +the intention behind it is not entirely clear. The +specification suggests that this function is necessary because of certain +orderings of data transfer undos and the releasing of memory regions (i.e., +privatization). However, this ordering is never defined, nor is the ordering of +dropping references w.r.t. other events. + +[New] Transactional indirect calls +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Indirect calls (i.e., calls through a function pointer) within transactions +should execute the transactional clone of the original function (i.e., a clone +of the original that has been fully instrumented to use the TM runtime), if +such a clone is available. The runtime provides two functions to +register/deregister clone tables: + +.. code-block:: c++ + + struct clone_entry + { + void *orig, *clone; + }; + + void _ITM_registerTMCloneTable (clone_entry *table, size_t entries); + void _ITM_deregisterTMCloneTable (clone_entry *table); + +Registered tables must be writable by the TM runtime, and must be live +throughout the life-time of the TM runtime. + +.. todo:: The intention was always to drop the registration functions + entirely, and create a new ELF Phdr describing the linker-sorted table. Much + like what currently happens for ``PT_GNU_EH_FRAME``. + This work kept getting bogged down in how to represent the :samp:`{N}` different + code generation variants. We clearly needed at least two---SW and HW + transactional clones---but there was always a suggestion of more variants for + different TM assumptions/invariants. + +The compiler can then use two TM runtime functions to perform indirect calls in +transactions: + +.. code-block:: c++ + + void *_ITM_getTMCloneOrIrrevocable (void *function) ITM_REGPARM; + void *_ITM_getTMCloneSafe (void *function) ITM_REGPARM; + +If there is a registered clone for supplied function, both will return a +pointer to the clone. If not, the first runtime function will attempt to switch +to serial--irrevocable mode and return the original pointer, whereas the second +will raise a fatal runtime error. + +[New] Transactional dynamic memory management +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. code-block:: c++ + + void *_ITM_malloc (size_t) + __attribute__((__malloc__)) ITM_PURE; + void *_ITM_calloc (size_t, size_t) + __attribute__((__malloc__)) ITM_PURE; + void _ITM_free (void *) ITM_PURE; + +These functions are essentially transactional wrappers for ``malloc``, +``calloc``, and ``free``. Within transactions, the compiler should +replace calls to the original functions with calls to the wrapper functions. + +libitm also provides transactional clones of C++ memory management functions +such as global operator new and delete. They are part of libitm for historic +reasons but do not need to be part of this ABI. \ No newline at end of file diff --git a/libitm/doc/the-libitm-abi/future-enhancements-to-the-abi.rst b/libitm/doc/the-libitm-abi/future-enhancements-to-the-abi.rst new file mode 100644 index 00000000000..f8fbac355e0 --- /dev/null +++ b/libitm/doc/the-libitm-abi/future-enhancements-to-the-abi.rst @@ -0,0 +1,7 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +[No changes] Future Enhancements to the ABI +******************************************* \ No newline at end of file diff --git a/libitm/doc/the-libitm-abi/library-design-principles.rst b/libitm/doc/the-libitm-abi/library-design-principles.rst new file mode 100644 index 00000000000..7482994f2b1 --- /dev/null +++ b/libitm/doc/the-libitm-abi/library-design-principles.rst @@ -0,0 +1,61 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Library design principles +************************* + +[No changes] Calling conventions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +[No changes] TM library algorithms +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +[No changes] Optimized load and store routines +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +[No changes] Aligned load and store routines +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Data logging functions +^^^^^^^^^^^^^^^^^^^^^^ + +The memory locations accessed with transactional loads and stores and the +memory locations whose values are logged must not overlap. This required +separation only extends to the scope of the execution of one transaction +including all the executions of all nested transactions. + +The compiler must be consistent (within the scope of a single transaction) +about which memory locations are shared and which are not shared with other +threads (i.e., data must be accessed either transactionally or +nontransactionally). Otherwise, non-write-through TM algorithms would not work. + +For memory locations on the stack, this requirement extends to only the +lifetime of the stack frame that the memory location belongs to (or the +lifetime of the transaction, whichever is shorter). Thus, memory that is +reused for several stack frames could be target of both data logging and +transactional accesses; however, this is harmless because these stack frames' +lifetimes will end before the transaction finishes. + +[No changes] Scatter/gather calls +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +[No changes] Serial and irrevocable mode +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +[No changes] Transaction descriptor +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Store allocation +^^^^^^^^^^^^^^^^ + +There is no ``getTransaction`` function. + +[No changes] Naming conventions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Function pointer encryption +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Currently, this is not implemented. \ No newline at end of file diff --git a/libitm/doc/the-libitm-abi/memory-model.rst b/libitm/doc/the-libitm-abi/memory-model.rst new file mode 100644 index 00000000000..f43e2f81df5 --- /dev/null +++ b/libitm/doc/the-libitm-abi/memory-model.rst @@ -0,0 +1,18 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +[New] Memory model +****************** + +The ABI should define a memory model and the ordering that is guaranteed for +data transfers and commit/undo actions, or at least refer to another memory +model that needs to be preserved. Without that, the compiler cannot ensure the +memory model specified on the level of the programming language (e.g., by the +C++ TM specification). + +For example, if a transactional load is ordered before another load/store, then +the TM runtime must also ensure this ordering when accessing shared state. If +not, this might break the kind of publication safety used in the C++ TM +specification. Likewise, the TM runtime must ensure privatization safety. \ No newline at end of file diff --git a/libitm/doc/the-libitm-abi/non-objectives.rst b/libitm/doc/the-libitm-abi/non-objectives.rst new file mode 100644 index 00000000000..b3c558e2394 --- /dev/null +++ b/libitm/doc/the-libitm-abi/non-objectives.rst @@ -0,0 +1,7 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +[No changes] Non-objectives +*************************** \ No newline at end of file diff --git a/libitm/doc/the-libitm-abi/objectives.rst b/libitm/doc/the-libitm-abi/objectives.rst new file mode 100644 index 00000000000..d4c5d460041 --- /dev/null +++ b/libitm/doc/the-libitm-abi/objectives.rst @@ -0,0 +1,7 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +[No changes] Objectives +*********************** \ No newline at end of file diff --git a/libitm/doc/the-libitm-abi/sample-code.rst b/libitm/doc/the-libitm-abi/sample-code.rst new file mode 100644 index 00000000000..c8e9541d810 --- /dev/null +++ b/libitm/doc/the-libitm-abi/sample-code.rst @@ -0,0 +1,10 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Sample code +************ + +The code examples might not be correct w.r.t. the current version of the ABI, +especially everything related to exception handling. \ No newline at end of file diff --git a/libitm/doc/the-libitm-abi/types-and-macros-list.rst b/libitm/doc/the-libitm-abi/types-and-macros-list.rst new file mode 100644 index 00000000000..248c6666497 --- /dev/null +++ b/libitm/doc/the-libitm-abi/types-and-macros-list.rst @@ -0,0 +1,10 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +Types and macros list +********************* + +``_ITM_codeProperties`` has changed, see :ref:`txn-code-properties`. +``_ITM_srcLocation`` is not used. \ No newline at end of file diff --git a/libitm/doc/tm-methods-and-method-groups.rst b/libitm/doc/tm-methods-and-method-groups.rst new file mode 100644 index 00000000000..a9b56197a5b --- /dev/null +++ b/libitm/doc/tm-methods-and-method-groups.rst @@ -0,0 +1,47 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +TM methods and method groups +**************************** + +libitm supports several ways of synchronizing transactions with each other. +These TM methods (or TM algorithms) are implemented in the form of +subclasses of ``abi_dispatch``, which provide methods for +transactional loads and stores as well as callbacks for rollback and commit. +All methods that are compatible with each other (i.e., that let concurrently +running transactions still synchronize correctly even if different methods +are used) belong to the same TM method group. Pointers to TM methods can be +obtained using the factory methods prefixed with ``dispatch_`` in +:samp:`libitm_i.h`. There are two special methods, ``dispatch_serial`` and +``dispatch_serialirr``, that are compatible with all methods because they +run transactions completely in serial mode. + +TM method life cycle +^^^^^^^^^^^^^^^^^^^^ + +The state of TM methods does not change after construction, but they do alter +the state of transactions that use this method. However, because +per-transaction data gets used by several methods, ``gtm_thread`` is +responsible for setting an initial state that is useful for all methods. +After that, methods are responsible for resetting/clearing this state on each +rollback or commit (of outermost transactions), so that the transaction +executed next is not affected by the previous transaction. + +There is also global state associated with each method group, which is +initialized and shut down (``method_group::init()`` and ``fini()``) +when switching between method groups (see :samp:`retry.cc`). + +Selecting the default method +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The default method that libitm uses for freshly started transactions (but +not necessarily for restarted transactions) can be set via an environment +variable (:envvar:`ITM_DEFAULT_METHOD`), whose value should be equal to the name +of one of the factory methods returning abi_dispatch subclasses but without +the "dispatch\_" prefix (e.g., "serialirr" instead of +``GTM::dispatch_serialirr()``). + +Note that this environment variable is only a hint for libitm and might not +be supported in the future. \ No newline at end of file diff --git a/libquadmath/doc/conf.py b/libquadmath/doc/conf.py new file mode 100644 index 00000000000..c3a84b666ca --- /dev/null +++ b/libquadmath/doc/conf.py @@ -0,0 +1,24 @@ +# Configuration file for the Sphinx documentation builder. + +import sys +sys.path.append('../..//doc') + +from baseconf import * + +name = 'libquadmath' +project = 'The GCC Quad-Precision Math Library' +copyright = '2010-2022 Free Software Foundation, Inc.' +authors = 'GCC Developer Community' + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +latex_documents = [ + ('index', f'{name}.tex', project, authors, 'manual'), +] + +texinfo_documents = [ + ('index', name, project, authors, None, None, None, True) +] + +set_common(name, globals()) \ No newline at end of file diff --git a/libquadmath/doc/copyright.rst b/libquadmath/doc/copyright.rst new file mode 100644 index 00000000000..75f73ea6b2c --- /dev/null +++ b/libquadmath/doc/copyright.rst @@ -0,0 +1,18 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the GPL license file + +Copyright +^^^^^^^^^ + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no +Invariant Sections, with the Front-Cover Texts being **A GNU Manual,** +and with the Back-Cover Texts as in (a) below. A copy of the +license is included in the section entitled :ref:`gnu_fdl`. + +(a) The FSF's Back-Cover Text is: + + You have the freedom to copy and modify this GNU manual. \ No newline at end of file diff --git a/libquadmath/doc/gnu-free-documentation-license.rst b/libquadmath/doc/gnu-free-documentation-license.rst new file mode 100644 index 00000000000..089cc682de2 --- /dev/null +++ b/libquadmath/doc/gnu-free-documentation-license.rst @@ -0,0 +1,6 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. include:: ../../doc/gnu_free_documentation_license.rst \ No newline at end of file diff --git a/libquadmath/doc/i-o-library-routines.rst b/libquadmath/doc/i-o-library-routines.rst new file mode 100644 index 00000000000..4f33373f020 --- /dev/null +++ b/libquadmath/doc/i-o-library-routines.rst @@ -0,0 +1,15 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _i-o-library-routines: + +I/O Library Routines +-------------------- + +.. toctree:: + :maxdepth: 2 + + strtoflt128 + quadmathsnprintf \ No newline at end of file diff --git a/libquadmath/doc/index.rst b/libquadmath/doc/index.rst new file mode 100644 index 00000000000..4eb70f9929c --- /dev/null +++ b/libquadmath/doc/index.rst @@ -0,0 +1,23 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +GCC libquadmath +=============== + +.. only:: html + + Contents: + +.. toctree:: + + copyright + introduction + typedef-and-constants + math-library-routines + i-o-library-routines + gnu-free-documentation-license + reporting-bugs + + indices-and-tables \ No newline at end of file diff --git a/libquadmath/doc/indices-and-tables.rst b/libquadmath/doc/indices-and-tables.rst new file mode 100644 index 00000000000..9799e4e2e48 --- /dev/null +++ b/libquadmath/doc/indices-and-tables.rst @@ -0,0 +1 @@ +.. include:: ../../doc/indices-and-tables.rst \ No newline at end of file diff --git a/libquadmath/doc/introduction.rst b/libquadmath/doc/introduction.rst new file mode 100644 index 00000000000..27fa8f26862 --- /dev/null +++ b/libquadmath/doc/introduction.rst @@ -0,0 +1,7 @@ +Introduction +============ + +.. index:: Introduction + +This manual documents the usage of libquadmath, the GCC Quad-Precision +Math Library Application Programming Interface (API). \ No newline at end of file diff --git a/libquadmath/doc/math-library-routines.rst b/libquadmath/doc/math-library-routines.rst new file mode 100644 index 00000000000..78cd8ee1d2d --- /dev/null +++ b/libquadmath/doc/math-library-routines.rst @@ -0,0 +1,104 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _math-library-routines: + +Math Library Routines +--------------------- + +The following mathematical functions are available: + +* :samp:`{acosq}`: arc cosine function +* :samp:`{acoshq}`: inverse hyperbolic cosine function +* :samp:`{asinq}`: arc sine function +* :samp:`{asinhq}`: inverse hyperbolic sine function +* :samp:`{atanq}`: arc tangent function +* :samp:`{atanhq}`: inverse hyperbolic tangent function +* :samp:`{atan2q}`: arc tangent function +* :samp:`{cbrtq}`: cube root function +* :samp:`{ceilq}`: ceiling value function +* :samp:`{copysignq}`: copy sign of a number +* :samp:`{coshq}`: hyperbolic cosine function +* :samp:`{cosq}`: cosine function +* :samp:`{erfq}`: error function +* :samp:`{erfcq}`: complementary error function +* :samp:`{exp2q}`: base 2 exponential function +* :samp:`{expq}`: exponential function +* :samp:`{expm1q}`: exponential minus 1 function +* :samp:`{fabsq}`: absolute value function +* :samp:`{fdimq}`: positive difference function +* :samp:`{finiteq}`: check finiteness of value +* :samp:`{floorq}`: floor value function +* :samp:`{fmaq}`: fused multiply and add +* :samp:`{fmaxq}`: determine maximum of two values +* :samp:`{fminq}`: determine minimum of two values +* :samp:`{fmodq}`: remainder value function +* :samp:`{frexpq}`: extract mantissa and exponent +* :samp:`{hypotq}`: Eucledian distance function +* :samp:`{ilogbq}`: get exponent of the value +* :samp:`{isinfq}`: check for infinity +* :samp:`{isnanq}`: check for not a number +* :samp:`{issignalingq}`: check for signaling not a number +* :samp:`{j0q}`: Bessel function of the first kind, first order +* :samp:`{j1q}`: Bessel function of the first kind, second order +* :samp:`{jnq}`: Bessel function of the first kind, {n}-th order +* :samp:`{ldexpq}`: load exponent of the value +* :samp:`{lgammaq}`: logarithmic gamma function +* :samp:`{llrintq}`: round to nearest integer value +* :samp:`{llroundq}`: round to nearest integer value away from zero +* :samp:`{logbq}`: get exponent of the value +* :samp:`{logq}`: natural logarithm function +* :samp:`{log10q}`: base 10 logarithm function +* :samp:`{log1pq}`: compute natural logarithm of the value plus one +* :samp:`{log2q}`: base 2 logarithm function +* :samp:`{lrintq}`: round to nearest integer value +* :samp:`{lroundq}`: round to nearest integer value away from zero +* :samp:`{modfq}`: decompose the floating-point number +* :samp:`{nanq}`: return quiet NaN +* :samp:`{nearbyintq}`: round to nearest integer +* :samp:`{nextafterq}`: next representable floating-point number +* :samp:`{powq}`: power function +* :samp:`{remainderq}`: remainder function +* :samp:`{remquoq}`: remainder and part of quotient +* :samp:`{rintq}`: round-to-nearest integral value +* :samp:`{roundq}`: round-to-nearest integral value, return {__float128} +* :samp:`{scalblnq}`: compute exponent using {FLT_RADIX} +* :samp:`{scalbnq}`: compute exponent using {FLT_RADIX} +* :samp:`{signbitq}`: return sign bit +* :samp:`{sincosq}`: calculate sine and cosine simultaneously +* :samp:`{sinhq}`: hyperbolic sine function +* :samp:`{sinq}`: sine function +* :samp:`{sqrtq}`: square root function +* :samp:`{tanq}`: tangent function +* :samp:`{tanhq}`: hyperbolic tangent function +* :samp:`{tgammaq}`: true gamma function +* :samp:`{truncq}`: round to integer, towards zero +* :samp:`{y0q}`: Bessel function of the second kind, first order +* :samp:`{y1q}`: Bessel function of the second kind, second order +* :samp:`{ynq}`: Bessel function of the second kind, {n}-th order +* :samp:`{cabsq}`: complex absolute value function +* :samp:`{cargq}`: calculate the argument +* :samp:`{cimagq}`: imaginary part of complex number +* :samp:`{crealq}`: real part of complex number +* :samp:`{cacoshq}`: complex arc hyperbolic cosine function +* :samp:`{cacosq}`: complex arc cosine function +* :samp:`{casinhq}`: complex arc hyperbolic sine function +* :samp:`{casinq}`: complex arc sine function +* :samp:`{catanhq}`: complex arc hyperbolic tangent function +* :samp:`{catanq}`: complex arc tangent function +* :samp:`{ccosq}`: complex cosine function +* :samp:`{ccoshq}`: complex hyperbolic cosine function +* :samp:`{cexpq}`: complex exponential function +* :samp:`{cexpiq}`: computes the exponential function of 'i' times a real value +* :samp:`{clogq}`: complex natural logarithm +* :samp:`{clog10q}`: complex base 10 logarithm +* :samp:`{conjq}`: complex conjugate function +* :samp:`{cpowq}`: complex power function +* :samp:`{cprojq}`: project into Riemann Sphere +* :samp:`{csinq}`: complex sine function +* :samp:`{csinhq}`: complex hyperbolic sine function +* :samp:`{csqrtq}`: complex square root +* :samp:`{ctanq}`: complex tangent function +* :samp:`{ctanhq}`: complex hyperbolic tangent function \ No newline at end of file diff --git a/libquadmath/doc/quadmathsnprintf.rst b/libquadmath/doc/quadmathsnprintf.rst new file mode 100644 index 00000000000..aad0e07e61a --- /dev/null +++ b/libquadmath/doc/quadmathsnprintf.rst @@ -0,0 +1,74 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _quadmath_snprintf: + +quadmath_snprintf --- Convert to string +*************************************** + +The function ``quadmath_snprintf`` converts a ``__float128`` floating-point +number into a string. It is a specialized alternative to ``snprintf``, where +the format string is restricted to a single conversion specifier with ``Q`` +modifier and conversion specifier ``e``, ``E``, ``f``, ``F``, ``g``, +``G``, ``a`` or ``A``, with no extra characters before or after the +conversion specifier. The ``%m$`` or ``*m$`` style must not be used in +the format. + +Syntax: + ``int quadmath_snprintf (char *s, size_t size, const char *format, ...)`` + +Arguments: + .. list-table:: + + * - :samp:`{s}` + - output string + * - :samp:`{size}` + - byte size of the string, including trailing NUL + * - :samp:`{format}` + - conversion specifier string + +Note: + On some targets when supported by the C library hooks are installed + for ``printf`` family of functions, so that ``printf ("%Qe", 1.2Q);`` + etc. works too. + +Example: + .. code-block:: c++ + + #include + #include + #include + + int main () + { + __float128 r; + int prec = 20; + int width = 46; + char buf[128]; + + r = 2.0q; + r = sqrtq (r); + int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, r); + if ((size_t) n < sizeof buf) + printf ("%s\n", buf); + /* Prints: +1.41421356237309504880e+00 */ + quadmath_snprintf (buf, sizeof buf, "%Qa", r); + if ((size_t) n < sizeof buf) + printf ("%s\n", buf); + /* Prints: 0x1.6a09e667f3bcc908b2fb1366ea96p+0 */ + n = quadmath_snprintf (NULL, 0, "%+-#46.*Qe", prec, r); + if (n > -1) + { + char *str = malloc (n + 1); + if (str) + { + quadmath_snprintf (str, n + 1, "%+-#46.*Qe", prec, r); + printf ("%s\n", str); + /* Prints: +1.41421356237309504880e+00 */ + } + free (str); + } + return 0; + } \ No newline at end of file diff --git a/libquadmath/doc/reporting-bugs.rst b/libquadmath/doc/reporting-bugs.rst new file mode 100644 index 00000000000..54532e9e2ff --- /dev/null +++ b/libquadmath/doc/reporting-bugs.rst @@ -0,0 +1,12 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _reporting-bugs: + +Reporting Bugs +-------------- + +Bugs in the GCC Quad-Precision Math Library implementation should be +reported via |bugurl|. \ No newline at end of file diff --git a/libquadmath/doc/strtoflt128.rst b/libquadmath/doc/strtoflt128.rst new file mode 100644 index 00000000000..d0a073d8b04 --- /dev/null +++ b/libquadmath/doc/strtoflt128.rst @@ -0,0 +1,40 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _strtoflt128: + +strtoflt128 --- Convert from string +*********************************** + +The function ``strtoflt128`` converts a string into a +``__float128`` number. + +Syntax: + ``__float128 strtoflt128 (const char *s, char **sp)`` + +Arguments: + .. list-table:: + + * - :samp:`{s}` + - input string + * - :samp:`{sp}` + - the address of the next character in the string + + The argument :samp:`{sp}` contains, if not ``NULL``, the address of the + next character following the parts of the string, which have been read. + +Example: + .. code-block:: c++ + + #include + + int main () + { + __float128 r; + + r = strtoflt128 ("1.2345678", NULL); + + return 0; + } \ No newline at end of file diff --git a/libquadmath/doc/typedef-and-constants.rst b/libquadmath/doc/typedef-and-constants.rst new file mode 100644 index 00000000000..cbd9d7685eb --- /dev/null +++ b/libquadmath/doc/typedef-and-constants.rst @@ -0,0 +1,43 @@ +.. + Copyright 1988-2022 Free Software Foundation, Inc. + This is part of the GCC manual. + For copying conditions, see the copyright.rst file. + +.. _typedef-and-constants: + +Typedef and constants +--------------------- + +The following data type has been defined via ``typedef``. + +* :samp:`{__complex128}`: ``__float128``-based complex number + +The following macros are defined, which give the numeric limits of the +``__float128`` data type. + +* :samp:`{FLT128_MAX}`: largest finite number +* :samp:`{FLT128_MIN}`: smallest positive number with full precision +* :samp:`{FLT128_EPSILON}`: difference between 1 and the next larger representable number +* :samp:`{FLT128_DENORM_MIN}`: smallest positive denormalized number +* :samp:`{FLT128_MANT_DIG}`: number of digits in the mantissa (bit precision) +* :samp:`{FLT128_MIN_EXP}`: maximal negative exponent +* :samp:`{FLT128_MAX_EXP}`: maximal positive exponent +* :samp:`{FLT128_DIG}`: number of decimal digits in the mantissa +* :samp:`{FLT128_MIN_10_EXP}`: maximal negative decimal exponent +* :samp:`{FLT128_MAX_10_EXP}`: maximal positive decimal exponent + +The following mathematical constants of type ``__float128`` are defined. + +* :samp:`{M_Eq}`: the constant e (Euler's number) +* :samp:`{M_LOG2Eq}`: binary logarithm of 2 +* :samp:`{M_LOG10Eq}`: common, decimal logarithm of 2 +* :samp:`{M_LN2q}`: natural logarithm of 2 +* :samp:`{M_LN10q}`: natural logarithm of 10 +* :samp:`{M_PIq}`: pi +* :samp:`{M_PI_2q}`: pi divided by two +* :samp:`{M_PI_4q}`: pi divided by four +* :samp:`{M_1_PIq}`: one over pi +* :samp:`{M_2_PIq}`: one over two pi +* :samp:`{M_2_SQRTPIq}`: two over square root of pi +* :samp:`{M_SQRT2q}`: square root of 2 +* :samp:`{M_SQRT1_2q}`: one over square root of 2 \ No newline at end of file -- 2.39.2