aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorantlilja <liljaanton2001@gmail.com>2023-07-17 00:16:49 +0200
committerAndrew Kelley <andrew@ziglang.org>2023-09-27 11:15:53 -0700
commit6a29646a553a93fc6a4cbf0fee5fa5362483c326 (patch)
treef19368082978b5004e65707cdf4c60c786617db0 /src/type.zig
parent1606717b5fed83ee64ba1a91e55248e07a51afa6 (diff)
downloadzig-6a29646a553a93fc6a4cbf0fee5fa5362483c326.tar.gz
zig-6a29646a553a93fc6a4cbf0fee5fa5362483c326.zip
Rename `@fabs` to `@abs` and accept integers
Replaces the @fabs builtin with a new @abs builtins which accepts floats, signed integers and vectors of said types.
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/type.zig b/src/type.zig
index 6345f1ef6a..79be8b4c5b 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -3197,6 +3197,17 @@ pub const Type = struct {
};
}
+ pub fn toUnsigned(ty: Type, mod: *Module) !Type {
+ return switch (ty.zigTypeTag(mod)) {
+ .Int => mod.intType(.unsigned, ty.intInfo(mod).bits),
+ .Vector => try mod.vectorType(.{
+ .len = ty.vectorLen(mod),
+ .child = (try ty.childType(mod).toUnsigned(mod)).toIntern(),
+ }),
+ else => unreachable,
+ };
+ }
+
pub const @"u1": Type = .{ .ip_index = .u1_type };
pub const @"u8": Type = .{ .ip_index = .u8_type };
pub const @"u16": Type = .{ .ip_index = .u16_type };