This is an archive of the discontinued LLVM Phabricator instance.

TableGen: Reimplement !foreach using the resolving mechanism
ClosedPublic

Authored by nhaehnle on Feb 22 2018, 4:05 PM.

Details

Summary

This changes the syntax of !foreach so that the first "parameter" is
a new syntactic variable: !foreach(x, lst, expr) will define the
variable x within the scope of expr, and evaluation of the !foreach
will substitute elements of the given list (or dag) for x in expr.

Aside from leading to a nicer syntax, this allows more complex
expressions where x is deeply nested, or even constant expressions
in which x does not occur at all.

!foreach is currently not actually used anywhere in trunk, but I
plan to use it in the AMDGPU backend. If out-of-tree targets are
using it, they can adjust to the new syntax very easily.

Change-Id: Ib966694d8ab6542279d6bc358b6f4d767945a805

Diff Detail

Repository
rL LLVM

Event Timeline

nhaehnle created this revision.Feb 22 2018, 4:05 PM
tra accepted this revision.Feb 23 2018, 2:55 PM

Hooray! Now we'll have proper temp variables in !foreach !

test/TableGen/foreach-leak.td
11 ↗(On Diff #135542)

"a" should be quoted, otherwise it looks like an indefinite article.

This revision is now accepted and ready to land.Feb 23 2018, 2:55 PM
nhaehnle marked an inline comment as done.Feb 25 2018, 7:57 AM
nhaehnle added inline comments.
test/TableGen/foreach-leak.td
11 ↗(On Diff #135542)

Done locally, will commit later.

nhaehnle updated this revision to Diff 135829.Feb 25 2018, 8:23 AM
nhaehnle marked an inline comment as done.

Put 'a' in quotation marks in the test case comment.

This revision was automatically updated to reflect the committed changes.