This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel/TableGen: Fix handling of EXTRACT_SUBREG constraints
ClosedPublic

Authored by arsenm on Sep 3 2019, 8:56 AM.

Details

Summary

This was only using the correct register constraints if this was the
final result instruction. If the extract was a sub instruction of the
result, it would attempt to use GIR_ConstrainSelectedInstOperands on a
COPY, which won't work. Move the handling to
createAndImportSubInstructionRenderer so it works correctly.

I don't fully understand why runOnPattern and
createAndImportSubInstructionRenderer both need to handle these
special cases, and constrain them with slightly different methods. If
I remove the runOnPattern handling, it does break the constraint when
the final result instruction is EXTRACT_SUBREG.

Diff Detail

Event Timeline

arsenm created this revision.Sep 3 2019, 8:56 AM
paquette added inline comments.Sep 3 2019, 9:15 AM
utils/TableGen/GlobalISelEmitter.cpp
4111

I think the REG_SEQUENCE part should be a separate patch, along with the SubRegIndexRenderer (since it's only used here)

arsenm updated this revision to Diff 218467.Sep 3 2019, 9:26 AM

Attach right patch

paquette added inline comments.Sep 3 2019, 9:49 AM
utils/TableGen/GlobalISelEmitter.cpp
4001–4002

Shouldn't getMatchingSubClassWithSubRegs always return a class which contains the subregisters?

If SuperClass doesn't have an appropriate subclass, then getMatchingSubClassWithSubRegs should return None, no?

paquette accepted this revision.Sep 5 2019, 4:36 PM

LGTM in any case; I think it would be good to find out why the register class can come out wrong though.

This revision is now accepted and ready to land.Sep 5 2019, 4:36 PM
arsenm marked an inline comment as done.Sep 5 2019, 4:51 PM
arsenm added inline comments.
utils/TableGen/GlobalISelEmitter.cpp
4001–4002

This comment was just copied from the other handling (still not sure why the sub-pattern case needs to be handled differently). I can just drop it. I'm not sure what it's worried about.

arsenm closed this revision.Sep 5 2019, 5:04 PM

r371150