Skip to content
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

Stage2 bit_shifting.zig passing #10532

Merged
merged 6 commits into from
Jan 8, 2022

Conversation

Hejsil
Copy link
Contributor

@Hejsil Hejsil commented Jan 7, 2022

This required some llvm and struct+union work. Hope I did it right. Each commit contains reasoning for why this change was done

src/codegen/llvm.zig Outdated Show resolved Hide resolved
src/value.zig Outdated Show resolved Hide resolved
@Hejsil Hejsil force-pushed the stage2-bit-shifting-passing branch 2 times, most recently from 5ce7495 to 97f08e3 Compare January 7, 2022 19:33
@@ -2647,7 +2647,7 @@ pub const FuncGen = struct {
switch (struct_ty.zigTypeTag()) {
.Struct => {
var ptr_ty_buf: Type.Payload.Pointer = undefined;
const llvm_field_index = llvmFieldIndex(struct_ty, field_index, target, &ptr_ty_buf);
const llvm_field_index = llvmFieldIndex(struct_ty, field_index, target, &ptr_ty_buf).?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming here that airStructFieldVal should never be emitted when the field is zero sized, as then the result would always be comptime know, so the instruction would never make it to llvm.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That assumption is sound 👍

resolveTypeForCodegen is called when we needed to resolve a type fully,
even through pointer. This commit fully implements this, even through
pointer fields on structs and unions.

The function has now also been renamed to resolveTypeFully
`runtime_param_index` is used to get the parameter type from `fn_type`,
but this variable was not incremented for zero sized parameters, causing
two zero sized parameters of different type to cause miss complication.
It is possible for Zig to emit field ptr instructions to fields whos
type is zero sized. In this case llvm should return a pointer which
points to the next none zero sized parameter.
@Hejsil Hejsil force-pushed the stage2-bit-shifting-passing branch from 97f08e3 to 3871d5e Compare January 7, 2022 21:10
@andrewrk andrewrk merged commit c4ab8d9 into ziglang:master Jan 8, 2022
@Hejsil Hejsil deleted the stage2-bit-shifting-passing branch January 8, 2022 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants