aboutsummaryrefslogtreecommitdiff
path: root/src/Air.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/Air.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/Air.zig')
-rw-r--r--src/Air.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Air.zig b/src/Air.zig
index cdc5ff2287..f7eccfd5a5 100644
--- a/src/Air.zig
+++ b/src/Air.zig
@@ -160,6 +160,14 @@ pub const Inst = struct {
/// Result type is the return type of the function being called.
/// Uses the `pl_op` field with the `Call` payload. operand is the callee.
call,
+ /// Count leading zeroes of an integer according to its representation in twos complement.
+ /// Result type will always be an unsigned integer big enough to fit the answer.
+ /// Uses the `ty_op` field.
+ clz,
+ /// Count trailing zeroes of an integer according to its representation in twos complement.
+ /// Result type will always be an unsigned integer big enough to fit the answer.
+ /// Uses the `ty_op` field.
+ ctz,
/// `<`. Result type is always bool.
/// Uses the `bin_op` field.
@@ -669,6 +677,8 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index) Type {
.float_to_int,
.int_to_float,
.get_union_tag,
+ .clz,
+ .ctz,
=> return air.getRefType(datas[inst].ty_op.ty),
.loop,