[PATCH] D148915: [WIP][TableGen] Introduce function and lambda

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 21 11:39:57 PDT 2023


tra added a comment.

This is really nice!

Now that we have functions, I would really love to see some sort of `dump` function which would print the value it's given when it's evaluated. This would make debugging tablegen files so much easier.



================
Comment at: llvm/docs/TableGen/ProgRef.rst:208-209
    in         include       int           let           list
-   multiclass string        then          true
+   multiclass string        then          true          function
+   return
 
----------------
The list of keywords should be sorted.


================
Comment at: llvm/docs/TableGen/ProgRef.rst:302
+``function<>``\ *rettype*\ ``[,`` *argtype*\ ``]*>``
+    This type represents a function who returns a value of the *rettype* and may
+    have several argument types *argtype* (can be empty). The return type and
----------------
Do we need to define some sort of `void` type? 



================
Comment at: llvm/test/TableGen/function.td:6
+function sub_func(int a, int b): int {
+  return !sub(a, b);
+}
----------------
I'd also add a few more test cases:
- return an immediate value.
- return an already-defined record or its field.
- Check that a local defvar has priority over an already defined record with the same name.


================
Comment at: llvm/test/TableGen/function.td:31
+  int default_arg_value = default_arg(add_func(2, 3));
+  int no_arg_value = no_arg();
+}
----------------
Can we ignore the value of a function call? E.g. one use case would be to use a function to consolidate various assertion checks without actually returning anything useful otherwise.



================
Comment at: llvm/test/TableGen/function.td:381
+
+// ---- Test recursive function ---- //
+
----------------
Do we limit recursion depth or prevent runaway evaluation otherwise? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148915/new/

https://reviews.llvm.org/D148915



More information about the llvm-commits mailing list