aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2013-01-30 13:21:01 +0000
committerNick Clifton <nickc@redhat.com>2013-01-30 13:21:01 +0000
commitf9b2d5449aa0df00eb0c2b2ca9da21d879245bad (patch)
treec85850def9ced8c1b801739c591a46bd17e2f9c0 /gas/config
parent92ff23a1bf4b32cc9076620619460565737d5164 (diff)
downloadgdb-f9b2d5449aa0df00eb0c2b2ca9da21d879245bad.zip
gdb-f9b2d5449aa0df00eb0c2b2ca9da21d879245bad.tar.gz
gdb-f9b2d5449aa0df00eb0c2b2ca9da21d879245bad.tar.bz2
* config/tc-metag.c: Make SWAP instruction less permissive with its operands.
* gas/metag/metacore21-invalid.s: Add invalid SWAP testcases * gas/metag/metacore21-invalid.l: Add expected output for invalid SWAP testcases
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-metag.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/gas/config/tc-metag.c b/gas/config/tc-metag.c
index d5e603a..f42d2f1 100644
--- a/gas/config/tc-metag.c
+++ b/gas/config/tc-metag.c
@@ -2026,11 +2026,37 @@ parse_swap (const char *line, metag_insn *insn,
if (l == NULL)
return NULL;
- insn->bits = (template->meta_opcode |
- (regs[1]->no << 19) |
- (regs[0]->no << 14) |
- (regs[1]->unit << 10) |
- (regs[0]->unit << 5));
+ /* 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)
+ | (regs[1]->unit << 10)
+ | (regs[0]->unit << 5));
insn->len = 4;
return l;