codegen: add support for lowering .field_ptr on a slice

Closes #13068
This commit is contained in:
jacobly0
2022-10-12 05:40:59 -04:00
committed by GitHub
parent b47e54ed3f
commit 562ac8be48
7 changed files with 83 additions and 18 deletions

View File

@@ -3938,6 +3938,15 @@ pub const DeclGen = struct {
const parent_llvm_ty = try dg.lowerType(parent_ty);
break :blk parent_llvm_ty.constInBoundsGEP(parent_llvm_ptr, &indices, indices.len);
},
.Pointer => {
assert(parent_ty.isSlice());
const indices: [2]*llvm.Value = .{
llvm_u32.constInt(0, .False),
llvm_u32.constInt(field_index, .False),
};
const parent_llvm_ty = try dg.lowerType(parent_ty);
break :blk parent_llvm_ty.constInBoundsGEP(parent_llvm_ptr, &indices, indices.len);
},
else => unreachable,
}
},