This is an archive of the discontinued LLVM Phabricator instance.

[TableGen][AsmMatcherEmitter] Allow tied operands of different classes in aliases.
ClosedPublic

Authored by sdesmalen on Jun 4 2018, 6:49 AM.

Details

Summary

Allow a tied operand of a different operand class in InstAliases,
so that the operand can be printed (and added to the MC instruction)
as the appropriate register. For example, 'GPR64as32', which would
be printed/parsed as a 32bit register and should match a tied 64bit
register operand, where the former is a sub-register of the latter.

This patch also generalizes the constraint checking to an overrideable
method in MCTargetAsmParser, so that target asmparsers can specify
whether a given operand satisfies the tied register constraint.

Diff Detail

Repository
rL LLVM

Event Timeline

Friendly ping..

fhahn added a comment.Jun 14 2018, 2:37 PM

To provide a bit more info here, this patch helps to use tied operands to handle instruction like SVE's sqinc (D47716)

sqinc x0, w0, all, mul #4
       ^___^ (must match)

Although I am not entirely sure if that is the best way, I could not think of a better approach right now and it should do the trick. It would be great to hear some additional thoughts. In any case, I think it would be great to document this behavior somewhere, otherwise it will be hard for other people to find and use.

fhahn accepted this revision.Jun 15 2018, 7:59 AM

LGTM, given that it solves the problem as a small extension of tied operand handling. Please wait with committing till next week, in case anyone else has comments or suggestions.

I suppose there is no place where to document this behavior, but could you add a brief comment to regsEqual, stating what it is used for?

utils/TableGen/AsmMatcherEmitter.cpp
2162 ↗(On Diff #149748)

If we are unsigned char here, should we change the type of TiedOperandsEnumMap's key accordingly?

2282 ↗(On Diff #149748)

Do we need the casts here? The elements in TiedOperandsEnumMap are unsigned already?

This revision is now accepted and ready to land.Jun 15 2018, 7:59 AM
sdesmalen marked 2 inline comments as done.Jun 18 2018, 6:44 AM

Thanks @fhahn I've added a comment to regsEqual describing what it can be used for.

This revision was automatically updated to reflect the committed changes.