Blame SOURCES/binutils-PPC-dcbt.patch

b7afb1
diff -rup binutils.orig/gas/testsuite/gas/ppc/power4_32.d binutils-2.35/gas/testsuite/gas/ppc/power4_32.d
b7afb1
--- binutils.orig/gas/testsuite/gas/ppc/power4_32.d	2022-01-25 13:39:48.063563099 +0000
b7afb1
+++ binutils-2.35/gas/testsuite/gas/ppc/power4_32.d	2022-01-25 13:48:30.857981751 +0000
b7afb1
@@ -41,7 +41,7 @@ Disassembly of section \.text:
b7afb1
   7c:	(7c 01 17 ec|ec 17 01 7c) 	dcbz    r1,r2
b7afb1
   80:	(7c 23 27 ec|ec 27 23 7c) 	dcbzl   r3,r4
b7afb1
   84:	(7c 05 37 ec|ec 37 05 7c) 	dcbz    r5,r6
b7afb1
-  88:	(7c 05 32 2c|2c 32 05 7c) 	dcbt    r5,r6
b7afb1
-  8c:	(7c 05 32 2c|2c 32 05 7c) 	dcbt    r5,r6
b7afb1
-  90:	(7d 05 32 2c|2c 32 05 7d) 	dcbt    r5,r6,8
b7afb1
+  88:	(7c 05 32 2c|2c 32 05 7c) 	dcbtct  r5,r6
b7afb1
+  8c:	(7c 05 32 2c|2c 32 05 7c) 	dcbtct  r5,r6
b7afb1
+  90:	(7d 05 32 2c|2c 32 05 7d) 	dcbtds  r5,r6
b7afb1
 #pass
b7afb1
diff -rup binutils.orig/opcodes/ppc-opc.c binutils-2.35/opcodes/ppc-opc.c
b7afb1
--- binutils.orig/opcodes/ppc-opc.c	2022-01-25 13:39:47.650565929 +0000
b7afb1
+++ binutils-2.35/opcodes/ppc-opc.c	2022-01-25 13:47:09.056542122 +0000
b7afb1
@@ -2205,6 +2205,74 @@ extract_sxl (uint64_t insn,
b7afb1
     return 1;
b7afb1
   return (insn >> 11) & 0x1;
b7afb1
 }
b7afb1
+
b7afb1
+/* The list of embedded processors that use the embedded operand ordering
b7afb1
+   for the 3 operand dcbt and dcbtst instructions.  */
b7afb1
+#define DCBT_EO (PPC_OPCODE_E500 | PPC_OPCODE_E500MC | PPC_OPCODE_476 \
b7afb1
+		 | PPC_OPCODE_A2)
b7afb1
+
b7afb1
+/* ISA 2.03 and later specify extended mnemonics dcbtct, dcbtds, and
b7afb1
+   dcbtstct, dcbtstds with a note saying these should be used in new
b7afb1
+   programs rather than the base mnemonics "so that it can be coded
b7afb1
+   with TH as the last operand for all categories".  For that reason
b7afb1
+   the extended mnemonics are enabled in the assembler for the
b7afb1
+   embedded processors, but not for the disassembler so as to display
b7afb1
+   the embedded dcbt or dcbtst expected form with TH first for
b7afb1
+   embedded programmers.  */
b7afb1
+
b7afb1
+static uint64_t
b7afb1
+insert_thct (uint64_t insn,
b7afb1
+	    int64_t value,
b7afb1
+	    ppc_cpu_t dialect ATTRIBUTE_UNUSED,
b7afb1
+	    const char **errmsg)
b7afb1
+{
b7afb1
+  if ((uint64_t) value > 7)
b7afb1
+    *errmsg = _("invalid TH value");
b7afb1
+  return insn | ((value & 7) << 21);
b7afb1
+}
b7afb1
+
b7afb1
+static int64_t
b7afb1
+extract_thct (uint64_t insn,
b7afb1
+	      ppc_cpu_t dialect,
b7afb1
+	      int *invalid)
b7afb1
+{
b7afb1
+  /* Missing optional operands have a value of 0.  */
b7afb1
+  if (*invalid < 0)
b7afb1
+    return 0;
b7afb1
+
b7afb1
+  int64_t value = (insn >> 21) & 0x1f;
b7afb1
+  if (value > 7 || (dialect & DCBT_EO) != 0)
b7afb1
+    *invalid = 1;
b7afb1
+
b7afb1
+  return value;
b7afb1
+}
b7afb1
+
b7afb1
+static uint64_t
b7afb1
+insert_thds (uint64_t insn,
b7afb1
+	     int64_t value,
b7afb1
+	     ppc_cpu_t dialect ATTRIBUTE_UNUSED,
b7afb1
+	     const char **errmsg)
b7afb1
+{
b7afb1
+  if (value < 8 || value > 15)
b7afb1
+    *errmsg = _("invalid TH value");
b7afb1
+  return insn | ((value & 0x1f) << 21);
b7afb1
+}
b7afb1
+
b7afb1
+static int64_t
b7afb1
+extract_thds (uint64_t insn,
b7afb1
+	      ppc_cpu_t dialect,
b7afb1
+	      int *invalid)
b7afb1
+{
b7afb1
+  /* Missing optional operands have a value of 8.  */
b7afb1
+  if (*invalid < 0)
b7afb1
+    return 8;
b7afb1
+
b7afb1
+  int64_t value = (insn >> 21) & 0x1f;
b7afb1
+  if (value < 8 || value > 15 || (dialect & DCBT_EO) != 0)
b7afb1
+    *invalid = 1;
b7afb1
+
b7afb1
+  return value;
b7afb1
+}
b7afb1
 
