<?xml version="1.0"?>
<!DOCTYPE flagsdescription
   SYSTEM "http://www.spec.org/dtd/cpuflags2.dtd"
>

<!-- Lines in this file will be up to this wide =============================================================================== -->


<!-- This flags file is both an example for the SPEC CPU(R) 2026 documentation and a useful flags file for results with AOCC.

     The first three lines at the top must be exactly as shown.  They claim that the file conforms to the DTD (Document Type
     Description) at the listed URL.  Results submitted to SPEC must use a well-formed flags file.  You can check your XML using
     a validating parser such as RXP, https://www.ltg.ed.ac.uk/~richard/rxp.html, also included in your kit as 'specrxp'.  See:
         https://www.spec.org/cpu2026/Docs/utility.html#specrxp.
     Or, you can use an on-line parser, such as: 
         https://www.cogsci.ed.ac.uk/~richard/xml-check.html
         https://validator.w3.org/

     When results are displayed at www.spec.org, the XML file is transformed to HTML (using 'flags_dump', which is on your kit).
     You should ALSO validate the HTML version, which can be done at:
        https://validator.w3.org/
-->

<flagsdescription>

<!-- filename   https://www.spec.org/cpu2026/Docs/flag-description.html#filename
                A complete (.rsf) result includes one or more embedded flags files.  When an embedded flags file is extracted, it 
                will need a name.  The next line tells the tools what name to use when extracting.  -->
<filename>aocc-rev-A2</filename>

<!-- title    https://www.spec.org/cpu2026/Docs/flag-description.html#title
              All flag descriptions MUST have a title.  It'll be used as the page title for the full HTML version, and as for 
              page headings in HTML reports.  -->
<title>AMD Optimizing C/C++ Compiler Suite Flag Descriptions</title>

<style>
    <![CDATA[
    body { background: white; }
    ]]>
</style>

<!-- sw_environment     https://www.spec.org/cpu2026/Docs/flag-description.html#sw_environment
                        Information about shell resources, environment variables, and other software options or installation
                        settings.  They'll be included in both the flags dump and per-result flag report.  As the contents should
                        be HTML, it will save lots of time to just enclose the whole thing in a CDATA section.  See:
                        https://www.spec.org/cpu2026/Docs/flag-description.html#CDATA -->
<sw_environment>
    <![CDATA[
    <p>One or more of the following may have been used in the run.  If so, it will be listed in the notes sections.  Here
        is a brief guide to understanding them:</p>
    <ul>

        <li><p><b><kbd>LD_LIBRARY_PATH=&lt;directories&gt;</kbd></b>  (set via config file <samp>preENV</samp>)
            <br>LD_LIBRARY_PATH controls the search order for libraries.  Often, it can be defaulted.  Sometimes, it is
                explicitly set (as documented in the notes in the submission) in order to ensure that the correct versions of
                libraries are picked up.</p>
        </li>

        <li><p><b><kbd>OMP_STACKSIZE=N</kbd></b> (set via config file <samp>preENV</samp>)
            <br>Set the stack size for subordinate OpenMP threads.</p>
        </li>

        <li><p><b><kbd>ulimit -s N</kbd></b>
            <br><b><kbd>ulimit -s unlimited</kbd></b>
            <br>'ulimit' is a Unix command, entered prior to the run.  It sets the stack size for the main process and its children,
                either to N kbytes or to no limit.</p>
        </li>

    </ul>
    ]]>
</sw_environment>


<!-- header            https://www.spec.org/cpu2026/Docs/flag-description.html#header
                       The header section is entirely optional.  If it is provided, and no class is specified, then it will be
                       inserted verbatim at the top of the flags dump and the per-result flag report.

                       If a class is specified, that text will be inserted verbatim before flags of that class in the flags dump.
                       It is omitted from the per-result flag report.
-->
<header>
    <![CDATA[
    <h2>Compilers: AMD Optimizing C/C++ Compiler Suite</h2>
    ]]>
</header>

<!-- Option splitters ========================================================================================================= -->

