shithub: riscv

Download patch

ref: 178cd4d1139b8ba928ddac19578643637a953a93
parent: 2734fa85452cd5886212183adbb727038a263a98
author: Jacob Moody <moody@posixcafe.org>
date: Mon May 13 21:54:07 EDT 2024

9[acl], libmach: LWSYNC/CMPW/CMPWU

--- a/sys/src/cmd/9a/lex.c
+++ b/sys/src/cmd/9a/lex.c
@@ -353,7 +353,9 @@
 	"BVS",		LBRA, ABVS,
 
 	"CMP",		LCMP, ACMP,
+	"CMPW",		LCMP, ACMPW,
 	"CMPU",		LCMP, ACMPU,
+	"CMPWU",	LCMP, ACMPWU,
 
 	"DIVW",		LLOGW, ADIVW,
 	"DIVWV",	LLOGW, ADIVWV,
@@ -553,6 +555,7 @@
 	"SYNC",		LRETRN, ASYNC,
 	"TLBSYNC",	LRETRN,	ATLBSYNC,
 	"PTESYNC",	LRETRN,	APTESYNC,
+	"LWSYNC",	LRETRN, ALWSYNC,
 /*	"TW",		LADDW,	ATW,*/
 
 	"WORD",		LWORD, AWORD,
--- a/sys/src/cmd/9c/9.out.h
+++ b/sys/src/cmd/9c/9.out.h
@@ -361,6 +361,8 @@
 	/* more 64-bit operations */
 	AHRFID,
 
+	ALWSYNC,
+
 	ALAST
 };
 
