1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

583 Commits

Author SHA1 Message Date
Owen Anderson
1cc1a1cb6a Match operand names to provide correct decoding for Thumb2 SMULL.
llvm-svn: 138294
2011-08-22 23:16:48 +00:00
Owen Anderson
b400952853 Provide a correct decoder hook for Thumb2 shifted registers. Found by randomized testing.
llvm-svn: 138292
2011-08-22 23:10:16 +00:00
Jim Grosbach
a5715c60b5 Clean up predicates on ARM target instruction aliases.
llvm-svn: 138249
2011-08-22 18:04:24 +00:00
Jim Grosbach
088d205084 Thumb instructions CBZ and CBNZ are Thumb2, not THumb1.
llvm-svn: 137956
2011-08-18 17:51:36 +00:00
Jim Grosbach
3efc45bfad ARM clean up the imm_sr operand class representation.
Represent the operand value as it will be encoded in the instruction. This
allows removing the specialized encoder and decoder methods entirely. Add
an assembler match class while we're at it to lay groundwork for parsing the
thumb shift instructions.

llvm-svn: 137879
2011-08-17 21:51:27 +00:00
Owen Anderson
1ec4fcb5d3 Improve operand validation for Thumb2 addressing modes.
llvm-svn: 137344
2011-08-11 20:40:40 +00:00
Owen Anderson
ffe1c55752 Replace the existing ARM disassembler with a new one based on the FixedLenDecoderEmitter.
This new disassembler can correctly decode all the testcases that the old one did, though
some "expected failure" testcases are XFAIL'd for now because it is not (yet) as strict in
operand checking as the old one was.

llvm-svn: 137144
2011-08-09 20:55:18 +00:00
Owen Anderson
e4638b5b2d Fix encodings for Thumb ASR and LSR immediate operands. They encode the range 1-32, with 32 encoded as 0.
llvm-svn: 137062
2011-08-08 20:42:17 +00:00
Eli Friedman
7a34419c6f Fix up the patterns for SXTB, SXTH, UXTB, and UXTH so that they are correctly active without HasT2ExtractPack. PR10611.
llvm-svn: 137061
2011-08-08 19:49:37 +00:00
Owen Anderson
11e2000c8c Fix broken encodings for the Thumb2 LDRD/STRD instructions.
llvm-svn: 136942
2011-08-04 23:18:05 +00:00
Jim Grosbach
767e9d16e6 ARM refactoring assembly parsing of memory address operands.
Memory operand parsing is a bit haphazzard at the moment, in no small part
due to the even more haphazzard representations of memory operands in the .td
files. Start cleaning that all up, at least a bit.

The addressing modes in the .td files will be being simplified to not be
so monolithic, especially with regards to immediate vs. register offsets
and post-indexed addressing. addrmode3 is on its way with this patch, for
example.

This patch is foundational to enable going back to smaller incremental patches
for the individual memory referencing instructions themselves. It does just
enough to get the basics in place and handle the "make check" regression tests
we already have.

Follow-up work will be fleshing out the details and adding more robust test
cases for the individual instructions, starting with ARM mode and moving from
there into Thumb and Thumb2.

llvm-svn: 136845
2011-08-03 23:50:40 +00:00
Jim Grosbach
c5cd3228c4 ARM parsing and encoding of SBFX and UBFX.
Encode the width operand as it encodes in the instruction, which simplifies
the disassembler and the encoder, by using the imm1_32 operand def. Add a
diagnostic for the context-sensitive constraint that the width must be in
the range [1,32-lsb].

llvm-svn: 136264
2011-07-27 21:09:25 +00:00
Jim Grosbach
f872c40f68 ARM cleanup of remaining extend instructions.
Refactor the rest of the extend instructions to not artificially distinguish
between a rotate of zero and a rotate of any other value. Replace the by-zero
versions with Pat<>'s for ISel.

llvm-svn: 136226
2011-07-27 17:48:13 +00:00
Jim Grosbach
7098677dbc ARM extend instructions simplification.
Refactor the SXTB, SXTH, SXTB16, UXTB, UXTH, and UXTB16 instructions to not
have an 'r' and an 'r_rot' version, but just a single version with a rotate
that can be zero. Use plain Pat<>'s for the ISel of the non-rotated version.

llvm-svn: 136225
2011-07-27 16:47:19 +00:00
Jim Grosbach
23c317b5a1 ARM rot_imm printing adjustment.
Allow the rot_imm operand to be optional. This sets the stage for refactoring
away the "rr" versions from the multiclasses and replacing them with Pat<>s.

llvm-svn: 136154
2011-07-26 21:44:37 +00:00
Jim Grosbach
24aa0e7c2e ARM cleanup of rot_imm encoding.
Start of cleaning this up a bit. First step is to remove the encoder hook by
storing the operand as the bits it'll actually encode to so it can just be
directly used. Map it to the assembly source values 8/16/24 when we print it.

llvm-svn: 136152
2011-07-26 21:28:43 +00:00
Jim Grosbach
ef3d573e31 ARM assembly parsing and encoding for SSAT16 instruction.
llvm-svn: 136006
2011-07-25 23:09:14 +00:00
Jim Grosbach
c1fe042da0 ARM assembly parsing and encoding for SSAT instruction.
Fix the Rn register encoding for both SSAT and USAT. Update the parsing of the
shift operand to correctly handle the allowed shift types and immediate ranges
and issue meaningful diagnostics when an illegal value or shift type is
specified. Add aliases to parse an ommitted shift operand (default value of
'lsl #0').

Add tests for diagnostics and proper encoding.

llvm-svn: 135990
2011-07-25 22:20:28 +00:00
Jim Grosbach
dd6b9fa0da ARM SSAT instruction 5-bit immediate handling.
The immediate is in the range 1-32, but is encoded as 0-31 in a 5-bit bitfield.
Update the representation such that we store the operand as 0-31, allowing us
to remove the encoder method and the special case handling in the disassembler.
Update the assembly parser and the instruction printer accordingly.

llvm-svn: 135823
2011-07-22 23:16:18 +00:00
Jim Grosbach
ebd66f344c ARM assembly parsing and encoding for SMC instruction.
llvm-svn: 135782
2011-07-22 18:13:31 +00:00
Jim Grosbach
fbaaa3ae98 Tidy up a bit.
Move common definitions for ARM and Thumb2 into ARMInstrFormats.td and rename
them to be a bit more descriptive that they're for the PKH instructions.

