This is an archive of the discontinued LLVM Phabricator instance.

[MC][ARM] add .w suffixes for BL (T1) and DBG
ClosedPublic

Authored by nickdesaulniers on Feb 22 2021, 3:25 PM.

Details

Summary

F1.2 Standard assembler syntax fields
describes .w and .n suffixes for wide and narrow encodings.

arch/arm/probes/kprobes/test-thumb.c tests installing kprobes for
certain instructions using inline asm. There's a few instructions we
fail to assemble due to missing .w t2InstAliases.

Adds .w suffixes for:

  • bl (F5.1.25 BL, BLX (immediate) T1)
  • dbg (F5.1.42 DBG T1)

Diff Detail

Event Timeline

nickdesaulniers requested review of this revision.Feb 22 2021, 3:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 22 2021, 3:25 PM

I couldn't find an official rule for allowing ".w" when the instructions only have 32 bit encodings. However GAS does it and we also allow others such as AND (immediate) (see test/MC/ARM/basic-thumb2-instructions.s) so I think it's fine.

llvm/test/MC/ARM/basic-thumb2-instructions.s
657

Also add a predicated one here.

llvm/test/MC/ARM/thumb2-branches.s
104

You could just use an immediate here and not need to check the relocation emitted.

Also I'd add one with a predicate just to check the alias allows that.

I thought that maybe we should use ".w" in the disassembly, however all bl and dbg are 32 bit encodings so there's no ambiguity here. This matches GAS's behavior too.

DavidSpickett added inline comments.Feb 23 2021, 3:10 AM
llvm/test/MC/ARM/basic-thumb2-instructions.s
657

s/predicated/conditional

llvm/test/MC/ARM/thumb2-branches.s
104

s/predicated/conditional

nickdesaulniers marked 2 inline comments as done.
  • add predicated test cases, use immediate operand in test
nickdesaulniers marked 2 inline comments as done.Feb 23 2021, 10:30 AM

I couldn't find an official rule for allowing ".w" when the instructions only have 32 bit encodings.

My interpretation of "F1.2 Standard assembler syntax fields":

.W Meaning wide, specifies that the assembler must select a 32-bit encoding for the
instruction. If this is not possible, an assembler error is produced.

(and says the same for .N/16b, so an error diagnostic should be produced whenever there is not a corresponding encoding for that suffix).

See also this thread starting from: https://github.com/ClangBuiltLinux/linux/issues/1296#issuecomment-778598573.

LGTM with nits fixed.

llvm/test/MC/ARM/basic-thumb2-instructions.s
659

nit: indent the @ encoding

llvm/test/MC/ARM/thumb2-branches.s
105

nit: indent the @ encoding

DavidSpickett accepted this revision.Feb 24 2021, 3:11 AM
This revision is now accepted and ready to land.Feb 24 2021, 3:11 AM
llvm/test/MC/ARM/basic-thumb2-instructions.s
659

I think phab is expanding tabs to a different number of spaces then 8. With tabstop=8, the indentation is consistent throughout the file.

llvm/test/MC/ARM/basic-thumb2-instructions.s
659

Yeah, if you click "show 20 lines" in phab, you can see what looks like existing cases of curious indentation. It's just phab expanding tabs to a different number of spaces.

This revision was automatically updated to reflect the committed changes.