--- a/sys/src/cmd/9c/enam.c
+++ /dev/null
@@ -1,309 +1,0 @@
-char	*anames[] =
-{
-	"XXX",
-	"ADD",
-	"ADDCC",
-	"ADDV",
-	"ADDVCC",
-	"ADDC",
-	"ADDCCC",
-	"ADDCV",
-	"ADDCVCC",
-	"ADDME",
-	"ADDMECC",
-	"ADDMEVCC",
-	"ADDMEV",
-	"ADDE",
-	"ADDECC",
-	"ADDEVCC",
-	"ADDEV",
-	"ADDZE",
-	"ADDZECC",
-	"ADDZEVCC",
-	"ADDZEV",
-	"AND",
-	"ANDCC",
-	"ANDN",
-	"ANDNCC",
-	"BC",
-	"BCL",
-	"BEQ",
-	"BGE",
-	"BGT",
-	"BL",
-	"BLE",
-	"BLT",
-	"BNE",
-	"BR",
-	"BVC",
-	"BVS",
-	"CMP",
-	"CMPU",
-	"CNTLZW",
-	"CNTLZWCC",
-	"CRAND",
-	"CRANDN",
-	"CREQV",
-	"CRNAND",
-	"CRNOR",
-	"CROR",
-	"CRORN",
-	"CRXOR",
-	"DIVW",
-	"DIVWCC",
-	"DIVWVCC",
-	"DIVWV",
-	"DIVWU",
-	"DIVWUCC",
-	"DIVWUVCC",
-	"DIVWUV",
-	"EQV",
-	"EQVCC",
-	"EXTSB",
-	"EXTSBCC",
-	"EXTSH",
-	"EXTSHCC",
-	"FABS",
-	"FABSCC",
-	"FADD",
-	"FADDCC",
-	"FADDS",
-	"FADDSCC",
-	"FCMPO",
-	"FCMPU",
-	"FCTIW",
-	"FCTIWCC",
-	"FCTIWZ",
-	"FCTIWZCC",
-	"FDIV",
-	"FDIVCC",
-	"FDIVS",
-	"FDIVSCC",
-	"FMADD",
-	"FMADDCC",
-	"FMADDS",
-	"FMADDSCC",
-	"FMOVD",
-	"FMOVDCC",
-	"FMOVDU",
-	"FMOVS",
-	"FMOVSU",
-	"FMSUB",
-	"FMSUBCC",
-	"FMSUBS",
-	"FMSUBSCC",
-	"FMUL",
-	"FMULCC",
-	"FMULS",
-	"FMULSCC",
-	"FNABS",
-	"FNABSCC",
-	"FNEG",
-	"FNEGCC",
-	"FNMADD",
-	"FNMADDCC",
-	"FNMADDS",
-	"FNMADDSCC",
-	"FNMSUB",
-	"FNMSUBCC",
-	"FNMSUBS",
-	"FNMSUBSCC",
-	"FRSP",
-	"FRSPCC",
-	"FSUB",
-	"FSUBCC",
-	"FSUBS",
-	"FSUBSCC",
-	"MOVMW",
-	"LSW",
-	"LWAR",
-	"MOVWBR",
-	"MOVB",
-	"MOVBU",
-	"MOVBZ",
-	"MOVBZU",
-	"MOVH",
-	"MOVHBR",
-	"MOVHU",
-	"MOVHZ",
-	"MOVHZU",
-	"MOVW",
-	"MOVWU",
-	"MOVFL",
-	"MOVCRFS",
-	"MTFSB0",
-	"MTFSB0CC",
-	"MTFSB1",
-	"MTFSB1CC",
-	"MULHW",
-	"MULHWCC",
-	"MULHWU",
-	"MULHWUCC",
-	"MULLW",
-	"MULLWCC",
-	"MULLWVCC",
-	"MULLWV",
-	"NAND",
-	"NANDCC",
-	"NEG",
-	"NEGCC",
-	"NEGVCC",
-	"NEGV",
-	"NOR",
-	"NORCC",
-	"OR",
-	"ORCC",
-	"ORN",
-	"ORNCC",
-	"REM",
-	"REMCC",
-	"REMV",
-	"REMVCC",
-	"REMU",
-	"REMUCC",
-	"REMUV",
-	"REMUVCC",
-	"RFI",
-	"RLWMI",
-	"RLWMICC",
-	"RLWNM",
-	"RLWNMCC",
-	"SLW",
-	"SLWCC",
-	"SRW",
-	"SRAW",
-	"SRAWCC",
-	"SRWCC",
-	"STSW",
-	"STWCCC",
-	"SUB",
-	"SUBCC",
-	"SUBVCC",
-	"SUBC",
-	"SUBCCC",
-	"SUBCV",
-	"SUBCVCC",
-	"SUBME",
-	"SUBMECC",
-	"SUBMEVCC",
-	"SUBMEV",
-	"SUBV",
-	"SUBE",
-	"SUBECC",
-	"SUBEV",
-	"SUBEVCC",
-	"SUBZE",
-	"SUBZECC",
-	"SUBZEVCC",
-	"SUBZEV",
-	"SYNC",
-	"XOR",
-	"XORCC",
-	"DCBF",
-	"DCBI",
-	"DCBST",
-	"DCBT",
-	"DCBTST",
-	"DCBZ",
-	"ECIWX",
-	"ECOWX",
-	"EIEIO",
-	"ICBI",
-	"ISYNC",
-	"PTESYNC",
-	"TLBIE",
-	"TLBIEL",
-	"TLBSYNC",
-	"TW",
-	"SYSCALL",
-	"DATA",
-	"GLOBL",
-	"GOK",
-	"HISTORY",
-	"NAME",
-	"NOP",
-	"RETURN",
-	"TEXT",
-	"WORD",
-	"END",
-	"DYNT",
-	"INIT",
-	"SIGNAME",
-	"RFCI",
-	"FRES",
-	"FRESCC",
-	"FRSQRTE",
-	"FRSQRTECC",
-	"FSEL",
-	"FSELCC",
-	"FSQRT",
-	"FSQRTCC",
-	"FSQRTS",
-	"FSQRTSCC",
-	"CNTLZD",
-	"CNTLZDCC",
-	"CMPW",
-	"CMPWU",
-	"DIVD",
-	"DIVDCC",
-	"DIVDVCC",
-	"DIVDV",
-	"DIVDU",
-	"DIVDUCC",
-	"DIVDUVCC",
-	"DIVDUV",
-	"EXTSW",
-	"EXTSWCC",
-	"FCFID",
-	"FCFIDCC",
-	"FCTID",
-	"FCTIDCC",
-	"FCTIDZ",
-	"FCTIDZCC",
-	"LDAR",
-	"MOVD",
-	"MOVDU",
-	"MOVWZ",
-	"MOVWZU",
-	"MULHD",
-	"MULHDCC",
-	"MULHDU",
-	"MULHDUCC",
-	"MULLD",
-	"MULLDCC",
-	"MULLDVCC",
-	"MULLDV",
-	"RFID",
-	"RLDMI",
-	"RLDMICC",
-	"RLDC",
-	"RLDCCC",
-	"RLDCR",
-	"RLDCRCC",
-	"RLDCL",
-	"RLDCLCC",
-	"SLBIA",
-	"SLBIE",
-	"SLBMFEE",
-	"SLBMFEV",
-	"SLBMTE",
-	"SLD",
-	"SLDCC",
-	"SRD",
-	"SRAD",
-	"SRADCC",
-	"SRDCC",
-	"STDCCC",
-	"TD",
-	"DWORD",
-	"REMD",
-	"REMDCC",
-	"REMDV",
-	"REMDVCC",
-	"REMDU",
-	"REMDUCC",
-	"REMDUV",
-	"REMDUVCC",
-	"HRFID",
-	"LAST",
-};
--- a/sys/src/cmd/9l/asmout.c
+++ b/sys/src/cmd/9l/asmout.c
@@ -1302,6 +1302,7 @@
 	case ASUBZEVCC:	return OPVCC(31,200,1,1);
 
 	case ASYNC:	return OPVCC(31,598,0,0);
