diff options
Diffstat (limited to 'docs/TableGenFundamentals.html')
-rw-r--r-- | docs/TableGenFundamentals.html | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/docs/TableGenFundamentals.html b/docs/TableGenFundamentals.html index 6db1827..45baf19 100644 --- a/docs/TableGenFundamentals.html +++ b/docs/TableGenFundamentals.html @@ -37,6 +37,7 @@ <ol> <li><a href="#include">File inclusion</a></li> <li><a href="#globallet">'let' expressions</a></li> + <li><a href="#foreach">'foreach' blocks</a></li> </ol></li> </ol></li> <li><a href="#backends">TableGen backends</a> @@ -401,6 +402,14 @@ which case the user must specify it explicitly.</dd> <dt><tt>list[4-7,17,2-3]</tt></dt> <dd>A slice of the 'list' list, including elements 4,5,6,7,17,2, and 3 from it. Elements may be included multiple times.</dd> +<dt><tt>foreach <var> = <list> in { <body> }</tt></dt> +<dt><tt>foreach <var> = <list> in <def></tt></dt> + <dd> Replicate <body> or <def>, replacing instances of + <var> with each value in <list>. <var> is scoped at the + level of the <tt>foreach</tt> loop and must not conflict with any other object + introduced in <body> or <def>. Currently only <tt>def</tt>s are + expanded within <body>. + </dd> <dt><tt>(DEF a, b)</tt></dt> <dd>a dag value. The first element is required to be a record definition, the remaining elements in the list may be arbitrary other values, including nested @@ -880,6 +889,39 @@ several levels of multiclass instanciations. This also avoids the need of using </pre> </div> +<!-- --------------------------------------------------------------------------> +<h4> + <a name="foreach">Looping</a> +</h4> + +<div> +<p>TableGen supports the '<tt>foreach</tt>' block, which textually replicates +the loop body, substituting iterator values for iterator references in the +body. Example:</p> + +<div class="doc_code"> +<pre> +<b>foreach</b> i = [0, 1, 2, 3] in { + <b>def</b> R#i : Register<...>; + <b>def</b> F#i : Register<...>; +} +</pre> +</div> + +<p>This will create objects <tt>R0</tt>, <tt>R1</tt>, <tt>R2</tt> and +<tt>R3</tt>. <tt>foreach</tt> blocks may be nested. If there is only +one item in the body the braces may be elided:</p> + +<div class="doc_code"> +<pre> +<b>foreach</b> i = [0, 1, 2, 3] in + <b>def</b> R#i : Register<...>; + +</pre> +</div> + +</div> + </div> </div> |