shithub: riscv

Download patch

ref: cbe4b116989c0bfec49b9ae7a1d9a85ead6648ae
parent: 3bb4169be1566faca886b232376e85b1ebf10fb3
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Sat May 13 20:11:40 EDT 2023

7l: allow paired SIMD load/store, correct a few comments

--- a/sys/src/cmd/7l/asmout.c
+++ b/sys/src/cmd/7l/asmout.c
@@ -848,7 +848,7 @@
 		o2 = olsr12u(opldr12(p->as), 0, REGTMP, p->to.reg);
 		break;
 
-	case 66:	/* movpT (R)O!,R; movpT O(R)!, R -> ldrT */
+	case 66:	/* movpT (R)O!,R,R; movpT O(R)!,R,R; movpT (R)O,R,R -> ldpT */
 		o1 = opldrpp(p->as);
 		v = p->from.offset >> 2 + ((o1 & S64) != 0);
 		if(v < -128 || v > 127)
@@ -859,10 +859,10 @@
 			o1 |= 3<<23;
 		else
 			o1 |= 2<<23;
-		o1 |= ((v&0x7F)<<15) | (p->from.reg<<5) | p->reg | (p->to.reg<<10);
+		o1 |= (v&0x7F)<<15 | p->from.reg<<5 | p->reg | p->to.reg<<10;
 		break;
 
-	case 67:	/* movpT R,(R)O!; movpT O(R)!, R -> strT */
+	case 67:	/* movpT R,R,(R)O!; movpT R,R,O(R)!; movpT R,R,O(R) -> stpT */
 		o1 = LD2STR(opldrpp(p->as));
 		v = p->to.offset >> 2 + ((o1 & S64) != 0);
 		if(v < -128 || v > 127)
@@ -873,7 +873,7 @@
 			o1 |= 3<<23;
 		else
 			o1 |= 2<<23;
-		o1 |= ((v&0x7F)<<15) | (p->to.reg<<5) | p->from.reg | (p->reg<<10);
+		o1 |= (v&0x7F)<<15 | p->to.reg<<5 | p->from.reg | p->reg<<10;
 		break;
 	}
 
@@ -1580,9 +1580,11 @@
 	case AMOVHU:	return 1<<30 | 7<<27 | 0<<26 | 0<<24 | 1<<22;
 	case AMOVB:	return 0<<30 | 7<<27 | 0<<26 | 0<<24 | 2<<22;
 	case AMOVBU:	return 0<<30 | 7<<27 | 0<<26 | 0<<24 | 1<<22;
-	case AMOVPW:	return 0<<30 | 5<<27 | 0<<26 | 0<<23 | 1<<22;
+	case AMOVPW:	return 0<<30 | 5<<27 | 0<<26 | 0<<23 | 1<<22;	/* simm7<<15 | Rt2<<10 | Rn<<5 | Rt */
 	case AMOVPSW:	return 1<<30 | 5<<27 | 0<<26 | 0<<23 | 1<<22;
 	case AMOVP:	return 2<<30 | 5<<27 | 0<<26 | 0<<23 | 1<<22;
+	case AMOVPS:	return 0<<30 | 5<<27 | 1<<26 | 0<<23 | 1<<22;
+	case AMOVPD:	return 1<<30 | 5<<27 | 1<<26 | 0<<23 | 1<<22;
 	}
 	diag("bad opldr %A\n%P", a, curp);
 	return 0;
--- a/sys/src/cmd/7l/optab.c
+++ b/sys/src/cmd/7l/optab.c
@@ -323,6 +323,20 @@
 	{ AMOVP, 	C_REG,		C_REG, C_XPOST,		67, 4, 0 },
 	{ AMOVP, 	C_REG,		C_REG, C_XPRE,		67, 4, 0 },
 
+	{ AMOVPS, 	C_PPAUTO,	C_FREG,	C_FREG,		66, 4, 0 },
+	{ AMOVPS, 	C_PPOREG,	C_FREG,	C_FREG,		66, 4, 0 },
+	{ AMOVPS, 	C_NPAUTO,	C_FREG,	C_FREG,		66, 4, 0 },
+	{ AMOVPS, 	C_NPOREG,	C_FREG,	C_FREG,		66, 4, 0 },
+	{ AMOVPS, 	C_XPOST,	C_FREG,	C_FREG,		66, 4, 0 },
+	{ AMOVPS, 	C_XPRE,		C_FREG,	C_FREG,		66, 4, 0 },
+
+	{ AMOVPS, 	C_FREG,		C_FREG, C_PPAUTO,	67, 4, 0 },
+	{ AMOVPS, 	C_FREG,		C_FREG, C_PPOREG,	67, 4, 0 },
+	{ AMOVPS, 	C_FREG,		C_FREG, C_NPAUTO,	67, 4, 0 },
+	{ AMOVPS, 	C_FREG,		C_FREG, C_NPOREG,	67, 4, 0 },
+	{ AMOVPS, 	C_FREG,		C_FREG, C_XPOST,	67, 4, 0 },
+	{ AMOVPS, 	C_FREG,		C_FREG, C_XPRE,		67, 4, 0 },
+
 	/* special */
 	{ AMOV,		C_SPR,	C_NONE,	C_REG,		35, 4, 0 },
 	{ AMRS,		C_SPR,	C_NONE,	C_REG,		35, 4, 0 },
--- a/sys/src/cmd/7l/span.c
+++ b/sys/src/cmd/7l/span.c
@@ -692,6 +692,17 @@
 	return C_GOK;
 }
 
+static int
+asregclass(ushort as)
+{
+	switch(as){
+	case AMOVPS:
+	case AMOVPD:
+	case AMOVPQ: return C_FREG;
+	}
+	return C_REG;
+}
+
 Optab*
 oplook(Prog *p)
 {
@@ -716,7 +727,7 @@
 	a3--;
 	a2 = C_NONE;
 	if(p->reg != NREG)
-		a2 = C_REG;
+		a2 = asregclass(p->as);
 	r = p->as;
 	o = oprange[r].start;
 	if(o == 0) {
@@ -1351,6 +1362,11 @@
 		case AMOVP:
 			oprange[AMOVPW] = t;
 			oprange[AMOVPSW] = t;
+			break;
+
+		case AMOVPS:
+			oprange[AMOVPS] = t;
+			oprange[AMOVPD] = t;
 			break;
 		}
 	}