aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorVictor Do Nascimento <victor.donascimento@arm.com>2023-11-20 15:32:15 +0000
committerVictor Do Nascimento <victor.donascimento@arm.com>2024-01-09 10:16:40 +0000
commit5517af829887ba3b19a3f372b6b60e8098bdfa29 (patch)
tree920b57119a6b6b1662da63f8916550a5ba35adfe /gas
parent3521a28f10900ed893f53fcceec2f66c335cb154 (diff)
downloadfsf-binutils-gdb-5517af829887ba3b19a3f372b6b60e8098bdfa29.zip
fsf-binutils-gdb-5517af829887ba3b19a3f372b6b60e8098bdfa29.tar.gz
fsf-binutils-gdb-5517af829887ba3b19a3f372b6b60e8098bdfa29.tar.bz2
aarch64: Apply narrowing of allowed immediate values for SYSP
While CRn and CRm fields in the SYSP instruction are 4-bit wide and are thus able to accommodate values in the range 0-15, the specifications for the SYSP instructions limit their ranges to 8-9 for CRm and 0-7 in the case of CRn. This led to the need to signal in some way to the operand parser that a given operand is under special restrictions regarding its use. This is done via the new `F_OPD_NARROW' flag, indicating a narrowing in the range of operand values for fields in the instruction tagged with the flag. The flag is then used in `parse_operands' when the instruction is assembled, but needs not be taken into consideration during disassembly.
Diffstat (limited to 'gas')
-rw-r--r--gas/config/tc-aarch64.c18
-rw-r--r--gas/testsuite/gas/aarch64/illegal-sys128.d3
-rw-r--r--gas/testsuite/gas/aarch64/sysp.d10
-rw-r--r--gas/testsuite/gas/aarch64/sysp.s4
4 files changed, 34 insertions, 1 deletions
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 29535e7..539bfa2 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -6474,6 +6474,7 @@ parse_operands (char *str, const aarch64_opcode *opcode)
int i;
char *backtrack_pos = 0;
const enum aarch64_opnd *operands = opcode->operands;
+ const uint64_t flags = opcode->flags;
aarch64_reg_type imm_reg_type;
clear_error ();
@@ -6822,7 +6823,22 @@ parse_operands (char *str, const aarch64_opcode *opcode)
goto failure;
po_imm_nc_or_fail ();
- if (val > 15)
+ if (flags & F_OPD_NARROW)
+ {
+ if ((operands[i] == AARCH64_OPND_CRn)
+ && (val < 8 || val > 9))
+ {
+ set_fatal_syntax_error (_(N_ ("C8 - C9 expected")));
+ goto failure;
+ }
+ else if ((operands[i] == AARCH64_OPND_CRm)
+ && (val > 7))
+ {
+ set_fatal_syntax_error (_(N_ ("C0 - C7 expected")));
+ goto failure;
+ }
+ }
+ else if (val > 15)
{
set_fatal_syntax_error (_(N_ ("C0 - C15 expected")));
goto failure;
diff --git a/gas/testsuite/gas/aarch64/illegal-sys128.d b/gas/testsuite/gas/aarch64/illegal-sys128.d
new file mode 100644
index 0000000..891b934
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/illegal-sys128.d
@@ -0,0 +1,3 @@
+#name: Out-of-bounds SYSP operand tests
+#source: illegal-sys128.s
+#error_output: illegal-sys128.l
diff --git a/gas/testsuite/gas/aarch64/sysp.d b/gas/testsuite/gas/aarch64/sysp.d
new file mode 100644
index 0000000..80286c1
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/sysp.d
@@ -0,0 +1,10 @@
+#objdump: -dr
+
+.*
+
+
+Disassembly of section \.text:
+
+0+ <\.text>:
+[^:]*: d5488000 sysp #0, C8, C0, #0, x0, x1
+[^:]*: d54e97fa sysp #6, C9, C7, #7, x26, x27 \ No newline at end of file
diff --git a/gas/testsuite/gas/aarch64/sysp.s b/gas/testsuite/gas/aarch64/sysp.s
new file mode 100644
index 0000000..f50d3ab
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/sysp.s
@@ -0,0 +1,4 @@
+ .arch armv9.4-a+d128
+
+ sysp #0, C8, C0, #0, x0, x1
+ sysp #6, C9, C7, #7, x26, x27