[llvm-dev] Manipulating DAGs in TableGen

Paul C. Anagnostopoulos via llvm-dev llvm-dev at lists.llvm.org
Sun Oct 11 07:54:45 PDT 2020

This is a proposal to enhance TableGen's ability to analyze and manipulate
DAGs. Hopefully this will allows more complex DAGs to be built in TableGen.

1. Add a new value suffix.


   The value must be a DAG. The index specifies the operator or an operand,
   whose value is produced. The index can be

   0            produce the operator
   1...n        produce operand by position
   $name        produce operator/operand by its variable name
   string       produce operator/operand by a string containing its
                variable name

   If the item does not exist, ? (uninitialized) is produced.

   Note that multiple value suffixes are allowed, so, for example,
   DagList[i](1) would produce the first operand of the i-th dag
   in the list.

2. Add the !getdag() bang operator.

   !getdag(dag, index [, default])

   This bang operator produces the same result as the (...) suffix.
   However, the default value can be specified as the third argument.
   If it is not specified, ? is used.

3. Add the !setdag bang operator.

   !setdag(dag, index1, value1, index2, value2, ...)

   This bang operator creates a copy of the top-level dag node and
   then replaces the operator and/or operands with new values. Each
   replacement is specified by an index and a value. The new dag
   is produced.

The two new bang operators replace !getop() and !setop(), which could be

4. The !size operator will be extended to accept a DAG and produce
   the number of operands in it.

More information about the llvm-dev mailing list