This is an archive of the discontinued LLVM Phabricator instance.

TableGen: Add !size operation
ClosedPublic

Authored by nhaehnle on Feb 21 2018, 2:40 AM.

Details

Summary

Returns the size of a list. I have found this to be rather useful in some
development for the AMDGPU backend where we could simplify our .td files
by concatenating list<LLVMType> for complex intrinsics. Doing so requires
us to compute the position argument for LLVMMatchType.

Basically, the usage is in a pattern that looks somewhat like this:

list<LLVMType> argtypes =
    !listconcat(base,
                [llvm_any_ty, LLVMMatchType<!size(base)>]);

Change-Id: I360a0b000fd488d18bea412228230fd93722bd2c

Diff Detail

Repository
rL LLVM

Event Timeline

nhaehnle created this revision.Feb 21 2018, 2:40 AM
tra added inline comments.Feb 21 2018, 10:46 AM
docs/TableGen/LangRef.rst
101 ↗(On Diff #135214)

It would be good to add more details about !size in docs/TableGen/LangIntro.rst

test/TableGen/size.td
6–20 ↗(On Diff #135214)

I'd interleave those with the def An:... below.

nhaehnle updated this revision to Diff 135416.Feb 22 2018, 7:15 AM

Add some documentation

nhaehnle marked an inline comment as done.Feb 22 2018, 7:17 AM
nhaehnle added inline comments.
docs/TableGen/LangRef.rst
101 ↗(On Diff #135214)

Done.

test/TableGen/size.td
6–20 ↗(On Diff #135214)

I'd prefer to leave it as-is. Unlike other tools, TableGen output is not in the order of the input file but sorted alphabetically, so I find interleaving the CHECK lines misleading. I think it's easier to work with this way.

tra accepted this revision.Feb 22 2018, 9:17 AM
tra added inline comments.
test/TableGen/size.td
6–20 ↗(On Diff #135214)

OK. In this case your defs are also sorted, that's why I've suggested interleaving the checks. It's fine either way.

This revision is now accepted and ready to land.Feb 22 2018, 9:17 AM
This revision was automatically updated to reflect the committed changes.