Source
pub fn extractValue(
self: *WipFunction,
val: Value,
indices: []const u32,
name: []const u8,
) Allocator.Error!Value {
assert(indices.len > 0);
_ = val.typeOfWip(self).childTypeAt(indices, self.builder);
try self.ensureUnusedExtraCapacity(1, Instruction.ExtractValue, indices.len);
const instruction = try self.addInst(name, .{
.tag = .extractvalue,
.data = self.addExtraAssumeCapacity(Instruction.ExtractValue{
.val = val,
.indices_len = @intCast(indices.len),
}),
});
self.extra.appendSliceAssumeCapacity(indices);
return instruction.toValue();
}