[PATCH] D43651: TableGen: Reimplement !foreach using the resolving mechanism

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 16:05:45 PST 2018


nhaehnle created this revision.
nhaehnle added reviewers: arsenm, craig.topper, tra, MartinO.
Herald added subscribers: tpr, wdng.

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


Repository:
  rL LLVM

https://reviews.llvm.org/D43651

Files:
  docs/TableGen/LangIntro.rst
  include/llvm/TableGen/Record.h
  lib/TableGen/Record.cpp
  lib/TableGen/TGParser.cpp
  test/TableGen/MultiPat.td
  test/TableGen/TargetInstrSpec.td
  test/TableGen/foreach-eval.td
  test/TableGen/foreach-leak.td
  test/TableGen/foreach.td

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43651.135542.patch
Type: text/x-patch
Size: 20870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180223/f7e1da66/attachment.bin>


More information about the llvm-commits mailing list