llvm-svn: 135617
2011-07-20 20:49:03 +00:00
Jim Grosbach
94a88152c9 ARM: Tidy up representation of PKH instruction.
The shift type is implied by the instruction (PKHBT vs. PKHTB) and so shouldn't
be also encoded as part of the shift value immediate. Otherwise we're able to
represent invalid instructions, plus it needlessly complicates the
representation. Preparatory work for asm parsing of these instructions.

llvm-svn: 135616
2011-07-20 20:32:09 +00:00
Jim Grosbach
66af8b4a40 ARM assembly parsing for MRC/MRC2/MRRC/MRRC2.
Add range checking to the immediate operands. Update tests accordingly.

llvm-svn: 135521
2011-07-19 20:35:35 +00:00
Jim Grosbach
294b83e3e2 ARM assembly parsing for MOV (immediate).
Add range checking for the immediate operand and handle the "mov" mnemonic
choosing between encodings based on the value of the immediate. Add tests
for fixups, encoding choice and values, and diagnostic for out of range values.

llvm-svn: 135500
2011-07-19 19:13:28 +00:00
Jim Grosbach
2ab898973a ARM MCRR/MCRR2 immediate operand range checking.
llvm-svn: 135192
2011-07-14 21:26:42 +00:00
Jim Grosbach
27ebbba831 ARM MCR/MCR2 assembly parsing operand constraints.
The immediate operands are restricted to 0-7. Enforce that when parsing
assembly.

llvm-svn: 135189
2011-07-14 21:19:17 +00:00
Owen Anderson
c68f12ff30 Add a target-indepedent entry to MCInstrDesc to describe the encoded size of an opcode. Switch ARM over to using that rather than its own special MCInstrDesc bits.
llvm-svn: 135106
2011-07-13 23:22:26 +00:00
Jim Grosbach
c0ec4205e2 ARM Assembler support for DBG instruction.
Add range checking and testing for parsing and encoding of DBG instruction.

llvm-svn: 135102
2011-07-13 22:59:38 +00:00
Jim Grosbach
c9e49f3b51 Revert 135093. Think-o.
llvm-svn: 135094
2011-07-13 22:06:11 +00:00
Jim Grosbach
545a3f4802 Correct range for thumb co-processor immediate
llvm-svn: 135093
2011-07-13 22:03:11 +00:00
Jim Grosbach
fd2ebb4552 Range checking for CDP[2] immediates.
llvm-svn: 135092
2011-07-13 22:01:08 +00:00
Jim Grosbach
76ba2e7e9c Cleanup Thumb co-processor instructions a bit.
Combine redundant base classes and such. No indended functional change.

llvm-svn: 135085
2011-07-13 21:35:10 +00:00
Jim Grosbach
385d9a3e57 Parameterize away the ARM T1Cop class.
llvm-svn: 135082
2011-07-13 21:17:59 +00:00
Jim Grosbach
d3b15141b8 Fix predicates for Thumb co-processor instructions.
They're all Thumb2 only, not just some of them. More refactoring cleanup
coming.

llvm-svn: 135081
2011-07-13 21:14:23 +00:00
Jim Grosbach
3790b35044 Use tPseudoExpand for tTAILJMPd and tTAILJMPdND.
llvm-svn: 134732
2011-07-08 20:32:21 +00:00
Jim Grosbach
5dd61ef1e9 Use TableGen'erated pseudo lowering for ARM.
Hook up the TableGen lowering for simple pseudo instructions for ARM and
use it for a subset of the many pseudos the backend has as proof of concept.

More conversions to come.

llvm-svn: 134705
2011-07-08 17:40:42 +00:00
Jim Grosbach
461adc233e ARMv7M vs. ARMv7E-M support.
The DSP instructions in the Thumb2 instruction set are an optional extension
in the Cortex-M* archtitecture. When present, the implementation is considered
an "ARMv7E-M implementation," and when not, an "ARMv7-M implementation."

Add a subtarget feature hook for the v7e-m instructions and hook it up. The
cortex-m3 cpu is an example of a v7m implementation, while the cortex-m4 is
a v7e-m implementation.

rdar://9572992

llvm-svn: 134261
2011-07-01 21:12:19 +00:00
Jim Grosbach
48ec24b950 Pseudo-ize t2MOVCC[ri].
t2MOVCC[ri] are just t2MOV[ri] instructions, so properly pseudo-ize them.
The Thumb1 versions, tMOVCC[ri] were only present for use by the size-
reduction pass, so they're no longer necessary at all and can be deleted.

llvm-svn: 134242
2011-07-01 17:14:11 +00:00
Jim Grosbach
fddcf02338 Pseudo-ize the Thumb tTPsoft instruction.
It's just a call to a special helper function. Get rid of the T2 variant
entirely, as it's identical to the Thumb1 version.

llvm-svn: 134178
2011-06-30 19:38:01 +00:00
Jim Grosbach
8c1fb3c4e1 Pseudo-ize the t2LDMIA_RET instruction.
It's just a t2LDMIA_UPD instruction with extra codegen properties, so it
doesn't need the encoding information. As a side-benefit, we now correctly
recognize for instruction printing as a 'pop' instruction.

llvm-svn: 134173
2011-06-30 18:25:42 +00:00
Jim Grosbach
746970d850 Remove redundant Thumb2 ADD/SUB SP instruction definitions.
Unlike Thumb1, Thumb2 does not have dedicated encodings for adjusting the
stack pointer. It can just use the normal add-register-immediate encoding
since it can use all registers as a source, not just R0-R7. The extra
instruction definitions are just duplicates of the normal instructions with
the (not well enforced) constraint that the source register was SP.

llvm-svn: 134114
2011-06-29 23:25:04 +00:00
Jim Grosbach
33470a73f0 ARM Thumb2 asm syntax optional destination operand for binary operators.
When the destination operand is the same as the first source register
operand for arithmetic instructions, the destination operand may be omitted.

For example, the following two instructions are equivalent:
and r1, #ff
and r1, r1, #ff

rdar://9672867

llvm-svn: 133973
2011-06-28 00:19:13 +00:00
Jim Grosbach
190b9d7ec0 ARM Assembly support for Thumb mov-immediate.
Correctly parse the forms of the Thumb mov-immediate instruction:
  1. 8-bit immediate 0-255.
  2. 12-bit shifted-immediate.

The 16-bit immediate "movw" form is also legal with just a "mov" mnemonic,
but is not yet supported. More parser logic necessary there due to fixups.

llvm-svn: 133966
2011-06-27 23:54:06 +00:00
Evan Cheng
dc39e02b91 Reorg. No functionality change.
llvm-svn: 133533
2011-06-21 19:00:54 +00:00
Evan Cheng
40adfc21f6 Teach dag combine to match halfword byteswap patterns.
1. (((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)
   => (bswap x) >> 16
2. ((x&0xff)<<8)|((x&0xff00)>>8)|((x&0xff000000)>>8)|((x&0x00ff0000)<<8))
   => (rotl (bswap x) 16)

This allows us to eliminate most of the def : Pat patterns for ARM rev16
revsh instructions. It catches many more cases for ARM and x86.

rdar://9609108

llvm-svn: 133503
2011-06-21 06:01:08 +00:00
Evan Cheng
df9192b200 Add an alternative rev16 pattern. We should figure out a better way to handle these complex rev patterns. rdar://9609108
llvm-svn: 133289
2011-06-17 20:47:21 +00:00
Evan Cheng
30f84a59ae Another revsh pattern. rdar://9609059
llvm-svn: 133064
2011-06-15 17:17:48 +00:00
Jim Grosbach
eff8e5d153 Clean up a few 80 column violations.
llvm-svn: 132946
2011-06-13 22:54:22 +00:00
Andrew Trick
a46c28e96c Fix for setjmp/longjmp exception handling on ARM. setjmp clobbers CPSR.
rdar://problem/9556069

llvm-svn: 132699
2011-06-07 00:08:49 +00:00
Bruno Cardoso Lopes
0bdb365634 Fix ssat and ssat16 encodings for ARM and Thumb. The bit position value
must be encoded decremented by one. Only add encoding tests for ssat16
because ssat can't be parsed yet.

llvm-svn: 132324
2011-05-31 03:33:27 +00:00
Bruno Cardoso Lopes
6d5e369a10 Add support for ARM ldrexd/strexd intrinsics. They both use i32 register pairs
to load/store i64 values. Since there's no current support to explicitly
declare such restrictions, implement it by using specific hardcoded register
pairs during isel.

llvm-svn: 132248
2011-05-28 04:07:29 +00:00
Cameron Zwarich
ed470705c0 Actually, the address operand of the Thumb2 LDREX / STREX instructions *can*
take r13, so we can just make it a GPR. This fixes PR8825.

llvm-svn: 131507
2011-05-17 23:26:20 +00:00
Cameron Zwarich
15807bac51 Correct a minor problem with the Thumb2 LDREX and STREX instruction encodings. They
were marked as taking a tGPR when in reality they take an rGPR.

llvm-svn: 131506
2011-05-17 23:11:12 +00:00
Jakob Stoklund Olesen
da28d31f03 Mark ultra-super-registers QQQQ as call-clobbered instead of the D sub-registers.
LiveVariables doesn't understand that clobbering D0 and D1 completely overwrites
Q0, so if Q0 is live-in to a function, its live range will extend beyond a
function call that only clobbers D0 and D1. This shows up in the
ARM/2009-11-01-NeonMoves test case.

LiveVariables should probably implement the much stricter rules for physreg
liveness that RAFast imposes - a physreg is killed by the first use of any
alias.

llvm-svn: 130801
2011-05-03 22:31:24 +00:00
Bruno Cardoso Lopes
c818d784a2 Fold ARM coprocessor intrinsics patterns into the instructions defs whenever
it's possible.

llvm-svn: 130764
2011-05-03 17:29:29 +00:00
Bruno Cardoso Lopes
9dd575e4a9 Add a few ARM coprocessor intrinsics. Testcases included
llvm-svn: 130763
2011-05-03 17:29:22 +00:00
Eli Friedman
1940912660 Switch to ImmLeaf (which can be used by FastISel) for a few more common ARM/Thumb2 patterns.
llvm-svn: 130552
2011-04-29 22:48:03 +00:00
Andrew Trick
88152ec6d2 Teach Thumb2 isel to fold and->rotr ==> ROR.
Generalization of Nate Begeman's patch!

llvm-svn: 130502
2011-04-29 14:18:15 +00:00
Eric Christopher
bea4df9acc Let the immediate leaf pattern take transforms and switch the signed
immediate patterns in arm to using the pattern.

Handles rdar://9299434

llvm-svn: 130386
2011-04-28 05:49:04 +00:00
Andrew Trick
a130d110d1 Thumb2 and ARM add/subtract with carry fixes.
Fixes Thumb2 ADCS and SBCS lowering: <rdar://problem/9275821>.
t2ADCS/t2SBCS are now pseudo instructions, consistent with ARM, so the
assembly printer correctly prints the 's' suffix.

Fixes Thumb2 adde -> SBC matching to check for live/dead carry flags.

Fixes the internal ARM machine opcode mnemonic for ADCS/SBCS.
Fixes ARM SBC lowering to check for live carry (potential bug).

llvm-svn: 130048
2011-04-23 03:55:32 +00:00
Johnny Chen
d7a6b974bc Thumb2 BFC was insufficiently encoded.
rdar://problem/9292717

llvm-svn: 129619
2011-04-15 22:52:15 +00:00
Chris Lattner
0304b82f80 Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129558
2011-04-15 05:18:47 +00:00
Johnny Chen
f268f057f4 For t2BFI, both Inst{26} and Inst{5} "should" be 0.
Ref: I.1 Instruction encoding diagrams and pseudocode
llvm-svn: 129552
2011-04-15 00:35:08 +00:00
Johnny Chen
dd6fc153b1 The LDR*T/STR*T (unpriviledged load/store) operations don't take SP or PC as Rt.
rdar://problem/9279440

llvm-svn: 129469
2011-04-13 21:04:32 +00:00
Johnny Chen
0da4c8bfec Forgot to add this change for http://llvm.org/viewvc/llvm-project?view=rev&revision=129387.
llvm-svn: 129451
2011-04-13 16:56:08 +00:00
Jakob Stoklund Olesen
b2c47a2087 Add @earlyclobber constraints to the writeback register of all ARM store instructions.
The ARMARM specifies these instructions as unpredictable when storing the
writeback register. This shouldn't affect code generation much since storing a
pointer to itself is quite rare.

llvm-svn: 129409
2011-04-12 23:27:48 +00:00
Johnny Chen
e3c070e904 The Thumb2 RFE instructions need to have their second halfword fully specified.
In addition, the base register is not rGPR, but GPR with th exception that:

    if n == 15 then UNPREDICTABLE

rdar://problem/9273836

llvm-svn: 129391
2011-04-12 21:41:51 +00:00
Johnny Chen
4435fc93c9 The Thumb2 Ld, St, and Preload instructions with the i12 forms should have its Inst{23}
be specified as '1' (add = TRUE).

Also add a utility function for Thumb2.

llvm-svn: 129377
2011-04-12 18:48:00 +00:00
Bruno Cardoso Lopes
a5de5df6d8 Add asm parsing support w/ testcases for strex/ldrex family of instructions
llvm-svn: 128236
2011-03-24 21:04:58 +00:00
Bruno Cardoso Lopes
c8d8dc9869 Change MRC and MRC2 instructions to model the output register properly
llvm-svn: 128085
2011-03-22 15:06:24 +00:00
Evan Cheng
93d04c1c00 Match a few more obvious patterns to revsh. rdar://9147637.
llvm-svn: 127913
2011-03-18 21:52:42 +00:00
Owen Anderson
c23c6e0c1a Thumb2 PC-relative loads require a fixup rather than just an immediate.
llvm-svn: 127888
2011-03-18 17:42:55 +00:00
Jim Grosbach
6ee5aef028 Remove some dead patterns.
llvm-svn: 127601
2011-03-14 18:34:35 +00:00
Bruno Cardoso Lopes
ad05904e0b Add assembly parsing support for "msr" and also fix its encoding. Also add
testcases for the disassembler to make sure it still works for "msr".

llvm-svn: 125948
2011-02-18 19:45:59 +00:00
Bruno Cardoso Lopes
e65a98b127 Fix encoding and add parsing support for the arm/thumb CPS instruction:
- Add custom operand matching for imod and iflags.
- Rename SplitMnemonicAndCC to SplitMnemonic since it splits more than CC
  from mnemonic.
- While adding ".w" as an operand, don't change "Head" to avoid passing the
  wrong mnemonic to ParseOperand.
- Add asm parser tests.
- Add disassembler tests just to make sure it can catch all cps versions.

llvm-svn: 125489
2011-02-14 13:09:44 +00:00
Owen Anderson
899a6d74bf Revert both r121082 (which broke a bunch of constant pool stuff) and r125074 (which worked around it). This should get us back to the old, correct behavior, though it will make the integrated assembler unhappy for the time being.
llvm-svn: 125127
2011-02-08 22:39:40 +00:00
Bob Wilson
e742c362e3 Remove inaccurate comments: so_imm and t2_so_imm operands are not encoded
until the instructions are emitted or printed.

llvm-svn: 125010
2011-02-07 17:43:06 +00:00
Bruno Cardoso Lopes
2d6bd03b18 fix the encoding and add testcases for ARM nop, yield, wfe and wfi instructions
llvm-svn: 124288
2011-01-26 13:28:14 +00:00
Evan Cheng
0dfe28a9b5 Last round of fixes for movw + movt global address codegen.
1. Fixed ARM pc adjustment.
2. Fixed dynamic-no-pic codegen
3. CSE of pc-relative load of global addresses.

It's now enabled by default for Darwin.

llvm-svn: 123991
2011-01-21 18:55:51 +00:00
Bruno Cardoso Lopes
2f96371a7a Fix the encoding of QADD/SUB, QDADD/SUB. While qadd16, qadd8 use "rd, rn, rm",
qadd and qdadd uses "rd, rm, rn", the same applies to the 'sub' variants. This
is described in ARM manuals and matches the encoding used by the gnu assembler.

llvm-svn: 123975
2011-01-21 14:07:40 +00:00
Bruno Cardoso Lopes
6aeb2e320f Fix the encoding and parsing of clrex instruction
llvm-svn: 123936
2011-01-20 19:18:32 +00:00
Bruno Cardoso Lopes
c0f87c11d6 Change instruction names for consistency
llvm-svn: 123930
2011-01-20 18:36:07 +00:00
Bruno Cardoso Lopes
5f06c0aa3b Add cdp/cdp2 instructions for thumb/thumb2
llvm-svn: 123929
2011-01-20 18:32:09 +00:00
Bruno Cardoso Lopes
75712e8a7a Add mcr*2 and mr*c2 support to thumb2 targets
llvm-svn: 123919
2011-01-20 16:58:48 +00:00
Evan Cheng
d9fdc9771e Correct itinerary entry for t2MOV_pic_ga_add_pc.
llvm-svn: 123907
2011-01-20 08:43:03 +00:00
Evan Cheng
6dc21c7358 Sorry, several patches in one.
TargetInstrInfo:
Change produceSameValue() to take MachineRegisterInfo as an optional argument.
When in SSA form, targets can use it to make more aggressive equality analysis.

Machine LICM:
1. Eliminate isLoadFromConstantMemory, use MI.isInvariantLoad instead.
2. Fix a bug which prevent CSE of instructions which are not re-materializable.
3. Use improved form of produceSameValue.

ARM:
1. Teach ARM produceSameValue to look pass some PIC labels.
2. Look for operands from different loads of different constant pool entries
   which have same values.
3. Re-implement PIC GA materialization using movw + movt. Combine the pair with
   a "add pc" or "ldr [pc]" to form pseudo instructions. This makes it possible
   to re-materialize the instruction, allow machine LICM to hoist the set of
   instructions out of the loop and make it possible to CSE them. It's a bit
   hacky, but it significantly improve code quality.
4. Some minor bug fixes as well.

With the fixes, using movw + movt to materialize GAs significantly outperform the
load from constantpool method. 186.crafty and 255.vortex improved > 20%, 254.gap
and 176.gcc ~10%.

llvm-svn: 123905
2011-01-20 08:34:58 +00:00
Evan Cheng
7e2b414953 Don't forget to emit the load from indirect symbol when using movw + movt to materialize GA indirect symbols.
llvm-svn: 123809
2011-01-19 02:16:49 +00:00
Bruno Cardoso Lopes
82c6fe3dfe Fix MRS encoding for arm and thumb.
llvm-svn: 123778
2011-01-18 21:31:35 +00:00
Bruno Cardoso Lopes
6e4c5af01e Fix the encoding of t2ISB by using the right class and also parse it correctly
llvm-svn: 123776
2011-01-18 21:17:09 +00:00
Bruno Cardoso Lopes
94247155c4 Add support for parsing and encoding ARM's official syntax for the BFI instruction
llvm-svn: 123770
2011-01-18 20:45:56 +00:00
Daniel Dunbar
ba39b2fdc1 McARM: Start marking T2 address operands as such, for the benefit of the parser.
llvm-svn: 123722
2011-01-18 03:06:03 +00:00
Evan Cheng
53ec6fc591 Materialize GA addresses with movw + movt pairs for Darwin in PIC mode. e.g.
movw    r0, :lower16:(L_foo$non_lazy_ptr-(LPC0_0+4))
        movt    r0, :upper16:(L_foo$non_lazy_ptr-(LPC0_0+4))
LPC0_0:
        add     r0, pc, r0

It's not yet enabled by default as some tests are failing. I suspect bugs in
down stream tools.

llvm-svn: 123619
2011-01-17 08:03:18 +00:00
Evan Cheng
cc474b4864 Model :upper16: and :lower16: as ARM specific MCTargetExpr. This is a step
in the right direction. It eliminated some hacks and will unblock codegen
work. But it's far from being done. It doesn't reject illegal expressions,
e.g. (FOO - :lower16:BAR). It also doesn't work in Thumb2 mode at all.

llvm-svn: 123369
2011-01-13 07:58:56 +00:00
Daniel Dunbar
3567bd2bcb McARM: Mark some T2 ...s instructions as codegen only, they aren't real
instructions but are restricted pseudo forms.

llvm-svn: 123177
2011-01-10 15:26:39 +00:00
Jim Grosbach
9017f2d179 Add bits 31-28 to the Thumb2 encoding of TBB/TBH.
llvm-svn: 122076
2010-12-17 18:42:56 +00:00
Jim Grosbach
30e7f0d09e Tweak a few pseudo-inst pattern base classes.
llvm-svn: 121878
2010-12-15 19:03:16 +00:00
Jim Grosbach
8278d5692a The new t2LEApcrel* pseudo instructions need the size specified.
rdar://8768390

llvm-svn: 121876
2010-12-15 18:48:45 +00:00
Jim Grosbach
ef58d5968e trailing whitespace.
llvm-svn: 121789
2010-12-14 20:46:39 +00:00
Owen Anderson
c84f8c23b3 Second attempt at make Thumb2 LEAs pseudos. This time, perform the lowering much later, which makes the entire
process cleaner.

llvm-svn: 121735
2010-12-14 00:36:49 +00:00
Owen Anderson
af1dde2673 Revert r121721, which broke buildbots.
llvm-svn: 121726
2010-12-13 22:51:08 +00:00
Owen Anderson
c298c8ed4d Make Thumb2 LEA-like instruction into pseudos, which map down to ADR. Provide correct fixups for Thumb2 ADR,
which is _of course_ different from ARM ADR fixups, or any other Thumb2 fixup.

llvm-svn: 121721
2010-12-13 22:29:52 +00:00
Owen Anderson
4ec912b842 In Thumb2, direct branches can be encoded as either a "short" conditional branch with a null predicate, or
as a "long" direct branch.  While the mnemonics are the same, they encode the branch offset differently, and
the Darwin assembler appears to prefer the "long" form for direct branches.  Thus, in the name of bitwise
equivalence, provide encoding and fixup support for it.

llvm-svn: 121710
2010-12-13 19:31:11 +00:00
Owen Anderson
44ad90c850 Fix Thumb2 encodings of STREX and LDREX.
llvm-svn: 121579
2010-12-10 21:52:38 +00:00
Jim Grosbach
82dd80c956 Correct encoding of rotation immediate for Thumb2 instructions. rdar://8755999
llvm-svn: 121525
2010-12-10 21:24:18 +00:00
Jim Grosbach
467e860805 More trivial cleanup. No need to define the EncoderMethod property type. Can
just assign to it.

llvm-svn: 121523
2010-12-10 20:53:44 +00:00
Owen Anderson
96545f21b9 Fix encoding of the immediate operands on post-indexed LDR and friends.
llvm-svn: 121354
2010-12-09 02:56:12 +00:00
Jim Grosbach
e38a2a39c6 The add/sub SP instructions are really pseudos. The assembler should ignore
them.

llvm-svn: 121345
2010-12-09 01:21:27 +00:00
Owen Anderson
b956593730 Fix Thumb2 BCC encoding and fixups.
llvm-svn: 121329
2010-12-09 00:27:41 +00:00
Jim Grosbach
5a00173ead Clean up the add/sub w/ SP source reg instructions in Thumb2 a bit. Add a FIXME
for more thorough cleanup.

llvm-svn: 121315
2010-12-08 23:30:19 +00:00
Jim Grosbach
2eda2e0be9 Fix T2TwoRegImm and use it for t2ADDrSPi12 and friends.
llvm-svn: 121314
2010-12-08 23:24:29 +00:00
Jim Grosbach
7a9e43e642 T2TwoRegImm isn't right for t2SUBrSPi12. Use T2I instead.
llvm-svn: 121311
2010-12-08 23:13:01 +00:00
Jim Grosbach
4f11f0f871 Add operand encoding for Thumb2 subw SP + imm. rdar://8745434
llvm-svn: 121310
2010-12-08 23:12:09 +00:00
Jim Grosbach
a423fbc4c7 Add operand encoding for Thumb2 addw Rn + imm. rdar://8745434
llvm-svn: 121309
2010-12-08 23:04:16 +00:00
Jim Grosbach
51082ed2a4 Add operand encoding for Thumb2 addw SP + imm. rdar://8745434
llvm-svn: 121305
2010-12-08 22:50:19 +00:00
Jim Grosbach
e1eb84a44a Parameterize opcode encoding bits for Thumb2 extended precision integer
multiply instructions.

llvm-svn: 121301
2010-12-08 22:38:41 +00:00
Jim Grosbach
13c16125f1 Fix operand encoding for Thumb2 extended precision multiplies. rdar://8745555
llvm-svn: 121297
2010-12-08 22:29:28 +00:00
Jim Grosbach
063c38c6df Simplify T2 operand assignment notation a bit. No need to specify a bit range
for the source field when it's the whole thing that's being referenced.

llvm-svn: 121291
2010-12-08 22:10:43 +00:00
Owen Anderson
a23e10f29d Fix Thumb2 encoding of the S bit.
llvm-svn: 121182
2010-12-07 20:50:15 +00:00
Jim Grosbach
1aa6a676cf Refactor the ARM CMPz* patterns to just use the normal CMP instructions when
possible. They were duplicates for everything exception the source pattern
before.

llvm-svn: 121179
2010-12-07 20:41:06 +00:00
Owen Anderson
81f8b084e6 Second attempt at converting Thumb2's LDRpci, including updating the gazillion places that need to know about it.
llvm-svn: 121082
2010-12-07 00:45:21 +00:00
Owen Anderson
8e9cb84ea2 Revert r121021, which broke the buildbots.
llvm-svn: 121026
2010-12-06 18:57:40 +00:00
Owen Anderson
0c51a02230 Improve handling of Thumb2 PC-relative loads by converting LDRpci (and friends) to Pseudos.
llvm-svn: 121021
2010-12-06 18:35:51 +00:00
Jim Grosbach
0bd3b0fd6c Trailing whitespace.
llvm-svn: 120748
2010-12-02 23:05:38 +00:00
Owen Anderson
8802c68592 Add correct encodings for STRD and LDRD, including fixup support. Additionally, update these to unified syntax.
llvm-svn: 120589
2010-12-01 19:18:46 +00:00
Owen Anderson
5aff471eb8 Simplify the encoding of reg+/-imm12 values that allow PC-relative encoding. This allows the
Thumb2 encoding to share code with the ARM encoding, which gets use fixup support for free.
It also allows us to fold away at least one codegen-only pattern.

llvm-svn: 120481
2010-11-30 22:45:47 +00:00
Owen Anderson
20a6f2bd2e Provide Thumb2 encodings for a few miscellaneous instructions.
llvm-svn: 120455
2010-11-30 20:00:01 +00:00
Owen Anderson
5f7b3e919b Add encoding support for Thumb2 PLD and PLI instructions.
llvm-svn: 120449
2010-11-30 19:19:31 +00:00
Owen Anderson
6581027075 Provide encodings for a few more load/store variants.
llvm-svn: 120439
2010-11-30 18:38:28 +00:00
Owen Anderson
b6e1c56c79 Correct Thumb2 encodings for a much wider range of loads and stores.
llvm-svn: 120364
2010-11-30 00:14:31 +00:00
Owen Anderson
14abbb1a2e Provide Thumb2 encodings for basic loads and stores.
llvm-svn: 120340
2010-11-29 22:44:32 +00:00
Evan Cheng
78baa6f30d Mark Darwin call instructions as using "r7" to prevent the frame-register
assignment instructions from being moved below / above calls.
rdar://8690640

llvm-svn: 120339
2010-11-29 22:43:27 +00:00
Jim Grosbach
90cb1bbd23 Nuke dead isCodeGenOnly annotation and extraneous comment.
llvm-svn: 120338
2010-11-29 22:40:58 +00:00
Jim Grosbach
208782384a tidy up.
llvm-svn: 120335
2010-11-29 22:38:48 +00:00
Jim Grosbach
89e90b7310 Pseudo-ize Thumb2 jump tables with explicit MC lowering to the raw
instructions. This simplifies instruction printing and disassembly.

llvm-svn: 120333
2010-11-29 22:37:40 +00:00
Jim Grosbach
71042b51a1 Rename t2 TBB and TBH instructions to reference that they encode the jump table
data. Next up, pseudo-izing them.

llvm-svn: 120320
2010-11-29 21:28:32 +00:00
Owen Anderson
4b82810d8c Improving the factoring of several instruction encodings.
llvm-svn: 120317
2010-11-29 20:38:48 +00:00
Owen Anderson
049177ff7f Thumb2 encodings for MSR and MRS.
llvm-svn: 120309
2010-11-29 19:29:15 +00:00
Owen Anderson
78d84a1921 Thumb2 encodings for system instructions.
llvm-svn: 120307
2010-11-29 19:22:08 +00:00
Owen Anderson
b29182b60f Thumb2 encodings for branches and IT blocks.
llvm-svn: 120306
2010-11-29 18:54:38 +00:00
Jim Grosbach
48531dd967 Remove trailing whitespace.
llvm-svn: 119806
2010-11-19 17:11:02 +00:00
Owen Anderson
99c5ea71f7 Fix decoding ambiguities of stdrex and ldrex.
llvm-svn: 119801
2010-11-19 13:11:50 +00:00
Evan Cheng
4a88903266 Fix an obvious oversight.
llvm-svn: 119792
2010-11-19 06:15:10 +00:00
Owen Anderson
fa216abdd5 Provide Thumb2 encodings for strex and ldrex.
llvm-svn: 119768
2010-11-19 00:28:38 +00:00
Owen Anderson
ca14474db4 Fix encodings for pkhbt, and fix some tests where I accidentally tested ARM mode instead of Thumb2.
llvm-svn: 119755
2010-11-18 23:29:56 +00:00
Owen Anderson
2f9d8861ac Provide Thumb2 encodings for mov's that come from MOVCC SDNodes.
llvm-svn: 119744
2010-11-18 21:46:31 +00:00
Owen Anderson
25dc3a4fe6 More Thumb2 encodings.
llvm-svn: 119737
2010-11-18 21:15:19 +00:00
Owen Anderson
eec8c82d32 Fill out the set of Thumb2 multiplication operator encodings.
llvm-svn: 119733
2010-11-18 20:32:18 +00:00
Jim Grosbach
2f9a2efb3c ARM PseudoInst instructions don't need or use an assembler string. Get rid of
the operand to the pattern.

llvm-svn: 119607
2010-11-18 01:38:26 +00:00
Owen Anderson
b7970b2c6a Try again at providing Thumb2 encodings for basic multiplication operators.
llvm-svn: 119601
2010-11-18 01:08:42 +00:00
Owen Anderson
e8906ba112 Revert r119593 while I figure out my testing disagrees with the buildbot.
llvm-svn: 119597
2010-11-18 00:42:51 +00:00
Owen Anderson
47a64ab90c Provide correct Thumb2 encodings for basic multiplication operators.
llvm-svn: 119593
2010-11-18 00:19:10 +00:00
Owen Anderson
ea6ac4cdff Second attempt at correct encodings for Thumb2 bitfield instructions.
llvm-svn: 119575
2010-11-17 22:16:31 +00:00
Owen Anderson
2adebbb603 Revert r119551, which broke buildbots.
llvm-svn: 119555
2010-11-17 20:48:51 +00:00
Owen Anderson
c7750780fc Provide Thumb2 encodings for bitfield instructions.
llvm-svn: 119551
2010-11-17 20:35:29 +00:00
Evan Cheng
ce610bd6b3 Remove ARM isel hacks that fold large immediates into a pair of add, sub, and,
and xor. The 32-bit move immediates can be hoisted out of loops by machine
LICM but the isel hacks were preventing them.

Instead, let peephole optimization pass recognize registers that are defined by
immediates and the ARM target hook will fold the immediates in.

Other changes include 1) do not fold and / xor into cmp to isel TST / TEQ
instructions if there are multiple uses. This happens when the 'and' is live
out, machine sink would have sinked the computation and that ends up pessimizing
code. The peephole pass would recognize situations where the 'and' can be
toggled to define CPSR and eliminate the comparison anyway.

