Commit Graph

69 Commits

Author SHA1 Message Date
Mihai Popa 4c2801f7fd This fixes the Thumb2 CPS assembly syntax.
In Thumb1, only one variant is supported: CPS{effect} {flags}

Thumb2 supports three:
CPS{effect}.W {flags}
CPS{effect} {flags} {mode}
CPS {mode}

Canonically, .W should be used only when ambiguity is present between encodings of different width.
The wide suffix is still accepted for the latter two forms via aliases.

llvm-svn: 188071
2013-08-09 13:52:32 +00:00
Mihai Popa ad18d3ce53 Fix assembling of Thumb2 branch instructions.
The long encoding for Thumb2 unconditional branches is broken.
Additionally, there is no range checking for target operands; as such 
for instructions originating in assembly code, only short Thumb encodings
are generated, regardless of the bitsize needed for the offset.

Adding range checking is non trivial due to the representation of Thumb
branch instructions. There is no true difference between conditional and
unconditional branches in terms of operands and syntax - even unconditional
branches have a predicate which is expected to match that of the IT block
they are in. Yet, the encodings and the permitted size of the offset differ.

Due to this, for any mnemonic there are really 4 encodings to choose for.

The problem cannot be handled in the parser alone or by manipulating td files.
Because the parser builds first a set of match candidates and then checks them
one by one, whatever tablegen-only solution might be found will ultimately be
dependent of the parser's evaluation order. What's worse is that due to the fact
that all branches have the same syntax and the same kinds of operands, that 
order is governed by the lexicographical ordering of the names of operand 
classes...

To circumvent all this, any necessary disambiguation is added to the instruction
validation pass.

llvm-svn: 188067
2013-08-09 10:38:32 +00:00
Mihai Popa d36cbaa423 This corrects the implementation of Thumb ADR instruction. There are three issues:
1. it should accept only 4-byte aligned addresses
2. the maximum offset should be 1020
3. it should be encoded with the offset scaled by two bits

