Blame SOURCES/binutils-aarch64-rng.patch

de02ff
diff -rup binutils.orig/gas/config/tc-aarch64.c binutils-2.30/gas/config/tc-aarch64.c
de02ff
--- binutils.orig/gas/config/tc-aarch64.c	2022-04-05 10:30:32.735881142 +0100
de02ff
+++ binutils-2.30/gas/config/tc-aarch64.c	2022-04-05 10:31:28.198694747 +0100
de02ff
@@ -8553,6 +8553,8 @@ static const struct aarch64_option_cpu_v
de02ff
   {"sha3",		AARCH64_FEATURE (AARCH64_FEATURE_SHA2
de02ff
 					 | AARCH64_FEATURE_SHA3, 0),
de02ff
 			AARCH64_ARCH_NONE},
de02ff
+  {"rng",               AARCH64_FEATURE (AARCH64_FEATURE_RNG, 0),
de02ff
+                        AARCH64_ARCH_NONE},
de02ff
   {NULL,		AARCH64_ARCH_NONE, AARCH64_ARCH_NONE},
de02ff
 };
de02ff
 
de02ff
diff -rup binutils.orig/gas/doc/c-aarch64.texi binutils-2.30/gas/doc/c-aarch64.texi
de02ff
--- binutils.orig/gas/doc/c-aarch64.texi	2022-04-05 10:30:32.735881142 +0100
de02ff
+++ binutils-2.30/gas/doc/c-aarch64.texi	2022-04-05 10:32:35.814423321 +0100
de02ff
@@ -179,6 +179,8 @@ automatically cause those extensions to
de02ff
 @item @code{fp16fml} @tab ARMv8.2-A @tab ARMv8.4-A or later
de02ff
  @tab Enable ARMv8.2 16-bit floating-point multiplication variant support.
de02ff
  This implies @code{fp16}.
de02ff
+@item @code{rng} @tab ARMv8.5-A @tab No
de02ff
+ @tab Enable ARMv8.5-A random number instructions.
de02ff
 @end multitable
de02ff
 
de02ff
 @node AArch64 Syntax
de02ff
Only in binutils-2.30/gas/testsuite/gas/aarch64: rng-1.d
de02ff
Only in binutils-2.30/gas/testsuite/gas/aarch64: rng-1.s
de02ff
diff -rup binutils.orig/include/opcode/aarch64.h binutils-2.30/include/opcode/aarch64.h
de02ff
--- binutils.orig/include/opcode/aarch64.h	2022-04-05 10:30:33.256879707 +0100
de02ff
+++ binutils-2.30/include/opcode/aarch64.h	2022-04-05 10:42:30.241087320 +0100
de02ff
@@ -62,6 +62,7 @@ typedef uint32_t aarch64_insn;
de02ff
 #define AARCH64_FEATURE_COMPNUM	0x40000000	/* Complex # instructions.  */
de02ff
 #define AARCH64_FEATURE_DOTPROD 0x080000000     /* Dot Product instructions.  */
de02ff
 #define AARCH64_FEATURE_F16_FML	0x1000000000ULL	/* v8.2 FP16FML ins.  */
de02ff
+#define AARCH64_FEATURE_RNG     0x80000000000ULL /* Random Number instructions.  */
de02ff
 
de02ff
 /* Architectures are the sum of the base and extensions.  */
de02ff
 #define AARCH64_ARCH_V8		AARCH64_FEATURE (AARCH64_FEATURE_V8, \
de02ff
diff -rup binutils.orig/opcodes/aarch64-opc.c binutils-2.30/opcodes/aarch64-opc.c
de02ff
--- binutils.orig/opcodes/aarch64-opc.c	2022-04-05 10:30:33.019880360 +0100
de02ff
+++ binutils-2.30/opcodes/aarch64-opc.c	2022-04-05 10:58:07.179526356 +0100
de02ff
@@ -3823,6 +3823,8 @@ const aarch64_sys_reg aarch64_sys_regs [
de02ff
   { "contextidr_el1",   CPENC(3,0,C13,C0,1),	0 },
de02ff
   { "contextidr_el2",	CPENC (3, 4, C13, C0, 1), F_ARCHEXT },
de02ff
   { "contextidr_el12",	CPENC (3, 5, C13, C0, 1), F_ARCHEXT },
de02ff
+  { "rndr",             CPENC(3,3,C2,C4,0),       F_ARCHEXT }, /* RO */
de02ff
+  { "rndrrs",           CPENC(3,3,C2,C4,1),       F_ARCHEXT }, /* RO */
de02ff
   { "tpidr_el0",        CPENC(3,3,C13,C0,2),	0 },
de02ff
   { "tpidrro_el0",      CPENC(3,3,C13,C0,3),	0 }, /* RO */
de02ff
   { "tpidr_el1",        CPENC(3,0,C13,C0,4),	0 },
de02ff
@@ -4254,6 +4256,13 @@ aarch64_sys_reg_supported_p (const aarch
de02ff
       && !AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_V8_4))
de02ff
     return FALSE;
de02ff
 
de02ff
+  /* Random Number Instructions.  For now they are available
de02ff
+     (and optional) only with ARMv8.5-A.  */
de02ff
+  if ((   reg->value == CPENC (3, 3, C2, C4, 0)
de02ff
+       || reg->value == CPENC (3, 3, C2, C4, 1))
de02ff
+      && !(AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_RNG)))
de02ff
+    return FALSE;
de02ff
+
de02ff
   return TRUE;
de02ff
 }
de02ff
 
de02ff
--- /dev/null	2022-04-05 09:32:54.900867346 +0100
de02ff
+++ binutils-2.30/gas/testsuite/gas/aarch64/rng-1.s	2022-04-05 10:36:04.921589937 +0100
de02ff
@@ -0,0 +1,3 @@
de02ff
+	.arch armv8.4-a+rng
de02ff
+	mrs x5, rndr
de02ff
+	mrs x6, rndrrs
de02ff
--- /dev/null	2022-04-05 09:32:54.900867346 +0100
de02ff
+++ binutils-2.30/gas/testsuite/gas/aarch64/rng-1.d	2022-04-05 10:35:48.937653638 +0100
de02ff
@@ -0,0 +1,10 @@
de02ff
+#source: rng-1.s
de02ff
+#objdump: -dr
de02ff
+
de02ff
+.*:     file format .*
de02ff
+
de02ff
+Disassembly of section \.text:
de02ff
+
de02ff
+0+ <.*>:
de02ff
+.*:	d53b2405 	mrs	x5, rndr
de02ff
+.*:	d53b2426 	mrs	x6, rndrrs