diff options
author | Kito Cheng <kito.cheng@sifive.com> | 2022-09-30 10:05:23 +0800 |
---|---|---|
committer | Kito Cheng <kito.cheng@sifive.com> | 2022-10-24 18:18:30 +0800 |
commit | 97d1ed67fc6a5773c8c00875bfa3616a457cf5f9 (patch) | |
tree | 3a80ead3350a186cd8932fdff8e3a2a365437088 /gcc/common | |
parent | 1e9d9ed095df3d064cf9d91d46f3e5426c2a05a7 (diff) | |
download | gcc-97d1ed67fc6a5773c8c00875bfa3616a457cf5f9.zip gcc-97d1ed67fc6a5773c8c00875bfa3616a457cf5f9.tar.gz gcc-97d1ed67fc6a5773c8c00875bfa3616a457cf5f9.tar.bz2 |
RISC-V: Support --target-help for -mcpu/-mtune
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_tunes): New.
(riscv_get_valid_option_values): New.
(TARGET_GET_VALID_OPTION_VALUES): New.
* config/riscv/riscv-cores.def (RISCV_TUNE): New, define options
for tune here.
(RISCV_CORE): Fix comment.
* config/riscv/riscv.cc (riscv_tune_info_table): Move definition to
riscv-cores.def.
Diffstat (limited to 'gcc/common')
-rw-r--r-- | gcc/common/config/riscv/riscv-common.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index c39ed2e..697bfe4 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -224,6 +224,14 @@ static const riscv_cpu_info riscv_cpu_tables[] = {NULL, NULL, NULL} }; +static const char *riscv_tunes[] = +{ +#define RISCV_TUNE(TUNE_NAME, PIPELINE_MODEL, TUNE_INFO) \ + TUNE_NAME, +#include "../../../config/riscv/riscv-cores.def" + NULL +}; + static const char *riscv_supported_std_ext (void); static riscv_subset_list *current_subset_list = NULL; @@ -1683,6 +1691,41 @@ riscv_compute_multilib ( return xstrdup (multilib_infos[best_match_multi_lib].path.c_str ()); } +vec<const char *> +riscv_get_valid_option_values (int option_code, + const char *prefix ATTRIBUTE_UNUSED) +{ + vec<const char *> v; + v.create (0); + opt_code opt = (opt_code) option_code; + + switch (opt) + { + case OPT_mtune_: + { + const char **tune = &riscv_tunes[0]; + for (;*tune; ++tune) + v.safe_push (*tune); + + const riscv_cpu_info *cpu_info = &riscv_cpu_tables[0]; + for (;cpu_info->name; ++cpu_info) + v.safe_push (cpu_info->name); + } + break; + case OPT_mcpu_: + { + const riscv_cpu_info *cpu_info = &riscv_cpu_tables[0]; + for (;cpu_info->name; ++cpu_info) + v.safe_push (cpu_info->name); + } + break; + default: + break; + } + + return v; +} + #undef TARGET_COMPUTE_MULTILIB #define TARGET_COMPUTE_MULTILIB riscv_compute_multilib #endif @@ -1701,4 +1744,7 @@ static const struct default_options riscv_option_optimization_table[] = #undef TARGET_HANDLE_OPTION #define TARGET_HANDLE_OPTION riscv_handle_option +#undef TARGET_GET_VALID_OPTION_VALUES +#define TARGET_GET_VALID_OPTION_VALUES riscv_get_valid_option_values + struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER; |