<!--
  AOCC allows multiple space-delimited flags to be sent to subsystems, as in
      -fplugin-arg-dragonegg-llvm-option="-enable-iv-split -merge-constant -inline-threshold:1000"
  which causes 3 space-delimited flags to be sent to the DragonEgg LLVM plugin.

  In order to make processing of these compound flags easier, the splitter below will break them up
  into individual flags.  For the example above, this flag will produce

      -fplugin-arg-dragonegg-llvm-option=-enable-iv-split
      -fplugin-arg-dragonegg-llvm-option="-merge-constant -inline-threshold:1000"

  This process is repeated until the compound flag is decomposed into its component parts:

      -fplugin-arg-dragonegg-llvm-option=-enable-iv-split
      -fplugin-arg-dragonegg-llvm-option=-merge-constant
      -fplugin-arg-dragonegg-llvm-option=-inline-threshold:1000
      -fplugin-arg-dragonegg-llvm-option=""

  The final switch is the degenerate case, and this section also contains a flag to consume it and not display it.

  In the regexp that follows,
   $1   (-\S+)         matches "-flag", which is assumed to contain one or more non-whitespace characters
   $2   ([^&quot;"]*)  matches the rest of the quoted string, which may be empty. "&quot;" is for the benefit of the
                       XML parser and expands to a double quote like you'd expect it to.
-->

<flag name="plugin_arg_splitter"
    regexp="-fplugin-arg-dragonegg-llvm-option=&quot;(-\S+)\s*([^&quot;]*)&quot;(?=\s|$)"
    class="optimization"
    >
    <example>Splitter rule for plugin arguments: -fplugin-arg-dragonegg-llvm-option="-flag[ -flag...]"</example>
    <include text="-fplugin-arg-dragonegg-llvm-option=$1" />
    <include text="-fplugin-arg-dragonegg-llvm-option=&quot;$2&quot;" />
    <display enable="0" />
</flag>

<flag name="empty_plugin_arg_eater"
    regexp="-fplugin-arg-dragonegg-llvm-option=&quot;&quot;(?=\s|$)"
    class="optimization"
    >
    <example>Consumer rule for the tail of split up plugin arguments: -fplugin-arg-dragonegg-llvm-option=""</example>
    <display enable="0" />
</flag>

<flag name="aocc-g"
   class="optimization"
   regexp="-g(?:\d)?\b"
   compilers="clang-c,clang-cpp,flang"
   >
   <example>-g</example>
   Produce debugging information.
</flag>


<!-- Optimization flags ======================================================================================================= -->

<flag name="F-O"
    class="optimization"
    >
    <example>-O</example>
    <![CDATA[
    <p>Set the optimization level to <kbd>-O2</kbd>.</p>

    <p>If multiple "O" options are used, with or without level numbers, the last such option is the one that is effective.</p>
    ]]>
    <include flag="F-O2" />
</flag>

<flag name="F-O0"
    class="optimization"
    >
    <example>-O0</example>
    <![CDATA[
    <p>Means "no optimization". This level compiles the fastest and generates the most debuggable code.</p>

    <p>If multiple "O" options are used, with or without level numbers, the last such option is the one that is effective.</p>
    ]]>
    <include flag="F-O0" />
</flag>

<flag name="F-O1"
    class="optimization"
    >
    <example>-O1</example>
    <![CDATA[
    <p>Somewhere between <kbd>-O0</kbd> and <kbd>-O2</kbd>.</p>

    <p>If multiple "O" options are used, with or without level numbers, the last such option is the one that is effective.</p>
    ]]>
</flag>

<flag name="F-O2"
    class="optimization"
    >
    <example>-O2</example>
    <![CDATA[
    <p>Moderate level of optimization which enables most optimizations.  This is the default when no "<kbd>-O</kbd>" option is specified,
        or if no value is specified (i.e. "<kbd>-O</kbd>").</p>

    <p>If multiple "O" options are used, with or without level numbers, the last such option is the one that is effective.</p>
    ]]>
    <include flag="F-O1" />
</flag>

<flag name="F-O3"
    class="optimization"
    >
    <example>-O3</example>
    <![CDATA[
    <p> Like <kbd>-O2</kbd>, except that it enables optimizations that take longer to perform or that may generate larger code (in
        an attempt to make the program run faster).</p>

    <p>If multiple "O" options are used, with or without level numbers, the last such option is the one that is effective.</p>
    ]]>
    <include flag="F-O2" />
</flag>

<flag name="F-Os"
    class="optimization"
    >
    <example>-Os</example>
    <![CDATA[
    <p>Like <kbd>-O2</kbd> with extra optimizations to reduce code size.</p>

    <p>If multiple "O" options are used, with or without level numbers, the last such option is the one that is effective.</p>
    ]]>
    <include flag="F-O2" />
</flag>

<flag name="F-Oz"
    class="optimization"
    >
    <example>-Oz</example>
    <![CDATA[
    <p>Like <kbd>-Os</kbd> (and thus <kbd>-O2</kbd>), but reduces code size further.</p>

    <p>If multiple "O" options are used, with or without level numbers, the last such option is the one that is effective.</p>
    ]]>
    <include flag="F-Os" />
</flag>

<flag name="F-O4"
    class="optimization"
    >
    <example>-O4</example>
    <![CDATA[
    <p>Equivalent to <kbd>-O3</kbd>.</p>

    <p>If multiple "O" options are used, with or without level numbers, the last such option is the one that is effective.</p>
    ]]>
    <include flag="F-O3" />
</flag>

<flag name="aocc-Ofast"
    class="optimization"
    regexp="-Ofast(?=\s|$)"
    >
    <example>-Ofast</example>
    <![CDATA[
    <p>Enables all the optimizations from <kbd>-O3</kbd> along with other aggressive optimizations that may violate strict
        compliance with language standards. Refer to the AOCC options document for the language you're using for more detailed
        documentation of optimizations enabled under <kbd>-Ofast</kbd>.</p>
    ]]>
    <include flag="F-O3" />
</flag>

<flag name="aocc-march"
    class="optimization"
    regexp="-march=(i486|x86-64|native|znver[1-6]|auto)(?=\s|$)"
    >
    <example>-march=znver5</example>
    <![CDATA[
    <p>Specify that Clang should generate code for a specific processor family member and later. For example, if you specify
        <kbd>-march=znver1</kbd>, the compiler is allowed to generate instructions that are valid on AMD Zen processors, but
        which may not exist on earlier products.</p>
    ]]>
</flag>

<flag name="aocc-flto"
    class="optimization"
    regexp="-flto(?=\s|$)"
    >
    <example>-flto</example>
    <![CDATA[
    <p>Enables link-time optimization.  When compiling, it causes output files to be generated in LLVM formats suitable for
        link time optimization. When used with <kbd>-S</kbd> this generates LLVM intermediate language assembly files, otherwise
        this generates LLVM bitcode format object files.  When linking, causes the optimization passes to happen.</p>
    ]]>
</flag>

<flag name="aocc-flto_thin"
    class="optimization"
    regexp="-flto=thin(?=\s|$)"
    >
    <example>-flto=thin</example>
    <![CDATA[
    <p>Enables link-time optimization.  When compiling, it causes output files to be generated in LLVM formats suitable for
        link time optimization. When used with <kbd>-S</kbd> this generates LLVM intermediate language assembly files, otherwise
        this generates LLVM bitcode format object files.  When linking, causes the optimization passes to happen, with as
        much parallelism as the system and the code being optimized will allow.</p>
    ]]>
</flag>

<flag name="aocc-flto_full"
    class="optimization"
    regexp="-flto=full(?=\s|$)"
    >
    <example>-flto=full</example>
    <![CDATA[
    <p>Enables link-time optimization.  When compiling, it causes output files to be generated in LLVM formats suitable for
        link time optimization. When used with <kbd>-S</kbd> this generates LLVM intermediate language assembly files, otherwise
        this generates LLVM bitcode format object files.  When linking, causes the optimization passes to happen.</p>
    ]]>
</flag>


<flag name="F-m64"
    class="optimization"
    >
    <example>-m64</example>
    <![CDATA[
    <p>Generate code for a 64-bit environment. The 64-bit environment sets <kbd>int</kbd> to 32 bits and <kbd>long</kbd> and
        <kbd>pointer</kbd> to 64 bits and generates code for AMD's x86-64 architecture. The compiler generates AMD64, INTEL64,
        x86-64 64-bit ABI. The default on a 32-bit host is 32-bit ABI. The default on a 64-bit host is 64-bit ABI if the target
        platform specified is 64-bit, otherwise the default is 32-bit.</p>
    ]]>
</flag>

<flag name="aocc-ffast-math"
    class="optimization"
    regexp="-ffast-math(?=\s|$)"
    >
    <example>-ffast-math</example>
    <![CDATA[
    <p>Enables a range of optimizations that provide faster, though sometimes less precise, mathematical operations that may
        not conform to the IEEE-754 specifications. When this option is specified, the <kbd>__STDC_IEC_559__</kbd> macro is
        ignored even if set by the system headers.</p>
    ]]>
</flag>

<flag name="F-Kieee"
    class="optimization"
    >
    <example>-Kieee</example>
    <![CDATA[
    <p>Instructs the compiler to conform to the IEEE-754 specifications.
        The compiler will perform floating-point operations in strict conformance with the IEEE-754 standard.
        Some optimizations are disabled when this option is specified.</p>
    ]]>
</flag>


<flag name="aocc-muldefs"
    class="optimization"
    regexp="-z\s+muldefs(?=\s|$)"
    >
    <example>-z muldefs</example>
    <![CDATA[
    <p>Instructs the linker to use the first definition encountered for a symbol, and ignore all others.</p>
    ]]>
</flag>


<flag name="F-lflang"
    class="optimization"
    >
    <example>-lflang</example>
    <![CDATA[
    <p>Instructs the compiler to link with flang Fortran runtime libraries.</p>
    ]]>
</flag>

<flag name="F-fgnu89-inline"
    class="optimization"
    >
    <example>-fgnu89-inline</example>
    <![CDATA[
    <p>This option causes Clang to revert to the same inlining behavior that GCC does when in pre-C99 mode.</p>
    ]]>
</flag>

<flag name="std-c"
    class="optimization"
    regexp="-std=(?:c|gnu)(?:89|99|11|17|18)(?=\s|$)"
    >
    <example>-std=gnu89</example>
    <![CDATA[
    <p>Selects the C language dialect.</p>
    ]]>
</flag>

<flag name="std-cpp"
   class="optimization"
   regexp="-std=c\+\+(?:98|03|11|14|17|2a)(?=\s|$)"
   >
   <example>-std=c++98</example>
   <![CDATA[
   <p>Selects the C++ language dialect.</p>
   ]]>
</flag>

<flag name="std-f"
   class="optimization"
   regexp="-std=f(?:95|2003|2008|2018|2023)(?=\s|$)"
   >
   <example>-std=f2008</example>
   <![CDATA[
   <p>Selects the Fortran language dialect.</p>
   ]]>
</flag>

<flag name="aocc-fopenmp"
   class="optimization"
   regexp="-fopenmp(?=\s|$)"
   parallel="yes"
   >
   Enables handling of OpenMP directives and generation of parallel code.
</flag>

<flag name="F-pthread"
   class="optimization"
   >
   <![CDATA[<p>
      Enable support for Posix Threads.  Note that C++ programs using std::thread may require this flag.
   </p>]]>
</flag>

<!-- Portability flags ======================================================================================================== -->

<flag name="aocc-no-fast-math"
    class="portability"
    regexp="-fno-fast-math(?=\s|$)"
    >
    <example>-fno-fast-math</example>
    <![CDATA[
    <p>Do not allow any optimizations that provide faster, though sometimes less precise, mathematical operations that may
        not conform to the IEEE-754 specifications. Disables <kbd>-ffast-math</kbd> optimizations.
    </p>
    ]]>
</flag>

<flag name="aocc-no-finite-math-only"
    class="portability"
    regexp="-fno-finite-math-only(?=\s|$)"
    >
    <example>-fno-finite-math-only</example>
    <![CDATA[<p><kbd>-ffinite-math-only</kbd>, which is implied by <kbd>-ffast-math</kbd> and <kbd>-Ofast</kbd>, allows
        optimizations for floating-point arithmetic that assume that arguments and results are not NaNs or +-Infs.
        Setting <kbd>-fno-finite-math-only</kbd> does the opposite: the compiler must prepare for the possible presence of
        NaNs and infinities.
    </p>]]>
</flag>

<flag name="aocc-no-associative-math"
    class="portability"
    regexp="-fno-associative-math(?=\s|$)"
    >
    <example>-fno-associative-math</example>
    <![CDATA[
    <p><kbd>-fassociative-math</kbd> allows the compiler to reassociate floating-point expressions.
        This means the compiler may change the grouping of operations (for example, transforming
        <code>(a + b) + c</code> into <code>a + (b + c)</code>) in order to enable better optimization.
        Such transformations may change numerical results due to rounding differences.</p>

    <p>This option is implied by <kbd>-ffast-math</kbd> and <kbd>-Ofast</kbd>.
        Using <kbd>-fno-associative-math</kbd> preserves strict evaluation order and IEEE-compliant
        rounding behavior.</p>
    ]]>
</flag>

<flag name="aocc-no-reciprocal-math"
    class="portability"
    regexp="-fno-reciprocal-math(?=\s|$)"
    >
    <example>-fno-reciprocal-math</example>
    <![CDATA[
    <p><kbd>-freciprocal-math</kbd> allows the compiler to replace floating-point division operations
        with multiplication by a reciprocal (for example, replacing <code>x / y</code> with
        <code>x * (1.0 / y)</code>). This can significantly improve performance on some architectures,
        but may reduce numerical accuracy.</p>

    <p>This option is implied by <kbd>-ffast-math</kbd> and <kbd>-Ofast</kbd>.
        Using <kbd>-fno-reciprocal-math</kbd> forces the compiler to preserve exact division semantics.</p>
    ]]>
</flag>

<flag name="aocc-fno-unsafe-math-optimizations"
    regexp="-fno-unsafe-math-optimizations(?=\s|$)"
    class="portability">
    <![CDATA[
    <p> Disables a range of optimizations that provide faster, though sometimes
        less precise, mathematical operations.</p>
    <p>A SPEC CPU config file might use this flag in combination with -Ofast, to specify that all the optimizations of
        -Ofast are desired, with the exception of -ffast-math.</p>
    ]]>
</flag>

<flag name="F-mbyteswapio"
    class="portability"
    regexp="-Mbyteswapio(?=\s|$)"
    >
    <example>"-Mbyteswapio"</example>
    <![CDATA[
    <p>  Swap bytes from big-endian to little-endian or vice versa on
         input/output of unformatted FORTRAN data. </p>
    ]]>
</flag>

<flag name="aocc-unsigned-char"
    class="portability"
    regexp="-funsigned-char(?=\s|$)"
    >
    <example>-funsigned-char</example>
    <![CDATA[
    <p>This option instructs the compiler to treat char type as unsigned.</p>
    ]]>
</flag>


<!-- Flags that identify the compiler being used ============================================================================== -->

<flag name="compiler_path_eater"
    class="compiler"
    regexp="/\S+/(CC|g(cc|\+\+)|c(c|\+\+)|FC|gfortran|clang(\+\+)?|flang|f90)(?=\s|$)"
    >
    <example>/path/to/{clang|clang++|flang|gfortran}</example>
    This flag is just to trim the path from the compiler line.
    <include text="$1"/>
    <display enable="0"/>
</flag>

<flag name="clang-c"
    class="compiler"
    regexp="\bclang(?=\s|$)"
    >
    <example>clang</example>
    <![CDATA[
    <p>clang is a C compiler which encompasses preprocessing, parsing, optimization, code generation, assembly, and linking.
        Depending on which high-level mode setting is passed, Clang will stop before doing a full link.</p>
    ]]>
</flag>

<flag name="clang-cpp"
    class="compiler"
    regexp="\bclang\+\+(?=\s|$)"
    >
    <example>clang++</example>
    <![CDATA[
    <p>clang++ is a C++ compiler which encompasses preprocessing, parsing, optimization, code generation, assembly, and linking.
        Depending on which high-level mode setting is passed, Clang will stop before doing a full link.</p>
    ]]>
</flag>

<flag name="flang"
    class="compiler"
    regexp="\bflang(?=\s|$)"
    >
    <example>flang</example>
    <![CDATA[
    <p>flang is a Fortran compiler which encompasses parsing, optimization, code generation, assembly, and linking. Depending on
        which high-level mode setting is passed, Flang will stop before doing a full link.</p>
    ]]>
</flag>


<!-- "Other" flags ============================================================================================================ -->

<flag name="Link_path"
    class="other"
    regexp="-L\s*\S+(?=\s|$)"
    >
    <example>-L/path/to/libs</example>
    <![CDATA[
    <p>Specifies a directory to search for libraries. Use <kbd>-L</kbd> to add directories to the search path for library
        files.  Multiple <kbd>-L</kbd> options are valid. However, the position of multiple <kbd>-L</kbd> options is important
        relative to <kbd>-l</kbd> options supplied.</p>
    ]]>
</flag>

<flag name="Include_path"
    class="other"
    regexp="-I\s*\S+(?=\s|$)"
    >
    <example>-I /path/to/include</example>
    <![CDATA[
    <p>Specifies a directory to search for include files. Use <kbd>-I</kbd> to add directories to the search path for include
        files.  Multiple <kbd>-I</kbd> options are valid.</p>
    ]]>
</flag>

<flag name="F-DUSE_OPENMP"
    class="other"
    >
    <example>-DUSE_OPENMP</example>
    <![CDATA[
    <p>Switch to enable OpenMP.</p>
    ]]>
</flag>


<!-- vim: set ai filetype=xml syntax=xml expandtab nosmarttab ts=8 sw=4 colorcolumn=132: -->
</flagsdescription>
