From 50339f595aa6ec96760b1cd9f8d0e0bfc3f167fc Mon Sep 17 00:00:00 2001
From: Eric Joldasov To convert an integer address into a pointer, use {#syntax#}@intToPtr{#endsyntax#}.
- To convert a pointer to an integer, use {#syntax#}@ptrToInt{#endsyntax#}: To convert an integer address into a pointer, use {#syntax#}@ptrFromInt{#endsyntax#}.
+ To convert a pointer to an integer, use {#syntax#}@intFromPtr{#endsyntax#}: Loads and stores are assumed to not have side effects. If a given load or store
should have side effects, such as Memory Mapped Input/Output (MMIO), use {#syntax#}volatile{#endsyntax#}.
@@ -2801,7 +2801,7 @@ test "comptime @intToPtr" {
const expect = @import("std").testing.expect;
test "volatile" {
- const mmio_ptr = @intToPtr(*volatile u8, 0x12345678);
+ const mmio_ptr = @ptrFromInt(*volatile u8, 0x12345678);
try expect(@TypeOf(mmio_ptr) == *volatile u8);
}
{#code_end#}
@@ -2942,8 +2942,8 @@ const expect = std.testing.expect;
test "allowzero" {
var zero: usize = 0;
- var ptr = @intToPtr(*allowzero i32, zero);
- try expect(@ptrToInt(ptr) == 0);
+ var ptr = @ptrFromInt(*allowzero i32, zero);
+ try expect(@intFromPtr(ptr) == 0);
}
{#code_end#}
{#header_close#}
@@ -3006,7 +3006,7 @@ test "basic slices" {
// while using the `ptr` field gives a many-item pointer.
try expect(@TypeOf(slice.ptr) == [*]i32);
try expect(@TypeOf(&slice[0]) == *i32);
- try expect(@ptrToInt(slice.ptr) == @ptrToInt(&slice[0]));
+ try expect(@intFromPtr(slice.ptr) == @intFromPtr(&slice[0]));
// Slices have array bounds checking. If you try to access something out
// of bounds, you'll get a safety check failure:
@@ -3448,8 +3448,8 @@ var bit_field = BitField{
};
test "pointers of sub-byte-aligned fields share addresses" {
- try expect(@ptrToInt(&bit_field.a) == @ptrToInt(&bit_field.b));
- try expect(@ptrToInt(&bit_field.a) == @ptrToInt(&bit_field.c));
+ try expect(@intFromPtr(&bit_field.a) == @intFromPtr(&bit_field.b));
+ try expect(@intFromPtr(&bit_field.a) == @intFromPtr(&bit_field.c));
}
{#code_end#}
@@ -3664,9 +3664,9 @@ const Value = enum(u2) {
// Now you can cast between u2 and Value.
// The ordinal value starts from 0, counting up by 1 from the previous member.
test "enum ordinal value" {
- try expect(@enumToInt(Value.zero) == 0);
- try expect(@enumToInt(Value.one) == 1);
- try expect(@enumToInt(Value.two) == 2);
+ try expect(@intFromEnum(Value.zero) == 0);
+ try expect(@intFromEnum(Value.one) == 1);
+ try expect(@intFromEnum(Value.two) == 2);
}
// You can override the ordinal value for an enum.
@@ -3676,9 +3676,9 @@ const Value2 = enum(u32) {
million = 1000000,
};
test "set enum ordinal value" {
- try expect(@enumToInt(Value2.hundred) == 100);
- try expect(@enumToInt(Value2.thousand) == 1000);
- try expect(@enumToInt(Value2.million) == 1000000);
+ try expect(@intFromEnum(Value2.hundred) == 100);
+ try expect(@intFromEnum(Value2.thousand) == 1000);
+ try expect(@intFromEnum(Value2.million) == 1000000);
}
// You can also override only some values.
@@ -3690,11 +3690,11 @@ const Value3 = enum(u4) {
e,
};
test "enum implicit ordinal values and overridden values" {
- try expect(@enumToInt(Value3.a) == 0);
- try expect(@enumToInt(Value3.b) == 8);
- try expect(@enumToInt(Value3.c) == 9);
- try expect(@enumToInt(Value3.d) == 4);
- try expect(@enumToInt(Value3.e) == 5);
+ try expect(@intFromEnum(Value3.a) == 0);
+ try expect(@intFromEnum(Value3.b) == 8);
+ try expect(@intFromEnum(Value3.c) == 9);
+ try expect(@intFromEnum(Value3.d) == 4);
+ try expect(@intFromEnum(Value3.e) == 5);
}
// Enums can have methods, the same as structs and unions.
@@ -3811,7 +3811,7 @@ test "switch using enum literals" {
It must specify a tag type and cannot consume every enumeration value.
- {#link|@intToEnum#} on a non-exhaustive enum involves the safety semantics
+ {#link|@enumFromInt#} on a non-exhaustive enum involves the safety semantics
of {#link|@intCast#} to the integer tag type, but beyond that always results in
a well-defined enum value.
{#header_close#}
@@ -6744,8 +6744,8 @@ fn peerTypeEmptyArrayAndSliceAndError(a: bool, slice: []u8) anyerror![]u8 {
}
test "peer type resolution: *const T and ?*T" {
- const a = @intToPtr(*const usize, 0x123456780);
- const b = @intToPtr(?*usize, 0x123456780);
+ const a = @ptrFromInt(*const usize, 0x123456780);
+ const b = @ptrFromInt(?*usize, 0x123456780);
try expect(a == b);
try expect(b == a);
}
@@ -7542,7 +7542,7 @@ pub fn main() void {
{#target_linux_x86_64#}
pub fn main() noreturn {
const msg = "hello world\n";
- _ = syscall3(SYS_write, STDOUT_FILENO, @ptrToInt(msg), msg.len);
+ _ = syscall3(SYS_write, STDOUT_FILENO, @intFromPtr(msg), msg.len);
_ = syscall1(SYS_exit, 0);
unreachable;
}
@@ -7857,7 +7857,7 @@ comptime {
Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}.
- Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@intToPtr{#endsyntax#} if you need this. + Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@ptrFromInt{#endsyntax#} if you need this.
Can be used for these things for example: @@ -7884,8 +7884,8 @@ comptime { {#see_also|@offsetOf#} {#header_close#} - {#header_open|@boolToInt#} -
{#syntax#}@boolToInt(value: bool) u1{#endsyntax#}+ {#header_open|@intFromBool#} +
{#syntax#}@intFromBool(value: bool) u1{#endsyntax#}
Converts {#syntax#}true{#endsyntax#} to {#syntax#}@as(u1, 1){#endsyntax#} and {#syntax#}false{#endsyntax#} to {#syntax#}@as(u1, 0){#endsyntax#}. @@ -8348,8 +8348,8 @@ test "main" { {#see_also|@import#} {#header_close#} - {#header_open|@enumToInt#} -
{#syntax#}@enumToInt(enum_or_tagged_union: anytype) anytype{#endsyntax#}+ {#header_open|@intFromEnum#} +
{#syntax#}@intFromEnum(enum_or_tagged_union: anytype) anytype{#endsyntax#}
Converts an enumeration value into its integer tag type. When a tagged union is passed, the tag value is used as the enumeration value. @@ -8358,7 +8358,7 @@ test "main" { If there is only one possible enum value, the result is a {#syntax#}comptime_int{#endsyntax#} known at {#link|comptime#}.
- {#see_also|@intToEnum#} + {#see_also|@enumFromInt#} {#header_close#} {#header_open|@errorName#} @@ -8383,8 +8383,8 @@ test "main" { {#header_close#} - {#header_open|@errorToInt#} -{#syntax#}@errorToInt(err: anytype) std.meta.Int(.unsigned, @sizeOf(anyerror) * 8){#endsyntax#}+ {#header_open|@intFromError#} +
{#syntax#}@intFromError(err: anytype) std.meta.Int(.unsigned, @sizeOf(anyerror) * 8){#endsyntax#}
Supports the following types:
@@ -8400,7 +8400,7 @@ test "main" { It is generally recommended to avoid this cast, as the integer representation of an error is not stable across source code changes. - {#see_also|@intToError#} + {#see_also|@errorFromInt#} {#header_close#} {#header_open|@errSetCast#} @@ -8526,8 +8526,8 @@ test "decl access by string" { {#header_close#} - {#header_open|@floatToInt#} -{#syntax#}@floatToInt(comptime DestType: type, float: anytype) DestType{#endsyntax#}+ {#header_open|@intFromFloat#} +
{#syntax#}@intFromFloat(comptime DestType: type, float: anytype) DestType{#endsyntax#}
Converts the integer part of a floating point number to the destination type.
@@ -8535,7 +8535,7 @@ test "decl access by string" { If the integer part of the floating point number cannot fit in the destination type, it invokes safety-checked {#link|Undefined Behavior#}. - {#see_also|@intToFloat#} + {#see_also|@floatFromInt#} {#header_close#} {#header_open|@frameAddress#} @@ -8666,8 +8666,8 @@ test "integer cast panic" { {#header_close#} - {#header_open|@intToEnum#} -{#syntax#}@intToEnum(comptime DestType: type, integer: anytype) DestType{#endsyntax#}+ {#header_open|@enumFromInt#} +
{#syntax#}@enumFromInt(comptime DestType: type, integer: anytype) DestType{#endsyntax#}
Converts an integer into an {#link|enum#} value.
@@ -8675,11 +8675,11 @@ test "integer cast panic" { Attempting to convert an integer which represents no value in the chosen enum type invokes safety-checked {#link|Undefined Behavior#}. - {#see_also|@enumToInt#} + {#see_also|@intFromEnum#} {#header_close#} - {#header_open|@intToError#} -{#syntax#}@intToError(value: std.meta.Int(.unsigned, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}+ {#header_open|@errorFromInt#} +
{#syntax#}@errorFromInt(value: std.meta.Int(.unsigned, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}
Converts from the integer representation of an error into {#link|The Global Error Set#} type.
@@ -8691,20 +8691,20 @@ test "integer cast panic" { Attempting to convert an integer that does not correspond to any error results in safety-protected {#link|Undefined Behavior#}. - {#see_also|@errorToInt#} + {#see_also|@intFromError#} {#header_close#} - {#header_open|@intToFloat#} -{#syntax#}@intToFloat(comptime DestType: type, int: anytype) DestType{#endsyntax#}+ {#header_open|@floatFromInt#} +
{#syntax#}@floatFromInt(comptime DestType: type, int: anytype) DestType{#endsyntax#}
- Converts an integer to the closest floating point representation. To convert the other way, use {#link|@floatToInt#}. This cast is always safe. + Converts an integer to the closest floating point representation. To convert the other way, use {#link|@intFromFloat#}. This cast is always safe.
{#header_close#} - {#header_open|@intToPtr#} -{#syntax#}@intToPtr(comptime DestType: type, address: usize) DestType{#endsyntax#}+ {#header_open|@ptrFromInt#} +
{#syntax#}@ptrFromInt(comptime DestType: type, address: usize) DestType{#endsyntax#}
- Converts an integer to a {#link|pointer|Pointers#}. To convert the other way, use {#link|@ptrToInt#}. Casting an address of 0 to a destination type + Converts an integer to a {#link|pointer|Pointers#}. To convert the other way, use {#link|@intFromPtr#}. Casting an address of 0 to a destination type which in not {#link|optional|Optional Pointers#} and does not have the {#syntax#}allowzero{#endsyntax#} attribute will result in a {#link|Pointer Cast Invalid Null#} panic when runtime safety checks are enabled.
@@ -8928,13 +8928,13 @@ pub const PrefetchOptions = struct { {#header_close#} - {#header_open|@ptrToInt#} -{#syntax#}@ptrToInt(value: anytype) usize{#endsyntax#}+ {#header_open|@intFromPtr#} +
{#syntax#}@intFromPtr(value: anytype) usize{#endsyntax#}
Converts {#syntax#}value{#endsyntax#} to a {#syntax#}usize{#endsyntax#} which is the address of the pointer. {#syntax#}value{#endsyntax#} can be {#syntax#}*T{#endsyntax#} or {#syntax#}?*T{#endsyntax#}.
-To convert the other way, use {#link|@intToPtr#}
+To convert the other way, use {#link|@ptrFromInt#}
{#header_close#} @@ -10165,8 +10165,8 @@ fn getNumberOrFail() !i32 { {#code_begin|test_err|test_comptime_invalid_error_code|integer value '11' represents no error#} comptime { const err = error.AnError; - const number = @errorToInt(err) + 10; - const invalid_err = @intToError(number); + const number = @intFromError(err) + 10; + const invalid_err = @errorFromInt(number); _ = invalid_err; } {#code_end#} @@ -10176,8 +10176,8 @@ const std = @import("std"); pub fn main() void { var err = error.AnError; - var number = @errorToInt(err) + 500; - var invalid_err = @intToError(number); + var number = @intFromError(err) + 500; + var invalid_err = @errorFromInt(number); std.debug.print("value: {}\n", .{invalid_err}); } {#code_end#} @@ -10192,7 +10192,7 @@ const Foo = enum { }; comptime { const a: u2 = 3; - const b = @intToEnum(Foo, a); + const b = @enumFromInt(Foo, a); _ = b; } {#code_end#} @@ -10208,7 +10208,7 @@ const Foo = enum { pub fn main() void { var a: u2 = 3; - var b = @intToEnum(Foo, a); + var b = @enumFromInt(Foo, a); std.debug.print("value: {s}\n", .{@tagName(b)}); } {#code_end#} @@ -10255,7 +10255,7 @@ fn foo(set1: Set1) void {At compile-time:
{#code_begin|test_err|test_comptime_incorrect_pointer_alignment|pointer address 0x1 is not aligned to 4 bytes#} comptime { - const ptr = @intToPtr(*align(1) i32, 0x1); + const ptr = @ptrFromInt(*align(1) i32, 0x1); const aligned = @alignCast(4, ptr); _ = aligned; } diff --git a/lib/compiler_rt.zig b/lib/compiler_rt.zig index 1cae2a710ed6..f0503d2219bc 100644 --- a/lib/compiler_rt.zig +++ b/lib/compiler_rt.zig @@ -55,7 +55,7 @@ comptime { _ = @import("compiler_rt/trunctfdf2.zig"); _ = @import("compiler_rt/trunctfxf2.zig"); - _ = @import("compiler_rt/float_to_int.zig"); + _ = @import("compiler_rt/int_from_float.zig"); _ = @import("compiler_rt/fixhfsi.zig"); _ = @import("compiler_rt/fixhfdi.zig"); _ = @import("compiler_rt/fixhfti.zig"); @@ -87,7 +87,7 @@ comptime { _ = @import("compiler_rt/fixunsxfdi.zig"); _ = @import("compiler_rt/fixunsxfti.zig"); - _ = @import("compiler_rt/int_to_float.zig"); + _ = @import("compiler_rt/float_from_int.zig"); _ = @import("compiler_rt/floatsihf.zig"); _ = @import("compiler_rt/floatsisf.zig"); _ = @import("compiler_rt/floatsidf.zig"); diff --git a/lib/compiler_rt/aarch64_outline_atomics.zig b/lib/compiler_rt/aarch64_outline_atomics.zig index 2471a4536552..c70fd81fc487 100644 --- a/lib/compiler_rt/aarch64_outline_atomics.zig +++ b/lib/compiler_rt/aarch64_outline_atomics.zig @@ -8,7 +8,7 @@ const always_has_lse = std.Target.aarch64.featureSetHas(builtin.cpu.features, .l /// It is intentionally not exported in order to make the machine code that /// uses it a statically predicted direct branch rather than using the PLT, /// which ARM is concerned would have too much overhead. -var __aarch64_have_lse_atomics: u8 = @boolToInt(always_has_lse); +var __aarch64_have_lse_atomics: u8 = @intFromBool(always_has_lse); fn __aarch64_cas1_relax() align(16) callconv(.Naked) void { @setRuntimeSafety(false); diff --git a/lib/compiler_rt/atomics.zig b/lib/compiler_rt/atomics.zig index 4b9d5921daf9..de0c777d4505 100644 --- a/lib/compiler_rt/atomics.zig +++ b/lib/compiler_rt/atomics.zig @@ -119,21 +119,21 @@ var spinlocks: SpinlockTable = SpinlockTable{}; fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void { _ = model; - var sl = spinlocks.get(@ptrToInt(src)); + var sl = spinlocks.get(@intFromPtr(src)); defer sl.release(); @memcpy(dest[0..size], src); } fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void { _ = model; - var sl = spinlocks.get(@ptrToInt(dest)); + var sl = spinlocks.get(@intFromPtr(dest)); defer sl.release(); @memcpy(dest[0..size], src); } fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void { _ = model; - var sl = spinlocks.get(@ptrToInt(ptr)); + var sl = spinlocks.get(@intFromPtr(ptr)); defer sl.release(); @memcpy(old[0..size], ptr); @memcpy(ptr[0..size], val); @@ -149,7 +149,7 @@ fn __atomic_compare_exchange( ) callconv(.C) i32 { _ = success; _ = failure; - var sl = spinlocks.get(@ptrToInt(ptr)); + var sl = spinlocks.get(@intFromPtr(ptr)); defer sl.release(); for (ptr[0..size], 0..) |b, i| { if (expected[i] != b) break; @@ -168,7 +168,7 @@ fn __atomic_compare_exchange( inline fn atomic_load_N(comptime T: type, src: *T, model: i32) T { _ = model; if (@sizeOf(T) > largest_atomic_size) { - var sl = spinlocks.get(@ptrToInt(src)); + var sl = spinlocks.get(@intFromPtr(src)); defer sl.release(); return src.*; } else { @@ -199,7 +199,7 @@ fn __atomic_load_16(src: *u128, model: i32) callconv(.C) u128 { inline fn atomic_store_N(comptime T: type, dst: *T, value: T, model: i32) void { _ = model; if (@sizeOf(T) > largest_atomic_size) { - var sl = spinlocks.get(@ptrToInt(dst)); + var sl = spinlocks.get(@intFromPtr(dst)); defer sl.release(); dst.* = value; } else { @@ -230,9 +230,9 @@ fn __atomic_store_16(dst: *u128, value: u128, model: i32) callconv(.C) void { fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T { const WideAtomic = std.meta.Int(.unsigned, smallest_atomic_fetch_exch_size * 8); - const addr = @ptrToInt(ptr); + const addr = @intFromPtr(ptr); const wide_addr = addr & ~(@as(T, smallest_atomic_fetch_exch_size) - 1); - const wide_ptr = @alignCast(smallest_atomic_fetch_exch_size, @intToPtr(*WideAtomic, wide_addr)); + const wide_ptr = @alignCast(smallest_atomic_fetch_exch_size, @ptrFromInt(*WideAtomic, wide_addr)); const inner_offset = addr & (@as(T, smallest_atomic_fetch_exch_size) - 1); const inner_shift = @intCast(std.math.Log2Int(T), inner_offset * 8); @@ -255,7 +255,7 @@ fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T { inline fn atomic_exchange_N(comptime T: type, ptr: *T, val: T, model: i32) T { _ = model; if (@sizeOf(T) > largest_atomic_size) { - var sl = spinlocks.get(@ptrToInt(ptr)); + var sl = spinlocks.get(@intFromPtr(ptr)); defer sl.release(); const value = ptr.*; ptr.* = val; @@ -305,7 +305,7 @@ inline fn atomic_compare_exchange_N( _ = success; _ = failure; if (@sizeOf(T) > largest_atomic_size) { - var sl = spinlocks.get(@ptrToInt(ptr)); + var sl = spinlocks.get(@intFromPtr(ptr)); defer sl.release(); const value = ptr.*; if (value == expected.*) { @@ -362,7 +362,7 @@ inline fn fetch_op_N(comptime T: type, comptime op: std.builtin.AtomicRmwOp, ptr }; if (@sizeOf(T) > largest_atomic_size) { - var sl = spinlocks.get(@ptrToInt(ptr)); + var sl = spinlocks.get(@intFromPtr(ptr)); defer sl.release(); const value = ptr.*; diff --git a/lib/compiler_rt/clear_cache.zig b/lib/compiler_rt/clear_cache.zig index 5038c4061a81..e39d726e0f45 100644 --- a/lib/compiler_rt/clear_cache.zig +++ b/lib/compiler_rt/clear_cache.zig @@ -63,7 +63,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void { .addr = start, .len = end - start, }; - const result = sysarch(ARM_SYNC_ICACHE, @ptrToInt(&arg)); + const result = sysarch(ARM_SYNC_ICACHE, @intFromPtr(&arg)); std.debug.assert(result == 0); exportIt(); }, diff --git a/lib/compiler_rt/cmpdf2.zig b/lib/compiler_rt/cmpdf2.zig index 8a7b37c2c9f0..c01b1c153883 100644 --- a/lib/compiler_rt/cmpdf2.zig +++ b/lib/compiler_rt/cmpdf2.zig @@ -26,7 +26,7 @@ comptime { /// Note that this matches the definition of `__ledf2`, `__eqdf2`, `__nedf2`, `__cmpdf2`, /// and `__ltdf2`. fn __cmpdf2(a: f64, b: f64) callconv(.C) i32 { - return @enumToInt(comparef.cmpf2(f64, comparef.LE, a, b)); + return @intFromEnum(comparef.cmpf2(f64, comparef.LE, a, b)); } /// "These functions return a value less than or equal to zero if neither argument is NaN, @@ -56,13 +56,13 @@ pub fn __ltdf2(a: f64, b: f64) callconv(.C) i32 { } fn __aeabi_dcmpeq(a: f64, b: f64) callconv(.AAPCS) i32 { - return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) == .Equal); + return @intFromBool(comparef.cmpf2(f64, comparef.LE, a, b) == .Equal); } fn __aeabi_dcmplt(a: f64, b: f64) callconv(.AAPCS) i32 { - return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) == .Less); + return @intFromBool(comparef.cmpf2(f64, comparef.LE, a, b) == .Less); } fn __aeabi_dcmple(a: f64, b: f64) callconv(.AAPCS) i32 { - return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) != .Greater); + return @intFromBool(comparef.cmpf2(f64, comparef.LE, a, b) != .Greater); } diff --git a/lib/compiler_rt/cmphf2.zig b/lib/compiler_rt/cmphf2.zig index d801b30ff6e3..67ad7a74b6a3 100644 --- a/lib/compiler_rt/cmphf2.zig +++ b/lib/compiler_rt/cmphf2.zig @@ -20,7 +20,7 @@ comptime { /// Note that this matches the definition of `__lehf2`, `__eqhf2`, `__nehf2`, `__cmphf2`, /// and `__lthf2`. fn __cmphf2(a: f16, b: f16) callconv(.C) i32 { - return @enumToInt(comparef.cmpf2(f16, comparef.LE, a, b)); + return @intFromEnum(comparef.cmpf2(f16, comparef.LE, a, b)); } /// "These functions return a value less than or equal to zero if neither argument is NaN, diff --git a/lib/compiler_rt/cmpsf2.zig b/lib/compiler_rt/cmpsf2.zig index 35e250e8109f..c51792254d38 100644 --- a/lib/compiler_rt/cmpsf2.zig +++ b/lib/compiler_rt/cmpsf2.zig @@ -26,7 +26,7 @@ comptime { /// Note that this matches the definition of `__lesf2`, `__eqsf2`, `__nesf2`, `__cmpsf2`, /// and `__ltsf2`. fn __cmpsf2(a: f32, b: f32) callconv(.C) i32 { - return @enumToInt(comparef.cmpf2(f32, comparef.LE, a, b)); + return @intFromEnum(comparef.cmpf2(f32, comparef.LE, a, b)); } /// "These functions return a value less than or equal to zero if neither argument is NaN, @@ -56,13 +56,13 @@ pub fn __ltsf2(a: f32, b: f32) callconv(.C) i32 { } fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.AAPCS) i32 { - return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Equal); + return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Equal); } fn __aeabi_fcmplt(a: f32, b: f32) callconv(.AAPCS) i32 { - return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Less); + return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Less); } fn __aeabi_fcmple(a: f32, b: f32) callconv(.AAPCS) i32 { - return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) != .Greater); + return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) != .Greater); } diff --git a/lib/compiler_rt/cmptf2.zig b/lib/compiler_rt/cmptf2.zig index bc53afc62531..bee06522929e 100644 --- a/lib/compiler_rt/cmptf2.zig +++ b/lib/compiler_rt/cmptf2.zig @@ -34,7 +34,7 @@ comptime { /// Note that this matches the definition of `__letf2`, `__eqtf2`, `__netf2`, `__cmptf2`, /// and `__lttf2`. fn __cmptf2(a: f128, b: f128) callconv(.C) i32 { - return @enumToInt(comparef.cmpf2(f128, comparef.LE, a, b)); + return @intFromEnum(comparef.cmpf2(f128, comparef.LE, a, b)); } /// "These functions return a value less than or equal to zero if neither argument is NaN, @@ -71,34 +71,34 @@ const SparcFCMP = enum(i32) { }; fn _Qp_cmp(a: *const f128, b: *const f128) callconv(.C) i32 { - return @enumToInt(comparef.cmpf2(f128, SparcFCMP, a.*, b.*)); + return @intFromEnum(comparef.cmpf2(f128, SparcFCMP, a.*, b.*)); } fn _Qp_feq(a: *const f128, b: *const f128) callconv(.C) bool { - return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Equal; + return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) == .Equal; } fn _Qp_fne(a: *const f128, b: *const f128) callconv(.C) bool { - return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) != .Equal; + return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) != .Equal; } fn _Qp_flt(a: *const f128, b: *const f128) callconv(.C) bool { - return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Less; + return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) == .Less; } fn _Qp_fgt(a: *const f128, b: *const f128) callconv(.C) bool { - return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Greater; + return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) == .Greater; } fn _Qp_fge(a: *const f128, b: *const f128) callconv(.C) bool { - return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) { + return switch (@enumFromInt(SparcFCMP, _Qp_cmp(a, b))) { .Equal, .Greater => true, .Less, .Unordered => false, }; } fn _Qp_fle(a: *const f128, b: *const f128) callconv(.C) bool { - return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) { + return switch (@enumFromInt(SparcFCMP, _Qp_cmp(a, b))) { .Equal, .Less => true, .Greater, .Unordered => false, }; diff --git a/lib/compiler_rt/cmpxf2.zig b/lib/compiler_rt/cmpxf2.zig index 75355775bbd7..cd66b1c6c8f7 100644 --- a/lib/compiler_rt/cmpxf2.zig +++ b/lib/compiler_rt/cmpxf2.zig @@ -20,7 +20,7 @@ comptime { /// Note that this matches the definition of `__lexf2`, `__eqxf2`, `__nexf2`, `__cmpxf2`, /// and `__ltxf2`. fn __cmpxf2(a: f80, b: f80) callconv(.C) i32 { - return @enumToInt(comparef.cmp_f80(comparef.LE, a, b)); + return @intFromEnum(comparef.cmp_f80(comparef.LE, a, b)); } /// "These functions return a value less than or equal to zero if neither argument is NaN, diff --git a/lib/compiler_rt/comparef.zig b/lib/compiler_rt/comparef.zig index 1fb6d2dfa059..d4f4e0504d5a 100644 --- a/lib/compiler_rt/comparef.zig +++ b/lib/compiler_rt/comparef.zig @@ -77,7 +77,7 @@ pub inline fn cmp_f80(comptime RT: type, a: f80, b: f80) RT { if ((a_rep.fraction | b_rep.fraction) | ((a_rep.exp | b_rep.exp) & special_exp) == 0) return .Equal; - if (@boolToInt(a_rep.exp == b_rep.exp) & @boolToInt(a_rep.fraction == b_rep.fraction) != 0) { + if (@intFromBool(a_rep.exp == b_rep.exp) & @intFromBool(a_rep.fraction == b_rep.fraction) != 0) { return .Equal; } else if (a_rep.exp & sign_bit != b_rep.exp & sign_bit) { // signs are different @@ -109,7 +109,7 @@ pub inline fn unordcmp(comptime T: type, a: T, b: T) i32 { const aAbs: rep_t = @bitCast(rep_t, a) & absMask; const bAbs: rep_t = @bitCast(rep_t, b) & absMask; - return @boolToInt(aAbs > infRep or bAbs > infRep); + return @intFromBool(aAbs > infRep or bAbs > infRep); } test { diff --git a/lib/compiler_rt/divdf3.zig b/lib/compiler_rt/divdf3.zig index 2f83d312dcc1..c71eed6d0fd7 100644 --- a/lib/compiler_rt/divdf3.zig +++ b/lib/compiler_rt/divdf3.zig @@ -199,7 +199,7 @@ inline fn div(a: f64, b: f64) f64 { } else if (writtenExponent < 1) { if (writtenExponent == 0) { // Check whether the rounded result is normal. - const round = @boolToInt((residual << 1) > bSignificand); + const round = @intFromBool((residual << 1) > bSignificand); // Clear the implicit bit. var absResult = quotient & significandMask; // Round. @@ -213,7 +213,7 @@ inline fn div(a: f64, b: f64) f64 { // code to round them correctly. return @bitCast(f64, quotientSign); } else { - const round = @boolToInt((residual << 1) > bSignificand); + const round = @intFromBool((residual << 1) > bSignificand); // Clear the implicit bit var absResult = quotient & significandMask; // Insert the exponent diff --git a/lib/compiler_rt/divsf3.zig b/lib/compiler_rt/divsf3.zig index 5f051416104b..d35220ca26bf 100644 --- a/lib/compiler_rt/divsf3.zig +++ b/lib/compiler_rt/divsf3.zig @@ -179,7 +179,7 @@ inline fn div(a: f32, b: f32) f32 { } else if (writtenExponent < 1) { if (writtenExponent == 0) { // Check whether the rounded result is normal. - const round = @boolToInt((residual << 1) > bSignificand); + const round = @intFromBool((residual << 1) > bSignificand); // Clear the implicit bit. var absResult = quotient & significandMask; // Round. @@ -193,7 +193,7 @@ inline fn div(a: f32, b: f32) f32 { // code to round them correctly. return @bitCast(f32, quotientSign); } else { - const round = @boolToInt((residual << 1) > bSignificand); + const round = @intFromBool((residual << 1) > bSignificand); // Clear the implicit bit var absResult = quotient & significandMask; // Insert the exponent diff --git a/lib/compiler_rt/divtf3.zig b/lib/compiler_rt/divtf3.zig index 165186b1fba4..86a2f30cc82e 100644 --- a/lib/compiler_rt/divtf3.zig +++ b/lib/compiler_rt/divtf3.zig @@ -214,7 +214,7 @@ inline fn div(a: f128, b: f128) f128 { } else if (writtenExponent < 1) { if (writtenExponent == 0) { // Check whether the rounded result is normal. - const round = @boolToInt((residual << 1) > bSignificand); + const round = @intFromBool((residual << 1) > bSignificand); // Clear the implicit bit. var absResult = quotient & significandMask; // Round. @@ -228,7 +228,7 @@ inline fn div(a: f128, b: f128) f128 { // code to round them correctly. return @bitCast(f128, quotientSign); } else { - const round = @boolToInt((residual << 1) >= bSignificand); + const round = @intFromBool((residual << 1) >= bSignificand); // Clear the implicit bit var absResult = quotient & significandMask; // Insert the exponent diff --git a/lib/compiler_rt/divxf3.zig b/lib/compiler_rt/divxf3.zig index 5fb686cee8ba..f0e93fa3be95 100644 --- a/lib/compiler_rt/divxf3.zig +++ b/lib/compiler_rt/divxf3.zig @@ -195,7 +195,7 @@ pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 { // code to round them correctly. return @bitCast(T, quotientSign); } else { - const round = @boolToInt(residual > (bSignificand >> 1)); + const round = @intFromBool(residual > (bSignificand >> 1)); // Insert the exponent var absResult = quotient | (@intCast(Z, writtenExponent) << significandBits); // Round diff --git a/lib/compiler_rt/exp.zig b/lib/compiler_rt/exp.zig index 24d29ad0bba4..32a1a84ff999 100644 --- a/lib/compiler_rt/exp.zig +++ b/lib/compiler_rt/exp.zig @@ -74,12 +74,12 @@ pub fn expf(x_: f32) callconv(.C) f32 { if (hx > 0x3EB17218) { // |x| > 1.5 * ln2 if (hx > 0x3F851592) { - k = @floatToInt(i32, invln2 * x + half[@intCast(usize, sign)]); + k = @intFromFloat(i32, invln2 * x + half[@intCast(usize, sign)]); } else { k = 1 - sign - sign; } - const fk = @intToFloat(f32, k); + const fk = @floatFromInt(f32, k); hi = x - fk * ln2hi; lo = fk * ln2lo; x = hi - lo; @@ -157,12 +157,12 @@ pub fn exp(x_: f64) callconv(.C) f64 { if (hx > 0x3FD62E42) { // |x| >= 1.5 * ln2 if (hx > 0x3FF0A2B2) { - k = @floatToInt(i32, invln2 * x + half[@intCast(usize, sign)]); + k = @intFromFloat(i32, invln2 * x + half[@intCast(usize, sign)]); } else { k = 1 - sign - sign; } - const dk = @intToFloat(f64, k); + const dk = @floatFromInt(f64, k); hi = x - dk * ln2hi; lo = dk * ln2lo; x = hi - lo; diff --git a/lib/compiler_rt/exp2.zig b/lib/compiler_rt/exp2.zig index 188236752244..731fd7013d46 100644 --- a/lib/compiler_rt/exp2.zig +++ b/lib/compiler_rt/exp2.zig @@ -32,7 +32,7 @@ pub fn __exp2h(x: f16) callconv(.C) f16 { pub fn exp2f(x: f32) callconv(.C) f32 { const tblsiz = @intCast(u32, exp2ft.len); - const redux: f32 = 0x1.8p23 / @intToFloat(f32, tblsiz); + const redux: f32 = 0x1.8p23 / @floatFromInt(f32, tblsiz); const P1: f32 = 0x1.62e430p-1; const P2: f32 = 0x1.ebfbe0p-3; const P3: f32 = 0x1.c6b348p-5; @@ -89,7 +89,7 @@ pub fn exp2f(x: f32) callconv(.C) f32 { pub fn exp2(x: f64) callconv(.C) f64 { const tblsiz: u32 = @intCast(u32, exp2dt.len / 2); - const redux: f64 = 0x1.8p52 / @intToFloat(f64, tblsiz); + const redux: f64 = 0x1.8p52 / @floatFromInt(f64, tblsiz); const P1: f64 = 0x1.62e42fefa39efp-1; const P2: f64 = 0x1.ebfbdff82c575p-3; const P3: f64 = 0x1.c6b08d704a0a6p-5; diff --git a/lib/compiler_rt/fixdfdi.zig b/lib/compiler_rt/fixdfdi.zig index 0329b3cc13b0..23b3876b9145 100644 --- a/lib/compiler_rt/fixdfdi.zig +++ b/lib/compiler_rt/fixdfdi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __fixdfdi(a: f64) callconv(.C) i64 { - return floatToInt(i64, a); + return intFromFloat(i64, a); } fn __aeabi_d2lz(a: f64) callconv(.AAPCS) i64 { - return floatToInt(i64, a); + return intFromFloat(i64, a); } diff --git a/lib/compiler_rt/fixdfsi.zig b/lib/compiler_rt/fixdfsi.zig index 74406171b4b5..09b95332543d 100644 --- a/lib/compiler_rt/fixdfsi.zig +++ b/lib/compiler_rt/fixdfsi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __fixdfsi(a: f64) callconv(.C) i32 { - return floatToInt(i32, a); + return intFromFloat(i32, a); } fn __aeabi_d2iz(a: f64) callconv(.AAPCS) i32 { - return floatToInt(i32, a); + return intFromFloat(i32, a); } diff --git a/lib/compiler_rt/fixdfti.zig b/lib/compiler_rt/fixdfti.zig index ecb4e8912c97..c3513f6becd3 100644 --- a/lib/compiler_rt/fixdfti.zig +++ b/lib/compiler_rt/fixdfti.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -13,11 +13,11 @@ comptime { } pub fn __fixdfti(a: f64) callconv(.C) i128 { - return floatToInt(i128, a); + return intFromFloat(i128, a); } const v2u64 = @Vector(2, u64); fn __fixdfti_windows_x86_64(a: f64) callconv(.C) v2u64 { - return @bitCast(v2u64, floatToInt(i128, a)); + return @bitCast(v2u64, intFromFloat(i128, a)); } diff --git a/lib/compiler_rt/fixhfdi.zig b/lib/compiler_rt/fixhfdi.zig index 3cb1186d7109..21736e2d9a34 100644 --- a/lib/compiler_rt/fixhfdi.zig +++ b/lib/compiler_rt/fixhfdi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __fixhfdi(a: f16) callconv(.C) i64 { - return floatToInt(i64, a); + return intFromFloat(i64, a); } diff --git a/lib/compiler_rt/fixhfsi.zig b/lib/compiler_rt/fixhfsi.zig index 2f24649fb7b8..cd1ae208f87a 100644 --- a/lib/compiler_rt/fixhfsi.zig +++ b/lib/compiler_rt/fixhfsi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __fixhfsi(a: f16) callconv(.C) i32 { - return floatToInt(i32, a); + return intFromFloat(i32, a); } diff --git a/lib/compiler_rt/fixhfti.zig b/lib/compiler_rt/fixhfti.zig index 2865bcad2955..d2b288a52da1 100644 --- a/lib/compiler_rt/fixhfti.zig +++ b/lib/compiler_rt/fixhfti.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -13,11 +13,11 @@ comptime { } pub fn __fixhfti(a: f16) callconv(.C) i128 { - return floatToInt(i128, a); + return intFromFloat(i128, a); } const v2u64 = @Vector(2, u64); fn __fixhfti_windows_x86_64(a: f16) callconv(.C) v2u64 { - return @bitCast(v2u64, floatToInt(i128, a)); + return @bitCast(v2u64, intFromFloat(i128, a)); } diff --git a/lib/compiler_rt/fixsfdi.zig b/lib/compiler_rt/fixsfdi.zig index 4bb63e676851..bbb31f6233a0 100644 --- a/lib/compiler_rt/fixsfdi.zig +++ b/lib/compiler_rt/fixsfdi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __fixsfdi(a: f32) callconv(.C) i64 { - return floatToInt(i64, a); + return intFromFloat(i64, a); } fn __aeabi_f2lz(a: f32) callconv(.AAPCS) i64 { - return floatToInt(i64, a); + return intFromFloat(i64, a); } diff --git a/lib/compiler_rt/fixsfsi.zig b/lib/compiler_rt/fixsfsi.zig index 55eb6e227614..7aa352bbf9b0 100644 --- a/lib/compiler_rt/fixsfsi.zig +++ b/lib/compiler_rt/fixsfsi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __fixsfsi(a: f32) callconv(.C) i32 { - return floatToInt(i32, a); + return intFromFloat(i32, a); } fn __aeabi_f2iz(a: f32) callconv(.AAPCS) i32 { - return floatToInt(i32, a); + return intFromFloat(i32, a); } diff --git a/lib/compiler_rt/fixsfti.zig b/lib/compiler_rt/fixsfti.zig index cd5e524b2041..033e5be5b8cb 100644 --- a/lib/compiler_rt/fixsfti.zig +++ b/lib/compiler_rt/fixsfti.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -13,11 +13,11 @@ comptime { } pub fn __fixsfti(a: f32) callconv(.C) i128 { - return floatToInt(i128, a); + return intFromFloat(i128, a); } const v2u64 = @Vector(2, u64); fn __fixsfti_windows_x86_64(a: f32) callconv(.C) v2u64 { - return @bitCast(v2u64, floatToInt(i128, a)); + return @bitCast(v2u64, intFromFloat(i128, a)); } diff --git a/lib/compiler_rt/fixtfdi.zig b/lib/compiler_rt/fixtfdi.zig index bafcf6d83a87..f65c9eaed14f 100644 --- a/lib/compiler_rt/fixtfdi.zig +++ b/lib/compiler_rt/fixtfdi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __fixtfdi(a: f128) callconv(.C) i64 { - return floatToInt(i64, a); + return intFromFloat(i64, a); } fn _Qp_qtox(a: *const f128) callconv(.C) i64 { - return floatToInt(i64, a.*); + return intFromFloat(i64, a.*); } diff --git a/lib/compiler_rt/fixtfsi.zig b/lib/compiler_rt/fixtfsi.zig index 389f2b117f47..2667b1f6261b 100644 --- a/lib/compiler_rt/fixtfsi.zig +++ b/lib/compiler_rt/fixtfsi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __fixtfsi(a: f128) callconv(.C) i32 { - return floatToInt(i32, a); + return intFromFloat(i32, a); } fn _Qp_qtoi(a: *const f128) callconv(.C) i32 { - return floatToInt(i32, a.*); + return intFromFloat(i32, a.*); } diff --git a/lib/compiler_rt/fixtfti.zig b/lib/compiler_rt/fixtfti.zig index 60b94807b96a..c3f574ed8a1c 100644 --- a/lib/compiler_rt/fixtfti.zig +++ b/lib/compiler_rt/fixtfti.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -15,11 +15,11 @@ comptime { } pub fn __fixtfti(a: f128) callconv(.C) i128 { - return floatToInt(i128, a); + return intFromFloat(i128, a); } const v2u64 = @Vector(2, u64); fn __fixtfti_windows_x86_64(a: f128) callconv(.C) v2u64 { - return @bitCast(v2u64, floatToInt(i128, a)); + return @bitCast(v2u64, intFromFloat(i128, a)); } diff --git a/lib/compiler_rt/fixunsdfdi.zig b/lib/compiler_rt/fixunsdfdi.zig index b544595c7f70..a43ad91ac8a4 100644 --- a/lib/compiler_rt/fixunsdfdi.zig +++ b/lib/compiler_rt/fixunsdfdi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __fixunsdfdi(a: f64) callconv(.C) u64 { - return floatToInt(u64, a); + return intFromFloat(u64, a); } fn __aeabi_d2ulz(a: f64) callconv(.AAPCS) u64 { - return floatToInt(u64, a); + return intFromFloat(u64, a); } diff --git a/lib/compiler_rt/fixunsdfsi.zig b/lib/compiler_rt/fixunsdfsi.zig index 87affbce329c..8af2c5af7eb0 100644 --- a/lib/compiler_rt/fixunsdfsi.zig +++ b/lib/compiler_rt/fixunsdfsi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __fixunsdfsi(a: f64) callconv(.C) u32 { - return floatToInt(u32, a); + return intFromFloat(u32, a); } fn __aeabi_d2uiz(a: f64) callconv(.AAPCS) u32 { - return floatToInt(u32, a); + return intFromFloat(u32, a); } diff --git a/lib/compiler_rt/fixunsdfti.zig b/lib/compiler_rt/fixunsdfti.zig index 242d84176b45..67959fb98afa 100644 --- a/lib/compiler_rt/fixunsdfti.zig +++ b/lib/compiler_rt/fixunsdfti.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -13,11 +13,11 @@ comptime { } pub fn __fixunsdfti(a: f64) callconv(.C) u128 { - return floatToInt(u128, a); + return intFromFloat(u128, a); } const v2u64 = @Vector(2, u64); fn __fixunsdfti_windows_x86_64(a: f64) callconv(.C) v2u64 { - return @bitCast(v2u64, floatToInt(u128, a)); + return @bitCast(v2u64, intFromFloat(u128, a)); } diff --git a/lib/compiler_rt/fixunshfdi.zig b/lib/compiler_rt/fixunshfdi.zig index 9c70df3d5eaa..cd68cab7579f 100644 --- a/lib/compiler_rt/fixunshfdi.zig +++ b/lib/compiler_rt/fixunshfdi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __fixunshfdi(a: f16) callconv(.C) u64 { - return floatToInt(u64, a); + return intFromFloat(u64, a); } diff --git a/lib/compiler_rt/fixunshfsi.zig b/lib/compiler_rt/fixunshfsi.zig index e5070f7a1b29..aa47d7edf71c 100644 --- a/lib/compiler_rt/fixunshfsi.zig +++ b/lib/compiler_rt/fixunshfsi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __fixunshfsi(a: f16) callconv(.C) u32 { - return floatToInt(u32, a); + return intFromFloat(u32, a); } diff --git a/lib/compiler_rt/fixunshfti.zig b/lib/compiler_rt/fixunshfti.zig index 0c67d4998ae1..5e767dc36c1e 100644 --- a/lib/compiler_rt/fixunshfti.zig +++ b/lib/compiler_rt/fixunshfti.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -13,11 +13,11 @@ comptime { } pub fn __fixunshfti(a: f16) callconv(.C) u128 { - return floatToInt(u128, a); + return intFromFloat(u128, a); } const v2u64 = @Vector(2, u64); fn __fixunshfti_windows_x86_64(a: f16) callconv(.C) v2u64 { - return @bitCast(v2u64, floatToInt(u128, a)); + return @bitCast(v2u64, intFromFloat(u128, a)); } diff --git a/lib/compiler_rt/fixunssfdi.zig b/lib/compiler_rt/fixunssfdi.zig index dd883693a7e9..dda6e80c6595 100644 --- a/lib/compiler_rt/fixunssfdi.zig +++ b/lib/compiler_rt/fixunssfdi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __fixunssfdi(a: f32) callconv(.C) u64 { - return floatToInt(u64, a); + return intFromFloat(u64, a); } fn __aeabi_f2ulz(a: f32) callconv(.AAPCS) u64 { - return floatToInt(u64, a); + return intFromFloat(u64, a); } diff --git a/lib/compiler_rt/fixunssfsi.zig b/lib/compiler_rt/fixunssfsi.zig index a071e674ae22..7c935c2731ab 100644 --- a/lib/compiler_rt/fixunssfsi.zig +++ b/lib/compiler_rt/fixunssfsi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __fixunssfsi(a: f32) callconv(.C) u32 { - return floatToInt(u32, a); + return intFromFloat(u32, a); } fn __aeabi_f2uiz(a: f32) callconv(.AAPCS) u32 { - return floatToInt(u32, a); + return intFromFloat(u32, a); } diff --git a/lib/compiler_rt/fixunssfti.zig b/lib/compiler_rt/fixunssfti.zig index ae2a27ab8e83..947164b36906 100644 --- a/lib/compiler_rt/fixunssfti.zig +++ b/lib/compiler_rt/fixunssfti.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -13,11 +13,11 @@ comptime { } pub fn __fixunssfti(a: f32) callconv(.C) u128 { - return floatToInt(u128, a); + return intFromFloat(u128, a); } const v2u64 = @Vector(2, u64); fn __fixunssfti_windows_x86_64(a: f32) callconv(.C) v2u64 { - return @bitCast(v2u64, floatToInt(u128, a)); + return @bitCast(v2u64, intFromFloat(u128, a)); } diff --git a/lib/compiler_rt/fixunstfdi.zig b/lib/compiler_rt/fixunstfdi.zig index 710207b330dc..778388a05caf 100644 --- a/lib/compiler_rt/fixunstfdi.zig +++ b/lib/compiler_rt/fixunstfdi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __fixunstfdi(a: f128) callconv(.C) u64 { - return floatToInt(u64, a); + return intFromFloat(u64, a); } fn _Qp_qtoux(a: *const f128) callconv(.C) u64 { - return floatToInt(u64, a.*); + return intFromFloat(u64, a.*); } diff --git a/lib/compiler_rt/fixunstfsi.zig b/lib/compiler_rt/fixunstfsi.zig index 1b0b64c193a4..aabebccb9918 100644 --- a/lib/compiler_rt/fixunstfsi.zig +++ b/lib/compiler_rt/fixunstfsi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __fixunstfsi(a: f128) callconv(.C) u32 { - return floatToInt(u32, a); + return intFromFloat(u32, a); } fn _Qp_qtoui(a: *const f128) callconv(.C) u32 { - return floatToInt(u32, a.*); + return intFromFloat(u32, a.*); } diff --git a/lib/compiler_rt/fixunstfti.zig b/lib/compiler_rt/fixunstfti.zig index f1f03c23e437..bf9764b1aa09 100644 --- a/lib/compiler_rt/fixunstfti.zig +++ b/lib/compiler_rt/fixunstfti.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -15,11 +15,11 @@ comptime { } pub fn __fixunstfti(a: f128) callconv(.C) u128 { - return floatToInt(u128, a); + return intFromFloat(u128, a); } const v2u64 = @Vector(2, u64); fn __fixunstfti_windows_x86_64(a: f128) callconv(.C) v2u64 { - return @bitCast(v2u64, floatToInt(u128, a)); + return @bitCast(v2u64, intFromFloat(u128, a)); } diff --git a/lib/compiler_rt/fixunsxfdi.zig b/lib/compiler_rt/fixunsxfdi.zig index de1cd138062f..d83cc123f4c0 100644 --- a/lib/compiler_rt/fixunsxfdi.zig +++ b/lib/compiler_rt/fixunsxfdi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __fixunsxfdi(a: f80) callconv(.C) u64 { - return floatToInt(u64, a); + return intFromFloat(u64, a); } diff --git a/lib/compiler_rt/fixunsxfsi.zig b/lib/compiler_rt/fixunsxfsi.zig index 93cdcb2bab8e..8212b5b2c30b 100644 --- a/lib/compiler_rt/fixunsxfsi.zig +++ b/lib/compiler_rt/fixunsxfsi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __fixunsxfsi(a: f80) callconv(.C) u32 { - return floatToInt(u32, a); + return intFromFloat(u32, a); } diff --git a/lib/compiler_rt/fixunsxfti.zig b/lib/compiler_rt/fixunsxfti.zig index a34bd288c098..b9ed4d813284 100644 --- a/lib/compiler_rt/fixunsxfti.zig +++ b/lib/compiler_rt/fixunsxfti.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -13,11 +13,11 @@ comptime { } pub fn __fixunsxfti(a: f80) callconv(.C) u128 { - return floatToInt(u128, a); + return intFromFloat(u128, a); } const v2u64 = @Vector(2, u64); fn __fixunsxfti_windows_x86_64(a: f80) callconv(.C) v2u64 { - return @bitCast(v2u64, floatToInt(u128, a)); + return @bitCast(v2u64, intFromFloat(u128, a)); } diff --git a/lib/compiler_rt/fixxfdi.zig b/lib/compiler_rt/fixxfdi.zig index 096e381629b5..c7510323d64d 100644 --- a/lib/compiler_rt/fixxfdi.zig +++ b/lib/compiler_rt/fixxfdi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __fixxfdi(a: f80) callconv(.C) i64 { - return floatToInt(i64, a); + return intFromFloat(i64, a); } diff --git a/lib/compiler_rt/fixxfsi.zig b/lib/compiler_rt/fixxfsi.zig index b6714d20663b..afcf06e4c996 100644 --- a/lib/compiler_rt/fixxfsi.zig +++ b/lib/compiler_rt/fixxfsi.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __fixxfsi(a: f80) callconv(.C) i32 { - return floatToInt(i32, a); + return intFromFloat(i32, a); } diff --git a/lib/compiler_rt/fixxfti.zig b/lib/compiler_rt/fixxfti.zig index 2e9dbdc2fbc6..c9a32d8ad4db 100644 --- a/lib/compiler_rt/fixxfti.zig +++ b/lib/compiler_rt/fixxfti.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const floatToInt = @import("./float_to_int.zig").floatToInt; +const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; @@ -13,11 +13,11 @@ comptime { } pub fn __fixxfti(a: f80) callconv(.C) i128 { - return floatToInt(i128, a); + return intFromFloat(i128, a); } const v2u64 = @Vector(2, u64); fn __fixxfti_windows_x86_64(a: f80) callconv(.C) v2u64 { - return @bitCast(v2u64, floatToInt(i128, a)); + return @bitCast(v2u64, intFromFloat(i128, a)); } diff --git a/lib/compiler_rt/int_to_float.zig b/lib/compiler_rt/float_from_int.zig similarity index 92% rename from lib/compiler_rt/int_to_float.zig rename to lib/compiler_rt/float_from_int.zig index 2eb7b5ade8ed..8a2c233cba87 100644 --- a/lib/compiler_rt/int_to_float.zig +++ b/lib/compiler_rt/float_from_int.zig @@ -1,7 +1,7 @@ const Int = @import("std").meta.Int; const math = @import("std").math; -pub fn intToFloat(comptime T: type, x: anytype) T { +pub fn floatFromInt(comptime T: type, x: anytype) T { if (x == 0) return 0; // Various constants whose values follow from the type parameters. @@ -38,7 +38,7 @@ pub fn intToFloat(comptime T: type, x: anytype) T { result = @intCast(uT, (abs_val >> (shift_amt - 1))) ^ (implicit_bit << 1); // Round result, including round-to-even for exact ties - result = ((result + 1) >> 1) & ~@as(uT, @boolToInt(exact_tie)); + result = ((result + 1) >> 1) & ~@as(uT, @intFromBool(exact_tie)); } // Compute exponent @@ -54,5 +54,5 @@ pub fn intToFloat(comptime T: type, x: anytype) T { } test { - _ = @import("int_to_float_test.zig"); + _ = @import("float_from_int_test.zig"); } diff --git a/lib/compiler_rt/int_to_float_test.zig b/lib/compiler_rt/float_from_int_test.zig similarity index 95% rename from lib/compiler_rt/int_to_float_test.zig rename to lib/compiler_rt/float_from_int_test.zig index 608a925bf2db..bbc315c74554 100644 --- a/lib/compiler_rt/int_to_float_test.zig +++ b/lib/compiler_rt/float_from_int_test.zig @@ -812,25 +812,25 @@ test "conversion to f32" { test "conversion to f80" { if (std.debug.runtime_safety) return error.SkipZigTest; - const intToFloat = @import("./int_to_float.zig").intToFloat; - - try testing.expect(intToFloat(f80, @as(i80, -12)) == -12); - try testing.expect(@floatToInt(u80, intToFloat(f80, @as(u64, math.maxInt(u64)) + 0)) == math.maxInt(u64) + 0); - try testing.expect(@floatToInt(u80, intToFloat(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1); - - try testing.expect(intToFloat(f80, @as(u32, 0)) == 0.0); - try testing.expect(intToFloat(f80, @as(u32, 1)) == 1.0); - try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u32, math.maxInt(u24)) + 0)) == math.maxInt(u24)); - try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 0)) == math.maxInt(u64)); - try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1); // Exact - try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 2)) == math.maxInt(u64) + 1); // Rounds down - try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 3)) == math.maxInt(u64) + 3); // Tie - Exact - try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 4)) == math.maxInt(u64) + 5); // Rounds up - - try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 0)) == math.maxInt(u65) + 1); // Rounds up - try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 1)) == math.maxInt(u65) + 1); // Exact - try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 2)) == math.maxInt(u65) + 1); // Rounds down - try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 3)) == math.maxInt(u65) + 1); // Tie - Rounds down - try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 4)) == math.maxInt(u65) + 5); // Rounds up - try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 5)) == math.maxInt(u65) + 5); // Exact + const floatFromInt = @import("./float_from_int.zig").floatFromInt; + + try testing.expect(floatFromInt(f80, @as(i80, -12)) == -12); + try testing.expect(@intFromFloat(u80, floatFromInt(f80, @as(u64, math.maxInt(u64)) + 0)) == math.maxInt(u64) + 0); + try testing.expect(@intFromFloat(u80, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1); + + try testing.expect(floatFromInt(f80, @as(u32, 0)) == 0.0); + try testing.expect(floatFromInt(f80, @as(u32, 1)) == 1.0); + try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u32, math.maxInt(u24)) + 0)) == math.maxInt(u24)); + try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 0)) == math.maxInt(u64)); + try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1); // Exact + try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 2)) == math.maxInt(u64) + 1); // Rounds down + try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 3)) == math.maxInt(u64) + 3); // Tie - Exact + try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 4)) == math.maxInt(u64) + 5); // Rounds up + + try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 0)) == math.maxInt(u65) + 1); // Rounds up + try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 1)) == math.maxInt(u65) + 1); // Exact + try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 2)) == math.maxInt(u65) + 1); // Rounds down + try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 3)) == math.maxInt(u65) + 1); // Tie - Rounds down + try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 4)) == math.maxInt(u65) + 5); // Rounds up + try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 5)) == math.maxInt(u65) + 5); // Exact } diff --git a/lib/compiler_rt/floatdidf.zig b/lib/compiler_rt/floatdidf.zig index 9b9df4ae7016..3615e8903595 100644 --- a/lib/compiler_rt/floatdidf.zig +++ b/lib/compiler_rt/floatdidf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __floatdidf(a: i64) callconv(.C) f64 { - return intToFloat(f64, a); + return floatFromInt(f64, a); } fn __aeabi_l2d(a: i64) callconv(.AAPCS) f64 { - return intToFloat(f64, a); + return floatFromInt(f64, a); } diff --git a/lib/compiler_rt/floatdihf.zig b/lib/compiler_rt/floatdihf.zig index 1db7a0eac670..4d01d5c2e0b0 100644 --- a/lib/compiler_rt/floatdihf.zig +++ b/lib/compiler_rt/floatdihf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __floatdihf(a: i64) callconv(.C) f16 { - return intToFloat(f16, a); + return floatFromInt(f16, a); } diff --git a/lib/compiler_rt/floatdisf.zig b/lib/compiler_rt/floatdisf.zig index 3bdcc60f20fd..1a1b5fc6d756 100644 --- a/lib/compiler_rt/floatdisf.zig +++ b/lib/compiler_rt/floatdisf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __floatdisf(a: i64) callconv(.C) f32 { - return intToFloat(f32, a); + return floatFromInt(f32, a); } fn __aeabi_l2f(a: i64) callconv(.AAPCS) f32 { - return intToFloat(f32, a); + return floatFromInt(f32, a); } diff --git a/lib/compiler_rt/floatditf.zig b/lib/compiler_rt/floatditf.zig index 173dd79f753e..5f0c49c12940 100644 --- a/lib/compiler_rt/floatditf.zig +++ b/lib/compiler_rt/floatditf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __floatditf(a: i64) callconv(.C) f128 { - return intToFloat(f128, a); + return floatFromInt(f128, a); } fn _Qp_xtoq(c: *f128, a: i64) callconv(.C) void { - c.* = intToFloat(f128, a); + c.* = floatFromInt(f128, a); } diff --git a/lib/compiler_rt/floatdixf.zig b/lib/compiler_rt/floatdixf.zig index c4fc9ca28f9f..b4d250b27733 100644 --- a/lib/compiler_rt/floatdixf.zig +++ b/lib/compiler_rt/floatdixf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __floatdixf(a: i64) callconv(.C) f80 { - return intToFloat(f80, a); + return floatFromInt(f80, a); } diff --git a/lib/compiler_rt/floatsidf.zig b/lib/compiler_rt/floatsidf.zig index 7ec7d90fbada..8402c5726b0f 100644 --- a/lib/compiler_rt/floatsidf.zig +++ b/lib/compiler_rt/floatsidf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __floatsidf(a: i32) callconv(.C) f64 { - return intToFloat(f64, a); + return floatFromInt(f64, a); } fn __aeabi_i2d(a: i32) callconv(.AAPCS) f64 { - return intToFloat(f64, a); + return floatFromInt(f64, a); } diff --git a/lib/compiler_rt/floatsihf.zig b/lib/compiler_rt/floatsihf.zig index 0a08c19847e1..889fa3c33f75 100644 --- a/lib/compiler_rt/floatsihf.zig +++ b/lib/compiler_rt/floatsihf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __floatsihf(a: i32) callconv(.C) f16 { - return intToFloat(f16, a); + return floatFromInt(f16, a); } diff --git a/lib/compiler_rt/floatsisf.zig b/lib/compiler_rt/floatsisf.zig index daddfb06e154..907c7a554da0 100644 --- a/lib/compiler_rt/floatsisf.zig +++ b/lib/compiler_rt/floatsisf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __floatsisf(a: i32) callconv(.C) f32 { - return intToFloat(f32, a); + return floatFromInt(f32, a); } fn __aeabi_i2f(a: i32) callconv(.AAPCS) f32 { - return intToFloat(f32, a); + return floatFromInt(f32, a); } diff --git a/lib/compiler_rt/floatsitf.zig b/lib/compiler_rt/floatsitf.zig index 9739b912803c..2553de5f1892 100644 --- a/lib/compiler_rt/floatsitf.zig +++ b/lib/compiler_rt/floatsitf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __floatsitf(a: i32) callconv(.C) f128 { - return intToFloat(f128, a); + return floatFromInt(f128, a); } fn _Qp_itoq(c: *f128, a: i32) callconv(.C) void { - c.* = intToFloat(f128, a); + c.* = floatFromInt(f128, a); } diff --git a/lib/compiler_rt/floatsixf.zig b/lib/compiler_rt/floatsixf.zig index a9d3709911eb..fe63f1c0a8d9 100644 --- a/lib/compiler_rt/floatsixf.zig +++ b/lib/compiler_rt/floatsixf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __floatsixf(a: i32) callconv(.C) f80 { - return intToFloat(f80, a); + return floatFromInt(f80, a); } diff --git a/lib/compiler_rt/floattidf.zig b/lib/compiler_rt/floattidf.zig index d70fedbfc301..c42e8f29744d 100644 --- a/lib/compiler_rt/floattidf.zig +++ b/lib/compiler_rt/floattidf.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __floattidf(a: i128) callconv(.C) f64 { - return intToFloat(f64, a); + return floatFromInt(f64, a); } fn __floattidf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f64 { - return intToFloat(f64, @bitCast(i128, a)); + return floatFromInt(f64, @bitCast(i128, a)); } diff --git a/lib/compiler_rt/floattihf.zig b/lib/compiler_rt/floattihf.zig index f90a57d1e0ba..90003660ecf1 100644 --- a/lib/compiler_rt/floattihf.zig +++ b/lib/compiler_rt/floattihf.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __floattihf(a: i128) callconv(.C) f16 { - return intToFloat(f16, a); + return floatFromInt(f16, a); } fn __floattihf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f16 { - return intToFloat(f16, @bitCast(i128, a)); + return floatFromInt(f16, @bitCast(i128, a)); } diff --git a/lib/compiler_rt/floattisf.zig b/lib/compiler_rt/floattisf.zig index 737e1ec40950..09c0b12ed082 100644 --- a/lib/compiler_rt/floattisf.zig +++ b/lib/compiler_rt/floattisf.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __floattisf(a: i128) callconv(.C) f32 { - return intToFloat(f32, a); + return floatFromInt(f32, a); } fn __floattisf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f32 { - return intToFloat(f32, @bitCast(i128, a)); + return floatFromInt(f32, @bitCast(i128, a)); } diff --git a/lib/compiler_rt/floattitf.zig b/lib/compiler_rt/floattitf.zig index d14264fb0427..ae0ecbb98aed 100644 --- a/lib/compiler_rt/floattitf.zig +++ b/lib/compiler_rt/floattitf.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -15,9 +15,9 @@ comptime { } pub fn __floattitf(a: i128) callconv(.C) f128 { - return intToFloat(f128, a); + return floatFromInt(f128, a); } fn __floattitf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f128 { - return intToFloat(f128, @bitCast(i128, a)); + return floatFromInt(f128, @bitCast(i128, a)); } diff --git a/lib/compiler_rt/floattixf.zig b/lib/compiler_rt/floattixf.zig index 1af4f83965fb..9c2339ff8a40 100644 --- a/lib/compiler_rt/floattixf.zig +++ b/lib/compiler_rt/floattixf.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __floattixf(a: i128) callconv(.C) f80 { - return intToFloat(f80, a); + return floatFromInt(f80, a); } fn __floattixf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f80 { - return intToFloat(f80, @bitCast(i128, a)); + return floatFromInt(f80, @bitCast(i128, a)); } diff --git a/lib/compiler_rt/floatundidf.zig b/lib/compiler_rt/floatundidf.zig index db4cc6505e1f..b158fb546d5c 100644 --- a/lib/compiler_rt/floatundidf.zig +++ b/lib/compiler_rt/floatundidf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __floatundidf(a: u64) callconv(.C) f64 { - return intToFloat(f64, a); + return floatFromInt(f64, a); } fn __aeabi_ul2d(a: u64) callconv(.AAPCS) f64 { - return intToFloat(f64, a); + return floatFromInt(f64, a); } diff --git a/lib/compiler_rt/floatundihf.zig b/lib/compiler_rt/floatundihf.zig index e6c6a79d5e72..1c534c91757e 100644 --- a/lib/compiler_rt/floatundihf.zig +++ b/lib/compiler_rt/floatundihf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __floatundihf(a: u64) callconv(.C) f16 { - return intToFloat(f16, a); + return floatFromInt(f16, a); } diff --git a/lib/compiler_rt/floatundisf.zig b/lib/compiler_rt/floatundisf.zig index eb17c0f657de..c9dffa7e36fc 100644 --- a/lib/compiler_rt/floatundisf.zig +++ b/lib/compiler_rt/floatundisf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __floatundisf(a: u64) callconv(.C) f32 { - return intToFloat(f32, a); + return floatFromInt(f32, a); } fn __aeabi_ul2f(a: u64) callconv(.AAPCS) f32 { - return intToFloat(f32, a); + return floatFromInt(f32, a); } diff --git a/lib/compiler_rt/floatunditf.zig b/lib/compiler_rt/floatunditf.zig index 0bfa36d6e185..d573d095bc6f 100644 --- a/lib/compiler_rt/floatunditf.zig +++ b/lib/compiler_rt/floatunditf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __floatunditf(a: u64) callconv(.C) f128 { - return intToFloat(f128, a); + return floatFromInt(f128, a); } fn _Qp_uxtoq(c: *f128, a: u64) callconv(.C) void { - c.* = intToFloat(f128, a); + c.* = floatFromInt(f128, a); } diff --git a/lib/compiler_rt/floatundixf.zig b/lib/compiler_rt/floatundixf.zig index 22f885167f32..33836f3ccb13 100644 --- a/lib/compiler_rt/floatundixf.zig +++ b/lib/compiler_rt/floatundixf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __floatundixf(a: u64) callconv(.C) f80 { - return intToFloat(f80, a); + return floatFromInt(f80, a); } diff --git a/lib/compiler_rt/floatunsidf.zig b/lib/compiler_rt/floatunsidf.zig index ef5bce2afaef..3ffd79655aa7 100644 --- a/lib/compiler_rt/floatunsidf.zig +++ b/lib/compiler_rt/floatunsidf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __floatunsidf(a: u32) callconv(.C) f64 { - return intToFloat(f64, a); + return floatFromInt(f64, a); } fn __aeabi_ui2d(a: u32) callconv(.AAPCS) f64 { - return intToFloat(f64, a); + return floatFromInt(f64, a); } diff --git a/lib/compiler_rt/floatunsihf.zig b/lib/compiler_rt/floatunsihf.zig index 0b43d61f4cc2..fcfbbaf64609 100644 --- a/lib/compiler_rt/floatunsihf.zig +++ b/lib/compiler_rt/floatunsihf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } pub fn __floatunsihf(a: u32) callconv(.C) f16 { - return intToFloat(f16, a); + return floatFromInt(f16, a); } diff --git a/lib/compiler_rt/floatunsisf.zig b/lib/compiler_rt/floatunsisf.zig index f85d1bb01371..b7cc567ff04e 100644 --- a/lib/compiler_rt/floatunsisf.zig +++ b/lib/compiler_rt/floatunsisf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -12,9 +12,9 @@ comptime { } pub fn __floatunsisf(a: u32) callconv(.C) f32 { - return intToFloat(f32, a); + return floatFromInt(f32, a); } fn __aeabi_ui2f(a: u32) callconv(.AAPCS) f32 { - return intToFloat(f32, a); + return floatFromInt(f32, a); } diff --git a/lib/compiler_rt/floatunsitf.zig b/lib/compiler_rt/floatunsitf.zig index ef9593cdf600..0414784b83bf 100644 --- a/lib/compiler_rt/floatunsitf.zig +++ b/lib/compiler_rt/floatunsitf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __floatunsitf(a: u32) callconv(.C) f128 { - return intToFloat(f128, a); + return floatFromInt(f128, a); } fn _Qp_uitoq(c: *f128, a: u32) callconv(.C) void { - c.* = intToFloat(f128, a); + c.* = floatFromInt(f128, a); } diff --git a/lib/compiler_rt/floatunsixf.zig b/lib/compiler_rt/floatunsixf.zig index cd402e227ded..866f3f8c475d 100644 --- a/lib/compiler_rt/floatunsixf.zig +++ b/lib/compiler_rt/floatunsixf.zig @@ -1,5 +1,5 @@ const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -8,5 +8,5 @@ comptime { } fn __floatunsixf(a: u32) callconv(.C) f80 { - return intToFloat(f80, a); + return floatFromInt(f80, a); } diff --git a/lib/compiler_rt/floatuntidf.zig b/lib/compiler_rt/floatuntidf.zig index d3a685a1ce16..a2b46506f045 100644 --- a/lib/compiler_rt/floatuntidf.zig +++ b/lib/compiler_rt/floatuntidf.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __floatuntidf(a: u128) callconv(.C) f64 { - return intToFloat(f64, a); + return floatFromInt(f64, a); } fn __floatuntidf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f64 { - return intToFloat(f64, @bitCast(u128, a)); + return floatFromInt(f64, @bitCast(u128, a)); } diff --git a/lib/compiler_rt/floatuntihf.zig b/lib/compiler_rt/floatuntihf.zig index 9102960e8d70..f493453c91d2 100644 --- a/lib/compiler_rt/floatuntihf.zig +++ b/lib/compiler_rt/floatuntihf.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __floatuntihf(a: u128) callconv(.C) f16 { - return intToFloat(f16, a); + return floatFromInt(f16, a); } fn __floatuntihf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f16 { - return intToFloat(f16, @bitCast(u128, a)); + return floatFromInt(f16, @bitCast(u128, a)); } diff --git a/lib/compiler_rt/floatuntisf.zig b/lib/compiler_rt/floatuntisf.zig index 7ee013339d70..9df7b833eafa 100644 --- a/lib/compiler_rt/floatuntisf.zig +++ b/lib/compiler_rt/floatuntisf.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __floatuntisf(a: u128) callconv(.C) f32 { - return intToFloat(f32, a); + return floatFromInt(f32, a); } fn __floatuntisf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f32 { - return intToFloat(f32, @bitCast(u128, a)); + return floatFromInt(f32, @bitCast(u128, a)); } diff --git a/lib/compiler_rt/floatuntitf.zig b/lib/compiler_rt/floatuntitf.zig index 41e715e01399..55a5ab4da111 100644 --- a/lib/compiler_rt/floatuntitf.zig +++ b/lib/compiler_rt/floatuntitf.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -15,9 +15,9 @@ comptime { } pub fn __floatuntitf(a: u128) callconv(.C) f128 { - return intToFloat(f128, a); + return floatFromInt(f128, a); } fn __floatuntitf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f128 { - return intToFloat(f128, @bitCast(u128, a)); + return floatFromInt(f128, @bitCast(u128, a)); } diff --git a/lib/compiler_rt/floatuntixf.zig b/lib/compiler_rt/floatuntixf.zig index 877203bd223f..cbf597ca8946 100644 --- a/lib/compiler_rt/floatuntixf.zig +++ b/lib/compiler_rt/floatuntixf.zig @@ -1,6 +1,6 @@ const builtin = @import("builtin"); const common = @import("./common.zig"); -const intToFloat = @import("./int_to_float.zig").intToFloat; +const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; @@ -13,9 +13,9 @@ comptime { } pub fn __floatuntixf(a: u128) callconv(.C) f80 { - return intToFloat(f80, a); + return floatFromInt(f80, a); } fn __floatuntixf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f80 { - return intToFloat(f80, @bitCast(u128, a)); + return floatFromInt(f80, @bitCast(u128, a)); } diff --git a/lib/compiler_rt/gedf2.zig b/lib/compiler_rt/gedf2.zig index c887a9b6e4ff..0ade0cf46a61 100644 --- a/lib/compiler_rt/gedf2.zig +++ b/lib/compiler_rt/gedf2.zig @@ -18,7 +18,7 @@ comptime { /// "These functions return a value greater than or equal to zero if neither /// argument is NaN, and a is greater than or equal to b." pub fn __gedf2(a: f64, b: f64) callconv(.C) i32 { - return @enumToInt(comparef.cmpf2(f64, comparef.GE, a, b)); + return @intFromEnum(comparef.cmpf2(f64, comparef.GE, a, b)); } /// "These functions return a value greater than zero if neither argument is NaN, @@ -28,9 +28,9 @@ pub fn __gtdf2(a: f64, b: f64) callconv(.C) i32 { } fn __aeabi_dcmpge(a: f64, b: f64) callconv(.AAPCS) i32 { - return @boolToInt(comparef.cmpf2(f64, comparef.GE, a, b) != .Less); + return @intFromBool(comparef.cmpf2(f64, comparef.GE, a, b) != .Less); } fn __aeabi_dcmpgt(a: f64, b: f64) callconv(.AAPCS) i32 { - return @boolToInt(comparef.cmpf2(f64, comparef.GE, a, b) == .Greater); + return @intFromBool(comparef.cmpf2(f64, comparef.GE, a, b) == .Greater); } diff --git a/lib/compiler_rt/gehf2.zig b/lib/compiler_rt/gehf2.zig index 6bea4e164a61..c6e7b90a65b3 100644 --- a/lib/compiler_rt/gehf2.zig +++ b/lib/compiler_rt/gehf2.zig @@ -13,7 +13,7 @@ comptime { /// "These functions return a value greater than or equal to zero if neither /// argument is NaN, and a is greater than or equal to b." pub fn __gehf2(a: f16, b: f16) callconv(.C) i32 { - return @enumToInt(comparef.cmpf2(f16, comparef.GE, a, b)); + return @intFromEnum(comparef.cmpf2(f16, comparef.GE, a, b)); } /// "These functions return a value greater than zero if neither argument is NaN, diff --git a/lib/compiler_rt/gesf2.zig b/lib/compiler_rt/gesf2.zig index 44439976bbea..44d8b5cc7582 100644 --- a/lib/compiler_rt/gesf2.zig +++ b/lib/compiler_rt/gesf2.zig @@ -18,7 +18,7 @@ comptime { /// "These functions return a value greater than or equal to zero if neither /// argument is NaN, and a is greater than or equal to b." pub fn __gesf2(a: f32, b: f32) callconv(.C) i32 { - return @enumToInt(comparef.cmpf2(f32, comparef.GE, a, b)); + return @intFromEnum(comparef.cmpf2(f32, comparef.GE, a, b)); } /// "These functions return a value greater than zero if neither argument is NaN, @@ -28,9 +28,9 @@ pub fn __gtsf2(a: f32, b: f32) callconv(.C) i32 { } fn __aeabi_fcmpge(a: f32, b: f32) callconv(.AAPCS) i32 { - return @boolToInt(comparef.cmpf2(f32, comparef.GE, a, b) != .Less); + return @intFromBool(comparef.cmpf2(f32, comparef.GE, a, b) != .Less); } fn __aeabi_fcmpgt(a: f32, b: f32) callconv(.AAPCS) i32 { - return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Greater); + return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Greater); } diff --git a/lib/compiler_rt/getf2.zig b/lib/compiler_rt/getf2.zig index 1a5c06af3d73..07e87ed55cd0 100644 --- a/lib/compiler_rt/getf2.zig +++ b/lib/compiler_rt/getf2.zig @@ -20,7 +20,7 @@ comptime { /// "These functions return a value greater than or equal to zero if neither /// argument is NaN, and a is greater than or equal to b." fn __getf2(a: f128, b: f128) callconv(.C) i32 { - return @enumToInt(comparef.cmpf2(f128, comparef.GE, a, b)); + return @intFromEnum(comparef.cmpf2(f128, comparef.GE, a, b)); } /// "These functions return a value greater than zero if neither argument is NaN, diff --git a/lib/compiler_rt/gexf2.zig b/lib/compiler_rt/gexf2.zig index bf0b0edccb07..94f735b8c292 100644 --- a/lib/compiler_rt/gexf2.zig +++ b/lib/compiler_rt/gexf2.zig @@ -9,7 +9,7 @@ comptime { } fn __gexf2(a: f80, b: f80) callconv(.C) i32 { - return @enumToInt(comparef.cmp_f80(comparef.GE, a, b)); + return @intFromEnum(comparef.cmp_f80(comparef.GE, a, b)); } fn __gtxf2(a: f80, b: f80) callconv(.C) i32 { diff --git a/lib/compiler_rt/float_to_int.zig b/lib/compiler_rt/int_from_float.zig similarity index 94% rename from lib/compiler_rt/float_to_int.zig rename to lib/compiler_rt/int_from_float.zig index 6fc7286f6858..78397a813108 100644 --- a/lib/compiler_rt/float_to_int.zig +++ b/lib/compiler_rt/int_from_float.zig @@ -2,7 +2,7 @@ const Int = @import("std").meta.Int; const math = @import("std").math; const Log2Int = math.Log2Int; -pub inline fn floatToInt(comptime I: type, a: anytype) I { +pub inline fn intFromFloat(comptime I: type, a: anytype) I { const F = @TypeOf(a); const float_bits = @typeInfo(F).Float.bits; const int_bits = @typeInfo(I).Int.bits; @@ -51,5 +51,5 @@ pub inline fn floatToInt(comptime I: type, a: anytype) I { } test { - _ = @import("float_to_int_test.zig"); + _ = @import("int_from_float_test.zig"); } diff --git a/lib/compiler_rt/float_to_int_test.zig b/lib/compiler_rt/int_from_float_test.zig similarity index 100% rename from lib/compiler_rt/float_to_int_test.zig rename to lib/compiler_rt/int_from_float_test.zig diff --git a/lib/compiler_rt/log.zig b/lib/compiler_rt/log.zig index 71d90f7c3a7c..622d509a2f86 100644 --- a/lib/compiler_rt/log.zig +++ b/lib/compiler_rt/log.zig @@ -77,7 +77,7 @@ pub fn logf(x_: f32) callconv(.C) f32 { const t2 = z * (Lg1 + w * Lg3); const R = t2 + t1; const hfsq = 0.5 * f * f; - const dk = @intToFloat(f32, k); + const dk = @floatFromInt(f32, k); return s * (hfsq + R) + dk * ln2_lo - hfsq + f + dk * ln2_hi; } @@ -133,7 +133,7 @@ pub fn log(x_: f64) callconv(.C) f64 { const t1 = w * (Lg2 + w * (Lg4 + w * Lg6)); const t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7))); const R = t2 + t1; - const dk = @intToFloat(f64, k); + const dk = @floatFromInt(f64, k); return s * (hfsq + R) + dk * ln2_lo - hfsq + f + dk * ln2_hi; } diff --git a/lib/compiler_rt/log10.zig b/lib/compiler_rt/log10.zig index 5c345ff12f70..d45a3d8a40cd 100644 --- a/lib/compiler_rt/log10.zig +++ b/lib/compiler_rt/log10.zig @@ -86,7 +86,7 @@ pub fn log10f(x_: f32) callconv(.C) f32 { u &= 0xFFFFF000; hi = @bitCast(f32, u); const lo = f - hi - hfsq + s * (hfsq + R); - const dk = @intToFloat(f32, k); + const dk = @floatFromInt(f32, k); return dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi + hi * ivln10hi + dk * log10_2hi; } @@ -154,7 +154,7 @@ pub fn log10(x_: f64) callconv(.C) f64 { // val_hi + val_lo ~ log10(1 + f) + k * log10(2) var val_hi = hi * ivln10hi; - const dk = @intToFloat(f64, k); + const dk = @floatFromInt(f64, k); const y = dk * log10_2hi; var val_lo = dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi; diff --git a/lib/compiler_rt/log2.zig b/lib/compiler_rt/log2.zig index 612c97859866..29595d07d9aa 100644 --- a/lib/compiler_rt/log2.zig +++ b/lib/compiler_rt/log2.zig @@ -84,7 +84,7 @@ pub fn log2f(x_: f32) callconv(.C) f32 { u &= 0xFFFFF000; hi = @bitCast(f32, u); const lo = f - hi - hfsq + s * (hfsq + R); - return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + @intToFloat(f32, k); + return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + @floatFromInt(f32, k); } pub fn log2(x_: f64) callconv(.C) f64 { @@ -150,7 +150,7 @@ pub fn log2(x_: f64) callconv(.C) f64 { var val_lo = (lo + hi) * ivln2lo + lo * ivln2hi; // spadd(val_hi, val_lo, y) - const y = @intToFloat(f64, k); + const y = @floatFromInt(f64, k); const ww = y + val_hi; val_lo += (y - ww) + val_hi; val_hi = ww; diff --git a/lib/compiler_rt/memmove.zig b/lib/compiler_rt/memmove.zig index 61ccb1205d2d..bb772b3217f9 100644 --- a/lib/compiler_rt/memmove.zig +++ b/lib/compiler_rt/memmove.zig @@ -8,7 +8,7 @@ comptime { pub fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8 { @setRuntimeSafety(false); - if (@ptrToInt(dest) < @ptrToInt(src)) { + if (@intFromPtr(dest) < @intFromPtr(src)) { var index: usize = 0; while (index != n) : (index += 1) { dest.?[index] = src.?[index]; diff --git a/lib/compiler_rt/mulf3.zig b/lib/compiler_rt/mulf3.zig index b02bd81671db..9652782a4968 100644 --- a/lib/compiler_rt/mulf3.zig +++ b/lib/compiler_rt/mulf3.zig @@ -126,7 +126,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T { // Otherwise, shift the significand of the result so that the round // bit is the high bit of productLo. const sticky = wideShrWithTruncation(ZSignificand, &productHi, &productLo, shift); - productLo |= @boolToInt(sticky); + productLo |= @intFromBool(sticky); result = productHi; // We include the integer bit so that rounding will carry to the exponent, diff --git a/lib/compiler_rt/os_version_check.zig b/lib/compiler_rt/os_version_check.zig index 2c6cdb54dc3a..187bb4ff3565 100644 --- a/lib/compiler_rt/os_version_check.zig +++ b/lib/compiler_rt/os_version_check.zig @@ -36,7 +36,7 @@ const __isPlatformVersionAtLeast = if (builtin.os.tag.isDarwin()) struct { .platform = platform, .version = constructVersion(major, minor, subminor), }; - return @boolToInt(_availability_version_check(1, &[_]dyld_build_version_t{build_version})); + return @intFromBool(_availability_version_check(1, &[_]dyld_build_version_t{build_version})); } // _availability_version_check darwin API support. diff --git a/lib/compiler_rt/paritydi2_test.zig b/lib/compiler_rt/paritydi2_test.zig index a13abda5feef..1cf587b1efcc 100644 --- a/lib/compiler_rt/paritydi2_test.zig +++ b/lib/compiler_rt/paritydi2_test.zig @@ -9,7 +9,7 @@ fn paritydi2Naive(a: i64) i32 { has_parity = !has_parity; x = x & (x - 1); } - return @intCast(i32, @boolToInt(has_parity)); + return @intCast(i32, @intFromBool(has_parity)); } fn test__paritydi2(a: i64) !void { diff --git a/lib/compiler_rt/paritysi2_test.zig b/lib/compiler_rt/paritysi2_test.zig index f63854e34f07..c1bac5eaaec6 100644 --- a/lib/compiler_rt/paritysi2_test.zig +++ b/lib/compiler_rt/paritysi2_test.zig @@ -9,7 +9,7 @@ fn paritysi2Naive(a: i32) i32 { has_parity = !has_parity; x = x & (x - 1); } - return @intCast(i32, @boolToInt(has_parity)); + return @intCast(i32, @intFromBool(has_parity)); } fn test__paritysi2(a: i32) !void { diff --git a/lib/compiler_rt/parityti2_test.zig b/lib/compiler_rt/parityti2_test.zig index e01893255549..8a869fe7182f 100644 --- a/lib/compiler_rt/parityti2_test.zig +++ b/lib/compiler_rt/parityti2_test.zig @@ -9,7 +9,7 @@ fn parityti2Naive(a: i128) i32 { has_parity = !has_parity; x = x & (x - 1); } - return @intCast(i32, @boolToInt(has_parity)); + return @intCast(i32, @intFromBool(has_parity)); } fn test__parityti2(a: i128) !void { diff --git a/lib/compiler_rt/rem_pio2.zig b/lib/compiler_rt/rem_pio2.zig index 73d477ee12b3..315a99c308c1 100644 --- a/lib/compiler_rt/rem_pio2.zig +++ b/lib/compiler_rt/rem_pio2.zig @@ -41,7 +41,7 @@ fn medium(ix: u32, x: f64, y: *[2]f64) i32 { // rint(x/(pi/2)) @"fn" = x * invpio2 + toint - toint; - n = @floatToInt(i32, @"fn"); + n = @intFromFloat(i32, @"fn"); r = x - @"fn" * pio2_1; w = @"fn" * pio2_1t; // 1st round, good to 85 bits // Matters with directed rounding. @@ -178,7 +178,7 @@ pub fn rem_pio2(x: f64, y: *[2]f64) i32 { i = 0; while (i < 2) : (i += 1) { - tx[U(i)] = @intToFloat(f64, @floatToInt(i32, z)); + tx[U(i)] = @floatFromInt(f64, @intFromFloat(i32, z)); z = (z - tx[U(i)]) * 0x1p24; } tx[U(i)] = z; diff --git a/lib/compiler_rt/rem_pio2_large.zig b/lib/compiler_rt/rem_pio2_large.zig index c8a53b741c07..afded1838736 100644 --- a/lib/compiler_rt/rem_pio2_large.zig +++ b/lib/compiler_rt/rem_pio2_large.zig @@ -295,7 +295,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 { i += 1; j += 1; }) { - f[U(i)] = if (j < 0) 0.0 else @intToFloat(f64, ipio2[U(j)]); + f[U(i)] = if (j < 0) 0.0 else @floatFromInt(f64, ipio2[U(j)]); } // compute q[0],q[1],...q[jk] @@ -322,16 +322,16 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 { i += 1; j -= 1; }) { - fw = @intToFloat(f64, @floatToInt(i32, 0x1p-24 * z)); - iq[U(i)] = @floatToInt(i32, z - 0x1p24 * fw); + fw = @floatFromInt(f64, @intFromFloat(i32, 0x1p-24 * z)); + iq[U(i)] = @intFromFloat(i32, z - 0x1p24 * fw); z = q[U(j - 1)] + fw; } // compute n z = math.scalbn(z, q0); // actual value of z z -= 8.0 * @floor(z * 0.125); // trim off integer >= 8 - n = @floatToInt(i32, z); - z -= @intToFloat(f64, n); + n = @intFromFloat(i32, z); + z -= @floatFromInt(f64, n); ih = 0; if (q0 > 0) { // need iq[jz-1] to determine n i = iq[U(jz - 1)] >> @intCast(u5, 24 - q0); @@ -390,7 +390,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 { i = jz + 1; while (i <= jz + k) : (i += 1) { // add q[jz+1] to q[jz+k] - f[U(jx + i)] = @intToFloat(f64, ipio2[U(jv + i)]); + f[U(jx + i)] = @floatFromInt(f64, ipio2[U(jv + i)]); j = 0; fw = 0; while (j <= jx) : (j += 1) { @@ -414,13 +414,13 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 { } else { // break z into 24-bit if necessary z = math.scalbn(z, -q0); if (z >= 0x1p24) { - fw = @intToFloat(f64, @floatToInt(i32, 0x1p-24 * z)); - iq[U(jz)] = @floatToInt(i32, z - 0x1p24 * fw); + fw = @floatFromInt(f64, @intFromFloat(i32, 0x1p-24 * z)); + iq[U(jz)] = @intFromFloat(i32, z - 0x1p24 * fw); jz += 1; q0 += 24; - iq[U(jz)] = @floatToInt(i32, fw); + iq[U(jz)] = @intFromFloat(i32, fw); } else { - iq[U(jz)] = @floatToInt(i32, z); + iq[U(jz)] = @intFromFloat(i32, z); } } @@ -428,7 +428,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 { fw = math.scalbn(@as(f64, 1.0), q0); i = jz; while (i >= 0) : (i -= 1) { - q[U(i)] = fw * @intToFloat(f64, iq[U(i)]); + q[U(i)] = fw * @floatFromInt(f64, iq[U(i)]); fw *= 0x1p-24; } diff --git a/lib/compiler_rt/rem_pio2f.zig b/lib/compiler_rt/rem_pio2f.zig index 34397dd73477..9e47bbcb24cc 100644 --- a/lib/compiler_rt/rem_pio2f.zig +++ b/lib/compiler_rt/rem_pio2f.zig @@ -37,7 +37,7 @@ pub fn rem_pio2f(x: f32, y: *f64) i32 { if (ix < 0x4dc90fdb) { // |x| ~< 2^28*(pi/2), medium size // Use a specialized rint() to get fn. @"fn" = @floatCast(f64, x) * invpio2 + toint - toint; - n = @floatToInt(i32, @"fn"); + n = @intFromFloat(i32, @"fn"); y.* = x - @"fn" * pio2_1 - @"fn" * pio2_1t; // Matters with directed rounding. if (y.* < -pio4) { diff --git a/lib/compiler_rt/trig.zig b/lib/compiler_rt/trig.zig index 8ece83515e21..4a9629e5c012 100644 --- a/lib/compiler_rt/trig.zig +++ b/lib/compiler_rt/trig.zig @@ -222,7 +222,7 @@ pub fn __tan(x_: f64, y_: f64, odd: bool) f64 { r = y + z * (s * (r + v) + y) + s * T[0]; w = x + r; if (big) { - s = 1 - 2 * @intToFloat(f64, @boolToInt(odd)); + s = 1 - 2 * @floatFromInt(f64, @intFromBool(odd)); v = s - 2.0 * (x + (r - w * w / (w + s))); return if (sign) -v else v; } diff --git a/lib/compiler_rt/truncf.zig b/lib/compiler_rt/truncf.zig index c012bcee621f..3de342fc99d5 100644 --- a/lib/compiler_rt/truncf.zig +++ b/lib/compiler_rt/truncf.zig @@ -81,7 +81,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t if (shift > srcSigBits) { absResult = 0; } else { - const sticky: src_rep_t = @boolToInt(significand << @intCast(SrcShift, srcBits - shift) != 0); + const sticky: src_rep_t = @intFromBool(significand << @intCast(SrcShift, srcBits - shift) != 0); const denormalizedSignificand: src_rep_t = significand >> @intCast(SrcShift, shift) | sticky; absResult = @intCast(dst_rep_t, denormalizedSignificand >> (srcSigBits - dstSigBits)); const roundBits: src_rep_t = denormalizedSignificand & roundMask; @@ -164,7 +164,7 @@ pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t { if (shift > src_sig_bits) { abs_result = 0; } else { - const sticky = @boolToInt(a_rep.fraction << @intCast(u6, shift) != 0); + const sticky = @intFromBool(a_rep.fraction << @intCast(u6, shift) != 0); const denormalized_significand = a_rep.fraction >> @intCast(u6, shift) | sticky; abs_result = @intCast(dst_rep_t, denormalized_significand >> (src_sig_bits - dst_sig_bits)); const round_bits = denormalized_significand & round_mask; diff --git a/lib/docs/main.js b/lib/docs/main.js index 0402f0f6af7b..c9c34ffe98c8 100644 --- a/lib/docs/main.js +++ b/lib/docs/main.js @@ -1234,9 +1234,9 @@ const NAV_MODES = { const name = getAstNode(field).name; return name; } - case "enumToInt": { - const enumToInt = zigAnalysis.exprs[expr.enumToInt]; - return "@enumToInt(" + exprName(enumToInt, opts) + ")"; + case "intFromEnum": { + const intFromEnum = zigAnalysis.exprs[expr.intFromEnum]; + return "@intFromEnum(" + exprName(intFromEnum, opts) + ")"; } case "bitSizeOf": { const bitSizeOf = zigAnalysis.exprs[expr.bitSizeOf]; @@ -1260,8 +1260,8 @@ const NAV_MODES = { payloadHtml += "alignOf"; break; } - case "bool_to_int": { - payloadHtml += "boolToInt"; + case "int_from_bool": { + payloadHtml += "intFromBool"; break; } case "embed_file": { @@ -1368,16 +1368,16 @@ const NAV_MODES = { payloadHtml += "workGroupId"; break; } - case "ptr_to_int": { - payloadHtml += "ptrToInt"; + case "int_from_ptr": { + payloadHtml += "intFromPtr"; break; } - case "error_to_int": { - payloadHtml += "errorToInt"; + case "int_from_error": { + payloadHtml += "intFromError"; break; } - case "int_to_error": { - payloadHtml += "intToError"; + case "error_to_int": { + payloadHtml += "errorFromInt"; break; } case "max": { @@ -1423,20 +1423,20 @@ const NAV_MODES = { let payloadHtml = "@"; switch (expr.builtinBin.name) { - case "float_to_int": { - payloadHtml += "floatToInt"; + case "int_from_float": { + payloadHtml += "intFromFloat"; break; } - case "int_to_float": { - payloadHtml += "intToFloat"; + case "float_from_int": { + payloadHtml += "floatFromInt"; break; } - case "int_to_ptr": { - payloadHtml += "intToPtr"; + case "ptr_from_int": { + payloadHtml += "ptrFromInt"; break; } - case "int_to_enum": { - payloadHtml += "intToEnum"; + case "enum_from_int": { + payloadHtml += "enumFromInt"; break; } case "float_cast": { diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig index bed1cc345e05..c574dbb5af55 100644 --- a/lib/std/Build/Step/Run.zig +++ b/lib/std/Build/Step/Run.zig @@ -1035,9 +1035,9 @@ fn evalZigTest( const TrHdr = std.zig.Server.Message.TestResults; const tr_hdr = @ptrCast(*align(1) const TrHdr, body); - fail_count += @boolToInt(tr_hdr.flags.fail); - skip_count += @boolToInt(tr_hdr.flags.skip); - leak_count += @boolToInt(tr_hdr.flags.leak); + fail_count += @intFromBool(tr_hdr.flags.fail); + skip_count += @intFromBool(tr_hdr.flags.skip); + leak_count += @intFromBool(tr_hdr.flags.leak); if (tr_hdr.flags.fail or tr_hdr.flags.leak) { const name = std.mem.sliceTo(md.string_bytes[md.names[tr_hdr.index]..], 0); diff --git a/lib/std/RingBuffer.zig b/lib/std/RingBuffer.zig index 080e6f54d32f..b83a9b017795 100644 --- a/lib/std/RingBuffer.zig +++ b/lib/std/RingBuffer.zig @@ -102,7 +102,7 @@ pub fn isFull(self: RingBuffer) bool { /// Returns the length pub fn len(self: RingBuffer) usize { - const wrap_offset = 2 * self.data.len * @boolToInt(self.write_index < self.read_index); + const wrap_offset = 2 * self.data.len * @intFromBool(self.write_index < self.read_index); const adjusted_write_index = self.write_index + wrap_offset; return adjusted_write_index - self.read_index; } diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index e2ee51e1dc95..f16f8a9a79b8 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -65,8 +65,8 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void { .linux => if (use_pthreads) { if (self.getHandle() == std.c.pthread_self()) { // Set the name of the calling thread (no thread id required). - const err = try os.prctl(.SET_NAME, .{@ptrToInt(name_with_terminator.ptr)}); - switch (@intToEnum(os.E, err)) { + const err = try os.prctl(.SET_NAME, .{@intFromPtr(name_with_terminator.ptr)}); + switch (@enumFromInt(os.E, err)) { .SUCCESS => return, else => |e| return os.unexpectedErrno(e), } @@ -175,8 +175,8 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co .linux => if (use_pthreads) { if (self.getHandle() == std.c.pthread_self()) { // Get the name of the calling thread (no thread id required). - const err = try os.prctl(.GET_NAME, .{@ptrToInt(buffer.ptr)}); - switch (@intToEnum(os.E, err)) { + const err = try os.prctl(.GET_NAME, .{@intFromPtr(buffer.ptr)}); + switch (@enumFromInt(os.E, err)) { .SUCCESS => return std.mem.sliceTo(buffer, 0), else => |e| return os.unexpectedErrno(e), } @@ -611,7 +611,7 @@ const PosixThreadImpl = struct { return @bitCast(u32, c.find_thread(null)); }, else => { - return @ptrToInt(c.pthread_self()); + return @intFromPtr(c.pthread_self()); }, } } @@ -776,7 +776,7 @@ const LinuxThreadImpl = struct { \\ movl $0, %%ebx \\ int $128 : - : [ptr] "r" (@ptrToInt(self.mapped.ptr)), + : [ptr] "r" (@intFromPtr(self.mapped.ptr)), [len] "r" (self.mapped.len), : "memory" ), @@ -787,7 +787,7 @@ const LinuxThreadImpl = struct { \\ movq $1, %%rdi \\ syscall : - : [ptr] "{rdi}" (@ptrToInt(self.mapped.ptr)), + : [ptr] "{rdi}" (@intFromPtr(self.mapped.ptr)), [len] "{rsi}" (self.mapped.len), ), .arm, .armeb, .thumb, .thumbeb => asm volatile ( @@ -799,7 +799,7 @@ const LinuxThreadImpl = struct { \\ mov r0, #0 \\ svc 0 : - : [ptr] "r" (@ptrToInt(self.mapped.ptr)), + : [ptr] "r" (@intFromPtr(self.mapped.ptr)), [len] "r" (self.mapped.len), : "memory" ), @@ -812,7 +812,7 @@ const LinuxThreadImpl = struct { \\ mov x0, #0 \\ svc 0 : - : [ptr] "r" (@ptrToInt(self.mapped.ptr)), + : [ptr] "r" (@intFromPtr(self.mapped.ptr)), [len] "r" (self.mapped.len), : "memory" ), @@ -826,7 +826,7 @@ const LinuxThreadImpl = struct { \\ li $4, 0 \\ syscall : - : [ptr] "r" (@ptrToInt(self.mapped.ptr)), + : [ptr] "r" (@intFromPtr(self.mapped.ptr)), [len] "r" (self.mapped.len), : "memory" ), @@ -839,7 +839,7 @@ const LinuxThreadImpl = struct { \\ li $4, 0 \\ syscall : - : [ptr] "r" (@ptrToInt(self.mapped.ptr)), + : [ptr] "r" (@intFromPtr(self.mapped.ptr)), [len] "r" (self.mapped.len), : "memory" ), @@ -853,7 +853,7 @@ const LinuxThreadImpl = struct { \\ sc \\ blr : - : [ptr] "r" (@ptrToInt(self.mapped.ptr)), + : [ptr] "r" (@intFromPtr(self.mapped.ptr)), [len] "r" (self.mapped.len), : "memory" ), @@ -866,7 +866,7 @@ const LinuxThreadImpl = struct { \\ mv a0, zero \\ ecall : - : [ptr] "r" (@ptrToInt(self.mapped.ptr)), + : [ptr] "r" (@intFromPtr(self.mapped.ptr)), [len] "r" (self.mapped.len), : "memory" ), @@ -893,7 +893,7 @@ const LinuxThreadImpl = struct { \\ mov 1, %%o0 \\ t 0x6d : - : [ptr] "r" (@ptrToInt(self.mapped.ptr)), + : [ptr] "r" (@intFromPtr(self.mapped.ptr)), [len] "r" (self.mapped.len), : "memory" ), @@ -911,7 +911,7 @@ const LinuxThreadImpl = struct { thread: ThreadCompletion, fn entryFn(raw_arg: usize) callconv(.C) u8 { - const self = @intToPtr(*@This(), raw_arg); + const self = @ptrFromInt(*@This(), raw_arg); defer switch (self.thread.completion.swap(.completed, .SeqCst)) { .running => {}, .completed => unreachable, @@ -980,7 +980,7 @@ const LinuxThreadImpl = struct { var tls_ptr = os.linux.tls.prepareTLS(mapped[tls_offset..]); var user_desc: if (target.cpu.arch == .x86) os.linux.user_desc else void = undefined; if (target.cpu.arch == .x86) { - defer tls_ptr = @ptrToInt(&user_desc); + defer tls_ptr = @intFromPtr(&user_desc); user_desc = .{ .entry_number = os.linux.tls.tls_image.gdt_entry_number, .base_addr = tls_ptr, @@ -1007,9 +1007,9 @@ const LinuxThreadImpl = struct { switch (linux.getErrno(linux.clone( Instance.entryFn, - @ptrToInt(&mapped[stack_offset]), + @intFromPtr(&mapped[stack_offset]), flags, - @ptrToInt(instance), + @intFromPtr(instance), &instance.thread.parent_tid, tls_ptr, &instance.thread.child_tid.value, diff --git a/lib/std/Thread/Condition.zig b/lib/std/Thread/Condition.zig index 2f8ab02d5eda..5b24e9ea19ac 100644 --- a/lib/std/Thread/Condition.zig +++ b/lib/std/Thread/Condition.zig @@ -487,7 +487,7 @@ test "Condition - multi signal" { // The first paddle will be hit one last time by the last paddle. for (paddles, 0..) |p, i| { - const expected = @as(u32, num_iterations) + @boolToInt(i == 0); + const expected = @as(u32, num_iterations) + @intFromBool(i == 0); try testing.expectEqual(p.value, expected); } } diff --git a/lib/std/Thread/Futex.zig b/lib/std/Thread/Futex.zig index 7fbe49fea29e..61e39eba27d5 100644 --- a/lib/std/Thread/Futex.zig +++ b/lib/std/Thread/Futex.zig @@ -202,7 +202,7 @@ const DarwinImpl = struct { }; if (status >= 0) return; - switch (@intToEnum(std.os.E, -status)) { + switch (@enumFromInt(std.os.E, -status)) { // Wait was interrupted by the OS or other spurious signalling. .INTR => {}, // Address of the futex was paged out. This is unlikely, but possible in theory, and @@ -229,7 +229,7 @@ const DarwinImpl = struct { const status = os.darwin.__ulock_wake(flags, addr, 0); if (status >= 0) return; - switch (@intToEnum(std.os.E, -status)) { + switch (@enumFromInt(std.os.E, -status)) { .INTR => continue, // spurious wake() .FAULT => unreachable, // __ulock_wake doesn't generate EFAULT according to darwin pthread_cond_t .NOENT => return, // nothing was woken up @@ -304,11 +304,11 @@ const FreebsdImpl = struct { } const rc = os.freebsd._umtx_op( - @ptrToInt(&ptr.value), - @enumToInt(os.freebsd.UMTX_OP.WAIT_UINT_PRIVATE), + @intFromPtr(&ptr.value), + @intFromEnum(os.freebsd.UMTX_OP.WAIT_UINT_PRIVATE), @as(c_ulong, expect), tm_size, - @ptrToInt(tm_ptr), + @intFromPtr(tm_ptr), ); switch (os.errno(rc)) { @@ -326,8 +326,8 @@ const FreebsdImpl = struct { fn wake(ptr: *const Atomic(u32), max_waiters: u32) void { const rc = os.freebsd._umtx_op( - @ptrToInt(&ptr.value), - @enumToInt(os.freebsd.UMTX_OP.WAKE_PRIVATE), + @intFromPtr(&ptr.value), + @intFromEnum(os.freebsd.UMTX_OP.WAKE_PRIVATE), @as(c_ulong, max_waiters), 0, // there is no timeout struct 0, // there is no timeout struct pointer @@ -719,7 +719,7 @@ const PosixImpl = struct { // Make sure the pointer is aligned, // then cut off the zero bits from the alignment to get the unique address. - const addr = @ptrToInt(ptr); + const addr = @intFromPtr(ptr); assert(addr & (alignment - 1) == 0); return addr >> @ctz(@as(usize, alignment)); } diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig index b46b5c12f0a0..d3ad94324ec9 100644 --- a/lib/std/array_hash_map.zig +++ b/lib/std/array_hash_map.zig @@ -2310,7 +2310,7 @@ pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context, return struct { fn hash(ctx: Context, key: K) u32 { _ = ctx; - return getAutoHashFn(usize, void)({}, @ptrToInt(key)); + return getAutoHashFn(usize, void)({}, @intFromPtr(key)); } }.hash; } diff --git a/lib/std/atomic/Atomic.zig b/lib/std/atomic/Atomic.zig index 6c0c477725f8..81918638b544 100644 --- a/lib/std/atomic/Atomic.zig +++ b/lib/std/atomic/Atomic.zig @@ -227,7 +227,7 @@ pub fn Atomic(comptime T: type) type { .Toggle => self.fetchXor(mask, ordering), }; - return @boolToInt(value & mask != 0); + return @intFromBool(value & mask != 0); } inline fn x86BitRmw(self: *Self, comptime op: BitRmwOp, bit: Bit, comptime ordering: Ordering) u1 { @@ -392,8 +392,8 @@ test "Atomic.swap" { try testing.expectEqual(a.load(.SeqCst), true); var b = Atomic(?*u8).init(null); - try testing.expectEqual(b.swap(@intToPtr(?*u8, @alignOf(u8)), ordering), null); - try testing.expectEqual(b.load(.SeqCst), @intToPtr(?*u8, @alignOf(u8))); + try testing.expectEqual(b.swap(@ptrFromInt(?*u8, @alignOf(u8)), ordering), null); + try testing.expectEqual(b.load(.SeqCst), @ptrFromInt(?*u8, @alignOf(u8))); } } diff --git a/lib/std/atomic/queue.zig b/lib/std/atomic/queue.zig index 7c9ffa2684a0..70cb293cf43b 100644 --- a/lib/std/atomic/queue.zig +++ b/lib/std/atomic/queue.zig @@ -135,7 +135,7 @@ pub fn Queue(comptime T: type) type { ) !void { try s.writeByteNTimes(' ', indent); if (optional_node) |node| { - try s.print("0x{x}={}\n", .{ @ptrToInt(node), node.data }); + try s.print("0x{x}={}\n", .{ @intFromPtr(node), node.data }); if (depth == 0) { try s.print("(max depth)\n", .{}); return; @@ -387,7 +387,7 @@ test "std.atomic.Queue dump" { \\tail: 0x{x}=1 \\ (null) \\ - , .{ @ptrToInt(queue.head), @ptrToInt(queue.tail) }); + , .{ @intFromPtr(queue.head), @intFromPtr(queue.tail) }); try expect(mem.eql(u8, buffer[0..fbs.pos], expected)); // Test a stream with two elements @@ -408,6 +408,6 @@ test "std.atomic.Queue dump" { \\tail: 0x{x}=2 \\ (null) \\ - , .{ @ptrToInt(queue.head), @ptrToInt(queue.head.?.next), @ptrToInt(queue.tail) }); + , .{ @intFromPtr(queue.head), @intFromPtr(queue.head.?.next), @intFromPtr(queue.tail) }); try expect(mem.eql(u8, buffer[0..fbs.pos], expected)); } diff --git a/lib/std/bit_set.zig b/lib/std/bit_set.zig index b7dfc8d5294d..4b83e8e057af 100644 --- a/lib/std/bit_set.zig +++ b/lib/std/bit_set.zig @@ -306,7 +306,7 @@ pub fn IntegerBitSet(comptime size: u16) type { } fn boolMaskBit(index: usize, value: bool) MaskInt { if (MaskInt == u0) return 0; - return @as(MaskInt, @boolToInt(value)) << @intCast(ShiftInt, index); + return @as(MaskInt, @intFromBool(value)) << @intCast(ShiftInt, index); } }; } @@ -640,7 +640,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { return index >> @bitSizeOf(ShiftInt); } fn boolMaskBit(index: usize, value: bool) MaskInt { - return @as(MaskInt, @boolToInt(value)) << @intCast(ShiftInt, index); + return @as(MaskInt, @intFromBool(value)) << @intCast(ShiftInt, index); } }; } @@ -669,7 +669,7 @@ pub const DynamicBitSetUnmanaged = struct { // Don't modify this value. Ideally it would go in const data so // modifications would cause a bus error, but the only way - // to discard a const qualifier is through ptrToInt, which + // to discard a const qualifier is through intFromPtr, which // cannot currently round trip at comptime. var empty_masks_data = [_]MaskInt{ 0, undefined }; const empty_masks_ptr = empty_masks_data[1..2]; @@ -1011,7 +1011,7 @@ pub const DynamicBitSetUnmanaged = struct { return index >> @bitSizeOf(ShiftInt); } fn boolMaskBit(index: usize, value: bool) MaskInt { - return @as(MaskInt, @boolToInt(value)) << @intCast(ShiftInt, index); + return @as(MaskInt, @intFromBool(value)) << @intCast(ShiftInt, index); } fn numMasks(bit_length: usize) usize { return (bit_length + (@bitSizeOf(MaskInt) - 1)) / @bitSizeOf(MaskInt); diff --git a/lib/std/c.zig b/lib/std/c.zig index 67c676f0dd1f..3b4bfef826f0 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -113,7 +113,7 @@ pub usingnamespace switch (builtin.os.tag) { pub fn getErrno(rc: anytype) c.E { if (rc == -1) { - return @intToEnum(c.E, c._errno().*); + return @enumFromInt(c.E, c._errno().*); } else { return .SUCCESS; } diff --git a/lib/std/c/darwin.zig b/lib/std/c/darwin.zig index a25743728218..b680a97933b1 100644 --- a/lib/std/c/darwin.zig +++ b/lib/std/c/darwin.zig @@ -51,19 +51,19 @@ pub const EXC = enum(exception_type_t) { pub const EXC_SOFT_SIGNAL = 0x10003; -pub const EXC_MASK_BAD_ACCESS = 1 << @enumToInt(EXC.BAD_ACCESS); -pub const EXC_MASK_BAD_INSTRUCTION = 1 << @enumToInt(EXC.BAD_INSTRUCTION); -pub const EXC_MASK_ARITHMETIC = 1 << @enumToInt(EXC.ARITHMETIC); -pub const EXC_MASK_EMULATION = 1 << @enumToInt(EXC.EMULATION); -pub const EXC_MASK_SOFTWARE = 1 << @enumToInt(EXC.SOFTWARE); -pub const EXC_MASK_BREAKPOINT = 1 << @enumToInt(EXC.BREAKPOINT); -pub const EXC_MASK_SYSCALL = 1 << @enumToInt(EXC.SYSCALL); -pub const EXC_MASK_MACH_SYSCALL = 1 << @enumToInt(EXC.MACH_SYSCALL); -pub const EXC_MASK_RPC_ALERT = 1 << @enumToInt(EXC.RPC_ALERT); -pub const EXC_MASK_CRASH = 1 << @enumToInt(EXC.CRASH); -pub const EXC_MASK_RESOURCE = 1 << @enumToInt(EXC.RESOURCE); -pub const EXC_MASK_GUARD = 1 << @enumToInt(EXC.GUARD); -pub const EXC_MASK_CORPSE_NOTIFY = 1 << @enumToInt(EXC.CORPSE_NOTIFY); +pub const EXC_MASK_BAD_ACCESS = 1 << @intFromEnum(EXC.BAD_ACCESS); +pub const EXC_MASK_BAD_INSTRUCTION = 1 << @intFromEnum(EXC.BAD_INSTRUCTION); +pub const EXC_MASK_ARITHMETIC = 1 << @intFromEnum(EXC.ARITHMETIC); +pub const EXC_MASK_EMULATION = 1 << @intFromEnum(EXC.EMULATION); +pub const EXC_MASK_SOFTWARE = 1 << @intFromEnum(EXC.SOFTWARE); +pub const EXC_MASK_BREAKPOINT = 1 << @intFromEnum(EXC.BREAKPOINT); +pub const EXC_MASK_SYSCALL = 1 << @intFromEnum(EXC.SYSCALL); +pub const EXC_MASK_MACH_SYSCALL = 1 << @intFromEnum(EXC.MACH_SYSCALL); +pub const EXC_MASK_RPC_ALERT = 1 << @intFromEnum(EXC.RPC_ALERT); +pub const EXC_MASK_CRASH = 1 << @intFromEnum(EXC.CRASH); +pub const EXC_MASK_RESOURCE = 1 << @intFromEnum(EXC.RESOURCE); +pub const EXC_MASK_GUARD = 1 << @intFromEnum(EXC.GUARD); +pub const EXC_MASK_CORPSE_NOTIFY = 1 << @intFromEnum(EXC.CORPSE_NOTIFY); pub const EXC_MASK_MACHINE = arch_bits.EXC_MASK_MACHINE; pub const EXC_MASK_ALL = EXC_MASK_BAD_ACCESS | @@ -1177,10 +1177,10 @@ pub const sigset_t = u32; pub const empty_sigset: sigset_t = 0; pub const SIG = struct { - pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize)); - pub const DFL = @intToPtr(?Sigaction.handler_fn, 0); - pub const IGN = @intToPtr(?Sigaction.handler_fn, 1); - pub const HOLD = @intToPtr(?Sigaction.handler_fn, 5); + pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); + pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); + pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); + pub const HOLD = @ptrFromInt(?Sigaction.handler_fn, 5); /// block specified signal set pub const _BLOCK = 1; @@ -1411,7 +1411,7 @@ pub const MAP = struct { pub const NOCACHE = 0x0400; /// don't reserve needed swap area pub const NORESERVE = 0x0040; - pub const FAILED = @intToPtr(*anyopaque, maxInt(usize)); + pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); }; pub const MSF = struct { @@ -2463,7 +2463,7 @@ pub const KernE = enum(u32) { pub const mach_msg_return_t = kern_return_t; pub fn getMachMsgError(err: mach_msg_return_t) MachMsgE { - return @intToEnum(MachMsgE, @truncate(u32, @intCast(usize, err))); + return @enumFromInt(MachMsgE, @truncate(u32, @intCast(usize, err))); } /// All special error code bits defined below. @@ -2665,10 +2665,10 @@ pub const RTLD = struct { pub const NODELETE = 0x80; pub const FIRST = 0x100; - pub const NEXT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1))); - pub const DEFAULT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -2))); - pub const SELF = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -3))); - pub const MAIN_ONLY = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -5))); + pub const NEXT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1))); + pub const DEFAULT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -2))); + pub const SELF = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -3))); + pub const MAIN_ONLY = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -5))); }; pub const F = struct { @@ -3418,12 +3418,12 @@ pub const PosixSpawn = struct { }; pub fn getKernError(err: kern_return_t) KernE { - return @intToEnum(KernE, @truncate(u32, @intCast(usize, err))); + return @enumFromInt(KernE, @truncate(u32, @intCast(usize, err))); } pub fn unexpectedKernError(err: KernE) std.os.UnexpectedError { if (std.os.unexpected_error_tracing) { - std.debug.print("unexpected error: {d}\n", .{@enumToInt(err)}); + std.debug.print("unexpected error: {d}\n", .{@intFromEnum(err)}); std.debug.dumpCurrentStackTrace(null); } return error.Unexpected; @@ -3455,7 +3455,7 @@ pub const MachTask = extern struct { var out_port: mach_port_name_t = undefined; switch (getKernError(mach_port_allocate( self.port, - @enumToInt(right), + @intFromEnum(right), &out_port, ))) { .SUCCESS => return .{ .port = out_port }, @@ -3473,7 +3473,7 @@ pub const MachTask = extern struct { self.port, port.port, port.port, - @enumToInt(msg), + @intFromEnum(msg), ))) { .SUCCESS => return, .FAILURE => return error.PermissionDenied, @@ -3665,7 +3665,7 @@ pub const MachTask = extern struct { } fn setProtectionImpl(task: MachTask, address: u64, len: usize, set_max: bool, prot: vm_prot_t) MachError!void { - switch (getKernError(mach_vm_protect(task.port, address, len, @boolToInt(set_max), prot))) { + switch (getKernError(mach_vm_protect(task.port, address, len, @intFromBool(set_max), prot))) { .SUCCESS => return, .FAILURE => return error.PermissionDenied, else => |err| return unexpectedKernError(err), @@ -3700,7 +3700,7 @@ pub const MachTask = extern struct { switch (getKernError(mach_vm_write( task.port, curr_addr, - @ptrToInt(out_buf.ptr), + @intFromPtr(out_buf.ptr), @intCast(mach_msg_type_number_t, curr_size), ))) { .SUCCESS => {}, @@ -3752,7 +3752,7 @@ pub const MachTask = extern struct { else => |err| return unexpectedKernError(err), } - @memcpy(out_buf[0..curr_bytes_read], @intToPtr([*]const u8, vm_memory)); + @memcpy(out_buf[0..curr_bytes_read], @ptrFromInt([*]const u8, vm_memory)); _ = vm_deallocate(mach_task_self(), vm_memory, curr_bytes_read); out_buf = out_buf[curr_bytes_read..]; @@ -3831,7 +3831,7 @@ pub const MachTask = extern struct { const self_task = machTaskForSelf(); _ = vm_deallocate( self_task.port, - @ptrToInt(list.buf.ptr), + @intFromPtr(list.buf.ptr), @intCast(vm_size_t, list.buf.len * @sizeOf(mach_port_t)), ); } diff --git a/lib/std/c/dragonfly.zig b/lib/std/c/dragonfly.zig index 457e817b682c..912bb9905633 100644 --- a/lib/std/c/dragonfly.zig +++ b/lib/std/c/dragonfly.zig @@ -172,7 +172,7 @@ pub const PROT = struct { pub const MAP = struct { pub const FILE = 0; - pub const FAILED = @intToPtr(*anyopaque, maxInt(usize)); + pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); pub const ANONYMOUS = ANON; pub const COPY = PRIVATE; pub const SHARED = 1; @@ -620,9 +620,9 @@ pub const S = struct { pub const BADSIG = SIG.ERR; pub const SIG = struct { - pub const DFL = @intToPtr(?Sigaction.handler_fn, 0); - pub const IGN = @intToPtr(?Sigaction.handler_fn, 1); - pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize)); + pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); + pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); + pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); pub const BLOCK = 1; pub const UNBLOCK = 2; @@ -871,10 +871,10 @@ pub const RTLD = struct { pub const NODELETE = 0x01000; pub const NOLOAD = 0x02000; - pub const NEXT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1))); - pub const DEFAULT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -2))); - pub const SELF = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -3))); - pub const ALL = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -4))); + pub const NEXT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1))); + pub const DEFAULT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -2))); + pub const SELF = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -3))); + pub const ALL = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -4))); }; pub const dl_phdr_info = extern struct { diff --git a/lib/std/c/freebsd.zig b/lib/std/c/freebsd.zig index 8e8a57656441..6f91ee65f7f1 100644 --- a/lib/std/c/freebsd.zig +++ b/lib/std/c/freebsd.zig @@ -961,7 +961,7 @@ pub const CLOCK = struct { }; pub const MAP = struct { - pub const FAILED = @intToPtr(*anyopaque, maxInt(usize)); + pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); pub const SHARED = 0x0001; pub const PRIVATE = 0x0002; pub const FIXED = 0x0010; @@ -1086,9 +1086,9 @@ pub const SIG = struct { pub const UNBLOCK = 2; pub const SETMASK = 3; - pub const DFL = @intToPtr(?Sigaction.handler_fn, 0); - pub const IGN = @intToPtr(?Sigaction.handler_fn, 1); - pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize)); + pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); + pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); + pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); pub const WORDS = 4; pub const MAXSIG = 128; @@ -2650,7 +2650,7 @@ const ioctl_cmd = enum(u32) { }; fn ioImpl(cmd: ioctl_cmd, op: u8, nr: u8, comptime IT: type) u32 { - return @bitCast(u32, @enumToInt(cmd) | @intCast(u32, @truncate(u8, @sizeOf(IT))) << 16 | @intCast(u32, op) << 8 | nr); + return @bitCast(u32, @intFromEnum(cmd) | @intCast(u32, @truncate(u8, @sizeOf(IT))) << 16 | @intCast(u32, op) << 8 | nr); } pub fn IO(op: u8, nr: u8) u32 { diff --git a/lib/std/c/haiku.zig b/lib/std/c/haiku.zig index 2e0e02a20f1d..2f9917a0f3d8 100644 --- a/lib/std/c/haiku.zig +++ b/lib/std/c/haiku.zig @@ -414,7 +414,7 @@ pub const CLOCK = struct { pub const MAP = struct { /// mmap() error return code - pub const FAILED = @intToPtr(*anyopaque, maxInt(usize)); + pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); /// changes are seen by others pub const SHARED = 0x01; /// changes are only seen by caller @@ -481,9 +481,9 @@ pub const SA = struct { }; pub const SIG = struct { - pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize)); - pub const DFL = @intToPtr(?Sigaction.handler_fn, 0); - pub const IGN = @intToPtr(?Sigaction.handler_fn, 1); + pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); + pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); + pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); pub const HUP = 1; pub const INT = 2; diff --git a/lib/std/c/linux.zig b/lib/std/c/linux.zig index d5add70033f8..d3a3bfdeba8a 100644 --- a/lib/std/c/linux.zig +++ b/lib/std/c/linux.zig @@ -32,7 +32,7 @@ pub const MADV = linux.MADV; pub const MAP = struct { pub usingnamespace linux.MAP; /// Only used by libc to communicate failure. - pub const FAILED = @intToPtr(*anyopaque, maxInt(usize)); + pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); }; pub const MSF = linux.MSF; pub const MMAP2_UNIT = linux.MMAP2_UNIT; diff --git a/lib/std/c/netbsd.zig b/lib/std/c/netbsd.zig index 5a848c480892..8f3837b2bbd1 100644 --- a/lib/std/c/netbsd.zig +++ b/lib/std/c/netbsd.zig @@ -172,9 +172,9 @@ pub const RTLD = struct { pub const NODELETE = 0x01000; pub const NOLOAD = 0x02000; - pub const NEXT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1))); - pub const DEFAULT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -2))); - pub const SELF = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -3))); + pub const NEXT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1))); + pub const DEFAULT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -2))); + pub const SELF = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -3))); }; pub const dl_phdr_info = extern struct { @@ -591,7 +591,7 @@ pub const CLOCK = struct { }; pub const MAP = struct { - pub const FAILED = @intToPtr(*anyopaque, maxInt(usize)); + pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); pub const SHARED = 0x0001; pub const PRIVATE = 0x0002; pub const REMAPDUP = 0x0004; @@ -1090,9 +1090,9 @@ pub const winsize = extern struct { const NSIG = 32; pub const SIG = struct { - pub const DFL = @intToPtr(?Sigaction.handler_fn, 0); - pub const IGN = @intToPtr(?Sigaction.handler_fn, 1); - pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize)); + pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); + pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); + pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); pub const WORDS = 4; pub const MAXSIG = 128; diff --git a/lib/std/c/openbsd.zig b/lib/std/c/openbsd.zig index 93681b77e18b..4d4446123732 100644 --- a/lib/std/c/openbsd.zig +++ b/lib/std/c/openbsd.zig @@ -449,7 +449,7 @@ pub const CLOCK = struct { }; pub const MAP = struct { - pub const FAILED = @intToPtr(*anyopaque, maxInt(usize)); + pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); pub const SHARED = 0x0001; pub const PRIVATE = 0x0002; pub const FIXED = 0x0010; @@ -990,11 +990,11 @@ pub const winsize = extern struct { const NSIG = 33; pub const SIG = struct { - pub const DFL = @intToPtr(?Sigaction.handler_fn, 0); - pub const IGN = @intToPtr(?Sigaction.handler_fn, 1); - pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize)); - pub const CATCH = @intToPtr(?Sigaction.handler_fn, 2); - pub const HOLD = @intToPtr(?Sigaction.handler_fn, 3); + pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); + pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); + pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); + pub const CATCH = @ptrFromInt(?Sigaction.handler_fn, 2); + pub const HOLD = @ptrFromInt(?Sigaction.handler_fn, 3); pub const HUP = 1; pub const INT = 2; diff --git a/lib/std/c/solaris.zig b/lib/std/c/solaris.zig index 3a6708613b23..511bf9ccc54b 100644 --- a/lib/std/c/solaris.zig +++ b/lib/std/c/solaris.zig @@ -111,10 +111,10 @@ pub const RTLD = struct { pub const FIRST = 0x02000; pub const CONFGEN = 0x10000; - pub const NEXT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1))); - pub const DEFAULT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -2))); - pub const SELF = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -3))); - pub const PROBE = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -4))); + pub const NEXT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1))); + pub const DEFAULT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -2))); + pub const SELF = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -3))); + pub const PROBE = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -4))); }; pub const Flock = extern struct { @@ -524,7 +524,7 @@ pub const CLOCK = struct { }; pub const MAP = struct { - pub const FAILED = @intToPtr(*anyopaque, maxInt(usize)); + pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); pub const SHARED = 0x0001; pub const PRIVATE = 0x0002; pub const TYPE = 0x000f; @@ -886,10 +886,10 @@ pub const winsize = extern struct { const NSIG = 75; pub const SIG = struct { - pub const DFL = @intToPtr(?Sigaction.handler_fn, 0); - pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize)); - pub const IGN = @intToPtr(?Sigaction.handler_fn, 1); - pub const HOLD = @intToPtr(?Sigaction.handler_fn, 2); + pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); + pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); + pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); + pub const HOLD = @ptrFromInt(?Sigaction.handler_fn, 2); pub const WORDS = 4; pub const MAXSIG = 75; @@ -1909,7 +1909,7 @@ const IoCtlCommand = enum(u32) { fn ioImpl(cmd: IoCtlCommand, io_type: u8, nr: u8, comptime IOT: type) i32 { const size = @intCast(u32, @truncate(u8, @sizeOf(IOT))) << 16; const t = @intCast(u32, io_type) << 8; - return @bitCast(i32, @enumToInt(cmd) | size | t | nr); + return @bitCast(i32, @intFromEnum(cmd) | size | t | nr); } pub fn IO(io_type: u8, nr: u8) i32 { diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig index db8524200260..636ef7f4d726 100644 --- a/lib/std/child_process.zig +++ b/lib/std/child_process.zig @@ -449,7 +449,7 @@ pub const ChildProcess = struct { // has a value greater than 0 if ((fd[0].revents & std.os.POLL.IN) != 0) { const err_int = try readIntFd(err_pipe[0]); - return @errSetCast(SpawnError, @intToError(err_int)); + return @errSetCast(SpawnError, @errorFromInt(err_int)); } } else { // Write maxInt(ErrInt) to the write end of the err_pipe. This is after @@ -462,7 +462,7 @@ pub const ChildProcess = struct { // Here we potentially return the fork child's error from the parent // pid. if (err_int != maxInt(ErrInt)) { - return @errSetCast(SpawnError, @intToError(err_int)); + return @errSetCast(SpawnError, @errorFromInt(err_int)); } } } @@ -1356,7 +1356,7 @@ fn destroyPipe(pipe: [2]os.fd_t) void { // Child of fork calls this to report an error to the fork parent. // Then the child exits. fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn { - writeIntFd(fd, @as(ErrInt, @errorToInt(err))) catch {}; + writeIntFd(fd, @as(ErrInt, @intFromError(err))) catch {}; // If we're linking libc, some naughty applications may have registered atexit handlers // which we really do not want to run in the fork child. I caught LLVM doing this and // it caused a deadlock instead of doing an exit syscall. In the words of Avril Lavigne, diff --git a/lib/std/coff.zig b/lib/std/coff.zig index a7c191e650e0..d28e54b94cee 100644 --- a/lib/std/coff.zig +++ b/lib/std/coff.zig @@ -1105,7 +1105,7 @@ pub const Coff = struct { assert(self.is_image); const data_dirs = self.getDataDirectories(); - const debug_dir = data_dirs[@enumToInt(DirectoryEntry.DEBUG)]; + const debug_dir = data_dirs[@intFromEnum(DirectoryEntry.DEBUG)]; var stream = std.io.fixedBufferStream(self.data); const reader = stream.reader(); @@ -1303,9 +1303,9 @@ pub const Symtab = struct { return .{ .name = raw[0..8].*, .value = mem.readIntLittle(u32, raw[8..12]), - .section_number = @intToEnum(SectionNumber, mem.readIntLittle(u16, raw[12..14])), + .section_number = @enumFromInt(SectionNumber, mem.readIntLittle(u16, raw[12..14])), .type = @bitCast(SymType, mem.readIntLittle(u16, raw[14..16])), - .storage_class = @intToEnum(StorageClass, raw[16]), + .storage_class = @enumFromInt(StorageClass, raw[16]), .number_of_aux_symbols = raw[17], }; } @@ -1333,7 +1333,7 @@ pub const Symtab = struct { fn asWeakExtDef(raw: []const u8) WeakExternalDefinition { return .{ .tag_index = mem.readIntLittle(u32, raw[0..4]), - .flag = @intToEnum(WeakExternalFlag, mem.readIntLittle(u32, raw[4..8])), + .flag = @enumFromInt(WeakExternalFlag, mem.readIntLittle(u32, raw[4..8])), .unused = raw[8..18].*, }; } @@ -1351,7 +1351,7 @@ pub const Symtab = struct { .number_of_linenumbers = mem.readIntLittle(u16, raw[6..8]), .checksum = mem.readIntLittle(u32, raw[8..12]), .number = mem.readIntLittle(u16, raw[12..14]), - .selection = @intToEnum(ComdatSelection, raw[14]), + .selection = @enumFromInt(ComdatSelection, raw[14]), .unused = raw[15..18].*, }; } diff --git a/lib/std/compress/deflate/huffman_bit_writer.zig b/lib/std/compress/deflate/huffman_bit_writer.zig index 0b76d9d89d2a..a852287b538b 100644 --- a/lib/std/compress/deflate/huffman_bit_writer.zig +++ b/lib/std/compress/deflate/huffman_bit_writer.zig @@ -527,7 +527,7 @@ pub fn HuffmanBitWriter(comptime WriterType: type) type { } // Huffman. - if (@ptrToInt(literal_encoding) == @ptrToInt(&self.fixed_literal_encoding)) { + if (@intFromPtr(literal_encoding) == @intFromPtr(&self.fixed_literal_encoding)) { try self.writeFixedHeader(eof); } else { try self.writeDynamicHeader(num_literals, num_offsets, num_codegens, eof); diff --git a/lib/std/compress/lzma/decode.zig b/lib/std/compress/lzma/decode.zig index f539abf8b1fc..a6adb941a498 100644 --- a/lib/std/compress/lzma/decode.zig +++ b/lib/std/compress/lzma/decode.zig @@ -326,7 +326,7 @@ pub const DecoderState = struct { while (result < 0x100) { const match_bit = (match_byte >> 7) & 1; match_byte <<= 1; - const bit = @boolToInt(try decoder.decodeBit( + const bit = @intFromBool(try decoder.decodeBit( reader, &probs[((@as(usize, 1) + match_bit) << 8) + result], update, @@ -339,7 +339,7 @@ pub const DecoderState = struct { } while (result < 0x100) { - result = (result << 1) ^ @boolToInt(try decoder.decodeBit(reader, &probs[result], update)); + result = (result << 1) ^ @intFromBool(try decoder.decodeBit(reader, &probs[result], update)); } return @truncate(u8, result - 0x100); diff --git a/lib/std/compress/lzma/decode/rangecoder.zig b/lib/std/compress/lzma/decode/rangecoder.zig index 5a2f309fe4d8..54d2195e33a6 100644 --- a/lib/std/compress/lzma/decode/rangecoder.zig +++ b/lib/std/compress/lzma/decode/rangecoder.zig @@ -57,7 +57,7 @@ pub const RangeDecoder = struct { var result: u32 = 0; var i: usize = 0; while (i < count) : (i += 1) - result = (result << 1) ^ @boolToInt(try self.getBit(reader)); + result = (result << 1) ^ @intFromBool(try self.getBit(reader)); return result; } @@ -93,7 +93,7 @@ pub const RangeDecoder = struct { var i: @TypeOf(num_bits) = 0; while (i < num_bits) : (i += 1) { const bit = try self.decodeBit(reader, &probs[tmp], update); - tmp = (tmp << 1) ^ @boolToInt(bit); + tmp = (tmp << 1) ^ @intFromBool(bit); } return tmp - (@as(u32, 1) << num_bits); } @@ -110,7 +110,7 @@ pub const RangeDecoder = struct { var tmp: usize = 1; var i: @TypeOf(num_bits) = 0; while (i < num_bits) : (i += 1) { - const bit = @boolToInt(try self.decodeBit(reader, &probs[offset + tmp], update)); + const bit = @intFromBool(try self.decodeBit(reader, &probs[offset + tmp], update)); tmp = (tmp << 1) ^ bit; result ^= @as(u32, bit) << i; } diff --git a/lib/std/compress/xz.zig b/lib/std/compress/xz.zig index 40735ca6b6c9..5debc81835ef 100644 --- a/lib/std/compress/xz.zig +++ b/lib/std/compress/xz.zig @@ -18,7 +18,7 @@ fn readStreamFlags(reader: anytype, check: *Check) !void { if (reserved1 != 0) return error.CorruptInput; - check.* = @intToEnum(Check, try bit_reader.readBitsNoEof(u4, 4)); + check.* = @enumFromInt(Check, try bit_reader.readBitsNoEof(u4, 4)); const reserved2 = try bit_reader.readBitsNoEof(u4, 4); if (reserved2 != 0) diff --git a/lib/std/compress/xz/block.zig b/lib/std/compress/xz/block.zig index 520c335794db..2a034011c2b0 100644 --- a/lib/std/compress/xz/block.zig +++ b/lib/std/compress/xz/block.zig @@ -124,12 +124,12 @@ pub fn Decoder(comptime ReaderType: type) type { _, }; - const filter_id = @intToEnum( + const filter_id = @enumFromInt( FilterId, try std.leb.readULEB128(u64, header_reader), ); - if (@enumToInt(filter_id) >= 0x4000_0000_0000_0000) + if (@intFromEnum(filter_id) >= 0x4000_0000_0000_0000) return error.CorruptInput; if (filter_id != .lzma2) diff --git a/lib/std/compress/zlib.zig b/lib/std/compress/zlib.zig index 2d90d6d6e354..98cabb473262 100644 --- a/lib/std/compress/zlib.zig +++ b/lib/std/compress/zlib.zig @@ -126,7 +126,7 @@ pub fn CompressStream(comptime WriterType: type) type { var header = ZLibHeader{ .compression_info = ZLibHeader.WINDOW_32K, .compression_method = ZLibHeader.DEFLATE, - .compression_level = @enumToInt(options.level), + .compression_level = @intFromEnum(options.level), .preset_dict = 0, .checksum = 0, }; diff --git a/lib/std/compress/zstandard/decode/block.zig b/lib/std/compress/zstandard/decode/block.zig index e2042650c6e7..40f5903a2491 100644 --- a/lib/std/compress/zstandard/decode/block.zig +++ b/lib/std/compress/zstandard/decode/block.zig @@ -894,7 +894,7 @@ pub fn decodeBlockReader( /// Decode the header of a block. pub fn decodeBlockHeader(src: *const [3]u8) frame.Zstandard.Block.Header { const last_block = src[0] & 1 == 1; - const block_type = @intToEnum(frame.Zstandard.Block.Type, (src[0] & 0b110) >> 1); + const block_type = @enumFromInt(frame.Zstandard.Block.Type, (src[0] & 0b110) >> 1); const block_size = ((src[0] & 0b11111000) >> 3) + (@as(u21, src[1]) << 5) + (@as(u21, src[2]) << 13); return .{ .last_block = last_block, @@ -1058,7 +1058,7 @@ fn decodeStreams(size_format: u2, stream_data: []const u8) !LiteralsSection.Stre /// - `error.EndOfStream` if there are not enough bytes in `source` pub fn decodeLiteralsHeader(source: anytype) !LiteralsSection.Header { const byte0 = try source.readByte(); - const block_type = @intToEnum(LiteralsSection.BlockType, byte0 & 0b11); + const block_type = @enumFromInt(LiteralsSection.BlockType, byte0 & 0b11); const size_format = @intCast(u2, (byte0 & 0b1100) >> 2); var regenerated_size: u20 = undefined; var compressed_size: ?u18 = null; @@ -1132,9 +1132,9 @@ pub fn decodeSequencesHeader( const compression_modes = try source.readByte(); - const matches_mode = @intToEnum(SequencesSection.Header.Mode, (compression_modes & 0b00001100) >> 2); - const offsets_mode = @intToEnum(SequencesSection.Header.Mode, (compression_modes & 0b00110000) >> 4); - const literal_mode = @intToEnum(SequencesSection.Header.Mode, (compression_modes & 0b11000000) >> 6); + const matches_mode = @enumFromInt(SequencesSection.Header.Mode, (compression_modes & 0b00001100) >> 2); + const offsets_mode = @enumFromInt(SequencesSection.Header.Mode, (compression_modes & 0b00110000) >> 4); + const literal_mode = @enumFromInt(SequencesSection.Header.Mode, (compression_modes & 0b11000000) >> 6); if (compression_modes & 0b11 != 0) return error.ReservedBitSet; return SequencesSection.Header{ diff --git a/lib/std/crypto/25519/edwards25519.zig b/lib/std/crypto/25519/edwards25519.zig index b9ce14bc9262..50f34c45f37f 100644 --- a/lib/std/crypto/25519/edwards25519.zig +++ b/lib/std/crypto/25519/edwards25519.zig @@ -38,11 +38,11 @@ pub const Edwards25519 = struct { const vxx = x.sq().mul(v); const has_m_root = vxx.sub(u).isZero(); const has_p_root = vxx.add(u).isZero(); - if ((@boolToInt(has_m_root) | @boolToInt(has_p_root)) == 0) { // best-effort to avoid two conditional branches + if ((@intFromBool(has_m_root) | @intFromBool(has_p_root)) == 0) { // best-effort to avoid two conditional branches return error.InvalidEncoding; } - x.cMov(x.mul(Fe.sqrtm1), 1 - @boolToInt(has_m_root)); - x.cMov(x.neg(), @boolToInt(x.isNegative()) ^ (s[31] >> 7)); + x.cMov(x.mul(Fe.sqrtm1), 1 - @intFromBool(has_m_root)); + x.cMov(x.neg(), @intFromBool(x.isNegative()) ^ (s[31] >> 7)); const t = x.mul(y); return Edwards25519{ .x = x, .y = y, .z = z, .t = t }; } @@ -51,7 +51,7 @@ pub const Edwards25519 = struct { pub fn toBytes(p: Edwards25519) [encoded_length]u8 { const zi = p.z.invert(); var s = p.y.mul(zi).toBytes(); - s[31] ^= @as(u8, @boolToInt(p.x.mul(zi).isNegative())) << 7; + s[31] ^= @as(u8, @intFromBool(p.x.mul(zi).isNegative())) << 7; return s; } @@ -369,7 +369,7 @@ pub const Edwards25519 = struct { // yed = (x-1)/(x+1) or 1 if the denominator is 0 var yed = x_plus_one_y_inv.mul(y).mul(x_minus_one); - yed.cMov(Fe.one, @boolToInt(x_plus_one_y_inv.isZero())); + yed.cMov(Fe.one, @intFromBool(x_plus_one_y_inv.isZero())); return Edwards25519{ .x = xed, @@ -390,9 +390,9 @@ pub const Edwards25519 = struct { const not_square = !gx1.isSquare(); // gx1 not a square => x = -x1-A - x.cMov(x.neg(), @boolToInt(not_square)); + x.cMov(x.neg(), @intFromBool(not_square)); x2 = Fe.zero; - x2.cMov(Fe.edwards25519a, @boolToInt(not_square)); + x2.cMov(Fe.edwards25519a, @intFromBool(not_square)); x = x.sub(x2); // We have y = sqrt(gx1) or sqrt(gx2) with gx2 = gx1*(A+x1)/(-x1) @@ -408,7 +408,7 @@ pub const Edwards25519 = struct { const y_sign = !elr.not_square; const y_neg = elr.y.neg(); - elr.y.cMov(y_neg, @boolToInt(elr.y.isNegative()) ^ @boolToInt(y_sign)); + elr.y.cMov(y_neg, @intFromBool(elr.y.isNegative()) ^ @intFromBool(y_sign)); return montToEd(elr.x, elr.y).clearCofactor(); } @@ -486,7 +486,7 @@ pub const Edwards25519 = struct { const elr = elligator2(Fe.fromBytes(s)); var p = montToEd(elr.x, elr.y); const p_neg = p.neg(); - p.cMov(p_neg, @boolToInt(p.x.isNegative()) ^ x_sign); + p.cMov(p_neg, @intFromBool(p.x.isNegative()) ^ x_sign); return p.clearCofactor(); } }; diff --git a/lib/std/crypto/25519/field.zig b/lib/std/crypto/25519/field.zig index f6265cba488e..eec83f3d2e9d 100644 --- a/lib/std/crypto/25519/field.zig +++ b/lib/std/crypto/25519/field.zig @@ -387,7 +387,7 @@ pub const Fe = struct { /// Return the absolute value of a field element pub fn abs(a: Fe) Fe { var r = a; - r.cMov(a.neg(), @boolToInt(a.isNegative())); + r.cMov(a.neg(), @intFromBool(a.isNegative())); return r; } @@ -412,7 +412,7 @@ pub const Fe = struct { const m_root2 = m_root.sq(); e = x2.sub(m_root2); var x = p_root; - x.cMov(m_root, @boolToInt(e.isZero())); + x.cMov(m_root, @intFromBool(e.isZero())); return x; } diff --git a/lib/std/crypto/25519/ristretto255.zig b/lib/std/crypto/25519/ristretto255.zig index e33bdb496d07..d12a672e7def 100644 --- a/lib/std/crypto/25519/ristretto255.zig +++ b/lib/std/crypto/25519/ristretto255.zig @@ -30,8 +30,8 @@ pub const Ristretto255 = struct { const has_p_root = p_root_check.isZero(); const has_f_root = f_root_check.isZero(); const x_sqrtm1 = x.mul(Fe.sqrtm1); // x*sqrt(-1) - x.cMov(x_sqrtm1, @boolToInt(has_p_root) | @boolToInt(has_f_root)); - return .{ .ratio_is_square = @boolToInt(has_m_root) | @boolToInt(has_p_root), .root = x.abs() }; + x.cMov(x_sqrtm1, @intFromBool(has_p_root) | @intFromBool(has_f_root)); + return .{ .ratio_is_square = @intFromBool(has_m_root) | @intFromBool(has_p_root), .root = x.abs() }; } fn rejectNonCanonical(s: [encoded_length]u8) NonCanonicalError!void { @@ -67,7 +67,7 @@ pub const Ristretto255 = struct { x = x.mul(s_); x = x.add(x).abs(); const t = x.mul(y); - if ((1 - inv_sqrt.ratio_is_square) | @boolToInt(t.isNegative()) | @boolToInt(y.isZero()) != 0) { + if ((1 - inv_sqrt.ratio_is_square) | @intFromBool(t.isNegative()) | @intFromBool(y.isZero()) != 0) { return error.InvalidEncoding; } const p: Curve = .{ @@ -96,7 +96,7 @@ pub const Ristretto255 = struct { const eden = den1.mul(Fe.edwards25519sqrtamd); // den1/sqrt(a-d) const t_z_inv = p.t.mul(z_inv); // T*z_inv - const rotate = @boolToInt(t_z_inv.isNegative()); + const rotate = @intFromBool(t_z_inv.isNegative()); var x = p.x; var y = p.y; var den_inv = den2; @@ -106,7 +106,7 @@ pub const Ristretto255 = struct { const x_z_inv = x.mul(z_inv); const yneg = y.neg(); - y.cMov(yneg, @boolToInt(x_z_inv.isNegative())); + y.cMov(yneg, @intFromBool(x_z_inv.isNegative())); return p.z.sub(y).mul(den_inv).abs().toBytes(); } @@ -163,7 +163,7 @@ pub const Ristretto255 = struct { const q_ = &q.p; const a = p_.x.mul(q_.y).equivalent(p_.y.mul(q_.x)); const b = p_.y.mul(q_.y).equivalent(p_.x.mul(q_.x)); - return (@boolToInt(a) | @boolToInt(b)) != 0; + return (@intFromBool(a) | @intFromBool(b)) != 0; } }; diff --git a/lib/std/crypto/Certificate.zig b/lib/std/crypto/Certificate.zig index b8dc636693c0..51eb97ab3244 100644 --- a/lib/std/crypto/Certificate.zig +++ b/lib/std/crypto/Certificate.zig @@ -312,7 +312,7 @@ pub const Parsed = struct { while (name_i < general_names.slice.end) { const general_name = try der.Element.parse(subject_alt_name, name_i); name_i = general_name.slice.end; - switch (@intToEnum(GeneralNameTag, @enumToInt(general_name.identifier.tag))) { + switch (@enumFromInt(GeneralNameTag, @intFromEnum(general_name.identifier.tag))) { .dNSName => { const dns_name = subject_alt_name[general_name.slice.start..general_name.slice.end]; if (checkHostName(host_name, dns_name)) return; @@ -597,8 +597,8 @@ const Date = struct { var month: u4 = 1; while (month < date.month) : (month += 1) { const days: u64 = std.time.epoch.getDaysInMonth( - @intToEnum(std.time.epoch.YearLeapKind, @boolToInt(is_leap)), - @intToEnum(std.time.epoch.Month, month), + @enumFromInt(std.time.epoch.YearLeapKind, @intFromBool(is_leap)), + @enumFromInt(std.time.epoch.Month, month), ); sec += days * std.time.epoch.secs_per_day; } diff --git a/lib/std/crypto/Certificate/Bundle/macos.zig b/lib/std/crypto/Certificate/Bundle/macos.zig index dba052079573..bd7100eb4674 100644 --- a/lib/std/crypto/Certificate/Bundle/macos.zig +++ b/lib/std/crypto/Certificate/Bundle/macos.zig @@ -42,7 +42,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { const table_header = try reader.readStructBig(TableHeader); - if (@intToEnum(std.os.darwin.cssm.DB_RECORDTYPE, table_header.table_id) != .X509_CERTIFICATE) { + if (@enumFromInt(std.os.darwin.cssm.DB_RECORDTYPE, table_header.table_id) != .X509_CERTIFICATE) { continue; } diff --git a/lib/std/crypto/argon2.zig b/lib/std/crypto/argon2.zig index 43dbe3e33260..40df3290c0a5 100644 --- a/lib/std/crypto/argon2.zig +++ b/lib/std/crypto/argon2.zig @@ -115,7 +115,7 @@ fn initHash( mem.writeIntLittle(u32, parameters[8..12], params.m); mem.writeIntLittle(u32, parameters[12..16], params.t); mem.writeIntLittle(u32, parameters[16..20], version); - mem.writeIntLittle(u32, parameters[20..24], @enumToInt(mode)); + mem.writeIntLittle(u32, parameters[20..24], @intFromEnum(mode)); b2.update(¶meters); mem.writeIntLittle(u32, &tmp, @intCast(u32, password.len)); b2.update(&tmp); @@ -292,7 +292,7 @@ fn processSegment( in[2] = slice; in[3] = memory; in[4] = passes; - in[5] = @enumToInt(mode); + in[5] = @intFromEnum(mode); } var index: u32 = 0; if (n == 0 and slice == 0) { diff --git a/lib/std/crypto/benchmark.zig b/lib/std/crypto/benchmark.zig index 26f5d50979ec..f47c334ee91f 100644 --- a/lib/std/crypto/benchmark.zig +++ b/lib/std/crypto/benchmark.zig @@ -54,8 +54,8 @@ pub fn benchmarkHash(comptime Hash: anytype, comptime bytes: comptime_int) !u64 const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, bytes / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, bytes / elapsed_s); return throughput; } @@ -95,8 +95,8 @@ pub fn benchmarkMac(comptime Mac: anytype, comptime bytes: comptime_int) !u64 { } const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, bytes / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, bytes / elapsed_s); return throughput; } @@ -125,8 +125,8 @@ pub fn benchmarkKeyExchange(comptime DhKeyExchange: anytype, comptime exchange_c } const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, exchange_count / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, exchange_count / elapsed_s); return throughput; } @@ -148,8 +148,8 @@ pub fn benchmarkSignature(comptime Signature: anytype, comptime signatures_count } const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, signatures_count / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, signatures_count / elapsed_s); return throughput; } @@ -172,8 +172,8 @@ pub fn benchmarkSignatureVerification(comptime Signature: anytype, comptime sign } const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, signatures_count / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, signatures_count / elapsed_s); return throughput; } @@ -201,8 +201,8 @@ pub fn benchmarkBatchSignatureVerification(comptime Signature: anytype, comptime } const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = batch.len * @floatToInt(u64, signatures_count / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = batch.len * @intFromFloat(u64, signatures_count / elapsed_s); return throughput; } @@ -227,8 +227,8 @@ pub fn benchmarkKem(comptime Kem: anytype, comptime kems_count: comptime_int) !u } const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, kems_count / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, kems_count / elapsed_s); return throughput; } @@ -249,8 +249,8 @@ pub fn benchmarkKemDecaps(comptime Kem: anytype, comptime kems_count: comptime_i } const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, kems_count / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, kems_count / elapsed_s); return throughput; } @@ -267,8 +267,8 @@ pub fn benchmarkKemKeyGen(comptime Kem: anytype, comptime kems_count: comptime_i } const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, kems_count / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, kems_count / elapsed_s); return throughput; } @@ -309,8 +309,8 @@ pub fn benchmarkAead(comptime Aead: anytype, comptime bytes: comptime_int) !u64 mem.doNotOptimizeAway(&in); const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, 2 * bytes / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, 2 * bytes / elapsed_s); return throughput; } @@ -338,8 +338,8 @@ pub fn benchmarkAes(comptime Aes: anytype, comptime count: comptime_int) !u64 { mem.doNotOptimizeAway(&in); const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, count / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, count / elapsed_s); return throughput; } @@ -367,8 +367,8 @@ pub fn benchmarkAes8(comptime Aes: anytype, comptime count: comptime_int) !u64 { mem.doNotOptimizeAway(&in); const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, 8 * count / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, 8 * count / elapsed_s); return throughput; } @@ -422,7 +422,7 @@ fn benchmarkPwhash( } const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; const throughput = elapsed_s / count; return throughput; diff --git a/lib/std/crypto/ff.zig b/lib/std/crypto/ff.zig index 37e3d1c1b3c8..7b298c71c2ee 100644 --- a/lib/std/crypto/ff.zig +++ b/lib/std/crypto/ff.zig @@ -637,7 +637,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type { assert(x.limbs_count() == self.limbs_count()); assert(y.limbs_count() == self.limbs_count()); const overflow = self.montgomeryLoop(&d, x, y); - const underflow = 1 -% @boolToInt(ct.limbsCmpGeq(d.v, self.v)); + const underflow = 1 -% @intFromBool(ct.limbsCmpGeq(d.v, self.v)); const need_sub = ct.eql(overflow, underflow); _ = d.v.conditionalSubWithOverflow(need_sub, self.v); d.montgomery = x.montgomery == y.montgomery; @@ -649,7 +649,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type { var d = self.zero; assert(x.limbs_count() == self.limbs_count()); const overflow = self.montgomeryLoop(&d, x, x); - const underflow = 1 -% @boolToInt(ct.limbsCmpGeq(d.v, self.v)); + const underflow = 1 -% @intFromBool(ct.limbsCmpGeq(d.v, self.v)); const need_sub = ct.eql(overflow, underflow); _ = d.v.conditionalSubWithOverflow(need_sub, self.v); d.montgomery = true; @@ -763,7 +763,7 @@ const ct = if (std.options.side_channels_mitigations == .none) ct_unprotected el const ct_protected = struct { // Returns x if on is true, otherwise y. fn select(on: bool, x: Limb, y: Limb) Limb { - const mask = @as(Limb, 0) -% @boolToInt(on); + const mask = @as(Limb, 0) -% @intFromBool(on); return y ^ (mask & (y ^ x)); } @@ -789,7 +789,7 @@ const ct_protected = struct { // Compares two big integers in constant time, returning true if x >= y. fn limbsCmpGeq(x: anytype, y: @TypeOf(x)) bool { - return @bitCast(bool, 1 - @boolToInt(ct.limbsCmpLt(x, y))); + return @bitCast(bool, 1 - @intFromBool(ct.limbsCmpLt(x, y))); } // Multiplies two limbs and returns the result as a wide limb. diff --git a/lib/std/crypto/kyber_d00.zig b/lib/std/crypto/kyber_d00.zig index dca4ab7ea760..3cb0f02c0d0a 100644 --- a/lib/std/crypto/kyber_d00.zig +++ b/lib/std/crypto/kyber_d00.zig @@ -1454,7 +1454,7 @@ fn Mat(comptime K: u8) type { // Returns `true` if a ≠b. fn ctneq(comptime len: usize, a: [len]u8, b: [len]u8) u1 { - return 1 - @boolToInt(crypto.utils.timingSafeEql([len]u8, a, b)); + return 1 - @intFromBool(crypto.utils.timingSafeEql([len]u8, a, b)); } // Copy src into dst given b = 1. diff --git a/lib/std/crypto/pcurves/p256.zig b/lib/std/crypto/pcurves/p256.zig index efda42028486..a797fbce3e2d 100644 --- a/lib/std/crypto/pcurves/p256.zig +++ b/lib/std/crypto/pcurves/p256.zig @@ -36,8 +36,8 @@ pub const P256 = struct { /// Reject the neutral element. pub fn rejectIdentity(p: P256) IdentityElementError!void { - const affine_0 = @boolToInt(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@boolToInt(p.y.isZero()) | @boolToInt(p.y.equivalent(AffineCoordinates.identityElement.y))); - const is_identity = @boolToInt(p.z.isZero()) | affine_0; + const affine_0 = @intFromBool(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@intFromBool(p.y.isZero()) | @intFromBool(p.y.equivalent(AffineCoordinates.identityElement.y))); + const is_identity = @intFromBool(p.z.isZero()) | affine_0; if (is_identity != 0) { return error.IdentityElement; } @@ -49,8 +49,8 @@ pub const P256 = struct { const y = p.y; const x3AxB = x.sq().mul(x).sub(x).sub(x).sub(x).add(B); const yy = y.sq(); - const on_curve = @boolToInt(x3AxB.equivalent(yy)); - const is_identity = @boolToInt(x.equivalent(AffineCoordinates.identityElement.x)) & @boolToInt(y.equivalent(AffineCoordinates.identityElement.y)); + const on_curve = @intFromBool(x3AxB.equivalent(yy)); + const is_identity = @intFromBool(x.equivalent(AffineCoordinates.identityElement.x)) & @intFromBool(y.equivalent(AffineCoordinates.identityElement.y)); if ((on_curve | is_identity) == 0) { return error.InvalidEncoding; } @@ -71,7 +71,7 @@ pub const P256 = struct { const x3AxB = x.sq().mul(x).sub(x).sub(x).sub(x).add(B); var y = try x3AxB.sqrt(); const yn = y.neg(); - y.cMov(yn, @boolToInt(is_odd) ^ @boolToInt(y.isOdd())); + y.cMov(yn, @intFromBool(is_odd) ^ @intFromBool(y.isOdd())); return y; } @@ -219,7 +219,7 @@ pub const P256 = struct { .y = Y3, .z = Z3, }; - ret.cMov(p, @boolToInt(q.x.isZero())); + ret.cMov(p, @intFromBool(q.x.isZero())); return ret; } @@ -288,8 +288,8 @@ pub const P256 = struct { /// Return affine coordinates. pub fn affineCoordinates(p: P256) AffineCoordinates { - const affine_0 = @boolToInt(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@boolToInt(p.y.isZero()) | @boolToInt(p.y.equivalent(AffineCoordinates.identityElement.y))); - const is_identity = @boolToInt(p.z.isZero()) | affine_0; + const affine_0 = @intFromBool(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@intFromBool(p.y.isZero()) | @intFromBool(p.y.equivalent(AffineCoordinates.identityElement.y))); + const is_identity = @intFromBool(p.z.isZero()) | affine_0; const zinv = p.z.invert(); var ret = AffineCoordinates{ .x = p.x.mul(zinv), diff --git a/lib/std/crypto/pcurves/p384.zig b/lib/std/crypto/pcurves/p384.zig index 958543084e31..3d96592f50cb 100644 --- a/lib/std/crypto/pcurves/p384.zig +++ b/lib/std/crypto/pcurves/p384.zig @@ -36,8 +36,8 @@ pub const P384 = struct { /// Reject the neutral element. pub fn rejectIdentity(p: P384) IdentityElementError!void { - const affine_0 = @boolToInt(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@boolToInt(p.y.isZero()) | @boolToInt(p.y.equivalent(AffineCoordinates.identityElement.y))); - const is_identity = @boolToInt(p.z.isZero()) | affine_0; + const affine_0 = @intFromBool(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@intFromBool(p.y.isZero()) | @intFromBool(p.y.equivalent(AffineCoordinates.identityElement.y))); + const is_identity = @intFromBool(p.z.isZero()) | affine_0; if (is_identity != 0) { return error.IdentityElement; } @@ -49,8 +49,8 @@ pub const P384 = struct { const y = p.y; const x3AxB = x.sq().mul(x).sub(x).sub(x).sub(x).add(B); const yy = y.sq(); - const on_curve = @boolToInt(x3AxB.equivalent(yy)); - const is_identity = @boolToInt(x.equivalent(AffineCoordinates.identityElement.x)) & @boolToInt(y.equivalent(AffineCoordinates.identityElement.y)); + const on_curve = @intFromBool(x3AxB.equivalent(yy)); + const is_identity = @intFromBool(x.equivalent(AffineCoordinates.identityElement.x)) & @intFromBool(y.equivalent(AffineCoordinates.identityElement.y)); if ((on_curve | is_identity) == 0) { return error.InvalidEncoding; } @@ -71,7 +71,7 @@ pub const P384 = struct { const x3AxB = x.sq().mul(x).sub(x).sub(x).sub(x).add(B); var y = try x3AxB.sqrt(); const yn = y.neg(); - y.cMov(yn, @boolToInt(is_odd) ^ @boolToInt(y.isOdd())); + y.cMov(yn, @intFromBool(is_odd) ^ @intFromBool(y.isOdd())); return y; } @@ -219,7 +219,7 @@ pub const P384 = struct { .y = Y3, .z = Z3, }; - ret.cMov(p, @boolToInt(q.x.isZero())); + ret.cMov(p, @intFromBool(q.x.isZero())); return ret; } @@ -288,8 +288,8 @@ pub const P384 = struct { /// Return affine coordinates. pub fn affineCoordinates(p: P384) AffineCoordinates { - const affine_0 = @boolToInt(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@boolToInt(p.y.isZero()) | @boolToInt(p.y.equivalent(AffineCoordinates.identityElement.y))); - const is_identity = @boolToInt(p.z.isZero()) | affine_0; + const affine_0 = @intFromBool(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@intFromBool(p.y.isZero()) | @intFromBool(p.y.equivalent(AffineCoordinates.identityElement.y))); + const is_identity = @intFromBool(p.z.isZero()) | affine_0; const zinv = p.z.invert(); var ret = AffineCoordinates{ .x = p.x.mul(zinv), diff --git a/lib/std/crypto/pcurves/secp256k1.zig b/lib/std/crypto/pcurves/secp256k1.zig index 2d94594f615a..f0b086f9744a 100644 --- a/lib/std/crypto/pcurves/secp256k1.zig +++ b/lib/std/crypto/pcurves/secp256k1.zig @@ -89,8 +89,8 @@ pub const Secp256k1 = struct { /// Reject the neutral element. pub fn rejectIdentity(p: Secp256k1) IdentityElementError!void { - const affine_0 = @boolToInt(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@boolToInt(p.y.isZero()) | @boolToInt(p.y.equivalent(AffineCoordinates.identityElement.y))); - const is_identity = @boolToInt(p.z.isZero()) | affine_0; + const affine_0 = @intFromBool(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@intFromBool(p.y.isZero()) | @intFromBool(p.y.equivalent(AffineCoordinates.identityElement.y))); + const is_identity = @intFromBool(p.z.isZero()) | affine_0; if (is_identity != 0) { return error.IdentityElement; } @@ -102,8 +102,8 @@ pub const Secp256k1 = struct { const y = p.y; const x3B = x.sq().mul(x).add(B); const yy = y.sq(); - const on_curve = @boolToInt(x3B.equivalent(yy)); - const is_identity = @boolToInt(x.equivalent(AffineCoordinates.identityElement.x)) & @boolToInt(y.equivalent(AffineCoordinates.identityElement.y)); + const on_curve = @intFromBool(x3B.equivalent(yy)); + const is_identity = @intFromBool(x.equivalent(AffineCoordinates.identityElement.x)) & @intFromBool(y.equivalent(AffineCoordinates.identityElement.y)); if ((on_curve | is_identity) == 0) { return error.InvalidEncoding; } @@ -124,7 +124,7 @@ pub const Secp256k1 = struct { const x3B = x.sq().mul(x).add(B); var y = try x3B.sqrt(); const yn = y.neg(); - y.cMov(yn, @boolToInt(is_odd) ^ @boolToInt(y.isOdd())); + y.cMov(yn, @intFromBool(is_odd) ^ @intFromBool(y.isOdd())); return y; } @@ -253,7 +253,7 @@ pub const Secp256k1 = struct { .y = Y3, .z = Z3, }; - ret.cMov(p, @boolToInt(q.x.isZero())); + ret.cMov(p, @intFromBool(q.x.isZero())); return ret; } @@ -316,8 +316,8 @@ pub const Secp256k1 = struct { /// Return affine coordinates. pub fn affineCoordinates(p: Secp256k1) AffineCoordinates { - const affine_0 = @boolToInt(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@boolToInt(p.y.isZero()) | @boolToInt(p.y.equivalent(AffineCoordinates.identityElement.y))); - const is_identity = @boolToInt(p.z.isZero()) | affine_0; + const affine_0 = @intFromBool(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@intFromBool(p.y.isZero()) | @intFromBool(p.y.equivalent(AffineCoordinates.identityElement.y))); + const is_identity = @intFromBool(p.z.isZero()) | affine_0; const zinv = p.z.invert(); var ret = AffineCoordinates{ .x = p.x.mul(zinv), diff --git a/lib/std/crypto/tls.zig b/lib/std/crypto/tls.zig index 0498c9c2978f..4c03c4897333 100644 --- a/lib/std/crypto/tls.zig +++ b/lib/std/crypto/tls.zig @@ -48,8 +48,8 @@ pub const hello_retry_request_sequence = [32]u8{ }; pub const close_notify_alert = [_]u8{ - @enumToInt(AlertLevel.warning), - @enumToInt(AlertDescription.close_notify), + @intFromEnum(AlertLevel.warning), + @intFromEnum(AlertDescription.close_notify), }; pub const ProtocolVersion = enum(u16) { @@ -399,7 +399,7 @@ pub fn hmac(comptime Hmac: type, message: []const u8, key: [Hmac.key_length]u8) } pub inline fn extension(comptime et: ExtensionType, bytes: anytype) [2 + 2 + bytes.len]u8 { - return int2(@enumToInt(et)) ++ array(1, bytes); + return int2(@intFromEnum(et)) ++ array(1, bytes); } pub inline fn array(comptime elem_size: comptime_int, bytes: anytype) [2 + bytes.len]u8 { @@ -411,8 +411,8 @@ pub inline fn enum_array(comptime E: type, comptime tags: []const E) [2 + @sizeO assert(@sizeOf(E) == 2); var result: [tags.len * 2]u8 = undefined; for (tags, 0..) |elem, i| { - result[i * 2] = @truncate(u8, @enumToInt(elem) >> 8); - result[i * 2 + 1] = @truncate(u8, @enumToInt(elem)); + result[i * 2] = @truncate(u8, @intFromEnum(elem) >> 8); + result[i * 2 + 1] = @truncate(u8, @intFromEnum(elem)); } return array(2, result); } @@ -513,7 +513,7 @@ pub const Decoder = struct { .Enum => |info| { const int = d.decode(info.tag_type); if (info.is_exhaustive) @compileError("exhaustive enum cannot be used"); - return @intToEnum(T, int); + return @enumFromInt(T, int); }, else => @compileError("unsupported type: " ++ @typeName(T)), } diff --git a/lib/std/crypto/tls/Client.zig b/lib/std/crypto/tls/Client.zig index 5b9b00538a4d..94ecf0d3ef7d 100644 --- a/lib/std/crypto/tls/Client.zig +++ b/lib/std/crypto/tls/Client.zig @@ -180,14 +180,14 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In .x25519, })) ++ tls.extension( .key_share, - array(1, int2(@enumToInt(tls.NamedGroup.x25519)) ++ + array(1, int2(@intFromEnum(tls.NamedGroup.x25519)) ++ array(1, x25519_kp.public_key) ++ - int2(@enumToInt(tls.NamedGroup.secp256r1)) ++ + int2(@intFromEnum(tls.NamedGroup.secp256r1)) ++ array(1, secp256r1_kp.public_key.toUncompressedSec1()) ++ - int2(@enumToInt(tls.NamedGroup.x25519_kyber768d00)) ++ + int2(@intFromEnum(tls.NamedGroup.x25519_kyber768d00)) ++ array(1, x25519_kp.public_key ++ kyber768_kp.public_key.toBytes())), ) ++ - int2(@enumToInt(tls.ExtensionType.server_name)) ++ + int2(@intFromEnum(tls.ExtensionType.server_name)) ++ int2(host_len + 5) ++ // byte length of this extension payload int2(host_len + 3) ++ // server_name_list byte count [1]u8{0x00} ++ // name_type @@ -200,7 +200,7 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In const legacy_compression_methods = 0x0100; const client_hello = - int2(@enumToInt(tls.ProtocolVersion.tls_1_2)) ++ + int2(@intFromEnum(tls.ProtocolVersion.tls_1_2)) ++ hello_rand ++ [1]u8{32} ++ legacy_session_id ++ cipher_suites ++ @@ -208,12 +208,12 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In extensions_header; const out_handshake = - [_]u8{@enumToInt(tls.HandshakeType.client_hello)} ++ + [_]u8{@intFromEnum(tls.HandshakeType.client_hello)} ++ int3(@intCast(u24, client_hello.len + host_len)) ++ client_hello; const plaintext_header = [_]u8{ - @enumToInt(tls.ContentType.handshake), + @intFromEnum(tls.ContentType.handshake), 0x03, 0x01, // legacy_record_version } ++ int2(@intCast(u16, out_handshake.len + host_len)) ++ out_handshake; @@ -348,7 +348,7 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In if (!have_shared_key) return error.TlsIllegalParameter; const tls_version = if (supported_version == 0) legacy_version else supported_version; - if (tls_version != @enumToInt(tls.ProtocolVersion.tls_1_3)) + if (tls_version != @intFromEnum(tls.ProtocolVersion.tls_1_3)) return error.TlsIllegalParameter; switch (cipher_suite_tag) { @@ -466,7 +466,7 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In }, }; - const inner_ct = @intToEnum(tls.ContentType, cleartext[cleartext.len - 1]); + const inner_ct = @enumFromInt(tls.ContentType, cleartext[cleartext.len - 1]); if (inner_ct != .handshake) return error.TlsUnexpectedMessage; var ctd = tls.Decoder.fromTheirSlice(cleartext[0 .. cleartext.len - 1]); @@ -624,7 +624,7 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In if (handshake_state != .finished) return error.TlsUnexpectedMessage; // This message is to trick buggy proxies into behaving correctly. const client_change_cipher_spec_msg = [_]u8{ - @enumToInt(tls.ContentType.change_cipher_spec), + @intFromEnum(tls.ContentType.change_cipher_spec), 0x03, 0x03, // legacy protocol version 0x00, 0x01, // length 0x01, @@ -640,14 +640,14 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In const handshake_hash = p.transcript_hash.finalResult(); const verify_data = tls.hmac(P.Hmac, &handshake_hash, p.client_finished_key); const out_cleartext = [_]u8{ - @enumToInt(tls.HandshakeType.finished), + @intFromEnum(tls.HandshakeType.finished), 0, 0, verify_data.len, // length - } ++ verify_data ++ [1]u8{@enumToInt(tls.ContentType.handshake)}; + } ++ verify_data ++ [1]u8{@intFromEnum(tls.ContentType.handshake)}; const wrapped_len = out_cleartext.len + P.AEAD.tag_length; var finished_msg = [_]u8{ - @enumToInt(tls.ContentType.application_data), + @intFromEnum(tls.ContentType.application_data), 0x03, 0x03, // legacy protocol version 0, wrapped_len, // byte length of encrypted record } ++ @as([wrapped_len]u8, undefined); @@ -809,7 +809,7 @@ fn prepareCiphertextRecord( }; @memcpy(cleartext_buf[0..encrypted_content_len], bytes[bytes_i..][0..encrypted_content_len]); - cleartext_buf[encrypted_content_len] = @enumToInt(inner_content_type); + cleartext_buf[encrypted_content_len] = @intFromEnum(inner_content_type); bytes_i += encrypted_content_len; const ciphertext_len = encrypted_content_len + 1; const cleartext = cleartext_buf[0..ciphertext_len]; @@ -817,8 +817,8 @@ fn prepareCiphertextRecord( const record_start = ciphertext_end; const ad = ciphertext_buf[ciphertext_end..][0..5]; ad.* = - [_]u8{@enumToInt(tls.ContentType.application_data)} ++ - int2(@enumToInt(tls.ProtocolVersion.tls_1_2)) ++ + [_]u8{@intFromEnum(tls.ContentType.application_data)} ++ + int2(@intFromEnum(tls.ProtocolVersion.tls_1_2)) ++ int2(ciphertext_len + P.AEAD.tag_length); ciphertext_end += ad.len; const ciphertext = ciphertext_buf[ciphertext_end..][0..ciphertext_len]; @@ -1037,7 +1037,7 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.os.iovec) in = 0; continue; } - const ct = @intToEnum(tls.ContentType, frag[in]); + const ct = @enumFromInt(tls.ContentType, frag[in]); in += 1; const legacy_version = mem.readIntBig(u16, frag[in..][0..2]); in += 2; @@ -1070,8 +1070,8 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.os.iovec) switch (ct) { .alert => { if (in + 2 > frag.len) return error.TlsDecodeError; - const level = @intToEnum(tls.AlertLevel, frag[in]); - const desc = @intToEnum(tls.AlertDescription, frag[in + 1]); + const level = @enumFromInt(tls.AlertLevel, frag[in]); + const desc = @enumFromInt(tls.AlertDescription, frag[in + 1]); _ = level; try desc.toError(); @@ -1105,11 +1105,11 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.os.iovec) c.read_seq = try std.math.add(u64, c.read_seq, 1); - const inner_ct = @intToEnum(tls.ContentType, cleartext[cleartext.len - 1]); + const inner_ct = @enumFromInt(tls.ContentType, cleartext[cleartext.len - 1]); switch (inner_ct) { .alert => { - const level = @intToEnum(tls.AlertLevel, cleartext[0]); - const desc = @intToEnum(tls.AlertDescription, cleartext[1]); + const level = @enumFromInt(tls.AlertLevel, cleartext[0]); + const desc = @enumFromInt(tls.AlertDescription, cleartext[1]); if (desc == .close_notify) { c.received_close_notify = true; c.partial_ciphertext_end = c.partial_ciphertext_idx; @@ -1124,7 +1124,7 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.os.iovec) .handshake => { var ct_i: usize = 0; while (true) { - const handshake_type = @intToEnum(tls.HandshakeType, cleartext[ct_i]); + const handshake_type = @enumFromInt(tls.HandshakeType, cleartext[ct_i]); ct_i += 1; const handshake_len = mem.readIntBig(u24, cleartext[ct_i..][0..3]); ct_i += 3; @@ -1148,7 +1148,7 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.os.iovec) } c.read_seq = 0; - switch (@intToEnum(tls.KeyUpdateRequest, handshake[0])) { + switch (@enumFromInt(tls.KeyUpdateRequest, handshake[0])) { .update_requested => { switch (c.application_cipher) { inline else => |*p| { diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 3015c30bfb4e..e0726d5444db 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -461,7 +461,7 @@ pub const StackIterator = struct { if (native_os == .freestanding) return true; const aligned_address = address & ~@intCast(usize, (mem.page_size - 1)); - const aligned_memory = @intToPtr([*]align(mem.page_size) u8, aligned_address)[0..mem.page_size]; + const aligned_memory = @ptrFromInt([*]align(mem.page_size) u8, aligned_address)[0..mem.page_size]; if (native_os != .windows) { if (native_os != .wasi) { @@ -511,7 +511,7 @@ pub const StackIterator = struct { if (fp == 0 or !mem.isAligned(fp, @alignOf(usize)) or !isValidMemory(fp)) return null; - const new_fp = math.add(usize, @intToPtr(*const usize, fp).*, fp_bias) catch return null; + const new_fp = math.add(usize, @ptrFromInt(*const usize, fp).*, fp_bias) catch return null; // Sanity check: the stack grows down thus all the parent frames must be // be at addresses that are greater (or equal) than the previous one. @@ -520,7 +520,7 @@ pub const StackIterator = struct { if (new_fp != 0 and new_fp < self.fp) return null; - const new_pc = @intToPtr( + const new_pc = @ptrFromInt( *const usize, math.add(usize, fp, pc_offset) catch return null, ).*; @@ -584,12 +584,12 @@ pub noinline fn walkStackWindows(addresses: []usize) usize { ); } else { // leaf function - context.setIp(@intToPtr(*u64, current_regs.sp).*); + context.setIp(@ptrFromInt(*u64, current_regs.sp).*); context.setSp(current_regs.sp + @sizeOf(usize)); } const next_regs = context.getRegs(); - if (next_regs.sp < @ptrToInt(tib.StackLimit) or next_regs.sp > @ptrToInt(tib.StackBase)) { + if (next_regs.sp < @intFromPtr(tib.StackLimit) or next_regs.sp > @intFromPtr(tib.StackBase)) { break; } @@ -1216,7 +1216,7 @@ pub const DebugInfo = struct { var module_valid = true; while (module_valid) { const module_info = try debug_info.modules.addOne(allocator); - module_info.base_address = @ptrToInt(module_entry.modBaseAddr); + module_info.base_address = @intFromPtr(module_entry.modBaseAddr); module_info.size = module_entry.modBaseSize; module_info.name = allocator.dupe(u8, mem.sliceTo(&module_entry.szModule, 0)) catch &.{}; module_valid = windows.kernel32.Module32Next(handle, &module_entry) == 1; @@ -1283,9 +1283,9 @@ pub const DebugInfo = struct { var it = macho.LoadCommandIterator{ .ncmds = header.ncmds, - .buffer = @alignCast(@alignOf(u64), @intToPtr( + .buffer = @alignCast(@alignOf(u64), @ptrFromInt( [*]u8, - @ptrToInt(header) + @sizeOf(macho.mach_header_64), + @intFromPtr(header) + @sizeOf(macho.mach_header_64), ))[0..header.sizeofcmds], }; while (it.next()) |cmd| switch (cmd.cmd()) { @@ -1332,7 +1332,7 @@ pub const DebugInfo = struct { return obj_di; } - const mapped_module = @intToPtr([*]const u8, module.base_address)[0..module.size]; + const mapped_module = @ptrFromInt([*]const u8, module.base_address)[0..module.size]; const obj_di = try self.allocator.create(ModuleDebugInfo); errdefer self.allocator.destroy(obj_di); @@ -1897,11 +1897,11 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any resetSegfaultHandler(); const addr = switch (native_os) { - .linux => @ptrToInt(info.fields.sigfault.addr), - .freebsd, .macos => @ptrToInt(info.addr), - .netbsd => @ptrToInt(info.info.reason.fault.addr), - .openbsd => @ptrToInt(info.data.fault.addr), - .solaris => @ptrToInt(info.reason.fault.addr), + .linux => @intFromPtr(info.fields.sigfault.addr), + .freebsd, .macos => @intFromPtr(info.addr), + .netbsd => @intFromPtr(info.info.reason.fault.addr), + .openbsd => @intFromPtr(info.data.fault.addr), + .solaris => @intFromPtr(info.reason.fault.addr), else => unreachable, }; @@ -2008,7 +2008,7 @@ fn handleSegfaultWindowsExtra( msg: u8, label: ?[]const u8, ) noreturn { - const exception_address = @ptrToInt(info.ExceptionRecord.ExceptionAddress); + const exception_address = @intFromPtr(info.ExceptionRecord.ExceptionAddress); if (@hasDecl(windows, "CONTEXT")) { nosuspend switch (panic_stage) { 0 => { diff --git a/lib/std/dynamic_library.zig b/lib/std/dynamic_library.zig index 928d0cc9c338..38c5de9cad60 100644 --- a/lib/std/dynamic_library.zig +++ b/lib/std/dynamic_library.zig @@ -71,18 +71,18 @@ pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator { while (_DYNAMIC[i].d_tag != elf.DT_NULL) : (i += 1) { switch (_DYNAMIC[i].d_tag) { elf.DT_DEBUG => { - const ptr = @intToPtr(?*RDebug, _DYNAMIC[i].d_val); + const ptr = @ptrFromInt(?*RDebug, _DYNAMIC[i].d_val); if (ptr) |r_debug| { if (r_debug.r_version != 1) return error.InvalidExe; break :init r_debug.r_map; } }, elf.DT_PLTGOT => { - const ptr = @intToPtr(?[*]usize, _DYNAMIC[i].d_val); + const ptr = @ptrFromInt(?[*]usize, _DYNAMIC[i].d_val); if (ptr) |got_table| { // The address to the link_map structure is stored in // the second slot - break :init @intToPtr(?*LinkMap, got_table[1]); + break :init @ptrFromInt(?*LinkMap, got_table[1]); } }, else => {}, @@ -136,7 +136,7 @@ pub const ElfDynLib = struct { if (!mem.eql(u8, eh.e_ident[0..4], elf.MAGIC)) return error.NotElfFile; if (eh.e_type != elf.ET.DYN) return error.NotDynamicLibrary; - const elf_addr = @ptrToInt(file_bytes.ptr); + const elf_addr = @intFromPtr(file_bytes.ptr); // Iterate over the program header entries to find out the // dynamic vector as well as the total size of the virtual memory. @@ -149,10 +149,10 @@ pub const ElfDynLib = struct { i += 1; ph_addr += eh.e_phentsize; }) { - const ph = @intToPtr(*elf.Phdr, ph_addr); + const ph = @ptrFromInt(*elf.Phdr, ph_addr); switch (ph.p_type) { elf.PT_LOAD => virt_addr_end = @max(virt_addr_end, ph.p_vaddr + ph.p_memsz), - elf.PT_DYNAMIC => maybe_dynv = @intToPtr([*]usize, elf_addr + ph.p_offset), + elf.PT_DYNAMIC => maybe_dynv = @ptrFromInt([*]usize, elf_addr + ph.p_offset), else => {}, } } @@ -170,7 +170,7 @@ pub const ElfDynLib = struct { ); errdefer os.munmap(all_loaded_mem); - const base = @ptrToInt(all_loaded_mem.ptr); + const base = @intFromPtr(all_loaded_mem.ptr); // Now iterate again and actually load all the program sections. { @@ -180,7 +180,7 @@ pub const ElfDynLib = struct { i += 1; ph_addr += eh.e_phentsize; }) { - const ph = @intToPtr(*elf.Phdr, ph_addr); + const ph = @ptrFromInt(*elf.Phdr, ph_addr); switch (ph.p_type) { elf.PT_LOAD => { // The VirtAddr may not be page-aligned; in such case there will be @@ -188,7 +188,7 @@ pub const ElfDynLib = struct { const aligned_addr = (base + ph.p_vaddr) & ~(@as(usize, mem.page_size) - 1); const extra_bytes = (base + ph.p_vaddr) - aligned_addr; const extended_memsz = mem.alignForward(usize, ph.p_memsz + extra_bytes, mem.page_size); - const ptr = @intToPtr([*]align(mem.page_size) u8, aligned_addr); + const ptr = @ptrFromInt([*]align(mem.page_size) u8, aligned_addr); const prot = elfToMmapProt(ph.p_flags); if ((ph.p_flags & elf.PF_W) == 0) { // If it does not need write access, it can be mapped from the fd. @@ -228,11 +228,11 @@ pub const ElfDynLib = struct { while (dynv[i] != 0) : (i += 2) { const p = base + dynv[i + 1]; switch (dynv[i]) { - elf.DT_STRTAB => maybe_strings = @intToPtr([*:0]u8, p), - elf.DT_SYMTAB => maybe_syms = @intToPtr([*]elf.Sym, p), - elf.DT_HASH => maybe_hashtab = @intToPtr([*]os.Elf_Symndx, p), - elf.DT_VERSYM => maybe_versym = @intToPtr([*]u16, p), - elf.DT_VERDEF => maybe_verdef = @intToPtr(*elf.Verdef, p), + elf.DT_STRTAB => maybe_strings = @ptrFromInt([*:0]u8, p), + elf.DT_SYMTAB => maybe_syms = @ptrFromInt([*]elf.Sym, p), + elf.DT_HASH => maybe_hashtab = @ptrFromInt([*]os.Elf_Symndx, p), + elf.DT_VERSYM => maybe_versym = @ptrFromInt([*]u16, p), + elf.DT_VERDEF => maybe_verdef = @ptrFromInt(*elf.Verdef, p), else => {}, } } @@ -261,7 +261,7 @@ pub const ElfDynLib = struct { pub fn lookup(self: *ElfDynLib, comptime T: type, name: [:0]const u8) ?T { if (self.lookupAddress("", name)) |symbol| { - return @intToPtr(T, symbol); + return @ptrFromInt(T, symbol); } else { return null; } @@ -284,7 +284,7 @@ pub const ElfDynLib = struct { if (!checkver(self.verdef.?, versym[i], vername, self.strings)) continue; } - return @ptrToInt(self.memory.ptr) + self.syms[i].st_value; + return @intFromPtr(self.memory.ptr) + self.syms[i].st_value; } return null; @@ -307,9 +307,9 @@ fn checkver(def_arg: *elf.Verdef, vsym_arg: i32, vername: []const u8, strings: [ break; if (def.vd_next == 0) return false; - def = @intToPtr(*elf.Verdef, @ptrToInt(def) + def.vd_next); + def = @ptrFromInt(*elf.Verdef, @intFromPtr(def) + def.vd_next); } - const aux = @intToPtr(*elf.Verdaux, @ptrToInt(def) + def.vd_aux); + const aux = @ptrFromInt(*elf.Verdaux, @intFromPtr(def) + def.vd_aux); return mem.eql(u8, vername, mem.sliceTo(strings + aux.vda_name, 0)); } diff --git a/lib/std/elf.zig b/lib/std/elf.zig index 751f82a9ea0c..6047abc2134d 100644 --- a/lib/std/elf.zig +++ b/lib/std/elf.zig @@ -453,8 +453,8 @@ pub const Header = struct { }; const machine = if (need_bswap) blk: { - const value = @enumToInt(hdr32.e_machine); - break :blk @intToEnum(EM, @byteSwap(value)); + const value = @intFromEnum(hdr32.e_machine); + break :blk @enumFromInt(EM, @byteSwap(value)); } else hdr32.e_machine; return @as(Header, .{ diff --git a/lib/std/enums.zig b/lib/std/enums.zig index 757c616b9bcb..a5ceebc9b1db 100644 --- a/lib/std/enums.zig +++ b/lib/std/enums.zig @@ -53,7 +53,7 @@ pub fn values(comptime E: type) []const E { /// Returns the tag name for `e` or null if no tag exists. pub fn tagName(comptime E: type, e: E) ?[]const u8 { return inline for (@typeInfo(E).Enum.fields) |f| { - if (@enumToInt(e) == f.value) break f.name; + if (@intFromEnum(e) == f.value) break f.name; } else null; } @@ -61,11 +61,11 @@ test tagName { const E = enum(u8) { a, b, _ }; try testing.expect(tagName(E, .a) != null); try testing.expectEqualStrings("a", tagName(E, .a).?); - try testing.expect(tagName(E, @intToEnum(E, 42)) == null); + try testing.expect(tagName(E, @enumFromInt(E, 42)) == null); } /// Determines the length of a direct-mapped enum array, indexed by -/// @intCast(usize, @enumToInt(enum_value)). +/// @intCast(usize, @intFromEnum(enum_value)). /// If the enum is non-exhaustive, the resulting length will only be enough /// to hold all explicit fields. /// If the enum contains any fields with values that cannot be represented @@ -100,7 +100,7 @@ pub fn directEnumArrayLen(comptime E: type, comptime max_unused_slots: comptime_ } /// Initializes an array of Data which can be indexed by -/// @intCast(usize, @enumToInt(enum_value)). +/// @intCast(usize, @intFromEnum(enum_value)). /// If the enum is non-exhaustive, the resulting array will only be large enough /// to hold all explicit fields. /// If the enum contains any fields with values that cannot be represented @@ -136,7 +136,7 @@ test "std.enums.directEnumArray" { } /// Initializes an array of Data which can be indexed by -/// @intCast(usize, @enumToInt(enum_value)). The enum must be exhaustive. +/// @intCast(usize, @intFromEnum(enum_value)). The enum must be exhaustive. /// If the enum contains any fields with values that cannot be represented /// by usize, a compile error is issued. The max_unused_slots parameter limits /// the total number of items which have no matching enum key (holes in the enum @@ -156,7 +156,7 @@ pub fn directEnumArrayDefault( var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined; inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f| { const enum_value = @field(E, f.name); - const index = @intCast(usize, @enumToInt(enum_value)); + const index = @intCast(usize, @intFromEnum(enum_value)); result[index] = @field(init_values, f.name); } return result; @@ -341,7 +341,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { var self = initWithCount(0); inline for (@typeInfo(E).Enum.fields) |field| { const c = @field(init_counts, field.name); - const key = @intToEnum(E, field.value); + const key = @enumFromInt(E, field.value); self.counts.set(key, c); } return self; @@ -412,7 +412,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// asserts operation will not overflow any key. pub fn addSetAssertSafe(self: *Self, other: Self) void { inline for (@typeInfo(E).Enum.fields) |field| { - const key = @intToEnum(E, field.value); + const key = @enumFromInt(E, field.value); self.addAssertSafe(key, other.getCount(key)); } } @@ -420,7 +420,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// Increases the all key counts by given multiset. pub fn addSet(self: *Self, other: Self) error{Overflow}!void { inline for (@typeInfo(E).Enum.fields) |field| { - const key = @intToEnum(E, field.value); + const key = @enumFromInt(E, field.value); try self.add(key, other.getCount(key)); } } @@ -430,7 +430,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// then that key will have a key count of zero. pub fn removeSet(self: *Self, other: Self) void { inline for (@typeInfo(E).Enum.fields) |field| { - const key = @intToEnum(E, field.value); + const key = @enumFromInt(E, field.value); self.remove(key, other.getCount(key)); } } @@ -439,7 +439,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// given multiset. pub fn eql(self: Self, other: Self) bool { inline for (@typeInfo(E).Enum.fields) |field| { - const key = @intToEnum(E, field.value); + const key = @enumFromInt(E, field.value); if (self.getCount(key) != other.getCount(key)) { return false; } @@ -451,7 +451,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// equal to the given multiset. pub fn subsetOf(self: Self, other: Self) bool { inline for (@typeInfo(E).Enum.fields) |field| { - const key = @intToEnum(E, field.value); + const key = @enumFromInt(E, field.value); if (self.getCount(key) > other.getCount(key)) { return false; } @@ -463,7 +463,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// equal to the given multiset. pub fn supersetOf(self: Self, other: Self) bool { inline for (@typeInfo(E).Enum.fields) |field| { - const key = @intToEnum(E, field.value); + const key = @enumFromInt(E, field.value); if (self.getCount(key) < other.getCount(key)) { return false; } @@ -1323,14 +1323,14 @@ pub fn EnumIndexer(comptime E: type) type { pub const Key = E; pub const count = fields_len; pub fn indexOf(e: E) usize { - return @intCast(usize, @enumToInt(e) - min); + return @intCast(usize, @intFromEnum(e) - min); } pub fn keyForIndex(i: usize) E { // TODO fix addition semantics. This calculation // gives up some safety to avoid artificially limiting // the range of signed enum values to max_isize. const enum_value = if (min < 0) @bitCast(isize, i) +% min else i + min; - return @intToEnum(E, @intCast(std.meta.Tag(E), enum_value)); + return @enumFromInt(E, @intCast(std.meta.Tag(E), enum_value)); } }; } diff --git a/lib/std/event/channel.zig b/lib/std/event/channel.zig index e1c147d25a3d..3329694da7dc 100644 --- a/lib/std/event/channel.zig +++ b/lib/std/event/channel.zig @@ -247,7 +247,7 @@ pub fn Channel(comptime T: type) type { // All the "get or null" functions should resume now. var remove_count: usize = 0; while (self.or_null_queue.get()) |or_null_node| { - remove_count += @boolToInt(self.getters.remove(or_null_node.data)); + remove_count += @intFromBool(self.getters.remove(or_null_node.data)); global_event_loop.onNextTick(or_null_node.data.data.tick_node); } if (remove_count != 0) { diff --git a/lib/std/event/lock.zig b/lib/std/event/lock.zig index 9cda7f2aba8e..9da3943d5d64 100644 --- a/lib/std/event/lock.zig +++ b/lib/std/event/lock.zig @@ -55,14 +55,14 @@ pub const Lock = struct { const head = switch (self.head) { UNLOCKED => unreachable, LOCKED => null, - else => @intToPtr(*Waiter, self.head), + else => @ptrFromInt(*Waiter, self.head), }; if (head) |h| { h.tail.next = &waiter; h.tail = &waiter; } else { - self.head = @ptrToInt(&waiter); + self.head = @intFromPtr(&waiter); } suspend { @@ -102,8 +102,8 @@ pub const Lock = struct { break :blk null; }, else => { - const waiter = @intToPtr(*Waiter, self.lock.head); - self.lock.head = if (waiter.next == null) LOCKED else @ptrToInt(waiter.next); + const waiter = @ptrFromInt(*Waiter, self.lock.head); + self.lock.head = if (waiter.next == null) LOCKED else @intFromPtr(waiter.next); if (waiter.next) |next| next.tail = waiter.tail; break :blk waiter; diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index bc0162423b7f..7eec26a2b175 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -244,7 +244,7 @@ pub const Loop = struct { self.os_data.final_eventfd_event = os.linux.epoll_event{ .events = os.linux.EPOLL.IN, - .data = os.linux.epoll_data{ .ptr = @ptrToInt(&self.final_resume_node) }, + .data = os.linux.epoll_data{ .ptr = @intFromPtr(&self.final_resume_node) }, }; try os.epoll_ctl( self.os_data.epollfd, @@ -293,7 +293,7 @@ pub const Loop = struct { .flags = os.system.EV_CLEAR | os.system.EV_ADD | os.system.EV_DISABLE, .fflags = 0, .data = 0, - .udata = @ptrToInt(&eventfd_node.data.base), + .udata = @intFromPtr(&eventfd_node.data.base), }, }, .next = undefined, @@ -313,7 +313,7 @@ pub const Loop = struct { .flags = os.system.EV_ADD | os.system.EV_DISABLE, .fflags = 0, .data = 0, - .udata = @ptrToInt(&self.final_resume_node), + .udata = @intFromPtr(&self.final_resume_node), }; const final_kev_arr = @as(*const [1]os.Kevent, &self.os_data.final_kevent); _ = try os.kevent(self.os_data.kqfd, final_kev_arr, empty_kevs, null); @@ -358,7 +358,7 @@ pub const Loop = struct { .flags = os.system.EV_CLEAR | os.system.EV_ADD | os.system.EV_DISABLE | os.system.EV_ONESHOT, .fflags = 0, .data = 0, - .udata = @ptrToInt(&eventfd_node.data.base), + .udata = @intFromPtr(&eventfd_node.data.base), }, }, .next = undefined, @@ -377,7 +377,7 @@ pub const Loop = struct { .flags = os.system.EV_ADD | os.system.EV_ONESHOT | os.system.EV_DISABLE, .fflags = 0, .data = 0, - .udata = @ptrToInt(&self.final_resume_node), + .udata = @intFromPtr(&self.final_resume_node), }; const final_kev_arr = @as(*const [1]os.Kevent, &self.os_data.final_kevent); _ = try os.kevent(self.os_data.kqfd, final_kev_arr, empty_kevs, null); @@ -418,7 +418,7 @@ pub const Loop = struct { .overlapped = ResumeNode.overlapped_init, }, // this one is for sending events - .completion_key = @ptrToInt(&eventfd_node.data.base), + .completion_key = @intFromPtr(&eventfd_node.data.base), }, .next = undefined, }; @@ -488,7 +488,7 @@ pub const Loop = struct { assert(flags & os.linux.EPOLL.ET == os.linux.EPOLL.ET); var ev = os.linux.epoll_event{ .events = flags, - .data = os.linux.epoll_data{ .ptr = @ptrToInt(resume_node) }, + .data = os.linux.epoll_data{ .ptr = @intFromPtr(resume_node) }, }; try os.epoll_ctl(self.os_data.epollfd, op, fd, &ev); } @@ -619,7 +619,7 @@ pub const Loop = struct { .flags = os.system.EV_ADD | os.system.EV_ENABLE | os.system.EV_CLEAR | flags, .fflags = 0, .data = 0, - .udata = @ptrToInt(&resume_node.base), + .udata = @intFromPtr(&resume_node.base), }}; const empty_kevs = &[0]os.Kevent{}; _ = try os.kevent(self.os_data.kqfd, &kev, empty_kevs, null); @@ -1415,7 +1415,7 @@ pub const Loop = struct { var events: [1]os.linux.epoll_event = undefined; const count = os.epoll_wait(self.os_data.epollfd, events[0..], -1); for (events[0..count]) |ev| { - const resume_node = @intToPtr(*ResumeNode, ev.data.ptr); + const resume_node = @ptrFromInt(*ResumeNode, ev.data.ptr); const handle = resume_node.handle; const resume_node_id = resume_node.id; switch (resume_node_id) { @@ -1439,7 +1439,7 @@ pub const Loop = struct { const empty_kevs = &[0]os.Kevent{}; const count = os.kevent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable; for (eventlist[0..count]) |ev| { - const resume_node = @intToPtr(*ResumeNode, ev.udata); + const resume_node = @ptrFromInt(*ResumeNode, ev.udata); const handle = resume_node.handle; const resume_node_id = resume_node.id; switch (resume_node_id) { diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index c9d8e611ca8c..b3b381faee3d 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -409,15 +409,15 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T .Pointer => |info| { try writer.writeAll(@typeName(info.child) ++ "@"); if (info.size == .Slice) - try formatInt(@ptrToInt(value.ptr), 16, .lower, FormatOptions{}, writer) + try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer) else - try formatInt(@ptrToInt(value), 16, .lower, FormatOptions{}, writer); + try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer); return; }, .Optional => |info| { if (@typeInfo(info.child) == .Pointer) { try writer.writeAll(@typeName(info.child) ++ "@"); - try formatInt(@ptrToInt(value), 16, .lower, FormatOptions{}, writer); + try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer); return; } }, @@ -531,7 +531,7 @@ pub fn formatType( // Use @tagName only if value is one of known fields @setEvalBranchQuota(3 * enumInfo.fields.len); inline for (enumInfo.fields) |enumField| { - if (@enumToInt(value) == enumField.value) { + if (@intFromEnum(value) == enumField.value) { try writer.writeAll("."); try writer.writeAll(@tagName(value)); return; @@ -539,7 +539,7 @@ pub fn formatType( } try writer.writeAll("("); - try formatType(@enumToInt(value), actual_fmt, options, writer, max_depth); + try formatType(@intFromEnum(value), actual_fmt, options, writer, max_depth); try writer.writeAll(")"); }, .Union => |info| { @@ -559,7 +559,7 @@ pub fn formatType( } try writer.writeAll(" }"); } else { - try format(writer, "@{x}", .{@ptrToInt(&value)}); + try format(writer, "@{x}", .{@intFromPtr(&value)}); } }, .Struct => |info| { @@ -624,7 +624,7 @@ pub fn formatType( .Enum, .Union, .Struct => { return formatType(value.*, actual_fmt, options, writer, max_depth); }, - else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }), + else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }), }, .Many, .C => { if (actual_fmt.len == 0) @@ -1213,7 +1213,7 @@ pub fn formatFloatHexadecimal( extra_bits -= 1; } // Round to nearest, tie to even. - mantissa |= @boolToInt(mantissa & 0b100 != 0); + mantissa |= @intFromBool(mantissa & 0b100 != 0); mantissa += 1; // Drop the excess bits. mantissa >>= 2; @@ -2099,7 +2099,7 @@ test "optional" { try expectFmt("optional: null\n", "optional: {?}\n", .{value}); } { - const value = @intToPtr(?*i32, 0xf000d000); + const value = @ptrFromInt(?*i32, 0xf000d000); try expectFmt("optional: *i32@f000d000\n", "optional: {*}\n", .{value}); } } @@ -2204,7 +2204,7 @@ test "array" { var buf: [100]u8 = undefined; try expectFmt( - try bufPrint(buf[0..], "array: [3]u8@{x}\n", .{@ptrToInt(&value)}), + try bufPrint(buf[0..], "array: [3]u8@{x}\n", .{@intFromPtr(&value)}), "array: {*}\n", .{&value}, ); @@ -2218,7 +2218,7 @@ test "slice" { } { var runtime_zero: usize = 0; - const value = @intToPtr([*]align(1) const []const u8, 0xdeadbeef)[runtime_zero..runtime_zero]; + const value = @ptrFromInt([*]align(1) const []const u8, 0xdeadbeef)[runtime_zero..runtime_zero]; try expectFmt("slice: []const u8@deadbeef\n", "slice: {*}\n", .{value}); } { @@ -2248,17 +2248,17 @@ test "escape non-printable" { test "pointer" { { - const value = @intToPtr(*align(1) i32, 0xdeadbeef); + const value = @ptrFromInt(*align(1) i32, 0xdeadbeef); try expectFmt("pointer: i32@deadbeef\n", "pointer: {}\n", .{value}); try expectFmt("pointer: i32@deadbeef\n", "pointer: {*}\n", .{value}); } const FnPtr = *align(1) const fn () void; { - const value = @intToPtr(FnPtr, 0xdeadbeef); + const value = @ptrFromInt(FnPtr, 0xdeadbeef); try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value}); } { - const value = @intToPtr(FnPtr, 0xdeadbeef); + const value = @ptrFromInt(FnPtr, 0xdeadbeef); try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value}); } } @@ -2360,11 +2360,11 @@ test "non-exhaustive enum" { }; try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.One\n", "enum: {}\n", .{Enum.One}); try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.Two\n", "enum: {}\n", .{Enum.Two}); - try expectFmt("enum: fmt.test.non-exhaustive enum.Enum(4660)\n", "enum: {}\n", .{@intToEnum(Enum, 0x1234)}); + try expectFmt("enum: fmt.test.non-exhaustive enum.Enum(4660)\n", "enum: {}\n", .{@enumFromInt(Enum, 0x1234)}); try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.One\n", "enum: {x}\n", .{Enum.One}); try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.Two\n", "enum: {x}\n", .{Enum.Two}); try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.Two\n", "enum: {X}\n", .{Enum.Two}); - try expectFmt("enum: fmt.test.non-exhaustive enum.Enum(1234)\n", "enum: {x}\n", .{@intToEnum(Enum, 0x1234)}); + try expectFmt("enum: fmt.test.non-exhaustive enum.Enum(1234)\n", "enum: {x}\n", .{@enumFromInt(Enum, 0x1234)}); } test "float.scientific" { diff --git a/lib/std/fmt/errol.zig b/lib/std/fmt/errol.zig index 9ad5d218a94a..b438733589d0 100644 --- a/lib/std/fmt/errol.zig +++ b/lib/std/fmt/errol.zig @@ -59,7 +59,7 @@ pub fn roundToPrecision(float_decimal: *FloatDecimal, precision: usize, mode: Ro float_decimal.exp += 1; // Re-size the buffer to use the reserved leading byte. - const one_before = @intToPtr([*]u8, @ptrToInt(&float_decimal.digits[0]) - 1); + const one_before = @ptrFromInt([*]u8, @intFromPtr(&float_decimal.digits[0]) - 1); float_decimal.digits = one_before[0 .. float_decimal.digits.len + 1]; float_decimal.digits[0] = '1'; return; @@ -113,7 +113,7 @@ fn errolSlow(val: f64, buffer: []u8) FloatDecimal { // normalize the midpoint const e = math.frexp(val).exponent; - var exp = @floatToInt(i16, @floor(307 + @intToFloat(f64, e) * 0.30103)); + var exp = @intFromFloat(i16, @floor(307 + @floatFromInt(f64, e) * 0.30103)); if (exp < 20) { exp = 20; } else if (@intCast(usize, exp) >= lookup_table.len) { @@ -171,25 +171,25 @@ fn errolSlow(val: f64, buffer: []u8) FloatDecimal { var buf_index: usize = 0; const bound = buffer.len - 1; while (buf_index < bound) { - var hdig = @floatToInt(u8, @floor(high.val)); - if ((high.val == @intToFloat(f64, hdig)) and (high.off < 0)) hdig -= 1; + var hdig = @intFromFloat(u8, @floor(high.val)); + if ((high.val == @floatFromInt(f64, hdig)) and (high.off < 0)) hdig -= 1; - var ldig = @floatToInt(u8, @floor(low.val)); - if ((low.val == @intToFloat(f64, ldig)) and (low.off < 0)) ldig -= 1; + var ldig = @intFromFloat(u8, @floor(low.val)); + if ((low.val == @floatFromInt(f64, ldig)) and (low.off < 0)) ldig -= 1; if (ldig != hdig) break; buffer[buf_index] = hdig + '0'; buf_index += 1; - high.val -= @intToFloat(f64, hdig); - low.val -= @intToFloat(f64, ldig); + high.val -= @floatFromInt(f64, hdig); + low.val -= @floatFromInt(f64, ldig); hpMul10(&high); hpMul10(&low); } const tmp = (high.val + low.val) / 2.0; - var mdig = @floatToInt(u8, @floor(tmp + 0.5)); - if ((@intToFloat(f64, mdig) - tmp) == 0.5 and (mdig & 0x1) != 0) mdig -= 1; + var mdig = @intFromFloat(u8, @floor(tmp + 0.5)); + if ((@floatFromInt(f64, mdig) - tmp) == 0.5 and (mdig & 0x1) != 0) mdig -= 1; buffer[buf_index] = mdig + '0'; buf_index += 1; @@ -303,7 +303,7 @@ fn errolInt(val: f64, buffer: []u8) FloatDecimal { assert((val > 9.007199254740992e15) and val < (3.40282366920938e38)); - var mid = @floatToInt(u128, val); + var mid = @intFromFloat(u128, val); var low: u128 = mid - fpeint((fpnext(val) - val) / 2.0); var high: u128 = mid + fpeint((val - fpprev(val)) / 2.0); @@ -328,7 +328,7 @@ fn errolInt(val: f64, buffer: []u8) FloatDecimal { var mi: i32 = mismatch10(l64, h64); var x: u64 = 1; { - var i: i32 = @boolToInt(lf == hf); + var i: i32 = @intFromBool(lf == hf); while (i < mi) : (i += 1) { x *= 10; } @@ -342,7 +342,7 @@ fn errolInt(val: f64, buffer: []u8) FloatDecimal { if (mi != 0) { const round_up = buffer[buf_index] >= '5'; if (buf_index == 0 or (round_up and buffer[buf_index - 1] == '9')) return errolSlow(val, buffer); - buffer[buf_index - 1] += @boolToInt(round_up); + buffer[buf_index - 1] += @intFromBool(round_up); } else { buf_index += 1; } @@ -360,8 +360,8 @@ fn errolInt(val: f64, buffer: []u8) FloatDecimal { fn errolFixed(val: f64, buffer: []u8) FloatDecimal { assert((val >= 16.0) and (val < 9.007199254740992e15)); - const u = @floatToInt(u64, val); - const n = @intToFloat(f64, u); + const u = @intFromFloat(u64, val); + const n = @floatFromInt(f64, u); var mid = val - n; var lo = ((fpprev(val) - n) + mid) / 2.0; @@ -375,16 +375,16 @@ fn errolFixed(val: f64, buffer: []u8) FloatDecimal { if (mid != 0.0) { while (mid != 0.0) { lo *= 10.0; - const ldig = @floatToInt(i32, lo); - lo -= @intToFloat(f64, ldig); + const ldig = @intFromFloat(i32, lo); + lo -= @floatFromInt(f64, ldig); mid *= 10.0; - const mdig = @floatToInt(i32, mid); - mid -= @intToFloat(f64, mdig); + const mdig = @intFromFloat(i32, mid); + mid -= @floatFromInt(f64, mdig); hi *= 10.0; - const hdig = @floatToInt(i32, hi); - hi -= @intToFloat(f64, hdig); + const hdig = @intFromFloat(i32, hi); + hi -= @floatFromInt(f64, hdig); buffer[j] = @intCast(u8, mdig + '0'); j += 1; diff --git a/lib/std/fmt/parse_float/convert_eisel_lemire.zig b/lib/std/fmt/parse_float/convert_eisel_lemire.zig index ff7169530371..5c49553a14d7 100644 --- a/lib/std/fmt/parse_float/convert_eisel_lemire.zig +++ b/lib/std/fmt/parse_float/convert_eisel_lemire.zig @@ -74,7 +74,7 @@ pub fn convertEiselLemire(comptime T: type, q: i64, w_: u64) ?BiasedFp(f64) { mantissa = math.shr(u64, mantissa, -power2 + 1); mantissa += mantissa & 1; mantissa >>= 1; - power2 = @boolToInt(mantissa >= (1 << float_info.mantissa_explicit_bits)); + power2 = @intFromBool(mantissa >= (1 << float_info.mantissa_explicit_bits)); return BiasedFp(f64){ .f = mantissa, .e = power2 }; } diff --git a/lib/std/fmt/parse_float/convert_fast.zig b/lib/std/fmt/parse_float/convert_fast.zig index 74beb745de7b..2124e436ab42 100644 --- a/lib/std/fmt/parse_float/convert_fast.zig +++ b/lib/std/fmt/parse_float/convert_fast.zig @@ -108,7 +108,7 @@ pub fn convertFast(comptime T: type, n: Number(T)) ?T { var value: T = 0; if (n.exponent <= info.max_exponent_fast_path) { // normal fast path - value = @intToFloat(T, n.mantissa); + value = @floatFromInt(T, n.mantissa); value = if (n.exponent < 0) value / fastPow10(T, @intCast(usize, -n.exponent)) else @@ -120,7 +120,7 @@ pub fn convertFast(comptime T: type, n: Number(T)) ?T { if (mantissa > info.max_mantissa_fast_path) { return null; } - value = @intToFloat(T, mantissa) * fastPow10(T, info.max_exponent_fast_path); + value = @floatFromInt(T, mantissa) * fastPow10(T, info.max_exponent_fast_path); } if (n.negative) { diff --git a/lib/std/fs.zig b/lib/std/fs.zig index bb0890be4ba7..8e828fd33498 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -1268,8 +1268,8 @@ pub const Dir = struct { &range_off, &range_len, null, - @boolToInt(flags.lock_nonblocking), - @boolToInt(exclusive), + @intFromBool(flags.lock_nonblocking), + @intFromBool(exclusive), ); return file; } @@ -1429,8 +1429,8 @@ pub const Dir = struct { &range_off, &range_len, null, - @boolToInt(flags.lock_nonblocking), - @boolToInt(exclusive), + @intFromBool(flags.lock_nonblocking), + @intFromBool(exclusive), ); return file; } diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig index 7b954399d862..0c6e8a24f7cb 100644 --- a/lib/std/fs/file.zig +++ b/lib/std/fs/file.zig @@ -516,7 +516,7 @@ pub const File = struct { /// Returns `true` if the chosen class has the selected permission. /// This method is only available on Unix platforms. pub fn unixHas(self: Self, class: Class, permission: Permission) bool { - const mask = @as(Mode, @enumToInt(permission)) << @as(u3, @enumToInt(class)) * 3; + const mask = @as(Mode, @intFromEnum(permission)) << @as(u3, @intFromEnum(class)) * 3; return self.mode & mask != 0; } @@ -527,7 +527,7 @@ pub const File = struct { write: ?bool = null, execute: ?bool = null, }) void { - const shift = @as(u3, @enumToInt(class)) * 3; + const shift = @as(u3, @intFromEnum(class)) * 3; if (permissions.read) |r| { if (r) { self.mode |= @as(Mode, 0o4) << shift; @@ -973,7 +973,7 @@ pub const File = struct { // The file size returned by stat is used as hint to set the buffer // size. If the reported size is zero, as it happens on Linux for files // in /proc, a small buffer is allocated instead. - const initial_cap = (if (size > 0) size else 1024) + @boolToInt(optional_sentinel != null); + const initial_cap = (if (size > 0) size else 1024) + @intFromBool(optional_sentinel != null); var array_list = try std.ArrayListAligned(u8, alignment).initCapacity(allocator, initial_cap); defer array_list.deinit(); @@ -1488,7 +1488,7 @@ pub const File = struct { &range_len, null, windows.FALSE, // non-blocking=false - @boolToInt(exclusive), + @intFromBool(exclusive), ) catch |err| switch (err) { error.WouldBlock => unreachable, // non-blocking=false else => |e| return e, @@ -1555,7 +1555,7 @@ pub const File = struct { &range_len, null, windows.TRUE, // non-blocking=true - @boolToInt(exclusive), + @intFromBool(exclusive), ) catch |err| switch (err) { error.WouldBlock => return false, else => |e| return e, diff --git a/lib/std/fs/path.zig b/lib/std/fs/path.zig index e7a28a7615f5..012d99f59a3c 100644 --- a/lib/std/fs/path.zig +++ b/lib/std/fs/path.zig @@ -67,7 +67,7 @@ fn joinSepMaybeZ(allocator: Allocator, separator: u8, comptime sepPredicate: fn if (this_path.len == 0) continue; const prev_sep = sepPredicate(prev_path[prev_path.len - 1]); const this_sep = sepPredicate(this_path[0]); - sum += @boolToInt(!prev_sep and !this_sep); + sum += @intFromBool(!prev_sep and !this_sep); sum += if (prev_sep and this_sep) this_path.len - 1 else this_path.len; prev_path = this_path; } @@ -663,7 +663,7 @@ pub fn resolvePosix(allocator: Allocator, paths: []const []const u8) Allocator.E continue; } else if (mem.eql(u8, component, "..")) { if (result.items.len == 0) { - negative_count += @boolToInt(!is_abs); + negative_count += @intFromBool(!is_abs); continue; } while (true) { @@ -1092,7 +1092,7 @@ pub fn relativeWindows(allocator: Allocator, from: []const u8, to: []const u8) ! while (from_it.next()) |_| { up_index_end += "\\..".len; } - const result = try allocator.alloc(u8, up_index_end + @boolToInt(to_rest.len > 0) + to_rest.len); + const result = try allocator.alloc(u8, up_index_end + @intFromBool(to_rest.len > 0) + to_rest.len); errdefer allocator.free(result); result[0..2].* = "..".*; diff --git a/lib/std/fs/watch.zig b/lib/std/fs/watch.zig index 469244fcd640..0deaa86468c0 100644 --- a/lib/std/fs/watch.zig +++ b/lib/std/fs/watch.zig @@ -285,7 +285,7 @@ pub fn Watch(comptime V: type) type { os.NOTE_WRITE | os.NOTE_DELETE | os.NOTE_REVOKE, .fflags = 0, .data = 0, - .udata = @ptrToInt(&resume_node.base), + .udata = @intFromPtr(&resume_node.base), }; suspend { global_event_loop.beginOneEvent(); @@ -486,7 +486,7 @@ pub fn Watch(comptime V: type) type { } else { var ptr: [*]u8 = &event_buf; const end_ptr = ptr + bytes_transferred; - while (@ptrToInt(ptr) < @ptrToInt(end_ptr)) { + while (@intFromPtr(ptr) < @intFromPtr(end_ptr)) { const ev = @ptrCast(*const windows.FILE_NOTIFY_INFORMATION, ptr); const emit = switch (ev.Action) { windows.FILE_ACTION_REMOVED => WatchEventId.Delete, @@ -585,7 +585,7 @@ pub fn Watch(comptime V: type) type { var ptr: [*]u8 = &event_buf; const end_ptr = ptr + bytes_read; - while (@ptrToInt(ptr) < @ptrToInt(end_ptr)) { + while (@intFromPtr(ptr) < @intFromPtr(end_ptr)) { const ev = @ptrCast(*const os.linux.inotify_event, ptr); if (ev.mask & os.linux.IN_CLOSE_WRITE == os.linux.IN_CLOSE_WRITE) { const basename_ptr = ptr + @sizeOf(os.linux.inotify_event); diff --git a/lib/std/hash/auto_hash.zig b/lib/std/hash/auto_hash.zig index d7b26ce2adc0..f33bd635fc5c 100644 --- a/lib/std/hash/auto_hash.zig +++ b/lib/std/hash/auto_hash.zig @@ -25,7 +25,7 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) switch (info.Pointer.size) { .One => switch (strat) { - .Shallow => hash(hasher, @ptrToInt(key), .Shallow), + .Shallow => hash(hasher, @intFromPtr(key), .Shallow), .Deep => hash(hasher, key.*, .Shallow), .DeepRecursive => hash(hasher, key.*, .DeepRecursive), }, @@ -44,7 +44,7 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) .Many, .C, => switch (strat) { - .Shallow => hash(hasher, @ptrToInt(key), .Shallow), + .Shallow => hash(hasher, @intFromPtr(key), .Shallow), else => @compileError( \\ unknown-length pointers and C pointers cannot be hashed deeply. \\ Consider providing your own hash function. @@ -108,10 +108,10 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { }, }, - .Bool => hash(hasher, @boolToInt(key), strat), - .Enum => hash(hasher, @enumToInt(key), strat), - .ErrorSet => hash(hasher, @errorToInt(key), strat), - .AnyFrame, .Fn => hash(hasher, @ptrToInt(key), strat), + .Bool => hash(hasher, @intFromBool(key), strat), + .Enum => hash(hasher, @intFromEnum(key), strat), + .ErrorSet => hash(hasher, @intFromError(key), strat), + .AnyFrame, .Fn => hash(hasher, @intFromPtr(key), strat), .Pointer => @call(.always_inline, hashPointer, .{ hasher, key, strat }), diff --git a/lib/std/hash/benchmark.zig b/lib/std/hash/benchmark.zig index cf2f18d22f8a..62df89f0ae23 100644 --- a/lib/std/hash/benchmark.zig +++ b/lib/std/hash/benchmark.zig @@ -127,8 +127,8 @@ pub fn benchmarkHash(comptime H: anytype, bytes: usize, allocator: std.mem.Alloc const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, @intToFloat(f64, bytes) / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, @floatFromInt(f64, bytes) / elapsed_s); return Result{ .hash = final, @@ -166,8 +166,8 @@ pub fn benchmarkHashSmallKeys(comptime H: anytype, key_size: usize, bytes: usize } const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, @intToFloat(f64, bytes) / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, @floatFromInt(f64, bytes) / elapsed_s); std.mem.doNotOptimizeAway(sum); diff --git a/lib/std/hash/crc.zig b/lib/std/hash/crc.zig index 0ad154abefd8..da250af1bf8d 100644 --- a/lib/std/hash/crc.zig +++ b/lib/std/hash/crc.zig @@ -129,7 +129,7 @@ pub fn Crc32WithPoly(comptime poly: Polynomial) type { var j: usize = 0; while (j < 8) : (j += 1) { if (crc & 1 == 1) { - crc = (crc >> 1) ^ @enumToInt(poly); + crc = (crc >> 1) ^ @intFromEnum(poly); } else { crc = (crc >> 1); } @@ -222,7 +222,7 @@ pub fn Crc32SmallWithPoly(comptime poly: Polynomial) type { var j: usize = 0; while (j < 8) : (j += 1) { if (crc & 1 == 1) { - crc = (crc >> 1) ^ @enumToInt(poly); + crc = (crc >> 1) ^ @intFromEnum(poly); } else { crc = (crc >> 1); } diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index 8c05dfeca5cf..4f1639cd60de 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -1442,7 +1442,7 @@ pub fn HashMapUnmanaged( // map, which is assumed to exist as keyPtr must be valid. This // item must be at index 0. const idx = if (@sizeOf(K) > 0) - (@ptrToInt(keyPtr) - @ptrToInt(self.keys())) / @sizeOf(K) + (@intFromPtr(keyPtr) - @intFromPtr(self.keys())) / @sizeOf(K) else 0; @@ -1554,19 +1554,19 @@ pub fn HashMapUnmanaged( const total_size = std.mem.alignForward(usize, vals_end, max_align); const slice = try allocator.alignedAlloc(u8, max_align, total_size); - const ptr = @ptrToInt(slice.ptr); + const ptr = @intFromPtr(slice.ptr); const metadata = ptr + @sizeOf(Header); - const hdr = @intToPtr(*Header, ptr); + const hdr = @ptrFromInt(*Header, ptr); if (@sizeOf([*]V) != 0) { - hdr.values = @intToPtr([*]V, ptr + vals_start); + hdr.values = @ptrFromInt([*]V, ptr + vals_start); } if (@sizeOf([*]K) != 0) { - hdr.keys = @intToPtr([*]K, ptr + keys_start); + hdr.keys = @ptrFromInt([*]K, ptr + keys_start); } hdr.capacity = new_capacity; - self.metadata = @intToPtr([*]Metadata, metadata); + self.metadata = @ptrFromInt([*]Metadata, metadata); } fn deallocate(self: *Self, allocator: Allocator) void { @@ -1589,7 +1589,7 @@ pub fn HashMapUnmanaged( const total_size = std.mem.alignForward(usize, vals_end, max_align); - const slice = @intToPtr([*]align(max_align) u8, @ptrToInt(self.header()))[0..total_size]; + const slice = @ptrFromInt([*]align(max_align) u8, @intFromPtr(self.header()))[0..total_size]; allocator.free(slice); self.metadata = null; diff --git a/lib/std/heap.zig b/lib/std/heap.zig index 7b4bf3af2184..fd5b0754fea0 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -61,7 +61,7 @@ const CAllocator = struct { pub const supports_posix_memalign = @hasDecl(c, "posix_memalign"); fn getHeader(ptr: [*]u8) *[*]u8 { - return @intToPtr(*[*]u8, @ptrToInt(ptr) - @sizeOf(usize)); + return @ptrFromInt(*[*]u8, @intFromPtr(ptr) - @sizeOf(usize)); } fn alignedAlloc(len: usize, log2_align: u8) ?[*]u8 { @@ -82,7 +82,7 @@ const CAllocator = struct { // alignment padding and store the original malloc()'ed pointer before // the aligned address. var unaligned_ptr = @ptrCast([*]u8, c.malloc(len + alignment - 1 + @sizeOf(usize)) orelse return null); - const unaligned_addr = @ptrToInt(unaligned_ptr); + const unaligned_addr = @intFromPtr(unaligned_ptr); const aligned_addr = mem.alignForward(usize, unaligned_addr + @sizeOf(usize), alignment); var aligned_ptr = unaligned_ptr + (aligned_addr - unaligned_addr); getHeader(aligned_ptr).* = unaligned_ptr; @@ -105,7 +105,7 @@ const CAllocator = struct { } const unaligned_ptr = getHeader(ptr).*; - const delta = @ptrToInt(ptr) - @ptrToInt(unaligned_ptr); + const delta = @intFromPtr(ptr) - @intFromPtr(unaligned_ptr); return CAllocator.malloc_size(unaligned_ptr) - delta; } @@ -283,7 +283,7 @@ pub const HeapAllocator = switch (builtin.os.tag) { } fn getRecordPtr(buf: []u8) *align(1) usize { - return @intToPtr(*align(1) usize, @ptrToInt(buf.ptr) + buf.len); + return @ptrFromInt(*align(1) usize, @intFromPtr(buf.ptr) + buf.len); } fn alloc( @@ -306,9 +306,9 @@ pub const HeapAllocator = switch (builtin.os.tag) { break :blk other_hh.?; // can't be null because of the cmpxchg }; const ptr = os.windows.kernel32.HeapAlloc(heap_handle, 0, amt) orelse return null; - const root_addr = @ptrToInt(ptr); + const root_addr = @intFromPtr(ptr); const aligned_addr = mem.alignForward(usize, root_addr, ptr_align); - const buf = @intToPtr([*]u8, aligned_addr)[0..n]; + const buf = @ptrFromInt([*]u8, aligned_addr)[0..n]; getRecordPtr(buf).* = root_addr; return buf.ptr; } @@ -325,15 +325,15 @@ pub const HeapAllocator = switch (builtin.os.tag) { const self = @ptrCast(*HeapAllocator, @alignCast(@alignOf(HeapAllocator), ctx)); const root_addr = getRecordPtr(buf).*; - const align_offset = @ptrToInt(buf.ptr) - root_addr; + const align_offset = @intFromPtr(buf.ptr) - root_addr; const amt = align_offset + new_size + @sizeOf(usize); const new_ptr = os.windows.kernel32.HeapReAlloc( self.heap_handle.?, os.windows.HEAP_REALLOC_IN_PLACE_ONLY, - @intToPtr(*anyopaque, root_addr), + @ptrFromInt(*anyopaque, root_addr), amt, ) orelse return false; - assert(new_ptr == @intToPtr(*anyopaque, root_addr)); + assert(new_ptr == @ptrFromInt(*anyopaque, root_addr)); getRecordPtr(buf.ptr[0..new_size]).* = root_addr; return true; } @@ -347,20 +347,20 @@ pub const HeapAllocator = switch (builtin.os.tag) { _ = log2_buf_align; _ = return_address; const self = @ptrCast(*HeapAllocator, @alignCast(@alignOf(HeapAllocator), ctx)); - os.windows.HeapFree(self.heap_handle.?, 0, @intToPtr(*anyopaque, getRecordPtr(buf).*)); + os.windows.HeapFree(self.heap_handle.?, 0, @ptrFromInt(*anyopaque, getRecordPtr(buf).*)); } }, else => @compileError("Unsupported OS"), }; fn sliceContainsPtr(container: []u8, ptr: [*]u8) bool { - return @ptrToInt(ptr) >= @ptrToInt(container.ptr) and - @ptrToInt(ptr) < (@ptrToInt(container.ptr) + container.len); + return @intFromPtr(ptr) >= @intFromPtr(container.ptr) and + @intFromPtr(ptr) < (@intFromPtr(container.ptr) + container.len); } fn sliceContainsSlice(container: []u8, slice: []u8) bool { - return @ptrToInt(slice.ptr) >= @ptrToInt(container.ptr) and - (@ptrToInt(slice.ptr) + slice.len) <= (@ptrToInt(container.ptr) + container.len); + return @intFromPtr(slice.ptr) >= @intFromPtr(container.ptr) and + (@intFromPtr(slice.ptr) + slice.len) <= (@intFromPtr(container.ptr) + container.len); } pub const FixedBufferAllocator = struct { @@ -804,21 +804,21 @@ pub fn testAllocatorLargeAlignment(base_allocator: mem.Allocator) !void { align_mask = @shlWithOverflow(~@as(usize, 0), @as(Allocator.Log2Align, @ctz(large_align)))[0]; var slice = try allocator.alignedAlloc(u8, large_align, 500); - try testing.expect(@ptrToInt(slice.ptr) & align_mask == @ptrToInt(slice.ptr)); + try testing.expect(@intFromPtr(slice.ptr) & align_mask == @intFromPtr(slice.ptr)); if (allocator.resize(slice, 100)) { slice = slice[0..100]; } slice = try allocator.realloc(slice, 5000); - try testing.expect(@ptrToInt(slice.ptr) & align_mask == @ptrToInt(slice.ptr)); + try testing.expect(@intFromPtr(slice.ptr) & align_mask == @intFromPtr(slice.ptr)); if (allocator.resize(slice, 10)) { slice = slice[0..10]; } slice = try allocator.realloc(slice, 20000); - try testing.expect(@ptrToInt(slice.ptr) & align_mask == @ptrToInt(slice.ptr)); + try testing.expect(@intFromPtr(slice.ptr) & align_mask == @intFromPtr(slice.ptr)); allocator.free(slice); } @@ -840,7 +840,7 @@ pub fn testAllocatorAlignedShrink(base_allocator: mem.Allocator) !void { // which is 16 pages, hence the 32. This test may require to increase // the size of the allocations feeding the `allocator` parameter if they // fail, because of this high over-alignment we want to have. - while (@ptrToInt(slice.ptr) == mem.alignForward(usize, @ptrToInt(slice.ptr), mem.page_size * 32)) { + while (@intFromPtr(slice.ptr) == mem.alignForward(usize, @intFromPtr(slice.ptr), mem.page_size * 32)) { try stuff_to_free.append(slice); slice = try allocator.alignedAlloc(u8, 16, alloc_size); } diff --git a/lib/std/heap/PageAllocator.zig b/lib/std/heap/PageAllocator.zig index 5da570fa4280..12a0bdcf3093 100644 --- a/lib/std/heap/PageAllocator.zig +++ b/lib/std/heap/PageAllocator.zig @@ -39,7 +39,7 @@ fn alloc(_: *anyopaque, n: usize, log2_align: u8, ra: usize) ?[*]u8 { -1, 0, ) catch return null; - assert(mem.isAligned(@ptrToInt(slice.ptr), mem.page_size)); + assert(mem.isAligned(@intFromPtr(slice.ptr), mem.page_size)); const new_hint = @alignCast(mem.page_size, slice.ptr + aligned_len); _ = @cmpxchgStrong(@TypeOf(std.heap.next_mmap_addr_hint), &std.heap.next_mmap_addr_hint, hint, new_hint, .Monotonic, .Monotonic); return slice.ptr; @@ -59,14 +59,14 @@ fn resize( if (builtin.os.tag == .windows) { const w = os.windows; if (new_size <= buf_unaligned.len) { - const base_addr = @ptrToInt(buf_unaligned.ptr); + const base_addr = @intFromPtr(buf_unaligned.ptr); const old_addr_end = base_addr + buf_unaligned.len; const new_addr_end = mem.alignForward(usize, base_addr + new_size, mem.page_size); if (old_addr_end > new_addr_end) { // For shrinking that is not releasing, we will only // decommit the pages not needed anymore. w.VirtualFree( - @intToPtr(*anyopaque, new_addr_end), + @ptrFromInt(*anyopaque, new_addr_end), old_addr_end - new_addr_end, w.MEM_DECOMMIT, ); diff --git a/lib/std/heap/WasmAllocator.zig b/lib/std/heap/WasmAllocator.zig index efec116db44f..e3e436fd2b3b 100644 --- a/lib/std/heap/WasmAllocator.zig +++ b/lib/std/heap/WasmAllocator.zig @@ -55,7 +55,7 @@ fn alloc(ctx: *anyopaque, len: usize, log2_align: u8, return_address: usize) ?[* const addr = a: { const top_free_ptr = frees[class]; if (top_free_ptr != 0) { - const node = @intToPtr(*usize, top_free_ptr + (slot_size - @sizeOf(usize))); + const node = @ptrFromInt(*usize, top_free_ptr + (slot_size - @sizeOf(usize))); frees[class] = node.*; break :a top_free_ptr; } @@ -74,11 +74,11 @@ fn alloc(ctx: *anyopaque, len: usize, log2_align: u8, return_address: usize) ?[* break :a next_addr; } }; - return @intToPtr([*]u8, addr); + return @ptrFromInt([*]u8, addr); } const bigpages_needed = bigPagesNeeded(actual_len); const addr = allocBigPages(bigpages_needed); - return @intToPtr([*]u8, addr); + return @ptrFromInt([*]u8, addr); } fn resize( @@ -121,16 +121,16 @@ fn free( const actual_len = @max(buf.len + @sizeOf(usize), buf_align); const slot_size = math.ceilPowerOfTwoAssert(usize, actual_len); const class = math.log2(slot_size) - min_class; - const addr = @ptrToInt(buf.ptr); + const addr = @intFromPtr(buf.ptr); if (class < size_class_count) { - const node = @intToPtr(*usize, addr + (slot_size - @sizeOf(usize))); + const node = @ptrFromInt(*usize, addr + (slot_size - @sizeOf(usize))); node.* = frees[class]; frees[class] = addr; } else { const bigpages_needed = bigPagesNeeded(actual_len); const pow2_pages = math.ceilPowerOfTwoAssert(usize, bigpages_needed); const big_slot_size_bytes = pow2_pages * bigpage_size; - const node = @intToPtr(*usize, addr + (big_slot_size_bytes - @sizeOf(usize))); + const node = @ptrFromInt(*usize, addr + (big_slot_size_bytes - @sizeOf(usize))); const big_class = math.log2(pow2_pages); node.* = big_frees[big_class]; big_frees[big_class] = addr; @@ -148,7 +148,7 @@ fn allocBigPages(n: usize) usize { const top_free_ptr = big_frees[class]; if (top_free_ptr != 0) { - const node = @intToPtr(*usize, top_free_ptr + (slot_size_bytes - @sizeOf(usize))); + const node = @ptrFromInt(*usize, top_free_ptr + (slot_size_bytes - @sizeOf(usize))); big_frees[class] = node.*; return top_free_ptr; } diff --git a/lib/std/heap/WasmPageAllocator.zig b/lib/std/heap/WasmPageAllocator.zig index 63ae22619651..c77164ee2de2 100644 --- a/lib/std/heap/WasmPageAllocator.zig +++ b/lib/std/heap/WasmPageAllocator.zig @@ -40,14 +40,14 @@ const FreeBlock = struct { fn getBit(self: FreeBlock, idx: usize) PageStatus { const bit_offset = 0; - return @intToEnum(PageStatus, Io.get(mem.sliceAsBytes(self.data), idx, bit_offset)); + return @enumFromInt(PageStatus, Io.get(mem.sliceAsBytes(self.data), idx, bit_offset)); } fn setBits(self: FreeBlock, start_idx: usize, len: usize, val: PageStatus) void { const bit_offset = 0; var i: usize = 0; while (i < len) : (i += 1) { - Io.set(mem.sliceAsBytes(self.data), start_idx + i, bit_offset, @enumToInt(val)); + Io.set(mem.sliceAsBytes(self.data), start_idx + i, bit_offset, @intFromEnum(val)); } } @@ -109,7 +109,7 @@ fn alloc(ctx: *anyopaque, len: usize, log2_align: u8, ra: usize) ?[*]u8 { if (len > maxInt(usize) - (mem.page_size - 1)) return null; const page_count = nPages(len); const page_idx = allocPages(page_count, log2_align) catch return null; - return @intToPtr([*]u8, page_idx * mem.page_size); + return @ptrFromInt([*]u8, page_idx * mem.page_size); } fn allocPages(page_count: usize, log2_align: u8) !usize { @@ -151,7 +151,7 @@ fn freePages(start: usize, end: usize) void { // TODO: would it be better if we use the first page instead? new_end -= 1; - extended.data = @intToPtr([*]u128, new_end * mem.page_size)[0 .. mem.page_size / @sizeOf(u128)]; + extended.data = @ptrFromInt([*]u128, new_end * mem.page_size)[0 .. mem.page_size / @sizeOf(u128)]; // Since this is the first page being freed and we consume it, assume *nothing* is free. @memset(extended.data, PageStatus.none_free); } @@ -175,7 +175,7 @@ fn resize( const current_n = nPages(aligned_len); const new_n = nPages(new_len); if (new_n != current_n) { - const base = nPages(@ptrToInt(buf.ptr)); + const base = nPages(@intFromPtr(buf.ptr)); freePages(base + new_n, base + current_n); } return true; @@ -192,7 +192,7 @@ fn free( _ = return_address; const aligned_len = mem.alignForward(usize, buf.len, mem.page_size); const current_n = nPages(aligned_len); - const base = nPages(@ptrToInt(buf.ptr)); + const base = nPages(@intFromPtr(buf.ptr)); freePages(base, base + current_n); } @@ -202,7 +202,7 @@ test "internals" { const conventional_memsize = WasmPageAllocator.conventional.totalPages() * mem.page_size; const initial = try page_allocator.alloc(u8, mem.page_size); - try testing.expect(@ptrToInt(initial.ptr) < conventional_memsize); // If this isn't conventional, the rest of these tests don't make sense. Also we have a serious memory leak in the test suite. + try testing.expect(@intFromPtr(initial.ptr) < conventional_memsize); // If this isn't conventional, the rest of these tests don't make sense. Also we have a serious memory leak in the test suite. var inplace = try page_allocator.realloc(initial, 1); try testing.expectEqual(initial.ptr, inplace.ptr); @@ -219,7 +219,7 @@ test "internals" { page_allocator.free(padding); const ext = try page_allocator.alloc(u8, conventional_memsize); - try testing.expect(@ptrToInt(ext.ptr) >= conventional_memsize); + try testing.expect(@intFromPtr(ext.ptr) >= conventional_memsize); const use_small = try page_allocator.alloc(u8, 1); try testing.expectEqual(initial.ptr, use_small.ptr); diff --git a/lib/std/heap/arena_allocator.zig b/lib/std/heap/arena_allocator.zig index f858510bcfa9..a8d6641d8d12 100644 --- a/lib/std/heap/arena_allocator.zig +++ b/lib/std/heap/arena_allocator.zig @@ -185,7 +185,7 @@ pub const ArenaAllocator = struct { while (true) { const cur_alloc_buf = @ptrCast([*]u8, cur_node)[0..cur_node.data]; const cur_buf = cur_alloc_buf[@sizeOf(BufNode)..]; - const addr = @ptrToInt(cur_buf.ptr) + self.state.end_index; + const addr = @intFromPtr(cur_buf.ptr) + self.state.end_index; const adjusted_addr = mem.alignForward(usize, addr, ptr_align); const adjusted_index = self.state.end_index + (adjusted_addr - addr); const new_end_index = adjusted_index + n; @@ -214,7 +214,7 @@ pub const ArenaAllocator = struct { const cur_node = self.state.buffer_list.first orelse return false; const cur_buf = @ptrCast([*]u8, cur_node)[@sizeOf(BufNode)..cur_node.data]; - if (@ptrToInt(cur_buf.ptr) + self.state.end_index != @ptrToInt(buf.ptr) + buf.len) { + if (@intFromPtr(cur_buf.ptr) + self.state.end_index != @intFromPtr(buf.ptr) + buf.len) { // It's not the most recent allocation, so it cannot be expanded, // but it's fine if they want to make it smaller. return new_len <= buf.len; @@ -240,7 +240,7 @@ pub const ArenaAllocator = struct { const cur_node = self.state.buffer_list.first orelse return; const cur_buf = @ptrCast([*]u8, cur_node)[@sizeOf(BufNode)..cur_node.data]; - if (@ptrToInt(cur_buf.ptr) + self.state.end_index == @ptrToInt(buf.ptr) + buf.len) { + if (@intFromPtr(cur_buf.ptr) + self.state.end_index == @intFromPtr(buf.ptr) + buf.len) { self.state.end_index -= buf.len; } } @@ -262,7 +262,7 @@ test "ArenaAllocator (reset with preheating)" { const size = random.intRangeAtMost(usize, 16, 256); const alignment = 32; const slice = try arena_allocator.allocator().alignedAlloc(u8, alignment, size); - try std.testing.expect(std.mem.isAligned(@ptrToInt(slice.ptr), alignment)); + try std.testing.expect(std.mem.isAligned(@intFromPtr(slice.ptr), alignment)); try std.testing.expectEqual(size, slice.len); alloced_bytes += slice.len; } diff --git a/lib/std/heap/general_purpose_allocator.zig b/lib/std/heap/general_purpose_allocator.zig index 51b6c1744f53..98375c850eed 100644 --- a/lib/std/heap/general_purpose_allocator.zig +++ b/lib/std/heap/general_purpose_allocator.zig @@ -216,8 +216,8 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { } fn getStackTrace(self: *LargeAlloc, trace_kind: TraceKind) std.builtin.StackTrace { - assert(@enumToInt(trace_kind) < trace_n); - const stack_addresses = &self.stack_addresses[@enumToInt(trace_kind)]; + assert(@intFromEnum(trace_kind) < trace_n); + const stack_addresses = &self.stack_addresses[@intFromEnum(trace_kind)]; var len: usize = 0; while (len < stack_n and stack_addresses[len] != 0) { len += 1; @@ -229,8 +229,8 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { } fn captureStackTrace(self: *LargeAlloc, ret_addr: usize, trace_kind: TraceKind) void { - assert(@enumToInt(trace_kind) < trace_n); - const stack_addresses = &self.stack_addresses[@enumToInt(trace_kind)]; + assert(@intFromEnum(trace_kind) < trace_n); + const stack_addresses = &self.stack_addresses[@intFromEnum(trace_kind)]; collectStackTrace(ret_addr, stack_addresses); } }; @@ -250,7 +250,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { used_count: SlotIndex, fn usedBits(bucket: *BucketHeader, index: usize) *u8 { - return @intToPtr(*u8, @ptrToInt(bucket) + @sizeOf(BucketHeader) + index); + return @ptrFromInt(*u8, @intFromPtr(bucket) + @sizeOf(BucketHeader) + index); } fn stackTracePtr( @@ -261,7 +261,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { ) *[stack_n]usize { const start_ptr = @ptrCast([*]u8, bucket) + bucketStackFramesStart(size_class); const addr = start_ptr + one_trace_size * traces_per_slot * slot_index + - @enumToInt(trace_kind) * @as(usize, one_trace_size); + @intFromEnum(trace_kind) * @as(usize, one_trace_size); return @ptrCast(*[stack_n]usize, @alignCast(@alignOf(usize), addr)); } @@ -344,7 +344,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { const stack_trace = bucketStackTrace(bucket, size_class, slot_index, .alloc); const addr = bucket.page + slot_index * size_class; log.err("memory address 0x{x} leaked: {}", .{ - @ptrToInt(addr), stack_trace, + @intFromPtr(addr), stack_trace, }); leaks = true; } @@ -376,7 +376,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { if (config.retain_metadata and large_alloc.freed) continue; const stack_trace = large_alloc.getStackTrace(.alloc); log.err("memory address 0x{x} leaked: {}", .{ - @ptrToInt(large_alloc.bytes.ptr), stack_trace, + @intFromPtr(large_alloc.bytes.ptr), stack_trace, }); leaks = true; } @@ -427,7 +427,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { var it = self.large_allocations.iterator(); while (it.next()) |large| { if (large.value_ptr.freed) { - _ = self.large_allocations.remove(@ptrToInt(large.value_ptr.bytes.ptr)); + _ = self.large_allocations.remove(@intFromPtr(large.value_ptr.bytes.ptr)); } } } @@ -444,7 +444,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { self.small_allocations.deinit(self.backing_allocator); } self.* = undefined; - return @intToEnum(Check, @boolToInt(leaks)); + return @enumFromInt(Check, @intFromBool(leaks)); } fn collectStackTrace(first_trace_addr: usize, addresses: *[stack_n]usize) void { @@ -510,8 +510,8 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { const first_bucket = bucket_list orelse return null; var bucket = first_bucket; while (true) { - const in_bucket_range = (addr >= @ptrToInt(bucket.page) and - addr < @ptrToInt(bucket.page) + page_size); + const in_bucket_range = (addr >= @intFromPtr(bucket.page) and + addr < @intFromPtr(bucket.page) + page_size); if (in_bucket_range) return bucket; bucket = bucket.prev; if (bucket == first_bucket) { @@ -529,7 +529,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { new_size: usize, ret_addr: usize, ) bool { - const entry = self.large_allocations.getEntry(@ptrToInt(old_mem.ptr)) orelse { + const entry = self.large_allocations.getEntry(@intFromPtr(old_mem.ptr)) orelse { if (config.safety) { @panic("Invalid free"); } else { @@ -604,7 +604,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { log2_old_align: u8, ret_addr: usize, ) void { - const entry = self.large_allocations.getEntry(@ptrToInt(old_mem.ptr)) orelse { + const entry = self.large_allocations.getEntry(@intFromPtr(old_mem.ptr)) orelse { if (config.safety) { @panic("Invalid free"); } else { @@ -649,7 +649,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { } if (!config.retain_metadata) { - assert(self.large_allocations.remove(@ptrToInt(old_mem.ptr))); + assert(self.large_allocations.remove(@intFromPtr(old_mem.ptr))); } else { entry.value_ptr.freed = true; entry.value_ptr.captureStackTrace(ret_addr, .free); @@ -683,7 +683,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { var bucket_index = math.log2(size_class_hint); var size_class: usize = size_class_hint; const bucket = while (bucket_index < small_bucket_count) : (bucket_index += 1) { - if (searchBucket(self.buckets[bucket_index], @ptrToInt(old_mem.ptr))) |bucket| { + if (searchBucket(self.buckets[bucket_index], @intFromPtr(old_mem.ptr))) |bucket| { // move bucket to head of list to optimize search for nearby allocations self.buckets[bucket_index] = bucket; break bucket; @@ -691,9 +691,9 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { size_class *= 2; } else blk: { if (config.retain_metadata) { - if (!self.large_allocations.contains(@ptrToInt(old_mem.ptr))) { + if (!self.large_allocations.contains(@intFromPtr(old_mem.ptr))) { // object not in active buckets or a large allocation, so search empty buckets - if (searchBucket(self.empty_buckets, @ptrToInt(old_mem.ptr))) |bucket| { + if (searchBucket(self.empty_buckets, @intFromPtr(old_mem.ptr))) |bucket| { // bucket is empty so is_used below will always be false and we exit there break :blk bucket; } else { @@ -703,7 +703,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { } return self.resizeLarge(old_mem, log2_old_align, new_size, ret_addr); }; - const byte_offset = @ptrToInt(old_mem.ptr) - @ptrToInt(bucket.page); + const byte_offset = @intFromPtr(old_mem.ptr) - @intFromPtr(bucket.page); const slot_index = @intCast(SlotIndex, byte_offset / size_class); const used_byte_index = slot_index / 8; const used_bit_index = @intCast(u3, slot_index % 8); @@ -720,7 +720,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { // Definitely an in-use small alloc now. if (config.safety) { - const entry = self.small_allocations.getEntry(@ptrToInt(old_mem.ptr)) orelse + const entry = self.small_allocations.getEntry(@intFromPtr(old_mem.ptr)) orelse @panic("Invalid free"); if (old_mem.len != entry.value_ptr.requested_size or log2_old_align != entry.value_ptr.log2_ptr_align) { var addresses: [stack_n]usize = [1]usize{0} ** stack_n; @@ -768,7 +768,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { }); } if (config.safety) { - const entry = self.small_allocations.getEntry(@ptrToInt(old_mem.ptr)).?; + const entry = self.small_allocations.getEntry(@intFromPtr(old_mem.ptr)).?; entry.value_ptr.requested_size = new_size; } return true; @@ -803,7 +803,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { var bucket_index = math.log2(size_class_hint); var size_class: usize = size_class_hint; const bucket = while (bucket_index < small_bucket_count) : (bucket_index += 1) { - if (searchBucket(self.buckets[bucket_index], @ptrToInt(old_mem.ptr))) |bucket| { + if (searchBucket(self.buckets[bucket_index], @intFromPtr(old_mem.ptr))) |bucket| { // move bucket to head of list to optimize search for nearby allocations self.buckets[bucket_index] = bucket; break bucket; @@ -811,9 +811,9 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { size_class *= 2; } else blk: { if (config.retain_metadata) { - if (!self.large_allocations.contains(@ptrToInt(old_mem.ptr))) { + if (!self.large_allocations.contains(@intFromPtr(old_mem.ptr))) { // object not in active buckets or a large allocation, so search empty buckets - if (searchBucket(self.empty_buckets, @ptrToInt(old_mem.ptr))) |bucket| { + if (searchBucket(self.empty_buckets, @intFromPtr(old_mem.ptr))) |bucket| { // bucket is empty so is_used below will always be false and we exit there break :blk bucket; } else { @@ -824,7 +824,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { self.freeLarge(old_mem, log2_old_align, ret_addr); return; }; - const byte_offset = @ptrToInt(old_mem.ptr) - @ptrToInt(bucket.page); + const byte_offset = @intFromPtr(old_mem.ptr) - @intFromPtr(bucket.page); const slot_index = @intCast(SlotIndex, byte_offset / size_class); const used_byte_index = slot_index / 8; const used_bit_index = @intCast(u3, slot_index % 8); @@ -842,7 +842,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { // Definitely an in-use small alloc now. if (config.safety) { - const entry = self.small_allocations.getEntry(@ptrToInt(old_mem.ptr)) orelse + const entry = self.small_allocations.getEntry(@intFromPtr(old_mem.ptr)) orelse @panic("Invalid free"); if (old_mem.len != entry.value_ptr.requested_size or log2_old_align != entry.value_ptr.log2_ptr_align) { var addresses: [stack_n]usize = [1]usize{0} ** stack_n; @@ -915,7 +915,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { @memset(old_mem, undefined); } if (config.safety) { - assert(self.small_allocations.remove(@ptrToInt(old_mem.ptr))); + assert(self.small_allocations.remove(@intFromPtr(old_mem.ptr))); } if (config.verbose_log) { log.info("small free {d} bytes at {*}", .{ old_mem.len, old_mem.ptr }); @@ -956,7 +956,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { return error.OutOfMemory; const slice = ptr[0..len]; - const gop = self.large_allocations.getOrPutAssumeCapacity(@ptrToInt(slice.ptr)); + const gop = self.large_allocations.getOrPutAssumeCapacity(@intFromPtr(slice.ptr)); if (config.retain_metadata and !config.never_unmap) { // Backing allocator may be reusing memory that we're retaining metadata for assert(!gop.found_existing or gop.value_ptr.freed); @@ -986,7 +986,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { const new_size_class = math.ceilPowerOfTwoAssert(usize, new_aligned_size); const ptr = try self.allocSlot(new_size_class, ret_addr); if (config.safety) { - const gop = self.small_allocations.getOrPutAssumeCapacity(@ptrToInt(ptr)); + const gop = self.small_allocations.getOrPutAssumeCapacity(@intFromPtr(ptr)); gop.value_ptr.requested_size = len; gop.value_ptr.log2_ptr_align = log2_ptr_align; } @@ -1212,7 +1212,7 @@ test "shrink large object to large object with larger alignment" { // alignment. Then we shrink the allocation after the loop, but increase the // alignment to the higher one, that we know will force it to realloc. var stuff_to_free = std.ArrayList([]align(16) u8).init(debug_allocator); - while (mem.isAligned(@ptrToInt(slice.ptr), big_alignment)) { + while (mem.isAligned(@intFromPtr(slice.ptr), big_alignment)) { try stuff_to_free.append(slice); slice = try allocator.alignedAlloc(u8, 16, alloc_size); } @@ -1281,7 +1281,7 @@ test "realloc large object to larger alignment" { }; // This loop allocates until we find a page that is not aligned to the big alignment. var stuff_to_free = std.ArrayList([]align(16) u8).init(debug_allocator); - while (mem.isAligned(@ptrToInt(slice.ptr), big_alignment)) { + while (mem.isAligned(@intFromPtr(slice.ptr), big_alignment)) { try stuff_to_free.append(slice); slice = try allocator.alignedAlloc(u8, 16, page_size * 2 + 50); } @@ -1375,18 +1375,18 @@ test "double frees" { const index: usize = 6; const size_class: usize = @as(usize, 1) << 6; const small = try allocator.alloc(u8, size_class); - try std.testing.expect(GPA.searchBucket(gpa.buckets[index], @ptrToInt(small.ptr)) != null); + try std.testing.expect(GPA.searchBucket(gpa.buckets[index], @intFromPtr(small.ptr)) != null); allocator.free(small); - try std.testing.expect(GPA.searchBucket(gpa.buckets[index], @ptrToInt(small.ptr)) == null); - try std.testing.expect(GPA.searchBucket(gpa.empty_buckets, @ptrToInt(small.ptr)) != null); + try std.testing.expect(GPA.searchBucket(gpa.buckets[index], @intFromPtr(small.ptr)) == null); + try std.testing.expect(GPA.searchBucket(gpa.empty_buckets, @intFromPtr(small.ptr)) != null); // detect a large allocation double free const large = try allocator.alloc(u8, 2 * page_size); - try std.testing.expect(gpa.large_allocations.contains(@ptrToInt(large.ptr))); - try std.testing.expectEqual(gpa.large_allocations.getEntry(@ptrToInt(large.ptr)).?.value_ptr.bytes, large); + try std.testing.expect(gpa.large_allocations.contains(@intFromPtr(large.ptr))); + try std.testing.expectEqual(gpa.large_allocations.getEntry(@intFromPtr(large.ptr)).?.value_ptr.bytes, large); allocator.free(large); - try std.testing.expect(gpa.large_allocations.contains(@ptrToInt(large.ptr))); - try std.testing.expect(gpa.large_allocations.getEntry(@ptrToInt(large.ptr)).?.value_ptr.freed); + try std.testing.expect(gpa.large_allocations.contains(@intFromPtr(large.ptr))); + try std.testing.expect(gpa.large_allocations.getEntry(@intFromPtr(large.ptr)).?.value_ptr.freed); const normal_small = try allocator.alloc(u8, size_class); defer allocator.free(normal_small); @@ -1396,9 +1396,9 @@ test "double frees" { // check that flushing retained metadata doesn't disturb live allocations gpa.flushRetainedMetadata(); try std.testing.expect(gpa.empty_buckets == null); - try std.testing.expect(GPA.searchBucket(gpa.buckets[index], @ptrToInt(normal_small.ptr)) != null); - try std.testing.expect(gpa.large_allocations.contains(@ptrToInt(normal_large.ptr))); - try std.testing.expect(!gpa.large_allocations.contains(@ptrToInt(large.ptr))); + try std.testing.expect(GPA.searchBucket(gpa.buckets[index], @intFromPtr(normal_small.ptr)) != null); + try std.testing.expect(gpa.large_allocations.contains(@intFromPtr(normal_large.ptr))); + try std.testing.expect(!gpa.large_allocations.contains(@intFromPtr(large.ptr))); } test "bug 9995 fix, large allocs count requested size not backing size" { diff --git a/lib/std/http.zig b/lib/std/http.zig index e9c62705b5d4..c09341c70179 100644 --- a/lib/std/http.zig +++ b/lib/std/http.zig @@ -232,7 +232,7 @@ pub const Status = enum(u10) { }; pub fn class(self: Status) Class { - return switch (@enumToInt(self)) { + return switch (@intFromEnum(self)) { 100...199 => .informational, 200...299 => .success, 300...399 => .redirect, diff --git a/lib/std/http/Client.zig b/lib/std/http/Client.zig index 975375a2b949..0c627642b8ec 100644 --- a/lib/std/http/Client.zig +++ b/lib/std/http/Client.zig @@ -343,7 +343,7 @@ pub const Response = struct { else => return error.HttpHeadersInvalid, }; if (first_line[8] != ' ') return error.HttpHeadersInvalid; - const status = @intToEnum(http.Status, parseInt3(first_line[9..12].*)); + const status = @enumFromInt(http.Status, parseInt3(first_line[9..12].*)); const reason = mem.trimLeft(u8, first_line[12..], " "); res.version = version; diff --git a/lib/std/http/Server.zig b/lib/std/http/Server.zig index 60f6243fce8c..fe57b5735d14 100644 --- a/lib/std/http/Server.zig +++ b/lib/std/http/Server.zig @@ -402,7 +402,7 @@ pub const Response = struct { try w.writeAll(@tagName(res.version)); try w.writeByte(' '); - try w.print("{d}", .{@enumToInt(res.status)}); + try w.print("{d}", .{@intFromEnum(res.status)}); try w.writeByte(' '); if (res.reason) |reason| { try w.writeAll(reason); diff --git a/lib/std/io.zig b/lib/std/io.zig index fb8b0b9d140f..f2804a31075a 100644 --- a/lib/std/io.zig +++ b/lib/std/io.zig @@ -257,7 +257,7 @@ pub fn Poller(comptime StreamEnum: type) type { } pub inline fn fifo(self: *Self, comptime which: StreamEnum) *PollFifo { - return &self.fifos[@enumToInt(which)]; + return &self.fifos[@intFromEnum(which)]; } fn pollWindows(self: *Self) !bool { @@ -275,7 +275,7 @@ pub fn Poller(comptime StreamEnum: type) type { )) { .pending => { self.windows.active.handles_buf[self.windows.active.count] = handle; - self.windows.active.stream_map[self.windows.active.count] = @intToEnum(StreamEnum, i); + self.windows.active.stream_map[self.windows.active.count] = @enumFromInt(StreamEnum, i); self.windows.active.count += 1; }, .closed => {}, // don't add to the wait_objects list @@ -302,7 +302,7 @@ pub fn Poller(comptime StreamEnum: type) type { const active_idx = status - os.windows.WAIT_OBJECT_0; const handle = self.windows.active.handles_buf[active_idx]; - const stream_idx = @enumToInt(self.windows.active.stream_map[active_idx]); + const stream_idx = @intFromEnum(self.windows.active.stream_map[active_idx]); var read_bytes: u32 = undefined; if (0 == os.windows.kernel32.GetOverlappedResult( handle, diff --git a/lib/std/io/bit_reader.zig b/lib/std/io/bit_reader.zig index e897850b83fd..4bdb0b91943a 100644 --- a/lib/std/io/bit_reader.zig +++ b/lib/std/io/bit_reader.zig @@ -143,7 +143,7 @@ pub fn BitReader(comptime endian: std.builtin.Endian, comptime ReaderType: type) b.* = try self.readBits(u8, u8_bit_count, &out_bits); out_bits_total += out_bits; } - const incomplete_byte = @boolToInt(out_bits_total % u8_bit_count > 0); + const incomplete_byte = @intFromBool(out_bits_total % u8_bit_count > 0); return (out_bits_total / u8_bit_count) + incomplete_byte; } diff --git a/lib/std/io/c_writer.zig b/lib/std/io/c_writer.zig index 80dcba3f6fbd..62c73d371453 100644 --- a/lib/std/io/c_writer.zig +++ b/lib/std/io/c_writer.zig @@ -13,7 +13,7 @@ pub fn cWriter(c_file: *std.c.FILE) CWriter { fn cWriterWrite(c_file: *std.c.FILE, bytes: []const u8) std.fs.File.WriteError!usize { const amt_written = std.c.fwrite(bytes.ptr, 1, bytes.len, c_file); if (amt_written >= 0) return amt_written; - switch (@intToEnum(os.E, std.c._errno().*)) { + switch (@enumFromInt(os.E, std.c._errno().*)) { .SUCCESS => unreachable, .INVAL => unreachable, .FAULT => unreachable, diff --git a/lib/std/json/static.zig b/lib/std/json/static.zig index 73a209ebc06a..3a3af8f8d92b 100644 --- a/lib/std/json/static.zig +++ b/lib/std/json/static.zig @@ -176,7 +176,7 @@ fn parseInternal( const float = try std.fmt.parseFloat(f128, slice); if (@round(float) != float) return error.InvalidNumber; if (float > std.math.maxInt(T) or float < std.math.minInt(T)) return error.Overflow; - return @floatToInt(T, float); + return @intFromFloat(T, float); }, .Optional => |optionalInfo| { switch (try source.peekNextTokenType()) { diff --git a/lib/std/leb128.zig b/lib/std/leb128.zig index bc5955d16a6c..859d753a6a74 100644 --- a/lib/std/leb128.zig +++ b/lib/std/leb128.zig @@ -318,7 +318,7 @@ fn test_write_leb128(value: anytype) !void { if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1); const unused_bits = if (value < 0) @clz(~value) else @clz(value); - const used_bits: u16 = (@typeInfo(T).Int.bits - unused_bits) + @boolToInt(t_signed); + const used_bits: u16 = (@typeInfo(T).Int.bits - unused_bits) + @intFromBool(t_signed); if (used_bits <= 7) break :bn @as(u16, 1); break :bn ((used_bits + 6) / 7); }; diff --git a/lib/std/log.zig b/lib/std/log.zig index dc45df9ea3f8..1c5b60ff1a78 100644 --- a/lib/std/log.zig +++ b/lib/std/log.zig @@ -36,7 +36,7 @@ //! // .my_project, .nice_library and the default //! const scope_prefix = "(" ++ switch (scope) { //! .my_project, .nice_library, std.log.default_log_scope => @tagName(scope), -//! else => if (@enumToInt(level) <= @enumToInt(std.log.Level.err)) +//! else => if (@intFromEnum(level) <= @intFromEnum(std.log.Level.err)) //! @tagName(scope) //! else //! return, @@ -128,9 +128,9 @@ fn log( /// Determine if a specific log message level and scope combination are enabled for logging. pub fn logEnabled(comptime message_level: Level, comptime scope: @Type(.EnumLiteral)) bool { inline for (scope_levels) |scope_level| { - if (scope_level.scope == scope) return @enumToInt(message_level) <= @enumToInt(scope_level.level); + if (scope_level.scope == scope) return @intFromEnum(message_level) <= @intFromEnum(scope_level.level); } - return @enumToInt(message_level) <= @enumToInt(level); + return @intFromEnum(message_level) <= @intFromEnum(level); } /// Determine if a specific log message level using the default log scope is enabled for logging. diff --git a/lib/std/math.zig b/lib/std/math.zig index e62a208d0bae..c7d354f78792 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -1104,7 +1104,7 @@ pub const AlignCastError = error{UnalignedMemory}; /// Align cast a pointer but return an error if it's the wrong alignment pub fn alignCast(comptime alignment: u29, ptr: anytype) AlignCastError!@TypeOf(@alignCast(alignment, ptr)) { - const addr = @ptrToInt(ptr); + const addr = @intFromPtr(ptr); if (addr % alignment != 0) { return error.UnalignedMemory; } @@ -1311,7 +1311,7 @@ pub fn lossyCast(comptime T: type, value: anytype) T { switch (@typeInfo(T)) { .Float => { switch (@typeInfo(@TypeOf(value))) { - .Int => return @intToFloat(T, value), + .Int => return @floatFromInt(T, value), .Float => return @floatCast(T, value), .ComptimeInt => return @as(T, value), .ComptimeFloat => return @as(T, value), @@ -1335,7 +1335,7 @@ pub fn lossyCast(comptime T: type, value: anytype) T { } else if (value <= minInt(T)) { return @as(T, minInt(T)); } else { - return @floatToInt(T, value); + return @intFromFloat(T, value); } }, else => @compileError("bad type"), @@ -1401,7 +1401,7 @@ pub fn maxInt(comptime T: type) comptime_int { const info = @typeInfo(T); const bit_count = info.Int.bits; if (bit_count == 0) return 0; - return (1 << (bit_count - @boolToInt(info.Int.signedness == .signed))) - 1; + return (1 << (bit_count - @intFromBool(info.Int.signedness == .signed))) - 1; } /// Returns the minimum value of integer type T. @@ -1624,7 +1624,7 @@ test "order.compare" { test "compare.reverse" { inline for (@typeInfo(CompareOperator).Enum.fields) |op_field| { - const op = @intToEnum(CompareOperator, op_field.value); + const op = @enumFromInt(CompareOperator, op_field.value); try testing.expect(compare(2, op, 3) == compare(3, op.reverse(), 2)); try testing.expect(compare(3, op, 3) == compare(3, op.reverse(), 3)); try testing.expect(compare(4, op, 3) == compare(3, op.reverse(), 4)); @@ -1643,13 +1643,13 @@ pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt { // The u1 and i1 cases tend to overflow, // so we special case them here. - if (MaskInt == u1) return @boolToInt(value); + if (MaskInt == u1) return @intFromBool(value); if (MaskInt == i1) { // The @as here is a workaround for #7950 - return @bitCast(i1, @as(u1, @boolToInt(value))); + return @bitCast(i1, @as(u1, @intFromBool(value))); } - return -%@intCast(MaskInt, @boolToInt(value)); + return -%@intCast(MaskInt, @intFromBool(value)); } test "boolMask" { @@ -1708,8 +1708,8 @@ pub fn break_f80(x: f80) F80 { pub inline fn sign(i: anytype) @TypeOf(i) { const T = @TypeOf(i); return switch (@typeInfo(T)) { - .Int, .ComptimeInt => @as(T, @boolToInt(i > 0)) - @as(T, @boolToInt(i < 0)), - .Float, .ComptimeFloat => @intToFloat(T, @boolToInt(i > 0)) - @intToFloat(T, @boolToInt(i < 0)), + .Int, .ComptimeInt => @as(T, @intFromBool(i > 0)) - @as(T, @intFromBool(i < 0)), + .Float, .ComptimeFloat => @floatFromInt(T, @intFromBool(i > 0)) - @floatFromInt(T, @intFromBool(i < 0)), .Vector => |vinfo| blk: { switch (@typeInfo(vinfo.child)) { .Int, .Float => { diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index 487812e1de31..846a809e0565 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -1127,7 +1127,7 @@ pub const Mutable = struct { return; } - const checkbit = bit_count - shift - @boolToInt(signedness == .signed); + const checkbit = bit_count - shift - @intFromBool(signedness == .signed); // If `checkbit` and more significant bits are zero, no overflow will take place. if (checkbit >= a.limbs.len * limb_bits) { @@ -1274,10 +1274,10 @@ pub const Mutable = struct { if (a.limbs.len > b.limbs.len) { r.positive = llsignedxor(r.limbs, a.limbs, a.positive, b.limbs, b.positive); - r.normalize(a.limbs.len + @boolToInt(a.positive != b.positive)); + r.normalize(a.limbs.len + @intFromBool(a.positive != b.positive)); } else { r.positive = llsignedxor(r.limbs, b.limbs, b.positive, a.limbs, a.positive); - r.normalize(b.limbs.len + @boolToInt(a.positive != b.positive)); + r.normalize(b.limbs.len + @intFromBool(a.positive != b.positive)); } } @@ -2128,7 +2128,7 @@ pub const Const = struct { return false; } - const req_bits = self.bitCountTwosComp() + @boolToInt(self.positive and signedness == .signed); + const req_bits = self.bitCountTwosComp() + @intFromBool(self.positive and signedness == .signed); return bit_count >= req_bits; } @@ -2143,7 +2143,7 @@ pub const Const = struct { /// value. It is inexact and may exceed the given value by ~1-2 bytes. /// TODO See if we can make this exact. pub fn sizeInBaseUpperBound(self: Const, base: usize) usize { - const bit_count = @as(usize, @boolToInt(!self.positive)) + self.bitCountAbs(); + const bit_count = @as(usize, @intFromBool(!self.positive)) + self.bitCountAbs(); return (bit_count / math.log2(base)) + 2; } @@ -3143,7 +3143,7 @@ pub const Managed = struct { /// r = a ^ b pub fn bitXor(r: *Managed, a: *const Managed, b: *const Managed) !void { - var cap = @max(a.len(), b.len()) + @boolToInt(a.isPositive() != b.isPositive()); + var cap = @max(a.len(), b.len()) + @intFromBool(a.isPositive() != b.isPositive()); try r.ensureCapacity(cap); var m = r.toMutable(); @@ -4048,9 +4048,9 @@ fn llsignedxor(r: []Limb, a: []const Limb, a_positive: bool, b: []const Limb, b_ // - if the result is supposed to be negative, add 1. var i: usize = 0; - var a_borrow = @boolToInt(!a_positive); - var b_borrow = @boolToInt(!b_positive); - var r_carry = @boolToInt(a_positive != b_positive); + var a_borrow = @intFromBool(!a_positive); + var b_borrow = @intFromBool(!b_positive); + var r_carry = @intFromBool(a_positive != b_positive); while (i < b.len) : (i += 1) { const ov1 = @subWithOverflow(a[i], a_borrow); diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig index cdc33e351d31..22f7ba183ff4 100644 --- a/lib/std/math/big/rational.zig +++ b/lib/std/math/big/rational.zig @@ -276,7 +276,7 @@ pub const Rational = struct { } mantissa >>= 1; - const f = math.scalbn(@intToFloat(T, mantissa), @intCast(i32, exp - msize1)); + const f = math.scalbn(@floatFromInt(T, mantissa), @intCast(i32, exp - msize1)); if (math.isInf(f)) { exact = false; } @@ -289,7 +289,7 @@ pub const Rational = struct { try self.p.set(p); try self.q.set(q); - self.p.setSign(@boolToInt(self.p.isPositive()) ^ @boolToInt(self.q.isPositive()) == 0); + self.p.setSign(@intFromBool(self.p.isPositive()) ^ @intFromBool(self.q.isPositive()) == 0); self.q.setSign(true); try self.reduce(); @@ -310,7 +310,7 @@ pub const Rational = struct { try self.p.copy(a.toConst()); try self.q.copy(b.toConst()); - self.p.setSign(@boolToInt(self.p.isPositive()) ^ @boolToInt(self.q.isPositive()) == 0); + self.p.setSign(@intFromBool(self.p.isPositive()) ^ @intFromBool(self.q.isPositive()) == 0); self.q.setSign(true); try self.reduce(); diff --git a/lib/std/math/complex/atan.zig b/lib/std/math/complex/atan.zig index 929b98aebd22..56c199016d4c 100644 --- a/lib/std/math/complex/atan.zig +++ b/lib/std/math/complex/atan.zig @@ -32,7 +32,7 @@ fn redupif32(x: f32) f32 { t -= 0.5; } - const u = @intToFloat(f32, @floatToInt(i32, t)); + const u = @floatFromInt(f32, @intFromFloat(i32, t)); return ((x - u * DP1) - u * DP2) - t * DP3; } @@ -81,7 +81,7 @@ fn redupif64(x: f64) f64 { t -= 0.5; } - const u = @intToFloat(f64, @floatToInt(i64, t)); + const u = @floatFromInt(f64, @intFromFloat(i64, t)); return ((x - u * DP1) - u * DP2) - t * DP3; } diff --git a/lib/std/math/expm1.zig b/lib/std/math/expm1.zig index 5911edf36f98..5c4052db56c5 100644 --- a/lib/std/math/expm1.zig +++ b/lib/std/math/expm1.zig @@ -88,8 +88,8 @@ fn expm1_32(x_: f32) f32 { kf += 0.5; } - k = @floatToInt(i32, kf); - const t = @intToFloat(f32, k); + k = @intFromFloat(i32, kf); + const t = @floatFromInt(f32, k); hi = x - t * ln2_hi; lo = t * ln2_lo; } @@ -219,8 +219,8 @@ fn expm1_64(x_: f64) f64 { kf += 0.5; } - k = @floatToInt(i32, kf); - const t = @intToFloat(f64, k); + k = @intFromFloat(i32, kf); + const t = @floatFromInt(f64, k); hi = x - t * ln2_hi; lo = t * ln2_lo; } diff --git a/lib/std/math/ilogb.zig b/lib/std/math/ilogb.zig index c091619f3a2e..7c58be2ec519 100644 --- a/lib/std/math/ilogb.zig +++ b/lib/std/math/ilogb.zig @@ -48,7 +48,7 @@ fn ilogbX(comptime T: type, x: T) i32 { } // offset sign bit, exponent bits, and integer bit (if present) + bias - const offset = 1 + exponentBits + @as(comptime_int, @boolToInt(T == f80)) - exponentBias; + const offset = 1 + exponentBits + @as(comptime_int, @intFromBool(T == f80)) - exponentBias; return offset - @intCast(i32, @clz(u)); } diff --git a/lib/std/math/ldexp.zig b/lib/std/math/ldexp.zig index 89474751594c..448e94f8e5bd 100644 --- a/lib/std/math/ldexp.zig +++ b/lib/std/math/ldexp.zig @@ -24,7 +24,7 @@ pub fn ldexp(x: anytype, n: i32) @TypeOf(x) { var exponent: i32 = @intCast(i32, (repr << 1) >> (mantissa_bits + 1)); if (exponent == 0) - exponent += (@as(i32, exponent_bits) + @boolToInt(T == f80)) - @clz(repr << 1); + exponent += (@as(i32, exponent_bits) + @intFromBool(T == f80)) - @clz(repr << 1); if (n >= 0) { if (n > max_biased_exponent - exponent) { @@ -53,11 +53,11 @@ pub fn ldexp(x: anytype, n: i32) @TypeOf(x) { var result = repr & mantissa_mask; if (T != f80) // Include integer bit - result |= @as(TBits, @boolToInt(exponent > 0)) << fractional_bits; + result |= @as(TBits, @intFromBool(exponent > 0)) << fractional_bits; result = @intCast(TBits, (result >> (shift - 1))); // Round result, including round-to-even for exact ties - result = ((result + 1) >> 1) & ~@as(TBits, @boolToInt(exact_tie)); + result = ((result + 1) >> 1) & ~@as(TBits, @intFromBool(exact_tie)); return @bitCast(T, result | sign_bit); } diff --git a/lib/std/math/log.zig b/lib/std/math/log.zig index ad2763fa5412..c1a0f5c8e473 100644 --- a/lib/std/math/log.zig +++ b/lib/std/math/log.zig @@ -30,7 +30,7 @@ pub fn log(comptime T: type, base: T, x: T) T { // TODO implement integer log without using float math .Int => |IntType| switch (IntType.signedness) { .signed => @compileError("log not implemented for signed integers"), - .unsigned => return @floatToInt(T, @floor(@log(@intToFloat(f64, x)) / @log(float_base))), + .unsigned => return @intFromFloat(T, @floor(@log(@floatFromInt(f64, x)) / @log(float_base))), }, .Float => { diff --git a/lib/std/math/log10.zig b/lib/std/math/log10.zig index 6b5758763c67..44e5a884459b 100644 --- a/lib/std/math/log10.zig +++ b/lib/std/math/log10.zig @@ -134,7 +134,7 @@ inline fn less_than_5(x: u32) u32 { } fn oldlog10(x: anytype) u8 { - return @floatToInt(u8, @log10(@intToFloat(f64, x))); + return @intFromFloat(u8, @log10(@floatFromInt(f64, x))); } test "oldlog10 doesn't work" { diff --git a/lib/std/math/log1p.zig b/lib/std/math/log1p.zig index e186b2795a4a..ad67955a8d20 100644 --- a/lib/std/math/log1p.zig +++ b/lib/std/math/log1p.zig @@ -96,7 +96,7 @@ fn log1p_32(x: f32) f32 { const t2 = z * (Lg1 + w * Lg3); const R = t2 + t1; const hfsq = 0.5 * f * f; - const dk = @intToFloat(f32, k); + const dk = @floatFromInt(f32, k); return s * (hfsq + R) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi; } @@ -176,7 +176,7 @@ fn log1p_64(x: f64) f64 { const t1 = w * (Lg2 + w * (Lg4 + w * Lg6)); const t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7))); const R = t2 + t1; - const dk = @intToFloat(f64, k); + const dk = @floatFromInt(f64, k); return s * (hfsq + R) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi; } diff --git a/lib/std/math/pow.zig b/lib/std/math/pow.zig index 9cedf50e1337..7643e143e3c4 100644 --- a/lib/std/math/pow.zig +++ b/lib/std/math/pow.zig @@ -144,7 +144,7 @@ pub fn pow(comptime T: type, x: T, y: T) T { var xe = r2.exponent; var x1 = r2.significand; - var i = @floatToInt(std.meta.Int(.signed, @typeInfo(T).Float.bits), yi); + var i = @intFromFloat(std.meta.Int(.signed, @typeInfo(T).Float.bits), yi); while (i != 0) : (i >>= 1) { const overflow_shift = math.floatExponentBits(T) + 1; if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) { @@ -179,7 +179,7 @@ pub fn pow(comptime T: type, x: T, y: T) T { fn isOddInteger(x: f64) bool { const r = math.modf(x); - return r.fpart == 0.0 and @floatToInt(i64, r.ipart) & 1 == 1; + return r.fpart == 0.0 and @intFromFloat(i64, r.ipart) & 1 == 1; } test "math.pow" { diff --git a/lib/std/mem.zig b/lib/std/mem.zig index b320f579c62d..bbeecdda2376 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -73,7 +73,7 @@ pub fn ValidationAllocator(comptime T: type) type { const underlying = self.getUnderlyingAllocatorPtr(); const result = underlying.rawAlloc(n, log2_ptr_align, ret_addr) orelse return null; - assert(mem.isAlignedLog2(@ptrToInt(result), log2_ptr_align)); + assert(mem.isAlignedLog2(@intFromPtr(result), log2_ptr_align)); return result; } @@ -185,7 +185,7 @@ test "Allocator.resize" { var values = try testing.allocator.alloc(T, 100); defer testing.allocator.free(values); - for (values, 0..) |*v, i| v.* = @intToFloat(T, i); + for (values, 0..) |*v, i| v.* = @floatFromInt(T, i); if (!testing.allocator.resize(values, values.len + 10)) return error.OutOfMemory; values = values.ptr[0 .. values.len + 10]; try testing.expect(values.len == 110); @@ -233,7 +233,7 @@ pub fn zeroes(comptime T: type) T { return @as(T, 0); }, .Enum, .EnumLiteral => { - return @intToEnum(T, 0); + return @enumFromInt(T, 0); }, .Void => { return {}; @@ -1374,7 +1374,7 @@ pub fn readVarPackedInt( const value = if (read_size == 1) b: { break :b @truncate(uN, read_bytes[0] >> bit_shift); } else b: { - const i: u1 = @boolToInt(endian == .Big); + const i: u1 = @intFromBool(endian == .Big); const head = @truncate(uN, read_bytes[i] >> bit_shift); const tail_shift = @intCast(Log2N, @as(u4, 8) - bit_shift); const tail = @truncate(uN, read_bytes[1 - i]); @@ -3778,7 +3778,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize { return 0; // Calculate the aligned base address with an eye out for overflow. - const addr = @ptrToInt(ptr); + const addr = @intFromPtr(ptr); var ov = @addWithOverflow(addr, align_to - 1); if (ov[1] != 0) return null; ov[0] &= ~@as(usize, align_to - 1); @@ -3800,16 +3800,16 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize { pub fn alignPointer(ptr: anytype, align_to: usize) ?@TypeOf(ptr) { const adjust_off = alignPointerOffset(ptr, align_to) orelse return null; const T = @TypeOf(ptr); - // Avoid the use of intToPtr to avoid losing the pointer provenance info. + // Avoid the use of ptrFromInt to avoid losing the pointer provenance info. return @alignCast(@typeInfo(T).Pointer.alignment, ptr + adjust_off); } test "alignPointer" { const S = struct { fn checkAlign(comptime T: type, base: usize, align_to: usize, expected: usize) !void { - var ptr = @intToPtr(T, base); + var ptr = @ptrFromInt(T, base); var aligned = alignPointer(ptr, align_to); - try testing.expectEqual(expected, @ptrToInt(aligned)); + try testing.expectEqual(expected, @intFromPtr(aligned)); } }; @@ -4236,8 +4236,8 @@ pub fn doNotOptimizeAway(val: anytype) void { const t = @typeInfo(@TypeOf(val)); switch (t) { .Void, .Null, .ComptimeInt, .ComptimeFloat => return, - .Enum => doNotOptimizeAway(@enumToInt(val)), - .Bool => doNotOptimizeAway(@boolToInt(val)), + .Enum => doNotOptimizeAway(@intFromEnum(val)), + .Bool => doNotOptimizeAway(@intFromBool(val)), .Int => { const bits = t.Int.bits; if (bits <= max_gp_register_bits and builtin.zig_backend != .stage2_c) { @@ -4425,7 +4425,7 @@ fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) t /// Returns the largest slice in the given bytes that conforms to the new alignment, /// or `null` if the given bytes contain no conforming address. pub fn alignInBytes(bytes: []u8, comptime new_alignment: usize) ?[]align(new_alignment) u8 { - const begin_address = @ptrToInt(bytes.ptr); + const begin_address = @intFromPtr(bytes.ptr); const end_address = begin_address + bytes.len; const begin_address_aligned = mem.alignForward(usize, begin_address, new_alignment); diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig index 4a1ff86721f1..301480f66273 100644 --- a/lib/std/mem/Allocator.zig +++ b/lib/std/mem/Allocator.zig @@ -101,7 +101,7 @@ pub inline fn rawFree(self: Allocator, buf: []u8, log2_buf_align: u8, ret_addr: /// Returns a pointer to undefined memory. /// Call `destroy` with the result to free the memory. pub fn create(self: Allocator, comptime T: type) Error!*T { - if (@sizeOf(T) == 0) return @intToPtr(*T, math.maxInt(usize)); + if (@sizeOf(T) == 0) return @ptrFromInt(*T, math.maxInt(usize)); const slice = try self.allocAdvancedWithRetAddr(T, null, 1, @returnAddress()); return &slice[0]; } @@ -209,7 +209,7 @@ pub fn allocAdvancedWithRetAddr( if (n == 0) { const ptr = comptime std.mem.alignBackward(usize, math.maxInt(usize), a); - return @intToPtr([*]align(a) T, ptr)[0..0]; + return @ptrFromInt([*]align(a) T, ptr)[0..0]; } const byte_count = math.mul(usize, @sizeOf(T), n) catch return Error.OutOfMemory; @@ -268,13 +268,13 @@ pub fn reallocAdvanced( if (new_n == 0) { self.free(old_mem); const ptr = comptime std.mem.alignBackward(usize, math.maxInt(usize), Slice.alignment); - return @intToPtr([*]align(Slice.alignment) T, ptr)[0..0]; + return @ptrFromInt([*]align(Slice.alignment) T, ptr)[0..0]; } const old_byte_slice = mem.sliceAsBytes(old_mem); const byte_count = math.mul(usize, @sizeOf(T), new_n) catch return Error.OutOfMemory; // Note: can't set shrunk memory to undefined as memory shouldn't be modified on realloc failure - if (mem.isAligned(@ptrToInt(old_byte_slice.ptr), Slice.alignment)) { + if (mem.isAligned(@intFromPtr(old_byte_slice.ptr), Slice.alignment)) { if (self.rawResize(old_byte_slice, log2a(Slice.alignment), byte_count, return_address)) { return mem.bytesAsSlice(T, @alignCast(Slice.alignment, old_byte_slice.ptr[0..byte_count])); } diff --git a/lib/std/meta.zig b/lib/std/meta.zig index db415199ed1e..fedbd1a40d74 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -453,7 +453,7 @@ pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeIn .Enum => Type.EnumField, else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"), } { - return fields(T)[@enumToInt(field)]; + return fields(T)[@intFromEnum(field)]; } test "std.meta.fieldInfo" { @@ -591,7 +591,7 @@ pub fn FieldEnum(comptime T: type) type { if (@typeInfo(T) == .Union) { if (@typeInfo(T).Union.tag_type) |tag_type| { for (std.enums.values(tag_type), 0..) |v, i| { - if (@enumToInt(v) != i) break; // enum values not consecutive + if (@intFromEnum(v) != i) break; // enum values not consecutive if (!std.mem.eql(u8, @tagName(v), field_infos[i].name)) break; // fields out of order } else { return tag_type; @@ -929,8 +929,8 @@ test "intToEnum with error return" { try testing.expect(intToEnum(E1, zero) catch unreachable == E1.A); try testing.expect(intToEnum(E2, one) catch unreachable == E2.B); try testing.expect(intToEnum(E3, zero) catch unreachable == E3.A); - try testing.expect(intToEnum(E3, 127) catch unreachable == @intToEnum(E3, 127)); - try testing.expect(intToEnum(E3, -128) catch unreachable == @intToEnum(E3, -128)); + try testing.expect(intToEnum(E3, 127) catch unreachable == @enumFromInt(E3, 127)); + try testing.expect(intToEnum(E3, -128) catch unreachable == @enumFromInt(E3, -128)); try testing.expectError(error.InvalidEnumTag, intToEnum(E1, one)); try testing.expectError(error.InvalidEnumTag, intToEnum(E3, 128)); try testing.expectError(error.InvalidEnumTag, intToEnum(E3, -129)); @@ -943,14 +943,14 @@ pub fn intToEnum(comptime EnumTag: type, tag_int: anytype) IntToEnumError!EnumTa if (!enum_info.is_exhaustive) { if (std.math.cast(enum_info.tag_type, tag_int)) |tag| { - return @intToEnum(EnumTag, tag); + return @enumFromInt(EnumTag, tag); } return error.InvalidEnumTag; } inline for (enum_info.fields) |f| { const this_tag_value = @field(EnumTag, f.name); - if (tag_int == @enumToInt(this_tag_value)) { + if (tag_int == @intFromEnum(this_tag_value)) { return this_tag_value; } } diff --git a/lib/std/meta/trailer_flags.zig b/lib/std/meta/trailer_flags.zig index a4d83dcbb305..cf37fc5adfb6 100644 --- a/lib/std/meta/trailer_flags.zig +++ b/lib/std/meta/trailer_flags.zig @@ -43,7 +43,7 @@ pub fn TrailerFlags(comptime Fields: type) type { pub const Self = @This(); pub fn has(self: Self, comptime field: FieldEnum) bool { - const field_index = @enumToInt(field); + const field_index = @intFromEnum(field); return (self.bits & (1 << field_index)) != 0; } @@ -54,7 +54,7 @@ pub fn TrailerFlags(comptime Fields: type) type { } pub fn setFlag(self: *Self, comptime field: FieldEnum) void { - const field_index = @enumToInt(field); + const field_index = @intFromEnum(field); self.bits |= 1 << field_index; } @@ -72,7 +72,7 @@ pub fn TrailerFlags(comptime Fields: type) type { pub fn setMany(self: Self, p: [*]align(@alignOf(Fields)) u8, fields: FieldValues) void { inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| { if (@field(fields, field.name)) |value| - self.set(p, @intToEnum(FieldEnum, i), value); + self.set(p, @enumFromInt(FieldEnum, i), value); } } @@ -103,7 +103,7 @@ pub fn TrailerFlags(comptime Fields: type) type { var off: usize = 0; inline for (@typeInfo(Fields).Struct.fields, 0..) |field_info, i| { const active = (self.bits & (1 << i)) != 0; - if (i == @enumToInt(field)) { + if (i == @intFromEnum(field)) { assert(active); return mem.alignForward(usize, off, @alignOf(field_info.type)); } else if (active) { @@ -114,7 +114,7 @@ pub fn TrailerFlags(comptime Fields: type) type { } pub fn Field(comptime field: FieldEnum) type { - return @typeInfo(Fields).Struct.fields[@enumToInt(field)].type; + return @typeInfo(Fields).Struct.fields[@intFromEnum(field)].type; } pub fn sizeInBytes(self: Self) usize { diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig index e9011c3c6345..26ba6cc919ae 100644 --- a/lib/std/multi_array_list.zig +++ b/lib/std/multi_array_list.zig @@ -64,7 +64,7 @@ pub fn MultiArrayList(comptime T: type) type { /// and then get the field arrays from the slice. pub const Slice = struct { /// This array is indexed by the field index which can be obtained - /// by using @enumToInt() on the Field enum + /// by using @intFromEnum() on the Field enum ptrs: [fields.len][*]u8, len: usize, capacity: usize, @@ -74,7 +74,7 @@ pub fn MultiArrayList(comptime T: type) type { if (self.capacity == 0) { return &[_]F{}; } - const byte_ptr = self.ptrs[@enumToInt(field)]; + const byte_ptr = self.ptrs[@intFromEnum(field)]; const casted_ptr: [*]F = if (@sizeOf(F) == 0) undefined else @@ -89,14 +89,14 @@ pub fn MultiArrayList(comptime T: type) type { else => unreachable, }; inline for (fields, 0..) |field_info, i| { - self.items(@intToEnum(Field, i))[index] = @field(e, field_info.name); + self.items(@enumFromInt(Field, i))[index] = @field(e, field_info.name); } } pub fn get(self: Slice, index: usize) T { var result: Elem = undefined; inline for (fields, 0..) |field_info, i| { - @field(result, field_info.name) = self.items(@intToEnum(Field, i))[index]; + @field(result, field_info.name) = self.items(@enumFromInt(Field, i))[index]; } return switch (@typeInfo(T)) { .Struct => result, @@ -294,7 +294,7 @@ pub fn MultiArrayList(comptime T: type) type { }; const slices = self.slice(); inline for (fields, 0..) |field_info, field_index| { - const field_slice = slices.items(@intToEnum(Field, field_index)); + const field_slice = slices.items(@enumFromInt(Field, field_index)); var i: usize = self.len - 1; while (i > index) : (i -= 1) { field_slice[i] = field_slice[i - 1]; @@ -309,7 +309,7 @@ pub fn MultiArrayList(comptime T: type) type { pub fn swapRemove(self: *Self, index: usize) void { const slices = self.slice(); inline for (fields, 0..) |_, i| { - const field_slice = slices.items(@intToEnum(Field, i)); + const field_slice = slices.items(@enumFromInt(Field, i)); field_slice[index] = field_slice[self.len - 1]; field_slice[self.len - 1] = undefined; } @@ -321,7 +321,7 @@ pub fn MultiArrayList(comptime T: type) type { pub fn orderedRemove(self: *Self, index: usize) void { const slices = self.slice(); inline for (fields, 0..) |_, field_index| { - const field_slice = slices.items(@intToEnum(Field, field_index)); + const field_slice = slices.items(@enumFromInt(Field, field_index)); var i = index; while (i < self.len - 1) : (i += 1) { field_slice[i] = field_slice[i + 1]; @@ -358,7 +358,7 @@ pub fn MultiArrayList(comptime T: type) type { const self_slice = self.slice(); inline for (fields, 0..) |field_info, i| { if (@sizeOf(field_info.type) != 0) { - const field = @intToEnum(Field, i); + const field = @enumFromInt(Field, i); const dest_slice = self_slice.items(field)[new_len..]; // We use memset here for more efficient codegen in safety-checked, // valgrind-enabled builds. Otherwise the valgrind client request @@ -379,7 +379,7 @@ pub fn MultiArrayList(comptime T: type) type { const other_slice = other.slice(); inline for (fields, 0..) |field_info, i| { if (@sizeOf(field_info.type) != 0) { - const field = @intToEnum(Field, i); + const field = @enumFromInt(Field, i); @memcpy(other_slice.items(field), self_slice.items(field)); } } @@ -440,7 +440,7 @@ pub fn MultiArrayList(comptime T: type) type { const other_slice = other.slice(); inline for (fields, 0..) |field_info, i| { if (@sizeOf(field_info.type) != 0) { - const field = @intToEnum(Field, i); + const field = @enumFromInt(Field, i); @memcpy(other_slice.items(field), self_slice.items(field)); } } @@ -459,7 +459,7 @@ pub fn MultiArrayList(comptime T: type) type { const result_slice = result.slice(); inline for (fields, 0..) |field_info, i| { if (@sizeOf(field_info.type) != 0) { - const field = @intToEnum(Field, i); + const field = @enumFromInt(Field, i); @memcpy(result_slice.items(field), self_slice.items(field)); } } @@ -476,7 +476,7 @@ pub fn MultiArrayList(comptime T: type) type { pub fn swap(sc: @This(), a_index: usize, b_index: usize) void { inline for (fields, 0..) |field_info, i| { if (@sizeOf(field_info.type) != 0) { - const field = @intToEnum(Field, i); + const field = @enumFromInt(Field, i); const ptr = sc.slice.items(field); mem.swap(field_info.type, &ptr[a_index], &ptr[b_index]); } diff --git a/lib/std/net.zig b/lib/std/net.zig index dfd6fe4a9ed4..0f8ecbf21e8f 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -804,8 +804,8 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) Get var first = true; while (true) { const rc = ws2_32.getaddrinfo(name_c.ptr, port_c.ptr, &hints, &res); - switch (@intToEnum(os.windows.ws2_32.WinsockError, @intCast(u16, rc))) { - @intToEnum(os.windows.ws2_32.WinsockError, 0) => break, + switch (@enumFromInt(os.windows.ws2_32.WinsockError, @intCast(u16, rc))) { + @enumFromInt(os.windows.ws2_32.WinsockError, 0) => break, .WSATRY_AGAIN => return error.TemporaryNameServerFailure, .WSANO_RECOVERY => return error.NameServerFailure, .WSAEAFNOSUPPORT => return error.AddressFamilyNotSupported, @@ -874,7 +874,7 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) Get }; var res: ?*os.addrinfo = null; switch (sys.getaddrinfo(name_c.ptr, port_c.ptr, &hints, &res)) { - @intToEnum(sys.EAI, 0) => {}, + @enumFromInt(sys.EAI, 0) => {}, .ADDRFAMILY => return error.HostLacksNetworkAddresses, .AGAIN => return error.TemporaryNameServerFailure, .BADFLAGS => unreachable, // Invalid hints @@ -1688,19 +1688,19 @@ fn dnsParse( if (qdcount + ancount > 64) return error.InvalidDnsPacket; while (qdcount != 0) { qdcount -= 1; - while (@ptrToInt(p) - @ptrToInt(r.ptr) < r.len and p[0] -% 1 < 127) p += 1; - if (p[0] > 193 or (p[0] == 193 and p[1] > 254) or @ptrToInt(p) > @ptrToInt(r.ptr) + r.len - 6) + while (@intFromPtr(p) - @intFromPtr(r.ptr) < r.len and p[0] -% 1 < 127) p += 1; + if (p[0] > 193 or (p[0] == 193 and p[1] > 254) or @intFromPtr(p) > @intFromPtr(r.ptr) + r.len - 6) return error.InvalidDnsPacket; - p += @as(usize, 5) + @boolToInt(p[0] != 0); + p += @as(usize, 5) + @intFromBool(p[0] != 0); } while (ancount != 0) { ancount -= 1; - while (@ptrToInt(p) - @ptrToInt(r.ptr) < r.len and p[0] -% 1 < 127) p += 1; - if (p[0] > 193 or (p[0] == 193 and p[1] > 254) or @ptrToInt(p) > @ptrToInt(r.ptr) + r.len - 6) + while (@intFromPtr(p) - @intFromPtr(r.ptr) < r.len and p[0] -% 1 < 127) p += 1; + if (p[0] > 193 or (p[0] == 193 and p[1] > 254) or @intFromPtr(p) > @intFromPtr(r.ptr) + r.len - 6) return error.InvalidDnsPacket; - p += @as(usize, 1) + @boolToInt(p[0] != 0); + p += @as(usize, 1) + @intFromBool(p[0] != 0); const len = p[8] * @as(usize, 256) + p[9]; - if (@ptrToInt(p) + len > @ptrToInt(r.ptr) + r.len) return error.InvalidDnsPacket; + if (@intFromPtr(p) + len > @intFromPtr(r.ptr) + r.len) return error.InvalidDnsPacket; try callback(ctx, p[1], p[10..][0..len], r); p += 10 + len; } diff --git a/lib/std/os.zig b/lib/std/os.zig index 802bb1d8df2c..2bfea02c21b5 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -608,7 +608,7 @@ pub fn abort() noreturn { sigprocmask(SIG.UNBLOCK, &sigabrtmask, null); // Beyond this point should be unreachable. - @intToPtr(*allowzero volatile u8, 0).* = 0; + @ptrFromInt(*allowzero volatile u8, 0).* = 0; raise(SIG.KILL) catch {}; exit(127); // Pid 1 might not be signalled in some containers. } @@ -678,10 +678,10 @@ pub fn exit(status: u8) noreturn { // exit() is only available if exitBootServices() has not been called yet. // This call to exit should not fail, so we don't care about its return value. if (uefi.system_table.boot_services) |bs| { - _ = bs.exit(uefi.handle, @intToEnum(uefi.Status, status), 0, null); + _ = bs.exit(uefi.handle, @enumFromInt(uefi.Status, status), 0, null); } // If we can't exit, reboot the system instead. - uefi.system_table.runtime_services.resetSystem(uefi.tables.ResetType.ResetCold, @intToEnum(uefi.Status, status), 0, null); + uefi.system_table.runtime_services.resetSystem(uefi.tables.ResetType.ResetCold, @enumFromInt(uefi.Status, status), 0, null); } system.exit(status); } @@ -2045,7 +2045,7 @@ pub fn getcwd(out_buffer: []u8) GetCwdError![]u8 { const err = if (builtin.link_libc) blk: { const c_err = if (std.c.getcwd(out_buffer.ptr, out_buffer.len)) |_| 0 else std.c._errno().*; - break :blk @intToEnum(E, c_err); + break :blk @enumFromInt(E, c_err); } else blk: { break :blk errno(system.getcwd(out_buffer.ptr, out_buffer.len)); }; @@ -3249,7 +3249,7 @@ pub fn isatty(handle: fd_t) bool { while (true) { var wsz: linux.winsize = undefined; const fd = @bitCast(usize, @as(isize, handle)); - const rc = linux.syscall3(.ioctl, fd, linux.T.IOCGWINSZ, @ptrToInt(&wsz)); + const rc = linux.syscall3(.ioctl, fd, linux.T.IOCGWINSZ, @intFromPtr(&wsz)); switch (linux.getErrno(rc)) { .SUCCESS => return true, .INTR => continue, @@ -4016,7 +4016,7 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void { const rc = system.getsockopt(sockfd, SOL.SOCKET, SO.ERROR, @ptrCast([*]u8, &err_code), &size); assert(size == 4); switch (errno(rc)) { - .SUCCESS => switch (@intToEnum(E, err_code)) { + .SUCCESS => switch (@enumFromInt(E, err_code)) { .SUCCESS => return, .ACCES => return error.PermissionDenied, .PERM => return error.PermissionDenied, @@ -4425,10 +4425,10 @@ pub fn mmap( const rc = mmap_sym(ptr, length, prot, flags, fd, ioffset); const err = if (builtin.link_libc) blk: { if (rc != std.c.MAP.FAILED) return @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length]; - break :blk @intToEnum(E, system._errno().*); + break :blk @enumFromInt(E, system._errno().*); } else blk: { const err = errno(rc); - if (err == .SUCCESS) return @intToPtr([*]align(mem.page_size) u8, rc)[0..length]; + if (err == .SUCCESS) return @ptrFromInt([*]align(mem.page_size) u8, rc)[0..length]; break :blk err; }; switch (err) { @@ -5164,7 +5164,7 @@ pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP return getFdPath(fd, out_buffer); } - const result_path = std.c.realpath(pathname, out_buffer) orelse switch (@intToEnum(E, std.c._errno().*)) { + const result_path = std.c.realpath(pathname, out_buffer) orelse switch (@enumFromInt(E, std.c._errno().*)) { .SUCCESS => unreachable, .INVAL => unreachable, .BADF => unreachable, @@ -5275,7 +5275,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 { if (comptime builtin.os.version_range.semver.max.order(.{ .major = 13, .minor = 0, .patch = 0 }) == .gt) { var kfile: system.kinfo_file = undefined; kfile.structsize = system.KINFO_FILE_SIZE; - switch (errno(system.fcntl(fd, system.F.KINFO, @ptrToInt(&kfile)))) { + switch (errno(system.fcntl(fd, system.F.KINFO, @intFromPtr(&kfile)))) { .SUCCESS => {}, .BADF => return error.FileNotFound, else => |err| return unexpectedErrno(err), @@ -5400,21 +5400,21 @@ pub fn dl_iterate_phdr( switch (system.dl_iterate_phdr(struct { fn callbackC(info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int { const context_ptr = @ptrCast(*const Context, @alignCast(@alignOf(*const Context), data)); - callback(info, size, context_ptr.*) catch |err| return @errorToInt(err); + callback(info, size, context_ptr.*) catch |err| return @intFromError(err); return 0; } - }.callbackC, @intToPtr(?*anyopaque, @ptrToInt(&context)))) { + }.callbackC, @ptrFromInt(?*anyopaque, @intFromPtr(&context)))) { 0 => return, - else => |err| return @errSetCast(Error, @intToError(@intCast(u16, err))), // TODO don't hardcode u16 + else => |err| return @errSetCast(Error, @errorFromInt(@intCast(u16, err))), // TODO don't hardcode u16 } } const elf_base = std.process.getBaseAddress(); - const ehdr = @intToPtr(*elf.Ehdr, elf_base); + const ehdr = @ptrFromInt(*elf.Ehdr, elf_base); // Make sure the base address points to an ELF image. assert(mem.eql(u8, ehdr.e_ident[0..4], elf.MAGIC)); const n_phdr = ehdr.e_phnum; - const phdrs = (@intToPtr([*]elf.Phdr, elf_base + ehdr.e_phoff))[0..n_phdr]; + const phdrs = (@ptrFromInt([*]elf.Phdr, elf_base + ehdr.e_phoff))[0..n_phdr]; var it = dl.linkmap_iterator(phdrs) catch unreachable; @@ -5425,7 +5425,7 @@ pub fn dl_iterate_phdr( // is non-zero. const base_address = for (phdrs) |*phdr| { if (phdr.p_type == elf.PT_PHDR) { - break @ptrToInt(phdrs.ptr) - phdr.p_vaddr; + break @intFromPtr(phdrs.ptr) - phdr.p_vaddr; // We could try computing the difference between _DYNAMIC and // the p_vaddr of the PT_DYNAMIC section, but using the phdr is // good enough (Is it?). @@ -5448,12 +5448,12 @@ pub fn dl_iterate_phdr( var dlpi_phnum: u16 = undefined; if (entry.l_addr != 0) { - const elf_header = @intToPtr(*elf.Ehdr, entry.l_addr); - dlpi_phdr = @intToPtr([*]elf.Phdr, entry.l_addr + elf_header.e_phoff); + const elf_header = @ptrFromInt(*elf.Ehdr, entry.l_addr); + dlpi_phdr = @ptrFromInt([*]elf.Phdr, entry.l_addr + elf_header.e_phoff); dlpi_phnum = elf_header.e_phnum; } else { // This is the running ELF image - dlpi_phdr = @intToPtr([*]elf.Phdr, elf_base + ehdr.e_phoff); + dlpi_phdr = @ptrFromInt([*]elf.Phdr, elf_base + ehdr.e_phoff); dlpi_phnum = ehdr.e_phnum; } @@ -5626,7 +5626,7 @@ pub const UnexpectedError = error{ /// and you get an unexpected error. pub fn unexpectedErrno(err: E) UnexpectedError { if (unexpected_error_tracing) { - std.debug.print("unexpected errno: {d}\n", .{@enumToInt(err)}); + std.debug.print("unexpected errno: {d}\n", .{@intFromEnum(err)}); std.debug.dumpCurrentStackTrace(null); } return error.Unexpected; @@ -5773,7 +5773,7 @@ pub fn res_mkquery( var name = dname; if (mem.endsWith(u8, name, ".")) name.len -= 1; assert(name.len <= 253); - const n = 17 + name.len + @boolToInt(name.len != 0); + const n = 17 + name.len + @intFromBool(name.len != 0); // Construct query template - ID will be filled later var q: [280]u8 = undefined; @@ -6673,7 +6673,7 @@ pub fn dn_expand( if ((p[0] & 0xc0) != 0) { if (p + 1 == end) return error.InvalidDnsPacket; var j = ((p[0] & @as(usize, 0x3f)) << 8) | p[1]; - if (len == std.math.maxInt(usize)) len = @ptrToInt(p) + 2 - @ptrToInt(comp_dn.ptr); + if (len == std.math.maxInt(usize)) len = @intFromPtr(p) + 2 - @intFromPtr(comp_dn.ptr); if (j >= msg.len) return error.InvalidDnsPacket; p = msg.ptr + j; } else if (p[0] != 0) { @@ -6683,7 +6683,7 @@ pub fn dn_expand( } var j = p[0]; p += 1; - if (j >= @ptrToInt(end) - @ptrToInt(p) or j >= @ptrToInt(dend) - @ptrToInt(dest)) { + if (j >= @intFromPtr(end) - @intFromPtr(p) or j >= @intFromPtr(dend) - @intFromPtr(dest)) { return error.InvalidDnsPacket; } while (j != 0) { @@ -6694,7 +6694,7 @@ pub fn dn_expand( } } else { dest[0] = 0; - if (len == std.math.maxInt(usize)) len = @ptrToInt(p) + 1 - @ptrToInt(comp_dn.ptr); + if (len == std.math.maxInt(usize)) len = @intFromPtr(p) + 1 - @intFromPtr(comp_dn.ptr); return len; } } @@ -6908,7 +6908,7 @@ pub const IoCtl_SIOCGIFINDEX_Error = error{ pub fn ioctl_SIOCGIFINDEX(fd: fd_t, ifr: *ifreq) IoCtl_SIOCGIFINDEX_Error!void { while (true) { - switch (errno(system.ioctl(fd, SIOCGIFINDEX, @ptrToInt(ifr)))) { + switch (errno(system.ioctl(fd, SIOCGIFINDEX, @intFromPtr(ifr)))) { .SUCCESS => return, .INVAL => unreachable, // Bad parameters. .NOTTY => unreachable, @@ -7032,7 +7032,7 @@ pub fn prctl(option: PR, args: anytype) PrctlError!u31 { inline while (i < args.len) : (i += 1) buf[i] = args[i]; } - const rc = system.prctl(@enumToInt(option), buf[0], buf[1], buf[2], buf[3]); + const rc = system.prctl(@intFromEnum(option), buf[0], buf[1], buf[2], buf[3]); switch (errno(rc)) { .SUCCESS => return @intCast(u31, rc), .ACCES => return error.AccessDenied, @@ -7318,7 +7318,7 @@ pub fn ptrace(request: u32, pid: pid_t, addr: usize, signal: usize) PtraceError! .macos, .ios, .tvos, .watchos => switch (errno(darwin.ptrace( math.cast(i32, request) orelse return error.Overflow, pid, - @intToPtr(?[*]u8, addr), + @ptrFromInt(?[*]u8, addr), math.cast(i32, signal) orelse return error.Overflow, ))) { .SUCCESS => {}, diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index e4d6790505ea..b7ec29383b46 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -206,7 +206,7 @@ fn splitValue64(val: i64) [2]u32 { pub fn getErrno(r: usize) E { const signed_r = @bitCast(isize, r); const int = if (signed_r > -4096 and signed_r < 0) -signed_r else 0; - return @intToEnum(E, int); + return @enumFromInt(E, int); } pub fn dup(old: i32) usize { @@ -234,7 +234,7 @@ pub fn dup3(old: i32, new: i32, flags: u32) usize { } pub fn chdir(path: [*:0]const u8) usize { - return syscall1(.chdir, @ptrToInt(path)); + return syscall1(.chdir, @intFromPtr(path)); } pub fn fchdir(fd: fd_t) usize { @@ -242,11 +242,11 @@ pub fn fchdir(fd: fd_t) usize { } pub fn chroot(path: [*:0]const u8) usize { - return syscall1(.chroot, @ptrToInt(path)); + return syscall1(.chroot, @intFromPtr(path)); } pub fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) usize { - return syscall3(.execve, @ptrToInt(path), @ptrToInt(argv), @ptrToInt(envp)); + return syscall3(.execve, @intFromPtr(path), @intFromPtr(argv), @intFromPtr(envp)); } pub fn fork() usize { @@ -273,7 +273,7 @@ pub fn futimens(fd: i32, times: *const [2]timespec) usize { } pub fn utimensat(dirfd: i32, path: ?[*:0]const u8, times: *const [2]timespec, flags: u32) usize { - return syscall4(.utimensat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(times), flags); + return syscall4(.utimensat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), @intFromPtr(times), flags); } pub fn fallocate(fd: i32, mode: i32, offset: i64, length: i64) usize { @@ -301,22 +301,22 @@ pub fn fallocate(fd: i32, mode: i32, offset: i64, length: i64) usize { } pub fn futex_wait(uaddr: *const i32, futex_op: u32, val: i32, timeout: ?*const timespec) usize { - return syscall4(.futex, @ptrToInt(uaddr), futex_op, @bitCast(u32, val), @ptrToInt(timeout)); + return syscall4(.futex, @intFromPtr(uaddr), futex_op, @bitCast(u32, val), @intFromPtr(timeout)); } pub fn futex_wake(uaddr: *const i32, futex_op: u32, val: i32) usize { - return syscall3(.futex, @ptrToInt(uaddr), futex_op, @bitCast(u32, val)); + return syscall3(.futex, @intFromPtr(uaddr), futex_op, @bitCast(u32, val)); } pub fn getcwd(buf: [*]u8, size: usize) usize { - return syscall2(.getcwd, @ptrToInt(buf), size); + return syscall2(.getcwd, @intFromPtr(buf), size); } pub fn getdents(fd: i32, dirp: [*]u8, len: usize) usize { return syscall3( .getdents, @bitCast(usize, @as(isize, fd)), - @ptrToInt(dirp), + @intFromPtr(dirp), @min(len, maxInt(c_int)), ); } @@ -325,7 +325,7 @@ pub fn getdents64(fd: i32, dirp: [*]u8, len: usize) usize { return syscall3( .getdents64, @bitCast(usize, @as(isize, fd)), - @ptrToInt(dirp), + @intFromPtr(dirp), @min(len, maxInt(c_int)), ); } @@ -335,7 +335,7 @@ pub fn inotify_init1(flags: u32) usize { } pub fn inotify_add_watch(fd: i32, pathname: [*:0]const u8, mask: u32) usize { - return syscall3(.inotify_add_watch, @bitCast(usize, @as(isize, fd)), @ptrToInt(pathname), mask); + return syscall3(.inotify_add_watch, @bitCast(usize, @as(isize, fd)), @intFromPtr(pathname), mask); } pub fn inotify_rm_watch(fd: i32, wd: i32) usize { @@ -344,61 +344,61 @@ pub fn inotify_rm_watch(fd: i32, wd: i32) usize { pub fn readlink(noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize { if (@hasField(SYS, "readlink")) { - return syscall3(.readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len); + return syscall3(.readlink, @intFromPtr(path), @intFromPtr(buf_ptr), buf_len); } else { - return syscall4(.readlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len); + return syscall4(.readlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(path), @intFromPtr(buf_ptr), buf_len); } } pub fn readlinkat(dirfd: i32, noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize { - return syscall4(.readlinkat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len); + return syscall4(.readlinkat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), @intFromPtr(buf_ptr), buf_len); } pub fn mkdir(path: [*:0]const u8, mode: u32) usize { if (@hasField(SYS, "mkdir")) { - return syscall2(.mkdir, @ptrToInt(path), mode); + return syscall2(.mkdir, @intFromPtr(path), mode); } else { - return syscall3(.mkdirat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), mode); + return syscall3(.mkdirat, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(path), mode); } } pub fn mkdirat(dirfd: i32, path: [*:0]const u8, mode: u32) usize { - return syscall3(.mkdirat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode); + return syscall3(.mkdirat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), mode); } pub fn mknod(path: [*:0]const u8, mode: u32, dev: u32) usize { if (@hasField(SYS, "mknod")) { - return syscall3(.mknod, @ptrToInt(path), mode, dev); + return syscall3(.mknod, @intFromPtr(path), mode, dev); } else { return mknodat(AT.FDCWD, path, mode, dev); } } pub fn mknodat(dirfd: i32, path: [*:0]const u8, mode: u32, dev: u32) usize { - return syscall4(.mknodat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode, dev); + return syscall4(.mknodat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), mode, dev); } pub fn mount(special: [*:0]const u8, dir: [*:0]const u8, fstype: ?[*:0]const u8, flags: u32, data: usize) usize { - return syscall5(.mount, @ptrToInt(special), @ptrToInt(dir), @ptrToInt(fstype), flags, data); + return syscall5(.mount, @intFromPtr(special), @intFromPtr(dir), @intFromPtr(fstype), flags, data); } pub fn umount(special: [*:0]const u8) usize { - return syscall2(.umount2, @ptrToInt(special), 0); + return syscall2(.umount2, @intFromPtr(special), 0); } pub fn umount2(special: [*:0]const u8, flags: u32) usize { - return syscall2(.umount2, @ptrToInt(special), flags); + return syscall2(.umount2, @intFromPtr(special), flags); } pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: i64) usize { if (@hasField(SYS, "mmap2")) { // Make sure the offset is also specified in multiples of page size if ((offset & (MMAP2_UNIT - 1)) != 0) - return @bitCast(usize, -@as(isize, @enumToInt(E.INVAL))); + return @bitCast(usize, -@as(isize, @intFromEnum(E.INVAL))); return syscall6( .mmap2, - @ptrToInt(address), + @intFromPtr(address), length, prot, flags, @@ -408,7 +408,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, of } else { return syscall6( .mmap, - @ptrToInt(address), + @intFromPtr(address), length, prot, flags, @@ -419,7 +419,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, of } pub fn mprotect(address: [*]const u8, length: usize, protection: usize) usize { - return syscall3(.mprotect, @ptrToInt(address), length, protection); + return syscall3(.mprotect, @intFromPtr(address), length, protection); } pub const MSF = struct { @@ -429,22 +429,22 @@ pub const MSF = struct { }; pub fn msync(address: [*]const u8, length: usize, flags: i32) usize { - return syscall3(.msync, @ptrToInt(address), length, @bitCast(u32, flags)); + return syscall3(.msync, @intFromPtr(address), length, @bitCast(u32, flags)); } pub fn munmap(address: [*]const u8, length: usize) usize { - return syscall2(.munmap, @ptrToInt(address), length); + return syscall2(.munmap, @intFromPtr(address), length); } pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize { if (@hasField(SYS, "poll")) { - return syscall3(.poll, @ptrToInt(fds), n, @bitCast(u32, timeout)); + return syscall3(.poll, @intFromPtr(fds), n, @bitCast(u32, timeout)); } else { return syscall5( .ppoll, - @ptrToInt(fds), + @intFromPtr(fds), n, - @ptrToInt(if (timeout >= 0) + @intFromPtr(if (timeout >= 0) ×pec{ .tv_sec = @divTrunc(timeout, 1000), .tv_nsec = @rem(timeout, 1000) * 1000000, @@ -458,11 +458,11 @@ pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize { } pub fn ppoll(fds: [*]pollfd, n: nfds_t, timeout: ?*timespec, sigmask: ?*const sigset_t) usize { - return syscall5(.ppoll, @ptrToInt(fds), n, @ptrToInt(timeout), @ptrToInt(sigmask), NSIG / 8); + return syscall5(.ppoll, @intFromPtr(fds), n, @intFromPtr(timeout), @intFromPtr(sigmask), NSIG / 8); } pub fn read(fd: i32, buf: [*]u8, count: usize) usize { - return syscall3(.read, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count); + return syscall3(.read, @bitCast(usize, @as(isize, fd)), @intFromPtr(buf), count); } pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: i64) usize { @@ -470,7 +470,7 @@ pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: i64) usize { return syscall5( .preadv, @bitCast(usize, @as(isize, fd)), - @ptrToInt(iov), + @intFromPtr(iov), count, // Kernel expects the offset is split into largest natural word-size. // See following link for detail: @@ -485,7 +485,7 @@ pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: i64, flags: k return syscall6( .preadv2, @bitCast(usize, @as(isize, fd)), - @ptrToInt(iov), + @intFromPtr(iov), count, // See comments in preadv @truncate(usize, offset_u), @@ -495,11 +495,11 @@ pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: i64, flags: k } pub fn readv(fd: i32, iov: [*]const iovec, count: usize) usize { - return syscall3(.readv, @bitCast(usize, @as(isize, fd)), @ptrToInt(iov), count); + return syscall3(.readv, @bitCast(usize, @as(isize, fd)), @intFromPtr(iov), count); } pub fn writev(fd: i32, iov: [*]const iovec_const, count: usize) usize { - return syscall3(.writev, @bitCast(usize, @as(isize, fd)), @ptrToInt(iov), count); + return syscall3(.writev, @bitCast(usize, @as(isize, fd)), @intFromPtr(iov), count); } pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: i64) usize { @@ -507,7 +507,7 @@ pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: i64) us return syscall5( .pwritev, @bitCast(usize, @as(isize, fd)), - @ptrToInt(iov), + @intFromPtr(iov), count, // See comments in preadv @truncate(usize, offset_u), @@ -520,7 +520,7 @@ pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: i64, f return syscall6( .pwritev2, @bitCast(usize, @as(isize, fd)), - @ptrToInt(iov), + @intFromPtr(iov), count, // See comments in preadv @truncate(usize, offset_u), @@ -531,22 +531,22 @@ pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: i64, f pub fn rmdir(path: [*:0]const u8) usize { if (@hasField(SYS, "rmdir")) { - return syscall1(.rmdir, @ptrToInt(path)); + return syscall1(.rmdir, @intFromPtr(path)); } else { - return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), AT.REMOVEDIR); + return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(path), AT.REMOVEDIR); } } pub fn symlink(existing: [*:0]const u8, new: [*:0]const u8) usize { if (@hasField(SYS, "symlink")) { - return syscall2(.symlink, @ptrToInt(existing), @ptrToInt(new)); + return syscall2(.symlink, @intFromPtr(existing), @intFromPtr(new)); } else { - return syscall3(.symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(new)); + return syscall3(.symlinkat, @intFromPtr(existing), @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(new)); } } pub fn symlinkat(existing: [*:0]const u8, newfd: i32, newpath: [*:0]const u8) usize { - return syscall3(.symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, newfd)), @ptrToInt(newpath)); + return syscall3(.symlinkat, @intFromPtr(existing), @bitCast(usize, @as(isize, newfd)), @intFromPtr(newpath)); } pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize { @@ -556,7 +556,7 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize { return syscall6( .pread64, @bitCast(usize, @as(isize, fd)), - @ptrToInt(buf), + @intFromPtr(buf), count, 0, offset_halves[0], @@ -566,7 +566,7 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize { return syscall5( .pread64, @bitCast(usize, @as(isize, fd)), - @ptrToInt(buf), + @intFromPtr(buf), count, offset_halves[0], offset_halves[1], @@ -581,7 +581,7 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize { return syscall4( syscall_number, @bitCast(usize, @as(isize, fd)), - @ptrToInt(buf), + @intFromPtr(buf), count, @bitCast(u64, offset), ); @@ -590,32 +590,32 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize { pub fn access(path: [*:0]const u8, mode: u32) usize { if (@hasField(SYS, "access")) { - return syscall2(.access, @ptrToInt(path), mode); + return syscall2(.access, @intFromPtr(path), mode); } else { - return syscall4(.faccessat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), mode, 0); + return syscall4(.faccessat, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(path), mode, 0); } } pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize { - return syscall4(.faccessat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode, flags); + return syscall4(.faccessat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), mode, flags); } pub fn pipe(fd: *[2]i32) usize { if (comptime (native_arch.isMIPS() or native_arch.isSPARC())) { return syscall_pipe(fd); } else if (@hasField(SYS, "pipe")) { - return syscall1(.pipe, @ptrToInt(fd)); + return syscall1(.pipe, @intFromPtr(fd)); } else { - return syscall2(.pipe2, @ptrToInt(fd), 0); + return syscall2(.pipe2, @intFromPtr(fd), 0); } } pub fn pipe2(fd: *[2]i32, flags: u32) usize { - return syscall2(.pipe2, @ptrToInt(fd), flags); + return syscall2(.pipe2, @intFromPtr(fd), flags); } pub fn write(fd: i32, buf: [*]const u8, count: usize) usize { - return syscall3(.write, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count); + return syscall3(.write, @bitCast(usize, @as(isize, fd)), @intFromPtr(buf), count); } pub fn ftruncate(fd: i32, length: i64) usize { @@ -654,7 +654,7 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize { return syscall6( .pwrite64, @bitCast(usize, @as(isize, fd)), - @ptrToInt(buf), + @intFromPtr(buf), count, 0, offset_halves[0], @@ -664,7 +664,7 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize { return syscall5( .pwrite64, @bitCast(usize, @as(isize, fd)), - @ptrToInt(buf), + @intFromPtr(buf), count, offset_halves[0], offset_halves[1], @@ -679,7 +679,7 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize { return syscall4( syscall_number, @bitCast(usize, @as(isize, fd)), - @ptrToInt(buf), + @intFromPtr(buf), count, @bitCast(u64, offset), ); @@ -688,11 +688,11 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize { pub fn rename(old: [*:0]const u8, new: [*:0]const u8) usize { if (@hasField(SYS, "rename")) { - return syscall2(.rename, @ptrToInt(old), @ptrToInt(new)); + return syscall2(.rename, @intFromPtr(old), @intFromPtr(new)); } else if (@hasField(SYS, "renameat")) { - return syscall4(.renameat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(new)); + return syscall4(.renameat, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(old), @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(new)); } else { - return syscall5(.renameat2, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(new), 0); + return syscall5(.renameat2, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(old), @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(new), 0); } } @@ -701,17 +701,17 @@ pub fn renameat(oldfd: i32, oldpath: [*]const u8, newfd: i32, newpath: [*]const return syscall4( .renameat, @bitCast(usize, @as(isize, oldfd)), - @ptrToInt(oldpath), + @intFromPtr(oldpath), @bitCast(usize, @as(isize, newfd)), - @ptrToInt(newpath), + @intFromPtr(newpath), ); } else { return syscall5( .renameat2, @bitCast(usize, @as(isize, oldfd)), - @ptrToInt(oldpath), + @intFromPtr(oldpath), @bitCast(usize, @as(isize, newfd)), - @ptrToInt(newpath), + @intFromPtr(newpath), 0, ); } @@ -721,21 +721,21 @@ pub fn renameat2(oldfd: i32, oldpath: [*:0]const u8, newfd: i32, newpath: [*:0]c return syscall5( .renameat2, @bitCast(usize, @as(isize, oldfd)), - @ptrToInt(oldpath), + @intFromPtr(oldpath), @bitCast(usize, @as(isize, newfd)), - @ptrToInt(newpath), + @intFromPtr(newpath), flags, ); } pub fn open(path: [*:0]const u8, flags: u32, perm: mode_t) usize { if (@hasField(SYS, "open")) { - return syscall3(.open, @ptrToInt(path), flags, perm); + return syscall3(.open, @intFromPtr(path), flags, perm); } else { return syscall4( .openat, @bitCast(usize, @as(isize, AT.FDCWD)), - @ptrToInt(path), + @intFromPtr(path), flags, perm, ); @@ -743,17 +743,17 @@ pub fn open(path: [*:0]const u8, flags: u32, perm: mode_t) usize { } pub fn create(path: [*:0]const u8, perm: mode_t) usize { - return syscall2(.creat, @ptrToInt(path), perm); + return syscall2(.creat, @intFromPtr(path), perm); } pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, mode: mode_t) usize { // dirfd could be negative, for example AT.FDCWD is -100 - return syscall4(.openat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags, mode); + return syscall4(.openat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), flags, mode); } /// See also `clone` (from the arch-specific include) pub fn clone5(flags: usize, child_stack_ptr: usize, parent_tid: *i32, child_tid: *i32, newtls: usize) usize { - return syscall5(.clone, flags, child_stack_ptr, @ptrToInt(parent_tid), @ptrToInt(child_tid), newtls); + return syscall5(.clone, flags, child_stack_ptr, @intFromPtr(parent_tid), @intFromPtr(child_tid), newtls); } /// See also `clone` (from the arch-specific include) @@ -771,12 +771,12 @@ pub fn fchmod(fd: i32, mode: mode_t) usize { pub fn chmod(path: [*:0]const u8, mode: mode_t) usize { if (@hasField(SYS, "chmod")) { - return syscall2(.chmod, @ptrToInt(path), mode); + return syscall2(.chmod, @intFromPtr(path), mode); } else { return syscall4( .fchmodat, @bitCast(usize, @as(isize, AT.FDCWD)), - @ptrToInt(path), + @intFromPtr(path), mode, 0, ); @@ -792,7 +792,7 @@ pub fn fchown(fd: i32, owner: uid_t, group: gid_t) usize { } pub fn fchmodat(fd: i32, path: [*:0]const u8, mode: mode_t, flags: u32) usize { - return syscall4(.fchmodat, @bitCast(usize, @as(isize, fd)), @ptrToInt(path), mode, flags); + return syscall4(.fchmodat, @bitCast(usize, @as(isize, fd)), @intFromPtr(path), mode, flags); } /// Can only be called on 32 bit systems. For 64 bit see `lseek`. @@ -804,7 +804,7 @@ pub fn llseek(fd: i32, offset: u64, result: ?*u64, whence: usize) usize { @bitCast(usize, @as(isize, fd)), @truncate(usize, offset >> 32), @truncate(usize, offset), - @ptrToInt(result), + @intFromPtr(result), whence, ); } @@ -874,15 +874,15 @@ pub const LINUX_REBOOT = struct { pub fn reboot(magic: LINUX_REBOOT.MAGIC1, magic2: LINUX_REBOOT.MAGIC2, cmd: LINUX_REBOOT.CMD, arg: ?*const anyopaque) usize { return std.os.linux.syscall4( .reboot, - @enumToInt(magic), - @enumToInt(magic2), - @enumToInt(cmd), - @ptrToInt(arg), + @intFromEnum(magic), + @intFromEnum(magic2), + @intFromEnum(cmd), + @intFromPtr(arg), ); } pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize { - return syscall3(.getrandom, @ptrToInt(buf), count, flags); + return syscall3(.getrandom, @intFromPtr(buf), count, flags); } pub fn kill(pid: pid_t, sig: i32) usize { @@ -901,17 +901,17 @@ pub fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: i32) usize { if (@hasField(SYS, "link")) { return syscall3( .link, - @ptrToInt(oldpath), - @ptrToInt(newpath), + @intFromPtr(oldpath), + @intFromPtr(newpath), @bitCast(usize, @as(isize, flags)), ); } else { return syscall5( .linkat, @bitCast(usize, @as(isize, AT.FDCWD)), - @ptrToInt(oldpath), + @intFromPtr(oldpath), @bitCast(usize, @as(isize, AT.FDCWD)), - @ptrToInt(newpath), + @intFromPtr(newpath), @bitCast(usize, @as(isize, flags)), ); } @@ -921,41 +921,41 @@ pub fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]co return syscall5( .linkat, @bitCast(usize, @as(isize, oldfd)), - @ptrToInt(oldpath), + @intFromPtr(oldpath), @bitCast(usize, @as(isize, newfd)), - @ptrToInt(newpath), + @intFromPtr(newpath), @bitCast(usize, @as(isize, flags)), ); } pub fn unlink(path: [*:0]const u8) usize { if (@hasField(SYS, "unlink")) { - return syscall1(.unlink, @ptrToInt(path)); + return syscall1(.unlink, @intFromPtr(path)); } else { - return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), 0); + return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(path), 0); } } pub fn unlinkat(dirfd: i32, path: [*:0]const u8, flags: u32) usize { - return syscall3(.unlinkat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags); + return syscall3(.unlinkat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), flags); } pub fn waitpid(pid: pid_t, status: *u32, flags: u32) usize { - return syscall4(.wait4, @bitCast(usize, @as(isize, pid)), @ptrToInt(status), flags, 0); + return syscall4(.wait4, @bitCast(usize, @as(isize, pid)), @intFromPtr(status), flags, 0); } pub fn wait4(pid: pid_t, status: *u32, flags: u32, usage: ?*rusage) usize { return syscall4( .wait4, @bitCast(usize, @as(isize, pid)), - @ptrToInt(status), + @intFromPtr(status), flags, - @ptrToInt(usage), + @intFromPtr(usage), ); } pub fn waitid(id_type: P, id: i32, infop: *siginfo_t, flags: u32) usize { - return syscall5(.waitid, @enumToInt(id_type), @bitCast(usize, @as(isize, id)), @ptrToInt(infop), flags, 0); + return syscall5(.waitid, @intFromEnum(id_type), @bitCast(usize, @as(isize, id)), @intFromPtr(infop), flags, 0); } pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) usize { @@ -978,16 +978,16 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize { const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr); const rc = f(clk_id, tp); switch (rc) { - 0, @bitCast(usize, -@as(isize, @enumToInt(E.INVAL))) => return rc, + 0, @bitCast(usize, -@as(isize, @intFromEnum(E.INVAL))) => return rc, else => {}, } } } - return syscall2(.clock_gettime, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp)); + return syscall2(.clock_gettime, @bitCast(usize, @as(isize, clk_id)), @intFromPtr(tp)); } fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize { - const ptr = @intToPtr(?*const anyopaque, vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM)); + const ptr = @ptrFromInt(?*const anyopaque, vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM)); // Note that we may not have a VDSO at all, update the stub address anyway // so that clock_gettime will fall back on the good old (and slow) syscall @atomicStore(?*const anyopaque, &vdso_clock_gettime, ptr, .Monotonic); @@ -996,27 +996,27 @@ fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize { const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr); return f(clk, ts); } - return @bitCast(usize, -@as(isize, @enumToInt(E.NOSYS))); + return @bitCast(usize, -@as(isize, @intFromEnum(E.NOSYS))); } pub fn clock_getres(clk_id: i32, tp: *timespec) usize { - return syscall2(.clock_getres, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp)); + return syscall2(.clock_getres, @bitCast(usize, @as(isize, clk_id)), @intFromPtr(tp)); } pub fn clock_settime(clk_id: i32, tp: *const timespec) usize { - return syscall2(.clock_settime, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp)); + return syscall2(.clock_settime, @bitCast(usize, @as(isize, clk_id)), @intFromPtr(tp)); } pub fn gettimeofday(tv: *timeval, tz: *timezone) usize { - return syscall2(.gettimeofday, @ptrToInt(tv), @ptrToInt(tz)); + return syscall2(.gettimeofday, @intFromPtr(tv), @intFromPtr(tz)); } pub fn settimeofday(tv: *const timeval, tz: *const timezone) usize { - return syscall2(.settimeofday, @ptrToInt(tv), @ptrToInt(tz)); + return syscall2(.settimeofday, @intFromPtr(tv), @intFromPtr(tz)); } pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize { - return syscall2(.nanosleep, @ptrToInt(req), @ptrToInt(rem)); + return syscall2(.nanosleep, @intFromPtr(req), @intFromPtr(rem)); } pub fn setuid(uid: uid_t) usize { @@ -1107,17 +1107,17 @@ pub fn setegid(egid: gid_t) usize { pub fn getresuid(ruid: *uid_t, euid: *uid_t, suid: *uid_t) usize { if (@hasField(SYS, "getresuid32")) { - return syscall3(.getresuid32, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid)); + return syscall3(.getresuid32, @intFromPtr(ruid), @intFromPtr(euid), @intFromPtr(suid)); } else { - return syscall3(.getresuid, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid)); + return syscall3(.getresuid, @intFromPtr(ruid), @intFromPtr(euid), @intFromPtr(suid)); } } pub fn getresgid(rgid: *gid_t, egid: *gid_t, sgid: *gid_t) usize { if (@hasField(SYS, "getresgid32")) { - return syscall3(.getresgid32, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid)); + return syscall3(.getresgid32, @intFromPtr(rgid), @intFromPtr(egid), @intFromPtr(sgid)); } else { - return syscall3(.getresgid, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid)); + return syscall3(.getresgid, @intFromPtr(rgid), @intFromPtr(egid), @intFromPtr(sgid)); } } @@ -1139,17 +1139,17 @@ pub fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) usize { pub fn getgroups(size: usize, list: *gid_t) usize { if (@hasField(SYS, "getgroups32")) { - return syscall2(.getgroups32, size, @ptrToInt(list)); + return syscall2(.getgroups32, size, @intFromPtr(list)); } else { - return syscall2(.getgroups, size, @ptrToInt(list)); + return syscall2(.getgroups, size, @intFromPtr(list)); } } pub fn setgroups(size: usize, list: [*]const gid_t) usize { if (@hasField(SYS, "setgroups32")) { - return syscall2(.setgroups32, size, @ptrToInt(list)); + return syscall2(.setgroups32, size, @intFromPtr(list)); } else { - return syscall2(.setgroups, size, @ptrToInt(list)); + return syscall2(.setgroups, size, @intFromPtr(list)); } } @@ -1162,7 +1162,7 @@ pub fn gettid() pid_t { } pub fn sigprocmask(flags: u32, noalias set: ?*const sigset_t, noalias oldset: ?*sigset_t) usize { - return syscall4(.rt_sigprocmask, flags, @ptrToInt(set), @ptrToInt(oldset), NSIG / 8); + return syscall4(.rt_sigprocmask, flags, @intFromPtr(set), @intFromPtr(oldset), NSIG / 8); } pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) usize { @@ -1187,12 +1187,12 @@ pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigact @memcpy(@ptrCast([*]u8, &ksa.mask)[0..mask_size], @ptrCast([*]const u8, &new.mask)); } - const ksa_arg = if (act != null) @ptrToInt(&ksa) else 0; - const oldksa_arg = if (oact != null) @ptrToInt(&oldksa) else 0; + const ksa_arg = if (act != null) @intFromPtr(&ksa) else 0; + const oldksa_arg = if (oact != null) @intFromPtr(&oldksa) else 0; const result = switch (native_arch) { // The sparc version of rt_sigaction needs the restorer function to be passed as an argument too. - .sparc, .sparc64 => syscall5(.rt_sigaction, sig, ksa_arg, oldksa_arg, @ptrToInt(ksa.restorer), mask_size), + .sparc, .sparc64 => syscall5(.rt_sigaction, sig, ksa_arg, oldksa_arg, @intFromPtr(ksa.restorer), mask_size), else => syscall4(.rt_sigaction, sig, ksa_arg, oldksa_arg, mask_size), }; if (getErrno(result) != .SUCCESS) return result; @@ -1223,16 +1223,16 @@ pub fn sigismember(set: *const sigset_t, sig: u6) bool { pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize { if (native_arch == .x86) { - return socketcall(SC.getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) }); + return socketcall(SC.getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intFromPtr(len) }); } - return syscall3(.getsockname, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len)); + return syscall3(.getsockname, @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intFromPtr(len)); } pub fn getpeername(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize { if (native_arch == .x86) { - return socketcall(SC.getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) }); + return socketcall(SC.getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intFromPtr(len) }); } - return syscall3(.getpeername, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len)); + return syscall3(.getpeername, @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intFromPtr(len)); } pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize { @@ -1244,21 +1244,21 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize { pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize { if (native_arch == .x86) { - return socketcall(SC.setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen) }); + return socketcall(SC.setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @intFromPtr(optval), @intCast(usize, optlen) }); } - return syscall5(.setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen)); + return syscall5(.setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @intFromPtr(optval), @intCast(usize, optlen)); } pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize { if (native_arch == .x86) { - return socketcall(SC.getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen) }); + return socketcall(SC.getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @intFromPtr(optval), @intFromPtr(optlen) }); } - return syscall5(.getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen)); + return syscall5(.getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @intFromPtr(optval), @intFromPtr(optlen)); } pub fn sendmsg(fd: i32, msg: *const msghdr_const, flags: u32) usize { const fd_usize = @bitCast(usize, @as(isize, fd)); - const msg_usize = @ptrToInt(msg); + const msg_usize = @intFromPtr(msg); if (native_arch == .x86) { return socketcall(SC.sendmsg, &[3]usize{ fd_usize, msg_usize, flags }); } else { @@ -1281,7 +1281,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize // batch-send all messages up to the current message if (next_unsent < i) { const batch_size = i - next_unsent; - const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(&msgvec[next_unsent]), batch_size, flags); + const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @intFromPtr(&msgvec[next_unsent]), batch_size, flags); if (getErrno(r) != 0) return next_unsent; if (r < batch_size) return next_unsent + r; } @@ -1297,18 +1297,18 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize } if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG.EOR) const batch_size = kvlen - next_unsent; - const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(&msgvec[next_unsent]), batch_size, flags); + const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @intFromPtr(&msgvec[next_unsent]), batch_size, flags); if (getErrno(r) != 0) return r; return next_unsent + r; } return kvlen; } - return syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msgvec), vlen, flags); + return syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @intFromPtr(msgvec), vlen, flags); } pub fn connect(fd: i32, addr: *const anyopaque, len: socklen_t) usize { const fd_usize = @bitCast(usize, @as(isize, fd)); - const addr_usize = @ptrToInt(addr); + const addr_usize = @intFromPtr(addr); if (native_arch == .x86) { return socketcall(SC.connect, &[3]usize{ fd_usize, addr_usize, len }); } else { @@ -1318,7 +1318,7 @@ pub fn connect(fd: i32, addr: *const anyopaque, len: socklen_t) usize { pub fn recvmsg(fd: i32, msg: *msghdr, flags: u32) usize { const fd_usize = @bitCast(usize, @as(isize, fd)); - const msg_usize = @ptrToInt(msg); + const msg_usize = @intFromPtr(msg); if (native_arch == .x86) { return socketcall(SC.recvmsg, &[3]usize{ fd_usize, msg_usize, flags }); } else { @@ -1335,9 +1335,9 @@ pub fn recvfrom( noalias alen: ?*socklen_t, ) usize { const fd_usize = @bitCast(usize, @as(isize, fd)); - const buf_usize = @ptrToInt(buf); - const addr_usize = @ptrToInt(addr); - const alen_usize = @ptrToInt(alen); + const buf_usize = @intFromPtr(buf); + const addr_usize = @intFromPtr(addr); + const alen_usize = @intFromPtr(alen); if (native_arch == .x86) { return socketcall(SC.recvfrom, &[6]usize{ fd_usize, buf_usize, len, flags, addr_usize, alen_usize }); } else { @@ -1354,9 +1354,9 @@ pub fn shutdown(fd: i32, how: i32) usize { pub fn bind(fd: i32, addr: *const sockaddr, len: socklen_t) usize { if (native_arch == .x86) { - return socketcall(SC.bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len) }); + return socketcall(SC.bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intCast(usize, len) }); } - return syscall3(.bind, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len)); + return syscall3(.bind, @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intCast(usize, len)); } pub fn listen(fd: i32, backlog: u32) usize { @@ -1368,9 +1368,9 @@ pub fn listen(fd: i32, backlog: u32) usize { pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize { if (native_arch == .x86) { - return socketcall(SC.sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen) }); + return socketcall(SC.sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @intFromPtr(buf), len, flags, @intFromPtr(addr), @intCast(usize, alen) }); } - return syscall6(.sendto, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen)); + return syscall6(.sendto, @bitCast(usize, @as(isize, fd)), @intFromPtr(buf), len, flags, @intFromPtr(addr), @intCast(usize, alen)); } pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize { @@ -1379,7 +1379,7 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize { .sendfile64, @bitCast(usize, @as(isize, outfd)), @bitCast(usize, @as(isize, infd)), - @ptrToInt(offset), + @intFromPtr(offset), count, ); } else { @@ -1387,7 +1387,7 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize { .sendfile, @bitCast(usize, @as(isize, outfd)), @bitCast(usize, @as(isize, infd)), - @ptrToInt(offset), + @intFromPtr(offset), count, ); } @@ -1395,9 +1395,9 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize { pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: *[2]i32) usize { if (native_arch == .x86) { - return socketcall(SC.socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(fd) }); + return socketcall(SC.socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @intFromPtr(fd) }); } - return syscall4(.socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(fd)); + return syscall4(.socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @intFromPtr(fd)); } pub fn accept(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize { @@ -1409,40 +1409,40 @@ pub fn accept(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flags: u32) usize { if (native_arch == .x86) { - return socketcall(SC.accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags }); + return socketcall(SC.accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intFromPtr(len), flags }); } - return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags); + return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intFromPtr(len), flags); } pub fn fstat(fd: i32, stat_buf: *Stat) usize { if (@hasField(SYS, "fstat64")) { - return syscall2(.fstat64, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf)); + return syscall2(.fstat64, @bitCast(usize, @as(isize, fd)), @intFromPtr(stat_buf)); } else { - return syscall2(.fstat, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf)); + return syscall2(.fstat, @bitCast(usize, @as(isize, fd)), @intFromPtr(stat_buf)); } } pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize { if (@hasField(SYS, "stat64")) { - return syscall2(.stat64, @ptrToInt(pathname), @ptrToInt(statbuf)); + return syscall2(.stat64, @intFromPtr(pathname), @intFromPtr(statbuf)); } else { - return syscall2(.stat, @ptrToInt(pathname), @ptrToInt(statbuf)); + return syscall2(.stat, @intFromPtr(pathname), @intFromPtr(statbuf)); } } pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize { if (@hasField(SYS, "lstat64")) { - return syscall2(.lstat64, @ptrToInt(pathname), @ptrToInt(statbuf)); + return syscall2(.lstat64, @intFromPtr(pathname), @intFromPtr(statbuf)); } else { - return syscall2(.lstat, @ptrToInt(pathname), @ptrToInt(statbuf)); + return syscall2(.lstat, @intFromPtr(pathname), @intFromPtr(statbuf)); } } pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize { if (@hasField(SYS, "fstatat64")) { - return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags); + return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), @intFromPtr(stat_buf), flags); } else { - return syscall4(.fstatat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags); + return syscall4(.fstatat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), @intFromPtr(stat_buf), flags); } } @@ -1451,61 +1451,61 @@ pub fn statx(dirfd: i32, path: [*]const u8, flags: u32, mask: u32, statx_buf: *S return syscall5( .statx, @bitCast(usize, @as(isize, dirfd)), - @ptrToInt(path), + @intFromPtr(path), flags, mask, - @ptrToInt(statx_buf), + @intFromPtr(statx_buf), ); } - return @bitCast(usize, -@as(isize, @enumToInt(E.NOSYS))); + return @bitCast(usize, -@as(isize, @intFromEnum(E.NOSYS))); } pub fn listxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize { - return syscall3(.listxattr, @ptrToInt(path), @ptrToInt(list), size); + return syscall3(.listxattr, @intFromPtr(path), @intFromPtr(list), size); } pub fn llistxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize { - return syscall3(.llistxattr, @ptrToInt(path), @ptrToInt(list), size); + return syscall3(.llistxattr, @intFromPtr(path), @intFromPtr(list), size); } pub fn flistxattr(fd: usize, list: [*]u8, size: usize) usize { - return syscall3(.flistxattr, fd, @ptrToInt(list), size); + return syscall3(.flistxattr, fd, @intFromPtr(list), size); } pub fn getxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize { - return syscall4(.getxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size); + return syscall4(.getxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size); } pub fn lgetxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize { - return syscall4(.lgetxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size); + return syscall4(.lgetxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size); } pub fn fgetxattr(fd: usize, name: [*:0]const u8, value: [*]u8, size: usize) usize { - return syscall4(.lgetxattr, fd, @ptrToInt(name), @ptrToInt(value), size); + return syscall4(.lgetxattr, fd, @intFromPtr(name), @intFromPtr(value), size); } pub fn setxattr(path: [*:0]const u8, name: [*:0]const u8, value: *const void, size: usize, flags: usize) usize { - return syscall5(.setxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size, flags); + return syscall5(.setxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size, flags); } pub fn lsetxattr(path: [*:0]const u8, name: [*:0]const u8, value: *const void, size: usize, flags: usize) usize { - return syscall5(.lsetxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size, flags); + return syscall5(.lsetxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size, flags); } pub fn fsetxattr(fd: usize, name: [*:0]const u8, value: *const void, size: usize, flags: usize) usize { - return syscall5(.fsetxattr, fd, @ptrToInt(name), @ptrToInt(value), size, flags); + return syscall5(.fsetxattr, fd, @intFromPtr(name), @intFromPtr(value), size, flags); } pub fn removexattr(path: [*:0]const u8, name: [*:0]const u8) usize { - return syscall2(.removexattr, @ptrToInt(path), @ptrToInt(name)); + return syscall2(.removexattr, @intFromPtr(path), @intFromPtr(name)); } pub fn lremovexattr(path: [*:0]const u8, name: [*:0]const u8) usize { - return syscall2(.lremovexattr, @ptrToInt(path), @ptrToInt(name)); + return syscall2(.lremovexattr, @intFromPtr(path), @intFromPtr(name)); } pub fn fremovexattr(fd: usize, name: [*:0]const u8) usize { - return syscall2(.fremovexattr, fd, @ptrToInt(name)); + return syscall2(.fremovexattr, fd, @intFromPtr(name)); } pub fn sched_yield() usize { @@ -1513,30 +1513,30 @@ pub fn sched_yield() usize { } pub fn sched_getaffinity(pid: pid_t, size: usize, set: *cpu_set_t) usize { - const rc = syscall3(.sched_getaffinity, @bitCast(usize, @as(isize, pid)), size, @ptrToInt(set)); + const rc = syscall3(.sched_getaffinity, @bitCast(usize, @as(isize, pid)), size, @intFromPtr(set)); if (@bitCast(isize, rc) < 0) return rc; if (rc < size) @memset(@ptrCast([*]u8, set)[rc..size], 0); return 0; } pub fn getcpu(cpu: *u32, node: *u32) usize { - return syscall3(.getcpu, @ptrToInt(cpu), @ptrToInt(node), 0); + return syscall3(.getcpu, @intFromPtr(cpu), @intFromPtr(node), 0); } pub fn sched_getcpu() usize { var cpu: u32 = undefined; - const rc = syscall3(.getcpu, @ptrToInt(&cpu), 0, 0); + const rc = syscall3(.getcpu, @intFromPtr(&cpu), 0, 0); if (@bitCast(isize, rc) < 0) return rc; return @intCast(usize, cpu); } /// libc has no wrapper for this syscall pub fn mbind(addr: ?*anyopaque, len: u32, mode: i32, nodemask: *const u32, maxnode: u32, flags: u32) usize { - return syscall6(.mbind, @ptrToInt(addr), len, @bitCast(usize, @as(isize, mode)), @ptrToInt(nodemask), maxnode, flags); + return syscall6(.mbind, @intFromPtr(addr), len, @bitCast(usize, @as(isize, mode)), @intFromPtr(nodemask), maxnode, flags); } pub fn sched_setaffinity(pid: pid_t, size: usize, set: *const cpu_set_t) usize { - const rc = syscall3(.sched_setaffinity, @bitCast(usize, @as(isize, pid)), size, @ptrToInt(set)); + const rc = syscall3(.sched_setaffinity, @bitCast(usize, @as(isize, pid)), size, @intFromPtr(set)); if (@bitCast(isize, rc) < 0) return rc; return 0; } @@ -1550,7 +1550,7 @@ pub fn epoll_create1(flags: usize) usize { } pub fn epoll_ctl(epoll_fd: i32, op: u32, fd: i32, ev: ?*epoll_event) usize { - return syscall4(.epoll_ctl, @bitCast(usize, @as(isize, epoll_fd)), @intCast(usize, op), @bitCast(usize, @as(isize, fd)), @ptrToInt(ev)); + return syscall4(.epoll_ctl, @bitCast(usize, @as(isize, epoll_fd)), @intCast(usize, op), @bitCast(usize, @as(isize, fd)), @intFromPtr(ev)); } pub fn epoll_wait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32) usize { @@ -1561,10 +1561,10 @@ pub fn epoll_pwait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeou return syscall6( .epoll_pwait, @bitCast(usize, @as(isize, epoll_fd)), - @ptrToInt(events), + @intFromPtr(events), @intCast(usize, maxevents), @bitCast(usize, @as(isize, timeout)), - @ptrToInt(sigmask), + @intFromPtr(sigmask), @sizeOf(sigset_t), ); } @@ -1583,11 +1583,11 @@ pub const itimerspec = extern struct { }; pub fn timerfd_gettime(fd: i32, curr_value: *itimerspec) usize { - return syscall2(.timerfd_gettime, @bitCast(usize, @as(isize, fd)), @ptrToInt(curr_value)); + return syscall2(.timerfd_gettime, @bitCast(usize, @as(isize, fd)), @intFromPtr(curr_value)); } pub fn timerfd_settime(fd: i32, flags: u32, new_value: *const itimerspec, old_value: ?*itimerspec) usize { - return syscall4(.timerfd_settime, @bitCast(usize, @as(isize, fd)), flags, @ptrToInt(new_value), @ptrToInt(old_value)); + return syscall4(.timerfd_settime, @bitCast(usize, @as(isize, fd)), flags, @intFromPtr(new_value), @intFromPtr(old_value)); } pub const sigevent = extern struct { @@ -1609,7 +1609,7 @@ pub const timer_t = ?*anyopaque; pub fn timer_create(clockid: i32, sevp: *sigevent, timerid: *timer_t) usize { var t: timer_t = undefined; - const rc = syscall3(.timer_create, @bitCast(usize, @as(isize, clockid)), @ptrToInt(sevp), @ptrToInt(&t)); + const rc = syscall3(.timer_create, @bitCast(usize, @as(isize, clockid)), @intFromPtr(sevp), @intFromPtr(&t)); if (@bitCast(isize, rc) < 0) return rc; timerid.* = t; return rc; @@ -1620,11 +1620,11 @@ pub fn timer_delete(timerid: timer_t) usize { } pub fn timer_gettime(timerid: timer_t, curr_value: *itimerspec) usize { - return syscall2(.timer_gettime, @ptrToInt(timerid), @ptrToInt(curr_value)); + return syscall2(.timer_gettime, @intFromPtr(timerid), @intFromPtr(curr_value)); } pub fn timer_settime(timerid: timer_t, flags: i32, new_value: *const itimerspec, old_value: ?*itimerspec) usize { - return syscall4(.timer_settime, @ptrToInt(timerid), @bitCast(usize, @as(isize, flags)), @ptrToInt(new_value), @ptrToInt(old_value)); + return syscall4(.timer_settime, @intFromPtr(timerid), @bitCast(usize, @as(isize, flags)), @intFromPtr(new_value), @intFromPtr(old_value)); } // Flags for the 'setitimer' system call @@ -1635,11 +1635,11 @@ pub const ITIMER = enum(i32) { }; pub fn getitimer(which: i32, curr_value: *itimerspec) usize { - return syscall2(.getitimer, @bitCast(usize, @as(isize, which)), @ptrToInt(curr_value)); + return syscall2(.getitimer, @bitCast(usize, @as(isize, which)), @intFromPtr(curr_value)); } pub fn setitimer(which: i32, new_value: *const itimerspec, old_value: ?*itimerspec) usize { - return syscall3(.setitimer, @bitCast(usize, @as(isize, which)), @ptrToInt(new_value), @ptrToInt(old_value)); + return syscall3(.setitimer, @bitCast(usize, @as(isize, which)), @intFromPtr(new_value), @intFromPtr(old_value)); } pub fn unshare(flags: usize) usize { @@ -1647,55 +1647,55 @@ pub fn unshare(flags: usize) usize { } pub fn capget(hdrp: *cap_user_header_t, datap: *cap_user_data_t) usize { - return syscall2(.capget, @ptrToInt(hdrp), @ptrToInt(datap)); + return syscall2(.capget, @intFromPtr(hdrp), @intFromPtr(datap)); } pub fn capset(hdrp: *cap_user_header_t, datap: *const cap_user_data_t) usize { - return syscall2(.capset, @ptrToInt(hdrp), @ptrToInt(datap)); + return syscall2(.capset, @intFromPtr(hdrp), @intFromPtr(datap)); } pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) usize { - return syscall2(.sigaltstack, @ptrToInt(ss), @ptrToInt(old_ss)); + return syscall2(.sigaltstack, @intFromPtr(ss), @intFromPtr(old_ss)); } pub fn uname(uts: *utsname) usize { - return syscall1(.uname, @ptrToInt(uts)); + return syscall1(.uname, @intFromPtr(uts)); } pub fn io_uring_setup(entries: u32, p: *io_uring_params) usize { - return syscall2(.io_uring_setup, entries, @ptrToInt(p)); + return syscall2(.io_uring_setup, entries, @intFromPtr(p)); } pub fn io_uring_enter(fd: i32, to_submit: u32, min_complete: u32, flags: u32, sig: ?*sigset_t) usize { - return syscall6(.io_uring_enter, @bitCast(usize, @as(isize, fd)), to_submit, min_complete, flags, @ptrToInt(sig), NSIG / 8); + return syscall6(.io_uring_enter, @bitCast(usize, @as(isize, fd)), to_submit, min_complete, flags, @intFromPtr(sig), NSIG / 8); } pub fn io_uring_register(fd: i32, opcode: IORING_REGISTER, arg: ?*const anyopaque, nr_args: u32) usize { - return syscall4(.io_uring_register, @bitCast(usize, @as(isize, fd)), @enumToInt(opcode), @ptrToInt(arg), nr_args); + return syscall4(.io_uring_register, @bitCast(usize, @as(isize, fd)), @intFromEnum(opcode), @intFromPtr(arg), nr_args); } pub fn memfd_create(name: [*:0]const u8, flags: u32) usize { - return syscall2(.memfd_create, @ptrToInt(name), flags); + return syscall2(.memfd_create, @intFromPtr(name), flags); } pub fn getrusage(who: i32, usage: *rusage) usize { - return syscall2(.getrusage, @bitCast(usize, @as(isize, who)), @ptrToInt(usage)); + return syscall2(.getrusage, @bitCast(usize, @as(isize, who)), @intFromPtr(usage)); } pub fn tcgetattr(fd: fd_t, termios_p: *termios) usize { - return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CGETS, @ptrToInt(termios_p)); + return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CGETS, @intFromPtr(termios_p)); } pub fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) usize { - return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CSETS + @enumToInt(optional_action), @ptrToInt(termios_p)); + return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CSETS + @intFromEnum(optional_action), @intFromPtr(termios_p)); } pub fn tcgetpgrp(fd: fd_t, pgrp: *pid_t) usize { - return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.IOCGPGRP, @ptrToInt(pgrp)); + return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.IOCGPGRP, @intFromPtr(pgrp)); } pub fn tcsetpgrp(fd: fd_t, pgrp: *const pid_t) usize { - return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.IOCSPGRP, @ptrToInt(pgrp)); + return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.IOCSPGRP, @intFromPtr(pgrp)); } pub fn tcdrain(fd: fd_t) usize { @@ -1707,23 +1707,23 @@ pub fn ioctl(fd: fd_t, request: u32, arg: usize) usize { } pub fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) usize { - return syscall4(.signalfd4, @bitCast(usize, @as(isize, fd)), @ptrToInt(mask), NSIG / 8, flags); + return syscall4(.signalfd4, @bitCast(usize, @as(isize, fd)), @intFromPtr(mask), NSIG / 8, flags); } pub fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: u32) usize { return syscall6( .copy_file_range, @bitCast(usize, @as(isize, fd_in)), - @ptrToInt(off_in), + @intFromPtr(off_in), @bitCast(usize, @as(isize, fd_out)), - @ptrToInt(off_out), + @intFromPtr(off_out), len, flags, ); } pub fn bpf(cmd: BPF.Cmd, attr: *BPF.Attr, size: u32) usize { - return syscall3(.bpf, @enumToInt(cmd), @ptrToInt(attr), size); + return syscall3(.bpf, @intFromEnum(cmd), @intFromPtr(attr), size); } pub fn sync() void { @@ -1760,18 +1760,18 @@ pub fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: ?*const rlimit, return syscall4( .prlimit64, @bitCast(usize, @as(isize, pid)), - @bitCast(usize, @as(isize, @enumToInt(resource))), - @ptrToInt(new_limit), - @ptrToInt(old_limit), + @bitCast(usize, @as(isize, @intFromEnum(resource))), + @intFromPtr(new_limit), + @intFromPtr(old_limit), ); } pub fn mincore(address: [*]u8, len: usize, vec: [*]u8) usize { - return syscall3(.mincore, @ptrToInt(address), len, @ptrToInt(vec)); + return syscall3(.mincore, @intFromPtr(address), len, @intFromPtr(vec)); } pub fn madvise(address: [*]u8, len: usize, advice: u32) usize { - return syscall3(.madvise, @ptrToInt(address), len, advice); + return syscall3(.madvise, @intFromPtr(address), len, advice); } pub fn pidfd_open(pid: pid_t, flags: u32) usize { @@ -1792,7 +1792,7 @@ pub fn pidfd_send_signal(pidfd: fd_t, sig: i32, info: ?*siginfo_t, flags: u32) u .pidfd_send_signal, @bitCast(usize, @as(isize, pidfd)), @bitCast(usize, @as(isize, sig)), - @ptrToInt(info), + @intFromPtr(info), flags, ); } @@ -1801,9 +1801,9 @@ pub fn process_vm_readv(pid: pid_t, local: []iovec, remote: []const iovec_const, return syscall6( .process_vm_readv, @bitCast(usize, @as(isize, pid)), - @ptrToInt(local.ptr), + @intFromPtr(local.ptr), local.len, - @ptrToInt(remote.ptr), + @intFromPtr(remote.ptr), remote.len, flags, ); @@ -1813,9 +1813,9 @@ pub fn process_vm_writev(pid: pid_t, local: []const iovec_const, remote: []const return syscall6( .process_vm_writev, @bitCast(usize, @as(isize, pid)), - @ptrToInt(local.ptr), + @intFromPtr(local.ptr), local.len, - @ptrToInt(remote.ptr), + @intFromPtr(remote.ptr), remote.len, flags, ); @@ -1889,7 +1889,7 @@ pub fn perf_event_open( ) usize { return syscall5( .perf_event_open, - @ptrToInt(attr), + @intFromPtr(attr), @bitCast(usize, @as(isize, pid)), @bitCast(usize, @as(isize, cpu)), @bitCast(usize, @as(isize, group_fd)), @@ -1898,7 +1898,7 @@ pub fn perf_event_open( } pub fn seccomp(operation: u32, flags: u32, args: ?*const anyopaque) usize { - return syscall3(.seccomp, operation, flags, @ptrToInt(args)); + return syscall3(.seccomp, operation, flags, @intFromPtr(args)); } pub fn ptrace( @@ -2154,9 +2154,9 @@ pub const SIG = if (is_mips) struct { pub const SYS = 31; pub const UNUSED = SIG.SYS; - pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize)); - pub const DFL = @intToPtr(?Sigaction.handler_fn, 0); - pub const IGN = @intToPtr(?Sigaction.handler_fn, 1); + pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); + pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); + pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); } else if (is_sparc) struct { pub const BLOCK = 1; pub const UNBLOCK = 2; @@ -2198,9 +2198,9 @@ pub const SIG = if (is_mips) struct { pub const PWR = LOST; pub const IO = SIG.POLL; - pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize)); - pub const DFL = @intToPtr(?Sigaction.handler_fn, 0); - pub const IGN = @intToPtr(?Sigaction.handler_fn, 1); + pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); + pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); + pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); } else struct { pub const BLOCK = 0; pub const UNBLOCK = 1; @@ -2241,9 +2241,9 @@ pub const SIG = if (is_mips) struct { pub const SYS = 31; pub const UNUSED = SIG.SYS; - pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize)); - pub const DFL = @intToPtr(?Sigaction.handler_fn, 0); - pub const IGN = @intToPtr(?Sigaction.handler_fn, 1); + pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); + pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); + pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); }; pub const kernel_rwf = u32; @@ -3876,26 +3876,26 @@ pub const IOSQE_BIT = enum(u8) { // io_uring_sqe.flags /// use fixed fileset -pub const IOSQE_FIXED_FILE = 1 << @enumToInt(IOSQE_BIT.FIXED_FILE); +pub const IOSQE_FIXED_FILE = 1 << @intFromEnum(IOSQE_BIT.FIXED_FILE); /// issue after inflight IO -pub const IOSQE_IO_DRAIN = 1 << @enumToInt(IOSQE_BIT.IO_DRAIN); +pub const IOSQE_IO_DRAIN = 1 << @intFromEnum(IOSQE_BIT.IO_DRAIN); /// links next sqe -pub const IOSQE_IO_LINK = 1 << @enumToInt(IOSQE_BIT.IO_LINK); +pub const IOSQE_IO_LINK = 1 << @intFromEnum(IOSQE_BIT.IO_LINK); /// like LINK, but stronger -pub const IOSQE_IO_HARDLINK = 1 << @enumToInt(IOSQE_BIT.IO_HARDLINK); +pub const IOSQE_IO_HARDLINK = 1 << @intFromEnum(IOSQE_BIT.IO_HARDLINK); /// always go async -pub const IOSQE_ASYNC = 1 << @enumToInt(IOSQE_BIT.ASYNC); +pub const IOSQE_ASYNC = 1 << @intFromEnum(IOSQE_BIT.ASYNC); /// select buffer from buf_group -pub const IOSQE_BUFFER_SELECT = 1 << @enumToInt(IOSQE_BIT.BUFFER_SELECT); +pub const IOSQE_BUFFER_SELECT = 1 << @intFromEnum(IOSQE_BIT.BUFFER_SELECT); /// don't post CQE if request succeeded /// Available since Linux 5.17 -pub const IOSQE_CQE_SKIP_SUCCESS = 1 << @enumToInt(IOSQE_BIT.CQE_SKIP_SUCCESS); +pub const IOSQE_CQE_SKIP_SUCCESS = 1 << @intFromEnum(IOSQE_BIT.CQE_SKIP_SUCCESS); pub const IORING_OP = enum(u8) { NOP, @@ -3999,7 +3999,7 @@ pub const io_uring_cqe = extern struct { pub fn err(self: io_uring_cqe) E { if (self.res > -4096 and self.res < 0) { - return @intToEnum(E, -self.res); + return @enumFromInt(E, -self.res); } return .SUCCESS; } @@ -5827,7 +5827,7 @@ pub const AUDIT = struct { ARM = toAudit(.arm), ARMEB = toAudit(.armeb), CSKY = toAudit(.csky), - HEXAGON = @enumToInt(std.elf.EM.HEXAGON), + HEXAGON = @intFromEnum(std.elf.EM.HEXAGON), X86 = toAudit(.x86), M68K = toAudit(.m68k), MIPS = toAudit(.mips), @@ -5845,7 +5845,7 @@ pub const AUDIT = struct { X86_64 = toAudit(.x86_64), fn toAudit(arch: std.Target.Cpu.Arch) u32 { - var res: u32 = @enumToInt(arch.toElfMachine()); + var res: u32 = @intFromEnum(arch.toElfMachine()); if (arch.endian() == .Little) res |= LE; switch (arch) { .aarch64, diff --git a/lib/std/os/linux/arm-eabi.zig b/lib/std/os/linux/arm-eabi.zig index 92d0fcfb440b..057ecc763adc 100644 --- a/lib/std/os/linux/arm-eabi.zig +++ b/lib/std/os/linux/arm-eabi.zig @@ -16,7 +16,7 @@ const timespec = linux.timespec; pub fn syscall0(number: SYS) usize { return asm volatile ("svc #0" : [ret] "={r0}" (-> usize), - : [number] "{r7}" (@enumToInt(number)), + : [number] "{r7}" (@intFromEnum(number)), : "memory" ); } @@ -24,7 +24,7 @@ pub fn syscall0(number: SYS) usize { pub fn syscall1(number: SYS, arg1: usize) usize { return asm volatile ("svc #0" : [ret] "={r0}" (-> usize), - : [number] "{r7}" (@enumToInt(number)), + : [number] "{r7}" (@intFromEnum(number)), [arg1] "{r0}" (arg1), : "memory" ); @@ -33,7 +33,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { return asm volatile ("svc #0" : [ret] "={r0}" (-> usize), - : [number] "{r7}" (@enumToInt(number)), + : [number] "{r7}" (@intFromEnum(number)), [arg1] "{r0}" (arg1), [arg2] "{r1}" (arg2), : "memory" @@ -43,7 +43,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { return asm volatile ("svc #0" : [ret] "={r0}" (-> usize), - : [number] "{r7}" (@enumToInt(number)), + : [number] "{r7}" (@intFromEnum(number)), [arg1] "{r0}" (arg1), [arg2] "{r1}" (arg2), [arg3] "{r2}" (arg3), @@ -54,7 +54,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { return asm volatile ("svc #0" : [ret] "={r0}" (-> usize), - : [number] "{r7}" (@enumToInt(number)), + : [number] "{r7}" (@intFromEnum(number)), [arg1] "{r0}" (arg1), [arg2] "{r1}" (arg2), [arg3] "{r2}" (arg3), @@ -66,7 +66,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { return asm volatile ("svc #0" : [ret] "={r0}" (-> usize), - : [number] "{r7}" (@enumToInt(number)), + : [number] "{r7}" (@intFromEnum(number)), [arg1] "{r0}" (arg1), [arg2] "{r1}" (arg2), [arg3] "{r2}" (arg3), @@ -87,7 +87,7 @@ pub fn syscall6( ) usize { return asm volatile ("svc #0" : [ret] "={r0}" (-> usize), - : [number] "{r7}" (@enumToInt(number)), + : [number] "{r7}" (@intFromEnum(number)), [arg1] "{r0}" (arg1), [arg2] "{r1}" (arg2), [arg3] "{r2}" (arg3), @@ -106,7 +106,7 @@ pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: * pub fn restore() callconv(.Naked) void { return asm volatile ("svc #0" : - : [number] "{r7}" (@enumToInt(SYS.sigreturn)), + : [number] "{r7}" (@intFromEnum(SYS.sigreturn)), : "memory" ); } @@ -114,7 +114,7 @@ pub fn restore() callconv(.Naked) void { pub fn restore_rt() callconv(.Naked) void { return asm volatile ("svc #0" : - : [number] "{r7}" (@enumToInt(SYS.rt_sigreturn)), + : [number] "{r7}" (@intFromEnum(SYS.rt_sigreturn)), : "memory" ); } diff --git a/lib/std/os/linux/arm64.zig b/lib/std/os/linux/arm64.zig index 9f9196079150..0824a9e9a4c7 100644 --- a/lib/std/os/linux/arm64.zig +++ b/lib/std/os/linux/arm64.zig @@ -16,7 +16,7 @@ const timespec = std.os.linux.timespec; pub fn syscall0(number: SYS) usize { return asm volatile ("svc #0" : [ret] "={x0}" (-> usize), - : [number] "{x8}" (@enumToInt(number)), + : [number] "{x8}" (@intFromEnum(number)), : "memory", "cc" ); } @@ -24,7 +24,7 @@ pub fn syscall0(number: SYS) usize { pub fn syscall1(number: SYS, arg1: usize) usize { return asm volatile ("svc #0" : [ret] "={x0}" (-> usize), - : [number] "{x8}" (@enumToInt(number)), + : [number] "{x8}" (@intFromEnum(number)), [arg1] "{x0}" (arg1), : "memory", "cc" ); @@ -33,7 +33,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { return asm volatile ("svc #0" : [ret] "={x0}" (-> usize), - : [number] "{x8}" (@enumToInt(number)), + : [number] "{x8}" (@intFromEnum(number)), [arg1] "{x0}" (arg1), [arg2] "{x1}" (arg2), : "memory", "cc" @@ -43,7 +43,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { return asm volatile ("svc #0" : [ret] "={x0}" (-> usize), - : [number] "{x8}" (@enumToInt(number)), + : [number] "{x8}" (@intFromEnum(number)), [arg1] "{x0}" (arg1), [arg2] "{x1}" (arg2), [arg3] "{x2}" (arg3), @@ -54,7 +54,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { return asm volatile ("svc #0" : [ret] "={x0}" (-> usize), - : [number] "{x8}" (@enumToInt(number)), + : [number] "{x8}" (@intFromEnum(number)), [arg1] "{x0}" (arg1), [arg2] "{x1}" (arg2), [arg3] "{x2}" (arg3), @@ -66,7 +66,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { return asm volatile ("svc #0" : [ret] "={x0}" (-> usize), - : [number] "{x8}" (@enumToInt(number)), + : [number] "{x8}" (@intFromEnum(number)), [arg1] "{x0}" (arg1), [arg2] "{x1}" (arg2), [arg3] "{x2}" (arg3), @@ -87,7 +87,7 @@ pub fn syscall6( ) usize { return asm volatile ("svc #0" : [ret] "={x0}" (-> usize), - : [number] "{x8}" (@enumToInt(number)), + : [number] "{x8}" (@intFromEnum(number)), [arg1] "{x0}" (arg1), [arg2] "{x1}" (arg2), [arg3] "{x2}" (arg3), @@ -111,12 +111,12 @@ pub fn restore_rt() callconv(.Naked) void { \\ mov x8, %[number] \\ svc #0 : - : [number] "i" (@enumToInt(SYS.rt_sigreturn)), + : [number] "i" (@intFromEnum(SYS.rt_sigreturn)), : "memory", "cc" ), else => return asm volatile ("svc #0" : - : [number] "{x8}" (@enumToInt(SYS.rt_sigreturn)), + : [number] "{x8}" (@intFromEnum(SYS.rt_sigreturn)), : "memory", "cc" ), } diff --git a/lib/std/os/linux/bpf.zig b/lib/std/os/linux/bpf.zig index 9f9e253547eb..87b92587f959 100644 --- a/lib/std/os/linux/bpf.zig +++ b/lib/std/os/linux/bpf.zig @@ -472,10 +472,10 @@ pub const Insn = packed struct { return Insn{ .code = code | src_type, - .dst = @enumToInt(dst), + .dst = @intFromEnum(dst), .src = switch (imm_or_reg) { .imm => 0, - .reg => |r| @enumToInt(r), + .reg => |r| @intFromEnum(r), }, .off = off, .imm = switch (imm_or_reg) { @@ -492,7 +492,7 @@ pub const Insn = packed struct { else => @compileError("width must be 32 or 64"), }; - return imm_reg(width_bitfield | @enumToInt(op), dst, src, 0); + return imm_reg(width_bitfield | @intFromEnum(op), dst, src, 0); } pub fn mov(dst: Reg, src: anytype) Insn { @@ -548,7 +548,7 @@ pub const Insn = packed struct { } pub fn jmp(op: JmpOp, dst: Reg, src: anytype, off: i16) Insn { - return imm_reg(JMP | @enumToInt(op), dst, src, off); + return imm_reg(JMP | @intFromEnum(op), dst, src, off); } pub fn ja(off: i16) Insn { @@ -602,8 +602,8 @@ pub const Insn = packed struct { pub fn xadd(dst: Reg, src: Reg) Insn { return Insn{ .code = STX | XADD | DW, - .dst = @enumToInt(dst), - .src = @enumToInt(src), + .dst = @intFromEnum(dst), + .src = @intFromEnum(src), .off = 0, .imm = 0, }; @@ -611,9 +611,9 @@ pub const Insn = packed struct { fn ld(mode: Mode, size: Size, dst: Reg, src: Reg, imm: i32) Insn { return Insn{ - .code = @enumToInt(mode) | @enumToInt(size) | LD, - .dst = @enumToInt(dst), - .src = @enumToInt(src), + .code = @intFromEnum(mode) | @intFromEnum(size) | LD, + .dst = @intFromEnum(dst), + .src = @intFromEnum(src), .off = 0, .imm = imm, }; @@ -629,9 +629,9 @@ pub const Insn = packed struct { pub fn ldx(size: Size, dst: Reg, src: Reg, off: i16) Insn { return Insn{ - .code = MEM | @enumToInt(size) | LDX, - .dst = @enumToInt(dst), - .src = @enumToInt(src), + .code = MEM | @intFromEnum(size) | LDX, + .dst = @intFromEnum(dst), + .src = @intFromEnum(src), .off = off, .imm = 0, }; @@ -640,8 +640,8 @@ pub const Insn = packed struct { fn ld_imm_impl1(dst: Reg, src: Reg, imm: u64) Insn { return Insn{ .code = LD | DW | IMM, - .dst = @enumToInt(dst), - .src = @enumToInt(src), + .dst = @intFromEnum(dst), + .src = @intFromEnum(src), .off = 0, .imm = @intCast(i32, @truncate(u32, imm)), }; @@ -666,7 +666,7 @@ pub const Insn = packed struct { } pub fn ld_map_fd1(dst: Reg, map_fd: fd_t) Insn { - return ld_imm_impl1(dst, @intToEnum(Reg, PSEUDO_MAP_FD), @intCast(u64, map_fd)); + return ld_imm_impl1(dst, @enumFromInt(Reg, PSEUDO_MAP_FD), @intCast(u64, map_fd)); } pub fn ld_map_fd2(map_fd: fd_t) Insn { @@ -675,8 +675,8 @@ pub const Insn = packed struct { pub fn st(comptime size: Size, dst: Reg, off: i16, imm: i32) Insn { return Insn{ - .code = MEM | @enumToInt(size) | ST, - .dst = @enumToInt(dst), + .code = MEM | @intFromEnum(size) | ST, + .dst = @intFromEnum(dst), .src = 0, .off = off, .imm = imm, @@ -685,9 +685,9 @@ pub const Insn = packed struct { pub fn stx(size: Size, dst: Reg, off: i16, src: Reg) Insn { return Insn{ - .code = MEM | @enumToInt(size) | STX, - .dst = @enumToInt(dst), - .src = @enumToInt(src), + .code = MEM | @intFromEnum(size) | STX, + .dst = @intFromEnum(dst), + .src = @intFromEnum(src), .off = off, .imm = 0, }; @@ -699,7 +699,7 @@ pub const Insn = packed struct { .Big => 0xdc, .Little => 0xd4, }, - .dst = @enumToInt(dst), + .dst = @intFromEnum(dst), .src = 0, .off = 0, .imm = switch (size) { @@ -725,7 +725,7 @@ pub const Insn = packed struct { .dst = 0, .src = 0, .off = 0, - .imm = @enumToInt(helper), + .imm = @intFromEnum(helper), }; } @@ -1511,7 +1511,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries .map_create = std.mem.zeroes(MapCreateAttr), }; - attr.map_create.map_type = @enumToInt(map_type); + attr.map_create.map_type = @intFromEnum(map_type); attr.map_create.key_size = key_size; attr.map_create.value_size = value_size; attr.map_create.max_entries = max_entries; @@ -1537,8 +1537,8 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void { }; attr.map_elem.map_fd = fd; - attr.map_elem.key = @ptrToInt(key.ptr); - attr.map_elem.result.value = @ptrToInt(value.ptr); + attr.map_elem.key = @intFromPtr(key.ptr); + attr.map_elem.result.value = @intFromPtr(value.ptr); const rc = linux.bpf(.map_lookup_elem, &attr, @sizeOf(MapElemAttr)); switch (errno(rc)) { @@ -1558,8 +1558,8 @@ pub fn map_update_elem(fd: fd_t, key: []const u8, value: []const u8, flags: u64) }; attr.map_elem.map_fd = fd; - attr.map_elem.key = @ptrToInt(key.ptr); - attr.map_elem.result = .{ .value = @ptrToInt(value.ptr) }; + attr.map_elem.key = @intFromPtr(key.ptr); + attr.map_elem.result = .{ .value = @intFromPtr(value.ptr) }; attr.map_elem.flags = flags; const rc = linux.bpf(.map_update_elem, &attr, @sizeOf(MapElemAttr)); @@ -1581,7 +1581,7 @@ pub fn map_delete_elem(fd: fd_t, key: []const u8) !void { }; attr.map_elem.map_fd = fd; - attr.map_elem.key = @ptrToInt(key.ptr); + attr.map_elem.key = @intFromPtr(key.ptr); const rc = linux.bpf(.map_delete_elem, &attr, @sizeOf(MapElemAttr)); switch (errno(rc)) { @@ -1601,8 +1601,8 @@ pub fn map_get_next_key(fd: fd_t, key: []const u8, next_key: []u8) !bool { }; attr.map_elem.map_fd = fd; - attr.map_elem.key = @ptrToInt(key.ptr); - attr.map_elem.result.next_key = @ptrToInt(next_key.ptr); + attr.map_elem.key = @intFromPtr(key.ptr); + attr.map_elem.result.next_key = @intFromPtr(next_key.ptr); const rc = linux.bpf(.map_get_next_key, &attr, @sizeOf(MapElemAttr)); switch (errno(rc)) { @@ -1666,15 +1666,15 @@ pub fn prog_load( .prog_load = std.mem.zeroes(ProgLoadAttr), }; - attr.prog_load.prog_type = @enumToInt(prog_type); - attr.prog_load.insns = @ptrToInt(insns.ptr); + attr.prog_load.prog_type = @intFromEnum(prog_type); + attr.prog_load.insns = @intFromPtr(insns.ptr); attr.prog_load.insn_cnt = @intCast(u32, insns.len); - attr.prog_load.license = @ptrToInt(license.ptr); + attr.prog_load.license = @intFromPtr(license.ptr); attr.prog_load.kern_version = kern_version; attr.prog_load.prog_flags = flags; if (log) |l| { - attr.prog_load.log_buf = @ptrToInt(l.buf.ptr); + attr.prog_load.log_buf = @intFromPtr(l.buf.ptr); attr.prog_load.log_size = @intCast(u32, l.buf.len); attr.prog_load.log_level = l.level; } diff --git a/lib/std/os/linux/bpf/helpers.zig b/lib/std/os/linux/bpf/helpers.zig index 6084b01e6cad..b26e7eda29ae 100644 --- a/lib/std/os/linux/bpf/helpers.zig +++ b/lib/std/os/linux/bpf/helpers.zig @@ -11,147 +11,147 @@ const SkFullSock = @compileError("TODO missing os bits: SkFullSock"); // // Note, these function signatures were created from documentation found in // '/usr/include/linux/bpf.h' -pub const map_lookup_elem = @intToPtr(*const fn (map: *const kern.MapDef, key: ?*const anyopaque) ?*anyopaque, 1); -pub const map_update_elem = @intToPtr(*const fn (map: *const kern.MapDef, key: ?*const anyopaque, value: ?*const anyopaque, flags: u64) c_long, 2); -pub const map_delete_elem = @intToPtr(*const fn (map: *const kern.MapDef, key: ?*const anyopaque) c_long, 3); -pub const probe_read = @intToPtr(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 4); -pub const ktime_get_ns = @intToPtr(*const fn () u64, 5); -pub const trace_printk = @intToPtr(*const fn (fmt: [*:0]const u8, fmt_size: u32, arg1: u64, arg2: u64, arg3: u64) c_long, 6); -pub const get_prandom_u32 = @intToPtr(*const fn () u32, 7); -pub const get_smp_processor_id = @intToPtr(*const fn () u32, 8); -pub const skb_store_bytes = @intToPtr(*const fn (skb: *kern.SkBuff, offset: u32, from: ?*const anyopaque, len: u32, flags: u64) c_long, 9); -pub const l3_csum_replace = @intToPtr(*const fn (skb: *kern.SkBuff, offset: u32, from: u64, to: u64, size: u64) c_long, 10); -pub const l4_csum_replace = @intToPtr(*const fn (skb: *kern.SkBuff, offset: u32, from: u64, to: u64, flags: u64) c_long, 11); -pub const tail_call = @intToPtr(*const fn (ctx: ?*anyopaque, prog_array_map: *const kern.MapDef, index: u32) c_long, 12); -pub const clone_redirect = @intToPtr(*const fn (skb: *kern.SkBuff, ifindex: u32, flags: u64) c_long, 13); -pub const get_current_pid_tgid = @intToPtr(*const fn () u64, 14); -pub const get_current_uid_gid = @intToPtr(*const fn () u64, 15); -pub const get_current_comm = @intToPtr(*const fn (buf: ?*anyopaque, size_of_buf: u32) c_long, 16); -pub const get_cgroup_classid = @intToPtr(*const fn (skb: *kern.SkBuff) u32, 17); +pub const map_lookup_elem = @ptrFromInt(*const fn (map: *const kern.MapDef, key: ?*const anyopaque) ?*anyopaque, 1); +pub const map_update_elem = @ptrFromInt(*const fn (map: *const kern.MapDef, key: ?*const anyopaque, value: ?*const anyopaque, flags: u64) c_long, 2); +pub const map_delete_elem = @ptrFromInt(*const fn (map: *const kern.MapDef, key: ?*const anyopaque) c_long, 3); +pub const probe_read = @ptrFromInt(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 4); +pub const ktime_get_ns = @ptrFromInt(*const fn () u64, 5); +pub const trace_printk = @ptrFromInt(*const fn (fmt: [*:0]const u8, fmt_size: u32, arg1: u64, arg2: u64, arg3: u64) c_long, 6); +pub const get_prandom_u32 = @ptrFromInt(*const fn () u32, 7); +pub const get_smp_processor_id = @ptrFromInt(*const fn () u32, 8); +pub const skb_store_bytes = @ptrFromInt(*const fn (skb: *kern.SkBuff, offset: u32, from: ?*const anyopaque, len: u32, flags: u64) c_long, 9); +pub const l3_csum_replace = @ptrFromInt(*const fn (skb: *kern.SkBuff, offset: u32, from: u64, to: u64, size: u64) c_long, 10); +pub const l4_csum_replace = @ptrFromInt(*const fn (skb: *kern.SkBuff, offset: u32, from: u64, to: u64, flags: u64) c_long, 11); +pub const tail_call = @ptrFromInt(*const fn (ctx: ?*anyopaque, prog_array_map: *const kern.MapDef, index: u32) c_long, 12); +pub const clone_redirect = @ptrFromInt(*const fn (skb: *kern.SkBuff, ifindex: u32, flags: u64) c_long, 13); +pub const get_current_pid_tgid = @ptrFromInt(*const fn () u64, 14); +pub const get_current_uid_gid = @ptrFromInt(*const fn () u64, 15); +pub const get_current_comm = @ptrFromInt(*const fn (buf: ?*anyopaque, size_of_buf: u32) c_long, 16); +pub const get_cgroup_classid = @ptrFromInt(*const fn (skb: *kern.SkBuff) u32, 17); // Note vlan_proto is big endian -pub const skb_vlan_push = @intToPtr(*const fn (skb: *kern.SkBuff, vlan_proto: u16, vlan_tci: u16) c_long, 18); -pub const skb_vlan_pop = @intToPtr(*const fn (skb: *kern.SkBuff) c_long, 19); -pub const skb_get_tunnel_key = @intToPtr(*const fn (skb: *kern.SkBuff, key: *kern.TunnelKey, size: u32, flags: u64) c_long, 20); -pub const skb_set_tunnel_key = @intToPtr(*const fn (skb: *kern.SkBuff, key: *kern.TunnelKey, size: u32, flags: u64) c_long, 21); -pub const perf_event_read = @intToPtr(*const fn (map: *const kern.MapDef, flags: u64) u64, 22); -pub const redirect = @intToPtr(*const fn (ifindex: u32, flags: u64) c_long, 23); -pub const get_route_realm = @intToPtr(*const fn (skb: *kern.SkBuff) u32, 24); -pub const perf_event_output = @intToPtr(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64, data: ?*anyopaque, size: u64) c_long, 25); -pub const skb_load_bytes = @intToPtr(*const fn (skb: ?*anyopaque, offset: u32, to: ?*anyopaque, len: u32) c_long, 26); -pub const get_stackid = @intToPtr(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64) c_long, 27); +pub const skb_vlan_push = @ptrFromInt(*const fn (skb: *kern.SkBuff, vlan_proto: u16, vlan_tci: u16) c_long, 18); +pub const skb_vlan_pop = @ptrFromInt(*const fn (skb: *kern.SkBuff) c_long, 19); +pub const skb_get_tunnel_key = @ptrFromInt(*const fn (skb: *kern.SkBuff, key: *kern.TunnelKey, size: u32, flags: u64) c_long, 20); +pub const skb_set_tunnel_key = @ptrFromInt(*const fn (skb: *kern.SkBuff, key: *kern.TunnelKey, size: u32, flags: u64) c_long, 21); +pub const perf_event_read = @ptrFromInt(*const fn (map: *const kern.MapDef, flags: u64) u64, 22); +pub const redirect = @ptrFromInt(*const fn (ifindex: u32, flags: u64) c_long, 23); +pub const get_route_realm = @ptrFromInt(*const fn (skb: *kern.SkBuff) u32, 24); +pub const perf_event_output = @ptrFromInt(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64, data: ?*anyopaque, size: u64) c_long, 25); +pub const skb_load_bytes = @ptrFromInt(*const fn (skb: ?*anyopaque, offset: u32, to: ?*anyopaque, len: u32) c_long, 26); +pub const get_stackid = @ptrFromInt(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64) c_long, 27); // from and to point to __be32 -pub const csum_diff = @intToPtr(*const fn (from: *u32, from_size: u32, to: *u32, to_size: u32, seed: u32) i64, 28); -pub const skb_get_tunnel_opt = @intToPtr(*const fn (skb: *kern.SkBuff, opt: ?*anyopaque, size: u32) c_long, 29); -pub const skb_set_tunnel_opt = @intToPtr(*const fn (skb: *kern.SkBuff, opt: ?*anyopaque, size: u32) c_long, 30); +pub const csum_diff = @ptrFromInt(*const fn (from: *u32, from_size: u32, to: *u32, to_size: u32, seed: u32) i64, 28); +pub const skb_get_tunnel_opt = @ptrFromInt(*const fn (skb: *kern.SkBuff, opt: ?*anyopaque, size: u32) c_long, 29); +pub const skb_set_tunnel_opt = @ptrFromInt(*const fn (skb: *kern.SkBuff, opt: ?*anyopaque, size: u32) c_long, 30); // proto is __be16 -pub const skb_change_proto = @intToPtr(*const fn (skb: *kern.SkBuff, proto: u16, flags: u64) c_long, 31); -pub const skb_change_type = @intToPtr(*const fn (skb: *kern.SkBuff, skb_type: u32) c_long, 32); -pub const skb_under_cgroup = @intToPtr(*const fn (skb: *kern.SkBuff, map: ?*const anyopaque, index: u32) c_long, 33); -pub const get_hash_recalc = @intToPtr(*const fn (skb: *kern.SkBuff) u32, 34); -pub const get_current_task = @intToPtr(*const fn () u64, 35); -pub const probe_write_user = @intToPtr(*const fn (dst: ?*anyopaque, src: ?*const anyopaque, len: u32) c_long, 36); -pub const current_task_under_cgroup = @intToPtr(*const fn (map: *const kern.MapDef, index: u32) c_long, 37); -pub const skb_change_tail = @intToPtr(*const fn (skb: *kern.SkBuff, len: u32, flags: u64) c_long, 38); -pub const skb_pull_data = @intToPtr(*const fn (skb: *kern.SkBuff, len: u32) c_long, 39); -pub const csum_update = @intToPtr(*const fn (skb: *kern.SkBuff, csum: u32) i64, 40); -pub const set_hash_invalid = @intToPtr(*const fn (skb: *kern.SkBuff) void, 41); -pub const get_numa_node_id = @intToPtr(*const fn () c_long, 42); -pub const skb_change_head = @intToPtr(*const fn (skb: *kern.SkBuff, len: u32, flags: u64) c_long, 43); -pub const xdp_adjust_head = @intToPtr(*const fn (xdp_md: *kern.XdpMd, delta: c_int) c_long, 44); -pub const probe_read_str = @intToPtr(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 45); -pub const get_socket_cookie = @intToPtr(*const fn (ctx: ?*anyopaque) u64, 46); -pub const get_socket_uid = @intToPtr(*const fn (skb: *kern.SkBuff) u32, 47); -pub const set_hash = @intToPtr(*const fn (skb: *kern.SkBuff, hash: u32) c_long, 48); -pub const setsockopt = @intToPtr(*const fn (bpf_socket: *kern.SockOps, level: c_int, optname: c_int, optval: ?*anyopaque, optlen: c_int) c_long, 49); -pub const skb_adjust_room = @intToPtr(*const fn (skb: *kern.SkBuff, len_diff: i32, mode: u32, flags: u64) c_long, 50); -pub const redirect_map = @intToPtr(*const fn (map: *const kern.MapDef, key: u32, flags: u64) c_long, 51); -pub const sk_redirect_map = @intToPtr(*const fn (skb: *kern.SkBuff, map: *const kern.MapDef, key: u32, flags: u64) c_long, 52); -pub const sock_map_update = @intToPtr(*const fn (skops: *kern.SockOps, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 53); -pub const xdp_adjust_meta = @intToPtr(*const fn (xdp_md: *kern.XdpMd, delta: c_int) c_long, 54); -pub const perf_event_read_value = @intToPtr(*const fn (map: *const kern.MapDef, flags: u64, buf: *kern.PerfEventValue, buf_size: u32) c_long, 55); -pub const perf_prog_read_value = @intToPtr(*const fn (ctx: *kern.PerfEventData, buf: *kern.PerfEventValue, buf_size: u32) c_long, 56); -pub const getsockopt = @intToPtr(*const fn (bpf_socket: ?*anyopaque, level: c_int, optname: c_int, optval: ?*anyopaque, optlen: c_int) c_long, 57); -pub const override_return = @intToPtr(*const fn (regs: *PtRegs, rc: u64) c_long, 58); -pub const sock_ops_cb_flags_set = @intToPtr(*const fn (bpf_sock: *kern.SockOps, argval: c_int) c_long, 59); -pub const msg_redirect_map = @intToPtr(*const fn (msg: *kern.SkMsgMd, map: *const kern.MapDef, key: u32, flags: u64) c_long, 60); -pub const msg_apply_bytes = @intToPtr(*const fn (msg: *kern.SkMsgMd, bytes: u32) c_long, 61); -pub const msg_cork_bytes = @intToPtr(*const fn (msg: *kern.SkMsgMd, bytes: u32) c_long, 62); -pub const msg_pull_data = @intToPtr(*const fn (msg: *kern.SkMsgMd, start: u32, end: u32, flags: u64) c_long, 63); -pub const bind = @intToPtr(*const fn (ctx: *kern.BpfSockAddr, addr: *kern.SockAddr, addr_len: c_int) c_long, 64); -pub const xdp_adjust_tail = @intToPtr(*const fn (xdp_md: *kern.XdpMd, delta: c_int) c_long, 65); -pub const skb_get_xfrm_state = @intToPtr(*const fn (skb: *kern.SkBuff, index: u32, xfrm_state: *kern.XfrmState, size: u32, flags: u64) c_long, 66); -pub const get_stack = @intToPtr(*const fn (ctx: ?*anyopaque, buf: ?*anyopaque, size: u32, flags: u64) c_long, 67); -pub const skb_load_bytes_relative = @intToPtr(*const fn (skb: ?*const anyopaque, offset: u32, to: ?*anyopaque, len: u32, start_header: u32) c_long, 68); -pub const fib_lookup = @intToPtr(*const fn (ctx: ?*anyopaque, params: *kern.FibLookup, plen: c_int, flags: u32) c_long, 69); -pub const sock_hash_update = @intToPtr(*const fn (skops: *kern.SockOps, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 70); -pub const msg_redirect_hash = @intToPtr(*const fn (msg: *kern.SkMsgMd, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 71); -pub const sk_redirect_hash = @intToPtr(*const fn (skb: *kern.SkBuff, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 72); -pub const lwt_push_encap = @intToPtr(*const fn (skb: *kern.SkBuff, typ: u32, hdr: ?*anyopaque, len: u32) c_long, 73); -pub const lwt_seg6_store_bytes = @intToPtr(*const fn (skb: *kern.SkBuff, offset: u32, from: ?*const anyopaque, len: u32) c_long, 74); -pub const lwt_seg6_adjust_srh = @intToPtr(*const fn (skb: *kern.SkBuff, offset: u32, delta: i32) c_long, 75); -pub const lwt_seg6_action = @intToPtr(*const fn (skb: *kern.SkBuff, action: u32, param: ?*anyopaque, param_len: u32) c_long, 76); -pub const rc_repeat = @intToPtr(*const fn (ctx: ?*anyopaque) c_long, 77); -pub const rc_keydown = @intToPtr(*const fn (ctx: ?*anyopaque, protocol: u32, scancode: u64, toggle: u32) c_long, 78); -pub const skb_cgroup_id = @intToPtr(*const fn (skb: *kern.SkBuff) u64, 79); -pub const get_current_cgroup_id = @intToPtr(*const fn () u64, 80); -pub const get_local_storage = @intToPtr(*const fn (map: ?*anyopaque, flags: u64) ?*anyopaque, 81); -pub const sk_select_reuseport = @intToPtr(*const fn (reuse: *kern.SkReusePortMd, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 82); -pub const skb_ancestor_cgroup_id = @intToPtr(*const fn (skb: *kern.SkBuff, ancestor_level: c_int) u64, 83); -pub const sk_lookup_tcp = @intToPtr(*const fn (ctx: ?*anyopaque, tuple: *kern.SockTuple, tuple_size: u32, netns: u64, flags: u64) ?*kern.Sock, 84); -pub const sk_lookup_udp = @intToPtr(*const fn (ctx: ?*anyopaque, tuple: *kern.SockTuple, tuple_size: u32, netns: u64, flags: u64) ?*kern.Sock, 85); -pub const sk_release = @intToPtr(*const fn (sock: *kern.Sock) c_long, 86); -pub const map_push_elem = @intToPtr(*const fn (map: *const kern.MapDef, value: ?*const anyopaque, flags: u64) c_long, 87); -pub const map_pop_elem = @intToPtr(*const fn (map: *const kern.MapDef, value: ?*anyopaque) c_long, 88); -pub const map_peek_elem = @intToPtr(*const fn (map: *const kern.MapDef, value: ?*anyopaque) c_long, 89); -pub const msg_push_data = @intToPtr(*const fn (msg: *kern.SkMsgMd, start: u32, len: u32, flags: u64) c_long, 90); -pub const msg_pop_data = @intToPtr(*const fn (msg: *kern.SkMsgMd, start: u32, len: u32, flags: u64) c_long, 91); -pub const rc_pointer_rel = @intToPtr(*const fn (ctx: ?*anyopaque, rel_x: i32, rel_y: i32) c_long, 92); -pub const spin_lock = @intToPtr(*const fn (lock: *kern.SpinLock) c_long, 93); -pub const spin_unlock = @intToPtr(*const fn (lock: *kern.SpinLock) c_long, 94); -pub const sk_fullsock = @intToPtr(*const fn (sk: *kern.Sock) ?*SkFullSock, 95); -pub const tcp_sock = @intToPtr(*const fn (sk: *kern.Sock) ?*kern.TcpSock, 96); -pub const skb_ecn_set_ce = @intToPtr(*const fn (skb: *kern.SkBuff) c_long, 97); -pub const get_listener_sock = @intToPtr(*const fn (sk: *kern.Sock) ?*kern.Sock, 98); -pub const skc_lookup_tcp = @intToPtr(*const fn (ctx: ?*anyopaque, tuple: *kern.SockTuple, tuple_size: u32, netns: u64, flags: u64) ?*kern.Sock, 99); -pub const tcp_check_syncookie = @intToPtr(*const fn (sk: *kern.Sock, iph: ?*anyopaque, iph_len: u32, th: *TcpHdr, th_len: u32) c_long, 100); -pub const sysctl_get_name = @intToPtr(*const fn (ctx: *kern.SysCtl, buf: ?*u8, buf_len: c_ulong, flags: u64) c_long, 101); -pub const sysctl_get_current_value = @intToPtr(*const fn (ctx: *kern.SysCtl, buf: ?*u8, buf_len: c_ulong) c_long, 102); -pub const sysctl_get_new_value = @intToPtr(*const fn (ctx: *kern.SysCtl, buf: ?*u8, buf_len: c_ulong) c_long, 103); -pub const sysctl_set_new_value = @intToPtr(*const fn (ctx: *kern.SysCtl, buf: ?*const u8, buf_len: c_ulong) c_long, 104); -pub const strtol = @intToPtr(*const fn (buf: *const u8, buf_len: c_ulong, flags: u64, res: *c_long) c_long, 105); -pub const strtoul = @intToPtr(*const fn (buf: *const u8, buf_len: c_ulong, flags: u64, res: *c_ulong) c_long, 106); -pub const sk_storage_get = @intToPtr(*const fn (map: *const kern.MapDef, sk: *kern.Sock, value: ?*anyopaque, flags: u64) ?*anyopaque, 107); -pub const sk_storage_delete = @intToPtr(*const fn (map: *const kern.MapDef, sk: *kern.Sock) c_long, 108); -pub const send_signal = @intToPtr(*const fn (sig: u32) c_long, 109); -pub const tcp_gen_syncookie = @intToPtr(*const fn (sk: *kern.Sock, iph: ?*anyopaque, iph_len: u32, th: *TcpHdr, th_len: u32) i64, 110); -pub const skb_output = @intToPtr(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64, data: ?*anyopaque, size: u64) c_long, 111); -pub const probe_read_user = @intToPtr(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 112); -pub const probe_read_kernel = @intToPtr(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 113); -pub const probe_read_user_str = @intToPtr(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 114); -pub const probe_read_kernel_str = @intToPtr(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 115); -pub const tcp_send_ack = @intToPtr(*const fn (tp: ?*anyopaque, rcv_nxt: u32) c_long, 116); -pub const send_signal_thread = @intToPtr(*const fn (sig: u32) c_long, 117); -pub const jiffies64 = @intToPtr(*const fn () u64, 118); -pub const read_branch_records = @intToPtr(*const fn (ctx: *kern.PerfEventData, buf: ?*anyopaque, size: u32, flags: u64) c_long, 119); -pub const get_ns_current_pid_tgid = @intToPtr(*const fn (dev: u64, ino: u64, nsdata: *kern.PidNsInfo, size: u32) c_long, 120); -pub const xdp_output = @intToPtr(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64, data: ?*anyopaque, size: u64) c_long, 121); -pub const get_netns_cookie = @intToPtr(*const fn (ctx: ?*anyopaque) u64, 122); -pub const get_current_ancestor_cgroup_id = @intToPtr(*const fn (ancestor_level: c_int) u64, 123); -pub const sk_assign = @intToPtr(*const fn (skb: *kern.SkBuff, sk: *kern.Sock, flags: u64) c_long, 124); -pub const ktime_get_boot_ns = @intToPtr(*const fn () u64, 125); -pub const seq_printf = @intToPtr(*const fn (m: *kern.SeqFile, fmt: ?*const u8, fmt_size: u32, data: ?*const anyopaque, data_len: u32) c_long, 126); -pub const seq_write = @intToPtr(*const fn (m: *kern.SeqFile, data: ?*const u8, len: u32) c_long, 127); -pub const sk_cgroup_id = @intToPtr(*const fn (sk: *kern.BpfSock) u64, 128); -pub const sk_ancestor_cgroup_id = @intToPtr(*const fn (sk: *kern.BpfSock, ancestor_level: c_long) u64, 129); -pub const ringbuf_output = @intToPtr(*const fn (ringbuf: ?*anyopaque, data: ?*anyopaque, size: u64, flags: u64) c_long, 130); -pub const ringbuf_reserve = @intToPtr(*const fn (ringbuf: ?*anyopaque, size: u64, flags: u64) ?*anyopaque, 131); -pub const ringbuf_submit = @intToPtr(*const fn (data: ?*anyopaque, flags: u64) void, 132); -pub const ringbuf_discard = @intToPtr(*const fn (data: ?*anyopaque, flags: u64) void, 133); -pub const ringbuf_query = @intToPtr(*const fn (ringbuf: ?*anyopaque, flags: u64) u64, 134); -pub const csum_level = @intToPtr(*const fn (skb: *kern.SkBuff, level: u64) c_long, 135); -pub const skc_to_tcp6_sock = @intToPtr(*const fn (sk: ?*anyopaque) ?*kern.Tcp6Sock, 136); -pub const skc_to_tcp_sock = @intToPtr(*const fn (sk: ?*anyopaque) ?*kern.TcpSock, 137); -pub const skc_to_tcp_timewait_sock = @intToPtr(*const fn (sk: ?*anyopaque) ?*kern.TcpTimewaitSock, 138); -pub const skc_to_tcp_request_sock = @intToPtr(*const fn (sk: ?*anyopaque) ?*kern.TcpRequestSock, 139); -pub const skc_to_udp6_sock = @intToPtr(*const fn (sk: ?*anyopaque) ?*kern.Udp6Sock, 140); -pub const get_task_stack = @intToPtr(*const fn (task: ?*anyopaque, buf: ?*anyopaque, size: u32, flags: u64) c_long, 141); +pub const skb_change_proto = @ptrFromInt(*const fn (skb: *kern.SkBuff, proto: u16, flags: u64) c_long, 31); +pub const skb_change_type = @ptrFromInt(*const fn (skb: *kern.SkBuff, skb_type: u32) c_long, 32); +pub const skb_under_cgroup = @ptrFromInt(*const fn (skb: *kern.SkBuff, map: ?*const anyopaque, index: u32) c_long, 33); +pub const get_hash_recalc = @ptrFromInt(*const fn (skb: *kern.SkBuff) u32, 34); +pub const get_current_task = @ptrFromInt(*const fn () u64, 35); +pub const probe_write_user = @ptrFromInt(*const fn (dst: ?*anyopaque, src: ?*const anyopaque, len: u32) c_long, 36); +pub const current_task_under_cgroup = @ptrFromInt(*const fn (map: *const kern.MapDef, index: u32) c_long, 37); +pub const skb_change_tail = @ptrFromInt(*const fn (skb: *kern.SkBuff, len: u32, flags: u64) c_long, 38); +pub const skb_pull_data = @ptrFromInt(*const fn (skb: *kern.SkBuff, len: u32) c_long, 39); +pub const csum_update = @ptrFromInt(*const fn (skb: *kern.SkBuff, csum: u32) i64, 40); +pub const set_hash_invalid = @ptrFromInt(*const fn (skb: *kern.SkBuff) void, 41); +pub const get_numa_node_id = @ptrFromInt(*const fn () c_long, 42); +pub const skb_change_head = @ptrFromInt(*const fn (skb: *kern.SkBuff, len: u32, flags: u64) c_long, 43); +pub const xdp_adjust_head = @ptrFromInt(*const fn (xdp_md: *kern.XdpMd, delta: c_int) c_long, 44); +pub const probe_read_str = @ptrFromInt(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 45); +pub const get_socket_cookie = @ptrFromInt(*const fn (ctx: ?*anyopaque) u64, 46); +pub const get_socket_uid = @ptrFromInt(*const fn (skb: *kern.SkBuff) u32, 47); +pub const set_hash = @ptrFromInt(*const fn (skb: *kern.SkBuff, hash: u32) c_long, 48); +pub const setsockopt = @ptrFromInt(*const fn (bpf_socket: *kern.SockOps, level: c_int, optname: c_int, optval: ?*anyopaque, optlen: c_int) c_long, 49); +pub const skb_adjust_room = @ptrFromInt(*const fn (skb: *kern.SkBuff, len_diff: i32, mode: u32, flags: u64) c_long, 50); +pub const redirect_map = @ptrFromInt(*const fn (map: *const kern.MapDef, key: u32, flags: u64) c_long, 51); +pub const sk_redirect_map = @ptrFromInt(*const fn (skb: *kern.SkBuff, map: *const kern.MapDef, key: u32, flags: u64) c_long, 52); +pub const sock_map_update = @ptrFromInt(*const fn (skops: *kern.SockOps, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 53); +pub const xdp_adjust_meta = @ptrFromInt(*const fn (xdp_md: *kern.XdpMd, delta: c_int) c_long, 54); +pub const perf_event_read_value = @ptrFromInt(*const fn (map: *const kern.MapDef, flags: u64, buf: *kern.PerfEventValue, buf_size: u32) c_long, 55); +pub const perf_prog_read_value = @ptrFromInt(*const fn (ctx: *kern.PerfEventData, buf: *kern.PerfEventValue, buf_size: u32) c_long, 56); +pub const getsockopt = @ptrFromInt(*const fn (bpf_socket: ?*anyopaque, level: c_int, optname: c_int, optval: ?*anyopaque, optlen: c_int) c_long, 57); +pub const override_return = @ptrFromInt(*const fn (regs: *PtRegs, rc: u64) c_long, 58); +pub const sock_ops_cb_flags_set = @ptrFromInt(*const fn (bpf_sock: *kern.SockOps, argval: c_int) c_long, 59); +pub const msg_redirect_map = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, map: *const kern.MapDef, key: u32, flags: u64) c_long, 60); +pub const msg_apply_bytes = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, bytes: u32) c_long, 61); +pub const msg_cork_bytes = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, bytes: u32) c_long, 62); +pub const msg_pull_data = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, start: u32, end: u32, flags: u64) c_long, 63); +pub const bind = @ptrFromInt(*const fn (ctx: *kern.BpfSockAddr, addr: *kern.SockAddr, addr_len: c_int) c_long, 64); +pub const xdp_adjust_tail = @ptrFromInt(*const fn (xdp_md: *kern.XdpMd, delta: c_int) c_long, 65); +pub const skb_get_xfrm_state = @ptrFromInt(*const fn (skb: *kern.SkBuff, index: u32, xfrm_state: *kern.XfrmState, size: u32, flags: u64) c_long, 66); +pub const get_stack = @ptrFromInt(*const fn (ctx: ?*anyopaque, buf: ?*anyopaque, size: u32, flags: u64) c_long, 67); +pub const skb_load_bytes_relative = @ptrFromInt(*const fn (skb: ?*const anyopaque, offset: u32, to: ?*anyopaque, len: u32, start_header: u32) c_long, 68); +pub const fib_lookup = @ptrFromInt(*const fn (ctx: ?*anyopaque, params: *kern.FibLookup, plen: c_int, flags: u32) c_long, 69); +pub const sock_hash_update = @ptrFromInt(*const fn (skops: *kern.SockOps, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 70); +pub const msg_redirect_hash = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 71); +pub const sk_redirect_hash = @ptrFromInt(*const fn (skb: *kern.SkBuff, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 72); +pub const lwt_push_encap = @ptrFromInt(*const fn (skb: *kern.SkBuff, typ: u32, hdr: ?*anyopaque, len: u32) c_long, 73); +pub const lwt_seg6_store_bytes = @ptrFromInt(*const fn (skb: *kern.SkBuff, offset: u32, from: ?*const anyopaque, len: u32) c_long, 74); +pub const lwt_seg6_adjust_srh = @ptrFromInt(*const fn (skb: *kern.SkBuff, offset: u32, delta: i32) c_long, 75); +pub const lwt_seg6_action = @ptrFromInt(*const fn (skb: *kern.SkBuff, action: u32, param: ?*anyopaque, param_len: u32) c_long, 76); +pub const rc_repeat = @ptrFromInt(*const fn (ctx: ?*anyopaque) c_long, 77); +pub const rc_keydown = @ptrFromInt(*const fn (ctx: ?*anyopaque, protocol: u32, scancode: u64, toggle: u32) c_long, 78); +pub const skb_cgroup_id = @ptrFromInt(*const fn (skb: *kern.SkBuff) u64, 79); +pub const get_current_cgroup_id = @ptrFromInt(*const fn () u64, 80); +pub const get_local_storage = @ptrFromInt(*const fn (map: ?*anyopaque, flags: u64) ?*anyopaque, 81); +pub const sk_select_reuseport = @ptrFromInt(*const fn (reuse: *kern.SkReusePortMd, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 82); +pub const skb_ancestor_cgroup_id = @ptrFromInt(*const fn (skb: *kern.SkBuff, ancestor_level: c_int) u64, 83); +pub const sk_lookup_tcp = @ptrFromInt(*const fn (ctx: ?*anyopaque, tuple: *kern.SockTuple, tuple_size: u32, netns: u64, flags: u64) ?*kern.Sock, 84); +pub const sk_lookup_udp = @ptrFromInt(*const fn (ctx: ?*anyopaque, tuple: *kern.SockTuple, tuple_size: u32, netns: u64, flags: u64) ?*kern.Sock, 85); +pub const sk_release = @ptrFromInt(*const fn (sock: *kern.Sock) c_long, 86); +pub const map_push_elem = @ptrFromInt(*const fn (map: *const kern.MapDef, value: ?*const anyopaque, flags: u64) c_long, 87); +pub const map_pop_elem = @ptrFromInt(*const fn (map: *const kern.MapDef, value: ?*anyopaque) c_long, 88); +pub const map_peek_elem = @ptrFromInt(*const fn (map: *const kern.MapDef, value: ?*anyopaque) c_long, 89); +pub const msg_push_data = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, start: u32, len: u32, flags: u64) c_long, 90); +pub const msg_pop_data = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, start: u32, len: u32, flags: u64) c_long, 91); +pub const rc_pointer_rel = @ptrFromInt(*const fn (ctx: ?*anyopaque, rel_x: i32, rel_y: i32) c_long, 92); +pub const spin_lock = @ptrFromInt(*const fn (lock: *kern.SpinLock) c_long, 93); +pub const spin_unlock = @ptrFromInt(*const fn (lock: *kern.SpinLock) c_long, 94); +pub const sk_fullsock = @ptrFromInt(*const fn (sk: *kern.Sock) ?*SkFullSock, 95); +pub const tcp_sock = @ptrFromInt(*const fn (sk: *kern.Sock) ?*kern.TcpSock, 96); +pub const skb_ecn_set_ce = @ptrFromInt(*const fn (skb: *kern.SkBuff) c_long, 97); +pub const get_listener_sock = @ptrFromInt(*const fn (sk: *kern.Sock) ?*kern.Sock, 98); +pub const skc_lookup_tcp = @ptrFromInt(*const fn (ctx: ?*anyopaque, tuple: *kern.SockTuple, tuple_size: u32, netns: u64, flags: u64) ?*kern.Sock, 99); +pub const tcp_check_syncookie = @ptrFromInt(*const fn (sk: *kern.Sock, iph: ?*anyopaque, iph_len: u32, th: *TcpHdr, th_len: u32) c_long, 100); +pub const sysctl_get_name = @ptrFromInt(*const fn (ctx: *kern.SysCtl, buf: ?*u8, buf_len: c_ulong, flags: u64) c_long, 101); +pub const sysctl_get_current_value = @ptrFromInt(*const fn (ctx: *kern.SysCtl, buf: ?*u8, buf_len: c_ulong) c_long, 102); +pub const sysctl_get_new_value = @ptrFromInt(*const fn (ctx: *kern.SysCtl, buf: ?*u8, buf_len: c_ulong) c_long, 103); +pub const sysctl_set_new_value = @ptrFromInt(*const fn (ctx: *kern.SysCtl, buf: ?*const u8, buf_len: c_ulong) c_long, 104); +pub const strtol = @ptrFromInt(*const fn (buf: *const u8, buf_len: c_ulong, flags: u64, res: *c_long) c_long, 105); +pub const strtoul = @ptrFromInt(*const fn (buf: *const u8, buf_len: c_ulong, flags: u64, res: *c_ulong) c_long, 106); +pub const sk_storage_get = @ptrFromInt(*const fn (map: *const kern.MapDef, sk: *kern.Sock, value: ?*anyopaque, flags: u64) ?*anyopaque, 107); +pub const sk_storage_delete = @ptrFromInt(*const fn (map: *const kern.MapDef, sk: *kern.Sock) c_long, 108); +pub const send_signal = @ptrFromInt(*const fn (sig: u32) c_long, 109); +pub const tcp_gen_syncookie = @ptrFromInt(*const fn (sk: *kern.Sock, iph: ?*anyopaque, iph_len: u32, th: *TcpHdr, th_len: u32) i64, 110); +pub const skb_output = @ptrFromInt(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64, data: ?*anyopaque, size: u64) c_long, 111); +pub const probe_read_user = @ptrFromInt(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 112); +pub const probe_read_kernel = @ptrFromInt(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 113); +pub const probe_read_user_str = @ptrFromInt(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 114); +pub const probe_read_kernel_str = @ptrFromInt(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 115); +pub const tcp_send_ack = @ptrFromInt(*const fn (tp: ?*anyopaque, rcv_nxt: u32) c_long, 116); +pub const send_signal_thread = @ptrFromInt(*const fn (sig: u32) c_long, 117); +pub const jiffies64 = @ptrFromInt(*const fn () u64, 118); +pub const read_branch_records = @ptrFromInt(*const fn (ctx: *kern.PerfEventData, buf: ?*anyopaque, size: u32, flags: u64) c_long, 119); +pub const get_ns_current_pid_tgid = @ptrFromInt(*const fn (dev: u64, ino: u64, nsdata: *kern.PidNsInfo, size: u32) c_long, 120); +pub const xdp_output = @ptrFromInt(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64, data: ?*anyopaque, size: u64) c_long, 121); +pub const get_netns_cookie = @ptrFromInt(*const fn (ctx: ?*anyopaque) u64, 122); +pub const get_current_ancestor_cgroup_id = @ptrFromInt(*const fn (ancestor_level: c_int) u64, 123); +pub const sk_assign = @ptrFromInt(*const fn (skb: *kern.SkBuff, sk: *kern.Sock, flags: u64) c_long, 124); +pub const ktime_get_boot_ns = @ptrFromInt(*const fn () u64, 125); +pub const seq_printf = @ptrFromInt(*const fn (m: *kern.SeqFile, fmt: ?*const u8, fmt_size: u32, data: ?*const anyopaque, data_len: u32) c_long, 126); +pub const seq_write = @ptrFromInt(*const fn (m: *kern.SeqFile, data: ?*const u8, len: u32) c_long, 127); +pub const sk_cgroup_id = @ptrFromInt(*const fn (sk: *kern.BpfSock) u64, 128); +pub const sk_ancestor_cgroup_id = @ptrFromInt(*const fn (sk: *kern.BpfSock, ancestor_level: c_long) u64, 129); +pub const ringbuf_output = @ptrFromInt(*const fn (ringbuf: ?*anyopaque, data: ?*anyopaque, size: u64, flags: u64) c_long, 130); +pub const ringbuf_reserve = @ptrFromInt(*const fn (ringbuf: ?*anyopaque, size: u64, flags: u64) ?*anyopaque, 131); +pub const ringbuf_submit = @ptrFromInt(*const fn (data: ?*anyopaque, flags: u64) void, 132); +pub const ringbuf_discard = @ptrFromInt(*const fn (data: ?*anyopaque, flags: u64) void, 133); +pub const ringbuf_query = @ptrFromInt(*const fn (ringbuf: ?*anyopaque, flags: u64) u64, 134); +pub const csum_level = @ptrFromInt(*const fn (skb: *kern.SkBuff, level: u64) c_long, 135); +pub const skc_to_tcp6_sock = @ptrFromInt(*const fn (sk: ?*anyopaque) ?*kern.Tcp6Sock, 136); +pub const skc_to_tcp_sock = @ptrFromInt(*const fn (sk: ?*anyopaque) ?*kern.TcpSock, 137); +pub const skc_to_tcp_timewait_sock = @ptrFromInt(*const fn (sk: ?*anyopaque) ?*kern.TcpTimewaitSock, 138); +pub const skc_to_tcp_request_sock = @ptrFromInt(*const fn (sk: ?*anyopaque) ?*kern.TcpRequestSock, 139); +pub const skc_to_udp6_sock = @ptrFromInt(*const fn (sk: ?*anyopaque) ?*kern.Udp6Sock, 140); +pub const get_task_stack = @ptrFromInt(*const fn (task: ?*anyopaque, buf: ?*anyopaque, size: u32, flags: u64) c_long, 141); diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig index 0610b214d58a..875138cf4f47 100644 --- a/lib/std/os/linux/io_uring.zig +++ b/lib/std/os/linux/io_uring.zig @@ -962,7 +962,7 @@ pub const IO_Uring = struct { var update = FilesUpdate{ .offset = offset, .resv = @as(u32, 0), - .fds = @as(u64, @ptrToInt(fds.ptr)), + .fds = @as(u64, @intFromPtr(fds.ptr)), }; const res = linux.io_uring_register( @@ -1244,11 +1244,11 @@ pub fn io_uring_prep_rw( } pub fn io_uring_prep_read(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []u8, offset: u64) void { - io_uring_prep_rw(.READ, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, offset); + io_uring_prep_rw(.READ, sqe, fd, @intFromPtr(buffer.ptr), buffer.len, offset); } pub fn io_uring_prep_write(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []const u8, offset: u64) void { - io_uring_prep_rw(.WRITE, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, offset); + io_uring_prep_rw(.WRITE, sqe, fd, @intFromPtr(buffer.ptr), buffer.len, offset); } pub fn io_uring_prep_readv( @@ -1257,7 +1257,7 @@ pub fn io_uring_prep_readv( iovecs: []const os.iovec, offset: u64, ) void { - io_uring_prep_rw(.READV, sqe, fd, @ptrToInt(iovecs.ptr), iovecs.len, offset); + io_uring_prep_rw(.READV, sqe, fd, @intFromPtr(iovecs.ptr), iovecs.len, offset); } pub fn io_uring_prep_writev( @@ -1266,16 +1266,16 @@ pub fn io_uring_prep_writev( iovecs: []const os.iovec_const, offset: u64, ) void { - io_uring_prep_rw(.WRITEV, sqe, fd, @ptrToInt(iovecs.ptr), iovecs.len, offset); + io_uring_prep_rw(.WRITEV, sqe, fd, @intFromPtr(iovecs.ptr), iovecs.len, offset); } pub fn io_uring_prep_read_fixed(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: *os.iovec, offset: u64, buffer_index: u16) void { - io_uring_prep_rw(.READ_FIXED, sqe, fd, @ptrToInt(buffer.iov_base), buffer.iov_len, offset); + io_uring_prep_rw(.READ_FIXED, sqe, fd, @intFromPtr(buffer.iov_base), buffer.iov_len, offset); sqe.buf_index = buffer_index; } pub fn io_uring_prep_write_fixed(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: *os.iovec, offset: u64, buffer_index: u16) void { - io_uring_prep_rw(.WRITE_FIXED, sqe, fd, @ptrToInt(buffer.iov_base), buffer.iov_len, offset); + io_uring_prep_rw(.WRITE_FIXED, sqe, fd, @intFromPtr(buffer.iov_base), buffer.iov_len, offset); sqe.buf_index = buffer_index; } @@ -1298,7 +1298,7 @@ pub fn io_uring_prep_accept( ) void { // `addr` holds a pointer to `sockaddr`, and `addr2` holds a pointer to socklen_t`. // `addr2` maps to `sqe.off` (u64) instead of `sqe.len` (which is only a u32). - io_uring_prep_rw(.ACCEPT, sqe, fd, @ptrToInt(addr), 0, @ptrToInt(addrlen)); + io_uring_prep_rw(.ACCEPT, sqe, fd, @intFromPtr(addr), 0, @intFromPtr(addrlen)); sqe.rw_flags = flags; } @@ -1309,7 +1309,7 @@ pub fn io_uring_prep_connect( addrlen: os.socklen_t, ) void { // `addrlen` maps to `sqe.off` (u64) instead of `sqe.len` (which is only a u32). - io_uring_prep_rw(.CONNECT, sqe, fd, @ptrToInt(addr), 0, addrlen); + io_uring_prep_rw(.CONNECT, sqe, fd, @intFromPtr(addr), 0, addrlen); } pub fn io_uring_prep_epoll_ctl( @@ -1319,16 +1319,16 @@ pub fn io_uring_prep_epoll_ctl( op: u32, ev: ?*linux.epoll_event, ) void { - io_uring_prep_rw(.EPOLL_CTL, sqe, epfd, @ptrToInt(ev), op, @intCast(u64, fd)); + io_uring_prep_rw(.EPOLL_CTL, sqe, epfd, @intFromPtr(ev), op, @intCast(u64, fd)); } pub fn io_uring_prep_recv(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []u8, flags: u32) void { - io_uring_prep_rw(.RECV, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, 0); + io_uring_prep_rw(.RECV, sqe, fd, @intFromPtr(buffer.ptr), buffer.len, 0); sqe.rw_flags = flags; } pub fn io_uring_prep_send(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []const u8, flags: u32) void { - io_uring_prep_rw(.SEND, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, 0); + io_uring_prep_rw(.SEND, sqe, fd, @intFromPtr(buffer.ptr), buffer.len, 0); sqe.rw_flags = flags; } @@ -1338,7 +1338,7 @@ pub fn io_uring_prep_recvmsg( msg: *os.msghdr, flags: u32, ) void { - linux.io_uring_prep_rw(.RECVMSG, sqe, fd, @ptrToInt(msg), 1, 0); + linux.io_uring_prep_rw(.RECVMSG, sqe, fd, @intFromPtr(msg), 1, 0); sqe.rw_flags = flags; } @@ -1348,7 +1348,7 @@ pub fn io_uring_prep_sendmsg( msg: *const os.msghdr_const, flags: u32, ) void { - linux.io_uring_prep_rw(.SENDMSG, sqe, fd, @ptrToInt(msg), 1, 0); + linux.io_uring_prep_rw(.SENDMSG, sqe, fd, @intFromPtr(msg), 1, 0); sqe.rw_flags = flags; } @@ -1359,7 +1359,7 @@ pub fn io_uring_prep_openat( flags: u32, mode: os.mode_t, ) void { - io_uring_prep_rw(.OPENAT, sqe, fd, @ptrToInt(path), mode, 0); + io_uring_prep_rw(.OPENAT, sqe, fd, @intFromPtr(path), mode, 0); sqe.rw_flags = flags; } @@ -1387,7 +1387,7 @@ pub fn io_uring_prep_timeout( count: u32, flags: u32, ) void { - io_uring_prep_rw(.TIMEOUT, sqe, -1, @ptrToInt(ts), 1, count); + io_uring_prep_rw(.TIMEOUT, sqe, -1, @intFromPtr(ts), 1, count); sqe.rw_flags = flags; } @@ -1414,7 +1414,7 @@ pub fn io_uring_prep_link_timeout( ts: *const os.linux.kernel_timespec, flags: u32, ) void { - linux.io_uring_prep_rw(.LINK_TIMEOUT, sqe, -1, @ptrToInt(ts), 1, 0); + linux.io_uring_prep_rw(.LINK_TIMEOUT, sqe, -1, @intFromPtr(ts), 1, 0); sqe.rw_flags = flags; } @@ -1423,7 +1423,7 @@ pub fn io_uring_prep_poll_add( fd: os.fd_t, poll_mask: u32, ) void { - io_uring_prep_rw(.POLL_ADD, sqe, fd, @ptrToInt(@as(?*anyopaque, null)), 0, 0); + io_uring_prep_rw(.POLL_ADD, sqe, fd, @intFromPtr(@as(?*anyopaque, null)), 0, 0); sqe.rw_flags = __io_uring_prep_poll_mask(poll_mask); } @@ -1477,7 +1477,7 @@ pub fn io_uring_prep_statx( mask: u32, buf: *linux.Statx, ) void { - io_uring_prep_rw(.STATX, sqe, fd, @ptrToInt(path), mask, @ptrToInt(buf)); + io_uring_prep_rw(.STATX, sqe, fd, @intFromPtr(path), mask, @intFromPtr(buf)); sqe.rw_flags = flags; } @@ -1510,9 +1510,9 @@ pub fn io_uring_prep_renameat( .RENAMEAT, sqe, old_dir_fd, - @ptrToInt(old_path), + @intFromPtr(old_path), 0, - @ptrToInt(new_path), + @intFromPtr(new_path), ); sqe.len = @bitCast(u32, new_dir_fd); sqe.rw_flags = flags; @@ -1524,7 +1524,7 @@ pub fn io_uring_prep_unlinkat( path: [*:0]const u8, flags: u32, ) void { - io_uring_prep_rw(.UNLINKAT, sqe, dir_fd, @ptrToInt(path), 0, 0); + io_uring_prep_rw(.UNLINKAT, sqe, dir_fd, @intFromPtr(path), 0, 0); sqe.rw_flags = flags; } @@ -1534,7 +1534,7 @@ pub fn io_uring_prep_mkdirat( path: [*:0]const u8, mode: os.mode_t, ) void { - io_uring_prep_rw(.MKDIRAT, sqe, dir_fd, @ptrToInt(path), mode, 0); + io_uring_prep_rw(.MKDIRAT, sqe, dir_fd, @intFromPtr(path), mode, 0); } pub fn io_uring_prep_symlinkat( @@ -1547,9 +1547,9 @@ pub fn io_uring_prep_symlinkat( .SYMLINKAT, sqe, new_dir_fd, - @ptrToInt(target), + @intFromPtr(target), 0, - @ptrToInt(link_path), + @intFromPtr(link_path), ); } @@ -1565,9 +1565,9 @@ pub fn io_uring_prep_linkat( .LINKAT, sqe, old_dir_fd, - @ptrToInt(old_path), + @intFromPtr(old_path), 0, - @ptrToInt(new_path), + @intFromPtr(new_path), ); sqe.len = @bitCast(u32, new_dir_fd); sqe.rw_flags = flags; @@ -1581,7 +1581,7 @@ pub fn io_uring_prep_provide_buffers( group_id: usize, buffer_id: usize, ) void { - const ptr = @ptrToInt(buffers); + const ptr = @intFromPtr(buffers); io_uring_prep_rw(.PROVIDE_BUFFERS, sqe, @intCast(i32, num), ptr, buffer_len, buffer_id); sqe.buf_index = @intCast(u16, group_id); } @@ -1918,8 +1918,8 @@ test "openat" { // Workaround for LLVM bug: https://github.com/ziglang/zig/issues/12014 const path_addr = if (builtin.zig_backend == .stage2_llvm) p: { var workaround = path; - break :p @ptrToInt(workaround); - } else @ptrToInt(path); + break :p @intFromPtr(workaround); + } else @intFromPtr(path); const flags: u32 = os.O.CLOEXEC | os.O.RDWR | os.O.CREAT; const mode: os.mode_t = 0o666; @@ -2098,7 +2098,7 @@ test "sendmsg/recvmsg" { try testing.expectEqual(@as(u32, 2), ring.cq_ready()); const cqe_sendmsg = try ring.copy_cqe(); - if (cqe_sendmsg.res == -@as(i32, @enumToInt(linux.E.INVAL))) return error.SkipZigTest; + if (cqe_sendmsg.res == -@as(i32, @intFromEnum(linux.E.INVAL))) return error.SkipZigTest; try testing.expectEqual(linux.io_uring_cqe{ .user_data = 0x11111111, .res = buffer_send.len, @@ -2106,7 +2106,7 @@ test "sendmsg/recvmsg" { }, cqe_sendmsg); const cqe_recvmsg = try ring.copy_cqe(); - if (cqe_recvmsg.res == -@as(i32, @enumToInt(linux.E.INVAL))) return error.SkipZigTest; + if (cqe_recvmsg.res == -@as(i32, @intFromEnum(linux.E.INVAL))) return error.SkipZigTest; try testing.expectEqual(linux.io_uring_cqe{ .user_data = 0x22222222, .res = buffer_recv.len, @@ -2140,12 +2140,12 @@ test "timeout (after a relative time)" { try testing.expectEqual(linux.io_uring_cqe{ .user_data = 0x55555555, - .res = -@as(i32, @enumToInt(linux.E.TIME)), + .res = -@as(i32, @intFromEnum(linux.E.TIME)), .flags = 0, }, cqe); // Tests should not depend on timings: skip test if outside margin. - if (!std.math.approxEqAbs(f64, ms, @intToFloat(f64, stopped - started), margin)) return error.SkipZigTest; + if (!std.math.approxEqAbs(f64, ms, @floatFromInt(f64, stopped - started), margin)) return error.SkipZigTest; } test "timeout (after a number of completions)" { @@ -2227,7 +2227,7 @@ test "timeout_remove" { if (cqe.user_data == 0x88888888) { try testing.expectEqual(linux.io_uring_cqe{ .user_data = 0x88888888, - .res = -@as(i32, @enumToInt(linux.E.CANCELED)), + .res = -@as(i32, @intFromEnum(linux.E.CANCELED)), .flags = 0, }, cqe); } else if (cqe.user_data == 0x99999999) { @@ -2274,16 +2274,16 @@ test "accept/connect/recv/link_timeout" { const cqe = try ring.copy_cqe(); switch (cqe.user_data) { 0xffffffff => { - if (cqe.res != -@as(i32, @enumToInt(linux.E.INTR)) and - cqe.res != -@as(i32, @enumToInt(linux.E.CANCELED))) + if (cqe.res != -@as(i32, @intFromEnum(linux.E.INTR)) and + cqe.res != -@as(i32, @intFromEnum(linux.E.CANCELED))) { std.debug.print("Req 0x{x} got {d}\n", .{ cqe.user_data, cqe.res }); try testing.expect(false); } }, 0x22222222 => { - if (cqe.res != -@as(i32, @enumToInt(linux.E.ALREADY)) and - cqe.res != -@as(i32, @enumToInt(linux.E.TIME))) + if (cqe.res != -@as(i32, @intFromEnum(linux.E.ALREADY)) and + cqe.res != -@as(i32, @intFromEnum(linux.E.TIME))) { std.debug.print("Req 0x{x} got {d}\n", .{ cqe.user_data, cqe.res }); try testing.expect(false); @@ -2439,7 +2439,7 @@ test "accept/connect/recv/cancel" { try testing.expectEqual(linux.io_uring_cqe{ .user_data = 0xffffffff, - .res = -@as(i32, @enumToInt(linux.E.CANCELED)), + .res = -@as(i32, @intFromEnum(linux.E.CANCELED)), .flags = 0, }, cqe_recv); diff --git a/lib/std/os/linux/mips.zig b/lib/std/os/linux/mips.zig index 66d204dfe132..781003bedc85 100644 --- a/lib/std/os/linux/mips.zig +++ b/lib/std/os/linux/mips.zig @@ -18,7 +18,7 @@ pub fn syscall0(number: SYS) usize { \\ subu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), : "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" ); } @@ -37,7 +37,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize { \\ sw $3, 4($4) \\ 2: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(SYS.pipe)), + : [number] "{$2}" (@intFromEnum(SYS.pipe)), [fd] "{$4}" (fd), : "$1", "$3", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" ); @@ -50,7 +50,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize { \\ subu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), : "$1", "$3", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" ); @@ -63,7 +63,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { \\ subu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), [arg2] "{$5}" (arg2), : "$1", "$3", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" @@ -77,7 +77,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { \\ subu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), [arg2] "{$5}" (arg2), [arg3] "{$6}" (arg3), @@ -92,7 +92,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) \\ subu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), [arg2] "{$5}" (arg2), [arg3] "{$6}" (arg3), @@ -112,7 +112,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, \\ subu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), [arg2] "{$5}" (arg2), [arg3] "{$6}" (arg3), @@ -145,7 +145,7 @@ pub fn syscall6( \\ subu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), [arg2] "{$5}" (arg2), [arg3] "{$6}" (arg3), @@ -178,7 +178,7 @@ pub fn syscall7( \\ subu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), [arg2] "{$5}" (arg2), [arg3] "{$6}" (arg3), @@ -198,7 +198,7 @@ pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: * pub fn restore() callconv(.Naked) void { return asm volatile ("syscall" : - : [number] "{$2}" (@enumToInt(SYS.sigreturn)), + : [number] "{$2}" (@intFromEnum(SYS.sigreturn)), : "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" ); } @@ -206,7 +206,7 @@ pub fn restore() callconv(.Naked) void { pub fn restore_rt() callconv(.Naked) void { return asm volatile ("syscall" : - : [number] "{$2}" (@enumToInt(SYS.rt_sigreturn)), + : [number] "{$2}" (@intFromEnum(SYS.rt_sigreturn)), : "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" ); } diff --git a/lib/std/os/linux/mips64.zig b/lib/std/os/linux/mips64.zig index dfc1c9b5761f..8d55dee37f25 100644 --- a/lib/std/os/linux/mips64.zig +++ b/lib/std/os/linux/mips64.zig @@ -18,7 +18,7 @@ pub fn syscall0(number: SYS) usize { \\ dsubu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), : "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" ); } @@ -37,7 +37,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize { \\ sw $3, 4($4) \\ 2: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(SYS.pipe)), + : [number] "{$2}" (@intFromEnum(SYS.pipe)), [fd] "{$4}" (fd), : "$1", "$3", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" ); @@ -50,7 +50,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize { \\ dsubu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), : "$1", "$3", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" ); @@ -63,7 +63,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { \\ dsubu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), [arg2] "{$5}" (arg2), : "$1", "$3", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" @@ -77,7 +77,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { \\ dsubu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), [arg2] "{$5}" (arg2), [arg3] "{$6}" (arg3), @@ -92,7 +92,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) \\ dsubu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), [arg2] "{$5}" (arg2), [arg3] "{$6}" (arg3), @@ -108,7 +108,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, \\ dsubu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), [arg2] "{$5}" (arg2), [arg3] "{$6}" (arg3), @@ -136,7 +136,7 @@ pub fn syscall6( \\ dsubu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), [arg2] "{$5}" (arg2), [arg3] "{$6}" (arg3), @@ -163,7 +163,7 @@ pub fn syscall7( \\ dsubu $2, $0, $2 \\ 1: : [ret] "={$2}" (-> usize), - : [number] "{$2}" (@enumToInt(number)), + : [number] "{$2}" (@intFromEnum(number)), [arg1] "{$4}" (arg1), [arg2] "{$5}" (arg2), [arg3] "{$6}" (arg3), @@ -183,7 +183,7 @@ pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: * pub fn restore() callconv(.Naked) void { return asm volatile ("syscall" : - : [number] "{$2}" (@enumToInt(SYS.rt_sigreturn)), + : [number] "{$2}" (@intFromEnum(SYS.rt_sigreturn)), : "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" ); } @@ -191,7 +191,7 @@ pub fn restore() callconv(.Naked) void { pub fn restore_rt() callconv(.Naked) void { return asm volatile ("syscall" : - : [number] "{$2}" (@enumToInt(SYS.rt_sigreturn)), + : [number] "{$2}" (@intFromEnum(SYS.rt_sigreturn)), : "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory" ); } diff --git a/lib/std/os/linux/powerpc.zig b/lib/std/os/linux/powerpc.zig index 6d2d408adf90..31c30f2d3068 100644 --- a/lib/std/os/linux/powerpc.zig +++ b/lib/std/os/linux/powerpc.zig @@ -20,7 +20,7 @@ pub fn syscall0(number: SYS) usize { \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" ); } @@ -32,7 +32,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize { \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), [arg1] "{r3}" (arg1), : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" ); @@ -45,7 +45,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), [arg1] "{r3}" (arg1), [arg2] "{r4}" (arg2), : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" @@ -59,7 +59,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), [arg1] "{r3}" (arg1), [arg2] "{r4}" (arg2), [arg3] "{r5}" (arg3), @@ -74,7 +74,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), [arg1] "{r3}" (arg1), [arg2] "{r4}" (arg2), [arg3] "{r5}" (arg3), @@ -90,7 +90,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), [arg1] "{r3}" (arg1), [arg2] "{r4}" (arg2), [arg3] "{r5}" (arg3), @@ -115,7 +115,7 @@ pub fn syscall6( \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), [arg1] "{r3}" (arg1), [arg2] "{r4}" (arg2), [arg3] "{r5}" (arg3), @@ -136,7 +136,7 @@ pub const restore = restore_rt; pub fn restore_rt() callconv(.Naked) void { return asm volatile ("sc" : - : [number] "{r0}" (@enumToInt(SYS.rt_sigreturn)), + : [number] "{r0}" (@intFromEnum(SYS.rt_sigreturn)), : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" ); } diff --git a/lib/std/os/linux/powerpc64.zig b/lib/std/os/linux/powerpc64.zig index ab0da460d8fe..722bd646878e 100644 --- a/lib/std/os/linux/powerpc64.zig +++ b/lib/std/os/linux/powerpc64.zig @@ -20,7 +20,7 @@ pub fn syscall0(number: SYS) usize { \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" ); } @@ -32,7 +32,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize { \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), [arg1] "{r3}" (arg1), : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" ); @@ -45,7 +45,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), [arg1] "{r3}" (arg1), [arg2] "{r4}" (arg2), : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" @@ -59,7 +59,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), [arg1] "{r3}" (arg1), [arg2] "{r4}" (arg2), [arg3] "{r5}" (arg3), @@ -74,7 +74,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), [arg1] "{r3}" (arg1), [arg2] "{r4}" (arg2), [arg3] "{r5}" (arg3), @@ -90,7 +90,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), [arg1] "{r3}" (arg1), [arg2] "{r4}" (arg2), [arg3] "{r5}" (arg3), @@ -115,7 +115,7 @@ pub fn syscall6( \\ neg 3, 3 \\ 1: : [ret] "={r3}" (-> usize), - : [number] "{r0}" (@enumToInt(number)), + : [number] "{r0}" (@intFromEnum(number)), [arg1] "{r3}" (arg1), [arg2] "{r4}" (arg2), [arg3] "{r5}" (arg3), @@ -136,7 +136,7 @@ pub const restore = restore_rt; pub fn restore_rt() callconv(.Naked) void { return asm volatile ("sc" : - : [number] "{r0}" (@enumToInt(SYS.rt_sigreturn)), + : [number] "{r0}" (@intFromEnum(SYS.rt_sigreturn)), : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" ); } diff --git a/lib/std/os/linux/riscv64.zig b/lib/std/os/linux/riscv64.zig index 627bb8498ec2..cbdaa76282c0 100644 --- a/lib/std/os/linux/riscv64.zig +++ b/lib/std/os/linux/riscv64.zig @@ -13,7 +13,7 @@ const timespec = std.os.linux.timespec; pub fn syscall0(number: SYS) usize { return asm volatile ("ecall" : [ret] "={x10}" (-> usize), - : [number] "{x17}" (@enumToInt(number)), + : [number] "{x17}" (@intFromEnum(number)), : "memory" ); } @@ -21,7 +21,7 @@ pub fn syscall0(number: SYS) usize { pub fn syscall1(number: SYS, arg1: usize) usize { return asm volatile ("ecall" : [ret] "={x10}" (-> usize), - : [number] "{x17}" (@enumToInt(number)), + : [number] "{x17}" (@intFromEnum(number)), [arg1] "{x10}" (arg1), : "memory" ); @@ -30,7 +30,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { return asm volatile ("ecall" : [ret] "={x10}" (-> usize), - : [number] "{x17}" (@enumToInt(number)), + : [number] "{x17}" (@intFromEnum(number)), [arg1] "{x10}" (arg1), [arg2] "{x11}" (arg2), : "memory" @@ -40,7 +40,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { return asm volatile ("ecall" : [ret] "={x10}" (-> usize), - : [number] "{x17}" (@enumToInt(number)), + : [number] "{x17}" (@intFromEnum(number)), [arg1] "{x10}" (arg1), [arg2] "{x11}" (arg2), [arg3] "{x12}" (arg3), @@ -51,7 +51,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { return asm volatile ("ecall" : [ret] "={x10}" (-> usize), - : [number] "{x17}" (@enumToInt(number)), + : [number] "{x17}" (@intFromEnum(number)), [arg1] "{x10}" (arg1), [arg2] "{x11}" (arg2), [arg3] "{x12}" (arg3), @@ -63,7 +63,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { return asm volatile ("ecall" : [ret] "={x10}" (-> usize), - : [number] "{x17}" (@enumToInt(number)), + : [number] "{x17}" (@intFromEnum(number)), [arg1] "{x10}" (arg1), [arg2] "{x11}" (arg2), [arg3] "{x12}" (arg3), @@ -84,7 +84,7 @@ pub fn syscall6( ) usize { return asm volatile ("ecall" : [ret] "={x10}" (-> usize), - : [number] "{x17}" (@enumToInt(number)), + : [number] "{x17}" (@intFromEnum(number)), [arg1] "{x10}" (arg1), [arg2] "{x11}" (arg2), [arg3] "{x12}" (arg3), @@ -104,7 +104,7 @@ pub const restore = restore_rt; pub fn restore_rt() callconv(.Naked) void { return asm volatile ("ecall" : - : [number] "{x17}" (@enumToInt(SYS.rt_sigreturn)), + : [number] "{x17}" (@intFromEnum(SYS.rt_sigreturn)), : "memory" ); } diff --git a/lib/std/os/linux/sparc64.zig b/lib/std/os/linux/sparc64.zig index ca1256cb2ee7..c741df989777 100644 --- a/lib/std/os/linux/sparc64.zig +++ b/lib/std/os/linux/sparc64.zig @@ -29,7 +29,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize { \\ clr %%o0 \\2: : [ret] "={o0}" (-> usize), - : [number] "{g1}" (@enumToInt(SYS.pipe)), + : [number] "{g1}" (@intFromEnum(SYS.pipe)), [arg] "r" (fd), : "memory", "g3" ); @@ -53,7 +53,7 @@ pub fn syscall_fork() usize { \\ and %%o1, %%o0, %%o0 \\ 2: : [ret] "={o0}" (-> usize), - : [number] "{g1}" (@enumToInt(SYS.fork)), + : [number] "{g1}" (@intFromEnum(SYS.fork)), : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" ); } @@ -66,7 +66,7 @@ pub fn syscall0(number: SYS) usize { \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), - : [number] "{g1}" (@enumToInt(number)), + : [number] "{g1}" (@intFromEnum(number)), : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" ); } @@ -79,7 +79,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize { \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), - : [number] "{g1}" (@enumToInt(number)), + : [number] "{g1}" (@intFromEnum(number)), [arg1] "{o0}" (arg1), : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" ); @@ -93,7 +93,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), - : [number] "{g1}" (@enumToInt(number)), + : [number] "{g1}" (@intFromEnum(number)), [arg1] "{o0}" (arg1), [arg2] "{o1}" (arg2), : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" @@ -108,7 +108,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), - : [number] "{g1}" (@enumToInt(number)), + : [number] "{g1}" (@intFromEnum(number)), [arg1] "{o0}" (arg1), [arg2] "{o1}" (arg2), [arg3] "{o2}" (arg3), @@ -124,7 +124,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), - : [number] "{g1}" (@enumToInt(number)), + : [number] "{g1}" (@intFromEnum(number)), [arg1] "{o0}" (arg1), [arg2] "{o1}" (arg2), [arg3] "{o2}" (arg3), @@ -141,7 +141,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), - : [number] "{g1}" (@enumToInt(number)), + : [number] "{g1}" (@intFromEnum(number)), [arg1] "{o0}" (arg1), [arg2] "{o1}" (arg2), [arg3] "{o2}" (arg3), @@ -167,7 +167,7 @@ pub fn syscall6( \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), - : [number] "{g1}" (@enumToInt(number)), + : [number] "{g1}" (@intFromEnum(number)), [arg1] "{o0}" (arg1), [arg2] "{o1}" (arg2), [arg3] "{o2}" (arg3), @@ -190,7 +190,7 @@ pub const restore = restore_rt; pub fn restore_rt() callconv(.C) void { return asm volatile ("t 0x6d" : - : [number] "{g1}" (@enumToInt(SYS.rt_sigreturn)), + : [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)), : "memory", "xcc", "o0", "o1", "o2", "o3", "o4", "o5", "o7" ); } diff --git a/lib/std/os/linux/start_pie.zig b/lib/std/os/linux/start_pie.zig index aa1418f4a33e..c9b1cb1e922b 100644 --- a/lib/std/os/linux/start_pie.zig +++ b/lib/std/os/linux/start_pie.zig @@ -78,7 +78,7 @@ pub fn relocate(phdrs: []elf.Phdr) void { const base_addr = base: { for (phdrs) |*phdr| { if (phdr.p_type != elf.PT_DYNAMIC) continue; - break :base @ptrToInt(dynv) - phdr.p_vaddr; + break :base @intFromPtr(dynv) - phdr.p_vaddr; } // This is not supposed to happen for well-formed binaries. std.os.abort(); @@ -103,17 +103,17 @@ pub fn relocate(phdrs: []elf.Phdr) void { // Apply the relocations. if (rel_addr != 0) { - const rel = std.mem.bytesAsSlice(elf.Rel, @intToPtr([*]u8, rel_addr)[0..rel_size]); + const rel = std.mem.bytesAsSlice(elf.Rel, @ptrFromInt([*]u8, rel_addr)[0..rel_size]); for (rel) |r| { if (r.r_type() != R_RELATIVE) continue; - @intToPtr(*usize, base_addr + r.r_offset).* += base_addr; + @ptrFromInt(*usize, base_addr + r.r_offset).* += base_addr; } } if (rela_addr != 0) { - const rela = std.mem.bytesAsSlice(elf.Rela, @intToPtr([*]u8, rela_addr)[0..rela_size]); + const rela = std.mem.bytesAsSlice(elf.Rela, @ptrFromInt([*]u8, rela_addr)[0..rela_size]); for (rela) |r| { if (r.r_type() != R_RELATIVE) continue; - @intToPtr(*usize, base_addr + r.r_offset).* += base_addr + @bitCast(usize, r.r_addend); + @ptrFromInt(*usize, base_addr + r.r_offset).* += base_addr + @bitCast(usize, r.r_addend); } } } diff --git a/lib/std/os/linux/thumb.zig b/lib/std/os/linux/thumb.zig index 6ac51afb7880..ec514ca5de42 100644 --- a/lib/std/os/linux/thumb.zig +++ b/lib/std/os/linux/thumb.zig @@ -10,7 +10,7 @@ const SYS = linux.SYS; pub fn syscall0(number: SYS) usize { @setRuntimeSafety(false); - var buf: [2]usize = .{ @enumToInt(number), undefined }; + var buf: [2]usize = .{ @intFromEnum(number), undefined }; return asm volatile ( \\ str r7, [%[tmp], #4] \\ ldr r7, [%[tmp]] @@ -25,7 +25,7 @@ pub fn syscall0(number: SYS) usize { pub fn syscall1(number: SYS, arg1: usize) usize { @setRuntimeSafety(false); - var buf: [2]usize = .{ @enumToInt(number), undefined }; + var buf: [2]usize = .{ @intFromEnum(number), undefined }; return asm volatile ( \\ str r7, [%[tmp], #4] \\ ldr r7, [%[tmp]] @@ -41,7 +41,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { @setRuntimeSafety(false); - var buf: [2]usize = .{ @enumToInt(number), undefined }; + var buf: [2]usize = .{ @intFromEnum(number), undefined }; return asm volatile ( \\ str r7, [%[tmp], #4] \\ ldr r7, [%[tmp]] @@ -58,7 +58,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { @setRuntimeSafety(false); - var buf: [2]usize = .{ @enumToInt(number), undefined }; + var buf: [2]usize = .{ @intFromEnum(number), undefined }; return asm volatile ( \\ str r7, [%[tmp], #4] \\ ldr r7, [%[tmp]] @@ -76,7 +76,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { @setRuntimeSafety(false); - var buf: [2]usize = .{ @enumToInt(number), undefined }; + var buf: [2]usize = .{ @intFromEnum(number), undefined }; return asm volatile ( \\ str r7, [%[tmp], #4] \\ ldr r7, [%[tmp]] @@ -95,7 +95,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { @setRuntimeSafety(false); - var buf: [2]usize = .{ @enumToInt(number), undefined }; + var buf: [2]usize = .{ @intFromEnum(number), undefined }; return asm volatile ( \\ str r7, [%[tmp], #4] \\ ldr r7, [%[tmp]] @@ -123,7 +123,7 @@ pub fn syscall6( ) usize { @setRuntimeSafety(false); - var buf: [2]usize = .{ @enumToInt(number), undefined }; + var buf: [2]usize = .{ @intFromEnum(number), undefined }; return asm volatile ( \\ str r7, [%[tmp], #4] \\ ldr r7, [%[tmp]] @@ -146,7 +146,7 @@ pub fn restore() callconv(.Naked) void { \\ mov r7, %[number] \\ svc #0 : - : [number] "I" (@enumToInt(SYS.sigreturn)), + : [number] "I" (@intFromEnum(SYS.sigreturn)), ); } @@ -155,7 +155,7 @@ pub fn restore_rt() callconv(.Naked) void { \\ mov r7, %[number] \\ svc #0 : - : [number] "I" (@enumToInt(SYS.rt_sigreturn)), + : [number] "I" (@intFromEnum(SYS.rt_sigreturn)), : "memory" ); } diff --git a/lib/std/os/linux/tls.zig b/lib/std/os/linux/tls.zig index d765e403c8d4..b60a2ed38897 100644 --- a/lib/std/os/linux/tls.zig +++ b/lib/std/os/linux/tls.zig @@ -122,7 +122,7 @@ pub fn setThreadPointer(addr: usize) void { .seg_not_present = 0, .useable = 1, }; - const rc = std.os.linux.syscall1(.set_thread_area, @ptrToInt(&user_desc)); + const rc = std.os.linux.syscall1(.set_thread_area, @intFromPtr(&user_desc)); assert(rc == 0); const gdt_entry_number = user_desc.entry_number; @@ -191,7 +191,7 @@ fn initTLS(phdrs: []elf.Phdr) void { for (phdrs) |*phdr| { switch (phdr.p_type) { - elf.PT_PHDR => img_base = @ptrToInt(phdrs.ptr) - phdr.p_vaddr, + elf.PT_PHDR => img_base = @intFromPtr(phdrs.ptr) - phdr.p_vaddr, elf.PT_TLS => tls_phdr = phdr, else => {}, } @@ -205,7 +205,7 @@ fn initTLS(phdrs: []elf.Phdr) void { // the data stored in the PT_TLS segment is p_filesz and may be less // than the former tls_align_factor = phdr.p_align; - tls_data = @intToPtr([*]u8, img_base + phdr.p_vaddr)[0..phdr.p_filesz]; + tls_data = @ptrFromInt([*]u8, img_base + phdr.p_vaddr)[0..phdr.p_filesz]; tls_data_alloc_size = phdr.p_memsz; } else { tls_align_factor = @alignOf(usize); @@ -292,7 +292,7 @@ pub fn prepareTLS(area: []u8) usize { // Return the corrected value (if needed) for the tp register. // Overflow here is not a problem, the pointer arithmetic involving the tp // is done with wrapping semantics. - return @ptrToInt(area.ptr) +% tls_tp_offset +% + return @intFromPtr(area.ptr) +% tls_tp_offset +% if (tls_tp_points_past_tcb) tls_image.data_offset else tls_image.tcb_offset; } @@ -328,7 +328,7 @@ pub fn initStaticTLS(phdrs: []elf.Phdr) void { ) catch os.abort(); // Make sure the slice is correctly aligned. - const begin_addr = @ptrToInt(alloc_tls_area.ptr); + const begin_addr = @intFromPtr(alloc_tls_area.ptr); const begin_aligned_addr = mem.alignForward(usize, begin_addr, tls_image.alloc_align); const start = begin_aligned_addr - begin_addr; break :blk alloc_tls_area[start .. start + tls_image.alloc_size]; diff --git a/lib/std/os/linux/vdso.zig b/lib/std/os/linux/vdso.zig index dc2f85776da1..c7dc7ae59991 100644 --- a/lib/std/os/linux/vdso.zig +++ b/lib/std/os/linux/vdso.zig @@ -8,7 +8,7 @@ pub fn lookup(vername: []const u8, name: []const u8) usize { const vdso_addr = std.os.system.getauxval(std.elf.AT_SYSINFO_EHDR); if (vdso_addr == 0) return 0; - const eh = @intToPtr(*elf.Ehdr, vdso_addr); + const eh = @ptrFromInt(*elf.Ehdr, vdso_addr); var ph_addr: usize = vdso_addr + eh.e_phoff; var maybe_dynv: ?[*]usize = null; @@ -19,14 +19,14 @@ pub fn lookup(vername: []const u8, name: []const u8) usize { i += 1; ph_addr += eh.e_phentsize; }) { - const this_ph = @intToPtr(*elf.Phdr, ph_addr); + const this_ph = @ptrFromInt(*elf.Phdr, ph_addr); switch (this_ph.p_type) { // On WSL1 as well as older kernels, the VDSO ELF image is pre-linked in the upper half // of the memory space (e.g. p_vaddr = 0xffffffffff700000 on WSL1). // Wrapping operations are used on this line as well as subsequent calculations relative to base // (lines 47, 78) to ensure no overflow check is tripped. elf.PT_LOAD => base = vdso_addr +% this_ph.p_offset -% this_ph.p_vaddr, - elf.PT_DYNAMIC => maybe_dynv = @intToPtr([*]usize, vdso_addr + this_ph.p_offset), + elf.PT_DYNAMIC => maybe_dynv = @ptrFromInt([*]usize, vdso_addr + this_ph.p_offset), else => {}, } } @@ -45,11 +45,11 @@ pub fn lookup(vername: []const u8, name: []const u8) usize { while (dynv[i] != 0) : (i += 2) { const p = base +% dynv[i + 1]; switch (dynv[i]) { - elf.DT_STRTAB => maybe_strings = @intToPtr([*]u8, p), - elf.DT_SYMTAB => maybe_syms = @intToPtr([*]elf.Sym, p), - elf.DT_HASH => maybe_hashtab = @intToPtr([*]linux.Elf_Symndx, p), - elf.DT_VERSYM => maybe_versym = @intToPtr([*]u16, p), - elf.DT_VERDEF => maybe_verdef = @intToPtr(*elf.Verdef, p), + elf.DT_STRTAB => maybe_strings = @ptrFromInt([*]u8, p), + elf.DT_SYMTAB => maybe_syms = @ptrFromInt([*]elf.Sym, p), + elf.DT_HASH => maybe_hashtab = @ptrFromInt([*]linux.Elf_Symndx, p), + elf.DT_VERSYM => maybe_versym = @ptrFromInt([*]u16, p), + elf.DT_VERDEF => maybe_verdef = @ptrFromInt(*elf.Verdef, p), else => {}, } } @@ -88,9 +88,9 @@ fn checkver(def_arg: *elf.Verdef, vsym_arg: i32, vername: []const u8, strings: [ break; if (def.vd_next == 0) return false; - def = @intToPtr(*elf.Verdef, @ptrToInt(def) + def.vd_next); + def = @ptrFromInt(*elf.Verdef, @intFromPtr(def) + def.vd_next); } - const aux = @intToPtr(*elf.Verdaux, @ptrToInt(def) + def.vd_aux); + const aux = @ptrFromInt(*elf.Verdaux, @intFromPtr(def) + def.vd_aux); const vda_name = @ptrCast([*:0]u8, strings + aux.vda_name); return mem.eql(u8, vername, mem.sliceTo(vda_name, 0)); } diff --git a/lib/std/os/linux/x86.zig b/lib/std/os/linux/x86.zig index c9274e11eecf..05c012c77cdb 100644 --- a/lib/std/os/linux/x86.zig +++ b/lib/std/os/linux/x86.zig @@ -16,7 +16,7 @@ const timespec = linux.timespec; pub fn syscall0(number: SYS) usize { return asm volatile ("int $0x80" : [ret] "={eax}" (-> usize), - : [number] "{eax}" (@enumToInt(number)), + : [number] "{eax}" (@intFromEnum(number)), : "memory" ); } @@ -24,7 +24,7 @@ pub fn syscall0(number: SYS) usize { pub fn syscall1(number: SYS, arg1: usize) usize { return asm volatile ("int $0x80" : [ret] "={eax}" (-> usize), - : [number] "{eax}" (@enumToInt(number)), + : [number] "{eax}" (@intFromEnum(number)), [arg1] "{ebx}" (arg1), : "memory" ); @@ -33,7 +33,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { return asm volatile ("int $0x80" : [ret] "={eax}" (-> usize), - : [number] "{eax}" (@enumToInt(number)), + : [number] "{eax}" (@intFromEnum(number)), [arg1] "{ebx}" (arg1), [arg2] "{ecx}" (arg2), : "memory" @@ -43,7 +43,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { return asm volatile ("int $0x80" : [ret] "={eax}" (-> usize), - : [number] "{eax}" (@enumToInt(number)), + : [number] "{eax}" (@intFromEnum(number)), [arg1] "{ebx}" (arg1), [arg2] "{ecx}" (arg2), [arg3] "{edx}" (arg3), @@ -54,7 +54,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { return asm volatile ("int $0x80" : [ret] "={eax}" (-> usize), - : [number] "{eax}" (@enumToInt(number)), + : [number] "{eax}" (@intFromEnum(number)), [arg1] "{ebx}" (arg1), [arg2] "{ecx}" (arg2), [arg3] "{edx}" (arg3), @@ -66,7 +66,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { return asm volatile ("int $0x80" : [ret] "={eax}" (-> usize), - : [number] "{eax}" (@enumToInt(number)), + : [number] "{eax}" (@intFromEnum(number)), [arg1] "{ebx}" (arg1), [arg2] "{ecx}" (arg2), [arg3] "{edx}" (arg3), @@ -97,7 +97,7 @@ pub fn syscall6( \\ pop %%ebp \\ add $4, %%esp : [ret] "={eax}" (-> usize), - : [number] "{eax}" (@enumToInt(number)), + : [number] "{eax}" (@intFromEnum(number)), [arg1] "{ebx}" (arg1), [arg2] "{ecx}" (arg2), [arg3] "{edx}" (arg3), @@ -111,9 +111,9 @@ pub fn syscall6( pub fn socketcall(call: usize, args: [*]const usize) usize { return asm volatile ("int $0x80" : [ret] "={eax}" (-> usize), - : [number] "{eax}" (@enumToInt(SYS.socketcall)), + : [number] "{eax}" (@intFromEnum(SYS.socketcall)), [arg1] "{ebx}" (call), - [arg2] "{ecx}" (@ptrToInt(args)), + [arg2] "{ecx}" (@intFromPtr(args)), : "memory" ); } @@ -130,14 +130,14 @@ pub fn restore() callconv(.Naked) void { \\ int $0x80 \\ ret : - : [number] "i" (@enumToInt(SYS.sigreturn)), + : [number] "i" (@intFromEnum(SYS.sigreturn)), : "memory" ), else => asm volatile ( \\ int $0x80 \\ ret : - : [number] "{eax}" (@enumToInt(SYS.sigreturn)), + : [number] "{eax}" (@intFromEnum(SYS.sigreturn)), : "memory" ), } @@ -151,14 +151,14 @@ pub fn restore_rt() callconv(.Naked) void { \\ int $0x80 \\ ret : - : [number] "i" (@enumToInt(SYS.rt_sigreturn)), + : [number] "i" (@intFromEnum(SYS.rt_sigreturn)), : "memory" ), else => asm volatile ( \\ int $0x80 \\ ret : - : [number] "{eax}" (@enumToInt(SYS.rt_sigreturn)), + : [number] "{eax}" (@intFromEnum(SYS.rt_sigreturn)), : "memory" ), } diff --git a/lib/std/os/linux/x86_64.zig b/lib/std/os/linux/x86_64.zig index 09047bda83e9..41c9c9ea46ca 100644 --- a/lib/std/os/linux/x86_64.zig +++ b/lib/std/os/linux/x86_64.zig @@ -18,7 +18,7 @@ const timespec = linux.timespec; pub fn syscall0(number: SYS) usize { return asm volatile ("syscall" : [ret] "={rax}" (-> usize), - : [number] "{rax}" (@enumToInt(number)), + : [number] "{rax}" (@intFromEnum(number)), : "rcx", "r11", "memory" ); } @@ -26,7 +26,7 @@ pub fn syscall0(number: SYS) usize { pub fn syscall1(number: SYS, arg1: usize) usize { return asm volatile ("syscall" : [ret] "={rax}" (-> usize), - : [number] "{rax}" (@enumToInt(number)), + : [number] "{rax}" (@intFromEnum(number)), [arg1] "{rdi}" (arg1), : "rcx", "r11", "memory" ); @@ -35,7 +35,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize { pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { return asm volatile ("syscall" : [ret] "={rax}" (-> usize), - : [number] "{rax}" (@enumToInt(number)), + : [number] "{rax}" (@intFromEnum(number)), [arg1] "{rdi}" (arg1), [arg2] "{rsi}" (arg2), : "rcx", "r11", "memory" @@ -45,7 +45,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { return asm volatile ("syscall" : [ret] "={rax}" (-> usize), - : [number] "{rax}" (@enumToInt(number)), + : [number] "{rax}" (@intFromEnum(number)), [arg1] "{rdi}" (arg1), [arg2] "{rsi}" (arg2), [arg3] "{rdx}" (arg3), @@ -56,7 +56,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { return asm volatile ("syscall" : [ret] "={rax}" (-> usize), - : [number] "{rax}" (@enumToInt(number)), + : [number] "{rax}" (@intFromEnum(number)), [arg1] "{rdi}" (arg1), [arg2] "{rsi}" (arg2), [arg3] "{rdx}" (arg3), @@ -68,7 +68,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { return asm volatile ("syscall" : [ret] "={rax}" (-> usize), - : [number] "{rax}" (@enumToInt(number)), + : [number] "{rax}" (@intFromEnum(number)), [arg1] "{rdi}" (arg1), [arg2] "{rsi}" (arg2), [arg3] "{rdx}" (arg3), @@ -89,7 +89,7 @@ pub fn syscall6( ) usize { return asm volatile ("syscall" : [ret] "={rax}" (-> usize), - : [number] "{rax}" (@enumToInt(number)), + : [number] "{rax}" (@intFromEnum(number)), [arg1] "{rdi}" (arg1), [arg2] "{rsi}" (arg2), [arg3] "{rdx}" (arg3), @@ -114,14 +114,14 @@ pub fn restore_rt() callconv(.Naked) void { \\ syscall \\ retq : - : [number] "i" (@enumToInt(SYS.rt_sigreturn)), + : [number] "i" (@intFromEnum(SYS.rt_sigreturn)), : "rcx", "r11", "memory" ), else => asm volatile ( \\ syscall \\ retq : - : [number] "{rax}" (@enumToInt(SYS.rt_sigreturn)), + : [number] "{rax}" (@intFromEnum(SYS.rt_sigreturn)), : "rcx", "r11", "memory" ), } diff --git a/lib/std/os/plan9.zig b/lib/std/os/plan9.zig index 1f46915b27d9..b628bc2afced 100644 --- a/lib/std/os/plan9.zig +++ b/lib/std/os/plan9.zig @@ -10,7 +10,7 @@ pub const E = @import("plan9/errno.zig").E; pub fn getErrno(r: usize) E { const signed_r = @bitCast(isize, r); const int = if (signed_r > -4096 and signed_r < 0) -signed_r else 0; - return @intToEnum(E, int); + return @enumFromInt(E, int); } pub const SIG = struct { /// hangup @@ -133,19 +133,19 @@ pub const SYS = enum(usize) { }; pub fn pwrite(fd: usize, buf: [*]const u8, count: usize, offset: usize) usize { - return syscall_bits.syscall4(.PWRITE, fd, @ptrToInt(buf), count, offset); + return syscall_bits.syscall4(.PWRITE, fd, @intFromPtr(buf), count, offset); } pub fn pread(fd: usize, buf: [*]const u8, count: usize, offset: usize) usize { - return syscall_bits.syscall4(.PREAD, fd, @ptrToInt(buf), count, offset); + return syscall_bits.syscall4(.PREAD, fd, @intFromPtr(buf), count, offset); } pub fn open(path: [*:0]const u8, omode: OpenMode) usize { - return syscall_bits.syscall2(.OPEN, @ptrToInt(path), @enumToInt(omode)); + return syscall_bits.syscall2(.OPEN, @intFromPtr(path), @intFromEnum(omode)); } pub fn create(path: [*:0]const u8, omode: OpenMode, perms: usize) usize { - return syscall_bits.syscall3(.CREATE, @ptrToInt(path), @enumToInt(omode), perms); + return syscall_bits.syscall3(.CREATE, @intFromPtr(path), @intFromEnum(omode), perms); } pub fn exit(status: u8) noreturn { @@ -159,7 +159,7 @@ pub fn exit(status: u8) noreturn { } pub fn exits(status: ?[*:0]const u8) noreturn { - _ = syscall_bits.syscall1(.EXITS, if (status) |s| @ptrToInt(s) else 0); + _ = syscall_bits.syscall1(.EXITS, if (status) |s| @intFromPtr(s) else 0); unreachable; } diff --git a/lib/std/os/plan9/x86_64.zig b/lib/std/os/plan9/x86_64.zig index c68fdc4f0fa2..ce8d44ff46d6 100644 --- a/lib/std/os/plan9/x86_64.zig +++ b/lib/std/os/plan9/x86_64.zig @@ -10,7 +10,7 @@ pub fn syscall1(sys: plan9.SYS, arg0: usize) usize { \\pop %%r11 : [ret] "={rax}" (-> usize), : [arg0] "{r8}" (arg0), - [syscall_number] "{rbp}" (@enumToInt(sys)), + [syscall_number] "{rbp}" (@intFromEnum(sys)), : "rcx", "rax", "rbp", "r11", "memory" ); } @@ -26,7 +26,7 @@ pub fn syscall2(sys: plan9.SYS, arg0: usize, arg1: usize) usize { : [ret] "={rax}" (-> usize), : [arg0] "{r8}" (arg0), [arg1] "{r9}" (arg1), - [syscall_number] "{rbp}" (@enumToInt(sys)), + [syscall_number] "{rbp}" (@intFromEnum(sys)), : "rcx", "rax", "rbp", "r11", "memory" ); } @@ -45,7 +45,7 @@ pub fn syscall3(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize) usize { : [arg0] "{r8}" (arg0), [arg1] "{r9}" (arg1), [arg2] "{r10}" (arg2), - [syscall_number] "{rbp}" (@enumToInt(sys)), + [syscall_number] "{rbp}" (@intFromEnum(sys)), : "rcx", "rax", "rbp", "r11", "memory" ); } @@ -67,7 +67,7 @@ pub fn syscall4(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize, arg3: usi [arg1] "{r9}" (arg1), [arg2] "{r10}" (arg2), [arg3] "{r11}" (arg3), - [syscall_number] "{rbp}" (@enumToInt(sys)), + [syscall_number] "{rbp}" (@intFromEnum(sys)), : "rcx", "rax", "rbp", "r11", "memory" ); } diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index 59575e0109fb..888b2f5c1cf3 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -488,7 +488,7 @@ fn iter_fn(info: *dl_phdr_info, size: usize, counter: *usize) IterFnError!void { const reloc_addr = info.dlpi_addr + phdr.p_vaddr; // Find the ELF header - const elf_header = @intToPtr(*elf.Ehdr, reloc_addr - phdr.p_offset); + const elf_header = @ptrFromInt(*elf.Ehdr, reloc_addr - phdr.p_offset); // Validate the magic if (!mem.eql(u8, elf_header.e_ident[0..4], elf.MAGIC)) return error.BadElfMagic; // Consistency check @@ -751,7 +751,7 @@ test "getrlimit and setrlimit" { } inline for (std.meta.fields(os.rlimit_resource)) |field| { - const resource = @intToEnum(os.rlimit_resource, field.value); + const resource = @enumFromInt(os.rlimit_resource, field.value); const limit = try os.getrlimit(resource); // On 32 bit MIPS musl includes a fix which changes limits greater than -1UL/2 to RLIM_INFINITY. @@ -931,10 +931,10 @@ test "POSIX file locking with fcntl" { // Place an exclusive lock on the first byte, and a shared lock on the second byte: var struct_flock = std.mem.zeroInit(os.Flock, .{ .type = os.F.WRLCK }); - _ = try os.fcntl(fd, os.F.SETLK, @ptrToInt(&struct_flock)); + _ = try os.fcntl(fd, os.F.SETLK, @intFromPtr(&struct_flock)); struct_flock.start = 1; struct_flock.type = os.F.RDLCK; - _ = try os.fcntl(fd, os.F.SETLK, @ptrToInt(&struct_flock)); + _ = try os.fcntl(fd, os.F.SETLK, @intFromPtr(&struct_flock)); // Check the locks in a child process: const pid = try os.fork(); @@ -942,15 +942,15 @@ test "POSIX file locking with fcntl" { // child expects be denied the exclusive lock: struct_flock.start = 0; struct_flock.type = os.F.WRLCK; - try expectError(error.Locked, os.fcntl(fd, os.F.SETLK, @ptrToInt(&struct_flock))); + try expectError(error.Locked, os.fcntl(fd, os.F.SETLK, @intFromPtr(&struct_flock))); // child expects to get the shared lock: struct_flock.start = 1; struct_flock.type = os.F.RDLCK; - _ = try os.fcntl(fd, os.F.SETLK, @ptrToInt(&struct_flock)); + _ = try os.fcntl(fd, os.F.SETLK, @intFromPtr(&struct_flock)); // child waits for the exclusive lock in order to test deadlock: struct_flock.start = 0; struct_flock.type = os.F.WRLCK; - _ = try os.fcntl(fd, os.F.SETLKW, @ptrToInt(&struct_flock)); + _ = try os.fcntl(fd, os.F.SETLKW, @intFromPtr(&struct_flock)); // child exits without continuing: os.exit(0); } else { @@ -959,15 +959,15 @@ test "POSIX file locking with fcntl" { // parent expects deadlock when attempting to upgrade the shared lock to exclusive: struct_flock.start = 1; struct_flock.type = os.F.WRLCK; - try expectError(error.DeadLock, os.fcntl(fd, os.F.SETLKW, @ptrToInt(&struct_flock))); + try expectError(error.DeadLock, os.fcntl(fd, os.F.SETLKW, @intFromPtr(&struct_flock))); // parent releases exclusive lock: struct_flock.start = 0; struct_flock.type = os.F.UNLCK; - _ = try os.fcntl(fd, os.F.SETLK, @ptrToInt(&struct_flock)); + _ = try os.fcntl(fd, os.F.SETLK, @intFromPtr(&struct_flock)); // parent releases shared lock: struct_flock.start = 1; struct_flock.type = os.F.UNLCK; - _ = try os.fcntl(fd, os.F.SETLK, @ptrToInt(&struct_flock)); + _ = try os.fcntl(fd, os.F.SETLK, @intFromPtr(&struct_flock)); // parent waits for child: const result = os.waitpid(pid, 0); try expect(result.status == 0 * 256); diff --git a/lib/std/os/uefi/pool_allocator.zig b/lib/std/os/uefi/pool_allocator.zig index 00b8941974d9..c24d9416f136 100644 --- a/lib/std/os/uefi/pool_allocator.zig +++ b/lib/std/os/uefi/pool_allocator.zig @@ -9,7 +9,7 @@ const Allocator = mem.Allocator; const UefiPoolAllocator = struct { fn getHeader(ptr: [*]u8) *[*]align(8) u8 { - return @intToPtr(*[*]align(8) u8, @ptrToInt(ptr) - @sizeOf(usize)); + return @ptrFromInt(*[*]align(8) u8, @intFromPtr(ptr) - @sizeOf(usize)); } fn alloc( @@ -31,7 +31,7 @@ const UefiPoolAllocator = struct { var unaligned_ptr: [*]align(8) u8 = undefined; if (uefi.system_table.boot_services.?.allocatePool(uefi.efi_pool_memory_type, full_len, &unaligned_ptr) != .Success) return null; - const unaligned_addr = @ptrToInt(unaligned_ptr); + const unaligned_addr = @intFromPtr(unaligned_ptr); const aligned_addr = mem.alignForward(usize, unaligned_addr + @sizeOf(usize), ptr_align); var aligned_ptr = unaligned_ptr + (aligned_addr - unaligned_addr); diff --git a/lib/std/os/uefi/protocols/device_path_protocol.zig b/lib/std/os/uefi/protocols/device_path_protocol.zig index 2365b0cb2e87..c64084e6ed8e 100644 --- a/lib/std/os/uefi/protocols/device_path_protocol.zig +++ b/lib/std/os/uefi/protocols/device_path_protocol.zig @@ -23,7 +23,7 @@ pub const DevicePathProtocol = extern struct { /// Returns the next DevicePathProtocol node in the sequence, if any. pub fn next(self: *DevicePathProtocol) ?*DevicePathProtocol { - if (self.type == .End and @intToEnum(EndDevicePath.Subtype, self.subtype) == .EndEntire) + if (self.type == .End and @enumFromInt(EndDevicePath.Subtype, self.subtype) == .EndEntire) return null; return @ptrCast(*DevicePathProtocol, @ptrCast([*]u8, self) + self.length); @@ -37,7 +37,7 @@ pub const DevicePathProtocol = extern struct { node = next_node; } - return (@ptrToInt(node) + node.length) - @ptrToInt(self); + return (@intFromPtr(node) + node.length) - @intFromPtr(self); } /// Creates a file device path from the existing device path and a file path. @@ -99,7 +99,7 @@ pub const DevicePathProtocol = extern struct { inline for (type_info.fields) |subtype| { // The tag names match the union names, so just grab that off the enum - const tag_val: u8 = @enumToInt(@field(TTag, subtype.name)); + const tag_val: u8 = @intFromEnum(@field(TTag, subtype.name)); if (self.subtype == tag_val) { // e.g. expr = .{ .Pci = @ptrCast(...) } diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index c591f8cf7fcf..421815c04d97 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -30,7 +30,7 @@ pub const gdi32 = @import("windows/gdi32.zig"); pub const winmm = @import("windows/winmm.zig"); pub const crypt32 = @import("windows/crypt32.zig"); -pub const self_process_handle = @intToPtr(HANDLE, maxInt(usize)); +pub const self_process_handle = @ptrFromInt(HANDLE, maxInt(usize)); const Self = @This(); @@ -242,7 +242,7 @@ pub fn DeviceIoControl( pub fn GetOverlappedResult(h: HANDLE, overlapped: *OVERLAPPED, wait: bool) !DWORD { var bytes: DWORD = undefined; - if (kernel32.GetOverlappedResult(h, overlapped, &bytes, @boolToInt(wait)) == 0) { + if (kernel32.GetOverlappedResult(h, overlapped, &bytes, @intFromBool(wait)) == 0) { switch (kernel32.GetLastError()) { .IO_INCOMPLETE => if (!wait) return error.WouldBlock else unreachable, else => |err| return unexpectedError(err), @@ -294,7 +294,7 @@ pub fn WaitForSingleObject(handle: HANDLE, milliseconds: DWORD) WaitForSingleObj } pub fn WaitForSingleObjectEx(handle: HANDLE, milliseconds: DWORD, alertable: bool) WaitForSingleObjectError!void { - switch (kernel32.WaitForSingleObjectEx(handle, milliseconds, @boolToInt(alertable))) { + switch (kernel32.WaitForSingleObjectEx(handle, milliseconds, @intFromBool(alertable))) { WAIT_ABANDONED => return error.WaitAbandoned, WAIT_OBJECT_0 => return, WAIT_TIMEOUT => return error.WaitTimeOut, @@ -311,9 +311,9 @@ pub fn WaitForMultipleObjectsEx(handles: []const HANDLE, waitAll: bool, millisec switch (kernel32.WaitForMultipleObjectsEx( nCount, handles.ptr, - @boolToInt(waitAll), + @intFromBool(waitAll), milliseconds, - @boolToInt(alertable), + @intFromBool(alertable), )) { WAIT_OBJECT_0...WAIT_OBJECT_0 + MAXIMUM_WAIT_OBJECTS => |n| { const handle_index = n - WAIT_OBJECT_0; @@ -422,7 +422,7 @@ pub fn GetQueuedCompletionStatusEx( @intCast(ULONG, completion_port_entries.len), &num_entries_removed, timeout_ms orelse INFINITE, - @boolToInt(alertable), + @intFromBool(alertable), ); if (success == FALSE) { @@ -1106,7 +1106,7 @@ test "QueryObjectName" { var out_buffer: [PATH_MAX_WIDE]u16 = undefined; var result_path = try QueryObjectName(handle, &out_buffer); - const required_len_in_u16 = result_path.len + @divExact(@ptrToInt(result_path.ptr) - @ptrToInt(&out_buffer), 2) + 1; + const required_len_in_u16 = result_path.len + @divExact(@intFromPtr(result_path.ptr) - @intFromPtr(&out_buffer), 2) + 1; //insufficient size try std.testing.expectError(error.NameTooLong, QueryObjectName(handle, out_buffer[0 .. required_len_in_u16 - 1])); //exactly-sufficient size @@ -1263,7 +1263,7 @@ test "GetFinalPathNameByHandle" { const nt_path = try GetFinalPathNameByHandle(handle, .{ .volume_name = .Nt }, &buffer); _ = try GetFinalPathNameByHandle(handle, .{ .volume_name = .Dos }, &buffer); - const required_len_in_u16 = nt_path.len + @divExact(@ptrToInt(nt_path.ptr) - @ptrToInt(&buffer), 2) + 1; + const required_len_in_u16 = nt_path.len + @divExact(@intFromPtr(nt_path.ptr) - @intFromPtr(&buffer), 2) + 1; //check with insufficient size try std.testing.expectError(error.NameTooLong, GetFinalPathNameByHandle(handle, .{ .volume_name = .Nt }, buffer[0 .. required_len_in_u16 - 1])); try std.testing.expectError(error.NameTooLong, GetFinalPathNameByHandle(handle, .{ .volume_name = .Dos }, buffer[0 .. required_len_in_u16 - 1])); @@ -1313,7 +1313,7 @@ pub fn WSAStartup(majorVersion: u8, minorVersion: u8) !ws2_32.WSADATA { var wsadata: ws2_32.WSADATA = undefined; return switch (ws2_32.WSAStartup((@as(WORD, minorVersion) << 8) | majorVersion, &wsadata)) { 0 => wsadata, - else => |err_int| switch (@intToEnum(ws2_32.WinsockError, @intCast(u16, err_int))) { + else => |err_int| switch (@enumFromInt(ws2_32.WinsockError, @intCast(u16, err_int))) { .WSASYSNOTREADY => return error.SystemNotAvailable, .WSAVERNOTSUPPORTED => return error.VersionNotSupported, .WSAEINPROGRESS => return error.BlockingOperationInProgress, @@ -2286,7 +2286,7 @@ pub fn loadWinsockExtensionFunction(comptime T: type, sock: ws2_32.SOCKET, guid: ws2_32.SIO_GET_EXTENSION_FUNCTION_POINTER, @ptrCast(*const anyopaque, &guid), @sizeOf(GUID), - @intToPtr(?*anyopaque, @ptrToInt(&function)), + @ptrFromInt(?*anyopaque, @intFromPtr(&function)), @sizeOf(T), &num_bytes, null, @@ -2325,21 +2325,21 @@ pub fn unexpectedError(err: Win32Error) std.os.UnexpectedError { null, ); _ = std.unicode.utf16leToUtf8(&buf_utf8, buf_wstr[0..len]) catch unreachable; - std.debug.print("error.Unexpected: GetLastError({}): {s}\n", .{ @enumToInt(err), buf_utf8[0..len] }); + std.debug.print("error.Unexpected: GetLastError({}): {s}\n", .{ @intFromEnum(err), buf_utf8[0..len] }); std.debug.dumpCurrentStackTrace(@returnAddress()); } return error.Unexpected; } pub fn unexpectedWSAError(err: ws2_32.WinsockError) std.os.UnexpectedError { - return unexpectedError(@intToEnum(Win32Error, @enumToInt(err))); + return unexpectedError(@enumFromInt(Win32Error, @intFromEnum(err))); } /// Call this when you made a windows NtDll call /// and you get an unexpected status. pub fn unexpectedStatus(status: NTSTATUS) std.os.UnexpectedError { if (std.os.unexpected_error_tracing) { - std.debug.print("error.Unexpected NTSTATUS=0x{x}\n", .{@enumToInt(status)}); + std.debug.print("error.Unexpected NTSTATUS=0x{x}\n", .{@intFromEnum(status)}); std.debug.dumpCurrentStackTrace(@returnAddress()); } return error.Unexpected; @@ -2527,10 +2527,10 @@ pub fn CTL_CODE(deviceType: u16, function: u12, method: TransferType, access: u2 return (@as(DWORD, deviceType) << 16) | (@as(DWORD, access) << 14) | (@as(DWORD, function) << 2) | - @enumToInt(method); + @intFromEnum(method); } -pub const INVALID_HANDLE_VALUE = @intToPtr(HANDLE, maxInt(usize)); +pub const INVALID_HANDLE_VALUE = @ptrFromInt(HANDLE, maxInt(usize)); pub const INVALID_FILE_ATTRIBUTES = @as(DWORD, maxInt(DWORD)); @@ -3221,7 +3221,7 @@ pub const LSTATUS = LONG; pub const HKEY = *opaque {}; -pub const HKEY_LOCAL_MACHINE: HKEY = @intToPtr(HKEY, 0x80000002); +pub const HKEY_LOCAL_MACHINE: HKEY = @ptrFromInt(HKEY, 0x80000002); /// Combines the STANDARD_RIGHTS_REQUIRED, KEY_QUERY_VALUE, KEY_SET_VALUE, KEY_CREATE_SUB_KEY, /// KEY_ENUMERATE_SUB_KEYS, KEY_NOTIFY, and KEY_CREATE_LINK access rights. @@ -4685,11 +4685,11 @@ pub const KUSER_SHARED_DATA = extern struct { /// Read-only user-mode address for the shared data. /// https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/ntexapi_x/kuser_shared_data/index.htm /// https://msrc-blog.microsoft.com/2022/04/05/randomizing-the-kuser_shared_data-structure-on-windows/ -pub const SharedUserData: *const KUSER_SHARED_DATA = @intToPtr(*const KUSER_SHARED_DATA, 0x7FFE0000); +pub const SharedUserData: *const KUSER_SHARED_DATA = @ptrFromInt(*const KUSER_SHARED_DATA, 0x7FFE0000); pub fn IsProcessorFeaturePresent(feature: PF) bool { - if (@enumToInt(feature) >= PROCESSOR_FEATURE_MAX) return false; - return SharedUserData.ProcessorFeatures[@enumToInt(feature)] == 1; + if (@intFromEnum(feature) >= PROCESSOR_FEATURE_MAX) return false; + return SharedUserData.ProcessorFeatures[@intFromEnum(feature)] == 1; } pub const TH32CS_SNAPHEAPLIST = 0x00000001; diff --git a/lib/std/os/windows/user32.zig b/lib/std/os/windows/user32.zig index 211b9d8462b7..0d6fc2c67037 100644 --- a/lib/std/os/windows/user32.zig +++ b/lib/std/os/windows/user32.zig @@ -1350,7 +1350,7 @@ pub extern "user32" fn AdjustWindowRectEx(lpRect: *RECT, dwStyle: DWORD, bMenu: pub fn adjustWindowRectEx(lpRect: *RECT, dwStyle: u32, bMenu: bool, dwExStyle: u32) !void { assert(dwStyle & WS_OVERLAPPED == 0); - if (AdjustWindowRectEx(lpRect, dwStyle, @boolToInt(bMenu), dwExStyle) == 0) { + if (AdjustWindowRectEx(lpRect, dwStyle, @intFromBool(bMenu), dwExStyle) == 0) { switch (GetLastError()) { .INVALID_PARAMETER => unreachable, else => |err| return windows.unexpectedError(err), diff --git a/lib/std/os/windows/ws2_32.zig b/lib/std/os/windows/ws2_32.zig index ae624dfd2bc9..821b903a34bb 100644 --- a/lib/std/os/windows/ws2_32.zig +++ b/lib/std/os/windows/ws2_32.zig @@ -21,7 +21,7 @@ const LPARAM = windows.LPARAM; const FARPROC = windows.FARPROC; pub const SOCKET = *opaque {}; -pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0)); +pub const INVALID_SOCKET = @ptrFromInt(SOCKET, ~@as(usize, 0)); pub const GROUP = u32; pub const ADDRESS_FAMILY = u16; diff --git a/lib/std/pdb.zig b/lib/std/pdb.zig index 180507ba7168..25a6786ec68b 100644 --- a/lib/std/pdb.zig +++ b/lib/std/pdb.zig @@ -863,7 +863,7 @@ pub const Pdb = struct { } pub fn getStream(self: *Pdb, stream: StreamType) ?*MsfStream { - const id = @enumToInt(stream); + const id = @intFromEnum(stream); return self.getStreamById(id); } }; diff --git a/lib/std/process.zig b/lib/std/process.zig index f27b7e835b10..05066fa4361d 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -514,9 +514,9 @@ pub const ArgIteratorWasi = struct { /// Call to free the internal buffer of the iterator. pub fn deinit(self: *ArgIteratorWasi) void { const last_item = self.args[self.args.len - 1]; - const last_byte_addr = @ptrToInt(last_item.ptr) + last_item.len + 1; // null terminated + const last_byte_addr = @intFromPtr(last_item.ptr) + last_item.len + 1; // null terminated const first_item_ptr = self.args[0].ptr; - const len = last_byte_addr - @ptrToInt(first_item_ptr); + const len = last_byte_addr - @intFromPtr(first_item_ptr); self.allocator.free(first_item_ptr[0..len]); self.allocator.free(self.args); } @@ -1079,9 +1079,9 @@ pub fn getBaseAddress() usize { return phdr - @sizeOf(std.elf.Ehdr); }, .macos, .freebsd, .netbsd => { - return @ptrToInt(&std.c._mh_execute_header); + return @intFromPtr(&std.c._mh_execute_header); }, - .windows => return @ptrToInt(os.windows.kernel32.GetModuleHandleW(null)), + .windows => return @intFromPtr(os.windows.kernel32.GetModuleHandleW(null)), else => @compileError("Unsupported OS"), } } diff --git a/lib/std/rand/benchmark.zig b/lib/std/rand/benchmark.zig index 668b664c27a6..ea3de9c70d9c 100644 --- a/lib/std/rand/benchmark.zig +++ b/lib/std/rand/benchmark.zig @@ -91,8 +91,8 @@ pub fn benchmark(comptime H: anytype, bytes: usize, comptime block_size: usize) } const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, @intToFloat(f64, bytes) / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, @floatFromInt(f64, bytes) / elapsed_s); std.debug.assert(rng.random().int(u64) != 0); diff --git a/lib/std/rand/test.zig b/lib/std/rand/test.zig index d257425ad1e4..6cc6891c5aa0 100644 --- a/lib/std/rand/test.zig +++ b/lib/std/rand/test.zig @@ -332,13 +332,13 @@ test "Random float chi-square goodness of fit" { while (i < num_numbers) : (i += 1) { const rand_f32 = random.float(f32); const rand_f64 = random.float(f64); - var f32_put = try f32_hist.getOrPut(@floatToInt(u32, rand_f32 * @intToFloat(f32, num_buckets))); + var f32_put = try f32_hist.getOrPut(@intFromFloat(u32, rand_f32 * @floatFromInt(f32, num_buckets))); if (f32_put.found_existing) { f32_put.value_ptr.* += 1; } else { f32_put.value_ptr.* = 1; } - var f64_put = try f64_hist.getOrPut(@floatToInt(u32, rand_f64 * @intToFloat(f64, num_buckets))); + var f64_put = try f64_hist.getOrPut(@intFromFloat(u32, rand_f64 * @floatFromInt(f64, num_buckets))); if (f64_put.found_existing) { f64_put.value_ptr.* += 1; } else { @@ -352,8 +352,8 @@ test "Random float chi-square goodness of fit" { { var j: u32 = 0; while (j < num_buckets) : (j += 1) { - const count = @intToFloat(f64, (if (f32_hist.get(j)) |v| v else 0)); - const expected = @intToFloat(f64, num_numbers) / @intToFloat(f64, num_buckets); + const count = @floatFromInt(f64, (if (f32_hist.get(j)) |v| v else 0)); + const expected = @floatFromInt(f64, num_numbers) / @floatFromInt(f64, num_buckets); const delta = count - expected; const variance = (delta * delta) / expected; f32_total_variance += variance; @@ -363,8 +363,8 @@ test "Random float chi-square goodness of fit" { { var j: u64 = 0; while (j < num_buckets) : (j += 1) { - const count = @intToFloat(f64, (if (f64_hist.get(j)) |v| v else 0)); - const expected = @intToFloat(f64, num_numbers) / @intToFloat(f64, num_buckets); + const count = @floatFromInt(f64, (if (f64_hist.get(j)) |v| v else 0)); + const expected = @floatFromInt(f64, num_numbers) / @floatFromInt(f64, num_buckets); const delta = count - expected; const variance = (delta * delta) / expected; f64_total_variance += variance; diff --git a/lib/std/simd.zig b/lib/std/simd.zig index 4ccdac6c1e47..78d24a80bfa6 100644 --- a/lib/std/simd.zig +++ b/lib/std/simd.zig @@ -61,7 +61,7 @@ pub fn suggestVectorSize(comptime T: type) ?usize { test "suggestVectorSizeForCpu works with signed and unsigned values" { comptime var cpu = std.Target.Cpu.baseline(std.Target.Cpu.Arch.x86_64); - comptime cpu.features.addFeature(@enumToInt(std.Target.x86.Feature.avx512f)); + comptime cpu.features.addFeature(@intFromEnum(std.Target.x86.Feature.avx512f)); const signed_integer_size = suggestVectorSizeForCpu(i32, cpu).?; const unsigned_integer_size = suggestVectorSizeForCpu(u32, cpu).?; try std.testing.expectEqual(@as(usize, 16), unsigned_integer_size); @@ -94,7 +94,7 @@ pub inline fn iota(comptime T: type, comptime len: usize) @Vector(len, T) { for (&out, 0..) |*element, i| { element.* = switch (@typeInfo(T)) { .Int => @intCast(T, i), - .Float => @intToFloat(T, i), + .Float => @floatFromInt(T, i), else => @compileError("Can't use type " ++ @typeName(T) ++ " in iota."), }; } diff --git a/lib/std/sort.zig b/lib/std/sort.zig index 813bad074170..928503ad40b7 100644 --- a/lib/std/sort.zig +++ b/lib/std/sort.zig @@ -96,7 +96,7 @@ fn siftDown(a: usize, root: usize, n: usize, context: anytype) void { if (child >= n) break; // choose the greater child. - child += @boolToInt(child + 1 < n and context.lessThan(child, child + 1)); + child += @intFromBool(child + 1 < n and context.lessThan(child, child + 1)); // stop if the invariant holds at `node`. if (!context.lessThan(node, child)) break; diff --git a/lib/std/start.zig b/lib/std/start.zig index f5d2688efb64..9c83bd881c81 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -248,7 +248,7 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv return root.main(); }, uefi.Status => { - return @enumToInt(root.main()); + return @intFromEnum(root.main()); }, else => @compileError("expected return type of main to be 'void', 'noreturn', 'usize', or 'std.os.uefi.Status'"), } @@ -419,7 +419,7 @@ fn posixCallMainAndExit() callconv(.C) noreturn { else => continue, } } - break :init @intToPtr([*]elf.Phdr, at_phdr)[0..at_phnum]; + break :init @ptrFromInt([*]elf.Phdr, at_phdr)[0..at_phnum]; }; // Apply the initial relocations as early as possible in the startup @@ -500,7 +500,7 @@ fn main(c_argc: c_int, c_argv: [*][*:0]c_char, c_envp: [*:null]?[*:0]c_char) cal if (builtin.os.tag == .linux) { const at_phdr = std.c.getauxval(elf.AT_PHDR); const at_phnum = std.c.getauxval(elf.AT_PHNUM); - const phdrs = (@intToPtr([*]elf.Phdr, at_phdr))[0..at_phnum]; + const phdrs = (@ptrFromInt([*]elf.Phdr, at_phdr))[0..at_phnum]; expandStackSize(phdrs); } diff --git a/lib/std/start_windows_tls.zig b/lib/std/start_windows_tls.zig index 6a3aad7a99ea..a1cd8387dca8 100644 --- a/lib/std/start_windows_tls.zig +++ b/lib/std/start_windows_tls.zig @@ -22,14 +22,14 @@ comptime { // TODO also note, ReactOS has a +1 on StartAddressOfRawData and AddressOfCallBacks. Investigate // why they do that. //export const _tls_used linksection(".rdata$T") = std.os.windows.IMAGE_TLS_DIRECTORY { -// .StartAddressOfRawData = @ptrToInt(&_tls_start), -// .EndAddressOfRawData = @ptrToInt(&_tls_end), -// .AddressOfIndex = @ptrToInt(&_tls_index), -// .AddressOfCallBacks = @ptrToInt(__xl_a), +// .StartAddressOfRawData = @intFromPtr(&_tls_start), +// .EndAddressOfRawData = @intFromPtr(&_tls_end), +// .AddressOfIndex = @intFromPtr(&_tls_index), +// .AddressOfCallBacks = @intFromPtr(__xl_a), // .SizeOfZeroFill = 0, // .Characteristics = 0, //}; -// This is the workaround because we can't do @ptrToInt at comptime like that. +// This is the workaround because we can't do @intFromPtr at comptime like that. pub const IMAGE_TLS_DIRECTORY = extern struct { StartAddressOfRawData: *anyopaque, EndAddressOfRawData: *anyopaque, diff --git a/lib/std/tar.zig b/lib/std/tar.zig index 14a9ce5d3fc7..688d0935871d 100644 --- a/lib/std/tar.zig +++ b/lib/std/tar.zig @@ -70,8 +70,8 @@ pub const Header = struct { } pub fn fileType(header: Header) FileType { - const result = @intToEnum(FileType, header.bytes[156]); - return if (result == @intToEnum(FileType, 0)) .normal else result; + const result = @enumFromInt(FileType, header.bytes[156]); + return if (result == @enumFromInt(FileType, 0)) .normal else result; } fn str(header: Header, start: usize, end: usize) []const u8 { diff --git a/lib/std/target.zig b/lib/std/target.zig index 995edd02f72a..912eb141ea4d 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -139,7 +139,7 @@ pub const Target = struct { /// Returns whether the first version `self` is newer (greater) than or equal to the second version `ver`. pub fn isAtLeast(self: WindowsVersion, ver: WindowsVersion) bool { - return @enumToInt(self) >= @enumToInt(ver); + return @intFromEnum(self) >= @intFromEnum(ver); } pub const Range = struct { @@ -147,14 +147,14 @@ pub const Target = struct { max: WindowsVersion, pub fn includesVersion(self: Range, ver: WindowsVersion) bool { - return @enumToInt(ver) >= @enumToInt(self.min) and @enumToInt(ver) <= @enumToInt(self.max); + return @intFromEnum(ver) >= @intFromEnum(self.min) and @intFromEnum(ver) <= @intFromEnum(self.max); } /// Checks if system is guaranteed to be at least `version` or older than `version`. /// Returns `null` if a runtime check is required. pub fn isAtLeast(self: Range, ver: WindowsVersion) ?bool { - if (@enumToInt(self.min) >= @enumToInt(ver)) return true; - if (@enumToInt(self.max) < @enumToInt(ver)) return false; + if (@intFromEnum(self.min) >= @intFromEnum(ver)) return true; + if (@intFromEnum(self.max) < @intFromEnum(ver)) return false; return null; } }; @@ -168,17 +168,17 @@ pub const Target = struct { out_stream: anytype, ) !void { if (comptime std.mem.eql(u8, fmt, "s")) { - if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.latest)) { + if (@intFromEnum(self) >= @intFromEnum(WindowsVersion.nt4) and @intFromEnum(self) <= @intFromEnum(WindowsVersion.latest)) { try std.fmt.format(out_stream, ".{s}", .{@tagName(self)}); } else { // TODO this code path breaks zig triples, but it is used in `builtin` - try std.fmt.format(out_stream, "@intToEnum(Target.Os.WindowsVersion, 0x{X:0>8})", .{@enumToInt(self)}); + try std.fmt.format(out_stream, "@enumFromInt(Target.Os.WindowsVersion, 0x{X:0>8})", .{@intFromEnum(self)}); } } else if (fmt.len == 0) { - if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.latest)) { + if (@intFromEnum(self) >= @intFromEnum(WindowsVersion.nt4) and @intFromEnum(self) <= @intFromEnum(WindowsVersion.latest)) { try std.fmt.format(out_stream, "WindowsVersion.{s}", .{@tagName(self)}); } else { - try std.fmt.format(out_stream, "WindowsVersion(0x{X:0>8})", .{@enumToInt(self)}); + try std.fmt.format(out_stream, "WindowsVersion(0x{X:0>8})", .{@intFromEnum(self)}); } } else { std.fmt.invalidFmtError(fmt, self); @@ -778,21 +778,21 @@ pub const Target = struct { pub fn featureSet(features: []const F) Set { var x = Set.empty; for (features) |feature| { - x.addFeature(@enumToInt(feature)); + x.addFeature(@intFromEnum(feature)); } return x; } /// Returns true if the specified feature is enabled. pub fn featureSetHas(set: Set, feature: F) bool { - return set.isEnabled(@enumToInt(feature)); + return set.isEnabled(@intFromEnum(feature)); } /// Returns true if any specified feature is enabled. pub fn featureSetHasAny(set: Set, features: anytype) bool { comptime std.debug.assert(std.meta.trait.isIndexable(@TypeOf(features))); inline for (features) |feature| { - if (set.isEnabled(@enumToInt(@as(F, feature)))) return true; + if (set.isEnabled(@intFromEnum(@as(F, feature)))) return true; } return false; } @@ -801,7 +801,7 @@ pub const Target = struct { pub fn featureSetHasAll(set: Set, features: anytype) bool { comptime std.debug.assert(std.meta.trait.isIndexable(@TypeOf(features))); inline for (features) |feature| { - if (!set.isEnabled(@enumToInt(@as(F, feature)))) return false; + if (!set.isEnabled(@intFromEnum(@as(F, feature)))) return false; } return true; } diff --git a/lib/std/target/aarch64.zig b/lib/std/target/aarch64.zig index 0c3b802b8a43..e20448102d0b 100644 --- a/lib/std/target/aarch64.zig +++ b/lib/std/target/aarch64.zig @@ -215,7 +215,7 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.a510)] = .{ + result[@intFromEnum(Feature.a510)] = .{ .llvm_name = "a510", .description = "Cortex-A510 ARM processors", .dependencies = featureSet(&[_]Feature{ @@ -224,7 +224,7 @@ pub const all_features = blk: { .use_postra_scheduler, }), }; - result[@enumToInt(Feature.a65)] = .{ + result[@intFromEnum(Feature.a65)] = .{ .llvm_name = "a65", .description = "Cortex-A65 ARM processors", .dependencies = featureSet(&[_]Feature{ @@ -235,7 +235,7 @@ pub const all_features = blk: { .fuse_literals, }), }; - result[@enumToInt(Feature.a710)] = .{ + result[@intFromEnum(Feature.a710)] = .{ .llvm_name = "a710", .description = "Cortex-A710 ARM processors", .dependencies = featureSet(&[_]Feature{ @@ -247,7 +247,7 @@ pub const all_features = blk: { .use_postra_scheduler, }), }; - result[@enumToInt(Feature.a76)] = .{ + result[@intFromEnum(Feature.a76)] = .{ .llvm_name = "a76", .description = "Cortex-A76 ARM processors", .dependencies = featureSet(&[_]Feature{ @@ -257,7 +257,7 @@ pub const all_features = blk: { .lsl_fast, }), }; - result[@enumToInt(Feature.a78)] = .{ + result[@intFromEnum(Feature.a78)] = .{ .llvm_name = "a78", .description = "Cortex-A78 ARM processors", .dependencies = featureSet(&[_]Feature{ @@ -269,7 +269,7 @@ pub const all_features = blk: { .use_postra_scheduler, }), }; - result[@enumToInt(Feature.a78c)] = .{ + result[@intFromEnum(Feature.a78c)] = .{ .llvm_name = "a78c", .description = "Cortex-A78C ARM processors", .dependencies = featureSet(&[_]Feature{ @@ -281,175 +281,175 @@ pub const all_features = blk: { .use_postra_scheduler, }), }; - result[@enumToInt(Feature.aes)] = .{ + result[@intFromEnum(Feature.aes)] = .{ .llvm_name = "aes", .description = "Enable AES support (FEAT_AES, FEAT_PMULL)", .dependencies = featureSet(&[_]Feature{ .neon, }), }; - result[@enumToInt(Feature.aggressive_fma)] = .{ + result[@intFromEnum(Feature.aggressive_fma)] = .{ .llvm_name = "aggressive-fma", .description = "Enable Aggressive FMA for floating-point.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.alternate_sextload_cvt_f32_pattern)] = .{ + result[@intFromEnum(Feature.alternate_sextload_cvt_f32_pattern)] = .{ .llvm_name = "alternate-sextload-cvt-f32-pattern", .description = "Use alternative pattern for sextload convert to f32", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.altnzcv)] = .{ + result[@intFromEnum(Feature.altnzcv)] = .{ .llvm_name = "altnzcv", .description = "Enable alternative NZCV format for floating point comparisons (FEAT_FlagM2)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.am)] = .{ + result[@intFromEnum(Feature.am)] = .{ .llvm_name = "am", .description = "Enable v8.4-A Activity Monitors extension (FEAT_AMUv1)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.amvs)] = .{ + result[@intFromEnum(Feature.amvs)] = .{ .llvm_name = "amvs", .description = "Enable v8.6-A Activity Monitors Virtualization support (FEAT_AMUv1p1)", .dependencies = featureSet(&[_]Feature{ .am, }), }; - result[@enumToInt(Feature.arith_bcc_fusion)] = .{ + result[@intFromEnum(Feature.arith_bcc_fusion)] = .{ .llvm_name = "arith-bcc-fusion", .description = "CPU fuses arithmetic+bcc operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.arith_cbz_fusion)] = .{ + result[@intFromEnum(Feature.arith_cbz_fusion)] = .{ .llvm_name = "arith-cbz-fusion", .description = "CPU fuses arithmetic + cbz/cbnz operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ascend_store_address)] = .{ + result[@intFromEnum(Feature.ascend_store_address)] = .{ .llvm_name = "ascend-store-address", .description = "Schedule vector stores by ascending address", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.b16b16)] = .{ + result[@intFromEnum(Feature.b16b16)] = .{ .llvm_name = "b16b16", .description = "Enable SVE2.1 or SME2.1 non-widening BFloat16 to BFloat16 instructions (FEAT_B16B16)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.balance_fp_ops)] = .{ + result[@intFromEnum(Feature.balance_fp_ops)] = .{ .llvm_name = "balance-fp-ops", .description = "balance mix of odd and even D-registers for fp multiply(-accumulate) ops", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.bf16)] = .{ + result[@intFromEnum(Feature.bf16)] = .{ .llvm_name = "bf16", .description = "Enable BFloat16 Extension (FEAT_BF16)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.brbe)] = .{ + result[@intFromEnum(Feature.brbe)] = .{ .llvm_name = "brbe", .description = "Enable Branch Record Buffer Extension (FEAT_BRBE)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.bti)] = .{ + result[@intFromEnum(Feature.bti)] = .{ .llvm_name = "bti", .description = "Enable Branch Target Identification (FEAT_BTI)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.call_saved_x10)] = .{ + result[@intFromEnum(Feature.call_saved_x10)] = .{ .llvm_name = "call-saved-x10", .description = "Make X10 callee saved.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.call_saved_x11)] = .{ + result[@intFromEnum(Feature.call_saved_x11)] = .{ .llvm_name = "call-saved-x11", .description = "Make X11 callee saved.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.call_saved_x12)] = .{ + result[@intFromEnum(Feature.call_saved_x12)] = .{ .llvm_name = "call-saved-x12", .description = "Make X12 callee saved.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.call_saved_x13)] = .{ + result[@intFromEnum(Feature.call_saved_x13)] = .{ .llvm_name = "call-saved-x13", .description = "Make X13 callee saved.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.call_saved_x14)] = .{ + result[@intFromEnum(Feature.call_saved_x14)] = .{ .llvm_name = "call-saved-x14", .description = "Make X14 callee saved.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.call_saved_x15)] = .{ + result[@intFromEnum(Feature.call_saved_x15)] = .{ .llvm_name = "call-saved-x15", .description = "Make X15 callee saved.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.call_saved_x18)] = .{ + result[@intFromEnum(Feature.call_saved_x18)] = .{ .llvm_name = "call-saved-x18", .description = "Make X18 callee saved.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.call_saved_x8)] = .{ + result[@intFromEnum(Feature.call_saved_x8)] = .{ .llvm_name = "call-saved-x8", .description = "Make X8 callee saved.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.call_saved_x9)] = .{ + result[@intFromEnum(Feature.call_saved_x9)] = .{ .llvm_name = "call-saved-x9", .description = "Make X9 callee saved.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ccdp)] = .{ + result[@intFromEnum(Feature.ccdp)] = .{ .llvm_name = "ccdp", .description = "Enable v8.5 Cache Clean to Point of Deep Persistence (FEAT_DPB2)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ccidx)] = .{ + result[@intFromEnum(Feature.ccidx)] = .{ .llvm_name = "ccidx", .description = "Enable v8.3-A Extend of the CCSIDR number of sets (FEAT_CCIDX)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ccpp)] = .{ + result[@intFromEnum(Feature.ccpp)] = .{ .llvm_name = "ccpp", .description = "Enable v8.2 data Cache Clean to Point of Persistence (FEAT_DPB)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.clrbhb)] = .{ + result[@intFromEnum(Feature.clrbhb)] = .{ .llvm_name = "clrbhb", .description = "Enable Clear BHB instruction (FEAT_CLRBHB)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.cmp_bcc_fusion)] = .{ + result[@intFromEnum(Feature.cmp_bcc_fusion)] = .{ .llvm_name = "cmp-bcc-fusion", .description = "CPU fuses cmp+bcc operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.complxnum)] = .{ + result[@intFromEnum(Feature.complxnum)] = .{ .llvm_name = "complxnum", .description = "Enable v8.3-A Floating-point complex number support (FEAT_FCMA)", .dependencies = featureSet(&[_]Feature{ .neon, }), }; - result[@enumToInt(Feature.contextidr_el2)] = .{ + result[@intFromEnum(Feature.contextidr_el2)] = .{ .llvm_name = "CONTEXTIDREL2", .description = "Enable RW operand Context ID Register (EL2)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.cortex_r82)] = .{ + result[@intFromEnum(Feature.cortex_r82)] = .{ .llvm_name = "cortex-r82", .description = "Cortex-R82 ARM processors", .dependencies = featureSet(&[_]Feature{ .use_postra_scheduler, }), }; - result[@enumToInt(Feature.crc)] = .{ + result[@intFromEnum(Feature.crc)] = .{ .llvm_name = "crc", .description = "Enable ARMv8 CRC-32 checksum instructions (FEAT_CRC32)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.crypto)] = .{ + result[@intFromEnum(Feature.crypto)] = .{ .llvm_name = "crypto", .description = "Enable cryptographic instructions", .dependencies = featureSet(&[_]Feature{ @@ -457,560 +457,560 @@ pub const all_features = blk: { .sha2, }), }; - result[@enumToInt(Feature.cssc)] = .{ + result[@intFromEnum(Feature.cssc)] = .{ .llvm_name = "cssc", .description = "Enable Common Short Sequence Compression (CSSC) instructions (FEAT_CSSC)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.custom_cheap_as_move)] = .{ + result[@intFromEnum(Feature.custom_cheap_as_move)] = .{ .llvm_name = "custom-cheap-as-move", .description = "Use custom handling of cheap instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.d128)] = .{ + result[@intFromEnum(Feature.d128)] = .{ .llvm_name = "d128", .description = "Enable Armv9.4-A 128-bit Page Table Descriptors, System Registers and Instructions (FEAT_D128, FEAT_LVA3, FEAT_SYSREG128, FEAT_SYSINSTR128)", .dependencies = featureSet(&[_]Feature{ .lse128, }), }; - result[@enumToInt(Feature.disable_latency_sched_heuristic)] = .{ + result[@intFromEnum(Feature.disable_latency_sched_heuristic)] = .{ .llvm_name = "disable-latency-sched-heuristic", .description = "Disable latency scheduling heuristic", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dit)] = .{ + result[@intFromEnum(Feature.dit)] = .{ .llvm_name = "dit", .description = "Enable v8.4-A Data Independent Timing instructions (FEAT_DIT)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dotprod)] = .{ + result[@intFromEnum(Feature.dotprod)] = .{ .llvm_name = "dotprod", .description = "Enable dot product support (FEAT_DotProd)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ecv)] = .{ + result[@intFromEnum(Feature.ecv)] = .{ .llvm_name = "ecv", .description = "Enable enhanced counter virtualization extension (FEAT_ECV)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.el2vmsa)] = .{ + result[@intFromEnum(Feature.el2vmsa)] = .{ .llvm_name = "el2vmsa", .description = "Enable Exception Level 2 Virtual Memory System Architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.el3)] = .{ + result[@intFromEnum(Feature.el3)] = .{ .llvm_name = "el3", .description = "Enable Exception Level 3", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.enable_select_opt)] = .{ + result[@intFromEnum(Feature.enable_select_opt)] = .{ .llvm_name = "enable-select-opt", .description = "Enable the select optimize pass for select loop heuristics", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ete)] = .{ + result[@intFromEnum(Feature.ete)] = .{ .llvm_name = "ete", .description = "Enable Embedded Trace Extension (FEAT_ETE)", .dependencies = featureSet(&[_]Feature{ .trbe, }), }; - result[@enumToInt(Feature.exynos_cheap_as_move)] = .{ + result[@intFromEnum(Feature.exynos_cheap_as_move)] = .{ .llvm_name = "exynos-cheap-as-move", .description = "Use Exynos specific handling of cheap instructions", .dependencies = featureSet(&[_]Feature{ .custom_cheap_as_move, }), }; - result[@enumToInt(Feature.f32mm)] = .{ + result[@intFromEnum(Feature.f32mm)] = .{ .llvm_name = "f32mm", .description = "Enable Matrix Multiply FP32 Extension (FEAT_F32MM)", .dependencies = featureSet(&[_]Feature{ .sve, }), }; - result[@enumToInt(Feature.f64mm)] = .{ + result[@intFromEnum(Feature.f64mm)] = .{ .llvm_name = "f64mm", .description = "Enable Matrix Multiply FP64 Extension (FEAT_F64MM)", .dependencies = featureSet(&[_]Feature{ .sve, }), }; - result[@enumToInt(Feature.fgt)] = .{ + result[@intFromEnum(Feature.fgt)] = .{ .llvm_name = "fgt", .description = "Enable fine grained virtualization traps extension (FEAT_FGT)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fix_cortex_a53_835769)] = .{ + result[@intFromEnum(Feature.fix_cortex_a53_835769)] = .{ .llvm_name = "fix-cortex-a53-835769", .description = "Mitigate Cortex-A53 Erratum 835769", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.flagm)] = .{ + result[@intFromEnum(Feature.flagm)] = .{ .llvm_name = "flagm", .description = "Enable v8.4-A Flag Manipulation Instructions (FEAT_FlagM)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fmv)] = .{ + result[@intFromEnum(Feature.fmv)] = .{ .llvm_name = "fmv", .description = "Enable Function Multi Versioning support.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.force_32bit_jump_tables)] = .{ + result[@intFromEnum(Feature.force_32bit_jump_tables)] = .{ .llvm_name = "force-32bit-jump-tables", .description = "Force jump table entries to be 32-bits wide except at MinSize", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fp16fml)] = .{ + result[@intFromEnum(Feature.fp16fml)] = .{ .llvm_name = "fp16fml", .description = "Enable FP16 FML instructions (FEAT_FHM)", .dependencies = featureSet(&[_]Feature{ .fullfp16, }), }; - result[@enumToInt(Feature.fp_armv8)] = .{ + result[@intFromEnum(Feature.fp_armv8)] = .{ .llvm_name = "fp-armv8", .description = "Enable ARMv8 FP (FEAT_FP)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fptoint)] = .{ + result[@intFromEnum(Feature.fptoint)] = .{ .llvm_name = "fptoint", .description = "Enable FRInt[32|64][Z|X] instructions that round a floating-point number to an integer (in FP format) forcing it to fit into a 32- or 64-bit int (FEAT_FRINTTS)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fullfp16)] = .{ + result[@intFromEnum(Feature.fullfp16)] = .{ .llvm_name = "fullfp16", .description = "Full FP16 (FEAT_FP16)", .dependencies = featureSet(&[_]Feature{ .fp_armv8, }), }; - result[@enumToInt(Feature.fuse_address)] = .{ + result[@intFromEnum(Feature.fuse_address)] = .{ .llvm_name = "fuse-address", .description = "CPU fuses address generation and memory operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fuse_adrp_add)] = .{ + result[@intFromEnum(Feature.fuse_adrp_add)] = .{ .llvm_name = "fuse-adrp-add", .description = "CPU fuses adrp+add operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fuse_aes)] = .{ + result[@intFromEnum(Feature.fuse_aes)] = .{ .llvm_name = "fuse-aes", .description = "CPU fuses AES crypto operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fuse_arith_logic)] = .{ + result[@intFromEnum(Feature.fuse_arith_logic)] = .{ .llvm_name = "fuse-arith-logic", .description = "CPU fuses arithmetic and logic operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fuse_crypto_eor)] = .{ + result[@intFromEnum(Feature.fuse_crypto_eor)] = .{ .llvm_name = "fuse-crypto-eor", .description = "CPU fuses AES/PMULL and EOR operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fuse_csel)] = .{ + result[@intFromEnum(Feature.fuse_csel)] = .{ .llvm_name = "fuse-csel", .description = "CPU fuses conditional select operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fuse_literals)] = .{ + result[@intFromEnum(Feature.fuse_literals)] = .{ .llvm_name = "fuse-literals", .description = "CPU fuses literal generation operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.harden_sls_blr)] = .{ + result[@intFromEnum(Feature.harden_sls_blr)] = .{ .llvm_name = "harden-sls-blr", .description = "Harden against straight line speculation across BLR instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.harden_sls_nocomdat)] = .{ + result[@intFromEnum(Feature.harden_sls_nocomdat)] = .{ .llvm_name = "harden-sls-nocomdat", .description = "Generate thunk code for SLS mitigation in the normal text section", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.harden_sls_retbr)] = .{ + result[@intFromEnum(Feature.harden_sls_retbr)] = .{ .llvm_name = "harden-sls-retbr", .description = "Harden against straight line speculation across RET and BR instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hbc)] = .{ + result[@intFromEnum(Feature.hbc)] = .{ .llvm_name = "hbc", .description = "Enable Armv8.8-A Hinted Conditional Branches Extension (FEAT_HBC)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hcx)] = .{ + result[@intFromEnum(Feature.hcx)] = .{ .llvm_name = "hcx", .description = "Enable Armv8.7-A HCRX_EL2 system register (FEAT_HCX)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.i8mm)] = .{ + result[@intFromEnum(Feature.i8mm)] = .{ .llvm_name = "i8mm", .description = "Enable Matrix Multiply Int8 Extension (FEAT_I8MM)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ite)] = .{ + result[@intFromEnum(Feature.ite)] = .{ .llvm_name = "ite", .description = "Enable Armv9.4-A Instrumentation Extension FEAT_ITE", .dependencies = featureSet(&[_]Feature{ .ete, }), }; - result[@enumToInt(Feature.jsconv)] = .{ + result[@intFromEnum(Feature.jsconv)] = .{ .llvm_name = "jsconv", .description = "Enable v8.3-A JavaScript FP conversion instructions (FEAT_JSCVT)", .dependencies = featureSet(&[_]Feature{ .fp_armv8, }), }; - result[@enumToInt(Feature.lor)] = .{ + result[@intFromEnum(Feature.lor)] = .{ .llvm_name = "lor", .description = "Enables ARM v8.1 Limited Ordering Regions extension (FEAT_LOR)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ls64)] = .{ + result[@intFromEnum(Feature.ls64)] = .{ .llvm_name = "ls64", .description = "Enable Armv8.7-A LD64B/ST64B Accelerator Extension (FEAT_LS64, FEAT_LS64_V, FEAT_LS64_ACCDATA)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lse)] = .{ + result[@intFromEnum(Feature.lse)] = .{ .llvm_name = "lse", .description = "Enable ARMv8.1 Large System Extension (LSE) atomic instructions (FEAT_LSE)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lse128)] = .{ + result[@intFromEnum(Feature.lse128)] = .{ .llvm_name = "lse128", .description = "Enable Armv9.4-A 128-bit Atomic Instructions (FEAT_LSE128)", .dependencies = featureSet(&[_]Feature{ .lse, }), }; - result[@enumToInt(Feature.lse2)] = .{ + result[@intFromEnum(Feature.lse2)] = .{ .llvm_name = "lse2", .description = "Enable ARMv8.4 Large System Extension 2 (LSE2) atomicity rules (FEAT_LSE2)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lsl_fast)] = .{ + result[@intFromEnum(Feature.lsl_fast)] = .{ .llvm_name = "lsl-fast", .description = "CPU has a fastpath logical shift of up to 3 places", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mec)] = .{ + result[@intFromEnum(Feature.mec)] = .{ .llvm_name = "mec", .description = "Enable Memory Encryption Contexts Extension", .dependencies = featureSet(&[_]Feature{ .rme, }), }; - result[@enumToInt(Feature.mops)] = .{ + result[@intFromEnum(Feature.mops)] = .{ .llvm_name = "mops", .description = "Enable Armv8.8-A memcpy and memset acceleration instructions (FEAT_MOPS)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mpam)] = .{ + result[@intFromEnum(Feature.mpam)] = .{ .llvm_name = "mpam", .description = "Enable v8.4-A Memory system Partitioning and Monitoring extension (FEAT_MPAM)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mte)] = .{ + result[@intFromEnum(Feature.mte)] = .{ .llvm_name = "mte", .description = "Enable Memory Tagging Extension (FEAT_MTE, FEAT_MTE2)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.neon)] = .{ + result[@intFromEnum(Feature.neon)] = .{ .llvm_name = "neon", .description = "Enable Advanced SIMD instructions (FEAT_AdvSIMD)", .dependencies = featureSet(&[_]Feature{ .fp_armv8, }), }; - result[@enumToInt(Feature.nmi)] = .{ + result[@intFromEnum(Feature.nmi)] = .{ .llvm_name = "nmi", .description = "Enable Armv8.8-A Non-maskable Interrupts (FEAT_NMI, FEAT_GICv3_NMI)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_bti_at_return_twice)] = .{ + result[@intFromEnum(Feature.no_bti_at_return_twice)] = .{ .llvm_name = "no-bti-at-return-twice", .description = "Don't place a BTI instruction after a return-twice", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_neg_immediates)] = .{ + result[@intFromEnum(Feature.no_neg_immediates)] = .{ .llvm_name = "no-neg-immediates", .description = "Convert immediates and instructions to their negated or complemented equivalent when the immediate does not fit in the encoding.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_zcz_fp)] = .{ + result[@intFromEnum(Feature.no_zcz_fp)] = .{ .llvm_name = "no-zcz-fp", .description = "Has no zero-cycle zeroing instructions for FP registers", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nv)] = .{ + result[@intFromEnum(Feature.nv)] = .{ .llvm_name = "nv", .description = "Enable v8.4-A Nested Virtualization Enchancement (FEAT_NV, FEAT_NV2)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.outline_atomics)] = .{ + result[@intFromEnum(Feature.outline_atomics)] = .{ .llvm_name = "outline-atomics", .description = "Enable out of line atomics to support LSE instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.pan)] = .{ + result[@intFromEnum(Feature.pan)] = .{ .llvm_name = "pan", .description = "Enables ARM v8.1 Privileged Access-Never extension (FEAT_PAN)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.pan_rwv)] = .{ + result[@intFromEnum(Feature.pan_rwv)] = .{ .llvm_name = "pan-rwv", .description = "Enable v8.2 PAN s1e1R and s1e1W Variants (FEAT_PAN2)", .dependencies = featureSet(&[_]Feature{ .pan, }), }; - result[@enumToInt(Feature.pauth)] = .{ + result[@intFromEnum(Feature.pauth)] = .{ .llvm_name = "pauth", .description = "Enable v8.3-A Pointer Authentication extension (FEAT_PAuth)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.perfmon)] = .{ + result[@intFromEnum(Feature.perfmon)] = .{ .llvm_name = "perfmon", .description = "Enable Code Generation for ARMv8 PMUv3 Performance Monitors extension (FEAT_PMUv3)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.predictable_select_expensive)] = .{ + result[@intFromEnum(Feature.predictable_select_expensive)] = .{ .llvm_name = "predictable-select-expensive", .description = "Prefer likely predicted branches over selects", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.predres)] = .{ + result[@intFromEnum(Feature.predres)] = .{ .llvm_name = "predres", .description = "Enable v8.5a execution and data prediction invalidation instructions (FEAT_SPECRES)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prfm_slc_target)] = .{ + result[@intFromEnum(Feature.prfm_slc_target)] = .{ .llvm_name = "prfm-slc-target", .description = "Enable SLC target for PRFM instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.rand)] = .{ + result[@intFromEnum(Feature.rand)] = .{ .llvm_name = "rand", .description = "Enable Random Number generation instructions (FEAT_RNG)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ras)] = .{ + result[@intFromEnum(Feature.ras)] = .{ .llvm_name = "ras", .description = "Enable ARMv8 Reliability, Availability and Serviceability Extensions (FEAT_RAS, FEAT_RASv1p1)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.rasv2)] = .{ + result[@intFromEnum(Feature.rasv2)] = .{ .llvm_name = "rasv2", .description = "Enable ARMv8.9-A Reliability, Availability and Serviceability Extensions (FEAT_RASv2)", .dependencies = featureSet(&[_]Feature{ .ras, }), }; - result[@enumToInt(Feature.rcpc)] = .{ + result[@intFromEnum(Feature.rcpc)] = .{ .llvm_name = "rcpc", .description = "Enable support for RCPC extension (FEAT_LRCPC)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.rcpc3)] = .{ + result[@intFromEnum(Feature.rcpc3)] = .{ .llvm_name = "rcpc3", .description = "Enable Armv8.9-A RCPC instructions for A64 and Advanced SIMD and floating-point instruction set (FEAT_LRCPC3)", .dependencies = featureSet(&[_]Feature{ .rcpc_immo, }), }; - result[@enumToInt(Feature.rcpc_immo)] = .{ + result[@intFromEnum(Feature.rcpc_immo)] = .{ .llvm_name = "rcpc-immo", .description = "Enable v8.4-A RCPC instructions with Immediate Offsets (FEAT_LRCPC2)", .dependencies = featureSet(&[_]Feature{ .rcpc, }), }; - result[@enumToInt(Feature.rdm)] = .{ + result[@intFromEnum(Feature.rdm)] = .{ .llvm_name = "rdm", .description = "Enable ARMv8.1 Rounding Double Multiply Add/Subtract instructions (FEAT_RDM)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x1)] = .{ + result[@intFromEnum(Feature.reserve_x1)] = .{ .llvm_name = "reserve-x1", .description = "Reserve X1, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x10)] = .{ + result[@intFromEnum(Feature.reserve_x10)] = .{ .llvm_name = "reserve-x10", .description = "Reserve X10, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x11)] = .{ + result[@intFromEnum(Feature.reserve_x11)] = .{ .llvm_name = "reserve-x11", .description = "Reserve X11, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x12)] = .{ + result[@intFromEnum(Feature.reserve_x12)] = .{ .llvm_name = "reserve-x12", .description = "Reserve X12, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x13)] = .{ + result[@intFromEnum(Feature.reserve_x13)] = .{ .llvm_name = "reserve-x13", .description = "Reserve X13, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x14)] = .{ + result[@intFromEnum(Feature.reserve_x14)] = .{ .llvm_name = "reserve-x14", .description = "Reserve X14, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x15)] = .{ + result[@intFromEnum(Feature.reserve_x15)] = .{ .llvm_name = "reserve-x15", .description = "Reserve X15, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x18)] = .{ + result[@intFromEnum(Feature.reserve_x18)] = .{ .llvm_name = "reserve-x18", .description = "Reserve X18, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x2)] = .{ + result[@intFromEnum(Feature.reserve_x2)] = .{ .llvm_name = "reserve-x2", .description = "Reserve X2, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x20)] = .{ + result[@intFromEnum(Feature.reserve_x20)] = .{ .llvm_name = "reserve-x20", .description = "Reserve X20, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x21)] = .{ + result[@intFromEnum(Feature.reserve_x21)] = .{ .llvm_name = "reserve-x21", .description = "Reserve X21, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x22)] = .{ + result[@intFromEnum(Feature.reserve_x22)] = .{ .llvm_name = "reserve-x22", .description = "Reserve X22, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x23)] = .{ + result[@intFromEnum(Feature.reserve_x23)] = .{ .llvm_name = "reserve-x23", .description = "Reserve X23, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x24)] = .{ + result[@intFromEnum(Feature.reserve_x24)] = .{ .llvm_name = "reserve-x24", .description = "Reserve X24, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x25)] = .{ + result[@intFromEnum(Feature.reserve_x25)] = .{ .llvm_name = "reserve-x25", .description = "Reserve X25, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x26)] = .{ + result[@intFromEnum(Feature.reserve_x26)] = .{ .llvm_name = "reserve-x26", .description = "Reserve X26, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x27)] = .{ + result[@intFromEnum(Feature.reserve_x27)] = .{ .llvm_name = "reserve-x27", .description = "Reserve X27, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x28)] = .{ + result[@intFromEnum(Feature.reserve_x28)] = .{ .llvm_name = "reserve-x28", .description = "Reserve X28, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x3)] = .{ + result[@intFromEnum(Feature.reserve_x3)] = .{ .llvm_name = "reserve-x3", .description = "Reserve X3, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x30)] = .{ + result[@intFromEnum(Feature.reserve_x30)] = .{ .llvm_name = "reserve-x30", .description = "Reserve X30, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x4)] = .{ + result[@intFromEnum(Feature.reserve_x4)] = .{ .llvm_name = "reserve-x4", .description = "Reserve X4, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x5)] = .{ + result[@intFromEnum(Feature.reserve_x5)] = .{ .llvm_name = "reserve-x5", .description = "Reserve X5, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x6)] = .{ + result[@intFromEnum(Feature.reserve_x6)] = .{ .llvm_name = "reserve-x6", .description = "Reserve X6, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x7)] = .{ + result[@intFromEnum(Feature.reserve_x7)] = .{ .llvm_name = "reserve-x7", .description = "Reserve X7, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x9)] = .{ + result[@intFromEnum(Feature.reserve_x9)] = .{ .llvm_name = "reserve-x9", .description = "Reserve X9, making it unavailable as a GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.rme)] = .{ + result[@intFromEnum(Feature.rme)] = .{ .llvm_name = "rme", .description = "Enable Realm Management Extension (FEAT_RME)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sb)] = .{ + result[@intFromEnum(Feature.sb)] = .{ .llvm_name = "sb", .description = "Enable v8.5 Speculation Barrier (FEAT_SB)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sel2)] = .{ + result[@intFromEnum(Feature.sel2)] = .{ .llvm_name = "sel2", .description = "Enable v8.4-A Secure Exception Level 2 extension (FEAT_SEL2)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sha2)] = .{ + result[@intFromEnum(Feature.sha2)] = .{ .llvm_name = "sha2", .description = "Enable SHA1 and SHA256 support (FEAT_SHA1, FEAT_SHA256)", .dependencies = featureSet(&[_]Feature{ .neon, }), }; - result[@enumToInt(Feature.sha3)] = .{ + result[@intFromEnum(Feature.sha3)] = .{ .llvm_name = "sha3", .description = "Enable SHA512 and SHA3 support (FEAT_SHA3, FEAT_SHA512)", .dependencies = featureSet(&[_]Feature{ .sha2, }), }; - result[@enumToInt(Feature.slow_misaligned_128store)] = .{ + result[@intFromEnum(Feature.slow_misaligned_128store)] = .{ .llvm_name = "slow-misaligned-128store", .description = "Misaligned 128 bit stores are slow", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_paired_128)] = .{ + result[@intFromEnum(Feature.slow_paired_128)] = .{ .llvm_name = "slow-paired-128", .description = "Paired 128 bit loads and stores are slow", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_strqro_store)] = .{ + result[@intFromEnum(Feature.slow_strqro_store)] = .{ .llvm_name = "slow-strqro-store", .description = "STR of Q register with register offset is slow", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm4)] = .{ + result[@intFromEnum(Feature.sm4)] = .{ .llvm_name = "sm4", .description = "Enable SM3 and SM4 support (FEAT_SM4, FEAT_SM3)", .dependencies = featureSet(&[_]Feature{ .neon, }), }; - result[@enumToInt(Feature.sme)] = .{ + result[@intFromEnum(Feature.sme)] = .{ .llvm_name = "sme", .description = "Enable Scalable Matrix Extension (SME) (FEAT_SME)", .dependencies = featureSet(&[_]Feature{ @@ -1018,79 +1018,79 @@ pub const all_features = blk: { .use_scalar_inc_vl, }), }; - result[@enumToInt(Feature.sme2)] = .{ + result[@intFromEnum(Feature.sme2)] = .{ .llvm_name = "sme2", .description = "Enable Scalable Matrix Extension 2 (SME2) instructions", .dependencies = featureSet(&[_]Feature{ .sme, }), }; - result[@enumToInt(Feature.sme2p1)] = .{ + result[@intFromEnum(Feature.sme2p1)] = .{ .llvm_name = "sme2p1", .description = "Enable Scalable Matrix Extension 2.1 (FEAT_SME2p1) instructions", .dependencies = featureSet(&[_]Feature{ .sme2, }), }; - result[@enumToInt(Feature.sme_f16f16)] = .{ + result[@intFromEnum(Feature.sme_f16f16)] = .{ .llvm_name = "sme-f16f16", .description = "Enable SME2.1 non-widening Float16 instructions (FEAT_SME_F16F16)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sme_f64f64)] = .{ + result[@intFromEnum(Feature.sme_f64f64)] = .{ .llvm_name = "sme-f64f64", .description = "Enable Scalable Matrix Extension (SME) F64F64 instructions (FEAT_SME_F64F64)", .dependencies = featureSet(&[_]Feature{ .sme, }), }; - result[@enumToInt(Feature.sme_i16i64)] = .{ + result[@intFromEnum(Feature.sme_i16i64)] = .{ .llvm_name = "sme-i16i64", .description = "Enable Scalable Matrix Extension (SME) I16I64 instructions (FEAT_SME_I16I64)", .dependencies = featureSet(&[_]Feature{ .sme, }), }; - result[@enumToInt(Feature.spe)] = .{ + result[@intFromEnum(Feature.spe)] = .{ .llvm_name = "spe", .description = "Enable Statistical Profiling extension (FEAT_SPE)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.spe_eef)] = .{ + result[@intFromEnum(Feature.spe_eef)] = .{ .llvm_name = "spe-eef", .description = "Enable extra register in the Statistical Profiling Extension (FEAT_SPEv1p2)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.specres2)] = .{ + result[@intFromEnum(Feature.specres2)] = .{ .llvm_name = "specres2", .description = "Enable Speculation Restriction Instruction (FEAT_SPECRES2)", .dependencies = featureSet(&[_]Feature{ .predres, }), }; - result[@enumToInt(Feature.specrestrict)] = .{ + result[@intFromEnum(Feature.specrestrict)] = .{ .llvm_name = "specrestrict", .description = "Enable architectural speculation restriction (FEAT_CSV2_2)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ssbs)] = .{ + result[@intFromEnum(Feature.ssbs)] = .{ .llvm_name = "ssbs", .description = "Enable Speculative Store Bypass Safe bit (FEAT_SSBS, FEAT_SSBS2)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.strict_align)] = .{ + result[@intFromEnum(Feature.strict_align)] = .{ .llvm_name = "strict-align", .description = "Disallow all unaligned memory access", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sve)] = .{ + result[@intFromEnum(Feature.sve)] = .{ .llvm_name = "sve", .description = "Enable Scalable Vector Extension (SVE) instructions (FEAT_SVE)", .dependencies = featureSet(&[_]Feature{ .fullfp16, }), }; - result[@enumToInt(Feature.sve2)] = .{ + result[@intFromEnum(Feature.sve2)] = .{ .llvm_name = "sve2", .description = "Enable Scalable Vector Extension 2 (SVE2) instructions (FEAT_SVE2)", .dependencies = featureSet(&[_]Feature{ @@ -1098,7 +1098,7 @@ pub const all_features = blk: { .use_scalar_inc_vl, }), }; - result[@enumToInt(Feature.sve2_aes)] = .{ + result[@intFromEnum(Feature.sve2_aes)] = .{ .llvm_name = "sve2-aes", .description = "Enable AES SVE2 instructions (FEAT_SVE_AES, FEAT_SVE_PMULL128)", .dependencies = featureSet(&[_]Feature{ @@ -1106,14 +1106,14 @@ pub const all_features = blk: { .sve2, }), }; - result[@enumToInt(Feature.sve2_bitperm)] = .{ + result[@intFromEnum(Feature.sve2_bitperm)] = .{ .llvm_name = "sve2-bitperm", .description = "Enable bit permutation SVE2 instructions (FEAT_SVE_BitPerm)", .dependencies = featureSet(&[_]Feature{ .sve2, }), }; - result[@enumToInt(Feature.sve2_sha3)] = .{ + result[@intFromEnum(Feature.sve2_sha3)] = .{ .llvm_name = "sve2-sha3", .description = "Enable SHA3 SVE2 instructions (FEAT_SVE_SHA3)", .dependencies = featureSet(&[_]Feature{ @@ -1121,7 +1121,7 @@ pub const all_features = blk: { .sve2, }), }; - result[@enumToInt(Feature.sve2_sm4)] = .{ + result[@intFromEnum(Feature.sve2_sm4)] = .{ .llvm_name = "sve2-sm4", .description = "Enable SM4 SVE2 instructions (FEAT_SVE_SM4)", .dependencies = featureSet(&[_]Feature{ @@ -1129,84 +1129,84 @@ pub const all_features = blk: { .sve2, }), }; - result[@enumToInt(Feature.sve2p1)] = .{ + result[@intFromEnum(Feature.sve2p1)] = .{ .llvm_name = "sve2p1", .description = "Enable Scalable Vector Extension 2.1 instructions", .dependencies = featureSet(&[_]Feature{ .sve2, }), }; - result[@enumToInt(Feature.tagged_globals)] = .{ + result[@intFromEnum(Feature.tagged_globals)] = .{ .llvm_name = "tagged-globals", .description = "Use an instruction sequence for taking the address of a global that allows a memory tag in the upper address bits", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.the)] = .{ + result[@intFromEnum(Feature.the)] = .{ .llvm_name = "the", .description = "Enable Armv8.9-A Translation Hardening Extension (FEAT_THE)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tlb_rmi)] = .{ + result[@intFromEnum(Feature.tlb_rmi)] = .{ .llvm_name = "tlb-rmi", .description = "Enable v8.4-A TLB Range and Maintenance Instructions (FEAT_TLBIOS, FEAT_TLBIRANGE)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tme)] = .{ + result[@intFromEnum(Feature.tme)] = .{ .llvm_name = "tme", .description = "Enable Transactional Memory Extension (FEAT_TME)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tpidr_el1)] = .{ + result[@intFromEnum(Feature.tpidr_el1)] = .{ .llvm_name = "tpidr-el1", .description = "Permit use of TPIDR_EL1 for the TLS base", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tpidr_el2)] = .{ + result[@intFromEnum(Feature.tpidr_el2)] = .{ .llvm_name = "tpidr-el2", .description = "Permit use of TPIDR_EL2 for the TLS base", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tpidr_el3)] = .{ + result[@intFromEnum(Feature.tpidr_el3)] = .{ .llvm_name = "tpidr-el3", .description = "Permit use of TPIDR_EL3 for the TLS base", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tracev8_4)] = .{ + result[@intFromEnum(Feature.tracev8_4)] = .{ .llvm_name = "tracev8.4", .description = "Enable v8.4-A Trace extension (FEAT_TRF)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.trbe)] = .{ + result[@intFromEnum(Feature.trbe)] = .{ .llvm_name = "trbe", .description = "Enable Trace Buffer Extension (FEAT_TRBE)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.uaops)] = .{ + result[@intFromEnum(Feature.uaops)] = .{ .llvm_name = "uaops", .description = "Enable v8.2 UAO PState (FEAT_UAO)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.use_experimental_zeroing_pseudos)] = .{ + result[@intFromEnum(Feature.use_experimental_zeroing_pseudos)] = .{ .llvm_name = "use-experimental-zeroing-pseudos", .description = "Hint to the compiler that the MOVPRFX instruction is merged with destructive operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.use_postra_scheduler)] = .{ + result[@intFromEnum(Feature.use_postra_scheduler)] = .{ .llvm_name = "use-postra-scheduler", .description = "Schedule again after register allocation", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.use_reciprocal_square_root)] = .{ + result[@intFromEnum(Feature.use_reciprocal_square_root)] = .{ .llvm_name = "use-reciprocal-square-root", .description = "Use the reciprocal square root approximation", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.use_scalar_inc_vl)] = .{ + result[@intFromEnum(Feature.use_scalar_inc_vl)] = .{ .llvm_name = "use-scalar-inc-vl", .description = "Prefer inc/dec over add+cnt", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v8_1a)] = .{ + result[@intFromEnum(Feature.v8_1a)] = .{ .llvm_name = "v8.1a", .description = "Support ARM v8.1a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1219,7 +1219,7 @@ pub const all_features = blk: { .vh, }), }; - result[@enumToInt(Feature.v8_2a)] = .{ + result[@intFromEnum(Feature.v8_2a)] = .{ .llvm_name = "v8.2a", .description = "Support ARM v8.2a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1230,7 +1230,7 @@ pub const all_features = blk: { .v8_1a, }), }; - result[@enumToInt(Feature.v8_3a)] = .{ + result[@intFromEnum(Feature.v8_3a)] = .{ .llvm_name = "v8.3a", .description = "Support ARM v8.3a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1242,7 +1242,7 @@ pub const all_features = blk: { .v8_2a, }), }; - result[@enumToInt(Feature.v8_4a)] = .{ + result[@intFromEnum(Feature.v8_4a)] = .{ .llvm_name = "v8.4a", .description = "Support ARM v8.4a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1260,7 +1260,7 @@ pub const all_features = blk: { .v8_3a, }), }; - result[@enumToInt(Feature.v8_5a)] = .{ + result[@intFromEnum(Feature.v8_5a)] = .{ .llvm_name = "v8.5a", .description = "Support ARM v8.5a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1275,7 +1275,7 @@ pub const all_features = blk: { .v8_4a, }), }; - result[@enumToInt(Feature.v8_6a)] = .{ + result[@intFromEnum(Feature.v8_6a)] = .{ .llvm_name = "v8.6a", .description = "Support ARM v8.6a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1287,7 +1287,7 @@ pub const all_features = blk: { .v8_5a, }), }; - result[@enumToInt(Feature.v8_7a)] = .{ + result[@intFromEnum(Feature.v8_7a)] = .{ .llvm_name = "v8.7a", .description = "Support ARM v8.7a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1297,7 +1297,7 @@ pub const all_features = blk: { .xs, }), }; - result[@enumToInt(Feature.v8_8a)] = .{ + result[@intFromEnum(Feature.v8_8a)] = .{ .llvm_name = "v8.8a", .description = "Support ARM v8.8a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1307,7 +1307,7 @@ pub const all_features = blk: { .v8_7a, }), }; - result[@enumToInt(Feature.v8_9a)] = .{ + result[@intFromEnum(Feature.v8_9a)] = .{ .llvm_name = "v8.9a", .description = "Support ARM v8.9a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1319,7 +1319,7 @@ pub const all_features = blk: { .v8_8a, }), }; - result[@enumToInt(Feature.v8a)] = .{ + result[@intFromEnum(Feature.v8a)] = .{ .llvm_name = "v8a", .description = "Support ARM v8.0a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1328,7 +1328,7 @@ pub const all_features = blk: { .neon, }), }; - result[@enumToInt(Feature.v8r)] = .{ + result[@intFromEnum(Feature.v8r)] = .{ .llvm_name = "v8r", .description = "Support ARM v8r instructions", .dependencies = featureSet(&[_]Feature{ @@ -1354,7 +1354,7 @@ pub const all_features = blk: { .uaops, }), }; - result[@enumToInt(Feature.v9_1a)] = .{ + result[@intFromEnum(Feature.v9_1a)] = .{ .llvm_name = "v9.1a", .description = "Support ARM v9.1a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1362,7 +1362,7 @@ pub const all_features = blk: { .v9a, }), }; - result[@enumToInt(Feature.v9_2a)] = .{ + result[@intFromEnum(Feature.v9_2a)] = .{ .llvm_name = "v9.2a", .description = "Support ARM v9.2a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1370,7 +1370,7 @@ pub const all_features = blk: { .v9_1a, }), }; - result[@enumToInt(Feature.v9_3a)] = .{ + result[@intFromEnum(Feature.v9_3a)] = .{ .llvm_name = "v9.3a", .description = "Support ARM v9.3a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1378,7 +1378,7 @@ pub const all_features = blk: { .v9_2a, }), }; - result[@enumToInt(Feature.v9_4a)] = .{ + result[@intFromEnum(Feature.v9_4a)] = .{ .llvm_name = "v9.4a", .description = "Support ARM v9.4a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1386,7 +1386,7 @@ pub const all_features = blk: { .v9_3a, }), }; - result[@enumToInt(Feature.v9a)] = .{ + result[@intFromEnum(Feature.v9a)] = .{ .llvm_name = "v9a", .description = "Support ARM v9a instructions", .dependencies = featureSet(&[_]Feature{ @@ -1395,41 +1395,41 @@ pub const all_features = blk: { .v8_5a, }), }; - result[@enumToInt(Feature.vh)] = .{ + result[@intFromEnum(Feature.vh)] = .{ .llvm_name = "vh", .description = "Enables ARM v8.1 Virtual Host extension (FEAT_VHE)", .dependencies = featureSet(&[_]Feature{ .contextidr_el2, }), }; - result[@enumToInt(Feature.wfxt)] = .{ + result[@intFromEnum(Feature.wfxt)] = .{ .llvm_name = "wfxt", .description = "Enable Armv8.7-A WFET and WFIT instruction (FEAT_WFxT)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.xs)] = .{ + result[@intFromEnum(Feature.xs)] = .{ .llvm_name = "xs", .description = "Enable Armv8.7-A limited-TLB-maintenance instruction (FEAT_XS)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zcm)] = .{ + result[@intFromEnum(Feature.zcm)] = .{ .llvm_name = "zcm", .description = "Has zero-cycle register moves", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zcz)] = .{ + result[@intFromEnum(Feature.zcz)] = .{ .llvm_name = "zcz", .description = "Has zero-cycle zeroing instructions", .dependencies = featureSet(&[_]Feature{ .zcz_gp, }), }; - result[@enumToInt(Feature.zcz_fp_workaround)] = .{ + result[@intFromEnum(Feature.zcz_fp_workaround)] = .{ .llvm_name = "zcz-fp-workaround", .description = "The zero-cycle floating-point zeroing instruction has a bug", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zcz_gp)] = .{ + result[@intFromEnum(Feature.zcz_gp)] = .{ .llvm_name = "zcz-gp", .description = "Has zero-cycle zeroing instructions for generic registers", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/amdgpu.zig b/lib/std/target/amdgpu.zig index 7c5dc74eb369..4fc47c8d729d 100644 --- a/lib/std/target/amdgpu.zig +++ b/lib/std/target/amdgpu.zig @@ -162,248 +162,248 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.@"16_bit_insts")] = .{ + result[@intFromEnum(Feature.@"16_bit_insts")] = .{ .llvm_name = "16-bit-insts", .description = "Has i16/f16 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.a16)] = .{ + result[@intFromEnum(Feature.a16)] = .{ .llvm_name = "a16", .description = "Support A16 for 16-bit coordinates/gradients/lod/clamp/mip image operands", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.add_no_carry_insts)] = .{ + result[@intFromEnum(Feature.add_no_carry_insts)] = .{ .llvm_name = "add-no-carry-insts", .description = "Have VALU add/sub instructions without carry out", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.aperture_regs)] = .{ + result[@intFromEnum(Feature.aperture_regs)] = .{ .llvm_name = "aperture-regs", .description = "Has Memory Aperture Base and Size Registers", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.architected_flat_scratch)] = .{ + result[@intFromEnum(Feature.architected_flat_scratch)] = .{ .llvm_name = "architected-flat-scratch", .description = "Flat Scratch register is a readonly SPI initialized architected register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.atomic_fadd_no_rtn_insts)] = .{ + result[@intFromEnum(Feature.atomic_fadd_no_rtn_insts)] = .{ .llvm_name = "atomic-fadd-no-rtn-insts", .description = "Has buffer_atomic_add_f32 and global_atomic_add_f32 instructions that don't return original value", .dependencies = featureSet(&[_]Feature{ .flat_global_insts, }), }; - result[@enumToInt(Feature.atomic_fadd_rtn_insts)] = .{ + result[@intFromEnum(Feature.atomic_fadd_rtn_insts)] = .{ .llvm_name = "atomic-fadd-rtn-insts", .description = "Has buffer_atomic_add_f32 and global_atomic_add_f32 instructions that return original value", .dependencies = featureSet(&[_]Feature{ .flat_global_insts, }), }; - result[@enumToInt(Feature.atomic_pk_fadd_no_rtn_insts)] = .{ + result[@intFromEnum(Feature.atomic_pk_fadd_no_rtn_insts)] = .{ .llvm_name = "atomic-pk-fadd-no-rtn-insts", .description = "Has buffer_atomic_pk_add_f16 and global_atomic_pk_add_f16 instructions that don't return original value", .dependencies = featureSet(&[_]Feature{ .flat_global_insts, }), }; - result[@enumToInt(Feature.auto_waitcnt_before_barrier)] = .{ + result[@intFromEnum(Feature.auto_waitcnt_before_barrier)] = .{ .llvm_name = "auto-waitcnt-before-barrier", .description = "Hardware automatically inserts waitcnt before barrier", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.back_off_barrier)] = .{ + result[@intFromEnum(Feature.back_off_barrier)] = .{ .llvm_name = "back-off-barrier", .description = "Hardware supports backing off s_barrier if an exception occurs", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ci_insts)] = .{ + result[@intFromEnum(Feature.ci_insts)] = .{ .llvm_name = "ci-insts", .description = "Additional instructions for CI+", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.cumode)] = .{ + result[@intFromEnum(Feature.cumode)] = .{ .llvm_name = "cumode", .description = "Enable CU wavefront execution mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dl_insts)] = .{ + result[@intFromEnum(Feature.dl_insts)] = .{ .llvm_name = "dl-insts", .description = "Has v_fmac_f32 and v_xnor_b32 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dot1_insts)] = .{ + result[@intFromEnum(Feature.dot1_insts)] = .{ .llvm_name = "dot1-insts", .description = "Has v_dot4_i32_i8 and v_dot8_i32_i4 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dot2_insts)] = .{ + result[@intFromEnum(Feature.dot2_insts)] = .{ .llvm_name = "dot2-insts", .description = "Has v_dot2_i32_i16, v_dot2_u32_u16 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dot3_insts)] = .{ + result[@intFromEnum(Feature.dot3_insts)] = .{ .llvm_name = "dot3-insts", .description = "Has v_dot8c_i32_i4 instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dot4_insts)] = .{ + result[@intFromEnum(Feature.dot4_insts)] = .{ .llvm_name = "dot4-insts", .description = "Has v_dot2c_i32_i16 instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dot5_insts)] = .{ + result[@intFromEnum(Feature.dot5_insts)] = .{ .llvm_name = "dot5-insts", .description = "Has v_dot2c_f32_f16 instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dot6_insts)] = .{ + result[@intFromEnum(Feature.dot6_insts)] = .{ .llvm_name = "dot6-insts", .description = "Has v_dot4c_i32_i8 instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dot7_insts)] = .{ + result[@intFromEnum(Feature.dot7_insts)] = .{ .llvm_name = "dot7-insts", .description = "Has v_dot2_f32_f16, v_dot4_u32_u8, v_dot8_u32_u4 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dot8_insts)] = .{ + result[@intFromEnum(Feature.dot8_insts)] = .{ .llvm_name = "dot8-insts", .description = "Has v_dot4_i32_iu8, v_dot8_i32_iu4 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dot9_insts)] = .{ + result[@intFromEnum(Feature.dot9_insts)] = .{ .llvm_name = "dot9-insts", .description = "Has v_dot2_f16_f16, v_dot2_bf16_bf16, v_dot2_f32_bf16 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dpp)] = .{ + result[@intFromEnum(Feature.dpp)] = .{ .llvm_name = "dpp", .description = "Support DPP (Data Parallel Primitives) extension", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dpp8)] = .{ + result[@intFromEnum(Feature.dpp8)] = .{ .llvm_name = "dpp8", .description = "Support DPP8 (Data Parallel Primitives) extension", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dpp_64bit)] = .{ + result[@intFromEnum(Feature.dpp_64bit)] = .{ .llvm_name = "dpp-64bit", .description = "Support DPP (Data Parallel Primitives) extension", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ds128)] = .{ + result[@intFromEnum(Feature.ds128)] = .{ .llvm_name = "enable-ds128", .description = "Use ds_{read|write}_b128", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ds_src2_insts)] = .{ + result[@intFromEnum(Feature.ds_src2_insts)] = .{ .llvm_name = "ds-src2-insts", .description = "Has ds_*_src2 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.extended_image_insts)] = .{ + result[@intFromEnum(Feature.extended_image_insts)] = .{ .llvm_name = "extended-image-insts", .description = "Support mips != 0, lod != 0, gather4, and get_lod", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_denormal_f32)] = .{ + result[@intFromEnum(Feature.fast_denormal_f32)] = .{ .llvm_name = "fast-denormal-f32", .description = "Enabling denormals does not cause f32 instructions to run at f64 rates", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_fmaf)] = .{ + result[@intFromEnum(Feature.fast_fmaf)] = .{ .llvm_name = "fast-fmaf", .description = "Assuming f32 fma is at least as fast as mul + add", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.flat_address_space)] = .{ + result[@intFromEnum(Feature.flat_address_space)] = .{ .llvm_name = "flat-address-space", .description = "Support flat address space", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.flat_atomic_fadd_f32_inst)] = .{ + result[@intFromEnum(Feature.flat_atomic_fadd_f32_inst)] = .{ .llvm_name = "flat-atomic-fadd-f32-inst", .description = "Has flat_atomic_add_f32 instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.flat_for_global)] = .{ + result[@intFromEnum(Feature.flat_for_global)] = .{ .llvm_name = "flat-for-global", .description = "Force to generate flat instruction for global", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.flat_global_insts)] = .{ + result[@intFromEnum(Feature.flat_global_insts)] = .{ .llvm_name = "flat-global-insts", .description = "Have global_* flat memory instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.flat_inst_offsets)] = .{ + result[@intFromEnum(Feature.flat_inst_offsets)] = .{ .llvm_name = "flat-inst-offsets", .description = "Flat instructions have immediate offset addressing mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.flat_scratch)] = .{ + result[@intFromEnum(Feature.flat_scratch)] = .{ .llvm_name = "enable-flat-scratch", .description = "Use scratch_* flat memory instructions to access scratch", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.flat_scratch_insts)] = .{ + result[@intFromEnum(Feature.flat_scratch_insts)] = .{ .llvm_name = "flat-scratch-insts", .description = "Have scratch_* flat memory instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.flat_segment_offset_bug)] = .{ + result[@intFromEnum(Feature.flat_segment_offset_bug)] = .{ .llvm_name = "flat-segment-offset-bug", .description = "GFX10 bug where inst_offset is ignored when flat instructions access global memory", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fma_mix_insts)] = .{ + result[@intFromEnum(Feature.fma_mix_insts)] = .{ .llvm_name = "fma-mix-insts", .description = "Has v_fma_mix_f32, v_fma_mixlo_f16, v_fma_mixhi_f16 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fmacf64_inst)] = .{ + result[@intFromEnum(Feature.fmacf64_inst)] = .{ .llvm_name = "fmacf64-inst", .description = "Has v_fmac_f64 instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fmaf)] = .{ + result[@intFromEnum(Feature.fmaf)] = .{ .llvm_name = "fmaf", .description = "Enable single precision FMA (not as fast as mul+add, but fused)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fp64)] = .{ + result[@intFromEnum(Feature.fp64)] = .{ .llvm_name = "fp64", .description = "Enable double precision operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fp8_insts)] = .{ + result[@intFromEnum(Feature.fp8_insts)] = .{ .llvm_name = "fp8-insts", .description = "Has fp8 and bf8 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.full_rate_64_ops)] = .{ + result[@intFromEnum(Feature.full_rate_64_ops)] = .{ .llvm_name = "full-rate-64-ops", .description = "Most fp64 instructions are full rate", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.g16)] = .{ + result[@intFromEnum(Feature.g16)] = .{ .llvm_name = "g16", .description = "Support G16 for 16-bit gradient image operands", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gcn3_encoding)] = .{ + result[@intFromEnum(Feature.gcn3_encoding)] = .{ .llvm_name = "gcn3-encoding", .description = "Encoding format for VI", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.get_wave_id_inst)] = .{ + result[@intFromEnum(Feature.get_wave_id_inst)] = .{ .llvm_name = "get-wave-id-inst", .description = "Has s_get_waveid_in_workgroup instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gfx10)] = .{ + result[@intFromEnum(Feature.gfx10)] = .{ .llvm_name = "gfx10", .description = "GFX10 GPU generation", .dependencies = featureSet(&[_]Feature{ @@ -449,27 +449,27 @@ pub const all_features = blk: { .vscnt, }), }; - result[@enumToInt(Feature.gfx10_3_insts)] = .{ + result[@intFromEnum(Feature.gfx10_3_insts)] = .{ .llvm_name = "gfx10-3-insts", .description = "Additional instructions for GFX10.3", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gfx10_a_encoding)] = .{ + result[@intFromEnum(Feature.gfx10_a_encoding)] = .{ .llvm_name = "gfx10_a-encoding", .description = "Has BVH ray tracing instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gfx10_b_encoding)] = .{ + result[@intFromEnum(Feature.gfx10_b_encoding)] = .{ .llvm_name = "gfx10_b-encoding", .description = "Encoding format GFX10_B", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gfx10_insts)] = .{ + result[@intFromEnum(Feature.gfx10_insts)] = .{ .llvm_name = "gfx10-insts", .description = "Additional instructions for GFX10+", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gfx11)] = .{ + result[@intFromEnum(Feature.gfx11)] = .{ .llvm_name = "gfx11", .description = "GFX11 GPU generation", .dependencies = featureSet(&[_]Feature{ @@ -514,27 +514,27 @@ pub const all_features = blk: { .vscnt, }), }; - result[@enumToInt(Feature.gfx11_full_vgprs)] = .{ + result[@intFromEnum(Feature.gfx11_full_vgprs)] = .{ .llvm_name = "gfx11-full-vgprs", .description = "GFX11 with 50% more physical VGPRs and 50% larger allocation granule than GFX10", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gfx11_insts)] = .{ + result[@intFromEnum(Feature.gfx11_insts)] = .{ .llvm_name = "gfx11-insts", .description = "Additional instructions for GFX11+", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gfx7_gfx8_gfx9_insts)] = .{ + result[@intFromEnum(Feature.gfx7_gfx8_gfx9_insts)] = .{ .llvm_name = "gfx7-gfx8-gfx9-insts", .description = "Instructions shared in GFX7, GFX8, GFX9", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gfx8_insts)] = .{ + result[@intFromEnum(Feature.gfx8_insts)] = .{ .llvm_name = "gfx8-insts", .description = "Additional instructions for GFX8+", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gfx9)] = .{ + result[@intFromEnum(Feature.gfx9)] = .{ .llvm_name = "gfx9", .description = "GFX9 GPU generation", .dependencies = featureSet(&[_]Feature{ @@ -577,277 +577,277 @@ pub const all_features = blk: { .xnack_support, }), }; - result[@enumToInt(Feature.gfx90a_insts)] = .{ + result[@intFromEnum(Feature.gfx90a_insts)] = .{ .llvm_name = "gfx90a-insts", .description = "Additional instructions for GFX90A+", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gfx940_insts)] = .{ + result[@intFromEnum(Feature.gfx940_insts)] = .{ .llvm_name = "gfx940-insts", .description = "Additional instructions for GFX940+", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gfx9_insts)] = .{ + result[@intFromEnum(Feature.gfx9_insts)] = .{ .llvm_name = "gfx9-insts", .description = "Additional instructions for GFX9+", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.half_rate_64_ops)] = .{ + result[@intFromEnum(Feature.half_rate_64_ops)] = .{ .llvm_name = "half-rate-64-ops", .description = "Most fp64 instructions are half rate instead of quarter", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.image_gather4_d16_bug)] = .{ + result[@intFromEnum(Feature.image_gather4_d16_bug)] = .{ .llvm_name = "image-gather4-d16-bug", .description = "Image Gather4 D16 hardware bug", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.image_insts)] = .{ + result[@intFromEnum(Feature.image_insts)] = .{ .llvm_name = "image-insts", .description = "Support image instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.image_store_d16_bug)] = .{ + result[@intFromEnum(Feature.image_store_d16_bug)] = .{ .llvm_name = "image-store-d16-bug", .description = "Image Store D16 hardware bug", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.inst_fwd_prefetch_bug)] = .{ + result[@intFromEnum(Feature.inst_fwd_prefetch_bug)] = .{ .llvm_name = "inst-fwd-prefetch-bug", .description = "S_INST_PREFETCH instruction causes shader to hang", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.int_clamp_insts)] = .{ + result[@intFromEnum(Feature.int_clamp_insts)] = .{ .llvm_name = "int-clamp-insts", .description = "Support clamp for integer destination", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.inv_2pi_inline_imm)] = .{ + result[@intFromEnum(Feature.inv_2pi_inline_imm)] = .{ .llvm_name = "inv-2pi-inline-imm", .description = "Has 1 / (2 * pi) as inline immediate", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lds_branch_vmem_war_hazard)] = .{ + result[@intFromEnum(Feature.lds_branch_vmem_war_hazard)] = .{ .llvm_name = "lds-branch-vmem-war-hazard", .description = "Switching between LDS and VMEM-tex not waiting VM_VSRC=0", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lds_misaligned_bug)] = .{ + result[@intFromEnum(Feature.lds_misaligned_bug)] = .{ .llvm_name = "lds-misaligned-bug", .description = "Some GFX10 bug with multi-dword LDS and flat access that is not naturally aligned in WGP mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ldsbankcount16)] = .{ + result[@intFromEnum(Feature.ldsbankcount16)] = .{ .llvm_name = "ldsbankcount16", .description = "The number of LDS banks per compute unit.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ldsbankcount32)] = .{ + result[@intFromEnum(Feature.ldsbankcount32)] = .{ .llvm_name = "ldsbankcount32", .description = "The number of LDS banks per compute unit.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.load_store_opt)] = .{ + result[@intFromEnum(Feature.load_store_opt)] = .{ .llvm_name = "load-store-opt", .description = "Enable SI load/store optimizer pass", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.localmemorysize32768)] = .{ + result[@intFromEnum(Feature.localmemorysize32768)] = .{ .llvm_name = "localmemorysize32768", .description = "The size of local memory in bytes", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.localmemorysize65536)] = .{ + result[@intFromEnum(Feature.localmemorysize65536)] = .{ .llvm_name = "localmemorysize65536", .description = "The size of local memory in bytes", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mad_intra_fwd_bug)] = .{ + result[@intFromEnum(Feature.mad_intra_fwd_bug)] = .{ .llvm_name = "mad-intra-fwd-bug", .description = "MAD_U64/I64 intra instruction forwarding bug", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mad_mac_f32_insts)] = .{ + result[@intFromEnum(Feature.mad_mac_f32_insts)] = .{ .llvm_name = "mad-mac-f32-insts", .description = "Has v_mad_f32/v_mac_f32/v_madak_f32/v_madmk_f32 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mad_mix_insts)] = .{ + result[@intFromEnum(Feature.mad_mix_insts)] = .{ .llvm_name = "mad-mix-insts", .description = "Has v_mad_mix_f32, v_mad_mixlo_f16, v_mad_mixhi_f16 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mai_insts)] = .{ + result[@intFromEnum(Feature.mai_insts)] = .{ .llvm_name = "mai-insts", .description = "Has mAI instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.max_private_element_size_16)] = .{ + result[@intFromEnum(Feature.max_private_element_size_16)] = .{ .llvm_name = "max-private-element-size-16", .description = "Maximum private access size may be 16", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.max_private_element_size_4)] = .{ + result[@intFromEnum(Feature.max_private_element_size_4)] = .{ .llvm_name = "max-private-element-size-4", .description = "Maximum private access size may be 4", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.max_private_element_size_8)] = .{ + result[@intFromEnum(Feature.max_private_element_size_8)] = .{ .llvm_name = "max-private-element-size-8", .description = "Maximum private access size may be 8", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mfma_inline_literal_bug)] = .{ + result[@intFromEnum(Feature.mfma_inline_literal_bug)] = .{ .llvm_name = "mfma-inline-literal-bug", .description = "MFMA cannot use inline literal as SrcC", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mimg_r128)] = .{ + result[@intFromEnum(Feature.mimg_r128)] = .{ .llvm_name = "mimg-r128", .description = "Support 128-bit texture resources", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.movrel)] = .{ + result[@intFromEnum(Feature.movrel)] = .{ .llvm_name = "movrel", .description = "Has v_movrel*_b32 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.negative_scratch_offset_bug)] = .{ + result[@intFromEnum(Feature.negative_scratch_offset_bug)] = .{ .llvm_name = "negative-scratch-offset-bug", .description = "Negative immediate offsets in scratch instructions with an SGPR offset page fault on GFX9", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.negative_unaligned_scratch_offset_bug)] = .{ + result[@intFromEnum(Feature.negative_unaligned_scratch_offset_bug)] = .{ .llvm_name = "negative-unaligned-scratch-offset-bug", .description = "Scratch instructions with a VGPR offset and a negative immediate offset that is not a multiple of 4 read wrong memory on GFX10", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_data_dep_hazard)] = .{ + result[@intFromEnum(Feature.no_data_dep_hazard)] = .{ .llvm_name = "no-data-dep-hazard", .description = "Does not need SW waitstates", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_sdst_cmpx)] = .{ + result[@intFromEnum(Feature.no_sdst_cmpx)] = .{ .llvm_name = "no-sdst-cmpx", .description = "V_CMPX does not write VCC/SGPR in addition to EXEC", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nsa_clause_bug)] = .{ + result[@intFromEnum(Feature.nsa_clause_bug)] = .{ .llvm_name = "nsa-clause-bug", .description = "MIMG-NSA in a hard clause has unpredictable results on GFX10.1", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nsa_encoding)] = .{ + result[@intFromEnum(Feature.nsa_encoding)] = .{ .llvm_name = "nsa-encoding", .description = "Support NSA encoding for image instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nsa_max_size_13)] = .{ + result[@intFromEnum(Feature.nsa_max_size_13)] = .{ .llvm_name = "nsa-max-size-13", .description = "The maximum non-sequential address size in VGPRs.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nsa_max_size_5)] = .{ + result[@intFromEnum(Feature.nsa_max_size_5)] = .{ .llvm_name = "nsa-max-size-5", .description = "The maximum non-sequential address size in VGPRs.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nsa_to_vmem_bug)] = .{ + result[@intFromEnum(Feature.nsa_to_vmem_bug)] = .{ .llvm_name = "nsa-to-vmem-bug", .description = "MIMG-NSA followed by VMEM fail if EXEC_LO or EXEC_HI equals zero", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.offset_3f_bug)] = .{ + result[@intFromEnum(Feature.offset_3f_bug)] = .{ .llvm_name = "offset-3f-bug", .description = "Branch offset of 3f hardware bug", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.packed_fp32_ops)] = .{ + result[@intFromEnum(Feature.packed_fp32_ops)] = .{ .llvm_name = "packed-fp32-ops", .description = "Support packed fp32 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.packed_tid)] = .{ + result[@intFromEnum(Feature.packed_tid)] = .{ .llvm_name = "packed-tid", .description = "Workitem IDs are packed into v0 at kernel launch", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.pk_fmac_f16_inst)] = .{ + result[@intFromEnum(Feature.pk_fmac_f16_inst)] = .{ .llvm_name = "pk-fmac-f16-inst", .description = "Has v_pk_fmac_f16 instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.promote_alloca)] = .{ + result[@intFromEnum(Feature.promote_alloca)] = .{ .llvm_name = "promote-alloca", .description = "Enable promote alloca pass", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prt_strict_null)] = .{ + result[@intFromEnum(Feature.prt_strict_null)] = .{ .llvm_name = "enable-prt-strict-null", .description = "Enable zeroing of result registers for sparse texture fetches", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.r128_a16)] = .{ + result[@intFromEnum(Feature.r128_a16)] = .{ .llvm_name = "r128-a16", .description = "Support gfx9-style A16 for 16-bit coordinates/gradients/lod/clamp/mip image operands, where a16 is aliased with r128", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.s_memrealtime)] = .{ + result[@intFromEnum(Feature.s_memrealtime)] = .{ .llvm_name = "s-memrealtime", .description = "Has s_memrealtime instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.s_memtime_inst)] = .{ + result[@intFromEnum(Feature.s_memtime_inst)] = .{ .llvm_name = "s-memtime-inst", .description = "Has s_memtime instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.scalar_atomics)] = .{ + result[@intFromEnum(Feature.scalar_atomics)] = .{ .llvm_name = "scalar-atomics", .description = "Has atomic scalar memory instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.scalar_flat_scratch_insts)] = .{ + result[@intFromEnum(Feature.scalar_flat_scratch_insts)] = .{ .llvm_name = "scalar-flat-scratch-insts", .description = "Have s_scratch_* flat memory instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.scalar_stores)] = .{ + result[@intFromEnum(Feature.scalar_stores)] = .{ .llvm_name = "scalar-stores", .description = "Has store scalar memory instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sdwa)] = .{ + result[@intFromEnum(Feature.sdwa)] = .{ .llvm_name = "sdwa", .description = "Support SDWA (Sub-DWORD Addressing) extension", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sdwa_mav)] = .{ + result[@intFromEnum(Feature.sdwa_mav)] = .{ .llvm_name = "sdwa-mav", .description = "Support v_mac_f32/f16 with SDWA (Sub-DWORD Addressing) extension", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sdwa_omod)] = .{ + result[@intFromEnum(Feature.sdwa_omod)] = .{ .llvm_name = "sdwa-omod", .description = "Support OMod with SDWA (Sub-DWORD Addressing) extension", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sdwa_out_mods_vopc)] = .{ + result[@intFromEnum(Feature.sdwa_out_mods_vopc)] = .{ .llvm_name = "sdwa-out-mods-vopc", .description = "Support clamp for VOPC with SDWA (Sub-DWORD Addressing) extension", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sdwa_scalar)] = .{ + result[@intFromEnum(Feature.sdwa_scalar)] = .{ .llvm_name = "sdwa-scalar", .description = "Support scalar register with SDWA (Sub-DWORD Addressing) extension", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sdwa_sdst)] = .{ + result[@intFromEnum(Feature.sdwa_sdst)] = .{ .llvm_name = "sdwa-sdst", .description = "Support scalar dst for VOPC with SDWA (Sub-DWORD Addressing) extension", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sea_islands)] = .{ + result[@intFromEnum(Feature.sea_islands)] = .{ .llvm_name = "sea-islands", .description = "SEA_ISLANDS GPU generation", .dependencies = featureSet(&[_]Feature{ @@ -868,27 +868,27 @@ pub const all_features = blk: { .wavefrontsize64, }), }; - result[@enumToInt(Feature.sgpr_init_bug)] = .{ + result[@intFromEnum(Feature.sgpr_init_bug)] = .{ .llvm_name = "sgpr-init-bug", .description = "VI SGPR initialization bug requiring a fixed SGPR allocation size", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.shader_cycles_register)] = .{ + result[@intFromEnum(Feature.shader_cycles_register)] = .{ .llvm_name = "shader-cycles-register", .description = "Has SHADER_CYCLES hardware register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.si_scheduler)] = .{ + result[@intFromEnum(Feature.si_scheduler)] = .{ .llvm_name = "si-scheduler", .description = "Enable SI Machine Scheduler", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.smem_to_vector_write_hazard)] = .{ + result[@intFromEnum(Feature.smem_to_vector_write_hazard)] = .{ .llvm_name = "smem-to-vector-write-hazard", .description = "s_load_dword followed by v_cmp page faults", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.southern_islands)] = .{ + result[@intFromEnum(Feature.southern_islands)] = .{ .llvm_name = "southern-islands", .description = "SOUTHERN_ISLANDS GPU generation", .dependencies = featureSet(&[_]Feature{ @@ -906,97 +906,97 @@ pub const all_features = blk: { .wavefrontsize64, }), }; - result[@enumToInt(Feature.sramecc)] = .{ + result[@intFromEnum(Feature.sramecc)] = .{ .llvm_name = "sramecc", .description = "Enable SRAMECC", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sramecc_support)] = .{ + result[@intFromEnum(Feature.sramecc_support)] = .{ .llvm_name = "sramecc-support", .description = "Hardware supports SRAMECC", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tgsplit)] = .{ + result[@intFromEnum(Feature.tgsplit)] = .{ .llvm_name = "tgsplit", .description = "Enable threadgroup split execution", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.trap_handler)] = .{ + result[@intFromEnum(Feature.trap_handler)] = .{ .llvm_name = "trap-handler", .description = "Trap handler support", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.trig_reduced_range)] = .{ + result[@intFromEnum(Feature.trig_reduced_range)] = .{ .llvm_name = "trig-reduced-range", .description = "Requires use of fract on arguments to trig instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.true16)] = .{ + result[@intFromEnum(Feature.true16)] = .{ .llvm_name = "true16", .description = "True 16-bit operand instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.unaligned_access_mode)] = .{ + result[@intFromEnum(Feature.unaligned_access_mode)] = .{ .llvm_name = "unaligned-access-mode", .description = "Enable unaligned global, local and region loads and stores if the hardware supports it", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.unaligned_buffer_access)] = .{ + result[@intFromEnum(Feature.unaligned_buffer_access)] = .{ .llvm_name = "unaligned-buffer-access", .description = "Hardware supports unaligned global loads and stores", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.unaligned_ds_access)] = .{ + result[@intFromEnum(Feature.unaligned_ds_access)] = .{ .llvm_name = "unaligned-ds-access", .description = "Hardware supports unaligned local and region loads and stores", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.unaligned_scratch_access)] = .{ + result[@intFromEnum(Feature.unaligned_scratch_access)] = .{ .llvm_name = "unaligned-scratch-access", .description = "Support unaligned scratch loads and stores", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.unpacked_d16_vmem)] = .{ + result[@intFromEnum(Feature.unpacked_d16_vmem)] = .{ .llvm_name = "unpacked-d16-vmem", .description = "Has unpacked d16 vmem instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.unsafe_ds_offset_folding)] = .{ + result[@intFromEnum(Feature.unsafe_ds_offset_folding)] = .{ .llvm_name = "unsafe-ds-offset-folding", .description = "Force using DS instruction immediate offsets on SI", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.user_sgpr_init16_bug)] = .{ + result[@intFromEnum(Feature.user_sgpr_init16_bug)] = .{ .llvm_name = "user-sgpr-init16-bug", .description = "Bug requiring at least 16 user+system SGPRs to be enabled", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.valu_trans_use_hazard)] = .{ + result[@intFromEnum(Feature.valu_trans_use_hazard)] = .{ .llvm_name = "valu-trans-use-hazard", .description = "Hazard when TRANS instructions are closely followed by a use of the result", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vcmpx_exec_war_hazard)] = .{ + result[@intFromEnum(Feature.vcmpx_exec_war_hazard)] = .{ .llvm_name = "vcmpx-exec-war-hazard", .description = "V_CMPX WAR hazard on EXEC (V_CMPX issue ONLY)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vcmpx_permlane_hazard)] = .{ + result[@intFromEnum(Feature.vcmpx_permlane_hazard)] = .{ .llvm_name = "vcmpx-permlane-hazard", .description = "TODO: describe me", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vgpr_index_mode)] = .{ + result[@intFromEnum(Feature.vgpr_index_mode)] = .{ .llvm_name = "vgpr-index-mode", .description = "Has VGPR mode register indexing", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vmem_to_scalar_write_hazard)] = .{ + result[@intFromEnum(Feature.vmem_to_scalar_write_hazard)] = .{ .llvm_name = "vmem-to-scalar-write-hazard", .description = "VMEM instruction followed by scalar writing to EXEC mask, M0 or SGPR leads to incorrect execution.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.volcanic_islands)] = .{ + result[@intFromEnum(Feature.volcanic_islands)] = .{ .llvm_name = "volcanic-islands", .description = "VOLCANIC_ISLANDS GPU generation", .dependencies = featureSet(&[_]Feature{ @@ -1030,47 +1030,47 @@ pub const all_features = blk: { .wavefrontsize64, }), }; - result[@enumToInt(Feature.vop3_literal)] = .{ + result[@intFromEnum(Feature.vop3_literal)] = .{ .llvm_name = "vop3-literal", .description = "Can use one literal in VOP3", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vop3p)] = .{ + result[@intFromEnum(Feature.vop3p)] = .{ .llvm_name = "vop3p", .description = "Has VOP3P packed instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vopd)] = .{ + result[@intFromEnum(Feature.vopd)] = .{ .llvm_name = "vopd", .description = "Has VOPD dual issue wave32 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vscnt)] = .{ + result[@intFromEnum(Feature.vscnt)] = .{ .llvm_name = "vscnt", .description = "Has separate store vscnt counter", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.wavefrontsize16)] = .{ + result[@intFromEnum(Feature.wavefrontsize16)] = .{ .llvm_name = "wavefrontsize16", .description = "The number of threads per wavefront", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.wavefrontsize32)] = .{ + result[@intFromEnum(Feature.wavefrontsize32)] = .{ .llvm_name = "wavefrontsize32", .description = "The number of threads per wavefront", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.wavefrontsize64)] = .{ + result[@intFromEnum(Feature.wavefrontsize64)] = .{ .llvm_name = "wavefrontsize64", .description = "The number of threads per wavefront", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.xnack)] = .{ + result[@intFromEnum(Feature.xnack)] = .{ .llvm_name = "xnack", .description = "Enable XNACK support", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.xnack_support)] = .{ + result[@intFromEnum(Feature.xnack_support)] = .{ .llvm_name = "xnack-support", .description = "Hardware supports XNACK", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/arc.zig b/lib/std/target/arc.zig index 86d803c21746..eff13c66375f 100644 --- a/lib/std/target/arc.zig +++ b/lib/std/target/arc.zig @@ -17,7 +17,7 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.norm)] = .{ + result[@intFromEnum(Feature.norm)] = .{ .llvm_name = "norm", .description = "Enable support for norm instruction.", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/arm.zig b/lib/std/target/arm.zig index 18b26d5ba997..a78fd6785add 100644 --- a/lib/std/target/arm.zig +++ b/lib/std/target/arm.zig @@ -214,156 +214,156 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.@"32bit")] = .{ + result[@intFromEnum(Feature.@"32bit")] = .{ .llvm_name = "32bit", .description = "Prefer 32-bit Thumb instrs", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.@"8msecext")] = .{ + result[@intFromEnum(Feature.@"8msecext")] = .{ .llvm_name = "8msecext", .description = "Enable support for ARMv8-M Security Extensions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.a76)] = .{ + result[@intFromEnum(Feature.a76)] = .{ .llvm_name = "a76", .description = "Cortex-A76 ARM processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.aapcs_frame_chain)] = .{ + result[@intFromEnum(Feature.aapcs_frame_chain)] = .{ .llvm_name = "aapcs-frame-chain", .description = "Create an AAPCS compliant frame chain", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.aapcs_frame_chain_leaf)] = .{ + result[@intFromEnum(Feature.aapcs_frame_chain_leaf)] = .{ .llvm_name = "aapcs-frame-chain-leaf", .description = "Create an AAPCS compliant frame chain for leaf functions", .dependencies = featureSet(&[_]Feature{ .aapcs_frame_chain, }), }; - result[@enumToInt(Feature.aclass)] = .{ + result[@intFromEnum(Feature.aclass)] = .{ .llvm_name = "aclass", .description = "Is application profile ('A' series)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.acquire_release)] = .{ + result[@intFromEnum(Feature.acquire_release)] = .{ .llvm_name = "acquire-release", .description = "Has v8 acquire/release (lda/ldaex etc) instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.aes)] = .{ + result[@intFromEnum(Feature.aes)] = .{ .llvm_name = "aes", .description = "Enable AES support", .dependencies = featureSet(&[_]Feature{ .neon, }), }; - result[@enumToInt(Feature.atomics_32)] = .{ + result[@intFromEnum(Feature.atomics_32)] = .{ .llvm_name = "atomics-32", .description = "Assume that lock-free 32-bit atomics are available", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.avoid_movs_shop)] = .{ + result[@intFromEnum(Feature.avoid_movs_shop)] = .{ .llvm_name = "avoid-movs-shop", .description = "Avoid movs instructions with shifter operand", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.avoid_partial_cpsr)] = .{ + result[@intFromEnum(Feature.avoid_partial_cpsr)] = .{ .llvm_name = "avoid-partial-cpsr", .description = "Avoid CPSR partial update for OOO execution", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.bf16)] = .{ + result[@intFromEnum(Feature.bf16)] = .{ .llvm_name = "bf16", .description = "Enable support for BFloat16 instructions", .dependencies = featureSet(&[_]Feature{ .neon, }), }; - result[@enumToInt(Feature.big_endian_instructions)] = .{ + result[@intFromEnum(Feature.big_endian_instructions)] = .{ .llvm_name = "big-endian-instructions", .description = "Expect instructions to be stored big-endian.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.cde)] = .{ + result[@intFromEnum(Feature.cde)] = .{ .llvm_name = "cde", .description = "Support CDE instructions", .dependencies = featureSet(&[_]Feature{ .has_v8m_main, }), }; - result[@enumToInt(Feature.cdecp0)] = .{ + result[@intFromEnum(Feature.cdecp0)] = .{ .llvm_name = "cdecp0", .description = "Coprocessor 0 ISA is CDEv1", .dependencies = featureSet(&[_]Feature{ .cde, }), }; - result[@enumToInt(Feature.cdecp1)] = .{ + result[@intFromEnum(Feature.cdecp1)] = .{ .llvm_name = "cdecp1", .description = "Coprocessor 1 ISA is CDEv1", .dependencies = featureSet(&[_]Feature{ .cde, }), }; - result[@enumToInt(Feature.cdecp2)] = .{ + result[@intFromEnum(Feature.cdecp2)] = .{ .llvm_name = "cdecp2", .description = "Coprocessor 2 ISA is CDEv1", .dependencies = featureSet(&[_]Feature{ .cde, }), }; - result[@enumToInt(Feature.cdecp3)] = .{ + result[@intFromEnum(Feature.cdecp3)] = .{ .llvm_name = "cdecp3", .description = "Coprocessor 3 ISA is CDEv1", .dependencies = featureSet(&[_]Feature{ .cde, }), }; - result[@enumToInt(Feature.cdecp4)] = .{ + result[@intFromEnum(Feature.cdecp4)] = .{ .llvm_name = "cdecp4", .description = "Coprocessor 4 ISA is CDEv1", .dependencies = featureSet(&[_]Feature{ .cde, }), }; - result[@enumToInt(Feature.cdecp5)] = .{ + result[@intFromEnum(Feature.cdecp5)] = .{ .llvm_name = "cdecp5", .description = "Coprocessor 5 ISA is CDEv1", .dependencies = featureSet(&[_]Feature{ .cde, }), }; - result[@enumToInt(Feature.cdecp6)] = .{ + result[@intFromEnum(Feature.cdecp6)] = .{ .llvm_name = "cdecp6", .description = "Coprocessor 6 ISA is CDEv1", .dependencies = featureSet(&[_]Feature{ .cde, }), }; - result[@enumToInt(Feature.cdecp7)] = .{ + result[@intFromEnum(Feature.cdecp7)] = .{ .llvm_name = "cdecp7", .description = "Coprocessor 7 ISA is CDEv1", .dependencies = featureSet(&[_]Feature{ .cde, }), }; - result[@enumToInt(Feature.cheap_predicable_cpsr)] = .{ + result[@intFromEnum(Feature.cheap_predicable_cpsr)] = .{ .llvm_name = "cheap-predicable-cpsr", .description = "Disable +1 predication cost for instructions updating CPSR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.clrbhb)] = .{ + result[@intFromEnum(Feature.clrbhb)] = .{ .llvm_name = "clrbhb", .description = "Enable Clear BHB instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.crc)] = .{ + result[@intFromEnum(Feature.crc)] = .{ .llvm_name = "crc", .description = "Enable support for CRC instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.crypto)] = .{ + result[@intFromEnum(Feature.crypto)] = .{ .llvm_name = "crypto", .description = "Enable support for Cryptography extensions", .dependencies = featureSet(&[_]Feature{ @@ -371,54 +371,54 @@ pub const all_features = blk: { .sha2, }), }; - result[@enumToInt(Feature.d32)] = .{ + result[@intFromEnum(Feature.d32)] = .{ .llvm_name = "d32", .description = "Extend FP to 32 double registers", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.db)] = .{ + result[@intFromEnum(Feature.db)] = .{ .llvm_name = "db", .description = "Has data barrier (dmb/dsb) instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dfb)] = .{ + result[@intFromEnum(Feature.dfb)] = .{ .llvm_name = "dfb", .description = "Has full data barrier (dfb) instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.disable_postra_scheduler)] = .{ + result[@intFromEnum(Feature.disable_postra_scheduler)] = .{ .llvm_name = "disable-postra-scheduler", .description = "Don't schedule again after register allocation", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dont_widen_vmovs)] = .{ + result[@intFromEnum(Feature.dont_widen_vmovs)] = .{ .llvm_name = "dont-widen-vmovs", .description = "Don't widen VMOVS to VMOVD", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dotprod)] = .{ + result[@intFromEnum(Feature.dotprod)] = .{ .llvm_name = "dotprod", .description = "Enable support for dot product instructions", .dependencies = featureSet(&[_]Feature{ .neon, }), }; - result[@enumToInt(Feature.dsp)] = .{ + result[@intFromEnum(Feature.dsp)] = .{ .llvm_name = "dsp", .description = "Supports DSP instructions in ARM and/or Thumb2", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.execute_only)] = .{ + result[@intFromEnum(Feature.execute_only)] = .{ .llvm_name = "execute-only", .description = "Enable the generation of execute only code.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.expand_fp_mlx)] = .{ + result[@intFromEnum(Feature.expand_fp_mlx)] = .{ .llvm_name = "expand-fp-mlx", .description = "Expand VFP/NEON MLA/MLS instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.exynos)] = .{ + result[@intFromEnum(Feature.exynos)] = .{ .llvm_name = "exynos", .description = "Samsung Exynos processors", .dependencies = featureSet(&[_]Feature{ @@ -441,36 +441,36 @@ pub const all_features = blk: { .zcz, }), }; - result[@enumToInt(Feature.fix_cmse_cve_2021_35465)] = .{ + result[@intFromEnum(Feature.fix_cmse_cve_2021_35465)] = .{ .llvm_name = "fix-cmse-cve-2021-35465", .description = "Mitigate against the cve-2021-35465 security vulnurability", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fix_cortex_a57_aes_1742098)] = .{ + result[@intFromEnum(Feature.fix_cortex_a57_aes_1742098)] = .{ .llvm_name = "fix-cortex-a57-aes-1742098", .description = "Work around Cortex-A57 Erratum 1742098 / Cortex-A72 Erratum 1655431 (AES)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fp16)] = .{ + result[@intFromEnum(Feature.fp16)] = .{ .llvm_name = "fp16", .description = "Enable half-precision floating point", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fp16fml)] = .{ + result[@intFromEnum(Feature.fp16fml)] = .{ .llvm_name = "fp16fml", .description = "Enable full half-precision floating point fml instructions", .dependencies = featureSet(&[_]Feature{ .fullfp16, }), }; - result[@enumToInt(Feature.fp64)] = .{ + result[@intFromEnum(Feature.fp64)] = .{ .llvm_name = "fp64", .description = "Floating point unit supports double precision", .dependencies = featureSet(&[_]Feature{ .fpregs64, }), }; - result[@enumToInt(Feature.fp_armv8)] = .{ + result[@intFromEnum(Feature.fp_armv8)] = .{ .llvm_name = "fp-armv8", .description = "Enable ARMv8 FP", .dependencies = featureSet(&[_]Feature{ @@ -479,7 +479,7 @@ pub const all_features = blk: { .vfp4, }), }; - result[@enumToInt(Feature.fp_armv8d16)] = .{ + result[@intFromEnum(Feature.fp_armv8d16)] = .{ .llvm_name = "fp-armv8d16", .description = "Enable ARMv8 FP with only 16 d-registers", .dependencies = featureSet(&[_]Feature{ @@ -487,14 +487,14 @@ pub const all_features = blk: { .vfp4d16, }), }; - result[@enumToInt(Feature.fp_armv8d16sp)] = .{ + result[@intFromEnum(Feature.fp_armv8d16sp)] = .{ .llvm_name = "fp-armv8d16sp", .description = "Enable ARMv8 FP with only 16 d-registers and no double precision", .dependencies = featureSet(&[_]Feature{ .vfp4d16sp, }), }; - result[@enumToInt(Feature.fp_armv8sp)] = .{ + result[@intFromEnum(Feature.fp_armv8sp)] = .{ .llvm_name = "fp-armv8sp", .description = "Enable ARMv8 FP with no double precision", .dependencies = featureSet(&[_]Feature{ @@ -502,31 +502,31 @@ pub const all_features = blk: { .vfp4sp, }), }; - result[@enumToInt(Feature.fpao)] = .{ + result[@intFromEnum(Feature.fpao)] = .{ .llvm_name = "fpao", .description = "Enable fast computation of positive address offsets", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fpregs)] = .{ + result[@intFromEnum(Feature.fpregs)] = .{ .llvm_name = "fpregs", .description = "Enable FP registers", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fpregs16)] = .{ + result[@intFromEnum(Feature.fpregs16)] = .{ .llvm_name = "fpregs16", .description = "Enable 16-bit FP registers", .dependencies = featureSet(&[_]Feature{ .fpregs, }), }; - result[@enumToInt(Feature.fpregs64)] = .{ + result[@intFromEnum(Feature.fpregs64)] = .{ .llvm_name = "fpregs64", .description = "Enable 64-bit FP registers", .dependencies = featureSet(&[_]Feature{ .fpregs, }), }; - result[@enumToInt(Feature.fullfp16)] = .{ + result[@intFromEnum(Feature.fullfp16)] = .{ .llvm_name = "fullfp16", .description = "Enable full half-precision floating point", .dependencies = featureSet(&[_]Feature{ @@ -534,72 +534,72 @@ pub const all_features = blk: { .fpregs16, }), }; - result[@enumToInt(Feature.fuse_aes)] = .{ + result[@intFromEnum(Feature.fuse_aes)] = .{ .llvm_name = "fuse-aes", .description = "CPU fuses AES crypto operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fuse_literals)] = .{ + result[@intFromEnum(Feature.fuse_literals)] = .{ .llvm_name = "fuse-literals", .description = "CPU fuses literal generation operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.harden_sls_blr)] = .{ + result[@intFromEnum(Feature.harden_sls_blr)] = .{ .llvm_name = "harden-sls-blr", .description = "Harden against straight line speculation across indirect calls", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.harden_sls_nocomdat)] = .{ + result[@intFromEnum(Feature.harden_sls_nocomdat)] = .{ .llvm_name = "harden-sls-nocomdat", .description = "Generate thunk code for SLS mitigation in the normal text section", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.harden_sls_retbr)] = .{ + result[@intFromEnum(Feature.harden_sls_retbr)] = .{ .llvm_name = "harden-sls-retbr", .description = "Harden against straight line speculation across RETurn and BranchRegister instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.has_v4t)] = .{ + result[@intFromEnum(Feature.has_v4t)] = .{ .llvm_name = "v4t", .description = "Support ARM v4T instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.has_v5t)] = .{ + result[@intFromEnum(Feature.has_v5t)] = .{ .llvm_name = "v5t", .description = "Support ARM v5T instructions", .dependencies = featureSet(&[_]Feature{ .has_v4t, }), }; - result[@enumToInt(Feature.has_v5te)] = .{ + result[@intFromEnum(Feature.has_v5te)] = .{ .llvm_name = "v5te", .description = "Support ARM v5TE, v5TEj, and v5TExp instructions", .dependencies = featureSet(&[_]Feature{ .has_v5t, }), }; - result[@enumToInt(Feature.has_v6)] = .{ + result[@intFromEnum(Feature.has_v6)] = .{ .llvm_name = "v6", .description = "Support ARM v6 instructions", .dependencies = featureSet(&[_]Feature{ .has_v5te, }), }; - result[@enumToInt(Feature.has_v6k)] = .{ + result[@intFromEnum(Feature.has_v6k)] = .{ .llvm_name = "v6k", .description = "Support ARM v6k instructions", .dependencies = featureSet(&[_]Feature{ .has_v6, }), }; - result[@enumToInt(Feature.has_v6m)] = .{ + result[@intFromEnum(Feature.has_v6m)] = .{ .llvm_name = "v6m", .description = "Support ARM v6M instructions", .dependencies = featureSet(&[_]Feature{ .has_v6, }), }; - result[@enumToInt(Feature.has_v6t2)] = .{ + result[@intFromEnum(Feature.has_v6t2)] = .{ .llvm_name = "v6t2", .description = "Support ARM v6t2 instructions", .dependencies = featureSet(&[_]Feature{ @@ -608,7 +608,7 @@ pub const all_features = blk: { .thumb2, }), }; - result[@enumToInt(Feature.has_v7)] = .{ + result[@intFromEnum(Feature.has_v7)] = .{ .llvm_name = "v7", .description = "Support ARM v7 instructions", .dependencies = featureSet(&[_]Feature{ @@ -616,12 +616,12 @@ pub const all_features = blk: { .has_v7clrex, }), }; - result[@enumToInt(Feature.has_v7clrex)] = .{ + result[@intFromEnum(Feature.has_v7clrex)] = .{ .llvm_name = "v7clrex", .description = "Has v7 clrex instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.has_v8)] = .{ + result[@intFromEnum(Feature.has_v8)] = .{ .llvm_name = "v8", .description = "Support ARM v8 instructions", .dependencies = featureSet(&[_]Feature{ @@ -630,35 +630,35 @@ pub const all_features = blk: { .perfmon, }), }; - result[@enumToInt(Feature.has_v8_1a)] = .{ + result[@intFromEnum(Feature.has_v8_1a)] = .{ .llvm_name = "v8.1a", .description = "Support ARM v8.1a instructions", .dependencies = featureSet(&[_]Feature{ .has_v8, }), }; - result[@enumToInt(Feature.has_v8_1m_main)] = .{ + result[@intFromEnum(Feature.has_v8_1m_main)] = .{ .llvm_name = "v8.1m.main", .description = "Support ARM v8-1M Mainline instructions", .dependencies = featureSet(&[_]Feature{ .has_v8m_main, }), }; - result[@enumToInt(Feature.has_v8_2a)] = .{ + result[@intFromEnum(Feature.has_v8_2a)] = .{ .llvm_name = "v8.2a", .description = "Support ARM v8.2a instructions", .dependencies = featureSet(&[_]Feature{ .has_v8_1a, }), }; - result[@enumToInt(Feature.has_v8_3a)] = .{ + result[@intFromEnum(Feature.has_v8_3a)] = .{ .llvm_name = "v8.3a", .description = "Support ARM v8.3a instructions", .dependencies = featureSet(&[_]Feature{ .has_v8_2a, }), }; - result[@enumToInt(Feature.has_v8_4a)] = .{ + result[@intFromEnum(Feature.has_v8_4a)] = .{ .llvm_name = "v8.4a", .description = "Support ARM v8.4a instructions", .dependencies = featureSet(&[_]Feature{ @@ -666,7 +666,7 @@ pub const all_features = blk: { .has_v8_3a, }), }; - result[@enumToInt(Feature.has_v8_5a)] = .{ + result[@intFromEnum(Feature.has_v8_5a)] = .{ .llvm_name = "v8.5a", .description = "Support ARM v8.5a instructions", .dependencies = featureSet(&[_]Feature{ @@ -674,7 +674,7 @@ pub const all_features = blk: { .sb, }), }; - result[@enumToInt(Feature.has_v8_6a)] = .{ + result[@intFromEnum(Feature.has_v8_6a)] = .{ .llvm_name = "v8.6a", .description = "Support ARM v8.6a instructions", .dependencies = featureSet(&[_]Feature{ @@ -683,21 +683,21 @@ pub const all_features = blk: { .i8mm, }), }; - result[@enumToInt(Feature.has_v8_7a)] = .{ + result[@intFromEnum(Feature.has_v8_7a)] = .{ .llvm_name = "v8.7a", .description = "Support ARM v8.7a instructions", .dependencies = featureSet(&[_]Feature{ .has_v8_6a, }), }; - result[@enumToInt(Feature.has_v8_8a)] = .{ + result[@intFromEnum(Feature.has_v8_8a)] = .{ .llvm_name = "v8.8a", .description = "Support ARM v8.8a instructions", .dependencies = featureSet(&[_]Feature{ .has_v8_7a, }), }; - result[@enumToInt(Feature.has_v8_9a)] = .{ + result[@intFromEnum(Feature.has_v8_9a)] = .{ .llvm_name = "v8.9a", .description = "Support ARM v8.9a instructions", .dependencies = featureSet(&[_]Feature{ @@ -705,21 +705,21 @@ pub const all_features = blk: { .has_v8_8a, }), }; - result[@enumToInt(Feature.has_v8m)] = .{ + result[@intFromEnum(Feature.has_v8m)] = .{ .llvm_name = "v8m", .description = "Support ARM v8M Baseline instructions", .dependencies = featureSet(&[_]Feature{ .has_v6m, }), }; - result[@enumToInt(Feature.has_v8m_main)] = .{ + result[@intFromEnum(Feature.has_v8m_main)] = .{ .llvm_name = "v8m.main", .description = "Support ARM v8M Mainline instructions", .dependencies = featureSet(&[_]Feature{ .has_v7, }), }; - result[@enumToInt(Feature.has_v9_1a)] = .{ + result[@intFromEnum(Feature.has_v9_1a)] = .{ .llvm_name = "v9.1a", .description = "Support ARM v9.1a instructions", .dependencies = featureSet(&[_]Feature{ @@ -727,7 +727,7 @@ pub const all_features = blk: { .has_v9a, }), }; - result[@enumToInt(Feature.has_v9_2a)] = .{ + result[@intFromEnum(Feature.has_v9_2a)] = .{ .llvm_name = "v9.2a", .description = "Support ARM v9.2a instructions", .dependencies = featureSet(&[_]Feature{ @@ -735,7 +735,7 @@ pub const all_features = blk: { .has_v9_1a, }), }; - result[@enumToInt(Feature.has_v9_3a)] = .{ + result[@intFromEnum(Feature.has_v9_3a)] = .{ .llvm_name = "v9.3a", .description = "Support ARM v9.3a instructions", .dependencies = featureSet(&[_]Feature{ @@ -743,7 +743,7 @@ pub const all_features = blk: { .has_v9_2a, }), }; - result[@enumToInt(Feature.has_v9_4a)] = .{ + result[@intFromEnum(Feature.has_v9_4a)] = .{ .llvm_name = "v9.4a", .description = "Support ARM v9.4a instructions", .dependencies = featureSet(&[_]Feature{ @@ -751,80 +751,80 @@ pub const all_features = blk: { .has_v9_3a, }), }; - result[@enumToInt(Feature.has_v9a)] = .{ + result[@intFromEnum(Feature.has_v9a)] = .{ .llvm_name = "v9a", .description = "Support ARM v9a instructions", .dependencies = featureSet(&[_]Feature{ .has_v8_5a, }), }; - result[@enumToInt(Feature.hwdiv)] = .{ + result[@intFromEnum(Feature.hwdiv)] = .{ .llvm_name = "hwdiv", .description = "Enable divide instructions in Thumb", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hwdiv_arm)] = .{ + result[@intFromEnum(Feature.hwdiv_arm)] = .{ .llvm_name = "hwdiv-arm", .description = "Enable divide instructions in ARM mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.i8mm)] = .{ + result[@intFromEnum(Feature.i8mm)] = .{ .llvm_name = "i8mm", .description = "Enable Matrix Multiply Int8 Extension", .dependencies = featureSet(&[_]Feature{ .neon, }), }; - result[@enumToInt(Feature.iwmmxt)] = .{ + result[@intFromEnum(Feature.iwmmxt)] = .{ .llvm_name = "iwmmxt", .description = "ARMv5te architecture", .dependencies = featureSet(&[_]Feature{ .v5te, }), }; - result[@enumToInt(Feature.iwmmxt2)] = .{ + result[@intFromEnum(Feature.iwmmxt2)] = .{ .llvm_name = "iwmmxt2", .description = "ARMv5te architecture", .dependencies = featureSet(&[_]Feature{ .v5te, }), }; - result[@enumToInt(Feature.lob)] = .{ + result[@intFromEnum(Feature.lob)] = .{ .llvm_name = "lob", .description = "Enable Low Overhead Branch extensions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.long_calls)] = .{ + result[@intFromEnum(Feature.long_calls)] = .{ .llvm_name = "long-calls", .description = "Generate calls via indirect call instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.loop_align)] = .{ + result[@intFromEnum(Feature.loop_align)] = .{ .llvm_name = "loop-align", .description = "Prefer 32-bit alignment for loops", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.m3)] = .{ + result[@intFromEnum(Feature.m3)] = .{ .llvm_name = "m3", .description = "Cortex-M3 ARM processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mclass)] = .{ + result[@intFromEnum(Feature.mclass)] = .{ .llvm_name = "mclass", .description = "Is microcontroller profile ('M' series)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mp)] = .{ + result[@intFromEnum(Feature.mp)] = .{ .llvm_name = "mp", .description = "Supports Multiprocessing extension", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.muxed_units)] = .{ + result[@intFromEnum(Feature.muxed_units)] = .{ .llvm_name = "muxed-units", .description = "Has muxed AGU and NEON/FPU", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mve)] = .{ + result[@intFromEnum(Feature.mve)] = .{ .llvm_name = "mve", .description = "Support M-Class Vector Extension with integer ops", .dependencies = featureSet(&[_]Feature{ @@ -834,22 +834,22 @@ pub const all_features = blk: { .has_v8_1m_main, }), }; - result[@enumToInt(Feature.mve1beat)] = .{ + result[@intFromEnum(Feature.mve1beat)] = .{ .llvm_name = "mve1beat", .description = "Model MVE instructions as a 1 beat per tick architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mve2beat)] = .{ + result[@intFromEnum(Feature.mve2beat)] = .{ .llvm_name = "mve2beat", .description = "Model MVE instructions as a 2 beats per tick architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mve4beat)] = .{ + result[@intFromEnum(Feature.mve4beat)] = .{ .llvm_name = "mve4beat", .description = "Model MVE instructions as a 4 beats per tick architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mve_fp)] = .{ + result[@intFromEnum(Feature.mve_fp)] = .{ .llvm_name = "mve.fp", .description = "Support M-Class Vector Extension with integer and floating ops", .dependencies = featureSet(&[_]Feature{ @@ -857,243 +857,243 @@ pub const all_features = blk: { .mve, }), }; - result[@enumToInt(Feature.nacl_trap)] = .{ + result[@intFromEnum(Feature.nacl_trap)] = .{ .llvm_name = "nacl-trap", .description = "NaCl trap", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.neon)] = .{ + result[@intFromEnum(Feature.neon)] = .{ .llvm_name = "neon", .description = "Enable NEON instructions", .dependencies = featureSet(&[_]Feature{ .vfp3, }), }; - result[@enumToInt(Feature.neon_fpmovs)] = .{ + result[@intFromEnum(Feature.neon_fpmovs)] = .{ .llvm_name = "neon-fpmovs", .description = "Convert VMOVSR, VMOVRS, VMOVS to NEON", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.neonfp)] = .{ + result[@intFromEnum(Feature.neonfp)] = .{ .llvm_name = "neonfp", .description = "Use NEON for single precision FP", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_branch_predictor)] = .{ + result[@intFromEnum(Feature.no_branch_predictor)] = .{ .llvm_name = "no-branch-predictor", .description = "Has no branch predictor", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_bti_at_return_twice)] = .{ + result[@intFromEnum(Feature.no_bti_at_return_twice)] = .{ .llvm_name = "no-bti-at-return-twice", .description = "Don't place a BTI instruction after a return-twice", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_movt)] = .{ + result[@intFromEnum(Feature.no_movt)] = .{ .llvm_name = "no-movt", .description = "Don't use movt/movw pairs for 32-bit imms", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_neg_immediates)] = .{ + result[@intFromEnum(Feature.no_neg_immediates)] = .{ .llvm_name = "no-neg-immediates", .description = "Convert immediates and instructions to their negated or complemented equivalent when the immediate does not fit in the encoding.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.noarm)] = .{ + result[@intFromEnum(Feature.noarm)] = .{ .llvm_name = "noarm", .description = "Does not support ARM mode execution", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nonpipelined_vfp)] = .{ + result[@intFromEnum(Feature.nonpipelined_vfp)] = .{ .llvm_name = "nonpipelined-vfp", .description = "VFP instructions are not pipelined", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.pacbti)] = .{ + result[@intFromEnum(Feature.pacbti)] = .{ .llvm_name = "pacbti", .description = "Enable Pointer Authentication and Branch Target Identification", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.perfmon)] = .{ + result[@intFromEnum(Feature.perfmon)] = .{ .llvm_name = "perfmon", .description = "Enable support for Performance Monitor extensions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prefer_ishst)] = .{ + result[@intFromEnum(Feature.prefer_ishst)] = .{ .llvm_name = "prefer-ishst", .description = "Prefer ISHST barriers", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prefer_vmovsr)] = .{ + result[@intFromEnum(Feature.prefer_vmovsr)] = .{ .llvm_name = "prefer-vmovsr", .description = "Prefer VMOVSR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prof_unpr)] = .{ + result[@intFromEnum(Feature.prof_unpr)] = .{ .llvm_name = "prof-unpr", .description = "Is profitable to unpredicate", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.r4)] = .{ + result[@intFromEnum(Feature.r4)] = .{ .llvm_name = "r4", .description = "Cortex-R4 ARM processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ras)] = .{ + result[@intFromEnum(Feature.ras)] = .{ .llvm_name = "ras", .description = "Enable Reliability, Availability and Serviceability extensions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.rclass)] = .{ + result[@intFromEnum(Feature.rclass)] = .{ .llvm_name = "rclass", .description = "Is realtime profile ('R' series)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.read_tp_hard)] = .{ + result[@intFromEnum(Feature.read_tp_hard)] = .{ .llvm_name = "read-tp-hard", .description = "Reading thread pointer from register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_r9)] = .{ + result[@intFromEnum(Feature.reserve_r9)] = .{ .llvm_name = "reserve-r9", .description = "Reserve R9, making it unavailable as GPR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ret_addr_stack)] = .{ + result[@intFromEnum(Feature.ret_addr_stack)] = .{ .llvm_name = "ret-addr-stack", .description = "Has return address stack", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sb)] = .{ + result[@intFromEnum(Feature.sb)] = .{ .llvm_name = "sb", .description = "Enable v8.5a Speculation Barrier", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sha2)] = .{ + result[@intFromEnum(Feature.sha2)] = .{ .llvm_name = "sha2", .description = "Enable SHA1 and SHA256 support", .dependencies = featureSet(&[_]Feature{ .neon, }), }; - result[@enumToInt(Feature.slow_fp_brcc)] = .{ + result[@intFromEnum(Feature.slow_fp_brcc)] = .{ .llvm_name = "slow-fp-brcc", .description = "FP compare + branch is slow", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_load_D_subreg)] = .{ + result[@intFromEnum(Feature.slow_load_D_subreg)] = .{ .llvm_name = "slow-load-D-subreg", .description = "Loading into D subregs is slow", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_odd_reg)] = .{ + result[@intFromEnum(Feature.slow_odd_reg)] = .{ .llvm_name = "slow-odd-reg", .description = "VLDM/VSTM starting with an odd register is slow", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_vdup32)] = .{ + result[@intFromEnum(Feature.slow_vdup32)] = .{ .llvm_name = "slow-vdup32", .description = "Has slow VDUP32 - prefer VMOV", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_vgetlni32)] = .{ + result[@intFromEnum(Feature.slow_vgetlni32)] = .{ .llvm_name = "slow-vgetlni32", .description = "Has slow VGETLNi32 - prefer VMOV", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slowfpvfmx)] = .{ + result[@intFromEnum(Feature.slowfpvfmx)] = .{ .llvm_name = "slowfpvfmx", .description = "Disable VFP / NEON FMA instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slowfpvmlx)] = .{ + result[@intFromEnum(Feature.slowfpvmlx)] = .{ .llvm_name = "slowfpvmlx", .description = "Disable VFP / NEON MAC instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.soft_float)] = .{ + result[@intFromEnum(Feature.soft_float)] = .{ .llvm_name = "soft-float", .description = "Use software floating point features.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.splat_vfp_neon)] = .{ + result[@intFromEnum(Feature.splat_vfp_neon)] = .{ .llvm_name = "splat-vfp-neon", .description = "Splat register from VFP to NEON", .dependencies = featureSet(&[_]Feature{ .dont_widen_vmovs, }), }; - result[@enumToInt(Feature.strict_align)] = .{ + result[@intFromEnum(Feature.strict_align)] = .{ .llvm_name = "strict-align", .description = "Disallow all unaligned memory access", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.swift)] = .{ + result[@intFromEnum(Feature.swift)] = .{ .llvm_name = "swift", .description = "Swift ARM processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.thumb2)] = .{ + result[@intFromEnum(Feature.thumb2)] = .{ .llvm_name = "thumb2", .description = "Enable Thumb2 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.thumb_mode)] = .{ + result[@intFromEnum(Feature.thumb_mode)] = .{ .llvm_name = "thumb-mode", .description = "Thumb mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.trustzone)] = .{ + result[@intFromEnum(Feature.trustzone)] = .{ .llvm_name = "trustzone", .description = "Enable support for TrustZone security extensions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.use_mipipeliner)] = .{ + result[@intFromEnum(Feature.use_mipipeliner)] = .{ .llvm_name = "use-mipipeliner", .description = "Use the MachinePipeliner", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.use_misched)] = .{ + result[@intFromEnum(Feature.use_misched)] = .{ .llvm_name = "use-misched", .description = "Use the MachineScheduler", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v2)] = .{ + result[@intFromEnum(Feature.v2)] = .{ .llvm_name = null, .description = "ARMv2 architecture", .dependencies = featureSet(&[_]Feature{ .strict_align, }), }; - result[@enumToInt(Feature.v2a)] = .{ + result[@intFromEnum(Feature.v2a)] = .{ .llvm_name = null, .description = "ARMv2a architecture", .dependencies = featureSet(&[_]Feature{ .strict_align, }), }; - result[@enumToInt(Feature.v3)] = .{ + result[@intFromEnum(Feature.v3)] = .{ .llvm_name = null, .description = "ARMv3 architecture", .dependencies = featureSet(&[_]Feature{ .strict_align, }), }; - result[@enumToInt(Feature.v3m)] = .{ + result[@intFromEnum(Feature.v3m)] = .{ .llvm_name = null, .description = "ARMv3m architecture", .dependencies = featureSet(&[_]Feature{ .strict_align, }), }; - result[@enumToInt(Feature.v4)] = .{ + result[@intFromEnum(Feature.v4)] = .{ .llvm_name = "armv4", .description = "ARMv4 architecture", .dependencies = featureSet(&[_]Feature{ .strict_align, }), }; - result[@enumToInt(Feature.v4t)] = .{ + result[@intFromEnum(Feature.v4t)] = .{ .llvm_name = "armv4t", .description = "ARMv4t architecture", .dependencies = featureSet(&[_]Feature{ @@ -1101,7 +1101,7 @@ pub const all_features = blk: { .strict_align, }), }; - result[@enumToInt(Feature.v5t)] = .{ + result[@intFromEnum(Feature.v5t)] = .{ .llvm_name = "armv5t", .description = "ARMv5t architecture", .dependencies = featureSet(&[_]Feature{ @@ -1109,7 +1109,7 @@ pub const all_features = blk: { .strict_align, }), }; - result[@enumToInt(Feature.v5te)] = .{ + result[@intFromEnum(Feature.v5te)] = .{ .llvm_name = "armv5te", .description = "ARMv5te architecture", .dependencies = featureSet(&[_]Feature{ @@ -1117,7 +1117,7 @@ pub const all_features = blk: { .strict_align, }), }; - result[@enumToInt(Feature.v5tej)] = .{ + result[@intFromEnum(Feature.v5tej)] = .{ .llvm_name = "armv5tej", .description = "ARMv5tej architecture", .dependencies = featureSet(&[_]Feature{ @@ -1125,7 +1125,7 @@ pub const all_features = blk: { .strict_align, }), }; - result[@enumToInt(Feature.v6)] = .{ + result[@intFromEnum(Feature.v6)] = .{ .llvm_name = "armv6", .description = "ARMv6 architecture", .dependencies = featureSet(&[_]Feature{ @@ -1133,21 +1133,21 @@ pub const all_features = blk: { .has_v6, }), }; - result[@enumToInt(Feature.v6j)] = .{ + result[@intFromEnum(Feature.v6j)] = .{ .llvm_name = "armv6j", .description = "ARMv7a architecture", .dependencies = featureSet(&[_]Feature{ .v6, }), }; - result[@enumToInt(Feature.v6k)] = .{ + result[@intFromEnum(Feature.v6k)] = .{ .llvm_name = "armv6k", .description = "ARMv6k architecture", .dependencies = featureSet(&[_]Feature{ .has_v6k, }), }; - result[@enumToInt(Feature.v6kz)] = .{ + result[@intFromEnum(Feature.v6kz)] = .{ .llvm_name = "armv6kz", .description = "ARMv6kz architecture", .dependencies = featureSet(&[_]Feature{ @@ -1155,7 +1155,7 @@ pub const all_features = blk: { .trustzone, }), }; - result[@enumToInt(Feature.v6m)] = .{ + result[@intFromEnum(Feature.v6m)] = .{ .llvm_name = "armv6-m", .description = "ARMv6m architecture", .dependencies = featureSet(&[_]Feature{ @@ -1167,7 +1167,7 @@ pub const all_features = blk: { .thumb_mode, }), }; - result[@enumToInt(Feature.v6sm)] = .{ + result[@intFromEnum(Feature.v6sm)] = .{ .llvm_name = "armv6s-m", .description = "ARMv6sm architecture", .dependencies = featureSet(&[_]Feature{ @@ -1179,7 +1179,7 @@ pub const all_features = blk: { .thumb_mode, }), }; - result[@enumToInt(Feature.v6t2)] = .{ + result[@intFromEnum(Feature.v6t2)] = .{ .llvm_name = "armv6t2", .description = "ARMv6t2 architecture", .dependencies = featureSet(&[_]Feature{ @@ -1187,7 +1187,7 @@ pub const all_features = blk: { .has_v6t2, }), }; - result[@enumToInt(Feature.v7a)] = .{ + result[@intFromEnum(Feature.v7a)] = .{ .llvm_name = "armv7-a", .description = "ARMv7a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1199,7 +1199,7 @@ pub const all_features = blk: { .perfmon, }), }; - result[@enumToInt(Feature.v7em)] = .{ + result[@intFromEnum(Feature.v7em)] = .{ .llvm_name = "armv7e-m", .description = "ARMv7em architecture", .dependencies = featureSet(&[_]Feature{ @@ -1212,14 +1212,14 @@ pub const all_features = blk: { .thumb_mode, }), }; - result[@enumToInt(Feature.v7k)] = .{ + result[@intFromEnum(Feature.v7k)] = .{ .llvm_name = "armv7k", .description = "ARMv7a architecture", .dependencies = featureSet(&[_]Feature{ .v7a, }), }; - result[@enumToInt(Feature.v7m)] = .{ + result[@intFromEnum(Feature.v7m)] = .{ .llvm_name = "armv7-m", .description = "ARMv7m architecture", .dependencies = featureSet(&[_]Feature{ @@ -1231,7 +1231,7 @@ pub const all_features = blk: { .thumb_mode, }), }; - result[@enumToInt(Feature.v7r)] = .{ + result[@intFromEnum(Feature.v7r)] = .{ .llvm_name = "armv7-r", .description = "ARMv7r architecture", .dependencies = featureSet(&[_]Feature{ @@ -1243,14 +1243,14 @@ pub const all_features = blk: { .rclass, }), }; - result[@enumToInt(Feature.v7s)] = .{ + result[@intFromEnum(Feature.v7s)] = .{ .llvm_name = "armv7s", .description = "ARMv7a architecture", .dependencies = featureSet(&[_]Feature{ .v7a, }), }; - result[@enumToInt(Feature.v7ve)] = .{ + result[@intFromEnum(Feature.v7ve)] = .{ .llvm_name = "armv7ve", .description = "ARMv7ve architecture", .dependencies = featureSet(&[_]Feature{ @@ -1265,7 +1265,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v8_1a)] = .{ + result[@intFromEnum(Feature.v8_1a)] = .{ .llvm_name = "armv8.1-a", .description = "ARMv81a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1281,7 +1281,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v8_1m_main)] = .{ + result[@intFromEnum(Feature.v8_1m_main)] = .{ .llvm_name = "armv8.1-m.main", .description = "ARMv81mMainline architecture", .dependencies = featureSet(&[_]Feature{ @@ -1297,7 +1297,7 @@ pub const all_features = blk: { .thumb_mode, }), }; - result[@enumToInt(Feature.v8_2a)] = .{ + result[@intFromEnum(Feature.v8_2a)] = .{ .llvm_name = "armv8.2-a", .description = "ARMv82a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1314,7 +1314,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v8_3a)] = .{ + result[@intFromEnum(Feature.v8_3a)] = .{ .llvm_name = "armv8.3-a", .description = "ARMv83a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1331,7 +1331,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v8_4a)] = .{ + result[@intFromEnum(Feature.v8_4a)] = .{ .llvm_name = "armv8.4-a", .description = "ARMv84a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1348,7 +1348,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v8_5a)] = .{ + result[@intFromEnum(Feature.v8_5a)] = .{ .llvm_name = "armv8.5-a", .description = "ARMv85a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1365,7 +1365,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v8_6a)] = .{ + result[@intFromEnum(Feature.v8_6a)] = .{ .llvm_name = "armv8.6-a", .description = "ARMv86a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1382,7 +1382,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v8_7a)] = .{ + result[@intFromEnum(Feature.v8_7a)] = .{ .llvm_name = "armv8.7-a", .description = "ARMv87a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1399,7 +1399,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v8_8a)] = .{ + result[@intFromEnum(Feature.v8_8a)] = .{ .llvm_name = "armv8.8-a", .description = "ARMv88a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1416,7 +1416,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v8_9a)] = .{ + result[@intFromEnum(Feature.v8_9a)] = .{ .llvm_name = "armv8.9-a", .description = "ARMv89a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1433,7 +1433,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v8a)] = .{ + result[@intFromEnum(Feature.v8a)] = .{ .llvm_name = "armv8-a", .description = "ARMv8a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1449,7 +1449,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v8m)] = .{ + result[@intFromEnum(Feature.v8m)] = .{ .llvm_name = "armv8-m.base", .description = "ARMv8mBaseline architecture", .dependencies = featureSet(&[_]Feature{ @@ -1465,7 +1465,7 @@ pub const all_features = blk: { .thumb_mode, }), }; - result[@enumToInt(Feature.v8m_main)] = .{ + result[@intFromEnum(Feature.v8m_main)] = .{ .llvm_name = "armv8-m.main", .description = "ARMv8mMainline architecture", .dependencies = featureSet(&[_]Feature{ @@ -1479,7 +1479,7 @@ pub const all_features = blk: { .thumb_mode, }), }; - result[@enumToInt(Feature.v8r)] = .{ + result[@intFromEnum(Feature.v8r)] = .{ .llvm_name = "armv8-r", .description = "ARMv8r architecture", .dependencies = featureSet(&[_]Feature{ @@ -1495,7 +1495,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v9_1a)] = .{ + result[@intFromEnum(Feature.v9_1a)] = .{ .llvm_name = "armv9.1-a", .description = "ARMv91a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1511,7 +1511,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v9_2a)] = .{ + result[@intFromEnum(Feature.v9_2a)] = .{ .llvm_name = "armv9.2-a", .description = "ARMv92a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1527,7 +1527,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v9_3a)] = .{ + result[@intFromEnum(Feature.v9_3a)] = .{ .llvm_name = "armv9.3-a", .description = "ARMv93a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1544,7 +1544,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v9_4a)] = .{ + result[@intFromEnum(Feature.v9_4a)] = .{ .llvm_name = "armv9.4-a", .description = "ARMv94a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1560,7 +1560,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.v9a)] = .{ + result[@intFromEnum(Feature.v9a)] = .{ .llvm_name = "armv9-a", .description = "ARMv9a architecture", .dependencies = featureSet(&[_]Feature{ @@ -1576,7 +1576,7 @@ pub const all_features = blk: { .virtualization, }), }; - result[@enumToInt(Feature.vfp2)] = .{ + result[@intFromEnum(Feature.vfp2)] = .{ .llvm_name = "vfp2", .description = "Enable VFP2 instructions", .dependencies = featureSet(&[_]Feature{ @@ -1584,14 +1584,14 @@ pub const all_features = blk: { .vfp2sp, }), }; - result[@enumToInt(Feature.vfp2sp)] = .{ + result[@intFromEnum(Feature.vfp2sp)] = .{ .llvm_name = "vfp2sp", .description = "Enable VFP2 instructions with no double precision", .dependencies = featureSet(&[_]Feature{ .fpregs, }), }; - result[@enumToInt(Feature.vfp3)] = .{ + result[@intFromEnum(Feature.vfp3)] = .{ .llvm_name = "vfp3", .description = "Enable VFP3 instructions", .dependencies = featureSet(&[_]Feature{ @@ -1599,7 +1599,7 @@ pub const all_features = blk: { .vfp3sp, }), }; - result[@enumToInt(Feature.vfp3d16)] = .{ + result[@intFromEnum(Feature.vfp3d16)] = .{ .llvm_name = "vfp3d16", .description = "Enable VFP3 instructions with only 16 d-registers", .dependencies = featureSet(&[_]Feature{ @@ -1607,14 +1607,14 @@ pub const all_features = blk: { .vfp3d16sp, }), }; - result[@enumToInt(Feature.vfp3d16sp)] = .{ + result[@intFromEnum(Feature.vfp3d16sp)] = .{ .llvm_name = "vfp3d16sp", .description = "Enable VFP3 instructions with only 16 d-registers and no double precision", .dependencies = featureSet(&[_]Feature{ .vfp2sp, }), }; - result[@enumToInt(Feature.vfp3sp)] = .{ + result[@intFromEnum(Feature.vfp3sp)] = .{ .llvm_name = "vfp3sp", .description = "Enable VFP3 instructions with no double precision", .dependencies = featureSet(&[_]Feature{ @@ -1622,7 +1622,7 @@ pub const all_features = blk: { .vfp3d16sp, }), }; - result[@enumToInt(Feature.vfp4)] = .{ + result[@intFromEnum(Feature.vfp4)] = .{ .llvm_name = "vfp4", .description = "Enable VFP4 instructions", .dependencies = featureSet(&[_]Feature{ @@ -1631,7 +1631,7 @@ pub const all_features = blk: { .vfp4sp, }), }; - result[@enumToInt(Feature.vfp4d16)] = .{ + result[@intFromEnum(Feature.vfp4d16)] = .{ .llvm_name = "vfp4d16", .description = "Enable VFP4 instructions with only 16 d-registers", .dependencies = featureSet(&[_]Feature{ @@ -1639,7 +1639,7 @@ pub const all_features = blk: { .vfp4d16sp, }), }; - result[@enumToInt(Feature.vfp4d16sp)] = .{ + result[@intFromEnum(Feature.vfp4d16sp)] = .{ .llvm_name = "vfp4d16sp", .description = "Enable VFP4 instructions with only 16 d-registers and no double precision", .dependencies = featureSet(&[_]Feature{ @@ -1647,7 +1647,7 @@ pub const all_features = blk: { .vfp3d16sp, }), }; - result[@enumToInt(Feature.vfp4sp)] = .{ + result[@intFromEnum(Feature.vfp4sp)] = .{ .llvm_name = "vfp4sp", .description = "Enable VFP4 instructions with no double precision", .dependencies = featureSet(&[_]Feature{ @@ -1655,7 +1655,7 @@ pub const all_features = blk: { .vfp4d16sp, }), }; - result[@enumToInt(Feature.virtualization)] = .{ + result[@intFromEnum(Feature.virtualization)] = .{ .llvm_name = "virtualization", .description = "Supports Virtualization extension", .dependencies = featureSet(&[_]Feature{ @@ -1663,34 +1663,34 @@ pub const all_features = blk: { .hwdiv_arm, }), }; - result[@enumToInt(Feature.vldn_align)] = .{ + result[@intFromEnum(Feature.vldn_align)] = .{ .llvm_name = "vldn-align", .description = "Check for VLDn unaligned access", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vmlx_forwarding)] = .{ + result[@intFromEnum(Feature.vmlx_forwarding)] = .{ .llvm_name = "vmlx-forwarding", .description = "Has multiplier accumulator forwarding", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vmlx_hazards)] = .{ + result[@intFromEnum(Feature.vmlx_hazards)] = .{ .llvm_name = "vmlx-hazards", .description = "Has VMLx hazards", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.wide_stride_vfp)] = .{ + result[@intFromEnum(Feature.wide_stride_vfp)] = .{ .llvm_name = "wide-stride-vfp", .description = "Use a wide stride when allocating VFP registers", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.xscale)] = .{ + result[@intFromEnum(Feature.xscale)] = .{ .llvm_name = "xscale", .description = "ARMv5te architecture", .dependencies = featureSet(&[_]Feature{ .v5te, }), }; - result[@enumToInt(Feature.zcz)] = .{ + result[@intFromEnum(Feature.zcz)] = .{ .llvm_name = "zcz", .description = "Has zero-cycle zeroing instructions", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/avr.zig b/lib/std/target/avr.zig index e670682ff929..a39475cb2a20 100644 --- a/lib/std/target/avr.zig +++ b/lib/std/target/avr.zig @@ -52,17 +52,17 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.addsubiw)] = .{ + result[@intFromEnum(Feature.addsubiw)] = .{ .llvm_name = "addsubiw", .description = "Enable 16-bit register-immediate addition and subtraction instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.avr0)] = .{ + result[@intFromEnum(Feature.avr0)] = .{ .llvm_name = "avr0", .description = "The device is a part of the avr0 family", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.avr1)] = .{ + result[@intFromEnum(Feature.avr1)] = .{ .llvm_name = "avr1", .description = "The device is a part of the avr1 family", .dependencies = featureSet(&[_]Feature{ @@ -72,7 +72,7 @@ pub const all_features = blk: { .progmem, }), }; - result[@enumToInt(Feature.avr2)] = .{ + result[@intFromEnum(Feature.avr2)] = .{ .llvm_name = "avr2", .description = "The device is a part of the avr2 family", .dependencies = featureSet(&[_]Feature{ @@ -82,7 +82,7 @@ pub const all_features = blk: { .sram, }), }; - result[@enumToInt(Feature.avr25)] = .{ + result[@intFromEnum(Feature.avr25)] = .{ .llvm_name = "avr25", .description = "The device is a part of the avr25 family", .dependencies = featureSet(&[_]Feature{ @@ -93,7 +93,7 @@ pub const all_features = blk: { .spm, }), }; - result[@enumToInt(Feature.avr3)] = .{ + result[@intFromEnum(Feature.avr3)] = .{ .llvm_name = "avr3", .description = "The device is a part of the avr3 family", .dependencies = featureSet(&[_]Feature{ @@ -101,7 +101,7 @@ pub const all_features = blk: { .jmpcall, }), }; - result[@enumToInt(Feature.avr31)] = .{ + result[@intFromEnum(Feature.avr31)] = .{ .llvm_name = "avr31", .description = "The device is a part of the avr31 family", .dependencies = featureSet(&[_]Feature{ @@ -109,7 +109,7 @@ pub const all_features = blk: { .elpm, }), }; - result[@enumToInt(Feature.avr35)] = .{ + result[@intFromEnum(Feature.avr35)] = .{ .llvm_name = "avr35", .description = "The device is a part of the avr35 family", .dependencies = featureSet(&[_]Feature{ @@ -120,7 +120,7 @@ pub const all_features = blk: { .spm, }), }; - result[@enumToInt(Feature.avr4)] = .{ + result[@intFromEnum(Feature.avr4)] = .{ .llvm_name = "avr4", .description = "The device is a part of the avr4 family", .dependencies = featureSet(&[_]Feature{ @@ -132,7 +132,7 @@ pub const all_features = blk: { .spm, }), }; - result[@enumToInt(Feature.avr5)] = .{ + result[@intFromEnum(Feature.avr5)] = .{ .llvm_name = "avr5", .description = "The device is a part of the avr5 family", .dependencies = featureSet(&[_]Feature{ @@ -144,7 +144,7 @@ pub const all_features = blk: { .spm, }), }; - result[@enumToInt(Feature.avr51)] = .{ + result[@intFromEnum(Feature.avr51)] = .{ .llvm_name = "avr51", .description = "The device is a part of the avr51 family", .dependencies = featureSet(&[_]Feature{ @@ -153,7 +153,7 @@ pub const all_features = blk: { .elpmx, }), }; - result[@enumToInt(Feature.avr6)] = .{ + result[@intFromEnum(Feature.avr6)] = .{ .llvm_name = "avr6", .description = "The device is a part of the avr6 family", .dependencies = featureSet(&[_]Feature{ @@ -161,7 +161,7 @@ pub const all_features = blk: { .eijmpcall, }), }; - result[@enumToInt(Feature.avrtiny)] = .{ + result[@intFromEnum(Feature.avrtiny)] = .{ .llvm_name = "avrtiny", .description = "The device is a part of the avrtiny family", .dependencies = featureSet(&[_]Feature{ @@ -172,82 +172,82 @@ pub const all_features = blk: { .tinyencoding, }), }; - result[@enumToInt(Feature.@"break")] = .{ + result[@intFromEnum(Feature.@"break")] = .{ .llvm_name = "break", .description = "The device supports the `BREAK` debugging instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.des)] = .{ + result[@intFromEnum(Feature.des)] = .{ .llvm_name = "des", .description = "The device supports the `DES k` encryption instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.eijmpcall)] = .{ + result[@intFromEnum(Feature.eijmpcall)] = .{ .llvm_name = "eijmpcall", .description = "The device supports the `EIJMP`/`EICALL` instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.elpm)] = .{ + result[@intFromEnum(Feature.elpm)] = .{ .llvm_name = "elpm", .description = "The device supports the ELPM instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.elpmx)] = .{ + result[@intFromEnum(Feature.elpmx)] = .{ .llvm_name = "elpmx", .description = "The device supports the `ELPM Rd, Z[+]` instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ijmpcall)] = .{ + result[@intFromEnum(Feature.ijmpcall)] = .{ .llvm_name = "ijmpcall", .description = "The device supports `IJMP`/`ICALL`instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.jmpcall)] = .{ + result[@intFromEnum(Feature.jmpcall)] = .{ .llvm_name = "jmpcall", .description = "The device supports the `JMP` and `CALL` instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lpm)] = .{ + result[@intFromEnum(Feature.lpm)] = .{ .llvm_name = "lpm", .description = "The device supports the `LPM` instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lpmx)] = .{ + result[@intFromEnum(Feature.lpmx)] = .{ .llvm_name = "lpmx", .description = "The device supports the `LPM Rd, Z[+]` instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.memmappedregs)] = .{ + result[@intFromEnum(Feature.memmappedregs)] = .{ .llvm_name = "memmappedregs", .description = "The device has CPU registers mapped in data address space", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.movw)] = .{ + result[@intFromEnum(Feature.movw)] = .{ .llvm_name = "movw", .description = "The device supports the 16-bit MOVW instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mul)] = .{ + result[@intFromEnum(Feature.mul)] = .{ .llvm_name = "mul", .description = "The device supports the multiplication instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.progmem)] = .{ + result[@intFromEnum(Feature.progmem)] = .{ .llvm_name = "progmem", .description = "The device has a separate flash namespace", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.rmw)] = .{ + result[@intFromEnum(Feature.rmw)] = .{ .llvm_name = "rmw", .description = "The device supports the read-write-modify instructions: XCH, LAS, LAC, LAT", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.smallstack)] = .{ + result[@intFromEnum(Feature.smallstack)] = .{ .llvm_name = "smallstack", .description = "The device has an 8-bit stack pointer", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.special)] = .{ + result[@intFromEnum(Feature.special)] = .{ .llvm_name = "special", .description = "Enable use of the entire instruction set - used for debugging", .dependencies = featureSet(&[_]Feature{ @@ -270,27 +270,27 @@ pub const all_features = blk: { .sram, }), }; - result[@enumToInt(Feature.spm)] = .{ + result[@intFromEnum(Feature.spm)] = .{ .llvm_name = "spm", .description = "The device supports the `SPM` instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.spmx)] = .{ + result[@intFromEnum(Feature.spmx)] = .{ .llvm_name = "spmx", .description = "The device supports the `SPM Z+` instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sram)] = .{ + result[@intFromEnum(Feature.sram)] = .{ .llvm_name = "sram", .description = "The device has random access memory", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tinyencoding)] = .{ + result[@intFromEnum(Feature.tinyencoding)] = .{ .llvm_name = "tinyencoding", .description = "The device has Tiny core specific instruction encodings", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.xmega)] = .{ + result[@intFromEnum(Feature.xmega)] = .{ .llvm_name = "xmega", .description = "The device is a part of the xmega family", .dependencies = featureSet(&[_]Feature{ @@ -313,7 +313,7 @@ pub const all_features = blk: { .sram, }), }; - result[@enumToInt(Feature.xmega3)] = .{ + result[@intFromEnum(Feature.xmega3)] = .{ .llvm_name = "xmega3", .description = "The device is a part of the xmega3 family", .dependencies = featureSet(&[_]Feature{ @@ -330,7 +330,7 @@ pub const all_features = blk: { .sram, }), }; - result[@enumToInt(Feature.xmegau)] = .{ + result[@intFromEnum(Feature.xmegau)] = .{ .llvm_name = "xmegau", .description = "The device is a part of the xmegau family", .dependencies = featureSet(&[_]Feature{ diff --git a/lib/std/target/bpf.zig b/lib/std/target/bpf.zig index 82503c11a4a1..35f4aac57fe8 100644 --- a/lib/std/target/bpf.zig +++ b/lib/std/target/bpf.zig @@ -19,17 +19,17 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.alu32)] = .{ + result[@intFromEnum(Feature.alu32)] = .{ .llvm_name = "alu32", .description = "Enable ALU32 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dummy)] = .{ + result[@intFromEnum(Feature.dummy)] = .{ .llvm_name = "dummy", .description = "unused feature", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dwarfris)] = .{ + result[@intFromEnum(Feature.dwarfris)] = .{ .llvm_name = "dwarfris", .description = "Disable MCAsmInfo DwarfUsesRelocationsAcrossSections", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/csky.zig b/lib/std/target/csky.zig index 0a2812c6d993..ef153a2708e5 100644 --- a/lib/std/target/csky.zig +++ b/lib/std/target/csky.zig @@ -79,26 +79,26 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.@"10e60")] = .{ + result[@intFromEnum(Feature.@"10e60")] = .{ .llvm_name = "10e60", .description = "Support CSKY 10e60 instructions", .dependencies = featureSet(&[_]Feature{ .@"7e10", }), }; - result[@enumToInt(Feature.@"2e3")] = .{ + result[@intFromEnum(Feature.@"2e3")] = .{ .llvm_name = "2e3", .description = "Support CSKY 2e3 instructions", .dependencies = featureSet(&[_]Feature{ .e2, }), }; - result[@enumToInt(Feature.@"3e3r1")] = .{ + result[@intFromEnum(Feature.@"3e3r1")] = .{ .llvm_name = "3e3r1", .description = "Support CSKY 3e3r1 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.@"3e3r2")] = .{ + result[@intFromEnum(Feature.@"3e3r2")] = .{ .llvm_name = "3e3r2", .description = "Support CSKY 3e3r2 instructions", .dependencies = featureSet(&[_]Feature{ @@ -106,311 +106,311 @@ pub const all_features = blk: { .doloop, }), }; - result[@enumToInt(Feature.@"3e3r3")] = .{ + result[@intFromEnum(Feature.@"3e3r3")] = .{ .llvm_name = "3e3r3", .description = "Support CSKY 3e3r3 instructions", .dependencies = featureSet(&[_]Feature{ .doloop, }), }; - result[@enumToInt(Feature.@"3e7")] = .{ + result[@intFromEnum(Feature.@"3e7")] = .{ .llvm_name = "3e7", .description = "Support CSKY 3e7 instructions", .dependencies = featureSet(&[_]Feature{ .@"2e3", }), }; - result[@enumToInt(Feature.@"7e10")] = .{ + result[@intFromEnum(Feature.@"7e10")] = .{ .llvm_name = "7e10", .description = "Support CSKY 7e10 instructions", .dependencies = featureSet(&[_]Feature{ .@"3e7", }), }; - result[@enumToInt(Feature.btst16)] = .{ + result[@intFromEnum(Feature.btst16)] = .{ .llvm_name = "btst16", .description = "Use the 16-bit btsti instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.cache)] = .{ + result[@intFromEnum(Feature.cache)] = .{ .llvm_name = "cache", .description = "Enable cache", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ccrt)] = .{ + result[@intFromEnum(Feature.ccrt)] = .{ .llvm_name = "ccrt", .description = "Use CSKY compiler runtime", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ck801)] = .{ + result[@intFromEnum(Feature.ck801)] = .{ .llvm_name = "ck801", .description = "CSKY ck801 processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ck802)] = .{ + result[@intFromEnum(Feature.ck802)] = .{ .llvm_name = "ck802", .description = "CSKY ck802 processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ck803)] = .{ + result[@intFromEnum(Feature.ck803)] = .{ .llvm_name = "ck803", .description = "CSKY ck803 processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ck803s)] = .{ + result[@intFromEnum(Feature.ck803s)] = .{ .llvm_name = "ck803s", .description = "CSKY ck803s processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ck804)] = .{ + result[@intFromEnum(Feature.ck804)] = .{ .llvm_name = "ck804", .description = "CSKY ck804 processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ck805)] = .{ + result[@intFromEnum(Feature.ck805)] = .{ .llvm_name = "ck805", .description = "CSKY ck805 processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ck807)] = .{ + result[@intFromEnum(Feature.ck807)] = .{ .llvm_name = "ck807", .description = "CSKY ck807 processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ck810)] = .{ + result[@intFromEnum(Feature.ck810)] = .{ .llvm_name = "ck810", .description = "CSKY ck810 processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ck810v)] = .{ + result[@intFromEnum(Feature.ck810v)] = .{ .llvm_name = "ck810v", .description = "CSKY ck810v processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ck860)] = .{ + result[@intFromEnum(Feature.ck860)] = .{ .llvm_name = "ck860", .description = "CSKY ck860 processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ck860v)] = .{ + result[@intFromEnum(Feature.ck860v)] = .{ .llvm_name = "ck860v", .description = "CSKY ck860v processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.constpool)] = .{ + result[@intFromEnum(Feature.constpool)] = .{ .llvm_name = "constpool", .description = "Dump the constant pool by compiler", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.doloop)] = .{ + result[@intFromEnum(Feature.doloop)] = .{ .llvm_name = "doloop", .description = "Enable doloop instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dsp1e2)] = .{ + result[@intFromEnum(Feature.dsp1e2)] = .{ .llvm_name = "dsp1e2", .description = "Support CSKY dsp1e2 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dsp_silan)] = .{ + result[@intFromEnum(Feature.dsp_silan)] = .{ .llvm_name = "dsp_silan", .description = "Enable DSP Silan instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dspe60)] = .{ + result[@intFromEnum(Feature.dspe60)] = .{ .llvm_name = "dspe60", .description = "Support CSKY dspe60 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dspv2)] = .{ + result[@intFromEnum(Feature.dspv2)] = .{ .llvm_name = "dspv2", .description = "Enable DSP V2.0 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.e1)] = .{ + result[@intFromEnum(Feature.e1)] = .{ .llvm_name = "e1", .description = "Support CSKY e1 instructions", .dependencies = featureSet(&[_]Feature{ .elrw, }), }; - result[@enumToInt(Feature.e2)] = .{ + result[@intFromEnum(Feature.e2)] = .{ .llvm_name = "e2", .description = "Support CSKY e2 instructions", .dependencies = featureSet(&[_]Feature{ .e1, }), }; - result[@enumToInt(Feature.edsp)] = .{ + result[@intFromEnum(Feature.edsp)] = .{ .llvm_name = "edsp", .description = "Enable DSP instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.elrw)] = .{ + result[@intFromEnum(Feature.elrw)] = .{ .llvm_name = "elrw", .description = "Use the extend LRW instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fdivdu)] = .{ + result[@intFromEnum(Feature.fdivdu)] = .{ .llvm_name = "fdivdu", .description = "Enable float divide instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.float1e2)] = .{ + result[@intFromEnum(Feature.float1e2)] = .{ .llvm_name = "float1e2", .description = "Support CSKY float1e2 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.float1e3)] = .{ + result[@intFromEnum(Feature.float1e3)] = .{ .llvm_name = "float1e3", .description = "Support CSKY float1e3 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.float3e4)] = .{ + result[@intFromEnum(Feature.float3e4)] = .{ .llvm_name = "float3e4", .description = "Support CSKY float3e4 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.float7e60)] = .{ + result[@intFromEnum(Feature.float7e60)] = .{ .llvm_name = "float7e60", .description = "Support CSKY float7e60 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.floate1)] = .{ + result[@intFromEnum(Feature.floate1)] = .{ .llvm_name = "floate1", .description = "Support CSKY floate1 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fpuv2_df)] = .{ + result[@intFromEnum(Feature.fpuv2_df)] = .{ .llvm_name = "fpuv2_df", .description = "Enable FPUv2 double float instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fpuv2_sf)] = .{ + result[@intFromEnum(Feature.fpuv2_sf)] = .{ .llvm_name = "fpuv2_sf", .description = "Enable FPUv2 single float instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fpuv3_df)] = .{ + result[@intFromEnum(Feature.fpuv3_df)] = .{ .llvm_name = "fpuv3_df", .description = "Enable FPUv3 double float instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fpuv3_hf)] = .{ + result[@intFromEnum(Feature.fpuv3_hf)] = .{ .llvm_name = "fpuv3_hf", .description = "Enable FPUv3 harf precision operate instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fpuv3_hi)] = .{ + result[@intFromEnum(Feature.fpuv3_hi)] = .{ .llvm_name = "fpuv3_hi", .description = "Enable FPUv3 harf word converting instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fpuv3_sf)] = .{ + result[@intFromEnum(Feature.fpuv3_sf)] = .{ .llvm_name = "fpuv3_sf", .description = "Enable FPUv3 single float instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hard_float)] = .{ + result[@intFromEnum(Feature.hard_float)] = .{ .llvm_name = "hard-float", .description = "Use hard floating point features", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hard_float_abi)] = .{ + result[@intFromEnum(Feature.hard_float_abi)] = .{ .llvm_name = "hard-float-abi", .description = "Use hard floating point ABI to pass args", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hard_tp)] = .{ + result[@intFromEnum(Feature.hard_tp)] = .{ .llvm_name = "hard-tp", .description = "Enable TLS Pointer register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.high_registers)] = .{ + result[@intFromEnum(Feature.high_registers)] = .{ .llvm_name = "high-registers", .description = "Enable r16-r31 registers", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hwdiv)] = .{ + result[@intFromEnum(Feature.hwdiv)] = .{ .llvm_name = "hwdiv", .description = "Enable divide instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.istack)] = .{ + result[@intFromEnum(Feature.istack)] = .{ .llvm_name = "istack", .description = "Enable interrupt attribute", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.java)] = .{ + result[@intFromEnum(Feature.java)] = .{ .llvm_name = "java", .description = "Enable java instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mp)] = .{ + result[@intFromEnum(Feature.mp)] = .{ .llvm_name = "mp", .description = "Support CSKY mp instructions", .dependencies = featureSet(&[_]Feature{ .@"2e3", }), }; - result[@enumToInt(Feature.mp1e2)] = .{ + result[@intFromEnum(Feature.mp1e2)] = .{ .llvm_name = "mp1e2", .description = "Support CSKY mp1e2 instructions", .dependencies = featureSet(&[_]Feature{ .@"3e7", }), }; - result[@enumToInt(Feature.multiple_stld)] = .{ + result[@intFromEnum(Feature.multiple_stld)] = .{ .llvm_name = "multiple_stld", .description = "Enable multiple load/store instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nvic)] = .{ + result[@intFromEnum(Feature.nvic)] = .{ .llvm_name = "nvic", .description = "Enable NVIC", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.pushpop)] = .{ + result[@intFromEnum(Feature.pushpop)] = .{ .llvm_name = "pushpop", .description = "Enable push/pop instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.smart)] = .{ + result[@intFromEnum(Feature.smart)] = .{ .llvm_name = "smart", .description = "Let CPU work in Smart Mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.soft_tp)] = .{ + result[@intFromEnum(Feature.soft_tp)] = .{ .llvm_name = "soft-tp", .description = "Disable TLS Pointer register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.stack_size)] = .{ + result[@intFromEnum(Feature.stack_size)] = .{ .llvm_name = "stack-size", .description = "Output stack size information", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.trust)] = .{ + result[@intFromEnum(Feature.trust)] = .{ .llvm_name = "trust", .description = "Enable trust instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vdsp2e3)] = .{ + result[@intFromEnum(Feature.vdsp2e3)] = .{ .llvm_name = "vdsp2e3", .description = "Support CSKY vdsp2e3 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vdsp2e60f)] = .{ + result[@intFromEnum(Feature.vdsp2e60f)] = .{ .llvm_name = "vdsp2e60f", .description = "Support CSKY vdsp2e60f instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vdspv1)] = .{ + result[@intFromEnum(Feature.vdspv1)] = .{ .llvm_name = "vdspv1", .description = "Enable 128bit vdsp-v1 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vdspv2)] = .{ + result[@intFromEnum(Feature.vdspv2)] = .{ .llvm_name = "vdspv2", .description = "Enable vdsp-v2 instructions", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/hexagon.zig b/lib/std/target/hexagon.zig index fb075513bb36..c84b2cb0c8b9 100644 --- a/lib/std/target/hexagon.zig +++ b/lib/std/target/hexagon.zig @@ -58,77 +58,77 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.audio)] = .{ + result[@intFromEnum(Feature.audio)] = .{ .llvm_name = "audio", .description = "Hexagon Audio extension instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.cabac)] = .{ + result[@intFromEnum(Feature.cabac)] = .{ .llvm_name = "cabac", .description = "Emit the CABAC instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.compound)] = .{ + result[@intFromEnum(Feature.compound)] = .{ .llvm_name = "compound", .description = "Use compound instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.duplex)] = .{ + result[@intFromEnum(Feature.duplex)] = .{ .llvm_name = "duplex", .description = "Enable generation of duplex instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hvx)] = .{ + result[@intFromEnum(Feature.hvx)] = .{ .llvm_name = "hvx", .description = "Hexagon HVX instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hvx_ieee_fp)] = .{ + result[@intFromEnum(Feature.hvx_ieee_fp)] = .{ .llvm_name = "hvx-ieee-fp", .description = "Hexagon HVX IEEE floating point instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hvx_length128b)] = .{ + result[@intFromEnum(Feature.hvx_length128b)] = .{ .llvm_name = "hvx-length128b", .description = "Hexagon HVX 128B instructions", .dependencies = featureSet(&[_]Feature{ .hvx, }), }; - result[@enumToInt(Feature.hvx_length64b)] = .{ + result[@intFromEnum(Feature.hvx_length64b)] = .{ .llvm_name = "hvx-length64b", .description = "Hexagon HVX 64B instructions", .dependencies = featureSet(&[_]Feature{ .hvx, }), }; - result[@enumToInt(Feature.hvx_qfloat)] = .{ + result[@intFromEnum(Feature.hvx_qfloat)] = .{ .llvm_name = "hvx-qfloat", .description = "Hexagon HVX QFloating point instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hvxv60)] = .{ + result[@intFromEnum(Feature.hvxv60)] = .{ .llvm_name = "hvxv60", .description = "Hexagon HVX instructions", .dependencies = featureSet(&[_]Feature{ .hvx, }), }; - result[@enumToInt(Feature.hvxv62)] = .{ + result[@intFromEnum(Feature.hvxv62)] = .{ .llvm_name = "hvxv62", .description = "Hexagon HVX instructions", .dependencies = featureSet(&[_]Feature{ .hvxv60, }), }; - result[@enumToInt(Feature.hvxv65)] = .{ + result[@intFromEnum(Feature.hvxv65)] = .{ .llvm_name = "hvxv65", .description = "Hexagon HVX instructions", .dependencies = featureSet(&[_]Feature{ .hvxv62, }), }; - result[@enumToInt(Feature.hvxv66)] = .{ + result[@intFromEnum(Feature.hvxv66)] = .{ .llvm_name = "hvxv66", .description = "Hexagon HVX instructions", .dependencies = featureSet(&[_]Feature{ @@ -136,161 +136,161 @@ pub const all_features = blk: { .zreg, }), }; - result[@enumToInt(Feature.hvxv67)] = .{ + result[@intFromEnum(Feature.hvxv67)] = .{ .llvm_name = "hvxv67", .description = "Hexagon HVX instructions", .dependencies = featureSet(&[_]Feature{ .hvxv66, }), }; - result[@enumToInt(Feature.hvxv68)] = .{ + result[@intFromEnum(Feature.hvxv68)] = .{ .llvm_name = "hvxv68", .description = "Hexagon HVX instructions", .dependencies = featureSet(&[_]Feature{ .hvxv67, }), }; - result[@enumToInt(Feature.hvxv69)] = .{ + result[@intFromEnum(Feature.hvxv69)] = .{ .llvm_name = "hvxv69", .description = "Hexagon HVX instructions", .dependencies = featureSet(&[_]Feature{ .hvxv68, }), }; - result[@enumToInt(Feature.hvxv71)] = .{ + result[@intFromEnum(Feature.hvxv71)] = .{ .llvm_name = "hvxv71", .description = "Hexagon HVX instructions", .dependencies = featureSet(&[_]Feature{ .hvxv69, }), }; - result[@enumToInt(Feature.hvxv73)] = .{ + result[@intFromEnum(Feature.hvxv73)] = .{ .llvm_name = "hvxv73", .description = "Hexagon HVX instructions", .dependencies = featureSet(&[_]Feature{ .hvxv71, }), }; - result[@enumToInt(Feature.long_calls)] = .{ + result[@intFromEnum(Feature.long_calls)] = .{ .llvm_name = "long-calls", .description = "Use constant-extended calls", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mem_noshuf)] = .{ + result[@intFromEnum(Feature.mem_noshuf)] = .{ .llvm_name = "mem_noshuf", .description = "Supports mem_noshuf feature", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.memops)] = .{ + result[@intFromEnum(Feature.memops)] = .{ .llvm_name = "memops", .description = "Use memop instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.noreturn_stack_elim)] = .{ + result[@intFromEnum(Feature.noreturn_stack_elim)] = .{ .llvm_name = "noreturn-stack-elim", .description = "Eliminate stack allocation in a noreturn function when possible", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nvj)] = .{ + result[@intFromEnum(Feature.nvj)] = .{ .llvm_name = "nvj", .description = "Support for new-value jumps", .dependencies = featureSet(&[_]Feature{ .packets, }), }; - result[@enumToInt(Feature.nvs)] = .{ + result[@intFromEnum(Feature.nvs)] = .{ .llvm_name = "nvs", .description = "Support for new-value stores", .dependencies = featureSet(&[_]Feature{ .packets, }), }; - result[@enumToInt(Feature.packets)] = .{ + result[@intFromEnum(Feature.packets)] = .{ .llvm_name = "packets", .description = "Support for instruction packets", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prev65)] = .{ + result[@intFromEnum(Feature.prev65)] = .{ .llvm_name = "prev65", .description = "Support features deprecated in v65", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserved_r19)] = .{ + result[@intFromEnum(Feature.reserved_r19)] = .{ .llvm_name = "reserved-r19", .description = "Reserve register R19", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.small_data)] = .{ + result[@intFromEnum(Feature.small_data)] = .{ .llvm_name = "small-data", .description = "Allow GP-relative addressing of global variables", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tinycore)] = .{ + result[@intFromEnum(Feature.tinycore)] = .{ .llvm_name = "tinycore", .description = "Hexagon Tiny Core", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.unsafe_fp)] = .{ + result[@intFromEnum(Feature.unsafe_fp)] = .{ .llvm_name = "unsafe-fp", .description = "Use unsafe FP math", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v5)] = .{ + result[@intFromEnum(Feature.v5)] = .{ .llvm_name = "v5", .description = "Enable Hexagon V5 architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v55)] = .{ + result[@intFromEnum(Feature.v55)] = .{ .llvm_name = "v55", .description = "Enable Hexagon V55 architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v60)] = .{ + result[@intFromEnum(Feature.v60)] = .{ .llvm_name = "v60", .description = "Enable Hexagon V60 architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v62)] = .{ + result[@intFromEnum(Feature.v62)] = .{ .llvm_name = "v62", .description = "Enable Hexagon V62 architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v65)] = .{ + result[@intFromEnum(Feature.v65)] = .{ .llvm_name = "v65", .description = "Enable Hexagon V65 architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v66)] = .{ + result[@intFromEnum(Feature.v66)] = .{ .llvm_name = "v66", .description = "Enable Hexagon V66 architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v67)] = .{ + result[@intFromEnum(Feature.v67)] = .{ .llvm_name = "v67", .description = "Enable Hexagon V67 architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v68)] = .{ + result[@intFromEnum(Feature.v68)] = .{ .llvm_name = "v68", .description = "Enable Hexagon V68 architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v69)] = .{ + result[@intFromEnum(Feature.v69)] = .{ .llvm_name = "v69", .description = "Enable Hexagon V69 architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v71)] = .{ + result[@intFromEnum(Feature.v71)] = .{ .llvm_name = "v71", .description = "Enable Hexagon V71 architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v73)] = .{ + result[@intFromEnum(Feature.v73)] = .{ .llvm_name = "v73", .description = "Enable Hexagon V73 architecture", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zreg)] = .{ + result[@intFromEnum(Feature.zreg)] = .{ .llvm_name = "zreg", .description = "Hexagon ZReg extension instructions", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/loongarch.zig b/lib/std/target/loongarch.zig index dcc6bd43fc28..6f0bf426bb05 100644 --- a/lib/std/target/loongarch.zig +++ b/lib/std/target/loongarch.zig @@ -27,63 +27,63 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.@"32bit")] = .{ + result[@intFromEnum(Feature.@"32bit")] = .{ .llvm_name = "32bit", .description = "LA32 Basic Integer and Privilege Instruction Set", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.@"64bit")] = .{ + result[@intFromEnum(Feature.@"64bit")] = .{ .llvm_name = "64bit", .description = "LA64 Basic Integer and Privilege Instruction Set", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.d)] = .{ + result[@intFromEnum(Feature.d)] = .{ .llvm_name = "d", .description = "'D' (Double-Precision Floating-Point)", .dependencies = featureSet(&[_]Feature{ .f, }), }; - result[@enumToInt(Feature.f)] = .{ + result[@intFromEnum(Feature.f)] = .{ .llvm_name = "f", .description = "'F' (Single-Precision Floating-Point)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.la_global_with_abs)] = .{ + result[@intFromEnum(Feature.la_global_with_abs)] = .{ .llvm_name = "la-global-with-abs", .description = "Expand la.global as la.abs", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.la_global_with_pcrel)] = .{ + result[@intFromEnum(Feature.la_global_with_pcrel)] = .{ .llvm_name = "la-global-with-pcrel", .description = "Expand la.global as la.pcrel", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.la_local_with_abs)] = .{ + result[@intFromEnum(Feature.la_local_with_abs)] = .{ .llvm_name = "la-local-with-abs", .description = "Expand la.local as la.abs", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lasx)] = .{ + result[@intFromEnum(Feature.lasx)] = .{ .llvm_name = "lasx", .description = "'LASX' (Loongson Advanced SIMD Extension)", .dependencies = featureSet(&[_]Feature{ .lsx, }), }; - result[@enumToInt(Feature.lbt)] = .{ + result[@intFromEnum(Feature.lbt)] = .{ .llvm_name = "lbt", .description = "'LBT' (Loongson Binary Translation Extension)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lsx)] = .{ + result[@intFromEnum(Feature.lsx)] = .{ .llvm_name = "lsx", .description = "'LSX' (Loongson SIMD Extension)", .dependencies = featureSet(&[_]Feature{ .d, }), }; - result[@enumToInt(Feature.lvz)] = .{ + result[@intFromEnum(Feature.lvz)] = .{ .llvm_name = "lvz", .description = "'LVZ' (Loongson Virtualization Extension)", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/m68k.zig b/lib/std/target/m68k.zig index 10a8ae4dc2b8..422b95ca177a 100644 --- a/lib/std/target/m68k.zig +++ b/lib/std/target/m68k.zig @@ -37,117 +37,117 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.isa_68000)] = .{ + result[@intFromEnum(Feature.isa_68000)] = .{ .llvm_name = "isa-68000", .description = "Is M68000 ISA supported", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.isa_68010)] = .{ + result[@intFromEnum(Feature.isa_68010)] = .{ .llvm_name = "isa-68010", .description = "Is M68010 ISA supported", .dependencies = featureSet(&[_]Feature{ .isa_68000, }), }; - result[@enumToInt(Feature.isa_68020)] = .{ + result[@intFromEnum(Feature.isa_68020)] = .{ .llvm_name = "isa-68020", .description = "Is M68020 ISA supported", .dependencies = featureSet(&[_]Feature{ .isa_68010, }), }; - result[@enumToInt(Feature.isa_68030)] = .{ + result[@intFromEnum(Feature.isa_68030)] = .{ .llvm_name = "isa-68030", .description = "Is M68030 ISA supported", .dependencies = featureSet(&[_]Feature{ .isa_68020, }), }; - result[@enumToInt(Feature.isa_68040)] = .{ + result[@intFromEnum(Feature.isa_68040)] = .{ .llvm_name = "isa-68040", .description = "Is M68040 ISA supported", .dependencies = featureSet(&[_]Feature{ .isa_68030, }), }; - result[@enumToInt(Feature.isa_68060)] = .{ + result[@intFromEnum(Feature.isa_68060)] = .{ .llvm_name = "isa-68060", .description = "Is M68060 ISA supported", .dependencies = featureSet(&[_]Feature{ .isa_68040, }), }; - result[@enumToInt(Feature.reserve_a0)] = .{ + result[@intFromEnum(Feature.reserve_a0)] = .{ .llvm_name = "reserve-a0", .description = "Reserve A0 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_a1)] = .{ + result[@intFromEnum(Feature.reserve_a1)] = .{ .llvm_name = "reserve-a1", .description = "Reserve A1 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_a2)] = .{ + result[@intFromEnum(Feature.reserve_a2)] = .{ .llvm_name = "reserve-a2", .description = "Reserve A2 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_a3)] = .{ + result[@intFromEnum(Feature.reserve_a3)] = .{ .llvm_name = "reserve-a3", .description = "Reserve A3 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_a4)] = .{ + result[@intFromEnum(Feature.reserve_a4)] = .{ .llvm_name = "reserve-a4", .description = "Reserve A4 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_a5)] = .{ + result[@intFromEnum(Feature.reserve_a5)] = .{ .llvm_name = "reserve-a5", .description = "Reserve A5 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_a6)] = .{ + result[@intFromEnum(Feature.reserve_a6)] = .{ .llvm_name = "reserve-a6", .description = "Reserve A6 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_d0)] = .{ + result[@intFromEnum(Feature.reserve_d0)] = .{ .llvm_name = "reserve-d0", .description = "Reserve D0 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_d1)] = .{ + result[@intFromEnum(Feature.reserve_d1)] = .{ .llvm_name = "reserve-d1", .description = "Reserve D1 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_d2)] = .{ + result[@intFromEnum(Feature.reserve_d2)] = .{ .llvm_name = "reserve-d2", .description = "Reserve D2 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_d3)] = .{ + result[@intFromEnum(Feature.reserve_d3)] = .{ .llvm_name = "reserve-d3", .description = "Reserve D3 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_d4)] = .{ + result[@intFromEnum(Feature.reserve_d4)] = .{ .llvm_name = "reserve-d4", .description = "Reserve D4 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_d5)] = .{ + result[@intFromEnum(Feature.reserve_d5)] = .{ .llvm_name = "reserve-d5", .description = "Reserve D5 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_d6)] = .{ + result[@intFromEnum(Feature.reserve_d6)] = .{ .llvm_name = "reserve-d6", .description = "Reserve D6 register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_d7)] = .{ + result[@intFromEnum(Feature.reserve_d7)] = .{ .llvm_name = "reserve-d7", .description = "Reserve D7 register", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/mips.zig b/lib/std/target/mips.zig index 5650bd64c2b8..8f3c0994d1dc 100644 --- a/lib/std/target/mips.zig +++ b/lib/std/target/mips.zig @@ -68,102 +68,102 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.abs2008)] = .{ + result[@intFromEnum(Feature.abs2008)] = .{ .llvm_name = "abs2008", .description = "Disable IEEE 754-2008 abs.fmt mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.cnmips)] = .{ + result[@intFromEnum(Feature.cnmips)] = .{ .llvm_name = "cnmips", .description = "Octeon cnMIPS Support", .dependencies = featureSet(&[_]Feature{ .mips64r2, }), }; - result[@enumToInt(Feature.cnmipsp)] = .{ + result[@intFromEnum(Feature.cnmipsp)] = .{ .llvm_name = "cnmipsp", .description = "Octeon+ cnMIPS Support", .dependencies = featureSet(&[_]Feature{ .cnmips, }), }; - result[@enumToInt(Feature.crc)] = .{ + result[@intFromEnum(Feature.crc)] = .{ .llvm_name = "crc", .description = "Mips R6 CRC ASE", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dsp)] = .{ + result[@intFromEnum(Feature.dsp)] = .{ .llvm_name = "dsp", .description = "Mips DSP ASE", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dspr2)] = .{ + result[@intFromEnum(Feature.dspr2)] = .{ .llvm_name = "dspr2", .description = "Mips DSP-R2 ASE", .dependencies = featureSet(&[_]Feature{ .dsp, }), }; - result[@enumToInt(Feature.dspr3)] = .{ + result[@intFromEnum(Feature.dspr3)] = .{ .llvm_name = "dspr3", .description = "Mips DSP-R3 ASE", .dependencies = featureSet(&[_]Feature{ .dspr2, }), }; - result[@enumToInt(Feature.eva)] = .{ + result[@intFromEnum(Feature.eva)] = .{ .llvm_name = "eva", .description = "Mips EVA ASE", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fp64)] = .{ + result[@intFromEnum(Feature.fp64)] = .{ .llvm_name = "fp64", .description = "Support 64-bit FP registers", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fpxx)] = .{ + result[@intFromEnum(Feature.fpxx)] = .{ .llvm_name = "fpxx", .description = "Support for FPXX", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ginv)] = .{ + result[@intFromEnum(Feature.ginv)] = .{ .llvm_name = "ginv", .description = "Mips Global Invalidate ASE", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gp64)] = .{ + result[@intFromEnum(Feature.gp64)] = .{ .llvm_name = "gp64", .description = "General Purpose Registers are 64-bit wide", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.long_calls)] = .{ + result[@intFromEnum(Feature.long_calls)] = .{ .llvm_name = "long-calls", .description = "Disable use of the jal instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.micromips)] = .{ + result[@intFromEnum(Feature.micromips)] = .{ .llvm_name = "micromips", .description = "microMips mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mips1)] = .{ + result[@intFromEnum(Feature.mips1)] = .{ .llvm_name = "mips1", .description = "Mips I ISA Support [highly experimental]", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mips16)] = .{ + result[@intFromEnum(Feature.mips16)] = .{ .llvm_name = "mips16", .description = "Mips16 mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mips2)] = .{ + result[@intFromEnum(Feature.mips2)] = .{ .llvm_name = "mips2", .description = "Mips II ISA Support [highly experimental]", .dependencies = featureSet(&[_]Feature{ .mips1, }), }; - result[@enumToInt(Feature.mips3)] = .{ + result[@intFromEnum(Feature.mips3)] = .{ .llvm_name = "mips3", .description = "MIPS III ISA Support [highly experimental]", .dependencies = featureSet(&[_]Feature{ @@ -174,7 +174,7 @@ pub const all_features = blk: { .mips3_32r2, }), }; - result[@enumToInt(Feature.mips32)] = .{ + result[@intFromEnum(Feature.mips32)] = .{ .llvm_name = "mips32", .description = "Mips32 ISA Support", .dependencies = featureSet(&[_]Feature{ @@ -183,7 +183,7 @@ pub const all_features = blk: { .mips4_32, }), }; - result[@enumToInt(Feature.mips32r2)] = .{ + result[@intFromEnum(Feature.mips32r2)] = .{ .llvm_name = "mips32r2", .description = "Mips32r2 ISA Support", .dependencies = featureSet(&[_]Feature{ @@ -193,21 +193,21 @@ pub const all_features = blk: { .mips5_32r2, }), }; - result[@enumToInt(Feature.mips32r3)] = .{ + result[@intFromEnum(Feature.mips32r3)] = .{ .llvm_name = "mips32r3", .description = "Mips32r3 ISA Support", .dependencies = featureSet(&[_]Feature{ .mips32r2, }), }; - result[@enumToInt(Feature.mips32r5)] = .{ + result[@intFromEnum(Feature.mips32r5)] = .{ .llvm_name = "mips32r5", .description = "Mips32r5 ISA Support", .dependencies = featureSet(&[_]Feature{ .mips32r3, }), }; - result[@enumToInt(Feature.mips32r6)] = .{ + result[@intFromEnum(Feature.mips32r6)] = .{ .llvm_name = "mips32r6", .description = "Mips32r6 ISA Support [experimental]", .dependencies = featureSet(&[_]Feature{ @@ -217,22 +217,22 @@ pub const all_features = blk: { .nan2008, }), }; - result[@enumToInt(Feature.mips3_32)] = .{ + result[@intFromEnum(Feature.mips3_32)] = .{ .llvm_name = "mips3_32", .description = "Subset of MIPS-III that is also in MIPS32 [highly experimental]", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mips3_32r2)] = .{ + result[@intFromEnum(Feature.mips3_32r2)] = .{ .llvm_name = "mips3_32r2", .description = "Subset of MIPS-III that is also in MIPS32r2 [highly experimental]", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mips3d)] = .{ + result[@intFromEnum(Feature.mips3d)] = .{ .llvm_name = "mips3d", .description = "Mips 3D ASE", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mips4)] = .{ + result[@intFromEnum(Feature.mips4)] = .{ .llvm_name = "mips4", .description = "MIPS IV ISA Support", .dependencies = featureSet(&[_]Feature{ @@ -241,17 +241,17 @@ pub const all_features = blk: { .mips4_32r2, }), }; - result[@enumToInt(Feature.mips4_32)] = .{ + result[@intFromEnum(Feature.mips4_32)] = .{ .llvm_name = "mips4_32", .description = "Subset of MIPS-IV that is also in MIPS32 [highly experimental]", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mips4_32r2)] = .{ + result[@intFromEnum(Feature.mips4_32r2)] = .{ .llvm_name = "mips4_32r2", .description = "Subset of MIPS-IV that is also in MIPS32r2 [highly experimental]", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mips5)] = .{ + result[@intFromEnum(Feature.mips5)] = .{ .llvm_name = "mips5", .description = "MIPS V ISA Support [highly experimental]", .dependencies = featureSet(&[_]Feature{ @@ -259,12 +259,12 @@ pub const all_features = blk: { .mips5_32r2, }), }; - result[@enumToInt(Feature.mips5_32r2)] = .{ + result[@intFromEnum(Feature.mips5_32r2)] = .{ .llvm_name = "mips5_32r2", .description = "Subset of MIPS-V that is also in MIPS32r2 [highly experimental]", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mips64)] = .{ + result[@intFromEnum(Feature.mips64)] = .{ .llvm_name = "mips64", .description = "Mips64 ISA Support", .dependencies = featureSet(&[_]Feature{ @@ -272,7 +272,7 @@ pub const all_features = blk: { .mips5, }), }; - result[@enumToInt(Feature.mips64r2)] = .{ + result[@intFromEnum(Feature.mips64r2)] = .{ .llvm_name = "mips64r2", .description = "Mips64r2 ISA Support", .dependencies = featureSet(&[_]Feature{ @@ -280,7 +280,7 @@ pub const all_features = blk: { .mips64, }), }; - result[@enumToInt(Feature.mips64r3)] = .{ + result[@intFromEnum(Feature.mips64r3)] = .{ .llvm_name = "mips64r3", .description = "Mips64r3 ISA Support", .dependencies = featureSet(&[_]Feature{ @@ -288,7 +288,7 @@ pub const all_features = blk: { .mips64r2, }), }; - result[@enumToInt(Feature.mips64r5)] = .{ + result[@intFromEnum(Feature.mips64r5)] = .{ .llvm_name = "mips64r5", .description = "Mips64r5 ISA Support", .dependencies = featureSet(&[_]Feature{ @@ -296,7 +296,7 @@ pub const all_features = blk: { .mips64r3, }), }; - result[@enumToInt(Feature.mips64r6)] = .{ + result[@intFromEnum(Feature.mips64r6)] = .{ .llvm_name = "mips64r6", .description = "Mips64r6 ISA Support [experimental]", .dependencies = featureSet(&[_]Feature{ @@ -304,84 +304,84 @@ pub const all_features = blk: { .mips64r5, }), }; - result[@enumToInt(Feature.msa)] = .{ + result[@intFromEnum(Feature.msa)] = .{ .llvm_name = "msa", .description = "Mips MSA ASE", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mt)] = .{ + result[@intFromEnum(Feature.mt)] = .{ .llvm_name = "mt", .description = "Mips MT ASE", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nan2008)] = .{ + result[@intFromEnum(Feature.nan2008)] = .{ .llvm_name = "nan2008", .description = "IEEE 754-2008 NaN encoding", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.noabicalls)] = .{ + result[@intFromEnum(Feature.noabicalls)] = .{ .llvm_name = "noabicalls", .description = "Disable SVR4-style position-independent code", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nomadd4)] = .{ + result[@intFromEnum(Feature.nomadd4)] = .{ .llvm_name = "nomadd4", .description = "Disable 4-operand madd.fmt and related instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nooddspreg)] = .{ + result[@intFromEnum(Feature.nooddspreg)] = .{ .llvm_name = "nooddspreg", .description = "Disable odd numbered single-precision registers", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.p5600)] = .{ + result[@intFromEnum(Feature.p5600)] = .{ .llvm_name = "p5600", .description = "The P5600 Processor", .dependencies = featureSet(&[_]Feature{ .mips32r5, }), }; - result[@enumToInt(Feature.ptr64)] = .{ + result[@intFromEnum(Feature.ptr64)] = .{ .llvm_name = "ptr64", .description = "Pointers are 64-bit wide", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.single_float)] = .{ + result[@intFromEnum(Feature.single_float)] = .{ .llvm_name = "single-float", .description = "Only supports single precision float", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.soft_float)] = .{ + result[@intFromEnum(Feature.soft_float)] = .{ .llvm_name = "soft-float", .description = "Does not support floating point instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sym32)] = .{ + result[@intFromEnum(Feature.sym32)] = .{ .llvm_name = "sym32", .description = "Symbols are 32 bit on Mips64", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.use_indirect_jump_hazard)] = .{ + result[@intFromEnum(Feature.use_indirect_jump_hazard)] = .{ .llvm_name = "use-indirect-jump-hazard", .description = "Use indirect jump guards to prevent certain speculation based attacks", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.use_tcc_in_div)] = .{ + result[@intFromEnum(Feature.use_tcc_in_div)] = .{ .llvm_name = "use-tcc-in-div", .description = "Force the assembler to use trapping", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vfpu)] = .{ + result[@intFromEnum(Feature.vfpu)] = .{ .llvm_name = "vfpu", .description = "Enable vector FPU instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.virt)] = .{ + result[@intFromEnum(Feature.virt)] = .{ .llvm_name = "virt", .description = "Mips Virtualization ASE", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.xgot)] = .{ + result[@intFromEnum(Feature.xgot)] = .{ .llvm_name = "xgot", .description = "Assume 32-bit GOT", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/msp430.zig b/lib/std/target/msp430.zig index 8e2b8536c8fd..98ea32d17fbb 100644 --- a/lib/std/target/msp430.zig +++ b/lib/std/target/msp430.zig @@ -20,22 +20,22 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.ext)] = .{ + result[@intFromEnum(Feature.ext)] = .{ .llvm_name = "ext", .description = "Enable MSP430-X extensions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hwmult16)] = .{ + result[@intFromEnum(Feature.hwmult16)] = .{ .llvm_name = "hwmult16", .description = "Enable 16-bit hardware multiplier", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hwmult32)] = .{ + result[@intFromEnum(Feature.hwmult32)] = .{ .llvm_name = "hwmult32", .description = "Enable 32-bit hardware multiplier", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hwmultf5)] = .{ + result[@intFromEnum(Feature.hwmultf5)] = .{ .llvm_name = "hwmultf5", .description = "Enable F5 series hardware multiplier", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/nvptx.zig b/lib/std/target/nvptx.zig index 135e66715e1d..dfe3061bae44 100644 --- a/lib/std/target/nvptx.zig +++ b/lib/std/target/nvptx.zig @@ -56,202 +56,202 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.ptx32)] = .{ + result[@intFromEnum(Feature.ptx32)] = .{ .llvm_name = "ptx32", .description = "Use PTX version 3.2", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx40)] = .{ + result[@intFromEnum(Feature.ptx40)] = .{ .llvm_name = "ptx40", .description = "Use PTX version 4.0", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx41)] = .{ + result[@intFromEnum(Feature.ptx41)] = .{ .llvm_name = "ptx41", .description = "Use PTX version 4.1", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx42)] = .{ + result[@intFromEnum(Feature.ptx42)] = .{ .llvm_name = "ptx42", .description = "Use PTX version 4.2", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx43)] = .{ + result[@intFromEnum(Feature.ptx43)] = .{ .llvm_name = "ptx43", .description = "Use PTX version 4.3", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx50)] = .{ + result[@intFromEnum(Feature.ptx50)] = .{ .llvm_name = "ptx50", .description = "Use PTX version 5.0", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx60)] = .{ + result[@intFromEnum(Feature.ptx60)] = .{ .llvm_name = "ptx60", .description = "Use PTX version 6.0", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx61)] = .{ + result[@intFromEnum(Feature.ptx61)] = .{ .llvm_name = "ptx61", .description = "Use PTX version 6.1", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx63)] = .{ + result[@intFromEnum(Feature.ptx63)] = .{ .llvm_name = "ptx63", .description = "Use PTX version 6.3", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx64)] = .{ + result[@intFromEnum(Feature.ptx64)] = .{ .llvm_name = "ptx64", .description = "Use PTX version 6.4", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx65)] = .{ + result[@intFromEnum(Feature.ptx65)] = .{ .llvm_name = "ptx65", .description = "Use PTX version 6.5", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx70)] = .{ + result[@intFromEnum(Feature.ptx70)] = .{ .llvm_name = "ptx70", .description = "Use PTX version 7.0", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx71)] = .{ + result[@intFromEnum(Feature.ptx71)] = .{ .llvm_name = "ptx71", .description = "Use PTX version 7.1", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx72)] = .{ + result[@intFromEnum(Feature.ptx72)] = .{ .llvm_name = "ptx72", .description = "Use PTX version 7.2", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx73)] = .{ + result[@intFromEnum(Feature.ptx73)] = .{ .llvm_name = "ptx73", .description = "Use PTX version 7.3", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx74)] = .{ + result[@intFromEnum(Feature.ptx74)] = .{ .llvm_name = "ptx74", .description = "Use PTX version 7.4", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx75)] = .{ + result[@intFromEnum(Feature.ptx75)] = .{ .llvm_name = "ptx75", .description = "Use PTX version 7.5", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx76)] = .{ + result[@intFromEnum(Feature.ptx76)] = .{ .llvm_name = "ptx76", .description = "Use PTX version 7.6", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx77)] = .{ + result[@intFromEnum(Feature.ptx77)] = .{ .llvm_name = "ptx77", .description = "Use PTX version 7.7", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptx78)] = .{ + result[@intFromEnum(Feature.ptx78)] = .{ .llvm_name = "ptx78", .description = "Use PTX version 7.8", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_20)] = .{ + result[@intFromEnum(Feature.sm_20)] = .{ .llvm_name = "sm_20", .description = "Target SM 2.0", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_21)] = .{ + result[@intFromEnum(Feature.sm_21)] = .{ .llvm_name = "sm_21", .description = "Target SM 2.1", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_30)] = .{ + result[@intFromEnum(Feature.sm_30)] = .{ .llvm_name = "sm_30", .description = "Target SM 3.0", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_32)] = .{ + result[@intFromEnum(Feature.sm_32)] = .{ .llvm_name = "sm_32", .description = "Target SM 3.2", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_35)] = .{ + result[@intFromEnum(Feature.sm_35)] = .{ .llvm_name = "sm_35", .description = "Target SM 3.5", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_37)] = .{ + result[@intFromEnum(Feature.sm_37)] = .{ .llvm_name = "sm_37", .description = "Target SM 3.7", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_50)] = .{ + result[@intFromEnum(Feature.sm_50)] = .{ .llvm_name = "sm_50", .description = "Target SM 5.0", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_52)] = .{ + result[@intFromEnum(Feature.sm_52)] = .{ .llvm_name = "sm_52", .description = "Target SM 5.2", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_53)] = .{ + result[@intFromEnum(Feature.sm_53)] = .{ .llvm_name = "sm_53", .description = "Target SM 5.3", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_60)] = .{ + result[@intFromEnum(Feature.sm_60)] = .{ .llvm_name = "sm_60", .description = "Target SM 6.0", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_61)] = .{ + result[@intFromEnum(Feature.sm_61)] = .{ .llvm_name = "sm_61", .description = "Target SM 6.1", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_62)] = .{ + result[@intFromEnum(Feature.sm_62)] = .{ .llvm_name = "sm_62", .description = "Target SM 6.2", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_70)] = .{ + result[@intFromEnum(Feature.sm_70)] = .{ .llvm_name = "sm_70", .description = "Target SM 7.0", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_72)] = .{ + result[@intFromEnum(Feature.sm_72)] = .{ .llvm_name = "sm_72", .description = "Target SM 7.2", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_75)] = .{ + result[@intFromEnum(Feature.sm_75)] = .{ .llvm_name = "sm_75", .description = "Target SM 7.5", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_80)] = .{ + result[@intFromEnum(Feature.sm_80)] = .{ .llvm_name = "sm_80", .description = "Target SM 8.0", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_86)] = .{ + result[@intFromEnum(Feature.sm_86)] = .{ .llvm_name = "sm_86", .description = "Target SM 8.6", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_87)] = .{ + result[@intFromEnum(Feature.sm_87)] = .{ .llvm_name = "sm_87", .description = "Target SM 8.7", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_89)] = .{ + result[@intFromEnum(Feature.sm_89)] = .{ .llvm_name = "sm_89", .description = "Target SM 8.9", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sm_90)] = .{ + result[@intFromEnum(Feature.sm_90)] = .{ .llvm_name = "sm_90", .description = "Target SM 9.0", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/powerpc.zig b/lib/std/target/powerpc.zig index 68d86777aa6e..c350c166ba89 100644 --- a/lib/std/target/powerpc.zig +++ b/lib/std/target/powerpc.zig @@ -97,329 +97,329 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.@"64bit")] = .{ + result[@intFromEnum(Feature.@"64bit")] = .{ .llvm_name = "64bit", .description = "Enable 64-bit instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.@"64bitregs")] = .{ + result[@intFromEnum(Feature.@"64bitregs")] = .{ .llvm_name = "64bitregs", .description = "Enable 64-bit registers usage for ppc32 [beta]", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.aix)] = .{ + result[@intFromEnum(Feature.aix)] = .{ .llvm_name = "aix", .description = "AIX OS", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.allow_unaligned_fp_access)] = .{ + result[@intFromEnum(Feature.allow_unaligned_fp_access)] = .{ .llvm_name = "allow-unaligned-fp-access", .description = "CPU does not trap on unaligned FP access", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.altivec)] = .{ + result[@intFromEnum(Feature.altivec)] = .{ .llvm_name = "altivec", .description = "Enable Altivec instructions", .dependencies = featureSet(&[_]Feature{ .fpu, }), }; - result[@enumToInt(Feature.booke)] = .{ + result[@intFromEnum(Feature.booke)] = .{ .llvm_name = "booke", .description = "Enable Book E instructions", .dependencies = featureSet(&[_]Feature{ .icbt, }), }; - result[@enumToInt(Feature.bpermd)] = .{ + result[@intFromEnum(Feature.bpermd)] = .{ .llvm_name = "bpermd", .description = "Enable the bpermd instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.cmpb)] = .{ + result[@intFromEnum(Feature.cmpb)] = .{ .llvm_name = "cmpb", .description = "Enable the cmpb instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.crbits)] = .{ + result[@intFromEnum(Feature.crbits)] = .{ .llvm_name = "crbits", .description = "Use condition-register bits individually", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.crypto)] = .{ + result[@intFromEnum(Feature.crypto)] = .{ .llvm_name = "crypto", .description = "Enable POWER8 Crypto instructions", .dependencies = featureSet(&[_]Feature{ .power8_altivec, }), }; - result[@enumToInt(Feature.direct_move)] = .{ + result[@intFromEnum(Feature.direct_move)] = .{ .llvm_name = "direct-move", .description = "Enable Power8 direct move instructions", .dependencies = featureSet(&[_]Feature{ .vsx, }), }; - result[@enumToInt(Feature.e500)] = .{ + result[@intFromEnum(Feature.e500)] = .{ .llvm_name = "e500", .description = "Enable E500/E500mc instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.efpu2)] = .{ + result[@intFromEnum(Feature.efpu2)] = .{ .llvm_name = "efpu2", .description = "Enable Embedded Floating-Point APU 2 instructions", .dependencies = featureSet(&[_]Feature{ .spe, }), }; - result[@enumToInt(Feature.extdiv)] = .{ + result[@intFromEnum(Feature.extdiv)] = .{ .llvm_name = "extdiv", .description = "Enable extended divide instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_MFLR)] = .{ + result[@intFromEnum(Feature.fast_MFLR)] = .{ .llvm_name = "fast-MFLR", .description = "MFLR is a fast instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fcpsgn)] = .{ + result[@intFromEnum(Feature.fcpsgn)] = .{ .llvm_name = "fcpsgn", .description = "Enable the fcpsgn instruction", .dependencies = featureSet(&[_]Feature{ .fpu, }), }; - result[@enumToInt(Feature.float128)] = .{ + result[@intFromEnum(Feature.float128)] = .{ .llvm_name = "float128", .description = "Enable the __float128 data type for IEEE-754R Binary128.", .dependencies = featureSet(&[_]Feature{ .vsx, }), }; - result[@enumToInt(Feature.fpcvt)] = .{ + result[@intFromEnum(Feature.fpcvt)] = .{ .llvm_name = "fpcvt", .description = "Enable fc[ft]* (unsigned and single-precision) and lfiwzx instructions", .dependencies = featureSet(&[_]Feature{ .fpu, }), }; - result[@enumToInt(Feature.fprnd)] = .{ + result[@intFromEnum(Feature.fprnd)] = .{ .llvm_name = "fprnd", .description = "Enable the fri[mnpz] instructions", .dependencies = featureSet(&[_]Feature{ .fpu, }), }; - result[@enumToInt(Feature.fpu)] = .{ + result[@intFromEnum(Feature.fpu)] = .{ .llvm_name = "fpu", .description = "Enable classic FPU instructions", .dependencies = featureSet(&[_]Feature{ .hard_float, }), }; - result[@enumToInt(Feature.fre)] = .{ + result[@intFromEnum(Feature.fre)] = .{ .llvm_name = "fre", .description = "Enable the fre instruction", .dependencies = featureSet(&[_]Feature{ .fpu, }), }; - result[@enumToInt(Feature.fres)] = .{ + result[@intFromEnum(Feature.fres)] = .{ .llvm_name = "fres", .description = "Enable the fres instruction", .dependencies = featureSet(&[_]Feature{ .fpu, }), }; - result[@enumToInt(Feature.frsqrte)] = .{ + result[@intFromEnum(Feature.frsqrte)] = .{ .llvm_name = "frsqrte", .description = "Enable the frsqrte instruction", .dependencies = featureSet(&[_]Feature{ .fpu, }), }; - result[@enumToInt(Feature.frsqrtes)] = .{ + result[@intFromEnum(Feature.frsqrtes)] = .{ .llvm_name = "frsqrtes", .description = "Enable the frsqrtes instruction", .dependencies = featureSet(&[_]Feature{ .fpu, }), }; - result[@enumToInt(Feature.fsqrt)] = .{ + result[@intFromEnum(Feature.fsqrt)] = .{ .llvm_name = "fsqrt", .description = "Enable the fsqrt instruction", .dependencies = featureSet(&[_]Feature{ .fpu, }), }; - result[@enumToInt(Feature.fuse_add_logical)] = .{ + result[@intFromEnum(Feature.fuse_add_logical)] = .{ .llvm_name = "fuse-add-logical", .description = "Target supports Add with Logical Operations fusion", .dependencies = featureSet(&[_]Feature{ .fusion, }), }; - result[@enumToInt(Feature.fuse_addi_load)] = .{ + result[@intFromEnum(Feature.fuse_addi_load)] = .{ .llvm_name = "fuse-addi-load", .description = "Power8 Addi-Load fusion", .dependencies = featureSet(&[_]Feature{ .fusion, }), }; - result[@enumToInt(Feature.fuse_addis_load)] = .{ + result[@intFromEnum(Feature.fuse_addis_load)] = .{ .llvm_name = "fuse-addis-load", .description = "Power8 Addis-Load fusion", .dependencies = featureSet(&[_]Feature{ .fusion, }), }; - result[@enumToInt(Feature.fuse_arith_add)] = .{ + result[@intFromEnum(Feature.fuse_arith_add)] = .{ .llvm_name = "fuse-arith-add", .description = "Target supports Arithmetic Operations with Add fusion", .dependencies = featureSet(&[_]Feature{ .fusion, }), }; - result[@enumToInt(Feature.fuse_back2back)] = .{ + result[@intFromEnum(Feature.fuse_back2back)] = .{ .llvm_name = "fuse-back2back", .description = "Target supports general back to back fusion", .dependencies = featureSet(&[_]Feature{ .fusion, }), }; - result[@enumToInt(Feature.fuse_cmp)] = .{ + result[@intFromEnum(Feature.fuse_cmp)] = .{ .llvm_name = "fuse-cmp", .description = "Target supports Comparison Operations fusion", .dependencies = featureSet(&[_]Feature{ .fusion, }), }; - result[@enumToInt(Feature.fuse_logical)] = .{ + result[@intFromEnum(Feature.fuse_logical)] = .{ .llvm_name = "fuse-logical", .description = "Target supports Logical Operations fusion", .dependencies = featureSet(&[_]Feature{ .fusion, }), }; - result[@enumToInt(Feature.fuse_logical_add)] = .{ + result[@intFromEnum(Feature.fuse_logical_add)] = .{ .llvm_name = "fuse-logical-add", .description = "Target supports Logical with Add Operations fusion", .dependencies = featureSet(&[_]Feature{ .fusion, }), }; - result[@enumToInt(Feature.fuse_sha3)] = .{ + result[@intFromEnum(Feature.fuse_sha3)] = .{ .llvm_name = "fuse-sha3", .description = "Target supports SHA3 assist fusion", .dependencies = featureSet(&[_]Feature{ .fusion, }), }; - result[@enumToInt(Feature.fuse_store)] = .{ + result[@intFromEnum(Feature.fuse_store)] = .{ .llvm_name = "fuse-store", .description = "Target supports store clustering", .dependencies = featureSet(&[_]Feature{ .fusion, }), }; - result[@enumToInt(Feature.fuse_wideimm)] = .{ + result[@intFromEnum(Feature.fuse_wideimm)] = .{ .llvm_name = "fuse-wideimm", .description = "Target supports Wide-Immediate fusion", .dependencies = featureSet(&[_]Feature{ .fusion, }), }; - result[@enumToInt(Feature.fuse_zeromove)] = .{ + result[@intFromEnum(Feature.fuse_zeromove)] = .{ .llvm_name = "fuse-zeromove", .description = "Target supports move to SPR with branch fusion", .dependencies = featureSet(&[_]Feature{ .fusion, }), }; - result[@enumToInt(Feature.fusion)] = .{ + result[@intFromEnum(Feature.fusion)] = .{ .llvm_name = "fusion", .description = "Target supports instruction fusion", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hard_float)] = .{ + result[@intFromEnum(Feature.hard_float)] = .{ .llvm_name = "hard-float", .description = "Enable floating-point instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.htm)] = .{ + result[@intFromEnum(Feature.htm)] = .{ .llvm_name = "htm", .description = "Enable Hardware Transactional Memory instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.icbt)] = .{ + result[@intFromEnum(Feature.icbt)] = .{ .llvm_name = "icbt", .description = "Enable icbt instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.invariant_function_descriptors)] = .{ + result[@intFromEnum(Feature.invariant_function_descriptors)] = .{ .llvm_name = "invariant-function-descriptors", .description = "Assume function descriptors are invariant", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.isa_future_instructions)] = .{ + result[@intFromEnum(Feature.isa_future_instructions)] = .{ .llvm_name = "isa-future-instructions", .description = "Enable instructions for Future ISA.", .dependencies = featureSet(&[_]Feature{ .isa_v31_instructions, }), }; - result[@enumToInt(Feature.isa_v206_instructions)] = .{ + result[@intFromEnum(Feature.isa_v206_instructions)] = .{ .llvm_name = "isa-v206-instructions", .description = "Enable instructions in ISA 2.06.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.isa_v207_instructions)] = .{ + result[@intFromEnum(Feature.isa_v207_instructions)] = .{ .llvm_name = "isa-v207-instructions", .description = "Enable instructions in ISA 2.07.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.isa_v30_instructions)] = .{ + result[@intFromEnum(Feature.isa_v30_instructions)] = .{ .llvm_name = "isa-v30-instructions", .description = "Enable instructions in ISA 3.0.", .dependencies = featureSet(&[_]Feature{ .isa_v207_instructions, }), }; - result[@enumToInt(Feature.isa_v31_instructions)] = .{ + result[@intFromEnum(Feature.isa_v31_instructions)] = .{ .llvm_name = "isa-v31-instructions", .description = "Enable instructions in ISA 3.1.", .dependencies = featureSet(&[_]Feature{ .isa_v30_instructions, }), }; - result[@enumToInt(Feature.isel)] = .{ + result[@intFromEnum(Feature.isel)] = .{ .llvm_name = "isel", .description = "Enable the isel instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ldbrx)] = .{ + result[@intFromEnum(Feature.ldbrx)] = .{ .llvm_name = "ldbrx", .description = "Enable the ldbrx instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lfiwax)] = .{ + result[@intFromEnum(Feature.lfiwax)] = .{ .llvm_name = "lfiwax", .description = "Enable the lfiwax instruction", .dependencies = featureSet(&[_]Feature{ .fpu, }), }; - result[@enumToInt(Feature.longcall)] = .{ + result[@intFromEnum(Feature.longcall)] = .{ .llvm_name = "longcall", .description = "Always use indirect calls", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mfocrf)] = .{ + result[@intFromEnum(Feature.mfocrf)] = .{ .llvm_name = "mfocrf", .description = "Enable the MFOCRF instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mma)] = .{ + result[@intFromEnum(Feature.mma)] = .{ .llvm_name = "mma", .description = "Enable MMA instructions", .dependencies = featureSet(&[_]Feature{ @@ -428,43 +428,43 @@ pub const all_features = blk: { .power9_altivec, }), }; - result[@enumToInt(Feature.modern_aix_as)] = .{ + result[@intFromEnum(Feature.modern_aix_as)] = .{ .llvm_name = "modern-aix-as", .description = "AIX system assembler is modern enough to support new mnes", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.msync)] = .{ + result[@intFromEnum(Feature.msync)] = .{ .llvm_name = "msync", .description = "Has only the msync instruction instead of sync", .dependencies = featureSet(&[_]Feature{ .booke, }), }; - result[@enumToInt(Feature.paired_vector_memops)] = .{ + result[@intFromEnum(Feature.paired_vector_memops)] = .{ .llvm_name = "paired-vector-memops", .description = "32Byte load and store instructions", .dependencies = featureSet(&[_]Feature{ .isa_v30_instructions, }), }; - result[@enumToInt(Feature.partword_atomics)] = .{ + result[@intFromEnum(Feature.partword_atomics)] = .{ .llvm_name = "partword-atomics", .description = "Enable l[bh]arx and st[bh]cx.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.pcrelative_memops)] = .{ + result[@intFromEnum(Feature.pcrelative_memops)] = .{ .llvm_name = "pcrelative-memops", .description = "Enable PC relative Memory Ops", .dependencies = featureSet(&[_]Feature{ .prefix_instrs, }), }; - result[@enumToInt(Feature.popcntd)] = .{ + result[@intFromEnum(Feature.popcntd)] = .{ .llvm_name = "popcntd", .description = "Enable the popcnt[dw] instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.power10_vector)] = .{ + result[@intFromEnum(Feature.power10_vector)] = .{ .llvm_name = "power10-vector", .description = "Enable POWER10 vector instructions", .dependencies = featureSet(&[_]Feature{ @@ -472,14 +472,14 @@ pub const all_features = blk: { .power9_vector, }), }; - result[@enumToInt(Feature.power8_altivec)] = .{ + result[@intFromEnum(Feature.power8_altivec)] = .{ .llvm_name = "power8-altivec", .description = "Enable POWER8 Altivec instructions", .dependencies = featureSet(&[_]Feature{ .altivec, }), }; - result[@enumToInt(Feature.power8_vector)] = .{ + result[@intFromEnum(Feature.power8_vector)] = .{ .llvm_name = "power8-vector", .description = "Enable POWER8 vector instructions", .dependencies = featureSet(&[_]Feature{ @@ -487,7 +487,7 @@ pub const all_features = blk: { .vsx, }), }; - result[@enumToInt(Feature.power9_altivec)] = .{ + result[@intFromEnum(Feature.power9_altivec)] = .{ .llvm_name = "power9-altivec", .description = "Enable POWER9 Altivec instructions", .dependencies = featureSet(&[_]Feature{ @@ -495,7 +495,7 @@ pub const all_features = blk: { .power8_altivec, }), }; - result[@enumToInt(Feature.power9_vector)] = .{ + result[@intFromEnum(Feature.power9_vector)] = .{ .llvm_name = "power9-vector", .description = "Enable POWER9 vector instructions", .dependencies = featureSet(&[_]Feature{ @@ -503,32 +503,32 @@ pub const all_features = blk: { .power9_altivec, }), }; - result[@enumToInt(Feature.ppc4xx)] = .{ + result[@intFromEnum(Feature.ppc4xx)] = .{ .llvm_name = "ppc4xx", .description = "Enable PPC 4xx instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ppc6xx)] = .{ + result[@intFromEnum(Feature.ppc6xx)] = .{ .llvm_name = "ppc6xx", .description = "Enable PPC 6xx instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ppc_postra_sched)] = .{ + result[@intFromEnum(Feature.ppc_postra_sched)] = .{ .llvm_name = "ppc-postra-sched", .description = "Use PowerPC post-RA scheduling strategy", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ppc_prera_sched)] = .{ + result[@intFromEnum(Feature.ppc_prera_sched)] = .{ .llvm_name = "ppc-prera-sched", .description = "Use PowerPC pre-RA scheduling strategy", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.predictable_select_expensive)] = .{ + result[@intFromEnum(Feature.predictable_select_expensive)] = .{ .llvm_name = "predictable-select-expensive", .description = "Prefer likely predicted branches over selects", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prefix_instrs)] = .{ + result[@intFromEnum(Feature.prefix_instrs)] = .{ .llvm_name = "prefix-instrs", .description = "Enable prefixed instructions", .dependencies = featureSet(&[_]Feature{ @@ -536,61 +536,61 @@ pub const all_features = blk: { .power9_altivec, }), }; - result[@enumToInt(Feature.privileged)] = .{ + result[@intFromEnum(Feature.privileged)] = .{ .llvm_name = "privileged", .description = "Add privileged instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.quadword_atomics)] = .{ + result[@intFromEnum(Feature.quadword_atomics)] = .{ .llvm_name = "quadword-atomics", .description = "Enable lqarx and stqcx.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.recipprec)] = .{ + result[@intFromEnum(Feature.recipprec)] = .{ .llvm_name = "recipprec", .description = "Assume higher precision reciprocal estimates", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.rop_protect)] = .{ + result[@intFromEnum(Feature.rop_protect)] = .{ .llvm_name = "rop-protect", .description = "Add ROP protect", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.secure_plt)] = .{ + result[@intFromEnum(Feature.secure_plt)] = .{ .llvm_name = "secure-plt", .description = "Enable secure plt mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_popcntd)] = .{ + result[@intFromEnum(Feature.slow_popcntd)] = .{ .llvm_name = "slow-popcntd", .description = "Has slow popcnt[dw] instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.spe)] = .{ + result[@intFromEnum(Feature.spe)] = .{ .llvm_name = "spe", .description = "Enable SPE instructions", .dependencies = featureSet(&[_]Feature{ .hard_float, }), }; - result[@enumToInt(Feature.stfiwx)] = .{ + result[@intFromEnum(Feature.stfiwx)] = .{ .llvm_name = "stfiwx", .description = "Enable the stfiwx instruction", .dependencies = featureSet(&[_]Feature{ .fpu, }), }; - result[@enumToInt(Feature.two_const_nr)] = .{ + result[@intFromEnum(Feature.two_const_nr)] = .{ .llvm_name = "two-const-nr", .description = "Requires two constant Newton-Raphson computation", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vectors_use_two_units)] = .{ + result[@intFromEnum(Feature.vectors_use_two_units)] = .{ .llvm_name = "vectors-use-two-units", .description = "Vectors use two units", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vsx)] = .{ + result[@intFromEnum(Feature.vsx)] = .{ .llvm_name = "vsx", .description = "Enable VSX instructions", .dependencies = featureSet(&[_]Feature{ diff --git a/lib/std/target/riscv.zig b/lib/std/target/riscv.zig index 0e72fa6e96b0..8e49a6b18084 100644 --- a/lib/std/target/riscv.zig +++ b/lib/std/target/riscv.zig @@ -124,311 +124,311 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.@"32bit")] = .{ + result[@intFromEnum(Feature.@"32bit")] = .{ .llvm_name = "32bit", .description = "Implements RV32", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.@"64bit")] = .{ + result[@intFromEnum(Feature.@"64bit")] = .{ .llvm_name = "64bit", .description = "Implements RV64", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.a)] = .{ + result[@intFromEnum(Feature.a)] = .{ .llvm_name = "a", .description = "'A' (Atomic Instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.c)] = .{ + result[@intFromEnum(Feature.c)] = .{ .llvm_name = "c", .description = "'C' (Compressed Instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.d)] = .{ + result[@intFromEnum(Feature.d)] = .{ .llvm_name = "d", .description = "'D' (Double-Precision Floating-Point)", .dependencies = featureSet(&[_]Feature{ .f, }), }; - result[@enumToInt(Feature.e)] = .{ + result[@intFromEnum(Feature.e)] = .{ .llvm_name = "e", .description = "Implements RV32E (provides 16 rather than 32 GPRs)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.experimental_zawrs)] = .{ + result[@intFromEnum(Feature.experimental_zawrs)] = .{ .llvm_name = "experimental-zawrs", .description = "'Zawrs' (Wait on Reservation Set)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.experimental_zca)] = .{ + result[@intFromEnum(Feature.experimental_zca)] = .{ .llvm_name = "experimental-zca", .description = "'Zca' (part of the C extension, excluding compressed floating point loads/stores)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.experimental_zcd)] = .{ + result[@intFromEnum(Feature.experimental_zcd)] = .{ .llvm_name = "experimental-zcd", .description = "'Zcd' (Compressed Double-Precision Floating-Point Instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.experimental_zcf)] = .{ + result[@intFromEnum(Feature.experimental_zcf)] = .{ .llvm_name = "experimental-zcf", .description = "'Zcf' (Compressed Single-Precision Floating-Point Instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.experimental_zihintntl)] = .{ + result[@intFromEnum(Feature.experimental_zihintntl)] = .{ .llvm_name = "experimental-zihintntl", .description = "'zihintntl' (Non-Temporal Locality Hints)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.experimental_ztso)] = .{ + result[@intFromEnum(Feature.experimental_ztso)] = .{ .llvm_name = "experimental-ztso", .description = "'Ztso' (Memory Model - Total Store Order)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.experimental_zvfh)] = .{ + result[@intFromEnum(Feature.experimental_zvfh)] = .{ .llvm_name = "experimental-zvfh", .description = "'Zvfh' (Vector Half-Precision Floating-Point)", .dependencies = featureSet(&[_]Feature{ .zve32f, }), }; - result[@enumToInt(Feature.f)] = .{ + result[@intFromEnum(Feature.f)] = .{ .llvm_name = "f", .description = "'F' (Single-Precision Floating-Point)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.forced_atomics)] = .{ + result[@intFromEnum(Feature.forced_atomics)] = .{ .llvm_name = "forced-atomics", .description = "Assume that lock-free native-width atomics are available", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.h)] = .{ + result[@intFromEnum(Feature.h)] = .{ .llvm_name = "h", .description = "'H' (Hypervisor)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lui_addi_fusion)] = .{ + result[@intFromEnum(Feature.lui_addi_fusion)] = .{ .llvm_name = "lui-addi-fusion", .description = "Enable LUI+ADDI macrofusion", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.m)] = .{ + result[@intFromEnum(Feature.m)] = .{ .llvm_name = "m", .description = "'M' (Integer Multiplication and Division)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_default_unroll)] = .{ + result[@intFromEnum(Feature.no_default_unroll)] = .{ .llvm_name = "no-default-unroll", .description = "Disable default unroll preference.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_optimized_zero_stride_load)] = .{ + result[@intFromEnum(Feature.no_optimized_zero_stride_load)] = .{ .llvm_name = "no-optimized-zero-stride-load", .description = "Hasn't optimized (perform fewer memory operations)zero-stride vector load", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_rvc_hints)] = .{ + result[@intFromEnum(Feature.no_rvc_hints)] = .{ .llvm_name = "no-rvc-hints", .description = "Disable RVC Hint Instructions.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.relax)] = .{ + result[@intFromEnum(Feature.relax)] = .{ .llvm_name = "relax", .description = "Enable Linker relaxation.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x1)] = .{ + result[@intFromEnum(Feature.reserve_x1)] = .{ .llvm_name = "reserve-x1", .description = "Reserve X1", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x10)] = .{ + result[@intFromEnum(Feature.reserve_x10)] = .{ .llvm_name = "reserve-x10", .description = "Reserve X10", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x11)] = .{ + result[@intFromEnum(Feature.reserve_x11)] = .{ .llvm_name = "reserve-x11", .description = "Reserve X11", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x12)] = .{ + result[@intFromEnum(Feature.reserve_x12)] = .{ .llvm_name = "reserve-x12", .description = "Reserve X12", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x13)] = .{ + result[@intFromEnum(Feature.reserve_x13)] = .{ .llvm_name = "reserve-x13", .description = "Reserve X13", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x14)] = .{ + result[@intFromEnum(Feature.reserve_x14)] = .{ .llvm_name = "reserve-x14", .description = "Reserve X14", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x15)] = .{ + result[@intFromEnum(Feature.reserve_x15)] = .{ .llvm_name = "reserve-x15", .description = "Reserve X15", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x16)] = .{ + result[@intFromEnum(Feature.reserve_x16)] = .{ .llvm_name = "reserve-x16", .description = "Reserve X16", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x17)] = .{ + result[@intFromEnum(Feature.reserve_x17)] = .{ .llvm_name = "reserve-x17", .description = "Reserve X17", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x18)] = .{ + result[@intFromEnum(Feature.reserve_x18)] = .{ .llvm_name = "reserve-x18", .description = "Reserve X18", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x19)] = .{ + result[@intFromEnum(Feature.reserve_x19)] = .{ .llvm_name = "reserve-x19", .description = "Reserve X19", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x2)] = .{ + result[@intFromEnum(Feature.reserve_x2)] = .{ .llvm_name = "reserve-x2", .description = "Reserve X2", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x20)] = .{ + result[@intFromEnum(Feature.reserve_x20)] = .{ .llvm_name = "reserve-x20", .description = "Reserve X20", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x21)] = .{ + result[@intFromEnum(Feature.reserve_x21)] = .{ .llvm_name = "reserve-x21", .description = "Reserve X21", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x22)] = .{ + result[@intFromEnum(Feature.reserve_x22)] = .{ .llvm_name = "reserve-x22", .description = "Reserve X22", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x23)] = .{ + result[@intFromEnum(Feature.reserve_x23)] = .{ .llvm_name = "reserve-x23", .description = "Reserve X23", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x24)] = .{ + result[@intFromEnum(Feature.reserve_x24)] = .{ .llvm_name = "reserve-x24", .description = "Reserve X24", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x25)] = .{ + result[@intFromEnum(Feature.reserve_x25)] = .{ .llvm_name = "reserve-x25", .description = "Reserve X25", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x26)] = .{ + result[@intFromEnum(Feature.reserve_x26)] = .{ .llvm_name = "reserve-x26", .description = "Reserve X26", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x27)] = .{ + result[@intFromEnum(Feature.reserve_x27)] = .{ .llvm_name = "reserve-x27", .description = "Reserve X27", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x28)] = .{ + result[@intFromEnum(Feature.reserve_x28)] = .{ .llvm_name = "reserve-x28", .description = "Reserve X28", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x29)] = .{ + result[@intFromEnum(Feature.reserve_x29)] = .{ .llvm_name = "reserve-x29", .description = "Reserve X29", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x3)] = .{ + result[@intFromEnum(Feature.reserve_x3)] = .{ .llvm_name = "reserve-x3", .description = "Reserve X3", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x30)] = .{ + result[@intFromEnum(Feature.reserve_x30)] = .{ .llvm_name = "reserve-x30", .description = "Reserve X30", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x31)] = .{ + result[@intFromEnum(Feature.reserve_x31)] = .{ .llvm_name = "reserve-x31", .description = "Reserve X31", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x4)] = .{ + result[@intFromEnum(Feature.reserve_x4)] = .{ .llvm_name = "reserve-x4", .description = "Reserve X4", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x5)] = .{ + result[@intFromEnum(Feature.reserve_x5)] = .{ .llvm_name = "reserve-x5", .description = "Reserve X5", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x6)] = .{ + result[@intFromEnum(Feature.reserve_x6)] = .{ .llvm_name = "reserve-x6", .description = "Reserve X6", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x7)] = .{ + result[@intFromEnum(Feature.reserve_x7)] = .{ .llvm_name = "reserve-x7", .description = "Reserve X7", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x8)] = .{ + result[@intFromEnum(Feature.reserve_x8)] = .{ .llvm_name = "reserve-x8", .description = "Reserve X8", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reserve_x9)] = .{ + result[@intFromEnum(Feature.reserve_x9)] = .{ .llvm_name = "reserve-x9", .description = "Reserve X9", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.save_restore)] = .{ + result[@intFromEnum(Feature.save_restore)] = .{ .llvm_name = "save-restore", .description = "Enable save/restore.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.short_forward_branch_opt)] = .{ + result[@intFromEnum(Feature.short_forward_branch_opt)] = .{ .llvm_name = "short-forward-branch-opt", .description = "Enable short forward branch optimization", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.svinval)] = .{ + result[@intFromEnum(Feature.svinval)] = .{ .llvm_name = "svinval", .description = "'Svinval' (Fine-Grained Address-Translation Cache Invalidation)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.svnapot)] = .{ + result[@intFromEnum(Feature.svnapot)] = .{ .llvm_name = "svnapot", .description = "'Svnapot' (NAPOT Translation Contiguity)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.svpbmt)] = .{ + result[@intFromEnum(Feature.svpbmt)] = .{ .llvm_name = "svpbmt", .description = "'Svpbmt' (Page-Based Memory Types)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tagged_globals)] = .{ + result[@intFromEnum(Feature.tagged_globals)] = .{ .llvm_name = "tagged-globals", .description = "Use an instruction sequence for taking the address of a global that allows a memory tag in the upper address bits", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.unaligned_scalar_mem)] = .{ + result[@intFromEnum(Feature.unaligned_scalar_mem)] = .{ .llvm_name = "unaligned-scalar-mem", .description = "Has reasonably performant unaligned scalar loads and stores", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v)] = .{ + result[@intFromEnum(Feature.v)] = .{ .llvm_name = "v", .description = "'V' (Vector Extension for Application Processors)", .dependencies = featureSet(&[_]Feature{ @@ -437,114 +437,114 @@ pub const all_features = blk: { .zvl128b, }), }; - result[@enumToInt(Feature.xtheadvdot)] = .{ + result[@intFromEnum(Feature.xtheadvdot)] = .{ .llvm_name = "xtheadvdot", .description = "'xtheadvdot' (T-Head Vector Extensions for Dot)", .dependencies = featureSet(&[_]Feature{ .v, }), }; - result[@enumToInt(Feature.xventanacondops)] = .{ + result[@intFromEnum(Feature.xventanacondops)] = .{ .llvm_name = "xventanacondops", .description = "'XVentanaCondOps' (Ventana Conditional Ops)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zba)] = .{ + result[@intFromEnum(Feature.zba)] = .{ .llvm_name = "zba", .description = "'Zba' (Address Generation Instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zbb)] = .{ + result[@intFromEnum(Feature.zbb)] = .{ .llvm_name = "zbb", .description = "'Zbb' (Basic Bit-Manipulation)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zbc)] = .{ + result[@intFromEnum(Feature.zbc)] = .{ .llvm_name = "zbc", .description = "'Zbc' (Carry-Less Multiplication)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zbkb)] = .{ + result[@intFromEnum(Feature.zbkb)] = .{ .llvm_name = "zbkb", .description = "'Zbkb' (Bitmanip instructions for Cryptography)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zbkc)] = .{ + result[@intFromEnum(Feature.zbkc)] = .{ .llvm_name = "zbkc", .description = "'Zbkc' (Carry-less multiply instructions for Cryptography)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zbkx)] = .{ + result[@intFromEnum(Feature.zbkx)] = .{ .llvm_name = "zbkx", .description = "'Zbkx' (Crossbar permutation instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zbs)] = .{ + result[@intFromEnum(Feature.zbs)] = .{ .llvm_name = "zbs", .description = "'Zbs' (Single-Bit Instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zdinx)] = .{ + result[@intFromEnum(Feature.zdinx)] = .{ .llvm_name = "zdinx", .description = "'Zdinx' (Double in Integer)", .dependencies = featureSet(&[_]Feature{ .zfinx, }), }; - result[@enumToInt(Feature.zfh)] = .{ + result[@intFromEnum(Feature.zfh)] = .{ .llvm_name = "zfh", .description = "'Zfh' (Half-Precision Floating-Point)", .dependencies = featureSet(&[_]Feature{ .f, }), }; - result[@enumToInt(Feature.zfhmin)] = .{ + result[@intFromEnum(Feature.zfhmin)] = .{ .llvm_name = "zfhmin", .description = "'Zfhmin' (Half-Precision Floating-Point Minimal)", .dependencies = featureSet(&[_]Feature{ .f, }), }; - result[@enumToInt(Feature.zfinx)] = .{ + result[@intFromEnum(Feature.zfinx)] = .{ .llvm_name = "zfinx", .description = "'Zfinx' (Float in Integer)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zhinx)] = .{ + result[@intFromEnum(Feature.zhinx)] = .{ .llvm_name = "zhinx", .description = "'Zhinx' (Half Float in Integer)", .dependencies = featureSet(&[_]Feature{ .zfinx, }), }; - result[@enumToInt(Feature.zhinxmin)] = .{ + result[@intFromEnum(Feature.zhinxmin)] = .{ .llvm_name = "zhinxmin", .description = "'Zhinxmin' (Half Float in Integer Minimal)", .dependencies = featureSet(&[_]Feature{ .zfinx, }), }; - result[@enumToInt(Feature.zicbom)] = .{ + result[@intFromEnum(Feature.zicbom)] = .{ .llvm_name = "zicbom", .description = "'Zicbom' (Cache-Block Management Instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zicbop)] = .{ + result[@intFromEnum(Feature.zicbop)] = .{ .llvm_name = "zicbop", .description = "'Zicbop' (Cache-Block Prefetch Instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zicboz)] = .{ + result[@intFromEnum(Feature.zicboz)] = .{ .llvm_name = "zicboz", .description = "'Zicboz' (Cache-Block Zero Instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zihintpause)] = .{ + result[@intFromEnum(Feature.zihintpause)] = .{ .llvm_name = "zihintpause", .description = "'zihintpause' (Pause Hint)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zk)] = .{ + result[@intFromEnum(Feature.zk)] = .{ .llvm_name = "zk", .description = "'Zk' (Standard scalar cryptography extension)", .dependencies = featureSet(&[_]Feature{ @@ -553,7 +553,7 @@ pub const all_features = blk: { .zkt, }), }; - result[@enumToInt(Feature.zkn)] = .{ + result[@intFromEnum(Feature.zkn)] = .{ .llvm_name = "zkn", .description = "'Zkn' (NIST Algorithm Suite)", .dependencies = featureSet(&[_]Feature{ @@ -565,27 +565,27 @@ pub const all_features = blk: { .zknh, }), }; - result[@enumToInt(Feature.zknd)] = .{ + result[@intFromEnum(Feature.zknd)] = .{ .llvm_name = "zknd", .description = "'Zknd' (NIST Suite: AES Decryption)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zkne)] = .{ + result[@intFromEnum(Feature.zkne)] = .{ .llvm_name = "zkne", .description = "'Zkne' (NIST Suite: AES Encryption)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zknh)] = .{ + result[@intFromEnum(Feature.zknh)] = .{ .llvm_name = "zknh", .description = "'Zknh' (NIST Suite: Hash Function Instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zkr)] = .{ + result[@intFromEnum(Feature.zkr)] = .{ .llvm_name = "zkr", .description = "'Zkr' (Entropy Source Extension)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zks)] = .{ + result[@intFromEnum(Feature.zks)] = .{ .llvm_name = "zks", .description = "'Zks' (ShangMi Algorithm Suite)", .dependencies = featureSet(&[_]Feature{ @@ -596,48 +596,48 @@ pub const all_features = blk: { .zksh, }), }; - result[@enumToInt(Feature.zksed)] = .{ + result[@intFromEnum(Feature.zksed)] = .{ .llvm_name = "zksed", .description = "'Zksed' (ShangMi Suite: SM4 Block Cipher Instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zksh)] = .{ + result[@intFromEnum(Feature.zksh)] = .{ .llvm_name = "zksh", .description = "'Zksh' (ShangMi Suite: SM3 Hash Function Instructions)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zkt)] = .{ + result[@intFromEnum(Feature.zkt)] = .{ .llvm_name = "zkt", .description = "'Zkt' (Data Independent Execution Latency)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zmmul)] = .{ + result[@intFromEnum(Feature.zmmul)] = .{ .llvm_name = "zmmul", .description = "'Zmmul' (Integer Multiplication)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zve32f)] = .{ + result[@intFromEnum(Feature.zve32f)] = .{ .llvm_name = "zve32f", .description = "'Zve32f' (Vector Extensions for Embedded Processors with maximal 32 EEW and F extension)", .dependencies = featureSet(&[_]Feature{ .zve32x, }), }; - result[@enumToInt(Feature.zve32x)] = .{ + result[@intFromEnum(Feature.zve32x)] = .{ .llvm_name = "zve32x", .description = "'Zve32x' (Vector Extensions for Embedded Processors with maximal 32 EEW)", .dependencies = featureSet(&[_]Feature{ .zvl32b, }), }; - result[@enumToInt(Feature.zve64d)] = .{ + result[@intFromEnum(Feature.zve64d)] = .{ .llvm_name = "zve64d", .description = "'Zve64d' (Vector Extensions for Embedded Processors with maximal 64 EEW, F and D extension)", .dependencies = featureSet(&[_]Feature{ .zve64f, }), }; - result[@enumToInt(Feature.zve64f)] = .{ + result[@intFromEnum(Feature.zve64f)] = .{ .llvm_name = "zve64f", .description = "'Zve64f' (Vector Extensions for Embedded Processors with maximal 64 EEW and F extension)", .dependencies = featureSet(&[_]Feature{ @@ -645,7 +645,7 @@ pub const all_features = blk: { .zve64x, }), }; - result[@enumToInt(Feature.zve64x)] = .{ + result[@intFromEnum(Feature.zve64x)] = .{ .llvm_name = "zve64x", .description = "'Zve64x' (Vector Extensions for Embedded Processors with maximal 64 EEW)", .dependencies = featureSet(&[_]Feature{ @@ -653,82 +653,82 @@ pub const all_features = blk: { .zvl64b, }), }; - result[@enumToInt(Feature.zvl1024b)] = .{ + result[@intFromEnum(Feature.zvl1024b)] = .{ .llvm_name = "zvl1024b", .description = "'Zvl' (Minimum Vector Length) 1024", .dependencies = featureSet(&[_]Feature{ .zvl512b, }), }; - result[@enumToInt(Feature.zvl128b)] = .{ + result[@intFromEnum(Feature.zvl128b)] = .{ .llvm_name = "zvl128b", .description = "'Zvl' (Minimum Vector Length) 128", .dependencies = featureSet(&[_]Feature{ .zvl64b, }), }; - result[@enumToInt(Feature.zvl16384b)] = .{ + result[@intFromEnum(Feature.zvl16384b)] = .{ .llvm_name = "zvl16384b", .description = "'Zvl' (Minimum Vector Length) 16384", .dependencies = featureSet(&[_]Feature{ .zvl8192b, }), }; - result[@enumToInt(Feature.zvl2048b)] = .{ + result[@intFromEnum(Feature.zvl2048b)] = .{ .llvm_name = "zvl2048b", .description = "'Zvl' (Minimum Vector Length) 2048", .dependencies = featureSet(&[_]Feature{ .zvl1024b, }), }; - result[@enumToInt(Feature.zvl256b)] = .{ + result[@intFromEnum(Feature.zvl256b)] = .{ .llvm_name = "zvl256b", .description = "'Zvl' (Minimum Vector Length) 256", .dependencies = featureSet(&[_]Feature{ .zvl128b, }), }; - result[@enumToInt(Feature.zvl32768b)] = .{ + result[@intFromEnum(Feature.zvl32768b)] = .{ .llvm_name = "zvl32768b", .description = "'Zvl' (Minimum Vector Length) 32768", .dependencies = featureSet(&[_]Feature{ .zvl16384b, }), }; - result[@enumToInt(Feature.zvl32b)] = .{ + result[@intFromEnum(Feature.zvl32b)] = .{ .llvm_name = "zvl32b", .description = "'Zvl' (Minimum Vector Length) 32", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.zvl4096b)] = .{ + result[@intFromEnum(Feature.zvl4096b)] = .{ .llvm_name = "zvl4096b", .description = "'Zvl' (Minimum Vector Length) 4096", .dependencies = featureSet(&[_]Feature{ .zvl2048b, }), }; - result[@enumToInt(Feature.zvl512b)] = .{ + result[@intFromEnum(Feature.zvl512b)] = .{ .llvm_name = "zvl512b", .description = "'Zvl' (Minimum Vector Length) 512", .dependencies = featureSet(&[_]Feature{ .zvl256b, }), }; - result[@enumToInt(Feature.zvl64b)] = .{ + result[@intFromEnum(Feature.zvl64b)] = .{ .llvm_name = "zvl64b", .description = "'Zvl' (Minimum Vector Length) 64", .dependencies = featureSet(&[_]Feature{ .zvl32b, }), }; - result[@enumToInt(Feature.zvl65536b)] = .{ + result[@intFromEnum(Feature.zvl65536b)] = .{ .llvm_name = "zvl65536b", .description = "'Zvl' (Minimum Vector Length) 65536", .dependencies = featureSet(&[_]Feature{ .zvl32768b, }), }; - result[@enumToInt(Feature.zvl8192b)] = .{ + result[@intFromEnum(Feature.zvl8192b)] = .{ .llvm_name = "zvl8192b", .description = "'Zvl' (Minimum Vector Length) 8192", .dependencies = featureSet(&[_]Feature{ diff --git a/lib/std/target/s390x.zig b/lib/std/target/s390x.zig index 546cbadfbdf9..b64284725833 100644 --- a/lib/std/target/s390x.zig +++ b/lib/std/target/s390x.zig @@ -57,207 +57,207 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.bear_enhancement)] = .{ + result[@intFromEnum(Feature.bear_enhancement)] = .{ .llvm_name = "bear-enhancement", .description = "Assume that the BEAR-enhancement facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.deflate_conversion)] = .{ + result[@intFromEnum(Feature.deflate_conversion)] = .{ .llvm_name = "deflate-conversion", .description = "Assume that the deflate-conversion facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dfp_packed_conversion)] = .{ + result[@intFromEnum(Feature.dfp_packed_conversion)] = .{ .llvm_name = "dfp-packed-conversion", .description = "Assume that the DFP packed-conversion facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.dfp_zoned_conversion)] = .{ + result[@intFromEnum(Feature.dfp_zoned_conversion)] = .{ .llvm_name = "dfp-zoned-conversion", .description = "Assume that the DFP zoned-conversion facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.distinct_ops)] = .{ + result[@intFromEnum(Feature.distinct_ops)] = .{ .llvm_name = "distinct-ops", .description = "Assume that the distinct-operands facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.enhanced_dat_2)] = .{ + result[@intFromEnum(Feature.enhanced_dat_2)] = .{ .llvm_name = "enhanced-dat-2", .description = "Assume that the enhanced-DAT facility 2 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.enhanced_sort)] = .{ + result[@intFromEnum(Feature.enhanced_sort)] = .{ .llvm_name = "enhanced-sort", .description = "Assume that the enhanced-sort facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.execution_hint)] = .{ + result[@intFromEnum(Feature.execution_hint)] = .{ .llvm_name = "execution-hint", .description = "Assume that the execution-hint facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_serialization)] = .{ + result[@intFromEnum(Feature.fast_serialization)] = .{ .llvm_name = "fast-serialization", .description = "Assume that the fast-serialization facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fp_extension)] = .{ + result[@intFromEnum(Feature.fp_extension)] = .{ .llvm_name = "fp-extension", .description = "Assume that the floating-point extension facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.guarded_storage)] = .{ + result[@intFromEnum(Feature.guarded_storage)] = .{ .llvm_name = "guarded-storage", .description = "Assume that the guarded-storage facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.high_word)] = .{ + result[@intFromEnum(Feature.high_word)] = .{ .llvm_name = "high-word", .description = "Assume that the high-word facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.insert_reference_bits_multiple)] = .{ + result[@intFromEnum(Feature.insert_reference_bits_multiple)] = .{ .llvm_name = "insert-reference-bits-multiple", .description = "Assume that the insert-reference-bits-multiple facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.interlocked_access1)] = .{ + result[@intFromEnum(Feature.interlocked_access1)] = .{ .llvm_name = "interlocked-access1", .description = "Assume that interlocked-access facility 1 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.load_and_trap)] = .{ + result[@intFromEnum(Feature.load_and_trap)] = .{ .llvm_name = "load-and-trap", .description = "Assume that the load-and-trap facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.load_and_zero_rightmost_byte)] = .{ + result[@intFromEnum(Feature.load_and_zero_rightmost_byte)] = .{ .llvm_name = "load-and-zero-rightmost-byte", .description = "Assume that the load-and-zero-rightmost-byte facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.load_store_on_cond)] = .{ + result[@intFromEnum(Feature.load_store_on_cond)] = .{ .llvm_name = "load-store-on-cond", .description = "Assume that the load/store-on-condition facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.load_store_on_cond_2)] = .{ + result[@intFromEnum(Feature.load_store_on_cond_2)] = .{ .llvm_name = "load-store-on-cond-2", .description = "Assume that the load/store-on-condition facility 2 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.message_security_assist_extension3)] = .{ + result[@intFromEnum(Feature.message_security_assist_extension3)] = .{ .llvm_name = "message-security-assist-extension3", .description = "Assume that the message-security-assist extension facility 3 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.message_security_assist_extension4)] = .{ + result[@intFromEnum(Feature.message_security_assist_extension4)] = .{ .llvm_name = "message-security-assist-extension4", .description = "Assume that the message-security-assist extension facility 4 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.message_security_assist_extension5)] = .{ + result[@intFromEnum(Feature.message_security_assist_extension5)] = .{ .llvm_name = "message-security-assist-extension5", .description = "Assume that the message-security-assist extension facility 5 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.message_security_assist_extension7)] = .{ + result[@intFromEnum(Feature.message_security_assist_extension7)] = .{ .llvm_name = "message-security-assist-extension7", .description = "Assume that the message-security-assist extension facility 7 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.message_security_assist_extension8)] = .{ + result[@intFromEnum(Feature.message_security_assist_extension8)] = .{ .llvm_name = "message-security-assist-extension8", .description = "Assume that the message-security-assist extension facility 8 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.message_security_assist_extension9)] = .{ + result[@intFromEnum(Feature.message_security_assist_extension9)] = .{ .llvm_name = "message-security-assist-extension9", .description = "Assume that the message-security-assist extension facility 9 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.miscellaneous_extensions)] = .{ + result[@intFromEnum(Feature.miscellaneous_extensions)] = .{ .llvm_name = "miscellaneous-extensions", .description = "Assume that the miscellaneous-extensions facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.miscellaneous_extensions_2)] = .{ + result[@intFromEnum(Feature.miscellaneous_extensions_2)] = .{ .llvm_name = "miscellaneous-extensions-2", .description = "Assume that the miscellaneous-extensions facility 2 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.miscellaneous_extensions_3)] = .{ + result[@intFromEnum(Feature.miscellaneous_extensions_3)] = .{ .llvm_name = "miscellaneous-extensions-3", .description = "Assume that the miscellaneous-extensions facility 3 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nnp_assist)] = .{ + result[@intFromEnum(Feature.nnp_assist)] = .{ .llvm_name = "nnp-assist", .description = "Assume that the NNP-assist facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.population_count)] = .{ + result[@intFromEnum(Feature.population_count)] = .{ .llvm_name = "population-count", .description = "Assume that the population-count facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.processor_activity_instrumentation)] = .{ + result[@intFromEnum(Feature.processor_activity_instrumentation)] = .{ .llvm_name = "processor-activity-instrumentation", .description = "Assume that the processor-activity-instrumentation facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.processor_assist)] = .{ + result[@intFromEnum(Feature.processor_assist)] = .{ .llvm_name = "processor-assist", .description = "Assume that the processor-assist facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reset_dat_protection)] = .{ + result[@intFromEnum(Feature.reset_dat_protection)] = .{ .llvm_name = "reset-dat-protection", .description = "Assume that the reset-DAT-protection facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reset_reference_bits_multiple)] = .{ + result[@intFromEnum(Feature.reset_reference_bits_multiple)] = .{ .llvm_name = "reset-reference-bits-multiple", .description = "Assume that the reset-reference-bits-multiple facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.soft_float)] = .{ + result[@intFromEnum(Feature.soft_float)] = .{ .llvm_name = "soft-float", .description = "Use software emulation for floating point", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.transactional_execution)] = .{ + result[@intFromEnum(Feature.transactional_execution)] = .{ .llvm_name = "transactional-execution", .description = "Assume that the transactional-execution facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vector)] = .{ + result[@intFromEnum(Feature.vector)] = .{ .llvm_name = "vector", .description = "Assume that the vectory facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vector_enhancements_1)] = .{ + result[@intFromEnum(Feature.vector_enhancements_1)] = .{ .llvm_name = "vector-enhancements-1", .description = "Assume that the vector enhancements facility 1 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vector_enhancements_2)] = .{ + result[@intFromEnum(Feature.vector_enhancements_2)] = .{ .llvm_name = "vector-enhancements-2", .description = "Assume that the vector enhancements facility 2 is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vector_packed_decimal)] = .{ + result[@intFromEnum(Feature.vector_packed_decimal)] = .{ .llvm_name = "vector-packed-decimal", .description = "Assume that the vector packed decimal facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vector_packed_decimal_enhancement)] = .{ + result[@intFromEnum(Feature.vector_packed_decimal_enhancement)] = .{ .llvm_name = "vector-packed-decimal-enhancement", .description = "Assume that the vector packed decimal enhancement facility is installed", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vector_packed_decimal_enhancement_2)] = .{ + result[@intFromEnum(Feature.vector_packed_decimal_enhancement_2)] = .{ .llvm_name = "vector-packed-decimal-enhancement-2", .description = "Assume that the vector packed decimal enhancement facility 2 is installed", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/sparc.zig b/lib/std/target/sparc.zig index 7deb01db24cb..87bd95697c20 100644 --- a/lib/std/target/sparc.zig +++ b/lib/std/target/sparc.zig @@ -35,97 +35,97 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.deprecated_v8)] = .{ + result[@intFromEnum(Feature.deprecated_v8)] = .{ .llvm_name = "deprecated-v8", .description = "Enable deprecated V8 instructions in V9 mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.detectroundchange)] = .{ + result[@intFromEnum(Feature.detectroundchange)] = .{ .llvm_name = "detectroundchange", .description = "LEON3 erratum detection: Detects any rounding mode change request: use only the round-to-nearest rounding mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fixallfdivsqrt)] = .{ + result[@intFromEnum(Feature.fixallfdivsqrt)] = .{ .llvm_name = "fixallfdivsqrt", .description = "LEON erratum fix: Fix FDIVS/FDIVD/FSQRTS/FSQRTD instructions with NOPs and floating-point store", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hard_quad_float)] = .{ + result[@intFromEnum(Feature.hard_quad_float)] = .{ .llvm_name = "hard-quad-float", .description = "Enable quad-word floating point instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hasleoncasa)] = .{ + result[@intFromEnum(Feature.hasleoncasa)] = .{ .llvm_name = "hasleoncasa", .description = "Enable CASA instruction for LEON3 and LEON4 processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hasumacsmac)] = .{ + result[@intFromEnum(Feature.hasumacsmac)] = .{ .llvm_name = "hasumacsmac", .description = "Enable UMAC and SMAC for LEON3 and LEON4 processors", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.insertnopload)] = .{ + result[@intFromEnum(Feature.insertnopload)] = .{ .llvm_name = "insertnopload", .description = "LEON3 erratum fix: Insert a NOP instruction after every single-cycle load instruction when the next instruction is another load/store instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.leon)] = .{ + result[@intFromEnum(Feature.leon)] = .{ .llvm_name = "leon", .description = "Enable LEON extensions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.leoncyclecounter)] = .{ + result[@intFromEnum(Feature.leoncyclecounter)] = .{ .llvm_name = "leoncyclecounter", .description = "Use the Leon cycle counter register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.leonpwrpsr)] = .{ + result[@intFromEnum(Feature.leonpwrpsr)] = .{ .llvm_name = "leonpwrpsr", .description = "Enable the PWRPSR instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_fmuls)] = .{ + result[@intFromEnum(Feature.no_fmuls)] = .{ .llvm_name = "no-fmuls", .description = "Disable the fmuls instruction.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.no_fsmuld)] = .{ + result[@intFromEnum(Feature.no_fsmuld)] = .{ .llvm_name = "no-fsmuld", .description = "Disable the fsmuld instruction.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.popc)] = .{ + result[@intFromEnum(Feature.popc)] = .{ .llvm_name = "popc", .description = "Use the popc (population count) instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.soft_float)] = .{ + result[@intFromEnum(Feature.soft_float)] = .{ .llvm_name = "soft-float", .description = "Use software emulation for floating point", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.soft_mul_div)] = .{ + result[@intFromEnum(Feature.soft_mul_div)] = .{ .llvm_name = "soft-mul-div", .description = "Use software emulation for integer multiply and divide", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v9)] = .{ + result[@intFromEnum(Feature.v9)] = .{ .llvm_name = "v9", .description = "Enable SPARC-V9 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vis)] = .{ + result[@intFromEnum(Feature.vis)] = .{ .llvm_name = "vis", .description = "Enable UltraSPARC Visual Instruction Set extensions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vis2)] = .{ + result[@intFromEnum(Feature.vis2)] = .{ .llvm_name = "vis2", .description = "Enable Visual Instruction Set extensions II", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vis3)] = .{ + result[@intFromEnum(Feature.vis3)] = .{ .llvm_name = "vis3", .description = "Enable Visual Instruction Set extensions III", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/spirv.zig b/lib/std/target/spirv.zig index b0f5a1946117..9d79aff2212c 100644 --- a/lib/std/target/spirv.zig +++ b/lib/std/target/spirv.zig @@ -304,803 +304,803 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.v1_1)] = .{ + result[@intFromEnum(Feature.v1_1)] = .{ .llvm_name = null, .description = "SPIR-V version 1.1", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.v1_2)] = .{ + result[@intFromEnum(Feature.v1_2)] = .{ .llvm_name = null, .description = "SPIR-V version 1.2", .dependencies = featureSet(&[_]Feature{ .v1_1, }), }; - result[@enumToInt(Feature.v1_3)] = .{ + result[@intFromEnum(Feature.v1_3)] = .{ .llvm_name = null, .description = "SPIR-V version 1.3", .dependencies = featureSet(&[_]Feature{ .v1_2, }), }; - result[@enumToInt(Feature.v1_4)] = .{ + result[@intFromEnum(Feature.v1_4)] = .{ .llvm_name = null, .description = "SPIR-V version 1.4", .dependencies = featureSet(&[_]Feature{ .v1_3, }), }; - result[@enumToInt(Feature.v1_5)] = .{ + result[@intFromEnum(Feature.v1_5)] = .{ .llvm_name = null, .description = "SPIR-V version 1.5", .dependencies = featureSet(&[_]Feature{ .v1_4, }), }; - result[@enumToInt(Feature.SPV_AMD_shader_fragment_mask)] = .{ + result[@intFromEnum(Feature.SPV_AMD_shader_fragment_mask)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_AMD_shader_fragment_mask", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_AMD_gpu_shader_int16)] = .{ + result[@intFromEnum(Feature.SPV_AMD_gpu_shader_int16)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_AMD_gpu_shader_int16", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_AMD_gpu_shader_half_float)] = .{ + result[@intFromEnum(Feature.SPV_AMD_gpu_shader_half_float)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_AMD_gpu_shader_half_float", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_AMD_texture_gather_bias_lod)] = .{ + result[@intFromEnum(Feature.SPV_AMD_texture_gather_bias_lod)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_AMD_texture_gather_bias_lod", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_AMD_shader_ballot)] = .{ + result[@intFromEnum(Feature.SPV_AMD_shader_ballot)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_AMD_shader_ballot", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_AMD_gcn_shader)] = .{ + result[@intFromEnum(Feature.SPV_AMD_gcn_shader)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_AMD_gcn_shader", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_AMD_shader_image_load_store_lod)] = .{ + result[@intFromEnum(Feature.SPV_AMD_shader_image_load_store_lod)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_AMD_shader_image_load_store_lod", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_AMD_shader_explicit_vertex_parameter)] = .{ + result[@intFromEnum(Feature.SPV_AMD_shader_explicit_vertex_parameter)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_AMD_shader_explicit_vertex_parameter", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_AMD_shader_trinary_minmax)] = .{ + result[@intFromEnum(Feature.SPV_AMD_shader_trinary_minmax)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_AMD_shader_trinary_minmax", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_AMD_gpu_shader_half_float_fetch)] = .{ + result[@intFromEnum(Feature.SPV_AMD_gpu_shader_half_float_fetch)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_AMD_gpu_shader_half_float_fetch", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_GOOGLE_hlsl_functionality1)] = .{ + result[@intFromEnum(Feature.SPV_GOOGLE_hlsl_functionality1)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_GOOGLE_hlsl_functionality1", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_GOOGLE_user_type)] = .{ + result[@intFromEnum(Feature.SPV_GOOGLE_user_type)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_GOOGLE_user_type", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_GOOGLE_decorate_string)] = .{ + result[@intFromEnum(Feature.SPV_GOOGLE_decorate_string)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_GOOGLE_decorate_string", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_EXT_demote_to_helper_invocation)] = .{ + result[@intFromEnum(Feature.SPV_EXT_demote_to_helper_invocation)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_EXT_demote_to_helper_invocation", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_EXT_descriptor_indexing)] = .{ + result[@intFromEnum(Feature.SPV_EXT_descriptor_indexing)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_EXT_descriptor_indexing", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_EXT_fragment_fully_covered)] = .{ + result[@intFromEnum(Feature.SPV_EXT_fragment_fully_covered)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_EXT_fragment_fully_covered", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_EXT_shader_stencil_export)] = .{ + result[@intFromEnum(Feature.SPV_EXT_shader_stencil_export)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_EXT_shader_stencil_export", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_EXT_physical_storage_buffer)] = .{ + result[@intFromEnum(Feature.SPV_EXT_physical_storage_buffer)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_EXT_physical_storage_buffer", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_EXT_shader_atomic_float_add)] = .{ + result[@intFromEnum(Feature.SPV_EXT_shader_atomic_float_add)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_EXT_shader_atomic_float_add", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_EXT_shader_atomic_float_min_max)] = .{ + result[@intFromEnum(Feature.SPV_EXT_shader_atomic_float_min_max)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_EXT_shader_atomic_float_min_max", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_EXT_shader_image_int64)] = .{ + result[@intFromEnum(Feature.SPV_EXT_shader_image_int64)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_EXT_shader_image_int64", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_EXT_fragment_shader_interlock)] = .{ + result[@intFromEnum(Feature.SPV_EXT_fragment_shader_interlock)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_EXT_fragment_shader_interlock", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_EXT_fragment_invocation_density)] = .{ + result[@intFromEnum(Feature.SPV_EXT_fragment_invocation_density)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_EXT_fragment_invocation_density", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_EXT_shader_viewport_index_layer)] = .{ + result[@intFromEnum(Feature.SPV_EXT_shader_viewport_index_layer)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_EXT_shader_viewport_index_layer", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_loop_fuse)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_loop_fuse)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_loop_fuse", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_fpga_dsp_control)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_fpga_dsp_control)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_fpga_dsp_control", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_fpga_reg)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_fpga_reg)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_fpga_reg", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_fpga_memory_accesses)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_fpga_memory_accesses)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_fpga_memory_accesses", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_fpga_loop_controls)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_fpga_loop_controls)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_fpga_loop_controls", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_io_pipes)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_io_pipes)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_io_pipes", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_unstructured_loop_controls)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_unstructured_loop_controls)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_unstructured_loop_controls", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_blocking_pipes)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_blocking_pipes)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_blocking_pipes", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_device_side_avc_motion_estimation)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_device_side_avc_motion_estimation)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_device_side_avc_motion_estimation", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_fpga_memory_attributes)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_fpga_memory_attributes)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_fpga_memory_attributes", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_fp_fast_math_mode)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_fp_fast_math_mode)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_fp_fast_math_mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_media_block_io)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_media_block_io)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_media_block_io", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_shader_integer_functions2)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_shader_integer_functions2)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_shader_integer_functions2", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_subgroups)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_subgroups)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_subgroups", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_fpga_cluster_attributes)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_fpga_cluster_attributes)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_fpga_cluster_attributes", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_kernel_attributes)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_kernel_attributes)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_kernel_attributes", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_INTEL_arbitrary_precision_integers)] = .{ + result[@intFromEnum(Feature.SPV_INTEL_arbitrary_precision_integers)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_INTEL_arbitrary_precision_integers", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_8bit_storage)] = .{ + result[@intFromEnum(Feature.SPV_KHR_8bit_storage)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_8bit_storage", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_shader_clock)] = .{ + result[@intFromEnum(Feature.SPV_KHR_shader_clock)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_shader_clock", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_device_group)] = .{ + result[@intFromEnum(Feature.SPV_KHR_device_group)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_device_group", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_16bit_storage)] = .{ + result[@intFromEnum(Feature.SPV_KHR_16bit_storage)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_16bit_storage", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_variable_pointers)] = .{ + result[@intFromEnum(Feature.SPV_KHR_variable_pointers)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_variable_pointers", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_no_integer_wrap_decoration)] = .{ + result[@intFromEnum(Feature.SPV_KHR_no_integer_wrap_decoration)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_no_integer_wrap_decoration", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_subgroup_vote)] = .{ + result[@intFromEnum(Feature.SPV_KHR_subgroup_vote)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_subgroup_vote", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_multiview)] = .{ + result[@intFromEnum(Feature.SPV_KHR_multiview)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_multiview", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_shader_ballot)] = .{ + result[@intFromEnum(Feature.SPV_KHR_shader_ballot)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_shader_ballot", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_vulkan_memory_model)] = .{ + result[@intFromEnum(Feature.SPV_KHR_vulkan_memory_model)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_vulkan_memory_model", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_physical_storage_buffer)] = .{ + result[@intFromEnum(Feature.SPV_KHR_physical_storage_buffer)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_physical_storage_buffer", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_workgroup_memory_explicit_layout)] = .{ + result[@intFromEnum(Feature.SPV_KHR_workgroup_memory_explicit_layout)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_workgroup_memory_explicit_layout", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_fragment_shading_rate)] = .{ + result[@intFromEnum(Feature.SPV_KHR_fragment_shading_rate)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_fragment_shading_rate", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_shader_atomic_counter_ops)] = .{ + result[@intFromEnum(Feature.SPV_KHR_shader_atomic_counter_ops)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_shader_atomic_counter_ops", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_shader_draw_parameters)] = .{ + result[@intFromEnum(Feature.SPV_KHR_shader_draw_parameters)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_shader_draw_parameters", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_storage_buffer_storage_class)] = .{ + result[@intFromEnum(Feature.SPV_KHR_storage_buffer_storage_class)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_storage_buffer_storage_class", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_linkonce_odr)] = .{ + result[@intFromEnum(Feature.SPV_KHR_linkonce_odr)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_linkonce_odr", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_terminate_invocation)] = .{ + result[@intFromEnum(Feature.SPV_KHR_terminate_invocation)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_terminate_invocation", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_non_semantic_info)] = .{ + result[@intFromEnum(Feature.SPV_KHR_non_semantic_info)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_non_semantic_info", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_post_depth_coverage)] = .{ + result[@intFromEnum(Feature.SPV_KHR_post_depth_coverage)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_post_depth_coverage", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_expect_assume)] = .{ + result[@intFromEnum(Feature.SPV_KHR_expect_assume)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_expect_assume", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_ray_tracing)] = .{ + result[@intFromEnum(Feature.SPV_KHR_ray_tracing)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_ray_tracing", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_ray_query)] = .{ + result[@intFromEnum(Feature.SPV_KHR_ray_query)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_ray_query", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_KHR_float_controls)] = .{ + result[@intFromEnum(Feature.SPV_KHR_float_controls)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_KHR_float_controls", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_viewport_array2)] = .{ + result[@intFromEnum(Feature.SPV_NV_viewport_array2)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_viewport_array2", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_shader_subgroup_partitioned)] = .{ + result[@intFromEnum(Feature.SPV_NV_shader_subgroup_partitioned)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_shader_subgroup_partitioned", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NVX_multiview_per_view_attributes)] = .{ + result[@intFromEnum(Feature.SPV_NVX_multiview_per_view_attributes)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NVX_multiview_per_view_attributes", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_ray_tracing)] = .{ + result[@intFromEnum(Feature.SPV_NV_ray_tracing)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_ray_tracing", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_shader_image_footprint)] = .{ + result[@intFromEnum(Feature.SPV_NV_shader_image_footprint)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_shader_image_footprint", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_shading_rate)] = .{ + result[@intFromEnum(Feature.SPV_NV_shading_rate)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_shading_rate", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_stereo_view_rendering)] = .{ + result[@intFromEnum(Feature.SPV_NV_stereo_view_rendering)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_stereo_view_rendering", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_compute_shader_derivatives)] = .{ + result[@intFromEnum(Feature.SPV_NV_compute_shader_derivatives)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_compute_shader_derivatives", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_shader_sm_builtins)] = .{ + result[@intFromEnum(Feature.SPV_NV_shader_sm_builtins)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_shader_sm_builtins", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_mesh_shader)] = .{ + result[@intFromEnum(Feature.SPV_NV_mesh_shader)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_mesh_shader", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_geometry_shader_passthrough)] = .{ + result[@intFromEnum(Feature.SPV_NV_geometry_shader_passthrough)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_geometry_shader_passthrough", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_fragment_shader_barycentric)] = .{ + result[@intFromEnum(Feature.SPV_NV_fragment_shader_barycentric)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_fragment_shader_barycentric", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_cooperative_matrix)] = .{ + result[@intFromEnum(Feature.SPV_NV_cooperative_matrix)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_cooperative_matrix", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SPV_NV_sample_mask_override_coverage)] = .{ + result[@intFromEnum(Feature.SPV_NV_sample_mask_override_coverage)] = .{ .llvm_name = null, .description = "SPIR-V extension SPV_NV_sample_mask_override_coverage", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.Matrix)] = .{ + result[@intFromEnum(Feature.Matrix)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Matrix", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.Shader)] = .{ + result[@intFromEnum(Feature.Shader)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Shader", .dependencies = featureSet(&[_]Feature{ .Matrix, }), }; - result[@enumToInt(Feature.Geometry)] = .{ + result[@intFromEnum(Feature.Geometry)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Geometry", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.Tessellation)] = .{ + result[@intFromEnum(Feature.Tessellation)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Tessellation", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.Addresses)] = .{ + result[@intFromEnum(Feature.Addresses)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Addresses", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.Linkage)] = .{ + result[@intFromEnum(Feature.Linkage)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Linkage", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.Kernel)] = .{ + result[@intFromEnum(Feature.Kernel)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Kernel", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.Vector16)] = .{ + result[@intFromEnum(Feature.Vector16)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Vector16", .dependencies = featureSet(&[_]Feature{ .Kernel, }), }; - result[@enumToInt(Feature.Float16Buffer)] = .{ + result[@intFromEnum(Feature.Float16Buffer)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Float16Buffer", .dependencies = featureSet(&[_]Feature{ .Kernel, }), }; - result[@enumToInt(Feature.Float16)] = .{ + result[@intFromEnum(Feature.Float16)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Float16", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.Float64)] = .{ + result[@intFromEnum(Feature.Float64)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Float64", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.Int64)] = .{ + result[@intFromEnum(Feature.Int64)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Int64", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.Int64Atomics)] = .{ + result[@intFromEnum(Feature.Int64Atomics)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Int64Atomics", .dependencies = featureSet(&[_]Feature{ .Int64, }), }; - result[@enumToInt(Feature.ImageBasic)] = .{ + result[@intFromEnum(Feature.ImageBasic)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ImageBasic", .dependencies = featureSet(&[_]Feature{ .Kernel, }), }; - result[@enumToInt(Feature.ImageReadWrite)] = .{ + result[@intFromEnum(Feature.ImageReadWrite)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ImageReadWrite", .dependencies = featureSet(&[_]Feature{ .ImageBasic, }), }; - result[@enumToInt(Feature.ImageMipmap)] = .{ + result[@intFromEnum(Feature.ImageMipmap)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ImageMipmap", .dependencies = featureSet(&[_]Feature{ .ImageBasic, }), }; - result[@enumToInt(Feature.Pipes)] = .{ + result[@intFromEnum(Feature.Pipes)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Pipes", .dependencies = featureSet(&[_]Feature{ .Kernel, }), }; - result[@enumToInt(Feature.Groups)] = .{ + result[@intFromEnum(Feature.Groups)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Groups", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.DeviceEnqueue)] = .{ + result[@intFromEnum(Feature.DeviceEnqueue)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability DeviceEnqueue", .dependencies = featureSet(&[_]Feature{ .Kernel, }), }; - result[@enumToInt(Feature.LiteralSampler)] = .{ + result[@intFromEnum(Feature.LiteralSampler)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability LiteralSampler", .dependencies = featureSet(&[_]Feature{ .Kernel, }), }; - result[@enumToInt(Feature.AtomicStorage)] = .{ + result[@intFromEnum(Feature.AtomicStorage)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability AtomicStorage", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.Int16)] = .{ + result[@intFromEnum(Feature.Int16)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Int16", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.TessellationPointSize)] = .{ + result[@intFromEnum(Feature.TessellationPointSize)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability TessellationPointSize", .dependencies = featureSet(&[_]Feature{ .Tessellation, }), }; - result[@enumToInt(Feature.GeometryPointSize)] = .{ + result[@intFromEnum(Feature.GeometryPointSize)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GeometryPointSize", .dependencies = featureSet(&[_]Feature{ .Geometry, }), }; - result[@enumToInt(Feature.ImageGatherExtended)] = .{ + result[@intFromEnum(Feature.ImageGatherExtended)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ImageGatherExtended", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.StorageImageMultisample)] = .{ + result[@intFromEnum(Feature.StorageImageMultisample)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageImageMultisample", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.UniformBufferArrayDynamicIndexing)] = .{ + result[@intFromEnum(Feature.UniformBufferArrayDynamicIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability UniformBufferArrayDynamicIndexing", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.SampledImageArrayDynamicIndexing)] = .{ + result[@intFromEnum(Feature.SampledImageArrayDynamicIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SampledImageArrayDynamicIndexing", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.StorageBufferArrayDynamicIndexing)] = .{ + result[@intFromEnum(Feature.StorageBufferArrayDynamicIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageBufferArrayDynamicIndexing", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.StorageImageArrayDynamicIndexing)] = .{ + result[@intFromEnum(Feature.StorageImageArrayDynamicIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageImageArrayDynamicIndexing", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.ClipDistance)] = .{ + result[@intFromEnum(Feature.ClipDistance)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ClipDistance", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.CullDistance)] = .{ + result[@intFromEnum(Feature.CullDistance)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability CullDistance", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.ImageCubeArray)] = .{ + result[@intFromEnum(Feature.ImageCubeArray)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ImageCubeArray", .dependencies = featureSet(&[_]Feature{ .SampledCubeArray, }), }; - result[@enumToInt(Feature.SampleRateShading)] = .{ + result[@intFromEnum(Feature.SampleRateShading)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SampleRateShading", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.ImageRect)] = .{ + result[@intFromEnum(Feature.ImageRect)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ImageRect", .dependencies = featureSet(&[_]Feature{ .SampledRect, }), }; - result[@enumToInt(Feature.SampledRect)] = .{ + result[@intFromEnum(Feature.SampledRect)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SampledRect", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.GenericPointer)] = .{ + result[@intFromEnum(Feature.GenericPointer)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GenericPointer", .dependencies = featureSet(&[_]Feature{ .Addresses, }), }; - result[@enumToInt(Feature.Int8)] = .{ + result[@intFromEnum(Feature.Int8)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Int8", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.InputAttachment)] = .{ + result[@intFromEnum(Feature.InputAttachment)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability InputAttachment", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.SparseResidency)] = .{ + result[@intFromEnum(Feature.SparseResidency)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SparseResidency", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.MinLod)] = .{ + result[@intFromEnum(Feature.MinLod)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability MinLod", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.Sampled1D)] = .{ + result[@intFromEnum(Feature.Sampled1D)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Sampled1D", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.Image1D)] = .{ + result[@intFromEnum(Feature.Image1D)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Image1D", .dependencies = featureSet(&[_]Feature{ .Sampled1D, }), }; - result[@enumToInt(Feature.SampledCubeArray)] = .{ + result[@intFromEnum(Feature.SampledCubeArray)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SampledCubeArray", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.SampledBuffer)] = .{ + result[@intFromEnum(Feature.SampledBuffer)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SampledBuffer", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ImageBuffer)] = .{ + result[@intFromEnum(Feature.ImageBuffer)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ImageBuffer", .dependencies = featureSet(&[_]Feature{ .SampledBuffer, }), }; - result[@enumToInt(Feature.ImageMSArray)] = .{ + result[@intFromEnum(Feature.ImageMSArray)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ImageMSArray", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.StorageImageExtendedFormats)] = .{ + result[@intFromEnum(Feature.StorageImageExtendedFormats)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageImageExtendedFormats", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.ImageQuery)] = .{ + result[@intFromEnum(Feature.ImageQuery)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ImageQuery", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.DerivativeControl)] = .{ + result[@intFromEnum(Feature.DerivativeControl)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability DerivativeControl", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.InterpolationFunction)] = .{ + result[@intFromEnum(Feature.InterpolationFunction)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability InterpolationFunction", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.TransformFeedback)] = .{ + result[@intFromEnum(Feature.TransformFeedback)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability TransformFeedback", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.GeometryStreams)] = .{ + result[@intFromEnum(Feature.GeometryStreams)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GeometryStreams", .dependencies = featureSet(&[_]Feature{ .Geometry, }), }; - result[@enumToInt(Feature.StorageImageReadWithoutFormat)] = .{ + result[@intFromEnum(Feature.StorageImageReadWithoutFormat)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageImageReadWithoutFormat", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.StorageImageWriteWithoutFormat)] = .{ + result[@intFromEnum(Feature.StorageImageWriteWithoutFormat)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageImageWriteWithoutFormat", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.MultiViewport)] = .{ + result[@intFromEnum(Feature.MultiViewport)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability MultiViewport", .dependencies = featureSet(&[_]Feature{ .Geometry, }), }; - result[@enumToInt(Feature.SubgroupDispatch)] = .{ + result[@intFromEnum(Feature.SubgroupDispatch)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SubgroupDispatch", .dependencies = featureSet(&[_]Feature{ @@ -1108,7 +1108,7 @@ pub const all_features = blk: { .DeviceEnqueue, }), }; - result[@enumToInt(Feature.NamedBarrier)] = .{ + result[@intFromEnum(Feature.NamedBarrier)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability NamedBarrier", .dependencies = featureSet(&[_]Feature{ @@ -1116,7 +1116,7 @@ pub const all_features = blk: { .Kernel, }), }; - result[@enumToInt(Feature.PipeStorage)] = .{ + result[@intFromEnum(Feature.PipeStorage)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability PipeStorage", .dependencies = featureSet(&[_]Feature{ @@ -1124,14 +1124,14 @@ pub const all_features = blk: { .Pipes, }), }; - result[@enumToInt(Feature.GroupNonUniform)] = .{ + result[@intFromEnum(Feature.GroupNonUniform)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GroupNonUniform", .dependencies = featureSet(&[_]Feature{ .v1_3, }), }; - result[@enumToInt(Feature.GroupNonUniformVote)] = .{ + result[@intFromEnum(Feature.GroupNonUniformVote)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GroupNonUniformVote", .dependencies = featureSet(&[_]Feature{ @@ -1139,7 +1139,7 @@ pub const all_features = blk: { .GroupNonUniform, }), }; - result[@enumToInt(Feature.GroupNonUniformArithmetic)] = .{ + result[@intFromEnum(Feature.GroupNonUniformArithmetic)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GroupNonUniformArithmetic", .dependencies = featureSet(&[_]Feature{ @@ -1147,7 +1147,7 @@ pub const all_features = blk: { .GroupNonUniform, }), }; - result[@enumToInt(Feature.GroupNonUniformBallot)] = .{ + result[@intFromEnum(Feature.GroupNonUniformBallot)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GroupNonUniformBallot", .dependencies = featureSet(&[_]Feature{ @@ -1155,7 +1155,7 @@ pub const all_features = blk: { .GroupNonUniform, }), }; - result[@enumToInt(Feature.GroupNonUniformShuffle)] = .{ + result[@intFromEnum(Feature.GroupNonUniformShuffle)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GroupNonUniformShuffle", .dependencies = featureSet(&[_]Feature{ @@ -1163,7 +1163,7 @@ pub const all_features = blk: { .GroupNonUniform, }), }; - result[@enumToInt(Feature.GroupNonUniformShuffleRelative)] = .{ + result[@intFromEnum(Feature.GroupNonUniformShuffleRelative)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GroupNonUniformShuffleRelative", .dependencies = featureSet(&[_]Feature{ @@ -1171,7 +1171,7 @@ pub const all_features = blk: { .GroupNonUniform, }), }; - result[@enumToInt(Feature.GroupNonUniformClustered)] = .{ + result[@intFromEnum(Feature.GroupNonUniformClustered)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GroupNonUniformClustered", .dependencies = featureSet(&[_]Feature{ @@ -1179,7 +1179,7 @@ pub const all_features = blk: { .GroupNonUniform, }), }; - result[@enumToInt(Feature.GroupNonUniformQuad)] = .{ + result[@intFromEnum(Feature.GroupNonUniformQuad)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GroupNonUniformQuad", .dependencies = featureSet(&[_]Feature{ @@ -1187,33 +1187,33 @@ pub const all_features = blk: { .GroupNonUniform, }), }; - result[@enumToInt(Feature.ShaderLayer)] = .{ + result[@intFromEnum(Feature.ShaderLayer)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ShaderLayer", .dependencies = featureSet(&[_]Feature{ .v1_5, }), }; - result[@enumToInt(Feature.ShaderViewportIndex)] = .{ + result[@intFromEnum(Feature.ShaderViewportIndex)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ShaderViewportIndex", .dependencies = featureSet(&[_]Feature{ .v1_5, }), }; - result[@enumToInt(Feature.FragmentShadingRateKHR)] = .{ + result[@intFromEnum(Feature.FragmentShadingRateKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FragmentShadingRateKHR", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.SubgroupBallotKHR)] = .{ + result[@intFromEnum(Feature.SubgroupBallotKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SubgroupBallotKHR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.DrawParameters)] = .{ + result[@intFromEnum(Feature.DrawParameters)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability DrawParameters", .dependencies = featureSet(&[_]Feature{ @@ -1221,47 +1221,47 @@ pub const all_features = blk: { .Shader, }), }; - result[@enumToInt(Feature.WorkgroupMemoryExplicitLayoutKHR)] = .{ + result[@intFromEnum(Feature.WorkgroupMemoryExplicitLayoutKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability WorkgroupMemoryExplicitLayoutKHR", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.WorkgroupMemoryExplicitLayout8BitAccessKHR)] = .{ + result[@intFromEnum(Feature.WorkgroupMemoryExplicitLayout8BitAccessKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability WorkgroupMemoryExplicitLayout8BitAccessKHR", .dependencies = featureSet(&[_]Feature{ .WorkgroupMemoryExplicitLayoutKHR, }), }; - result[@enumToInt(Feature.WorkgroupMemoryExplicitLayout16BitAccessKHR)] = .{ + result[@intFromEnum(Feature.WorkgroupMemoryExplicitLayout16BitAccessKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability WorkgroupMemoryExplicitLayout16BitAccessKHR", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.SubgroupVoteKHR)] = .{ + result[@intFromEnum(Feature.SubgroupVoteKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SubgroupVoteKHR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.StorageBuffer16BitAccess)] = .{ + result[@intFromEnum(Feature.StorageBuffer16BitAccess)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageBuffer16BitAccess", .dependencies = featureSet(&[_]Feature{ .v1_3, }), }; - result[@enumToInt(Feature.StorageUniformBufferBlock16)] = .{ + result[@intFromEnum(Feature.StorageUniformBufferBlock16)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageUniformBufferBlock16", .dependencies = featureSet(&[_]Feature{ .v1_3, }), }; - result[@enumToInt(Feature.UniformAndStorageBuffer16BitAccess)] = .{ + result[@intFromEnum(Feature.UniformAndStorageBuffer16BitAccess)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability UniformAndStorageBuffer16BitAccess", .dependencies = featureSet(&[_]Feature{ @@ -1270,7 +1270,7 @@ pub const all_features = blk: { .StorageUniformBufferBlock16, }), }; - result[@enumToInt(Feature.StorageUniform16)] = .{ + result[@intFromEnum(Feature.StorageUniform16)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageUniform16", .dependencies = featureSet(&[_]Feature{ @@ -1279,28 +1279,28 @@ pub const all_features = blk: { .StorageUniformBufferBlock16, }), }; - result[@enumToInt(Feature.StoragePushConstant16)] = .{ + result[@intFromEnum(Feature.StoragePushConstant16)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StoragePushConstant16", .dependencies = featureSet(&[_]Feature{ .v1_3, }), }; - result[@enumToInt(Feature.StorageInputOutput16)] = .{ + result[@intFromEnum(Feature.StorageInputOutput16)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageInputOutput16", .dependencies = featureSet(&[_]Feature{ .v1_3, }), }; - result[@enumToInt(Feature.DeviceGroup)] = .{ + result[@intFromEnum(Feature.DeviceGroup)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability DeviceGroup", .dependencies = featureSet(&[_]Feature{ .v1_3, }), }; - result[@enumToInt(Feature.MultiView)] = .{ + result[@intFromEnum(Feature.MultiView)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability MultiView", .dependencies = featureSet(&[_]Feature{ @@ -1308,7 +1308,7 @@ pub const all_features = blk: { .Shader, }), }; - result[@enumToInt(Feature.VariablePointersStorageBuffer)] = .{ + result[@intFromEnum(Feature.VariablePointersStorageBuffer)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability VariablePointersStorageBuffer", .dependencies = featureSet(&[_]Feature{ @@ -1316,7 +1316,7 @@ pub const all_features = blk: { .Shader, }), }; - result[@enumToInt(Feature.VariablePointers)] = .{ + result[@intFromEnum(Feature.VariablePointers)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability VariablePointers", .dependencies = featureSet(&[_]Feature{ @@ -1324,24 +1324,24 @@ pub const all_features = blk: { .VariablePointersStorageBuffer, }), }; - result[@enumToInt(Feature.AtomicStorageOps)] = .{ + result[@intFromEnum(Feature.AtomicStorageOps)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability AtomicStorageOps", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SampleMaskPostDepthCoverage)] = .{ + result[@intFromEnum(Feature.SampleMaskPostDepthCoverage)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SampleMaskPostDepthCoverage", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.StorageBuffer8BitAccess)] = .{ + result[@intFromEnum(Feature.StorageBuffer8BitAccess)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageBuffer8BitAccess", .dependencies = featureSet(&[_]Feature{ .v1_5, }), }; - result[@enumToInt(Feature.UniformAndStorageBuffer8BitAccess)] = .{ + result[@intFromEnum(Feature.UniformAndStorageBuffer8BitAccess)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability UniformAndStorageBuffer8BitAccess", .dependencies = featureSet(&[_]Feature{ @@ -1349,63 +1349,63 @@ pub const all_features = blk: { .StorageBuffer8BitAccess, }), }; - result[@enumToInt(Feature.StoragePushConstant8)] = .{ + result[@intFromEnum(Feature.StoragePushConstant8)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StoragePushConstant8", .dependencies = featureSet(&[_]Feature{ .v1_5, }), }; - result[@enumToInt(Feature.DenormPreserve)] = .{ + result[@intFromEnum(Feature.DenormPreserve)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability DenormPreserve", .dependencies = featureSet(&[_]Feature{ .v1_4, }), }; - result[@enumToInt(Feature.DenormFlushToZero)] = .{ + result[@intFromEnum(Feature.DenormFlushToZero)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability DenormFlushToZero", .dependencies = featureSet(&[_]Feature{ .v1_4, }), }; - result[@enumToInt(Feature.SignedZeroInfNanPreserve)] = .{ + result[@intFromEnum(Feature.SignedZeroInfNanPreserve)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SignedZeroInfNanPreserve", .dependencies = featureSet(&[_]Feature{ .v1_4, }), }; - result[@enumToInt(Feature.RoundingModeRTE)] = .{ + result[@intFromEnum(Feature.RoundingModeRTE)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability RoundingModeRTE", .dependencies = featureSet(&[_]Feature{ .v1_4, }), }; - result[@enumToInt(Feature.RoundingModeRTZ)] = .{ + result[@intFromEnum(Feature.RoundingModeRTZ)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability RoundingModeRTZ", .dependencies = featureSet(&[_]Feature{ .v1_4, }), }; - result[@enumToInt(Feature.RayQueryProvisionalKHR)] = .{ + result[@intFromEnum(Feature.RayQueryProvisionalKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability RayQueryProvisionalKHR", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.RayQueryKHR)] = .{ + result[@intFromEnum(Feature.RayQueryKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability RayQueryKHR", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.RayTraversalPrimitiveCullingKHR)] = .{ + result[@intFromEnum(Feature.RayTraversalPrimitiveCullingKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability RayTraversalPrimitiveCullingKHR", .dependencies = featureSet(&[_]Feature{ @@ -1413,160 +1413,160 @@ pub const all_features = blk: { .RayTracingKHR, }), }; - result[@enumToInt(Feature.RayTracingKHR)] = .{ + result[@intFromEnum(Feature.RayTracingKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability RayTracingKHR", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.Float16ImageAMD)] = .{ + result[@intFromEnum(Feature.Float16ImageAMD)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Float16ImageAMD", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.ImageGatherBiasLodAMD)] = .{ + result[@intFromEnum(Feature.ImageGatherBiasLodAMD)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ImageGatherBiasLodAMD", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.FragmentMaskAMD)] = .{ + result[@intFromEnum(Feature.FragmentMaskAMD)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FragmentMaskAMD", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.StencilExportEXT)] = .{ + result[@intFromEnum(Feature.StencilExportEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StencilExportEXT", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.ImageReadWriteLodAMD)] = .{ + result[@intFromEnum(Feature.ImageReadWriteLodAMD)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ImageReadWriteLodAMD", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.Int64ImageEXT)] = .{ + result[@intFromEnum(Feature.Int64ImageEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability Int64ImageEXT", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.ShaderClockKHR)] = .{ + result[@intFromEnum(Feature.ShaderClockKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ShaderClockKHR", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.SampleMaskOverrideCoverageNV)] = .{ + result[@intFromEnum(Feature.SampleMaskOverrideCoverageNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SampleMaskOverrideCoverageNV", .dependencies = featureSet(&[_]Feature{ .SampleRateShading, }), }; - result[@enumToInt(Feature.GeometryShaderPassthroughNV)] = .{ + result[@intFromEnum(Feature.GeometryShaderPassthroughNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GeometryShaderPassthroughNV", .dependencies = featureSet(&[_]Feature{ .Geometry, }), }; - result[@enumToInt(Feature.ShaderViewportIndexLayerEXT)] = .{ + result[@intFromEnum(Feature.ShaderViewportIndexLayerEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ShaderViewportIndexLayerEXT", .dependencies = featureSet(&[_]Feature{ .MultiViewport, }), }; - result[@enumToInt(Feature.ShaderViewportIndexLayerNV)] = .{ + result[@intFromEnum(Feature.ShaderViewportIndexLayerNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ShaderViewportIndexLayerNV", .dependencies = featureSet(&[_]Feature{ .MultiViewport, }), }; - result[@enumToInt(Feature.ShaderViewportMaskNV)] = .{ + result[@intFromEnum(Feature.ShaderViewportMaskNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ShaderViewportMaskNV", .dependencies = featureSet(&[_]Feature{ .ShaderViewportIndexLayerNV, }), }; - result[@enumToInt(Feature.ShaderStereoViewNV)] = .{ + result[@intFromEnum(Feature.ShaderStereoViewNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ShaderStereoViewNV", .dependencies = featureSet(&[_]Feature{ .ShaderViewportMaskNV, }), }; - result[@enumToInt(Feature.PerViewAttributesNV)] = .{ + result[@intFromEnum(Feature.PerViewAttributesNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability PerViewAttributesNV", .dependencies = featureSet(&[_]Feature{ .MultiView, }), }; - result[@enumToInt(Feature.FragmentFullyCoveredEXT)] = .{ + result[@intFromEnum(Feature.FragmentFullyCoveredEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FragmentFullyCoveredEXT", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.MeshShadingNV)] = .{ + result[@intFromEnum(Feature.MeshShadingNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability MeshShadingNV", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.ImageFootprintNV)] = .{ + result[@intFromEnum(Feature.ImageFootprintNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ImageFootprintNV", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.FragmentBarycentricNV)] = .{ + result[@intFromEnum(Feature.FragmentBarycentricNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FragmentBarycentricNV", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ComputeDerivativeGroupQuadsNV)] = .{ + result[@intFromEnum(Feature.ComputeDerivativeGroupQuadsNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ComputeDerivativeGroupQuadsNV", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.FragmentDensityEXT)] = .{ + result[@intFromEnum(Feature.FragmentDensityEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FragmentDensityEXT", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.ShadingRateNV)] = .{ + result[@intFromEnum(Feature.ShadingRateNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ShadingRateNV", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.GroupNonUniformPartitionedNV)] = .{ + result[@intFromEnum(Feature.GroupNonUniformPartitionedNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability GroupNonUniformPartitionedNV", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ShaderNonUniform)] = .{ + result[@intFromEnum(Feature.ShaderNonUniform)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ShaderNonUniform", .dependencies = featureSet(&[_]Feature{ @@ -1574,7 +1574,7 @@ pub const all_features = blk: { .Shader, }), }; - result[@enumToInt(Feature.ShaderNonUniformEXT)] = .{ + result[@intFromEnum(Feature.ShaderNonUniformEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ShaderNonUniformEXT", .dependencies = featureSet(&[_]Feature{ @@ -1582,7 +1582,7 @@ pub const all_features = blk: { .Shader, }), }; - result[@enumToInt(Feature.RuntimeDescriptorArray)] = .{ + result[@intFromEnum(Feature.RuntimeDescriptorArray)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability RuntimeDescriptorArray", .dependencies = featureSet(&[_]Feature{ @@ -1590,7 +1590,7 @@ pub const all_features = blk: { .Shader, }), }; - result[@enumToInt(Feature.RuntimeDescriptorArrayEXT)] = .{ + result[@intFromEnum(Feature.RuntimeDescriptorArrayEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability RuntimeDescriptorArrayEXT", .dependencies = featureSet(&[_]Feature{ @@ -1598,7 +1598,7 @@ pub const all_features = blk: { .Shader, }), }; - result[@enumToInt(Feature.InputAttachmentArrayDynamicIndexing)] = .{ + result[@intFromEnum(Feature.InputAttachmentArrayDynamicIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability InputAttachmentArrayDynamicIndexing", .dependencies = featureSet(&[_]Feature{ @@ -1606,7 +1606,7 @@ pub const all_features = blk: { .InputAttachment, }), }; - result[@enumToInt(Feature.InputAttachmentArrayDynamicIndexingEXT)] = .{ + result[@intFromEnum(Feature.InputAttachmentArrayDynamicIndexingEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability InputAttachmentArrayDynamicIndexingEXT", .dependencies = featureSet(&[_]Feature{ @@ -1614,7 +1614,7 @@ pub const all_features = blk: { .InputAttachment, }), }; - result[@enumToInt(Feature.UniformTexelBufferArrayDynamicIndexing)] = .{ + result[@intFromEnum(Feature.UniformTexelBufferArrayDynamicIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability UniformTexelBufferArrayDynamicIndexing", .dependencies = featureSet(&[_]Feature{ @@ -1622,7 +1622,7 @@ pub const all_features = blk: { .SampledBuffer, }), }; - result[@enumToInt(Feature.UniformTexelBufferArrayDynamicIndexingEXT)] = .{ + result[@intFromEnum(Feature.UniformTexelBufferArrayDynamicIndexingEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability UniformTexelBufferArrayDynamicIndexingEXT", .dependencies = featureSet(&[_]Feature{ @@ -1630,7 +1630,7 @@ pub const all_features = blk: { .SampledBuffer, }), }; - result[@enumToInt(Feature.StorageTexelBufferArrayDynamicIndexing)] = .{ + result[@intFromEnum(Feature.StorageTexelBufferArrayDynamicIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageTexelBufferArrayDynamicIndexing", .dependencies = featureSet(&[_]Feature{ @@ -1638,7 +1638,7 @@ pub const all_features = blk: { .ImageBuffer, }), }; - result[@enumToInt(Feature.StorageTexelBufferArrayDynamicIndexingEXT)] = .{ + result[@intFromEnum(Feature.StorageTexelBufferArrayDynamicIndexingEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageTexelBufferArrayDynamicIndexingEXT", .dependencies = featureSet(&[_]Feature{ @@ -1646,7 +1646,7 @@ pub const all_features = blk: { .ImageBuffer, }), }; - result[@enumToInt(Feature.UniformBufferArrayNonUniformIndexing)] = .{ + result[@intFromEnum(Feature.UniformBufferArrayNonUniformIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability UniformBufferArrayNonUniformIndexing", .dependencies = featureSet(&[_]Feature{ @@ -1654,7 +1654,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.UniformBufferArrayNonUniformIndexingEXT)] = .{ + result[@intFromEnum(Feature.UniformBufferArrayNonUniformIndexingEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability UniformBufferArrayNonUniformIndexingEXT", .dependencies = featureSet(&[_]Feature{ @@ -1662,7 +1662,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.SampledImageArrayNonUniformIndexing)] = .{ + result[@intFromEnum(Feature.SampledImageArrayNonUniformIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SampledImageArrayNonUniformIndexing", .dependencies = featureSet(&[_]Feature{ @@ -1670,7 +1670,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.SampledImageArrayNonUniformIndexingEXT)] = .{ + result[@intFromEnum(Feature.SampledImageArrayNonUniformIndexingEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SampledImageArrayNonUniformIndexingEXT", .dependencies = featureSet(&[_]Feature{ @@ -1678,7 +1678,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.StorageBufferArrayNonUniformIndexing)] = .{ + result[@intFromEnum(Feature.StorageBufferArrayNonUniformIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageBufferArrayNonUniformIndexing", .dependencies = featureSet(&[_]Feature{ @@ -1686,7 +1686,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.StorageBufferArrayNonUniformIndexingEXT)] = .{ + result[@intFromEnum(Feature.StorageBufferArrayNonUniformIndexingEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageBufferArrayNonUniformIndexingEXT", .dependencies = featureSet(&[_]Feature{ @@ -1694,7 +1694,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.StorageImageArrayNonUniformIndexing)] = .{ + result[@intFromEnum(Feature.StorageImageArrayNonUniformIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageImageArrayNonUniformIndexing", .dependencies = featureSet(&[_]Feature{ @@ -1702,7 +1702,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.StorageImageArrayNonUniformIndexingEXT)] = .{ + result[@intFromEnum(Feature.StorageImageArrayNonUniformIndexingEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageImageArrayNonUniformIndexingEXT", .dependencies = featureSet(&[_]Feature{ @@ -1710,7 +1710,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.InputAttachmentArrayNonUniformIndexing)] = .{ + result[@intFromEnum(Feature.InputAttachmentArrayNonUniformIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability InputAttachmentArrayNonUniformIndexing", .dependencies = featureSet(&[_]Feature{ @@ -1719,7 +1719,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.InputAttachmentArrayNonUniformIndexingEXT)] = .{ + result[@intFromEnum(Feature.InputAttachmentArrayNonUniformIndexingEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability InputAttachmentArrayNonUniformIndexingEXT", .dependencies = featureSet(&[_]Feature{ @@ -1728,7 +1728,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.UniformTexelBufferArrayNonUniformIndexing)] = .{ + result[@intFromEnum(Feature.UniformTexelBufferArrayNonUniformIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability UniformTexelBufferArrayNonUniformIndexing", .dependencies = featureSet(&[_]Feature{ @@ -1737,7 +1737,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.UniformTexelBufferArrayNonUniformIndexingEXT)] = .{ + result[@intFromEnum(Feature.UniformTexelBufferArrayNonUniformIndexingEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability UniformTexelBufferArrayNonUniformIndexingEXT", .dependencies = featureSet(&[_]Feature{ @@ -1746,7 +1746,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.StorageTexelBufferArrayNonUniformIndexing)] = .{ + result[@intFromEnum(Feature.StorageTexelBufferArrayNonUniformIndexing)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageTexelBufferArrayNonUniformIndexing", .dependencies = featureSet(&[_]Feature{ @@ -1755,7 +1755,7 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.StorageTexelBufferArrayNonUniformIndexingEXT)] = .{ + result[@intFromEnum(Feature.StorageTexelBufferArrayNonUniformIndexingEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability StorageTexelBufferArrayNonUniformIndexingEXT", .dependencies = featureSet(&[_]Feature{ @@ -1764,42 +1764,42 @@ pub const all_features = blk: { .ShaderNonUniform, }), }; - result[@enumToInt(Feature.RayTracingNV)] = .{ + result[@intFromEnum(Feature.RayTracingNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability RayTracingNV", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.VulkanMemoryModel)] = .{ + result[@intFromEnum(Feature.VulkanMemoryModel)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability VulkanMemoryModel", .dependencies = featureSet(&[_]Feature{ .v1_5, }), }; - result[@enumToInt(Feature.VulkanMemoryModelKHR)] = .{ + result[@intFromEnum(Feature.VulkanMemoryModelKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability VulkanMemoryModelKHR", .dependencies = featureSet(&[_]Feature{ .v1_5, }), }; - result[@enumToInt(Feature.VulkanMemoryModelDeviceScope)] = .{ + result[@intFromEnum(Feature.VulkanMemoryModelDeviceScope)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability VulkanMemoryModelDeviceScope", .dependencies = featureSet(&[_]Feature{ .v1_5, }), }; - result[@enumToInt(Feature.VulkanMemoryModelDeviceScopeKHR)] = .{ + result[@intFromEnum(Feature.VulkanMemoryModelDeviceScopeKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability VulkanMemoryModelDeviceScopeKHR", .dependencies = featureSet(&[_]Feature{ .v1_5, }), }; - result[@enumToInt(Feature.PhysicalStorageBufferAddresses)] = .{ + result[@intFromEnum(Feature.PhysicalStorageBufferAddresses)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability PhysicalStorageBufferAddresses", .dependencies = featureSet(&[_]Feature{ @@ -1807,7 +1807,7 @@ pub const all_features = blk: { .Shader, }), }; - result[@enumToInt(Feature.PhysicalStorageBufferAddressesEXT)] = .{ + result[@intFromEnum(Feature.PhysicalStorageBufferAddressesEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability PhysicalStorageBufferAddressesEXT", .dependencies = featureSet(&[_]Feature{ @@ -1815,261 +1815,261 @@ pub const all_features = blk: { .Shader, }), }; - result[@enumToInt(Feature.ComputeDerivativeGroupLinearNV)] = .{ + result[@intFromEnum(Feature.ComputeDerivativeGroupLinearNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ComputeDerivativeGroupLinearNV", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.RayTracingProvisionalKHR)] = .{ + result[@intFromEnum(Feature.RayTracingProvisionalKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability RayTracingProvisionalKHR", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.CooperativeMatrixNV)] = .{ + result[@intFromEnum(Feature.CooperativeMatrixNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability CooperativeMatrixNV", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.FragmentShaderSampleInterlockEXT)] = .{ + result[@intFromEnum(Feature.FragmentShaderSampleInterlockEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FragmentShaderSampleInterlockEXT", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.FragmentShaderShadingRateInterlockEXT)] = .{ + result[@intFromEnum(Feature.FragmentShaderShadingRateInterlockEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FragmentShaderShadingRateInterlockEXT", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.ShaderSMBuiltinsNV)] = .{ + result[@intFromEnum(Feature.ShaderSMBuiltinsNV)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ShaderSMBuiltinsNV", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.FragmentShaderPixelInterlockEXT)] = .{ + result[@intFromEnum(Feature.FragmentShaderPixelInterlockEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FragmentShaderPixelInterlockEXT", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.DemoteToHelperInvocationEXT)] = .{ + result[@intFromEnum(Feature.DemoteToHelperInvocationEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability DemoteToHelperInvocationEXT", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.SubgroupShuffleINTEL)] = .{ + result[@intFromEnum(Feature.SubgroupShuffleINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SubgroupShuffleINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SubgroupBufferBlockIOINTEL)] = .{ + result[@intFromEnum(Feature.SubgroupBufferBlockIOINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SubgroupBufferBlockIOINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SubgroupImageBlockIOINTEL)] = .{ + result[@intFromEnum(Feature.SubgroupImageBlockIOINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SubgroupImageBlockIOINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SubgroupImageMediaBlockIOINTEL)] = .{ + result[@intFromEnum(Feature.SubgroupImageMediaBlockIOINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SubgroupImageMediaBlockIOINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.RoundToInfinityINTEL)] = .{ + result[@intFromEnum(Feature.RoundToInfinityINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability RoundToInfinityINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.FloatingPointModeINTEL)] = .{ + result[@intFromEnum(Feature.FloatingPointModeINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FloatingPointModeINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.IntegerFunctions2INTEL)] = .{ + result[@intFromEnum(Feature.IntegerFunctions2INTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability IntegerFunctions2INTEL", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.FunctionPointersINTEL)] = .{ + result[@intFromEnum(Feature.FunctionPointersINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FunctionPointersINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.IndirectReferencesINTEL)] = .{ + result[@intFromEnum(Feature.IndirectReferencesINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability IndirectReferencesINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.AsmINTEL)] = .{ + result[@intFromEnum(Feature.AsmINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability AsmINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.AtomicFloat32MinMaxEXT)] = .{ + result[@intFromEnum(Feature.AtomicFloat32MinMaxEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability AtomicFloat32MinMaxEXT", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.AtomicFloat64MinMaxEXT)] = .{ + result[@intFromEnum(Feature.AtomicFloat64MinMaxEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability AtomicFloat64MinMaxEXT", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.AtomicFloat16MinMaxEXT)] = .{ + result[@intFromEnum(Feature.AtomicFloat16MinMaxEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability AtomicFloat16MinMaxEXT", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.VectorComputeINTEL)] = .{ + result[@intFromEnum(Feature.VectorComputeINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability VectorComputeINTEL", .dependencies = featureSet(&[_]Feature{ .VectorAnyINTEL, }), }; - result[@enumToInt(Feature.VectorAnyINTEL)] = .{ + result[@intFromEnum(Feature.VectorAnyINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability VectorAnyINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ExpectAssumeKHR)] = .{ + result[@intFromEnum(Feature.ExpectAssumeKHR)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ExpectAssumeKHR", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SubgroupAvcMotionEstimationINTEL)] = .{ + result[@intFromEnum(Feature.SubgroupAvcMotionEstimationINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SubgroupAvcMotionEstimationIntraINTEL)] = .{ + result[@intFromEnum(Feature.SubgroupAvcMotionEstimationIntraINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationIntraINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.SubgroupAvcMotionEstimationChromaINTEL)] = .{ + result[@intFromEnum(Feature.SubgroupAvcMotionEstimationChromaINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationChromaINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.VariableLengthArrayINTEL)] = .{ + result[@intFromEnum(Feature.VariableLengthArrayINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability VariableLengthArrayINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.FunctionFloatControlINTEL)] = .{ + result[@intFromEnum(Feature.FunctionFloatControlINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FunctionFloatControlINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.FPGAMemoryAttributesINTEL)] = .{ + result[@intFromEnum(Feature.FPGAMemoryAttributesINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FPGAMemoryAttributesINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.FPFastMathModeINTEL)] = .{ + result[@intFromEnum(Feature.FPFastMathModeINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FPFastMathModeINTEL", .dependencies = featureSet(&[_]Feature{ .Kernel, }), }; - result[@enumToInt(Feature.ArbitraryPrecisionIntegersINTEL)] = .{ + result[@intFromEnum(Feature.ArbitraryPrecisionIntegersINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability ArbitraryPrecisionIntegersINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.UnstructuredLoopControlsINTEL)] = .{ + result[@intFromEnum(Feature.UnstructuredLoopControlsINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability UnstructuredLoopControlsINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.FPGALoopControlsINTEL)] = .{ + result[@intFromEnum(Feature.FPGALoopControlsINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FPGALoopControlsINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.KernelAttributesINTEL)] = .{ + result[@intFromEnum(Feature.KernelAttributesINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability KernelAttributesINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.FPGAKernelAttributesINTEL)] = .{ + result[@intFromEnum(Feature.FPGAKernelAttributesINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FPGAKernelAttributesINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.FPGAMemoryAccessesINTEL)] = .{ + result[@intFromEnum(Feature.FPGAMemoryAccessesINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FPGAMemoryAccessesINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.FPGAClusterAttributesINTEL)] = .{ + result[@intFromEnum(Feature.FPGAClusterAttributesINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FPGAClusterAttributesINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.LoopFuseINTEL)] = .{ + result[@intFromEnum(Feature.LoopFuseINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability LoopFuseINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.FPGABufferLocationINTEL)] = .{ + result[@intFromEnum(Feature.FPGABufferLocationINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FPGABufferLocationINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.USMStorageClassesINTEL)] = .{ + result[@intFromEnum(Feature.USMStorageClassesINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability USMStorageClassesINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.IOPipesINTEL)] = .{ + result[@intFromEnum(Feature.IOPipesINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability IOPipesINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.BlockingPipesINTEL)] = .{ + result[@intFromEnum(Feature.BlockingPipesINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability BlockingPipesINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.FPGARegINTEL)] = .{ + result[@intFromEnum(Feature.FPGARegINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability FPGARegINTEL", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.AtomicFloat32AddEXT)] = .{ + result[@intFromEnum(Feature.AtomicFloat32AddEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability AtomicFloat32AddEXT", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.AtomicFloat64AddEXT)] = .{ + result[@intFromEnum(Feature.AtomicFloat64AddEXT)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability AtomicFloat64AddEXT", .dependencies = featureSet(&[_]Feature{ .Shader, }), }; - result[@enumToInt(Feature.LongConstantCompositeINTEL)] = .{ + result[@intFromEnum(Feature.LongConstantCompositeINTEL)] = .{ .llvm_name = null, .description = "Enable SPIR-V capability LongConstantCompositeINTEL", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/ve.zig b/lib/std/target/ve.zig index 224da897c882..09ee056ef903 100644 --- a/lib/std/target/ve.zig +++ b/lib/std/target/ve.zig @@ -17,7 +17,7 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.vpu)] = .{ + result[@intFromEnum(Feature.vpu)] = .{ .llvm_name = "vpu", .description = "Enable the VPU", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/wasm.zig b/lib/std/target/wasm.zig index 7dd0bd48434b..a06d37cf7dd9 100644 --- a/lib/std/target/wasm.zig +++ b/lib/std/target/wasm.zig @@ -28,62 +28,62 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.atomics)] = .{ + result[@intFromEnum(Feature.atomics)] = .{ .llvm_name = "atomics", .description = "Enable Atomics", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.bulk_memory)] = .{ + result[@intFromEnum(Feature.bulk_memory)] = .{ .llvm_name = "bulk-memory", .description = "Enable bulk memory operations", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.exception_handling)] = .{ + result[@intFromEnum(Feature.exception_handling)] = .{ .llvm_name = "exception-handling", .description = "Enable Wasm exception handling", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.extended_const)] = .{ + result[@intFromEnum(Feature.extended_const)] = .{ .llvm_name = "extended-const", .description = "Enable extended const expressions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.multivalue)] = .{ + result[@intFromEnum(Feature.multivalue)] = .{ .llvm_name = "multivalue", .description = "Enable multivalue blocks, instructions, and functions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mutable_globals)] = .{ + result[@intFromEnum(Feature.mutable_globals)] = .{ .llvm_name = "mutable-globals", .description = "Enable mutable globals", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nontrapping_fptoint)] = .{ + result[@intFromEnum(Feature.nontrapping_fptoint)] = .{ .llvm_name = "nontrapping-fptoint", .description = "Enable non-trapping float-to-int conversion operators", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.reference_types)] = .{ + result[@intFromEnum(Feature.reference_types)] = .{ .llvm_name = "reference-types", .description = "Enable reference types", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.relaxed_simd)] = .{ + result[@intFromEnum(Feature.relaxed_simd)] = .{ .llvm_name = "relaxed-simd", .description = "Enable relaxed-simd instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sign_ext)] = .{ + result[@intFromEnum(Feature.sign_ext)] = .{ .llvm_name = "sign-ext", .description = "Enable sign extension operators", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.simd128)] = .{ + result[@intFromEnum(Feature.simd128)] = .{ .llvm_name = "simd128", .description = "Enable 128-bit SIMD", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tail_call)] = .{ + result[@intFromEnum(Feature.tail_call)] = .{ .llvm_name = "tail-call", .description = "Enable tail call instructions", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/target/x86.zig b/lib/std/target/x86.zig index bf3b8cb95396..645d5f688dc5 100644 --- a/lib/std/target/x86.zig +++ b/lib/std/target/x86.zig @@ -178,135 +178,135 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.@"16bit_mode")] = .{ + result[@intFromEnum(Feature.@"16bit_mode")] = .{ .llvm_name = "16bit-mode", .description = "16-bit mode (i8086)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.@"32bit_mode")] = .{ + result[@intFromEnum(Feature.@"32bit_mode")] = .{ .llvm_name = "32bit-mode", .description = "32-bit mode (80386)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.@"3dnow")] = .{ + result[@intFromEnum(Feature.@"3dnow")] = .{ .llvm_name = "3dnow", .description = "Enable 3DNow! instructions", .dependencies = featureSet(&[_]Feature{ .mmx, }), }; - result[@enumToInt(Feature.@"3dnowa")] = .{ + result[@intFromEnum(Feature.@"3dnowa")] = .{ .llvm_name = "3dnowa", .description = "Enable 3DNow! Athlon instructions", .dependencies = featureSet(&[_]Feature{ .@"3dnow", }), }; - result[@enumToInt(Feature.@"64bit")] = .{ + result[@intFromEnum(Feature.@"64bit")] = .{ .llvm_name = "64bit", .description = "Support 64-bit instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.adx)] = .{ + result[@intFromEnum(Feature.adx)] = .{ .llvm_name = "adx", .description = "Support ADX instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.aes)] = .{ + result[@intFromEnum(Feature.aes)] = .{ .llvm_name = "aes", .description = "Enable AES instructions", .dependencies = featureSet(&[_]Feature{ .sse2, }), }; - result[@enumToInt(Feature.allow_light_256_bit)] = .{ + result[@intFromEnum(Feature.allow_light_256_bit)] = .{ .llvm_name = "allow-light-256-bit", .description = "Enable generation of 256-bit load/stores even if we prefer 128-bit", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.amx_bf16)] = .{ + result[@intFromEnum(Feature.amx_bf16)] = .{ .llvm_name = "amx-bf16", .description = "Support AMX-BF16 instructions", .dependencies = featureSet(&[_]Feature{ .amx_tile, }), }; - result[@enumToInt(Feature.amx_fp16)] = .{ + result[@intFromEnum(Feature.amx_fp16)] = .{ .llvm_name = "amx-fp16", .description = "Support AMX amx-fp16 instructions", .dependencies = featureSet(&[_]Feature{ .amx_tile, }), }; - result[@enumToInt(Feature.amx_int8)] = .{ + result[@intFromEnum(Feature.amx_int8)] = .{ .llvm_name = "amx-int8", .description = "Support AMX-INT8 instructions", .dependencies = featureSet(&[_]Feature{ .amx_tile, }), }; - result[@enumToInt(Feature.amx_tile)] = .{ + result[@intFromEnum(Feature.amx_tile)] = .{ .llvm_name = "amx-tile", .description = "Support AMX-TILE instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.avx)] = .{ + result[@intFromEnum(Feature.avx)] = .{ .llvm_name = "avx", .description = "Enable AVX instructions", .dependencies = featureSet(&[_]Feature{ .sse4_2, }), }; - result[@enumToInt(Feature.avx2)] = .{ + result[@intFromEnum(Feature.avx2)] = .{ .llvm_name = "avx2", .description = "Enable AVX2 instructions", .dependencies = featureSet(&[_]Feature{ .avx, }), }; - result[@enumToInt(Feature.avx512bf16)] = .{ + result[@intFromEnum(Feature.avx512bf16)] = .{ .llvm_name = "avx512bf16", .description = "Support bfloat16 floating point", .dependencies = featureSet(&[_]Feature{ .avx512bw, }), }; - result[@enumToInt(Feature.avx512bitalg)] = .{ + result[@intFromEnum(Feature.avx512bitalg)] = .{ .llvm_name = "avx512bitalg", .description = "Enable AVX-512 Bit Algorithms", .dependencies = featureSet(&[_]Feature{ .avx512bw, }), }; - result[@enumToInt(Feature.avx512bw)] = .{ + result[@intFromEnum(Feature.avx512bw)] = .{ .llvm_name = "avx512bw", .description = "Enable AVX-512 Byte and Word Instructions", .dependencies = featureSet(&[_]Feature{ .avx512f, }), }; - result[@enumToInt(Feature.avx512cd)] = .{ + result[@intFromEnum(Feature.avx512cd)] = .{ .llvm_name = "avx512cd", .description = "Enable AVX-512 Conflict Detection Instructions", .dependencies = featureSet(&[_]Feature{ .avx512f, }), }; - result[@enumToInt(Feature.avx512dq)] = .{ + result[@intFromEnum(Feature.avx512dq)] = .{ .llvm_name = "avx512dq", .description = "Enable AVX-512 Doubleword and Quadword Instructions", .dependencies = featureSet(&[_]Feature{ .avx512f, }), }; - result[@enumToInt(Feature.avx512er)] = .{ + result[@intFromEnum(Feature.avx512er)] = .{ .llvm_name = "avx512er", .description = "Enable AVX-512 Exponential and Reciprocal Instructions", .dependencies = featureSet(&[_]Feature{ .avx512f, }), }; - result[@enumToInt(Feature.avx512f)] = .{ + result[@intFromEnum(Feature.avx512f)] = .{ .llvm_name = "avx512f", .description = "Enable AVX-512 instructions", .dependencies = featureSet(&[_]Feature{ @@ -315,7 +315,7 @@ pub const all_features = blk: { .fma, }), }; - result[@enumToInt(Feature.avx512fp16)] = .{ + result[@intFromEnum(Feature.avx512fp16)] = .{ .llvm_name = "avx512fp16", .description = "Support 16-bit floating point", .dependencies = featureSet(&[_]Feature{ @@ -324,287 +324,287 @@ pub const all_features = blk: { .avx512vl, }), }; - result[@enumToInt(Feature.avx512ifma)] = .{ + result[@intFromEnum(Feature.avx512ifma)] = .{ .llvm_name = "avx512ifma", .description = "Enable AVX-512 Integer Fused Multiply-Add", .dependencies = featureSet(&[_]Feature{ .avx512f, }), }; - result[@enumToInt(Feature.avx512pf)] = .{ + result[@intFromEnum(Feature.avx512pf)] = .{ .llvm_name = "avx512pf", .description = "Enable AVX-512 PreFetch Instructions", .dependencies = featureSet(&[_]Feature{ .avx512f, }), }; - result[@enumToInt(Feature.avx512vbmi)] = .{ + result[@intFromEnum(Feature.avx512vbmi)] = .{ .llvm_name = "avx512vbmi", .description = "Enable AVX-512 Vector Byte Manipulation Instructions", .dependencies = featureSet(&[_]Feature{ .avx512bw, }), }; - result[@enumToInt(Feature.avx512vbmi2)] = .{ + result[@intFromEnum(Feature.avx512vbmi2)] = .{ .llvm_name = "avx512vbmi2", .description = "Enable AVX-512 further Vector Byte Manipulation Instructions", .dependencies = featureSet(&[_]Feature{ .avx512bw, }), }; - result[@enumToInt(Feature.avx512vl)] = .{ + result[@intFromEnum(Feature.avx512vl)] = .{ .llvm_name = "avx512vl", .description = "Enable AVX-512 Vector Length eXtensions", .dependencies = featureSet(&[_]Feature{ .avx512f, }), }; - result[@enumToInt(Feature.avx512vnni)] = .{ + result[@intFromEnum(Feature.avx512vnni)] = .{ .llvm_name = "avx512vnni", .description = "Enable AVX-512 Vector Neural Network Instructions", .dependencies = featureSet(&[_]Feature{ .avx512f, }), }; - result[@enumToInt(Feature.avx512vp2intersect)] = .{ + result[@intFromEnum(Feature.avx512vp2intersect)] = .{ .llvm_name = "avx512vp2intersect", .description = "Enable AVX-512 vp2intersect", .dependencies = featureSet(&[_]Feature{ .avx512f, }), }; - result[@enumToInt(Feature.avx512vpopcntdq)] = .{ + result[@intFromEnum(Feature.avx512vpopcntdq)] = .{ .llvm_name = "avx512vpopcntdq", .description = "Enable AVX-512 Population Count Instructions", .dependencies = featureSet(&[_]Feature{ .avx512f, }), }; - result[@enumToInt(Feature.avxifma)] = .{ + result[@intFromEnum(Feature.avxifma)] = .{ .llvm_name = "avxifma", .description = "Enable AVX-IFMA", .dependencies = featureSet(&[_]Feature{ .avx2, }), }; - result[@enumToInt(Feature.avxneconvert)] = .{ + result[@intFromEnum(Feature.avxneconvert)] = .{ .llvm_name = "avxneconvert", .description = "Support AVX-NE-CONVERT instructions", .dependencies = featureSet(&[_]Feature{ .avx2, }), }; - result[@enumToInt(Feature.avxvnni)] = .{ + result[@intFromEnum(Feature.avxvnni)] = .{ .llvm_name = "avxvnni", .description = "Support AVX_VNNI encoding", .dependencies = featureSet(&[_]Feature{ .avx2, }), }; - result[@enumToInt(Feature.avxvnniint8)] = .{ + result[@intFromEnum(Feature.avxvnniint8)] = .{ .llvm_name = "avxvnniint8", .description = "Enable AVX-VNNI-INT8", .dependencies = featureSet(&[_]Feature{ .avx2, }), }; - result[@enumToInt(Feature.bmi)] = .{ + result[@intFromEnum(Feature.bmi)] = .{ .llvm_name = "bmi", .description = "Support BMI instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.bmi2)] = .{ + result[@intFromEnum(Feature.bmi2)] = .{ .llvm_name = "bmi2", .description = "Support BMI2 instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.branchfusion)] = .{ + result[@intFromEnum(Feature.branchfusion)] = .{ .llvm_name = "branchfusion", .description = "CMP/TEST can be fused with conditional branches", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.cldemote)] = .{ + result[@intFromEnum(Feature.cldemote)] = .{ .llvm_name = "cldemote", .description = "Enable Cache Line Demote", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.clflushopt)] = .{ + result[@intFromEnum(Feature.clflushopt)] = .{ .llvm_name = "clflushopt", .description = "Flush A Cache Line Optimized", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.clwb)] = .{ + result[@intFromEnum(Feature.clwb)] = .{ .llvm_name = "clwb", .description = "Cache Line Write Back", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.clzero)] = .{ + result[@intFromEnum(Feature.clzero)] = .{ .llvm_name = "clzero", .description = "Enable Cache Line Zero", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.cmov)] = .{ + result[@intFromEnum(Feature.cmov)] = .{ .llvm_name = "cmov", .description = "Enable conditional move instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.cmpccxadd)] = .{ + result[@intFromEnum(Feature.cmpccxadd)] = .{ .llvm_name = "cmpccxadd", .description = "Support CMPCCXADD instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.crc32)] = .{ + result[@intFromEnum(Feature.crc32)] = .{ .llvm_name = "crc32", .description = "Enable SSE 4.2 CRC32 instruction (used when SSE4.2 is supported but function is GPR only)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.cx16)] = .{ + result[@intFromEnum(Feature.cx16)] = .{ .llvm_name = "cx16", .description = "64-bit with cmpxchg16b (this is true for most x86-64 chips, but not the first AMD chips)", .dependencies = featureSet(&[_]Feature{ .cx8, }), }; - result[@enumToInt(Feature.cx8)] = .{ + result[@intFromEnum(Feature.cx8)] = .{ .llvm_name = "cx8", .description = "Support CMPXCHG8B instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.enqcmd)] = .{ + result[@intFromEnum(Feature.enqcmd)] = .{ .llvm_name = "enqcmd", .description = "Has ENQCMD instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ermsb)] = .{ + result[@intFromEnum(Feature.ermsb)] = .{ .llvm_name = "ermsb", .description = "REP MOVS/STOS are fast", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.f16c)] = .{ + result[@intFromEnum(Feature.f16c)] = .{ .llvm_name = "f16c", .description = "Support 16-bit floating point conversion instructions", .dependencies = featureSet(&[_]Feature{ .avx, }), }; - result[@enumToInt(Feature.false_deps_getmant)] = .{ + result[@intFromEnum(Feature.false_deps_getmant)] = .{ .llvm_name = "false-deps-getmant", .description = "VGETMANTSS/SD/SH and VGETMANDPS/PD(memory version) has a false dependency on dest register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.false_deps_lzcnt_tzcnt)] = .{ + result[@intFromEnum(Feature.false_deps_lzcnt_tzcnt)] = .{ .llvm_name = "false-deps-lzcnt-tzcnt", .description = "LZCNT/TZCNT have a false dependency on dest register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.false_deps_mulc)] = .{ + result[@intFromEnum(Feature.false_deps_mulc)] = .{ .llvm_name = "false-deps-mulc", .description = "VF[C]MULCPH/SH has a false dependency on dest register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.false_deps_mullq)] = .{ + result[@intFromEnum(Feature.false_deps_mullq)] = .{ .llvm_name = "false-deps-mullq", .description = "VPMULLQ has a false dependency on dest register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.false_deps_perm)] = .{ + result[@intFromEnum(Feature.false_deps_perm)] = .{ .llvm_name = "false-deps-perm", .description = "VPERMD/Q/PS/PD has a false dependency on dest register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.false_deps_popcnt)] = .{ + result[@intFromEnum(Feature.false_deps_popcnt)] = .{ .llvm_name = "false-deps-popcnt", .description = "POPCNT has a false dependency on dest register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.false_deps_range)] = .{ + result[@intFromEnum(Feature.false_deps_range)] = .{ .llvm_name = "false-deps-range", .description = "VRANGEPD/PS/SD/SS has a false dependency on dest register", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_11bytenop)] = .{ + result[@intFromEnum(Feature.fast_11bytenop)] = .{ .llvm_name = "fast-11bytenop", .description = "Target can quickly decode up to 11 byte NOPs", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_15bytenop)] = .{ + result[@intFromEnum(Feature.fast_15bytenop)] = .{ .llvm_name = "fast-15bytenop", .description = "Target can quickly decode up to 15 byte NOPs", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_7bytenop)] = .{ + result[@intFromEnum(Feature.fast_7bytenop)] = .{ .llvm_name = "fast-7bytenop", .description = "Target can quickly decode up to 7 byte NOPs", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_bextr)] = .{ + result[@intFromEnum(Feature.fast_bextr)] = .{ .llvm_name = "fast-bextr", .description = "Indicates that the BEXTR instruction is implemented as a single uop with good throughput", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_gather)] = .{ + result[@intFromEnum(Feature.fast_gather)] = .{ .llvm_name = "fast-gather", .description = "Indicates if gather is reasonably fast (this is true for Skylake client and all AVX-512 CPUs)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_hops)] = .{ + result[@intFromEnum(Feature.fast_hops)] = .{ .llvm_name = "fast-hops", .description = "Prefer horizontal vector math instructions (haddp, phsub, etc.) over normal vector instructions with shuffles", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_lzcnt)] = .{ + result[@intFromEnum(Feature.fast_lzcnt)] = .{ .llvm_name = "fast-lzcnt", .description = "LZCNT instructions are as fast as most simple integer ops", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_movbe)] = .{ + result[@intFromEnum(Feature.fast_movbe)] = .{ .llvm_name = "fast-movbe", .description = "Prefer a movbe over a single-use load + bswap / single-use bswap + store", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_scalar_fsqrt)] = .{ + result[@intFromEnum(Feature.fast_scalar_fsqrt)] = .{ .llvm_name = "fast-scalar-fsqrt", .description = "Scalar SQRT is fast (disable Newton-Raphson)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_scalar_shift_masks)] = .{ + result[@intFromEnum(Feature.fast_scalar_shift_masks)] = .{ .llvm_name = "fast-scalar-shift-masks", .description = "Prefer a left/right scalar logical shift pair over a shift+and pair", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_shld_rotate)] = .{ + result[@intFromEnum(Feature.fast_shld_rotate)] = .{ .llvm_name = "fast-shld-rotate", .description = "SHLD can be used as a faster rotate", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_variable_crosslane_shuffle)] = .{ + result[@intFromEnum(Feature.fast_variable_crosslane_shuffle)] = .{ .llvm_name = "fast-variable-crosslane-shuffle", .description = "Cross-lane shuffles with variable masks are fast", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_variable_perlane_shuffle)] = .{ + result[@intFromEnum(Feature.fast_variable_perlane_shuffle)] = .{ .llvm_name = "fast-variable-perlane-shuffle", .description = "Per-lane shuffles with variable masks are fast", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_vector_fsqrt)] = .{ + result[@intFromEnum(Feature.fast_vector_fsqrt)] = .{ .llvm_name = "fast-vector-fsqrt", .description = "Vector SQRT is fast (disable Newton-Raphson)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fast_vector_shift_masks)] = .{ + result[@intFromEnum(Feature.fast_vector_shift_masks)] = .{ .llvm_name = "fast-vector-shift-masks", .description = "Prefer a left/right vector logical shift pair over a shift+and pair", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fma)] = .{ + result[@intFromEnum(Feature.fma)] = .{ .llvm_name = "fma", .description = "Enable three-operand fused multiply-add", .dependencies = featureSet(&[_]Feature{ .avx, }), }; - result[@enumToInt(Feature.fma4)] = .{ + result[@intFromEnum(Feature.fma4)] = .{ .llvm_name = "fma4", .description = "Enable four-operand fused multiply-add", .dependencies = featureSet(&[_]Feature{ @@ -612,218 +612,218 @@ pub const all_features = blk: { .sse4a, }), }; - result[@enumToInt(Feature.fsgsbase)] = .{ + result[@intFromEnum(Feature.fsgsbase)] = .{ .llvm_name = "fsgsbase", .description = "Support FS/GS Base instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fsrm)] = .{ + result[@intFromEnum(Feature.fsrm)] = .{ .llvm_name = "fsrm", .description = "REP MOVSB of short lengths is faster", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.fxsr)] = .{ + result[@intFromEnum(Feature.fxsr)] = .{ .llvm_name = "fxsr", .description = "Support fxsave/fxrestore instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.gfni)] = .{ + result[@intFromEnum(Feature.gfni)] = .{ .llvm_name = "gfni", .description = "Enable Galois Field Arithmetic Instructions", .dependencies = featureSet(&[_]Feature{ .sse2, }), }; - result[@enumToInt(Feature.harden_sls_ijmp)] = .{ + result[@intFromEnum(Feature.harden_sls_ijmp)] = .{ .llvm_name = "harden-sls-ijmp", .description = "Harden against straight line speculation across indirect JMP instructions.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.harden_sls_ret)] = .{ + result[@intFromEnum(Feature.harden_sls_ret)] = .{ .llvm_name = "harden-sls-ret", .description = "Harden against straight line speculation across RET instructions.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.hreset)] = .{ + result[@intFromEnum(Feature.hreset)] = .{ .llvm_name = "hreset", .description = "Has hreset instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.idivl_to_divb)] = .{ + result[@intFromEnum(Feature.idivl_to_divb)] = .{ .llvm_name = "idivl-to-divb", .description = "Use 8-bit divide for positive values less than 256", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.idivq_to_divl)] = .{ + result[@intFromEnum(Feature.idivq_to_divl)] = .{ .llvm_name = "idivq-to-divl", .description = "Use 32-bit divide for positive values less than 2^32", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.invpcid)] = .{ + result[@intFromEnum(Feature.invpcid)] = .{ .llvm_name = "invpcid", .description = "Invalidate Process-Context Identifier", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.kl)] = .{ + result[@intFromEnum(Feature.kl)] = .{ .llvm_name = "kl", .description = "Support Key Locker kl Instructions", .dependencies = featureSet(&[_]Feature{ .sse2, }), }; - result[@enumToInt(Feature.lea_sp)] = .{ + result[@intFromEnum(Feature.lea_sp)] = .{ .llvm_name = "lea-sp", .description = "Use LEA for adjusting the stack pointer (this is an optimization for Intel Atom processors)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lea_uses_ag)] = .{ + result[@intFromEnum(Feature.lea_uses_ag)] = .{ .llvm_name = "lea-uses-ag", .description = "LEA instruction needs inputs at AG stage", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lvi_cfi)] = .{ + result[@intFromEnum(Feature.lvi_cfi)] = .{ .llvm_name = "lvi-cfi", .description = "Prevent indirect calls/branches from using a memory operand, and precede all indirect calls/branches from a register with an LFENCE instruction to serialize control flow. Also decompose RET instructions into a POP+LFENCE+JMP sequence.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lvi_load_hardening)] = .{ + result[@intFromEnum(Feature.lvi_load_hardening)] = .{ .llvm_name = "lvi-load-hardening", .description = "Insert LFENCE instructions to prevent data speculatively injected into loads from being used maliciously.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lwp)] = .{ + result[@intFromEnum(Feature.lwp)] = .{ .llvm_name = "lwp", .description = "Enable LWP instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.lzcnt)] = .{ + result[@intFromEnum(Feature.lzcnt)] = .{ .llvm_name = "lzcnt", .description = "Support LZCNT instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.macrofusion)] = .{ + result[@intFromEnum(Feature.macrofusion)] = .{ .llvm_name = "macrofusion", .description = "Various instructions can be fused with conditional branches", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mmx)] = .{ + result[@intFromEnum(Feature.mmx)] = .{ .llvm_name = "mmx", .description = "Enable MMX instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.movbe)] = .{ + result[@intFromEnum(Feature.movbe)] = .{ .llvm_name = "movbe", .description = "Support MOVBE instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.movdir64b)] = .{ + result[@intFromEnum(Feature.movdir64b)] = .{ .llvm_name = "movdir64b", .description = "Support movdir64b instruction (direct store 64 bytes)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.movdiri)] = .{ + result[@intFromEnum(Feature.movdiri)] = .{ .llvm_name = "movdiri", .description = "Support movdiri instruction (direct store integer)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.mwaitx)] = .{ + result[@intFromEnum(Feature.mwaitx)] = .{ .llvm_name = "mwaitx", .description = "Enable MONITORX/MWAITX timer functionality", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.nopl)] = .{ + result[@intFromEnum(Feature.nopl)] = .{ .llvm_name = "nopl", .description = "Enable NOPL instruction (generally pentium pro+)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.pad_short_functions)] = .{ + result[@intFromEnum(Feature.pad_short_functions)] = .{ .llvm_name = "pad-short-functions", .description = "Pad short functions (to prevent a stall when returning too early)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.pclmul)] = .{ + result[@intFromEnum(Feature.pclmul)] = .{ .llvm_name = "pclmul", .description = "Enable packed carry-less multiplication instructions", .dependencies = featureSet(&[_]Feature{ .sse2, }), }; - result[@enumToInt(Feature.pconfig)] = .{ + result[@intFromEnum(Feature.pconfig)] = .{ .llvm_name = "pconfig", .description = "platform configuration instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.pku)] = .{ + result[@intFromEnum(Feature.pku)] = .{ .llvm_name = "pku", .description = "Enable protection keys", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.popcnt)] = .{ + result[@intFromEnum(Feature.popcnt)] = .{ .llvm_name = "popcnt", .description = "Support POPCNT instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prefer_128_bit)] = .{ + result[@intFromEnum(Feature.prefer_128_bit)] = .{ .llvm_name = "prefer-128-bit", .description = "Prefer 128-bit AVX instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prefer_256_bit)] = .{ + result[@intFromEnum(Feature.prefer_256_bit)] = .{ .llvm_name = "prefer-256-bit", .description = "Prefer 256-bit AVX instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prefer_mask_registers)] = .{ + result[@intFromEnum(Feature.prefer_mask_registers)] = .{ .llvm_name = "prefer-mask-registers", .description = "Prefer AVX512 mask registers over PTEST/MOVMSK", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prefetchi)] = .{ + result[@intFromEnum(Feature.prefetchi)] = .{ .llvm_name = "prefetchi", .description = "Prefetch instruction with T0 or T1 Hint", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prefetchwt1)] = .{ + result[@intFromEnum(Feature.prefetchwt1)] = .{ .llvm_name = "prefetchwt1", .description = "Prefetch with Intent to Write and T1 Hint", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.prfchw)] = .{ + result[@intFromEnum(Feature.prfchw)] = .{ .llvm_name = "prfchw", .description = "Support PRFCHW instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ptwrite)] = .{ + result[@intFromEnum(Feature.ptwrite)] = .{ .llvm_name = "ptwrite", .description = "Support ptwrite instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.raoint)] = .{ + result[@intFromEnum(Feature.raoint)] = .{ .llvm_name = "raoint", .description = "Support RAO-INT instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.rdpid)] = .{ + result[@intFromEnum(Feature.rdpid)] = .{ .llvm_name = "rdpid", .description = "Support RDPID instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.rdpru)] = .{ + result[@intFromEnum(Feature.rdpru)] = .{ .llvm_name = "rdpru", .description = "Support RDPRU instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.rdrnd)] = .{ + result[@intFromEnum(Feature.rdrnd)] = .{ .llvm_name = "rdrnd", .description = "Support RDRAND instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.rdseed)] = .{ + result[@intFromEnum(Feature.rdseed)] = .{ .llvm_name = "rdseed", .description = "Support RDSEED instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.retpoline)] = .{ + result[@intFromEnum(Feature.retpoline)] = .{ .llvm_name = "retpoline", .description = "Remove speculation of indirect branches from the generated code, either by avoiding them entirely or lowering them with a speculation blocking construct", .dependencies = featureSet(&[_]Feature{ @@ -831,200 +831,200 @@ pub const all_features = blk: { .retpoline_indirect_calls, }), }; - result[@enumToInt(Feature.retpoline_external_thunk)] = .{ + result[@intFromEnum(Feature.retpoline_external_thunk)] = .{ .llvm_name = "retpoline-external-thunk", .description = "When lowering an indirect call or branch using a `retpoline`, rely on the specified user provided thunk rather than emitting one ourselves. Only has effect when combined with some other retpoline feature", .dependencies = featureSet(&[_]Feature{ .retpoline_indirect_calls, }), }; - result[@enumToInt(Feature.retpoline_indirect_branches)] = .{ + result[@intFromEnum(Feature.retpoline_indirect_branches)] = .{ .llvm_name = "retpoline-indirect-branches", .description = "Remove speculation of indirect branches from the generated code", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.retpoline_indirect_calls)] = .{ + result[@intFromEnum(Feature.retpoline_indirect_calls)] = .{ .llvm_name = "retpoline-indirect-calls", .description = "Remove speculation of indirect calls from the generated code", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.rtm)] = .{ + result[@intFromEnum(Feature.rtm)] = .{ .llvm_name = "rtm", .description = "Support RTM instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sahf)] = .{ + result[@intFromEnum(Feature.sahf)] = .{ .llvm_name = "sahf", .description = "Support LAHF and SAHF instructions in 64-bit mode", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sbb_dep_breaking)] = .{ + result[@intFromEnum(Feature.sbb_dep_breaking)] = .{ .llvm_name = "sbb-dep-breaking", .description = "SBB with same register has no source dependency", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.serialize)] = .{ + result[@intFromEnum(Feature.serialize)] = .{ .llvm_name = "serialize", .description = "Has serialize instruction", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.seses)] = .{ + result[@intFromEnum(Feature.seses)] = .{ .llvm_name = "seses", .description = "Prevent speculative execution side channel timing attacks by inserting a speculation barrier before memory reads, memory writes, and conditional branches. Implies LVI Control Flow integrity.", .dependencies = featureSet(&[_]Feature{ .lvi_cfi, }), }; - result[@enumToInt(Feature.sgx)] = .{ + result[@intFromEnum(Feature.sgx)] = .{ .llvm_name = "sgx", .description = "Enable Software Guard Extensions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sha)] = .{ + result[@intFromEnum(Feature.sha)] = .{ .llvm_name = "sha", .description = "Enable SHA instructions", .dependencies = featureSet(&[_]Feature{ .sse2, }), }; - result[@enumToInt(Feature.shstk)] = .{ + result[@intFromEnum(Feature.shstk)] = .{ .llvm_name = "shstk", .description = "Support CET Shadow-Stack instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_3ops_lea)] = .{ + result[@intFromEnum(Feature.slow_3ops_lea)] = .{ .llvm_name = "slow-3ops-lea", .description = "LEA instruction with 3 ops or certain registers is slow", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_incdec)] = .{ + result[@intFromEnum(Feature.slow_incdec)] = .{ .llvm_name = "slow-incdec", .description = "INC and DEC instructions are slower than ADD and SUB", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_lea)] = .{ + result[@intFromEnum(Feature.slow_lea)] = .{ .llvm_name = "slow-lea", .description = "LEA instruction with certain arguments is slow", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_pmaddwd)] = .{ + result[@intFromEnum(Feature.slow_pmaddwd)] = .{ .llvm_name = "slow-pmaddwd", .description = "PMADDWD is slower than PMULLD", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_pmulld)] = .{ + result[@intFromEnum(Feature.slow_pmulld)] = .{ .llvm_name = "slow-pmulld", .description = "PMULLD instruction is slow (compared to PMULLW/PMULHW and PMULUDQ)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_shld)] = .{ + result[@intFromEnum(Feature.slow_shld)] = .{ .llvm_name = "slow-shld", .description = "SHLD instruction is slow", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_two_mem_ops)] = .{ + result[@intFromEnum(Feature.slow_two_mem_ops)] = .{ .llvm_name = "slow-two-mem-ops", .description = "Two memory operand instructions are slow", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_unaligned_mem_16)] = .{ + result[@intFromEnum(Feature.slow_unaligned_mem_16)] = .{ .llvm_name = "slow-unaligned-mem-16", .description = "Slow unaligned 16-byte memory access", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.slow_unaligned_mem_32)] = .{ + result[@intFromEnum(Feature.slow_unaligned_mem_32)] = .{ .llvm_name = "slow-unaligned-mem-32", .description = "Slow unaligned 32-byte memory access", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.soft_float)] = .{ + result[@intFromEnum(Feature.soft_float)] = .{ .llvm_name = "soft-float", .description = "Use software floating point features", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sse)] = .{ + result[@intFromEnum(Feature.sse)] = .{ .llvm_name = "sse", .description = "Enable SSE instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.sse2)] = .{ + result[@intFromEnum(Feature.sse2)] = .{ .llvm_name = "sse2", .description = "Enable SSE2 instructions", .dependencies = featureSet(&[_]Feature{ .sse, }), }; - result[@enumToInt(Feature.sse3)] = .{ + result[@intFromEnum(Feature.sse3)] = .{ .llvm_name = "sse3", .description = "Enable SSE3 instructions", .dependencies = featureSet(&[_]Feature{ .sse2, }), }; - result[@enumToInt(Feature.sse4_1)] = .{ + result[@intFromEnum(Feature.sse4_1)] = .{ .llvm_name = "sse4.1", .description = "Enable SSE 4.1 instructions", .dependencies = featureSet(&[_]Feature{ .ssse3, }), }; - result[@enumToInt(Feature.sse4_2)] = .{ + result[@intFromEnum(Feature.sse4_2)] = .{ .llvm_name = "sse4.2", .description = "Enable SSE 4.2 instructions", .dependencies = featureSet(&[_]Feature{ .sse4_1, }), }; - result[@enumToInt(Feature.sse4a)] = .{ + result[@intFromEnum(Feature.sse4a)] = .{ .llvm_name = "sse4a", .description = "Support SSE 4a instructions", .dependencies = featureSet(&[_]Feature{ .sse3, }), }; - result[@enumToInt(Feature.sse_unaligned_mem)] = .{ + result[@intFromEnum(Feature.sse_unaligned_mem)] = .{ .llvm_name = "sse-unaligned-mem", .description = "Allow unaligned memory operands with SSE instructions (this may require setting a configuration bit in the processor)", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.ssse3)] = .{ + result[@intFromEnum(Feature.ssse3)] = .{ .llvm_name = "ssse3", .description = "Enable SSSE3 instructions", .dependencies = featureSet(&[_]Feature{ .sse3, }), }; - result[@enumToInt(Feature.tagged_globals)] = .{ + result[@intFromEnum(Feature.tagged_globals)] = .{ .llvm_name = "tagged-globals", .description = "Use an instruction sequence for taking the address of a global that allows a memory tag in the upper address bits.", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tbm)] = .{ + result[@intFromEnum(Feature.tbm)] = .{ .llvm_name = "tbm", .description = "Enable TBM instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.tsxldtrk)] = .{ + result[@intFromEnum(Feature.tsxldtrk)] = .{ .llvm_name = "tsxldtrk", .description = "Support TSXLDTRK instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.uintr)] = .{ + result[@intFromEnum(Feature.uintr)] = .{ .llvm_name = "uintr", .description = "Has UINTR Instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.use_glm_div_sqrt_costs)] = .{ + result[@intFromEnum(Feature.use_glm_div_sqrt_costs)] = .{ .llvm_name = "use-glm-div-sqrt-costs", .description = "Use Goldmont specific floating point div/sqrt costs", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.use_slm_arith_costs)] = .{ + result[@intFromEnum(Feature.use_slm_arith_costs)] = .{ .llvm_name = "use-slm-arith-costs", .description = "Use Silvermont specific arithmetic costs", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.vaes)] = .{ + result[@intFromEnum(Feature.vaes)] = .{ .llvm_name = "vaes", .description = "Promote selected AES instructions to AVX512/AVX registers", .dependencies = featureSet(&[_]Feature{ @@ -1032,7 +1032,7 @@ pub const all_features = blk: { .avx, }), }; - result[@enumToInt(Feature.vpclmulqdq)] = .{ + result[@intFromEnum(Feature.vpclmulqdq)] = .{ .llvm_name = "vpclmulqdq", .description = "Enable vpclmulqdq instructions", .dependencies = featureSet(&[_]Feature{ @@ -1040,60 +1040,60 @@ pub const all_features = blk: { .pclmul, }), }; - result[@enumToInt(Feature.vzeroupper)] = .{ + result[@intFromEnum(Feature.vzeroupper)] = .{ .llvm_name = "vzeroupper", .description = "Should insert vzeroupper instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.waitpkg)] = .{ + result[@intFromEnum(Feature.waitpkg)] = .{ .llvm_name = "waitpkg", .description = "Wait and pause enhancements", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.wbnoinvd)] = .{ + result[@intFromEnum(Feature.wbnoinvd)] = .{ .llvm_name = "wbnoinvd", .description = "Write Back No Invalidate", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.widekl)] = .{ + result[@intFromEnum(Feature.widekl)] = .{ .llvm_name = "widekl", .description = "Support Key Locker wide Instructions", .dependencies = featureSet(&[_]Feature{ .kl, }), }; - result[@enumToInt(Feature.x87)] = .{ + result[@intFromEnum(Feature.x87)] = .{ .llvm_name = "x87", .description = "Enable X87 float instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.xop)] = .{ + result[@intFromEnum(Feature.xop)] = .{ .llvm_name = "xop", .description = "Enable XOP instructions", .dependencies = featureSet(&[_]Feature{ .fma4, }), }; - result[@enumToInt(Feature.xsave)] = .{ + result[@intFromEnum(Feature.xsave)] = .{ .llvm_name = "xsave", .description = "Support xsave instructions", .dependencies = featureSet(&[_]Feature{}), }; - result[@enumToInt(Feature.xsavec)] = .{ + result[@intFromEnum(Feature.xsavec)] = .{ .llvm_name = "xsavec", .description = "Support xsavec instructions", .dependencies = featureSet(&[_]Feature{ .xsave, }), }; - result[@enumToInt(Feature.xsaveopt)] = .{ + result[@intFromEnum(Feature.xsaveopt)] = .{ .llvm_name = "xsaveopt", .description = "Support xsaveopt instructions", .dependencies = featureSet(&[_]Feature{ .xsave, }), }; - result[@enumToInt(Feature.xsaves)] = .{ + result[@intFromEnum(Feature.xsaves)] = .{ .llvm_name = "xsaves", .description = "Support xsaves instructions", .dependencies = featureSet(&[_]Feature{ diff --git a/lib/std/target/xtensa.zig b/lib/std/target/xtensa.zig index 5979abcaf137..22851c4554cf 100644 --- a/lib/std/target/xtensa.zig +++ b/lib/std/target/xtensa.zig @@ -17,7 +17,7 @@ pub const all_features = blk: { const len = @typeInfo(Feature).Enum.fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; - result[@enumToInt(Feature.density)] = .{ + result[@intFromEnum(Feature.density)] = .{ .llvm_name = "density", .description = "Enable Density instructions", .dependencies = featureSet(&[_]Feature{}), diff --git a/lib/std/time/epoch.zig b/lib/std/time/epoch.zig index 0a9c18656f45..279acc4298a8 100644 --- a/lib/std/time/epoch.zig +++ b/lib/std/time/epoch.zig @@ -83,7 +83,7 @@ pub const Month = enum(u4) { /// return the numeric calendar value for the given month /// i.e. jan=1, feb=2, etc pub fn numeric(self: Month) u4 { - return @enumToInt(self); + return @intFromEnum(self); } }; @@ -122,7 +122,7 @@ pub const YearAndDay = struct { if (days_left < days_in_month) break; days_left -= days_in_month; - month = @intToEnum(Month, @enumToInt(month) + 1); + month = @enumFromInt(Month, @intFromEnum(month) + 1); } return .{ .month = month, .day_index = @intCast(u5, days_left) }; } diff --git a/lib/std/treap.zig b/lib/std/treap.zig index a74256356c89..eabcfd051832 100644 --- a/lib/std/treap.zig +++ b/lib/std/treap.zig @@ -159,7 +159,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type { if (order == .eq) break; parent_ref.* = current; - node = current.children[@boolToInt(order == .gt)]; + node = current.children[@intFromBool(order == .gt)]; } return node; @@ -168,12 +168,12 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type { fn insert(self: *Self, key: Key, parent: ?*Node, node: *Node) void { // generate a random priority & prepare the node to be inserted into the tree node.key = key; - node.priority = self.prng.random(@ptrToInt(node)); + node.priority = self.prng.random(@intFromPtr(node)); node.parent = parent; node.children = [_]?*Node{ null, null }; // point the parent at the new node - const link = if (parent) |p| &p.children[@boolToInt(compare(key, p.key) == .gt)] else &self.root; + const link = if (parent) |p| &p.children[@intFromBool(compare(key, p.key) == .gt)] else &self.root; assert(link.* == null); link.* = node; @@ -182,7 +182,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type { if (p.priority <= node.priority) break; const is_right = p.children[1] == node; - assert(p.children[@boolToInt(is_right)] == node); + assert(p.children[@intFromBool(is_right)] == node); const rotate_right = !is_right; self.rotate(p, rotate_right); @@ -197,7 +197,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type { new.children = old.children; // point the parent at the new node - const link = if (old.parent) |p| &p.children[@boolToInt(p.children[1] == old)] else &self.root; + const link = if (old.parent) |p| &p.children[@intFromBool(p.children[1] == old)] else &self.root; assert(link.* == old); link.* = new; @@ -220,7 +220,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type { } // node is a now a leaf; remove by nulling out the parent's reference to it. - const link = if (node.parent) |p| &p.children[@boolToInt(p.children[1] == node)] else &self.root; + const link = if (node.parent) |p| &p.children[@intFromBool(p.children[1] == node)] else &self.root; assert(link.* == node); link.* = null; @@ -240,12 +240,12 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type { // parent -> (node (target YY adjacent) XX) // parent -> (target YY (node adjacent XX)) const parent = node.parent; - const target = node.children[@boolToInt(!right)] orelse unreachable; - const adjacent = target.children[@boolToInt(right)]; + const target = node.children[@intFromBool(!right)] orelse unreachable; + const adjacent = target.children[@intFromBool(right)]; // rotate the children - target.children[@boolToInt(right)] = node; - node.children[@boolToInt(!right)] = adjacent; + target.children[@intFromBool(right)] = node; + node.children[@intFromBool(!right)] = adjacent; // rotate the parents node.parent = target; @@ -253,7 +253,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type { if (adjacent) |adj| adj.parent = node; // fix the parent link - const link = if (parent) |p| &p.children[@boolToInt(p.children[1] == node)] else &self.root; + const link = if (parent) |p| &p.children[@intFromBool(p.children[1] == node)] else &self.root; assert(link.* == node); link.* = target; } diff --git a/lib/std/unicode/throughput_test.zig b/lib/std/unicode/throughput_test.zig index 66014ad48dcf..b828b4e43f4d 100644 --- a/lib/std/unicode/throughput_test.zig +++ b/lib/std/unicode/throughput_test.zig @@ -32,8 +32,8 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount { } const end = timer.read(); - const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s; - const throughput = @floatToInt(u64, @intToFloat(f64, bytes) / elapsed_s); + const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s; + const throughput = @intFromFloat(u64, @floatFromInt(f64, bytes) / elapsed_s); return ResultCount{ .count = r, .throughput = throughput }; } diff --git a/lib/std/valgrind.zig b/lib/std/valgrind.zig index 099aaf73600a..ae4fde0da18b 100644 --- a/lib/std/valgrind.zig +++ b/lib/std/valgrind.zig @@ -94,7 +94,7 @@ pub fn IsTool(base: [2]u8, code: usize) bool { } fn doClientRequestExpr(default: usize, request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize { - return doClientRequest(default, @intCast(usize, @enumToInt(request)), a1, a2, a3, a4, a5); + return doClientRequest(default, @intCast(usize, @intFromEnum(request)), a1, a2, a3, a4, a5); } fn doClientRequestStmt(request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void { @@ -117,7 +117,7 @@ test "works whether running on valgrind or not" { /// a JITter or some such, since it provides a way to make sure valgrind will /// retranslate the invalidated area. Returns no value. pub fn discardTranslations(qzz: []const u8) void { - doClientRequestStmt(.DiscardTranslations, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); + doClientRequestStmt(.DiscardTranslations, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } pub fn innerThreads(qzz: [*]u8) void { @@ -125,19 +125,19 @@ pub fn innerThreads(qzz: [*]u8) void { } pub fn nonSIMDCall0(func: fn (usize) usize) usize { - return doClientRequestExpr(0, .ClientCall0, @ptrToInt(func), 0, 0, 0, 0); + return doClientRequestExpr(0, .ClientCall0, @intFromPtr(func), 0, 0, 0, 0); } pub fn nonSIMDCall1(func: fn (usize, usize) usize, a1: usize) usize { - return doClientRequestExpr(0, .ClientCall1, @ptrToInt(func), a1, 0, 0, 0); + return doClientRequestExpr(0, .ClientCall1, @intFromPtr(func), a1, 0, 0, 0); } pub fn nonSIMDCall2(func: fn (usize, usize, usize) usize, a1: usize, a2: usize) usize { - return doClientRequestExpr(0, .ClientCall2, @ptrToInt(func), a1, a2, 0, 0); + return doClientRequestExpr(0, .ClientCall2, @intFromPtr(func), a1, a2, 0, 0); } pub fn nonSIMDCall3(func: fn (usize, usize, usize, usize) usize, a1: usize, a2: usize, a3: usize) usize { - return doClientRequestExpr(0, .ClientCall3, @ptrToInt(func), a1, a2, a3, 0); + return doClientRequestExpr(0, .ClientCall3, @intFromPtr(func), a1, a2, a3, 0); } /// Counts the number of errors that have been recorded by a tool. Nb: @@ -149,15 +149,15 @@ pub fn countErrors() usize { } pub fn mallocLikeBlock(mem: []u8, rzB: usize, is_zeroed: bool) void { - doClientRequestStmt(.MalloclikeBlock, @ptrToInt(mem.ptr), mem.len, rzB, @boolToInt(is_zeroed), 0); + doClientRequestStmt(.MalloclikeBlock, @intFromPtr(mem.ptr), mem.len, rzB, @intFromBool(is_zeroed), 0); } pub fn resizeInPlaceBlock(oldmem: []u8, newsize: usize, rzB: usize) void { - doClientRequestStmt(.ResizeinplaceBlock, @ptrToInt(oldmem.ptr), oldmem.len, newsize, rzB, 0); + doClientRequestStmt(.ResizeinplaceBlock, @intFromPtr(oldmem.ptr), oldmem.len, newsize, rzB, 0); } pub fn freeLikeBlock(addr: [*]u8, rzB: usize) void { - doClientRequestStmt(.FreelikeBlock, @ptrToInt(addr), rzB, 0, 0, 0); + doClientRequestStmt(.FreelikeBlock, @intFromPtr(addr), rzB, 0, 0, 0); } /// Create a memory pool. @@ -166,7 +166,7 @@ pub const MempoolFlags = struct { pub const MetaPool = 2; }; pub fn createMempool(pool: [*]u8, rzB: usize, is_zeroed: bool, flags: usize) void { - doClientRequestStmt(.CreateMempool, @ptrToInt(pool), rzB, @boolToInt(is_zeroed), flags, 0); + doClientRequestStmt(.CreateMempool, @intFromPtr(pool), rzB, @intFromBool(is_zeroed), flags, 0); } /// Destroy a memory pool. @@ -176,39 +176,39 @@ pub fn destroyMempool(pool: [*]u8) void { /// Associate a piece of memory with a memory pool. pub fn mempoolAlloc(pool: [*]u8, mem: []u8) void { - doClientRequestStmt(.MempoolAlloc, @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len, 0, 0); + doClientRequestStmt(.MempoolAlloc, @intFromPtr(pool), @intFromPtr(mem.ptr), mem.len, 0, 0); } /// Disassociate a piece of memory from a memory pool. pub fn mempoolFree(pool: [*]u8, addr: [*]u8) void { - doClientRequestStmt(.MempoolFree, @ptrToInt(pool), @ptrToInt(addr), 0, 0, 0); + doClientRequestStmt(.MempoolFree, @intFromPtr(pool), @intFromPtr(addr), 0, 0, 0); } /// Disassociate any pieces outside a particular range. pub fn mempoolTrim(pool: [*]u8, mem: []u8) void { - doClientRequestStmt(.MempoolTrim, @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len, 0, 0); + doClientRequestStmt(.MempoolTrim, @intFromPtr(pool), @intFromPtr(mem.ptr), mem.len, 0, 0); } /// Resize and/or move a piece associated with a memory pool. pub fn moveMempool(poolA: [*]u8, poolB: [*]u8) void { - doClientRequestStmt(.MoveMempool, @ptrToInt(poolA), @ptrToInt(poolB), 0, 0, 0); + doClientRequestStmt(.MoveMempool, @intFromPtr(poolA), @intFromPtr(poolB), 0, 0, 0); } /// Resize and/or move a piece associated with a memory pool. pub fn mempoolChange(pool: [*]u8, addrA: [*]u8, mem: []u8) void { - doClientRequestStmt(.MempoolChange, @ptrToInt(pool), @ptrToInt(addrA), @ptrToInt(mem.ptr), mem.len, 0); + doClientRequestStmt(.MempoolChange, @intFromPtr(pool), @intFromPtr(addrA), @intFromPtr(mem.ptr), mem.len, 0); } /// Return if a mempool exists. pub fn mempoolExists(pool: [*]u8) bool { - return doClientRequestExpr(0, .MempoolExists, @ptrToInt(pool), 0, 0, 0, 0) != 0; + return doClientRequestExpr(0, .MempoolExists, @intFromPtr(pool), 0, 0, 0, 0) != 0; } /// Mark a piece of memory as being a stack. Returns a stack id. /// start is the lowest addressable stack byte, end is the highest /// addressable stack byte. pub fn stackRegister(stack: []u8) usize { - return doClientRequestExpr(0, .StackRegister, @ptrToInt(stack.ptr), @ptrToInt(stack.ptr) + stack.len, 0, 0, 0); + return doClientRequestExpr(0, .StackRegister, @intFromPtr(stack.ptr), @intFromPtr(stack.ptr) + stack.len, 0, 0, 0); } /// Unmark the piece of memory associated with a stack id as being a stack. @@ -220,7 +220,7 @@ pub fn stackDeregister(id: usize) void { /// start is the new lowest addressable stack byte, end is the new highest /// addressable stack byte. pub fn stackChange(id: usize, newstack: []u8) void { - doClientRequestStmt(.StackChange, id, @ptrToInt(newstack.ptr), @ptrToInt(newstack.ptr) + newstack.len, 0, 0); + doClientRequestStmt(.StackChange, id, @intFromPtr(newstack.ptr), @intFromPtr(newstack.ptr) + newstack.len, 0, 0); } // Load PDB debug info for Wine PE image_map. @@ -235,7 +235,7 @@ pub fn stackChange(id: usize, newstack: []u8) void { /// result will be dumped in there and is guaranteed to be zero /// terminated. If no info is found, the first byte is set to zero. pub fn mapIpToSrcloc(addr: *const u8, buf64: [64]u8) usize { - return doClientRequestExpr(0, .MapIpToSrcloc, @ptrToInt(addr), @ptrToInt(&buf64[0]), 0, 0, 0); + return doClientRequestExpr(0, .MapIpToSrcloc, @intFromPtr(addr), @intFromPtr(&buf64[0]), 0, 0, 0); } /// Disable error reporting for this thread. Behaves in a stack like @@ -261,7 +261,7 @@ pub fn enableErrorReporting() void { /// If no connection is opened, output will go to the log output. /// Returns 1 if command not recognised, 0 otherwise. pub fn monitorCommand(command: [*]u8) bool { - return doClientRequestExpr(0, .GdbMonitorCommand, @ptrToInt(command.ptr), 0, 0, 0, 0) != 0; + return doClientRequestExpr(0, .GdbMonitorCommand, @intFromPtr(command.ptr), 0, 0, 0, 0) != 0; } pub const memcheck = @import("valgrind/memcheck.zig"); diff --git a/lib/std/valgrind/callgrind.zig b/lib/std/valgrind/callgrind.zig index fd6967bb9686..f3d8c7ae3c7c 100644 --- a/lib/std/valgrind/callgrind.zig +++ b/lib/std/valgrind/callgrind.zig @@ -11,7 +11,7 @@ pub const CallgrindClientRequest = enum(usize) { }; fn doCallgrindClientRequestExpr(default: usize, request: CallgrindClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize { - return valgrind.doClientRequest(default, @intCast(usize, @enumToInt(request)), a1, a2, a3, a4, a5); + return valgrind.doClientRequest(default, @intCast(usize, @intFromEnum(request)), a1, a2, a3, a4, a5); } fn doCallgrindClientRequestStmt(request: CallgrindClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void { @@ -28,7 +28,7 @@ pub fn dumpStats() void { /// the dump. This string is written as a description field into the /// profile data dump. pub fn dumpStatsAt(pos_str: [*]u8) void { - doCallgrindClientRequestStmt(.DumpStatsAt, @ptrToInt(pos_str), 0, 0, 0, 0); + doCallgrindClientRequestStmt(.DumpStatsAt, @intFromPtr(pos_str), 0, 0, 0, 0); } /// Zero cost centers diff --git a/lib/std/valgrind/memcheck.zig b/lib/std/valgrind/memcheck.zig index 25081510cd5f..dd6c79cd90e3 100644 --- a/lib/std/valgrind/memcheck.zig +++ b/lib/std/valgrind/memcheck.zig @@ -21,7 +21,7 @@ pub const MemCheckClientRequest = enum(usize) { }; fn doMemCheckClientRequestExpr(default: usize, request: MemCheckClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize { - return valgrind.doClientRequest(default, @intCast(usize, @enumToInt(request)), a1, a2, a3, a4, a5); + return valgrind.doClientRequest(default, @intCast(usize, @intFromEnum(request)), a1, a2, a3, a4, a5); } fn doMemCheckClientRequestStmt(request: MemCheckClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void { @@ -32,7 +32,7 @@ fn doMemCheckClientRequestStmt(request: MemCheckClientRequest, a1: usize, a2: us /// This returns -1 when run on Valgrind and 0 otherwise. pub fn makeMemNoAccess(qzz: []u8) i1 { return @intCast(i1, doMemCheckClientRequestExpr(0, // default return - .MakeMemNoAccess, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); + .MakeMemNoAccess, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0)); } /// Similarly, mark memory at qzz.ptr as addressable but undefined @@ -40,7 +40,7 @@ pub fn makeMemNoAccess(qzz: []u8) i1 { /// This returns -1 when run on Valgrind and 0 otherwise. pub fn makeMemUndefined(qzz: []u8) i1 { return @intCast(i1, doMemCheckClientRequestExpr(0, // default return - .MakeMemUndefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); + .MakeMemUndefined, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0)); } /// Similarly, mark memory at qzz.ptr as addressable and defined @@ -48,7 +48,7 @@ pub fn makeMemUndefined(qzz: []u8) i1 { pub fn makeMemDefined(qzz: []u8) i1 { // This returns -1 when run on Valgrind and 0 otherwise. return @intCast(i1, doMemCheckClientRequestExpr(0, // default return - .MakeMemDefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); + .MakeMemDefined, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0)); } /// Similar to makeMemDefined except that addressability is @@ -57,7 +57,7 @@ pub fn makeMemDefined(qzz: []u8) i1 { /// This returns -1 when run on Valgrind and 0 otherwise. pub fn makeMemDefinedIfAddressable(qzz: []u8) i1 { return @intCast(i1, doMemCheckClientRequestExpr(0, // default return - .MakeMemDefinedIfAddressable, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); + .MakeMemDefinedIfAddressable, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0)); } /// Create a block-description handle. The description is an ascii @@ -66,7 +66,7 @@ pub fn makeMemDefinedIfAddressable(qzz: []u8) i1 { /// properties of the memory range. pub fn createBlock(qzz: []u8, desc: [*]u8) usize { return doMemCheckClientRequestExpr(0, // default return - .CreateBlock, @ptrToInt(qzz.ptr), qzz.len, @ptrToInt(desc), 0, 0); + .CreateBlock, @intFromPtr(qzz.ptr), qzz.len, @intFromPtr(desc), 0, 0); } /// Discard a block-description-handle. Returns 1 for an @@ -81,7 +81,7 @@ pub fn discard(blkindex: usize) bool { /// error message and returns the address of the first offending byte. /// Otherwise it returns zero. pub fn checkMemIsAddressable(qzz: []u8) usize { - return doMemCheckClientRequestExpr(0, .CheckMemIsAddressable, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); + return doMemCheckClientRequestExpr(0, .CheckMemIsAddressable, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } /// Check that memory at qzz.ptr is addressable and defined for @@ -89,7 +89,7 @@ pub fn checkMemIsAddressable(qzz: []u8) usize { /// established, Valgrind prints an error message and returns the /// address of the first offending byte. Otherwise it returns zero. pub fn checkMemIsDefined(qzz: []u8) usize { - return doMemCheckClientRequestExpr(0, .CheckMemIsDefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); + return doMemCheckClientRequestExpr(0, .CheckMemIsDefined, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } /// Do a full memory leak check (like --leak-check=full) mid-execution. @@ -134,10 +134,10 @@ pub fn countLeaks() CountResult { }; doMemCheckClientRequestStmt( .CountLeaks, - @ptrToInt(&res.leaked), - @ptrToInt(&res.dubious), - @ptrToInt(&res.reachable), - @ptrToInt(&res.suppressed), + @intFromPtr(&res.leaked), + @intFromPtr(&res.dubious), + @intFromPtr(&res.reachable), + @intFromPtr(&res.suppressed), 0, ); return res; @@ -164,10 +164,10 @@ pub fn countLeakBlocks() CountResult { }; doMemCheckClientRequestStmt( .CountLeakBlocks, - @ptrToInt(&res.leaked), - @ptrToInt(&res.dubious), - @ptrToInt(&res.reachable), - @ptrToInt(&res.suppressed), + @intFromPtr(&res.leaked), + @intFromPtr(&res.dubious), + @intFromPtr(&res.reachable), + @intFromPtr(&res.suppressed), 0, ); return res; @@ -195,7 +195,7 @@ test "countLeakBlocks" { /// impossible to segfault your system by using this call. pub fn getVbits(zza: []u8, zzvbits: []u8) u2 { std.debug.assert(zzvbits.len >= zza.len / 8); - return @intCast(u2, doMemCheckClientRequestExpr(0, .GetVbits, @ptrToInt(zza.ptr), @ptrToInt(zzvbits), zza.len, 0, 0)); + return @intCast(u2, doMemCheckClientRequestExpr(0, .GetVbits, @intFromPtr(zza.ptr), @intFromPtr(zzvbits), zza.len, 0, 0)); } /// Set the validity data for addresses zza, copying it @@ -208,17 +208,17 @@ pub fn getVbits(zza: []u8, zzvbits: []u8) u2 { /// impossible to segfault your system by using this call. pub fn setVbits(zzvbits: []u8, zza: []u8) u2 { std.debug.assert(zzvbits.len >= zza.len / 8); - return @intCast(u2, doMemCheckClientRequestExpr(0, .SetVbits, @ptrToInt(zza.ptr), @ptrToInt(zzvbits), zza.len, 0, 0)); + return @intCast(u2, doMemCheckClientRequestExpr(0, .SetVbits, @intFromPtr(zza.ptr), @intFromPtr(zzvbits), zza.len, 0, 0)); } /// Disable and re-enable reporting of addressing errors in the /// specified address range. pub fn disableAddrErrorReportingInRange(qzz: []u8) usize { return doMemCheckClientRequestExpr(0, // default return - .DisableAddrErrorReportingInRange, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); + .DisableAddrErrorReportingInRange, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } pub fn enableAddrErrorReportingInRange(qzz: []u8) usize { return doMemCheckClientRequestExpr(0, // default return - .EnableAddrErrorReportingInRange, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); + .EnableAddrErrorReportingInRange, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } diff --git a/lib/std/wasm.zig b/lib/std/wasm.zig index d54e998b675d..b02f72ed4c51 100644 --- a/lib/std/wasm.zig +++ b/lib/std/wasm.zig @@ -198,7 +198,7 @@ pub const Opcode = enum(u8) { /// Returns the integer value of an `Opcode`. Used by the Zig compiler /// to write instructions to the wasm binary file pub fn opcode(op: Opcode) u8 { - return @enumToInt(op); + return @intFromEnum(op); } test "Wasm - opcodes" { @@ -244,7 +244,7 @@ pub const MiscOpcode = enum(u32) { /// Returns the integer value of an `MiscOpcode`. Used by the Zig compiler /// to write instructions to the wasm binary file pub fn miscOpcode(op: MiscOpcode) u32 { - return @enumToInt(op); + return @intFromEnum(op); } /// Simd opcodes that require a prefix `0xFD`. @@ -515,7 +515,7 @@ pub const SimdOpcode = enum(u32) { /// Returns the integer value of an `SimdOpcode`. Used by the Zig compiler /// to write instructions to the wasm binary file pub fn simdOpcode(op: SimdOpcode) u32 { - return @enumToInt(op); + return @intFromEnum(op); } /// Simd opcodes that require a prefix `0xFE`. @@ -595,7 +595,7 @@ pub const AtomicsOpcode = enum(u32) { /// Returns the integer value of an `AtomicsOpcode`. Used by the Zig compiler /// to write instructions to the wasm binary file pub fn atomicsOpcode(op: AtomicsOpcode) u32 { - return @enumToInt(op); + return @intFromEnum(op); } /// Enum representing all Wasm value types as per spec: @@ -610,7 +610,7 @@ pub const Valtype = enum(u8) { /// Returns the integer value of a `Valtype` pub fn valtype(value: Valtype) u8 { - return @enumToInt(value); + return @intFromEnum(value); } /// Reference types, where the funcref references to a function regardless of its type @@ -622,7 +622,7 @@ pub const RefType = enum(u8) { /// Returns the integer value of a `Reftype` pub fn reftype(value: RefType) u8 { - return @enumToInt(value); + return @intFromEnum(value); } test "Wasm - valtypes" { @@ -649,11 +649,11 @@ pub const Limits = struct { }; pub fn hasFlag(limits: Limits, flag: Flags) bool { - return limits.flags & @enumToInt(flag) != 0; + return limits.flags & @intFromEnum(flag) != 0; } pub fn setFlag(limits: *Limits, flag: Flags) void { - limits.flags |= @enumToInt(flag); + limits.flags |= @intFromEnum(flag); } }; @@ -790,7 +790,7 @@ pub const Section = enum(u8) { /// Returns the integer value of a given `Section` pub fn section(val: Section) u8 { - return @enumToInt(val); + return @intFromEnum(val); } /// The kind of the type when importing or exporting to/from the host environment @@ -804,7 +804,7 @@ pub const ExternalKind = enum(u8) { /// Returns the integer value of a given `ExternalKind` pub fn externalKind(val: ExternalKind) u8 { - return @enumToInt(val); + return @intFromEnum(val); } /// Defines the enum values for each subsection id for the "Names" custom section diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig index 7bc78c17da4b..86e4e488203f 100644 --- a/lib/std/zig/Ast.zig +++ b/lib/std/zig/Ast.zig @@ -208,22 +208,22 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void { }, .expected_block => { return stream.print("expected block, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_block_or_assignment => { return stream.print("expected block or assignment, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_block_or_expr => { return stream.print("expected block or expression, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_block_or_field => { return stream.print("expected block or field, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_container_members => { @@ -233,42 +233,42 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void { }, .expected_expr => { return stream.print("expected expression, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_expr_or_assignment => { return stream.print("expected expression or assignment, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_fn => { return stream.print("expected function, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_inlinable => { return stream.print("expected 'while' or 'for', found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_labelable => { return stream.print("expected 'while', 'for', 'inline', or '{{', found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_param_list => { return stream.print("expected parameter list, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_prefix_expr => { return stream.print("expected prefix expression, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_primary_type_expr => { return stream.print("expected primary type expression, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_pub_item => { @@ -276,7 +276,7 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void { }, .expected_return_type => { return stream.print("expected return type expression, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_semi_or_else => { @@ -292,32 +292,32 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void { }, .expected_suffix_op => { return stream.print("expected pointer dereference, optional unwrap, or field access, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_type_expr => { return stream.print("expected type expression, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_var_decl => { return stream.print("expected variable declaration, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_var_decl_or_fn => { return stream.print("expected variable declaration or function, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_loop_payload => { return stream.print("expected loop payload, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .expected_container => { return stream.print("expected a struct, enum or union, found '{s}'", .{ - token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(), + token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(), }); }, .extern_fn_body => { @@ -434,7 +434,7 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void { }, .expected_token => { - const found_tag = token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)]; + const found_tag = token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)]; const expected_symbol = parse_error.extra.expected_tag.symbol(); switch (found_tag) { .invalid => return stream.print("expected '{s}', found invalid bytes", .{ @@ -1289,7 +1289,7 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex { }, .@"for" => { const extra = @bitCast(Node.For, datas[n].rhs); - n = tree.extra_data[datas[n].lhs + extra.inputs + @boolToInt(extra.has_else)]; + n = tree.extra_data[datas[n].lhs + extra.inputs + @intFromBool(extra.has_else)]; }, .@"suspend" => { if (datas[n].lhs != 0) { @@ -2291,7 +2291,7 @@ fn fullForComponents(tree: Ast, info: full.For.Components) full.For { result.label_token = tok_i - 1; } const last_cond_token = tree.lastToken(info.inputs[info.inputs.len - 1]); - result.payload_token = last_cond_token + 3 + @boolToInt(token_tags[last_cond_token + 1] == .comma); + result.payload_token = last_cond_token + 3 + @intFromBool(token_tags[last_cond_token + 1] == .comma); if (info.else_expr != 0) { result.else_token = tree.lastToken(info.then_expr) + 1; } diff --git a/lib/std/zig/ErrorBundle.zig b/lib/std/zig/ErrorBundle.zig index 72d49b4f36af..36101a7f2274 100644 --- a/lib/std/zig/ErrorBundle.zig +++ b/lib/std/zig/ErrorBundle.zig @@ -98,17 +98,17 @@ pub fn getMessages(eb: ErrorBundle) []const MessageIndex { } pub fn getErrorMessage(eb: ErrorBundle, index: MessageIndex) ErrorMessage { - return eb.extraData(ErrorMessage, @enumToInt(index)).data; + return eb.extraData(ErrorMessage, @intFromEnum(index)).data; } pub fn getSourceLocation(eb: ErrorBundle, index: SourceLocationIndex) SourceLocation { assert(index != .none); - return eb.extraData(SourceLocation, @enumToInt(index)).data; + return eb.extraData(SourceLocation, @intFromEnum(index)).data; } pub fn getNotes(eb: ErrorBundle, index: MessageIndex) []const MessageIndex { const notes_len = eb.getErrorMessage(index).notes_len; - const start = @enumToInt(index) + @typeInfo(ErrorMessage).Struct.fields.len; + const start = @intFromEnum(index) + @typeInfo(ErrorMessage).Struct.fields.len; return @ptrCast([]const MessageIndex, eb.extra[start..][0..notes_len]); } @@ -125,8 +125,8 @@ fn extraData(eb: ErrorBundle, comptime T: type, index: usize) struct { data: T, inline for (fields) |field| { @field(result, field.name) = switch (field.type) { u32 => eb.extra[i], - MessageIndex => @intToEnum(MessageIndex, eb.extra[i]), - SourceLocationIndex => @intToEnum(SourceLocationIndex, eb.extra[i]), + MessageIndex => @enumFromInt(MessageIndex, eb.extra[i]), + SourceLocationIndex => @enumFromInt(SourceLocationIndex, eb.extra[i]), else => @compileError("bad field type"), }; i += 1; @@ -189,7 +189,7 @@ fn renderErrorMessageToWriter( const counting_stderr = counting_writer.writer(); const err_msg = eb.getErrorMessage(err_msg_index); if (err_msg.src_loc != .none) { - const src = eb.extraData(SourceLocation, @enumToInt(err_msg.src_loc)); + const src = eb.extraData(SourceLocation, @intFromEnum(err_msg.src_loc)); try counting_stderr.writeByteNTimes(' ', indent); try ttyconf.setColor(stderr, .bold); try counting_stderr.print("{s}:{d}:{d}: ", .{ @@ -407,15 +407,15 @@ pub const Wip = struct { } pub fn addErrorMessage(wip: *Wip, em: ErrorMessage) !MessageIndex { - return @intToEnum(MessageIndex, try addExtra(wip, em)); + return @enumFromInt(MessageIndex, try addExtra(wip, em)); } pub fn addErrorMessageAssumeCapacity(wip: *Wip, em: ErrorMessage) MessageIndex { - return @intToEnum(MessageIndex, addExtraAssumeCapacity(wip, em)); + return @enumFromInt(MessageIndex, addExtraAssumeCapacity(wip, em)); } pub fn addSourceLocation(wip: *Wip, sl: SourceLocation) !SourceLocationIndex { - return @intToEnum(SourceLocationIndex, try addExtra(wip, sl)); + return @enumFromInt(SourceLocationIndex, try addExtra(wip, sl)); } pub fn addReferenceTrace(wip: *Wip, rt: ReferenceTrace) !void { @@ -433,7 +433,7 @@ pub const Wip = struct { // The ensureUnusedCapacity call above guarantees this. const notes_start = wip.reserveNotes(@intCast(u32, other_list.len)) catch unreachable; for (notes_start.., other_list) |note, message| { - wip.extra.items[note] = @enumToInt(wip.addOtherMessage(other, message) catch unreachable); + wip.extra.items[note] = @intFromEnum(wip.addOtherMessage(other, message) catch unreachable); } } @@ -455,7 +455,7 @@ pub const Wip = struct { }); const notes_start = try wip.reserveNotes(other_msg.notes_len); for (notes_start.., other.getNotes(msg_index)) |note, other_note| { - wip.extra.items[note] = @enumToInt(try wip.addOtherMessage(other, other_note)); + wip.extra.items[note] = @intFromEnum(try wip.addOtherMessage(other, other_note)); } return msg; } @@ -505,8 +505,8 @@ pub const Wip = struct { inline for (fields) |field| { wip.extra.items[i] = switch (field.type) { u32 => @field(extra, field.name), - MessageIndex => @enumToInt(@field(extra, field.name)), - SourceLocationIndex => @enumToInt(@field(extra, field.name)), + MessageIndex => @intFromEnum(@field(extra, field.name)), + SourceLocationIndex => @intFromEnum(@field(extra, field.name)), else => @compileError("bad field type"), }; i += 1; diff --git a/lib/std/zig/Parse.zig b/lib/std/zig/Parse.zig index 2ef91ca3a690..f3eec86acc31 100644 --- a/lib/std/zig/Parse.zig +++ b/lib/std/zig/Parse.zig @@ -1486,7 +1486,7 @@ fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!Node.Index { while (true) { const tok_tag = p.token_tags[p.tok_i]; - const info = operTable[@intCast(usize, @enumToInt(tok_tag))]; + const info = operTable[@intCast(usize, @intFromEnum(tok_tag))]; if (info.prec < min_prec) { break; } diff --git a/lib/std/zig/Server.zig b/lib/std/zig/Server.zig index 0c099744ccb9..f4f979f012da 100644 --- a/lib/std/zig/Server.zig +++ b/lib/std/zig/Server.zig @@ -253,7 +253,7 @@ fn bswap(x: anytype) @TypeOf(x) { const T = @TypeOf(x); switch (@typeInfo(T)) { - .Enum => return @intToEnum(T, @byteSwap(@enumToInt(x))), + .Enum => return @enumFromInt(T, @byteSwap(@intFromEnum(x))), .Int => return @byteSwap(x), .Struct => |info| switch (info.layout) { .Extern => { @@ -286,7 +286,7 @@ fn bswap_and_workaround_u32(bytes_ptr: *const [4]u8) u32 { /// workaround for https://github.com/ziglang/zig/issues/14904 fn bswap_and_workaround_tag(bytes_ptr: *const [4]u8) InMessage.Tag { const int = std.mem.readIntLittle(u32, bytes_ptr); - return @intToEnum(InMessage.Tag, int); + return @enumFromInt(InMessage.Tag, int); } const OutMessage = std.zig.Server.Message; diff --git a/lib/std/zig/c_builtins.zig b/lib/std/zig/c_builtins.zig index b28134c7cd8c..de9ac9560027 100644 --- a/lib/std/zig/c_builtins.zig +++ b/lib/std/zig/c_builtins.zig @@ -11,10 +11,10 @@ pub inline fn __builtin_bswap64(val: u64) u64 { } pub inline fn __builtin_signbit(val: f64) c_int { - return @boolToInt(std.math.signbit(val)); + return @intFromBool(std.math.signbit(val)); } pub inline fn __builtin_signbitf(val: f32) c_int { - return @boolToInt(std.math.signbit(val)); + return @intFromBool(std.math.signbit(val)); } pub inline fn __builtin_popcount(val: c_uint) c_int { @@ -215,11 +215,11 @@ pub inline fn __builtin_inff() f32 { } pub inline fn __builtin_isnan(x: anytype) c_int { - return @boolToInt(std.math.isNan(x)); + return @intFromBool(std.math.isNan(x)); } pub inline fn __builtin_isinf(x: anytype) c_int { - return @boolToInt(std.math.isInf(x)); + return @intFromBool(std.math.isInf(x)); } /// Similar to isinf, except the return value is -1 for an argument of -Inf and 1 for an argument of +Inf. @@ -230,7 +230,7 @@ pub inline fn __builtin_isinf_sign(x: anytype) c_int { pub inline fn __has_builtin(func: anytype) c_int { _ = func; - return @boolToInt(true); + return @intFromBool(true); } pub inline fn __builtin_assume(cond: bool) void { @@ -243,7 +243,7 @@ pub inline fn __builtin_unreachable() noreturn { pub inline fn __builtin_constant_p(expr: anytype) c_int { _ = expr; - return @boolToInt(false); + return @intFromBool(false); } pub fn __builtin_mul_overflow(a: anytype, b: anytype, result: *@TypeOf(a, b)) c_int { const res = @mulWithOverflow(a, b); diff --git a/lib/std/zig/c_translation.zig b/lib/std/zig/c_translation.zig index 1273527358c0..dafef5e63b1e 100644 --- a/lib/std/zig/c_translation.zig +++ b/lib/std/zig/c_translation.zig @@ -21,30 +21,30 @@ pub fn cast(comptime DestType: type, target: anytype) DestType { .Int => { switch (@typeInfo(SourceType)) { .Pointer => { - return castInt(DestType, @ptrToInt(target)); + return castInt(DestType, @intFromPtr(target)); }, .Optional => |opt| { if (@typeInfo(opt.child) == .Pointer) { - return castInt(DestType, @ptrToInt(target)); + return castInt(DestType, @intFromPtr(target)); } }, .Int => { return castInt(DestType, target); }, .Fn => { - return castInt(DestType, @ptrToInt(&target)); + return castInt(DestType, @intFromPtr(&target)); }, .Bool => { - return @boolToInt(target); + return @intFromBool(target); }, else => {}, } }, .Float => { switch (@typeInfo(SourceType)) { - .Int => return @intToFloat(DestType, target), + .Int => return @floatFromInt(DestType, target), .Float => return @floatCast(DestType, target), - .Bool => return @intToFloat(DestType, @boolToInt(target)), + .Bool => return @floatFromInt(DestType, @intFromBool(target)), else => {}, } }, @@ -88,13 +88,13 @@ fn castPtr(comptime DestType: type, target: anytype) DestType { fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype) DestType { switch (@typeInfo(SourceType)) { .Int => { - return @intToPtr(DestType, castInt(usize, target)); + return @ptrFromInt(DestType, castInt(usize, target)); }, .ComptimeInt => { if (target < 0) - return @intToPtr(DestType, @bitCast(usize, @intCast(isize, target))) + return @ptrFromInt(DestType, @bitCast(usize, @intCast(isize, target))) else - return @intToPtr(DestType, @intCast(usize, target)); + return @ptrFromInt(DestType, @intCast(usize, target)); }, .Pointer => { return castPtr(DestType, target); @@ -120,34 +120,34 @@ fn ptrInfo(comptime PtrType: type) std.builtin.Type.Pointer { test "cast" { var i = @as(i64, 10); - try testing.expect(cast(*u8, 16) == @intToPtr(*u8, 16)); + try testing.expect(cast(*u8, 16) == @ptrFromInt(*u8, 16)); try testing.expect(cast(*u64, &i).* == @as(u64, 10)); try testing.expect(cast(*i64, @as(?*align(1) i64, &i)) == &i); - try testing.expect(cast(?*u8, 2) == @intToPtr(*u8, 2)); + try testing.expect(cast(?*u8, 2) == @ptrFromInt(*u8, 2)); try testing.expect(cast(?*i64, @as(*align(1) i64, &i)) == &i); try testing.expect(cast(?*i64, @as(?*align(1) i64, &i)) == &i); - try testing.expectEqual(@as(u32, 4), cast(u32, @intToPtr(*u32, 4))); - try testing.expectEqual(@as(u32, 4), cast(u32, @intToPtr(?*u32, 4))); + try testing.expectEqual(@as(u32, 4), cast(u32, @ptrFromInt(*u32, 4))); + try testing.expectEqual(@as(u32, 4), cast(u32, @ptrFromInt(?*u32, 4))); try testing.expectEqual(@as(u32, 10), cast(u32, @as(u64, 10))); try testing.expectEqual(@bitCast(i32, @as(u32, 0x8000_0000)), cast(i32, @as(u32, 0x8000_0000))); - try testing.expectEqual(@intToPtr(*u8, 2), cast(*u8, @intToPtr(*const u8, 2))); - try testing.expectEqual(@intToPtr(*u8, 2), cast(*u8, @intToPtr(*volatile u8, 2))); + try testing.expectEqual(@ptrFromInt(*u8, 2), cast(*u8, @ptrFromInt(*const u8, 2))); + try testing.expectEqual(@ptrFromInt(*u8, 2), cast(*u8, @ptrFromInt(*volatile u8, 2))); - try testing.expectEqual(@intToPtr(?*anyopaque, 2), cast(?*anyopaque, @intToPtr(*u8, 2))); + try testing.expectEqual(@ptrFromInt(?*anyopaque, 2), cast(?*anyopaque, @ptrFromInt(*u8, 2))); var foo: c_int = -1; - try testing.expect(cast(*anyopaque, -1) == @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1)))); - try testing.expect(cast(*anyopaque, foo) == @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1)))); - try testing.expect(cast(?*anyopaque, -1) == @intToPtr(?*anyopaque, @bitCast(usize, @as(isize, -1)))); - try testing.expect(cast(?*anyopaque, foo) == @intToPtr(?*anyopaque, @bitCast(usize, @as(isize, -1)))); + try testing.expect(cast(*anyopaque, -1) == @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1)))); + try testing.expect(cast(*anyopaque, foo) == @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1)))); + try testing.expect(cast(?*anyopaque, -1) == @ptrFromInt(?*anyopaque, @bitCast(usize, @as(isize, -1)))); + try testing.expect(cast(?*anyopaque, foo) == @ptrFromInt(?*anyopaque, @bitCast(usize, @as(isize, -1)))); const FnPtr = ?*align(1) const fn (*anyopaque) void; - try testing.expect(cast(FnPtr, 0) == @intToPtr(FnPtr, @as(usize, 0))); - try testing.expect(cast(FnPtr, foo) == @intToPtr(FnPtr, @bitCast(usize, @as(isize, -1)))); + try testing.expect(cast(FnPtr, 0) == @ptrFromInt(FnPtr, @as(usize, 0))); + try testing.expect(cast(FnPtr, foo) == @ptrFromInt(FnPtr, @bitCast(usize, @as(isize, -1)))); } /// Given a value returns its size as C's sizeof operator would. diff --git a/lib/std/zig/number_literal.zig b/lib/std/zig/number_literal.zig index b021190ad9b8..66596b3b15d1 100644 --- a/lib/std/zig/number_literal.zig +++ b/lib/std/zig/number_literal.zig @@ -141,7 +141,7 @@ pub fn parseNumberLiteral(bytes: []const u8) Result { 'a'...'z' => c - 'a' + 10, else => return .{ .failure = .{ .invalid_character = i } }, }; - if (digit >= base) return .{ .failure = .{ .invalid_digit = .{ .i = i, .base = @intToEnum(Base, base) } } }; + if (digit >= base) return .{ .failure = .{ .invalid_digit = .{ .i = i, .base = @enumFromInt(Base, base) } } }; if (exponent and digit >= 10) return .{ .failure = .{ .invalid_digit_exponent = i } }; underscore = false; special = 0; @@ -159,7 +159,7 @@ pub fn parseNumberLiteral(bytes: []const u8) Result { if (underscore) return .{ .failure = .{ .trailing_underscore = bytes.len - 1 } }; if (special != 0) return .{ .failure = .{ .trailing_special = bytes.len - 1 } }; - if (float) return .{ .float = @intToEnum(FloatBase, base) }; - if (overflow) return .{ .big_int = @intToEnum(Base, base) }; + if (float) return .{ .float = @enumFromInt(FloatBase, base) }; + if (overflow) return .{ .big_int = @enumFromInt(Base, base) }; return .{ .int = x }; } diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 21785278ecff..e41e9157e6c0 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -628,7 +628,7 @@ test "zig fmt: builtin call with trailing comma" { try testCanonical( \\pub fn main() void { \\ @breakpoint(); - \\ _ = @boolToInt(a); + \\ _ = @intFromBool(a); \\ _ = @call( \\ a, \\ b, @@ -4815,7 +4815,7 @@ test "zig fmt: use of comments and multiline string literals may force the param \\ \\ Consider providing your own hash function. \\ ); \\ return @intCast(i1, doMemCheckClientRequestExpr(0, // default return - \\ .MakeMemUndefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); + \\ .MakeMemUndefined, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0)); \\} \\ \\// This looks like garbage don't do this diff --git a/lib/std/zig/perf_test.zig b/lib/std/zig/perf_test.zig index 58f7a67694ad..df6097851037 100644 --- a/lib/std/zig/perf_test.zig +++ b/lib/std/zig/perf_test.zig @@ -18,9 +18,9 @@ pub fn main() !void { } const end = timer.read(); memory_used /= iterations; - const elapsed_s = @intToFloat(f64, end - start) / std.time.ns_per_s; - const bytes_per_sec_float = @intToFloat(f64, source.len * iterations) / elapsed_s; - const bytes_per_sec = @floatToInt(u64, @floor(bytes_per_sec_float)); + const elapsed_s = @floatFromInt(f64, end - start) / std.time.ns_per_s; + const bytes_per_sec_float = @floatFromInt(f64, source.len * iterations) / elapsed_s; + const bytes_per_sec = @intFromFloat(u64, @floor(bytes_per_sec_float)); var stdout_file = std.io.getStdOut(); const stdout = stdout_file.writer(); diff --git a/lib/std/zig/render.zig b/lib/std/zig/render.zig index 70c9d7209c27..0c93230d464d 100644 --- a/lib/std/zig/render.zig +++ b/lib/std/zig/render.zig @@ -1723,7 +1723,7 @@ fn renderSwitchCase( if (switch_case.payload_token) |payload_token| { try renderToken(ais, tree, payload_token - 1, .none); // pipe - const ident = payload_token + @boolToInt(token_tags[payload_token] == .asterisk); + const ident = payload_token + @intFromBool(token_tags[payload_token] == .asterisk); if (token_tags[payload_token] == .asterisk) { try renderToken(ais, tree, payload_token, .none); // asterisk } diff --git a/lib/std/zig/system/NativeTargetInfo.zig b/lib/std/zig/system/NativeTargetInfo.zig index 2daac4881d16..66ab6206220d 100644 --- a/lib/std/zig/system/NativeTargetInfo.zig +++ b/lib/std/zig/system/NativeTargetInfo.zig @@ -207,10 +207,10 @@ pub fn detect(cross_target: CrossTarget) DetectError!NativeTargetInfo { })) { switch (result.target.abi) { .code16 => result.target.cpu.features.addFeature( - @enumToInt(std.Target.x86.Feature.@"16bit_mode"), + @intFromEnum(std.Target.x86.Feature.@"16bit_mode"), ), else => result.target.cpu.features.addFeature( - @enumToInt(std.Target.x86.Feature.@"32bit_mode"), + @intFromEnum(std.Target.x86.Feature.@"32bit_mode"), ), } } @@ -221,7 +221,7 @@ pub fn detect(cross_target: CrossTarget) DetectError!NativeTargetInfo { }, .thumb, .thumbeb => { result.target.cpu.features.addFeature( - @enumToInt(std.Target.arm.Feature.thumb_mode), + @intFromEnum(std.Target.arm.Feature.thumb_mode), ); }, else => {}, @@ -268,7 +268,7 @@ fn detectAbiAndDynamicLinker( // and supported by Zig. But that means that we must detect the system ABI here rather than // relying on `builtin.target`. const all_abis = comptime blk: { - assert(@enumToInt(Target.Abi.none) == 0); + assert(@intFromEnum(Target.Abi.none) == 0); const fields = std.meta.fields(Target.Abi)[1..]; var array: [fields.len]Target.Abi = undefined; inline for (fields, 0..) |field, i| { diff --git a/lib/std/zig/system/arm.zig b/lib/std/zig/system/arm.zig index 82f87b1e9af6..da05c8c90d09 100644 --- a/lib/std/zig/system/arm.zig +++ b/lib/std/zig/system/arm.zig @@ -135,7 +135,7 @@ pub const cpu_models = struct { pub const aarch64 = struct { fn setFeature(cpu: *Target.Cpu, feature: Target.aarch64.Feature, enabled: bool) void { - const idx = @as(Target.Cpu.Feature.Set.Index, @enumToInt(feature)); + const idx = @as(Target.Cpu.Feature.Set.Index, @intFromEnum(feature)); if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx); } diff --git a/lib/std/zig/system/windows.zig b/lib/std/zig/system/windows.zig index 6039425b1a98..c5c6f052ec6a 100644 --- a/lib/std/zig/system/windows.zig +++ b/lib/std/zig/system/windows.zig @@ -43,7 +43,7 @@ pub fn detectRuntimeVersion() WindowsVersion { const version: u32 = @as(u32, os_ver) << 16 | @as(u16, sp_ver) << 8 | sub_ver; - return @intToEnum(WindowsVersion, version); + return @enumFromInt(WindowsVersion, version); } // Technically, a registry value can be as long as 1MB. However, MS recommends storing @@ -188,7 +188,7 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void { } fn setFeature(comptime Feature: type, cpu: *Target.Cpu, feature: Feature, enabled: bool) void { - const idx = @as(Target.Cpu.Feature.Set.Index, @enumToInt(feature)); + const idx = @as(Target.Cpu.Feature.Set.Index, @intFromEnum(feature)); if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx); } diff --git a/lib/std/zig/system/x86.zig b/lib/std/zig/system/x86.zig index 873659e58cff..b99f5cf65faa 100644 --- a/lib/std/zig/system/x86.zig +++ b/lib/std/zig/system/x86.zig @@ -10,7 +10,7 @@ const XCR0_ZMM0_15 = 0x40; const XCR0_ZMM16_31 = 0x80; fn setFeature(cpu: *Target.Cpu, feature: Target.x86.Feature, enabled: bool) void { - const idx = @as(Target.Cpu.Feature.Set.Index, @enumToInt(feature)); + const idx = @as(Target.Cpu.Feature.Set.Index, @intFromEnum(feature)); if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx); } diff --git a/lib/test_runner.zig b/lib/test_runner.zig index 33fe547b57b9..8bc79a96c8b6 100644 --- a/lib/test_runner.zig +++ b/lib/test_runner.zig @@ -117,7 +117,7 @@ fn mainServer() !void { }, else => { - std.debug.print("unsupported message: {x}", .{@enumToInt(hdr.tag)}); + std.debug.print("unsupported message: {x}", .{@intFromEnum(hdr.tag)}); std.process.exit(1); }, } @@ -216,10 +216,10 @@ pub fn log( comptime format: []const u8, args: anytype, ) void { - if (@enumToInt(message_level) <= @enumToInt(std.log.Level.err)) { + if (@intFromEnum(message_level) <= @intFromEnum(std.log.Level.err)) { log_err_count += 1; } - if (@enumToInt(message_level) <= @enumToInt(std.testing.log_level)) { + if (@intFromEnum(message_level) <= @intFromEnum(std.testing.log_level)) { std.debug.print( "[" ++ @tagName(scope) ++ "] (" ++ @tagName(message_level) ++ "): " ++ format ++ "\n", args, diff --git a/src/Air.zig b/src/Air.zig index 91e8d0da4df2..d4d4de07f28c 100644 --- a/src/Air.zig +++ b/src/Air.zig @@ -850,93 +850,93 @@ pub const Inst = struct { pub const Index = u32; pub const Ref = enum(u32) { - u1_type = @enumToInt(InternPool.Index.u1_type), - u8_type = @enumToInt(InternPool.Index.u8_type), - i8_type = @enumToInt(InternPool.Index.i8_type), - u16_type = @enumToInt(InternPool.Index.u16_type), - i16_type = @enumToInt(InternPool.Index.i16_type), - u29_type = @enumToInt(InternPool.Index.u29_type), - u32_type = @enumToInt(InternPool.Index.u32_type), - i32_type = @enumToInt(InternPool.Index.i32_type), - u64_type = @enumToInt(InternPool.Index.u64_type), - i64_type = @enumToInt(InternPool.Index.i64_type), - u80_type = @enumToInt(InternPool.Index.u80_type), - u128_type = @enumToInt(InternPool.Index.u128_type), - i128_type = @enumToInt(InternPool.Index.i128_type), - usize_type = @enumToInt(InternPool.Index.usize_type), - isize_type = @enumToInt(InternPool.Index.isize_type), - c_char_type = @enumToInt(InternPool.Index.c_char_type), - c_short_type = @enumToInt(InternPool.Index.c_short_type), - c_ushort_type = @enumToInt(InternPool.Index.c_ushort_type), - c_int_type = @enumToInt(InternPool.Index.c_int_type), - c_uint_type = @enumToInt(InternPool.Index.c_uint_type), - c_long_type = @enumToInt(InternPool.Index.c_long_type), - c_ulong_type = @enumToInt(InternPool.Index.c_ulong_type), - c_longlong_type = @enumToInt(InternPool.Index.c_longlong_type), - c_ulonglong_type = @enumToInt(InternPool.Index.c_ulonglong_type), - c_longdouble_type = @enumToInt(InternPool.Index.c_longdouble_type), - f16_type = @enumToInt(InternPool.Index.f16_type), - f32_type = @enumToInt(InternPool.Index.f32_type), - f64_type = @enumToInt(InternPool.Index.f64_type), - f80_type = @enumToInt(InternPool.Index.f80_type), - f128_type = @enumToInt(InternPool.Index.f128_type), - anyopaque_type = @enumToInt(InternPool.Index.anyopaque_type), - bool_type = @enumToInt(InternPool.Index.bool_type), - void_type = @enumToInt(InternPool.Index.void_type), - type_type = @enumToInt(InternPool.Index.type_type), - anyerror_type = @enumToInt(InternPool.Index.anyerror_type), - comptime_int_type = @enumToInt(InternPool.Index.comptime_int_type), - comptime_float_type = @enumToInt(InternPool.Index.comptime_float_type), - noreturn_type = @enumToInt(InternPool.Index.noreturn_type), - anyframe_type = @enumToInt(InternPool.Index.anyframe_type), - null_type = @enumToInt(InternPool.Index.null_type), - undefined_type = @enumToInt(InternPool.Index.undefined_type), - enum_literal_type = @enumToInt(InternPool.Index.enum_literal_type), - atomic_order_type = @enumToInt(InternPool.Index.atomic_order_type), - atomic_rmw_op_type = @enumToInt(InternPool.Index.atomic_rmw_op_type), - calling_convention_type = @enumToInt(InternPool.Index.calling_convention_type), - address_space_type = @enumToInt(InternPool.Index.address_space_type), - float_mode_type = @enumToInt(InternPool.Index.float_mode_type), - reduce_op_type = @enumToInt(InternPool.Index.reduce_op_type), - call_modifier_type = @enumToInt(InternPool.Index.call_modifier_type), - prefetch_options_type = @enumToInt(InternPool.Index.prefetch_options_type), - export_options_type = @enumToInt(InternPool.Index.export_options_type), - extern_options_type = @enumToInt(InternPool.Index.extern_options_type), - type_info_type = @enumToInt(InternPool.Index.type_info_type), - manyptr_u8_type = @enumToInt(InternPool.Index.manyptr_u8_type), - manyptr_const_u8_type = @enumToInt(InternPool.Index.manyptr_const_u8_type), - manyptr_const_u8_sentinel_0_type = @enumToInt(InternPool.Index.manyptr_const_u8_sentinel_0_type), - single_const_pointer_to_comptime_int_type = @enumToInt(InternPool.Index.single_const_pointer_to_comptime_int_type), - slice_const_u8_type = @enumToInt(InternPool.Index.slice_const_u8_type), - slice_const_u8_sentinel_0_type = @enumToInt(InternPool.Index.slice_const_u8_sentinel_0_type), - anyerror_void_error_union_type = @enumToInt(InternPool.Index.anyerror_void_error_union_type), - generic_poison_type = @enumToInt(InternPool.Index.generic_poison_type), - empty_struct_type = @enumToInt(InternPool.Index.empty_struct_type), - undef = @enumToInt(InternPool.Index.undef), - zero = @enumToInt(InternPool.Index.zero), - zero_usize = @enumToInt(InternPool.Index.zero_usize), - zero_u8 = @enumToInt(InternPool.Index.zero_u8), - one = @enumToInt(InternPool.Index.one), - one_usize = @enumToInt(InternPool.Index.one_usize), - one_u8 = @enumToInt(InternPool.Index.one_u8), - four_u8 = @enumToInt(InternPool.Index.four_u8), - negative_one = @enumToInt(InternPool.Index.negative_one), - calling_convention_c = @enumToInt(InternPool.Index.calling_convention_c), - calling_convention_inline = @enumToInt(InternPool.Index.calling_convention_inline), - void_value = @enumToInt(InternPool.Index.void_value), - unreachable_value = @enumToInt(InternPool.Index.unreachable_value), - null_value = @enumToInt(InternPool.Index.null_value), - bool_true = @enumToInt(InternPool.Index.bool_true), - bool_false = @enumToInt(InternPool.Index.bool_false), - empty_struct = @enumToInt(InternPool.Index.empty_struct), - generic_poison = @enumToInt(InternPool.Index.generic_poison), + u1_type = @intFromEnum(InternPool.Index.u1_type), + u8_type = @intFromEnum(InternPool.Index.u8_type), + i8_type = @intFromEnum(InternPool.Index.i8_type), + u16_type = @intFromEnum(InternPool.Index.u16_type), + i16_type = @intFromEnum(InternPool.Index.i16_type), + u29_type = @intFromEnum(InternPool.Index.u29_type), + u32_type = @intFromEnum(InternPool.Index.u32_type), + i32_type = @intFromEnum(InternPool.Index.i32_type), + u64_type = @intFromEnum(InternPool.Index.u64_type), + i64_type = @intFromEnum(InternPool.Index.i64_type), + u80_type = @intFromEnum(InternPool.Index.u80_type), + u128_type = @intFromEnum(InternPool.Index.u128_type), + i128_type = @intFromEnum(InternPool.Index.i128_type), + usize_type = @intFromEnum(InternPool.Index.usize_type), + isize_type = @intFromEnum(InternPool.Index.isize_type), + c_char_type = @intFromEnum(InternPool.Index.c_char_type), + c_short_type = @intFromEnum(InternPool.Index.c_short_type), + c_ushort_type = @intFromEnum(InternPool.Index.c_ushort_type), + c_int_type = @intFromEnum(InternPool.Index.c_int_type), + c_uint_type = @intFromEnum(InternPool.Index.c_uint_type), + c_long_type = @intFromEnum(InternPool.Index.c_long_type), + c_ulong_type = @intFromEnum(InternPool.Index.c_ulong_type), + c_longlong_type = @intFromEnum(InternPool.Index.c_longlong_type), + c_ulonglong_type = @intFromEnum(InternPool.Index.c_ulonglong_type), + c_longdouble_type = @intFromEnum(InternPool.Index.c_longdouble_type), + f16_type = @intFromEnum(InternPool.Index.f16_type), + f32_type = @intFromEnum(InternPool.Index.f32_type), + f64_type = @intFromEnum(InternPool.Index.f64_type), + f80_type = @intFromEnum(InternPool.Index.f80_type), + f128_type = @intFromEnum(InternPool.Index.f128_type), + anyopaque_type = @intFromEnum(InternPool.Index.anyopaque_type), + bool_type = @intFromEnum(InternPool.Index.bool_type), + void_type = @intFromEnum(InternPool.Index.void_type), + type_type = @intFromEnum(InternPool.Index.type_type), + anyerror_type = @intFromEnum(InternPool.Index.anyerror_type), + comptime_int_type = @intFromEnum(InternPool.Index.comptime_int_type), + comptime_float_type = @intFromEnum(InternPool.Index.comptime_float_type), + noreturn_type = @intFromEnum(InternPool.Index.noreturn_type), + anyframe_type = @intFromEnum(InternPool.Index.anyframe_type), + null_type = @intFromEnum(InternPool.Index.null_type), + undefined_type = @intFromEnum(InternPool.Index.undefined_type), + enum_literal_type = @intFromEnum(InternPool.Index.enum_literal_type), + atomic_order_type = @intFromEnum(InternPool.Index.atomic_order_type), + atomic_rmw_op_type = @intFromEnum(InternPool.Index.atomic_rmw_op_type), + calling_convention_type = @intFromEnum(InternPool.Index.calling_convention_type), + address_space_type = @intFromEnum(InternPool.Index.address_space_type), + float_mode_type = @intFromEnum(InternPool.Index.float_mode_type), + reduce_op_type = @intFromEnum(InternPool.Index.reduce_op_type), + call_modifier_type = @intFromEnum(InternPool.Index.call_modifier_type), + prefetch_options_type = @intFromEnum(InternPool.Index.prefetch_options_type), + export_options_type = @intFromEnum(InternPool.Index.export_options_type), + extern_options_type = @intFromEnum(InternPool.Index.extern_options_type), + type_info_type = @intFromEnum(InternPool.Index.type_info_type), + manyptr_u8_type = @intFromEnum(InternPool.Index.manyptr_u8_type), + manyptr_const_u8_type = @intFromEnum(InternPool.Index.manyptr_const_u8_type), + manyptr_const_u8_sentinel_0_type = @intFromEnum(InternPool.Index.manyptr_const_u8_sentinel_0_type), + single_const_pointer_to_comptime_int_type = @intFromEnum(InternPool.Index.single_const_pointer_to_comptime_int_type), + slice_const_u8_type = @intFromEnum(InternPool.Index.slice_const_u8_type), + slice_const_u8_sentinel_0_type = @intFromEnum(InternPool.Index.slice_const_u8_sentinel_0_type), + anyerror_void_error_union_type = @intFromEnum(InternPool.Index.anyerror_void_error_union_type), + generic_poison_type = @intFromEnum(InternPool.Index.generic_poison_type), + empty_struct_type = @intFromEnum(InternPool.Index.empty_struct_type), + undef = @intFromEnum(InternPool.Index.undef), + zero = @intFromEnum(InternPool.Index.zero), + zero_usize = @intFromEnum(InternPool.Index.zero_usize), + zero_u8 = @intFromEnum(InternPool.Index.zero_u8), + one = @intFromEnum(InternPool.Index.one), + one_usize = @intFromEnum(InternPool.Index.one_usize), + one_u8 = @intFromEnum(InternPool.Index.one_u8), + four_u8 = @intFromEnum(InternPool.Index.four_u8), + negative_one = @intFromEnum(InternPool.Index.negative_one), + calling_convention_c = @intFromEnum(InternPool.Index.calling_convention_c), + calling_convention_inline = @intFromEnum(InternPool.Index.calling_convention_inline), + void_value = @intFromEnum(InternPool.Index.void_value), + unreachable_value = @intFromEnum(InternPool.Index.unreachable_value), + null_value = @intFromEnum(InternPool.Index.null_value), + bool_true = @intFromEnum(InternPool.Index.bool_true), + bool_false = @intFromEnum(InternPool.Index.bool_false), + empty_struct = @intFromEnum(InternPool.Index.empty_struct), + generic_poison = @intFromEnum(InternPool.Index.generic_poison), /// This Ref does not correspond to any AIR instruction or constant /// value. It is used to handle argument types of var args functions. - var_args_param_type = @enumToInt(InternPool.Index.var_args_param_type), + var_args_param_type = @intFromEnum(InternPool.Index.var_args_param_type), /// This Ref does not correspond to any AIR instruction or constant /// value and may instead be used as a sentinel to indicate null. - none = @enumToInt(InternPool.Index.none), + none = @intFromEnum(InternPool.Index.none), _, }; @@ -1103,11 +1103,11 @@ pub const VectorCmp = struct { op: u32, pub fn compareOperator(self: VectorCmp) std.math.CompareOperator { - return @intToEnum(std.math.CompareOperator, @truncate(u3, self.op)); + return @enumFromInt(std.math.CompareOperator, @truncate(u3, self.op)); } pub fn encodeOp(compare_operator: std.math.CompareOperator) u32 { - return @enumToInt(compare_operator); + return @intFromEnum(compare_operator); } }; @@ -1148,11 +1148,11 @@ pub const Cmpxchg = struct { flags: u32, pub fn successOrder(self: Cmpxchg) std.builtin.AtomicOrder { - return @intToEnum(std.builtin.AtomicOrder, @truncate(u3, self.flags)); + return @enumFromInt(std.builtin.AtomicOrder, @truncate(u3, self.flags)); } pub fn failureOrder(self: Cmpxchg) std.builtin.AtomicOrder { - return @intToEnum(std.builtin.AtomicOrder, @truncate(u3, self.flags >> 3)); + return @enumFromInt(std.builtin.AtomicOrder, @truncate(u3, self.flags >> 3)); } }; @@ -1163,11 +1163,11 @@ pub const AtomicRmw = struct { flags: u32, pub fn ordering(self: AtomicRmw) std.builtin.AtomicOrder { - return @intToEnum(std.builtin.AtomicOrder, @truncate(u3, self.flags)); + return @enumFromInt(std.builtin.AtomicOrder, @truncate(u3, self.flags)); } pub fn op(self: AtomicRmw) std.builtin.AtomicRmwOp { - return @intToEnum(std.builtin.AtomicRmwOp, @truncate(u4, self.flags >> 3)); + return @enumFromInt(std.builtin.AtomicRmwOp, @truncate(u4, self.flags >> 3)); } }; @@ -1177,13 +1177,13 @@ pub const UnionInit = struct { }; pub fn getMainBody(air: Air) []const Air.Inst.Index { - const body_index = air.extra[@enumToInt(ExtraIndex.main_block)]; + const body_index = air.extra[@intFromEnum(ExtraIndex.main_block)]; const extra = air.extraData(Block, body_index); return air.extra[extra.end..][0..extra.data.body_len]; } pub fn typeOf(air: Air, inst: Air.Inst.Ref, ip: *const InternPool) Type { - const ref_int = @enumToInt(inst); + const ref_int = @intFromEnum(inst); if (ref_int < InternPool.static_keys.len) { return InternPool.static_keys[ref_int].typeOf().toType(); } @@ -1446,9 +1446,9 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: *const InternPool) Type { } pub fn getRefType(air: Air, ref: Air.Inst.Ref) Type { - const ref_int = @enumToInt(ref); + const ref_int = @intFromEnum(ref); if (ref_int < ref_start_index) { - const ip_index = @intToEnum(InternPool.Index, ref_int); + const ip_index = @enumFromInt(InternPool.Index, ref_int); return ip_index.toType(); } const inst_index = ref_int - ref_start_index; @@ -1469,9 +1469,9 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end inline for (fields) |field| { @field(result, field.name) = switch (field.type) { u32 => air.extra[i], - Inst.Ref => @intToEnum(Inst.Ref, air.extra[i]), + Inst.Ref => @enumFromInt(Inst.Ref, air.extra[i]), i32 => @bitCast(i32, air.extra[i]), - InternPool.Index => @intToEnum(InternPool.Index, air.extra[i]), + InternPool.Index => @enumFromInt(InternPool.Index, air.extra[i]), else => @compileError("bad field type: " ++ @typeName(field.type)), }; i += 1; @@ -1491,12 +1491,12 @@ pub fn deinit(air: *Air, gpa: std.mem.Allocator) void { pub const ref_start_index: u32 = InternPool.static_len; pub fn indexToRef(inst: Inst.Index) Inst.Ref { - return @intToEnum(Inst.Ref, ref_start_index + inst); + return @enumFromInt(Inst.Ref, ref_start_index + inst); } pub fn refToIndex(inst: Inst.Ref) ?Inst.Index { assert(inst != .none); - const ref_int = @enumToInt(inst); + const ref_int = @intFromEnum(inst); if (ref_int >= ref_start_index) { return ref_int - ref_start_index; } else { @@ -1511,9 +1511,9 @@ pub fn refToIndexAllowNone(inst: Inst.Ref) ?Inst.Index { /// Returns `null` if runtime-known. pub fn value(air: Air, inst: Inst.Ref, mod: *Module) !?Value { - const ref_int = @enumToInt(inst); + const ref_int = @intFromEnum(inst); if (ref_int < ref_start_index) { - const ip_index = @intToEnum(InternPool.Index, ref_int); + const ip_index = @enumFromInt(InternPool.Index, ref_int); return ip_index.toValue(); } const inst_index = @intCast(Air.Inst.Index, ref_int - ref_start_index); diff --git a/src/AstGen.zig b/src/AstGen.zig index 05087042698c..f1acd7e3e3c2 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -82,7 +82,7 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void { inline for (fields) |field| { astgen.extra.items[i] = switch (field.type) { u32 => @field(extra, field.name), - Zir.Inst.Ref => @enumToInt(@field(extra, field.name)), + Zir.Inst.Ref => @intFromEnum(@field(extra, field.name)), i32 => @bitCast(u32, @field(extra, field.name)), Zir.Inst.Call.Flags => @bitCast(u32, @field(extra, field.name)), Zir.Inst.BuiltinCall.Flags => @bitCast(u32, @field(extra, field.name)), @@ -168,7 +168,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { try lowerAstErrors(&astgen); } - const err_index = @enumToInt(Zir.ExtraIndex.compile_errors); + const err_index = @intFromEnum(Zir.ExtraIndex.compile_errors); if (astgen.compile_errors.items.len == 0) { astgen.extra.items[err_index] = 0; } else { @@ -184,7 +184,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { } } - const imports_index = @enumToInt(Zir.ExtraIndex.imports); + const imports_index = @intFromEnum(Zir.ExtraIndex.imports); if (astgen.imports.count() == 0) { astgen.extra.items[imports_index] = 0; } else { @@ -1513,7 +1513,7 @@ fn arrayInitExprRlNone( for (elements) |elem_init| { const elem_ref = try expr(gz, scope, .{ .rl = .none }, elem_init); - astgen.extra.items[extra_index] = @enumToInt(elem_ref); + astgen.extra.items[extra_index] = @intFromEnum(elem_ref); extra_index += 1; } return try gz.addPlNodePayloadIndex(tag, node, payload_index); @@ -1530,13 +1530,13 @@ fn arrayInitExprInner( ) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; - const len = elements.len + @boolToInt(array_ty_inst != .none); + const len = elements.len + @intFromBool(array_ty_inst != .none); const payload_index = try addExtra(astgen, Zir.Inst.MultiOp{ .operands_len = @intCast(u32, len), }); var extra_index = try reserveExtra(astgen, len); if (array_ty_inst != .none) { - astgen.extra.items[extra_index] = @enumToInt(array_ty_inst); + astgen.extra.items[extra_index] = @intFromEnum(array_ty_inst); extra_index += 1; } @@ -1548,14 +1548,14 @@ fn arrayInitExprInner( .tag = .elem_type_index, .data = .{ .bin = .{ .lhs = array_ty_inst, - .rhs = @intToEnum(Zir.Inst.Ref, i), + .rhs = @enumFromInt(Zir.Inst.Ref, i), } }, }); break :ri ResultInfo{ .rl = .{ .coerced_ty = ty_expr } }; } else ResultInfo{ .rl = .{ .none = {} } }; const elem_ref = try expr(gz, scope, ri, elem_init); - astgen.extra.items[extra_index] = @enumToInt(elem_ref); + astgen.extra.items[extra_index] = @intFromEnum(elem_ref); extra_index += 1; } @@ -3515,17 +3515,17 @@ fn ptrType( .src_node = gz.nodeIndexToRelative(node), }); if (sentinel_ref != .none) { - gz.astgen.extra.appendAssumeCapacity(@enumToInt(sentinel_ref)); + gz.astgen.extra.appendAssumeCapacity(@intFromEnum(sentinel_ref)); } if (align_ref != .none) { - gz.astgen.extra.appendAssumeCapacity(@enumToInt(align_ref)); + gz.astgen.extra.appendAssumeCapacity(@intFromEnum(align_ref)); } if (addrspace_ref != .none) { - gz.astgen.extra.appendAssumeCapacity(@enumToInt(addrspace_ref)); + gz.astgen.extra.appendAssumeCapacity(@intFromEnum(addrspace_ref)); } if (bit_start_ref != .none) { - gz.astgen.extra.appendAssumeCapacity(@enumToInt(bit_start_ref)); - gz.astgen.extra.appendAssumeCapacity(@enumToInt(bit_end_ref)); + gz.astgen.extra.appendAssumeCapacity(@intFromEnum(bit_start_ref)); + gz.astgen.extra.appendAssumeCapacity(@intFromEnum(bit_end_ref)); } const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len); @@ -3644,10 +3644,10 @@ const WipMembers = struct { assert(index < self.decls_start); const bit_bag: u32 = if (self.decl_index % decls_per_u32 == 0) 0 else self.payload.items[index]; self.payload.items[index] = (bit_bag >> bits_per_decl) | - (@as(u32, @boolToInt(is_pub)) << 28) | - (@as(u32, @boolToInt(is_export)) << 29) | - (@as(u32, @boolToInt(has_align)) << 30) | - (@as(u32, @boolToInt(has_section_or_addrspace)) << 31); + (@as(u32, @intFromBool(is_pub)) << 28) | + (@as(u32, @intFromBool(is_export)) << 29) | + (@as(u32, @intFromBool(has_align)) << 30) | + (@as(u32, @intFromBool(has_section_or_addrspace)) << 31); self.decl_index += 1; } @@ -3659,7 +3659,7 @@ const WipMembers = struct { bit_bag >>= bits_per_field; comptime var i = 0; inline while (i < bits_per_field) : (i += 1) { - bit_bag |= @as(u32, @boolToInt(bits[i])) << (32 - bits_per_field + i); + bit_bag |= @as(u32, @intFromBool(bits[i])) << (32 - bits_per_field + i); } self.payload.items[index] = bit_bag; self.field_index += 1; @@ -4233,11 +4233,11 @@ fn globalVarDecl( wip_members.appendToDecl(block_inst); wip_members.appendToDecl(doc_comment_index); // doc_comment wip if (align_inst != .none) { - wip_members.appendToDecl(@enumToInt(align_inst)); + wip_members.appendToDecl(@intFromEnum(align_inst)); } if (has_section_or_addrspace) { - wip_members.appendToDecl(@enumToInt(section_inst)); - wip_members.appendToDecl(@enumToInt(addrspace_inst)); + wip_members.appendToDecl(@intFromEnum(section_inst)); + wip_members.appendToDecl(@intFromEnum(addrspace_inst)); } } @@ -4727,7 +4727,7 @@ fn structDeclInner( wip_members.appendToField(@intCast(u32, astgen.scratch.items.len - old_scratch_len)); block_scope.instructions.items.len = block_scope.instructions_top; } else { - wip_members.appendToField(@enumToInt(field_type)); + wip_members.appendToField(@intFromEnum(field_type)); } if (have_align) { @@ -4878,13 +4878,13 @@ fn unionDeclInner( if (have_type) { const field_type = try typeExpr(&block_scope, &namespace.base, member.ast.type_expr); - wip_members.appendToField(@enumToInt(field_type)); + wip_members.appendToField(@intFromEnum(field_type)); } else if (arg_inst == .none and auto_enum_tok == null) { return astgen.failNode(member_node, "union field missing type", .{}); } if (have_align) { const align_inst = try expr(&block_scope, &block_scope.base, .{ .rl = .{ .ty = .u32_type } }, member.ast.align_expr); - wip_members.appendToField(@enumToInt(align_inst)); + wip_members.appendToField(@intFromEnum(align_inst)); } if (have_value) { if (arg_inst == .none) { @@ -4916,7 +4916,7 @@ fn unionDeclInner( ); } const tag_value = try expr(&block_scope, &block_scope.base, .{ .rl = .{ .ty = arg_inst } }, member.ast.value_expr); - wip_members.appendToField(@enumToInt(tag_value)); + wip_members.appendToField(@intFromEnum(tag_value)); } } @@ -5167,7 +5167,7 @@ fn containerDecl( } namespace.base.tag = .enum_namespace; const tag_value_inst = try expr(&block_scope, &namespace.base, .{ .rl = .{ .ty = arg_inst } }, member.ast.value_expr); - wip_members.appendToField(@enumToInt(tag_value_inst)); + wip_members.appendToField(@intFromEnum(tag_value_inst)); } } @@ -5846,7 +5846,7 @@ fn ifExpr( else .err_union_payload_unsafe; const payload_inst = try then_scope.addUnNode(tag, cond.inst, then_node); - const token_name_index = payload_token + @boolToInt(payload_is_ref); + const token_name_index = payload_token + @intFromBool(payload_is_ref); const ident_name = try astgen.identAsString(token_name_index); const token_name_str = tree.tokenSlice(token_name_index); if (mem.eql(u8, "_", token_name_str)) @@ -6000,8 +6000,8 @@ fn setCondBrPayload( const astgen = then_scope.astgen; const then_body = then_scope.instructionsSliceUpto(else_scope); const else_body = else_scope.instructionsSlice(); - const then_body_len = astgen.countBodyLenAfterFixups(then_body) + @boolToInt(then_break != 0); - const else_body_len = astgen.countBodyLenAfterFixups(else_body) + @boolToInt(else_break != 0); + const then_body_len = astgen.countBodyLenAfterFixups(then_body) + @intFromBool(then_break != 0); + const else_body_len = astgen.countBodyLenAfterFixups(else_body) + @intFromBool(else_break != 0); try astgen.extra.ensureUnusedCapacity( astgen.gpa, @typeInfo(Zir.Inst.CondBr).Struct.fields.len + then_body_len + else_body_len, @@ -6036,8 +6036,8 @@ fn setCondBrPayloadElideBlockStorePtr( const else_body = else_scope.instructionsSlice(); const has_then_break = then_break != 0; const has_else_break = else_break != 0; - const then_body_len = astgen.countBodyLenAfterFixups(then_body) + @boolToInt(has_then_break); - const else_body_len = astgen.countBodyLenAfterFixups(else_body) + @boolToInt(has_else_break); + const then_body_len = astgen.countBodyLenAfterFixups(then_body) + @intFromBool(has_then_break); + const else_body_len = astgen.countBodyLenAfterFixups(else_body) + @intFromBool(has_else_break); try astgen.extra.ensureUnusedCapacity( astgen.gpa, @typeInfo(Zir.Inst.CondBr).Struct.fields.len + then_body_len + else_body_len, @@ -6197,7 +6197,7 @@ fn whileExpr( const ident_bytes = tree.tokenSlice(ident_token); if (mem.eql(u8, "_", ident_bytes)) break :s &then_scope.base; - const payload_name_loc = payload_token + @boolToInt(payload_is_ref); + const payload_name_loc = payload_token + @intFromBool(payload_is_ref); const ident_name = try astgen.identAsString(payload_name_loc); try astgen.detectLocalShadowing(&then_scope.base, ident_name, payload_name_loc, ident_bytes, .capture); payload_val_scope = .{ @@ -6439,7 +6439,7 @@ fn forExpr( for (for_full.ast.inputs, 0..) |input, i_usize| { const i = @intCast(u32, i_usize); const capture_is_ref = token_tags[capture_token] == .asterisk; - const ident_tok = capture_token + @boolToInt(capture_is_ref); + const ident_tok = capture_token + @intFromBool(capture_is_ref); const is_discard = mem.eql(u8, tree.tokenSlice(ident_tok), "_"); if (is_discard and capture_is_ref) { @@ -6567,7 +6567,7 @@ fn forExpr( for (for_full.ast.inputs, 0..) |input, i_usize| { const i = @intCast(u32, i_usize); const capture_is_ref = token_tags[capture_token] == .asterisk; - const ident_tok = capture_token + @boolToInt(capture_is_ref); + const ident_tok = capture_token + @intFromBool(capture_is_ref); const capture_name = tree.tokenSlice(ident_tok); // Skip over the comma, and on to the next capture (or the ending pipe character). capture_token = ident_tok + 2; @@ -6591,7 +6591,7 @@ fn forExpr( // indexables, we use it as an element index. This is so similar // that they can share the same code paths, branching only on the // ZIR tag. - const switch_cond = (@as(u2, @boolToInt(capture_is_ref)) << 1) | @boolToInt(is_counter); + const switch_cond = (@as(u2, @intFromBool(capture_is_ref)) << 1) | @intFromBool(is_counter); const tag: Zir.Inst.Tag = switch (switch_cond) { 0b00 => .elem_val, 0b01 => .add, @@ -6842,7 +6842,7 @@ fn switchExpr( const payloads = &astgen.scratch; const scratch_top = astgen.scratch.items.len; const case_table_start = scratch_top; - const scalar_case_table = case_table_start + @boolToInt(special_prong != .none); + const scalar_case_table = case_table_start + @intFromBool(special_prong != .none); const multi_case_table = scalar_case_table + scalar_cases_len; const case_table_end = multi_case_table + multi_cases_len; try astgen.scratch.resize(gpa, case_table_end); @@ -6971,7 +6971,7 @@ fn switchExpr( items_len += 1; const item_inst = try comptimeExpr(parent_gz, scope, item_ri, item_node); - try payloads.append(gpa, @enumToInt(item_inst)); + try payloads.append(gpa, @intFromEnum(item_inst)); } // ranges @@ -6983,7 +6983,7 @@ fn switchExpr( const first = try comptimeExpr(parent_gz, scope, item_ri, node_datas[range].lhs); const last = try comptimeExpr(parent_gz, scope, item_ri, node_datas[range].rhs); try payloads.appendSlice(gpa, &[_]u32{ - @enumToInt(first), @enumToInt(last), + @intFromEnum(first), @intFromEnum(last), }); } @@ -7000,7 +7000,7 @@ fn switchExpr( try payloads.resize(gpa, header_index + 2); // item, body_len const item_node = case.ast.values[0]; const item_inst = try comptimeExpr(parent_gz, scope, item_ri, item_node); - payloads.items[header_index] = @enumToInt(item_inst); + payloads.items[header_index] = @intFromEnum(item_inst); break :blk header_index + 1; }; @@ -7069,8 +7069,8 @@ fn switchExpr( try parent_gz.instructions.append(gpa, switch_block); try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlock).Struct.fields.len + - @boolToInt(multi_cases_len != 0) + - @boolToInt(any_has_tag_capture) + + @intFromBool(multi_cases_len != 0) + + @intFromBool(any_has_tag_capture) + payloads.items.len - case_table_end); const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.SwitchBlock{ @@ -7633,8 +7633,8 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node: const gpa = astgen.gpa; var big_int = try std.math.big.int.Managed.init(gpa); defer big_int.deinit(); - const prefix_offset = @as(u8, 2) * @boolToInt(base != .decimal); - big_int.setString(@enumToInt(base), bytes[prefix_offset..]) catch |err| switch (err) { + const prefix_offset = @as(u8, 2) * @intFromBool(base != .decimal); + big_int.setString(@intFromEnum(base), bytes[prefix_offset..]) catch |err| switch (err) { error.InvalidCharacter => unreachable, // caught in `parseNumberLiteral` error.InvalidBase => unreachable, // we only pass 16, 8, 2, see above error.OutOfMemory => return error.OutOfMemory, @@ -7739,7 +7739,7 @@ fn asmExpr( }, else => .{ .tag = .asm_expr, - .tmpl = @enumToInt(try comptimeExpr(gz, scope, .{ .rl = .none }, full.ast.template)), + .tmpl = @intFromEnum(try comptimeExpr(gz, scope, .{ .rl = .none }, full.ast.template)), }, }; @@ -7977,7 +7977,7 @@ fn typeOf( for (args, 0..) |arg, i| { const param_ref = try reachableExpr(&typeof_scope, &typeof_scope.base, .{ .rl = .none }, arg, node); - astgen.extra.items[args_index + i] = @enumToInt(param_ref); + astgen.extra.items[args_index + i] = @intFromEnum(param_ref); } _ = try typeof_scope.addBreak(.break_inline, refToIndex(typeof_inst).?, .void_value); @@ -8026,7 +8026,7 @@ fn minMax( var extra_index = try reserveExtra(gz.astgen, args.len); for (args) |arg| { const arg_ref = try expr(gz, scope, .{ .rl = .none }, arg); - astgen.extra.items[extra_index] = @enumToInt(arg_ref); + astgen.extra.items[extra_index] = @intFromEnum(arg_ref); extra_index += 1; } const tag: Zir.Inst.Extended = switch (op) { @@ -8101,7 +8101,7 @@ fn builtinCall( var extra_index = try reserveExtra(gz.astgen, params.len); for (params) |param| { const param_ref = try expr(gz, scope, .{ .rl = .none }, param); - astgen.extra.items[extra_index] = @enumToInt(param_ref); + astgen.extra.items[extra_index] = @intFromEnum(param_ref); extra_index += 1; } const result = try gz.addExtendedMultiOpPayloadIndex(.compile_log, payload_index, params.len); @@ -8335,7 +8335,7 @@ fn builtinCall( .tag = .extended, .data = .{ .extended = .{ .opcode = .reify, - .small = @enumToInt(gz.anon_name_strategy), + .small = @intFromEnum(gz.anon_name_strategy), .operand = payload_index, } }, }); @@ -9050,7 +9050,7 @@ fn callExpr( .callee = callee_obj, .flags = .{ .pop_error_return_trace = !propagate_error_trace, - .packed_modifier = @intCast(Zir.Inst.Call.Flags.PackedModifier, @enumToInt(modifier)), + .packed_modifier = @intCast(Zir.Inst.Call.Flags.PackedModifier, @intFromEnum(modifier)), .args_len = @intCast(Zir.Inst.Call.Flags.PackedArgsLen, call.ast.params.len), }, }); @@ -9071,7 +9071,7 @@ fn callExpr( .field_name_start = callee_field.field_name_start, .flags = .{ .pop_error_return_trace = !propagate_error_trace, - .packed_modifier = @intCast(Zir.Inst.Call.Flags.PackedModifier, @enumToInt(modifier)), + .packed_modifier = @intCast(Zir.Inst.Call.Flags.PackedModifier, @intFromEnum(modifier)), .args_len = @intCast(Zir.Inst.Call.Flags.PackedArgsLen, call.ast.params.len), }, }); @@ -10266,80 +10266,80 @@ fn rvalue( }, .ty => |ty_inst| { // Quickly eliminate some common, unnecessary type coercion. - const as_ty = @as(u64, @enumToInt(Zir.Inst.Ref.type_type)) << 32; - const as_comptime_int = @as(u64, @enumToInt(Zir.Inst.Ref.comptime_int_type)) << 32; - const as_bool = @as(u64, @enumToInt(Zir.Inst.Ref.bool_type)) << 32; - const as_usize = @as(u64, @enumToInt(Zir.Inst.Ref.usize_type)) << 32; - const as_void = @as(u64, @enumToInt(Zir.Inst.Ref.void_type)) << 32; - switch ((@as(u64, @enumToInt(ty_inst)) << 32) | @as(u64, @enumToInt(result))) { - as_ty | @enumToInt(Zir.Inst.Ref.u1_type), - as_ty | @enumToInt(Zir.Inst.Ref.u8_type), - as_ty | @enumToInt(Zir.Inst.Ref.i8_type), - as_ty | @enumToInt(Zir.Inst.Ref.u16_type), - as_ty | @enumToInt(Zir.Inst.Ref.u29_type), - as_ty | @enumToInt(Zir.Inst.Ref.i16_type), - as_ty | @enumToInt(Zir.Inst.Ref.u32_type), - as_ty | @enumToInt(Zir.Inst.Ref.i32_type), - as_ty | @enumToInt(Zir.Inst.Ref.u64_type), - as_ty | @enumToInt(Zir.Inst.Ref.i64_type), - as_ty | @enumToInt(Zir.Inst.Ref.u128_type), - as_ty | @enumToInt(Zir.Inst.Ref.i128_type), - as_ty | @enumToInt(Zir.Inst.Ref.usize_type), - as_ty | @enumToInt(Zir.Inst.Ref.isize_type), - as_ty | @enumToInt(Zir.Inst.Ref.c_char_type), - as_ty | @enumToInt(Zir.Inst.Ref.c_short_type), - as_ty | @enumToInt(Zir.Inst.Ref.c_ushort_type), - as_ty | @enumToInt(Zir.Inst.Ref.c_int_type), - as_ty | @enumToInt(Zir.Inst.Ref.c_uint_type), - as_ty | @enumToInt(Zir.Inst.Ref.c_long_type), - as_ty | @enumToInt(Zir.Inst.Ref.c_ulong_type), - as_ty | @enumToInt(Zir.Inst.Ref.c_longlong_type), - as_ty | @enumToInt(Zir.Inst.Ref.c_ulonglong_type), - as_ty | @enumToInt(Zir.Inst.Ref.c_longdouble_type), - as_ty | @enumToInt(Zir.Inst.Ref.f16_type), - as_ty | @enumToInt(Zir.Inst.Ref.f32_type), - as_ty | @enumToInt(Zir.Inst.Ref.f64_type), - as_ty | @enumToInt(Zir.Inst.Ref.f80_type), - as_ty | @enumToInt(Zir.Inst.Ref.f128_type), - as_ty | @enumToInt(Zir.Inst.Ref.anyopaque_type), - as_ty | @enumToInt(Zir.Inst.Ref.bool_type), - as_ty | @enumToInt(Zir.Inst.Ref.void_type), - as_ty | @enumToInt(Zir.Inst.Ref.type_type), - as_ty | @enumToInt(Zir.Inst.Ref.anyerror_type), - as_ty | @enumToInt(Zir.Inst.Ref.comptime_int_type), - as_ty | @enumToInt(Zir.Inst.Ref.comptime_float_type), - as_ty | @enumToInt(Zir.Inst.Ref.noreturn_type), - as_ty | @enumToInt(Zir.Inst.Ref.anyframe_type), - as_ty | @enumToInt(Zir.Inst.Ref.null_type), - as_ty | @enumToInt(Zir.Inst.Ref.undefined_type), - as_ty | @enumToInt(Zir.Inst.Ref.enum_literal_type), - as_ty | @enumToInt(Zir.Inst.Ref.atomic_order_type), - as_ty | @enumToInt(Zir.Inst.Ref.atomic_rmw_op_type), - as_ty | @enumToInt(Zir.Inst.Ref.calling_convention_type), - as_ty | @enumToInt(Zir.Inst.Ref.address_space_type), - as_ty | @enumToInt(Zir.Inst.Ref.float_mode_type), - as_ty | @enumToInt(Zir.Inst.Ref.reduce_op_type), - as_ty | @enumToInt(Zir.Inst.Ref.call_modifier_type), - as_ty | @enumToInt(Zir.Inst.Ref.prefetch_options_type), - as_ty | @enumToInt(Zir.Inst.Ref.export_options_type), - as_ty | @enumToInt(Zir.Inst.Ref.extern_options_type), - as_ty | @enumToInt(Zir.Inst.Ref.type_info_type), - as_ty | @enumToInt(Zir.Inst.Ref.manyptr_u8_type), - as_ty | @enumToInt(Zir.Inst.Ref.manyptr_const_u8_type), - as_ty | @enumToInt(Zir.Inst.Ref.manyptr_const_u8_sentinel_0_type), - as_ty | @enumToInt(Zir.Inst.Ref.single_const_pointer_to_comptime_int_type), - as_ty | @enumToInt(Zir.Inst.Ref.slice_const_u8_type), - as_ty | @enumToInt(Zir.Inst.Ref.slice_const_u8_sentinel_0_type), - as_ty | @enumToInt(Zir.Inst.Ref.anyerror_void_error_union_type), - as_ty | @enumToInt(Zir.Inst.Ref.generic_poison_type), - as_ty | @enumToInt(Zir.Inst.Ref.empty_struct_type), - as_comptime_int | @enumToInt(Zir.Inst.Ref.zero), - as_comptime_int | @enumToInt(Zir.Inst.Ref.one), - as_bool | @enumToInt(Zir.Inst.Ref.bool_true), - as_bool | @enumToInt(Zir.Inst.Ref.bool_false), - as_usize | @enumToInt(Zir.Inst.Ref.zero_usize), - as_usize | @enumToInt(Zir.Inst.Ref.one_usize), - as_void | @enumToInt(Zir.Inst.Ref.void_value), + const as_ty = @as(u64, @intFromEnum(Zir.Inst.Ref.type_type)) << 32; + const as_comptime_int = @as(u64, @intFromEnum(Zir.Inst.Ref.comptime_int_type)) << 32; + const as_bool = @as(u64, @intFromEnum(Zir.Inst.Ref.bool_type)) << 32; + const as_usize = @as(u64, @intFromEnum(Zir.Inst.Ref.usize_type)) << 32; + const as_void = @as(u64, @intFromEnum(Zir.Inst.Ref.void_type)) << 32; + switch ((@as(u64, @intFromEnum(ty_inst)) << 32) | @as(u64, @intFromEnum(result))) { + as_ty | @intFromEnum(Zir.Inst.Ref.u1_type), + as_ty | @intFromEnum(Zir.Inst.Ref.u8_type), + as_ty | @intFromEnum(Zir.Inst.Ref.i8_type), + as_ty | @intFromEnum(Zir.Inst.Ref.u16_type), + as_ty | @intFromEnum(Zir.Inst.Ref.u29_type), + as_ty | @intFromEnum(Zir.Inst.Ref.i16_type), + as_ty | @intFromEnum(Zir.Inst.Ref.u32_type), + as_ty | @intFromEnum(Zir.Inst.Ref.i32_type), + as_ty | @intFromEnum(Zir.Inst.Ref.u64_type), + as_ty | @intFromEnum(Zir.Inst.Ref.i64_type), + as_ty | @intFromEnum(Zir.Inst.Ref.u128_type), + as_ty | @intFromEnum(Zir.Inst.Ref.i128_type), + as_ty | @intFromEnum(Zir.Inst.Ref.usize_type), + as_ty | @intFromEnum(Zir.Inst.Ref.isize_type), + as_ty | @intFromEnum(Zir.Inst.Ref.c_char_type), + as_ty | @intFromEnum(Zir.Inst.Ref.c_short_type), + as_ty | @intFromEnum(Zir.Inst.Ref.c_ushort_type), + as_ty | @intFromEnum(Zir.Inst.Ref.c_int_type), + as_ty | @intFromEnum(Zir.Inst.Ref.c_uint_type), + as_ty | @intFromEnum(Zir.Inst.Ref.c_long_type), + as_ty | @intFromEnum(Zir.Inst.Ref.c_ulong_type), + as_ty | @intFromEnum(Zir.Inst.Ref.c_longlong_type), + as_ty | @intFromEnum(Zir.Inst.Ref.c_ulonglong_type), + as_ty | @intFromEnum(Zir.Inst.Ref.c_longdouble_type), + as_ty | @intFromEnum(Zir.Inst.Ref.f16_type), + as_ty | @intFromEnum(Zir.Inst.Ref.f32_type), + as_ty | @intFromEnum(Zir.Inst.Ref.f64_type), + as_ty | @intFromEnum(Zir.Inst.Ref.f80_type), + as_ty | @intFromEnum(Zir.Inst.Ref.f128_type), + as_ty | @intFromEnum(Zir.Inst.Ref.anyopaque_type), + as_ty | @intFromEnum(Zir.Inst.Ref.bool_type), + as_ty | @intFromEnum(Zir.Inst.Ref.void_type), + as_ty | @intFromEnum(Zir.Inst.Ref.type_type), + as_ty | @intFromEnum(Zir.Inst.Ref.anyerror_type), + as_ty | @intFromEnum(Zir.Inst.Ref.comptime_int_type), + as_ty | @intFromEnum(Zir.Inst.Ref.comptime_float_type), + as_ty | @intFromEnum(Zir.Inst.Ref.noreturn_type), + as_ty | @intFromEnum(Zir.Inst.Ref.anyframe_type), + as_ty | @intFromEnum(Zir.Inst.Ref.null_type), + as_ty | @intFromEnum(Zir.Inst.Ref.undefined_type), + as_ty | @intFromEnum(Zir.Inst.Ref.enum_literal_type), + as_ty | @intFromEnum(Zir.Inst.Ref.atomic_order_type), + as_ty | @intFromEnum(Zir.Inst.Ref.atomic_rmw_op_type), + as_ty | @intFromEnum(Zir.Inst.Ref.calling_convention_type), + as_ty | @intFromEnum(Zir.Inst.Ref.address_space_type), + as_ty | @intFromEnum(Zir.Inst.Ref.float_mode_type), + as_ty | @intFromEnum(Zir.Inst.Ref.reduce_op_type), + as_ty | @intFromEnum(Zir.Inst.Ref.call_modifier_type), + as_ty | @intFromEnum(Zir.Inst.Ref.prefetch_options_type), + as_ty | @intFromEnum(Zir.Inst.Ref.export_options_type), + as_ty | @intFromEnum(Zir.Inst.Ref.extern_options_type), + as_ty | @intFromEnum(Zir.Inst.Ref.type_info_type), + as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_u8_type), + as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_const_u8_type), + as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_const_u8_sentinel_0_type), + as_ty | @intFromEnum(Zir.Inst.Ref.single_const_pointer_to_comptime_int_type), + as_ty | @intFromEnum(Zir.Inst.Ref.slice_const_u8_type), + as_ty | @intFromEnum(Zir.Inst.Ref.slice_const_u8_sentinel_0_type), + as_ty | @intFromEnum(Zir.Inst.Ref.anyerror_void_error_union_type), + as_ty | @intFromEnum(Zir.Inst.Ref.generic_poison_type), + as_ty | @intFromEnum(Zir.Inst.Ref.empty_struct_type), + as_comptime_int | @intFromEnum(Zir.Inst.Ref.zero), + as_comptime_int | @intFromEnum(Zir.Inst.Ref.one), + as_bool | @intFromEnum(Zir.Inst.Ref.bool_true), + as_bool | @intFromEnum(Zir.Inst.Ref.bool_false), + as_usize | @intFromEnum(Zir.Inst.Ref.zero_usize), + as_usize | @intFromEnum(Zir.Inst.Ref.one_usize), + as_void | @intFromEnum(Zir.Inst.Ref.void_value), => return result, // type of result is already correct // Need an explicit type coercion instruction. @@ -11429,8 +11429,8 @@ const GenZir = struct { fancyFnExprExtraLen(astgen, cc_body, args.cc_ref) + fancyFnExprExtraLen(astgen, ret_body, ret_ref) + body_len + src_locs.len + - @boolToInt(args.lib_name != 0) + - @boolToInt(args.noalias_bits != 0), + @intFromBool(args.lib_name != 0) + + @intFromBool(args.noalias_bits != 0), ); const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.FuncFancy{ .param_block = args.param_block, @@ -11468,7 +11468,7 @@ const GenZir = struct { const inst_data = zir_datas[align_body[align_body.len - 1]].@"break"; astgen.extra.items[inst_data.payload_index] = new_index; } else if (args.align_ref != .none) { - astgen.extra.appendAssumeCapacity(@enumToInt(args.align_ref)); + astgen.extra.appendAssumeCapacity(@intFromEnum(args.align_ref)); } if (addrspace_body.len != 0) { astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, addrspace_body)); @@ -11476,7 +11476,7 @@ const GenZir = struct { const inst_data = zir_datas[addrspace_body[addrspace_body.len - 1]].@"break"; astgen.extra.items[inst_data.payload_index] = new_index; } else if (args.addrspace_ref != .none) { - astgen.extra.appendAssumeCapacity(@enumToInt(args.addrspace_ref)); + astgen.extra.appendAssumeCapacity(@intFromEnum(args.addrspace_ref)); } if (section_body.len != 0) { astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, section_body)); @@ -11484,7 +11484,7 @@ const GenZir = struct { const inst_data = zir_datas[section_body[section_body.len - 1]].@"break"; astgen.extra.items[inst_data.payload_index] = new_index; } else if (args.section_ref != .none) { - astgen.extra.appendAssumeCapacity(@enumToInt(args.section_ref)); + astgen.extra.appendAssumeCapacity(@intFromEnum(args.section_ref)); } if (cc_body.len != 0) { astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, cc_body)); @@ -11492,7 +11492,7 @@ const GenZir = struct { const inst_data = zir_datas[cc_body[cc_body.len - 1]].@"break"; astgen.extra.items[inst_data.payload_index] = new_index; } else if (args.cc_ref != .none) { - astgen.extra.appendAssumeCapacity(@enumToInt(args.cc_ref)); + astgen.extra.appendAssumeCapacity(@intFromEnum(args.cc_ref)); } if (ret_body.len != 0) { astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, ret_body)); @@ -11500,7 +11500,7 @@ const GenZir = struct { const inst_data = zir_datas[ret_body[ret_body.len - 1]].@"break"; astgen.extra.items[inst_data.payload_index] = new_index; } else if (ret_ref != .none) { - astgen.extra.appendAssumeCapacity(@enumToInt(ret_ref)); + astgen.extra.appendAssumeCapacity(@intFromEnum(ret_ref)); } if (args.noalias_bits != 0) { @@ -11542,7 +11542,7 @@ const GenZir = struct { const ret_body_len = if (ret_body.len != 0) countBodyLenAfterFixups(astgen, ret_body) else - @boolToInt(ret_ref != .none); + @intFromBool(ret_ref != .none); const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.Func{ .param_block = args.param_block, @@ -11556,7 +11556,7 @@ const GenZir = struct { const inst_data = zir_datas[ret_body[ret_body.len - 1]].@"break"; astgen.extra.items[inst_data.payload_index] = new_index; } else if (ret_ref != .none) { - astgen.extra.appendAssumeCapacity(@enumToInt(ret_ref)); + astgen.extra.appendAssumeCapacity(@intFromEnum(ret_ref)); } astgen.appendBodyWithFixups(body); astgen.extra.appendSliceAssumeCapacity(src_locs); @@ -11587,7 +11587,7 @@ const GenZir = struct { fn fancyFnExprExtraLen(astgen: *AstGen, body: []Zir.Inst.Index, ref: Zir.Inst.Ref) u32 { // In the case of non-empty body, there is one for the body length, // and then one for each instruction. - return countBodyLenAfterFixups(astgen, body) + @boolToInt(ref != .none); + return countBodyLenAfterFixups(astgen, body) + @intFromBool(ref != .none); } fn addVar(gz: *GenZir, args: struct { @@ -11607,9 +11607,9 @@ const GenZir = struct { try astgen.extra.ensureUnusedCapacity( gpa, @typeInfo(Zir.Inst.ExtendedVar).Struct.fields.len + - @boolToInt(args.lib_name != 0) + - @boolToInt(args.align_inst != .none) + - @boolToInt(args.init != .none), + @intFromBool(args.lib_name != 0) + + @intFromBool(args.align_inst != .none) + + @intFromBool(args.init != .none), ); const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.ExtendedVar{ .var_type = args.var_type, @@ -11618,10 +11618,10 @@ const GenZir = struct { astgen.extra.appendAssumeCapacity(args.lib_name); } if (args.align_inst != .none) { - astgen.extra.appendAssumeCapacity(@enumToInt(args.align_inst)); + astgen.extra.appendAssumeCapacity(@intFromEnum(args.align_inst)); } if (args.init != .none) { - astgen.extra.appendAssumeCapacity(@enumToInt(args.init)); + astgen.extra.appendAssumeCapacity(@intFromEnum(args.init)); } const new_index = @intCast(Zir.Inst.Index, astgen.instructions.len); @@ -12208,23 +12208,23 @@ const GenZir = struct { try astgen.extra.ensureUnusedCapacity( gpa, @typeInfo(Zir.Inst.AllocExtended).Struct.fields.len + - @as(usize, @boolToInt(args.type_inst != .none)) + - @as(usize, @boolToInt(args.align_inst != .none)), + @as(usize, @intFromBool(args.type_inst != .none)) + + @as(usize, @intFromBool(args.align_inst != .none)), ); const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.AllocExtended{ .src_node = gz.nodeIndexToRelative(args.node), }); if (args.type_inst != .none) { - astgen.extra.appendAssumeCapacity(@enumToInt(args.type_inst)); + astgen.extra.appendAssumeCapacity(@intFromEnum(args.type_inst)); } if (args.align_inst != .none) { - astgen.extra.appendAssumeCapacity(@enumToInt(args.align_inst)); + astgen.extra.appendAssumeCapacity(@intFromEnum(args.align_inst)); } - const has_type: u4 = @boolToInt(args.type_inst != .none); - const has_align: u4 = @boolToInt(args.align_inst != .none); - const is_const: u4 = @boolToInt(args.is_const); - const is_comptime: u4 = @boolToInt(args.is_comptime); + const has_type: u4 = @intFromBool(args.type_inst != .none); + const has_align: u4 = @intFromBool(args.align_inst != .none); + const is_const: u4 = @intFromBool(args.is_const); + const is_comptime: u4 = @intFromBool(args.is_comptime); const small: u16 = has_type | (has_align << 1) | (is_const << 2) | (is_comptime << 3); const new_index = @intCast(Zir.Inst.Index, astgen.instructions.len); @@ -12284,7 +12284,7 @@ const GenZir = struct { const small: u16 = @intCast(u16, args.outputs.len) | @intCast(u16, args.inputs.len << 5) | @intCast(u16, args.clobbers.len << 10) | - (@as(u16, @boolToInt(args.is_volatile)) << 15); + (@as(u16, @intFromBool(args.is_volatile)) << 15); const new_index = @intCast(Zir.Inst.Index, astgen.instructions.len); astgen.instructions.appendAssumeCapacity(.{ @@ -12362,7 +12362,7 @@ const GenZir = struct { if (args.backing_int_ref != .none) { astgen.extra.appendAssumeCapacity(args.backing_int_body_len); if (args.backing_int_body_len == 0) { - astgen.extra.appendAssumeCapacity(@enumToInt(args.backing_int_ref)); + astgen.extra.appendAssumeCapacity(@intFromEnum(args.backing_int_ref)); } } astgen.instructions.set(inst, .{ @@ -12405,7 +12405,7 @@ const GenZir = struct { astgen.extra.appendAssumeCapacity(@bitCast(u32, node_offset)); } if (args.tag_type != .none) { - astgen.extra.appendAssumeCapacity(@enumToInt(args.tag_type)); + astgen.extra.appendAssumeCapacity(@intFromEnum(args.tag_type)); } if (args.body_len != 0) { astgen.extra.appendAssumeCapacity(args.body_len); @@ -12454,7 +12454,7 @@ const GenZir = struct { astgen.extra.appendAssumeCapacity(@bitCast(u32, node_offset)); } if (args.tag_type != .none) { - astgen.extra.appendAssumeCapacity(@enumToInt(args.tag_type)); + astgen.extra.appendAssumeCapacity(@intFromEnum(args.tag_type)); } if (args.body_len != 0) { astgen.extra.appendAssumeCapacity(args.body_len); @@ -12948,10 +12948,10 @@ fn lowerAstErrors(astgen: *AstGen) !void { var notes: std.ArrayListUnmanaged(u32) = .{}; defer notes.deinit(gpa); - if (token_tags[parse_err.token + @boolToInt(parse_err.token_is_prev)] == .invalid) { - const tok = parse_err.token + @boolToInt(parse_err.token_is_prev); - const bad_off = @intCast(u32, tree.tokenSlice(parse_err.token + @boolToInt(parse_err.token_is_prev)).len); - const byte_abs = token_starts[parse_err.token + @boolToInt(parse_err.token_is_prev)] + bad_off; + if (token_tags[parse_err.token + @intFromBool(parse_err.token_is_prev)] == .invalid) { + const tok = parse_err.token + @intFromBool(parse_err.token_is_prev); + const bad_off = @intCast(u32, tree.tokenSlice(parse_err.token + @intFromBool(parse_err.token_is_prev)).len); + const byte_abs = token_starts[parse_err.token + @intFromBool(parse_err.token_is_prev)] + bad_off; try notes.append(gpa, try astgen.errNoteTokOff(tok, bad_off, "invalid byte: '{'}'", .{ std.zig.fmtEscapes(tree.source[byte_abs..][0..1]), })); diff --git a/src/Autodoc.zig b/src/Autodoc.zig index e3580483fb40..68ddcc94c458 100644 --- a/src/Autodoc.zig +++ b/src/Autodoc.zig @@ -107,10 +107,10 @@ pub fn generateZirData(self: *Autodoc) !void { const file = self.comp_module.import_table.get(abs_root_src_path).?; // file is expected to be present in the import table // Append all the types in Zir.Inst.Ref. { - comptime std.debug.assert(@enumToInt(InternPool.Index.first_type) == 0); + comptime std.debug.assert(@intFromEnum(InternPool.Index.first_type) == 0); var i: u32 = 0; - while (i <= @enumToInt(InternPool.Index.last_type)) : (i += 1) { - const ip_index = @intToEnum(InternPool.Index, i); + while (i <= @intFromEnum(InternPool.Index.last_type)) : (i += 1) { + const ip_index = @enumFromInt(InternPool.Index, i); var tmpbuf = std.ArrayList(u8).init(self.arena); if (ip_index == .generic_poison_type) { // Not a real type, doesn't have a normal name @@ -696,14 +696,14 @@ const DocData = struct { jsw.whitespace = opts.whitespace; try jsw.beginArray(); try jsw.arrayElem(); - try jsw.emitNumber(@enumToInt(active_tag)); + try jsw.emitNumber(@intFromEnum(active_tag)); inline for (comptime std.meta.fields(Type)) |case| { if (@field(Type, case.name) == active_tag) { const current_value = @field(self, case.name); inline for (comptime std.meta.fields(case.type)) |f| { try jsw.arrayElem(); if (f.type == std.builtin.Type.Pointer.Size) { - try jsw.emitNumber(@enumToInt(@field(current_value, f.name))); + try jsw.emitNumber(@intFromEnum(@field(current_value, f.name))); } else { try std.json.stringify(@field(current_value, f.name), opts, w); jsw.state_index -= 1; @@ -756,7 +756,7 @@ const DocData = struct { as: As, sizeOf: usize, // index in `exprs` bitSizeOf: usize, // index in `exprs` - enumToInt: usize, // index in `exprs` + intFromEnum: usize, // index in `exprs` compileError: usize, //index in `exprs` errorSets: usize, string: []const u8, // direct value @@ -956,7 +956,7 @@ fn walkInstruction( if (result.found_existing) { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = result.value_ptr.main }, }; } @@ -1005,7 +1005,7 @@ fn walkInstruction( const result = try self.files.getOrPut(self.arena, new_file.file); if (result.found_existing) { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = result.value_ptr.* }, }; } @@ -1033,8 +1033,8 @@ fn walkInstruction( }, .ret_type => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, - .expr = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, + .expr = .{ .type = @intFromEnum(Ref.type_type) }, }; }, .ret_node => { @@ -1093,7 +1093,7 @@ fn walkInstruction( try self.types.append(self.arena, .{ .Array = .{ .len = .{ .int = .{ .value = str.len } }, - .child = .{ .type = @enumToInt(Ref.u8_type) }, + .child = .{ .type = @intFromEnum(Ref.u8_type) }, .sentinel = .{ .int = .{ .value = 0, .negated = false, @@ -1155,7 +1155,7 @@ fn walkInstruction( .int => { const int = data[inst_index].int; return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.comptime_int_type) }, .expr = .{ .int = .{ .value = int } }, }; }, @@ -1176,7 +1176,7 @@ fn walkInstruction( const as_string = try big_int.toStringAlloc(self.arena, 10, .lower); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.comptime_int_type) }, .expr = .{ .int_big = .{ .value = as_string } }, }; }, @@ -1422,7 +1422,7 @@ fn walkInstruction( } }; return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .binOpIndex = binop_index }, }; }, @@ -1466,7 +1466,7 @@ fn walkInstruction( } }; return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.bool_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.bool_type) }, .expr = .{ .binOpIndex = binop_index }, }; }, @@ -1516,7 +1516,7 @@ fn walkInstruction( self.exprs.items[bin_index] = .{ .builtin = .{ .name = @tagName(tags[inst_index]), .param = param_index } }; return DocData.WalkResult{ - .typeRef = param.typeRef orelse .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = param.typeRef orelse .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .builtinIndex = bin_index }, }; }, @@ -1578,7 +1578,7 @@ fn walkInstruction( self.exprs.items[binop_index] = .{ .builtinBin = .{ .name = @tagName(tags[inst_index]), .lhs = lhs_index, .rhs = rhs_index } }; return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .builtinBinIndex = binop_index }, }; }, @@ -1608,7 +1608,7 @@ fn walkInstruction( } }); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .errorUnion = type_slot_index }, }; }, @@ -1637,7 +1637,7 @@ fn walkInstruction( } }); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .errorSets = type_slot_index }, }; }, @@ -1670,7 +1670,7 @@ fn walkInstruction( // present in json var sentinel: ?DocData.Expr = null; if (ptr.flags.has_sentinel) { - const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + const ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); const ref_result = try self.walkRef(file, parent_scope, parent_src, ref, false); sentinel = ref_result.expr; extra_index += 1; @@ -1678,21 +1678,21 @@ fn walkInstruction( var @"align": ?DocData.Expr = null; if (ptr.flags.has_align) { - const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + const ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); const ref_result = try self.walkRef(file, parent_scope, parent_src, ref, false); @"align" = ref_result.expr; extra_index += 1; } var address_space: ?DocData.Expr = null; if (ptr.flags.has_addrspace) { - const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + const ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); const ref_result = try self.walkRef(file, parent_scope, parent_src, ref, false); address_space = ref_result.expr; extra_index += 1; } var bit_start: ?DocData.Expr = null; if (ptr.flags.has_bit_range) { - const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + const ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); const ref_result = try self.walkRef(file, parent_scope, parent_src, ref, false); address_space = ref_result.expr; extra_index += 1; @@ -1700,7 +1700,7 @@ fn walkInstruction( var host_size: ?DocData.Expr = null; if (ptr.flags.has_bit_range) { - const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + const ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); const ref_result = try self.walkRef(file, parent_scope, parent_src, ref, false); host_size = ref_result.expr; } @@ -1724,7 +1724,7 @@ fn walkInstruction( }, }); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = type_slot_index }, }; }, @@ -1744,7 +1744,7 @@ fn walkInstruction( }); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = type_slot_index }, }; }, @@ -1764,7 +1764,7 @@ fn walkInstruction( }, }); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = type_slot_index }, }; }, @@ -1863,7 +1863,7 @@ fn walkInstruction( .float => { const float = data[inst_index].float; return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.comptime_float_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.comptime_float_type) }, .expr = .{ .float = float }, }; }, @@ -1872,7 +1872,7 @@ fn walkInstruction( const pl_node = data[inst_index].pl_node; const extra = file.zir.extraData(Zir.Inst.Float128, pl_node.payload_index); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.comptime_float_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.comptime_float_type) }, .expr = .{ .float128 = extra.data.get() }, }; }, @@ -1913,7 +1913,7 @@ fn walkInstruction( const operand_index = self.exprs.items.len; try self.exprs.append(self.arena, operand.expr); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.comptime_int_type) }, .expr = .{ .sizeOf = operand_index }, }; }, @@ -1950,8 +1950,8 @@ fn walkInstruction( try self.exprs.append(self.arena, operand.expr); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, - .expr = .{ .enumToInt = operand_index }, + .typeRef = .{ .type = @intFromEnum(Ref.comptime_int_type) }, + .expr = .{ .intFromEnum = operand_index }, }; }, .switch_block => { @@ -1992,7 +1992,7 @@ fn walkInstruction( // } }); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .switchIndex = switch_index }, }; }, @@ -2109,7 +2109,7 @@ fn walkInstruction( }); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = operand_idx }, }; }, @@ -2210,13 +2210,13 @@ fn walkInstruction( }); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = self.types.items.len - 1 }, }; }, .block => { const res = DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .comptimeExpr = self.comptime_exprs.items.len }, }; const pl_node = data[inst_index].pl_node; @@ -2233,7 +2233,7 @@ fn walkInstruction( parent_src, getBlockInlineBreak(file.zir, inst_index) orelse { const res = DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .comptimeExpr = self.comptime_exprs.items.len }, }; const pl_node = data[inst_index].pl_node; @@ -2376,7 +2376,7 @@ fn walkInstruction( }); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = type_slot_index }, }; }, @@ -2600,7 +2600,7 @@ fn walkInstruction( // anyway, but maybe we should put it elsewhere. } return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = type_slot_index }, }; }, @@ -2620,7 +2620,7 @@ fn walkInstruction( }; if (small.has_init) { - const var_init_ref = @intToEnum(Ref, file.zir.extra[extra_index]); + const var_init_ref = @enumFromInt(Ref, file.zir.extra[extra_index]); const var_init = try self.walkRef(file, parent_scope, parent_src, var_init_ref, need_type); value.expr = var_init.expr; value.typeRef = var_init.typeRef; @@ -2656,7 +2656,7 @@ fn walkInstruction( const tag_type_ref: ?Ref = if (small.has_tag_type) blk: { const tag_type = file.zir.extra[extra_index]; extra_index += 1; - const tag_ref = @intToEnum(Ref, tag_type); + const tag_ref = @enumFromInt(Ref, tag_type); break :blk tag_ref; } else null; @@ -2751,7 +2751,7 @@ fn walkInstruction( } return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = type_slot_index }, }; }, @@ -2781,7 +2781,7 @@ fn walkInstruction( const tag_type: ?DocData.Expr = if (small.has_tag_type) blk: { const tag_type = file.zir.extra[extra_index]; extra_index += 1; - const tag_ref = @intToEnum(Ref, tag_type); + const tag_ref = @enumFromInt(Ref, tag_type); const wr = try self.walkRef(file, parent_scope, parent_src, tag_ref, false); break :blk wr.expr; } else null; @@ -2839,7 +2839,7 @@ fn walkInstruction( const value_expr: ?DocData.Expr = if (has_value) blk: { const value_ref = file.zir.extra[extra_index]; extra_index += 1; - const value = try self.walkRef(file, &scope, src_info, @intToEnum(Ref, value_ref), false); + const value = try self.walkRef(file, &scope, src_info, @enumFromInt(Ref, value_ref), false); break :blk value.expr; } else null; try field_values.append(self.arena, value_expr); @@ -2887,7 +2887,7 @@ fn walkInstruction( // anyway, but maybe we should put it elsewhere. } return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = type_slot_index }, }; }, @@ -2928,7 +2928,7 @@ fn walkInstruction( const backing_int_body_len = file.zir.extra[extra_index]; extra_index += 1; // backing_int_body_len if (backing_int_body_len == 0) { - const backing_int_ref = @intToEnum(Ref, file.zir.extra[extra_index]); + const backing_int_ref = @enumFromInt(Ref, file.zir.extra[extra_index]); const backing_int_res = try self.walkRef(file, &scope, src_info, backing_int_ref, true); backing_int = backing_int_res.expr; extra_index += 1; // backing_int_ref @@ -3006,13 +3006,13 @@ fn walkInstruction( // anyway, but maybe we should put it elsewhere. } return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = type_slot_index }, }; }, .this => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .this = parent_scope.enclosing_type.?, // We know enclosing_type is always present @@ -3038,7 +3038,7 @@ fn walkInstruction( self.exprs.items[bin_index] = .{ .builtin = .{ .name = @tagName(extended.opcode), .param = param_index } }; return DocData.WalkResult{ - .typeRef = param.typeRef orelse .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = param.typeRef orelse .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .builtinIndex = bin_index }, }; }, @@ -3058,7 +3058,7 @@ fn walkInstruction( return DocData.WalkResult{ // from docs we know they return u32 - .typeRef = .{ .type = @enumToInt(Ref.u32_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.u32_type) }, .expr = .{ .builtinIndex = bin_index }, }; }, @@ -3131,7 +3131,7 @@ fn walkInstruction( .failure_order = failure_order_index, } }); return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .cmpxchgIndex = cmpxchg_index }, }; }, @@ -3280,21 +3280,21 @@ fn analyzeDecl( extra_index += 1; const align_inst: Zir.Inst.Ref = if (!has_align) .none else inst: { - const inst = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + const inst = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); extra_index += 1; break :inst inst; }; _ = align_inst; const section_inst: Zir.Inst.Ref = if (!has_section_or_addrspace) .none else inst: { - const inst = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + const inst = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); extra_index += 1; break :inst inst; }; _ = section_inst; const addrspace_inst: Zir.Inst.Ref = if (!has_section_or_addrspace) .none else inst: { - const inst = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + const inst = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); extra_index += 1; break :inst inst; }; @@ -4111,7 +4111,7 @@ fn analyzeFancyFunction( var align_index: ?usize = null; if (extra.data.bits.has_align_ref) { - const align_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + const align_ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); align_index = self.exprs.items.len; _ = try self.walkRef(file, scope, parent_src, align_ref, false); extra_index += 1; @@ -4128,7 +4128,7 @@ fn analyzeFancyFunction( var addrspace_index: ?usize = null; if (extra.data.bits.has_addrspace_ref) { - const addrspace_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + const addrspace_ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); addrspace_index = self.exprs.items.len; _ = try self.walkRef(file, scope, parent_src, addrspace_ref, false); extra_index += 1; @@ -4145,7 +4145,7 @@ fn analyzeFancyFunction( var section_index: ?usize = null; if (extra.data.bits.has_section_ref) { - const section_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + const section_ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); section_index = self.exprs.items.len; _ = try self.walkRef(file, scope, parent_src, section_ref, false); extra_index += 1; @@ -4162,7 +4162,7 @@ fn analyzeFancyFunction( var cc_index: ?usize = null; if (extra.data.bits.has_cc_ref and !extra.data.bits.has_cc_body) { - const cc_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + const cc_ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); const cc_expr = try self.walkRef(file, scope, parent_src, cc_ref, false); cc_index = self.exprs.items.len; @@ -4211,7 +4211,7 @@ fn analyzeFancyFunction( const generic_ret: ?DocData.Expr = switch (ret_type_ref) { .type => |t| blk: { if (fn_info.body.len == 0) break :blk null; - if (t == @enumToInt(Ref.type_type)) { + if (t == @intFromEnum(Ref.type_type)) { break :blk try self.getGenericReturnType( file, scope, @@ -4249,7 +4249,7 @@ fn analyzeFancyFunction( }; return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = type_slot_index }, }; } @@ -4354,7 +4354,7 @@ fn analyzeFunction( const generic_ret: ?DocData.Expr = switch (ret_type_ref) { .type => |t| blk: { if (fn_info.body.len == 0) break :blk null; - if (t == @enumToInt(Ref.type_type)) { + if (t == @intFromEnum(Ref.type_type)) { break :blk try self.getGenericReturnType( file, scope, @@ -4395,7 +4395,7 @@ fn analyzeFunction( }; return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, .expr = .{ .type = type_slot_index }, }; } @@ -4467,7 +4467,7 @@ fn collectUnionFieldInfo( const doc_comment_index = file.zir.extra[extra_index]; extra_index += 1; const field_type = if (has_type) - @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]) + @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]) else .void_type; if (has_type) extra_index += 1; @@ -4561,7 +4561,7 @@ fn collectStructFieldInfo( if (has_type_body) { fields[field_i].type_body_len = file.zir.extra[extra_index]; } else { - fields[field_i].type_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); + fields[field_i].type_ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]); } extra_index += 1; @@ -4651,13 +4651,13 @@ fn walkRef( ) AutodocErrors!DocData.WalkResult { if (ref == .none) { return .{ .expr = .{ .comptimeExpr = 0 } }; - } else if (@enumToInt(ref) <= @enumToInt(InternPool.Index.last_type)) { + } else if (@intFromEnum(ref) <= @intFromEnum(InternPool.Index.last_type)) { // We can just return a type that indexes into `types` with the // enum value because in the beginning we pre-filled `types` with // the types that are listed in `Ref`. return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(std.builtin.TypeId.Type) }, - .expr = .{ .type = @enumToInt(ref) }, + .typeRef = .{ .type = @intFromEnum(std.builtin.TypeId.Type) }, + .expr = .{ .type = @intFromEnum(ref) }, }; } else if (Zir.refToIndex(ref)) |zir_index| { return self.walkInstruction(file, parent_scope, parent_src, zir_index, need_type); @@ -4676,26 +4676,26 @@ fn walkRef( }, .zero => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.comptime_int_type) }, .expr = .{ .int = .{ .value = 0 } }, }; }, .one => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.comptime_int_type) }, .expr = .{ .int = .{ .value = 1 } }, }; }, .void_value => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.void_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.void_type) }, .expr = .{ .void = .{} }, }; }, .unreachable_value => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.noreturn_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.noreturn_type) }, .expr = .{ .@"unreachable" = .{} }, }; }, @@ -4704,13 +4704,13 @@ fn walkRef( }, .bool_true => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.bool_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.bool_type) }, .expr = .{ .bool = true }, }; }, .bool_false => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.bool_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.bool_type) }, .expr = .{ .bool = false }, }; }, @@ -4719,37 +4719,37 @@ fn walkRef( }, .zero_usize => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.usize_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.usize_type) }, .expr = .{ .int = .{ .value = 0 } }, }; }, .one_usize => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.usize_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.usize_type) }, .expr = .{ .int = .{ .value = 1 } }, }; }, .calling_convention_type => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.type_type) }, - .expr = .{ .type = @enumToInt(Ref.calling_convention_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.type_type) }, + .expr = .{ .type = @intFromEnum(Ref.calling_convention_type) }, }; }, .calling_convention_c => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.calling_convention_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.calling_convention_type) }, .expr = .{ .enumLiteral = "C" }, }; }, .calling_convention_inline => { return DocData.WalkResult{ - .typeRef = .{ .type = @enumToInt(Ref.calling_convention_type) }, + .typeRef = .{ .type = @intFromEnum(Ref.calling_convention_type) }, .expr = .{ .enumLiteral = "Inline" }, }; }, // .generic_poison => { // return DocData.WalkResult{ .int = .{ - // .type = @enumToInt(Ref.comptime_int_type), + // .type = @intFromEnum(Ref.comptime_int_type), // .value = 1, // } }; // }, diff --git a/src/Compilation.zig b/src/Compilation.zig index 739b747e3233..4c8b901fd1d7 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1050,7 +1050,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { const is_enabled = options.target.cpu.features.isEnabled(index); if (feature.llvm_name) |llvm_name| { - const plus_or_minus = "-+"[@boolToInt(is_enabled)]; + const plus_or_minus = "-+"[@intFromBool(is_enabled)]; try buf.ensureUnusedCapacity(2 + llvm_name.len); buf.appendAssumeCapacity(plus_or_minus); buf.appendSliceAssumeCapacity(llvm_name); @@ -2506,7 +2506,7 @@ pub fn makeBinFileWritable(self: *Compilation) !void { /// This function is temporally single-threaded. pub fn totalErrorCount(self: *Compilation) u32 { var total: usize = self.failed_c_objects.count() + self.misc_failures.count() + - @boolToInt(self.alloc_failure_occurred) + self.lld_errors.items.len; + @intFromBool(self.alloc_failure_occurred) + self.lld_errors.items.len; if (self.bin_file.options.module) |module| { total += module.failed_exports.count(); @@ -2520,7 +2520,7 @@ pub fn totalErrorCount(self: *Compilation) u32 { } else { const file = entry.key_ptr.*; assert(file.zir_loaded); - const payload_index = file.zir.extra[@enumToInt(Zir.ExtraIndex.compile_errors)]; + const payload_index = file.zir.extra[@intFromEnum(Zir.ExtraIndex.compile_errors)]; assert(payload_index != 0); const header = file.zir.extraData(Zir.Inst.CompileErrors, payload_index); total += header.data.items_len; @@ -2551,14 +2551,14 @@ pub fn totalErrorCount(self: *Compilation) u32 { // The "no entry point found" error only counts if there are no semantic analysis errors. if (total == 0) { - total += @boolToInt(self.link_error_flags.no_entry_point_found); + total += @intFromBool(self.link_error_flags.no_entry_point_found); } - total += @boolToInt(self.link_error_flags.missing_libc); + total += @intFromBool(self.link_error_flags.missing_libc); // Compile log errors only count if there are no other errors. if (total == 0) { if (self.bin_file.options.module) |module| { - total += @boolToInt(module.compile_log_decls.count() != 0); + total += @intFromBool(module.compile_log_decls.count() != 0); } } @@ -2604,7 +2604,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle { }); const notes_start = try bundle.reserveNotes(notes_len); for (notes_start.., lld_error.context_lines) |note, context_line| { - bundle.extra.items[note] = @enumToInt(bundle.addErrorMessageAssumeCapacity(.{ + bundle.extra.items[note] = @intFromEnum(bundle.addErrorMessageAssumeCapacity(.{ .msg = try bundle.addString(context_line), })); } @@ -2697,10 +2697,10 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle { .notes_len = 2, }); const notes_start = try bundle.reserveNotes(2); - bundle.extra.items[notes_start + 0] = @enumToInt(try bundle.addErrorMessage(.{ + bundle.extra.items[notes_start + 0] = @intFromEnum(try bundle.addErrorMessage(.{ .msg = try bundle.addString("run 'zig libc -h' to learn about libc installations"), })); - bundle.extra.items[notes_start + 1] = @enumToInt(try bundle.addErrorMessage(.{ + bundle.extra.items[notes_start + 1] = @intFromEnum(try bundle.addErrorMessage(.{ .msg = try bundle.addString("run 'zig targets' to see the targets for which zig can always provide libc"), })); } @@ -2895,7 +2895,7 @@ pub fn addModuleErrorMsg(mod: *Module, eb: *ErrorBundle.Wip, module_err_msg: Mod const notes_start = try eb.reserveNotes(notes_len); for (notes_start.., notes.keys()) |i, note| { - eb.extra.items[i] = @enumToInt(try eb.addErrorMessage(note)); + eb.extra.items[i] = @intFromEnum(try eb.addErrorMessage(note)); } } @@ -2903,7 +2903,7 @@ pub fn addZirErrorMessages(eb: *ErrorBundle.Wip, file: *Module.File) !void { assert(file.zir_loaded); assert(file.tree_loaded); assert(file.source_loaded); - const payload_index = file.zir.extra[@enumToInt(Zir.ExtraIndex.compile_errors)]; + const payload_index = file.zir.extra[@intFromEnum(Zir.ExtraIndex.compile_errors)]; assert(payload_index != 0); const gpa = eb.gpa; @@ -2963,7 +2963,7 @@ pub fn addZirErrorMessages(eb: *ErrorBundle.Wip, file: *Module.File) !void { const src_path = try file.fullPath(gpa); defer gpa.free(src_path); - eb.extra.items[note_i] = @enumToInt(try eb.addErrorMessage(.{ + eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{ .msg = try eb.addString(msg), .src_loc = try eb.addSourceLocation(.{ .src_path = try eb.addString(src_path), @@ -3466,7 +3466,7 @@ fn workerAstGenFile( // If we experience an error preemptively fetching the // file, just ignore it and let it happen again later during Sema. assert(file.zir_loaded); - const imports_index = file.zir.extra[@enumToInt(Zir.ExtraIndex.imports)]; + const imports_index = file.zir.extra[@intFromEnum(Zir.ExtraIndex.imports)]; if (imports_index != 0) { const extra = file.zir.extraData(Zir.Inst.Imports, imports_index); var import_i: u32 = 0; @@ -4239,10 +4239,10 @@ pub fn addCCArgs( } try argv.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{ - @enumToInt(comp.libcxx_abi_version), + @intFromEnum(comp.libcxx_abi_version), })); try argv.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{ - @enumToInt(comp.libcxx_abi_version), + @intFromEnum(comp.libcxx_abi_version), })); } @@ -4307,7 +4307,7 @@ pub fn addCCArgs( if (feature.llvm_name) |llvm_name| { argv.appendSliceAssumeCapacity(&[_][]const u8{ "-Xclang", "-target-feature", "-Xclang" }); - const plus_or_minus = "-+"[@boolToInt(is_enabled)]; + const plus_or_minus = "-+"[@intFromBool(is_enabled)]; const arg = try std.fmt.allocPrint(arena, "{c}{s}", .{ plus_or_minus, llvm_name }); argv.appendAssumeCapacity(arg); } diff --git a/src/InternPool.zig b/src/InternPool.zig index 4da4790e2f93..221b56b88aff 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -80,7 +80,7 @@ const KeyAdapter = struct { pub fn eql(ctx: @This(), a: Key, b_void: void, b_map_index: usize) bool { _ = b_void; - return ctx.intern_pool.indexToKey(@intToEnum(Index, b_map_index)).eql(a, ctx.intern_pool); + return ctx.intern_pool.indexToKey(@enumFromInt(Index, b_map_index)).eql(a, ctx.intern_pool); } pub fn hash(ctx: @This(), a: Key) u32 { @@ -95,7 +95,7 @@ pub const OptionalMapIndex = enum(u32) { pub fn unwrap(oi: OptionalMapIndex) ?MapIndex { if (oi == .none) return null; - return @intToEnum(MapIndex, @enumToInt(oi)); + return @enumFromInt(MapIndex, @intFromEnum(oi)); } }; @@ -104,7 +104,7 @@ pub const MapIndex = enum(u32) { _, pub fn toOptional(i: MapIndex) OptionalMapIndex { - return @intToEnum(OptionalMapIndex, @enumToInt(i)); + return @enumFromInt(OptionalMapIndex, @intFromEnum(i)); } }; @@ -114,7 +114,7 @@ pub const RuntimeIndex = enum(u32) { _, pub fn increment(ri: *RuntimeIndex) void { - ri.* = @intToEnum(RuntimeIndex, @enumToInt(ri.*) + 1); + ri.* = @enumFromInt(RuntimeIndex, @intFromEnum(ri.*) + 1); } }; @@ -130,11 +130,11 @@ pub const NullTerminatedString = enum(u32) { _, pub fn toString(self: NullTerminatedString) String { - return @intToEnum(String, @enumToInt(self)); + return @enumFromInt(String, @intFromEnum(self)); } pub fn toOptional(self: NullTerminatedString) OptionalNullTerminatedString { - return @intToEnum(OptionalNullTerminatedString, @enumToInt(self)); + return @enumFromInt(OptionalNullTerminatedString, @intFromEnum(self)); } const Adapter = struct { @@ -147,14 +147,14 @@ pub const NullTerminatedString = enum(u32) { pub fn hash(ctx: @This(), a: NullTerminatedString) u32 { _ = ctx; - return std.hash.uint32(@enumToInt(a)); + return std.hash.uint32(@intFromEnum(a)); } }; /// Compare based on integer value alone, ignoring the string contents. pub fn indexLessThan(ctx: void, a: NullTerminatedString, b: NullTerminatedString) bool { _ = ctx; - return @enumToInt(a) < @enumToInt(b); + return @intFromEnum(a) < @intFromEnum(b); } pub fn toUnsigned(self: NullTerminatedString, ip: *const InternPool) ?u32 { @@ -196,7 +196,7 @@ pub const OptionalNullTerminatedString = enum(u32) { pub fn unwrap(oi: OptionalNullTerminatedString) ?NullTerminatedString { if (oi == .none) return null; - return @intToEnum(NullTerminatedString, @enumToInt(oi)); + return @enumFromInt(NullTerminatedString, @intFromEnum(oi)); } }; @@ -279,7 +279,7 @@ pub const Key = union(enum) { /// Look up field index based on field name. pub fn nameIndex(self: ErrorSetType, ip: *const InternPool, name: NullTerminatedString) ?u32 { - const map = &ip.maps.items[@enumToInt(self.names_map.unwrap().?)]; + const map = &ip.maps.items[@intFromEnum(self.names_map.unwrap().?)]; const adapter: NullTerminatedString.Adapter = .{ .strings = self.names }; const field_index = map.getIndexAdapted(name, adapter) orelse return null; return @intCast(u32, field_index); @@ -417,7 +417,7 @@ pub const Key = union(enum) { /// Look up field index based on field name. pub fn nameIndex(self: EnumType, ip: *const InternPool, name: NullTerminatedString) ?u32 { - const map = &ip.maps.items[@enumToInt(self.names_map.unwrap().?)]; + const map = &ip.maps.items[@intFromEnum(self.names_map.unwrap().?)]; const adapter: NullTerminatedString.Adapter = .{ .strings = self.names }; const field_index = map.getIndexAdapted(name, adapter) orelse return null; return @intCast(u32, field_index); @@ -437,7 +437,7 @@ pub const Key = union(enum) { else => unreachable, }; if (self.values_map.unwrap()) |values_map| { - const map = &ip.maps.items[@enumToInt(values_map)]; + const map = &ip.maps.items[@intFromEnum(values_map)]; const adapter: Index.Adapter = .{ .indexes = self.values }; const field_index = map.getIndexAdapted(int_tag_val, adapter) orelse return null; return @intCast(u32, field_index); @@ -691,7 +691,7 @@ pub const Key = union(enum) { pub fn hash64(key: Key, ip: *const InternPool) u64 { const asBytes = std.mem.asBytes; const KeyTag = @typeInfo(Key).Union.tag_type.?; - const seed = @enumToInt(@as(KeyTag, key)); + const seed = @intFromEnum(@as(KeyTag, key)); return switch (key) { // TODO: assert no padding in these types inline .ptr_type, @@ -714,8 +714,8 @@ pub const Key = union(enum) { .un, => |x| Hash.hash(seed, asBytes(&x)), - .int_type => |x| Hash.hash(seed + @enumToInt(x.signedness), asBytes(&x.bits)), - .union_type => |x| Hash.hash(seed + @enumToInt(x.runtime_tag), asBytes(&x.index)), + .int_type => |x| Hash.hash(seed + @intFromEnum(x.signedness), asBytes(&x.bits)), + .union_type => |x| Hash.hash(seed + @intFromEnum(x.runtime_tag), asBytes(&x.index)), .error_union => |x| switch (x.val) { .err_name => |y| Hash.hash(seed + 0, asBytes(&x.ty) ++ asBytes(&y)), @@ -777,7 +777,7 @@ pub const Key = union(enum) { // Int-to-ptr pointers are hashed separately than decl-referencing pointers. // This is sound due to pointer provenance rules. const addr: @typeInfo(Key.Ptr.Addr).Union.tag_type.? = ptr.addr; - const seed2 = seed + @enumToInt(addr); + const seed2 = seed + @intFromEnum(addr); const common = asBytes(&ptr.ty) ++ asBytes(&ptr.len); return switch (ptr.addr) { .decl => |x| Hash.hash(seed2, common ++ asBytes(&x)), @@ -1381,7 +1381,7 @@ pub const Index = enum(u32) { pub fn hash(ctx: @This(), a: Index) u32 { _ = ctx; - return std.hash.uint32(@enumToInt(a)); + return std.hash.uint32(@intFromEnum(a)); } }; @@ -2259,21 +2259,21 @@ pub const Alignment = enum(u6) { pub fn toByteUnitsOptional(a: Alignment) ?u64 { return switch (a) { .none => null, - _ => @as(u64, 1) << @enumToInt(a), + _ => @as(u64, 1) << @intFromEnum(a), }; } pub fn toByteUnits(a: Alignment, default: u64) u64 { return switch (a) { .none => default, - _ => @as(u64, 1) << @enumToInt(a), + _ => @as(u64, 1) << @intFromEnum(a), }; } pub fn fromByteUnits(n: u64) Alignment { if (n == 0) return .none; assert(std.math.isPowerOfTwo(n)); - return @intToEnum(Alignment, @ctz(n)); + return @enumFromInt(Alignment, @ctz(n)); } pub fn fromNonzeroByteUnits(n: u64) Alignment { @@ -2282,7 +2282,7 @@ pub const Alignment = enum(u6) { } pub fn min(a: Alignment, b: Alignment) Alignment { - return @intToEnum(Alignment, @min(@enumToInt(a), @enumToInt(b))); + return @enumFromInt(Alignment, @min(@intFromEnum(a), @intFromEnum(b))); } }; @@ -2509,10 +2509,10 @@ pub fn init(ip: *InternPool, gpa: Allocator) !void { const cc_c = ip.indexToKey(.calling_convention_c).enum_tag.int; assert(ip.indexToKey(cc_inline).int.storage.u64 == - @enumToInt(std.builtin.CallingConvention.Inline)); + @intFromEnum(std.builtin.CallingConvention.Inline)); assert(ip.indexToKey(cc_c).int.storage.u64 == - @enumToInt(std.builtin.CallingConvention.C)); + @intFromEnum(std.builtin.CallingConvention.C)); assert(ip.indexToKey(ip.typeOf(cc_inline)).int_type.bits == @typeInfo(@typeInfo(std.builtin.CallingConvention).Enum.tag_type).Int.bits); @@ -2550,7 +2550,7 @@ pub fn deinit(ip: *InternPool, gpa: Allocator) void { pub fn indexToKey(ip: *const InternPool, index: Index) Key { assert(index != .none); - const item = ip.items.get(@enumToInt(index)); + const item = ip.items.get(@intFromEnum(index)); const data = item.data; return switch (item.tag) { .type_int_signed => .{ @@ -2581,8 +2581,8 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { .sentinel = .none, } }; }, - .simple_type => .{ .simple_type = @intToEnum(SimpleType, data) }, - .simple_value => .{ .simple_value = @intToEnum(SimpleValue, data) }, + .simple_type => .{ .simple_type = @enumFromInt(SimpleType, data) }, + .simple_value => .{ .simple_value = @enumFromInt(SimpleValue, data) }, .type_vector => { const vector_info = ip.extraData(Vector, data); @@ -2601,8 +2601,8 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { return .{ .ptr_type = ptr_info }; }, - .type_optional => .{ .opt_type = @intToEnum(Index, data) }, - .type_anyframe => .{ .anyframe_type = @intToEnum(Index, data) }, + .type_optional => .{ .opt_type = @enumFromInt(Index, data) }, + .type_anyframe => .{ .anyframe_type = @enumFromInt(Index, data) }, .type_error_union => .{ .error_union_type = ip.extraData(Key.ErrorUnionType, data) }, .type_error_set => { @@ -2615,12 +2615,12 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { } }; }, .type_inferred_error_set => .{ - .inferred_error_set_type = @intToEnum(Module.Fn.InferredErrorSet.Index, data), + .inferred_error_set_type = @enumFromInt(Module.Fn.InferredErrorSet.Index, data), }, .type_opaque => .{ .opaque_type = ip.extraData(Key.OpaqueType, data) }, .type_struct => { - const struct_index = @intToEnum(Module.Struct.OptionalIndex, data); + const struct_index = @enumFromInt(Module.Struct.OptionalIndex, data); const namespace = if (struct_index.unwrap()) |i| ip.structPtrConst(i).namespace.toOptional() else @@ -2632,7 +2632,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { }, .type_struct_ns => .{ .struct_type = .{ .index = .none, - .namespace = @intToEnum(Module.Namespace.Index, data).toOptional(), + .namespace = @enumFromInt(Module.Namespace.Index, data).toOptional(), } }, .type_struct_anon => { @@ -2660,15 +2660,15 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { }, .type_union_untagged => .{ .union_type = .{ - .index = @intToEnum(Module.Union.Index, data), + .index = @enumFromInt(Module.Union.Index, data), .runtime_tag = .none, } }, .type_union_tagged => .{ .union_type = .{ - .index = @intToEnum(Module.Union.Index, data), + .index = @enumFromInt(Module.Union.Index, data), .runtime_tag = .tagged, } }, .type_union_safety => .{ .union_type = .{ - .index = @intToEnum(Module.Union.Index, data), + .index = @enumFromInt(Module.Union.Index, data), .runtime_tag = .safety, } }, @@ -2693,10 +2693,10 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { .type_enum_nonexhaustive => ip.indexToKeyEnum(data, .nonexhaustive), .type_function => .{ .func_type = ip.indexToKeyFuncType(data) }, - .undef => .{ .undef = @intToEnum(Index, data) }, + .undef => .{ .undef = @enumFromInt(Index, data) }, .runtime_value => .{ .runtime_value = ip.extraData(Tag.TypeValue, data) }, .opt_null => .{ .opt = .{ - .ty = @intToEnum(Index, data), + .ty = @enumFromInt(Index, data), .val = .none, } }, .opt_payload => { @@ -2754,7 +2754,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { .ptr_elem => { // Avoid `indexToKey` recursion by asserting the tag encoding. const info = ip.extraData(PtrBaseIndex, data); - const index_item = ip.items.get(@enumToInt(info.index)); + const index_item = ip.items.get(@intFromEnum(info.index)); return switch (index_item.tag) { .int_usize => .{ .ptr = .{ .ty = info.ty, @@ -2770,7 +2770,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { .ptr_field => { // Avoid `indexToKey` recursion by asserting the tag encoding. const info = ip.extraData(PtrBaseIndex, data); - const index_item = ip.items.get(@enumToInt(info.index)); + const index_item = ip.items.get(@intFromEnum(info.index)); return switch (index_item.tag) { .int_usize => .{ .ptr = .{ .ty = info.ty, @@ -2785,7 +2785,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { }, .ptr_slice => { const info = ip.extraData(PtrSlice, data); - const ptr_item = ip.items.get(@enumToInt(info.ptr)); + const ptr_item = ip.items.get(@intFromEnum(info.ptr)); return .{ .ptr = .{ .ty = info.ty, @@ -2815,7 +2815,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { .ptr_elem => b: { // Avoid `indexToKey` recursion by asserting the tag encoding. const sub_info = ip.extraData(PtrBaseIndex, ptr_item.data); - const index_item = ip.items.get(@enumToInt(sub_info.index)); + const index_item = ip.items.get(@intFromEnum(sub_info.index)); break :b switch (index_item.tag) { .int_usize => .{ .elem = .{ .base = sub_info.base, @@ -2828,7 +2828,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { .ptr_field => b: { // Avoid `indexToKey` recursion by asserting the tag encoding. const sub_info = ip.extraData(PtrBaseIndex, ptr_item.data); - const index_item = ip.items.get(@enumToInt(sub_info.index)); + const index_item = ip.items.get(@intFromEnum(sub_info.index)); break :b switch (index_item.tag) { .int_usize => .{ .field = .{ .base = sub_info.base, @@ -2940,8 +2940,8 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { .extern_func => .{ .extern_func = ip.extraData(Tag.ExternFunc, data) }, .func => .{ .func = ip.extraData(Tag.Func, data) }, .only_possible_value => { - const ty = @intToEnum(Index, data); - const ty_item = ip.items.get(@enumToInt(ty)); + const ty = @enumFromInt(Index, data); + const ty_item = ip.items.get(@intFromEnum(ty)); return switch (ty_item.tag) { .type_array_big => { const sentinel = @ptrCast( @@ -2950,7 +2950,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { ); return .{ .aggregate = .{ .ty = ty, - .storage = .{ .elems = sentinel[0..@boolToInt(sentinel[0] != .none)] }, + .storage = .{ .elems = sentinel[0..@intFromBool(sentinel[0] != .none)] }, } }; }, .type_array_small, .type_vector => .{ .aggregate = .{ @@ -2994,7 +2994,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { const len = @intCast(u32, ip.aggregateTypeLenIncludingSentinel(extra.ty)); return .{ .aggregate = .{ .ty = extra.ty, - .storage = .{ .bytes = ip.string_bytes.items[@enumToInt(extra.bytes)..][0..len] }, + .storage = .{ .bytes = ip.string_bytes.items[@intFromEnum(extra.bytes)..][0..len] }, } }; }, .aggregate => { @@ -3029,7 +3029,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { .val = .{ .payload = extra.val }, } }; }, - .enum_literal => .{ .enum_literal = @intToEnum(NullTerminatedString, data) }, + .enum_literal => .{ .enum_literal = @enumFromInt(NullTerminatedString, data) }, .enum_tag => .{ .enum_tag = ip.extraData(Tag.EnumTag, data) }, .memoized_call => { @@ -3103,7 +3103,7 @@ fn indexToKeyBigInt(ip: *const InternPool, limb_index: u32, positive: bool) Key pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { const adapter: KeyAdapter = .{ .intern_pool = ip }; const gop = try ip.map.getOrPutAdapted(gpa, key, adapter); - if (gop.found_existing) return @intToEnum(Index, gop.index); + if (gop.found_existing) return @enumFromInt(Index, gop.index); try ip.items.ensureUnusedCapacity(gpa, 1); switch (key) { .int_type => |int_type| { @@ -3129,9 +3129,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { try ip.items.ensureUnusedCapacity(gpa, 1); ip.items.appendAssumeCapacity(.{ .tag = .type_slice, - .data = @enumToInt(ptr_type_index), + .data = @intFromEnum(ptr_type_index), }); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); } var ptr_type_adjusted = ptr_type; @@ -3155,7 +3155,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .child = array_type.child, }), }); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); } } @@ -3183,14 +3183,14 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { assert(payload_type != .none); ip.items.appendAssumeCapacity(.{ .tag = .type_optional, - .data = @enumToInt(payload_type), + .data = @intFromEnum(payload_type), }); }, .anyframe_type => |payload_type| { // payload_type might be none, indicating the type is `anyframe`. ip.items.appendAssumeCapacity(.{ .tag = .type_anyframe, - .data = @enumToInt(payload_type), + .data = @intFromEnum(payload_type), }); }, .error_union_type => |error_union_type| { @@ -3218,26 +3218,26 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .inferred_error_set_type => |ies_index| { ip.items.appendAssumeCapacity(.{ .tag = .type_inferred_error_set, - .data = @enumToInt(ies_index), + .data = @intFromEnum(ies_index), }); }, .simple_type => |simple_type| { ip.items.appendAssumeCapacity(.{ .tag = .simple_type, - .data = @enumToInt(simple_type), + .data = @intFromEnum(simple_type), }); }, .simple_value => |simple_value| { ip.items.appendAssumeCapacity(.{ .tag = .simple_value, - .data = @enumToInt(simple_value), + .data = @intFromEnum(simple_value), }); }, .undef => |ty| { assert(ty != .none); ip.items.appendAssumeCapacity(.{ .tag = .undef, - .data = @enumToInt(ty), + .data = @intFromEnum(ty), }); }, .runtime_value => |runtime_value| { @@ -3251,13 +3251,13 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .struct_type => |struct_type| { ip.items.appendAssumeCapacity(if (struct_type.index.unwrap()) |i| .{ .tag = .type_struct, - .data = @enumToInt(i), + .data = @intFromEnum(i), } else if (struct_type.namespace.unwrap()) |i| .{ .tag = .type_struct_ns, - .data = @enumToInt(i), + .data = @intFromEnum(i), } else .{ .tag = .type_struct, - .data = @enumToInt(Module.Struct.OptionalIndex.none), + .data = @intFromEnum(Module.Struct.OptionalIndex.none), }); }, @@ -3279,7 +3279,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { }); ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, anon_struct_type.types)); ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, anon_struct_type.values)); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); } assert(anon_struct_type.names.len == anon_struct_type.types.len); @@ -3297,7 +3297,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, anon_struct_type.types)); ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, anon_struct_type.values)); ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, anon_struct_type.names)); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); }, .union_type => |union_type| { @@ -3307,7 +3307,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .safety => .type_union_safety, .tagged => .type_union_tagged, }, - .data = @enumToInt(union_type.index), + .data = @intFromEnum(union_type.index), }); }, @@ -3343,7 +3343,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { }), }); ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, enum_type.names)); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); }, .explicit => return finishGetEnum(ip, gpa, enum_type, .type_enum_explicit), .nonexhaustive => return finishGetEnum(ip, gpa, enum_type, .type_enum_nonexhaustive), @@ -3540,7 +3540,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { }); }, } - assert(ptr.ty == ip.indexToKey(@intToEnum(Index, ip.items.len - 1)).ptr.ty); + assert(ptr.ty == ip.indexToKey(@enumFromInt(Index, ip.items.len - 1)).ptr.ty); }, .opt => |opt| { @@ -3548,7 +3548,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { assert(opt.val == .none or ip.indexToKey(opt.ty).opt_type == ip.typeOf(opt.val)); ip.items.appendAssumeCapacity(if (opt.val == .none) .{ .tag = .opt_null, - .data = @enumToInt(opt.ty), + .data = @intFromEnum(opt.ty), } else .{ .tag = .opt_payload, .data = try ip.addExtra(gpa, Tag.TypeValue{ @@ -3574,7 +3574,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .lazy_ty = lazy_ty, }), }); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); }, } switch (int.ty) { @@ -3715,7 +3715,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .value = casted, }), }); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); } else |_| {} const tag: Tag = if (big_int.positive) .int_positive else .int_negative; @@ -3730,7 +3730,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .value = casted, }), }); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); } var buf: [2]Limb = undefined; @@ -3772,7 +3772,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .enum_literal => |enum_literal| ip.items.appendAssumeCapacity(.{ .tag = .enum_literal, - .data = @enumToInt(enum_literal), + .data = @intFromEnum(enum_literal), }), .enum_tag => |enum_tag| { @@ -3790,7 +3790,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .empty_enum_value => |enum_or_union_ty| ip.items.appendAssumeCapacity(.{ .tag = .only_possible_value, - .data = @enumToInt(enum_or_union_ty), + .data = @intFromEnum(enum_or_union_ty), }), .float => |float| { @@ -3847,7 +3847,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .vector_type, .anon_struct_type, .struct_type => .none, else => unreachable, }; - const len_including_sentinel = len + @boolToInt(sentinel != .none); + const len_including_sentinel = len + @intFromBool(sentinel != .none); switch (aggregate.storage) { .bytes => |bytes| { assert(child == .u8_type); @@ -3891,9 +3891,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { if (len == 0) { ip.items.appendAssumeCapacity(.{ .tag = .only_possible_value, - .data = @enumToInt(aggregate.ty), + .data = @intFromEnum(aggregate.ty), }); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); } switch (ty_key) { @@ -3919,9 +3919,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { // in the aggregate fields. ip.items.appendAssumeCapacity(.{ .tag = .only_possible_value, - .data = @enumToInt(aggregate.ty), + .data = @intFromEnum(aggregate.ty), }); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); }, else => {}, } @@ -3960,7 +3960,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .elem_val = elem, }), }); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); } if (child == .u8_type) bytes: { @@ -3994,7 +3994,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { @intCast(u8, ip.indexToKey(sentinel).int.storage.u64), ); const string = if (has_internal_null) - @intToEnum(String, string_bytes_index) + @enumFromInt(String, string_bytes_index) else (try ip.getOrPutTrailingString(gpa, @intCast(usize, len_including_sentinel))).toString(); ip.items.appendAssumeCapacity(.{ @@ -4004,7 +4004,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .bytes = string, }), }); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); } try ip.extra.ensureUnusedCapacity( @@ -4018,7 +4018,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { }), }); ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, aggregate.storage.elems)); - if (sentinel != .none) ip.extra.appendAssumeCapacity(@enumToInt(sentinel)); + if (sentinel != .none) ip.extra.appendAssumeCapacity(@intFromEnum(sentinel)); }, .un => |un| { @@ -4046,7 +4046,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, memoized_call.arg_values)); }, } - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); } /// Provides API for completing an enum type after calling `getIncompleteEnum`. @@ -4060,7 +4060,7 @@ pub const IncompleteEnumType = struct { pub fn setTagType(self: @This(), ip: *InternPool, tag_ty: Index) void { assert(tag_ty == .noreturn_type or ip.isIntegerType(tag_ty)); - ip.extra.items[self.tag_ty_index] = @enumToInt(tag_ty); + ip.extra.items[self.tag_ty_index] = @intFromEnum(tag_ty); } /// Returns the already-existing field with the same name, if any. @@ -4070,7 +4070,7 @@ pub const IncompleteEnumType = struct { gpa: Allocator, name: NullTerminatedString, ) Allocator.Error!?u32 { - const map = &ip.maps.items[@enumToInt(self.names_map)]; + const map = &ip.maps.items[@intFromEnum(self.names_map)]; const field_index = map.count(); const strings = ip.extra.items[self.names_start..][0..field_index]; const adapter: NullTerminatedString.Adapter = .{ @@ -4078,7 +4078,7 @@ pub const IncompleteEnumType = struct { }; const gop = try map.getOrPutAdapted(gpa, name, adapter); if (gop.found_existing) return @intCast(u32, gop.index); - ip.extra.items[self.names_start + field_index] = @enumToInt(name); + ip.extra.items[self.names_start + field_index] = @intFromEnum(name); return null; } @@ -4090,8 +4090,8 @@ pub const IncompleteEnumType = struct { gpa: Allocator, value: Index, ) Allocator.Error!?u32 { - assert(ip.typeOf(value) == @intToEnum(Index, ip.extra.items[self.tag_ty_index])); - const map = &ip.maps.items[@enumToInt(self.values_map.unwrap().?)]; + assert(ip.typeOf(value) == @enumFromInt(Index, ip.extra.items[self.tag_ty_index])); + const map = &ip.maps.items[@intFromEnum(self.values_map.unwrap().?)]; const field_index = map.count(); const indexes = ip.extra.items[self.values_start..][0..field_index]; const adapter: Index.Adapter = .{ @@ -4099,7 +4099,7 @@ pub const IncompleteEnumType = struct { }; const gop = try map.getOrPutAdapted(gpa, value, adapter); if (gop.found_existing) return @intCast(u32, gop.index); - ip.extra.items[self.values_start + field_index] = @enumToInt(value); + ip.extra.items[self.values_start + field_index] = @intFromEnum(value); return null; } }; @@ -4156,9 +4156,9 @@ fn getIncompleteEnumAuto( .tag = .type_enum_auto, .data = extra_index, }); - ip.extra.appendNTimesAssumeCapacity(@enumToInt(Index.none), enum_type.fields_len); + ip.extra.appendNTimesAssumeCapacity(@intFromEnum(Index.none), enum_type.fields_len); return .{ - .index = @intToEnum(Index, ip.items.len - 1), + .index = @enumFromInt(Index, ip.items.len - 1), .tag_ty_index = extra_index + std.meta.fieldIndex(EnumAuto, "int_tag_type").?, .names_map = names_map, .names_start = extra_index + extra_fields_len, @@ -4207,9 +4207,9 @@ fn getIncompleteEnumExplicit( .data = extra_index, }); // This is both fields and values (if present). - ip.extra.appendNTimesAssumeCapacity(@enumToInt(Index.none), reserved_len); + ip.extra.appendNTimesAssumeCapacity(@intFromEnum(Index.none), reserved_len); return .{ - .index = @intToEnum(Index, ip.items.len - 1), + .index = @enumFromInt(Index, ip.items.len - 1), .tag_ty_index = extra_index + std.meta.fieldIndex(EnumExplicit, "int_tag_type").?, .names_map = names_map, .names_start = extra_index + extra_fields_len, @@ -4248,13 +4248,13 @@ pub fn finishGetEnum( }); ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, enum_type.names)); ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, enum_type.values)); - return @intToEnum(Index, ip.items.len - 1); + return @enumFromInt(Index, ip.items.len - 1); } pub fn getIfExists(ip: *const InternPool, key: Key) ?Index { const adapter: KeyAdapter = .{ .intern_pool = ip }; const index = ip.map.getIndexAdapted(key, adapter) orelse return null; - return @intToEnum(Index, index); + return @enumFromInt(Index, index); } pub fn getAssumeExists(ip: *const InternPool, key: Key) Index { @@ -4267,7 +4267,7 @@ fn addStringsToMap( map_index: MapIndex, strings: []const NullTerminatedString, ) Allocator.Error!void { - const map = &ip.maps.items[@enumToInt(map_index)]; + const map = &ip.maps.items[@intFromEnum(map_index)]; const adapter: NullTerminatedString.Adapter = .{ .strings = strings }; for (strings) |string| { const gop = try map.getOrPutAdapted(gpa, string, adapter); @@ -4281,7 +4281,7 @@ fn addIndexesToMap( map_index: MapIndex, indexes: []const Index, ) Allocator.Error!void { - const map = &ip.maps.items[@enumToInt(map_index)]; + const map = &ip.maps.items[@intFromEnum(map_index)]; const adapter: Index.Adapter = .{ .indexes = indexes }; for (indexes) |index| { const gop = try map.getOrPutAdapted(gpa, index, adapter); @@ -4292,7 +4292,7 @@ fn addIndexesToMap( fn addMap(ip: *InternPool, gpa: Allocator) Allocator.Error!MapIndex { const ptr = try ip.maps.addOne(gpa); ptr.* = .{}; - return @intToEnum(MapIndex, ip.maps.items.len - 1); + return @enumFromInt(MapIndex, ip.maps.items.len - 1); } /// This operation only happens under compile error conditions. @@ -4324,22 +4324,22 @@ fn addExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 { inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| { ip.extra.appendAssumeCapacity(switch (field.type) { u32 => @field(extra, field.name), - Index => @enumToInt(@field(extra, field.name)), - Module.Decl.Index => @enumToInt(@field(extra, field.name)), - Module.Namespace.Index => @enumToInt(@field(extra, field.name)), - Module.Namespace.OptionalIndex => @enumToInt(@field(extra, field.name)), - Module.Fn.Index => @enumToInt(@field(extra, field.name)), - MapIndex => @enumToInt(@field(extra, field.name)), - OptionalMapIndex => @enumToInt(@field(extra, field.name)), - RuntimeIndex => @enumToInt(@field(extra, field.name)), - String => @enumToInt(@field(extra, field.name)), - NullTerminatedString => @enumToInt(@field(extra, field.name)), - OptionalNullTerminatedString => @enumToInt(@field(extra, field.name)), + Index => @intFromEnum(@field(extra, field.name)), + Module.Decl.Index => @intFromEnum(@field(extra, field.name)), + Module.Namespace.Index => @intFromEnum(@field(extra, field.name)), + Module.Namespace.OptionalIndex => @intFromEnum(@field(extra, field.name)), + Module.Fn.Index => @intFromEnum(@field(extra, field.name)), + MapIndex => @intFromEnum(@field(extra, field.name)), + OptionalMapIndex => @intFromEnum(@field(extra, field.name)), + RuntimeIndex => @intFromEnum(@field(extra, field.name)), + String => @intFromEnum(@field(extra, field.name)), + NullTerminatedString => @intFromEnum(@field(extra, field.name)), + OptionalNullTerminatedString => @intFromEnum(@field(extra, field.name)), i32 => @bitCast(u32, @field(extra, field.name)), Tag.TypePointer.Flags => @bitCast(u32, @field(extra, field.name)), TypeFunction.Flags => @bitCast(u32, @field(extra, field.name)), Tag.TypePointer.PackedOffset => @bitCast(u32, @field(extra, field.name)), - Tag.TypePointer.VectorIndex => @enumToInt(@field(extra, field.name)), + Tag.TypePointer.VectorIndex => @intFromEnum(@field(extra, field.name)), Tag.Variable.Flags => @bitCast(u32, @field(extra, field.name)), else => @compileError("bad field type: " ++ @typeName(field.type)), }); @@ -4365,7 +4365,7 @@ fn addLimbsExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 { inline for (@typeInfo(@TypeOf(extra)).Struct.fields, 0..) |field, i| { const new: u32 = switch (field.type) { u32 => @field(extra, field.name), - Index => @enumToInt(@field(extra, field.name)), + Index => @intFromEnum(@field(extra, field.name)), else => @compileError("bad field type: " ++ @typeName(field.type)), }; if (i % 2 == 0) { @@ -4392,22 +4392,22 @@ fn extraDataTrail(ip: *const InternPool, comptime T: type, index: usize) struct const int32 = ip.extra.items[i + index]; @field(result, field.name) = switch (field.type) { u32 => int32, - Index => @intToEnum(Index, int32), - Module.Decl.Index => @intToEnum(Module.Decl.Index, int32), - Module.Namespace.Index => @intToEnum(Module.Namespace.Index, int32), - Module.Namespace.OptionalIndex => @intToEnum(Module.Namespace.OptionalIndex, int32), - Module.Fn.Index => @intToEnum(Module.Fn.Index, int32), - MapIndex => @intToEnum(MapIndex, int32), - OptionalMapIndex => @intToEnum(OptionalMapIndex, int32), - RuntimeIndex => @intToEnum(RuntimeIndex, int32), - String => @intToEnum(String, int32), - NullTerminatedString => @intToEnum(NullTerminatedString, int32), - OptionalNullTerminatedString => @intToEnum(OptionalNullTerminatedString, int32), + Index => @enumFromInt(Index, int32), + Module.Decl.Index => @enumFromInt(Module.Decl.Index, int32), + Module.Namespace.Index => @enumFromInt(Module.Namespace.Index, int32), + Module.Namespace.OptionalIndex => @enumFromInt(Module.Namespace.OptionalIndex, int32), + Module.Fn.Index => @enumFromInt(Module.Fn.Index, int32), + MapIndex => @enumFromInt(MapIndex, int32), + OptionalMapIndex => @enumFromInt(OptionalMapIndex, int32), + RuntimeIndex => @enumFromInt(RuntimeIndex, int32), + String => @enumFromInt(String, int32), + NullTerminatedString => @enumFromInt(NullTerminatedString, int32), + OptionalNullTerminatedString => @enumFromInt(OptionalNullTerminatedString, int32), i32 => @bitCast(i32, int32), Tag.TypePointer.Flags => @bitCast(Tag.TypePointer.Flags, int32), TypeFunction.Flags => @bitCast(TypeFunction.Flags, int32), Tag.TypePointer.PackedOffset => @bitCast(Tag.TypePointer.PackedOffset, int32), - Tag.TypePointer.VectorIndex => @intToEnum(Tag.TypePointer.VectorIndex, int32), + Tag.TypePointer.VectorIndex => @enumFromInt(Tag.TypePointer.VectorIndex, int32), Tag.Variable.Flags => @bitCast(Tag.Variable.Flags, int32), else => @compileError("bad field type: " ++ @typeName(field.type)), }; @@ -4439,7 +4439,7 @@ fn limbData(ip: *const InternPool, comptime T: type, index: usize) T { @field(result, field.name) = switch (field.type) { u32 => int32, - Index => @intToEnum(Index, int32), + Index => @enumFromInt(Index, int32), else => @compileError("bad field type: " ++ @typeName(field.type)), }; } @@ -4475,7 +4475,7 @@ fn limbsSliceToIndex(ip: *const InternPool, limbs: []const Limb) LimbsAsIndexes }; // TODO: https://github.com/ziglang/zig/issues/1738 return .{ - .start = @intCast(u32, @divExact(@ptrToInt(limbs.ptr) - @ptrToInt(host_slice.ptr), @sizeOf(Limb))), + .start = @intCast(u32, @divExact(@intFromPtr(limbs.ptr) - @intFromPtr(host_slice.ptr), @sizeOf(Limb))), .len = @intCast(u32, limbs.len), }; } @@ -4536,16 +4536,16 @@ pub fn slicePtrType(ip: *const InternPool, i: Index) Index { .slice_const_u8_sentinel_0_type => return .manyptr_const_u8_sentinel_0_type, else => {}, } - const item = ip.items.get(@enumToInt(i)); + const item = ip.items.get(@intFromEnum(i)); switch (item.tag) { - .type_slice => return @intToEnum(Index, item.data), + .type_slice => return @enumFromInt(Index, item.data), else => unreachable, // not a slice type } } /// Given a slice value, returns the value of the ptr field. pub fn slicePtr(ip: *const InternPool, i: Index) Index { - const item = ip.items.get(@enumToInt(i)); + const item = ip.items.get(@intFromEnum(i)); switch (item.tag) { .ptr_slice => return ip.extraData(PtrSlice, item.data).ptr, else => unreachable, // not a slice value @@ -4554,7 +4554,7 @@ pub fn slicePtr(ip: *const InternPool, i: Index) Index { /// Given a slice value, returns the value of the len field. pub fn sliceLen(ip: *const InternPool, i: Index) Index { - const item = ip.items.get(@enumToInt(i)); + const item = ip.items.get(@intFromEnum(i)); switch (item.tag) { .ptr_slice => return ip.extraData(PtrSlice, item.data).len, else => unreachable, // not a slice value @@ -4841,28 +4841,28 @@ pub fn getCoercedInts(ip: *InternPool, gpa: Allocator, int: Key.Int, new_ty: Ind pub fn indexToStructType(ip: *const InternPool, val: Index) Module.Struct.OptionalIndex { assert(val != .none); const tags = ip.items.items(.tag); - if (tags[@enumToInt(val)] != .type_struct) return .none; + if (tags[@intFromEnum(val)] != .type_struct) return .none; const datas = ip.items.items(.data); - return @intToEnum(Module.Struct.Index, datas[@enumToInt(val)]).toOptional(); + return @enumFromInt(Module.Struct.Index, datas[@intFromEnum(val)]).toOptional(); } pub fn indexToUnionType(ip: *const InternPool, val: Index) Module.Union.OptionalIndex { assert(val != .none); const tags = ip.items.items(.tag); - switch (tags[@enumToInt(val)]) { + switch (tags[@intFromEnum(val)]) { .type_union_tagged, .type_union_untagged, .type_union_safety => {}, else => return .none, } const datas = ip.items.items(.data); - return @intToEnum(Module.Union.Index, datas[@enumToInt(val)]).toOptional(); + return @enumFromInt(Module.Union.Index, datas[@intFromEnum(val)]).toOptional(); } pub fn indexToFuncType(ip: *const InternPool, val: Index) ?Key.FuncType { assert(val != .none); const tags = ip.items.items(.tag); const datas = ip.items.items(.data); - switch (tags[@enumToInt(val)]) { - .type_function => return indexToKeyFuncType(ip, datas[@enumToInt(val)]), + switch (tags[@intFromEnum(val)]) { + .type_function => return indexToKeyFuncType(ip, datas[@intFromEnum(val)]), else => return null, } } @@ -4870,17 +4870,17 @@ pub fn indexToFuncType(ip: *const InternPool, val: Index) ?Key.FuncType { pub fn indexToFunc(ip: *const InternPool, val: Index) Module.Fn.OptionalIndex { assert(val != .none); const tags = ip.items.items(.tag); - if (tags[@enumToInt(val)] != .func) return .none; + if (tags[@intFromEnum(val)] != .func) return .none; const datas = ip.items.items(.data); - return ip.extraData(Tag.Func, datas[@enumToInt(val)]).index.toOptional(); + return ip.extraData(Tag.Func, datas[@intFromEnum(val)]).index.toOptional(); } pub fn indexToInferredErrorSetType(ip: *const InternPool, val: Index) Module.Fn.InferredErrorSet.OptionalIndex { assert(val != .none); const tags = ip.items.items(.tag); - if (tags[@enumToInt(val)] != .type_inferred_error_set) return .none; + if (tags[@intFromEnum(val)] != .type_inferred_error_set) return .none; const datas = ip.items.items(.data); - return @intToEnum(Module.Fn.InferredErrorSet.Index, datas[@enumToInt(val)]).toOptional(); + return @enumFromInt(Module.Fn.InferredErrorSet.Index, datas[@intFromEnum(val)]).toOptional(); } /// includes .comptime_int_type @@ -4956,9 +4956,9 @@ pub fn isAggregateType(ip: *const InternPool, ty: Index) bool { /// The is only legal because the initializer is not part of the hash. pub fn mutateVarInit(ip: *InternPool, index: Index, init_index: Index) void { - const item = ip.items.get(@enumToInt(index)); + const item = ip.items.get(@intFromEnum(index)); assert(item.tag == .variable); - ip.extra.items[item.data + std.meta.fieldIndex(Tag.Variable, "init").?] = @enumToInt(init_index); + ip.extra.items[item.data + std.meta.fieldIndex(Tag.Variable, "init").?] = @intFromEnum(init_index); } pub fn dump(ip: *const InternPool) void { @@ -5038,7 +5038,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void { .type_enum_auto => @sizeOf(EnumAuto), .type_opaque => @sizeOf(Key.OpaqueType), .type_struct => b: { - const struct_index = @intToEnum(Module.Struct.Index, data); + const struct_index = @enumFromInt(Module.Struct.Index, data); const struct_obj = ip.structPtrConst(struct_index); break :b @sizeOf(Module.Struct) + @sizeOf(Module.Namespace) + @@ -5107,7 +5107,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void { const info = ip.extraData(Bytes, data); const len = @intCast(u32, ip.aggregateTypeLenIncludingSentinel(info.ty)); break :b @sizeOf(Bytes) + len + - @boolToInt(ip.string_bytes.items[@enumToInt(info.bytes) + len - 1] != 0); + @intFromBool(ip.string_bytes.items[@intFromEnum(info.bytes) + len - 1] != 0); }, .aggregate => b: { const info = ip.extraData(Tag.Aggregate, data); @@ -5162,8 +5162,8 @@ fn dumpAllFallible(ip: *const InternPool) anyerror!void { for (tags, datas, 0..) |tag, data, i| { try w.print("${d} = {s}(", .{ i, @tagName(tag) }); switch (tag) { - .simple_type => try w.print("{s}", .{@tagName(@intToEnum(SimpleType, data))}), - .simple_value => try w.print("{s}", .{@tagName(@intToEnum(SimpleValue, data))}), + .simple_type => try w.print("{s}", .{@tagName(@enumFromInt(SimpleType, data))}), + .simple_value => try w.print("{s}", .{@tagName(@enumFromInt(SimpleValue, data))}), .type_int_signed, .type_int_unsigned, @@ -5246,11 +5246,11 @@ fn dumpAllFallible(ip: *const InternPool) anyerror!void { } pub fn structPtr(ip: *InternPool, index: Module.Struct.Index) *Module.Struct { - return ip.allocated_structs.at(@enumToInt(index)); + return ip.allocated_structs.at(@intFromEnum(index)); } pub fn structPtrConst(ip: *const InternPool, index: Module.Struct.Index) *const Module.Struct { - return ip.allocated_structs.at(@enumToInt(index)); + return ip.allocated_structs.at(@intFromEnum(index)); } pub fn structPtrUnwrapConst(ip: *const InternPool, index: Module.Struct.OptionalIndex) ?*const Module.Struct { @@ -5258,27 +5258,27 @@ pub fn structPtrUnwrapConst(ip: *const InternPool, index: Module.Struct.Optional } pub fn unionPtr(ip: *InternPool, index: Module.Union.Index) *Module.Union { - return ip.allocated_unions.at(@enumToInt(index)); + return ip.allocated_unions.at(@intFromEnum(index)); } pub fn unionPtrConst(ip: *const InternPool, index: Module.Union.Index) *const Module.Union { - return ip.allocated_unions.at(@enumToInt(index)); + return ip.allocated_unions.at(@intFromEnum(index)); } pub fn funcPtr(ip: *InternPool, index: Module.Fn.Index) *Module.Fn { - return ip.allocated_funcs.at(@enumToInt(index)); + return ip.allocated_funcs.at(@intFromEnum(index)); } pub fn funcPtrConst(ip: *const InternPool, index: Module.Fn.Index) *const Module.Fn { - return ip.allocated_funcs.at(@enumToInt(index)); + return ip.allocated_funcs.at(@intFromEnum(index)); } pub fn inferredErrorSetPtr(ip: *InternPool, index: Module.Fn.InferredErrorSet.Index) *Module.Fn.InferredErrorSet { - return ip.allocated_inferred_error_sets.at(@enumToInt(index)); + return ip.allocated_inferred_error_sets.at(@intFromEnum(index)); } pub fn inferredErrorSetPtrConst(ip: *const InternPool, index: Module.Fn.InferredErrorSet.Index) *const Module.Fn.InferredErrorSet { - return ip.allocated_inferred_error_sets.at(@enumToInt(index)); + return ip.allocated_inferred_error_sets.at(@intFromEnum(index)); } pub fn createStruct( @@ -5287,12 +5287,12 @@ pub fn createStruct( initialization: Module.Struct, ) Allocator.Error!Module.Struct.Index { if (ip.structs_free_list.popOrNull()) |index| { - ip.allocated_structs.at(@enumToInt(index)).* = initialization; + ip.allocated_structs.at(@intFromEnum(index)).* = initialization; return index; } const ptr = try ip.allocated_structs.addOne(gpa); ptr.* = initialization; - return @intToEnum(Module.Struct.Index, ip.allocated_structs.len - 1); + return @enumFromInt(Module.Struct.Index, ip.allocated_structs.len - 1); } pub fn destroyStruct(ip: *InternPool, gpa: Allocator, index: Module.Struct.Index) void { @@ -5309,12 +5309,12 @@ pub fn createUnion( initialization: Module.Union, ) Allocator.Error!Module.Union.Index { if (ip.unions_free_list.popOrNull()) |index| { - ip.allocated_unions.at(@enumToInt(index)).* = initialization; + ip.allocated_unions.at(@intFromEnum(index)).* = initialization; return index; } const ptr = try ip.allocated_unions.addOne(gpa); ptr.* = initialization; - return @intToEnum(Module.Union.Index, ip.allocated_unions.len - 1); + return @enumFromInt(Module.Union.Index, ip.allocated_unions.len - 1); } pub fn destroyUnion(ip: *InternPool, gpa: Allocator, index: Module.Union.Index) void { @@ -5331,12 +5331,12 @@ pub fn createFunc( initialization: Module.Fn, ) Allocator.Error!Module.Fn.Index { if (ip.funcs_free_list.popOrNull()) |index| { - ip.allocated_funcs.at(@enumToInt(index)).* = initialization; + ip.allocated_funcs.at(@intFromEnum(index)).* = initialization; return index; } const ptr = try ip.allocated_funcs.addOne(gpa); ptr.* = initialization; - return @intToEnum(Module.Fn.Index, ip.allocated_funcs.len - 1); + return @enumFromInt(Module.Fn.Index, ip.allocated_funcs.len - 1); } pub fn destroyFunc(ip: *InternPool, gpa: Allocator, index: Module.Fn.Index) void { @@ -5353,12 +5353,12 @@ pub fn createInferredErrorSet( initialization: Module.Fn.InferredErrorSet, ) Allocator.Error!Module.Fn.InferredErrorSet.Index { if (ip.inferred_error_sets_free_list.popOrNull()) |index| { - ip.allocated_inferred_error_sets.at(@enumToInt(index)).* = initialization; + ip.allocated_inferred_error_sets.at(@intFromEnum(index)).* = initialization; return index; } const ptr = try ip.allocated_inferred_error_sets.addOne(gpa); ptr.* = initialization; - return @intToEnum(Module.Fn.InferredErrorSet.Index, ip.allocated_inferred_error_sets.len - 1); + return @enumFromInt(Module.Fn.InferredErrorSet.Index, ip.allocated_inferred_error_sets.len - 1); } pub fn destroyInferredErrorSet(ip: *InternPool, gpa: Allocator, index: Module.Fn.InferredErrorSet.Index) void { @@ -5425,11 +5425,11 @@ pub fn getOrPutTrailingString( }); if (gop.found_existing) { string_bytes.shrinkRetainingCapacity(str_index); - return @intToEnum(NullTerminatedString, gop.key_ptr.*); + return @enumFromInt(NullTerminatedString, gop.key_ptr.*); } else { gop.key_ptr.* = str_index; string_bytes.appendAssumeCapacity(0); - return @intToEnum(NullTerminatedString, str_index); + return @enumFromInt(NullTerminatedString, str_index); } } @@ -5437,7 +5437,7 @@ pub fn getString(ip: *InternPool, s: []const u8) OptionalNullTerminatedString { if (ip.string_table.getKeyAdapted(s, std.hash_map.StringIndexAdapter{ .bytes = &ip.string_bytes, })) |index| { - return @intToEnum(NullTerminatedString, index).toOptional(); + return @enumFromInt(NullTerminatedString, index).toOptional(); } else { return .none; } @@ -5445,7 +5445,7 @@ pub fn getString(ip: *InternPool, s: []const u8) OptionalNullTerminatedString { pub fn stringToSlice(ip: *const InternPool, s: NullTerminatedString) [:0]const u8 { const string_bytes = ip.string_bytes.items; - const start = @enumToInt(s); + const start = @intFromEnum(s); var end: usize = start; while (string_bytes[end] != 0) end += 1; return string_bytes[start..end :0]; @@ -5543,7 +5543,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index { // This optimization on tags is needed so that indexToKey can call // typeOf without being recursive. - _ => switch (ip.items.items(.tag)[@enumToInt(index)]) { + _ => switch (ip.items.items(.tag)[@intFromEnum(index)]) { .type_int_signed, .type_int_unsigned, .type_array_big, @@ -5574,7 +5574,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index { .undef, .opt_null, .only_possible_value, - => @intToEnum(Index, ip.items.items(.data)[@enumToInt(index)]), + => @enumFromInt(Index, ip.items.items(.data)[@intFromEnum(index)]), .simple_value => unreachable, // handled via Index above @@ -5604,9 +5604,9 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index { .aggregate, .repeated, => |t| { - const extra_index = ip.items.items(.data)[@enumToInt(index)]; + const extra_index = ip.items.items(.data)[@intFromEnum(index)]; const field_index = std.meta.fieldIndex(t.Payload(), "ty").?; - return @intToEnum(Index, ip.extra.items[extra_index + field_index]); + return @enumFromInt(Index, ip.extra.items[extra_index + field_index]); }, .int_u8 => .u8_type, @@ -5622,7 +5622,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index { // Note these are stored in limbs data, not extra data. .int_positive, .int_negative, - => ip.limbData(Int, ip.items.items(.data)[@enumToInt(index)]).ty, + => ip.limbData(Int, ip.items.items(.data)[@intFromEnum(index)]).ty, .enum_literal => .enum_literal_type, .float_f16 => .f16_type, @@ -5648,7 +5648,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index { /// Assumes that the enum's field indexes equal its value tags. pub fn toEnum(ip: *const InternPool, comptime E: type, i: Index) E { const int = ip.indexToKey(i).enum_tag.int; - return @intToEnum(E, ip.indexToKey(int).int.storage.u64); + return @enumFromInt(E, ip.indexToKey(int).int.storage.u64); } pub fn aggregateTypeLen(ip: *const InternPool, ty: Index) u64 { @@ -5665,7 +5665,7 @@ pub fn aggregateTypeLenIncludingSentinel(ip: *const InternPool, ty: Index) u64 { return switch (ip.indexToKey(ty)) { .struct_type => |struct_type| ip.structPtrConst(struct_type.index.unwrap() orelse return 0).fields.count(), .anon_struct_type => |anon_struct_type| anon_struct_type.types.len, - .array_type => |array_type| array_type.len + @boolToInt(array_type.sentinel != .none), + .array_type => |array_type| array_type.len + @intFromBool(array_type.sentinel != .none), .vector_type => |vector_type| vector_type.len, else => unreachable, }; @@ -5783,7 +5783,7 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois .var_args_param_type => unreachable, // special tag - _ => switch (ip.items.items(.tag)[@enumToInt(index)]) { + _ => switch (ip.items.items(.tag)[@intFromEnum(index)]) { .type_int_signed, .type_int_unsigned, => .Int, diff --git a/src/Liveness.zig b/src/Liveness.zig index ea922b1a8dc5..2ba029136406 100644 --- a/src/Liveness.zig +++ b/src/Liveness.zig @@ -1286,7 +1286,7 @@ fn analyzeOperands( break :blk true; }; - var tomb_bits: Bpi = @as(Bpi, @boolToInt(immediate_death)) << (bpi - 1); + var tomb_bits: Bpi = @as(Bpi, @intFromBool(immediate_death)) << (bpi - 1); // If our result is unused and the instruction doesn't need to be lowered, backends will // skip the lowering of this instruction, so we don't want to record uses of operands. diff --git a/src/Manifest.zig b/src/Manifest.zig index 068a14942f50..0549287e60d4 100644 --- a/src/Manifest.zig +++ b/src/Manifest.zig @@ -39,7 +39,7 @@ pub const multihash_function: MultihashFunction = switch (Hash) { comptime { // We avoid unnecessary uleb128 code in hexDigest by asserting here the // values are small enough to be contained in the one-byte encoding. - assert(@enumToInt(multihash_function) < 127); + assert(@intFromEnum(multihash_function) < 127); assert(Hash.digest_length < 127); } pub const multihash_len = 1 + 1 + Hash.digest_length; @@ -117,8 +117,8 @@ test hex64 { pub fn hexDigest(digest: [Hash.digest_length]u8) [multihash_len * 2]u8 { var result: [multihash_len * 2]u8 = undefined; - result[0] = hex_charset[@enumToInt(multihash_function) >> 4]; - result[1] = hex_charset[@enumToInt(multihash_function) & 15]; + result[0] = hex_charset[@intFromEnum(multihash_function) >> 4]; + result[1] = hex_charset[@intFromEnum(multihash_function) & 15]; result[2] = hex_charset[Hash.digest_length >> 4]; result[3] = hex_charset[Hash.digest_length & 15]; @@ -284,7 +284,7 @@ const Parse = struct { @errorName(err), }); }; - if (@intToEnum(MultihashFunction, their_multihash_func) != multihash_function) { + if (@enumFromInt(MultihashFunction, their_multihash_func) != multihash_function) { return fail(p, tok, "unsupported hash function: only sha2-256 is supported", .{}); } } diff --git a/src/Module.zig b/src/Module.zig index 8d9f9593ddec..28696b327155 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -223,7 +223,7 @@ pub const MonomorphedFuncsContext = struct { pub fn hash(ctx: @This(), key: MonomorphedFuncKey) u64 { const key_args = ctx.mod.monomorphed_func_keys.items[key.args_index..][0..key.args_len]; - return std.hash.Wyhash.hash(@enumToInt(key.func), std.mem.sliceAsBytes(key_args)); + return std.hash.Wyhash.hash(@intFromEnum(key.func), std.mem.sliceAsBytes(key_args)); } }; @@ -236,7 +236,7 @@ pub const MonomorphedFuncsAdaptedContext = struct { } pub fn hash(_: @This(), adapted_key: MonomorphedFuncAdaptedKey) u64 { - return std.hash.Wyhash.hash(@enumToInt(adapted_key.func), std.mem.sliceAsBytes(adapted_key.args)); + return std.hash.Wyhash.hash(@intFromEnum(adapted_key.func), std.mem.sliceAsBytes(adapted_key.args)); } }; @@ -263,7 +263,7 @@ pub const GlobalEmitH = struct { allocated_emit_h: std.SegmentedList(EmitH, 0) = .{}, pub fn declPtr(global_emit_h: *GlobalEmitH, decl_index: Decl.Index) *EmitH { - return global_emit_h.allocated_emit_h.at(@enumToInt(decl_index)); + return global_emit_h.allocated_emit_h.at(@intFromEnum(decl_index)); } }; @@ -553,7 +553,7 @@ pub const Decl = struct { _, pub fn toOptional(i: Index) OptionalIndex { - return @intToEnum(OptionalIndex, @enumToInt(i)); + return @enumFromInt(OptionalIndex, @intFromEnum(i)); } }; @@ -562,12 +562,12 @@ pub const Decl = struct { _, pub fn init(oi: ?Index) OptionalIndex { - return @intToEnum(OptionalIndex, @enumToInt(oi orelse return .none)); + return @enumFromInt(OptionalIndex, @intFromEnum(oi orelse return .none)); } pub fn unwrap(oi: OptionalIndex) ?Index { if (oi == .none) return null; - return @intToEnum(Index, @enumToInt(oi)); + return @enumFromInt(Index, @intFromEnum(oi)); } }; @@ -632,23 +632,23 @@ pub const Decl = struct { if (!decl.has_align) return .none; assert(decl.zir_decl_index != 0); const zir = decl.getFileScope(mod).zir; - return @intToEnum(Zir.Inst.Ref, zir.extra[decl.zir_decl_index + 8]); + return @enumFromInt(Zir.Inst.Ref, zir.extra[decl.zir_decl_index + 8]); } pub fn zirLinksectionRef(decl: Decl, mod: *Module) Zir.Inst.Ref { if (!decl.has_linksection_or_addrspace) return .none; assert(decl.zir_decl_index != 0); const zir = decl.getFileScope(mod).zir; - const extra_index = decl.zir_decl_index + 8 + @boolToInt(decl.has_align); - return @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); + const extra_index = decl.zir_decl_index + 8 + @intFromBool(decl.has_align); + return @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]); } pub fn zirAddrspaceRef(decl: Decl, mod: *Module) Zir.Inst.Ref { if (!decl.has_linksection_or_addrspace) return .none; assert(decl.zir_decl_index != 0); const zir = decl.getFileScope(mod).zir; - const extra_index = decl.zir_decl_index + 8 + @boolToInt(decl.has_align) + 1; - return @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); + const extra_index = decl.zir_decl_index + 8 + @intFromBool(decl.has_align) + 1; + return @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]); } pub fn relativeToLine(decl: Decl, offset: u32) u32 { @@ -831,7 +831,7 @@ pub const Decl = struct { decl.scope.sub_file_path, loc.line + 1, loc.column + 1, - @enumToInt(decl.name), + @intFromEnum(decl.name), @tagName(decl.analysis), }); if (decl.has_tv) { @@ -927,7 +927,7 @@ pub const Struct = struct { _, pub fn toOptional(i: Index) OptionalIndex { - return @intToEnum(OptionalIndex, @enumToInt(i)); + return @enumFromInt(OptionalIndex, @intFromEnum(i)); } }; @@ -936,12 +936,12 @@ pub const Struct = struct { _, pub fn init(oi: ?Index) OptionalIndex { - return @intToEnum(OptionalIndex, @enumToInt(oi orelse return .none)); + return @enumFromInt(OptionalIndex, @intFromEnum(oi orelse return .none)); } pub fn unwrap(oi: OptionalIndex) ?Index { if (oi == .none) return null; - return @intToEnum(Index, @enumToInt(oi)); + return @enumFromInt(Index, @intFromEnum(oi)); } }; @@ -1128,7 +1128,7 @@ pub const Union = struct { _, pub fn toOptional(i: Index) OptionalIndex { - return @intToEnum(OptionalIndex, @enumToInt(i)); + return @enumFromInt(OptionalIndex, @intFromEnum(i)); } }; @@ -1137,12 +1137,12 @@ pub const Union = struct { _, pub fn init(oi: ?Index) OptionalIndex { - return @intToEnum(OptionalIndex, @enumToInt(oi orelse return .none)); + return @enumFromInt(OptionalIndex, @intFromEnum(oi orelse return .none)); } pub fn unwrap(oi: OptionalIndex) ?Index { if (oi == .none) return null; - return @intToEnum(Index, @enumToInt(oi)); + return @enumFromInt(Index, @intFromEnum(oi)); } }; @@ -1424,7 +1424,7 @@ pub const Fn = struct { _, pub fn toOptional(i: Index) OptionalIndex { - return @intToEnum(OptionalIndex, @enumToInt(i)); + return @enumFromInt(OptionalIndex, @intFromEnum(i)); } }; @@ -1433,12 +1433,12 @@ pub const Fn = struct { _, pub fn init(oi: ?Index) OptionalIndex { - return @intToEnum(OptionalIndex, @enumToInt(oi orelse return .none)); + return @enumFromInt(OptionalIndex, @intFromEnum(oi orelse return .none)); } pub fn unwrap(oi: OptionalIndex) ?Index { if (oi == .none) return null; - return @intToEnum(Index, @enumToInt(oi)); + return @enumFromInt(Index, @intFromEnum(oi)); } }; @@ -1492,7 +1492,7 @@ pub const Fn = struct { _, pub fn toOptional(i: InferredErrorSet.Index) InferredErrorSet.OptionalIndex { - return @intToEnum(InferredErrorSet.OptionalIndex, @enumToInt(i)); + return @enumFromInt(InferredErrorSet.OptionalIndex, @intFromEnum(i)); } }; @@ -1501,12 +1501,12 @@ pub const Fn = struct { _, pub fn init(oi: ?InferredErrorSet.Index) InferredErrorSet.OptionalIndex { - return @intToEnum(InferredErrorSet.OptionalIndex, @enumToInt(oi orelse return .none)); + return @enumFromInt(InferredErrorSet.OptionalIndex, @intFromEnum(oi orelse return .none)); } pub fn unwrap(oi: InferredErrorSet.OptionalIndex) ?InferredErrorSet.Index { if (oi == .none) return null; - return @intToEnum(InferredErrorSet.Index, @enumToInt(oi)); + return @enumFromInt(InferredErrorSet.Index, @intFromEnum(oi)); } }; @@ -1594,7 +1594,7 @@ pub const DeclAdapter = struct { pub fn hash(self: @This(), s: InternPool.NullTerminatedString) u32 { _ = self; - return std.hash.uint32(@enumToInt(s)); + return std.hash.uint32(@intFromEnum(s)); } pub fn eql(self: @This(), a: InternPool.NullTerminatedString, b_decl_index: Decl.Index, b_index: usize) bool { @@ -1628,7 +1628,7 @@ pub const Namespace = struct { _, pub fn toOptional(i: Index) OptionalIndex { - return @intToEnum(OptionalIndex, @enumToInt(i)); + return @enumFromInt(OptionalIndex, @intFromEnum(i)); } }; @@ -1637,12 +1637,12 @@ pub const Namespace = struct { _, pub fn init(oi: ?Index) OptionalIndex { - return @intToEnum(OptionalIndex, @enumToInt(oi orelse return .none)); + return @enumFromInt(OptionalIndex, @intFromEnum(oi orelse return .none)); } pub fn unwrap(oi: OptionalIndex) ?Index { if (oi == .none) return null; - return @intToEnum(Index, @enumToInt(oi)); + return @enumFromInt(Index, @intFromEnum(oi)); } }; @@ -1651,7 +1651,7 @@ pub const Namespace = struct { pub fn hash(ctx: @This(), decl_index: Decl.Index) u32 { const decl = ctx.module.declPtr(decl_index); - return std.hash.uint32(@enumToInt(decl.name)); + return std.hash.uint32(@intFromEnum(decl.name)); } pub fn eql(ctx: @This(), a_decl_index: Decl.Index, b_decl_index: Decl.Index, b_index: usize) bool { @@ -2006,7 +2006,7 @@ pub const File = struct { // be the case if there were other astgen failures in this file if (!file.zir_loaded) return; - const imports_index = file.zir.extra[@enumToInt(Zir.ExtraIndex.imports)]; + const imports_index = file.zir.extra[@intFromEnum(Zir.ExtraIndex.imports)]; if (imports_index == 0) return; const extra = file.zir.extraData(Zir.Inst.Imports, imports_index); @@ -3360,11 +3360,11 @@ pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void { } pub fn declPtr(mod: *Module, index: Decl.Index) *Decl { - return mod.allocated_decls.at(@enumToInt(index)); + return mod.allocated_decls.at(@intFromEnum(index)); } pub fn namespacePtr(mod: *Module, index: Namespace.Index) *Namespace { - return mod.allocated_namespaces.at(@enumToInt(index)); + return mod.allocated_namespaces.at(@intFromEnum(index)); } pub fn unionPtr(mod: *Module, index: Union.Index) *Union { @@ -3767,10 +3767,10 @@ fn loadZirCacheBody(gpa: Allocator, header: Zir.Header, cache_file: std.fs.File) if (data_has_safety_tag) { const tags = zir.instructions.items(.tag); for (zir.instructions.items(.data), 0..) |*data, i| { - const union_tag = Zir.Inst.Tag.data_tags[@enumToInt(tags[i])]; + const union_tag = Zir.Inst.Tag.data_tags[@intFromEnum(tags[i])]; const as_struct = @ptrCast(*HackDataLayout, data); as_struct.* = .{ - .safety_tag = @enumToInt(union_tag), + .safety_tag = @intFromEnum(union_tag), .data = safety_buffer[i], }; } @@ -4101,7 +4101,7 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void { const update_level: Decl.DepType = if (!type_changed and decl.ty.zigTypeTag(mod) == .Fn) .function_body else .normal; for (decl.dependants.keys(), decl.dependants.values()) |dep_index, dep_type| { - if (@enumToInt(dep_type) < @enumToInt(update_level)) continue; + if (@intFromEnum(dep_type) < @intFromEnum(update_level)) continue; const dep = mod.declPtr(dep_index); switch (dep.analysis) { @@ -4621,7 +4621,7 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool { const is_inline = decl.ty.fnCallingConvention(mod) == .Inline; if (decl.is_exported) { - const export_src: LazySrcLoc = .{ .token_offset = @boolToInt(decl.is_pub) }; + const export_src: LazySrcLoc = .{ .token_offset = @intFromBool(decl.is_pub) }; if (is_inline) { return sema.fail(&block_scope, export_src, "export of inline function", .{}); } @@ -4721,7 +4721,7 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool { } if (decl.is_exported) { - const export_src: LazySrcLoc = .{ .token_offset = @boolToInt(decl.is_pub) }; + const export_src: LazySrcLoc = .{ .token_offset = @intFromBool(decl.is_pub) }; // The scope needs to have the decl in it. try sema.analyzeExport(&block_scope, export_src, .{ .name = decl.name }, decl_index); } @@ -4742,7 +4742,7 @@ pub fn declareDeclDependencyType(mod: *Module, depender_index: Decl.Index, depen const dependee = mod.declPtr(dependee_index); if (depender.dependencies.get(dependee_index)) |cur_type| { - if (@enumToInt(cur_type) >= @enumToInt(dep_type)) { + if (@intFromEnum(cur_type) >= @intFromEnum(dep_type)) { // We already have this dependency (or stricter) marked return; } @@ -5611,7 +5611,7 @@ pub fn analyzeFnBody(mod: *Module, func_index: Fn.Index, arena: Allocator) SemaE .body_len = @intCast(u32, inner_block.instructions.items.len), }); sema.air_extra.appendSliceAssumeCapacity(inner_block.instructions.items); - sema.air_extra.items[@enumToInt(Air.ExtraIndex.main_block)] = main_block_index; + sema.air_extra.items[@intFromEnum(Air.ExtraIndex.main_block)] = main_block_index; func.state = .success; @@ -5681,12 +5681,12 @@ fn markOutdatedDecl(mod: *Module, decl_index: Decl.Index) !void { pub fn createNamespace(mod: *Module, initialization: Namespace) !Namespace.Index { if (mod.namespaces_free_list.popOrNull()) |index| { - mod.allocated_namespaces.at(@enumToInt(index)).* = initialization; + mod.allocated_namespaces.at(@intFromEnum(index)).* = initialization; return index; } const ptr = try mod.allocated_namespaces.addOne(mod.gpa); ptr.* = initialization; - return @intToEnum(Namespace.Index, mod.allocated_namespaces.len - 1); + return @enumFromInt(Namespace.Index, mod.allocated_namespaces.len - 1); } pub fn destroyNamespace(mod: *Module, index: Namespace.Index) void { @@ -5744,7 +5744,7 @@ pub fn allocateNewDecl( } break :d .{ .new_decl = decl, - .decl_index = @intToEnum(Decl.Index, mod.allocated_decls.len - 1), + .decl_index = @enumFromInt(Decl.Index, mod.allocated_decls.len - 1), }; }; @@ -5808,7 +5808,7 @@ pub fn createAnonymousDeclFromDecl( const new_decl_index = try mod.allocateNewDecl(namespace, src_decl.src_node, src_scope); errdefer mod.destroyDecl(new_decl_index); const name = try mod.intern_pool.getOrPutStringFmt(mod.gpa, "{}__anon_{d}", .{ - src_decl.name.fmt(&mod.intern_pool), @enumToInt(new_decl_index), + src_decl.name.fmt(&mod.intern_pool), @intFromEnum(new_decl_index), }); try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, namespace, tv, name); return new_decl_index; @@ -6172,7 +6172,7 @@ pub fn argSrc( @setCold(true); const gpa = mod.gpa; if (start_arg_i == 0 and bound_arg_src != null) return bound_arg_src.?; - const arg_i = start_arg_i - @boolToInt(bound_arg_src != null); + const arg_i = start_arg_i - @intFromBool(bound_arg_src != null); const tree = decl.getFileScope(mod).getTree(gpa) catch |err| { // In this case we emit a warning + a less precise source location. log.warn("unable to load {s}: {s}", .{ @@ -6741,7 +6741,7 @@ pub fn ptrType(mod: *Module, info: InternPool.Key.PtrType) Allocator.Error!Type } }, .runtime => {}, - _ => assert(@enumToInt(info.flags.vector_index) < info.packed_offset.host_size), + _ => assert(@intFromEnum(info.flags.vector_index) < info.packed_offset.host_size), } return (try intern(mod, .{ .ptr_type = canon_info })).toType(); @@ -6969,17 +6969,17 @@ pub fn intBitsForValue(mod: *Module, val: Value, sign: bool) u16 { const key = mod.intern_pool.indexToKey(val.toIntern()); switch (key.int.storage) { .i64 => |x| { - if (std.math.cast(u64, x)) |casted| return Type.smallestUnsignedBits(casted) + @boolToInt(sign); + if (std.math.cast(u64, x)) |casted| return Type.smallestUnsignedBits(casted) + @intFromBool(sign); assert(sign); // Protect against overflow in the following negation. if (x == std.math.minInt(i64)) return 64; return Type.smallestUnsignedBits(@intCast(u64, -(x + 1))) + 1; }, .u64 => |x| { - return Type.smallestUnsignedBits(x) + @boolToInt(sign); + return Type.smallestUnsignedBits(x) + @intFromBool(sign); }, .big_int => |big| { - if (big.positive) return @intCast(u16, big.bitCountAbs() + @boolToInt(sign)); + if (big.positive) return @intCast(u16, big.bitCountAbs() + @intFromBool(sign)); // Zero is still a possibility, in which case unsigned is fine if (big.eqZero()) return 0; @@ -6987,10 +6987,10 @@ pub fn intBitsForValue(mod: *Module, val: Value, sign: bool) u16 { return @intCast(u16, big.bitCountTwosComp()); }, .lazy_align => |lazy_ty| { - return Type.smallestUnsignedBits(lazy_ty.toType().abiAlignment(mod)) + @boolToInt(sign); + return Type.smallestUnsignedBits(lazy_ty.toType().abiAlignment(mod)) + @intFromBool(sign); }, .lazy_size => |lazy_ty| { - return Type.smallestUnsignedBits(lazy_ty.toType().abiSize(mod)) + @boolToInt(sign); + return Type.smallestUnsignedBits(lazy_ty.toType().abiSize(mod)) + @intFromBool(sign); }, } } diff --git a/src/Package.zig b/src/Package.zig index e8431927b110..dd8f3c8a7e19 100644 --- a/src/Package.zig +++ b/src/Package.zig @@ -502,7 +502,7 @@ fn fetchAndUnpack( if (req.response.status != .ok) { return report.fail(dep.url_tok, "Expected response status '200 OK' got '{} {s}'", .{ - @enumToInt(req.response.status), + @intFromEnum(req.response.status), req.response.status.phrase() orelse "", }); } @@ -568,7 +568,7 @@ fn fetchAndUnpack( .msg = "url field is missing corresponding hash field", }); const notes_start = try eb.reserveNotes(notes_len); - eb.extra.items[notes_start] = @enumToInt(try eb.addErrorMessage(.{ + eb.extra.items[notes_start] = @intFromEnum(try eb.addErrorMessage(.{ .msg = try eb.printString("expected .hash = \"{s}\",", .{&actual_hex}), })); return error.PackageFetchFailed; @@ -715,7 +715,7 @@ fn hashFileFallible(dir: fs.Dir, hashed_file: *HashedFile) HashedFile.Error!void defer file.close(); var hasher = Manifest.Hash.init(.{}); hasher.update(hashed_file.normalized_path); - hasher.update(&.{ 0, @boolToInt(try isExecutable(file)) }); + hasher.update(&.{ 0, @intFromBool(try isExecutable(file)) }); while (true) { const bytes_read = try file.read(&buf); if (bytes_read == 0) break; diff --git a/src/Sema.zig b/src/Sema.zig index c7115409e61c..69326a170401 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -1387,7 +1387,7 @@ fn analyzeBodyInner( check_block = check_block.parent.?; }; - if (@enumToInt(target_runtime_index) < @enumToInt(block.runtime_index)) { + if (@intFromEnum(target_runtime_index) < @intFromEnum(block.runtime_index)) { const runtime_src = block.runtime_cond orelse block.runtime_loop.?; const msg = msg: { const msg = try sema.errMsg(block, src, "comptime control flow inside runtime block", .{}); @@ -1761,10 +1761,10 @@ pub fn resolveInstAllowNone(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref { pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref { assert(zir_ref != .none); - const i = @enumToInt(zir_ref); + const i = @intFromEnum(zir_ref); // First section of indexes correspond to a set number of constant values. // We intentionally map the same indexes to the same values between ZIR and AIR. - if (i < InternPool.static_len) return @intToEnum(Air.Inst.Ref, i); + if (i < InternPool.static_len) return @enumFromInt(Air.Inst.Ref, i); // The last section of indexes refers to the map of ZIR => AIR. const inst = sema.inst_map.get(i - InternPool.static_len).?; if (inst == .generic_poison) return error.GenericPoison; @@ -2038,9 +2038,9 @@ fn resolveMaybeUndefValAllowVariablesMaybeRuntime( ) CompileError!?Value { assert(inst != .none); // First section of indexes correspond to a set number of constant values. - const int = @enumToInt(inst); + const int = @intFromEnum(inst); if (int < InternPool.static_len) { - return @intToEnum(InternPool.Index, int).toValue(); + return @enumFromInt(InternPool.Index, int).toValue(); } const i = int - InternPool.static_len; @@ -2745,8 +2745,8 @@ pub fn analyzeStructDecl( } var extra_index: usize = extended.operand; - extra_index += @boolToInt(small.has_src_node); - extra_index += @boolToInt(small.has_fields_len); + extra_index += @intFromBool(small.has_src_node); + extra_index += @intFromBool(small.has_fields_len); const decls_len = if (small.has_decls_len) blk: { const decls_len = sema.code.extra[extra_index]; extra_index += 1; @@ -2857,7 +2857,7 @@ fn createAnonymousDeclTypeNamed( // renamed. const name = mod.intern_pool.getOrPutStringFmt(gpa, "{}__{s}_{d}", .{ - src_decl.name.fmt(&mod.intern_pool), anon_prefix, @enumToInt(new_decl_index), + src_decl.name.fmt(&mod.intern_pool), anon_prefix, @intFromEnum(new_decl_index), }) catch unreachable; try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, namespace, typed_value, name); return new_decl_index; @@ -2948,7 +2948,7 @@ fn zirEnumDecl( const tag_ty_src: LazySrcLoc = .{ .node_offset_container_tag = src.node_offset.x }; const tag_type_ref = if (small.has_tag_type) blk: { - const tag_type_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const tag_type_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; break :blk tag_type_ref; } else .none; @@ -3131,7 +3131,7 @@ fn zirEnumDecl( } const tag_overflow = if (has_tag_value) overflow: { - const tag_val_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const tag_val_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const tag_inst = try sema.resolveInst(tag_val_ref); last_tag_val = sema.resolveConstValue(block, .unneeded, tag_inst, "") catch |err| switch (err) { @@ -3222,9 +3222,9 @@ fn zirUnionDecl( break :blk LazySrcLoc.nodeOffset(node_offset); } else sema.src; - extra_index += @boolToInt(small.has_tag_type); - extra_index += @boolToInt(small.has_body_len); - extra_index += @boolToInt(small.has_fields_len); + extra_index += @intFromBool(small.has_tag_type); + extra_index += @intFromBool(small.has_body_len); + extra_index += @intFromBool(small.has_fields_len); const decls_len = if (small.has_decls_len) blk: { const decls_len = sema.code.extra[extra_index]; @@ -3574,13 +3574,13 @@ fn zirAllocExtended( var extra_index: usize = extra.end; const var_ty: Type = if (small.has_type) blk: { - const type_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const type_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; break :blk try sema.resolveType(block, ty_src, type_ref); } else undefined; const alignment: u32 = if (small.has_align) blk: { - const align_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const align_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const alignment = try sema.resolveAlign(block, align_src, align_ref); break :blk alignment; @@ -6006,7 +6006,7 @@ fn zirFence(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) Co const order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; const order = try sema.resolveAtomicOrder(block, order_src, extra.operand, "atomic order of @fence must be comptime-known"); - if (@enumToInt(order) < @enumToInt(std.builtin.AtomicOrder.Acquire)) { + if (@intFromEnum(order) < @intFromEnum(std.builtin.AtomicOrder.Acquire)) { return sema.fail(block, order_src, "atomic ordering must be Acquire or stricter", .{}); } @@ -6441,7 +6441,7 @@ fn zirCall( const extra = sema.code.extraData(ExtraType, inst_data.payload_index); const args_len = extra.data.flags.args_len; - const modifier = @intToEnum(std.builtin.CallModifier, extra.data.flags.packed_modifier); + const modifier = @enumFromInt(std.builtin.CallModifier, extra.data.flags.packed_modifier); const ensure_result_used = extra.data.flags.ensure_result_used; const pop_error_return_trace = extra.data.flags.pop_error_return_trace; @@ -6473,7 +6473,7 @@ fn zirCall( } const callee_ty = sema.typeOf(func); - const total_args = args_len + @boolToInt(bound_arg_src != null); + const total_args = args_len + @intFromBool(bound_arg_src != null); const func_ty = try sema.checkCallArgumentCount(block, func, callee_src, callee_ty, total_args, bound_arg_src != null); const args_body = sema.code.extra[extra.end..]; @@ -6612,7 +6612,7 @@ fn checkCallArgumentCount( const func_ty_info = mod.typeToFunc(func_ty).?; const fn_params_len = func_ty_info.param_types.len; - const args_len = total_args - @boolToInt(member_fn); + const args_len = total_args - @intFromBool(member_fn); if (func_ty_info.is_var_args) { assert(func_ty_info.cc == .C); if (total_args >= fn_params_len) return func_ty; @@ -6631,7 +6631,7 @@ fn checkCallArgumentCount( .{ member_str, variadic_str, - fn_params_len - @boolToInt(member_fn), + fn_params_len - @intFromBool(member_fn), args_len, }, ); @@ -7538,7 +7538,7 @@ fn instantiateGenericCall( const new_decl = mod.declPtr(new_decl_index); // TODO better names for generic function instantiations const decl_name = try mod.intern_pool.getOrPutStringFmt(gpa, "{}__anon_{d}", .{ - fn_owner_decl.name.fmt(&mod.intern_pool), @enumToInt(new_decl_index), + fn_owner_decl.name.fmt(&mod.intern_pool), @intFromEnum(new_decl_index), }); new_decl.name = decl_name; new_decl.src_line = fn_owner_decl.src_line; @@ -7982,7 +7982,7 @@ fn zirElemTypeIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr const indexable_ty = try sema.resolveType(block, .unneeded, bin.lhs); assert(indexable_ty.isIndexable(mod)); // validated by a previous instruction if (indexable_ty.zigTypeTag(mod) == .Struct) { - const elem_type = indexable_ty.structFieldType(@enumToInt(bin.rhs), mod); + const elem_type = indexable_ty.structFieldType(@intFromEnum(bin.rhs), mod); return sema.addType(elem_type); } else { const elem_type = indexable_ty.elemType2(mod); @@ -8295,7 +8295,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError } if (try sema.resolveMaybeUndefVal(enum_tag)) |enum_tag_val| { - const val = try enum_tag_val.enumToInt(enum_tag_ty, mod); + const val = try enum_tag_val.intFromEnum(enum_tag_ty, mod); return sema.addConstant(int_tag_ty, try val.copy(sema.arena)); } @@ -8729,7 +8729,7 @@ fn zirFunc( const ret_ty: Type = switch (extra.data.ret_body_len) { 0 => Type.void, 1 => blk: { - const ret_ty_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const ret_ty_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; if (sema.resolveType(block, ret_ty_src, ret_ty_ref)) |ret_ty| { break :blk ret_ty; @@ -9668,8 +9668,8 @@ fn intCast( const wanted_info = dest_scalar_ty.intInfo(mod); const actual_bits = actual_info.bits; const wanted_bits = wanted_info.bits; - const actual_value_bits = actual_bits - @boolToInt(actual_info.signedness == .signed); - const wanted_value_bits = wanted_bits - @boolToInt(wanted_info.signedness == .signed); + const actual_value_bits = actual_bits - @intFromBool(actual_info.signedness == .signed); + const wanted_value_bits = wanted_bits - @intFromBool(wanted_info.signedness == .signed); // range shrinkage // requirement: int value fits into target type @@ -9790,7 +9790,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air const msg = try sema.errMsg(block, dest_ty_src, "cannot @bitCast to '{}'", .{dest_ty.fmt(mod)}); errdefer msg.destroy(sema.gpa); switch (operand_ty.zigTypeTag(mod)) { - .Int, .ComptimeInt => try sema.errNote(block, dest_ty_src, msg, "use @intToEnum to cast from '{}'", .{operand_ty.fmt(mod)}), + .Int, .ComptimeInt => try sema.errNote(block, dest_ty_src, msg, "use @enumFromInt to cast from '{}'", .{operand_ty.fmt(mod)}), else => {}, } @@ -9804,7 +9804,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air const msg = try sema.errMsg(block, dest_ty_src, "cannot @bitCast to '{}'", .{dest_ty.fmt(mod)}); errdefer msg.destroy(sema.gpa); switch (operand_ty.zigTypeTag(mod)) { - .Int, .ComptimeInt => try sema.errNote(block, dest_ty_src, msg, "use @intToPtr to cast from '{}'", .{operand_ty.fmt(mod)}), + .Int, .ComptimeInt => try sema.errNote(block, dest_ty_src, msg, "use @ptrFromInt to cast from '{}'", .{operand_ty.fmt(mod)}), .Pointer => try sema.errNote(block, dest_ty_src, msg, "use @ptrCast to cast from '{}'", .{operand_ty.fmt(mod)}), else => {}, } @@ -9854,7 +9854,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air const msg = try sema.errMsg(block, operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(mod)}); errdefer msg.destroy(sema.gpa); switch (dest_ty.zigTypeTag(mod)) { - .Int, .ComptimeInt => try sema.errNote(block, operand_src, msg, "use @enumToInt to cast to '{}'", .{dest_ty.fmt(mod)}), + .Int, .ComptimeInt => try sema.errNote(block, operand_src, msg, "use @intFromEnum to cast to '{}'", .{dest_ty.fmt(mod)}), else => {}, } @@ -9867,7 +9867,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air const msg = try sema.errMsg(block, operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(mod)}); errdefer msg.destroy(sema.gpa); switch (dest_ty.zigTypeTag(mod)) { - .Int, .ComptimeInt => try sema.errNote(block, operand_src, msg, "use @ptrToInt to cast to '{}'", .{dest_ty.fmt(mod)}), + .Int, .ComptimeInt => try sema.errNote(block, operand_src, msg, "use @intFromPtr to cast to '{}'", .{dest_ty.fmt(mod)}), .Pointer => try sema.errNote(block, operand_src, msg, "use @ptrCast to cast to '{}'", .{dest_ty.fmt(mod)}), else => {}, } @@ -10547,7 +10547,7 @@ const SwitchProngAnalysis = struct { try cases_extra.ensureUnusedCapacity(3 + coerce_block.instructions.items.len); cases_extra.appendAssumeCapacity(1); // items_len cases_extra.appendAssumeCapacity(@intCast(u32, coerce_block.instructions.items.len)); // body_len - cases_extra.appendAssumeCapacity(@enumToInt(case_vals[idx])); // item + cases_extra.appendAssumeCapacity(@intFromEnum(case_vals[idx])); // item cases_extra.appendSliceAssumeCapacity(coerce_block.instructions.items); // body } } @@ -10834,7 +10834,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r { var scalar_i: u32 = 0; while (scalar_i < scalar_cases_len) : (scalar_i += 1) { - const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const item_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const info = @bitCast(Zir.Inst.SwitchBlock.ProngInfo, sema.code.extra[extra_index]); extra_index += 1 + info.body_len; @@ -10933,7 +10933,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r { var scalar_i: u32 = 0; while (scalar_i < scalar_cases_len) : (scalar_i += 1) { - const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const item_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const info = @bitCast(Zir.Inst.SwitchBlock.ProngInfo, sema.code.extra[extra_index]); extra_index += 1 + info.body_len; @@ -11074,7 +11074,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r { var scalar_i: u32 = 0; while (scalar_i < scalar_cases_len) : (scalar_i += 1) { - const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const item_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const info = @bitCast(Zir.Inst.SwitchBlock.ProngInfo, sema.code.extra[extra_index]); extra_index += 1 + info.body_len; @@ -11116,9 +11116,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r try case_vals.ensureUnusedCapacity(gpa, 2 * ranges_len); var range_i: u32 = 0; while (range_i < ranges_len) : (range_i += 1) { - const item_first = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const item_first = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; - const item_last = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const item_last = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const vals = try sema.validateSwitchRange( @@ -11169,7 +11169,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r { var scalar_i: u32 = 0; while (scalar_i < scalar_cases_len) : (scalar_i += 1) { - const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const item_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const info = @bitCast(Zir.Inst.SwitchBlock.ProngInfo, sema.code.extra[extra_index]); extra_index += 1 + info.body_len; @@ -11251,7 +11251,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r { var scalar_i: u32 = 0; while (scalar_i < scalar_cases_len) : (scalar_i += 1) { - const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const item_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const info = @bitCast(Zir.Inst.SwitchBlock.ProngInfo, sema.code.extra[extra_index]); extra_index += 1; @@ -11571,7 +11571,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); cases_extra.appendAssumeCapacity(1); // items_len cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); - cases_extra.appendAssumeCapacity(@enumToInt(item)); + cases_extra.appendAssumeCapacity(@intFromEnum(item)); cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); } @@ -11656,7 +11656,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); cases_extra.appendAssumeCapacity(1); // items_len cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); - cases_extra.appendAssumeCapacity(@enumToInt(item_ref)); + cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); } } @@ -11702,7 +11702,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); cases_extra.appendAssumeCapacity(1); // items_len cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); - cases_extra.appendAssumeCapacity(@enumToInt(item)); + cases_extra.appendAssumeCapacity(@intFromEnum(item)); cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); } @@ -11753,7 +11753,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); for (items) |item| { - cases_extra.appendAssumeCapacity(@enumToInt(item)); + cases_extra.appendAssumeCapacity(@intFromEnum(item)); } cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); @@ -11903,7 +11903,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); cases_extra.appendAssumeCapacity(1); // items_len cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); - cases_extra.appendAssumeCapacity(@enumToInt(item_ref)); + cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); } }, @@ -11944,7 +11944,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); cases_extra.appendAssumeCapacity(1); // items_len cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); - cases_extra.appendAssumeCapacity(@enumToInt(item_ref)); + cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); } }, @@ -11975,7 +11975,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); cases_extra.appendAssumeCapacity(1); // items_len cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); - cases_extra.appendAssumeCapacity(@enumToInt(item_ref)); + cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); } }, @@ -12003,7 +12003,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); cases_extra.appendAssumeCapacity(1); // items_len cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); - cases_extra.appendAssumeCapacity(@enumToInt(Air.Inst.Ref.bool_true)); + cases_extra.appendAssumeCapacity(@intFromEnum(Air.Inst.Ref.bool_true)); cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); } if (false_count == 0) { @@ -12029,7 +12029,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); cases_extra.appendAssumeCapacity(1); // items_len cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); - cases_extra.appendAssumeCapacity(@enumToInt(Air.Inst.Ref.bool_false)); + cases_extra.appendAssumeCapacity(@intFromEnum(Air.Inst.Ref.bool_false)); cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); } }, @@ -15685,7 +15685,7 @@ fn zirAsm( const is_global_assembly = sema.func_index == .none; const asm_source: []const u8 = if (tmpl_is_expr) blk: { - const tmpl = @intToEnum(Zir.Inst.Ref, extra.data.asm_source); + const tmpl = @enumFromInt(Zir.Inst.Ref, extra.data.asm_source); const s: []const u8 = try sema.resolveConstString(block, src, tmpl, "assembly code must be comptime-known"); break :blk s; } else sema.code.nullTerminatedString(extra.data.asm_source); @@ -15789,7 +15789,7 @@ fn zirAsm( .source_len = @intCast(u32, asm_source.len), .outputs_len = outputs_len, .inputs_len = @intCast(u32, args.len), - .flags = (@as(u32, @boolToInt(is_volatile)) << 31) | @intCast(u32, clobbers.len), + .flags = (@as(u32, @intFromBool(is_volatile)) << 31) | @intCast(u32, clobbers.len), }), } }, }); @@ -16448,7 +16448,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai .EnumLiteral, => |type_info_tag| return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(type_info_tag))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(type_info_tag))).toIntern(), .val = .void_value, } })).toValue()), .Fn => { @@ -16543,7 +16543,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai const field_values = .{ // calling_convention: CallingConvention, - (try mod.enumValueFieldIndex(callconv_ty, @enumToInt(info.cc))).toIntern(), + (try mod.enumValueFieldIndex(callconv_ty, @intFromEnum(info.cc))).toIntern(), // alignment: comptime_int, (try mod.intValue(Type.comptime_int, ty.abiAlignment(mod))).toIntern(), // is_generic: bool, @@ -16557,7 +16557,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai }; return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Fn))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Fn))).toIntern(), .val = try mod.intern(.{ .aggregate = .{ .ty = fn_info_ty.toIntern(), .storage = .{ .elems = &field_values }, @@ -16580,13 +16580,13 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai const info = ty.intInfo(mod); const field_values = .{ // signedness: Signedness, - try (try mod.enumValueFieldIndex(signedness_ty, @enumToInt(info.signedness))).intern(signedness_ty, mod), + try (try mod.enumValueFieldIndex(signedness_ty, @intFromEnum(info.signedness))).intern(signedness_ty, mod), // bits: u16, (try mod.intValue(Type.u16, info.bits)).toIntern(), }; return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Int))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Int))).toIntern(), .val = try mod.intern(.{ .aggregate = .{ .ty = int_info_ty.toIntern(), .storage = .{ .elems = &field_values }, @@ -16611,7 +16611,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai }; return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Float))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Float))).toIntern(), .val = try mod.intern(.{ .aggregate = .{ .ty = float_info_ty.toIntern(), .storage = .{ .elems = &field_vals }, @@ -16653,7 +16653,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai const field_values = .{ // size: Size, - try (try mod.enumValueFieldIndex(ptr_size_ty, @enumToInt(info.size))).intern(ptr_size_ty, mod), + try (try mod.enumValueFieldIndex(ptr_size_ty, @intFromEnum(info.size))).intern(ptr_size_ty, mod), // is_const: bool, Value.makeBool(!info.mutable).toIntern(), // is_volatile: bool, @@ -16661,7 +16661,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai // alignment: comptime_int, alignment.toIntern(), // address_space: AddressSpace - try (try mod.enumValueFieldIndex(addrspace_ty, @enumToInt(info.@"addrspace"))).intern(addrspace_ty, mod), + try (try mod.enumValueFieldIndex(addrspace_ty, @intFromEnum(info.@"addrspace"))).intern(addrspace_ty, mod), // child: type, info.pointee_type.toIntern(), // is_allowzero: bool, @@ -16671,7 +16671,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai }; return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Pointer))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Pointer))).toIntern(), .val = try mod.intern(.{ .aggregate = .{ .ty = pointer_ty.toIntern(), .storage = .{ .elems = &field_values }, @@ -16703,7 +16703,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai }; return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Array))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Array))).toIntern(), .val = try mod.intern(.{ .aggregate = .{ .ty = array_field_ty.toIntern(), .storage = .{ .elems = &field_values }, @@ -16733,7 +16733,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai }; return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Vector))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Vector))).toIntern(), .val = try mod.intern(.{ .aggregate = .{ .ty = vector_field_ty.toIntern(), .storage = .{ .elems = &field_values }, @@ -16760,7 +16760,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai }; return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Optional))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Optional))).toIntern(), .val = try mod.intern(.{ .aggregate = .{ .ty = optional_field_ty.toIntern(), .storage = .{ .elems = &field_values }, @@ -16870,7 +16870,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai // Construct Type{ .ErrorSet = errors_val } return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.ErrorSet))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.ErrorSet))).toIntern(), .val = errors_val, } })).toValue()); }, @@ -16896,7 +16896,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai }; return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.ErrorUnion))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.ErrorUnion))).toIntern(), .val = try mod.intern(.{ .aggregate = .{ .ty = error_union_field_ty.toIntern(), .storage = .{ .elems = &field_values }, @@ -17023,7 +17023,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai }; return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Enum))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Enum))).toIntern(), .val = try mod.intern(.{ .aggregate = .{ .ty = type_enum_ty.toIntern(), .storage = .{ .elems = &field_values }, @@ -17164,7 +17164,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai const field_values = .{ // layout: ContainerLayout, - (try mod.enumValueFieldIndex(container_layout_ty, @enumToInt(layout))).toIntern(), + (try mod.enumValueFieldIndex(container_layout_ty, @intFromEnum(layout))).toIntern(), // tag_type: ?type, enum_tag_ty_val, @@ -17175,7 +17175,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai }; return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Union))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Union))).toIntern(), .val = try mod.intern(.{ .aggregate = .{ .ty = type_union_ty.toIntern(), .storage = .{ .elems = &field_values }, @@ -17393,7 +17393,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai const field_values = [_]InternPool.Index{ // layout: ContainerLayout, - (try mod.enumValueFieldIndex(container_layout_ty, @enumToInt(layout))).toIntern(), + (try mod.enumValueFieldIndex(container_layout_ty, @intFromEnum(layout))).toIntern(), // backing_integer: ?type, backing_integer_val, // fields: []const StructField, @@ -17405,7 +17405,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai }; return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Struct))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Struct))).toIntern(), .val = try mod.intern(.{ .aggregate = .{ .ty = type_struct_ty.toIntern(), .storage = .{ .elems = &field_values }, @@ -17437,7 +17437,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai }; return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{ .ty = type_info_ty.toIntern(), - .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Opaque))).toIntern(), + .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Opaque))).toIntern(), .val = try mod.intern(.{ .aggregate = .{ .ty = type_opaque_ty.toIntern(), .storage = .{ .elems = &field_values }, @@ -18494,7 +18494,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air var extra_i = extra.end; const sentinel = if (inst_data.flags.has_sentinel) blk: { - const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); + const ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_i]); extra_i += 1; const coerced = try sema.coerce(block, elem_ty, try sema.resolveInst(ref), sentinel_src); const val = try sema.resolveConstValue(block, sentinel_src, coerced, "pointer sentinel value must be comptime-known"); @@ -18502,7 +18502,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air } else .none; const abi_align: InternPool.Alignment = if (inst_data.flags.has_align) blk: { - const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); + const ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_i]); extra_i += 1; const coerced = try sema.coerce(block, Type.u32, try sema.resolveInst(ref), align_src); const val = try sema.resolveConstValue(block, align_src, coerced, "pointer alignment must be comptime-known"); @@ -18521,20 +18521,20 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air } else .none; const address_space: std.builtin.AddressSpace = if (inst_data.flags.has_addrspace) blk: { - const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); + const ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_i]); extra_i += 1; break :blk try sema.analyzeAddressSpace(block, addrspace_src, ref, .pointer); } else if (elem_ty.zigTypeTag(mod) == .Fn and target.cpu.arch == .avr) .flash else .generic; const bit_offset = if (inst_data.flags.has_bit_range) blk: { - const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); + const ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_i]); extra_i += 1; const bit_offset = try sema.resolveInt(block, bitoffset_src, ref, Type.u16, "pointer bit-offset must be comptime-known"); break :blk @intCast(u16, bit_offset); } else 0; const host_size: u16 = if (inst_data.flags.has_bit_range) blk: { - const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); + const ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_i]); extra_i += 1; const host_size = try sema.resolveInt(block, hostsize_src, ref, Type.u16, "pointer host size must be comptime-known"); break :blk @intCast(u16, host_size); @@ -19093,7 +19093,7 @@ fn zirArrayInit( const array_ty = try sema.resolveType(block, src, args[0]); const sentinel_val = array_ty.sentinel(mod); - const resolved_args = try gpa.alloc(Air.Inst.Ref, args.len - 1 + @boolToInt(sentinel_val != null)); + const resolved_args = try gpa.alloc(Air.Inst.Ref, args.len - 1 + @intFromBool(sentinel_val != null)); defer gpa.free(resolved_args); for (args[1..], 0..) |arg, i| { const resolved_arg = try sema.resolveInst(arg); @@ -19600,7 +19600,7 @@ fn zirReify( const mod = sema.mod; const gpa = sema.gpa; const ip = &mod.intern_pool; - const name_strategy = @intToEnum(Zir.Inst.NameStrategy, extended.small); + const name_strategy = @enumFromInt(Zir.Inst.NameStrategy, extended.small); const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; const src = LazySrcLoc.nodeOffset(extra.node); const type_info_ty = try sema.getBuiltinType("Type"); @@ -19612,7 +19612,7 @@ fn zirReify( const target = mod.getTarget(); if (try union_val.val.toValue().anyUndef(mod)) return sema.failWithUseOfUndef(block, src); const tag_index = type_info_ty.unionTagFieldIndex(union_val.tag.toValue(), mod).?; - switch (@intToEnum(std.builtin.TypeId, tag_index)) { + switch (@enumFromInt(std.builtin.TypeId, tag_index)) { .Type => return Air.Inst.Ref.type_type, .Void => return Air.Inst.Ref.void_type, .Bool => return Air.Inst.Ref.bool_type, @@ -20762,7 +20762,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro try sema.checkFloatType(block, operand_src, operand_ty); if (try sema.resolveMaybeUndefVal(operand)) |val| { - const result_val = try sema.floatToInt(block, operand_src, val, operand_ty, dest_ty); + const result_val = try sema.intFromFloat(block, operand_src, val, operand_ty, dest_ty); return sema.addConstant(dest_ty, result_val); } else if (dest_ty.zigTypeTag(mod) == .ComptimeInt) { return sema.failWithNeededComptime(block, operand_src, "value being casted to 'comptime_int' must be comptime-known"); @@ -20802,7 +20802,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro _ = try sema.checkIntType(block, operand_src, operand_ty); if (try sema.resolveMaybeUndefVal(operand)) |val| { - const result_val = try val.intToFloatAdvanced(sema.arena, operand_ty, dest_ty, sema.mod, sema); + const result_val = try val.floatFromIntAdvanced(sema.arena, operand_ty, dest_ty, sema.mod, sema); return sema.addConstant(dest_ty, result_val); } else if (dest_ty.zigTypeTag(mod) == .ComptimeFloat) { return sema.failWithNeededComptime(block, operand_src, "value being casted to 'comptime_float' must be comptime-known"); @@ -21750,7 +21750,7 @@ fn checkComptimeVarStore( src: LazySrcLoc, decl_ref_mut: InternPool.Key.Ptr.Addr.MutDecl, ) CompileError!void { - if (@enumToInt(decl_ref_mut.runtime_index) < @enumToInt(block.runtime_index)) { + if (@intFromEnum(decl_ref_mut.runtime_index) < @intFromEnum(block.runtime_index)) { if (block.runtime_cond) |cond_src| { const msg = msg: { const msg = try sema.errMsg(block, src, "store to comptime variable depends on runtime condition", .{}); @@ -22065,13 +22065,13 @@ fn zirCmpxchg( const success_order = try sema.resolveAtomicOrder(block, success_order_src, extra.success_order, "atomic order of cmpxchg success must be comptime-known"); const failure_order = try sema.resolveAtomicOrder(block, failure_order_src, extra.failure_order, "atomic order of cmpxchg failure must be comptime-known"); - if (@enumToInt(success_order) < @enumToInt(std.builtin.AtomicOrder.Monotonic)) { + if (@intFromEnum(success_order) < @intFromEnum(std.builtin.AtomicOrder.Monotonic)) { return sema.fail(block, success_order_src, "success atomic ordering must be Monotonic or stricter", .{}); } - if (@enumToInt(failure_order) < @enumToInt(std.builtin.AtomicOrder.Monotonic)) { + if (@intFromEnum(failure_order) < @intFromEnum(std.builtin.AtomicOrder.Monotonic)) { return sema.fail(block, failure_order_src, "failure atomic ordering must be Monotonic or stricter", .{}); } - if (@enumToInt(failure_order) > @enumToInt(success_order)) { + if (@intFromEnum(failure_order) > @intFromEnum(success_order)) { return sema.fail(block, failure_order_src, "failure atomic ordering must be no stricter than success", .{}); } if (failure_order == .Release or failure_order == .AcqRel) { @@ -22110,8 +22110,8 @@ fn zirCmpxchg( } else break :rs expected_src; } else ptr_src; - const flags: u32 = @as(u32, @enumToInt(success_order)) | - (@as(u32, @enumToInt(failure_order)) << 3); + const flags: u32 = @as(u32, @intFromEnum(success_order)) | + (@as(u32, @intFromEnum(failure_order)) << 3); try sema.requireRuntimeBlock(block, src, runtime_src); return block.addInst(.{ @@ -22610,7 +22610,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A } else break :rs ptr_src; } else ptr_src; - const flags: u32 = @as(u32, @enumToInt(order)) | (@as(u32, @enumToInt(op)) << 3); + const flags: u32 = @as(u32, @intFromEnum(order)) | (@as(u32, @intFromEnum(op)) << 3); try sema.requireRuntimeBlock(block, src, runtime_src); return block.addInst(.{ @@ -23556,7 +23556,7 @@ fn zirVarExtended( assert(!small.has_align); const uncasted_init: Air.Inst.Ref = if (small.has_init) blk: { - const init_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const init_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; break :blk try sema.resolveInst(init_ref); } else .none; @@ -23641,7 +23641,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A break :blk alignment; } } else if (extra.data.bits.has_align_ref) blk: { - const align_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const align_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const align_tv = sema.resolveInstConst(block, align_src, align_ref, "alignment must be comptime-known") catch |err| switch (err) { error.GenericPoison => { @@ -23671,7 +23671,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A } break :blk mod.toEnum(std.builtin.AddressSpace, val); } else if (extra.data.bits.has_addrspace_ref) blk: { - const addrspace_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const addrspace_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const addrspace_tv = sema.resolveInstConst(block, addrspace_src, addrspace_ref, "addrespace must be comptime-known") catch |err| switch (err) { error.GenericPoison => { @@ -23695,7 +23695,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A } break :blk FuncLinkSection{ .explicit = try val.toIpString(ty, mod) }; } else if (extra.data.bits.has_section_ref) blk: { - const section_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const section_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const section_name = sema.resolveConstStringIntern(block, section_src, section_ref, "linksection must be comptime-known") catch |err| switch (err) { error.GenericPoison => { @@ -23719,7 +23719,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A } break :blk mod.toEnum(std.builtin.CallingConvention, val); } else if (extra.data.bits.has_cc_ref) blk: { - const cc_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const cc_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const cc_tv = sema.resolveInstConst(block, cc_src, cc_ref, "calling convention must be comptime-known") catch |err| switch (err) { error.GenericPoison => { @@ -23743,7 +23743,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A const ty = val.toType(); break :blk ty; } else if (extra.data.bits.has_ret_ty_ref) blk: { - const ret_ty_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); + const ret_ty_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]); extra_index += 1; const ret_ty_tv = sema.resolveInstConst(block, ret_src, ret_ty_ref, "return type must be comptime-known") catch |err| switch (err) { error.GenericPoison => { @@ -26354,7 +26354,7 @@ fn elemValArray( const array_ty = sema.typeOf(array); const array_sent = array_ty.sentinel(mod); const array_len = array_ty.arrayLen(mod); - const array_len_s = array_len + @boolToInt(array_sent != null); + const array_len_s = array_len + @intFromBool(array_sent != null); const elem_ty = array_ty.childType(mod); if (array_len_s == 0) { @@ -26419,7 +26419,7 @@ fn elemPtrArray( const array_ty = array_ptr_ty.childType(mod); const array_sent = array_ty.sentinel(mod) != null; const array_len = array_ty.arrayLen(mod); - const array_len_s = array_len + @boolToInt(array_sent); + const array_len_s = array_len + @intFromBool(array_sent); if (array_len_s == 0) { return sema.fail(block, array_ptr_src, "indexing into empty array is not allowed", .{}); @@ -26489,7 +26489,7 @@ fn elemValSlice( if (maybe_slice_val) |slice_val| { runtime_src = elem_index_src; const slice_len = slice_val.sliceLen(mod); - const slice_len_s = slice_len + @boolToInt(slice_sent); + const slice_len_s = slice_len + @intFromBool(slice_sent); if (slice_len_s == 0) { return sema.fail(block, slice_src, "indexing into empty slice is not allowed", .{}); } @@ -26551,7 +26551,7 @@ fn elemPtrSlice( return sema.addConstUndef(elem_ptr_ty); } const slice_len = slice_val.sliceLen(mod); - const slice_len_s = slice_len + @boolToInt(slice_sent); + const slice_len_s = slice_len + @intFromBool(slice_sent); if (slice_len_s == 0) { return sema.fail(block, slice_src, "indexing into empty slice is not allowed", .{}); } @@ -27020,7 +27020,7 @@ fn coerceExtra( .{ val.fmtValue(inst_ty, mod), dest_ty.fmt(mod) }, ); } - const result_val = try sema.floatToInt(block, inst_src, val, inst_ty, dest_ty); + const result_val = try sema.intFromFloat(block, inst_src, val, inst_ty, dest_ty); return try sema.addConstant(dest_ty, result_val); }, .Int, .ComptimeInt => { @@ -27102,9 +27102,9 @@ fn coerceExtra( } break :int; }; - const result_val = try val.intToFloatAdvanced(sema.arena, inst_ty, dest_ty, mod, sema); + const result_val = try val.floatFromIntAdvanced(sema.arena, inst_ty, dest_ty, mod, sema); // TODO implement this compile error - //const int_again_val = try result_val.floatToInt(sema.arena, inst_ty); + //const int_again_val = try result_val.intFromFloat(sema.arena, inst_ty); //if (!int_again_val.eql(val, inst_ty, mod)) { // return sema.fail( // block, @@ -30773,7 +30773,7 @@ fn analyzeSlice( } const has_sentinel = slice_ty.sentinel(mod) != null; const slice_len = slice_val.sliceLen(mod); - const len_plus_sent = slice_len + @boolToInt(has_sentinel); + const len_plus_sent = slice_len + @intFromBool(has_sentinel); const slice_len_val_with_sentinel = try mod.intValue(Type.usize, len_plus_sent); if (!(try sema.compareAll(end_val, .lte, slice_len_val_with_sentinel, Type.usize))) { const sentinel_label: []const u8 = if (has_sentinel) @@ -31234,12 +31234,12 @@ fn cmpNumeric( } else { lhs_bits = lhs_val.intBitCountTwosComp(mod); } - lhs_bits += @boolToInt(!lhs_is_signed and dest_int_is_signed); + lhs_bits += @intFromBool(!lhs_is_signed and dest_int_is_signed); } else if (lhs_is_float) { dest_float_type = lhs_ty; } else { const int_info = lhs_ty.intInfo(mod); - lhs_bits = int_info.bits + @boolToInt(int_info.signedness == .unsigned and dest_int_is_signed); + lhs_bits = int_info.bits + @intFromBool(int_info.signedness == .unsigned and dest_int_is_signed); } var rhs_bits: usize = undefined; @@ -31292,12 +31292,12 @@ fn cmpNumeric( } else { rhs_bits = rhs_val.intBitCountTwosComp(mod); } - rhs_bits += @boolToInt(!rhs_is_signed and dest_int_is_signed); + rhs_bits += @intFromBool(!rhs_is_signed and dest_int_is_signed); } else if (rhs_is_float) { dest_float_type = rhs_ty; } else { const int_info = rhs_ty.intInfo(mod); - rhs_bits = int_info.bits + @boolToInt(int_info.signedness == .unsigned and dest_int_is_signed); + rhs_bits = int_info.bits + @intFromBool(int_info.signedness == .unsigned and dest_int_is_signed); } const dest_ty = if (dest_float_type) |ft| ft else blk: { @@ -31356,7 +31356,7 @@ fn compareIntsOnlyPossibleResult( .neq, .lt, .lte => true, }; - const sign_adj = @boolToInt(!is_negative and rhs_info.signedness == .signed); + const sign_adj = @intFromBool(!is_negative and rhs_info.signedness == .signed); const req_bits = lhs_val.intBitCountTwosComp(mod) + sign_adj; // No sized type can have more than 65535 bits. @@ -31628,7 +31628,7 @@ const PeerResolveStrategy = enum { // Our merging should be order-independent. Thus, even though the union order is arbitrary, // by sorting the tags and switching first on the smaller, we have half as many cases to // worry about (since we avoid the duplicates). - const s0_is_a = @enumToInt(a) <= @enumToInt(b); + const s0_is_a = @intFromEnum(a) <= @intFromEnum(b); const s0 = if (s0_is_a) a else b; const s1 = if (s0_is_a) b else a; @@ -33288,9 +33288,9 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi if (small.has_backing_int) { var extra_index: usize = extended.operand; - extra_index += @boolToInt(small.has_src_node); - extra_index += @boolToInt(small.has_fields_len); - extra_index += @boolToInt(small.has_decls_len); + extra_index += @intFromBool(small.has_src_node); + extra_index += @intFromBool(small.has_fields_len); + extra_index += @intFromBool(small.has_decls_len); const backing_int_body_len = zir.extra[extra_index]; extra_index += 1; @@ -33338,7 +33338,7 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi const backing_int_src: LazySrcLoc = .{ .node_offset_container_tag = 0 }; const backing_int_ty = blk: { if (backing_int_body_len == 0) { - const backing_int_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); + const backing_int_ref = @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]); break :blk try sema.resolveType(&block, backing_int_src, backing_int_ref); } else { const body = zir.extra[extra_index..][0..backing_int_body_len]; @@ -34013,7 +34013,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void var extra_index: usize = extended.operand; const src = LazySrcLoc.nodeOffset(0); - extra_index += @boolToInt(small.has_src_node); + extra_index += @intFromBool(small.has_src_node); const fields_len = if (small.has_fields_len) blk: { const fields_len = zir.extra[extra_index]; @@ -34140,7 +34140,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void if (has_type_body) { fields[field_i].type_body_len = zir.extra[extra_index]; } else { - fields[field_i].type_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); + fields[field_i].type_ref = @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]); } extra_index += 1; @@ -34364,10 +34364,10 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { var extra_index: usize = extended.operand; const src = LazySrcLoc.nodeOffset(0); - extra_index += @boolToInt(small.has_src_node); + extra_index += @intFromBool(small.has_src_node); const tag_type_ref: Zir.Inst.Ref = if (small.has_tag_type) blk: { - const ty_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); + const ty_ref = @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]); extra_index += 1; break :blk ty_ref; } else .none; @@ -34532,19 +34532,19 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { extra_index += 1; const field_type_ref: Zir.Inst.Ref = if (has_type) blk: { - const field_type_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); + const field_type_ref = @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]); extra_index += 1; break :blk field_type_ref; } else .none; const align_ref: Zir.Inst.Ref = if (has_align) blk: { - const align_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); + const align_ref = @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]); extra_index += 1; break :blk align_ref; } else .none; const tag_ref: Air.Inst.Ref = if (has_tag) blk: { - const tag_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); + const tag_ref = @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]); extra_index += 1; break :blk try sema.resolveInst(tag_ref); } else .none; @@ -34955,7 +34955,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { inline .array_type, .vector_type => |seq_type, seq_tag| { const has_sentinel = seq_tag == .array_type and seq_type.sentinel != .none; - if (seq_type.len + @boolToInt(has_sentinel) == 0) return (try mod.intern(.{ .aggregate = .{ + if (seq_type.len + @intFromBool(has_sentinel) == 0) return (try mod.intern(.{ .aggregate = .{ .ty = ty.toIntern(), .storage = .{ .elems = &.{} }, } })).toValue(); @@ -35177,8 +35177,8 @@ pub fn getTmpAir(sema: Sema) Air { } pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref { - if (@enumToInt(ty.toIntern()) < Air.ref_start_index) - return @intToEnum(Air.Inst.Ref, @enumToInt(ty.toIntern())); + if (@intFromEnum(ty.toIntern()) < Air.ref_start_index) + return @enumFromInt(Air.Inst.Ref, @intFromEnum(ty.toIntern())); try sema.air_instructions.append(sema.gpa, .{ .tag = .interned, .data = .{ .interned = ty.toIntern() }, @@ -35209,8 +35209,8 @@ pub fn addConstant(sema: *Sema, ty: Type, val: Value) SemaError!Air.Inst.Ref { }); } } - if (@enumToInt(val.toIntern()) < Air.ref_start_index) - return @intToEnum(Air.Inst.Ref, @enumToInt(val.toIntern())); + if (@intFromEnum(val.toIntern()) < Air.ref_start_index) + return @enumFromInt(Air.Inst.Ref, @intFromEnum(val.toIntern())); try sema.air_instructions.append(gpa, .{ .tag = .interned, .data = .{ .interned = val.toIntern() }, @@ -35230,9 +35230,9 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 { inline for (fields) |field| { sema.air_extra.appendAssumeCapacity(switch (field.type) { u32 => @field(extra, field.name), - Air.Inst.Ref => @enumToInt(@field(extra, field.name)), + Air.Inst.Ref => @intFromEnum(@field(extra, field.name)), i32 => @bitCast(u32, @field(extra, field.name)), - InternPool.Index => @enumToInt(@field(extra, field.name)), + InternPool.Index => @intFromEnum(@field(extra, field.name)), else => @compileError("bad field type: " ++ @typeName(field.type)), }); } @@ -36001,12 +36001,12 @@ fn intSubWithOverflowScalar( const overflowed = result_bigint.subWrap(lhs_bigint, rhs_bigint, info.signedness, info.bits); const wrapped_result = try mod.intValue_big(ty, result_bigint.toConst()); return Value.OverflowArithmeticResult{ - .overflow_bit = try mod.intValue(Type.u1, @boolToInt(overflowed)), + .overflow_bit = try mod.intValue(Type.u1, @intFromBool(overflowed)), .wrapped_result = wrapped_result, }; } -fn floatToInt( +fn intFromFloat( sema: *Sema, block: *Block, src: LazySrcLoc, @@ -36021,14 +36021,14 @@ fn floatToInt( const scalar_ty = int_ty.scalarType(mod); for (result_data, 0..) |*scalar, i| { const elem_val = try val.elemValue(sema.mod, i); - scalar.* = try (try sema.floatToIntScalar(block, src, elem_val, elem_ty, int_ty.scalarType(mod))).intern(scalar_ty, mod); + scalar.* = try (try sema.intFromFloatScalar(block, src, elem_val, elem_ty, int_ty.scalarType(mod))).intern(scalar_ty, mod); } return (try mod.intern(.{ .aggregate = .{ .ty = int_ty.toIntern(), .storage = .{ .elems = result_data }, } })).toValue(); } - return sema.floatToIntScalar(block, src, val, float_ty, int_ty); + return sema.intFromFloatScalar(block, src, val, float_ty, int_ty); } // float is expected to be finite and non-NaN @@ -36056,7 +36056,7 @@ fn float128IntPartToBigInt( return rational.p; } -fn floatToIntScalar( +fn intFromFloatScalar( sema: *Sema, block: *Block, src: LazySrcLoc, @@ -36123,21 +36123,21 @@ fn intFitsInType( return big_int.fitsInTwosComp(info.signedness, info.bits); }, .lazy_align => |lazy_ty| { - const max_needed_bits = @as(u16, 16) + @boolToInt(info.signedness == .signed); + const max_needed_bits = @as(u16, 16) + @intFromBool(info.signedness == .signed); // If it is u16 or bigger we know the alignment fits without resolving it. if (info.bits >= max_needed_bits) return true; const x = try sema.typeAbiAlignment(lazy_ty.toType()); if (x == 0) return true; - const actual_needed_bits = std.math.log2(x) + 1 + @boolToInt(info.signedness == .signed); + const actual_needed_bits = std.math.log2(x) + 1 + @intFromBool(info.signedness == .signed); return info.bits >= actual_needed_bits; }, .lazy_size => |lazy_ty| { - const max_needed_bits = @as(u16, 64) + @boolToInt(info.signedness == .signed); + const max_needed_bits = @as(u16, 64) + @intFromBool(info.signedness == .signed); // If it is u64 or bigger we know the size fits without resolving it. if (info.bits >= max_needed_bits) return true; const x = try sema.typeAbiSize(lazy_ty.toType()); if (x == 0) return true; - const actual_needed_bits = std.math.log2(x) + 1 + @boolToInt(info.signedness == .signed); + const actual_needed_bits = std.math.log2(x) + 1 + @intFromBool(info.signedness == .signed); return info.bits >= actual_needed_bits; }, }, @@ -36146,7 +36146,7 @@ fn intFitsInType( return switch (aggregate.storage) { .bytes => |bytes| for (bytes, 0..) |byte, i| { if (byte == 0) continue; - const actual_needed_bits = std.math.log2(byte) + 1 + @boolToInt(info.signedness == .signed); + const actual_needed_bits = std.math.log2(byte) + 1 + @intFromBool(info.signedness == .signed); if (info.bits >= actual_needed_bits) continue; if (vector_index) |vi| vi.* = i; break false; @@ -36242,7 +36242,7 @@ fn intAddWithOverflowScalar( const overflowed = result_bigint.addWrap(lhs_bigint, rhs_bigint, info.signedness, info.bits); const result = try mod.intValue_big(ty, result_bigint.toConst()); return Value.OverflowArithmeticResult{ - .overflow_bit = try mod.intValue(Type.u1, @boolToInt(overflowed)), + .overflow_bit = try mod.intValue(Type.u1, @intFromBool(overflowed)), .wrapped_result = result, }; } @@ -36352,7 +36352,7 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type { break :blk .{ .host_size = @intCast(u16, parent_ty.arrayLen(mod)), .alignment = @intCast(u16, parent_ty.abiAlignment(mod)), - .vector_index = if (offset) |some| @intToEnum(VI, some) else .runtime, + .vector_index = if (offset) |some| @enumFromInt(VI, some) else .runtime, }; } else .{}; diff --git a/src/TypedValue.zig b/src/TypedValue.zig index 93454710dc28..159297a4e8f8 100644 --- a/src/TypedValue.zig +++ b/src/TypedValue.zig @@ -41,8 +41,8 @@ pub fn hash(tv: TypedValue, hasher: *std.hash.Wyhash, mod: *Module) void { return tv.val.hash(tv.ty, hasher, mod); } -pub fn enumToInt(tv: TypedValue, mod: *Module) Allocator.Error!Value { - return tv.val.enumToInt(tv.ty, mod); +pub fn intFromEnum(tv: TypedValue, mod: *Module) Allocator.Error!Value { + return tv.val.intFromEnum(tv.ty, mod); } const max_aggregate_items = 100; @@ -240,7 +240,7 @@ pub fn print( try writer.print(".{i}", .{enum_type.names[tag_index].fmt(ip)}); return; } - try writer.writeAll("@intToEnum("); + try writer.writeAll("@enumFromInt("); try print(.{ .ty = Type.type, .val = enum_tag.ty.toValue(), diff --git a/src/Zir.zig b/src/Zir.zig index 5b00dc22aa52..4a0fdde24f95 100644 --- a/src/Zir.zig +++ b/src/Zir.zig @@ -74,7 +74,7 @@ pub fn extraData(code: Zir, comptime T: type, index: usize) struct { data: T, en inline for (fields) |field| { @field(result, field.name) = switch (field.type) { u32 => code.extra[i], - Inst.Ref => @intToEnum(Inst.Ref, code.extra[i]), + Inst.Ref => @enumFromInt(Inst.Ref, code.extra[i]), i32 => @bitCast(i32, code.extra[i]), Inst.Call.Flags => @bitCast(Inst.Call.Flags, code.extra[i]), Inst.BuiltinCall.Flags => @bitCast(Inst.BuiltinCall.Flags, code.extra[i]), @@ -105,7 +105,7 @@ pub fn refSlice(code: Zir, start: usize, len: usize) []Inst.Ref { } pub fn hasCompileErrors(code: Zir) bool { - return code.extra[@enumToInt(ExtraIndex.compile_errors)] != 0; + return code.extra[@intFromEnum(ExtraIndex.compile_errors)] != 0; } pub fn deinit(code: *Zir, gpa: Allocator) void { @@ -1934,7 +1934,7 @@ pub const Inst = struct { /// Implement builtin `@errToInt`. /// `operand` is payload index to `UnNode`. int_from_error, - /// Implement builtin `@intToError`. + /// Implement builtin `@errorFromInt`. /// `operand` is payload index to `UnNode`. error_from_int, /// Implement builtin `@Type`. @@ -2005,93 +2005,93 @@ pub const Inst = struct { /// The tag type is specified so that it is safe to bitcast between `[]u32` /// and `[]Ref`. pub const Ref = enum(u32) { - u1_type = @enumToInt(InternPool.Index.u1_type), - u8_type = @enumToInt(InternPool.Index.u8_type), - i8_type = @enumToInt(InternPool.Index.i8_type), - u16_type = @enumToInt(InternPool.Index.u16_type), - i16_type = @enumToInt(InternPool.Index.i16_type), - u29_type = @enumToInt(InternPool.Index.u29_type), - u32_type = @enumToInt(InternPool.Index.u32_type), - i32_type = @enumToInt(InternPool.Index.i32_type), - u64_type = @enumToInt(InternPool.Index.u64_type), - i64_type = @enumToInt(InternPool.Index.i64_type), - u80_type = @enumToInt(InternPool.Index.u80_type), - u128_type = @enumToInt(InternPool.Index.u128_type), - i128_type = @enumToInt(InternPool.Index.i128_type), - usize_type = @enumToInt(InternPool.Index.usize_type), - isize_type = @enumToInt(InternPool.Index.isize_type), - c_char_type = @enumToInt(InternPool.Index.c_char_type), - c_short_type = @enumToInt(InternPool.Index.c_short_type), - c_ushort_type = @enumToInt(InternPool.Index.c_ushort_type), - c_int_type = @enumToInt(InternPool.Index.c_int_type), - c_uint_type = @enumToInt(InternPool.Index.c_uint_type), - c_long_type = @enumToInt(InternPool.Index.c_long_type), - c_ulong_type = @enumToInt(InternPool.Index.c_ulong_type), - c_longlong_type = @enumToInt(InternPool.Index.c_longlong_type), - c_ulonglong_type = @enumToInt(InternPool.Index.c_ulonglong_type), - c_longdouble_type = @enumToInt(InternPool.Index.c_longdouble_type), - f16_type = @enumToInt(InternPool.Index.f16_type), - f32_type = @enumToInt(InternPool.Index.f32_type), - f64_type = @enumToInt(InternPool.Index.f64_type), - f80_type = @enumToInt(InternPool.Index.f80_type), - f128_type = @enumToInt(InternPool.Index.f128_type), - anyopaque_type = @enumToInt(InternPool.Index.anyopaque_type), - bool_type = @enumToInt(InternPool.Index.bool_type), - void_type = @enumToInt(InternPool.Index.void_type), - type_type = @enumToInt(InternPool.Index.type_type), - anyerror_type = @enumToInt(InternPool.Index.anyerror_type), - comptime_int_type = @enumToInt(InternPool.Index.comptime_int_type), - comptime_float_type = @enumToInt(InternPool.Index.comptime_float_type), - noreturn_type = @enumToInt(InternPool.Index.noreturn_type), - anyframe_type = @enumToInt(InternPool.Index.anyframe_type), - null_type = @enumToInt(InternPool.Index.null_type), - undefined_type = @enumToInt(InternPool.Index.undefined_type), - enum_literal_type = @enumToInt(InternPool.Index.enum_literal_type), - atomic_order_type = @enumToInt(InternPool.Index.atomic_order_type), - atomic_rmw_op_type = @enumToInt(InternPool.Index.atomic_rmw_op_type), - calling_convention_type = @enumToInt(InternPool.Index.calling_convention_type), - address_space_type = @enumToInt(InternPool.Index.address_space_type), - float_mode_type = @enumToInt(InternPool.Index.float_mode_type), - reduce_op_type = @enumToInt(InternPool.Index.reduce_op_type), - call_modifier_type = @enumToInt(InternPool.Index.call_modifier_type), - prefetch_options_type = @enumToInt(InternPool.Index.prefetch_options_type), - export_options_type = @enumToInt(InternPool.Index.export_options_type), - extern_options_type = @enumToInt(InternPool.Index.extern_options_type), - type_info_type = @enumToInt(InternPool.Index.type_info_type), - manyptr_u8_type = @enumToInt(InternPool.Index.manyptr_u8_type), - manyptr_const_u8_type = @enumToInt(InternPool.Index.manyptr_const_u8_type), - manyptr_const_u8_sentinel_0_type = @enumToInt(InternPool.Index.manyptr_const_u8_sentinel_0_type), - single_const_pointer_to_comptime_int_type = @enumToInt(InternPool.Index.single_const_pointer_to_comptime_int_type), - slice_const_u8_type = @enumToInt(InternPool.Index.slice_const_u8_type), - slice_const_u8_sentinel_0_type = @enumToInt(InternPool.Index.slice_const_u8_sentinel_0_type), - anyerror_void_error_union_type = @enumToInt(InternPool.Index.anyerror_void_error_union_type), - generic_poison_type = @enumToInt(InternPool.Index.generic_poison_type), - empty_struct_type = @enumToInt(InternPool.Index.empty_struct_type), - undef = @enumToInt(InternPool.Index.undef), - zero = @enumToInt(InternPool.Index.zero), - zero_usize = @enumToInt(InternPool.Index.zero_usize), - zero_u8 = @enumToInt(InternPool.Index.zero_u8), - one = @enumToInt(InternPool.Index.one), - one_usize = @enumToInt(InternPool.Index.one_usize), - one_u8 = @enumToInt(InternPool.Index.one_u8), - four_u8 = @enumToInt(InternPool.Index.four_u8), - negative_one = @enumToInt(InternPool.Index.negative_one), - calling_convention_c = @enumToInt(InternPool.Index.calling_convention_c), - calling_convention_inline = @enumToInt(InternPool.Index.calling_convention_inline), - void_value = @enumToInt(InternPool.Index.void_value), - unreachable_value = @enumToInt(InternPool.Index.unreachable_value), - null_value = @enumToInt(InternPool.Index.null_value), - bool_true = @enumToInt(InternPool.Index.bool_true), - bool_false = @enumToInt(InternPool.Index.bool_false), - empty_struct = @enumToInt(InternPool.Index.empty_struct), - generic_poison = @enumToInt(InternPool.Index.generic_poison), + u1_type = @intFromEnum(InternPool.Index.u1_type), + u8_type = @intFromEnum(InternPool.Index.u8_type), + i8_type = @intFromEnum(InternPool.Index.i8_type), + u16_type = @intFromEnum(InternPool.Index.u16_type), + i16_type = @intFromEnum(InternPool.Index.i16_type), + u29_type = @intFromEnum(InternPool.Index.u29_type), + u32_type = @intFromEnum(InternPool.Index.u32_type), + i32_type = @intFromEnum(InternPool.Index.i32_type), + u64_type = @intFromEnum(InternPool.Index.u64_type), + i64_type = @intFromEnum(InternPool.Index.i64_type), + u80_type = @intFromEnum(InternPool.Index.u80_type), + u128_type = @intFromEnum(InternPool.Index.u128_type), + i128_type = @intFromEnum(InternPool.Index.i128_type), + usize_type = @intFromEnum(InternPool.Index.usize_type), + isize_type = @intFromEnum(InternPool.Index.isize_type), + c_char_type = @intFromEnum(InternPool.Index.c_char_type), + c_short_type = @intFromEnum(InternPool.Index.c_short_type), + c_ushort_type = @intFromEnum(InternPool.Index.c_ushort_type), + c_int_type = @intFromEnum(InternPool.Index.c_int_type), + c_uint_type = @intFromEnum(InternPool.Index.c_uint_type), + c_long_type = @intFromEnum(InternPool.Index.c_long_type), + c_ulong_type = @intFromEnum(InternPool.Index.c_ulong_type), + c_longlong_type = @intFromEnum(InternPool.Index.c_longlong_type), + c_ulonglong_type = @intFromEnum(InternPool.Index.c_ulonglong_type), + c_longdouble_type = @intFromEnum(InternPool.Index.c_longdouble_type), + f16_type = @intFromEnum(InternPool.Index.f16_type), + f32_type = @intFromEnum(InternPool.Index.f32_type), + f64_type = @intFromEnum(InternPool.Index.f64_type), + f80_type = @intFromEnum(InternPool.Index.f80_type), + f128_type = @intFromEnum(InternPool.Index.f128_type), + anyopaque_type = @intFromEnum(InternPool.Index.anyopaque_type), + bool_type = @intFromEnum(InternPool.Index.bool_type), + void_type = @intFromEnum(InternPool.Index.void_type), + type_type = @intFromEnum(InternPool.Index.type_type), + anyerror_type = @intFromEnum(InternPool.Index.anyerror_type), + comptime_int_type = @intFromEnum(InternPool.Index.comptime_int_type), + comptime_float_type = @intFromEnum(InternPool.Index.comptime_float_type), + noreturn_type = @intFromEnum(InternPool.Index.noreturn_type), + anyframe_type = @intFromEnum(InternPool.Index.anyframe_type), + null_type = @intFromEnum(InternPool.Index.null_type), + undefined_type = @intFromEnum(InternPool.Index.undefined_type), + enum_literal_type = @intFromEnum(InternPool.Index.enum_literal_type), + atomic_order_type = @intFromEnum(InternPool.Index.atomic_order_type), + atomic_rmw_op_type = @intFromEnum(InternPool.Index.atomic_rmw_op_type), + calling_convention_type = @intFromEnum(InternPool.Index.calling_convention_type), + address_space_type = @intFromEnum(InternPool.Index.address_space_type), + float_mode_type = @intFromEnum(InternPool.Index.float_mode_type), + reduce_op_type = @intFromEnum(InternPool.Index.reduce_op_type), + call_modifier_type = @intFromEnum(InternPool.Index.call_modifier_type), + prefetch_options_type = @intFromEnum(InternPool.Index.prefetch_options_type), + export_options_type = @intFromEnum(InternPool.Index.export_options_type), + extern_options_type = @intFromEnum(InternPool.Index.extern_options_type), + type_info_type = @intFromEnum(InternPool.Index.type_info_type), + manyptr_u8_type = @intFromEnum(InternPool.Index.manyptr_u8_type), + manyptr_const_u8_type = @intFromEnum(InternPool.Index.manyptr_const_u8_type), + manyptr_const_u8_sentinel_0_type = @intFromEnum(InternPool.Index.manyptr_const_u8_sentinel_0_type), + single_const_pointer_to_comptime_int_type = @intFromEnum(InternPool.Index.single_const_pointer_to_comptime_int_type), + slice_const_u8_type = @intFromEnum(InternPool.Index.slice_const_u8_type), + slice_const_u8_sentinel_0_type = @intFromEnum(InternPool.Index.slice_const_u8_sentinel_0_type), + anyerror_void_error_union_type = @intFromEnum(InternPool.Index.anyerror_void_error_union_type), + generic_poison_type = @intFromEnum(InternPool.Index.generic_poison_type), + empty_struct_type = @intFromEnum(InternPool.Index.empty_struct_type), + undef = @intFromEnum(InternPool.Index.undef), + zero = @intFromEnum(InternPool.Index.zero), + zero_usize = @intFromEnum(InternPool.Index.zero_usize), + zero_u8 = @intFromEnum(InternPool.Index.zero_u8), + one = @intFromEnum(InternPool.Index.one), + one_usize = @intFromEnum(InternPool.Index.one_usize), + one_u8 = @intFromEnum(InternPool.Index.one_u8), + four_u8 = @intFromEnum(InternPool.Index.four_u8), + negative_one = @intFromEnum(InternPool.Index.negative_one), + calling_convention_c = @intFromEnum(InternPool.Index.calling_convention_c), + calling_convention_inline = @intFromEnum(InternPool.Index.calling_convention_inline), + void_value = @intFromEnum(InternPool.Index.void_value), + unreachable_value = @intFromEnum(InternPool.Index.unreachable_value), + null_value = @intFromEnum(InternPool.Index.null_value), + bool_true = @intFromEnum(InternPool.Index.bool_true), + bool_false = @intFromEnum(InternPool.Index.bool_false), + empty_struct = @intFromEnum(InternPool.Index.empty_struct), + generic_poison = @intFromEnum(InternPool.Index.generic_poison), /// This tag is here to match Air and InternPool, however it is unused /// for ZIR purposes. - var_args_param_type = @enumToInt(InternPool.Index.var_args_param_type), + var_args_param_type = @intFromEnum(InternPool.Index.var_args_param_type), /// This Ref does not correspond to any ZIR instruction or constant /// value and may instead be used as a sentinel to indicate null. - none = @enumToInt(InternPool.Index.none), + none = @intFromEnum(InternPool.Index.none), _, }; @@ -2691,8 +2691,8 @@ pub const Inst = struct { pub const ScalarCasesLen = u28; pub fn specialProng(bits: Bits) SpecialProng { - const has_else: u2 = @boolToInt(bits.has_else); - const has_under: u2 = @boolToInt(bits.has_under); + const has_else: u2 = @intFromBool(bits.has_else); + const has_under: u2 = @intFromBool(bits.has_under); return switch ((has_else << 1) | has_under) { 0b00 => .none, 0b01 => .under, @@ -3241,8 +3241,8 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator { .struct_decl => { const small = @bitCast(Inst.StructDecl.Small, extended.small); var extra_index: usize = extended.operand; - extra_index += @boolToInt(small.has_src_node); - extra_index += @boolToInt(small.has_fields_len); + extra_index += @intFromBool(small.has_src_node); + extra_index += @intFromBool(small.has_fields_len); const decls_len = if (small.has_decls_len) decls_len: { const decls_len = zir.extra[extra_index]; extra_index += 1; @@ -3264,10 +3264,10 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator { .enum_decl => { const small = @bitCast(Inst.EnumDecl.Small, extended.small); var extra_index: usize = extended.operand; - extra_index += @boolToInt(small.has_src_node); - extra_index += @boolToInt(small.has_tag_type); - extra_index += @boolToInt(small.has_body_len); - extra_index += @boolToInt(small.has_fields_len); + extra_index += @intFromBool(small.has_src_node); + extra_index += @intFromBool(small.has_tag_type); + extra_index += @intFromBool(small.has_body_len); + extra_index += @intFromBool(small.has_fields_len); const decls_len = if (small.has_decls_len) decls_len: { const decls_len = zir.extra[extra_index]; extra_index += 1; @@ -3279,10 +3279,10 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator { .union_decl => { const small = @bitCast(Inst.UnionDecl.Small, extended.small); var extra_index: usize = extended.operand; - extra_index += @boolToInt(small.has_src_node); - extra_index += @boolToInt(small.has_tag_type); - extra_index += @boolToInt(small.has_body_len); - extra_index += @boolToInt(small.has_fields_len); + extra_index += @intFromBool(small.has_src_node); + extra_index += @intFromBool(small.has_tag_type); + extra_index += @intFromBool(small.has_body_len); + extra_index += @intFromBool(small.has_fields_len); const decls_len = if (small.has_decls_len) decls_len: { const decls_len = zir.extra[extra_index]; extra_index += 1; @@ -3294,7 +3294,7 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator { .opaque_decl => { const small = @bitCast(Inst.OpaqueDecl.Small, extended.small); var extra_index: usize = extended.operand; - extra_index += @boolToInt(small.has_src_node); + extra_index += @intFromBool(small.has_src_node); const decls_len = if (small.has_decls_len) decls_len: { const decls_len = zir.extra[extra_index]; extra_index += 1; @@ -3367,7 +3367,7 @@ fn findDeclsInner( const inst_data = datas[inst].pl_node; const extra = zir.extraData(Inst.FuncFancy, inst_data.payload_index); var extra_index: usize = extra.end; - extra_index += @boolToInt(extra.data.bits.has_lib_name); + extra_index += @intFromBool(extra.data.bits.has_lib_name); if (extra.data.bits.has_align_body) { const body_len = zir.extra[extra_index]; @@ -3419,7 +3419,7 @@ fn findDeclsInner( extra_index += 1; } - extra_index += @boolToInt(extra.data.bits.has_any_noalias); + extra_index += @intFromBool(extra.data.bits.has_any_noalias); const body = zir.extra[extra_index..][0..extra.data.body_len]; return zir.findDeclsBody(list, body); @@ -3598,7 +3598,7 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo { ret_ty_ref = .void_type; }, 1 => { - ret_ty_ref = @intToEnum(Inst.Ref, zir.extra[extra_index]); + ret_ty_ref = @enumFromInt(Inst.Ref, zir.extra[extra_index]); extra_index += 1; }, else => { @@ -3625,7 +3625,7 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo { var ret_ty_ref: Inst.Ref = .void_type; var ret_ty_body: []const Inst.Index = &.{}; - extra_index += @boolToInt(extra.data.bits.has_lib_name); + extra_index += @intFromBool(extra.data.bits.has_lib_name); if (extra.data.bits.has_align_body) { extra_index += zir.extra[extra_index] + 1; } else if (extra.data.bits.has_align_ref) { @@ -3652,11 +3652,11 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo { ret_ty_body = zir.extra[extra_index..][0..body_len]; extra_index += ret_ty_body.len; } else if (extra.data.bits.has_ret_ty_ref) { - ret_ty_ref = @intToEnum(Inst.Ref, zir.extra[extra_index]); + ret_ty_ref = @enumFromInt(Inst.Ref, zir.extra[extra_index]); extra_index += 1; } - extra_index += @boolToInt(extra.data.bits.has_any_noalias); + extra_index += @intFromBool(extra.data.bits.has_any_noalias); const body = zir.extra[extra_index..][0..extra.data.body_len]; extra_index += body.len; @@ -3696,12 +3696,12 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo { pub const ref_start_index: u32 = InternPool.static_len; pub fn indexToRef(inst: Inst.Index) Inst.Ref { - return @intToEnum(Inst.Ref, ref_start_index + inst); + return @enumFromInt(Inst.Ref, ref_start_index + inst); } pub fn refToIndex(inst: Inst.Ref) ?Inst.Index { assert(inst != .none); - const ref_int = @enumToInt(inst); + const ref_int = @intFromEnum(inst); if (ref_int >= ref_start_index) { return ref_int - ref_start_index; } else { diff --git a/src/arch/aarch64/CodeGen.zig b/src/arch/aarch64/CodeGen.zig index b93b9b212a8c..5080a0451a7c 100644 --- a/src/arch/aarch64/CodeGen.zig +++ b/src/arch/aarch64/CodeGen.zig @@ -951,7 +951,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live const dies = @truncate(u1, tomb_bits) != 0; tomb_bits >>= 1; if (!dies) continue; - const op_int = @enumToInt(op); + const op_int = @intFromEnum(op); if (op_int < Air.ref_start_index) continue; const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index); self.processDeath(op_index); @@ -4026,7 +4026,7 @@ fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type .tag = tag, .data = .{ .payload = try self.addExtra(Mir.LoadMemoryPie{ - .register = @enumToInt(src_reg), + .register = @intFromEnum(src_reg), .atom_index = atom_index, .sym_index = load_struct.sym_index, }), @@ -4694,7 +4694,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { // that death now instead of later as this has an effect on // whether it needs to be spilled in the branches if (self.liveness.operandDies(inst, 0)) { - const op_int = @enumToInt(pl_op.operand); + const op_int = @intFromEnum(pl_op.operand); if (op_int >= Air.ref_start_index) { const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index); self.processDeath(op_index); @@ -5546,7 +5546,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro .tag = tag, .data = .{ .payload = try self.addExtra(Mir.LoadMemoryPie{ - .register = @enumToInt(src_reg), + .register = @intFromEnum(src_reg), .atom_index = atom_index, .sym_index = load_struct.sym_index, }), @@ -5667,7 +5667,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void .tag = tag, .data = .{ .payload = try self.addExtra(Mir.LoadMemoryPie{ - .register = @enumToInt(reg), + .register = @intFromEnum(reg), .atom_index = atom_index, .sym_index = load_struct.sym_index, }), @@ -5864,7 +5864,7 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I .tag = tag, .data = .{ .payload = try self.addExtra(Mir.LoadMemoryPie{ - .register = @enumToInt(src_reg), + .register = @intFromEnum(src_reg), .atom_index = atom_index, .sym_index = load_struct.sym_index, }), diff --git a/src/arch/aarch64/Emit.zig b/src/arch/aarch64/Emit.zig index 3903229a2179..238a63c92112 100644 --- a/src/arch/aarch64/Emit.zig +++ b/src/arch/aarch64/Emit.zig @@ -837,7 +837,7 @@ fn mirLoadMemoryPie(emit: *Emit, inst: Mir.Inst.Index) !void { const tag = emit.mir.instructions.items(.tag)[inst]; const payload = emit.mir.instructions.items(.data)[inst].payload; const data = emit.mir.extraData(Mir.LoadMemoryPie, payload).data; - const reg = @intToEnum(Register, data.register); + const reg = @enumFromInt(Register, data.register); // PC-relative displacement to the entry in memory. // adrp @@ -1245,7 +1245,7 @@ fn mirPushPopRegs(emit: *Emit, inst: Mir.Inst.Index) !void { var count: u6 = 0; var other_reg: ?Register = null; while (i > 0) : (i -= 1) { - const reg = @intToEnum(Register, i - 1); + const reg = @enumFromInt(Register, i - 1); if (regListIsSet(reg_list, reg)) { if (count == 0 and odd_number_of_regs) { try emit.writeInstruction(Instruction.ldr( @@ -1274,7 +1274,7 @@ fn mirPushPopRegs(emit: *Emit, inst: Mir.Inst.Index) !void { var count: u6 = 0; var other_reg: ?Register = null; while (i < 32) : (i += 1) { - const reg = @intToEnum(Register, i); + const reg = @enumFromInt(Register, i); if (regListIsSet(reg_list, reg)) { if (count == number_of_regs - 1 and odd_number_of_regs) { try emit.writeInstruction(Instruction.str( diff --git a/src/arch/aarch64/bits.zig b/src/arch/aarch64/bits.zig index 0baa7e65ce4b..3446d6995091 100644 --- a/src/arch/aarch64/bits.zig +++ b/src/arch/aarch64/bits.zig @@ -62,84 +62,84 @@ pub const Register = enum(u8) { // zig fmt: on pub fn class(self: Register) RegisterClass { - return switch (@enumToInt(self)) { - @enumToInt(Register.x0)...@enumToInt(Register.xzr) => .general_purpose, - @enumToInt(Register.w0)...@enumToInt(Register.wzr) => .general_purpose, - - @enumToInt(Register.sp) => .stack_pointer, - @enumToInt(Register.wsp) => .stack_pointer, - - @enumToInt(Register.q0)...@enumToInt(Register.q31) => .floating_point, - @enumToInt(Register.d0)...@enumToInt(Register.d31) => .floating_point, - @enumToInt(Register.s0)...@enumToInt(Register.s31) => .floating_point, - @enumToInt(Register.h0)...@enumToInt(Register.h31) => .floating_point, - @enumToInt(Register.b0)...@enumToInt(Register.b31) => .floating_point, + return switch (@intFromEnum(self)) { + @intFromEnum(Register.x0)...@intFromEnum(Register.xzr) => .general_purpose, + @intFromEnum(Register.w0)...@intFromEnum(Register.wzr) => .general_purpose, + + @intFromEnum(Register.sp) => .stack_pointer, + @intFromEnum(Register.wsp) => .stack_pointer, + + @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => .floating_point, + @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => .floating_point, + @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => .floating_point, + @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => .floating_point, + @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => .floating_point, else => unreachable, }; } pub fn id(self: Register) u6 { - return switch (@enumToInt(self)) { - @enumToInt(Register.x0)...@enumToInt(Register.xzr) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.x0)), - @enumToInt(Register.w0)...@enumToInt(Register.wzr) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.w0)), - - @enumToInt(Register.sp) => 32, - @enumToInt(Register.wsp) => 32, - - @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.q0) + 33), - @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.d0) + 33), - @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.s0) + 33), - @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.h0) + 33), - @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.b0) + 33), + return switch (@intFromEnum(self)) { + @intFromEnum(Register.x0)...@intFromEnum(Register.xzr) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.x0)), + @intFromEnum(Register.w0)...@intFromEnum(Register.wzr) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.w0)), + + @intFromEnum(Register.sp) => 32, + @intFromEnum(Register.wsp) => 32, + + @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.q0) + 33), + @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.d0) + 33), + @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.s0) + 33), + @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.h0) + 33), + @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.b0) + 33), else => unreachable, }; } pub fn enc(self: Register) u5 { - return switch (@enumToInt(self)) { - @enumToInt(Register.x0)...@enumToInt(Register.xzr) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.x0)), - @enumToInt(Register.w0)...@enumToInt(Register.wzr) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.w0)), - - @enumToInt(Register.sp) => 31, - @enumToInt(Register.wsp) => 31, - - @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.q0)), - @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.d0)), - @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.s0)), - @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.h0)), - @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.b0)), + return switch (@intFromEnum(self)) { + @intFromEnum(Register.x0)...@intFromEnum(Register.xzr) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.x0)), + @intFromEnum(Register.w0)...@intFromEnum(Register.wzr) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.w0)), + + @intFromEnum(Register.sp) => 31, + @intFromEnum(Register.wsp) => 31, + + @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.q0)), + @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.d0)), + @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.s0)), + @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.h0)), + @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.b0)), else => unreachable, }; } /// Returns the bit-width of the register. pub fn size(self: Register) u8 { - return switch (@enumToInt(self)) { - @enumToInt(Register.x0)...@enumToInt(Register.xzr) => 64, - @enumToInt(Register.w0)...@enumToInt(Register.wzr) => 32, - - @enumToInt(Register.sp) => 64, - @enumToInt(Register.wsp) => 32, - - @enumToInt(Register.q0)...@enumToInt(Register.q31) => 128, - @enumToInt(Register.d0)...@enumToInt(Register.d31) => 64, - @enumToInt(Register.s0)...@enumToInt(Register.s31) => 32, - @enumToInt(Register.h0)...@enumToInt(Register.h31) => 16, - @enumToInt(Register.b0)...@enumToInt(Register.b31) => 8, + return switch (@intFromEnum(self)) { + @intFromEnum(Register.x0)...@intFromEnum(Register.xzr) => 64, + @intFromEnum(Register.w0)...@intFromEnum(Register.wzr) => 32, + + @intFromEnum(Register.sp) => 64, + @intFromEnum(Register.wsp) => 32, + + @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => 128, + @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => 64, + @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => 32, + @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => 16, + @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => 8, else => unreachable, }; } /// Convert from a general-purpose register to its 64 bit alias. pub fn toX(self: Register) Register { - return switch (@enumToInt(self)) { - @enumToInt(Register.x0)...@enumToInt(Register.xzr) => @intToEnum( + return switch (@intFromEnum(self)) { + @intFromEnum(Register.x0)...@intFromEnum(Register.xzr) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.x0) + @enumToInt(Register.x0), + @intFromEnum(self) - @intFromEnum(Register.x0) + @intFromEnum(Register.x0), ), - @enumToInt(Register.w0)...@enumToInt(Register.wzr) => @intToEnum( + @intFromEnum(Register.w0)...@intFromEnum(Register.wzr) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.w0) + @enumToInt(Register.x0), + @intFromEnum(self) - @intFromEnum(Register.w0) + @intFromEnum(Register.x0), ), else => unreachable, }; @@ -147,14 +147,14 @@ pub const Register = enum(u8) { /// Convert from a general-purpose register to its 32 bit alias. pub fn toW(self: Register) Register { - return switch (@enumToInt(self)) { - @enumToInt(Register.x0)...@enumToInt(Register.xzr) => @intToEnum( + return switch (@intFromEnum(self)) { + @intFromEnum(Register.x0)...@intFromEnum(Register.xzr) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.x0) + @enumToInt(Register.w0), + @intFromEnum(self) - @intFromEnum(Register.x0) + @intFromEnum(Register.w0), ), - @enumToInt(Register.w0)...@enumToInt(Register.wzr) => @intToEnum( + @intFromEnum(Register.w0)...@intFromEnum(Register.wzr) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.w0) + @enumToInt(Register.w0), + @intFromEnum(self) - @intFromEnum(Register.w0) + @intFromEnum(Register.w0), ), else => unreachable, }; @@ -162,26 +162,26 @@ pub const Register = enum(u8) { /// Convert from a floating-point register to its 128 bit alias. pub fn toQ(self: Register) Register { - return switch (@enumToInt(self)) { - @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intToEnum( + return switch (@intFromEnum(self)) { + @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.q0) + @enumToInt(Register.q0), + @intFromEnum(self) - @intFromEnum(Register.q0) + @intFromEnum(Register.q0), ), - @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intToEnum( + @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.d0) + @enumToInt(Register.q0), + @intFromEnum(self) - @intFromEnum(Register.d0) + @intFromEnum(Register.q0), ), - @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intToEnum( + @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.s0) + @enumToInt(Register.q0), + @intFromEnum(self) - @intFromEnum(Register.s0) + @intFromEnum(Register.q0), ), - @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intToEnum( + @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.h0) + @enumToInt(Register.q0), + @intFromEnum(self) - @intFromEnum(Register.h0) + @intFromEnum(Register.q0), ), - @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intToEnum( + @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.b0) + @enumToInt(Register.q0), + @intFromEnum(self) - @intFromEnum(Register.b0) + @intFromEnum(Register.q0), ), else => unreachable, }; @@ -189,26 +189,26 @@ pub const Register = enum(u8) { /// Convert from a floating-point register to its 64 bit alias. pub fn toD(self: Register) Register { - return switch (@enumToInt(self)) { - @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intToEnum( + return switch (@intFromEnum(self)) { + @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.q0) + @enumToInt(Register.d0), + @intFromEnum(self) - @intFromEnum(Register.q0) + @intFromEnum(Register.d0), ), - @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intToEnum( + @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.d0) + @enumToInt(Register.d0), + @intFromEnum(self) - @intFromEnum(Register.d0) + @intFromEnum(Register.d0), ), - @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intToEnum( + @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.s0) + @enumToInt(Register.d0), + @intFromEnum(self) - @intFromEnum(Register.s0) + @intFromEnum(Register.d0), ), - @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intToEnum( + @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.h0) + @enumToInt(Register.d0), + @intFromEnum(self) - @intFromEnum(Register.h0) + @intFromEnum(Register.d0), ), - @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intToEnum( + @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.b0) + @enumToInt(Register.d0), + @intFromEnum(self) - @intFromEnum(Register.b0) + @intFromEnum(Register.d0), ), else => unreachable, }; @@ -216,26 +216,26 @@ pub const Register = enum(u8) { /// Convert from a floating-point register to its 32 bit alias. pub fn toS(self: Register) Register { - return switch (@enumToInt(self)) { - @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intToEnum( + return switch (@intFromEnum(self)) { + @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.q0) + @enumToInt(Register.s0), + @intFromEnum(self) - @intFromEnum(Register.q0) + @intFromEnum(Register.s0), ), - @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intToEnum( + @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.d0) + @enumToInt(Register.s0), + @intFromEnum(self) - @intFromEnum(Register.d0) + @intFromEnum(Register.s0), ), - @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intToEnum( + @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.s0) + @enumToInt(Register.s0), + @intFromEnum(self) - @intFromEnum(Register.s0) + @intFromEnum(Register.s0), ), - @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intToEnum( + @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.h0) + @enumToInt(Register.s0), + @intFromEnum(self) - @intFromEnum(Register.h0) + @intFromEnum(Register.s0), ), - @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intToEnum( + @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.b0) + @enumToInt(Register.s0), + @intFromEnum(self) - @intFromEnum(Register.b0) + @intFromEnum(Register.s0), ), else => unreachable, }; @@ -243,26 +243,26 @@ pub const Register = enum(u8) { /// Convert from a floating-point register to its 16 bit alias. pub fn toH(self: Register) Register { - return switch (@enumToInt(self)) { - @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intToEnum( + return switch (@intFromEnum(self)) { + @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.q0) + @enumToInt(Register.h0), + @intFromEnum(self) - @intFromEnum(Register.q0) + @intFromEnum(Register.h0), ), - @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intToEnum( + @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.d0) + @enumToInt(Register.h0), + @intFromEnum(self) - @intFromEnum(Register.d0) + @intFromEnum(Register.h0), ), - @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intToEnum( + @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.s0) + @enumToInt(Register.h0), + @intFromEnum(self) - @intFromEnum(Register.s0) + @intFromEnum(Register.h0), ), - @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intToEnum( + @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.h0) + @enumToInt(Register.h0), + @intFromEnum(self) - @intFromEnum(Register.h0) + @intFromEnum(Register.h0), ), - @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intToEnum( + @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.b0) + @enumToInt(Register.h0), + @intFromEnum(self) - @intFromEnum(Register.b0) + @intFromEnum(Register.h0), ), else => unreachable, }; @@ -270,26 +270,26 @@ pub const Register = enum(u8) { /// Convert from a floating-point register to its 8 bit alias. pub fn toB(self: Register) Register { - return switch (@enumToInt(self)) { - @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intToEnum( + return switch (@intFromEnum(self)) { + @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.q0) + @enumToInt(Register.b0), + @intFromEnum(self) - @intFromEnum(Register.q0) + @intFromEnum(Register.b0), ), - @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intToEnum( + @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.d0) + @enumToInt(Register.b0), + @intFromEnum(self) - @intFromEnum(Register.d0) + @intFromEnum(Register.b0), ), - @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intToEnum( + @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.s0) + @enumToInt(Register.b0), + @intFromEnum(self) - @intFromEnum(Register.s0) + @intFromEnum(Register.b0), ), - @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intToEnum( + @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.h0) + @enumToInt(Register.b0), + @intFromEnum(self) - @intFromEnum(Register.h0) + @intFromEnum(Register.b0), ), - @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intToEnum( + @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @enumFromInt( Register, - @enumToInt(self) - @enumToInt(Register.b0) + @enumToInt(Register.b0), + @intFromEnum(self) - @intFromEnum(Register.b0) + @intFromEnum(Register.b0), ), else => unreachable, }; @@ -901,7 +901,7 @@ pub const Instruction = union(enum) { .rn = rn.enc(), .rt2 = rt2.enc(), .imm7 = imm7, - .load = @boolToInt(load), + .load = @intFromBool(load), .encoding = encoding, .opc = 0b00, }, @@ -916,7 +916,7 @@ pub const Instruction = union(enum) { .rn = rn.enc(), .rt2 = rt2.enc(), .imm7 = imm7, - .load = @boolToInt(load), + .load = @intFromBool(load), .encoding = encoding, .opc = 0b10, }, @@ -1010,7 +1010,7 @@ pub const Instruction = union(enum) { .imm6 = amount, .rm = rm.enc(), .n = n, - .shift = @enumToInt(shift), + .shift = @intFromEnum(shift), .opc = opc, .sf = switch (rd.size()) { 32 => 0b0, @@ -1037,7 +1037,7 @@ pub const Instruction = union(enum) { .rd = rd.enc(), .rn = rn.enc(), .imm12 = imm12, - .sh = @boolToInt(shift), + .sh = @intFromBool(shift), .s = s, .op = op, .sf = switch (rd.size()) { @@ -1126,7 +1126,7 @@ pub const Instruction = union(enum) { .rn = rn.enc(), .imm6 = imm6, .rm = rm.enc(), - .shift = @enumToInt(shift), + .shift = @intFromEnum(shift), .s = s, .op = op, .sf = switch (rd.size()) { @@ -1163,7 +1163,7 @@ pub const Instruction = union(enum) { .rd = rd.enc(), .rn = rn.enc(), .imm3 = imm3, - .option = @enumToInt(extend), + .option = @intFromEnum(extend), .rm = rm.enc(), .s = s, .op = op, @@ -1186,7 +1186,7 @@ pub const Instruction = union(enum) { return Instruction{ .conditional_branch = .{ - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), .o0 = o0, .imm19 = @bitCast(u19, @intCast(i19, offset >> 2)), .o1 = o1, @@ -1232,7 +1232,7 @@ pub const Instruction = union(enum) { .rd = rd.enc(), .rn = rn.enc(), .op2 = op2, - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), .rm = rm.enc(), .s = s, .op = op, @@ -1394,7 +1394,7 @@ pub const Instruction = union(enum) { }; pub fn ldp(rt1: Register, rt2: Register, rn: Register, offset: LoadStorePairOffset) Instruction { - return loadStoreRegisterPair(rt1, rt2, rn, offset.offset, @enumToInt(offset.encoding), true); + return loadStoreRegisterPair(rt1, rt2, rn, offset.offset, @intFromEnum(offset.encoding), true); } pub fn ldnp(rt1: Register, rt2: Register, rn: Register, offset: i9) Instruction { @@ -1402,7 +1402,7 @@ pub const Instruction = union(enum) { } pub fn stp(rt1: Register, rt2: Register, rn: Register, offset: LoadStorePairOffset) Instruction { - return loadStoreRegisterPair(rt1, rt2, rn, offset.offset, @enumToInt(offset.encoding), false); + return loadStoreRegisterPair(rt1, rt2, rn, offset.offset, @intFromEnum(offset.encoding), false); } pub fn stnp(rt1: Register, rt2: Register, rn: Register, offset: i9) Instruction { diff --git a/src/arch/arm/CodeGen.zig b/src/arch/arm/CodeGen.zig index 2ad9a8775cb3..7ece4ba2e3a3 100644 --- a/src/arch/arm/CodeGen.zig +++ b/src/arch/arm/CodeGen.zig @@ -937,7 +937,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live const dies = @truncate(u1, tomb_bits) != 0; tomb_bits >>= 1; if (!dies) continue; - const op_int = @enumToInt(op); + const op_int = @intFromEnum(op); if (op_int < Air.ref_start_index) continue; const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index); self.processDeath(op_index); @@ -4649,7 +4649,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { // that death now instead of later as this has an effect on // whether it needs to be spilled in the branches if (self.liveness.operandDies(inst, 0)) { - const op_int = @enumToInt(pl_op.operand); + const op_int = @intFromEnum(pl_op.operand); if (op_int >= Air.ref_start_index) { const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index); self.processDeath(op_index); diff --git a/src/arch/arm/bits.zig b/src/arch/arm/bits.zig index 185c4ed921ca..1de40a7059bc 100644 --- a/src/arch/arm/bits.zig +++ b/src/arch/arm/bits.zig @@ -159,7 +159,7 @@ pub const Register = enum(u5) { /// Returns the unique 4-bit ID of this register which is used in /// the machine code pub fn id(self: Register) u4 { - return @truncate(u4, @enumToInt(self)); + return @truncate(u4, @intFromEnum(self)); } pub fn dwarfLocOp(self: Register) u8 { @@ -408,7 +408,7 @@ pub const Instruction = union(enum) { return Shift{ .register = .{ .rs = rs.id(), - .typ = @enumToInt(typ), + .typ = @intFromEnum(typ), }, }; } @@ -417,7 +417,7 @@ pub const Instruction = union(enum) { return Shift{ .immediate = .{ .amount = amount, - .typ = @enumToInt(typ), + .typ = @intFromEnum(typ), }, }; } @@ -633,9 +633,9 @@ pub const Instruction = union(enum) { ) Instruction { return Instruction{ .data_processing = .{ - .cond = @enumToInt(cond), - .i = @boolToInt(op2 == .immediate), - .opcode = @enumToInt(opcode), + .cond = @intFromEnum(cond), + .i = @intFromBool(op2 == .immediate), + .opcode = @intFromEnum(opcode), .s = s, .rn = rn.id(), .rd = rd.id(), @@ -652,7 +652,7 @@ pub const Instruction = union(enum) { ) Instruction { return Instruction{ .data_processing = .{ - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), .i = 1, .opcode = if (top) 0b1010 else 0b1000, .s = 0, @@ -673,8 +673,8 @@ pub const Instruction = union(enum) { ) Instruction { return Instruction{ .multiply = .{ - .cond = @enumToInt(cond), - .accumulate = @boolToInt(ra != null), + .cond = @intFromEnum(cond), + .accumulate = @intFromBool(ra != null), .set_cond = set_cond, .rd = rd.id(), .rn = rn.id(), @@ -696,7 +696,7 @@ pub const Instruction = union(enum) { ) Instruction { return Instruction{ .multiply_long = .{ - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), .unsigned = signed, .accumulate = accumulate, .set_cond = set_cond, @@ -723,7 +723,7 @@ pub const Instruction = union(enum) { .m = m, .rm = rm.id(), .rd = rd.id(), - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), }, }; } @@ -741,7 +741,7 @@ pub const Instruction = union(enum) { .rd = rd.id(), .rn = rn.id(), .opc = opc, - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), }, }; } @@ -762,7 +762,7 @@ pub const Instruction = union(enum) { .rd = rd.id(), .widthm1 = @intCast(u5, width - 1), .unsigned = unsigned, - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), }, }; } @@ -779,7 +779,7 @@ pub const Instruction = union(enum) { ) Instruction { return Instruction{ .single_data_transfer = .{ - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), .rn = rn.id(), .rd = rd.id(), .offset = offset.toU12(), @@ -789,12 +789,12 @@ pub const Instruction = union(enum) { .pre_index, .post_index => 0b1, }, .byte_word = byte_word, - .up_down = @boolToInt(positive), + .up_down = @intFromBool(positive), .pre_post = switch (mode) { .offset, .pre_index => 0b1, .post_index => 0b0, }, - .imm = @boolToInt(offset != .immediate), + .imm = @intFromBool(offset != .immediate), }, }; } @@ -830,13 +830,13 @@ pub const Instruction = union(enum) { .offset => 0b0, .pre_index, .post_index => 0b1, }, - .imm = @boolToInt(offset == .immediate), - .up_down = @boolToInt(positive), + .imm = @intFromBool(offset == .immediate), + .up_down = @intFromBool(positive), .pre_index = switch (mode) { .offset, .pre_index => 0b1, .post_index => 0b0, }, - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), }, }; } @@ -856,11 +856,11 @@ pub const Instruction = union(enum) { .register_list = @bitCast(u16, reg_list), .rn = rn.id(), .load_store = load_store, - .write_back = @boolToInt(write_back), + .write_back = @intFromBool(write_back), .psr_or_user = psr_or_user, .up_down = up_down, .pre_post = pre_post, - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), }, }; } @@ -868,7 +868,7 @@ pub const Instruction = union(enum) { fn branch(cond: Condition, offset: i26, link: u1) Instruction { return Instruction{ .branch = .{ - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), .link = link, .offset = @bitCast(u24, @intCast(i24, offset >> 2)), }, @@ -878,7 +878,7 @@ pub const Instruction = union(enum) { fn branchExchange(cond: Condition, rn: Register, link: u1) Instruction { return Instruction{ .branch_exchange = .{ - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), .link = link, .rn = rn.id(), }, @@ -888,7 +888,7 @@ pub const Instruction = union(enum) { fn supervisorCall(cond: Condition, comment: u24) Instruction { return Instruction{ .supervisor_call = .{ - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), .comment = comment, }, }; @@ -1060,7 +1060,7 @@ pub const Instruction = union(enum) { pub fn mrs(cond: Condition, rd: Register, psr: Psr) Instruction { return Instruction{ .data_processing = .{ - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), .i = 0, .opcode = if (psr == .spsr) 0b1010 else 0b1000, .s = 0, @@ -1074,7 +1074,7 @@ pub const Instruction = union(enum) { pub fn msr(cond: Condition, psr: Psr, op: Operand) Instruction { return Instruction{ .data_processing = .{ - .cond = @enumToInt(cond), + .cond = @intFromEnum(cond), .i = 0, .opcode = if (psr == .spsr) 0b1011 else 0b1001, .s = 0, diff --git a/src/arch/riscv64/CodeGen.zig b/src/arch/riscv64/CodeGen.zig index 57383b3043b5..cba1de92c1ed 100644 --- a/src/arch/riscv64/CodeGen.zig +++ b/src/arch/riscv64/CodeGen.zig @@ -755,7 +755,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live const dies = @truncate(u1, tomb_bits) != 0; tomb_bits >>= 1; if (!dies) continue; - const op_int = @enumToInt(op); + const op_int = @intFromEnum(op); if (op_int < Air.ref_start_index) continue; const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index); self.processDeath(op_index); diff --git a/src/arch/riscv64/bits.zig b/src/arch/riscv64/bits.zig index 7b3ff0bfe980..5db3bf4f0520 100644 --- a/src/arch/riscv64/bits.zig +++ b/src/arch/riscv64/bits.zig @@ -407,7 +407,7 @@ pub const Register = enum(u6) { /// Returns the unique 4-bit ID of this register which is used in /// the machine code pub fn id(self: Register) u5 { - return @truncate(u5, @enumToInt(self)); + return @truncate(u5, @intFromEnum(self)); } pub fn dwarfLocOp(reg: Register) u8 { diff --git a/src/arch/sparc64/CodeGen.zig b/src/arch/sparc64/CodeGen.zig index 97bb2f8ab175..f210f8e14461 100644 --- a/src/arch/sparc64/CodeGen.zig +++ b/src/arch/sparc64/CodeGen.zig @@ -1513,7 +1513,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { // that death now instead of later as this has an effect on // whether it needs to be spilled in the branches if (self.liveness.operandDies(inst, 0)) { - const op_int = @enumToInt(pl_op.operand); + const op_int = @intFromEnum(pl_op.operand); if (op_int >= Air.ref_start_index) { const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index); self.processDeath(op_index); @@ -3568,7 +3568,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live const dies = @truncate(u1, tomb_bits) != 0; tomb_bits >>= 1; if (!dies) continue; - const op_int = @enumToInt(op); + const op_int = @intFromEnum(op); if (op_int < Air.ref_start_index) continue; const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index); self.processDeath(op_index); diff --git a/src/arch/sparc64/bits.zig b/src/arch/sparc64/bits.zig index 7c943626f9dc..81656b422b6c 100644 --- a/src/arch/sparc64/bits.zig +++ b/src/arch/sparc64/bits.zig @@ -16,7 +16,7 @@ pub const Register = enum(u6) { // zig fmt: on pub fn id(self: Register) u5 { - return @truncate(u5, @enumToInt(self)); + return @truncate(u5, @intFromEnum(self)); } pub fn enc(self: Register) u5 { @@ -96,9 +96,9 @@ pub const FloatingPointRegister = enum(u7) { pub fn id(self: FloatingPointRegister) u6 { return switch (self.size()) { - 32 => @truncate(u6, @enumToInt(self)), - 64 => @truncate(u6, (@enumToInt(self) - 32) * 2), - 128 => @truncate(u6, (@enumToInt(self) - 64) * 4), + 32 => @truncate(u6, @intFromEnum(self)), + 64 => @truncate(u6, (@intFromEnum(self) - 32) * 2), + 128 => @truncate(u6, (@intFromEnum(self) - 64) * 4), else => unreachable, }; } @@ -114,7 +114,7 @@ pub const FloatingPointRegister = enum(u7) { /// Returns the bit-width of the register. pub fn size(self: FloatingPointRegister) u8 { - return switch (@enumToInt(self)) { + return switch (@intFromEnum(self)) { 0...31 => 32, 32...63 => 64, 64...79 => 128, @@ -696,8 +696,8 @@ pub const Instruction = union(enum) { /// Encodes the condition into the instruction bit pattern. pub fn enc(cond: Condition) u4 { return switch (cond) { - .icond => |c| @enumToInt(c), - .fcond => |c| @enumToInt(c), + .icond => |c| @intFromEnum(c), + .fcond => |c| @intFromEnum(c), }; } @@ -786,7 +786,7 @@ pub const Instruction = union(enum) { const udisp_truncated = @truncate(u22, udisp >> 2); return Instruction{ .format_2b = .{ - .a = @boolToInt(annul), + .a = @intFromBool(annul), .cond = cond.enc(), .op2 = op2, .disp22 = udisp_truncated, @@ -803,16 +803,16 @@ pub const Instruction = union(enum) { // Discard the last two bits since those are implicitly zero. const udisp_truncated = @truncate(u19, udisp >> 2); - const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1); - const ccr_cc0 = @truncate(u1, @enumToInt(ccr)); + const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1); + const ccr_cc0 = @truncate(u1, @intFromEnum(ccr)); return Instruction{ .format_2c = .{ - .a = @boolToInt(annul), + .a = @intFromBool(annul), .cond = cond.enc(), .op2 = op2, .cc1 = ccr_cc1, .cc0 = ccr_cc0, - .p = @boolToInt(pt), + .p = @intFromBool(pt), .disp19 = udisp_truncated, }, }; @@ -831,10 +831,10 @@ pub const Instruction = union(enum) { const udisp_lo = @truncate(u14, udisp_truncated & 0b0011_1111_1111_1111); return Instruction{ .format_2d = .{ - .a = @boolToInt(annul), - .rcond = @enumToInt(rcond), + .a = @intFromBool(annul), + .rcond = @intFromEnum(rcond), .op2 = op2, - .p = @boolToInt(pt), + .p = @intFromBool(pt), .rs1 = rs1.enc(), .d16hi = udisp_hi, .d16lo = udisp_lo, @@ -891,7 +891,7 @@ pub const Instruction = union(enum) { .rd = rd.enc(), .op3 = op3, .rs1 = rs1.enc(), - .rcond = @enumToInt(rcond), + .rcond = @intFromEnum(rcond), .rs2 = rs2.enc(), }, }; @@ -903,7 +903,7 @@ pub const Instruction = union(enum) { .rd = rd.enc(), .op3 = op3, .rs1 = rs1.enc(), - .rcond = @enumToInt(rcond), + .rcond = @intFromEnum(rcond), .simm10 = @bitCast(u10, imm), }, }; @@ -934,7 +934,7 @@ pub const Instruction = union(enum) { .rd = rd.enc(), .op3 = op3, .rs1 = rs1.enc(), - .imm_asi = @enumToInt(asi), + .imm_asi = @intFromEnum(asi), .rs2 = rs2.enc(), }, }; @@ -956,7 +956,7 @@ pub const Instruction = union(enum) { .rd = rd.enc(), .op3 = op3, .rs1 = rs1.enc(), - .x = @enumToInt(sw), + .x = @intFromEnum(sw), .rs2 = rs2.enc(), }, }; @@ -995,8 +995,8 @@ pub const Instruction = union(enum) { }; } fn format3o(op: u2, op3: u6, opf: u9, ccr: CCR, rs1: Register, rs2: Register) Instruction { - const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1); - const ccr_cc0 = @truncate(u1, @enumToInt(ccr)); + const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1); + const ccr_cc0 = @truncate(u1, @intFromEnum(ccr)); return Instruction{ .format_3o = .{ .op = op, @@ -1051,8 +1051,8 @@ pub const Instruction = union(enum) { } fn format4a(op3: u6, ccr: CCR, rs1: Register, rs2: Register, rd: Register) Instruction { - const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1); - const ccr_cc0 = @truncate(u1, @enumToInt(ccr)); + const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1); + const ccr_cc0 = @truncate(u1, @intFromEnum(ccr)); return Instruction{ .format_4a = .{ .rd = rd.enc(), @@ -1066,8 +1066,8 @@ pub const Instruction = union(enum) { } fn format4b(op3: u6, ccr: CCR, rs1: Register, imm: i11, rd: Register) Instruction { - const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1); - const ccr_cc0 = @truncate(u1, @enumToInt(ccr)); + const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1); + const ccr_cc0 = @truncate(u1, @intFromEnum(ccr)); return Instruction{ .format_4b = .{ .rd = rd.enc(), @@ -1081,9 +1081,9 @@ pub const Instruction = union(enum) { } fn format4c(op3: u6, cond: Condition, ccr: CCR, rs2: Register, rd: Register) Instruction { - const ccr_cc2 = @truncate(u1, @enumToInt(ccr) >> 2); - const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1); - const ccr_cc0 = @truncate(u1, @enumToInt(ccr)); + const ccr_cc2 = @truncate(u1, @intFromEnum(ccr) >> 2); + const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1); + const ccr_cc0 = @truncate(u1, @intFromEnum(ccr)); return Instruction{ .format_4c = .{ .rd = rd.enc(), @@ -1098,9 +1098,9 @@ pub const Instruction = union(enum) { } fn format4d(op3: u6, cond: Condition, ccr: CCR, imm: i11, rd: Register) Instruction { - const ccr_cc2 = @truncate(u1, @enumToInt(ccr) >> 2); - const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1); - const ccr_cc0 = @truncate(u1, @enumToInt(ccr)); + const ccr_cc2 = @truncate(u1, @intFromEnum(ccr) >> 2); + const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1); + const ccr_cc0 = @truncate(u1, @intFromEnum(ccr)); return Instruction{ .format_4d = .{ .rd = rd.enc(), @@ -1115,8 +1115,8 @@ pub const Instruction = union(enum) { } fn format4e(op3: u6, ccr: CCR, rs1: Register, rd: Register, sw_trap: u7) Instruction { - const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1); - const ccr_cc0 = @truncate(u1, @enumToInt(ccr)); + const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1); + const ccr_cc0 = @truncate(u1, @intFromEnum(ccr)); return Instruction{ .format_4e = .{ .rd = rd.enc(), @@ -1142,7 +1142,7 @@ pub const Instruction = union(enum) { .rd = rd.enc(), .op3 = op3, .rs1 = rs1.enc(), - .rcond = @enumToInt(rcond), + .rcond = @intFromEnum(rcond), .opf_low = opf_low, .rs2 = rs2.enc(), }, @@ -1468,8 +1468,8 @@ pub const Instruction = union(enum) { pub fn trap(comptime s2: type, cond: ICondition, ccr: CCR, rs1: Register, rs2: s2) Instruction { // Tcc instructions abuse the rd field to store the conditionals. return switch (s2) { - Register => format4a(0b11_1010, ccr, rs1, rs2, @intToEnum(Register, @enumToInt(cond))), - u7 => format4e(0b11_1010, ccr, rs1, @intToEnum(Register, @enumToInt(cond)), rs2), + Register => format4a(0b11_1010, ccr, rs1, rs2, @enumFromInt(Register, @intFromEnum(cond))), + u7 => format4e(0b11_1010, ccr, rs1, @enumFromInt(Register, @intFromEnum(cond)), rs2), else => unreachable, }; } diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index 4c92b093ae4e..efd5ea6642f9 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -116,11 +116,11 @@ const WValue = union(enum) { fn free(value: *WValue, gen: *CodeGen) void { if (value.* != .local) return; const local_value = value.local.value; - const reserved = gen.args.len + @boolToInt(gen.return_value != .none); + const reserved = gen.args.len + @intFromBool(gen.return_value != .none); if (local_value < reserved + 2) return; // reserved locals may never be re-used. Also accounts for 2 stack locals. const index = local_value - reserved; - const valtype = @intToEnum(wasm.Valtype, gen.locals.items[index]); + const valtype = @enumFromInt(wasm.Valtype, gen.locals.items[index]); switch (valtype) { .i32 => gen.free_locals_i32.append(gen.gpa, local_value) catch return, // It's ok to fail any of those, a new local can be allocated instead .i64 => gen.free_locals_i64.append(gen.gpa, local_value) catch return, @@ -889,7 +889,7 @@ fn processDeath(func: *CodeGen, ref: Air.Inst.Ref) void { // TODO: Upon branch consolidation free any locals if needed. const value = func.currentBranch().values.getPtr(ref) orelse return; if (value.* != .local) return; - const reserved_indexes = func.args.len + @boolToInt(func.return_value != .none); + const reserved_indexes = func.args.len + @intFromBool(func.return_value != .none); if (value.local.value < reserved_indexes) { return; // function arguments can never be re-used } @@ -911,7 +911,7 @@ fn addTag(func: *CodeGen, tag: Mir.Inst.Tag) error{OutOfMemory}!void { fn addExtended(func: *CodeGen, opcode: wasm.MiscOpcode) error{OutOfMemory}!void { const extra_index = @intCast(u32, func.mir_extra.items.len); - try func.mir_extra.append(func.gpa, @enumToInt(opcode)); + try func.mir_extra.append(func.gpa, @intFromEnum(opcode)); try func.addInst(.{ .tag = .misc_prefix, .data = .{ .payload = extra_index } }); } @@ -3218,7 +3218,7 @@ fn lowerConstant(func: *CodeGen, arg_val: Value, ty: Type) InnerError!WValue { return WValue{ .imm32 = 0 }; } } else { - return WValue{ .imm32 = @boolToInt(!val.isNull(mod)) }; + return WValue{ .imm32 = @intFromBool(!val.isNull(mod)) }; }, .aggregate => switch (mod.intern_pool.indexToKey(ty.ip_index)) { .array_type => return func.fail("Wasm TODO: LowerConstant for {}", .{ty.fmt(mod)}), @@ -3904,7 +3904,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { } // Account for default branch so always add '1' - const depth = @intCast(u32, highest - lowest + @boolToInt(has_else_body)) + 1; + const depth = @intCast(u32, highest - lowest + @intFromBool(has_else_body)) + 1; const jump_table: Mir.JumpTable = .{ .length = depth }; const table_extra_index = try func.addExtra(jump_table); try func.addInst(.{ .tag = .br_table, .data = .{ .payload = table_extra_index } }); @@ -3939,7 +3939,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { break :blk target_ty.intInfo(mod).signedness; }; - try func.branches.ensureUnusedCapacity(func.gpa, case_list.items.len + @boolToInt(has_else_body)); + try func.branches.ensureUnusedCapacity(func.gpa, case_list.items.len + @intFromBool(has_else_body)); for (case_list.items, 0..) |case, index| { // when sparse, we use if/else-chain, so emit conditional checks if (is_sparse) { @@ -4821,7 +4821,7 @@ fn airIntFromFloat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { const op_ty = func.typeOf(ty_op.operand); if (op_ty.abiSize(mod) > 8) { - return func.fail("TODO: floatToInt for integers/floats with bitsize larger than 64 bits", .{}); + return func.fail("TODO: intFromFloat for integers/floats with bitsize larger than 64 bits", .{}); } try func.emitWValue(operand); @@ -4846,7 +4846,7 @@ fn airFloatFromInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { const op_ty = func.typeOf(ty_op.operand); if (op_ty.abiSize(mod) > 8) { - return func.fail("TODO: intToFloat for integers/floats with bitsize larger than 64 bits", .{}); + return func.fail("TODO: floatFromInt for integers/floats with bitsize larger than 64 bits", .{}); } try func.emitWValue(operand); diff --git a/src/arch/wasm/Emit.zig b/src/arch/wasm/Emit.zig index 45ad1d7eb377..3314f4d993be 100644 --- a/src/arch/wasm/Emit.zig +++ b/src/arch/wasm/Emit.zig @@ -269,12 +269,12 @@ fn emitLocals(emit: *Emit) !void { } fn emitTag(emit: *Emit, tag: Mir.Inst.Tag) !void { - try emit.code.append(@enumToInt(tag)); + try emit.code.append(@intFromEnum(tag)); } fn emitBlock(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void { const block_type = emit.mir.instructions.items(.data)[inst].block_type; - try emit.code.append(@enumToInt(tag)); + try emit.code.append(@intFromEnum(tag)); try emit.code.append(block_type); } @@ -293,13 +293,13 @@ fn emitBrTable(emit: *Emit, inst: Mir.Inst.Index) !void { fn emitLabel(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void { const label = emit.mir.instructions.items(.data)[inst].label; - try emit.code.append(@enumToInt(tag)); + try emit.code.append(@intFromEnum(tag)); try leb128.writeULEB128(emit.code.writer(), label); } fn emitGlobal(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void { const label = emit.mir.instructions.items(.data)[inst].label; - try emit.code.append(@enumToInt(tag)); + try emit.code.append(@intFromEnum(tag)); var buf: [5]u8 = undefined; leb128.writeUnsignedFixed(5, &buf, label); const global_offset = emit.offset(); @@ -343,7 +343,7 @@ fn emitFloat64(emit: *Emit, inst: Mir.Inst.Index) !void { fn emitMemArg(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void { const extra_index = emit.mir.instructions.items(.data)[inst].payload; const mem_arg = emit.mir.extraData(Mir.MemArg, extra_index).data; - try emit.code.append(@enumToInt(tag)); + try emit.code.append(@intFromEnum(tag)); try encodeMemArg(mem_arg, emit.code.writer()); } @@ -436,7 +436,7 @@ fn emitExtended(emit: *Emit, inst: Mir.Inst.Index) !void { const writer = emit.code.writer(); try emit.code.append(std.wasm.opcode(.misc_prefix)); try leb128.writeULEB128(writer, opcode); - switch (@intToEnum(std.wasm.MiscOpcode, opcode)) { + switch (@enumFromInt(std.wasm.MiscOpcode, opcode)) { // bulk-memory opcodes .data_drop => { const segment = emit.mir.extra[extra_index + 1]; @@ -475,7 +475,7 @@ fn emitSimd(emit: *Emit, inst: Mir.Inst.Index) !void { const writer = emit.code.writer(); try emit.code.append(std.wasm.opcode(.simd_prefix)); try leb128.writeULEB128(writer, opcode); - switch (@intToEnum(std.wasm.SimdOpcode, opcode)) { + switch (@enumFromInt(std.wasm.SimdOpcode, opcode)) { .v128_store, .v128_load, .v128_load8_splat, @@ -526,7 +526,7 @@ fn emitAtomic(emit: *Emit, inst: Mir.Inst.Index) !void { const writer = emit.code.writer(); try emit.code.append(std.wasm.opcode(.atomics_prefix)); try leb128.writeULEB128(writer, opcode); - switch (@intToEnum(std.wasm.AtomicsOpcode, opcode)) { + switch (@enumFromInt(std.wasm.AtomicsOpcode, opcode)) { .i32_atomic_load, .i64_atomic_load, .i32_atomic_load8_u, diff --git a/src/arch/wasm/Mir.zig b/src/arch/wasm/Mir.zig index 4c550d86379a..6e93f0fb88b3 100644 --- a/src/arch/wasm/Mir.zig +++ b/src/arch/wasm/Mir.zig @@ -544,12 +544,12 @@ pub const Inst = struct { /// From a given wasm opcode, returns a MIR tag. pub fn fromOpcode(opcode: std.wasm.Opcode) Tag { - return @intToEnum(Tag, @enumToInt(opcode)); // Given `Opcode` is not present as a tag for MIR yet + return @enumFromInt(Tag, @intFromEnum(opcode)); // Given `Opcode` is not present as a tag for MIR yet } /// Returns a wasm opcode from a given MIR tag. pub fn toOpcode(self: Tag) std.wasm.Opcode { - return @intToEnum(std.wasm.Opcode, @enumToInt(self)); + return @enumFromInt(std.wasm.Opcode, @intFromEnum(self)); } }; diff --git a/src/arch/x86/bits.zig b/src/arch/x86/bits.zig index 3f4ad26e26ec..0bb2cbea301d 100644 --- a/src/arch/x86/bits.zig +++ b/src/arch/x86/bits.zig @@ -14,7 +14,7 @@ pub const Register = enum(u8) { /// Returns the bit-width of the register. pub fn size(self: Register) u7 { - return switch (@enumToInt(self)) { + return switch (@intFromEnum(self)) { 0...7 => 32, 8...15 => 16, 16...23 => 8, @@ -26,22 +26,22 @@ pub const Register = enum(u8) { /// x86 has. It is embedded in some instructions, such as the `B8 +rd` move /// instruction, and is used in the R/M byte. pub fn id(self: Register) u3 { - return @truncate(u3, @enumToInt(self)); + return @truncate(u3, @intFromEnum(self)); } /// Convert from any register to its 32 bit alias. pub fn to32(self: Register) Register { - return @intToEnum(Register, @as(u8, self.id())); + return @enumFromInt(Register, @as(u8, self.id())); } /// Convert from any register to its 16 bit alias. pub fn to16(self: Register) Register { - return @intToEnum(Register, @as(u8, self.id()) + 8); + return @enumFromInt(Register, @as(u8, self.id()) + 8); } /// Convert from any register to its 8 bit alias. pub fn to8(self: Register) Register { - return @intToEnum(Register, @as(u8, self.id()) + 16); + return @enumFromInt(Register, @as(u8, self.id()) + 16); } pub fn dwarfLocOp(reg: Register) u8 { diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 375b72bad5f5..b4ef42b953c5 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -690,7 +690,7 @@ pub fn generate( try function.frame_allocs.resize(gpa, FrameIndex.named_count); function.frame_allocs.set( - @enumToInt(FrameIndex.stack_frame), + @intFromEnum(FrameIndex.stack_frame), FrameAlloc.init(.{ .size = 0, .alignment = if (mod.align_stack_fns.get(module_fn_index)) |set_align_stack| @@ -700,7 +700,7 @@ pub fn generate( }), ); function.frame_allocs.set( - @enumToInt(FrameIndex.call_frame), + @intFromEnum(FrameIndex.call_frame), FrameAlloc.init(.{ .size = 0, .alignment = 1 }), ); @@ -721,16 +721,16 @@ pub fn generate( function.args = call_info.args; function.ret_mcv = call_info.return_value; - function.frame_allocs.set(@enumToInt(FrameIndex.ret_addr), FrameAlloc.init(.{ + function.frame_allocs.set(@intFromEnum(FrameIndex.ret_addr), FrameAlloc.init(.{ .size = Type.usize.abiSize(mod), .alignment = @min(Type.usize.abiAlignment(mod), call_info.stack_align), })); - function.frame_allocs.set(@enumToInt(FrameIndex.base_ptr), FrameAlloc.init(.{ + function.frame_allocs.set(@intFromEnum(FrameIndex.base_ptr), FrameAlloc.init(.{ .size = Type.usize.abiSize(mod), .alignment = @min(Type.usize.abiAlignment(mod) * 2, call_info.stack_align), })); function.frame_allocs.set( - @enumToInt(FrameIndex.args_frame), + @intFromEnum(FrameIndex.args_frame), FrameAlloc.init(.{ .size = call_info.stack_byte_count, .alignment = call_info.stack_align }), ); @@ -2147,7 +2147,7 @@ fn setFrameLoc( offset: *i32, comptime aligned: bool, ) void { - const frame_i = @enumToInt(frame_index); + const frame_i = @intFromEnum(frame_index); if (aligned) { const alignment = @as(i32, 1) << self.frame_allocs.items(.abi_align)[frame_i]; offset.* = mem.alignForward(i32, offset.*, alignment); @@ -2167,21 +2167,21 @@ fn computeFrameLayout(self: *Self) !FrameLayout { const frame_offset = self.frame_locs.items(.disp); for (stack_frame_order, FrameIndex.named_count..) |*frame_order, frame_index| - frame_order.* = @intToEnum(FrameIndex, frame_index); + frame_order.* = @enumFromInt(FrameIndex, frame_index); { const SortContext = struct { frame_align: @TypeOf(frame_align), pub fn lessThan(context: @This(), lhs: FrameIndex, rhs: FrameIndex) bool { - return context.frame_align[@enumToInt(lhs)] > context.frame_align[@enumToInt(rhs)]; + return context.frame_align[@intFromEnum(lhs)] > context.frame_align[@intFromEnum(rhs)]; } }; const sort_context = SortContext{ .frame_align = frame_align }; mem.sort(FrameIndex, stack_frame_order, sort_context, SortContext.lessThan); } - const call_frame_align = frame_align[@enumToInt(FrameIndex.call_frame)]; - const stack_frame_align = frame_align[@enumToInt(FrameIndex.stack_frame)]; - const args_frame_align = frame_align[@enumToInt(FrameIndex.args_frame)]; + const call_frame_align = frame_align[@intFromEnum(FrameIndex.call_frame)]; + const stack_frame_align = frame_align[@intFromEnum(FrameIndex.stack_frame)]; + const args_frame_align = frame_align[@intFromEnum(FrameIndex.args_frame)]; const needed_align = @max(call_frame_align, stack_frame_align); const need_align_stack = needed_align > args_frame_align; @@ -2200,7 +2200,7 @@ fn computeFrameLayout(self: *Self) !FrameLayout { self.setFrameLoc(.ret_addr, .rbp, &rbp_offset, false); self.setFrameLoc(.args_frame, .rbp, &rbp_offset, false); const stack_frame_align_offset = - if (need_align_stack) 0 else frame_offset[@enumToInt(FrameIndex.args_frame)]; + if (need_align_stack) 0 else frame_offset[@intFromEnum(FrameIndex.args_frame)]; var rsp_offset: i32 = 0; self.setFrameLoc(.call_frame, .rsp, &rsp_offset, true); @@ -2209,23 +2209,23 @@ fn computeFrameLayout(self: *Self) !FrameLayout { rsp_offset += stack_frame_align_offset; rsp_offset = mem.alignForward(i32, rsp_offset, @as(i32, 1) << needed_align); rsp_offset -= stack_frame_align_offset; - frame_size[@enumToInt(FrameIndex.call_frame)] = - @intCast(u31, rsp_offset - frame_offset[@enumToInt(FrameIndex.stack_frame)]); + frame_size[@intFromEnum(FrameIndex.call_frame)] = + @intCast(u31, rsp_offset - frame_offset[@intFromEnum(FrameIndex.stack_frame)]); return .{ .stack_mask = @as(u32, math.maxInt(u32)) << (if (need_align_stack) needed_align else 0), - .stack_adjust = @intCast(u32, rsp_offset - frame_offset[@enumToInt(FrameIndex.call_frame)]), + .stack_adjust = @intCast(u32, rsp_offset - frame_offset[@intFromEnum(FrameIndex.call_frame)]), .save_reg_list = save_reg_list, }; } fn getFrameAddrAlignment(self: *Self, frame_addr: FrameAddr) u32 { - const alloc_align = @as(u32, 1) << self.frame_allocs.get(@enumToInt(frame_addr.index)).abi_align; + const alloc_align = @as(u32, 1) << self.frame_allocs.get(@intFromEnum(frame_addr.index)).abi_align; return @min(alloc_align, @bitCast(u32, frame_addr.off) & (alloc_align - 1)); } fn getFrameAddrSize(self: *Self, frame_addr: FrameAddr) u32 { - return self.frame_allocs.get(@enumToInt(frame_addr.index)).abi_size - @intCast(u31, frame_addr.off); + return self.frame_allocs.get(@intFromEnum(frame_addr.index)).abi_size - @intCast(u31, frame_addr.off); } fn allocFrameIndex(self: *Self, alloc: FrameAlloc) !FrameIndex { @@ -2233,19 +2233,19 @@ fn allocFrameIndex(self: *Self, alloc: FrameAlloc) !FrameIndex { const frame_size = frame_allocs_slice.items(.abi_size); const frame_align = frame_allocs_slice.items(.abi_align); - const stack_frame_align = &frame_align[@enumToInt(FrameIndex.stack_frame)]; + const stack_frame_align = &frame_align[@intFromEnum(FrameIndex.stack_frame)]; stack_frame_align.* = @max(stack_frame_align.*, alloc.abi_align); for (self.free_frame_indices.keys(), 0..) |frame_index, free_i| { - const abi_size = frame_size[@enumToInt(frame_index)]; + const abi_size = frame_size[@intFromEnum(frame_index)]; if (abi_size != alloc.abi_size) continue; - const abi_align = &frame_align[@enumToInt(frame_index)]; + const abi_align = &frame_align[@intFromEnum(frame_index)]; abi_align.* = @max(abi_align.*, alloc.abi_align); _ = self.free_frame_indices.swapRemoveAt(free_i); return frame_index; } - const frame_index = @intToEnum(FrameIndex, self.frame_allocs.len); + const frame_index = @enumFromInt(FrameIndex, self.frame_allocs.len); try self.frame_allocs.append(self.gpa, alloc); return frame_index; } @@ -2876,7 +2876,7 @@ fn activeIntBits(self: *Self, dst_air: Air.Inst.Ref) u16 { var space: Value.BigIntSpace = undefined; const src_int = src_val.toBigInt(&space, mod); return @intCast(u16, src_int.bitCountTwosComp()) + - @boolToInt(src_int.positive and dst_info.signedness == .signed); + @intFromBool(src_int.positive and dst_info.signedness == .signed); }, .intcast => { const src_ty = self.typeOf(air_data[inst].ty_op.operand); @@ -8034,10 +8034,10 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier FrameAlloc.init(.{ .size = info.stack_byte_count, .alignment = info.stack_align }); const frame_allocs_slice = self.frame_allocs.slice(); const stack_frame_size = - &frame_allocs_slice.items(.abi_size)[@enumToInt(FrameIndex.call_frame)]; + &frame_allocs_slice.items(.abi_size)[@intFromEnum(FrameIndex.call_frame)]; stack_frame_size.* = @max(stack_frame_size.*, needed_call_frame.abi_size); const stack_frame_align = - &frame_allocs_slice.items(.abi_align)[@enumToInt(FrameIndex.call_frame)]; + &frame_allocs_slice.items(.abi_align)[@intFromEnum(FrameIndex.call_frame)]; stack_frame_align.* = @max(stack_frame_align.*, needed_call_frame.abi_align); } @@ -10915,10 +10915,10 @@ fn airTagName(self: *Self, inst: Air.Inst.Index) !void { }); const frame_allocs_slice = self.frame_allocs.slice(); const stack_frame_size = - &frame_allocs_slice.items(.abi_size)[@enumToInt(FrameIndex.call_frame)]; + &frame_allocs_slice.items(.abi_size)[@intFromEnum(FrameIndex.call_frame)]; stack_frame_size.* = @max(stack_frame_size.*, needed_call_frame.abi_size); const stack_frame_align = - &frame_allocs_slice.items(.abi_align)[@enumToInt(FrameIndex.call_frame)]; + &frame_allocs_slice.items(.abi_align)[@intFromEnum(FrameIndex.call_frame)]; stack_frame_align.* = @max(stack_frame_align.*, needed_call_frame.abi_align); } @@ -11413,7 +11413,7 @@ fn airUnionInit(self: *Self, inst: Air.Inst.Index) !void { const tag_ty = union_obj.tag_ty; const field_index = tag_ty.enumFieldIndex(field_name, mod).?; const tag_val = try mod.enumValueFieldIndex(tag_ty, field_index); - const tag_int_val = try tag_val.enumToInt(tag_ty, mod); + const tag_int_val = try tag_val.intFromEnum(tag_ty, mod); const tag_int = tag_int_val.toUnsignedInt(mod); const tag_off = if (layout.tag_align < layout.payload_align) @intCast(i32, layout.payload_size) @@ -11637,7 +11637,7 @@ fn limitImmediateType(self: *Self, operand: Air.Inst.Ref, comptime T: type) !MCV switch (mcv) { .immediate => |imm| { // This immediate is unsigned. - const U = std.meta.Int(.unsigned, ti.bits - @boolToInt(ti.signedness == .signed)); + const U = std.meta.Int(.unsigned, ti.bits - @intFromBool(ti.signedness == .signed)); if (imm >= math.maxInt(U)) { return MCValue{ .register = try self.copyToTmpRegister(Type.usize, mcv) }; } @@ -11782,17 +11782,17 @@ fn resolveCallingConventionValues( }, .float, .sse => switch (self.target.os.tag) { .windows => if (param_reg_i < 4) { - arg.* = .{ .register = @intToEnum( + arg.* = .{ .register = @enumFromInt( Register, - @enumToInt(Register.xmm0) + param_reg_i, + @intFromEnum(Register.xmm0) + param_reg_i, ) }; param_reg_i += 1; continue; }, else => if (param_sse_reg_i < 8) { - arg.* = .{ .register = @intToEnum( + arg.* = .{ .register = @enumFromInt( Register, - @enumToInt(Register.xmm0) + param_sse_reg_i, + @intFromEnum(Register.xmm0) + param_sse_reg_i, ) }; param_sse_reg_i += 1; continue; diff --git a/src/arch/x86_64/Encoding.zig b/src/arch/x86_64/Encoding.zig index 625a5283b98a..a3963ca149b9 100644 --- a/src/arch/x86_64/Encoding.zig +++ b/src/arch/x86_64/Encoding.zig @@ -56,7 +56,7 @@ pub fn findByMnemonic( var shortest_enc: ?Encoding = null; var shortest_len: ?usize = null; - next: for (mnemonic_to_encodings_map[@enumToInt(mnemonic)]) |data| { + next: for (mnemonic_to_encodings_map[@intFromEnum(mnemonic)]) |data| { switch (data.mode) { .none, .short => if (rex_required) continue, .rex, .rex_short => if (!rex_required) continue, @@ -85,7 +85,7 @@ pub fn findByOpcode(opc: []const u8, prefixes: struct { rex: Rex, }, modrm_ext: ?u3) ?Encoding { for (mnemonic_to_encodings_map, 0..) |encs, mnemonic_int| for (encs) |data| { - const enc = Encoding{ .mnemonic = @intToEnum(Mnemonic, mnemonic_int), .data = data }; + const enc = Encoding{ .mnemonic = @enumFromInt(Mnemonic, mnemonic_int), .data = data }; if (modrm_ext) |ext| if (ext != data.modrm_ext) continue; if (!std.mem.eql(u8, opc, enc.opcode())) continue; if (prefixes.rex.w) { @@ -772,7 +772,7 @@ const mnemonic_to_encodings_map = init: { var entries = encodings.table; std.mem.sort(encodings.Entry, &entries, {}, struct { fn lessThan(_: void, lhs: encodings.Entry, rhs: encodings.Entry) bool { - return @enumToInt(lhs[0]) < @enumToInt(rhs[0]); + return @intFromEnum(lhs[0]) < @intFromEnum(rhs[0]); } }.lessThan); var data_storage: [entries.len]Data = undefined; @@ -794,7 +794,7 @@ const mnemonic_to_encodings_map = init: { std.mem.copyForwards(Op, &data.ops, entry[2]); std.mem.copyForwards(u8, &data.opc, entry[3]); - while (mnemonic_int < @enumToInt(entry[0])) : (mnemonic_int += 1) { + while (mnemonic_int < @intFromEnum(entry[0])) : (mnemonic_int += 1) { mnemonic_map[mnemonic_int] = data_storage[mnemonic_start..data_index]; mnemonic_start = data_index; } diff --git a/src/arch/x86_64/Mir.zig b/src/arch/x86_64/Mir.zig index 96b774292972..36eacf4db93a 100644 --- a/src/arch/x86_64/Mir.zig +++ b/src/arch/x86_64/Mir.zig @@ -1053,16 +1053,16 @@ pub const MemorySib = struct { const sib = mem.sib; assert(sib.scale_index.scale == 0 or std.math.isPowerOfTwo(sib.scale_index.scale)); return .{ - .ptr_size = @enumToInt(sib.ptr_size), - .base_tag = @enumToInt(@as(Memory.Base.Tag, sib.base)), + .ptr_size = @intFromEnum(sib.ptr_size), + .base_tag = @intFromEnum(@as(Memory.Base.Tag, sib.base)), .base = switch (sib.base) { .none => undefined, - .reg => |r| @enumToInt(r), - .frame => |fi| @enumToInt(fi), + .reg => |r| @intFromEnum(r), + .frame => |fi| @intFromEnum(fi), }, .scale_index = @as(u32, sib.scale_index.scale) << 0 | @as(u32, if (sib.scale_index.scale > 0) - @enumToInt(sib.scale_index.index) + @intFromEnum(sib.scale_index.index) else undefined) << 4, .disp = sib.disp, @@ -1073,15 +1073,15 @@ pub const MemorySib = struct { const scale = @truncate(u4, msib.scale_index); assert(scale == 0 or std.math.isPowerOfTwo(scale)); return .{ .sib = .{ - .ptr_size = @intToEnum(Memory.PtrSize, msib.ptr_size), - .base = switch (@intToEnum(Memory.Base.Tag, msib.base_tag)) { + .ptr_size = @enumFromInt(Memory.PtrSize, msib.ptr_size), + .base = switch (@enumFromInt(Memory.Base.Tag, msib.base_tag)) { .none => .none, - .reg => .{ .reg = @intToEnum(Register, msib.base) }, - .frame => .{ .frame = @intToEnum(bits.FrameIndex, msib.base) }, + .reg => .{ .reg = @enumFromInt(Register, msib.base) }, + .frame => .{ .frame = @enumFromInt(bits.FrameIndex, msib.base) }, }, .scale_index = .{ .scale = scale, - .index = if (scale > 0) @intToEnum(Register, msib.scale_index >> 4) else undefined, + .index = if (scale > 0) @enumFromInt(Register, msib.scale_index >> 4) else undefined, }, .disp = msib.disp, } }; @@ -1096,14 +1096,14 @@ pub const MemoryRip = struct { pub fn encode(mem: Memory) MemoryRip { return .{ - .ptr_size = @enumToInt(mem.rip.ptr_size), + .ptr_size = @intFromEnum(mem.rip.ptr_size), .disp = mem.rip.disp, }; } pub fn decode(mrip: MemoryRip) Memory { return .{ .rip = .{ - .ptr_size = @intToEnum(Memory.PtrSize, mrip.ptr_size), + .ptr_size = @enumFromInt(Memory.PtrSize, mrip.ptr_size), .disp = mrip.disp, } }; } @@ -1119,7 +1119,7 @@ pub const MemoryMoffs = struct { pub fn encode(seg: Register, offset: u64) MemoryMoffs { return .{ - .seg = @enumToInt(seg), + .seg = @intFromEnum(seg), .msb = @truncate(u32, offset >> 32), .lsb = @truncate(u32, offset >> 0), }; @@ -1127,7 +1127,7 @@ pub const MemoryMoffs = struct { pub fn decode(moffs: MemoryMoffs) Memory { return .{ .moffs = .{ - .seg = @intToEnum(Register, moffs.seg), + .seg = @enumFromInt(Register, moffs.seg), .offset = @as(u64, moffs.msb) << 32 | @as(u64, moffs.lsb) << 0, } }; } @@ -1168,8 +1168,8 @@ pub fn resolveFrameLoc(mir: Mir, mem: Memory) Memory { .sib => |sib| switch (sib.base) { .none, .reg => mem, .frame => |index| if (mir.frame_locs.len > 0) Memory.sib(sib.ptr_size, .{ - .base = .{ .reg = mir.frame_locs.items(.base)[@enumToInt(index)] }, - .disp = mir.frame_locs.items(.disp)[@enumToInt(index)] + sib.disp, + .base = .{ .reg = mir.frame_locs.items(.base)[@intFromEnum(index)] }, + .disp = mir.frame_locs.items(.disp)[@intFromEnum(index)] + sib.disp, .scale_index = mem.scaleIndex(), }) else mem, }, diff --git a/src/arch/x86_64/bits.zig b/src/arch/x86_64/bits.zig index 923ba31266bf..e232a2db05ff 100644 --- a/src/arch/x86_64/bits.zig +++ b/src/arch/x86_64/bits.zig @@ -193,20 +193,20 @@ pub const Register = enum(u7) { }; pub fn class(reg: Register) Class { - return switch (@enumToInt(reg)) { + return switch (@intFromEnum(reg)) { // zig fmt: off - @enumToInt(Register.rax) ... @enumToInt(Register.r15) => .general_purpose, - @enumToInt(Register.eax) ... @enumToInt(Register.r15d) => .general_purpose, - @enumToInt(Register.ax) ... @enumToInt(Register.r15w) => .general_purpose, - @enumToInt(Register.al) ... @enumToInt(Register.r15b) => .general_purpose, - @enumToInt(Register.ah) ... @enumToInt(Register.bh) => .general_purpose, + @intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => .general_purpose, + @intFromEnum(Register.eax) ... @intFromEnum(Register.r15d) => .general_purpose, + @intFromEnum(Register.ax) ... @intFromEnum(Register.r15w) => .general_purpose, + @intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => .general_purpose, + @intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => .general_purpose, - @enumToInt(Register.ymm0) ... @enumToInt(Register.ymm15) => .sse, - @enumToInt(Register.xmm0) ... @enumToInt(Register.xmm15) => .sse, - @enumToInt(Register.mm0) ... @enumToInt(Register.mm7) => .mmx, - @enumToInt(Register.st0) ... @enumToInt(Register.st7) => .x87, + @intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm15) => .sse, + @intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm15) => .sse, + @intFromEnum(Register.mm0) ... @intFromEnum(Register.mm7) => .mmx, + @intFromEnum(Register.st0) ... @intFromEnum(Register.st7) => .x87, - @enumToInt(Register.es) ... @enumToInt(Register.gs) => .segment, + @intFromEnum(Register.es) ... @intFromEnum(Register.gs) => .segment, else => unreachable, // zig fmt: on @@ -214,42 +214,42 @@ pub const Register = enum(u7) { } pub fn id(reg: Register) u6 { - const base = switch (@enumToInt(reg)) { + const base = switch (@intFromEnum(reg)) { // zig fmt: off - @enumToInt(Register.rax) ... @enumToInt(Register.r15) => @enumToInt(Register.rax), - @enumToInt(Register.eax) ... @enumToInt(Register.r15d) => @enumToInt(Register.eax), - @enumToInt(Register.ax) ... @enumToInt(Register.r15w) => @enumToInt(Register.ax), - @enumToInt(Register.al) ... @enumToInt(Register.r15b) => @enumToInt(Register.al), - @enumToInt(Register.ah) ... @enumToInt(Register.bh) => @enumToInt(Register.ah) - 4, + @intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => @intFromEnum(Register.rax), + @intFromEnum(Register.eax) ... @intFromEnum(Register.r15d) => @intFromEnum(Register.eax), + @intFromEnum(Register.ax) ... @intFromEnum(Register.r15w) => @intFromEnum(Register.ax), + @intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => @intFromEnum(Register.al), + @intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => @intFromEnum(Register.ah) - 4, - @enumToInt(Register.ymm0) ... @enumToInt(Register.ymm15) => @enumToInt(Register.ymm0) - 16, - @enumToInt(Register.xmm0) ... @enumToInt(Register.xmm15) => @enumToInt(Register.xmm0) - 16, - @enumToInt(Register.mm0) ... @enumToInt(Register.mm7) => @enumToInt(Register.mm0) - 32, - @enumToInt(Register.st0) ... @enumToInt(Register.st7) => @enumToInt(Register.st0) - 40, + @intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm15) => @intFromEnum(Register.ymm0) - 16, + @intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm15) => @intFromEnum(Register.xmm0) - 16, + @intFromEnum(Register.mm0) ... @intFromEnum(Register.mm7) => @intFromEnum(Register.mm0) - 32, + @intFromEnum(Register.st0) ... @intFromEnum(Register.st7) => @intFromEnum(Register.st0) - 40, - @enumToInt(Register.es) ... @enumToInt(Register.gs) => @enumToInt(Register.es) - 48, + @intFromEnum(Register.es) ... @intFromEnum(Register.gs) => @intFromEnum(Register.es) - 48, else => unreachable, // zig fmt: on }; - return @intCast(u6, @enumToInt(reg) - base); + return @intCast(u6, @intFromEnum(reg) - base); } pub fn bitSize(reg: Register) u64 { - return switch (@enumToInt(reg)) { + return switch (@intFromEnum(reg)) { // zig fmt: off - @enumToInt(Register.rax) ... @enumToInt(Register.r15) => 64, - @enumToInt(Register.eax) ... @enumToInt(Register.r15d) => 32, - @enumToInt(Register.ax) ... @enumToInt(Register.r15w) => 16, - @enumToInt(Register.al) ... @enumToInt(Register.r15b) => 8, - @enumToInt(Register.ah) ... @enumToInt(Register.bh) => 8, + @intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => 64, + @intFromEnum(Register.eax) ... @intFromEnum(Register.r15d) => 32, + @intFromEnum(Register.ax) ... @intFromEnum(Register.r15w) => 16, + @intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => 8, + @intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => 8, - @enumToInt(Register.ymm0) ... @enumToInt(Register.ymm15) => 256, - @enumToInt(Register.xmm0) ... @enumToInt(Register.xmm15) => 128, - @enumToInt(Register.mm0) ... @enumToInt(Register.mm7) => 64, - @enumToInt(Register.st0) ... @enumToInt(Register.st7) => 80, + @intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm15) => 256, + @intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm15) => 128, + @intFromEnum(Register.mm0) ... @intFromEnum(Register.mm7) => 64, + @intFromEnum(Register.st0) ... @intFromEnum(Register.st7) => 80, - @enumToInt(Register.es) ... @enumToInt(Register.gs) => 16, + @intFromEnum(Register.es) ... @intFromEnum(Register.gs) => 16, else => unreachable, // zig fmt: on @@ -257,15 +257,15 @@ pub const Register = enum(u7) { } pub fn isExtended(reg: Register) bool { - return switch (@enumToInt(reg)) { + return switch (@intFromEnum(reg)) { // zig fmt: off - @enumToInt(Register.r8) ... @enumToInt(Register.r15) => true, - @enumToInt(Register.r8d) ... @enumToInt(Register.r15d) => true, - @enumToInt(Register.r8w) ... @enumToInt(Register.r15w) => true, - @enumToInt(Register.r8b) ... @enumToInt(Register.r15b) => true, + @intFromEnum(Register.r8) ... @intFromEnum(Register.r15) => true, + @intFromEnum(Register.r8d) ... @intFromEnum(Register.r15d) => true, + @intFromEnum(Register.r8w) ... @intFromEnum(Register.r15w) => true, + @intFromEnum(Register.r8b) ... @intFromEnum(Register.r15b) => true, - @enumToInt(Register.ymm8) ... @enumToInt(Register.ymm15) => true, - @enumToInt(Register.xmm8) ... @enumToInt(Register.xmm15) => true, + @intFromEnum(Register.ymm8) ... @intFromEnum(Register.ymm15) => true, + @intFromEnum(Register.xmm8) ... @intFromEnum(Register.xmm15) => true, else => false, // zig fmt: on @@ -273,25 +273,25 @@ pub const Register = enum(u7) { } pub fn enc(reg: Register) u4 { - const base = switch (@enumToInt(reg)) { + const base = switch (@intFromEnum(reg)) { // zig fmt: off - @enumToInt(Register.rax) ... @enumToInt(Register.r15) => @enumToInt(Register.rax), - @enumToInt(Register.eax) ... @enumToInt(Register.r15d) => @enumToInt(Register.eax), - @enumToInt(Register.ax) ... @enumToInt(Register.r15w) => @enumToInt(Register.ax), - @enumToInt(Register.al) ... @enumToInt(Register.r15b) => @enumToInt(Register.al), - @enumToInt(Register.ah) ... @enumToInt(Register.bh) => @enumToInt(Register.ah) - 4, + @intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => @intFromEnum(Register.rax), + @intFromEnum(Register.eax) ... @intFromEnum(Register.r15d) => @intFromEnum(Register.eax), + @intFromEnum(Register.ax) ... @intFromEnum(Register.r15w) => @intFromEnum(Register.ax), + @intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => @intFromEnum(Register.al), + @intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => @intFromEnum(Register.ah) - 4, - @enumToInt(Register.ymm0) ... @enumToInt(Register.ymm15) => @enumToInt(Register.ymm0), - @enumToInt(Register.xmm0) ... @enumToInt(Register.xmm15) => @enumToInt(Register.xmm0), - @enumToInt(Register.mm0) ... @enumToInt(Register.mm7) => @enumToInt(Register.mm0), - @enumToInt(Register.st0) ... @enumToInt(Register.st7) => @enumToInt(Register.st0), + @intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm15) => @intFromEnum(Register.ymm0), + @intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm15) => @intFromEnum(Register.xmm0), + @intFromEnum(Register.mm0) ... @intFromEnum(Register.mm7) => @intFromEnum(Register.mm0), + @intFromEnum(Register.st0) ... @intFromEnum(Register.st7) => @intFromEnum(Register.st0), - @enumToInt(Register.es) ... @enumToInt(Register.gs) => @enumToInt(Register.es), + @intFromEnum(Register.es) ... @intFromEnum(Register.gs) => @intFromEnum(Register.es), else => unreachable, // zig fmt: on }; - return @truncate(u4, @enumToInt(reg) - base); + return @truncate(u4, @intFromEnum(reg) - base); } pub fn lowEnc(reg: Register) u3 { @@ -312,49 +312,49 @@ pub const Register = enum(u7) { fn gpBase(reg: Register) u7 { assert(reg.class() == .general_purpose); - return switch (@enumToInt(reg)) { + return switch (@intFromEnum(reg)) { // zig fmt: off - @enumToInt(Register.rax) ... @enumToInt(Register.r15) => @enumToInt(Register.rax), - @enumToInt(Register.eax) ... @enumToInt(Register.r15d) => @enumToInt(Register.eax), - @enumToInt(Register.ax) ... @enumToInt(Register.r15w) => @enumToInt(Register.ax), - @enumToInt(Register.al) ... @enumToInt(Register.r15b) => @enumToInt(Register.al), - @enumToInt(Register.ah) ... @enumToInt(Register.bh) => @enumToInt(Register.ah) - 4, + @intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => @intFromEnum(Register.rax), + @intFromEnum(Register.eax) ... @intFromEnum(Register.r15d) => @intFromEnum(Register.eax), + @intFromEnum(Register.ax) ... @intFromEnum(Register.r15w) => @intFromEnum(Register.ax), + @intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => @intFromEnum(Register.al), + @intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => @intFromEnum(Register.ah) - 4, else => unreachable, // zig fmt: on }; } pub fn to64(reg: Register) Register { - return @intToEnum(Register, @enumToInt(reg) - reg.gpBase() + @enumToInt(Register.rax)); + return @enumFromInt(Register, @intFromEnum(reg) - reg.gpBase() + @intFromEnum(Register.rax)); } pub fn to32(reg: Register) Register { - return @intToEnum(Register, @enumToInt(reg) - reg.gpBase() + @enumToInt(Register.eax)); + return @enumFromInt(Register, @intFromEnum(reg) - reg.gpBase() + @intFromEnum(Register.eax)); } pub fn to16(reg: Register) Register { - return @intToEnum(Register, @enumToInt(reg) - reg.gpBase() + @enumToInt(Register.ax)); + return @enumFromInt(Register, @intFromEnum(reg) - reg.gpBase() + @intFromEnum(Register.ax)); } pub fn to8(reg: Register) Register { - return @intToEnum(Register, @enumToInt(reg) - reg.gpBase() + @enumToInt(Register.al)); + return @enumFromInt(Register, @intFromEnum(reg) - reg.gpBase() + @intFromEnum(Register.al)); } fn sseBase(reg: Register) u7 { assert(reg.class() == .sse); - return switch (@enumToInt(reg)) { - @enumToInt(Register.ymm0)...@enumToInt(Register.ymm15) => @enumToInt(Register.ymm0), - @enumToInt(Register.xmm0)...@enumToInt(Register.xmm15) => @enumToInt(Register.xmm0), + return switch (@intFromEnum(reg)) { + @intFromEnum(Register.ymm0)...@intFromEnum(Register.ymm15) => @intFromEnum(Register.ymm0), + @intFromEnum(Register.xmm0)...@intFromEnum(Register.xmm15) => @intFromEnum(Register.xmm0), else => unreachable, }; } pub fn to256(reg: Register) Register { - return @intToEnum(Register, @enumToInt(reg) - reg.sseBase() + @enumToInt(Register.ymm0)); + return @enumFromInt(Register, @intFromEnum(reg) - reg.sseBase() + @intFromEnum(Register.ymm0)); } pub fn to128(reg: Register) Register { - return @intToEnum(Register, @enumToInt(reg) - reg.sseBase() + @enumToInt(Register.xmm0)); + return @enumFromInt(Register, @intFromEnum(reg) - reg.sseBase() + @intFromEnum(Register.xmm0)); } /// DWARF register encoding @@ -421,7 +421,7 @@ pub const FrameIndex = enum(u32) { pub const named_count = @typeInfo(FrameIndex).Enum.fields.len; pub fn isNamed(fi: FrameIndex) bool { - return @enumToInt(fi) < named_count; + return @intFromEnum(fi) < named_count; } pub fn format( @@ -436,7 +436,7 @@ pub const FrameIndex = enum(u32) { try writer.writeAll(@tagName(fi)); } else { try writer.writeByte('('); - try std.fmt.formatType(@enumToInt(fi), fmt, options, writer, 0); + try std.fmt.formatType(@intFromEnum(fi), fmt, options, writer, 0); try writer.writeByte(')'); } } diff --git a/src/arch/x86_64/encoder.zig b/src/arch/x86_64/encoder.zig index 5f9a2f49b38d..d953a9410d4d 100644 --- a/src/arch/x86_64/encoder.zig +++ b/src/arch/x86_64/encoder.zig @@ -267,7 +267,7 @@ pub const Instruction = struct { fn encodeOpcode(inst: Instruction, encoder: anytype) !void { const opcode = inst.encoding.opcode(); - const first = @boolToInt(inst.encoding.mandatoryPrefix() != null); + const first = @intFromBool(inst.encoding.mandatoryPrefix() != null); const final = opcode.len - 1; for (opcode[first..final]) |byte| try encoder.opcode_1byte(byte); switch (inst.encoding.data.op_en) { @@ -647,25 +647,25 @@ fn Encoder(comptime T: type, comptime opts: Options) type { try self.writer.writeByte(0b1100_0100); try self.writer.writeByte( - @as(u8, ~@boolToInt(fields.r)) << 7 | - @as(u8, ~@boolToInt(fields.x)) << 6 | - @as(u8, ~@boolToInt(fields.b)) << 5 | - @as(u8, @enumToInt(fields.m)) << 0, + @as(u8, ~@intFromBool(fields.r)) << 7 | + @as(u8, ~@intFromBool(fields.x)) << 6 | + @as(u8, ~@intFromBool(fields.b)) << 5 | + @as(u8, @intFromEnum(fields.m)) << 0, ); try self.writer.writeByte( - @as(u8, @boolToInt(fields.w)) << 7 | + @as(u8, @intFromBool(fields.w)) << 7 | @as(u8, ~fields.v.enc()) << 3 | - @as(u8, @boolToInt(fields.l)) << 2 | - @as(u8, @enumToInt(fields.p)) << 0, + @as(u8, @intFromBool(fields.l)) << 2 | + @as(u8, @intFromEnum(fields.p)) << 0, ); } else { try self.writer.writeByte(0b1100_0101); try self.writer.writeByte( - @as(u8, ~@boolToInt(fields.r)) << 7 | + @as(u8, ~@intFromBool(fields.r)) << 7 | @as(u8, ~fields.v.enc()) << 3 | - @as(u8, @boolToInt(fields.l)) << 2 | - @as(u8, @enumToInt(fields.p)) << 0, + @as(u8, @intFromBool(fields.l)) << 2 | + @as(u8, @intFromEnum(fields.p)) << 0, ); } } diff --git a/src/clang.zig b/src/clang.zig index f368bb0c3c6c..d6a655a7046b 100644 --- a/src/clang.zig +++ b/src/clang.zig @@ -1448,7 +1448,7 @@ pub const CK = enum(c_int) { IntegralToBoolean, IntegralToFloating, FloatingToFixedPoint, - FixedPointToFloating, + FixedPofloatFromInting, FixedPointCast, FixedPointToIntegral, IntegralToFixedPoint, diff --git a/src/codegen.zig b/src/codegen.zig index 430562fe9ba7..3bd7dca2c68c 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -381,7 +381,7 @@ pub fn generateSymbol( .fail => |em| return Result{ .fail = em }, } } - try code.writer().writeByte(@boolToInt(payload_val != null)); + try code.writer().writeByte(@intFromBool(payload_val != null)); try code.writer().writeByteNTimes(0, padding); } }, @@ -391,7 +391,7 @@ pub fn generateSymbol( .elems, .repeated_elem => { var index: u64 = 0; var len_including_sentinel = - array_type.len + @boolToInt(array_type.sentinel != .none); + array_type.len + @intFromBool(array_type.sentinel != .none); while (index < len_including_sentinel) : (index += 1) { switch (try generateSymbol(bin_file, src_loc, .{ .ty = array_type.child.toType(), @@ -952,7 +952,7 @@ pub fn genTypedValue( } }, .Bool => { - return GenResult.mcv(.{ .immediate = @boolToInt(typed_value.val.toBool()) }); + return GenResult.mcv(.{ .immediate = @intFromBool(typed_value.val.toBool()) }); }, .Optional => { if (typed_value.ty.isPtrLikeOptional(mod)) { @@ -961,7 +961,7 @@ pub fn genTypedValue( .val = typed_value.val.optionalValue(mod) orelse return GenResult.mcv(.{ .immediate = 0 }), }, owner_decl_index); } else if (typed_value.ty.abiSize(mod) == 1) { - return GenResult.mcv(.{ .immediate = @boolToInt(!typed_value.val.isNull(mod)) }); + return GenResult.mcv(.{ .immediate = @intFromBool(!typed_value.val.isNull(mod)) }); } }, .Enum => { diff --git a/src/codegen/c.zig b/src/codegen/c.zig index a5110a34b014..498eca4ce28b 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -462,7 +462,7 @@ pub const Function = struct { => |owner_decl| try std.fmt.allocPrint(arena, "zig_{s}_{}__{d}", .{ @tagName(key), fmtIdent(mod.intern_pool.stringToSlice(mod.declPtr(owner_decl).name)), - @enumToInt(owner_decl), + @intFromEnum(owner_decl), }), }, .data = switch (key) { @@ -1865,7 +1865,7 @@ pub const DeclGen = struct { }; try writer.print("{}__{d}", .{ fmtIdent(name_stream.getWritten()), - @enumToInt(decl_index), + @intFromEnum(decl_index), }); } } @@ -1991,7 +1991,7 @@ fn renderTypeName( @tagName(tag)["fwd_".len..], attributes, fmtIdent(mod.intern_pool.stringToSlice(mod.declPtr(owner_decl).name)), - @enumToInt(owner_decl), + @intFromEnum(owner_decl), }); }, } @@ -2100,7 +2100,7 @@ fn renderTypePrefix( .fwd_anon_struct, .fwd_anon_union, => if (decl.unwrap()) |decl_index| - try w.print("anon__{d}_{d}", .{ @enumToInt(decl_index), idx }) + try w.print("anon__{d}_{d}", .{ @intFromEnum(decl_index), idx }) else try renderTypeName(mod, w, idx, cty, ""), @@ -2514,7 +2514,7 @@ pub fn genLazyFn(o: *Object, lazy_fn: LazyFnMap.Entry) !void { const name = mod.intern_pool.stringToSlice(name_ip); const tag_val = try mod.enumValueFieldIndex(enum_ty, index); - const int_val = try tag_val.enumToInt(enum_ty, mod); + const int_val = try tag_val.intFromEnum(enum_ty, mod); const name_ty = try mod.arrayType(.{ .len = name.len, @@ -4701,7 +4701,7 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue { // On the final iteration we do not need to fix any state. This is because, like in the `else` // branch of a `cond_br`, our parent has to do it for this entire body anyway. - const last_case_i = switch_br.data.cases_len - @boolToInt(switch_br.data.else_body_len == 0); + const last_case_i = switch_br.data.cases_len - @intFromBool(switch_br.data.else_body_len == 0); var extra_index: usize = switch_br.end; for (0..switch_br.data.cases_len) |case_i| { @@ -6894,7 +6894,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue { const tag_val = try mod.enumValueFieldIndex(tag_ty, field_index); - const int_val = try tag_val.enumToInt(tag_ty, mod); + const int_val = try tag_val.intFromEnum(tag_ty, mod); const a = try Assignment.start(f, writer, tag_ty); try f.writeCValueMember(writer, local, .{ .identifier = "tag" }); @@ -6924,7 +6924,7 @@ fn airPrefetch(f: *Function, inst: Air.Inst.Index) !CValue { .data => { try writer.writeAll("zig_prefetch("); try f.writeCValue(writer, ptr, .FunctionArgument); - try writer.print(", {d}, {d});\n", .{ @enumToInt(prefetch.rw), prefetch.locality }); + try writer.print(", {d}, {d});\n", .{ @intFromEnum(prefetch.rw), prefetch.locality }); }, // The available prefetch intrinsics do not accept a cache argument; only // address, rw, and locality. diff --git a/src/codegen/c/type.zig b/src/codegen/c/type.zig index 81ca1dd80d5b..86324c9a7ce3 100644 --- a/src/codegen/c/type.zig +++ b/src/codegen/c/type.zig @@ -129,15 +129,15 @@ pub const CType = extern union { varargs_function, pub const last_no_payload_tag = Tag.zig_c_longdouble; - pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1; + pub const no_payload_count = @intFromEnum(last_no_payload_tag) + 1; pub fn hasPayload(self: Tag) bool { - return @enumToInt(self) >= no_payload_count; + return @intFromEnum(self) >= no_payload_count; } pub fn toIndex(self: Tag) Index { assert(!self.hasPayload()); - return @intCast(Index, @enumToInt(self)); + return @intCast(Index, @intFromEnum(self)); } pub fn Type(comptime self: Tag) type { @@ -334,7 +334,7 @@ pub const CType = extern union { map: Map = .{}, pub fn indexToCType(self: Set, index: Index) CType { - if (index < Tag.no_payload_count) return initTag(@intToEnum(Tag, index)); + if (index < Tag.no_payload_count) return initTag(@enumFromInt(Tag, index)); return self.map.keys()[index - Tag.no_payload_count]; } @@ -370,7 +370,7 @@ pub const CType = extern union { pub fn cTypeToIndex(self: *Promoted, cty: CType) Allocator.Error!Index { const t = cty.tag(); - if (@enumToInt(t) < Tag.no_payload_count) return @intCast(Index, @enumToInt(t)); + if (@intFromEnum(t) < Tag.no_payload_count) return @intCast(Index, @intFromEnum(t)); const gop = try self.set.map.getOrPutContext(self.gpa(), cty, .{ .store = &self.set }); if (!gop.found_existing) gop.key_ptr.* = cty; diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 1868298edb81..1f390edc0210 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -949,7 +949,7 @@ pub const Object = struct { mod.comp.bin_file.options.error_return_tracing; const err_ret_trace = if (err_return_tracing) - llvm_func.getParam(@boolToInt(ret_ptr != null)) + llvm_func.getParam(@intFromBool(ret_ptr != null)) else null; @@ -960,7 +960,7 @@ pub const Object = struct { defer args.deinit(); { - var llvm_arg_i = @as(c_uint, @boolToInt(ret_ptr != null)) + @boolToInt(err_return_tracing); + var llvm_arg_i = @as(c_uint, @intFromBool(ret_ptr != null)) + @intFromBool(err_return_tracing); var it = iterateParamTypes(&dg, fn_info); while (it.next()) |lowering| switch (lowering) { .no_bits => continue, @@ -2570,7 +2570,7 @@ pub const DeclGen = struct { mod.comp.bin_file.options.error_return_tracing; if (err_return_tracing) { - dg.addArgAttr(llvm_fn, @boolToInt(sret), "nonnull"); + dg.addArgAttr(llvm_fn, @intFromBool(sret), "nonnull"); } switch (fn_info.cc) { @@ -2604,8 +2604,8 @@ pub const DeclGen = struct { // because functions with bodies are handled in `updateFunc`. if (is_extern) { var it = iterateParamTypes(dg, fn_info); - it.llvm_index += @boolToInt(sret); - it.llvm_index += @boolToInt(err_return_tracing); + it.llvm_index += @intFromBool(sret); + it.llvm_index += @intFromBool(err_return_tracing); while (it.next()) |lowering| switch (lowering) { .byval => { const param_index = it.zig_index - 1; @@ -2812,7 +2812,7 @@ pub const DeclGen = struct { const elem_ty = t.childType(mod); if (std.debug.runtime_safety) assert((try elem_ty.onePossibleValue(mod)) == null); const elem_llvm_ty = try dg.lowerType(elem_ty); - const total_len = t.arrayLen(mod) + @boolToInt(t.sentinel(mod) != null); + const total_len = t.arrayLen(mod) + @intFromBool(t.sentinel(mod) != null); return elem_llvm_ty.arrayType(@intCast(c_uint, total_len)); }, .Vector => { @@ -3307,7 +3307,7 @@ pub const DeclGen = struct { } }, .enum_tag => { - const int_val = try tv.enumToInt(mod); + const int_val = try tv.intFromEnum(mod); var bigint_space: Value.BigIntSpace = undefined; const bigint = int_val.toBigInt(&bigint_space, mod); @@ -3476,7 +3476,7 @@ pub const DeclGen = struct { const elem_ty = tv.ty.childType(mod); const sentinel = tv.ty.sentinel(mod); const len = @intCast(usize, tv.ty.arrayLen(mod)); - const len_including_sent = len + @boolToInt(sentinel != null); + const len_including_sent = len + @intFromBool(sentinel != null); const gpa = dg.gpa; const llvm_elems = try gpa.alloc(*llvm.Value, len_including_sent); defer gpa.free(llvm_elems); @@ -3923,7 +3923,7 @@ pub const DeclGen = struct { const llvm_pl_index = if (layout.tag_size == 0) 0 else - @boolToInt(layout.tag_align >= layout.payload_align); + @intFromBool(layout.tag_align >= layout.payload_align); const indices: [2]*llvm.Value = .{ llvm_u32.constInt(0, .False), llvm_u32.constInt(llvm_pl_index, .False), @@ -3959,7 +3959,7 @@ pub const DeclGen = struct { }; return parent_llvm_ty.constInBoundsGEP(parent_llvm_ptr, &indices, indices.len); } else { - const llvm_index = llvm_u32.constInt(@boolToInt(parent_ty.hasRuntimeBitsIgnoreComptime(mod)), .False); + const llvm_index = llvm_u32.constInt(@intFromBool(parent_ty.hasRuntimeBitsIgnoreComptime(mod)), .False); const indices: [1]*llvm.Value = .{llvm_index}; return parent_llvm_ty.constInBoundsGEP(parent_llvm_ptr, &indices, indices.len); } @@ -4762,8 +4762,8 @@ pub const FuncGen = struct { if (callee_ty.zigTypeTag(mod) == .Pointer) { // Add argument attributes for function pointer calls. it = iterateParamTypes(self.dg, fn_info); - it.llvm_index += @boolToInt(sret); - it.llvm_index += @boolToInt(err_return_tracing); + it.llvm_index += @intFromBool(sret); + it.llvm_index += @intFromBool(err_return_tracing); while (it.next()) |lowering| switch (lowering) { .byval => { const param_index = it.zig_index - 1; @@ -5857,7 +5857,7 @@ pub const FuncGen = struct { .Union => { const union_llvm_ty = try self.dg.lowerType(struct_ty); const layout = struct_ty.unionGetLayout(mod); - const payload_index = @boolToInt(layout.tag_align >= layout.payload_align); + const payload_index = @intFromBool(layout.tag_align >= layout.payload_align); const field_ptr = self.builder.buildStructGEP(union_llvm_ty, struct_llvm_val, payload_index, ""); const llvm_field_ty = try self.dg.lowerType(field_ty); if (isByRef(field_ty, mod)) { @@ -8444,7 +8444,7 @@ pub const FuncGen = struct { return null; } const un_llvm_ty = try self.dg.lowerType(un_ty); - const tag_index = @boolToInt(layout.tag_align < layout.payload_align); + const tag_index = @intFromBool(layout.tag_align < layout.payload_align); const tag_field_ptr = self.builder.buildStructGEP(un_llvm_ty, union_ptr, tag_index, ""); // TODO alignment on this store _ = self.builder.buildStore(new_tag, tag_field_ptr); @@ -8463,14 +8463,14 @@ pub const FuncGen = struct { if (layout.payload_size == 0) { return self.builder.buildLoad(llvm_un_ty, union_handle, ""); } - const tag_index = @boolToInt(layout.tag_align < layout.payload_align); + const tag_index = @intFromBool(layout.tag_align < layout.payload_align); const tag_field_ptr = self.builder.buildStructGEP(llvm_un_ty, union_handle, tag_index, ""); return self.builder.buildLoad(llvm_un_ty.structGetTypeAtIndex(tag_index), tag_field_ptr, ""); } else { if (layout.payload_size == 0) { return union_handle; } - const tag_index = @boolToInt(layout.tag_align < layout.payload_align); + const tag_index = @intFromBool(layout.tag_align < layout.payload_align); return self.builder.buildExtractValue(union_handle, tag_index, ""); } } @@ -9206,7 +9206,7 @@ pub const FuncGen = struct { const union_field_name = union_obj.fields.keys()[extra.field_index]; const enum_field_index = tag_ty.enumFieldIndex(union_field_name, mod).?; const tag_val = try mod.enumValueFieldIndex(tag_ty, enum_field_index); - const tag_int_val = try tag_val.enumToInt(tag_ty, mod); + const tag_int_val = try tag_val.intFromEnum(tag_ty, mod); break :blk tag_int_val.toUnsignedInt(mod); }; if (layout.payload_size == 0) { @@ -9288,7 +9288,7 @@ pub const FuncGen = struct { { const indices: [3]*llvm.Value = .{ index_type.constNull(), - index_type.constInt(@boolToInt(layout.tag_align >= layout.payload_align), .False), + index_type.constInt(@intFromBool(layout.tag_align >= layout.payload_align), .False), index_type.constNull(), }; const len: c_uint = if (field_size == layout.payload_size) 2 else 3; @@ -9298,7 +9298,7 @@ pub const FuncGen = struct { { const indices: [2]*llvm.Value = .{ index_type.constNull(), - index_type.constInt(@boolToInt(layout.tag_align < layout.payload_align), .False), + index_type.constInt(@intFromBool(layout.tag_align < layout.payload_align), .False), }; const field_ptr = self.builder.buildInBoundsGEP(llvm_union_ty, result_ptr, &indices, indices.len, ""); const tag_llvm_ty = try self.dg.lowerType(union_obj.tag_ty); @@ -9313,15 +9313,15 @@ pub const FuncGen = struct { fn airPrefetch(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value { const prefetch = self.air.instructions.items(.data)[inst].prefetch; - comptime assert(@enumToInt(std.builtin.PrefetchOptions.Rw.read) == 0); - comptime assert(@enumToInt(std.builtin.PrefetchOptions.Rw.write) == 1); + comptime assert(@intFromEnum(std.builtin.PrefetchOptions.Rw.read) == 0); + comptime assert(@intFromEnum(std.builtin.PrefetchOptions.Rw.write) == 1); // TODO these two asserts should be able to be comptime because the type is a u2 assert(prefetch.locality >= 0); assert(prefetch.locality <= 3); - comptime assert(@enumToInt(std.builtin.PrefetchOptions.Cache.instruction) == 0); - comptime assert(@enumToInt(std.builtin.PrefetchOptions.Cache.data) == 1); + comptime assert(@intFromEnum(std.builtin.PrefetchOptions.Cache.instruction) == 0); + comptime assert(@intFromEnum(std.builtin.PrefetchOptions.Cache.data) == 1); // LLVM fails during codegen of instruction cache prefetchs for these architectures. // This is an LLVM bug as the prefetch intrinsic should be a noop if not supported @@ -9368,9 +9368,9 @@ pub const FuncGen = struct { const params = [_]*llvm.Value{ ptr, - llvm_u32.constInt(@enumToInt(prefetch.rw), .False), + llvm_u32.constInt(@intFromEnum(prefetch.rw), .False), llvm_u32.constInt(prefetch.locality, .False), - llvm_u32.constInt(@enumToInt(prefetch.cache), .False), + llvm_u32.constInt(@intFromEnum(prefetch.cache), .False), }; _ = self.builder.buildCall(fn_val.globalGetValueType(), fn_val, ¶ms, params.len, .C, .Auto, ""); return null; @@ -9596,7 +9596,7 @@ pub const FuncGen = struct { // the index to the element at index `1` to get a pointer to the end of // the struct. const llvm_u32 = self.context.intType(32); - const llvm_index = llvm_u32.constInt(@boolToInt(struct_ty.hasRuntimeBitsIgnoreComptime(mod)), .False); + const llvm_index = llvm_u32.constInt(@intFromBool(struct_ty.hasRuntimeBitsIgnoreComptime(mod)), .False); const indices: [1]*llvm.Value = .{llvm_index}; return self.builder.buildInBoundsGEP(struct_llvm_ty, struct_ptr, &indices, indices.len, ""); } @@ -9605,7 +9605,7 @@ pub const FuncGen = struct { .Union => { const layout = struct_ty.unionGetLayout(mod); if (layout.payload_size == 0 or struct_ty.containerLayout(mod) == .Packed) return struct_ptr; - const payload_index = @boolToInt(layout.tag_align >= layout.payload_align); + const payload_index = @intFromBool(layout.tag_align >= layout.payload_align); const union_llvm_ty = try self.dg.lowerType(struct_ty); const union_field_ptr = self.builder.buildStructGEP(union_llvm_ty, struct_ptr, payload_index, ""); return union_field_ptr; @@ -9658,7 +9658,7 @@ pub const FuncGen = struct { assert(info.vector_index != .runtime); if (info.vector_index != .none) { - const index_u32 = self.context.intType(32).constInt(@enumToInt(info.vector_index), .False); + const index_u32 = self.context.intType(32).constInt(@intFromEnum(info.vector_index), .False); const vec_elem_ty = try self.dg.lowerType(info.pointee_type); const vec_ty = vec_elem_ty.vectorType(info.host_size); @@ -9734,7 +9734,7 @@ pub const FuncGen = struct { assert(info.vector_index != .runtime); if (info.vector_index != .none) { - const index_u32 = self.context.intType(32).constInt(@enumToInt(info.vector_index), .False); + const index_u32 = self.context.intType(32).constInt(@intFromEnum(info.vector_index), .False); const vec_elem_ty = try self.dg.lowerType(elem_ty); const vec_ty = vec_elem_ty.vectorType(info.host_size); @@ -11025,29 +11025,29 @@ const AnnotatedDITypePtr = enum(usize) { _, fn initFwd(di_type: *llvm.DIType) AnnotatedDITypePtr { - const addr = @ptrToInt(di_type); + const addr = @intFromPtr(di_type); assert(@truncate(u1, addr) == 0); - return @intToEnum(AnnotatedDITypePtr, addr | 1); + return @enumFromInt(AnnotatedDITypePtr, addr | 1); } fn initFull(di_type: *llvm.DIType) AnnotatedDITypePtr { - const addr = @ptrToInt(di_type); - return @intToEnum(AnnotatedDITypePtr, addr); + const addr = @intFromPtr(di_type); + return @enumFromInt(AnnotatedDITypePtr, addr); } fn init(di_type: *llvm.DIType, resolve: Object.DebugResolveStatus) AnnotatedDITypePtr { - const addr = @ptrToInt(di_type); - const bit = @boolToInt(resolve == .fwd); - return @intToEnum(AnnotatedDITypePtr, addr | bit); + const addr = @intFromPtr(di_type); + const bit = @intFromBool(resolve == .fwd); + return @enumFromInt(AnnotatedDITypePtr, addr | bit); } fn toDIType(self: AnnotatedDITypePtr) *llvm.DIType { - const fixed_addr = @enumToInt(self) & ~@as(usize, 1); - return @intToPtr(*llvm.DIType, fixed_addr); + const fixed_addr = @intFromEnum(self) & ~@as(usize, 1); + return @ptrFromInt(*llvm.DIType, fixed_addr); } fn isFwdOnly(self: AnnotatedDITypePtr) bool { - return @truncate(u1, @enumToInt(self)) != 0; + return @truncate(u1, @intFromEnum(self)) != 0; } }; @@ -11118,11 +11118,11 @@ fn buildAllocaInner( } fn errUnionPayloadOffset(payload_ty: Type, mod: *Module) u1 { - return @boolToInt(Type.anyerror.abiAlignment(mod) > payload_ty.abiAlignment(mod)); + return @intFromBool(Type.anyerror.abiAlignment(mod) > payload_ty.abiAlignment(mod)); } fn errUnionErrorOffset(payload_ty: Type, mod: *Module) u1 { - return @boolToInt(Type.anyerror.abiAlignment(mod) <= payload_ty.abiAlignment(mod)); + return @intFromBool(Type.anyerror.abiAlignment(mod) <= payload_ty.abiAlignment(mod)); } /// Returns true for asm constraint (e.g. "=*m", "=r") if it accepts a memory location diff --git a/src/codegen/llvm/bindings.zig b/src/codegen/llvm/bindings.zig index 0e5a2d0a7d2b..758cf5c72188 100644 --- a/src/codegen/llvm/bindings.zig +++ b/src/codegen/llvm/bindings.zig @@ -8,7 +8,7 @@ pub const Bool = enum(c_int) { _, pub fn fromBool(b: bool) Bool { - return @intToEnum(Bool, @boolToInt(b)); + return @enumFromInt(Bool, @intFromBool(b)); } pub fn toBool(b: Bool) bool { diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index 2e614d90d1ff..46ef5609dbe7 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -387,7 +387,7 @@ pub const DeclGen = struct { switch (repr) { .indirect => { const int_ty_ref = try self.intType(.unsigned, 1); - return self.spv.constInt(int_ty_ref, @boolToInt(value)); + return self.spv.constInt(int_ty_ref, @intFromBool(value)); }, .direct => { const bool_ty_ref = try self.resolveType(Type.bool, .direct); @@ -532,7 +532,7 @@ pub const DeclGen = struct { } fn addConstBool(self: *@This(), value: bool) !void { - try self.addByte(@boolToInt(value)); // TODO: Keep in sync with something? + try self.addByte(@intFromBool(value)); // TODO: Keep in sync with something? } fn addInt(self: *@This(), ty: Type, val: Value) !void { @@ -697,7 +697,7 @@ pub const DeclGen = struct { try self.addUndef(padding); }, .enum_tag => { - const int_val = try val.enumToInt(ty, mod); + const int_val = try val.intFromEnum(ty, mod); const int_ty = ty.intTagType(mod); @@ -873,7 +873,7 @@ pub const DeclGen = struct { assert(storage_class != .Generic and storage_class != .Function); const var_id = self.spv.allocId(); - log.debug("lowerIndirectConstant: id = {}, index = {}, ty = {}, val = {}", .{ var_id.id, @enumToInt(spv_decl_index), ty.fmt(self.module), val.fmtDebug() }); + log.debug("lowerIndirectConstant: id = {}, index = {}, ty = {}, val = {}", .{ var_id.id, @intFromEnum(spv_decl_index), ty.fmt(self.module), val.fmtDebug() }); const section = &self.spv.globals.section; @@ -1010,7 +1010,7 @@ pub const DeclGen = struct { false, alignment, ); - log.debug("indirect constant: index = {}", .{@enumToInt(spv_decl_index)}); + log.debug("indirect constant: index = {}", .{@intFromEnum(spv_decl_index)}); try self.func.decl_deps.put(self.spv.gpa, spv_decl_index, {}); try self.func.body.emit(self.spv.gpa, .OpLoad, .{ @@ -1578,7 +1578,7 @@ pub const DeclGen = struct { } } - fn boolToInt(self: *DeclGen, result_ty_ref: CacheRef, condition_id: IdRef) !IdRef { + fn intFromBool(self: *DeclGen, result_ty_ref: CacheRef, condition_id: IdRef) !IdRef { const zero_id = try self.spv.constInt(result_ty_ref, 0); const one_id = try self.spv.constInt(result_ty_ref, 1); const result_id = self.spv.allocId(); @@ -1621,7 +1621,7 @@ pub const DeclGen = struct { return switch (ty.zigTypeTag(mod)) { .Bool => blk: { const indirect_bool_ty_ref = try self.resolveType(ty, .indirect); - break :blk self.boolToInt(indirect_bool_ty_ref, operand_id); + break :blk self.intFromBool(indirect_bool_ty_ref, operand_id); }, else => operand_id, }; @@ -2011,7 +2011,7 @@ pub const DeclGen = struct { // Construct the struct that Zig wants as result. // The value should already be the correct type. - const ov_id = try self.boolToInt(ov_ty_ref, overflowed_id); + const ov_id = try self.intFromBool(ov_ty_ref, overflowed_id); const result_ty_ref = try self.resolveType(result_ty, .direct); return try self.constructStruct(result_ty_ref, &.{ value_id, @@ -2515,7 +2515,7 @@ pub const DeclGen = struct { if (layout.payload_size == 0) return union_handle; const tag_ty = un_ty.unionTagTypeSafety().?; - const tag_index = @boolToInt(layout.tag_align < layout.payload_align); + const tag_index = @intFromBool(layout.tag_align < layout.payload_align); return try self.extractField(tag_ty, union_handle, tag_index); } @@ -3105,7 +3105,7 @@ pub const DeclGen = struct { .Int => if (cond_ty.isSignedInt(mod)) @bitCast(u64, value.toSignedInt(mod)) else value.toUnsignedInt(mod), .Enum => blk: { // TODO: figure out of cond_ty is correct (something with enum literals) - break :blk (try value.enumToInt(cond_ty, mod)).toUnsignedInt(mod); // TODO: composite integer constants + break :blk (try value.intFromEnum(cond_ty, mod)).toUnsignedInt(mod); // TODO: composite integer constants }, else => unreachable, }; diff --git a/src/codegen/spirv/Assembler.zig b/src/codegen/spirv/Assembler.zig index c7848bbc921a..73a842ebe9ec 100644 --- a/src/codegen/spirv/Assembler.zig +++ b/src/codegen/spirv/Assembler.zig @@ -306,7 +306,7 @@ fn processTypeInstruction(self: *Assembler) !AsmValue { }, .OpTypePointer => try self.spv.ptrType( try self.resolveTypeRef(operands[2].ref_id), - @intToEnum(spec.StorageClass, operands[1].value), + @enumFromInt(spec.StorageClass, operands[1].value), ), .OpTypeFunction => blk: { const param_operands = operands[2..]; @@ -340,7 +340,7 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue { else => switch (self.inst.opcode) { .OpEntryPoint => unreachable, .OpExecutionMode, .OpExecutionModeId => &self.spv.sections.execution_modes, - .OpVariable => switch (@intToEnum(spec.StorageClass, operands[2].value)) { + .OpVariable => switch (@enumFromInt(spec.StorageClass, operands[2].value)) { .Function => &self.func.prologue, else => { // This is currently disabled because global variables are required to be @@ -391,7 +391,7 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue { } const actual_word_count = section.instructions.items.len - first_word; - section.instructions.items[first_word] |= @as(u32, @intCast(u16, actual_word_count)) << 16 | @enumToInt(self.inst.opcode); + section.instructions.items[first_word] |= @as(u32, @intCast(u16, actual_word_count)) << 16 | @intFromEnum(self.inst.opcode); if (maybe_result_id) |result| { return AsmValue{ .value = result }; @@ -695,7 +695,7 @@ fn parseContextDependentInt(self: *Assembler, signedness: std.builtin.Signedness .unsigned => 0, .signed => -(@as(i128, 1) << (@intCast(u7, width) - 1)), }; - const max = (@as(i128, 1) << (@intCast(u7, width) - @boolToInt(signedness == .signed))) - 1; + const max = (@as(i128, 1) << (@intCast(u7, width) - @intFromBool(signedness == .signed))) - 1; if (int < min or int > max) { break :invalid; } diff --git a/src/codegen/spirv/Cache.zig b/src/codegen/spirv/Cache.zig index 4c41bf583b79..7d7fc0fb0d9d 100644 --- a/src/codegen/spirv/Cache.zig +++ b/src/codegen/spirv/Cache.zig @@ -411,7 +411,7 @@ pub const Key = union(enum) { pub fn eql(ctx: @This(), a: Key, b_void: void, b_index: usize) bool { _ = b_void; - return ctx.self.lookup(@intToEnum(Ref, b_index)).eql(a); + return ctx.self.lookup(@enumFromInt(Ref, b_index)).eql(a); } pub fn hash(ctx: @This(), a: Key) u32 { @@ -445,7 +445,7 @@ pub fn materialize(self: *const Self, spv: *Module) !Section { var section = Section{}; errdefer section.deinit(spv.gpa); for (self.items.items(.result_id), 0..) |result_id, index| { - try self.emit(spv, result_id, @intToEnum(Ref, index), §ion); + try self.emit(spv, result_id, @enumFromInt(Ref, index), §ion); } return section; } @@ -603,14 +603,14 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref { const adapter: Key.Adapter = .{ .self = self }; const entry = try self.map.getOrPutAdapted(spv.gpa, key, adapter); if (entry.found_existing) { - return @intToEnum(Ref, entry.index); + return @enumFromInt(Ref, entry.index); } const result_id = spv.allocId(); const item: Item = switch (key) { inline .void_type, .bool_type => .{ .tag = .type_simple, .result_id = result_id, - .data = @enumToInt(key.toSimpleType()), + .data = @intFromEnum(key.toSimpleType()), }, .int_type => |int| blk: { const t: Tag = switch (int.signedness) { @@ -654,17 +654,17 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref { .Generic => Item{ .tag = .type_ptr_generic, .result_id = result_id, - .data = @enumToInt(ptr.child_type), + .data = @intFromEnum(ptr.child_type), }, .CrossWorkgroup => Item{ .tag = .type_ptr_crosswgp, .result_id = result_id, - .data = @enumToInt(ptr.child_type), + .data = @intFromEnum(ptr.child_type), }, .Function => Item{ .tag = .type_ptr_function, .result_id = result_id, - .data = @enumToInt(ptr.child_type), + .data = @intFromEnum(ptr.child_type), }, else => |storage_class| Item{ .tag = .type_ptr_simple, @@ -770,12 +770,12 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref { .undef => |undef| .{ .tag = .undef, .result_id = result_id, - .data = @enumToInt(undef.ty), + .data = @intFromEnum(undef.ty), }, .null => |null_info| .{ .tag = .null, .result_id = result_id, - .data = @enumToInt(null_info.ty), + .data = @intFromEnum(null_info.ty), }, .bool => |bool_info| .{ .tag = switch (bool_info.value) { @@ -783,21 +783,21 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref { false => Tag.bool_false, }, .result_id = result_id, - .data = @enumToInt(bool_info.ty), + .data = @intFromEnum(bool_info.ty), }, }; try self.items.append(spv.gpa, item); - return @intToEnum(Ref, entry.index); + return @enumFromInt(Ref, entry.index); } /// Turn a Ref back into a Key. /// The Key is valid until the next call to resolve(). pub fn lookup(self: *const Self, ref: Ref) Key { - const item = self.items.get(@enumToInt(ref)); + const item = self.items.get(@intFromEnum(ref)); const data = item.data; return switch (item.tag) { - .type_simple => switch (@intToEnum(Tag.SimpleType, data)) { + .type_simple => switch (@enumFromInt(Tag.SimpleType, data)) { .void => .void_type, .bool => .bool_type, }, @@ -826,19 +826,19 @@ pub fn lookup(self: *const Self, ref: Ref) Key { .type_ptr_generic => .{ .ptr_type = .{ .storage_class = .Generic, - .child_type = @intToEnum(Ref, data), + .child_type = @enumFromInt(Ref, data), }, }, .type_ptr_crosswgp => .{ .ptr_type = .{ .storage_class = .CrossWorkgroup, - .child_type = @intToEnum(Ref, data), + .child_type = @enumFromInt(Ref, data), }, }, .type_ptr_function => .{ .ptr_type = .{ .storage_class = .Function, - .child_type = @intToEnum(Ref, data), + .child_type = @enumFromInt(Ref, data), }, }, .type_ptr_simple => { @@ -923,17 +923,17 @@ pub fn lookup(self: *const Self, ref: Ref) Key { } }; }, .undef => .{ .undef = .{ - .ty = @intToEnum(Ref, data), + .ty = @enumFromInt(Ref, data), } }, .null => .{ .null = .{ - .ty = @intToEnum(Ref, data), + .ty = @enumFromInt(Ref, data), } }, .bool_true => .{ .bool = .{ - .ty = @intToEnum(Ref, data), + .ty = @enumFromInt(Ref, data), .value = true, } }, .bool_false => .{ .bool = .{ - .ty = @intToEnum(Ref, data), + .ty = @enumFromInt(Ref, data), .value = false, } }, }; @@ -942,14 +942,14 @@ pub fn lookup(self: *const Self, ref: Ref) Key { /// Look op the result-id that corresponds to a particular /// ref. pub fn resultId(self: Self, ref: Ref) IdResult { - return self.items.items(.result_id)[@enumToInt(ref)]; + return self.items.items(.result_id)[@intFromEnum(ref)]; } /// Get the ref for a key that has already been added to the cache. fn get(self: *const Self, key: Key) Ref { const adapter: Key.Adapter = .{ .self = self }; const index = self.map.getIndexAdapted(key, adapter).?; - return @intToEnum(Ref, index); + return @enumFromInt(Ref, index); } fn addExtra(self: *Self, spv: *Module, extra: anytype) !u32 { @@ -965,9 +965,9 @@ fn addExtraAssumeCapacity(self: *Self, extra: anytype) !u32 { const word = switch (field.type) { u32 => field_val, i32 => @bitCast(u32, field_val), - Ref => @enumToInt(field_val), - StorageClass => @enumToInt(field_val), - String => @enumToInt(field_val), + Ref => @intFromEnum(field_val), + StorageClass => @intFromEnum(field_val), + String => @intFromEnum(field_val), else => @compileError("Invalid type: " ++ @typeName(field.type)), }; self.extra.appendAssumeCapacity(word); @@ -987,9 +987,9 @@ fn extraDataTrail(self: Self, comptime T: type, offset: u32) struct { data: T, t @field(result, field.name) = switch (field.type) { u32 => word, i32 => @bitCast(i32, word), - Ref => @intToEnum(Ref, word), - StorageClass => @intToEnum(StorageClass, word), - String => @intToEnum(String, word), + Ref => @enumFromInt(Ref, word), + StorageClass => @enumFromInt(StorageClass, word), + String => @enumFromInt(String, word), else => @compileError("Invalid type: " ++ @typeName(field.type)), }; } @@ -1035,12 +1035,12 @@ pub fn addString(self: *Self, spv: *Module, str: []const u8) !String { entry.value_ptr.* = @intCast(u32, offset); } - return @intToEnum(String, entry.index); + return @enumFromInt(String, entry.index); } pub fn getString(self: *const Self, ref: String) ?[]const u8 { return switch (ref) { .none => null, - else => std.mem.sliceTo(self.string_bytes.items[self.strings.values()[@enumToInt(ref)]..], 0), + else => std.mem.sliceTo(self.string_bytes.items[self.strings.values()[@intFromEnum(ref)]..], 0), }; } diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig index d53dcb4368ca..9d8cca9445ba 100644 --- a/src/codegen/spirv/Module.zig +++ b/src/codegen/spirv/Module.zig @@ -246,10 +246,10 @@ fn orderGlobalsInto( const global = self.globalPtr(decl_index).?; const insts = self.globals.section.instructions.items[global.begin_inst..global.end_inst]; - seen.set(@enumToInt(decl_index)); + seen.set(@intFromEnum(decl_index)); for (deps) |dep| { - if (!seen.isSet(@enumToInt(dep))) { + if (!seen.isSet(@intFromEnum(dep))) { try self.orderGlobalsInto(dep, section, seen); } } @@ -267,7 +267,7 @@ fn orderGlobals(self: *Module) !Section { errdefer ordered_globals.deinit(self.gpa); for (globals) |decl_index| { - if (!seen.isSet(@enumToInt(decl_index))) { + if (!seen.isSet(@intFromEnum(decl_index))) { try self.orderGlobalsInto(decl_index, &ordered_globals, &seen); } } @@ -284,14 +284,14 @@ fn addEntryPointDeps( const decl = self.declPtr(decl_index); const deps = self.decl_deps.items[decl.begin_dep..decl.end_dep]; - seen.set(@enumToInt(decl_index)); + seen.set(@intFromEnum(decl_index)); if (self.globalPtr(decl_index)) |global| { try interface.append(global.result_id); } for (deps) |dep| { - if (!seen.isSet(@enumToInt(dep))) { + if (!seen.isSet(@intFromEnum(dep))) { try self.addEntryPointDeps(dep, seen, interface); } } @@ -516,7 +516,7 @@ pub fn allocDecl(self: *Module, kind: DeclKind) !Decl.Index { .begin_dep = undefined, .end_dep = undefined, }); - const index = @intToEnum(Decl.Index, @intCast(u32, self.decls.items.len - 1)); + const index = @enumFromInt(Decl.Index, @intCast(u32, self.decls.items.len - 1)); switch (kind) { .func => {}, // If the decl represents a global, also allocate a global node. @@ -531,7 +531,7 @@ pub fn allocDecl(self: *Module, kind: DeclKind) !Decl.Index { } pub fn declPtr(self: *Module, index: Decl.Index) *Decl { - return &self.decls.items[@enumToInt(index)]; + return &self.decls.items[@intFromEnum(index)]; } pub fn globalPtr(self: *Module, index: Decl.Index) ?*Global { diff --git a/src/codegen/spirv/Section.zig b/src/codegen/spirv/Section.zig index b6087bbc3b61..b35dc489e420 100644 --- a/src/codegen/spirv/Section.zig +++ b/src/codegen/spirv/Section.zig @@ -50,7 +50,7 @@ pub fn emitRaw( ) !void { const word_count = 1 + operand_words; try section.instructions.ensureUnusedCapacity(allocator, word_count); - section.writeWord((@intCast(Word, word_count << 16)) | @enumToInt(opcode)); + section.writeWord((@intCast(Word, word_count << 16)) | @intFromEnum(opcode)); } pub fn emit( @@ -61,7 +61,7 @@ pub fn emit( ) !void { const word_count = instructionSize(opcode, operands); try section.instructions.ensureUnusedCapacity(allocator, word_count); - section.writeWord(@intCast(Word, word_count << 16) | @enumToInt(opcode)); + section.writeWord(@intCast(Word, word_count << 16) | @intFromEnum(opcode)); section.writeOperands(opcode.Operands(), operands); } @@ -126,14 +126,14 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand) // TODO: Where this type is used (OpSpecConstantOp) is currently not correct in the spec json, // so it most likely needs to be altered into something that can actually describe the entire // instruction in which it is used. - spec.LiteralSpecConstantOpInteger => section.writeWord(@enumToInt(operand.opcode)), + spec.LiteralSpecConstantOpInteger => section.writeWord(@intFromEnum(operand.opcode)), spec.PairLiteralIntegerIdRef => section.writeWords(&.{ operand.value, operand.label.id }), spec.PairIdRefLiteralInteger => section.writeWords(&.{ operand.target.id, operand.member }), spec.PairIdRefIdRef => section.writeWords(&.{ operand[0].id, operand[1].id }), else => switch (@typeInfo(Operand)) { - .Enum => section.writeWord(@enumToInt(operand)), + .Enum => section.writeWord(@intFromEnum(operand)), .Optional => |info| if (operand) |child| { section.writeOperand(info.child, child); }, @@ -217,7 +217,7 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand fn writeExtendedUnion(section: *Section, comptime Operand: type, operand: Operand) void { const tag = std.meta.activeTag(operand); - section.writeWord(@enumToInt(tag)); + section.writeWord(@intFromEnum(tag)); inline for (@typeInfo(Operand).Union.fields) |field| { if (@field(Operand, field.name) == tag) { @@ -327,7 +327,7 @@ test "SPIR-V Section emit() - no operands" { try section.emit(std.testing.allocator, .OpNop, {}); - try testing.expect(section.instructions.items[0] == (@as(Word, 1) << 16) | @enumToInt(Opcode.OpNop)); + try testing.expect(section.instructions.items[0] == (@as(Word, 1) << 16) | @intFromEnum(Opcode.OpNop)); } test "SPIR-V Section emit() - simple" { @@ -340,7 +340,7 @@ test "SPIR-V Section emit() - simple" { }); try testing.expectEqualSlices(Word, &.{ - (@as(Word, 3) << 16) | @enumToInt(Opcode.OpUndef), + (@as(Word, 3) << 16) | @intFromEnum(Opcode.OpUndef), 0, 1, }, section.instructions.items); @@ -358,8 +358,8 @@ test "SPIR-V Section emit() - string" { }); try testing.expectEqualSlices(Word, &.{ - (@as(Word, 10) << 16) | @enumToInt(Opcode.OpSource), - @enumToInt(spec.SourceLanguage.Unknown), + (@as(Word, 10) << 16) | @intFromEnum(Opcode.OpSource), + @intFromEnum(spec.SourceLanguage.Unknown), 123, 456, std.mem.bytesToValue(Word, "pub "), @@ -389,7 +389,7 @@ test "SPIR-V Section emit() - extended mask" { }); try testing.expectEqualSlices(Word, &.{ - (@as(Word, 5) << 16) | @enumToInt(Opcode.OpLoopMerge), + (@as(Word, 5) << 16) | @intFromEnum(Opcode.OpLoopMerge), 10, 20, @bitCast(Word, spec.LoopControl{ .Unroll = true, .DependencyLength = true }), @@ -409,9 +409,9 @@ test "SPIR-V Section emit() - extended union" { }); try testing.expectEqualSlices(Word, &.{ - (@as(Word, 6) << 16) | @enumToInt(Opcode.OpExecutionMode), + (@as(Word, 6) << 16) | @intFromEnum(Opcode.OpExecutionMode), 888, - @enumToInt(spec.ExecutionMode.LocalSize), + @intFromEnum(spec.ExecutionMode.LocalSize), 4, 8, 16, diff --git a/src/crash_report.zig b/src/crash_report.zig index 57b870c198c0..cb468c101f82 100644 --- a/src/crash_report.zig +++ b/src/crash_report.zig @@ -186,11 +186,11 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any PanicSwitch.preDispatch(); const addr = switch (builtin.os.tag) { - .linux => @ptrToInt(info.fields.sigfault.addr), - .freebsd, .macos => @ptrToInt(info.addr), - .netbsd => @ptrToInt(info.info.reason.fault.addr), - .openbsd => @ptrToInt(info.data.fault.addr), - .solaris => @ptrToInt(info.reason.fault.addr), + .linux => @intFromPtr(info.fields.sigfault.addr), + .freebsd, .macos => @intFromPtr(info.addr), + .netbsd => @intFromPtr(info.info.reason.fault.addr), + .openbsd => @intFromPtr(info.data.fault.addr), + .solaris => @intFromPtr(info.reason.fault.addr), else => @compileError("TODO implement handleSegfaultPosix for new POSIX OS"), }; @@ -279,7 +279,7 @@ fn handleSegfaultWindowsExtra(info: *os.windows.EXCEPTION_POINTERS, comptime msg const regs = info.ContextRecord.getRegs(); break :ctx StackContext{ .exception = .{ .bp = regs.bp, .ip = regs.ip } }; } else ctx: { - const addr = @ptrToInt(info.ExceptionRecord.ExceptionAddress); + const addr = @intFromPtr(info.ExceptionRecord.ExceptionAddress); break :ctx StackContext{ .current = .{ .ret_addr = addr } }; }; diff --git a/src/libcxx.zig b/src/libcxx.zig index 07e3473338a3..07967ec694f8 100644 --- a/src/libcxx.zig +++ b/src/libcxx.zig @@ -128,10 +128,10 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" }); const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" }); const abi_version_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{ - @enumToInt(comp.libcxx_abi_version), + @intFromEnum(comp.libcxx_abi_version), }); const abi_namespace_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{ - @enumToInt(comp.libcxx_abi_version), + @intFromEnum(comp.libcxx_abi_version), }); var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxx_files.len); @@ -302,10 +302,10 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" }); const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" }); const abi_version_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{ - @enumToInt(comp.libcxx_abi_version), + @intFromEnum(comp.libcxx_abi_version), }); const abi_namespace_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{ - @enumToInt(comp.libcxx_abi_version), + @intFromEnum(comp.libcxx_abi_version), }); var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxxabi_files.len); diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 202bb71e9b5e..e3fcc941eb46 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -538,7 +538,7 @@ fn allocateAtom(self: *Coff, atom_index: Atom.Index, new_atom_size: u32, alignme defer tracy.end(); const atom = self.getAtom(atom_index); - const sect_id = @enumToInt(atom.getSymbol(self).section_number) - 1; + const sect_id = @intFromEnum(atom.getSymbol(self).section_number) - 1; const header = &self.sections.items(.header)[sect_id]; const free_list = &self.sections.items(.free_list)[sect_id]; const maybe_last_atom_index = &self.sections.items(.last_atom_index)[sect_id]; @@ -739,7 +739,7 @@ fn shrinkAtom(self: *Coff, atom_index: Atom.Index, new_block_size: u32) void { fn writeAtom(self: *Coff, atom_index: Atom.Index, code: []u8) !void { const atom = self.getAtom(atom_index); const sym = atom.getSymbol(self); - const section = self.sections.get(@enumToInt(sym.section_number) - 1); + const section = self.sections.get(@intFromEnum(sym.section_number) - 1); const file_offset = section.header.pointer_to_raw_data + sym.value - section.header.virtual_address; log.debug("writing atom for symbol {s} at file offset 0x{x} to 0x{x}", .{ @@ -769,14 +769,14 @@ fn writeAtom(self: *Coff, atom_index: Atom.Index, code: []u8) !void { if (is_hot_update_compatible) { if (self.base.child_pid) |handle| { - const slide = @ptrToInt(self.hot_state.loaded_base_address.?); + const slide = @intFromPtr(self.hot_state.loaded_base_address.?); const mem_code = try gpa.dupe(u8, code); defer gpa.free(mem_code); self.resolveRelocs(atom_index, relocs.items, mem_code, slide); const vaddr = sym.value + slide; - const pvaddr = @intToPtr(*anyopaque, vaddr); + const pvaddr = @ptrFromInt(*anyopaque, vaddr); log.debug("writing to memory at address {x}", .{vaddr}); @@ -860,9 +860,9 @@ fn writeOffsetTableEntry(self: *Coff, index: usize) !void { if (is_hot_update_compatible) { if (self.base.child_pid) |handle| { const gpa = self.base.allocator; - const slide = @ptrToInt(self.hot_state.loaded_base_address.?); + const slide = @intFromPtr(self.hot_state.loaded_base_address.?); const actual_vmaddr = vmaddr + slide; - const pvaddr = @intToPtr(*anyopaque, actual_vmaddr); + const pvaddr = @ptrFromInt(*anyopaque, actual_vmaddr); log.debug("writing GOT entry to memory at address {x}", .{actual_vmaddr}); if (build_options.enable_logging) { switch (self.ptr_width) { @@ -970,7 +970,7 @@ fn freeAtom(self: *Coff, atom_index: Atom.Index) void { const atom = self.getAtom(atom_index); const sym = atom.getSymbol(self); - const sect_id = @enumToInt(sym.section_number) - 1; + const sect_id = @intFromEnum(sym.section_number) - 1; const free_list = &self.sections.items(.free_list)[sect_id]; var already_have_free_list_node = false; { @@ -1107,7 +1107,7 @@ pub fn lowerUnnamedConst(self: *Coff, tv: TypedValue, decl_index: Module.Decl.In const atom = self.getAtom(atom_index); const sym = atom.getSymbolPtr(self); try self.setSymbolName(sym, sym_name); - sym.section_number = @intToEnum(coff.SectionNumber, self.rdata_section_index.? + 1); + sym.section_number = @enumFromInt(coff.SectionNumber, self.rdata_section_index.? + 1); } const res = try codegen.generateSymbol(&self.base, decl.srcLoc(mod), tv, &code_buffer, .none, .{ @@ -1244,7 +1244,7 @@ fn updateLazySymbolAtom( const code_len = @intCast(u32, code.len); const symbol = atom.getSymbolPtr(self); try self.setSymbolName(symbol, name); - symbol.section_number = @intToEnum(coff.SectionNumber, section_index + 1); + symbol.section_number = @enumFromInt(coff.SectionNumber, section_index + 1); symbol.type = .{ .complex_type = .NULL, .base_type = .NULL }; const vaddr = try self.allocateAtom(atom_index, code_len, required_alignment); @@ -1341,7 +1341,7 @@ fn updateDeclCode(self: *Coff, decl_index: Module.Decl.Index, code: []u8, comple if (atom.size != 0) { const sym = atom.getSymbolPtr(self); try self.setSymbolName(sym, decl_name); - sym.section_number = @intToEnum(coff.SectionNumber, sect_index + 1); + sym.section_number = @enumFromInt(coff.SectionNumber, sect_index + 1); sym.type = .{ .complex_type = complex_type, .base_type = .NULL }; const capacity = atom.capacity(self); @@ -1365,7 +1365,7 @@ fn updateDeclCode(self: *Coff, decl_index: Module.Decl.Index, code: []u8, comple } else { const sym = atom.getSymbolPtr(self); try self.setSymbolName(sym, decl_name); - sym.section_number = @intToEnum(coff.SectionNumber, sect_index + 1); + sym.section_number = @enumFromInt(coff.SectionNumber, sect_index + 1); sym.type = .{ .complex_type = complex_type, .base_type = .NULL }; const vaddr = try self.allocateAtom(atom_index, code_len, required_alignment); @@ -1502,7 +1502,7 @@ pub fn updateDeclExports( const sym = self.getSymbolPtr(sym_loc); try self.setSymbolName(sym, mod.intern_pool.stringToSlice(exp.opts.name)); sym.value = decl_sym.value; - sym.section_number = @intToEnum(coff.SectionNumber, self.text_section_index.? + 1); + sym.section_number = @enumFromInt(coff.SectionNumber, self.text_section_index.? + 1); sym.type = .{ .complex_type = .FUNCTION, .base_type = .NULL }; switch (exp.opts.linkage) { @@ -1668,7 +1668,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod const atom = self.getAtom(atom_index); const sym = atom.getSymbol(self); - const section = self.sections.get(@enumToInt(sym.section_number) - 1).header; + const section = self.sections.get(@intFromEnum(sym.section_number) - 1).header; const file_offset = section.pointer_to_raw_data + sym.value - section.virtual_address; var code = std.ArrayList(u8).init(gpa); @@ -1878,7 +1878,7 @@ fn writeBaseRelocations(self: *Coff) !void { try self.base.file.?.pwriteAll(buffer.items, header.pointer_to_raw_data); - self.data_directories[@enumToInt(coff.DirectoryEntry.BASERELOC)] = .{ + self.data_directories[@intFromEnum(coff.DirectoryEntry.BASERELOC)] = .{ .virtual_address = header.virtual_address, .size = needed_size, }; @@ -2011,11 +2011,11 @@ fn writeImportTables(self: *Coff) !void { try self.base.file.?.pwriteAll(buffer.items, header.pointer_to_raw_data); - self.data_directories[@enumToInt(coff.DirectoryEntry.IMPORT)] = .{ + self.data_directories[@intFromEnum(coff.DirectoryEntry.IMPORT)] = .{ .virtual_address = header.virtual_address + iat_size, .size = dir_table_size, }; - self.data_directories[@enumToInt(coff.DirectoryEntry.IAT)] = .{ + self.data_directories[@intFromEnum(coff.DirectoryEntry.IAT)] = .{ .virtual_address = header.virtual_address, .size = iat_size, }; @@ -2469,7 +2469,7 @@ fn logSymtab(self: *Coff) void { .UNDEFINED => 0, // TODO .ABSOLUTE => unreachable, // TODO .DEBUG => unreachable, // TODO - else => @enumToInt(sym.section_number), + else => @intFromEnum(sym.section_number), }; log.debug(" %{d}: {?s} @{x} in {s}({d}), {s}", .{ sym_id, diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig index 3cb1c213e94a..c9b535e7faa7 100644 --- a/src/link/Dwarf.zig +++ b/src/link/Dwarf.zig @@ -171,11 +171,11 @@ pub const DeclState = struct { switch (ty.zigTypeTag(mod)) { .NoReturn => unreachable, .Void => { - try dbg_info_buffer.append(@enumToInt(AbbrevKind.pad1)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.pad1)); }, .Bool => { try dbg_info_buffer.ensureUnusedCapacity(12); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.base_type)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.base_type)); // DW.AT.encoding, DW.FORM.data1 dbg_info_buffer.appendAssumeCapacity(DW.ATE.boolean); // DW.AT.byte_size, DW.FORM.udata @@ -186,7 +186,7 @@ pub const DeclState = struct { .Int => { const info = ty.intInfo(mod); try dbg_info_buffer.ensureUnusedCapacity(12); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.base_type)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.base_type)); // DW.AT.encoding, DW.FORM.data1 dbg_info_buffer.appendAssumeCapacity(switch (info.signedness) { .signed => DW.ATE.signed, @@ -200,7 +200,7 @@ pub const DeclState = struct { .Optional => { if (ty.isPtrLikeOptional(mod)) { try dbg_info_buffer.ensureUnusedCapacity(12); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.base_type)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.base_type)); // DW.AT.encoding, DW.FORM.data1 dbg_info_buffer.appendAssumeCapacity(DW.ATE.address); // DW.AT.byte_size, DW.FORM.udata @@ -211,7 +211,7 @@ pub const DeclState = struct { // Non-pointer optionals are structs: struct { .maybe = *, .val = * } const payload_ty = ty.optionalChild(mod); // DW.AT.structure_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_type)); // DW.AT.byte_size, DW.FORM.udata const abi_size = ty.abiSize(mod); try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); @@ -219,7 +219,7 @@ pub const DeclState = struct { try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(7); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("maybe"); dbg_info_buffer.appendAssumeCapacity(0); @@ -231,7 +231,7 @@ pub const DeclState = struct { try dbg_info_buffer.ensureUnusedCapacity(6); dbg_info_buffer.appendAssumeCapacity(0); // DW.AT.member - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("val"); dbg_info_buffer.appendAssumeCapacity(0); @@ -253,14 +253,14 @@ pub const DeclState = struct { const ptr_bytes = @intCast(u8, @divExact(ptr_bits, 8)); // DW.AT.structure_type try dbg_info_buffer.ensureUnusedCapacity(2); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_type)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_type)); // DW.AT.byte_size, DW.FORM.udata try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod)); // DW.AT.name, DW.FORM.string try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(5); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("ptr"); dbg_info_buffer.appendAssumeCapacity(0); @@ -273,7 +273,7 @@ pub const DeclState = struct { try dbg_info_buffer.ensureUnusedCapacity(6); dbg_info_buffer.appendAssumeCapacity(0); // DW.AT.member - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("len"); dbg_info_buffer.appendAssumeCapacity(0); @@ -288,7 +288,7 @@ pub const DeclState = struct { dbg_info_buffer.appendAssumeCapacity(0); } else { try dbg_info_buffer.ensureUnusedCapacity(5); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.ptr_type)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.ptr_type)); // DW.AT.type, DW.FORM.ref4 const index = dbg_info_buffer.items.len; try dbg_info_buffer.resize(index + 4); @@ -297,7 +297,7 @@ pub const DeclState = struct { }, .Array => { // DW.AT.array_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.array_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.array_type)); // DW.AT.name, DW.FORM.string try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); // DW.AT.type, DW.FORM.ref4 @@ -305,7 +305,7 @@ pub const DeclState = struct { try dbg_info_buffer.resize(index + 4); try self.addTypeRelocGlobal(atom_index, ty.childType(mod), @intCast(u32, index)); // DW.AT.subrange_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.array_dim)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.array_dim)); // DW.AT.type, DW.FORM.ref4 index = dbg_info_buffer.items.len; try dbg_info_buffer.resize(index + 4); @@ -318,7 +318,7 @@ pub const DeclState = struct { }, .Struct => blk: { // DW.AT.structure_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_type)); // DW.AT.byte_size, DW.FORM.udata try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod)); @@ -329,7 +329,7 @@ pub const DeclState = struct { for (fields.types, 0..) |field_ty, field_index| { // DW.AT.member - try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_member)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string try dbg_info_buffer.writer().print("{d}\x00", .{field_index}); // DW.AT.type, DW.FORM.ref4 @@ -363,7 +363,7 @@ pub const DeclState = struct { const field_name = mod.intern_pool.stringToSlice(field_name_ip); // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(field_name.len + 2); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity(field_name); dbg_info_buffer.appendAssumeCapacity(0); @@ -384,7 +384,7 @@ pub const DeclState = struct { }, .Enum => { // DW.AT.enumeration_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.enum_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.enum_type)); // DW.AT.byte_size, DW.FORM.udata try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod)); // DW.AT.name, DW.FORM.string @@ -398,7 +398,7 @@ pub const DeclState = struct { const field_name = mod.intern_pool.stringToSlice(field_name_index); // DW.AT.enumerator try dbg_info_buffer.ensureUnusedCapacity(field_name.len + 2 + @sizeOf(u64)); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.enum_variant)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.enum_variant)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity(field_name); dbg_info_buffer.appendAssumeCapacity(0); @@ -408,7 +408,7 @@ pub const DeclState = struct { const value = enum_type.values[field_i]; // TODO do not assume a 64bit enum value - could be bigger. // See https://github.com/ziglang/zig/issues/645 - const field_int_val = try value.toValue().enumToInt(ty, mod); + const field_int_val = try value.toValue().intFromEnum(ty, mod); break :value @bitCast(u64, field_int_val.toSignedInt(mod)); }; mem.writeInt(u64, dbg_info_buffer.addManyAsArrayAssumeCapacity(8), value, target_endian); @@ -430,7 +430,7 @@ pub const DeclState = struct { // for untagged unions. if (is_tagged) { // DW.AT.structure_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_type)); // DW.AT.byte_size, DW.FORM.udata try leb128.writeULEB128(dbg_info_buffer.writer(), layout.abi_size); // DW.AT.name, DW.FORM.string @@ -440,7 +440,7 @@ pub const DeclState = struct { // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(9); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("payload"); dbg_info_buffer.appendAssumeCapacity(0); @@ -453,7 +453,7 @@ pub const DeclState = struct { } // DW.AT.union_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.union_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.union_type)); // DW.AT.byte_size, DW.FORM.udata, try leb128.writeULEB128(dbg_info_buffer.writer(), layout.payload_size); // DW.AT.name, DW.FORM.string @@ -468,7 +468,7 @@ pub const DeclState = struct { const field = fields.get(field_name).?; if (!field.ty.hasRuntimeBits(mod)) continue; // DW.AT.member - try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_member)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string try dbg_info_buffer.appendSlice(mod.intern_pool.stringToSlice(field_name)); try dbg_info_buffer.append(0); @@ -485,7 +485,7 @@ pub const DeclState = struct { if (is_tagged) { // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(5); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("tag"); dbg_info_buffer.appendAssumeCapacity(0); @@ -519,7 +519,7 @@ pub const DeclState = struct { const error_off = if (error_align >= payload_align) 0 else payload_ty.abiSize(mod); // DW.AT.structure_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_type)); // DW.AT.byte_size, DW.FORM.udata try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); // DW.AT.name, DW.FORM.string @@ -529,7 +529,7 @@ pub const DeclState = struct { if (!payload_ty.isNoReturn(mod)) { // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(7); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("value"); dbg_info_buffer.appendAssumeCapacity(0); @@ -544,7 +544,7 @@ pub const DeclState = struct { { // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(5); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("err"); dbg_info_buffer.appendAssumeCapacity(0); @@ -561,7 +561,7 @@ pub const DeclState = struct { }, else => { log.debug("TODO implement .debug_info for type '{}'", .{ty.fmt(self.mod)}); - try dbg_info_buffer.append(@enumToInt(AbbrevKind.pad1)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.pad1)); }, } } @@ -595,7 +595,7 @@ pub const DeclState = struct { switch (loc) { .register => |reg| { try dbg_info.ensureUnusedCapacity(4); - dbg_info.appendAssumeCapacity(@enumToInt(AbbrevKind.parameter)); + dbg_info.appendAssumeCapacity(@intFromEnum(AbbrevKind.parameter)); // DW.AT.location, DW.FORM.exprloc var expr_len = std.io.countingWriter(std.io.null_writer); if (reg < 32) { @@ -614,7 +614,7 @@ pub const DeclState = struct { }, .stack => |info| { try dbg_info.ensureUnusedCapacity(9); - dbg_info.appendAssumeCapacity(@enumToInt(AbbrevKind.parameter)); + dbg_info.appendAssumeCapacity(@intFromEnum(AbbrevKind.parameter)); // DW.AT.location, DW.FORM.exprloc var expr_len = std.io.countingWriter(std.io.null_writer); if (info.fp_register < 32) { @@ -643,7 +643,7 @@ pub const DeclState = struct { // where each argument is encoded as //