This is an archive of the discontinued LLVM Phabricator instance.

MC: Split the x86 asm matcher implementations by dialect
ClosedPublic

Authored by rnk on Jul 31 2014, 3:11 PM.

Details

Summary

The existing matcher has lots of AT&T assembly dialect assumptions baked
into it. In particular, the hack for resolving the size of a memory
operand by appending the four most common suffixes doesn't work at all.
The Intel assembly dialect mnemonic table has ambiguous entries, so we
need to try matching multiple times with different operand sizes, since
that's the only way to choose different instruction variants.

This makes us more compatible with gas's implementation of Intel
assembly syntax. MSVC assumes you want byte-sized operations for the
instructions that we reject as ambiguous.

Diff Detail

Repository
rL LLVM

Event Timeline

rnk updated this revision to Diff 12087.Jul 31 2014, 3:11 PM
rnk retitled this revision from to MC: Split the x86 asm matcher implementations by dialect.
rnk updated this object.
rnk added a reviewer: grosbach.
rnk added a subscriber: Unknown Object (MLST).

+ddunbar, since I think he wrote the AT&T suffix disambiguation code.

Ping for the new week. :)

ddunbar edited edge metadata.Aug 7 2014, 5:21 PM

Hi Reid,

I haven't really examined the Intel matching logic, but this patch looks
like a nice improvement to me.

I think WasOriginallyInvalidOperand is unused in your Intel matching
implementation?

  • Daniel
grosbach edited edge metadata.Aug 8 2014, 1:31 PM

I believe Daniel's right that WasOriginallyInvalidOperand is unused and can be nuked in MatchAndEmitIntelInstruction().

Do we already have testcases for the various other forms? I'm specifically thinking of the retry loop "for (unsigned Size : MopSizes) {".

test/MC/X86/intel-syntax-ambiguous.s
11 ↗(On Diff #12087)

We should check the encoding of these instructions, not just that we can parse them without error.

rnk added a comment.Aug 11 2014, 5:55 PM
In D4747#8, @grosbach wrote:

I believe Daniel's right that WasOriginallyInvalidOperand is unused and can be nuked in MatchAndEmitIntelInstruction().

Gone.

Do we already have testcases for the various other forms? I'm specifically thinking of the retry loop "for (unsigned Size : MopSizes) {".

It looks like I don't actually need the SSE sizes of 128, 256, and 512. I can't find a single SSE instruction that lacks register operands, or doesn't encode the size into the mnemonic.

test/MC/X86/intel-syntax-ambiguous.s
11 ↗(On Diff #12087)

I can't check encoding in the same test file. Do you want a full encoding test, or is a simple gas-dump style test like intel-syntax.s good enough?

rnk updated this revision to Diff 12378.Aug 11 2014, 6:04 PM
rnk edited edge metadata.
  • Add more tests and kill dead code.
rnk closed this revision.Aug 26 2014, 1:42 PM
rnk updated this revision to Diff 12965.

Closed by commit rL216481 (authored by @rnk).