zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit c413ac100fa5a4cece5702d3afb6b0898e9c6214 (tree)
parent 1024332adc88928299dfc07426f11624ae8ba18b
Author: Jakub Konka <kubkon@jakubkonka.com>
Date:   Fri,  3 Mar 2023 18:40:16 +0100

codegen: refactor generating Int as immediate where appropriate

Diffstat:
Msrc/codegen.zig | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/codegen.zig b/src/codegen.zig @@ -1051,11 +1051,12 @@ pub fn genTypedValue( }, .Int => { const info = typed_value.ty.intInfo(target); - if (info.bits <= ptr_bits and info.signedness == .signed) { - return GenResult.mcv(.{ .immediate = @bitCast(u64, typed_value.val.toSignedInt(target)) }); - } - if (!(info.bits > ptr_bits or info.signedness == .signed)) { - return GenResult.mcv(.{ .immediate = typed_value.val.toUnsignedInt(target) }); + if (info.bits <= ptr_bits) { + const unsigned = switch (info.signedness) { + .signed => @bitCast(u64, typed_value.val.toSignedInt(target)), + .unsigned => typed_value.val.toUnsignedInt(target), + }; + return GenResult.mcv(.{ .immediate = unsigned }); } }, .Bool => {