diff --git a/CMakeLists.txt b/CMakeLists.txt index 16c7dd3d0ef3..a229107e3aed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -376,7 +376,7 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfdi.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfsi.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfti.zig" - "${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_to_int.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_from_float.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdidf.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdihf.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdisf.zig" @@ -417,7 +417,7 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/compiler_rt/getf2.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/gexf2.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/int.zig" - "${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_to_float.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_from_int.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/log.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/log10.zig" "${CMAKE_SOURCE_DIR}/lib/compiler_rt/log2.zig" diff --git a/build.zig b/build.zig index 28bc52877221..e04cfd1fc0cc 100644 --- a/build.zig +++ b/build.zig @@ -487,7 +487,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { .cpu_arch = .wasm32, .os_tag = .wasi, }; - target.cpu_features_add.addFeature(@enumToInt(std.Target.wasm.Feature.bulk_memory)); + target.cpu_features_add.addFeature(@intFromEnum(std.Target.wasm.Feature.bulk_memory)); const exe = addCompilerStep(b, .ReleaseSmall, target); diff --git a/doc/langref.html.in b/doc/langref.html.in index 68384c94d79c..7c184c8f3688 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -2763,14 +2763,14 @@ test "comptime pointers" { } } {#code_end#} -

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#}:

{#code_begin|test|test_integer_pointer_conversion#} const expect = @import("std").testing.expect; -test "@ptrToInt and @intToPtr" { - const ptr = @intToPtr(*i32, 0xdeadbee0); - const addr = @ptrToInt(ptr); +test "@intFromPtr and @ptrFromInt" { + const ptr = @ptrFromInt(*i32, 0xdeadbee0); + const addr = @intFromPtr(ptr); try expect(@TypeOf(addr) == usize); try expect(addr == 0xdeadbee0); } @@ -2780,18 +2780,18 @@ test "@ptrToInt and @intToPtr" { {#code_begin|test|test_comptime_pointer_conversion#} const expect = @import("std").testing.expect; -test "comptime @intToPtr" { +test "comptime @ptrFromInt" { comptime { // Zig is able to do this at compile-time, as long as // ptr is never dereferenced. - const ptr = @intToPtr(*i32, 0xdeadbee0); - const addr = @ptrToInt(ptr); + const ptr = @ptrFromInt(*i32, 0xdeadbee0); + const addr = @intFromPtr(ptr); try expect(@TypeOf(addr) == usize); try expect(addr == 0xdeadbee0); } } {#code_end#} - {#see_also|Optional Pointers|@intToPtr|@ptrToInt|C Pointers#} + {#see_also|Optional Pointers|@ptrFromInt|@intFromPtr|C Pointers#} {#header_open|volatile#}

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.

@@ -4385,7 +4385,7 @@ fn withFor(any: AnySlice) usize { // With `inline for` the function gets generated as // a series of `if` statements relying on the optimizer // to convert it to a switch. - if (field.value == @enumToInt(any)) { + if (field.value == @intFromEnum(any)) { return @field(any, field.name).len; } } @@ -4428,7 +4428,7 @@ fn getNum(u: U) u32 { // `u.a` or `u.b` and `tag` is `u`'s comptime-known tag value. inline else => |num, tag| { if (tag == .b) { - return @floatToInt(u32, num); + return @intFromFloat(u32, num); } return num; } @@ -6625,19 +6625,19 @@ test "coercion from homogenous tuple to array" { {#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 // i:uleb128 dbg_info.appendSliceAssumeCapacity(&.{ - @enumToInt(AbbrevKind.parameter), + @intFromEnum(AbbrevKind.parameter), DW.OP.WASM_location, DW.OP.WASM_local, }); @@ -670,7 +670,7 @@ pub const DeclState = struct { const dbg_info = &self.dbg_info; const atom_index = self.di_atom_decls.get(owner_decl).?; const name_with_null = name.ptr[0 .. name.len + 1]; - try dbg_info.append(@enumToInt(AbbrevKind.variable)); + try dbg_info.append(@intFromEnum(AbbrevKind.variable)); const mod = self.mod; const target = mod.getTarget(); const endian = target.cpu.arch.endian(); @@ -679,7 +679,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) { @@ -699,7 +699,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) { @@ -741,7 +741,7 @@ pub const DeclState = struct { const ptr_width = @intCast(u8, @divExact(target.ptrBitWidth(), 8)); try dbg_info.ensureUnusedCapacity(2 + ptr_width); dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc - 1 + ptr_width + @boolToInt(is_ptr), + 1 + ptr_width + @intFromBool(is_ptr), DW.OP.addr, // literal address }); const offset = @intCast(u32, dbg_info.items.len); @@ -1015,9 +1015,9 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) const fn_ret_type = decl.ty.fnReturnType(mod); const fn_ret_has_bits = fn_ret_type.hasRuntimeBits(mod); if (fn_ret_has_bits) { - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.subprogram)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.subprogram)); } else { - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.subprogram_retvoid)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.subprogram_retvoid)); } // These get overwritten after generating the machine code. These values are // "relocations" and have to be in this fixed place so that functions can be @@ -1617,14 +1617,14 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { // These are LEB encoded but since the values are all less than 127 // we can simply append these bytes. const abbrev_buf = [_]u8{ - @enumToInt(AbbrevKind.compile_unit), DW.TAG.compile_unit, DW.CHILDREN.yes, // header - DW.AT.stmt_list, DW.FORM.sec_offset, DW.AT.low_pc, - DW.FORM.addr, DW.AT.high_pc, DW.FORM.addr, - DW.AT.name, DW.FORM.strp, DW.AT.comp_dir, - DW.FORM.strp, DW.AT.producer, DW.FORM.strp, - DW.AT.language, DW.FORM.data2, 0, + @intFromEnum(AbbrevKind.compile_unit), DW.TAG.compile_unit, DW.CHILDREN.yes, // header + DW.AT.stmt_list, DW.FORM.sec_offset, DW.AT.low_pc, + DW.FORM.addr, DW.AT.high_pc, DW.FORM.addr, + DW.AT.name, DW.FORM.strp, DW.AT.comp_dir, + DW.FORM.strp, DW.AT.producer, DW.FORM.strp, + DW.AT.language, DW.FORM.data2, 0, 0, // table sentinel - @enumToInt(AbbrevKind.subprogram), + @intFromEnum(AbbrevKind.subprogram), DW.TAG.subprogram, DW.CHILDREN.yes, // header DW.AT.low_pc, @@ -1635,15 +1635,15 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.ref4, DW.AT.name, DW.FORM.string, - 0, 0, // table sentinel - @enumToInt(AbbrevKind.subprogram_retvoid), + 0, 0, // table sentinel + @intFromEnum(AbbrevKind.subprogram_retvoid), DW.TAG.subprogram, DW.CHILDREN.yes, // header DW.AT.low_pc, DW.FORM.addr, DW.AT.high_pc, DW.FORM.data4, DW.AT.name, DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.base_type), + @intFromEnum(AbbrevKind.base_type), DW.TAG.base_type, DW.CHILDREN.no, // header DW.AT.encoding, @@ -1654,14 +1654,14 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.ptr_type), + @intFromEnum(AbbrevKind.ptr_type), DW.TAG.pointer_type, DW.CHILDREN.no, // header DW.AT.type, DW.FORM.ref4, 0, 0, // table sentinel - @enumToInt(AbbrevKind.struct_type), + @intFromEnum(AbbrevKind.struct_type), DW.TAG.structure_type, DW.CHILDREN.yes, // header DW.AT.byte_size, @@ -1670,7 +1670,7 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.struct_member), + @intFromEnum(AbbrevKind.struct_member), DW.TAG.member, DW.CHILDREN.no, // header DW.AT.name, @@ -1681,7 +1681,7 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.udata, 0, 0, // table sentinel - @enumToInt(AbbrevKind.enum_type), + @intFromEnum(AbbrevKind.enum_type), DW.TAG.enumeration_type, DW.CHILDREN.yes, // header DW.AT.byte_size, @@ -1690,7 +1690,7 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.enum_variant), + @intFromEnum(AbbrevKind.enum_variant), DW.TAG.enumerator, DW.CHILDREN.no, // header DW.AT.name, @@ -1699,7 +1699,7 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.data8, 0, 0, // table sentinel - @enumToInt(AbbrevKind.union_type), + @intFromEnum(AbbrevKind.union_type), DW.TAG.union_type, DW.CHILDREN.yes, // header DW.AT.byte_size, @@ -1708,32 +1708,32 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.pad1), + @intFromEnum(AbbrevKind.pad1), DW.TAG.unspecified_type, DW.CHILDREN.no, // header 0, 0, // table sentinel - @enumToInt(AbbrevKind.parameter), + @intFromEnum(AbbrevKind.parameter), DW.TAG.formal_parameter, DW.CHILDREN.no, // header DW.AT.location, DW.FORM.exprloc, DW.AT.type, DW.FORM.ref4, DW.AT.name, DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.variable), + @intFromEnum(AbbrevKind.variable), DW.TAG.variable, DW.CHILDREN.no, // header DW.AT.location, DW.FORM.exprloc, DW.AT.type, DW.FORM.ref4, DW.AT.name, DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.array_type), + @intFromEnum(AbbrevKind.array_type), DW.TAG.array_type, DW.CHILDREN.yes, // header DW.AT.name, DW.FORM.string, DW.AT.type, DW.FORM.ref4, 0, 0, // table sentinel - @enumToInt(AbbrevKind.array_dim), + @intFromEnum(AbbrevKind.array_dim), DW.TAG.subrange_type, DW.CHILDREN.no, // header DW.AT.type, DW.FORM.ref4, DW.AT.count, DW.FORM.udata, @@ -1838,7 +1838,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, module: *Module, low_pc: u64, high_pc: u const comp_dir_strp = try self.strtab.insert(self.allocator, compile_unit_dir); const producer_strp = try self.strtab.insert(self.allocator, link.producer_string); - di_buf.appendAssumeCapacity(@enumToInt(AbbrevKind.compile_unit)); + di_buf.appendAssumeCapacity(@intFromEnum(AbbrevKind.compile_unit)); if (self.bin_file.tag == .macho) { mem.writeIntLittle(u32, di_buf.addManyAsArrayAssumeCapacity(4), 0); // DW.AT.stmt_list, DW.FORM.sec_offset mem.writeIntLittle(u64, di_buf.addManyAsArrayAssumeCapacity(8), low_pc); @@ -2038,7 +2038,7 @@ fn pwriteDbgInfoNops( const tracy = trace(@src()); defer tracy.end(); - const page_of_nops = [1]u8{@enumToInt(AbbrevKind.pad1)} ** 4096; + const page_of_nops = [1]u8{@intFromEnum(AbbrevKind.pad1)} ** 4096; var vecs: [32]std.os.iovec_const = undefined; var vec_index: usize = 0; { @@ -2110,9 +2110,9 @@ fn writeDbgInfoNopsToArrayList( buffer.items.len, offset + content.len + next_padding_size + 1, )); - @memset(buffer.items[offset - prev_padding_size .. offset], @enumToInt(AbbrevKind.pad1)); + @memset(buffer.items[offset - prev_padding_size .. offset], @intFromEnum(AbbrevKind.pad1)); @memcpy(buffer.items[offset..][0..content.len], content); - @memset(buffer.items[offset + content.len ..][0..next_padding_size], @enumToInt(AbbrevKind.pad1)); + @memset(buffer.items[offset + content.len ..][0..next_padding_size], @intFromEnum(AbbrevKind.pad1)); if (trailing_zero) { buffer.items[offset + content.len + next_padding_size] = 0; @@ -2653,7 +2653,7 @@ fn addDbgInfoErrorSet( const target_endian = target.cpu.arch.endian(); // 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 const abi_size = Type.anyerror.abiSize(mod); try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); @@ -2664,7 +2664,7 @@ fn addDbgInfoErrorSet( // DW.AT.enumerator const no_error = "(no error)"; try dbg_info_buffer.ensureUnusedCapacity(no_error.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(no_error); dbg_info_buffer.appendAssumeCapacity(0); @@ -2677,7 +2677,7 @@ fn addDbgInfoErrorSet( const error_name = mod.intern_pool.stringToSlice(error_name_ip); // DW.AT.enumerator try dbg_info_buffer.ensureUnusedCapacity(error_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(error_name); dbg_info_buffer.appendAssumeCapacity(0); diff --git a/src/link/Elf.zig b/src/link/Elf.zig index a0d63335359c..283bd9ccca4b 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1826,7 +1826,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v for (system_libs, 0..) |link_lib, i| { const lib_as_needed = !system_libs_values[i].needed; - switch ((@as(u2, @boolToInt(lib_as_needed)) << 1) | @boolToInt(as_needed)) { + switch ((@as(u2, @intFromBool(lib_as_needed)) << 1) | @intFromBool(as_needed)) { 0b00, 0b11 => {}, 0b01 => { argv.appendAssumeCapacity("--no-as-needed"); @@ -2048,11 +2048,11 @@ fn writeElfHeader(self: *Elf) !void { .Dynamic => elf.ET.DYN, }, }; - mem.writeInt(u16, hdr_buf[index..][0..2], @enumToInt(elf_type), endian); + mem.writeInt(u16, hdr_buf[index..][0..2], @intFromEnum(elf_type), endian); index += 2; const machine = self.base.options.target.cpu.arch.toElfMachine(); - mem.writeInt(u16, hdr_buf[index..][0..2], @enumToInt(machine), endian); + mem.writeInt(u16, hdr_buf[index..][0..2], @intFromEnum(machine), endian); index += 2; // ELF Version, again @@ -2557,7 +2557,7 @@ fn updateDeclCode(self: *Elf, decl_index: Module.Decl.Index, code: []const u8, s .iov_len = code.len, }}; var remote_vec: [1]std.os.iovec_const = .{.{ - .iov_base = @intToPtr([*]u8, @intCast(usize, local_sym.st_value)), + .iov_base = @ptrFromInt([*]u8, @intCast(usize, local_sym.st_value)), .iov_len = code.len, }}; const rc = std.os.linux.process_vm_writev(pid, &code_vec, &remote_vec, 0); @@ -3051,7 +3051,7 @@ fn writeOffsetTableEntry(self: *Elf, index: @TypeOf(self.got_table).Index) !void .iov_len = buf.len, }}; var remote_vec: [1]std.os.iovec_const = .{.{ - .iov_base = @intToPtr([*]u8, @intCast(usize, vaddr)), + .iov_base = @ptrFromInt([*]u8, @intCast(usize, vaddr)), .iov_len = buf.len, }}; const rc = std.os.linux.process_vm_writev(pid, &local_vec, &remote_vec, 0); diff --git a/src/link/MachO/UnwindInfo.zig b/src/link/MachO/UnwindInfo.zig index 8d2a36be9dfb..3c9a438f92fa 100644 --- a/src/link/MachO/UnwindInfo.zig +++ b/src/link/MachO/UnwindInfo.zig @@ -760,14 +760,14 @@ pub const UnwindEncoding = struct { pub fn isDwarf(enc: macho.compact_unwind_encoding_t, cpu_arch: std.Target.Cpu.Arch) bool { const mode = getMode(enc); return switch (cpu_arch) { - .aarch64 => @intToEnum(macho.UNWIND_ARM64_MODE, mode) == .DWARF, - .x86_64 => @intToEnum(macho.UNWIND_X86_64_MODE, mode) == .DWARF, + .aarch64 => @enumFromInt(macho.UNWIND_ARM64_MODE, mode) == .DWARF, + .x86_64 => @enumFromInt(macho.UNWIND_X86_64_MODE, mode) == .DWARF, else => unreachable, }; } pub fn setMode(enc: *macho.compact_unwind_encoding_t, mode: anytype) void { - enc.* |= @intCast(u32, @enumToInt(mode)) << 24; + enc.* |= @intCast(u32, @intFromEnum(mode)) << 24; } pub fn hasLsda(enc: macho.compact_unwind_encoding_t) bool { @@ -776,7 +776,7 @@ pub const UnwindEncoding = struct { } pub fn setHasLsda(enc: *macho.compact_unwind_encoding_t, has_lsda: bool) void { - const mask = @intCast(u32, @boolToInt(has_lsda)) << 31; + const mask = @intCast(u32, @intFromBool(has_lsda)) << 31; enc.* |= mask; } diff --git a/src/link/MachO/ZldAtom.zig b/src/link/MachO/ZldAtom.zig index baa6340a139f..1252379aa794 100644 --- a/src/link/MachO/ZldAtom.zig +++ b/src/link/MachO/ZldAtom.zig @@ -214,7 +214,7 @@ pub fn parseRelocTarget(zld: *Zld, ctx: struct { mem.readIntLittle(u32, ctx.code[rel_offset..][0..4]); } else blk: { assert(zld.options.target.cpu.arch == .x86_64); - const correction: u3 = switch (@intToEnum(macho.reloc_type_x86_64, ctx.rel.r_type)) { + const correction: u3 = switch (@enumFromInt(macho.reloc_type_x86_64, ctx.rel.r_type)) { .X86_64_RELOC_SIGNED => 0, .X86_64_RELOC_SIGNED_1 => 1, .X86_64_RELOC_SIGNED_2 => 2, @@ -272,7 +272,7 @@ pub fn getRelocTargetAtomIndex(zld: *Zld, target: SymbolWithLoc, is_via_got: boo fn scanAtomRelocsArm64(zld: *Zld, atom_index: AtomIndex, relocs: []align(1) const macho.relocation_info) !void { for (relocs) |rel| { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); switch (rel_type) { .ARM64_RELOC_ADDEND, .ARM64_RELOC_SUBTRACTOR => continue, @@ -321,7 +321,7 @@ fn scanAtomRelocsArm64(zld: *Zld, atom_index: AtomIndex, relocs: []align(1) cons fn scanAtomRelocsX86(zld: *Zld, atom_index: AtomIndex, relocs: []align(1) const macho.relocation_info) !void { for (relocs) |rel| { - const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type); switch (rel_type) { .X86_64_RELOC_SUBTRACTOR => continue, @@ -495,7 +495,7 @@ fn resolveRelocsArm64( var subtractor: ?SymbolWithLoc = null; for (atom_relocs) |rel| { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); switch (rel_type) { .ARM64_RELOC_ADDEND => { @@ -797,7 +797,7 @@ fn resolveRelocsX86( var subtractor: ?SymbolWithLoc = null; for (atom_relocs) |rel| { - const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type); switch (rel_type) { .X86_64_RELOC_SUBTRACTOR => { @@ -1004,14 +1004,14 @@ pub fn getAtomRelocs(zld: *Zld, atom_index: AtomIndex) []const macho.relocation_ pub fn relocRequiresGot(zld: *Zld, rel: macho.relocation_info) bool { switch (zld.options.target.cpu.arch) { - .aarch64 => switch (@intToEnum(macho.reloc_type_arm64, rel.r_type)) { + .aarch64 => switch (@enumFromInt(macho.reloc_type_arm64, rel.r_type)) { .ARM64_RELOC_GOT_LOAD_PAGE21, .ARM64_RELOC_GOT_LOAD_PAGEOFF12, .ARM64_RELOC_POINTER_TO_GOT, => return true, else => return false, }, - .x86_64 => switch (@intToEnum(macho.reloc_type_x86_64, rel.r_type)) { + .x86_64 => switch (@enumFromInt(macho.reloc_type_x86_64, rel.r_type)) { .X86_64_RELOC_GOT, .X86_64_RELOC_GOT_LOAD, => return true, diff --git a/src/link/MachO/dead_strip.zig b/src/link/MachO/dead_strip.zig index ca0d961e2ded..b2c569447d20 100644 --- a/src/link/MachO/dead_strip.zig +++ b/src/link/MachO/dead_strip.zig @@ -148,7 +148,7 @@ fn markLive(zld: *Zld, atom_index: AtomIndex, alive: *AtomTable) void { for (relocs) |rel| { const target = switch (cpu_arch) { - .aarch64 => switch (@intToEnum(macho.reloc_type_arm64, rel.r_type)) { + .aarch64 => switch (@enumFromInt(macho.reloc_type_arm64, rel.r_type)) { .ARM64_RELOC_ADDEND => continue, else => Atom.parseRelocTarget(zld, .{ .object_id = atom.getFile().?, @@ -208,7 +208,7 @@ fn refersLive(zld: *Zld, atom_index: AtomIndex, alive: AtomTable) bool { for (relocs) |rel| { const target = switch (cpu_arch) { - .aarch64 => switch (@intToEnum(macho.reloc_type_arm64, rel.r_type)) { + .aarch64 => switch (@enumFromInt(macho.reloc_type_arm64, rel.r_type)) { .ARM64_RELOC_ADDEND => continue, else => Atom.parseRelocTarget(zld, .{ .object_id = atom.getFile().?, diff --git a/src/link/MachO/eh_frame.zig b/src/link/MachO/eh_frame.zig index ea8d4128c24e..1672e372297c 100644 --- a/src/link/MachO/eh_frame.zig +++ b/src/link/MachO/eh_frame.zig @@ -291,7 +291,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type { for (relocs) |rel| { switch (cpu_arch) { .aarch64 => { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); switch (rel_type) { .ARM64_RELOC_SUBTRACTOR, .ARM64_RELOC_UNSIGNED, @@ -301,7 +301,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type { } }, .x86_64 => { - const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type); switch (rel_type) { .X86_64_RELOC_GOT => {}, else => unreachable, @@ -342,7 +342,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type { switch (cpu_arch) { .aarch64 => { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); switch (rel_type) { .ARM64_RELOC_SUBTRACTOR => { // Address of the __eh_frame in the source object file @@ -363,7 +363,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type { } }, .x86_64 => { - const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type); switch (rel_type) { .X86_64_RELOC_GOT => { const target_addr = try Atom.getRelocTargetAddress(zld, target, true, false); diff --git a/src/link/MachO/thunks.zig b/src/link/MachO/thunks.zig index 7895190005ba..f3289e544b81 100644 --- a/src/link/MachO/thunks.zig +++ b/src/link/MachO/thunks.zig @@ -289,7 +289,7 @@ fn scanRelocs( } inline fn relocNeedsThunk(rel: macho.relocation_info) bool { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); return rel_type == .ARM64_RELOC_BRANCH26; } diff --git a/src/link/MachO/zld.zig b/src/link/MachO/zld.zig index 7902d67d87e5..be283900f519 100644 --- a/src/link/MachO/zld.zig +++ b/src/link/MachO/zld.zig @@ -1819,12 +1819,12 @@ pub const Zld = struct { for (relocs) |rel| { switch (cpu_arch) { .aarch64 => { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); if (rel_type != .ARM64_RELOC_UNSIGNED) continue; if (rel.r_length != 3) continue; }, .x86_64 => { - const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type); if (rel_type != .X86_64_RELOC_UNSIGNED) continue; if (rel.r_length != 3) continue; }, @@ -1958,12 +1958,12 @@ pub const Zld = struct { for (relocs) |rel| { switch (cpu_arch) { .aarch64 => { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); if (rel_type != .ARM64_RELOC_UNSIGNED) continue; if (rel.r_length != 3) continue; }, .x86_64 => { - const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type); if (rel_type != .X86_64_RELOC_UNSIGNED) continue; if (rel.r_length != 3) continue; }, diff --git a/src/link/Plan9.zig b/src/link/Plan9.zig index 6433fb2762d0..b36e16452ec1 100644 --- a/src/link/Plan9.zig +++ b/src/link/Plan9.zig @@ -1192,7 +1192,7 @@ pub fn writeSym(self: *Plan9, w: anytype, sym: aout.Sym) !void { } else { try w.writeIntBig(u64, sym.value); } - try w.writeByte(@enumToInt(sym.type)); + try w.writeByte(@intFromEnum(sym.type)); try w.writeAll(sym.name); try w.writeByte(0); } diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 2d2930be8c9f..1e94e886b9b5 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -196,7 +196,7 @@ pub const Segment = struct { }; pub fn isPassive(segment: Segment) bool { - return segment.flags & @enumToInt(Flag.WASM_DATA_SEGMENT_IS_PASSIVE) != 0; + return segment.flags & @intFromEnum(Flag.WASM_DATA_SEGMENT_IS_PASSIVE) != 0; } /// For a given segment, determines if it needs passive initialization @@ -1094,14 +1094,14 @@ fn validateFeatures( const value = @intCast(u16, object_index) << 1 | @as(u1, 1); switch (feature.prefix) { .used => { - used[@enumToInt(feature.tag)] = value; + used[@intFromEnum(feature.tag)] = value; }, .disallowed => { - disallowed[@enumToInt(feature.tag)] = value; + disallowed[@intFromEnum(feature.tag)] = value; }, .required => { - required[@enumToInt(feature.tag)] = value; - used[@enumToInt(feature.tag)] = value; + required[@intFromEnum(feature.tag)] = value; + used[@intFromEnum(feature.tag)] = value; }, } } @@ -1120,9 +1120,9 @@ fn validateFeatures( const is_enabled = @truncate(u1, used_set) != 0; if (infer) { allowed[used_index] = is_enabled; - emit_features_count.* += @boolToInt(is_enabled); + emit_features_count.* += @intFromBool(is_enabled); } else if (is_enabled and !allowed[used_index]) { - log.err("feature '{}' not allowed, but used by linked object", .{@intToEnum(types.Feature.Tag, used_index)}); + log.err("feature '{}' not allowed, but used by linked object", .{@enumFromInt(types.Feature.Tag, used_index)}); log.err(" defined in '{s}'", .{wasm.objects.items[used_set >> 1].name}); valid_feature_set = false; } @@ -1133,7 +1133,7 @@ fn validateFeatures( } if (wasm.base.options.shared_memory) { - const disallowed_feature = disallowed[@enumToInt(types.Feature.Tag.shared_mem)]; + const disallowed_feature = disallowed[@intFromEnum(types.Feature.Tag.shared_mem)]; if (@truncate(u1, disallowed_feature) != 0) { log.err( "shared-memory is disallowed by '{s}' because it wasn't compiled with 'atomics' and 'bulk-memory' features enabled", @@ -1143,7 +1143,7 @@ fn validateFeatures( } for ([_]types.Feature.Tag{ .atomics, .bulk_memory }) |feature| { - if (!allowed[@enumToInt(feature)]) { + if (!allowed[@intFromEnum(feature)]) { log.err("feature '{}' is not used but is required for shared-memory", .{feature}); } } @@ -1151,7 +1151,7 @@ fn validateFeatures( if (has_tls) { for ([_]types.Feature.Tag{ .atomics, .bulk_memory }) |feature| { - if (!allowed[@enumToInt(feature)]) { + if (!allowed[@intFromEnum(feature)]) { log.err("feature '{}' is not used but is required for thread-local storage", .{feature}); } } @@ -1162,7 +1162,7 @@ fn validateFeatures( for (object.features) |feature| { if (feature.prefix == .disallowed) continue; // already defined in 'disallowed' set. // from here a feature is always used - const disallowed_feature = disallowed[@enumToInt(feature.tag)]; + const disallowed_feature = disallowed[@intFromEnum(feature.tag)]; if (@truncate(u1, disallowed_feature) != 0) { log.err("feature '{}' is disallowed, but used by linked object", .{feature.tag}); log.err(" disallowed by '{s}'", .{wasm.objects.items[disallowed_feature >> 1].name}); @@ -1170,14 +1170,14 @@ fn validateFeatures( valid_feature_set = false; } - object_used_features[@enumToInt(feature.tag)] = true; + object_used_features[@intFromEnum(feature.tag)] = true; } // validate the linked object file has each required feature for (required, 0..) |required_feature, feature_index| { const is_required = @truncate(u1, required_feature) != 0; if (is_required and !object_used_features[feature_index]) { - log.err("feature '{}' is required but not used in linked object", .{@intToEnum(types.Feature.Tag, feature_index)}); + log.err("feature '{}' is required but not used in linked object", .{@enumFromInt(types.Feature.Tag, feature_index)}); log.err(" required by '{s}'", .{wasm.objects.items[required_feature >> 1].name}); log.err(" missing in '{s}'", .{object.name}); valid_feature_set = false; @@ -1324,7 +1324,7 @@ pub fn allocateSymbol(wasm: *Wasm) !u32 { try wasm.symbols.ensureUnusedCapacity(wasm.base.allocator, 1); var symbol: Symbol = .{ .name = undefined, // will be set after updateDecl - .flags = @enumToInt(Symbol.Flag.WASM_SYM_BINDING_LOCAL), + .flags = @intFromEnum(Symbol.Flag.WASM_SYM_BINDING_LOCAL), .tag = undefined, // will be set after updateDecl .index = undefined, // will be set after updateDecl .virtual_address = undefined, // will be set during atom allocation @@ -1560,7 +1560,7 @@ pub fn lowerUnnamedConst(wasm: *Wasm, tv: TypedValue, decl_index: Module.Decl.In atom.alignment = tv.ty.abiAlignment(mod); wasm.symbols.items[atom.sym_index] = .{ .name = try wasm.string_table.put(wasm.base.allocator, name), - .flags = @enumToInt(Symbol.Flag.WASM_SYM_BINDING_LOCAL), + .flags = @intFromEnum(Symbol.Flag.WASM_SYM_BINDING_LOCAL), .tag = .data, .index = undefined, .virtual_address = undefined, @@ -2028,7 +2028,7 @@ fn parseAtom(wasm: *Wasm, atom_index: Atom.Index, kind: Kind) !void { const index = @intCast(u32, wasm.segments.items.len); var flags: u32 = 0; if (wasm.base.options.shared_memory) { - flags |= @enumToInt(Segment.Flag.WASM_DATA_SEGMENT_IS_PASSIVE); + flags |= @intFromEnum(Segment.Flag.WASM_DATA_SEGMENT_IS_PASSIVE); } try wasm.segments.append(wasm.base.allocator, .{ .alignment = atom.alignment, @@ -2868,7 +2868,7 @@ pub fn getMatchingSegment(wasm: *Wasm, object_index: u16, relocatable_index: u32 result.value_ptr.* = index; var flags: u32 = 0; if (wasm.base.options.shared_memory) { - flags |= @enumToInt(Segment.Flag.WASM_DATA_SEGMENT_IS_PASSIVE); + flags |= @intFromEnum(Segment.Flag.WASM_DATA_SEGMENT_IS_PASSIVE); } try wasm.segments.append(wasm.base.allocator, .{ .alignment = 1, @@ -3073,7 +3073,7 @@ pub fn createDebugSectionForIndex(wasm: *Wasm, index: *?u32, name: []const u8) ! .tag = .section, .name = try wasm.string_table.put(wasm.base.allocator, name), .index = 0, - .flags = @enumToInt(Symbol.Flag.WASM_SYM_BINDING_LOCAL), + .flags = @intFromEnum(Symbol.Flag.WASM_SYM_BINDING_LOCAL), }; atom.alignment = 1; // debug sections are always 1-byte-aligned @@ -3544,7 +3544,7 @@ fn writeToFile( header_offset, .import, @intCast(u32, binary_bytes.items.len - header_offset - header_size), - @intCast(u32, wasm.imports.count() + @boolToInt(import_memory)), + @intCast(u32, wasm.imports.count() + @intFromBool(import_memory)), ); section_count += 1; } @@ -3606,7 +3606,7 @@ fn writeToFile( for (wasm.wasm_globals.items) |global| { try binary_writer.writeByte(std.wasm.valtype(global.global_type.valtype)); - try binary_writer.writeByte(@boolToInt(global.global_type.mutable)); + try binary_writer.writeByte(@intFromBool(global.global_type.mutable)); try emitInit(binary_writer, global.init); } @@ -3628,7 +3628,7 @@ fn writeToFile( const name = wasm.string_table.get(exp.name); try leb.writeULEB128(binary_writer, @intCast(u32, name.len)); try binary_writer.writeAll(name); - try leb.writeULEB128(binary_writer, @enumToInt(exp.kind)); + try leb.writeULEB128(binary_writer, @intFromEnum(exp.kind)); try leb.writeULEB128(binary_writer, exp.index); } @@ -3644,7 +3644,7 @@ fn writeToFile( header_offset, .@"export", @intCast(u32, binary_bytes.items.len - header_offset - header_size), - @intCast(u32, wasm.exports.items.len) + @boolToInt(!import_memory), + @intCast(u32, wasm.exports.items.len) + @intFromBool(!import_memory), ); section_count += 1; } @@ -3682,7 +3682,7 @@ fn writeToFile( } // When the shared-memory option is enabled, we *must* emit the 'data count' section. - const data_segments_count = wasm.data_segments.count() - @boolToInt(wasm.data_segments.contains(".bss") and import_memory); + const data_segments_count = wasm.data_segments.count() - @intFromBool(wasm.data_segments.contains(".bss") and import_memory); if (data_segments_count != 0 and wasm.base.options.shared_memory) { const header_offset = try reserveVecSectionHeader(&binary_bytes); try writeVecSectionHeader( @@ -3760,7 +3760,7 @@ fn writeToFile( var atom_index = wasm.atoms.get(segment_index).?; try leb.writeULEB128(binary_writer, segment.flags); - if (segment.flags & @enumToInt(Wasm.Segment.Flag.WASM_DATA_SEGMENT_HAS_MEMINDEX) != 0) { + if (segment.flags & @intFromEnum(Wasm.Segment.Flag.WASM_DATA_SEGMENT_HAS_MEMINDEX) != 0) { try leb.writeULEB128(binary_writer, @as(u32, 0)); // memory is always index 0 as we only have 1 memory entry } // when a segment is passive, it's initialized during runtime. @@ -4030,8 +4030,8 @@ fn emitFeaturesSection(binary_bytes: *std.ArrayList(u8), enabled_features: []con try leb.writeULEB128(writer, features_count); for (enabled_features, 0..) |enabled, feature_index| { if (enabled) { - const feature: types.Feature = .{ .prefix = .used, .tag = @intToEnum(types.Feature.Tag, feature_index) }; - try leb.writeULEB128(writer, @enumToInt(feature.prefix)); + const feature: types.Feature = .{ .prefix = .used, .tag = @enumFromInt(types.Feature.Tag, feature_index) }; + try leb.writeULEB128(writer, @intFromEnum(feature.prefix)); var buf: [100]u8 = undefined; const string = try std.fmt.bufPrint(&buf, "{}", .{feature.tag}); try leb.writeULEB128(writer, @intCast(u32, string.len)); @@ -4121,7 +4121,7 @@ fn emitNameSubsection(wasm: *Wasm, section_id: std.wasm.NameSubsection, names: a } // From now, write to the actual writer - try leb.writeULEB128(writer, @enumToInt(section_id)); + try leb.writeULEB128(writer, @intFromEnum(section_id)); try leb.writeULEB128(writer, @intCast(u32, section_list.items.len)); try writer.writeAll(section_list.items); } @@ -4169,12 +4169,12 @@ fn emitImport(wasm: *Wasm, writer: anytype, import: types.Import) !void { try leb.writeULEB128(writer, @intCast(u32, name.len)); try writer.writeAll(name); - try writer.writeByte(@enumToInt(import.kind)); + try writer.writeByte(@intFromEnum(import.kind)); switch (import.kind) { .function => |type_index| try leb.writeULEB128(writer, type_index), .global => |global_type| { try leb.writeULEB128(writer, std.wasm.valtype(global_type.valtype)); - try writer.writeByte(@boolToInt(global_type.mutable)); + try writer.writeByte(@intFromBool(global_type.mutable)); }, .table => |table| { try leb.writeULEB128(writer, std.wasm.reftype(table.reftype)); @@ -4609,7 +4609,7 @@ fn reserveCustomSectionHeader(bytes: *std.ArrayList(u8)) !u32 { fn writeVecSectionHeader(buffer: []u8, offset: u32, section: std.wasm.Section, size: u32, items: u32) !void { var buf: [1 + 5 + 5]u8 = undefined; - buf[0] = @enumToInt(section); + buf[0] = @intFromEnum(section); leb.writeUnsignedFixed(5, buf[1..6], size); leb.writeUnsignedFixed(5, buf[6..], items); buffer[offset..][0..buf.len].* = buf; @@ -4645,7 +4645,7 @@ fn emitLinkSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: *std.AutoArrayHashMap(SymbolLoc, u32)) !void { const writer = binary_bytes.writer(); - try leb.writeULEB128(writer, @enumToInt(types.SubsectionType.WASM_SYMBOL_TABLE)); + try leb.writeULEB128(writer, @intFromEnum(types.SubsectionType.WASM_SYMBOL_TABLE)); const table_offset = binary_bytes.items.len; var symbol_count: u32 = 0; @@ -4655,7 +4655,7 @@ fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: try symbol_table.putNoClobber(sym_loc, symbol_count); symbol_count += 1; log.debug("Emit symbol: {}", .{symbol}); - try leb.writeULEB128(writer, @enumToInt(symbol.tag)); + try leb.writeULEB128(writer, @intFromEnum(symbol.tag)); try leb.writeULEB128(writer, symbol.flags); const sym_name = if (wasm.export_names.get(sym_loc)) |exp_name| wasm.string_table.get(exp_name) else sym_loc.getName(wasm); @@ -4693,7 +4693,7 @@ fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: fn emitSegmentInfo(wasm: *Wasm, binary_bytes: *std.ArrayList(u8)) !void { const writer = binary_bytes.writer(); - try leb.writeULEB128(writer, @enumToInt(types.SubsectionType.WASM_SEGMENT_INFO)); + try leb.writeULEB128(writer, @intFromEnum(types.SubsectionType.WASM_SEGMENT_INFO)); const segment_offset = binary_bytes.items.len; try leb.writeULEB128(writer, @intCast(u32, wasm.segment_info.count())); @@ -4754,7 +4754,7 @@ fn emitCodeRelocations( count += 1; const sym_loc: SymbolLoc = .{ .file = atom.file, .index = relocation.index }; const symbol_index = symbol_table.get(sym_loc).?; - try leb.writeULEB128(writer, @enumToInt(relocation.relocation_type)); + try leb.writeULEB128(writer, @intFromEnum(relocation.relocation_type)); const offset = atom.offset + relocation.offset + size_offset; try leb.writeULEB128(writer, offset); try leb.writeULEB128(writer, symbol_index); @@ -4804,7 +4804,7 @@ fn emitDataRelocations( .index = relocation.index, }; const symbol_index = symbol_table.get(sym_loc).?; - try leb.writeULEB128(writer, @enumToInt(relocation.relocation_type)); + try leb.writeULEB128(writer, @intFromEnum(relocation.relocation_type)); const offset = atom.offset + relocation.offset + size_offset; try leb.writeULEB128(writer, offset); try leb.writeULEB128(writer, symbol_index); diff --git a/src/link/Wasm/Object.zig b/src/link/Wasm/Object.zig index 33f54dece5cc..db9638193829 100644 --- a/src/link/Wasm/Object.zig +++ b/src/link/Wasm/Object.zig @@ -365,7 +365,7 @@ fn Parser(comptime ReaderType: type) type { const len = try readLeb(u32, parser.reader.reader()); var limited_reader = std.io.limitedReader(parser.reader.reader(), len); const reader = limited_reader.reader(); - switch (@intToEnum(std.wasm.Section, byte)) { + switch (@enumFromInt(std.wasm.Section, byte)) { .custom => { const name_len = try readLeb(u32, reader); const name = try gpa.alloc(u8, name_len); @@ -645,7 +645,7 @@ fn Parser(comptime ReaderType: type) type { /// such as access to the `import` section to find the name of a symbol. fn parseSubsection(parser: *ObjectParser, gpa: Allocator, reader: anytype) !void { const sub_type = try leb.readULEB128(u8, reader); - log.debug("Found subsection: {s}", .{@tagName(@intToEnum(types.SubsectionType, sub_type))}); + log.debug("Found subsection: {s}", .{@tagName(@enumFromInt(types.SubsectionType, sub_type))}); const payload_len = try leb.readULEB128(u32, reader); if (payload_len == 0) return; @@ -655,7 +655,7 @@ fn Parser(comptime ReaderType: type) type { // every subsection contains a 'count' field const count = try leb.readULEB128(u32, limited_reader); - switch (@intToEnum(types.SubsectionType, sub_type)) { + switch (@enumFromInt(types.SubsectionType, sub_type)) { .WASM_SEGMENT_INFO => { const segments = try gpa.alloc(types.Segment, count); errdefer gpa.free(segments); @@ -678,7 +678,7 @@ fn Parser(comptime ReaderType: type) type { // support legacy object files that specified being TLS by the name instead of the TLS flag. if (!segment.isTLS() and (std.mem.startsWith(u8, segment.name, ".tdata") or std.mem.startsWith(u8, segment.name, ".tbss"))) { // set the flag so we can simply check for the flag in the rest of the linker. - segment.flags |= @enumToInt(types.Segment.Flags.WASM_SEG_FLAG_TLS); + segment.flags |= @intFromEnum(types.Segment.Flags.WASM_SEG_FLAG_TLS); } } parser.object.segment_info = segments; @@ -714,7 +714,7 @@ fn Parser(comptime ReaderType: type) type { errdefer gpa.free(symbols); for (symbols) |*symbol| { symbol.* = .{ - .kind = @intToEnum(types.ComdatSym.Type, try leb.readULEB128(u8, reader)), + .kind = @enumFromInt(types.ComdatSym.Type, try leb.readULEB128(u8, reader)), .index = try leb.readULEB128(u32, reader), }; } @@ -758,7 +758,7 @@ fn Parser(comptime ReaderType: type) type { /// requires access to `Object` to find the name of a symbol when it's /// an import and flag `WASM_SYM_EXPLICIT_NAME` is not set. fn parseSymbol(parser: *ObjectParser, gpa: Allocator, reader: anytype) !Symbol { - const tag = @intToEnum(Symbol.Tag, try leb.readULEB128(u8, reader)); + const tag = @enumFromInt(Symbol.Tag, try leb.readULEB128(u8, reader)); const flags = try leb.readULEB128(u32, reader); var symbol: Symbol = .{ .flags = flags, @@ -846,7 +846,7 @@ fn readLeb(comptime T: type, reader: anytype) !T { /// Asserts `T` is an enum fn readEnum(comptime T: type, reader: anytype) !T { switch (@typeInfo(T)) { - .Enum => |enum_type| return @intToEnum(T, try readLeb(enum_type.tag_type, reader)), + .Enum => |enum_type| return @enumFromInt(T, try readLeb(enum_type.tag_type, reader)), else => @compileError("T must be an enum. Instead was given type " ++ @typeName(T)), } } @@ -867,7 +867,7 @@ fn readLimits(reader: anytype) !std.wasm.Limits { fn readInit(reader: anytype) !std.wasm.InitExpression { const opcode = try reader.readByte(); - const init_expr: std.wasm.InitExpression = switch (@intToEnum(std.wasm.Opcode, opcode)) { + const init_expr: std.wasm.InitExpression = switch (@enumFromInt(std.wasm.Opcode, opcode)) { .i32_const => .{ .i32_const = try readLeb(i32, reader) }, .global_get => .{ .global_get = try readLeb(u32, reader) }, else => @panic("TODO: initexpression for other opcodes"), diff --git a/src/link/Wasm/Symbol.zig b/src/link/Wasm/Symbol.zig index 8a1c4c5fdbb1..8dc10771ae7f 100644 --- a/src/link/Wasm/Symbol.zig +++ b/src/link/Wasm/Symbol.zig @@ -91,32 +91,32 @@ pub fn requiresImport(symbol: Symbol) bool { } pub fn isTLS(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_TLS) != 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_TLS) != 0; } pub fn hasFlag(symbol: Symbol, flag: Flag) bool { - return symbol.flags & @enumToInt(flag) != 0; + return symbol.flags & @intFromEnum(flag) != 0; } pub fn setFlag(symbol: *Symbol, flag: Flag) void { - symbol.flags |= @enumToInt(flag); + symbol.flags |= @intFromEnum(flag); } pub fn isUndefined(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_UNDEFINED) != 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_UNDEFINED) != 0; } pub fn setUndefined(symbol: *Symbol, is_undefined: bool) void { if (is_undefined) { symbol.setFlag(.WASM_SYM_UNDEFINED); } else { - symbol.flags &= ~@enumToInt(Flag.WASM_SYM_UNDEFINED); + symbol.flags &= ~@intFromEnum(Flag.WASM_SYM_UNDEFINED); } } pub fn setGlobal(symbol: *Symbol, is_global: bool) void { if (is_global) { - symbol.flags &= ~@enumToInt(Flag.WASM_SYM_BINDING_LOCAL); + symbol.flags &= ~@intFromEnum(Flag.WASM_SYM_BINDING_LOCAL); } else { symbol.setFlag(.WASM_SYM_BINDING_LOCAL); } @@ -127,23 +127,23 @@ pub fn isDefined(symbol: Symbol) bool { } pub fn isVisible(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_VISIBILITY_HIDDEN) == 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_VISIBILITY_HIDDEN) == 0; } pub fn isLocal(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_BINDING_LOCAL) != 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_BINDING_LOCAL) != 0; } pub fn isGlobal(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_BINDING_LOCAL) == 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_BINDING_LOCAL) == 0; } pub fn isHidden(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_VISIBILITY_HIDDEN) != 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_VISIBILITY_HIDDEN) != 0; } pub fn isNoStrip(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_NO_STRIP) != 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_NO_STRIP) != 0; } pub fn isExported(symbol: Symbol, is_dynamic: bool) bool { @@ -153,7 +153,7 @@ pub fn isExported(symbol: Symbol, is_dynamic: bool) bool { } pub fn isWeak(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_BINDING_WEAK) != 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_BINDING_WEAK) != 0; } /// Formats the symbol into human-readable text diff --git a/src/link/Wasm/types.zig b/src/link/Wasm/types.zig index 801c25e9d975..9bf54f25c3d1 100644 --- a/src/link/Wasm/types.zig +++ b/src/link/Wasm/types.zig @@ -118,7 +118,7 @@ pub const Segment = struct { flags: u32, pub fn isTLS(segment: Segment) bool { - return segment.flags & @enumToInt(Flags.WASM_SEG_FLAG_TLS) != 0; + return segment.flags & @intFromEnum(Flags.WASM_SEG_FLAG_TLS) != 0; } /// Returns the name as how it will be output into the final object @@ -205,7 +205,7 @@ pub const Feature = struct { /// From a given cpu feature, returns its linker feature pub fn fromCpuFeature(feature: std.Target.wasm.Feature) Tag { - return @intToEnum(Tag, @enumToInt(feature)); + return @enumFromInt(Tag, @intFromEnum(feature)); } pub fn format(tag: Tag, comptime fmt: []const u8, opt: std.fmt.FormatOptions, writer: anytype) !void { diff --git a/src/main.zig b/src/main.zig index 2f56cad133d5..e7cd48a3dafd 100644 --- a/src/main.zig +++ b/src/main.zig @@ -140,8 +140,8 @@ pub fn log( // Hide debug messages unless: // * logging enabled with `-Dlog`. // * the --debug-log arg for the scope has been provided - if (@enumToInt(level) > @enumToInt(std.options.log_level) or - @enumToInt(level) > @enumToInt(std.log.Level.info)) + if (@intFromEnum(level) > @intFromEnum(std.options.log_level) or + @intFromEnum(level) > @intFromEnum(std.log.Level.info)) { if (!build_options.enable_logging) return; @@ -2424,8 +2424,8 @@ fn buildOutputType( fatal("shared memory is not allowed in object files", .{}); } - if (!target_info.target.cpu.features.isEnabled(@enumToInt(std.Target.wasm.Feature.atomics)) or - !target_info.target.cpu.features.isEnabled(@enumToInt(std.Target.wasm.Feature.bulk_memory))) + if (!target_info.target.cpu.features.isEnabled(@intFromEnum(std.Target.wasm.Feature.atomics)) or + !target_info.target.cpu.features.isEnabled(@intFromEnum(std.Target.wasm.Feature.bulk_memory))) { fatal("'atomics' and 'bulk-memory' features must be enabled to use shared memory", .{}); } @@ -2640,7 +2640,7 @@ fn buildOutputType( if (output_mode == .Obj and (object_format == .coff or object_format == .macho)) { const total_obj_count = c_source_files.items.len + - @boolToInt(root_src_file != null) + + @intFromBool(root_src_file != null) + link_objects.items.len; if (total_obj_count > 1) { fatal("{s} does not support linking multiple objects into one", .{@tagName(object_format)}); @@ -3466,7 +3466,7 @@ fn serve( } }, else => { - fatal("unrecognized message from client: 0x{x}", .{@enumToInt(hdr.tag)}); + fatal("unrecognized message from client: 0x{x}", .{@intFromEnum(hdr.tag)}); }, } } @@ -4706,7 +4706,7 @@ pub fn cmdFmt(gpa: Allocator, arena: Allocator, args: []const []const u8) !void defer gpa.free(formatted); if (check_flag) { - const code: u8 = @boolToInt(mem.eql(u8, formatted, source_code)); + const code: u8 = @intFromBool(mem.eql(u8, formatted, source_code)); process.exit(code); } @@ -5080,7 +5080,7 @@ pub fn lldMain( unreachable; } }; - return @boolToInt(!ok); + return @intFromBool(!ok); } const ArgIteratorResponseFile = process.ArgIteratorGeneral(.{ .comments = true, .single_quotes = true }); diff --git a/src/objcopy.zig b/src/objcopy.zig index 014208cc0d48..ce7b03903a71 100644 --- a/src/objcopy.zig +++ b/src/objcopy.zig @@ -539,7 +539,7 @@ const HexWriter = struct { const parts = addressParts(self.address); sum +%= parts[0]; sum +%= parts[1]; - sum +%= @enumToInt(self.payload); + sum +%= @intFromEnum(self.payload); for (payload_bytes) |byte| { sum +%= byte; } @@ -557,7 +557,7 @@ const HexWriter = struct { const line = try std.fmt.bufPrint(&outbuf, ":{0X:0>2}{1X:0>4}{2X:0>2}{3s}{4X:0>2}" ++ linesep, .{ @intCast(u8, payload_bytes.len), self.address, - @enumToInt(self.payload), + @intFromEnum(self.payload), std.fmt.fmtSliceHexUpper(payload_bytes), self.checksum(), }); diff --git a/src/print_air.zig b/src/print_air.zig index ddb63ac17c88..d73ec308917f 100644 --- a/src/print_air.zig +++ b/src/print_air.zig @@ -956,7 +956,7 @@ const Writer = struct { operand: Air.Inst.Ref, dies: bool, ) @TypeOf(s).Error!void { - const i = @enumToInt(operand); + const i = @intFromEnum(operand); if (i < InternPool.static_len) { return s.print("@{}", .{operand}); diff --git a/src/print_zir.zig b/src/print_zir.zig index b3359e2e31d1..029157818957 100644 --- a/src/print_zir.zig +++ b/src/print_zir.zig @@ -36,7 +36,7 @@ pub fn renderAsTextToFile( try stream.print("%{d} ", .{main_struct_inst}); try writer.writeInstToStream(stream, main_struct_inst); try stream.writeAll("\n"); - const imports_index = scope_file.zir.extra[@enumToInt(Zir.ExtraIndex.imports)]; + const imports_index = scope_file.zir.extra[@intFromEnum(Zir.ExtraIndex.imports)]; if (imports_index != 0) { try stream.writeAll("Imports:\n"); @@ -559,7 +559,7 @@ const Writer = struct { fn writeElemTypeIndex(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { const inst_data = self.code.instructions.items(.data)[inst].bin; try self.writeInstRef(stream, inst_data.lhs); - try stream.print(", {d})", .{@enumToInt(inst_data.rhs)}); + try stream.print(", {d})", .{@intFromEnum(inst_data.rhs)}); } fn writeUnNode( @@ -632,25 +632,25 @@ const Writer = struct { var extra_index = extra.end; if (inst_data.flags.has_sentinel) { try stream.writeAll(", "); - try self.writeInstRef(stream, @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index])); + try self.writeInstRef(stream, @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index])); extra_index += 1; } if (inst_data.flags.has_align) { try stream.writeAll(", align("); - try self.writeInstRef(stream, @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index])); + try self.writeInstRef(stream, @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index])); extra_index += 1; if (inst_data.flags.has_bit_range) { - const bit_start = extra_index + @boolToInt(inst_data.flags.has_addrspace); + const bit_start = extra_index + @intFromBool(inst_data.flags.has_addrspace); try stream.writeAll(":"); - try self.writeInstRef(stream, @intToEnum(Zir.Inst.Ref, self.code.extra[bit_start])); + try self.writeInstRef(stream, @enumFromInt(Zir.Inst.Ref, self.code.extra[bit_start])); try stream.writeAll(":"); - try self.writeInstRef(stream, @intToEnum(Zir.Inst.Ref, self.code.extra[bit_start + 1])); + try self.writeInstRef(stream, @enumFromInt(Zir.Inst.Ref, self.code.extra[bit_start + 1])); } try stream.writeAll(")"); } if (inst_data.flags.has_addrspace) { try stream.writeAll(", addrspace("); - try self.writeInstRef(stream, @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index])); + try self.writeInstRef(stream, @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index])); try stream.writeAll(")"); } try stream.writeAll(") "); @@ -1084,7 +1084,7 @@ const Writer = struct { try self.writeFlag(stream, "volatile, ", is_volatile); if (tmpl_is_expr) { - try self.writeInstRef(stream, @intToEnum(Zir.Inst.Ref, extra.data.asm_source)); + try self.writeInstRef(stream, @enumFromInt(Zir.Inst.Ref, extra.data.asm_source)); try stream.writeAll(", "); } else { const asm_source = self.code.nullTerminatedString(extra.data.asm_source); @@ -1179,7 +1179,7 @@ const Writer = struct { if (extra.data.flags.ensure_result_used) { try stream.writeAll("nodiscard "); } - try stream.print(".{s}, ", .{@tagName(@intToEnum(std.builtin.CallModifier, extra.data.flags.packed_modifier))}); + try stream.print(".{s}, ", .{@tagName(@enumFromInt(std.builtin.CallModifier, extra.data.flags.packed_modifier))}); switch (kind) { .direct => try self.writeInstRef(stream, extra.data.callee), .field => { @@ -1287,7 +1287,7 @@ const Writer = struct { extra_index += 1; try stream.writeAll("Packed("); if (backing_int_body_len == 0) { - const backing_int_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const backing_int_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; try self.writeInstRef(stream, backing_int_ref); } else { @@ -1369,7 +1369,7 @@ const Writer = struct { if (has_type_body) { fields[field_i].type_len = self.code.extra[extra_index]; } else { - fields[field_i].type = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + fields[field_i].type = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); } extra_index += 1; @@ -1454,7 +1454,7 @@ const Writer = struct { } else null; const tag_type_ref = if (small.has_tag_type) blk: { - const tag_type_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const tag_type_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; break :blk tag_type_ref; } else .none; @@ -1552,14 +1552,14 @@ const Writer = struct { try stream.print("{}", .{std.zig.fmtId(field_name)}); if (has_type) { - const field_type = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const field_type = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; try stream.writeAll(": "); try self.writeInstRef(stream, field_type); } if (has_align) { - const align_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const align_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; try stream.writeAll(" align("); @@ -1567,7 +1567,7 @@ const Writer = struct { try stream.writeAll(")"); } if (has_value) { - const default_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const default_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; try stream.writeAll(" = "); @@ -1618,17 +1618,17 @@ const Writer = struct { extra_index += 1; const align_inst: Zir.Inst.Ref = if (!has_align) .none else inst: { - const inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; break :inst inst; }; const section_inst: Zir.Inst.Ref = if (!has_section_or_addrspace) .none else inst: { - const inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; break :inst inst; }; const addrspace_inst: Zir.Inst.Ref = if (!has_section_or_addrspace) .none else inst: { - const inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; break :inst inst; }; @@ -1712,7 +1712,7 @@ const Writer = struct { } else null; const tag_type_ref = if (small.has_tag_type) blk: { - const tag_type_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const tag_type_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; break :blk tag_type_ref; } else .none; @@ -1797,7 +1797,7 @@ const Writer = struct { try stream.print("{}", .{std.zig.fmtId(field_name)}); if (has_tag_value) { - const tag_value_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const tag_value_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; try stream.writeAll(" = "); @@ -1940,7 +1940,7 @@ const Writer = struct { const scalar_cases_len = extra.data.bits.scalar_cases_len; var scalar_i: usize = 0; while (scalar_i < scalar_cases_len) : (scalar_i += 1) { - const item_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const item_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; const info = @bitCast(Zir.Inst.SwitchBlock.ProngInfo, self.code.extra[extra_index]); extra_index += 1; @@ -1988,9 +1988,9 @@ const Writer = struct { var range_i: usize = 0; while (range_i < ranges_len) : (range_i += 1) { - const item_first = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const item_first = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; - const item_last = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const item_last = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; if (range_i != 0 or items.len != 0) { @@ -2091,7 +2091,7 @@ const Writer = struct { ret_ty_ref = .void_type; }, 1 => { - ret_ty_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + ret_ty_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; }, else => { @@ -2162,7 +2162,7 @@ const Writer = struct { align_body = self.code.extra[extra_index..][0..body_len]; extra_index += align_body.len; } else if (extra.data.bits.has_align_ref) { - align_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + align_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; } if (extra.data.bits.has_addrspace_body) { @@ -2171,7 +2171,7 @@ const Writer = struct { addrspace_body = self.code.extra[extra_index..][0..body_len]; extra_index += addrspace_body.len; } else if (extra.data.bits.has_addrspace_ref) { - addrspace_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + addrspace_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; } if (extra.data.bits.has_section_body) { @@ -2180,7 +2180,7 @@ const Writer = struct { section_body = self.code.extra[extra_index..][0..body_len]; extra_index += section_body.len; } else if (extra.data.bits.has_section_ref) { - section_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + section_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; } if (extra.data.bits.has_cc_body) { @@ -2189,7 +2189,7 @@ const Writer = struct { cc_body = self.code.extra[extra_index..][0..body_len]; extra_index += cc_body.len; } else if (extra.data.bits.has_cc_ref) { - cc_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + cc_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; } if (extra.data.bits.has_ret_ty_body) { @@ -2198,7 +2198,7 @@ const Writer = struct { ret_ty_body = self.code.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(Zir.Inst.Ref, self.code.extra[extra_index]); + ret_ty_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; } @@ -2251,12 +2251,12 @@ const Writer = struct { try stream.print(", lib_name=\"{}\"", .{std.zig.fmtEscapes(lib_name)}); } const align_inst: Zir.Inst.Ref = if (!small.has_align) .none else blk: { - const align_inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const align_inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; break :blk align_inst; }; const init_inst: Zir.Inst.Ref = if (!small.has_init) .none else blk: { - const init_inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const init_inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; break :blk init_inst; }; @@ -2274,12 +2274,12 @@ const Writer = struct { var extra_index: usize = extra.end; const type_inst: Zir.Inst.Ref = if (!small.has_type) .none else blk: { - const type_inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const type_inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; break :blk type_inst; }; const align_inst: Zir.Inst.Ref = if (!small.has_align) .none else blk: { - const align_inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + const align_inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]); extra_index += 1; break :blk align_inst; }; @@ -2480,8 +2480,8 @@ const Writer = struct { } fn writeInstRef(self: *Writer, stream: anytype, ref: Zir.Inst.Ref) !void { - const i = @enumToInt(ref); - if (i < InternPool.static_len) return stream.print("@{}", .{@intToEnum(InternPool.Index, i)}); + const i = @intFromEnum(ref); + if (i < InternPool.static_len) return stream.print("@{}", .{@enumFromInt(InternPool.Index, i)}); return self.writeInstIndex(stream, i - InternPool.static_len); } diff --git a/src/register_manager.zig b/src/register_manager.zig index 841545bf0956..f9e2daeab195 100644 --- a/src/register_manager.zig +++ b/src/register_manager.zig @@ -366,7 +366,7 @@ const MockRegister1 = enum(u2) { r3, pub fn id(reg: MockRegister1) u2 { - return @enumToInt(reg); + return @intFromEnum(reg); } const allocatable_registers = [_]MockRegister1{ .r2, .r3 }; @@ -394,7 +394,7 @@ const MockRegister2 = enum(u2) { r3, pub fn id(reg: MockRegister2) u2 { - return @enumToInt(reg); + return @intFromEnum(reg); } const allocatable_registers = [_]MockRegister2{ .r0, .r1, .r2, .r3 }; @@ -426,14 +426,14 @@ const MockRegister3 = enum(u3) { x3, pub fn id(reg: MockRegister3) u3 { - return switch (@enumToInt(reg)) { - 0...3 => @as(u3, @truncate(u2, @enumToInt(reg))), - 4...7 => @enumToInt(reg), + return switch (@intFromEnum(reg)) { + 0...3 => @as(u3, @truncate(u2, @intFromEnum(reg))), + 4...7 => @intFromEnum(reg), }; } pub fn enc(reg: MockRegister3) u2 { - return @truncate(u2, @enumToInt(reg)); + return @truncate(u2, @intFromEnum(reg)); } const gp_regs = [_]MockRegister3{ .r0, .r1, .r2, .r3 }; diff --git a/src/translate_c.zig b/src/translate_c.zig index 37717950626d..8d5804c5e56d 100644 --- a/src/translate_c.zig +++ b/src/translate_c.zig @@ -110,7 +110,7 @@ const Scope = struct { if (self.base.parent.?.id == .do_loop) { // We reserve 1 extra statement if the parent is a do_loop. This is in case of // do while, we want to put `if (cond) break;` at the end. - const alloc_len = self.statements.items.len + @boolToInt(self.base.parent.?.id == .do_loop); + const alloc_len = self.statements.items.len + @intFromBool(self.base.parent.?.id == .do_loop); var stmts = try c.arena.alloc(Node, alloc_len); stmts.len = self.statements.items.len; @memcpy(stmts[0..self.statements.items.len], self.statements.items); @@ -507,14 +507,14 @@ fn declVisitorNamesOnly(c: *Context, decl: *const clang.Decl) Error!void { const enum_decl = enum_ty.getDecl(); // check if this decl is unnamed if (@ptrCast(*const clang.NamedDecl, enum_decl).getName_bytes_begin()[0] != 0) return; - break @ptrToInt(enum_decl.getCanonicalDecl()); + break @intFromPtr(enum_decl.getCanonicalDecl()); }, .Record => { const record_ty = @ptrCast(*const clang.RecordType, child_ty); const record_decl = record_ty.getDecl(); // check if this decl is unnamed if (@ptrCast(*const clang.NamedDecl, record_decl).getName_bytes_begin()[0] != 0) return; - break @ptrToInt(record_decl.getCanonicalDecl()); + break @intFromPtr(record_decl.getCanonicalDecl()); }, .Elaborated => { const elaborated_ty = @ptrCast(*const clang.ElaboratedType, child_ty); @@ -543,7 +543,7 @@ fn declVisitorNamesOnly(c: *Context, decl: *const clang.Decl) Error!void { } result.value_ptr.* = decl_name; // Put this typedef in the decl_table to avoid redefinitions. - try c.decl_table.putNoClobber(c.gpa, @ptrToInt(typedef_decl.getCanonicalDecl()), decl_name); + try c.decl_table.putNoClobber(c.gpa, @intFromPtr(typedef_decl.getCanonicalDecl()), decl_name); try c.typedefs.put(c.gpa, decl_name, {}); } } @@ -913,7 +913,7 @@ const builtin_typedef_map = std.ComptimeStringMap([]const u8, .{ }); fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNameDecl) Error!void { - if (c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl()))) |_| + if (c.decl_table.get(@intFromPtr(typedef_decl.getCanonicalDecl()))) |_| return; // Avoid processing this decl twice const toplevel = scope.id == .root; const bs: *Scope.Block = if (!toplevel) try scope.findBlockScope(c) else undefined; @@ -922,10 +922,10 @@ fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNa try c.typedefs.put(c.gpa, name, {}); if (builtin_typedef_map.get(name)) |builtin| { - return c.decl_table.putNoClobber(c.gpa, @ptrToInt(typedef_decl.getCanonicalDecl()), builtin); + return c.decl_table.putNoClobber(c.gpa, @intFromPtr(typedef_decl.getCanonicalDecl()), builtin); } if (!toplevel) name = try bs.makeMangledName(c, name); - try c.decl_table.putNoClobber(c.gpa, @ptrToInt(typedef_decl.getCanonicalDecl()), name); + try c.decl_table.putNoClobber(c.gpa, @intFromPtr(typedef_decl.getCanonicalDecl()), name); const child_qt = typedef_decl.getUnderlyingType(); const typedef_loc = typedef_decl.getLocation(); @@ -938,7 +938,7 @@ fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNa const payload = try c.arena.create(ast.Payload.SimpleVarDecl); payload.* = .{ - .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@boolToInt(toplevel)] }, + .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@intFromBool(toplevel)] }, .data = .{ .name = name, .init = init_node, @@ -1063,7 +1063,7 @@ fn hasFlexibleArrayField(c: *Context, record_def: *const clang.RecordDecl) bool } fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordDecl) Error!void { - if (c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl()))) |_| + if (c.decl_table.get(@intFromPtr(record_decl.getCanonicalDecl()))) |_| return; // Avoid processing this decl twice const record_loc = record_decl.getLocation(); const toplevel = scope.id == .root; @@ -1079,13 +1079,13 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD } else if (record_decl.isStruct()) { container_kind_name = "struct"; } else { - try c.decl_table.putNoClobber(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), bare_name); + try c.decl_table.putNoClobber(c.gpa, @intFromPtr(record_decl.getCanonicalDecl()), bare_name); return failDecl(c, record_loc, bare_name, "record {s} is not a struct or union", .{bare_name}); } var is_unnamed = false; var name = bare_name; - if (c.unnamed_typedefs.get(@ptrToInt(record_decl.getCanonicalDecl()))) |typedef_name| { + if (c.unnamed_typedefs.get(@intFromPtr(record_decl.getCanonicalDecl()))) |typedef_name| { bare_name = typedef_name; name = typedef_name; } else { @@ -1098,12 +1098,12 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD name = try std.fmt.allocPrint(c.arena, "{s}_{s}", .{ container_kind_name, bare_name }); } if (!toplevel) name = try bs.makeMangledName(c, name); - try c.decl_table.putNoClobber(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), name); + try c.decl_table.putNoClobber(c.gpa, @intFromPtr(record_decl.getCanonicalDecl()), name); const is_pub = toplevel and !is_unnamed; const init_node = blk: { const record_def = record_decl.getDefinition() orelse { - try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); + try c.opaque_demotes.put(c.gpa, @intFromPtr(record_decl.getCanonicalDecl()), {}); break :blk Tag.opaque_literal.init(); }; @@ -1126,7 +1126,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD const field_qt = field_decl.getType(); if (field_decl.isBitField()) { - try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); + try c.opaque_demotes.put(c.gpa, @intFromPtr(record_decl.getCanonicalDecl()), {}); try warn(c, scope, field_loc, "{s} demoted to opaque type - has bitfield", .{container_kind_name}); break :blk Tag.opaque_literal.init(); } @@ -1142,7 +1142,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD if (isFlexibleArrayFieldDecl(c, field_decl)) { const flexible_array_fn = buildFlexibleArrayFn(c, scope, layout, field_name, field_decl) catch |err| switch (err) { error.UnsupportedType => { - try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); + try c.opaque_demotes.put(c.gpa, @intFromPtr(record_decl.getCanonicalDecl()), {}); try warn(c, scope, record_loc, "{s} demoted to opaque type - unable to translate type of flexible array field {s}", .{ container_kind_name, field_name }); break :blk Tag.opaque_literal.init(); }, @@ -1153,7 +1153,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD } const field_type = transQualType(c, scope, field_qt, field_loc) catch |err| switch (err) { error.UnsupportedType => { - try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); + try c.opaque_demotes.put(c.gpa, @intFromPtr(record_decl.getCanonicalDecl()), {}); try warn(c, scope, record_loc, "{s} demoted to opaque type - unable to translate type of field {s}", .{ container_kind_name, field_name }); break :blk Tag.opaque_literal.init(); }, @@ -1166,7 +1166,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD ClangAlignment.forField(c, field_decl, record_def).zigAlignment(); if (is_anon) { - try c.decl_table.putNoClobber(c.gpa, @ptrToInt(field_decl.getCanonicalDecl()), field_name); + try c.decl_table.putNoClobber(c.gpa, @intFromPtr(field_decl.getCanonicalDecl()), field_name); } try fields.append(.{ @@ -1178,7 +1178,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD const record_payload = try c.arena.create(ast.Payload.Record); record_payload.* = .{ - .base = .{ .tag = ([2]Tag{ .@"struct", .@"union" })[@boolToInt(is_union)] }, + .base = .{ .tag = ([2]Tag{ .@"struct", .@"union" })[@intFromBool(is_union)] }, .data = .{ .layout = .@"extern", .fields = try c.arena.dupe(ast.Payload.Record.Field, fields.items), @@ -1191,7 +1191,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD const payload = try c.arena.create(ast.Payload.SimpleVarDecl); payload.* = .{ - .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@boolToInt(is_pub)] }, + .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@intFromBool(is_pub)] }, .data = .{ .name = name, .init = init_node, @@ -1211,7 +1211,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD } fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) Error!void { - if (c.decl_table.get(@ptrToInt(enum_decl.getCanonicalDecl()))) |_| + if (c.decl_table.get(@intFromPtr(enum_decl.getCanonicalDecl()))) |_| return; // Avoid processing this decl twice const enum_loc = enum_decl.getLocation(); const toplevel = scope.id == .root; @@ -1220,7 +1220,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E var is_unnamed = false; var bare_name: []const u8 = try c.str(@ptrCast(*const clang.NamedDecl, enum_decl).getName_bytes_begin()); var name = bare_name; - if (c.unnamed_typedefs.get(@ptrToInt(enum_decl.getCanonicalDecl()))) |typedef_name| { + if (c.unnamed_typedefs.get(@intFromPtr(enum_decl.getCanonicalDecl()))) |typedef_name| { bare_name = typedef_name; name = typedef_name; } else { @@ -1231,7 +1231,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E name = try std.fmt.allocPrint(c.arena, "enum_{s}", .{bare_name}); } if (!toplevel) name = try bs.makeMangledName(c, name); - try c.decl_table.putNoClobber(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), name); + try c.decl_table.putNoClobber(c.gpa, @intFromPtr(enum_decl.getCanonicalDecl()), name); const enum_type_node = if (enum_decl.getDefinition()) |enum_def| blk: { var it = enum_def.enumerator_begin(); @@ -1280,14 +1280,14 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E else try Tag.type.create(c.arena, "c_int"); } else blk: { - try c.opaque_demotes.put(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), {}); + try c.opaque_demotes.put(c.gpa, @intFromPtr(enum_decl.getCanonicalDecl()), {}); break :blk Tag.opaque_literal.init(); }; const is_pub = toplevel and !is_unnamed; const payload = try c.arena.create(ast.Payload.SimpleVarDecl); payload.* = .{ - .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@boolToInt(is_pub)] }, + .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@intFromBool(is_pub)] }, .data = .{ .init = enum_type_node, .name = name, @@ -1536,7 +1536,7 @@ fn transSimpleOffsetOfExpr(c: *Context, expr: *const clang.OffsetOfExpr) TransEr if (component.getKind() == .Field) { const field_decl = component.getField(); if (field_decl.getParent()) |record_decl| { - if (c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl()))) |type_name| { + if (c.decl_table.get(@intFromPtr(record_decl.getCanonicalDecl()))) |type_name| { const type_node = try Tag.type.create(c.arena, type_name); var raw_field_name = try c.str(@ptrCast(*const clang.NamedDecl, field_decl).getName_bytes_begin()); @@ -1768,7 +1768,7 @@ fn transBinaryOperator( const infixOpNode = try transCreateNodeInfixOp(c, op_id, lhs, rhs, result_used); if (isPointerDiffExpr) { - // @divExact(@bitCast(, @ptrToInt(lhs) -% @ptrToInt(rhs)), @sizeOf()) + // @divExact(@bitCast(, @intFromPtr(lhs) -% @intFromPtr(rhs)), @sizeOf()) const ptrdiff_type = try transQualTypeIntWidthOf(c, qt, true); // C standard requires that pointer subtraction operands are of the same type, @@ -2138,7 +2138,7 @@ fn transBoolExpr( return fail(c, error.UnsupportedTranslation, expr.getBeginLoc(), "invalid integer literal", .{}); } const is_zero = signum == 0; - return Node{ .tag_if_small_enough = @enumToInt(([2]Tag{ .true_literal, .false_literal })[@boolToInt(is_zero)]) }; + return Node{ .tag_if_small_enough = @intFromEnum(([2]Tag{ .true_literal, .false_literal })[@intFromBool(is_zero)]) }; } var res = try transExpr(c, scope, expr, used); @@ -2599,7 +2599,7 @@ fn literalFitsInType(c: *Context, expr: *const clang.Expr, qt: clang.QualType) b var width = qualTypeIntBitWidth(c, qt) catch 8; if (width == 0) width = 8; // Byte is the smallest type. const is_signed = cIsSignedInteger(qt); - const width_max_int = (@as(u64, 1) << math.lossyCast(u6, width - @boolToInt(is_signed))) - 1; + const width_max_int = (@as(u64, 1) << math.lossyCast(u6, width - @intFromBool(is_signed))) - 1; switch (@ptrCast(*const clang.Stmt, expr).getStmtClass()) { .CharacterLiteralClass => { @@ -2664,7 +2664,7 @@ fn transInitListExprRecord( // .field_name = expr var raw_name = try c.str(@ptrCast(*const clang.NamedDecl, field_decl).getName_bytes_begin()); if (field_decl.isAnonymousStructOrUnion()) { - const name = c.decl_table.get(@ptrToInt(field_decl.getCanonicalDecl())).?; + const name = c.decl_table.get(@intFromPtr(field_decl.getCanonicalDecl())).?; raw_name = try c.arena.dupe(u8, name); } @@ -3442,7 +3442,7 @@ fn transMemberExpr(c: *Context, scope: *Scope, stmt: *const clang.MemberExpr, re if (decl_kind == .Field) { const field_decl = @ptrCast(*const clang.FieldDecl, member_decl); if (field_decl.isAnonymousStructOrUnion()) { - const name = c.decl_table.get(@ptrToInt(field_decl.getCanonicalDecl())).?; + const name = c.decl_table.get(@intFromPtr(field_decl.getCanonicalDecl())).?; break :blk try c.arena.dupe(u8, name); } } @@ -4026,7 +4026,7 @@ fn transCreateCompoundAssign( return block_scope.complete(c); } -// Casting away const or volatile requires us to use @intToPtr +// Casting away const or volatile requires us to use @ptrFromInt fn removeCVQualifiers(c: *Context, dst_type_node: Node, expr: Node) Error!Node { const int_from_ptr = try Tag.int_from_ptr.create(c.arena, expr); return Tag.ptr_from_int.create(c.arena, .{ .lhs = dst_type_node, .rhs = int_from_ptr }); @@ -4835,7 +4835,7 @@ fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clan if (builtin_typedef_map.get(decl_name)) |builtin| return Tag.type.create(c.arena, builtin); } try transTypeDef(c, trans_scope, typedef_decl); - const name = c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl())).?; + const name = c.decl_table.get(@intFromPtr(typedef_decl.getCanonicalDecl())).?; return Tag.identifier.create(c.arena, name); }, .Record => { @@ -4848,7 +4848,7 @@ fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clan if (c.global_names.get(decl_name)) |_| trans_scope = &c.global_scope.base; } try transRecordDecl(c, trans_scope, record_decl); - const name = c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl())).?; + const name = c.decl_table.get(@intFromPtr(record_decl.getCanonicalDecl())).?; return Tag.identifier.create(c.arena, name); }, .Enum => { @@ -4861,7 +4861,7 @@ fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clan if (c.global_names.get(decl_name)) |_| trans_scope = &c.global_scope.base; } try transEnumDecl(c, trans_scope, enum_decl); - const name = c.decl_table.get(@ptrToInt(enum_decl.getCanonicalDecl())).?; + const name = c.decl_table.get(@intFromPtr(enum_decl.getCanonicalDecl())).?; return Tag.identifier.create(c.arena, name); }, .Elaborated => { @@ -4928,7 +4928,7 @@ fn qualTypeWasDemotedToOpaque(c: *Context, qt: clang.QualType) bool { const record_ty = @ptrCast(*const clang.RecordType, ty); const record_decl = record_ty.getDecl(); - const canonical = @ptrToInt(record_decl.getCanonicalDecl()); + const canonical = @intFromPtr(record_decl.getCanonicalDecl()); if (c.opaque_demotes.contains(canonical)) return true; // check all childern for opaque types. @@ -4944,7 +4944,7 @@ fn qualTypeWasDemotedToOpaque(c: *Context, qt: clang.QualType) bool { const enum_ty = @ptrCast(*const clang.EnumType, ty); const enum_decl = enum_ty.getDecl(); - const canonical = @ptrToInt(enum_decl.getCanonicalDecl()); + const canonical = @intFromPtr(enum_decl.getCanonicalDecl()); return c.opaque_demotes.contains(canonical); }, .Elaborated => { @@ -5533,7 +5533,7 @@ fn getMacroText(unit: *const clang.ASTUnit, c: *const Context, macro: *const cla const begin_c = c.source_manager.getCharacterData(begin_loc); const end_c = c.source_manager.getCharacterData(end_loc); - const slice_len = @ptrToInt(end_c) - @ptrToInt(begin_c); + const slice_len = @intFromPtr(end_c) - @intFromPtr(begin_c); return begin_c[0..slice_len]; } @@ -6087,7 +6087,7 @@ fn parseCPrimaryExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { return node; } -fn macroBoolToInt(c: *Context, node: Node) !Node { +fn macroIntFromBool(c: *Context, node: Node) !Node { if (!isBoolRes(node)) { return node; } @@ -6141,8 +6141,8 @@ fn parseCAndExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { fn parseCBitOrExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { var node = try parseCBitXorExpr(c, m, scope); while (m.next().? == .Pipe) { - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCBitXorExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCBitXorExpr(c, m, scope)); node = try Tag.bit_or.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); } m.i -= 1; @@ -6152,8 +6152,8 @@ fn parseCBitOrExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { fn parseCBitXorExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { var node = try parseCBitAndExpr(c, m, scope); while (m.next().? == .Caret) { - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCBitAndExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCBitAndExpr(c, m, scope)); node = try Tag.bit_xor.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); } m.i -= 1; @@ -6163,8 +6163,8 @@ fn parseCBitXorExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { fn parseCBitAndExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { var node = try parseCEqExpr(c, m, scope); while (m.next().? == .Ampersand) { - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCEqExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCEqExpr(c, m, scope)); node = try Tag.bit_and.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); } m.i -= 1; @@ -6177,14 +6177,14 @@ fn parseCEqExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { switch (m.peek().?) { .BangEqual => { _ = m.next(); - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCRelExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCRelExpr(c, m, scope)); node = try Tag.not_equal.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); }, .EqualEqual => { _ = m.next(); - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCRelExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCRelExpr(c, m, scope)); node = try Tag.equal.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); }, else => return node, @@ -6198,26 +6198,26 @@ fn parseCRelExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { switch (m.peek().?) { .AngleBracketRight => { _ = m.next(); - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCShiftExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCShiftExpr(c, m, scope)); node = try Tag.greater_than.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); }, .AngleBracketRightEqual => { _ = m.next(); - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCShiftExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCShiftExpr(c, m, scope)); node = try Tag.greater_than_equal.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); }, .AngleBracketLeft => { _ = m.next(); - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCShiftExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCShiftExpr(c, m, scope)); node = try Tag.less_than.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); }, .AngleBracketLeftEqual => { _ = m.next(); - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCShiftExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCShiftExpr(c, m, scope)); node = try Tag.less_than_equal.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); }, else => return node, @@ -6231,14 +6231,14 @@ fn parseCShiftExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { switch (m.peek().?) { .AngleBracketAngleBracketLeft => { _ = m.next(); - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCAddSubExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCAddSubExpr(c, m, scope)); node = try Tag.shl.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); }, .AngleBracketAngleBracketRight => { _ = m.next(); - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCAddSubExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCAddSubExpr(c, m, scope)); node = try Tag.shr.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); }, else => return node, @@ -6252,14 +6252,14 @@ fn parseCAddSubExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { switch (m.peek().?) { .Plus => { _ = m.next(); - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCMulExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCMulExpr(c, m, scope)); node = try Tag.add.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); }, .Minus => { _ = m.next(); - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCMulExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCMulExpr(c, m, scope)); node = try Tag.sub.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); }, else => return node, @@ -6272,18 +6272,18 @@ fn parseCMulExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { while (true) { switch (m.next().?) { .Asterisk => { - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCCastExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCCastExpr(c, m, scope)); node = try Tag.mul.create(c.arena, .{ .lhs = lhs, .rhs = rhs }); }, .Slash => { - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCCastExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCCastExpr(c, m, scope)); node = try Tag.macro_arithmetic.create(c.arena, .{ .op = .div, .lhs = lhs, .rhs = rhs }); }, .Percent => { - const lhs = try macroBoolToInt(c, node); - const rhs = try macroBoolToInt(c, try parseCCastExpr(c, m, scope)); + const lhs = try macroIntFromBool(c, node); + const rhs = try macroIntFromBool(c, try parseCCastExpr(c, m, scope)); node = try Tag.macro_arithmetic.create(c.arena, .{ .op = .rem, .lhs = lhs, .rhs = rhs }); }, else => { @@ -6512,7 +6512,7 @@ fn parseCPostfixExpr(c: *Context, m: *MacroCtx, scope: *Scope, type_name: ?Node) node = try Tag.field_access.create(c.arena, .{ .lhs = deref, .field_name = m.slice() }); }, .LBracket => { - const index_val = try macroBoolToInt(c, try parseCExpr(c, m, scope)); + const index_val = try macroIntFromBool(c, try parseCExpr(c, m, scope)); const index = try Tag.int_cast.create(c.arena, .{ .lhs = try Tag.type.create(c.arena, "usize"), .rhs = index_val, @@ -6610,12 +6610,12 @@ fn parseCUnaryExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { return Tag.not.create(c.arena, operand); }, .Minus => { - const operand = try macroBoolToInt(c, try parseCCastExpr(c, m, scope)); + const operand = try macroIntFromBool(c, try parseCCastExpr(c, m, scope)); return Tag.negate.create(c.arena, operand); }, .Plus => return try parseCCastExpr(c, m, scope), .Tilde => { - const operand = try macroBoolToInt(c, try parseCCastExpr(c, m, scope)); + const operand = try macroIntFromBool(c, try parseCCastExpr(c, m, scope)); return Tag.bit_not.create(c.arena, operand); }, .Asterisk => { diff --git a/src/translate_c/ast.zig b/src/translate_c/ast.zig index 942844ec4e48..c8ccfa497f52 100644 --- a/src/translate_c/ast.zig +++ b/src/translate_c/ast.zig @@ -228,7 +228,7 @@ pub const Node = extern union { array_filler, pub const last_no_payload_tag = Tag.@"break"; - pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1; + pub const no_payload_count = @intFromEnum(last_no_payload_tag) + 1; pub fn Type(comptime t: Tag) type { return switch (t) { @@ -381,8 +381,8 @@ pub const Node = extern union { } pub fn init(comptime t: Tag) Node { - comptime std.debug.assert(@enumToInt(t) < Tag.no_payload_count); - return .{ .tag_if_small_enough = @enumToInt(t) }; + comptime std.debug.assert(@intFromEnum(t) < Tag.no_payload_count); + return .{ .tag_if_small_enough = @intFromEnum(t) }; } pub fn create(comptime t: Tag, ally: Allocator, data: Data(t)) error{OutOfMemory}!Node { @@ -401,7 +401,7 @@ pub const Node = extern union { pub fn tag(self: Node) Tag { if (self.tag_if_small_enough < Tag.no_payload_count) { - return @intToEnum(Tag, @intCast(std.meta.Tag(Tag), self.tag_if_small_enough)); + return @enumFromInt(Tag, @intCast(std.meta.Tag(Tag), self.tag_if_small_enough)); } else { return self.ptr_otherwise.tag; } @@ -418,7 +418,7 @@ pub const Node = extern union { } pub fn initPayload(payload: *Payload) Node { - std.debug.assert(@enumToInt(payload.tag) >= Tag.no_payload_count); + std.debug.assert(@intFromEnum(payload.tag) >= Tag.no_payload_count); return .{ .ptr_otherwise = payload }; } diff --git a/src/type.zig b/src/type.zig index 1c3435dafd9b..ac5305b3f41d 100644 --- a/src/type.zig +++ b/src/type.zig @@ -130,7 +130,7 @@ pub const Type = struct { // The InternPool data structure hashes based on Key to make interned objects // unique. An Index can be treated simply as u32 value for the // purpose of Type/Value hashing and equality. - return std.hash.uint32(@enumToInt(ty.toIntern())); + return std.hash.uint32(@intFromEnum(ty.toIntern())); } pub fn format(ty: Type, comptime unused_fmt_string: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { @@ -227,7 +227,7 @@ pub const Type = struct { if (info.vector_index == .runtime) { try writer.writeAll(":?"); } else if (info.vector_index != .none) { - try writer.print(":{d}", .{@enumToInt(info.vector_index)}); + try writer.print(":{d}", .{@intFromEnum(info.vector_index)}); } try writer.writeAll(") "); } @@ -1227,7 +1227,7 @@ pub const Type = struct { if (have_tag) { return abiAlignmentAdvanced(union_obj.tag_ty, mod, strat); } else { - return AbiAlignmentAdvanced{ .scalar = @boolToInt(union_obj.layout == .Extern) }; + return AbiAlignmentAdvanced{ .scalar = @intFromBool(union_obj.layout == .Extern) }; } } @@ -1307,7 +1307,7 @@ pub const Type = struct { .anyframe_type => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, .array_type => |array_type| { - const len = array_type.len + @boolToInt(array_type.sentinel != .none); + const len = array_type.len + @intFromBool(array_type.sentinel != .none); switch (try array_type.child.toType().abiSizeAdvanced(mod, strat)) { .scalar => |elem_size| return .{ .scalar = len * elem_size }, .val => switch (strat) { @@ -1630,7 +1630,7 @@ pub const Type = struct { .anyframe_type => return target.ptrBitWidth(), .array_type => |array_type| { - const len = array_type.len + @boolToInt(array_type.sentinel != .none); + const len = array_type.len + @intFromBool(array_type.sentinel != .none); if (len == 0) return 0; const elem_ty = array_type.child.toType(); const elem_size = @max(elem_ty.abiAlignment(mod), elem_ty.abiSize(mod)); @@ -2182,7 +2182,7 @@ pub const Type = struct { } pub fn arrayLenIncludingSentinel(ty: Type, mod: *const Module) u64 { - return ty.arrayLen(mod) + @boolToInt(ty.sentinel(mod) != null); + return ty.arrayLen(mod) + @intFromBool(ty.sentinel(mod) != null); } pub fn vectorLen(ty: Type, mod: *const Module) u32 { @@ -2477,7 +2477,7 @@ pub const Type = struct { 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(); @@ -3540,7 +3540,7 @@ pub const Type = struct { if (max == 0) return 0; const base = std.math.log2(max); const upper = (@as(u64, 1) << @intCast(u6, base)) - 1; - return @intCast(u16, base + @boolToInt(upper < max)); + return @intCast(u16, base + @intFromBool(upper < max)); } /// This is only used for comptime asserts. Bump this number when you make a change diff --git a/src/value.zig b/src/value.zig index 8590aa8872df..f348ce2edbff 100644 --- a/src/value.zig +++ b/src/value.zig @@ -112,7 +112,7 @@ pub const Value = struct { return self.castTag(T.base_tag); } inline for (@typeInfo(Tag).Enum.fields) |field| { - const t = @intToEnum(Tag, field.value); + const t = @enumFromInt(Tag, field.value); if (self.legacy.ptr_otherwise.tag == t) { if (T == t.Type()) { return @fieldParentPtr(T, "base", self.legacy.ptr_otherwise); @@ -503,7 +503,7 @@ pub const Value = struct { return self.toIntern().toType(); } - pub fn enumToInt(val: Value, ty: Type, mod: *Module) Allocator.Error!Value { + pub fn intFromEnum(val: Value, ty: Type, mod: *Module) Allocator.Error!Value { const ip = &mod.intern_pool; return switch (ip.indexToKey(ip.typeOf(val.toIntern()))) { // Assume it is already an integer and return it directly. @@ -703,7 +703,7 @@ pub const Value = struct { switch (ty.zigTypeTag(mod)) { .Void => {}, .Bool => { - buffer[0] = @boolToInt(val.toBool()); + buffer[0] = @intFromBool(val.toBool()); }, .Int, .Enum => { const int_info = ty.intInfo(mod); @@ -836,7 +836,7 @@ pub const Value = struct { const bits = ty.intInfo(mod).bits; if (bits == 0) return; - switch (mod.intern_pool.indexToKey((try val.enumToInt(ty, mod)).toIntern()).int.storage) { + switch (mod.intern_pool.indexToKey((try val.intFromEnum(ty, mod)).toIntern()).int.storage) { inline .u64, .i64 => |int| std.mem.writeVarPackedInt(buffer, bit_offset, bits, int, endian), .big_int => |bigint| bigint.writePackedTwosComplement(buffer, bit_offset, bits, endian), else => unreachable, @@ -1170,10 +1170,10 @@ pub const Value = struct { if (T == f80) { @panic("TODO we can't lower this properly on non-x86 llvm backend yet"); } - return @intToFloat(T, x); + return @floatFromInt(T, x); }, - .lazy_align => |ty| @intToFloat(T, ty.toType().abiAlignment(mod)), - .lazy_size => |ty| @intToFloat(T, ty.toType().abiSize(mod)), + .lazy_align => |ty| @floatFromInt(T, ty.toType().abiAlignment(mod)), + .lazy_size => |ty| @floatFromInt(T, ty.toType().abiSize(mod)), }, .float => |float| switch (float.storage) { inline else => |x| @floatCast(T, x), @@ -1191,7 +1191,7 @@ pub const Value = struct { var i: usize = limbs.len; while (i != 0) { i -= 1; - const limb: f128 = @intToFloat(f128, limbs[i]); + const limb: f128 = @floatFromInt(f128, limbs[i]); result = @mulAdd(f128, base, result, limb); } if (positive) { @@ -1593,8 +1593,8 @@ pub const Value = struct { return a_type.eql(b_type, mod); }, .Enum => { - const a_val = try a.enumToInt(ty, mod); - const b_val = try b.enumToInt(ty, mod); + const a_val = try a.intFromEnum(ty, mod); + const b_val = try b.intFromEnum(ty, mod); const int_ty = ty.intTagType(mod); return eqlAdvanced(a_val, int_ty, b_val, int_ty, mod, opt_sema); }, @@ -2124,30 +2124,30 @@ pub const Value = struct { }; } - pub fn intToFloat(val: Value, arena: Allocator, int_ty: Type, float_ty: Type, mod: *Module) !Value { - return intToFloatAdvanced(val, arena, int_ty, float_ty, mod, null) catch |err| switch (err) { + pub fn floatFromInt(val: Value, arena: Allocator, int_ty: Type, float_ty: Type, mod: *Module) !Value { + return floatFromIntAdvanced(val, arena, int_ty, float_ty, mod, null) catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, else => unreachable, }; } - pub fn intToFloatAdvanced(val: Value, arena: Allocator, int_ty: Type, float_ty: Type, mod: *Module, opt_sema: ?*Sema) !Value { + pub fn floatFromIntAdvanced(val: Value, arena: Allocator, int_ty: Type, float_ty: Type, mod: *Module, opt_sema: ?*Sema) !Value { if (int_ty.zigTypeTag(mod) == .Vector) { const result_data = try arena.alloc(InternPool.Index, int_ty.vectorLen(mod)); const scalar_ty = float_ty.scalarType(mod); for (result_data, 0..) |*scalar, i| { const elem_val = try val.elemValue(mod, i); - scalar.* = try (try intToFloatScalar(elem_val, scalar_ty, mod, opt_sema)).intern(scalar_ty, mod); + scalar.* = try (try floatFromIntScalar(elem_val, scalar_ty, mod, opt_sema)).intern(scalar_ty, mod); } return (try mod.intern(.{ .aggregate = .{ .ty = float_ty.toIntern(), .storage = .{ .elems = result_data }, } })).toValue(); } - return intToFloatScalar(val, float_ty, mod, opt_sema); + return floatFromIntScalar(val, float_ty, mod, opt_sema); } - pub fn intToFloatScalar(val: Value, float_ty: Type, mod: *Module, opt_sema: ?*Sema) !Value { + pub fn floatFromIntScalar(val: Value, float_ty: Type, mod: *Module, opt_sema: ?*Sema) !Value { return switch (mod.intern_pool.indexToKey(val.toIntern())) { .undef => (try mod.intern(.{ .undef = float_ty.toIntern() })).toValue(), .int => |int| switch (int.storage) { @@ -2155,30 +2155,30 @@ pub const Value = struct { const float = bigIntToFloat(big_int.limbs, big_int.positive); return mod.floatValue(float_ty, float); }, - inline .u64, .i64 => |x| intToFloatInner(x, float_ty, mod), + inline .u64, .i64 => |x| floatFromIntInner(x, float_ty, mod), .lazy_align => |ty| if (opt_sema) |sema| { - return intToFloatInner((try ty.toType().abiAlignmentAdvanced(mod, .{ .sema = sema })).scalar, float_ty, mod); + return floatFromIntInner((try ty.toType().abiAlignmentAdvanced(mod, .{ .sema = sema })).scalar, float_ty, mod); } else { - return intToFloatInner(ty.toType().abiAlignment(mod), float_ty, mod); + return floatFromIntInner(ty.toType().abiAlignment(mod), float_ty, mod); }, .lazy_size => |ty| if (opt_sema) |sema| { - return intToFloatInner((try ty.toType().abiSizeAdvanced(mod, .{ .sema = sema })).scalar, float_ty, mod); + return floatFromIntInner((try ty.toType().abiSizeAdvanced(mod, .{ .sema = sema })).scalar, float_ty, mod); } else { - return intToFloatInner(ty.toType().abiSize(mod), float_ty, mod); + return floatFromIntInner(ty.toType().abiSize(mod), float_ty, mod); }, }, else => unreachable, }; } - fn intToFloatInner(x: anytype, dest_ty: Type, mod: *Module) !Value { + fn floatFromIntInner(x: anytype, dest_ty: Type, mod: *Module) !Value { const target = mod.getTarget(); const storage: InternPool.Key.Float.Storage = switch (dest_ty.floatBits(target)) { - 16 => .{ .f16 = @intToFloat(f16, x) }, - 32 => .{ .f32 = @intToFloat(f32, x) }, - 64 => .{ .f64 = @intToFloat(f64, x) }, - 80 => .{ .f80 = @intToFloat(f80, x) }, - 128 => .{ .f128 = @intToFloat(f128, x) }, + 16 => .{ .f16 = @floatFromInt(f16, x) }, + 32 => .{ .f32 = @floatFromInt(f32, x) }, + 64 => .{ .f64 = @floatFromInt(f64, x) }, + 80 => .{ .f80 = @floatFromInt(f80, x) }, + 128 => .{ .f128 = @floatFromInt(f128, x) }, else => unreachable, }; return (try mod.intern(.{ .float = .{ @@ -2193,7 +2193,7 @@ pub const Value = struct { } const w_value = @fabs(scalar); - return @divFloor(@floatToInt(std.math.big.Limb, std.math.log2(w_value)), @typeInfo(std.math.big.Limb).Int.bits) + 1; + return @divFloor(@intFromFloat(std.math.big.Limb, std.math.log2(w_value)), @typeInfo(std.math.big.Limb).Int.bits) + 1; } pub const OverflowArithmeticResult = struct { @@ -2364,7 +2364,7 @@ pub const Value = struct { } return OverflowArithmeticResult{ - .overflow_bit = try mod.intValue(Type.u1, @boolToInt(overflowed)), + .overflow_bit = try mod.intValue(Type.u1, @intFromBool(overflowed)), .wrapped_result = try mod.intValue_big(ty, result_bigint.toConst()), }; } @@ -3177,7 +3177,7 @@ pub const Value = struct { result_bigint.truncate(result_bigint.toConst(), info.signedness, info.bits); } return OverflowArithmeticResult{ - .overflow_bit = try mod.intValue(Type.u1, @boolToInt(overflowed)), + .overflow_bit = try mod.intValue(Type.u1, @intFromBool(overflowed)), .wrapped_result = try mod.intValue_big(ty, result_bigint.toConst()), }; } diff --git a/test/behavior.zig b/test/behavior.zig index 017b5b48249a..6e9435c49ef4 100644 --- a/test/behavior.zig +++ b/test/behavior.zig @@ -174,7 +174,7 @@ test { _ = @import("behavior/inline_switch.zig"); _ = @import("behavior/int128.zig"); _ = @import("behavior/int_comparison_elision.zig"); - _ = @import("behavior/inttoptr.zig"); + _ = @import("behavior/ptrfromint.zig"); _ = @import("behavior/ir_block_deps.zig"); _ = @import("behavior/lower_strlit_to_vector.zig"); _ = @import("behavior/math.zig"); diff --git a/test/behavior/align.zig b/test/behavior/align.zig index 4ce408e65d0c..d3e4d8125014 100644 --- a/test/behavior/align.zig +++ b/test/behavior/align.zig @@ -24,7 +24,7 @@ test "slicing array of length 1 can not assume runtime index is always zero" { const slice = @as(*align(4) [1]u8, &foo)[runtime_index..]; try expect(@TypeOf(slice) == []u8); try expect(slice.len == 0); - try expect(@truncate(u2, @ptrToInt(slice.ptr) - 1) == 0); + try expect(@truncate(u2, @intFromPtr(slice.ptr) - 1) == 0); } test "default alignment allows unspecified in type syntax" { @@ -299,11 +299,11 @@ test "page aligned array on stack" { var number1: u8 align(16) = 42; var number2: u8 align(16) = 43; - try expect(@ptrToInt(&array[0]) & 0xFFF == 0); + try expect(@intFromPtr(&array[0]) & 0xFFF == 0); try expect(array[3] == 4); - try expect(@truncate(u4, @ptrToInt(&number1)) == 0); - try expect(@truncate(u4, @ptrToInt(&number2)) == 0); + try expect(@truncate(u4, @intFromPtr(&number1)) == 0); + try expect(@truncate(u4, @intFromPtr(&number2)) == 0); try expect(number1 == 42); try expect(number2 == 43); } @@ -518,7 +518,7 @@ test "struct field explicit alignment" { node.massive_byte = 100; try expect(node.massive_byte == 100); try comptime expect(@TypeOf(&node.massive_byte) == *align(64) u8); - try expect(@ptrToInt(&node.massive_byte) % 64 == 0); + try expect(@intFromPtr(&node.massive_byte) % 64 == 0); } test "align(@alignOf(T)) T does not force resolution of T" { @@ -561,7 +561,7 @@ test "align(N) on functions" { if (native_arch == .wasm32 or native_arch == .wasm64) return error.SkipZigTest; if (native_arch == .thumb) return error.SkipZigTest; - try expect((@ptrToInt(&overaligned_fn) & (0x1000 - 1)) == 0); + try expect((@intFromPtr(&overaligned_fn) & (0x1000 - 1)) == 0); } fn overaligned_fn() align(0x1000) i32 { return 42; @@ -578,7 +578,7 @@ test "comptime alloc alignment" { _ = bytes1; comptime var bytes2 align(256) = [_]u8{0}; - var bytes2_addr = @ptrToInt(&bytes2); + var bytes2_addr = @intFromPtr(&bytes2); try expect(bytes2_addr & 0xff == 0); } diff --git a/test/behavior/array.zig b/test/behavior/array.zig index cd4c81508a54..9ef4a55b398c 100644 --- a/test/behavior/array.zig +++ b/test/behavior/array.zig @@ -176,8 +176,8 @@ test "array with sentinels" { var arr: [3:0x55]u8 = undefined; // Make sure the sentinel pointer is pointing after the last element. if (!is_ct) { - const sentinel_ptr = @ptrToInt(&arr[3]); - const last_elem_ptr = @ptrToInt(&arr[2]); + const sentinel_ptr = @intFromPtr(&arr[3]); + const last_elem_ptr = @intFromPtr(&arr[2]); try expect((sentinel_ptr - last_elem_ptr) == 1); } // Make sure the sentinel is writeable. diff --git a/test/behavior/async_fn.zig b/test/behavior/async_fn.zig index 54609ac298da..dcbe78b0910c 100644 --- a/test/behavior/async_fn.zig +++ b/test/behavior/async_fn.zig @@ -829,7 +829,7 @@ test "alignment of local variables in async functions" { var y: u8 = 123; _ = y; var x: u8 align(128) = 1; - try expect(@ptrToInt(&x) % 128 == 0); + try expect(@intFromPtr(&x) % 128 == 0); } }; try S.doTheTest(); @@ -1184,7 +1184,7 @@ test "using @TypeOf on a generic function call" { global_frame = @frame(); } const F = @TypeOf(async amain(x - 1)); - const frame = @intToPtr(*F, @ptrToInt(&buf)); + const frame = @ptrFromInt(*F, @intFromPtr(&buf)); return await @asyncCall(frame, {}, amain, .{x - 1}); } }; @@ -1212,7 +1212,7 @@ test "recursive call of await @asyncCall with struct return type" { global_frame = @frame(); } const F = @TypeOf(async amain(x - 1)); - const frame = @intToPtr(*F, @ptrToInt(&buf)); + const frame = @ptrFromInt(*F, @intFromPtr(&buf)); return await @asyncCall(frame, {}, amain, .{x - 1}); } diff --git a/test/behavior/bool.zig b/test/behavior/bool.zig index a2636ecf42b6..50a098c11190 100644 --- a/test/behavior/bool.zig +++ b/test/behavior/bool.zig @@ -13,22 +13,22 @@ test "cast bool to int" { const t = true; const f = false; - try expectEqual(@as(u32, 1), @boolToInt(t)); - try expectEqual(@as(u32, 0), @boolToInt(f)); - try expectEqual(-1, @bitCast(i1, @boolToInt(t))); - try expectEqual(0, @bitCast(i1, @boolToInt(f))); - try expectEqual(u1, @TypeOf(@boolToInt(t))); - try expectEqual(u1, @TypeOf(@boolToInt(f))); - try nonConstCastBoolToInt(t, f); + try expectEqual(@as(u32, 1), @intFromBool(t)); + try expectEqual(@as(u32, 0), @intFromBool(f)); + try expectEqual(-1, @bitCast(i1, @intFromBool(t))); + try expectEqual(0, @bitCast(i1, @intFromBool(f))); + try expectEqual(u1, @TypeOf(@intFromBool(t))); + try expectEqual(u1, @TypeOf(@intFromBool(f))); + try nonConstCastIntFromBool(t, f); } -fn nonConstCastBoolToInt(t: bool, f: bool) !void { - try expectEqual(@as(u32, 1), @boolToInt(t)); - try expectEqual(@as(u32, 0), @boolToInt(f)); - try expectEqual(@as(i1, -1), @bitCast(i1, @boolToInt(t))); - try expectEqual(@as(i1, 0), @bitCast(i1, @boolToInt(f))); - try expectEqual(u1, @TypeOf(@boolToInt(t))); - try expectEqual(u1, @TypeOf(@boolToInt(f))); +fn nonConstCastIntFromBool(t: bool, f: bool) !void { + try expectEqual(@as(u32, 1), @intFromBool(t)); + try expectEqual(@as(u32, 0), @intFromBool(f)); + try expectEqual(@as(i1, -1), @bitCast(i1, @intFromBool(t))); + try expectEqual(@as(i1, 0), @bitCast(i1, @intFromBool(f))); + try expectEqual(u1, @TypeOf(@intFromBool(t))); + try expectEqual(u1, @TypeOf(@intFromBool(f))); } test "bool cmp" { diff --git a/test/behavior/bugs/10138.zig b/test/behavior/bugs/10138.zig index 1ea2954777aa..1c8ff7cf7c4c 100644 --- a/test/behavior/bugs/10138.zig +++ b/test/behavior/bugs/10138.zig @@ -17,7 +17,7 @@ fn open() usize { } fn write(fd: usize, a: [*]const u8, len: usize) usize { - return syscall4(.WRITE, fd, @ptrToInt(a), len); + return syscall4(.WRITE, fd, @intFromPtr(a), len); } fn syscall4(n: enum { WRITE }, a: usize, b: usize, c: usize) usize { diff --git a/test/behavior/bugs/12142.zig b/test/behavior/bugs/12142.zig index 4b9a4d9fa1c8..ca66b1f8f5b9 100644 --- a/test/behavior/bugs/12142.zig +++ b/test/behavior/bugs/12142.zig @@ -15,7 +15,7 @@ const Letter = enum(u8) { }; fn letter(e: Letter) u8 { - return @enumToInt(e); + return @intFromEnum(e); } test { diff --git a/test/behavior/bugs/12450.zig b/test/behavior/bugs/12450.zig index 368f055d05e1..db91529051a5 100644 --- a/test/behavior/bugs/12450.zig +++ b/test/behavior/bugs/12450.zig @@ -18,6 +18,6 @@ test { var f1: *align(16) Foo = @alignCast(16, @ptrCast(*align(1) Foo, &buffer[0])); try expect(@typeInfo(@TypeOf(f1)).Pointer.alignment == 16); - try expect(@ptrToInt(f1) == @ptrToInt(&f1.a)); + try expect(@intFromPtr(f1) == @intFromPtr(&f1.a)); try expect(@typeInfo(@TypeOf(&f1.a)).Pointer.alignment == 16); } diff --git a/test/behavior/bugs/12680_other_file.zig b/test/behavior/bugs/12680_other_file.zig index 32b9dc1b2774..5bcc9e1c1606 100644 --- a/test/behavior/bugs/12680_other_file.zig +++ b/test/behavior/bugs/12680_other_file.zig @@ -1,6 +1,6 @@ // export this function twice pub export fn testFunc() callconv(.C) usize { - return @ptrToInt(&testFunc); + return @intFromPtr(&testFunc); } comptime { diff --git a/test/behavior/bugs/12723.zig b/test/behavior/bugs/12723.zig index 81e276218a1f..abecf890256e 100644 --- a/test/behavior/bugs/12723.zig +++ b/test/behavior/bugs/12723.zig @@ -3,6 +3,6 @@ const expect = @import("std").testing.expect; test "Non-exhaustive enum backed by comptime_int" { const E = enum(comptime_int) { a, b, c, _ }; comptime var e: E = .a; - e = @intToEnum(E, 378089457309184723749); - try expect(@enumToInt(e) == 378089457309184723749); + e = @enumFromInt(E, 378089457309184723749); + try expect(@intFromEnum(e) == 378089457309184723749); } diff --git a/test/behavior/bugs/1741.zig b/test/behavior/bugs/1741.zig index 6c36ba5e157e..b4cf5577de35 100644 --- a/test/behavior/bugs/1741.zig +++ b/test/behavior/bugs/1741.zig @@ -8,5 +8,5 @@ test "fixed" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; const x: f32 align(128) = 12.34; - try std.testing.expect(@ptrToInt(&x) % 128 == 0); + try std.testing.expect(@intFromPtr(&x) % 128 == 0); } diff --git a/test/behavior/bugs/9584.zig b/test/behavior/bugs/9584.zig index 49139db89979..6f3223c36225 100644 --- a/test/behavior/bugs/9584.zig +++ b/test/behavior/bugs/9584.zig @@ -35,7 +35,7 @@ pub fn a( _ = flag_a; // With this bug present, `flag_b` would actually contain the value 17. // Note: this bug only presents itself on debug mode. - const flag_b_byte: u8 = @boolToInt(flag_b); + const flag_b_byte: u8 = @intFromBool(flag_b); try std.testing.expect(flag_b_byte == 1); } diff --git a/test/behavior/builtin_functions_returning_void_or_noreturn.zig b/test/behavior/builtin_functions_returning_void_or_noreturn.zig index ea5365888849..ae369c4e9d44 100644 --- a/test/behavior/builtin_functions_returning_void_or_noreturn.zig +++ b/test/behavior/builtin_functions_returning_void_or_noreturn.zig @@ -17,8 +17,8 @@ test { try testing.expectEqual(void, @TypeOf(@breakpoint())); try testing.expectEqual({}, @export(x, .{ .name = "x" })); try testing.expectEqual({}, @fence(.Acquire)); - try testing.expectEqual({}, @memcpy(@intToPtr([*]u8, 1)[0..0], @intToPtr([*]u8, 1)[0..0])); - try testing.expectEqual({}, @memset(@intToPtr([*]u8, 1)[0..0], undefined)); + try testing.expectEqual({}, @memcpy(@ptrFromInt([*]u8, 1)[0..0], @ptrFromInt([*]u8, 1)[0..0])); + try testing.expectEqual({}, @memset(@ptrFromInt([*]u8, 1)[0..0], undefined)); try testing.expectEqual(noreturn, @TypeOf(if (true) @panic("") else {})); try testing.expectEqual({}, @prefetch(&val, .{})); try testing.expectEqual({}, @setAlignStack(16)); diff --git a/test/behavior/call.zig b/test/behavior/call.zig index 64eca08c82b5..627df37e9bb2 100644 --- a/test/behavior/call.zig +++ b/test/behavior/call.zig @@ -364,11 +364,11 @@ test "Enum constructed by @Type passed as generic argument" { alive: bool, }); fn foo(comptime a: E, b: u32) !void { - try expect(@enumToInt(a) == b); + try expect(@intFromEnum(a) == b); } }; inline for (@typeInfo(S.E).Enum.fields, 0..) |_, i| { - try S.foo(@intToEnum(S.E, i), i); + try S.foo(@enumFromInt(S.E, i), i); } } diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index 5123e190b62d..d51d864ea1cf 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -10,14 +10,14 @@ const native_endian = builtin.target.cpu.arch.endian(); test "int to ptr cast" { const x = @as(usize, 13); - const y = @intToPtr(*u8, x); - const z = @ptrToInt(y); + const y = @ptrFromInt(*u8, x); + const z = @intFromPtr(y); try expect(z == 13); } test "integer literal to pointer cast" { - const vga_mem = @intToPtr(*u16, 0xB8000); - try expect(@ptrToInt(vga_mem) == 0xB8000); + const vga_mem = @ptrFromInt(*u16, 0xB8000); + try expect(@intFromPtr(vga_mem) == 0xB8000); } test "peer type resolution: ?T and T" { @@ -66,37 +66,37 @@ test "implicit cast comptime_int to comptime_float" { try expect(2 == 2.0); } -test "comptime_int @intToFloat" { +test "comptime_int @floatFromInt" { { - const result = @intToFloat(f16, 1234); + const result = @floatFromInt(f16, 1234); try expect(@TypeOf(result) == f16); try expect(result == 1234.0); } { - const result = @intToFloat(f32, 1234); + const result = @floatFromInt(f32, 1234); try expect(@TypeOf(result) == f32); try expect(result == 1234.0); } { - const result = @intToFloat(f64, 1234); + const result = @floatFromInt(f64, 1234); try expect(@TypeOf(result) == f64); try expect(result == 1234.0); } { - const result = @intToFloat(f128, 1234); + const result = @floatFromInt(f128, 1234); try expect(@TypeOf(result) == f128); try expect(result == 1234.0); } // big comptime_int (> 64 bits) to f128 conversion { - const result = @intToFloat(f128, 0x1_0000_0000_0000_0000); + const result = @floatFromInt(f128, 0x1_0000_0000_0000_0000); try expect(@TypeOf(result) == f128); try expect(result == 0x1_0000_0000_0000_0000.0); } } -test "@intToFloat" { +test "@floatFromInt" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO @@ -107,8 +107,8 @@ test "@intToFloat" { } fn testIntToFloat(k: i32) !void { - const f = @intToFloat(f32, k); - const i = @floatToInt(i32, f); + const f = @floatFromInt(f32, k); + const i = @intFromFloat(i32, f); try expect(i == k); } }; @@ -116,7 +116,7 @@ test "@intToFloat" { try comptime S.doTheTest(); } -test "@intToFloat(f80)" { +test "@floatFromInt(f80)" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO @@ -131,8 +131,8 @@ test "@intToFloat(f80)" { fn testIntToFloat(comptime Int: type, k: Int) !void { @setRuntimeSafety(false); // TODO - const f = @intToFloat(f80, k); - const i = @floatToInt(Int, f); + const f = @floatFromInt(f80, k); + const i = @intFromFloat(Int, f); try expect(i == k); } }; @@ -152,28 +152,28 @@ test "@intToFloat(f80)" { try comptime S.doTheTest(i256); } -test "@floatToInt" { +test "@intFromFloat" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO - try testFloatToInts(); - try comptime testFloatToInts(); + try testIntFromFloats(); + try comptime testIntFromFloats(); } -fn testFloatToInts() !void { +fn testIntFromFloats() !void { const x = @as(i32, 1e4); try expect(x == 10000); - const y = @floatToInt(i32, @as(f32, 1e4)); + const y = @intFromFloat(i32, @as(f32, 1e4)); try expect(y == 10000); - try expectFloatToInt(f32, 255.1, u8, 255); - try expectFloatToInt(f32, 127.2, i8, 127); - try expectFloatToInt(f32, -128.2, i8, -128); + try expectIntFromFloat(f32, 255.1, u8, 255); + try expectIntFromFloat(f32, 127.2, i8, 127); + try expectIntFromFloat(f32, -128.2, i8, -128); } -fn expectFloatToInt(comptime F: type, f: F, comptime I: type, i: I) !void { - try expect(@floatToInt(I, f) == i); +fn expectIntFromFloat(comptime F: type, f: F, comptime I: type, i: I) !void { + try expect(@intFromFloat(I, f) == i); } test "implicitly cast indirect pointer to maybe-indirect pointer" { @@ -280,9 +280,9 @@ test "*usize to *void" { v.* = {}; } -test "@intToEnum passed a comptime_int to an enum with one item" { +test "@enumFromInt passed a comptime_int to an enum with one item" { const E = enum { A }; - const x = @intToEnum(E, 0); + const x = @enumFromInt(E, 0); try expect(x == E.A); } @@ -420,8 +420,8 @@ test "explicit cast from integer to error type" { try comptime testCastIntToErr(error.ItBroke); } fn testCastIntToErr(err: anyerror) !void { - const x = @errorToInt(err); - const y = @intToError(x); + const x = @intFromError(err); + const y = @errorFromInt(x); try expect(error.ItBroke == y); } @@ -1093,15 +1093,15 @@ test "peer type resolve array pointer and unknown pointer" { test "comptime float casts" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; - const a = @intToFloat(comptime_float, 1); + const a = @floatFromInt(comptime_float, 1); try expect(a == 1); try expect(@TypeOf(a) == comptime_float); - const b = @floatToInt(comptime_int, 2); + const b = @intFromFloat(comptime_int, 2); try expect(b == 2); try expect(@TypeOf(b) == comptime_int); - try expectFloatToInt(comptime_int, 1234, i16, 1234); - try expectFloatToInt(comptime_float, 12.3, comptime_int, 12); + try expectIntFromFloat(comptime_int, 1234, i16, 1234); + try expectIntFromFloat(comptime_float, 12.3, comptime_int, 12); } test "pointer reinterpret const float to int" { @@ -1146,11 +1146,11 @@ test "compile time int to ptr of function" { // On some architectures function pointers must be aligned. const hardcoded_fn_addr = maxInt(usize) & ~@as(usize, 0xf); -pub const FUNCTION_CONSTANT = @intToPtr(PFN_void, hardcoded_fn_addr); +pub const FUNCTION_CONSTANT = @ptrFromInt(PFN_void, hardcoded_fn_addr); pub const PFN_void = *const fn (*anyopaque) callconv(.C) void; fn foobar(func: PFN_void) !void { - try std.testing.expect(@ptrToInt(func) == hardcoded_fn_addr); + try std.testing.expect(@intFromPtr(func) == hardcoded_fn_addr); } test "implicit ptr to *anyopaque" { @@ -1285,11 +1285,11 @@ test "implicit cast *[0]T to E![]const u8" { var global_array: [4]u8 = undefined; test "cast from array reference to fn: comptime fn ptr" { const f = @ptrCast(*align(1) const fn () callconv(.C) void, &global_array); - try expect(@ptrToInt(f) == @ptrToInt(&global_array)); + try expect(@intFromPtr(f) == @intFromPtr(&global_array)); } test "cast from array reference to fn: runtime fn ptr" { var f = @ptrCast(*align(1) const fn () callconv(.C) void, &global_array); - try expect(@ptrToInt(f) == @ptrToInt(&global_array)); + try expect(@intFromPtr(f) == @intFromPtr(&global_array)); } test "*const [N]null u8 to ?[]const u8" { @@ -1500,19 +1500,19 @@ test "coerce between pointers of compatible differently-named floats" { } test "peer type resolution of const and non-const pointer to array" { - const a = @intToPtr(*[1024]u8, 42); - const b = @intToPtr(*const [1024]u8, 42); + const a = @ptrFromInt(*[1024]u8, 42); + const b = @ptrFromInt(*const [1024]u8, 42); try std.testing.expect(@TypeOf(a, b) == *const [1024]u8); try std.testing.expect(a == b); } -test "floatToInt to zero-bit int" { +test "intFromFloat to zero-bit int" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO const a: f32 = 0.0; - try comptime std.testing.expect(@floatToInt(u0, a) == 0); + try comptime std.testing.expect(@intFromFloat(u0, a) == 0); } test "peer type resolution of function pointer and function body" { @@ -1560,9 +1560,9 @@ test "optional pointer coerced to optional allowzero pointer" { var p: ?*u32 = undefined; var q: ?*allowzero u32 = undefined; - p = @intToPtr(*u32, 4); + p = @ptrFromInt(*u32, 4); q = p; - try expect(@ptrToInt(q.?) == 4); + try expect(@intFromPtr(q.?) == 4); } test "single item pointer to pointer to array to slice" { @@ -1623,8 +1623,8 @@ test "peer type resolution: const sentinel slice and mutable non-sentinel slice" const S = struct { fn doTheTest(comptime T: type, comptime s: T) !void { - var a: [:s]const T = @intToPtr(*const [2:s]T, 0x1000); - var b: []T = @intToPtr(*[3]T, 0x2000); + var a: [:s]const T = @ptrFromInt(*const [2:s]T, 0x1000); + var b: []T = @ptrFromInt(*[3]T, 0x2000); comptime assert(@TypeOf(a, b) == []const T); comptime assert(@TypeOf(b, a) == []const T); @@ -1634,8 +1634,8 @@ test "peer type resolution: const sentinel slice and mutable non-sentinel slice" const R = @TypeOf(r1); - try expectEqual(@as(R, @intToPtr(*const [2:s]T, 0x1000)), r1); - try expectEqual(@as(R, @intToPtr(*const [3]T, 0x2000)), r2); + try expectEqual(@as(R, @ptrFromInt(*const [2:s]T, 0x1000)), r1); + try expectEqual(@as(R, @ptrFromInt(*const [3]T, 0x2000)), r2); } }; @@ -1815,7 +1815,7 @@ test "peer type resolution: three-way resolution combines error set and optional const E = error{Foo}; var a: E = error.Foo; - var b: *const [5:0]u8 = @intToPtr(*const [5:0]u8, 0x1000); + var b: *const [5:0]u8 = @ptrFromInt(*const [5:0]u8, 0x1000); var c: ?[*:0]u8 = null; comptime assert(@TypeOf(a, b, c) == E!?[*:0]const u8); comptime assert(@TypeOf(a, c, b) == E!?[*:0]const u8); @@ -1844,7 +1844,7 @@ test "peer type resolution: three-way resolution combines error set and optional const T = @TypeOf(r1); try expectEqual(@as(T, error.Foo), r1); - try expectEqual(@as(T, @intToPtr([*:0]u8, 0x1000)), r2); + try expectEqual(@as(T, @ptrFromInt([*:0]u8, 0x1000)), r2); try expectEqual(@as(T, null), r3); } diff --git a/test/behavior/comptime_memory.zig b/test/behavior/comptime_memory.zig index 646433a5c0c0..ade0f0dc4215 100644 --- a/test/behavior/comptime_memory.zig +++ b/test/behavior/comptime_memory.zig @@ -192,9 +192,9 @@ test "basic pointer preservation" { } comptime { - const lazy_address = @ptrToInt(&imports.global_u32); - try testing.expectEqual(@ptrToInt(&imports.global_u32), lazy_address); - try testing.expectEqual(&imports.global_u32, @intToPtr(*u32, lazy_address)); + const lazy_address = @intFromPtr(&imports.global_u32); + try testing.expectEqual(@intFromPtr(&imports.global_u32), lazy_address); + try testing.expectEqual(&imports.global_u32, @ptrFromInt(*u32, lazy_address)); } } @@ -251,7 +251,7 @@ test "shuffle chunks of linker value" { return error.SkipZigTest; } - const lazy_address = @ptrToInt(&imports.global_u32); + const lazy_address = @intFromPtr(&imports.global_u32); const shuffled1_rt = shuffle(lazy_address, Bits, ShuffledBits); const unshuffled1_rt = shuffle(shuffled1_rt, ShuffledBits, Bits); try testing.expectEqual(lazy_address, unshuffled1_rt); @@ -271,8 +271,8 @@ test "dance on linker values" { comptime { var arr: [2]usize = undefined; - arr[0] = @ptrToInt(&imports.global_u32); - arr[1] = @ptrToInt(&imports.global_u32); + arr[0] = @intFromPtr(&imports.global_u32); + arr[1] = @intFromPtr(&imports.global_u32); const weird_ptr = @ptrCast([*]Bits, @ptrCast([*]u8, &arr) + @sizeOf(usize) - 3); try doTypePunBitsTest(&weird_ptr[0]); @@ -290,7 +290,7 @@ test "dance on linker values" { rebuilt_bytes[i] = arr_bytes[1][i]; } - try testing.expectEqual(&imports.global_u32, @intToPtr(*u32, @bitCast(usize, rebuilt_bytes))); + try testing.expectEqual(&imports.global_u32, @ptrFromInt(*u32, @bitCast(usize, rebuilt_bytes))); } } @@ -309,14 +309,14 @@ test "offset array ptr by element size" { .{ .x = bigToNativeEndian(u32, 0x03070b0f) }, }; - const address = @ptrToInt(&arr); - try testing.expectEqual(@ptrToInt(&arr[0]), address); - try testing.expectEqual(@ptrToInt(&arr[0]) + 10, address + 10); - try testing.expectEqual(@ptrToInt(&arr[1]), address + @sizeOf(VirtualStruct)); - try testing.expectEqual(@ptrToInt(&arr[2]), address + 2 * @sizeOf(VirtualStruct)); - try testing.expectEqual(@ptrToInt(&arr[3]), address + @sizeOf(VirtualStruct) * 3); + const address = @intFromPtr(&arr); + try testing.expectEqual(@intFromPtr(&arr[0]), address); + try testing.expectEqual(@intFromPtr(&arr[0]) + 10, address + 10); + try testing.expectEqual(@intFromPtr(&arr[1]), address + @sizeOf(VirtualStruct)); + try testing.expectEqual(@intFromPtr(&arr[2]), address + 2 * @sizeOf(VirtualStruct)); + try testing.expectEqual(@intFromPtr(&arr[3]), address + @sizeOf(VirtualStruct) * 3); - const secondElement = @intToPtr(*VirtualStruct, @ptrToInt(&arr[0]) + 2 * @sizeOf(VirtualStruct)); + const secondElement = @ptrFromInt(*VirtualStruct, @intFromPtr(&arr[0]) + 2 * @sizeOf(VirtualStruct)); try testing.expectEqual(bigToNativeEndian(u32, 0x02060a0e), secondElement.x); } } @@ -331,18 +331,18 @@ test "offset instance by field size" { const VirtualStruct = struct { x: u32, y: u32, z: u32, w: u32 }; var inst = VirtualStruct{ .x = 0, .y = 1, .z = 2, .w = 3 }; - var ptr = @ptrToInt(&inst); + var ptr = @intFromPtr(&inst); ptr -= 4; ptr += @offsetOf(VirtualStruct, "x"); - try testing.expectEqual(@as(u32, 0), @intToPtr([*]u32, ptr)[1]); + try testing.expectEqual(@as(u32, 0), @ptrFromInt([*]u32, ptr)[1]); ptr -= @offsetOf(VirtualStruct, "x"); ptr += @offsetOf(VirtualStruct, "y"); - try testing.expectEqual(@as(u32, 1), @intToPtr([*]u32, ptr)[1]); + try testing.expectEqual(@as(u32, 1), @ptrFromInt([*]u32, ptr)[1]); ptr = ptr - @offsetOf(VirtualStruct, "y") + @offsetOf(VirtualStruct, "z"); - try testing.expectEqual(@as(u32, 2), @intToPtr([*]u32, ptr)[1]); - ptr = @ptrToInt(&inst.z) - 4 - @offsetOf(VirtualStruct, "z"); + try testing.expectEqual(@as(u32, 2), @ptrFromInt([*]u32, ptr)[1]); + ptr = @intFromPtr(&inst.z) - 4 - @offsetOf(VirtualStruct, "z"); ptr += @offsetOf(VirtualStruct, "w"); - try testing.expectEqual(@as(u32, 3), @intToPtr(*u32, ptr + 4).*); + try testing.expectEqual(@as(u32, 3), @ptrFromInt(*u32, ptr + 4).*); } } diff --git a/test/behavior/enum.zig b/test/behavior/enum.zig index a795d5f4b864..12926800e307 100644 --- a/test/behavior/enum.zig +++ b/test/behavior/enum.zig @@ -8,7 +8,7 @@ const Tag = std.meta.Tag; const Number = enum { Zero, One, Two, Three, Four }; fn shouldEqual(n: Number, expected: u3) !void { - try expect(@enumToInt(n) == expected); + try expect(@intFromEnum(n) == expected); } test "enum to int" { @@ -20,7 +20,7 @@ test "enum to int" { } fn testIntToEnumEval(x: i32) !void { - try expect(@intToEnum(IntToEnumNumber, x) == IntToEnumNumber.Three); + try expect(@enumFromInt(IntToEnumNumber, x) == IntToEnumNumber.Three); } const IntToEnumNumber = enum { Zero, One, Two, Three, Four }; @@ -597,7 +597,7 @@ const MultipleChoice = enum(u32) { }; fn testEnumWithSpecifiedTagValues(x: MultipleChoice) !void { - try expect(@enumToInt(x) == 60); + try expect(@intFromEnum(x) == 60); try expect(1234 == switch (x) { MultipleChoice.A => 1, MultipleChoice.B => 2, @@ -629,7 +629,7 @@ test "non-exhaustive enum" { .b => true, _ => false, }); - e = @intToEnum(E, 12); + e = @enumFromInt(E, 12); try expect(switch (e) { .a => false, .b => false, @@ -648,10 +648,10 @@ test "non-exhaustive enum" { }); try expect(@typeInfo(E).Enum.fields.len == 2); - e = @intToEnum(E, 12); - try expect(@enumToInt(e) == 12); - e = @intToEnum(E, y); - try expect(@enumToInt(e) == 52); + e = @enumFromInt(E, 12); + try expect(@intFromEnum(e) == 12); + e = @enumFromInt(E, y); + try expect(@intFromEnum(e) == 52); try expect(@typeInfo(E).Enum.is_exhaustive == false); } }; @@ -666,11 +666,11 @@ test "empty non-exhaustive enum" { const E = enum(u8) { _ }; fn doTheTest(y: u8) !void { - var e = @intToEnum(E, y); + var e = @enumFromInt(E, y); try expect(switch (e) { _ => true, }); - try expect(@enumToInt(e) == y); + try expect(@intFromEnum(e) == y); try expect(@typeInfo(E).Enum.fields.len == 0); try expect(@typeInfo(E).Enum.is_exhaustive == false); @@ -693,7 +693,7 @@ test "single field non-exhaustive enum" { .a => true, _ => false, }); - e = @intToEnum(E, 12); + e = @enumFromInt(E, 12); try expect(switch (e) { .a => false, _ => true, @@ -709,7 +709,7 @@ test "single field non-exhaustive enum" { else => false, }); - try expect(@enumToInt(@intToEnum(E, y)) == y); + try expect(@intFromEnum(@enumFromInt(E, y)) == y); try expect(@typeInfo(E).Enum.fields.len == 1); try expect(@typeInfo(E).Enum.is_exhaustive == false); } @@ -725,7 +725,7 @@ const EnumWithTagValues = enum(u4) { D = 1 << 3, }; test "enum with tag values don't require parens" { - try expect(@enumToInt(EnumWithTagValues.C) == 0b0100); + try expect(@intFromEnum(EnumWithTagValues.C) == 0b0100); } const MultipleChoice2 = enum(u32) { @@ -741,8 +741,8 @@ const MultipleChoice2 = enum(u32) { }; test "cast integer literal to enum" { - try expect(@intToEnum(MultipleChoice2, 0) == MultipleChoice2.Unspecified1); - try expect(@intToEnum(MultipleChoice2, 40) == MultipleChoice2.B); + try expect(@enumFromInt(MultipleChoice2, 0) == MultipleChoice2.Unspecified1); + try expect(@enumFromInt(MultipleChoice2, 40) == MultipleChoice2.B); } test "enum with specified and unspecified tag values" { @@ -754,7 +754,7 @@ test "enum with specified and unspecified tag values" { } fn testEnumWithSpecifiedAndUnspecifiedTagValues(x: MultipleChoice2) !void { - try expect(@enumToInt(x) == 1000); + try expect(@intFromEnum(x) == 1000); try expect(1234 == switch (x) { MultipleChoice2.A => 1, MultipleChoice2.B => 2, @@ -790,7 +790,7 @@ test "casting enum to its tag type" { } fn testCastEnumTag(value: Small2) !void { - try expect(@enumToInt(value) == 1); + try expect(@intFromEnum(value) == 1); } test "enum with 1 field but explicit tag type should still have the tag type" { @@ -807,27 +807,27 @@ test "signed integer as enum tag" { A2 = 1, }; - try expect(@enumToInt(SignedEnum.A0) == -1); - try expect(@enumToInt(SignedEnum.A1) == 0); - try expect(@enumToInt(SignedEnum.A2) == 1); + try expect(@intFromEnum(SignedEnum.A0) == -1); + try expect(@intFromEnum(SignedEnum.A1) == 0); + try expect(@intFromEnum(SignedEnum.A2) == 1); } test "enum with one member and custom tag type" { const E = enum(u2) { One, }; - try expect(@enumToInt(E.One) == 0); + try expect(@intFromEnum(E.One) == 0); const E2 = enum(u2) { One = 2, }; - try expect(@enumToInt(E2.One) == 2); + try expect(@intFromEnum(E2.One) == 2); } -test "enum with one member and u1 tag type @enumToInt" { +test "enum with one member and u1 tag type @intFromEnum" { const Enum = enum(u1) { Test, }; - try expect(@enumToInt(Enum.Test) == 0); + try expect(@intFromEnum(Enum.Test) == 0); } test "enum with comptime_int tag type" { @@ -901,9 +901,9 @@ test "enum value allocation" { A2, }; - try expect(@enumToInt(LargeEnum.A0) == 0x80000000); - try expect(@enumToInt(LargeEnum.A1) == 0x80000001); - try expect(@enumToInt(LargeEnum.A2) == 0x80000002); + try expect(@intFromEnum(LargeEnum.A0) == 0x80000000); + try expect(@intFromEnum(LargeEnum.A1) == 0x80000001); + try expect(@intFromEnum(LargeEnum.A2) == 0x80000002); } test "enum literal casting to tagged union" { @@ -1183,7 +1183,7 @@ test "Non-exhaustive enum with nonstandard int size behaves correctly" { test "runtime int to enum with one possible value" { const E = enum { one }; var runtime: usize = 0; - if (@intToEnum(E, runtime) != .one) { + if (@enumFromInt(E, runtime) != .one) { @compileError("test failed"); } } @@ -1194,6 +1194,6 @@ test "enum tag from a local variable" { return enum(Inner) { _ }; } }; - const i = @intToEnum(S.Int(u32), 0); - try std.testing.expect(@enumToInt(i) == 0); + const i = @enumFromInt(S.Int(u32), 0); + try std.testing.expect(@intFromEnum(i) == 0); } diff --git a/test/behavior/error.zig b/test/behavior/error.zig index c61cd70e6b5a..14b0eca03084 100644 --- a/test/behavior/error.zig +++ b/test/behavior/error.zig @@ -16,8 +16,8 @@ fn expectError(expected_err: anyerror, observed_err_union: anytype) !void { } test "error values" { - const a = @errorToInt(error.err1); - const b = @errorToInt(error.err2); + const a = @intFromError(error.err1); + const b = @intFromError(error.err2); try expect(a != b); } @@ -259,14 +259,14 @@ fn testComptimeTestErrorEmptySet(x: EmptyErrorSet!i32) !void { } test "comptime err to int of error set with only 1 possible value" { - testErrToIntWithOnePossibleValue(error.A, @errorToInt(error.A)); - comptime testErrToIntWithOnePossibleValue(error.A, @errorToInt(error.A)); + testErrToIntWithOnePossibleValue(error.A, @intFromError(error.A)); + comptime testErrToIntWithOnePossibleValue(error.A, @intFromError(error.A)); } fn testErrToIntWithOnePossibleValue( x: error{A}, comptime value: u32, ) void { - if (@errorToInt(x) != value) { + if (@intFromError(x) != value) { @compileError("bad"); } } diff --git a/test/behavior/eval.zig b/test/behavior/eval.zig index 2c2f1d72ff6e..85dc5e29b5d6 100644 --- a/test/behavior/eval.zig +++ b/test/behavior/eval.zig @@ -1372,7 +1372,7 @@ test "lazy value is resolved as slice operand" { const ptr1 = a[0..@sizeOf(A)]; const ptr2 = @ptrCast([*]u8, &a)[0..@sizeOf(A)]; - try expect(@ptrToInt(ptr1) == @ptrToInt(ptr2)); + try expect(@intFromPtr(ptr1) == @intFromPtr(ptr2)); try expect(ptr1.len == ptr2.len); } diff --git a/test/behavior/export.zig b/test/behavior/export.zig index 6123aa593bdd..4928e8672542 100644 --- a/test/behavior/export.zig +++ b/test/behavior/export.zig @@ -7,7 +7,7 @@ const builtin = @import("builtin"); // can't really run this test but we can make sure it has no compile error // and generates code -const vram = @intToPtr([*]volatile u8, 0x20000000)[0..0x8000]; +const vram = @ptrFromInt([*]volatile u8, 0x20000000)[0..0x8000]; export fn writeToVRam() void { vram[0] = 'X'; } diff --git a/test/behavior/export_self_referential_type_info.zig b/test/behavior/export_self_referential_type_info.zig index 0982985cee14..1b1bb35e5b9d 100644 --- a/test/behavior/export_self_referential_type_info.zig +++ b/test/behavior/export_self_referential_type_info.zig @@ -1 +1 @@ -export const self_referential_type_info: c_int = @boolToInt(@typeInfo(@This()).Struct.is_tuple); +export const self_referential_type_info: c_int = @intFromBool(@typeInfo(@This()).Struct.is_tuple); diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig index 15033d551581..56f3885a4aa5 100644 --- a/test/behavior/floatop.zig +++ b/test/behavior/floatop.zig @@ -89,12 +89,12 @@ fn testDifferentSizedFloatComparisons() !void { // } //} -test "negative f128 floatToInt at compile-time" { +test "negative f128 intFromFloat at compile-time" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO const a: f128 = -2; - var b = @floatToInt(i64, a); + var b = @intFromFloat(i64, a); try expect(@as(i64, -2) == b); } diff --git a/test/behavior/fn_in_struct_in_comptime.zig b/test/behavior/fn_in_struct_in_comptime.zig index a7d8e779cc21..b31b377c048b 100644 --- a/test/behavior/fn_in_struct_in_comptime.zig +++ b/test/behavior/fn_in_struct_in_comptime.zig @@ -5,7 +5,7 @@ fn get_foo() fn (*u8) usize { comptime { return struct { fn func(ptr: *u8) usize { - var u = @ptrToInt(ptr); + var u = @intFromPtr(ptr); return u; } }.func; @@ -14,5 +14,5 @@ fn get_foo() fn (*u8) usize { test "define a function in an anonymous struct in comptime" { const foo = get_foo(); - try expect(foo(@intToPtr(*u8, 12345)) == 12345); + try expect(foo(@ptrFromInt(*u8, 12345)) == 12345); } diff --git a/test/behavior/generics.zig b/test/behavior/generics.zig index 7f22f63045d5..f0c8516f6721 100644 --- a/test/behavior/generics.zig +++ b/test/behavior/generics.zig @@ -267,7 +267,7 @@ test "generic function instantiation turns into comptime call" { .Enum => std.builtin.Type.EnumField, else => void, } { - return @typeInfo(T).Enum.fields[@enumToInt(field)]; + return @typeInfo(T).Enum.fields[@intFromEnum(field)]; } pub fn FieldEnum(comptime T: type) type { @@ -425,10 +425,10 @@ test "null sentinel pointer passed as generic argument" { const S = struct { fn doTheTest(a: anytype) !void { - try std.testing.expect(@ptrToInt(a) == 8); + try std.testing.expect(@intFromPtr(a) == 8); } }; - try S.doTheTest((@intToPtr([*:null]const [*c]const u8, 8))); + try S.doTheTest((@ptrFromInt([*:null]const [*c]const u8, 8))); } test "generic function passed as comptime argument" { diff --git a/test/behavior/inline_switch.zig b/test/behavior/inline_switch.zig index 426026d82617..fc2eae31befc 100644 --- a/test/behavior/inline_switch.zig +++ b/test/behavior/inline_switch.zig @@ -103,7 +103,7 @@ test "inline else enum" { var a: E2 = .a; switch (a) { .a, .b => {}, - inline else => |val| comptime if (@enumToInt(val) < 4) @compileError("bad"), + inline else => |val| comptime if (@intFromEnum(val) < 4) @compileError("bad"), } } diff --git a/test/behavior/packed-struct.zig b/test/behavior/packed-struct.zig index 5a6e92403b2f..037fee74ee26 100644 --- a/test/behavior/packed-struct.zig +++ b/test/behavior/packed-struct.zig @@ -375,7 +375,7 @@ test "load pointer from packed struct" { } } -test "@ptrToInt on a packed struct field" { +test "@intFromPtr on a packed struct field" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; @@ -394,7 +394,7 @@ test "@ptrToInt on a packed struct field" { .z = 0, }; }; - try expect(@ptrToInt(&S.p0.z) - @ptrToInt(&S.p0.x) == 2); + try expect(@intFromPtr(&S.p0.z) - @intFromPtr(&S.p0.x) == 2); } test "optional pointer in packed struct" { diff --git a/test/behavior/pointers.zig b/test/behavior/pointers.zig index 32c2dc13ac65..4e04fe580c23 100644 --- a/test/behavior/pointers.zig +++ b/test/behavior/pointers.zig @@ -184,8 +184,8 @@ test "implicit cast error unions with non-optional to optional pointer" { } test "compare equality of optional and non-optional pointer" { - const a = @intToPtr(*const usize, 0x12345678); - const b = @intToPtr(?*usize, 0x12345678); + const a = @ptrFromInt(*const usize, 0x12345678); + const b = @ptrFromInt(?*usize, 0x12345678); try expect(a == b); try expect(b == a); } @@ -197,14 +197,14 @@ test "allowzero pointer and slice" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; - var ptr = @intToPtr([*]allowzero i32, 0); + var ptr = @ptrFromInt([*]allowzero i32, 0); var opt_ptr: ?[*]allowzero i32 = ptr; try expect(opt_ptr != null); - try expect(@ptrToInt(ptr) == 0); + try expect(@intFromPtr(ptr) == 0); var runtime_zero: usize = 0; var slice = ptr[runtime_zero..10]; try comptime expect(@TypeOf(slice) == []allowzero i32); - try expect(@ptrToInt(&slice[5]) == 20); + try expect(@intFromPtr(&slice[5]) == 20); try comptime expect(@typeInfo(@TypeOf(ptr)).Pointer.is_allowzero); try comptime expect(@typeInfo(@TypeOf(slice)).Pointer.is_allowzero); @@ -367,10 +367,10 @@ test "pointer sentinel with +inf" { } test "pointer to array at fixed address" { - const array = @intToPtr(*volatile [2]u32, 0x10); + const array = @ptrFromInt(*volatile [2]u32, 0x10); // Silly check just to reference `array` - try expect(@ptrToInt(&array[0]) == 0x10); - try expect(@ptrToInt(&array[1]) == 0x14); + try expect(@intFromPtr(&array[0]) == 0x10); + try expect(@intFromPtr(&array[1]) == 0x14); } test "pointer arithmetic affects the alignment" { @@ -404,16 +404,16 @@ test "pointer arithmetic affects the alignment" { } } -test "@ptrToInt on null optional at comptime" { +test "@intFromPtr on null optional at comptime" { { - const pointer = @intToPtr(?*u8, 0x000); - const x = @ptrToInt(pointer); + const pointer = @ptrFromInt(?*u8, 0x000); + const x = @intFromPtr(pointer); _ = x; - try comptime expect(0 == @ptrToInt(pointer)); + try comptime expect(0 == @intFromPtr(pointer)); } { - const pointer = @intToPtr(?*u8, 0xf00); - try comptime expect(0xf00 == @ptrToInt(pointer)); + const pointer = @ptrFromInt(?*u8, 0xf00); + try comptime expect(0xf00 == @intFromPtr(pointer)); } } @@ -516,7 +516,7 @@ test "ptrCast comptime known slice to C pointer" { try std.testing.expectEqualStrings(s, std.mem.sliceTo(p, 0)); } -test "ptrToInt on a generic function" { +test "intFromPtr on a generic function" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO @@ -527,7 +527,7 @@ test "ptrToInt on a generic function" { return i; } fn doTheTest(a: anytype) !void { - try expect(@ptrToInt(a) != 0); + try expect(@intFromPtr(a) != 0); } }; try S.doTheTest(&S.generic); diff --git a/test/behavior/inttoptr.zig b/test/behavior/ptrfromint.zig similarity index 75% rename from test/behavior/inttoptr.zig rename to test/behavior/ptrfromint.zig index 5a3778b09fd7..c07a6df8347a 100644 --- a/test/behavior/inttoptr.zig +++ b/test/behavior/ptrfromint.zig @@ -9,10 +9,10 @@ test "casting integer address to function pointer" { fn addressToFunction() void { var addr: usize = 0xdeadbee0; - _ = @intToPtr(*const fn () void, addr); + _ = @ptrFromInt(*const fn () void, addr); } -test "mutate through ptr initialized with constant intToPtr value" { +test "mutate through ptr initialized with constant ptrFromInt value" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO @@ -21,7 +21,7 @@ test "mutate through ptr initialized with constant intToPtr value" { } fn forceCompilerAnalyzeBranchHardCodedPtrDereference(x: bool) void { - const hardCodedP = @intToPtr(*volatile u8, 0xdeadbeef); + const hardCodedP = @ptrFromInt(*volatile u8, 0xdeadbeef); if (x) { hardCodedP.* = hardCodedP.* | 10; } else { @@ -29,20 +29,20 @@ fn forceCompilerAnalyzeBranchHardCodedPtrDereference(x: bool) void { } } -test "@intToPtr creates null pointer" { +test "@ptrFromInt creates null pointer" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO - const ptr = @intToPtr(?*u32, 0); + const ptr = @ptrFromInt(?*u32, 0); try expectEqual(@as(?*u32, null), ptr); } -test "@intToPtr creates allowzero zero pointer" { +test "@ptrFromInt creates allowzero zero pointer" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO - const ptr = @intToPtr(*allowzero u32, 0); - try expectEqual(@as(usize, 0), @ptrToInt(ptr)); + const ptr = @ptrFromInt(*allowzero u32, 0); + try expectEqual(@as(usize, 0), @intFromPtr(ptr)); } diff --git a/test/behavior/sizeof_and_typeof.zig b/test/behavior/sizeof_and_typeof.zig index a14ae1c6e77a..3657e77e5065 100644 --- a/test/behavior/sizeof_and_typeof.zig +++ b/test/behavior/sizeof_and_typeof.zig @@ -92,15 +92,15 @@ test "@offsetOf" { // // Normal struct fields can be moved/padded var a: A = undefined; - try expect(@ptrToInt(&a.a) - @ptrToInt(&a) == @offsetOf(A, "a")); - try expect(@ptrToInt(&a.b) - @ptrToInt(&a) == @offsetOf(A, "b")); - try expect(@ptrToInt(&a.c) - @ptrToInt(&a) == @offsetOf(A, "c")); - try expect(@ptrToInt(&a.d) - @ptrToInt(&a) == @offsetOf(A, "d")); - try expect(@ptrToInt(&a.e) - @ptrToInt(&a) == @offsetOf(A, "e")); - try expect(@ptrToInt(&a.f) - @ptrToInt(&a) == @offsetOf(A, "f")); - try expect(@ptrToInt(&a.g) - @ptrToInt(&a) == @offsetOf(A, "g")); - try expect(@ptrToInt(&a.h) - @ptrToInt(&a) == @offsetOf(A, "h")); - try expect(@ptrToInt(&a.i) - @ptrToInt(&a) == @offsetOf(A, "i")); + try expect(@intFromPtr(&a.a) - @intFromPtr(&a) == @offsetOf(A, "a")); + try expect(@intFromPtr(&a.b) - @intFromPtr(&a) == @offsetOf(A, "b")); + try expect(@intFromPtr(&a.c) - @intFromPtr(&a) == @offsetOf(A, "c")); + try expect(@intFromPtr(&a.d) - @intFromPtr(&a) == @offsetOf(A, "d")); + try expect(@intFromPtr(&a.e) - @intFromPtr(&a) == @offsetOf(A, "e")); + try expect(@intFromPtr(&a.f) - @intFromPtr(&a) == @offsetOf(A, "f")); + try expect(@intFromPtr(&a.g) - @intFromPtr(&a) == @offsetOf(A, "g")); + try expect(@intFromPtr(&a.h) - @intFromPtr(&a) == @offsetOf(A, "h")); + try expect(@intFromPtr(&a.i) - @intFromPtr(&a) == @offsetOf(A, "i")); } test "@bitOffsetOf" { @@ -231,7 +231,7 @@ test "@sizeOf comparison against zero" { test "hardcoded address in typeof expression" { const S = struct { - fn func() @TypeOf(@intToPtr(*[]u8, 0x10).*[0]) { + fn func() @TypeOf(@ptrFromInt(*[]u8, 0x10).*[0]) { return 0; } }; @@ -252,7 +252,7 @@ test "array access of generic param in typeof expression" { test "lazy size cast to float" { { const S = struct { a: u8 }; - try expect(@intToFloat(f32, @sizeOf(S)) == 1.0); + try expect(@floatFromInt(f32, @sizeOf(S)) == 1.0); } { const S = struct { a: u8 }; diff --git a/test/behavior/slice.zig b/test/behavior/slice.zig index ae5fbf09513a..fcbae214ace0 100644 --- a/test/behavior/slice.zig +++ b/test/behavior/slice.zig @@ -138,10 +138,10 @@ fn memFree(comptime T: type, memory: []T) void { test "slice of hardcoded address to pointer" { const S = struct { fn doTheTest() !void { - const pointer = @intToPtr([*]u8, 0x04)[0..2]; + const pointer = @ptrFromInt([*]u8, 0x04)[0..2]; try comptime expect(@TypeOf(pointer) == *[2]u8); const slice: []const u8 = pointer; - try expect(@ptrToInt(slice.ptr) == 4); + try expect(@intFromPtr(slice.ptr) == 4); try expect(slice.len == 2); } }; @@ -197,13 +197,13 @@ test "slicing pointer by length" { } } -const x = @intToPtr([*]i32, 0x1000)[0..0x500]; +const x = @ptrFromInt([*]i32, 0x1000)[0..0x500]; const y = x[0x100..]; test "compile time slice of pointer to hard coded address" { - try expect(@ptrToInt(x) == 0x1000); + try expect(@intFromPtr(x) == 0x1000); try expect(x.len == 0x500); - try expect(@ptrToInt(y) == 0x1400); + try expect(@intFromPtr(y) == 0x1400); try expect(y.len == 0x400); } @@ -838,13 +838,13 @@ test "empty slice ptr is non null" { const empty_slice: []u8 = &[_]u8{}; const p: [*]u8 = empty_slice.ptr + 0; const t = @ptrCast([*]i8, p); - try expect(@ptrToInt(t) == @ptrToInt(empty_slice.ptr)); + try expect(@intFromPtr(t) == @intFromPtr(empty_slice.ptr)); } { const empty_slice: []u8 = &.{}; const p: [*]u8 = empty_slice.ptr + 0; const t = @ptrCast([*]i8, p); - try expect(@ptrToInt(t) == @ptrToInt(empty_slice.ptr)); + try expect(@intFromPtr(t) == @intFromPtr(empty_slice.ptr)); } } diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig index 6686c911a574..6ced42998e6b 100644 --- a/test/behavior/struct.zig +++ b/test/behavior/struct.zig @@ -838,7 +838,7 @@ test "non-packed struct with u128 entry in union" { var sx: S = undefined; var s = &sx; - try expect(@ptrToInt(&s.f2) - @ptrToInt(&s.f1) == @offsetOf(S, "f2")); + try expect(@intFromPtr(&s.f2) - @intFromPtr(&s.f1) == @offsetOf(S, "f2")); var v2 = U{ .Num = 123 }; s.f2 = v2; try expect(s.f2.Num == 123); diff --git a/test/behavior/switch.zig b/test/behavior/switch.zig index 02e3ef4dcefe..f9fb9c76596e 100644 --- a/test/behavior/switch.zig +++ b/test/behavior/switch.zig @@ -590,9 +590,9 @@ test "switch on pointer type" { field: u32, }; - const P1 = @intToPtr(*X, 0x400); - const P2 = @intToPtr(*X, 0x800); - const P3 = @intToPtr(*X, 0xC00); + const P1 = @ptrFromInt(*X, 0x400); + const P2 = @ptrFromInt(*X, 0x800); + const P3 = @ptrFromInt(*X, 0xC00); fn doTheTest(arg: *X) i32 { switch (arg) { @@ -682,9 +682,9 @@ test "enum value without tag name used as switch item" { b = 2, _, }; - var e: E = @intToEnum(E, 0); + var e: E = @enumFromInt(E, 0); switch (e) { - @intToEnum(E, 0) => {}, + @enumFromInt(E, 0) => {}, .a => return error.TestFailed, .b => return error.TestFailed, _ => return error.TestFailed, diff --git a/test/behavior/translate_c_macros.zig b/test/behavior/translate_c_macros.zig index b3d1a688fe32..a69396c2032a 100644 --- a/test/behavior/translate_c_macros.zig +++ b/test/behavior/translate_c_macros.zig @@ -60,7 +60,7 @@ test "cast negative integer to pointer" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; - try expectEqual(@intToPtr(?*anyopaque, @bitCast(usize, @as(isize, -1))), h.MAP_FAILED); + try expectEqual(@ptrFromInt(?*anyopaque, @bitCast(usize, @as(isize, -1))), h.MAP_FAILED); } test "casting to union with a macro" { diff --git a/test/behavior/type.zig b/test/behavior/type.zig index 94a6b460e4e2..9420b5d2fdb8 100644 --- a/test/behavior/type.zig +++ b/test/behavior/type.zig @@ -363,8 +363,8 @@ test "Type.Enum" { }, }); try testing.expectEqual(true, @typeInfo(Foo).Enum.is_exhaustive); - try testing.expectEqual(@as(u8, 1), @enumToInt(Foo.a)); - try testing.expectEqual(@as(u8, 5), @enumToInt(Foo.b)); + try testing.expectEqual(@as(u8, 1), @intFromEnum(Foo.a)); + try testing.expectEqual(@as(u8, 5), @intFromEnum(Foo.b)); const Bar = @Type(.{ .Enum = .{ .tag_type = u32, @@ -377,9 +377,9 @@ test "Type.Enum" { }, }); try testing.expectEqual(false, @typeInfo(Bar).Enum.is_exhaustive); - try testing.expectEqual(@as(u32, 1), @enumToInt(Bar.a)); - try testing.expectEqual(@as(u32, 5), @enumToInt(Bar.b)); - try testing.expectEqual(@as(u32, 6), @enumToInt(@intToEnum(Bar, 6))); + try testing.expectEqual(@as(u32, 1), @intFromEnum(Bar.a)); + try testing.expectEqual(@as(u32, 5), @intFromEnum(Bar.b)); + try testing.expectEqual(@as(u32, 6), @intFromEnum(@enumFromInt(Bar, 6))); } test "Type.Union" { diff --git a/test/behavior/union.zig b/test/behavior/union.zig index c94695ff2132..33cf1198ad1e 100644 --- a/test/behavior/union.zig +++ b/test/behavior/union.zig @@ -364,7 +364,7 @@ test "simple union(enum(u32))" { var x = MultipleChoice.C; try expect(x == MultipleChoice.C); - try expect(@enumToInt(@as(Tag(MultipleChoice), x)) == 60); + try expect(@intFromEnum(@as(Tag(MultipleChoice), x)) == 60); } const PackedPtrOrInt = packed union { @@ -655,7 +655,7 @@ const MultipleChoice2 = union(enum(u32)) { }; fn testEnumWithSpecifiedAndUnspecifiedTagValues(x: MultipleChoice2) !void { - try expect(@enumToInt(@as(Tag(MultipleChoice2), x)) == 60); + try expect(@intFromEnum(@as(Tag(MultipleChoice2), x)) == 60); try expect(1123 == switch (x) { MultipleChoice2.A => 1, MultipleChoice2.B => 2, @@ -721,11 +721,11 @@ test "union with only 1 field casted to its enum type which has enum value speci try comptime expect(Tag(ExprTag) == comptime_int); comptime var t = @as(ExprTag, e); try expect(t == Expr.Literal); - try expect(@enumToInt(t) == 33); - try comptime expect(@enumToInt(t) == 33); + try expect(@intFromEnum(t) == 33); + try comptime expect(@intFromEnum(t) == 33); } -test "@enumToInt works on unions" { +test "@intFromEnum works on unions" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO @@ -739,9 +739,9 @@ test "@enumToInt works on unions" { const a = Bar{ .A = true }; var b = Bar{ .B = undefined }; var c = Bar.C; - try expect(@enumToInt(a) == 0); - try expect(@enumToInt(b) == 1); - try expect(@enumToInt(c) == 2); + try expect(@intFromEnum(a) == 0); + try expect(@intFromEnum(b) == 1); + try expect(@intFromEnum(c) == 2); } test "comptime union field value equality" { @@ -1396,7 +1396,7 @@ test "@unionInit uses tag value instead of field index" { var a = &u.b; try expect(a.* == i); } - try expect(@enumToInt(u) == 255); + try expect(@intFromEnum(u) == 255); } test "union field ptr - zero sized payload" { diff --git a/test/behavior/vector.zig b/test/behavior/vector.zig index 367a21fc0aab..47864a83c93e 100644 --- a/test/behavior/vector.zig +++ b/test/behavior/vector.zig @@ -1173,7 +1173,7 @@ test "byte vector initialized in inline function" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (comptime builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .x86_64 and - builtin.cpu.features.isEnabled(@enumToInt(std.Target.x86.Feature.avx512f))) + builtin.cpu.features.isEnabled(@intFromEnum(std.Target.x86.Feature.avx512f))) { // TODO https://github.com/ziglang/zig/issues/13279 return error.SkipZigTest; diff --git a/test/c_abi/main.zig b/test/c_abi/main.zig index db76697473a9..f06d45506099 100644 --- a/test/c_abi/main.zig +++ b/test/c_abi/main.zig @@ -143,11 +143,11 @@ export fn zig_longdouble(x: c_longdouble) void { extern fn c_ptr(*anyopaque) void; test "C ABI pointer" { - c_ptr(@intToPtr(*anyopaque, 0xdeadbeef)); + c_ptr(@ptrFromInt(*anyopaque, 0xdeadbeef)); } export fn zig_ptr(x: *anyopaque) void { - expect(@ptrToInt(x) == 0xdeadbeef) catch @panic("test failure: zig_ptr"); + expect(@intFromPtr(x) == 0xdeadbeef) catch @panic("test failure: zig_ptr"); } extern fn c_bool(bool) void; @@ -1058,14 +1058,14 @@ test "C function that takes byval struct called via function pointer" { var fn_ptr = &c_func_ptr_byval; fn_ptr( - @intToPtr(*anyopaque, 1), - @intToPtr(*anyopaque, 2), + @ptrFromInt(*anyopaque, 1), + @ptrFromInt(*anyopaque, 2), ByVal{ .origin = .{ .x = 9, .y = 10, .z = 11 }, .size = .{ .width = 12, .height = 13, .depth = 14 }, }, @as(c_ulong, 3), - @intToPtr(*anyopaque, 4), + @ptrFromInt(*anyopaque, 4), @as(c_ulong, 5), ); } diff --git a/test/cases/assert_function.18.zig b/test/cases/assert_function.18.zig index 5f05e4ae7014..ac0f97c40f89 100644 --- a/test/cases/assert_function.18.zig +++ b/test/cases/assert_function.18.zig @@ -7,7 +7,7 @@ pub fn main() void { } fn print() void { - _ = write(1, @ptrToInt("hello\n"), 6); + _ = write(1, @intFromPtr("hello\n"), 6); } // run diff --git a/test/cases/assert_function.7.zig b/test/cases/assert_function.7.zig index 0004435db6f3..9db604d3b9c0 100644 --- a/test/cases/assert_function.7.zig +++ b/test/cases/assert_function.7.zig @@ -7,7 +7,7 @@ pub fn main() void { } fn print() void { - _ = write(1, @ptrToInt("hello\n"), 6); + _ = write(1, @intFromPtr("hello\n"), 6); } pub fn assert(ok: bool) void { diff --git a/test/cases/assert_function.8.zig b/test/cases/assert_function.8.zig index 3e8e247dacf8..02b486a8cb2b 100644 --- a/test/cases/assert_function.8.zig +++ b/test/cases/assert_function.8.zig @@ -7,7 +7,7 @@ pub fn main() void { } fn print() void { - _ = write(1, @ptrToInt("hello\n"), 6); + _ = write(1, @intFromPtr("hello\n"), 6); } pub fn assert(ok: bool) void { diff --git a/test/cases/compile_errors/add_overflow_in_function_evaluation.zig b/test/cases/compile_errors/add_overflow_in_function_evaluation.zig index 2f8a4678d365..ef1a01671161 100644 --- a/test/cases/compile_errors/add_overflow_in_function_evaluation.zig +++ b/test/cases/compile_errors/add_overflow_in_function_evaluation.zig @@ -3,7 +3,9 @@ fn add(a: u16, b: u16) u16 { return a + b; } -export fn entry() usize { return @sizeOf(@TypeOf(y)); } +export fn entry() usize { + return @sizeOf(@TypeOf(y)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/addition_with_non_numbers.zig b/test/cases/compile_errors/addition_with_non_numbers.zig index 3687df914f25..1b60d1ba9a64 100644 --- a/test/cases/compile_errors/addition_with_non_numbers.zig +++ b/test/cases/compile_errors/addition_with_non_numbers.zig @@ -1,12 +1,14 @@ const Foo = struct { field: i32, }; -const x = Foo {.field = 1} + Foo {.field = 2}; +const x = Foo{ .field = 1 } + Foo{ .field = 2 }; -export fn entry() usize { return @sizeOf(@TypeOf(x)); } +export fn entry() usize { + return @sizeOf(@TypeOf(x)); +} // error // backend=llvm // target=native // -// :4:28: error: invalid operands to binary expression: 'Struct' and 'Struct' +// :4:29: error: invalid operands to binary expression: 'Struct' and 'Struct' diff --git a/test/cases/compile_errors/address_of_number_literal.zig b/test/cases/compile_errors/address_of_number_literal.zig index c6b41a149558..e41fbd229c49 100644 --- a/test/cases/compile_errors/address_of_number_literal.zig +++ b/test/cases/compile_errors/address_of_number_literal.zig @@ -1,12 +1,16 @@ const x = 3; const y = &x; -fn foo() *const i32 { return y; } -export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } +fn foo() *const i32 { + return y; +} +export fn entry() usize { + return @sizeOf(@TypeOf(&foo)); +} // error // backend=stage2 // target=native // -// :3:30: error: expected type '*const i32', found '*const comptime_int' -// :3:30: note: pointer type child 'comptime_int' cannot cast into pointer type child 'i32' +// :4:12: error: expected type '*const i32', found '*const comptime_int' +// :4:12: note: pointer type child 'comptime_int' cannot cast into pointer type child 'i32' // :3:10: note: function return type declared here diff --git a/test/cases/compile_errors/alignment_of_enum_field_specified.zig b/test/cases/compile_errors/alignment_of_enum_field_specified.zig index 14ffa6f499a2..ecb06aa2543b 100644 --- a/test/cases/compile_errors/alignment_of_enum_field_specified.zig +++ b/test/cases/compile_errors/alignment_of_enum_field_specified.zig @@ -1,7 +1,10 @@ +// zig fmt: off const Number = enum { a, b align(i32), }; +// zig fmt: on + export fn entry1() void { var x: Number = undefined; _ = x; @@ -11,4 +14,4 @@ export fn entry1() void { // backend=stage2 // target=native // -// :3:13: error: enum fields cannot be aligned +// :4:13: error: enum fields cannot be aligned diff --git a/test/cases/compile_errors/array_concatenation_with_wrong_type.zig b/test/cases/compile_errors/array_concatenation_with_wrong_type.zig index 6f2648f74b2e..5c634eceb098 100644 --- a/test/cases/compile_errors/array_concatenation_with_wrong_type.zig +++ b/test/cases/compile_errors/array_concatenation_with_wrong_type.zig @@ -2,7 +2,9 @@ const src = "aoeu"; const derp: usize = 1234; const a = derp ++ "foo"; -export fn entry() usize { return @sizeOf(@TypeOf(a)); } +export fn entry() usize { + return @sizeOf(@TypeOf(a)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/array_mult_with_number_type.zig b/test/cases/compile_errors/array_mult_with_number_type.zig index d3ec870f4e86..bd47c3b56f7b 100644 --- a/test/cases/compile_errors/array_mult_with_number_type.zig +++ b/test/cases/compile_errors/array_mult_with_number_type.zig @@ -7,4 +7,4 @@ export fn entry(base: f32, exponent: f32) f32 { // target=native // // :2:12: error: expected indexable; found 'f32' -// :2:17: note: this operator multiplies arrays; use std.math.pow for exponentiation \ No newline at end of file +// :2:17: note: this operator multiplies arrays; use std.math.pow for exponentiation diff --git a/test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig b/test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig index 857123eae55d..b16cb8f66e63 100644 --- a/test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig +++ b/test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig @@ -2,7 +2,7 @@ export fn entry() void { var a = &b; _ = a; } -fn b() callconv(.Inline) void { } +inline fn b() void {} // error // backend=stage2 diff --git a/test/cases/compile_errors/assign_null_to_non-optional_pointer.zig b/test/cases/compile_errors/assign_null_to_non-optional_pointer.zig index ca36dbfbfbdf..cc410e62289a 100644 --- a/test/cases/compile_errors/assign_null_to_non-optional_pointer.zig +++ b/test/cases/compile_errors/assign_null_to_non-optional_pointer.zig @@ -1,6 +1,8 @@ const a: *u8 = null; -export fn entry() usize { return @sizeOf(@TypeOf(a)); } +export fn entry() usize { + return @sizeOf(@TypeOf(a)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/assign_through_constant_pointer.zig b/test/cases/compile_errors/assign_through_constant_pointer.zig index 674d0875aa6a..7cc7a4b6ab4c 100644 --- a/test/cases/compile_errors/assign_through_constant_pointer.zig +++ b/test/cases/compile_errors/assign_through_constant_pointer.zig @@ -1,10 +1,10 @@ export fn f() void { - var cstr = "Hat"; - cstr[0] = 'W'; + var cstr = "Hat"; + cstr[0] = 'W'; } // error // backend=stage2 // target=native // -// :3:7: error: cannot assign to constant +// :3:9: error: cannot assign to constant diff --git a/test/cases/compile_errors/assign_through_constant_slice.zig b/test/cases/compile_errors/assign_through_constant_slice.zig index 08910b624838..9ac006a1a458 100644 --- a/test/cases/compile_errors/assign_through_constant_slice.zig +++ b/test/cases/compile_errors/assign_through_constant_slice.zig @@ -1,10 +1,10 @@ export fn f() void { - var cstr: []const u8 = "Hat"; - cstr[0] = 'W'; + var cstr: []const u8 = "Hat"; + cstr[0] = 'W'; } // error // backend=stage2 // target=native // -// :3:7: error: cannot assign to constant +// :3:9: error: cannot assign to constant diff --git a/test/cases/compile_errors/assign_to_constant_field.zig b/test/cases/compile_errors/assign_to_constant_field.zig index 33f08344c4ca..312ff44e0ea4 100644 --- a/test/cases/compile_errors/assign_to_constant_field.zig +++ b/test/cases/compile_errors/assign_to_constant_field.zig @@ -2,7 +2,9 @@ const Foo = struct { field: i32, }; export fn derp() void { - const f = Foo {.field = 1234,}; + const f = Foo{ + .field = 1234, + }; f.field = 0; } @@ -10,4 +12,4 @@ export fn derp() void { // backend=stage2 // target=native // -// :6:6: error: cannot assign to constant +// :8:6: error: cannot assign to constant diff --git a/test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig b/test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig index d8ab4087e0a3..82cbb4469aaf 100644 --- a/test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig +++ b/test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig @@ -3,7 +3,7 @@ export fn entry() void { var bytes: [100]u8 align(16) = undefined; _ = @asyncCall(&bytes, {}, ptr, .{}); } -fn afunc() void { } +fn afunc() void {} // error // backend=stage1 diff --git a/test/cases/compile_errors/async/prevent_bad_implicit_casting_of_anyframe_types.zig b/test/cases/compile_errors/async/prevent_bad_implicit_casting_of_anyframe_types.zig index 066bf1c10787..bdf7bec45816 100644 --- a/test/cases/compile_errors/async/prevent_bad_implicit_casting_of_anyframe_types.zig +++ b/test/cases/compile_errors/async/prevent_bad_implicit_casting_of_anyframe_types.zig @@ -21,4 +21,4 @@ fn func() void {} // // :3:28: error: expected type 'anyframe->i32', found 'anyframe' // :8:28: error: expected type 'anyframe->i32', found 'i32' -// tmp.zig:13:29: error: expected type 'anyframe->i32', found '*@Frame(func)' \ No newline at end of file +// tmp.zig:13:29: error: expected type 'anyframe->i32', found '*@Frame(func)' diff --git a/test/cases/compile_errors/async/runtime-known_function_called_with_async_keyword.zig b/test/cases/compile_errors/async/runtime-known_function_called_with_async_keyword.zig index c66d0f9cbb55..bfc22cca255d 100644 --- a/test/cases/compile_errors/async/runtime-known_function_called_with_async_keyword.zig +++ b/test/cases/compile_errors/async/runtime-known_function_called_with_async_keyword.zig @@ -3,7 +3,7 @@ export fn entry() void { _ = async ptr(); } -fn afunc() callconv(.Async) void { } +fn afunc() callconv(.Async) void {} // error // backend=stage1 diff --git a/test/cases/compile_errors/bad_alignCast_at_comptime.zig b/test/cases/compile_errors/bad_alignCast_at_comptime.zig index 0d2d91ece378..885700ecac8e 100644 --- a/test/cases/compile_errors/bad_alignCast_at_comptime.zig +++ b/test/cases/compile_errors/bad_alignCast_at_comptime.zig @@ -1,5 +1,5 @@ comptime { - const ptr = @intToPtr(*align(1) i32, 0x1); + const ptr = @ptrFromInt(*align(1) i32, 0x1); const aligned = @alignCast(4, ptr); _ = aligned; } diff --git a/test/cases/compile_errors/bad_import.zig b/test/cases/compile_errors/bad_import.zig index e624d7104c68..521331e345e5 100644 --- a/test/cases/compile_errors/bad_import.zig +++ b/test/cases/compile_errors/bad_import.zig @@ -1,4 +1,6 @@ -const bogus = @import("bogus-does-not-exist.zig",); +const bogus = @import( + "bogus-does-not-exist.zig", +); // error // backend=stage2 diff --git a/test/cases/compile_errors/binary_not_on_number_literal.zig b/test/cases/compile_errors/binary_not_on_number_literal.zig index cb57ca9ee151..455b79130a59 100644 --- a/test/cases/compile_errors/binary_not_on_number_literal.zig +++ b/test/cases/compile_errors/binary_not_on_number_literal.zig @@ -2,7 +2,9 @@ const TINY_QUANTUM_SHIFT = 4; const TINY_QUANTUM_SIZE = 1 << TINY_QUANTUM_SHIFT; var block_aligned_stuff: usize = (4 + TINY_QUANTUM_SIZE) & ~(TINY_QUANTUM_SIZE - 1); -export fn entry() usize { return @sizeOf(@TypeOf(block_aligned_stuff)); } +export fn entry() usize { + return @sizeOf(@TypeOf(block_aligned_stuff)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/bitCast_to_enum_type.zig b/test/cases/compile_errors/bitCast_to_enum_type.zig index a8fedb7d5462..b3bc72c21b96 100644 --- a/test/cases/compile_errors/bitCast_to_enum_type.zig +++ b/test/cases/compile_errors/bitCast_to_enum_type.zig @@ -9,4 +9,4 @@ export fn entry() void { // target=native // // :3:24: error: cannot @bitCast to 'tmp.entry.E' -// :3:24: note: use @intToEnum to cast from 'u32' +// :3:24: note: use @enumFromInt to cast from 'u32' diff --git a/test/cases/compile_errors/bogus_compile_var.zig b/test/cases/compile_errors/bogus_compile_var.zig index be222e539349..4780423caecf 100644 --- a/test/cases/compile_errors/bogus_compile_var.zig +++ b/test/cases/compile_errors/bogus_compile_var.zig @@ -1,5 +1,7 @@ const x = @import("builtin").bogus; -export fn entry() usize { return @sizeOf(@TypeOf(x)); } +export fn entry() usize { + return @sizeOf(@TypeOf(x)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/bogus_method_call_on_slice.zig b/test/cases/compile_errors/bogus_method_call_on_slice.zig index ed18f43f48bf..694993074c4a 100644 --- a/test/cases/compile_errors/bogus_method_call_on_slice.zig +++ b/test/cases/compile_errors/bogus_method_call_on_slice.zig @@ -2,7 +2,9 @@ var self = "aoeu"; fn f(m: []const u8) void { m.copy(u8, self[0..], m); } -export fn entry() usize { return @sizeOf(@TypeOf(&f)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&f)); +} pub export fn entry1() void { .{}.bar(); } @@ -14,6 +16,6 @@ pub export fn entry2() void { // backend=stage2 // target=native // -// :7:8: error: no field or member function named 'bar' in '@TypeOf(.{})' -// :10:18: error: no field or member function named 'bar' in 'struct{comptime foo: comptime_int = 1}' +// :9:8: error: no field or member function named 'bar' in '@TypeOf(.{})' +// :12:18: error: no field or member function named 'bar' in 'struct{comptime foo: comptime_int = 1}' // :3:6: error: no field or member function named 'copy' in '[]const u8' diff --git a/test/cases/compile_errors/branch_on_undefined_value.zig b/test/cases/compile_errors/branch_on_undefined_value.zig index a0a3be83cfa4..fc30fe7d3c93 100644 --- a/test/cases/compile_errors/branch_on_undefined_value.zig +++ b/test/cases/compile_errors/branch_on_undefined_value.zig @@ -1,6 +1,8 @@ const x = if (undefined) true else false; -export fn entry() usize { return @sizeOf(@TypeOf(x)); } +export fn entry() usize { + return @sizeOf(@TypeOf(x)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/calling_function_with_naked_calling_convention.zig b/test/cases/compile_errors/calling_function_with_naked_calling_convention.zig index 54bf58542542..2bd0364d4f8e 100644 --- a/test/cases/compile_errors/calling_function_with_naked_calling_convention.zig +++ b/test/cases/compile_errors/calling_function_with_naked_calling_convention.zig @@ -1,7 +1,7 @@ export fn entry() void { foo(); } -fn foo() callconv(.Naked) void { } +fn foo() callconv(.Naked) void {} // error // backend=llvm diff --git a/test/cases/compile_errors/calling_var_args_extern_function_passing_array_instead_of_pointer.zig b/test/cases/compile_errors/calling_var_args_extern_function_passing_array_instead_of_pointer.zig index c9e2e2e5eb82..0960c3507457 100644 --- a/test/cases/compile_errors/calling_var_args_extern_function_passing_array_instead_of_pointer.zig +++ b/test/cases/compile_errors/calling_var_args_extern_function_passing_array_instead_of_pointer.zig @@ -1,5 +1,7 @@ export fn entry() void { - foo("hello".*,); + foo( + "hello".*, + ); } pub extern fn foo(format: *const u8, ...) void; @@ -7,5 +9,5 @@ pub extern fn foo(format: *const u8, ...) void; // backend=stage2 // target=native // -// :2:16: error: expected type '*const u8', found '[5:0]u8' -// :4:27: note: parameter type declared here +// :3:16: error: expected type '*const u8', found '[5:0]u8' +// :6:27: note: parameter type declared here diff --git a/test/cases/compile_errors/cast_unreachable.zig b/test/cases/compile_errors/cast_unreachable.zig index cf2331ff7e5f..39da655d7fe1 100644 --- a/test/cases/compile_errors/cast_unreachable.zig +++ b/test/cases/compile_errors/cast_unreachable.zig @@ -1,7 +1,9 @@ fn f() i32 { return @as(i32, return 1); } -export fn entry() void { _ = f(); } +export fn entry() void { + _ = f(); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig b/test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig index f9df19802ade..8cf62c8ec0d8 100644 --- a/test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig +++ b/test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig @@ -12,7 +12,9 @@ fn bar(x: *const u3) u3 { return x.*; } -export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&foo)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/colliding_invalid_top_level_functions.zig b/test/cases/compile_errors/colliding_invalid_top_level_functions.zig index ee0711088d92..8a2adb2f0778 100644 --- a/test/cases/compile_errors/colliding_invalid_top_level_functions.zig +++ b/test/cases/compile_errors/colliding_invalid_top_level_functions.zig @@ -1,6 +1,8 @@ fn func() bogus {} fn func() bogus {} -export fn entry() usize { return @sizeOf(@TypeOf(func)); } +export fn entry() usize { + return @sizeOf(@TypeOf(func)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/compileError_shows_traceback_of_references_that_caused_it.zig b/test/cases/compile_errors/compileError_shows_traceback_of_references_that_caused_it.zig index 092cbbd40034..d5206671fba8 100644 --- a/test/cases/compile_errors/compileError_shows_traceback_of_references_that_caused_it.zig +++ b/test/cases/compile_errors/compileError_shows_traceback_of_references_that_caused_it.zig @@ -1,4 +1,6 @@ -const foo = @compileError("aoeu",); +const foo = @compileError( + "aoeu", +); const bar = baz + foo; const baz = 1; diff --git a/test/cases/compile_errors/compile_log_statement_warning_deduplication_in_generic_fn.zig b/test/cases/compile_errors/compile_log_statement_warning_deduplication_in_generic_fn.zig index 4b31d9924a5c..2e2addbc2e1a 100644 --- a/test/cases/compile_errors/compile_log_statement_warning_deduplication_in_generic_fn.zig +++ b/test/cases/compile_errors/compile_log_statement_warning_deduplication_in_generic_fn.zig @@ -4,15 +4,17 @@ export fn entry() void { } fn inner(comptime n: usize) void { comptime var i = 0; - inline while (i < n) : (i += 1) { @compileLog("!@#$"); } + inline while (i < n) : (i += 1) { + @compileLog("!@#$"); + } } // error // backend=llvm // target=native // -// :7:39: error: found compile log statement -// :7:39: note: also here +// :8:9: error: found compile log statement +// :8:9: note: also here // // Compile Log Output: // @as(*const [4:0]u8, "!@#$") diff --git a/test/cases/compile_errors/compile_time_division_by_zero.zig b/test/cases/compile_errors/compile_time_division_by_zero.zig index 281ccf28a1d4..8954ace9ab1e 100644 --- a/test/cases/compile_errors/compile_time_division_by_zero.zig +++ b/test/cases/compile_errors/compile_time_division_by_zero.zig @@ -3,7 +3,9 @@ fn foo(x: u32) u32 { return 1 / x; } -export fn entry() usize { return @sizeOf(@TypeOf(y)); } +export fn entry() usize { + return @sizeOf(@TypeOf(y)); +} // error // backend=llvm diff --git a/test/cases/compile_errors/comptime_call_of_function_pointer.zig b/test/cases/compile_errors/comptime_call_of_function_pointer.zig index cf01f5ea2ca4..d6598aab3929 100644 --- a/test/cases/compile_errors/comptime_call_of_function_pointer.zig +++ b/test/cases/compile_errors/comptime_call_of_function_pointer.zig @@ -1,5 +1,5 @@ export fn entry() void { - const fn_ptr = @intToPtr(*align(1) fn () void, 0xffd2); + const fn_ptr = @ptrFromInt(*align(1) fn () void, 0xffd2); comptime fn_ptr(); } diff --git a/test/cases/compile_errors/comptime_if_inside_runtime_for.zig b/test/cases/compile_errors/comptime_if_inside_runtime_for.zig index 6200776d1892..40055a70b9b8 100644 --- a/test/cases/compile_errors/comptime_if_inside_runtime_for.zig +++ b/test/cases/compile_errors/comptime_if_inside_runtime_for.zig @@ -1,14 +1,14 @@ export fn entry() void { - var x: u32 = 0; - for(0..1, 1..2) |_, _| { - var y = x + if(x == 0) 1 else 0; - _ = y; - } + var x: u32 = 0; + for (0..1, 1..2) |_, _| { + var y = x + if (x == 0) 1 else 0; + _ = y; + } } // error // backend=stage2 // target=native // -// :4:15: error: value with comptime-only type 'comptime_int' depends on runtime control flow -// :3:6: note: runtime control flow here +// :4:21: error: value with comptime-only type 'comptime_int' depends on runtime control flow +// :3:10: note: runtime control flow here diff --git a/test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig b/test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig index 2b67390b05b2..1ce744d6d7e0 100644 --- a/test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig +++ b/test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig @@ -1,7 +1,9 @@ const ContextAllocator = MemoryPool(usize); pub fn MemoryPool(comptime T: type) type { - const free_list_t = @compileError("aoeu",); + const free_list_t = @compileError( + "aoeu", + ); _ = T; return struct { diff --git a/test/cases/compile_errors/container_init_with_non-type.zig b/test/cases/compile_errors/container_init_with_non-type.zig index aa62be6dc5a0..7bdf07a1cefe 100644 --- a/test/cases/compile_errors/container_init_with_non-type.zig +++ b/test/cases/compile_errors/container_init_with_non-type.zig @@ -1,7 +1,9 @@ const zero: i32 = 0; const a = zero{1}; -export fn entry() usize { return @sizeOf(@TypeOf(a)); } +export fn entry() usize { + return @sizeOf(@TypeOf(a)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/control_flow_uses_comptime_var_at_runtime.zig b/test/cases/compile_errors/control_flow_uses_comptime_var_at_runtime.zig index a8058e8c758d..5283239af6a7 100644 --- a/test/cases/compile_errors/control_flow_uses_comptime_var_at_runtime.zig +++ b/test/cases/compile_errors/control_flow_uses_comptime_var_at_runtime.zig @@ -5,7 +5,7 @@ export fn foo() void { } } -fn bar() void { } +fn bar() void {} export fn baz() void { comptime var idx: u32 = 0; while (idx < 1) { diff --git a/test/cases/compile_errors/dereference_an_array.zig b/test/cases/compile_errors/dereference_an_array.zig index f5aabf081c5a..27e4d81e5550 100644 --- a/test/cases/compile_errors/dereference_an_array.zig +++ b/test/cases/compile_errors/dereference_an_array.zig @@ -5,7 +5,9 @@ pub fn pass(in: []u8) []u8 { return out.*[0..1]; } -export fn entry() usize { return @sizeOf(@TypeOf(&pass)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&pass)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/direct_struct_loop.zig b/test/cases/compile_errors/direct_struct_loop.zig index 0abc1a4f73b0..9fdda1bdc706 100644 --- a/test/cases/compile_errors/direct_struct_loop.zig +++ b/test/cases/compile_errors/direct_struct_loop.zig @@ -1,9 +1,13 @@ -const A = struct { a : A, }; -export fn entry() usize { return @sizeOf(A); } +const A = struct { + a: A, +}; +export fn entry() usize { + return @sizeOf(A); +} // error // backend=stage2 // target=native // // :1:11: error: struct 'tmp.A' depends on itself -// :1:20: note: while checking this field +// :2:5: note: while checking this field diff --git a/test/cases/compile_errors/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig b/test/cases/compile_errors/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig index 3670def4eec8..45fa4c14f5e8 100644 --- a/test/cases/compile_errors/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig +++ b/test/cases/compile_errors/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig @@ -1,6 +1,6 @@ extern fn puts(s: [*:0]const u8) c_int; pub export fn entry() void { - const no_zero_array = [_]u8{'h', 'e', 'l', 'l', 'o'}; + const no_zero_array = [_]u8{ 'h', 'e', 'l', 'l', 'o' }; const no_zero_ptr: [*]const u8 = &no_zero_array; _ = puts(no_zero_ptr); } diff --git a/test/cases/compile_errors/division_by_zero.zig b/test/cases/compile_errors/division_by_zero.zig index 2e2f7e2be2a7..3019554fb83a 100644 --- a/test/cases/compile_errors/division_by_zero.zig +++ b/test/cases/compile_errors/division_by_zero.zig @@ -3,10 +3,18 @@ const lit_float_x = 1.0 / 0.0; const int_x = @as(u32, 1) / @as(u32, 0); const float_x = @as(f32, 1.0) / @as(f32, 0.0); -export fn entry1() usize { return @sizeOf(@TypeOf(lit_int_x)); } -export fn entry2() usize { return @sizeOf(@TypeOf(lit_float_x)); } -export fn entry3() usize { return @sizeOf(@TypeOf(int_x)); } -export fn entry4() usize { return @sizeOf(@TypeOf(float_x)); } // no error on purpose +export fn entry1() usize { + return @sizeOf(@TypeOf(lit_int_x)); +} +export fn entry2() usize { + return @sizeOf(@TypeOf(lit_float_x)); +} +export fn entry3() usize { + return @sizeOf(@TypeOf(int_x)); +} +export fn entry4() usize { + return @sizeOf(@TypeOf(float_x)); +} // no error on purpose // error // backend=stage2 diff --git a/test/cases/compile_errors/duplicate-unused_labels.zig b/test/cases/compile_errors/duplicate-unused_labels.zig index 4bfc6c596012..301d273bde42 100644 --- a/test/cases/compile_errors/duplicate-unused_labels.zig +++ b/test/cases/compile_errors/duplicate-unused_labels.zig @@ -1,31 +1,37 @@ comptime { - blk: { blk: while (false) {} } + blk: { + blk: while (false) {} + } } comptime { - blk: while (false) { blk: for (@as([0]void, undefined)) |_| {} } + blk: while (false) { + blk: for (@as([0]void, undefined)) |_| {} + } } comptime { - blk: for (@as([0]void, undefined)) |_| { blk: {} } + blk: for (@as([0]void, undefined)) |_| { + blk: {} + } } comptime { blk: {} } comptime { - blk: while(false) {} + blk: while (false) {} } comptime { - blk: for(@as([0]void, undefined)) |_| {} + blk: for (@as([0]void, undefined)) |_| {} } // error // target=native // -// :2:12: error: redefinition of label 'blk' +// :3:9: error: redefinition of label 'blk' // :2:5: note: previous definition here -// :5:26: error: redefinition of label 'blk' -// :5:5: note: previous definition here -// :8:46: error: redefinition of label 'blk' -// :8:5: note: previous definition here -// :11:5: error: unused block label -// :14:5: error: unused while loop label -// :17:5: error: unused for loop label +// :8:9: error: redefinition of label 'blk' +// :7:5: note: previous definition here +// :13:9: error: redefinition of label 'blk' +// :12:5: note: previous definition here +// :17:5: error: unused block label +// :20:5: error: unused while loop label +// :23:5: error: unused for loop label diff --git a/test/cases/compile_errors/duplicate_error_value_in_error_set.zig b/test/cases/compile_errors/duplicate_error_value_in_error_set.zig index 5e9cddb975d8..927537d952ce 100644 --- a/test/cases/compile_errors/duplicate_error_value_in_error_set.zig +++ b/test/cases/compile_errors/duplicate_error_value_in_error_set.zig @@ -1,4 +1,4 @@ -const Foo = error { +const Foo = error{ Bar, Bar, }; diff --git a/test/cases/compile_errors/duplicate_field_in_struct_value_expression.zig b/test/cases/compile_errors/duplicate_field_in_struct_value_expression.zig index fa5bc6fb4e31..eda001c086cb 100644 --- a/test/cases/compile_errors/duplicate_field_in_struct_value_expression.zig +++ b/test/cases/compile_errors/duplicate_field_in_struct_value_expression.zig @@ -1,10 +1,10 @@ const A = struct { - x : i32, - y : i32, - z : i32, + x: i32, + y: i32, + z: i32, }; export fn f() void { - const a = A { + const a = A{ .z = 1, .y = 2, .x = 3, diff --git a/test/cases/compile_errors/embedFile_with_bogus_file.zig b/test/cases/compile_errors/embedFile_with_bogus_file.zig index fa05d1ed4909..956ea31f07b0 100644 --- a/test/cases/compile_errors/embedFile_with_bogus_file.zig +++ b/test/cases/compile_errors/embedFile_with_bogus_file.zig @@ -1,6 +1,8 @@ -const resource = @embedFile("bogus.txt",); +const resource = @embedFile("bogus.txt"); -export fn entry() usize { return @sizeOf(@TypeOf(resource)); } +export fn entry() usize { + return @sizeOf(@TypeOf(resource)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/empty_switch_on_an_integer.zig b/test/cases/compile_errors/empty_switch_on_an_integer.zig index de4d7e9c652d..6ba69f8d3e87 100644 --- a/test/cases/compile_errors/empty_switch_on_an_integer.zig +++ b/test/cases/compile_errors/empty_switch_on_an_integer.zig @@ -1,6 +1,6 @@ export fn entry() void { var x: u32 = 0; - switch(x) {} + switch (x) {} } // error diff --git a/test/cases/compile_errors/intToEnum_on_non-exhaustive_enums_checks_int_in_range.zig b/test/cases/compile_errors/enumFromInt_on_non-exhaustive_enums_checks_int_in_range.zig similarity index 85% rename from test/cases/compile_errors/intToEnum_on_non-exhaustive_enums_checks_int_in_range.zig rename to test/cases/compile_errors/enumFromInt_on_non-exhaustive_enums_checks_int_in_range.zig index b05c9f35d9ef..dfef66b6284b 100644 --- a/test/cases/compile_errors/intToEnum_on_non-exhaustive_enums_checks_int_in_range.zig +++ b/test/cases/compile_errors/enumFromInt_on_non-exhaustive_enums_checks_int_in_range.zig @@ -1,6 +1,6 @@ pub export fn entry() void { const E = enum(u3) { a, b, c, _ }; - @compileLog(@intToEnum(E, 100)); + @compileLog(@enumFromInt(E, 100)); } // error diff --git a/test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig b/test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig index e79f6d478f97..0cf9fcce0112 100644 --- a/test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig +++ b/test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig @@ -3,7 +3,7 @@ const Foo = enum(u32) { B = 11, }; export fn entry() void { - var x = @intToEnum(Foo, 0); + var x = @enumFromInt(Foo, 0); _ = x; } diff --git a/test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig b/test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig index f23718c2ca57..fb55a733e522 100644 --- a/test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig +++ b/test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig @@ -1,5 +1,8 @@ export fn entry() void { - _ = @Type(@typeInfo(enum { foo, const bar = 1; })); + _ = @Type(@typeInfo(enum { + foo, + const bar = 1; + })); } // error diff --git a/test/cases/compile_errors/error_not_handled_in_switch.zig b/test/cases/compile_errors/error_not_handled_in_switch.zig index 8f0d26a4a92b..04f122b11d24 100644 --- a/test/cases/compile_errors/error_not_handled_in_switch.zig +++ b/test/cases/compile_errors/error_not_handled_in_switch.zig @@ -5,9 +5,9 @@ export fn entry() void { } fn foo(x: i32) !void { switch (x) { - 0 ... 10 => return error.Foo, - 11 ... 20 => return error.Bar, - 21 ... 30 => return error.Baz, + 0...10 => return error.Foo, + 11...20 => return error.Bar, + 21...30 => return error.Baz, else => {}, } } diff --git a/test/cases/compile_errors/error_note_for_function_parameter_incompatibility.zig b/test/cases/compile_errors/error_note_for_function_parameter_incompatibility.zig index 76543697a42d..bbf8bcfa4091 100644 --- a/test/cases/compile_errors/error_note_for_function_parameter_incompatibility.zig +++ b/test/cases/compile_errors/error_note_for_function_parameter_incompatibility.zig @@ -1,5 +1,9 @@ -fn do_the_thing(func: *const fn (arg: i32) void) void { _ = func; } -fn bar(arg: bool) void { _ = arg; } +fn do_the_thing(func: *const fn (arg: i32) void) void { + _ = func; +} +fn bar(arg: bool) void { + _ = arg; +} export fn entry() void { do_the_thing(bar); } @@ -8,6 +12,6 @@ export fn entry() void { // backend=stage2 // target=native // -// :4:18: error: expected type '*const fn(i32) void', found '*const fn(bool) void' -// :4:18: note: pointer type child 'fn(bool) void' cannot cast into pointer type child 'fn(i32) void' -// :4:18: note: parameter 0 'bool' cannot cast into 'i32' +// :8:18: error: expected type '*const fn(i32) void', found '*const fn(bool) void' +// :8:18: note: pointer type child 'fn(bool) void' cannot cast into pointer type child 'fn(i32) void' +// :8:18: note: parameter 0 'bool' cannot cast into 'i32' diff --git a/test/cases/compile_errors/explicitly_casting_non_tag_type_to_enum.zig b/test/cases/compile_errors/explicitly_casting_non_tag_type_to_enum.zig index aac876e61476..6ae39489a0d8 100644 --- a/test/cases/compile_errors/explicitly_casting_non_tag_type_to_enum.zig +++ b/test/cases/compile_errors/explicitly_casting_non_tag_type_to_enum.zig @@ -7,7 +7,7 @@ const Small = enum(u2) { export fn entry() void { var y = @as(f32, 3); - var x = @intToEnum(Small, y); + var x = @enumFromInt(Small, y); _ = x; } @@ -15,4 +15,4 @@ export fn entry() void { // backend=stage2 // target=native // -// :10:31: error: expected integer type, found 'f32' +// :10:33: error: expected integer type, found 'f32' diff --git a/test/cases/compile_errors/export_function_with_comptime_parameter.zig b/test/cases/compile_errors/export_function_with_comptime_parameter.zig index 4491a98e9cb0..8d5dbef1c36c 100644 --- a/test/cases/compile_errors/export_function_with_comptime_parameter.zig +++ b/test/cases/compile_errors/export_function_with_comptime_parameter.zig @@ -1,4 +1,4 @@ -export fn foo(comptime x: anytype, y: i32) i32{ +export fn foo(comptime x: anytype, y: i32) i32 { return x + y; } diff --git a/test/cases/compile_errors/export_with_empty_name_string.zig b/test/cases/compile_errors/export_with_empty_name_string.zig index f199c2632c05..9f3b215bc216 100644 --- a/test/cases/compile_errors/export_with_empty_name_string.zig +++ b/test/cases/compile_errors/export_with_empty_name_string.zig @@ -1,4 +1,4 @@ -pub export fn entry() void { } +pub export fn entry() void {} comptime { @export(entry, .{ .name = "" }); } diff --git a/test/cases/compile_errors/extern_function_pointer_mismatch.zig b/test/cases/compile_errors/extern_function_pointer_mismatch.zig index f10a3dbdb3b9..f4371303fbde 100644 --- a/test/cases/compile_errors/extern_function_pointer_mismatch.zig +++ b/test/cases/compile_errors/extern_function_pointer_mismatch.zig @@ -1,13 +1,21 @@ -const fns = [_](fn(i32)i32) { a, b, c }; -pub fn a(x: i32) i32 {return x + 0;} -pub fn b(x: i32) i32 {return x + 1;} -export fn c(x: i32) i32 {return x + 2;} +const fns = [_](fn (i32) i32){ a, b, c }; +pub fn a(x: i32) i32 { + return x + 0; +} +pub fn b(x: i32) i32 { + return x + 1; +} +export fn c(x: i32) i32 { + return x + 2; +} -export fn entry() usize { return @sizeOf(@TypeOf(fns)); } +export fn entry() usize { + return @sizeOf(@TypeOf(fns)); +} // error // backend=stage2 // target=native // -// :1:37: error: expected type 'fn(i32) i32', found 'fn(i32) callconv(.C) i32' -// :1:37: note: calling convention 'C' cannot cast into calling convention 'Unspecified' +// :1:38: error: expected type 'fn(i32) i32', found 'fn(i32) callconv(.C) i32' +// :1:38: note: calling convention 'C' cannot cast into calling convention 'Unspecified' diff --git a/test/cases/compile_errors/extern_function_with_comptime_parameter.zig b/test/cases/compile_errors/extern_function_with_comptime_parameter.zig index 8ade9ca2aaec..fac09cc26519 100644 --- a/test/cases/compile_errors/extern_function_with_comptime_parameter.zig +++ b/test/cases/compile_errors/extern_function_with_comptime_parameter.zig @@ -4,9 +4,15 @@ fn f() i32 { } pub extern fn entry1(b: u32, comptime a: [2]u8, c: i32) void; pub extern fn entry2(b: u32, noalias a: anytype, i43) void; -comptime { _ = &f; } -comptime { _ = &entry1; } -comptime { _ = &entry2; } +comptime { + _ = &f; +} +comptime { + _ = &entry1; +} +comptime { + _ = &entry2; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig b/test/cases/compile_errors/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig index 6484e301a9cc..2faa7c871318 100644 --- a/test/cases/compile_errors/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig +++ b/test/cases/compile_errors/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig @@ -1,3 +1,4 @@ +// zig fmt: off pub const E = enum { @"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12", @"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23", @@ -27,6 +28,7 @@ pub const E = enum { @"245",@"246",@"247",@"248",@"249",@"250",@"251",@"252",@"253", @"254",@"255", @"256" }; +// zig fmt: on pub const S = extern struct { e: E, }; @@ -39,7 +41,7 @@ export fn entry() void { // backend=stage2 // target=native // -// :31:8: error: extern structs cannot contain fields of type 'tmp.E' -// :31:8: note: enum tag type 'u9' is not extern compatible -// :31:8: note: only integers with power of two bits are extern compatible -// :1:15: note: enum declared here +// :33:8: error: extern structs cannot contain fields of type 'tmp.E' +// :33:8: note: enum tag type 'u9' is not extern compatible +// :33:8: note: only integers with power of two bits are extern compatible +// :2:15: note: enum declared here diff --git a/test/cases/compile_errors/extern_union_field_missing_type.zig b/test/cases/compile_errors/extern_union_field_missing_type.zig index 6890e65714c4..fde58f69e5e2 100644 --- a/test/cases/compile_errors/extern_union_field_missing_type.zig +++ b/test/cases/compile_errors/extern_union_field_missing_type.zig @@ -2,7 +2,7 @@ const Letter = extern union { A, }; export fn entry() void { - var a = Letter { .A = {} }; + var a = Letter{ .A = {} }; _ = a; } diff --git a/test/cases/compile_errors/extern_union_given_enum_tag_type.zig b/test/cases/compile_errors/extern_union_given_enum_tag_type.zig index 6a691eb2e2f5..4aa0e623c796 100644 --- a/test/cases/compile_errors/extern_union_given_enum_tag_type.zig +++ b/test/cases/compile_errors/extern_union_given_enum_tag_type.zig @@ -9,7 +9,7 @@ const Payload = extern union(Letter) { C: bool, }; export fn entry() void { - var a = Payload { .A = 1234 }; + var a = Payload{ .A = 1234 }; _ = a; } diff --git a/test/cases/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig b/test/cases/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig index 7f57268f0645..9fc8038d7a35 100644 --- a/test/cases/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig +++ b/test/cases/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig @@ -2,10 +2,13 @@ const Foo = struct { a: i32, b: i32, }; -const foo = Foo { .a = 1, .b = 2, }; +const foo = Foo{ + .a = 1, + .b = 2, +}; comptime { - const field_ptr = @intToPtr(*i32, 0x1234); + const field_ptr = @ptrFromInt(*i32, 0x1234); const another_foo_ptr = @fieldParentPtr(Foo, "b", field_ptr); _ = another_foo_ptr; } @@ -14,4 +17,4 @@ comptime { // backend=stage2 // target=native // -// :9:55: error: pointer value not based on parent struct +// :12:55: error: pointer value not based on parent struct diff --git a/test/cases/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig b/test/cases/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig index a73409aea336..7a37eb2adcdf 100644 --- a/test/cases/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig +++ b/test/cases/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig @@ -2,7 +2,10 @@ const Foo = struct { a: i32, b: i32, }; -const foo = Foo { .a = 1, .b = 2, }; +const foo = Foo{ + .a = 1, + .b = 2, +}; comptime { const another_foo_ptr = @fieldParentPtr(Foo, "b", &foo.a); @@ -13,5 +16,5 @@ comptime { // backend=stage2 // target=native // -// :8:29: error: field 'b' has index '1' but pointer value is index '0' of struct 'tmp.Foo' +// :11:29: error: field 'b' has index '1' but pointer value is index '0' of struct 'tmp.Foo' // :1:13: note: struct declared here diff --git a/test/cases/compile_errors/floatToInt_comptime_safety.zig b/test/cases/compile_errors/floatToInt_comptime_safety.zig deleted file mode 100644 index 068d8e2d8938..000000000000 --- a/test/cases/compile_errors/floatToInt_comptime_safety.zig +++ /dev/null @@ -1,17 +0,0 @@ -comptime { - _ = @floatToInt(i8, @as(f32, -129.1)); -} -comptime { - _ = @floatToInt(u8, @as(f32, -1.1)); -} -comptime { - _ = @floatToInt(u8, @as(f32, 256.1)); -} - -// error -// backend=stage2 -// target=native -// -// :2:25: error: float value '-129.10000610351562' cannot be stored in integer type 'i8' -// :5:25: error: float value '-1.100000023841858' cannot be stored in integer type 'u8' -// :8:25: error: float value '256.1000061035156' cannot be stored in integer type 'u8' diff --git a/test/cases/compile_errors/for.zig b/test/cases/compile_errors/for.zig index 435bb68607f5..568c416062f1 100644 --- a/test/cases/compile_errors/for.zig +++ b/test/cases/compile_errors/for.zig @@ -1,13 +1,15 @@ export fn a() void { for (0..10, 10..21) |i, j| { - _ = i; _ = j; + _ = i; + _ = j; } } export fn b() void { const s1 = "hello"; const s2 = true; for (s1, s2) |i, j| { - _ = i; _ = j; + _ = i; + _ = j; } } export fn c() void { @@ -20,7 +22,9 @@ export fn d() void { const x: [*]const u8 = "hello"; const y: [*]const u8 = "world"; for (x, 0.., y) |x1, x2, x3| { - _ = x1; _ = x2; _ = x3; + _ = x1; + _ = x2; + _ = x3; } } @@ -31,10 +35,10 @@ export fn d() void { // :2:5: error: non-matching for loop lengths // :2:11: note: length 10 here // :2:19: note: length 11 here -// :9:14: error: type 'bool' is not indexable and not a range -// :9:14: note: for loop operand must be a range, array, slice, tuple, or vector -// :15:16: error: pointer capture of non pointer type '[10]u8' -// :15:10: note: consider using '&' here -// :22:5: error: unbounded for loop -// :22:10: note: type '[*]const u8' has no upper bound -// :22:18: note: type '[*]const u8' has no upper bound +// :10:14: error: type 'bool' is not indexable and not a range +// :10:14: note: for loop operand must be a range, array, slice, tuple, or vector +// :17:16: error: pointer capture of non pointer type '[10]u8' +// :17:10: note: consider using '&' here +// :24:5: error: unbounded for loop +// :24:10: note: type '[*]const u8' has no upper bound +// :24:18: note: type '[*]const u8' has no upper bound diff --git a/test/cases/compile_errors/for_extra_capture.zig b/test/cases/compile_errors/for_extra_capture.zig index a137b57d5152..0a4ed724ad0e 100644 --- a/test/cases/compile_errors/for_extra_capture.zig +++ b/test/cases/compile_errors/for_extra_capture.zig @@ -1,12 +1,15 @@ +// zig fmt: off export fn b() void { for (0..10) |i, j| { - _ = i; _ = j; + _ = i; + _ = j; } } +// zig fmt: on // error // backend=stage2 // target=native // -// :2:21: error: extra capture in for loop -// :2:21: note: run 'zig fmt' to upgrade your code automatically +// :3:21: error: extra capture in for loop +// :3:21: note: run 'zig fmt' to upgrade your code automatically diff --git a/test/cases/compile_errors/function_alignment_non_power_of_2.zig b/test/cases/compile_errors/function_alignment_non_power_of_2.zig index 11d6768dfd0c..e40ca022d2c1 100644 --- a/test/cases/compile_errors/function_alignment_non_power_of_2.zig +++ b/test/cases/compile_errors/function_alignment_non_power_of_2.zig @@ -1,5 +1,7 @@ extern fn foo() align(3) void; -export fn entry() void { return foo(); } +export fn entry() void { + return foo(); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/function_call_assigned_to_incorrect_type.zig b/test/cases/compile_errors/function_call_assigned_to_incorrect_type.zig index fcbfabe2978a..1060987b9a19 100644 --- a/test/cases/compile_errors/function_call_assigned_to_incorrect_type.zig +++ b/test/cases/compile_errors/function_call_assigned_to_incorrect_type.zig @@ -3,7 +3,7 @@ export fn entry() void { arr = concat(); } fn concat() [16]f32 { - return [1]f32{0}**16; + return [1]f32{0} ** 16; } // error diff --git a/test/cases/compile_errors/function_parameter_is_opaque.zig b/test/cases/compile_errors/function_parameter_is_opaque.zig index 57c89bd7f47f..61e15f9ae6a8 100644 --- a/test/cases/compile_errors/function_parameter_is_opaque.zig +++ b/test/cases/compile_errors/function_parameter_is_opaque.zig @@ -9,12 +9,16 @@ export fn entry2() void { _ = someFuncPtr; } -fn foo(p: FooType) void {_ = p;} +fn foo(p: FooType) void { + _ = p; +} export fn entry3() void { _ = foo; } -fn bar(p: @TypeOf(null)) void {_ = p;} +fn bar(p: @TypeOf(null)) void { + _ = p; +} export fn entry4() void { _ = bar; } @@ -28,4 +32,4 @@ export fn entry4() void { // :8:28: error: parameter of type '@TypeOf(null)' not allowed // :12:8: error: parameter of opaque type 'tmp.FooType' not allowed // :1:17: note: opaque declared here -// :17:8: error: parameter of type '@TypeOf(null)' not allowed +// :19:8: error: parameter of type '@TypeOf(null)' not allowed diff --git a/test/cases/compile_errors/function_with_non-extern_non-packed_enum_parameter.zig b/test/cases/compile_errors/function_with_non-extern_non-packed_enum_parameter.zig index c6412161e53a..ae347470f2e1 100644 --- a/test/cases/compile_errors/function_with_non-extern_non-packed_enum_parameter.zig +++ b/test/cases/compile_errors/function_with_non-extern_non-packed_enum_parameter.zig @@ -1,5 +1,7 @@ const Foo = enum { A, B, C }; -export fn entry(foo: Foo) void { _ = foo; } +export fn entry(foo: Foo) void { + _ = foo; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/function_with_non-extern_non-packed_struct_parameter.zig b/test/cases/compile_errors/function_with_non-extern_non-packed_struct_parameter.zig index 55ee27764112..137037f9e747 100644 --- a/test/cases/compile_errors/function_with_non-extern_non-packed_struct_parameter.zig +++ b/test/cases/compile_errors/function_with_non-extern_non-packed_struct_parameter.zig @@ -3,7 +3,9 @@ const Foo = struct { B: f32, C: bool, }; -export fn entry(foo: Foo) void { _ = foo; } +export fn entry(foo: Foo) void { + _ = foo; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/function_with_non-extern_non-packed_union_parameter.zig b/test/cases/compile_errors/function_with_non-extern_non-packed_union_parameter.zig index f848392c9092..d651329f72f8 100644 --- a/test/cases/compile_errors/function_with_non-extern_non-packed_union_parameter.zig +++ b/test/cases/compile_errors/function_with_non-extern_non-packed_union_parameter.zig @@ -3,7 +3,9 @@ const Foo = union { B: f32, C: bool, }; -export fn entry(foo: Foo) void { _ = foo; } +export fn entry(foo: Foo) void { + _ = foo; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/generic_function_call_assigned_to_incorrect_type.zig b/test/cases/compile_errors/generic_function_call_assigned_to_incorrect_type.zig index a2e303670d6d..4ff284128284 100644 --- a/test/cases/compile_errors/generic_function_call_assigned_to_incorrect_type.zig +++ b/test/cases/compile_errors/generic_function_call_assigned_to_incorrect_type.zig @@ -2,7 +2,7 @@ pub export fn entry() void { var res: []i32 = undefined; res = myAlloc(i32); } -fn myAlloc(comptime arg: type) anyerror!arg{ +fn myAlloc(comptime arg: type) anyerror!arg { unreachable; } diff --git a/test/cases/compile_errors/generic_function_instance_with_non-constant_expression.zig b/test/cases/compile_errors/generic_function_instance_with_non-constant_expression.zig index 1317c4376a83..18c60cd4aa68 100644 --- a/test/cases/compile_errors/generic_function_instance_with_non-constant_expression.zig +++ b/test/cases/compile_errors/generic_function_instance_with_non-constant_expression.zig @@ -1,13 +1,17 @@ -fn foo(comptime x: i32, y: i32) i32 { return x + y; } +fn foo(comptime x: i32, y: i32) i32 { + return x + y; +} fn test1(a: i32, b: i32) i32 { return foo(a, b); } -export fn entry() usize { return @sizeOf(@TypeOf(&test1)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&test1)); +} // error // backend=stage2 // target=native // -// :3:16: error: unable to resolve comptime value -// :3:16: note: parameter is comptime +// :5:16: error: unable to resolve comptime value +// :5:16: note: parameter is comptime diff --git a/test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig b/test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig index 3146c3860403..c730f80e6f42 100644 --- a/test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig +++ b/test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig @@ -6,7 +6,6 @@ pub export fn entry() void { } fn sliceAsBytes(slice: anytype) std.meta.trait.isPtrTo(.Array)(@TypeOf(slice)) {} - // error // backend=llvm // target=native diff --git a/test/cases/compile_errors/global_variable_alignment_non_power_of_2.zig b/test/cases/compile_errors/global_variable_alignment_non_power_of_2.zig index b88d8aaf701c..5110e41334b8 100644 --- a/test/cases/compile_errors/global_variable_alignment_non_power_of_2.zig +++ b/test/cases/compile_errors/global_variable_alignment_non_power_of_2.zig @@ -1,5 +1,7 @@ const some_data: [100]u8 align(3) = undefined; -export fn entry() usize { return @sizeOf(@TypeOf(some_data)); } +export fn entry() usize { + return @sizeOf(@TypeOf(some_data)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/global_variable_initializer_must_be_constant_expression.zig b/test/cases/compile_errors/global_variable_initializer_must_be_constant_expression.zig index e2694343e825..a87f62839660 100644 --- a/test/cases/compile_errors/global_variable_initializer_must_be_constant_expression.zig +++ b/test/cases/compile_errors/global_variable_initializer_must_be_constant_expression.zig @@ -1,6 +1,8 @@ extern fn foo() i32; const x = foo(); -export fn entry() i32 { return x; } +export fn entry() i32 { + return x; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/ignored_assert-err-ok_return_value.zig b/test/cases/compile_errors/ignored_assert-err-ok_return_value.zig index 39657badd479..1257636622da 100644 --- a/test/cases/compile_errors/ignored_assert-err-ok_return_value.zig +++ b/test/cases/compile_errors/ignored_assert-err-ok_return_value.zig @@ -1,7 +1,9 @@ export fn foo() void { bar() catch unreachable; } -fn bar() anyerror!i32 { return 0; } +fn bar() anyerror!i32 { + return 0; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/ignored_comptime_statement_value.zig b/test/cases/compile_errors/ignored_comptime_statement_value.zig index fc6cdfdd28fe..2067f3b71609 100644 --- a/test/cases/compile_errors/ignored_comptime_statement_value.zig +++ b/test/cases/compile_errors/ignored_comptime_statement_value.zig @@ -1,11 +1,13 @@ export fn foo() void { - comptime {1;} + comptime { + 1; + } } // error // backend=stage2 // target=native // -// :2:15: error: value of type 'comptime_int' ignored -// :2:15: note: all non-void values must be used -// :2:15: note: this error can be suppressed by assigning the value to '_' +// :3:9: error: value of type 'comptime_int' ignored +// :3:9: note: all non-void values must be used +// :3:9: note: this error can be suppressed by assigning the value to '_' diff --git a/test/cases/compile_errors/ignored_deferred_function_call.zig b/test/cases/compile_errors/ignored_deferred_function_call.zig index b318baa16cb5..9537255d3304 100644 --- a/test/cases/compile_errors/ignored_deferred_function_call.zig +++ b/test/cases/compile_errors/ignored_deferred_function_call.zig @@ -1,7 +1,9 @@ export fn foo() void { defer bar(); } -fn bar() anyerror!i32 { return 0; } +fn bar() anyerror!i32 { + return 0; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/ignored_deferred_statement_value.zig b/test/cases/compile_errors/ignored_deferred_statement_value.zig index 9a270497afc9..1f42efc3f5e1 100644 --- a/test/cases/compile_errors/ignored_deferred_statement_value.zig +++ b/test/cases/compile_errors/ignored_deferred_statement_value.zig @@ -1,11 +1,13 @@ export fn foo() void { - defer {1;} + defer { + 1; + } } // error // backend=stage2 // target=native // -// :2:12: error: value of type 'comptime_int' ignored -// :2:12: note: all non-void values must be used -// :2:12: note: this error can be suppressed by assigning the value to '_' +// :3:9: error: value of type 'comptime_int' ignored +// :3:9: note: all non-void values must be used +// :3:9: note: this error can be suppressed by assigning the value to '_' diff --git a/test/cases/compile_errors/ignored_return_value.zig b/test/cases/compile_errors/ignored_return_value.zig index 57f859e3d375..08424c4fe9fc 100644 --- a/test/cases/compile_errors/ignored_return_value.zig +++ b/test/cases/compile_errors/ignored_return_value.zig @@ -1,7 +1,9 @@ export fn foo() void { bar(); } -fn bar() i32 { return 0; } +fn bar() i32 { + return 0; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/illegal_comparison_of_types.zig b/test/cases/compile_errors/illegal_comparison_of_types.zig index 69d7a28fa44f..5720aa05cc87 100644 --- a/test/cases/compile_errors/illegal_comparison_of_types.zig +++ b/test/cases/compile_errors/illegal_comparison_of_types.zig @@ -9,8 +9,12 @@ fn bad_eql_2(a: *const EnumWithData, b: *const EnumWithData) bool { return a.* == b.*; } -export fn entry1() usize { return @sizeOf(@TypeOf(&bad_eql_1)); } -export fn entry2() usize { return @sizeOf(@TypeOf(&bad_eql_2)); } +export fn entry1() usize { + return @sizeOf(@TypeOf(&bad_eql_1)); +} +export fn entry2() usize { + return @sizeOf(@TypeOf(&bad_eql_2)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/implicit_cast_from_array_to_mutable_slice.zig b/test/cases/compile_errors/implicit_cast_from_array_to_mutable_slice.zig index e7ae5d72770a..1efc37542554 100644 --- a/test/cases/compile_errors/implicit_cast_from_array_to_mutable_slice.zig +++ b/test/cases/compile_errors/implicit_cast_from_array_to_mutable_slice.zig @@ -1,5 +1,7 @@ var global_array: [10]i32 = undefined; -fn foo(param: []i32) void {_ = param;} +fn foo(param: []i32) void { + _ = param; +} export fn entry() void { foo(global_array); } @@ -8,4 +10,4 @@ export fn entry() void { // backend=llvm // target=native // -// :4:9: error: array literal requires address-of operator (&) to coerce to slice type '[]i32' +// :6:9: error: array literal requires address-of operator (&) to coerce to slice type '[]i32' diff --git a/test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig b/test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig index 13adba1b9140..fcecfa861117 100644 --- a/test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig +++ b/test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig @@ -4,7 +4,7 @@ const Foo = packed struct { }; export fn entry() void { - var foo = Foo { .a = 1, .b = 10 }; + var foo = Foo{ .a = 1, .b = 10 }; bar(&foo.b); } diff --git a/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig b/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig index 84ec6464f4ad..171936097dc9 100644 --- a/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig +++ b/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig @@ -4,7 +4,7 @@ const Foo = packed struct { }; export fn entry() void { - var foo = Foo { .a = 1, .b = 10 }; + var foo = Foo{ .a = 1, .b = 10 }; foo.b += 1; bar(@as(*[1]u32, &foo.b)[0..]); } diff --git a/test/cases/compile_errors/import_outside_package_path.zig b/test/cases/compile_errors/import_outside_package_path.zig index 0c0df594193e..34044e3b0fba 100644 --- a/test/cases/compile_errors/import_outside_package_path.zig +++ b/test/cases/compile_errors/import_outside_package_path.zig @@ -1,4 +1,4 @@ -comptime{ +comptime { _ = @import("../a.zig"); } diff --git a/test/cases/compile_errors/incorrect_return_type.zig b/test/cases/compile_errors/incorrect_return_type.zig index 57cf54a02347..798b167dcb9d 100644 --- a/test/cases/compile_errors/incorrect_return_type.zig +++ b/test/cases/compile_errors/incorrect_return_type.zig @@ -1,24 +1,24 @@ - pub export fn entry() void{ - _ = foo(); - } - const A = struct { - a: u32, - }; - fn foo() A { - return bar(); - } - const B = struct { - a: u32, - }; - fn bar() B { - unreachable; - } +pub export fn entry() void { + _ = foo(); +} +const A = struct { + a: u32, +}; +fn foo() A { + return bar(); +} +const B = struct { + a: u32, +}; +fn bar() B { + unreachable; +} // error // backend=stage2 // target=native // -// :8:16: error: expected type 'tmp.A', found 'tmp.B' -// :10:12: note: struct declared here -// :4:12: note: struct declared here -// :7:11: note: function return type declared here +// :8:15: error: expected type 'tmp.A', found 'tmp.B' +// :10:11: note: struct declared here +// :4:11: note: struct declared here +// :7:10: note: function return type declared here diff --git a/test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig b/test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig index 242454e859c7..8d7e14acae89 100644 --- a/test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig +++ b/test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig @@ -1,5 +1,5 @@ export fn entry() u32 { - var bytes: [4]u8 = [_]u8{0x01, 0x02, 0x03, 0x04}; + var bytes: [4]u8 = [_]u8{ 0x01, 0x02, 0x03, 0x04 }; const ptr = @ptrCast(*u32, &bytes[0]); return ptr.*; } diff --git a/test/cases/compile_errors/indirect_struct_loop.zig b/test/cases/compile_errors/indirect_struct_loop.zig index dca2b9c3f65b..ef5526830e98 100644 --- a/test/cases/compile_errors/indirect_struct_loop.zig +++ b/test/cases/compile_errors/indirect_struct_loop.zig @@ -1,13 +1,21 @@ -const A = struct { b : B, }; -const B = struct { c : C, }; -const C = struct { a : A, }; -export fn entry() usize { return @sizeOf(A); } +const A = struct { + b: B, +}; +const B = struct { + c: C, +}; +const C = struct { + a: A, +}; +export fn entry() usize { + return @sizeOf(A); +} // error // backend=stage2 // target=native // // :1:11: error: struct 'tmp.A' depends on itself -// :3:20: note: while checking this field -// :2:20: note: while checking this field -// :1:20: note: while checking this field +// :8:5: note: while checking this field +// :5:5: note: while checking this field +// :2:5: note: while checking this field diff --git a/test/cases/compile_errors/inferred_array_size_invalid_here.zig b/test/cases/compile_errors/inferred_array_size_invalid_here.zig index 084057dc8e6d..0791540ed2d5 100644 --- a/test/cases/compile_errors/inferred_array_size_invalid_here.zig +++ b/test/cases/compile_errors/inferred_array_size_invalid_here.zig @@ -4,7 +4,7 @@ export fn entry() void { } export fn entry2() void { const S = struct { a: *const [_]u8 }; - var a = .{ S{} }; + var a = .{S{}}; _ = a; } diff --git a/test/cases/compile_errors/inferring_error_set_of_function_pointer.zig b/test/cases/compile_errors/inferring_error_set_of_function_pointer.zig index 862e33906a6b..ce1b2763609a 100644 --- a/test/cases/compile_errors/inferring_error_set_of_function_pointer.zig +++ b/test/cases/compile_errors/inferring_error_set_of_function_pointer.zig @@ -1,9 +1,9 @@ comptime { - const z: ?fn()!void = null; + const z: ?fn () !void = null; } // error // backend=stage2 // target=native // -// :2:19: error: function prototype may not have inferred error set +// :2:21: error: function prototype may not have inferred error set diff --git a/test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig b/test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig index 4c3b3fc1ae08..ecf8f61fc524 100644 --- a/test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig +++ b/test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig @@ -1,17 +1,17 @@ export fn foo() void { var a: f32 = 2; - _ = @floatToInt(comptime_int, a); + _ = @intFromFloat(comptime_int, a); } export fn bar() void { var a: u32 = 2; - _ = @intToFloat(comptime_float, a); + _ = @floatFromInt(comptime_float, a); } // error // backend=stage2 // target=native // -// :3:35: error: unable to resolve comptime value -// :3:35: note: value being casted to 'comptime_int' must be comptime-known -// :7:37: error: unable to resolve comptime value -// :7:37: note: value being casted to 'comptime_float' must be comptime-known +// :3:37: error: unable to resolve comptime value +// :3:37: note: value being casted to 'comptime_int' must be comptime-known +// :7:39: error: unable to resolve comptime value +// :7:39: note: value being casted to 'comptime_float' must be comptime-known diff --git a/test/cases/compile_errors/intFromFloat_comptime_safety.zig b/test/cases/compile_errors/intFromFloat_comptime_safety.zig new file mode 100644 index 000000000000..275f67006fb6 --- /dev/null +++ b/test/cases/compile_errors/intFromFloat_comptime_safety.zig @@ -0,0 +1,17 @@ +comptime { + _ = @intFromFloat(i8, @as(f32, -129.1)); +} +comptime { + _ = @intFromFloat(u8, @as(f32, -1.1)); +} +comptime { + _ = @intFromFloat(u8, @as(f32, 256.1)); +} + +// error +// backend=stage2 +// target=native +// +// :2:27: error: float value '-129.10000610351562' cannot be stored in integer type 'i8' +// :5:27: error: float value '-1.100000023841858' cannot be stored in integer type 'u8' +// :8:27: error: float value '256.1000061035156' cannot be stored in integer type 'u8' diff --git a/test/cases/compile_errors/intFromPtr_0_to_non_optional_pointer.zig b/test/cases/compile_errors/intFromPtr_0_to_non_optional_pointer.zig new file mode 100644 index 000000000000..4a2ea05eaaf2 --- /dev/null +++ b/test/cases/compile_errors/intFromPtr_0_to_non_optional_pointer.zig @@ -0,0 +1,10 @@ +export fn entry() void { + var b = @ptrFromInt(*i32, 0); + _ = b; +} + +// error +// backend=stage2 +// target=native +// +// :2:31: error: pointer type '*i32' does not allow address zero diff --git a/test/cases/compile_errors/intToPtr_with_misaligned_address.zig b/test/cases/compile_errors/intToPtr_with_misaligned_address.zig deleted file mode 100644 index 43f89ab3b512..000000000000 --- a/test/cases/compile_errors/intToPtr_with_misaligned_address.zig +++ /dev/null @@ -1,10 +0,0 @@ -pub export fn entry() void { - var y = @intToPtr([*]align(4) u8, 5); - _ = y; -} - -// error -// backend=stage2 -// target=native -// -// :2:39: error: pointer type '[*]align(4) u8' requires aligned address diff --git a/test/cases/compile_errors/int_to_err_global_invalid_number.zig b/test/cases/compile_errors/int_to_err_global_invalid_number.zig index 5bb9b75a8e77..000b5d1e6abd 100644 --- a/test/cases/compile_errors/int_to_err_global_invalid_number.zig +++ b/test/cases/compile_errors/int_to_err_global_invalid_number.zig @@ -4,7 +4,7 @@ const Set1 = error{ }; comptime { var x: u16 = 3; - var y = @intToError(x); + var y = @errorFromInt(x); _ = y; } @@ -12,4 +12,4 @@ comptime { // backend=stage2 // target=native // -// :7:25: error: integer value '3' represents no error +// :7:27: error: integer value '3' represents no error diff --git a/test/cases/compile_errors/int_to_err_non_global_invalid_number.zig b/test/cases/compile_errors/int_to_err_non_global_invalid_number.zig index f837ccd532e6..6a1f2db531e9 100644 --- a/test/cases/compile_errors/int_to_err_non_global_invalid_number.zig +++ b/test/cases/compile_errors/int_to_err_non_global_invalid_number.zig @@ -7,8 +7,8 @@ const Set2 = error{ C, }; comptime { - var x = @errorToInt(Set1.B); - var y = @errSetCast(Set2, @intToError(x)); + var x = @intFromError(Set1.B); + var y = @errSetCast(Set2, @errorFromInt(x)); _ = y; } diff --git a/test/cases/compile_errors/integer_overflow_error.zig b/test/cases/compile_errors/integer_overflow_error.zig index aa4725b7e7ad..9de1a2820f5e 100644 --- a/test/cases/compile_errors/integer_overflow_error.zig +++ b/test/cases/compile_errors/integer_overflow_error.zig @@ -1,8 +1,10 @@ -const x : u8 = 300; -export fn entry() usize { return @sizeOf(@TypeOf(x)); } +const x: u8 = 300; +export fn entry() usize { + return @sizeOf(@TypeOf(x)); +} // error // backend=stage2 // target=native // -// :1:16: error: type 'u8' cannot represent integer value '300' +// :1:15: error: type 'u8' cannot represent integer value '300' diff --git a/test/cases/compile_errors/integer_underflow_error.zig b/test/cases/compile_errors/integer_underflow_error.zig index 120edd08387c..275b593ecc18 100644 --- a/test/cases/compile_errors/integer_underflow_error.zig +++ b/test/cases/compile_errors/integer_underflow_error.zig @@ -1,9 +1,9 @@ export fn entry() void { - _ = @intToPtr(*anyopaque, ~@as(usize, @import("std").math.maxInt(usize)) - 1); + _ = @ptrFromInt(*anyopaque, ~@as(usize, @import("std").math.maxInt(usize)) - 1); } // error // backend=stage2 // target=native // -// :2:78: error: overflow of integer type 'usize' with value '-1' +// :2:80: error: overflow of integer type 'usize' with value '-1' diff --git a/test/cases/compile_errors/inttoptr_non_ptr_type.zig b/test/cases/compile_errors/inttoptr_non_ptr_type.zig deleted file mode 100644 index fa308f677d50..000000000000 --- a/test/cases/compile_errors/inttoptr_non_ptr_type.zig +++ /dev/null @@ -1,15 +0,0 @@ -pub export fn entry() void { - _ = @intToPtr(i32, 10); -} - -pub export fn entry2() void { - _ = @intToPtr([]u8, 20); -} - -// error -// backend=stage2 -// target=native -// -// :2:19: error: expected pointer type, found 'i32' -// :6:19: error: integer cannot be converted to slice type '[]u8' -// :6:19: note: slice length cannot be inferred from address diff --git a/test/cases/compile_errors/invalid_builtin_fn.zig b/test/cases/compile_errors/invalid_builtin_fn.zig index 5b7b832177bf..3297525fd981 100644 --- a/test/cases/compile_errors/invalid_builtin_fn.zig +++ b/test/cases/compile_errors/invalid_builtin_fn.zig @@ -1,6 +1,7 @@ -fn f() @bogus(foo) { +fn f() @bogus(foo) {} +export fn entry() void { + _ = f(); } -export fn entry() void { _ = f(); } // error // backend=stage2 diff --git a/test/cases/compile_errors/invalid_capture_type.zig b/test/cases/compile_errors/invalid_capture_type.zig index 3813021c951b..6f480df09705 100644 --- a/test/cases/compile_errors/invalid_capture_type.zig +++ b/test/cases/compile_errors/invalid_capture_type.zig @@ -1,5 +1,7 @@ export fn f1() void { - if (true) |x| { _ = x; } + if (true) |x| { + _ = x; + } } export fn f2() void { if (@as(usize, 5)) |_| {} @@ -19,6 +21,6 @@ export fn f5() void { // target=native // // :2:9: error: expected optional type, found 'bool' -// :5:9: error: expected optional type, found 'usize' -// :8:9: error: expected error union type, found 'usize' -// :14:9: error: expected error union type, found 'error{Foo}' +// :7:9: error: expected optional type, found 'usize' +// :10:9: error: expected error union type, found 'usize' +// :16:9: error: expected error union type, found 'error{Foo}' diff --git a/test/cases/compile_errors/invalid_comparison_for_function_pointers.zig b/test/cases/compile_errors/invalid_comparison_for_function_pointers.zig index cd63c70259b3..3c76da2e38c0 100644 --- a/test/cases/compile_errors/invalid_comparison_for_function_pointers.zig +++ b/test/cases/compile_errors/invalid_comparison_for_function_pointers.zig @@ -1,7 +1,9 @@ fn foo() void {} const invalid = foo > foo; -export fn entry() usize { return @sizeOf(@TypeOf(invalid)); } +export fn entry() usize { + return @sizeOf(@TypeOf(invalid)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/invalid_field_access_in_comptime.zig b/test/cases/compile_errors/invalid_field_access_in_comptime.zig index 672c2b74c90b..74fada311dea 100644 --- a/test/cases/compile_errors/invalid_field_access_in_comptime.zig +++ b/test/cases/compile_errors/invalid_field_access_in_comptime.zig @@ -1,7 +1,10 @@ -comptime { var x = doesnt_exist.whatever; _ = x; } +comptime { + var x = doesnt_exist.whatever; + _ = x; +} // error // backend=stage2 // target=native // -// :1:20: error: use of undeclared identifier 'doesnt_exist' +// :2:13: error: use of undeclared identifier 'doesnt_exist' diff --git a/test/cases/compile_errors/invalid_field_in_struct_value_expression.zig b/test/cases/compile_errors/invalid_field_in_struct_value_expression.zig index 97f440da3b3f..f1cd96d8e7cc 100644 --- a/test/cases/compile_errors/invalid_field_in_struct_value_expression.zig +++ b/test/cases/compile_errors/invalid_field_in_struct_value_expression.zig @@ -1,10 +1,10 @@ const A = struct { - x : i32, - y : i32, - z : i32, + x: i32, + y: i32, + z: i32, }; export fn f() void { - const a = A { + const a = A{ .z = 4, .y = 2, .foo = 42, @@ -21,7 +21,6 @@ pub export fn entry() void { dump(.{ .field_1 = 123, .field_3 = 456 }); } - // error // backend=stage2 // target=native diff --git a/test/cases/compile_errors/invalid_float_casts.zig b/test/cases/compile_errors/invalid_float_casts.zig index 152c98182b5a..507ced1e57b4 100644 --- a/test/cases/compile_errors/invalid_float_casts.zig +++ b/test/cases/compile_errors/invalid_float_casts.zig @@ -4,11 +4,11 @@ export fn foo() void { } export fn bar() void { var a: f32 = 2; - _ = @floatToInt(f32, a); + _ = @intFromFloat(f32, a); } export fn baz() void { var a: f32 = 2; - _ = @intToFloat(f32, a); + _ = @floatFromInt(f32, a); } export fn qux() void { var a: u32 = 2; @@ -20,6 +20,6 @@ export fn qux() void { // target=native // // :3:36: error: unable to cast runtime value to 'comptime_float' -// :7:21: error: expected integer type, found 'f32' -// :11:26: error: expected integer type, found 'f32' +// :7:23: error: expected integer type, found 'f32' +// :11:28: error: expected integer type, found 'f32' // :15:25: error: expected float type, found 'u32' diff --git a/test/cases/compile_errors/invalid_int_casts.zig b/test/cases/compile_errors/invalid_int_casts.zig index d220869201d3..262a096bd9f7 100644 --- a/test/cases/compile_errors/invalid_int_casts.zig +++ b/test/cases/compile_errors/invalid_int_casts.zig @@ -4,11 +4,11 @@ export fn foo() void { } export fn bar() void { var a: u32 = 2; - _ = @intToFloat(u32, a); + _ = @floatFromInt(u32, a); } export fn baz() void { var a: u32 = 2; - _ = @floatToInt(u32, a); + _ = @intFromFloat(u32, a); } export fn qux() void { var a: f32 = 2; @@ -20,6 +20,6 @@ export fn qux() void { // target=native // // :3:32: error: unable to cast runtime value to 'comptime_int' -// :7:21: error: expected float type, found 'u32' -// :11:26: error: expected float type, found 'u32' +// :7:23: error: expected float type, found 'u32' +// :11:28: error: expected float type, found 'u32' // :15:23: error: expected integer or vector, found 'f32' diff --git a/test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig b/test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig index fa58c0845a4a..5457a61d3fd0 100644 --- a/test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig +++ b/test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig @@ -8,12 +8,12 @@ const U = union(E) { b, }; export fn foo() void { - var e = @intToEnum(E, 15); + var e = @enumFromInt(E, 15); var u: U = e; _ = u; } export fn bar() void { - const e = @intToEnum(E, 15); + const e = @enumFromInt(E, 15); var u: U = e; _ = u; } @@ -24,5 +24,5 @@ export fn bar() void { // // :12:16: error: runtime coercion to union 'tmp.U' from non-exhaustive enum // :1:11: note: enum declared here -// :17:16: error: union 'tmp.U' has no tag with value '@intToEnum(tmp.E, 15)' +// :17:16: error: union 'tmp.U' has no tag with value '@enumFromInt(tmp.E, 15)' // :6:11: note: union declared here diff --git a/test/cases/compile_errors/invalid_optional_type_in_extern_struct.zig b/test/cases/compile_errors/invalid_optional_type_in_extern_struct.zig index 10e140d881ff..c7d7b4233abe 100644 --- a/test/cases/compile_errors/invalid_optional_type_in_extern_struct.zig +++ b/test/cases/compile_errors/invalid_optional_type_in_extern_struct.zig @@ -1,7 +1,9 @@ const stroo = extern struct { moo: ?[*c]u8, }; -export fn testf(fluff: *stroo) void { _ = fluff; } +export fn testf(fluff: *stroo) void { + _ = fluff; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/invalid_pointer_with_reify_type.zig b/test/cases/compile_errors/invalid_pointer_with_reify_type.zig index cac9e3289440..dce09234d459 100644 --- a/test/cases/compile_errors/invalid_pointer_with_reify_type.zig +++ b/test/cases/compile_errors/invalid_pointer_with_reify_type.zig @@ -8,7 +8,7 @@ export fn entry() void { .child = u8, .is_allowzero = false, .sentinel = &@as(u8, 0), - }}); + } }); } // error diff --git a/test/cases/compile_errors/invalid_shift_amount_error.zig b/test/cases/compile_errors/invalid_shift_amount_error.zig index 49852b5b7d03..9ea4c55d2981 100644 --- a/test/cases/compile_errors/invalid_shift_amount_error.zig +++ b/test/cases/compile_errors/invalid_shift_amount_error.zig @@ -1,8 +1,10 @@ -const x : u8 = 2; +const x: u8 = 2; fn f() u16 { return x << 8; } -export fn entry() u16 { return f(); } +export fn entry() u16 { + return f(); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/invalid_type.zig b/test/cases/compile_errors/invalid_type.zig index 902d3652e7a3..a7c7d8109422 100644 --- a/test/cases/compile_errors/invalid_type.zig +++ b/test/cases/compile_errors/invalid_type.zig @@ -1,5 +1,7 @@ fn a() bogus {} -export fn entry() void { _ = a(); } +export fn entry() void { + _ = a(); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/invalid_type_in_builtin_extern.zig b/test/cases/compile_errors/invalid_type_in_builtin_extern.zig index c3d35958ae4b..882febbb7358 100644 --- a/test/cases/compile_errors/invalid_type_in_builtin_extern.zig +++ b/test/cases/compile_errors/invalid_type_in_builtin_extern.zig @@ -1,4 +1,4 @@ -const x = @extern(*comptime_int, .{.name="foo"}); +const x = @extern(*comptime_int, .{ .name = "foo" }); pub export fn entry() void { _ = x; } diff --git a/test/cases/compile_errors/invalid_variadic_function.zig b/test/cases/compile_errors/invalid_variadic_function.zig index 997db9fee8fa..7652cb329a08 100644 --- a/test/cases/compile_errors/invalid_variadic_function.zig +++ b/test/cases/compile_errors/invalid_variadic_function.zig @@ -1,8 +1,12 @@ fn foo(...) void {} fn bar(a: anytype, ...) callconv(a) void {} -comptime { _ = foo; } -comptime { _ = bar; } +comptime { + _ = foo; +} +comptime { + _ = bar; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig b/test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig index 874f015ffb93..7a4c0eb7e858 100644 --- a/test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig +++ b/test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig @@ -1,10 +1,10 @@ export fn foo1() void { - var bytes = [_]u8{1, 2}; + var bytes = [_]u8{ 1, 2 }; const word: u16 = @bitCast(u16, bytes[0..]); _ = word; } export fn foo2() void { - var bytes: []const u8 = &[_]u8{1, 2}; + var bytes: []const u8 = &[_]u8{ 1, 2 }; const word: u16 = @bitCast(u16, bytes); _ = word; } @@ -14,6 +14,6 @@ export fn foo2() void { // target=native // // :3:42: error: cannot @bitCast from '*[2]u8' -// :3:42: note: use @ptrToInt to cast to 'u16' +// :3:42: note: use @intFromPtr to cast to 'u16' // :8:37: error: cannot @bitCast from '[]const u8' -// :8:37: note: use @ptrToInt to cast to 'u16' +// :8:37: note: use @intFromPtr to cast to 'u16' diff --git a/test/cases/compile_errors/local_variable_redeclaration.zig b/test/cases/compile_errors/local_variable_redeclaration.zig index a0861ada490d..5b81cd5fbc20 100644 --- a/test/cases/compile_errors/local_variable_redeclaration.zig +++ b/test/cases/compile_errors/local_variable_redeclaration.zig @@ -1,5 +1,5 @@ export fn f() void { - const a : i32 = 0; + const a: i32 = 0; var a = 0; } diff --git a/test/cases/compile_errors/local_variable_redeclares_parameter.zig b/test/cases/compile_errors/local_variable_redeclares_parameter.zig index 6e523c2c8f6d..f49b7f137e8d 100644 --- a/test/cases/compile_errors/local_variable_redeclares_parameter.zig +++ b/test/cases/compile_errors/local_variable_redeclares_parameter.zig @@ -1,7 +1,9 @@ -fn f(a : i32) void { +fn f(a: i32) void { const a = 0; } -export fn entry() void { f(1); } +export fn entry() void { + f(1); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/local_variable_shadowing_global.zig b/test/cases/compile_errors/local_variable_shadowing_global.zig index 91df6a7c3d81..e3f221d0c560 100644 --- a/test/cases/compile_errors/local_variable_shadowing_global.zig +++ b/test/cases/compile_errors/local_variable_shadowing_global.zig @@ -2,7 +2,7 @@ const Foo = struct {}; const Bar = struct {}; export fn entry() void { - var Bar : i32 = undefined; + var Bar: i32 = undefined; _ = Bar; } diff --git a/test/cases/compile_errors/main_function_with_bogus_args_type.zig b/test/cases/compile_errors/main_function_with_bogus_args_type.zig index dd02e1af34ac..f0322e0484f8 100644 --- a/test/cases/compile_errors/main_function_with_bogus_args_type.zig +++ b/test/cases/compile_errors/main_function_with_bogus_args_type.zig @@ -1,4 +1,6 @@ -pub fn main(args: [][]bogus) !void {_ = args;} +pub fn main(args: [][]bogus) !void { + _ = args; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/missing_const_in_slice_with_nested_array_type.zig b/test/cases/compile_errors/missing_const_in_slice_with_nested_array_type.zig index 1ef986935b73..2f596db1ed7e 100644 --- a/test/cases/compile_errors/missing_const_in_slice_with_nested_array_type.zig +++ b/test/cases/compile_errors/missing_const_in_slice_with_nested_array_type.zig @@ -2,7 +2,7 @@ const Geo3DTex2D = struct { vertices: [][2]f32 }; pub fn getGeo3DTex2D() Geo3DTex2D { return Geo3DTex2D{ .vertices = [_][2]f32{ - [_]f32{ -0.5, -0.5}, + [_]f32{ -0.5, -0.5 }, }, }; } diff --git a/test/cases/compile_errors/missing_else_clause.zig b/test/cases/compile_errors/missing_else_clause.zig index e96363b9cdc4..13a164ddea04 100644 --- a/test/cases/compile_errors/missing_else_clause.zig +++ b/test/cases/compile_errors/missing_else_clause.zig @@ -1,9 +1,13 @@ fn f(b: bool) void { - const x : i32 = if (b) h: { break :h 1; }; + const x: i32 = if (b) h: { + break :h 1; + }; _ = x; } fn g(b: bool) void { - const y = if (b) h: { break :h @as(i32, 1); }; + const y = if (b) h: { + break :h @as(i32, 1); + }; _ = y; } fn h() void { @@ -30,10 +34,10 @@ export fn entry() void { // backend=stage2 // target=native // -// :2:21: error: incompatible types: 'i32' and 'void' -// :2:31: note: type 'i32' here -// :6:15: error: incompatible types: 'i32' and 'void' -// :6:25: note: type 'i32' here -// :12:16: error: expected type 'tmp.h.T', found 'void' -// :11:15: note: struct declared here -// :18:9: error: incompatible types: 'void' and 'tmp.k.T' +// :2:20: error: incompatible types: 'i32' and 'void' +// :2:30: note: type 'i32' here +// :8:15: error: incompatible types: 'i32' and 'void' +// :8:25: note: type 'i32' here +// :16:16: error: expected type 'tmp.h.T', found 'void' +// :15:15: note: struct declared here +// :22:9: error: incompatible types: 'void' and 'tmp.k.T' diff --git a/test/cases/compile_errors/missing_field_in_struct_value_expression.zig b/test/cases/compile_errors/missing_field_in_struct_value_expression.zig index 600540d1e043..eec50ee1afb0 100644 --- a/test/cases/compile_errors/missing_field_in_struct_value_expression.zig +++ b/test/cases/compile_errors/missing_field_in_struct_value_expression.zig @@ -1,12 +1,12 @@ const A = struct { - x : i32, - y : i32, - z : i32, + x: i32, + y: i32, + z: i32, }; export fn f() void { // we want the error on the '{' not the 'A' because // the A could be a complicated expression - const a = A { + const a = A{ .z = 4, .y = 2, }; @@ -17,5 +17,5 @@ export fn f() void { // backend=stage2 // target=native // -// :9:17: error: missing struct field: x +// :9:16: error: missing struct field: x // :1:11: note: struct 'tmp.A' declared here diff --git a/test/cases/compile_errors/missing_main_fn_in_executable.zig b/test/cases/compile_errors/missing_main_fn_in_executable.zig index 3c1ae631ac40..9f243356b779 100644 --- a/test/cases/compile_errors/missing_main_fn_in_executable.zig +++ b/test/cases/compile_errors/missing_main_fn_in_executable.zig @@ -1,5 +1,3 @@ - - // error // backend=llvm // target=x86_64-linux diff --git a/test/cases/compile_errors/missing_param_name.zig b/test/cases/compile_errors/missing_param_name.zig index 88da902ea2d2..1f679ea1d825 100644 --- a/test/cases/compile_errors/missing_param_name.zig +++ b/test/cases/compile_errors/missing_param_name.zig @@ -1,5 +1,7 @@ fn f(i32) void {} -export fn entry() usize { return @sizeOf(@TypeOf(f)); } +export fn entry() usize { + return @sizeOf(@TypeOf(f)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig b/test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig index ef8fce6c8086..ca8adade0198 100644 --- a/test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig +++ b/test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig @@ -24,11 +24,13 @@ pub const JsonNode = struct { fn foo() void { var jll: JasonList = undefined; jll.init(1234); - var jd = JsonNode {.kind = JsonType.JSONArray , .jobject = JsonOA.JSONArray {jll} }; + var jd = JsonNode{ .kind = JsonType.JSONArray, .jobject = JsonOA.JSONArray{jll} }; _ = jd; } -export fn entry() usize { return @sizeOf(@TypeOf(foo)); } +export fn entry() usize { + return @sizeOf(@TypeOf(foo)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/mul_overflow_in_function_evaluation.zig b/test/cases/compile_errors/mul_overflow_in_function_evaluation.zig index 6be57f770eb8..c484df754083 100644 --- a/test/cases/compile_errors/mul_overflow_in_function_evaluation.zig +++ b/test/cases/compile_errors/mul_overflow_in_function_evaluation.zig @@ -3,7 +3,9 @@ fn mul(a: u16, b: u16) u16 { return a * b; } -export fn entry() usize { return @sizeOf(@TypeOf(&y)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&y)); +} // error // backend=stage2 @@ -11,4 +13,3 @@ export fn entry() usize { return @sizeOf(@TypeOf(&y)); } // // :3:14: error: overflow of integer type 'u16' with value '1800000' // :1:14: note: called from here - diff --git a/test/cases/compile_errors/multiple_function_definitions.zig b/test/cases/compile_errors/multiple_function_definitions.zig index d07eaee257e1..134daaeaa4f6 100644 --- a/test/cases/compile_errors/multiple_function_definitions.zig +++ b/test/cases/compile_errors/multiple_function_definitions.zig @@ -1,6 +1,8 @@ fn a() void {} fn a() void {} -export fn entry() void { a(); } +export fn entry() void { + a(); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/negation_overflow_in_function_evaluation.zig b/test/cases/compile_errors/negation_overflow_in_function_evaluation.zig index abd8549fd20d..208f76100519 100644 --- a/test/cases/compile_errors/negation_overflow_in_function_evaluation.zig +++ b/test/cases/compile_errors/negation_overflow_in_function_evaluation.zig @@ -3,7 +3,9 @@ fn neg(x: i8) i8 { return -x; } -export fn entry() usize { return @sizeOf(@TypeOf(&y)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&y)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/nested_vectors.zig b/test/cases/compile_errors/nested_vectors.zig index 11b09971e91b..29934668b07f 100644 --- a/test/cases/compile_errors/nested_vectors.zig +++ b/test/cases/compile_errors/nested_vectors.zig @@ -10,4 +10,3 @@ export fn entry() void { // target=native // // :3:16: error: expected integer, float, bool, or pointer for the vector element type; found '@Vector(4, u8)' - diff --git a/test/cases/compile_errors/noalias_on_non_pointer_param.zig b/test/cases/compile_errors/noalias_on_non_pointer_param.zig index 65e6e141cec7..45641fcabc0f 100644 --- a/test/cases/compile_errors/noalias_on_non_pointer_param.zig +++ b/test/cases/compile_errors/noalias_on_non_pointer_param.zig @@ -1,11 +1,19 @@ -fn f(noalias x: i32) void { _ = x; } -export fn entry() void { f(1234); } +fn f(noalias x: i32) void { + _ = x; +} +export fn entry() void { + f(1234); +} -fn generic(comptime T: type, noalias _: [*]T, noalias _: [*]const T, _: usize) void {} -comptime { _ = &generic; } +fn generic(comptime T: type, noalias _: [*]T, noalias _: [*]const T, _: usize) void {} +comptime { + _ = &generic; +} -fn slice(noalias _: []u8) void {} -comptime { _ = &slice; } +fn slice(noalias _: []u8) void {} +comptime { + _ = &slice; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig b/test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig index de5a3830ebc5..f5eba9ee62a0 100644 --- a/test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig +++ b/test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig @@ -5,8 +5,7 @@ export fn entry() void { _ = llamas2; } -fn makeLlamas(count: usize) [count]u8 { -} +fn makeLlamas(count: usize) [count]u8 {} // error // target=native diff --git a/test/cases/compile_errors/non-const_expression_function_call_with_struct_return_value_outside_function.zig b/test/cases/compile_errors/non-const_expression_function_call_with_struct_return_value_outside_function.zig index 4acd0afb815a..d9bd0dd2b223 100644 --- a/test/cases/compile_errors/non-const_expression_function_call_with_struct_return_value_outside_function.zig +++ b/test/cases/compile_errors/non-const_expression_function_call_with_struct_return_value_outside_function.zig @@ -4,11 +4,13 @@ const Foo = struct { const a = get_it(); fn get_it() Foo { global_side_effect = true; - return Foo {.x = 13}; + return Foo{ .x = 13 }; } var global_side_effect = false; -export fn entry() usize { return @sizeOf(@TypeOf(a)); } +export fn entry() usize { + return @sizeOf(@TypeOf(a)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/non-const_expression_in_struct_literal_outside_function.zig b/test/cases/compile_errors/non-const_expression_in_struct_literal_outside_function.zig index 2e0043c5ecec..c6d4e04fc1f7 100644 --- a/test/cases/compile_errors/non-const_expression_in_struct_literal_outside_function.zig +++ b/test/cases/compile_errors/non-const_expression_in_struct_literal_outside_function.zig @@ -1,10 +1,12 @@ const Foo = struct { x: i32, }; -const a = Foo {.x = get_it()}; +const a = Foo{ .x = get_it() }; extern fn get_it() i32; -export fn entry() usize { return @sizeOf(@TypeOf(a)); } +export fn entry() usize { + return @sizeOf(@TypeOf(a)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig b/test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig index cf65131a1f1e..48b92460c475 100644 --- a/test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig +++ b/test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig @@ -1,30 +1,30 @@ export fn entry1() void { - var m2 = &2; - _ = m2; + var m2 = &2; + _ = m2; } export fn entry2() void { - var a = undefined; - _ = a; + var a = undefined; + _ = a; } export fn entry3() void { - var b = 1; - _ = b; + var b = 1; + _ = b; } export fn entry4() void { - var c = 1.0; - _ = c; + var c = 1.0; + _ = c; } export fn entry5() void { - var d = null; - _ = d; + var d = null; + _ = d; } export fn entry6(opaque_: *Opaque) void { - var e = opaque_.*; - _ = e; + var e = opaque_.*; + _ = e; } export fn entry7() void { - var f = i32; - _ = f; + var f = i32; + _ = f; } const Opaque = opaque {}; @@ -32,14 +32,14 @@ const Opaque = opaque {}; // backend=stage2 // target=native // -// :2:8: error: variable of type '*const comptime_int' must be const or comptime -// :6:8: error: variable of type '@TypeOf(undefined)' must be const or comptime -// :10:8: error: variable of type 'comptime_int' must be const or comptime -// :10:8: note: to modify this variable at runtime, it must be given an explicit fixed-size number type -// :14:8: error: variable of type 'comptime_float' must be const or comptime -// :14:8: note: to modify this variable at runtime, it must be given an explicit fixed-size number type -// :18:8: error: variable of type '@TypeOf(null)' must be const or comptime -// :22:19: error: values of type 'tmp.Opaque' must be comptime-known, but operand value is runtime-known -// :22:19: note: opaque type 'tmp.Opaque' has undefined size -// :26:8: error: variable of type 'type' must be const or comptime -// :26:8: note: types are not available at runtime +// :2:9: error: variable of type '*const comptime_int' must be const or comptime +// :6:9: error: variable of type '@TypeOf(undefined)' must be const or comptime +// :10:9: error: variable of type 'comptime_int' must be const or comptime +// :10:9: note: to modify this variable at runtime, it must be given an explicit fixed-size number type +// :14:9: error: variable of type 'comptime_float' must be const or comptime +// :14:9: note: to modify this variable at runtime, it must be given an explicit fixed-size number type +// :18:9: error: variable of type '@TypeOf(null)' must be const or comptime +// :22:20: error: values of type 'tmp.Opaque' must be comptime-known, but operand value is runtime-known +// :22:20: note: opaque type 'tmp.Opaque' has undefined size +// :26:9: error: variable of type 'type' must be const or comptime +// :26:9: note: types are not available at runtime diff --git a/test/cases/compile_errors/non-exhaustive_enum_marker_assigned_a_value.zig b/test/cases/compile_errors/non-exhaustive_enum_marker_assigned_a_value.zig index c9ebb6af7142..831845722bfd 100644 --- a/test/cases/compile_errors/non-exhaustive_enum_marker_assigned_a_value.zig +++ b/test/cases/compile_errors/non-exhaustive_enum_marker_assigned_a_value.zig @@ -8,7 +8,10 @@ const B = enum { b, _, }; -comptime { _ = A; _ = B; } +comptime { + _ = A; + _ = B; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/non-inline_for_loop_on_a_type_that_requires_comptime.zig b/test/cases/compile_errors/non-inline_for_loop_on_a_type_that_requires_comptime.zig index ce72f912b87e..2bb3f84cb9d2 100644 --- a/test/cases/compile_errors/non-inline_for_loop_on_a_type_that_requires_comptime.zig +++ b/test/cases/compile_errors/non-inline_for_loop_on_a_type_that_requires_comptime.zig @@ -4,7 +4,9 @@ const Foo = struct { }; export fn entry() void { const xx: [2]Foo = .{ .{ .name = "", .T = u8 }, .{ .name = "", .T = u8 } }; - for (xx) |f| { _ = f;} + for (xx) |f| { + _ = f; + } } // error diff --git a/test/cases/compile_errors/non_constant_expression_in_array_size.zig b/test/cases/compile_errors/non_constant_expression_in_array_size.zig index 07facfa0f2c8..7c4594a3e3fb 100644 --- a/test/cases/compile_errors/non_constant_expression_in_array_size.zig +++ b/test/cases/compile_errors/non_constant_expression_in_array_size.zig @@ -2,14 +2,18 @@ const Foo = struct { y: [get()]u8, }; var global_var: usize = 1; -fn get() usize { return global_var; } +fn get() usize { + return global_var; +} -export fn entry() usize { return @offsetOf(Foo, "y"); } +export fn entry() usize { + return @offsetOf(Foo, "y"); +} // error // backend=stage2 // target=native // -// :5:18: error: unable to resolve comptime value -// :5:18: note: value being returned at comptime must be comptime-known +// :6:5: error: unable to resolve comptime value +// :6:5: note: value being returned at comptime must be comptime-known // :2:12: note: called from here diff --git a/test/cases/compile_errors/non_float_passed_to_floatToInt.zig b/test/cases/compile_errors/non_float_passed_to_floatToInt.zig deleted file mode 100644 index 2d4e0315bebc..000000000000 --- a/test/cases/compile_errors/non_float_passed_to_floatToInt.zig +++ /dev/null @@ -1,10 +0,0 @@ -export fn entry() void { - const x = @floatToInt(i32, @as(i32, 54)); - _ = x; -} - -// error -// backend=stage2 -// target=native -// -// :2:32: error: expected float type, found 'i32' diff --git a/test/cases/compile_errors/non_float_passed_to_intFromFloat.zig b/test/cases/compile_errors/non_float_passed_to_intFromFloat.zig new file mode 100644 index 000000000000..fac51c59c8df --- /dev/null +++ b/test/cases/compile_errors/non_float_passed_to_intFromFloat.zig @@ -0,0 +1,10 @@ +export fn entry() void { + const x = @intFromFloat(i32, @as(i32, 54)); + _ = x; +} + +// error +// backend=stage2 +// target=native +// +// :2:34: error: expected float type, found 'i32' diff --git a/test/cases/compile_errors/non_int_passed_to_floatFromInt.zig b/test/cases/compile_errors/non_int_passed_to_floatFromInt.zig new file mode 100644 index 000000000000..63e6753a53fd --- /dev/null +++ b/test/cases/compile_errors/non_int_passed_to_floatFromInt.zig @@ -0,0 +1,10 @@ +export fn entry() void { + const x = @floatFromInt(f32, 1.1); + _ = x; +} + +// error +// backend=stage2 +// target=native +// +// :2:34: error: expected integer type, found 'comptime_float' diff --git a/test/cases/compile_errors/non_int_passed_to_intToFloat.zig b/test/cases/compile_errors/non_int_passed_to_intToFloat.zig deleted file mode 100644 index f40fa93df0a7..000000000000 --- a/test/cases/compile_errors/non_int_passed_to_intToFloat.zig +++ /dev/null @@ -1,10 +0,0 @@ -export fn entry() void { - const x = @intToFloat(f32, 1.1); - _ = x; -} - -// error -// backend=stage2 -// target=native -// -// :2:32: error: expected integer type, found 'comptime_float' diff --git a/test/cases/compile_errors/non_pointer_given_to_ptrToInt.zig b/test/cases/compile_errors/non_pointer_given_to_intFromPtr.zig similarity index 52% rename from test/cases/compile_errors/non_pointer_given_to_ptrToInt.zig rename to test/cases/compile_errors/non_pointer_given_to_intFromPtr.zig index 27b5d6d1f73d..cb8ea24f635c 100644 --- a/test/cases/compile_errors/non_pointer_given_to_ptrToInt.zig +++ b/test/cases/compile_errors/non_pointer_given_to_intFromPtr.zig @@ -1,9 +1,9 @@ export fn entry(x: i32) usize { - return @ptrToInt(x); + return @intFromPtr(x); } // error // backend=stage2 // target=native // -// :2:22: error: expected pointer, found 'i32' +// :2:24: error: expected pointer, found 'i32' diff --git a/test/cases/compile_errors/offsetOf-bad_field_name.zig b/test/cases/compile_errors/offsetOf-bad_field_name.zig index eb04da3c6816..ceded4f6189b 100644 --- a/test/cases/compile_errors/offsetOf-bad_field_name.zig +++ b/test/cases/compile_errors/offsetOf-bad_field_name.zig @@ -2,12 +2,15 @@ const Foo = struct { derp: i32, }; export fn foo() usize { - return @offsetOf(Foo, "a",); + return @offsetOf( + Foo, + "a", + ); } // error // backend=stage2 // target=native // -// :5:27: error: no field named 'a' in struct 'tmp.Foo' +// :7:9: error: no field named 'a' in struct 'tmp.Foo' // :1:13: note: struct declared here diff --git a/test/cases/compile_errors/offsetOf-non_struct.zig b/test/cases/compile_errors/offsetOf-non_struct.zig index 45e9cf9518fb..8970fa86d9a7 100644 --- a/test/cases/compile_errors/offsetOf-non_struct.zig +++ b/test/cases/compile_errors/offsetOf-non_struct.zig @@ -1,6 +1,6 @@ const Foo = i32; export fn foo() usize { - return @offsetOf(Foo, "a",); + return @offsetOf(Foo, "a"); } // error diff --git a/test/cases/compile_errors/old_fn_ptr_in_extern_context.zig b/test/cases/compile_errors/old_fn_ptr_in_extern_context.zig index 4f957a827cc7..7983ed8ec88b 100644 --- a/test/cases/compile_errors/old_fn_ptr_in_extern_context.zig +++ b/test/cases/compile_errors/old_fn_ptr_in_extern_context.zig @@ -5,7 +5,7 @@ comptime { _ = @sizeOf(S) == 1; } comptime { - _ = [*c][4]fn() callconv(.C) void; + _ = [*c][4]fn () callconv(.C) void; } // error diff --git a/test/cases/compile_errors/out_of_int_range_comptime_float_passed_to_intFromFloat.zig b/test/cases/compile_errors/out_of_int_range_comptime_float_passed_to_intFromFloat.zig new file mode 100644 index 000000000000..574ffc5a20ea --- /dev/null +++ b/test/cases/compile_errors/out_of_int_range_comptime_float_passed_to_intFromFloat.zig @@ -0,0 +1,10 @@ +export fn entry() void { + const x = @intFromFloat(i8, 200); + _ = x; +} + +// error +// backend=stage2 +// target=native +// +// :2:33: error: float value '200' cannot be stored in integer type 'i8' diff --git a/test/cases/compile_errors/out_of_range_comptime_int_passed_to_floatToInt.zig b/test/cases/compile_errors/out_of_range_comptime_int_passed_to_floatToInt.zig deleted file mode 100644 index 426e0c95cb74..000000000000 --- a/test/cases/compile_errors/out_of_range_comptime_int_passed_to_floatToInt.zig +++ /dev/null @@ -1,10 +0,0 @@ -export fn entry() void { - const x = @floatToInt(i8, 200); - _ = x; -} - -// error -// backend=stage2 -// target=native -// -// :2:31: error: float value '200' cannot be stored in integer type 'i8' diff --git a/test/cases/compile_errors/overflow_in_enum_value_allocation.zig b/test/cases/compile_errors/overflow_in_enum_value_allocation.zig index 2a5b55e86da1..821ac6c2563e 100644 --- a/test/cases/compile_errors/overflow_in_enum_value_allocation.zig +++ b/test/cases/compile_errors/overflow_in_enum_value_allocation.zig @@ -3,8 +3,8 @@ const Moo = enum(u8) { Over, }; pub export fn entry() void { - var y = Moo.Last; - _ = y; + var y = Moo.Last; + _ = y; } // error diff --git a/test/cases/compile_errors/packed_union_given_enum_tag_type.zig b/test/cases/compile_errors/packed_union_given_enum_tag_type.zig index 03aaef0d8cd5..2e69afd0a9ec 100644 --- a/test/cases/compile_errors/packed_union_given_enum_tag_type.zig +++ b/test/cases/compile_errors/packed_union_given_enum_tag_type.zig @@ -9,7 +9,7 @@ const Payload = packed union(Letter) { C: bool, }; export fn entry() void { - var a = Payload { .A = 1234 }; + var a = Payload{ .A = 1234 }; _ = a; } diff --git a/test/cases/compile_errors/packed_union_with_automatic_layout_field.zig b/test/cases/compile_errors/packed_union_with_automatic_layout_field.zig index 0db9d83dfbc7..26d224de8594 100644 --- a/test/cases/compile_errors/packed_union_with_automatic_layout_field.zig +++ b/test/cases/compile_errors/packed_union_with_automatic_layout_field.zig @@ -7,7 +7,7 @@ const Payload = packed union { B: bool, }; export fn entry() void { - var a = Payload { .B = true }; + var a = Payload{ .B = true }; _ = a; } diff --git a/test/cases/compile_errors/panic_called_at_compile_time.zig b/test/cases/compile_errors/panic_called_at_compile_time.zig index 220161930bc4..8198cd8e5d31 100644 --- a/test/cases/compile_errors/panic_called_at_compile_time.zig +++ b/test/cases/compile_errors/panic_called_at_compile_time.zig @@ -1,6 +1,8 @@ export fn entry() void { comptime { - @panic("aoeu",); + @panic( + "aoeu", + ); } } diff --git a/test/cases/compile_errors/parameter_redeclaration.zig b/test/cases/compile_errors/parameter_redeclaration.zig index 89c7c4bd2aa8..1805c9ac756e 100644 --- a/test/cases/compile_errors/parameter_redeclaration.zig +++ b/test/cases/compile_errors/parameter_redeclaration.zig @@ -1,10 +1,11 @@ -fn f(a : i32, a : i32) void { +fn f(a: i32, a: i32) void {} +export fn entry() void { + f(1, 2); } -export fn entry() void { f(1, 2); } // error // backend=stage2 // target=native // -// :1:15: error: redeclaration of function parameter 'a' +// :1:14: error: redeclaration of function parameter 'a' // :1:6: note: previous declaration here diff --git a/test/cases/compile_errors/pass_const_ptr_to_mutable_ptr_fn.zig b/test/cases/compile_errors/pass_const_ptr_to_mutable_ptr_fn.zig index fd24b58f5563..7914a825180f 100644 --- a/test/cases/compile_errors/pass_const_ptr_to_mutable_ptr_fn.zig +++ b/test/cases/compile_errors/pass_const_ptr_to_mutable_ptr_fn.zig @@ -1,14 +1,17 @@ fn foo() bool { - const a = @as([]const u8, "a",); + const a = @as([]const u8, "a"); const b = &a; return ptrEql(b, b); } fn ptrEql(a: *[]const u8, b: *[]const u8) bool { - _ = a; _ = b; + _ = a; + _ = b; return true; } -export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&foo)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/passing_an_under-aligned_function_pointer.zig b/test/cases/compile_errors/passing_an_under-aligned_function_pointer.zig index 3e3500e71fc7..6d3e2e871d14 100644 --- a/test/cases/compile_errors/passing_an_under-aligned_function_pointer.zig +++ b/test/cases/compile_errors/passing_an_under-aligned_function_pointer.zig @@ -4,7 +4,9 @@ export fn entry() void { fn testImplicitlyDecreaseFnAlign(ptr: *const fn () align(8) i32, answer: i32) void { if (ptr() != answer) unreachable; } -fn alignedSmall() align(4) i32 { return 1234; } +fn alignedSmall() align(4) i32 { + return 1234; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/pointer_to_noreturn.zig b/test/cases/compile_errors/pointer_to_noreturn.zig index 0891fd36997f..5d757f631b46 100644 --- a/test/cases/compile_errors/pointer_to_noreturn.zig +++ b/test/cases/compile_errors/pointer_to_noreturn.zig @@ -1,5 +1,7 @@ fn a() *noreturn {} -export fn entry() void { _ = a(); } +export fn entry() void { + _ = a(); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/ptrFromInt_non_ptr_type.zig b/test/cases/compile_errors/ptrFromInt_non_ptr_type.zig new file mode 100644 index 000000000000..f472789affcf --- /dev/null +++ b/test/cases/compile_errors/ptrFromInt_non_ptr_type.zig @@ -0,0 +1,15 @@ +pub export fn entry() void { + _ = @ptrFromInt(i32, 10); +} + +pub export fn entry2() void { + _ = @ptrFromInt([]u8, 20); +} + +// error +// backend=stage2 +// target=native +// +// :2:21: error: expected pointer type, found 'i32' +// :6:21: error: integer cannot be converted to slice type '[]u8' +// :6:21: note: slice length cannot be inferred from address diff --git a/test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig b/test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig new file mode 100644 index 000000000000..c45e998d825e --- /dev/null +++ b/test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig @@ -0,0 +1,10 @@ +pub export fn entry() void { + var y = @ptrFromInt([*]align(4) u8, 5); + _ = y; +} + +// error +// backend=stage2 +// target=native +// +// :2:41: error: pointer type '[*]align(4) u8' requires aligned address diff --git a/test/cases/compile_errors/ptrToInt_0_to_non_optional_pointer.zig b/test/cases/compile_errors/ptrToInt_0_to_non_optional_pointer.zig deleted file mode 100644 index 86a5dd6dca3e..000000000000 --- a/test/cases/compile_errors/ptrToInt_0_to_non_optional_pointer.zig +++ /dev/null @@ -1,10 +0,0 @@ -export fn entry() void { - var b = @intToPtr(*i32, 0); - _ = b; -} - -// error -// backend=stage2 -// target=native -// -// :2:29: error: pointer type '*i32' does not allow address zero diff --git a/test/cases/compile_errors/range_operator_in_switch_used_on_error_set.zig b/test/cases/compile_errors/range_operator_in_switch_used_on_error_set.zig index 859197929c6f..99dd773f32a6 100644 --- a/test/cases/compile_errors/range_operator_in_switch_used_on_error_set.zig +++ b/test/cases/compile_errors/range_operator_in_switch_used_on_error_set.zig @@ -1,13 +1,13 @@ export fn entry() void { foo(452) catch |err| switch (err) { - error.Foo ... error.Bar => {}, + error.Foo...error.Bar => {}, else => {}, }; } fn foo(x: i32) !void { switch (x) { - 0 ... 10 => return error.Foo, - 11 ... 20 => return error.Bar, + 0...10 => return error.Foo, + 11...20 => return error.Bar, else => {}, } } @@ -17,4 +17,4 @@ fn foo(x: i32) !void { // target=native // // :2:34: error: ranges not allowed when switching on type '@typeInfo(@typeInfo(@TypeOf(tmp.foo)).Fn.return_type.?).ErrorUnion.error_set' -// :3:19: note: range here +// :3:18: note: range here diff --git a/test/cases/compile_errors/reassign_to_array_parameter.zig b/test/cases/compile_errors/reassign_to_array_parameter.zig index 492732997065..380fd6215436 100644 --- a/test/cases/compile_errors/reassign_to_array_parameter.zig +++ b/test/cases/compile_errors/reassign_to_array_parameter.zig @@ -1,8 +1,8 @@ fn reassign(a: [3]f32) void { - a = [3]f32{4, 5, 6}; + a = [3]f32{ 4, 5, 6 }; } export fn entry() void { - reassign(.{1, 2, 3}); + reassign(.{ 1, 2, 3 }); } // error diff --git a/test/cases/compile_errors/reassign_to_struct_parameter.zig b/test/cases/compile_errors/reassign_to_struct_parameter.zig index 963448f8fe0e..560de215b532 100644 --- a/test/cases/compile_errors/reassign_to_struct_parameter.zig +++ b/test/cases/compile_errors/reassign_to_struct_parameter.zig @@ -2,10 +2,10 @@ const S = struct { x: u32, }; fn reassign(s: S) void { - s = S{.x = 2}; + s = S{ .x = 2 }; } export fn entry() void { - reassign(S{.x = 3}); + reassign(S{ .x = 3 }); } // error diff --git a/test/cases/compile_errors/redefinition_of_enums.zig b/test/cases/compile_errors/redefinition_of_enums.zig index 641211872e12..34d5efe8df86 100644 --- a/test/cases/compile_errors/redefinition_of_enums.zig +++ b/test/cases/compile_errors/redefinition_of_enums.zig @@ -1,5 +1,5 @@ -const A = enum {x}; -const A = enum {x}; +const A = enum { x }; +const A = enum { x }; // error // backend=stage2 diff --git a/test/cases/compile_errors/redefinition_of_global_variables.zig b/test/cases/compile_errors/redefinition_of_global_variables.zig index ed0d6f3ed95b..6f4ed225f791 100644 --- a/test/cases/compile_errors/redefinition_of_global_variables.zig +++ b/test/cases/compile_errors/redefinition_of_global_variables.zig @@ -1,5 +1,5 @@ -var a : i32 = 1; -var a : i32 = 2; +var a: i32 = 1; +var a: i32 = 2; // error // backend=stage2 diff --git a/test/cases/compile_errors/redefinition_of_struct.zig b/test/cases/compile_errors/redefinition_of_struct.zig index dc6d4abeebea..22852966dbc2 100644 --- a/test/cases/compile_errors/redefinition_of_struct.zig +++ b/test/cases/compile_errors/redefinition_of_struct.zig @@ -1,5 +1,5 @@ -const A = struct { x : i32, }; -const A = struct { y : i32, }; +const A = struct { x: i32 }; +const A = struct { y: i32 }; // error // backend=stage2 diff --git a/test/cases/compile_errors/reference_to_const_data.zig b/test/cases/compile_errors/reference_to_const_data.zig index cbc0fe131cfa..e773cdb4a088 100644 --- a/test/cases/compile_errors/reference_to_const_data.zig +++ b/test/cases/compile_errors/reference_to_const_data.zig @@ -1,5 +1,5 @@ export fn foo() void { - var ptr = &[_]u8{0,0,0,0}; + var ptr = &[_]u8{ 0, 0, 0, 0 }; ptr[1] = 2; } export fn bar() void { @@ -11,11 +11,11 @@ export fn baz() void { ptr.* = false; } export fn qux() void { - const S = struct{ + const S = struct { x: usize, y: usize, }; - var ptr = &S{.x=1,.y=2}; + var ptr = &S{ .x = 1, .y = 2 }; ptr.x = 2; } export fn quux() void { diff --git a/test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig b/test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig index abdccdf36df6..bb2c4bbe6282 100644 --- a/test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig +++ b/test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig @@ -8,7 +8,9 @@ const Foo = @Type(.{ .params = &.{}, }, }); -comptime { _ = Foo; } +comptime { + _ = Foo; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig b/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig index f3542d583a13..a341435b36ba 100644 --- a/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig +++ b/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig @@ -8,7 +8,9 @@ const Foo = @Type(.{ .params = &.{}, }, }); -comptime { _ = Foo; } +comptime { + _ = Foo; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig b/test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig index 49335ab69336..d348a0c908a0 100644 --- a/test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig +++ b/test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig @@ -8,7 +8,9 @@ const Foo = @Type(.{ .params = &.{}, }, }); -comptime { _ = Foo; } +comptime { + _ = Foo; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig b/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig index 60c6ce9a59ac..9b140a0923f6 100644 --- a/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig +++ b/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig @@ -7,7 +7,7 @@ const Tag = @Type(.{ }, }); export fn entry() void { - _ = @intToEnum(Tag, 0); + _ = @enumFromInt(Tag, 0); } // error diff --git a/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig b/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig index 896d68904623..b2cd8e1214ee 100644 --- a/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig +++ b/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig @@ -7,7 +7,7 @@ const Tag = @Type(.{ }, }); export fn entry() void { - _ = @intToEnum(Tag, 0); + _ = @enumFromInt(Tag, 0); } // error diff --git a/test/cases/compile_errors/reify_type_union_payload_is_undefined.zig b/test/cases/compile_errors/reify_type_union_payload_is_undefined.zig index 410bb9265811..886d443a00c0 100644 --- a/test/cases/compile_errors/reify_type_union_payload_is_undefined.zig +++ b/test/cases/compile_errors/reify_type_union_payload_is_undefined.zig @@ -1,7 +1,9 @@ const Foo = @Type(.{ .Struct = undefined, }); -comptime { _ = Foo; } +comptime { + _ = Foo; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/return_from_defer_expression.zig b/test/cases/compile_errors/return_from_defer_expression.zig index 12aa08a11cdc..28d1b0c6c6c4 100644 --- a/test/cases/compile_errors/return_from_defer_expression.zig +++ b/test/cases/compile_errors/return_from_defer_expression.zig @@ -6,13 +6,15 @@ pub fn testTrickyDefer() !void { const a = maybeInt() orelse return; } -fn canFail() anyerror!void { } +fn canFail() anyerror!void {} pub fn maybeInt() ?i32 { return 0; } -export fn entry() usize { return @sizeOf(@TypeOf(testTrickyDefer)); } +export fn entry() usize { + return @sizeOf(@TypeOf(testTrickyDefer)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig b/test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig index 5949031fb926..39e966267992 100644 --- a/test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig +++ b/test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig @@ -4,7 +4,7 @@ const Foo = struct { }; export fn f() void { var x: u8 = 0; - const foo = Foo { .Bar = x, .Baz = u8 }; + const foo = Foo{ .Bar = x, .Baz = u8 }; _ = foo; } @@ -12,5 +12,5 @@ export fn f() void { // backend=stage2 // target=native // -// :7:30: error: unable to resolve comptime value -// :7:30: note: initializer of comptime only struct must be comptime-known +// :7:29: error: unable to resolve comptime value +// :7:29: note: initializer of comptime only struct must be comptime-known diff --git a/test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig b/test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig index 04e2a97e7aa0..71a490bc2f89 100644 --- a/test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig +++ b/test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig @@ -4,7 +4,7 @@ const Foo = union { }; export fn f() void { var x: u8 = 0; - const foo = Foo { .Bar = x }; + const foo = Foo{ .Bar = x }; _ = foo; } @@ -12,5 +12,5 @@ export fn f() void { // backend=stage2 // target=native // -// :7:30: error: unable to resolve comptime value -// :7:30: note: initializer of comptime only union must be comptime-known +// :7:29: error: unable to resolve comptime value +// :7:29: note: initializer of comptime only union must be comptime-known diff --git a/test/cases/compile_errors/runtime_to_comptime_num.zig b/test/cases/compile_errors/runtime_to_comptime_num.zig index 972adb59bb40..8d4a3fb999f5 100644 --- a/test/cases/compile_errors/runtime_to_comptime_num.zig +++ b/test/cases/compile_errors/runtime_to_comptime_num.zig @@ -2,16 +2,16 @@ pub export fn entry() void { var a: u32 = 0; _ = @as(comptime_int, a); } -pub export fn entry2() void{ +pub export fn entry2() void { var a: u32 = 0; _ = @as(comptime_float, a); } -pub export fn entry3() void{ +pub export fn entry3() void { comptime var aa: comptime_float = 0.0; var a: f32 = 4; aa = a; } -pub export fn entry4() void{ +pub export fn entry4() void { comptime var aa: comptime_int = 0.0; var a: f32 = 4; aa = a; diff --git a/test/cases/compile_errors/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig b/test/cases/compile_errors/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig index c8e95e3969e5..e835db2cdf4d 100644 --- a/test/cases/compile_errors/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig +++ b/test/cases/compile_errors/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig @@ -1,12 +1,12 @@ export fn a() void { comptime { - var x = @as(i32, 1); - x <<|= @as(i32, -2); - } + var x = @as(i32, 1); + x <<|= @as(i32, -2); + } } // error // backend=stage2 // target=native // -// :4:14: error: shift by negative amount '-2' +// :4:16: error: shift by negative amount '-2' diff --git a/test/cases/compile_errors/self_referential_struct_requires_comptime.zig b/test/cases/compile_errors/self_referential_struct_requires_comptime.zig index 3ce75710267c..661a12df97c8 100644 --- a/test/cases/compile_errors/self_referential_struct_requires_comptime.zig +++ b/test/cases/compile_errors/self_referential_struct_requires_comptime.zig @@ -7,7 +7,6 @@ pub export fn entry() void { _ = s; } - // error // backend=stage2 // target=native diff --git a/test/cases/compile_errors/setAlignStack_in_inline_function.zig b/test/cases/compile_errors/setAlignStack_in_inline_function.zig index 62bbb3865c9c..a84424e368c0 100644 --- a/test/cases/compile_errors/setAlignStack_in_inline_function.zig +++ b/test/cases/compile_errors/setAlignStack_in_inline_function.zig @@ -1,7 +1,7 @@ export fn entry() void { foo(); } -fn foo() callconv(.Inline) void { +inline fn foo() void { @setAlignStack(16); } @@ -12,7 +12,6 @@ fn bar() void { @setAlignStack(16); } - // error // backend=stage2 // target=native diff --git a/test/cases/compile_errors/slice_passed_as_array_init_type_with_elems.zig b/test/cases/compile_errors/slice_passed_as_array_init_type_with_elems.zig index 7af505e20d34..91dc5f512899 100644 --- a/test/cases/compile_errors/slice_passed_as_array_init_type_with_elems.zig +++ b/test/cases/compile_errors/slice_passed_as_array_init_type_with_elems.zig @@ -1,5 +1,5 @@ export fn entry() void { - const x = []u8{1, 2}; + const x = []u8{ 1, 2 }; _ = x; } diff --git a/test/cases/compile_errors/slice_sentinel_mismatch-2.zig b/test/cases/compile_errors/slice_sentinel_mismatch-2.zig index ea34805e32ef..42c1328bb6fc 100644 --- a/test/cases/compile_errors/slice_sentinel_mismatch-2.zig +++ b/test/cases/compile_errors/slice_sentinel_mismatch-2.zig @@ -2,7 +2,9 @@ fn foo() [:0]u8 { var x: []u8 = undefined; return x; } -comptime { _ = &foo; } +comptime { + _ = &foo; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/slice_used_as_extern_fn_param.zig b/test/cases/compile_errors/slice_used_as_extern_fn_param.zig index 8391c3e21bfa..e6b065cd623f 100644 --- a/test/cases/compile_errors/slice_used_as_extern_fn_param.zig +++ b/test/cases/compile_errors/slice_used_as_extern_fn_param.zig @@ -1,4 +1,4 @@ -extern fn Text(str: []const u8, num: i32) callconv(.C) void; +extern fn Text(str: []const u8, num: i32) callconv(.C) void; export fn entry() void { _ = Text; } diff --git a/test/cases/compile_errors/specify_enum_tag_type_that_is_too_small.zig b/test/cases/compile_errors/specify_enum_tag_type_that_is_too_small.zig index d878bec18b0d..3024f1dee841 100644 --- a/test/cases/compile_errors/specify_enum_tag_type_that_is_too_small.zig +++ b/test/cases/compile_errors/specify_enum_tag_type_that_is_too_small.zig @@ -1,4 +1,4 @@ -const Small = enum (u2) { +const Small = enum(u2) { One, Two, Three, diff --git a/test/cases/compile_errors/specify_non-integer_enum_tag_type.zig b/test/cases/compile_errors/specify_non-integer_enum_tag_type.zig index f2ff3e2cd142..4fa7691a1174 100644 --- a/test/cases/compile_errors/specify_non-integer_enum_tag_type.zig +++ b/test/cases/compile_errors/specify_non-integer_enum_tag_type.zig @@ -1,4 +1,4 @@ -const Small = enum (f32) { +const Small = enum(f32) { One, Two, Three, @@ -13,4 +13,4 @@ export fn entry() void { // backend=stage2 // target=native // -// :1:21: error: expected integer tag type, found 'f32' +// :1:20: error: expected integer tag type, found 'f32' diff --git a/test/cases/compile_errors/src_fields_runtime.zig b/test/cases/compile_errors/src_fields_runtime.zig index 0bdb5af81cbe..a9828311233a 100644 --- a/test/cases/compile_errors/src_fields_runtime.zig +++ b/test/cases/compile_errors/src_fields_runtime.zig @@ -4,7 +4,10 @@ pub export fn entry1() void { comptime var b: []const u8 = s.fn_name; comptime var c: u32 = s.column; comptime var d: u32 = s.line; - _ = a; _ = b; _ = c; _ = d; + _ = a; + _ = b; + _ = c; + _ = d; } // error diff --git a/test/cases/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig b/test/cases/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig index c8d31ec8dfac..75f43ed914b9 100644 --- a/test/cases/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig +++ b/test/cases/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig @@ -1,10 +1,8 @@ fn Foo(comptime T: type) Foo(T) { - return struct{ x: T }; + return struct { x: T }; } export fn entry() void { - const t = Foo(u32) { - .x = 1 - }; + const t = Foo(u32){ .x = 1 }; _ = t; } diff --git a/test/cases/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig b/test/cases/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig index 7c70fc509528..5bcf30547b5f 100644 --- a/test/cases/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig +++ b/test/cases/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig @@ -1,6 +1,10 @@ export fn foo() void { var bar: u32 = 3; - asm volatile ("" : [baz]"+r"(bar) : : ""); + asm volatile ("" + : [baz] "+r" (bar), + : + : "" + ); } // error diff --git a/test/cases/compile_errors/std.fmt_error_for_unused_arguments.zig b/test/cases/compile_errors/std.fmt_error_for_unused_arguments.zig index a20f2798bc8d..6661fe54eba8 100644 --- a/test/cases/compile_errors/std.fmt_error_for_unused_arguments.zig +++ b/test/cases/compile_errors/std.fmt_error_for_unused_arguments.zig @@ -1,5 +1,5 @@ export fn entry() void { - @import("std").debug.print("{d} {d} {d} {d} {d}", .{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}); + @import("std").debug.print("{d} {d} {d} {d} {d}", .{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }); } // error diff --git a/test/cases/compile_errors/struct_type_mismatch_in_arg.zig b/test/cases/compile_errors/struct_type_mismatch_in_arg.zig index d051966c523d..32bbc6564823 100644 --- a/test/cases/compile_errors/struct_type_mismatch_in_arg.zig +++ b/test/cases/compile_errors/struct_type_mismatch_in_arg.zig @@ -1,18 +1,18 @@ const Foo = struct { i: i32 }; const Bar = struct { j: i32 }; -pub fn helper(_: Foo, _: Bar) void { } +pub fn helper(_: Foo, _: Bar) void {} comptime { - helper(Bar { .j = 10 }, Bar { .j = 10 }); - helper(Bar { .i = 10 }, Bar { .j = 10 }); + helper(Bar{ .j = 10 }, Bar{ .j = 10 }); + helper(Bar{ .i = 10 }, Bar{ .j = 10 }); } // error // backend=stage2 // target=native // -// :7:16: error: expected type 'tmp.Foo', found 'tmp.Bar' +// :7:15: error: expected type 'tmp.Foo', found 'tmp.Bar' // :2:13: note: struct declared here // :1:13: note: struct declared here // :4:18: note: parameter type declared here diff --git a/test/cases/compile_errors/struct_type_returned_from_non-generic_function.zig b/test/cases/compile_errors/struct_type_returned_from_non-generic_function.zig index 27e2b7b1db4f..f5647625ddbb 100644 --- a/test/cases/compile_errors/struct_type_returned_from_non-generic_function.zig +++ b/test/cases/compile_errors/struct_type_returned_from_non-generic_function.zig @@ -1,5 +1,5 @@ pub export fn entry(param: usize) usize { - return struct{ param }; + return struct { param }; } // error diff --git a/test/cases/compile_errors/struct_with_declarations_unavailable_for_reify_type.zig b/test/cases/compile_errors/struct_with_declarations_unavailable_for_reify_type.zig index 81864160dcc1..f0a24632283e 100644 --- a/test/cases/compile_errors/struct_with_declarations_unavailable_for_reify_type.zig +++ b/test/cases/compile_errors/struct_with_declarations_unavailable_for_reify_type.zig @@ -1,5 +1,7 @@ export fn entry() void { - _ = @Type(@typeInfo(struct { const foo = 1; })); + _ = @Type(@typeInfo(struct { + const foo = 1; + })); } // error diff --git a/test/cases/compile_errors/struct_with_invalid_field.zig b/test/cases/compile_errors/struct_with_invalid_field.zig index aa24b029bb73..dbcf5243c25b 100644 --- a/test/cases/compile_errors/struct_with_invalid_field.zig +++ b/test/cases/compile_errors/struct_with_invalid_field.zig @@ -1,10 +1,10 @@ -const std = @import("std",); +const std = @import( + "std", +); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; -const HeaderWeight = enum { - H1, H2, H3, H4, H5, H6, -}; +const HeaderWeight = enum { H1, H2, H3, H4, H5, H6 }; const MdText = ArrayList(u8); @@ -16,7 +16,7 @@ const MdNode = union(enum) { }; export fn entry() void { - const a = MdNode.Header { + const a = MdNode.Header{ .text = MdText.init(std.testing.allocator), .weight = HeaderWeight.H1, }; diff --git a/test/cases/compile_errors/sub_overflow_in_function_evaluation.zig b/test/cases/compile_errors/sub_overflow_in_function_evaluation.zig index c87f99837309..651ef34bdcd6 100644 --- a/test/cases/compile_errors/sub_overflow_in_function_evaluation.zig +++ b/test/cases/compile_errors/sub_overflow_in_function_evaluation.zig @@ -3,7 +3,9 @@ fn sub(a: u16, b: u16) u16 { return a - b; } -export fn entry() usize { return @sizeOf(@TypeOf(&y)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&y)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/suspend_inside_suspend_block.zig b/test/cases/compile_errors/suspend_inside_suspend_block.zig index 80436bd07f7f..29a7968e0baa 100644 --- a/test/cases/compile_errors/suspend_inside_suspend_block.zig +++ b/test/cases/compile_errors/suspend_inside_suspend_block.zig @@ -3,8 +3,7 @@ export fn entry() void { } fn foo() void { suspend { - suspend { - } + suspend {} } } diff --git a/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong.zig b/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong.zig index 7011f0a2d5a0..58f98a55f57c 100644 --- a/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong.zig +++ b/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong.zig @@ -14,7 +14,9 @@ fn f(n: Number) i32 { } } -export fn entry() usize { return @sizeOf(@TypeOf(&f)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&f)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong_when_else_present.zig b/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong_when_else_present.zig index 89f195937576..045760e287c2 100644 --- a/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong_when_else_present.zig +++ b/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong_when_else_present.zig @@ -15,7 +15,9 @@ fn f(n: Number) i32 { } } -export fn entry() usize { return @sizeOf(@TypeOf(&f)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&f)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/switch_expression-duplicate_or_overlapping_integer_value.zig b/test/cases/compile_errors/switch_expression-duplicate_or_overlapping_integer_value.zig index 60e361a47afe..6e5bd5384603 100644 --- a/test/cases/compile_errors/switch_expression-duplicate_or_overlapping_integer_value.zig +++ b/test/cases/compile_errors/switch_expression-duplicate_or_overlapping_integer_value.zig @@ -1,16 +1,18 @@ fn foo(x: u8) u8 { return switch (x) { - 0 ... 100 => @as(u8, 0), - 101 ... 200 => 1, - 201, 203 ... 207 => 2, - 206 ... 255 => 3, + 0...100 => @as(u8, 0), + 101...200 => 1, + 201, 203...207 => 2, + 206...255 => 3, }; } -export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&foo)); +} // error // backend=stage2 // target=native // -// :6:13: error: duplicate switch value -// :5:18: note: previous value here +// :6:12: error: duplicate switch value +// :5:17: note: previous value here diff --git a/test/cases/compile_errors/switch_expression-duplicate_type.zig b/test/cases/compile_errors/switch_expression-duplicate_type.zig index 59c9b0657a26..44f745364c39 100644 --- a/test/cases/compile_errors/switch_expression-duplicate_type.zig +++ b/test/cases/compile_errors/switch_expression-duplicate_type.zig @@ -7,7 +7,9 @@ fn foo(comptime T: type, x: T) u8 { else => 3, }; } -export fn entry() usize { return @sizeOf(@TypeOf(foo(u32, 0))); } +export fn entry() usize { + return @sizeOf(@TypeOf(foo(u32, 0))); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/switch_expression-duplicate_type_struct_alias.zig b/test/cases/compile_errors/switch_expression-duplicate_type_struct_alias.zig index 797d2bd50d30..4420e575c95f 100644 --- a/test/cases/compile_errors/switch_expression-duplicate_type_struct_alias.zig +++ b/test/cases/compile_errors/switch_expression-duplicate_type_struct_alias.zig @@ -11,7 +11,9 @@ fn foo(comptime T: type, x: T) u8 { else => 3, }; } -export fn entry() usize { return @sizeOf(@TypeOf(foo(u32, 0))); } +export fn entry() usize { + return @sizeOf(@TypeOf(foo(u32, 0))); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/switch_expression-missing_enumeration_prong.zig b/test/cases/compile_errors/switch_expression-missing_enumeration_prong.zig index 1075b837de7f..ca80d420ff93 100644 --- a/test/cases/compile_errors/switch_expression-missing_enumeration_prong.zig +++ b/test/cases/compile_errors/switch_expression-missing_enumeration_prong.zig @@ -12,7 +12,9 @@ fn f(n: Number) i32 { } } -export fn entry() usize { return @sizeOf(@TypeOf(&f)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&f)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/switch_expression-non_exhaustive_integer_prongs.zig b/test/cases/compile_errors/switch_expression-non_exhaustive_integer_prongs.zig index 6770b5a0555c..83097f273391 100644 --- a/test/cases/compile_errors/switch_expression-non_exhaustive_integer_prongs.zig +++ b/test/cases/compile_errors/switch_expression-non_exhaustive_integer_prongs.zig @@ -3,7 +3,9 @@ fn foo(x: u8) void { 0 => {}, } } -export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&foo)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/switch_expression-switch_on_pointer_type_with_no_else.zig b/test/cases/compile_errors/switch_expression-switch_on_pointer_type_with_no_else.zig index bbad58c74c84..32491170ebbd 100644 --- a/test/cases/compile_errors/switch_expression-switch_on_pointer_type_with_no_else.zig +++ b/test/cases/compile_errors/switch_expression-switch_on_pointer_type_with_no_else.zig @@ -4,7 +4,9 @@ fn foo(x: *u8) void { } } var y: u8 = 100; -export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&foo)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/switch_expression-unreachable_else_prong_bool.zig b/test/cases/compile_errors/switch_expression-unreachable_else_prong_bool.zig index 5dfc839c13f6..859f97fa8af5 100644 --- a/test/cases/compile_errors/switch_expression-unreachable_else_prong_bool.zig +++ b/test/cases/compile_errors/switch_expression-unreachable_else_prong_bool.zig @@ -5,7 +5,9 @@ fn foo(x: bool) void { else => {}, } } -export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&foo)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/switch_expression-unreachable_else_prong_enum.zig b/test/cases/compile_errors/switch_expression-unreachable_else_prong_enum.zig index cc837b8b5e1f..e7bb8d392f0d 100644 --- a/test/cases/compile_errors/switch_expression-unreachable_else_prong_enum.zig +++ b/test/cases/compile_errors/switch_expression-unreachable_else_prong_enum.zig @@ -1,4 +1,4 @@ -const TestEnum = enum{ T1, T2 }; +const TestEnum = enum { T1, T2 }; fn err(x: u8) TestEnum { switch (x) { @@ -15,7 +15,9 @@ fn foo(x: u8) void { } } -export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&foo)); +} // error // backend=llvm diff --git a/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_i8.zig b/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_i8.zig index bcb84eed122d..861b0ceaeece 100644 --- a/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_i8.zig +++ b/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_i8.zig @@ -8,7 +8,9 @@ fn foo(x: i8) void { else => {}, } } -export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&foo)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_u8.zig b/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_u8.zig index 2230434ea065..16fdea91ea17 100644 --- a/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_u8.zig +++ b/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_u8.zig @@ -8,7 +8,9 @@ fn foo(x: u8) void { else => {}, } } -export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&foo)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/switch_expression-unreachable_else_prong_u1.zig b/test/cases/compile_errors/switch_expression-unreachable_else_prong_u1.zig index 58458474a4fc..3d7988454e27 100644 --- a/test/cases/compile_errors/switch_expression-unreachable_else_prong_u1.zig +++ b/test/cases/compile_errors/switch_expression-unreachable_else_prong_u1.zig @@ -5,7 +5,9 @@ fn foo(x: u1) void { else => {}, } } -export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&foo)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/switch_expression-unreachable_else_prong_u2.zig b/test/cases/compile_errors/switch_expression-unreachable_else_prong_u2.zig index 9e337cb2007c..dd8f315dcdb1 100644 --- a/test/cases/compile_errors/switch_expression-unreachable_else_prong_u2.zig +++ b/test/cases/compile_errors/switch_expression-unreachable_else_prong_u2.zig @@ -7,7 +7,9 @@ fn foo(x: u2) void { else => {}, } } -export fn entry() usize { return @sizeOf(@TypeOf(&foo)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&foo)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig b/test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig index 3dad0be9df20..e3d09bc13333 100644 --- a/test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig +++ b/test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig @@ -1,4 +1,4 @@ -const E = enum{ +const E = enum { a, b, }; diff --git a/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig b/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig index 435d409dd48e..5678102fc6c5 100644 --- a/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig +++ b/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig @@ -22,7 +22,7 @@ pub export fn entry2() void { } } pub export fn entry3() void { - var u = U{.a = 2}; + var u = U{ .a = 2 }; switch (u) { // error: `_` prong not allowed when switching on tagged union .a => {}, .b => {}, diff --git a/test/cases/compile_errors/tagName_on_invalid_value_of_non-exhaustive_enum.zig b/test/cases/compile_errors/tagName_on_invalid_value_of_non-exhaustive_enum.zig index 3523a360549f..df454a38d004 100644 --- a/test/cases/compile_errors/tagName_on_invalid_value_of_non-exhaustive_enum.zig +++ b/test/cases/compile_errors/tagName_on_invalid_value_of_non-exhaustive_enum.zig @@ -1,6 +1,6 @@ test "enum" { const E = enum(u8) { A, B, _ }; - _ = @tagName(@intToEnum(E, 5)); + _ = @tagName(@enumFromInt(E, 5)); } // error @@ -8,5 +8,5 @@ test "enum" { // target=native // is_test=1 // -// :3:9: error: no field with value '@intToEnum(tmp.test.enum.E, 5)' in enum 'test.enum.E' +// :3:9: error: no field with value '@enumFromInt(tmp.test.enum.E, 5)' in enum 'test.enum.E' // :2:15: note: declared here diff --git a/test/cases/compile_errors/tagName_used_on_union_with_no_associated_enum_tag.zig b/test/cases/compile_errors/tagName_used_on_union_with_no_associated_enum_tag.zig index cbe0f642a5fb..28eaa9bad815 100644 --- a/test/cases/compile_errors/tagName_used_on_union_with_no_associated_enum_tag.zig +++ b/test/cases/compile_errors/tagName_used_on_union_with_no_associated_enum_tag.zig @@ -3,7 +3,7 @@ const FloatInt = extern union { Int: i32, }; export fn entry() void { - var fi = FloatInt{.Float = 123.45}; + var fi = FloatInt{ .Float = 123.45 }; var tagName = @tagName(fi); _ = tagName; } diff --git a/test/cases/compile_errors/top_level_decl_dependency_loop.zig b/test/cases/compile_errors/top_level_decl_dependency_loop.zig index 8ba3d98ea28f..5657ca52fe3c 100644 --- a/test/cases/compile_errors/top_level_decl_dependency_loop.zig +++ b/test/cases/compile_errors/top_level_decl_dependency_loop.zig @@ -1,5 +1,5 @@ -const a : @TypeOf(b) = 0; -const b : @TypeOf(a) = 0; +const a: @TypeOf(b) = 0; +const b: @TypeOf(a) = 0; export fn entry() void { const c = a + b; _ = c; diff --git a/test/cases/compile_errors/try_in_function_with_non_error_return_type.zig b/test/cases/compile_errors/try_in_function_with_non_error_return_type.zig index 44d8b9ee56ee..96b098237034 100644 --- a/test/cases/compile_errors/try_in_function_with_non_error_return_type.zig +++ b/test/cases/compile_errors/try_in_function_with_non_error_return_type.zig @@ -1,7 +1,7 @@ export fn f() void { try something(); } -fn something() anyerror!void { } +fn something() anyerror!void {} // error // backend=stage2 diff --git a/test/cases/compile_errors/tuple_init_edge_cases.zig b/test/cases/compile_errors/tuple_init_edge_cases.zig index f093515a3867..2ac275f2b73d 100644 --- a/test/cases/compile_errors/tuple_init_edge_cases.zig +++ b/test/cases/compile_errors/tuple_init_edge_cases.zig @@ -1,44 +1,56 @@ pub export fn entry1() void { const T = @TypeOf(.{ 123, 3 }); - var b = T{ .@"1" = 3 }; _ = b; - var c = T{ 123, 3 }; _ = c; - var d = T{}; _ = d; + var b = T{ .@"1" = 3 }; + _ = b; + var c = T{ 123, 3 }; + _ = c; + var d = T{}; + _ = d; } pub export fn entry2() void { var a: u32 = 2; const T = @TypeOf(.{ 123, a }); - var b = T{ .@"1" = 3 }; _ = b; - var c = T{ 123, 3 }; _ = c; - var d = T{}; _ = d; + var b = T{ .@"1" = 3 }; + _ = b; + var c = T{ 123, 3 }; + _ = c; + var d = T{}; + _ = d; } pub export fn entry3() void { var a: u32 = 2; const T = @TypeOf(.{ 123, a }); - var b = T{ .@"0" = 123 }; _ = b; + var b = T{ .@"0" = 123 }; + _ = b; } comptime { var a: u32 = 2; const T = @TypeOf(.{ 123, a }); - var b = T{ .@"0" = 123 }; _ = b; - var c = T{ 123, 2 }; _ = c; - var d = T{}; _ = d; + var b = T{ .@"0" = 123 }; + _ = b; + var c = T{ 123, 2 }; + _ = c; + var d = T{}; + _ = d; } pub export fn entry4() void { var a: u32 = 2; const T = @TypeOf(.{ 123, a }); - var b = T{ 123, 4, 5 }; _ = b; + var b = T{ 123, 4, 5 }; + _ = b; } pub export fn entry5() void { var a: u32 = 2; const T = @TypeOf(.{ 123, a }); - var b = T{ .@"0" = 123, .@"2" = 123, .@"1" = 123 }; _ = b; + var b = T{ .@"0" = 123, .@"2" = 123, .@"1" = 123 }; + _ = b; } // error // backend=stage2 // target=native // -// :12:14: error: missing tuple field with index 1 // :17:14: error: missing tuple field with index 1 -// :29:14: error: expected at most 2 tuple fields; found 3 -// :34:30: error: index '2' out of bounds of tuple 'struct{comptime comptime_int = 123, u32}' +// :23:14: error: missing tuple field with index 1 +// :39:14: error: expected at most 2 tuple fields; found 3 +// :45:30: error: index '2' out of bounds of tuple 'struct{comptime comptime_int = 123, u32}' diff --git a/test/cases/compile_errors/type_checking_function_pointers.zig b/test/cases/compile_errors/type_checking_function_pointers.zig index f11330917061..a0fea6b60fd3 100644 --- a/test/cases/compile_errors/type_checking_function_pointers.zig +++ b/test/cases/compile_errors/type_checking_function_pointers.zig @@ -1,7 +1,9 @@ fn a(b: *const fn (*const u8) void) void { _ = b; } -fn c(d: u8) void {_ = d;} +fn c(d: u8) void { + _ = d; +} export fn entry() void { a(c); } @@ -10,6 +12,6 @@ export fn entry() void { // backend=stage2 // target=native // -// :6:7: error: expected type '*const fn(*const u8) void', found '*const fn(u8) void' -// :6:7: note: pointer type child 'fn(u8) void' cannot cast into pointer type child 'fn(*const u8) void' -// :6:7: note: parameter 0 'u8' cannot cast into '*const u8' +// :8:7: error: expected type '*const fn(*const u8) void', found '*const fn(u8) void' +// :8:7: note: pointer type child 'fn(u8) void' cannot cast into pointer type child 'fn(*const u8) void' +// :8:7: note: parameter 0 'u8' cannot cast into '*const u8' diff --git a/test/cases/compile_errors/undeclared_identifier.zig b/test/cases/compile_errors/undeclared_identifier.zig index 7edc0d2896bf..86ba2e2be0d0 100644 --- a/test/cases/compile_errors/undeclared_identifier.zig +++ b/test/cases/compile_errors/undeclared_identifier.zig @@ -1,11 +1,9 @@ export fn a() void { - return - b + - c; + return b + c; } // error // backend=stage2 // target=native // -// :3:5: error: use of undeclared identifier 'b' +// :2:12: error: use of undeclared identifier 'b' diff --git a/test/cases/compile_errors/union_auto-enum_value_already_taken.zig b/test/cases/compile_errors/union_auto-enum_value_already_taken.zig index 36b52c96b9bd..da2fefbad5a3 100644 --- a/test/cases/compile_errors/union_auto-enum_value_already_taken.zig +++ b/test/cases/compile_errors/union_auto-enum_value_already_taken.zig @@ -6,7 +6,7 @@ const MultipleChoice = union(enum(u32)) { E = 60, }; export fn entry() void { - var x = MultipleChoice { .C = {} }; + var x = MultipleChoice{ .C = {} }; _ = x; } diff --git a/test/cases/compile_errors/union_enum_field_does_not_match_enum.zig b/test/cases/compile_errors/union_enum_field_does_not_match_enum.zig index 3c1e2d53ef7a..6b70c0eaf4b4 100644 --- a/test/cases/compile_errors/union_enum_field_does_not_match_enum.zig +++ b/test/cases/compile_errors/union_enum_field_does_not_match_enum.zig @@ -10,7 +10,7 @@ const Payload = union(Letter) { D: bool, }; export fn entry() void { - var a = Payload {.A = 1234}; + var a = Payload{ .A = 1234 }; _ = a; } diff --git a/test/cases/compile_errors/unreachable_parameter.zig b/test/cases/compile_errors/unreachable_parameter.zig index 31649744321b..f00b24e07acf 100644 --- a/test/cases/compile_errors/unreachable_parameter.zig +++ b/test/cases/compile_errors/unreachable_parameter.zig @@ -1,5 +1,9 @@ -fn f(a: noreturn) void { _ = a; } -export fn entry() void { f(); } +fn f(a: noreturn) void { + _ = a; +} +export fn entry() void { + f(); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/unreachable_with_return.zig b/test/cases/compile_errors/unreachable_with_return.zig index 5293734c8200..083f36087370 100644 --- a/test/cases/compile_errors/unreachable_with_return.zig +++ b/test/cases/compile_errors/unreachable_with_return.zig @@ -1,9 +1,13 @@ -fn a() noreturn {return;} -export fn entry() void { a(); } +fn a() noreturn { + return; +} +export fn entry() void { + a(); +} // error // backend=stage2 // target=native // -// :1:18: error: function declared 'noreturn' returns +// :2:5: error: function declared 'noreturn' returns // :1:8: note: 'noreturn' declared here diff --git a/test/cases/compile_errors/while_expected_bool_got_error_union.zig b/test/cases/compile_errors/while_expected_bool_got_error_union.zig index ecf3dd0736fa..07b441188371 100644 --- a/test/cases/compile_errors/while_expected_bool_got_error_union.zig +++ b/test/cases/compile_errors/while_expected_bool_got_error_union.zig @@ -1,7 +1,9 @@ export fn foo() void { while (bar()) {} } -fn bar() anyerror!i32 { return 1; } +fn bar() anyerror!i32 { + return 1; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/while_expected_bool_got_optional.zig b/test/cases/compile_errors/while_expected_bool_got_optional.zig index 3db4b7ae74e4..2a2af57ef328 100644 --- a/test/cases/compile_errors/while_expected_bool_got_optional.zig +++ b/test/cases/compile_errors/while_expected_bool_got_optional.zig @@ -1,7 +1,9 @@ export fn foo() void { while (bar()) {} } -fn bar() ?i32 { return 1; } +fn bar() ?i32 { + return 1; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/while_expected_error_union_got_bool.zig b/test/cases/compile_errors/while_expected_error_union_got_bool.zig index f7960437ec55..6d31d2055baa 100644 --- a/test/cases/compile_errors/while_expected_error_union_got_bool.zig +++ b/test/cases/compile_errors/while_expected_error_union_got_bool.zig @@ -1,7 +1,13 @@ export fn foo() void { - while (bar()) |x| {_ = x;} else |err| {_ = err;} + while (bar()) |x| { + _ = x; + } else |err| { + _ = err; + } +} +fn bar() bool { + return true; } -fn bar() bool { return true; } // error // backend=stage2 diff --git a/test/cases/compile_errors/while_expected_error_union_got_optional.zig b/test/cases/compile_errors/while_expected_error_union_got_optional.zig index 5cabd76fce3f..6ebf96dc4c7f 100644 --- a/test/cases/compile_errors/while_expected_error_union_got_optional.zig +++ b/test/cases/compile_errors/while_expected_error_union_got_optional.zig @@ -1,7 +1,13 @@ export fn foo() void { - while (bar()) |x| {_ = x;} else |err| {_ = err;} + while (bar()) |x| { + _ = x; + } else |err| { + _ = err; + } +} +fn bar() ?i32 { + return 1; } -fn bar() ?i32 { return 1; } // error // backend=stage2 diff --git a/test/cases/compile_errors/while_expected_optional_got_bool.zig b/test/cases/compile_errors/while_expected_optional_got_bool.zig index 22b8c1e58c73..5ced72b49266 100644 --- a/test/cases/compile_errors/while_expected_optional_got_bool.zig +++ b/test/cases/compile_errors/while_expected_optional_got_bool.zig @@ -1,7 +1,11 @@ export fn foo() void { - while (bar()) |x| {_ = x;} + while (bar()) |x| { + _ = x; + } +} +fn bar() bool { + return true; } -fn bar() bool { return true; } // error // backend=stage2 diff --git a/test/cases/compile_errors/while_expected_optional_got_error_union.zig b/test/cases/compile_errors/while_expected_optional_got_error_union.zig index 38a8a0dd2038..7bde2c866d29 100644 --- a/test/cases/compile_errors/while_expected_optional_got_error_union.zig +++ b/test/cases/compile_errors/while_expected_optional_got_error_union.zig @@ -1,7 +1,11 @@ export fn foo() void { - while (bar()) |x| {_ = x;} + while (bar()) |x| { + _ = x; + } +} +fn bar() anyerror!i32 { + return 1; } -fn bar() anyerror!i32 { return 1; } // error // backend=stage2 diff --git a/test/cases/compile_errors/write_to_const_global_variable.zig b/test/cases/compile_errors/write_to_const_global_variable.zig index 5ffd3a305d06..075854c45462 100644 --- a/test/cases/compile_errors/write_to_const_global_variable.zig +++ b/test/cases/compile_errors/write_to_const_global_variable.zig @@ -1,8 +1,10 @@ -const x : i32 = 99; +const x: i32 = 99; fn f() void { x = 1; } -export fn entry() void { f(); } +export fn entry() void { + f(); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/wrong_function_type.zig b/test/cases/compile_errors/wrong_function_type.zig index 867bdccc1a6e..6dfa9bd70232 100644 --- a/test/cases/compile_errors/wrong_function_type.zig +++ b/test/cases/compile_errors/wrong_function_type.zig @@ -1,8 +1,16 @@ -const fns = [_]fn() void { a, b, c }; -fn a() i32 {return 0;} -fn b() i32 {return 1;} -fn c() i32 {return 2;} -export fn entry() usize { return @sizeOf(@TypeOf(fns)); } +const fns = [_]fn () void{ a, b, c }; +fn a() i32 { + return 0; +} +fn b() i32 { + return 1; +} +fn c() i32 { + return 2; +} +export fn entry() usize { + return @sizeOf(@TypeOf(fns)); +} // error // backend=stage2 diff --git a/test/cases/compile_errors/wrong_number_of_arguments.zig b/test/cases/compile_errors/wrong_number_of_arguments.zig index 05d761de18ca..b83a7a4a3706 100644 --- a/test/cases/compile_errors/wrong_number_of_arguments.zig +++ b/test/cases/compile_errors/wrong_number_of_arguments.zig @@ -1,7 +1,11 @@ export fn a() void { c(1); } -fn c(d: i32, e: i32, f: i32) void { _ = d; _ = e; _ = f; } +fn c(d: i32, e: i32, f: i32) void { + _ = d; + _ = e; + _ = f; +} // error // backend=stage2 diff --git a/test/cases/compile_errors/wrong_number_of_arguments_for_method_fn_call.zig b/test/cases/compile_errors/wrong_number_of_arguments_for_method_fn_call.zig index da6a7be4fa45..b0981e3d4df2 100644 --- a/test/cases/compile_errors/wrong_number_of_arguments_for_method_fn_call.zig +++ b/test/cases/compile_errors/wrong_number_of_arguments_for_method_fn_call.zig @@ -1,15 +1,19 @@ const Foo = struct { - fn method(self: *const Foo, a: i32) void {_ = self; _ = a;} + fn method(self: *const Foo, a: i32) void { + _ = self; + _ = a; + } }; fn f(foo: *const Foo) void { - foo.method(1, 2); } -export fn entry() usize { return @sizeOf(@TypeOf(&f)); } +export fn entry() usize { + return @sizeOf(@TypeOf(&f)); +} // error // backend=stage2 // target=native // -// :6:8: error: member function expected 1 argument(s), found 2 +// :8:8: error: member function expected 1 argument(s), found 2 // :2:5: note: function declared here diff --git a/test/cases/compile_errors/wrong_size_to_an_array_literal.zig b/test/cases/compile_errors/wrong_size_to_an_array_literal.zig index a38d8d4d8587..a58d6d984605 100644 --- a/test/cases/compile_errors/wrong_size_to_an_array_literal.zig +++ b/test/cases/compile_errors/wrong_size_to_an_array_literal.zig @@ -1,5 +1,5 @@ comptime { - const array = [2]u8{1, 2, 3}; + const array = [2]u8{ 1, 2, 3 }; _ = array; } diff --git a/test/cases/compile_errors/wrong_types_given_to_export.zig b/test/cases/compile_errors/wrong_types_given_to_export.zig index 2ae55b4a6317..6e688d33d65b 100644 --- a/test/cases/compile_errors/wrong_types_given_to_export.zig +++ b/test/cases/compile_errors/wrong_types_given_to_export.zig @@ -1,11 +1,11 @@ -fn entry() callconv(.C) void { } +fn entry() callconv(.C) void {} comptime { - @export(entry, .{.name = "entry", .linkage = @as(u32, 1234) }); + @export(entry, .{ .name = "entry", .linkage = @as(u32, 1234) }); } // error // backend=stage2 // target=native // -// :3:50: error: expected type 'builtin.GlobalLinkage', found 'u32' +// :3:51: error: expected type 'builtin.GlobalLinkage', found 'u32' // :?:?: note: enum declared here diff --git a/test/cases/comptime_var.2.zig b/test/cases/comptime_var.2.zig index 7c99aba62584..2d717cb802b2 100644 --- a/test/cases/comptime_var.2.zig +++ b/test/cases/comptime_var.2.zig @@ -8,7 +8,7 @@ pub fn main() void { } fn print(len: usize) void { - _ = write(1, @ptrToInt("Hello, World!\n"), len); + _ = write(1, @intFromPtr("Hello, World!\n"), len); } // run diff --git a/test/cases/comptime_var.6.zig b/test/cases/comptime_var.6.zig index 3b655e381e69..d4e96106bb1b 100644 --- a/test/cases/comptime_var.6.zig +++ b/test/cases/comptime_var.6.zig @@ -7,7 +7,7 @@ pub fn main() void { } } fn print(len: usize) void { - _ = write(1, @ptrToInt("Hello"), len); + _ = write(1, @intFromPtr("Hello"), len); } // run diff --git a/test/cases/conditional_branches.0.zig b/test/cases/conditional_branches.0.zig index 61c9fdd50ea2..d1fce95b2cd9 100644 --- a/test/cases/conditional_branches.0.zig +++ b/test/cases/conditional_branches.0.zig @@ -12,7 +12,7 @@ fn foo(x: u64) void { fn print() void { const str = "Hello, World!\n"; - _ = write(1, @ptrToInt(str.ptr), ptr.len); + _ = write(1, @intFromPtr(str.ptr), ptr.len); } // run diff --git a/test/cases/conditional_branches.1.zig b/test/cases/conditional_branches.1.zig index 2668133a7c9c..f402cd3bd499 100644 --- a/test/cases/conditional_branches.1.zig +++ b/test/cases/conditional_branches.1.zig @@ -15,7 +15,7 @@ fn foo(x: bool) void { fn print() void { const str = "Hello, World!\n"; - _ = write(1, @ptrToInt(str.ptr), ptr.len); + _ = write(1, @intFromPtr(str.ptr), ptr.len); } // run diff --git a/test/cases/decl_value_arena.zig b/test/cases/decl_value_arena.zig index 02062c454386..9c7c12903b29 100644 --- a/test/cases/decl_value_arena.zig +++ b/test/cases/decl_value_arena.zig @@ -1,20 +1,20 @@ pub const Protocols: struct { - list: *const fn(*Connection) void = undefined, - handShake: type = struct { - const stepStart: u8 = 0; - }, + list: *const fn (*Connection) void = undefined, + handShake: type = struct { + const stepStart: u8 = 0; + }, } = .{}; pub const Connection = struct { - streamBuffer: [0]u8 = undefined, - __lastReceivedPackets: [0]u8 = undefined, + streamBuffer: [0]u8 = undefined, + __lastReceivedPackets: [0]u8 = undefined, - handShakeState: u8 = Protocols.handShake.stepStart, + handShakeState: u8 = Protocols.handShake.stepStart, }; pub fn main() void { - var conn: Connection = undefined; - _ = conn; + var conn: Connection = undefined; + _ = conn; } // run diff --git a/test/cases/enum_values.0.zig b/test/cases/enum_values.0.zig index d96841dd8c65..2c44a095dde7 100644 --- a/test/cases/enum_values.0.zig +++ b/test/cases/enum_values.0.zig @@ -7,8 +7,8 @@ pub fn main() void { number1; number2; } - const number3 = @intToEnum(Number, 2); - if (@enumToInt(number3) != 2) { + const number3 = @enumFromInt(Number, 2); + if (@intFromEnum(number3) != 2) { unreachable; } return; diff --git a/test/cases/enum_values.1.zig b/test/cases/enum_values.1.zig index 47b9e21a2778..1b5a9836db8c 100644 --- a/test/cases/enum_values.1.zig +++ b/test/cases/enum_values.1.zig @@ -3,12 +3,12 @@ const Number = enum { One, Two, Three }; pub fn main() void { var number1 = Number.One; var number2: Number = .Two; - const number3 = @intToEnum(Number, 2); + const number3 = @enumFromInt(Number, 2); assert(number1 != number2); assert(number2 != number3); - assert(@enumToInt(number1) == 0); - assert(@enumToInt(number2) == 1); - assert(@enumToInt(number3) == 2); + assert(@intFromEnum(number1) == 0); + assert(@intFromEnum(number2) == 1); + assert(@intFromEnum(number3) == 2); var x: Number = .Two; assert(number2 == x); diff --git a/test/cases/error_in_nested_declaration.zig b/test/cases/error_in_nested_declaration.zig index 3fff746909a5..710b821e6552 100644 --- a/test/cases/error_in_nested_declaration.zig +++ b/test/cases/error_in_nested_declaration.zig @@ -5,7 +5,7 @@ const S = struct { pub fn str(_: @This(), extra: []u32) []i32 { return @bitCast([]i32, extra); } - }, + }, }; pub export fn entry() void { diff --git a/test/cases/hello_world_with_updates.2.zig b/test/cases/hello_world_with_updates.2.zig index be6dc58c7439..db5564e3a703 100644 --- a/test/cases/hello_world_with_updates.2.zig +++ b/test/cases/hello_world_with_updates.2.zig @@ -8,7 +8,7 @@ pub export fn main() noreturn { } fn print() void { - const msg = @ptrToInt("Hello, World!\n"); + const msg = @intFromPtr("Hello, World!\n"); const len = 14; _ = write(1, msg, len); } diff --git a/test/cases/hello_world_with_updates.3.zig b/test/cases/hello_world_with_updates.3.zig index f464c379aa6c..8c57d52924b2 100644 --- a/test/cases/hello_world_with_updates.3.zig +++ b/test/cases/hello_world_with_updates.3.zig @@ -5,7 +5,7 @@ pub fn main() void { } fn print() void { - const msg = @ptrToInt("Hello, World!\n"); + const msg = @intFromPtr("Hello, World!\n"); const len = 14; _ = write(1, msg, len); } diff --git a/test/cases/hello_world_with_updates.4.zig b/test/cases/hello_world_with_updates.4.zig index c9efbd0f35d2..54641a3ad5b9 100644 --- a/test/cases/hello_world_with_updates.4.zig +++ b/test/cases/hello_world_with_updates.4.zig @@ -8,7 +8,7 @@ pub fn main() void { } fn print() void { - const msg = @ptrToInt("Hello, World!\n"); + const msg = @intFromPtr("Hello, World!\n"); const len = 14; _ = write(1, msg, len); } diff --git a/test/cases/hello_world_with_updates.5.zig b/test/cases/hello_world_with_updates.5.zig index 5070ea457c3e..ae57d9b7b671 100644 --- a/test/cases/hello_world_with_updates.5.zig +++ b/test/cases/hello_world_with_updates.5.zig @@ -5,7 +5,7 @@ pub fn main() void { } fn print() void { - const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); + const msg = @intFromPtr("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); const len = 104; _ = write(1, msg, len); } diff --git a/test/cases/hello_world_with_updates.6.zig b/test/cases/hello_world_with_updates.6.zig index a33f2954e5f7..76f006992ed4 100644 --- a/test/cases/hello_world_with_updates.6.zig +++ b/test/cases/hello_world_with_updates.6.zig @@ -8,7 +8,7 @@ pub fn main() void { } fn print() void { - const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); + const msg = @intFromPtr("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); const len = 104; _ = write(1, msg, len); } diff --git a/test/cases/int_to_ptr.0.zig b/test/cases/int_to_ptr.0.zig index b7c70b90a44f..ba14c0380430 100644 --- a/test/cases/int_to_ptr.0.zig +++ b/test/cases/int_to_ptr.0.zig @@ -1,5 +1,5 @@ pub fn main() void { - _ = @intToPtr(*u8, 0); + _ = @ptrFromInt(*u8, 0); } // error diff --git a/test/cases/int_to_ptr.1.zig b/test/cases/int_to_ptr.1.zig index 72c8c8c9d6f0..e75ae81f6f47 100644 --- a/test/cases/int_to_ptr.1.zig +++ b/test/cases/int_to_ptr.1.zig @@ -1,5 +1,5 @@ pub fn main() void { - _ = @intToPtr(*u32, 2); + _ = @ptrFromInt(*u32, 2); } // error diff --git a/test/cases/llvm/f_segment_address_space_reading_and_writing.zig b/test/cases/llvm/f_segment_address_space_reading_and_writing.zig index 62db92668b4d..507362a93787 100644 --- a/test/cases/llvm/f_segment_address_space_reading_and_writing.zig +++ b/test/cases/llvm/f_segment_address_space_reading_and_writing.zig @@ -20,7 +20,7 @@ fn getFs() c_ulong { : : [number] "{rax}" (158), [code] "{rdi}" (0x1003), - [ptr] "{rsi}" (@ptrToInt(&result)), + [ptr] "{rsi}" (@intFromPtr(&result)), : "rcx", "r11", "memory" ); return result; @@ -31,10 +31,10 @@ var test_value: u64 = 12345; pub fn main() void { const orig_fs = getFs(); - setFs(@ptrToInt(&test_value)); - assert(getFs() == @ptrToInt(&test_value)); + setFs(@intFromPtr(&test_value)); + assert(getFs() == @intFromPtr(&test_value)); - var test_ptr = @intToPtr(*allowzero addrspace(.fs) u64, 0); + var test_ptr = @ptrFromInt(*allowzero addrspace(.fs) u64, 0); assert(test_ptr.* == 12345); test_ptr.* = 98765; assert(test_value == 98765); diff --git a/test/cases/safety/@alignCast misaligned.zig b/test/cases/safety/@alignCast misaligned.zig index aed805cf66bf..538e0ecdf69a 100644 --- a/test/cases/safety/@alignCast misaligned.zig +++ b/test/cases/safety/@alignCast misaligned.zig @@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { - var array align(4) = [_]u32{0x11111111, 0x11111111}; + var array align(4) = [_]u32{ 0x11111111, 0x11111111 }; const bytes = std.mem.sliceAsBytes(array[0..]); if (foo(bytes) != 0x11111111) return error.Wrong; return error.TestFailed; diff --git a/test/cases/safety/@intToEnum - no matching tag value.zig b/test/cases/safety/@enumFromInt - no matching tag value.zig similarity index 93% rename from test/cases/safety/@intToEnum - no matching tag value.zig rename to test/cases/safety/@enumFromInt - no matching tag value.zig index c4967b413b80..57f8954f930c 100644 --- a/test/cases/safety/@intToEnum - no matching tag value.zig +++ b/test/cases/safety/@enumFromInt - no matching tag value.zig @@ -17,7 +17,7 @@ pub fn main() !void { return error.TestFailed; } fn bar(a: u2) Foo { - return @intToEnum(Foo, a); + return @enumFromInt(Foo, a); } fn baz(_: Foo) void {} diff --git a/test/cases/safety/@errSetCast error not present in destination.zig b/test/cases/safety/@errSetCast error not present in destination.zig index 2fd0a912e660..372bd80aa59a 100644 --- a/test/cases/safety/@errSetCast error not present in destination.zig +++ b/test/cases/safety/@errSetCast error not present in destination.zig @@ -7,8 +7,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } std.process.exit(1); } -const Set1 = error{A, B}; -const Set2 = error{A, C}; +const Set1 = error{ A, B }; +const Set2 = error{ A, C }; pub fn main() !void { foo(Set1.B) catch {}; return error.TestFailed; diff --git a/test/cases/safety/@floatToInt cannot fit - negative out of range.zig b/test/cases/safety/@intFromFloat cannot fit - negative out of range.zig similarity index 88% rename from test/cases/safety/@floatToInt cannot fit - negative out of range.zig rename to test/cases/safety/@intFromFloat cannot fit - negative out of range.zig index fa7e628f4a02..9a8853c0e9d6 100644 --- a/test/cases/safety/@floatToInt cannot fit - negative out of range.zig +++ b/test/cases/safety/@intFromFloat cannot fit - negative out of range.zig @@ -12,9 +12,9 @@ pub fn main() !void { return error.TestFailed; } fn bar(a: f32) i8 { - return @floatToInt(i8, a); + return @intFromFloat(i8, a); } -fn baz(_: i8) void { } +fn baz(_: i8) void {} // run // backend=llvm // target=native diff --git a/test/cases/safety/@floatToInt cannot fit - negative to unsigned.zig b/test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig similarity index 88% rename from test/cases/safety/@floatToInt cannot fit - negative to unsigned.zig rename to test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig index 5bab7710b13a..caf7bbf0d6ea 100644 --- a/test/cases/safety/@floatToInt cannot fit - negative to unsigned.zig +++ b/test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig @@ -12,9 +12,9 @@ pub fn main() !void { return error.TestFailed; } fn bar(a: f32) u8 { - return @floatToInt(u8, a); + return @intFromFloat(u8, a); } -fn baz(_: u8) void { } +fn baz(_: u8) void {} // run // backend=llvm // target=native diff --git a/test/cases/safety/@floatToInt cannot fit - positive out of range.zig b/test/cases/safety/@intFromFloat cannot fit - positive out of range.zig similarity index 88% rename from test/cases/safety/@floatToInt cannot fit - positive out of range.zig rename to test/cases/safety/@intFromFloat cannot fit - positive out of range.zig index fe931e875153..d335238b65f2 100644 --- a/test/cases/safety/@floatToInt cannot fit - positive out of range.zig +++ b/test/cases/safety/@intFromFloat cannot fit - positive out of range.zig @@ -12,9 +12,9 @@ pub fn main() !void { return error.TestFailed; } fn bar(a: f32) u8 { - return @floatToInt(u8, a); + return @intFromFloat(u8, a); } -fn baz(_: u8) void { } +fn baz(_: u8) void {} // run // backend=llvm // target=native diff --git a/test/cases/safety/@intToPtr address zero to non-optional byte-aligned pointer.zig b/test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig similarity index 91% rename from test/cases/safety/@intToPtr address zero to non-optional byte-aligned pointer.zig rename to test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig index 413959706faa..345d5cfc7407 100644 --- a/test/cases/safety/@intToPtr address zero to non-optional byte-aligned pointer.zig +++ b/test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig @@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { var zero: usize = 0; - var b = @intToPtr(*u8, zero); + var b = @ptrFromInt(*u8, zero); _ = b; return error.TestFailed; } diff --git a/test/cases/safety/@intToPtr address zero to non-optional pointer.zig b/test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig similarity index 91% rename from test/cases/safety/@intToPtr address zero to non-optional pointer.zig rename to test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig index 457b2d12c07e..e7d3b66d6c0f 100644 --- a/test/cases/safety/@intToPtr address zero to non-optional pointer.zig +++ b/test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig @@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { var zero: usize = 0; - var b = @intToPtr(*i32, zero); + var b = @ptrFromInt(*i32, zero); _ = b; return error.TestFailed; } diff --git a/test/cases/safety/intToPtr with misaligned address.zig b/test/cases/safety/@ptrFromInt with misaligned address.zig similarity index 89% rename from test/cases/safety/intToPtr with misaligned address.zig rename to test/cases/safety/@ptrFromInt with misaligned address.zig index e53c7e90871d..c2e1d351eb59 100644 --- a/test/cases/safety/intToPtr with misaligned address.zig +++ b/test/cases/safety/@ptrFromInt with misaligned address.zig @@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { var x: usize = 5; - var y = @intToPtr([*]align(4) u8, x); + var y = @ptrFromInt([*]align(4) u8, x); _ = y; return error.TestFailed; } diff --git a/test/cases/safety/bad union field access.zig b/test/cases/safety/bad union field access.zig index fbe7718c6658..c6706d41764d 100644 --- a/test/cases/safety/bad union field access.zig +++ b/test/cases/safety/bad union field access.zig @@ -14,7 +14,7 @@ const Foo = union { }; pub fn main() !void { - var f = Foo { .int = 42 }; + var f = Foo{ .int = 42 }; bar(&f); return error.TestFailed; } diff --git a/test/cases/safety/cast []u8 to bigger slice of wrong size.zig b/test/cases/safety/cast []u8 to bigger slice of wrong size.zig index 93d18178a84f..a72b2fcca2ca 100644 --- a/test/cases/safety/cast []u8 to bigger slice of wrong size.zig +++ b/test/cases/safety/cast []u8 to bigger slice of wrong size.zig @@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { - const x = widenSlice(&[_]u8{1, 2, 3, 4, 5}); + const x = widenSlice(&[_]u8{ 1, 2, 3, 4, 5 }); if (x.len == 0) return error.Whatever; return error.TestFailed; } diff --git a/test/cases/safety/cast integer to global error and no code matches.zig b/test/cases/safety/cast integer to global error and no code matches.zig index 466bf8d2ca66..61daf07a2ba2 100644 --- a/test/cases/safety/cast integer to global error and no code matches.zig +++ b/test/cases/safety/cast integer to global error and no code matches.zig @@ -12,7 +12,7 @@ pub fn main() !void { return error.TestFailed; } fn bar(x: u16) anyerror { - return @intToError(x); + return @errorFromInt(x); } // run // backend=llvm diff --git a/test/cases/safety/error return trace across suspend points.zig b/test/cases/safety/error return trace across suspend points.zig index 28c53cb6d144..2c31aacc9d2f 100644 --- a/test/cases/safety/error return trace across suspend points.zig +++ b/test/cases/safety/error return trace across suspend points.zig @@ -1,6 +1,5 @@ const std = @import("std"); - pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = message; _ = stack_trace; @@ -36,4 +35,4 @@ fn printTrace(p: anyframe->anyerror!void) void { } // run // backend=stage1 -// target=native \ No newline at end of file +// target=native diff --git a/test/cases/safety/exact division failure - vectors.zig b/test/cases/safety/exact division failure - vectors.zig index 3c515cbdf118..cc8c01db9e3b 100644 --- a/test/cases/safety/exact division failure - vectors.zig +++ b/test/cases/safety/exact division failure - vectors.zig @@ -9,8 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { - var a: @Vector(4, i32) = [4]i32{111, 222, 333, 444}; - var b: @Vector(4, i32) = [4]i32{111, 222, 333, 441}; + var a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 }; + var b: @Vector(4, i32) = [4]i32{ 111, 222, 333, 441 }; const x = divExact(a, b); _ = x; return error.TestFailed; diff --git a/test/cases/safety/for_len_mismatch_three.zig b/test/cases/safety/for_len_mismatch_three.zig index 95bc24426994..0cfcddbfeecc 100644 --- a/test/cases/safety/for_len_mismatch_three.zig +++ b/test/cases/safety/for_len_mismatch_three.zig @@ -21,4 +21,3 @@ pub fn main() !void { // run // backend=llvm // target=native - diff --git a/test/cases/safety/integer division by zero - vectors.zig b/test/cases/safety/integer division by zero - vectors.zig index ed7ac7777b4b..a376b66fdb85 100644 --- a/test/cases/safety/integer division by zero - vectors.zig +++ b/test/cases/safety/integer division by zero - vectors.zig @@ -8,8 +8,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi std.process.exit(1); } pub fn main() !void { - var a: @Vector(4, i32) = [4]i32{111, 222, 333, 444}; - var b: @Vector(4, i32) = [4]i32{111, 0, 333, 444}; + var a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 }; + var b: @Vector(4, i32) = [4]i32{ 111, 0, 333, 444 }; const x = div0(a, b); _ = x; return error.TestFailed; diff --git a/test/cases/safety/pointer casting to null function pointer.zig b/test/cases/safety/pointer casting to null function pointer.zig index bedbcdda8589..7736cb503479 100644 --- a/test/cases/safety/pointer casting to null function pointer.zig +++ b/test/cases/safety/pointer casting to null function pointer.zig @@ -13,7 +13,7 @@ fn getNullPtr() ?*const anyopaque { } pub fn main() !void { const null_ptr: ?*const anyopaque = getNullPtr(); - const required_ptr: *align(1) const fn() void = @ptrCast(*align(1) const fn() void, null_ptr); + const required_ptr: *align(1) const fn () void = @ptrCast(*align(1) const fn () void, null_ptr); _ = required_ptr; return error.TestFailed; } diff --git a/test/cases/safety/slice sentinel mismatch - optional pointers.zig b/test/cases/safety/slice sentinel mismatch - optional pointers.zig index 6be303d9aad8..33f4a1099b03 100644 --- a/test/cases/safety/slice sentinel mismatch - optional pointers.zig +++ b/test/cases/safety/slice sentinel mismatch - optional pointers.zig @@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { - var buf: [4]?*i32 = .{ @intToPtr(*i32, 4), @intToPtr(*i32, 8), @intToPtr(*i32, 12), @intToPtr(*i32, 16) }; + var buf: [4]?*i32 = .{ @ptrFromInt(*i32, 4), @ptrFromInt(*i32, 8), @ptrFromInt(*i32, 12), @ptrFromInt(*i32, 16) }; const slice = buf[0..3 :null]; _ = slice; return error.TestFailed; diff --git a/test/cases/safety/zero casted to error.zig b/test/cases/safety/zero casted to error.zig index c1be6856a7e7..78340db3163c 100644 --- a/test/cases/safety/zero casted to error.zig +++ b/test/cases/safety/zero casted to error.zig @@ -12,7 +12,7 @@ pub fn main() !void { return error.TestFailed; } fn bar(x: u16) anyerror { - return @intToError(x); + return @errorFromInt(x); } // run // backend=llvm diff --git a/test/cases/unused_labels.3.zig b/test/cases/unused_labels.3.zig index e4f3ac05a404..36c9aa2319b0 100644 --- a/test/cases/unused_labels.3.zig +++ b/test/cases/unused_labels.3.zig @@ -1,5 +1,7 @@ comptime { - blk: {blk: {}} + blk: { + blk: {} + } } // error diff --git a/test/cases/variable_shadowing.3.zig b/test/cases/variable_shadowing.3.zig index 3d899e72cc86..af16bccc1478 100644 --- a/test/cases/variable_shadowing.3.zig +++ b/test/cases/variable_shadowing.3.zig @@ -1,7 +1,6 @@ pub fn main() void { var i = 0; - for ("n", 0..) |_, i| { - } + for ("n", 0..) |_, i| {} } // error diff --git a/test/cases/variable_shadowing.4.zig b/test/cases/variable_shadowing.4.zig index ab9f93d17d4a..3653c2457de7 100644 --- a/test/cases/variable_shadowing.4.zig +++ b/test/cases/variable_shadowing.4.zig @@ -1,7 +1,6 @@ pub fn main() void { var i = 0; - for ("n") |i| { - } + for ("n") |i| {} } // error diff --git a/test/cases/variable_shadowing.5.zig b/test/cases/variable_shadowing.5.zig index 1a5676190ada..78247e68feaa 100644 --- a/test/cases/variable_shadowing.5.zig +++ b/test/cases/variable_shadowing.5.zig @@ -1,7 +1,6 @@ pub fn main() void { var i = 0; - while ("n") |i| { - } + while ("n") |i| {} } // error diff --git a/test/cases/variable_shadowing.6.zig b/test/cases/variable_shadowing.6.zig index 894a398b61de..a3ae7bc34687 100644 --- a/test/cases/variable_shadowing.6.zig +++ b/test/cases/variable_shadowing.6.zig @@ -2,9 +2,7 @@ pub fn main() void { var i = 0; while ("n") |bruh| { _ = bruh; - } else |i| { - - } + } else |i| {} } // error diff --git a/test/cases/x86_64-linux/inline_assembly.2.zig b/test/cases/x86_64-linux/inline_assembly.2.zig index 1695265ab4eb..7958d0df71ea 100644 --- a/test/cases/x86_64-linux/inline_assembly.2.zig +++ b/test/cases/x86_64-linux/inline_assembly.2.zig @@ -2,7 +2,7 @@ pub fn main() void { var bruh: u32 = 1; asm ("" : - : [bruh] "{rax}" (4) + : [bruh] "{rax}" (4), : "memory" ); } diff --git a/test/cases/x86_64-linux/inline_assembly.3.zig b/test/cases/x86_64-linux/inline_assembly.3.zig index 765eaeb97eb2..a6f57e832a74 100644 --- a/test/cases/x86_64-linux/inline_assembly.3.zig +++ b/test/cases/x86_64-linux/inline_assembly.3.zig @@ -2,7 +2,7 @@ pub fn main() void {} comptime { asm ("" : - : [bruh] "{rax}" (4) + : [bruh] "{rax}" (4), : "memory" ); } diff --git a/test/cbe.zig b/test/cbe.zig index 25ac3cb1372d..f0cf720fd338 100644 --- a/test/cbe.zig +++ b/test/cbe.zig @@ -71,22 +71,22 @@ pub fn addCases(ctx: *Cases) !void { } { - var case = ctx.exeFromCompiledC("intToError", .{}); + var case = ctx.exeFromCompiledC("errorFromInt", .{}); case.addCompareOutput( \\pub export fn main() c_int { \\ // comptime checks \\ const a = error.A; \\ const b = error.B; - \\ const c = @intToError(2); - \\ const d = @intToError(1); + \\ const c = @errorFromInt(2); + \\ const d = @errorFromInt(1); \\ if (!(c == b)) unreachable; \\ if (!(a == d)) unreachable; \\ // runtime checks \\ var x = error.A; \\ var y = error.B; - \\ var z = @intToError(2); - \\ var f = @intToError(1); + \\ var z = @errorFromInt(2); + \\ var f = @errorFromInt(1); \\ if (!(y == z)) unreachable; \\ if (!(x == f)) unreachable; \\ return 0; @@ -94,13 +94,13 @@ pub fn addCases(ctx: *Cases) !void { , ""); case.addError( \\pub export fn main() c_int { - \\ _ = @intToError(0); + \\ _ = @errorFromInt(0); \\ return 0; \\} , &.{":2:21: error: integer value '0' represents no error"}); case.addError( \\pub export fn main() c_int { - \\ _ = @intToError(3); + \\ _ = @errorFromInt(3); \\ return 0; \\} , &.{":2:21: error: integer value '3' represents no error"}); @@ -635,19 +635,19 @@ pub fn addCases(ctx: *Cases) !void { ":6:12: note: consider 'union(enum)' here to make it a tagged union", }); - // @enumToInt, @intToEnum, enum literal coercion, field access syntax, comparison, switch + // @intFromEnum, @enumFromInt, enum literal coercion, field access syntax, comparison, switch case.addCompareOutput( \\const Number = enum { One, Two, Three }; \\ \\pub export fn main() c_int { \\ var number1 = Number.One; \\ var number2: Number = .Two; - \\ const number3 = @intToEnum(Number, 2); + \\ const number3 = @enumFromInt(Number, 2); \\ if (number1 == number2) return 1; \\ if (number2 == number3) return 1; - \\ if (@enumToInt(number1) != 0) return 1; - \\ if (@enumToInt(number2) != 1) return 1; - \\ if (@enumToInt(number3) != 2) return 1; + \\ if (@intFromEnum(number1) != 0) return 1; + \\ if (@intFromEnum(number2) != 1) return 1; + \\ if (@intFromEnum(number3) != 2) return 1; \\ var x: Number = .Two; \\ if (number2 != x) return 1; \\ switch (x) { @@ -728,7 +728,7 @@ pub fn addCases(ctx: *Cases) !void { case.addError( \\pub export fn main() c_int { \\ const a = true; - \\ _ = @enumToInt(a); + \\ _ = @intFromEnum(a); \\} , &.{ ":3:20: error: expected enum or tagged union, found 'bool'", @@ -737,7 +737,7 @@ pub fn addCases(ctx: *Cases) !void { case.addError( \\pub export fn main() c_int { \\ const a = 1; - \\ _ = @intToEnum(bool, a); + \\ _ = @enumFromInt(bool, a); \\} , &.{ ":3:20: error: expected enum, found 'bool'", @@ -746,7 +746,7 @@ pub fn addCases(ctx: *Cases) !void { case.addError( \\const E = enum { a, b, c }; \\pub export fn main() c_int { - \\ _ = @intToEnum(E, 3); + \\ _ = @enumFromInt(E, 3); \\} , &.{ ":3:9: error: enum 'tmp.E' has no tag with value '3'", diff --git a/test/compare_output.zig b/test/compare_output.zig index ad14152e7681..66b56244436c 100644 --- a/test/compare_output.zig +++ b/test/compare_output.zig @@ -229,8 +229,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ } \\ const small: f32 = 3.25; \\ const x: f64 = small; - \\ const y = @floatToInt(i32, x); - \\ const z = @intToFloat(f64, y); + \\ const y = @intFromFloat(i32, x); + \\ const z = @floatFromInt(f64, y); \\ _ = c.printf("%.2f\n%d\n%.2f\n%.2f\n", x, y, z, @as(f64, -0.4)); \\ return 0; \\} diff --git a/test/gen_h.zig b/test/gen_h.zig index c00abf320b5c..a41f4d6f82ea 100644 --- a/test/gen_h.zig +++ b/test/gen_h.zig @@ -137,7 +137,7 @@ pub fn addCases(cases: *tests.GenHContext) void { \\}; \\ \\export fn a(s: *E) u8 { - \\ return @enumToInt(s.*); + \\ return @intFromEnum(s.*); \\} , &[_][]const u8{ \\enum E; diff --git a/test/link/common_symbols_alignment/main.zig b/test/link/common_symbols_alignment/main.zig index 3d3457c76494..06316b40fa14 100644 --- a/test/link/common_symbols_alignment/main.zig +++ b/test/link/common_symbols_alignment/main.zig @@ -4,6 +4,6 @@ extern var foo: i32; extern var bar: i32; test { - try std.testing.expect(@ptrToInt(&foo) % 4 == 0); - try std.testing.expect(@ptrToInt(&bar) % 4096 == 0); + try std.testing.expect(@intFromPtr(&foo) % 4 == 0); + try std.testing.expect(@intFromPtr(&bar) % 4096 == 0); } diff --git a/test/standalone/pie/main.zig b/test/standalone/pie/main.zig index 6a49c45e975d..89d204aa1c2a 100644 --- a/test/standalone/pie/main.zig +++ b/test/standalone/pie/main.zig @@ -5,7 +5,7 @@ threadlocal var foo: u8 = 42; test "Check ELF header" { // PIE executables are marked as ET_DYN, regular exes as ET_EXEC. - const header = @intToPtr(*elf.Ehdr, std.process.getBaseAddress()); + const header = @ptrFromInt(*elf.Ehdr, std.process.getBaseAddress()); try std.testing.expectEqual(elf.ET.DYN, header.e_type); } diff --git a/test/translate_c.zig b/test/translate_c.zig index 6caf69dcdba0..966f3e278540 100644 --- a/test/translate_c.zig +++ b/test/translate_c.zig @@ -300,7 +300,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub const FOO = (foo + @as(c_int, 2)).*; , - \\pub const VALUE = ((((@as(c_int, 1) + (@as(c_int, 2) * @as(c_int, 3))) + (@as(c_int, 4) * @as(c_int, 5))) + @as(c_int, 6)) << @as(c_int, 7)) | @boolToInt(@as(c_int, 8) == @as(c_int, 9)); + \\pub const VALUE = ((((@as(c_int, 1) + (@as(c_int, 2) * @as(c_int, 3))) + (@as(c_int, 4) * @as(c_int, 5))) + @as(c_int, 6)) << @as(c_int, 7)) | @intFromBool(@as(c_int, 8) == @as(c_int, 9)); , \\pub inline fn _AL_READ3BYTES(p: anytype) @TypeOf((@import("std").zig.c_translation.cast([*c]u8, p).* | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16))) { \\ return (@import("std").zig.c_translation.cast([*c]u8, p).* | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16)); @@ -439,8 +439,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\#define FOO(x) ((x >= 0) + (x >= 0)) \\#define BAR 1 && 2 > 4 , &[_][]const u8{ - \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0))) { - \\ return @boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0)); + \\pub inline fn FOO(x: anytype) @TypeOf(@intFromBool(x >= @as(c_int, 0)) + @intFromBool(x >= @as(c_int, 0))) { + \\ return @intFromBool(x >= @as(c_int, 0)) + @intFromBool(x >= @as(c_int, 0)); \\} , \\pub const BAR = (@as(c_int, 1) != 0) and (@as(c_int, 2) > @as(c_int, 4)); @@ -905,7 +905,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub extern fn foo() void; \\pub export fn bar() void { \\ var func_ptr: ?*anyopaque = @ptrCast(?*anyopaque, &foo); - \\ var typed_func_ptr: ?*const fn () callconv(.C) void = @intToPtr(?*const fn () callconv(.C) void, @intCast(c_ulong, @ptrToInt(func_ptr))); + \\ var typed_func_ptr: ?*const fn () callconv(.C) void = @ptrFromInt(?*const fn () callconv(.C) void, @intCast(c_ulong, @intFromPtr(func_ptr))); \\ _ = @TypeOf(typed_func_ptr); \\} }); @@ -1719,10 +1719,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ var a: c_int = undefined; \\ var b: f32 = undefined; \\ var c: ?*anyopaque = undefined; - \\ return @boolToInt(!(a == @as(c_int, 0))); - \\ return @boolToInt(!(a != 0)); - \\ return @boolToInt(!(b != 0)); - \\ return @boolToInt(!(c != null)); + \\ return @intFromBool(!(a == @as(c_int, 0))); + \\ return @intFromBool(!(a != 0)); + \\ return @intFromBool(!(b != 0)); + \\ return @intFromBool(!(c != null)); \\} }); @@ -2238,7 +2238,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export var a: f32 = @floatCast(f32, 3.1415); \\pub export var b: f64 = 3.1415; - \\pub export var c: c_int = @floatToInt(c_int, 3.1415); + \\pub export var c: c_int = @intFromFloat(c_int, 3.1415); \\pub export var d: f64 = 3; }); @@ -2417,13 +2417,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void { }); cases.add("c style cast", - \\int float_to_int(float a) { + \\int int_from_float(float a) { \\ return (int)a; \\} , &[_][]const u8{ - \\pub export fn float_to_int(arg_a: f32) c_int { + \\pub export fn int_from_float(arg_a: f32) c_int { \\ var a = arg_a; - \\ return @floatToInt(c_int, a); + \\ return @intFromFloat(c_int, a); \\} }); @@ -2534,18 +2534,18 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ var b = arg_b; \\ var c = arg_c; \\ var d: enum_Foo = @bitCast(c_uint, FooA); - \\ var e: c_int = @boolToInt((a != 0) and (b != 0)); - \\ var f: c_int = @boolToInt((b != 0) and (c != null)); - \\ var g: c_int = @boolToInt((a != 0) and (c != null)); - \\ var h: c_int = @boolToInt((a != 0) or (b != 0)); - \\ var i: c_int = @boolToInt((b != 0) or (c != null)); - \\ var j: c_int = @boolToInt((a != 0) or (c != null)); - \\ var k: c_int = @boolToInt((a != 0) or (@bitCast(c_int, d) != 0)); - \\ var l: c_int = @boolToInt((@bitCast(c_int, d) != 0) and (b != 0)); - \\ var m: c_int = @boolToInt((c != null) or (d != 0)); + \\ var e: c_int = @intFromBool((a != 0) and (b != 0)); + \\ var f: c_int = @intFromBool((b != 0) and (c != null)); + \\ var g: c_int = @intFromBool((a != 0) and (c != null)); + \\ var h: c_int = @intFromBool((a != 0) or (b != 0)); + \\ var i: c_int = @intFromBool((b != 0) or (c != null)); + \\ var j: c_int = @intFromBool((a != 0) or (c != null)); + \\ var k: c_int = @intFromBool((a != 0) or (@bitCast(c_int, d) != 0)); + \\ var l: c_int = @intFromBool((@bitCast(c_int, d) != 0) and (b != 0)); + \\ var m: c_int = @intFromBool((c != null) or (d != 0)); \\ var td: SomeTypedef = 44; - \\ var o: c_int = @boolToInt((td != 0) or (b != 0)); - \\ var p: c_int = @boolToInt((c != null) and (td != 0)); + \\ var o: c_int = @intFromBool((td != 0) or (b != 0)); + \\ var p: c_int = @intFromBool((c != null) and (td != 0)); \\ return (((((((((e + f) + g) + h) + i) + j) + k) + l) + m) + o) + p; \\} , @@ -2605,13 +2605,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export fn test_comparisons(arg_a: c_int, arg_b: c_int) c_int { \\ var a = arg_a; \\ var b = arg_b; - \\ var c: c_int = @boolToInt(a < b); - \\ var d: c_int = @boolToInt(a > b); - \\ var e: c_int = @boolToInt(a <= b); - \\ var f: c_int = @boolToInt(a >= b); - \\ var g: c_int = @boolToInt(c < d); - \\ var h: c_int = @boolToInt(e < f); - \\ var i: c_int = @boolToInt(g < h); + \\ var c: c_int = @intFromBool(a < b); + \\ var d: c_int = @intFromBool(a > b); + \\ var e: c_int = @intFromBool(a <= b); + \\ var f: c_int = @intFromBool(a >= b); + \\ var g: c_int = @intFromBool(c < d); + \\ var h: c_int = @intFromBool(e < f); + \\ var i: c_int = @intFromBool(g < h); \\ return i; \\} }); @@ -3258,11 +3258,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub extern fn fn_bool(x: bool) void; \\pub extern fn fn_ptr(x: ?*anyopaque) void; \\pub export fn call() void { - \\ fn_int(@floatToInt(c_int, 3.0)); - \\ fn_int(@floatToInt(c_int, 3.0)); + \\ fn_int(@intFromFloat(c_int, 3.0)); + \\ fn_int(@intFromFloat(c_int, 3.0)); \\ fn_int(@as(c_int, 1094861636)); - \\ fn_f32(@intToFloat(f32, @as(c_int, 3))); - \\ fn_f64(@intToFloat(f64, @as(c_int, 3))); + \\ fn_f32(@floatFromInt(f32, @as(c_int, 3))); + \\ fn_f64(@floatFromInt(f64, @as(c_int, 3))); \\ fn_char(@bitCast(u8, @truncate(i8, @as(c_int, '3')))); \\ fn_char(@bitCast(u8, @truncate(i8, @as(c_int, '\x01')))); \\ fn_char(@bitCast(u8, @truncate(i8, @as(c_int, 0)))); @@ -3270,9 +3270,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ fn_f64(3.0); \\ fn_bool(@as(c_int, 123) != 0); \\ fn_bool(@as(c_int, 0) != 0); - \\ fn_bool(@ptrToInt(&fn_int) != 0); - \\ fn_int(@intCast(c_int, @ptrToInt(&fn_int))); - \\ fn_ptr(@intToPtr(?*anyopaque, @as(c_int, 42))); + \\ fn_bool(@intFromPtr(&fn_int) != 0); + \\ fn_int(@intCast(c_int, @intFromPtr(&fn_int))); + \\ fn_ptr(@ptrFromInt(?*anyopaque, @as(c_int, 42))); \\} }); @@ -3473,11 +3473,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\} \\pub export fn bar(arg_a: [*c]const c_int) void { \\ var a = arg_a; - \\ foo(@intToPtr([*c]c_int, @ptrToInt(a))); + \\ foo(@ptrFromInt([*c]c_int, @intFromPtr(a))); \\} \\pub export fn baz(arg_a: [*c]volatile c_int) void { \\ var a = arg_a; - \\ foo(@intToPtr([*c]c_int, @ptrToInt(a))); + \\ foo(@ptrFromInt([*c]c_int, @intFromPtr(a))); \\} }); @@ -3491,10 +3491,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo(arg_x: bool) bool { \\ var x = arg_x; - \\ var a: bool = @as(c_int, @boolToInt(x)) != @as(c_int, 1); - \\ var b: bool = @as(c_int, @boolToInt(a)) != @as(c_int, 0); - \\ var c: bool = @ptrToInt(&foo) != 0; - \\ return foo(@as(c_int, @boolToInt(c)) != @as(c_int, @boolToInt(b))); + \\ var a: bool = @as(c_int, @intFromBool(x)) != @as(c_int, 1); + \\ var b: bool = @as(c_int, @intFromBool(a)) != @as(c_int, 0); + \\ var c: bool = @intFromPtr(&foo) != 0; + \\ return foo(@as(c_int, @intFromBool(c)) != @as(c_int, @intFromBool(b))); \\} }); @@ -3910,7 +3910,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export fn foo() void { \\ var a: c_int = undefined; \\ if ((blk: { - \\ const tmp = @boolToInt(@as(c_int, 1) > @as(c_int, 0)); + \\ const tmp = @intFromBool(@as(c_int, 1) > @as(c_int, 0)); \\ a = tmp; \\ break :blk tmp; \\ }) != 0) {} @@ -3928,7 +3928,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export fn foo() void { \\ var a: S = undefined; \\ var b: S = undefined; - \\ var c: c_longlong = @divExact(@bitCast(c_longlong, @ptrToInt(a) -% @ptrToInt(b)), @sizeOf(u8)); + \\ var c: c_longlong = @divExact(@bitCast(c_longlong, @intFromPtr(a) -% @intFromPtr(b)), @sizeOf(u8)); \\ _ = @TypeOf(c); \\} }); @@ -3943,7 +3943,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export fn foo() void { \\ var a: S = undefined; \\ var b: S = undefined; - \\ var c: c_long = @divExact(@bitCast(c_long, @ptrToInt(a) -% @ptrToInt(b)), @sizeOf(u8)); + \\ var c: c_long = @divExact(@bitCast(c_long, @intFromPtr(a) -% @intFromPtr(b)), @sizeOf(u8)); \\ _ = @TypeOf(c); \\} }); diff --git a/tools/gen_outline_atomics.zig b/tools/gen_outline_atomics.zig index 0cfdacffd1a3..445e17646c2b 100644 --- a/tools/gen_outline_atomics.zig +++ b/tools/gen_outline_atomics.zig @@ -31,7 +31,7 @@ pub fn main() !void { \\/// 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); \\ \\ ); @@ -144,11 +144,11 @@ const N = enum(u8) { } fn register(n: N) []const u8 { - return if (@enumToInt(n) < 8) "w" else "x"; + return if (@intFromEnum(n) < 8) "w" else "x"; } fn toBytes(n: N) u8 { - return @enumToInt(n); + return @intFromEnum(n); } fn toBits(n: N) u8 { @@ -212,7 +212,7 @@ fn generateCas(arena: Allocator, n: N, order: Ordering) ![]const u8 { const reg = n.register(); - if (@enumToInt(n) < 16) { + if (@intFromEnum(n) < 16) { const cas = try std.fmt.allocPrint(arena, ".inst 0x08a07c41 + {s} + {s}", .{ s_def.b, o_def.m }); const ldxr = try std.fmt.allocPrint(arena, "ld{s}xr{s}", .{ o_def.a, s_def.s }); const stxr = try std.fmt.allocPrint(arena, "st{s}xr{s}", .{ o_def.l, s_def.s }); diff --git a/tools/gen_stubs.zig b/tools/gen_stubs.zig index 5d6b0acbd6d8..78b008612137 100644 --- a/tools/gen_stubs.zig +++ b/tools/gen_stubs.zig @@ -444,7 +444,7 @@ fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian) const name = try arena.dupe(u8, mem.sliceTo(dynstr[s(sym.st_name)..], 0)); const ty = @truncate(u4, sym.st_info); const binding = @truncate(u4, sym.st_info >> 4); - const visib = @intToEnum(elf.STV, @truncate(u2, sym.st_other)); + const visib = @enumFromInt(elf.STV, @truncate(u2, sym.st_other)); const size = s(sym.st_size); if (parse.blacklist.contains(name)) continue; diff --git a/tools/process_headers.zig b/tools/process_headers.zig index b93cd07a2cc2..a7abcb0297c2 100644 --- a/tools/process_headers.zig +++ b/tools/process_headers.zig @@ -32,7 +32,7 @@ const MultiArch = union(enum) { specific: Arch, fn eql(a: MultiArch, b: MultiArch) bool { - if (@enumToInt(a) != @enumToInt(b)) + if (@intFromEnum(a) != @intFromEnum(b)) return false; if (a != .specific) return true; @@ -45,7 +45,7 @@ const MultiAbi = union(enum) { specific: Abi, fn eql(a: MultiAbi, b: MultiAbi) bool { - if (@enumToInt(a) != @enumToInt(b)) + if (@intFromEnum(a) != @intFromEnum(b)) return false; if (std.meta.Tag(MultiAbi)(a) != .specific) return true; @@ -262,9 +262,9 @@ const DestTarget = struct { const HashContext = struct { pub fn hash(self: @This(), a: DestTarget) u32 { _ = self; - return @enumToInt(a.arch) +% - (@enumToInt(a.os) *% @as(u32, 4202347608)) +% - (@enumToInt(a.abi) *% @as(u32, 4082223418)); + return @intFromEnum(a.arch) +% + (@intFromEnum(a.os) *% @as(u32, 4202347608)) +% + (@intFromEnum(a.abi) *% @as(u32, 4082223418)); } pub fn eql(self: @This(), a: DestTarget, b: DestTarget, b_index: usize) bool { diff --git a/tools/update-linux-headers.zig b/tools/update-linux-headers.zig index 1ed65d5405f1..e3a3e9294dd9 100644 --- a/tools/update-linux-headers.zig +++ b/tools/update-linux-headers.zig @@ -37,7 +37,7 @@ const MultiArch = union(enum) { specific: Arch, fn eql(a: MultiArch, b: MultiArch) bool { - if (@enumToInt(a) != @enumToInt(b)) + if (@intFromEnum(a) != @intFromEnum(b)) return false; if (a != .specific) return true; diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig index 5d105195ef7c..4584a87ef758 100644 --- a/tools/update_clang_options.zig +++ b/tools/update_clang_options.zig @@ -591,7 +591,7 @@ pub fn main() anyerror!void { for (all_features, 0..) |feat, i| { const llvm_name = feat.llvm_name orelse continue; - const zig_feat = @intToEnum(Feature, i); + const zig_feat = @enumFromInt(Feature, i); const zig_name = @tagName(zig_feat); try llvm_to_zig_cpu_features.put(llvm_name, zig_name); } diff --git a/tools/update_cpu_features.zig b/tools/update_cpu_features.zig index a4b9607a403c..0b14769eadb1 100644 --- a/tools/update_cpu_features.zig +++ b/tools/update_cpu_features.zig @@ -1247,7 +1247,7 @@ fn processOneTarget(job: Job) anyerror!void { for (all_features.items) |feature| { if (feature.llvm_name) |llvm_name| { try w.print( - \\ result[@enumToInt(Feature.{})] = .{{ + \\ result[@intFromEnum(Feature.{})] = .{{ \\ .llvm_name = "{}", \\ .description = "{}", \\ .dependencies = featureSet(&[_]Feature{{ @@ -1260,7 +1260,7 @@ fn processOneTarget(job: Job) anyerror!void { ); } else { try w.print( - \\ result[@enumToInt(Feature.{})] = .{{ + \\ result[@intFromEnum(Feature.{})] = .{{ \\ .llvm_name = null, \\ .description = "{}", \\ .dependencies = featureSet(&[_]Feature{{ diff --git a/tools/update_spirv_features.zig b/tools/update_spirv_features.zig index 6fd1b26c7f31..0c8acf5aef15 100644 --- a/tools/update_spirv_features.zig +++ b/tools/update_spirv_features.zig @@ -137,7 +137,7 @@ pub fn main() !void { for (versions, 0..) |ver, i| { try w.print( - \\ result[@enumToInt(Feature.v{0}_{1})] = .{{ + \\ result[@intFromEnum(Feature.v{0}_{1})] = .{{ \\ .llvm_name = null, \\ .description = "SPIR-V version {0}.{1}", \\ @@ -163,7 +163,7 @@ pub fn main() !void { // TODO: Extension dependencies. for (extensions) |ext| { try w.print( - \\ result[@enumToInt(Feature.{s})] = .{{ + \\ result[@intFromEnum(Feature.{s})] = .{{ \\ .llvm_name = null, \\ .description = "SPIR-V extension {s}", \\ .dependencies = featureSet(&[_]Feature{{}}), @@ -178,7 +178,7 @@ pub fn main() !void { // TODO: Capability extension dependencies. for (capabilities) |cap| { try w.print( - \\ result[@enumToInt(Feature.{s})] = .{{ + \\ result[@intFromEnum(Feature.{s})] = .{{ \\ .llvm_name = null, \\ .description = "Enable SPIR-V capability {s}", \\ .dependencies = featureSet(&[_]Feature{{