2) Move peephole pass to after machine LICM, sink, and CSE to avoid blocking
important optimizations.

rdar://8663787, rdar://8241368

llvm-svn: 119548
2010-11-17 20:13:28 +00:00
Owen Anderson
d88cfe5453 More miscellaneous Thumb2 encodings.
llvm-svn: 119546
2010-11-17 19:57:38 +00:00
Bill Wendling
d2da6dff5e Use the correct variable names so that the encodings will be correct.
llvm-svn: 119403
2010-11-16 23:44:49 +00:00
Bill Wendling
655c05147e L_bit doesn't work here.
llvm-svn: 119325
2010-11-16 02:20:22 +00:00
Bill Wendling
2ac47f0959 - Remove dead patterns.
- Add encodings to the *LDMIA_RET instrs. Probably not needed...

llvm-svn: 119323
2010-11-16 02:08:45 +00:00
Bill Wendling
b450d320ec Encode the multi-load/store instructions with their respective modes ('ia',
'db', 'ib', 'da') instead of having that mode as a separate field in the
instruction. It's more convenient for the asm parser and much more readable for
humans.
<rdar://problem/8654088>

llvm-svn: 119310
2010-11-16 01:16:36 +00:00
Owen Anderson
686fae59e6 Add Thumb2 encodings for mov and friends.
llvm-svn: 119295
2010-11-16 00:29:56 +00:00
Owen Anderson
3d47a3536c Attempt to provide encodings for some miscellaneous Thumb2 encodings.
llvm-svn: 119187
2010-11-15 21:30:39 +00:00
Owen Anderson
db1a4541c2 Provide Thumb2 encodings for sxtb and friends.
llvm-svn: 119185
2010-11-15 21:12:05 +00:00
Owen Anderson
0bb2efeb7d Add Thumb2 encodings for comparison and shift operators.
llvm-svn: 119176
2010-11-15 19:58:36 +00:00
Owen Anderson
5ae5db8931 Add correct Thumb2 encodings for mvn and friends.
llvm-svn: 119170
2010-11-15 18:45:17 +00:00
Chris Lattner
b2daeac125 add fields to the .td files unconditionally, simplifying tblgen a bit.
Switch the ARM backend to use 'let' instead of 'set' with this change.

