This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] AsmMatcher: Skip optional operands in the midle of instruction if it is not present
ClosedPublic

Authored by SamWot on Feb 24 2016, 5:41 AM.

Details

Summary

Previosy, if actual instruction have one of optional operands then other optional operands listed before this also should be presented.
For example instruction v_fract_f32 v0, v1, mul:2 have one optional operand - OMod and do not have optional operand clamp. Previously this was not allowed because clamp is listed before omod in AsmString:

string AsmString = "v_fract_f32$vdst, $src0_modifiers$clamp$omod";

Making this work required some hacks (both OMod and Clamp match classes have same PredicateMethod).

Now, if MatchInstructionImpl meets formal optional operand that is not presented in actual instruction it skips this formal operand and tries to match current actual operand with next formal.

Diff Detail

Event Timeline

SamWot updated this revision to Diff 48915.Feb 24 2016, 5:41 AM
SamWot retitled this revision from to [TableGen] AsmMatcher: Skip optional operands in the midle of instruction if it is not present.
SamWot updated this object.
SamWot added reviewers: tstellarAMD, ab, olista01.
SamWot added subscribers: arsenm, nhaustov, llvm-commits.
ab accepted this revision.Feb 26 2016, 1:08 PM
ab edited edge metadata.

LGTM, but please wait for D17644.

utils/TableGen/AsmMatcherEmitter.cpp
3137–3139

An extra comment here would help, I think.

This revision is now accepted and ready to land.Feb 26 2016, 1:08 PM
SamWot updated this revision to Diff 49348.Feb 29 2016, 2:03 AM
SamWot edited edge metadata.

Added comment

nhaustov closed this revision.Mar 1 2016, 4:41 AM

r262314