| author | |
| committer | |
| log | c880644d929ff8e403494ff7e6e347b4857db263 |
| tree | cbc3002540eab62b3d2757c2b86e9e47cc39e68a |
| parent | 9358a7528f74cfa8b45f98e83749b8e695d9a941 |
9 files changed, 96 insertions(+), 50 deletions(-)
lib/std/crypto/ecdsa.zig+24-6| ... | @@ -372,7 +372,10 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type { | ... | @@ -372,7 +372,10 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type { |
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | test "ECDSA - Basic operations over EcdsaP384Sha384" { | 374 | test "ECDSA - Basic operations over EcdsaP384Sha384" { |
| 375 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 375 | switch (builtin.zig_backend) { |
| 376 | .stage2_c, .stage2_x86_64 => return error.SkipZigTest, | ||
| 377 | else => {}, | ||
| 378 | } | ||
| 376 | 379 | ||
| 377 | const Scheme = EcdsaP384Sha384; | 380 | const Scheme = EcdsaP384Sha384; |
| 378 | const kp = try Scheme.KeyPair.create(null); | 381 | const kp = try Scheme.KeyPair.create(null); |
| ... | @@ -388,7 +391,10 @@ test "ECDSA - Basic operations over EcdsaP384Sha384" { | ... | @@ -388,7 +391,10 @@ test "ECDSA - Basic operations over EcdsaP384Sha384" { |
| 388 | } | 391 | } |
| 389 | 392 | ||
| 390 | test "ECDSA - Basic operations over Secp256k1" { | 393 | test "ECDSA - Basic operations over Secp256k1" { |
| 391 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 394 | switch (builtin.zig_backend) { |
| 395 | .stage2_c, .stage2_x86_64 => return error.SkipZigTest, | ||
| 396 | else => {}, | ||
| 397 | } | ||
| 392 | 398 | ||
| 393 | const Scheme = EcdsaSecp256k1Sha256oSha256; | 399 | const Scheme = EcdsaSecp256k1Sha256oSha256; |
| 394 | const kp = try Scheme.KeyPair.create(null); | 400 | const kp = try Scheme.KeyPair.create(null); |
| ... | @@ -404,7 +410,10 @@ test "ECDSA - Basic operations over Secp256k1" { | ... | @@ -404,7 +410,10 @@ test "ECDSA - Basic operations over Secp256k1" { |
| 404 | } | 410 | } |
| 405 | 411 | ||
| 406 | test "ECDSA - Basic operations over EcdsaP384Sha256" { | 412 | test "ECDSA - Basic operations over EcdsaP384Sha256" { |
| 407 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 413 | switch (builtin.zig_backend) { |
| 414 | .stage2_c, .stage2_x86_64 => return error.SkipZigTest, | ||
| 415 | else => {}, | ||
| 416 | } | ||
| 408 | 417 | ||
| 409 | const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256); | 418 | const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256); |
| 410 | const kp = try Scheme.KeyPair.create(null); | 419 | const kp = try Scheme.KeyPair.create(null); |
| ... | @@ -420,7 +429,10 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" { | ... | @@ -420,7 +429,10 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" { |
| 420 | } | 429 | } |
| 421 | 430 | ||
| 422 | test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" { | 431 | test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" { |
| 423 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 432 | switch (builtin.zig_backend) { |
| 433 | .stage2_c, .stage2_x86_64 => return error.SkipZigTest, | ||
| 434 | else => {}, | ||
| 435 | } | ||
| 424 | 436 | ||
| 425 | const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256); | 437 | const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256); |
| 426 | // zig fmt: off | 438 | // zig fmt: off |
| ... | @@ -464,7 +476,10 @@ const TestVector = struct { | ... | @@ -464,7 +476,10 @@ const TestVector = struct { |
| 464 | }; | 476 | }; |
| 465 | 477 | ||
| 466 | test "ECDSA - Test vectors from Project Wycheproof" { | 478 | test "ECDSA - Test vectors from Project Wycheproof" { |
| 467 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 479 | switch (builtin.zig_backend) { |
| 480 | .stage2_c, .stage2_x86_64 => return error.SkipZigTest, | ||
| 481 | else => {}, | ||
| 482 | } | ||
| 468 | 483 | ||
| 469 | const vectors = [_]TestVector{ | 484 | const vectors = [_]TestVector{ |
| 470 | .{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e1802204cd60b855d442f5b3c7b11eb6c4e0ae7525fe710fab9aa7c77a67f79e6fadd76", .result = .valid }, | 485 | .{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e1802204cd60b855d442f5b3c7b11eb6c4e0ae7525fe710fab9aa7c77a67f79e6fadd76", .result = .valid }, |
| ... | @@ -878,7 +893,10 @@ fn tvTry(vector: TestVector) !void { | ... | @@ -878,7 +893,10 @@ fn tvTry(vector: TestVector) !void { |
| 878 | } | 893 | } |
| 879 | 894 | ||
| 880 | test "ECDSA - Sec1 encoding/decoding" { | 895 | test "ECDSA - Sec1 encoding/decoding" { |
| 881 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 896 | switch (builtin.zig_backend) { |
| 897 | .stage2_c, .stage2_x86_64 => return error.SkipZigTest, | ||
| 898 | else => {}, | ||
| 899 | } | ||
| 882 | 900 | ||
| 883 | const Scheme = EcdsaP384Sha384; | 901 | const Scheme = EcdsaP384Sha384; |
| 884 | const kp = try Scheme.KeyPair.create(null); | 902 | const kp = try Scheme.KeyPair.create(null); |
lib/std/crypto/ff.zig+4-1| ... | @@ -912,7 +912,10 @@ const ct_unprotected = struct { | ... | @@ -912,7 +912,10 @@ const ct_unprotected = struct { |
| 912 | }; | 912 | }; |
| 913 | 913 | ||
| 914 | test { | 914 | test { |
| 915 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; | 915 | switch (@import("builtin").zig_backend) { |
| 916 | .stage2_c, .stage2_x86_64 => return error.SkipZigTest, | ||
| 917 | else => {}, | ||
| 918 | } | ||
| 916 | 919 | ||
| 917 | const M = Modulus(256); | 920 | const M = Modulus(256); |
| 918 | const m = try M.fromPrimitive(u256, 3429938563481314093726330772853735541133072814650493833233); | 921 | const m = try M.fromPrimitive(u256, 3429938563481314093726330772853735541133072814650493833233); |
lib/std/crypto/pcurves/p384.zig+4-1| ... | @@ -478,7 +478,10 @@ pub const AffineCoordinates = struct { | ... | @@ -478,7 +478,10 @@ pub const AffineCoordinates = struct { |
| 478 | }; | 478 | }; |
| 479 | 479 | ||
| 480 | test { | 480 | test { |
| 481 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; | 481 | switch (@import("builtin").zig_backend) { |
| 482 | .stage2_c, .stage2_x86_64 => return error.SkipZigTest, | ||
| 483 | else => {}, | ||
| 484 | } | ||
| 482 | 485 | ||
| 483 | _ = @import("tests/p384.zig"); | 486 | _ = @import("tests/p384.zig"); |
| 484 | } | 487 | } |
lib/std/crypto/pcurves/secp256k1.zig+4-1| ... | @@ -556,7 +556,10 @@ pub const AffineCoordinates = struct { | ... | @@ -556,7 +556,10 @@ pub const AffineCoordinates = struct { |
| 556 | }; | 556 | }; |
| 557 | 557 | ||
| 558 | test { | 558 | test { |
| 559 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; | 559 | switch (@import("builtin").zig_backend) { |
| 560 | .stage2_c, .stage2_x86_64 => return error.SkipZigTest, | ||
| 561 | else => {}, | ||
| 562 | } | ||
| 560 | 563 | ||
| 561 | _ = @import("tests/secp256k1.zig"); | 564 | _ = @import("tests/secp256k1.zig"); |
| 562 | } | 565 | } |
lib/std/math/big/int_test.zig+2| ... | @@ -3031,6 +3031,8 @@ fn byteSwapTest(comptime T: type, comptime input: comptime_int, comptime expecte | ... | @@ -3031,6 +3031,8 @@ fn byteSwapTest(comptime T: type, comptime input: comptime_int, comptime expecte |
| 3031 | } | 3031 | } |
| 3032 | 3032 | ||
| 3033 | test "big int byte swap" { | 3033 | test "big int byte swap" { |
| 3034 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 3035 | |||
| 3034 | var a = try Managed.initSet(testing.allocator, 0x01_ffffffff_ffffffff_ffffffff); | 3036 | var a = try Managed.initSet(testing.allocator, 0x01_ffffffff_ffffffff_ffffffff); |
| 3035 | defer a.deinit(); | 3037 | defer a.deinit(); |
| 3036 | 3038 |
lib/std/math/log10.zig+1-1| ... | @@ -170,11 +170,11 @@ test "log10_int vs old implementation" { | ... | @@ -170,11 +170,11 @@ test "log10_int vs old implementation" { |
| 170 | test "log10_int close to powers of 10" { | 170 | test "log10_int close to powers of 10" { |
| 171 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | 171 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 172 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 172 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 173 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 174 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 173 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 175 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 174 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 176 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 175 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 177 | if (builtin.zig_backend == .stage2_llvm and comptime builtin.target.isWasm()) return error.SkipZigTest; // TODO | 176 | if (builtin.zig_backend == .stage2_llvm and comptime builtin.target.isWasm()) return error.SkipZigTest; // TODO |
| 177 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 178 | 178 | ||
| 179 | const int_types = .{ u8, u16, u32, u64, u128, u256, u512 }; | 179 | const int_types = .{ u8, u16, u32, u64, u128, u256, u512 }; |
| 180 | const max_log_values: [7]usize = .{ 2, 4, 9, 19, 38, 77, 154 }; | 180 | const max_log_values: [7]usize = .{ 2, 4, 9, 19, 38, 77, 154 }; |
lib/std/math/nextafter.zig+2| ... | @@ -103,6 +103,8 @@ fn nextAfterFloat(comptime T: type, x: T, y: T) T { | ... | @@ -103,6 +103,8 @@ fn nextAfterFloat(comptime T: type, x: T, y: T) T { |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | test "math.nextAfter.int" { | 105 | test "math.nextAfter.int" { |
| 106 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 107 | |||
| 106 | try expect(nextAfter(i0, 0, 0) == 0); | 108 | try expect(nextAfter(i0, 0, 0) == 0); |
| 107 | try expect(nextAfter(u0, 0, 0) == 0); | 109 | try expect(nextAfter(u0, 0, 0) == 0); |
| 108 | try expect(nextAfter(i1, 0, 0) == 0); | 110 | try expect(nextAfter(i1, 0, 0) == 0); |
src/arch/x86_64/CodeGen.zig+53-38| ... | @@ -2895,13 +2895,16 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2895,13 +2895,16 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void { |
| 2895 | }.signedness; | 2895 | }.signedness; |
| 2896 | 2896 | ||
| 2897 | const src_mcv = try self.resolveInst(ty_op.operand); | 2897 | const src_mcv = try self.resolveInst(ty_op.operand); |
| 2898 | const src_storage_bits = switch (src_mcv) { | 2898 | const src_storage_bits: u16 = switch (src_mcv) { |
| 2899 | .register, .register_offset => 64, | 2899 | .register, .register_offset => 64, |
| 2900 | .load_frame => |frame_addr| self.getFrameAddrSize(frame_addr) * 8, | 2900 | .register_pair => 128, |
| 2901 | .load_frame => |frame_addr| @intCast(self.getFrameAddrSize(frame_addr) * 8), | ||
| 2901 | else => src_int_info.bits, | 2902 | else => src_int_info.bits, |
| 2902 | }; | 2903 | }; |
| 2903 | 2904 | ||
| 2904 | const dst_mcv = if (dst_int_info.bits <= src_storage_bits and | 2905 | const dst_mcv = if (dst_int_info.bits <= src_storage_bits and |
| 2906 | std.math.divCeil(u16, dst_int_info.bits, 64) catch unreachable == | ||
| 2907 | std.math.divCeil(u32, src_storage_bits, 64) catch unreachable and | ||
| 2905 | self.reuseOperand(inst, ty_op.operand, 0, src_mcv)) src_mcv else dst: { | 2908 | self.reuseOperand(inst, ty_op.operand, 0, src_mcv)) src_mcv else dst: { |
| 2906 | const dst_mcv = try self.allocRegOrMem(inst, true); | 2909 | const dst_mcv = try self.allocRegOrMem(inst, true); |
| 2907 | try self.genCopy(min_ty, dst_mcv, src_mcv); | 2910 | try self.genCopy(min_ty, dst_mcv, src_mcv); |
| ... | @@ -3646,7 +3649,10 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -3646,7 +3649,10 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 3646 | }, | 3649 | }, |
| 3647 | else => { | 3650 | else => { |
| 3648 | // For now, this is the only supported multiply that doesn't fit in a register. | 3651 | // For now, this is the only supported multiply that doesn't fit in a register. |
| 3649 | assert(dst_info.bits <= 128 and src_bits == 64); | 3652 | if (dst_info.bits > 128 or src_bits != 64) |
| 3653 | return self.fail("TODO implement airWithOverflow from {} to {}", .{ | ||
| 3654 | src_ty.fmt(mod), dst_ty.fmt(mod), | ||
| 3655 | }); | ||
| 3650 | 3656 | ||
| 3651 | const frame_index = | 3657 | const frame_index = |
| 3652 | try self.allocFrameIndex(FrameAlloc.initType(tuple_ty, mod)); | 3658 | try self.allocFrameIndex(FrameAlloc.initType(tuple_ty, mod)); |
| ... | @@ -4424,42 +4430,46 @@ fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -4424,42 +4430,46 @@ fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void { |
| 4424 | // this is identical to the `airPtrElemPtr` codegen expect here an | 4430 | // this is identical to the `airPtrElemPtr` codegen expect here an |
| 4425 | // additional `mov` is needed at the end to get the actual value | 4431 | // additional `mov` is needed at the end to get the actual value |
| 4426 | 4432 | ||
| 4427 | const elem_ty = ptr_ty.elemType2(mod); | 4433 | const result = result: { |
| 4428 | const elem_abi_size: u32 = @intCast(elem_ty.abiSize(mod)); | 4434 | const elem_ty = ptr_ty.elemType2(mod); |
| 4429 | const index_ty = self.typeOf(bin_op.rhs); | 4435 | if (!elem_ty.hasRuntimeBitsIgnoreComptime(mod)) break :result .none; |
| 4430 | const index_mcv = try self.resolveInst(bin_op.rhs); | ||
| 4431 | const index_lock = switch (index_mcv) { | ||
| 4432 | .register => |reg| self.register_manager.lockRegAssumeUnused(reg), | ||
| 4433 | else => null, | ||
| 4434 | }; | ||
| 4435 | defer if (index_lock) |lock| self.register_manager.unlockReg(lock); | ||
| 4436 | 4436 | ||
| 4437 | const offset_reg = try self.elemOffset(index_ty, index_mcv, elem_abi_size); | 4437 | const elem_abi_size: u32 = @intCast(elem_ty.abiSize(mod)); |
| 4438 | const offset_lock = self.register_manager.lockRegAssumeUnused(offset_reg); | 4438 | const index_ty = self.typeOf(bin_op.rhs); |
| 4439 | defer self.register_manager.unlockReg(offset_lock); | 4439 | const index_mcv = try self.resolveInst(bin_op.rhs); |
| 4440 | const index_lock = switch (index_mcv) { | ||
| 4441 | .register => |reg| self.register_manager.lockRegAssumeUnused(reg), | ||
| 4442 | else => null, | ||
| 4443 | }; | ||
| 4444 | defer if (index_lock) |lock| self.register_manager.unlockReg(lock); | ||
| 4440 | 4445 | ||
| 4441 | const ptr_mcv = try self.resolveInst(bin_op.lhs); | 4446 | const offset_reg = try self.elemOffset(index_ty, index_mcv, elem_abi_size); |
| 4442 | const elem_ptr_reg = if (ptr_mcv.isRegister() and self.liveness.operandDies(inst, 0)) | 4447 | const offset_lock = self.register_manager.lockRegAssumeUnused(offset_reg); |
| 4443 | ptr_mcv.register | 4448 | defer self.register_manager.unlockReg(offset_lock); |
| 4444 | else | ||
| 4445 | try self.copyToTmpRegister(ptr_ty, ptr_mcv); | ||
| 4446 | const elem_ptr_lock = self.register_manager.lockRegAssumeUnused(elem_ptr_reg); | ||
| 4447 | defer self.register_manager.unlockReg(elem_ptr_lock); | ||
| 4448 | try self.asmRegisterRegister( | ||
| 4449 | .{ ._, .add }, | ||
| 4450 | elem_ptr_reg, | ||
| 4451 | offset_reg, | ||
| 4452 | ); | ||
| 4453 | 4449 | ||
| 4454 | const dst_mcv = try self.allocRegOrMem(inst, true); | 4450 | const ptr_mcv = try self.resolveInst(bin_op.lhs); |
| 4455 | const dst_lock = switch (dst_mcv) { | 4451 | const elem_ptr_reg = if (ptr_mcv.isRegister() and self.liveness.operandDies(inst, 0)) |
| 4456 | .register => |reg| self.register_manager.lockRegAssumeUnused(reg), | 4452 | ptr_mcv.register |
| 4457 | else => null, | 4453 | else |
| 4458 | }; | 4454 | try self.copyToTmpRegister(ptr_ty, ptr_mcv); |
| 4459 | defer if (dst_lock) |lock| self.register_manager.unlockReg(lock); | 4455 | const elem_ptr_lock = self.register_manager.lockRegAssumeUnused(elem_ptr_reg); |
| 4460 | try self.load(dst_mcv, ptr_ty, .{ .register = elem_ptr_reg }); | 4456 | defer self.register_manager.unlockReg(elem_ptr_lock); |
| 4457 | try self.asmRegisterRegister( | ||
| 4458 | .{ ._, .add }, | ||
| 4459 | elem_ptr_reg, | ||
| 4460 | offset_reg, | ||
| 4461 | ); | ||
| 4461 | 4462 | ||
| 4462 | return self.finishAir(inst, dst_mcv, .{ bin_op.lhs, bin_op.rhs, .none }); | 4463 | const dst_mcv = try self.allocRegOrMem(inst, true); |
| 4464 | const dst_lock = switch (dst_mcv) { | ||
| 4465 | .register => |reg| self.register_manager.lockRegAssumeUnused(reg), | ||
| 4466 | else => null, | ||
| 4467 | }; | ||
| 4468 | defer if (dst_lock) |lock| self.register_manager.unlockReg(lock); | ||
| 4469 | try self.load(dst_mcv, ptr_ty, .{ .register = elem_ptr_reg }); | ||
| 4470 | break :result dst_mcv; | ||
| 4471 | }; | ||
| 4472 | return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none }); | ||
| 4463 | } | 4473 | } |
| 4464 | 4474 | ||
| 4465 | fn airPtrElemPtr(self: *Self, inst: Air.Inst.Index) !void { | 4475 | fn airPtrElemPtr(self: *Self, inst: Air.Inst.Index) !void { |
| ... | @@ -5790,15 +5800,17 @@ fn packedLoad(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) Inn | ... | @@ -5790,15 +5800,17 @@ fn packedLoad(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) Inn |
| 5790 | const ptr_info = ptr_ty.ptrInfo(mod); | 5800 | const ptr_info = ptr_ty.ptrInfo(mod); |
| 5791 | 5801 | ||
| 5792 | const val_ty = ptr_info.child.toType(); | 5802 | const val_ty = ptr_info.child.toType(); |
| 5803 | if (!val_ty.hasRuntimeBitsIgnoreComptime(mod)) return; | ||
| 5793 | const val_abi_size: u32 = @intCast(val_ty.abiSize(mod)); | 5804 | const val_abi_size: u32 = @intCast(val_ty.abiSize(mod)); |
| 5805 | |||
| 5806 | if (val_abi_size > 8) return self.fail("TODO implement packed load of {}", .{val_ty.fmt(mod)}); | ||
| 5807 | |||
| 5794 | const limb_abi_size: u32 = @min(val_abi_size, 8); | 5808 | const limb_abi_size: u32 = @min(val_abi_size, 8); |
| 5795 | const limb_abi_bits = limb_abi_size * 8; | 5809 | const limb_abi_bits = limb_abi_size * 8; |
| 5796 | const val_byte_off: i32 = @intCast(ptr_info.packed_offset.bit_offset / limb_abi_bits * limb_abi_size); | 5810 | const val_byte_off: i32 = @intCast(ptr_info.packed_offset.bit_offset / limb_abi_bits * limb_abi_size); |
| 5797 | const val_bit_off = ptr_info.packed_offset.bit_offset % limb_abi_bits; | 5811 | const val_bit_off = ptr_info.packed_offset.bit_offset % limb_abi_bits; |
| 5798 | const val_extra_bits = self.regExtraBits(val_ty); | 5812 | const val_extra_bits = self.regExtraBits(val_ty); |
| 5799 | 5813 | ||
| 5800 | if (val_abi_size > 8) return self.fail("TODO implement packed load of {}", .{val_ty.fmt(mod)}); | ||
| 5801 | |||
| 5802 | const ptr_reg = try self.copyToTmpRegister(ptr_ty, ptr_mcv); | 5814 | const ptr_reg = try self.copyToTmpRegister(ptr_ty, ptr_mcv); |
| 5803 | const ptr_lock = self.register_manager.lockRegAssumeUnused(ptr_reg); | 5815 | const ptr_lock = self.register_manager.lockRegAssumeUnused(ptr_reg); |
| 5804 | defer self.register_manager.unlockReg(ptr_lock); | 5816 | defer self.register_manager.unlockReg(ptr_lock); |
| ... | @@ -5861,6 +5873,7 @@ fn packedLoad(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) Inn | ... | @@ -5861,6 +5873,7 @@ fn packedLoad(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) Inn |
| 5861 | fn load(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerError!void { | 5873 | fn load(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerError!void { |
| 5862 | const mod = self.bin_file.options.module.?; | 5874 | const mod = self.bin_file.options.module.?; |
| 5863 | const dst_ty = ptr_ty.childType(mod); | 5875 | const dst_ty = ptr_ty.childType(mod); |
| 5876 | if (!dst_ty.hasRuntimeBitsIgnoreComptime(mod)) return; | ||
| 5864 | switch (ptr_mcv) { | 5877 | switch (ptr_mcv) { |
| 5865 | .none, | 5878 | .none, |
| 5866 | .unreach, | 5879 | .unreach, |
| ... | @@ -5937,6 +5950,7 @@ fn packedStore(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) In | ... | @@ -5937,6 +5950,7 @@ fn packedStore(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) In |
| 5937 | const mod = self.bin_file.options.module.?; | 5950 | const mod = self.bin_file.options.module.?; |
| 5938 | const ptr_info = ptr_ty.ptrInfo(mod); | 5951 | const ptr_info = ptr_ty.ptrInfo(mod); |
| 5939 | const src_ty = ptr_ty.childType(mod); | 5952 | const src_ty = ptr_ty.childType(mod); |
| 5953 | if (!src_ty.hasRuntimeBitsIgnoreComptime(mod)) return; | ||
| 5940 | 5954 | ||
| 5941 | const limb_abi_size: u16 = @min(ptr_info.packed_offset.host_size, 8); | 5955 | const limb_abi_size: u16 = @min(ptr_info.packed_offset.host_size, 8); |
| 5942 | const limb_abi_bits = limb_abi_size * 8; | 5956 | const limb_abi_bits = limb_abi_size * 8; |
| ... | @@ -6008,6 +6022,7 @@ fn packedStore(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) In | ... | @@ -6008,6 +6022,7 @@ fn packedStore(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) In |
| 6008 | fn store(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) InnerError!void { | 6022 | fn store(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) InnerError!void { |
| 6009 | const mod = self.bin_file.options.module.?; | 6023 | const mod = self.bin_file.options.module.?; |
| 6010 | const src_ty = ptr_ty.childType(mod); | 6024 | const src_ty = ptr_ty.childType(mod); |
| 6025 | if (!src_ty.hasRuntimeBitsIgnoreComptime(mod)) return; | ||
| 6011 | switch (ptr_mcv) { | 6026 | switch (ptr_mcv) { |
| 6012 | .none, | 6027 | .none, |
| 6013 | .unreach, | 6028 | .unreach, |
| ... | @@ -11286,7 +11301,6 @@ fn genSetReg(self: *Self, dst_reg: Register, ty: Type, src_mcv: MCValue) InnerEr | ... | @@ -11286,7 +11301,6 @@ fn genSetReg(self: *Self, dst_reg: Register, ty: Type, src_mcv: MCValue) InnerEr |
| 11286 | .none, | 11301 | .none, |
| 11287 | .unreach, | 11302 | .unreach, |
| 11288 | .dead, | 11303 | .dead, |
| 11289 | .register_pair, | ||
| 11290 | .register_overflow, | 11304 | .register_overflow, |
| 11291 | .reserved_frame, | 11305 | .reserved_frame, |
| 11292 | => unreachable, | 11306 | => unreachable, |
| ... | @@ -11390,6 +11404,7 @@ fn genSetReg(self: *Self, dst_reg: Register, ty: Type, src_mcv: MCValue) InnerEr | ... | @@ -11390,6 +11404,7 @@ fn genSetReg(self: *Self, dst_reg: Register, ty: Type, src_mcv: MCValue) InnerEr |
| 11390 | }, | 11404 | }, |
| 11391 | .x87, .mmx => unreachable, | 11405 | .x87, .mmx => unreachable, |
| 11392 | }, | 11406 | }, |
| 11407 | .register_pair => |src_regs| try self.genSetReg(dst_reg, ty, .{ .register = src_regs[0] }), | ||
| 11393 | .register_offset, | 11408 | .register_offset, |
| 11394 | .indirect, | 11409 | .indirect, |
| 11395 | .load_frame, | 11410 | .load_frame, |
src/codegen.zig+2-2| ... | @@ -545,7 +545,7 @@ pub fn generateSymbol( | ... | @@ -545,7 +545,7 @@ pub fn generateSymbol( |
| 545 | 545 | ||
| 546 | if (layout.payload_size == 0) { | 546 | if (layout.payload_size == 0) { |
| 547 | return generateSymbol(bin_file, src_loc, .{ | 547 | return generateSymbol(bin_file, src_loc, .{ |
| 548 | .ty = typed_value.ty.unionTagType(mod).?, | 548 | .ty = typed_value.ty.unionTagTypeSafety(mod).?, |
| 549 | .val = un.tag.toValue(), | 549 | .val = un.tag.toValue(), |
| 550 | }, code, debug_output, reloc_info); | 550 | }, code, debug_output, reloc_info); |
| 551 | } | 551 | } |
| ... | @@ -553,7 +553,7 @@ pub fn generateSymbol( | ... | @@ -553,7 +553,7 @@ pub fn generateSymbol( |
| 553 | // Check if we should store the tag first. | 553 | // Check if we should store the tag first. |
| 554 | if (layout.tag_size > 0 and layout.tag_align.compare(.gte, layout.payload_align)) { | 554 | if (layout.tag_size > 0 and layout.tag_align.compare(.gte, layout.payload_align)) { |
| 555 | switch (try generateSymbol(bin_file, src_loc, .{ | 555 | switch (try generateSymbol(bin_file, src_loc, .{ |
| 556 | .ty = typed_value.ty.unionTagType(mod).?, | 556 | .ty = typed_value.ty.unionTagTypeSafety(mod).?, |
| 557 | .val = un.tag.toValue(), | 557 | .val = un.tag.toValue(), |
| 558 | }, code, debug_output, reloc_info)) { | 558 | }, code, debug_output, reloc_info)) { |
| 559 | .ok => {}, | 559 | .ok => {}, |