[PATCH] D32684: [X86] Adding new LLVM TableGen backend that generates the X86 backend memory folding tables.

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 13 08:11:48 PDT 2017


RKSimon added inline comments.


================
Comment at: utils/TableGen/X86FoldTablesEmitter.cpp:257
+  for (unsigned i = 0, e = B->getNumBits(); i != e; ++i) {
+    if (BitInit *Bit = cast<BitInit>(B->getBit(i)))
+      Value |= uint64_t(Bit->getValue()) << i;
----------------
Shouldn't this be dyn_cast if you want it to fail gracefully? Otherwise possibly replace that PrintFatalError with an assertion at the start of the loop?


================
Comment at: utils/TableGen/X86FoldTablesEmitter.cpp:268
+  if (B1->getNumBits() != B2->getNumBits())
+    PrintFatalError("Comparing two BitsInits with different sizes!");
+
----------------
Are we better off with an assertion?


================
Comment at: utils/TableGen/X86FoldTablesEmitter.cpp:271
+  for (unsigned i = 0, e = B1->getNumBits(); i != e; ++i) {
+    if (BitInit *Bit1 = cast<BitInit>(B1->getBit(i))) {
+      if (BitInit *Bit2 = cast<BitInit>(B2->getBit(i))) {
----------------
Again, use dyn_cast and assertions?


https://reviews.llvm.org/D32684





More information about the llvm-commits mailing list