diff options
Diffstat (limited to 'lib')
273 files changed, 3233 insertions, 3213 deletions
diff --git a/lib/compiler_rt.zig b/lib/compiler_rt.zig index 1cae2a710e..f0503d2219 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 2471a45365..c70fd81fc4 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 4b9d5921da..de0c777d45 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 5038c4061a..e39d726e0f 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 8a7b37c2c9..c01b1c1538 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 d801b30ff6..67ad7a74b6 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 35e250e810..c51792254d 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 bc53afc625..bee0652292 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 75355775bb..cd66b1c6c8 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 1fb6d2dfa0..d4f4e0504d 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 2f83d312dc..c71eed6d0f 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 5f05141610..d35220ca26 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 165186b1fb..86a2f30cc8 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 5fb686cee8..f0e93fa3be 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 24d29ad0bb..32a1a84ff9 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 1882367522..731fd7013d 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 0329b3cc13..23b3876b91 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 74406171b4..09b9533254 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 ecb4e8912c..c3513f6bec 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 3cb1186d71..21736e2d9a 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 2f24649fb7..cd1ae208f8 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 2865bcad29..d2b288a52d 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 4bb63e6768..bbb31f6233 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 55eb6e2276..7aa352bbf9 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 cd5e524b20..033e5be5b8 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 bafcf6d83a..f65c9eaed1 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 389f2b117f..2667b1f626 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 60b94807b9..c3f574ed8a 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 b544595c7f..a43ad91ac8 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 87affbce32..8af2c5af7e 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 242d84176b..67959fb98a 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 9c70df3d5e..cd68cab757 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 e5070f7a1b..aa47d7edf7 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 0c67d4998a..5e767dc36c 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 dd883693a7..dda6e80c65 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 a071e674ae..7c935c2731 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 ae2a27ab8e..947164b369 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 710207b330..778388a05c 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 1b0b64c193..aabebccb99 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 f1f03c23e4..bf9764b1aa 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 de1cd13806..d83cc123f4 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 93cdcb2bab..8212b5b2c3 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 a34bd288c0..b9ed4d8132 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 096e381629..c7510323d6 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 b6714d2066..afcf06e4c9 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 2e9dbdc2fb..c9a32d8ad4 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 index 2eb7b5ade8..8a2c233cba 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 index 608a925bf2..bbc315c745 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 9b9df4ae70..3615e89035 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 1db7a0eac6..4d01d5c2e0 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 3bdcc60f20..1a1b5fc6d7 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 173dd79f75..5f0c49c129 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 c4fc9ca28f..b4d250b277 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 7ec7d90fba..8402c5726b 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 0a08c19847..889fa3c33f 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 daddfb06e1..907c7a554d 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 9739b91280..2553de5f18 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 a9d3709911..fe63f1c0a8 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 d70fedbfc3..c42e8f2974 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 f90a57d1e0..90003660ec 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 737e1ec409..09c0b12ed0 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 d14264fb04..ae0ecbb98a 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 1af4f83965..9c2339ff8a 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 db4cc6505e..b158fb546d 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 e6c6a79d5e..1c534c9175 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 eb17c0f657..c9dffa7e36 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 0bfa36d6e1..d573d095bc 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 22f885167f..33836f3ccb 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 ef5bce2afa..3ffd79655a 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 0b43d61f4c..fcfbbaf646 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 f85d1bb013..b7cc567ff0 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 ef9593cdf6..0414784b83 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 cd402e227d..866f3f8c47 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 d3a685a1ce..a2b46506f0 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 9102960e8d..f493453c91 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 7ee013339d..9df7b833ea 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 41e715e013..55a5ab4da1 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 877203bd22..cbf597ca89 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 c887a9b6e4..0ade0cf46a 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 6bea4e164a..c6e7b90a65 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 44439976bb..44d8b5cc75 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 1a5c06af3d..07e87ed55c 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 bf0b0edccb..94f735b8c2 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 index 6fc7286f68..78397a8131 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 index 676c12e914..676c12e914 100644 --- a/lib/compiler_rt/float_to_int_test.zig +++ b/lib/compiler_rt/int_from_float_test.zig diff --git a/lib/compiler_rt/log.zig b/lib/compiler_rt/log.zig index 71d90f7c3a..622d509a2f 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 5c345ff12f..d45a3d8a40 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 612c978598..29595d07d9 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 61ccb1205d..bb772b3217 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 b02bd81671..9652782a49 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 2c6cdb54dc..187bb4ff35 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 a13abda5fe..1cf587b1ef 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 f63854e34f..c1bac5eaae 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 e018932555..8a869fe718 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 73d477ee12..315a99c308 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 c8a53b741c..afded18387 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 34397dd734..9e47bbcb24 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 8ece83515e..4a9629e5c0 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 c012bcee62..3de342fc99 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 0402f0f6af..c9c34ffe98 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 bed1cc345e..c574dbb5af 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 080e6f54d3..b83a9b0177 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 e2ee51e1dc..f16f8a9a79 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 2f8ab02d5e..5b24e9ea19 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 7fbe49fea2..61e39eba27 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 b46b5c12f0..d3ad94324e 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 6c0c477725..81918638b5 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 7c9ffa2684..70cb293cf4 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 b7dfc8d529..4b83e8e057 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 67c676f0dd..3b4bfef826 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 a257437282..b680a97933 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 457e817b68..912bb99056 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 8e8a576564..6f91ee65f7 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 2e0e02a20f..2f9917a0f3 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 d5add70033..d3a3bfdeba 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 5a848c4808..8f3837b2bb 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 93681b77e1..4d44461237 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 3a6708613b..511bf9ccc5 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 db85242002..636ef7f4d7 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 a7c191e650..d28e54b94c 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 0b76d9d89d..a852287b53 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 f539abf8b1..a6adb941a4 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 5a2f309fe4..54d2195e33 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 40735ca6b6..5debc81835 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 520c335794..2a034011c2 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 2d90d6d6e3..98cabb4732 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 e2042650c6..40f5903a24 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 b9ce14bc92..50f34c45f3 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 f6265cba48..eec83f3d2e 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 e33bdb496d..d12a672e7d 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 b8dc636693..51eb97ab32 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 dba0520795..bd7100eb46 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 43dbe3e332..40df3290c0 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 26f5d50979..f47c334ee9 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 37e3d1c1b3..7b298c71c2 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 dca4ab7ea7..3cb0f02c0d 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 efda420284..a797fbce3e 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 958543084e..3d96592f50 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 2d94594f61..f0b086f974 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 0498c9c297..4c03c48973 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 5b9b00538a..94ecf0d3ef 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 3015c30bfb..e0726d5444 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 928d0cc9c3..38c5de9cad 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 9f30a36148..9a71f73e05 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 757c616b9b..a5ceebc9b1 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 e1c147d25a..3329694da7 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 9cda7f2aba..9da3943d5d 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 bc0162423b..7eec26a2b1 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 e2ad5240b2..d983aba369 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 9ad5d218a9..b438733589 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 ff71695303..5c49553a14 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 74beb745de..2124e436ab 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 bb0890be4b..8e828fd334 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 7b954399d8..0c6e8a24f7 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 e7a28a7615..012d99f59a 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 469244fcd6..0deaa86468 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 d7b26ce2ad..f33bd635fc 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 cf2f18d22f..62df89f0ae 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 0ad154abef..da250af1bf 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 8c05dfeca5..4f1639cd60 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 7b4bf3af21..fd5b0754fe 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 5da570fa42..12a0bdcf30 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 efec116db4..e3e436fd2b 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 63ae226196..c77164ee2d 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 f858510bcf..a8d6641d8d 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 51b6c1744f..98375c850e 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 e9c62705b5..c09341c701 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 975375a2b9..0c627642b8 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 60f6243fce..fe57b5735d 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 fb8b0b9d14..f2804a3107 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 e897850b83..4bdb0b9194 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 80dcba3f6f..62c73d3714 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 73a209ebc0..3a3af8f8d9 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 bc5955d16a..859d753a6a 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 dc45df9ea3..1c5b60ff1a 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 e62a208d0b..c7d354f787 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 487812e1de..846a809e05 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 cdc33e351d..22f7ba183f 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 929b98aebd..56c199016d 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 5911edf36f..5c4052db56 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 c091619f3a..7c58be2ec5 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 8947475159..448e94f8e5 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 ad2763fa54..c1a0f5c8e4 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 6b5758763c..44e5a88445 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 e186b2795a..ad67955a8d 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 9cedf50e13..7643e143e3 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 b320f579c6..bbeecdda23 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 4a1ff86721..301480f662 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 db415199ed..fedbd1a40d 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 a4d83dcbb3..cf37fc5adf 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 e9011c3c63..26ba6cc919 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 dfd6fe4a9e..0f8ecbf21e 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 802bb1d8df..2bfea02c21 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 e4d6790505..b7ec29383b 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 92d0fcfb44..057ecc763a 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 9f91960791..0824a9e9a4 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 9f9e253547..87b92587f9 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 6084b01e6c..b26e7eda29 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 0610b214d5..875138cf4f 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 66d204dfe1..781003bedc 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 dfc1c9b576..8d55dee37f 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 6d2d408adf..31c30f2d30 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 ab0da460d8..722bd64687 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 627bb8498e..cbdaa76282 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 ca1256cb2e..c741df9897 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 aa1418f4a3..c9b1cb1e92 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 6ac51afb78..ec514ca5de 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 d765e403c8..b60a2ed388 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 dc2f85776d..c7dc7ae599 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 c9274e11ee..05c012c77c 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 09047bda83..41c9c9ea46 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 1f46915b27..b628bc2afc 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 c68fdc4f0f..ce8d44ff46 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 59575e0109..888b2f5c1c 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 00b8941974..c24d9416f1 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 2365b0cb2e..c64084e6ed 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 c591f8cf7f..421815c04d 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 211b9d8462..0d6fc2c670 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 ae624dfd2b..821b903a34 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 180507ba71..25a6786ec6 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 f27b7e835b..05066fa436 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 668b664c27..ea3de9c70d 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 d257425ad1..6cc6891c5a 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 4ccdac6c1e..78d24a80bf 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 813bad0741..928503ad40 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 f5d2688efb..9c83bd881c 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 6a3aad7a99..a1cd8387dc 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 14a9ce5d3f..688d093587 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 995edd02f7..912eb141ea 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 0c3b802b8a..e20448102d 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 7c5dc74eb3..4fc47c8d72 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 86d803c217..eff13c6637 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 18b26d5ba9..a78fd6785a 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 e670682ff9..a39475cb2a 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 82503c11a4..35f4aac57f 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 0a2812c6d9..ef153a2708 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 fb075513bb..c84b2cb0c8 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 dcc6bd43fc..6f0bf426bb 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 10a8ae4dc2..422b95ca17 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 5650bd64c2..8f3c0994d1 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 8e2b8536c8..98ea32d17f 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 135e66715e..dfe3061bae 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 68d86777aa..c350c166ba 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 0e72fa6e96..8e49a6b180 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 546cbadfbd..b642847258 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 7deb01db24..87bd95697c 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 b0f5a19461..9d79aff221 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 224da897c8..09ee056ef9 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 7dd0bd4843..a06d37cf7d 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 bf3b8cb953..645d5f688d 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 5979abcaf1..22851c4554 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 0a9c18656f..279acc4298 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 a74256356c..eabcfd0518 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 66014ad48d..b828b4e43f 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 099aaf7360..ae4fde0da1 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 fd6967bb96..f3d8c7ae3c 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 25081510cd..dd6c79cd90 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 d54e998b67..b02f72ed4c 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 7bc78c17da..86e4e48820 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 72d49b4f36..36101a7f22 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 2ef91ca3a6..f3eec86acc 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 0c099744cc..f4f979f012 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 b28134c7cd..de9ac95600 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 1273527358..dafef5e63b 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 b021190ad9..66596b3b15 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 21785278ec..e41e9157e6 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 58f7a67694..df60978510 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 3930c9714a..0c93230d46 100644 --- a/lib/std/zig/render.zig +++ b/lib/std/zig/render.zig @@ -1396,6 +1396,26 @@ fn renderBuiltinCall( try ais.writer().writeAll("@max"); } else if (mem.eql(u8, slice, "@minimum")) { try ais.writer().writeAll("@min"); + } + // + else if (mem.eql(u8, slice, "@boolToInt")) { + try ais.writer().writeAll("@intFromBool"); + } else if (mem.eql(u8, slice, "@enumToInt")) { + try ais.writer().writeAll("@intFromEnum"); + } else if (mem.eql(u8, slice, "@errorToInt")) { + try ais.writer().writeAll("@intFromError"); + } else if (mem.eql(u8, slice, "@floatToInt")) { + try ais.writer().writeAll("@intFromFloat"); + } else if (mem.eql(u8, slice, "@intToEnum")) { + try ais.writer().writeAll("@enumFromInt"); + } else if (mem.eql(u8, slice, "@intToError")) { + try ais.writer().writeAll("@errorFromInt"); + } else if (mem.eql(u8, slice, "@intToFloat")) { + try ais.writer().writeAll("@floatFromInt"); + } else if (mem.eql(u8, slice, "@intToPtr")) { + try ais.writer().writeAll("@ptrFromInt"); + } else if (mem.eql(u8, slice, "@ptrToInt")) { + try ais.writer().writeAll("@intFromPtr"); } else { try renderToken(ais, tree, builtin_token, .none); // @name } @@ -1703,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 2daac4881d..66ab620622 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 82f87b1e9a..da05c8c90d 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 6039425b1a..c5c6f052ec 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 873659e58c..b99f5cf65f 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 33fe547b57..8bc79a96c8 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, |
