ureg: Reuse meta types between registers with the same field layout.

This makes it trivial for the optimizer to realize that a generic method
operating on different registers with the same fields can be
deduplicated, since they now use the exact same generic type parameters.

(While testing PR #81, I noticed that the optimizer was
intermittently creating multiple copies of inline(never) functions with
the register address hard-coded; this change makes that impossible).

Codegen diff:

--- /tmp/old-9f68fe1b8c2218acce41fac1d49b76f9c55f4b73   2023-02-21 23:58:34.453745653 -0800
+++ /tmp/new-070db26dd29cb3804a14c2c8b760843c3d0c34cd   2023-02-21 23:59:17.069261052 -0800
@@ -23,10 +23,10 @@
   [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   [ 1] .text             PROGBITS        00000000 001000 001acf 00 AXM  0   0 16
    00     .text
 target/riscv32imc-unknown-none-elf/debug/deps/hmac384-53a16658694a446f
-  [ 1] .text             PROGBITS        00000000 001000 002dcc 00 AXM  0   0 16
+  [ 1] .text             PROGBITS        00000000 001000 002d8c 00 AXM  0   0 16
    00     .text
 target/riscv32imc-unknown-none-elf/debug/deps/ecc384-29620b311093f9b3
-  [ 1] .text             PROGBITS        00000000 001000 0042f0 00 AXM  0   0 16
+  [ 1] .text             PROGBITS        00000000 001000 004390 00 AXM  0   0 16
    00     .text
 target/riscv32imc-unknown-none-elf/debug/deps/doe-a6c703fbbd8279c3
   [ 1] .text             PROGBITS        00000000 001000 0001b0 00  AX  0   0  2

I looked at the disassembly for the ecc size regression, and this seems
to be optimizer heuristics causing spooky action at a distance; the
optimizer removed some of the keyvault code from the original
Ecc384::sign() (I guess it figured out that the test-case didn't invoke
it?), but not the new one.
2 files changed
tree: ba1499770f45b66c693faf56ab1fb9bd1d25ea87
  1. lib/
  2. src/
  3. .gitignore
  4. Cargo.toml
  5. LICENSE
  6. README.md
  7. SECURITY.md
README.md

caliptra-ureg