[llvm-commits] [llvm] r141236 - /llvm/trunk/docs/TableGenFundamentals.html
David Greene
greened at obbligato.org
Wed Oct 5 15:42:49 PDT 2011
Author: greened
Date: Wed Oct 5 17:42:49 2011
New Revision: 141236
URL: http://llvm.org/viewvc/llvm-project?rev=141236&view=rev
Log:
Document Multidefs
Provide documentation for multidefs, explaining in detail how they
work.
Modified:
llvm/trunk/docs/TableGenFundamentals.html
Modified: llvm/trunk/docs/TableGenFundamentals.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/TableGenFundamentals.html?rev=141236&r1=141235&r2=141236&view=diff
==============================================================================
--- llvm/trunk/docs/TableGenFundamentals.html (original)
+++ llvm/trunk/docs/TableGenFundamentals.html Wed Oct 5 17:42:49 2011
@@ -769,6 +769,65 @@
</pre>
</div>
+<p>
+A special "multidef" may be used inside a multiclass to generate
+several defs given a list of values.
+</p>
+
+<div class="doc_code">
+<pre>
+<b>class</b> Base<int i> {
+ int value = i;
+}
+
+<b>multiclass</b> Multi<list<int> values> {
+ <b>def</b> ONE : Base<values[0]>;
+ <b>def</b> TWO : Base<values[1]>;
+
+ <b>multidef</b> COUNT<values, int v, 2> : Base<:v>;
+}
+
+<b>defm</b> List : Multi<[1, 2, 3, 4, 5, 6]<;
+...
+
+<i>// Results</i>
+<b>def</b> ListCOUNT {
+ int v = ?;
+ int value = v;
+ list<int> Multi::values = [1, 2, 3, 4, 5, 6];
+}
+<b>def</b> ListONE {
+ int value = 1;
+}
+<b>def</b> ListTWO {
+ int value = 2;
+}
+<b>def</b> MD2.ListCOUNT {
+ int value = 3;
+}
+<b>def</b> MD3.ListCOUNT {
+ int value = 4;
+}
+<b>def</b> MD4.ListCOUNT {
+ int value = 5;
+}
+<b>def</b> MD5.ListCOUNT {
+ int value = 6;
+}
+</pre>
+</div>
+
+<p>
+A multidef takes three "arguments" in the <> notation after the multidef
+name. The first is a list of items to process. The second is a declaration.
+This declaration creates a temporary name used as an iterator. It picks up the
+value of each processed list item as TableGen generates defs from the multidef.
+This temporary may be named and passed into the multidef body as shown in the
+example above. This provides a powerful way to generate defs with various
+values from a single multidef. The final "argument" is an integer value
+indicating where in the list to begin processing. In the above example we
+chose to begin list processing with the third item (index 2).
+</p>
</div>
</div>
More information about the llvm-commits
mailing list