b7afb1
 /* The operands table.
b7afb1
 
b7afb1
@@ -2402,10 +2470,18 @@ const struct powerpc_operand powerpc_ope
b7afb1
 #define MO CT
b7afb1
   { 0x1f, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
b7afb1
 
b7afb1
+  /* The TH field in dcbtct.  */
b7afb1
+#define THCT CT + 1
b7afb1
+  { 0x1f, 21, insert_thct, extract_thct, PPC_OPERAND_OPTIONAL },
b7afb1
+
b7afb1
+  /* The TH field in dcbtds.  */
b7afb1
+#define THDS THCT + 1
b7afb1
+  { 0x1f, 21, insert_thds, extract_thds, PPC_OPERAND_OPTIONAL },
b7afb1
+
b7afb1
   /* The D field in a D form instruction.  This is a displacement off
b7afb1
      a register, and implies that the next operand is a register in
b7afb1
      parentheses.  */
b7afb1
-#define D CT + 1
b7afb1
+#define D THDS + 1
b7afb1
   { 0xffff, 0, NULL, NULL, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },
b7afb1
 
b7afb1
   /* The D8 field in a D form instruction.  This is a displacement off
b7afb1
@@ -4211,12 +4287,6 @@ const unsigned int num_powerpc_operands
b7afb1
 #define PPCHTM  PPC_OPCODE_POWER8
b7afb1
 #define E200Z4  PPC_OPCODE_E200Z4
b7afb1
 #define PPCLSP  PPC_OPCODE_LSP
b7afb1
-/* The list of embedded processors that use the embedded operand ordering
b7afb1
-   for the 3 operand dcbt and dcbtst instructions.  */
b7afb1
-#define DCBT_EO	(PPC_OPCODE_E500 | PPC_OPCODE_E500MC | PPC_OPCODE_476 \
b7afb1
-		 | PPC_OPCODE_A2)
b7afb1
-
b7afb1
-
b7afb1
 
b7afb1
 /* The opcode table.
b7afb1
 
b7afb1
@@ -6592,6 +6662,8 @@ const struct powerpc_opcode powerpc_opco
b7afb1
 {"mtvsrwz",	X(31,243),	XX1RB_MASK,   PPCVSX2,	0,		{XT6, RA}},
b7afb1
 
b7afb1
 {"dcbtstt",	XRT(31,246,0x10), XRT_MASK,  POWER7,	0,		{RA0, RB}},
b7afb1
+{"dcbtstct",	X(31,246),	X_MASK,	     POWER4,	0,		{RA0, RB, THCT}},
b7afb1
+{"dcbtstds",	X(31,246),	X_MASK,	     POWER4,	0,		{RA0, RB, THDS}},
b7afb1
 {"dcbtst",	X(31,246),	X_MASK,	     POWER4,	DCBT_EO,	{RA0, RB, CT}},
b7afb1
 {"dcbtst",	X(31,246),	X_MASK,	     DCBT_EO,	0,		{CT, RA0, RB}},
b7afb1
 {"dcbtst",	X(31,246),	X_MASK,	     PPC,	POWER4|DCBT_EO,	{RA0, RB}},
b7afb1
@@ -6643,6 +6715,9 @@ const struct powerpc_opcode powerpc_opco
b7afb1
 {"lscbx.",	XRC(31,277,1),	X_MASK,	     M601,	0,		{RT, RA, RB}},
b7afb1
 
b7afb1
 {"dcbtt",	XRT(31,278,0x10), XRT_MASK,  POWER7,	0,		{RA0, RB}},
b7afb1
+{"dcbna",	XRT(31,278,0x11), XRT_MASK,  POWER10,	0,		{RA0, RB}},
b7afb1
+{"dcbtct",	X(31,278),	X_MASK,      POWER4,	0,		{RA0, RB, THCT}},
b7afb1
+{"dcbtds",	X(31,278),	X_MASK,      POWER4,	0,		{RA0, RB, THDS}},
b7afb1
 {"dcbt",	X(31,278),	X_MASK,	     POWER4,	DCBT_EO,	{RA0, RB, CT}},
b7afb1
 {"dcbt",	X(31,278),	X_MASK,	     DCBT_EO,	0,		{CT, RA0, RB}},
b7afb1
 {"dcbt",	X(31,278),	X_MASK,	     PPC,	POWER4|DCBT_EO,	{RA0, RB}},