[PATCH] D44110: TableGen: Add !dag function for construction

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 7 02:45:48 PST 2018


nhaehnle added inline comments.


================
Comment at: docs/TableGen/LangIntro.rst:178
+
+    Example: !dag(op, [a1, a2], ["name1", "name2"]) results in
+    (op a1:$name1, a2:$name2).
----------------
tra wrote:
> Is it possible to construct a dag that has mix of dags and records as children? E.g `(op1 (op11 a111, a112:$n112),  a12)` ?  That is sometimes needsd to construct patterns where one of the arguments should be a dag (e.g. NVPTX uses a wrapper node for global symbols).
Unfortunately, no. This is the weakness in the type system I think I've already mentioned elsewhere: since we don't have an `any` type, a list that mixes records and dags won't type-check. It would have to be a `list<any>`.

I think it makes sense to address that (although I haven't done so), but as a separate change.


================
Comment at: lib/TableGen/TGParser.cpp:1226
+      if (!MHSt && !isa<UnsetInit>(MHS)) {
+        Error(MHSLoc, "could not determine type of argument of !dag");
+        return nullptr;
----------------
tra wrote:
> The error should be more specific describing which argument is in error -- op, children or names (or operand index). Same in the RHS handling below.
Good point, done. Note that the error will already point at the correct location of the operand (via the MHSLoc), but it's definitely true that a more explicit error can help avoid confusion.


Repository:
  rL LLVM

https://reviews.llvm.org/D44110





More information about the llvm-commits mailing list