[PATCH] D47530: TableGen: some LangRef doc fixes
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 4 07:30:35 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333901: TableGen: some LangRef doc fixes (authored by nha, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D47530
Files:
llvm/trunk/docs/TableGen/LangIntro.rst
llvm/trunk/docs/TableGen/LangRef.rst
Index: llvm/trunk/docs/TableGen/LangRef.rst
===================================================================
--- llvm/trunk/docs/TableGen/LangRef.rst
+++ llvm/trunk/docs/TableGen/LangRef.rst
@@ -229,25 +229,34 @@
int Baz = Bar;
}
+ Values defined in superclasses can be accessed the same way.
+
* a template arg of a ``class``, such as the use of ``Bar`` in::
class Foo<int Bar> {
int Baz = Bar;
}
-* value local to a ``multiclass``, such as the use of ``Bar`` in::
+* value local to a ``class``, such as the use of ``Bar`` in::
- multiclass Foo {
+ class Foo {
int Bar = 5;
int Baz = Bar;
}
* a template arg to a ``multiclass``, such as the use of ``Bar`` in::
multiclass Foo<int Bar> {
- int Baz = Bar;
+ def : SomeClass<Bar>;
}
+* the iteration variable of a ``foreach``, such as the use of ``i`` in::
+
+ foreach i = 0-5 in
+ def Foo#i;
+
+* a variable defined by ``defset``
+
* the implicit template argument ``NAME`` in a ``class`` or ``multiclass``
.. productionlist::
Index: llvm/trunk/docs/TableGen/LangIntro.rst
===================================================================
--- llvm/trunk/docs/TableGen/LangIntro.rst
+++ llvm/trunk/docs/TableGen/LangIntro.rst
@@ -152,8 +152,8 @@
``foreach <var> = [ <list> ] in <def>``
Replicate <body> or <def>, replacing instances of <var> with each value
in <list>. <var> is scoped at the level of the ``foreach`` loop and must
- not conflict with any other object introduced in <body> or <def>. Currently
- only ``def``\s are expanded within <body>.
+ not conflict with any other object introduced in <body> or <def>. Only
+ ``def``\s and ``defm``\s are expanded within <body>.
``foreach <var> = 0-15 in ...``
@@ -348,6 +348,23 @@
despite the fact that it derives (indirectly) from the ``C`` class, because the
``D`` class overrode its value.
+References between variables in a record are substituted late, which gives
+``let`` expressions unusual power. Consider this admittedly silly example:
+
+.. code-block:: text
+
+ class A<int x> {
+ int Y = x;
+ int Yplus1 = !add(Y, 1);
+ int xplus1 = !add(x, 1);
+ }
+ def Z : A<5> {
+ let Y = 10;
+ }
+
+The value of ``Z.xplus1`` will be 6, but the value of ``Z.Yplus1`` is 11. Use
+this power wisely.
+
.. _template arguments:
Class template arguments
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47530.149762.patch
Type: text/x-patch
Size: 2427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180604/bc0fd744/attachment.bin>
More information about the llvm-commits
mailing list