@@ -6833,6 +6833,7 @@ riscv_asm_output_opcode (FILE *asm_out_file, const char *p)
'S' Print shift-index of single-bit mask OP.
'T' Print shift-index of inverted single-bit mask OP.
'~' Print w if TARGET_64BIT is true; otherwise not print anything.
+ 'N' Print register encoding as integer (0-31).
Note please keep this list and the list in riscv.md in sync. */
@@ -7079,6 +7080,28 @@ riscv_print_operand (FILE *file, rtx op, int letter)
output_addr_const (file, newop);
break;
}
+ case 'N':
+ {
+ if (!REG_P(op))
+ {
+ output_operand_lossage ("modifier 'N' require register operand");
+ break;
+ }
+
+ unsigned regno = REGNO (op);
+ unsigned offset = 0;
+ if (IN_RANGE (regno, GP_REG_FIRST, GP_REG_LAST))
+ offset = GP_REG_FIRST;
+ else if (IN_RANGE (regno, FP_REG_FIRST, FP_REG_LAST))
+ offset = FP_REG_FIRST;
+ else if (IN_RANGE (regno, V_REG_FIRST, V_REG_LAST))
+ offset = V_REG_FIRST;
+ else
+ output_operand_lossage ("invalid register number for 'N' modifie");
+
+ asm_fprintf (file, "%u", (regno - offset));
+ break;
+ }
default:
switch (code)
{
@@ -12586,6 +12586,7 @@ The list below describes the supported modifiers and their effects for RISC-V.
@headitem Modifier @tab Description
@item @code{z} @tab Print ''@code{zero}'' instead of 0 if the operand is an immediate with a value of zero.
@item @code{i} @tab Print the character ''@code{i}'' if the operand is an immediate.
+@item @code{N} @tab Print the register encoding as integer (0 - 31).
@end multitable
@anchor{shOperandmodifiers}
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64if -mabi=lp64" } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+void foo() {
+/*
+** foo:
+** ...
+** fadd.s\s*ft0,\s*8,\s*9
+** ...
+*/
+ register float fs0 __asm__ ("fs0");
+ register float fs1 __asm__ ("fs1");
+ __asm__ volatile("fadd.s ft0, %N0, %N1" : : "f" (fs0), "f" (fs1) : "memory");
+}
new file mode 100644
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gv -mabi=lp64" } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+#pragma riscv intrinsic "vector"
+
+void foo() {
+/*
+** foo:
+** ...
+** vadd.vv\s*v0,\s*1,\s*2
+** ...
+*/
+ register vint32m1_t v1 __asm__ ("v1");
+ register vint32m1_t v2 __asm__ ("v2");
+ __asm__ volatile("vadd.vv v0, %N0, %N1" : : "vr" (v1), "vr" (v2) : "memory");
+}
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+
+void foo() {
+/*
+** foo:
+** ...
+** addi\s*t0,\s*9,\s*4
+** ...
+*/
+ register int s1 __asm__ ("s1");
+ register int tp __asm__ ("tp");
+ __asm__ volatile("addi t0, %N0, %N1" : : "r" (s1), "r" (tp) : "memory");
+}