]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Prohibit combination of 'E' and 'H'
authorTsukasa OI <research_trasio@irq.a4lg.com>
Sat, 21 Oct 2023 04:28:21 +0000 (04:28 +0000)
committerTsukasa OI <research_trasio@irq.a4lg.com>
Sun, 22 Oct 2023 02:21:05 +0000 (02:21 +0000)
According to the ratified privileged specification (version 20211203),
it says:

> The hypervisor extension depends on an "I" base integer ISA with 32 x
> registers (RV32I or RV64I), not RV32E, which has only 16 x registers.

Also in the latest draft, it also prohibits RV64E with the 'H' extension.
This commit prohibits the combination of 'E' and 'H' extensions.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc (riscv_subset_list::parse):
Prohibit 'E' and 'H' combinations.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-26.c: New test.

gcc/common/config/riscv/riscv-common.cc
gcc/testsuite/gcc.target/riscv/arch-26.c [new file with mode: 0644]

index 860c8521b7b68b2f89c3a5992eb8f5f46cc7c311..526dbb7603be1f7f323dc08bea71ddd8f006056d 100644 (file)
@@ -1495,6 +1495,10 @@ riscv_subset_list::parse (const char *arch, location_t loc)
     error_at (loc, "%<-march=%s%>: z*inx conflicts with floating-point "
                   "extensions", arch);
 
+  /* 'H' hypervisor extension requires base ISA with 32 registers.  */
+  if (subset_list->lookup ("e") && subset_list->lookup ("h"))
+    error_at (loc, "%<-march=%s%>: h extension requires i extension", arch);
+
   return subset_list;
 
 fail:
diff --git a/gcc/testsuite/gcc.target/riscv/arch-26.c b/gcc/testsuite/gcc.target/riscv/arch-26.c
new file mode 100644 (file)
index 0000000..0b48bc9
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv32eh -mabi=ilp32e" } */
+int foo() {}
+/* { dg-error "'-march=rv32eh': h extension requires i extension" "" { target *-*-* } 0 } */