X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=docs%2FTableGenFundamentals.html;h=f09e0d06420e5f99f44db1bec1fabb7683f5f06c;hb=a75ce9f5d2236d93c117e861e60e6f3f748c9555;hp=764f99282b107da88c5b2dc577b4763857f8d350;hpb=310adf1c6f58921b30fde145fd15cb1798050205;p=oota-llvm.git diff --git a/docs/TableGenFundamentals.html b/docs/TableGenFundamentals.html index 764f99282b1..f09e0d06420 100644 --- a/docs/TableGenFundamentals.html +++ b/docs/TableGenFundamentals.html @@ -144,7 +144,6 @@ file prints this (at the time of this writing):
bit mayLoad = 0; bit mayStore = 0; bit isImplicitDef = 0; - bit isTwoAddress = 1; bit isConvertibleToThreeAddress = 1; bit isCommutable = 1; bit isTerminator = 0; @@ -333,8 +332,9 @@ The TableGen types are:To date, these types have been sufficient for describing things that @@ -405,8 +405,6 @@ which case the user must specify it explicitly. the symbol table. If the type of 'a' does not match type, TableGen aborts with an error. !cast<string> is a special case in that the argument must be an object defined by a 'def' construct. -
Note that all of the values have rules specifying how they convert to values @@ -686,6 +685,91 @@ Here is an example TableGen fragment that shows this idea: +
+A defm can also be used inside a multiclass providing several levels of +multiclass instanciations. +
+ ++class Instruction<bits<4> opc, string Name> { + bits<4> opcode = opc; + string name = Name; +} + +multiclass basic_r<bits<4> opc> { + def rr : Instruction<opc, "rr">; + def rm : Instruction<opc, "rm">; +} + +multiclass basic_s<bits<4> opc> { + defm SS : basic_r<opc>; + defm SD : basic_r<opc>; + def X : Instruction<opc, "x">; +} + +multiclass basic_p<bits<4> opc> { + defm PS : basic_r<opc>; + defm PD : basic_r<opc>; + def Y : Instruction<opc, "y">; +} + +defm ADD : basic_s<0xf>, basic_p<0xf>; +... + +// Results +def ADDPDrm { ... +def ADDPDrr { ... +def ADDPSrm { ... +def ADDPSrr { ... +def ADDSDrm { ... +def ADDSDrr { ... +def ADDY { ... +def ADDX { ... ++
+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. +
+ ++class XD { bits<4> Prefix = 11; } +class XS { bits<4> Prefix = 12; } + +class I<bits<4> op> { + bits<4> opcode = op; +} + +multiclass R { + def rr : I<4>; + def rm : I<2>; +} + +multiclass Y { + defm SS : R, XD; + defm SD : R, XS; +} + +defm Instr : Y; + +// Results +def InstrSDrm { + bits<4> opcode = { 0, 0, 1, 0 }; + bits<4> Prefix = { 1, 1, 0, 0 }; +} +... +def InstrSSrr { + bits<4> opcode = { 0, 1, 0, 0 }; + bits<4> Prefix = { 1, 0, 1, 1 }; +} ++
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.
+ ++multiclass basic_r<bits<4> opc> { + let Predicates = [HasSSE2] in { + def rr : Instruction<opc, "rr">; + def rm : Instruction<opc, "rm">; + } + let Predicates = [HasSSE3] in + def rx : Instruction<opc, "rx">; +} + +multiclass basic_ss<bits<4> opc> { + let IsDouble = 0 in + defm SS : basic_r<opc>; + + let IsDouble = 1 in + defm SD : basic_r<opc>; +} + +defm ADD : basic_ss<0xf>; ++
Expressions used by code generator to describe instructions and isel patterns:
-