From 3295fee9116789f144e6406493116c451aee7c57 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Tue, 18 Oct 2022 11:37:43 -0700 Subject: stage2: Use mem.readPackedInt etc. for packed bitcasts Packed memory has a well-defined layout that doesn't require conversion from an integer to read from. Let's use it :-) This change means that for bitcasting to/from a packed value that is N layers deep, we no longer have to create N temporary big-ints and perform N copies. Other miscellaneous improvements: - Adds support for casting to packed enums and vectors - Fixes bitcasting to/from vectors outside of a packed struct - Adds a fast path for bitcasting <= u/i64 - Fixes bug when bitcasting f80 which would clear following fields This also changes the bitcast memory layout of exotic integers on big-endian systems to match what's empirically observed on our targets. Technically, this layout is not guaranteed by LLVM so we should probably ban bitcasts that reveal these padding bits, but for now this is an improvement. --- src/codegen.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/codegen.zig') diff --git a/src/codegen.zig b/src/codegen.zig index 757bd23b38..6acea5a509 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -470,7 +470,7 @@ pub fn generateSymbol( const abi_size = math.cast(usize, typed_value.ty.abiSize(target)) orelse return error.Overflow; const start = code.items.len; try code.resize(start + abi_size); - bigint.writeTwosComplement(code.items[start..][0..abi_size], info.bits, abi_size, endian); + bigint.writeTwosComplement(code.items[start..][0..abi_size], endian); return Result{ .appended = {} }; } switch (info.signedness) { -- cgit v1.2.3