X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FTableGenFundamentals.html;h=5be11624ced305d1c411fd5ad5cfe106a9b17f0d;hb=b2b31a6f93f5329c86e41c04ec8c33799d012f9e;hp=aaa5551196611732246004b676517ba26ab7f388;hpb=0602df7403182526995419e6384e89d87329605a;p=oota-llvm.git diff --git a/docs/TableGenFundamentals.html b/docs/TableGenFundamentals.html index aaa55511966..5be11624ced 100644 --- a/docs/TableGenFundamentals.html +++ b/docs/TableGenFundamentals.html @@ -104,8 +104,10 @@ definition, so the backend can find all definitions of a particular class, such as "Instruction".

TableGen multiclasses are groups of abstract records that are -instantiated all at once. Each instantiation can result in multiple TableGen -definitions.

+instantiated all at once. Each instantiation can result in multiple +TableGen definitions. If a multiclass inherits from another multiclass, +the definitions in the sub-multiclass become part of the current +multiclass, as if they were declared in the current multiclass.

@@ -138,7 +140,7 @@ file prints this (at the time of this writing):

bit isIndirectBranch = 0; bit isBarrier = 0; bit isCall = 0; - bit isSimpleLoad = 0; + bit canFoldAsLoad = 0; bit mayLoad = 0; bit mayStore = 0; bit isImplicitDef = 0; @@ -149,11 +151,10 @@ file prints this (at the time of this writing):

bit isReMaterializable = 0; bit isPredicable = 0; bit hasDelaySlot = 0; - bit usesCustomDAGSchedInserter = 0; + bit usesCustomInserter = 0; bit hasCtrlDep = 0; bit isNotDuplicable = 0; bit hasSideEffects = 0; - bit mayHaveSideEffects = 0; bit neverHasSideEffects = 0; InstrItinClass Itinerary = NoItinerary; string Constraints = ""; @@ -187,7 +188,7 @@ backend, and is only shown as an example.

As you can see, a lot of information is needed for every instruction supported by the code generator, and specifying it all manually would be -unmaintainble, prone to bugs, and tiring to do in the first place. Because we +unmaintainable, prone to bugs, and tiring to do in the first place. Because we are using TableGen, all of the information was derived from the following definition:

@@ -332,8 +333,9 @@ The TableGen types are:

This type represents a nestable directed graph of elements.
code
-
This represents a big hunk of text. NOTE: I don't remember why this is - distinct from string!
+
This represents a big hunk of text. This is lexically distinct from + string values because it doesn't require escapeing double quotes and other + common characters that occur in code.

To date, these types have been sufficient for describing things that @@ -369,8 +371,11 @@ supported include:

string value
[{ ... }]
code fragment
-
[ X, Y, Z ]
-
list value.
+
[ X, Y, Z ]<type>
+
list value. <type> is the type of the list +element and is usually optional. In rare cases, +TableGen is unable to deduce the element type in +which case the user must specify it explicitly.
{ a, b, c }
initializer for a "bits<3>" value
value
@@ -396,6 +401,32 @@ supported include:

!strconcat(a, b)
A string value that is the result of concatenating the 'a' and 'b' strings.
+
!cast<type>(a)
+
A symbol of type type obtained by looking up the string 'a' in +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.
+
!nameconcat<type>(a, b)
+
Shorthand for !cast<type>(!strconcat(a, b))
+
!subst(a, b, c)
+
If 'a' and 'b' are of string type or are symbol references, substitute +'b' for 'a' in 'c.' This operation is analogous to $(subst) in GNU make.
+
!foreach(a, b, c)
+
For each member 'b' of dag or list 'a' apply operator 'c.' 'b' is a +dummy variable that should be declared as a member variable of an instantiated +class. This operation is analogous to $(foreach) in GNU make.
+
!car(a)
+
The first element of list 'a.'
+
!cdr(a)
+
The 2nd-N elements of list 'a.'
+
!null(a)
+
An integer {0,1} indicating whether list 'a' is empty.
+
!if(a,b,c)
+
'b' if the result of integer operator 'a' is nonzero, 'c' otherwise.
+
!eq(a,b)
+
Integer one if string a is equal to string b, zero otherwise. This + only operates on string objects. Use !cast to compare other + types of objects.

Note that all of the values have rules specifying how they convert to values @@ -625,8 +656,10 @@ Here is an example TableGen fragment that shows this idea:

The name of the resultant definitions has the multidef fragment names appended to them, so this defines ADD_rr, ADD_ri, - SUB_rr, etc. Using a multiclass this way is exactly equivalent to - instantiating the classes multiple times yourself, e.g. by writing:

+ SUB_rr, etc. A defm may inherit from multiple multiclasses, + instantiating definitions from each multiclass. Using a multiclass + this way is exactly equivalent to instantiating the classes multiple + times yourself, e.g. by writing:

@@ -694,7 +727,7 @@ File-scope let expressions are really just another way that TableGen allows the
 end-user to factor out commonality from the records.

File-scope "let" expressions take a comma-separated list of bindings to -apply, and one of more records to bind the values in. Here are some +apply, and one or more records to bind the values in. Here are some examples:

@@ -707,12 +740,12 @@ examples:

let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS] in { - def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops), - "call\t${dst:call}", []>; - def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops), - "call\t{*}$dst", [(X86call GR32:$dst)]>; - def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops), - "call\t{*}$dst", []>; + def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops), + "call\t${dst:call}", []>; + def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops), + "call\t{*}$dst", [(X86call GR32:$dst)]>; + def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops), + "call\t{*}$dst", []>; }
@@ -723,6 +756,22 @@ opened, as in the case with the CALL* instructions above.

+ +
Code Generator backend info
+ + +

Expressions used by code generator to describe instructions and isel +patterns:

+ +
+ +
(implicit a)
+
an implicitly defined physical register. This tells the dag instruction + selection emitter the input pattern's extra definitions matches implicit + physical register definitions.
+ +
+
TableGen backends
@@ -740,9 +789,9 @@ This should highlight the APIs in TableGen/Record.h.


Valid CSS! + src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"> Valid HTML 4.01! + src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"> Chris Lattner
LLVM Compiler Infrastructure