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

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 5 06:53:14 PST 2018


nhaehnle 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.
----------------
tra wrote:
> `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`?
I've tried to make the rules more explicit.


================
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;
+    }
+  }
----------------
tra wrote:
> What makes getBit(0) special for !cast ops? 
Good point, it shouldn't be special. This was fixing some cases of `!cast<bits<1>>(P){0}` --> `{ P }{0}` --> `P` in initializers where P itself was unset.

However, the real fix for this is to handle the case `convertInitializerTo(bits<1>)` for all inits of type `bit`. I've added that to TypedInit::convertInitializerTo.


Repository:
  rL LLVM

https://reviews.llvm.org/D43753





More information about the llvm-commits mailing list