This is an archive of the discontinued LLVM Phabricator instance.

TableGen: Add address space to matchers
ClosedPublic

Authored by arsenm on Jul 8 2019, 7:29 AM.

Details

Reviewers
dsanders
Summary

Currently AMDGPU uses a CodePatPred to check address spaces from the
MachineMemOperand. Introduce a new first class property so that the
existing patterns can be easily modified to uses the new generated
predicate, which will also be handled for GlobalISel.

I would prefer these to match against the pointer type of the
instruction, but that would be difficult to get working with
SelectionDAG compatbility. This is much easier for now and will avoid
a painful tablegen rewrite for all the loads and stores.

I'm also not sure if there's a better way to encode multiple address
spaces in the table, rather than putting the number to expect.

Diff Detail

Event Timeline

arsenm created this revision.Jul 8 2019, 7:29 AM
dsanders accepted this revision.Jul 12 2019, 4:55 PM

LGTM

I'm also not sure if there's a better way to encode multiple address spaces in the table, rather than putting the number to expect.

It amounts to the same thing but they could be LLT's like the ones defined in llvm/Target/GlobalISel/Target.td. If each target defines it's own pX's then it does at least constrain it to the expected address spaces.

test/TableGen/address-space-patfrags.td
20

Regarding the FIXME. The importer currently operates after PatFrag expansion which is too late to infer it. I expect the code that does the expansion could infer it but I haven't dug into that.

utils/TableGen/GlobalISelEmitter.cpp
245–248

Other places in this file achieve this with:

StringRef Separator = "";
for (...) {
  OS << Separator << ...;
  Separator = ", ";
}

I think it ends up a bit neater but I don't mind either way

This revision is now accepted and ready to land.Jul 12 2019, 4:55 PM
arsenm closed this revision.Jul 15 2019, 1:59 PM
arsenm marked an inline comment as done.

r366128