[PATCH] D99883: [TableGen] Make behavior of list slice suffix consistent across all values

Paul C. Anagnostopoulos via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 6 17:19:37 PDT 2021


Paul-C-Anagnostopoulos added inline comments.


================
Comment at: llvm/lib/TableGen/Record.cpp:618-620
+  if (Elements.size() == 1)
+    return getElement(0);
+
----------------
Paul-C-Anagnostopoulos wrote:
> dblaikie wrote:
> > Paul-C-Anagnostopoulos wrote:
> > > dblaikie wrote:
> > > > Where's the code that already supports the non-literal case? Is there any chance of collapsing these two cases together?
> > > It's in TypedInit::convertInitListSlice(). It's sufficiently different that parameterizing a common subfunction would be more complicated than simply repeating the few common-ish lines of code. 
> > What if convertInitListSlice always returned in the ListInit form, but TGParser.cpp ParseValue checked for length 1 and did the work to turn it into a VarListElementInit or whatnot?
> I assume you're still trying to combine the two convertInitListSlice() functions. But in the loop, the thing that is push_back'ed onto the vector is different in the two functions. And the common case of a single index would build a vector for no reason. I suppose we could build a list of the Inits and then convert to a list of TypeInits, but is that really simpler?
Oh wait, my last sentence makes no sense. Anyway, does taking some of the logic out of the two functions really make it simpler overall? I guess I'm still confused about what you're suggesting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99883



More information about the llvm-commits mailing list