-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variant Unboxing #209
base: master
Are you sure you want to change the base?
Variant Unboxing #209
Conversation
aeneas/src/ir/Normalization.v3
Outdated
var variantSolver: VariantSolver; | ||
|
||
new() { | ||
variantSolver = VariantSolver.new(config, this, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally like splitting this out into a separate file, but the two are now intertwined in a way that is confusing. Any thoughts how we can improve this? E.g. splitting out just the part that is shared between logic here and there into a separate reusable piece?
a0e04be
to
a58574b
Compare
9891a2c
to
4315b77
Compare
test/adt_layout/eq00.v3
Outdated
case Y(x: int); | ||
} | ||
|
||
def eq(a: A00, b: A00) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be def eq = A00.==
.
test/adt_layout/eq00.v3
Outdated
var a00_y2: A00 = A00.Y(12); | ||
var a00_y3: A00 = A00.Y(13); | ||
|
||
if (!eq(a00_x, a00_x2)) return -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's generally better to have a test take an (integer) argument and then switch on it, returning a different value for each input. Then the first line of the file can list all the inputs and expected outputs. This helps speed up debugging a little, because when the test fails, the test framework will tell you which input it failed on. Also, the test is simpler and less code, because it doesn't even do equality checking for expected result, it just returns a result.
test/adt_layout/eq00.v3
Outdated
@@ -0,0 +1,23 @@ | |||
//@execute =0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move all of these into test/variants/
@titzer I've gone ahead and added Also fixed a bug in the existing compiler that I discovered while writing extra tests: equality for boxed variants in tuples wasn't normalized correctly, e.g. if Separately, the equality code for |
757d09f
to
edf6b0b
Compare
This PR enables (with the
-unbox-variants
flag) the ability to unbox ADTs, both at the parent level and at a per-case level.For now, these ADTs are normalized by greedily packing fields into the fewest scalars possible, and then attaching an extra scalar representing the tag.
Todo: