[PATCH] D114790: [syntax][pseudo] Add grammar facilities for the pseudo-parser

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 3 02:06:51 PST 2022


hokein added inline comments.


================
Comment at: clang/include/clang/Tooling/Syntax/Pseudo/Grammar.h:85
+  static constexpr unsigned SizeBits = 4;
+  static_assert(SizeBits + SymbolBits <= 16,
+                "Must be able to store symbol ID + size efficiently");
----------------
sammccall wrote:
> We're being quite fiddly with layout but actually pretty wasteful.
> 
> wc says 652 with 1323 total RHS elements on the RHS - average ~2.
> So we could aim for 6 bytes per rule = 4KB but we're using 34 bytes per rule = 22KB.
> 
> Can't see a nice concrete way to achieve that though.
Yes :(
I'd keep it as-is (and decrease the MaxElements to 9). One idea is to use a flat array as a center storage of all sequences, then Rule class just need an index, and size. But there will be more data (annotations, hooks) in this class, we could figure it out later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114790



More information about the cfe-commits mailing list