X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FTableGenFundamentals.html;h=6db1827b3be6cae930a50940b9aa4f6a90691f02;hb=c352caf168094c83f05a8010ca14c2e643dbf618;hp=90ac804db767055765bff4a8d56c8e63fbd2682b;hpb=b9a33634cc9b65465934c4ae13122c8b772b2c29;p=oota-llvm.git diff --git a/docs/TableGenFundamentals.html b/docs/TableGenFundamentals.html index 90ac804db76..6db1827b3be 100644 --- a/docs/TableGenFundamentals.html +++ b/docs/TableGenFundamentals.html @@ -2,14 +2,15 @@ "http://www.w3.org/TR/html4/strict.dtd"> + TableGen Fundamentals -
TableGen Fundamentals
+

TableGen Fundamentals

-
+
-
Introduction
+

Introduction

-
+

TableGen's purpose is to help a human develop and maintain records of domain-specific information. Because there may be a large number of these @@ -72,12 +73,10 @@ find an emacs "TableGen mode" and a vim language file in the llvm/utils/emacs and llvm/utils/vim directories of your LLVM distribution, respectively.

-
- - +

Basic concepts

-
+

TableGen files consist of two key parts: 'classes' and 'definitions', both of which are considered 'records'.

@@ -112,9 +111,9 @@ multiclass, as if they were declared in the current multiclass.

- +

An example record

-
+

With no other arguments, TableGen parses the specified file and prints out all of the classes, then all of the definitions. This is a good way to see what @@ -209,12 +208,20 @@ file, to factor out the common features that instructions of its class share. A key feature of TableGen is that it allows the end-user to define the abstractions they prefer to use when describing their information.

+

Each def record has a special entry called "NAME." This is the +name of the def ("ADD32rr" above). In the general case def names can +be formed from various kinds of string processing expressions and NAME +resolves to the final value obtained after resolving all of those +expressions. The user may refer to NAME anywhere she desires to use +the ultimate name of the def. NAME should not be defined anywhere +else in user code to avoid conflict problems.

+
- +

Running TableGen

-
+

TableGen runs just like any other LLVM tool. The first (optional) argument specifies the file to read. If a filename is not specified, tblgen @@ -256,27 +263,28 @@ what you need and formats it in the appropriate way.

+
- +

TableGen syntax

-
+

TableGen doesn't care about the meaning of data (that is up to the backend to define), but it does care about syntax, and it enforces a simple type system. This section describes the syntax and the constructs allowed in a TableGen file.

-
- - +

TableGen primitives

+ +
- +

TableGen comments

-
+

TableGen supports BCPL style "//" comments, which run to the end of the line, and it also supports nestable "/* */" comments.

@@ -284,11 +292,11 @@ the line, and it also supports nestable "/* */" comments.

- + -
+

TableGen files are strongly typed, in a simple (but complete) type-system. These types are used to perform automatic conversions, check for errors, and to @@ -344,11 +352,11 @@ needed.

- + -
+

TableGen allows for a pretty reasonable number of different expression forms when building up values. These forms allow the TableGen file to be written in a @@ -400,6 +408,10 @@ which case the user must specify it explicitly.

!strconcat(a, b)
A string value that is the result of concatenating the 'a' and 'b' strings.
+
str1#str2
+
"#" (paste) is a shorthand for !strconcat. It may concatenate + things that are not quoted strings, in which case an implicit + !cast is done on the operand of the paste.
!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 @@ -433,12 +445,14 @@ to a "bits<4>" value, for example.

+
+ - + -
+

As mentioned in the intro, classes and definitions (collectively known as 'records') in TableGen are the main high-level unit of @@ -473,14 +487,12 @@ between a group of records and isolating it in a single place. Also, classes permit the specification of default values for their subclasses, allowing the subclasses to override them as they wish.

-
- - + -
+

Value definitions define named entries in records. A value must be defined before it can be referred to as the operand for another value definition or @@ -492,11 +504,11 @@ equal sign. Value definitions require terminating semicolons.

- + -
+

A record-level let expression is used to change the value of a value definition in a record. This is primarily useful when a superclass defines a @@ -519,11 +531,11 @@ because the D class overrode its value.

- + -
+

TableGen permits the definition of parameterized classes as well as normal concrete classes. Parameterized TableGen classes specify a list of variable @@ -610,11 +622,11 @@ X86 backend.

- + -
+

While classes with template arguments are a good way to factor commonality @@ -772,17 +784,21 @@ before them.

+
+ - + + +
- + -
+

TableGen supports the 'include' token, which textually substitutes the specified file in place of the include directive. The filename should be specified as a double quoted string immediately after the 'include' @@ -797,11 +813,11 @@ keyword. Example:

- + -
+

"Let" expressions at file scope are similar to "let" expressions within a record, except they can specify a value binding for @@ -864,11 +880,15 @@ several levels of multiclass instanciations. This also avoids the need of using

+
+ +
+ - +

Code Generator backend info

-
+

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

@@ -882,10 +902,10 @@ patterns:

- +

TableGen backends

-
+

TODO: How they work, how to write one. This section should not contain details about any particular backend, except maybe -print-enums as an example.