Merge pull request #23355 from jacobly0/x86_64-rewrite

x86_64: start rewriting overflow operations
This commit is contained in:
Jacob Young 2025-04-11 05:21:44 -04:00 committed by GitHub
commit c82e1fe880
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 6022 additions and 597 deletions

View File

@ -8854,10 +8854,10 @@ fn asmExpr(
return astgen.failNode(node, "assembly expression with no output must be marked volatile", .{});
}
}
if (full.outputs.len > 32) {
return astgen.failNode(full.outputs[32], "too many asm outputs", .{});
if (full.outputs.len >= 16) {
return astgen.failNode(full.outputs[16], "too many asm outputs", .{});
}
var outputs_buffer: [32]Zir.Inst.Asm.Output = undefined;
var outputs_buffer: [15]Zir.Inst.Asm.Output = undefined;
const outputs = outputs_buffer[0..full.outputs.len];
var output_type_bits: u32 = 0;
@ -8893,10 +8893,10 @@ fn asmExpr(
}
}
if (full.inputs.len > 32) {
if (full.inputs.len >= 32) {
return astgen.failNode(full.inputs[32], "too many asm inputs", .{});
}
var inputs_buffer: [32]Zir.Inst.Asm.Input = undefined;
var inputs_buffer: [31]Zir.Inst.Asm.Input = undefined;
const inputs = inputs_buffer[0..full.inputs.len];
for (full.inputs, 0..) |input_node, i| {
@ -8912,7 +8912,7 @@ fn asmExpr(
};
}
var clobbers_buffer: [32]u32 = undefined;
var clobbers_buffer: [63]u32 = undefined;
var clobber_i: usize = 0;
if (full.first_clobber) |first_clobber| clobbers: {
// asm ("foo" ::: "a", "b")
@ -12932,14 +12932,14 @@ const GenZir = struct {
}
gz.astgen.extra.appendSliceAssumeCapacity(args.clobbers);
// * 0b00000000_000XXXXX - `outputs_len`.
// * 0b000000XX_XXX00000 - `inputs_len`.
// * 0b0XXXXX00_00000000 - `clobbers_len`.
// * 0b00000000_0000XXXX - `outputs_len`.
// * 0b0000000X_XXXX0000 - `inputs_len`.
// * 0b0XXXXXX0_00000000 - `clobbers_len`.
// * 0bX0000000_00000000 - is volatile
const small: u16 = @as(u16, @intCast(args.outputs.len)) |
@as(u16, @intCast(args.inputs.len << 5)) |
@as(u16, @intCast(args.clobbers.len << 10)) |
(@as(u16, @intFromBool(args.is_volatile)) << 15);
const small: u16 = @as(u16, @as(u4, @intCast(args.outputs.len))) << 0 |
@as(u16, @as(u5, @intCast(args.inputs.len))) << 4 |
@as(u16, @as(u6, @intCast(args.clobbers.len))) << 9 |
@as(u16, @intFromBool(args.is_volatile)) << 15;
const new_index: Zir.Inst.Index = @enumFromInt(astgen.instructions.len);
astgen.instructions.appendAssumeCapacity(.{

View File

@ -16661,9 +16661,9 @@ fn zirAsm(
const extra = sema.code.extraData(Zir.Inst.Asm, extended.operand);
const src = block.nodeOffset(extra.data.src_node);
const ret_ty_src = block.src(.{ .node_offset_asm_ret_ty = extra.data.src_node });
const outputs_len: u5 = @truncate(extended.small);
const inputs_len: u5 = @truncate(extended.small >> 5);
const clobbers_len: u5 = @truncate(extended.small >> 10);
const outputs_len: u4 = @truncate(extended.small);
const inputs_len: u5 = @truncate(extended.small >> 4);
const clobbers_len: u6 = @truncate(extended.small >> 9);
const is_volatile = @as(u1, @truncate(extended.small >> 15)) != 0;
const is_global_assembly = sema.func_index == .none;
const zir_tags = sema.code.instructions.items(.tag);

File diff suppressed because it is too large Load Diff

View File

@ -97,12 +97,14 @@ pub fn emitMir(emit: *Emit) Error!void {
op_index -= 1;
const op = lowered_inst.encoding.data.ops[op_index];
if (op == .none) continue;
const enc_length: u4 = @intCast(
std.math.divCeil(u7, @intCast(op.immBitSize()), 8) catch unreachable,
);
const is_mem = op.isMemory();
const enc_length: u4 = if (is_mem) switch (lowered_inst.ops[op_index].mem.sib.base) {
.rip_inst => 4,
else => unreachable,
} else @intCast(std.math.divCeil(u7, @intCast(op.immBitSize()), 8) catch unreachable);
reloc_offset -= enc_length;
if (op_index == lowered_relocs[0].op_index)
break :reloc_offset_length .{ reloc_offset, enc_length };
if (op_index == lowered_relocs[0].op_index) break :reloc_offset_length .{ reloc_offset, enc_length };
std.debug.assert(!is_mem);
}
};
try relocs.append(emit.lower.allocator, .{
@ -434,7 +436,7 @@ pub fn emitMir(emit: *Emit) Error!void {
loc_buf[0] = switch (mem.base()) {
.none => .{ .constu = 0 },
.reg => |reg| .{ .breg = reg.dwarfNum() },
.frame, .table => unreachable,
.frame, .table, .rip_inst => unreachable,
.reloc => |sym_index| .{ .addr = .{ .sym = sym_index } },
};
break :base &loc_buf[0];

View File

@ -50,7 +50,7 @@ pub fn findByMnemonic(
else => {},
} else false;
const rex_extended = for (ops) |op| {
if (op.isBaseExtended() or op.isIndexExtended()) break true;
if (op.baseExtEnc() != 0b00 or op.indexExtEnc() != 0b00) break true;
} else false;
if ((rex_required or rex_extended) and rex_invalid) return error.CannotEncode;

View File

@ -395,6 +395,7 @@ pub fn mem(lower: *Lower, op_index: InstOpIndex, payload: u32) Memory {
.sib => |*sib| switch (sib.base) {
else => {},
.table => sib.disp = lower.reloc(op_index, .table, sib.disp).signed,
.rip_inst => |inst_index| sib.disp = lower.reloc(op_index, .{ .inst = inst_index }, sib.disp).signed,
},
else => {},
}

View File

@ -1742,6 +1742,7 @@ pub const Memory = struct {
.reg => |reg| @intFromEnum(reg),
.frame => |frame_index| @intFromEnum(frame_index),
.reloc => |sym_index| sym_index,
.rip_inst => |inst_index| inst_index,
},
.off = switch (mem.mod) {
.rm => |rm| @bitCast(rm.disp),
@ -1769,6 +1770,7 @@ pub const Memory = struct {
.frame => .{ .frame = @enumFromInt(mem.base) },
.table => .table,
.reloc => .{ .reloc = mem.base },
.rip_inst => .{ .rip_inst = mem.base },
},
.scale_index = switch (mem.info.index) {
.none => null,
@ -1832,7 +1834,7 @@ pub fn resolveFrameAddr(mir: Mir, frame_addr: bits.FrameAddr) bits.RegisterOffse
pub fn resolveFrameLoc(mir: Mir, mem: Memory) Memory {
return switch (mem.info.base) {
.none, .reg, .table, .reloc => mem,
.none, .reg, .table, .reloc, .rip_inst => mem,
.frame => if (mir.frame_locs.len > 0) .{
.info = .{
.base = .reg,

View File

@ -266,7 +266,8 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: *const std.Target, ctx: Cont
// separately.".
const ty_size = ty.abiSize(zcu);
switch (ty.containerLayout(zcu)) {
.auto, .@"extern" => {},
.auto => unreachable,
.@"extern" => {},
.@"packed" => {
assert(ty_size <= 16);
result[0] = .integer;
@ -345,7 +346,8 @@ fn classifySystemVStruct(
);
if (zcu.typeToStruct(field_ty)) |field_loaded_struct| {
switch (field_loaded_struct.layout) {
.auto, .@"extern" => {
.auto => unreachable,
.@"extern" => {
byte_offset = classifySystemVStruct(result, byte_offset, field_loaded_struct, zcu, target);
continue;
},
@ -353,7 +355,8 @@ fn classifySystemVStruct(
}
} else if (zcu.typeToUnion(field_ty)) |field_loaded_union| {
switch (field_loaded_union.flagsUnordered(ip).layout) {
.auto, .@"extern" => {
.auto => unreachable,
.@"extern" => {
byte_offset = classifySystemVUnion(result, byte_offset, field_loaded_union, zcu, target);
continue;
},
@ -386,7 +389,8 @@ fn classifySystemVUnion(
const field_ty = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);
if (zcu.typeToStruct(field_ty)) |field_loaded_struct| {
switch (field_loaded_struct.layout) {
.auto, .@"extern" => {
.auto => unreachable,
.@"extern" => {
_ = classifySystemVStruct(result, starting_byte_offset, field_loaded_struct, zcu, target);
continue;
},
@ -394,7 +398,8 @@ fn classifySystemVUnion(
}
} else if (zcu.typeToUnion(field_ty)) |field_loaded_union| {
switch (field_loaded_union.flagsUnordered(ip).layout) {
.auto, .@"extern" => {
.auto => unreachable,
.@"extern" => {
_ = classifySystemVUnion(result, starting_byte_offset, field_loaded_union, zcu, target);
continue;
},

View File

@ -4,6 +4,7 @@ const expect = std.testing.expect;
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const Mir = @import("Mir.zig");
/// EFLAGS condition codes
pub const Condition = enum(u5) {
@ -359,11 +360,20 @@ pub const Register = enum(u8) {
ah, ch, dh, bh,
ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7,
ymm8, ymm9, ymm10, ymm11, ymm12, ymm13, ymm14, ymm15,
zmm0, zmm1, zmm2, zmm3, zmm4, zmm5, zmm6, zmm7,
zmm8, zmm9, zmm10, zmm11, zmm12, zmm13, zmm14, zmm15,
zmm16, zmm17,zmm18, zmm19, zmm20, zmm21, zmm22, zmm23,
zmm24, zmm25,zmm26, zmm27, zmm28, zmm29, zmm30, zmm31,
xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15,
ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7,
ymm8, ymm9, ymm10, ymm11, ymm12, ymm13, ymm14, ymm15,
ymm16, ymm17,ymm18, ymm19, ymm20, ymm21, ymm22, ymm23,
ymm24, ymm25,ymm26, ymm27, ymm28, ymm29, ymm30, ymm31,
xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15,
xmm16, xmm17,xmm18, xmm19, xmm20, xmm21, xmm22, xmm23,
xmm24, xmm25,xmm26, xmm27, xmm28, xmm29, xmm30, xmm31,
mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7,
@ -403,8 +413,9 @@ pub const Register = enum(u8) {
@intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => .general_purpose,
@intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => .gphi,
@intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm15) => .sse,
@intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm15) => .sse,
@intFromEnum(Register.zmm0) ... @intFromEnum(Register.zmm31) => .sse,
@intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm31) => .sse,
@intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm31) => .sse,
@intFromEnum(Register.mm0) ... @intFromEnum(Register.mm7) => .mmx,
@intFromEnum(Register.st0) ... @intFromEnum(Register.st7) => .x87,
@ -427,13 +438,14 @@ pub const Register = enum(u8) {
@intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => @intFromEnum(Register.al),
@intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => @intFromEnum(Register.ah),
@intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm15) => @intFromEnum(Register.ymm0) - 16,
@intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm15) => @intFromEnum(Register.xmm0) - 16,
@intFromEnum(Register.mm0) ... @intFromEnum(Register.mm7) => @intFromEnum(Register.mm0) - 32,
@intFromEnum(Register.st0) ... @intFromEnum(Register.st7) => @intFromEnum(Register.st0) - 40,
@intFromEnum(Register.es) ... @intFromEnum(Register.gs) => @intFromEnum(Register.es) - 48,
@intFromEnum(Register.cr0) ... @intFromEnum(Register.cr15) => @intFromEnum(Register.cr0) - 54,
@intFromEnum(Register.dr0) ... @intFromEnum(Register.dr15) => @intFromEnum(Register.dr0) - 70,
@intFromEnum(Register.zmm0) ... @intFromEnum(Register.zmm31) => @intFromEnum(Register.zmm0) - 16,
@intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm31) => @intFromEnum(Register.ymm0) - 16,
@intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm31) => @intFromEnum(Register.xmm0) - 16,
@intFromEnum(Register.mm0) ... @intFromEnum(Register.mm7) => @intFromEnum(Register.mm0) - 48,
@intFromEnum(Register.st0) ... @intFromEnum(Register.st7) => @intFromEnum(Register.st0) - 56,
@intFromEnum(Register.es) ... @intFromEnum(Register.gs) => @intFromEnum(Register.es) - 64,
@intFromEnum(Register.cr0) ... @intFromEnum(Register.cr15) => @intFromEnum(Register.cr0) - 70,
@intFromEnum(Register.dr0) ... @intFromEnum(Register.dr15) => @intFromEnum(Register.dr0) - 86,
else => unreachable,
// zig fmt: on
@ -450,6 +462,7 @@ pub const Register = enum(u8) {
@intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => 8,
@intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => 8,
@intFromEnum(Register.zmm0) ... @intFromEnum(Register.zmm15) => 512,
@intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm15) => 256,
@intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm15) => 128,
@intFromEnum(Register.mm0) ... @intFromEnum(Register.mm7) => 64,
@ -473,8 +486,9 @@ pub const Register = enum(u8) {
@intFromEnum(Register.r8w) ... @intFromEnum(Register.r15w) => true,
@intFromEnum(Register.r8b) ... @intFromEnum(Register.r15b) => true,
@intFromEnum(Register.ymm8) ... @intFromEnum(Register.ymm15) => true,
@intFromEnum(Register.xmm8) ... @intFromEnum(Register.xmm15) => true,
@intFromEnum(Register.zmm8) ... @intFromEnum(Register.zmm31) => true,
@intFromEnum(Register.ymm8) ... @intFromEnum(Register.ymm31) => true,
@intFromEnum(Register.xmm8) ... @intFromEnum(Register.xmm31) => true,
@intFromEnum(Register.cr8) ... @intFromEnum(Register.cr15) => true,
@intFromEnum(Register.dr8) ... @intFromEnum(Register.dr15) => true,
@ -484,7 +498,7 @@ pub const Register = enum(u8) {
};
}
pub fn enc(reg: Register) u4 {
pub fn enc(reg: Register) u5 {
const base = switch (@intFromEnum(reg)) {
// zig fmt: off
@intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => @intFromEnum(Register.rax),
@ -509,10 +523,6 @@ pub const Register = enum(u8) {
return @truncate(@intFromEnum(reg) - base);
}
pub fn lowEnc(reg: Register) u3 {
return @truncate(reg.enc());
}
pub fn toBitSize(reg: Register, bit_size: u64) Register {
return switch (bit_size) {
8 => reg.to8(),
@ -557,11 +567,12 @@ pub const Register = enum(u8) {
};
}
fn sseBase(reg: Register) u7 {
fn sseBase(reg: Register) u8 {
assert(reg.class() == .sse);
return switch (@intFromEnum(reg)) {
@intFromEnum(Register.ymm0)...@intFromEnum(Register.ymm15) => @intFromEnum(Register.ymm0),
@intFromEnum(Register.xmm0)...@intFromEnum(Register.xmm15) => @intFromEnum(Register.xmm0),
@intFromEnum(Register.zmm0)...@intFromEnum(Register.zmm31) => @intFromEnum(Register.zmm0),
@intFromEnum(Register.ymm0)...@intFromEnum(Register.ymm31) => @intFromEnum(Register.ymm0),
@intFromEnum(Register.xmm0)...@intFromEnum(Register.xmm31) => @intFromEnum(Register.xmm0),
else => unreachable,
};
}
@ -678,15 +689,9 @@ pub const Memory = struct {
frame: FrameIndex,
table,
reloc: u32,
rip_inst: Mir.Inst.Index,
pub const Tag = @typeInfo(Base).@"union".tag_type.?;
pub fn isExtended(self: Base) bool {
return switch (self) {
.none, .frame, .table, .reloc => false, // rsp, rbp, and rip are not extended
.reg => |reg| reg.isExtended(),
};
}
};
pub const Mod = union(enum(u1)) {

View File

@ -138,7 +138,7 @@ pub const Instruction = struct {
.moffs => true,
.rip => false,
.sib => |s| switch (s.base) {
.none, .frame, .table, .reloc => false,
.none, .frame, .table, .reloc, .rip_inst => false,
.reg => |reg| reg.class() == .segment,
},
};
@ -206,19 +206,22 @@ pub const Instruction = struct {
};
}
pub fn isBaseExtended(op: Operand) bool {
pub fn baseExtEnc(op: Operand) u2 {
return switch (op) {
.none, .imm => false,
.reg => |reg| reg.isExtended(),
.mem => |mem| mem.base().isExtended(),
.none, .imm => 0b00,
.reg => |reg| @truncate(reg.enc() >> 3),
.mem => |mem| switch (mem.base()) {
.none, .frame, .table, .reloc, .rip_inst => 0b00, // rsp, rbp, and rip are not extended
.reg => |reg| @truncate(reg.enc() >> 3),
},
.bytes => unreachable,
};
}
pub fn isIndexExtended(op: Operand) bool {
pub fn indexExtEnc(op: Operand) u2 {
return switch (op) {
.none, .reg, .imm => false,
.mem => |mem| if (mem.scaleIndex()) |si| si.index.isExtended() else false,
.none, .reg, .imm => 0b00,
.mem => |mem| if (mem.scaleIndex()) |si| @truncate(si.index.enc() >> 3) else 0b00,
.bytes => unreachable,
};
}
@ -279,6 +282,7 @@ pub const Instruction = struct {
.frame => |frame_index| try writer.print("{}", .{frame_index}),
.table => try writer.print("Table", .{}),
.reloc => |sym_index| try writer.print("Symbol({d})", .{sym_index}),
.rip_inst => |inst_index| try writer.print("RipInst({d})", .{inst_index}),
}
if (mem.scaleIndex()) |si| {
if (any) try writer.writeAll(" + ");
@ -421,14 +425,14 @@ pub const Instruction = struct {
};
switch (mem_op) {
.reg => |reg| {
const rm = switch (data.op_en) {
const rm: u3 = switch (data.op_en) {
.ia, .m, .mi, .m1, .mc, .vm, .vmi => enc.modRmExt(),
.mr, .mri, .mrc => inst.ops[1].reg.lowEnc(),
.rm, .rmi, .rm0, .rvm, .rvmr, .rvmi, .rmv => inst.ops[0].reg.lowEnc(),
.mvr => inst.ops[2].reg.lowEnc(),
.mr, .mri, .mrc => @truncate(inst.ops[1].reg.enc()),
.rm, .rmi, .rm0, .rvm, .rvmr, .rvmi, .rmv => @truncate(inst.ops[0].reg.enc()),
.mvr => @truncate(inst.ops[2].reg.enc()),
else => unreachable,
};
try encoder.modRm_direct(rm, reg.lowEnc());
try encoder.modRm_direct(rm, @truncate(reg.enc()));
},
.mem => |mem| {
const op = switch (data.op_en) {
@ -447,7 +451,7 @@ pub const Instruction = struct {
.ia => try encodeImm(inst.ops[0].imm, data.ops[0], encoder),
.mi => try encodeImm(inst.ops[1].imm, data.ops[1], encoder),
.rmi, .mri, .vmi => try encodeImm(inst.ops[2].imm, data.ops[2], encoder),
.rvmr => try encoder.imm8(@as(u8, inst.ops[3].reg.enc()) << 4),
.rvmr => try encoder.imm8(@as(u8, @as(u4, @intCast(inst.ops[3].reg.enc()))) << 4),
.rvmi => try encodeImm(inst.ops[3].imm, data.ops[3], encoder),
else => {},
}
@ -461,8 +465,8 @@ pub const Instruction = struct {
const final = opcode.len - 1;
for (opcode[first..final]) |byte| try encoder.opcode_1byte(byte);
switch (inst.encoding.data.op_en) {
.o, .oz, .oi => try encoder.opcode_withReg(opcode[final], inst.ops[0].reg.lowEnc()),
.zo => try encoder.opcode_withReg(opcode[final], inst.ops[1].reg.lowEnc()),
.o, .oz, .oi => try encoder.opcode_withReg(opcode[final], @truncate(inst.ops[0].reg.enc())),
.zo => try encoder.opcode_withReg(opcode[final], @truncate(inst.ops[1].reg.enc())),
else => try encoder.opcode_1byte(opcode[final]),
}
}
@ -532,23 +536,29 @@ pub const Instruction = struct {
switch (op_en) {
.z, .i, .zi, .ii, .ia, .fd, .td, .d => {},
.o, .oz, .oi => rex.b = inst.ops[0].reg.isExtended(),
.zo => rex.b = inst.ops[1].reg.isExtended(),
.o, .oz, .oi => rex.b = inst.ops[0].reg.enc() & 0b01000 != 0,
.zo => rex.b = inst.ops[1].reg.enc() & 0b01000 != 0,
.m, .mi, .m1, .mc, .mr, .rm, .rmi, .mri, .mrc, .rm0, .rmv => {
const r_op = switch (op_en) {
.rm, .rmi, .rm0, .rmv => inst.ops[0],
.mr, .mri, .mrc => inst.ops[1],
else => .none,
};
rex.r = r_op.isBaseExtended();
const r_op_base_ext_enc = r_op.baseExtEnc();
rex.r = r_op_base_ext_enc & 0b01 != 0;
assert(r_op_base_ext_enc & 0b10 == 0);
const b_x_op = switch (op_en) {
.rm, .rmi, .rm0 => inst.ops[1],
.m, .mi, .m1, .mc, .mr, .mri, .mrc => inst.ops[0],
else => unreachable,
};
rex.b = b_x_op.isBaseExtended();
rex.x = b_x_op.isIndexExtended();
const b_x_op_base_ext_enc = b_x_op.baseExtEnc();
rex.b = b_x_op_base_ext_enc & 0b01 != 0;
assert(b_x_op_base_ext_enc & 0b10 == 0);
const b_x_op_index_ext_enc = b_x_op.indexExtEnc();
rex.x = b_x_op_index_ext_enc & 0b01 != 0;
assert(b_x_op_index_ext_enc & 0b10 == 0);
},
.vm, .vmi, .rvm, .rvmr, .rvmi, .mvr => unreachable,
}
@ -575,7 +585,9 @@ pub const Instruction = struct {
.m, .mi, .m1, .mc, .vm, .vmi => .none,
else => unreachable,
};
vex.r = r_op.isBaseExtended();
const r_op_base_ext_enc = r_op.baseExtEnc();
vex.r = r_op_base_ext_enc & 0b01 != 0;
assert(r_op_base_ext_enc & 0b10 == 0);
const b_x_op = switch (op_en) {
.rm, .rmi, .rm0, .vm, .vmi, .rmv => inst.ops[1],
@ -583,8 +595,12 @@ pub const Instruction = struct {
.rvm, .rvmr, .rvmi => inst.ops[2],
else => unreachable,
};
vex.b = b_x_op.isBaseExtended();
vex.x = b_x_op.isIndexExtended();
const b_x_op_base_ext_enc = b_x_op.baseExtEnc();
vex.b = b_x_op_base_ext_enc & 0b01 != 0;
assert(b_x_op_base_ext_enc & 0b10 == 0);
const b_x_op_index_ext_enc = b_x_op.indexExtEnc();
vex.x = b_x_op_index_ext_enc & 0b01 != 0;
assert(b_x_op_index_ext_enc & 0b10 == 0);
},
}
@ -621,8 +637,8 @@ pub const Instruction = struct {
}
fn encodeMemory(encoding: Encoding, mem: Memory, operand: Operand, encoder: anytype) !void {
const operand_enc = switch (operand) {
.reg => |reg| reg.lowEnc(),
const operand_enc: u3 = switch (operand) {
.reg => |reg| @truncate(reg.enc()),
.none => encoding.modRmExt(),
else => unreachable,
};
@ -634,7 +650,7 @@ pub const Instruction = struct {
try encoder.modRm_SIBDisp0(operand_enc);
if (mem.scaleIndex()) |si| {
const scale = math.log2_int(u4, si.scale);
try encoder.sib_scaleIndexDisp32(scale, si.index.lowEnc());
try encoder.sib_scaleIndexDisp32(scale, @truncate(si.index.enc()));
} else {
try encoder.sib_disp32();
}
@ -646,21 +662,21 @@ pub const Instruction = struct {
try encoder.modRm_SIBDisp0(operand_enc);
if (mem.scaleIndex()) |si| {
const scale = math.log2_int(u4, si.scale);
try encoder.sib_scaleIndexDisp32(scale, si.index.lowEnc());
try encoder.sib_scaleIndexDisp32(scale, @truncate(si.index.enc()));
} else {
try encoder.sib_disp32();
}
try encoder.disp32(sib.disp);
},
.general_purpose => {
const dst = base.lowEnc();
const dst: u3 = @truncate(base.enc());
const src = operand_enc;
if (dst == 4 or mem.scaleIndex() != null) {
if (sib.disp == 0 and dst != 5) {
try encoder.modRm_SIBDisp0(src);
if (mem.scaleIndex()) |si| {
const scale = math.log2_int(u4, si.scale);
try encoder.sib_scaleIndexBase(scale, si.index.lowEnc(), dst);
try encoder.sib_scaleIndexBase(scale, @truncate(si.index.enc()), dst);
} else {
try encoder.sib_base(dst);
}
@ -668,7 +684,7 @@ pub const Instruction = struct {
try encoder.modRm_SIBDisp8(src);
if (mem.scaleIndex()) |si| {
const scale = math.log2_int(u4, si.scale);
try encoder.sib_scaleIndexBaseDisp8(scale, si.index.lowEnc(), dst);
try encoder.sib_scaleIndexBaseDisp8(scale, @truncate(si.index.enc()), dst);
} else {
try encoder.sib_baseDisp8(dst);
}
@ -677,7 +693,7 @@ pub const Instruction = struct {
try encoder.modRm_SIBDisp32(src);
if (mem.scaleIndex()) |si| {
const scale = math.log2_int(u4, si.scale);
try encoder.sib_scaleIndexBaseDisp32(scale, si.index.lowEnc(), dst);
try encoder.sib_scaleIndexBaseDisp32(scale, @truncate(si.index.enc()), dst);
} else {
try encoder.sib_baseDisp32(dst);
}
@ -705,6 +721,10 @@ pub const Instruction = struct {
try encoder.modRm_indirectDisp32(operand_enc, 0);
try encoder.disp32(undefined);
} else return error.CannotEncode,
.rip_inst => {
try encoder.modRm_RIPDisp32(operand_enc);
try encoder.disp32(sib.disp);
},
},
.rip => |rip| {
try encoder.modRm_RIPDisp32(operand_enc);
@ -862,7 +882,7 @@ fn Encoder(comptime T: type, comptime opts: Options) type {
try self.writer.writeByte(
@as(u8, @intFromBool(fields.w)) << 7 |
@as(u8, ~fields.v.enc()) << 3 |
@as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3 |
@as(u8, @intFromBool(fields.l)) << 2 |
@as(u8, @intFromEnum(fields.p)) << 0,
);
@ -870,7 +890,7 @@ fn Encoder(comptime T: type, comptime opts: Options) type {
try self.writer.writeByte(0b1100_0101);
try self.writer.writeByte(
@as(u8, ~@intFromBool(fields.r)) << 7 |
@as(u8, ~fields.v.enc()) << 3 |
@as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3 |
@as(u8, @intFromBool(fields.l)) << 2 |
@as(u8, @intFromEnum(fields.p)) << 0,
);

View File

@ -787,7 +787,6 @@ fn should_not_be_zero(x: f128) !void {
test "umax wrapped squaring" {
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
{
@ -1050,13 +1049,13 @@ test "@mulWithOverflow bitsize > 32" {
}
test "@mulWithOverflow bitsize 128 bits" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
try testMulWithOverflow(u128, 3, 0x5555555555555555_5555555555555555, 0xffffffffffffffff_ffffffffffffffff, 0);
try testMulWithOverflow(u128, 3, 0x5555555555555555_5555555555555556, 2, 1);
@ -1070,13 +1069,19 @@ test "@mulWithOverflow bitsize 128 bits" {
try testMulWithOverflow(i128, 3, -0x2aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaab, 0x7fffffffffffffff_ffffffffffffffff, 1);
try testMulWithOverflow(i128, -1, -1, 1, 0);
try testMulWithOverflow(i128, minInt(i128), minInt(i128), 0, 1);
try testMulWithOverflow(i128, 1 << 126, 1 << 1, -1 << 127, 1);
try testMulWithOverflow(i128, -1 << 105, 1 << 22, -1 << 127, 0);
try testMulWithOverflow(i128, 1 << 84, -1 << 43, -1 << 127, 0);
try testMulWithOverflow(i128, -1 << 63, -1 << 64, -1 << 127, 1);
}
test "@mulWithOverflow u256" {
test "@mulWithOverflow bitsize 256 bits" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
{
const const_lhs: u256 = 8035709466408580321693645878924206181189;
@ -1106,6 +1111,10 @@ test "@mulWithOverflow u256" {
try std.testing.expect(var_result[0] == const_result[0]);
try std.testing.expect(var_result[1] == const_result[1]);
}
try testMulWithOverflow(i256, 1 << 254, 1 << 1, -1 << 255, 1);
try testMulWithOverflow(i256, -1 << 212, 1 << 43, -1 << 255, 0);
try testMulWithOverflow(i256, 1 << 170, -1 << 85, -1 << 255, 0);
try testMulWithOverflow(i256, -1 << 128, -1 << 127, -1 << 255, 1);
}
fn testSubWithOverflow(comptime T: type, a: T, b: T, sub: T, bit: u1) !void {

View File

@ -43,7 +43,6 @@ fn testSwitchWithAllRanges(x: u32, y: u32) u32 {
}
test "switch arbitrary int size" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO

View File

@ -7,6 +7,8 @@ test {
if (builtin.object_format == .macho) return error.SkipZigTest;
// COFF linker does not support the new backend.
if (builtin.object_format == .coff) return error.SkipZigTest;
_ = @import("x86_64/math.zig");
_ = @import("x86_64/binary.zig");
_ = @import("x86_64/cast.zig");
_ = @import("x86_64/mem.zig");
_ = @import("x86_64/unary.zig");
}

View File

@ -81,26 +81,88 @@ fn binary(comptime op: anytype, comptime opts: struct { compare: Compare = .rela
);
}
fn testInts() !void {
try testArgs(i4, 0x3, 0x2);
try testArgs(u4, 0xe, 0x6);
try testArgs(i8, 0x48, 0x6c);
try testArgs(u8, 0xbb, 0x43);
try testArgs(i16, -0x0fdf, 0x302e);
try testArgs(u16, 0xb8bf, 0x626d);
try testArgs(i32, -0x6280178f, 0x6802c034);
try testArgs(u32, 0x80d7a2c6, 0xbff6a402);
try testArgs(i64, 0x0365a53b8ee0c987, -0x1bb6d3013500a7d2);
try testArgs(u64, 0x71138bc6b4a38898, 0x1bc4043de9438c7b);
try testArgs(i128, 0x76d428c46cdeaa2ac43de8abffb22f6d, 0x427f7545abe434a12544fdbe2a012889);
try testArgs(u128, 0xe05fc132ef2cd8affee00a907f0a851f, 0x29f912a72cfc6a7c6973426a9636da9a);
try testArgs(i256, -0x53d4148cee74ea43477a65b3daa7b8fdadcbf4508e793f4af113b8d8da5a7eb6, -0x30dcbaf7b9b7a3df033694e6795444d842fb0b8f79bc18b3ea8a6b7ccad3ea91);
try testArgs(u256, 0xb7935f5c2f3b1ae7a422c0a7c446884294b7d5370bada307d2fe5a4c4284a999, 0x310e6e196ba4f143b8d285ca6addf7f3bb3344224aff221b27607a31e148be08);
try testArgs(i258, -0x0eee283365108dbeea0bec82f5147418d8ffe86f9eed00e414b4eccd65c21239a, -0x122c730073fc29a24cd6e3e6263566879bc5325d8566b8db31fcb4a76f7ab95eb);
try testArgs(u258, 0x186d5ddaab8cb8cb04e5b41e36f812e039d008baf49f12894c39e29a07796d800, 0x2072daba6ffad168826163eb136f6d28ca4360c8e7e5e41e29755e19e4753a4f5);
try testArgs(i495, 0x2fe6bc5448c55ce18252e2c9d44777505dfe63ff249a8027a6626c7d8dd9893fd5731e51474727be556f757facb586a4e04bbc0148c6c7ad692302f46fbd, -0x016a358821ef8240172f3a08e8830c06e6bcf2225f5f4d41ed42b44d249385f55cc594e1278ecac31c73faed890e5054af1a561483bb1bb6fb1f753514cf);
try testArgs(u495, 0x6eaf4e252b3bf74b75bac59e0b43ca5326bad2a25b3fdb74a67ef132ac5e47d72eebc3316fb2351ee66c50dc5afb92a75cea9b0e35160652c7db39eeb158, 0x49fbed744a92b549d8c05bb3512c617d24dd824f3f69bdf3923bc326a75674b85f5b828d2566fab9c86f571d12c2a63c9164feb0d191d27905533d09622a);
try testArgs(i512, -0x3a6876ca92775286c6e1504a64a9b8d56985bebf4a1b66539d404e0e96f24b226f70c4bcff295fdc2043b82513b2052dc45fd78f7e9e80e5b3e101757289f054, 0x5080c516a819bd32a0a5f0976441bbfbcf89e77684f1f10eb326aeb28e1f8d593278cff60fc99b8ffc87d8696882c64728dd3c322b7142803f4341f85a03bc10);
try testArgs(u512, 0xe5b1fedca3c77db765e517aabd05ffc524a3a8aff1784bbf67c45b894447ede32b65b9940e78173c591e56e078932d465f235aece7ad47b7f229df7ba8f12295, 0x8b4bb7c2969e3b121cc1082c442f8b4330f0a50058438fed56447175bb10178607ecfe425cb54dacc25ef26810f3e04681de1844f1aa8d029aca75d658634806);
try testArgs(i1, 0x0, -0x1);
try testArgs(u1, 0x1, 0x1);
try testArgs(i2, 0x0, -0x2);
try testArgs(u2, 0x2, 0x1);
try testArgs(i3, 0x1, -0x3);
try testArgs(u3, 0x6, 0x1);
try testArgs(i4, 0x6, 0x3);
try testArgs(u4, 0x8, 0x5);
try testArgs(i5, -0x9, -0xd);
try testArgs(u5, 0x5, 0x13);
try testArgs(i7, 0x34, 0x1d);
try testArgs(u7, 0x31, 0x56);
try testArgs(i8, -0x57, -0x70);
try testArgs(u8, 0x12, 0xd6);
try testArgs(i9, -0x8a, -0xa0);
try testArgs(u9, 0xf8, 0x95);
try testArgs(i15, -0x790, 0x116f);
try testArgs(u15, 0x548b, 0x4cd6);
try testArgs(i16, -0x2d17, -0x5c17);
try testArgs(u16, 0xadc0, 0xb223);
try testArgs(i17, 0xe543, 0xaad5);
try testArgs(u17, 0x9515, 0xa3c1);
try testArgs(i31, -0x28858a2f, 0x369e917a);
try testArgs(u31, 0x32bab794, 0x75464e7f);
try testArgs(i32, 0x79e74e44, 0x61fe4ab1);
try testArgs(u32, 0xc82f8e2, 0x5dde37e2);
try testArgs(i33, -0xa4cbaa13, -0x4d20ee61);
try testArgs(u33, 0x17461d437, 0x16cbc228f);
try testArgs(i63, 0x333220e16b1e53fb, 0x121a0d970a5a4504);
try testArgs(u63, 0x2dcd94e2ae4aa2af, 0x5f401e6e287a4dd7);
try testArgs(i64, 0x17e6bb7d8d430410, 0x760d42736f4b445c);
try testArgs(u64, 0x430970421452be50, 0xb4b5e96f4183b5fc);
try testArgs(i65, 0xb4477484679a6576, 0x21c9a3100d35de49);
try testArgs(u65, 0x1b7ffa914193a316, 0x6751268790308460);
try testArgs(i95, 0xd573e2100686f5df03aa29f, 0x4f7c921eb980b43a554b763);
try testArgs(u95, 0x62791162d2740f3ae84a9fcf, 0x1b6e66ae70bb9785a2118ecc);
try testArgs(i96, -0x6dc72375264ab887ea6073d5, 0x357ca705a600e94f6dd114c9);
try testArgs(u96, 0x77867877aae9bc90b2b57ce7, 0xd9a5352eb86061b67a61b212);
try testArgs(i97, 0x76f421e0ccfc6e7531c03ad5, 0x6775cdacdfca5455771c0dae);
try testArgs(u97, 0xaeb79499018e490b6aa2a5fc, 0x6cf53b08068cf25bdc307606);
try testArgs(i127, -0xc6de705251f892f8ba6a4f10aee0c7, -0x1598d3c6fd635ec0796a584af7479027);
try testArgs(u127, 0x5b3ec94f88a61621be2f745e90153390, 0x72456ad6a7ef886decf13195a50ca4d6);
try testArgs(i128, -0x44570544f745b89beb111016359577d5, -0x48904e59a05caede0974f916efba61a0);
try testArgs(u128, 0x3b14f670f6ac712d087a9ec7b15394d2, 0x19b69cb71a6763a9dc5baec5bb818450);
try testArgs(i129, 0xd58a765abb324106d83362db47fc374d, 0x548642028e222abf2ee21a1999a8ac5f);
try testArgs(u129, 0x1144fb18eba36e437bc45a73bbe25f10e, 0xdc7cb5f65f5127b00a842adf3f5a5231);
try testArgs(i159, 0x3121c6ae74c46679386f2051ee0520d9264e01cf, -0x34fec2cf28ce549281a5dc79f7ed834483f418af);
try testArgs(u159, 0x2e479684775f86a8ff1a9c6fab9022b18a6f6be4, 0x63c77ea3d97ad2c715fd13db972e678fefe3efba);
try testArgs(i160, 0x1e55924219aa114ef8d2b3193d09ae7849a3e551, -0x13f1ff6a62e562f7b78559f032bb05b2e2d15748);
try testArgs(u160, 0x8ed3d206fcc59350cf23dcd9e042eb36bcc63e52, 0xc88e1c5a42abf98aee0a3479e7f4fe88ab53b6f2);
try testArgs(i161, -0xd3d6885c0df36bd513aca744561684d12a62f044, 0xa519d3c4a7ea2e4768d840ec8641995689de6116);
try testArgs(u161, 0x10b4afdfa36471c77a2b629ef85e1289b798161b, 0x15e89da33c31ec01adf6921b8d13bc943f139fba2);
try testArgs(i191, 0x2436122b85c017733d9d28347544298d148223e1d9cbf0a2, 0x46b80688a0e0b59e66628940772893fcce258d3da7c0193);
try testArgs(u191, 0x3d00a8da821de44f98fa70d298bda9e25f99d8f54936d09f, 0x4ad4440686be966599985094f16e364c961503214ff86519);
try testArgs(i192, 0x124d0580271a71745f842e3a81d8cb6154c7f6f4b8b0cf39, -0x5bae9d7d471e609f1570a3f9805b80c4d672a086d44107eb);
try testArgs(u192, 0x3b882677dc62d5c76cc942bea0d2f72925ff0a9e234d7ce9, 0x5d7825e3f2254bf214257ebe84716dc88fde6c9563218ac4);
try testArgs(i193, 0x9c143db83d19c8fff1c23f3c93b103eaf8be02910a1cbe5, 0xcfa1059ba12508d2ff3ef9763ce8224eb1d0a0f22def289d);
try testArgs(u193, 0x635890f170da79117490445db595c1f2bb5a5cf640abc8e8, 0xdb5a2a6a3c6db7f43949123f0886cb93bbbed2d5dd7690e);
try testArgs(i223, -0x25e4a8d454e5957a9906a66a0c02ad53e727e3e18ca4b8be98561306, 0x8d6d3977afce56a5dffc537de19d4c73f2e5603699373d010e51d10);
try testArgs(u223, 0x5721636a3c6d271fe9eb08420d29454775666266801a7d23d61075be, 0x7e573fd8dcbd6dc780d13b61d5255cae790ea697d1c9a5479fa51ee);
try testArgs(i224, 0x51f97aaa96493aaed2677294bfde0715d69d961fef97a557ae9dbc84, 0x306d9305e2d5162dd0ce0454d2daaa54879b11a77386bb03e779a23e);
try testArgs(u224, 0xdc7eb2070c048b6fd22d6df97b3ef5e9fc5f28d8d229710333defecd, 0x475662887f29712bc927fae9de37cd842d883682a26e653d7b3f2ed9);
try testArgs(i225, -0x9b3dba4fe2026e8d90d9be4b8b2334034d2ae23569c4e1a3a311925d, -0x2ae4c074cff2da1e7fcab269ce6da7f4a9f763062f97526c0b4abf34);
try testArgs(u225, 0xb36dd536afb070e9be7fba5eaf548fe741182cabaf9f9510f86b3ffb, 0x1f35e5728f29e2566afd9a325beaf17ebf5f894e744825bdd56bb12d0);
try testArgs(i255, 0x2db696171e4045e17cb2a96763ff2728b459e5bf9ade6e9cd118bbc4f91aca89, -0x1580d80086052560091fe42077ce66c45d7e93173f74327f44fec7b63ed9f2aa);
try testArgs(u255, 0x392b3639141d03da49d576fd0ce498e1bafb8fc032604e68e91e589f6d2a05a3, 0x46f60e500f01bdbe18f71fb8dbef0395245a94f55421637ca50eb8922a751977);
try testArgs(i256, -0x2f3c22cb1d12628b2eccd705f1526d8a91258183742d9521bdc97d943591d87c, -0x864d3ef8b592e041289dbb54def60ceee798673138aa750a5efdaffcd42b62d);
try testArgs(u256, 0x25776f0ce5f3c6761eec99ace965f9162e9416e4d4e298674e5723b64e443528, 0xb1ee7fd2efaddd5d25eea49bde34e53c40d59221757f17d53d9a4c9ab7eca3f5);
try testArgs(i257, 0xd599706e1a09217f1f698520993d2b62ee877a4150bd8db6e5546657900dc7ce, 0x51d0faef82bb0878a4fd4331dcaec6ed57156acc2377c7e301eca6989e897346);
try testArgs(u257, 0xb0d42105facc0db629c5a65d6e975d25163841051efb1e187b70015f8c9e22ba, 0xf0eb6d0529e15fac6e97e850f50b7bf5056c9010345884926bf056590ddf3187);
try testArgs(i511, 0x23c07fa26fea1595de6e368cb42d05696562d8fb05a2aab6b304c443275071a31684a369f69f30fd53223017669dcf8157f7ff1bcda05ad28dcf46c92f7f2bd5, 0x44884ae45727d2c249b280cbb6795f237015f1082ade12167c52f0318422b3ae9c1753263011878e3fa4fce0db683efdd249e325188a40ccb959bd6bf050fbf);
try testArgs(u511, 0x642d98a41a7cc71dab7845c2c568696d0d77733c266846019756937cc29382d46074c8eb86502f4855c35f6354e51d98c41674166a9a7385ab94b0c7a63f58c0, 0x3cc5230f530a12c8cae29654e55a6d7cd26fe7606beed5c9a8fef443b107bf18dd8cc034683b47a213a3a885abd7048188713e8e7b9157145cd24748e256f5b7);
try testArgs(i512, -0x4b6d88a77e2a42d67daada905d16c6045b4dd57e608a0482f45531781d4994e2a6b71ad41a106b2dfc76e60aebd9e1d357b24b8d6889de3cf3e58ff3a48f54aa, -0x2e28e1b21ec33fd5dd9b1fbdc312e32884208b549ce0ca1661ca1150a6bd43363d4d186aa8ac70ad0595b44b5279ff070df8bd0b51095c62c8c499bfcaa7494c);
try testArgs(u512, 0xf40ad922664478a7b71a5676fc49434a45ba86975cef377c8321159cd880b67cd543fcca70187d5912675c0bc1fa4129cb470f280cde56ac4ec848ca589f143f, 0xe20a8110780ff05718adc173677ff0579126576f1fc3857ac41d6b7d5334d93134181af15ce2d35224d2e5c63384f33e331b16ecbc6db44edbb4074134d23e97);
try testArgs(i513, 0x55a556c6b6605897ffb7a791bdf309d5edb879f2841d1bba37006cdd0e7d00d971c85def024e28b7a17e53f3bcf5a5d5c43e780c6d13d67de1ca7b8f05deddfb, 0x53f475716443b38792e618ce109cec641aa351ce2e258a99153820c5522a4acc7f2b5b4ecd0000bcbe5a410bbee200576f6ff17ce7e8b7d1f0752390d1bb9b3f);
try testArgs(u513, 0x1e4e15bc406c558c14f48b83090647d7f2254fa571eac7f8aad8edb76a90547f7854bd6315e50ad44ea93034db9fab450a584b53abf8537e31d39cd706a31eaa7, 0x1d348de8124b72ca1d0e382501024c9e1b0f6fc16c5cd4a86aef2731bd39c29173749afe94bb2992ea805148fe0d96abdc5980b2143bd81419c1e40bf81b2496f);
try testArgs(i1023, -0x37781a6086d9310e4cdb24f5f374736e32af53c9545298aa53fe17854f73052cd808f658efacea622c59adb51af4d2dd636521ca2717acc43389c975505b7543da2c62f33c3152907f13b1ffa5b9881b33acec3cab1d8e33c2239ea6835277c474629a9157f8acd7c1d83076c2e75a48a8d3a94067e801c51057e47e09f0be14, 0x39ad04132dec8b795b98fd7cd085605ce8354655633068ee485d9dc78853feb922a54a3df6209989d1137e4ea8b0ad2cae48b21df2e0c04feeca56d2551f12782312a6ae483ffff466ff78446ebd4d47a61c1cba2603a62b44a72800060dda7eec8bc9060b8c5533afa7946bd38e93fddb863392500c22616dd4ae4932f20fe4);
try testArgs(u1023, 0x6e14a9d998a9ef7ac77b6fe08225fcc176e687685736e0e32c9e6b8fe96e9a7b14b3318310e945f7f84128455075eedb4a7b7736185f58e5640688c5d3b47d785338a0b70e77f4d237fd85f7820f3ebe6eb30f5a71231e813a70d6c76963d66291f271cd6f462ce685a0270ec5f6e856340f91d7597cd2b779566fe3ff4d4a98, 0x211eafbd449691e390d14dd34cb9c4d32627ecbec485d4a0a7cca1b28bd81d2153a7a75c2f62c4c3c7f198740cfe65dfa3c86156aa0b6d22757fd07f4070ddd50e334782f045a58b96c5a8f04b4615968501e9b5e801c475bdc034919c9e9df6df3cbbd59bacfa9409b21c3365d10e132d75958774c6244446127b043d155ec4);
try testArgs(i1024, 0xa6bd15fd4c529a24e4d727c5c0db9422ed7038ba23944b2b54ffc8d3731e2ffc19e12d885010fb10d208ea045e2a4cfec32d190f221bd453ec73fcecc03e37fd70be3fba3945c881cb9bce69f3f6ad9a6ee0d42a393b3669d1ca518d0b7b06a2c47978f22bc1db8802ef6ce29ea51b48256c6fed82e04355665f9d27ff485b, -0x69f258c2a86e97161ce2e683801591976a8e5a71b88605450961ee271637e6c2fee13459c29d42d4c5fb408f80236d3b2db34752e307fee6cbce2e5088adc817902a5adbbba72c8be84b9f8af5ce0fac464cae61cff9cbbe3a8dcdbec0af855b2e6c2c19fbe4f01baec9ca28b78bd7d383281c71d81da74fd0a2c8a5b754ee57);
try testArgs(u1024, 0x111e0a4e0c61ab3c5229154539ddb010542cb528533b4ea13813d8dbbaca7de395aac3c22dae1bd9db8bf9005ea9ef3df253aefabdce060a93e60da6edc3b1b2d78aead4647e7a589b66aa53fb953742b71f823b539150918df0fe781ee4d00279e4da9995804391bb19504de2f108f7d6ba14d624fa175842bd429f638de8f9, 0xcf9160dcb7ed13a738f7c8b2a17ca2fe84f53620a50f6a948698c4efca88392dc104ef5d26f19c82c8f770f727585702cc8d1c4cc2bba9e691e61b055d98cd636347a7c50b3bd2b2f5dfa416dadbdd76c111d45598c93ef729588cf998a55260cfe94d376ec4e8dc132afa42b66b68bc826c50169f9f4fc798cf7e8f29df639a);
try testArgs(i1025, 0xef2102c2cab6ad6bf2f2ba09c154440e65acc56cb14c5221a12b12404f7eafefeab4537f70cc10afb945e93c935223ffd3146911021666fd68fcaa494ded54ce66d2832b1d82b0654f24f1183bbc3ee45eb15c424a74ad41f22c7009b86cb404ac3b810445679417d7e0c5d5f4e88dec7c90352afa367004facbc1d668ab0a7, 0xc7743d3a52bad9bed0d24dbeaac4f27f4790ee14e984484f7ee077e6285394f046f2ba6d3a9c6e0aea1c07de98741a88669a035ec4d9755130fe96414223486e89d710a743ca2c2b53871fdb4851d90a595111d8d12e6732e4b580e235218edee3bc56fca3de99bc5f9a37c9dbc9a8ca5aaba710ec5e498b58b239a1be56915b);
try testArgs(u1025, 0x1dea81169800bac2f3afcf3be5dbd2d8eefbace8a24a2da0a383a928d1109459f34028be4413119f1af00ad90ce4d63064016dc1cee5b783c79c1998a0a49de21c4db71d432273576503589fc966c7ec2d730fa9bc4c5ff3128a82653ab8149528de67804718e39722f89b91c75d012ea41c642c889f0db95c882a9790a5e922f, 0x156fe02946ab9069a644dcc1f2b1afa04ee88ab1de19575a2715abf4a52bf374d297fdf78455ccdb87a934d3d818d774b63865eaedfdad3c56a56b8fcc62703c391aedf16cf770af06d7d205f93778c012df54fe5290084e1cd2bbec86a2f295cdce69a2cd774e064580f3c9cfae60d17b12f610e86566e68d5183d706c8ad8af);
}
fn testFloats() !void {
@setEvalBranchQuota(21_700);
@ -1942,130 +2004,67 @@ fn binary(comptime op: anytype, comptime opts: struct { compare: Compare = .rela
0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
});
// workaround https://github.com/ziglang/zig/issues/22914
// TODO: try testArgs(@Vector(1, i2), .{
// 0x1,
// }, .{
// 0x1,
// });
// try testArgs(@Vector(2, i2), .{
// 0x0, -0x2,
// }, .{
// -0x2, -0x2,
// });
// try testArgs(@Vector(4, i2), .{
// -0x2, -0x1, 0x0, -0x2,
// }, .{
// -0x2, 0x1, -0x1, -0x2,
// });
// try testArgs(@Vector(8, i2), .{
// -0x1, 0x1, 0x1, -0x1, -0x2, -0x2, 0x0, -0x2,
// }, .{
// -0x1, -0x1, -0x2, -0x1, -0x2, 0x1, -0x1, 0x1,
// });
// try testArgs(@Vector(16, i2), .{
// 0x0, -0x2, -0x1, -0x2, 0x1, 0x0, -0x1, 0x0, 0x1, -0x2, 0x1, -0x1, -0x2, -0x2, 0x1, 0x0,
// }, .{
// -0x2, -0x2, 0x1, -0x2, -0x1, -0x2, -0x1, -0x2, -0x2, -0x2, -0x1, -0x2, 0x1, -0x2, -0x2, -0x2,
// });
// try testArgs(@Vector(32, i2), .{
// -0x2, 0x1, -0x1, 0x1, 0x0, -0x2, 0x1, -0x2, -0x2, 0x0, -0x1, 0x0, -0x2, -0x2, 0x0, 0x1,
// -0x1, 0x1, -0x1, 0x1, 0x1, 0x1, 0x1, -0x2, -0x1, -0x1, 0x1, -0x2, 0x0, -0x1, 0x0, -0x2,
// }, .{
// 0x1, -0x1, 0x1, -0x1, 0x1, 0x1, 0x1, -0x2, 0x1, -0x2, -0x1, -0x2, 0x1, 0x1, 0x1, -0x1,
// -0x2, 0x1, 0x1, -0x1, -0x2, -0x2, -0x1, -0x2, -0x1, -0x2, 0x1, -0x2, -0x1, 0x1, -0x2, -0x2,
// });
// try testArgs(@Vector(64, i2), .{
// 0x1, -0x2, -0x1, 0x0, 0x1, -0x2, -0x1, -0x2, -0x2, -0x1, -0x2, -0x1, 0x1, 0x1, 0x0, 0x1,
// -0x1, -0x1, -0x1, 0x1, 0x1, -0x1, 0x0, 0x1, -0x1, 0x0, 0x0, 0x1, 0x1, 0x0, -0x2, -0x2,
// 0x1, 0x0, -0x2, -0x2, 0x1, -0x2, -0x2, 0x1, 0x1, -0x2, 0x1, 0x0, 0x0, -0x1, 0x0, 0x1,
// -0x2, 0x0, 0x0, -0x1, -0x1, 0x1, -0x2, 0x0, -0x2, 0x0, -0x2, 0x1, 0x0, -0x1, -0x1, 0x1,
// }, .{
// -0x2, -0x2, 0x1, -0x1, -0x2, -0x2, -0x1, -0x2, 0x1, 0x1, 0x1, -0x1, 0x1, 0x1, 0x1, -0x1,
// -0x2, 0x1, 0x1, -0x2, -0x2, 0x1, 0x1, -0x1, -0x2, -0x2, 0x1, -0x1, -0x2, 0x1, -0x2, 0x1,
// 0x1, -0x2, -0x2, -0x2, -0x2, 0x1, 0x1, 0x1, -0x2, 0x1, -0x1, 0x1, -0x1, 0x1, 0x1, -0x1,
// -0x2, 0x1, -0x1, 0x1, -0x1, -0x1, 0x1, 0x1, -0x2, 0x1, 0x1, -0x2, -0x2, -0x1, -0x2, -0x2,
// });
// try testArgs(@Vector(128, i2), .{
// -0x1, -0x2, 0x0, -0x2, -0x2, 0x1, -0x1, 0x0, -0x1, -0x2, 0x0, -0x2, 0x0, 0x1, 0x0, -0x1,
// 0x0, -0x2, 0x1, 0x0, 0x1, 0x0, -0x2, 0x1, 0x1, 0x1, -0x1, 0x1, 0x0, -0x1, 0x1, -0x1,
// 0x1, -0x2, 0x1, -0x2, 0x1, -0x2, 0x1, -0x2, -0x2, -0x2, 0x0, 0x0, 0x1, 0x1, -0x2, -0x1,
// 0x1, 0x0, 0x0, 0x1, -0x2, -0x1, 0x0, -0x1, 0x1, -0x2, 0x1, 0x0, 0x1, 0x0, 0x0, -0x2,
// 0x0, 0x0, -0x1, 0x1, -0x1, 0x0, -0x1, -0x2, 0x1, -0x2, -0x2, -0x1, -0x2, 0x0, 0x0, 0x0,
// -0x1, -0x1, -0x1, -0x1, -0x2, 0x0, -0x1, 0x1, 0x0, 0x0, -0x2, 0x0, 0x0, 0x0, 0x0, 0x1,
// 0x1, -0x2, 0x0, 0x0, -0x1, -0x1, 0x1, -0x1, -0x2, 0x0, -0x1, -0x1, -0x2, -0x2, 0x0, 0x0,
// -0x1, 0x0, 0x1, 0x0, -0x1, -0x2, 0x1, -0x2, -0x1, -0x1, 0x0, 0x0, -0x1, 0x0, 0x0, 0x1,
// }, .{
// -0x2, -0x2, 0x1, 0x1, -0x2, -0x1, 0x1, 0x1, 0x1, -0x2, -0x2, 0x1, -0x2, -0x2, 0x1, -0x1,
// -0x1, -0x2, 0x1, -0x1, 0x1, 0x1, 0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, 0x1, 0x1, -0x2,
// -0x1, -0x2, -0x2, -0x2, -0x2, -0x2, -0x1, -0x2, 0x1, 0x1, -0x1, -0x1, -0x1, -0x1, 0x1, -0x2,
// 0x1, -0x1, 0x1, -0x1, 0x1, 0x1, -0x1, -0x2, 0x1, 0x1, -0x2, -0x2, -0x2, 0x1, 0x1, -0x2,
// -0x1, 0x1, -0x2, -0x1, -0x1, 0x1, -0x2, -0x2, 0x1, 0x1, -0x2, -0x1, -0x2, -0x2, -0x2, -0x2,
// 0x1, -0x1, 0x1, -0x2, 0x1, -0x1, -0x1, 0x1, 0x1, -0x1, 0x1, -0x1, -0x2, -0x2, -0x1, -0x2,
// -0x2, 0x1, -0x2, -0x2, -0x1, -0x1, -0x1, -0x2, 0x1, -0x2, 0x1, -0x2, 0x1, -0x2, -0x2, 0x1,
// 0x1, -0x1, 0x1, 0x1, -0x1, -0x2, 0x1, 0x1, -0x1, -0x2, -0x1, -0x1, 0x1, -0x2, -0x2, -0x2,
// });
try testArgs(@Vector(1, i2), .{
-0x1,
0x1,
}, .{
-0x2,
0x1,
});
try testArgs(@Vector(2, i2), .{
-0x1, -0x1,
0x0, -0x2,
}, .{
0x1, -0x1,
-0x2, -0x2,
});
try testArgs(@Vector(4, i2), .{
-0x1, 0x1, -0x1, -0x1,
-0x2, -0x1, 0x0, -0x2,
}, .{
0x1, -0x1, -0x1, 0x1,
-0x2, 0x1, -0x1, -0x2,
});
try testArgs(@Vector(8, i2), .{
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, -0x1, 0x1,
-0x1, 0x1, 0x1, -0x1, -0x2, -0x2, 0x0, -0x2,
}, .{
0x1, -0x1, -0x1, -0x2, -0x1, -0x2, -0x1, 0x1,
-0x1, -0x1, -0x2, -0x1, -0x2, 0x1, -0x1, 0x1,
});
try testArgs(@Vector(16, i2), .{
0x1, 0x0, 0x0, -0x1, 0x1, 0x0, 0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, 0x1, 0x1, 0x0,
0x0, -0x2, -0x1, -0x2, 0x1, 0x0, -0x1, 0x0, 0x1, -0x2, 0x1, -0x1, -0x2, -0x2, 0x1, 0x0,
}, .{
0x1, 0x1, 0x1, 0x1, -0x2, -0x2, -0x1, -0x1, -0x1, -0x2, 0x1, 0x1, -0x1, -0x2, -0x1, -0x1,
-0x2, -0x2, 0x1, -0x2, -0x1, -0x2, -0x1, -0x2, -0x2, -0x2, -0x1, -0x2, 0x1, -0x2, -0x2, -0x2,
});
try testArgs(@Vector(32, i2), .{
0x0, 0x1, -0x1, -0x1, -0x1, 0x0, -0x1, 0x0, -0x1, -0x1, 0x1, -0x1, 0x0, -0x1, 0x0, -0x1,
-0x1, 0x1, 0x1, 0x1, -0x1, -0x1, 0x1, -0x1, -0x1, 0x1, -0x1, -0x1, 0x1, 0x0, 0x0, 0x1,
-0x2, 0x1, -0x1, 0x1, 0x0, -0x2, 0x1, -0x2, -0x2, 0x0, -0x1, 0x0, -0x2, -0x2, 0x0, 0x1,
-0x1, 0x1, -0x1, 0x1, 0x1, 0x1, 0x1, -0x2, -0x1, -0x1, 0x1, -0x2, 0x0, -0x1, 0x0, -0x2,
}, .{
-0x2, -0x1, -0x2, 0x1, -0x1, 0x1, -0x2, -0x2, -0x1, -0x1, -0x1, -0x1, 0x1, 0x1, 0x1, -0x2,
-0x1, -0x1, -0x2, -0x2, -0x1, -0x2, -0x1, 0x1, -0x2, -0x1, -0x1, -0x2, 0x1, -0x2, -0x2, -0x1,
0x1, -0x1, 0x1, -0x1, 0x1, 0x1, 0x1, -0x2, 0x1, -0x2, -0x1, -0x2, 0x1, 0x1, 0x1, -0x1,
-0x2, 0x1, 0x1, -0x1, -0x2, -0x2, -0x1, -0x2, -0x1, -0x2, 0x1, -0x2, -0x1, 0x1, -0x2, -0x2,
});
try testArgs(@Vector(64, i2), .{
0x1, 0x1, -0x1, 0x0, 0x0, 0x1, 0x1, -0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0,
-0x1, 0x0, 0x0, 0x0, 0x0, -0x1, 0x0, 0x1, 0x1, 0x0, 0x1, -0x1, -0x1, 0x0, -0x1, 0x0,
-0x1, 0x1, -0x1, 0x0, -0x1, 0x1, 0x0, 0x0, 0x0, 0x1, -0x1, 0x0, -0x1, 0x1, 0x0, 0x0,
0x1, -0x1, -0x1, 0x0, 0x1, -0x1, -0x1, 0x0, 0x1, 0x1, -0x1, 0x0, 0x1, -0x1, 0x0, 0x0,
0x1, -0x2, -0x1, 0x0, 0x1, -0x2, -0x1, -0x2, -0x2, -0x1, -0x2, -0x1, 0x1, 0x1, 0x0, 0x1,
-0x1, -0x1, -0x1, 0x1, 0x1, -0x1, 0x0, 0x1, -0x1, 0x0, 0x0, 0x1, 0x1, 0x0, -0x2, -0x2,
0x1, 0x0, -0x2, -0x2, 0x1, -0x2, -0x2, 0x1, 0x1, -0x2, 0x1, 0x0, 0x0, -0x1, 0x0, 0x1,
-0x2, 0x0, 0x0, -0x1, -0x1, 0x1, -0x2, 0x0, -0x2, 0x0, -0x2, 0x1, 0x0, -0x1, -0x1, 0x1,
}, .{
-0x1, 0x1, -0x2, -0x1, -0x1, 0x1, 0x1, -0x2, -0x2, 0x1, 0x1, -0x1, -0x2, 0x1, 0x1, -0x1,
-0x1, -0x1, 0x1, -0x2, -0x2, -0x2, -0x1, -0x1, -0x2, 0x1, -0x2, -0x2, -0x2, 0x1, -0x2, -0x2,
-0x2, -0x1, -0x1, 0x1, -0x2, -0x1, -0x1, -0x1, -0x2, 0x1, -0x1, 0x1, -0x2, -0x2, 0x1, -0x1,
-0x1, 0x1, -0x2, -0x2, -0x2, -0x2, -0x2, -0x2, -0x2, 0x1, 0x1, -0x1, 0x1, 0x1, -0x1, -0x2,
-0x2, -0x2, 0x1, -0x1, -0x2, -0x2, -0x1, -0x2, 0x1, 0x1, 0x1, -0x1, 0x1, 0x1, 0x1, -0x1,
-0x2, 0x1, 0x1, -0x2, -0x2, 0x1, 0x1, -0x1, -0x2, -0x2, 0x1, -0x1, -0x2, 0x1, -0x2, 0x1,
0x1, -0x2, -0x2, -0x2, -0x2, 0x1, 0x1, 0x1, -0x2, 0x1, -0x1, 0x1, -0x1, 0x1, 0x1, -0x1,
-0x2, 0x1, -0x1, 0x1, -0x1, -0x1, 0x1, 0x1, -0x2, 0x1, 0x1, -0x2, -0x2, -0x1, -0x2, -0x2,
});
try testArgs(@Vector(128, i2), .{
0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, 0x0, 0x1, 0x0, -0x1, 0x0, -0x1, 0x0, 0x0, 0x0,
0x0, 0x0, 0x1, -0x1, 0x1, -0x1, -0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, -0x1, 0x0, -0x1,
0x0, 0x1, -0x1, 0x1, -0x1, -0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, -0x1, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x1, -0x1, 0x1, 0x1, -0x1, 0x1, -0x1, 0x0, 0x1, 0x0, 0x1,
0x0, -0x1, 0x0, 0x0, 0x1, -0x1, 0x0, 0x0, -0x1, -0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1,
0x0, -0x1, 0x1, -0x1, -0x1, 0x0, 0x0, 0x1, -0x1, -0x1, 0x1, 0x0, -0x1, 0x1, 0x0, -0x1,
0x1, 0x0, 0x1, -0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, -0x1, -0x1, 0x0, 0x1, 0x0,
0x0, 0x0, 0x1, 0x0, 0x0, 0x1, -0x1, 0x0, -0x1, -0x1, 0x0, 0x0, 0x0, 0x1, 0x1, -0x1,
-0x1, -0x2, 0x0, -0x2, -0x2, 0x1, -0x1, 0x0, -0x1, -0x2, 0x0, -0x2, 0x0, 0x1, 0x0, -0x1,
0x0, -0x2, 0x1, 0x0, 0x1, 0x0, -0x2, 0x1, 0x1, 0x1, -0x1, 0x1, 0x0, -0x1, 0x1, -0x1,
0x1, -0x2, 0x1, -0x2, 0x1, -0x2, 0x1, -0x2, -0x2, -0x2, 0x0, 0x0, 0x1, 0x1, -0x2, -0x1,
0x1, 0x0, 0x0, 0x1, -0x2, -0x1, 0x0, -0x1, 0x1, -0x2, 0x1, 0x0, 0x1, 0x0, 0x0, -0x2,
0x0, 0x0, -0x1, 0x1, -0x1, 0x0, -0x1, -0x2, 0x1, -0x2, -0x2, -0x1, -0x2, 0x0, 0x0, 0x0,
-0x1, -0x1, -0x1, -0x1, -0x2, 0x0, -0x1, 0x1, 0x0, 0x0, -0x2, 0x0, 0x0, 0x0, 0x0, 0x1,
0x1, -0x2, 0x0, 0x0, -0x1, -0x1, 0x1, -0x1, -0x2, 0x0, -0x1, -0x1, -0x2, -0x2, 0x0, 0x0,
-0x1, 0x0, 0x1, 0x0, -0x1, -0x2, 0x1, -0x2, -0x1, -0x1, 0x0, 0x0, -0x1, 0x0, 0x0, 0x1,
}, .{
-0x2, -0x2, -0x1, -0x2, -0x1, -0x1, -0x2, -0x2, -0x2, 0x1, -0x2, -0x2, -0x2, -0x2, -0x2, 0x1,
-0x1, 0x1, -0x1, -0x1, -0x2, -0x2, -0x1, -0x2, 0x1, -0x2, -0x1, -0x2, -0x2, -0x1, 0x1, -0x1,
-0x2, -0x1, -0x1, -0x2, -0x1, -0x2, -0x1, 0x1, -0x1, -0x1, 0x1, -0x1, -0x2, 0x1, -0x2, -0x1,
-0x2, 0x1, -0x1, -0x2, -0x2, -0x2, -0x2, -0x1, 0x1, 0x1, 0x1, 0x1, -0x1, -0x2, -0x1, -0x1,
-0x2, -0x2, 0x1, 0x1, -0x2, -0x1, 0x1, -0x2, -0x1, -0x2, -0x1, -0x2, -0x2, 0x1, -0x1, 0x1,
-0x2, -0x2, 0x1, -0x2, -0x1, -0x1, 0x1, -0x1, -0x1, -0x1, -0x2, -0x2, -0x1, 0x1, 0x1, -0x2,
-0x1, -0x2, 0x1, 0x1, 0x1, 0x1, -0x2, 0x1, -0x1, -0x1, -0x2, 0x1, -0x1, -0x2, -0x1, -0x2,
-0x2, -0x2, -0x1, -0x1, -0x2, -0x1, 0x1, -0x1, 0x1, 0x1, 0x1, -0x2, -0x1, 0x1, -0x2, 0x1,
-0x2, -0x2, 0x1, 0x1, -0x2, -0x1, 0x1, 0x1, 0x1, -0x2, -0x2, 0x1, -0x2, -0x2, 0x1, -0x1,
-0x1, -0x2, 0x1, -0x1, 0x1, 0x1, 0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, 0x1, 0x1, -0x2,
-0x1, -0x2, -0x2, -0x2, -0x2, -0x2, -0x1, -0x2, 0x1, 0x1, -0x1, -0x1, -0x1, -0x1, 0x1, -0x2,
0x1, -0x1, 0x1, -0x1, 0x1, 0x1, -0x1, -0x2, 0x1, 0x1, -0x2, -0x2, -0x2, 0x1, 0x1, -0x2,
-0x1, 0x1, -0x2, -0x1, -0x1, 0x1, -0x2, -0x2, 0x1, 0x1, -0x2, -0x1, -0x2, -0x2, -0x2, -0x2,
0x1, -0x1, 0x1, -0x2, 0x1, -0x1, -0x1, 0x1, 0x1, -0x1, 0x1, -0x1, -0x2, -0x2, -0x1, -0x2,
-0x2, 0x1, -0x2, -0x2, -0x1, -0x1, -0x1, -0x2, 0x1, -0x2, 0x1, -0x2, 0x1, -0x2, -0x2, 0x1,
0x1, -0x1, 0x1, 0x1, -0x1, -0x2, 0x1, 0x1, -0x1, -0x2, -0x1, -0x1, 0x1, -0x2, -0x2, -0x2,
});
try testArgs(@Vector(1, u2), .{
@ -2131,130 +2130,67 @@ fn binary(comptime op: anytype, comptime opts: struct { compare: Compare = .rela
0x2, 0x2, 0x3, 0x3, 0x1, 0x1, 0x1, 0x1, 0x2, 0x1, 0x3, 0x1, 0x3, 0x2, 0x3, 0x1,
});
// workaround https://github.com/ziglang/zig/issues/22914
// TODO: try testArgs(@Vector(1, i3), .{
// -0x3,
// }, .{
// -0x1,
// });
// try testArgs(@Vector(2, i3), .{
// 0x2, -0x3,
// }, .{
// 0x1, 0x3,
// });
// try testArgs(@Vector(4, i3), .{
// 0x1, -0x4, -0x2, -0x3,
// }, .{
// -0x2, -0x4, 0x2, 0x2,
// });
// try testArgs(@Vector(8, i3), .{
// 0x0, 0x1, 0x3, 0x1, -0x3, 0x1, 0x3, 0x3,
// }, .{
// -0x3, 0x2, 0x1, 0x1, -0x4, -0x1, 0x3, -0x2,
// });
// try testArgs(@Vector(16, i3), .{
// -0x4, 0x3, -0x2, 0x0, -0x2, -0x1, 0x2, -0x4, 0x1, -0x3, 0x2, -0x2, 0x1, -0x2, 0x2, -0x4,
// }, .{
// 0x2, -0x3, 0x3, 0x1, -0x4, 0x1, -0x1, 0x1, -0x1, -0x3, -0x4, 0x2, 0x3, 0x3, -0x1, -0x4,
// });
// try testArgs(@Vector(32, i3), .{
// 0x1, -0x3, -0x1, -0x3, -0x3, 0x2, 0x1, 0x0, 0x0, -0x1, 0x3, -0x2, 0x3, 0x0, -0x3, 0x0,
// -0x4, -0x2, -0x1, -0x4, -0x4, 0x2, 0x2, 0x3, 0x1, 0x2, -0x4, -0x4, -0x3, 0x1, -0x1, -0x2,
// }, .{
// -0x4, -0x2, 0x1, -0x1, 0x3, 0x1, 0x2, -0x3, 0x2, -0x2, 0x1, -0x1, -0x2, -0x1, -0x1, -0x2,
// -0x2, -0x3, 0x3, -0x3, -0x4, 0x1, -0x3, 0x3, 0x1, -0x3, 0x3, 0x3, -0x4, 0x3, 0x2, -0x2,
// });
// try testArgs(@Vector(64, i3), .{
// 0x1, 0x2, 0x1, 0x2, -0x2, 0x2, 0x2, -0x1, -0x4, 0x1, 0x3, 0x0, -0x2, -0x2, 0x2, -0x2,
// 0x0, -0x4, -0x3, -0x4, -0x1, -0x1, 0x2, 0x2, -0x2, -0x1, -0x1, 0x3, 0x3, -0x4, 0x2, 0x0,
// 0x3, 0x2, -0x4, -0x1, 0x1, 0x1, 0x3, 0x1, 0x2, 0x3, -0x3, 0x1, -0x4, -0x2, 0x1, -0x3,
// -0x3, -0x1, 0x1, -0x3, -0x1, 0x3, -0x4, -0x4, 0x0, 0x0, -0x4, -0x2, 0x3, -0x1, -0x3, -0x3,
// }, .{
// 0x3, -0x2, 0x1, -0x4, 0x1, 0x3, -0x3, 0x1, 0x3, 0x1, 0x1, -0x1, -0x2, 0x1, -0x3, 0x1,
// -0x2, -0x2, 0x3, -0x3, -0x1, -0x3, 0x1, -0x1, -0x3, -0x3, 0x1, -0x2, 0x1, -0x2, 0x1, 0x2,
// 0x3, -0x4, -0x4, -0x1, 0x1, 0x3, 0x1, 0x1, -0x4, 0x2, -0x3, 0x3, 0x3, -0x1, 0x1, -0x1,
// -0x2, 0x2, 0x2, -0x4, -0x4, 0x3, -0x2, -0x4, -0x1, -0x2, -0x4, 0x1, 0x2, 0x1, -0x1, -0x2,
// });
// try testArgs(@Vector(128, i3), .{
// -0x4, 0x1, 0x0, -0x4, -0x4, 0x1, -0x4, -0x2, 0x2, 0x2, -0x3, 0x1, 0x2, -0x2, 0x1, 0x1,
// 0x3, 0x0, 0x3, -0x4, -0x1, 0x3, 0x3, -0x4, 0x0, -0x3, 0x2, -0x2, 0x0, 0x3, 0x1, -0x2,
// -0x1, -0x1, 0x3, -0x1, -0x2, 0x3, 0x3, 0x1, -0x3, 0x1, -0x1, -0x2, -0x4, 0x2, -0x2, -0x1,
// 0x1, 0x1, 0x1, 0x0, -0x1, 0x2, -0x1, 0x3, 0x2, -0x1, -0x2, 0x3, -0x2, 0x3, 0x3, 0x1,
// 0x3, -0x3, -0x4, -0x1, 0x2, 0x2, -0x2, 0x3, -0x4, -0x2, -0x1, 0x0, 0x1, -0x1, 0x0, 0x0,
// -0x2, 0x3, 0x0, -0x3, -0x4, 0x2, -0x3, -0x2, -0x4, 0x0, -0x3, -0x4, -0x4, -0x2, -0x1, -0x3,
// 0x0, -0x1, 0x0, -0x1, 0x2, -0x4, -0x3, 0x0, -0x4, 0x0, -0x2, 0x1, -0x2, -0x4, -0x1, -0x1,
// -0x3, 0x3, -0x1, -0x1, -0x2, 0x1, 0x3, 0x1, -0x3, 0x1, -0x4, -0x2, 0x0, -0x1, -0x2, 0x2,
// }, .{
// -0x3, 0x2, -0x3, 0x1, -0x2, -0x1, -0x3, 0x1, 0x2, 0x2, -0x2, 0x2, 0x2, 0x1, 0x3, -0x1,
// -0x4, -0x3, 0x2, -0x3, -0x2, 0x3, -0x3, 0x2, -0x1, -0x3, 0x1, 0x2, -0x4, 0x2, -0x2, -0x3,
// 0x1, -0x1, 0x2, 0x2, -0x1, -0x3, -0x4, 0x2, 0x1, -0x4, 0x1, -0x4, 0x2, -0x1, 0x2, -0x2,
// 0x2, 0x1, -0x4, 0x3, 0x1, -0x2, -0x3, -0x4, 0x3, -0x1, 0x3, -0x4, -0x2, 0x1, -0x2, 0x3,
// 0x1, 0x1, 0x2, 0x1, -0x1, -0x2, 0x2, -0x1, 0x1, -0x1, -0x3, -0x1, 0x1, -0x4, -0x1, -0x1,
// -0x3, -0x1, -0x4, 0x3, 0x1, -0x1, -0x1, -0x1, 0x1, -0x4, 0x1, -0x2, -0x4, 0x2, -0x4, -0x3,
// 0x2, -0x4, -0x1, 0x1, 0x3, 0x2, -0x1, 0x3, 0x2, 0x2, 0x1, -0x4, -0x3, 0x1, -0x1, 0x1,
// -0x2, -0x4, 0x1, 0x3, -0x1, 0x3, 0x1, 0x2, -0x4, 0x2, 0x2, -0x3, -0x3, -0x4, -0x2, 0x3,
// });
try testArgs(@Vector(1, i3), .{
-0x1,
}, .{
-0x3,
}, .{
-0x1,
});
try testArgs(@Vector(2, i3), .{
0x2, -0x2,
0x2, -0x3,
}, .{
0x3, 0x3,
0x1, 0x3,
});
try testArgs(@Vector(4, i3), .{
0x1, 0x0, -0x2, 0x0,
0x1, -0x4, -0x2, -0x3,
}, .{
0x2, -0x2, -0x4, 0x3,
-0x2, -0x4, 0x2, 0x2,
});
try testArgs(@Vector(8, i3), .{
0x3, -0x1, -0x3, -0x3, -0x3, -0x2, 0x2, -0x3,
0x0, 0x1, 0x3, 0x1, -0x3, 0x1, 0x3, 0x3,
}, .{
-0x1, 0x1, -0x2, 0x2, 0x1, -0x2, -0x3, -0x1,
-0x3, 0x2, 0x1, 0x1, -0x4, -0x1, 0x3, -0x2,
});
try testArgs(@Vector(16, i3), .{
-0x1, -0x1, 0x3, -0x2, -0x2, -0x2, -0x2, -0x1, 0x2, 0x1, -0x2, 0x2, -0x2, 0x1, 0x1, -0x3,
-0x4, 0x3, -0x2, 0x0, -0x2, -0x1, 0x2, -0x4, 0x1, -0x3, 0x2, -0x2, 0x1, -0x2, 0x2, -0x4,
}, .{
0x1, -0x1, -0x1, -0x1, 0x1, 0x3, -0x1, -0x1, 0x1, 0x3, -0x1, -0x3, 0x1, 0x3, 0x1, -0x2,
0x2, -0x3, 0x3, 0x1, -0x4, 0x1, -0x1, 0x1, -0x1, -0x3, -0x4, 0x2, 0x3, 0x3, -0x1, -0x4,
});
try testArgs(@Vector(32, i3), .{
0x3, -0x1, -0x3, 0x1, 0x0, 0x0, -0x3, -0x1, -0x3, 0x1, 0x1, 0x2, -0x1, 0x1, -0x1, -0x1,
0x1, -0x3, 0x1, -0x1, 0x1, 0x0, -0x2, 0x3, -0x2, -0x3, 0x3, 0x1, -0x1, 0x0, 0x3, -0x1,
0x1, -0x3, -0x1, -0x3, -0x3, 0x2, 0x1, 0x0, 0x0, -0x1, 0x3, -0x2, 0x3, 0x0, -0x3, 0x0,
-0x4, -0x2, -0x1, -0x4, -0x4, 0x2, 0x2, 0x3, 0x1, 0x2, -0x4, -0x4, -0x3, 0x1, -0x1, -0x2,
}, .{
0x1, -0x2, -0x4, -0x4, 0x2, 0x1, -0x4, -0x3, -0x4, 0x1, -0x3, -0x4, -0x1, 0x2, -0x1, 0x1,
0x2, -0x2, -0x4, 0x3, -0x3, 0x1, 0x2, -0x2, -0x2, 0x3, 0x3, 0x2, -0x2, -0x4, -0x2, -0x3,
-0x4, -0x2, 0x1, -0x1, 0x3, 0x1, 0x2, -0x3, 0x2, -0x2, 0x1, -0x1, -0x2, -0x1, -0x1, -0x2,
-0x2, -0x3, 0x3, -0x3, -0x4, 0x1, -0x3, 0x3, 0x1, -0x3, 0x3, 0x3, -0x4, 0x3, 0x2, -0x2,
});
try testArgs(@Vector(64, i3), .{
-0x2, 0x1, 0x3, -0x1, -0x3, -0x1, 0x1, -0x3, 0x1, -0x2, 0x0, 0x3, 0x0, -0x2, 0x1, -0x3,
-0x2, 0x1, -0x2, 0x2, 0x0, 0x1, -0x3, 0x0, -0x3, 0x0, -0x3, -0x2, -0x2, -0x3, -0x2, 0x3,
-0x1, 0x1, 0x1, 0x1, -0x1, 0x0, -0x3, -0x3, -0x3, -0x3, -0x2, 0x2, 0x3, 0x2, -0x3, 0x1,
-0x3, -0x3, -0x1, -0x1, -0x1, -0x3, -0x2, -0x2, 0x2, 0x3, 0x3, -0x3, 0x0, 0x3, -0x3, -0x3,
0x1, 0x2, 0x1, 0x2, -0x2, 0x2, 0x2, -0x1, -0x4, 0x1, 0x3, 0x0, -0x2, -0x2, 0x2, -0x2,
0x0, -0x4, -0x3, -0x4, -0x1, -0x1, 0x2, 0x2, -0x2, -0x1, -0x1, 0x3, 0x3, -0x4, 0x2, 0x0,
0x3, 0x2, -0x4, -0x1, 0x1, 0x1, 0x3, 0x1, 0x2, 0x3, -0x3, 0x1, -0x4, -0x2, 0x1, -0x3,
-0x3, -0x1, 0x1, -0x3, -0x1, 0x3, -0x4, -0x4, 0x0, 0x0, -0x4, -0x2, 0x3, -0x1, -0x3, -0x3,
}, .{
0x2, 0x1, -0x1, -0x3, -0x1, -0x4, -0x2, -0x3, 0x2, -0x2, -0x4, 0x2, 0x2, -0x2, 0x1, 0x1,
0x1, -0x1, -0x3, 0x2, -0x2, 0x2, -0x1, 0x3, 0x3, -0x1, -0x1, -0x3, -0x1, 0x2, -0x2, 0x2,
0x1, -0x4, -0x2, -0x4, 0x2, -0x1, -0x2, 0x3, 0x3, 0x3, -0x4, -0x2, 0x3, -0x4, 0x1, -0x2,
-0x2, 0x2, -0x3, -0x3, 0x1, -0x3, 0x3, 0x2, 0x1, 0x3, -0x3, 0x3, 0x2, -0x2, -0x2, 0x2,
0x3, -0x2, 0x1, -0x4, 0x1, 0x3, -0x3, 0x1, 0x3, 0x1, 0x1, -0x1, -0x2, 0x1, -0x3, 0x1,
-0x2, -0x2, 0x3, -0x3, -0x1, -0x3, 0x1, -0x1, -0x3, -0x3, 0x1, -0x2, 0x1, -0x2, 0x1, 0x2,
0x3, -0x4, -0x4, -0x1, 0x1, 0x3, 0x1, 0x1, -0x4, 0x2, -0x3, 0x3, 0x3, -0x1, 0x1, -0x1,
-0x2, 0x2, 0x2, -0x4, -0x4, 0x3, -0x2, -0x4, -0x1, -0x2, -0x4, 0x1, 0x2, 0x1, -0x1, -0x2,
});
try testArgs(@Vector(128, i3), .{
-0x1, 0x2, 0x1, 0x2, 0x1, 0x1, 0x2, 0x1, -0x3, 0x1, -0x2, -0x1, 0x0, 0x2, 0x3, -0x3,
-0x1, -0x1, -0x2, 0x3, 0x1, 0x2, 0x2, 0x3, -0x2, 0x3, -0x2, -0x3, 0x1, 0x0, -0x1, -0x2,
-0x1, -0x1, 0x1, -0x1, 0x2, -0x3, 0x1, -0x2, -0x1, 0x2, -0x2, 0x1, 0x1, -0x3, -0x2, 0x3,
-0x1, -0x1, 0x1, -0x3, -0x1, -0x2, 0x0, 0x1, -0x1, 0x0, -0x1, 0x2, 0x1, 0x2, 0x3, -0x1,
0x0, 0x1, 0x2, 0x3, -0x2, 0x2, -0x3, 0x2, 0x0, -0x2, -0x3, -0x2, 0x0, 0x1, 0x2, 0x1,
-0x3, 0x0, -0x2, -0x3, -0x1, 0x2, -0x3, 0x2, 0x3, 0x1, 0x1, -0x1, 0x2, 0x1, -0x1, 0x2,
0x2, 0x0, 0x1, -0x3, -0x3, 0x1, 0x2, 0x0, 0x1, 0x0, 0x0, -0x1, 0x0, 0x0, 0x3, 0x3,
0x0, -0x2, -0x2, -0x2, 0x3, 0x0, -0x1, -0x2, 0x0, 0x3, -0x3, 0x1, 0x2, -0x1, 0x1, 0x1,
-0x4, 0x1, 0x0, -0x4, -0x4, 0x1, -0x4, -0x2, 0x2, 0x2, -0x3, 0x1, 0x2, -0x2, 0x1, 0x1,
0x3, 0x0, 0x3, -0x4, -0x1, 0x3, 0x3, -0x4, 0x0, -0x3, 0x2, -0x2, 0x0, 0x3, 0x1, -0x2,
-0x1, -0x1, 0x3, -0x1, -0x2, 0x3, 0x3, 0x1, -0x3, 0x1, -0x1, -0x2, -0x4, 0x2, -0x2, -0x1,
0x1, 0x1, 0x1, 0x0, -0x1, 0x2, -0x1, 0x3, 0x2, -0x1, -0x2, 0x3, -0x2, 0x3, 0x3, 0x1,
0x3, -0x3, -0x4, -0x1, 0x2, 0x2, -0x2, 0x3, -0x4, -0x2, -0x1, 0x0, 0x1, -0x1, 0x0, 0x0,
-0x2, 0x3, 0x0, -0x3, -0x4, 0x2, -0x3, -0x2, -0x4, 0x0, -0x3, -0x4, -0x4, -0x2, -0x1, -0x3,
0x0, -0x1, 0x0, -0x1, 0x2, -0x4, -0x3, 0x0, -0x4, 0x0, -0x2, 0x1, -0x2, -0x4, -0x1, -0x1,
-0x3, 0x3, -0x1, -0x1, -0x2, 0x1, 0x3, 0x1, -0x3, 0x1, -0x4, -0x2, 0x0, -0x1, -0x2, 0x2,
}, .{
0x3, 0x3, 0x2, 0x3, -0x3, -0x4, 0x1, -0x3, 0x2, 0x3, 0x3, -0x2, 0x2, -0x1, 0x1, 0x3,
-0x4, -0x4, -0x1, -0x1, 0x2, -0x3, -0x3, -0x3, -0x2, -0x3, -0x2, -0x1, 0x1, 0x3, -0x4, -0x2,
-0x3, 0x1, 0x3, 0x1, -0x2, 0x1, 0x1, 0x2, 0x1, 0x2, -0x4, -0x4, -0x3, -0x2, -0x1, -0x2,
0x3, 0x2, -0x3, -0x2, -0x2, 0x3, -0x3, -0x4, 0x3, -0x3, 0x3, -0x1, 0x3, -0x1, -0x1, 0x2,
0x3, -0x4, -0x4, -0x2, -0x4, 0x2, -0x2, -0x4, -0x2, -0x2, -0x3, 0x3, 0x2, 0x2, 0x2, -0x4,
0x1, -0x4, -0x3, -0x2, -0x4, -0x4, 0x1, -0x4, -0x1, 0x3, -0x2, -0x4, 0x3, -0x4, 0x3, -0x1,
0x3, 0x1, -0x1, 0x1, 0x1, 0x2, 0x1, -0x3, -0x4, -0x1, -0x1, -0x2, -0x3, -0x2, 0x3, -0x2,
-0x1, 0x3, 0x3, -0x1, 0x3, 0x1, 0x1, 0x2, -0x3, 0x3, -0x1, 0x3, -0x3, -0x4, -0x4, 0x1,
-0x3, 0x2, -0x3, 0x1, -0x2, -0x1, -0x3, 0x1, 0x2, 0x2, -0x2, 0x2, 0x2, 0x1, 0x3, -0x1,
-0x4, -0x3, 0x2, -0x3, -0x2, 0x3, -0x3, 0x2, -0x1, -0x3, 0x1, 0x2, -0x4, 0x2, -0x2, -0x3,
0x1, -0x1, 0x2, 0x2, -0x1, -0x3, -0x4, 0x2, 0x1, -0x4, 0x1, -0x4, 0x2, -0x1, 0x2, -0x2,
0x2, 0x1, -0x4, 0x3, 0x1, -0x2, -0x3, -0x4, 0x3, -0x1, 0x3, -0x4, -0x2, 0x1, -0x2, 0x3,
0x1, 0x1, 0x2, 0x1, -0x1, -0x2, 0x2, -0x1, 0x1, -0x1, -0x3, -0x1, 0x1, -0x4, -0x1, -0x1,
-0x3, -0x1, -0x4, 0x3, 0x1, -0x1, -0x1, -0x1, 0x1, -0x4, 0x1, -0x2, -0x4, 0x2, -0x4, -0x3,
0x2, -0x4, -0x1, 0x1, 0x3, 0x2, -0x1, 0x3, 0x2, 0x2, 0x1, -0x4, -0x3, 0x1, -0x1, 0x1,
-0x2, -0x4, 0x1, 0x3, -0x1, 0x3, 0x1, 0x2, -0x4, 0x2, 0x2, -0x3, -0x3, -0x4, -0x2, 0x3,
});
try testArgs(@Vector(1, u3), .{
@ -2320,130 +2256,67 @@ fn binary(comptime op: anytype, comptime opts: struct { compare: Compare = .rela
0x1, 0x1, 0x2, 0x7, 0x2, 0x5, 0x1, 0x6, 0x4, 0x6, 0x1, 0x6, 0x5, 0x1, 0x2, 0x1,
});
// workaround https://github.com/ziglang/zig/issues/22914
// TODO: try testArgs(@Vector(1, i4), .{
// 0x2,
// }, .{
// 0x1,
// });
// try testArgs(@Vector(2, i4), .{
// -0x2, 0x5,
// }, .{
// -0x1, 0x2,
// });
// try testArgs(@Vector(4, i4), .{
// -0x8, 0x5, 0x5, -0x2,
// }, .{
// -0x3, -0x7, -0x4, -0x5,
// });
// try testArgs(@Vector(8, i4), .{
// 0x7, 0x3, 0x2, -0x1, -0x8, -0x2, 0x7, 0x1,
// }, .{
// -0x2, 0x4, -0x8, 0x7, 0x1, -0x5, 0x6, -0x7,
// });
// try testArgs(@Vector(16, i4), .{
// 0x6, -0x3, 0x6, 0x6, -0x5, 0x6, 0x3, 0x7, -0x6, 0x7, -0x7, 0x6, -0x2, -0x2, -0x5, 0x0,
// }, .{
// 0x2, -0x3, -0x4, -0x5, 0x3, 0x3, -0x5, 0x5, 0x4, -0x1, -0x6, 0x4, 0x7, -0x2, 0x3, 0x2,
// });
// try testArgs(@Vector(32, i4), .{
// -0x1, -0x4, 0x6, 0x6, 0x5, 0x3, 0x4, 0x0, 0x3, 0x7, -0x6, 0x7, -0x2, -0x7, -0x4, 0x6,
// 0x3, -0x7, -0x5, 0x1, -0x7, -0x6, 0x1, 0x3, 0x7, -0x8, -0x5, 0x6, -0x5, 0x0, 0x0, -0x8,
// }, .{
// -0x4, -0x4, -0x4, 0x4, -0x5, 0x3, -0x1, 0x6, 0x1, -0x3, -0x1, 0x6, 0x5, -0x8, 0x1, -0x4,
// -0x1, -0x4, 0x1, -0x3, 0x4, 0x6, -0x3, -0x8, -0x7, -0x4, 0x2, -0x3, -0x1, -0x2, 0x6, -0x6,
// });
// try testArgs(@Vector(64, i4), .{
// 0x0, -0x3, -0x3, 0x5, 0x2, -0x1, 0x4, 0x5, 0x6, -0x2, 0x1, 0x5, -0x3, -0x1, -0x2, -0x1,
// -0x8, 0x2, -0x1, -0x2, 0x7, -0x3, -0x2, -0x3, 0x1, -0x5, 0x5, 0x2, -0x1, -0x6, -0x2, -0x1,
// -0x2, -0x5, 0x0, 0x6, 0x3, -0x4, -0x5, -0x5, -0x4, -0x7, -0x4, 0x1, 0x0, -0x6, -0x7, -0x6,
// 0x1, -0x6, 0x4, -0x4, -0x2, 0x6, -0x7, 0x4, 0x4, 0x5, 0x3, -0x6, -0x8, -0x5, 0x5, -0x7,
// }, .{
// -0x1, -0x5, 0x5, -0x2, 0x6, -0x6, -0x4, -0x5, -0x4, 0x7, -0x6, 0x7, 0x4, -0x5, 0x5, 0x7,
// -0x6, 0x3, -0x4, 0x2, -0x8, 0x4, -0x2, 0x5, -0x5, -0x5, -0x8, 0x3, -0x1, -0x4, -0x8, -0x2,
// -0x2, 0x5, -0x7, -0x3, 0x2, -0x5, -0x6, -0x7, -0x8, -0x2, 0x5, -0x3, 0x2, -0x1, -0x7, -0x4,
// -0x3, -0x3, 0x6, -0x8, 0x3, -0x4, 0x7, 0x3, -0x2, 0x7, -0x1, 0x1, 0x1, 0x6, -0x2, -0x2,
// });
// try testArgs(@Vector(128, i4), .{
// -0x1, -0x3, -0x3, -0x4, 0x3, -0x4, 0x0, -0x4, 0x7, 0x3, 0x5, -0x4, -0x5, -0x4, -0x2, -0x7,
// 0x2, 0x0, -0x4, 0x7, 0x3, -0x5, 0x4, 0x5, -0x2, -0x3, -0x4, 0x6, -0x7, -0x1, 0x1, -0x6,
// 0x1, 0x5, 0x2, 0x5, 0x2, 0x2, -0x4, -0x4, 0x5, 0x2, -0x2, -0x8, -0x1, -0x2, 0x5, 0x3,
// 0x0, -0x5, 0x5, 0x7, 0x6, -0x3, -0x2, 0x0, -0x7, -0x7, -0x4, 0x2, -0x4, 0x7, 0x1, -0x5,
// -0x4, -0x8, 0x2, -0x7, 0x3, -0x4, 0x7, 0x6, -0x7, -0x3, -0x7, 0x2, 0x4, 0x2, -0x5, -0x6,
// 0x3, 0x5, 0x1, 0x6, 0x5, 0x7, 0x7, -0x4, -0x7, -0x1, 0x0, -0x7, 0x6, 0x0, 0x6, 0x0,
// 0x0, -0x5, -0x1, -0x8, 0x7, -0x6, -0x5, -0x2, -0x4, 0x1, 0x1, -0x8, 0x2, 0x6, -0x1, -0x3,
// -0x6, 0x5, -0x8, 0x3, 0x3, 0x1, -0x1, -0x3, -0x3, -0x6, 0x7, -0x6, -0x8, 0x1, -0x7, -0x8,
// }, .{
// 0x1, 0x3, 0x1, 0x3, -0x6, 0x6, 0x2, -0x3, 0x1, -0x7, 0x7, -0x3, -0x1, -0x1, 0x7, 0x2,
// -0x8, 0x2, -0x3, -0x4, 0x4, -0x4, 0x7, 0x6, -0x5, -0x2, -0x1, 0x6, -0x7, 0x4, 0x7, -0x3,
// -0x5, -0x8, -0x5, -0x6, -0x6, 0x2, 0x1, -0x8, 0x4, 0x3, -0x5, 0x7, -0x8, 0x3, -0x1, 0x7,
// -0x3, 0x7, -0x3, -0x2, -0x6, 0x4, 0x2, -0x2, -0x2, -0x7, 0x5, -0x1, -0x6, 0x7, -0x5, 0x5,
// 0x4, 0x5, -0x8, -0x5, 0x6, 0x1, -0x5, 0x7, -0x6, -0x3, -0x4, 0x6, -0x8, 0x7, 0x7, -0x6,
// 0x6, -0x4, 0x2, -0x8, -0x8, -0x4, -0x8, -0x3, 0x6, 0x5, 0x7, -0x6, 0x1, 0x2, -0x7, -0x3,
// -0x3, 0x1, -0x3, 0x3, -0x1, 0x3, -0x7, -0x8, 0x1, -0x3, -0x3, -0x3, -0x4, 0x5, 0x7, -0x7,
// 0x3, 0x2, 0x6, -0x2, -0x4, -0x3, -0x1, 0x5, -0x6, 0x2, 0x3, -0x5, 0x5, -0x3, -0x2, -0x8,
// });
try testArgs(@Vector(1, i4), .{
-0x1,
0x2,
}, .{
-0x1,
0x1,
});
try testArgs(@Vector(2, i4), .{
0x7, 0x5,
-0x2, 0x5,
}, .{
0x4, 0x1,
-0x1, 0x2,
});
try testArgs(@Vector(4, i4), .{
-0x2, -0x3, -0x6, 0x1,
-0x8, 0x5, 0x5, -0x2,
}, .{
0x3, -0x5, -0x1, -0x3,
-0x3, -0x7, -0x4, -0x5,
});
try testArgs(@Vector(8, i4), .{
-0x5, -0x3, -0x2, 0x2, -0x4, -0x4, 0x0, 0x1,
0x7, 0x3, 0x2, -0x1, -0x8, -0x2, 0x7, 0x1,
}, .{
-0x7, -0x2, -0x7, 0x1, 0x6, 0x2, -0x7, 0x7,
-0x2, 0x4, -0x8, 0x7, 0x1, -0x5, 0x6, -0x7,
});
try testArgs(@Vector(16, i4), .{
-0x1, -0x1, 0x6, 0x3, -0x1, 0x2, -0x6, 0x6, 0x1, 0x5, -0x1, 0x7, 0x7, -0x3, -0x1, 0x4,
0x6, -0x3, 0x6, 0x6, -0x5, 0x6, 0x3, 0x7, -0x6, 0x7, -0x7, 0x6, -0x2, -0x2, -0x5, 0x0,
}, .{
0x1, -0x3, 0x4, -0x1, 0x2, 0x5, -0x3, -0x5, -0x5, 0x5, -0x7, 0x7, 0x1, 0x5, -0x5, -0x6,
0x2, -0x3, -0x4, -0x5, 0x3, 0x3, -0x5, 0x5, 0x4, -0x1, -0x6, 0x4, 0x7, -0x2, 0x3, 0x2,
});
try testArgs(@Vector(32, i4), .{
-0x7, 0x4, -0x5, -0x5, -0x5, 0x1, 0x7, 0x3, -0x2, 0x7, -0x3, -0x7, -0x3, -0x2, -0x5, -0x7,
0x5, 0x4, 0x3, 0x0, -0x6, -0x2, -0x4, -0x1, 0x5, 0x4, -0x7, -0x7, -0x5, 0x5, -0x5, -0x1,
-0x1, -0x4, 0x6, 0x6, 0x5, 0x3, 0x4, 0x0, 0x3, 0x7, -0x6, 0x7, -0x2, -0x7, -0x4, 0x6,
0x3, -0x7, -0x5, 0x1, -0x7, -0x6, 0x1, 0x3, 0x7, -0x8, -0x5, 0x6, -0x5, 0x0, 0x0, -0x8,
}, .{
0x4, 0x4, 0x5, 0x2, 0x3, -0x4, 0x6, 0x2, -0x7, 0x3, 0x7, 0x2, 0x6, 0x2, 0x2, 0x3,
0x7, -0x3, -0x7, -0x2, 0x3, -0x1, -0x4, 0x4, -0x8, 0x1, 0x6, -0x7, 0x5, 0x1, 0x7, -0x2,
-0x4, -0x4, -0x4, 0x4, -0x5, 0x3, -0x1, 0x6, 0x1, -0x3, -0x1, 0x6, 0x5, -0x8, 0x1, -0x4,
-0x1, -0x4, 0x1, -0x3, 0x4, 0x6, -0x3, -0x8, -0x7, -0x4, 0x2, -0x3, -0x1, -0x2, 0x6, -0x6,
});
try testArgs(@Vector(64, i4), .{
0x0, 0x3, 0x7, -0x7, 0x1, -0x5, -0x4, 0x2, 0x2, 0x5, 0x4, 0x0, -0x3, -0x4, -0x4, -0x4,
-0x7, 0x6, 0x2, 0x1, 0x0, 0x3, -0x6, 0x4, -0x4, 0x2, 0x7, 0x3, -0x4, -0x3, -0x3, -0x3,
-0x4, 0x0, -0x3, -0x6, 0x0, 0x1, -0x5, -0x7, -0x2, -0x1, -0x1, -0x7, 0x3, -0x5, -0x4, -0x3,
0x5, 0x1, -0x4, 0x7, 0x1, 0x7, -0x5, 0x4, 0x5, -0x4, 0x1, -0x4, 0x4, 0x5, 0x4, -0x2,
0x0, -0x3, -0x3, 0x5, 0x2, -0x1, 0x4, 0x5, 0x6, -0x2, 0x1, 0x5, -0x3, -0x1, -0x2, -0x1,
-0x8, 0x2, -0x1, -0x2, 0x7, -0x3, -0x2, -0x3, 0x1, -0x5, 0x5, 0x2, -0x1, -0x6, -0x2, -0x1,
-0x2, -0x5, 0x0, 0x6, 0x3, -0x4, -0x5, -0x5, -0x4, -0x7, -0x4, 0x1, 0x0, -0x6, -0x7, -0x6,
0x1, -0x6, 0x4, -0x4, -0x2, 0x6, -0x7, 0x4, 0x4, 0x5, 0x3, -0x6, -0x8, -0x5, 0x5, -0x7,
}, .{
0x2, -0x4, -0x1, 0x4, 0x4, -0x1, -0x3, 0x6, 0x4, 0x2, 0x4, 0x3, -0x6, -0x7, -0x4, 0x6,
0x6, 0x4, 0x6, -0x7, 0x2, 0x4, -0x8, -0x1, -0x8, 0x3, -0x2, -0x7, 0x1, 0x5, -0x3, -0x6,
-0x8, 0x2, -0x5, 0x7, 0x4, 0x7, -0x4, 0x3, 0x6, -0x7, -0x1, 0x1, -0x8, -0x2, -0x3, 0x3,
0x3, -0x4, 0x4, -0x7, 0x5, -0x4, -0x1, 0x2, 0x6, -0x2, -0x5, 0x2, 0x7, 0x2, -0x8, -0x3,
-0x1, -0x5, 0x5, -0x2, 0x6, -0x6, -0x4, -0x5, -0x4, 0x7, -0x6, 0x7, 0x4, -0x5, 0x5, 0x7,
-0x6, 0x3, -0x4, 0x2, -0x8, 0x4, -0x2, 0x5, -0x5, -0x5, -0x8, 0x3, -0x1, -0x4, -0x8, -0x2,
-0x2, 0x5, -0x7, -0x3, 0x2, -0x5, -0x6, -0x7, -0x8, -0x2, 0x5, -0x3, 0x2, -0x1, -0x7, -0x4,
-0x3, -0x3, 0x6, -0x8, 0x3, -0x4, 0x7, 0x3, -0x2, 0x7, -0x1, 0x1, 0x1, 0x6, -0x2, -0x2,
});
try testArgs(@Vector(128, i4), .{
0x3, 0x3, -0x6, 0x3, 0x2, 0x1, 0x5, -0x2, 0x0, -0x7, 0x4, 0x3, 0x0, -0x3, -0x7, -0x5,
0x4, 0x0, 0x1, 0x6, 0x3, 0x3, -0x4, 0x7, -0x6, -0x6, 0x6, 0x1, 0x6, -0x5, -0x6, -0x6,
0x4, -0x2, 0x3, -0x1, -0x4, -0x6, -0x1, 0x2, 0x4, 0x3, -0x2, 0x2, 0x3, 0x5, 0x0, -0x2,
0x5, 0x6, -0x1, -0x5, 0x6, 0x7, 0x7, -0x6, -0x6, 0x0, 0x0, -0x6, -0x2, -0x7, -0x6, 0x3,
-0x6, -0x6, 0x4, -0x4, 0x4, -0x5, 0x0, 0x6, 0x6, 0x7, 0x4, -0x5, 0x5, -0x7, -0x7, 0x6,
-0x4, 0x4, -0x7, 0x4, 0x3, 0x2, -0x4, -0x1, -0x6, -0x2, 0x5, -0x2, 0x4, -0x7, -0x3, -0x3,
0x4, 0x1, -0x1, 0x2, -0x1, 0x4, -0x5, -0x3, -0x1, -0x3, 0x3, 0x7, 0x5, -0x1, -0x1, -0x4,
0x2, 0x1, -0x3, 0x7, -0x6, -0x7, -0x6, -0x4, -0x5, -0x2, 0x5, 0x0, -0x5, 0x7, -0x7, 0x5,
-0x1, -0x3, -0x3, -0x4, 0x3, -0x4, 0x0, -0x4, 0x7, 0x3, 0x5, -0x4, -0x5, -0x4, -0x2, -0x7,
0x2, 0x0, -0x4, 0x7, 0x3, -0x5, 0x4, 0x5, -0x2, -0x3, -0x4, 0x6, -0x7, -0x1, 0x1, -0x6,
0x1, 0x5, 0x2, 0x5, 0x2, 0x2, -0x4, -0x4, 0x5, 0x2, -0x2, -0x8, -0x1, -0x2, 0x5, 0x3,
0x0, -0x5, 0x5, 0x7, 0x6, -0x3, -0x2, 0x0, -0x7, -0x7, -0x4, 0x2, -0x4, 0x7, 0x1, -0x5,
-0x4, -0x8, 0x2, -0x7, 0x3, -0x4, 0x7, 0x6, -0x7, -0x3, -0x7, 0x2, 0x4, 0x2, -0x5, -0x6,
0x3, 0x5, 0x1, 0x6, 0x5, 0x7, 0x7, -0x4, -0x7, -0x1, 0x0, -0x7, 0x6, 0x0, 0x6, 0x0,
0x0, -0x5, -0x1, -0x8, 0x7, -0x6, -0x5, -0x2, -0x4, 0x1, 0x1, -0x8, 0x2, 0x6, -0x1, -0x3,
-0x6, 0x5, -0x8, 0x3, 0x3, 0x1, -0x1, -0x3, -0x3, -0x6, 0x7, -0x6, -0x8, 0x1, -0x7, -0x8,
}, .{
-0x6, -0x5, -0x1, 0x4, 0x6, 0x4, -0x1, -0x7, -0x3, 0x4, -0x6, -0x2, -0x3, 0x1, 0x6, 0x2,
-0x1, -0x3, -0x4, 0x2, 0x3, 0x6, -0x7, 0x3, 0x7, -0x6, 0x1, -0x7, -0x5, 0x6, 0x7, -0x4,
0x7, -0x4, 0x2, -0x5, 0x4, 0x5, 0x5, -0x3, -0x1, 0x6, -0x6, -0x2, -0x4, 0x3, -0x4, -0x4,
-0x5, 0x6, -0x6, 0x3, -0x6, -0x3, 0x6, 0x5, 0x6, -0x6, -0x3, 0x1, -0x4, -0x5, -0x8, -0x3,
-0x4, 0x7, -0x2, -0x1, 0x4, 0x2, -0x3, 0x6, 0x4, 0x6, -0x3, 0x6, 0x5, -0x2, -0x1, 0x5,
0x6, -0x6, -0x8, -0x2, -0x3, 0x6, -0x6, 0x5, -0x2, -0x6, 0x5, -0x6, 0x2, 0x1, 0x3, -0x3,
0x7, 0x7, 0x3, -0x1, 0x5, -0x2, -0x3, 0x4, 0x7, -0x7, 0x7, 0x6, -0x2, -0x5, 0x4, -0x5,
-0x1, -0x2, 0x1, 0x4, -0x2, 0x1, -0x3, 0x1, -0x4, 0x3, -0x2, -0x6, -0x4, -0x2, -0x8, 0x2,
0x1, 0x3, 0x1, 0x3, -0x6, 0x6, 0x2, -0x3, 0x1, -0x7, 0x7, -0x3, -0x1, -0x1, 0x7, 0x2,
-0x8, 0x2, -0x3, -0x4, 0x4, -0x4, 0x7, 0x6, -0x5, -0x2, -0x1, 0x6, -0x7, 0x4, 0x7, -0x3,
-0x5, -0x8, -0x5, -0x6, -0x6, 0x2, 0x1, -0x8, 0x4, 0x3, -0x5, 0x7, -0x8, 0x3, -0x1, 0x7,
-0x3, 0x7, -0x3, -0x2, -0x6, 0x4, 0x2, -0x2, -0x2, -0x7, 0x5, -0x1, -0x6, 0x7, -0x5, 0x5,
0x4, 0x5, -0x8, -0x5, 0x6, 0x1, -0x5, 0x7, -0x6, -0x3, -0x4, 0x6, -0x8, 0x7, 0x7, -0x6,
0x6, -0x4, 0x2, -0x8, -0x8, -0x4, -0x8, -0x3, 0x6, 0x5, 0x7, -0x6, 0x1, 0x2, -0x7, -0x3,
-0x3, 0x1, -0x3, 0x3, -0x1, 0x3, -0x7, -0x8, 0x1, -0x3, -0x3, -0x3, -0x4, 0x5, 0x7, -0x7,
0x3, 0x2, 0x6, -0x2, -0x4, -0x3, -0x1, 0x5, -0x6, 0x2, 0x3, -0x5, 0x5, -0x3, -0x2, -0x8,
});
try testArgs(@Vector(1, u4), .{
@ -2509,130 +2382,67 @@ fn binary(comptime op: anytype, comptime opts: struct { compare: Compare = .rela
0x9, 0x6, 0x4, 0x5, 0xf, 0xe, 0x8, 0x5, 0x2, 0x5, 0xf, 0xb, 0xf, 0x4, 0x6, 0x4,
});
// workaround https://github.com/ziglang/zig/issues/22914
// TODO: try testArgs(@Vector(1, i5), .{
// 0x03,
// }, .{
// 0x0a,
// });
// try testArgs(@Vector(2, i5), .{
// 0x0c, -0x0e,
// }, .{
// -0x0f, -0x0e,
// });
// try testArgs(@Vector(4, i5), .{
// -0x0a, 0x06, -0x05, 0x09,
// }, .{
// -0x0f, 0x05, 0x05, 0x09,
// });
// try testArgs(@Vector(8, i5), .{
// -0x04, -0x04, 0x05, -0x05, 0x0f, -0x0e, 0x0f, -0x0e,
// }, .{
// -0x09, -0x0d, 0x02, 0x01, 0x08, -0x05, -0x09, -0x03,
// });
// try testArgs(@Vector(16, i5), .{
// -0x0e, -0x08, -0x10, -0x0b, -0x10, -0x09, -0x0f, -0x05, -0x10, 0x06, 0x0d, -0x04, 0x09, -0x0e, -0x10, -0x10,
// }, .{
// 0x03, 0x0b, 0x0c, 0x06, -0x0d, 0x0e, -0x09, -0x04, 0x0a, -0x0e, -0x0d, 0x0f, -0x09, -0x0e, -0x0b, 0x03,
// });
// try testArgs(@Vector(32, i5), .{
// -0x08, -0x05, 0x09, -0x08, 0x01, 0x0e, -0x0c, 0x0b, -0x0e, 0x0f, -0x0b, 0x01, -0x03, 0x03, 0x08, 0x04,
// 0x02, 0x0f, -0x0b, -0x0b, 0x0d, 0x00, 0x09, 0x00, -0x06, -0x08, -0x01, 0x0b, 0x05, 0x03, -0x05, -0x07,
// }, .{
// -0x0c, 0x07, 0x0d, -0x09, 0x0a, 0x06, -0x0b, -0x07, -0x0a, 0x08, 0x07, -0x0d, 0x08, 0x07, 0x09, -0x07,
// 0x0b, -0x02, -0x02, -0x02, -0x06, -0x08, 0x0a, -0x0a, 0x02, -0x07, -0x0a, 0x0d, -0x07, -0x05, -0x0e, 0x05,
// });
// try testArgs(@Vector(64, i5), .{
// 0x04, -0x0d, 0x0d, -0x01, 0x07, 0x0c, 0x00, 0x01, -0x07, 0x0a, -0x01, -0x01, 0x08, -0x0b, -0x03, -0x06,
// -0x03, -0x03, -0x0c, 0x0e, -0x0c, -0x02, 0x07, -0x03, 0x0e, -0x0a, -0x0e, -0x06, -0x08, 0x0a, -0x0c, -0x0c,
// 0x06, -0x04, 0x04, 0x00, 0x05, 0x07, 0x04, 0x06, -0x01, 0x0a, 0x07, -0x08, 0x00, 0x0f, 0x0f, 0x0d,
// -0x07, 0x0f, 0x05, -0x0b, -0x08, -0x0c, 0x0d, -0x05, -0x05, 0x0e, 0x02, 0x06, 0x0d, 0x06, 0x00, 0x0a,
// }, .{
// 0x02, -0x09, -0x01, -0x10, -0x0c, -0x0f, -0x10, -0x0d, 0x02, 0x0e, 0x07, -0x01, -0x0a, -0x0b, 0x05, -0x0e,
// -0x09, 0x03, 0x08, -0x0d, 0x0d, 0x03, -0x02, 0x0e, 0x0c, 0x03, 0x0b, -0x0d, -0x04, -0x10, 0x0e, 0x0d,
// 0x09, -0x03, -0x0e, -0x03, -0x05, -0x0c, -0x07, 0x08, -0x06, 0x08, -0x0e, 0x02, -0x10, 0x01, 0x01, -0x0a,
// 0x01, -0x09, 0x03, -0x01, 0x05, 0x09, 0x06, -0x03, -0x0a, 0x08, -0x0e, 0x0e, 0x07, -0x05, -0x0c, -0x10,
// });
// try testArgs(@Vector(128, i5), .{
// 0x01, 0x0b, -0x01, -0x10, -0x05, 0x05, -0x09, 0x0e, -0x0e, 0x04, 0x0f, -0x06, 0x0f, 0x04, -0x02, 0x0a,
// -0x08, -0x06, 0x08, -0x07, -0x08, 0x0e, 0x06, 0x0d, -0x07, -0x04, 0x04, -0x0b, 0x02, -0x06, 0x07, -0x10,
// 0x0d, 0x09, 0x0b, -0x04, 0x0e, -0x06, -0x0a, 0x01, 0x06, 0x08, 0x01, -0x0b, -0x09, -0x08, -0x0c, -0x0b,
// 0x07, 0x06, 0x0d, 0x0c, -0x0b, -0x03, -0x06, -0x0c, -0x0e, 0x05, 0x0b, 0x08, -0x01, 0x00, 0x01, 0x0a,
// 0x00, 0x0a, 0x06, 0x06, -0x10, -0x05, -0x05, -0x0f, 0x02, -0x06, -0x08, -0x08, 0x0f, 0x09, -0x07, -0x05,
// 0x07, 0x06, 0x03, 0x05, 0x02, 0x0f, 0x0d, -0x0e, -0x03, -0x01, -0x06, -0x02, -0x01, -0x07, 0x09, 0x05,
// -0x07, -0x07, -0x08, 0x0c, -0x0e, 0x09, -0x0c, -0x0d, 0x07, 0x04, 0x07, -0x03, 0x09, 0x0e, 0x04, 0x02,
// 0x0f, -0x02, -0x10, -0x03, -0x0d, -0x04, 0x0c, -0x06, -0x01, -0x0e, -0x0e, -0x0a, 0x0d, -0x0e, 0x04, 0x03,
// }, .{
// -0x08, -0x09, -0x04, 0x0f, -0x0f, -0x08, -0x04, 0x0b, 0x09, -0x0b, -0x02, 0x0f, 0x01, -0x01, -0x0a, -0x0a,
// 0x08, 0x09, 0x0d, -0x06, 0x0f, -0x02, 0x0c, 0x01, 0x0c, 0x02, -0x04, 0x0b, 0x05, 0x02, -0x08, -0x09,
// 0x01, 0x0f, -0x0b, 0x02, -0x06, 0x08, -0x0e, -0x02, -0x0b, -0x03, -0x01, 0x0c, 0x09, -0x04, 0x08, -0x0a,
// 0x09, -0x05, 0x08, 0x0e, 0x05, 0x03, -0x0a, 0x0d, -0x03, 0x06, 0x0f, -0x09, 0x0a, 0x03, 0x02, 0x0c,
// 0x08, -0x0a, 0x06, 0x0e, 0x08, 0x02, 0x08, -0x04, -0x0d, -0x02, -0x08, -0x0a, 0x0a, 0x0c, -0x03, 0x04,
// 0x0b, -0x0c, -0x0e, 0x01, 0x07, -0x01, 0x09, 0x0f, -0x06, -0x05, -0x0e, -0x01, -0x04, 0x0a, -0x0a, -0x0d,
// -0x10, -0x10, -0x03, -0x0f, -0x0c, -0x0a, -0x0b, -0x06, -0x04, -0x0f, -0x0b, -0x08, 0x0e, 0x04, -0x01, -0x0b,
// -0x06, 0x0a, 0x0a, -0x0c, -0x0c, 0x0b, -0x02, 0x0c, -0x04, -0x06, -0x0c, -0x09, -0x09, -0x0b, -0x0c, -0x0b,
// });
try testArgs(@Vector(1, i5), .{
-0x0f,
0x03,
}, .{
-0x03,
0x0a,
});
try testArgs(@Vector(2, i5), .{
0x0b, -0x04,
0x0c, -0x0e,
}, .{
-0x05, -0x08,
-0x0f, -0x0e,
});
try testArgs(@Vector(4, i5), .{
0x08, 0x0f, -0x06, -0x0d,
-0x0a, 0x06, -0x05, 0x09,
}, .{
-0x03, -0x0a, -0x05, -0x03,
-0x0f, 0x05, 0x05, 0x09,
});
try testArgs(@Vector(8, i5), .{
0x08, 0x0c, 0x07, 0x00, -0x06, 0x08, 0x08, 0x0d,
-0x04, -0x04, 0x05, -0x05, 0x0f, -0x0e, 0x0f, -0x0e,
}, .{
0x07, 0x09, 0x05, -0x08, 0x08, -0x0e, -0x0e, -0x0e,
-0x09, -0x0d, 0x02, 0x01, 0x08, -0x05, -0x09, -0x03,
});
try testArgs(@Vector(16, i5), .{
0x06, 0x0b, 0x07, 0x0e, 0x0e, 0x02, -0x08, -0x0b, -0x03, 0x09, -0x08, 0x0e, -0x03, -0x0a, 0x01, 0x0b,
-0x0e, -0x08, -0x10, -0x0b, -0x10, -0x09, -0x0f, -0x05, -0x10, 0x06, 0x0d, -0x04, 0x09, -0x0e, -0x10, -0x10,
}, .{
-0x05, 0x0f, -0x08, -0x10, -0x07, 0x06, 0x08, 0x01, 0x0a, 0x06, 0x05, -0x0f, 0x03, 0x05, 0x0b, -0x06,
0x03, 0x0b, 0x0c, 0x06, -0x0d, 0x0e, -0x09, -0x04, 0x0a, -0x0e, -0x0d, 0x0f, -0x09, -0x0e, -0x0b, 0x03,
});
try testArgs(@Vector(32, i5), .{
0x0e, 0x07, -0x08, 0x0b, 0x04, -0x05, 0x0f, 0x02, 0x04, -0x0c, 0x0d, 0x09, 0x0e, -0x02, -0x0f, 0x04,
-0x03, -0x02, 0x09, -0x0d, 0x01, 0x00, -0x0e, -0x0a, 0x02, -0x06, 0x0c, 0x03, 0x06, 0x0e, 0x06, -0x07,
-0x08, -0x05, 0x09, -0x08, 0x01, 0x0e, -0x0c, 0x0b, -0x0e, 0x0f, -0x0b, 0x01, -0x03, 0x03, 0x08, 0x04,
0x02, 0x0f, -0x0b, -0x0b, 0x0d, 0x00, 0x09, 0x00, -0x06, -0x08, -0x01, 0x0b, 0x05, 0x03, -0x05, -0x07,
}, .{
-0x0a, 0x01, 0x0a, -0x10, 0x06, 0x09, 0x0e, 0x03, 0x0e, -0x09, 0x08, -0x08, 0x06, 0x0c, -0x0a, -0x07,
0x04, -0x02, -0x09, 0x0b, 0x0e, -0x03, -0x01, -0x0d, 0x0e, -0x0a, -0x02, 0x08, 0x0e, 0x02, -0x04, -0x05,
-0x0c, 0x07, 0x0d, -0x09, 0x0a, 0x06, -0x0b, -0x07, -0x0a, 0x08, 0x07, -0x0d, 0x08, 0x07, 0x09, -0x07,
0x0b, -0x02, -0x02, -0x02, -0x06, -0x08, 0x0a, -0x0a, 0x02, -0x07, -0x0a, 0x0d, -0x07, -0x05, -0x0e, 0x05,
});
try testArgs(@Vector(64, i5), .{
0x04, 0x02, -0x04, -0x0a, -0x0b, -0x0b, -0x0c, -0x08, -0x0b, -0x05, 0x0c, 0x0b, 0x05, 0x02, -0x01, -0x06,
-0x09, -0x06, 0x0a, 0x0f, -0x06, -0x0d, 0x0c, 0x05, 0x0b, -0x06, -0x02, 0x09, 0x0e, -0x09, 0x05, 0x0a,
-0x0c, 0x0b, -0x01, -0x04, 0x01, 0x0c, 0x0f, -0x0f, -0x07, 0x0a, 0x04, 0x02, 0x08, -0x01, -0x03, 0x0a,
-0x0e, -0x04, -0x03, -0x0b, -0x01, 0x02, -0x05, 0x08, -0x03, 0x02, -0x01, -0x05, 0x07, -0x09, 0x0f, 0x00,
0x04, -0x0d, 0x0d, -0x01, 0x07, 0x0c, 0x00, 0x01, -0x07, 0x0a, -0x01, -0x01, 0x08, -0x0b, -0x03, -0x06,
-0x03, -0x03, -0x0c, 0x0e, -0x0c, -0x02, 0x07, -0x03, 0x0e, -0x0a, -0x0e, -0x06, -0x08, 0x0a, -0x0c, -0x0c,
0x06, -0x04, 0x04, 0x00, 0x05, 0x07, 0x04, 0x06, -0x01, 0x0a, 0x07, -0x08, 0x00, 0x0f, 0x0f, 0x0d,
-0x07, 0x0f, 0x05, -0x0b, -0x08, -0x0c, 0x0d, -0x05, -0x05, 0x0e, 0x02, 0x06, 0x0d, 0x06, 0x00, 0x0a,
}, .{
-0x09, -0x02, -0x0a, -0x05, -0x05, -0x0d, 0x04, -0x05, 0x0e, -0x01, -0x07, 0x04, 0x0d, -0x0f, -0x09, -0x04,
-0x0b, -0x0b, 0x0e, 0x01, 0x06, -0x0f, -0x0b, 0x03, -0x04, 0x05, -0x03, -0x09, 0x0a, 0x04, 0x04, -0x06,
-0x02, 0x01, 0x0e, 0x0c, -0x10, 0x0f, -0x09, -0x08, -0x10, -0x02, -0x07, -0x0d, 0x08, 0x07, -0x03, 0x01,
-0x0d, -0x10, -0x07, 0x08, 0x0d, 0x07, 0x09, 0x0f, 0x04, 0x06, -0x05, -0x09, 0x04, -0x04, -0x04, 0x0d,
0x02, -0x09, -0x01, -0x10, -0x0c, -0x0f, -0x10, -0x0d, 0x02, 0x0e, 0x07, -0x01, -0x0a, -0x0b, 0x05, -0x0e,
-0x09, 0x03, 0x08, -0x0d, 0x0d, 0x03, -0x02, 0x0e, 0x0c, 0x03, 0x0b, -0x0d, -0x04, -0x10, 0x0e, 0x0d,
0x09, -0x03, -0x0e, -0x03, -0x05, -0x0c, -0x07, 0x08, -0x06, 0x08, -0x0e, 0x02, -0x10, 0x01, 0x01, -0x0a,
0x01, -0x09, 0x03, -0x01, 0x05, 0x09, 0x06, -0x03, -0x0a, 0x08, -0x0e, 0x0e, 0x07, -0x05, -0x0c, -0x10,
});
try testArgs(@Vector(128, i5), .{
-0x02, -0x07, -0x03, 0x08, -0x0b, -0x09, -0x0c, 0x0d, -0x0e, 0x08, -0x03, -0x09, 0x0a, 0x02, -0x0d, 0x05,
-0x04, -0x0c, -0x07, 0x08, -0x0a, 0x04, 0x08, -0x07, 0x0c, 0x03, 0x0e, 0x0f, 0x08, -0x08, -0x02, -0x0a,
-0x08, 0x04, -0x0c, -0x09, 0x0a, -0x0e, -0x04, -0x05, 0x02, 0x0d, -0x04, -0x0f, -0x0d, -0x02, 0x05, -0x07,
0x06, 0x0b, -0x0b, -0x04, -0x04, -0x0e, -0x0c, 0x09, 0x02, -0x0c, 0x0e, 0x09, 0x02, -0x04, 0x05, 0x04,
-0x0e, -0x02, -0x08, 0x05, 0x00, 0x0f, -0x0a, 0x0a, 0x0b, 0x0b, 0x02, -0x02, -0x0d, -0x08, -0x0d, 0x03,
0x0b, -0x0b, 0x02, 0x05, -0x06, -0x07, -0x08, -0x0a, -0x09, -0x03, -0x0e, -0x0f, -0x0b, 0x03, 0x00, 0x09,
0x07, 0x0a, -0x0b, 0x06, 0x01, -0x03, -0x0a, -0x09, -0x07, -0x0d, 0x0a, -0x0c, 0x01, -0x09, -0x01, -0x01,
-0x09, 0x00, 0x0f, 0x05, -0x0b, 0x0c, 0x04, 0x0c, 0x0b, -0x08, 0x01, -0x05, -0x04, 0x02, 0x0c, 0x04,
0x01, 0x0b, -0x01, -0x10, -0x05, 0x05, -0x09, 0x0e, -0x0e, 0x04, 0x0f, -0x06, 0x0f, 0x04, -0x02, 0x0a,
-0x08, -0x06, 0x08, -0x07, -0x08, 0x0e, 0x06, 0x0d, -0x07, -0x04, 0x04, -0x0b, 0x02, -0x06, 0x07, -0x10,
0x0d, 0x09, 0x0b, -0x04, 0x0e, -0x06, -0x0a, 0x01, 0x06, 0x08, 0x01, -0x0b, -0x09, -0x08, -0x0c, -0x0b,
0x07, 0x06, 0x0d, 0x0c, -0x0b, -0x03, -0x06, -0x0c, -0x0e, 0x05, 0x0b, 0x08, -0x01, 0x00, 0x01, 0x0a,
0x00, 0x0a, 0x06, 0x06, -0x10, -0x05, -0x05, -0x0f, 0x02, -0x06, -0x08, -0x08, 0x0f, 0x09, -0x07, -0x05,
0x07, 0x06, 0x03, 0x05, 0x02, 0x0f, 0x0d, -0x0e, -0x03, -0x01, -0x06, -0x02, -0x01, -0x07, 0x09, 0x05,
-0x07, -0x07, -0x08, 0x0c, -0x0e, 0x09, -0x0c, -0x0d, 0x07, 0x04, 0x07, -0x03, 0x09, 0x0e, 0x04, 0x02,
0x0f, -0x02, -0x10, -0x03, -0x0d, -0x04, 0x0c, -0x06, -0x01, -0x0e, -0x0e, -0x0a, 0x0d, -0x0e, 0x04, 0x03,
}, .{
-0x08, -0x05, -0x0a, 0x06, -0x06, -0x04, 0x01, 0x07, 0x0d, -0x0a, -0x02, 0x0b, -0x01, -0x0c, -0x04, 0x0c,
-0x06, 0x0d, 0x04, 0x0b, 0x07, 0x0c, 0x02, 0x02, -0x02, 0x09, 0x0d, -0x07, -0x08, 0x07, -0x04, 0x06,
-0x0a, 0x07, 0x01, 0x07, -0x0d, 0x02, 0x09, -0x02, 0x0e, -0x08, -0x03, -0x07, 0x07, 0x0a, -0x0e, -0x06,
0x0b, -0x0d, 0x0c, -0x06, -0x07, 0x0a, 0x0b, -0x0a, 0x05, 0x01, -0x0d, -0x08, -0x0e, -0x08, -0x07, -0x01,
-0x10, 0x07, 0x03, 0x06, 0x03, 0x0a, 0x08, -0x0a, 0x04, -0x09, 0x0c, 0x01, -0x10, 0x02, 0x09, 0x0d,
0x0f, -0x01, -0x06, -0x0a, 0x04, 0x01, 0x07, 0x07, 0x0e, 0x0e, -0x04, -0x0a, -0x03, 0x07, 0x07, -0x10,
-0x04, 0x0e, -0x09, -0x0f, -0x0b, -0x0e, 0x0c, -0x0d, 0x0b, -0x06, 0x0f, -0x0d, 0x0b, 0x04, -0x10, -0x10,
-0x0e, 0x09, 0x0d, -0x02, -0x0e, -0x06, -0x0b, -0x0f, -0x08, -0x0f, -0x0d, -0x0a, -0x02, 0x03, 0x0b, -0x0a,
-0x08, -0x09, -0x04, 0x0f, -0x0f, -0x08, -0x04, 0x0b, 0x09, -0x0b, -0x02, 0x0f, 0x01, -0x01, -0x0a, -0x0a,
0x08, 0x09, 0x0d, -0x06, 0x0f, -0x02, 0x0c, 0x01, 0x0c, 0x02, -0x04, 0x0b, 0x05, 0x02, -0x08, -0x09,
0x01, 0x0f, -0x0b, 0x02, -0x06, 0x08, -0x0e, -0x02, -0x0b, -0x03, -0x01, 0x0c, 0x09, -0x04, 0x08, -0x0a,
0x09, -0x05, 0x08, 0x0e, 0x05, 0x03, -0x0a, 0x0d, -0x03, 0x06, 0x0f, -0x09, 0x0a, 0x03, 0x02, 0x0c,
0x08, -0x0a, 0x06, 0x0e, 0x08, 0x02, 0x08, -0x04, -0x0d, -0x02, -0x08, -0x0a, 0x0a, 0x0c, -0x03, 0x04,
0x0b, -0x0c, -0x0e, 0x01, 0x07, -0x01, 0x09, 0x0f, -0x06, -0x05, -0x0e, -0x01, -0x04, 0x0a, -0x0a, -0x0d,
-0x10, -0x10, -0x03, -0x0f, -0x0c, -0x0a, -0x0b, -0x06, -0x04, -0x0f, -0x0b, -0x08, 0x0e, 0x04, -0x01, -0x0b,
-0x06, 0x0a, 0x0a, -0x0c, -0x0c, 0x0b, -0x02, 0x0c, -0x04, -0x06, -0x0c, -0x09, -0x09, -0x0b, -0x0c, -0x0b,
});
try testArgs(@Vector(1, u5), .{
@ -5452,6 +5262,17 @@ test addUnsafe {
try test_add_unsafe.testFloatVectors();
}
inline fn addSafe(comptime Type: type, lhs: Type, rhs: Type) AddOneBit(Type) {
@setRuntimeSafety(true);
return @as(AddOneBit(Type), lhs) + rhs;
}
test addSafe {
const test_add_safe = binary(addSafe, .{});
try test_add_safe.testInts();
try test_add_safe.testFloats();
try test_add_safe.testFloatVectors();
}
inline fn addWrap(comptime Type: type, lhs: Type, rhs: Type) Type {
return lhs +% rhs;
}
@ -5463,15 +5284,14 @@ test addWrap {
inline fn subUnsafe(comptime Type: type, lhs: Type, rhs: Type) AddOneBit(Type) {
@setRuntimeSafety(false);
switch (@typeInfo(Scalar(Type))) {
return switch (@typeInfo(Scalar(Type))) {
else => @compileError(@typeName(Type)),
.int => |int| switch (int.signedness) {
.signed => {},
.unsigned => return @as(AddOneBit(Type), @max(lhs, rhs)) - @min(lhs, rhs),
.signed => @as(AddOneBit(Type), lhs) - rhs,
.unsigned => @as(AddOneBit(Type), @max(lhs, rhs)) - @min(lhs, rhs),
},
.float => {},
}
return @as(AddOneBit(Type), lhs) - rhs;
.float => lhs - rhs,
};
}
test subUnsafe {
const test_sub_unsafe = binary(subUnsafe, .{});
@ -5481,6 +5301,24 @@ test subUnsafe {
try test_sub_unsafe.testFloatVectors();
}
inline fn subSafe(comptime Type: type, lhs: Type, rhs: Type) AddOneBit(Type) {
@setRuntimeSafety(true);
return switch (@typeInfo(Scalar(Type))) {
else => @compileError(@typeName(Type)),
.int => |int| switch (int.signedness) {
.signed => @as(AddOneBit(Type), lhs) - rhs,
.unsigned => @as(AddOneBit(Type), @max(lhs, rhs)) - @min(lhs, rhs),
},
.float => lhs - rhs,
};
}
test subSafe {
const test_sub_safe = binary(subSafe, .{});
try test_sub_safe.testInts();
try test_sub_safe.testFloats();
try test_sub_safe.testFloatVectors();
}
inline fn subWrap(comptime Type: type, lhs: Type, rhs: Type) Type {
return lhs -% rhs;
}
@ -5500,6 +5338,15 @@ test mulUnsafe {
try test_mul_unsafe.testIntVectors();
}
inline fn mulSafe(comptime Type: type, lhs: Type, rhs: Type) DoubleBits(Type) {
@setRuntimeSafety(true);
return @as(DoubleBits(Type), lhs) * rhs;
}
test mulSafe {
const test_mul_safe = binary(mulSafe, .{});
try test_mul_safe.testInts();
}
inline fn mulWrap(comptime Type: type, lhs: Type, rhs: Type) Type {
return lhs *% rhs;
}
@ -5606,6 +5453,30 @@ test min {
try test_min.testFloatVectors();
}
inline fn addWithOverflow(comptime Type: type, lhs: Type, rhs: Type) struct { Type, u1 } {
return @addWithOverflow(lhs, rhs);
}
test addWithOverflow {
const test_add_with_overflow = binary(addWithOverflow, .{});
try test_add_with_overflow.testInts();
}
inline fn subWithOverflow(comptime Type: type, lhs: Type, rhs: Type) struct { Type, u1 } {
return @subWithOverflow(lhs, rhs);
}
test subWithOverflow {
const test_sub_with_overflow = binary(subWithOverflow, .{});
try test_sub_with_overflow.testInts();
}
inline fn mulWithOverflow(comptime Type: type, lhs: Type, rhs: Type) struct { Type, u1 } {
return @mulWithOverflow(lhs, rhs);
}
test mulWithOverflow {
const test_mul_with_overflow = binary(mulWithOverflow, .{});
try test_mul_with_overflow.testInts();
}
inline fn equal(comptime Type: type, lhs: Type, rhs: Type) @TypeOf(lhs == rhs) {
return lhs == rhs;
}
@ -5709,15 +5580,16 @@ test shl {
try test_shl.testInts();
}
inline fn shlExact(comptime Type: type, lhs: Type, rhs: Type) Type {
inline fn shlExactUnsafe(comptime Type: type, lhs: Type, rhs: Type) Type {
@setRuntimeSafety(false);
const bit_cast_rhs: @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(Type) } }) = @bitCast(rhs);
const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs);
const final_rhs = if (comptime cast(Log2Int(Type), @bitSizeOf(Type))) |bits| truncate_rhs % bits else truncate_rhs;
return @shlExact(lhs << final_rhs >> final_rhs, final_rhs);
}
test shlExact {
const test_shl_exact = binary(shlExact, .{});
try test_shl_exact.testInts();
test shlExactUnsafe {
const test_shl_exact_unsafe = binary(shlExactUnsafe, .{});
try test_shl_exact_unsafe.testInts();
}
inline fn bitXor(comptime Type: type, lhs: Type, rhs: Type) @TypeOf(lhs ^ rhs) {

View File

@ -153,6 +153,9 @@ pub noinline fn checkExpected(expected: anytype, actual: @TypeOf(expected), comp
);
},
},
.@"struct" => |@"struct"| inline for (@"struct".fields) |field| {
try checkExpected(@field(expected, field.name), @field(actual, field.name), compare);
} else return,
};
if (switch (@typeInfo(Expected)) {
else => unexpected,