llvm-svn: 185528
2013-07-03 09:21:44 +00:00
Jim Grosbach 4739f2eb19 ARM: Better disassembly for pc-relative LDR.
When the operand is a plain immediate rather than a label, print it
as [pc, #imm] like we do for the Thumb2 wide encoding variant.

rdar://12154503

llvm-svn: 166991
2012-10-30 01:04:51 +00:00
Kevin Enderby 914223010c Fix issues with the ARM bl and blx thumb instructions and the J1 and J2 bits
for the assembler and disassembler.  Which were not being set/read correctly
for offsets greater than 22 bits in some cases.

Changes to lib/Target/ARM/ARMAsmBackend.cpp from Gideon Myles!

llvm-svn: 156118
2012-05-03 22:41:56 +00:00
Richard Barton 0fc56890ba Disallow YIELD and other allocated nop hints in pre-ARMv6 architectures.
llvm-svn: 155983
2012-05-02 09:43:18 +00:00
Jim Grosbach ad66de155b ARM add missing Thumb1 two-operand aliases for shift-by-immediate.
rdar://11222742

llvm-svn: 154457
2012-04-11 00:15:16 +00:00
Jim Grosbach 930f2f66e7 ARM assembly aliases for add negative immediates using sub.
'add r2, #-1024' should just use 'sub r2, #1024' rather than erroring out.
Thumb1 aliases for adding a negative immediate to the stack pointer,
also.

rdar://11192734

llvm-svn: 154123
2012-04-05 20:57:13 +00:00
Jim Grosbach 5a5ce63742 Thumb MUL assembly parsing for 3-operand form.
Get the source register that isn't tied to the destination register correct,
even when the assembly source operand order is backwards.

rdar://10428630

llvm-svn: 144322
2011-11-10 22:10:12 +00:00
Owen Anderson a455a0b1e7 Fix encoding for tBcc with immediate offset operand.
llvm-svn: 138889
2011-08-31 20:26:14 +00:00
Jim Grosbach 6a69d6902f Run the Thumb1 parser tests in Thumb2 mode, as well.
Thumb2 is a superset of Thumb1, so all of the encodings should still work.

llvm-svn: 138883
2011-08-31 19:50:28 +00:00
Owen Anderson 5c160fd243 Fix roundtripping of Thumb BL/BLX instructions with immediate offsets instead of labels.
llvm-svn: 138874
2011-08-31 18:30:20 +00:00
Jim Grosbach 6d606fbe14 Tweak Thumb1 ADD encoding selection a bit.
When the destination register of an add immediate instruction is
explicitly specified, encoding T1 is preferred, else encoding T2 is
preferred.

llvm-svn: 138862
2011-08-31 17:07:33 +00:00
Owen Anderson d16fb43b1f Fix encoding of PC-relative Thumb1 LDR's when using immediate offsets instead of labels.
llvm-svn: 138835
2011-08-30 22:10:03 +00:00
Owen Anderson 543c89fb15 Fix encoding of Thumb1 B instructions with immediate offsets, which is necessary for round-tripping.
llvm-svn: 138834
2011-08-30 22:03:20 +00:00
Owen Anderson a01bcbfc80 Support an extension of ARM asm syntax to allow immediate operands to ADR instructions. This is helpful for disassembler testing, and indeed exposed a disassembler bug that is also fixed here.
llvm-svn: 138635
2011-08-26 18:09:22 +00:00
Jim Grosbach 4b701af908 Thumb parsing and encoding for SUB (SP minu immediate).
Fix FiXME in test file. Remove FIXME for SUB (SP minus register) since that
form is Thumb2 only.

llvm-svn: 138494
2011-08-24 21:42:27 +00:00
Jim Grosbach 0a0b3071df Thumb parsing and encoding support for ADD SP instructions.
Fix the test FIXME and add parsing support for the ADD (SP plus immediate)
and ADD (SP plus register) instruction forms.

llvm-svn: 138488
2011-08-24 21:22:15 +00:00
Jim Grosbach 37563cd545 Thumb parsing and encoding for WFE, WFI and YIELD.
llvm-svn: 138364
2011-08-23 20:02:30 +00:00
Jim Grosbach ad9e8655ee Thumb parsing and encoding for UXTB and UXTH.
llvm-svn: 138363
2011-08-23 19:59:32 +00:00
Jim Grosbach 5e4ea175f6 Thumb parsing and encoding for TST.
llvm-svn: 138362
2011-08-23 19:53:17 +00:00
Jim Grosbach bb07e73e0d Thumb parsing and encoding for SXTB and SXTH.
llvm-svn: 138361
2011-08-23 19:51:42 +00:00
Jim Grosbach 5cc338da67 Thumb parsing and encoding for SVC.
llvm-svn: 138360
2011-08-23 19:49:10 +00:00
Jim Grosbach d88404fbaa Thumb parsing and encoding for SUB.
llvm-svn: 138359
2011-08-23 19:45:45 +00:00
Jim Grosbach f1ca6a6df6 Thumb parsing and encoding for STRH.
llvm-svn: 138352
2011-08-23 18:56:20 +00:00
Jim Grosbach 635aa69a91 Thumb parsing and encoding for STRB.
llvm-svn: 138349
2011-08-23 18:43:06 +00:00
Jim Grosbach 505be75900 Thumb parsing and encoding for tSTRspi.
llvm-svn: 138348
2011-08-23 18:39:41 +00:00
Jim Grosbach 6e546e0725 Thumb parsing and encoding for STR.
Not including tSTRspi.

llvm-svn: 138347
2011-08-23 18:33:38 +00:00
Jim Grosbach d80d169a04 Thumb parsing and encoding for STM.
llvm-svn: 138345
2011-08-23 18:15:37 +00:00
Jim Grosbach cc9d792ec1 Thumb parsing and encoding for SETEND.
llvm-svn: 138312
2011-08-22 23:58:02 +00:00
Jim Grosbach 3636be3c8f Thumb parsing and encoding for SBC.
llvm-svn: 138311
2011-08-22 23:55:58 +00:00
Jim Grosbach c3c32d9e09 Thumb parsing and encoding for RSB.
llvm-svn: 138308
2011-08-22 23:47:13 +00:00
Jim Grosbach 73661b8a37 Thumb parsing and encoding for ROR.
llvm-svn: 138304
2011-08-22 23:40:51 +00:00
Jim Grosbach a9d88df987 Thumb parsing and encoding for REV/REV16/REVSH.
llvm-svn: 138303
2011-08-22 23:39:25 +00:00
Jim Grosbach 40da063178 Thumb parsing and encoding for PUSH.
llvm-svn: 138290
2011-08-22 23:05:11 +00:00
Jim Grosbach 0869b900cc Thumb assembly parsing and encoding for POP.
llvm-svn: 138286
2011-08-22 23:00:19 +00:00
Jim Grosbach aa42847164 Thumb assembly parsing and encoding for ORR.
llvm-svn: 138245
2011-08-22 17:41:44 +00:00
Jim Grosbach 2597722e07 Thumb parsing and encoding support for NOP.
The irony is not lost that this is not a completely trivial patchset.

llvm-svn: 138143
2011-08-19 23:24:36 +00:00
Jim Grosbach 37aa348195 Thumb assembly parsing and encoding for NEG.
llvm-svn: 138131
2011-08-19 22:51:03 +00:00
Jim Grosbach fd4de3aeff Thumb assembly parsing and encoding for MVN.
llvm-svn: 138109
2011-08-19 22:09:23 +00:00
Jim Grosbach 8e048495c8 Thumb assembly parsing and encoding for MUL.
llvm-svn: 138108
2011-08-19 22:07:46 +00:00
Jim Grosbach d07e104844 Add FIXME.
llvm-svn: 138077
2011-08-19 20:48:54 +00:00
Jim Grosbach f86cd37bef Thumb assembly parsing and encoding for MOV.
llvm-svn: 138076
2011-08-19 20:46:54 +00:00
Jim Grosbach 1eb6eb0955 Thumb assembly parsing and encoding for LSR.
llvm-svn: 138065
2011-08-19 19:34:22 +00:00
Jim Grosbach 3245520ade Thumb assembly parsing and encoding for LSL(register).
llvm-svn: 138064
2011-08-19 19:30:58 +00:00
Jim Grosbach 5503c3a4e8 Thumb assembly parsing and encoding for LSL(immediate).
llvm-svn: 138063
2011-08-19 19:29:25 +00:00
Jim Grosbach 7c4739da3c Thumb assembly parsing and encoding for LDRSB and LDRSH.
llvm-svn: 138061
2011-08-19 19:17:58 +00:00
Jim Grosbach 26d3587bd8 Thumb assembly parsing and encoding for LDRH.
llvm-svn: 138060
2011-08-19 18:55:51 +00:00
Jim Grosbach a32c753ebf Thumb assembly parsing and encoding for LDRB.
llvm-svn: 138059
2011-08-19 18:49:59 +00:00
Jim Grosbach 106281f329 Thumb assembly parsing and encoding for LDR(register).
llvm-svn: 138056
2011-08-19 18:35:06 +00:00