Skip to content

Dynamic Constant Normalization

Aaron Councilman requested to merge dc-normalization into main

Implements #18 (closed). A few notes on the actual implementation

  • Any object that can be used to add dynamic constants should implement the DynamicConstantView trait (in hercules_ir/ir/dc_normalization.rs), in particular this just requires implementing get_dynconst which can be used to retrieve dynamic constant values from their IDs and add_dynconst which takes a (normalized) dynamic constant object and interns it and produces its ID. An object that implements that trait can then be used to normalize and intern dynamic constants via the various dc_* methods.
  • Not described in the original issue, min and max actually track their fields in a set since duplicates don't matter. Also, min ignores 0 if it is one of the elements, since dynamic constants are non-negative so min {0, ...} = min {...}.
  • The trait implements a dc_normalize which can take a dynamic constant and normalize it (unlike most of the other functions which take the arguments and normalize them).
  • Re-wrote Juno's dynamic constant generation (again) mainly to use the new APIs that handle adding/multiplying lists of dynamic constants but also to fix some issues with division.

Merge request reports

Loading