Skip to content
Snippets Groups Projects
  1. Nov 29, 2018
    • Connor Abbott's avatar
      nir/algebraic: Add unit tests for bitsize validation · db7f5623
      Connor Abbott authored
      The non-failure path can be tested by just compiling mesa and then
      testing it, but the failure paths won't be hit unless you make a mistake,
      so it's best to test them with some unit tests.
      db7f5623
    • Connor Abbott's avatar
      nir/algebraic: Rewrite bit-size inference · 7c4523fd
      Connor Abbott authored
      Before this commit, there were two copies of the algorithm: one in C,
      that we would use to figure out what bit-size to give the replacement
      expression, and one in Python, that emulated the C one and tried to
      prove that the C algorithm would never fail to correctly assign
      bit-sizes. That seemed pretty fragile, and likely to fall over if we
      make any changes. Furthermore, the C code was really just recomputing
      more-or-less the same thing as the Python code every time. Instead, we
      can just store the results of the Python algorithm in the C
      datastructure, and consult it to compute the bitsize of each value,
      moving the "brains" entirely into Python. Since the Python algorithm no
      longer has to match C, it's also a lot easier to change it to something
      more closely approximating an actual type-inference algorithm. The
      algorithm used is based on Hindley-Milner, although deliberately
      weakened a little. It's a few more lines than the old one, judging by
      the diffstat, but I think it's easier to verify that it's correct while
      being as general as possible.
      
      We could split this up into two changes, first making the C code use the
      results of the Python code and then rewriting the Python algorithm, but
      since the old algorithm never tracked which variable each equivalence
      class, it would mean we'd have to add some non-trivial code which would
      then get thrown away. I think it's better to see the final state all at
      once, although I could also try splitting it up.
      7c4523fd
  2. Nov 20, 2018
  3. Nov 19, 2018
  4. Nov 18, 2018
  5. Nov 17, 2018
Loading