aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2007-04-18 13:49:34 +0000
committerPaul Brook <paul@codesourcery.com>2007-04-18 13:49:34 +0000
commit026d3abbb22d4ac067a57d0a9aa2b2482266c9e7 (patch)
treef52f4105fc9cd3a84c266a32bf5c04b2444c8ca3 /gas/config
parent3d1f72c2311203ec590529ccfcc8efb17fb85856 (diff)
downloadgdb-026d3abbb22d4ac067a57d0a9aa2b2482266c9e7.zip
gdb-026d3abbb22d4ac067a57d0a9aa2b2482266c9e7.tar.gz
gdb-026d3abbb22d4ac067a57d0a9aa2b2482266c9e7.tar.bz2
2007-04-18 Paul Brook <paul@codesourcery.com>
gas/testsuite/ * gas/arm/thumb2_add.s: Add rsb #0 test. * gas/arm/thumb2_add.d: Update expected output. gas/ * config/tc-arm.c (do_t_rsb): Use 16-bit encoding when possible.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-arm.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 9b8db7a..b20803f 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -9956,8 +9956,37 @@ do_t_rsb (void)
inst.instruction |= Rs << 16;
if (!inst.operands[2].isreg)
{
- inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
- inst.reloc.type = BFD_RELOC_ARM_T32_IMMEDIATE;
+ bfd_boolean narrow;
+
+ if ((inst.instruction & 0x00100000) != 0)
+ narrow = (current_it_mask == 0);
+ else
+ narrow = (current_it_mask != 0);
+
+ if (Rd > 7 || Rs > 7)
+ narrow = FALSE;
+
+ if (inst.size_req == 4 || !unified_syntax)
+ narrow = FALSE;
+
+ if (inst.reloc.exp.X_op != O_constant
+ || inst.reloc.exp.X_add_number != 0)
+ narrow = FALSE;
+
+ /* Turn rsb #0 into 16-bit neg. We should probably do this via
+ relaxation, but it doesn't seem worth the hassle. */
+ if (narrow)
+ {
+ inst.reloc.type = BFD_RELOC_UNUSED;
+ inst.instruction = THUMB_OP16 (T_MNEM_negs);
+ inst.instruction |= Rs << 3;
+ inst.instruction |= Rd;
+ }
+ else
+ {
+ inst.instruction = (inst.instruction & 0xe1ffffff) | 0x10000000;
+ inst.reloc.type = BFD_RELOC_ARM_T32_IMMEDIATE;
+ }
}
else
encode_thumb32_shifted_operand (2);