This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] gas/metag: Make SWAP instruction less permissive with its operands
- From: Markos Chandras <markos dot chandras at gmail dot com>
- To: <binutils at sourceware dot org>
- Date: Tue, 29 Jan 2013 14:59:26 +0000
- Subject: [PATCH] gas/metag: Make SWAP instruction less permissive with its operands
From: Markos Chandras <markos.chandras@imgtec.com>
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
gas/ChangeLog:
2013-01-29 Markos Chandras <markos.chandras@imgtec.com>
* config/tc-metag.c: Make SWAP instruction less permissive with its operands.
gas/testsuite/ChangeLog:
2013-01-29 Markos Chandras <markos.chandras@imgtec.com>
* gas/metag/metacore21-invalid.s: Add invalid SWAP testcases
* gas/metag/metacore21-invalid.l: Add expected output for invalid SWAP testcases
---
gas/config/tc-metag.c | 25 +++++++++++++++++++++++++
gas/testsuite/gas/metag/metacore21-invalid.l | 6 ++++++
gas/testsuite/gas/metag/metacore21-invalid.s | 3 +++
3 files changed, 34 insertions(+)
diff --git a/gas/config/tc-metag.c b/gas/config/tc-metag.c
index d5e603a..73d7d1a 100644
--- a/gas/config/tc-metag.c
+++ b/gas/config/tc-metag.c
@@ -2026,6 +2026,31 @@ parse_swap (const char *line, metag_insn *insn,
if (l == NULL)
return NULL;
+ /* PC.r | CT.r | TR.r | TT.r are treated as if they are a single unit */
+ switch (regs[0]->unit)
+ {
+ case UNIT_PC:
+ case UNIT_CT:
+ case UNIT_TR:
+ case UNIT_TT:
+ if (regs[1]->unit == UNIT_PC ||
+ regs[1]->unit == UNIT_CT ||
+ regs[1]->unit == UNIT_TR ||
+ regs[1]->unit == UNIT_TT)
+ {
+ as_bad (_("PC, CT, TR and TT are treated as if they are a single unit but operands must be in different units"));
+ return NULL;
+ }
+ default:
+ /* Registers must be in different units */
+ if (regs[0]->unit == regs[1]->unit)
+ {
+ as_bad (_("source and destination register must be in different units"));
+ return NULL;
+ }
+ break;
+ }
+
insn->bits = (template->meta_opcode |
(regs[1]->no << 19) |
(regs[0]->no << 14) |
diff --git a/gas/testsuite/gas/metag/metacore21-invalid.l b/gas/testsuite/gas/metag/metacore21-invalid.l
index 3352457..4c27c53 100644
--- a/gas/testsuite/gas/metag/metacore21-invalid.l
+++ b/gas/testsuite/gas/metag/metacore21-invalid.l
@@ -15,3 +15,9 @@
.*:8: Error: .*
.*:8: Error: .*
.*:8: Error: .*
+.*:9: Error: .*
+.*:9: Error: .*
+.*:10: Error: .*
+.*:10: Error: .*
+.*:11: Error: .*
+.*:11: Error: .*
diff --git a/gas/testsuite/gas/metag/metacore21-invalid.s b/gas/testsuite/gas/metag/metacore21-invalid.s
index be23532..8dd4c04 100644
--- a/gas/testsuite/gas/metag/metacore21-invalid.s
+++ b/gas/testsuite/gas/metag/metacore21-invalid.s
@@ -6,3 +6,6 @@ _start:
SETD [A0.0+A0.1],A0.2
ASL D0.0,D1.0,D0.0
GETD D0.0,[D0.0--D0.0]
+ SWAP PC,PCX
+ SWAP CT.0,PCX
+ SWAP D0.1,D0.2
--
1.8.1.1