cakeml icon indicating copy to clipboard operation
cakeml copied to clipboard

More immediate-friendly object header words

Open sorear opened this issue 5 years ago • 0 comments

(all estimates assume #754 #774 #789 have already happened)

  • ag32, arm7: These are already quite immediate friendly, most header words fit in a 15-16 bit immediate field.
  • x64: Most of our header words need 34ish bits, but the most convenient instructions for loading them have a 32 bit field. If we bumped size_len up to 40, we'd be able to use 32-bit instructions for most header words, saving 5 bytes each (~200kb total) with little impact on anything. (There are ~40k header word immediates in the basis-less bootstrapped compiler.)
  • mips, arm8: The most useful immediate fields are 15-16 bits. size_len=52 would allow a single immediate to be used for most header words; this leaves 8 bits for the tag, which seems low to me but it's the same amount we provide on 32 bit targets. Would save ~160kb for arm8, ~320kb for mips.
  • riscv64 (Major stretch goal): size_len=40 would save an instruction for most header words, but not bytes (a 2+2+4 becomes a 4+4, so save 160kb in the rare non-RVC case.) Pushing size_len to 56 would only allow for datatypes with 16 constructors, which seems unacceptably small, but we can get around this by rearranging bits in the header word: either have extra tag bits at the top (requiring two shifts to extract the length, and making pattern matching datatypes with a large number of constructors more complicated), or just leave the 12 low-order bits of header words unused and use lui to initialize them (20 bit field).
  • riscv32 (possible future work): Leaving 12 bits unused is not going to work with only 32 to start with, so either the tag field or the size field would need to be broken.

sorear avatar Sep 24 '20 21:09 sorear