llvm-svn: 119120
2010-11-15 05:19:05 +00:00
Owen Anderson
ad4f83df6a Second attempt at providing correct encodings for Thumb2 binary operators.
llvm-svn: 119029
2010-11-14 05:37:38 +00:00
Bill Wendling
49dd03e223 Comment out the defms until they're activated.
llvm-svn: 119000
2010-11-13 11:20:05 +00:00
Bill Wendling
fadcb3cded Add uses of the *_ldst_multi multiclasses. These aren't used yet.
llvm-svn: 118999
2010-11-13 10:57:02 +00:00
Bill Wendling
184bc1368d Convert the modes to lower case.
llvm-svn: 118998
2010-11-13 10:43:34 +00:00
Bill Wendling
aa9ca6fcca Add *_ldst_mult multiclasses to the ARM back-end. These will be used in the
future to separate out the ia, ib, da, db variants of the load/store multiple
instructions.

llvm-svn: 118995
2010-11-13 09:09:38 +00:00
Evan Cheng
239d9b439d Conditional moves are slightly more expensive than moves.
llvm-svn: 118985
2010-11-13 05:14:20 +00:00
Evan Cheng
a7d3c3d387 Add conditional move of large immediate.
llvm-svn: 118968
2010-11-13 02:25:14 +00:00
Owen Anderson
053d9fb9b5 Revert r118939 while I work out why it broke some buildbots.
llvm-svn: 118942
2010-11-12 23:36:03 +00:00
Owen Anderson
f8192cf0cc Attemt to provide correct encodings for Thumb2 binary operators.
llvm-svn: 118939
2010-11-12 23:18:11 +00:00
Evan Cheng
19f018a1be Add conditional mvn instructions.
llvm-svn: 118935
2010-11-12 22:42:47 +00:00
Owen Anderson
f1ffc8fdc9 First stab at providing correct Thumb2 encodings, start with adc.
llvm-svn: 118924
2010-11-12 21:12:40 +00:00
Evan Cheng
165e65f53a Fix @llvm.prefetch isel. Selecting between pld / pldw using the first immediate rw. There is currently no intrinsic that matches to pli.
llvm-svn: 118237
2010-11-04 05:19:35 +00:00
Evan Cheng
eab7251695 Fix preload instruction isel. Only v7 supports pli, and only v7 with mp extension supports pldw. Add subtarget attribute to denote mp extension support and legalize illegal ones to nothing.
llvm-svn: 118160
2010-11-03 06:34:55 +00:00
Evan Cheng
b41703bc2f Add support to match @llvm.prefetch to pld / pldw / pli. rdar://8601536.
llvm-svn: 118152
2010-11-03 05:14:24 +00:00
Jim Grosbach
c10d3f3d4b Break ARM addrmode4 (load/store multiple base address) into its constituent
parts. Represent the operation mode as an optional operand instead.
rdar://8614429

