]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Support --with-cpu
authorCharlie Jenkins <charlie@rivosinc.com>
Wed, 26 Nov 2025 19:29:51 +0000 (11:29 -0800)
committerKito Cheng <kito.cheng@sifive.com>
Fri, 28 Nov 2025 09:14:31 +0000 (17:14 +0800)
The --with-cpu will allow riscv compilers to have a default mcpu flag.
Setting -mcpu or -march at compile time will override the configured
--with-cpu.

gcc/ChangeLog:

* config.gcc: Add cpu to supported configure options
* config/riscv/riscv.h (riscv_arch_help): Use --with-cpu during
compilation
* doc/install.texi: Mention in docs that --with-cpu is supported

gcc/config.gcc
gcc/config/riscv/riscv.h
gcc/doc/install.texi

index 6ac00ebdcb307c939fbcadaa6cb4694c9998aa55..7035542639696ec6908914eab5520b5f824abbe0 100644 (file)
@@ -4753,7 +4753,7 @@ case "${target}" in
                ;;
 
        riscv*-*-*)
-               supported_defaults="abi arch tune riscv_attribute isa_spec tls cmodel"
+               supported_defaults="abi arch cpu tune riscv_attribute isa_spec tls cmodel"
 
                case "${target}" in
                riscv-* | riscv32*) xlen=32 ;;
index a0ad75c765a14c13188c8390cc33df2c743665dc..6a3e5372d3b52dbee045ed9699e34cc056633893 100644 (file)
@@ -60,17 +60,18 @@ extern const char *riscv_arch_help (int argc, const char **argv);
   { "riscv_arch_help", riscv_arch_help },
 
 /* Support for a compile-time default CPU, et cetera.  The rules are:
-   --with-arch is ignored if -march or -mcpu is specified.
+   --with-arch and --with-cpu are ignored if -march or -mcpu is specified.
    --with-abi is ignored if -mabi is specified.
    --with-tune is ignored if -mtune or -mcpu is specified.
    --with-isa-spec is ignored if -misa-spec is specified.
    --with-tls is ignored if -mtls-dialect is specified.
 
-   But using default -march/-mtune value if -mcpu don't have valid option.  */
+   Uses default values if -mcpu doesn't have a valid option.  */
 #define OPTION_DEFAULT_SPECS \
   {"tune", "%{!mtune=*:"                                               \
           "  %{!mcpu=*:-mtune=%(VALUE)}"                               \
           "  %{mcpu=*:-mtune=%:riscv_default_mtune(%* %(VALUE))}}" },  \
+  {"cpu", "%{!march=*:%{!mcpu=*:%:riscv_expand_arch_from_cpu(%(VALUE))}}" }, \
   {"arch", "%{!march=*|march=unset:"                                   \
           "  %{!mcpu=*:-march=%(VALUE)}"                               \
           "  %{mcpu=*:%:riscv_expand_arch_from_cpu(%* %(VALUE))}}" },  \
index 437e4636db338dff067f85dd7e556a2ee09ea521..7f4321c424b9cf14dfe907725e9478e0a0685a28 100644 (file)
@@ -1687,10 +1687,10 @@ not use transactional memory.
 Specify which cpu variant the compiler should generate code for by default.
 @var{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@.
+PowerPC, RISC-V, 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@.
 
 @item --with-schedule=@var{cpu}
 @itemx --with-arch=@var{cpu}