+	case ALWSYNC:	return OPVCC(31,598,0,0) | (1<<21);
 	case APTESYNC:	return OPVCC(31,598,0,0) | (2<<21);
 
 	case ATLBIE:	return OPVCC(31,306,0,0);
--- a/sys/src/cmd/9l/span.c
+++ b/sys/src/cmd/9l/span.c
@@ -784,6 +784,7 @@
 			oprange[AISYNC] = oprange[r];
 			oprange[APTESYNC] = oprange[r];
 			oprange[ATLBSYNC] = oprange[r];
+			oprange[ALWSYNC] = oprange[r];
 			break;
 		case ARLWMI:
 			oprange[ARLWMICC] = oprange[r];
--- a/sys/src/libmach/qdb.c
+++ b/sys/src/libmach/qdb.c
@@ -914,6 +914,24 @@
 	}
 }
 
+static void
+sync(Opcode *o, Instr *i)
+{
+	switch(IBF(i->w[0], 9, 10)){
+	case 0:
+		format(o->mnemonic, i, o->ken);
+		break;
+	case 1:
+		format("LWSYNC", i, o->ken);
+		break;
+	case 2:
+		format("PTESYNC", i, o->ken);
+		break;
+	default:
+		format("reserved instruction", i, 0);
+	}
+}
+
 static	char	ir2[] = "R%a,R%d";		/* reverse of IBM order */
 static	char	ir3[] = "R%b,R%a,R%d";
 static	char	ir3r[] = "R%a,R%b,R%d";
@@ -1098,10 +1116,10 @@
 	{19,	528,	ALL,	"BC%L",		branch,	"%d,%a,(CTR)"},
 	{19,	16,	ALL,	"BC%L",		branch,	"%d,%a,(LR)"},
 
-	{31,	0,	ALL,	"CMP",		0,	icmp3},
-	{11,	0,	0,	"CMP",		0,	"R%a,%i,%D"},
-	{31,	32,	ALL,	"CMPU",		0,	icmp3},
-	{10,	0,	0,	"CMPU",		0,	"R%a,%I,%D"},
+	{31,	0,	ALL,	"CMP%W",	0,	icmp3},
+	{11,	0,	0,	"CMP%W",	0,	"R%a,%i,%D"},
+	{31,	32,	ALL,	"CMP%WU",	0,	icmp3},
+	{10,	0,	0,	"CMP%WU",	0,	"R%a,%I,%D"},
 
 	{31,	58,	ALL,	"CNTLZD%C",	gencc,	ir2},	/* 64 */
 	{31,	26,	ALL,	"CNTLZ%W%C",	gencc,	ir2},
@@ -1390,7 +1408,7 @@
 	{31,	232,	OEM,	"SUBME%V%C",	sub,	ir2},
 	{31,	200,	OEM,	"SUBZE%V%C",	sub,	ir2},
 
-	{31,	598,	ALL,	"SYNC",		gen,	0},	/* TO DO: there's a parameter buried in there */
+	{31,	598,	ALL,	"SYNC",		sync,	0},
 	{2,	0,	0,	"TD",		gen,	"%d,R%a,%i"},	/* 64 */
 	{31,	370,	ALL,	"TLBIA",	gen,	0},	/* optional */
 	{31,	306,	ALL,	"TLBIE",	gen,	"R%b"},	/* optional */
@@ -2494,7 +2512,10 @@
 			break;
 
 		case 'W':
-			if(i->m64)
+			if(!i->m64)
+				break;
+			/* sloppy */
+			if(i->xo == 26 || IB(i->w[0], 10) == 0)
 				bprint(i, "W");
 			break;