aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-09-28 22:38:51 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-09-28 22:38:51 -0700
commit33e77f127d8237088b561fae2ca0f4412bc1d6c9 (patch)
tree2ad81a2a7ac5fa5635d6d03456333d30fe568364 /src/type.zig
parent7efc2a06264170632e56256a5fad97e945768056 (diff)
downloadzig-33e77f127d8237088b561fae2ca0f4412bc1d6c9.tar.gz
zig-33e77f127d8237088b561fae2ca0f4412bc1d6c9.zip
stage2: implement `@clz` and `@ctz`
Also improve the LLVM backend to support lowering bigints to LLVM values. Moves over a bunch of math.zig test cases to the "passing for stage2" section.
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/type.zig b/src/type.zig
index e13ede852a..cb2cc6d58a 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -3902,16 +3902,16 @@ pub const Type = extern union {
const bits = bits: {
if (max == 0) break :bits 0;
const base = std.math.log2(max);
- const upper = (@as(u64, 1) << base) - 1;
+ const upper = (@as(u64, 1) << @intCast(u6, base)) - 1;
break :bits base + @boolToInt(upper < max);
};
- return switch (bits) {
+ return switch (@intCast(u16, bits)) {
1 => initTag(.u1),
8 => initTag(.u8),
16 => initTag(.u16),
32 => initTag(.u32),
64 => initTag(.u64),
- else => return Tag.int_unsigned.create(arena, bits),
+ else => |b| return Tag.int_unsigned.create(arena, b),
};
}
};