Page MenuHomePhabricator

[TableGen] Allow DAG isel patterns to override default operands.

Authored by simon_tatham on Jun 26 2019, 5:22 AM.



When a Tablegen instruction description uses OperandWithDefaultOps,
isel patterns for that instruction don't have to fill in the default
value for the operand in question. But the flip side is that they
actually can't override the defaults even if they want to.

This will be very inconvenient for the Arm backend, when we start
wanting to write isel patterns that generate the many MVE predicated
vector instructions, in the form with predication actually enabled. So
this small Tablegen fix makes it possible to write an isel pattern
either with or without values for a defaulted operand, and have the
default values filled in only if they are not overridden.

If all the defaulted operands come at the end of the instruction's
operand list, there's a natural way to match them up to the arguments
supplied in the pattern: consume pattern arguments until you run out,
then fill in any missing instruction operands with their default
values. But if defaulted and non-defaulted operands are interleaved,
it's less clear what to do. This does happen in existing targets (the
first example I came across was KILLGT, in the AMDGPU/R600 backend),
and of course they expect the previous behaviour (that the default for
those operands is used and a pattern argument is not consumed), so for
backwards compatibility I've stuck with that.

Diff Detail


Event Timeline

simon_tatham created this revision.Jun 26 2019, 5:22 AM

Changed my mind about the opt-in system: instead of using a subclass of OperandWithDefaultOps, I've switched to using a flag field inside the existing class.

That should make it easier for a back end to define some flags one way and some another. And if people ever want to switch the default over to permitting overrides, and have a small number of back ends unset the same flag, it will be easier this way.

simon_tatham edited the summary of this revision. (Show Details)Jun 27 2019, 6:23 AM

Would it be possible to make default operands overridable automatically iff they are at the end of the operand list? I.e., if you have a suffix of default operands, then those can be overridden?

simon_tatham edited the summary of this revision. (Show Details)

Apparently it would: trying it that way, it does look simpler, and as far as I can tell it doesn't change the output of any currently checked-in Tablegen input.

simon_tatham edited the summary of this revision. (Show Details)Jul 1 2019, 7:44 AM
hfinkel accepted this revision.Jul 3 2019, 7:20 PM


This revision is now accepted and ready to land.Jul 3 2019, 7:20 PM
This revision was automatically updated to reflect the committed changes.