Source
pub fn bin(
self: *WipFunction,
tag: Instruction.Tag,
lhs: Value,
rhs: Value,
name: []const u8,
) Allocator.Error!Value {
switch (tag) {
.add,
.@"add nsw",
.@"add nuw",
.@"and",
.ashr,
.@"ashr exact",
.fadd,
.@"fadd fast",
.fdiv,
.@"fdiv fast",
.fmul,
.@"fmul fast",
.frem,
.@"frem fast",
.fsub,
.@"fsub fast",
.lshr,
.@"lshr exact",
.mul,
.@"mul nsw",
.@"mul nuw",
.@"or",
.sdiv,
.@"sdiv exact",
.shl,
.@"shl nsw",
.@"shl nuw",
.srem,
.sub,
.@"sub nsw",
.@"sub nuw",
.udiv,
.@"udiv exact",
.urem,
.xor,
=> assert(lhs.typeOfWip(self) == rhs.typeOfWip(self)),
else => unreachable,
}
try self.ensureUnusedExtraCapacity(1, Instruction.Binary, 0);
const instruction = try self.addInst(name, .{
.tag = tag,
.data = self.addExtraAssumeCapacity(Instruction.Binary{ .lhs = lhs, .rhs = rhs }),
});
return instruction.toValue();
}