]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/config/riscv/riscv.h
RISC-V: Add support for -mcpu option.
authorKito Cheng <kito.cheng@sifive.com>
Tue, 13 Oct 2020 07:07:21 +0000 (15:07 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Thu, 15 Oct 2020 03:12:39 +0000 (11:12 +0800)
commit72eb8335848be77649ac1c5229b8c26352ab8949
tree0e37516358d838fad0ff170d9e98d863be23e7e2
parent83927c63897ec25b2efb5dac58f20a0561d28f26
RISC-V: Add support for -mcpu option.

 - The behavior of -mcpu basically equal to -march plus -mtune, but it
   has lower priority than -march and -mtune.

 - The behavior and available options has sync with clang except we don't add
   few LLVM specific value, and add more sifive processor to the list.

 - -mtune also accept all available options of -mcpu, and use it setting.

gcc/ChangeLog:

* common/config/riscv/riscv-common.c (riscv_cpu_tables): New.
(riscv_arch_str): Return empty string if current_subset_list
is NULL.
(riscv_find_cpu): New.
(riscv_handle_option): Verify option value of -mcpu.
(riscv_expand_arch): Using std::string.
(riscv_default_mtune): New.
(riscv_expand_arch_from_cpu): Ditto.
* config/riscv/riscv-cores.def: New.
* config/riscv/riscv-protos.h (riscv_find_cpu): New.
(riscv_cpu_info): New.
* config/riscv/riscv.c (riscv_tune_info): Rename ...
(riscv_tune_param): ... to this.
(riscv_cpu_info): Rename ...
(riscv_tune_info): ... to this.
(tune_info): Rename ...
(tune_param): ... to this.
(rocket_tune_info): Update data type name.
(sifive_7_tune_info): Ditto.
(optimize_size_tune_info): Ditto.
(riscv_cpu_info_table): Rename ...
(riscv_tune_info_table): ... to this.
(riscv_parse_cpu): Rename ...
(riscv_parse_tune): ... to this, and translate valid -mcpu option to
-mtune option.
(riscv_rtx_costs): Rename tune_info to tune_param.
(riscv_class_max_nregs): Ditto.
(riscv_memory_move_cost): Ditto.
(riscv_init_machine_status): Use value of -mcpu if -mtune is not
given, and rename tune_info to tune_param.
* config/riscv/riscv.h (riscv_expand_arch_from_cpu): New.
(riscv_default_mtune): Ditto.
(EXTRA_SPEC_FUNCTIONS): Add riscv_expand_arch_from_cpu and
riscv_default_mtune.
(OPTION_DEFAULT_SPECS): Handle default value of -march/-mabi.
(DRIVER_SELF_SPECS): Expand -march from -mcpu if -march is not
given.
* config/riscv/riscv.opt (-mcpu): New option.
* config/riscv/t-riscv ($(common_out_file)): Add
riscv-cores.def to dependency.
* doc/invoke.texi (RISC-V Option): Add -mcpu, and update the
description of default value for -mtune and -march.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/mcpu-1.c: New.
* gcc.target/riscv/mcpu-2.c: Ditto.
* gcc.target/riscv/mcpu-3.c: Ditto.
* gcc.target/riscv/mcpu-4.c: Ditto.
* gcc.target/riscv/mcpu-5.c: Ditto.
* gcc.target/riscv/mcpu-6.c: Ditto.
* gcc.target/riscv/mcpu-7.c: Ditto.
15 files changed:
gcc/common/config/riscv/riscv-common.c
gcc/config/riscv/riscv-cores.def [new file with mode: 0644]
gcc/config/riscv/riscv-protos.h
gcc/config/riscv/riscv.c
gcc/config/riscv/riscv.h
gcc/config/riscv/riscv.opt
gcc/config/riscv/t-riscv
gcc/doc/invoke.texi
gcc/testsuite/gcc.target/riscv/mcpu-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/mcpu-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/mcpu-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/mcpu-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/mcpu-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/mcpu-6.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/mcpu-7.c [new file with mode: 0644]