llvm-svn: 118137
2010-11-03 01:01:43 +00:00
Chris Lattner
d3f7a5d3bd Completely reject instructions that have an operand in their
ins/outs list that isn't specified by their asmstring.  Previously
the asmmatcher would just force a 0 register into it, which clearly
isn't right.  Mark a bunch of ARM instructions that use this as 
isCodeGenOnly.  Some of them are clearly pseudo instructions (like
t2TBB) others use a weird hasExtraSrcRegAllocReq thing that will
either need to be removed or the asmmatcher will need to be taught
about it (someday).

llvm-svn: 118119
2010-11-02 23:40:41 +00:00
Jim Grosbach
311aa5e22f The T2 extract/pack instructions are only valid in Thumb2 mode. Mark the
patterns as such

llvm-svn: 117923
2010-11-01 15:59:52 +00:00
Chris Lattner
5d088218e5 two changes: make the asmmatcher generator ignore ARM pseudos properly,
and make it a hard error for instructions to not have an asm string.
These instructions should be marked isCodeGenOnly.

llvm-svn: 117861
2010-10-31 19:15:18 +00:00
Chris Lattner
01acd65875 reapply r117858 with apparent editor malfunction fixed (somehow I
got a dulicated line).

llvm-svn: 117860
2010-10-31 19:10:56 +00:00
Chris Lattner
8132a182e7 revert r117858 while I check out a failure I missed.
llvm-svn: 117859
2010-10-31 19:05:32 +00:00
Chris Lattner
70b05a5b88 the asm matcher can't handle operands with modifiers (like ${foo:bar}).
Instead of silently ignoring these instructions, emit a hard error and
force the target author to either refactor the target or mark the 
instruction 'isCodeGenOnly'.

Mark a few instructions in ARM and MBlaze as isCodeGenOnly the are 
doing this.

llvm-svn: 117858
2010-10-31 18:48:12 +00:00
Bob Wilson
183c466006 Overhaul memory barriers in the ARM backend. Radar 8601999.
There were a number of issues to fix up here:
* The "device" argument of the llvm.memory.barrier intrinsic should be
used to distinguish the "Full System" domain from the "Inner Shareable"
domain.  It has nothing to do with using DMB vs. DSB instructions.
* The compiler should never need to emit DSB instructions.  Remove the
ARMISD::SYNCBARRIER node and also remove the instruction patterns for DSB.
* Merge the separate DMB/DSB instructions for options only used for the
disassembler with the default DMB/DSB instructions.  Add the default
"full system" option ARM_MB::SY to the ARM_MB::MemBOpt enum.
* Add a separate ARMISD::MEMBARRIER_MCR node for subtargets that implement
a data memory barrier using the MCR instruction.
* Fix up encodings for these instructions (except MCR).
I also updated the tests and added a few new ones to check for DMB options
that were not currently being exercised.

llvm-svn: 117756
2010-10-30 00:54:37 +00:00
Jim Grosbach
9a473e23b8 Remove hard tab characters.
llvm-svn: 117742
2010-10-29 23:23:15 +00:00
Evan Cheng
bc4588c439 Re-commit 117518 and 117519 now that ARM MC test failures are out of the way.
llvm-svn: 117531
2010-10-28 06:47:08 +00:00
Evan Cheng
fdc80a0316 Revert 117518 and 117519 for now. They changed scheduling and cause MC tests to fail. Ugh.
llvm-svn: 117520
2010-10-28 02:00:25 +00:00
Evan Cheng
5c358e02ea - Assign load / store with shifter op address modes the right itinerary classes.
- For now, loads of [r, r] addressing mode is the same as the
  [r, r lsl/lsr/asr #] variants. ARMBaseInstrInfo::getOperandLatency() should
  identify the former case and reduce the output latency by 1.
- Also identify [r, r << 2] case. This special form of shifter addressing mode
  is "free".

llvm-svn: 117519
2010-10-28 01:49:06 +00:00
Jim Grosbach
1a13b873e7 imm12 operands aren't Thumb2 only, so rename the printer helper function.
llvm-svn: 117291
2010-10-25 20:00:01 +00:00
Bob Wilson
6b6b53ad6f Remove unused ARMISD::AND selection DAG node.
llvm-svn: 116566
2010-10-15 04:34:40 +00:00
Jim Grosbach
29dc23398f Tweak the ARM backend to use the RRX mnemonic instead of the 'mov a, b, rrx'
pseudonym.

llvm-svn: 116512
2010-10-14 20:43:44 +00:00
Jim Grosbach
506b966b9d A few 80 column fixes.
llvm-svn: 116451
2010-10-13 23:34:31 +00:00
Jim Grosbach
c0a61c0796 Allow use of the 16-bit literal move instruction in CMOVs for Thumb2 mode.
llvm-svn: 115890
2010-10-07 00:53:56 +00:00
Jim Grosbach
de2bd8cd3f Clean up MOVi32imm and t2MOVi32imm pseudo instruction definitions.
llvm-svn: 115853
2010-10-06 22:01:26 +00:00
Evan Cheng
6fbb6dea7c - Add TargetInstrInfo::getOperandLatency() to compute operand latencies. This
allow target to correctly compute latency for cases where static scheduling
  itineraries isn't sufficient. e.g. variable_ops instructions such as
  ARM::ldm.
  This also allows target without scheduling itineraries to compute operand
  latencies. e.g. X86 can return (approximated) latencies for high latency
  instructions such as division.
- Compute operand latencies for those defined by load multiple instructions,
  e.g. ldm and those used by store multiple instructions, e.g. stm.

llvm-svn: 115755
2010-10-06 06:27:31 +00:00
Jim Grosbach
619f1c1cc5 Nuke the rest of the :comment references
llvm-svn: 115373
2010-10-01 23:21:38 +00:00