shithub: riscv

Download patch

ref: e2224a90bb2455993363efe52e005b2fe9c78cdd
parent: 1446861bcaf14342e2a1d4914b001025ab3fa80f
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat Sep 2 16:33:44 EDT 2023

7l: support fmov between general and fp registers

--- a/sys/src/cmd/7l/asmout.c
+++ b/sys/src/cmd/7l/asmout.c
@@ -48,6 +48,7 @@
 static long	opldr9(int);
 static long	opxrrr(int);
 static long	olsxrr(int, int, int, int);
+static long	opfmovr(int);
 static long	oprrr(int);
 static long	opirr(int);
 static long	opldr12(int);
@@ -758,6 +759,12 @@
 		o1 |= rf<<16 | r<<5 | rt;
 		break;
 
+	case 55:	/* fmovT Rn, Fd; fmovT Fn, Rd */
+		o1 = opfmovr(p->as) | p->from.reg<<5 | p->to.reg;
+		if(p->to.type == D_FREG)
+			o1 |= 1<<16;
+		break;
+
 	case 56:	/* floating point compare */
 		o1 = oprrr(p->as);
 		if(p->from.type == D_FCONST) {
@@ -934,6 +941,18 @@
 		lputl(o4);
 		lputl(o5);
 		break;
+	}
+}
+
+static long
+opfmovr(int a)
+{
+	switch(a){
+	case AFMOVS:	return 0<<31 | 0x1e<<24 | 0<<22 | 1<<21 | 6<<16;
+	case AFMOVD:	return 1<<31 | 0x1e<<24 | 1<<22 | 1<<21 | 6<<16;
+	default:
+		diag("bad fmov op\n%P", curp);
+		return 0;
 	}
 }
 
--- a/sys/src/cmd/7l/optab.c
+++ b/sys/src/cmd/7l/optab.c
@@ -426,6 +426,11 @@
 	{ AFMOVD,	C_FCON,	C_NONE,	C_FREG,		54, 4, 0 },
 	{ AFMOVD,	C_FREG, C_NONE, C_FREG,		54, 4, 0 },
 
+	{ AFMOVS,	C_FREG, C_NONE, C_REG,		55, 4, 0 },
+	{ AFMOVS,	C_REG,  C_NONE, C_FREG,		55, 4, 0 },
+	{ AFMOVD,	C_FREG, C_NONE, C_REG,		55, 4, 0 },
+	{ AFMOVD,	C_REG,  C_NONE, C_FREG,		55, 4, 0 },
+
 	{ AFCVTZSD,	C_FREG,	C_NONE,	C_REG,		29, 4, 0 },
 	{ ASCVTFD,	C_REG,	C_NONE,	C_FREG,		29, 4, 0 },