OSDN Git Service

TableGen: Streamline the semantics of NAME
authorNicolai Haehnle <nhaehnle@gmail.com>
Mon, 4 Jun 2018 14:26:05 +0000 (14:26 +0000)
committerNicolai Haehnle <nhaehnle@gmail.com>
Mon, 4 Jun 2018 14:26:05 +0000 (14:26 +0000)
commit26db53e38e1a8942f615fb661f283f489ca0c490
tree6fbf106b81e31e96bed45e243be240fa31424ac7
parentfa47ca777719b86b8f3d02d1ddf9bcbb48e7cebb
TableGen: Streamline the semantics of NAME

Summary:
The new rules are straightforward. The main rules to keep in mind
are:

1. NAME is an implicit template argument of class and multiclass,
   and will be substituted by the name of the instantiating def/defm.

2. The name of a def/defm in a multiclass must contain a reference
   to NAME. If such a reference is not present, it is automatically
   prepended.

And for some additional subtleties, consider these:

3. defm with no name generates a unique name but has no special
   behavior otherwise.

4. def with no name generates an anonymous record, whose name is
   unique but undefined. In particular, the name won't contain a
   reference to NAME.

Keeping rules 1&2 in mind should allow a predictable behavior of
name resolution that is simple to follow.

The old "rules" were rather surprising: sometimes (but not always),
NAME would correspond to the name of the toplevel defm. They were
also plain bonkers when you pushed them to their limits, as the old
version of the TableGen test case shows.

Having NAME correspond to the name of the toplevel defm introduces
"spooky action at a distance" and breaks composability:
refactoring the upper layers of a hierarchy of nested multiclass
instantiations can cause unexpected breakage by changing the value
of NAME at a lower level of the hierarchy. The new rules don't
suffer from this problem.

Some existing .td files have to be adjusted because they ended up
depending on the details of the old implementation.

Change-Id: I694095231565b30f563e6fd0417b41ee01a12589

Reviewers: tra, simon_tatham, craig.topper, MartinO, arsenm, javed.absar

Subscribers: wdng, llvm-commits

Differential Revision: https://reviews.llvm.org/D47430

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333900 91177308-0d34-0410-b5e6-96231b3b80d8
16 files changed:
docs/TableGen/LangRef.rst
docs/TableGen/index.rst
include/llvm/TableGen/Record.h
lib/TableGen/Record.cpp
lib/TableGen/TGParser.cpp
lib/TableGen/TGParser.h
lib/Target/AArch64/AArch64InstrFormats.td
lib/Target/AMDGPU/BUFInstructions.td
lib/Target/AMDGPU/MIMGInstructions.td
lib/Target/X86/X86InstrAVX512.td
lib/Target/X86/X86InstrSSE.td
test/TableGen/Dag.td
test/TableGen/MultiClassDefName.td
test/TableGen/lisp.td
test/TableGen/name-resolution-consistency.td
test/TableGen/subst.td