Cleavir-type-inference is totally overhauled, obviously. The core algorithm is unchanged.
Two new HIR instructions, funcall-no-return and the-values.
funcall-no-return is like funcall but with no successors and no outputs. It is not generated by ast-to-hir, and currently is only produced by one of the transforms i added.
the-values is THE for a values type. I put rationales in the comment and in the commit somewhere, tl;dr values types are strange and M->F to THE as previous is not tenable in the general case. It is generated by ast-to-hir when a THE-AST has a values context. I added a transform to remove them entirely (at the expense of a bit of safety), so that should make it easier for implementations to deal with.
added a cleavir ir utility function, bypass-instruction, to delete conditionals
THE-ASTs are totally changed. Instead of just storing the CDR of a values type they break the values type up into three slots, required/optional/rest. This simplifies a lot of things later. the-values-instruction does the same thing.
THE instructions are unchanged except that i simplified the generation in ast-to-hir some. They have the same semantics etc.
Generate-AST now preserves ftype information by throwing THEs around function calls and arguments to them. It should be smart enough to merge (the ... (the ... ...)) so this is surprisingly unintrusive.
This code hasn't been tested on large code. The transforms especially are tentative.
Here is how I imagine type-related phases going:
in safe code, thes->typeqs is run to turn declarations into assertions.
run infer-types
run any transforms that need type information. the fact that they can alter the graph is problematic for maintaining the coherence of the type dictionary, but it should be okay some of the time, and if there is a problem you could just rerun infer-types on an altered graph. The most important transform to run is probably prune-typeqs, which can cut out big parts of the instruction graph.
in unsafe code (or in mostly-safe code to axe the-values), delete-the is run to eliminate the now useless instructions before MIR generation.
but of course running any transforms is optional.
Current limitations:
needs testing and tests
values types are uninferred
there is no transform to turn the-values into proper tests. current HIR instructions are not sufficient to test a type like (values integer &optional cons &rest single-float). yes, that's a stupid type nobody would actually use, but it's valid. perhaps more importantly, current HIR instructions are also not sufficient to test a type like (values integer &rest nil), i.e. "exactly one value, which is an integer").
honestly values types in general are kind of ridiculous. need more work to replace unknown-values returns with something amenable to using fixed registers.
add more type descriptors. adding further simple descriptors disjoint to the current ones, e.g. the million array types, would be very easy, just tedious.
see long note in transform.lisp about how to do pruning.
The merge conflict seems to be in ast-to-source. sorry about that. I think this is something you resolve? Just use the version in this commit instead of master so that THE-ASTs display correctly.
Approximately a million changes here. Major ones:
This code hasn't been tested on large code. The transforms especially are tentative.
Here is how I imagine type-related phases going:
but of course running any transforms is optional.
Current limitations:
The merge conflict seems to be in ast-to-source. sorry about that. I think this is something you resolve? Just use the version in this commit instead of master so that THE-ASTs display correctly.