diff options
Diffstat (limited to 'docs/TableGenFundamentals.html')
-rw-r--r-- | docs/TableGenFundamentals.html | 121 |
1 files changed, 116 insertions, 5 deletions
diff --git a/docs/TableGenFundamentals.html b/docs/TableGenFundamentals.html index 4ad6191..0bdb6dd 100644 --- a/docs/TableGenFundamentals.html +++ b/docs/TableGenFundamentals.html @@ -144,7 +144,6 @@ file prints this (at the time of this writing):</p> <b>bit</b> mayLoad = 0; <b>bit</b> mayStore = 0; <b>bit</b> isImplicitDef = 0; - <b>bit</b> isTwoAddress = 1; <b>bit</b> isConvertibleToThreeAddress = 1; <b>bit</b> isCommutable = 1; <b>bit</b> isTerminator = 0; @@ -422,11 +421,12 @@ class. This operation is analogous to $(foreach) in GNU make.</dd> <dt><tt>!null(a)</tt></dt> <dd>An integer {0,1} indicating whether list 'a' is empty.</dd> <dt><tt>!if(a,b,c)</tt></dt> - <dd>'b' if the result of integer operator 'a' is nonzero, 'c' otherwise.</dd> + <dd>'b' if the result of 'int' or 'bit' operator 'a' is nonzero, + 'c' otherwise.</dd> <dt><tt>!eq(a,b)</tt></dt> <dd>Integer one if string a is equal to string b, zero otherwise. This - only operates on string objects. Use !cast<string> to compare other - types of objects.</dd> + only operates on string, int and bit objects. Use !cast<string> to + compare other types of objects.</dd> </dl> <p>Note that all of the values have rules specifying how they convert to values @@ -687,6 +687,91 @@ Here is an example TableGen fragment that shows this idea: </pre> </div> +<p> +A defm can also be used inside a multiclass providing several levels of +multiclass instanciations. +</p> + +<div class="doc_code"> +<pre> +<b>class</b> Instruction<bits<4> opc, string Name> { + bits<4> opcode = opc; + string name = Name; +} + +<b>multiclass</b> basic_r<bits<4> opc> { + <b>def</b> rr : Instruction<opc, "rr">; + <b>def</b> rm : Instruction<opc, "rm">; +} + +<b>multiclass</b> basic_s<bits<4> opc> { + <b>defm</b> SS : basic_r<opc>; + <b>defm</b> SD : basic_r<opc>; + <b>def</b> X : Instruction<opc, "x">; +} + +<b>multiclass</b> basic_p<bits<4> opc> { + <b>defm</b> PS : basic_r<opc>; + <b>defm</b> PD : basic_r<opc>; + <b>def</b> Y : Instruction<opc, "y">; +} + +<b>defm</b> ADD : basic_s<0xf>, basic_p<0xf>; +... + +<i>// Results</i> +<b>def</b> ADDPDrm { ... +<b>def</b> ADDPDrr { ... +<b>def</b> ADDPSrm { ... +<b>def</b> ADDPSrr { ... +<b>def</b> ADDSDrm { ... +<b>def</b> ADDSDrr { ... +<b>def</b> ADDY { ... +<b>def</b> ADDX { ... +</pre> +</div> + +<p> +defm declarations can inherit from classes too, the +rule to follow is that the class list must start after the +last multiclass, and there must be at least one multiclass +before them. +</p> + +<div class="doc_code"> +<pre> +<b>class</b> XD { bits<4> Prefix = 11; } +<b>class</b> XS { bits<4> Prefix = 12; } + +<b>class</b> I<bits<4> op> { + bits<4> opcode = op; +} + +<b>multiclass</b> R { + <b>def</b> rr : I<4>; + <b>def</b> rm : I<2>; +} + +<b>multiclass</b> Y { + <b>defm</b> SS : R, XD; + <b>defm</b> SD : R, XS; +} + +<b>defm</b> Instr : Y; + +<i>// Results</i> +<b>def</b> InstrSDrm { + bits<4> opcode = { 0, 0, 1, 0 }; + bits<4> Prefix = { 1, 1, 0, 0 }; +} +... +<b>def</b> InstrSSrr { + bits<4> opcode = { 0, 1, 0, 0 }; + bits<4> Prefix = { 1, 0, 1, 1 }; +} +</pre> +</div> + </div> <!-- ======================================================================= --> @@ -754,6 +839,32 @@ examples:</p> need to be added to several records, and the records do not otherwise need to be opened, as in the case with the <tt>CALL*</tt> instructions above.</p> +<p>It's also possible to use "let" expressions inside multiclasses, providing +more ways to factor out commonality from the records, specially if using +several levels of multiclass instanciations. This also avoids the need of using +"let" expressions within subsequent records inside a multiclass.</p> + +<div class="doc_code"> +<pre> +<b>multiclass </b>basic_r<bits<4> opc> { + <b>let </b>Predicates = [HasSSE2] in { + <b>def </b>rr : Instruction<opc, "rr">; + <b>def </b>rm : Instruction<opc, "rm">; + } + <b>let </b>Predicates = [HasSSE3] in + <b>def </b>rx : Instruction<opc, "rx">; +} + +<b>multiclass </b>basic_ss<bits<4> opc> { + <b>let </b>IsDouble = 0 in + <b>defm </b>SS : basic_r<opc>; + + <b>let </b>IsDouble = 1 in + <b>defm </b>SD : basic_r<opc>; +} + +<b>defm </b>ADD : basic_ss<0xf>; +</pre> </div> <!-- *********************************************************************** --> @@ -795,7 +906,7 @@ This should highlight the APIs in <tt>TableGen/Record.h</tt>.</p> <a href="mailto:sabre@nondot.org">Chris Lattner</a><br> <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br> - Last modified: $Date: 2010-05-07 02:28:04 +0200 (Fri, 07 May 2010) $ + Last modified: $Date: 2010-06-21 22:35:09 +0200 (Mon, 21 Jun 2010) $ </address> </body> |