static const char *riscv_supported_std_ext (void);
+bool riscv_subset_list::parse_failed = false;
+
static riscv_subset_list *current_subset_list = NULL;
const riscv_subset_list *riscv_current_subset_list ()
}
}
+/* Return true if EXT is a standard extension. */
+
+static bool
+standard_extensions_p (const char *ext)
+{
+ const riscv_ext_version *ext_ver;
+ for (ext_ver = &riscv_ext_version_table[0]; ext_ver->name != NULL; ++ext_ver)
+ if (strcmp (ext, ext_ver->name) == 0)
+ return true;
+ return false;
+}
+
/* Add new subset to list. */
void
return;
}
+ else if (strlen (subset) == 1 && !standard_extensions_p (subset))
+ {
+ error_at (m_loc,
+ "%<-march=%s%>: extension %qs is unsupported standard single "
+ "letter extension",
+ m_arch, subset);
+ return;
+ }
+ else if (subset[0] == 'z' && !standard_extensions_p (subset))
+ {
+ error_at (m_loc,
+ "%<-march=%s%>: extension %qs starts with `z` but is "
+ "unsupported standard extension",
+ m_arch, subset);
+ return;
+ }
+ else if (subset[0] == 's' && !standard_extensions_p (subset))
+ {
+ error_at (m_loc,
+ "%<-march=%s%>: extension %qs starts with `s` but is "
+ "unsupported standard supervisor extension",
+ m_arch, subset);
+ return;
+ }
+ else if (subset[0] == 'x' && !standard_extensions_p (subset))
+ {
+ error_at (m_loc,
+ "%<-march=%s%>: extension %qs starts with `x` but is "
+ "unsupported non-standard extension",
+ m_arch, subset);
+ return;
+ }
riscv_subset_t *s = new riscv_subset_t ();
riscv_subset_t *itr;
while (*std_exts && std_ext != *std_exts)
std_exts++;
- if (std_ext != *std_exts)
- {
- if (strchr (all_std_exts, std_ext) == NULL)
- error_at (m_loc, "%<-march=%s%>: unsupported ISA subset %<%c%>",
- m_arch, *p);
- else
- error_at (m_loc,
- "%<-march=%s%>: ISA string is not in canonical order. "
- "%<%c%>", m_arch, *p);
- return NULL;
- }
+ subset[0] = std_ext;
+ if (std_ext != *std_exts && standard_extensions_p (subset))
+ error_at (m_loc,
+ "%<-march=%s%>: ISA string is not in canonical order. "
+ "%<%c%>",
+ m_arch, *p);
std_exts++;
p++;
- subset[0] = std_ext;
p = parsing_subset_version (subset, p, &major_version, &minor_version,
/* std_ext_p= */ true, &explicit_version_p);
riscv_subset_list *
riscv_subset_list::parse (const char *arch, location_t loc)
{
+ if (riscv_subset_list::parse_failed)
+ return NULL;
+
riscv_subset_list *subset_list = new riscv_subset_list (arch, loc);
riscv_subset_t *itr;
const char *p = arch;
fail:
delete subset_list;
+ riscv_subset_list::parse_failed = true;
return NULL;
}
/* Subset list. */
class riscv_subset_list
{
+public:
+ /* Because the parse method is called in several places, to prevent repeated
+ errors, use this flag to prevent it from repeating parse. */
+ static bool parse_failed;
+
private:
/* Original arch string. */
const char *m_arch;
/* { dg-do compile } */
-/* { dg-options "-march=rv32ixabc_xfoo -mabi=ilp32" } */
+/* { dg-options "-march=rv32ixtheadba_xtheadsync -mabi=ilp32" } */
int foo()
{
}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gvcw_zvl128_s123_x123 -mabi=lp64d" } */
+int foo()
+{
+}
+
+/* { dg-error "ISA string is not in canonical order. 'c'" "" { target *-*-* } 0 } */
+/* { dg-error "extension 'w' is unsupported standard single letter extension" "" { target *-*-* } 0 } */
+/* { dg-error "extension 'zvl' starts with `z` but is unsupported standard extension" "" { target *-*-* } 0 } */
+/* { dg-error "extension 's123' starts with `s` but is unsupported standard supervisor extension" "" { target *-*-* } 0 } */
+/* { dg-error "extension 'x123' starts with `x` but is unsupported non-standard extension" "" { target *-*-* } 0 } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gvcw_zvl128_s123_x123 -mabi=lp64d" } */
+int foo()
+{
+}
+
+/* { dg-error "ISA string is not in canonical order. 'c'" "" { target *-*-* } 0 } */
+/* { dg-error "extension 'w' is unsupported standard single letter extension" "" { target *-*-* } 0 } */
+/* { dg-error "extension 'zvl' starts with `z` but is unsupported standard extension" "" { target *-*-* } 0 } */
+/* { dg-error "extension 's123' starts with `s` but is unsupported standard supervisor extension" "" { target *-*-* } 0 } */
+/* { dg-error "extension 'x123' starts with `x` but is unsupported non-standard extension" "" { target *-*-* } 0 } */
/* { dg-do compile } */
-/* { dg-options "-march=rv32isabc_xbar -mabi=ilp32" } */
+/* { dg-options "-march=rv32isvinval_xtheadba -mabi=ilp32" } */
int foo()
{
}
/* { dg-do compile } */
-/* { dg-options "-march=rv32i_zfoo_sabc_xbar -mabi=ilp32" } */
+/* { dg-options "-march=rv32i_zmmul_svnapot_xtheadba -mabi=ilp32" } */
int foo()
{
}
/* { dg-do compile } */
-/* { dg-options "-march=rv32id_zicsr_zifence -mabi=ilp32" } */
+/* { dg-options "-march=rv32id_zicsr_zifencei -mabi=ilp32" } */
int foo()
{
}
/* { dg-do compile } */
-/* { dg-options "-march=rv32i -march=rv32im_sx_unexpectedstring -mabi=ilp32" } */
+/* { dg-options "-march=rv32i -march=rv32im_svnapot_unexpectedstring -mabi=ilp32" } */
int foo()
{
}
/* { dg-do compile } */
-/* { dg-options "-mriscv-attribute -march=rv64imafdcp -mabi=lp64d -misa-spec=2.2" } */
+/* { dg-options "-mriscv-attribute -march=rv64imafdc -mabi=lp64d -misa-spec=2.2" } */
int foo() {}
-/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0_p\"" } } */
+/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0\"" } } */
/* { dg-do compile } */
-/* { dg-options "-mriscv-attribute -march=rv64imp0p9 -mabi=lp64 -misa-spec=2.2" } */
+/* { dg-options "-mriscv-attribute -march=rv64im -mabi=lp64 -misa-spec=2.2" } */
int foo() {}
-/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p0_m2p0_p0p9\"" } } */
+/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p0_m2p0\"" } } */
/* { dg-do compile } */
-/* { dg-options "-mriscv-attribute -march=rv32i2p0xabc_xv5 -mabi=ilp32" } */
+/* { dg-options "-mriscv-attribute -march=rv32i2p0xtheadba_xtheadbb -mabi=ilp32" } */
int foo()
{
}
-/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p0_xabc_xv5p0\"" } } */
+/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p0_xtheadba1p0_xtheadbb1p0\"" } } */
/* { dg-do compile } */
-/* { dg-options "-mriscv-attribute -march=rv32i2p0sabc_xbar -mabi=ilp32e" } */
+/* { dg-options "-mriscv-attribute -march=rv32i2p0svinval_xtheadba -mabi=ilp32e" } */
int foo()
{
}
-/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p0_sabc_xbar\"" } } */
+/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p0_svinval1p0_xtheadba1p0\"" } } */
int foo()
{
}
+
+/* { dg-error "extension 'zb' starts with `z` but is unsupported standard extension" "" { target *-*-* } 0 } */