[PATCH] D43753: TableGen: Allow !cast of records, cleanup conversion machinery

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 26 15:56:21 PST 2018


tra added inline comments.


================
Comment at: docs/TableGen/LangIntro.rst:186
+    If 'a' is a string, 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 aborts with an error. Otherwise, perform a normal type cast e.g.
----------------
`symbol table` may need some disambiguation.  I.e. we have more than one kind of symbols (template parameters, class/multiclass names, field names, defined records, temporary variables in !foreach) and not all of them are applicable here.

Does it mean `list of all records defined by the time tablegen reaches the end of its input`?


================
Comment at: docs/TableGen/LangIntro.rst:190-191
+    a record to a subclass, though if the types do not match, constant folding
+    will be inhibited. !cast<string> is a special case in that the argument
+    can be a record, in which case the record's name is returned.
 
----------------
Is it going to be limited to records only? We currently allow !cast<string> for other types, though not all of them work. E.g. currently int works, bits and lists do not. It may be worth documenting this in more details.


================
Comment at: lib/TableGen/Record.cpp:790-795
+  if (getOpcode() == CAST) {
+    if (auto LHSt = dyn_cast<TypedInit>(LHS)) {
+      if (isa<BitRecTy>(LHSt->getType()) && Bit == 0)
+        return LHS;
+    }
+  }
----------------
What makes getBit(0) special for !cast ops? 


Repository:
  rL LLVM

https://reviews.llvm.org/D43753





More information about the llvm-commits mailing list