fn callInner(
self: *WipFunction,
kind: Instruction.Call.Kind,
call_conv: CallConv,
function_attributes: FunctionAttributes,
ty: Type,
callee: Value,
args: []const Value,
name: []const u8,
has_op_bundle_cold: bool,
) Allocator.Error!Value {
const ret_ty = ty.functionReturn(self.builder);
assert(ty.isFunction(self.builder));
assert(callee.typeOfWip(self).isPointer(self.builder));
const params = ty.functionParameters(self.builder);
for (params, args[0..params.len]) |param, arg_val| assert(param == arg_val.typeOfWip(self));
try self.ensureUnusedExtraCapacity(1, Instruction.Call, args.len);
const instruction = try self.addInst(switch (ret_ty) {
.void => null,
else => name,
}, .{
.tag = switch (kind) {
.normal => .call,
.fast => .@"call fast",
.musttail => .@"musttail call",
.musttail_fast => .@"musttail call fast",
.notail => .@"notail call",
.notail_fast => .@"notail call fast",
.tail => .@"tail call",
.tail_fast => .@"tail call fast",
},
.data = self.addExtraAssumeCapacity(Instruction.Call{
.info = .{
.call_conv = call_conv,
.has_op_bundle_cold = has_op_bundle_cold,
},
.attributes = function_attributes,
.ty = ty,
.callee = callee,
.args_len = @intCast(args.len),
}),
});
self.extra.appendSliceAssumeCapacity(@ptrCast(args));
return instruction.toValue();
}