This is an archive of the discontinued LLVM Phabricator instance.

[TableGen][CodeEmitterGen] Allow local names for sub-operands in a operand list.
ClosedPublic

Authored by jyknight on Aug 2 2022, 11:16 AM.

Details

Summary

These names can then be matched by name against 'bits' fields in a
record, to populate an instruction's encoding.

This does _not_ yet change DecoderEmitter to allow by-name matching of
sub-operands. Unlike the encoder, the decoder already defaulted to not
supporting positional matching, and backends had workarounds in place
for the missing decoding support.

Additionally, use this new capability to allow the ARM and AArch64
backends not to require any positional operand matching.

Diff Detail

Event Timeline

jyknight created this revision.Aug 2 2022, 11:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2022, 11:16 AM
jyknight requested review of this revision.Aug 2 2022, 11:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2022, 11:17 AM

Huh, that's an interesting hack. I'd say your change makes it less hacky, but yeah, it's all rather questionable.

How about an approach where the users of these complex patterns look something like:

def : Pat<(sub GPR32:$Rn, (arith_shifted_reg32 GPR32:$src2, imm:$shift)),
          (SUBSWrs GPR32:$Rn, $src2, $shift)>;

Having the two operands to the arith_shifted_reg32 would fall out implicitly from using the ComplexPattern tablegen class.

This seems like a potentially clean way to go in terms of the TableGen DSL. I have no idea how feasible that would be to implement, though...

jyknight updated this revision to Diff 458038.Sep 5 2022, 10:14 AM

Switch to allowing the user to assign names to suboperands in the
instruction's operand list.

jyknight retitled this revision from [TableGen][CodeEmitterGen] Add the capability to match sub-operands by name. to [TableGen][CodeEmitterGen] Allow local names for sub-operands in a operand list..Sep 16 2022, 1:04 PM
jyknight edited the summary of this revision. (Show Details)
jyknight added reviewers: MaskRay, nhaehnle.
MaskRay accepted this revision.Sep 21 2022, 10:47 AM
This revision is now accepted and ready to land.Sep 21 2022, 10:47 AM