[llvm-dev] [Beginner] Understanding Tablegen language

Rotate Right via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 13 11:11:20 PDT 2020


Hi,
I am new to LLVM and I find TableGen language really cryptic. The reference
manual to the language is not helpful either. I can look at the existing
.td file and reverse engineer but I am looking for a detailed manual.
Specifically, I have below questions:

1. What is a basic syntax for writing a dag? From the lang ref manual I can
see that its something like operator followed by ArgList which is enclosed
in parentheses. Where does predicate fit in this picture? I don't see any
mention of predicates in lang ref manual. A DAG should have an operator,
one or more return value and a bunch of arguments. Each of them would have
a type. I am not sure how that maps to syntax provided by TableGen
language. In TargetSelectionDAG.td I see (vt SDNode) in definition of
ImmLeaf. Does that mean vt is return type of SDNode?
2. Entity followed after "(" is always need to be an operator? or it can be
ValueType or something else?

3. What are keywords like "ins", "outs" and "ops"? They are not mentioned
in lang ref manual either.

4. What is a "node" keyword?

5. How are PatFrags used? I see some .td files I see, like X86InstrFMA.td,
PatFrag MemFrag is passed as argument to multiclass and then used along
with addr:$src3 in it. I really don't understand what this means. Does this
mean that whatever comes after PatFrag "object" is substituted as Args in
PatFrag? e.g. TargetSelectionDAG defines

*def not  : PatFrag<(ops node:$in), (xor node:$in, -1)>; how do you
visualize this? *


Thanks.
Praveen
BTech Student, VIT.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200713/0b1861e0/attachment.html>


More information about the llvm-dev mailing list