#include <vector>
#define INCLUDE_STRING
+#define INCLUDE_SET
+#define INCLUDE_MAP
#include "config.h"
#include "system.h"
#include "coretypes.h"
return v;
}
+const char *
+riscv_arch_help (int, const char **)
+{
+ /* Collect all exts, and sort it in canonical order. */
+ struct extension_comparator {
+ bool operator()(const std::string& a, const std::string& b) const {
+ return subset_cmp(a, b) >= 1;
+ }
+ };
+ std::map<std::string, std::set<unsigned>, extension_comparator> all_exts;
+ for (const riscv_ext_version &ext : riscv_ext_version_table)
+ {
+ if (!ext.name)
+ break;
+ if (ext.name[0] == 'g')
+ continue;
+ unsigned version_value = (ext.major_version * RISCV_MAJOR_VERSION_BASE)
+ + (ext.minor_version
+ * RISCV_MINOR_VERSION_BASE);
+ all_exts[ext.name].insert(version_value);
+ }
+
+ printf("All available -march extensions for RISC-V:\n");
+ printf("\t%-20sVersion\n", "Name");
+ for (auto const &ext_info : all_exts)
+ {
+ printf("\t%-20s\t", ext_info.first.c_str());
+ bool first = true;
+ for (auto version : ext_info.second)
+ {
+ if (first)
+ first = false;
+ else
+ printf(", ");
+ unsigned major = version / RISCV_MAJOR_VERSION_BASE;
+ unsigned minor = (version % RISCV_MAJOR_VERSION_BASE)
+ / RISCV_MINOR_VERSION_BASE;
+ printf("%u.%u", major, minor);
+ }
+ printf("\n");
+ }
+ exit (0);
+}
+
/* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
static const struct default_options riscv_option_optimization_table[] =
{
static int
riscv_ext_version_value (unsigned major, unsigned minor)
{
- return (major * 1000000) + (minor * 1000);
+ return (major * RISCV_MAJOR_VERSION_BASE) + (minor * RISCV_MINOR_VERSION_BASE);
}
/* Implement TARGET_CPU_CPP_BUILTINS. */
riscv_parse_tune (const char *, bool);
const cpu_vector_cost *get_vector_costs ();
+enum
+{
+ RISCV_MAJOR_VERSION_BASE = 1000000,
+ RISCV_MINOR_VERSION_BASE = 1000,
+ RISCV_REVISION_VERSION_BASE = 1,
+};
+
#endif /* ! GCC_RISCV_PROTOS_H */
extern const char *riscv_expand_arch_from_cpu (int argc, const char **argv);
extern const char *riscv_default_mtune (int argc, const char **argv);
extern const char *riscv_multi_lib_check (int argc, const char **argv);
+extern const char *riscv_arch_help (int argc, const char **argv);
# define EXTRA_SPEC_FUNCTIONS \
{ "riscv_expand_arch", riscv_expand_arch }, \
{ "riscv_expand_arch_from_cpu", riscv_expand_arch_from_cpu }, \
{ "riscv_default_mtune", riscv_default_mtune }, \
- { "riscv_multi_lib_check", riscv_multi_lib_check },
+ { "riscv_multi_lib_check", riscv_multi_lib_check }, \
+ { "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.
#undef DRIVER_SELF_SPECS
#define DRIVER_SELF_SPECS \
+"%{march=help:%:riscv_arch_help()} " \
+"%{print-supported-extensions:%:riscv_arch_help()} " \
+"%{-print-supported-extensions:%:riscv_arch_help()} " \
"%{march=*:%:riscv_expand_arch(%*)} " \
"%{!march=*:%{mcpu=*:%:riscv_expand_arch_from_cpu(%*)}} "
-march= Generate code for given RISC-V ISA (e.g. RV64IM). ISA strings must be
lower-case.
+march=help
+Target RejectNegative
+-march=help Print supported -march extensions.
+
+; -print-supported-extensions and --print-supported-extensions are added for
+; clang compatibility.
+print-supported-extensions
+Target Undocumented RejectNegative Alias(march=help)
+
+-print-supported-extensions
+Target Undocumented RejectNegative Alias(march=help)
+
mtune=
Target RejectNegative Joined Var(riscv_tune_string) Save
-mtune=PROCESSOR Optimize the output for PROCESSOR.
@item -march=@var{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}.
+@samp{rv32imaf}. Additionally, a special value @option{help}
+(@option{-march=help}) is accepted to list all supported extensions.
The syntax of the ISA string is defined as follows: