This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Support fixup for Thumb2 modified immediate
ClosedPublic

Authored by peter.smith on May 24 2017, 5:57 AM.

Details

Summary

This change adds a new fixup fixup_t2_so_imm for the t2_so_imm_asmoperand "T2SOImm". The fixup permits code such as:

.L1:
     sub r3, r3, #.L2 - .L1
.L2:

to assemble in Thumb2 as well as in ARM state. There isn't any relocation directive matching the fixup so the expression must be resolved to a constant at assembly time.

The operand predicate isT2SOImm() explicitly doesn't match expressions containing :upper16: and :lower16: as expressions with these operators must match the movt and movw instructions.

The test mov r0, foo2 in thumb2-diagnostics is moved to a new file as the fixup delays the error message till after the assembler has quit due to the other errors. As the mov instruction shares the t2_so_imm_asmoperand mov instructions with a non constant expression now match t2MOVi rather than t2MOVi16 so the error message is slightly different.

Fixes PR28647

Diff Detail

Event Timeline

peter.smith created this revision.May 24 2017, 5:57 AM
olista01 added inline comments.Jun 2 2017, 3:51 AM
test/MC/ARM/t2-modified-immediate-fixup.s
21

These register numbers don't match the input, has something overwritten the wrong part of the instructions?

Thanks for the spot, at a glance it looks like I've got the mask for the lowest immediate too large, I think it should be 0xff and not 0xfff. I'll check this afternoon and update.

Updated diff to correct immediate mask to 0xff which maps to imm8 in the ARM ARM, previously I had used 0xfff which caused the destination register to get corrupted when the high bits of the immediate were set.

Tests now have correct register numbers. Apologies for my previous blindness, I concentrated on the numbers and missed that the registers had been corrupted.

olista01 accepted this revision.Jun 2 2017, 5:40 AM

LGTM

This revision is now accepted and ready to land.Jun 2 2017, 5:40 AM
This revision was automatically updated to reflect the committed changes.