+/* List of Z-class extensions that binutils should know about.
+ Whether or not a particular entry is in this list will
+ dictate if gas/ld will accept its presence in the -march
+ string.
+
+ Example: To add an extension called "Zbb" (bitmanip base extension),
+ add "zbb" string to the list (all lowercase).
+
+ Keep this list alphabetically ordered. */
+
+static const char * const riscv_std_z_ext_strtab[] =
+ {
+ NULL
+ };
+
+/* Same as `riscv_std_z_ext_strtab', but for S-class extensions. */
+
+static const char * const riscv_std_s_ext_strtab[] =
+ {
+ NULL
+ };
+
+/* For the extension EXT, search through the list of known extensions
+ KNOWN_EXTS for a match, and return TRUE if found. */
+
+static bfd_boolean
+riscv_multi_letter_ext_valid_p (const char *ext,
+ const char *const *known_exts)
+{
+ for (size_t i = 0; known_exts[i]; ++i)
+ {
+ if (!strcmp (ext, known_exts[i]))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/* Predicator function for x-prefixed extensions.
+ Anything goes, except the literal 'x'. */
+
+static bfd_boolean
+riscv_ext_x_valid_p (const char *arg)
+{
+ if (!strcasecmp (arg, "x"))
+ return FALSE;
+
+ return TRUE;
+}
+
+/* Predicator functions for z-prefixed extensions.
+ Only known z-extensions are permitted. */
+
+static bfd_boolean
+riscv_ext_z_valid_p (const char *arg)
+{
+ return riscv_multi_letter_ext_valid_p (arg, riscv_std_z_ext_strtab);
+}
+
+/* Predicator function for 's' prefixed extensions.
+ Must be either literal 's', or a known s-prefixed extension. */
+
+static bfd_boolean
+riscv_ext_s_valid_p (const char *arg)
+{
+ return riscv_multi_letter_ext_valid_p (arg, riscv_std_s_ext_strtab);
+}
+
+/* Parsing order that is specified by the ISA manual. */
+
+static const riscv_parse_config_t parse_config[] =
+{
+ {RV_ISA_CLASS_S, "s", riscv_ext_s_valid_p},
+ {RV_ISA_CLASS_Z, "z", riscv_ext_z_valid_p},
+ {RV_ISA_CLASS_X, "x", riscv_ext_x_valid_p},
+ {RV_ISA_CLASS_UNKNOWN, NULL, NULL}
+};
+